Refresh 14

This commit is contained in:
n64 committed 2021-07-12 23:17:54 -04:00
1 parent ecd3d152fb
commit f9982e0ef5
251 files changed
+7496 -5757

No files matched your search

-6
View File
@@ -877,12 +877,6 @@ u16 unk_sh_data_4[] = {
0x5FFF, 0x9001,
0x7FFF, 0x8001
};
char shindouDebugPrint1[] = "Terminate-Canceled Channel %d,Phase %d\n";
char shindouDebugPrint2[] = "S->W\n";
char shindouDebugPrint3[] = "W->S\n";
char shindouDebugPrint4[] = "S-Resample Pitch %x (old %d -> delay %d)\n";
// These debug prints are continued in shindou_debug_prints_1.c.
#endif
#ifndef VERSION_SH
+32 -22
View File
@@ -485,15 +485,9 @@ void unused_8031E4F0(void) {
stubbed_printf("\n");
stubbed_printf("BNK ");
#ifdef VERSION_SH
#define count 1
#else
#define count 4
#endif
for (i = 0; i < 40; i += count) {
for (i = 0; i < 40; i += 4) {
stubbed_printf("%1x", 0);
}
#undef count
stubbed_printf("\n");
stubbed_printf("FIXHEAP ");
@@ -1157,8 +1151,8 @@ static void select_current_sounds(u8 bank) {
}
/**
* Given an x and z coordinates, return the pan. This is a value between 0 and
* 1 that represents the audio direction.
* Given x and z coordinates, return the pan. This is a value nominally between
* 0 and 1 that represents the audio direction.
*
* Pan:
* 0.0 - fully left
@@ -1192,12 +1186,17 @@ static f32 get_sound_pan(f32 x, f32 z) {
pan = US_FLOAT(0.5);
} else if (x >= US_FLOAT(0.0) && absX >= absZ) {
// far right pan
pan = US_FLOAT(1.0) - (US_FLOAT(44000.0) - absX) / (US_FLOAT(3.0) * (US_FLOAT(44000.0) - absZ));
pan = US_FLOAT(1.0) - (2 * AUDIO_MAX_DISTANCE - absX) / (US_FLOAT(3.0) * (2 * AUDIO_MAX_DISTANCE - absZ));
} else if (x < 0 && absX > absZ) {
// far left pan
pan = (US_FLOAT(44000.0) - absX) / (US_FLOAT(3.0) * (US_FLOAT(44000.0) - absZ));
pan = (2 * AUDIO_MAX_DISTANCE - absX) / (US_FLOAT(3.0) * (2 * AUDIO_MAX_DISTANCE - absZ));
} else {
// center pan
//! @bug (JP PU sound glitch) If |x|, |z| > AUDIO_MAX_DISTANCE, we'll
// end up in this case, and pan may be set to something outside of [0,1]
// since x is not clamped. On JP, this can lead to an out-of-bounds
// float read in note_set_vel_pan_reverb when x is highly negative,
// causing console crashes when that float is a nan or denormal.
pan = 0.5 + x / (US_FLOAT(6.0) * absZ);
}
@@ -1243,6 +1242,8 @@ static f32 get_sound_volume(u8 bank, u8 soundIndex, f32 volumeRange) {
if (sSoundBanks[bank][soundIndex].soundBits & SOUND_VIBRATO) {
#ifdef VERSION_JP
//! @bug Intensity is 0 when the sound is far away. Due to the subtraction below, it is possible to end up with a negative intensity.
// When it is, objects with a volumeRange of 1 can still occasionally be lightly heard.
if (intensity != 0.0)
#else
if (intensity >= 0.08f)
@@ -1444,7 +1445,7 @@ static void update_game_sound(void) {
func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8),
get_sound_reverb(bank, soundIndex, channelIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb =
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverbVol =
get_sound_reverb(bank, soundIndex, channelIndex);
#endif
@@ -1485,7 +1486,7 @@ static void update_game_sound(void) {
*sSoundBanks[bank][soundIndex].z);
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->freqScale =
get_sound_freq_scale(bank, soundIndex);
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb =
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverbVol =
get_sound_reverb(bank, soundIndex, channelIndex);
#endif
break;
@@ -1508,7 +1509,7 @@ static void update_game_sound(void) {
func_802ad728(0x04020000 | ((channelIndex & 0xff) << 8),
get_sound_freq_scale(bank, soundIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb =
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverbVol =
get_sound_reverb(bank, soundIndex, channelIndex);
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume =
get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK2);
@@ -1524,6 +1525,13 @@ static void update_game_sound(void) {
#ifdef VERSION_JP
// If the sound was marked for deletion (bits set to NO_SOUND), then stop playing it
// and delete it
// @bug (JP double red coin sound) If the sound finished within the same frame as
// being marked for deletion, the signal to stop playing will be interpreted as a
// signal to *start* playing, as .main_loop_023589 in 00_sound_player does not check
// for soundScriptIO[0] being zero. This happens most commonly for red coin sounds
// whose sound spawners deactivate 30 frames after the sound starts to play, while
// the sound itself runs for 1.20 seconds. With enough lag these may coincide.
// Fixed on US by checking that layer0->finished is FALSE.
else if (soundStatus == SOUND_STATUS_STOPPED) {
update_background_music_after_sound(bank, soundIndex);
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[0] = 0;
@@ -1535,17 +1543,19 @@ static void update_game_sound(void) {
sSoundBanks[bank][soundIndex].soundStatus = SOUND_STATUS_STOPPED;
delete_sound_from_bank(bank, soundIndex);
} else if (soundStatus == SOUND_STATUS_STOPPED
&& gSequencePlayers[SEQ_PLAYER_SFX]
.channels[channelIndex]
->layers[0]
->finished
== FALSE) {
&& gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]
->layers[0]->finished == FALSE) {
update_background_music_after_sound(bank, soundIndex);
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[0] = 0;
delete_sound_from_bank(bank, soundIndex);
}
#endif
// If sound has finished playing, then delete it
// @bug (JP sound glitch) On JP, ...->layers[0] has not been checked for null,
// so this access can crash if an earlier layer allocation failed due to too
// many sounds playing at once. This crash is comparatively common; RTA
// speedrunners even have a setup for avoiding it within the SSL pyramid:
// https://www.youtube.com/watch?v=QetyTgbQxcw
else if (gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->layers[0]->enabled
== FALSE) {
update_background_music_after_sound(bank, soundIndex);
@@ -1619,7 +1629,7 @@ static void update_game_sound(void) {
func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8),
get_sound_reverb(bank, soundIndex, channelIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb =
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverbVol =
get_sound_reverb(bank, soundIndex, channelIndex);
#endif
@@ -1660,7 +1670,7 @@ static void update_game_sound(void) {
*sSoundBanks[bank][soundIndex].z);
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->freqScale =
get_sound_freq_scale(bank, soundIndex);
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb =
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverbVol =
get_sound_reverb(bank, soundIndex, channelIndex);
#endif
break;
@@ -1683,7 +1693,7 @@ static void update_game_sound(void) {
func_802ad728(0x04020000 | ((channelIndex & 0xff) << 8),
get_sound_freq_scale(bank, soundIndex));
#else
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverb =
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->reverbVol =
get_sound_reverb(bank, soundIndex, channelIndex);
gSequencePlayers[SEQ_PLAYER_SFX].channels[channelIndex]->volume =
get_sound_volume(bank, soundIndex, VOLUME_RANGE_UNK2);
-3
View File
@@ -27,9 +27,6 @@ extern u32 gAudioRandom;
extern u8 gAudioSPTaskYieldBuffer[]; // ucode yield data ptr; only used in JP
struct SPTask *create_next_audio_frame_task(void);
#ifdef VERSION_SH
struct SPTask *func_sh_802f5a80(void);
#endif
void play_sound(s32 soundBits, f32 *pos);
void audio_signal_game_loop_tick(void);
void seq_player_fade_out(u8 player, u16 fadeDuration);
+7 -9
View File
@@ -206,8 +206,6 @@ void discard_bank(s32 bankId) {
#if defined(VERSION_EU)
if (note->noteSubEu.bankId == bankId) {
#elif defined(VERSION_SH)
if (note->unkSH33 == bankId) {
#else
if (note->bankId == bankId) {
#endif
@@ -384,7 +382,7 @@ void temporary_pools_init(struct PoolSplit *a) {
#undef SOUND_ALLOC_FUNC
#if defined(VERSION_JP) || defined(VERSION_US)
static void unused_803163D4(void) {
UNUSED static void unused_803163D4(void) {
}
#endif
@@ -512,7 +510,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
if (poolIdx == 1) {
if (firstVal == SOUND_LOAD_STATUS_4) {
for (i = 0; i < gMaxSimultaneousNotes; i++) {
if (gNotes[i].unkSH33 == tp->entries[0].id && gNotes[i].noteSubEu.enabled) {
if (gNotes[i].bankId == tp->entries[0].id && gNotes[i].noteSubEu.enabled) {
break;
}
}
@@ -525,7 +523,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
}
if (secondVal == SOUND_LOAD_STATUS_4) {
for (i = 0; i < gMaxSimultaneousNotes; i++) {
if (gNotes[i].unkSH33 == tp->entries[1].id && gNotes[i].noteSubEu.enabled) {
if (gNotes[i].bankId == tp->entries[1].id && gNotes[i].noteSubEu.enabled) {
break;
}
}
@@ -591,7 +589,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
} else if (poolIdx == 1) {
if (firstVal == SOUND_LOAD_STATUS_COMPLETE) {
for (i = 0; i < gMaxSimultaneousNotes; i++) {
if (gNotes[i].unkSH33 == tp->entries[0].id && gNotes[i].noteSubEu.enabled) {
if (gNotes[i].bankId == tp->entries[0].id && gNotes[i].noteSubEu.enabled) {
break;
}
}
@@ -602,7 +600,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
}
if (secondVal == SOUND_LOAD_STATUS_COMPLETE) {
for (i = 0; i < gMaxSimultaneousNotes; i++) {
if (gNotes[i].unkSH33 == tp->entries[1].id && gNotes[i].noteSubEu.enabled) {
if (gNotes[i].bankId == tp->entries[1].id && gNotes[i].noteSubEu.enabled) {
break;
}
}
@@ -1681,7 +1679,7 @@ void func_sh_802f23ec(void) {
s32 i;
s32 idx;
s32 seqCount;
u32 bankId1; // non symmetric fake match? can also change 0xff to 0xffU for same effect
s32 bankId1;
s32 bankId2;
s32 instId;
s32 drumId;
@@ -1694,7 +1692,7 @@ void func_sh_802f23ec(void) {
for (idx = 0; idx < seqCount; idx++) {
bankId1 = gCtlEntries[idx].bankId1;
bankId2 = gCtlEntries[idx].bankId2;
if ((bankId1 != 0xff && entry->bankId == bankId1) || (bankId2 != 0xff && entry->bankId == bankId2) || entry->bankId == 0) {
if ((bankId1 != 0xffu && entry->bankId == bankId1) || (bankId2 != 0xff && entry->bankId == bankId2) || entry->bankId == 0) {
if (get_bank_or_seq(1, 3, idx) != NULL) {
if (IS_BANK_LOAD_COMPLETE(idx) != FALSE) {
for (i = 0; i < gUnkPool2.numEntries; i++) {
+2
View File
@@ -131,12 +131,14 @@ void audio_reset_session(void);
#else
void audio_reset_session(struct AudioSessionSettings *preset);
#endif
void discard_bank(s32 bankId);
#ifdef VERSION_SH
void fill_filter(s16 filter[8], s32 arg1, s32 arg2);
u8 *func_sh_802f1d40(u32 size, s32 bank, u8 *arg2, s8 medium);
u8 *func_sh_802f1d90(u32 size, s32 bank, u8 *arg2, s8 medium);
void *unk_pool1_lookup(s32 poolIdx, s32 id);
void *unk_pool1_alloc(s32 poolIndex, s32 arg1, u32 size);
#endif
#endif // AUDIO_HEAP_H
+29 -20
View File
@@ -41,6 +41,11 @@
#define TATUMS_PER_BEAT 48
// abi.h contains more details about the ADPCM and S8 codecs, "skip" skips codec processing
#define CODEC_ADPCM 0
#define CODEC_S8 1
#define CODEC_SKIP 2
#ifdef VERSION_JP
#define TEMPO_SCALE 1
#else
@@ -373,8 +378,8 @@ union ReverbBits {
/* 0x00 */ u8 asByte;
};
struct ReverbInfo {
u8 reverb;
u8 bankId;
u8 reverbVol;
u8 synthesisVolume; // UQ4.4, although 0 <= x < 1 is rounded up to 1
u8 pan;
union ReverbBits reverbBits;
f32 freqScale;
@@ -385,9 +390,9 @@ struct ReverbInfo {
struct NoteAttributes
{
u8 reverb;
u8 reverbVol;
#ifdef VERSION_SH
u8 unk1;
u8 synthesisVolume; // UQ4.4, although 0 <= x < 1 is rounded up to 1
#endif
#if defined(VERSION_EU) || defined(VERSION_SH)
u8 pan;
@@ -430,7 +435,7 @@ struct SequenceChannel
#endif
/*0x01, 0x02*/ u8 noteAllocPolicy;
/*0x02, 0x03, 0x03*/ u8 muteBehavior;
/*0x03, 0x04, 0x04*/ u8 reverb; // or dry/wet mix
/*0x03, 0x04, 0x04*/ u8 reverbVol; // until EU: Q1.7, after EU: UQ0.8
/*0x04, ????*/ u8 notePriority; // 0-3
#ifdef VERSION_SH
u8 unkSH06; // some priority
@@ -445,7 +450,7 @@ struct SequenceChannel
/*0x06, */ u8 updatesPerFrameUnused;
#endif
#ifdef VERSION_SH
/* 0x0C*/ u8 unkSH0C; // bankId
/* 0x0C*/ u8 synthesisVolume; // UQ4.4, although 0 <= x < 1 is rounded up to 1
#endif
/*0x08, 0x0C, 0x0E*/ u16 vibratoRateStart; // initially 0x800
/*0x0A, 0x0E, 0x10*/ u16 vibratoExtentStart;
@@ -521,7 +526,7 @@ struct SequenceChannelLayer
// 0..0x3f; this makes 0x40..0x7f accessible as well)
/*0x20, 0x24, 0x24*/ f32 freqScale;
#ifdef VERSION_SH
/* 0x28*/ f32 unkSH28;
/* 0x28*/ f32 freqScaleMultiplier;
#endif
/*0x24, 0x28, 0x2C*/ f32 velocitySquare;
#if defined(VERSION_JP) || defined(VERSION_US)
@@ -562,8 +567,8 @@ struct NoteSynthesisState
/*0x04, 0x06*/ u16 samplePosFrac;
/*0x08*/ s32 samplePosInt;
/*0x0C*/ struct NoteSynthesisBuffers *synthesisBuffers;
/*0x10*/ s16 curVolLeft;
/*0x12*/ s16 curVolRight;
/*0x10*/ s16 curVolLeft; // UQ0.16 (EU Q1.15)
/*0x12*/ s16 curVolRight; // UQ0.16 (EU Q1.15)
};
struct NotePlaybackState
{
@@ -572,7 +577,7 @@ struct NotePlaybackState
/* 0x01, 0x01*/ u8 waveId;
/* 0x02, 0x02*/ u8 sampleCountIndex;
#ifdef VERSION_SH
/* 0x03*/ u8 unkSH33; // bankId?
/* 0x03*/ u8 bankId;
/* 0x04*/ u8 unkSH34;
#endif
/*0x08, 0x04, 0x06*/ s16 adsrVolScale;
@@ -600,12 +605,16 @@ struct NoteSubEu
/*0x01*/ u8 bookOffset : 3;
/*0x01*/ u8 isSyntheticWave : 1;
/*0x01*/ u8 hasTwoAdpcmParts : 1;
#ifdef VERSION_EU
/*0x02*/ u8 bankId;
#else
/*0x02*/ u8 synthesisVolume; // UQ4.4, although 0 <= x < 1 is rounded up to 1
#endif
/*0x03*/ u8 headsetPanRight;
/*0x04*/ u8 headsetPanLeft;
/*0x05*/ u8 reverbVol;
/*0x06*/ u16 targetVolLeft;
/*0x08*/ u16 targetVolRight;
/*0x05*/ u8 reverbVol; // UQ0.7 (EU Q1.7)
/*0x06*/ u16 targetVolLeft; // UQ0.12 (EU UQ0.10)
/*0x08*/ u16 targetVolRight; // UQ0.12 (EU UQ0.10)
/*0x0A*/ u16 resamplingRateFixedPoint; // stored as signed but loaded as u16
/*0x0C*/ union {
s16 *samples;
@@ -633,7 +642,7 @@ struct Note
/* 0x31, 0x31*/ u8 waveId;
/* 0x32, 0x32*/ u8 sampleCountIndex;
#ifdef VERSION_SH
/* 0x33*/ u8 unkSH33; // bankId?
/* 0x33*/ u8 bankId;
/* 0x34*/ u8 unkSH34;
#endif
/*0x08, 0x34, 0x36*/ s16 adsrVolScale;
@@ -691,17 +700,17 @@ struct Note
/*0x30, 0x48*/ struct SequenceChannelLayer *wantedParentLayer;
/*0x34*/ struct NoteSynthesisBuffers *synthesisBuffers;
/*0x38*/ f32 frequency;
/*0x3C*/ u16 targetVolLeft;
/*0x3E*/ u16 targetVolRight;
/*0x40*/ u8 reverb;
/*0x3C*/ u16 targetVolLeft; // Q1.15, but will always be non-negative
/*0x3E*/ u16 targetVolRight; // Q1.15, but will always be non-negative
/*0x40*/ u8 reverbVol; // Q1.7
/*0x41*/ u8 unused1; // never read, set to 0x3f
/*0x44*/ struct NoteAttributes attributes;
/*0x54, 0x58*/ struct AdsrState adsr;
/*0x74, 0x7C*/ struct Portamento portamento;
/*0x84, 0x8C*/ struct VibratoState vibratoState;
/*0x9C*/ s16 curVolLeft;
/*0x9E*/ s16 curVolRight;
/*0xA0*/ s16 reverbVol;
/*0x9C*/ s16 curVolLeft; // Q1.15, but will always be non-negative
/*0x9E*/ s16 curVolRight; // Q1.15, but will always be non-negative
/*0xA0*/ s16 reverbVolShifted; // Q1.15
/*0xA2*/ s16 unused2; // never read, set to 0
/*0xA4, 0x00*/ struct AudioListItem listItem;
/* */ u8 pad2[0xc];
+41 -1485
View File
File diff suppressed because it is too large. Load diff
+12 -5
View File
@@ -89,18 +89,25 @@ void patch_audio_bank(s32 bankId, struct AudioBank *mem, struct PatchStruct *pat
#else
void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32 numDrums);
#endif
#ifndef VERSION_SH
#ifdef VERSION_SH
void preload_sequence(u32 seqId, s32 preloadMask);
#else
void preload_sequence(u32 seqId, u8 preloadMask);
#endif
void load_sequence(u32 player, u32 seqId, s32 loadAsync);
#ifdef VERSION_SH
void func_sh_802f3158(s32 index, s32 arg1, s32 arg2, OSMesgQueue *retQueue);
u8 *func_sh_802f3220(u32 index, u32 *a1);
void func_sh_802f3158(s32 seqId, s32 arg1, s32 arg2, OSMesgQueue *retQueue);
u8 *func_sh_802f3220(u32 seqId, u32 *a1);
struct AudioBankSample *func_sh_802f4978(s32 bankId, s32 idx);
void *func_802f3f08(s32 poolIdx, s32 arg1, s32 arg2, s32 arg3, OSMesgQueue *retQueue);
s32 func_sh_802f3368(s32 arg0);
s32 func_sh_802f47c8(s32 bankId, u8 idx, s8 *io);
void *func_sh_802f3f08(s32 poolIdx, s32 arg1, s32 arg2, s32 arg3, OSMesgQueue *retQueue);
void func_sh_802f41e4(s32 audioResetStatus);
BAD_RETURN(s32) func_sh_802f3368(s32 bankId);
void *func_sh_802f3764(s32 arg0, s32 idx, s32 *arg2);
s32 func_sh_802f3024(s32 bankId, s32 instId, s32 arg2);
void func_sh_802f30f4(s32 arg0, s32 arg1, s32 arg2, OSMesgQueue *arg3);
void func_sh_802f3288(s32 idx);
#endif
+1640
View File
File diff suppressed because it is too large. Load diff
+26 -25
View File
@@ -15,7 +15,7 @@ void note_set_resampling_rate(struct Note *note, f32 resamplingRateInput);
#ifdef VERSION_SH
void note_set_vel_pan_reverb(struct Note *note, struct ReverbInfo *reverbInfo)
#else
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverb)
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverbVol)
#endif
{
struct NoteSubEu *sub = &note->noteSubEu;
@@ -30,7 +30,7 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverb)
UNUSED u32 pad1;
f32 velocity;
u8 pan;
u8 reverb;
u8 reverbVol;
struct ReverbBitsData reverbBits;
#endif
@@ -38,7 +38,7 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverb)
note_set_resampling_rate(note, reverbInfo->freqScale);
velocity = reverbInfo->velocity;
pan = reverbInfo->pan;
reverb = reverbInfo->reverb;
reverbVol = reverbInfo->reverbVol;
reverbBits = reverbInfo->reverbBits.s;
pan &= 0x7f;
#else
@@ -119,7 +119,7 @@ void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverb)
}
#ifdef VERSION_SH
if (velocity < 0.0f) {
if (velocity < 0.0f) {
velocity = 0.0f;
}
if (velocity > 1.0f) {
@@ -128,7 +128,7 @@ if (velocity < 0.0f) {
sub->targetVolLeft = ((s32) (velocity * volLeft * 4095.999f));
sub->targetVolRight = ((s32) (velocity * volRight * 4095.999f));
sub->bankId = reverbInfo->bankId;
sub->synthesisVolume = reverbInfo->synthesisVolume;
sub->filter = reverbInfo->filter;
#else
if (velocity < 0.0f) {
@@ -144,11 +144,12 @@ if (velocity < 0.0f) {
sub->targetVolRight = ((s32) (velocity * volRight) & 0xffff) >> 5;
#endif
if (sub->reverbVol != reverb) {
//! @bug for the change to UQ0.7, the if statement should also have been changed accordingly
if (sub->reverbVol != reverbVol) {
#ifdef VERSION_SH
sub->reverbVol = reverb >> 1;
sub->reverbVol = reverbVol >> 1;
#else
sub->reverbVol = reverb;
sub->reverbVol = reverbVol;
#endif
sub->envMixerNeedsInit = TRUE;
return;
@@ -345,7 +346,7 @@ void process_notes(void) {
#ifndef VERSION_SH
f32 frequency;
#if defined(VERSION_JP) || defined(VERSION_US)
u8 reverb;
u8 reverbVol;
#endif
f32 velocity;
#if defined(VERSION_JP) || defined(VERSION_US)
@@ -359,11 +360,11 @@ void process_notes(void) {
struct NoteSubEu *noteSubEu;
#ifndef VERSION_SH
UNUSED u8 pad[12];
u8 reverb;
u8 reverbVol;
UNUSED u8 pad3;
u8 pan;
#else
u8 pad[8];
UNUSED u8 pad[8];
struct ReverbInfo reverbInfo;
#endif
u8 bookOffset;
@@ -508,9 +509,9 @@ void process_notes(void) {
reverbInfo.freqScale = attributes->freqScale;
reverbInfo.velocity = attributes->velocity;
reverbInfo.pan = attributes->pan;
reverbInfo.reverb = attributes->reverb;
reverbInfo.reverbVol = attributes->reverbVol;
reverbInfo.reverbBits = attributes->reverbBits;
reverbInfo.bankId = attributes->unk1;
reverbInfo.synthesisVolume = attributes->synthesisVolume;
reverbInfo.filter = attributes->filter;
bookOffset = noteSubEu->bookOffset;
} else {
@@ -518,8 +519,8 @@ void process_notes(void) {
reverbInfo.velocity = playbackState->parentLayer->noteVelocity;
reverbInfo.pan = playbackState->parentLayer->notePan;
reverbInfo.reverbBits = playbackState->parentLayer->reverbBits;
reverbInfo.reverb = playbackState->parentLayer->seqChannel->reverb;
reverbInfo.bankId = playbackState->parentLayer->seqChannel->unkSH0C;
reverbInfo.reverbVol = playbackState->parentLayer->seqChannel->reverbVol;
reverbInfo.synthesisVolume = playbackState->parentLayer->seqChannel->synthesisVolume;
reverbInfo.filter = playbackState->parentLayer->seqChannel->filter;
bookOffset = playbackState->parentLayer->seqChannel->bookOffset & 0x7;
if (playbackState->parentLayer->seqChannel->seqPlayer->muted
@@ -538,7 +539,7 @@ void process_notes(void) {
frequency = attributes->freqScale;
velocity = attributes->velocity;
pan = attributes->pan;
reverb = attributes->reverb;
reverbVol = attributes->reverbVol;
if (1) {
}
bookOffset = noteSubEu->bookOffset;
@@ -546,7 +547,7 @@ void process_notes(void) {
frequency = playbackState->parentLayer->noteFreqScale;
velocity = playbackState->parentLayer->noteVelocity;
pan = playbackState->parentLayer->notePan;
reverb = playbackState->parentLayer->seqChannel->reverb;
reverbVol = playbackState->parentLayer->seqChannel->reverbVol;
bookOffset = playbackState->parentLayer->seqChannel->bookOffset & 0x7;
}
@@ -554,7 +555,7 @@ void process_notes(void) {
frequency *= gAudioBufferParameters.resampleRate;
velocity = velocity * scale * scale;
note_set_resampling_rate(note, frequency);
note_set_vel_pan_reverb(note, velocity, pan, reverb);
note_set_vel_pan_reverb(note, velocity, pan, reverbVol);
#endif
noteSubEu->bookOffset = bookOffset;
skip:;
@@ -603,12 +604,12 @@ void process_notes(void) {
frequency = attributes->freqScale;
velocity = attributes->velocity;
pan = attributes->pan;
reverb = attributes->reverb;
reverbVol = attributes->reverbVol;
} else {
frequency = note->parentLayer->noteFreqScale;
velocity = note->parentLayer->noteVelocity;
pan = note->parentLayer->notePan;
reverb = note->parentLayer->seqChannel->reverb;
reverbVol = note->parentLayer->seqChannel->reverbVol;
}
scale = note->adsrVolScale;
@@ -621,7 +622,7 @@ void process_notes(void) {
scale *= 4.3498e-5f; // ~1 / 23000
velocity = velocity * scale * scale;
note_set_frequency(note, frequency);
note_set_vel_pan_reverb(note, velocity, pan, reverb);
note_set_vel_pan_reverb(note, velocity, pan, reverbVol);
continue;
}
#endif
@@ -746,9 +747,9 @@ void seq_channel_layer_decay_release_internal(struct SequenceChannelLayer *seqLa
attributes->reverbBits = seqLayer->reverbBits;
#endif
if (seqLayer->seqChannel != NULL) {
attributes->reverb = seqLayer->seqChannel->reverb;
attributes->reverbVol = seqLayer->seqChannel->reverbVol;
#ifdef VERSION_SH
attributes->unk1 = seqLayer->seqChannel->unkSH0C;
attributes->synthesisVolume = seqLayer->seqChannel->synthesisVolume;
attributes->filter = seqLayer->seqChannel->filter;
if (seqLayer->seqChannel->seqPlayer->muted && (seqLayer->seqChannel->muteBehavior & 8) != 0) {
note->noteSubEu.finished = TRUE;
@@ -1159,7 +1160,7 @@ void note_init_for_layer(struct Note *note, struct SequenceChannelLayer *seqLaye
build_synthetic_wave(note, seqLayer, instId);
}
#ifdef VERSION_SH
note->unkSH33 = seqLayer->seqChannel->bankId;
note->bankId = seqLayer->seqChannel->bankId;
#else
sub->bankId = seqLayer->seqChannel->bankId;
#endif
@@ -1444,7 +1445,7 @@ void note_init_all(void) {
#if defined(VERSION_EU) || defined(VERSION_SH)
note->waveId = 0;
#else
note->reverb = 0;
note->reverbVol = 0;
note->usesHeadsetPanEffects = FALSE;
note->sampleCount = 0;
note->instOrWave = 0;
+1 -1
View File
@@ -33,7 +33,7 @@ void note_init_all(void);
#if defined(VERSION_SH)
void note_set_vel_pan_reverb(struct Note *note, struct ReverbInfo *reverbInfo);
#elif defined(VERSION_EU)
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverb);
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, u8 pan, u8 reverbVol);
#endif
#if defined(VERSION_EU) || defined(VERSION_SH)
+1 -2
View File
@@ -29,7 +29,6 @@ extern struct EuAudioCmd sAudioCmd[0x100];
void func_8031D690(s32 player, FadeT fadeInTime);
void seq_player_fade_to_zero_volume(s32 player, FadeT fadeOutTime);
void port_eu_init_queues(void);
void decrease_sample_dma_ttls(void);
s32 audio_shut_down_and_reset_step(void);
void func_802ad7ec(u32);
@@ -300,7 +299,7 @@ void func_802ad7ec(u32 arg0) {
chan->changes.as_bitfields.freqScale = TRUE;
break;
case 5:
chan->reverb = cmd->u2.as_s8;
chan->reverbVol = cmd->u2.as_s8;
break;
case 6:
if (cmd->u.s.arg3 < 8) {
@@ -1,4 +1,5 @@
#ifdef VERSION_SH
// TODO: merge this with port_eu.c?
#include <ultra64.h>
@@ -7,6 +8,7 @@
#include "load.h"
#include "synthesis.h"
#include "internal.h"
#include "seqplayer.h"
#define EXTRA_BUFFERED_AI_SAMPLES_TARGET 0x80
#define SAMPLES_TO_OVERPRODUCE 0x10
@@ -15,12 +17,13 @@ extern s32 D_SH_80314FC8;
extern struct SPTask *D_SH_80314FCC;
extern u8 D_SH_80315098;
extern u8 D_SH_8031509C;
extern OSMesgQueue *D_SH_80350F68;
void func_sh_802f62e0(s32 playerIndex, s32 numFrames);
void func_sh_802f6288(s32 arg0, s32 numFrames);
void func_sh_802f6554(u32 arg0);
void func_8031D690(s32 playerIndex, s32 numFrames);
void seq_player_fade_to_zero_volume(s32 arg0, s32 numFrames);
void func_802ad7ec(u32 arg0);
struct SPTask *func_sh_802f5a80(void) {
struct SPTask *create_next_audio_frame_task(void) {
u32 samplesRemainingInAI;
s32 writtenCmds;
s32 index;
@@ -59,7 +62,7 @@ struct SPTask *func_sh_802f5a80(void) {
gCurrAudioFrameDmaCount = 0;
decrease_sample_dma_ttls();
func_802f41e4(gAudioResetStatus);
func_sh_802f41e4(gAudioResetStatus);
if (osRecvMesg(D_SH_80350F88, (OSMesg *) &sp38, OS_MESG_NOBLOCK) != -1) {
if (gAudioResetStatus == 0) {
gAudioResetStatus = 5;
@@ -99,7 +102,7 @@ struct SPTask *func_sh_802f5a80(void) {
if (osRecvMesg(D_SH_80350F68, (OSMesg *) &sp34, 0) != -1) {
do {
func_sh_802f6554(sp34);
func_802ad7ec(sp34);
} while (osRecvMesg(D_SH_80350F68, (OSMesg *) &sp34, 0) != -1);
}
@@ -143,7 +146,7 @@ struct SPTask *func_sh_802f5a80(void) {
}
}
void func_sh_802f5fb8(struct EuAudioCmd *cmd) {
void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
s32 i;
struct Note *note;
struct NoteSubEu *sub;
@@ -155,8 +158,8 @@ void func_sh_802f5fb8(struct EuAudioCmd *cmd) {
case 0x82:
case 0x88:
func_sh_802F3410(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3);
func_sh_802f62e0(cmd->u.s.arg1, cmd->u2.as_s32);
load_sequence(cmd->u.s.arg1, cmd->u.s.arg2, cmd->u.s.arg3);
func_8031D690(cmd->u.s.arg1, cmd->u2.as_s32);
break;
case 0x83:
@@ -165,7 +168,7 @@ void func_sh_802f5fb8(struct EuAudioCmd *cmd) {
sequence_player_disable(&gSequencePlayers[cmd->u.s.arg1]);
}
else {
func_sh_802f6288(cmd->u.s.arg1, cmd->u2.as_s32);
seq_player_fade_to_zero_volume(cmd->u.s.arg1, cmd->u2.as_s32);
}
}
break;
@@ -220,32 +223,32 @@ void func_sh_802f5fb8(struct EuAudioCmd *cmd) {
}
}
void func_sh_802f6288(s32 arg0, s32 numFrames) {
void seq_player_fade_to_zero_volume(s32 arg0, s32 fadeOutTime) {
struct SequencePlayer *player;
if (numFrames == 0) {
numFrames = 1;
if (fadeOutTime == 0) {
fadeOutTime = 1;
}
player = &gSequencePlayers[arg0];
player->state = 2;
player->fadeRemainingFrames = numFrames;
player->fadeVelocity = -(player->fadeVolume / (f32) numFrames);
player->fadeRemainingFrames = fadeOutTime;
player->fadeVelocity = -(player->fadeVolume / (f32) fadeOutTime);
}
void func_sh_802f62e0(s32 playerIndex, s32 numFrames) {
void func_8031D690(s32 playerIndex, s32 fadeInTime) {
struct SequencePlayer *player;
if (numFrames != 0) {
if (fadeInTime != 0) {
player = &gSequencePlayers[playerIndex];
player->state = 1;
player->fadeTimerUnkEu = numFrames;
player->fadeRemainingFrames = numFrames;
player->fadeTimerUnkEu = fadeInTime;
player->fadeRemainingFrames = fadeInTime;
player->fadeVolume = 0.0f;
player->fadeVelocity = 0.0f;
}
}
void func_sh_802f6330(void) {
void port_eu_init_queues(void) {
D_SH_80350F18 = 0;
D_SH_80350F19 = 0;
D_SH_80350F38 = &D_SH_80350F20;
@@ -258,8 +261,8 @@ void func_sh_802f6330(void) {
osCreateMesgQueue(D_SH_80350FA8, D_SH_80350F8C, 1);
}
extern struct EuAudioCmd sAudioCmd[0x100]; // sAudioCmd, maybe?
void func_802ad6f0(s32 arg0, s32 *arg1) { // func_sh_802f63f8
extern struct EuAudioCmd sAudioCmd[0x100];
void func_802ad6f0(s32 arg0, s32 *arg1) {
struct EuAudioCmd *cmd = &sAudioCmd[D_SH_80350F18 & 0xff];
cmd->u.first = arg0;
cmd->u2.as_u32 = *arg1;
@@ -269,34 +272,30 @@ void func_802ad6f0(s32 arg0, s32 *arg1) { // func_sh_802f63f8
}
}
void func_802ad728(u32 arg0, f32 arg1) { // func_sh_802f6450
void func_802ad728(u32 arg0, f32 arg1) {
func_802ad6f0(arg0, (s32 *) &arg1);
}
void func_802ad74c(u32 arg0, u32 arg1) { // func_sh_802f6474
void func_802ad74c(u32 arg0, u32 arg1) {
func_802ad6f0(arg0, (s32 *) &arg1);
}
void func_802ad770(u32 arg0, s8 arg1) { // func_sh_802f6498
void func_802ad770(u32 arg0, s8 arg1) {
s32 sp1C = arg1 << 24;
func_802ad6f0(arg0, &sp1C);
}
char shindouDebugPrint133[] = "AudioSend: %d -> %d (%d)\n";
extern OSMesgQueue *D_SH_80350F68;
void func_sh_802F64C8(void) {
static s32 D_SH_8031503C = 0;
s32 a0 = (D_SH_80350F18 - D_SH_80350F19 + 0x100) & 0xff;
s32 a1;
s32 mesg;
if (D_SH_8031503C < a0) {
D_SH_8031503C = a0;
if (((D_SH_80350F18 - D_SH_80350F19 + 0x100) & 0xff) > D_SH_8031503C) {
D_SH_8031503C = (D_SH_80350F18 - D_SH_80350F19 + 0x100) & 0xff;
}
a0 = ((D_SH_80350F19 & 0xff) << 8) | (D_SH_80350F18 & 0xFF);
a1 = a0;
a0 = D_SH_80350F68;
osSendMesg(a0, a1, 0);
mesg = ((D_SH_80350F19 & 0xff) << 8) | (D_SH_80350F18 & 0xff);
osSendMesg(D_SH_80350F68, (OSMesg)mesg, OS_MESG_NOBLOCK);
D_SH_80350F19 = D_SH_80350F18;
}
@@ -304,16 +303,16 @@ void func_sh_802f6540(void) {
D_SH_80350F19 = D_SH_80350F18;
}
void func_sh_802f6554(u32 arg0) {
void func_802ad7ec(u32 arg0) {
struct EuAudioCmd *cmd;
struct SequencePlayer *seqPlayer;
struct SequenceChannel *chan;
u8 a0;
u8 end;
static char shindouDebugPrint134[] = "Continue Port\n";
static char shindouDebugPrint135[] = "%d -> %d\n";
static char shindouDebugPrint136[] = "Sync-Frame Break. (Remain %d)\n";
static char shindouDebugPrint137[] = "Undefined Port Command %d\n";
UNUSED static char shindouDebugPrint134[] = "Continue Port\n";
UNUSED static char shindouDebugPrint135[] = "%d -> %d\n";
UNUSED static char shindouDebugPrint136[] = "Sync-Frame Break. (Remain %d)\n";
UNUSED static char shindouDebugPrint137[] = "Undefined Port Command %d\n";
static u8 D_SH_80315098 = 0;
static u8 D_SH_8031509C = 0;
@@ -322,10 +321,10 @@ void func_sh_802f6554(u32 arg0) {
D_SH_80315098 = (arg0 >> 8) & 0xff;
}
a0 = arg0 & 0xff;
end = arg0 & 0xff;
for (;;) {
if (D_SH_80315098 == a0) {
if (D_SH_80315098 == end) {
D_SH_8031509C = 0;
break;
}
@@ -336,12 +335,12 @@ void func_sh_802f6554(u32 arg0) {
break;
}
else if ((cmd->u.s.op & 0xf0) == 0xf0) {
func_sh_802f5fb8(cmd);
eu_process_audio_cmd(cmd);
}
else if (cmd->u.s.arg1 < SEQUENCE_PLAYERS) {
seqPlayer = &gSequencePlayers[cmd->u.s.arg1];
if ((cmd->u.s.op & 0x80) != 0) {
func_sh_802f5fb8(cmd);
eu_process_audio_cmd(cmd);
}
else if ((cmd->u.s.op & 0x40) != 0) {
switch (cmd->u.s.op) {
@@ -399,8 +398,9 @@ void func_sh_802f6554(u32 arg0) {
}
break;
case 5:
if (chan->reverb != cmd->u2.as_s8) {
chan->reverb = cmd->u2.as_s8;
//! @bug u8 s8 comparison (but harmless)
if (chan->reverbVol != cmd->u2.as_s8) {
chan->reverbVol = cmd->u2.as_s8;
}
break;
case 6:
@@ -489,9 +489,8 @@ s8 func_sh_802f6a6c(s32 playerIndex, s32 index) {
return gSequencePlayers[playerIndex].seqVariationEu[index];
}
void func_sh_802f6a9c(void) {
// creates a bunch of os message queues
func_sh_802f6330();
void port_eu_init(void) {
port_eu_init_queues();
}
char shindouDebugPrint138[] = "specchg conjunction error (Msg:%d Cur:%d)\n";
@@ -525,9 +524,13 @@ char shindouDebugPrint164[] = "Audio: C-Alloc : lowerPrio is NULL\n";
char shindouDebugPrint165[] = "Intterupt UseStop %d (Kill %d)\n";
char shindouDebugPrint166[] = "Intterupt RelWait %d (Kill %d)\n";
char shindouDebugPrint167[] = "Drop Voice (Prio %x)\n";
s32 D_SH_803154CC = 0; // Either an unused variable or a file boundary.
s32 D_SH_803154CC = 0; // file boundary
// effects.c
char shindouDebugPrint168[] = "Audio:Envp: overflow %f\n";
s32 D_SH_803154EC = 0; // Either an unused variable or a file boundary.
s32 D_SH_803154EC = 0; // file boundary
// seqplayer.c
char shindouDebugPrint169[] = "Audio:Track:Warning: No Free Notetrack\n";
char shindouDebugPrint170[] = "SUBTRACK DIM\n";
char shindouDebugPrint171[] = "Audio:Track: Warning :SUBTRACK had been stolen by other Group.\n";
+12 -12
View File
@@ -55,9 +55,9 @@ void sequence_channel_init(struct SequenceChannel *seqChannel) {
seqChannel->panChannelWeight = 1.0f;
seqChannel->noteUnused = NULL;
#endif
seqChannel->reverb = 0;
seqChannel->reverbVol = 0;
#ifdef VERSION_SH
seqChannel->unkSH0C = 0;
seqChannel->synthesisVolume = 0;
#endif
seqChannel->notePriority = NOTE_PRIORITY_DEFAULT;
#ifdef VERSION_SH
@@ -142,7 +142,7 @@ s32 seq_channel_set_layer(struct SequenceChannel *seqChannel, s32 layerIndex) {
layer->freqScale = 1.0f;
layer->velocitySquare = 0.0f;
#ifdef VERSION_SH
layer->unkSH28 = 1.0f;
layer->freqScaleMultiplier = 1.0f;
#endif
layer->instOrWave = 0xff;
#else
@@ -989,7 +989,7 @@ void seq_channel_layer_process_script_part1(struct SequenceChannelLayer *layer)
}
s32 seq_channel_layer_process_script_part5(struct SequenceChannelLayer *layer, s32 cmd) {
if (!layer->stopSomething && layer->sound != NULL && layer->sound->sample->codec == 2 &&
if (!layer->stopSomething && layer->sound != NULL && layer->sound->sample->codec == CODEC_SKIP &&
layer->sound->sample->medium != 0) {
layer->stopSomething = TRUE;
return -1;
@@ -1176,7 +1176,7 @@ s32 seq_channel_layer_process_script_part2(struct SequenceChannelLayer *layer) {
case 0xce:
cmd = m64_read_u8(state) + 0x80;
layer->unkSH28 = unk_sh_data_1[cmd];
layer->freqScaleMultiplier = unk_sh_data_1[cmd];
// missing break :)
default:
@@ -1320,7 +1320,7 @@ s32 seq_channel_layer_process_script_part4(struct SequenceChannelLayer *layer, s
}
}
layer->delayUnused = layer->delay;
layer->freqScale *= layer->unkSH28;
layer->freqScale *= layer->freqScaleMultiplier;
return sameSound;
}
@@ -1828,7 +1828,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
#endif
case 0xd4: // chan_setreverb
seqChannel->reverb = m64_read_u8(state);
seqChannel->reverbVol = m64_read_u8(state);
break;
case 0xc6: // chan_setbank; switch bank within set
@@ -1972,8 +1972,8 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
seqChannel->transposition = (s8) *seqData++;
seqChannel->newPan = *seqData++;
seqChannel->panChannelWeight = *seqData++;
seqChannel->reverb = *seqData++;
seqChannel->reverbIndex = *seqData++; // reverb index?
seqChannel->reverbVol = *seqData++;
seqChannel->reverbIndex = *seqData++;
seqChannel->changes.as_bitfields.pan = TRUE;
break;
@@ -1984,7 +1984,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
seqChannel->transposition = (s8) m64_read_u8(state);
seqChannel->newPan = m64_read_u8(state);
seqChannel->panChannelWeight = m64_read_u8(state);
seqChannel->reverb = m64_read_u8(state);
seqChannel->reverbVol = m64_read_u8(state);
seqChannel->reverbIndex = m64_read_u8(state);
seqChannel->changes.as_bitfields.pan = TRUE;
break;
@@ -2016,7 +2016,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
#endif
#ifdef VERSION_SH
case 0xed:
seqChannel->unkSH0C = m64_read_u8(state);
seqChannel->synthesisVolume = m64_read_u8(state);
break;
case 0xef:
@@ -2112,7 +2112,7 @@ void sequence_channel_process_script(struct SequenceChannel *seqChannel) {
case 0x10:
seqChannel->soundScriptIO[loBits] = -1;
if (func_802f47c8(seqChannel->bankId, (u8)value, &seqChannel->soundScriptIO[loBits]) == -1) {
if (func_sh_802f47c8(seqChannel->bankId, (u8)value, &seqChannel->soundScriptIO[loBits]) == -1) {
}
break;
#else
+12 -2
View File
@@ -1,7 +1,14 @@
#include <ultra64.h>
#ifdef VERSION_SH
// The first four debug prints are in data.c.
// synthesis.c
char shindouDebugPrint1[] = "Terminate-Canceled Channel %d,Phase %d\n";
char shindouDebugPrint2[] = "S->W\n";
char shindouDebugPrint3[] = "W->S\n";
char shindouDebugPrint4[] = "S-Resample Pitch %x (old %d -> delay %d)\n";
s32 shindouDebugPrintPadding1[] = {0,0,0};
// heap.c
char shindouDebugPrint5[] = "Warning:Kill Note %x \n";
char shindouDebugPrint6[] = "Kill Voice %d (ID %d) %d\n";
char shindouDebugPrint7[] = "Warning: Running Sequence's data disappear!\n";
@@ -58,8 +65,9 @@ char shindouDebugPrint57[] = "Request--------Single-Stay, %d\n";
char shindouDebugPrint58[] = "Try Kill %d \n";
char shindouDebugPrint59[] = "Try Kill %x %x\n";
char shindouDebugPrint60[] = "Try Kill %x %x %x\n";
// Zero padding here. These aren't used variables, so they could be either unused variables or a file boundary.
s32 shindouDebugPrintPadding[] = {0, 0, 0};
// load.c
char shindouDebugPrint61[] = "CAUTION:WAVE CACHE FULL %d";
char shindouDebugPrint62[] = "SUPERDMA";
char shindouDebugPrint63[] = "Bank Change... top %d lba %d\n";
@@ -124,6 +132,8 @@ char shindouDebugPrint121[] = "N start %d\n";
char shindouDebugPrint122[] = "============Error: Magic is Broken: %x\n";
char shindouDebugPrint123[] = "Error: No Handle.\n";
char shindouDebugPrint124[] = "Success: %x\n";
// port_eu.c
char shindouDebugPrint125[] = "DAC:Lost 1 Frame.\n";
char shindouDebugPrint126[] = "DMA: Request queue over.( %d )\n";
char shindouDebugPrint127[] = "Spec Change Override. %d -> %d\n";
+100 -776
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -90,7 +90,7 @@ extern s16 D_SH_803479B4;
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen);
#if defined(VERSION_JP) || defined(VERSION_US)
void note_init_volume(struct Note *note);
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverb);
void note_set_vel_pan_reverb(struct Note *note, f32 velocity, f32 pan, u8 reverbVol);
void note_set_frequency(struct Note *note, f32 frequency);
void note_enable(struct Note *note);
void note_disable(struct Note *note);
+910
View File
@@ -0,0 +1,910 @@
#ifdef VERSION_SH
#include <ultra64.h>
#include "synthesis.h"
#include "heap.h"
#include "data.h"
#include "load.h"
#include "seqplayer.h"
#include "internal.h"
#include "external.h"
#define DMEM_ADDR_TEMP 0x450
#define DMEM_ADDR_RESAMPLED 0x470
#define DMEM_ADDR_RESAMPLED2 0x5f0
#define DMEM_ADDR_UNCOMPRESSED_NOTE 0x5f0
#define DMEM_ADDR_NOTE_PAN_TEMP 0x650
#define DMEM_ADDR_COMPRESSED_ADPCM_DATA 0x990
#define DMEM_ADDR_LEFT_CH 0x990
#define DMEM_ADDR_RIGHT_CH 0xb10
#define DMEM_ADDR_WET_LEFT_CH 0xc90
#define DMEM_ADDR_WET_RIGHT_CH 0xe10
#define aSetLoadBufferPair(pkt, c, off) \
aSetBuffer(pkt, 0, c + DMEM_ADDR_WET_LEFT_CH, 0, DEFAULT_LEN_1CH - c); \
aLoadBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.left + (off))); \
aSetBuffer(pkt, 0, c + DMEM_ADDR_WET_RIGHT_CH, 0, DEFAULT_LEN_1CH - c); \
aLoadBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.right + (off)))
#define aSetSaveBufferPair(pkt, c, d, off) \
aSetBuffer(pkt, 0, 0, c + DMEM_ADDR_WET_LEFT_CH, d); \
aSaveBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.left + (off))); \
aSetBuffer(pkt, 0, 0, c + DMEM_ADDR_WET_RIGHT_CH, d); \
aSaveBuffer(pkt, VIRTUAL_TO_PHYSICAL2(gSynthesisReverb.ringBuffer.right + (off)));
#define ALIGN(val, amnt) (((val) + (1 << amnt) - 1) & ~((1 << amnt) - 1))
struct VolumeChange {
u16 sourceLeft;
u16 sourceRight;
u16 targetLeft;
u16 targetRight;
};
u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex);
u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex);
u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad);
u64 *final_resample(u64 *cmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags);
u64 *process_envelope(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags);
u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight);
struct SynthesisReverb gSynthesisReverbs[4];
u8 sAudioSynthesisPad[0x10];
s16 gVolume;
s8 gUseReverb;
s8 gNumSynthesisReverbs;
s16 D_SH_803479B4; // contains 4096
struct NoteSubEu *gNoteSubsEu;
// Equivalent functionality as the US/JP version,
// just that the reverb structure is chosen from an array with index
// Identical in EU.
void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex) {
struct ReverbRingBufferItem *item;
struct SynthesisReverb *reverb = &gSynthesisReverbs[reverbIndex];
s32 srcPos;
s32 dstPos;
s32 nSamples;
s32 excessiveSamples;
s32 UNUSED pad[3];
if (reverb->downsampleRate != 1) {
if (reverb->framesLeftToIgnore == 0) {
// Now that the RSP has finished, downsample the samples produced two frames ago by skipping
// samples.
item = &reverb->items[reverb->curFrame][updateIndex];
// Touches both left and right since they are adjacent in memory
osInvalDCache(item->toDownsampleLeft, DEFAULT_LEN_2CH);
for (srcPos = 0, dstPos = 0; dstPos < item->lengthA / 2;
srcPos += reverb->downsampleRate, dstPos++) {
reverb->ringBuffer.left[item->startPos + dstPos] =
item->toDownsampleLeft[srcPos];
reverb->ringBuffer.right[item->startPos + dstPos] =
item->toDownsampleRight[srcPos];
}
for (dstPos = 0; dstPos < item->lengthB / 2; srcPos += reverb->downsampleRate, dstPos++) {
reverb->ringBuffer.left[dstPos] = item->toDownsampleLeft[srcPos];
reverb->ringBuffer.right[dstPos] = item->toDownsampleRight[srcPos];
}
}
}
item = &reverb->items[reverb->curFrame][updateIndex];
nSamples = chunkLen / reverb->downsampleRate;
excessiveSamples = (nSamples + reverb->nextRingBufferPos) - reverb->bufSizePerChannel;
if (excessiveSamples < 0) {
// There is space in the ring buffer before it wraps around
item->lengthA = nSamples * 2;
item->lengthB = 0;
item->startPos = (s32) reverb->nextRingBufferPos;
reverb->nextRingBufferPos += nSamples;
} else {
// Ring buffer wrapped around
item->lengthA = (nSamples - excessiveSamples) * 2;
item->lengthB = excessiveSamples * 2;
item->startPos = reverb->nextRingBufferPos;
reverb->nextRingBufferPos = excessiveSamples;
}
// These fields are never read later
item->numSamplesAfterDownsampling = nSamples;
item->chunkLen = chunkLen;
}
u64 *synthesis_load_reverb_ring_buffer(u64 *cmd, u16 addr, u16 srcOffset, s32 len, s32 reverbIndex) {
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.left[srcOffset]),
addr, len);
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.right[srcOffset]),
addr + DEFAULT_LEN_1CH, len);
return cmd;
}
u64 *synthesis_save_reverb_ring_buffer(u64 *cmd, u16 addr, u16 destOffset, s32 len, s32 reverbIndex) {
aSaveBuffer(cmd++, addr,
VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.left[destOffset]), len);
aSaveBuffer(cmd++, addr + DEFAULT_LEN_1CH,
VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.right[destOffset]), len);
return cmd;
}
void func_sh_802ed644(s32 updateIndexStart, s32 noteIndex) {
s32 i;
for (i = updateIndexStart + 1; i < gAudioBufferParameters.updatesPerFrame; i++) {
if (!gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].needsInit) {
gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].enabled = FALSE;
} else {
break;
}
}
}
void synthesis_load_note_subs_eu(s32 updateIndex) {
struct NoteSubEu *src;
struct NoteSubEu *dest;
s32 i;
for (i = 0; i < gMaxSimultaneousNotes; i++) {
src = &gNotes[i].noteSubEu;
dest = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i];
if (src->enabled) {
*dest = *src;
src->needsInit = FALSE;
} else {
dest->enabled = FALSE;
}
}
}
// TODO: (Scrub C) pointless mask and whitespace
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) {
s32 i, j;
u32 *aiBufPtr;
u64 *cmd = cmdBuf;
s32 chunkLen;
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
process_sequences(i - 1);
synthesis_load_note_subs_eu(gAudioBufferParameters.updatesPerFrame - i);
}
aiBufPtr = (u32 *) aiBuf;
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
if (i == 1) {
chunkLen = bufLen;
} else {
if (bufLen / i >= gAudioBufferParameters.samplesPerUpdateMax) {
chunkLen = gAudioBufferParameters.samplesPerUpdateMax;
} else if (bufLen / i <= gAudioBufferParameters.samplesPerUpdateMin) {
chunkLen = gAudioBufferParameters.samplesPerUpdateMin;
} else {
chunkLen = gAudioBufferParameters.samplesPerUpdate;
}
}
for (j = 0; j < gNumSynthesisReverbs; j++) {
if (gSynthesisReverbs[j].useReverb != 0) {
prepare_reverb_ring_buffer(chunkLen, gAudioBufferParameters.updatesPerFrame - i, j);
}
}
cmd = synthesis_do_one_audio_update((s16 *) aiBufPtr, chunkLen, cmd, gAudioBufferParameters.updatesPerFrame - i);
bufLen -= chunkLen;
aiBufPtr += chunkLen;
}
for (j = 0; j < gNumSynthesisReverbs; j++) {
if (gSynthesisReverbs[j].framesLeftToIgnore != 0) {
gSynthesisReverbs[j].framesLeftToIgnore--;
}
gSynthesisReverbs[j].curFrame ^= 1;
}
*writtenCmds = cmd - cmdBuf;
return cmd;
}
u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s16 updateIndex) {
struct ReverbRingBufferItem *item;
s16 startPad;
s16 paddedLengthA;
item = &gSynthesisReverbs[reverbIndex].items[gSynthesisReverbs[reverbIndex].curFrame][updateIndex];
if (gSynthesisReverbs[reverbIndex].downsampleRate == 1) {
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH, item->startPos, item->lengthA, reverbIndex);
if (item->lengthB != 0) {
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH + item->lengthA, 0, item->lengthB, reverbIndex);
}
aAddMixer(cmd++, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
aMix(cmd++, 0x8000 + gSynthesisReverbs[reverbIndex].reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
} else {
startPad = (item->startPos % 8u) * 2;
paddedLengthA = ALIGN(startPad + item->lengthA, 4);
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED, (item->startPos - startPad / 2), DEFAULT_LEN_1CH, reverbIndex);
if (item->lengthB != 0) {
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED + paddedLengthA, 0, DEFAULT_LEN_1CH - paddedLengthA, reverbIndex);
}
aSetBuffer(cmd++, 0, DMEM_ADDR_RESAMPLED + startPad, DMEM_ADDR_WET_LEFT_CH, bufLen * 2);
aResample(cmd++, gSynthesisReverbs[reverbIndex].resampleFlags, gSynthesisReverbs[reverbIndex].resampleRate, VIRTUAL_TO_PHYSICAL2(gSynthesisReverbs[reverbIndex].resampleStateLeft));
aSetBuffer(cmd++, 0, DMEM_ADDR_RESAMPLED2 + startPad, DMEM_ADDR_WET_RIGHT_CH, bufLen * 2);
aResample(cmd++, gSynthesisReverbs[reverbIndex].resampleFlags, gSynthesisReverbs[reverbIndex].resampleRate, VIRTUAL_TO_PHYSICAL2(gSynthesisReverbs[reverbIndex].resampleStateRight));
aAddMixer(cmd++, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
aMix(cmd++, 0x8000 + gSynthesisReverbs[reverbIndex].reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
}
if (gSynthesisReverbs[reverbIndex].panRight != 0 || gSynthesisReverbs[reverbIndex].panLeft != 0) {
// Leak some audio from the left reverb channel into the right reverb channel and vice versa (pan)
aDMEMMove(cmd++, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_RESAMPLED, DEFAULT_LEN_1CH);
aMix(cmd++, gSynthesisReverbs[reverbIndex].panRight, DMEM_ADDR_WET_RIGHT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_1CH);
aMix(cmd++, gSynthesisReverbs[reverbIndex].panLeft, DMEM_ADDR_RESAMPLED, DMEM_ADDR_WET_RIGHT_CH, DEFAULT_LEN_1CH);
}
return cmd;
}
u64 *synthesis_load_reverb_samples(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
struct ReverbRingBufferItem *item;
struct SynthesisReverb *reverb;
reverb = &gSynthesisReverbs[reverbIndex];
item = &reverb->items[reverb->curFrame][updateIndex];
// Get the oldest samples in the ring buffer into the wet channels
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED, item->startPos, item->lengthA, reverbIndex);
if (item->lengthB != 0) {
// Ring buffer wrapped
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED + item->lengthA, 0, item->lengthB, reverbIndex);
}
return cmd;
}
u64 *synthesis_save_reverb_samples(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
struct ReverbRingBufferItem *item;
item = &gSynthesisReverbs[reverbIndex].items[gSynthesisReverbs[reverbIndex].curFrame][updateIndex];
switch (gSynthesisReverbs[reverbIndex].downsampleRate) {
case 1:
// Put the oldest samples in the ring buffer into the wet channels
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH, item->startPos, item->lengthA, reverbIndex);
if (item->lengthB != 0) {
// Ring buffer wrapped
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH + item->lengthA, 0, item->lengthB, reverbIndex);
}
break;
default:
// Downsampling is done later by CPU when RSP is done, therefore we need to have double
// buffering. Left and right buffers are adjacent in memory.
aSaveBuffer(cmd++, DMEM_ADDR_WET_LEFT_CH,
VIRTUAL_TO_PHYSICAL2(gSynthesisReverbs[reverbIndex].items[gSynthesisReverbs[reverbIndex].curFrame][updateIndex].toDownsampleLeft), DEFAULT_LEN_2CH);
break;
}
gSynthesisReverbs[reverbIndex].resampleFlags = 0;
return cmd;
}
u64 *func_sh_802EDF24(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
struct ReverbRingBufferItem *item;
struct SynthesisReverb *reverb;
reverb = &gSynthesisReverbs[reverbIndex];
item = &reverb->items[reverb->curFrame][updateIndex];
// Put the oldest samples in the ring buffer into the wet channels
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED, item->startPos, item->lengthA, reverbIndex);
if (item->lengthB != 0) {
// Ring buffer wrapped
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED + item->lengthA, 0, item->lengthB, reverbIndex);
}
return cmd;
}
u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex) {
struct NoteSubEu *noteSubEu;
u8 noteIndices[56];
s32 temp;
s32 i;
s16 j;
s16 notePos = 0;
if (gNumSynthesisReverbs == 0) {
for (i = 0; i < gMaxSimultaneousNotes; i++) {
if (gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i].enabled) {
noteIndices[notePos++] = i;
}
}
} else {
for (j = 0; j < gNumSynthesisReverbs; j++) {
for (i = 0; i < gMaxSimultaneousNotes; i++) {
noteSubEu = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i];
if (noteSubEu->enabled && j == noteSubEu->reverbIndex) {
noteIndices[notePos++] = i;
}
}
}
for (i = 0; i < gMaxSimultaneousNotes; i++) {
noteSubEu = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i];
if (noteSubEu->enabled && noteSubEu->reverbIndex >= gNumSynthesisReverbs) {
noteIndices[notePos++] = i;
}
}
}
aClearBuffer(cmd++, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
i = 0;
for (j = 0; j < gNumSynthesisReverbs; j++) {
gUseReverb = gSynthesisReverbs[j].useReverb;
if (gUseReverb != 0) {
cmd = synthesis_resample_and_mix_reverb(cmd, bufLen, j, updateIndex);
}
for (; i < notePos; i++) {
temp = updateIndex * gMaxSimultaneousNotes;
if (j == gNoteSubsEu[temp + noteIndices[i]].reverbIndex) {
cmd = synthesis_process_note(noteIndices[i],
&gNoteSubsEu[temp + noteIndices[i]],
&gNotes[noteIndices[i]].synthesisState,
aiBuf, bufLen, cmd, updateIndex);
continue;
} else {
break;
}
}
if (gSynthesisReverbs[j].useReverb != 0) {
if (gSynthesisReverbs[j].unk100 != NULL) {
aFilter(cmd++, 0x02, bufLen * 2, gSynthesisReverbs[j].unk100);
aFilter(cmd++, gSynthesisReverbs[j].resampleFlags, DMEM_ADDR_WET_LEFT_CH, gSynthesisReverbs[j].unk108);
}
if (gSynthesisReverbs[j].unk104 != NULL) {
aFilter(cmd++, 0x02, bufLen * 2, gSynthesisReverbs[j].unk104);
aFilter(cmd++, gSynthesisReverbs[j].resampleFlags, DMEM_ADDR_WET_RIGHT_CH, gSynthesisReverbs[j].unk10C);
}
cmd = synthesis_save_reverb_samples(cmd, j, updateIndex);
if (gSynthesisReverbs[j].unk5 != -1) {
if (gSynthesisReverbs[gSynthesisReverbs[j].unk5].downsampleRate == 1) {
cmd = synthesis_load_reverb_samples(cmd, gSynthesisReverbs[j].unk5, updateIndex);
aMix(cmd++, gSynthesisReverbs[j].unk08, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_RESAMPLED, DEFAULT_LEN_2CH);
cmd = func_sh_802EDF24(cmd++, gSynthesisReverbs[j].unk5, updateIndex);
}
}
}
}
for (; i < notePos; i++) {
struct NoteSubEu *noteSubEu2 = &gNoteSubsEu[updateIndex * gMaxSimultaneousNotes + noteIndices[i]];
cmd = synthesis_process_note(noteIndices[i],
noteSubEu2,
&gNotes[noteIndices[i]].synthesisState,
aiBuf, bufLen, cmd, updateIndex);
}
temp = bufLen * 2;
aInterleave(cmd++, DMEM_ADDR_TEMP, DMEM_ADDR_LEFT_CH, DMEM_ADDR_RIGHT_CH, temp);
aSaveBuffer(cmd++, DMEM_ADDR_TEMP, VIRTUAL_TO_PHYSICAL2(aiBuf), temp * 2);
return cmd;
}
u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, UNUSED s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex) {
UNUSED s32 pad0[3];
struct AudioBankSample *audioBookSample; // sp164, sp138
struct AdpcmLoop *loopInfo; // sp160, sp134
s16 *curLoadedBook; // sp154, sp130
UNUSED u8 padEU[0x04];
UNUSED u8 pad8[0x04];
s32 noteFinished; // 150 t2, sp124
s32 restart; // 14c t3, sp120
s32 flags; // sp148, sp11C, t8
u16 resamplingRateFixedPoint; // sp5c, sp11A
s32 nSamplesToLoad; //s0, Ec
UNUSED u8 pad7[0x0c]; // sp100
s32 sp130; //sp128, sp104
UNUSED s32 tempBufLen;
UNUSED u32 pad9;
s32 t0;
u8 *sampleAddr; // sp120, spF4
s32 s6;
s32 samplesLenAdjusted; // 108, spEC
s32 nAdpcmSamplesProcessed; // signed required for US // spc0
s32 endPos; // sp110, spE4
s32 nSamplesToProcess; // sp10c/a0, spE0
// Might have been used to store (samplesLenFixedPoint >> 0x10), but doing so causes strange
// behavior with the break near the end of the loop, causing US and JP to need a goto instead
UNUSED s32 samplesLenInt;
s32 s2;
s32 leftRight; //s0
s32 s5; //s4
u32 samplesLenFixedPoint; // v1_1
s32 s3; // spA0
s32 nSamplesInThisIteration; // v1_2
u32 a3;
u8 *v0_2;
s32 unk_s6; // sp90
s32 s5Aligned;
s32 sp88;
s32 sp84;
u32 temp;
s32 nParts; // spE8, spBC
s32 curPart; // spE4, spB8
s32 aligned;
UNUSED u32 padSH1;
s32 resampledTempLen; // spD8, spAC, sp6c
u16 noteSamplesDmemAddrBeforeResampling; // spD6, spAA, sp6a -- 6C
UNUSED u32 padSH2;
UNUSED u32 padSH3;
UNUSED u32 padSH4;
struct Note *note; // sp58
u16 sp56; // sp56
u16 addr;
u8 synthesisVolume;
curLoadedBook = NULL;
note = &gNotes[noteIndex];
flags = 0;
if (noteSubEu->needsInit == TRUE) {
flags = A_INIT;
synthesisState->restart = 0;
synthesisState->samplePosInt = 0;
synthesisState->samplePosFrac = 0;
synthesisState->curVolLeft = 0;
synthesisState->curVolRight = 0;
synthesisState->prevHeadsetPanRight = 0;
synthesisState->prevHeadsetPanLeft = 0;
synthesisState->reverbVol = noteSubEu->reverbVol;
synthesisState->unk5 = 0;
note->noteSubEu.finished = 0;
}
resamplingRateFixedPoint = noteSubEu->resamplingRateFixedPoint;
nParts = noteSubEu->hasTwoAdpcmParts + 1;
samplesLenFixedPoint = (resamplingRateFixedPoint * bufLen * 2) + synthesisState->samplePosFrac;
nSamplesToLoad = (samplesLenFixedPoint >> 0x10);
synthesisState->samplePosFrac = samplesLenFixedPoint & 0xFFFF;
if ((synthesisState->unk5 == 1) && (nParts == 2)) {
nSamplesToLoad += 2;
sp56 = 2;
} else if ((synthesisState->unk5 == 2) && (nParts == 1)) {
nSamplesToLoad -= 4;
sp56 = 4;
} else {
sp56 = 0;
}
synthesisState->unk5 = nParts;
if (noteSubEu->isSyntheticWave) {
cmd = load_wave_samples(cmd, noteSubEu, synthesisState, nSamplesToLoad);
noteSamplesDmemAddrBeforeResampling = (synthesisState->samplePosInt * 2) + DMEM_ADDR_UNCOMPRESSED_NOTE;
synthesisState->samplePosInt += nSamplesToLoad;
} else {
// ADPCM note
audioBookSample = noteSubEu->sound.audioBankSound->sample;
loopInfo = audioBookSample->loop;
endPos = loopInfo->end;
sampleAddr = audioBookSample->sampleAddr;
resampledTempLen = 0;
for (curPart = 0; curPart < nParts; curPart++) {
nAdpcmSamplesProcessed = 0; // s8
s5 = 0; // s4
if (nParts == 1) {
samplesLenAdjusted = nSamplesToLoad;
} else if (nSamplesToLoad & 1) {
samplesLenAdjusted = (nSamplesToLoad & ~1) + (curPart * 2);
} else {
samplesLenAdjusted = nSamplesToLoad;
}
if (audioBookSample->codec == CODEC_ADPCM) {
if (curLoadedBook != (*audioBookSample->book).book) {
u32 nEntries;
switch (noteSubEu->bookOffset) {
case 1:
curLoadedBook = euUnknownData_80301950 + 1;
break;
case 2:
curLoadedBook = euUnknownData_80301950 + 2;
break;
case 3:
default:
curLoadedBook = audioBookSample->book->book;
break;
}
nEntries = 16 * audioBookSample->book->order * audioBookSample->book->npredictors;
aLoadADPCM(cmd++, nEntries, VIRTUAL_TO_PHYSICAL2(curLoadedBook));
}
}
while (nAdpcmSamplesProcessed != samplesLenAdjusted) {
s32 samplesRemaining; // v1
s32 s0;
noteFinished = FALSE;
restart = FALSE;
s2 = synthesisState->samplePosInt & 0xf;
samplesRemaining = endPos - synthesisState->samplePosInt;
nSamplesToProcess = samplesLenAdjusted - nAdpcmSamplesProcessed;
if (s2 == 0 && synthesisState->restart == FALSE) {
s2 = 16;
}
s6 = 16 - s2; // a1
if (nSamplesToProcess < samplesRemaining) {
t0 = (nSamplesToProcess - s6 + 0xf) / 16;
s0 = t0 * 16;
s3 = s6 + s0 - nSamplesToProcess;
} else {
s0 = samplesRemaining - s6;
s3 = 0;
if (s0 <= 0) {
s0 = 0;
s6 = samplesRemaining;
}
t0 = (s0 + 0xf) / 16;
if (loopInfo->count != 0) {
// Loop around and restart
restart = 1;
} else {
noteFinished = 1;
}
}
switch (audioBookSample->codec) {
case CODEC_ADPCM:
unk_s6 = 9;
sp88 = 0x10;
sp84 = 0;
break;
case CODEC_S8:
unk_s6 = 0x10;
sp88 = 0x10;
sp84 = 0;
break;
case CODEC_SKIP: goto skip;
}
if (t0 != 0) {
temp = (synthesisState->samplePosInt + sp88 - s2) / 16;
if (audioBookSample->medium == 0) {
v0_2 = sp84 + (temp * unk_s6) + sampleAddr;
} else {
v0_2 = dma_sample_data((uintptr_t)(sp84 + (temp * unk_s6) + sampleAddr),
ALIGN(t0 * unk_s6 + 16, 4), flags, &synthesisState->sampleDmaIndex, audioBookSample->medium);
}
a3 = ((uintptr_t)v0_2 & 0xf);
aligned = ALIGN(t0 * unk_s6 + 16, 4);
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(v0_2 - a3), addr, ALIGN(t0 * unk_s6 + 16, 4));
} else {
s0 = 0;
a3 = 0;
}
if (synthesisState->restart != FALSE) {
aSetLoop(cmd++, VIRTUAL_TO_PHYSICAL2(audioBookSample->loop->state));
flags = A_LOOP; // = 2
synthesisState->restart = FALSE;
}
nSamplesInThisIteration = s0 + s6 - s3;
if (nAdpcmSamplesProcessed == 0) {
switch (audioBookSample->codec) {
case CODEC_ADPCM:
aligned = ALIGN(t0 * unk_s6 + 16, 4);
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
aSetBuffer(cmd++, 0, addr + a3, DMEM_ADDR_UNCOMPRESSED_NOTE, s0 * 2);
aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
break;
case CODEC_S8:
aligned = ALIGN(t0 * unk_s6 + 16, 4);
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
aSetBuffer(cmd++, 0, addr + a3, DMEM_ADDR_UNCOMPRESSED_NOTE, s0 * 2);
aS8Dec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
break;
}
sp130 = s2 * 2;
} else {
s5Aligned = ALIGN(s5 + 16, 4);
switch (audioBookSample->codec) {
case CODEC_ADPCM:
aligned = ALIGN(t0 * unk_s6 + 16, 4);
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
aSetBuffer(cmd++, 0, addr + a3, DMEM_ADDR_UNCOMPRESSED_NOTE + s5Aligned, s0 * 2);
aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
break;
case CODEC_S8:
aligned = ALIGN(t0 * unk_s6 + 16, 4);
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
aSetBuffer(cmd++, 0, addr + a3, DMEM_ADDR_UNCOMPRESSED_NOTE + s5Aligned, s0 * 2);
aS8Dec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
break;
}
aDMEMMove(cmd++, DMEM_ADDR_UNCOMPRESSED_NOTE + s5Aligned + (s2 * 2), DMEM_ADDR_UNCOMPRESSED_NOTE + s5, (nSamplesInThisIteration) * 2);
}
nAdpcmSamplesProcessed += nSamplesInThisIteration;
switch (flags) {
case A_INIT: // = 1
sp130 = 0x20;
s5 = (s0 + 0x10) * 2;
break;
case A_LOOP: // = 2
s5 = (nSamplesInThisIteration) * 2 + s5;
break;
default:
if (s5 != 0) {
s5 = (nSamplesInThisIteration) * 2 + s5;
} else {
s5 = (s2 + (nSamplesInThisIteration)) * 2;
}
break;
}
flags = 0;
skip:
if (noteFinished) {
aClearBuffer(cmd++, DMEM_ADDR_UNCOMPRESSED_NOTE + s5,
(samplesLenAdjusted - nAdpcmSamplesProcessed) * 2);
noteSubEu->finished = 1;
note->noteSubEu.finished = 1;
func_sh_802ed644(updateIndex, noteIndex);
break;
}
if (restart != 0) {
synthesisState->restart = TRUE;
synthesisState->samplePosInt = loopInfo->start;
} else {
synthesisState->samplePosInt += nSamplesToProcess;
}
}
switch (nParts) {
case 1:
noteSamplesDmemAddrBeforeResampling = DMEM_ADDR_UNCOMPRESSED_NOTE + sp130;
break;
case 2:
switch (curPart) {
case 0:
aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), DMEM_ADDR_UNCOMPRESSED_NOTE + sp130, DMEM_ADDR_RESAMPLED);
resampledTempLen = samplesLenAdjusted;
noteSamplesDmemAddrBeforeResampling = DMEM_ADDR_RESAMPLED;
if (noteSubEu->finished != FALSE) {
aClearBuffer(cmd++, noteSamplesDmemAddrBeforeResampling + resampledTempLen, samplesLenAdjusted + 0x10);
}
break;
case 1:
aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), DMEM_ADDR_UNCOMPRESSED_NOTE + sp130, resampledTempLen + DMEM_ADDR_RESAMPLED);
break;
}
}
if (noteSubEu->finished != FALSE) {
break;
}
}
}
flags = 0;
if (noteSubEu->needsInit == TRUE) {
flags = A_INIT;
noteSubEu->needsInit = FALSE;
}
flags = flags | sp56;
cmd = final_resample(cmd, synthesisState, bufLen * 2, resamplingRateFixedPoint,
noteSamplesDmemAddrBeforeResampling, flags);
if ((flags & 1) != 0) {
flags = 1;
}
if (noteSubEu->filter) {
aFilter(cmd++, 0x02, bufLen * 2, noteSubEu->filter);
aFilter(cmd++, flags, DMEM_ADDR_TEMP, synthesisState->synthesisBuffers->filterBuffer);
}
if (noteSubEu->bookOffset == 3) {
aUnknown25(cmd++, 0, bufLen * 2, DMEM_ADDR_TEMP, DMEM_ADDR_TEMP);
}
synthesisVolume = noteSubEu->synthesisVolume;
if (synthesisVolume != 0) {
if (synthesisVolume < 0x10) {
synthesisVolume = 0x10;
}
aHiLoGain(cmd++, synthesisVolume, (bufLen + 0x10) * 2, DMEM_ADDR_TEMP);
}
if (noteSubEu->headsetPanRight != 0 || synthesisState->prevHeadsetPanRight != 0) {
leftRight = 1;
} else if (noteSubEu->headsetPanLeft != 0 || synthesisState->prevHeadsetPanLeft != 0) {
leftRight = 2;
} else {
leftRight = 0;
}
cmd = process_envelope(cmd, noteSubEu, synthesisState, bufLen, DMEM_ADDR_TEMP, leftRight, flags);
if (noteSubEu->usesHeadsetPanEffects) {
if ((flags & 1) == 0) {
flags = 0;
}
cmd = note_apply_headset_pan_effects(cmd, noteSubEu, synthesisState, bufLen * 2, flags, leftRight);
}
return cmd;
}
u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad) {
s32 a3;
s32 repeats;
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(noteSubEu->sound.samples),
DMEM_ADDR_UNCOMPRESSED_NOTE, 128);
synthesisState->samplePosInt &= 0x3f;
a3 = 64 - synthesisState->samplePosInt;
if (a3 < nSamplesToLoad) {
repeats = (nSamplesToLoad - a3 + 63) / 64;
if (repeats != 0) {
aDuplicate(cmd++,
/*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE,
/*dmemout*/ DMEM_ADDR_UNCOMPRESSED_NOTE + 128,
/*copies*/ repeats);
}
}
return cmd;
}
u64 *final_resample(u64 *cmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags) {
if (pitch == 0) {
aClearBuffer(cmd++, DMEM_ADDR_TEMP, count);
} else {
aSetBuffer(cmd++, /*flags*/ 0, dmemIn, /*dmemout*/ DMEM_ADDR_TEMP, count);
aResample(cmd++, flags, pitch, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->finalResampleState));
}
return cmd;
}
u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, UNUSED u32 flags) {
u16 sourceRight;
u16 sourceLeft;
u16 targetLeft;
u16 targetRight;
s16 rampLeft;
s16 rampRight;
s32 sourceReverbVol;
s16 rampReverb;
s32 reverbVolDiff = 0;
sourceLeft = synthesisState->curVolLeft;
sourceRight = synthesisState->curVolRight;
targetLeft = note->targetVolLeft;
targetRight = note->targetVolRight;
targetLeft <<= 4;
targetRight <<= 4;
if (targetLeft != sourceLeft) {
rampLeft = (targetLeft - sourceLeft) / (nSamples >> 3);
} else {
rampLeft = 0;
}
if (targetRight != sourceRight) {
rampRight = (targetRight - sourceRight) / (nSamples >> 3);
} else {
rampRight = 0;
}
sourceReverbVol = synthesisState->reverbVol;
if (note->reverbVol != sourceReverbVol) {
reverbVolDiff = ((note->reverbVol & 0x7f) - (sourceReverbVol & 0x7f)) << 9;
rampReverb = reverbVolDiff / (nSamples >> 3);
synthesisState->reverbVol = note->reverbVol;
} else {
rampReverb = 0;
}
synthesisState->curVolLeft = sourceLeft + rampLeft * (nSamples >> 3);
synthesisState->curVolRight = sourceRight + rampRight * (nSamples >> 3);
if (note->usesHeadsetPanEffects) {
aClearBuffer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, DEFAULT_LEN_1CH);
aEnvSetup1(cmd++, (sourceReverbVol & 0x7f) * 2, rampReverb, rampLeft, rampRight);
aEnvSetup2(cmd++, sourceLeft, sourceRight);
switch (headsetPanSettings) {
case 1:
aEnvMixer(cmd++,
inBuf, nSamples,
(sourceReverbVol & 0x80) >> 7,
note->stereoStrongRight, note->stereoStrongLeft,
DMEM_ADDR_NOTE_PAN_TEMP,
DMEM_ADDR_RIGHT_CH,
DMEM_ADDR_WET_LEFT_CH,
DMEM_ADDR_WET_RIGHT_CH);
break;
case 2:
aEnvMixer(cmd++,
inBuf, nSamples,
(sourceReverbVol & 0x80) >> 7,
note->stereoStrongRight, note->stereoStrongLeft,
DMEM_ADDR_LEFT_CH,
DMEM_ADDR_NOTE_PAN_TEMP,
DMEM_ADDR_WET_LEFT_CH,
DMEM_ADDR_WET_RIGHT_CH);
break;
default:
aEnvMixer(cmd++,
inBuf, nSamples,
(sourceReverbVol & 0x80) >> 7,
note->stereoStrongRight, note->stereoStrongLeft,
DMEM_ADDR_LEFT_CH,
DMEM_ADDR_RIGHT_CH,
DMEM_ADDR_WET_LEFT_CH,
DMEM_ADDR_WET_RIGHT_CH);
break;
}
} else {
aEnvSetup1(cmd++, (sourceReverbVol & 0x7f) * 2, rampReverb, rampLeft, rampRight);
aEnvSetup2(cmd++, sourceLeft, sourceRight);
aEnvMixer(cmd++,
inBuf, nSamples,
(sourceReverbVol & 0x80) >> 7,
note->stereoStrongRight, note->stereoStrongLeft,
DMEM_ADDR_LEFT_CH,
DMEM_ADDR_RIGHT_CH,
DMEM_ADDR_WET_LEFT_CH,
DMEM_ADDR_WET_RIGHT_CH);
}
return cmd;
}
u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight) {
u16 dest;
u16 pitch;
u8 prevPanShift;
u8 panShift;
UNUSED u8 unkDebug;
switch (leftRight) {
case 1:
dest = DMEM_ADDR_LEFT_CH;
panShift = noteSubEu->headsetPanRight;
note->prevHeadsetPanLeft = 0;
prevPanShift = note->prevHeadsetPanRight;
note->prevHeadsetPanRight = panShift;
break;
case 2:
dest = DMEM_ADDR_RIGHT_CH;
panShift = noteSubEu->headsetPanLeft;
note->prevHeadsetPanRight = 0;
prevPanShift = note->prevHeadsetPanLeft;
note->prevHeadsetPanLeft = panShift;
break;
default:
return cmd;
}
if (flags != 1) { // A_INIT?
// Slightly adjust the sample rate in order to fit a change in pan shift
if (panShift != prevPanShift) {
pitch = (((bufLen << 0xf) / 2) - 1) / ((bufLen + panShift - prevPanShift - 2) / 2);
aSetBuffer(cmd++, 0, DMEM_ADDR_NOTE_PAN_TEMP, DMEM_ADDR_TEMP, (bufLen + panShift) - prevPanShift);
aResampleZoh(cmd++, pitch, 0);
} else {
aDMEMMove(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, DMEM_ADDR_TEMP, bufLen);
}
if (prevPanShift != 0) {
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->panSamplesBuffer),
DMEM_ADDR_NOTE_PAN_TEMP, ALIGN(prevPanShift, 4));
aDMEMMove(cmd++, DMEM_ADDR_TEMP, DMEM_ADDR_NOTE_PAN_TEMP + prevPanShift, bufLen + panShift - prevPanShift);
} else {
aDMEMMove(cmd++, DMEM_ADDR_TEMP, DMEM_ADDR_NOTE_PAN_TEMP, bufLen + panShift);
}
} else {
// Just shift right
aDMEMMove(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, DMEM_ADDR_TEMP, bufLen);
aClearBuffer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, panShift);
aDMEMMove(cmd++, DMEM_ADDR_TEMP, DMEM_ADDR_NOTE_PAN_TEMP + panShift, bufLen);
}
if (panShift) {
// Save excessive samples for next iteration
aSaveBuffer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP + bufLen,
VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->panSamplesBuffer), ALIGN(panShift, 4));
}
aAddMixer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, dest, (bufLen + 0x3f) & 0xffc0);
return cmd;
}
#endif
+2 -1
View File
@@ -1,6 +1,7 @@
#include <ultra64.h>
#include "buffers.h"
#include "config.h"
ALIGNED8 u8 gDecompressionHeap[0xD000];
#if defined(VERSION_EU)
@@ -15,7 +16,7 @@ ALIGNED8 u8 gIdleThreadStack[0x800];
ALIGNED8 u8 gThread3Stack[0x2000];
ALIGNED8 u8 gThread4Stack[0x2000];
ALIGNED8 u8 gThread5Stack[0x2000];
#ifdef VERSION_SH
#if ENABLE_RUMBLE
ALIGNED8 u8 gThread6Stack[0x2000];
#endif
// 0x400 bytes
+2 -1
View File
@@ -5,6 +5,7 @@
#include "game/save_file.h"
#include "game/game_init.h"
#include "config.h"
extern u8 gDecompressionHeap[];
@@ -18,7 +19,7 @@ extern u8 gIdleThreadStack[];
extern u8 gThread3Stack[];
extern u8 gThread4Stack[];
extern u8 gThread5Stack[];
#ifdef VERSION_SH
#if ENABLE_RUMBLE
extern u8 gThread6Stack[];
#endif
+3 -3
View File
@@ -31,7 +31,7 @@
static u16 gRandomSeed16;
// Unused function that directly jumps to a behavior command and resets the object's stack index.
static void goto_behavior_unused(const BehaviorScript *bhvAddr) {
UNUSED static void goto_behavior_unused(const BehaviorScript *bhvAddr) {
gCurBhvCommand = segmented_to_virtual(bhvAddr);
gCurrentObject->bhvStackIndex = 0;
}
@@ -107,7 +107,7 @@ static uintptr_t cur_obj_bhv_stack_pop(void) {
return bhvAddr;
}
static void stub_behavior_script_1(void) {
UNUSED static void stub_behavior_script_1(void) {
for (;;) {
;
}
@@ -687,7 +687,7 @@ static s32 bhv_cmd_begin(void) {
// It cannot be simply re-added to the table, as unlike all other bhv commands it takes a parameter.
// Theoretically this command would have been of variable size.
// Included below is a modified/repaired version of this function that would work properly.
static void bhv_cmd_set_int_random_from_table(s32 tableSize) {
UNUSED static void bhv_cmd_set_int_random_from_table(s32 tableSize) {
u8 field = BHV_CMD_GET_2ND_U8(0);
s32 table[16];
s32 i;
+1 -1
View File
@@ -827,7 +827,7 @@ struct LevelCommand *level_script_execute(struct LevelCommand *cmd) {
}
profiler_log_thread5_time(LEVEL_SCRIPT_EXECUTE);
init_render_image();
init_rcp();
render_game();
end_master_display_list();
alloc_display_list(0);
+8 -1
View File
@@ -15,7 +15,14 @@ int gSplineState;
// These functions have bogus return values.
// Disable the compiler warning.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreturn-local-addr"
#ifdef __GNUC__
#if defined(__clang__)
#pragma GCC diagnostic ignored "-Wreturn-stack-address"
#else
#pragma GCC diagnostic ignored "-Wreturn-local-addr"
#endif
#endif
/// Copy vector 'src' to 'dest'
void *vec3f_copy(Vec3f dest, Vec3f src) {
+1 -1
View File
@@ -369,7 +369,7 @@ f32 unused_obj_find_floor_height(struct Object *obj) {
*/
struct FloorGeometry sFloorGeo;
static u8 unused8038BE50[0x40];
UNUSED static u8 unused8038BE50[0x40];
/**
* Return the floor height underneath (xPos, yPos, zPos) and populate `floorGeo`
+2 -2
View File
@@ -291,7 +291,7 @@ static void add_surface(struct Surface *surface, s32 dynamic) {
}
}
static void stub_surface_load_1(void) {
UNUSED static void stub_surface_load_1(void) {
}
/**
@@ -653,7 +653,7 @@ void clear_dynamic_surfaces(void) {
}
}
static void unused_80383604(void) {
UNUSED static void unused_80383604(void) {
}
/**
+10 -8
View File
@@ -21,6 +21,7 @@
#include "engine/geo_layout.h"
#include "save_file.h"
#include "level_table.h"
#include "dialog_ids.h"
struct SpawnInfo gPlayerSpawnInfos[1];
struct GraphNode *D_8033A160[0x100];
@@ -32,7 +33,7 @@ s16 gCurrCourseNum;
s16 gCurrActNum;
s16 gCurrAreaIndex;
s16 gSavedCourseNum;
s16 gPauseScreenMode;
s16 gMenuOptSelectIndex;
s16 gSaveOptSelectIndex;
struct SpawnInfo *gMarioSpawnInfo = &gPlayerSpawnInfos[0];
@@ -196,8 +197,8 @@ void clear_areas(void) {
gAreaData[i].unused28 = NULL;
gAreaData[i].whirlpools[0] = NULL;
gAreaData[i].whirlpools[1] = NULL;
gAreaData[i].dialog[0] = 255;
gAreaData[i].dialog[1] = 255;
gAreaData[i].dialog[0] = DIALOG_NONE;
gAreaData[i].dialog[1] = DIALOG_NONE;
gAreaData[i].musicParam = 0;
gAreaData[i].musicParam2 = 0;
}
@@ -373,19 +374,20 @@ void render_game(void) {
render_text_labels();
do_cutscene_handler();
print_displaying_credits_entry();
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH,
SCREEN_HEIGHT - BORDER_HEIGHT);
gPauseScreenMode = render_menus_and_dialogs();
if (gPauseScreenMode != 0) {
gSaveOptSelectIndex = gPauseScreenMode;
gMenuOptSelectIndex = render_menus_and_dialogs();
if (gMenuOptSelectIndex != MENU_OPT_NONE) {
gSaveOptSelectIndex = gMenuOptSelectIndex;
}
if (D_8032CE78 != NULL) {
make_viewport_clip_rect(D_8032CE78);
} else
} else {
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH,
SCREEN_HEIGHT - BORDER_HEIGHT);
}
if (gWarpTransition.isActive) {
if (gWarpTransDelay == 0) {
+19 -1
View File
@@ -118,6 +118,24 @@ struct WarpTransition
/*0x04*/ struct WarpTransitionData data;
};
enum MenuOption {
MENU_OPT_NONE,
MENU_OPT_1,
MENU_OPT_2,
MENU_OPT_3,
MENU_OPT_DEFAULT = MENU_OPT_1,
// Course Pause Menu
MENU_OPT_CONTINUE = MENU_OPT_1,
MENU_OPT_EXIT_COURSE = MENU_OPT_2,
MENU_OPT_CAMERA_ANGLE_R = MENU_OPT_3,
// Save Menu
MENU_OPT_SAVE_AND_CONTINUE = MENU_OPT_1,
MENU_OPT_SAVE_AND_QUIT = MENU_OPT_2,
MENU_OPT_CONTINUE_DONT_SAVE = MENU_OPT_3
};
extern struct GraphNode **gLoadedGraphNodes;
extern struct SpawnInfo gPlayerSpawnInfos[];
extern struct GraphNode *D_8033A160[];
@@ -127,7 +145,7 @@ extern s16 gCurrCourseNum;
extern s16 gCurrActNum;
extern s16 gCurrAreaIndex;
extern s16 gSavedCourseNum;
extern s16 gPauseScreenMode;
extern s16 gMenuOptSelectIndex;
extern s16 gSaveOptSelectIndex;
extern struct SpawnInfo *gMarioSpawnInfo;
+13 -18
View File
@@ -23,6 +23,7 @@
#include "level_table.h"
#include "level_update.h"
#include "levels/bob/header.h"
#include "levels/bowser_3/header.h"
#include "levels/castle_inside/header.h"
#include "levels/hmc/header.h"
#include "main.h"
@@ -61,14 +62,6 @@ struct Struct8032F34C {
const void *segAddr;
};
struct Struct8032F698 {
void *unk0;
s16 unk1;
s16 unk2;
s16 unk3;
s16 unk4;
};
struct Struct802C0DF0 {
u8 unk0;
u8 unk1;
@@ -89,10 +82,10 @@ struct OpenableGrill {
const Collision *collision;
};
s32 D_8032F0C0[] = { SAVE_FLAG_HAVE_WING_CAP, SAVE_FLAG_HAVE_METAL_CAP, SAVE_FLAG_HAVE_VANISH_CAP };
static s32 sCapSaveFlags[] = { SAVE_FLAG_HAVE_WING_CAP, SAVE_FLAG_HAVE_METAL_CAP, SAVE_FLAG_HAVE_VANISH_CAP };
// Boo Roll
s16 D_8032F0CC[] = { 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046, 2775,
static s16 sBooHitRotations[] = { 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046, 2775,
2517, 2271, 2039, 1818, 1611, 1416, 1233, 1063, 906, 761, 629,
509, 402, 308, 226, 157, 100, 56, 25, 4, 0 };
@@ -115,21 +108,21 @@ s16 D_8032F0CC[] = { 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046,
#include "behaviors/white_puff_explode.inc.c"
// not in behavior file
struct SpawnParticlesInfo D_8032F270 = { 2, 20, MODEL_MIST, 0, 40, 5, 30, 20, 252, 30, 330.0f, 10.0f };
struct SpawnParticlesInfo sMistParticles = { 2, 20, MODEL_MIST, 0, 40, 5, 30, 20, 252, 30, 330.0f, 10.0f };
// generate_wind_puffs/dust (something like that)
void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size) {
D_8032F270.sizeBase = size;
D_8032F270.sizeRange = size / 20.0;
D_8032F270.offsetY = offsetY;
sMistParticles.sizeBase = size;
sMistParticles.sizeRange = size / 20.0;
sMistParticles.offsetY = offsetY;
if (count == 0) {
D_8032F270.count = 20;
sMistParticles.count = 20;
} else if (count > 20) {
D_8032F270.count = count;
sMistParticles.count = count;
} else {
D_8032F270.count = 4;
sMistParticles.count = 4;
}
cur_obj_spawn_particles(&D_8032F270);
cur_obj_spawn_particles(&sMistParticles);
}
#include "behaviors/sparkle_spawn_star.inc.c"
@@ -205,6 +198,8 @@ void spawn_sparkle_particles(s32 n, s32 a1, s32 a2, s32 r) {
#include "behaviors/bowser_key.inc.c"
#include "behaviors/bullet_bill.inc.c"
#include "behaviors/bowser.inc.c"
#include "behaviors/bowser_falling_platform.inc.c"
#include "behaviors/bowser_flame.inc.c"
#include "behaviors/blue_fish.inc.c"
// Not in behavior file, duplicate of vec3f_copy except without bad return.
+1 -1
View File
@@ -231,7 +231,7 @@ void bhv_big_boo_loop(void);
void bhv_courtyard_boo_triplet_init(void);
void obj_set_secondary_camera_focus(void);
void bhv_boo_loop(void);
void bhv_boo_boss_spawned_bridge_loop(void);
void bhv_boo_staircase(void);
void bhv_bbh_tilting_trap_platform_loop(void);
void bhv_haunted_bookshelf_loop(void);
void bhv_merry_go_round_loop(void);
+2 -2
View File
@@ -87,14 +87,14 @@ static void beta_boo_key_dropped_loop(void) {
if (obj_check_if_collided_with_object(o, gMarioObject)) {
// This interaction status is 0x01, the first interaction status flag.
// It was only used for Hoot in the final game, but it seems it could've
// done something else or held some special meaning in beta.
// treated as a TRUE/FALSE statement or held some special meaning in beta.
// Earlier, in beta_boo_key_drop (called when the parent boo is killed),
// o->parentObj is set to the parent boo's parentObj. This means that
// here, the parentObj is actually the parent of the old parent boo.
// One theory about this code is that there was a boo spawner, which
// spawned "false" boos and one "true" boo with the key, and the player
// was intended to find the one with the key to progress.
o->parentObj->oInteractStatus = INT_STATUS_HOOT_GRABBED_BY_MARIO;
o->parentObj->oInteractStatus = TRUE;
// Delete the object and spawn sparkles
obj_mark_for_deletion(o);
+4 -4
View File
@@ -46,7 +46,7 @@ void bobomb_check_interactions(void) {
obj_set_hitbox(o, &sBobombHitbox);
if ((o->oInteractStatus & INT_STATUS_INTERACTED) != 0)
{
if ((o->oInteractStatus & INT_STATUS_MARIO_UNK1) != 0)
if ((o->oInteractStatus & INT_STATUS_MARIO_KNOCKBACK_DMG) != 0)
{
o->oMoveAngleYaw = gMarioObject->header.gfx.angle[1];
o->oForwardVel = 25.0;
@@ -344,7 +344,7 @@ void bobomb_buddy_cannon_dialog(s16 dialogFirstText, s16 dialogSecondText) {
break;
case BOBOMB_BUDDY_CANNON_STOP_TALKING:
set_mario_npc_dialog(0);
set_mario_npc_dialog(MARIO_DIALOG_STOP);
o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP;
o->oBobombBuddyHasTalkedToMario = BOBOMB_BUDDY_HAS_TALKED;
@@ -356,14 +356,14 @@ void bobomb_buddy_cannon_dialog(s16 dialogFirstText, s16 dialogSecondText) {
}
void bobomb_buddy_act_talk(void) {
if (set_mario_npc_dialog(1) == 2) {
if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_FRONT) == MARIO_DIALOG_STATUS_SPEAK) {
o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP;
switch (o->oBobombBuddyRole) {
case BOBOMB_BUDDY_ROLE_ADVICE:
if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, o->oBehParams2ndByte)
!= BOBOMB_BUDDY_BP_STYPE_GENERIC) {
set_mario_npc_dialog(0);
set_mario_npc_dialog(MARIO_DIALOG_STOP);
o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP;
o->oBobombBuddyHasTalkedToMario = BOBOMB_BUDDY_HAS_TALKED;
+10 -10
View File
@@ -197,8 +197,8 @@ static void boo_move_during_hit(s32 roll, f32 fVel) {
o->oMoveAngleYaw = o->oBooMoveYawDuringHit;
if (roll != FALSE) {
o->oFaceAngleYaw += D_8032F0CC[o->oTimer];
o->oFaceAngleRoll += D_8032F0CC[o->oTimer];
o->oFaceAngleYaw += sBooHitRotations[o->oTimer];
o->oFaceAngleRoll += sBooHitRotations[o->oTimer];
}
}
@@ -223,7 +223,7 @@ static s32 boo_update_after_bounced_on(f32 a0) {
}
if (o->oTimer < 32) {
boo_move_during_hit(FALSE, D_8032F0CC[o->oTimer]/5000.0f * a0);
boo_move_during_hit(FALSE, sBooHitRotations[o->oTimer]/5000.0f * a0);
} else {
cur_obj_become_tangible();
boo_reset_after_hit();
@@ -243,7 +243,7 @@ static s32 big_boo_update_during_nonlethal_hit(f32 a0) {
}
if (o->oTimer < 32) {
boo_move_during_hit(TRUE, D_8032F0CC[o->oTimer]/5000.0f * a0);
boo_move_during_hit(TRUE, sBooHitRotations[o->oTimer]/5000.0f * a0);
} else if (o->oTimer < 48) {
big_boo_shake_after_hit();
} else {
@@ -464,7 +464,7 @@ static void boo_act_4(void) {
dialogID = DIALOG_107;
}
if (cur_obj_update_dialog(2, 2, dialogID, 0)) {
if (cur_obj_update_dialog(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_TEXT_DEFAULT, dialogID, 0)) {
create_sound_spawner(SOUND_OBJ_DYING_ENEMY1);
obj_mark_for_deletion(o);
@@ -644,9 +644,9 @@ static void big_boo_act_4(void) {
if (o->oTimer > 60 && o->oDistanceToMario < 600.0f) {
obj_set_pos(o, 973, 0, 717);
spawn_object_relative(0, 0, 0, 0, o, MODEL_BBH_STAIRCASE_STEP, bhvBooBossSpawnedBridge);
spawn_object_relative(1, 0, 0, -200, o, MODEL_BBH_STAIRCASE_STEP, bhvBooBossSpawnedBridge);
spawn_object_relative(2, 0, 0, 200, o, MODEL_BBH_STAIRCASE_STEP, bhvBooBossSpawnedBridge);
spawn_object_relative(0, 0, 0, 0, o, MODEL_BBH_STAIRCASE_STEP, bhvBooStaircase);
spawn_object_relative(1, 0, 0, -200, o, MODEL_BBH_STAIRCASE_STEP, bhvBooStaircase);
spawn_object_relative(2, 0, 0, 200, o, MODEL_BBH_STAIRCASE_STEP, bhvBooStaircase);
obj_mark_for_deletion(o);
}
@@ -863,7 +863,7 @@ void bhv_boo_in_castle_loop(void) {
cur_obj_move_using_fvel_and_gravity();
}
void bhv_boo_boss_spawned_bridge_loop(void) {
void bhv_boo_staircase(void) {
f32 targetY;
switch (o->oBehParams2ndByte) {
@@ -898,7 +898,7 @@ void bhv_boo_boss_spawned_bridge_loop(void) {
cur_obj_play_sound_2(SOUND_GENERAL_UNKNOWN4_LOWPRIO);
}
if (cur_obj_move_up_and_down(o->oTimer)) {
if (jiggle_bbh_stair(o->oTimer)) {
o->oAction++;
}
+6
View File
@@ -79,6 +79,9 @@ void bowling_ball_set_waypoints(void) {
void bhv_bowling_ball_roll_loop(void) {
s16 collisionFlags;
s32 sp18;
#ifdef AVOID_UB
sp18 = 0;
#endif
bowling_ball_set_waypoints();
collisionFlags = object_step();
@@ -109,6 +112,9 @@ void bhv_bowling_ball_roll_loop(void) {
void bhv_bowling_ball_initializeLoop(void) {
s32 sp1c;
#ifdef AVOID_UB
sp1c = 0;
#endif
bowling_ball_set_waypoints();
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,90 @@
struct BowserFallingPlatformData {
const Collision *collision;
s16 posX;
s16 posZ;
s16 angle;
};
struct BowserFallingPlatformData sBowserFallingPlatform[] = {
{ NULL, 0, 0, 0 },
{ bowser_3_seg7_collision_07004B94, -800, -1000, -20992 },
{ bowser_3_seg7_collision_07004C18, -1158, 390, -18432 },
{ bowser_3_seg7_collision_07004C9C, -1158, 390, -7680 },
{ bowser_3_seg7_collision_07004D20, 0, 1240, -6144 },
{ bowser_3_seg7_collision_07004DA4, 0, 1240, 6144 },
{ bowser_3_seg7_collision_07004E28, 1158, 390, 7680 },
{ bowser_3_seg7_collision_07004EAC, 1158, 390, 18432 },
{ bowser_3_seg7_collision_07004F30, 800, -1000, 20992 },
{ bowser_3_seg7_collision_07004FB4, 800, -1000, -31744 },
{ bowser_3_seg7_collision_07005038, -800, -1000, 31744 }
};
void falling_bowser_plat_act_start(void) {
o->oBitsPlatformBowser = cur_obj_nearest_object_with_behavior(bhvBowser);
obj_set_collision_data(o, sBowserFallingPlatform[o->oBehParams2ndByte].collision);
if (o->oBitsPlatformBowser != 0)
o->oAction = BOWSER_BITS_PLAT_ACT_CHECK;
}
void falling_bowser_plat_act_check(void) {
UNUSED s32 unused;
struct Object *bowser = o->oBitsPlatformBowser;
if (bowser->platform == o) {
if (bowser->oAction == BOWSER_ACT_BIG_JUMP && bowser->oBowserStatus & BOWSER_STATUS_BIG_JUMP) {
o->oAction = BOWSER_BITS_PLAT_ACT_FALL;
}
}
if (bowser->oHealth == 1 && (bowser->oAction == BOWSER_ACT_DANCE || bowser->oHeldState != HELD_FREE)) {
o->oSubAction = 1;
}
if (o->oSubAction == 0) {
o->oBitsPlatformTimer = 0;
} else {
if ((gDebugInfo[4][6] + 20) * (o->oBehParams2ndByte - 1) < o->oBitsPlatformTimer)
o->oAction = BOWSER_BITS_PLAT_ACT_FALL;
o->oBitsPlatformTimer++;
}
}
void falling_bowser_plat_act_fall(void) {
Vec3f pos;
s16 angle;
f32 val;
UNUSED struct Object *bowser = o->oBitsPlatformBowser;
if (o->oTimer == 0 || o->oTimer == 22) {
cur_obj_play_sound_2(SOUND_GENERAL_BOWSER_PLATFORM_2);
}
if (o->oTimer < 22) {
set_environmental_camera_shake(SHAKE_ENV_FALLING_BITS_PLAT);
o->oVelY = 8.0f;
o->oGravity = 0.0f;
} else
o->oGravity = -4.0f;
if ((o->oTimer & 1) == 0 && o->oTimer < 14) {
angle = sBowserFallingPlatform[o->oBehParams2ndByte].angle + (gDebugInfo[4][1] << 8);
val = -(o->oTimer / 2) * 290 + 1740;
vec3f_copy_2(pos, &o->oPosX);
o->oPosX = sBowserFallingPlatform[o->oBehParams2ndByte].posX + sins(angle + 0x14B0) * val;
o->oPosZ = sBowserFallingPlatform[o->oBehParams2ndByte].posZ + coss(angle + 0x14B0) * val;
o->oPosY = 307.0f;
spawn_mist_particles_variable(4, 0, 100.0f);
o->oPosX = sBowserFallingPlatform[o->oBehParams2ndByte].posX + sins(angle - 0x14B0) * val;
o->oPosZ = sBowserFallingPlatform[o->oBehParams2ndByte].posZ + coss(angle - 0x14B0) * val;
spawn_mist_particles_variable(4, 0, 100);
vec3f_copy_2(&o->oPosX, pos);
}
cur_obj_move_using_fvel_and_gravity();
if (o->oTimer > 300) {
obj_mark_for_deletion(o);
}
}
void (*sFallingBowserPlatformActions[])(void) = {
falling_bowser_plat_act_start,
falling_bowser_plat_act_check,
falling_bowser_plat_act_fall,
};
void bhv_falling_bowser_platform_loop(void) {
cur_obj_call_action_function(sFallingBowserPlatformActions);
}
+263
View File
@@ -0,0 +1,263 @@
struct ObjectHitbox sGrowingBowserFlameHitbox = {
/* interactType: */ INTERACT_FLAME,
/* downOffset: */ 20,
/* damageOrCoinValue: */ 1,
/* health: */ 0,
/* numLootCoins: */ 0,
/* radius: */ 10,
/* height: */ 40,
/* hurtboxRadius: */ 0,
/* hurtboxHeight: */ 0,
};
struct ObjectHitbox sBowserFlameHitbox = {
/* interactType: */ INTERACT_FLAME,
/* downOffset: */ 0,
/* damageOrCoinValue: */ 1,
/* health: */ 0,
/* numLootCoins: */ 0,
/* radius: */ 10,
/* height: */ 40,
/* hurtboxRadius: */ 0,
/* hurtboxHeight: */ 0,
};
void bowser_flame_despawn(void) {
obj_mark_for_deletion(o);
spawn_object_with_scale(o, MODEL_NONE, bhvBlackSmokeUpward, 1.0f);
if (random_float() < 0.1) {
spawn_object(o, MODEL_YELLOW_COIN, bhvTemporaryYellowCoin);
}
}
s32 bowser_flame_should_despawn(s32 maxTime) {
if (maxTime < o->oTimer) {
return TRUE;
}
// Flames should despawn if they fall off the arena.
if (o->oFloorType == SURFACE_BURNING) {
return TRUE;
}
if (o->oFloorType == SURFACE_DEATH_PLANE) {
return TRUE;
}
return FALSE;
}
void bhv_flame_bowser_init(void) {
o->oAnimState = (s32)(random_float() * 10.0f);
o->oMoveAngleYaw = random_u16();
if (random_float() < 0.2) {
o->oVelY = 80.0f;
} else {
o->oVelY = 20.0f;
}
o->oForwardVel = 10.0f;
o->oGravity = -1.0f;
o->oFlameScale = random_float() + 1.0f;
}
void bhv_flame_large_burning_out_init(void) {
o->oAnimState = (s32)(random_float() * 10.0f);
o->oMoveAngleYaw = random_u16();
o->oVelY = 10.0f;
o->oForwardVel = 0.0f;
o->oFlameScale = 7.0f;
}
void bowser_flame_move(void) {
s32 timer;
timer = ((o->oFlameSpeedTimerOffset + gGlobalTimer) & 0x3F) << 10;
o->oPosX += sins(o->oMoveAngleYaw) * sins(timer) * 4.0f;
o->oPosZ += coss(o->oMoveAngleYaw) * sins(timer) * 4.0f;
}
void bhv_flame_bowser_loop(void) {
cur_obj_update_floor_and_walls();
cur_obj_move_standard(78);
if (o->oVelY < -4.0f) {
o->oVelY = -4.0f;
}
if (o->oAction == 0) {
cur_obj_become_intangible();
bowser_flame_move();
if (o->oMoveFlags & OBJ_MOVE_LANDED) {
o->oAction++;
if (cur_obj_has_behavior(bhvFlameLargeBurningOut)) {
o->oFlameScale = 8.0f;
} else {
o->oFlameScale = random_float() * 2 + 6.0f;
}
o->oForwardVel = 0;
o->oVelY = 0;
o->oGravity = 0;
}
} else {
cur_obj_become_tangible();
if (o->oTimer > o->oFlameScale * 10 + 5.0f) {
o->oFlameScale -= 0.15;
if (o->oFlameScale <= 0) {
bowser_flame_despawn();
}
}
}
cur_obj_scale(o->oFlameScale);
o->oGraphYOffset = o->header.gfx.scale[1] * 14.0f;
obj_set_hitbox(o, &sBowserFlameHitbox);
}
void bhv_flame_moving_forward_growing_init(void) {
o->oForwardVel = 30.0f;
obj_translate_xz_random(o, 80.0f);
o->oAnimState = (s32)(random_float() * 10.0f);
o->oFlameScale = 3.0f;
}
void bhv_flame_moving_forward_growing_loop(void) {
UNUSED s32 unused;
UNUSED struct Object *flame;
obj_set_hitbox(o, &sGrowingBowserFlameHitbox);
o->oFlameScale = o->oFlameScale + 0.5;
cur_obj_scale(o->oFlameScale);
if (o->oMoveAnglePitch > 0x800) {
o->oMoveAnglePitch -= 0x200;
}
cur_obj_set_pos_via_transform();
cur_obj_update_floor_height();
if (o->oFlameScale > 30.0f) {
obj_mark_for_deletion(o);
}
if (o->oPosY < o->oFloorHeight) {
o->oPosY = o->oFloorHeight;
flame = spawn_object(o, MODEL_RED_FLAME, bhvFlameBowser);
obj_mark_for_deletion(o);
}
}
void bhv_flame_floating_landing_init(void) {
o->oAnimState = (s32)(random_float() * 10.0f);
o->oMoveAngleYaw = random_u16();
if (o->oBehParams2ndByte != 0) {
o->oForwardVel = random_float() * 5.0f;
} else {
o->oForwardVel = random_float() * 70.0f;
}
o->oVelY = random_float() * 20.0f;
o->oGravity = -1.0f;
o->oFlameSpeedTimerOffset = random_float() * 64.0f;
}
f32 sFlameFloatingYLimit[] = { -8.0f, -6.0f, -3.0f };
void bhv_flame_floating_landing_loop(void) {
UNUSED s32 unused;
cur_obj_update_floor_and_walls();
cur_obj_move_standard(78);
bowser_flame_move();
if (bowser_flame_should_despawn(900)) {
obj_mark_for_deletion(o);
}
if (o->oVelY < sFlameFloatingYLimit[o->oBehParams2ndByte]) {
o->oVelY = sFlameFloatingYLimit[o->oBehParams2ndByte];
}
if (o->oMoveFlags & OBJ_MOVE_LANDED) {
if (o->oBehParams2ndByte == 0) {
spawn_object(o, MODEL_RED_FLAME, bhvFlameLargeBurningOut);
} else {
spawn_object(o, MODEL_NONE, bhvBlueFlamesGroup); //? wonder if they meant MODEL_BLUE_FLAME?
}
obj_mark_for_deletion(o);
}
o->oGraphYOffset = o->header.gfx.scale[1] * 14.0f;
}
void bhv_blue_bowser_flame_init(void) {
obj_translate_xz_random(o, 80.0f);
o->oAnimState = (s32)(random_float() * 10.0f);
o->oVelY = 7.0f;
o->oForwardVel = 35.0f;
o->oFlameScale = 3.0f;
o->oFlameUnusedRand = random_float() * 0.5;
o->oGravity = 1.0f;
o->oFlameSpeedTimerOffset = (s32)(random_float() * 64.0f);
}
void bhv_blue_bowser_flame_loop(void) {
s32 i;
obj_set_hitbox(o, &sGrowingBowserFlameHitbox);
if (o->oFlameScale < 16.0f) {
o->oFlameScale = o->oFlameScale + 0.5;
}
cur_obj_scale(o->oFlameScale);
cur_obj_update_floor_and_walls();
cur_obj_move_standard(78);
if (o->oTimer > 0x14) {
if (o->oBehParams2ndByte == 0) {
for (i = 0; i < 3; i++) {
spawn_object_relative_with_scale(0, 0, 0, 0, 5.0f, o, MODEL_RED_FLAME,
bhvFlameFloatingLanding);
}
} else {
spawn_object_relative_with_scale(1, 0, 0, 0, 8.0f, o, MODEL_BLUE_FLAME,
bhvFlameFloatingLanding);
spawn_object_relative_with_scale(2, 0, 0, 0, 8.0f, o, MODEL_BLUE_FLAME,
bhvFlameFloatingLanding);
}
obj_mark_for_deletion(o);
}
}
void bhv_flame_bouncing_init(void) {
o->oAnimState = (s32)(random_float() * 10.0f);
o->oVelY = 30.0f;
o->oForwardVel = 20.0f;
o->oFlameScale = o->header.gfx.scale[0];
o->oFlameSpeedTimerOffset = (s32)(random_float() * 64.0f);
}
void bhv_flame_bouncing_loop(void) {
struct Object *bowser;
if (o->oTimer == 0) {
o->oFlameBowser = cur_obj_nearest_object_with_behavior(bhvBowser);
}
bowser = o->oFlameBowser;
o->oForwardVel = 15.0f;
o->oBounciness = -1.0f;
cur_obj_scale(o->oFlameScale);
obj_set_hitbox(o, &sGrowingBowserFlameHitbox);
cur_obj_update_floor_and_walls();
cur_obj_move_standard(78);
if (bowser_flame_should_despawn(300)) {
obj_mark_for_deletion(o);
}
if (bowser != NULL) {
if (bowser->oHeldState == HELD_FREE) {
if (lateral_dist_between_objects(o, bowser) < 300.0f) {
obj_mark_for_deletion(o);
}
}
}
}
void bhv_blue_flames_group_loop(void) {
struct Object *flame;
s32 i;
if (o->oTimer == 0) {
o->oMoveAngleYaw = obj_angle_to_object(o, gMarioObject);
o->oBlueFlameNextScale = 5.0f;
}
if (o->oTimer < 16) {
if ((o->oTimer & 1) == 0) {
for (i = 0; i < 3; i++) {
flame = spawn_object(o, MODEL_BLUE_FLAME, bhvFlameBouncing);
flame->oMoveAngleYaw += i * 0x5555;
flame->header.gfx.scale[0] = o->oBlueFlameNextScale;
}
o->oBlueFlameNextScale -= 0.5;
}
} else {
obj_mark_for_deletion(o);
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ void spawn_triangle_break_particles(s16 numTris, s16 triModel, f32 triSize, s16
triangle->oFaceAngleYaw = triangle->oMoveAngleYaw;
triangle->oFaceAnglePitch = random_u16();
triangle->oVelY = random_f32_around_zero(50.0f);
if (triModel == 138 || triModel == 56) {
if (triModel == MODEL_DIRT_ANIMATION || triModel == MODEL_SL_CRACKED_ICE_CHUNK) {
triangle->oAngleVelPitch = 0xF00;
triangle->oAngleVelYaw = 0x500;
triangle->oForwardVel = 30.0f;
+1 -1
View File
@@ -43,7 +43,7 @@ void small_breakable_box_act_move(void) {
if (sp1E & 2) {
spawn_mist_particles();
spawn_triangle_break_particles(20, 138, 0.7f, 3);
spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 0.7f, 3);
obj_spawn_yellow_coins(o, 3);
create_sound_spawner(SOUND_GENERAL_BREAK_BOX);
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
+8 -3
View File
@@ -32,7 +32,7 @@ static void camera_lakitu_intro_act_trigger_cutscene(void) {
&& gMarioObject->oPosZ > -2000.0f && gMarioObject->oPosZ < -177.0f
&& gMarioObject->oPosZ < -177.0f) // always double check your conditions
{
if (set_mario_npc_dialog(2) == 1) {
if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_START) {
o->oAction = CAMERA_LAKITU_INTRO_ACT_SPAWN_CLOUD;
}
}
@@ -42,7 +42,7 @@ static void camera_lakitu_intro_act_trigger_cutscene(void) {
* Warp up into the air and spawn cloud, then enter the TODO action.
*/
static void camera_lakitu_intro_act_spawn_cloud(void) {
if (set_mario_npc_dialog(2) == 2) {
if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_SPEAK) {
o->oAction = CAMERA_LAKITU_INTRO_ACT_UNK2;
o->oPosX = 1800.0f;
@@ -63,6 +63,10 @@ static void camera_lakitu_intro_act_spawn_cloud(void) {
static void camera_lakitu_intro_act_show_dialog(void) {
s16 targetMovePitch;
s16 targetMoveYaw;
#ifdef AVOID_UB
targetMovePitch = 0;
targetMoveYaw = 0;
#endif
cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY);
@@ -115,7 +119,8 @@ static void camera_lakitu_intro_act_show_dialog(void) {
}
}
}
} else if (cur_obj_update_dialog_with_cutscene(2, DIALOG_UNK2_FLAG_0, CUTSCENE_DIALOG, DIALOG_034) != 0) {
} else if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_034)) {
o->oCameraLakituFinishedDialog = TRUE;
}
}
-4
View File
@@ -107,10 +107,6 @@ void (*sOpenedCannonActions[])(void) = { opened_cannon_act_0, opened_cannon_act_
opened_cannon_act_3, opened_cannon_act_4, opened_cannon_act_5,
opened_cannon_act_6 };
u8 unused0EA1FC[] = { 2, 0, 0, 0, 0, 0, 0, 0, 63, 128, 0, 0, 2, 0, 0, 0, 65, 32, 0, 0,
63, 128, 0, 0, 2, 0, 0, 0, 65, 160, 0, 0, 63, 128, 0, 0, 2, 0, 0, 0,
65, 160, 0, 0, 63, 128, 0, 0, 8, 0, 0, 0, 65, 32, 0, 0, 63, 128, 0, 0 };
void bhv_cannon_base_loop(void) {
cur_obj_call_action_function(sOpenedCannonActions);
if (o->oCannonUnkF8)
+11 -5
View File
@@ -1,12 +1,14 @@
// capswitch.c.inc
UNUSED u8 sCapSwitchText[] = { DIALOG_010, DIALOG_011, DIALOG_012 };
void cap_switch_act_0(void) {
o->oAnimState = o->oBehParams2ndByte;
cur_obj_scale(0.5f);
o->oPosY += 71.0f;
spawn_object_relative_with_scale(0, 0, -71, 0, 0.5f, o, MODEL_CAP_SWITCH_BASE, bhvCapSwitchBase);
if (gCurrLevelNum != LEVEL_UNKNOWN_32) {
if (save_file_get_flags() & D_8032F0C0[o->oBehParams2ndByte]) {
if (save_file_get_flags() & sCapSaveFlags[o->oBehParams2ndByte]) {
o->oAction = 3;
o->header.gfx.scale[1] = 0.1f;
} else
@@ -17,7 +19,7 @@ void cap_switch_act_0(void) {
void cap_switch_act_1(void) {
if (cur_obj_is_mario_on_platform()) {
save_file_set_flags(D_8032F0C0[o->oBehParams2ndByte]);
save_file_set_flags(sCapSaveFlags[o->oBehParams2ndByte]);
o->oAction = 2;
cur_obj_play_sound_2(SOUND_GENERAL_ACTIVATE_CAP_SWITCH);
}
@@ -30,13 +32,17 @@ void cap_switch_act_2(void) {
if (o->oTimer == 4) {
cur_obj_shake_screen(SHAKE_POS_SMALL);
spawn_mist_particles();
spawn_triangle_break_particles(60, 139, 0.3f, o->oBehParams2ndByte);
#ifdef VERSION_SH
spawn_triangle_break_particles(60, MODEL_CARTOON_STAR, 0.3f, o->oBehParams2ndByte);
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
}
} else {
sp1C = cur_obj_update_dialog_with_cutscene(1, 0x0C, CUTSCENE_CAP_SWITCH_PRESS, 0);
//! Neither of these flags are defined in this function so they do nothing.
// On an extra note, there's a specific check for this cutscene and
// there's no dialog defined since the cutscene itself calls the dialog.
sp1C = cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_FRONT,
(DIALOG_FLAG_TEXT_RESPONSE | DIALOG_FLAG_UNK_CAPSWITCH), CUTSCENE_CAP_SWITCH_PRESS, 0);
if (sp1C)
o->oAction = 3;
}
+4 -4
View File
@@ -256,8 +256,8 @@ static void chain_chomp_released_trigger_cutscene(void) {
//! Can delay this if we get into a cutscene-unfriendly action after the
// last post ground pound and before this
if (set_mario_npc_dialog(2) == 2 && (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND)
&& cutscene_object(CUTSCENE_STAR_SPAWN, o) == 1) {
if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_SPEAK
&& (o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND) && cutscene_object(CUTSCENE_STAR_SPAWN, o) == 1) {
o->oChainChompReleaseStatus = CHAIN_CHOMP_RELEASED_LUNGE_AROUND;
o->oTimer = 0;
}
@@ -342,7 +342,7 @@ static void chain_chomp_released_jump_away(void) {
*/
static void chain_chomp_released_end_cutscene(void) {
if (cutscene_object(CUTSCENE_STAR_SPAWN, o) == -1) {
set_mario_npc_dialog(0);
set_mario_npc_dialog(MARIO_DIALOG_STOP);
o->oAction = CHAIN_CHOMP_ACT_UNLOAD_CHAIN;
}
}
@@ -536,7 +536,7 @@ void bhv_chain_chomp_gate_update(void) {
spawn_mist_particles_with_sound(SOUND_GENERAL_WALL_EXPLOSION);
set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ);
spawn_mist_particles_variable(0, 0x7F, 200.0f);
spawn_triangle_break_particles(30, 0x8A, 3.0f, 4);
spawn_triangle_break_particles(30, MODEL_DIRT_ANIMATION, 3.0f, 4);
obj_mark_for_deletion(o);
}
}
+16 -1
View File
@@ -1,5 +1,17 @@
// chuckya.c.inc
struct UnusedChuckyaData {
u8 unk0;
f32 unk4;
f32 unk8;
};
struct UnusedChuckyaData sUnusedChuckyaData[] = { { 2, 0.f, 1.f },
{ 2, 10.f, 1.f },
{ 2, 20.f, 1.f },
{ 2, 20.f, 1.f },
{ 8, 10.f, 1.f }};
void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30) {
switch (o->parentObj->oChuckyaUnk88) {
case 0:
@@ -72,6 +84,9 @@ s32 approach_forward_vel(f32 *arr, f32 spC, f32 sp10) {
void chuckya_act_0(void) {
s32 sp3C;
#ifdef AVOID_UB
sp3C = 0;
#endif
UNUSED u8 pad[16];
s32 sp28;
if (o->oTimer == 0)
@@ -197,7 +212,7 @@ void bhv_chuckya_loop(void) {
chuckya_move();
break;
case HELD_HELD:
cur_obj_unrender_and_reset_state(2, 0);
cur_obj_unrender_set_action_and_anim(2, 0);
break;
case HELD_THROWN:
case HELD_DROPPED:
+3 -3
View File
@@ -12,7 +12,7 @@ struct ObjectHitbox sYellowCoinHitbox = {
/* hurtboxHeight: */ 0,
};
s16 D_8032F2A4[][2] = { { 0, -150 }, { 0, -50 }, { 0, 50 }, { 0, 150 },
s16 sCoinArrowPositions[][2] = { { 0, -150 }, { 0, -50 }, { 0, 50 }, { 0, 150 },
{ -50, 100 }, { -100, 50 }, { 50, 100 }, { 100, 50 } };
s32 bhv_coin_sparkles_init(void) {
@@ -161,8 +161,8 @@ void spawn_coin_in_formation(s32 sp50, s32 sp54) {
sp40[1] = sins(sp50 << 13) * 200.0f + 200.0f;
break;
case 4:
sp40[0] = D_8032F2A4[sp50][0];
sp40[2] = D_8032F2A4[sp50][1];
sp40[0] = sCoinArrowPositions[sp50][0];
sp40[2] = sCoinArrowPositions[sp50][1];
break;
}
if (sp54 & 0x10)
+10 -10
View File
@@ -1,10 +1,10 @@
// collide_particles.c.inc
s16 D_8032F2CC[] = { 0xD000, 0, 0x3000, 0, 0xDE67, 0x2199,
0x2199, 0x2199, 0xDE67, 0xDE67, 0x2199, 0xDE67 };
static s16 sTinyTriMovementParams[] = { 0xD000, 0, 0x3000, 0, 0xDE67, 0x2199,
0x2199, 0x2199, 0xDE67, 0xDE67, 0x2199, 0xDE67 };
s16 D_8032F2E4[] = { 0xE000, 0, 0, 0, 0x2000, 0, 0xE99A,
0x1666, 0x1666, 0x1666, 0xE99A, 0xE99A, 0x1666, 0xE99A };
static s16 sTinyStarMovementParams[] = { 0xE000, 0, 0, 0, 0x2000, 0, 0xE99A,
0x1666, 0x1666, 0x1666, 0xE99A, 0xE99A, 0x1666, 0xE99A };
void bhv_punch_tiny_triangle_loop(void) {
s16 sp1E;
@@ -28,9 +28,9 @@ void bhv_punch_tiny_triangle_init(void) {
struct Object *triangle;
for (i = 0; i < 6; i++) {
triangle = spawn_object(o, MODEL_DIRT_ANIMATION, bhvPunchTinyTriangle);
triangle->oMoveAngleYaw = gMarioObject->oMoveAngleYaw + D_8032F2CC[2 * i] + 0x8000;
triangle->oVelY = sins(D_8032F2CC[2 * i + 1]) * 25.0f;
triangle->oForwardVel = coss(D_8032F2CC[2 * i + 1]) * 25.0f;
triangle->oMoveAngleYaw = gMarioObject->oMoveAngleYaw + sTinyTriMovementParams[2 * i] + 0x8000;
triangle->oVelY = sins(sTinyTriMovementParams[2 * i + 1]) * 25.0f;
triangle->oForwardVel = coss(sTinyTriMovementParams[2 * i + 1]) * 25.0f;
}
}
@@ -54,9 +54,9 @@ void bhv_tiny_star_particles_init(void) {
struct Object *particle;
for (i = 0; i < 7; i++) {
particle = spawn_object(o, MODEL_CARTOON_STAR, bhvWallTinyStarParticle);
particle->oMoveAngleYaw = gMarioObject->oMoveAngleYaw + D_8032F2E4[2 * i] + 0x8000;
particle->oVelY = sins(D_8032F2E4[2 * i + 1]) * 25.0f;
particle->oForwardVel = coss(D_8032F2E4[2 * i + 1]) * 25.0f;
particle->oMoveAngleYaw = gMarioObject->oMoveAngleYaw + sTinyStarMovementParams[2 * i] + 0x8000;
particle->oVelY = sins(sTinyStarMovementParams[2 * i + 1]) * 25.0f;
particle->oForwardVel = coss(sTinyStarMovementParams[2 * i + 1]) * 25.0f;
}
}
@@ -79,7 +79,7 @@ void controllable_platform_hit_wall(s8 sp1B) {
D_80331694 = 5;
cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(50, 80);
#endif
}
+9 -9
View File
@@ -6,11 +6,11 @@ struct DoorAction
s32 action;
};
struct DoorAction D_8032F300[] = { { 0x40000, 3 }, { 0x80000, 4 }, { 0x10000, 1 }, { 0x20000, 2 }, { -1, 0 }, };
static struct DoorAction sDoorActions[] = { { 0x40000, 3 }, { 0x80000, 4 }, { 0x10000, 1 }, { 0x20000, 2 }, { -1, 0 }, };
s32 D_8032F328[] = { SOUND_GENERAL_OPEN_WOOD_DOOR, SOUND_GENERAL_OPEN_IRON_DOOR };
static s32 sDoorOpenSounds[] = { SOUND_GENERAL_OPEN_WOOD_DOOR, SOUND_GENERAL_OPEN_IRON_DOOR };
s32 D_8032F330[] = { SOUND_GENERAL_CLOSE_WOOD_DOOR, SOUND_GENERAL_CLOSE_IRON_DOOR };
static s32 sDoorCloseSounds[] = { SOUND_GENERAL_CLOSE_WOOD_DOOR, SOUND_GENERAL_CLOSE_IRON_DOOR };
void door_animation_and_reset(s32 sp18) {
cur_obj_init_animation_with_sound(sp18);
@@ -29,27 +29,27 @@ void set_door_camera_event(void) {
void play_door_open_noise(void) {
s32 sp1C = cur_obj_has_model(MODEL_HMC_METAL_DOOR);
if (o->oTimer == 0) {
cur_obj_play_sound_2(D_8032F328[sp1C]);
cur_obj_play_sound_2(sDoorOpenSounds[sp1C]);
gTimeStopState |= TIME_STOP_MARIO_OPENED_DOOR;
}
if (o->oTimer == 70) {
cur_obj_play_sound_2(D_8032F330[sp1C]);
cur_obj_play_sound_2(sDoorCloseSounds[sp1C]);
}
}
void play_warp_door_open_noise(void) {
s32 sp1C = cur_obj_has_model(MODEL_HMC_METAL_DOOR);
if (o->oTimer == 30)
cur_obj_play_sound_2(D_8032F330[sp1C]);
cur_obj_play_sound_2(sDoorCloseSounds[sp1C]);
}
void bhv_door_loop(void) {
s32 sp1C = 0;
while (D_8032F300[sp1C].flag != (u32)~0) {
if (cur_obj_clear_interact_status_flag(D_8032F300[sp1C].flag)) {
while (sDoorActions[sp1C].flag != (u32)~0) {
if (cur_obj_clear_interact_status_flag(sDoorActions[sp1C].flag)) {
set_door_camera_event();
cur_obj_change_action(D_8032F300[sp1C].action);
cur_obj_change_action(sDoorActions[sp1C].action);
}
sp1C++;
}
+5 -4
View File
@@ -68,7 +68,8 @@ void dorrie_act_lower_head(void) {
if (o->oTimer > 150) {
dorrie_begin_head_raise(FALSE);
} else if (gMarioObject->platform == o) {
if (o->oDorrieForwardDistToMario > 830.0f && set_mario_npc_dialog(2) == 1) {
if (o->oDorrieForwardDistToMario > 830.0f
&& set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_START) {
dorrie_begin_head_raise(TRUE);
} else if (o->oDorrieForwardDistToMario > 320.0f) {
o->oTimer = 0;
@@ -77,7 +78,7 @@ void dorrie_act_lower_head(void) {
#else
if (gMarioObject->platform == o) {
if (o->oDorrieOffsetY == -17.0f && o->oDorrieForwardDistToMario > 780.0f
&& set_mario_npc_dialog(2) == 1) {
&& set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_START) {
dorrie_begin_head_raise(TRUE);
} else if (o->oDorrieForwardDistToMario > 320.0f) {
o->oTimer = 0;
@@ -97,10 +98,10 @@ void dorrie_act_raise_head(void) {
if (cur_obj_check_if_near_animation_end()) {
o->oAction = DORRIE_ACT_MOVE;
} else if (o->oDorrieLiftingMario && o->header.gfx.animInfo.animFrame < 74) {
if (set_mario_npc_dialog(2) == 2) {
if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_SPEAK) {
o->oDorrieHeadRaiseSpeed += 0x1CC;
if (cur_obj_check_anim_frame(73)) {
set_mario_npc_dialog(0);
set_mario_npc_dialog(MARIO_DIALOG_STOP);
}
dorrie_raise_head();
} else {
+12 -13
View File
@@ -1,5 +1,13 @@
// elevator.c.inc
static s16 sElevatorHeights[] = { -51, 0, 0,
-461, 0, 0,
-512, 0, 0,
-2611, 0, 0,
-2360, 0, 0,
214, 0, 0,
-50, 1945, 1 };
void elevator_starting_shake(void) {
cur_obj_play_sound_2(SOUND_GENERAL_QUIET_POUND1);
cur_obj_shake_screen(SHAKE_POS_SMALL);
@@ -84,15 +92,15 @@ void elevator_act_3(void) // nearly identical to action 2
}
void bhv_elevator_init(void) {
s32 sp1C = D_8032F38C[o->oBehParams2ndByte * 3 + 2];
s32 sp1C = sElevatorHeights[o->oBehParams2ndByte * 3 + 2];
if (sp1C == 0) {
o->oElevatorUnkF4 = D_8032F38C[o->oBehParams2ndByte * 3];
o->oElevatorUnkF4 = sElevatorHeights[o->oBehParams2ndByte * 3];
o->oElevatorUnkF8 = o->oHomeY;
o->oElevatorUnkFC = (o->oElevatorUnkF4 + o->oElevatorUnkF8) / 2;
o->oElevatorUnk100 = cur_obj_has_behavior(bhvRrElevatorPlatform);
} else {
o->oElevatorUnkF4 = D_8032F38C[o->oBehParams2ndByte * 3];
o->oElevatorUnkF8 = D_8032F38C[o->oBehParams2ndByte * 3 + 1];
o->oElevatorUnkF4 = sElevatorHeights[o->oBehParams2ndByte * 3];
o->oElevatorUnkF8 = sElevatorHeights[o->oBehParams2ndByte * 3 + 1];
o->oElevatorUnkFC = (o->oElevatorUnkF4 + o->oElevatorUnkF8) / 2;
o->oElevatorUnk100 = 2;
}
@@ -101,15 +109,6 @@ void bhv_elevator_init(void) {
void (*sElevatorActions[])(void) = { elevator_act_0, elevator_act_1, elevator_act_2, elevator_act_3,
elevator_act_4 };
struct SpawnParticlesInfo D_8032F3CC = { 3, 20, MODEL_MIST, 20, 10, 5, 0, 0, 0, 30, 30.0f, 1.5f };
struct SpawnParticlesInfo D_8032F3E0 = { 0, 5, MODEL_SAND_DUST, 0, 0, 20, 20, 0, 252, 30, 5.0f, 2.0f };
s16 D_8032F3F4[] = { 2, -8, 1, 4 };
struct SpawnParticlesInfo D_8032F3FC = { 0, 5, MODEL_WHITE_PARTICLE_DL, 0, 0, 20, 20, 0, 252, 30,
2.0f, 2.0f };
void bhv_elevator_loop(void) {
cur_obj_call_action_function(sElevatorActions);
}
+4 -4
View File
@@ -38,7 +38,7 @@ void bhv_rotating_exclamation_box_loop(void) {
void exclamation_box_act_0(void) {
if (o->oBehParams2ndByte < 3) {
o->oAnimState = o->oBehParams2ndByte;
if ((save_file_get_flags() & D_8032F0C0[o->oBehParams2ndByte])
if ((save_file_get_flags() & sCapSaveFlags[o->oBehParams2ndByte])
|| ((o->oBehParams >> 24) & 0xFF) != 0)
o->oAction = 2;
else
@@ -55,7 +55,7 @@ void exclamation_box_act_1(void) {
spawn_object(o, MODEL_EXCLAMATION_POINT, bhvRotatingExclamationMark);
cur_obj_set_model(MODEL_EXCLAMATION_BOX_OUTLINE);
}
if ((save_file_get_flags() & D_8032F0C0[o->oBehParams2ndByte])
if ((save_file_get_flags() & sCapSaveFlags[o->oBehParams2ndByte])
|| ((o->oBehParams >> 24) & 0xFF) != 0) {
o->oAction = 2;
cur_obj_set_model(MODEL_EXCLAMATION_BOX);
@@ -78,7 +78,7 @@ void exclamation_box_act_2(void) {
o->oGravity = -8.0f;
o->oFloorHeight = o->oPosY;
o->oAction = 3;
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
}
@@ -124,7 +124,7 @@ void exclamation_box_spawn_contents(struct Struct802C0DF0 *a0, u8 a1) {
void exclamation_box_act_4(void) {
exclamation_box_spawn_contents(sExclamationBoxContents, o->oBehParams2ndByte);
spawn_mist_particles_variable(0, 0, 46.0f);
spawn_triangle_break_particles(20, 139, 0.3f, o->oAnimState);
spawn_triangle_break_particles(20, MODEL_CARTOON_STAR, 0.3f, o->oAnimState);
create_sound_spawner(SOUND_GENERAL_BREAK_BOX);
if (o->oBehParams2ndByte < 3) {
o->oAction = 5;
+2 -2
View File
@@ -63,7 +63,7 @@ static void eyerok_boss_act_wake_up(void) {
}
static void eyerok_boss_act_show_intro_text(void) {
if (cur_obj_update_dialog_with_cutscene(2, 0, CUTSCENE_DIALOG, DIALOG_117)) {
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_NONE, CUTSCENE_DIALOG, DIALOG_117)) {
o->oAction = EYEROK_BOSS_ACT_FIGHT;
}
}
@@ -117,7 +117,7 @@ static void eyerok_boss_act_fight(void) {
static void eyerok_boss_act_die(void) {
if (o->oTimer == 60) {
if (cur_obj_update_dialog_with_cutscene(2, 0, CUTSCENE_DIALOG, DIALOG_118)) {
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_NONE, CUTSCENE_DIALOG, DIALOG_118)) {
spawn_default_star(0.0f, -900.0f, -3700.0f);
} else {
o->oTimer -= 1;
@@ -1,15 +1,15 @@
// falling_rising_platform.c.inc
void bhv_squishable_platform_loop(void) {
o->header.gfx.scale[1] = (sins(o->oPlatformTimer) + 1.0) * 0.3 + 0.4;
o->oPlatformTimer += 0x80;
o->header.gfx.scale[1] = (sins(o->oBitfsPlatformTimer) + 1.0) * 0.3 + 0.4;
o->oBitfsPlatformTimer += 0x80;
}
void bhv_bitfs_sinking_platform_loop(void) {
o->oPosY -=
sins(o->oPlatformTimer)
sins(o->oBitfsPlatformTimer)
* 0.58; //! f32 double conversion error accumulates on Wii VC causing the platform to rise up
o->oPlatformTimer += 0x100;
o->oBitfsPlatformTimer += 0x100;
}
// TODO: Named incorrectly. fix
@@ -21,8 +21,8 @@ void bhv_bitfs_sinking_cage_platform_loop(void) {
if (o->oBehParams2ndByte != 0) {
if (o->oTimer == 0)
o->oPosY -= 300.0f;
o->oPosY += sins(o->oPlatformTimer) * 7.0f;
o->oPosY += sins(o->oBitfsPlatformTimer) * 7.0f;
} else
o->oPosY -= sins(o->oPlatformTimer) * 3.0f;
o->oPlatformTimer += 0x100;
o->oPosY -= sins(o->oBitfsPlatformTimer) * 3.0f;
o->oBitfsPlatformTimer += 0x100;
}
+1 -1
View File
@@ -51,7 +51,7 @@ void bhv_grand_star_loop(void) {
o->oPosY = o->oHomeY + 200.0f;
grand_star_zero_velocity();
gObjCutsceneDone = 1;
set_mario_npc_dialog(0);
set_mario_npc_dialog(MARIO_DIALOG_STOP);
o->oAction++;
o->oInteractStatus = 0;
cur_obj_play_sound_2(SOUND_GENERAL_GRAND_STAR_JUMP);
+16 -7
View File
@@ -1,25 +1,34 @@
// ground_particles.c.inc
static struct SpawnParticlesInfo sGlobalMistParticles = { 3, 20, MODEL_MIST, 20, 10, 5, 0, 0, 0, 30, 30.0f, 1.5f };
static struct SpawnParticlesInfo sSandParticles = { 0, 5, MODEL_SAND_DUST, 0, 0, 20, 20, 0, 252, 30, 5.0f, 2.0f };
static s16 sSmokeMovementParams[] = { 2, -8, 1, 4 };
static struct SpawnParticlesInfo sSnowParticles = { 0, 5, MODEL_WHITE_PARTICLE_DL, 0, 0, 20, 20, 0, 252, 30,
2.0f, 2.0f };
void bhv_pound_white_puffs_init(void) {
clear_particle_flags(0x8000);
spawn_mist_from_global();
}
void spawn_mist_from_global(void) {
cur_obj_spawn_particles(&D_8032F3CC);
cur_obj_spawn_particles(&sGlobalMistParticles);
}
void bhv_ground_sand_init(void) {
clear_particle_flags(0x4000);
cur_obj_spawn_particles(&D_8032F3E0);
cur_obj_spawn_particles(&sSandParticles);
}
void spawn_smoke_with_velocity(void) {
struct Object *smoke = spawn_object_with_scale(o, MODEL_SMOKE, bhvWhitePuffSmoke2, 1.0f);
smoke->oForwardVel = D_8032F3F4[0];
smoke->oVelY = D_8032F3F4[1];
smoke->oGravity = D_8032F3F4[2];
obj_translate_xyz_random(smoke, D_8032F3F4[3]);
smoke->oForwardVel = sSmokeMovementParams[0];
smoke->oVelY = sSmokeMovementParams[1];
smoke->oGravity = sSmokeMovementParams[2];
obj_translate_xyz_random(smoke, sSmokeMovementParams[3]);
}
// TODO Fix name
@@ -29,5 +38,5 @@ void clear_particle_flags(u32 flags) {
void bhv_ground_snow_init(void) {
clear_particle_flags(1 << 16);
cur_obj_spawn_particles(&D_8032F3FC);
cur_obj_spawn_particles(&sSnowParticles);
}
+1 -1
View File
@@ -111,7 +111,7 @@ void bhv_heave_ho_loop(void) {
heave_ho_move();
break;
case HELD_HELD:
cur_obj_unrender_and_reset_state(0, 0);
cur_obj_unrender_set_action_and_anim(0, 0);
break;
case HELD_THROWN:
cur_obj_get_dropped();
+4 -3
View File
@@ -225,7 +225,7 @@ void hoot_turn_to_home(void) {
}
void hoot_awake_loop(void) {
if (o->oInteractStatus == INT_STATUS_HOOT_GRABBED_BY_MARIO) {
if (o->oInteractStatus == TRUE) { //! Note: Not a flag, treated as a TRUE/FALSE statement
hoot_action_loop();
cur_obj_init_animation(1);
} else {
@@ -254,8 +254,9 @@ void bhv_hoot_loop(void) {
case HOOT_AVAIL_WANTS_TO_TALK:
hoot_awake_loop();
if (set_mario_npc_dialog(2) == 2 && cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_044)) {
set_mario_npc_dialog(0);
if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_SPEAK
&& cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_044)) {
set_mario_npc_dialog(MARIO_DIALOG_STOP);
cur_obj_become_tangible();
+1 -1
View File
@@ -40,7 +40,7 @@ void bhv_intro_peach_loop(void) {
case 2:
intro_peach_set_pos_and_opacity(gCurrentObject, 255.f, 3.f);
if ((gCurrentObject->oTimer > 100) && (get_dialog_id() == -1))
if ((gCurrentObject->oTimer > 100) && (get_dialog_id() == DIALOG_NONE))
gCurrentObject->oAction += 1;
break;
case 3:
+1 -1
View File
@@ -52,7 +52,7 @@ void bhv_jumping_box_loop(void) {
case HELD_HELD:
obj_copy_pos(o, gMarioObject);
cur_obj_set_model(MODEL_BREAKABLE_BOX_SMALL);
cur_obj_unrender_and_reset_state(-1, 0);
cur_obj_unrender_set_action_and_anim(-1, 0);
break;
case HELD_THROWN:
cur_obj_get_thrown_or_placed(40.0f, 20.0f, 1);
+8 -5
View File
@@ -35,7 +35,8 @@ void king_bobomb_act_0(void) {
o->oSubAction++;
seq_player_lower_volume(SEQ_PLAYER_LEVEL, 60, 40);
}
} else if (cur_obj_update_dialog_with_cutscene(2, 1, CUTSCENE_DIALOG, DIALOG_017)) {
} else if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_017)) {
o->oAction = 2;
o->oFlags |= OBJ_FLAG_HOLDABLE;
}
@@ -170,12 +171,13 @@ void king_bobomb_act_6(void) {
void king_bobomb_act_7(void) {
cur_obj_init_animation_with_sound(2);
if (cur_obj_update_dialog_with_cutscene(2, 2, CUTSCENE_DIALOG, DIALOG_116)) {
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_TEXT_DEFAULT, CUTSCENE_DIALOG, DIALOG_116)) {
create_sound_spawner(SOUND_OBJ_KING_WHOMP_DEATH);
cur_obj_hide();
cur_obj_become_intangible();
spawn_mist_particles_variable(0, 0, 200.0f);
spawn_triangle_break_particles(20, 138, 3.0f, 4);
spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 3.0f, 4);
cur_obj_shake_screen(SHAKE_POS_SMALL);
#ifndef VERSION_JP
cur_obj_spawn_star_at_y_offset(2000.0f, 4500.0f, -4500.0f, 200.0f);
@@ -262,7 +264,8 @@ void king_bobomb_act_5(void) { // bobomb returns home
o->oSubAction++;
break;
case 4:
if (cur_obj_update_dialog_with_cutscene(2, 1, CUTSCENE_DIALOG, DIALOG_128))
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_128))
o->oAction = 2;
break;
}
@@ -311,7 +314,7 @@ void bhv_king_bobomb_loop(void) {
king_bobomb_move();
break;
case HELD_HELD:
cur_obj_unrender_and_reset_state(6, 1);
cur_obj_unrender_set_action_and_anim(6, 1);
break;
case HELD_THROWN:
case HELD_DROPPED:
+11 -10
View File
@@ -482,7 +482,7 @@ s32 obj_begin_race(s32 noTimer) {
}
// Unfreeze mario and disable time stop to begin the race
set_mario_npc_dialog(0);
set_mario_npc_dialog(MARIO_DIALOG_STOP);
disable_time_stop_including_mario();
} else if (o->oTimer > 50) {
return TRUE;
@@ -518,7 +518,7 @@ static void koopa_the_quick_act_show_init_text(void) {
s32 response = obj_update_race_proposition_dialog(
sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].initText);
if (response == 1) {
if (response == DIALOG_RESPONSE_YES) {
UNUSED s32 unused;
gMarioShotFromCannon = FALSE;
@@ -531,7 +531,7 @@ static void koopa_the_quick_act_show_init_text(void) {
o->oKoopaTurningAwayFromWall = FALSE;
o->oFlags |= OBJ_FLAG_ACTIVE_FROM_AFAR;
} else if (response == 2) {
} else if (response == DIALOG_RESPONSE_NO) {
o->oAction = KOOPA_THE_QUICK_ACT_WAIT_BEFORE_RACE;
o->oKoopaTheQuickInitTextboxCooldown = 60;
}
@@ -707,7 +707,7 @@ static void koopa_the_quick_act_stop(void) {
static void koopa_the_quick_act_after_race(void) {
cur_obj_init_animation_with_sound(7);
if (o->parentObj->oKoopaRaceEndpointUnk100 == 0) {
if (o->parentObj->oKoopaRaceEndpointDialog == 0) {
if (cur_obj_can_mario_activate_textbox_2(400.0f, 400.0f)) {
stop_background_music(SEQUENCE_ARGS(4, SEQ_LEVEL_SLIDE));
@@ -717,23 +717,24 @@ static void koopa_the_quick_act_after_race(void) {
if (o->parentObj->oKoopaRaceEndpointRaceStatus < 0) {
// Mario cheated
o->parentObj->oKoopaRaceEndpointRaceStatus = 0;
o->parentObj->oKoopaRaceEndpointUnk100 = DIALOG_006;
o->parentObj->oKoopaRaceEndpointDialog = DIALOG_006;
} else {
// Mario won
o->parentObj->oKoopaRaceEndpointUnk100 =
o->parentObj->oKoopaRaceEndpointDialog =
sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].winText;
}
} else {
// KtQ won
o->parentObj->oKoopaRaceEndpointUnk100 = DIALOG_041;
o->parentObj->oKoopaRaceEndpointDialog = DIALOG_041;
}
o->oFlags &= ~OBJ_FLAG_ACTIVE_FROM_AFAR;
}
} else if (o->parentObj->oKoopaRaceEndpointUnk100 > 0) {
s32 dialogResponse = cur_obj_update_dialog_with_cutscene(2, 1, CUTSCENE_DIALOG, o->parentObj->oKoopaRaceEndpointUnk100);
} else if (o->parentObj->oKoopaRaceEndpointDialog > 0) {
s32 dialogResponse = cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, o->parentObj->oKoopaRaceEndpointDialog);
if (dialogResponse != 0) {
o->parentObj->oKoopaRaceEndpointUnk100 = -1;
o->parentObj->oKoopaRaceEndpointDialog = DIALOG_NONE;
o->oTimer = 0;
}
} else if (o->parentObj->oKoopaRaceEndpointRaceStatus != 0) {
@@ -22,7 +22,7 @@ void bhv_koopa_shell_underwater_loop(void) {
set_koopa_shell_underwater_hitbox();
break;
case HELD_HELD:
cur_obj_unrender_and_reset_state(-1, 0);
cur_obj_unrender_set_action_and_anim(-1, 0);
break;
case HELD_THROWN:
case HELD_DROPPED:
+4 -1
View File
@@ -43,6 +43,9 @@ void bhv_manta_ray_init(void) {
static void manta_ray_move(void) {
s16 animFrame;
s32 pathStatus;
#ifdef AVOID_UB
pathStatus = 0;
#endif
animFrame = o->header.gfx.animInfo.animFrame;
gCurrentObject->oPathedStartWaypoint = (struct Waypoint *) sMantaRayTraj;
@@ -53,7 +56,7 @@ static void manta_ray_move(void) {
o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oMantaTargetYaw, 0x80);
o->oMoveAnglePitch = approach_s16_symmetric(o->oMoveAnglePitch, o->oMantaTargetPitch, 0x80);
// This causes the ray to tilt as it turns.
if ((s16) o->oMantaTargetYaw != (s16) o->oMoveAngleYaw) {
o->oMoveAngleRoll -= 91;
+5 -2
View File
@@ -113,6 +113,9 @@ void bhv_mips_act_follow_path(void) {
s32 followStatus;
struct Waypoint **pathBase;
struct Waypoint *waypoint;
#ifdef AVOID_UB
followStatus = 0;
#endif
// Retrieve current waypoint.
pathBase = segmented_to_virtual(&inside_castle_seg7_trajectory_mips);
@@ -239,13 +242,13 @@ void bhv_mips_held(void) {
else
dialogID = DIALOG_162;
if (set_mario_npc_dialog(1) == 2) {
if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_FRONT) == MARIO_DIALOG_STATUS_SPEAK) {
o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP;
if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, dialogID)) {
o->oInteractionSubtype |= INT_SUBTYPE_DROP_IMMEDIATELY;
o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP;
o->oMipsStarStatus = MIPS_STAR_STATUS_SHOULD_SPAWN_STAR;
set_mario_npc_dialog(0);
set_mario_npc_dialog(MARIO_DIALOG_STOP);
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ void bhv_1up_interact(void) {
play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource);
gMarioState->numLives++;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
}
+1 -1
View File
@@ -32,7 +32,7 @@ void bhv_purple_switch_loop(void) {
cur_obj_play_sound_2(SOUND_GENERAL2_PURPLE_SWITCH);
o->oAction = PURPLE_SWITCH_TICKING;
cur_obj_shake_screen(SHAKE_POS_SMALL);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
}
+4 -3
View File
@@ -27,7 +27,7 @@ static void racing_penguin_act_wait_for_mario(void) {
static void racing_penguin_act_show_init_text(void) {
s32 response = obj_update_race_proposition_dialog(sRacingPenguinData[o->oBehParams2ndByte].text);
if (response == 1) {
if (response == DIALOG_RESPONSE_YES) {
struct Object *child;
child = cur_obj_nearest_object_with_behavior(bhvPenguinRaceFinishLine);
@@ -42,7 +42,7 @@ static void racing_penguin_act_show_init_text(void) {
o->oAction = RACING_PENGUIN_ACT_PREPARE_FOR_RACE;
o->oVelY = 60.0f;
} else if (response == 2) {
} else if (response == DIALOG_RESPONSE_NO) {
o->oAction = RACING_PENGUIN_ACT_WAIT_FOR_MARIO;
o->oRacingPenguinInitTextCooldown = 60;
}
@@ -143,7 +143,8 @@ static void racing_penguin_act_show_final_text(void) {
o->oForwardVel = 4.0f;
}
} else if (o->oRacingPenguinFinalTextbox > 0) {
if ((textResult = cur_obj_update_dialog_with_cutscene(2, 1, CUTSCENE_DIALOG, o->oRacingPenguinFinalTextbox)) != 0) {
if ((textResult = cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, o->oRacingPenguinFinalTextbox))) {
o->oRacingPenguinFinalTextbox = -1;
o->oTimer = 0;
}
@@ -1,15 +1,15 @@
// rotating_octagonal_plat.inc.c
void const *D_80331A44[] = {
static const Collision *sOctagonalPlatformCollision[] = {
bits_seg7_collision_0701AA84,
rr_seg7_collision_07029508,
};
s16 D_80331A4C[] = { 300, -300, 600, -600 };
static s16 sOctagonalPlatformAngularVelocities[] = { 300, -300, 600, -600 };
void bhv_rotating_octagonal_plat_init(void) {
o->collisionData = segmented_to_virtual(D_80331A44[(u8)(o->oBehParams >> 16)]);
o->oAngleVelYaw = D_80331A4C[(u8)(o->oBehParams >> 24)];
o->collisionData = segmented_to_virtual(sOctagonalPlatformCollision[(u8)(o->oBehParams >> 16)]);
o->oAngleVelYaw = sOctagonalPlatformAngularVelocities[(u8)(o->oBehParams >> 24)];
}
void bhv_rotating_octagonal_plat_loop(void) {
+27 -14
View File
@@ -1,25 +1,38 @@
// shock_wave.c.inc
f32 D_8032F420[] = { 1.9f, 2.4f, 4.0f, 4.8f };
/**
* Shockwave scale distance hit points
*/
f32 sBowserShockwaveHitPoints[] = { 1.9f, 2.4f, 4.0f, 4.8f };
/**
* Bowser's shockwave attack main loop
*/
void bhv_bowser_shock_wave_loop(void) {
f32 sp2C, sp28, sp24, sp20;
s16 sp1E = 70;
o->oBowserShockWaveUnkF4 = o->oTimer * 10;
cur_obj_scale(o->oBowserShockWaveUnkF4);
f32 distMin1, distMax1, distMin2, distMax2;
s16 fadeFrames = 70;
// Scale shockwave as the timer goes on
o->oBowserShockWaveScale = o->oTimer * 10;
cur_obj_scale(o->oBowserShockWaveScale);
// Slightly reduce opacity each 3 frames
if (gGlobalTimer % 3)
o->oOpacity -= 1;
if (o->oTimer > sp1E)
// Reduce opacity faster after 70 frames have passed
if (o->oTimer > fadeFrames)
o->oOpacity -= 5;
// Delete object when it's fully transparent
if (o->oOpacity <= 0)
obj_mark_for_deletion(o);
if (o->oTimer < sp1E && mario_is_in_air_action() == 0) {
sp2C = o->oBowserShockWaveUnkF4 * D_8032F420[0];
sp28 = o->oBowserShockWaveUnkF4 * D_8032F420[1];
sp24 = o->oBowserShockWaveUnkF4 * D_8032F420[2];
sp20 = o->oBowserShockWaveUnkF4 * D_8032F420[3];
if ((sp2C < o->oDistanceToMario && o->oDistanceToMario < sp28)
|| (sp24 < o->oDistanceToMario && o->oDistanceToMario < sp20))
gMarioObject->oInteractStatus |= INT_STATUS_HIT_BY_SHOCKWAVE;
// If object times is less than 70 frame and Mario is not in the air...
if (o->oTimer < fadeFrames && mario_is_in_air_action() == 0) {
// ..define distance values depending of the scale multiplied by hit points
distMin1 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[0];
distMax1 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[1];
distMin2 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[2];
distMax2 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[3];
// If Mario is in between distMin and distMax values, shock him
if ((distMin1 < o->oDistanceToMario && o->oDistanceToMario < distMax1)
|| (distMin2 < o->oDistanceToMario && o->oDistanceToMario < distMax2))
gMarioObject->oInteractStatus |= INT_STATUS_MARIO_SHOCKWAVE;
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ void bhv_sl_snowman_wind_loop(void) {
// Mario has come close, begin dialog.
} else if (o->oSubAction == SL_SNOWMAN_WIND_ACT_TALKING) {
if (cur_obj_update_dialog(2, 2, DIALOG_153, 0))
if (cur_obj_update_dialog(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_TEXT_DEFAULT, DIALOG_153, 0))
o->oSubAction++;
// Blowing, spawn wind particles (SL_SNOWMAN_WIND_ACT_BLOWING)
+7 -4
View File
@@ -54,6 +54,9 @@ void snowmans_bottom_act_1(void) {
UNUSED s16 sp26;
s32 sp20;
UNUSED s16 sp1E;
#ifdef AVOID_UB
sp20 = 0;
#endif
o->oPathedStartWaypoint = segmented_to_virtual(&ccm_seg7_trajectory_snowman);
sp26 = object_step_without_floor_orient();
@@ -125,12 +128,12 @@ void bhv_snowmans_bottom_loop(void) {
switch (o->oAction) {
case 0:
if (is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 400) == 1
&& set_mario_npc_dialog(1) == 2) {
&& set_mario_npc_dialog(MARIO_DIALOG_LOOK_FRONT) == MARIO_DIALOG_STATUS_SPEAK) {
sp1E = cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_110);
if (sp1E) {
o->oForwardVel = 10.0f;
o->oAction = 1;
set_mario_npc_dialog(0);
set_mario_npc_dialog(MARIO_DIALOG_STOP);
}
}
break;
@@ -191,7 +194,7 @@ void bhv_snowmans_head_loop(void) {
switch (o->oAction) {
case 0:
if (trigger_obj_dialog_when_facing(&o->oSnowmansHeadUnkF4, DIALOG_109, 400.0f, 1))
if (trigger_obj_dialog_when_facing(&o->oSnowmansHeadDialogActive, DIALOG_109, 400.0f, MARIO_DIALOG_LOOK_FRONT))
o->oAction = 1;
break;
@@ -215,7 +218,7 @@ void bhv_snowmans_head_loop(void) {
break;
case 4:
if (trigger_obj_dialog_when_facing(&o->oSnowmansHeadUnkF4, DIALOG_111, 700.0f, 2)) {
if (trigger_obj_dialog_when_facing(&o->oSnowmansHeadDialogActive, DIALOG_111, 700.0f, MARIO_DIALOG_LOOK_UP)) {
spawn_mist_particles();
spawn_default_star(-4700.0f, -1024.0f, 1890.0f);
o->oAction = 1;
+9
View File
@@ -123,18 +123,27 @@ struct Object *spawn_star(struct Object *sp30, f32 sp34, f32 sp38, f32 sp3C) {
void spawn_default_star(f32 sp20, f32 sp24, f32 sp28) {
struct Object *sp1C;
#ifdef AVOID_UB
sp1C = 0;
#endif
sp1C = spawn_star(sp1C, sp20, sp24, sp28);
sp1C->oBehParams2ndByte = 0;
}
void spawn_red_coin_cutscene_star(f32 sp20, f32 sp24, f32 sp28) {
struct Object *sp1C;
#ifdef AVOID_UB
sp1C = 0;
#endif
sp1C = spawn_star(sp1C, sp20, sp24, sp28);
sp1C->oBehParams2ndByte = 1;
}
void spawn_no_exit_star(f32 sp20, f32 sp24, f32 sp28) {
struct Object *sp1C;
#ifdef AVOID_UB
sp1C = 0;
#endif
sp1C = spawn_star(sp1C, sp20, sp24, sp28);
sp1C->oBehParams2ndByte = 1;
sp1C->oInteractionSubtype |= INT_SUBTYPE_NO_EXIT;
+6 -6
View File
@@ -1,8 +1,8 @@
// star_door.c.inc
void star_door_update_pos(void) {
o->oVelX = (o->oUnkBC) * coss(o->oMoveAngleYaw);
o->oVelZ = (o->oUnkBC) * -sins(o->oMoveAngleYaw);
o->oVelX = (o->oLeftVel) * coss(o->oMoveAngleYaw);
o->oVelZ = (o->oLeftVel) * -sins(o->oMoveAngleYaw);
o->oPosX += o->oVelX;
o->oPosZ += o->oVelZ;
}
@@ -22,12 +22,12 @@ void bhv_star_door_loop(void) {
case 1:
if (o->oTimer == 0 && (s16)(o->oMoveAngleYaw) >= 0) {
cur_obj_play_sound_2(SOUND_GENERAL_STAR_DOOR_OPEN);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(35, 30);
#endif
}
cur_obj_become_intangible();
o->oUnkBC = -8.0f;
o->oLeftVel = -8.0f;
star_door_update_pos();
if (o->oTimer >= 16)
o->oAction++;
@@ -39,11 +39,11 @@ void bhv_star_door_loop(void) {
case 3:
if (o->oTimer == 0 && (s16)(o->oMoveAngleYaw) >= 0) {
cur_obj_play_sound_2(SOUND_GENERAL_STAR_DOOR_CLOSE);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(35, 30);
#endif
}
o->oUnkBC = 8.0f;
o->oLeftVel = 8.0f;
star_door_update_pos();
if (o->oTimer >= 16)
o->oAction++;
@@ -54,7 +54,7 @@ void hidden_breakable_box_actions(void) {
o->oAction = 0;
if (cur_obj_was_attacked_or_ground_pounded()) {
spawn_mist_particles();
spawn_triangle_break_particles(30, 138, 3.0f, 4);
spawn_triangle_break_particles(30, MODEL_DIRT_ANIMATION, 3.0f, 4);
o->oAction++;
cur_obj_play_sound_2(SOUND_GENERAL_BREAK_BOX);
}
+3 -5
View File
@@ -1,11 +1,9 @@
// thi_top.c.inc
struct SpawnParticlesInfo D_8032F134 = {
struct SpawnParticlesInfo sThiTopPuffs = {
0, 30, MODEL_WHITE_PARTICLE_SMALL, 0, 40, 0, 20, 40, 252, 30, 20.0f, 0.0f
};
UNUSED u8 unused8032F134[] = { 10, 11, 12 };
void bhv_thi_huge_island_top_loop(void) {
if (gTHIWaterDrained & 1) {
if (o->oTimer == 0)
@@ -21,8 +19,8 @@ void bhv_thi_tiny_island_top_loop(void) {
if (o->oDistanceToMario < 500.0f)
if (gMarioStates[0].action == ACT_GROUND_POUND_LAND) {
o->oAction++;
cur_obj_spawn_particles(&D_8032F134);
spawn_triangle_break_particles(20, 138, 0.3f, 3);
cur_obj_spawn_particles(&sThiTopPuffs);
spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 0.3f, 3);
cur_obj_play_sound_2(SOUND_GENERAL_ACTIVATE_CAP_SWITCH);
cur_obj_hide();
}
+1 -1
View File
@@ -17,7 +17,7 @@ void tox_box_move(f32 forwardVel, f32 a1, s16 deltaPitch, s16 deltaRoll)
{
o->oPosY = 99.41124 * sins((f32)(o->oTimer + 1) / 8 * 0x8000) + o->oHomeY + 3.0f;
o->oForwardVel = forwardVel;
o->oUnkC0 = a1;
o->oUpVel = a1;
o->oFaceAnglePitch += deltaPitch;
if ((s16) o->oFaceAnglePitch < 0)
deltaRoll = -deltaRoll;
+1 -1
View File
@@ -136,7 +136,7 @@ void bhv_treasure_chest_ship_loop(void) {
gEnvironmentRegions[6] = -335;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}
#ifdef VERSION_SH
#if ENABLE_RUMBLE
reset_rumble_timers_2(2);
#endif
}
+2 -2
View File
@@ -10,11 +10,11 @@ void bhv_tree_snow_or_leaf_loop(void) {
}
if (o->oPosY < o->oFloorHeight)
obj_mark_for_deletion(o);
if (o->oFloorHeight < -11000.0f)
if (o->oFloorHeight < FLOOR_LOWER_LIMIT)
obj_mark_for_deletion(o);
if (o->oTimer > 100)
obj_mark_for_deletion(o);
if (gPrevFrameObjectCount > 212)
if (gPrevFrameObjectCount > (OBJECT_POOL_CAPACITY - 28))
obj_mark_for_deletion(o);
o->oFaceAnglePitch += o->oAngleVelPitch;
o->oFaceAngleRoll += o->oAngleVelRoll;
-3
View File
@@ -104,9 +104,6 @@ void tumbling_bridge_act_0(void) {
void (*sTumblingBridgeActions[])(void) = { tumbling_bridge_act_0, tumbling_bridge_act_1,
tumbling_bridge_act_2, tumbling_bridge_act_3 };
s16 D_8032F38C[] = { -51, 0, 0, -461, 0, 0, -512, 0, 0, -2611, 0,
0, -2360, 0, 0, 214, 0, 0, -50, 1945, 1, 0 };
void bhv_tumbling_bridge_loop(void) {
cur_obj_call_action_function(sTumblingBridgeActions);
}
+5 -3
View File
@@ -54,7 +54,8 @@ void tuxies_mother_act_1(void) {
dialogID = DIALOG_058;
else
dialogID = DIALOG_059;
if (cur_obj_update_dialog_with_cutscene(2, 1, CUTSCENE_DIALOG, dialogID)) {
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, dialogID)) {
if (dialogID == DIALOG_058)
o->oSubAction = 1;
else
@@ -117,7 +118,8 @@ void tuxies_mother_act_0(void) {
o->oSubAction++;
break;
case 1:
if (cur_obj_update_dialog_with_cutscene(2, 1, CUTSCENE_DIALOG, DIALOG_057))
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_057))
o->oSubAction++;
break;
case 2:
@@ -260,7 +262,7 @@ void bhv_small_penguin_loop(void) {
small_penguin_free_actions();
break;
case HELD_HELD:
cur_obj_unrender_and_reset_state(0, 0);
cur_obj_unrender_set_action_and_anim(0, 0);
if (cur_obj_has_behavior(bhvPenguinBaby))
obj_set_behavior(o, bhvSmallPenguin);
obj_copy_pos(o, gMarioObject);
+12 -10
View File
@@ -383,7 +383,8 @@ void ukiki_act_go_to_cage(void) {
case UKIKI_SUB_ACT_CAGE_TALK_TO_MARIO:
cur_obj_init_animation_with_sound(UKIKI_ANIM_HANDSTAND);
if (cur_obj_update_dialog_with_cutscene(3, 1, CUTSCENE_DIALOG, DIALOG_080)) {
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_DOWN,
DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_080)) {
o->oSubAction++;
}
break;
@@ -501,7 +502,7 @@ void ukiki_free_loop(void) {
*
* Possibly unused so AnimState could be used for wearing a cap?
*/
static void ukiki_blink_timer(void) {
UNUSED static void ukiki_blink_timer(void) {
if (gGlobalTimer % 50 < 7) {
o->oAnimState = UKIKI_ANIM_STATE_EYE_CLOSED;
} else {
@@ -516,16 +517,16 @@ void cage_ukiki_held_loop(void) {
if (o->oPosY - o->oHomeY > -100.0f) {
switch(o->oUkikiTextState) {
case UKIKI_TEXT_DEFAULT:
if (set_mario_npc_dialog(2) == 2) {
if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_UP) == MARIO_DIALOG_STATUS_SPEAK) {
create_dialog_box_with_response(DIALOG_079);
o->oUkikiTextState = UKIKI_TEXT_CAGE_TEXTBOX;
}
break;
case UKIKI_TEXT_CAGE_TEXTBOX:
if (gDialogResponse != 0) {
set_mario_npc_dialog(0);
if (gDialogResponse == 1) {
if (gDialogResponse != DIALOG_RESPONSE_NONE) {
set_mario_npc_dialog(MARIO_DIALOG_STOP);
if (gDialogResponse == DIALOG_RESPONSE_YES) {
o->oInteractionSubtype |= INT_SUBTYPE_DROP_IMMEDIATELY;
o->oUkikiTextState = UKIKI_TEXT_GO_TO_CAGE;
} else {
@@ -567,7 +568,7 @@ void cap_ukiki_held_loop(void) {
break;
case UKIKI_TEXT_STEAL_CAP:
if (cur_obj_update_dialog(2, 2, DIALOG_100, 0)) {
if (cur_obj_update_dialog(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_TEXT_DEFAULT, DIALOG_100, 0)) {
o->oInteractionSubtype |= INT_SUBTYPE_DROP_IMMEDIATELY;
o->oUkikiTextState = UKIKI_TEXT_STOLE_CAP;
}
@@ -577,9 +578,10 @@ void cap_ukiki_held_loop(void) {
break;
case UKIKI_TEXT_HAS_CAP:
if (cur_obj_update_dialog(2, 18, DIALOG_101, 0)) {
if (cur_obj_update_dialog(MARIO_DIALOG_LOOK_UP,
(DIALOG_FLAG_TEXT_DEFAULT | DIALOG_FLAG_TIME_STOP_ENABLED), DIALOG_101, 0)) {
mario_retrieve_cap();
set_mario_npc_dialog(0);
set_mario_npc_dialog(MARIO_DIALOG_STOP);
o->oUkikiHasCap &= ~UKIKI_CAP_ON;
o->oUkikiTextState = UKIKI_TEXT_GAVE_CAP_BACK;
}
@@ -617,7 +619,7 @@ void bhv_ukiki_loop(void) {
break;
case HELD_HELD:
cur_obj_unrender_and_reset_state(UKIKI_ANIM_HELD, 0);
cur_obj_unrender_set_action_and_anim(UKIKI_ANIM_HELD, 0);
obj_copy_pos(o, gMarioObject);
if (o->oBehParams2ndByte == UKIKI_CAP) {
+1 -1
View File
@@ -36,7 +36,7 @@ void bhv_ukiki_cage_star_loop(void) {
case UKIKI_CAGE_STAR_ACT_SPAWN_STAR:
obj_mark_for_deletion(o);
spawn_mist_particles();
spawn_triangle_break_particles(20, 138, 0.7, 3);
spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 0.7, 3);
spawn_default_star(2500.0f, -1200.0f, 1300.0f);
break;
}
@@ -18,7 +18,7 @@ void bhv_unused_poundable_platform(void) {
if (o->oAction == 0) {
if (cur_obj_is_mario_ground_pounding_platform()) {
spawn_mist_particles();
spawn_triangle_break_particles(20, 56, 3.0f, 0);
spawn_triangle_break_particles(20, MODEL_SL_CRACKED_ICE_CHUNK, 3.0f, 0);
o->oAction++;
}
} else if (o->oTimer > 7) {
+1 -1
View File
@@ -40,7 +40,7 @@ void water_level_pillar_undrained(void) {
(s32) approach_f32_symmetric(gEnvironmentLevels[2], -2450.0f, 5.0f);
gEnvironmentLevels[0] =
(s32) approach_f32_symmetric(gEnvironmentLevels[0], -2450.0f, 5.0f);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
reset_rumble_timers_2(2);
#endif
} else
+1 -1
View File
@@ -49,7 +49,7 @@ void bhv_water_level_diamond_loop(void) {
cur_obj_play_sound_1(SOUND_ENV_WATER_DRAIN); // same as above
}
o->oAngleVelYaw = 0x800;
#ifdef VERSION_SH
#if ENABLE_RUMBLE
reset_rumble_timers_2(2);
#endif
}
+44 -36
View File
@@ -1,20 +1,20 @@
// whomp.c.inc
void whomp_play_sfx_from_pound_animation(void) {
UNUSED s32 sp2C = o->header.gfx.animInfo.animFrame;
s32 sp28 = 0;
UNUSED s32 animFrame = o->header.gfx.animInfo.animFrame;
s32 playSound = 0;
if (o->oForwardVel < 5.0f) {
sp28 = cur_obj_check_anim_frame(0);
sp28 |= cur_obj_check_anim_frame(23);
playSound = cur_obj_check_anim_frame(0);
playSound |= cur_obj_check_anim_frame(23);
} else {
sp28 = cur_obj_check_anim_frame_in_range(0, 3);
sp28 |= cur_obj_check_anim_frame_in_range(23, 3);
playSound = cur_obj_check_anim_frame_in_range(0, 3);
playSound |= cur_obj_check_anim_frame_in_range(23, 3);
}
if (sp28)
if (playSound)
cur_obj_play_sound_2(SOUND_OBJ_POUNDING1);
}
void whomp_act_0(void) {
void whomp_init(void) {
cur_obj_init_animation_with_accel_and_sound(0, 1.0f);
cur_obj_set_pos_to_home();
if (o->oBehParams2ndByte != 0) {
@@ -28,14 +28,15 @@ void whomp_act_0(void) {
cur_obj_set_pos_to_home();
o->oHealth = 3;
}
} else if (cur_obj_update_dialog_with_cutscene(2, 1, CUTSCENE_DIALOG, DIALOG_114))
} else if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_114))
o->oAction = 2;
} else if (o->oDistanceToMario < 500.0f)
o->oAction = 1;
whomp_play_sfx_from_pound_animation();
}
void whomp_act_7(void) {
void whomp_turn(void) {
if (o->oSubAction == 0) {
o->oForwardVel = 0.0f;
cur_obj_init_animation_with_accel_and_sound(0, 1.0f);
@@ -51,21 +52,24 @@ void whomp_act_7(void) {
whomp_play_sfx_from_pound_animation();
}
void whomp_act_1(void) {
s16 sp26;
f32 sp20;
f32 sp1C;
sp26 = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw);
sp20 = cur_obj_lateral_dist_to_home();
void whomp_patrol(void) {
s16 marioAngle;
f32 distWalked;
f32 patrolDist;
marioAngle = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw);
distWalked = cur_obj_lateral_dist_to_home();
if (gCurrLevelNum == LEVEL_BITS)
sp1C = 200.0f;
patrolDist = 200.0f;
else
sp1C = 700.0f;
patrolDist = 700.0f;
cur_obj_init_animation_with_accel_and_sound(0, 1.0f);
o->oForwardVel = 3.0f;
if (sp20 > sp1C)
if (distWalked > patrolDist)
o->oAction = 7;
else if (sp26 < 0x2000) {
else if (marioAngle < 0x2000) {
if (o->oDistanceToMario < 1500.0f) {
o->oForwardVel = 9.0f;
cur_obj_init_animation_with_accel_and_sound(0, 3.0f);
@@ -76,14 +80,15 @@ void whomp_act_1(void) {
whomp_play_sfx_from_pound_animation();
}
void whomp_act_2(void) {
s16 sp1E;
void king_whomp_chase(void) {
s16 marioAngle;
cur_obj_init_animation_with_accel_and_sound(0, 1.0f);
o->oForwardVel = 3.0f;
cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x200);
if (o->oTimer > 30) {
sp1E = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw);
if (sp1E < 0x2000) {
marioAngle = abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw);
if (marioAngle < 0x2000) {
if (o->oDistanceToMario < 1500.0f) {
o->oForwardVel = 9.0f;
cur_obj_init_animation_with_accel_and_sound(0, 3.0f);
@@ -92,6 +97,7 @@ void whomp_act_2(void) {
o->oAction = 3;
}
}
whomp_play_sfx_from_pound_animation();
if (mario_is_far_below_object(1000.0f)) {
o->oAction = 0;
@@ -99,14 +105,14 @@ void whomp_act_2(void) {
}
}
void whomp_act_3(void) {
void whomp_prepare_jump(void) {
o->oForwardVel = 0.0f;
cur_obj_init_animation_with_accel_and_sound(1, 1.0f);
if (cur_obj_check_if_near_animation_end())
o->oAction = 4;
}
void whomp_act_4(void) {
void whomp_jump(void) {
if (o->oTimer == 0)
o->oVelY = 40.0f;
if (o->oTimer < 8) {
@@ -121,7 +127,7 @@ void whomp_act_4(void) {
}
}
void whomp_act_5(void) {
void whomp_land(void) {
if (o->oSubAction == 0 && o->oMoveFlags & OBJ_MOVE_LANDED) {
cur_obj_play_sound_2(SOUND_OBJ_WHOMP_LOWPRIO);
cur_obj_shake_screen(SHAKE_POS_SMALL);
@@ -145,7 +151,7 @@ void king_whomp_on_ground(void) {
vec3f_copy_2(pos, &o->oPosX);
vec3f_copy_2(&o->oPosX, &gMarioObject->oPosX);
spawn_mist_particles_variable(0, 0, 100.0f);
spawn_triangle_break_particles(20, 138, 3.0f, 4);
spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 3.0f, 4);
cur_obj_shake_screen(SHAKE_POS_SMALL);
vec3f_copy_2(&o->oPosX, pos);
}
@@ -180,12 +186,13 @@ void whomp_on_ground(void) {
o->oSubAction = 0;
}
void whomp_act_6(void) {
void whomp_on_ground_general(void) {
if (o->oSubAction != 10) {
o->oForwardVel = 0.0f;
o->oAngleVelPitch = 0;
o->oAngleVelYaw = 0;
o->oAngleVelRoll = 0;
if (o->oBehParams2ndByte != 0)
king_whomp_on_ground();
else
@@ -207,14 +214,15 @@ void whomp_act_6(void) {
}
}
void whomp_act_8(void) {
void whomp_die(void) {
if (o->oBehParams2ndByte != 0) {
if (cur_obj_update_dialog_with_cutscene(2, 2, CUTSCENE_DIALOG, DIALOG_115)) {
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_TEXT_DEFAULT, CUTSCENE_DIALOG, DIALOG_115)) {
obj_set_angle(o, 0, 0, 0);
cur_obj_hide();
cur_obj_become_intangible();
spawn_mist_particles_variable(0, 0, 200.0f);
spawn_triangle_break_particles(20, 138, 3.0f, 4);
spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 3.0f, 4);
cur_obj_shake_screen(SHAKE_POS_SMALL);
o->oPosY += 100.0f;
spawn_default_star(180.0f, 3880.0f, 340.0f);
@@ -223,21 +231,21 @@ void whomp_act_8(void) {
}
} else {
spawn_mist_particles_variable(0, 0, 100.0f);
spawn_triangle_break_particles(20, 138, 3.0f, 4);
spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 3.0f, 4);
cur_obj_shake_screen(SHAKE_POS_SMALL);
create_sound_spawner(SOUND_OBJ_THWOMP);
obj_mark_for_deletion(o);
}
}
void whomp_act_9(void) {
void king_whomp_stop_music(void) {
if (o->oTimer == 60)
stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
}
void (*sWhompActions[])(void) = {
whomp_act_0, whomp_act_1, whomp_act_2, whomp_act_3, whomp_act_4,
whomp_act_5, whomp_act_6, whomp_act_7, whomp_act_8, whomp_act_9
whomp_init, whomp_patrol, king_whomp_chase, whomp_prepare_jump, whomp_jump,
whomp_land, whomp_on_ground_general, whomp_turn, whomp_die, king_whomp_stop_music
};
// MM
+4 -2
View File
@@ -228,7 +228,8 @@ static void wiggler_act_walk(void) {
// If Mario is positioned below the wiggler, assume he entered through the
// lower cave entrance, so don't display text.
if (gMarioObject->oPosY < o->oPosY || cur_obj_update_dialog_with_cutscene(2, 0, CUTSCENE_DIALOG, DIALOG_150) != 0) {
if (gMarioObject->oPosY < o->oPosY || cur_obj_update_dialog_with_cutscene(
MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_NONE, CUTSCENE_DIALOG, DIALOG_150)) {
o->oWigglerTextStatus = WIGGLER_TEXT_STATUS_COMPLETED_DIALOG;
}
} else {
@@ -304,7 +305,8 @@ static void wiggler_act_jumped_on(void) {
// defeated) or go back to walking
if (o->header.gfx.scale[1] >= 4.0f) {
if (o->oTimer > 30) {
if (cur_obj_update_dialog_with_cutscene(2, 0, CUTSCENE_DIALOG, attackText[o->oHealth - 2]) != 0) {
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
DIALOG_FLAG_NONE, CUTSCENE_DIALOG, attackText[o->oHealth - 2])) {
// Because we don't want the wiggler to disappear after being
// defeated, we leave its health at 1
if (--o->oHealth == 1) {
+2 -2
View File
@@ -76,7 +76,7 @@ void yoshi_idle_loop(void) {
void yoshi_talk_loop(void) {
if ((s16) o->oMoveAngleYaw == (s16) o->oAngleToMario) {
cur_obj_init_animation(0);
if (set_mario_npc_dialog(1) == 2) {
if (set_mario_npc_dialog(MARIO_DIALOG_LOOK_FRONT) == MARIO_DIALOG_STATUS_SPEAK) {
o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP;
if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_161)) {
o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP;
@@ -123,7 +123,7 @@ void yoshi_finish_jumping_and_despawn_loop(void) {
obj_move_xyz_using_fvel_and_yaw(o);
o->oVelY -= 2.0;
if (o->oPosY < 2100.0f) {
set_mario_npc_dialog(0);
set_mario_npc_dialog(MARIO_DIALOG_STOP);
gObjCutsceneDone = TRUE;
sYoshiDead = TRUE;
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
+61 -42
View File
@@ -390,9 +390,13 @@ struct CameraStoredInfo sCameraStoreCutscene;
// first iteration of data
u32 unused8032CFC0 = 0;
struct Object *gCutsceneFocus = NULL;
// other camera focuses?
u32 unused8032CFC8 = 0;
u32 unused8032CFCC = 0;
/**
* The information of a second focus camera used by some objects
*/
struct Object *gSecondCameraFocus = NULL;
/**
@@ -431,7 +435,7 @@ u8 sFramesSinceCutsceneEnded = 0;
* 2 = No
* 3 = Dialog doesn't have a response
*/
u8 sCutsceneDialogResponse = 0;
u8 sCutsceneDialogResponse = DIALOG_RESPONSE_NONE;
struct PlayerCameraState *sMarioCamState = &gPlayerCameraState[0];
struct PlayerCameraState *sLuigiCamState = &gPlayerCameraState[1];
u32 unused8032D008 = 0;
@@ -1703,9 +1707,12 @@ struct ParallelTrackingPoint sBBHLibraryParTrackPath[] = {
};
s32 unused_update_mode_5_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) {
#ifdef AVOID_UB
return 0;
#endif
}
static void stub_camera_1(UNUSED s32 unused) {
UNUSED static void stub_camera_1(UNUSED s32 unused) {
}
void mode_boss_fight_camera(struct Camera *c) {
@@ -2028,6 +2035,9 @@ void mode_behind_mario_camera(struct Camera *c) {
}
s32 nop_update_water_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) {
#ifdef AVOID_UB
return 0;
#endif
}
/**
@@ -2226,7 +2236,7 @@ s16 update_default_camera(struct Camera *c) {
if ((closeToMario & 1) && avoidStatus != 0) {
yawVel = 0;
}
if (yawVel != 0 && get_dialog_id() == -1) {
if (yawVel != 0 && get_dialog_id() == DIALOG_NONE) {
camera_approach_s16_symmetric_bool(&yaw, yawGoal, yawVel);
}
}
@@ -3327,12 +3337,18 @@ void init_camera(struct Camera *c) {
// Set the camera's starting position or start a cutscene for certain levels
switch (gCurrLevelNum) {
// Calls the initial cutscene when you enter Bowser battle levels
// Note: This replaced an "old" way to call these cutscenes using
// a camEvent value: CAM_EVENT_BOWSER_INIT
case LEVEL_BOWSER_1:
#ifndef VERSION_JP
// Since Bowser 1 has a demo entry, check for it
// If it is, then set CamAct to the end to directly activate Bowser
// If it isn't, then start cutscene
if (gCurrDemoInput == NULL) {
start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA);
} else if (gSecondCameraFocus != NULL) {
gSecondCameraFocus->oBowserUnk88 = 2;
gSecondCameraFocus->oBowserCamAct = BOWSER_CAM_ACT_END;
}
#else
start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA);
@@ -4848,6 +4864,9 @@ void play_sound_if_cam_switched_to_lakitu_or_mario(void) {
*/
s32 radial_camera_input(struct Camera *c, UNUSED f32 unused) {
s16 dummy;
#ifdef AVOID_UB
dummy = 0;
#endif
if ((gCameraMovementFlags & CAM_MOVE_ENTERED_ROTATE_SURFACE) || !(gCameraMovementFlags & CAM_MOVE_ROTATE)) {
@@ -5315,7 +5334,7 @@ void set_focus_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 forwBack
* @param forwBack offset to Mario's front/back, relative to his faceAngle
* @param yawOff offset to Mario's faceAngle, changes the direction of `leftRight` and `forwBack`
*/
static void unused_set_pos_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 forwBack, s16 yawOff) {
UNUSED static void unused_set_pos_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 forwBack, s16 yawOff) {
u16 yaw = sMarioCamState->faceAngle[1] + yawOff;
c->pos[0] = sMarioCamState->pos[0] + forwBack * sins(yaw) + leftRight * coss(yaw);
@@ -5364,7 +5383,7 @@ void determine_pushing_or_pulling_door(s16 *rotation) {
if (sMarioCamState->action == ACT_PULLING_DOOR) {
*rotation = 0;
} else {
*rotation = DEGREES(180);
*rotation = DEGREES(-180);
}
}
@@ -6863,31 +6882,31 @@ void start_object_cutscene(u8 cutscene, struct Object *o) {
*/
u8 start_object_cutscene_without_focus(u8 cutscene) {
sObjectCutscene = cutscene;
sCutsceneDialogResponse = 0;
sCutsceneDialogResponse = DIALOG_RESPONSE_NONE;
return 0;
}
s32 unused_dialog_cutscene_response(u8 cutscene) {
s16 unused_dialog_cutscene_response(u8 cutscene) {
// if not in a cutscene, start this one
if ((gCamera->cutscene == 0) && (sObjectCutscene == 0)) {
sObjectCutscene = cutscene;
}
// if playing this cutscene and Mario responded, return the response
if ((gCamera->cutscene == cutscene) && (sCutsceneDialogResponse != 0)) {
return (s16) sCutsceneDialogResponse;
if ((gCamera->cutscene == cutscene) && (sCutsceneDialogResponse)) {
return sCutsceneDialogResponse;
} else {
return 0;
}
}
s16 cutscene_object_with_dialog(u8 cutscene, struct Object *o, s16 dialogID) {
s16 response = 0;
s16 response = DIALOG_RESPONSE_NONE;
if ((gCamera->cutscene == 0) && (sObjectCutscene == 0)) {
if (gRecentCutscene != cutscene) {
start_object_cutscene(cutscene, o);
if (dialogID != -1) {
if (dialogID != DIALOG_NONE) {
sCutsceneDialogID = dialogID;
} else {
sCutsceneDialogID = DIALOG_001;
@@ -6902,7 +6921,7 @@ s16 cutscene_object_with_dialog(u8 cutscene, struct Object *o, s16 dialogID) {
}
s16 cutscene_object_without_dialog(u8 cutscene, struct Object *o) {
s16 response = cutscene_object_with_dialog(cutscene, o, -1);
s16 response = cutscene_object_with_dialog(cutscene, o, DIALOG_NONE);
return response;
}
@@ -6987,7 +7006,7 @@ void copy_spline_segment(struct CutsceneSplinePoint dst[], struct CutsceneSpline
s16 cutscene_common_set_dialog_state(s32 state) {
s16 timer = gCutsceneTimer;
// If the dialog ended, return CUTSCENE_LOOP, which would end the cutscene shot
if (set_mario_npc_dialog(state) == 2) {
if (set_mario_npc_dialog(state) == MARIO_DIALOG_STATUS_SPEAK) {
timer = CUTSCENE_LOOP;
}
return timer;
@@ -6995,19 +7014,19 @@ s16 cutscene_common_set_dialog_state(s32 state) {
/// Unused SSL cutscene?
static UNUSED void unused_cutscene_mario_dialog_looking_down(UNUSED struct Camera *c) {
gCutsceneTimer = cutscene_common_set_dialog_state(3);
gCutsceneTimer = cutscene_common_set_dialog_state(MARIO_DIALOG_LOOK_DOWN);
}
/**
* Cause Mario to enter the normal dialog state.
*/
static BAD_RETURN(s32) cutscene_mario_dialog(UNUSED struct Camera *c) {
gCutsceneTimer = cutscene_common_set_dialog_state(1);
gCutsceneTimer = cutscene_common_set_dialog_state(MARIO_DIALOG_LOOK_FRONT);
}
/// Unused SSL cutscene?
static UNUSED void unused_cutscene_mario_dialog_looking_up(UNUSED struct Camera *c) {
gCutsceneTimer = cutscene_common_set_dialog_state(2);
gCutsceneTimer = cutscene_common_set_dialog_state(MARIO_DIALOG_LOOK_UP);
}
/**
@@ -7196,7 +7215,7 @@ void cutscene_unsoften_music(UNUSED struct Camera *c) {
seq_player_unlower_volume(SEQ_PLAYER_LEVEL, 60);
}
static void stub_camera_5(UNUSED struct Camera *c) {
UNUSED static void stub_camera_5(UNUSED struct Camera *c) {
}
BAD_RETURN(s32) cutscene_unused_start(UNUSED struct Camera *c) {
@@ -7682,7 +7701,7 @@ BAD_RETURN(s32) cutscene_dance_rotate_move_towards_mario(struct Camera *c) {
/**
* Speculated to be dance-related due to its proximity to the other dance functions
*/
static BAD_RETURN(s32) cutscene_dance_unused(UNUSED struct Camera *c) {
UNUSED static BAD_RETURN(s32) cutscene_dance_unused(UNUSED struct Camera *c) {
}
/**
@@ -8033,10 +8052,10 @@ BAD_RETURN(s32) cutscene_bowser_area_shake_fov(UNUSED struct Camera *c) {
}
/**
* Set oBowserUnk88 to 1, which causes bowser to start walking.
* Set oBowserCamAct to 1, which causes bowser to start walking.
*/
BAD_RETURN(s32) cutscene_bowser_area_start_bowser_walking(UNUSED struct Camera *c) {
gSecondCameraFocus->oBowserUnk88 = 1;
gSecondCameraFocus->oBowserCamAct = BOWSER_CAM_ACT_WALK;
}
/**
@@ -8093,11 +8112,11 @@ BAD_RETURN(s32) cutscene_bowser_arena_pan_left(UNUSED struct Camera *c) {
* Duplicate of cutscene_mario_dialog().
*/
BAD_RETURN(s32) cutscene_bowser_arena_mario_dialog(UNUSED struct Camera *c) {
cutscene_common_set_dialog_state(1);
cutscene_common_set_dialog_state(MARIO_DIALOG_LOOK_FRONT);
}
void cutscene_stop_dialog(UNUSED struct Camera *c) {
cutscene_common_set_dialog_state(0);
cutscene_common_set_dialog_state(MARIO_DIALOG_STOP);
}
/**
@@ -8138,7 +8157,7 @@ BAD_RETURN(s32) bowser_fight_intro_dialog(UNUSED struct Camera *c) {
case LEVEL_BOWSER_2:
dialog = DIALOG_092;
break;
default:
default: // LEVEL_BOWSER_3
dialog = DIALOG_093;
}
@@ -8151,7 +8170,7 @@ BAD_RETURN(s32) bowser_fight_intro_dialog(UNUSED struct Camera *c) {
BAD_RETURN(s32) cutscene_bowser_arena_dialog(struct Camera *c) {
cutscene_event(bowser_fight_intro_dialog, c, 0, 0);
if (get_dialog_id() == -1) {
if (get_dialog_id() == DIALOG_NONE) {
gCutsceneTimer = CUTSCENE_LOOP;
}
}
@@ -8165,7 +8184,7 @@ BAD_RETURN(s32) cutscene_bowser_arena_end(struct Camera *c) {
transition_next_state(c, 20);
sStatusFlags |= CAM_FLAG_UNUSED_CUTSCENE_ACTIVE;
sModeOffsetYaw = sMarioCamState->faceAngle[1] + DEGREES(90);
gSecondCameraFocus->oBowserUnk88 = 2;
gSecondCameraFocus->oBowserCamAct = BOWSER_CAM_ACT_END;
}
/**
@@ -8595,7 +8614,7 @@ BAD_RETURN(s32) cutscene_death_stomach_goto_mario(struct Camera *c) {
/**
* Ah, yes
*/
static void unused_water_death_move_to_side_of_mario(struct Camera *c) {
UNUSED static void unused_water_death_move_to_side_of_mario(struct Camera *c) {
water_death_move_to_mario_side(c);
}
@@ -8869,7 +8888,7 @@ BAD_RETURN(s32) cutscene_enter_pyramid_top(struct Camera *c) {
}
}
static void unused_cutscene_goto_cvar(struct Camera *c) {
UNUSED static void unused_cutscene_goto_cvar(struct Camera *c) {
f32 dist;
dist = calc_abs_dist(sCutsceneVars[3].point, sMarioCamState->pos);
@@ -8967,7 +8986,7 @@ BAD_RETURN(s32) cutscene_dialog_create_dialog_box(struct Camera *c) {
}
//! Unused. This may have been used before sCutsceneDialogResponse was implemented.
sCutsceneVars[8].angle[0] = 3;
sCutsceneVars[8].angle[0] = DIALOG_RESPONSE_NOT_DEFINED;
}
/**
@@ -8979,13 +8998,13 @@ BAD_RETURN(s32) cutscene_dialog(struct Camera *c) {
cutscene_event(cutscene_dialog_create_dialog_box, c, 10, 10);
sStatusFlags |= CAM_FLAG_SMOOTH_MOVEMENT;
if (gDialogResponse != 0) {
if (gDialogResponse != DIALOG_RESPONSE_NONE) {
sCutsceneDialogResponse = gDialogResponse;
}
if ((get_dialog_id() == -1) && (sCutsceneVars[8].angle[0] != 0)) {
if ((get_dialog_id() == DIALOG_NONE) && (sCutsceneVars[8].angle[0] != 0)) {
if (c->cutscene != CUTSCENE_RACE_DIALOG) {
sCutsceneDialogResponse = 3;
sCutsceneDialogResponse = DIALOG_RESPONSE_NOT_DEFINED;
}
gCutsceneTimer = CUTSCENE_LOOP;
@@ -9030,7 +9049,7 @@ BAD_RETURN(s32) cutscene_read_message_start(struct Camera *c) {
sCutsceneVars[0].angle[0] = 0;
}
static void unused_cam_to_mario(struct Camera *c) {
UNUSED static void unused_cam_to_mario(struct Camera *c) {
Vec3s dir;
vec3s_set(dir, 0, sMarioCamState->faceAngle[1], 0);
@@ -9050,7 +9069,7 @@ BAD_RETURN(s32) cutscene_read_message(struct Camera *c) {
switch (sCutsceneVars[0].angle[0]) {
// Do nothing until message is gone.
case 0:
if (get_dialog_id() != -1) {
if (get_dialog_id() != DIALOG_NONE) {
sCutsceneVars[0].angle[0] += 1;
set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG);
}
@@ -9062,7 +9081,7 @@ BAD_RETURN(s32) cutscene_read_message(struct Camera *c) {
// This could cause softlocks. If a message starts one frame after another one closes, the
// cutscene will never end.
if (get_dialog_id() == -1) {
if (get_dialog_id() == DIALOG_NONE) {
gCutsceneTimer = CUTSCENE_LOOP;
retrieve_info_star(c);
transition_next_state(c, 15);
@@ -9395,11 +9414,11 @@ BAD_RETURN(s32) cutscene_cap_switch_press(struct Camera *c) {
cutscene_event(cutscene_cap_switch_press_create_dialog, c, 10, 10);
vec3f_get_dist_and_angle(sMarioCamState->pos, c->pos, &dist, &pitch, &yaw);
if (gDialogResponse != 0) {
if (gDialogResponse != DIALOG_RESPONSE_NONE) {
sCutsceneVars[4].angle[0] = gDialogResponse;
}
if ((get_dialog_id() == -1) && (sCutsceneVars[4].angle[0] != 0)) {
if ((get_dialog_id() == DIALOG_NONE) && (sCutsceneVars[4].angle[0] != 0)) {
sCutsceneDialogResponse = sCutsceneVars[4].angle[0];
if (sCutsceneVars[4].angle[0] == 1) {
cap_switch_save(gCutsceneFocus->oBehParams2ndByte);
@@ -9493,8 +9512,8 @@ s32 intro_peach_move_camera_start_to_pipe(struct Camera *c, struct CutsceneSplin
// The two splines used by this function are reflected in the horizontal plane for some reason,
// so they are rotated every frame. Why do this, Nintendo?
rotate_in_xz(c->focus, c->focus, DEGREES(180));
rotate_in_xz(c->pos, c->pos, DEGREES(180));
rotate_in_xz(c->focus, c->focus, DEGREES(-180));
rotate_in_xz(c->pos, c->pos, DEGREES(-180));
vec3f_set(offset, -1328.f, 260.f, 4664.f);
vec3f_add(c->focus, offset);
@@ -9532,7 +9551,7 @@ BAD_RETURN(s32) cutscene_intro_peach_start_to_pipe_spline(struct Camera *c) {
* Loop the cutscene until Mario exits the dialog.
*/
BAD_RETURN(s32) cutscene_intro_peach_dialog(struct Camera *c) {
if (get_dialog_id() == -1) {
if (get_dialog_id() == DIALOG_NONE) {
vec3f_copy(gLakituState.goalPos, c->pos);
vec3f_copy(gLakituState.goalFocus, c->focus);
sStatusFlags |= (CAM_FLAG_SMOOTH_MOVEMENT | CAM_FLAG_UNUSED_CUTSCENE_ACTIVE);
@@ -9654,7 +9673,7 @@ BAD_RETURN(s32) cutscene_intro_peach_letter(struct Camera *c) {
cutscene_event(play_sound_peach_reading_letter, c, 83, 83);
#endif
if ((gCutsceneTimer > 120) && (get_dialog_id() == -1)) {
if ((gCutsceneTimer > 120) && (get_dialog_id() == DIALOG_NONE)) {
// Start the next scene
gCutsceneTimer = CUTSCENE_LOOP;
}
+4 -7
View File
@@ -337,7 +337,7 @@ void reset_debug_objectinfo(void) {
* C Right) and then toggles the debug flags from FF to 2; 2 is unused,
* despite so this has no effect, being called. (unused)
*/
static void check_debug_button_seq(void) {
UNUSED static void check_debug_button_seq(void) {
s16 *buttonArr;
s16 cButtonMask;
@@ -367,7 +367,7 @@ static void check_debug_button_seq(void) {
* Poll the debug info flags and controller for appropriate presses that
* control sDebugPage's range. (unused)
*/
static void try_change_debug_page(void) {
UNUSED static void try_change_debug_page(void) {
if (gDebugInfoFlags & DEBUG_INFO_FLAG_DPRINT) {
if ((gPlayer1Controller->buttonPressed & L_JPAD)
&& (gPlayer1Controller->buttonDown & (L_TRIG | R_TRIG))) {
@@ -392,8 +392,8 @@ static void try_change_debug_page(void) {
* sDebugSysCursor. This is used to adjust enemy and effect behaviors
* on the fly. (unused)
*/
#ifndef VERSION_SH
static
#ifdef VERSION_EU
UNUSED static
#endif
void try_modify_debug_controls(void) {
s32 sp4;
@@ -525,9 +525,6 @@ void try_do_mario_debug_object_spawn(void) {
}
// TODO: figure out what this is
#ifndef VERSION_SH
static
#endif
void debug_print_obj_move_flags(void) {
#ifndef VERSION_EU // TODO: Is there a better way to diff this? static EU doesn't seem to work.
if (gCurrentObject->oMoveFlags & OBJ_MOVE_LANDED) {
+3 -2
View File
@@ -1,6 +1,7 @@
#include <ultra64.h>
#include "sm64.h"
#include "dialog_ids.h"
#include "game_init.h"
#include "memory.h"
#include "ingame_menu.h"
@@ -272,7 +273,7 @@ void envfx_update_snow_blizzard(s32 snowCylinderX, s32 snowCylinderY, s32 snowCy
* find it. The radius of 3000 units is quite large for that though, covering
* more than half of the mirror room.
*/
static s32 is_in_mystery_snow_area(s32 x, UNUSED s32 y, s32 z) {
UNUSED static s32 is_in_mystery_snow_area(s32 x, UNUSED s32 y, s32 z) {
if (sqr(x - 3380) + sqr(z + 520) < sqr(3000)) {
return 1;
}
@@ -463,7 +464,7 @@ Gfx *envfx_update_snow(s32 snowMode, Vec3s marioPos, Vec3s camFrom, Vec3s camTo)
Gfx *envfx_update_particles(s32 mode, Vec3s marioPos, Vec3s camTo, Vec3s camFrom) {
Gfx *gfx;
if (get_dialog_id() != -1) {
if (get_dialog_id() != DIALOG_NONE) {
return NULL;
}
+228 -167
View File
@@ -21,51 +21,71 @@
#include "rumble_init.h"
#include <prevent_bss_reordering.h>
// FIXME: I'm not sure all of these variables belong in this file, but I don't
// know of a good way to split them
// First 3 controller slots
struct Controller gControllers[3];
// Gfx handlers
struct SPTask *gGfxSPTask;
Gfx *gDisplayListHead;
u8 *gGfxPoolEnd;
struct GfxPool *gGfxPool;
// OS Controllers
OSContStatus gControllerStatuses[4];
OSContPad gControllerPads[4];
u8 gControllerBits;
s8 gEepromProbe;
s8 gEepromProbe; // Save Data Probe
// OS Messages
OSMesgQueue gGameVblankQueue;
OSMesgQueue D_80339CB8;
OSMesg D_80339CD0;
OSMesg D_80339CD4;
OSMesgQueue gGfxVblankQueue;
OSMesg gGameMesgBuf[1];
OSMesg gGfxMesgBuf[1];
// Vblank Handler
struct VblankHandler gGameVblankHandler;
// Buffers
uintptr_t gPhysicalFrameBuffers[3];
uintptr_t gPhysicalZBuffer;
void *D_80339CF0;
void *D_80339CF4;
struct MarioAnimation D_80339D10;
struct MarioAnimation gDemo;
UNUSED u8 filler80339D30[0x90];
s32 unused8032C690 = 0;
// Mario Anims and Demo allocation
void *gMarioAnimsMemAlloc;
void *gDemoInputsMemAlloc;
struct DmaHandlerList gMarioAnimsBuf;
struct DmaHandlerList gDemoInputsBuf;
// fillers
UNUSED static u8 sfillerGameInit[0x90];
static s32 sUnusedGameInitValue = 0;
// General timer that runs as the game starts
u32 gGlobalTimer = 0;
static u16 sCurrFBNum = 0;
u16 frameBufferIndex = 0;
// Framebuffer rendering values (max 3)
u16 sRenderedFramebuffer = 0;
u16 sRenderingFrameBuffer = 0;
// Goddard Vblank Function Caller
void (*gGoddardVblankCallback)(void) = NULL;
// Defined controller slots
struct Controller *gPlayer1Controller = &gControllers[0];
struct Controller *gPlayer2Controller = &gControllers[1];
// probably debug only, see note below
struct Controller *gPlayer3Controller = &gControllers[2];
struct DemoInput *gCurrDemoInput = NULL; // demo input sequence
struct Controller *gPlayer3Controller = &gControllers[2]; // Probably debug only, see note below
// Title Screen Demo Handler
struct DemoInput *gCurrDemoInput = NULL;
u16 gDemoInputListID = 0;
struct DemoInput gRecordedDemoInput = { 0 }; // possibly removed in EU. TODO: Check
struct DemoInput gRecordedDemoInput = { 0 };
// Display
// ----------------------------------------------------------------------------------------------------
/**
* Initializes the Reality Display Processor (RDP).
* This function initializes settings such as texture filtering mode,
* scissoring, and render mode (although keep in mind that this render
* mode is not used in-game, where it is set in render_graph_node.c).
* Sets the initial RDP (Reality Display Processor) rendering settings.
*/
void my_rdp_init(void) {
void init_rdp(void) {
gDPPipeSync(gDisplayListHead++);
gDPPipelineMode(gDisplayListHead++, G_PM_1PRIMITIVE);
@@ -92,11 +112,9 @@ void my_rdp_init(void) {
}
/**
* Initializes the RSP's built-in geometry and lighting engines.
* Most of these (with the notable exception of gSPNumLights), are
* almost immediately overwritten.
* Sets the initial RSP (Reality Signal Processor) settings.
*/
void my_rsp_init(void) {
void init_rsp(void) {
gSPClearGeometryMode(gDisplayListHead++, G_SHADE | G_SHADING_SMOOTH | G_CULL_BOTH | G_FOG
| G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD);
@@ -105,17 +123,17 @@ void my_rsp_init(void) {
gSPNumLights(gDisplayListHead++, NUMLIGHTS_1);
gSPTexture(gDisplayListHead++, 0, 0, 0, G_TX_RENDERTILE, G_OFF);
// @bug Nintendo did not explicitly define the clipping ratio.
// For Fast3DEX2, this causes the dreaded warped vertices issue
// unless the clipping ratio is changed back to the intended value,
// as Fast3DEX2 uses a different initial value than Fast3D(EX).
// @bug Failing to set the clip ratio will result in warped triangles in F3DEX2
// without this change: https://jrra.zone/n64/doc/n64man/gsp/gSPClipRatio.htm
#ifdef F3DEX_GBI_2
gSPClipRatio(gDisplayListHead++, FRUSTRATIO_1);
#endif
}
/** Clear the Z buffer. */
void clear_z_buffer(void) {
/**
* Initialize the z buffer for the current frame.
*/
void init_z_buffer(void) {
gDPPipeSync(gDisplayListHead++);
gDPSetDepthSource(gDisplayListHead++, G_ZS_PIXEL);
@@ -129,18 +147,23 @@ void clear_z_buffer(void) {
SCREEN_HEIGHT - 1 - BORDER_HEIGHT);
}
/** Sets up the final framebuffer image. */
void display_frame_buffer(void) {
/**
* Tells the RDP which of the three framebuffers it shall draw to.
*/
void select_frame_buffer(void) {
gDPPipeSync(gDisplayListHead++);
gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE);
gDPSetColorImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH,
gPhysicalFrameBuffers[frameBufferIndex]);
gPhysicalFrameBuffers[sRenderingFrameBuffer]);
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, BORDER_HEIGHT, SCREEN_WIDTH,
SCREEN_HEIGHT - BORDER_HEIGHT);
}
/** Clears the framebuffer, allowing it to be overwritten. */
/**
* Clear the framebuffer and fill it with a 32-bit color.
* Information about the color argument: https://jrra.zone/n64/doc/n64man/gdp/gDPSetFillColor.htm
*/
void clear_frame_buffer(s32 color) {
gDPPipeSync(gDisplayListHead++);
@@ -157,7 +180,9 @@ void clear_frame_buffer(s32 color) {
gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE);
}
/** Clears and initializes the viewport. */
/**
* Resets the viewport, readying it for the final image.
*/
void clear_viewport(Vp *viewport, s32 color) {
s16 vpUlx = (viewport->vp.vtrans[0] - viewport->vp.vscale[0]) / 4 + 1;
s16 vpUly = (viewport->vp.vtrans[1] - viewport->vp.vscale[1]) / 4 + 1;
@@ -182,7 +207,9 @@ void clear_viewport(Vp *viewport, s32 color) {
gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE);
}
/** Draws the horizontal screen borders */
/**
* Draw the horizontal screen borders.
*/
void draw_screen_borders(void) {
gDPPipeSync(gDisplayListHead++);
@@ -201,6 +228,10 @@ void draw_screen_borders(void) {
#endif
}
/**
* Defines the viewport scissoring rectangle.
* Scissoring: https://jrra.zone/n64/doc/pro-man/pro12/12-03.htm#01
*/
void make_viewport_clip_rect(Vp *viewport) {
s16 vpUlx = (viewport->vp.vtrans[0] - viewport->vp.vscale[0]) / 4 + 1;
s16 vpPly = (viewport->vp.vtrans[1] - viewport->vp.vscale[1]) / 4 + 1;
@@ -211,14 +242,13 @@ void make_viewport_clip_rect(Vp *viewport) {
}
/**
* Loads the F3D microcodes.
* Refer to this function if you would like to load
* other microcodes (i.e. S2DEX).
* Initializes the Fast3D OSTask structure.
* If you plan on using gSPLoadUcode, make sure to add OS_TASK_LOADABLE to the flags member.
*/
void create_task_structure(void) {
void create_gfx_task_structure(void) {
s32 entries = gDisplayListHead - gGfxPool->buffer;
gGfxSPTask->msgqueue = &D_80339CB8;
gGfxSPTask->msgqueue = &gGfxVblankQueue;
gGfxSPTask->msg = (OSMesg) 2;
gGfxSPTask->task.t.type = M_GFXTASK;
gGfxSPTask->task.t.ucode_boot = rspF3DBootStart;
@@ -239,16 +269,20 @@ void create_task_structure(void) {
gGfxSPTask->task.t.yield_data_size = OS_YIELD_DATA_SIZE;
}
/** Starts rendering the scene. */
void init_render_image(void) {
/**
* Set default RCP (Reality Co-Processor) settings.
*/
void init_rcp(void) {
move_segment_table_to_dmem();
my_rdp_init();
my_rsp_init();
clear_z_buffer();
display_frame_buffer();
init_rdp();
init_rsp();
init_z_buffer();
select_frame_buffer();
}
/** Ends the master display list. */
/**
* End the master display list and initialize the graphics task structure for the next frame to be rendered.
*/
void end_master_display_list(void) {
draw_screen_borders();
if (gShowProfiler) {
@@ -258,94 +292,113 @@ void end_master_display_list(void) {
gDPFullSync(gDisplayListHead++);
gSPEndDisplayList(gDisplayListHead++);
create_task_structure();
create_gfx_task_structure();
}
/**
* Draw the bars that appear when the N64 is soft reset.
*/
void draw_reset_bars(void) {
s32 sp24;
s32 sp20;
s32 width, height;
s32 fbNum;
u64 *sp18;
u64 *fbPtr;
if (gResetTimer != 0 && D_8032C648 < 15) {
if (sCurrFBNum == 0) {
if (gResetTimer != 0 && gNmiResetBarsTimer < 15) {
if (sRenderedFramebuffer == 0) {
fbNum = 2;
} else {
fbNum = sCurrFBNum - 1;
fbNum = sRenderedFramebuffer - 1;
}
sp18 = (u64 *) PHYSICAL_TO_VIRTUAL(gPhysicalFrameBuffers[fbNum]);
sp18 += D_8032C648++ * (SCREEN_WIDTH / 4);
fbPtr = (u64 *) PHYSICAL_TO_VIRTUAL(gPhysicalFrameBuffers[fbNum]);
fbPtr += gNmiResetBarsTimer++ * (SCREEN_WIDTH / 4);
for (sp24 = 0; sp24 < ((SCREEN_HEIGHT / 16) + 1); sp24++) {
for (width = 0; width < ((SCREEN_HEIGHT / 16) + 1); width++) {
// Loop must be one line to match on -O2
for (sp20 = 0; sp20 < (SCREEN_WIDTH / 4); sp20++) *sp18++ = 0;
sp18 += ((SCREEN_WIDTH / 4) * 14);
for (height = 0; height < (SCREEN_WIDTH / 4); height++) *fbPtr++ = 0;
fbPtr += ((SCREEN_WIDTH / 4) * 14);
}
}
osWritebackDCacheAll();
osRecvMesg(&gGameVblankQueue, &D_80339BEC, OS_MESG_BLOCK);
osRecvMesg(&gGameVblankQueue, &D_80339BEC, OS_MESG_BLOCK);
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
}
void rendering_init(void) {
/**
* Initial settings for the first rendered frame.
*/
void render_init(void) {
gGfxPool = &gGfxPools[0];
set_segment_base_addr(1, gGfxPool->buffer);
gGfxSPTask = &gGfxPool->spTask;
gDisplayListHead = gGfxPool->buffer;
gGfxPoolEnd = (u8 *) (gGfxPool->buffer + GFX_POOL_SIZE);
init_render_image();
gGfxPoolEnd = (u8 *)(gGfxPool->buffer + GFX_POOL_SIZE);
init_rcp();
clear_frame_buffer(0);
end_master_display_list();
send_display_list(&gGfxPool->spTask);
exec_display_list(&gGfxPool->spTask);
frameBufferIndex++;
sRenderingFrameBuffer++;
gGlobalTimer++;
}
void config_gfx_pool(void) {
gGfxPool = &gGfxPools[gGlobalTimer % 2];
/**
* Selects the location of the F3D output buffer (gDisplayListHead).
*/
void select_gfx_pool(void) {
gGfxPool = &gGfxPools[gGlobalTimer % ARRAY_COUNT(gGfxPools)];
set_segment_base_addr(1, gGfxPool->buffer);
gGfxSPTask = &gGfxPool->spTask;
gDisplayListHead = gGfxPool->buffer;
gGfxPoolEnd = (u8 *) (gGfxPool->buffer + GFX_POOL_SIZE);
}
/** Handles vsync. */
/**
* This function:
* - Sends the current master display list out to be rendered.
* - Tells the VI which color framebuffer to be displayed.
* - Yields to the VI framerate twice, locking the game at 30 FPS.
* - Selects which framebuffer will be rendered and displayed to next time.
*/
void display_and_vsync(void) {
profiler_log_thread5_time(BEFORE_DISPLAY_LISTS);
osRecvMesg(&D_80339CB8, &D_80339BEC, OS_MESG_BLOCK);
osRecvMesg(&gGfxVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
if (gGoddardVblankCallback != NULL) {
gGoddardVblankCallback();
gGoddardVblankCallback = NULL;
}
send_display_list(&gGfxPool->spTask);
exec_display_list(&gGfxPool->spTask);
profiler_log_thread5_time(AFTER_DISPLAY_LISTS);
osRecvMesg(&gGameVblankQueue, &D_80339BEC, OS_MESG_BLOCK);
osViSwapBuffer((void *) PHYSICAL_TO_VIRTUAL(gPhysicalFrameBuffers[sCurrFBNum]));
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
osViSwapBuffer((void *) PHYSICAL_TO_VIRTUAL(gPhysicalFrameBuffers[sRenderedFramebuffer]));
profiler_log_thread5_time(THREAD5_END);
osRecvMesg(&gGameVblankQueue, &D_80339BEC, OS_MESG_BLOCK);
if (++sCurrFBNum == 3) {
sCurrFBNum = 0;
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
if (++sRenderedFramebuffer == 3) {
sRenderedFramebuffer = 0;
}
if (++frameBufferIndex == 3) {
frameBufferIndex = 0;
if (++sRenderingFrameBuffer == 3) {
sRenderingFrameBuffer = 0;
}
gGlobalTimer++;
}
// this function records distinct inputs over a 255-frame interval to RAM locations and was likely
// used to record the demo sequences seen in the final game. This function is unused.
static void record_demo(void) {
// record the player's button mask and current rawStickX and rawStickY.
// Controls
// ----------------------------------------------------------------------------------------------------
/**
* This function records distinct inputs over a 255-frame interval to RAM locations and was likely
* used to record the demo sequences seen in the final game. This function is unused.
*/
UNUSED static void record_demo(void) {
// Record the player's button mask and current rawStickX and rawStickY.
u8 buttonMask =
((gPlayer1Controller->buttonDown & (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON)) >> 8)
| (gPlayer1Controller->buttonDown & (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS));
s8 rawStickX = gPlayer1Controller->rawStickX;
s8 rawStickY = gPlayer1Controller->rawStickY;
// if the stick is in deadzone, set its value to 0 to
// If the stick is in deadzone, set its value to 0 to
// nullify the effects. We do not record deadzone inputs.
if (rawStickX > -8 && rawStickX < 8) {
rawStickX = 0;
@@ -355,9 +408,8 @@ static void record_demo(void) {
rawStickY = 0;
}
// record the distinct input and timer so long as they
// are unique. If the timer hits 0xFF, reset the timer
// for the next demo input.
// Rrecord the distinct input and timer so long as they are unique.
// If the timer hits 0xFF, reset the timer for the next demo input.
if (gRecordedDemoInput.timer == 0xFF || buttonMask != gRecordedDemoInput.buttonMask
|| rawStickX != gRecordedDemoInput.rawStickX || rawStickY != gRecordedDemoInput.rawStickY) {
gRecordedDemoInput.timer = 0;
@@ -368,16 +420,17 @@ static void record_demo(void) {
gRecordedDemoInput.timer++;
}
// take the updated controller struct and calculate
// the new x, y, and distance floats.
/**
* Take the updated controller struct and calculate the new x, y, and distance floats.
*/
void adjust_analog_stick(struct Controller *controller) {
UNUSED u8 pad[8];
// reset the controller's x and y floats.
// Reset the controller's x and y floats.
controller->stickX = 0;
controller->stickY = 0;
// modulate the rawStickX and rawStickY to be the new f32 values by adding/subtracting 6.
// Modulate the rawStickX and rawStickY to be the new f32 values by adding/subtracting 6.
if (controller->rawStickX <= -8) {
controller->stickX = controller->rawStickX + 6;
}
@@ -394,12 +447,12 @@ void adjust_analog_stick(struct Controller *controller) {
controller->stickY = controller->rawStickY - 6;
}
// calculate f32 magnitude from the center by vector length.
// Calculate f32 magnitude from the center by vector length.
controller->stickMag =
sqrtf(controller->stickX * controller->stickX + controller->stickY * controller->stickY);
// magnitude cannot exceed 64.0f: if it does, modify the values appropriately to
// flatten the values down to the allowed maximum value.
// Magnitude cannot exceed 64.0f: if it does, modify the values
// appropriately to flatten the values down to the allowed maximum value.
if (controller->stickMag > 64) {
controller->stickX *= 64 / controller->stickMag;
controller->stickY *= 64 / controller->stickMag;
@@ -407,64 +460,56 @@ void adjust_analog_stick(struct Controller *controller) {
}
}
// if a demo sequence exists, this will run the demo
// input list until it is complete. called every frame.
/**
* If a demo sequence exists, this will run the demo input list until it is complete.
*/
void run_demo_inputs(void) {
// eliminate the unused bits.
// Eliminate the unused bits.
gControllers[0].controllerData->button &= VALID_BUTTONS;
/*
Check if a demo inputs list
exists and if so, run the
active demo input list.
*/
// Check if a demo inputs list exists and if so,
// run the active demo input list.
if (gCurrDemoInput != NULL) {
/*
clear player 2's inputs if they exist. Player 2's controller
cannot be used to influence a demo. At some point, Nintendo
may have planned for there to be a demo where 2 players moved
around instead of just one, so clearing player 2's influence from
the demo had to have been necessary to perform this. Co-op mode, perhaps?
*/
// Clear player 2's inputs if they exist. Player 2's controller
// cannot be used to influence a demo. At some point, Nintendo
// may have planned for there to be a demo where 2 players moved
// around instead of just one, so clearing player 2's influence from
// the demo had to have been necessary to perform this. Co-op mode, perhaps?
if (gControllers[1].controllerData != NULL) {
gControllers[1].controllerData->stick_x = 0;
gControllers[1].controllerData->stick_y = 0;
gControllers[1].controllerData->button = 0;
}
// the timer variable being 0 at the current input means the demo is over.
// set the button to the END_DEMO mask to end the demo.
// The timer variable being 0 at the current input means the demo is over.
// Set the button to the END_DEMO mask to end the demo.
if (gCurrDemoInput->timer == 0) {
gControllers[0].controllerData->stick_x = 0;
gControllers[0].controllerData->stick_y = 0;
gControllers[0].controllerData->button = END_DEMO;
} else {
// backup the start button if it is pressed, since we don't want the
// Backup the start button if it is pressed, since we don't want the
// demo input to override the mask where start may have been pressed.
u16 startPushed = gControllers[0].controllerData->button & START_BUTTON;
// perform the demo inputs by assigning the current button mask and the stick inputs.
// Perform the demo inputs by assigning the current button mask and the stick inputs.
gControllers[0].controllerData->stick_x = gCurrDemoInput->rawStickX;
gControllers[0].controllerData->stick_y = gCurrDemoInput->rawStickY;
/*
to assign the demo input, the button information is stored in
an 8-bit mask rather than a 16-bit mask. this is because only
A, B, Z, Start, and the C-Buttons are used in a demo, as bits
in that order. In order to assign the mask, we need to take the
upper 4 bits (A, B, Z, and Start) and shift then left by 8 to
match the correct input mask. We then add this to the masked
lower 4 bits to get the correct button mask.
*/
// To assign the demo input, the button information is stored in
// an 8-bit mask rather than a 16-bit mask. this is because only
// A, B, Z, Start, and the C-Buttons are used in a demo, as bits
// in that order. In order to assign the mask, we need to take the
// upper 4 bits (A, B, Z, and Start) and shift then left by 8 to
// match the correct input mask. We then add this to the masked
// lower 4 bits to get the correct button mask.
gControllers[0].controllerData->button =
((gCurrDemoInput->buttonMask & 0xF0) << 8) + ((gCurrDemoInput->buttonMask & 0xF));
// if start was pushed, put it into the demo sequence being input to
// end the demo.
// If start was pushed, put it into the demo sequence being input to end the demo.
gControllers[0].controllerData->button |= startPushed;
// run the current demo input's timer down. if it hits 0, advance the
// demo input list.
// Run the current demo input's timer down. if it hits 0, advance the demo input list.
if (--gCurrDemoInput->timer == 0) {
gCurrDemoInput++;
}
@@ -472,16 +517,17 @@ void run_demo_inputs(void) {
}
}
// update the controller struct with available inputs if present.
/**
* Update the controller struct with available inputs if present.
*/
void read_controller_inputs(void) {
s32 i;
// if any controllers are plugged in, update the
// controller information.
// If any controllers are plugged in, update the controller information.
if (gControllerBits) {
osRecvMesg(&gSIEventMesgQueue, &D_80339BEC, OS_MESG_BLOCK);
osRecvMesg(&gSIEventMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
osContGetReadData(&gControllerPads[0]);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
release_rumble_pak_control();
#endif
}
@@ -490,8 +536,7 @@ void read_controller_inputs(void) {
for (i = 0; i < 2; i++) {
struct Controller *controller = &gControllers[i];
// if we're receiving inputs, update the controller struct
// with the new button info.
// if we're receiving inputs, update the controller struct with the new button info.
if (controller->controllerData != NULL) {
controller->rawStickX = controller->controllerData->stick_x;
controller->rawStickY = controller->controllerData->stick_y;
@@ -512,9 +557,9 @@ void read_controller_inputs(void) {
}
}
// For some reason, player 1's inputs are copied to player 3's port. This
// potentially may have been a way the developers "recorded" the inputs
// for demos, despite record_demo existing.
// For some reason, player 1's inputs are copied to player 3's port.
// This potentially may have been a way the developers "recorded"
// the inputs for demos, despite record_demo existing.
gPlayer3Controller->rawStickX = gPlayer1Controller->rawStickX;
gPlayer3Controller->rawStickY = gPlayer1Controller->rawStickY;
gPlayer3Controller->stickX = gPlayer1Controller->stickX;
@@ -524,33 +569,35 @@ void read_controller_inputs(void) {
gPlayer3Controller->buttonDown = gPlayer1Controller->buttonDown;
}
// initialize the controller structs to point at the OSCont information.
/**
* Initialize the controller structs to point at the OSCont information.
*/
void init_controllers(void) {
s16 port, cont;
// set controller 1 to point to the set of status/pads for input 1 and
// Set controller 1 to point to the set of status/pads for input 1 and
// init the controllers.
gControllers[0].statusData = &gControllerStatuses[0];
gControllers[0].controllerData = &gControllerPads[0];
osContInit(&gSIEventMesgQueue, &gControllerBits, &gControllerStatuses[0]);
// strangely enough, the EEPROM probe for save data is done in this function.
// save pak detection?
// Strangely enough, the EEPROM probe for save data is done in this function.
// Save Pak detection?
gEepromProbe = osEepromProbe(&gSIEventMesgQueue);
// loop over the 4 ports and link the controller structs to the appropriate
// Loop over the 4 ports and link the controller structs to the appropriate
// status and pad. Interestingly, although there are pointers to 3 controllers,
// only 2 are connected here. The third seems to have been reserved for debug
// purposes and was never connected in the retail ROM, thus gPlayer3Controller
// cannot be used, despite being referenced in various code.
for (cont = 0, port = 0; port < 4 && cont < 2; port++) {
// is controller plugged in?
// Is controller plugged in?
if (gControllerBits & (1 << port)) {
// the game allows you to have just 1 controller plugged
// The game allows you to have just 1 controller plugged
// into any port in order to play the game. this was probably
// so if any of the ports didn't work, you can have controllers
// plugged into any of them and it will work.
#ifdef VERSION_SH
#if ENABLE_RUMBLE
gControllers[cont].port = port;
#endif
gControllers[cont].statusData = &gControllerStatuses[port];
@@ -559,69 +606,83 @@ void init_controllers(void) {
}
}
void setup_game_memory(void) {
UNUSED u8 pad[8];
// Game thread core
// ----------------------------------------------------------------------------------------------------
/**
* Setup main segments and framebuffers.
*/
void setup_game_memory(void) {
UNUSED u64 padding;
// Setup general Segment 0
set_segment_base_addr(0, (void *) 0x80000000);
osCreateMesgQueue(&D_80339CB8, &D_80339CD4, 1);
osCreateMesgQueue(&gGameVblankQueue, &D_80339CD0, 1);
// Create Mesg Queues
osCreateMesgQueue(&gGfxVblankQueue, gGfxMesgBuf, ARRAY_COUNT(gGfxMesgBuf));
osCreateMesgQueue(&gGameVblankQueue, gGameMesgBuf, ARRAY_COUNT(gGameMesgBuf));
// Setup z buffer and framebuffer
gPhysicalZBuffer = VIRTUAL_TO_PHYSICAL(gZBuffer);
gPhysicalFrameBuffers[0] = VIRTUAL_TO_PHYSICAL(gFrameBuffer0);
gPhysicalFrameBuffers[1] = VIRTUAL_TO_PHYSICAL(gFrameBuffer1);
gPhysicalFrameBuffers[2] = VIRTUAL_TO_PHYSICAL(gFrameBuffer2);
D_80339CF0 = main_pool_alloc(0x4000, MEMORY_POOL_LEFT);
set_segment_base_addr(17, (void *) D_80339CF0);
func_80278A78(&D_80339D10, gMarioAnims, D_80339CF0);
D_80339CF4 = main_pool_alloc(2048, MEMORY_POOL_LEFT);
set_segment_base_addr(24, (void *) D_80339CF4);
func_80278A78(&gDemo, gDemoInputs, D_80339CF4);
// Setup Mario Animations
gMarioAnimsMemAlloc = main_pool_alloc(0x4000, MEMORY_POOL_LEFT);
set_segment_base_addr(17, (void *) gMarioAnimsMemAlloc);
setup_dma_table_list(&gMarioAnimsBuf, gMarioAnims, gMarioAnimsMemAlloc);
// Setup Demo Inputs List
gDemoInputsMemAlloc = main_pool_alloc(0x800, MEMORY_POOL_LEFT);
set_segment_base_addr(24, (void *) gDemoInputsMemAlloc);
setup_dma_table_list(&gDemoInputsBuf, gDemoInputs, gDemoInputsMemAlloc);
// Setup Level Script Entry
load_segment(0x10, _entrySegmentRomStart, _entrySegmentRomEnd, MEMORY_POOL_LEFT);
// Setup Segment 2 (Fonts, Text, etc)
load_segment_decompress(2, _segment2_mio0SegmentRomStart, _segment2_mio0SegmentRomEnd);
}
// main game loop thread. runs forever as long as the game
// continues.
/**
* Main game loop thread. Runs forever as long as the game continues.
*/
void thread5_game_loop(UNUSED void *arg) {
struct LevelCommand *addr;
setup_game_memory();
#ifdef VERSION_SH
#if ENABLE_RUMBLE
init_rumble_pak_scheduler_queue();
#endif
init_controllers();
#ifdef VERSION_SH
#if ENABLE_RUMBLE
create_thread_6();
#endif
save_file_load_all();
set_vblank_handler(2, &gGameVblankHandler, &gGameVblankQueue, (OSMesg) 1);
// point addr to the entry point into the level script data.
// Point address to the entry point into the level script data.
addr = segmented_to_virtual(level_script_entry);
play_music(SEQ_PLAYER_SFX, SEQUENCE_ARGS(0, SEQ_SOUND_PLAYER), 0);
set_sound_mode(save_file_get_sound_mode());
rendering_init();
render_init();
while (TRUE) {
// if the reset timer is active, run the process to reset the game.
// If the reset timer is active, run the process to reset the game.
if (gResetTimer) {
draw_reset_bars();
continue;
}
profiler_log_thread5_time(THREAD5_START);
// if any controllers are plugged in, start read the data for when
// If any controllers are plugged in, start read the data for when
// read_controller_inputs is called later.
if (gControllerBits) {
#ifdef VERSION_SH
#if ENABLE_RUMBLE
block_until_rumble_pak_free();
#endif
osContStartReadData(&gSIEventMesgQueue);
}
audio_game_loop_tick();
config_gfx_pool();
select_gfx_pool();
read_controller_inputs();
addr = level_script_execute(addr);
+12 -12
View File
@@ -9,7 +9,7 @@
#include "types.h"
#include "memory.h"
#define GFX_POOL_SIZE 6400
#define GFX_POOL_SIZE 6400 // Size of how large the master display list (gDisplayListHead) can be
struct GfxPool {
Gfx buffer[GFX_POOL_SIZE];
@@ -28,14 +28,14 @@ extern struct Controller gControllers[3];
extern OSContStatus gControllerStatuses[4];
extern OSContPad gControllerPads[4];
extern OSMesgQueue gGameVblankQueue;
extern OSMesgQueue D_80339CB8;
extern OSMesg D_80339CD0;
extern OSMesg D_80339CD4;
extern OSMesgQueue gGfxVblankQueue;
extern OSMesg gGameMesgBuf[1];
extern OSMesg gGfxMesgBuf[1];
extern struct VblankHandler gGameVblankHandler;
extern uintptr_t gPhysicalFrameBuffers[3];
extern uintptr_t gPhysicalZBuffer;
extern void *D_80339CF0;
extern void *D_80339CF4;
extern void *gMarioAnimsMemAlloc;
extern void *gDemoInputsMemAlloc;
extern struct SPTask *gGfxSPTask;
extern Gfx *gDisplayListHead;
extern u8 *gGfxPoolEnd;
@@ -53,13 +53,13 @@ extern struct DemoInput gRecordedDemoInput;
// this area is the demo input + the header. when the demo is loaded in, there is a header the size
// of a single word next to the input list. this word is the current ID count.
extern struct MarioAnimation D_80339D10;
extern struct MarioAnimation gDemo;
extern struct DmaHandlerList gMarioAnimsBuf;
extern struct DmaHandlerList gDemoInputsBuf;
extern u8 gMarioAnims[];
extern u8 gDemoInputs[];
extern u16 frameBufferIndex;
extern u16 sRenderingFrameBuffer;
extern u32 gGlobalTimer;
void setup_game_memory(void);
@@ -67,10 +67,10 @@ void thread5_game_loop(UNUSED void *arg);
void clear_frame_buffer(s32 color);
void clear_viewport(Vp *viewport, s32 color);
void make_viewport_clip_rect(Vp *viewport);
void init_render_image(void);
void init_rcp(void);
void end_master_display_list(void);
void rendering_init(void);
void config_gfx_pool(void);
void render_init(void);
void select_gfx_pool(void);
void display_and_vsync(void);
#endif // GAME_INIT_H
+1 -1
View File
@@ -53,7 +53,7 @@ static struct PowerMeterHUD sPowerMeterHUD = {
// when the power meter is hidden.
s32 sPowerMeterVisibleTimer = 0;
static struct UnusedHUDStruct sUnusedHUDValues = { 0x00, 0x0A, 0x00 };
UNUSED static struct UnusedHUDStruct sUnusedHUDValues = { 0x00, 0x0A, 0x00 };
static struct CameraHUD sCameraHUD = { CAM_STATUS_NONE };
+65 -63
View File
@@ -99,7 +99,7 @@ f32 gDialogBoxOpenTimer = DEFAULT_DIALOG_BOX_ANGLE;
f32 gDialogBoxScale = DEFAULT_DIALOG_BOX_SCALE;
s16 gDialogScrollOffsetY = 0;
s8 gDialogBoxType = DIALOG_TYPE_ROTATE;
s16 gDialogID = -1;
s16 gDialogID = DIALOG_NONE;
s16 gLastDialogPageStrPos = 0;
s16 gDialogTextPos = 0;
#ifdef VERSION_EU
@@ -109,7 +109,7 @@ s8 gDialogLineNum = 1;
s8 gLastDialogResponse = 0;
u8 gMenuHoldKeyIndex = 0;
u8 gMenuHoldKeyTimer = 0;
s32 gDialogResponse = 0;
s32 gDialogResponse = DIALOG_RESPONSE_NONE;
void create_dl_identity_matrix(void) {
@@ -197,6 +197,9 @@ void create_dl_ortho_matrix(void) {
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(matrix), G_MTX_PROJECTION | G_MTX_MUL | G_MTX_NOPUSH)
}
#if !defined(VERSION_JP) && !defined(VERSION_SH)
UNUSED
#endif
static u8 *alloc_ia8_text_from_i1(u16 *in, s16 width, s16 height) {
s32 inPos;
u16 bitMask;
@@ -878,14 +881,14 @@ s16 get_dialog_id(void) {
}
void create_dialog_box(s16 dialog) {
if (gDialogID == -1) {
if (gDialogID == DIALOG_NONE) {
gDialogID = dialog;
gDialogBoxType = DIALOG_TYPE_ROTATE;
}
}
void create_dialog_box_with_var(s16 dialog, s32 dialogVar) {
if (gDialogID == -1) {
if (gDialogID == DIALOG_NONE) {
gDialogID = dialog;
gDialogVariable = dialogVar;
gDialogBoxType = DIALOG_TYPE_ROTATE;
@@ -893,14 +896,14 @@ void create_dialog_box_with_var(s16 dialog, s32 dialogVar) {
}
void create_dialog_inverted_box(s16 dialog) {
if (gDialogID == -1) {
if (gDialogID == DIALOG_NONE) {
gDialogID = dialog;
gDialogBoxType = DIALOG_TYPE_ZOOM;
}
}
void create_dialog_box_with_response(s16 dialog) {
if (gDialogID == -1) {
if (gDialogID == DIALOG_NONE) {
gDialogID = dialog;
gDialogBoxType = DIALOG_TYPE_ROTATE;
gLastDialogResponse = 1;
@@ -917,11 +920,11 @@ void reset_dialog_render_state(void) {
gDialogBoxScale = 19.0f;
gDialogBoxOpenTimer = 90.0f;
gDialogBoxState = DIALOG_STATE_OPENING;
gDialogID = -1;
gDialogID = DIALOG_NONE;
gDialogTextPos = 0;
gLastDialogResponse = 0;
gLastDialogPageStrPos = 0;
gDialogResponse = 0;
gDialogResponse = DIALOG_RESPONSE_NONE;
}
#if defined(VERSION_JP) || defined(VERSION_SH)
@@ -1527,18 +1530,18 @@ void render_dialog_string_color(s8 linesPerBox) {
void handle_special_dialog_text(s16 dialogID) { // dialog ID tables, in order
// King Bob-omb (Start), Whomp (Start), King Bob-omb (throw him out), Eyerock (Start), Wiggler (Start)
s16 dialogBossStart[] = { 17, 114, 128, 117, 150 };
s16 dialogBossStart[] = { DIALOG_017, DIALOG_114, DIALOG_128, DIALOG_117, DIALOG_150 };
// Koopa the Quick (BOB), Koopa the Quick (THI), Penguin Race, Fat Penguin Race (120 stars)
s16 dialogRaceSound[] = { 5, 9, 55, 164 };
s16 dialogRaceSound[] = { DIALOG_005, DIALOG_009, DIALOG_055, DIALOG_164 };
// Red Switch, Green Switch, Blue Switch, 100 coins star, Bowser Red Coin Star
s16 dialogStarSound[] = { 10, 11, 12, 13, 14 };
s16 dialogStarSound[] = { DIALOG_010, DIALOG_011, DIALOG_012, DIALOG_013, DIALOG_014 };
// King Bob-omb (Start), Whomp (Defeated), King Bob-omb (Defeated, missing in JP), Eyerock (Defeated), Wiggler (Defeated)
#if BUGFIX_KING_BOB_OMB_FADE_MUSIC
s16 dialogBossStop[] = { 17, 115, 116, 118, 152 };
s16 dialogBossStop[] = { DIALOG_017, DIALOG_115, DIALOG_116, DIALOG_118, DIALOG_152 };
#else
//! @bug JP misses King Bob-omb defeated dialog "116", meaning that the boss music will still
//! @bug JP misses King Bob-omb defeated DIALOG_116, meaning that the boss music will still
//! play after King Bob-omb is defeated until BOB loads it's music after the star cutscene
s16 dialogBossStop[] = { 17, 115, 118, 152 };
s16 dialogBossStop[] = { DIALOG_017, DIALOG_115, DIALOG_118, DIALOG_152 };
#endif
s16 i;
@@ -1572,7 +1575,7 @@ void handle_special_dialog_text(s16 dialogID) { // dialog ID tables, in order
}
}
s16 gMenuMode = -1;
s16 gMenuMode = MENU_MODE_NONE;
u8 gEndCutsceneStrEn0[] = { TEXT_FILE_MARIO_EXCLAMATION };
u8 gEndCutsceneStrEn1[] = { TEXT_POWER_STARS_RESTORED };
@@ -1701,7 +1704,7 @@ void render_dialog_entries(void) {
// if the dialog entry is invalid, set the ID to -1.
if (segmented_to_virtual(NULL) == dialog) {
gDialogID = -1;
gDialogID = DIALOG_NONE;
return;
}
@@ -1779,11 +1782,11 @@ void render_dialog_entries(void) {
if (gDialogBoxOpenTimer == DEFAULT_DIALOG_BOX_ANGLE) {
gDialogBoxState = DIALOG_STATE_OPENING;
gDialogID = -1;
gDialogID = DIALOG_NONE;
gDialogTextPos = 0;
gLastDialogResponse = 0;
gLastDialogPageStrPos = 0;
gDialogResponse = 0;
gDialogResponse = DIALOG_RESPONSE_NONE;
}
#if !defined(VERSION_JP)
lowerBound = 1;
@@ -1841,7 +1844,7 @@ void render_dialog_entries(void) {
// Calls a gMenuMode value defined by render_menus_and_dialogs cases
void set_menu_mode(s16 mode) {
if (gMenuMode == -1) {
if (gMenuMode == MENU_MODE_NONE) {
gMenuMode = mode;
}
}
@@ -2062,7 +2065,7 @@ void print_peach_letter_message(void) {
if (gCutsceneMsgTimer > (PEACH_MESSAGE_TIMER + 20)) {
gCutsceneMsgIndex = -1;
gCutsceneMsgFade = 0; //! uselessly reset since the next execution will just set it to 0 again.
gDialogID = -1;
gDialogID = DIALOG_NONE;
gCutsceneMsgTimer = 0;
return; // return to avoid incrementing the timer
}
@@ -2336,17 +2339,17 @@ void render_pause_camera_options(s16 x, s16 y, s8 *index, s16 xIndex) {
print_generic_string(x + TXT2_X, y - 13, textNormalFixed);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
create_dl_translation_matrix(MENU_MTX_PUSH, ((index[0] - 1) * xIndex) + x, y + Y_VAL7, 0);
create_dl_translation_matrix(MENU_MTX_PUSH, ((*index - 1) * xIndex) + x, y + Y_VAL7, 0);
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha);
gSPDisplayList(gDisplayListHead++, dl_draw_triangle);
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
switch (index[0]) {
case 1:
cam_select_alt_mode(1);
switch (*index) {
case CAM_SELECTION_MARIO:
cam_select_alt_mode(CAM_SELECTION_MARIO);
break;
case 2:
cam_select_alt_mode(2);
case CAM_SELECTION_FIXED:
cam_select_alt_mode(CAM_SELECTION_FIXED);
break;
}
}
@@ -2393,18 +2396,18 @@ void render_pause_course_options(s16 x, s16 y, s8 *index, s16 yIndex) {
print_generic_string(x + 10, y - 2, textContinue);
print_generic_string(x + 10, y - 17, textExitCourse);
if (index[0] != 3) {
if (*index != MENU_OPT_CAMERA_ANGLE_R) {
print_generic_string(x + 10, y - 33, textCameraAngleR);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
create_dl_translation_matrix(MENU_MTX_PUSH, x - X_VAL8, (y - ((index[0] - 1) * yIndex)) - Y_VAL8, 0);
create_dl_translation_matrix(MENU_MTX_PUSH, x - X_VAL8, (y - ((*index - 1) * yIndex)) - Y_VAL8, 0);
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha);
gSPDisplayList(gDisplayListHead++, dl_draw_triangle);
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
}
if (index[0] == 3) {
if (*index == MENU_OPT_CAMERA_ANGLE_R) {
render_pause_camera_options(x - 42, y - 42, &gDialogCameraAngleIndex, 110);
}
}
@@ -2597,7 +2600,7 @@ s32 gCourseCompleteCoins = 0;
s8 gHudFlash = 0;
s16 render_pause_courses_and_castle(void) {
s16 num;
s16 index;
#ifdef VERSION_EU
gInGameLanguage = eu_get_language();
@@ -2605,7 +2608,7 @@ s16 render_pause_courses_and_castle(void) {
switch (gDialogBoxState) {
case DIALOG_STATE_OPENING:
gDialogLineNum = 1;
gDialogLineNum = MENU_OPT_DEFAULT;
gDialogTextAlpha = 0;
level_set_transition(-1, NULL);
#ifdef VERSION_JP
@@ -2641,15 +2644,15 @@ s16 render_pause_courses_and_castle(void) {
level_set_transition(0, NULL);
play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource);
gDialogBoxState = DIALOG_STATE_OPENING;
gMenuMode = -1;
gMenuMode = MENU_MODE_NONE;
if (gDialogLineNum == 2) {
num = gDialogLineNum;
} else {
num = 1;
if (gDialogLineNum == MENU_OPT_EXIT_COURSE) {
index = gDialogLineNum;
} else { // MENU_OPT_CONTINUE or MENU_OPT_CAMERA_ANGLE_R
index = MENU_OPT_DEFAULT;
}
return num;
return index;
}
break;
case DIALOG_STATE_HORIZONTAL:
@@ -2667,10 +2670,10 @@ s16 render_pause_courses_and_castle(void) {
{
level_set_transition(0, NULL);
play_sound(SOUND_MENU_PAUSE_2, gGlobalSoundSource);
gMenuMode = -1;
gMenuMode = MENU_MODE_NONE;
gDialogBoxState = DIALOG_STATE_OPENING;
return 1;
return MENU_OPT_DEFAULT;
}
break;
}
@@ -2679,7 +2682,7 @@ s16 render_pause_courses_and_castle(void) {
gDialogTextAlpha += 25;
}
return 0;
return MENU_OPT_NONE;
}
#if defined(VERSION_JP)
@@ -2770,7 +2773,7 @@ void print_hud_course_complete_coins(s16 x, s16 y) {
if (gCourseCompleteCoins == 50 || gCourseCompleteCoins == 100 || gCourseCompleteCoins == 150) {
play_sound(SOUND_GENERAL_COLLECT_1UP, gGlobalSoundSource);
gMarioState[0].numLives++;
gMarioState->numLives++;
}
}
@@ -2976,7 +2979,7 @@ void render_save_confirmation(s16 x, s16 y, s8 *index, s16 sp6e)
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
create_dl_translation_matrix(MENU_MTX_PUSH, X_VAL9, y - ((index[0] - 1) * sp6e), 0);
create_dl_translation_matrix(MENU_MTX_PUSH, X_VAL9, y - ((*index - 1) * sp6e), 0);
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, gDialogTextAlpha);
gSPDisplayList(gDisplayListHead++, dl_draw_triangle);
@@ -2985,7 +2988,7 @@ void render_save_confirmation(s16 x, s16 y, s8 *index, s16 sp6e)
}
s16 render_course_complete_screen(void) {
s16 num;
s16 index;
#ifdef VERSION_EU
gInGameLanguage = eu_get_language();
#endif
@@ -2997,7 +3000,7 @@ s16 render_course_complete_screen(void) {
gDialogBoxState = DIALOG_STATE_VERTICAL;
level_set_transition(-1, NULL);
gDialogTextAlpha = 0;
gDialogLineNum = 1;
gDialogLineNum = MENU_OPT_DEFAULT;
}
break;
case DIALOG_STATE_VERTICAL:
@@ -3019,14 +3022,14 @@ s16 render_course_complete_screen(void) {
level_set_transition(0, NULL);
play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource);
gDialogBoxState = DIALOG_STATE_OPENING;
gMenuMode = -1;
num = gDialogLineNum;
gMenuMode = MENU_MODE_NONE;
index = gDialogLineNum;
gCourseDoneMenuTimer = 0;
gCourseCompleteCoins = 0;
gCourseCompleteCoinsEqual = 0;
gHudFlash = 0;
return num;
return index;
}
break;
}
@@ -3037,41 +3040,40 @@ s16 render_course_complete_screen(void) {
gCourseDoneMenuTimer++;
return 0;
return MENU_OPT_NONE;
}
// Only case 1 and 2 are used
s16 render_menus_and_dialogs(void) {
s16 mode = 0;
s16 index = MENU_OPT_NONE;
create_dl_ortho_matrix();
if (gMenuMode != -1) {
if (gMenuMode != MENU_MODE_NONE) {
switch (gMenuMode) {
case 0:
mode = render_pause_courses_and_castle();
case MENU_MODE_UNUSED_0:
index = render_pause_courses_and_castle();
break;
case 1:
mode = render_pause_courses_and_castle();
case MENU_MODE_RENDER_PAUSE_SCREEN:
index = render_pause_courses_and_castle();
break;
case 2:
mode = render_course_complete_screen();
case MENU_MODE_RENDER_COURSE_COMPLETE_SCREEN:
index = render_course_complete_screen();
break;
case 3:
mode = render_course_complete_screen();
case MENU_MODE_UNUSED_3:
index = render_course_complete_screen();
break;
}
gDialogColorFadeTimer = (s16) gDialogColorFadeTimer + 0x1000;
} else if (gDialogID != -1) {
} else if (gDialogID != DIALOG_NONE) {
// The Peach "Dear Mario" message needs to be repositioned separately
if (gDialogID == 20) {
if (gDialogID == DIALOG_020) {
print_peach_letter_message();
return mode;
return index;
}
render_dialog_entries();
gDialogColorFadeTimer = (s16) gDialogColorFadeTimer + 0x1000;
}
return mode;
return index;
}
+15 -3
View File
@@ -27,9 +27,13 @@
#define HUD_LUT_DIFF HUD_LUT_GLOBAL
#endif
#define RENDER_PAUSE_SCREEN 1
#define RENDER_COURSE_DONE_SCREEN 2
enum MenuMode {
MENU_MODE_NONE = -1,
MENU_MODE_UNUSED_0,
MENU_MODE_RENDER_PAUSE_SCREEN,
MENU_MODE_RENDER_COURSE_COMPLETE_SCREEN,
MENU_MODE_UNUSED_3
};
extern s8 gDialogCourseActNum;
extern s8 gHudFlash;
@@ -105,6 +109,14 @@ enum DialogSpecialChars {
DIALOG_CHAR_TERMINATOR = 0xFF
};
// gDialogResponse
enum DialogResponseDefines {
DIALOG_RESPONSE_NONE,
DIALOG_RESPONSE_YES,
DIALOG_RESPONSE_NO,
DIALOG_RESPONSE_NOT_DEFINED
};
extern s32 gDialogResponse;
extern u16 gDialogColorFadeTimer;
extern s8 gLastDialogLineNum;
+21 -20
View File
@@ -336,7 +336,7 @@ void mario_stop_riding_and_holding(struct MarioState *m) {
mario_stop_riding_object(m);
if (m->action == ACT_RIDING_HOOT) {
m->usedObj->oInteractStatus = 0;
m->usedObj->oInteractStatus = FALSE;
m->usedObj->oHootMarioReleaseTime = gGlobalTimer;
}
}
@@ -526,7 +526,7 @@ void hit_object_from_below(struct MarioState *m, UNUSED struct Object *o) {
set_camera_shake_from_hit(SHAKE_HIT_FROM_BELOW);
}
static u32 unused_determine_knockback_action(struct MarioState *m) {
UNUSED static u32 unused_determine_knockback_action(struct MarioState *m) {
u32 bonkAction;
s16 angleToObject = mario_obj_angle_to_object(m, m->interactObj);
s16 facingDYaw = angleToObject - m->faceAngle[1];
@@ -699,7 +699,7 @@ u32 take_damage_from_interact_object(struct MarioState *m) {
m->hurtCounter += 4 * damage;
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
set_camera_shake_from_hit(shake);
@@ -750,7 +750,7 @@ u32 interact_coin(struct MarioState *m, UNUSED u32 interactType, struct Object *
&& m->numCoins >= 100) {
bhv_spawn_star_no_level_exit(6);
}
#ifdef VERSION_SH
#if ENABLE_RUMBLE
if (o->oDamageOrCoinValue >= 2) {
queue_rumble_data(5, 80);
}
@@ -773,7 +773,7 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O
if (m->health >= 0x100) {
mario_stop_riding_and_holding(m);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
@@ -876,7 +876,7 @@ u32 interact_warp(struct MarioState *m, UNUSED u32 interactType, struct Object *
m->interactObj = o;
m->usedObj = o;
#ifdef VERSION_SH
#if ENABLE_RUMBLE
if (o->collisionData == segmented_to_virtual(warp_pipe_seg3_collision_03009AC8)) {
play_sound(SOUND_MENU_ENTER_PIPE, m->marioObj->header.gfx.cameraToObject);
queue_rumble_data(15, 80);
@@ -1100,7 +1100,7 @@ u32 interact_tornado(struct MarioState *m, UNUSED u32 interactType, struct Objec
marioObj->oMarioTornadoPosY = m->pos[1] - o->oPosY;
play_sound(SOUND_MARIO_WAAAOOOW, m->marioObj->header.gfx.cameraToObject);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(30, 60);
#endif
return set_mario_action(m, ACT_TORNADO_TWIRLING, m->action == ACT_TWIRLING);
@@ -1123,7 +1123,7 @@ u32 interact_whirlpool(struct MarioState *m, UNUSED u32 interactType, struct Obj
marioObj->oMarioWhirlpoolPosY = m->pos[1] - o->oPosY;
play_sound(SOUND_MARIO_WAAAOOOW, m->marioObj->header.gfx.cameraToObject);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(30, 60);
#endif
return set_mario_action(m, ACT_CAUGHT_IN_WHIRLPOOL, 0);
@@ -1159,7 +1159,7 @@ u32 interact_flame(struct MarioState *m, UNUSED u32 interactType, struct Object
if (!sInvulnerable && !(m->flags & MARIO_METAL_CAP) && !(m->flags & MARIO_VANISH_CAP)
&& !(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY)) {
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
o->oInteractStatus = INT_STATUS_INTERACTED;
@@ -1238,7 +1238,7 @@ u32 interact_bully(struct MarioState *m, UNUSED u32 interactType, struct Object
m->interactObj = o;
if (interaction & INT_ATTACK_NOT_FROM_BELOW) {
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
push_mario_out_of_object(m, o, 5.0f);
@@ -1263,7 +1263,7 @@ u32 interact_bully(struct MarioState *m, UNUSED u32 interactType, struct Object
push_mario_out_of_object(m, o, 5.0f);
drop_and_set_mario_action(m, bully_knock_back_mario(m), 0);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
return TRUE;
@@ -1282,7 +1282,7 @@ u32 interact_shock(struct MarioState *m, UNUSED u32 interactType, struct Object
take_damage_from_interact_object(m);
play_sound(SOUND_MARIO_ATTACKED, m->marioObj->header.gfx.cameraToObject);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(70, 60);
#endif
@@ -1301,7 +1301,7 @@ u32 interact_shock(struct MarioState *m, UNUSED u32 interactType, struct Object
return FALSE;
}
static u32 interact_stub(UNUSED struct MarioState *m, UNUSED u32 interactType, struct Object *o) {
UNUSED static u32 interact_stub(UNUSED struct MarioState *m, UNUSED u32 interactType, struct Object *o) {
if (!(o->oInteractionSubtype & INT_SUBTYPE_DELAY_INVINCIBILITY)) {
sDelayInvincTimer = TRUE;
}
@@ -1331,7 +1331,7 @@ u32 interact_hit_from_below(struct MarioState *m, UNUSED u32 interactType, struc
}
if (interaction & INT_ANY_ATTACK) {
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
attack_object(o, interaction);
@@ -1373,7 +1373,7 @@ u32 interact_bounce_top(struct MarioState *m, UNUSED u32 interactType, struct Ob
}
if (interaction & INT_ATTACK_NOT_FROM_BELOW) {
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
attack_object(o, interaction);
@@ -1495,7 +1495,7 @@ u32 check_object_grab_mario(struct MarioState *m, UNUSED u32 interactType, struc
update_mario_sound_and_camera(m);
play_sound(SOUND_MARIO_OOOF, m->marioObj->header.gfx.cameraToObject);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
return set_mario_action(m, ACT_GRABBED, 0);
@@ -1546,7 +1546,7 @@ u32 interact_pole(struct MarioState *m, UNUSED u32 interactType, struct Object *
marioObj->oMarioPoleYawVel = (s32)(m->forwardVel * 0x100 + 0x1000);
#endif
reset_mario_pitch(m);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
return set_mario_action(m, ACT_GRAB_POLE_FAST, 0);
@@ -1564,11 +1564,12 @@ u32 interact_hoot(struct MarioState *m, UNUSED u32 interactType, struct Object *
if (actionId >= 0x080 && actionId < 0x098
&& (gGlobalTimer - m->usedObj->oHootMarioReleaseTime > 30)) {
mario_stop_riding_and_holding(m);
o->oInteractStatus = INT_STATUS_HOOT_GRABBED_BY_MARIO;
o->oInteractStatus = TRUE; //! Note: Not a flag, treated as a TRUE/FALSE statement
m->interactObj = o;
m->usedObj = o;
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
#endif
update_mario_sound_and_camera(m);
@@ -1781,7 +1782,7 @@ void mario_process_interactions(struct MarioState *m) {
if (!(m->action & ACT_FLAG_INTANGIBLE) && m->collidedObjInteractTypes != 0) {
s32 i;
for (i = 0; i < 31; i++) {
for (i = 0; i < ARRAY_COUNT(sInteractionHandlers); i++) {
u32 interactType = sInteractionHandlers[i].interactType;
if (m->collidedObjInteractTypes & interactType) {
struct Object *object = mario_get_collided_object(m, interactType);
+6 -3
View File
@@ -80,14 +80,17 @@
#define INT_STATUS_ATTACK_MASK 0x000000FF
#define INT_STATUS_HOOT_GRABBED_BY_MARIO (1 << 0) /* 0x00000001 */
#define INT_STATUS_MARIO_UNK1 (1 << 1) /* 0x00000002 */
// Mario Interaction Status
#define INT_STATUS_MARIO_STUNNED (1 << 0) /* 0x00000001 */
#define INT_STATUS_MARIO_KNOCKBACK_DMG (1 << 1) /* 0x00000002 */
#define INT_STATUS_MARIO_UNK2 (1 << 2) /* 0x00000004 */
#define INT_STATUS_MARIO_DROP_OBJECT (1 << 3) /* 0x00000008 */
#define INT_STATUS_HIT_BY_SHOCKWAVE (1 << 4) /* 0x00000010 */
#define INT_STATUS_MARIO_SHOCKWAVE (1 << 4) /* 0x00000010 */
#define INT_STATUS_MARIO_UNK5 (1 << 5) /* 0x00000020 */
#define INT_STATUS_MARIO_UNK6 (1 << 6) /* 0x00000040 */
#define INT_STATUS_MARIO_UNK7 (1 << 7) /* 0x00000080 */
// Object Interaction Status
#define INT_STATUS_GRABBED_MARIO (1 << 11) /* 0x00000800 */
#define INT_STATUS_ATTACKED_MARIO (1 << 13) /* 0x00002000 */
#define INT_STATUS_WAS_ATTACKED (1 << 14) /* 0x00004000 */
+11 -13
View File
@@ -212,10 +212,10 @@ u16 level_control_timer(s32 timerOp) {
}
u32 pressed_pause(void) {
u32 val4 = get_dialog_id() >= 0;
u32 dialogActive = get_dialog_id() >= 0;
u32 intangible = (gMarioState->action & ACT_FLAG_INTANGIBLE) != 0;
if (!intangible && !val4 && !gWarpTransition.isActive && sDelayedWarpOp == WARP_OP_NONE
if (!intangible && !dialogActive && !gWarpTransition.isActive && sDelayedWarpOp == WARP_OP_NONE
&& (gPlayer1Controller->buttonPressed & START_BUTTON)) {
return TRUE;
}
@@ -266,7 +266,7 @@ void load_level_init_text(u32 arg) {
gotAchievement = save_file_get_flags() & SAVE_FLAG_HAVE_WING_CAP;
break;
case 255:
case (u8)DIALOG_NONE: // 255, cast value to u8 to match (-1)
gotAchievement = TRUE;
break;
@@ -689,7 +689,7 @@ void initiate_painting_warp(void) {
play_sound(SOUND_MENU_STAR_SOUND, gGlobalSoundSource);
fadeout_music(398);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
queue_rumble_data(80, 70);
func_sh_8024C89C(1);
#endif
@@ -1004,7 +1004,7 @@ s32 play_mode_normal(void) {
set_play_mode(PLAY_MODE_CHANGE_AREA);
} else if (pressed_pause()) {
lower_background_noise(1);
#ifdef VERSION_SH
#if ENABLE_RUMBLE
cancel_rumble();
#endif
gCameraMovementFlags |= CAM_MOVE_PAUSE_SCREEN;
@@ -1016,15 +1016,13 @@ s32 play_mode_normal(void) {
}
s32 play_mode_paused(void) {
if (gPauseScreenMode == 0) {
set_menu_mode(RENDER_PAUSE_SCREEN);
} else if (gPauseScreenMode == 1) {
if (gMenuOptSelectIndex == MENU_OPT_NONE) {
set_menu_mode(MENU_MODE_RENDER_PAUSE_SCREEN);
} else if (gMenuOptSelectIndex == MENU_OPT_DEFAULT) {
raise_background_noise(1);
gCameraMovementFlags &= ~CAM_MOVE_PAUSE_SCREEN;
set_play_mode(PLAY_MODE_NORMAL);
} else {
// Exit level
} else { // MENU_OPT_EXIT_COURSE
if (gDebugLevelSelect) {
fade_into_special_warp(-9, 1);
} else {
@@ -1118,7 +1116,7 @@ s32 play_mode_change_level(void) {
/**
* Unused play mode. Doesn't call transition update and doesn't reset transition at the end.
*/
static s32 play_mode_unused(void) {
UNUSED static s32 play_mode_unused(void) {
if (--sTransitionTimer == -1) {
gHudDisplay.flags = HUD_DISPLAY_NONE;
@@ -1217,7 +1215,7 @@ s32 init_level(void) {
set_background_music(gCurrentArea->musicParam, gCurrentArea->musicParam2, 0);
}
}
#ifdef VERSION_SH
#if ENABLE_RUMBLE
if (gCurrDemoInput == NULL) {
cancel_rumble();
}
+2 -2
View File
@@ -79,7 +79,7 @@ void spawn_macro_abs_special(s32 model, const BehaviorScript *behavior, s16 x, s
newObj->oMacroUnk110 = (f32) unkC;
}
static void spawn_macro_coin_unknown(const BehaviorScript *behavior, s16 a1[]) {
UNUSED static void spawn_macro_coin_unknown(const BehaviorScript *behavior, s16 a1[]) {
struct Object *sp3C;
s16 model;
@@ -203,7 +203,7 @@ void spawn_macro_objects_hardcoded(s16 areaIndex, s16 *macroObjList) {
// However, BBH doesn't use this function so this might just be an early test?
switch (macroObjPreset) {
case 0:
spawn_macro_abs_yrot_2params(MODEL_NONE, bhvBooBossSpawnedBridge, macroObjX, macroObjY,
spawn_macro_abs_yrot_2params(MODEL_NONE, bhvBooStaircase, macroObjX, macroObjY,
macroObjZ, macroObjRY, 0);
break;
case 1:
+9 -5
View File
@@ -26,7 +26,7 @@ OSThread gGameLoopThread;
OSThread gSoundThread;
OSIoMesg gDmaIoMesg;
OSMesg D_80339BEC;
OSMesg gMainReceivedMesg;
OSMesgQueue gDmaMesgQueue;
OSMesgQueue gSIEventMesgQueue;
@@ -50,7 +50,7 @@ struct SPTask *sNextDisplaySPTask = NULL;
s8 sAudioEnabled = TRUE;
u32 gNumVblanks = 0;
s8 gResetTimer = 0;
s8 D_8032C648 = 0;
s8 gNmiResetBarsTimer = 0;
s8 gDebugLevelSelect = FALSE;
s8 D_8032C650 = 0;
@@ -89,6 +89,10 @@ void unknown_main_func(void) {
// uninitialized
OSTime time;
u32 b;
#ifdef AVOID_UB
time = 0;
b = 0;
#endif
osSetTime(time);
osMapTLB(0, b, NULL, 0, 0, 0);
@@ -143,7 +147,7 @@ extern void func_sh_802f69cc(void);
void handle_nmi_request(void) {
gResetTimer = 1;
D_8032C648 = 0;
gNmiResetBarsTimer = 0;
stop_sounds_in_continuous_banks();
sound_banks_disable(SEQ_PLAYER_SFX, SOUND_BANKS_BACKGROUND);
fadeout_music(90);
@@ -253,7 +257,7 @@ void handle_vblank(void) {
start_sptask(M_GFXTASK);
}
}
#ifdef VERSION_SH
#if ENABLE_RUMBLE
rumble_thread_update_vi();
#endif
@@ -386,7 +390,7 @@ void dispatch_audio_sptask(struct SPTask *spTask) {
}
}
void send_display_list(struct SPTask *spTask) {
void exec_display_list(struct SPTask *spTask) {
if (spTask != NULL) {
osWritebackDCacheAll();
spTask->state = SPTASK_STATE_NOT_STARTED;
Loaded 100 of 251 files, more files were not shown because too many files have changed in this diff. Show more