Add SurfaceFlags, and more formatting :)
This commit is contained in:
@@ -63,21 +63,16 @@ seqChannel->changes.as_u8=0;
|
|||||||
#else
|
#else
|
||||||
static void sequence_channel_process_sound(struct SequenceChannel *seqChannel)
|
static void sequence_channel_process_sound(struct SequenceChannel *seqChannel)
|
||||||
{
|
{
|
||||||
f32 channelVolume;
|
f32 channelVolume = seqChannel->volume * seqChannel->volumeScale * seqChannel->seqPlayer->fadeVolume;
|
||||||
f32 panLayerWeight;
|
|
||||||
f32 panFromChannel;
|
|
||||||
s32 i;
|
|
||||||
|
|
||||||
channelVolume = seqChannel->volume * seqChannel->volumeScale * seqChannel->seqPlayer->fadeVolume;
|
|
||||||
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0)
|
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0)
|
||||||
{
|
{
|
||||||
channelVolume *= seqChannel->seqPlayer->muteVolumeScale;
|
channelVolume *= seqChannel->seqPlayer->muteVolumeScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
panFromChannel = seqChannel->pan * seqChannel->panChannelWeight;
|
f32 panFromChannel = seqChannel->pan * seqChannel->panChannelWeight;
|
||||||
panLayerWeight = US_FLOAT(1.0) - seqChannel->panChannelWeight;
|
f32 panLayerWeight = US_FLOAT(1.0) - seqChannel->panChannelWeight;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (s32 i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
struct SequenceChannelLayer *layer = seqChannel->layers[i];
|
struct SequenceChannelLayer *layer = seqChannel->layers[i];
|
||||||
if (layer != NULL && layer->enabled && layer->note != NULL)
|
if (layer != NULL && layer->enabled && layer->note != NULL)
|
||||||
@@ -92,8 +87,6 @@ static void sequence_channel_process_sound(struct SequenceChannel *seqChannel)
|
|||||||
|
|
||||||
void sequence_player_process_sound(struct SequencePlayer *seqPlayer)
|
void sequence_player_process_sound(struct SequencePlayer *seqPlayer)
|
||||||
{
|
{
|
||||||
s32 i;
|
|
||||||
|
|
||||||
if (seqPlayer->fadeRemainingFrames != 0)
|
if (seqPlayer->fadeRemainingFrames != 0)
|
||||||
{
|
{
|
||||||
seqPlayer->fadeVolume += seqPlayer->fadeVelocity;
|
seqPlayer->fadeVolume += seqPlayer->fadeVelocity;
|
||||||
@@ -145,7 +138,7 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Process channels
|
// Process channels
|
||||||
for (i = 0; i < CHANNELS_MAX; i++)
|
for (s32 i = 0; i < CHANNELS_MAX; i++)
|
||||||
{
|
{
|
||||||
if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE
|
if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE
|
||||||
&& seqPlayer->channels[i]->enabled == TRUE)
|
&& seqPlayer->channels[i]->enabled == TRUE)
|
||||||
@@ -205,10 +198,9 @@ s16 get_vibrato_pitch_change(struct VibratoState *vib)
|
|||||||
#else
|
#else
|
||||||
s8 get_vibrato_pitch_change(struct VibratoState *vib)
|
s8 get_vibrato_pitch_change(struct VibratoState *vib)
|
||||||
{
|
{
|
||||||
s32 index;
|
|
||||||
vib->time += vib->rate;
|
vib->time += vib->rate;
|
||||||
|
|
||||||
index = vib->time >> 10 & 0x3F;
|
s32 index = vib->time >> 10 & 0x3F;
|
||||||
|
|
||||||
switch (index & 0x30)
|
switch (index & 0x30)
|
||||||
{
|
{
|
||||||
@@ -233,8 +225,6 @@ s8 get_vibrato_pitch_change(struct VibratoState *vib)
|
|||||||
|
|
||||||
f32 get_vibrato_freq_scale(struct VibratoState *vib)
|
f32 get_vibrato_freq_scale(struct VibratoState *vib)
|
||||||
{
|
{
|
||||||
s32 pitchChange;
|
|
||||||
f32 extent;
|
|
||||||
f32 result;
|
f32 result;
|
||||||
|
|
||||||
if (vib->delay != 0)
|
if (vib->delay != 0)
|
||||||
@@ -291,8 +281,8 @@ f32 get_vibrato_freq_scale(struct VibratoState *vib)
|
|||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
pitchChange = get_vibrato_pitch_change(vib);
|
s32 pitchChange = get_vibrato_pitch_change(vib);
|
||||||
extent = (f32)vib->extent / US_FLOAT(4096.0);
|
f32 extent = (f32)vib->extent / US_FLOAT(4096.0);
|
||||||
|
|
||||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||||
result = US_FLOAT(1.0) + extent * (gPitchBendFrequencyScale[pitchChange + 128] - US_FLOAT(1.0));
|
result = US_FLOAT(1.0) + extent * (gPitchBendFrequencyScale[pitchChange + 128] - US_FLOAT(1.0));
|
||||||
|
|||||||
+34
-78
@@ -864,15 +864,11 @@ void create_next_audio_buffer(s16 *samples, u32 num_samples)
|
|||||||
*/
|
*/
|
||||||
static void process_sound_request(u32 bits, f32 *pos)
|
static void process_sound_request(u32 bits, f32 *pos)
|
||||||
{
|
{
|
||||||
u8 bank;
|
|
||||||
u8 soundIndex;
|
|
||||||
u8 counter = 0;
|
u8 counter = 0;
|
||||||
u8 soundId;
|
|
||||||
f32 dist;
|
|
||||||
const f32 one = 1.0f;
|
const f32 one = 1.0f;
|
||||||
|
|
||||||
bank = (bits & SOUNDARGS_MASK_BANK) >> SOUNDARGS_SHIFT_BANK;
|
u8 bank = (bits & SOUNDARGS_MASK_BANK) >> SOUNDARGS_SHIFT_BANK;
|
||||||
soundId = (bits & SOUNDARGS_MASK_SOUNDID) >> SOUNDARGS_SHIFT_SOUNDID;
|
u8 soundId = (bits & SOUNDARGS_MASK_SOUNDID) >> SOUNDARGS_SHIFT_SOUNDID;
|
||||||
|
|
||||||
if (soundId >= sNumSoundsPerBank[bank] || sSoundBankDisabled[bank])
|
if (soundId >= sNumSoundsPerBank[bank] || sSoundBankDisabled[bank])
|
||||||
{
|
{
|
||||||
@@ -880,7 +876,7 @@ static void process_sound_request(u32 bits, f32 *pos)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
soundIndex = sSoundBanks[bank][0].next;
|
u8 soundIndex = sSoundBanks[bank][0].next;
|
||||||
while (soundIndex != 0xff && soundIndex != 0)
|
while (soundIndex != 0xff && soundIndex != 0)
|
||||||
{
|
{
|
||||||
//DEBUG_PRINT("process_sound_request: soundIndex %d\n", soundIndex);
|
//DEBUG_PRINT("process_sound_request: soundIndex %d\n", soundIndex);
|
||||||
@@ -938,7 +934,7 @@ static void process_sound_request(u32 bits, f32 *pos)
|
|||||||
// Allocate from free list
|
// Allocate from free list
|
||||||
soundIndex = sSoundBankFreeListFront[bank];
|
soundIndex = sSoundBankFreeListFront[bank];
|
||||||
|
|
||||||
dist = sqrtf(pos[0] * pos[0] + pos[1] * pos[1] + pos[2] * pos[2]) * one;
|
f32 dist = sqrtf(pos[0] * pos[0] + pos[1] * pos[1] + pos[2] * pos[2]) * one;
|
||||||
sSoundBanks[bank][soundIndex].x = &pos[0];
|
sSoundBanks[bank][soundIndex].x = &pos[0];
|
||||||
sSoundBanks[bank][soundIndex].y = &pos[1];
|
sSoundBanks[bank][soundIndex].y = &pos[1];
|
||||||
sSoundBanks[bank][soundIndex].z = &pos[2];
|
sSoundBanks[bank][soundIndex].z = &pos[2];
|
||||||
@@ -965,11 +961,9 @@ static void process_sound_request(u32 bits, f32 *pos)
|
|||||||
*/
|
*/
|
||||||
static void process_all_sound_requests(void)
|
static void process_all_sound_requests(void)
|
||||||
{
|
{
|
||||||
struct Sound *sound;
|
|
||||||
|
|
||||||
while (sSoundRequestCount != sNumProcessedSoundRequests)
|
while (sSoundRequestCount != sNumProcessedSoundRequests)
|
||||||
{
|
{
|
||||||
sound = &sSoundRequests[sNumProcessedSoundRequests];
|
struct Sound *sound = &sSoundRequests[sNumProcessedSoundRequests];
|
||||||
process_sound_request(sound->soundBits, sound->position);
|
process_sound_request(sound->soundBits, sound->position);
|
||||||
sNumProcessedSoundRequests++;
|
sNumProcessedSoundRequests++;
|
||||||
//DEBUG_PRINT("processed sounds: %d\n", sNumProcessedSoundRequests);
|
//DEBUG_PRINT("processed sounds: %d\n", sNumProcessedSoundRequests);
|
||||||
@@ -1019,11 +1013,7 @@ static void update_background_music_after_sound(u8 bank, u8 soundIndex)
|
|||||||
*/
|
*/
|
||||||
static void select_current_sounds(u8 bank)
|
static void select_current_sounds(u8 bank)
|
||||||
{
|
{
|
||||||
u32 isDiscreteAndStatus;
|
|
||||||
u8 latestSoundIndex;
|
|
||||||
u8 i;
|
u8 i;
|
||||||
u8 j;
|
|
||||||
u8 soundIndex;
|
|
||||||
u32 liveSoundPriorities[16] = {
|
u32 liveSoundPriorities[16] = {
|
||||||
0x10000000, 0x10000000, 0x10000000, 0x10000000,
|
0x10000000, 0x10000000, 0x10000000, 0x10000000,
|
||||||
0x10000000, 0x10000000, 0x10000000, 0x10000000,
|
0x10000000, 0x10000000, 0x10000000, 0x10000000,
|
||||||
@@ -1039,15 +1029,14 @@ static void select_current_sounds(u8 bank)
|
|||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
|
||||||
};
|
};
|
||||||
u8 numSoundsInBank = 0;
|
u8 numSoundsInBank = 0;
|
||||||
u8 requestedPriority;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Delete stale sounds and prioritize remaining sounds into the liveSound arrays
|
// Delete stale sounds and prioritize remaining sounds into the liveSound arrays
|
||||||
//
|
//
|
||||||
soundIndex = sSoundBanks[bank][0].next;
|
u8 soundIndex = sSoundBanks[bank][0].next;
|
||||||
while (soundIndex != 0xff)
|
while (soundIndex != 0xff)
|
||||||
{
|
{
|
||||||
latestSoundIndex = soundIndex;
|
u8 latestSoundIndex = soundIndex;
|
||||||
|
|
||||||
// If a discrete sound goes 10 frames without being played (because it is too low
|
// If a discrete sound goes 10 frames without being played (because it is too low
|
||||||
// priority), then mark it for deletion
|
// priority), then mark it for deletion
|
||||||
@@ -1093,7 +1082,7 @@ static void select_current_sounds(u8 bank)
|
|||||||
+ *sSoundBanks[bank][soundIndex].z * *sSoundBanks[bank][soundIndex].z)
|
+ *sSoundBanks[bank][soundIndex].z * *sSoundBanks[bank][soundIndex].z)
|
||||||
* 1;
|
* 1;
|
||||||
|
|
||||||
requestedPriority = (sSoundBanks[bank][soundIndex].soundBits & SOUNDARGS_MASK_PRIORITY)
|
u8 requestedPriority = (sSoundBanks[bank][soundIndex].soundBits & SOUNDARGS_MASK_PRIORITY)
|
||||||
>> SOUNDARGS_SHIFT_PRIORITY;
|
>> SOUNDARGS_SHIFT_PRIORITY;
|
||||||
|
|
||||||
// Recompute priority, possibly based on the sound's source position relative to the
|
// Recompute priority, possibly based on the sound's source position relative to the
|
||||||
@@ -1127,7 +1116,7 @@ static void select_current_sounds(u8 bank)
|
|||||||
if (liveSoundPriorities[i] >= sSoundBanks[bank][soundIndex].priority)
|
if (liveSoundPriorities[i] >= sSoundBanks[bank][soundIndex].priority)
|
||||||
{
|
{
|
||||||
// Shift remaining sounds to the right
|
// Shift remaining sounds to the right
|
||||||
for (j = sMaxChannelsForSoundBank[bank] - 1; j > i; j--)
|
for (u8 j = sMaxChannelsForSoundBank[bank] - 1; j > i; j--)
|
||||||
{
|
{
|
||||||
liveSoundPriorities[j] = liveSoundPriorities[j - 1];
|
liveSoundPriorities[j] = liveSoundPriorities[j - 1];
|
||||||
liveSoundIndices[j] = liveSoundIndices[j - 1];
|
liveSoundIndices[j] = liveSoundIndices[j - 1];
|
||||||
@@ -1185,7 +1174,7 @@ static void select_current_sounds(u8 bank)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the sound is discrete and is playing, then delete it
|
// If the sound is discrete and is playing, then delete it
|
||||||
isDiscreteAndStatus = sSoundBanks[bank][sCurrentSound[bank][i]].soundBits
|
u32 isDiscreteAndStatus = sSoundBanks[bank][sCurrentSound[bank][i]].soundBits
|
||||||
& (SOUND_DISCRETE | SOUNDARGS_MASK_STATUS);
|
& (SOUND_DISCRETE | SOUNDARGS_MASK_STATUS);
|
||||||
if (isDiscreteAndStatus >= (SOUND_DISCRETE | SOUND_STATUS_PLAYING)
|
if (isDiscreteAndStatus >= (SOUND_DISCRETE | SOUND_STATUS_PLAYING)
|
||||||
&& sSoundBanks[bank][sCurrentSound[bank][i]].soundStatus != SOUND_STATUS_STOPPED)
|
&& sSoundBanks[bank][sCurrentSound[bank][i]].soundStatus != SOUND_STATUS_STOPPED)
|
||||||
@@ -1259,17 +1248,15 @@ static void select_current_sounds(u8 bank)
|
|||||||
*/
|
*/
|
||||||
static f32 get_sound_pan(f32 x, f32 z)
|
static f32 get_sound_pan(f32 x, f32 z)
|
||||||
{
|
{
|
||||||
f32 absX;
|
|
||||||
f32 absZ;
|
|
||||||
f32 pan;
|
f32 pan;
|
||||||
|
|
||||||
absX = x < 0 ? -x : x;
|
f32 absX = x < 0 ? -x : x;
|
||||||
if (absX > AUDIO_MAX_DISTANCE)
|
if (absX > AUDIO_MAX_DISTANCE)
|
||||||
{
|
{
|
||||||
absX = AUDIO_MAX_DISTANCE;
|
absX = AUDIO_MAX_DISTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
absZ = z < 0 ? -z : z;
|
f32 absZ = z < 0 ? -z : z;
|
||||||
if (absZ > AUDIO_MAX_DISTANCE)
|
if (absZ > AUDIO_MAX_DISTANCE)
|
||||||
{
|
{
|
||||||
absZ = AUDIO_MAX_DISTANCE;
|
absZ = AUDIO_MAX_DISTANCE;
|
||||||
@@ -1476,9 +1463,7 @@ void audio_signal_game_loop_tick(void)
|
|||||||
void update_game_sound(void)
|
void update_game_sound(void)
|
||||||
{
|
{
|
||||||
u8 soundStatus;
|
u8 soundStatus;
|
||||||
u8 i;
|
|
||||||
u8 soundId;
|
u8 soundId;
|
||||||
u8 bank;
|
|
||||||
u8 channelIndex = 0;
|
u8 channelIndex = 0;
|
||||||
u8 soundIndex;
|
u8 soundIndex;
|
||||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||||
@@ -1493,11 +1478,11 @@ void update_game_sound(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (bank = 0; bank < SOUND_BANK_COUNT; bank++)
|
for (u8 bank = 0; bank < SOUND_BANK_COUNT; bank++)
|
||||||
{
|
{
|
||||||
select_current_sounds(bank);
|
select_current_sounds(bank);
|
||||||
|
|
||||||
for (i = 0; i < MAX_CHANNELS_PER_SOUND_BANK; i++)
|
for (u8 i = 0; i < MAX_CHANNELS_PER_SOUND_BANK; i++)
|
||||||
{
|
{
|
||||||
soundIndex = sCurrentSound[bank][i];
|
soundIndex = sCurrentSound[bank][i];
|
||||||
|
|
||||||
@@ -1890,7 +1875,6 @@ void update_game_sound(void)
|
|||||||
void seq_player_play_sequence(u8 player, u8 seqId, u16 arg2)
|
void seq_player_play_sequence(u8 player, u8 seqId, u16 arg2)
|
||||||
{
|
{
|
||||||
u8 targetVolume;
|
u8 targetVolume;
|
||||||
u8 i;
|
|
||||||
|
|
||||||
if (player == SEQ_PLAYER_LEVEL)
|
if (player == SEQ_PLAYER_LEVEL)
|
||||||
{
|
{
|
||||||
@@ -1900,7 +1884,7 @@ void seq_player_play_sequence(u8 player, u8 seqId, u16 arg2)
|
|||||||
sMusicDynamicDelay = 2;
|
sMusicDynamicDelay = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < CHANNELS_MAX; i++)
|
for (u8 i = 0; i < CHANNELS_MAX; i++)
|
||||||
{
|
{
|
||||||
D_80360928[player][i].remainingFrames = 0;
|
D_80360928[player][i].remainingFrames = 0;
|
||||||
}
|
}
|
||||||
@@ -1968,8 +1952,7 @@ void seq_player_fade_out(u8 player, u16 fadeDuration)
|
|||||||
*/
|
*/
|
||||||
void fade_volume_scale(u8 player, u8 targetScale, u16 fadeDuration)
|
void fade_volume_scale(u8 player, u8 targetScale, u16 fadeDuration)
|
||||||
{
|
{
|
||||||
u8 i;
|
for (u8 i = 0; i < CHANNELS_MAX; i++)
|
||||||
for (i = 0; i < CHANNELS_MAX; i++)
|
|
||||||
{
|
{
|
||||||
fade_channel_volume_scale(player, i, targetScale, fadeDuration);
|
fade_channel_volume_scale(player, i, targetScale, fadeDuration);
|
||||||
}
|
}
|
||||||
@@ -1980,11 +1963,9 @@ void fade_volume_scale(u8 player, u8 targetScale, u16 fadeDuration)
|
|||||||
*/
|
*/
|
||||||
static void fade_channel_volume_scale(u8 player, u8 channelIndex, u8 targetScale, u16 fadeDuration)
|
static void fade_channel_volume_scale(u8 player, u8 channelIndex, u8 targetScale, u16 fadeDuration)
|
||||||
{
|
{
|
||||||
struct ChannelVolumeScaleFade *temp;
|
|
||||||
|
|
||||||
if (gSequencePlayers[player].channels[channelIndex] != &gSequenceChannelNone)
|
if (gSequencePlayers[player].channels[channelIndex] != &gSequenceChannelNone)
|
||||||
{
|
{
|
||||||
temp = &D_80360928[player][channelIndex];
|
struct ChannelVolumeScaleFade *temp = &D_80360928[player][channelIndex];
|
||||||
temp->remainingFrames = fadeDuration;
|
temp->remainingFrames = fadeDuration;
|
||||||
temp->velocity = (targetScale / US_FLOAT(127.0)
|
temp->velocity = (targetScale / US_FLOAT(127.0)
|
||||||
- gSequencePlayers[player].channels[channelIndex]->volumeScale)
|
- gSequencePlayers[player].channels[channelIndex]->volumeScale)
|
||||||
@@ -1999,10 +1980,8 @@ static void fade_channel_volume_scale(u8 player, u8 channelIndex, u8 targetScale
|
|||||||
*/
|
*/
|
||||||
static void func_8031F96C(u8 player)
|
static void func_8031F96C(u8 player)
|
||||||
{
|
{
|
||||||
u8 i;
|
|
||||||
|
|
||||||
// Loop over channels
|
// Loop over channels
|
||||||
for (i = 0; i < CHANNELS_MAX; i++)
|
for (u8 i = 0; i < CHANNELS_MAX; i++)
|
||||||
{
|
{
|
||||||
if (gSequencePlayers[player].channels[i] != &gSequenceChannelNone
|
if (gSequencePlayers[player].channels[i] != &gSequenceChannelNone
|
||||||
&& D_80360928[player][i].remainingFrames != 0)
|
&& D_80360928[player][i].remainingFrames != 0)
|
||||||
@@ -2037,18 +2016,12 @@ static void func_8031F96C(u8 player)
|
|||||||
*/
|
*/
|
||||||
void process_level_music_dynamics(void)
|
void process_level_music_dynamics(void)
|
||||||
{
|
{
|
||||||
u32 conditionBits;
|
|
||||||
u16 tempBits;
|
u16 tempBits;
|
||||||
UNUSED u16 pad;
|
UNUSED u16 pad;
|
||||||
u8 musicDynIndex;
|
|
||||||
u8 condIndex;
|
|
||||||
u8 i;
|
|
||||||
u8 j;
|
|
||||||
s16 conditionValues[8];
|
s16 conditionValues[8];
|
||||||
u8 conditionTypes[8];
|
u8 conditionTypes[8];
|
||||||
s16 dur1;
|
s16 dur1;
|
||||||
s16 dur2;
|
s16 dur2;
|
||||||
u16 bit;
|
|
||||||
|
|
||||||
func_8031F96C(0);
|
func_8031F96C(0);
|
||||||
func_8031F96C(2);
|
func_8031F96C(2);
|
||||||
@@ -2067,14 +2040,14 @@ void process_level_music_dynamics(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
conditionBits = sLevelDynamics[gCurrLevelNum][1] & 0xff00;
|
u32 conditionBits = sLevelDynamics[gCurrLevelNum][1] & 0xff00;
|
||||||
musicDynIndex = (u8)sLevelDynamics[gCurrLevelNum][1] & 0xff;
|
u8 musicDynIndex = (u8)sLevelDynamics[gCurrLevelNum][1] & 0xff;
|
||||||
i = 2;
|
u8 i = 2;
|
||||||
while (conditionBits & 0xff00)
|
while (conditionBits & 0xff00)
|
||||||
{
|
{
|
||||||
j = 0;
|
u8 j = 0;
|
||||||
condIndex = 0;
|
u8 condIndex = 0;
|
||||||
bit = 0x8000;
|
u16 bit = 0x8000;
|
||||||
while (j < 8)
|
while (j < 8)
|
||||||
{
|
{
|
||||||
if (conditionBits & bit)
|
if (conditionBits & bit)
|
||||||
@@ -2163,14 +2136,12 @@ void process_level_music_dynamics(void)
|
|||||||
|
|
||||||
void unused_8031FED0(u8 player, u32 bits, s8 arg2)
|
void unused_8031FED0(u8 player, u32 bits, s8 arg2)
|
||||||
{
|
{
|
||||||
u8 i;
|
|
||||||
|
|
||||||
if (arg2 < 0)
|
if (arg2 < 0)
|
||||||
{
|
{
|
||||||
arg2 = -arg2;
|
arg2 = -arg2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < CHANNELS_MAX; i++)
|
for (u8 i = 0; i < CHANNELS_MAX; i++)
|
||||||
{
|
{
|
||||||
if (gSequencePlayers[player].channels[i] != &gSequenceChannelNone)
|
if (gSequencePlayers[player].channels[i] != &gSequenceChannelNone)
|
||||||
{
|
{
|
||||||
@@ -2311,9 +2282,7 @@ static u8 begin_background_music_fade(u16 fadeDuration)
|
|||||||
*/
|
*/
|
||||||
void set_audio_muted(u8 muted)
|
void set_audio_muted(u8 muted)
|
||||||
{
|
{
|
||||||
u8 i;
|
for (u8 i = 0; i < SEQUENCE_PLAYERS; i++)
|
||||||
|
|
||||||
for (i = 0; i < SEQUENCE_PLAYERS; i++)
|
|
||||||
{
|
{
|
||||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||||
if (muted)
|
if (muted)
|
||||||
@@ -2402,10 +2371,9 @@ void sound_init(void)
|
|||||||
// (unused)
|
// (unused)
|
||||||
void get_currently_playing_sound(u8 bank, u8 *numPlayingSounds, u8 *numSoundsInBank, u8 *soundId)
|
void get_currently_playing_sound(u8 bank, u8 *numPlayingSounds, u8 *numSoundsInBank, u8 *soundId)
|
||||||
{
|
{
|
||||||
u8 i;
|
|
||||||
u8 count = 0;
|
u8 count = 0;
|
||||||
|
|
||||||
for (i = 0; i < sMaxChannelsForSoundBank[bank]; i++)
|
for (u8 i = 0; i < sMaxChannelsForSoundBank[bank]; i++)
|
||||||
{
|
{
|
||||||
if (sCurrentSound[bank][i] != 0xff)
|
if (sCurrentSound[bank][i] != 0xff)
|
||||||
{
|
{
|
||||||
@@ -2458,12 +2426,9 @@ void stop_sound(u32 soundBits, f32 *pos)
|
|||||||
*/
|
*/
|
||||||
void stop_sounds_from_source(f32 *pos)
|
void stop_sounds_from_source(f32 *pos)
|
||||||
{
|
{
|
||||||
u8 bank;
|
for (u8 bank = 0; bank < SOUND_BANK_COUNT; bank++)
|
||||||
u8 soundIndex;
|
|
||||||
|
|
||||||
for (bank = 0; bank < SOUND_BANK_COUNT; bank++)
|
|
||||||
{
|
{
|
||||||
soundIndex = sSoundBanks[bank][0].next;
|
u8 soundIndex = sSoundBanks[bank][0].next;
|
||||||
while (soundIndex != 0xff)
|
while (soundIndex != 0xff)
|
||||||
{
|
{
|
||||||
if (sSoundBanks[bank][soundIndex].x == pos)
|
if (sSoundBanks[bank][soundIndex].x == pos)
|
||||||
@@ -2510,9 +2475,7 @@ void stop_sounds_in_continuous_banks(void)
|
|||||||
*/
|
*/
|
||||||
void sound_banks_disable(UNUSED u8 player, u16 bankMask)
|
void sound_banks_disable(UNUSED u8 player, u16 bankMask)
|
||||||
{
|
{
|
||||||
u8 i;
|
for (u8 i = 0; i < SOUND_BANK_COUNT; i++)
|
||||||
|
|
||||||
for (i = 0; i < SOUND_BANK_COUNT; i++)
|
|
||||||
{
|
{
|
||||||
if (bankMask & 1)
|
if (bankMask & 1)
|
||||||
{
|
{
|
||||||
@@ -2527,9 +2490,7 @@ void sound_banks_disable(UNUSED u8 player, u16 bankMask)
|
|||||||
*/
|
*/
|
||||||
static void disable_all_sequence_players(void)
|
static void disable_all_sequence_players(void)
|
||||||
{
|
{
|
||||||
u8 i;
|
for (u8 i = 0; i < SEQUENCE_PLAYERS; i++)
|
||||||
|
|
||||||
for (i = 0; i < SEQUENCE_PLAYERS; i++)
|
|
||||||
{
|
{
|
||||||
sequence_player_disable(&gSequencePlayers[i]);
|
sequence_player_disable(&gSequencePlayers[i]);
|
||||||
}
|
}
|
||||||
@@ -2540,9 +2501,7 @@ static void disable_all_sequence_players(void)
|
|||||||
*/
|
*/
|
||||||
void sound_banks_enable(UNUSED u8 player, u16 bankMask)
|
void sound_banks_enable(UNUSED u8 player, u16 bankMask)
|
||||||
{
|
{
|
||||||
u8 i;
|
for (u8 i = 0; i < SOUND_BANK_COUNT; i++)
|
||||||
|
|
||||||
for (i = 0; i < SOUND_BANK_COUNT; i++)
|
|
||||||
{
|
{
|
||||||
if (bankMask & 1)
|
if (bankMask & 1)
|
||||||
{
|
{
|
||||||
@@ -2658,7 +2617,6 @@ void play_music(u8 player, u16 seqArgs, u16 fadeTimer)
|
|||||||
*/
|
*/
|
||||||
void stop_background_music(u16 seqId)
|
void stop_background_music(u16 seqId)
|
||||||
{
|
{
|
||||||
u8 foundIndex;
|
|
||||||
u8 i;
|
u8 i;
|
||||||
|
|
||||||
if (sBackgroundMusicQueueSize == 0)
|
if (sBackgroundMusicQueueSize == 0)
|
||||||
@@ -2668,7 +2626,7 @@ void stop_background_music(u16 seqId)
|
|||||||
|
|
||||||
// If sequence is not found, remove an empty queue item (the next empty
|
// If sequence is not found, remove an empty queue item (the next empty
|
||||||
// queue slot).
|
// queue slot).
|
||||||
foundIndex = sBackgroundMusicQueueSize;
|
u8 foundIndex = sBackgroundMusicQueueSize;
|
||||||
|
|
||||||
// Search for the sequence.
|
// Search for the sequence.
|
||||||
for (i = 0; i < sBackgroundMusicQueueSize; i++)
|
for (i = 0; i < sBackgroundMusicQueueSize; i++)
|
||||||
@@ -2829,8 +2787,6 @@ void func_80321080(u16 fadeTimer)
|
|||||||
*/
|
*/
|
||||||
void func_803210D4(u16 fadeDuration)
|
void func_803210D4(u16 fadeDuration)
|
||||||
{
|
{
|
||||||
u8 i;
|
|
||||||
|
|
||||||
if (sHasStartedFadeOut)
|
if (sHasStartedFadeOut)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -2854,7 +2810,7 @@ void func_803210D4(u16 fadeDuration)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < SOUND_BANK_COUNT; i++)
|
for (u8 i = 0; i < SOUND_BANK_COUNT; i++)
|
||||||
{
|
{
|
||||||
if (i != SOUND_BANK_MENU)
|
if (i != SOUND_BANK_MENU)
|
||||||
{
|
{
|
||||||
|
|||||||
+7
-15
@@ -236,9 +236,7 @@ void reset_bank_and_seq_load_status(void)
|
|||||||
|
|
||||||
void discard_bank(s32 bankId)
|
void discard_bank(s32 bankId)
|
||||||
{
|
{
|
||||||
s32 i;
|
for (s32 i = 0; i < gMaxSimultaneousNotes; i++)
|
||||||
|
|
||||||
for (i = 0; i < gMaxSimultaneousNotes; i++)
|
|
||||||
{
|
{
|
||||||
struct Note *note = &gNotes[i];
|
struct Note *note = &gNotes[i];
|
||||||
|
|
||||||
@@ -271,9 +269,7 @@ void discard_bank(s32 bankId)
|
|||||||
|
|
||||||
void discard_sequence(s32 seqId)
|
void discard_sequence(s32 seqId)
|
||||||
{
|
{
|
||||||
s32 i;
|
for (s32 i = 0; i < SEQUENCE_PLAYERS; i++)
|
||||||
|
|
||||||
for (i = 0; i < SEQUENCE_PLAYERS; i++)
|
|
||||||
{
|
{
|
||||||
if (gSequencePlayers[i].enabled && gSequencePlayers[i].seqId == seqId)
|
if (gSequencePlayers[i].enabled && gSequencePlayers[i].seqId == seqId)
|
||||||
{
|
{
|
||||||
@@ -289,15 +285,13 @@ void discard_sequence(s32 seqId)
|
|||||||
void *soundAlloc(struct SoundAllocPool *pool, u32 size)
|
void *soundAlloc(struct SoundAllocPool *pool, u32 size)
|
||||||
{
|
{
|
||||||
u8 *start;
|
u8 *start;
|
||||||
s32 last;
|
|
||||||
s32 i;
|
|
||||||
|
|
||||||
if (pool->cur + ALIGN16(size) <= pool->size + pool->start)
|
if (pool->cur + ALIGN16(size) <= pool->size + pool->start)
|
||||||
{
|
{
|
||||||
start = pool->cur;
|
start = pool->cur;
|
||||||
pool->cur += ALIGN16(size);
|
pool->cur += ALIGN16(size);
|
||||||
last = pool->cur - start - 1;
|
s32 last = pool->cur - start - 1;
|
||||||
for (i = 0; i <= last; i++)
|
for (s32 i = 0; i <= last; i++)
|
||||||
{
|
{
|
||||||
start[i] = 0;
|
start[i] = 0;
|
||||||
}
|
}
|
||||||
@@ -993,7 +987,6 @@ void *get_bank_or_seq_inner(s32 poolIdx, s32 arg1, s32 bankId)
|
|||||||
#ifndef VERSION_SH
|
#ifndef VERSION_SH
|
||||||
void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id)
|
void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id)
|
||||||
{
|
{
|
||||||
u32 i;
|
|
||||||
UNUSED
|
UNUSED
|
||||||
void *ret;
|
void *ret;
|
||||||
struct TemporaryPool *temporary = &arg0->temporary;
|
struct TemporaryPool *temporary = &arg0->temporary;
|
||||||
@@ -1017,7 +1010,7 @@ void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct PersistentPool *persistent = &arg0->persistent;
|
struct PersistentPool *persistent = &arg0->persistent;
|
||||||
for (i = 0; i < persistent->numEntries; i++)
|
for (u32 i = 0; i < persistent->numEntries; i++)
|
||||||
{
|
{
|
||||||
if (id == persistent->entries[i].id)
|
if (id == persistent->entries[i].id)
|
||||||
{
|
{
|
||||||
@@ -1302,8 +1295,7 @@ void audio_reset_session(void)
|
|||||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||||
s8 updatesPerFrame;
|
s8 updatesPerFrame;
|
||||||
s32 reverbWindowSize;
|
s32 reverbWindowSize;
|
||||||
s32 k;
|
#endif
|
||||||
#endif
|
|
||||||
s32 i;
|
s32 i;
|
||||||
s32 j;
|
s32 j;
|
||||||
s32 persistentMem;
|
s32 persistentMem;
|
||||||
@@ -1379,7 +1371,7 @@ void audio_reset_session(void)
|
|||||||
|
|
||||||
for (j = 0; j < NUMAIBUFFERS; j++)
|
for (j = 0; j < NUMAIBUFFERS; j++)
|
||||||
{
|
{
|
||||||
for (k = 0; k < (s32)(AIBUFFER_LEN / sizeof(s16)); k++)
|
for (s32 k = 0; k < (s32)(AIBUFFER_LEN / sizeof(s16)); k++)
|
||||||
{
|
{
|
||||||
gAiBuffers[j][k] = 0;
|
gAiBuffers[j][k] = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-51
@@ -228,16 +228,13 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef)
|
|||||||
{
|
{
|
||||||
s32 hasDma = FALSE;
|
s32 hasDma = FALSE;
|
||||||
struct SharedDma *dma;
|
struct SharedDma *dma;
|
||||||
uintptr_t dmaDevAddr;
|
|
||||||
u32 transfer;
|
|
||||||
u32 i;
|
|
||||||
u32 dmaIndex;
|
u32 dmaIndex;
|
||||||
ssize_t bufferPos;
|
ssize_t bufferPos;
|
||||||
UNUSED u32 pad;
|
UNUSED u32 pad;
|
||||||
|
|
||||||
if (arg2 != 0 || *dmaIndexRef >= sSampleDmaListSize1)
|
if (arg2 != 0 || *dmaIndexRef >= sSampleDmaListSize1)
|
||||||
{
|
{
|
||||||
for (i = sSampleDmaListSize1; i < gSampleDmaNumListItems; i++)
|
for (u32 i = sSampleDmaListSize1; i < gSampleDmaNumListItems; i++)
|
||||||
{
|
{
|
||||||
#if defined(VERSION_EU)
|
#if defined(VERSION_EU)
|
||||||
dma = &sSampleDmas[i];
|
dma = &sSampleDmas[i];
|
||||||
@@ -329,8 +326,8 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef)
|
|||||||
hasDma = TRUE;
|
hasDma = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
transfer = dma->bufSize;
|
u32 transfer = dma->bufSize;
|
||||||
dmaDevAddr = devAddr & ~0xF;
|
uintptr_t dmaDevAddr = devAddr & ~0xF;
|
||||||
dma->ttl = 2;
|
dma->ttl = 2;
|
||||||
dma->source = dmaDevAddr;
|
dma->source = dmaDevAddr;
|
||||||
dma->sizeUnused = transfer;
|
dma->sizeUnused = transfer;
|
||||||
@@ -461,7 +458,6 @@ UNUSED static
|
|||||||
#endif
|
#endif
|
||||||
void patch_sound(UNUSED struct AudioBankSound *sound, UNUSED u8 *memBase, UNUSED u8 *offsetBase)
|
void patch_sound(UNUSED struct AudioBankSound *sound, UNUSED u8 *memBase, UNUSED u8 *offsetBase)
|
||||||
{
|
{
|
||||||
struct AudioBankSample *sample;
|
|
||||||
void *patched;
|
void *patched;
|
||||||
UNUSED u8 *mem; // unused on US
|
UNUSED u8 *mem; // unused on US
|
||||||
|
|
||||||
@@ -469,7 +465,7 @@ void patch_sound(UNUSED struct AudioBankSound *sound, UNUSED u8 *memBase, UNUSED
|
|||||||
|
|
||||||
if (sound->sample != NULL)
|
if (sound->sample != NULL)
|
||||||
{
|
{
|
||||||
sample = sound->sample = PATCH(sound->sample, memBase);
|
struct AudioBankSample *sample = sound->sample = PATCH(sound->sample, memBase);
|
||||||
if (sample->loaded == 0)
|
if (sample->loaded == 0)
|
||||||
{
|
{
|
||||||
sample->sampleAddr = PATCH(sample->sampleAddr, offsetBase);
|
sample->sampleAddr = PATCH(sample->sampleAddr, offsetBase);
|
||||||
@@ -537,7 +533,6 @@ void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32
|
|||||||
struct Instrument **itInstrs;
|
struct Instrument **itInstrs;
|
||||||
struct Instrument **end;
|
struct Instrument **end;
|
||||||
struct AudioBank *temp;
|
struct AudioBank *temp;
|
||||||
u32 i;
|
|
||||||
void *patched;
|
void *patched;
|
||||||
struct Drum *drum;
|
struct Drum *drum;
|
||||||
struct Drum **drums;
|
struct Drum **drums;
|
||||||
@@ -561,7 +556,7 @@ void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32
|
|||||||
{
|
{
|
||||||
mem->drums = (void *)((uintptr_t)drums + (uintptr_t)mem);
|
mem->drums = (void *)((uintptr_t)drums + (uintptr_t)mem);
|
||||||
if (numDrums > 0) //! unneeded when -sopt is enabled
|
if (numDrums > 0) //! unneeded when -sopt is enabled
|
||||||
for (i = 0; i < numDrums; i++)
|
for (u32 i = 0; i < numDrums; i++)
|
||||||
{
|
{
|
||||||
#else
|
#else
|
||||||
numDrums2 = numDrums;
|
numDrums2 = numDrums;
|
||||||
@@ -603,9 +598,8 @@ void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32
|
|||||||
if (numInstruments > 0)
|
if (numInstruments > 0)
|
||||||
{
|
{
|
||||||
//! Doesn't affect EU, but required for US/JP
|
//! Doesn't affect EU, but required for US/JP
|
||||||
struct Instrument **tempInst;
|
|
||||||
itInstrs = temp->instruments;
|
itInstrs = temp->instruments;
|
||||||
tempInst = temp->instruments;
|
struct Instrument **tempInst = temp->instruments;
|
||||||
end = numInstruments + tempInst;
|
end = numInstruments + tempInst;
|
||||||
|
|
||||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||||
@@ -656,22 +650,18 @@ struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1)
|
|||||||
|
|
||||||
UNUSED u32 pad1[4];
|
UNUSED u32 pad1[4];
|
||||||
u32 buf[4];
|
u32 buf[4];
|
||||||
u32 numInstruments, numDrums;
|
|
||||||
struct AudioBank *ret;
|
|
||||||
u8 *ctlData;
|
|
||||||
s32 alloc;
|
|
||||||
|
|
||||||
// (This is broken if the length is 1 (mod 16), but that never happens --
|
// (This is broken if the length is 1 (mod 16), but that never happens --
|
||||||
// it's always divisible by 4.)
|
// it's always divisible by 4.)
|
||||||
DEBUG_PRINT("- getting alloc");
|
DEBUG_PRINT("- getting alloc");
|
||||||
alloc = gAlCtlHeader->seqArray[bankId].len + 0xf;
|
s32 alloc = gAlCtlHeader->seqArray[bankId].len + 0xf;
|
||||||
DEBUG_PRINT("- aligning");
|
DEBUG_PRINT("- aligning");
|
||||||
alloc = ALIGN16(alloc);
|
alloc = ALIGN16(alloc);
|
||||||
alloc -= 0x10;
|
alloc -= 0x10;
|
||||||
DEBUG_PRINT("- getting ctl data for bank %d", bankId);
|
DEBUG_PRINT("- getting ctl data for bank %d", bankId);
|
||||||
ctlData = gAlCtlHeader->seqArray[bankId].offset;
|
u8 *ctlData = gAlCtlHeader->seqArray[bankId].offset;
|
||||||
DEBUG_PRINT("- alloc bank or seq");
|
DEBUG_PRINT("- alloc bank or seq");
|
||||||
ret = alloc_bank_or_seq(&gBankLoadedPool, 1, alloc, arg1, bankId);
|
struct AudioBank *ret = alloc_bank_or_seq(&gBankLoadedPool, 1, alloc, arg1, bankId);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -681,8 +671,8 @@ struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1)
|
|||||||
DEBUG_PRINT("- ctlData: %x", ctlData);
|
DEBUG_PRINT("- ctlData: %x", ctlData);
|
||||||
audio_dma_copy_immediate((uintptr_t)ctlData, buf, 0x10);
|
audio_dma_copy_immediate((uintptr_t)ctlData, buf, 0x10);
|
||||||
DEBUG_PRINT("- getting nums");
|
DEBUG_PRINT("- getting nums");
|
||||||
numInstruments = buf[0];
|
u32 numInstruments = buf[0];
|
||||||
numDrums = buf[1];
|
u32 numDrums = buf[1];
|
||||||
DEBUG_PRINT("- copying dma immediate 2");
|
DEBUG_PRINT("- copying dma immediate 2");
|
||||||
audio_dma_copy_immediate((uintptr_t)(ctlData + 0x10), ret, alloc);
|
audio_dma_copy_immediate((uintptr_t)(ctlData + 0x10), ret, alloc);
|
||||||
DEBUG_PRINT("- patching bank");
|
DEBUG_PRINT("- patching bank");
|
||||||
@@ -757,14 +747,10 @@ struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *s
|
|||||||
|
|
||||||
void *sequence_dma_immediate(s32 seqId, s32 arg1)
|
void *sequence_dma_immediate(s32 seqId, s32 arg1)
|
||||||
{
|
{
|
||||||
s32 seqLength;
|
s32 seqLength = gSeqFileHeader->seqArray[seqId].len + 0xf;
|
||||||
void *ptr;
|
|
||||||
u8 *seqData;
|
|
||||||
|
|
||||||
seqLength = gSeqFileHeader->seqArray[seqId].len + 0xf;
|
|
||||||
seqLength = ALIGN16(seqLength);
|
seqLength = ALIGN16(seqLength);
|
||||||
seqData = gSeqFileHeader->seqArray[seqId].offset;
|
u8 *seqData = gSeqFileHeader->seqArray[seqId].offset;
|
||||||
ptr = alloc_bank_or_seq(&gSeqLoadedPool, 1, seqLength, arg1, seqId);
|
void *ptr = alloc_bank_or_seq(&gSeqLoadedPool, 1, seqLength, arg1, seqId);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -777,16 +763,11 @@ void *sequence_dma_immediate(s32 seqId, s32 arg1)
|
|||||||
|
|
||||||
void *sequence_dma_async(s32 seqId, s32 arg1, struct SequencePlayer *seqPlayer)
|
void *sequence_dma_async(s32 seqId, s32 arg1, struct SequencePlayer *seqPlayer)
|
||||||
{
|
{
|
||||||
s32 seqLength;
|
|
||||||
void *ptr;
|
|
||||||
u8 *seqData;
|
|
||||||
OSMesgQueue *mesgQueue;
|
|
||||||
|
|
||||||
eu_stubbed_printf_1("Seq %d Loading Start\n", seqId);
|
eu_stubbed_printf_1("Seq %d Loading Start\n", seqId);
|
||||||
seqLength = gSeqFileHeader->seqArray[seqId].len + 0xf;
|
s32 seqLength = gSeqFileHeader->seqArray[seqId].len + 0xf;
|
||||||
seqLength = ALIGN16(seqLength);
|
seqLength = ALIGN16(seqLength);
|
||||||
seqData = gSeqFileHeader->seqArray[seqId].offset;
|
u8 *seqData = gSeqFileHeader->seqArray[seqId].offset;
|
||||||
ptr = alloc_bank_or_seq(&gSeqLoadedPool, 1, seqLength, arg1, seqId);
|
void *ptr = alloc_bank_or_seq(&gSeqLoadedPool, 1, seqLength, arg1, seqId);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
{
|
{
|
||||||
eu_stubbed_printf_0("Heap Overflow Error\n");
|
eu_stubbed_printf_0("Heap Overflow Error\n");
|
||||||
@@ -805,7 +786,7 @@ void *sequence_dma_async(s32 seqId, s32 arg1, struct SequencePlayer *seqPlayer)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
audio_dma_copy_immediate((uintptr_t)seqData, ptr, 0x40);
|
audio_dma_copy_immediate((uintptr_t)seqData, ptr, 0x40);
|
||||||
mesgQueue = &seqPlayer->seqDmaMesgQueue;
|
OSMesgQueue *mesgQueue = &seqPlayer->seqDmaMesgQueue;
|
||||||
osCreateMesgQueue(mesgQueue, &seqPlayer->seqDmaMesg, 1);
|
osCreateMesgQueue(mesgQueue, &seqPlayer->seqDmaMesg, 1);
|
||||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||||
seqPlayer->seqDmaMesg = NULL;
|
seqPlayer->seqDmaMesg = NULL;
|
||||||
@@ -873,11 +854,10 @@ struct AudioBank *load_banks_immediate(s32 seqId, u8 *outDefaultBank)
|
|||||||
DEBUG_PRINT("load_banks_immediate()");
|
DEBUG_PRINT("load_banks_immediate()");
|
||||||
void *ret;
|
void *ret;
|
||||||
u32 bankId;
|
u32 bankId;
|
||||||
u16 offset;
|
|
||||||
u8 i;
|
u8 i;
|
||||||
|
|
||||||
DEBUG_PRINT("- getting offset");
|
DEBUG_PRINT("- getting offset");
|
||||||
offset = ((u16 *)gAlBankSets)[seqId];
|
u16 offset = ((u16 *)gAlBankSets)[seqId];
|
||||||
#ifdef VERSION_EU
|
#ifdef VERSION_EU
|
||||||
for (i = gAlBankSets[offset++]; i != 0; i--)
|
for (i = gAlBankSets[offset++]; i != 0; i--)
|
||||||
{
|
{
|
||||||
@@ -977,7 +957,6 @@ void load_sequence(u32 player, u32 seqId, s32 loadAsync)
|
|||||||
|
|
||||||
void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync)
|
void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync)
|
||||||
{
|
{
|
||||||
void *sequenceData;
|
|
||||||
struct SequencePlayer *seqPlayer = &gSequencePlayers[player];
|
struct SequencePlayer *seqPlayer = &gSequencePlayers[player];
|
||||||
UNUSED u32 padding[2];
|
UNUSED u32 padding[2];
|
||||||
|
|
||||||
@@ -1022,7 +1001,7 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync)
|
|||||||
eu_stubbed_printf_0("Seq Loading Start\n");
|
eu_stubbed_printf_0("Seq Loading Start\n");
|
||||||
|
|
||||||
seqPlayer->seqId = seqId;
|
seqPlayer->seqId = seqId;
|
||||||
sequenceData = get_bank_or_seq(&gSeqLoadedPool, 2, seqId);
|
void *sequenceData = get_bank_or_seq(&gSeqLoadedPool, 2, seqId);
|
||||||
if (sequenceData == NULL)
|
if (sequenceData == NULL)
|
||||||
{
|
{
|
||||||
if (seqPlayer->seqDmaInProgress)
|
if (seqPlayer->seqDmaInProgress)
|
||||||
@@ -1061,18 +1040,16 @@ void audio_init()
|
|||||||
DEBUG_PRINT("audio_init()");
|
DEBUG_PRINT("audio_init()");
|
||||||
UNUSED s8 pad[32];
|
UNUSED s8 pad[32];
|
||||||
u8 buf[0x10];
|
u8 buf[0x10];
|
||||||
s32 i, j, UNUSED k;
|
s32 i, UNUSED k;
|
||||||
UNUSED s32 lim1; // lim1 unused in EU
|
// lim1 unused in EU
|
||||||
s32 lim2, UNUSED lim3;
|
s32 UNUSED lim3;
|
||||||
UNUSED u32 size;
|
|
||||||
UNUSED u64 *ptr64;
|
UNUSED u64 *ptr64;
|
||||||
void *data;
|
|
||||||
UNUSED s32 pad2;
|
UNUSED s32 pad2;
|
||||||
|
|
||||||
gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED;
|
gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED;
|
||||||
|
|
||||||
DEBUG_PRINT("- setting values in unused");
|
DEBUG_PRINT("- setting values in unused");
|
||||||
lim1 = gUnusedCount80333EE8;
|
s32 lim1 = gUnusedCount80333EE8;
|
||||||
for (i = 0; i < lim1; i++)
|
for (i = 0; i < lim1; i++)
|
||||||
{
|
{
|
||||||
gUnused80226E58[i] = 0;
|
gUnused80226E58[i] = 0;
|
||||||
@@ -1080,7 +1057,7 @@ void audio_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_PRINT("- clearing audio heap");
|
DEBUG_PRINT("- clearing audio heap");
|
||||||
lim2 = gAudioHeapSize;
|
s32 lim2 = gAudioHeapSize;
|
||||||
for (i = 0; i <= lim2 / 8 - 1; i++)
|
for (i = 0; i <= lim2 / 8 - 1; i++)
|
||||||
{
|
{
|
||||||
((u64 *)gAudioHeap)[i] = 0;
|
((u64 *)gAudioHeap)[i] = 0;
|
||||||
@@ -1113,7 +1090,7 @@ void audio_init()
|
|||||||
{
|
{
|
||||||
gAiBuffers[i] = soundAlloc(&gAudioInitPool, AIBUFFER_LEN);
|
gAiBuffers[i] = soundAlloc(&gAudioInitPool, AIBUFFER_LEN);
|
||||||
|
|
||||||
for (j = 0; j < (s32)(AIBUFFER_LEN / sizeof(s16)); j++)
|
for (s32 j = 0; j < (s32)(AIBUFFER_LEN / sizeof(s16)); j++)
|
||||||
{
|
{
|
||||||
gAiBuffers[i][j] = 0;
|
gAiBuffers[i][j] = 0;
|
||||||
}
|
}
|
||||||
@@ -1128,10 +1105,10 @@ void audio_init()
|
|||||||
|
|
||||||
// Load headers for sounds and sequences
|
// Load headers for sounds and sequences
|
||||||
gSeqFileHeader = (ALSeqFile *)buf;
|
gSeqFileHeader = (ALSeqFile *)buf;
|
||||||
data = gMusicData;
|
void *data = gMusicData;
|
||||||
audio_dma_copy_immediate((uintptr_t)data, gSeqFileHeader, 0x10);
|
audio_dma_copy_immediate((uintptr_t)data, gSeqFileHeader, 0x10);
|
||||||
gSequenceCount = gSeqFileHeader->seqCount;
|
gSequenceCount = gSeqFileHeader->seqCount;
|
||||||
size = ALIGN16(gSequenceCount * sizeof(ALSeqData) + 4);
|
u32 size = ALIGN16(gSequenceCount * sizeof(ALSeqData) + 4);
|
||||||
gSeqFileHeader = soundAlloc(&gAudioInitPool, size);
|
gSeqFileHeader = soundAlloc(&gAudioInitPool, size);
|
||||||
audio_dma_copy_immediate((uintptr_t)data, gSeqFileHeader, size);
|
audio_dma_copy_immediate((uintptr_t)data, gSeqFileHeader, size);
|
||||||
alSeqFileNew(gSeqFileHeader, data);
|
alSeqFileNew(gSeqFileHeader, data);
|
||||||
|
|||||||
+11
-25
@@ -400,7 +400,6 @@ void process_notes(void)
|
|||||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||||
struct AudioListItem *it;
|
struct AudioListItem *it;
|
||||||
#endif
|
#endif
|
||||||
s32 i;
|
|
||||||
|
|
||||||
// Macro versions of audio_list_push_front and audio_list_remove.
|
// Macro versions of audio_list_push_front and audio_list_remove.
|
||||||
// Should ideally be changed to use copt.
|
// Should ideally be changed to use copt.
|
||||||
@@ -414,7 +413,7 @@ void process_notes(void)
|
|||||||
? it \
|
? it \
|
||||||
: (it->prev->next = it->next, it->next->prev = it->prev, it->prev = NULL, it))
|
: (it->prev->next = it->next, it->next->prev = it->prev, it->prev = NULL, it))
|
||||||
|
|
||||||
for (i = 0; i < gMaxSimultaneousNotes; i++)
|
for (s32 i = 0; i < gMaxSimultaneousNotes; i++)
|
||||||
{
|
{
|
||||||
note = &gNotes[i];
|
note = &gNotes[i];
|
||||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||||
@@ -980,8 +979,6 @@ void build_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLay
|
|||||||
s32 j;
|
s32 j;
|
||||||
s32 pos;
|
s32 pos;
|
||||||
s32 stepSize;
|
s32 stepSize;
|
||||||
s32 offset;
|
|
||||||
u8 lim;
|
|
||||||
u8 origSampleCount = note->sampleCount;
|
u8 origSampleCount = note->sampleCount;
|
||||||
|
|
||||||
if (seqLayer->freqScale < US_FLOAT(1.0))
|
if (seqLayer->freqScale < US_FLOAT(1.0))
|
||||||
@@ -1023,9 +1020,9 @@ void build_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLay
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Repeat sample
|
// Repeat sample
|
||||||
for (offset = note->sampleCount; offset < 0x40; offset += note->sampleCount)
|
for (s32 offset = note->sampleCount; offset < 0x40; offset += note->sampleCount)
|
||||||
{
|
{
|
||||||
lim = note->sampleCount;
|
u8 lim = note->sampleCount;
|
||||||
if (offset < 0 || offset > 0)
|
if (offset < 0 || offset > 0)
|
||||||
{
|
{
|
||||||
for (j = 0; j < lim; j++)
|
for (j = 0; j < lim; j++)
|
||||||
@@ -1098,10 +1095,8 @@ void init_note_lists(struct NotePool *pool)
|
|||||||
|
|
||||||
void init_note_free_list(void)
|
void init_note_free_list(void)
|
||||||
{
|
{
|
||||||
s32 i;
|
|
||||||
|
|
||||||
init_note_lists(&gNoteFreeLists);
|
init_note_lists(&gNoteFreeLists);
|
||||||
for (i = 0; i < gMaxSimultaneousNotes; i++)
|
for (s32 i = 0; i < gMaxSimultaneousNotes; i++)
|
||||||
{
|
{
|
||||||
gNotes[i].listItem.u.value = &gNotes[i];
|
gNotes[i].listItem.u.value = &gNotes[i];
|
||||||
gNotes[i].listItem.prev = NULL;
|
gNotes[i].listItem.prev = NULL;
|
||||||
@@ -1111,13 +1106,12 @@ void init_note_free_list(void)
|
|||||||
|
|
||||||
void note_pool_clear(struct NotePool *pool)
|
void note_pool_clear(struct NotePool *pool)
|
||||||
{
|
{
|
||||||
s32 i;
|
|
||||||
struct AudioListItem *source;
|
struct AudioListItem *source;
|
||||||
struct AudioListItem *cur;
|
struct AudioListItem *cur;
|
||||||
struct AudioListItem *dest;
|
struct AudioListItem *dest;
|
||||||
UNUSED s32 j; // unused in EU
|
UNUSED s32 j; // unused in EU
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (s32 i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
@@ -1180,7 +1174,6 @@ void note_pool_fill(struct NotePool *pool, s32 count)
|
|||||||
{
|
{
|
||||||
s32 i;
|
s32 i;
|
||||||
s32 j;
|
s32 j;
|
||||||
struct Note *note;
|
|
||||||
struct AudioListItem *source;
|
struct AudioListItem *source;
|
||||||
struct AudioListItem *dest;
|
struct AudioListItem *dest;
|
||||||
|
|
||||||
@@ -1219,7 +1212,7 @@ void note_pool_fill(struct NotePool *pool, s32 count)
|
|||||||
|
|
||||||
while (j < count)
|
while (j < count)
|
||||||
{
|
{
|
||||||
note = audio_list_pop_back(source);
|
struct Note *note = audio_list_pop_back(source);
|
||||||
if (note == NULL)
|
if (note == NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -1593,16 +1586,12 @@ null_return: seqLayer->status = SOUND_LOAD_STATUS_NOT_LOADED;
|
|||||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||||
void reclaim_notes(void)
|
void reclaim_notes(void)
|
||||||
{
|
{
|
||||||
struct Note *note;
|
for (s32 i = 0; i < gMaxSimultaneousNotes; i++)
|
||||||
s32 i;
|
|
||||||
s32 cond;
|
|
||||||
|
|
||||||
for (i = 0; i < gMaxSimultaneousNotes; i++)
|
|
||||||
{
|
{
|
||||||
note = &gNotes[i];
|
struct Note *note = &gNotes[i];
|
||||||
if (note->parentLayer != NO_LAYER)
|
if (note->parentLayer != NO_LAYER)
|
||||||
{
|
{
|
||||||
cond = FALSE;
|
s32 cond = FALSE;
|
||||||
if (!note->parentLayer->enabled && note->priority >= NOTE_PRIORITY_MIN)
|
if (!note->parentLayer->enabled && note->priority >= NOTE_PRIORITY_MIN)
|
||||||
{
|
{
|
||||||
cond = TRUE;
|
cond = TRUE;
|
||||||
@@ -1645,12 +1634,9 @@ void reclaim_notes(void)
|
|||||||
|
|
||||||
void note_init_all(void)
|
void note_init_all(void)
|
||||||
{
|
{
|
||||||
struct Note *note;
|
for (s32 i = 0; i < gMaxSimultaneousNotes; i++)
|
||||||
s32 i;
|
|
||||||
|
|
||||||
for (i = 0; i < gMaxSimultaneousNotes; i++)
|
|
||||||
{
|
{
|
||||||
note = &gNotes[i];
|
struct Note *note = &gNotes[i];
|
||||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||||
note->noteSubEu = gZeroNoteSub;
|
note->noteSubEu = gZeroNoteSub;
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ u8 get_instrument(
|
|||||||
|
|
||||||
void sequence_channel_init(struct SequenceChannel *seqChannel)
|
void sequence_channel_init(struct SequenceChannel *seqChannel)
|
||||||
{
|
{
|
||||||
s32 i;
|
|
||||||
|
|
||||||
seqChannel->enabled = FALSE;
|
seqChannel->enabled = FALSE;
|
||||||
seqChannel->finished = FALSE;
|
seqChannel->finished = FALSE;
|
||||||
seqChannel->stopScript = FALSE;
|
seqChannel->stopScript = FALSE;
|
||||||
@@ -91,7 +89,7 @@ void sequence_channel_init(struct SequenceChannel *seqChannel)
|
|||||||
seqChannel->freqScale = 1.0f;
|
seqChannel->freqScale = 1.0f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < 8; i++)
|
for (s32 i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
seqChannel->soundScriptIO[i] = -1;
|
seqChannel->soundScriptIO[i] = -1;
|
||||||
}
|
}
|
||||||
@@ -200,8 +198,7 @@ void seq_channel_layer_free(struct SequenceChannel *seqChannel, s32 layerIndex)
|
|||||||
|
|
||||||
void sequence_channel_disable(struct SequenceChannel *seqChannel)
|
void sequence_channel_disable(struct SequenceChannel *seqChannel)
|
||||||
{
|
{
|
||||||
s32 i;
|
for (s32 i = 0; i < LAYERS_MAX; i++)
|
||||||
for (i = 0; i < LAYERS_MAX; i++)
|
|
||||||
{
|
{
|
||||||
seq_channel_layer_free(seqChannel, i);
|
seq_channel_layer_free(seqChannel, i);
|
||||||
}
|
}
|
||||||
@@ -213,8 +210,7 @@ void sequence_channel_disable(struct SequenceChannel *seqChannel)
|
|||||||
|
|
||||||
struct SequenceChannel *allocate_sequence_channel(void)
|
struct SequenceChannel *allocate_sequence_channel(void)
|
||||||
{
|
{
|
||||||
s32 i;
|
for (s32 i = 0; i < ARRAY_COUNT(gSequenceChannels); i++)
|
||||||
for (i = 0; i < ARRAY_COUNT(gSequenceChannels); i++)
|
|
||||||
{
|
{
|
||||||
if (gSequenceChannels[i].seqPlayer == NULL)
|
if (gSequenceChannels[i].seqPlayer == NULL)
|
||||||
{
|
{
|
||||||
@@ -230,14 +226,11 @@ struct SequenceChannel *allocate_sequence_channel(void)
|
|||||||
|
|
||||||
void sequence_player_init_channels(struct SequencePlayer *seqPlayer, u16 channelBits)
|
void sequence_player_init_channels(struct SequencePlayer *seqPlayer, u16 channelBits)
|
||||||
{
|
{
|
||||||
struct SequenceChannel *seqChannel;
|
for (s32 i = 0; i < CHANNELS_MAX; i++)
|
||||||
s32 i;
|
|
||||||
|
|
||||||
for (i = 0; i < CHANNELS_MAX; i++)
|
|
||||||
{
|
{
|
||||||
if (channelBits & 1)
|
if (channelBits & 1)
|
||||||
{
|
{
|
||||||
seqChannel = seqPlayer->channels[i];
|
struct SequenceChannel *seqChannel = seqPlayer->channels[i];
|
||||||
if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == TRUE && seqChannel->seqPlayer == seqPlayer)
|
if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == TRUE && seqChannel->seqPlayer == seqPlayer)
|
||||||
{
|
{
|
||||||
sequence_channel_disable(seqChannel);
|
sequence_channel_disable(seqChannel);
|
||||||
@@ -270,15 +263,12 @@ void sequence_player_init_channels(struct SequencePlayer *seqPlayer, u16 channel
|
|||||||
|
|
||||||
void sequence_player_disable_channels(struct SequencePlayer *seqPlayer, u16 channelBits)
|
void sequence_player_disable_channels(struct SequencePlayer *seqPlayer, u16 channelBits)
|
||||||
{
|
{
|
||||||
struct SequenceChannel *seqChannel;
|
|
||||||
s32 i;
|
|
||||||
|
|
||||||
eu_stubbed_printf_0("SUBTRACK DIM\n");
|
eu_stubbed_printf_0("SUBTRACK DIM\n");
|
||||||
for (i = 0; i < CHANNELS_MAX; i++)
|
for (s32 i = 0; i < CHANNELS_MAX; i++)
|
||||||
{
|
{
|
||||||
if (channelBits & 1)
|
if (channelBits & 1)
|
||||||
{
|
{
|
||||||
seqChannel = seqPlayer->channels[i];
|
struct SequenceChannel *seqChannel = seqPlayer->channels[i];
|
||||||
if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == TRUE)
|
if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == TRUE)
|
||||||
{
|
{
|
||||||
if (seqChannel->seqPlayer == seqPlayer)
|
if (seqChannel->seqPlayer == seqPlayer)
|
||||||
@@ -307,7 +297,6 @@ void sequence_player_disable_channels(struct SequencePlayer *seqPlayer, u16 chan
|
|||||||
void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex, void *script)
|
void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex, void *script)
|
||||||
{
|
{
|
||||||
struct SequenceChannel *seqChannel = seqPlayer->channels[channelIndex];
|
struct SequenceChannel *seqChannel = seqPlayer->channels[channelIndex];
|
||||||
s32 i;
|
|
||||||
if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == FALSE)
|
if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == FALSE)
|
||||||
{
|
{
|
||||||
#ifdef VERSION_EU
|
#ifdef VERSION_EU
|
||||||
@@ -337,7 +326,7 @@ void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex,
|
|||||||
seqChannel->scriptState.depth = 0;
|
seqChannel->scriptState.depth = 0;
|
||||||
seqChannel->scriptState.pc = script;
|
seqChannel->scriptState.pc = script;
|
||||||
seqChannel->delay = 0;
|
seqChannel->delay = 0;
|
||||||
for (i = 0; i < LAYERS_MAX; i++)
|
for (s32 i = 0; i < LAYERS_MAX; i++)
|
||||||
{
|
{
|
||||||
if (seqChannel->layers[i] != NULL)
|
if (seqChannel->layers[i] != NULL)
|
||||||
{
|
{
|
||||||
@@ -439,14 +428,12 @@ void *audio_list_pop_back(struct AudioListItem *list)
|
|||||||
|
|
||||||
void init_layer_freelist(void)
|
void init_layer_freelist(void)
|
||||||
{
|
{
|
||||||
s32 i;
|
|
||||||
|
|
||||||
gLayerFreeList.prev = &gLayerFreeList;
|
gLayerFreeList.prev = &gLayerFreeList;
|
||||||
gLayerFreeList.next = &gLayerFreeList;
|
gLayerFreeList.next = &gLayerFreeList;
|
||||||
gLayerFreeList.u.count = 0;
|
gLayerFreeList.u.count = 0;
|
||||||
gLayerFreeList.pool = NULL;
|
gLayerFreeList.pool = NULL;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_COUNT(gSequenceLayers); i++)
|
for (s32 i = 0; i < ARRAY_COUNT(gSequenceLayers); i++)
|
||||||
{
|
{
|
||||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||||
gSequenceLayers[i].listItem.u.value = &gSequenceLayers[i];
|
gSequenceLayers[i].listItem.u.value = &gSequenceLayers[i];
|
||||||
@@ -1673,9 +1660,6 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel)
|
|||||||
{
|
{
|
||||||
DEBUG_PRINT("sequence_channel_process_script()");
|
DEBUG_PRINT("sequence_channel_process_script()");
|
||||||
|
|
||||||
struct M64ScriptState *state;
|
|
||||||
struct SequencePlayer *seqPlayer;
|
|
||||||
u8 cmd;
|
|
||||||
s8 temp;
|
s8 temp;
|
||||||
u8 loBits;
|
u8 loBits;
|
||||||
u16 sp5A;
|
u16 sp5A;
|
||||||
@@ -1701,7 +1685,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
seqPlayer = seqChannel->seqPlayer;
|
struct SequencePlayer *seqPlayer = seqChannel->seqPlayer;
|
||||||
if (seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_STOP_SCRIPT) != 0)
|
if (seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_STOP_SCRIPT) != 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -1712,12 +1696,12 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel)
|
|||||||
seqChannel->delay--;
|
seqChannel->delay--;
|
||||||
}
|
}
|
||||||
|
|
||||||
state = &seqChannel->scriptState;
|
struct M64ScriptState *state = &seqChannel->scriptState;
|
||||||
if (seqChannel->delay == 0)
|
if (seqChannel->delay == 0)
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
cmd = m64_read_u8(state);
|
u8 cmd = m64_read_u8(state);
|
||||||
DEBUG_PRINT("- handling command: %x", cmd);
|
DEBUG_PRINT("- handling command: %x", cmd);
|
||||||
|
|
||||||
#if !defined(VERSION_EU) && !defined(VERSION_SH)
|
#if !defined(VERSION_EU) && !defined(VERSION_SH)
|
||||||
@@ -2073,11 +2057,10 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel)
|
|||||||
case 0xc7: // chan_writeseq; write to sequence data (!)
|
case 0xc7: // chan_writeseq; write to sequence data (!)
|
||||||
{
|
{
|
||||||
#if !defined(VERSION_EU) && !defined(VERSION_SH)
|
#if !defined(VERSION_EU) && !defined(VERSION_SH)
|
||||||
u8 *seqData;
|
|
||||||
#endif
|
#endif
|
||||||
cmd = m64_read_u8(state);
|
cmd = m64_read_u8(state);
|
||||||
sp5A = m64_read_s16(state);
|
sp5A = m64_read_s16(state);
|
||||||
seqData = seqPlayer->seqData + sp5A;
|
u8 *seqData = seqPlayer->seqData + sp5A;
|
||||||
*seqData = (u8)value + cmd;
|
*seqData = (u8)value + cmd;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2489,7 +2472,6 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer)
|
|||||||
u8 loBits;
|
u8 loBits;
|
||||||
u8 temp;
|
u8 temp;
|
||||||
s32 value;
|
s32 value;
|
||||||
s32 i;
|
|
||||||
u16 u16v;
|
u16 u16v;
|
||||||
u8 *seqData;
|
u8 *seqData;
|
||||||
struct M64ScriptState *state;
|
struct M64ScriptState *state;
|
||||||
@@ -3029,7 +3011,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < CHANNELS_MAX; i++)
|
for (s32 i = 0; i < CHANNELS_MAX; i++)
|
||||||
{
|
{
|
||||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||||
if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE)
|
if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE)
|
||||||
@@ -3048,8 +3030,7 @@ void sequence_player_process_sequence(struct SequencePlayer *seqPlayer)
|
|||||||
// This runs 240 times per second.
|
// This runs 240 times per second.
|
||||||
void process_sequences(UNUSED s32 iterationsRemaining)
|
void process_sequences(UNUSED s32 iterationsRemaining)
|
||||||
{
|
{
|
||||||
s32 i;
|
for (s32 i = 0; i < SEQUENCE_PLAYERS; i++)
|
||||||
for (i = 0; i < SEQUENCE_PLAYERS; i++)
|
|
||||||
{
|
{
|
||||||
if (gSequencePlayers[i].enabled == TRUE)
|
if (gSequencePlayers[i].enabled == TRUE)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -171,9 +171,6 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex)
|
|||||||
struct ReverbRingBufferItem *item;
|
struct ReverbRingBufferItem *item;
|
||||||
s32 srcPos;
|
s32 srcPos;
|
||||||
s32 dstPos;
|
s32 dstPos;
|
||||||
s32 nSamples;
|
|
||||||
s32 numSamplesAfterDownsampling;
|
|
||||||
s32 excessiveSamples;
|
|
||||||
if (gReverbDownsampleRate != 1)
|
if (gReverbDownsampleRate != 1)
|
||||||
{
|
{
|
||||||
if (gSynthesisReverb.framesLeftToIgnore == 0)
|
if (gSynthesisReverb.framesLeftToIgnore == 0)
|
||||||
@@ -202,7 +199,7 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex)
|
|||||||
}
|
}
|
||||||
item = &gSynthesisReverb.items[gSynthesisReverb.curFrame][updateIndex];
|
item = &gSynthesisReverb.items[gSynthesisReverb.curFrame][updateIndex];
|
||||||
|
|
||||||
numSamplesAfterDownsampling = chunkLen / gReverbDownsampleRate;
|
s32 numSamplesAfterDownsampling = chunkLen / gReverbDownsampleRate;
|
||||||
if (numSamplesAfterDownsampling + gSynthesisReverb.nextRingBufferPos - gSynthesisReverb.bufSizePerChannel < 0)
|
if (numSamplesAfterDownsampling + gSynthesisReverb.nextRingBufferPos - gSynthesisReverb.bufSizePerChannel < 0)
|
||||||
{
|
{
|
||||||
// There is space in the ring buffer before it wraps around
|
// There is space in the ring buffer before it wraps around
|
||||||
@@ -214,9 +211,8 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Ring buffer wrapped around
|
// Ring buffer wrapped around
|
||||||
excessiveSamples =
|
s32 excessiveSamples = numSamplesAfterDownsampling + gSynthesisReverb.nextRingBufferPos - gSynthesisReverb.bufSizePerChannel;
|
||||||
numSamplesAfterDownsampling + gSynthesisReverb.nextRingBufferPos - gSynthesisReverb.bufSizePerChannel;
|
s32 nSamples = numSamplesAfterDownsampling - excessiveSamples;
|
||||||
nSamples = numSamplesAfterDownsampling - excessiveSamples;
|
|
||||||
item->lengthA = nSamples * 2;
|
item->lengthA = nSamples * 2;
|
||||||
item->lengthB = excessiveSamples * 2;
|
item->lengthB = excessiveSamples * 2;
|
||||||
item->startPos = gSynthesisReverb.nextRingBufferPos;
|
item->startPos = gSynthesisReverb.nextRingBufferPos;
|
||||||
@@ -368,14 +364,12 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen)
|
|||||||
{
|
{
|
||||||
DEBUG_PRINT("synthesis_execute()");
|
DEBUG_PRINT("synthesis_execute()");
|
||||||
s32 chunkLen;
|
s32 chunkLen;
|
||||||
s32 i;
|
|
||||||
u32 *aiBufPtr = (u32 *)aiBuf;
|
u32 *aiBufPtr = (u32 *)aiBuf;
|
||||||
u64 *cmd = cmdBuf + 1;
|
u64 *cmd = cmdBuf + 1;
|
||||||
s32 v0;
|
|
||||||
|
|
||||||
aSegment(cmdBuf, 0, 0);
|
aSegment(cmdBuf, 0, 0);
|
||||||
|
|
||||||
for (i = gAudioUpdatesPerFrame; i > 0; i--)
|
for (s32 i = gAudioUpdatesPerFrame; i > 0; i--)
|
||||||
{
|
{
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
{
|
{
|
||||||
@@ -384,7 +378,7 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v0 = bufLen / i;
|
s32 v0 = bufLen / i;
|
||||||
// chunkLen = v0 rounded to nearest multiple of 8
|
// chunkLen = v0 rounded to nearest multiple of 8
|
||||||
chunkLen = v0 - (v0 & 7);
|
chunkLen = v0 - (v0 & 7);
|
||||||
|
|
||||||
@@ -592,17 +586,14 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateI
|
|||||||
DEBUG_PRINT("synthesis_do_one_audio_update()");
|
DEBUG_PRINT("synthesis_do_one_audio_update()");
|
||||||
|
|
||||||
UNUSED s32 pad1[1];
|
UNUSED s32 pad1[1];
|
||||||
s16 ra;
|
|
||||||
s16 t4;
|
|
||||||
UNUSED s32 pad[2];
|
UNUSED s32 pad[2];
|
||||||
struct ReverbRingBufferItem *v1;
|
|
||||||
UNUSED s32 pad2[1];
|
UNUSED s32 pad2[1];
|
||||||
s16 temp;
|
s16 temp;
|
||||||
|
|
||||||
DEBUG_PRINT("- curFrame: %d", gSynthesisReverb.curFrame);
|
DEBUG_PRINT("- curFrame: %d", gSynthesisReverb.curFrame);
|
||||||
DEBUG_PRINT("- updateIndex: %d", updateIndex);
|
DEBUG_PRINT("- updateIndex: %d", updateIndex);
|
||||||
|
|
||||||
v1 = &gSynthesisReverb.items[gSynthesisReverb.curFrame][updateIndex];
|
struct ReverbRingBufferItem *v1 = &gSynthesisReverb.items[gSynthesisReverb.curFrame][updateIndex];
|
||||||
DEBUG_PRINT("- v1: %x", v1);
|
DEBUG_PRINT("- v1: %x", v1);
|
||||||
|
|
||||||
if (gSynthesisReverb.useReverb == 0)
|
if (gSynthesisReverb.useReverb == 0)
|
||||||
@@ -649,8 +640,8 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateI
|
|||||||
|
|
||||||
// Same as above but upsample the previously downsampled samples used for reverb first
|
// Same as above but upsample the previously downsampled samples used for reverb first
|
||||||
temp = 0; //! jesus christ
|
temp = 0; //! jesus christ
|
||||||
t4 = (v1->startPos & 7) * 2;
|
s16 t4 = (v1->startPos & 7) * 2;
|
||||||
ra = ALIGN(v1->lengthA + t4, 4);
|
s16 ra = ALIGN(v1->lengthA + t4, 4);
|
||||||
DEBUG_PRINT("- set load buffer pair");
|
DEBUG_PRINT("- set load buffer pair");
|
||||||
aSetLoadBufferPair(cmd++, 0, v1->startPos - t4 / 2);
|
aSetLoadBufferPair(cmd++, 0, v1->startPos - t4 / 2);
|
||||||
if (v1->lengthB != 0)
|
if (v1->lengthB != 0)
|
||||||
@@ -1126,16 +1117,14 @@ u64 *synthesis_process_notes(s16 *aiBuf, s32 bufLen, u64 *cmd)
|
|||||||
|
|
||||||
u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad)
|
u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad)
|
||||||
{
|
{
|
||||||
s32 a3;
|
|
||||||
s32 i;
|
|
||||||
aSetBuffer(cmd++, /*flags*/ 0, /*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE, /*dmemout*/ 0,
|
aSetBuffer(cmd++, /*flags*/ 0, /*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE, /*dmemout*/ 0,
|
||||||
/*count*/ sizeof(note->synthesisBuffers->samples));
|
/*count*/ sizeof(note->synthesisBuffers->samples));
|
||||||
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->samples));
|
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->samples));
|
||||||
note->samplePosInt &= note->sampleCount - 1;
|
note->samplePosInt &= note->sampleCount - 1;
|
||||||
a3 = 64 - note->samplePosInt;
|
s32 a3 = 64 - note->samplePosInt;
|
||||||
if (a3 < nSamplesToLoad)
|
if (a3 < nSamplesToLoad)
|
||||||
{
|
{
|
||||||
for (i = 0; i <= (nSamplesToLoad - a3 + 63) / 64 - 1; i++)
|
for (s32 i = 0; i <= (nSamplesToLoad - a3 + 63) / 64 - 1; i++)
|
||||||
{
|
{
|
||||||
aDMEMMove(cmd++, /*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE, /*dmemout*/ DMEM_ADDR_UNCOMPRESSED_NOTE + (1 + i) * sizeof(note->synthesisBuffers->samples), /*count*/ sizeof(note->synthesisBuffers->samples));
|
aDMEMMove(cmd++, /*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE, /*dmemout*/ DMEM_ADDR_UNCOMPRESSED_NOTE + (1 + i) * sizeof(note->synthesisBuffers->samples), /*count*/ sizeof(note->synthesisBuffers->samples));
|
||||||
}
|
}
|
||||||
@@ -1522,10 +1511,8 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverb
|
|||||||
}
|
}
|
||||||
else if (note->stereoHeadsetEffects && gSoundMode == SOUND_MODE_STEREO)
|
else if (note->stereoHeadsetEffects && gSoundMode == SOUND_MODE_STEREO)
|
||||||
{
|
{
|
||||||
u8 strongLeft;
|
u8 strongLeft = FALSE;
|
||||||
u8 strongRight;
|
u8 strongRight = FALSE;
|
||||||
strongLeft = FALSE;
|
|
||||||
strongRight = FALSE;
|
|
||||||
note->headsetPanLeft = 0;
|
note->headsetPanLeft = 0;
|
||||||
note->headsetPanRight = 0;
|
note->headsetPanRight = 0;
|
||||||
note->usesHeadsetPanEffects = FALSE;
|
note->usesHeadsetPanEffects = FALSE;
|
||||||
|
|||||||
@@ -214,9 +214,6 @@ void geo_layout_cmd_update_node_flags(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_root(void)
|
void geo_layout_cmd_node_root(void)
|
||||||
{
|
{
|
||||||
s32 i;
|
|
||||||
struct GraphNodeRoot *graphNode;
|
|
||||||
|
|
||||||
s16 x = cur_geo_cmd_s16(0x04);
|
s16 x = cur_geo_cmd_s16(0x04);
|
||||||
s16 y = cur_geo_cmd_s16(0x06);
|
s16 y = cur_geo_cmd_s16(0x06);
|
||||||
s16 width = cur_geo_cmd_s16(0x08);
|
s16 width = cur_geo_cmd_s16(0x08);
|
||||||
@@ -227,7 +224,7 @@ void geo_layout_cmd_node_root(void)
|
|||||||
// cmd+0x02 = 0x00: Mario face, 0x0A: all other levels
|
// cmd+0x02 = 0x00: Mario face, 0x0A: all other levels
|
||||||
gGeoNumViews = cur_geo_cmd_s16(0x02) + 2;
|
gGeoNumViews = cur_geo_cmd_s16(0x02) + 2;
|
||||||
|
|
||||||
graphNode = init_graph_node_root(gGraphNodePool, NULL, 0, x, y, width, height);
|
struct GraphNodeRoot *graphNode = init_graph_node_root(gGraphNodePool, NULL, 0, x, y, width, height);
|
||||||
|
|
||||||
// gGeoViews is unused in libsm64
|
// gGeoViews is unused in libsm64
|
||||||
gGeoViews = NULL; // alloc_only_pool_alloc(gGraphNodePool, gGeoNumViews * sizeof(struct GraphNode *));
|
gGeoViews = NULL; // alloc_only_pool_alloc(gGraphNodePool, gGeoNumViews * sizeof(struct GraphNode *));
|
||||||
@@ -235,7 +232,7 @@ void geo_layout_cmd_node_root(void)
|
|||||||
graphNode->views = gGeoViews;
|
graphNode->views = gGeoViews;
|
||||||
graphNode->numViews = gGeoNumViews;
|
graphNode->numViews = gGeoNumViews;
|
||||||
|
|
||||||
for (i = 0; i < gGeoNumViews; i++)
|
for (s32 i = 0; i < gGeoNumViews; i++)
|
||||||
{
|
{
|
||||||
gGeoViews[i] = NULL;
|
gGeoViews[i] = NULL;
|
||||||
}
|
}
|
||||||
@@ -251,10 +248,9 @@ void geo_layout_cmd_node_root(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_ortho_projection(void)
|
void geo_layout_cmd_node_ortho_projection(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeOrthoProjection *graphNode;
|
|
||||||
f32 scale = (f32)cur_geo_cmd_s16(0x02) / 100.0f;
|
f32 scale = (f32)cur_geo_cmd_s16(0x02) / 100.0f;
|
||||||
|
|
||||||
graphNode = init_graph_node_ortho_projection(gGraphNodePool, NULL, scale);
|
struct GraphNodeOrthoProjection *graphNode = init_graph_node_ortho_projection(gGraphNodePool, NULL, scale);
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -271,7 +267,6 @@ void geo_layout_cmd_node_ortho_projection(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_perspective(void)
|
void geo_layout_cmd_node_perspective(void)
|
||||||
{
|
{
|
||||||
struct GraphNodePerspective *graphNode;
|
|
||||||
GraphNodeFunc frustumFunc = NULL;
|
GraphNodeFunc frustumFunc = NULL;
|
||||||
s16 fov = cur_geo_cmd_s16(0x02);
|
s16 fov = cur_geo_cmd_s16(0x02);
|
||||||
s16 near = cur_geo_cmd_s16(0x04);
|
s16 near = cur_geo_cmd_s16(0x04);
|
||||||
@@ -284,7 +279,7 @@ void geo_layout_cmd_node_perspective(void)
|
|||||||
gGeoLayoutCommand += 4 << CMD_SIZE_SHIFT;
|
gGeoLayoutCommand += 4 << CMD_SIZE_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphNode = init_graph_node_perspective(gGraphNodePool, NULL, fov, near, far, frustumFunc, 0);
|
struct GraphNodePerspective *graphNode = init_graph_node_perspective(gGraphNodePool, NULL, fov, near, far, frustumFunc, 0);
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->fnNode.node);
|
register_scene_graph_node(&graphNode->fnNode.node);
|
||||||
|
|
||||||
@@ -297,9 +292,7 @@ void geo_layout_cmd_node_perspective(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_start(void)
|
void geo_layout_cmd_node_start(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeStart *graphNode;
|
struct GraphNodeStart *graphNode = init_graph_node_start(gGraphNodePool, NULL);
|
||||||
|
|
||||||
graphNode = init_graph_node_start(gGraphNodePool, NULL);
|
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -318,9 +311,7 @@ void geo_layout_cmd_nop3(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_master_list(void)
|
void geo_layout_cmd_node_master_list(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeMasterList *graphNode;
|
struct GraphNodeMasterList *graphNode = init_graph_node_master_list(gGraphNodePool, NULL, cur_geo_cmd_u8(0x01));
|
||||||
|
|
||||||
graphNode = init_graph_node_master_list(gGraphNodePool, NULL, cur_geo_cmd_u8(0x01));
|
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -335,11 +326,10 @@ void geo_layout_cmd_node_master_list(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_level_of_detail(void)
|
void geo_layout_cmd_node_level_of_detail(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeLevelOfDetail *graphNode;
|
|
||||||
s16 minDistance = cur_geo_cmd_s16(0x04);
|
s16 minDistance = cur_geo_cmd_s16(0x04);
|
||||||
s16 maxDistance = cur_geo_cmd_s16(0x06);
|
s16 maxDistance = cur_geo_cmd_s16(0x06);
|
||||||
|
|
||||||
graphNode = init_graph_node_render_range(gGraphNodePool, NULL, minDistance, maxDistance);
|
struct GraphNodeLevelOfDetail *graphNode = init_graph_node_render_range(gGraphNodePool, NULL, minDistance, maxDistance);
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -356,10 +346,7 @@ void geo_layout_cmd_node_level_of_detail(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_switch_case(void)
|
void geo_layout_cmd_node_switch_case(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeSwitchCase *graphNode;
|
struct GraphNodeSwitchCase *graphNode = init_graph_node_switch_case(gGraphNodePool, NULL,
|
||||||
|
|
||||||
graphNode =
|
|
||||||
init_graph_node_switch_case(gGraphNodePool, NULL,
|
|
||||||
cur_geo_cmd_s16(0x02), // case which is initially selected
|
cur_geo_cmd_s16(0x02), // case which is initially selected
|
||||||
0,
|
0,
|
||||||
cur_geo_cmd_ptr(0x04), // case update function
|
cur_geo_cmd_ptr(0x04), // case update function
|
||||||
@@ -383,7 +370,6 @@ void geo_layout_cmd_node_switch_case(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_camera(void)
|
void geo_layout_cmd_node_camera(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeCamera *graphNode;
|
|
||||||
s16 *cmdPos = (s16 *)&gGeoLayoutCommand[4];
|
s16 *cmdPos = (s16 *)&gGeoLayoutCommand[4];
|
||||||
|
|
||||||
Vec3f pos, focus;
|
Vec3f pos, focus;
|
||||||
@@ -391,7 +377,7 @@ void geo_layout_cmd_node_camera(void)
|
|||||||
cmdPos = read_vec3s_to_vec3f(pos, cmdPos);
|
cmdPos = read_vec3s_to_vec3f(pos, cmdPos);
|
||||||
cmdPos = read_vec3s_to_vec3f(focus, cmdPos);
|
cmdPos = read_vec3s_to_vec3f(focus, cmdPos);
|
||||||
|
|
||||||
graphNode = init_graph_node_camera(gGraphNodePool, NULL, pos, focus,
|
struct GraphNodeCamera *graphNode = init_graph_node_camera(gGraphNodePool, NULL, pos, focus,
|
||||||
cur_geo_cmd_ptr(0x10), cur_geo_cmd_s16(0x02));
|
cur_geo_cmd_ptr(0x10), cur_geo_cmd_s16(0x02));
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->fnNode.node);
|
register_scene_graph_node(&graphNode->fnNode.node);
|
||||||
@@ -437,8 +423,6 @@ void geo_layout_cmd_node_camera(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_translation_rotation(void)
|
void geo_layout_cmd_node_translation_rotation(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeTranslationRotation *graphNode;
|
|
||||||
|
|
||||||
Vec3s translation, rotation;
|
Vec3s translation, rotation;
|
||||||
|
|
||||||
void *displayList = NULL;
|
void *displayList = NULL;
|
||||||
@@ -475,7 +459,7 @@ void geo_layout_cmd_node_translation_rotation(void)
|
|||||||
cmdPos += 2 << CMD_SIZE_SHIFT;
|
cmdPos += 2 << CMD_SIZE_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphNode = init_graph_node_translation_rotation(gGraphNodePool, NULL, drawingLayer, displayList,
|
struct GraphNodeTranslationRotation *graphNode = init_graph_node_translation_rotation(gGraphNodePool, NULL, drawingLayer, displayList,
|
||||||
translation, rotation);
|
translation, rotation);
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -494,8 +478,6 @@ void geo_layout_cmd_node_translation_rotation(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_translation(void)
|
void geo_layout_cmd_node_translation(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeTranslation *graphNode;
|
|
||||||
|
|
||||||
Vec3s translation;
|
Vec3s translation;
|
||||||
|
|
||||||
s16 drawingLayer = 0;
|
s16 drawingLayer = 0;
|
||||||
@@ -512,8 +494,7 @@ void geo_layout_cmd_node_translation(void)
|
|||||||
cmdPos += 2 << CMD_SIZE_SHIFT;
|
cmdPos += 2 << CMD_SIZE_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphNode =
|
struct GraphNodeTranslation *graphNode = init_graph_node_translation(gGraphNodePool, NULL, drawingLayer, displayList, translation);
|
||||||
init_graph_node_translation(gGraphNodePool, NULL, drawingLayer, displayList, translation);
|
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -532,8 +513,6 @@ void geo_layout_cmd_node_translation(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_rotation(void)
|
void geo_layout_cmd_node_rotation(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeRotation *graphNode;
|
|
||||||
|
|
||||||
Vec3s sp2c;
|
Vec3s sp2c;
|
||||||
|
|
||||||
s16 drawingLayer = 0;
|
s16 drawingLayer = 0;
|
||||||
@@ -550,7 +529,7 @@ void geo_layout_cmd_node_rotation(void)
|
|||||||
cmdPos += 2 << CMD_SIZE_SHIFT;
|
cmdPos += 2 << CMD_SIZE_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphNode = init_graph_node_rotation(gGraphNodePool, NULL, drawingLayer, displayList, sp2c);
|
struct GraphNodeRotation *graphNode = init_graph_node_rotation(gGraphNodePool, NULL, drawingLayer, displayList, sp2c);
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -567,8 +546,6 @@ void geo_layout_cmd_node_rotation(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_scale(void)
|
void geo_layout_cmd_node_scale(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeScale *graphNode;
|
|
||||||
|
|
||||||
s16 drawingLayer = 0;
|
s16 drawingLayer = 0;
|
||||||
s16 params = cur_geo_cmd_u8(0x01);
|
s16 params = cur_geo_cmd_u8(0x01);
|
||||||
f32 scale = cur_geo_cmd_u32(0x04) / 65536.0f;
|
f32 scale = cur_geo_cmd_u32(0x04) / 65536.0f;
|
||||||
@@ -581,7 +558,7 @@ void geo_layout_cmd_node_scale(void)
|
|||||||
gGeoLayoutCommand += 4 << CMD_SIZE_SHIFT;
|
gGeoLayoutCommand += 4 << CMD_SIZE_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphNode = init_graph_node_scale(gGraphNodePool, NULL, drawingLayer, displayList, scale);
|
struct GraphNodeScale *graphNode = init_graph_node_scale(gGraphNodePool, NULL, drawingLayer, displayList, scale);
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -604,7 +581,6 @@ void geo_layout_cmd_nop2(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_animated_part(void)
|
void geo_layout_cmd_node_animated_part(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeAnimatedPart *graphNode;
|
|
||||||
Vec3s translation;
|
Vec3s translation;
|
||||||
s32 drawingLayer = cur_geo_cmd_u8(0x01);
|
s32 drawingLayer = cur_geo_cmd_u8(0x01);
|
||||||
void *displayList = cur_geo_cmd_ptr(0x08);
|
void *displayList = cur_geo_cmd_ptr(0x08);
|
||||||
@@ -612,8 +588,7 @@ void geo_layout_cmd_node_animated_part(void)
|
|||||||
|
|
||||||
read_vec3s(translation, &cmdPos[1]);
|
read_vec3s(translation, &cmdPos[1]);
|
||||||
|
|
||||||
graphNode =
|
struct GraphNodeAnimatedPart *graphNode = init_graph_node_animated_part(gGraphNodePool, NULL, drawingLayer, displayList, translation);
|
||||||
init_graph_node_animated_part(gGraphNodePool, NULL, drawingLayer, displayList, translation);
|
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -632,7 +607,6 @@ void geo_layout_cmd_node_animated_part(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_billboard(void)
|
void geo_layout_cmd_node_billboard(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeBillboard *graphNode;
|
|
||||||
Vec3s translation;
|
Vec3s translation;
|
||||||
s16 drawingLayer = 0;
|
s16 drawingLayer = 0;
|
||||||
s16 params = cur_geo_cmd_u8(0x01);
|
s16 params = cur_geo_cmd_u8(0x01);
|
||||||
@@ -648,7 +622,7 @@ void geo_layout_cmd_node_billboard(void)
|
|||||||
cmdPos += 2 << CMD_SIZE_SHIFT;
|
cmdPos += 2 << CMD_SIZE_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphNode = init_graph_node_billboard(gGraphNodePool, NULL, drawingLayer, displayList, translation);
|
struct GraphNodeBillboard *graphNode = init_graph_node_billboard(gGraphNodePool, NULL, drawingLayer, displayList, translation);
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -662,11 +636,10 @@ void geo_layout_cmd_node_billboard(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_display_list(void)
|
void geo_layout_cmd_node_display_list(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeDisplayList *graphNode;
|
|
||||||
s32 drawingLayer = cur_geo_cmd_u8(0x01);
|
s32 drawingLayer = cur_geo_cmd_u8(0x01);
|
||||||
void *displayList = cur_geo_cmd_ptr(0x04);
|
void *displayList = cur_geo_cmd_ptr(0x04);
|
||||||
|
|
||||||
graphNode = init_graph_node_display_list(gGraphNodePool, NULL, drawingLayer, displayList);
|
struct GraphNodeDisplayList *graphNode = init_graph_node_display_list(gGraphNodePool, NULL, drawingLayer, displayList);
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -681,12 +654,11 @@ void geo_layout_cmd_node_display_list(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_shadow(void)
|
void geo_layout_cmd_node_shadow(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeShadow *graphNode;
|
|
||||||
u8 shadowType = cur_geo_cmd_s16(0x02);
|
u8 shadowType = cur_geo_cmd_s16(0x02);
|
||||||
u8 shadowSolidity = cur_geo_cmd_s16(0x04);
|
u8 shadowSolidity = cur_geo_cmd_s16(0x04);
|
||||||
s16 shadowScale = cur_geo_cmd_s16(0x06);
|
s16 shadowScale = cur_geo_cmd_s16(0x06);
|
||||||
|
|
||||||
graphNode = init_graph_node_shadow(gGraphNodePool, NULL, shadowScale, shadowSolidity, shadowType);
|
struct GraphNodeShadow *graphNode = init_graph_node_shadow(gGraphNodePool, NULL, shadowScale, shadowSolidity, shadowType);
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -696,9 +668,7 @@ void geo_layout_cmd_node_shadow(void)
|
|||||||
// 0x17: Create scene graph node that manages the group of all object nodes
|
// 0x17: Create scene graph node that manages the group of all object nodes
|
||||||
void geo_layout_cmd_node_object_parent(void)
|
void geo_layout_cmd_node_object_parent(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeObjectParent *graphNode;
|
struct GraphNodeObjectParent *graphNode = init_graph_node_object_parent(gGraphNodePool, NULL, &gObjParentGraphNode);
|
||||||
|
|
||||||
graphNode = init_graph_node_object_parent(gGraphNodePool, NULL, &gObjParentGraphNode);
|
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -712,9 +682,7 @@ void geo_layout_cmd_node_object_parent(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_generated(void)
|
void geo_layout_cmd_node_generated(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeGenerated *graphNode;
|
struct GraphNodeGenerated *graphNode = init_graph_node_generated(gGraphNodePool, NULL,
|
||||||
|
|
||||||
graphNode = init_graph_node_generated(gGraphNodePool, NULL,
|
|
||||||
cur_geo_cmd_ptr(0x04), // asm function
|
cur_geo_cmd_ptr(0x04), // asm function
|
||||||
cur_geo_cmd_s16(0x02)); // parameter
|
cur_geo_cmd_s16(0x02)); // parameter
|
||||||
|
|
||||||
@@ -730,9 +698,7 @@ void geo_layout_cmd_node_generated(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_background(void)
|
void geo_layout_cmd_node_background(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeBackground *graphNode;
|
struct GraphNodeBackground *graphNode = init_graph_node_background(
|
||||||
|
|
||||||
graphNode = init_graph_node_background(
|
|
||||||
gGraphNodePool, NULL,
|
gGraphNodePool, NULL,
|
||||||
cur_geo_cmd_s16(0x02), // background ID, or RGBA5551 color if asm function is null
|
cur_geo_cmd_s16(0x02), // background ID, or RGBA5551 color if asm function is null
|
||||||
cur_geo_cmd_ptr(0x04), // asm function
|
cur_geo_cmd_ptr(0x04), // asm function
|
||||||
@@ -756,7 +722,6 @@ void geo_layout_cmd_nop(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_copy_view(void)
|
void geo_layout_cmd_copy_view(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeObjectParent *graphNode;
|
|
||||||
struct GraphNode *node = NULL;
|
struct GraphNode *node = NULL;
|
||||||
s16 index = cur_geo_cmd_s16(0x02);
|
s16 index = cur_geo_cmd_s16(0x02);
|
||||||
|
|
||||||
@@ -774,7 +739,7 @@ void geo_layout_cmd_copy_view(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
graphNode = init_graph_node_object_parent(gGraphNodePool, NULL, node);
|
struct GraphNodeObjectParent *graphNode = init_graph_node_object_parent(gGraphNodePool, NULL, node);
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
|
|
||||||
@@ -791,12 +756,11 @@ void geo_layout_cmd_copy_view(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_held_obj(void)
|
void geo_layout_cmd_node_held_obj(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeHeldObject *graphNode;
|
|
||||||
Vec3s offset;
|
Vec3s offset;
|
||||||
|
|
||||||
read_vec3s(offset, (s16 *)&gGeoLayoutCommand[0x02]);
|
read_vec3s(offset, (s16 *)&gGeoLayoutCommand[0x02]);
|
||||||
|
|
||||||
graphNode = init_graph_node_held_object(
|
struct GraphNodeHeldObject *graphNode = init_graph_node_held_object(
|
||||||
gGraphNodePool, NULL, NULL, offset, cur_geo_cmd_ptr(0x08), cur_geo_cmd_u8(0x01));
|
gGraphNodePool, NULL, NULL, offset, cur_geo_cmd_ptr(0x08), cur_geo_cmd_u8(0x01));
|
||||||
|
|
||||||
register_scene_graph_node(&graphNode->fnNode.node);
|
register_scene_graph_node(&graphNode->fnNode.node);
|
||||||
@@ -811,8 +775,7 @@ void geo_layout_cmd_node_held_obj(void)
|
|||||||
*/
|
*/
|
||||||
void geo_layout_cmd_node_culling_radius(void)
|
void geo_layout_cmd_node_culling_radius(void)
|
||||||
{
|
{
|
||||||
struct GraphNodeCullingRadius *graphNode;
|
struct GraphNodeCullingRadius *graphNode = init_graph_node_culling_radius(gGraphNodePool, NULL, cur_geo_cmd_s16(0x02));
|
||||||
graphNode = init_graph_node_culling_radius(gGraphNodePool, NULL, cur_geo_cmd_s16(0x02));
|
|
||||||
register_scene_graph_node(&graphNode->node);
|
register_scene_graph_node(&graphNode->node);
|
||||||
gGeoLayoutCommand += 0x04 << CMD_SIZE_SHIFT;
|
gGeoLayoutCommand += 0x04 << CMD_SIZE_SHIFT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -618,13 +618,10 @@ struct GraphNodeHeldObject *init_graph_node_held_object(
|
|||||||
*/
|
*/
|
||||||
struct GraphNode *geo_add_child(struct GraphNode *parent, struct GraphNode *childNode)
|
struct GraphNode *geo_add_child(struct GraphNode *parent, struct GraphNode *childNode)
|
||||||
{
|
{
|
||||||
struct GraphNode *parentFirstChild;
|
|
||||||
struct GraphNode *parentLastChild;
|
|
||||||
|
|
||||||
if (childNode != NULL)
|
if (childNode != NULL)
|
||||||
{
|
{
|
||||||
childNode->parent = parent;
|
childNode->parent = parent;
|
||||||
parentFirstChild = parent->children;
|
struct GraphNode *parentFirstChild = parent->children;
|
||||||
|
|
||||||
if (parentFirstChild == NULL)
|
if (parentFirstChild == NULL)
|
||||||
{
|
{
|
||||||
@@ -634,7 +631,7 @@ struct GraphNode *geo_add_child(struct GraphNode *parent, struct GraphNode *chil
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parentLastChild = parentFirstChild->prev;
|
struct GraphNode *parentLastChild = parentFirstChild->prev;
|
||||||
childNode->prev = parentLastChild;
|
childNode->prev = parentLastChild;
|
||||||
childNode->next = parentFirstChild;
|
childNode->next = parentFirstChild;
|
||||||
parentFirstChild->prev = childNode;
|
parentFirstChild->prev = childNode;
|
||||||
@@ -653,11 +650,8 @@ struct GraphNode *geo_add_child(struct GraphNode *parent, struct GraphNode *chil
|
|||||||
*/
|
*/
|
||||||
struct GraphNode *geo_remove_child(struct GraphNode *graphNode)
|
struct GraphNode *geo_remove_child(struct GraphNode *graphNode)
|
||||||
{
|
{
|
||||||
struct GraphNode *parent;
|
struct GraphNode *parent = graphNode->parent;
|
||||||
struct GraphNode **firstChild;
|
struct GraphNode **firstChild = &parent->children;
|
||||||
|
|
||||||
parent = graphNode->parent;
|
|
||||||
firstChild = &parent->children;
|
|
||||||
|
|
||||||
// Remove link with siblings
|
// Remove link with siblings
|
||||||
graphNode->prev->next = graphNode->next;
|
graphNode->prev->next = graphNode->next;
|
||||||
@@ -688,12 +682,8 @@ struct GraphNode *geo_remove_child(struct GraphNode *graphNode)
|
|||||||
*/
|
*/
|
||||||
struct GraphNode *geo_make_first_child(struct GraphNode *newFirstChild)
|
struct GraphNode *geo_make_first_child(struct GraphNode *newFirstChild)
|
||||||
{
|
{
|
||||||
struct GraphNode *lastSibling;
|
struct GraphNode *parent = newFirstChild->parent;
|
||||||
struct GraphNode *parent;
|
struct GraphNode **firstChild = &parent->children;
|
||||||
struct GraphNode **firstChild;
|
|
||||||
|
|
||||||
parent = newFirstChild->parent;
|
|
||||||
firstChild = &parent->children;
|
|
||||||
|
|
||||||
if (*firstChild != newFirstChild)
|
if (*firstChild != newFirstChild)
|
||||||
{
|
{
|
||||||
@@ -701,7 +691,7 @@ struct GraphNode *geo_make_first_child(struct GraphNode *newFirstChild)
|
|||||||
{
|
{
|
||||||
newFirstChild->prev->next = newFirstChild->next;
|
newFirstChild->prev->next = newFirstChild->next;
|
||||||
newFirstChild->next->prev = newFirstChild->prev;
|
newFirstChild->next->prev = newFirstChild->prev;
|
||||||
lastSibling = (*firstChild)->prev;
|
struct GraphNode *lastSibling = (*firstChild)->prev;
|
||||||
newFirstChild->prev = lastSibling;
|
newFirstChild->prev = lastSibling;
|
||||||
newFirstChild->next = *firstChild;
|
newFirstChild->next = *firstChild;
|
||||||
(*firstChild)->prev = newFirstChild;
|
(*firstChild)->prev = newFirstChild;
|
||||||
@@ -720,14 +710,12 @@ struct GraphNode *geo_make_first_child(struct GraphNode *newFirstChild)
|
|||||||
void geo_call_global_function_nodes_helper(struct GraphNode *graphNode, s32 callContext)
|
void geo_call_global_function_nodes_helper(struct GraphNode *graphNode, s32 callContext)
|
||||||
{
|
{
|
||||||
struct GraphNode **globalPtr;
|
struct GraphNode **globalPtr;
|
||||||
struct GraphNode *curNode;
|
|
||||||
struct FnGraphNode *asFnNode;
|
|
||||||
|
|
||||||
curNode = graphNode;
|
struct GraphNode *curNode = graphNode;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
asFnNode = (struct FnGraphNode *)curNode;
|
struct FnGraphNode *asFnNode = (struct FnGraphNode *)curNode;
|
||||||
|
|
||||||
if (curNode->type & GRAPH_NODE_TYPE_FUNCTIONAL)
|
if (curNode->type & GRAPH_NODE_TYPE_FUNCTIONAL)
|
||||||
{
|
{
|
||||||
@@ -922,9 +910,8 @@ s32 retrieve_animation_index(s32 frame, u16 **attributes)
|
|||||||
s16 geo_update_animation_frame(struct AnimInfo *obj, s32 *accelAssist)
|
s16 geo_update_animation_frame(struct AnimInfo *obj, s32 *accelAssist)
|
||||||
{
|
{
|
||||||
s32 result;
|
s32 result;
|
||||||
struct Animation *anim;
|
|
||||||
|
|
||||||
anim = obj->curAnim;
|
struct Animation *anim = obj->curAnim;
|
||||||
|
|
||||||
if (obj->animTimer == gAreaUpdateCounter || anim->flags & ANIM_FLAG_2)
|
if (obj->animTimer == gAreaUpdateCounter || anim->flags & ANIM_FLAG_2)
|
||||||
{
|
{
|
||||||
@@ -1003,15 +990,13 @@ void geo_retreive_animation_translation(struct GraphNodeObject *obj, Vec3f posit
|
|||||||
{
|
{
|
||||||
struct Animation *animation = obj->animInfo.curAnim;
|
struct Animation *animation = obj->animInfo.curAnim;
|
||||||
u16 *attribute;
|
u16 *attribute;
|
||||||
s16 *values;
|
|
||||||
s16 frame;
|
|
||||||
|
|
||||||
if (animation != NULL)
|
if (animation != NULL)
|
||||||
{
|
{
|
||||||
attribute = segmented_to_virtual(animation->index);
|
attribute = segmented_to_virtual(animation->index);
|
||||||
values = segmented_to_virtual(animation->values);
|
s16 *values = segmented_to_virtual(animation->values);
|
||||||
|
|
||||||
frame = obj->animInfo.animFrame;
|
s16 frame = obj->animInfo.animFrame;
|
||||||
|
|
||||||
if (frame < 0)
|
if (frame < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,12 +8,11 @@
|
|||||||
#if IS_64_BIT
|
#if IS_64_BIT
|
||||||
static s16 next_s16_in_geo_script(s16 **src)
|
static s16 next_s16_in_geo_script(s16 **src)
|
||||||
{
|
{
|
||||||
s16 ret;
|
|
||||||
if (((uintptr_t) * src & 7) == 4)
|
if (((uintptr_t) * src & 7) == 4)
|
||||||
{
|
{
|
||||||
*src += 2; // skip 32 bits
|
*src += 2; // skip 32 bits
|
||||||
}
|
}
|
||||||
ret = *(*src)++;
|
s16 ret = *(*src)++;
|
||||||
if (((uintptr_t) * src & 7) == 4)
|
if (((uintptr_t) * src & 7) == 4)
|
||||||
{
|
{
|
||||||
*src += 2; // skip 32 bits
|
*src += 2; // skip 32 bits
|
||||||
|
|||||||
@@ -60,10 +60,9 @@ void guMtxL2F(float mf[4][4], Mtx *m)
|
|||||||
|
|
||||||
void guMtxIdentF(float mf[4][4])
|
void guMtxIdentF(float mf[4][4])
|
||||||
{
|
{
|
||||||
int r, c;
|
for (int r = 0; r < 4; r++)
|
||||||
for (r = 0; r < 4; r++)
|
|
||||||
{
|
{
|
||||||
for (c = 0; c < 4; c++)
|
for (int c = 0; c < 4; c++)
|
||||||
{
|
{
|
||||||
if (r == c)
|
if (r == c)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1591,11 +1591,10 @@ void *vec3f_normalize(Vec3f dest)
|
|||||||
/// Copy matrix 'src' to 'dest'
|
/// Copy matrix 'src' to 'dest'
|
||||||
void mtxf_copy(Mat4 dest, Mat4 src)
|
void mtxf_copy(Mat4 dest, Mat4 src)
|
||||||
{
|
{
|
||||||
register s32 i;
|
|
||||||
register u32 *d = (u32 *)dest;
|
register u32 *d = (u32 *)dest;
|
||||||
register u32 *s = (u32 *)src;
|
register u32 *s = (u32 *)src;
|
||||||
|
|
||||||
for (i = 0; i < 16; i++)
|
for (register s32 i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
*d++ = *s++;
|
*d++ = *s++;
|
||||||
}
|
}
|
||||||
@@ -1636,42 +1635,29 @@ void mtxf_translate(Mat4 dest, Vec3f b)
|
|||||||
*/
|
*/
|
||||||
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll)
|
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll)
|
||||||
{
|
{
|
||||||
register f32 invLength;
|
f32 dx = to[0] - from[0];
|
||||||
f32 dx;
|
f32 dz = to[2] - from[2];
|
||||||
f32 dz;
|
|
||||||
f32 xColY;
|
|
||||||
f32 yColY;
|
|
||||||
f32 zColY;
|
|
||||||
f32 xColZ;
|
|
||||||
f32 yColZ;
|
|
||||||
f32 zColZ;
|
|
||||||
f32 xColX;
|
|
||||||
f32 yColX;
|
|
||||||
f32 zColX;
|
|
||||||
|
|
||||||
dx = to[0] - from[0];
|
register f32 invLength = -1.0 / sqrtf(dx * dx + dz * dz);
|
||||||
dz = to[2] - from[2];
|
|
||||||
|
|
||||||
invLength = -1.0 / sqrtf(dx * dx + dz * dz);
|
|
||||||
dx *= invLength;
|
dx *= invLength;
|
||||||
dz *= invLength;
|
dz *= invLength;
|
||||||
|
|
||||||
yColY = coss(roll);
|
f32 yColY = coss(roll);
|
||||||
xColY = sins(roll) * dz;
|
f32 xColY = sins(roll) * dz;
|
||||||
zColY = -sins(roll) * dx;
|
f32 zColY = -sins(roll) * dx;
|
||||||
|
|
||||||
xColZ = to[0] - from[0];
|
f32 xColZ = to[0] - from[0];
|
||||||
yColZ = to[1] - from[1];
|
f32 yColZ = to[1] - from[1];
|
||||||
zColZ = to[2] - from[2];
|
f32 zColZ = to[2] - from[2];
|
||||||
|
|
||||||
invLength = -1.0 / sqrtf(xColZ * xColZ + yColZ * yColZ + zColZ * zColZ);
|
invLength = -1.0 / sqrtf(xColZ * xColZ + yColZ * yColZ + zColZ * zColZ);
|
||||||
xColZ *= invLength;
|
xColZ *= invLength;
|
||||||
yColZ *= invLength;
|
yColZ *= invLength;
|
||||||
zColZ *= invLength;
|
zColZ *= invLength;
|
||||||
|
|
||||||
xColX = yColY * zColZ - zColY * yColZ;
|
f32 xColX = yColY * zColZ - zColY * yColZ;
|
||||||
yColX = zColY * xColZ - xColY * zColZ;
|
f32 yColX = zColY * xColZ - xColY * zColZ;
|
||||||
zColX = xColY * yColZ - yColY * xColZ;
|
f32 zColX = xColY * yColZ - yColY * xColZ;
|
||||||
|
|
||||||
invLength = 1.0 / sqrtf(xColX * xColX + yColX * yColX + zColX * zColX);
|
invLength = 1.0 / sqrtf(xColX * xColX + yColX * yColX + zColX * zColX);
|
||||||
|
|
||||||
@@ -1872,7 +1858,6 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius)
|
|||||||
Vec3f xColumn;
|
Vec3f xColumn;
|
||||||
Vec3f yColumn;
|
Vec3f yColumn;
|
||||||
Vec3f zColumn;
|
Vec3f zColumn;
|
||||||
f32 avgY;
|
|
||||||
f32 minY = -radius * 3;
|
f32 minY = -radius * 3;
|
||||||
|
|
||||||
point0[0] = pos[0] + radius * sins(yaw + 0x2AAA);
|
point0[0] = pos[0] + radius * sins(yaw + 0x2AAA);
|
||||||
@@ -1901,7 +1886,7 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius)
|
|||||||
point2[1] = pos[1];
|
point2[1] = pos[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
avgY = (point0[1] + point1[1] + point2[1]) / 3;
|
f32 avgY = (point0[1] + point1[1] + point2[1]) / 3;
|
||||||
|
|
||||||
vec3f_set(forward, sins(yaw), 0, coss(yaw));
|
vec3f_set(forward, sins(yaw), 0, coss(yaw));
|
||||||
find_vector_perpendicular_to_plane(yColumn, point0, point1, point2);
|
find_vector_perpendicular_to_plane(yColumn, point0, point1, point2);
|
||||||
@@ -1943,14 +1928,11 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius)
|
|||||||
void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b)
|
void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b)
|
||||||
{
|
{
|
||||||
Mat4 temp;
|
Mat4 temp;
|
||||||
register f32 entry0;
|
|
||||||
register f32 entry1;
|
|
||||||
register f32 entry2;
|
|
||||||
|
|
||||||
// column 0
|
// column 0
|
||||||
entry0 = a[0][0];
|
register f32 entry0 = a[0][0];
|
||||||
entry1 = a[0][1];
|
register f32 entry1 = a[0][1];
|
||||||
entry2 = a[0][2];
|
register f32 entry2 = a[0][2];
|
||||||
temp[0][0] = entry0 * b[0][0] + entry1 * b[1][0] + entry2 * b[2][0];
|
temp[0][0] = entry0 * b[0][0] + entry1 * b[1][0] + entry2 * b[2][0];
|
||||||
temp[0][1] = entry0 * b[0][1] + entry1 * b[1][1] + entry2 * b[2][1];
|
temp[0][1] = entry0 * b[0][1] + entry1 * b[1][1] + entry2 * b[2][1];
|
||||||
temp[0][2] = entry0 * b[0][2] + entry1 * b[1][2] + entry2 * b[2][2];
|
temp[0][2] = entry0 * b[0][2] + entry1 * b[1][2] + entry2 * b[2][2];
|
||||||
@@ -1990,9 +1972,7 @@ void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b)
|
|||||||
*/
|
*/
|
||||||
void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s)
|
void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s)
|
||||||
{
|
{
|
||||||
register s32 i;
|
for (register s32 i = 0; i < 4; i++)
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
{
|
{
|
||||||
dest[0][i] = mtx[0][i] * s[0];
|
dest[0][i] = mtx[0][i] * s[0];
|
||||||
dest[1][i] = mtx[1][i] * s[1];
|
dest[1][i] = mtx[1][i] * s[1];
|
||||||
@@ -2363,12 +2343,11 @@ void anim_spline_init(Vec4s *keyFrames)
|
|||||||
s32 anim_spline_poll(Vec3f result)
|
s32 anim_spline_poll(Vec3f result)
|
||||||
{
|
{
|
||||||
Vec4f weights;
|
Vec4f weights;
|
||||||
s32 i;
|
|
||||||
s32 hasEnded = FALSE;
|
s32 hasEnded = FALSE;
|
||||||
|
|
||||||
vec3f_copy(result, gVec3fZero);
|
vec3f_copy(result, gVec3fZero);
|
||||||
spline_get_weights(weights, gSplineKeyframeFraction, gSplineState);
|
spline_get_weights(weights, gSplineKeyframeFraction, gSplineState);
|
||||||
for (i = 0; i < 4; i++)
|
for (s32 i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
result[0] += weights[i] * gSplineKeyframe[i][1];
|
result[0] += weights[i] * gSplineKeyframe[i][1];
|
||||||
result[1] += weights[i] * gSplineKeyframe[i][2];
|
result[1] += weights[i] * gSplineKeyframe[i][2];
|
||||||
@@ -2412,8 +2391,7 @@ s32 anim_spline_poll(Vec3f result)
|
|||||||
*/
|
*/
|
||||||
void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v)
|
void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v)
|
||||||
{
|
{
|
||||||
s32 i;
|
for (s32 i = 0; i < 3; i++)
|
||||||
for (i = 0; i < 3; i++)
|
|
||||||
{
|
{
|
||||||
dst[i] = m[0][i] * v[0] + m[1][i] * v[1] + m[2][i] * v[2];
|
dst[i] = m[0][i] * v[0] + m[1][i] * v[1] + m[2][i] * v[2];
|
||||||
}
|
}
|
||||||
@@ -2429,8 +2407,7 @@ void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v)
|
|||||||
*/
|
*/
|
||||||
void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v)
|
void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v)
|
||||||
{
|
{
|
||||||
s32 i;
|
for (s32 i = 0; i < 3; i++)
|
||||||
for (i = 0; i < 3; i++)
|
|
||||||
{
|
{
|
||||||
dst[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2];
|
dst[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
*/
|
*/
|
||||||
static struct SM64SurfaceCollisionData *find_ceil_from_list(f32 x, f32 y, f32 z, f32 *pheight)
|
static struct SM64SurfaceCollisionData *find_ceil_from_list(f32 x, f32 y, f32 z, f32 *pheight)
|
||||||
{
|
{
|
||||||
register struct SM64SurfaceCollisionData *surf;
|
|
||||||
register f32 x1, z1, x2, z2, x3, z3;
|
|
||||||
struct SM64SurfaceCollisionData *ceil = NULL;
|
struct SM64SurfaceCollisionData *ceil = NULL;
|
||||||
|
|
||||||
ceil = NULL;
|
ceil = NULL;
|
||||||
@@ -22,7 +20,7 @@ static struct SM64SurfaceCollisionData *find_ceil_from_list(f32 x, f32 y, f32 z,
|
|||||||
uint32_t surfCount = loaded_surface_iter_group_size(i);
|
uint32_t surfCount = loaded_surface_iter_group_size(i);
|
||||||
for (int j = 0; j < surfCount; ++j)
|
for (int j = 0; j < surfCount; ++j)
|
||||||
{
|
{
|
||||||
surf = loaded_surface_iter_get_at_index(i, j);
|
register struct SM64SurfaceCollisionData *surf = loaded_surface_iter_get_at_index(i, j);
|
||||||
|
|
||||||
// libsm64: Weed out surfaces whose triangles are actually line segs. TODO do this at surface load time
|
// libsm64: Weed out surfaces whose triangles are actually line segs. TODO do this at surface load time
|
||||||
if (!surf->isValid) continue;
|
if (!surf->isValid) continue;
|
||||||
@@ -30,10 +28,10 @@ static struct SM64SurfaceCollisionData *find_ceil_from_list(f32 x, f32 y, f32 z,
|
|||||||
// Do the check normally done in add_surface_to_cell
|
// Do the check normally done in add_surface_to_cell
|
||||||
if (surf->normal.y >= -0.01f) continue;
|
if (surf->normal.y >= -0.01f) continue;
|
||||||
|
|
||||||
x1 = surf->vertex1[0];
|
register f32 x1 = surf->vertex1[0];
|
||||||
z1 = surf->vertex1[2];
|
register f32 z1 = surf->vertex1[2];
|
||||||
z2 = surf->vertex2[2];
|
register f32 z2 = surf->vertex2[2];
|
||||||
x2 = surf->vertex2[0];
|
register f32 x2 = surf->vertex2[0];
|
||||||
|
|
||||||
// Checking if point is in bounds of the triangle laterally.
|
// Checking if point is in bounds of the triangle laterally.
|
||||||
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) > 0)
|
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) > 0)
|
||||||
@@ -42,8 +40,8 @@ static struct SM64SurfaceCollisionData *find_ceil_from_list(f32 x, f32 y, f32 z,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Slight optimization by checking these later.
|
// Slight optimization by checking these later.
|
||||||
x3 = surf->vertex3[0];
|
register f32 x3 = surf->vertex3[0];
|
||||||
z3 = surf->vertex3[2];
|
register f32 z3 = surf->vertex3[2];
|
||||||
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) > 0)
|
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) > 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -58,7 +56,6 @@ static struct SM64SurfaceCollisionData *find_ceil_from_list(f32 x, f32 y, f32 z,
|
|||||||
f32 ny = surf->normal.y;
|
f32 ny = surf->normal.y;
|
||||||
f32 nz = surf->normal.z;
|
f32 nz = surf->normal.z;
|
||||||
f32 oo = surf->originOffset;
|
f32 oo = surf->originOffset;
|
||||||
f32 height;
|
|
||||||
|
|
||||||
// If a wall, ignore it. Likely a remnant, should never occur.
|
// If a wall, ignore it. Likely a remnant, should never occur.
|
||||||
if (ny == 0.0f)
|
if (ny == 0.0f)
|
||||||
@@ -67,7 +64,7 @@ static struct SM64SurfaceCollisionData *find_ceil_from_list(f32 x, f32 y, f32 z,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the ceil height at the specific point.
|
// Find the ceil height at the specific point.
|
||||||
height = -(x * nx + nz * z + oo) / ny;
|
f32 height = -(x * nx + nz * z + oo) / ny;
|
||||||
|
|
||||||
// Checks for ceiling interaction with a 78 unit buffer.
|
// Checks for ceiling interaction with a 78 unit buffer.
|
||||||
//! (Exposed Ceilings) Because any point above a ceiling counts
|
//! (Exposed Ceilings) Because any point above a ceiling counts
|
||||||
@@ -94,11 +91,6 @@ static struct SM64SurfaceCollisionData *find_ceil_from_list(f32 x, f32 y, f32 z,
|
|||||||
*/
|
*/
|
||||||
static struct SM64SurfaceCollisionData *find_floor_from_list(f32 x, f32 y, f32 z, f32 *pheight)
|
static struct SM64SurfaceCollisionData *find_floor_from_list(f32 x, f32 y, f32 z, f32 *pheight)
|
||||||
{
|
{
|
||||||
register struct SM64SurfaceCollisionData *surf;
|
|
||||||
register f32 x1, z1, x2, z2, x3, z3;
|
|
||||||
f32 nx, ny, nz;
|
|
||||||
f32 oo;
|
|
||||||
f32 height;
|
|
||||||
struct SM64SurfaceCollisionData *floor = NULL;
|
struct SM64SurfaceCollisionData *floor = NULL;
|
||||||
|
|
||||||
uint32_t groupCount = loaded_surface_iter_group_count();
|
uint32_t groupCount = loaded_surface_iter_group_count();
|
||||||
@@ -107,7 +99,7 @@ static struct SM64SurfaceCollisionData *find_floor_from_list(f32 x, f32 y, f32 z
|
|||||||
uint32_t surfCount = loaded_surface_iter_group_size(i);
|
uint32_t surfCount = loaded_surface_iter_group_size(i);
|
||||||
for (int j = 0; j < surfCount; ++j)
|
for (int j = 0; j < surfCount; ++j)
|
||||||
{
|
{
|
||||||
surf = loaded_surface_iter_get_at_index(i, j);
|
register struct SM64SurfaceCollisionData *surf = loaded_surface_iter_get_at_index(i, j);
|
||||||
|
|
||||||
// libsm64: Weed out surfaces whose triangles are actually line segs. TODO do this at surface load time
|
// libsm64: Weed out surfaces whose triangles are actually line segs. TODO do this at surface load time
|
||||||
if (!surf->isValid) continue;
|
if (!surf->isValid) continue;
|
||||||
@@ -115,10 +107,10 @@ static struct SM64SurfaceCollisionData *find_floor_from_list(f32 x, f32 y, f32 z
|
|||||||
// Do the check normally done in add_surface_to_cell
|
// Do the check normally done in add_surface_to_cell
|
||||||
if (surf->normal.y <= 0.01f) continue;
|
if (surf->normal.y <= 0.01f) continue;
|
||||||
|
|
||||||
x1 = surf->vertex1[0];
|
register f32 x1 = surf->vertex1[0];
|
||||||
z1 = surf->vertex1[2];
|
register f32 z1 = surf->vertex1[2];
|
||||||
x2 = surf->vertex2[0];
|
register f32 x2 = surf->vertex2[0];
|
||||||
z2 = surf->vertex2[2];
|
register f32 z2 = surf->vertex2[2];
|
||||||
|
|
||||||
// Check that the point is within the triangle bounds.
|
// Check that the point is within the triangle bounds.
|
||||||
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) < 0)
|
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) < 0)
|
||||||
@@ -127,8 +119,8 @@ static struct SM64SurfaceCollisionData *find_floor_from_list(f32 x, f32 y, f32 z
|
|||||||
}
|
}
|
||||||
|
|
||||||
// To slightly save on computation time, set this later.
|
// To slightly save on computation time, set this later.
|
||||||
x3 = surf->vertex3[0];
|
register f32 x3 = surf->vertex3[0];
|
||||||
z3 = surf->vertex3[2];
|
register f32 z3 = surf->vertex3[2];
|
||||||
|
|
||||||
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) < 0)
|
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) < 0)
|
||||||
{
|
{
|
||||||
@@ -139,10 +131,10 @@ static struct SM64SurfaceCollisionData *find_floor_from_list(f32 x, f32 y, f32 z
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
nx = surf->normal.x;
|
f32 nx = surf->normal.x;
|
||||||
ny = surf->normal.y;
|
f32 ny = surf->normal.y;
|
||||||
nz = surf->normal.z;
|
f32 nz = surf->normal.z;
|
||||||
oo = surf->originOffset;
|
f32 oo = surf->originOffset;
|
||||||
|
|
||||||
// If a wall, ignore it. Likely a remnant, should never occur.
|
// If a wall, ignore it. Likely a remnant, should never occur.
|
||||||
if (ny == 0.0f)
|
if (ny == 0.0f)
|
||||||
@@ -151,7 +143,7 @@ static struct SM64SurfaceCollisionData *find_floor_from_list(f32 x, f32 y, f32 z
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the height of the floor at a given location.
|
// Find the height of the floor at a given location.
|
||||||
height = -(x * nx + nz * z + oo) / ny;
|
f32 height = -(x * nx + nz * z + oo) / ny;
|
||||||
// Checks for floor interaction with a 78 unit buffer.
|
// Checks for floor interaction with a 78 unit buffer.
|
||||||
if (y - (height + -78.0f) < 0.0f)
|
if (y - (height + -78.0f) < 0.0f)
|
||||||
{
|
{
|
||||||
@@ -170,13 +162,10 @@ static struct SM64SurfaceCollisionData *find_floor_from_list(f32 x, f32 y, f32 z
|
|||||||
|
|
||||||
static s32 find_wall_collisions_from_list(struct SM64WallCollisionData *data)
|
static s32 find_wall_collisions_from_list(struct SM64WallCollisionData *data)
|
||||||
{
|
{
|
||||||
register struct SM64SurfaceCollisionData *surf;
|
|
||||||
register f32 offset;
|
|
||||||
register f32 radius = data->radius;
|
register f32 radius = data->radius;
|
||||||
register f32 x = data->x;
|
register f32 x = data->x;
|
||||||
register f32 y = data->y + data->offsetY;
|
register f32 y = data->y + data->offsetY;
|
||||||
register f32 z = data->z;
|
register f32 z = data->z;
|
||||||
register f32 px, pz;
|
|
||||||
register f32 w1, w2, w3;
|
register f32 w1, w2, w3;
|
||||||
register f32 y1, y2, y3;
|
register f32 y1, y2, y3;
|
||||||
s32 numCols = 0;
|
s32 numCols = 0;
|
||||||
@@ -193,7 +182,7 @@ static s32 find_wall_collisions_from_list(struct SM64WallCollisionData *data)
|
|||||||
uint32_t surfCount = loaded_surface_iter_group_size(i);
|
uint32_t surfCount = loaded_surface_iter_group_size(i);
|
||||||
for (int j = 0; j < surfCount; ++j)
|
for (int j = 0; j < surfCount; ++j)
|
||||||
{
|
{
|
||||||
surf = loaded_surface_iter_get_at_index(i, j);
|
register struct SM64SurfaceCollisionData *surf = loaded_surface_iter_get_at_index(i, j);
|
||||||
|
|
||||||
// libsm64: Weed out surfaces whose triangles are actually line segs. TODO do this at surface load time
|
// libsm64: Weed out surfaces whose triangles are actually line segs. TODO do this at surface load time
|
||||||
if (!surf->isValid) continue;
|
if (!surf->isValid) continue;
|
||||||
@@ -212,15 +201,15 @@ static s32 find_wall_collisions_from_list(struct SM64WallCollisionData *data)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = surf->normal.x * x + surf->normal.y * y + surf->normal.z * z + surf->originOffset;
|
register f32 offset = surf->normal.x * x + surf->normal.y * y + surf->normal.z * z + surf->originOffset;
|
||||||
|
|
||||||
if (offset < -radius || offset > radius)
|
if (offset < -radius || offset > radius)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
px = x;
|
register f32 px = x;
|
||||||
pz = z;
|
register f32 pz = z;
|
||||||
|
|
||||||
//! (Quantum Tunneling) Due to issues with the vertices walls choose and
|
//! (Quantum Tunneling) Due to issues with the vertices walls choose and
|
||||||
// the fact they are floating point, certain floating point positions
|
// the fact they are floating point, certain floating point positions
|
||||||
|
|||||||
@@ -7,11 +7,10 @@
|
|||||||
Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx)
|
Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx)
|
||||||
{
|
{
|
||||||
Mat4 sp20;
|
Mat4 sp20;
|
||||||
struct Object *sp1C;
|
|
||||||
|
|
||||||
if (run == TRUE)
|
if (run == TRUE)
|
||||||
{
|
{
|
||||||
sp1C = (struct Object *)gCurGraphNodeObject;
|
struct Object *sp1C = (struct Object *)gCurGraphNodeObject;
|
||||||
if (sp1C == gMarioObject && sp1C->prevObj != NULL)
|
if (sp1C == gMarioObject && sp1C->prevObj != NULL)
|
||||||
{
|
{
|
||||||
create_transformation_from_matrices(sp20, mtx, *gCurGraphNodeCamera->matrixPtr);
|
create_transformation_from_matrices(sp20, mtx, *gCurGraphNodeCamera->matrixPtr);
|
||||||
|
|||||||
@@ -446,12 +446,9 @@ u32 able_to_grab_object(struct MarioState *m, UNUSED struct Object *o)
|
|||||||
|
|
||||||
struct Object *mario_get_collided_object(struct MarioState *m, u32 interactType)
|
struct Object *mario_get_collided_object(struct MarioState *m, u32 interactType)
|
||||||
{
|
{
|
||||||
s32 i;
|
for (s32 i = 0; i < m->marioObj->numCollidedObjs; i++)
|
||||||
struct Object *object;
|
|
||||||
|
|
||||||
for (i = 0; i < m->marioObj->numCollidedObjs; i++)
|
|
||||||
{
|
{
|
||||||
object = m->marioObj->collidedObjs[i];
|
struct Object *object = m->marioObj->collidedObjs[i];
|
||||||
|
|
||||||
if (object->oInteractType == interactType)
|
if (object->oInteractType == interactType)
|
||||||
{
|
{
|
||||||
@@ -502,10 +499,6 @@ u32 bully_knock_back_mario(struct MarioState *mario)
|
|||||||
{
|
{
|
||||||
struct BullyCollisionData marioData;
|
struct BullyCollisionData marioData;
|
||||||
struct BullyCollisionData bullyData;
|
struct BullyCollisionData bullyData;
|
||||||
s16 newMarioYaw;
|
|
||||||
s16 newBullyYaw;
|
|
||||||
s16 marioDYaw;
|
|
||||||
UNUSED s16 bullyDYaw;
|
|
||||||
|
|
||||||
u32 bonkAction = 0;
|
u32 bonkAction = 0;
|
||||||
|
|
||||||
@@ -531,11 +524,11 @@ u32 bully_knock_back_mario(struct MarioState *mario)
|
|||||||
transfer_bully_speed(&bullyData, &marioData);
|
transfer_bully_speed(&bullyData, &marioData);
|
||||||
}
|
}
|
||||||
|
|
||||||
newMarioYaw = atan2s(marioData.velZ, marioData.velX);
|
s16 newMarioYaw = atan2s(marioData.velZ, marioData.velX);
|
||||||
newBullyYaw = atan2s(bullyData.velZ, bullyData.velX);
|
s16 newBullyYaw = atan2s(bullyData.velZ, bullyData.velX);
|
||||||
|
|
||||||
marioDYaw = newMarioYaw - mario->faceAngle[1];
|
s16 marioDYaw = newMarioYaw - mario->faceAngle[1];
|
||||||
bullyDYaw = newBullyYaw - bully->oMoveAngleYaw;
|
s16 bullyDYaw = newBullyYaw - bully->oMoveAngleYaw;
|
||||||
|
|
||||||
mario->faceAngle[1] = newMarioYaw;
|
mario->faceAngle[1] = newMarioYaw;
|
||||||
mario->forwardVel = sqrtf(marioData.velX * marioData.velX + marioData.velZ * marioData.velZ);
|
mario->forwardVel = sqrtf(marioData.velX * marioData.velX + marioData.velZ * marioData.velZ);
|
||||||
@@ -814,15 +807,13 @@ u32 take_damage_from_interact_object(struct MarioState *m)
|
|||||||
|
|
||||||
u32 take_damage_and_knock_back(struct MarioState *m, struct Object *o)
|
u32 take_damage_and_knock_back(struct MarioState *m, struct Object *o)
|
||||||
{
|
{
|
||||||
u32 damage;
|
|
||||||
|
|
||||||
if (!sInvulnerable && !(m->flags & MARIO_VANISH_CAP)
|
if (!sInvulnerable && !(m->flags & MARIO_VANISH_CAP)
|
||||||
&& !(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY))
|
&& !(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY))
|
||||||
{
|
{
|
||||||
o->oInteractStatus = INT_STATUS_INTERACTED | INT_STATUS_ATTACKED_MARIO;
|
o->oInteractStatus = INT_STATUS_INTERACTED | INT_STATUS_ATTACKED_MARIO;
|
||||||
m->interactObj = o;
|
m->interactObj = o;
|
||||||
|
|
||||||
damage = take_damage_from_interact_object(m);
|
u32 damage = take_damage_from_interact_object(m);
|
||||||
|
|
||||||
if (o->oInteractionSubtype & INT_SUBTYPE_BIG_KNOCKBACK)
|
if (o->oInteractionSubtype & INT_SUBTYPE_BIG_KNOCKBACK)
|
||||||
{
|
{
|
||||||
@@ -880,8 +871,6 @@ u32 check_object_grab_mario(struct MarioState *m, UNUSED u32 interactType, struc
|
|||||||
|
|
||||||
u32 mario_can_talk(struct MarioState *m, u32 arg)
|
u32 mario_can_talk(struct MarioState *m, u32 arg)
|
||||||
{
|
{
|
||||||
s16 val6;
|
|
||||||
|
|
||||||
if ((m->action & ACT_FLAG_IDLE) != 0x00000000)
|
if ((m->action & ACT_FLAG_IDLE) != 0x00000000)
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -894,7 +883,7 @@ u32 mario_can_talk(struct MarioState *m, u32 arg)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
val6 = m->marioObj->header.gfx.animInfo.animID;
|
s16 val6 = m->marioObj->header.gfx.animInfo.animID;
|
||||||
|
|
||||||
if (val6 == 0x0080 || val6 == 0x007F || val6 == 0x006C)
|
if (val6 == 0x0080 || val6 == 0x007F || val6 == 0x006C)
|
||||||
{
|
{
|
||||||
|
|||||||
+18
-38
@@ -228,9 +228,6 @@ s32 is_anim_past_frame(struct MarioState *m, s16 animFrame)
|
|||||||
*/
|
*/
|
||||||
s16 find_mario_anim_flags_and_translation(struct Object *obj, s32 yaw, Vec3s translation)
|
s16 find_mario_anim_flags_and_translation(struct Object *obj, s32 yaw, Vec3s translation)
|
||||||
{
|
{
|
||||||
f32 dx;
|
|
||||||
f32 dz;
|
|
||||||
|
|
||||||
struct Animation *curAnim = (void *)obj->header.gfx.animInfo.curAnim;
|
struct Animation *curAnim = (void *)obj->header.gfx.animInfo.curAnim;
|
||||||
s16 animFrame = geo_update_animation_frame(&obj->header.gfx.animInfo, NULL);
|
s16 animFrame = geo_update_animation_frame(&obj->header.gfx.animInfo, NULL);
|
||||||
u16 *animIndex = segmented_to_virtual(curAnim->index);
|
u16 *animIndex = segmented_to_virtual(curAnim->index);
|
||||||
@@ -239,9 +236,9 @@ s16 find_mario_anim_flags_and_translation(struct Object *obj, s32 yaw, Vec3s tra
|
|||||||
f32 s = sins(yaw);
|
f32 s = sins(yaw);
|
||||||
f32 c = coss(yaw);
|
f32 c = coss(yaw);
|
||||||
|
|
||||||
dx = *(animValues + retrieve_animation_index(animFrame, &animIndex)) / 4.0f;
|
f32 dx = *(animValues + retrieve_animation_index(animFrame, &animIndex)) / 4.0f;
|
||||||
translation[1] = *(animValues + retrieve_animation_index(animFrame, &animIndex)) / 4.0f;
|
translation[1] = *(animValues + retrieve_animation_index(animFrame, &animIndex)) / 4.0f;
|
||||||
dz = *(animValues + retrieve_animation_index(animFrame, &animIndex)) / 4.0f;
|
f32 dz = *(animValues + retrieve_animation_index(animFrame, &animIndex)) / 4.0f;
|
||||||
|
|
||||||
translation[0] = dx * c + dz * s;
|
translation[0] = dx * c + dz * s;
|
||||||
translation[2] = -dx * s + dz * c;
|
translation[2] = -dx * s + dz * c;
|
||||||
@@ -255,9 +252,8 @@ s16 find_mario_anim_flags_and_translation(struct Object *obj, s32 yaw, Vec3s tra
|
|||||||
void update_mario_pos_for_anim(struct MarioState *m)
|
void update_mario_pos_for_anim(struct MarioState *m)
|
||||||
{
|
{
|
||||||
Vec3s translation;
|
Vec3s translation;
|
||||||
s16 flags;
|
|
||||||
|
|
||||||
flags = find_mario_anim_flags_and_translation(m->marioObj, m->faceAngle[1], translation);
|
s16 flags = find_mario_anim_flags_and_translation(m->marioObj, m->faceAngle[1], translation);
|
||||||
|
|
||||||
if (flags & (ANIM_FLAG_HOR_TRANS | ANIM_FLAG_6))
|
if (flags & (ANIM_FLAG_HOR_TRANS | ANIM_FLAG_6))
|
||||||
{
|
{
|
||||||
@@ -360,8 +356,7 @@ void play_sound_and_spawn_particles(struct MarioState *m, u32 soundBits, u32 wav
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->flags & MARIO_METAL_CAP || soundBits == SOUND_ACTION_UNSTUCK_FROM_GROUND
|
if (m->flags & MARIO_METAL_CAP || soundBits == SOUND_ACTION_UNSTUCK_FROM_GROUND || soundBits == SOUND_MARIO_PUNCH_HOO)
|
||||||
|| soundBits == SOUND_MARIO_PUNCH_HOO)
|
|
||||||
{
|
{
|
||||||
play_sound(soundBits, m->marioObj->header.gfx.cameraToObject);
|
play_sound(soundBits, m->marioObj->header.gfx.cameraToObject);
|
||||||
}
|
}
|
||||||
@@ -554,11 +549,10 @@ u32 mario_get_terrain_sound_addend(struct MarioState *m)
|
|||||||
{
|
{
|
||||||
s16 floorSoundType;
|
s16 floorSoundType;
|
||||||
s32 ret = SOUND_TERRAIN_DEFAULT << 16;
|
s32 ret = SOUND_TERRAIN_DEFAULT << 16;
|
||||||
s32 floorType;
|
|
||||||
|
|
||||||
if (m->floor != NULL)
|
if (m->floor != NULL)
|
||||||
{
|
{
|
||||||
floorType = m->floor->type;
|
s32 floorType = m->floor->type;
|
||||||
s16 terrainType = m->curTerrain;
|
s16 terrainType = m->curTerrain;
|
||||||
|
|
||||||
if (gCurrLevelNum != LEVEL_LLL && m->floorHeight < m->waterLevel - 10)
|
if (gCurrLevelNum != LEVEL_LLL && m->floorHeight < m->waterLevel - 10)
|
||||||
@@ -790,12 +784,11 @@ s32 mario_floor_is_steep(struct MarioState *m)
|
|||||||
f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f32 distFromMario)
|
f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f32 distFromMario)
|
||||||
{
|
{
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor;
|
||||||
f32 floorY;
|
|
||||||
|
|
||||||
f32 y = sins(m->faceAngle[1] + angleFromMario) * distFromMario;
|
f32 y = sins(m->faceAngle[1] + angleFromMario) * distFromMario;
|
||||||
f32 x = coss(m->faceAngle[1] + angleFromMario) * distFromMario;
|
f32 x = coss(m->faceAngle[1] + angleFromMario) * distFromMario;
|
||||||
|
|
||||||
floorY = find_floor(m->pos[0] + y, m->pos[1] + 100.0f, m->pos[2] + x, &floor);
|
f32 floorY = find_floor(m->pos[0] + y, m->pos[1] + 100.0f, m->pos[2] + x, &floor);
|
||||||
|
|
||||||
return floorY;
|
return floorY;
|
||||||
}
|
}
|
||||||
@@ -806,20 +799,18 @@ f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f
|
|||||||
s16 find_floor_slope(struct MarioState *m, s16 yawOffset)
|
s16 find_floor_slope(struct MarioState *m, s16 yawOffset)
|
||||||
{
|
{
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor;
|
||||||
f32 forwardFloorY, backwardFloorY;
|
|
||||||
f32 forwardYDelta, backwardYDelta;
|
|
||||||
s16 result;
|
s16 result;
|
||||||
|
|
||||||
f32 x = sins(m->faceAngle[1] + yawOffset) * 5.0f;
|
f32 x = sins(m->faceAngle[1] + yawOffset) * 5.0f;
|
||||||
f32 z = coss(m->faceAngle[1] + yawOffset) * 5.0f;
|
f32 z = coss(m->faceAngle[1] + yawOffset) * 5.0f;
|
||||||
|
|
||||||
forwardFloorY = find_floor(m->pos[0] + x, m->pos[1] + 100.0f, m->pos[2] + z, &floor);
|
f32 forwardFloorY = find_floor(m->pos[0] + x, m->pos[1] + 100.0f, m->pos[2] + z, &floor);
|
||||||
backwardFloorY = find_floor(m->pos[0] - x, m->pos[1] + 100.0f, m->pos[2] - z, &floor);
|
f32 backwardFloorY = find_floor(m->pos[0] - x, m->pos[1] + 100.0f, m->pos[2] - z, &floor);
|
||||||
|
|
||||||
//! If Mario is near OOB, these floorY's can sometimes be -11000.
|
//! If Mario is near OOB, these floorY's can sometimes be -11000.
|
||||||
// This will cause these to be off and give improper slopes.
|
// This will cause these to be off and give improper slopes.
|
||||||
forwardYDelta = forwardFloorY - m->pos[1];
|
f32 forwardYDelta = forwardFloorY - m->pos[1];
|
||||||
backwardYDelta = m->pos[1] - backwardFloorY;
|
f32 backwardYDelta = m->pos[1] - backwardFloorY;
|
||||||
|
|
||||||
if (forwardYDelta * forwardYDelta < backwardYDelta * backwardYDelta)
|
if (forwardYDelta * forwardYDelta < backwardYDelta * backwardYDelta)
|
||||||
{
|
{
|
||||||
@@ -1441,14 +1432,11 @@ void squish_mario_model(struct MarioState *m)
|
|||||||
*/
|
*/
|
||||||
void debug_print_speed_action_normal(struct MarioState *m)
|
void debug_print_speed_action_normal(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 steepness;
|
|
||||||
f32 floor_nY;
|
|
||||||
|
|
||||||
if (gShowDebugText)
|
if (gShowDebugText)
|
||||||
{
|
{
|
||||||
steepness = sqrtf(
|
f32 steepness = sqrtf(
|
||||||
m->floor->normal.x * m->floor->normal.x + m->floor->normal.z * m->floor->normal.z);
|
m->floor->normal.x * m->floor->normal.x + m->floor->normal.z * m->floor->normal.z);
|
||||||
floor_nY = m->floor->normal.y;
|
f32 floor_nY = m->floor->normal.y;
|
||||||
|
|
||||||
print_text_fmt_int(210, 88, "ANG %d", atan2s(floor_nY, steepness) * 180.0f / 32768.0f);
|
print_text_fmt_int(210, 88, "ANG %d", atan2s(floor_nY, steepness) * 180.0f / 32768.0f);
|
||||||
|
|
||||||
@@ -1546,7 +1534,6 @@ void update_mario_joystick_inputs(struct MarioState *m)
|
|||||||
void update_mario_geometry_inputs(struct MarioState *m)
|
void update_mario_geometry_inputs(struct MarioState *m)
|
||||||
{
|
{
|
||||||
//f32 gasLevel;
|
//f32 gasLevel;
|
||||||
f32 ceilToFloorDist;
|
|
||||||
|
|
||||||
f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 60.0f, 50.0f);
|
f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 60.0f, 50.0f);
|
||||||
f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 30.0f, 24.0f);
|
f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 30.0f, 24.0f);
|
||||||
@@ -1582,10 +1569,9 @@ void update_mario_geometry_inputs(struct MarioState *m)
|
|||||||
m->input |= INPUT_ABOVE_SLIDE;
|
m->input |= INPUT_ABOVE_SLIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->floor->flags & SURFACE_FLAG_DYNAMIC
|
if (m->floor->flags & SURFACE_FLAG_DYNAMIC || (m->ceil && m->ceil->flags & SURFACE_FLAG_DYNAMIC))
|
||||||
|| (m->ceil && m->ceil->flags & SURFACE_FLAG_DYNAMIC))
|
|
||||||
{
|
{
|
||||||
ceilToFloorDist = m->ceilHeight - m->floorHeight;
|
f32 ceilToFloorDist = m->ceilHeight - m->floorHeight;
|
||||||
|
|
||||||
if (0.0f <= ceilToFloorDist && ceilToFloorDist <= 150.0f)
|
if (0.0f <= ceilToFloorDist && ceilToFloorDist <= 150.0f)
|
||||||
{
|
{
|
||||||
@@ -1673,13 +1659,10 @@ void update_mario_inputs(struct MarioState *m)
|
|||||||
*/
|
*/
|
||||||
void set_submerged_cam_preset_and_spawn_bubbles(struct MarioState *m)
|
void set_submerged_cam_preset_and_spawn_bubbles(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 heightBelowWater;
|
|
||||||
s16 camPreset;
|
|
||||||
|
|
||||||
if ((m->action & ACT_GROUP_MASK) == ACT_GROUP_SUBMERGED)
|
if ((m->action & ACT_GROUP_MASK) == ACT_GROUP_SUBMERGED)
|
||||||
{
|
{
|
||||||
heightBelowWater = (f32)(m->waterLevel - 80) - m->pos[1];
|
f32 heightBelowWater = (f32)(m->waterLevel - 80) - m->pos[1];
|
||||||
camPreset = m->area->camera->mode;
|
s16 camPreset = m->area->camera->mode;
|
||||||
|
|
||||||
if (m->action & ACT_FLAG_METAL_WATER)
|
if (m->action & ACT_FLAG_METAL_WATER)
|
||||||
{
|
{
|
||||||
@@ -1719,8 +1702,6 @@ void set_submerged_cam_preset_and_spawn_bubbles(struct MarioState *m)
|
|||||||
*/
|
*/
|
||||||
void update_mario_health(struct MarioState *m)
|
void update_mario_health(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 terrainIsSnow;
|
|
||||||
|
|
||||||
if (m->health >= 0x100)
|
if (m->health >= 0x100)
|
||||||
{
|
{
|
||||||
// When already healing or hurting Mario, Mario's HP is not changed any more here.
|
// When already healing or hurting Mario, Mario's HP is not changed any more here.
|
||||||
@@ -1737,7 +1718,7 @@ void update_mario_health(struct MarioState *m)
|
|||||||
{
|
{
|
||||||
if (m->action & ACT_FLAG_SWIMMING && !(m->action & ACT_FLAG_INTANGIBLE))
|
if (m->action & ACT_FLAG_SWIMMING && !(m->action & ACT_FLAG_INTANGIBLE))
|
||||||
{
|
{
|
||||||
terrainIsSnow = m->floor != NULL && m->curTerrain == TERRAIN_SNOW;
|
s32 terrainIsSnow = m->floor != NULL && m->curTerrain == TERRAIN_SNOW;
|
||||||
|
|
||||||
// When Mario is near the water surface, recover health (unless in snow),
|
// When Mario is near the water surface, recover health (unless in snow),
|
||||||
// when in snow terrains lose 3 health.
|
// when in snow terrains lose 3 health.
|
||||||
@@ -1855,11 +1836,10 @@ u64 sCapFlickerFrames = 0x4444449249255555;
|
|||||||
u32 update_and_return_cap_flags(struct MarioState *m)
|
u32 update_and_return_cap_flags(struct MarioState *m)
|
||||||
{
|
{
|
||||||
u32 flags = m->flags;
|
u32 flags = m->flags;
|
||||||
u32 action;
|
|
||||||
|
|
||||||
if (m->capTimer > 0)
|
if (m->capTimer > 0)
|
||||||
{
|
{
|
||||||
action = m->action;
|
u32 action = m->action;
|
||||||
|
|
||||||
if (m->capTimer <= 60
|
if (m->capTimer <= 60
|
||||||
|| (action != ACT_READING_AUTOMATIC_DIALOG && action != ACT_READING_NPC_DIALOG
|
|| (action != ACT_READING_AUTOMATIC_DIALOG && action != ACT_READING_NPC_DIALOG
|
||||||
|
|||||||
@@ -78,10 +78,9 @@ s32 lava_boost_on_wall(struct MarioState *m)
|
|||||||
|
|
||||||
s32 check_fall_damage(struct MarioState *m, u32 hardFallAction)
|
s32 check_fall_damage(struct MarioState *m, u32 hardFallAction)
|
||||||
{
|
{
|
||||||
f32 fallHeight;
|
|
||||||
f32 damageHeight;
|
f32 damageHeight;
|
||||||
|
|
||||||
fallHeight = m->peakHeight - m->pos[1];
|
f32 fallHeight = m->peakHeight - m->pos[1];
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wtype-limits"
|
#pragma GCC diagnostic ignored "-Wtype-limits"
|
||||||
@@ -177,20 +176,16 @@ s32 check_fall_damage_or_get_stuck(struct MarioState *m, u32 hardFallAction)
|
|||||||
|
|
||||||
s32 check_horizontal_wind(struct MarioState *m)
|
s32 check_horizontal_wind(struct MarioState *m)
|
||||||
{
|
{
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor = m->floor;
|
||||||
f32 speed;
|
|
||||||
s16 pushAngle;
|
|
||||||
|
|
||||||
floor = m->floor;
|
|
||||||
|
|
||||||
if (floor->type == SURFACE_HORIZONTAL_WIND)
|
if (floor->type == SURFACE_HORIZONTAL_WIND)
|
||||||
{
|
{
|
||||||
pushAngle = floor->force << 8;
|
s16 pushAngle = floor->force << 8;
|
||||||
|
|
||||||
m->slideVelX += 1.2f * sins(pushAngle);
|
m->slideVelX += 1.2f * sins(pushAngle);
|
||||||
m->slideVelZ += 1.2f * coss(pushAngle);
|
m->slideVelZ += 1.2f * coss(pushAngle);
|
||||||
|
|
||||||
speed = sqrtf(m->slideVelX * m->slideVelX + m->slideVelZ * m->slideVelZ);
|
f32 speed = sqrtf(m->slideVelX * m->slideVelX + m->slideVelZ * m->slideVelZ);
|
||||||
|
|
||||||
if (speed > 48.0f)
|
if (speed > 48.0f)
|
||||||
{
|
{
|
||||||
@@ -251,19 +246,16 @@ void update_air_with_turn(struct MarioState *m)
|
|||||||
void update_air_without_turn(struct MarioState *m)
|
void update_air_without_turn(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 sidewaysSpeed = 0.0f;
|
f32 sidewaysSpeed = 0.0f;
|
||||||
f32 dragThreshold;
|
|
||||||
s16 intendedDYaw;
|
|
||||||
f32 intendedMag;
|
|
||||||
|
|
||||||
if (!check_horizontal_wind(m))
|
if (!check_horizontal_wind(m))
|
||||||
{
|
{
|
||||||
dragThreshold = m->action == ACT_LONG_JUMP ? 48.0f : 32.0f;
|
f32 dragThreshold = m->action == ACT_LONG_JUMP ? 48.0f : 32.0f;
|
||||||
m->forwardVel = approach_f32(m->forwardVel, 0.0f, 0.35f, 0.35f);
|
m->forwardVel = approach_f32(m->forwardVel, 0.0f, 0.35f, 0.35f);
|
||||||
|
|
||||||
if (m->input & INPUT_NONZERO_ANALOG)
|
if (m->input & INPUT_NONZERO_ANALOG)
|
||||||
{
|
{
|
||||||
intendedDYaw = m->intendedYaw - m->faceAngle[1];
|
s16 intendedDYaw = m->intendedYaw - m->faceAngle[1];
|
||||||
intendedMag = m->intendedMag / 32.0f;
|
f32 intendedMag = m->intendedMag / 32.0f;
|
||||||
|
|
||||||
m->forwardVel += intendedMag * coss(intendedDYaw) * 1.5f;
|
m->forwardVel += intendedMag * coss(intendedDYaw) * 1.5f;
|
||||||
sidewaysSpeed = intendedMag * sins(intendedDYaw) * 10.0f;
|
sidewaysSpeed = intendedMag * sins(intendedDYaw) * 10.0f;
|
||||||
@@ -292,13 +284,10 @@ void update_air_without_turn(struct MarioState *m)
|
|||||||
|
|
||||||
void update_lava_boost_or_twirling(struct MarioState *m)
|
void update_lava_boost_or_twirling(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s16 intendedDYaw;
|
|
||||||
f32 intendedMag;
|
|
||||||
|
|
||||||
if (m->input & INPUT_NONZERO_ANALOG)
|
if (m->input & INPUT_NONZERO_ANALOG)
|
||||||
{
|
{
|
||||||
intendedDYaw = m->intendedYaw - m->faceAngle[1];
|
s16 intendedDYaw = m->intendedYaw - m->faceAngle[1];
|
||||||
intendedMag = m->intendedMag / 32.0f;
|
f32 intendedMag = m->intendedMag / 32.0f;
|
||||||
|
|
||||||
m->forwardVel += coss(intendedDYaw) * intendedMag;
|
m->forwardVel += coss(intendedDYaw) * intendedMag;
|
||||||
m->faceAngle[1] += sins(intendedDYaw) * intendedMag * 1024.0f;
|
m->faceAngle[1] += sins(intendedDYaw) * intendedMag * 1024.0f;
|
||||||
@@ -451,11 +440,9 @@ void update_flying(struct MarioState *m)
|
|||||||
|
|
||||||
u32 common_air_action_step(struct MarioState *m, u32 landAction, s32 animation, u32 stepArg)
|
u32 common_air_action_step(struct MarioState *m, u32 landAction, s32 animation, u32 stepArg)
|
||||||
{
|
{
|
||||||
u32 stepResult;
|
|
||||||
|
|
||||||
update_air_without_turn(m);
|
update_air_without_turn(m);
|
||||||
|
|
||||||
stepResult = perform_air_step(m, stepArg);
|
u32 stepResult = perform_air_step(m, stepArg);
|
||||||
switch (stepResult)
|
switch (stepResult)
|
||||||
{
|
{
|
||||||
case AIR_STEP_NONE:
|
case AIR_STEP_NONE:
|
||||||
@@ -1091,16 +1078,13 @@ s32 act_steep_jump(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_ground_pound(struct MarioState *m)
|
s32 act_ground_pound(struct MarioState *m)
|
||||||
{
|
{
|
||||||
u32 stepResult;
|
|
||||||
f32 yOffset;
|
|
||||||
|
|
||||||
play_sound_if_no_flag(m, SOUND_ACTION_THROW, MARIO_ACTION_SOUND_PLAYED);
|
play_sound_if_no_flag(m, SOUND_ACTION_THROW, MARIO_ACTION_SOUND_PLAYED);
|
||||||
|
|
||||||
if (m->actionState == 0)
|
if (m->actionState == 0)
|
||||||
{
|
{
|
||||||
if (m->actionTimer < 10)
|
if (m->actionTimer < 10)
|
||||||
{
|
{
|
||||||
yOffset = 20 - 2 * m->actionTimer;
|
f32 yOffset = 20 - 2 * m->actionTimer;
|
||||||
if (m->pos[1] + yOffset + 160.0f < m->ceilHeight)
|
if (m->pos[1] + yOffset + 160.0f < m->ceilHeight)
|
||||||
{
|
{
|
||||||
m->pos[1] += yOffset;
|
m->pos[1] += yOffset;
|
||||||
@@ -1131,7 +1115,7 @@ s32 act_ground_pound(struct MarioState *m)
|
|||||||
{
|
{
|
||||||
set_mario_animation(m, MARIO_ANIM_GROUND_POUND);
|
set_mario_animation(m, MARIO_ANIM_GROUND_POUND);
|
||||||
|
|
||||||
stepResult = perform_air_step(m, 0);
|
u32 stepResult = perform_air_step(m, 0);
|
||||||
if (stepResult == AIR_STEP_LANDED)
|
if (stepResult == AIR_STEP_LANDED)
|
||||||
{
|
{
|
||||||
if (should_get_stuck_in_ground(m))
|
if (should_get_stuck_in_ground(m))
|
||||||
@@ -1303,11 +1287,9 @@ u32 common_air_knockback_step(
|
|||||||
struct MarioState *m, u32 landAction, u32 hardFallAction, s32 animation,
|
struct MarioState *m, u32 landAction, u32 hardFallAction, s32 animation,
|
||||||
f32 speed)
|
f32 speed)
|
||||||
{
|
{
|
||||||
u32 stepResult;
|
|
||||||
|
|
||||||
mario_set_forward_vel(m, speed);
|
mario_set_forward_vel(m, speed);
|
||||||
|
|
||||||
stepResult = perform_air_step(m, 0);
|
u32 stepResult = perform_air_step(m, 0);
|
||||||
switch (stepResult)
|
switch (stepResult)
|
||||||
{
|
{
|
||||||
case AIR_STEP_NONE:
|
case AIR_STEP_NONE:
|
||||||
@@ -1446,8 +1428,6 @@ s32 act_thrown_backward(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_thrown_forward(struct MarioState *m)
|
s32 act_thrown_forward(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s16 pitch;
|
|
||||||
|
|
||||||
u32 landAction;
|
u32 landAction;
|
||||||
if (m->actionArg != 0)
|
if (m->actionArg != 0)
|
||||||
{
|
{
|
||||||
@@ -1463,7 +1443,7 @@ s32 act_thrown_forward(struct MarioState *m)
|
|||||||
if (common_air_knockback_step(m, landAction, ACT_HARD_FORWARD_GROUND_KB, 0x002D, m->forwardVel)
|
if (common_air_knockback_step(m, landAction, ACT_HARD_FORWARD_GROUND_KB, 0x002D, m->forwardVel)
|
||||||
== AIR_STEP_NONE)
|
== AIR_STEP_NONE)
|
||||||
{
|
{
|
||||||
pitch = atan2s(m->forwardVel, -m->vel[1]);
|
s16 pitch = atan2s(m->forwardVel, -m->vel[1]);
|
||||||
if (pitch > 0x1800)
|
if (pitch > 0x1800)
|
||||||
{
|
{
|
||||||
pitch = 0x1800;
|
pitch = 0x1800;
|
||||||
@@ -1943,8 +1923,6 @@ s32 act_slide_kick(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_jump_kick(struct MarioState *m)
|
s32 act_jump_kick(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 animFrame;
|
|
||||||
|
|
||||||
if (m->actionState == 0)
|
if (m->actionState == 0)
|
||||||
{
|
{
|
||||||
play_sound_if_no_flag(m, SOUND_MARIO_PUNCH_HOO, MARIO_ACTION_SOUND_PLAYED);
|
play_sound_if_no_flag(m, SOUND_MARIO_PUNCH_HOO, MARIO_ACTION_SOUND_PLAYED);
|
||||||
@@ -1953,7 +1931,7 @@ s32 act_jump_kick(struct MarioState *m)
|
|||||||
m->actionState = 1;
|
m->actionState = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
animFrame = m->marioObj->header.gfx.animInfo.animFrame;
|
s32 animFrame = m->marioObj->header.gfx.animInfo.animFrame;
|
||||||
if (animFrame == 0)
|
if (animFrame == 0)
|
||||||
{
|
{
|
||||||
m->marioBodyState->punchState = 2 << 6 | 6;
|
m->marioBodyState->punchState = 2 << 6 | 6;
|
||||||
|
|||||||
@@ -70,9 +70,6 @@ s32 set_pole_position(struct MarioState *m, f32 offsetY)
|
|||||||
UNUSED s32 unused3;
|
UNUSED s32 unused3;
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor;
|
||||||
struct SM64SurfaceCollisionData *ceil;
|
struct SM64SurfaceCollisionData *ceil;
|
||||||
f32 floorHeight;
|
|
||||||
f32 ceilHeight;
|
|
||||||
s32 collided;
|
|
||||||
s32 result = POLE_NONE;
|
s32 result = POLE_NONE;
|
||||||
f32 poleTop = m->usedObj->hitboxHeight - 100.0f;
|
f32 poleTop = m->usedObj->hitboxHeight - 100.0f;
|
||||||
struct Object *marioObj = m->marioObj;
|
struct Object *marioObj = m->marioObj;
|
||||||
@@ -86,17 +83,17 @@ s32 set_pole_position(struct MarioState *m, f32 offsetY)
|
|||||||
m->pos[2] = m->usedObj->oPosZ;
|
m->pos[2] = m->usedObj->oPosZ;
|
||||||
m->pos[1] = m->usedObj->oPosY + marioObj->oMarioPolePos + offsetY;
|
m->pos[1] = m->usedObj->oPosY + marioObj->oMarioPolePos + offsetY;
|
||||||
|
|
||||||
collided = f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 60.0f, 50.0f);
|
s32 collided = f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 60.0f, 50.0f);
|
||||||
collided |= f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 30.0f, 24.0f);
|
collided |= f32_find_wall_collision(&m->pos[0], &m->pos[1], &m->pos[2], 30.0f, 24.0f);
|
||||||
|
|
||||||
ceilHeight = vec3f_find_ceil(m->pos, m->pos[1], &ceil);
|
f32 ceilHeight = vec3f_find_ceil(m->pos, m->pos[1], &ceil);
|
||||||
if (m->pos[1] > ceilHeight - 160.0f)
|
if (m->pos[1] > ceilHeight - 160.0f)
|
||||||
{
|
{
|
||||||
m->pos[1] = ceilHeight - 160.0f;
|
m->pos[1] = ceilHeight - 160.0f;
|
||||||
marioObj->oMarioPolePos = m->pos[1] - m->usedObj->oPosY;
|
marioObj->oMarioPolePos = m->pos[1] - m->usedObj->oPosY;
|
||||||
}
|
}
|
||||||
|
|
||||||
floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &floor);
|
f32 floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &floor);
|
||||||
if (m->pos[1] < floorHeight)
|
if (m->pos[1] < floorHeight)
|
||||||
{
|
{
|
||||||
m->pos[1] = floorHeight;
|
m->pos[1] = floorHeight;
|
||||||
@@ -360,13 +357,10 @@ s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos)
|
|||||||
UNUSED s32 unused;
|
UNUSED s32 unused;
|
||||||
struct SM64SurfaceCollisionData *ceil;
|
struct SM64SurfaceCollisionData *ceil;
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor;
|
||||||
f32 ceilHeight;
|
|
||||||
f32 floorHeight;
|
|
||||||
f32 ceilOffset;
|
|
||||||
|
|
||||||
m->wall = resolve_and_return_wall_collisions(nextPos, 50.0f, 50.0f);
|
m->wall = resolve_and_return_wall_collisions(nextPos, 50.0f, 50.0f);
|
||||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
f32 floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||||
ceilHeight = vec3f_find_ceil(nextPos, floorHeight, &ceil);
|
f32 ceilHeight = vec3f_find_ceil(nextPos, floorHeight, &ceil);
|
||||||
|
|
||||||
if (floor == NULL)
|
if (floor == NULL)
|
||||||
{
|
{
|
||||||
@@ -385,7 +379,7 @@ s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos)
|
|||||||
return HANG_LEFT_CEIL;
|
return HANG_LEFT_CEIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ceilOffset = ceilHeight - (nextPos[1] + 160.0f);
|
f32 ceilOffset = ceilHeight - (nextPos[1] + 160.0f);
|
||||||
if (ceilOffset < -30.0f)
|
if (ceilOffset < -30.0f)
|
||||||
{
|
{
|
||||||
return HANG_HIT_CEIL_OR_OOB;
|
return HANG_HIT_CEIL_OR_OOB;
|
||||||
@@ -408,7 +402,6 @@ s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos)
|
|||||||
|
|
||||||
s32 update_hang_moving(struct MarioState *m)
|
s32 update_hang_moving(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 stepResult;
|
|
||||||
Vec3f nextPos;
|
Vec3f nextPos;
|
||||||
f32 maxSpeed = 4.0f;
|
f32 maxSpeed = 4.0f;
|
||||||
|
|
||||||
@@ -433,7 +426,7 @@ s32 update_hang_moving(struct MarioState *m)
|
|||||||
nextPos[2] = m->pos[2] - m->ceil->normal.y * m->vel[2];
|
nextPos[2] = m->pos[2] - m->ceil->normal.y * m->vel[2];
|
||||||
nextPos[1] = m->pos[1];
|
nextPos[1] = m->pos[1];
|
||||||
|
|
||||||
stepResult = perform_hanging_step(m, nextPos);
|
s32 stepResult = perform_hanging_step(m, nextPos);
|
||||||
|
|
||||||
vec3f_copy(m->marioObj->header.gfx.pos, m->pos);
|
vec3f_copy(m->marioObj->header.gfx.pos, m->pos);
|
||||||
vec3s_set(m->marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);
|
vec3s_set(m->marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);
|
||||||
@@ -583,7 +576,6 @@ s32 act_hang_moving(struct MarioState *m)
|
|||||||
|
|
||||||
s32 let_go_of_ledge(struct MarioState *m)
|
s32 let_go_of_ledge(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 floorHeight;
|
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor;
|
||||||
|
|
||||||
m->vel[1] = 0.0f;
|
m->vel[1] = 0.0f;
|
||||||
@@ -591,7 +583,7 @@ s32 let_go_of_ledge(struct MarioState *m)
|
|||||||
m->pos[0] -= 60.0f * sins(m->faceAngle[1]);
|
m->pos[0] -= 60.0f * sins(m->faceAngle[1]);
|
||||||
m->pos[2] -= 60.0f * coss(m->faceAngle[1]);
|
m->pos[2] -= 60.0f * coss(m->faceAngle[1]);
|
||||||
|
|
||||||
floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &floor);
|
f32 floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &floor);
|
||||||
if (floorHeight < m->pos[1] - 100.0f)
|
if (floorHeight < m->pos[1] - 100.0f)
|
||||||
{
|
{
|
||||||
m->pos[1] -= 100.0f;
|
m->pos[1] -= 100.0f;
|
||||||
@@ -906,9 +898,6 @@ s32 act_tornado_twirling(struct MarioState *m)
|
|||||||
{
|
{
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor;
|
||||||
Vec3f nextPos;
|
Vec3f nextPos;
|
||||||
f32 sinAngleVel;
|
|
||||||
f32 cosAngleVel;
|
|
||||||
f32 floorHeight;
|
|
||||||
struct Object *marioObj = m->marioObj;
|
struct Object *marioObj = m->marioObj;
|
||||||
struct Object *usedObj = m->usedObj;
|
struct Object *usedObj = m->usedObj;
|
||||||
s16 prevTwirlYaw = m->twirlYaw;
|
s16 prevTwirlYaw = m->twirlYaw;
|
||||||
@@ -946,8 +935,8 @@ s32 act_tornado_twirling(struct MarioState *m)
|
|||||||
|
|
||||||
m->twirlYaw += m->angleVel[1];
|
m->twirlYaw += m->angleVel[1];
|
||||||
|
|
||||||
sinAngleVel = sins(marioObj->oMarioTornadoYawVel);
|
f32 sinAngleVel = sins(marioObj->oMarioTornadoYawVel);
|
||||||
cosAngleVel = coss(marioObj->oMarioTornadoYawVel);
|
f32 cosAngleVel = coss(marioObj->oMarioTornadoYawVel);
|
||||||
|
|
||||||
nextPos[0] = usedObj->oPosX + dx * cosAngleVel + dz * sinAngleVel;
|
nextPos[0] = usedObj->oPosX + dx * cosAngleVel + dz * sinAngleVel;
|
||||||
nextPos[2] = usedObj->oPosZ - dx * sinAngleVel + dz * cosAngleVel;
|
nextPos[2] = usedObj->oPosZ - dx * sinAngleVel + dz * cosAngleVel;
|
||||||
@@ -955,7 +944,7 @@ s32 act_tornado_twirling(struct MarioState *m)
|
|||||||
|
|
||||||
f32_find_wall_collision(&nextPos[0], &nextPos[1], &nextPos[2], 60.0f, 50.0f);
|
f32_find_wall_collision(&nextPos[0], &nextPos[1], &nextPos[2], 60.0f, 50.0f);
|
||||||
|
|
||||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
f32 floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||||
if (floor != NULL)
|
if (floor != NULL)
|
||||||
{
|
{
|
||||||
m->floor = floor;
|
m->floor = floor;
|
||||||
|
|||||||
@@ -429,7 +429,6 @@ s32 set_mario_npc_dialog(s32 actionArg)
|
|||||||
s32 act_reading_npc_dialog(struct MarioState *m)
|
s32 act_reading_npc_dialog(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 headTurnAmount = 0;
|
s32 headTurnAmount = 0;
|
||||||
s16 angleToNPC;
|
|
||||||
|
|
||||||
if (m->actionArg == 2)
|
if (m->actionArg == 2)
|
||||||
{
|
{
|
||||||
@@ -443,7 +442,7 @@ s32 act_reading_npc_dialog(struct MarioState *m)
|
|||||||
if (m->actionState < 8)
|
if (m->actionState < 8)
|
||||||
{
|
{
|
||||||
// turn to NPC
|
// turn to NPC
|
||||||
angleToNPC = mario_obj_angle_to_object(m, m->usedObj);
|
s16 angleToNPC = mario_obj_angle_to_object(m, m->usedObj);
|
||||||
m->faceAngle[1] =
|
m->faceAngle[1] =
|
||||||
angleToNPC - approach_s32((angleToNPC - m->faceAngle[1]) << 16 >> 16, 0, 2048, 2048);
|
angleToNPC - approach_s32((angleToNPC - m->faceAngle[1]) << 16 >> 16, 0, 2048, 2048);
|
||||||
// turn head to npc
|
// turn head to npc
|
||||||
@@ -609,13 +608,11 @@ s32 act_debug_free_move(struct MarioState *m)
|
|||||||
struct Controller *gPlayer1Controller = &gController;
|
struct Controller *gPlayer1Controller = &gController;
|
||||||
|
|
||||||
struct SM64SurfaceCollisionData *surf;
|
struct SM64SurfaceCollisionData *surf;
|
||||||
f32 floorHeight;
|
|
||||||
Vec3f pos;
|
Vec3f pos;
|
||||||
f32 speed;
|
|
||||||
u32 action;
|
u32 action;
|
||||||
|
|
||||||
// integer immediates, generates convert instructions for some reason
|
// integer immediates, generates convert instructions for some reason
|
||||||
speed = gPlayer1Controller->buttonDown & B_BUTTON ? 4 : 1;
|
f32 speed = gPlayer1Controller->buttonDown & B_BUTTON ? 4 : 1;
|
||||||
if (gPlayer1Controller->buttonDown & L_TRIG)
|
if (gPlayer1Controller->buttonDown & L_TRIG)
|
||||||
{
|
{
|
||||||
speed = 0.01f;
|
speed = 0.01f;
|
||||||
@@ -641,7 +638,7 @@ s32 act_debug_free_move(struct MarioState *m)
|
|||||||
|
|
||||||
resolve_and_return_wall_collisions(pos, 60.0f, 50.0f);
|
resolve_and_return_wall_collisions(pos, 60.0f, 50.0f);
|
||||||
|
|
||||||
floorHeight = find_floor(pos[0], pos[1], pos[2], &surf);
|
f32 floorHeight = find_floor(pos[0], pos[1], pos[2], &surf);
|
||||||
if (surf != NULL)
|
if (surf != NULL)
|
||||||
{
|
{
|
||||||
if (pos[1] < floorHeight)
|
if (pos[1] < floorHeight)
|
||||||
@@ -875,10 +872,9 @@ s32 act_eaten_by_bubba(struct MarioState *m)
|
|||||||
// set the new action
|
// set the new action
|
||||||
s32 launch_mario_until_land(struct MarioState *m, s32 endAction, s32 animation, f32 forwardVel)
|
s32 launch_mario_until_land(struct MarioState *m, s32 endAction, s32 animation, f32 forwardVel)
|
||||||
{
|
{
|
||||||
s32 airStepLanded;
|
|
||||||
mario_set_forward_vel(m, forwardVel);
|
mario_set_forward_vel(m, forwardVel);
|
||||||
set_mario_animation(m, animation);
|
set_mario_animation(m, animation);
|
||||||
airStepLanded = perform_air_step(m, 0) == AIR_STEP_LANDED;
|
s32 airStepLanded = perform_air_step(m, 0) == AIR_STEP_LANDED;
|
||||||
if (airStepLanded)
|
if (airStepLanded)
|
||||||
{
|
{
|
||||||
set_mario_action(m, endAction, 0);
|
set_mario_action(m, endAction, 0);
|
||||||
@@ -973,16 +969,12 @@ s32 act_unlocking_star_door(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_entering_star_door(struct MarioState *m)
|
s32 act_entering_star_door(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 targetDX;
|
|
||||||
f32 targetDZ;
|
|
||||||
s16 targetAngle;
|
|
||||||
|
|
||||||
if (m->actionTimer++ == 0)
|
if (m->actionTimer++ == 0)
|
||||||
{
|
{
|
||||||
m->interactObj->oInteractStatus = 0x00010000;
|
m->interactObj->oInteractStatus = 0x00010000;
|
||||||
|
|
||||||
// ~30 degrees / 1/12 rot
|
// ~30 degrees / 1/12 rot
|
||||||
targetAngle = m->usedObj->oMoveAngleYaw + 0x1555;
|
s16 targetAngle = m->usedObj->oMoveAngleYaw + 0x1555;
|
||||||
if (m->actionArg & 2)
|
if (m->actionArg & 2)
|
||||||
{
|
{
|
||||||
targetAngle += 0x5556; // ~120 degrees / 1/3 rot (total 150d / 5/12)
|
targetAngle += 0x5556; // ~120 degrees / 1/3 rot (total 150d / 5/12)
|
||||||
@@ -991,8 +983,8 @@ s32 act_entering_star_door(struct MarioState *m)
|
|||||||
// targetDX and targetDZ are the offsets to add to Mario's position to
|
// targetDX and targetDZ are the offsets to add to Mario's position to
|
||||||
// have Mario stand 150 units in front of the door
|
// have Mario stand 150 units in front of the door
|
||||||
|
|
||||||
targetDX = m->usedObj->oPosX + 150.0f * sins(targetAngle) - m->pos[0];
|
f32 targetDX = m->usedObj->oPosX + 150.0f * sins(targetAngle) - m->pos[0];
|
||||||
targetDZ = m->usedObj->oPosZ + 150.0f * coss(targetAngle) - m->pos[2];
|
f32 targetDZ = m->usedObj->oPosZ + 150.0f * coss(targetAngle) - m->pos[2];
|
||||||
|
|
||||||
m->marioObj->oMarioReadingSignDPosX = targetDX / 20.0f;
|
m->marioObj->oMarioReadingSignDPosX = targetDX / 20.0f;
|
||||||
m->marioObj->oMarioReadingSignDPosZ = targetDZ / 20.0f;
|
m->marioObj->oMarioReadingSignDPosZ = targetDZ / 20.0f;
|
||||||
@@ -1453,15 +1445,11 @@ s32 act_spawn_no_spin_landing(struct MarioState *m)
|
|||||||
s32 act_bbh_enter_spin(struct MarioState *m)
|
s32 act_bbh_enter_spin(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 floorDist;
|
f32 floorDist;
|
||||||
f32 scale;
|
|
||||||
f32 cageDX;
|
|
||||||
f32 cageDZ;
|
|
||||||
f32 cageDist;
|
|
||||||
f32 forwardVel;
|
f32 forwardVel;
|
||||||
|
|
||||||
cageDX = m->usedObj->oPosX - m->pos[0];
|
f32 cageDX = m->usedObj->oPosX - m->pos[0];
|
||||||
cageDZ = m->usedObj->oPosZ - m->pos[2];
|
f32 cageDZ = m->usedObj->oPosZ - m->pos[2];
|
||||||
cageDist = sqrtf(cageDX * cageDX + cageDZ * cageDZ);
|
f32 cageDist = sqrtf(cageDX * cageDX + cageDZ * cageDZ);
|
||||||
|
|
||||||
if (cageDist > 20.0f)
|
if (cageDist > 20.0f)
|
||||||
{
|
{
|
||||||
@@ -1534,7 +1522,7 @@ s32 act_bbh_enter_spin(struct MarioState *m)
|
|||||||
if (m->actionTimer >= 11)
|
if (m->actionTimer >= 11)
|
||||||
{
|
{
|
||||||
m->actionTimer -= 6;
|
m->actionTimer -= 6;
|
||||||
scale = m->actionTimer / 100.0f;
|
f32 scale = m->actionTimer / 100.0f;
|
||||||
vec3f_set(m->marioObj->header.gfx.scale, scale, scale, scale);
|
vec3f_set(m->marioObj->header.gfx.scale, scale, scale, scale);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1550,19 +1538,15 @@ s32 act_bbh_enter_spin(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_bbh_enter_jump(struct MarioState *m)
|
s32 act_bbh_enter_jump(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 cageDX;
|
|
||||||
f32 cageDZ;
|
|
||||||
f32 cageDist;
|
|
||||||
|
|
||||||
play_mario_action_sound(
|
play_mario_action_sound(
|
||||||
m, m->flags & MARIO_METAL_CAP ? SOUND_ACTION_METAL_JUMP : SOUND_ACTION_TERRAIN_JUMP, 1);
|
m, m->flags & MARIO_METAL_CAP ? SOUND_ACTION_METAL_JUMP : SOUND_ACTION_TERRAIN_JUMP, 1);
|
||||||
play_mario_jump_sound(m);
|
play_mario_jump_sound(m);
|
||||||
|
|
||||||
if (m->actionState == 0)
|
if (m->actionState == 0)
|
||||||
{
|
{
|
||||||
cageDX = m->usedObj->oPosX - m->pos[0];
|
f32 cageDX = m->usedObj->oPosX - m->pos[0];
|
||||||
cageDZ = m->usedObj->oPosZ - m->pos[2];
|
f32 cageDZ = m->usedObj->oPosZ - m->pos[2];
|
||||||
cageDist = sqrtf(cageDX * cageDX + cageDZ * cageDZ);
|
f32 cageDist = sqrtf(cageDX * cageDX + cageDZ * cageDZ);
|
||||||
|
|
||||||
m->vel[1] = 60.0f;
|
m->vel[1] = 60.0f;
|
||||||
m->faceAngle[1] = atan2s(cageDZ, cageDX);
|
m->faceAngle[1] = atan2s(cageDZ, cageDX);
|
||||||
@@ -1697,7 +1681,6 @@ s32 act_shocked(struct MarioState *m)
|
|||||||
s32 act_squished(struct MarioState *m)
|
s32 act_squished(struct MarioState *m)
|
||||||
{
|
{
|
||||||
UNUSED s32 pad;
|
UNUSED s32 pad;
|
||||||
f32 squishAmount;
|
|
||||||
f32 spaceUnderCeil;
|
f32 spaceUnderCeil;
|
||||||
s16 surfAngle;
|
s16 surfAngle;
|
||||||
s32 underSteepSurf = FALSE; // seems to be responsible for setting velocity?
|
s32 underSteepSurf = FALSE; // seems to be responsible for setting velocity?
|
||||||
@@ -1721,7 +1704,7 @@ s32 act_squished(struct MarioState *m)
|
|||||||
if (spaceUnderCeil >= 10.1f)
|
if (spaceUnderCeil >= 10.1f)
|
||||||
{
|
{
|
||||||
// Mario becomes a pancake
|
// Mario becomes a pancake
|
||||||
squishAmount = spaceUnderCeil / 160.0f;
|
f32 squishAmount = spaceUnderCeil / 160.0f;
|
||||||
vec3f_set(m->marioObj->header.gfx.scale, 2.0f - squishAmount, squishAmount,
|
vec3f_set(m->marioObj->header.gfx.scale, 2.0f - squishAmount, squishAmount,
|
||||||
2.0f - squishAmount);
|
2.0f - squishAmount);
|
||||||
}
|
}
|
||||||
@@ -2101,7 +2084,6 @@ static void jumbo_star_cutscene_falling(struct MarioState *m)
|
|||||||
static s32 jumbo_star_cutscene_taking_off(struct MarioState *m)
|
static s32 jumbo_star_cutscene_taking_off(struct MarioState *m)
|
||||||
{
|
{
|
||||||
struct Object *marioObj = m->marioObj;
|
struct Object *marioObj = m->marioObj;
|
||||||
s32 animFrame;
|
|
||||||
|
|
||||||
if (m->actionState == 0)
|
if (m->actionState == 0)
|
||||||
{
|
{
|
||||||
@@ -2116,7 +2098,7 @@ static s32 jumbo_star_cutscene_taking_off(struct MarioState *m)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
animFrame = set_mario_animation(m, MARIO_ANIM_FINAL_BOWSER_WING_CAP_TAKE_OFF);
|
s32 animFrame = set_mario_animation(m, MARIO_ANIM_FINAL_BOWSER_WING_CAP_TAKE_OFF);
|
||||||
if (animFrame == 3 || animFrame == 28 || animFrame == 60)
|
if (animFrame == 3 || animFrame == 28 || animFrame == 60)
|
||||||
{
|
{
|
||||||
play_sound_and_spawn_particles(m, SOUND_ACTION_TERRAIN_JUMP, 1);
|
play_sound_and_spawn_particles(m, SOUND_ACTION_TERRAIN_JUMP, 1);
|
||||||
@@ -2165,11 +2147,6 @@ static s32 jumbo_star_cutscene_flying(struct MarioState *m)
|
|||||||
Vec3f targetPos;
|
Vec3f targetPos;
|
||||||
UNUSED
|
UNUSED
|
||||||
struct Object *marioObj = m->marioObj;
|
struct Object *marioObj = m->marioObj;
|
||||||
f32 targetDX;
|
|
||||||
f32 targetDY;
|
|
||||||
f32 targetDZ;
|
|
||||||
f32 targetHyp;
|
|
||||||
s16 targetAngle;
|
|
||||||
|
|
||||||
switch (m->actionState)
|
switch (m->actionState)
|
||||||
{
|
{
|
||||||
@@ -2187,11 +2164,11 @@ static s32 jumbo_star_cutscene_flying(struct MarioState *m)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
targetDX = targetPos[0] - m->pos[0];
|
f32 targetDX = targetPos[0] - m->pos[0];
|
||||||
targetDY = targetPos[1] - m->pos[1];
|
f32 targetDY = targetPos[1] - m->pos[1];
|
||||||
targetDZ = targetPos[2] - m->pos[2];
|
f32 targetDZ = targetPos[2] - m->pos[2];
|
||||||
targetHyp = sqrtf(targetDX * targetDX + targetDZ * targetDZ);
|
f32 targetHyp = sqrtf(targetDX * targetDX + targetDZ * targetDZ);
|
||||||
targetAngle = atan2s(targetDZ, targetDX);
|
s16 targetAngle = atan2s(targetDZ, targetDX);
|
||||||
|
|
||||||
vec3f_copy(m->pos, targetPos);
|
vec3f_copy(m->pos, targetPos);
|
||||||
m->marioObj->header.gfx.angle[0] = -atan2s(targetHyp, targetDY);
|
m->marioObj->header.gfx.angle[0] = -atan2s(targetHyp, targetDY);
|
||||||
|
|||||||
@@ -121,10 +121,6 @@ void check_ledge_climb_down(struct MarioState *m)
|
|||||||
{
|
{
|
||||||
struct SM64WallCollisionData wallCols;
|
struct SM64WallCollisionData wallCols;
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor;
|
||||||
f32 floorHeight;
|
|
||||||
struct SM64SurfaceCollisionData *wall;
|
|
||||||
s16 wallAngle;
|
|
||||||
s16 wallDYaw;
|
|
||||||
|
|
||||||
if (m->forwardVel < 10.0f)
|
if (m->forwardVel < 10.0f)
|
||||||
{
|
{
|
||||||
@@ -136,12 +132,12 @@ void check_ledge_climb_down(struct MarioState *m)
|
|||||||
|
|
||||||
if (find_wall_collisions(&wallCols) != 0)
|
if (find_wall_collisions(&wallCols) != 0)
|
||||||
{
|
{
|
||||||
floorHeight = find_floor(wallCols.x, wallCols.y, wallCols.z, &floor);
|
f32 floorHeight = find_floor(wallCols.x, wallCols.y, wallCols.z, &floor);
|
||||||
if (floor != NULL && wallCols.y - floorHeight > 160.0f)
|
if (floor != NULL && wallCols.y - floorHeight > 160.0f)
|
||||||
{
|
{
|
||||||
wall = wallCols.walls[wallCols.numWalls - 1];
|
struct SM64SurfaceCollisionData *wall = wallCols.walls[wallCols.numWalls - 1];
|
||||||
wallAngle = atan2s(wall->normal.z, wall->normal.x);
|
s16 wallAngle = atan2s(wall->normal.z, wall->normal.x);
|
||||||
wallDYaw = wallAngle - m->faceAngle[1];
|
s16 wallDYaw = wallAngle - m->faceAngle[1];
|
||||||
|
|
||||||
if (wallDYaw > -0x4000 && wallDYaw < 0x4000)
|
if (wallDYaw > -0x4000 && wallDYaw < 0x4000)
|
||||||
{
|
{
|
||||||
@@ -193,9 +189,6 @@ s32 set_triple_jump_action(struct MarioState *m, UNUSED u32 action, UNUSED u32 a
|
|||||||
|
|
||||||
void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor)
|
void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor)
|
||||||
{
|
{
|
||||||
s32 newFacingDYaw;
|
|
||||||
s16 facingDYaw;
|
|
||||||
|
|
||||||
struct SM64SurfaceCollisionData *floor = m->floor;
|
struct SM64SurfaceCollisionData *floor = m->floor;
|
||||||
s16 slopeAngle = atan2s(floor->normal.z, floor->normal.x);
|
s16 slopeAngle = atan2s(floor->normal.z, floor->normal.x);
|
||||||
f32 steepness = sqrtf(floor->normal.x * floor->normal.x + floor->normal.z * floor->normal.z);
|
f32 steepness = sqrtf(floor->normal.x * floor->normal.x + floor->normal.z * floor->normal.z);
|
||||||
@@ -209,8 +202,8 @@ void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor)
|
|||||||
|
|
||||||
m->slideYaw = atan2s(m->slideVelZ, m->slideVelX);
|
m->slideYaw = atan2s(m->slideVelZ, m->slideVelX);
|
||||||
|
|
||||||
facingDYaw = m->faceAngle[1] - m->slideYaw;
|
s16 facingDYaw = m->faceAngle[1] - m->slideYaw;
|
||||||
newFacingDYaw = facingDYaw;
|
s32 newFacingDYaw = facingDYaw;
|
||||||
|
|
||||||
//! -0x4000 not handled - can slide down a slope while facing perpendicular to it
|
//! -0x4000 not handled - can slide down a slope while facing perpendicular to it
|
||||||
if (newFacingDYaw > 0 && newFacingDYaw <= 0x4000)
|
if (newFacingDYaw > 0 && newFacingDYaw <= 0x4000)
|
||||||
@@ -269,8 +262,6 @@ s32 update_sliding(struct MarioState *m, f32 stopSpeed)
|
|||||||
{
|
{
|
||||||
f32 lossFactor;
|
f32 lossFactor;
|
||||||
f32 accel;
|
f32 accel;
|
||||||
f32 oldSpeed;
|
|
||||||
f32 newSpeed;
|
|
||||||
|
|
||||||
s32 stopped = FALSE;
|
s32 stopped = FALSE;
|
||||||
|
|
||||||
@@ -307,7 +298,7 @@ s32 update_sliding(struct MarioState *m, f32 stopSpeed)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldSpeed = sqrtf(m->slideVelX * m->slideVelX + m->slideVelZ * m->slideVelZ);
|
f32 oldSpeed = sqrtf(m->slideVelX * m->slideVelX + m->slideVelZ * m->slideVelZ);
|
||||||
|
|
||||||
//! This is attempting to use trig derivatives to rotate Mario's speed.
|
//! This is attempting to use trig derivatives to rotate Mario's speed.
|
||||||
// It is slightly off/asymmetric since it uses the new X speed, but the old
|
// It is slightly off/asymmetric since it uses the new X speed, but the old
|
||||||
@@ -315,7 +306,7 @@ s32 update_sliding(struct MarioState *m, f32 stopSpeed)
|
|||||||
m->slideVelX += m->slideVelZ * (m->intendedMag / 32.0f) * sideward * 0.05f;
|
m->slideVelX += m->slideVelZ * (m->intendedMag / 32.0f) * sideward * 0.05f;
|
||||||
m->slideVelZ -= m->slideVelX * (m->intendedMag / 32.0f) * sideward * 0.05f;
|
m->slideVelZ -= m->slideVelX * (m->intendedMag / 32.0f) * sideward * 0.05f;
|
||||||
|
|
||||||
newSpeed = sqrtf(m->slideVelX * m->slideVelX + m->slideVelZ * m->slideVelZ);
|
f32 newSpeed = sqrtf(m->slideVelX * m->slideVelX + m->slideVelZ * m->slideVelZ);
|
||||||
|
|
||||||
if (oldSpeed > 0.0f && newSpeed > 0.0f)
|
if (oldSpeed > 0.0f && newSpeed > 0.0f)
|
||||||
{
|
{
|
||||||
@@ -414,7 +405,6 @@ s32 apply_landing_accel(struct MarioState *m, f32 frictionFactor)
|
|||||||
void update_shell_speed(struct MarioState *m)
|
void update_shell_speed(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 maxTargetSpeed;
|
f32 maxTargetSpeed;
|
||||||
f32 targetSpeed;
|
|
||||||
|
|
||||||
if (m->floorHeight < m->waterLevel)
|
if (m->floorHeight < m->waterLevel)
|
||||||
{
|
{
|
||||||
@@ -432,7 +422,7 @@ void update_shell_speed(struct MarioState *m)
|
|||||||
maxTargetSpeed = 64.0f;
|
maxTargetSpeed = 64.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
targetSpeed = m->intendedMag * 2.0f;
|
f32 targetSpeed = m->intendedMag * 2.0f;
|
||||||
if (targetSpeed > maxTargetSpeed)
|
if (targetSpeed > maxTargetSpeed)
|
||||||
{
|
{
|
||||||
targetSpeed = maxTargetSpeed;
|
targetSpeed = maxTargetSpeed;
|
||||||
@@ -516,7 +506,6 @@ s32 update_decelerating_speed(struct MarioState *m)
|
|||||||
void update_walking_speed(struct MarioState *m)
|
void update_walking_speed(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 maxTargetSpeed;
|
f32 maxTargetSpeed;
|
||||||
f32 targetSpeed;
|
|
||||||
|
|
||||||
if (m->floor != NULL && m->floor->type == SURFACE_SLOW)
|
if (m->floor != NULL && m->floor->type == SURFACE_SLOW)
|
||||||
{
|
{
|
||||||
@@ -527,7 +516,7 @@ void update_walking_speed(struct MarioState *m)
|
|||||||
maxTargetSpeed = 32.0f;
|
maxTargetSpeed = 32.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
targetSpeed = m->intendedMag < maxTargetSpeed ? m->intendedMag : maxTargetSpeed;
|
f32 targetSpeed = m->intendedMag < maxTargetSpeed ? m->intendedMag : maxTargetSpeed;
|
||||||
|
|
||||||
if (m->quicksandDepth > 10.0f)
|
if (m->quicksandDepth > 10.0f)
|
||||||
{
|
{
|
||||||
@@ -622,9 +611,8 @@ void anim_and_audio_for_walk(struct MarioState *m)
|
|||||||
struct Object *marioObj = m->marioObj;
|
struct Object *marioObj = m->marioObj;
|
||||||
s32 val0C = TRUE;
|
s32 val0C = TRUE;
|
||||||
s16 targetPitch = 0;
|
s16 targetPitch = 0;
|
||||||
f32 val04;
|
|
||||||
|
|
||||||
val04 = m->intendedMag > m->forwardVel ? m->intendedMag : m->forwardVel;
|
f32 val04 = m->intendedMag > m->forwardVel ? m->intendedMag : m->forwardVel;
|
||||||
|
|
||||||
if (val04 < 4.0f)
|
if (val04 < 4.0f)
|
||||||
{
|
{
|
||||||
@@ -735,9 +723,8 @@ void anim_and_audio_for_hold_walk(struct MarioState *m)
|
|||||||
{
|
{
|
||||||
s32 val0C;
|
s32 val0C;
|
||||||
s32 val08 = TRUE;
|
s32 val08 = TRUE;
|
||||||
f32 val04;
|
|
||||||
|
|
||||||
val04 = m->intendedMag > m->forwardVel ? m->intendedMag : m->forwardVel;
|
f32 val04 = m->intendedMag > m->forwardVel ? m->intendedMag : m->forwardVel;
|
||||||
|
|
||||||
if (val04 < 2.0f)
|
if (val04 < 2.0f)
|
||||||
{
|
{
|
||||||
@@ -867,17 +854,14 @@ void tilt_body_walking(struct MarioState *m, s16 startYaw)
|
|||||||
UNUSED
|
UNUSED
|
||||||
struct Object *marioObj = m->marioObj;
|
struct Object *marioObj = m->marioObj;
|
||||||
s16 animID = m->marioObj->header.gfx.animInfo.animID;
|
s16 animID = m->marioObj->header.gfx.animInfo.animID;
|
||||||
s16 dYaw;
|
|
||||||
s16 val02;
|
|
||||||
s16 val00;
|
|
||||||
|
|
||||||
if (animID == MARIO_ANIM_WALKING || animID == MARIO_ANIM_RUNNING)
|
if (animID == MARIO_ANIM_WALKING || animID == MARIO_ANIM_RUNNING)
|
||||||
{
|
{
|
||||||
dYaw = m->faceAngle[1] - startYaw;
|
s16 dYaw = m->faceAngle[1] - startYaw;
|
||||||
//! (Speed Crash) These casts can cause a crash if (dYaw * forwardVel / 12) or
|
//! (Speed Crash) These casts can cause a crash if (dYaw * forwardVel / 12) or
|
||||||
//! (forwardVel * 170) exceed or equal 2^31.
|
//! (forwardVel * 170) exceed or equal 2^31.
|
||||||
val02 = -(s16)(dYaw * m->forwardVel / 12.0f);
|
s16 val02 = -(s16)(dYaw * m->forwardVel / 12.0f);
|
||||||
val00 = (s16)(m->forwardVel * 170.0f);
|
s16 val00 = (s16)(m->forwardVel * 170.0f);
|
||||||
|
|
||||||
if (val02 > 0x1555)
|
if (val02 > 0x1555)
|
||||||
{
|
{
|
||||||
@@ -1514,8 +1498,6 @@ s32 act_riding_shell_ground(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_crawling(struct MarioState *m)
|
s32 act_crawling(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 val04;
|
|
||||||
|
|
||||||
if (should_begin_sliding(m))
|
if (should_begin_sliding(m))
|
||||||
{
|
{
|
||||||
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
|
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
|
||||||
@@ -1568,7 +1550,7 @@ s32 act_crawling(struct MarioState *m)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
val04 = (s32)(m->intendedMag * 2.0f * 0x10000);
|
s32 val04 = (s32)(m->intendedMag * 2.0f * 0x10000);
|
||||||
set_mario_anim_with_accel(m, MARIO_ANIM_CRAWLING, val04);
|
set_mario_anim_with_accel(m, MARIO_ANIM_CRAWLING, val04);
|
||||||
play_step_sound(m, 26, 79);
|
play_step_sound(m, 26, 79);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -1741,14 +1723,12 @@ s32 act_butt_slide(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_hold_butt_slide(struct MarioState *m)
|
s32 act_hold_butt_slide(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 cancel;
|
|
||||||
|
|
||||||
if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_DROP_OBJECT)
|
if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_DROP_OBJECT)
|
||||||
{
|
{
|
||||||
return drop_and_set_mario_action(m, ACT_BUTT_SLIDE, 0);
|
return drop_and_set_mario_action(m, ACT_BUTT_SLIDE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel = common_slide_action_with_jump(m, ACT_HOLD_BUTT_SLIDE_STOP, ACT_HOLD_JUMP, ACT_HOLD_BUTT_SLIDE_AIR,
|
s32 cancel = common_slide_action_with_jump(m, ACT_HOLD_BUTT_SLIDE_STOP, ACT_HOLD_JUMP, ACT_HOLD_BUTT_SLIDE_AIR,
|
||||||
MARIO_ANIM_SLIDING_ON_BOTTOM_WITH_LIGHT_OBJ);
|
MARIO_ANIM_SLIDING_ON_BOTTOM_WITH_LIGHT_OBJ);
|
||||||
tilt_body_butt_slide(m);
|
tilt_body_butt_slide(m);
|
||||||
return cancel;
|
return cancel;
|
||||||
@@ -1756,8 +1736,6 @@ s32 act_hold_butt_slide(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_crouch_slide(struct MarioState *m)
|
s32 act_crouch_slide(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 cancel;
|
|
||||||
|
|
||||||
if (m->input & INPUT_ABOVE_SLIDE)
|
if (m->input & INPUT_ABOVE_SLIDE)
|
||||||
{
|
{
|
||||||
return set_mario_action(m, ACT_BUTT_SLIDE, 0);
|
return set_mario_action(m, ACT_BUTT_SLIDE, 0);
|
||||||
@@ -1797,7 +1775,7 @@ s32 act_crouch_slide(struct MarioState *m)
|
|||||||
return set_mario_action(m, ACT_BRAKING, 0);
|
return set_mario_action(m, ACT_BRAKING, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel = common_slide_action_with_jump(m, ACT_CROUCHING, ACT_JUMP, ACT_FREEFALL,
|
s32 cancel = common_slide_action_with_jump(m, ACT_CROUCHING, ACT_JUMP, ACT_FREEFALL,
|
||||||
MARIO_ANIM_START_CROUCHING);
|
MARIO_ANIM_START_CROUCHING);
|
||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
@@ -1872,14 +1850,12 @@ s32 act_stomach_slide(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_hold_stomach_slide(struct MarioState *m)
|
s32 act_hold_stomach_slide(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 cancel;
|
|
||||||
|
|
||||||
if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_DROP_OBJECT)
|
if (m->marioObj->oInteractStatus & INT_STATUS_MARIO_DROP_OBJECT)
|
||||||
{
|
{
|
||||||
return drop_and_set_mario_action(m, ACT_STOMACH_SLIDE, 0);
|
return drop_and_set_mario_action(m, ACT_STOMACH_SLIDE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancel = stomach_slide_action(m, ACT_DIVE_PICKING_UP, ACT_HOLD_FREEFALL, MARIO_ANIM_SLIDE_DIVE);
|
s32 cancel = stomach_slide_action(m, ACT_DIVE_PICKING_UP, ACT_HOLD_FREEFALL, MARIO_ANIM_SLIDE_DIVE);
|
||||||
return cancel;
|
return cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1920,8 +1896,6 @@ s32 act_dive_slide(struct MarioState *m)
|
|||||||
|
|
||||||
s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2, s32 arg3, s32 arg4)
|
s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2, s32 arg3, s32 arg4)
|
||||||
{
|
{
|
||||||
s32 animFrame;
|
|
||||||
|
|
||||||
if (arg3)
|
if (arg3)
|
||||||
{
|
{
|
||||||
play_mario_heavy_landing_sound_once(m, SOUND_ACTION_TERRAIN_BODY_HIT_GROUND);
|
play_mario_heavy_landing_sound_once(m, SOUND_ACTION_TERRAIN_BODY_HIT_GROUND);
|
||||||
@@ -1949,7 +1923,7 @@ s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2
|
|||||||
m->forwardVel = -32.0f;
|
m->forwardVel = -32.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
animFrame = set_mario_animation(m, animation);
|
s32 animFrame = set_mario_animation(m, animation);
|
||||||
if (animFrame < arg2)
|
if (animFrame < arg2)
|
||||||
{
|
{
|
||||||
apply_landing_accel(m, 0.9f);
|
apply_landing_accel(m, 0.9f);
|
||||||
@@ -2066,12 +2040,10 @@ s32 act_ground_bonk(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_death_exit_land(struct MarioState *m)
|
s32 act_death_exit_land(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 animFrame;
|
|
||||||
|
|
||||||
apply_landing_accel(m, 0.9f);
|
apply_landing_accel(m, 0.9f);
|
||||||
play_mario_heavy_landing_sound_once(m, SOUND_ACTION_TERRAIN_BODY_HIT_GROUND);
|
play_mario_heavy_landing_sound_once(m, SOUND_ACTION_TERRAIN_BODY_HIT_GROUND);
|
||||||
|
|
||||||
animFrame = set_mario_animation(m, MARIO_ANIM_FALL_OVER_BACKWARDS);
|
s32 animFrame = set_mario_animation(m, MARIO_ANIM_FALL_OVER_BACKWARDS);
|
||||||
|
|
||||||
if (animFrame == 54)
|
if (animFrame == 54)
|
||||||
{
|
{
|
||||||
@@ -2092,8 +2064,6 @@ s32 act_death_exit_land(struct MarioState *m)
|
|||||||
|
|
||||||
u32 common_landing_action(struct MarioState *m, s16 animation, u32 airAction)
|
u32 common_landing_action(struct MarioState *m, s16 animation, u32 airAction)
|
||||||
{
|
{
|
||||||
u32 stepResult;
|
|
||||||
|
|
||||||
if (m->input & INPUT_NONZERO_ANALOG)
|
if (m->input & INPUT_NONZERO_ANALOG)
|
||||||
{
|
{
|
||||||
apply_landing_accel(m, 0.98f);
|
apply_landing_accel(m, 0.98f);
|
||||||
@@ -2107,7 +2077,7 @@ u32 common_landing_action(struct MarioState *m, s16 animation, u32 airAction)
|
|||||||
m->vel[1] = 0.0f;
|
m->vel[1] = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
stepResult = perform_ground_step(m);
|
u32 stepResult = perform_ground_step(m);
|
||||||
switch (stepResult)
|
switch (stepResult)
|
||||||
{
|
{
|
||||||
case GROUND_STEP_LEFT_GROUND:
|
case GROUND_STEP_LEFT_GROUND:
|
||||||
|
|||||||
@@ -502,15 +502,13 @@ s32 act_shivering(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_coughing(struct MarioState *m)
|
s32 act_coughing(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 animFrame;
|
|
||||||
|
|
||||||
if (check_common_idle_cancels(m))
|
if (check_common_idle_cancels(m))
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
stationary_ground_step(m);
|
stationary_ground_step(m);
|
||||||
animFrame = set_mario_animation(m, MARIO_ANIM_COUGHING);
|
s32 animFrame = set_mario_animation(m, MARIO_ANIM_COUGHING);
|
||||||
if (animFrame == 25 || animFrame == 35)
|
if (animFrame == 25 || animFrame == 35)
|
||||||
{
|
{
|
||||||
play_sound(SOUND_MARIO_COUGHING3, m->marioObj->header.gfx.cameraToObject);
|
play_sound(SOUND_MARIO_COUGHING3, m->marioObj->header.gfx.cameraToObject);
|
||||||
@@ -964,9 +962,6 @@ s32 act_stop_crawling(struct MarioState *m)
|
|||||||
|
|
||||||
s32 act_shockwave_bounce(struct MarioState *m)
|
s32 act_shockwave_bounce(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s16 sp1E;
|
|
||||||
f32 sp18;
|
|
||||||
|
|
||||||
if (m->marioObj->oInteractStatus & INT_STATUS_HIT_BY_SHOCKWAVE)
|
if (m->marioObj->oInteractStatus & INT_STATUS_HIT_BY_SHOCKWAVE)
|
||||||
{
|
{
|
||||||
#ifdef VERSION_SH
|
#ifdef VERSION_SH
|
||||||
@@ -991,8 +986,8 @@ s32 act_shockwave_bounce(struct MarioState *m)
|
|||||||
return set_mario_action(m, ACT_IDLE, 0);
|
return set_mario_action(m, ACT_IDLE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sp1E = (m->actionTimer % 16) << 12;
|
s16 sp1E = (m->actionTimer % 16) << 12;
|
||||||
sp18 = (f32)(6 - m->actionTimer / 8) * 8.0f + 4.0f;
|
f32 sp18 = (f32)(6 - m->actionTimer / 8) * 8.0f + 4.0f;
|
||||||
mario_set_forward_vel(m, 0);
|
mario_set_forward_vel(m, 0);
|
||||||
vec3f_set(m->vel, 0.0f, 0.0f, 0.0f);
|
vec3f_set(m->vel, 0.0f, 0.0f, 0.0f);
|
||||||
if (sins(sp1E) >= 0.0f)
|
if (sins(sp1E) >= 0.0f)
|
||||||
|
|||||||
@@ -95,15 +95,12 @@ static f32 get_buoyancy(struct MarioState *m)
|
|||||||
|
|
||||||
static u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos)
|
static u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos)
|
||||||
{
|
{
|
||||||
struct SM64SurfaceCollisionData *wall;
|
|
||||||
struct SM64SurfaceCollisionData *ceil;
|
struct SM64SurfaceCollisionData *ceil;
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor;
|
||||||
f32 ceilHeight;
|
|
||||||
f32 floorHeight;
|
|
||||||
|
|
||||||
wall = resolve_and_return_wall_collisions(nextPos, 10.0f, 110.0f);
|
struct SM64SurfaceCollisionData *wall = resolve_and_return_wall_collisions(nextPos, 10.0f, 110.0f);
|
||||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
f32 floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||||
ceilHeight = vec3f_find_ceil(nextPos, floorHeight, &ceil);
|
f32 ceilHeight = vec3f_find_ceil(nextPos, floorHeight, &ceil);
|
||||||
|
|
||||||
if (floor == NULL)
|
if (floor == NULL)
|
||||||
{
|
{
|
||||||
@@ -155,7 +152,6 @@ static u32 perform_water_full_step(struct MarioState *m, Vec3f nextPos)
|
|||||||
|
|
||||||
static void apply_water_current(struct MarioState *m, Vec3f step)
|
static void apply_water_current(struct MarioState *m, Vec3f step)
|
||||||
{
|
{
|
||||||
s32 i;
|
|
||||||
f32 whirlpoolRadius = 2000.0f;
|
f32 whirlpoolRadius = 2000.0f;
|
||||||
|
|
||||||
if (m->floor->type == SURFACE_FLOWING_WATER)
|
if (m->floor->type == SURFACE_FLOWING_WATER)
|
||||||
@@ -167,7 +163,7 @@ static void apply_water_current(struct MarioState *m, Vec3f step)
|
|||||||
step[2] += currentSpeed * coss(currentAngle);
|
step[2] += currentSpeed * coss(currentAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (s32 i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
struct Whirlpool *whirlpool = gCurrentArea->whirlpools[i];
|
struct Whirlpool *whirlpool = gCurrentArea->whirlpools[i];
|
||||||
if (whirlpool != NULL)
|
if (whirlpool != NULL)
|
||||||
@@ -212,7 +208,6 @@ static void apply_water_current(struct MarioState *m, Vec3f step)
|
|||||||
static u32 perform_water_step(struct MarioState *m)
|
static u32 perform_water_step(struct MarioState *m)
|
||||||
{
|
{
|
||||||
UNUSED u32 unused;
|
UNUSED u32 unused;
|
||||||
u32 stepResult;
|
|
||||||
Vec3f nextPos;
|
Vec3f nextPos;
|
||||||
Vec3f step;
|
Vec3f step;
|
||||||
struct Object *marioObj = m->marioObj;
|
struct Object *marioObj = m->marioObj;
|
||||||
@@ -234,7 +229,7 @@ static u32 perform_water_step(struct MarioState *m)
|
|||||||
m->vel[1] = 0.0f;
|
m->vel[1] = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
stepResult = perform_water_full_step(m, nextPos);
|
u32 stepResult = perform_water_full_step(m, nextPos);
|
||||||
|
|
||||||
vec3f_copy(marioObj->header.gfx.pos, m->pos);
|
vec3f_copy(marioObj->header.gfx.pos, m->pos);
|
||||||
vec3s_set(marioObj->header.gfx.angle, -m->faceAngle[0], m->faceAngle[1], m->faceAngle[2]);
|
vec3s_set(marioObj->header.gfx.angle, -m->faceAngle[0], m->faceAngle[1], m->faceAngle[2]);
|
||||||
@@ -1162,7 +1157,6 @@ static s32 act_water_death(struct MarioState *m)
|
|||||||
|
|
||||||
static s32 act_water_plunge(struct MarioState *m)
|
static s32 act_water_plunge(struct MarioState *m)
|
||||||
{
|
{
|
||||||
u32 stepResult;
|
|
||||||
s32 stateFlags = m->heldObj != NULL;
|
s32 stateFlags = m->heldObj != NULL;
|
||||||
|
|
||||||
f32 endVSpeed;
|
f32 endVSpeed;
|
||||||
@@ -1188,7 +1182,7 @@ static s32 act_water_plunge(struct MarioState *m)
|
|||||||
|
|
||||||
stationary_slow_down(m);
|
stationary_slow_down(m);
|
||||||
|
|
||||||
stepResult = perform_water_step(m);
|
u32 stepResult = perform_water_step(m);
|
||||||
|
|
||||||
if (m->actionState == 0)
|
if (m->actionState == 0)
|
||||||
{
|
{
|
||||||
@@ -1262,8 +1256,6 @@ static s32 act_water_plunge(struct MarioState *m)
|
|||||||
|
|
||||||
static s32 act_caught_in_whirlpool(struct MarioState *m)
|
static s32 act_caught_in_whirlpool(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 sinAngleChange;
|
|
||||||
f32 cosAngleChange;
|
|
||||||
f32 newDistance;
|
f32 newDistance;
|
||||||
s16 angleChange;
|
s16 angleChange;
|
||||||
|
|
||||||
@@ -1301,8 +1293,8 @@ static s32 act_caught_in_whirlpool(struct MarioState *m)
|
|||||||
|
|
||||||
m->vel[1] = -640.0f / (newDistance + 16.0f);
|
m->vel[1] = -640.0f / (newDistance + 16.0f);
|
||||||
|
|
||||||
sinAngleChange = sins(angleChange);
|
f32 sinAngleChange = sins(angleChange);
|
||||||
cosAngleChange = coss(angleChange);
|
f32 cosAngleChange = coss(angleChange);
|
||||||
|
|
||||||
if (distance < 1.0f)
|
if (distance < 1.0f)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -351,12 +351,11 @@ Gfx *geo_mirror_mario_set_alpha(s32 callContext, struct GraphNode *node, UNUSED
|
|||||||
Gfx *gfx = NULL;
|
Gfx *gfx = NULL;
|
||||||
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *)node;
|
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *)node;
|
||||||
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];
|
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];
|
||||||
s16 alpha;
|
|
||||||
UNUSED u8 unused2[4];
|
UNUSED u8 unused2[4];
|
||||||
|
|
||||||
if (callContext == GEO_CONTEXT_RENDER)
|
if (callContext == GEO_CONTEXT_RENDER)
|
||||||
{
|
{
|
||||||
alpha = bodyState->modelState & 0x100 ? bodyState->modelState & 0xFF : 255;
|
s16 alpha = bodyState->modelState & 0x100 ? bodyState->modelState & 0xFF : 255;
|
||||||
gfx = make_gfx_mario_alpha(asGenerated, alpha);
|
gfx = make_gfx_mario_alpha(asGenerated, alpha);
|
||||||
}
|
}
|
||||||
return gfx;
|
return gfx;
|
||||||
@@ -387,13 +386,12 @@ Gfx *geo_switch_mario_eyes(s32 callContext, struct GraphNode *node, UNUSED Mat4
|
|||||||
{
|
{
|
||||||
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *)node;
|
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *)node;
|
||||||
struct MarioBodyState *bodyState = &gBodyStates[switchCase->numCases];
|
struct MarioBodyState *bodyState = &gBodyStates[switchCase->numCases];
|
||||||
s16 blinkFrame;
|
|
||||||
|
|
||||||
if (callContext == GEO_CONTEXT_RENDER)
|
if (callContext == GEO_CONTEXT_RENDER)
|
||||||
{
|
{
|
||||||
if (bodyState->eyeState == 0)
|
if (bodyState->eyeState == 0)
|
||||||
{
|
{
|
||||||
blinkFrame = (switchCase->numCases * 32 + gAreaUpdateCounter) >> 1 & 0x1F;
|
s16 blinkFrame = (switchCase->numCases * 32 + gAreaUpdateCounter) >> 1 & 0x1F;
|
||||||
if (blinkFrame < 7)
|
if (blinkFrame < 7)
|
||||||
{
|
{
|
||||||
switchCase->selectedCase = gMarioBlinkAnimation[blinkFrame];
|
switchCase->selectedCase = gMarioBlinkAnimation[blinkFrame];
|
||||||
|
|||||||
@@ -271,13 +271,12 @@ void stop_and_set_height_to_floor(struct MarioState *m)
|
|||||||
|
|
||||||
s32 stationary_ground_step(struct MarioState *m)
|
s32 stationary_ground_step(struct MarioState *m)
|
||||||
{
|
{
|
||||||
u32 takeStep;
|
|
||||||
struct Object *marioObj = m->marioObj;
|
struct Object *marioObj = m->marioObj;
|
||||||
u32 stepResult = GROUND_STEP_NONE;
|
u32 stepResult = GROUND_STEP_NONE;
|
||||||
|
|
||||||
mario_set_forward_vel(m, 0.0f);
|
mario_set_forward_vel(m, 0.0f);
|
||||||
|
|
||||||
takeStep = mario_update_moving_sand(m);
|
u32 takeStep = mario_update_moving_sand(m);
|
||||||
takeStep |= mario_update_windy_ground(m);
|
takeStep |= mario_update_windy_ground(m);
|
||||||
if (takeStep)
|
if (takeStep)
|
||||||
{
|
{
|
||||||
@@ -297,23 +296,17 @@ s32 stationary_ground_step(struct MarioState *m)
|
|||||||
|
|
||||||
static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos)
|
static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos)
|
||||||
{
|
{
|
||||||
UNUSED
|
|
||||||
struct SM64SurfaceCollisionData *lowerWall;
|
|
||||||
struct SM64SurfaceCollisionData *upperWall;
|
|
||||||
struct SM64SurfaceCollisionData *ceil;
|
struct SM64SurfaceCollisionData *ceil;
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor;
|
||||||
f32 ceilHeight;
|
|
||||||
f32 floorHeight;
|
|
||||||
f32 waterLevel;
|
|
||||||
|
|
||||||
lowerWall = resolve_and_return_wall_collisions(nextPos, 30.0f, 24.0f);
|
struct SM64SurfaceCollisionData *lowerWall = resolve_and_return_wall_collisions(nextPos, 30.0f, 24.0f);
|
||||||
upperWall = resolve_and_return_wall_collisions(nextPos, 60.0f, 50.0f);
|
struct SM64SurfaceCollisionData *upperWall = resolve_and_return_wall_collisions(nextPos, 60.0f, 50.0f);
|
||||||
|
|
||||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
f32 floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||||
ceilHeight = vec3f_find_ceil(nextPos, floorHeight, &ceil);
|
f32 ceilHeight = vec3f_find_ceil(nextPos, floorHeight, &ceil);
|
||||||
|
|
||||||
//waterLevel = find_water_level(nextPos[0], nextPos[2]);
|
//waterLevel = find_water_level(nextPos[0], nextPos[2]);
|
||||||
waterLevel = m->waterLevel;
|
f32 waterLevel = m->waterLevel;
|
||||||
|
|
||||||
m->wall = upperWall;
|
m->wall = upperWall;
|
||||||
|
|
||||||
@@ -372,11 +365,10 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos)
|
|||||||
|
|
||||||
s32 perform_ground_step(struct MarioState *m)
|
s32 perform_ground_step(struct MarioState *m)
|
||||||
{
|
{
|
||||||
s32 i;
|
|
||||||
u32 stepResult;
|
u32 stepResult;
|
||||||
Vec3f intendedPos;
|
Vec3f intendedPos;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (s32 i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
intendedPos[0] = m->pos[0] + m->floor->normal.y * (m->vel[0] / 4.0f);
|
intendedPos[0] = m->pos[0] + m->floor->normal.y * (m->vel[0] / 4.0f);
|
||||||
intendedPos[2] = m->pos[2] + m->floor->normal.y * (m->vel[2] / 4.0f);
|
intendedPos[2] = m->pos[2] + m->floor->normal.y * (m->vel[2] / 4.0f);
|
||||||
@@ -404,16 +396,14 @@ u32 check_ledge_grab(struct MarioState *m, struct SM64SurfaceCollisionData *wall
|
|||||||
{
|
{
|
||||||
struct SM64SurfaceCollisionData *ledgeFloor;
|
struct SM64SurfaceCollisionData *ledgeFloor;
|
||||||
Vec3f ledgePos;
|
Vec3f ledgePos;
|
||||||
f32 displacementX;
|
|
||||||
f32 displacementZ;
|
|
||||||
|
|
||||||
if (m->vel[1] > 0)
|
if (m->vel[1] > 0)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
displacementX = nextPos[0] - intendedPos[0];
|
f32 displacementX = nextPos[0] - intendedPos[0];
|
||||||
displacementZ = nextPos[2] - intendedPos[2];
|
f32 displacementZ = nextPos[2] - intendedPos[2];
|
||||||
|
|
||||||
// Only ledge grab if the wall displaced Mario in the opposite direction of
|
// Only ledge grab if the wall displaced Mario in the opposite direction of
|
||||||
// his velocity.
|
// his velocity.
|
||||||
@@ -446,26 +436,20 @@ u32 check_ledge_grab(struct MarioState *m, struct SM64SurfaceCollisionData *wall
|
|||||||
|
|
||||||
s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepArg)
|
s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepArg)
|
||||||
{
|
{
|
||||||
s16 wallDYaw;
|
|
||||||
Vec3f nextPos;
|
Vec3f nextPos;
|
||||||
struct SM64SurfaceCollisionData *upperWall;
|
|
||||||
struct SM64SurfaceCollisionData *lowerWall;
|
|
||||||
struct SM64SurfaceCollisionData *ceil;
|
struct SM64SurfaceCollisionData *ceil;
|
||||||
struct SM64SurfaceCollisionData *floor;
|
struct SM64SurfaceCollisionData *floor;
|
||||||
f32 ceilHeight;
|
|
||||||
f32 floorHeight;
|
|
||||||
f32 waterLevel;
|
|
||||||
|
|
||||||
vec3f_copy(nextPos, intendedPos);
|
vec3f_copy(nextPos, intendedPos);
|
||||||
|
|
||||||
upperWall = resolve_and_return_wall_collisions(nextPos, 150.0f, 50.0f);
|
struct SM64SurfaceCollisionData *upperWall = resolve_and_return_wall_collisions(nextPos, 150.0f, 50.0f);
|
||||||
lowerWall = resolve_and_return_wall_collisions(nextPos, 30.0f, 50.0f);
|
struct SM64SurfaceCollisionData *lowerWall = resolve_and_return_wall_collisions(nextPos, 30.0f, 50.0f);
|
||||||
|
|
||||||
floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
f32 floorHeight = find_floor(nextPos[0], nextPos[1], nextPos[2], &floor);
|
||||||
ceilHeight = vec3f_find_ceil(nextPos, floorHeight, &ceil);
|
f32 ceilHeight = vec3f_find_ceil(nextPos, floorHeight, &ceil);
|
||||||
|
|
||||||
//waterLevel = find_water_level(nextPos[0], nextPos[2]);
|
//waterLevel = find_water_level(nextPos[0], nextPos[2]);
|
||||||
waterLevel = m->waterLevel;
|
f32 waterLevel = m->waterLevel;
|
||||||
|
|
||||||
m->wall = NULL;
|
m->wall = NULL;
|
||||||
|
|
||||||
@@ -558,7 +542,7 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
|
|||||||
if (upperWall != NULL || lowerWall != NULL)
|
if (upperWall != NULL || lowerWall != NULL)
|
||||||
{
|
{
|
||||||
m->wall = upperWall != NULL ? upperWall : lowerWall;
|
m->wall = upperWall != NULL ? upperWall : lowerWall;
|
||||||
wallDYaw = atan2s(m->wall->normal.z, m->wall->normal.x) - m->faceAngle[1];
|
s16 wallDYaw = atan2s(m->wall->normal.z, m->wall->normal.x) - m->faceAngle[1];
|
||||||
|
|
||||||
if (m->wall->type == SURFACE_BURNING)
|
if (m->wall->type == SURFACE_BURNING)
|
||||||
{
|
{
|
||||||
@@ -577,7 +561,6 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
|
|||||||
|
|
||||||
void apply_twirl_gravity(struct MarioState *m)
|
void apply_twirl_gravity(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 terminalVelocity;
|
|
||||||
f32 heaviness = 1.0f;
|
f32 heaviness = 1.0f;
|
||||||
|
|
||||||
if (m->angleVel[1] > 1024)
|
if (m->angleVel[1] > 1024)
|
||||||
@@ -585,7 +568,7 @@ void apply_twirl_gravity(struct MarioState *m)
|
|||||||
heaviness = 1024.0f / m->angleVel[1];
|
heaviness = 1024.0f / m->angleVel[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
terminalVelocity = -75.0f * heaviness;
|
f32 terminalVelocity = -75.0f * heaviness;
|
||||||
|
|
||||||
m->vel[1] -= 4.0f * heaviness;
|
m->vel[1] -= 4.0f * heaviness;
|
||||||
if (m->vel[1] < terminalVelocity)
|
if (m->vel[1] < terminalVelocity)
|
||||||
@@ -691,11 +674,10 @@ void apply_gravity(struct MarioState *m)
|
|||||||
void apply_vertical_wind(struct MarioState *m)
|
void apply_vertical_wind(struct MarioState *m)
|
||||||
{
|
{
|
||||||
f32 maxVelY;
|
f32 maxVelY;
|
||||||
f32 offsetY;
|
|
||||||
|
|
||||||
if (m->action != ACT_GROUND_POUND)
|
if (m->action != ACT_GROUND_POUND)
|
||||||
{
|
{
|
||||||
offsetY = m->pos[1] - -1500.0f;
|
f32 offsetY = m->pos[1] - -1500.0f;
|
||||||
|
|
||||||
if (m->floor->type == SURFACE_VERTICAL_WIND && -3000.0f < offsetY && offsetY < 2000.0f)
|
if (m->floor->type == SURFACE_VERTICAL_WIND && -3000.0f < offsetY && offsetY < 2000.0f)
|
||||||
{
|
{
|
||||||
@@ -726,19 +708,17 @@ void apply_vertical_wind(struct MarioState *m)
|
|||||||
s32 perform_air_step(struct MarioState *m, u32 stepArg)
|
s32 perform_air_step(struct MarioState *m, u32 stepArg)
|
||||||
{
|
{
|
||||||
Vec3f intendedPos;
|
Vec3f intendedPos;
|
||||||
s32 i;
|
|
||||||
s32 quarterStepResult;
|
|
||||||
s32 stepResult = AIR_STEP_NONE;
|
s32 stepResult = AIR_STEP_NONE;
|
||||||
|
|
||||||
m->wall = NULL;
|
m->wall = NULL;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (s32 i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
intendedPos[0] = m->pos[0] + m->vel[0] / 4.0f;
|
intendedPos[0] = m->pos[0] + m->vel[0] / 4.0f;
|
||||||
intendedPos[1] = m->pos[1] + m->vel[1] / 4.0f;
|
intendedPos[1] = m->pos[1] + m->vel[1] / 4.0f;
|
||||||
intendedPos[2] = m->pos[2] + m->vel[2] / 4.0f;
|
intendedPos[2] = m->pos[2] + m->vel[2] / 4.0f;
|
||||||
|
|
||||||
quarterStepResult = perform_air_quarter_step(m, intendedPos, stepArg);
|
s32 quarterStepResult = perform_air_quarter_step(m, intendedPos, stepArg);
|
||||||
|
|
||||||
//! On one qf, hit OOB/ceil/wall to store the 2 return value, and continue
|
//! On one qf, hit OOB/ceil/wall to store the 2 return value, and continue
|
||||||
// getting 0s until your last qf. Graze a wall on your last qf, and it will
|
// getting 0s until your last qf. Graze a wall on your last qf, and it will
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ static Vec3s gVec3sZero = {0, 0, 0};
|
|||||||
|
|
||||||
static struct Object *try_allocate_object(void)
|
static struct Object *try_allocate_object(void)
|
||||||
{
|
{
|
||||||
struct ObjectNode *nextObj;
|
struct ObjectNode *nextObj = (struct ObjectNode *)malloc(sizeof(struct Object));
|
||||||
nextObj = (struct ObjectNode *)malloc(sizeof(struct Object));
|
|
||||||
nextObj->prev = NULL;
|
nextObj->prev = NULL;
|
||||||
nextObj->next = NULL;
|
nextObj->next = NULL;
|
||||||
return (struct Object *)nextObj;
|
return (struct Object *)nextObj;
|
||||||
@@ -22,7 +21,6 @@ static struct Object *try_allocate_object(void)
|
|||||||
|
|
||||||
static struct Object *allocate_object(void)
|
static struct Object *allocate_object(void)
|
||||||
{
|
{
|
||||||
s32 i;
|
|
||||||
struct Object *obj = try_allocate_object();
|
struct Object *obj = try_allocate_object();
|
||||||
|
|
||||||
// Initialize object fields
|
// Initialize object fields
|
||||||
@@ -33,7 +31,7 @@ static struct Object *allocate_object(void)
|
|||||||
obj->collidedObjInteractTypes = 0;
|
obj->collidedObjInteractTypes = 0;
|
||||||
obj->numCollidedObjs = 0;
|
obj->numCollidedObjs = 0;
|
||||||
|
|
||||||
for (i = 0; i < 0x50; i++)
|
for (s32 i = 0; i < 0x50; i++)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
obj->rawData.asS32[i] = 0;
|
obj->rawData.asS32[i] = 0;
|
||||||
@@ -89,8 +87,7 @@ static struct Object *allocate_object(void)
|
|||||||
|
|
||||||
static struct Object *create_object(void)
|
static struct Object *create_object(void)
|
||||||
{
|
{
|
||||||
struct Object *obj;
|
struct Object *obj = allocate_object();
|
||||||
obj = allocate_object();
|
|
||||||
obj->curBhvCommand = NULL;
|
obj->curBhvCommand = NULL;
|
||||||
obj->behavior = NULL;
|
obj->behavior = NULL;
|
||||||
return obj;
|
return obj;
|
||||||
@@ -115,9 +112,7 @@ static void geo_obj_init(struct GraphNodeObject *graphNode, void *sharedChild, V
|
|||||||
|
|
||||||
static struct Object *spawn_object_at_origin(void)
|
static struct Object *spawn_object_at_origin(void)
|
||||||
{
|
{
|
||||||
struct Object *obj;
|
struct Object *obj = create_object();
|
||||||
obj = create_object();
|
|
||||||
|
|
||||||
obj->parentObj = NULL;
|
obj->parentObj = NULL;
|
||||||
obj->header.gfx.areaIndex = 0;
|
obj->header.gfx.areaIndex = 0;
|
||||||
obj->header.gfx.activeAreaIndex = 0;
|
obj->header.gfx.activeAreaIndex = 0;
|
||||||
@@ -194,11 +189,9 @@ void bhv_mario_update(void)
|
|||||||
|
|
||||||
void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2)
|
void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2)
|
||||||
{
|
{
|
||||||
f32 spC, sp8, sp4;
|
f32 spC = a2[3][0] * a2[0][0] + a2[3][1] * a2[0][1] + a2[3][2] * a2[0][2];
|
||||||
|
f32 sp8 = a2[3][0] * a2[1][0] + a2[3][1] * a2[1][1] + a2[3][2] * a2[1][2];
|
||||||
spC = a2[3][0] * a2[0][0] + a2[3][1] * a2[0][1] + a2[3][2] * a2[0][2];
|
f32 sp4 = a2[3][0] * a2[2][0] + a2[3][1] * a2[2][1] + a2[3][2] * a2[2][2];
|
||||||
sp8 = a2[3][0] * a2[1][0] + a2[3][1] * a2[1][1] + a2[3][2] * a2[1][2];
|
|
||||||
sp4 = a2[3][0] * a2[2][0] + a2[3][1] * a2[2][1] + a2[3][2] * a2[2][2];
|
|
||||||
|
|
||||||
a0[0][0] = a1[0][0] * a2[0][0] + a1[0][1] * a2[0][1] + a1[0][2] * a2[0][2];
|
a0[0][0] = a1[0][0] * a2[0][0] + a1[0][1] * a2[0][1] + a1[0][2] * a2[0][2];
|
||||||
a0[0][1] = a1[0][0] * a2[1][0] + a1[0][1] * a2[1][1] + a1[0][2] * a2[1][2];
|
a0[0][1] = a1[0][0] * a2[1][0] + a1[0][1] * a2[1][1] + a1[0][2] * a2[1][2];
|
||||||
|
|||||||
@@ -98,9 +98,6 @@ void apply_platform_displacement(u32 isMario, struct SM64SurfaceObjectTransform
|
|||||||
Vec3f relativeOffset;
|
Vec3f relativeOffset;
|
||||||
Vec3f newObjectOffset;
|
Vec3f newObjectOffset;
|
||||||
Vec3s rotation;
|
Vec3s rotation;
|
||||||
UNUSED s16 unused1;
|
|
||||||
UNUSED s16 unused2;
|
|
||||||
UNUSED s16 unused3;
|
|
||||||
f32 displaceMatrix[4][4];
|
f32 displaceMatrix[4][4];
|
||||||
|
|
||||||
rotation[0] = platform->aAngleVelPitch;
|
rotation[0] = platform->aAngleVelPitch;
|
||||||
@@ -121,9 +118,9 @@ void apply_platform_displacement(u32 isMario, struct SM64SurfaceObjectTransform
|
|||||||
|
|
||||||
if (rotation[0] != 0 || rotation[1] != 0 || rotation[2] != 0)
|
if (rotation[0] != 0 || rotation[1] != 0 || rotation[2] != 0)
|
||||||
{
|
{
|
||||||
unused1 = rotation[0];
|
s16 unused1 = rotation[0];
|
||||||
unused2 = rotation[2];
|
s16 unused2 = rotation[2];
|
||||||
unused3 = platform->aFaceAngleYaw;
|
s16 unused3 = platform->aFaceAngleYaw;
|
||||||
|
|
||||||
if (isMario)
|
if (isMario)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -170,7 +170,6 @@ LookAt lookAt;
|
|||||||
static void geo_process_master_list_sub(struct GraphNodeMasterList *node)
|
static void geo_process_master_list_sub(struct GraphNodeMasterList *node)
|
||||||
{
|
{
|
||||||
struct DisplayListNode *currList;
|
struct DisplayListNode *currList;
|
||||||
s32 i;
|
|
||||||
s32 enableZBuffer = (node->node.flags & GRAPH_RENDER_Z_BUFFER) != 0;
|
s32 enableZBuffer = (node->node.flags & GRAPH_RENDER_Z_BUFFER) != 0;
|
||||||
// struct RenderModeContainer *modeList = &renderModeTable_1Cycle[enableZBuffer];
|
// struct RenderModeContainer *modeList = &renderModeTable_1Cycle[enableZBuffer];
|
||||||
// struct RenderModeContainer *mode2List = &renderModeTable_2Cycle[enableZBuffer];
|
// struct RenderModeContainer *mode2List = &renderModeTable_2Cycle[enableZBuffer];
|
||||||
@@ -193,7 +192,7 @@ static void geo_process_master_list_sub(struct GraphNodeMasterList *node)
|
|||||||
// Mario ends up in the second master list for some reason.
|
// Mario ends up in the second master list for some reason.
|
||||||
// The first item in the list is the projection matrix that is uninitialized, so just skip it.
|
// The first item in the list is the projection matrix that is uninitialized, so just skip it.
|
||||||
int xx = FALSE;
|
int xx = FALSE;
|
||||||
for (i = 1; i < GFX_NUM_MASTER_LISTS; i++)
|
for (s32 i = 1; i < GFX_NUM_MASTER_LISTS; i++)
|
||||||
{
|
{
|
||||||
if ((currList = node->listHeads[i]) != NULL)
|
if ((currList = node->listHeads[i]) != NULL)
|
||||||
{
|
{
|
||||||
@@ -256,13 +255,12 @@ static void geo_append_display_list(void *displayList, s16 layer)
|
|||||||
*/
|
*/
|
||||||
static void geo_process_master_list(struct GraphNodeMasterList *node)
|
static void geo_process_master_list(struct GraphNodeMasterList *node)
|
||||||
{
|
{
|
||||||
s32 i;
|
|
||||||
UNUSED s32 sp1C;
|
UNUSED s32 sp1C;
|
||||||
|
|
||||||
if (gCurGraphNodeMasterList == NULL && node->node.children != NULL)
|
if (gCurGraphNodeMasterList == NULL && node->node.children != NULL)
|
||||||
{
|
{
|
||||||
gCurGraphNodeMasterList = node;
|
gCurGraphNodeMasterList = node;
|
||||||
for (i = 0; i < GFX_NUM_MASTER_LISTS; i++)
|
for (s32 i = 0; i < GFX_NUM_MASTER_LISTS; i++)
|
||||||
{
|
{
|
||||||
node->listHeads[i] = NULL;
|
node->listHeads[i] = NULL;
|
||||||
}
|
}
|
||||||
@@ -364,13 +362,12 @@ static void geo_process_level_of_detail(struct GraphNodeLevelOfDetail *node)
|
|||||||
static void geo_process_switch(struct GraphNodeSwitchCase *node)
|
static void geo_process_switch(struct GraphNodeSwitchCase *node)
|
||||||
{
|
{
|
||||||
struct GraphNode *selectedChild = node->fnNode.node.children;
|
struct GraphNode *selectedChild = node->fnNode.node.children;
|
||||||
s32 i;
|
|
||||||
|
|
||||||
if (node->fnNode.func != NULL)
|
if (node->fnNode.func != NULL)
|
||||||
{
|
{
|
||||||
node->fnNode.func(GEO_CONTEXT_RENDER, &node->fnNode.node, gMatStack[gMatStackIndex]);
|
node->fnNode.func(GEO_CONTEXT_RENDER, &node->fnNode.node, gMatStack[gMatStackIndex]);
|
||||||
}
|
}
|
||||||
for (i = 0; selectedChild != NULL && node->selectedCase > i; i++)
|
for (s32 i = 0; selectedChild != NULL && node->selectedCase > i; i++)
|
||||||
{
|
{
|
||||||
selectedChild = selectedChild->next;
|
selectedChild = selectedChild->next;
|
||||||
}
|
}
|
||||||
@@ -879,23 +876,21 @@ static void geo_process_shadow(struct GraphNodeShadow *node)
|
|||||||
static s32 obj_is_in_view(struct GraphNodeObject *node, Mat4 matrix)
|
static s32 obj_is_in_view(struct GraphNodeObject *node, Mat4 matrix)
|
||||||
{
|
{
|
||||||
s16 cullingRadius;
|
s16 cullingRadius;
|
||||||
s16 halfFov; // half of the fov in in-game angle units instead of degrees
|
// half of the fov in in-game angle units instead of degrees
|
||||||
struct GraphNode *geo;
|
|
||||||
f32 hScreenEdge;
|
|
||||||
|
|
||||||
if (node->node.flags & GRAPH_RENDER_INVISIBLE)
|
if (node->node.flags & GRAPH_RENDER_INVISIBLE)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
geo = node->sharedChild;
|
struct GraphNode *geo = node->sharedChild;
|
||||||
|
|
||||||
// ! @bug The aspect ratio is not accounted for. When the fov value is 45,
|
// ! @bug The aspect ratio is not accounted for. When the fov value is 45,
|
||||||
// the horizontal effective fov is actually 60 degrees, so you can see objects
|
// the horizontal effective fov is actually 60 degrees, so you can see objects
|
||||||
// visibly pop in or out at the edge of the screen.
|
// visibly pop in or out at the edge of the screen.
|
||||||
halfFov = (gCurGraphNodeCamFrustum->fov / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f;
|
s16 halfFov = (gCurGraphNodeCamFrustum->fov / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f;
|
||||||
|
|
||||||
hScreenEdge = -matrix[3][2] * sins(halfFov) / coss(halfFov);
|
f32 hScreenEdge = -matrix[3][2] * sins(halfFov) / coss(halfFov);
|
||||||
// -matrix[3][2] is the depth, which gets multiplied by tan(halfFov) to get
|
// -matrix[3][2] is the depth, which gets multiplied by tan(halfFov) to get
|
||||||
// the amount of units between the center of the screen and the horizontal edge
|
// the amount of units between the center of the screen and the horizontal edge
|
||||||
// given the distance from the object to the camera.
|
// given the distance from the object to the camera.
|
||||||
@@ -1274,10 +1269,8 @@ void geo_process_root_hack_single_node(struct GraphNode *node)
|
|||||||
|
|
||||||
display_list_pool_reset();
|
display_list_pool_reset();
|
||||||
|
|
||||||
Mtx *initialMatrix;
|
|
||||||
|
|
||||||
gDisplayListHeap = alloc_only_pool_init();
|
gDisplayListHeap = alloc_only_pool_init();
|
||||||
initialMatrix = alloc_display_list(sizeof(*initialMatrix));
|
Mtx *initialMatrix = alloc_display_list(sizeof(*initialMatrix));
|
||||||
gMatStackIndex = 0;
|
gMatStackIndex = 0;
|
||||||
gCurAnimType = 0;
|
gCurAnimType = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
|
|
||||||
void alSeqFileNew(ALSeqFile *f, u8 *base)
|
void alSeqFileNew(ALSeqFile *f, u8 *base)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < f->seqCount; i++)
|
||||||
for (i = 0; i < f->seqCount; i++)
|
|
||||||
{
|
{
|
||||||
PATCH(f->seqArray[i].offset, base, u8 *);
|
PATCH(f->seqArray[i].offset, base, u8 *);
|
||||||
}
|
}
|
||||||
@@ -14,11 +13,6 @@ void alSeqFileNew(ALSeqFile *f, u8 *base)
|
|||||||
|
|
||||||
static void _bnkfPatchBank(ALInstrument *inst, ALBankFile *f, u8 *table)
|
static void _bnkfPatchBank(ALInstrument *inst, ALBankFile *f, u8 *table)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
ALSound *sound;
|
|
||||||
ALWaveTable *wavetable;
|
|
||||||
u8 *table2;
|
|
||||||
|
|
||||||
if (inst->flags)
|
if (inst->flags)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -26,22 +20,22 @@ static void _bnkfPatchBank(ALInstrument *inst, ALBankFile *f, u8 *table)
|
|||||||
|
|
||||||
inst->flags = 1;
|
inst->flags = 1;
|
||||||
|
|
||||||
for (i = 0; i < inst->soundCount; i++)
|
for (int i = 0; i < inst->soundCount; i++)
|
||||||
{
|
{
|
||||||
PATCH(inst->soundArray[i], f, ALSound *);
|
PATCH(inst->soundArray[i], f, ALSound *);
|
||||||
sound = inst->soundArray[i];
|
ALSound *sound = inst->soundArray[i];
|
||||||
if (sound->flags)
|
if (sound->flags)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
table2 = table;
|
u8 *table2 = table;
|
||||||
|
|
||||||
sound->flags = 1;
|
sound->flags = 1;
|
||||||
PATCH(sound->envelope, f, ALEnvelope *);
|
PATCH(sound->envelope, f, ALEnvelope *);
|
||||||
PATCH(sound->keyMap, f, ALKeyMap *);
|
PATCH(sound->keyMap, f, ALKeyMap *);
|
||||||
PATCH(sound->wavetable, f, ALWaveTable *);
|
PATCH(sound->wavetable, f, ALWaveTable *);
|
||||||
wavetable = sound->wavetable;
|
ALWaveTable *wavetable = sound->wavetable;
|
||||||
if (wavetable->flags)
|
if (wavetable->flags)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -75,16 +69,13 @@ static void unused(void)
|
|||||||
|
|
||||||
void alBnkfNew(ALBankFile *f, u8 *table)
|
void alBnkfNew(ALBankFile *f, u8 *table)
|
||||||
{
|
{
|
||||||
ALBank *bank;
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
unused();
|
unused();
|
||||||
if (f->revision != AL_BANK_VERSION)
|
if (f->revision != AL_BANK_VERSION)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < f->bankCount; i++)
|
for (int i = 0; i < f->bankCount; i++)
|
||||||
{
|
{
|
||||||
PATCH(f->bankArray[i], f, ALBank *);
|
PATCH(f->bankArray[i], f, ALBank *);
|
||||||
if (f->bankArray[i] == NULL)
|
if (f->bankArray[i] == NULL)
|
||||||
@@ -92,7 +83,7 @@ void alBnkfNew(ALBankFile *f, u8 *table)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bank = f->bankArray[i];
|
ALBank *bank = f->bankArray[i];
|
||||||
if (bank->flags == 0)
|
if (bank->flags == 0)
|
||||||
{
|
{
|
||||||
bank->flags = 1;
|
bank->flags = 1;
|
||||||
@@ -101,7 +92,7 @@ void alBnkfNew(ALBankFile *f, u8 *table)
|
|||||||
PATCH(bank->percussion, f, ALInstrument *);
|
PATCH(bank->percussion, f, ALInstrument *);
|
||||||
_bnkfPatchBank(bank->percussion, f, table);
|
_bnkfPatchBank(bank->percussion, f, table);
|
||||||
}
|
}
|
||||||
for (j = 0; j < bank->instCount; j++)
|
for (int j = 0; j < bank->instCount; j++)
|
||||||
{
|
{
|
||||||
PATCH(bank->instArray[j], f, ALInstrument *);
|
PATCH(bank->instArray[j], f, ALInstrument *);
|
||||||
if (bank->instArray[j] != NULL)
|
if (bank->instArray[j] != NULL)
|
||||||
|
|||||||
@@ -474,7 +474,7 @@ void aADPCMdecImpl(uint8_t flags, ADPCM_STATE state)
|
|||||||
int16_t ins[8];
|
int16_t ins[8];
|
||||||
int16_t prev1 = out[-1];
|
int16_t prev1 = out[-1];
|
||||||
int16_t prev2 = out[-2];
|
int16_t prev2 = out[-2];
|
||||||
int j, k;
|
int j;
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
ins[j * 2] = (((*in >> 4) << 28) >> 28) << shift;
|
ins[j * 2] = (((*in >> 4) << 28) >> 28) << shift;
|
||||||
@@ -483,7 +483,7 @@ void aADPCMdecImpl(uint8_t flags, ADPCM_STATE state)
|
|||||||
for (j = 0; j < 8; j++)
|
for (j = 0; j < 8; j++)
|
||||||
{
|
{
|
||||||
int32_t acc = tbl[0][j] * prev2 + tbl[1][j] * prev1 + (ins[j] << 11);
|
int32_t acc = tbl[0][j] * prev2 + tbl[1][j] * prev1 + (ins[j] << 11);
|
||||||
for (k = 0; k < j; k++)
|
for (int k = 0; k < j; k++)
|
||||||
{
|
{
|
||||||
acc += tbl[1][(j - k - 1)] * ins[k];
|
acc += tbl[1][(j - k - 1)] * ins[k];
|
||||||
}
|
}
|
||||||
@@ -931,7 +931,7 @@ void aEnvMixerImpl(uint8_t flags, ENVMIX_STATE state)
|
|||||||
int32_t step_diff[2];
|
int32_t step_diff[2];
|
||||||
int32_t vols[2][8];
|
int32_t vols[2][8];
|
||||||
|
|
||||||
int c, i;
|
int i;
|
||||||
|
|
||||||
if (flags & A_INIT)
|
if (flags & A_INIT)
|
||||||
{
|
{
|
||||||
@@ -964,7 +964,7 @@ void aEnvMixerImpl(uint8_t flags, ENVMIX_STATE state)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
for (c = 0; c < 2; c++)
|
for (int c = 0; c < 2; c++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
+23
-43
@@ -78,9 +78,7 @@ static int find_longest(const unsigned char *buf, int start_offset, int max_sear
|
|||||||
{
|
{
|
||||||
int best_length = 0;
|
int best_length = 0;
|
||||||
int best_offset = 0;
|
int best_offset = 0;
|
||||||
int cur_length;
|
int i;
|
||||||
int search_len;
|
|
||||||
int farthest, off, i;
|
|
||||||
int lb_idx;
|
int lb_idx;
|
||||||
const unsigned char first = buf[start_offset];
|
const unsigned char first = buf[start_offset];
|
||||||
lookback *lb = &lkbk[first];
|
lookback *lb = &lkbk[first];
|
||||||
@@ -93,7 +91,7 @@ static int find_longest(const unsigned char *buf, int start_offset, int max_sear
|
|||||||
// +cur_length
|
// +cur_length
|
||||||
|
|
||||||
// check at most the past 4096 values
|
// check at most the past 4096 values
|
||||||
farthest = MAX(start_offset - 4096, 0);
|
int farthest = MAX(start_offset - 4096, 0);
|
||||||
// find starting index
|
// find starting index
|
||||||
for (lb_idx = lb->start; lb_idx < lb->count && lb->indexes[lb_idx] < farthest; lb_idx++)
|
for (lb_idx = lb->start; lb_idx < lb->count && lb->indexes[lb_idx] < farthest; lb_idx++)
|
||||||
{
|
{
|
||||||
@@ -101,9 +99,9 @@ static int find_longest(const unsigned char *buf, int start_offset, int max_sear
|
|||||||
lb->start = lb_idx;
|
lb->start = lb_idx;
|
||||||
for (; lb_idx < lb->count && lb->indexes[lb_idx] < start_offset; lb_idx++)
|
for (; lb_idx < lb->count && lb->indexes[lb_idx] < start_offset; lb_idx++)
|
||||||
{
|
{
|
||||||
off = lb->indexes[lb_idx];
|
int off = lb->indexes[lb_idx];
|
||||||
// check at most requested max or up until start
|
// check at most requested max or up until start
|
||||||
search_len = MIN(max_search, start_offset - off);
|
int search_len = MIN(max_search, start_offset - off);
|
||||||
for (i = 0; i < search_len; i++)
|
for (i = 0; i < search_len; i++)
|
||||||
{
|
{
|
||||||
if (buf[start_offset + i] != buf[off + i])
|
if (buf[start_offset + i] != buf[off + i])
|
||||||
@@ -111,7 +109,7 @@ static int find_longest(const unsigned char *buf, int start_offset, int max_sear
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur_length = i;
|
int cur_length = i;
|
||||||
// if matched up until start, continue matching in already matched parts
|
// if matched up until start, continue matching in already matched parts
|
||||||
if (cur_length == search_len)
|
if (cur_length == search_len)
|
||||||
{
|
{
|
||||||
@@ -167,10 +165,9 @@ int mio0_decode(const unsigned char *in, unsigned char *out, unsigned int *end)
|
|||||||
int bit_idx = 0;
|
int bit_idx = 0;
|
||||||
int comp_idx = 0;
|
int comp_idx = 0;
|
||||||
int uncomp_idx = 0;
|
int uncomp_idx = 0;
|
||||||
int valid;
|
|
||||||
|
|
||||||
// extract header
|
// extract header
|
||||||
valid = mio0_decode_header(in, &head);
|
int valid = mio0_decode_header(in, &head);
|
||||||
// verify MIO0 header
|
// verify MIO0 header
|
||||||
if (!valid)
|
if (!valid)
|
||||||
{
|
{
|
||||||
@@ -190,14 +187,11 @@ int mio0_decode(const unsigned char *in, unsigned char *out, unsigned int *end)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 0 - read compressed data
|
// 0 - read compressed data
|
||||||
int idx;
|
|
||||||
int length;
|
|
||||||
int i;
|
|
||||||
const unsigned char *vals = &in[head.comp_offset + comp_idx];
|
const unsigned char *vals = &in[head.comp_offset + comp_idx];
|
||||||
comp_idx += 2;
|
comp_idx += 2;
|
||||||
length = ((vals[0] & 0xF0) >> 4) + 3;
|
int length = ((vals[0] & 0xF0) >> 4) + 3;
|
||||||
idx = ((vals[0] & 0x0F) << 8) + vals[1] + 1;
|
int idx = ((vals[0] & 0x0F) << 8) + vals[1] + 1;
|
||||||
for (i = 0; i < length; i++)
|
for (int i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
out[bytes_written] = out[bytes_written - idx];
|
out[bytes_written] = out[bytes_written - idx];
|
||||||
bytes_written++;
|
bytes_written++;
|
||||||
@@ -216,26 +210,18 @@ int mio0_decode(const unsigned char *in, unsigned char *out, unsigned int *end)
|
|||||||
|
|
||||||
int mio0_encode(const unsigned char *in, unsigned int length, unsigned char *out)
|
int mio0_encode(const unsigned char *in, unsigned int length, unsigned char *out)
|
||||||
{
|
{
|
||||||
unsigned char *bit_buf;
|
|
||||||
unsigned char *comp_buf;
|
|
||||||
unsigned char *uncomp_buf;
|
|
||||||
unsigned int bit_length;
|
|
||||||
unsigned int comp_offset;
|
|
||||||
unsigned int uncomp_offset;
|
|
||||||
unsigned int bytes_proc = 0;
|
unsigned int bytes_proc = 0;
|
||||||
int bytes_written;
|
|
||||||
int bit_idx = 0;
|
int bit_idx = 0;
|
||||||
int comp_idx = 0;
|
int comp_idx = 0;
|
||||||
int uncomp_idx = 0;
|
int uncomp_idx = 0;
|
||||||
lookback *lookbacks;
|
|
||||||
|
|
||||||
// initialize lookback buffer
|
// initialize lookback buffer
|
||||||
lookbacks = lookback_init();
|
lookback *lookbacks = lookback_init();
|
||||||
|
|
||||||
// allocate some temporary buffers worst case size
|
// allocate some temporary buffers worst case size
|
||||||
bit_buf = malloc((length + 7) / 8); // 1-bit/byte
|
unsigned char *bit_buf = malloc((length + 7) / 8); // 1-bit/byte
|
||||||
comp_buf = malloc(length); // 16-bits/2bytes
|
unsigned char *comp_buf = malloc(length); // 16-bits/2bytes
|
||||||
uncomp_buf = malloc(length); // all uncompressed
|
unsigned char *uncomp_buf = malloc(length); // all uncompressed
|
||||||
memset(bit_buf, 0, (length + 7) / 8);
|
memset(bit_buf, 0, (length + 7) / 8);
|
||||||
|
|
||||||
// encode data
|
// encode data
|
||||||
@@ -297,11 +283,11 @@ int mio0_encode(const unsigned char *in, unsigned int length, unsigned char *out
|
|||||||
|
|
||||||
// compute final sizes and offsets
|
// compute final sizes and offsets
|
||||||
// +7 so int division accounts for all bits
|
// +7 so int division accounts for all bits
|
||||||
bit_length = (bit_idx + 7) / 8;
|
unsigned int bit_length = (bit_idx + 7) / 8;
|
||||||
// compressed data after control bits and aligned to 4-byte boundary
|
// compressed data after control bits and aligned to 4-byte boundary
|
||||||
comp_offset = ALIGN(MIO0_HEADER_LENGTH + bit_length, 4);
|
unsigned int comp_offset = ALIGN(MIO0_HEADER_LENGTH + bit_length, 4);
|
||||||
uncomp_offset = comp_offset + comp_idx;
|
unsigned int uncomp_offset = comp_offset + comp_idx;
|
||||||
bytes_written = uncomp_offset + uncomp_idx;
|
int bytes_written = uncomp_offset + uncomp_idx;
|
||||||
|
|
||||||
// output header
|
// output header
|
||||||
memcpy(out, "MIO0", 4);
|
memcpy(out, "MIO0", 4);
|
||||||
@@ -340,18 +326,15 @@ static FILE *mio0_open_out_file(const char *out_file)
|
|||||||
int mio0_decode_file(const char *in_file, unsigned long offset, const char *out_file)
|
int mio0_decode_file(const char *in_file, unsigned long offset, const char *out_file)
|
||||||
{
|
{
|
||||||
mio0_header_t head;
|
mio0_header_t head;
|
||||||
FILE *in;
|
|
||||||
FILE *out;
|
FILE *out;
|
||||||
unsigned char *in_buf = NULL;
|
unsigned char *in_buf = NULL;
|
||||||
unsigned char *out_buf = NULL;
|
unsigned char *out_buf = NULL;
|
||||||
long file_size;
|
|
||||||
int ret_val = 0;
|
int ret_val = 0;
|
||||||
size_t bytes_read;
|
|
||||||
int bytes_decoded;
|
int bytes_decoded;
|
||||||
int bytes_written;
|
int bytes_written;
|
||||||
int valid;
|
int valid;
|
||||||
|
|
||||||
in = fopen(in_file, "rb");
|
FILE *in = fopen(in_file, "rb");
|
||||||
if (in == NULL)
|
if (in == NULL)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
@@ -359,12 +342,12 @@ int mio0_decode_file(const char *in_file, unsigned long offset, const char *out_
|
|||||||
|
|
||||||
// allocate buffer to read from offset to end of file
|
// allocate buffer to read from offset to end of file
|
||||||
fseek(in, 0, SEEK_END);
|
fseek(in, 0, SEEK_END);
|
||||||
file_size = ftell(in);
|
long file_size = ftell(in);
|
||||||
in_buf = malloc(file_size - offset);
|
in_buf = malloc(file_size - offset);
|
||||||
fseek(in, offset, SEEK_SET);
|
fseek(in, offset, SEEK_SET);
|
||||||
|
|
||||||
// read bytes
|
// read bytes
|
||||||
bytes_read = fread(in_buf, 1, file_size - offset, in);
|
size_t bytes_read = fread(in_buf, 1, file_size - offset, in);
|
||||||
if (bytes_read != file_size - offset)
|
if (bytes_read != file_size - offset)
|
||||||
{
|
{
|
||||||
ret_val = 2;
|
ret_val = 2;
|
||||||
@@ -423,17 +406,14 @@ free_all: if (out_buf)
|
|||||||
|
|
||||||
int mio0_encode_file(const char *in_file, const char *out_file)
|
int mio0_encode_file(const char *in_file, const char *out_file)
|
||||||
{
|
{
|
||||||
FILE *in;
|
|
||||||
FILE *out;
|
FILE *out;
|
||||||
unsigned char *in_buf = NULL;
|
unsigned char *in_buf = NULL;
|
||||||
unsigned char *out_buf = NULL;
|
unsigned char *out_buf = NULL;
|
||||||
size_t file_size;
|
|
||||||
size_t bytes_read;
|
|
||||||
int bytes_encoded;
|
int bytes_encoded;
|
||||||
int bytes_written;
|
int bytes_written;
|
||||||
int ret_val = 0;
|
int ret_val = 0;
|
||||||
|
|
||||||
in = fopen(in_file, "rb");
|
FILE *in = fopen(in_file, "rb");
|
||||||
if (in == NULL)
|
if (in == NULL)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
@@ -441,12 +421,12 @@ int mio0_encode_file(const char *in_file, const char *out_file)
|
|||||||
|
|
||||||
// allocate buffer to read entire contents of files
|
// allocate buffer to read entire contents of files
|
||||||
fseek(in, 0, SEEK_END);
|
fseek(in, 0, SEEK_END);
|
||||||
file_size = ftell(in);
|
size_t file_size = ftell(in);
|
||||||
fseek(in, 0, SEEK_SET);
|
fseek(in, 0, SEEK_SET);
|
||||||
in_buf = malloc(file_size);
|
in_buf = malloc(file_size);
|
||||||
|
|
||||||
// read bytes
|
// read bytes
|
||||||
bytes_read = fread(in_buf, 1, file_size, in);
|
size_t bytes_read = fread(in_buf, 1, file_size, in);
|
||||||
if (bytes_read != file_size)
|
if (bytes_read != file_size)
|
||||||
{
|
{
|
||||||
ret_val = 2;
|
ret_val = 2;
|
||||||
|
|||||||
@@ -42,9 +42,8 @@ typedef struct
|
|||||||
rgba *raw2rgba(const uint8_t *raw, int width, int height, int depth)
|
rgba *raw2rgba(const uint8_t *raw, int width, int height, int depth)
|
||||||
{
|
{
|
||||||
rgba *img;
|
rgba *img;
|
||||||
int img_size;
|
|
||||||
|
|
||||||
img_size = width * height * sizeof(*img);
|
int img_size = width * height * sizeof(*img);
|
||||||
img = malloc(img_size);
|
img = malloc(img_size);
|
||||||
if (!img)
|
if (!img)
|
||||||
{
|
{
|
||||||
@@ -79,9 +78,8 @@ rgba *raw2rgba(const uint8_t *raw, int width, int height, int depth)
|
|||||||
ia *raw2ia(const uint8_t *raw, int width, int height, int depth)
|
ia *raw2ia(const uint8_t *raw, int width, int height, int depth)
|
||||||
{
|
{
|
||||||
ia *img;
|
ia *img;
|
||||||
int img_size;
|
|
||||||
|
|
||||||
img_size = width * height * sizeof(*img);
|
int img_size = width * height * sizeof(*img);
|
||||||
img = malloc(img_size);
|
img = malloc(img_size);
|
||||||
if (!img)
|
if (!img)
|
||||||
{
|
{
|
||||||
@@ -108,8 +106,7 @@ ia *raw2ia(const uint8_t *raw, int width, int height, int depth)
|
|||||||
case 4:
|
case 4:
|
||||||
for (int i = 0; i < width * height; i++)
|
for (int i = 0; i < width * height; i++)
|
||||||
{
|
{
|
||||||
uint8_t bits;
|
uint8_t bits = raw[i / 2];
|
||||||
bits = raw[i / 2];
|
|
||||||
if (i % 2)
|
if (i % 2)
|
||||||
{
|
{
|
||||||
bits &= 0xF;
|
bits &= 0xF;
|
||||||
@@ -125,10 +122,8 @@ ia *raw2ia(const uint8_t *raw, int width, int height, int depth)
|
|||||||
case 1:
|
case 1:
|
||||||
for (int i = 0; i < width * height; i++)
|
for (int i = 0; i < width * height; i++)
|
||||||
{
|
{
|
||||||
uint8_t bits;
|
uint8_t bits = raw[i / 8];
|
||||||
uint8_t mask;
|
uint8_t mask = 1 << (7 - i % 8); // MSb->LSb
|
||||||
bits = raw[i / 8];
|
|
||||||
mask = 1 << (7 - i % 8); // MSb->LSb
|
|
||||||
bits = bits & mask ? 0xFF : 0x00;
|
bits = bits & mask ? 0xFF : 0x00;
|
||||||
img[i].intensity = bits;
|
img[i].intensity = bits;
|
||||||
img[i].alpha = bits;
|
img[i].alpha = bits;
|
||||||
@@ -145,9 +140,8 @@ ia *raw2ia(const uint8_t *raw, int width, int height, int depth)
|
|||||||
ia *raw2i(const uint8_t *raw, int width, int height, int depth)
|
ia *raw2i(const uint8_t *raw, int width, int height, int depth)
|
||||||
{
|
{
|
||||||
ia *img = NULL;
|
ia *img = NULL;
|
||||||
int img_size;
|
|
||||||
|
|
||||||
img_size = width * height * sizeof(*img);
|
int img_size = width * height * sizeof(*img);
|
||||||
img = malloc(img_size);
|
img = malloc(img_size);
|
||||||
if (!img)
|
if (!img)
|
||||||
{
|
{
|
||||||
@@ -167,8 +161,7 @@ ia *raw2i(const uint8_t *raw, int width, int height, int depth)
|
|||||||
case 4:
|
case 4:
|
||||||
for (int i = 0; i < width * height; i++)
|
for (int i = 0; i < width * height; i++)
|
||||||
{
|
{
|
||||||
uint8_t bits;
|
uint8_t bits = raw[i / 2];
|
||||||
bits = raw[i / 2];
|
|
||||||
if (i % 2)
|
if (i % 2)
|
||||||
{
|
{
|
||||||
bits &= 0xF;
|
bits &= 0xF;
|
||||||
@@ -195,12 +188,9 @@ ia *raw2i(const uint8_t *raw, int width, int height, int depth)
|
|||||||
// convert CI raw data and palette to raw data (either RGBA16 or IA16)
|
// convert CI raw data and palette to raw data (either RGBA16 or IA16)
|
||||||
uint8_t *ci2raw(const uint8_t *rawci, const uint8_t *palette, int width, int height, int ci_depth)
|
uint8_t *ci2raw(const uint8_t *rawci, const uint8_t *palette, int width, int height, int ci_depth)
|
||||||
{
|
{
|
||||||
uint8_t *raw;
|
|
||||||
int raw_size;
|
|
||||||
|
|
||||||
// first convert to raw RGBA
|
// first convert to raw RGBA
|
||||||
raw_size = sizeof(uint16_t) * width * height;
|
int raw_size = sizeof(uint16_t) * width * height;
|
||||||
raw = malloc(raw_size);
|
uint8_t *raw = malloc(raw_size);
|
||||||
if (!raw)
|
if (!raw)
|
||||||
{
|
{
|
||||||
ERROR("Error allocating %u bytes\n", raw_size);
|
ERROR("Error allocating %u bytes\n", raw_size);
|
||||||
@@ -239,11 +229,10 @@ int rgba2raw(uint8_t *raw, const rgba *img, int width, int height, int depth)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < width * height; i++)
|
for (int i = 0; i < width * height; i++)
|
||||||
{
|
{
|
||||||
uint8_t r, g, b, a;
|
uint8_t r = SCALE_8_5(img[i].red);
|
||||||
r = SCALE_8_5(img[i].red);
|
uint8_t g = SCALE_8_5(img[i].green);
|
||||||
g = SCALE_8_5(img[i].green);
|
uint8_t b = SCALE_8_5(img[i].blue);
|
||||||
b = SCALE_8_5(img[i].blue);
|
uint8_t a = img[i].alpha ? 0x1 : 0x0;
|
||||||
a = img[i].alpha ? 0x1 : 0x0;
|
|
||||||
raw[i * 2] = r << 3 | g >> 2;
|
raw[i * 2] = r << 3 | g >> 2;
|
||||||
raw[i * 2 + 1] = (g & 0x3) << 6 | b << 1 | a;
|
raw[i * 2 + 1] = (g & 0x3) << 6 | b << 1 | a;
|
||||||
}
|
}
|
||||||
@@ -438,7 +427,6 @@ rgba *png2rgba(const char *png_filename, int *width, int *height)
|
|||||||
int w = 0;
|
int w = 0;
|
||||||
int h = 0;
|
int h = 0;
|
||||||
int channels = 0;
|
int channels = 0;
|
||||||
int img_size;
|
|
||||||
|
|
||||||
stbi_uc *data = stbi_load(png_filename, &w, &h, &channels, STBI_default);
|
stbi_uc *data = stbi_load(png_filename, &w, &h, &channels, STBI_default);
|
||||||
if (!data || w <= 0 || h <= 0)
|
if (!data || w <= 0 || h <= 0)
|
||||||
@@ -448,7 +436,7 @@ rgba *png2rgba(const char *png_filename, int *width, int *height)
|
|||||||
}
|
}
|
||||||
INFO("Read \"%s\" %dx%d channels: %d\n", png_filename, w, h, channels);
|
INFO("Read \"%s\" %dx%d channels: %d\n", png_filename, w, h, channels);
|
||||||
|
|
||||||
img_size = w * h * sizeof(*img);
|
int img_size = w * h * sizeof(*img);
|
||||||
img = malloc(img_size);
|
img = malloc(img_size);
|
||||||
if (!img)
|
if (!img)
|
||||||
{
|
{
|
||||||
@@ -511,7 +499,6 @@ ia *png2ia(const char *png_filename, int *width, int *height)
|
|||||||
ia *img = NULL;
|
ia *img = NULL;
|
||||||
int w = 0, h = 0;
|
int w = 0, h = 0;
|
||||||
int channels = 0;
|
int channels = 0;
|
||||||
int img_size;
|
|
||||||
|
|
||||||
stbi_uc *data = stbi_load(png_filename, &w, &h, &channels, STBI_default);
|
stbi_uc *data = stbi_load(png_filename, &w, &h, &channels, STBI_default);
|
||||||
if (!data || w <= 0 || h <= 0)
|
if (!data || w <= 0 || h <= 0)
|
||||||
@@ -521,7 +508,7 @@ ia *png2ia(const char *png_filename, int *width, int *height)
|
|||||||
}
|
}
|
||||||
INFO("Read \"%s\" %dx%d channels: %d\n", png_filename, w, h, channels);
|
INFO("Read \"%s\" %dx%d channels: %d\n", png_filename, w, h, channels);
|
||||||
|
|
||||||
img_size = w * h * sizeof(*img);
|
int img_size = w * h * sizeof(*img);
|
||||||
img = malloc(img_size);
|
img = malloc(img_size);
|
||||||
if (!img)
|
if (!img)
|
||||||
{
|
{
|
||||||
@@ -595,8 +582,7 @@ static int pal_find_color(const palette_t *pal, uint16_t val)
|
|||||||
// returns palette index entered or -1 if palette full
|
// returns palette index entered or -1 if palette full
|
||||||
static int pal_add_color(palette_t *pal, uint16_t val)
|
static int pal_add_color(palette_t *pal, uint16_t val)
|
||||||
{
|
{
|
||||||
int idx;
|
int idx = pal_find_color(pal, val);
|
||||||
idx = pal_find_color(pal, val);
|
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
{
|
{
|
||||||
if (pal->used == pal->max)
|
if (pal->used == pal->max)
|
||||||
|
|||||||
+216
-329
File diff suppressed because it is too large
Load Diff
@@ -370,7 +370,6 @@ static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char
|
|||||||
static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d)
|
static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d)
|
||||||
{
|
{
|
||||||
unsigned char bg[3] = {255, 0, 255}, px[3];
|
unsigned char bg[3] = {255, 0, 255}, px[3];
|
||||||
int k;
|
|
||||||
|
|
||||||
if (write_alpha < 0)
|
if (write_alpha < 0)
|
||||||
s->func(s->context, &d[comp - 1], 1);
|
s->func(s->context, &d[comp - 1], 1);
|
||||||
@@ -388,7 +387,7 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in
|
|||||||
if (!write_alpha)
|
if (!write_alpha)
|
||||||
{
|
{
|
||||||
// composite against pink background
|
// composite against pink background
|
||||||
for (k = 0; k < 3; ++k)
|
for (int k = 0; k < 3; ++k)
|
||||||
px[k] = bg[k] + (d[k] - bg[k]) * d[3] / 255;
|
px[k] = bg[k] + (d[k] - bg[k]) * d[3] / 255;
|
||||||
stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]);
|
stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]);
|
||||||
break;
|
break;
|
||||||
@@ -405,7 +404,7 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in
|
|||||||
static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono)
|
static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono)
|
||||||
{
|
{
|
||||||
stbiw_uint32 zero = 0;
|
stbiw_uint32 zero = 0;
|
||||||
int i, j, j_end;
|
int j, j_end;
|
||||||
|
|
||||||
if (y <= 0)
|
if (y <= 0)
|
||||||
return;
|
return;
|
||||||
@@ -420,7 +419,7 @@ static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, i
|
|||||||
|
|
||||||
for (; j != j_end; j += vdir)
|
for (; j != j_end; j += vdir)
|
||||||
{
|
{
|
||||||
for (i = 0; i < x; ++i)
|
for (int i = 0; i < x; ++i)
|
||||||
{
|
{
|
||||||
unsigned char *d = (unsigned char *)data + (j * x + i) * comp;
|
unsigned char *d = (unsigned char *)data + (j * x + i) * comp;
|
||||||
stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d);
|
stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d);
|
||||||
@@ -493,7 +492,7 @@ static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, v
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int j, k;
|
||||||
int jend, jdir;
|
int jend, jdir;
|
||||||
|
|
||||||
stbiw__writef(s, "111 221 2222 11", 0, 0, format + 8, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);
|
stbiw__writef(s, "111 221 2222 11", 0, 0, format + 8, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);
|
||||||
@@ -515,7 +514,7 @@ static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, v
|
|||||||
unsigned char *row = (unsigned char *)data + j * x * comp;
|
unsigned char *row = (unsigned char *)data + j * x * comp;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
for (i = 0; i < x; i += len)
|
for (int i = 0; i < x; i += len)
|
||||||
{
|
{
|
||||||
unsigned char *begin = row + i * comp;
|
unsigned char *begin = row + i * comp;
|
||||||
int diff = 1;
|
int diff = 1;
|
||||||
@@ -676,7 +675,6 @@ void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, uns
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int c, r;
|
|
||||||
/* encode into scratch buffer */
|
/* encode into scratch buffer */
|
||||||
for (x = 0; x < width; x++)
|
for (x = 0; x < width; x++)
|
||||||
{
|
{
|
||||||
@@ -702,7 +700,7 @@ void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, uns
|
|||||||
s->func(s->context, scanlineheader, 4);
|
s->func(s->context, scanlineheader, 4);
|
||||||
|
|
||||||
/* RLE each component separately */
|
/* RLE each component separately */
|
||||||
for (c = 0; c < 4; c++)
|
for (int c = 0; c < 4; c++)
|
||||||
{
|
{
|
||||||
unsigned char *comp = &scratch[width * c];
|
unsigned char *comp = &scratch[width * c];
|
||||||
|
|
||||||
@@ -710,7 +708,7 @@ void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, uns
|
|||||||
while (x < width)
|
while (x < width)
|
||||||
{
|
{
|
||||||
// find first run
|
// find first run
|
||||||
r = x;
|
int r = x;
|
||||||
while (r + 2 < width)
|
while (r + 2 < width)
|
||||||
{
|
{
|
||||||
if (comp[r] == comp[r + 1] && comp[r] == comp[r + 2])
|
if (comp[r] == comp[r + 1] && comp[r] == comp[r + 2])
|
||||||
@@ -755,7 +753,7 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f
|
|||||||
{
|
{
|
||||||
// Each component is stored separately. Allocate scratch space for full output scanline.
|
// Each component is stored separately. Allocate scratch space for full output scanline.
|
||||||
unsigned char *scratch = STBIW_MALLOC(x * 4);
|
unsigned char *scratch = STBIW_MALLOC(x * 4);
|
||||||
int i, len;
|
int len;
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
|
char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
|
||||||
s->func(s->context, header, sizeof(header) - 1);
|
s->func(s->context, header, sizeof(header) - 1);
|
||||||
@@ -767,7 +765,7 @@ len= sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x
|
|||||||
#endif
|
#endif
|
||||||
s->func (s->context, buffer, len);
|
s->func (s->context, buffer, len);
|
||||||
|
|
||||||
for(i=0; i<y; i++)
|
for(int i = 0; i<y; i++)
|
||||||
stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp * x * (stbi__flip_vertically_on_write ? y - 1 - i : i) * x);
|
stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp * x * (stbi__flip_vertically_on_write ? y - 1 - i : i) * x);
|
||||||
STBIW_FREE (scratch);
|
STBIW_FREE (scratch);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1053,8 +1051,7 @@ static unsigned int stbiw__crc32(unsigned char *buffer, int len)
|
|||||||
};
|
};
|
||||||
|
|
||||||
unsigned int crc = ~0u;
|
unsigned int crc = ~0u;
|
||||||
int i;
|
for (int i = 0; i < len; ++i)
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
crc = crc >> 8 ^ crc_table[buffer[i] ^ crc & 0xff];
|
crc = crc >> 8 ^ crc_table[buffer[i] ^ crc & 0xff];
|
||||||
return ~crc;
|
return ~crc;
|
||||||
}
|
}
|
||||||
@@ -1148,9 +1145,7 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
|||||||
int force_filter = stbi_write_force_png_filter;
|
int force_filter = stbi_write_force_png_filter;
|
||||||
int ctype[5] = {-1, 0, 4, 2, 6};
|
int ctype[5] = {-1, 0, 4, 2, 6};
|
||||||
unsigned char sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
unsigned char sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||||
unsigned char *out, *o, *filt, *zlib;
|
int zlen;
|
||||||
signed char *line_buffer;
|
|
||||||
int j, zlen;
|
|
||||||
|
|
||||||
if (stride_bytes == 0)
|
if (stride_bytes == 0)
|
||||||
stride_bytes = x * n;
|
stride_bytes = x * n;
|
||||||
@@ -1160,15 +1155,15 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
|||||||
force_filter = -1;
|
force_filter = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
filt = (unsigned char *)STBIW_MALLOC((x * n + 1) * y);
|
unsigned char *filt = (unsigned char *)STBIW_MALLOC((x * n + 1) * y);
|
||||||
if (!filt) return 0;
|
if (!filt) return 0;
|
||||||
line_buffer = (signed char *)STBIW_MALLOC(x * n);
|
signed char *line_buffer = (signed char *)STBIW_MALLOC(x * n);
|
||||||
if (!line_buffer)
|
if (!line_buffer)
|
||||||
{
|
{
|
||||||
STBIW_FREE(filt);
|
STBIW_FREE(filt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (j = 0; j < y; ++j)
|
for (int j = 0; j < y; ++j)
|
||||||
{
|
{
|
||||||
int filter_type;
|
int filter_type;
|
||||||
if (force_filter > -1)
|
if (force_filter > -1)
|
||||||
@@ -1178,14 +1173,14 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Estimate the best filter by running through all of them:
|
{ // Estimate the best filter by running through all of them:
|
||||||
int best_filter = 0, best_filter_val = 0x7fffffff, est, i;
|
int best_filter = 0, best_filter_val = 0x7fffffff;
|
||||||
for (filter_type = 0; filter_type < 5; filter_type++)
|
for (filter_type = 0; filter_type < 5; filter_type++)
|
||||||
{
|
{
|
||||||
stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, filter_type, line_buffer);
|
stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, filter_type, line_buffer);
|
||||||
|
|
||||||
// Estimate the entropy of the line using this filter; the less, the better.
|
// Estimate the entropy of the line using this filter; the less, the better.
|
||||||
est = 0;
|
int est = 0;
|
||||||
for (i = 0; i < x * n; ++i)
|
for (int i = 0; i < x * n; ++i)
|
||||||
{
|
{
|
||||||
est += abs(line_buffer[i]);
|
est += abs(line_buffer[i]);
|
||||||
}
|
}
|
||||||
@@ -1206,16 +1201,16 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
|||||||
STBIW_MEMMOVE(filt + j * (x * n + 1) + 1, line_buffer, x * n);
|
STBIW_MEMMOVE(filt + j * (x * n + 1) + 1, line_buffer, x * n);
|
||||||
}
|
}
|
||||||
STBIW_FREE(line_buffer);
|
STBIW_FREE(line_buffer);
|
||||||
zlib = stbi_zlib_compress(filt, y * (x * n + 1), &zlen, stbi_write_png_compression_level);
|
unsigned char *zlib = stbi_zlib_compress(filt, y * (x * n + 1), &zlen, stbi_write_png_compression_level);
|
||||||
STBIW_FREE(filt);
|
STBIW_FREE(filt);
|
||||||
if (!zlib) return 0;
|
if (!zlib) return 0;
|
||||||
|
|
||||||
// each tag requires 12 bytes of overhead
|
// each tag requires 12 bytes of overhead
|
||||||
out = (unsigned char *)STBIW_MALLOC(8 + 12 + 13 + 12 + zlen + 12);
|
unsigned char *out = (unsigned char *)STBIW_MALLOC(8 + 12 + 13 + 12 + zlen + 12);
|
||||||
if (!out) return 0;
|
if (!out) return 0;
|
||||||
*out_len = 8 + 12 + 13 + 12 + zlen + 12;
|
*out_len = 8 + 12 + 13 + 12 + zlen + 12;
|
||||||
|
|
||||||
o = out;
|
unsigned char *o = out;
|
||||||
STBIW_MEMMOVE(o, sig, 8);
|
STBIW_MEMMOVE(o, sig, 8);
|
||||||
o += 8;
|
o += 8;
|
||||||
stbiw__wp32(o, 13); // header length
|
stbiw__wp32(o, 13); // header length
|
||||||
@@ -1313,7 +1308,6 @@ static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitC
|
|||||||
static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p)
|
static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p)
|
||||||
{
|
{
|
||||||
float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p;
|
float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p;
|
||||||
float z1, z2, z3, z4, z5, z11, z13;
|
|
||||||
|
|
||||||
float tmp0 = d0 + d7;
|
float tmp0 = d0 + d7;
|
||||||
float tmp7 = d0 - d7;
|
float tmp7 = d0 - d7;
|
||||||
@@ -1333,7 +1327,7 @@ static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float
|
|||||||
d0 = tmp10 + tmp11; // phase 3
|
d0 = tmp10 + tmp11; // phase 3
|
||||||
d4 = tmp10 - tmp11;
|
d4 = tmp10 - tmp11;
|
||||||
|
|
||||||
z1 = (tmp12 + tmp13) * 0.707106781f; // c4
|
float z1 = (tmp12 + tmp13) * 0.707106781f; // c4
|
||||||
d2 = tmp13 + z1; // phase 5
|
d2 = tmp13 + z1; // phase 5
|
||||||
d6 = tmp13 - z1;
|
d6 = tmp13 - z1;
|
||||||
|
|
||||||
@@ -1343,13 +1337,13 @@ static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float
|
|||||||
tmp12 = tmp6 + tmp7;
|
tmp12 = tmp6 + tmp7;
|
||||||
|
|
||||||
// The rotator is modified from fig 4-8 to avoid extra negations.
|
// The rotator is modified from fig 4-8 to avoid extra negations.
|
||||||
z5 = (tmp10 - tmp12) * 0.382683433f; // c6
|
float z5 = (tmp10 - tmp12) * 0.382683433f; // c6
|
||||||
z2 = tmp10 * 0.541196100f + z5; // c2-c6
|
float z2 = tmp10 * 0.541196100f + z5; // c2-c6
|
||||||
z4 = tmp12 * 1.306562965f + z5; // c2+c6
|
float z4 = tmp12 * 1.306562965f + z5; // c2+c6
|
||||||
z3 = tmp11 * 0.707106781f; // c4
|
float z3 = tmp11 * 0.707106781f; // c4
|
||||||
|
|
||||||
z11 = tmp7 + z3; // phase 5
|
float z11 = tmp7 + z3; // phase 5
|
||||||
z13 = tmp7 - z3;
|
float z13 = tmp7 - z3;
|
||||||
|
|
||||||
*d5p = z13 + z2; // phase 6
|
*d5p = z13 + z2; // phase 6
|
||||||
*d3p = z13 - z2;
|
*d3p = z13 - z2;
|
||||||
@@ -1378,7 +1372,7 @@ static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt
|
|||||||
{
|
{
|
||||||
const unsigned short EOB[2] = {HTAC[0x00][0], HTAC[0x00][1]};
|
const unsigned short EOB[2] = {HTAC[0x00][0], HTAC[0x00][1]};
|
||||||
const unsigned short M16zeroes[2] = {HTAC[0xF0][0], HTAC[0xF0][1]};
|
const unsigned short M16zeroes[2] = {HTAC[0xF0][0], HTAC[0xF0][1]};
|
||||||
int dataOff, i, diff, end0pos;
|
int dataOff, i;
|
||||||
int DU[64];
|
int DU[64];
|
||||||
|
|
||||||
// DCT rows
|
// DCT rows
|
||||||
@@ -1401,7 +1395,7 @@ static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Encode DC
|
// Encode DC
|
||||||
diff = DU[0] - DC;
|
int diff = DU[0] - DC;
|
||||||
if (diff == 0)
|
if (diff == 0)
|
||||||
{
|
{
|
||||||
stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]);
|
stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]);
|
||||||
@@ -1414,7 +1408,7 @@ static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt
|
|||||||
stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);
|
stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);
|
||||||
}
|
}
|
||||||
// Encode ACs
|
// Encode ACs
|
||||||
end0pos = 63;
|
int end0pos = 63;
|
||||||
for (; end0pos > 0 && DU[end0pos] == 0; --end0pos)
|
for (; end0pos > 0 && DU[end0pos] == 0; --end0pos)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1427,17 +1421,15 @@ static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt
|
|||||||
for (i = 1; i <= end0pos; ++i)
|
for (i = 1; i <= end0pos; ++i)
|
||||||
{
|
{
|
||||||
int startpos = i;
|
int startpos = i;
|
||||||
int nrzeroes;
|
|
||||||
unsigned short bits[2];
|
unsigned short bits[2];
|
||||||
for (; DU[i] == 0 && i <= end0pos; ++i)
|
for (; DU[i] == 0 && i <= end0pos; ++i)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
nrzeroes = i - startpos;
|
int nrzeroes = i - startpos;
|
||||||
if (nrzeroes >= 16)
|
if (nrzeroes >= 16)
|
||||||
{
|
{
|
||||||
int lng = nrzeroes >> 4;
|
int lng = nrzeroes >> 4;
|
||||||
int nrmarker;
|
for (int nrmarker = 1; nrmarker <= lng; ++nrmarker)
|
||||||
for (nrmarker = 1; nrmarker <= lng; ++nrmarker)
|
|
||||||
stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes);
|
stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes);
|
||||||
nrzeroes &= 15;
|
nrzeroes &= 15;
|
||||||
}
|
}
|
||||||
@@ -1531,7 +1523,7 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
|
|||||||
1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f
|
1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f
|
||||||
};
|
};
|
||||||
|
|
||||||
int row, col, i, k;
|
int row, col, k;
|
||||||
float fdtbl_Y[64], fdtbl_UV[64];
|
float fdtbl_Y[64], fdtbl_UV[64];
|
||||||
unsigned char YTable[64], UVTable[64];
|
unsigned char YTable[64], UVTable[64];
|
||||||
|
|
||||||
@@ -1544,11 +1536,11 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
|
|||||||
quality = quality < 1 ? 1 : quality > 100 ? 100 : quality;
|
quality = quality < 1 ? 1 : quality > 100 ? 100 : quality;
|
||||||
quality = quality < 50 ? 5000 / quality : 200 - quality * 2;
|
quality = quality < 50 ? 5000 / quality : 200 - quality * 2;
|
||||||
|
|
||||||
for (i = 0; i < 64; ++i)
|
for (int i = 0; i < 64; ++i)
|
||||||
{
|
{
|
||||||
int uvti, yti = (YQT[i] * quality + 50) / 100;
|
int yti = (YQT[i] * quality + 50) / 100;
|
||||||
YTable[stbiw__jpg_ZigZag[i]] = (unsigned char)(yti < 1 ? 1 : yti > 255 ? 255 : yti);
|
YTable[stbiw__jpg_ZigZag[i]] = (unsigned char)(yti < 1 ? 1 : yti > 255 ? 255 : yti);
|
||||||
uvti = (UVQT[i] * quality + 50) / 100;
|
int uvti = (UVQT[i] * quality + 50) / 100;
|
||||||
UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char)(uvti < 1 ? 1 : uvti > 255 ? 255 : uvti);
|
UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char)(uvti < 1 ? 1 : uvti > 255 ? 255 : uvti);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1596,10 +1588,10 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
|
|||||||
int bitBuf = 0, bitCnt = 0;
|
int bitBuf = 0, bitCnt = 0;
|
||||||
// comp == 2 is grey+alpha (alpha is ignored)
|
// comp == 2 is grey+alpha (alpha is ignored)
|
||||||
int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0;
|
int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0;
|
||||||
int x, y, pos;
|
int pos;
|
||||||
for (y = 0; y < height; y += 8)
|
for (int y = 0; y < height; y += 8)
|
||||||
{
|
{
|
||||||
for (x = 0; x < width; x += 8)
|
for (int x = 0; x < width; x += 8)
|
||||||
{
|
{
|
||||||
float YDU[64], UDU[64], VDU[64];
|
float YDU[64], UDU[64], VDU[64];
|
||||||
for (row = y, pos = 0; row < y + 8; ++row)
|
for (row = y, pos = 0; row < y + 8; ++row)
|
||||||
@@ -1607,7 +1599,6 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
|
|||||||
for (col = x; col < x + 8; ++col, ++pos)
|
for (col = x; col < x + 8; ++col, ++pos)
|
||||||
{
|
{
|
||||||
int p = (stbi__flip_vertically_on_write ? height - 1 - row : row) * width * comp + col * comp;
|
int p = (stbi__flip_vertically_on_write ? height - 1 - row : row) * width * comp + col * comp;
|
||||||
float r, g, b;
|
|
||||||
if (row >= height)
|
if (row >= height)
|
||||||
{
|
{
|
||||||
p -= width * comp * (row + 1 - height);
|
p -= width * comp * (row + 1 - height);
|
||||||
@@ -1617,9 +1608,9 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
|
|||||||
p -= comp * (col + 1 - width);
|
p -= comp * (col + 1 - width);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = imageData[p + 0];
|
float r = imageData[p + 0];
|
||||||
g = imageData[p + ofsG];
|
float g = imageData[p + ofsG];
|
||||||
b = imageData[p + ofsB];
|
float b = imageData[p + ofsB];
|
||||||
YDU[pos] = +0.29900f * r + 0.58700f * g + 0.11400f * b - 128;
|
YDU[pos] = +0.29900f * r + 0.58700f * g + 0.11400f * b - 128;
|
||||||
UDU[pos] = -0.16874f * r - 0.33126f * g + 0.50000f * b;
|
UDU[pos] = -0.16874f * r - 0.33126f * g + 0.50000f * b;
|
||||||
VDU[pos] = +0.50000f * r - 0.41869f * g - 0.08131f * b;
|
VDU[pos] = +0.50000f * r - 0.41869f * g - 0.08131f * b;
|
||||||
|
|||||||
+19
-38
@@ -55,8 +55,7 @@ int is_power2(unsigned int val)
|
|||||||
|
|
||||||
void fprint_hex(FILE *fp, const unsigned char *buf, int length)
|
void fprint_hex(FILE *fp, const unsigned char *buf, int length)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < length; i++)
|
||||||
for (i = 0; i < length; i++)
|
|
||||||
{
|
{
|
||||||
fprint_byte(fp, buf[i]);
|
fprint_byte(fp, buf[i]);
|
||||||
fputc(' ', fp);
|
fputc(' ', fp);
|
||||||
@@ -65,8 +64,7 @@ void fprint_hex(FILE *fp, const unsigned char *buf, int length)
|
|||||||
|
|
||||||
void fprint_hex_source(FILE *fp, const unsigned char *buf, int length)
|
void fprint_hex_source(FILE *fp, const unsigned char *buf, int length)
|
||||||
{
|
{
|
||||||
int i;
|
for (int i = 0; i < length; i++)
|
||||||
for (i = 0; i < length; i++)
|
|
||||||
{
|
{
|
||||||
if (i > 0) fputs(", ", fp);
|
if (i > 0) fputs(", ", fp);
|
||||||
fputs("0x", fp);
|
fputs("0x", fp);
|
||||||
@@ -81,11 +79,9 @@ void print_hex(const unsigned char *buf, int length)
|
|||||||
|
|
||||||
void swap_bytes(unsigned char *data, long length)
|
void swap_bytes(unsigned char *data, long length)
|
||||||
{
|
{
|
||||||
long i;
|
for (long i = 0; i < length; i += 2)
|
||||||
unsigned char tmp;
|
|
||||||
for (i = 0; i < length; i += 2)
|
|
||||||
{
|
{
|
||||||
tmp = data[i];
|
unsigned char tmp = data[i];
|
||||||
data[i] = data[i + 1];
|
data[i] = data[i + 1];
|
||||||
data[i + 1] = tmp;
|
data[i + 1] = tmp;
|
||||||
}
|
}
|
||||||
@@ -93,11 +89,9 @@ void swap_bytes(unsigned char *data, long length)
|
|||||||
|
|
||||||
void reverse_endian(unsigned char *data, long length)
|
void reverse_endian(unsigned char *data, long length)
|
||||||
{
|
{
|
||||||
long i;
|
for (long i = 0; i < length; i += 4)
|
||||||
unsigned char tmp;
|
|
||||||
for (i = 0; i < length; i += 4)
|
|
||||||
{
|
{
|
||||||
tmp = data[i];
|
unsigned char tmp = data[i];
|
||||||
data[i] = data[i + 3];
|
data[i] = data[i + 3];
|
||||||
data[i + 3] = tmp;
|
data[i + 3] = tmp;
|
||||||
tmp = data[i + 1];
|
tmp = data[i + 1];
|
||||||
@@ -120,9 +114,8 @@ long filesize(const char *filename)
|
|||||||
|
|
||||||
void touch_file(const char *filename)
|
void touch_file(const char *filename)
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
//fd = open(filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666);
|
//fd = open(filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666);
|
||||||
fd = open(filename, O_WRONLY | O_CREAT, 0666);
|
int fd = open(filename, O_WRONLY | O_CREAT, 0666);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
utime(filename, NULL);
|
utime(filename, NULL);
|
||||||
@@ -132,11 +125,8 @@ void touch_file(const char *filename)
|
|||||||
|
|
||||||
long read_file(const char *file_name, unsigned char **data)
|
long read_file(const char *file_name, unsigned char **data)
|
||||||
{
|
{
|
||||||
FILE *in;
|
|
||||||
unsigned char *in_buf = NULL;
|
unsigned char *in_buf = NULL;
|
||||||
long file_size;
|
FILE *in = fopen(file_name, "rb");
|
||||||
long bytes_read;
|
|
||||||
in = fopen(file_name, "rb");
|
|
||||||
if (in == NULL)
|
if (in == NULL)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
@@ -144,7 +134,7 @@ long read_file(const char *file_name, unsigned char **data)
|
|||||||
|
|
||||||
// allocate buffer to read from offset to end of file
|
// allocate buffer to read from offset to end of file
|
||||||
fseek(in, 0, SEEK_END);
|
fseek(in, 0, SEEK_END);
|
||||||
file_size = ftell(in);
|
long file_size = ftell(in);
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if (file_size > 256 * MB)
|
if (file_size > 256 * MB)
|
||||||
@@ -156,7 +146,7 @@ long read_file(const char *file_name, unsigned char **data)
|
|||||||
fseek(in, 0, SEEK_SET);
|
fseek(in, 0, SEEK_SET);
|
||||||
|
|
||||||
// read bytes
|
// read bytes
|
||||||
bytes_read = fread(in_buf, 1, file_size, in);
|
long bytes_read = fread(in_buf, 1, file_size, in);
|
||||||
if (bytes_read != file_size)
|
if (bytes_read != file_size)
|
||||||
{
|
{
|
||||||
return -3;
|
return -3;
|
||||||
@@ -169,16 +159,14 @@ long read_file(const char *file_name, unsigned char **data)
|
|||||||
|
|
||||||
long write_file(const char *file_name, unsigned char *data, long length)
|
long write_file(const char *file_name, unsigned char *data, long length)
|
||||||
{
|
{
|
||||||
FILE *out;
|
|
||||||
long bytes_written;
|
|
||||||
// open output file
|
// open output file
|
||||||
out = fopen(file_name, "wb");
|
FILE *out = fopen(file_name, "wb");
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
{
|
{
|
||||||
perror(file_name);
|
perror(file_name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
bytes_written = fwrite(data, 1, length, out);
|
long bytes_written = fwrite(data, 1, length, out);
|
||||||
fclose(out);
|
fclose(out);
|
||||||
return bytes_written;
|
return bytes_written;
|
||||||
}
|
}
|
||||||
@@ -186,10 +174,9 @@ long write_file(const char *file_name, unsigned char *data, long length)
|
|||||||
void generate_filename(const char *in_name, char *out_name, char *extension)
|
void generate_filename(const char *in_name, char *out_name, char *extension)
|
||||||
{
|
{
|
||||||
char tmp_name[FILENAME_MAX];
|
char tmp_name[FILENAME_MAX];
|
||||||
int len;
|
|
||||||
int i;
|
int i;
|
||||||
strcpy(tmp_name, in_name);
|
strcpy(tmp_name, in_name);
|
||||||
len = strlen(tmp_name);
|
int len = strlen(tmp_name);
|
||||||
for (i = len - 1; i > 0; i--)
|
for (i = len - 1; i > 0; i--)
|
||||||
{
|
{
|
||||||
if (tmp_name[i] == '.')
|
if (tmp_name[i] == '.')
|
||||||
@@ -230,14 +217,12 @@ void make_dir(const char *dir_name)
|
|||||||
long copy_file(const char *src_name, const char *dst_name)
|
long copy_file(const char *src_name, const char *dst_name)
|
||||||
{
|
{
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
long bytes_written;
|
|
||||||
long bytes_read;
|
|
||||||
|
|
||||||
bytes_read = read_file(src_name, &buf);
|
long bytes_read = read_file(src_name, &buf);
|
||||||
|
|
||||||
if (bytes_read > 0)
|
if (bytes_read > 0)
|
||||||
{
|
{
|
||||||
bytes_written = write_file(dst_name, buf, bytes_read);
|
long bytes_written = write_file(dst_name, buf, bytes_read);
|
||||||
if (bytes_written != bytes_read)
|
if (bytes_written != bytes_read)
|
||||||
{
|
{
|
||||||
bytes_read = -1;
|
bytes_read = -1;
|
||||||
@@ -250,23 +235,19 @@ long copy_file(const char *src_name, const char *dst_name)
|
|||||||
|
|
||||||
void dir_list_ext(const char *dir, const char *extension, dir_list *list)
|
void dir_list_ext(const char *dir, const char *extension, dir_list *list)
|
||||||
{
|
{
|
||||||
char *pool;
|
|
||||||
char *pool_ptr;
|
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
DIR *dfd;
|
|
||||||
int idx;
|
|
||||||
|
|
||||||
dfd = opendir(dir);
|
DIR *dfd = opendir(dir);
|
||||||
if (dfd == NULL)
|
if (dfd == NULL)
|
||||||
{
|
{
|
||||||
ERROR("Can't open '%s'\n", dir);
|
ERROR("Can't open '%s'\n", dir);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pool = malloc(FILENAME_MAX * MAX_DIR_FILES);
|
char *pool = malloc(FILENAME_MAX * MAX_DIR_FILES);
|
||||||
pool_ptr = pool;
|
char *pool_ptr = pool;
|
||||||
|
|
||||||
idx = 0;
|
int idx = 0;
|
||||||
while ((entry = readdir(dfd)) != NULL && idx < MAX_DIR_FILES)
|
while ((entry = readdir(dfd)) != NULL && idx < MAX_DIR_FILES)
|
||||||
{
|
{
|
||||||
if (!extension || str_ends_with(entry->d_name, extension))
|
if (!extension || str_ends_with(entry->d_name, extension))
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ struct SM64Surface
|
|||||||
int16_t type;
|
int16_t type;
|
||||||
int16_t force;
|
int16_t force;
|
||||||
uint16_t terrain;
|
uint16_t terrain;
|
||||||
|
int8_t flags;
|
||||||
float vertices[3][3]; // world-space coordinates
|
float vertices[3][3]; // world-space coordinates
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+26
-28
@@ -69,9 +69,9 @@ static void update_transform(struct SM64SurfaceObjectTransform *out, const struc
|
|||||||
* Returns whether a surface has exertion/moves Mario
|
* Returns whether a surface has exertion/moves Mario
|
||||||
* based on the surface type.
|
* based on the surface type.
|
||||||
*/
|
*/
|
||||||
static s32 surface_has_force(s16 surfaceType)
|
static bool surface_has_force(s16 surfaceType)
|
||||||
{
|
{
|
||||||
s32 hasForce = FALSE;
|
bool hasForce = false;
|
||||||
|
|
||||||
switch (surfaceType)
|
switch (surfaceType)
|
||||||
{
|
{
|
||||||
@@ -82,7 +82,7 @@ static s32 surface_has_force(s16 surfaceType)
|
|||||||
case SURFACE_MOVING_QUICKSAND:
|
case SURFACE_MOVING_QUICKSAND:
|
||||||
case SURFACE_HORIZONTAL_WIND:
|
case SURFACE_HORIZONTAL_WIND:
|
||||||
case SURFACE_INSTANT_MOVING_QUICKSAND:
|
case SURFACE_INSTANT_MOVING_QUICKSAND:
|
||||||
hasForce = TRUE;
|
hasForce = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -93,21 +93,17 @@ static s32 surface_has_force(s16 surfaceType)
|
|||||||
|
|
||||||
static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *surface, const struct SM64Surface *libSurf, struct SM64SurfaceObjectTransform *transform)
|
static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *surface, const struct SM64Surface *libSurf, struct SM64SurfaceObjectTransform *transform)
|
||||||
{
|
{
|
||||||
int16_t type = libSurf->type;
|
f32 x1 = libSurf->vertices[0][0]; // v1.x
|
||||||
int16_t force = libSurf->force;
|
f32 y1 = libSurf->vertices[0][1]; // v1.y
|
||||||
f32 x1 = libSurf->vertices[0][0];
|
f32 z1 = libSurf->vertices[0][2]; // v1.z
|
||||||
f32 y1 = libSurf->vertices[0][1];
|
|
||||||
f32 z1 = libSurf->vertices[0][2];
|
|
||||||
f32 x2 = libSurf->vertices[1][0];
|
|
||||||
f32 y2 = libSurf->vertices[1][1];
|
|
||||||
f32 z2 = libSurf->vertices[1][2];
|
|
||||||
f32 x3 = libSurf->vertices[2][0];
|
|
||||||
f32 y3 = libSurf->vertices[2][1];
|
|
||||||
f32 z3 = libSurf->vertices[2][2];
|
|
||||||
|
|
||||||
f32 maxY, minY;
|
f32 x2 = libSurf->vertices[1][0]; // v2.x
|
||||||
f32 nx, ny, nz;
|
f32 y2 = libSurf->vertices[1][1]; // v2.y
|
||||||
f32 mag;
|
f32 z2 = libSurf->vertices[1][2]; // v2.z
|
||||||
|
|
||||||
|
f32 x3 = libSurf->vertices[2][0]; // v3.x
|
||||||
|
f32 y3 = libSurf->vertices[2][1]; // v3.y
|
||||||
|
f32 z3 = libSurf->vertices[2][2]; // v3.z
|
||||||
|
|
||||||
if (transform != NULL)
|
if (transform != NULL)
|
||||||
{
|
{
|
||||||
@@ -127,9 +123,11 @@ static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *sur
|
|||||||
x1 = v1[0];
|
x1 = v1[0];
|
||||||
y1 = v1[1];
|
y1 = v1[1];
|
||||||
z1 = v1[2];
|
z1 = v1[2];
|
||||||
|
|
||||||
x2 = v2[0];
|
x2 = v2[0];
|
||||||
y2 = v2[1];
|
y2 = v2[1];
|
||||||
z2 = v2[2];
|
z2 = v2[2];
|
||||||
|
|
||||||
x3 = v3[0];
|
x3 = v3[0];
|
||||||
y3 = v3[1];
|
y3 = v3[1];
|
||||||
z3 = v3[2];
|
z3 = v3[2];
|
||||||
@@ -142,13 +140,13 @@ static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *sur
|
|||||||
}
|
}
|
||||||
|
|
||||||
// (v2 - v1) x (v3 - v2)
|
// (v2 - v1) x (v3 - v2)
|
||||||
nx = (y2 - y1) * (z3 - z2) - (z2 - z1) * (y3 - y2);
|
f32 nx = (y2 - y1) * (z3 - z2) - (z2 - z1) * (y3 - y2);
|
||||||
ny = (z2 - z1) * (x3 - x2) - (x2 - x1) * (z3 - z2);
|
f32 ny = (z2 - z1) * (x3 - x2) - (x2 - x1) * (z3 - z2);
|
||||||
nz = (x2 - x1) * (y3 - y2) - (y2 - y1) * (x3 - x2);
|
f32 nz = (x2 - x1) * (y3 - y2) - (y2 - y1) * (x3 - x2);
|
||||||
mag = sqrtf(nx * nx + ny * ny + nz * nz);
|
f32 mag = sqrtf(nx * nx + ny * ny + nz * nz);
|
||||||
|
|
||||||
// Could have used min_3 and max_3 for this...
|
// Could have used min_3 and max_3 for this...
|
||||||
minY = y1;
|
f32 minY = y1;
|
||||||
if (y2 < minY)
|
if (y2 < minY)
|
||||||
{
|
{
|
||||||
minY = y2;
|
minY = y2;
|
||||||
@@ -158,7 +156,7 @@ static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *sur
|
|||||||
minY = y3;
|
minY = y3;
|
||||||
}
|
}
|
||||||
|
|
||||||
maxY = y1;
|
f32 maxY = y1;
|
||||||
if (y2 > maxY)
|
if (y2 > maxY)
|
||||||
{
|
{
|
||||||
maxY = y2;
|
maxY = y2;
|
||||||
@@ -204,17 +202,17 @@ static void engine_surface_from_lib_surface(struct SM64SurfaceCollisionData *sur
|
|||||||
surface->lowerY = minY - 5;
|
surface->lowerY = minY - 5;
|
||||||
surface->upperY = maxY + 5;
|
surface->upperY = maxY + 5;
|
||||||
|
|
||||||
s16 hasForce = surface_has_force(type);
|
int16_t type = libSurf->type;
|
||||||
s16 flags = 0; // surf_has_no_cam_collision(type);
|
// s16 flags = 0; // surf_has_no_cam_collision(type);
|
||||||
|
|
||||||
surface->room = 0;
|
surface->room = 0;
|
||||||
surface->type = type;
|
surface->type = type;
|
||||||
surface->flags = (s8)flags;
|
surface->flags = libSurf->flags;
|
||||||
surface->terrain = libSurf->terrain;
|
surface->terrain = libSurf->terrain;
|
||||||
|
|
||||||
if (hasForce)
|
if (surface_has_force(type))
|
||||||
{
|
{
|
||||||
surface->force = force;
|
surface->force = libSurf->force;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-7
@@ -73,9 +73,7 @@ static float glm_vec3_norm(vec3 v)
|
|||||||
|
|
||||||
static void glm_vec3_normalize(vec3 v)
|
static void glm_vec3_normalize(vec3 v)
|
||||||
{
|
{
|
||||||
float norm;
|
float norm = glm_vec3_norm(v);
|
||||||
|
|
||||||
norm = glm_vec3_norm(v);
|
|
||||||
|
|
||||||
if (norm == 0.0f)
|
if (norm == 0.0f)
|
||||||
{
|
{
|
||||||
@@ -107,12 +105,10 @@ static void glm_perspective(
|
|||||||
float farVal,
|
float farVal,
|
||||||
mat4 dest)
|
mat4 dest)
|
||||||
{
|
{
|
||||||
float f, fn;
|
|
||||||
|
|
||||||
glm_mat4_zero(dest);
|
glm_mat4_zero(dest);
|
||||||
|
|
||||||
f = 1.0f / tanf(fovy * 0.5f);
|
float f = 1.0f / tanf(fovy * 0.5f);
|
||||||
fn = 1.0f / (nearVal - farVal);
|
float fn = 1.0f / (nearVal - farVal);
|
||||||
|
|
||||||
dest[0][0] = f / aspect;
|
dest[0][0] = f / aspect;
|
||||||
dest[1][1] = f;
|
dest[1][1] = f;
|
||||||
|
|||||||
@@ -238,7 +238,6 @@ static GLuint shader_compile(const char *shaderContents, size_t shaderContentsLe
|
|||||||
|
|
||||||
static GLuint shader_load(const char *shaderContents)
|
static GLuint shader_load(const char *shaderContents)
|
||||||
{
|
{
|
||||||
GLuint result;
|
|
||||||
GLuint vert = shader_compile(shaderContents, strlen(shaderContents), GL_VERTEX_SHADER);
|
GLuint vert = shader_compile(shaderContents, strlen(shaderContents), GL_VERTEX_SHADER);
|
||||||
GLuint frag = shader_compile(shaderContents, strlen(shaderContents), GL_FRAGMENT_SHADER);
|
GLuint frag = shader_compile(shaderContents, strlen(shaderContents), GL_FRAGMENT_SHADER);
|
||||||
|
|
||||||
@@ -249,7 +248,7 @@ static GLuint shader_load(const char *shaderContents)
|
|||||||
glLinkProgram(ref);
|
glLinkProgram(ref);
|
||||||
glDetachShader(ref, vert);
|
glDetachShader(ref, vert);
|
||||||
glDetachShader(ref, frag);
|
glDetachShader(ref, frag);
|
||||||
result = ref;
|
GLuint result = ref;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user