diff --git a/.clang-format b/.clang-format index 03ea4a3a..8b56ca8d 100644 --- a/.clang-format +++ b/.clang-format @@ -1,18 +1,23 @@ IndentWidth: 4 Language: Cpp -AlignAfterOpenBracket: Align -SortIncludes: false -ColumnLimit: 104 +UseTab: Never +ColumnLimit: 120 PointerAlignment: Right -AllowShortFunctionsOnASingleLine: false -AllowShortIfStatementsOnASingleLine: false -BinPackArguments: true -BinPackParameters: true -SpaceAfterCStyleCast: true BreakBeforeBraces: Attach -BreakBeforeTernaryOperators: true -BreakBeforeBinaryOperators: NonAssignment +SpaceAfterCStyleCast: true Cpp11BracedListStyle: false IndentCaseLabels: true +BinPackArguments: true +BinPackParameters: true +AlignAfterOpenBracket: Align +AlignOperands: true +BreakBeforeTernaryOperators: true +BreakBeforeBinaryOperators: None +AllowShortBlocksOnASingleLine: true +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AlignEscapedNewlines: Left AlignTrailingComments: true -UseTab: Never +SortIncludes: false \ No newline at end of file diff --git a/.clang-tidy b/.clang-tidy index db861ad8..380d059f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,10 @@ -Checks: '-*,readability-braces-around-statements' +Checks: '-*,readability-braces-around-statements,readability-inconsistent-declaration-parameter-name' WarningsAsErrors: '' HeaderFilterRegex: '(src|include)\/.*\.h$' FormatStyle: 'file' -CheckOptions: \ No newline at end of file +CheckOptions: + # Require argument names to match exactly (instead of allowing a name to be a prefix/suffix of another) + # Note: 'true' is expected by clang-tidy 12+ but '1' is used for compatibility with older versions + - key: readability-inconsistent-declaration-parameter-name.Strict + value: 1 + diff --git a/src/asset_loading.c b/src/asset_loading.c index addb0597..85a8ece8 100644 --- a/src/asset_loading.c +++ b/src/asset_loading.c @@ -26,7 +26,7 @@ extern u8 __ASSETS_LUT_START[], __ASSETS_LUT_END[]; // __ASSETS_LUT_START = 0xEC * This will send messages when DMA reads are finished. * After, allocate space and load the asset table into RAM. * Official Name: piInit -*/ + */ void init_PI_mesg_queue(void) { u32 assetTableSize; osCreateMesgQueue(&gPIMesgQueue, gPIMesgBuf, ARRAY_COUNT(gPIMesgBuf)); @@ -58,7 +58,7 @@ u32 *load_asset_section_from_rom(u32 assetIndex) { if (out == 0) { return 0; } - dmacopy((u32) (start + __ASSETS_LUT_END), (u32)out, size); + dmacopy((u32) (start + __ASSETS_LUT_END), (u32) out, size); return out; } @@ -85,7 +85,7 @@ UNUSED u8 *load_compressed_asset_from_rom(u32 assetIndex, s32 extraMemory) { totalSpace = byteswap32(gzipHeaderRamPos) + extraMemory; free_from_memory_pool(gzipHeaderRamPos); out = (u8 *) allocate_from_main_pool_safe(totalSpace + extraMemory, COLOUR_TAG_GREY); - if (out == NULL){ + if (out == NULL) { return NULL; } gzipHeaderRamPos = (out + totalSpace) - size; @@ -95,7 +95,6 @@ UNUSED u8 *load_compressed_asset_from_rom(u32 assetIndex, s32 extraMemory) { return out; } - /** * Loads an asset section to a specific memory address. * Returns the size of asset section. @@ -185,7 +184,8 @@ void dmacopy(u32 romOffset, u32 ramAddress, s32 numBytes) { if (numBytes < numBytesToDMA) { numBytesToDMA = numBytes; } - osPiStartDma(&gAssetsDmaIoMesg, OS_MESG_PRI_NORMAL, OS_READ, romOffset, (u32 *) ramAddress, numBytesToDMA, &gDmaMesgQueue); + osPiStartDma(&gAssetsDmaIoMesg, OS_MESG_PRI_NORMAL, OS_READ, romOffset, (u32 *) ramAddress, numBytesToDMA, + &gDmaMesgQueue); osRecvMesg(&gDmaMesgQueue, &dmaMesg, OS_MESG_BLOCK); numBytes -= numBytesToDMA; romOffset += numBytesToDMA; diff --git a/src/audio.c b/src/audio.c index e1dc0e56..0fe413a1 100644 --- a/src/audio.c +++ b/src/audio.c @@ -78,7 +78,7 @@ SoundMask *gRacerSoundMask; /** * Allocate memory for all of the audio systems, including sequence data, sound data and heaps. * Afterwards, set up the audio thread and start it. -*/ + */ void audio_init(OSSched *sc) { s32 iCnt; ALSynConfig synth_config; @@ -92,8 +92,10 @@ void audio_init(OSSched *sc) { alHeapInit(&gALHeap, gBssSectionStart, sizeof(gBssSectionStart)); addrPtr = (s32 *) load_asset_section_from_rom(ASSET_AUDIO_TABLE); - gSoundBank = (ALBankFile *) allocate_from_main_pool_safe(addrPtr[ASSET_AUDIO_2] - addrPtr[ASSET_AUDIO_1], COLOUR_TAG_CYAN); - load_asset_to_address(ASSET_AUDIO, (u32) gSoundBank, addrPtr[ASSET_AUDIO_1], addrPtr[ASSET_AUDIO_2] - addrPtr[ASSET_AUDIO_1]); + gSoundBank = + (ALBankFile *) allocate_from_main_pool_safe(addrPtr[ASSET_AUDIO_2] - addrPtr[ASSET_AUDIO_1], COLOUR_TAG_CYAN); + load_asset_to_address(ASSET_AUDIO, (u32) gSoundBank, addrPtr[ASSET_AUDIO_1], + addrPtr[ASSET_AUDIO_2] - addrPtr[ASSET_AUDIO_1]); alBnkfNew(gSoundBank, get_rom_offset_of_asset(ASSET_AUDIO, addrPtr[ASSET_AUDIO_2])); gSoundTableSize = addrPtr[ASSET_AUDIO_7] - addrPtr[ASSET_AUDIO_6]; @@ -165,8 +167,9 @@ void audio_init(OSSched *sc) { } /** - * Depending on whether or not the audio volume is set to normal and the argument is false, reset sound effect channel volumes. -*/ + * Depending on whether or not the audio volume is set to normal and the argument is false, reset sound effect channel + * volumes. + */ void sound_volume_reset(u8 skipReset) { if (gAudioVolumeSetting == VOLUME_NORMAL) { gSkipResetChannels = skipReset; @@ -183,7 +186,7 @@ void sound_volume_reset(u8 skipReset) { /** * Changes the volume of each sound channel depending on what value is passed through. -*/ + */ void sound_volume_change(s32 behaviour) { switch (behaviour) { case VOLUME_LOWER: // Mute most sound effects and half the volume of music. @@ -220,14 +223,14 @@ void sound_volume_change(s32 behaviour) { /** * Prevents changing of background music. -*/ + */ void music_change_off(void) { gBlockMusicChange = TRUE; } /** * Allows changing of background music. -*/ + */ void music_change_on(void) { gBlockMusicChange = FALSE; } @@ -235,7 +238,7 @@ void music_change_on(void) { /** * Queue a new music sequence to play if not blocked. * Stops any playing existing music beforehand. -*/ + */ void music_play(u8 seqID) { if (gBlockMusicChange == FALSE && gMusicSliderVolume != 0) { gCurrentSequenceID = seqID; @@ -252,7 +255,7 @@ void music_play(u8 seqID) { /** * Update the background music voice limit if not prevented from doing so. -*/ + */ void music_voicelimit_set(u8 voiceLimit) { if (gBlockVoiceLimitChange == FALSE) { set_voice_limit(gMusicPlayer, voiceLimit); @@ -261,21 +264,21 @@ void music_voicelimit_set(u8 voiceLimit) { /** * Prevent the background music voice limit from being changed. -*/ + */ void music_voicelimit_change_off(void) { gBlockVoiceLimitChange = TRUE; } /** * Allow the background music voice limit to be changed. -*/ + */ void music_voicelimit_change_on(void) { gBlockVoiceLimitChange = FALSE; } /** * Update the jingle players voice limit. -*/ + */ void music_jingle_voicelimit_set(u8 voiceLimit) { set_voice_limit(gJinglePlayer, voiceLimit); } @@ -295,7 +298,7 @@ void music_fade(s32 time) { /** * Sets the background music volume back to normal. -*/ + */ void music_volume_reset(void) { sMusicDelayTimer = 0; sMusicDelayLength = 0; @@ -307,7 +310,7 @@ void music_volume_reset(void) { * Run every frame, this handles the transitions in and out of music sequences. * If there's something in the queue, then begin to play that. * Additionally, it also handles the delayed audio queue, counting down and playing any sounds. -*/ + */ void sound_update_queue(u8 updateRate) { s32 i; s32 j; @@ -363,7 +366,7 @@ void sound_update_queue(u8 updateRate) { /** * Add a sound to a queue to play after a set time has passed. * Delay time is in seconds. (1.0f = 1 second) -*/ + */ void sound_play_delayed(u16 soundId, SoundMask *soundMask, f32 delayTime) { if (gDelayedSoundsCount < 8) { gDelayedSounds[gDelayedSoundsCount].soundId = soundId; @@ -375,7 +378,7 @@ void sound_play_delayed(u16 soundId, SoundMask *soundMask, f32 delayTime) { /** * Clear the delayed sound queue. -*/ + */ void sound_clear_delayed(void) { gDelayedSoundsCount = 0; } @@ -383,14 +386,14 @@ void sound_clear_delayed(void) { /** * Return the channel mask of the music player. * Official name: musicGetChanMask -*/ + */ u16 music_channel_get_mask(void) { return gMusicPlayer->chanMask; } /** * Sets the channels in the sequence on or off based on the channel mask given. -*/ + */ void music_dynamic_set(u16 channelMask) { u32 i; if (gMusicNextSeqID) { @@ -402,7 +405,6 @@ void music_dynamic_set(u16 channelMask) { music_channel_on(i); } else { music_channel_off(i); - } } } @@ -410,7 +412,7 @@ void music_dynamic_set(u16 channelMask) { /** * Mute the sequence channel, preventing it from playing any sound. -*/ + */ void music_channel_off(u8 channel) { if (channel < AUDIO_CHANNELS) { alSeqChOff(gMusicPlayer, channel); @@ -420,14 +422,14 @@ void music_channel_off(u8 channel) { /** * Return true if the given channel is currently active. * Official name: musicGetChnlActive -*/ + */ s32 music_channel_active(s32 channel) { return (gMusicPlayer->chanMask & (1 << channel)) == 0; } /** * Unmute the sequence channel so it can play sound. -*/ + */ void music_channel_on(u8 channel) { if (channel < AUDIO_CHANNELS) { alSeqChOn(gMusicPlayer, channel); @@ -437,7 +439,7 @@ void music_channel_on(u8 channel) { /** * Set the panning level of the given channel for the music player. * Official name: musicSetChlPan -*/ + */ void music_channel_pan_set(u8 channel, ALPan pan) { if (channel < AUDIO_CHANNELS) { alCSPSetChlPan((ALCSPlayer *) gMusicPlayer, channel, pan); @@ -447,7 +449,7 @@ void music_channel_pan_set(u8 channel, ALPan pan) { /** * Set the volume of the given channel for the music player. * Official name musicSetChlVol -*/ + */ void music_channel_volume_set(u8 channel, u8 volume) { if (channel < AUDIO_CHANNELS) { alCSPSetChlVol((ALCSPlayer *) gMusicPlayer, channel, volume); @@ -457,7 +459,7 @@ void music_channel_volume_set(u8 channel, u8 volume) { /** * Return the volume of the given channel in the music player. * Official name: musicGetChlVol -*/ + */ UNUSED u8 music_channel_volume(u8 channel) { if (channel >= AUDIO_CHANNELS) { return 0; @@ -468,7 +470,7 @@ UNUSED u8 music_channel_volume(u8 channel) { /** * Set this channel to fade in over time. -*/ + */ void music_channel_fade_set(u8 channel, ALPan fade) { if (channel < AUDIO_CHANNELS) { alCSPSetFadeIn(gMusicPlayer, channel, fade); @@ -477,7 +479,7 @@ void music_channel_fade_set(u8 channel, ALPan fade) { /** * Return the fade volume of the given channel. -*/ + */ u8 music_channel_fade(u8 channel) { if (channel >= AUDIO_CHANNELS) { return 0; @@ -488,7 +490,7 @@ u8 music_channel_fade(u8 channel) { /** * Resets all audio channels for the music player to the default state. * This is being enabled, centre panning and at normal volume. -*/ + */ void music_channel_reset_all(void) { u32 channel; if (gBlockMusicChange == FALSE) { @@ -505,7 +507,7 @@ UNUSED u8 func_80001358(u8 arg0, u8 arg1, s32 arg2) { u8 val_1e; s32 updatedVol; - //u8 fadeIn_chan = arg0; + // u8 fadeIn_chan = arg0; if (!(arg0 == 100)) { val_1f = arg2 + alCSPGetChlVol((ALCSPlayer *) gMusicPlayer, arg0); if (val_1f > 127) { @@ -536,10 +538,11 @@ UNUSED void func_80001440(u8 *arg0) { /** * Multiplies the current tempo of the background music. - * Since it calls music_tempo and multiplies it by the result, calling this repeatedly can recursively change the music's speed. -*/ + * Since it calls music_tempo and multiplies it by the result, calling this repeatedly can recursively change the + * music's speed. + */ void music_tempo_set_relative(f32 tempo) { - music_tempo_set((s32)((f32)(u32)(music_tempo() & 0xFF) * tempo)); + music_tempo_set((s32) ((f32) (u32) (music_tempo() & 0xFF) * tempo)); } /** @@ -549,7 +552,7 @@ void music_tempo_set_relative(f32 tempo) { void music_tempo_set(s32 tempo) { if (tempo != 0) { f32 inv_tempo = (1.0f / tempo); - alCSPSetTempo((ALCSPlayer *) gMusicPlayer, (s32)(inv_tempo * 60000000.0f)); + alCSPSetTempo((ALCSPlayer *) gMusicPlayer, (s32) (inv_tempo * 60000000.0f)); sMusicTempo = tempo; } } @@ -564,7 +567,7 @@ s16 music_tempo(void) { /** * Returns true if background music is currently playing. -*/ + */ u8 music_is_playing(void) { return (alCSPGetState((ALCSPlayer *) gMusicPlayer) == AL_PLAYING); } @@ -572,7 +575,7 @@ u8 music_is_playing(void) { /** * Counts up using the internal timer. * Loops itself round, so the final result will return 0.0f - 1.0f. -*/ + */ f32 music_animation_fraction(void) { f32 tmp; u32 cnt = osGetCount(); @@ -584,15 +587,16 @@ f32 music_animation_fraction(void) { if (gMusicPlaying == FALSE) { sMusicTempo = 182; } - for (tmp = 120000.0f / (f32) sMusicTempo; tmp < gMusicAnimationTick; gMusicAnimationTick -= tmp) + for (tmp = 120000.0f / (f32) sMusicTempo; tmp < gMusicAnimationTick; gMusicAnimationTick -= tmp) { ; + } audioPrevCount = (s32) cnt; return gMusicAnimationTick / tmp; } /** * Writes the music and sound tempo, as well as the volume to the arguments. -*/ + */ UNUSED void sound_get_properties(u8 poolID, u8 *tempo, u8 *volume, u8 *reverb) { *tempo = gSeqSoundTable[poolID].tempo; *volume = gSeqSoundTable[poolID].volume; @@ -601,7 +605,7 @@ UNUSED void sound_get_properties(u8 poolID, u8 *tempo, u8 *volume, u8 *reverb) { /** * Play a jingle, but only if there isn't one playing already. -*/ + */ void music_jingle_play_safe(u8 jingleID) { if (music_jingle_playing() == SEQUENCE_NONE) { music_sequence_start(gCurrentJingleID = jingleID, gJinglePlayer); @@ -611,15 +615,15 @@ void music_jingle_play_safe(u8 jingleID) { /** * Sets the tempo for the jingle player. -*/ + */ void sound_jingle_tempo_set(s32 tempo) { f32 inv_tempo = (1.0f / tempo); - alCSPSetTempo((ALCSPlayer *) gJinglePlayer, (s32)(inv_tempo * 60000000.0f)); + alCSPSetTempo((ALCSPlayer *) gJinglePlayer, (s32) (inv_tempo * 60000000.0f)); } /** * Stops the background music. -*/ + */ void music_stop(void) { if (gBlockMusicChange == FALSE) { music_sequence_stop(gMusicPlayer); @@ -629,7 +633,7 @@ void music_stop(void) { /** * Set background music to play or not. * If the setting changed, then either stop or start music. -*/ + */ UNUSED void music_enabled_set(u8 setting) { if (setting != gCanPlayMusic) { gCanPlayMusic = setting; @@ -643,14 +647,14 @@ UNUSED void music_enabled_set(u8 setting) { /** * Return whether background music can be played. -*/ + */ u8 music_can_play(void) { return gCanPlayMusic; } /** * Stops the currently playing jingle. -*/ + */ void music_jingle_stop(void) { if (music_jingle_playing() == SEQUENCE_NONE) { gCurrentJingleID = SEQUENCE_NONE; @@ -660,7 +664,7 @@ void music_jingle_stop(void) { /** * Return the currently playing music. -*/ + */ u8 music_current_sequence(void) { if (gCurrentSequenceID != SEQUENCE_NONE && gMusicPlayer->state == AL_PLAYING) { return gCurrentSequenceID; @@ -672,7 +676,7 @@ u8 music_current_sequence(void) { /** * Return the next music sequence to be played if there is one. * Otherwise, return what's currently playing. -*/ + */ UNUSED u8 music_next(void) { if (gMusicNextSeqID) { return gMusicNextSeqID; @@ -683,7 +687,7 @@ UNUSED u8 music_next(void) { /** * Return the currently playing jingle. -*/ + */ u8 music_jingle_current(void) { return gCurrentJingleID; } @@ -691,38 +695,38 @@ u8 music_jingle_current(void) { /** * Set the volume of the music. * Update music volume with this new setting. -*/ + */ void music_volume_set(u8 volume) { f32 normalized_vol; gMusicBaseVolume = volume; normalized_vol = gMusicSliderVolume * gMusicBaseVolume * sMusicFadeVolume; - alCSPSetVol((ALCSPlayer *) gMusicPlayer, (s16)((s32)(gGlobalMusicVolume * normalized_vol) >> 8)); + alCSPSetVol((ALCSPlayer *) gMusicPlayer, (s16) ((s32) (gGlobalMusicVolume * normalized_vol) >> 8)); } /** * Set the user configured music volume. * Update music volume with this new setting. -*/ + */ void music_volume_config_set(u32 slider_val) { f32 normalized_vol; slider_val = (slider_val <= 256) ? slider_val : 256; gMusicSliderVolume = slider_val; normalized_vol = gMusicSliderVolume * gMusicBaseVolume * sMusicFadeVolume; - alCSPSetVol((ALCSPlayer *) gMusicPlayer, (s16)((s32)(gGlobalMusicVolume * normalized_vol) >> 8)); + alCSPSetVol((ALCSPlayer *) gMusicPlayer, (s16) ((s32) (gGlobalMusicVolume * normalized_vol) >> 8)); } /** * Return the baseline music volume, unaffected by user config. -*/ + */ u8 music_volume(void) { return gMusicBaseVolume; } /** * Return the music volume set by the player. -*/ + */ s32 music_volume_config(void) { return gMusicSliderVolume; } @@ -730,15 +734,15 @@ s32 music_volume_config(void) { /** * Set the volume for the jingle player. * The jingle player scales with sfx volume rather than music volume. -*/ + */ void music_jingle_volume_set(u8 arg0) { sfxRelativeVolume = arg0; - alCSPSetVol((ALCSPlayer *) gJinglePlayer, (s16)(get_sfx_volume_slider() * sfxRelativeVolume)); + alCSPSetVol((ALCSPlayer *) gJinglePlayer, (s16) (get_sfx_volume_slider() * sfxRelativeVolume)); } /** * Set the panning level for every channel in the jingle player. -*/ + */ void music_jingle_pan_set(ALPan pan) { u32 iChan; for (iChan = 0; iChan < AUDIO_CHANNELS; iChan++) { @@ -757,7 +761,7 @@ void music_jingle_play(u8 seqID) { /** * If there's a jingle playing, return that, otherwise, return 0. -*/ + */ u32 music_jingle_playing(void) { if (gCurrentJingleID && gCanPlayJingle && (gJinglePlayer->state == AL_PLAYING)) { return gCurrentJingleID; @@ -770,7 +774,7 @@ u32 music_jingle_playing(void) { * Sets the volume for every sound channel. * Tries to set up to 64, regardless of if there are 64 sound channels or not. * !@bug: This can cause an out of bounds array index. -*/ + */ UNUSED void sound_channel_volume_all(u16 volume) { u32 i; for (i = 0; i < 64; i++) { @@ -780,7 +784,7 @@ UNUSED void sound_channel_volume_all(u16 volume) { /** * Return the audible distance of the sound effect. -*/ + */ u16 sound_distance(u16 soundId) { if (soundId > gSoundCount) { return 0; @@ -791,7 +795,7 @@ u16 sound_distance(u16 soundId) { /** * Add the requested sound to the queue and update the mask to show that this sound is playing at that source. * If no soundmask is provided, then instead use the global mask. -*/ + */ void sound_play(u16 soundID, s32 *soundMask) { f32 pitch; s32 soundBite; @@ -816,14 +820,14 @@ void sound_play(u16 soundID, s32 *soundMask) { func_80004668(gSoundBank->bankArray[0], soundBite, gSoundTable[soundID].unk8, (SoundMask *) soundMask); if (*soundMask != NULL) { sound_event_update(*soundMask, AL_SNDP_VOL_EVT, gSoundTable[soundID].volume * 256); - sound_event_update(*soundMask, AL_SNDP_PITCH_EVT, *((u32*) &pitch)); + sound_event_update(*soundMask, AL_SNDP_PITCH_EVT, *((u32 *) &pitch)); } } else { soundMask = (s32 *) &gGlobalSoundMask; func_80004668(gSoundBank->bankArray[0], soundBite, gSoundTable[soundID].unk8, (SoundMask *) &gGlobalSoundMask); if (*soundMask != NULL) { sound_event_update(*soundMask, AL_SNDP_VOL_EVT, gSoundTable[soundID].volume * 256); - sound_event_update(*soundMask, AL_SNDP_PITCH_EVT, *((u32*) &pitch)); + sound_event_update(*soundMask, AL_SNDP_PITCH_EVT, *((u32 *) &pitch)); } } } @@ -861,7 +865,7 @@ void func_80001F14(u16 soundID, s32 *soundMask) { /** * Set the volume of the sound relative to the baseline volume of the sound ID. -*/ + */ void sound_volume_set_relative(u16 soundID, void *soundState, u8 volume) { s32 newVolume = ((s32) (gSoundTable[soundID].volume * (volume / 127.0f))) * 256; if (soundState) { @@ -871,7 +875,7 @@ void sound_volume_set_relative(u16 soundID, void *soundState, u8 volume) { /** * Updates the volume of the given sound mask. -*/ + */ UNUSED void sound_volume_set(SoundMask *soundMask, u8 arg1) { if (soundMask != NULL) { sound_event_update((s32) soundMask, AL_SNDP_VOL_EVT, arg1 * 256); @@ -881,7 +885,7 @@ UNUSED void sound_volume_set(SoundMask *soundMask, u8 arg1) { /** * Updates the pitch of the given sound mask. * Official name: amSndSetPitchDirect -*/ + */ UNUSED void sound_pitch_set(SoundMask *soundMask, u32 pitch) { u32 *pitchAddr = &pitch; if (soundMask != NULL) { @@ -891,21 +895,21 @@ UNUSED void sound_pitch_set(SoundMask *soundMask, u32 pitch) { /** * Return the number of playable sounds in the audio table. -*/ + */ u16 sound_count(void) { return gSoundBank->bankArray[0]->instArray[0]->soundCount; } /** * Return mumber of playable sequences in the table. -*/ + */ u8 music_sequence_count(void) { return gSequenceTable->seqCount; } /** * Writes the sound table address, size and element count into the arguments. -*/ + */ void sound_table_properties(SoundData **table, s32 *size, s32 *count) { if (table != NULL) { *table = gSoundTable; @@ -920,7 +924,7 @@ void sound_table_properties(SoundData **table, s32 *size, s32 *count) { /** * Writes the music sound table address, size and element count into the arguments. -*/ + */ UNUSED void music_table_properties(MusicData **table, s32 *size, s32 *count) { if (table != NULL) { *table = gSeqSoundTable; @@ -937,19 +941,19 @@ u8 gSoundBank_GetSoundDecayTime(u16 soundID) { if (soundID <= 0 || gSoundBank->bankArray[0]->instArray[0]->soundCount < soundID) { return 0; } - return ((u32)(1 + gSoundBank->bankArray[0]->instArray[0]->soundArray[soundID - 1]->envelope->decayTime) == 0); + return ((u32) (1 + gSoundBank->bankArray[0]->instArray[0]->soundArray[soundID - 1]->envelope->decayTime) == 0); } /** * Allocate space, then initialise a sequence player for audio playback. -*/ + */ ALSeqPlayer *sound_seqplayer_init(s32 maxVoices, s32 maxEvents) { ALCSPlayer *cseqp; ALSeqpConfig config; config.maxVoices = maxVoices; config.maxEvents = maxEvents; - config.unknown_0x10 = maxVoices; //this member doesn't exist in other versions of ALSeqpConfig + config.unknown_0x10 = maxVoices; // this member doesn't exist in other versions of ALSeqpConfig config.maxChannels = AUDIO_CHANNELS; config.heap = &gALHeap; config.initOsc = NULL; @@ -966,7 +970,7 @@ ALSeqPlayer *sound_seqplayer_init(s32 maxVoices, s32 maxEvents) { /** * Stop the current sequence then set the parameters for the next sequence. -*/ + */ void music_sequence_start(u8 seqID, ALSeqPlayer *seqPlayer) { music_sequence_stop(seqPlayer); if (seqID < gSequenceTable->seqCount) { @@ -980,17 +984,19 @@ void music_sequence_start(u8 seqID, ALSeqPlayer *seqPlayer) { } } -/** +/** * If the sequence player is currently inactive, start a new sequence with the current properties. -*/ + */ void music_sequence_init(ALSeqPlayer *seqp, void *sequence, u8 *seqID, ALCSeq *seq) { s32 i; - if ((alCSPGetState((ALCSPlayer* ) seqp) == AL_STOPPED) && (*seqID != 0)) { - load_asset_to_address(ASSET_AUDIO, (u32) sequence, gSequenceTable->seqArray[*seqID].offset - get_rom_offset_of_asset(ASSET_AUDIO, 0), (s32) gSeqLengthTable[*seqID]); + if ((alCSPGetState((ALCSPlayer *) seqp) == AL_STOPPED) && (*seqID != 0)) { + load_asset_to_address(ASSET_AUDIO, (u32) sequence, + gSequenceTable->seqArray[*seqID].offset - get_rom_offset_of_asset(ASSET_AUDIO, 0), + (s32) gSeqLengthTable[*seqID]); alCSeqNew(seq, sequence); - alCSPSetSeq((ALCSPlayer* ) seqp, seq); - alCSPPlay((ALCSPlayer* ) seqp); + alCSPSetSeq((ALCSPlayer *) seqp, seq); + alCSPPlay((ALCSPlayer *) seqp); if (seqp == gMusicPlayer) { music_volume_set(gSeqSoundTable[*seqID].volume); if (gSeqSoundTable[*seqID].tempo != 0) { @@ -1022,7 +1028,7 @@ void music_sequence_init(ALSeqPlayer *seqp, void *sequence, u8 *seqID, ALCSeq *s /** * Stops the current playing sequence for the given sequence player. -*/ + */ void music_sequence_stop(ALSeqPlayer *seqPlayer) { if (gMusicPlayer == seqPlayer && gMusicPlaying) { alCSPStop((ALCSPlayer *) seqPlayer); @@ -1039,14 +1045,14 @@ void music_sequence_stop(ALSeqPlayer *seqPlayer) { /** * Enable or disable special audio effects. * This includes reverb and echo. -*/ + */ void sound_reverb_set(u8 setting) { alFxReverbSet(setting); } /** * Returns whether or not reverb is currently enabled. -*/ + */ UNUSED u8 sound_reverb_enabled(void) { return gSeqSoundTable[gCurrentSequenceID].reverb; } diff --git a/src/audio.h b/src/audio.h index c546f0cd..202c524c 100644 --- a/src/audio.h +++ b/src/audio.h @@ -61,9 +61,9 @@ void alCSPSetVol(ALCSPlayer *seqp, s16 volume); //lib/src/al/alCSPSetVol.c void alCSPStop(ALCSPlayer *seqp); //lib/src/al/unknown_0C91A0.c s32 alCSPGetState(ALCSPlayer *seqp); //lib/src/unknown_0C8650.c -void audio_init(OSSched *arg0); +void audio_init(OSSched *sc); void sound_volume_reset(u8 skipReset); -void sound_volume_change(s32 arg0); +void sound_volume_change(s32 behaviour); void music_change_off(void); void music_change_on(void); void music_play(u8 seqID); @@ -77,20 +77,20 @@ void sound_update_queue(u8 updateRate); void sound_play_delayed(u16 soundId, SoundMask *soundMask, f32 delayTime); void sound_clear_delayed(void); u16 music_channel_get_mask(void); -void music_dynamic_set(u16 arg0); +void music_dynamic_set(u16 channelMask); void music_channel_off(u8 channel); s32 music_channel_active(s32 channel); void music_channel_on(u8 channel); void music_channel_pan_set(u8 channel, ALPan pan); void music_channel_volume_set(u8 channel, u8 volume); -void music_channel_fade_set(u8 channel, ALPan pan); -u8 music_channel_fade(u8 arg0); +void music_channel_fade_set(u8 channel, ALPan fade); +u8 music_channel_fade(u8 channel); void music_channel_reset_all(void); void music_tempo_set_relative(f32 tempo); void music_tempo_set(s32 tempo); s16 music_tempo(void); u8 music_is_playing(void); -void music_jingle_play_safe(u8 a0); +void music_jingle_play_safe(u8 jingleID); void sound_jingle_tempo_set(s32 tempo); void music_stop(void); u8 music_can_play(void); @@ -106,22 +106,22 @@ void music_jingle_pan_set(ALPan pan); void music_jingle_play(u8 seqID); u32 music_jingle_playing(void); u16 sound_distance(u16 soundId); -void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, s32 **arg4); +void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, s32 **soundMask); void func_80001F14(u16 soundID, s32 *soundMask); u16 sound_count(void); u8 music_sequence_count(void); void sound_table_properties(SoundData **table, s32 *size, s32 *count); u8 gSoundBank_GetSoundDecayTime(u16 soundID); -ALSeqPlayer *sound_seqplayer_init(s32 _max_voices, s32 _max_events); -void music_sequence_start(u8 arg0, ALSeqPlayer *arg1); -void music_sequence_stop(ALSeqPlayer *seqp); -void sound_reverb_set(u8 arg0); +ALSeqPlayer *sound_seqplayer_init(s32 maxVoices, s32 maxEvents); +void music_sequence_start(u8 seqID, ALSeqPlayer *seqPlayer); +void music_sequence_stop(ALSeqPlayer *seqPlayer); +void sound_reverb_set(u8 setting); void alSeqFileNew(ALSeqFile *file, u8 *base); void func_80063A90(ALSeqPlayer *seqp, u8 channel); void sound_volume_set_relative(u16 soundID, void *soundState, u8 volume); -void music_sequence_init(ALSeqPlayer* arg0, void* arg1, u8* arg2, ALCSeq* arg3); +void music_sequence_init(ALSeqPlayer *seqp, void *sequence, u8 *seqID, ALCSeq *seq); void sound_play(u16 soundID, s32* soundMask); f32 music_animation_fraction(void); -void func_80009B7C(s32 *SoundMask, f32 x, f32 y, f32 z); +void func_80009B7C(s32 *soundState, f32 x, f32 y, f32 z); #endif diff --git a/src/audio_assert.c b/src/audio_assert.c index 4e8b8e60..6d718762 100644 --- a/src/audio_assert.c +++ b/src/audio_assert.c @@ -3,12 +3,14 @@ #include "audio_assert.h" -UNUSED void func_800B6F30(UNUSED int arg0, UNUSED int arg1, UNUSED int arg2) {} +UNUSED void func_800B6F30(UNUSED int arg0, UNUSED int arg1, UNUSED int arg2) { +} -// Only called from two libultra funcs for some reason. +// Only called from two libultra funcs for some reason. // This is likely an assert gone wrong. // Called from alEnvMixerPull, and _pullSubFrame // assert_stub("samples >= 0", "env.c", 104); // assert_stub("samples <= AL_MAX_RSP_SAMPLES", "env.c", 105); // assert_stub("source", "env.c", 373); -void assert_stub(UNUSED char *message, UNUSED char *fileName, UNUSED s32 lineNumber) {} +void assert_stub(UNUSED char *message, UNUSED char *fileName, UNUSED s32 lineNumber) { +} diff --git a/src/audio_spatial.c b/src/audio_spatial.c index 866c50be..7219333d 100644 --- a/src/audio_spatial.c +++ b/src/audio_spatial.c @@ -79,7 +79,7 @@ void func_80008168(void) { #ifdef NON_EQUIVALENT extern f32 D_80119C60[672]; -extern f32 D_8011A6E0[336];//[7][48]; +extern f32 D_8011A6E0[336]; //[7][48]; extern unk8011A6D8 **D_8011A6DC; void func_80008174(void) { s32 i; @@ -123,7 +123,7 @@ void func_80008174(void) { // D_8011A6E0[i][j] = -100000.0; // } } - + D_8011AC18 = 0; } #else @@ -159,7 +159,7 @@ s32 func_800090C0(f32 arg0, f32 arg1, s32 arg2) { return ret; } -//Best I can figure, this measures the distance between XYZ values. +// Best I can figure, this measures the distance between XYZ values. s32 func_800092A8(f32 inX, f32 inY, f32 inZ, floatXYZVals *floatXYZ, f32 *outX, f32 *outY, f32 *outZ) { f32 dx, dy, dz; f32 x1, y1, z1; @@ -183,8 +183,7 @@ s32 func_800092A8(f32 inX, f32 inY, f32 inZ, floatXYZVals *floatXYZ, f32 *outX, if (dx == 0.0 && dy == 0.0 && dz == 0.0) { temp = 0.0f; } else { - temp = ((inX - x1) * dx + (inY - y1) * dy + (inZ - z1) * dz) / - (dx * dx + dy * dy + dz * dz); + temp = ((inX - x1) * dx + (inY - y1) * dy + (inZ - z1) * dz) / (dx * dx + dy * dy + dz * dz); } if (temp < 0.0f) { @@ -205,8 +204,7 @@ s32 func_800092A8(f32 inX, f32 inY, f32 inZ, floatXYZVals *floatXYZ, f32 *outX, ret = sqrtf(dx * dx + dy * dy + dz * dz); } else { *outX = temp * dx + x1, // Comma required here as this was likely all one line. - *outY = temp * dy + y1, - *outZ = temp * dz + z1; + *outY = temp * dy + y1, *outZ = temp * dz + z1; ret = sqrtf((*outX - inX) * (*outX - inX) + (*outY - inY) * (*outY - inY) + (*outZ - inZ) * (*outZ - inZ)); } @@ -215,12 +213,11 @@ s32 func_800092A8(f32 inX, f32 inY, f32 inZ, floatXYZVals *floatXYZ, f32 *outX, } /** - * Play Sound at position + * Play Sound at position */ void play_sound_at_position(u16 soundId, f32 x, f32 y, f32 z, u8 arg4, SoundMask **soundMask) { - func_8000974C(D_80119C40[soundId].soundBite, x, y, z, arg4, D_80119C40[soundId].unk3, - D_80119C40[soundId].volume, D_80119C40[soundId].distance, 0, D_80119C40[soundId].pitch, - D_80119C40[soundId].unk8, soundMask); + func_8000974C(D_80119C40[soundId].soundBite, x, y, z, arg4, D_80119C40[soundId].unk3, D_80119C40[soundId].volume, + D_80119C40[soundId].distance, 0, D_80119C40[soundId].pitch, D_80119C40[soundId].unk8, soundMask); } void func_800095E8(u16 soundId, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, f32 arg6, SoundMask **soundMask) { @@ -244,7 +241,8 @@ void func_800096F8(SoundMask *arg0) { } } -void func_8000974C(u16 soundBite, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, u8 volume, u16 distance, u8 arg8, u8 pitch, u8 argA, SoundMask **soundMask) { +void func_8000974C(u16 soundBite, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, u8 volume, u16 distance, u8 arg8, u8 pitch, + u8 argA, SoundMask **soundMask) { SoundMask *newMask; if (soundMask != NULL) { @@ -277,14 +275,14 @@ void func_8000974C(u16 soundBite, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, u8 volu } } -void func_800098A4(u8 arg0, u16 soundId, f32 x, f32 y, f32 z, u8 arg5, u8 arg6, - u8 arg7, u8 arg8, u16 arg9, u8 argA, u8 argB, u8 argC) { +void func_800098A4(u8 arg0, u16 soundId, f32 x, f32 y, f32 z, u8 arg5, u8 arg6, u8 arg7, u8 arg8, u16 arg9, u8 argA, + u8 argB, u8 argC) { Vec3f *temp_a0; unk80119C58 *temp_v1; if ((argB < 7) && (argC < 30)) { temp_v1 = &D_80119C58[argB]; - temp_a0 = (Vec3f *) (((u32 *) &temp_v1->unk4) + argC * 3); //This can't be right... + temp_a0 = (Vec3f *) (((u32 *) &temp_v1->unk4) + argC * 3); // This can't be right... temp_a0->x = x; temp_a0->y = y; temp_a0->z = z; @@ -319,7 +317,7 @@ void func_80009968(f32 x, f32 y, f32 z, u8 arg3, u8 arg4, u8 arg5) { D_8011A6D8[arg4].unk0.unk0_02 = arg3 & 0xFF; } if (D_8011A6D8[arg4].unkB8 < tempArg5) { - D_8011A6D8[arg4].unkB8 = tempArg5; + D_8011A6D8[arg4].unkB8 = tempArg5; } } } @@ -356,8 +354,8 @@ s32 func_80009AB4(u8 arg0) { s32 ret; s32 i; unk8011A6D8 *levelHeader; - unk8011A6D8_04 *var_a2; //Probably a Vec3f - + unk8011A6D8_04 *var_a2; // Probably a Vec3f + ret = 1; levelHeader = &D_8011A6D8[arg0]; var_a2 = (unk8011A6D8_04 *) &levelHeader->unk4; @@ -367,9 +365,7 @@ s32 func_80009AB4(u8 arg0) { } for (i = 0; i < levelHeader->unkB8; i++, var_a2++) { - if ((var_a2->unk0 == -100000.0) || - (var_a2->unk0 + 1 == -100000.0) || - (var_a2->unk0 + 2 == -100000.0)) { + if ((var_a2->unk0 == -100000.0) || (var_a2->unk0 + 1 == -100000.0) || (var_a2->unk0 + 2 == -100000.0)) { ret = 0; } } @@ -475,7 +471,7 @@ void func_8000A2E8(s32 arg0) { /** * Generates and renders a coloured line visible from anywhere. * Allows use of a colour, that interpolates from bright to dark from the beginning to the end of the line. -*/ + */ void debug_render_line(Gfx **dlist, Vertex **verts, Triangle **tris, floatXYZVals *coords, u8 red, u8 green, u8 blue) { Gfx *temp_dlist; Vertex *temp_verts; @@ -487,14 +483,14 @@ void debug_render_line(Gfx **dlist, Vertex **verts, Triangle **tris, floatXYZVal s16 y2; s16 z2; - x1 = coords->x1; - y1 = coords->y1; - z1 = coords->z1; - x2 = coords->x2; - y2 = coords->y2; - z2 = coords->z2; + x1 = coords->x1; + y1 = coords->y1; + z1 = coords->z1; + x2 = coords->x2; + y2 = coords->y2; + z2 = coords->z2; temp_dlist = *dlist; - + temp_verts = *verts; temp_tris = *tris; load_and_set_texture_no_offset(&temp_dlist, NULL, RENDER_NONE); @@ -529,7 +525,7 @@ void debug_render_line(Gfx **dlist, Vertex **verts, Triangle **tris, floatXYZVal temp_verts[3].b = 255; temp_verts[3].a = 255; temp_verts += 4; - + temp_tris[0].flags = 0x40; // 0x40 = Draw backface. temp_tris[0].vi0 = 2; temp_tris[0].vi1 = 1; @@ -551,7 +547,7 @@ void debug_render_line(Gfx **dlist, Vertex **verts, Triangle **tris, floatXYZVal temp_tris[1].uv2.u = 1; temp_tris[1].uv2.v = 0; temp_tris += 2; - + *dlist = temp_dlist; *verts = temp_verts; *tris = temp_tris; diff --git a/src/audio_spatial.h b/src/audio_spatial.h index fe17ddfa..664f3b0f 100644 --- a/src/audio_spatial.h +++ b/src/audio_spatial.h @@ -53,7 +53,8 @@ typedef struct unk800A414_arg3 { void func_80008168(void); void func_800096F8(SoundMask *); void func_80008140(void); -void func_8000974C(u16 soundId, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, u8 arg6, u16 arg7, u8 arg8, u8 arg9, u8 argA, SoundMask **soundMask); +void func_8000974C(u16 soundBite, f32 x, f32 y, f32 z, u8 arg4, u8 arg5, u8 volume, u16 distance, u8 arg8, u8 pitch, + u8 argA, SoundMask **soundMask); void play_sound_at_position(u16 soundId, f32 x, f32 y, f32 z, u8 arg4, SoundMask **soundMask); void func_8000A2E8(s32 arg0); s32 func_800090C0(f32, f32, s32); @@ -71,6 +72,6 @@ void func_80009968(f32, f32, f32, u8, u8, u8); // Non Matching void func_80008174(void); // Non Matching void func_80008040(void); // Non Matching void func_80008438(Object **arg0, s32 numRacers, s32 updateRate); // Non Matching -void func_80006FC8(Object **arg0, s32 numRacers, ObjectSegment *arg2, u8 arg3, s32 updateRate); // Non Matching +void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3, s32 updateRate); // Non Matching #endif diff --git a/src/audio_vehicle.c b/src/audio_vehicle.c index d6225a77..274a2785 100644 --- a/src/audio_vehicle.c +++ b/src/audio_vehicle.c @@ -30,14 +30,14 @@ VehicleSoundData *gRacerSound; Object_Racer *gSoundRacerObj; SoundData *D_80119C40; // This should be in audio_spatial? SoundMask **gSoundMaskHeapUsed; -unk80119C48 **gSoundMaskHeap; //0x24 struct size - 0x5A0 total size - should be 40 elements +unk80119C48 **gSoundMaskHeap; // 0x24 struct size - 0x5A0 total size - should be 40 elements u8 gFreeMasks; SoundMask **gSoundMaskHeapFree; -s32 D_80119C54; //Padding? -unk80119C58 **D_80119C58; //Struct of size in func_8000A184 = 0x180 = 384 bytes | Ambient Sounds -unk80119C58 **D_80119C5C; //Struct of size in func_8000A184 = 0x180 = 384 bytes Likely the same as above -f32 D_80119C60[670]; //array size of 672 looks to be required for func_80008174 -unk8011A6D8 *D_8011A6D8; //unk8011A6D8[] | Reverb stuff +s32 D_80119C54; // Padding? +unk80119C58 **D_80119C58; // Struct of size in func_8000A184 = 0x180 = 384 bytes | Ambient Sounds +unk80119C58 **D_80119C5C; // Struct of size in func_8000A184 = 0x180 = 384 bytes Likely the same as above +f32 D_80119C60[670]; // array size of 672 looks to be required for func_80008174 +unk8011A6D8 *D_8011A6D8; // unk8011A6D8[] | Reverb stuff unk8011A6D8 **D_8011A6DC; // Struct of size 0xC0 f32 D_8011A6E0[334]; s32 D_8011AC18; @@ -68,7 +68,7 @@ VehicleSoundData *func_80004B40(s8 characterId, s8 vehicleId) { if (characterId >= 11) { characterId = 11; } - + if (D_800DC6D8 != 0) { for (i = 0; i < 2; i++) { D_80119C30[i] = NULL; @@ -81,8 +81,8 @@ VehicleSoundData *func_80004B40(s8 characterId, s8 vehicleId) { temp_v0_2 = (unkAudioAsset *) allocate_from_main_pool_safe(sizeof(unkAudioAsset), COLOUR_TAG_CYAN); load_asset_to_address(ASSET_AUDIO, (u32) temp_v0_2, temp_s1, sizeof(unkAudioAsset)); temp_v0_3 = (VehicleSoundData *) allocate_from_main_pool_safe(sizeof(VehicleSoundData), COLOUR_TAG_CYAN); - - //Not really sure this is right... + + // Not really sure this is right... memset = temp_v0_3; for (var_a3 = 0; var_a3 < sizeof(VehicleSoundData); var_a3++) { memset[var_a3] = 0; @@ -114,7 +114,7 @@ VehicleSoundData *func_80004B40(s8 characterId, s8 vehicleId) { temp_v0_3->unkC[0][0] = temp_v0_2->unkC; var_a2 = &temp_v0_3->unk0[1]; temp_v0_3->unk2C[0] = temp_v0_2->unk2C; -loop_10: + loop_10: var_a3_2 += 2; var_a0->unk4[0][0] = (u8) var_v1_2->unk4[0]; var_v1_2 += 2; @@ -154,10 +154,12 @@ loop_10: } else { temp_v0_3->unk5C[0] = temp_v0_3->basePitch; temp_a1 = temp_v0_3->unk5C[0] * 10000.0f; - for (var_a0_2 = 0; temp_a1 >= temp_v0_3->unk18[var_a0_2] && var_a0_2 < 4; var_a0_2++) { } + for (var_a0_2 = 0; temp_a1 >= temp_v0_3->unk18[var_a0_2] && var_a0_2 < 4; var_a0_2++) {} var_a0_2--; - new_var = (temp_a1 - temp_v0_3->unk18[var_a0_2]) / ((f32) (temp_v0_3->unk18[var_a0_2 + 1] - temp_v0_3->unk18[var_a0_2])); - temp_v0_3->unk54[0] = temp_v0_3->unk2C[var_a0_2] + (temp_v0_3->unk2C[var_a0_2 + 1] - temp_v0_3->unk2C[var_a0_2]) * new_var; + new_var = (temp_a1 - temp_v0_3->unk18[var_a0_2]) / + ((f32) (temp_v0_3->unk18[var_a0_2 + 1] - temp_v0_3->unk18[var_a0_2])); + temp_v0_3->unk54[0] = + temp_v0_3->unk2C[var_a0_2] + (temp_v0_3->unk2C[var_a0_2 + 1] - temp_v0_3->unk2C[var_a0_2]) * new_var; } free_from_memory_pool(addrPtr); free_from_memory_pool((void *) temp_v0_2); @@ -171,7 +173,7 @@ GLOBAL_ASM("asm/non_matchings/audio_vehicle/func_80004B40.s") * Update the sound of the engine and braking during gameplay, for later. * Check which vehicle is being used, update the position of the audio, * then call a function to handle that particular vehicles audio. -*/ + */ void racer_sound_update(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateRate) { if (gVehicleSounds) { gSoundRacerObj = &obj->unk64->racer; @@ -208,7 +210,7 @@ void racer_sound_update(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 up } #ifdef NON_EQUIVALENT -//Scratch: https://decomp.me/scratch/w3w2c +// Scratch: https://decomp.me/scratch/w3w2c void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateRate) { f32 sp6C; f32 temp_f14; @@ -242,25 +244,31 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR for (outerLoop = 0; outerLoop < 1; outerLoop++) { if ((gRacerSound->unk0[outerLoop]) != 0) { innerLoop = 0; - while ((var_s0 < gRacerSound->unkC[outerLoop][innerLoop] || var_s0 > gRacerSound->unkC[outerLoop][innerLoop + 1] ) && innerLoop < 4) { + while ((var_s0 < gRacerSound->unkC[outerLoop][innerLoop] || + var_s0 > gRacerSound->unkC[outerLoop][innerLoop + 1]) && + innerLoop < 4) { innerLoop++; } - - temp_f14 = (var_s0 - gRacerSound->unkC[0][innerLoop] ) / ((f32) (gRacerSound->unkC[0][innerLoop + 1] - gRacerSound->unkC[0][innerLoop] )); - temp_f4 = gRacerSound->unk2C[outerLoop] + (gRacerSound->unk2C[outerLoop + 1] - gRacerSound->unk2C[outerLoop]) * temp_f14; - + + temp_f14 = (var_s0 - gRacerSound->unkC[0][innerLoop]) / + ((f32) (gRacerSound->unkC[0][innerLoop + 1] - gRacerSound->unkC[0][innerLoop])); + temp_f4 = gRacerSound->unk2C[outerLoop] + + (gRacerSound->unk2C[outerLoop + 1] - gRacerSound->unk2C[outerLoop]) * temp_f14; + innerLoop = 0; - while ((var_s0 < gRacerSound->unk4[0][innerLoop] || var_s0 > gRacerSound->unk4[0][innerLoop + 1]) && innerLoop < 4) { + while ((var_s0 < gRacerSound->unk4[0][innerLoop] || var_s0 > gRacerSound->unk4[0][innerLoop + 1]) && + innerLoop < 4) { innerLoop++; } - - temp_f14 = (var_s0 - gRacerSound->unk4[0][innerLoop]) / ((f32) (gRacerSound->unk4[0][innerLoop + 1] - gRacerSound->unk4[0][innerLoop])); + + temp_f14 = (var_s0 - gRacerSound->unk4[0][innerLoop]) / + ((f32) (gRacerSound->unk4[0][innerLoop + 1] - gRacerSound->unk4[0][innerLoop])); temp_f16 = gRacerSound->unk18[innerLoop] / 10000.0f; temp_f18 = gRacerSound->unk18[innerLoop + 1] / 10000.0f; if (var_s0 > 50 && gSoundRacerObj->bananas != 0) { if (gSoundRacerObj->bananas <= 10) { var_v1_3 = gSoundRacerObj->bananas; - } else { + } else { var_v1_3 = 10; } if (gRacerSound->bananaPitch < (0.05 * var_v1_3)) { @@ -316,12 +324,11 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR } } } - if (((gSoundRacerObj->unk10 != 0) || (gSoundRacerObj->unk14 != 0) || - !(buttonsHeld & B_BUTTON) || (gSoundRacerObj->velocity > -0.1) || - (gSoundRacerObj->vehicleID == 4)) && (gRacerSound->unkA8 != 0) - ) { - func_8000488C(gRacerSound->unkA8); - gRacerSound->unkA8 = 0; + if (((gSoundRacerObj->unk10 != 0) || (gSoundRacerObj->unk14 != 0) || !(buttonsHeld & B_BUTTON) || + (gSoundRacerObj->velocity > -0.1) || (gSoundRacerObj->vehicleID == 4)) && + (gRacerSound->unkA8 != 0)) { + func_8000488C(gRacerSound->unkA8); + gRacerSound->unkA8 = 0; } else if ((buttonsPressed & B_BUTTON) && (gRacerSound->unkA8 == 0) && (gSoundRacerObj->playerIndex >= 0)) { if (gSoundRacerObj->velocity < 0.0f) { var_f20 = -gSoundRacerObj->velocity; @@ -335,7 +342,7 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR sp6C = (((var_f20 * 0.5) / 12.0) + 0.5); temp_a0_4 = gRacerSound->unkA8; if (temp_a0_4 != 0) { - sound_event_update(temp_a0_4, 16, *((u32*) &sp6C)); + sound_event_update(temp_a0_4, 16, *((u32 *) &sp6C)); } gRacerSound->unkAC = 110; gRacerSound->unkD0 = 0; @@ -350,7 +357,8 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR sound_event_update(gRacerSound->unkA8, 8, 0); } else { sound_event_update(gRacerSound->unkA8, 8, gRacerSound->unkAC << 8); - func_80009B7C((s32 *) gRacerSound->unkA8, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + func_80009B7C((s32 *) gRacerSound->unkA8, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position); } } gRacerSound->unkA0 = var_s0; @@ -366,7 +374,7 @@ GLOBAL_ASM("asm/non_matchings/audio_vehicle/func_80005254.s") * Update the engine sounds for the hovercraft. * Uses velocity, banana count and ground contact to decide what pitch to use. * Those values are calculated in this function. -*/ + */ void racer_sound_hovercraft(Object *obj, UNUSED u32 buttonsPressed, u32 buttonsHeld, s32 updateRate) { UNUSED s32 pad; f32 velocity; @@ -381,7 +389,8 @@ void racer_sound_hovercraft(Object *obj, UNUSED u32 buttonsPressed, u32 buttonsH u8 i; if (get_race_countdown() == 0) { - velocity = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + (obj->segment.z_velocity * obj->segment.z_velocity)); + velocity = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + + (obj->segment.z_velocity * obj->segment.z_velocity)); } else { velocity = 0.0f; } @@ -433,17 +442,18 @@ void racer_sound_hovercraft(Object *obj, UNUSED u32 buttonsPressed, u32 buttonsH pitch += gRacerSound->bananaPitch; } pitch += ((velocity * gRacerSound->unkCC) + var_f18 + gRacerSound->throttlePitch); - if (gSoundRacerObj->playerIndex != PLAYER_COMPUTER && gSoundRacerObj->groundedWheels == 0 && gSoundRacerObj->waterTimer < 4) { + if (gSoundRacerObj->playerIndex != PLAYER_COMPUTER && gSoundRacerObj->groundedWheels == 0 && + gSoundRacerObj->waterTimer < 4) { if (get_race_countdown() == 0) { pitch += 0.3; } } gRacerSound->unk5C[0] += ((pitch - gRacerSound->unk5C[0]) / 8); if (gRacerSound->unk5C[0] > (0x7FFF / 5000.0)) { - gRacerSound->unk5C[0] = (0x7FFF / 5000.0); //6.5534 + gRacerSound->unk5C[0] = (0x7FFF / 5000.0); // 6.5534 } temp_f10 = gRacerSound->unk5C[0] * 10000.0f; - for (i = 0; temp_f10 >= gRacerSound->unk18[i] && i < 4; i++) { } + for (i = 0; temp_f10 >= gRacerSound->unk18[i] && i < 4; i++) {} if (i == 4) { var_t0 = gRacerSound->unk2C[i]; } else { @@ -461,7 +471,7 @@ void racer_sound_hovercraft(Object *obj, UNUSED u32 buttonsPressed, u32 buttonsH #ifdef NON_EQUIVALENT void func_800063EC(Object *obj, UNUSED u32 buttonsPressed, u32 buttonsHeld, s32 updateRate) { f32 sp28; - f32 var_f2; + f32 var_f2; u16 temp_f10; f32 var_f14; f32 temp_f8; @@ -478,7 +488,8 @@ void func_800063EC(Object *obj, UNUSED u32 buttonsPressed, u32 buttonsHeld, s32 zVel = obj->segment.z_velocity; yVel = obj->segment.y_velocity; var_f18 = sqrtf((xVel * xVel) + (zVel * zVel) + (yVel * yVel)); - //var_f18 = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + (obj->segment.z_velocity * obj->segment.z_velocity) + (obj->segment.y_velocity * obj->segment.y_velocity)); + // var_f18 = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + (obj->segment.z_velocity * + // obj->segment.z_velocity) + (obj->segment.y_velocity * obj->segment.y_velocity)); } else { var_f18 = 0.0f; } @@ -486,7 +497,7 @@ void func_800063EC(Object *obj, UNUSED u32 buttonsPressed, u32 buttonsHeld, s32 gRacerSound->unk54[0] += ((gRacerSound->unk37 - gRacerSound->unk54[0]) / 8); } else { temp_f10 = gRacerSound->unk5C[0] * 10000.0f; - for (i = 0; temp_f10 >= gRacerSound->unk18[i] && i < 4; i++) { } + for (i = 0; temp_f10 >= gRacerSound->unk18[i] && i < 4; i++) {} if (i == 4) { var_t0 = gRacerSound->unk2C[i]; } else { @@ -544,11 +555,12 @@ void func_800063EC(Object *obj, UNUSED u32 buttonsPressed, u32 buttonsHeld, s32 } gRacerSound->unk5C[0] += ((var_f14 - gRacerSound->unk5C[0]) / 8); if (gRacerSound->unk5C[0] > (0x7FFF / 5000.0)) { - gRacerSound->unk5C[0] = (0x7FFF / 5000.0); //6.5534 + gRacerSound->unk5C[0] = (0x7FFF / 5000.0); // 6.5534 } gRacerSound->unk5C[1] = 1.0f; gRacerSound->unk54[1] = 0.0f; - if ((gSoundRacerObj->playerIndex != PLAYER_COMPUTER) && (gSoundRacerObj->spinout_timer != 0) && !gRacerSound->brakeSound) { + if ((gSoundRacerObj->playerIndex != PLAYER_COMPUTER) && (gSoundRacerObj->spinout_timer != 0) && + !gRacerSound->brakeSound) { gRacerSound->brakeSound = TRUE; sound_play(SOUND_UNK_13D, &gRacerSound->brakeSoundMask); } else if (gSoundRacerObj->spinout_timer == 0) { @@ -564,7 +576,7 @@ GLOBAL_ASM("asm/non_matchings/audio_vehicle/func_800063EC.s") /** * Stops all associated sounds and then frees the vehicle sound data from RAM. -*/ + */ void racer_sound_free(Object *obj) { s32 i; @@ -631,10 +643,13 @@ void func_80006BFC(Object *obj, ObjectSegment *segment, Object *obj2, s32 update } break; case VEHICLE_HOVERCRAFT: - velocity = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + (obj->segment.z_velocity * obj->segment.z_velocity)); + velocity = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + + (obj->segment.z_velocity * obj->segment.z_velocity)); break; default: - velocity = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + (obj->segment.z_velocity * obj->segment.z_velocity) + (obj->segment.y_velocity * obj->segment.y_velocity)); + velocity = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + + (obj->segment.z_velocity * obj->segment.z_velocity) + + (obj->segment.y_velocity * obj->segment.y_velocity)); break; } if (velocity > 15.0f) { @@ -653,7 +668,10 @@ void func_80006BFC(Object *obj, ObjectSegment *segment, Object *obj2, s32 update var_f2_2 = -15.0f; } new_var = func_80007FA4(gRacerSound->unk5C[0]) * 1731.23404; - gRacerSound->unk68 += (((alCents2Ratio((((70.0f + var_f2_2) / (70.0f - var_f2_2)) * new_var)) - gRacerSound->unk5C[0]) - gRacerSound->unk68) / 2); + gRacerSound->unk68 += + (((alCents2Ratio((((70.0f + var_f2_2) / (70.0f - var_f2_2)) * new_var)) - gRacerSound->unk5C[0]) - + gRacerSound->unk68) / + 2); gRacerSound->unk68 *= sp1C; if (gRacerSound->unk68 > 0.8) { gRacerSound->unk68 = 0.8; @@ -665,7 +683,7 @@ void func_80006BFC(Object *obj, ObjectSegment *segment, Object *obj2, s32 update } #ifdef NON_EQUIVALENT -//https://decomp.me/scratch/utYpK +// https://decomp.me/scratch/utYpK void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3, s32 updateRate) { f32 tempxPos; f32 tempyPos; @@ -692,7 +710,7 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 } else { gRacerSound = NULL; } - + if (gRacerSound != NULL && gRacerSound->unk0[0] != 0) { if (racer->raceFinished || check_if_showing_cutscene_camera()) { tempxPos = objs[loopCount1]->segment.trans.x_position - segment[loopCount1].trans.x_position; @@ -716,7 +734,8 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 gRacerSound->unk91[0] = 64; gRacerSound->unk68 = 0.0f; } - if ((gRacerSound->unkA0 < 70) && (gRacerSound->unk36) && (arg3 < 3) && (var_f26 != 0.0) && !(gRacerSound->unk44[0] & 1)) { + if ((gRacerSound->unkA0 < 70) && (gRacerSound->unk36) && (arg3 < 3) && (var_f26 != 0.0) && + !(gRacerSound->unk44[0] & 1)) { temp_f20_2 = gRacerSound->unkA0 / 70.0f; temp_s3 = (gRacerSound->unk37 - (gRacerSound->unk37 * temp_f20_2)) * var_f26; if (temp_s3 >= 16) { @@ -726,9 +745,11 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 temp_f0_3 = gRacerSound->unk38 / 100.0f; sp8C = temp_f0_3 + ((((f32) gRacerSound->unk39 / 100.0f) - temp_f0_3) * temp_f20_2); if (gRacerSound->unk50 != NULL) { - func_80009B7C((s32 *) gRacerSound->unk50, objs[loopCount1]->segment.trans.x_position, objs[loopCount1]->segment.trans.y_position, objs[loopCount1]->segment.trans.z_position); + func_80009B7C((s32 *) gRacerSound->unk50, objs[loopCount1]->segment.trans.x_position, + objs[loopCount1]->segment.trans.y_position, + objs[loopCount1]->segment.trans.z_position); sound_event_update(gRacerSound->unk50, 8, temp_s3 << 8); - sound_event_update(gRacerSound->unk50, 16, *((u32*) &sp8C)); + sound_event_update(gRacerSound->unk50, 16, *((u32 *) &sp8C)); func_80004604(gRacerSound->unk50, 80); sound_event_update(gRacerSound->unk50, 4, gRacerSound->unk91[0]); } @@ -741,8 +762,9 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 gRacerSound->unk50 = 0; } for (loopCount2 = 0; loopCount2 < 2 && gRacerSound->unk0[loopCount2] != 0 && var_f26 != 0.0; loopCount2++) { - temp_s3 = gRacerSound->unk54[loopCount2] * var_f26; - sp8C = gRacerSound->unk5C[loopCount2] + gRacerSound->bananaPitch + gRacerSound->enginePitch + gRacerSound->unk68; + temp_s3 = gRacerSound->unk54[loopCount2] * var_f26; + sp8C = gRacerSound->unk5C[loopCount2] + gRacerSound->bananaPitch + gRacerSound->enginePitch + + gRacerSound->unk68; if (sp8C < 0.05) { sp8C = 0.05f; } @@ -760,9 +782,11 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 func_80001F14(gRacerSound->unk0[loopCount2], (s32 *) &gRacerSound->unk48[loopCount2]); } if (gRacerSound->unk48[loopCount2] != NULL) { - func_80009B7C((s32 *) gRacerSound->unk48[loopCount2], objs[loopCount1]->segment.trans.x_position, objs[loopCount1]->segment.trans.y_position, objs[loopCount1]->segment.trans.z_position); + func_80009B7C( + (s32 *) gRacerSound->unk48[loopCount2], objs[loopCount1]->segment.trans.x_position, + objs[loopCount1]->segment.trans.y_position, objs[loopCount1]->segment.trans.z_position); sound_event_update(gRacerSound->unk48[loopCount2], 8, temp_s3 << 8); - sound_event_update(gRacerSound->unk48[loopCount2], 16, *((u32*) &sp8C)); + sound_event_update(gRacerSound->unk48[loopCount2], 16, *((u32 *) &sp8C)); func_80004604(gRacerSound->unk48[loopCount2], 80); if (arg3 != 1) { gRacerSound->unk91[0] = 64; @@ -790,16 +814,23 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 if (objs[loopCount2]->unk64 != NULL) { gRacerSound = (VehicleSoundData *) objs[loopCount2]->unk64->racer.cameraYaw; if (gRacerSound != 0) { - if (racer->raceFinished != 0) { - tempxPos = objs[loopCount2]->segment.trans.x_position - segment[loopCount1].trans.x_position; - tempyPos = objs[loopCount2]->segment.trans.y_position - segment[loopCount1].trans.y_position; - tempzPos = objs[loopCount2]->segment.trans.z_position - segment[loopCount1].trans.z_position; + if (racer->raceFinished != 0) { + tempxPos = + objs[loopCount2]->segment.trans.x_position - segment[loopCount1].trans.x_position; + tempyPos = + objs[loopCount2]->segment.trans.y_position - segment[loopCount1].trans.y_position; + tempzPos = + objs[loopCount2]->segment.trans.z_position - segment[loopCount1].trans.z_position; } else { - tempxPos = objs[loopCount2]->segment.trans.x_position - objs[loopCount1]->segment.trans.x_position; - tempyPos = objs[loopCount2]->segment.trans.y_position - objs[loopCount1]->segment.trans.y_position; - tempzPos = objs[loopCount2]->segment.trans.z_position - objs[loopCount1]->segment.trans.z_position; + tempxPos = + objs[loopCount2]->segment.trans.x_position - objs[loopCount1]->segment.trans.x_position; + tempyPos = + objs[loopCount2]->segment.trans.y_position - objs[loopCount1]->segment.trans.y_position; + tempzPos = + objs[loopCount2]->segment.trans.z_position - objs[loopCount1]->segment.trans.z_position; } - gRacerSound->unk84 = sqrtf((tempxPos * tempxPos) + (tempyPos * tempyPos) + (tempzPos * tempzPos)); + gRacerSound->unk84 = + sqrtf((tempxPos * tempxPos) + (tempyPos * tempyPos) + (tempzPos * tempzPos)); if (gRacerSound->unk84 < 1500.0f) { var_f26 = 2250000.0f; //(1500.0f * 1500.0f) var_f26 = (var_f26 - (gRacerSound->unk84 * gRacerSound->unk84)) / var_f26; @@ -892,9 +923,10 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 func_80001F14(temp->unk0[0], (s32 *) &temp->unk48[0]); } if (temp->unk48[0] != NULL) { - func_80009B7C((s32 *) temp->unk48[0], temp->racerPos.x, temp->racerPos.y, temp->racerPos.z); + func_80009B7C((s32 *) temp->unk48[0], temp->racerPos.x, temp->racerPos.y, + temp->racerPos.z); sound_event_update(temp->unk48[0], 8, temp->unk88 << 8); - sound_event_update(temp->unk48[0], 16, *((u32*) &temp->unk8C)); + sound_event_update(temp->unk48[0], 16, *((u32 *) &temp->unk8C)); if (arg3 != 1) { temp->unk91[0] = 64; } @@ -914,21 +946,21 @@ GLOBAL_ASM("asm/non_matchings/audio_vehicle/func_80006FC8.s") /** * Enable the vehicle sounds made during gameplay. -*/ + */ UNUSED void sound_vehicle_enable(void) { gVehicleSounds = TRUE; } /** * Disable the vehicle sounds made during gameplay. -*/ + */ UNUSED void sound_vehicle_disable(void) { gVehicleSounds = FALSE; } /** * Return whether vehicle sounds should be playing during gameplay. -*/ + */ UNUSED u8 sound_vehicle_check(void) { return gVehicleSounds; } diff --git a/src/audio_vehicle.h b/src/audio_vehicle.h index 8b45cd84..a5bb0dfe 100644 --- a/src/audio_vehicle.h +++ b/src/audio_vehicle.h @@ -138,8 +138,7 @@ extern SoundMask **gSoundMaskHeapUsed; extern SoundMask **gSoundMaskHeapFree; extern u8 gFreeMasks; - -void racer_sound_update(Object* obj, u32 buttonsPressed, u32 carInput, s32 updateRate); +void racer_sound_update(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateRate); void racer_sound_free(Object *); f32 func_80007FA4(f32 arg0); diff --git a/src/audiomgr.c b/src/audiomgr.c index ab6831ff..cf3beebd 100644 --- a/src/audiomgr.c +++ b/src/audiomgr.c @@ -14,44 +14,43 @@ typedef union { struct { - short type; + short type; } gen; struct { - short type; - struct AudioInfo_s *info; + short type; + struct AudioInfo_s *info; } done; - OSScMsg app; + OSScMsg app; } AudioMsg; // TODO: Rare likely modified this struct as evidenced by __amHandleFrameMsg // using *data when it should have been using msg. typedef struct AudioInfo_s { - short *data; /* Output data pointer */ - short frameSamples; /* # of samples synthesized in this frame */ - OSScTask task; /* scheduler structure */ - AudioMsg msg; /* completion message */ + short *data; /* Output data pointer */ + short frameSamples; /* # of samples synthesized in this frame */ + OSScTask task; /* scheduler structure */ + AudioMsg msg; /* completion message */ } AudioInfo; typedef struct { - Acmd *ACMDList[NUM_ACMD_LISTS]; - AudioInfo *audioInfo[NUM_OUTPUT_BUFFERS]; - OSThread thread; - OSMesgQueue audioFrameMsgQ; - OSMesg audioFrameMsgBuf[MAX_MESGS]; - OSMesgQueue audioReplyMsgQ; - OSMesg audioReplyMsgBuf[MAX_MESGS]; - ALGlobals g; + Acmd *ACMDList[NUM_ACMD_LISTS]; + AudioInfo *audioInfo[NUM_OUTPUT_BUFFERS]; + OSThread thread; + OSMesgQueue audioFrameMsgQ; + OSMesg audioFrameMsgBuf[MAX_MESGS]; + OSMesgQueue audioReplyMsgQ; + OSMesg audioReplyMsgBuf[MAX_MESGS]; + ALGlobals g; } AMAudioMgr; -typedef struct -{ - ALLink node; - u32 startAddr; - u32 lastFrame; - char *ptr; +typedef struct { + ALLink node; + u32 startAddr; + u32 lastFrame; + char *ptr; } AMDMABuffer; typedef struct { @@ -60,35 +59,34 @@ typedef struct { AMDMABuffer *firstFree; } AMDMAState; - /**** audio manager globals ****/ OSSched *gAudioSched; ALHeap *gAudioHeap; // Set but not used -AMAudioMgr __am; -static u64 audioStack[AUDIO_STACKSIZE/sizeof(u64)]; +AMAudioMgr __am; +static u64 audioStack[AUDIO_STACKSIZE / sizeof(u64)]; -AMDMAState dmaState; -AMDMABuffer dmaBuffs[NUM_DMA_BUFFERS]; -u32 audFrameCt = 0; -u32 nextDMA = 0; -u32 curAcmdList = 0; -u32 minFrameSize; -u32 frameSize; -u32 maxFrameSize; -s32 gAudioCmdLen; // Set but not used +AMDMAState dmaState; +AMDMABuffer dmaBuffs[NUM_DMA_BUFFERS]; +u32 audFrameCt = 0; +u32 nextDMA = 0; +u32 curAcmdList = 0; +u32 minFrameSize; +u32 frameSize; +u32 maxFrameSize; +s32 gAudioCmdLen; // Set but not used /**** Anti Piracy - Sets random audio frequency ****/ -s16 gAntiPiracyCRCStart; -s8 gAntiPiracyAudioFreq = FALSE; -s32 gFunc80019808Checksum = 0x35281; -s32 gFunc80019808Length = 0xFD0; +s16 gAntiPiracyCRCStart; +s8 gAntiPiracyAudioFreq = FALSE; +s32 gFunc80019808Checksum = 0x35281; +s32 gFunc80019808Length = 0xFD0; /** Queues and storage for use with audio DMA's ****/ -OSIoMesg audDMAIOMesgBuf[NUM_DMA_MESSAGES]; -OSMesgQueue audDMAMessageQ; -OSMesg audDMAMessageBuf[NUM_DMA_MESSAGES]; +OSIoMesg audDMAIOMesgBuf[NUM_DMA_MESSAGES]; +OSMesgQueue audDMAMessageQ; +OSMesg audDMAMessageBuf[NUM_DMA_MESSAGES]; /**** Not really sure why these are here. They are set, but never used. ****/ static s16 *gLastAudioPtr = 0; @@ -98,13 +96,13 @@ static s32 gLastAudioFrameSamples = 0; static void __amMain(UNUSED void *arg); static s32 __amDMA(s32 addr, s32 len, void *state); static ALDMAproc __amDmaNew(AMDMAState **state); -static u32 __amHandleFrameMsg(AudioInfo *info, AudioInfo *lastInfo); +static u32 __amHandleFrameMsg(AudioInfo *info, AudioInfo *lastInfo); static void __amHandleDoneMsg(AudioInfo *info); static void __clearAudioDMA(void); - /**** Debug strings ****/ -const char D_800E49F0[] = "audio manager: RCP audio interface bug caused DMA from bad address - move audiomgr.c in the makelist!\n"; +const char D_800E49F0[] = + "audio manager: RCP audio interface bug caused DMA from bad address - move audiomgr.c in the makelist!\n"; const char D_800E4A58[] = "audio: ai out of samples\n"; const char D_800E4A74[] = "OH DEAR - No audio DMA buffers left\n"; const char D_800E4A9C[] = "Dma not done\n"; @@ -190,10 +188,11 @@ void amCreateAudioMgr(ALSynConfig *c, OSPri pri, OSSched *audSched) { } for (i = 0; i < NUM_ACMD_LISTS; i++) { - __am.ACMDList[i] = (Acmd *) alHeapAlloc(c->heap, 1, 0xA000); //sizeof(Acmd) * DMA_BUFFER_LENGTH * 5? + __am.ACMDList[i] = (Acmd *) alHeapAlloc(c->heap, 1, 0xA000); // sizeof(Acmd) * DMA_BUFFER_LENGTH * 5? } - asset = allocate_at_address_in_main_pool((maxFrameSize * 12), (u8 *)(0x803FFE00 - (maxFrameSize * 12)), COLOUR_TAG_CYAN); + asset = allocate_at_address_in_main_pool((maxFrameSize * 12), (u8 *) (0x803FFE00 - (maxFrameSize * 12)), + COLOUR_TAG_CYAN); /**** initialize the done messages ****/ for (i = 0; i < NUM_ACMD_LISTS + 1; i++) { @@ -206,13 +205,12 @@ void amCreateAudioMgr(ALSynConfig *c, OSPri pri, OSSched *audSched) { osCreateMesgQueue(&__am.audioFrameMsgQ, __am.audioFrameMsgBuf, MAX_MESGS); osCreateMesgQueue(&audDMAMessageQ, audDMAMessageBuf, NUM_DMA_MESSAGES); - osCreateThread(&__am.thread, 4, __amMain, 0, - (void *)(audioStack+AUDIO_STACKSIZE/sizeof(u64)), pri); + osCreateThread(&__am.thread, 4, __amMain, 0, (void *) (audioStack + AUDIO_STACKSIZE / sizeof(u64)), pri); } /** * Official Name: amGo -*/ + */ void audioStartThread(void) { osStartThread(&__am.thread); } @@ -249,21 +247,21 @@ static void __amMain(UNUSED void *arg) { while (!done) { (void) osRecvMesg(&__am.audioFrameMsgQ, (OSMesg *) &msg, OS_MESG_BLOCK); switch (msg->gen.type) { - case OS_SC_RETRACE_MSG: - //TODO: Check type of ACMDList? - __amHandleFrameMsg((AudioInfo *) __am.ACMDList[(((u32) audFrameCt % 3))+2], lastInfo); - /* wait for done message */ - osRecvMesg(&__am.audioReplyMsgQ, (OSMesg *) &lastInfo, OS_MESG_BLOCK); - __amHandleDoneMsg(lastInfo); - break; - case OS_SC_PRE_NMI_MSG: - /* what should we really do here? quit? ramp down volume? */ - break; - case QUIT_MSG: - done = 1; - break; - default: - break; + case OS_SC_RETRACE_MSG: + // TODO: Check type of ACMDList? + __amHandleFrameMsg((AudioInfo *) __am.ACMDList[(((u32) audFrameCt % 3)) + 2], lastInfo); + /* wait for done message */ + osRecvMesg(&__am.audioReplyMsgQ, (OSMesg *) &lastInfo, OS_MESG_BLOCK); + __amHandleDoneMsg(lastInfo); + break; + case OS_SC_PRE_NMI_MSG: + /* what should we really do here? quit? ramp down volume? */ + break; + case QUIT_MSG: + done = 1; + break; + default: + break; } } @@ -272,13 +270,13 @@ static void __amMain(UNUSED void *arg) { /****************************************************************************** * - * __amHandleFrameMsg. First, clear the past audio dma's, then calculate + * __amHandleFrameMsg. First, clear the past audio dma's, then calculate * the number of samples you will need for this frame. This value varies - * due to the fact that audio is synchronised off of the video interupt - * which can have a small amount of jitter in it. Varying the number of + * due to the fact that audio is synchronised off of the video interupt + * which can have a small amount of jitter in it. Varying the number of * samples slightly will allow you to stay in synch with the video. This - * is an advantageous thing to do, since if you are in synch with the - * video, you will have fewer graphics yields. After you've calculated + * is an advantageous thing to do, since if you are in synch with the + * video, you will have fewer graphics yields. After you've calculated * the number of frames needed, call alAudioFrame, which will call all * of the synthesizer's players (sequence player and sound player) to * generate the audio task list. If you get a valid task list back, put @@ -293,11 +291,10 @@ static u32 __amHandleFrameMsg(AudioInfo *info, AudioInfo *lastInfo) { OSScTask *t; u32 ret; - __clearAudioDMA(); /* call once a frame, before doing alAudioFrame */ audioPtr = (s16 *) osVirtualToPhysical(info->data); - + if (lastInfo) { s16 *outputDataPointer; s32 frameSamples; @@ -312,37 +309,35 @@ static u32 __amHandleFrameMsg(AudioInfo *info, AudioInfo *lastInfo) { } } - /* calculate how many samples needed for this frame to keep the DAC full */ /* this will vary slightly frame to frame, must recalculate every frame */ samplesLeft = osAiGetLength() >> 2; /* divide by four, to convert bytes */ /* to stereo 16 bit samples */ info->frameSamples = (16 + (frameSize - samplesLeft + EXTRA_SAMPLES)) & ~0xf; - if ((u32)info->frameSamples < minFrameSize) + if ((u32) info->frameSamples < minFrameSize) { info->frameSamples = minFrameSize; + } - cmdp = alAudioFrame(__am.ACMDList[curAcmdList], &gAudioCmdLen, audioPtr, - info->frameSamples); + cmdp = alAudioFrame(__am.ACMDList[curAcmdList], &gAudioCmdLen, audioPtr, info->frameSamples); t = &info->task; - - t->next = 0; /* paranoia */ - t->msgQ = &__am.audioReplyMsgQ; /* reply to when finished */ - //TODO: This should be &info->msg, but the struct is likely modified. - t->msg = (OSMesg) &info->data; /* reply with this message */ - t->flags = OS_SC_NEEDS_RSP; + + t->next = 0; /* paranoia */ + t->msgQ = &__am.audioReplyMsgQ; /* reply to when finished */ + // TODO: This should be &info->msg, but the struct is likely modified. + t->msg = (OSMesg) &info->data; /* reply with this message */ + t->flags = OS_SC_NEEDS_RSP; t->unk58 = -1; t->unk60 = 0xFF; t->unk5C = 0; t->unk64 = 0; - - t->list.t.data_ptr = (u64 *) __am.ACMDList[curAcmdList]; - t->list.t.data_size = (cmdp - __am.ACMDList[curAcmdList]) * sizeof(Acmd); - t->list.t.type = M_AUDTASK; - t->list.t.ucode_boot = (u64 *)rspF3DDKRBootStart; - t->list.t.ucode_boot_size = - ((int) rspF3DDKRDramStart - (int) rspF3DDKRBootStart); - t->list.t.flags = OS_TASK_DP_WAIT; + + t->list.t.data_ptr = (u64 *) __am.ACMDList[curAcmdList]; + t->list.t.data_size = (cmdp - __am.ACMDList[curAcmdList]) * sizeof(Acmd); + t->list.t.type = M_AUDTASK; + t->list.t.ucode_boot = (u64 *) rspF3DDKRBootStart; + t->list.t.ucode_boot_size = ((int) rspF3DDKRDramStart - (int) rspF3DDKRBootStart); + t->list.t.flags = OS_TASK_DP_WAIT; t->list.t.ucode = (u64 *) aspMainTextStart; t->list.t.ucode_data = (u64 *) aspMainDataStart; t->list.t.ucode_data_size = SP_UCODE_DATA_SIZE; @@ -351,9 +346,9 @@ static u32 __amHandleFrameMsg(AudioInfo *info, AudioInfo *lastInfo) { t->unk6C = 1; ret = osSendMesg(osScGetCmdQ(gAudioSched), (OSMesg) t, OS_MESG_NOBLOCK); - - curAcmdList ^= 1; /* swap which acmd list you use each frame */ - + + curAcmdList ^= 1; /* swap which acmd list you use each frame */ + return ret; } @@ -364,12 +359,12 @@ static u32 __amHandleFrameMsg(AudioInfo *info, AudioInfo *lastInfo) { * *****************************************************************************/ static void __amHandleDoneMsg(UNUSED AudioInfo *info) { - s32 samplesLeft; + s32 samplesLeft; static int firstTime = 1; - samplesLeft = osAiGetLength()>>2; + samplesLeft = osAiGetLength() >> 2; if (samplesLeft == 0 && !firstTime) { - //stubbed_printf("audio: ai out of samples\n"); + // stubbed_printf("audio: ai out of samples\n"); firstTime = 0; } } @@ -389,31 +384,31 @@ static void __amHandleDoneMsg(UNUSED AudioInfo *info) { * *****************************************************************************/ static s32 __amDMA(s32 addr, s32 len, UNUSED void *state) { - void *foundBuffer; - s32 delta, addrEnd, buffEnd; - AMDMABuffer *dmaPtr, *lastDmaPtr; + void *foundBuffer; + s32 delta, addrEnd, buffEnd; + AMDMABuffer *dmaPtr, *lastDmaPtr; UNUSED s32 pad; lastDmaPtr = 0; delta = addr & 1; dmaPtr = dmaState.firstUsed; - addrEnd = addr+len; + addrEnd = addr + len; /* first check to see if a currently existing buffer contains the sample that you need. */ while (dmaPtr) { buffEnd = dmaPtr->startAddr + DMA_BUFFER_LENGTH; - if(dmaPtr->startAddr > (u32)addr) /* since buffers are ordered */ - break; /* abort if past possible */ + if (dmaPtr->startAddr > (u32) addr) { /* since buffers are ordered */ + break; /* abort if past possible */ - else if(addrEnd <= buffEnd) { /* yes, found a buffer with samples */ + } else if (addrEnd <= buffEnd) { /* yes, found a buffer with samples */ dmaPtr->lastFrame = audFrameCt; /* mark it used */ foundBuffer = dmaPtr->ptr + addr - dmaPtr->startAddr; return (int) osVirtualToPhysical(foundBuffer); } lastDmaPtr = dmaPtr; - dmaPtr = (AMDMABuffer * )dmaPtr->node.next; + dmaPtr = (AMDMABuffer *) dmaPtr->node.next; } /* get here, and you didn't find a buffer, so dma a new one */ @@ -430,7 +425,7 @@ static s32 __amDMA(s32 addr, s32 len, UNUSED void *state) { * pointer, it's better than nothing */ if (!dmaPtr) { - return (int) osVirtualToPhysical(lastDmaPtr->ptr) + delta; + return (int) osVirtualToPhysical(lastDmaPtr->ptr) + delta; } dmaState.firstFree = (AMDMABuffer *) dmaPtr->node.next; @@ -438,18 +433,16 @@ static s32 __amDMA(s32 addr, s32 len, UNUSED void *state) { /* add it to the used list */ if (lastDmaPtr) { /* if you have other dmabuffers used, add this one */ - /* to the list, after the last one checked above */ + /* to the list, after the last one checked above */ alLink((ALLink *) dmaPtr, (ALLink *) lastDmaPtr); - } - else if (dmaState.firstUsed) { /* if this buffer is before any others */ - /* jam at begining of list */ + } else if (dmaState.firstUsed) { /* if this buffer is before any others */ + /* jam at begining of list */ lastDmaPtr = dmaState.firstUsed; dmaState.firstUsed = dmaPtr; dmaPtr->node.next = (ALLink *) lastDmaPtr; dmaPtr->node.prev = 0; lastDmaPtr->node.prev = (ALLink *) dmaPtr; - } - else { /* no buffers in list, this is the first one */ + } else { /* no buffers in list, this is the first one */ dmaState.firstUsed = dmaPtr; dmaPtr->node.next = 0; dmaPtr->node.prev = 0; @@ -458,10 +451,10 @@ static s32 __amDMA(s32 addr, s32 len, UNUSED void *state) { foundBuffer = dmaPtr->ptr; addr -= delta; dmaPtr->startAddr = addr; - dmaPtr->lastFrame = audFrameCt; /* mark it */ + dmaPtr->lastFrame = audFrameCt; /* mark it */ - osPiStartDma(&audDMAIOMesgBuf[nextDMA++], OS_MESG_PRI_HIGH, OS_READ, - addr, foundBuffer, DMA_BUFFER_LENGTH, &audDMAMessageQ); + osPiStartDma(&audDMAIOMesgBuf[nextDMA++], OS_MESG_PRI_HIGH, OS_READ, addr, foundBuffer, DMA_BUFFER_LENGTH, + &audDMAMessageQ); return (int) osVirtualToPhysical(foundBuffer) + delta; } @@ -479,13 +472,13 @@ static s32 __amDMA(s32 addr, s32 len, UNUSED void *state) { *****************************************************************************/ static ALDMAproc __amDmaNew(AMDMAState **state) { - if(!dmaState.initialized) { /* only do this once */ + if (!dmaState.initialized) { /* only do this once */ dmaState.firstUsed = 0; dmaState.firstFree = &dmaBuffs[0]; dmaState.initialized = 1; } - *state = &dmaState; /* state is never used in this case */ + *state = &dmaState; /* state is never used in this case */ return __amDMA; } @@ -495,42 +488,41 @@ static ALDMAproc __amDmaNew(AMDMAState **state) { * __clearAudioDMA. Routine to move dma buffers back to the unused list. * First clear out your dma messageQ. Then check each buffer to see when * it was last used. If that was more than FRAME_LAG frames ago, move it - * back to the unused list. + * back to the unused list. * *****************************************************************************/ static void __clearAudioDMA(void) { - u32 i; - OSIoMesg *iomsg = 0; - AMDMABuffer *dmaPtr,*nextPtr; - + u32 i; + OSIoMesg *iomsg = 0; + AMDMABuffer *dmaPtr, *nextPtr; + /* * Don't block here. If dma's aren't complete, you've had an audio * overrun. (Bad news, but go for it anyway, and try and recover. */ for (i = 0; i < nextDMA; i++) { - if (osRecvMesg(&audDMAMessageQ, (OSMesg *) &iomsg, OS_MESG_NOBLOCK) == -1) - { /* stubbed_printf("Dma not done\n"); */ } + if (osRecvMesg(&audDMAMessageQ, (OSMesg *) &iomsg, OS_MESG_NOBLOCK) == + -1) { /* stubbed_printf("Dma not done\n"); */ + } // if (logging) // osLogEvent(log, 17, 2, iomsg->devAddr, iomsg->size); } - dmaPtr = dmaState.firstUsed; - while(dmaPtr) { + while (dmaPtr) { nextPtr = (AMDMABuffer *) dmaPtr->node.next; /* remove old dma's from list */ /* Can change FRAME_LAG value. Should be at least one. */ /* Larger values mean more buffers needed, but fewer DMA's */ - if(dmaPtr->lastFrame + FRAME_LAG < audFrameCt) { - if(dmaState.firstUsed == dmaPtr) { + if (dmaPtr->lastFrame + FRAME_LAG < audFrameCt) { + if (dmaState.firstUsed == dmaPtr) { dmaState.firstUsed = (AMDMABuffer *) dmaPtr->node.next; } alUnlink((ALLink *) dmaPtr); - if(dmaState.firstFree) { + if (dmaState.firstFree) { alLink((ALLink *) dmaPtr, (ALLink *) dmaState.firstFree); - } - else { + } else { dmaState.firstFree = dmaPtr; dmaPtr->node.next = 0; dmaPtr->node.prev = 0; @@ -538,7 +530,7 @@ static void __clearAudioDMA(void) { } dmaPtr = nextPtr; } - - nextDMA = 0; /* reset */ + + nextDMA = 0; /* reset */ audFrameCt++; } diff --git a/src/audiosfx.c b/src/audiosfx.c index 0fa7b90b..ba6e8681 100644 --- a/src/audiosfx.c +++ b/src/audiosfx.c @@ -11,7 +11,7 @@ #include "PR/libaudio.h" ALSoundState *D_800DC6B0 = NULL; -s32 D_800DC6B4 = 0; // Currently unknown, might be a different type. +s32 D_800DC6B4 = 0; // Currently unknown, might be a different type. unk800DC6BC_40 *D_800DC6B8 = NULL; // Set but not used. unk800DC6BC gAlSndPlayer; unk800DC6BC *gAlSndPlayerPtr = &gAlSndPlayer; @@ -46,7 +46,7 @@ void set_sound_channel_count(s32 numChannels) { /** * Initialise a sound player and ready it for use with the sound event system. -*/ + */ void alSndPNew(audioMgrConfig *c) { u32 i; unk800DC6BC_40 *tmp1; @@ -58,9 +58,8 @@ void alSndPNew(audioMgrConfig *c) { gAlSndPlayerPtr->soundChannelsMax = c->maxChannels; gAlSndPlayerPtr->soundChannels = c->maxChannels; gAlSndPlayerPtr->unk3C = 0; - gAlSndPlayerPtr->frameTime = 33000; //AL_USEC_PER_FRAME /* time between API events */ - gAlSndPlayerPtr->unk40 = (unk800DC6BC_40 *) alHeapAlloc(c->hp, 1, - c->unk00 * sizeof(unk800DC6BC_40)); + gAlSndPlayerPtr->frameTime = 33000; // AL_USEC_PER_FRAME /* time between API events */ + gAlSndPlayerPtr->unk40 = (unk800DC6BC_40 *) alHeapAlloc(c->hp, 1, c->unk00 * sizeof(unk800DC6BC_40)); alEvtqNew(&(gAlSndPlayerPtr->evtq), alHeapAlloc(c->hp, 1, (c->unk04) * 28), c->unk04); D_800DC6B8 = gAlSndPlayerPtr->unk40; for (i = 1; i < c->unk00; i++) { @@ -131,36 +130,37 @@ void func_8000418C(ALVoiceState *voiceState) { ALEvent_unk8000418C evt; f32 sp1C; - sp1C = alCents2Ratio(((ALLink_unk8000418C*)voiceState->voice.node.prev->prev)->unk5) * voiceState->vibrato; + sp1C = alCents2Ratio(((ALLink_unk8000418C *) voiceState->voice.node.prev->prev)->unk5) * voiceState->vibrato; evt.type = AL_SEQP_STOP_EVT; evt.unk4 = voiceState; - evt.unk8 = *((s32*)&sp1C); // But why tho? + evt.unk8 = *((s32 *) &sp1C); // But why tho? alEvtqPostEvent(&gAlSndPlayerPtr->evtq, (ALEvent *) &evt, 33333); } static void _removeEvents(ALEventQueue *evtq, ALSoundState *state, u16 eventType) { - ALLink *thisNode; - ALLink *nextNode; - ALEventListItem *thisItem; - ALEventListItem *nextItem; - ALSndpEvent *thisEvent; - OSIntMask mask; + ALLink *thisNode; + ALLink *nextNode; + ALEventListItem *thisItem; + ALEventListItem *nextItem; + ALSndpEvent *thisEvent; + OSIntMask mask; mask = osSetIntMask(OS_IM_NONE); thisNode = evtq->allocList.next; - while( thisNode != 0 ) { - nextNode = thisNode->next; + while (thisNode != 0) { + nextNode = thisNode->next; thisItem = (ALEventListItem *) thisNode; nextItem = (ALEventListItem *) nextNode; thisEvent = (ALSndpEvent *) &thisItem->evt; - if (thisEvent->common.state == state && (u16)thisEvent->msg.type & eventType){ - if( nextItem ) + if (thisEvent->common.state == state && (u16) thisEvent->msg.type & eventType) { + if (nextItem) { nextItem->delta += thisItem->delta; + } alUnlink(thisNode); alLink(thisNode, &evtq->freeList); } - thisNode = nextNode; + thisNode = nextNode; } osSetIntMask(mask); @@ -206,13 +206,15 @@ GLOBAL_ASM("asm/non_matchings/audiosfx/func_80004384.s") GLOBAL_ASM("asm/non_matchings/audiosfx/func_80004520.s") void func_80004604(u8 *arg0, u8 arg1) { - if (arg0) + if (arg0) { arg0[0x36] = arg1; + } } UNUSED u8 func_8000461C(u8 *arg0) { - if (arg0) + if (arg0) { return arg0[0x3F]; + } return 0; } @@ -227,13 +229,13 @@ s32 func_80004668(ALBank *bnk, s16 sndIndx, u8 arg2, SoundMask *soundMask) { GLOBAL_ASM("asm/non_matchings/audiosfx/func_80004668.s") #endif -//input typing not right (some type of struct) -// 99% sure this function will clear the audio buffer associated with a given sound mask. +// input typing not right (some type of struct) +// 99% sure this function will clear the audio buffer associated with a given sound mask. void func_8000488C(u8 *arg0) { ALEvent sp_18; sp_18.type = 1024; //((u32 *)(&sp_18))[1] = (u32)arg0; - sp_18.msg.osc.vs = (ALVoiceState *) arg0; //Not really a voice state, but not sure what else it is. + sp_18.msg.osc.vs = (ALVoiceState *) arg0; // Not really a voice state, but not sure what else it is. if (arg0) { arg0[0x3e] &= ~(1 << 4); alEvtqPostEvent(&(gAlSndPlayerPtr->evtq), &sp_18, 0); @@ -269,14 +271,14 @@ UNUSED void func_800049B8(void) { /** * Stops all sounds from playing. -*/ + */ void sound_stop_all(void) { func_800048D8(AL_SNDP_PLAY_EVT | AL_SNDP_STOP_EVT); } /** * Send a message to the sound player to update an existing property of the sound entry. -*/ + */ void sound_event_update(s32 soundMask, s16 type, u32 volume) { ALEvent2 sndEvt; sndEvt.snd_event.type = type; @@ -290,16 +292,17 @@ void sound_event_update(s32 soundMask, s16 type, u32 volume) { /** * Returns the volume level of the channel ID. * Official Name: gsSndpGetMasterVolume -*/ + */ u16 get_sound_channel_volume(u8 channel) { return gSoundChannelVolume[channel]; } -//TODO: The structs used here are almost definitely wrong, but they do match, so it can at least show the pattern we're looking for. +// TODO: The structs used here are almost definitely wrong, but they do match, so it can at least show the pattern we're +// looking for. /** * Looks for the intended audio channel in the main buffer and adjusts its volume * Official Name: gsSndpSetMasterVolume -*/ + */ void set_sound_channel_volume(u8 channel, u16 volume) { OSIntMask mask; ALEventQueue *queue; @@ -311,7 +314,7 @@ void set_sound_channel_volume(u8 channel, u16 volume) { gSoundChannelVolume[channel] = volume; while (queue != NULL) { - //This is almost definitely the wrong struct list, but it matches so I'm not going to complain + // This is almost definitely the wrong struct list, but it matches so I'm not going to complain if ((((ALInstrument *) queue->allocList.next->prev)->priority & 0x3F) == channel) { evt.type = AL_SNDP_UNK_11_EVT; evt.msg.spseq.seq = (void *) queue; diff --git a/src/borders.c b/src/borders.c index 4c7b6317..b73f56ed 100644 --- a/src/borders.c +++ b/src/borders.c @@ -26,7 +26,7 @@ void render_borders_for_multiplayer(Gfx **dlist) { width = GET_VIDEO_WIDTH(widthAndHeight); height = GET_VIDEO_HEIGHT(widthAndHeight); xOffset = width / 256; - width += 0; //Fake match? + width += 0; // Fake match? yOffset = height / 128; gDPSetCycleType((*dlist)++, G_CYC_FILL); gDPSetFillColor((*dlist)++, GPACK_RGBA5551(0, 0, 0, 1) << 16 | GPACK_RGBA5551(0, 0, 0, 1)); // Black fill color @@ -46,7 +46,8 @@ void render_borders_for_multiplayer(Gfx **dlist) { case VIEWPORTS_COUNT_4_PLAYERS: x = (width >> 1) - xOffset; // Draws 2 black lines in the middle of the screen. One vertical, another horizontal. - gDPFillRectangle((*dlist)++, height * 0, (height >> 1) - yOffset, width, ((height >> 1) - yOffset) + yOffset); + gDPFillRectangle((*dlist)++, height * 0, (height >> 1) - yOffset, width, + ((height >> 1) - yOffset) + yOffset); gDPFillRectangle((*dlist)++, x, 0, x + xOffset, height); break; } @@ -75,7 +76,7 @@ void render_second_multiplayer_borders(Gfx **dlist) { gDPSetCombineMode((*dlist)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); gDPSetRenderMode((*dlist)++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetPrimColor((*dlist)++, 0, 0, 0, 0, 0, 0); - switch(get_viewport_count()) { + switch (get_viewport_count()) { case VIEWPORTS_COUNT_2_PLAYERS: tempY = (screenHeight / 2) - (height / 2); gDPFillRectangle((*dlist)++, 0, tempY, screenWidth, tempY + height); diff --git a/src/camera.c b/src/camera.c index 457dcd36..4b4b5d7d 100644 --- a/src/camera.c +++ b/src/camera.c @@ -34,11 +34,9 @@ s8 gAntiPiracyViewport = FALSE; // posX, posY, width, height // scissorX1, scissorY1, scissorX2, scissorY2 // flags -#define DEFAULT_VIEWPORT \ - 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, \ - SCREEN_WIDTH_HALF, SCREEN_HEIGHT_HALF, SCREEN_WIDTH, SCREEN_HEIGHT, \ - 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, \ - 0 +#define DEFAULT_VIEWPORT \ + 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH_HALF, SCREEN_HEIGHT_HALF, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, \ + SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0 ScreenViewport gScreenViewports[4] = { { DEFAULT_VIEWPORT }, @@ -49,35 +47,23 @@ ScreenViewport gScreenViewports[4] = { u32 gViewportWithBG = FALSE; -Vertex gVehiclePartVertex = { - 0, 0, 0, 255, 255, 255, 255 -}; +Vertex gVehiclePartVertex = { 0, 0, 0, 255, 255, 255, 255 }; -//The viewport z-range below is half of the max (511) +// The viewport z-range below is half of the max (511) #define G_HALFZ (G_MAXZ / 2) /* 9 bits of integer screen-Z precision */ // RSP Viewports Vp gViewportStack[20] = { - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, - { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, + { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, { { { 0, 0, G_HALFZ, 0 }, { 0, 0, G_HALFZ, 0 } } }, }; ObjectTransform D_800DD288 = { @@ -95,9 +81,7 @@ Matrix gOrthoMatrixF = { { 0.0f, 0.0f, 0.0f, 160.0f }, }; -u8 gCameraZoomLevels[8] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; +u8 gCameraZoomLevels[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; /*******************************/ @@ -140,21 +124,23 @@ Matrix gCurrentModelMatrixS; extern s32 D_B0000578; /** * Official Name: camInit -*/ + */ void camera_init(void) { s32 i; s32 j; u32 stat; - - // This loop is not cooperating. - for (i = 0; i < 5; i++) { gModelMatrixF[i] = D_80120DA0 + i + i*0; } + + // This loop is not cooperating. + for (i = 0; i < 5; i++) { + gModelMatrixF[i] = D_80120DA0 + i + i * 0; + } for (j = 0; j < 8; j++) { gActiveCameraID = j; camera_reset(200, 200, 200, 0, 0, 180); } - - gCutsceneCameraActive = FALSE; + + gCutsceneCameraActive = FALSE; gActiveCameraID = 0; gModelMatrixStackPos = 0; gCameraMatrixPos = 0; @@ -163,15 +149,16 @@ void camera_init(void) { D_80120D18 = 0; gAdjustViewportHeight = 0; gAntiPiracyViewport = 0; - + WAIT_ON_IOBUSY(stat); - - //0xB0000578 is a direct read from the ROM as opposed to RAM + + // 0xB0000578 is a direct read from the ROM as opposed to RAM if (((D_B0000578 & 0xFFFF) & 0xFFFF) != 0x8965) { gAntiPiracyViewport = TRUE; } - guPerspectiveF(gPerspectiveMatrixF, &perspNorm, CAMERA_DEFAULT_FOV, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); + guPerspectiveF(gPerspectiveMatrixF, &perspNorm, CAMERA_DEFAULT_FOV, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, + CAMERA_SCALE); f32_matrix_to_s16_matrix(&gPerspectiveMatrixF, &gProjectionMatrixS); gCurCamFOV = CAMERA_DEFAULT_FOV; } @@ -189,7 +176,7 @@ void func_80066060(s32 cameraID, s32 zoomLevel) { /** * Set gAdjustViewportHeight to PAL mode if necessary, if setting is 1. * Otherwise, set it to 0, regardless of TV type. -*/ + */ void set_viewport_tv_type(s8 setting) { if (osTvType == TV_TYPE_PAL) { gAdjustViewportHeight = setting; @@ -219,7 +206,8 @@ UNUSED f32 get_current_camera_fov(void) { void update_camera_fov(f32 camFieldOfView) { if (CAMERA_MIN_FOV < camFieldOfView && camFieldOfView < CAMERA_MAX_FOV && camFieldOfView != gCurCamFOV) { gCurCamFOV = camFieldOfView; - guPerspectiveF(gPerspectiveMatrixF, &perspNorm, camFieldOfView, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); + guPerspectiveF(gPerspectiveMatrixF, &perspNorm, camFieldOfView, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, + CAMERA_SCALE); f32_matrix_to_s16_matrix(&gPerspectiveMatrixF, &gProjectionMatrixS); } } @@ -228,20 +216,21 @@ void update_camera_fov(f32 camFieldOfView) { * Unused function that recalculates the perspective matrix. */ UNUSED void calculate_camera_perspective(void) { - guPerspectiveF(gPerspectiveMatrixF, &perspNorm, CAMERA_DEFAULT_FOV, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); + guPerspectiveF(gPerspectiveMatrixF, &perspNorm, CAMERA_DEFAULT_FOV, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, + CAMERA_SCALE); f32_matrix_to_s16_matrix(&gPerspectiveMatrixF, &gProjectionMatrixS); } /** * Return the current fixed point model matrix. -*/ + */ UNUSED Matrix *matrix_get_model_s16(void) { return &gCurrentModelMatrixS; } /** * Returns the number of active viewports. -*/ + */ s32 get_viewport_count(void) { return gNumberOfViewports; } @@ -249,14 +238,14 @@ s32 get_viewport_count(void) { /** * Return the index of the active view. * 0-3 is players 1-4, and 4-7 is the same, but with 4 added on for cutscenes. -*/ + */ s32 get_current_viewport(void) { return gActiveCameraID; } /** * Initialises the camera object for the tracks menu. -*/ + */ void camera_init_tracks_menu(Gfx **dList, MatrixS **mtxS) { ObjectSegment *cam; s16 angleY; @@ -297,7 +286,7 @@ void camera_init_tracks_menu(Gfx **dList, MatrixS **mtxS) { /** * Compare the coordinates passed through to the active camera and return the distance between them. -*/ + */ f32 get_distance_to_active_camera(f32 xPos, f32 yPos, f32 zPos) { s32 index; f32 dx, dz, dy; @@ -317,7 +306,7 @@ f32 get_distance_to_active_camera(f32 xPos, f32 yPos, f32 zPos) { /** * Sets the position and angle of the active camera. * Also sets the other properties of the camera to a default. -*/ + */ void camera_reset(s32 xPos, s32 yPos, s32 zPos, s32 angleZ, s32 angleX, s32 angleY) { gCameraSegment[gActiveCameraID].trans.z_rotation = (s16) (angleZ * 0xB6); gCameraSegment[gActiveCameraID].trans.x_position = (f32) xPos; @@ -338,7 +327,7 @@ void camera_reset(s32 xPos, s32 yPos, s32 zPos, s32 angleZ, s32 angleX, s32 angl * Write directly to the second set of object stack indeces. * The first 4 are reserved for the 4 player viewports, so the misc views, used in the title screen * and course previews instead use the next 4. -*/ + */ void write_to_object_render_stack(s32 stackPos, f32 xPos, f32 yPos, f32 zPos, s16 arg4, s16 arg5, s16 arg6) { stackPos += 4; gCameraSegment[stackPos].camera.unk38 = 0; @@ -355,14 +344,14 @@ void write_to_object_render_stack(s32 stackPos, f32 xPos, f32 yPos, f32 zPos, s1 /** * Check if the misc camera view is active. * Official name: camIsUserView -*/ + */ s8 check_if_showing_cutscene_camera(void) { return gCutsceneCameraActive; } /** * Disable the cutscene camera, returning it to the conventional mode. -*/ + */ void disable_cutscene_camera(void) { gCutsceneCameraActive = FALSE; } @@ -371,7 +360,7 @@ void disable_cutscene_camera(void) { * Sets the cap for the viewports. Usually reflecting how many there are. * If the number passed is within 1-4, then the stack cap is set to * how many active viewports there are. -*/ + */ s32 set_active_viewports_and_max(s32 num) { if (num >= 0 && num < 4) { gNumberOfViewports = num; @@ -402,7 +391,7 @@ s32 set_active_viewports_and_max(s32 num) { * Sets the active viewport ID to the passed number. * If it's not within 1-4, then it's set to 0. * Official name: camSetView -*/ + */ void set_active_camera(s32 num) { if (num >= 0 && num < 4) { gActiveCameraID = num; @@ -414,7 +403,7 @@ void set_active_camera(s32 num) { /** * Takes the size of each view frame and writes them to the viewport stack, using values compatable with the RSP. * Only does this if extended backgrounds are enabled. -*/ + */ void copy_viewports_to_stack(void) { s32 width; s32 height; @@ -462,7 +451,7 @@ void copy_viewports_to_stack(void) { port = i + (gViewportWithBG * 5); port += 10; if (get_filtered_cheats() & CHEAT_MIRRORED_TRACKS) { - if (0) { } // Fakematch + if (0) {} // Fakematch width = -width; } gViewportStack[port].vp.vtrans[0] = xPos; @@ -494,7 +483,7 @@ void camDisableUserView(s32 viewPortIndex, s32 arg1) { /** * Return's the current viewport's flag status for extended backgrounds. * Required to draw some extra things used in menus. -*/ + */ s32 check_viewport_background_flag(s32 viewPortIndex) { return gScreenViewports[viewPortIndex].flags & VIEWPORT_EXTRA_BG; } @@ -502,7 +491,7 @@ s32 check_viewport_background_flag(s32 viewPortIndex) { /** * Sets the intended viewport to the size passed through by arguments. * Official Name: camSetUserView -*/ + */ void viewport_menu_set(s32 viewPortIndex, s32 x1, s32 y1, s32 x2, s32 y2) { s32 widthAndHeight, width, height; s32 temp; @@ -567,8 +556,8 @@ void set_viewport_properties(s32 viewPortIndex, s32 posX, s32 posY, s32 width, s gScreenViewports[viewPortIndex].flags &= ~VIEWPORT_X_CUSTOM; } if (posY != VIEWPORT_AUTO) { -//!@bug Viewport Y writes to the X value. Luckily, all cases this function is called use VIEWPORT_AUTO, -// so this bug doesn't happen in practice. + //!@bug Viewport Y writes to the X value. Luckily, all cases this function is called use VIEWPORT_AUTO, + // so this bug doesn't happen in practice. gScreenViewports[viewPortIndex].posX = posY; gScreenViewports[viewPortIndex].flags |= VIEWPORT_Y_CUSTOM; } else { @@ -594,7 +583,7 @@ void set_viewport_properties(s32 viewPortIndex, s32 posX, s32 posY, s32 width, s * Official name: camGetVisibleUserView */ s32 copy_viewport_background_size_to_coords(s32 viewPortIndex, s32 *x1, s32 *y1, s32 *x2, s32 *y2) { - //gDPFillRectangle values + // gDPFillRectangle values *x1 = gScreenViewports[viewPortIndex].scissorX1; *x2 = gScreenViewports[viewPortIndex].scissorX2; *y1 = gScreenViewports[viewPortIndex].scissorY1; @@ -630,7 +619,7 @@ UNUSED void copy_framebuffer_size_to_coords(s32 *x1, s32 *y1, s32 *x2, s32 *y2) #ifdef NON_EQUIVALENT // viewport_main -//Alternative attempt: https://decomp.me/scratch/rcJYo +// Alternative attempt: https://decomp.me/scratch/rcJYo // Still a work-in-progress but it doesn't seem to cause any problems, // which is why it is labeled under NON_EQUIVALENT @@ -666,12 +655,9 @@ void func_80066CDC(Gfx **dlist, MatrixS **mats) { if (gScreenViewports[savedCameraID].flags & VIEWPORT_EXTRA_BG) { tempCameraID = gActiveCameraID; gActiveCameraID = savedCameraID; - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, - gScreenViewports[gActiveCameraID].scissorX1, - gScreenViewports[gActiveCameraID].scissorY1, - gScreenViewports[gActiveCameraID].scissorX2, - gScreenViewports[gActiveCameraID].scissorY2 - ); + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, gScreenViewports[gActiveCameraID].scissorX1, + gScreenViewports[gActiveCameraID].scissorY1, gScreenViewports[gActiveCameraID].scissorX2, + gScreenViewports[gActiveCameraID].scissorY2); viewport_rsp_set(dlist, 0, 0, 0, 0); gActiveCameraID = tempCameraID; if (mats != 0) { @@ -711,7 +697,8 @@ void func_80066CDC(Gfx **dlist, MatrixS **mats) { } else { posY = y; posY += videoHeight >> 2; - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, (y + (videoHeight >> 7)), videoWidth, (videoHeight - (videoHeight >> 7))); + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, (y + (videoHeight >> 7)), videoWidth, + (videoHeight - (videoHeight >> 7))); } posX = x; break; @@ -722,9 +709,10 @@ void func_80066CDC(Gfx **dlist, MatrixS **mats) { gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, x - (videoWidth >> 8), videoHeight); } else { posY = sp58_y; - //posX = x; + // posX = x; posX = x + (videoWidth >> 2); - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, x + (videoWidth >> 8), 0, videoWidth - (videoWidth >> 8), videoHeight); + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, x + (videoWidth >> 8), 0, videoWidth - (videoWidth >> 8), + videoHeight); } break; case VIEWPORTS_COUNT_4_PLAYERS: @@ -734,22 +722,26 @@ void func_80066CDC(Gfx **dlist, MatrixS **mats) { posX = 0; switch (gActiveCameraID) { case 0: - //Using posX and posY here is not smart since IDO can't optimize out the zero now. - //Why here of all places did they do this instead of just setting zero like everywhere else? - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, posX, posY, (x - (videoWidth >> 8)), (y - (videoHeight >> 7))); + // Using posX and posY here is not smart since IDO can't optimize out the zero now. + // Why here of all places did they do this instead of just setting zero like everywhere else? + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, posX, posY, (x - (videoWidth >> 8)), + (y - (videoHeight >> 7))); break; case 1: posX = x; - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, (sp54_x + (videoWidth >> 8)), 0, ((sp54_x + sp54_x) - (videoWidth >> 8)), (y - (videoHeight >> 7))); + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, (sp54_x + (videoWidth >> 8)), 0, + ((sp54_x + sp54_x) - (videoWidth >> 8)), (y - (videoHeight >> 7))); break; case 2: posY = y; - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, y + (videoHeight >> 7), x - (videoWidth >> 8), (y + y) - (videoHeight >> 7)); + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, y + (videoHeight >> 7), x - (videoWidth >> 8), + (y + y) - (videoHeight >> 7)); break; case 3: posY = y; posX = x; - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, (sp54_x + (videoWidth >> 8)), y + (videoHeight >> 7), (x + x) - (videoWidth >> 8), (y + y) - (videoHeight >> 7)); + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, (sp54_x + (videoWidth >> 8)), y + (videoHeight >> 7), + (x + x) - (videoWidth >> 8), (y + y) - (videoHeight >> 7)); break; } posY += sp58_y; @@ -785,7 +777,7 @@ GLOBAL_ASM("asm/non_matchings/camera/func_80066CDC.s") /** * Takes the size of the screen as depicted by the active menu viewport, then sets the RDP scissor to match it. * Official Name: camSetScissor -*/ + */ void viewport_scissor(Gfx **dlist) { s32 size; s32 lrx; @@ -811,59 +803,63 @@ void viewport_scissor(Gfx **dlist) { } lrx = ulx = 0; lry = uly = 0; + // clang-format off lrx += width;\ lry += height; + // clang-format on temp = lry >> 7; temp2 = lrx >> 8; temp4 = lrx >> 1; temp3 = lry >> 1; switch (numViewports) { - case 1: - switch (gActiveCameraID) { - case 0: - lry = temp3 - temp; - break; - default: - uly = temp3 + temp; - lry -= temp; - break; - } - break; - case 2: - switch (gActiveCameraID) { - case 0: - lrx = temp4 - temp2; - break; - default: - ulx = temp4 + temp2; - lrx -= temp2; - break; - } - break; - case 3: - switch (gActiveCameraID) { - case 0: - lrx = temp4 - temp2;\ - lry = temp3 - temp; - break; case 1: - ulx = temp4 + temp2; - lrx -= temp2; - lry = temp3 - temp; + switch (gActiveCameraID) { + case 0: + lry = temp3 - temp; + break; + default: + uly = temp3 + temp; + lry -= temp; + break; + } break; case 2: - uly = temp3 + temp; - lrx = temp4 - temp2;\ - lry -= temp; + switch (gActiveCameraID) { + case 0: + lrx = temp4 - temp2; + break; + default: + ulx = temp4 + temp2; + lrx -= temp2; + break; + } break; case 3: - ulx = temp4 + temp2; \ - uly = temp3 + temp; - lrx -= temp2; \ - lry -= temp; + // clang-format off + switch (gActiveCameraID) { + case 0: + lrx = temp4 - temp2;\ + lry = temp3 - temp; + break; + case 1: + ulx = temp4 + temp2; + lrx -= temp2; + lry = temp3 - temp; + break; + case 2: + uly = temp3 + temp; + lrx = temp4 - temp2;\ + lry -= temp; + break; + case 3: + ulx = temp4 + temp2;\ + uly = temp3 + temp; + lrx -= temp2;\ + lry -= temp; + break; + } + // clang-format on break; - } - break; } gDPSetScissor((*dlist)++, 0, ulx, uly, lrx, lry); return; @@ -871,7 +867,7 @@ void viewport_scissor(Gfx **dlist) { gDPSetScissor((*dlist)++, 0, 0, 0, width, height); } -//Official Name: camGetPlayerProjMtx / camSetProjMtx - ?? +// Official Name: camGetPlayerProjMtx / camSetProjMtx - ?? void func_80067D3C(Gfx **dlist, UNUSED MatrixS **mats) { s32 temp; @@ -883,7 +879,8 @@ void func_80067D3C(Gfx **dlist, UNUSED MatrixS **mats) { } gCameraTransform.y_rotation = 0x8000 + gCameraSegment[gActiveCameraID].trans.y_rotation; - gCameraTransform.x_rotation = gCameraSegment[gActiveCameraID].trans.x_rotation + gCameraSegment[gActiveCameraID].camera.unk38; + gCameraTransform.x_rotation = + gCameraSegment[gActiveCameraID].trans.x_rotation + gCameraSegment[gActiveCameraID].camera.unk38; gCameraTransform.z_rotation = gCameraSegment[gActiveCameraID].trans.z_rotation; gCameraTransform.x_position = -gCameraSegment[gActiveCameraID].trans.x_position; @@ -897,7 +894,8 @@ void func_80067D3C(Gfx **dlist, UNUSED MatrixS **mats) { f32_matrix_mult(&gCameraMatrixF, &gPerspectiveMatrixF, &gViewMatrixF); gCameraTransform.y_rotation = -0x8000 - gCameraSegment[gActiveCameraID].trans.y_rotation; - gCameraTransform.x_rotation = -(gCameraSegment[gActiveCameraID].trans.x_rotation + gCameraSegment[gActiveCameraID].camera.unk38); + gCameraTransform.x_rotation = + -(gCameraSegment[gActiveCameraID].trans.x_rotation + gCameraSegment[gActiveCameraID].camera.unk38); gCameraTransform.z_rotation = -gCameraSegment[gActiveCameraID].trans.z_rotation; gCameraTransform.scale = 1.0f; gCameraTransform.x_position = gCameraSegment[gActiveCameraID].trans.x_position; @@ -926,7 +924,7 @@ void set_ortho_matrix_height(f32 value) { * Sets the current matrix to represent an orthogonal view. * Used for drawing triangles on screen as HUD. * Official Name: camStandardOrtho -*/ + */ void set_ortho_matrix_view(Gfx **dlist, MatrixS **mtx) { u32 widthAndHeight; s32 width, height; @@ -947,18 +945,20 @@ void set_ortho_matrix_view(Gfx **dlist, MatrixS **mtx) { gMatrixType = G_MTX_DKR_INDEX_0; for (i = 0; i < 4; i++) { - //Required to be one line, but the "\" fixes that. - for (j = 0; j < 4; j++){ \ + // clang-format off + // Required to be one line, but the "\" fixes that. + for (j = 0; j < 4; j++) { \ gViewMatrixF[i][j] = gOrthoMatrixF[i][j]; } + // clang-format on } } -//Official Name: camStandardPersp? +// Official Name: camStandardPersp? void func_8006807C(Gfx **dlist, MatrixS **mtx) { object_transform_to_matrix_2(gCurrentModelMatrixF, &D_800DD288); f32_matrix_mult(&gCurrentModelMatrixF, &gPerspectiveMatrixF, &gViewMatrixF); - object_transform_to_matrix_2((float (*)[4]) gModelMatrixF[0], &D_800DD2A0); + object_transform_to_matrix_2((float(*)[4]) gModelMatrixF[0], &D_800DD2A0); f32_matrix_mult(gModelMatrixF[0], &gViewMatrixF, &gCurrentModelMatrixF); f32_matrix_to_s16_matrix(&gCurrentModelMatrixF, *mtx); gSPMatrix((*dlist)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); @@ -970,7 +970,7 @@ void func_8006807C(Gfx **dlist, MatrixS **mtx) { * Sets the RSP viewport onscreen to the given properties. * Viewports have a centre position and a scale factor, rather than a standard four corners. * Official Name: camSetViewport -*/ + */ void viewport_rsp_set(Gfx **dlist, s32 width, s32 height, s32 posX, s32 posY) { s32 tempWidth = (get_filtered_cheats() & CHEAT_MIRRORED_TRACKS) ? -width : width; // Antipiracy measure. Flips the screen upside down. @@ -993,7 +993,7 @@ void viewport_rsp_set(Gfx **dlist, s32 width, s32 height, s32 posX, s32 posY) { * Resets the viewport back to default. * If in the track menu, or post-race, set it to a small screen view instead. * Official Name: camResetView? -*/ + */ void viewport_reset(Gfx **dlist) { u32 widthAndHeight, width, height; gActiveCameraID = 4; @@ -1014,7 +1014,7 @@ void viewport_reset(Gfx **dlist) { * Sets the matrix position to the world origin (0, 0, 0) * Used when the next thing rendered relies on there not being any matrix offset. * Official Name: camOffsetZero? -*/ + */ void matrix_world_origin(Gfx **dlist, MatrixS **mtx) { f32_matrix_from_position(gModelMatrixF[gModelMatrixStackPos], 0.0f, 0.0f, 0.0f); f32_matrix_mult(gModelMatrixF[gModelMatrixStackPos], &gViewMatrixF, &gCurrentModelMatrixF); @@ -1030,7 +1030,8 @@ void func_80068508(s32 bool) { /** * Calculates angle from object to camera, then renders the sprite as a billboard, facing the camera. */ -s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Object *obj, unk80068514_arg4 *arg4, s32 flags) { +s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Object *obj, unk80068514_arg4 *arg4, + s32 flags) { f32 diffX; f32 diffY; Vertex *v; @@ -1086,7 +1087,8 @@ s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Obj gCameraTransform.z_position = obj->segment.trans.z_position; object_transform_to_matrix(gCurrentModelMatrixF, &gCameraTransform); gModelMatrixStackPos++; - f32_matrix_mult(&gCurrentModelMatrixF, gModelMatrixF[gModelMatrixStackPos-1], gModelMatrixF[gModelMatrixStackPos]); + f32_matrix_mult(&gCurrentModelMatrixF, gModelMatrixF[gModelMatrixStackPos - 1], + gModelMatrixF[gModelMatrixStackPos]); f32_matrix_mult(gModelMatrixF[gModelMatrixStackPos], &gViewMatrixF, &gCurrentModelMatrixF); f32_matrix_to_s16_matrix(&gCurrentModelMatrixF, *mtx); gModelMatrixS[gModelMatrixStackPos] = *mtx; @@ -1110,7 +1112,8 @@ s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Obj } textureFrame = obj->segment.animFrame; gModelMatrixStackPos++; - f32_matrix_from_rotation_and_scale((f32 (*)[4]) gModelMatrixF[gModelMatrixStackPos], angleDiff, obj->segment.trans.scale, gVideoAspectRatio); + f32_matrix_from_rotation_and_scale((f32(*)[4]) gModelMatrixF[gModelMatrixStackPos], angleDiff, + obj->segment.trans.scale, gVideoAspectRatio); f32_matrix_to_s16_matrix(gModelMatrixF[gModelMatrixStackPos], *mtx); gModelMatrixS[gModelMatrixStackPos] = *mtx; gSPMatrix((*dlist)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_DKR_INDEX_2); @@ -1123,7 +1126,8 @@ s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Obj if (flags & RENDER_SEMI_TRANSPARENT) { flags |= RENDER_ANTI_ALIASING; } - func_8007BF34(dlist, arg4->unk6 | (flags & (RENDER_FOG_ACTIVE | RENDER_SEMI_TRANSPARENT | RENDER_Z_COMPARE | RENDER_ANTI_ALIASING))); + func_8007BF34(dlist, arg4->unk6 | (flags & (RENDER_FOG_ACTIVE | RENDER_SEMI_TRANSPARENT | RENDER_Z_COMPARE | + RENDER_ANTI_ALIASING))); if (!(flags & RENDER_Z_UPDATE)) { gDPSetPrimColor((*dlist)++, 0, 0, 255, 255, 255, 255); } @@ -1140,9 +1144,11 @@ s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Obj } /** - * Sets transform and scale matrices to set position and size, loads the texture, sets the rendermodes, then draws the result onscreen. -*/ -void render_ortho_triangle_image(Gfx **dList, MatrixS **mtx, Vertex **vtx, ObjectSegment *segment, Sprite *sprite, s32 flags) { + * Sets transform and scale matrices to set position and size, loads the texture, sets the rendermodes, then draws the + * result onscreen. + */ +void render_ortho_triangle_image(Gfx **dList, MatrixS **mtx, Vertex **vtx, ObjectSegment *segment, Sprite *sprite, + s32 flags) { UNUSED s32 pad; f32 scale; s32 index; @@ -1162,7 +1168,7 @@ void render_ortho_triangle_image(Gfx **dList, MatrixS **mtx, Vertex **vtx, Objec gSPVertexDKR((*dList)++, OS_PHYSICAL_TO_K0(*vtx), 1, 0); (*vtx)++; // Can't be done in the macro? index = segment->animFrame; - gModelMatrixStackPos ++; + gModelMatrixStackPos++; gCameraTransform.y_rotation = -segment->trans.y_rotation; gCameraTransform.x_rotation = -segment->trans.x_rotation; gCameraTransform.z_rotation = gCameraSegment[gActiveCameraID].trans.z_rotation + segment->trans.z_rotation; @@ -1185,7 +1191,7 @@ void render_ortho_triangle_image(Gfx **dList, MatrixS **mtx, Vertex **vtx, Objec gSPMatrix((*dList)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_DKR_INDEX_2); gDkrEnableBillboard((*dList)++); if (D_80120D0C == FALSE) { - index = (((u8) index) * sprite->baseTextureId) >> 8; + index = (((u8) index) * sprite->baseTextureId) >> 8; } func_8007BF34(dList, sprite->unk6 | flags); if (index >= sprite->baseTextureId) { @@ -1205,7 +1211,7 @@ void render_ortho_triangle_image(Gfx **dList, MatrixS **mtx, Vertex **vtx, Objec /** * Generate a matrix with rotation, scaling and shearing and run it. * Used for wavy type effects like the shield. -*/ + */ void apply_object_shear_matrix(Gfx **dList, MatrixS **mtx, Object *arg2, Object *arg3, f32 shear) { UNUSED s32 pad; f32 cossf_x_arg2; @@ -1245,21 +1251,60 @@ void apply_object_shear_matrix(Gfx **dList, MatrixS **mtx, Object *arg2, Object arg3_zPos = arg3->segment.trans.z_position; arg2_scale = arg2->segment.trans.scale; shear *= arg2_scale; - matrix_mult[0][0] = ((((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3))) * cossf_y_arg2) + (-sinsf_y_arg2 * (cossf_x_arg3 * sinsf_y_arg3))) * arg2_scale; + matrix_mult[0][0] = + ((((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3))) * cossf_y_arg2) + + (-sinsf_y_arg2 * (cossf_x_arg3 * sinsf_y_arg3))) * + arg2_scale; matrix_mult[0][1] = (((sinsf_z_arg3 * cossf_x_arg3) * cossf_y_arg2) + (-sinsf_y_arg2 * -sinsf_x_arg3)) * arg2_scale; - matrix_mult[0][2] = ((((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3))) * cossf_y_arg2) + (-sinsf_y_arg2 * (cossf_x_arg3 * cossf_y_arg3))) * arg2_scale; + matrix_mult[0][2] = + ((((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3))) * cossf_y_arg2) + + (-sinsf_y_arg2 * (cossf_x_arg3 * cossf_y_arg3))) * + arg2_scale; matrix_mult[0][3] = 0.0f; - matrix_mult[1][0] = ((((-sinsf_z_arg3 * cossf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3))) * cossf_x_arg2) + (sinsf_x_arg2 * ((sinsf_y_arg2 * ((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + (cossf_y_arg2 * (cossf_x_arg3 * sinsf_y_arg3))))) * shear; - matrix_mult[1][1] = (((cossf_z_arg3 * cossf_x_arg3) * cossf_x_arg2) + (sinsf_x_arg2 * ((sinsf_y_arg2 * (sinsf_z_arg3 * cossf_x_arg3)) + (cossf_y_arg2 * -sinsf_x_arg3)))) * shear; - matrix_mult[1][2] = ((((-sinsf_z_arg3 * -sinsf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3))) * cossf_x_arg2) + (sinsf_x_arg2 * ((sinsf_y_arg2 * ((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + (cossf_y_arg2 * (cossf_x_arg3 * cossf_y_arg3))))) * shear; + matrix_mult[1][0] = + ((((-sinsf_z_arg3 * cossf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3))) * cossf_x_arg2) + + (sinsf_x_arg2 * + ((sinsf_y_arg2 * ((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + + (cossf_y_arg2 * (cossf_x_arg3 * sinsf_y_arg3))))) * + shear; + matrix_mult[1][1] = + (((cossf_z_arg3 * cossf_x_arg3) * cossf_x_arg2) + + (sinsf_x_arg2 * ((sinsf_y_arg2 * (sinsf_z_arg3 * cossf_x_arg3)) + (cossf_y_arg2 * -sinsf_x_arg3)))) * + shear; + matrix_mult[1][2] = + ((((-sinsf_z_arg3 * -sinsf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3))) * cossf_x_arg2) + + (sinsf_x_arg2 * + ((sinsf_y_arg2 * ((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + + (cossf_y_arg2 * (cossf_x_arg3 * cossf_y_arg3))))) * + shear; matrix_mult[1][3] = 0.0f; - matrix_mult[2][0] = ((-sinsf_x_arg2 * ((-sinsf_z_arg3 * cossf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + (cossf_x_arg2 * ((sinsf_y_arg2 * ((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + (cossf_y_arg2 * (cossf_x_arg3 * sinsf_y_arg3))))) * arg2_scale; - matrix_mult[2][1] = ((-sinsf_x_arg2 * (cossf_z_arg3 * cossf_x_arg3)) + (cossf_x_arg2 * ((sinsf_y_arg2 * (sinsf_z_arg3 * cossf_x_arg3)) + (cossf_y_arg2 * -sinsf_x_arg3)))) * arg2_scale; - matrix_mult[2][2] = ((-sinsf_x_arg2 * ((-sinsf_z_arg3 * -sinsf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + (cossf_x_arg2 * ((sinsf_y_arg2 * ((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + (cossf_y_arg2 * (cossf_x_arg3 * cossf_y_arg3))))) * arg2_scale; + matrix_mult[2][0] = + ((-sinsf_x_arg2 * ((-sinsf_z_arg3 * cossf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + + (cossf_x_arg2 * + ((sinsf_y_arg2 * ((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + + (cossf_y_arg2 * (cossf_x_arg3 * sinsf_y_arg3))))) * + arg2_scale; + matrix_mult[2][1] = + ((-sinsf_x_arg2 * (cossf_z_arg3 * cossf_x_arg3)) + + (cossf_x_arg2 * ((sinsf_y_arg2 * (sinsf_z_arg3 * cossf_x_arg3)) + (cossf_y_arg2 * -sinsf_x_arg3)))) * + arg2_scale; + matrix_mult[2][2] = + ((-sinsf_x_arg2 * ((-sinsf_z_arg3 * -sinsf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + + (cossf_x_arg2 * + ((sinsf_y_arg2 * ((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + + (cossf_y_arg2 * (cossf_x_arg3 * cossf_y_arg3))))) * + arg2_scale; matrix_mult[2][3] = 0.0f; - matrix_mult[3][0] = (((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3))) * arg2_xPos) + (arg2_yPos * ((-sinsf_z_arg3 * cossf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + (arg2_zPos * (cossf_x_arg3 * sinsf_y_arg3)) + arg3_xPos; - matrix_mult[3][1] = ((sinsf_z_arg3 * cossf_x_arg3) * arg2_xPos) + (arg2_yPos * (cossf_z_arg3 * cossf_x_arg3)) + (arg2_zPos * -sinsf_x_arg3) + arg3_yPos; - matrix_mult[3][2] = (((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3))) * arg2_xPos) + (arg2_yPos * ((-sinsf_z_arg3 * -sinsf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + (arg2_zPos * (cossf_x_arg3 * cossf_y_arg3)) + arg3_zPos; + matrix_mult[3][0] = + (((cossf_z_arg3 * cossf_y_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3))) * arg2_xPos) + + (arg2_yPos * ((-sinsf_z_arg3 * cossf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * sinsf_y_arg3)))) + + (arg2_zPos * (cossf_x_arg3 * sinsf_y_arg3)) + arg3_xPos; + matrix_mult[3][1] = ((sinsf_z_arg3 * cossf_x_arg3) * arg2_xPos) + (arg2_yPos * (cossf_z_arg3 * cossf_x_arg3)) + + (arg2_zPos * -sinsf_x_arg3) + arg3_yPos; + matrix_mult[3][2] = + (((-sinsf_y_arg3 * cossf_z_arg3) + (sinsf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3))) * arg2_xPos) + + (arg2_yPos * ((-sinsf_z_arg3 * -sinsf_y_arg3) + (cossf_z_arg3 * (sinsf_x_arg3 * cossf_y_arg3)))) + + (arg2_zPos * (cossf_x_arg3 * cossf_y_arg3)) + arg3_zPos; matrix_mult[3][3] = 1.0f; f32_matrix_mult(&matrix_mult, &gViewMatrixF, &gCurrentModelMatrixS); @@ -1269,7 +1314,7 @@ void apply_object_shear_matrix(Gfx **dList, MatrixS **mtx, Object *arg2, Object /** * Official Name: camPushModelMtx -*/ + */ void camera_push_model_mtx(Gfx **dList, MatrixS **mtx, ObjectTransform *trans, f32 scale, f32 scaleY) { f32 tempX; f32 tempY; @@ -1284,12 +1329,16 @@ void camera_push_model_mtx(Gfx **dList, MatrixS **mtx, ObjectTransform *trans, f if (scale != 1.0f) { f32_matrix_scale(&gCurrentModelMatrixF, scale); } - f32_matrix_mult(&gCurrentModelMatrixF, gModelMatrixF[gModelMatrixStackPos], gModelMatrixF[gModelMatrixStackPos + 1]); + f32_matrix_mult(&gCurrentModelMatrixF, gModelMatrixF[gModelMatrixStackPos], + gModelMatrixF[gModelMatrixStackPos + 1]); f32_matrix_mult(gModelMatrixF[gModelMatrixStackPos + 1], &gViewMatrixF, &gCurrentModelMatrixS); f32_matrix_to_s16_matrix(&gCurrentModelMatrixS, *mtx); gModelMatrixStackPos++; - gModelMatrixS[0, gModelMatrixStackPos] = *mtx; // Should be [gModelMatrixStackPos], but only matches with [0, gModelMatrixStackPos] - if (1) { } if (1) { } if (1) { }; // Fakematch + gModelMatrixS[0, gModelMatrixStackPos] = + *mtx; // Should be [gModelMatrixStackPos], but only matches with [0, gModelMatrixStackPos] + if (1) {} + if (1) {} + if (1) {}; // Fakematch gSPMatrix((*dList)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_DKR_INDEX_1); guMtxXFMF(*gModelMatrixF[gModelMatrixStackPos], 0.0f, 0.0f, 0.0f, &tempX, &tempY, &tempZ); index = gActiveCameraID; @@ -1322,7 +1371,7 @@ void camera_push_model_mtx(Gfx **dList, MatrixS **mtx, ObjectTransform *trans, f /** * Calculate the rotation matrix for an actors head, then run it. -*/ + */ void apply_head_turning_matrix(Gfx **dlist, MatrixS **mtx, Object_68 *objGfx, s16 headAngle) { f32 coss_headAngle; f32 sins_headAngle; @@ -1353,8 +1402,10 @@ void apply_head_turning_matrix(Gfx **dlist, MatrixS **mtx, Object_68 *objGfx, s1 headMtxF[2][1] = (sins_headAngle * sins_unk1C); headMtxF[2][2] = coss_headAngle; headMtxF[2][3] = 0.0f; - headMtxF[3][0] = (-f_unk16 * (coss_headAngle * coss_unk1C)) + (-f_unk18 * -sins_unk1C) + (-f_unk1A * (sins_headAngle * coss_unk1C)) + f_unk16; - headMtxF[3][1] = (-f_unk16 * (coss_headAngle * sins_unk1C)) + (-f_unk18 * coss_unk1C) + (-f_unk1A * (sins_headAngle * sins_unk1C)) + f_unk18; + headMtxF[3][0] = (-f_unk16 * (coss_headAngle * coss_unk1C)) + (-f_unk18 * -sins_unk1C) + + (-f_unk1A * (sins_headAngle * coss_unk1C)) + f_unk16; + headMtxF[3][1] = (-f_unk16 * (coss_headAngle * sins_unk1C)) + (-f_unk18 * coss_unk1C) + + (-f_unk1A * (sins_headAngle * sins_unk1C)) + f_unk18; headMtxF[3][2] = (-f_unk16 * -sins_headAngle) + (-f_unk1A * coss_headAngle) + f_unk1A; headMtxF[3][3] = 1.0f; f32_matrix_mult(&headMtxF, &gCurrentModelMatrixS, &rotationMtxF); @@ -1365,7 +1416,7 @@ void apply_head_turning_matrix(Gfx **dlist, MatrixS **mtx, Object_68 *objGfx, s1 /** * Writes the model matrix vector to the arguments. -*/ + */ UNUSED void get_modelmatrix_vector(f32 *x, f32 *y, f32 *z) { *x = gModelMatrixViewX[gCameraMatrixPos]; *y = gModelMatrixViewY[gCameraMatrixPos]; @@ -1375,12 +1426,15 @@ UNUSED void get_modelmatrix_vector(f32 *x, f32 *y, f32 *z) { /** * Run a matrix from the top of the stack and pop it. * If the stack pos is less than zero, add a matrix instead. -*/ + */ void apply_matrix_from_stack(Gfx **dlist) { gCameraMatrixPos--; gModelMatrixStackPos--; - { s32 temp = gCameraMatrixPos; if ((temp && temp) != 0){} } // Fakematch + { + s32 temp = gCameraMatrixPos; + if ((temp && temp) != 0) {} + } // Fakematch if (gModelMatrixStackPos > 0) { gSPMatrix((*dlist)++, OS_PHYSICAL_TO_K0(gModelMatrixS[gModelMatrixStackPos]), G_MTX_DKR_INDEX_1); @@ -1392,37 +1446,33 @@ void apply_matrix_from_stack(Gfx **dlist) { /** * Move the camera with the given velocities. * Also recalculates which block it's in. -*/ + */ UNUSED void translate_camera_segment(f32 x, f32 y, f32 z) { gCameraSegment[gActiveCameraID].trans.x_position += x; gCameraSegment[gActiveCameraID].trans.y_position += y; gCameraSegment[gActiveCameraID].trans.z_position += z; - gCameraSegment[gActiveCameraID].object.cameraSegmentID = - get_level_segment_index_from_position( - gCameraSegment[gActiveCameraID].trans.x_position, - gCameraSegment[gActiveCameraID].trans.y_position, - gCameraSegment[gActiveCameraID].trans.z_position); + gCameraSegment[gActiveCameraID].object.cameraSegmentID = get_level_segment_index_from_position( + gCameraSegment[gActiveCameraID].trans.x_position, gCameraSegment[gActiveCameraID].trans.y_position, + gCameraSegment[gActiveCameraID].trans.z_position); } /** * Move the camera with velocities accounting for face direction. * Also recalculates which block it's in. -*/ + */ UNUSED void transform_camera_segment(f32 x, UNUSED f32 y, f32 z) { gCameraSegment[gActiveCameraID].trans.x_position -= x * coss_f(gCameraSegment[gActiveCameraID].trans.y_rotation); gCameraSegment[gActiveCameraID].trans.z_position -= x * sins_f(gCameraSegment[gActiveCameraID].trans.y_rotation); gCameraSegment[gActiveCameraID].trans.x_position -= z * sins_f(gCameraSegment[gActiveCameraID].trans.y_rotation); gCameraSegment[gActiveCameraID].trans.z_position += z * coss_f(gCameraSegment[gActiveCameraID].trans.y_rotation); - gCameraSegment[gActiveCameraID].object.cameraSegmentID = - get_level_segment_index_from_position( - gCameraSegment[gActiveCameraID].trans.x_position, - gCameraSegment[gActiveCameraID].trans.y_position, - gCameraSegment[gActiveCameraID].trans.z_position); + gCameraSegment[gActiveCameraID].object.cameraSegmentID = get_level_segment_index_from_position( + gCameraSegment[gActiveCameraID].trans.x_position, gCameraSegment[gActiveCameraID].trans.y_position, + gCameraSegment[gActiveCameraID].trans.z_position); } /** * Rotate the camera with the given angles. -*/ + */ UNUSED void rotate_camera_segment(s32 angleX, s32 angleY, s32 angleZ) { gCameraSegment[gActiveCameraID].trans.y_rotation += angleX; gCameraSegment[gActiveCameraID].trans.x_rotation += angleY; @@ -1431,14 +1481,14 @@ UNUSED void rotate_camera_segment(s32 angleX, s32 angleY, s32 angleZ) { /** * Returns the segment data of the active camera, but won't apply the offset for cutscenes. -*/ + */ ObjectSegment *get_active_camera_segment_no_cutscenes(void) { return &gCameraSegment[gActiveCameraID]; } /** * Returns the segment data of the active camera. -*/ + */ ObjectSegment *get_active_camera_segment(void) { if (gCutsceneCameraActive) { return &gCameraSegment[gActiveCameraID + 4]; @@ -1449,7 +1499,7 @@ ObjectSegment *get_active_camera_segment(void) { /** * Returns the segment data of the active cutscene camera. * If no cutscene is active, return player 1's camera. -*/ + */ ObjectSegment *get_cutscene_camera_segment(void) { if (gCutsceneCameraActive) { return &gCameraSegment[4]; @@ -1459,28 +1509,28 @@ ObjectSegment *get_cutscene_camera_segment(void) { /** * Return the current floating point projection matrix. -*/ + */ Matrix *get_projection_matrix_f32(void) { return &gProjectionMatrixF; } /** * Return the current fixed point projection matrix. -*/ + */ MatrixS *get_projection_matrix_s16(void) { return &gProjectionMatrixS; } /** * Return the current camera matrix. -*/ + */ Matrix *get_camera_matrix(void) { return &gCameraMatrixF; } /** * Return the screenspace distance to the camera. -*/ + */ f32 get_distance_to_camera(f32 x, f32 y, f32 z) { f32 ox, oy, oz; @@ -1491,7 +1541,7 @@ f32 get_distance_to_camera(f32 x, f32 y, f32 z) { /** * Apply a shake to the camera based on the distance to the source. -*/ + */ void set_camera_shake_by_distance(f32 x, f32 y, f32 z, f32 dist, f32 magnitude) { f32 diffX; f32 distance; @@ -1512,7 +1562,7 @@ void set_camera_shake_by_distance(f32 x, f32 y, f32 z, f32 dist, f32 magnitude) /** * Apply a shake to all active cameras. -*/ + */ void set_camera_shake(f32 magnitude) { s32 i; for (i = 0; i <= gNumberOfViewports; i++) { @@ -1532,10 +1582,10 @@ UNUSED void debug_print_fixed_matrix_values(s16 *mtx) { val = mtx[i * 4 + j]; rmonPrintf("%x.", val); val = mtx[((i + 4) * 4 + j)]; - rmonPrintf("%x ", (u16)val & 0xFFFF); + rmonPrintf("%x ", (u16) val & 0xFFFF); } rmonPrintf("\n"); - if (!val){} // Fakematch + if (!val) {} // Fakematch } rmonPrintf("\n"); } diff --git a/src/camera.h b/src/camera.h index 1577152c..958ac40f 100644 --- a/src/camera.h +++ b/src/camera.h @@ -79,8 +79,8 @@ typedef struct unk80068514_arg4 { Gfx *unk8[1]; } unk80068514_arg4; -void func_80066060(s32 arg0, s32 arg1); -void set_viewport_tv_type(s8 arg0); +void func_80066060(s32 cameraID, s32 zoomLevel); +void set_viewport_tv_type(s8 setting); void func_800660C0(void); void func_800660D0(void); UNUSED f32 get_current_camera_fov(void); @@ -88,28 +88,28 @@ void update_camera_fov(f32 camFieldOfView); Matrix *matrix_get_model_s16(void); s32 get_viewport_count(void); s32 get_current_viewport(void); -void camera_init_tracks_menu(Gfx **dlist, MatrixS **arg1); +void camera_init_tracks_menu(Gfx **dList, MatrixS **mtxS); f32 get_distance_to_active_camera(f32 xPos, f32 yPos, f32 zPos); -void camera_reset(s32 xPos, s32 yPos, s32 zPos, s32 arg3, s32 arg4, s32 arg5); -void write_to_object_render_stack(s32 arg0, f32 xPos, f32 yPos, f32 zPos, s16 arg4, s16 arg5, s16 arg6); +void camera_reset(s32 xPos, s32 yPos, s32 zPos, s32 angleZ, s32 angleX, s32 angleY); +void write_to_object_render_stack(s32 stackPos, f32 xPos, f32 yPos, f32 zPos, s16 arg4, s16 arg5, s16 arg6); void disable_cutscene_camera(void); s8 check_if_showing_cutscene_camera(void); s32 set_active_viewports_and_max(s32 num); -void set_active_camera(s32 arg0); +void set_active_camera(s32 num); void camEnableUserView(s32 viewPortIndex, s32 arg1); void camDisableUserView(s32 viewPortIndex, s32 arg1); s32 check_viewport_background_flag(s32 viewPortIndex); void viewport_menu_set(s32 viewPortIndex, s32 x1, s32 y1, s32 x2, s32 y2); -void set_viewport_properties(s32 viewPortIndex, s32 x1, s32 x2, s32 y1, s32 y2); +void set_viewport_properties(s32 viewPortIndex, s32 posX, s32 posY, s32 width, s32 height); s32 copy_viewport_background_size_to_coords(s32 viewPortIndex, s32 *x1, s32 *y1, s32 *x2, s32 *y2); void copy_viewport_frame_size_to_coords(s32 viewPortIndex, s32 *x1, s32 *y1, s32 *x2, s32 *y2); void copy_framebuffer_size_to_coords(s32 *x1, s32 *y1, s32 *x2, s32 *y2); void set_ortho_matrix_height(f32 value); -void set_ortho_matrix_view(Gfx **dlist, MatrixS **mats); -void func_8006807C(Gfx **dlist, MatrixS **mats); -void viewport_rsp_set(Gfx **dlist, s32 arg1, s32 arg2, s32 arg3, s32 arg4); +void set_ortho_matrix_view(Gfx **dlist, MatrixS **mtx); +void func_8006807C(Gfx **dlist, MatrixS **mtx); +void viewport_rsp_set(Gfx **dlist, s32 width, s32 height, s32 posX, s32 posY); void viewport_reset(Gfx **dlist); -void matrix_world_origin(Gfx **dlist, MatrixS **mats); +void matrix_world_origin(Gfx **dlist, MatrixS **mtx); void func_80068508(s32 bool); ObjectSegment *get_active_camera_segment_no_cutscenes(void); ObjectSegment *get_active_camera_segment(void); @@ -123,12 +123,12 @@ void set_camera_shake(f32 magnitude); void func_80067D3C(Gfx **dlist, MatrixS **mats); void render_ortho_triangle_image(Gfx **dList, MatrixS **mtx, Vertex **vtx, ObjectSegment *segment, Sprite *sprite, s32 flags); s32 render_sprite_billboard(Gfx **dlist, MatrixS **mtx, Vertex **vertexList, Object *obj, unk80068514_arg4 *arg4, s32 flags); -void camera_push_model_mtx(Gfx **arg0, MatrixS **arg1, ObjectTransform *arg2, f32 scale, f32 scaleY); +void camera_push_model_mtx(Gfx **dList, MatrixS **mtx, ObjectTransform *trans, f32 scale, f32 scaleY); void viewport_scissor(Gfx **dlist); void apply_matrix_from_stack(Gfx **dlist); void copy_viewports_to_stack(void); -void apply_head_turning_matrix(Gfx **dlist, MatrixS **mtx, Object_68 *obj68, s16 headAngle); -void apply_object_shear_matrix(Gfx **dlist, MatrixS **mtx, Object *arg2, Object *arg3, f32 shear); +void apply_head_turning_matrix(Gfx **dlist, MatrixS **mtx, Object_68 *objGfx, s16 headAngle); +void apply_object_shear_matrix(Gfx **dList, MatrixS **mtx, Object *arg2, Object *arg3, f32 shear); // Non Matching void camera_init(void); diff --git a/src/collision.c b/src/collision.c index c9cb6fb3..05457f70 100644 --- a/src/collision.c +++ b/src/collision.c @@ -15,42 +15,51 @@ GLOBAL_ASM("asm/collision/func_80031130.s") // Might be segment related. #ifdef NON_EQUIVALENT -s32 func_800314DC(LevelModelSegmentBoundingBox *a0, s32 a1, s32 a2, s32 a3, s32 t5) { +s32 func_800314DC(LevelModelSegmentBoundingBox *segment, s32 x1, s32 z1, s32 x2, s32 z2) { s32 v0 = 0; s32 v1; s32 t0, t1, t2, t3, t4; - if (a0 == NULL) + if (segment == NULL) { return v0; + } - t0 = a0->x1; - t1 = a0->z1; - t2 = a0->x2; - t3 = a0->z2; + t0 = segment->x1; + t1 = segment->z1; + t2 = segment->x2; + t3 = segment->z2; - if (a3 < t0) - a3 = t0; + if (x2 < t0) { + x2 = t0; + } - if (a1 < t0) - a1 = t0; + if (x1 < t0) { + x1 = t0; + } - if (t5 < t1) - t5 = t1; + if (z2 < t1) { + z2 = t1; + } - if (a2 < t1) - a2 = t1; + if (z1 < t1) { + z1 = t1; + } - if (t2 < a3) - a3 = t2; + if (t2 < x2) { + x2 = t2; + } - if (t2 < a1) - a1 = t2; + if (t2 < x1) { + x1 = t2; + } - if (t3 < t5) - t5 = t3; + if (t3 < z2) { + z2 = t3; + } - if (t3 < a2) - a2 = t3; + if (t3 < z1) { + z1 = t3; + } v1 = 1; @@ -58,8 +67,9 @@ s32 func_800314DC(LevelModelSegmentBoundingBox *a0, s32 a1, s32 a2, s32 a3, s32 t4 = t2 + t0; while (v1 < (1 << 8)) { - if (t4 >= a1 && a3 >= t0) + if (t4 >= x1 && x2 >= t0) { v0 |= v1; + } v1 <<= 1; t4 += t2; @@ -70,8 +80,9 @@ s32 func_800314DC(LevelModelSegmentBoundingBox *a0, s32 a1, s32 a2, s32 a3, s32 t4 = t2 + t1; while (v1 < (1 << 16)) { - if (t4 >= a2 && t5 >= t1) + if (t4 >= z1 && z2 >= t1) { v0 |= v1; + } v1 <<= 1; t4 += t2; diff --git a/src/controller.c b/src/controller.c index f0c15baf..82e67db4 100644 --- a/src/controller.c +++ b/src/controller.c @@ -4,8 +4,9 @@ #include "controller.h" #include "game.h" -s32 sNoControllerPluggedIn = FALSE; // Looks to be a boolean for whether a controller is plugged in. FALSE if plugged in, and TRUE if not. -u16 gButtonMask = 0xFFFF; //Used when anti-cheat/anti-tamper has failed in init_level_globals() +s32 sNoControllerPluggedIn = + FALSE; // Looks to be a boolean for whether a controller is plugged in. FALSE if plugged in, and TRUE if not. +u16 gButtonMask = 0xFFFF; // Used when anti-cheat/anti-tamper has failed in init_level_globals() OSMesgQueue sSIMesgQueue; OSMesg sSIMesgBuf; @@ -65,7 +66,7 @@ s32 handle_save_data_and_read_controller(s32 saveDataFlags, s32 updateRate) { s32 i; if (osRecvMesg(&sSIMesgQueue, &unusedMsg, OS_MESG_NOBLOCK) == 0) { - //Back up old controller data + // Back up old controller data for (i = 0; i < MAXCONTROLLERS; i++) { gControllerPrevData[i] = gControllerCurrData[i]; } @@ -101,7 +102,7 @@ s32 handle_save_data_and_read_controller(s32 saveDataFlags, s32 updateRate) { if (saveDataFlags & SAVE_DATA_FLAG_WRITE_EEPROM_SETTINGS) { write_eeprom_settings(get_eeprom_settings_pointer()); } - //Reset all flags + // Reset all flags saveDataFlags = 0; } rumble_controllers(updateRate); @@ -111,9 +112,14 @@ s32 handle_save_data_and_read_controller(s32 saveDataFlags, s32 updateRate) { if (sNoControllerPluggedIn) { gControllerCurrData[i].button = 0; } - //XOR the diff between the last read of the controller data with the current read to see what buttons have been pushed and released. - gControllerButtonsPressed[i] = ((gControllerCurrData[i].button ^ gControllerPrevData[i].button) & gControllerCurrData[i].button) & gButtonMask; - gControllerButtonsReleased[i] = ((gControllerCurrData[i].button ^ gControllerPrevData[i].button) & gControllerPrevData[i].button) & gButtonMask; + // XOR the diff between the last read of the controller data with the current read to see what buttons have been + // pushed and released. + gControllerButtonsPressed[i] = + ((gControllerCurrData[i].button ^ gControllerPrevData[i].button) & gControllerCurrData[i].button) & + gButtonMask; + gControllerButtonsReleased[i] = + ((gControllerCurrData[i].button ^ gControllerPrevData[i].button) & gControllerPrevData[i].button) & + gButtonMask; } return saveDataFlags; } diff --git a/src/fade_transition.c b/src/fade_transition.c index 5f3de28c..4f963fc2 100644 --- a/src/fade_transition.c +++ b/src/fade_transition.c @@ -42,33 +42,25 @@ Gfx dTransitionFadeSettings[] = { }; s16 gTransitionBarnHorizontalData[28] = { - 0xFE20, 0x0078, 0xFEC0, 0x0078, 0xFF60, 0x0078, 0x0000, 0x0078, - 0x00A0, 0x0078, 0x0140, 0x0078, 0x01E0, 0x0078, 0xFE20, 0xFF88, - 0xFEC0, 0xFF88, 0xFF60, 0xFF88, 0x0000, 0xFF88, 0x00A0, 0xFF88, - 0x0140, 0xFF88, 0x01E0, 0xFF88, + 0xFE20, 0x0078, 0xFEC0, 0x0078, 0xFF60, 0x0078, 0x0000, 0x0078, 0x00A0, 0x0078, 0x0140, 0x0078, 0x01E0, 0x0078, + 0xFE20, 0xFF88, 0xFEC0, 0xFF88, 0xFF60, 0xFF88, 0x0000, 0xFF88, 0x00A0, 0xFF88, 0x0140, 0xFF88, 0x01E0, 0xFF88, }; s16 gTransitionBarnVerticalData[28] = { - 0xFF60, 0x0168, 0xFF60, 0x00F0, 0xFF60, 0x0078, 0xFF60, 0x0000, - 0xFF60, 0xFF88, 0xFF60, 0xFF10, 0xFF60, 0xFF10, 0x00A0, 0x0168, - 0x00A0, 0x00F0, 0x00A0, 0x0078, 0x00A0, 0x0000, 0x00A0, 0xFF88, - 0x00A0, 0xFF10, 0x00A0, 0xFF10, + 0xFF60, 0x0168, 0xFF60, 0x00F0, 0xFF60, 0x0078, 0xFF60, 0x0000, 0xFF60, 0xFF88, 0xFF60, 0xFF10, 0xFF60, 0xFF10, + 0x00A0, 0x0168, 0x00A0, 0x00F0, 0x00A0, 0x0078, 0x00A0, 0x0000, 0x00A0, 0xFF88, 0x00A0, 0xFF10, 0x00A0, 0xFF10, }; u8 D_800E32A0[12] = { - 0x00, 0x02, 0x04, 0x0E, 0x10, 0x12, 0x08, 0x0A, - 0x0C, 0x16, 0x18, 0x1A, + 0x00, 0x02, 0x04, 0x0E, 0x10, 0x12, 0x08, 0x0A, 0x0C, 0x16, 0x18, 0x1A, }; u8 D_800E32AC[12] = { - 0x04, 0x06, 0x08, 0x12, 0x14, 0x16, 0x04, 0x06, - 0x08, 0x12, 0x14, 0x16, + 0x04, 0x06, 0x08, 0x12, 0x14, 0x16, 0x04, 0x06, 0x08, 0x12, 0x14, 0x16, }; TriangleList gTransitionBarnDoorTris[24] = { - 0, 3, 1, 1, 3, 4, 1, 4, - 2, 2, 4, 5, 6, 9, 7, 7, - 9, 10, 7, 10, 8, 8, 10, 11, + 0, 3, 1, 1, 3, 4, 1, 4, 2, 2, 4, 5, 6, 9, 7, 7, 9, 10, 7, 10, 8, 8, 10, 11, }; u8 gTransitionBarnDoorAlpha[12] = { @@ -76,9 +68,8 @@ u8 gTransitionBarnDoorAlpha[12] = { }; s16 gTransitionBarnDiagData[24] = { - 0xFCE0, 0x0078, 0xFE20, 0x0078, 0xFF60, 0x0078, 0x00A0, 0x0078, - 0x01E0, 0x0078, 0x0320, 0x0078, 0xFCE0, 0xFF88, 0xFE20, 0xFF88, - 0xFF60, 0xFF88, 0x00A0, 0xFF88, 0x01E0, 0xFF88, 0x0320, 0xFF88, + 0xFCE0, 0x0078, 0xFE20, 0x0078, 0xFF60, 0x0078, 0x00A0, 0x0078, 0x01E0, 0x0078, 0x0320, 0x0078, + 0xFCE0, 0xFF88, 0xFE20, 0xFF88, 0xFF60, 0xFF88, 0x00A0, 0xFF88, 0x01E0, 0xFF88, 0x0320, 0xFF88, }; u8 D_800E330C[12] = { @@ -98,80 +89,50 @@ u8 gTransitionBarnDoorDiagAlpha[12] = { }; s16 gTransitionWaveData[126] = { - 0xFF60, 0x00A0, 0xFF70, 0x00A0, 0xFF80, 0x00A0, 0xFF90, 0x00A0, - 0xFFA0, 0x00A0, 0xFFB0, 0x00A0, 0xFFC0, 0x00A0, 0xFFD0, 0x00A0, - 0xFFE0, 0x00A0, 0xFFF0, 0x00A0, 0x0000, 0x00A0, 0x0010, 0x00A0, - 0x0020, 0x00A0, 0x0030, 0x00A0, 0x0040, 0x00A0, 0x0050, 0x00A0, - 0x0060, 0x00A0, 0x0070, 0x00A0, 0x0080, 0x00A0, 0x0090, 0x00A0, - 0x00A0, 0x00A0, 0xFF60, 0xFF38, 0xFF70, 0xFF60, 0xFF80, 0xFF74, - 0xFF90, 0xFF7E, 0xFFA0, 0xFF74, 0xFFB0, 0xFF38, 0xFFC0, 0xFF10, - 0xFFD0, 0xFEFC, 0xFFE0, 0xFEF2, 0xFFF0, 0xFEFC, 0x0000, 0xFF24, - 0x0010, 0xFF2E, 0x0020, 0xFF38, 0x0030, 0xFF2E, 0x0040, 0xFF24, - 0x0050, 0xFEFC, 0x0060, 0xFEF2, 0x0070, 0xFEFC, 0x0080, 0xFF24, - 0x0090, 0xFF60, 0x00A0, 0xFF74, 0xFF60, 0xFEE8, 0xFF70, 0xFEE8, - 0xFF80, 0xFEE8, 0xFF90, 0xFEE8, 0xFFA0, 0xFEE8, 0xFFB0, 0xFEE8, - 0xFFC0, 0xFEE8, 0xFFD0, 0xFEE8, 0xFFE0, 0xFEE8, 0xFFF0, 0xFEE8, - 0x0000, 0xFEE8, 0x0010, 0xFEE8, 0x0020, 0xFEE8, 0x0030, 0xFEE8, - 0x0040, 0xFEE8, 0x0050, 0xFEE8, 0x0060, 0xFEE8, 0x0070, 0xFEE8, - 0x0080, 0xFEE8, 0x0090, 0xFEE8, 0x00A0, 0xFEE8, + 0xFF60, 0x00A0, 0xFF70, 0x00A0, 0xFF80, 0x00A0, 0xFF90, 0x00A0, 0xFFA0, 0x00A0, 0xFFB0, 0x00A0, 0xFFC0, 0x00A0, + 0xFFD0, 0x00A0, 0xFFE0, 0x00A0, 0xFFF0, 0x00A0, 0x0000, 0x00A0, 0x0010, 0x00A0, 0x0020, 0x00A0, 0x0030, 0x00A0, + 0x0040, 0x00A0, 0x0050, 0x00A0, 0x0060, 0x00A0, 0x0070, 0x00A0, 0x0080, 0x00A0, 0x0090, 0x00A0, 0x00A0, 0x00A0, + 0xFF60, 0xFF38, 0xFF70, 0xFF60, 0xFF80, 0xFF74, 0xFF90, 0xFF7E, 0xFFA0, 0xFF74, 0xFFB0, 0xFF38, 0xFFC0, 0xFF10, + 0xFFD0, 0xFEFC, 0xFFE0, 0xFEF2, 0xFFF0, 0xFEFC, 0x0000, 0xFF24, 0x0010, 0xFF2E, 0x0020, 0xFF38, 0x0030, 0xFF2E, + 0x0040, 0xFF24, 0x0050, 0xFEFC, 0x0060, 0xFEF2, 0x0070, 0xFEFC, 0x0080, 0xFF24, 0x0090, 0xFF60, 0x00A0, 0xFF74, + 0xFF60, 0xFEE8, 0xFF70, 0xFEE8, 0xFF80, 0xFEE8, 0xFF90, 0xFEE8, 0xFFA0, 0xFEE8, 0xFFB0, 0xFEE8, 0xFFC0, 0xFEE8, + 0xFFD0, 0xFEE8, 0xFFE0, 0xFEE8, 0xFFF0, 0xFEE8, 0x0000, 0xFEE8, 0x0010, 0xFEE8, 0x0020, 0xFEE8, 0x0030, 0xFEE8, + 0x0040, 0xFEE8, 0x0050, 0xFEE8, 0x0060, 0xFEE8, 0x0070, 0xFEE8, 0x0080, 0xFEE8, 0x0090, 0xFEE8, 0x00A0, 0xFEE8, }; u8 D_800E3440[92] = { - 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, - 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, - 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x0E, - 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1A, 0x1C, - 0x1E, 0x20, 0x22, 0x24, 0x26, 0x28, 0x1A, 0x1C, - 0x1E, 0x20, 0x22, 0x24, 0x26, 0x28, 0x00, 0x02, - 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x54, 0x56, - 0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62, 0x0E, 0x10, - 0x12, 0x14, 0x16, 0x18, 0x1A, 0x62, 0x64, 0x66, - 0x68, 0x6A, 0x6C, 0x6E, 0x1A, 0x1C, 0x1E, 0x20, - 0x22, 0x24, 0x26, 0x28, 0x6E, 0x70, 0x72, 0x74, - 0x76, 0x78, 0x7A, 0x7C, + 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x0E, 0x10, 0x12, + 0x14, 0x16, 0x18, 0x1A, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24, 0x26, 0x28, + 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24, 0x26, 0x28, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, 0x54, 0x56, 0x58, + 0x5A, 0x5C, 0x5E, 0x60, 0x62, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x62, 0x64, 0x66, 0x68, 0x6A, 0x6C, 0x6E, + 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24, 0x26, 0x28, 0x6E, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, }; u8 D_800E349C[92] = { - 0x2A, 0x2C, 0x2E, 0x30, 0x32, 0x34, 0x36, 0x38, - 0x54, 0x56, 0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62, - 0x38, 0x3A, 0x3C, 0x3E, 0x40, 0x42, 0x44, 0x62, - 0x64, 0x66, 0x68, 0x6A, 0x6C, 0x6E, 0x44, 0x46, - 0x48, 0x4A, 0x4C, 0x4E, 0x50, 0x52, 0x6E, 0x70, - 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, 0x54, 0x56, - 0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62, 0x54, 0x56, - 0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62, 0x62, 0x64, - 0x66, 0x68, 0x6A, 0x6C, 0x6E, 0x62, 0x64, 0x66, - 0x68, 0x6A, 0x6C, 0x6E, 0x6E, 0x70, 0x72, 0x74, - 0x76, 0x78, 0x7A, 0x7C, 0x6E, 0x70, 0x72, 0x74, - 0x76, 0x78, 0x7A, 0x7C, + 0x2A, 0x2C, 0x2E, 0x30, 0x32, 0x34, 0x36, 0x38, 0x54, 0x56, 0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62, 0x38, 0x3A, 0x3C, + 0x3E, 0x40, 0x42, 0x44, 0x62, 0x64, 0x66, 0x68, 0x6A, 0x6C, 0x6E, 0x44, 0x46, 0x48, 0x4A, 0x4C, 0x4E, 0x50, 0x52, + 0x6E, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, 0x54, 0x56, 0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62, 0x54, 0x56, 0x58, + 0x5A, 0x5C, 0x5E, 0x60, 0x62, 0x62, 0x64, 0x66, 0x68, 0x6A, 0x6C, 0x6E, 0x62, 0x64, 0x66, 0x68, 0x6A, 0x6C, 0x6E, + 0x6E, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, 0x6E, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, }; u8 gTransitionWaveAlpha[92] = { - 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, - 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, - 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, + 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, }; TriangleList gTransitionWaveTris[244] = { - 0, 8, 9, 0, 9, 1, 1, 9, 10, 1, 10, 2, 2, 10, 11, 2, - 11, 3, 3, 11, 12, 3, 12, 4, 4, 12, 13, 4, 13, 5, 5, 13, - 14, 5, 14, 6, 6, 14, 15, 6, 15, 7, 0, 7, 8, 0, 8, 1, - 1, 8, 9, 1, 9, 2, 2, 9, 10, 2, 10, 3, 3, 10, 11, 3, - 11, 4, 4, 11, 12, 4, 12, 5, 5, 12, 13, 5, 13, 6, 0, 8, - 9, 0, 9, 1, 1, 9, 10, 1, 10, 2, 2, 10, 11, 2, 11, 3, - 3, 11, 12, 3, 12, 4, 4, 12, 13, 4, 13, 5, 5, 13, 14, 5, - 14, 6, 6, 14, 15, 6, 15, 7, 0, 8, 9, 0, 9, 1, 1, 9, - 10, 1, 10, 2, 2, 10, 11, 2, 11, 3, 3, 11, 12, 3, 12, 4, - 4, 12, 13, 4, 13, 5, 5, 13, 14, 5, 14, 6, 6, 14, 15, 6, - 15, 7, 0, 7, 8, 0, 8, 1, 1, 8, 9, 1, 9, 2, 2, 9, - 10, 2, 10, 3, 3, 10, 11, 3, 11, 4, 4, 11, 12, 4, 12, 5, - 5, 12, 13, 5, 13, 6, 0, 8, 9, 0, 9, 1, 1, 9, 10, 1, - 10, 2, 2, 10, 11, 2, 11, 3, 3, 11, 12, 3, 12, 4, 4, 12, - 13, 4, 13, 5, 5, 13, 14, 5, 14, 6, 6, 14, 15, 6, 15, 7, - 0, 0, 0, 0, + 0, 8, 9, 0, 9, 1, 1, 9, 10, 1, 10, 2, 2, 10, 11, 2, 11, 3, 3, 11, 12, 3, 12, 4, 4, 12, 13, 4, + 13, 5, 5, 13, 14, 5, 14, 6, 6, 14, 15, 6, 15, 7, 0, 7, 8, 0, 8, 1, 1, 8, 9, 1, 9, 2, 2, 9, + 10, 2, 10, 3, 3, 10, 11, 3, 11, 4, 4, 11, 12, 4, 12, 5, 5, 12, 13, 5, 13, 6, 0, 8, 9, 0, 9, 1, + 1, 9, 10, 1, 10, 2, 2, 10, 11, 2, 11, 3, 3, 11, 12, 3, 12, 4, 4, 12, 13, 4, 13, 5, 5, 13, 14, 5, + 14, 6, 6, 14, 15, 6, 15, 7, 0, 8, 9, 0, 9, 1, 1, 9, 10, 1, 10, 2, 2, 10, 11, 2, 11, 3, 3, 11, + 12, 3, 12, 4, 4, 12, 13, 4, 13, 5, 5, 13, 14, 5, 14, 6, 6, 14, 15, 6, 15, 7, 0, 7, 8, 0, 8, 1, + 1, 8, 9, 1, 9, 2, 2, 9, 10, 2, 10, 3, 3, 10, 11, 3, 11, 4, 4, 11, 12, 4, 12, 5, 5, 12, 13, 5, + 13, 6, 0, 8, 9, 0, 9, 1, 1, 9, 10, 1, 10, 2, 2, 10, 11, 2, 11, 3, 3, 11, 12, 3, 12, 4, 4, 12, + 13, 4, 13, 5, 5, 13, 14, 5, 14, 6, 6, 14, 15, 6, 15, 7, 0, 0, 0, 0, }; Gfx dTransitionShapeSettings[] = { @@ -214,21 +175,21 @@ s32 gTransitionVertexCount; /** * Set the value indicating that a new screen transition can be started. -*/ + */ void enable_new_screen_transitions(void) { gTransitionsDisabled = TRUE; } /** * Set the value indicating new transitions will not be created. -*/ + */ void disable_new_screen_transitions(void) { gTransitionsDisabled = FALSE; } /** * Checks if there is currently a fadeout transition playing. -*/ + */ u32 check_fadeout_transition(void) { u32 isActive = sTransitionFadeTimer != 0; if (isActive == FALSE) { @@ -237,12 +198,12 @@ u32 check_fadeout_transition(void) { return (gTransitionFadeIn != 0); } } -//!@bug: This doesn't seem to guarantee a return. + //!@bug: This doesn't seem to guarantee a return. } /** * Reset the state then initialise the transition states based on the current transition data. -*/ + */ s32 transition_begin(FadeTransition *transition) { if (gTransitionsDisabled) { return 0; @@ -259,7 +220,7 @@ s32 transition_begin(FadeTransition *transition) { gTransitionInvert = transition->type & FADE_FLAG_INVERT; sLevelTransitionDelayTimer = 0; if (!gTransitionFadeIn && !sLevelTransitionDelayTimer) { - sLevelTransitionDelayTimer = 2; + sLevelTransitionDelayTimer = 2; } if (sTransitionFadeTimer > 0) { gLastFadeRed = gCurFadeRed; @@ -269,27 +230,32 @@ s32 transition_begin(FadeTransition *transition) { gCurFadeGreen = transition->green; gCurFadeBlue = transition->blue; switch (gCurFadeTransition) { - case FADE_FULLSCREEN: - transition_fullscreen_start(transition); - break; - case FADE_BARNDOOR_HORIZONTAL: - init_transition_shape(transition, 12, 8, gTransitionBarnHorizontalData, D_800E32A0, D_800E32AC, gTransitionBarnDoorAlpha, gTransitionBarnDoorAlpha, gTransitionBarnDoorTris); - break; - case FADE_BARNDOOR_VERTICAL: - init_transition_shape(transition, 12, 8, gTransitionBarnVerticalData, D_800E32A0, D_800E32AC, gTransitionBarnDoorAlpha, gTransitionBarnDoorAlpha, gTransitionBarnDoorTris); - break; - case FADE_CIRCLE: - func_800C15D4(transition); - break; - case FADE_WAVES: - init_transition_shape(transition, 92, 80, gTransitionWaveData, D_800E349C, D_800E3440, gTransitionWaveAlpha, gTransitionWaveAlpha, gTransitionWaveTris); - break; - case FADE_BARNDOOR_DIAGONAL: - init_transition_shape(transition, 10, 6, gTransitionBarnDiagData, D_800E330C, D_800E3318, gTransitionBarnDoorDiagAlpha, gTransitionBarnDoorDiagAlpha, gTransitionBarnDoorDiagTris); - break; - case FADE_DISABLED: - init_transition_blank(transition); - break; + case FADE_FULLSCREEN: + transition_fullscreen_start(transition); + break; + case FADE_BARNDOOR_HORIZONTAL: + init_transition_shape(transition, 12, 8, gTransitionBarnHorizontalData, D_800E32A0, D_800E32AC, + gTransitionBarnDoorAlpha, gTransitionBarnDoorAlpha, gTransitionBarnDoorTris); + break; + case FADE_BARNDOOR_VERTICAL: + init_transition_shape(transition, 12, 8, gTransitionBarnVerticalData, D_800E32A0, D_800E32AC, + gTransitionBarnDoorAlpha, gTransitionBarnDoorAlpha, gTransitionBarnDoorTris); + break; + case FADE_CIRCLE: + func_800C15D4(transition); + break; + case FADE_WAVES: + init_transition_shape(transition, 92, 80, gTransitionWaveData, D_800E349C, D_800E3440, + gTransitionWaveAlpha, gTransitionWaveAlpha, gTransitionWaveTris); + break; + case FADE_BARNDOOR_DIAGONAL: + init_transition_shape(transition, 10, 6, gTransitionBarnDiagData, D_800E330C, D_800E3318, + gTransitionBarnDoorDiagAlpha, gTransitionBarnDoorDiagAlpha, + gTransitionBarnDoorDiagTris); + break; + case FADE_DISABLED: + init_transition_blank(transition); + break; } } return sTransitionStatus; @@ -304,7 +270,8 @@ s32 handle_transitions(s32 updateRate) { if (sLevelTransitionDelayTimer) { sLevelTransitionDelayTimer--; updateRate = LOGIC_NULL; - } else if (updateRate >= LOGIC_10FPS) { // Redundant because the logic update rate is clamped before this function is called. + } else if (updateRate >= LOGIC_10FPS) { + // Redundant because the logic update rate is clamped before this function is called. updateRate = LOGIC_12FPS; } @@ -399,7 +366,7 @@ void transition_end(void) { /** * Sets the transition timer and opacity to positive or negative depending on whether to fade in or out. -*/ + */ void transition_fullscreen_start(FadeTransition *transition) { if (transition->type & FADE_FLAG_OUT) { sTransitionOpacity = 255.0f; @@ -413,7 +380,7 @@ void transition_fullscreen_start(FadeTransition *transition) { /** * Slowly dade in or out by increasing or decreasing opacity. -*/ + */ void process_transition_fullscreen(s32 updateRate) { s32 var_v0; do { @@ -457,7 +424,7 @@ void process_transition_fullscreen(s32 updateRate) { /** * Draws a simple fillrect covering the whole screen that fades in or out. -*/ + */ void render_fade_fullscreen(Gfx **dList, UNUSED MatrixS **mats, UNUSED Vertex **verts) { s32 screenSize = get_video_width_and_height_as_s32(); gSPDisplayList((*dList)++, dTransitionFadeSettings); @@ -468,21 +435,23 @@ void render_fade_fullscreen(Gfx **dList, UNUSED MatrixS **mats, UNUSED Vertex ** } /** - * Allocate space for the new transitions vertices and triangles, then build the geometry based on the vertex and triangle shapes given. -*/ -void init_transition_shape(FadeTransition *transition, s32 numVerts, s32 numTris, s16 *coords, u8 *nextPos, u8 *targetPos, u8 *nextAlpha, u8 *targetAlpha, u8 *vertIndices) { - UNUSED s32 pad; + * Allocate space for the new transitions vertices and triangles, then build the geometry based on the vertex and + * triangle shapes given. + */ +void init_transition_shape(FadeTransition *transition, s32 numVerts, s32 numTris, s16 *coords, u8 *nextPos, + u8 *targetPos, u8 *nextAlpha, u8 *targetAlpha, u8 *vertIndices) { + UNUSED s32 pad; u8 *swap; s32 sizeVerts; s32 sizeTris; s32 i; s32 j; - + j = numVerts; sizeVerts = j * 10; sizeTris = numTris * 16; i = j * 12; - + sTransitionVtx[0] = allocate_from_main_pool_safe(((sizeVerts + sizeTris) * 2) + (i * 3), COLOUR_TAG_YELLOW); sTransitionVtx[1] = sTransitionVtx[0] + j; sTransitionTris[0] = (Triangle *) (sTransitionVtx[1] + j); @@ -498,7 +467,7 @@ void init_transition_shape(FadeTransition *transition, s32 numVerts, s32 numTris nextAlpha = targetAlpha; targetAlpha = swap; } - + for (i = 0; i < numVerts; i++) { gTransitionNextVtx[(i * 3) + 0] = coords[nextPos[i]]; gTransitionNextVtx[(i * 3) + 1] = coords[nextPos[i] + 1]; @@ -506,11 +475,14 @@ void init_transition_shape(FadeTransition *transition, s32 numVerts, s32 numTris gTransitionVertexTarget[(i * 3) + 0] = coords[targetPos[i]]; gTransitionVertexTarget[(i * 3) + 1] = coords[targetPos[i] + 1]; gTransitionVertexTarget[(i * 3) + 2] = targetAlpha[i]; - gTransitionVtxStep[(i * 3) + 0] = (gTransitionVertexTarget[(i * 3) + 0] - gTransitionNextVtx[(i * 3) + 0]) / sTransitionFadeTimer; - gTransitionVtxStep[(i * 3) + 1] = (gTransitionVertexTarget[(i * 3) + 1] - gTransitionNextVtx[(i * 3) + 1]) / sTransitionFadeTimer; - gTransitionVtxStep[(i * 3) + 2] = (gTransitionVertexTarget[(i * 3) + 2] - gTransitionNextVtx[(i * 3) + 2]) / sTransitionFadeTimer; + gTransitionVtxStep[(i * 3) + 0] = + (gTransitionVertexTarget[(i * 3) + 0] - gTransitionNextVtx[(i * 3) + 0]) / sTransitionFadeTimer; + gTransitionVtxStep[(i * 3) + 1] = + (gTransitionVertexTarget[(i * 3) + 1] - gTransitionNextVtx[(i * 3) + 1]) / sTransitionFadeTimer; + gTransitionVtxStep[(i * 3) + 2] = + (gTransitionVertexTarget[(i * 3) + 2] - gTransitionNextVtx[(i * 3) + 2]) / sTransitionFadeTimer; } - + for (i = 0; i < 2; i++) { for (j = 0; j < numVerts; j++) { sTransitionVtx[i][j].z = -16; @@ -519,7 +491,7 @@ void init_transition_shape(FadeTransition *transition, s32 numVerts, s32 numTris sTransitionVtx[i][j].b = gCurFadeBlue; } } - + for (i = 0; i < 2; i++) { for (j = 0; j < numTris; j++) { sTransitionTris[i][j].flags = 0x40; @@ -534,7 +506,7 @@ void init_transition_shape(FadeTransition *transition, s32 numVerts, s32 numTris sTransitionTris[i][j].uv2.v = 0; } } - + sTransitionStatus = TRANSITION_ACTIVE; gTransitionVertexCount = numVerts; } @@ -542,7 +514,7 @@ void init_transition_shape(FadeTransition *transition, s32 numVerts, s32 numTris /** * Slowly update the vertices of the transition based on what the next frames target is. * That target is set based on a velocity. -*/ + */ void process_transition_shape(s32 updateRate) { s32 i; f32 updateRateF; @@ -550,24 +522,24 @@ void process_transition_shape(s32 updateRate) { updateRateF = updateRate; if (sTransitionFadeTimer > 0) { if (updateRate < sTransitionFadeTimer) { - for (i = 0; i < gTransitionVertexCount; i++) { - gTransitionNextVtx[i*3] += updateRateF * gTransitionVtxStep[i*3]; - gTransitionNextVtx[i*3 + 1] += updateRateF * gTransitionVtxStep[i*3 + 1]; - gTransitionNextVtx[i*3 + 2] += updateRateF * gTransitionVtxStep[i*3 + 2]; + for (i = 0; i < gTransitionVertexCount; i++) { + gTransitionNextVtx[i * 3] += updateRateF * gTransitionVtxStep[i * 3]; + gTransitionNextVtx[i * 3 + 1] += updateRateF * gTransitionVtxStep[i * 3 + 1]; + gTransitionNextVtx[i * 3 + 2] += updateRateF * gTransitionVtxStep[i * 3 + 2]; } sTransitionFadeTimer -= updateRate; } else { for (i = 0; i < gTransitionVertexCount; i++) { - gTransitionNextVtx[i*3] = gTransitionVertexTarget[i*3]; - gTransitionNextVtx[i*3 + 1] = gTransitionVertexTarget[i*3 + 1]; - gTransitionNextVtx[i*3 + 2] = gTransitionVertexTarget[i*3 + 2]; + gTransitionNextVtx[i * 3] = gTransitionVertexTarget[i * 3]; + gTransitionNextVtx[i * 3 + 1] = gTransitionVertexTarget[i * 3 + 1]; + gTransitionNextVtx[i * 3 + 2] = gTransitionVertexTarget[i * 3 + 2]; } sTransitionFadeTimer = 0; } for (i = 0; i < gTransitionVertexCount; i++) { - sTransitionVtx[sTransitionTaskNum][i].x = gTransitionNextVtx[i*3]; - sTransitionVtx[sTransitionTaskNum][i].y = gTransitionNextVtx[i*3+1]; - sTransitionVtx[sTransitionTaskNum][i].a = (s32) gTransitionNextVtx[i*3+2]; + sTransitionVtx[sTransitionTaskNum][i].x = gTransitionNextVtx[i * 3]; + sTransitionVtx[sTransitionTaskNum][i].y = gTransitionNextVtx[i * 3 + 1]; + sTransitionVtx[sTransitionTaskNum][i].a = (s32) gTransitionNextVtx[i * 3 + 2]; } } else if (gTransitionEndTimer != 0xFFFF) { if (updateRate < gTransitionEndTimer) { @@ -580,7 +552,7 @@ void process_transition_shape(s32 updateRate) { /** * Renders a transition effect on screen that will close in from both sides horizonally. -*/ + */ void render_fade_barndoor_horizontal(Gfx **dList, UNUSED MatrixS **mats, UNUSED Vertex **verts) { reset_render_settings(dList); gSPDisplayList((*dList)++, dTransitionShapeSettings); @@ -592,7 +564,7 @@ void render_fade_barndoor_horizontal(Gfx **dList, UNUSED MatrixS **mats, UNUSED /** * Renders a transition effect on screen that will close in from both sides vertically. * Codewise, exactly the same as above, but uses a different vertex layout to make the difference. -*/ + */ void render_fade_barndoor_vertical(Gfx **dList, UNUSED MatrixS **mats, UNUSED Vertex **verts) { reset_render_settings(dList); gSPDisplayList((*dList)++, dTransitionShapeSettings); @@ -619,27 +591,27 @@ void func_800C15D4(FadeTransition *transition) { sTransitionTris[1] = (Triangle *) ((uintptr_t) sTransitionTris[0] + sizeTris); // This first one should be correct? - for(i = 0; i < 2; i++) { - for(j = 0; j < 72; j++) { + for (i = 0; i < 2; i++) { + for (j = 0; j < 72; j++) { sTransitionVtx[i][j].r = gCurFadeRed; - sTransitionVtx[i][j].g = gCurFadeGreen; + sTransitionVtx[i][j].g = gCurFadeGreen; sTransitionVtx[i][j].b = gCurFadeBlue; sTransitionVtx[i][j].a = 255; } } // ??? - for(i = 0; i < 2; i++) { - for(j = 0; j < 9; j++) { - sTransitionVtx[i][j+19].a = 0; - sTransitionVtx[i][j+55].a = 0; + for (i = 0; i < 2; i++) { + for (j = 0; j < 9; j++) { + sTransitionVtx[i][j + 19].a = 0; + sTransitionVtx[i][j + 55].a = 0; } } - for(i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { s16 xSins = sins_f(i * 0x1000) * 240.0f; s16 yCoss = coss_f(i * 0x1000) * 180.0f; - for(j = 0; j < 9; j++) { + for (j = 0; j < 9; j++) { sTransitionVtx[i][j].x = xSins; sTransitionVtx[i][j].y = yCoss; sTransitionVtx[i][j].z = -16; @@ -653,7 +625,7 @@ void func_800C15D4(FadeTransition *transition) { sTransitionVtx[i][j + 55].z = -16; } } - + if (transition->type & FADE_FLAG_OUT) { D_8012A758 = 0.0f; D_8012A75C = 0.0f; @@ -669,7 +641,7 @@ void func_800C15D4(FadeTransition *transition) { D_8012A768 = 0.0f; D_8012A76C = 0.0f; } - + for (i = 0; i < 2; i++) { for (j = 0; j < 64; j++) { sTransitionTris[i][j].flags = 0x40; @@ -691,7 +663,7 @@ void func_800C15D4(FadeTransition *transition) { sTransitionTris[i][j * sizeof(Triangle) + 1].vi2 = (i) + 3; } } - + sTransitionStatus = TRANSITION_ACTIVE; } #else @@ -719,8 +691,8 @@ void func_800C1EE8(s32 updateRate) { D_8012A75C = D_8012A76C; sTransitionFadeTimer = 0; } - - for (j = 0, i = 0; i < 9; i++, j += 0x1000) { + + for (j = 0, i = 0; i < 9; i++, j += 0x1000) { new_var = 1.2f; temp_f20 = sins_f(j) * D_8012A758; temp_f2 = coss_f(j) * D_8012A75C; @@ -730,8 +702,8 @@ void func_800C1EE8(s32 updateRate) { sTransitionVtx[sTransitionTaskNum][(i << 1) + 1].y = temp_f16; sTransitionVtx[sTransitionTaskNum][(i << 1) + 37].x = -temp_f6; sTransitionVtx[sTransitionTaskNum][(i << 1) + 37].y = temp_f16; - sTransitionVtx[sTransitionTaskNum][(i << 1) + 18].x = temp_f6; - sTransitionVtx[sTransitionTaskNum][(i << 1) + 18].y = temp_f16; + sTransitionVtx[sTransitionTaskNum][(i << 1) + 18].x = temp_f6; + sTransitionVtx[sTransitionTaskNum][(i << 1) + 18].y = temp_f16; sTransitionVtx[sTransitionTaskNum][(i << 1) + 54].x = -temp_f6; sTransitionVtx[sTransitionTaskNum][(i << 1) + 54].y = temp_f16; sTransitionVtx[sTransitionTaskNum][(i << 1) + 19].x = temp_f20; @@ -753,7 +725,7 @@ void func_800C1EE8(s32 updateRate) { #define NUM_OF_TRIS 16 /** * Render a circle shape transition onscreen using previously allocated geometry. -*/ + */ void render_fade_circle(Gfx **dList, UNUSED MatrixS **mats, UNUSED Vertex **verts) { Vertex *vertsToRender; Triangle *trisToRender; @@ -780,7 +752,7 @@ void render_fade_circle(Gfx **dList, UNUSED MatrixS **mats, UNUSED Vertex **vert /** * Render the wavy transition onscreen using the vertex data allocated earlier. -*/ + */ void render_fade_waves(Gfx **dlist, UNUSED MatrixS **mats, UNUSED Vertex **verts) { Gfx *gfx; s32 i; @@ -818,7 +790,7 @@ void render_fade_waves(Gfx **dlist, UNUSED MatrixS **mats, UNUSED Vertex **verts /** * Renders a transition effect on screen that will close in from the opposite corners of the screen. -*/ + */ void render_fade_barndoor_diagonal(Gfx **dList, UNUSED MatrixS **mats, UNUSED Vertex **verts) { reset_render_settings(dList); gSPDisplayList((*dList)++, dTransitionShapeSettings); @@ -829,7 +801,7 @@ void render_fade_barndoor_diagonal(Gfx **dList, UNUSED MatrixS **mats, UNUSED Ve /** * Set the transition colour target, then set the velocity for the colour to fade to. -*/ + */ void init_transition_blank(UNUSED FadeTransition *transition) { gLastFadeRed <<= 16; gLastFadeGreen <<= 16; @@ -845,7 +817,7 @@ void init_transition_blank(UNUSED FadeTransition *transition) { /** * Shifts the colours of the transition over time while the timer ticks down. -*/ + */ void process_transition_disabled(s32 updateRate) { s32 var_v0; do { @@ -876,7 +848,7 @@ void process_transition_disabled(s32 updateRate) { /** * Fill the whole screen with a solid colour. -*/ + */ void render_fade_disabled(Gfx **dList, UNUSED MatrixS **mats, UNUSED Vertex **verts) { s32 screenSize = get_video_width_and_height_as_s32(); gSPDisplayList((*dList)++, dTransitionFadeSettings); diff --git a/src/fade_transition.h b/src/fade_transition.h index ff52c354..402933e8 100644 --- a/src/fade_transition.h +++ b/src/fade_transition.h @@ -65,7 +65,8 @@ void process_transition_disabled(s32 updateRate); s32 transition_begin(FadeTransition *transition); void render_fade_circle(Gfx **dList, MatrixS **mats, Vertex **verts); void process_transition_shape(s32 updateRate); -void init_transition_shape(FadeTransition *transition, s32 numVerts, s32 numTris, s16 *arg3, u8 *arg4, u8 *arg5, u8 *arg6, u8 *arg7, u8 *arg8); +void init_transition_shape(FadeTransition *transition, s32 numVerts, s32 numTris, s16 *coords, u8 *nextPos, + u8 *targetPos, u8 *nextAlpha, u8 *targetAlpha, u8 *vertIndices); void func_800C1EE8(s32 updateRate); void render_fade_waves(Gfx **dlist, UNUSED MatrixS **mats, UNUSED Vertex **verts); diff --git a/src/font.c b/src/font.c index 39b9e21b..72def2a0 100644 --- a/src/font.c +++ b/src/font.c @@ -39,9 +39,10 @@ s32 gDescPowsOf10[9] = { // The dialogue box will draw in pieces, using properties from each line. It starts with a box // and goes inwards or outwards depending on the direction, set by the define. -#define INWARDS 0 +#define INWARDS 0 #define OUTWARDS 1 +// clang-format off s8 sDialogueBoxDimensions[48] = { /*X Offset*/ 4, INWARDS, /*Y Start*/ 0, INWARDS, /*Y end*/ 1, /*X Offset*/ 2, INWARDS, /*Y Start*/ 1, INWARDS, /*Y end*/ 2, @@ -53,6 +54,7 @@ s8 sDialogueBoxDimensions[48] = { /*X Offset*/ -1, 0, 0, 0, 0, // End of Data /*X Offset*/ 0, 0, 0, 0, 0, 0, 0, 0, }; +// clang-format on #undef INWARDS #undef OUTWARDS @@ -66,10 +68,11 @@ OSDevMgr __osPiDevMgr = { /************ .bss ************/ s32 gNumberOfFonts; -FontData *gFonts; //Official Name: Font -DialogueBoxBackground *gDialogueBoxBackground; //Official Name: Window -DialogueTextElement *gDialogueText; //Official Name: String -s32 gCompactKerning; // Official Name: squash - Boolean value, seems to be related to X placement of menus on the X Axis? +FontData *gFonts; // Official Name: Font +DialogueBoxBackground *gDialogueBoxBackground; // Official Name: Window +DialogueTextElement *gDialogueText; // Official Name: String +s32 gCompactKerning; // Official Name: squash - Boolean value, seems to be related to X placement of menus on the X + // Axis? s8 sDialogueBoxCloseTimer; /******************************/ @@ -144,7 +147,7 @@ void load_fonts(void) { /** * Sets text kerning to true or false. * If false, text displayed will be monospaced. -*/ + */ void set_kerning(s32 setting) { gCompactKerning = setting; } @@ -152,7 +155,7 @@ void set_kerning(s32 setting) { /** * Load the texture assets of the given font into RAM. * This is required before any text using this font can be displayed in a scene. -*/ + */ void load_font(s32 fontID) { if (fontID < gNumberOfFonts) { FontData *fontData = &gFonts[fontID]; @@ -170,7 +173,7 @@ void load_font(s32 fontID) { /** * Free a font's assets from RAM. * Highly recommended to do for any existing font when unloading a scene to prevent leaks. -*/ + */ void unload_font(s32 fontID) { if (fontID < gNumberOfFonts) { FontData *fontData = &gFonts[fontID]; @@ -274,7 +277,8 @@ UNUSED void draw_dialogue_text_unused(Gfx **displayList, s32 dialogueBoxID, char * Unused text draw function that would draw text in the current dialogue box while overriding position. * Official Name: fontPrintWindowXY */ -UNUSED void draw_dialogue_text_pos_unused(Gfx **displayList, s32 dialogueBoxID, s32 xpos, s32 ypos, char *text, AlignmentFlags alignmentFlags) { +UNUSED void draw_dialogue_text_pos_unused(Gfx **displayList, s32 dialogueBoxID, s32 xpos, s32 ypos, char *text, + AlignmentFlags alignmentFlags) { if (dialogueBoxID >= 0 && dialogueBoxID < DIALOGUEBOXBACKGROUND_COUNT) { DialogueBoxBackground *temp = &gDialogueBoxBackground[dialogueBoxID]; temp->xpos = (xpos == POS_CENTRED) ? temp->width >> 1 : xpos; @@ -287,7 +291,8 @@ UNUSED void draw_dialogue_text_pos_unused(Gfx **displayList, s32 dialogueBoxID, * Loops through a string, then draws each character onscreen. * Will also draw a fillrect if text backgrounds are enabled. */ -void render_text_string(Gfx **dList, DialogueBoxBackground *box, char *text, AlignmentFlags alignmentFlags, f32 scisScale) { +void render_text_string(Gfx **dList, DialogueBoxBackground *box, char *text, AlignmentFlags alignmentFlags, + f32 scisScale) { s32 scisOffset; s32 scisPos; s32 ypos; @@ -356,8 +361,7 @@ void render_text_string(Gfx **dList, DialogueBoxBackground *box, char *text, Ali gDPPipeSync((*dList)++); xpos += box->textOffsetX; ypos += box->textOffsetY; - for (charIndex = 0; (text[charIndex] != '\0') && (box->y2 >= ypos); - xpos += charSpace, charIndex++) { + for (charIndex = 0; (text[charIndex] != '\0') && (box->y2 >= ypos); xpos += charSpace, charIndex++) { curChar = text[charIndex]; newData = FALSE; charSpace = 0; @@ -399,8 +403,7 @@ void render_text_string(Gfx **dList, DialogueBoxBackground *box, char *text, Ali textureT = fontData->letter[curChar].t; xAlignmentDiff = fontData->letter[curChar].lrx; yAlignmentDiff = fontData->letter[curChar].lry; - charSpace = - (fontData->x == 0) ? (fontData->letter[curChar].ulx) : (fontData->x); + charSpace = (fontData->x == 0) ? (fontData->letter[curChar].ulx) : (fontData->x); newData = TRUE; } } @@ -419,7 +422,8 @@ void render_text_string(Gfx **dList, DialogueBoxBackground *box, char *text, Ali textureT += -textureUly * 8; textureUly = 0; } - gSPTextureRectangle((*dList)++, textureUlx, textureUly, textureLrx, newTempY, 0, textureS, textureT, 1 << 10, 1 << 10); + gSPTextureRectangle((*dList)++, textureUlx, textureUly, textureLrx, newTempY, 0, textureS, textureT, + 1 << 10, 1 << 10); if (lastTextureIndex) {} // Fakematch } if (gCompactKerning && charSpace) { @@ -808,7 +812,7 @@ UNUSED void enable_dialogue_box_vertices(s32 dialogueBoxID) { /** * Clears the open flag from the dialogue box. -*/ + */ void clear_dialogue_box_open_flag(s32 dialogueBoxID) { gDialogueBoxBackground[dialogueBoxID].flags &= (DIALOGUE_BOX_VERTS + DIALOGUE_BOX_CLOSED); } @@ -925,12 +929,17 @@ void render_dialogue_box(Gfx **dlist, MatrixS **mat, Vertex **verts, s32 dialogu gDkrDmaDisplayList((*dlist)++, OS_K0_TO_PHYSICAL(&dDialogueBoxDrawModes[1]), 2); gDPSetEnvColor((*dlist)++, 0, 0, 0, 0); if (dialogueBox->x2 - dialogueBox->x1 < 10 || dialogueBox->y2 - dialogueBox->y1 < 10) { - render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 - 2, dialogueBox->x2 + 2, dialogueBox->y2 + 2); + render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 - 2, dialogueBox->x2 + 2, + dialogueBox->y2 + 2); } else { - render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 + 2, dialogueBox->x1 + 2, dialogueBox->y2 - 2); - render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 - 2, dialogueBox->x2 + 2, dialogueBox->y1 + 2); - render_fill_rectangle(dlist, dialogueBox->x2 - 2, dialogueBox->y1 + 2, dialogueBox->x2 + 2, dialogueBox->y2 - 2); - render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y2 - 2, dialogueBox->x2 + 2, dialogueBox->y2 + 2); + render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 + 2, dialogueBox->x1 + 2, + dialogueBox->y2 - 2); + render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y1 - 2, dialogueBox->x2 + 2, + dialogueBox->y1 + 2); + render_fill_rectangle(dlist, dialogueBox->x2 - 2, dialogueBox->y1 + 2, dialogueBox->x2 + 2, + dialogueBox->y2 - 2); + render_fill_rectangle(dlist, dialogueBox->x1 - 2, dialogueBox->y2 - 2, dialogueBox->x2 + 2, + dialogueBox->y2 + 2); } gDPPipeSync((*dlist)++); gDPSetEnvColor((*dlist)++, dialogueBox->backgroundColourR, dialogueBox->backgroundColourG, @@ -939,9 +948,11 @@ void render_dialogue_box(Gfx **dlist, MatrixS **mat, Vertex **verts, s32 dialogu // The array determines the width and height of each entry before drawing it. for (i = 0; sDialogueBoxDimensions[i] >= 0; i += 5) { x1 = sDialogueBoxDimensions[i] + dialogueBox->x1; - y1 = (sDialogueBoxDimensions[i + 1]) ? sDialogueBoxDimensions[i + 2] + dialogueBox->y2 : sDialogueBoxDimensions[i + 2] + dialogueBox->y1; + y1 = (sDialogueBoxDimensions[i + 1]) ? sDialogueBoxDimensions[i + 2] + dialogueBox->y2 + : sDialogueBoxDimensions[i + 2] + dialogueBox->y1; x2 = dialogueBox->x2 - sDialogueBoxDimensions[i]; - y2 = (sDialogueBoxDimensions[i + 3]) ? sDialogueBoxDimensions[i + 4] + dialogueBox->y2 : sDialogueBoxDimensions[i + 4] + dialogueBox->y1; + y2 = (sDialogueBoxDimensions[i + 3]) ? sDialogueBoxDimensions[i + 4] + dialogueBox->y2 + : sDialogueBoxDimensions[i + 4] + dialogueBox->y1; render_fill_rectangle(dlist, x1, y1, x2, y2); } gDPPipeSync((*dlist)++); diff --git a/src/font.h b/src/font.h index 59356b07..ce07ad46 100644 --- a/src/font.h +++ b/src/font.h @@ -165,7 +165,7 @@ void set_dialogue_font(s32 dialogueBoxID, s32 font); void set_current_dialogue_background_colour(s32 dialogueBoxID, s32 red, s32 green, s32 blue, s32 alpha); void set_current_text_colour(s32 dialogueBoxID, s32 red, s32 green, s32 blue, s32 alpha, s32 opacity); void set_current_text_background_colour(s32 dialogueBoxID, s32 red, s32 green, s32 blue, s32 alpha); -void move_dialogue_box_to_front(s32 dialogueBoxID, DialogueBox *box); +void move_dialogue_box_to_front(s32 dialogueBoxID, DialogueBox *dialogueBox); void assign_dialogue_box_id(s32 dialogueBoxID); void open_dialogue_box(s32 dialogueBoxID); void close_dialogue_box(s32 dialogueBoxID); @@ -177,7 +177,8 @@ void parse_string_with_number(char *input, char *output, s32 number); void s32_to_string(char **outString, s32 number); void load_font(s32 fontID); void unload_font(s32 fontID); -void render_text_string(Gfx **dlist, DialogueBoxBackground *box, char *text, AlignmentFlags alignmentFlags, f32 scisScale); +void render_text_string(Gfx **dList, DialogueBoxBackground *box, char *text, AlignmentFlags alignmentFlags, + f32 scisScale); s32 get_text_width(char *text, s32 x, s32 font); void *render_dialogue_text(s32 dialogueBoxID, s32 posX, s32 posY, char *text, s32 number, s32 flags); diff --git a/src/game.c b/src/game.c index 8ec3958c..bea09460 100644 --- a/src/game.c +++ b/src/game.c @@ -80,8 +80,9 @@ s16 gLevelPropertyStack[5 * 4]; // Stores level info for cutscenes. 5 sets of fo /** * Allocates memory for gGlobalLevelTable, then populates it with relevant data from every level header. * The level headers are streamed from ROM. - * Additionally loads other globally accessed information, like level names, then runs a checksum compare, for good measure. -*/ + * Additionally loads other globally accessed information, like level names, then runs a checksum compare, for good + * measure. + */ void init_level_globals(void) { s32 i; s32 size; @@ -100,7 +101,8 @@ void init_level_globals(void) { gNumberOfLevelHeaders++; } gNumberOfLevelHeaders--; - gGlobalLevelTable = allocate_from_main_pool_safe(gNumberOfLevelHeaders * sizeof(LevelGlobalData), COLOUR_TAG_YELLOW); + gGlobalLevelTable = + allocate_from_main_pool_safe(gNumberOfLevelHeaders * sizeof(LevelGlobalData), COLOUR_TAG_YELLOW); gCurrentLevelHeader = (LevelHeader *) header; gNumberOfWorlds = -1; for (i = 0; i < gNumberOfLevelHeaders; i++) { @@ -131,7 +133,7 @@ void init_level_globals(void) { free_from_memory_pool(gTempAssetTable); free_from_memory_pool(header); gTempAssetTable = (s32 *) load_asset_section_from_rom(ASSET_LEVEL_NAMES_TABLE); - for (i = 0; gTempAssetTable[i] != (-1); i++) { } + for (i = 0; gTempAssetTable[i] != (-1); i++) {} i--; size = gTempAssetTable[i] - gTempAssetTable[0]; gLevelNames = allocate_from_main_pool_safe(i * sizeof(s32), COLOUR_TAG_YELLOW); @@ -164,7 +166,7 @@ UNUSED s16 func_8006ABB4(s32 levelID) { /** * Iterates through the level property table and attempts to find a level ID that matches the properties you want. * Iterates Forwards. -*/ + */ UNUSED s32 search_level_properties_forwards(s32 levelID, s8 raceType, s8 worldID) { if (levelID < 0) { levelID = 0; @@ -186,7 +188,8 @@ UNUSED s32 search_level_properties_forwards(s32 levelID, s8 raceType, s8 worldID } } else { for (; levelID < gNumberOfLevelHeaders; levelID++) { - if ((raceType == gGlobalLevelTable[levelID].raceType) && (worldID == gGlobalLevelTable[levelID].world)) { + if ((raceType == gGlobalLevelTable[levelID].raceType) && + (worldID == gGlobalLevelTable[levelID].world)) { return levelID; } } @@ -200,7 +203,8 @@ UNUSED s32 search_level_properties_forwards(s32 levelID, s8 raceType, s8 worldID } } else { for (; levelID < gNumberOfLevelHeaders; levelID++) { - if ((gGlobalLevelTable[levelID].raceType & RACETYPE_CHALLENGE) && (worldID == gGlobalLevelTable[levelID].world)) { + if ((gGlobalLevelTable[levelID].raceType & RACETYPE_CHALLENGE) && + (worldID == gGlobalLevelTable[levelID].world)) { return levelID; } } @@ -212,9 +216,9 @@ UNUSED s32 search_level_properties_forwards(s32 levelID, s8 raceType, s8 worldID /** * Iterates through the level property table and attempts to find a level ID that matches the properties you want. * Iterates Backwards. -*/ + */ UNUSED s32 search_level_properties_backwards(s32 levelID, s8 raceType, s8 worldID) { - if(levelID >= gNumberOfLevelHeaders){ + if (levelID >= gNumberOfLevelHeaders) { levelID = gNumberOfLevelHeaders; } levelID--; @@ -233,7 +237,8 @@ UNUSED s32 search_level_properties_backwards(s32 levelID, s8 raceType, s8 worldI } } else { for (; levelID >= 0; levelID--) { - if ((raceType == gGlobalLevelTable[levelID].raceType) && (worldID == gGlobalLevelTable[levelID].world)) { + if ((raceType == gGlobalLevelTable[levelID].raceType) && + (worldID == gGlobalLevelTable[levelID].world)) { return levelID; } } @@ -247,7 +252,8 @@ UNUSED s32 search_level_properties_backwards(s32 levelID, s8 raceType, s8 worldI } } else { for (; levelID >= 0; levelID--) { - if ((gGlobalLevelTable[levelID].raceType & RACETYPE_CHALLENGE) && (worldID == gGlobalLevelTable[levelID].world)) { + if ((gGlobalLevelTable[levelID].raceType & RACETYPE_CHALLENGE) && + (worldID == gGlobalLevelTable[levelID].world)) { return levelID; } } @@ -258,7 +264,7 @@ UNUSED s32 search_level_properties_backwards(s32 levelID, s8 raceType, s8 worldI /** * Return the number of tracks that fall under a certain race type. -*/ + */ UNUSED s32 get_race_type_count(s8 raceType) { if (raceType >= 0 && raceType < 16) { return gRaceTypeCountTable[raceType]; @@ -268,7 +274,7 @@ UNUSED s32 get_race_type_count(s8 raceType) { /** * Returns the number of levels that belong to one hub world. -*/ + */ UNUSED s32 get_world_level_count(s8 worldID) { s32 out, i; out = 0; @@ -282,7 +288,7 @@ UNUSED s32 get_world_level_count(s8 worldID) { /** * Returns the default vehicle from the set map ID. -*/ + */ Vehicle get_map_default_vehicle(s32 mapId) { if (mapId > 0 && mapId < gNumberOfLevelHeaders) { return gGlobalLevelTable[mapId].vehicles & 0xF; @@ -292,7 +298,7 @@ Vehicle get_map_default_vehicle(s32 mapId) { /** * Returns the available vehicles from the set map ID. -*/ + */ s32 get_map_available_vehicles(s32 mapId) { if (mapId > 0 && mapId < gNumberOfLevelHeaders) { s32 temp = gGlobalLevelTable[mapId].vehicles; @@ -305,7 +311,7 @@ s32 get_map_available_vehicles(s32 mapId) { /** * Returns the race type from the set map ID. -*/ + */ s8 get_map_race_type(s32 mapId) { if (mapId >= 0 && mapId < gNumberOfLevelHeaders) { return gGlobalLevelTable[mapId].raceType; @@ -315,7 +321,7 @@ s8 get_map_race_type(s32 mapId) { /** * Returns the world ID from the set map ID. -*/ + */ s8 get_map_world_id(s32 mapId) { if (mapId >= 0 && mapId < gNumberOfLevelHeaders) { return gGlobalLevelTable[mapId].world; @@ -325,21 +331,21 @@ s8 get_map_world_id(s32 mapId) { /** * Returns the ID of the current hub world. Example: Dino Domain. -*/ + */ s32 get_hub_area_id(s32 worldId) { s8 *hubAreaIds; if (worldId < 0 || worldId >= gNumberOfWorlds) { worldId = 0; } - hubAreaIds = (s8 *)get_misc_asset(ASSET_MISC_HUB_AREA_IDS); + hubAreaIds = (s8 *) get_misc_asset(ASSET_MISC_HUB_AREA_IDS); return hubAreaIds[worldId]; } /** * Writes the level and hub count to the two arguments passed through. -*/ + */ void get_number_of_levels_and_worlds(s32 *outLevelCount, s32 *outWorldCount) { *outLevelCount = gNumberOfLevelHeaders; *outWorldCount = gNumberOfWorlds; @@ -348,7 +354,7 @@ void get_number_of_levels_and_worlds(s32 *outLevelCount, s32 *outWorldCount) { /** * Returns true if the current event is a regular race or a boss race. * Returns false if it's a menu, challenge or hubworld. -*/ + */ s32 check_if_in_race(void) { return gIsInRace; } @@ -356,7 +362,7 @@ s32 check_if_in_race(void) { /** * Loads and sets up the level header, then loads and sets of the level geometry. * Sets weather, fog and active cutscenes where applicable. -*/ + */ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicleId, s32 cutsceneId) { s8 *someAsset; s32 i; @@ -378,7 +384,7 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl } else { numPlayers = 0; } - + if (numberOfPlayers == ONE_PLAYER) { set_sound_channel_count(8); } else if (numberOfPlayers == TWO_PLAYERS) { @@ -389,7 +395,7 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl settings = get_settings(); gTempAssetTable = (s32 *) load_asset_section_from_rom(ASSET_LEVEL_HEADERS_TABLE); - for (i = 0; gTempAssetTable[i] != -1; i++) { } + for (i = 0; gTempAssetTable[i] != -1; i++) {} i--; if (levelId >= i) { stubbed_printf("LOADLEVEL Error: Level out of range\n"); @@ -409,7 +415,8 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl if (gCurrentLevelHeader->race_type == RACETYPE_BOSS) { var_s0 = settings->courseFlagsPtr[levelId]; wizpig = FALSE; - if (gCurrentLevelHeader->world == WORLD_CENTRAL_AREA || gCurrentLevelHeader->world == WORLD_FUTURE_FUN_LAND) { + if (gCurrentLevelHeader->world == WORLD_CENTRAL_AREA || + gCurrentLevelHeader->world == WORLD_FUTURE_FUN_LAND) { wizpig = TRUE; } if (!(var_s0 & 1) || wizpig) { @@ -426,7 +433,7 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl } } someAsset = (s8 *) get_misc_asset(ASSET_MISC_67); - for (var_s0 = 0; levelId != someAsset[var_s0]; var_s0 += 2) { } + for (var_s0 = 0; levelId != someAsset[var_s0]; var_s0 += 2) {} levelId = someAsset[var_s0 + 1]; entranceId = cutsceneId; if (cutsceneId == CUTSCENE_NONE) { @@ -437,7 +444,8 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl if (gCurrentLevelHeader->race_type == RACETYPE_HUBWORLD) { if (gCurrentLevelHeader->world > WORLD_CENTRAL_AREA && gCurrentLevelHeader->world < WORLD_FUTURE_FUN_LAND) { var_s0 = gCurrentLevelHeader->world; - if (settings->keys & (1 << var_s0) && !(settings->cutsceneFlags & (CUTSCENE_DINO_DOMAIN_KEY << (var_s0 + 31)))) { + if (settings->keys & (1 << var_s0) && + !(settings->cutsceneFlags & (CUTSCENE_DINO_DOMAIN_KEY << (var_s0 + 31)))) { // Trigger World Key unlocking Challenge Door cutscene. push_level_property_stack(levelId, entranceId, vehicleId, cutsceneId); settings->cutsceneFlags |= CUTSCENE_DINO_DOMAIN_KEY << (var_s0 + 31); @@ -448,7 +456,7 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl } } } - if (gCurrentLevelHeader->race_type == RACETYPE_HUBWORLD && gCurrentLevelHeader->world == WORLD_CENTRAL_AREA && + if (gCurrentLevelHeader->race_type == RACETYPE_HUBWORLD && gCurrentLevelHeader->world == WORLD_CENTRAL_AREA && !(settings->cutsceneFlags & CUTSCENE_WIZPIG_FACE) && settings->wizpigAmulet >= 4) { // Trigger wizpig face cutscene push_level_property_stack(levelId, entranceId, vehicleId, cutsceneId); @@ -472,7 +480,8 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl gMapId = levelId; for (var_s0 = 0; var_s0 < 7; var_s0++) { if ((s32) gCurrentLevelHeader->unk74[var_s0] != -1) { - gCurrentLevelHeader->unk74[var_s0] = (LevelHeader_70 *) get_misc_asset((s32) gCurrentLevelHeader->unk74[var_s0]); + gCurrentLevelHeader->unk74[var_s0] = + (LevelHeader_70 *) get_misc_asset((s32) gCurrentLevelHeader->unk74[var_s0]); func_8007F1E8((LevelHeader_70 *) gCurrentLevelHeader->unk74[var_s0]); } } @@ -550,25 +559,28 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl if (numberOfPlayers != ONE_PLAYER && gCurrentLevelHeader->race_type == RACETYPE_DEFAULT) { cutsceneId = CUTSCENE_ID_UNK_64; } - if ((gCurrentLevelHeader->race_type == RACETYPE_DEFAULT || gCurrentLevelHeader->race_type & RACETYPE_CHALLENGE) && is_in_two_player_adventure()) { + if ((gCurrentLevelHeader->race_type == RACETYPE_DEFAULT || gCurrentLevelHeader->race_type & RACETYPE_CHALLENGE) && + is_in_two_player_adventure()) { gTwoPlayerAdvRace = TRUE; cutsceneId = CUTSCENE_ID_UNK_64; } else { gTwoPlayerAdvRace = FALSE; - } if (gCurrentLevelHeader->race_type == RACETYPE_DEFAULT && numPlayers == 0 && is_time_trial_enabled()) { cutsceneId = CUTSCENE_ID_UNK_64; } set_cutscene_id(cutsceneId); - init_track(gCurrentLevelHeader->geometry, gCurrentLevelHeader->skybox, numberOfPlayers, vehicleId, entranceId, gCurrentLevelHeader->collectables, gCurrentLevelHeader->unkBA); - if (gCurrentLevelHeader->fogNear == 0 && gCurrentLevelHeader->fogFar == 0 && gCurrentLevelHeader->fogR == 0 && gCurrentLevelHeader->fogG == 0 && gCurrentLevelHeader->fogB == 0) { + init_track(gCurrentLevelHeader->geometry, gCurrentLevelHeader->skybox, numberOfPlayers, vehicleId, entranceId, + gCurrentLevelHeader->collectables, gCurrentLevelHeader->unkBA); + if (gCurrentLevelHeader->fogNear == 0 && gCurrentLevelHeader->fogFar == 0 && gCurrentLevelHeader->fogR == 0 && + gCurrentLevelHeader->fogG == 0 && gCurrentLevelHeader->fogB == 0) { for (var_s0 = 0; var_s0 < 4; var_s0++) { reset_fog(var_s0); } } else { for (var_s0 = 0; var_s0 < 4; var_s0++) { - set_fog(var_s0, gCurrentLevelHeader->fogNear, gCurrentLevelHeader->fogFar, (u8) gCurrentLevelHeader->fogR, gCurrentLevelHeader->fogG, gCurrentLevelHeader->fogB); + set_fog(var_s0, gCurrentLevelHeader->fogNear, gCurrentLevelHeader->fogFar, (u8) gCurrentLevelHeader->fogR, + gCurrentLevelHeader->fogG, gCurrentLevelHeader->fogB); } } settings = get_settings(); @@ -577,7 +589,10 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl } settings->courseId = levelId; if (gCurrentLevelHeader->weatherEnable > 0) { - func_800AB4A8(gCurrentLevelHeader->weatherType, gCurrentLevelHeader->weatherEnable, gCurrentLevelHeader->weatherVelX << 8, gCurrentLevelHeader->weatherVelY << 8, gCurrentLevelHeader->weatherVelZ << 8, gCurrentLevelHeader->weatherIntensity * 257, gCurrentLevelHeader->weatherOpacity * 257); + func_800AB4A8(gCurrentLevelHeader->weatherType, gCurrentLevelHeader->weatherEnable, + gCurrentLevelHeader->weatherVelX << 8, gCurrentLevelHeader->weatherVelY << 8, + gCurrentLevelHeader->weatherVelZ << 8, gCurrentLevelHeader->weatherIntensity * 257, + gCurrentLevelHeader->weatherOpacity * 257); set_weather_limits(-1, -512); } if (gCurrentLevelHeader->skyDome == -1) { @@ -586,18 +601,20 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl gCurrentLevelHeader->unkAA = 0; } if ((s32) gCurrentLevelHeader->pulseLightData != -1) { - gCurrentLevelHeader->pulseLightData = (PulsatingLightData *) get_misc_asset((s32) gCurrentLevelHeader->pulseLightData); + gCurrentLevelHeader->pulseLightData = + (PulsatingLightData *) get_misc_asset((s32) gCurrentLevelHeader->pulseLightData); init_pulsating_light_data(gCurrentLevelHeader->pulseLightData); } update_camera_fov(gCurrentLevelHeader->cameraFOV); - set_background_prim_colour(gCurrentLevelHeader->bgColorRed, gCurrentLevelHeader->bgColorGreen, gCurrentLevelHeader->bgColorBlue); + set_background_prim_colour(gCurrentLevelHeader->bgColorRed, gCurrentLevelHeader->bgColorGreen, + gCurrentLevelHeader->bgColorBlue); reset_video_delta_time(); func_8007AB24(gCurrentLevelHeader->unk4[numberOfPlayers]); } /** * If the level's music ID is nonzero, set the current background music. -*/ + */ void start_level_music(f32 tempo) { if (gCurrentLevelHeader->music != SEQUENCE_NONE) { music_channel_reset_all(); @@ -609,7 +626,7 @@ void start_level_music(f32 tempo) { /** * Return the current map ID. -*/ + */ s32 get_current_map_id(void) { return gMapId; } @@ -676,7 +693,7 @@ char *get_level_name(s32 levelId) { /** * Call multiple functions to stop and free audio, then free track, weather and wave data. -*/ + */ void clear_audio_and_track(void) { free_ai_behaviour_table(); set_background_prim_colour(0, 0, 0); @@ -701,7 +718,7 @@ void clear_audio_and_track(void) { /** * Set the skill level of the AI. * Apply offsets based on game mode. -*/ + */ void set_ai_level(s8 *aiLevelTable) { s32 temp; UNUSED s32 temp2; @@ -754,21 +771,21 @@ void set_ai_level(s8 *aiLevelTable) { /** * Frees the AI behaviour table from memory. -*/ + */ void free_ai_behaviour_table(void) { free_from_memory_pool(gAIBehaviourTable); } /** * Return the behaviour value table for AI racers. -*/ + */ AIBehaviourTable *get_ai_behaviour_table(void) { return gAIBehaviourTable; } /** * Return whether it is a standard race with two players in adventure mode. -*/ + */ s8 is_two_player_adventure_race(void) { return gTwoPlayerAdvRace; } @@ -776,7 +793,7 @@ s8 is_two_player_adventure_race(void) { /** * Pushes the current level data onto a stack. * Used for preserving certain properties when viewing cutscenes, where this information would otherwise be lost. -*/ + */ void push_level_property_stack(s32 levelId, s32 entranceId, Vehicle vehicleId, s32 cutsceneId) { gLevelPropertyStack[gLevelPropertyStackPos++] = levelId; gLevelPropertyStack[gLevelPropertyStackPos++] = entranceId; @@ -787,7 +804,7 @@ void push_level_property_stack(s32 levelId, s32 entranceId, Vehicle vehicleId, s /** * Reads the level data from the stack, then pops it. * Used after cutscenes to properly restore the previous level status. -*/ + */ void pop_level_property_stack(s32 *levelId, s32 *entranceId, s32 *vehicleId, s32 *cutsceneId) { s32 tempVehicleID; @@ -806,7 +823,7 @@ void pop_level_property_stack(s32 *levelId, s32 *entranceId, s32 *vehicleId, s32 /** * Resets the position in the level propert stack, effectively clearing it. -*/ + */ void clear_level_property_stack(void) { gLevelPropertyStackPos = 0; } diff --git a/src/game.h b/src/game.h index 64c9658c..8b36db9e 100644 --- a/src/game.h +++ b/src/game.h @@ -40,7 +40,7 @@ s8 get_map_world_id(s32 mapId); s32 get_hub_area_id(s32 worldId); void get_number_of_levels_and_worlds(s32 *outLevelCount, s32 *outWorldCount); s32 check_if_in_race(void); -void start_level_music(f32 arg0); +void start_level_music(f32 tempo); s32 get_current_map_id(void); u8 get_current_level_race_type(void); LevelHeader *get_current_level_header(void); diff --git a/src/game_text.c b/src/game_text.c index 65e19720..bd617d37 100644 --- a/src/game_text.c +++ b/src/game_text.c @@ -32,7 +32,7 @@ UNUSED s16 D_8012A78C; // Set to -1, never read. s16 D_8012A78E; s16 gTextTableEntries; UNUSED s16 D_8012A792; -char *gGameTextTableEntries[2]; //960 x2 bytes +char *gGameTextTableEntries[2]; // 960 x2 bytes char *D_8012A7A0; s32 D_8012A7A4; s16 gDialogueAlpha; @@ -55,7 +55,7 @@ s32 D_8012A7D4; /** * Set the default values of dialogue and allocate memory for the active text entry. -*/ + */ void init_dialogue_text(void) { gCurrentMessageText[0] = (char *) allocate_from_main_pool_safe(0x780, COLOUR_TAG_GREEN); gCurrentMessageText[1] = gCurrentMessageText[0] + 0x3C0; @@ -78,7 +78,7 @@ void init_dialogue_text(void) { /** * Close screen dialogue and free the text currently loaded into it. -*/ + */ void free_message_box(void) { free_from_memory_pool(gCurrentMessageText[0]); gShowSubtitles = FALSE; @@ -88,14 +88,14 @@ void free_message_box(void) { /** * Toggle an override that prevents subtitles from showing. -*/ + */ void set_subtitles(s32 setting) { gSubtitleSetting = setting; } /** * Render currently active subtitles on the screen. -*/ + */ void render_subtitles(void) { s32 textX; s32 textY; @@ -109,7 +109,6 @@ void render_subtitles(void) { set_current_text_background_colour(6, 0, 0, 0, 0); textY = ((((gDialogueYPos2 - gDialogueYPos1) - (gSubtitleLineCount * 12)) - (gSubtitleLineCount * 2)) + 2) >> 1; - for (i = 0; i < gSubtitleLineCount; i++) { textData = &gSubtitleProperties[0]; set_dialogue_font(6, (s32) textData[i][TEXT_FONT]); @@ -123,7 +122,8 @@ void render_subtitles(void) { textX = 8; } } - set_current_text_colour(6, textData[i][TEXT_COL_R], textData[i][TEXT_COL_G], textData[i][TEXT_COL_B], 255, (textData[i][TEXT_ALPHA] * gDialogueAlpha) >> 8); + set_current_text_colour(6, textData[i][TEXT_COL_R], textData[i][TEXT_COL_G], textData[i][TEXT_COL_B], 255, + (textData[i][TEXT_ALPHA] * gDialogueAlpha) >> 8); render_dialogue_text(6, textX, textY, textData[i] + 8, 1, textFlags); set_current_text_colour(6, 0, 0, 0, 255, (gDialogueAlpha * 255) >> 8); render_dialogue_text(6, textX + 1, textY + 1, textData[i] + 8, 1, textFlags); @@ -135,13 +135,13 @@ void render_subtitles(void) { /** * Get the line count and text timer from the next message of the subtitle. * Close the subtitles if none can be found. -*/ + */ void find_next_subtitle(void) { u32 new_var3; u8 new_var; s32 new_var2; s32 done; - + gSubtitleLineCount = 0; gSubtitleTimer = 0; done = FALSE; @@ -172,14 +172,14 @@ void find_next_subtitle(void) { } } if (gSubtitleLineCount > 0) { - gShowSubtitles = TRUE; + gShowSubtitles = TRUE; } } /** * Handle the subtitle system from here. * Slowly show the text, tick down the timer, find the next message or close the box, then render. -*/ + */ void process_subtitles(s32 updateRate) { if (gSubtitleSetting == FALSE) { gShowSubtitles = FALSE; @@ -212,7 +212,7 @@ void process_subtitles(s32 updateRate) { /** * Load the text table into RAM. * Assign the entries to a pointer table, then calculate the number of entries. -*/ + */ void load_game_text_table(void) { D_8012A78C = -1; gGameTextTable[0] = (GameTextTableStruct *) allocate_from_main_pool_safe(0x800, COLOUR_TAG_GREEN); @@ -243,21 +243,21 @@ void free_game_text_table(void) { /** * Set the variable used by the message boxes when trying to display an arbitrary number. -*/ + */ void set_textbox_display_value(s32 num) { gTextDisplayNumber = num; } /** * Sets the delayed text timer back to 0. -*/ + */ void reset_delayed_text(void) { gTextboxDelay = 0; } /** * Set the delayed text ID and delay (in seconds) -*/ + */ void set_delayed_text(s32 textID, f32 delay) { if (osTvType == TV_TYPE_PAL) { gTextboxDelay = delay * 50.0; @@ -269,44 +269,46 @@ void set_delayed_text(s32 textID, f32 delay) { /** * Set the current text index based on the entry. - * Start certain behaviours based on the header, + * Start certain behaviours based on the header, * like showing a subtitle, or opening an onscreen text box. -*/ + */ void set_current_text(s32 textID) { char **entries; UNUSED s32 pad; s32 size; s32 language; s32 temp; - + if (gTextTableExists && textID >= 0 && textID < gTextTableEntries) { language = get_language(); switch (language) { - case LANGUAGE_GERMAN: - textID += 85; - break; - case LANGUAGE_FRENCH: - textID += 170; - break; - case LANGUAGE_JAPANESE: - textID += 255; - break; + case LANGUAGE_GERMAN: + textID += 85; + break; + case LANGUAGE_FRENCH: + textID += 170; + break; + case LANGUAGE_JAPANESE: + textID += 255; + break; } load_asset_to_address(ASSET_GAME_TEXT_TABLE, (u32) (*gGameTextTable)->entries, (textID & (~1)) << 2, 16); - + entries = (*gGameTextTable)->entries; temp = ((s32) entries[textID & 1]) & 0xFF000000; size = (((s32) entries[(textID & 1) + 1]) & 0xFFFFFF) - (((s32) entries[textID & 1]) & 0xFFFFFF); - + if (temp) { - load_asset_to_address(ASSET_GAME_TEXT, (u32) gCurrentMessageText[D_8012A7D4], ((s32) entries[textID & 1]) ^ temp, size); + load_asset_to_address(ASSET_GAME_TEXT, (u32) gCurrentMessageText[D_8012A7D4], + ((s32) entries[textID & 1]) ^ temp, size); gCurrentTextProperties = gCurrentMessageText[D_8012A7D4]; find_next_subtitle(); D_8012A7D4 = (D_8012A7D4 + 1) & 1; return; } - load_asset_to_address(ASSET_GAME_TEXT, (u32) gGameTextTableEntries[D_8012A7A4], ((s32) entries[textID & 1]) ^ temp, size); + load_asset_to_address(ASSET_GAME_TEXT, (u32) gGameTextTableEntries[D_8012A7A4], + ((s32) entries[textID & 1]) ^ temp, size); D_8012A7A0 = gGameTextTableEntries[D_8012A7A4]; D_8012A7A4 = (D_8012A7A4 + 1) & 1; D_8012A788 = 0; @@ -340,7 +342,7 @@ s32 func_800C3400(void) { /** * Top level function for handling message boxes and dialogue. * Calls a function too, to load in text entries when needed. -*/ + */ void process_onscreen_textbox(s32 updateRate) { if (gTextTableExists) { if (!is_game_paused()) { @@ -386,13 +388,13 @@ s32 dialogue_challenge_loop(void) { textBox.textColBlue = 0; textBox.textColAlpha = 0; SET_TEXTBOX_TEXT_POS_AND_LINEHEIGHT(5, 10, 15); - + set_current_dialogue_box_coords(1, textBox.left, textBox.top, textBox.right, textBox.bottom); set_dialogue_font(1, textBox.font); set_current_dialogue_background_colour(1, 0, 16, 16, 128); - set_current_text_colour(1, textBox.textColRed, textBox.textColGreen, textBox.textColBlue, textBox.textColAlpha, 255); + set_current_text_colour(1, textBox.textColRed, textBox.textColGreen, textBox.textColBlue, textBox.textColAlpha, + 255); - for (index = 0, numberOfOnes = 0; D_8012A78E != numberOfOnes && D_8012A7A0[index] != 2; index++) { if (D_8012A7A0[index] >= 3 && D_8012A7A0[index] < 13) { index = func_800C38B4(index, &textBox); @@ -404,7 +406,7 @@ s32 dialogue_challenge_loop(void) { if (D_8012A7A0[index] >= 3 && D_8012A7A0[index] < 13) { index = func_800C38B4(index, &textBox); } - + keepLooping = TRUE; do { if (textBox.textFlags == 0) { @@ -454,80 +456,81 @@ s32 func_800C38B4(s32 arg0, TextBox *textbox) { var_s0 = &D_8012A7A0[arg0]; while (var_s0[0] >= 3 && var_s0[0] < 13) { switch (var_s0[0] - 3) { - case 0: - textbox->font = var_s0[1]; - arg0 += 2; - set_dialogue_font(1, textbox->font); - var_s0 = &D_8012A7A0[arg0]; - break; - case 1: - textbox->left = var_s0[1] & 0xFF; - textbox->top = D_8012A7A0[arg0 + 2] & 0xFF; - if (osTvType == TV_TYPE_PAL) { - temp = textbox->top; - textbox->top = (textbox->top * 264) / 240; - temp = textbox->top - temp; - } else { - temp = 0; - } - textbox->right = (D_8012A7A0[arg0 + 3] & 0xFF) + 65; - textbox->bottom = (D_8012A7A0[arg0 + 4] & 0xFF) + temp; - arg0 += 5; - set_current_dialogue_box_coords(1, textbox->left, textbox->top, textbox->right, textbox->bottom); - var_s0 = &D_8012A7A0[arg0]; - break; - case 2: - textbox->textColRed = var_s0[1]; - textbox->textColGreen = D_8012A7A0[arg0 + 2]; - textbox->textColBlue = D_8012A7A0[arg0 + 3]; - textbox->textColAlpha = D_8012A7A0[arg0 + 4]; - arg0 += 5; - set_current_text_colour(1, textbox->textColRed, textbox->textColGreen, textbox->textColBlue, textbox->textColAlpha, 255); - var_s0 = &D_8012A7A0[arg0]; - break; - case 3: - if (var_s0[1] == 0) { - textbox->textFlags = 4; - } else { - textbox->textFlags = 0; - } - arg0 += 2; - var_s0 = &D_8012A7A0[arg0]; - break; - case 4: - arg0 += 2; - textbox->textX = var_s0[1]; - var_s0 = &D_8012A7A0[arg0]; - break; - case 5: - arg0 += 2; - textbox->textY += var_s0[1]; - var_s0 = &D_8012A7A0[arg0]; - break; - case 6: - arg0 += 2; - textbox->lineHeight = var_s0[1]; - var_s0 = &D_8012A7A0[arg0]; - break; - case 7: - if (gTextCloseTimerSeconds == 0) { - gTextCloseTimerSeconds = var_s0[1] & 0xFF; - gTextCloseTimerFrames = normalise_time(60); + case 0: + textbox->font = var_s0[1]; + arg0 += 2; + set_dialogue_font(1, textbox->font); var_s0 = &D_8012A7A0[arg0]; - } - arg0 += 2; - var_s0 += 2; - break; - case 8: - arg0 += 2; - D_8012A787 = var_s0[1]; - var_s0 += 2; - break; - case 9: - arg0 += 2; - D_8012A788 = var_s0[1]; - var_s0 += 2; - break; + break; + case 1: + textbox->left = var_s0[1] & 0xFF; + textbox->top = D_8012A7A0[arg0 + 2] & 0xFF; + if (osTvType == TV_TYPE_PAL) { + temp = textbox->top; + textbox->top = (textbox->top * 264) / 240; + temp = textbox->top - temp; + } else { + temp = 0; + } + textbox->right = (D_8012A7A0[arg0 + 3] & 0xFF) + 65; + textbox->bottom = (D_8012A7A0[arg0 + 4] & 0xFF) + temp; + arg0 += 5; + set_current_dialogue_box_coords(1, textbox->left, textbox->top, textbox->right, textbox->bottom); + var_s0 = &D_8012A7A0[arg0]; + break; + case 2: + textbox->textColRed = var_s0[1]; + textbox->textColGreen = D_8012A7A0[arg0 + 2]; + textbox->textColBlue = D_8012A7A0[arg0 + 3]; + textbox->textColAlpha = D_8012A7A0[arg0 + 4]; + arg0 += 5; + set_current_text_colour(1, textbox->textColRed, textbox->textColGreen, textbox->textColBlue, + textbox->textColAlpha, 255); + var_s0 = &D_8012A7A0[arg0]; + break; + case 3: + if (var_s0[1] == 0) { + textbox->textFlags = 4; + } else { + textbox->textFlags = 0; + } + arg0 += 2; + var_s0 = &D_8012A7A0[arg0]; + break; + case 4: + arg0 += 2; + textbox->textX = var_s0[1]; + var_s0 = &D_8012A7A0[arg0]; + break; + case 5: + arg0 += 2; + textbox->textY += var_s0[1]; + var_s0 = &D_8012A7A0[arg0]; + break; + case 6: + arg0 += 2; + textbox->lineHeight = var_s0[1]; + var_s0 = &D_8012A7A0[arg0]; + break; + case 7: + if (gTextCloseTimerSeconds == 0) { + gTextCloseTimerSeconds = var_s0[1] & 0xFF; + gTextCloseTimerFrames = normalise_time(60); + var_s0 = &D_8012A7A0[arg0]; + } + arg0 += 2; + var_s0 += 2; + break; + case 8: + arg0 += 2; + D_8012A787 = var_s0[1]; + var_s0 += 2; + break; + case 9: + arg0 += 2; + D_8012A788 = var_s0[1]; + var_s0 += 2; + break; } } return arg0; diff --git a/src/game_text.h b/src/game_text.h index b4e74f02..745fdca1 100644 --- a/src/game_text.h +++ b/src/game_text.h @@ -53,15 +53,15 @@ typedef struct TextBox { void init_dialogue_text(void); void free_message_box(void); -void set_subtitles(s32 arg0); -void process_subtitles(s32 arg0); +void set_subtitles(s32 setting); +void process_subtitles(s32 updateRate); void load_game_text_table(void); void free_game_text_table(void); -void set_textbox_display_value(s32 arg0); +void set_textbox_display_value(s32 num); void reset_delayed_text(void); -void set_delayed_text(s32 arg0, f32 arg1); +void set_delayed_text(s32 textID, f32 delay); s32 func_800C3400(void); -void process_onscreen_textbox(s32 arg0); +void process_onscreen_textbox(s32 updateRate); void find_next_subtitle(void); s32 func_800C38B4(s32 arg0, TextBox *textbox); void render_subtitles(void); diff --git a/src/game_ui.c b/src/game_ui.c index 00fb8f6f..e7d6031b 100644 --- a/src/game_ui.c +++ b/src/game_ui.c @@ -90,35 +90,24 @@ unk800E1E64 D_800E1E64[59] = { }; u16 D_800E25C4[96] = { - 0x0000, 0x0035, 0x0010, 0x0001, 0x0036, 0x0012, 0x0004, 0x00CB, - 0x0013, 0x0005, 0x00D3, 0x0013, 0x0006, 0x00DC, 0x0013, 0x0002, - 0xFF88, 0xFFE1, 0x001B, 0x0021, 0x0016, 0x0008, 0x00D3, 0x0013, - 0x0009, 0x00DC, 0x0013, 0x000B, 0x00A7, 0x0013, 0x000E, 0x0000, - 0x000A, 0x0010, 0x003B, 0x0023, 0x0011, 0x003B, 0x0023, 0x0007, - 0x0021, 0x0016, 0x001C, 0x001E, 0x002A, 0x0012, 0x00CA, 0x0013, - 0x000D, 0x0000, 0x000A, 0x000C, 0x0000, 0x000A, 0x0023, 0x0000, - 0x000A, 0x0024, 0x0000, 0x000A, 0x001E, 0x0000, 0x000A, 0x001F, - 0x0000, 0x000A, 0x001D, 0x0000, 0x000A, 0x002F, 0xFF38, 0x0023, - 0x0030, 0xFF51, 0x0025, 0x0031, 0xFF96, 0xFFD3, 0x0003, 0x00B4, - 0x0013, 0x0032, 0x0107, 0x0011, 0x0020, 0x00F7, 0x002D, 0x0033, - 0x0103, 0x0031, 0x002E, 0x0022, 0x0047, 0xFFFF, 0xFFFF, 0xFFFF, + 0x0000, 0x0035, 0x0010, 0x0001, 0x0036, 0x0012, 0x0004, 0x00CB, 0x0013, 0x0005, 0x00D3, 0x0013, 0x0006, 0x00DC, + 0x0013, 0x0002, 0xFF88, 0xFFE1, 0x001B, 0x0021, 0x0016, 0x0008, 0x00D3, 0x0013, 0x0009, 0x00DC, 0x0013, 0x000B, + 0x00A7, 0x0013, 0x000E, 0x0000, 0x000A, 0x0010, 0x003B, 0x0023, 0x0011, 0x003B, 0x0023, 0x0007, 0x0021, 0x0016, + 0x001C, 0x001E, 0x002A, 0x0012, 0x00CA, 0x0013, 0x000D, 0x0000, 0x000A, 0x000C, 0x0000, 0x000A, 0x0023, 0x0000, + 0x000A, 0x0024, 0x0000, 0x000A, 0x001E, 0x0000, 0x000A, 0x001F, 0x0000, 0x000A, 0x001D, 0x0000, 0x000A, 0x002F, + 0xFF38, 0x0023, 0x0030, 0xFF51, 0x0025, 0x0031, 0xFF96, 0xFFD3, 0x0003, 0x00B4, 0x0013, 0x0032, 0x0107, 0x0011, + 0x0020, 0x00F7, 0x002D, 0x0033, 0x0103, 0x0031, 0x002E, 0x0022, 0x0047, 0xFFFF, 0xFFFF, 0xFFFF, }; u16 D_800E2684[118] = { - 0x0000, 0x002D, 0x0010, 0x0087, 0x0004, 0x005E, 0x0013, 0x004E, - 0x0005, 0x0066, 0x0013, 0x0056, 0x0006, 0x006F, 0x0013, 0x005F, - 0x0002, 0xFFD1, 0xFFDC, 0x0024, 0x001B, 0x0000, 0x0016, 0xFFE3, - 0x0007, 0x0000, 0x0016, 0xFFE3, 0x0008, 0x0061, 0x0013, 0x0044, - 0x0009, 0x006A, 0x0013, 0x004D, 0x000B, 0x0037, 0x0013, 0x001A, - 0x000C, 0x0000, 0x000A, 0x0000, 0x000D, 0x0000, 0x000A, 0x0000, - 0x000E, 0xFF60, 0x000A, 0xFF60, 0x0010, 0x0066, 0x0013, 0x0056, - 0x0011, 0x0066, 0x0013, 0x0056, 0x0012, 0x0058, 0x0013, 0x003B, - 0x001C, 0xFFFD, 0x002A, 0xFFE0, 0x0020, 0x0012, 0x002D, 0x0078, - 0x001E, 0xFFEA, 0x000A, 0xFFEA, 0x001F, 0x000C, 0x000A, 0x0010, - 0x001D, 0x0000, 0x000A, 0xFFD9, 0x0023, 0x0000, 0x000A, 0x0000, - 0x0024, 0x0000, 0x000A, 0x0000, 0x002F, 0xFF38, 0x0019, 0xFFD8, - 0x0030, 0xFF51, 0x001B, 0xFFF1, 0x0031, 0xFFDF, 0xFFCE, 0x0032, - 0x0003, 0x0047, 0x0013, 0x0037, 0x0033, 0x003C, 0x0014, 0x003C, + 0x0000, 0x002D, 0x0010, 0x0087, 0x0004, 0x005E, 0x0013, 0x004E, 0x0005, 0x0066, 0x0013, 0x0056, 0x0006, 0x006F, + 0x0013, 0x005F, 0x0002, 0xFFD1, 0xFFDC, 0x0024, 0x001B, 0x0000, 0x0016, 0xFFE3, 0x0007, 0x0000, 0x0016, 0xFFE3, + 0x0008, 0x0061, 0x0013, 0x0044, 0x0009, 0x006A, 0x0013, 0x004D, 0x000B, 0x0037, 0x0013, 0x001A, 0x000C, 0x0000, + 0x000A, 0x0000, 0x000D, 0x0000, 0x000A, 0x0000, 0x000E, 0xFF60, 0x000A, 0xFF60, 0x0010, 0x0066, 0x0013, 0x0056, + 0x0011, 0x0066, 0x0013, 0x0056, 0x0012, 0x0058, 0x0013, 0x003B, 0x001C, 0xFFFD, 0x002A, 0xFFE0, 0x0020, 0x0012, + 0x002D, 0x0078, 0x001E, 0xFFEA, 0x000A, 0xFFEA, 0x001F, 0x000C, 0x000A, 0x0010, 0x001D, 0x0000, 0x000A, 0xFFD9, + 0x0023, 0x0000, 0x000A, 0x0000, 0x0024, 0x0000, 0x000A, 0x0000, 0x002F, 0xFF38, 0x0019, 0xFFD8, 0x0030, 0xFF51, + 0x001B, 0xFFF1, 0x0031, 0xFFDF, 0xFFCE, 0x0032, 0x0003, 0x0047, 0x0013, 0x0037, 0x0033, 0x003C, 0x0014, 0x003C, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0x0000, }; @@ -129,16 +118,9 @@ unk800E2770 D_800E2770[2] = { u8 gShowCourseDirections = TRUE; -u8 D_800E2794[4][4] = { - {1, 1, 1, 1}, - {2, 2, 2, 2}, - {2, 2, 2, 2}, - {2, 2, 2, 2} -}; +u8 D_800E2794[4][4] = { { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 2, 2, 2, 2 }, { 2, 2, 2, 2 } }; -s8 gHudToggleSettings[4] = { - 1, 1, 1, 1 -}; +s8 gHudToggleSettings[4] = { 1, 1, 1, 1 }; s8 D_800E27A8 = 1; @@ -151,46 +133,13 @@ u32 D_800E27AC[3] = { u8 D_800E27B8 = 0; ByteColour gHudMinimapColours[40] = { - { 255, 160, 0 }, - { 255, 255, 0 }, - { 0, 128, 255 }, - { 255, 255, 255 }, - { 0, 175, 0 }, - { 0, 255, 128 }, - { 255, 0, 0 }, - { 255, 128, 190 }, - { 128, 128, 128 }, - { 0, 0, 255 }, - { 0, 0, 0 }, - { 0, 0, 0 }, - { 0, 0, 0 }, - { 0, 0, 0 }, - { 0, 0, 0 }, - { 32, 0, 0 }, - { 0, 0, 0 }, - { 0, 0, 64 }, - { 0, 0, 0 }, - { 0, 0, 0 }, - { 0, 96, 0 }, - { 0, 0, 0 }, - { 0, 0, 0 }, - { 128, 0, 0 }, - { 0, 0, 0 }, - { 0, 0, 0 }, - { 0, 64, 0 }, - { 0, 0, 0 }, - { 0, 32, 0 }, - { 64, 0, 0 }, - { 0, 0, 0 }, - { 64, 0, 64 }, - { 0, 0, 0 }, - { 0, 0, 96 }, - { 0, 64, 0 }, - { 0, 0, 0 }, - { 0, 128, 0 }, - { 64, 0, 0 }, - { 0, 0, 0 }, - { 0, 0, 0 }, + { 255, 160, 0 }, { 255, 255, 0 }, { 0, 128, 255 }, { 255, 255, 255 }, { 0, 175, 0 }, { 0, 255, 128 }, + { 255, 0, 0 }, { 255, 128, 190 }, { 128, 128, 128 }, { 0, 0, 255 }, { 0, 0, 0 }, { 0, 0, 0 }, + { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 32, 0, 0 }, { 0, 0, 0 }, { 0, 0, 64 }, + { 0, 0, 0 }, { 0, 0, 0 }, { 0, 96, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 128, 0, 0 }, + { 0, 0, 0 }, { 0, 0, 0 }, { 0, 64, 0 }, { 0, 0, 0 }, { 0, 32, 0 }, { 64, 0, 0 }, + { 0, 0, 0 }, { 64, 0, 64 }, { 0, 0, 0 }, { 0, 0, 96 }, { 0, 64, 0 }, { 0, 0, 0 }, + { 0, 128, 0 }, { 64, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, }; u32 gHudColour = COLOUR_RGBA32(255, 255, 255, 254); @@ -198,9 +147,7 @@ u32 gHudColour = COLOUR_RGBA32(255, 255, 255, 254); f32 D_800E2838 = 0.0f; // Unused? -s32 D_800E283C[5] = { - 0x06FFFFFF, 0x000FFFFF, 0x06000000, 0x0014FFFF, 0x00000000 -}; +s32 D_800E283C[5] = { 0x06FFFFFF, 0x000FFFFF, 0x06000000, 0x0014FFFF, 0x00000000 }; /*******************************/ @@ -221,13 +168,13 @@ s8 D_80126CD3; * - 3->4 on the "Go" voice and text * - 4->5 on the "Go" sliding off screen * - stays 5 until the next race starts -*/ + */ s8 gRaceStartShowHudStep; s8 D_80126CD5; u8 *gAssetHudElementStaleCounter; unk80126CDC *gCurrentHud; -unk80126CDC *gPlayerHud[MAXCONTROLLERS]; //One per active player +unk80126CDC *gPlayerHud[MAXCONTROLLERS]; // One per active player s16 *gAssetHudElementIds; HudElements *gAssetHudElements; s32 gAssetHudElementIdsCount; @@ -294,7 +241,7 @@ u8 gGfxTaskYieldData[OS_YIELD_DATA_SIZE]; /** * Load basic hud assets and allocate HUD data for each player. * Set up the global hud elements and reset global vars. -*/ + */ void init_hud(UNUSED s32 viewportCount) { s32 i; s32 playerCount; @@ -303,23 +250,27 @@ void init_hud(UNUSED s32 viewportCount) { gNumActivePlayers = set_active_viewports_and_max(gHUDNumPlayers); gHudSettings = get_settings(); gHudSilverCoinRace = check_if_silver_coin_race(); - gAssetHudElementIds = (s16 *) load_asset_section_from_rom(ASSET_HUD_ELEMENT_IDS); + gAssetHudElementIds = (s16 *) load_asset_section_from_rom(ASSET_HUD_ELEMENT_IDS); gAssetHudElementIdsCount = 0; - - while(gAssetHudElementIds[gAssetHudElementIdsCount] != -1) { + + while (gAssetHudElementIds[gAssetHudElementIdsCount] != -1) { gAssetHudElementIdsCount++; } gAssetHudElements = allocate_from_main_pool_safe(gAssetHudElementIdsCount * (sizeof(void *) + 1), COLOUR_TAG_BLUE); // Evil pointer shenanigans to store the timer in that last byte in the struct above. gAssetHudElementStaleCounter = (u8 *) ((gAssetHudElementIdsCount + (s32 *) gAssetHudElements)); - for(i = 0; i < gAssetHudElementIdsCount; i++) { + for (i = 0; i < gAssetHudElementIdsCount; i++) { gAssetHudElementStaleCounter[i] = 0; gAssetHudElements->entry[i] = NULL; } - gAssetHudElements->entry[HUD_ELEMENT_UNK_01] = func_8007C12C(gAssetHudElementIds[HUD_ELEMENT_UNK_01] & 0x3FFF, 1); //ID: 86 - 0x56 - gAssetHudElements->entry[HUD_ELEMENT_UNK_17] = func_8007C12C(gAssetHudElementIds[HUD_ELEMENT_UNK_17] & 0x3FFF, 1); //ID: 291 - 0x123 - gAssetHudElements->entry[HUD_ELEMENT_UNK_08] = func_8007C12C(gAssetHudElementIds[HUD_ELEMENT_UNK_08] & 0x3FFF, 1); //ID: 156 - 0x9C - gAssetHudElements->entry[HUD_ELEMENT_UNK_11] = func_8007C12C(gAssetHudElementIds[HUD_ELEMENT_UNK_11] & 0x3FFF, 1); //ID: 60 - 0x3C + gAssetHudElements->entry[HUD_ELEMENT_UNK_01] = + func_8007C12C(gAssetHudElementIds[HUD_ELEMENT_UNK_01] & 0x3FFF, 1); // ID: 86 - 0x56 + gAssetHudElements->entry[HUD_ELEMENT_UNK_17] = + func_8007C12C(gAssetHudElementIds[HUD_ELEMENT_UNK_17] & 0x3FFF, 1); // ID: 291 - 0x123 + gAssetHudElements->entry[HUD_ELEMENT_UNK_08] = + func_8007C12C(gAssetHudElementIds[HUD_ELEMENT_UNK_08] & 0x3FFF, 1); // ID: 156 - 0x9C + gAssetHudElements->entry[HUD_ELEMENT_UNK_11] = + func_8007C12C(gAssetHudElementIds[HUD_ELEMENT_UNK_11] & 0x3FFF, 1); // ID: 60 - 0x3C if (gNumActivePlayers != 3) { playerCount = gNumActivePlayers; } else { @@ -348,7 +299,7 @@ void init_hud(UNUSED s32 viewportCount) { func_8007F1E8(D_80127194); set_sound_channel_volume(0, 32767); set_sound_channel_volume(2, 32767); - for(i = 0; i < 2; i++){ + for (i = 0; i < 2; i++) { D_800E2770[i].volume = 0; D_800E2770[i].unk3 = 0; D_800E2770[i].playerIndex = PLAYER_COMPUTER; @@ -393,7 +344,7 @@ u8 func_800A0190(void) { /** * The root function for all of the heads up display during an active event. * Branches off to its own function for each race type, but overridden completely in time trial. -*/ + */ void render_hud(Gfx **dList, MatrixS **mtx, Vertex **vertexList, Object *arg3, s32 updateRate) { s32 sp2C; Object_Racer *racer; @@ -435,7 +386,10 @@ void render_hud(Gfx **dList, MatrixS **mtx, Vertex **vertexList, Object *arg3, s gCurrentHud = gPlayerHud[gHudCurrentViewport]; if (get_cutscene_id() != 10) { if (gHUDNumPlayers == ONE_PLAYER) { - if (get_buttons_pressed_from_player(D_80126D10) & D_CBUTTONS && racer->raceFinished == FALSE && ((gHudLevelHeader->race_type == RACETYPE_DEFAULT) || gHudLevelHeader->race_type == RACETYPE_HORSESHOE_GULCH) && D_80126D34) { + if (get_buttons_pressed_from_player(D_80126D10) & D_CBUTTONS && racer->raceFinished == FALSE && + ((gHudLevelHeader->race_type == RACETYPE_DEFAULT) || + gHudLevelHeader->race_type == RACETYPE_HORSESHOE_GULCH) && + D_80126D34) { gShowCourseDirections = 1 - gShowCourseDirections; sound_play((SOUND_TING_HIGHER + gShowCourseDirections), NULL); if (gShowCourseDirections) { @@ -444,15 +398,18 @@ void render_hud(Gfx **dList, MatrixS **mtx, Vertex **vertexList, Object *arg3, s D_800E27B8 = 0; } } - } else if (get_buttons_pressed_from_player(D_80126D10) & D_CBUTTONS && racer->raceFinished == FALSE && !(gHudLevelHeader->race_type & RACETYPE_CHALLENGE) && D_80126D34) { + } else if (get_buttons_pressed_from_player(D_80126D10) & D_CBUTTONS && + racer->raceFinished == FALSE && !(gHudLevelHeader->race_type & RACETYPE_CHALLENGE) && + D_80126D34) { if (D_800E2794[gHUDNumPlayers][racer->playerIndex] < PLAYER_FOUR) { - D_800E2794[gHUDNumPlayers][racer->playerIndex]++; + D_800E2794[gHUDNumPlayers][racer->playerIndex]++; } else { - D_800E2794[gHUDNumPlayers][racer->playerIndex] = PLAYER_ONE; + D_800E2794[gHUDNumPlayers][racer->playerIndex] = PLAYER_ONE; } sound_play((SOUND_TING_HIGHEST - (D_800E2794[gHUDNumPlayers][racer->playerIndex] == 0)), NULL); } - if (get_buttons_pressed_from_player(D_80126D10) & R_CBUTTONS && racer->raceFinished == FALSE && D_80126D34 && D_80126CD0 == 0) { + if (get_buttons_pressed_from_player(D_80126D10) & R_CBUTTONS && racer->raceFinished == FALSE && + D_80126D34 && D_80126CD0 == 0) { gHudToggleSettings[gHUDNumPlayers] = 1 - gHudToggleSettings[gHUDNumPlayers]; if (gHudToggleSettings[gHUDNumPlayers] == 0) { sound_play(SOUND_TING_LOW, NULL); @@ -462,7 +419,10 @@ void render_hud(Gfx **dList, MatrixS **mtx, Vertex **vertexList, Object *arg3, s } } if (gRaceStartShowHudStep == 0) { - if (gHudLevelHeader->race_type & RACETYPE_CHALLENGE || gHudLevelHeader->race_type == RACETYPE_DEFAULT || gHudLevelHeader->race_type == RACETYPE_HORSESHOE_GULCH || gHudLevelHeader->race_type == RACETYPE_BOSS) { + if (gHudLevelHeader->race_type & RACETYPE_CHALLENGE || + gHudLevelHeader->race_type == RACETYPE_DEFAULT || + gHudLevelHeader->race_type == RACETYPE_HORSESHOE_GULCH || + gHudLevelHeader->race_type == RACETYPE_BOSS) { D_800E2770[0].volume = 127; D_800E2770[1].volume = 127; music_stop(); @@ -480,7 +440,8 @@ void render_hud(Gfx **dList, MatrixS **mtx, Vertex **vertexList, Object *arg3, s tex_enable_modes(RENDER_ALL); tex_disable_modes(RENDER_Z_COMPARE); sprite_opaque(FALSE); - if (check_if_showing_cutscene_camera() == FALSE && D_80126D34 == FALSE && racer->playerIndex == PLAYER_ONE) { + if (check_if_showing_cutscene_camera() == FALSE && D_80126D34 == FALSE && + racer->playerIndex == PLAYER_ONE) { if (D_80126D35 != 0) { D_80126D28 = sins_f(D_80126D2C) * D_80126D30 * 8.0f; D_80126D2C += updateRate << 0xB; @@ -559,10 +520,10 @@ void render_hud(Gfx **dList, MatrixS **mtx, Vertex **vertexList, Object *arg3, s } goto block_95; } -showFinish: + showFinish: render_race_finish_position(racer, updateRate); } else { -block_95: + block_95: func_800A6254(racer, updateRate); } func_80068508(FALSE); @@ -606,7 +567,7 @@ void func_800A0BD4(s32 updateRate) { } } } - for(i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { if (D_800E2770[i].volume) { if (D_800E2770[i].soundMask == NULL) { sound_play(D_800E2770[i].soundID, (s32 *) &D_800E2770[i].soundMask); @@ -650,7 +611,7 @@ void func_800A0BD4(s32 updateRate) { /** * In a race, render all of the race related HUD. -*/ + */ void render_hud_race(s32 arg0, Object *obj, s32 updateRate) { Object_Racer *racer = &obj->unk64->racer; @@ -678,7 +639,7 @@ void render_hud_race(s32 arg0, Object *obj, s32 updateRate) { /** * Render the onscreen course arrows that show the player where to go. -*/ + */ void render_course_indicator_arrows(Object_Racer *racer, s32 updateRate) { s32 timer; s32 type; @@ -692,49 +653,50 @@ void render_course_indicator_arrows(Object_Racer *racer, s32 updateRate) { if (type) { indicator = (IndicatorArrow *) &gCurrentHud->courseIndicator; switch (type) { - case INDICATOR_LEFT: - indicator->textureID = 33; - indicator->unk0 = 0; - break; - case INDICATOR_LEFT_SHARP: - indicator->textureID = 32; - indicator->unk0 = 0; - break; - case INDICATOR_LEFT_UTURN: - indicator->textureID = 31; - indicator->unk0 = 0; - break; - case INDICATOR_RIGHT: - indicator->textureID = 33; - indicator->unk0 = -0x8000; - break; - case INDICATOR_RIGHT_SHARP: - indicator->textureID = 32; - indicator->unk0 = -0x8000; - break; - case INDICATOR_RIGHT_UTURN: - indicator->textureID = 31; - indicator->unk0 = -0x8000; - break; - case INDICATOR_UP: - indicator->textureID = 30; - indicator->unk0 = -0x8000; - indicator->unk2 = -0x8000; - break; - case INDICATOR_DOWN: - indicator->textureID = 30; - indicator->unk0 = 0; - break; - default: // INDICATOR_EXCLAMATION - indicator->textureID = 29; - indicator->unk0 = 0; - break; + case INDICATOR_LEFT: + indicator->textureID = 33; + indicator->unk0 = 0; + break; + case INDICATOR_LEFT_SHARP: + indicator->textureID = 32; + indicator->unk0 = 0; + break; + case INDICATOR_LEFT_UTURN: + indicator->textureID = 31; + indicator->unk0 = 0; + break; + case INDICATOR_RIGHT: + indicator->textureID = 33; + indicator->unk0 = -0x8000; + break; + case INDICATOR_RIGHT_SHARP: + indicator->textureID = 32; + indicator->unk0 = -0x8000; + break; + case INDICATOR_RIGHT_UTURN: + indicator->textureID = 31; + indicator->unk0 = -0x8000; + break; + case INDICATOR_UP: + indicator->textureID = 30; + indicator->unk0 = -0x8000; + indicator->unk2 = -0x8000; + break; + case INDICATOR_DOWN: + indicator->textureID = 30; + indicator->unk0 = 0; + break; + default: // INDICATOR_EXCLAMATION + indicator->textureID = 29; + indicator->unk0 = 0; + break; } // Flip the arrow direction on adventure 2. if (get_filtered_cheats() & CHEAT_MIRRORED_TRACKS && racer->indicator_type < 30) { indicator->unk0 = (s16) (0x8000 - indicator->unk0); } - if (gHUDNumPlayers == ONE_PLAYER && racer->raceFinished == FALSE && racer->indicator_type && D_800E27B8 == 0) { + if (gHUDNumPlayers == ONE_PLAYER && racer->raceFinished == FALSE && racer->indicator_type && + D_800E27B8 == 0) { gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, 255, 255, 255, 160); func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) indicator); indicator->unkC = -indicator->unkC; @@ -775,7 +737,7 @@ void render_course_indicator_arrows(Object_Racer *racer, s32 updateRate) { /* * Renders the HUD for the Smokey Castle challenge. * Shows each players portrait and their aquired treasure. -*/ + */ void render_hud_banana_challenge(s32 arg0, Object *obj, s32 updateRate) { Object_Racer *racer; Object **racers; @@ -787,25 +749,25 @@ void render_hud_banana_challenge(s32 arg0, Object *obj, s32 updateRate) { func_80068508(TRUE); render_race_start(arg0, updateRate); switch (gNumActivePlayers) { - case 1: - for (i = 0; i < numRacers; i++) { - racer = &racers[i]->unk64->racer; - render_treasure_hud(racer); - if (i == 1) { + case 1: + for (i = 0; i < numRacers; i++) { + racer = &racers[i]->unk64->racer; + render_treasure_hud(racer); + if (i == 1) { + gCurrentHud->unk64C += 55.0f; + gCurrentHud->unk40C += 55.0f; + } gCurrentHud->unk64C += 55.0f; gCurrentHud->unk40C += 55.0f; } - gCurrentHud->unk64C += 55.0f; - gCurrentHud->unk40C += 55.0f; - } - if (1) {} // Fakematch - gCurrentHud->unk64C -= 275.0f; - gCurrentHud->unk40C -= 275.0f; - break; - case 3: - case 4: - render_treasure_hud(racer); - break; + if (1) {} // Fakematch + gCurrentHud->unk64C -= 275.0f; + gCurrentHud->unk40C -= 275.0f; + break; + case 3: + case 4: + render_treasure_hud(racer); + break; } racer = &obj->unk64->racer; reset_render_settings(&gHUDCurrDisplayList); @@ -816,7 +778,7 @@ void render_hud_banana_challenge(s32 arg0, Object *obj, s32 updateRate) { /** * The Egg Collector challenge mode displays the icons of each player and their score. -*/ + */ void render_hud_challenge_eggs(s32 arg0, Object *obj, s32 updateRate) { Object_Racer *racer = &obj->unk64->racer; if (racer->raceFinished == FALSE) { @@ -850,9 +812,9 @@ void func_800A14F0(Object *racerObj, s32 updateRate) { racers = get_racer_objects(&numRacers); if (gNumActivePlayers == 2) { numOfFinishedPlayers = 0; - for(i = 0; i < numRacers; i++) { + for (i = 0; i < numRacers; i++) { curRacer = &racers[i]->unk64->racer; - if(curRacer->playerIndex != -1 && curRacer->raceFinished) { + if (curRacer->playerIndex != -1 && curRacer->raceFinished) { numOfFinishedPlayers++; } } @@ -871,7 +833,7 @@ void func_800A14F0(Object *racerObj, s32 updateRate) { sp3C = (s32) gCurrentHud->unk650; sp40 = (s32) (gCurrentHud->unk66C - sp44); sp38 = (s32) (gCurrentHud->unk670 - sp3C); - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { curRacer = &racers[i]->unk64->racer; if (((s32) gNumActivePlayers < 3) || (racer->playerIndex == curRacer->playerIndex)) { func_800A19A4(curRacer, updateRate); @@ -899,7 +861,6 @@ void func_800A14F0(Object *racerObj, s32 updateRate) { } } - void func_800A19A4(Object_Racer *racer, UNUSED s32 updateRate) { s32 i; UNUSED s32 pad; @@ -939,7 +900,7 @@ void func_800A19A4(Object_Racer *racer, UNUSED s32 updateRate) { /** * Render the HUD for the battle mode challenge. * Shows each players portrait and their remaining health. -*/ + */ void render_hud_battle(s32 arg0, Object *obj, s32 updateRate) { Object **racerObjs; Object_Racer *racer; @@ -991,7 +952,7 @@ void func_800A1E48(Object *racerObj, s32 updateRate) { s32 offset; s32 temp3; s32 temp4; - + racers = get_racer_objects(&numRacers); if (racerObj != NULL) { racer = &racerObj->unk64->racer; @@ -1094,7 +1055,7 @@ void func_800A22F4(Object_Racer *racer, UNUSED s32 updateRate) { /** * When racing the boss, render the essentials, but skip the bananas. -*/ + */ void render_hud_race_boss(s32 arg0, Object *obj, s32 updateRate) { LevelHeader *level; Object_Racer *racer = (Object_Racer *) obj->unk64; @@ -1117,7 +1078,7 @@ void render_hud_race_boss(s32 arg0, Object *obj, s32 updateRate) { /** * When racing Taj in the overworld, render most of the basic race hud. -*/ + */ void render_hud_taj_race(s32 arg0, Object *obj, s32 updateRate) { Object_Racer *racer = (Object_Racer *) obj->unk64; @@ -1134,7 +1095,7 @@ void render_hud_taj_race(s32 arg0, Object *obj, s32 updateRate) { /** * The hub world displays the player's balloon count. * In two player adventure, the icon of the character of the player sitting out is displayed. -*/ + */ void render_hud_hubworld(Object *obj, s32 updateRate) { Object_Racer *racer; unk80126CDC *temp_a3; @@ -1157,7 +1118,7 @@ void render_hud_hubworld(Object *obj, s32 updateRate) { // render_hud_time_trial // https://decomp.me/scratch/BWqz9 // Draws Time Trial HUD. Also handles music/audio? -void func_800A277C(s32 arg0, Object* playerRacerObj, s32 updateRate) { +void func_800A277C(s32 arg0, Object *playerRacerObj, s32 updateRate) { s32 i; s32 spB8; s32 spB4; @@ -1180,7 +1141,7 @@ void func_800A277C(s32 arg0, Object* playerRacerObj, s32 updateRate) { f32 posZ; UNUSED f32 new_var; char *SWMessage[3]; - + curRacer = &playerRacerObj->unk64->racer; stopwatchTimer = 0; if (gAssetHudElements->entry[20] == NULL) { @@ -1192,7 +1153,7 @@ void func_800A277C(s32 arg0, Object* playerRacerObj, s32 updateRate) { gAssetHudElements->entry[20] = spawn_object(&ttSWBody, 0); gCurrentHud->unk340 = -0x8000; if (gAssetHudElements->entry[20] != NULL) { - ((Object *) gAssetHudElements->entry[20])->segment.animFrame = 0; + ((Object *) gAssetHudElements->entry[20])->segment.animFrame = 0; } } if (gAssetHudElements->entry[34] == 0) { @@ -1249,12 +1210,12 @@ void func_800A277C(s32 arg0, Object* playerRacerObj, s32 updateRate) { } object_animate(ttSWBodyObject); } - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC** ) &gCurrentHud->unk340); - - for(i = 0; curRacer->lap >= i && i < 5; i++) { + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &gCurrentHud->unk340); + + for (i = 0; curRacer->lap >= i && i < 5; i++) { stopwatchTimer += curRacer->lap_times[i]; } - + if (osTvType == TV_TYPE_PAL) { stopwatchTimer = (f32) stopwatchTimer * 1.2; } @@ -1263,12 +1224,14 @@ void func_800A277C(s32 arg0, Object* playerRacerObj, s32 updateRate) { } gCurrentHud->unk444 = ((stopwatchTimer * 0x444) + 0x7FF8); if (get_contpak_error() <= 0) { - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &gCurrentHud->unk440); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, + (unk80126CDC **) &gCurrentHud->unk440); } gCurrentHud->unk444 = ((((stopwatchTimer / 60) + 30) % 60) * 0x444); gCurrentHud->unk450 = gCurrentHud->unk350 + 28.0f; if (get_contpak_error() <= 0) { - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &gCurrentHud->unk440); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, + (unk80126CDC **) &gCurrentHud->unk440); } obj68->unk20 = 0; func_80068508(TRUE); @@ -1276,7 +1239,7 @@ void func_800A277C(s32 arg0, Object* playerRacerObj, s32 updateRate) { if (!curRacer->raceFinished) { spB8 = gCurrentHud->unk2F0; for (i = 0; i < curRacer->countLap && i < gHudLevelHeader->laps; i++) { - // FAKEMATCH + // FAKEMATCH get_timestamp_from_frames(curRacer->lap_times[i] & 0xFFFFFFFFFFFFFFFF, &spB4, &spB0, &spAC); gHudColour = D_800E27AC[i]; render_timer(gCurrentHud->unk2EC, spB8, spB4, spB0, spAC, 1); @@ -1284,8 +1247,10 @@ void func_800A277C(s32 arg0, Object* playerRacerObj, s32 updateRate) { spB8 += 12; gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, 255, 255, 255, 255); gCurrentHud->unk338 = i + 1; - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &gCurrentHud->unk320); - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &gCurrentHud->unk300); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, + (unk80126CDC **) &gCurrentHud->unk320); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, + (unk80126CDC **) &gCurrentHud->unk300); gCurrentHud->unk330 += 12.0f; gCurrentHud->unk310 += 12.0f; } @@ -1317,9 +1282,12 @@ void func_800A277C(s32 arg0, Object* playerRacerObj, s32 updateRate) { } } } - if ((curRacer->lap > 0) && (curRacer->lap < gHudLevelHeader->laps) && (curRacer->lap_times[curRacer->lap] < 20) && (gHUDVoiceSoundMask == 0) && (curRacer->vehicleID <= VEHICLE_PLANE)) { + if ((curRacer->lap > 0) && (curRacer->lap < gHudLevelHeader->laps) && + (curRacer->lap_times[curRacer->lap] < 20) && (gHUDVoiceSoundMask == 0) && + (curRacer->vehicleID <= VEHICLE_PLANE)) { gHudSettings = get_settings(); - if (curRacer->lap_times[curRacer->lap - 1] < gHudSettings->flapTimesPtr[curRacer->vehicleID][get_current_map_id()]) { + if (curRacer->lap_times[curRacer->lap - 1] < + gHudSettings->flapTimesPtr[curRacer->vehicleID][get_current_map_id()]) { recordTime = curRacer->lap_times[curRacer->lap - 1]; for (i = 0; i < curRacer->lap - 1; i++) { if (recordTime >= curRacer->lap_times[i]) { @@ -1338,7 +1306,8 @@ void func_800A277C(s32 arg0, Object* playerRacerObj, s32 updateRate) { posY = ttSWBodyObject->segment.trans.y_position - playerRacerObj->segment.trans.y_position; posX = ttSWBodyObject->segment.trans.x_position - playerRacerObj->segment.trans.x_position; posZ = ttSWBodyObject->segment.trans.z_position - playerRacerObj->segment.trans.z_position; - if ((sqrtf(posX * posX + (posY * posY) + (posZ * posZ)) < 600.0f) && (gHUDVoiceSoundMask == 0) && (D_80126D50 == 0)) { + if ((sqrtf(posX * posX + (posY * posY) + (posZ * posZ)) < 600.0f) && (gHUDVoiceSoundMask == 0) && + (D_80126D50 == 0)) { newLapSoundID = (get_random_number_from_range(0, 2) + SOUND_VOICE_TT_GO_FOR_IT); while (D_80126D48 == newLapSoundID) { newLapSoundID = (get_random_number_from_range(0, 2) + SOUND_VOICE_TT_GO_FOR_IT); @@ -1389,14 +1358,20 @@ void func_800A277C(s32 arg0, Object* playerRacerObj, s32 updateRate) { set_text_font(ASSET_FONTS_FUNFONT); // Draw text shadow. set_text_colour(0, 0, 0, 255, 255); - draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28 + 1, D_80127190 + 1, SWMessage[0], ALIGN_MIDDLE_CENTER); - draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28 + 1, D_80127190 + 15, SWMessage[1], ALIGN_MIDDLE_CENTER); - draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28 + 1, D_80127190 + 29, SWMessage[2], ALIGN_MIDDLE_CENTER); + draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28 + 1, D_80127190 + 1, SWMessage[0], + ALIGN_MIDDLE_CENTER); + draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28 + 1, D_80127190 + 15, SWMessage[1], + ALIGN_MIDDLE_CENTER); + draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28 + 1, D_80127190 + 29, SWMessage[2], + ALIGN_MIDDLE_CENTER); // Draw actual text. set_text_colour(D_80127194->red, D_80127194->green, D_80127194->blue, 128, D_80127194->alpha); - draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28, D_80127190, SWMessage[0], ALIGN_MIDDLE_CENTER); - draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28, D_80127190 + 14, SWMessage[1], ALIGN_MIDDLE_CENTER); - draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28, D_80127190 + 28, SWMessage[2], ALIGN_MIDDLE_CENTER); + draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28, D_80127190, SWMessage[0], + ALIGN_MIDDLE_CENTER); + draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28, D_80127190 + 14, SWMessage[1], + ALIGN_MIDDLE_CENTER); + draw_text(&gHUDCurrDisplayList, D_8012718C + D_80126D24 + D_80126D28, D_80127190 + 28, SWMessage[2], + ALIGN_MIDDLE_CENTER); update_colour_cycle(D_80127194, updateRate); set_kerning(0); } @@ -1419,7 +1394,7 @@ void set_stopwatch_face(u8 arg0, u8 arg1, u8 faceID, u8 arg3, u8 arg4) { if (hud20 != NULL) { unk68 = (Object_68 **) hud20->unk68[0]; var_a3 = unk68[0]->unk28; - + for (i = 0; i < var_a3; i++) { if (D_80126D66 == unk68[0]->unk38[i].unk0[0]) { unk68[0]->unk38[i].unk0[0] = arg0; @@ -1434,7 +1409,7 @@ void set_stopwatch_face(u8 arg0, u8 arg1, u8 faceID, u8 arg3, u8 arg4) { } else if (D_80126D65 == unk68[0]->unk38[i].unk0[0]) { unk68[0]->unk38[i].unk0[0] = arg1; var_a3 = unk68[0]->unk28; - } + } } D_80126D66 = arg0; D_80126D65 = arg1; @@ -1452,7 +1427,7 @@ void func_800A3870(void) { /** * When enabled, displays speed of the player in the bottom right corner, replacing the minimap. * Speed is calculated by normalising racer velocity. then scaling the angle of the needle with that number. -*/ + */ void render_speedometer(Object *obj, UNUSED s32 updateRate) { f32 vel; Object_Racer *racer; @@ -1463,9 +1438,12 @@ void render_speedometer(Object *obj, UNUSED s32 updateRate) { racer = (Object_Racer *) obj->unk64; if (racer->raceFinished == FALSE) { if (racer->vehicleID == VEHICLE_PLANE) { - vel = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + (obj->segment.y_velocity * obj->segment.y_velocity) + (obj->segment.z_velocity * obj->segment.z_velocity)); + vel = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + + (obj->segment.y_velocity * obj->segment.y_velocity) + + (obj->segment.z_velocity * obj->segment.z_velocity)); } else { - vel = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + (obj->segment.z_velocity * obj->segment.z_velocity)); + vel = sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + + (obj->segment.z_velocity * obj->segment.z_velocity)); } if (D_800E2838 < vel) { D_800E2838 = vel; @@ -1516,11 +1494,10 @@ void render_speedometer(Object *obj, UNUSED s32 updateRate) { } } - /** * Call the functions that render the "Get Ready" and "GO!" as well as their countdowns to control fade. * This function will also call to begin the background music for 1 and 2 player. 3 and 4 are treated with silence. -*/ + */ void render_race_start(s32 arg0, s32 updateRate) { if (!is_game_paused()) { @@ -1544,17 +1521,19 @@ void render_race_start(s32 arg0, s32 updateRate) { if (D_80126D3C == NULL && func_80023568() == 0) { f32 sp4C; UNUSED s32 pad; - Object** racerGroup; - Object* randomRacer; - Object_Racer* racer; + Object **racerGroup; + Object *randomRacer; + Object_Racer *racer; s32 numRacerObjects; racerGroup = get_racer_objects(&numRacerObjects); randomRacer = racerGroup[get_random_number_from_range(1, numRacerObjects) - 1]; - racer = (Object_Racer*)randomRacer->unk64; + racer = (Object_Racer *) randomRacer->unk64; if (racer->vehicleID == VEHICLE_CAR) { if (get_random_number_from_range(0, 100) >= 96) { sp4C = 1.25 - ((get_random_number_from_range(0, 7) * 0.5) / 7.0); - func_800095E8(76, randomRacer->segment.trans.x_position, randomRacer->segment.trans.y_position, randomRacer->segment.trans.z_position, 4, ((get_random_number_from_range(0, 7) * 63) / 7) + 24, sp4C * 100.0f, &D_80126D3C); + func_800095E8(76, randomRacer->segment.trans.x_position, randomRacer->segment.trans.y_position, + randomRacer->segment.trans.z_position, 4, + ((get_random_number_from_range(0, 7) * 63) / 7) + 24, sp4C * 100.0f, &D_80126D3C); } } } @@ -1593,13 +1572,19 @@ void render_race_start(s32 arg0, s32 updateRate) { /** * Renders the banana counter on screen. * When a banana is collected, render sparkles and animate the banana. for a brief moment. -*/ + */ void render_racer_bananas(Object_Racer *racer, s32 updateRate) { s32 bananas; UNUSED s16 pad; s32 temp_lo; u8 var_v1; - if(racer->playerIndex == PLAYER_COMPUTER || (((gHUDNumPlayers < TWO_PLAYERS || D_800E2794[gHUDNumPlayers][racer->playerIndex] == PLAYER_THREE || gHudLevelHeader->race_type == RACETYPE_CHALLENGE_BANANAS || gHudLevelHeader->race_type == RACETYPE_CHALLENGE_BATTLE) && racer->raceFinished == FALSE) && (gHUDNumPlayers < TWO_PLAYERS || (racer->lap < 1) || racer->lap_times[racer->lap] >= 180 || gHudLevelHeader->race_type & RACETYPE_CHALLENGE))) { + if (racer->playerIndex == PLAYER_COMPUTER || + (((gHUDNumPlayers < TWO_PLAYERS || D_800E2794[gHUDNumPlayers][racer->playerIndex] == PLAYER_THREE || + gHudLevelHeader->race_type == RACETYPE_CHALLENGE_BANANAS || + gHudLevelHeader->race_type == RACETYPE_CHALLENGE_BATTLE) && + racer->raceFinished == FALSE) && + (gHUDNumPlayers < TWO_PLAYERS || (racer->lap < 1) || racer->lap_times[racer->lap] >= 180 || + gHudLevelHeader->race_type & RACETYPE_CHALLENGE))) { func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk240); bananas = racer->bananas; var_v1 = gCurrentHud->unkF8; @@ -1668,7 +1653,7 @@ void render_racer_bananas(Object_Racer *racer, s32 updateRate) { /** * Renders the icons and secured treasure in Smokey's castle. * In 4 player, all icons are skipped and in 3 player, player 4's icon is shown on their quadrant. -*/ + */ void render_treasure_hud(Object_Racer *racer) { s32 i; s32 sp48; @@ -1697,14 +1682,14 @@ void render_treasure_hud(Object_Racer *racer) { /** * Render the silver coin counter on the side of the screen. * When the 8th coin is collected, wait a second then play an encouraging voice clip from T.T. -*/ + */ void render_silver_coin_counter(Object_Racer *racer, s32 updateRate) { s32 i; s32 prevUnk5D0; - gCurrentHud->unk5D0 = (s32) gCurrentHud->unk5D0; //Rounds float down to it's int value. + gCurrentHud->unk5D0 = (s32) gCurrentHud->unk5D0; // Rounds float down to it's int value. prevUnk5D0 = gCurrentHud->unk5D0; - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { if (i >= racer->silverCoinCount) { gHudColour = COLOUR_RGBA32(128, 128, 128, 128); } @@ -1732,7 +1717,7 @@ void render_silver_coin_counter(Object_Racer *racer, s32 updateRate) { * Plays the race finish fanfare and displays what position you finished * in the middle of the screen. * Uses a 3 step process to play the sounds, display the position, then slide it offscreen. -*/ + */ void render_race_finish_position(Object_Racer *racer, s32 updateRate) { unk800A497C *temp_a3; unk800A497C *temp_s0; @@ -1740,7 +1725,7 @@ void render_race_finish_position(Object_Racer *racer, s32 updateRate) { temp_a3 = (unk800A497C *) &gCurrentHud->unk700; temp_s0 = (unk800A497C *) &gCurrentHud->unk740; - //temp_s0 = &gCurrentHud->unk740; + // temp_s0 = &gCurrentHud->unk740; drawPosition = FALSE; switch (temp_a3->unk1A) { case 0: @@ -1798,13 +1783,13 @@ void render_race_finish_position(Object_Racer *racer, s32 updateRate) { } } - -UNUSED void func_800A4C34(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) {} +UNUSED void func_800A4C34(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { +} /** * Render the current race position of the racer. * Scales up and down when the position changes. -*/ + */ void render_race_position(Object_Racer *racer, s32 updateRate) { s32 place; f32 prevCurrHudUnkC; @@ -1864,15 +1849,15 @@ void render_race_position(Object_Racer *racer, s32 updateRate) { } } - /** * Displays the current lap number onscreen. * Also displays the "Lap 2" and "Final Lap" messages when the line is crossed. * In multiplayer, shows a cut down display, if the display setting is set to show laps. -*/ + */ void render_lap_count(Object_Racer *racer, s32 updateRate) { - if (racer->raceFinished == FALSE && (gHUDNumPlayers <= ONE_PLAYER || racer->lap <= 0 || racer->lap_times[racer->lap] >= 180) - && (gHUDNumPlayers <= ONE_PLAYER || D_800E2794[gHUDNumPlayers][racer->playerIndex] == 3)) { + if (racer->raceFinished == FALSE && + (gHUDNumPlayers <= ONE_PLAYER || racer->lap <= 0 || racer->lap_times[racer->lap] >= 180) && + (gHUDNumPlayers <= ONE_PLAYER || D_800E2794[gHUDNumPlayers][racer->playerIndex] == 3)) { if (gHudLevelHeader->laps == (0, racer->countLap + 1) && gHUDNumPlayers < THREE_PLAYERS) { gCurrentHud->unk21A += updateRate; if (gCurrentHud->unk21A > 6) { @@ -1906,31 +1891,31 @@ void render_lap_count(Object_Racer *racer, s32 updateRate) { gCurrentHud->unk3DD = 0; sound_play(SOUND_WHOOSH1, NULL); switch (gHUDNumPlayers) { - case ONE_PLAYER: - gCurrentHud->unk3DC = -21; - gCurrentHud->unk3FC = 32; - gCurrentHud->unk3CC = -200.0f; - gCurrentHud->unk3EC = 211.0f; - break; - case TWO_PLAYERS: - gCurrentHud->unk3DC = -16; - gCurrentHud->unk3FC = 27; - gCurrentHud->unk3CC = -200.0f; - gCurrentHud->unk3EC = 211.0f; - break; - default: - if (racer->playerIndex != PLAYER_ONE && racer->playerIndex != PLAYER_THREE) { - gCurrentHud->unk3DC = 60; - gCurrentHud->unk3FC = 91; - gCurrentHud->unk3CC = -70.0f; - gCurrentHud->unk3EC = 221.0f; - } else { - gCurrentHud->unk3DC = -90; - gCurrentHud->unk3FC = -59; - gCurrentHud->unk3CC = -220.0f; - gCurrentHud->unk3EC = 71.0f; - } - break; + case ONE_PLAYER: + gCurrentHud->unk3DC = -21; + gCurrentHud->unk3FC = 32; + gCurrentHud->unk3CC = -200.0f; + gCurrentHud->unk3EC = 211.0f; + break; + case TWO_PLAYERS: + gCurrentHud->unk3DC = -16; + gCurrentHud->unk3FC = 27; + gCurrentHud->unk3CC = -200.0f; + gCurrentHud->unk3EC = 211.0f; + break; + default: + if (racer->playerIndex != PLAYER_ONE && racer->playerIndex != PLAYER_THREE) { + gCurrentHud->unk3DC = 60; + gCurrentHud->unk3FC = 91; + gCurrentHud->unk3CC = -70.0f; + gCurrentHud->unk3EC = 221.0f; + } else { + gCurrentHud->unk3DC = -90; + gCurrentHud->unk3FC = -59; + gCurrentHud->unk3CC = -220.0f; + gCurrentHud->unk3EC = 71.0f; + } + break; } } else if (gHudLevelHeader->laps == (0, racer->lap + 1) && racer->lap != 0) { gCurrentHud->unk3DA = 3; @@ -1938,31 +1923,31 @@ void render_lap_count(Object_Racer *racer, s32 updateRate) { gCurrentHud->unk3DD = 0; sound_play(SOUND_WHOOSH1, NULL); switch (gHUDNumPlayers) { - case ONE_PLAYER: - gCurrentHud->unk3DC = 51; - gCurrentHud->unk3BC = -41; - gCurrentHud->unk3CC = 210.0f; - gCurrentHud->unk3AC = -200.0f; - break; - case TWO_PLAYERS: - gCurrentHud->unk3DC = 41; - gCurrentHud->unk3BC = -31; - gCurrentHud->unk3CC = 210.0f; - gCurrentHud->unk3AC = -200.0f; - break; - default: - if (racer->playerIndex != PLAYER_ONE && racer->playerIndex != PLAYER_THREE) { - gCurrentHud->unk3DC = 100; - gCurrentHud->unk3BC = 50; - gCurrentHud->unk3CC = 100.0f; - gCurrentHud->unk3AC = -50.0f; - } else { - gCurrentHud->unk3DC = -50; - gCurrentHud->unk3BC = -100; - gCurrentHud->unk3CC = 50.0f; + case ONE_PLAYER: + gCurrentHud->unk3DC = 51; + gCurrentHud->unk3BC = -41; + gCurrentHud->unk3CC = 210.0f; gCurrentHud->unk3AC = -200.0f; - } - break; + break; + case TWO_PLAYERS: + gCurrentHud->unk3DC = 41; + gCurrentHud->unk3BC = -31; + gCurrentHud->unk3CC = 210.0f; + gCurrentHud->unk3AC = -200.0f; + break; + default: + if (racer->playerIndex != PLAYER_ONE && racer->playerIndex != PLAYER_THREE) { + gCurrentHud->unk3DC = 100; + gCurrentHud->unk3BC = 50; + gCurrentHud->unk3CC = 100.0f; + gCurrentHud->unk3AC = -50.0f; + } else { + gCurrentHud->unk3DC = -50; + gCurrentHud->unk3BC = -100; + gCurrentHud->unk3CC = 50.0f; + gCurrentHud->unk3AC = -200.0f; + } + break; } } } @@ -1983,7 +1968,8 @@ void render_lap_count(Object_Racer *racer, s32 updateRate) { gCurrentHud->unk3DB = -1; sound_play(SOUND_WHOOSH1, NULL); } - if (gCurrentHud->unk3CC == ((0, gCurrentHud))->unk3DC && gCurrentHud->unk3EC == ((0, gCurrentHud))->unk3FC && gCurrentHud->unk3DD == 0) { + if (gCurrentHud->unk3CC == ((0, gCurrentHud))->unk3DC && + gCurrentHud->unk3EC == ((0, gCurrentHud))->unk3FC && gCurrentHud->unk3DD == 0) { if (gHUDVoiceSoundMask == NULL) { sound_play(SOUND_VOICE_TT_LAP2, &gHUDVoiceSoundMask); } @@ -2016,7 +2002,8 @@ void render_lap_count(Object_Racer *racer, s32 updateRate) { gCurrentHud->unk3DB = 1; sound_play(SOUND_WHOOSH1, NULL); } - if (gCurrentHud->unk3CC == ((0, gCurrentHud))->unk3DC && gCurrentHud->unk3AC == ((0, gCurrentHud))->unk3BC && gCurrentHud->unk3DD == 0) { + if (gCurrentHud->unk3CC == ((0, gCurrentHud))->unk3DC && + gCurrentHud->unk3AC == ((0, gCurrentHud))->unk3BC && gCurrentHud->unk3DD == 0) { if (gHUDVoiceSoundMask == NULL) { sound_play(SOUND_VOICE_TT_FINAL_LAP, &gHUDVoiceSoundMask); } @@ -2029,7 +2016,7 @@ void render_lap_count(Object_Racer *racer, s32 updateRate) { gCurrentHud->unk3DA = 0; } } - + gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, 255, 255, 255, 160); func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk3A0); func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk3C0); @@ -2043,8 +2030,8 @@ void render_lap_count(Object_Racer *racer, s32 updateRate) { /** * Players going the wrong way will be nagged by T.T to turn around. * This function plays the audio, and makes the text fly in. -*/ -void render_wrong_way_text(Object_Racer *obj, s32 updateRate) { + */ +void render_wrong_way_text(Object_Racer *obj, s32 updateRate) { f32 textMoveSpeed; f32 textPosTarget; @@ -2110,7 +2097,7 @@ void render_wrong_way_text(Object_Racer *obj, s32 updateRate) { if (gHUDNumPlayers == TWO_PLAYERS) { gCurrentHud->unk47A[2] = -21; gCurrentHud->unk49C = 42; - } else if (gHUDNumPlayers > TWO_PLAYERS) { + } else if (gHUDNumPlayers > TWO_PLAYERS) { if (obj->playerIndex == PLAYER_ONE || obj->playerIndex == PLAYER_THREE) { gCurrentHud->unk47A[2] = -100; gCurrentHud->unk49C = -55; @@ -2120,7 +2107,7 @@ void render_wrong_way_text(Object_Racer *obj, s32 updateRate) { } } gCurrentHud->unk48C = gCurrentHud->unk49C + 200; - gCurrentHud->unk46C = gCurrentHud->unk49C - 200; + gCurrentHud->unk46C = gCurrentHud->unk49C - 200; sound_play(SOUND_WHOOSH1, NULL); } sprite_opaque(FALSE); @@ -2133,16 +2120,22 @@ void func_800A5F18(Object_Racer *racer) { func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk600); if (!(get_current_level_race_type() & RACETYPE_CHALLENGE_BATTLE) && (is_in_two_player_adventure() == 0)) { get_racer_objects(&sp24); - if (gNumActivePlayers >= 2 && (is_in_two_player_adventure() == FALSE || is_postrace_viewport_active() == FALSE)) { + if (gNumActivePlayers >= 2 && + (is_in_two_player_adventure() == FALSE || is_postrace_viewport_active() == FALSE)) { set_text_font(FONT_COLOURFUL); if (sp24 != racer->unk1AC) { set_text_colour(255, 255, 255, 0, 255); - draw_text(&gHUDCurrDisplayList, gCurrentHud->unk16C - 40.0f, gCurrentHud->unk170, "RACE", ALIGN_TOP_LEFT); - render_timer(gCurrentHud->unk16C, gCurrentHud->unk170, gCurrentHud->unk17A, gCurrentHud->unk17B, gCurrentHud->unk17C, 1); - draw_text(&gHUDCurrDisplayList, gCurrentHud->unk2EC - 40.0f, gCurrentHud->unk2F0, "LAP", ALIGN_TOP_LEFT); - render_timer(gCurrentHud->unk2EC, gCurrentHud->unk2F0, gCurrentHud->unk2FA, gCurrentHud->unk2FB, gCurrentHud->unk2FC, 1); + draw_text(&gHUDCurrDisplayList, gCurrentHud->unk16C - 40.0f, gCurrentHud->unk170, "RACE", + ALIGN_TOP_LEFT); + render_timer(gCurrentHud->unk16C, gCurrentHud->unk170, gCurrentHud->unk17A, gCurrentHud->unk17B, + gCurrentHud->unk17C, 1); + draw_text(&gHUDCurrDisplayList, gCurrentHud->unk2EC - 40.0f, gCurrentHud->unk2F0, "LAP", + ALIGN_TOP_LEFT); + render_timer(gCurrentHud->unk2EC, gCurrentHud->unk2F0, gCurrentHud->unk2FA, gCurrentHud->unk2FB, + gCurrentHud->unk2FC, 1); } else { - draw_text(&gHUDCurrDisplayList, gCurrentHud->unk16C - 35.0f, gCurrentHud->unk170, "DID NOT FINISH", ALIGN_TOP_LEFT); + draw_text(&gHUDCurrDisplayList, gCurrentHud->unk16C - 35.0f, gCurrentHud->unk170, "DID NOT FINISH", + ALIGN_TOP_LEFT); } } } @@ -2166,7 +2159,7 @@ void func_800A6254(Object_Racer *racer, s32 updateRate) { s32 hundredths; LevelHeader *curLevelHeader; s32 temp_v0_4; - + raceType = get_current_level_race_type(); if (is_in_two_player_adventure() && is_postrace_viewport_active() && D_80127189 == 0) { if (func_8000E184()) { @@ -2182,7 +2175,7 @@ void func_800A6254(Object_Racer *racer, s32 updateRate) { D_800E2770[0].playerIndex = racer->playerIndex; D_80127189 = 1; } - + switch (gCurrentHud->unk5FA) { case 0: if (!(raceType & RACETYPE_CHALLENGE_BATTLE)) { @@ -2323,14 +2316,14 @@ void func_800A6254(Object_Racer *racer, s32 updateRate) { gCurrentHud->unk16C -= var_v1; if (gCurrentHud->unk2EC < (gCurrentHud->unk2FD - var_v1) + 160) { var_a2 = FALSE; - } else { + } else { var_v1 = (gCurrentHud->unk2FD + 160) - gCurrentHud->unk2EC; } gCurrentHud->unk2EC += var_v1; } - temp_v0_4 = 2; //fakematch? + temp_v0_4 = 2; // fakematch? if (var_a2) { - gCurrentHud->unk5FA = temp_v0_4; //fakematch? Why not just set directly to 2? + gCurrentHud->unk5FA = temp_v0_4; // fakematch? Why not just set directly to 2? gCurrentHud->unk5FB = -120; gCurrentHud->unk5FC = 0; if (gHUDVoiceSoundMask == NULL) { @@ -2356,7 +2349,7 @@ void func_800A6254(Object_Racer *racer, s32 updateRate) { break; case 2: gCurrentHud->unk5FB += updateRate; - + if (gCurrentHud->unk5FB >= 120) { gCurrentHud->unk5FB = -120; gCurrentHud->unk5FC++; @@ -2405,7 +2398,7 @@ GLOBAL_ASM("asm/non_matchings/game_ui/func_800A6254.s") /** * Play the normal race finish message, unless you beat your time record, * then T.T will say "Race Record" instead. -*/ + */ void play_time_trial_end_message(s16 *playerID) { Settings *settings = get_settings(); @@ -2420,81 +2413,81 @@ void play_time_trial_end_message(s16 *playerID) { /** * Render the finishing overlay after a time trial. -*/ + */ void render_time_trial_finish(Object_Racer *racer, s32 updateRate) { s32 temp; - + switch (gCurrentHud->unk1DA) { - case 0: - D_800E2770->volume = 127; - D_800E2770->unk3 = 0; - D_800E2770->playerIndex = (s8) racer->playerIndex; - sound_play(SOUND_WHOOSH1, NULL); - if (gHUDNumPlayers == 0 || gHUDNumPlayers == 1) { - gCurrentHud->unk1CC = -200.0f; - gCurrentHud->unk1DD = 0; - } else { - if ((racer->playerIndex == 0) || (racer->playerIndex == 2)) { - gCurrentHud->unk1DD = -80; + case 0: + D_800E2770->volume = 127; + D_800E2770->unk3 = 0; + D_800E2770->playerIndex = (s8) racer->playerIndex; + sound_play(SOUND_WHOOSH1, NULL); + if (gHUDNumPlayers == 0 || gHUDNumPlayers == 1) { gCurrentHud->unk1CC = -200.0f; - } else { - gCurrentHud->unk1DD = 80; - gCurrentHud->unk1CC = -40.0f; - } - } - gCurrentHud->unk1DA = 1; - return; - case 1: - temp = (updateRate * 13); - if (gCurrentHud->unk1CC < gCurrentHud->unk1DD - temp) { - gCurrentHud->unk1CC += temp; - } else { - gCurrentHud->unk1CC = gCurrentHud->unk1DD; - gCurrentHud->unk1DA = 2; - gCurrentHud->unk1DB = -120; - if (gHUDVoiceSoundMask == NULL && D_80126D71 == 0) { - play_time_trial_end_message(&racer->playerIndex); - } - } - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk1C0); - return; - case 2: - gCurrentHud->unk1DB += updateRate; - if (gCurrentHud->unk1DB >= 120) { - gCurrentHud->unk1DA = 3; - if ((gHUDNumPlayers == 0) || (gHUDNumPlayers == 1)) { - gCurrentHud->unk1DD = 56; + gCurrentHud->unk1DD = 0; } else { if ((racer->playerIndex == 0) || (racer->playerIndex == 2)) { - gCurrentHud->unk1DD = 56; + gCurrentHud->unk1DD = -80; + gCurrentHud->unk1CC = -200.0f; } else { - gCurrentHud->unk1DD = -40; + gCurrentHud->unk1DD = 80; + gCurrentHud->unk1CC = -40.0f; } } - sound_play(SOUND_WHOOSH1, NULL); - } - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk1C0); - return; - case 3: - gCurrentHud->unk1CC -= updateRate * 13; - if (gCurrentHud->unk1CC < gCurrentHud->unk1DD) { - gCurrentHud->unk1DA = 4; - } - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk1C0); - return; - case 4: - D_800E2770->unk3 = -1; - gCurrentHud->unk1DA = 5; - gCurrentHud->unk1DB = 0; - return; - default: - return; + gCurrentHud->unk1DA = 1; + return; + case 1: + temp = (updateRate * 13); + if (gCurrentHud->unk1CC < gCurrentHud->unk1DD - temp) { + gCurrentHud->unk1CC += temp; + } else { + gCurrentHud->unk1CC = gCurrentHud->unk1DD; + gCurrentHud->unk1DA = 2; + gCurrentHud->unk1DB = -120; + if (gHUDVoiceSoundMask == NULL && D_80126D71 == 0) { + play_time_trial_end_message(&racer->playerIndex); + } + } + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk1C0); + return; + case 2: + gCurrentHud->unk1DB += updateRate; + if (gCurrentHud->unk1DB >= 120) { + gCurrentHud->unk1DA = 3; + if ((gHUDNumPlayers == 0) || (gHUDNumPlayers == 1)) { + gCurrentHud->unk1DD = 56; + } else { + if ((racer->playerIndex == 0) || (racer->playerIndex == 2)) { + gCurrentHud->unk1DD = 56; + } else { + gCurrentHud->unk1DD = -40; + } + } + sound_play(SOUND_WHOOSH1, NULL); + } + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk1C0); + return; + case 3: + gCurrentHud->unk1CC -= updateRate * 13; + if (gCurrentHud->unk1CC < gCurrentHud->unk1DD) { + gCurrentHud->unk1DA = 4; + } + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk1C0); + return; + case 4: + D_800E2770->unk3 = -1; + gCurrentHud->unk1DA = 5; + gCurrentHud->unk1DB = 0; + return; + default: + return; } } /** * Render the icon, and the number of collectable balloons onscreen. -*/ + */ void render_balloon_count(UNUSED Object_Racer *racer) { s32 balloonCount; s32 div; @@ -2543,11 +2536,10 @@ void render_balloon_count(UNUSED Object_Racer *racer) { func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk280); } - /** * Unused function that plays whichever T.T voice line is passed through. * Only if the game is currently running and no voice line is already playing. -*/ + */ UNUSED void play_hud_voice_line(u16 soundId) { if (gHUDVoiceSoundMask == NULL && !(is_game_paused())) { sound_play(soundId, &gHUDVoiceSoundMask); @@ -2557,7 +2549,7 @@ UNUSED void play_hud_voice_line(u16 soundId) { /** * Set the sound ID and delay (in seconds) of the voice clip that will be played * after the time trial run starts. -*/ + */ void set_time_trial_start_voice(u16 soundID, f32 delay, s32 arg2) { if (gTimeTrialVoiceDelay == 0) { gTimeTrialVoiceID = soundID; @@ -2575,7 +2567,7 @@ void func_800A74EC(u16 soundID, s32 arg1) { /** * Renders the icon in the bottom left of the current weapon. * The icon will spin and grow as it appears, then spins and shrinks as it disappears. -*/ + */ void render_weapon_hud(Object *obj, s32 updateRate) { Object_Racer *racer; s32 temp_a0; @@ -2627,7 +2619,8 @@ void render_weapon_hud(Object *obj, s32 updateRate) { if (racer->balloon_quantity < 3) { gCurrentHud->unk63A -= updateRate; } - if (racer->balloon_quantity >= 3 || ((((gCurrentHud->unk63A + 128) % 32) < 20) && racer->balloon_quantity != 1)) { + if (racer->balloon_quantity >= 3 || + ((((gCurrentHud->unk63A + 128) % 32) < 20) && racer->balloon_quantity != 1)) { gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, 255, 255, 255, 160); gCurrentHud->unk638 = racer->balloon_quantity - 1; func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk620); @@ -2655,14 +2648,14 @@ void render_weapon_hud(Object *obj, s32 updateRate) { /** * If currently using a magnet, render a reticle over the racer that's being targeted. -*/ + */ void render_magnet_reticle(Object *racerObj) { unk80068514_arg4 *entry; unk80126CDC *hud; Object_Racer *racer; s32 hudElementIndex; - if(entry){} // Fakematch + if (entry) {} // Fakematch racer = &racerObj->unk64->racer; if (racer->magnetTargetObj != NULL && get_current_viewport() == racer->playerIndex) { hud = gCurrentHud; @@ -2678,14 +2671,15 @@ void render_magnet_reticle(Object *racerObj) { hud = (unk80126CDC *) &hud->unk220; func_80066CDC(&gHUDCurrDisplayList, &gHUDCurrMatrix); matrix_world_origin(&gHUDCurrDisplayList, &gHUDCurrMatrix); - render_sprite_billboard(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (Object *) hud, entry, RENDER_Z_UPDATE); + render_sprite_billboard(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (Object *) hud, entry, + RENDER_Z_UPDATE); } } /** * Render the lap time on the top right. * When the player begins a new lap, start flashing the previous lap time below instead. -*/ + */ void render_race_time(Object_Racer *racer, s32 updateRate) { s32 i; s32 stopwatchTimer; @@ -2695,7 +2689,8 @@ void render_race_time(Object_Racer *racer, s32 updateRate) { s32 countingDown; s32 timerHideCounter; - if (!(gHUDNumPlayers != ONE_PLAYER && D_800E2794[gHUDNumPlayers][racer->playerIndex] != 1) || (gHUDNumPlayers > ONE_PLAYER && racer->lap > 0 && racer->lap_times[racer->lap] < 180)) { + if (!(gHUDNumPlayers != ONE_PLAYER && D_800E2794[gHUDNumPlayers][racer->playerIndex] != 1) || + (gHUDNumPlayers > ONE_PLAYER && racer->lap > 0 && racer->lap_times[racer->lap] < 180)) { if (racer->raceFinished == FALSE) { timerHideCounter = gCurrentHud->unk15A + 127; if (racer->lap > 0 && racer->lap_times[racer->lap] < 180 && racer->lap < gHudLevelHeader->laps) { @@ -2721,7 +2716,7 @@ void render_race_time(Object_Racer *racer, s32 updateRate) { } get_timestamp_from_frames(stopwatchTimer, &minutes, &seconds, &hundredths); if (countingDown || (normalise_time(36000) == stopwatchTimer)) { - if((timerHideCounter > updateRate)) { + if ((timerHideCounter > updateRate)) { timerHideCounter -= updateRate; } else { timerHideCounter = 0; @@ -2745,7 +2740,7 @@ void render_race_time(Object_Racer *racer, s32 updateRate) { gCurrentHud->unk15B = 0; } } - + if (gNumActivePlayers == 1) { render_timer(gCurrentHud->unk16C, gCurrentHud->unk170, minutes, seconds, hundredths, 0); } else { @@ -2758,7 +2753,7 @@ void render_race_time(Object_Racer *racer, s32 updateRate) { /** * Render a time in minutes, seconds and hundredths of a second. -*/ + */ void render_timer(s32 arg0, s32 arg1, s32 minutes, s32 seconds, s32 hundredths, s32 someBool) { UNUSED s32 pad; unk80126CDC_entry entry2; @@ -2793,42 +2788,41 @@ void render_timer(s32 arg0, s32 arg1, s32 minutes, s32 seconds, s32 hundredths, } entry2.unk6 = var_s4; entry2.unk18 = minutes / 10; - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC** ) &entry2); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &entry2); entry2.unkC += unk14; entry2.unk18 = minutes % 10; - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC** ) &entry2); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &entry2); entry2.unk18 = 0; entry2.unkC += unk10; entry2.unk10 += unk8; entry2.unk6 = unk0; - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC** ) &entry2); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &entry2); entry2.unk6 = var_s4; entry2.unkC += unkC; entry2.unk10 -= unk8; entry2.unk18 = seconds / 10; - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC** ) &entry2); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &entry2); entry2.unkC += unk14; entry2.unk18 = seconds % 10; - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC** ) &entry2); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &entry2); entry2.unk18 = 0; entry2.unkC += unk10; entry2.unk10 += unk8; entry2.unk6 = (s16) unk0; - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC** ) &entry2); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &entry2); entry2.unk6 = var_s4; entry2.unkC += unkC; entry2.unk10 -= unk8; entry2.unk18 = hundredths / 10; - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC** ) &entry2); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &entry2); entry2.unkC += unk14; entry2.unk18 = hundredths % 10; - func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC** ) &entry2); + func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (unk80126CDC **) &entry2); } - /** * Loads the minimap sprite from the level data, then sets the global colours for the minimap. -*/ + */ void minimap_init(LevelModel *model) { s32 sp2C; gMinimapRed = (model->minimapColor >> 16) & 0xFF; @@ -2845,7 +2839,7 @@ void minimap_init(LevelModel *model) { * For 2 players, it's for toggling the minimap * For 3 players, it's for toggling between the minimap and a spectator cam in viewport 4. * For 4 players, it's for toggling the minimap. -*/ + */ s8 get_hud_setting(void) { return gHudToggleSettings[gHUDNumPlayers]; } @@ -2853,7 +2847,7 @@ s8 get_hud_setting(void) { /** * Renders the minimap in all modes as well as a few other random pieces of HUD. * This function also handles the HUD in 3 or 4 player, instead of the normal dedicated functions it has. -*/ + */ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 updateRate) { Object_Racer *curRacerObj; LevelModel *lvlMdl; @@ -2898,21 +2892,21 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u s32 temp_s3; s32 temp; UNUSED s32 pad3[4]; - + func_800A0BD4(updateRate); - + gAssetHudElementStaleCounter[HUD_ELEMENT_UNK_01] = 0; gAssetHudElementStaleCounter[HUD_ELEMENT_UNK_17] = 0; gAssetHudElementStaleCounter[HUD_ELEMENT_UNK_08] = 0; gAssetHudElementStaleCounter[HUD_ELEMENT_UNK_11] = 0; D_80127180 = 0; - + if (D_80126CD3 & 2) { mapOpacity = 255.0f - ((D_80126CD0 * 255.0f) / D_8012718B); } else { mapOpacity = 255; } - + for (i = 0; i < gAssetHudElementIdsCount; i++) { if (gAssetHudElements->entry[i] && i != 40) { if (++gAssetHudElementStaleCounter[i] > 60) { @@ -2929,7 +2923,7 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u } } } - + gHudLevelHeader = get_current_level_header(); objectGroup = get_racer_objects_by_port(&objectCount); gHUDCurrDisplayList = *dList; @@ -2942,7 +2936,7 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u } else { if (gNumActivePlayers == 3) { tempVar4 = NULL; - for(tempVar2 = 0; tempVar2 < objectCount; tempVar2++) { + for (tempVar2 = 0; tempVar2 < objectCount; tempVar2++) { if (objectGroup[tempVar2]->unk64->racer.playerIndex == PLAYER_COMPUTER) { tempVar4 = &objectGroup[tempVar2]->unk64->racer; } @@ -2985,8 +2979,8 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u // In 3/4 player, just show the life counter. if (gNumActivePlayers == 3) { curRacerObj = NULL; - for(tempVar2 = 0; tempVar2 < objectCount; tempVar2++) { - if (objectGroup[tempVar2]->unk64->racer.playerIndex == PLAYER_COMPUTER) { + for (tempVar2 = 0; tempVar2 < objectCount; tempVar2++) { + if (objectGroup[tempVar2]->unk64->racer.playerIndex == PLAYER_COMPUTER) { curRacerObj = &objectGroup[tempVar2]->unk64->racer; } } @@ -3011,7 +3005,7 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u temp = -100.0f - gCurrentHud->unk370; } gCurrentHud->unk36C += var_a0_5; - gCurrentHud->unk370 += temp; + gCurrentHud->unk370 += temp; gCurrentHud->unkEC += var_a0_5; gCurrentHud->unkF0 += temp; gCurrentHud->unk38C += var_a0_5; @@ -3078,7 +3072,7 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u gCurrentHud->unk410 = spBC; } else if (gNumActivePlayers == 3) { tempVar4 = NULL; - for(tempVar2 = 0; tempVar2 < objectCount; tempVar2++) { + for (tempVar2 = 0; tempVar2 < objectCount; tempVar2++) { if (objectGroup[tempVar2]->unk64->racer.playerIndex == PLAYER_COMPUTER) { tempVar4 = &objectGroup[tempVar2]->unk64->racer; } @@ -3117,15 +3111,14 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u *vtx = gHUDCurrVertex; if (!(gHudLevelHeader->unkBC & 1)) { sp113 = TRUE; - for(i = 0; i < objectCount; i++) { + for (i = 0; i < objectCount; i++) { someRacer = (Object_Racer *) objectGroup[i]->unk64; - if (someRacer != NULL && - someRacer->playerIndex != PLAYER_COMPUTER && - someRacer->raceFinished == FALSE) { + if (someRacer != NULL && someRacer->playerIndex != PLAYER_COMPUTER && someRacer->raceFinished == FALSE) { sp113 = FALSE; } } - if ((gHUDNumPlayers == THREE_PLAYERS && is_postrace_viewport_active()) || check_if_showing_cutscene_camera() || sp113) { + if ((gHUDNumPlayers == THREE_PLAYERS && is_postrace_viewport_active()) || check_if_showing_cutscene_camera() || + sp113) { goto test; } else if (gHudToggleSettings[gHUDNumPlayers] != 1) { test: @@ -3146,13 +3139,13 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u gMinimapScreenY = -gMinimapDotOffsetY / 2; break; case THREE_PLAYERS: - if (get_current_level_race_type() == RACETYPE_CHALLENGE_EGGS || - get_current_level_race_type() == RACETYPE_CHALLENGE_BATTLE || + if (get_current_level_race_type() == RACETYPE_CHALLENGE_EGGS || + get_current_level_race_type() == RACETYPE_CHALLENGE_BATTLE || get_current_level_race_type() == RACETYPE_CHALLENGE_BANANAS) { gMinimapScreenX = (gMinimapDotOffsetX / 2) - 8; - gMinimapScreenY = -gMinimapDotOffsetY / 2; + gMinimapScreenY = -gMinimapDotOffsetY / 2; } else { - gMinimapScreenX = ( gMinimapDotOffsetX / 2) + 72; + gMinimapScreenX = (gMinimapDotOffsetX / 2) + 72; gMinimapScreenY = -60 - (gMinimapDotOffsetY / 2); } break; @@ -3194,28 +3187,32 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u } else { gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, gMinimapRed, gMinimapGreen, gMinimapBlue, mapOpacity); } - render_ortho_triangle_image(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, (ObjectSegment* ) &objTrans.trans, minimap, 0); + render_ortho_triangle_image(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, + (ObjectSegment *) &objTrans.trans, minimap, 0); sp11C = (lvlMdl->upperXBounds - lvlMdl->lowerXBounds) / (f32) (lvlMdl->upperZBounds - lvlMdl->lowerZBounds); sp118 = coss_f((lvlMdl->minimapRotation * 0xFFFF) / 360); sp114 = sins_f((lvlMdl->minimapRotation * 0xFFFF) / 360); if (is_in_time_trial() && func_8001B288()) { temp_v0_8 = func_8001B2E0(); if (temp_v0_8 != NULL) { - minimap_marker_pos(temp_v0_8->segment.trans.x_position, temp_v0_8->segment.trans.z_position, sp114, sp118, sp11C); + minimap_marker_pos(temp_v0_8->segment.trans.x_position, temp_v0_8->segment.trans.z_position, sp114, + sp118, sp11C); gCurrentHud->unk1E6 = 14; gCurrentHud->unk1E4 = 0; gCurrentHud->unk1E8 = 1.0f; - tempVar1 = (opacity * (f32) temp_v0_8->segment.object.opacity) * 0.0078125; + tempVar1 = (opacity * (f32) temp_v0_8->segment.object.opacity) * (1.0 / 128.0); gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, 60, 60, 60, tempVar1); func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk1E0); } } temp_v0_8 = get_time_trial_ghost(); if (temp_v0_8 != NULL) { - minimap_marker_pos(temp_v0_8->segment.trans.x_position, temp_v0_8->segment.trans.z_position, sp114, sp118, sp11C); + minimap_marker_pos(temp_v0_8->segment.trans.x_position, temp_v0_8->segment.trans.z_position, sp114, + sp118, sp11C); gCurrentHud->unk1E4 = 0; - tempVar1 = (opacity * (f32) temp_v0_8->segment.object.opacity) * 0.0078125; - gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, gHudMinimapColours[8].red, gHudMinimapColours[8].green, gHudMinimapColours[8].blue, tempVar1); + tempVar1 = (opacity * (f32) temp_v0_8->segment.object.opacity) * (1.0 / 128.0); + gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, gHudMinimapColours[8].red, gHudMinimapColours[8].green, + gHudMinimapColours[8].blue, tempVar1); gCurrentHud->unk1E8 = 1.0f; gCurrentHud->unk1E6 = 14; func_800AA600(&gHUDCurrDisplayList, &gHUDCurrMatrix, &gHUDCurrVertex, &gCurrentHud->unk1E0); @@ -3225,7 +3222,8 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u temp_v0_8 = find_taj_object(); if (temp_v0_8 != NULL) { gCurrentHud->unk1E6 = 14; - minimap_marker_pos(temp_v0_8->segment.trans.x_position, temp_v0_8->segment.trans.z_position, sp114, sp118, sp11C); + minimap_marker_pos(temp_v0_8->segment.trans.x_position, temp_v0_8->segment.trans.z_position, sp114, + sp118, sp11C); gCurrentHud->unk1E4 = 0; gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, 255, 0, 255, opacity); gCurrentHud->unk1E8 = 1.0f; @@ -3238,12 +3236,15 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u temp_v0_8 = objectGroup[i]; someRacer = (Object_Racer *) objectGroup[i]->unk64; if (someRacer != NULL) { - minimap_marker_pos(objectGroup[i]->segment.trans.x_position, objectGroup[i]->segment.trans.z_position, sp114, sp118, sp11C); + minimap_marker_pos(objectGroup[i]->segment.trans.x_position, + objectGroup[i]->segment.trans.z_position, sp114, sp118, sp11C); if (someRacer->playerIndex != PLAYER_COMPUTER) { gCurrentHud->unk1F0 -= 1.0f; gCurrentHud->unk1E6 = 27; - gCurrentHud->unk1E4 = (objectGroup[i]->segment.trans.y_rotation - ((lvlMdl->minimapRotation * 0xFFFF) / 360)) & 0xFFFF; - + gCurrentHud->unk1E4 = + (objectGroup[i]->segment.trans.y_rotation - ((lvlMdl->minimapRotation * 0xFFFF) / 360)) & + 0xFFFF; + if (get_filtered_cheats() & CHEAT_MIRRORED_TRACKS) { gCurrentHud->unk1E4 = 0xFFFF - gCurrentHud->unk1E4; } @@ -3255,7 +3256,9 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u if (is_taj_challenge() && someRacer->vehicleID == VEHICLE_CARPET) { gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, 255, 0, 255, opacity); } else { - gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, gHudMinimapColours[someRacer->characterId].red, gHudMinimapColours[someRacer->characterId].green, gHudMinimapColours[someRacer->characterId].blue, opacity); + gDPSetPrimColor(gHUDCurrDisplayList++, 0, 0, gHudMinimapColours[someRacer->characterId].red, + gHudMinimapColours[someRacer->characterId].green, + gHudMinimapColours[someRacer->characterId].blue, opacity); } if (!(get_current_level_race_type() & RACETYPE_CHALLENGE) || (!someRacer->raceFinished)) { if (osTvType == TV_TYPE_PAL) { @@ -3295,31 +3298,39 @@ void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 u /** * Set the position of the minimap marker based on object position. * Some markers can rotate, so account for that, too. -*/ + */ void minimap_marker_pos(f32 x, f32 z, f32 angleSin, f32 angleCos, f32 modelAspectRatio) { - LevelModel* lvlMdl; + LevelModel *lvlMdl; UNUSED s32 pad24[2]; f32 scaledX; f32 scaledY; s32 a; s32 b; - + lvlMdl = get_current_level_model(); - + a = lvlMdl->upperXBounds - lvlMdl->lowerXBounds; b = lvlMdl->upperZBounds - lvlMdl->lowerZBounds; scaledX = (60.0f * modelAspectRatio * lvlMdl->minimapXScale * (x - lvlMdl->lowerXBounds)) / a; scaledY = (lvlMdl->minimapYScale * -60.0f * (z - lvlMdl->lowerZBounds)) / b; if (get_filtered_cheats() & CHEAT_MIRRORED_TRACKS) { // Is adventure 2? - gCurrentHud->unk1EC = (((f32) gMinimapScreenX - ((scaledX * angleCos) + (scaledY * angleSin))) + (f32) lvlMdl->minimapOffsetXAdv2) - (f32) gMinimapDotOffsetX; - gCurrentHud->unk1F0 = ((f32) (lvlMdl->minimapOffsetYAdv2 + gMinimapScreenY) - ((scaledX * angleSin) - (scaledY * angleCos))) + (f32) gMinimapDotOffsetY; + gCurrentHud->unk1EC = (((f32) gMinimapScreenX - ((scaledX * angleCos) + (scaledY * angleSin))) + + (f32) lvlMdl->minimapOffsetXAdv2) - + (f32) gMinimapDotOffsetX; + gCurrentHud->unk1F0 = + ((f32) (lvlMdl->minimapOffsetYAdv2 + gMinimapScreenY) - ((scaledX * angleSin) - (scaledY * angleCos))) + + (f32) gMinimapDotOffsetY; return; } // Final x position on minimap - gCurrentHud->unk1EC = ((f32) gMinimapScreenX + ((scaledX * angleCos) + (scaledY * angleSin)) + (f32) lvlMdl->minimapOffsetXAdv1) - (f32) gMinimapDotOffsetX; + gCurrentHud->unk1EC = + ((f32) gMinimapScreenX + ((scaledX * angleCos) + (scaledY * angleSin)) + (f32) lvlMdl->minimapOffsetXAdv1) - + (f32) gMinimapDotOffsetX; // Final y position on minimap - gCurrentHud->unk1F0 = ((f32) (lvlMdl->minimapOffsetYAdv1 + gMinimapScreenY) - ((scaledX * angleSin) - (scaledY * angleCos))) + (f32) gMinimapDotOffsetY; + gCurrentHud->unk1F0 = + ((f32) (lvlMdl->minimapOffsetYAdv1 + gMinimapScreenY) - ((scaledX * angleSin) - (scaledY * angleCos))) + + (f32) gMinimapDotOffsetY; } GLOBAL_ASM("asm/non_matchings/game_ui/func_800AA600.s") @@ -3340,7 +3351,7 @@ void func_800AAFD0(ObjectModel *objModel) { s32 flags; numBatches = objModel->numberOfBatches; - + for (i = 0; i < numBatches; i++) { flags = objModel->batches[i].flags; if (!(flags & RENDER_Z_UPDATE)) { @@ -3350,7 +3361,7 @@ void func_800AAFD0(ObjectModel *objModel) { numTris = objModel->batches[i + 1].facesOffset - triOffset; verts = &objModel->vertices[vertOffset]; tris = &objModel->triangles[triOffset]; - texIndex = objModel->batches[i].textureIndex; // 0xFF = No Texture + texIndex = objModel->batches[i].textureIndex; // 0xFF = No Texture textureEnabled = TRIN_ENABLE_TEXTURE; if (texIndex == 0xFF) { texPtr = NULL; @@ -3365,7 +3376,7 @@ void func_800AAFD0(ObjectModel *objModel) { gSPPolygon(gHUDCurrDisplayList++, OS_PHYSICAL_TO_K0(tris), numTris, textureEnabled); numBatches = objModel->numberOfBatches; } - } + } } void func_800AB194(s32 arg0) { @@ -3380,14 +3391,14 @@ void func_800AB1AC(s32 arg0) { /** * Sets the race start HUD procedure to the first step. -*/ + */ UNUSED void reset_race_start_hud(void) { gRaceStartShowHudStep = 0; } /** * Sets the visibility of the hud, hiding almost everything, leaving only the minimap. -*/ + */ void set_hud_visibility(u8 setting) { gShowHUD = 1 - setting; } diff --git a/src/game_ui.h b/src/game_ui.h index 471d5df8..313df3c3 100644 --- a/src/game_ui.h +++ b/src/game_ui.h @@ -481,18 +481,18 @@ void func_800AB194(s32 arg0); void func_800AB1AC(s32 arg0); void func_800AB1C8(void); void set_hud_visibility(u8 setting); -void render_race_time(Object_Racer *obj, s32 updateRate); -void render_wrong_way_text(Object_Racer *racer, s32 updateRate); +void render_race_time(Object_Racer *racer, s32 updateRate); +void render_wrong_way_text(Object_Racer *obj, s32 updateRate); void render_course_indicator_arrows(Object_Racer *racer, s32 updateRate); void render_hud_hubworld(Object *obj, s32 updateRate); -void render_hud(Gfx **dList, MatrixS **mtx, Vertex **tris, Object *obj, s32 updateRate); +void render_hud(Gfx **dList, MatrixS **mtx, Vertex **vertexList, Object *arg3, s32 updateRate); void render_weapon_hud(Object *obj, s32 updateRate); void render_race_start(s32 arg0, s32 updateRate); -void render_racer_bananas(Object_Racer *obj, s32 updateRate); +void render_racer_bananas(Object_Racer *racer, s32 updateRate); void render_race_finish_position(Object_Racer *racer, s32 updateRate); void render_speedometer(Object *obj, s32 updateRate); void render_lap_count(Object_Racer *racer, s32 updateRate); -void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtxList, s32 updateRate); +void render_minimap_and_misc_hud(Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 updateRate); void init_hud(s32 viewportCount); void render_hud_battle(s32 arg0, Object *obj, s32 updateRate); void func_800A22F4(Object_Racer *racer, s32 updateRate); diff --git a/src/gzip.c b/src/gzip.c index dd17acec..eb559946 100644 --- a/src/gzip.c +++ b/src/gzip.c @@ -7,7 +7,7 @@ /************ .data ************/ -huft *gHuftTable = NULL; //gzip_huft_alloc +huft *gHuftTable = NULL; // gzip_huft_alloc s32 *gAssetAddress = NULL; u8 *gzip_inflate_input = NULL; u8 *gzip_inflate_output = NULL; @@ -18,13 +18,13 @@ u8 *gzip_inflate_output = NULL; u32 gzip_bit_buffer; u32 gzip_num_bits; -s32 gHuftTablePos; //gzip_hufts +s32 gHuftTablePos; // gzip_hufts /******************************/ void init_rzip(void) { - gHuftTable = (huft *)allocate_from_main_pool_safe(0x2800, COLOUR_TAG_BLACK); - gAssetAddress = (s32 *)allocate_from_main_pool_safe(0x10, COLOUR_TAG_BLACK); + gHuftTable = (huft *) allocate_from_main_pool_safe(0x2800, COLOUR_TAG_BLACK); + gAssetAddress = (s32 *) allocate_from_main_pool_safe(0x10, COLOUR_TAG_BLACK); } /** @@ -47,7 +47,7 @@ s32 byteswap32(u8 *arg0) { */ s32 get_asset_uncompressed_size(s32 assetIndex, s32 assetOffset) { load_asset_to_address(assetIndex, (u32) gAssetAddress, assetOffset, 8); - return byteswap32((u8 *)gAssetAddress); + return byteswap32((u8 *) gAssetAddress); } /** @@ -66,177 +66,178 @@ u8 *gzip_inflate(u8 *compressedInput, u8 *decompressedOutput) { /* Official name: huft_build */ void gzip_huft_build(u32 *b, u32 n, u32 s, u16 *d, u16 *e, huft **t, s32 *m) { - u32 a; /* counter for codes of length k */ - u32 c[BMAX+1]; /* bit length count table */ - u32 f; /* i repeats in table every f entries */ - s32 g; /* maximum code length */ - s32 h; /* table level */ - register u32 i; /* counter, current code */ - register u32 j; /* counter */ - register s32 k; /* number of bits in current code */ - s32 l; /* bits per table (returned in m) */ - register u32 *p; /* pointer into c[], b[], or v[] */ - register struct huft *q; /* points to current table */ - struct huft r; /* table entry for structure assignment */ - struct huft *u[BMAX]; /* table stack */ - u32 v[N_MAX]; /* values in order of bit length */ - register s32 w; /* bits before this table == (l * h) */ - u32 x[BMAX+1]; /* bit offsets, then code stack */ - u32 *xp; /* pointer into x */ - s32 y; /* number of dummy codes added */ - u32 z; /* number of entries in current table */ + u32 a; /* counter for codes of length k */ + u32 c[BMAX + 1]; /* bit length count table */ + u32 f; /* i repeats in table every f entries */ + s32 g; /* maximum code length */ + s32 h; /* table level */ + register u32 i; /* counter, current code */ + register u32 j; /* counter */ + register s32 k; /* number of bits in current code */ + s32 l; /* bits per table (returned in m) */ + register u32 *p; /* pointer into c[], b[], or v[] */ + register struct huft *q; /* points to current table */ + struct huft r; /* table entry for structure assignment */ + struct huft *u[BMAX]; /* table stack */ + u32 v[N_MAX]; /* values in order of bit length */ + register s32 w; /* bits before this table == (l * h) */ + u32 x[BMAX + 1]; /* bit offsets, then code stack */ + u32 *xp; /* pointer into x */ + s32 y; /* number of dummy codes added */ + u32 z; /* number of entries in current table */ - - /* Generate counts for each bit length */ - bzero(c, sizeof(c)); - p = b; i = n; - do { - c[*p]++; /* assume all entries <= BMAX */ - p++; /* Can't combine with above line (Solaris bug) */ - } while (--i); - if (c[0] == n) /* null input--all zero length codes */ - { - *t = NULL; - *m = 0; - return; - } - - /* Find minimum and maximum length, bound *m by those */ - l = *m; - for (j = 1; j <= BMAX; j++) - if (c[j]) - break; - k = j; /* minimum code length */ - if ((u32) l < j) - l = j; - for (i = BMAX; i; i--) - if (c[i]) - break; - g = i; /* maximum code length */ - if ((u32) l > i) - l = i; - *m = l; - - // Something is missing here. - /* Adjust last length count to fill out codes, if needed */ - y = 1 << j; - while (j < i) { - y -= c[j]; - j++; - y <<= 1; - } - y -= c[i]; - c[i] += y; - - - /* Generate starting offsets into the value table for each length */ - x[1] = j = 0; - p = c + 1; xp = x + 2; - while (--i) { /* note that i == g from above */ - *xp++ = (j += *p++); - } - - - /* Make a table of values in order of bit lengths */ - p = b; i = 0; - do { - if ((j = *p++) != 0) - v[x[j]++] = i; - } while (++i < n); - // n = x[g]; /* set n to length of v */ - - - /* Generate the Huffman codes and for each, make the table entries */ - x[0] = i = 0; /* first Huffman code is zero */ - p = v; /* grab values in bit order */ - h = -1; /* no tables yet--level -1 */ - w = -l; /* bits decoded == (l * h) */ - u[0] = NULL; /* just to keep compilers happy */ - q = NULL; /* ditto */ - z = 0; /* ditto */ - - // gHuftTable and gHuftTablePos go in here somewhere. - - /* go through the bit lengths (k already is bits in shortest code) */ - for (; k <= g; k++) - { - a = c[k]; - while (a--) + /* Generate counts for each bit length */ + bzero(c, sizeof(c)); + p = b; + i = n; + do { + c[*p]++; /* assume all entries <= BMAX */ + p++; /* Can't combine with above line (Solaris bug) */ + } while (--i); + if (c[0] == n) /* null input--all zero length codes */ { - /* here i is the Huffman code of length k bits for value *p */ - /* make tables up to required level */ - while (k > w + l) - { - h++; - w += l; /* previous table always l bits */ - - /* compute minimum size table less than or equal to l bits */ - z = (z = g - w) > (u32) l ? (u32) l : z; /* upper limit on table size */ - if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ - { /* too few codes for k-w bit table */ - f -= a + 1; /* deduct codes from patterns left */ - xp = c + k; - while (++j < z) /* try smaller tables up to z bits */ - { - if ((f <<= 1) <= *++xp) - break; /* enough codes to use up j bits */ - f -= *xp; /* else deduct codes from patterns */ - } - } - z = 1 << j; /* table entries for j-bit table */ - - q = &gHuftTable[gHuftTablePos]; - gHuftTablePos += z + 1; - - *t = q + 1; /* link to list for huft_free() */ - *(t = &(q->v.t)) = NULL; - u[h] = ++q; /* table starts after link */ - - /* connect to last table, if there is one */ - if (h) - { - x[h] = i; /* save pattern for backing up */ - r.b = l; /* bits to dump before this table */ - r.e = 16 + j; /* bits in this table */ - r.v.t = q; /* pointer to this table */ - j = i >> (w - l); /* (get around Turbo C bug) */ - u[h-1][j] = r; /* connect to last table */ - } - } - - /* set up table entry in r */ - r.b = k - w; - if (p >= v + n) - r.e = 99; /* out of values--invalid code */ - else if (*p < s) - { - r.e = *p < 256 ? 16 : 15; /* 256 is end-of-block code */ - r.v.n = *p; /* simple code is just the value */ - p++; /* one compiler does not like *p++ */ - } - else - { - r.e = ((u8*) e)[*p - s]; /* non-simple--look up in lists */ - r.v.n = d[*p++ - s]; - } - - /* fill code-like entries with r */ - f = 1 << (k - w); - for (j = i >> w; j < z; j += f) - q[j] = r; - - /* backwards increment the k-bit code i */ - for (j = 1 << (k - 1); i & j; j >>= 1) - i ^= j; - i ^= j; - - /* backup over finished tables */ - while ((i & ((1 << w) - 1)) != x[h]) - { - h--; /* don't need to update q */ - w -= l; - } + *t = NULL; + *m = 0; + return; } - } - return; + + /* Find minimum and maximum length, bound *m by those */ + l = *m; + for (j = 1; j <= BMAX; j++) { + if (c[j]) { + break; + } + } + k = j; /* minimum code length */ + if ((u32) l < j) { + l = j; + } + for (i = BMAX; i; i--) { + if (c[i]) { + break; + } + } + g = i; /* maximum code length */ + if ((u32) l > i) { + l = i; + } + *m = l; + + // Something is missing here. + /* Adjust last length count to fill out codes, if needed */ + y = 1 << j; + while (j < i) { + y -= c[j]; + j++; + y <<= 1; + } + y -= c[i]; + c[i] += y; + + /* Generate starting offsets into the value table for each length */ + x[1] = j = 0; + p = c + 1; + xp = x + 2; + while (--i) { /* note that i == g from above */ + *xp++ = (j += *p++); + } + + /* Make a table of values in order of bit lengths */ + p = b; + i = 0; + do { + if ((j = *p++) != 0) { + v[x[j]++] = i; + } + } while (++i < n); + // n = x[g]; /* set n to length of v */ + + /* Generate the Huffman codes and for each, make the table entries */ + x[0] = i = 0; /* first Huffman code is zero */ + p = v; /* grab values in bit order */ + h = -1; /* no tables yet--level -1 */ + w = -l; /* bits decoded == (l * h) */ + u[0] = NULL; /* just to keep compilers happy */ + q = NULL; /* ditto */ + z = 0; /* ditto */ + + // gHuftTable and gHuftTablePos go in here somewhere. + + /* go through the bit lengths (k already is bits in shortest code) */ + for (; k <= g; k++) { + a = c[k]; + while (a--) { + /* here i is the Huffman code of length k bits for value *p */ + /* make tables up to required level */ + while (k > w + l) { + h++; + w += l; /* previous table always l bits */ + + /* compute minimum size table less than or equal to l bits */ + z = (z = g - w) > (u32) l ? (u32) l : z; /* upper limit on table size */ + if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ + { /* too few codes for k-w bit table */ + f -= a + 1; /* deduct codes from patterns left */ + xp = c + k; + while (++j < z) /* try smaller tables up to z bits */ + { + if ((f <<= 1) <= *++xp) { + break; /* enough codes to use up j bits */ + } + f -= *xp; /* else deduct codes from patterns */ + } + } + z = 1 << j; /* table entries for j-bit table */ + + q = &gHuftTable[gHuftTablePos]; + gHuftTablePos += z + 1; + + *t = q + 1; /* link to list for huft_free() */ + *(t = &(q->v.t)) = NULL; + u[h] = ++q; /* table starts after link */ + + /* connect to last table, if there is one */ + if (h) { + x[h] = i; /* save pattern for backing up */ + r.b = l; /* bits to dump before this table */ + r.e = 16 + j; /* bits in this table */ + r.v.t = q; /* pointer to this table */ + j = i >> (w - l); /* (get around Turbo C bug) */ + u[h - 1][j] = r; /* connect to last table */ + } + } + + /* set up table entry in r */ + r.b = k - w; + if (p >= v + n) { + r.e = 99; /* out of values--invalid code */ + } else if (*p < s) { + r.e = *p < 256 ? 16 : 15; /* 256 is end-of-block code */ + r.v.n = *p; /* simple code is just the value */ + p++; /* one compiler does not like *p++ */ + } else { + r.e = ((u8 *) e)[*p - s]; /* non-simple--look up in lists */ + r.v.n = d[*p++ - s]; + } + + /* fill code-like entries with r */ + f = 1 << (k - w); + for (j = i >> w; j < z; j += f) { + q[j] = r; + } + + /* backwards increment the k-bit code i */ + for (j = 1 << (k - 1); i & j; j >>= 1) { + i ^= j; + } + i ^= j; + + /* backup over finished tables */ + while ((i & ((1 << w) - 1)) != x[h]) { + h--; /* don't need to update q */ + w -= l; + } + } + } + return; } diff --git a/src/lights.c b/src/lights.c index 63c8f6df..7e0ca38f 100644 --- a/src/lights.c +++ b/src/lights.c @@ -57,12 +57,13 @@ void setup_lights(s32 count) { free_lights(); gMaxLights = count; - temp_v0 = (ObjectLight **) allocate_from_main_pool_safe(gMaxLights * (sizeof(s32 *) + sizeof(ObjectLight) + sizeof(unk800DC960) + sizeof(Vec3f)), COLOUR_TAG_MAGENTA); + temp_v0 = (ObjectLight **) allocate_from_main_pool_safe( + gMaxLights * (sizeof(s32 *) + sizeof(ObjectLight) + sizeof(unk800DC960) + sizeof(Vec3f)), COLOUR_TAG_MAGENTA); newCount = gMaxLights; gActiveLights = temp_v0; - D_800DC954 = (ObjectLight *) (newCount + (0, temp_v0)); //fakematch - D_800DC960 = (unk800DC960 *) (newCount + (0, D_800DC954)); //fakematch - D_800DC964 = (Vec3f *) (newCount + (0, D_800DC960)); //fakematch + D_800DC954 = (ObjectLight *) (newCount + (0, temp_v0)); // fakematch + D_800DC960 = (unk800DC960 *) (newCount + (0, D_800DC954)); // fakematch + D_800DC964 = (Vec3f *) (newCount + (0, D_800DC960)); // fakematch for (i = 0; i < gMaxLights; i++) { gActiveLights[i] = &D_800DC954[i]; } @@ -120,14 +121,14 @@ ObjectLight *func_80031CAC(Object *light, LevelObjectEntry_RgbaLight *lightEntry newLight->unk4E = 0; newLight->unk48 = (u16) &test->red2; temp_a0 = (u16) &test->red2; - for (i = 0; i < temp_a0; ) { + for (i = 0; i < temp_a0;) { newLight->unk4E += test->unk18[i++].unk0; } } } newLight->radius = lightEntry->unkE; - newLight->unk60 = lightEntry->unk10; - newLight->unk64 = lightEntry->unk12; + newLight->unk60 = lightEntry->unk10; + newLight->unk64 = lightEntry->unk12; newLight->radiusSquare = newLight->radius * newLight->radius; newLight->radiusMag = 1 / newLight->radius; newLight->unk70 = lightEntry->unk14; @@ -189,9 +190,9 @@ ObjectLight *add_object_light(Object *obj, ObjectHeader24 *arg1) { light->unk4C = 0; light->unk4E = 0; light->unk44 = (SubMiscAssetObjectHeader24 *) &miscAsset->unk14; - for (i = 0; i < light->unk48 ; i++) { \ - light->unk4E += light->unk44[i].unk4; //Must be on one line! - } + // clang-format off + for (i = 0; i < light->unk48; i++) { light->unk4E += light->unk44[i].unk4; } // Must be on one line! + // clang-format on } else { light->unk44 = 0; } @@ -215,7 +216,7 @@ ObjectLight *add_object_light(Object *obj, ObjectHeader24 *arg1) { /** * Disable this objects light data. * Official Name: turnLightOff? -*/ + */ UNUSED void disable_object_light(ObjectLight *light) { light->enabled = FALSE; } @@ -223,14 +224,14 @@ UNUSED void disable_object_light(ObjectLight *light) { /** * Enable this objects light data. * Official Name: turnLightOn? -*/ + */ UNUSED void enable_object_light(ObjectLight *light) { light->enabled = TRUE; } /** * Toggle this objects light data on or off. -*/ + */ UNUSED void toggle_object_light(ObjectLight *light) { if (light->enabled == TRUE) { light->enabled = FALSE; @@ -263,7 +264,7 @@ UNUSED void func_80032344(ObjectLight *light, s32 arg1, s32 arg2) { /** * Loops through all active lights and updates their properties. -*/ + */ void lightUpdateLights(s32 updateRate) { s32 i; for (i = 0; i < gNumActiveLights; i++) { @@ -275,7 +276,7 @@ GLOBAL_ASM("asm/non_matchings/lights/func_80032424.s") /** * Official Name: killLight? -*/ + */ void func_80032BAC(ObjectLight *light) { ObjectLight *entry = NULL; s32 i; @@ -296,7 +297,7 @@ void func_80032BAC(ObjectLight *light) { /** * Return the number of active lights. * Official Name: lightGetLights? -*/ + */ s32 get_light_count(void) { return gNumActiveLights; } @@ -320,7 +321,7 @@ void func_80032C7C(Object *object) { sp64 = 2; break; case OBJECT_MODEL_TYPE_SPRITE_BILLBOARD: // 2D Billboard - case OBJECT_MODEL_TYPE_VEHICLE_PART: // Vehicle Part + case OBJECT_MODEL_TYPE_VEHICLE_PART: // Vehicle Part case OBJECT_MODEL_TYPE_UNKNOWN3: sp64 = 4; break; @@ -335,9 +336,8 @@ void func_80032C7C(Object *object) { D_800DC968 = 0; for (i = 0; i < gNumActiveLights; i++) { entry = gActiveLights[i]; - if ((entry->unk2 & sp64) && (entry->enabled == 1) && (sp82 >= entry->unk50) && - (entry->unk56 >= sp82) && (sp80 >= entry->unk52) && (entry->unk58 >= sp80) && - (sp7E >= entry->unk54) && (entry->unk5A >= sp7E)) { + if ((entry->unk2 & sp64) && (entry->enabled == 1) && (sp82 >= entry->unk50) && (entry->unk56 >= sp82) && + (sp80 >= entry->unk52) && (entry->unk58 >= sp80) && (sp7E >= entry->unk54) && (entry->unk5A >= sp7E)) { if (entry->unk0 == 0) { if (entry->unk28 >= 0x10000) { D_800DC960[D_800DC968].unk0 = entry->unk0; @@ -354,7 +354,8 @@ void func_80032C7C(Object *object) { if (entry->unk0 == 2) { gLightDiffY = 0.0f; } - gLightDistance = (gLightDiffX * gLightDiffX) + (gLightDiffY * gLightDiffY) + (gLightDiffZ * gLightDiffZ); + gLightDistance = + (gLightDiffX * gLightDiffX) + (gLightDiffY * gLightDiffY) + (gLightDiffZ * gLightDiffZ); if (gLightDistance < entry->radiusSquare) { if (entry->unk1 == 2) { f20 = light_direction_calc(entry); @@ -383,7 +384,7 @@ void func_80032C7C(Object *object) { D_800DC960[D_800DC968].unk4 = entry->unk1C >> 0x10; D_800DC960[D_800DC968].unk8 = entry->unk20 >> 0x10; D_800DC960[D_800DC968].unkC = entry->unk24 >> 0x10; - D_800DC960[D_800DC968].unk10 = (u8)f20; + D_800DC960[D_800DC968].unk10 = (u8) f20; D_800DC968++; } } @@ -469,8 +470,8 @@ void func_800337E4(void) { unk800DC960 *temp_a1; for (i = 1; i < D_800DC968; i++) { - index = i; // Needed? - if ((&D_800DC960[index])->unk10){} // Fakematch + index = i; // Needed? + if ((&D_800DC960[index])->unk10) {} // Fakematch temp_a1 = (0, D_800DC960) + index; temp_a2 = temp_a1->unk10; if (temp_a2 >= 2) { @@ -491,7 +492,7 @@ void func_800337E4(void) { D_800DC960->unk4 = 255; } if (D_800DC960->unk8 >= 256) { - D_800DC960->unk8 = 255; + D_800DC960->unk8 = 255; } if (D_800DC960->unkC >= 256) { D_800DC960->unkC = 255; @@ -502,42 +503,42 @@ void func_800337E4(void) { /** * Official Name: lightDistanceCalc -*/ + */ f32 light_distance_calc(ObjectLight *light) { f32 dist; f32 mag; dist = light->unk28 / 65536.0f; switch (light->type) { - case LIGHT_UNK1: - mag = 1.0f - (sqrtf(gLightDistance) * light->radiusMag); - dist *= mag; - break; - case LIGHT_UNK2: - mag = 1.0f - sqrtf(sqrtf(gLightDistance) * light->radiusMag); - dist *= mag; - break; - case LIGHT_UNK3: - mag = coss_f(sqrtf(gLightDistance) * light->radiusMag * 16384.0f); - dist *= mag; - break; - case LIGHT_UNK4: - mag = coss_f(sqrtf(gLightDistance) * light->radiusMag * 16384.0f); - mag *= mag; - dist *= mag; - break; - case LIGHT_UNK5: - mag = 1.0f - (sqrtf(gLightDistance) * light->radiusMag); - mag *= mag; - dist *= mag; - break; + case LIGHT_UNK1: + mag = 1.0f - (sqrtf(gLightDistance) * light->radiusMag); + dist *= mag; + break; + case LIGHT_UNK2: + mag = 1.0f - sqrtf(sqrtf(gLightDistance) * light->radiusMag); + dist *= mag; + break; + case LIGHT_UNK3: + mag = coss_f(sqrtf(gLightDistance) * light->radiusMag * 16384.0f); + dist *= mag; + break; + case LIGHT_UNK4: + mag = coss_f(sqrtf(gLightDistance) * light->radiusMag * 16384.0f); + mag *= mag; + dist *= mag; + break; + case LIGHT_UNK5: + mag = 1.0f - (sqrtf(gLightDistance) * light->radiusMag); + mag *= mag; + dist *= mag; + break; } return dist; } /** * Official Name: lightDirectionCalc -*/ + */ f32 light_direction_calc(ObjectLight *light) { f32 mag; f32 distance; @@ -545,7 +546,8 @@ f32 light_direction_calc(ObjectLight *light) { distance = gLightDistance; if (distance > 0.0f) { mag = 1.0f / sqrtf(distance); - distance = (gLightDiffX * mag * light->unk7C) + (gLightDiffY * mag * light->unk80) + (gLightDiffZ * mag * light->unk84); + distance = (gLightDiffX * mag * light->unk7C) + (gLightDiffY * mag * light->unk80) + + (gLightDiffZ * mag * light->unk84); if (distance < 0.0f) { distance = 0.0f; } diff --git a/src/main.c b/src/main.c index 16eda03c..30075578 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,7 @@ UNUSED u64 gUnusedThreadStack[0x200]; * Once the boot procedure is finished in IPL3, this function is run. * It kicks things off by initialising thread1, which serves as the top level * Official name: boot -*/ + */ void main(void) { osInitialize(); osCreateThread(&gThread1, 1, &thread1_main, 0, &gThread1Stack[0x20], OS_PRIORITY_IDLE); @@ -32,7 +32,7 @@ void main(void) { * Initialise the crash handler thread, then initialise the main game thread. * Reset the start and endpoint of the game thread stack, then set thread priority to zero, effectively * stopping this thread, as it's no longer needed. -*/ + */ void thread1_main(UNUSED void *unused) { thread0_create(); osCreateThread(&gThread3, 3, &thread3_main, 0, &gThread3Stack[0x400], 10); @@ -47,7 +47,7 @@ void thread1_main(UNUSED void *unused) { * Increments the start and endpoint of the stack. * They should have an equal value, so if they don't, that triggers a printout saying a stack wraparound has occured. * Official Name: bootCheckStack -*/ + */ void thread3_verify_stack(void) { gThread3Stack[0x400]++; gThread3Stack[0]++; diff --git a/src/math_util.c b/src/math_util.c index 57924829..1920015d 100644 --- a/src/math_util.c +++ b/src/math_util.c @@ -11,16 +11,17 @@ #include "string.h" extern s32 gIntDisFlag; -extern s32 gCurrentRNGSeed; //Official Name: rngSeed +extern s32 gCurrentRNGSeed; // Official Name: rngSeed extern s32 gPrevRNGSeed; extern s16 gSineTable[]; extern s16 gArcTanTable[]; /** * Most files below are handwritten assembly. Because of this, matching C code is impossible. - * Nonmatching is not, so functionally equivalent C code can be here to replace these handwritten functions in nonmatching builds. - * Variables cannot be declared here because of the way they're aligned, so they have to stay in an assembly file. -*/ + * Nonmatching is not, so functionally equivalent C code can be here to replace these handwritten functions in + * nonmatching builds. Variables cannot be declared here because of the way they're aligned, so they have to stay in an + * assembly file. + */ /******************************/ @@ -67,15 +68,15 @@ GLOBAL_ASM("asm/math_util/get_gIntDisFlag.s") #ifdef NON_EQUIVALENT // Untested UNUSED void s32_matrix_to_s16_matrix(s32 **input, s16 **output) { s32 i; - for(i = 0; i < 4; i++){ + for (i = 0; i < 4; i++) { output[i][2] = input[i][0]; - output[i][3] = input[i+4][0]; + output[i][3] = input[i + 4][0]; output[i][6] = input[i][1]; - output[i][7] = input[i+4][1]; + output[i][7] = input[i + 4][1]; output[i][0] = input[i][0] >> 16; - output[i][1] = input[i+4][0] >> 16; + output[i][1] = input[i + 4][0] >> 16; output[i][4] = input[i][1] >> 16; - output[i][5] = input[i+4][1] >> 16; + output[i][5] = input[i + 4][1] >> 16; } } #else @@ -85,7 +86,7 @@ GLOBAL_ASM("asm/math_util/s32_matrix_to_s16_matrix.s") #ifdef NON_MATCHING void f32_matrix_to_s32_matrix(Matrix *input, MatrixS *output) { s32 i; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { (*output)[i][0] = (s32) ((*input)[i][0] * 65536.0f); (*output)[i][1] = (s32) ((*input)[i][1] * 65536.0f); (*output)[i][2] = (s32) ((*input)[i][2] * 65536.0f); @@ -99,9 +100,9 @@ GLOBAL_ASM("asm/math_util/f32_matrix_to_s32_matrix.s") #ifdef NON_MATCHING /* Official name: mathMtxXFMF */ void guMtxXFMF(Matrix mf, float x, float y, float z, float *ox, float *oy, float *oz) { - *ox = mf[0][0]*x + mf[1][0]*y + mf[2][0]*z + mf[3][0]; - *oy = mf[0][1]*x + mf[1][1]*y + mf[2][1]*z + mf[3][1]; - *oz = mf[0][2]*x + mf[1][2]*y + mf[2][2]*z + mf[3][2]; + *ox = mf[0][0] * x + mf[1][0] * y + mf[2][0] * z + mf[3][0]; + *oy = mf[0][1] * x + mf[1][1] * y + mf[2][1] * z + mf[3][1]; + *oz = mf[0][2] * x + mf[1][2] * y + mf[2][2] * z + mf[3][2]; } #else GLOBAL_ASM("asm/math_util/guMtxXFMF.s") @@ -138,10 +139,14 @@ void f32_matrix_mult(Matrix *mat1, Matrix *mat2, Matrix *output) { y = (*mat1)[i][1]; z = (*mat1)[i][2]; w = (*mat1)[i][3]; - (*output)[i][0] = (f32) ((y * (*mat2)[1][0]) + (z * (*mat2)[2][0]) + ((x * (*mat2)[0][0]) + (w * (*mat2)[3][0]))); - (*output)[i][1] = (f32) ((y * (*mat2)[1][1]) + (z * (*mat2)[2][1]) + ((x * (*mat2)[0][1]) + (w * (*mat2)[3][1]))); - (*output)[i][2] = (f32) ((y * (*mat2)[1][2]) + (z * (*mat2)[2][2]) + ((x * (*mat2)[0][2]) + (w * (*mat2)[3][2]))); - (*output)[i][3] = (f32) ((y * (*mat2)[1][3]) + (z * (*mat2)[2][3]) + ((x * (*mat2)[0][3]) + (w * (*mat2)[3][3]))); + (*output)[i][0] = + (f32) ((y * (*mat2)[1][0]) + (z * (*mat2)[2][0]) + ((x * (*mat2)[0][0]) + (w * (*mat2)[3][0]))); + (*output)[i][1] = + (f32) ((y * (*mat2)[1][1]) + (z * (*mat2)[2][1]) + ((x * (*mat2)[0][1]) + (w * (*mat2)[3][1]))); + (*output)[i][2] = + (f32) ((y * (*mat2)[1][2]) + (z * (*mat2)[2][2]) + ((x * (*mat2)[0][2]) + (w * (*mat2)[3][2]))); + (*output)[i][3] = + (f32) ((y * (*mat2)[1][3]) + (z * (*mat2)[2][3]) + ((x * (*mat2)[0][3]) + (w * (*mat2)[3][3]))); } } #else @@ -151,7 +156,7 @@ GLOBAL_ASM("asm/math_util/f32_matrix_mult.s") #ifdef NON_MATCHING /* Official name: mathMtxF2L */ void f32_matrix_to_s16_matrix(Matrix *input, MatrixS *output) { - guMtxF2L((float (*)[4]) input, (Mtx *) output); + guMtxF2L((float(*)[4]) input, (Mtx *) output); } #else GLOBAL_ASM("asm/math_util/f32_matrix_to_s16_matrix.s") @@ -190,7 +195,8 @@ s32 get_random_number_from_range(s32 min, s32 max) { s32 newSeed; u64 curSeed; - curSeed = (((u64) ((s64) gCurrentRNGSeed << 0x3F) >> 0x1F) | ((u64) ((s64) gCurrentRNGSeed << 0x1F) >> 0x20)) ^ ((u64) ((s64) gCurrentRNGSeed << 0x2C) >> 0x20); + curSeed = (((u64) ((s64) gCurrentRNGSeed << 0x3F) >> 0x1F) | ((u64) ((s64) gCurrentRNGSeed << 0x1F) >> 0x20)) ^ + ((u64) ((s64) gCurrentRNGSeed << 0x2C) >> 0x20); newSeed = ((curSeed >> 0x14) & 0xFFF) ^ curSeed; gCurrentRNGSeed = newSeed; return ((u32) (newSeed - min) % (u32) ((max - min) + 1)) + min; @@ -207,8 +213,8 @@ void s16_matrix_rotate(s16 *arg0[4][4], s16 arg1[4][4]) { temp_t6 = (s32) ((*arg0[0][0] * arg1[0][0]) + (*arg0[0][1] * arg1[0][1]) + (*arg0[0][2] * *arg0[0][2])) >> 12; *arg0[1][0] = (s16) (((s32) (temp_t6 * arg1[0][0]) >> 13) - *arg0[0][0]); *arg0[1][1] = (s16) (((s32) (temp_t6 * arg1[0][1]) >> 13) - *arg0[0][1]); - *arg0[1][2] = (s16) (((s32) (temp_t6 * arg1[0][2]) >> 13) - *arg0[0][0]); // Did they mean to do `- *arg0[0][2]` here? - + *arg0[1][2] = + (s16) (((s32) (temp_t6 * arg1[0][2]) >> 13) - *arg0[0][0]); // Did they mean to do `- *arg0[0][2]` here? } #else GLOBAL_ASM("asm/math_util/s16_matrix_rotate.s") @@ -217,9 +223,9 @@ GLOBAL_ASM("asm/math_util/s16_matrix_rotate.s") #ifdef NON_EQUIVALENT // Untested UNUSED void s16_matrix_to_s32_matrix(s16 **arg0, s32 **arg1) { s32 i, j; - for(i = 0; i < 4; i++) { - for(j = 0; j < 4; j++) { - arg1[i][j] = (arg0[i][j] << 16) | arg0[i+4][j]; + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + arg1[i][j] = (arg0[i][j] << 16) | arg0[i + 4][j]; } } } @@ -255,7 +261,7 @@ GLOBAL_ASM("asm/math_util/s16_vec3_mult_by_s32_matrix.s") #endif #ifdef NON_EQUIVALENT -void object_transform_to_matrix(Matrix arg0, ObjectTransform *trans) { +void object_transform_to_matrix(Matrix mtx, ObjectTransform *trans) { f32 yRotSine; f32 yRotCosine; f32 xRotSine; @@ -271,23 +277,23 @@ void object_transform_to_matrix(Matrix arg0, ObjectTransform *trans) { zRotSine = sins(trans->z_rotation) * 0.000015f; zRotCosine = coss(trans->z_rotation) * 0.000015f; scale = trans->scale * 0.000015f; - - arg0[0][0] = ((xRotSine * yRotSine * zRotSine) + (scale * yRotCosine)) * scale; - arg0[0][1] = (zRotSine * xRotCosine * scale); - arg0[0][2] = (((xRotSine * yRotCosine * zRotSine) - (scale * yRotSine)) * scale); - arg0[0][3] = 0; - arg0[1][0] = (((xRotSine * yRotSine * scale) - (zRotSine * yRotCosine)) * scale); - arg0[1][1] = (scale * xRotCosine * scale); - arg0[1][2] = (((xRotSine * yRotCosine * scale) + (zRotSine * yRotSine)) * scale); - arg0[1][3] = 0; - arg0[2][0] = (xRotCosine * yRotSine * scale); - arg0[2][1] = -(xRotSine * scale); - arg0[2][2] = (xRotCosine * yRotCosine * scale); - arg0[2][3] = 0; - arg0[3][0] = trans->x_position; - arg0[3][1] = trans->y_position; - arg0[3][2] = 1.0f; - arg0[3][3] = trans->z_position; + + mtx[0][0] = ((xRotSine * yRotSine * zRotSine) + (scale * yRotCosine)) * scale; + mtx[0][1] = (zRotSine * xRotCosine * scale); + mtx[0][2] = (((xRotSine * yRotCosine * zRotSine) - (scale * yRotSine)) * scale); + mtx[0][3] = 0; + mtx[1][0] = (((xRotSine * yRotSine * scale) - (zRotSine * yRotCosine)) * scale); + mtx[1][1] = (scale * xRotCosine * scale); + mtx[1][2] = (((xRotSine * yRotCosine * scale) + (zRotSine * yRotSine)) * scale); + mtx[1][3] = 0; + mtx[2][0] = (xRotCosine * yRotSine * scale); + mtx[2][1] = -(xRotSine * scale); + mtx[2][2] = (xRotCosine * yRotCosine * scale); + mtx[2][3] = 0; + mtx[3][0] = trans->x_position; + mtx[3][1] = trans->y_position; + mtx[3][2] = 1.0f; + mtx[3][3] = trans->z_position; } #else GLOBAL_ASM("asm/math_util/object_transform_to_matrix.s") @@ -331,9 +337,9 @@ void object_transform_to_matrix_2(Matrix mtx, ObjectTransform *trans) { xRotSine = sins(trans->x_rotation) * 0.000015f; zRotCosine = coss(trans->z_rotation) * 0.000015f; zRotSine = sins(trans->z_rotation) * 0.000015f; - + scale = trans->scale * 0.000015f; - + mtx[0][0] = (yRotSine * scale) - (xRotCosine * zRotCosine * yRotCosine); mtx[0][1] = (xRotCosine * scale * yRotCosine) + (yRotSine * zRotCosine); mtx[0][2] = -(yRotCosine * xRotSine); @@ -402,18 +408,18 @@ void s16_vec3_apply_object_rotation(ObjectTransform *trans, s16 *vec3Arg) { xRotSine = sins(trans->x_rotation); zRotCosine = coss(trans->z_rotation); zRotSine = sins(trans->z_rotation); - + temp_t3 = ((vec3Arg[0] * yRotSine) - (vec3Arg[1] * yRotCosine)) >> 16; temp_t4 = ((vec3Arg[1] * yRotSine) + (vec3Arg[0] * yRotCosine)) >> 16; - - temp_t4 = (( temp_t4 * xRotSine) - (vec3Arg[2] * xRotCosine)) >> 16; - temp_t5 = ((vec3Arg[2] * xRotSine) + ( temp_t4 * xRotCosine)) >> 16; - + + temp_t4 = ((temp_t4 * xRotSine) - (vec3Arg[2] * xRotCosine)) >> 16; + temp_t5 = ((vec3Arg[2] * xRotSine) + (temp_t4 * xRotCosine)) >> 16; + vec3Arg[1] = temp_t4; - + temp_t3 = ((temp_t3 * zRotSine) + (temp_t5 * zRotCosine)) >> 16; temp_t5 = ((temp_t5 * zRotSine) - (temp_t3 * zRotCosine)) >> 16; - + vec3Arg[0] = temp_t3; vec3Arg[2] = temp_t5; } @@ -439,22 +445,22 @@ void f32_vec3_apply_object_rotation(ObjectTransform *trans, f32 *vec3_f32) { xRotCosine = cosf(trans->x_rotation); yRotSine = sinf(trans->y_rotation); yRotCosine = cosf(trans->y_rotation); - + x = vec3_f32[0]; y = vec3_f32[1]; z = vec3_f32[2]; - + x = (vec3_f32[0] * zRotCosine) - (vec3_f32[1] * zRotSine); y = (vec3_f32[1] * zRotCosine) + (vec3_f32[0] * zRotSine); - + temp = y; y = (temp * xRotCosine) - (vec3_f32[2] * xRotSine); z = (vec3_f32[2] * xRotCosine) + (temp * xRotSine); - + temp = x; x = (temp * yRotCosine) + (z * yRotSine); z = (z * yRotCosine) - (temp * yRotSine); - + vec3_f32[0] = x; vec3_f32[1] = y; vec3_f32[2] = z; @@ -482,18 +488,18 @@ void f32_vec3_apply_object_rotation2(ObjectTransform *trans, f32 *arg1) { yRotCosine = cosf(trans->y_rotation); zRotCosine = cosf(trans->z_rotation); zRotSine = sinf(trans->z_rotation); - + temp_f4 = (arg1[0] * xRotSine) + (arg1[2] * xRotCosine); temp_f8 = (arg1[2] * xRotSine) - (arg1[0] * xRotCosine); - + temp_f6 = (arg1[1] * yRotSine) - (temp_f8 * yRotCosine); temp_f8 = (temp_f8 * yRotSine) + (arg1[1] * yRotCosine); - + arg1[2] = temp_f8; - + temp_f4 = (temp_f4 * zRotSine) - (temp_f6 * zRotCosine); temp_f6 = (temp_f6 * zRotSine) + (temp_f4 * zRotCosine); - + arg1[0] = temp_f4; arg1[1] = temp_f6; } @@ -514,13 +520,13 @@ void f32_vec3_apply_object_rotation3(ObjectTransform *trans, f32 *vec3_f32) { xRotCosine = cosf(trans->x_rotation); yRotSine = sinf(trans->y_rotation); yRotCosine = cosf(trans->y_rotation); - + z = vec3_f32[2]; y = -(z * xRotSine); z = z * xRotCosine; x = (z * yRotSine); z = z * yRotCosine; - + vec3_f32[0] = x; vec3_f32[1] = y; vec3_f32[2] = z; @@ -577,8 +583,8 @@ void f32_matrix_from_position(Matrix *mtx, f32 x, f32 y, f32 z) { s32 j; s32 i; // Clear matrix - for(i = 0; i < 4; i++) { - for(j = 0; j < 4; j++) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { *mtx[i][j] = 0; } } @@ -604,43 +610,43 @@ static u16 atan2_lookup(f32 y, f32 x) { if (x == 0) { ret = gArcTanTable[0]; } else { - ret = gArcTanTable[(s32)(y / x * 1024 + 0.5f)]; + ret = gArcTanTable[(s32) (y / x * 1024 + 0.5f)]; } return ret; } -s32 atan2s(s32 x, s32 y) { +s32 atan2s(s32 xDelta, s32 zDelta) { u16 ret; - if (x >= 0) { - if (y >= 0) { - if (y >= x) { - ret = atan2_lookup(x, y); + if (xDelta >= 0) { + if (zDelta >= 0) { + if (zDelta >= xDelta) { + ret = atan2_lookup(xDelta, zDelta); } else { - ret = 0x4000 - atan2_lookup(y, x); + ret = 0x4000 - atan2_lookup(zDelta, xDelta); } } else { - y = -y; - if (y < x) { - ret = 0x4000 + atan2_lookup(y, x); + zDelta = -zDelta; + if (zDelta < xDelta) { + ret = 0x4000 + atan2_lookup(zDelta, xDelta); } else { - ret = 0x8000 - atan2_lookup(x, y); + ret = 0x8000 - atan2_lookup(xDelta, zDelta); } } } else { - x = -x; - if (y < 0) { - y = -y; - if (y >= x) { - ret = 0x8000 + atan2_lookup(x, y); + xDelta = -xDelta; + if (zDelta < 0) { + zDelta = -zDelta; + if (zDelta >= xDelta) { + ret = 0x8000 + atan2_lookup(xDelta, zDelta); } else { - ret = 0xC000 - atan2_lookup(y, x); + ret = 0xC000 - atan2_lookup(zDelta, xDelta); } } else { - if (y < x) { - ret = 0xC000 + atan2_lookup(y, x); + if (zDelta < xDelta) { + ret = 0xC000 + atan2_lookup(zDelta, xDelta); } else { - ret = -atan2_lookup(x, y); + ret = -atan2_lookup(xDelta, zDelta); } } } @@ -695,15 +701,16 @@ UNUSED s32 calc_dyn_lighting_for_level_segment(LevelModelSegment *segment, s32 * numBatches = segment->numberOfBatches; batches = segment->batches; vertCount = 0; - for(i = 0; i < numBatches; i++){ + for (i = 0; i < numBatches; i++) { // batches[i].unk6 is 0xFF if vertex colors are used. Otherwise dynamic lighting is used. - if ((batches[i].unk6 - 0xFF) != 0) { + if ((batches[i].unk6 - 0xFF) != 0) { verts = &segment->vertices[vertCount]; verts2C = &segment->unk2C[vertCount]; - numVertsInBatch = batches[i+1].verticesOffset - batches[i].verticesOffset; - for(j = 0; j < numVertsInBatch; j++) { + numVertsInBatch = batches[i + 1].verticesOffset - batches[i].verticesOffset; + for (j = 0; j < numVertsInBatch; j++) { alpha = verts2C[j].a; - dotProduct = (verts2C[j].x * vec3_ints[0]) + (verts2C[j].y * vec3_ints[1]) + (verts2C[j].z * vec3_ints[2]); + dotProduct = + (verts2C[j].x * vec3_ints[0]) + (verts2C[j].y * vec3_ints[1]) + (verts2C[j].z * vec3_ints[2]); if (dotProduct > 0) { alpha += dotProduct >> 22; if (alpha > 128) { @@ -717,7 +724,7 @@ UNUSED s32 calc_dyn_lighting_for_level_segment(LevelModelSegment *segment, s32 * } vertCount += numVertsInBatch; } else { - vertCount += batches[i+1].verticesOffset - batches[i].verticesOffset; + vertCount += batches[i + 1].verticesOffset - batches[i].verticesOffset; } } return vertCount; @@ -729,9 +736,9 @@ GLOBAL_ASM("asm/math_util/calc_dyn_lighting_for_level_segment.s") #ifdef NON_MATCHING /** * Signed distance field calculation. It's used to calculate the level of intersection between a point and a triangle. -*/ + */ f32 area_triangle_2d(f32 x0, f32 z0, f32 x1, f32 z1, f32 x2, f32 z2) { - f32 dx0 = x1 - x0; + f32 dx0 = x1 - x0; f32 dz0 = z1 - z0; f32 dx1 = x2 - x1; f32 dz1 = z2 - z1; @@ -740,7 +747,7 @@ f32 area_triangle_2d(f32 x0, f32 z0, f32 x1, f32 z1, f32 x2, f32 z2) { f32 d0 = sqrtf((dx0 * dx0) + (dz0 * dz0)); // Distance between points 0 & 1 f32 d1 = sqrtf((dx1 * dx1) + (dz1 * dz1)); // Distance between points 1 & 2 f32 d2 = sqrtf((dx2 * dx2) + (dz2 * dz2)); // Distance between points 2 & 0 - f32 m = 0.5f * (d0 + d1 + d2); // Half the sum of the distances? + f32 m = 0.5f * (d0 + d1 + d2); // Half the sum of the distances? f32 result = m * (m - d0) * (m - d1) * (m - d2); if (result < 0.0f) { result = 0.0f; @@ -759,4 +766,4 @@ void dmacopy_doubleword(void *src, void *dst, s32 size) { } #else GLOBAL_ASM("asm/math_util/dmacopy_doubleword.s") -#endif \ No newline at end of file +#endif diff --git a/src/memory.c b/src/memory.c index 3c2f9a4f..e54d165d 100644 --- a/src/memory.c +++ b/src/memory.c @@ -18,14 +18,14 @@ s32 gNumberOfMemoryPools; UNUSED s32 D_801235C4; FreeQueueSlot gFreeQueue[256]; s32 gFreeQueueCount; -s32 gFreeQueueTimer; //Official Name: mmDelay +s32 gFreeQueueTimer; // Official Name: mmDelay extern MemoryPoolSlot gMainMemoryPool; /******************************/ /** - * Creates the main memory pool. + * Creates the main memory pool. * Starts at 0x8012D3F0. Ends at 0x80400000. Contains 1600 allocation slots. * Official Name: mmInit */ @@ -38,7 +38,7 @@ void init_main_memory_pool(void) { } else { ramEnd = RAM_END; } - new_memory_pool(&gMainMemoryPool, ramEnd - (s32)(&gMainMemoryPool), MAIN_POOL_SLOT_COUNT); + new_memory_pool(&gMainMemoryPool, ramEnd - (s32) (&gMainMemoryPool), MAIN_POOL_SLOT_COUNT); set_free_queue_state(2); gFreeQueueCount = 0; } @@ -64,13 +64,13 @@ MemoryPoolSlot *new_sub_memory_pool(s32 poolDataSize, s32 numSlots) { /** * Create and initialise a memory pool in RAM that will act as the place where arbitrary allocations can go. * Will return the location of the first free slot in that pool. -*/ + */ MemoryPoolSlot *new_memory_pool(MemoryPoolSlot *slots, s32 poolSize, s32 numSlots) { MemoryPoolSlot *firstSlot; s32 poolCount; s32 i; s32 firstSlotSize; - + poolCount = ++gNumberOfMemoryPools; firstSlotSize = poolSize - (numSlots * sizeof(MemoryPoolSlot)); gMemoryPools[poolCount].maxNumSlots = numSlots; @@ -107,7 +107,7 @@ void *allocate_from_main_pool_safe(s32 size, u32 colourTag) { dump_memory_to_cpak(get_stack_pointer()->unk14, size, colourTag); } temp_v0 = allocate_from_memory_pool(0, size, colourTag); - if (temp_v0 == (void *)NULL) { + if (temp_v0 == (void *) NULL) { dump_memory_to_cpak(get_stack_pointer()->unk14, size, colourTag); } return temp_v0; @@ -123,7 +123,7 @@ MemoryPoolSlot *allocate_from_main_pool(s32 size, u32 colourTag) { /** * Search the existing empty slots and try to find one that can meet the size requirement. * Afterwards, write the new allocation data to the slot in question and return the address. -*/ + */ MemoryPoolSlot *allocate_from_memory_pool(s32 poolIndex, s32 size, u32 colourTag) { s32 slotSize; MemoryPoolSlot *curSlot; @@ -133,7 +133,7 @@ MemoryPoolSlot *allocate_from_memory_pool(s32 poolIndex, s32 size, u32 colourTag u32 flags; s32 nextIndex; s32 currIndex; - + flags = disable_interrupts(); if (size == 0) { stubbed_printf("*** mmAlloc: size = 0 ***\n"); @@ -180,7 +180,7 @@ void *allocate_from_pool_containing_slots(MemoryPoolSlot *slots, s32 size) { return allocate_from_memory_pool(i, size, 0); } } - return (void *)NULL; + return (void *) NULL; } /* Official Name: mmAllocAtAddr */ @@ -189,7 +189,7 @@ void *allocate_at_address_in_main_pool(s32 size, u8 *address, u32 colorTag) { MemoryPoolSlot *curSlot; MemoryPoolSlot *slots; u32 flags; - + flags = disable_interrupts(); if (size == 0) { stubbed_printf("*** mmAllocAtAddr: size = 0 ***\n"); @@ -205,7 +205,8 @@ void *allocate_at_address_in_main_pool(s32 size, u8 *address, u32 colorTag) { for (i = 0; i != -1; i = curSlot->nextIndex) { curSlot = &slots[i]; if (curSlot->flags == 0) { - if ((u32) address >= (u32) curSlot->data && (u32)address + size <= (u32) curSlot->data + curSlot->size) { + if ((u32) address >= (u32) curSlot->data && + (u32) address + size <= (u32) curSlot->data + curSlot->size) { if (address == (u8 *) curSlot->data) { allocate_memory_pool_slot(0, i, size, 1, 0, colorTag); enable_interrupts(flags); @@ -289,13 +290,13 @@ void free_slot_containing_address(u8 *address) { MemoryPool *pool; MemoryPoolSlot *slots; MemoryPoolSlot *slot; - + poolIndex = get_memory_pool_index_containing_address(address); pool = gMemoryPools; slots = pool[poolIndex].slots; for (slotIndex = 0; slotIndex != -1; slotIndex = slot->nextIndex) { slot = &slots[slotIndex]; - + if (address == (u8 *) slot->data) { if (slot->flags == 1 || slot->flags == 4) { free_memory_pool_slot(poolIndex, slotIndex); @@ -313,7 +314,7 @@ UNUSED void func_80071314(void) { u32 flags; s32 poolIndex; s32 slotIndex; - + flags = disable_interrupts(); poolIndex = gNumberOfMemoryPools; while (poolIndex != -1) { @@ -348,7 +349,7 @@ UNUSED const char D_800E7438[] = "\n*** mm Error *** ---> Can't unfix the specif /** * Adds the current memory address to the back of the queue, so it can be freed. -*/ + */ void add_to_free_queue(void *dataAddress) { gFreeQueue[gFreeQueueCount].dataAddress = dataAddress; gFreeQueue[gFreeQueueCount].freeTimer = gFreeQueueTimer; @@ -382,7 +383,7 @@ s32 func_80071478(u8 *address) { /** * Search the memory pool for the slot that's tied to the given address. * Return true if it's found, otherwise return false. -*/ + */ s32 memory_slot_exists(u8 *address) { s32 slotIndex; MemoryPoolSlot *slot; @@ -394,7 +395,7 @@ s32 memory_slot_exists(u8 *address) { slotIndex = 0; while (slotIndex != -1) { slot = slotIndex + pool->slots; // `slot = &pool->slots[slotIndex];` does not match. - if (address == (u8 *)slot->data) { + if (address == (u8 *) slot->data) { if (slot->flags & 2) { slot->flags ^= 2; enable_interrupts(flags); @@ -429,7 +430,7 @@ s32 get_memory_pool_index_containing_address(u8 *address) { /** * Clears the current slot of all information, effectively freeing the allocated memory. * Unused slots before and after will be merged with this slot -*/ + */ void free_memory_pool_slot(s32 poolIndex, s32 slotIndex) { s32 nextIndex; s32 prevIndex; @@ -439,7 +440,7 @@ void free_memory_pool_slot(s32 poolIndex, s32 slotIndex) { MemoryPoolSlot *slot; MemoryPoolSlot *nextSlot; MemoryPoolSlot *prevSlot; - + pool = &gMemoryPools[poolIndex]; slots = pool->slots; pool = pool; // Fakematch @@ -478,7 +479,7 @@ void free_memory_pool_slot(s32 poolIndex, s32 slotIndex) { /** * Return the address of the first slot of a given memory pool. -*/ + */ UNUSED MemoryPoolSlot *get_memory_pool_address(s32 poolIndex) { return gMemoryPools[poolIndex].slots; } @@ -487,14 +488,15 @@ UNUSED MemoryPoolSlot *get_memory_pool_address(s32 poolIndex) { * Initialise and attempts to fit the new memory block in the slot given. * Updates the linked list with any entries before and after then returns the new slot index. * If the region cannot fit, return the old slot instead. -*/ -s32 allocate_memory_pool_slot(s32 poolIndex, s32 slotIndex, s32 size, s32 slotIsTaken, s32 newSlotIsTaken, u32 colourTag) { + */ +s32 allocate_memory_pool_slot(s32 poolIndex, s32 slotIndex, s32 size, s32 slotIsTaken, s32 newSlotIsTaken, + u32 colourTag) { MemoryPool *pool; MemoryPoolSlot *poolSlots; s32 index; s32 nextIndex; s32 poolSize; - + pool = &gMemoryPools[poolIndex]; poolSlots = pool->slots; pool = pool; // Fakematch @@ -528,9 +530,9 @@ s32 allocate_memory_pool_slot(s32 poolIndex, s32 slotIndex, s32 size, s32 slotIs * Official name: mmAlign16 */ u8 *align16(u8 *address) { - s32 remainder = (s32)address & 0xF; + s32 remainder = (s32) address & 0xF; if (remainder > 0) { - address = (u8 *)(((s32)address - remainder) + 16); + address = (u8 *) (((s32) address - remainder) + 16); } return address; } @@ -540,9 +542,9 @@ u8 *align16(u8 *address) { * Official name: mmAlign8 */ UNUSED u8 *align8(u8 *address) { - s32 remainder = (s32)address & 0x7; + s32 remainder = (s32) address & 0x7; if (remainder > 0) { - address = (u8 *)(((s32)address - remainder) + 8); + address = (u8 *) (((s32) address - remainder) + 8); } return address; } @@ -552,9 +554,9 @@ UNUSED u8 *align8(u8 *address) { * Official name: mmAlign4 */ UNUSED u8 *align4(u8 *address) { - s32 remainder = (s32)address & 0x3; + s32 remainder = (s32) address & 0x3; if (remainder > 0) { - address = (u8 *)(((s32)address - remainder) + 4); + address = (u8 *) (((s32) address - remainder) + 4); } return address; } @@ -565,7 +567,7 @@ UNUSED u8 *align4(u8 *address) { * Afterwards, print out the results. * Since the function only has space for 64 different colours, make sure * any missed tallies are at least reported. -*/ + */ UNUSED s32 find_active_pool_slot_colours(void) { u32 colours[64]; u32 colourCounts[64]; @@ -576,11 +578,11 @@ UNUSED s32 find_active_pool_slot_colours(void) { s32 colourIndex; s32 slotColour; u32 curColour; - + numOverflows = 0; for (j = 0; j < 64; j++) { colours[j] = 0; - colourCounts[j] = 0; + colourCounts[j] = 0; } for (i = 0; i < gNumberOfMemoryPools; i++) { curSlot = gMemoryPools[i].slots; @@ -622,7 +624,7 @@ UNUSED s32 find_active_pool_slot_colours(void) { /** * Search through each memory pool, counting up the slots that match the colour tag looking to be found. * Marked as unused, since the functions calling it is also unused. -*/ + */ UNUSED s32 get_memory_colour_tag_count(u32 colourTag) { s32 i, count; MemoryPoolSlot *slot; @@ -630,7 +632,7 @@ UNUSED s32 get_memory_colour_tag_count(u32 colourTag) { slot = &gMemoryPools[0].slots[0]; for (i = 0; i < MAIN_POOL_SLOT_COUNT; i++) { if (slot->flags != 0) { - if(colourTag == slot->colourTag) { + if (colourTag == slot->colourTag) { count++; } } @@ -678,7 +680,7 @@ UNUSED void mmSlotPrint(void) { s32 index2; s32 nextIndex; MemoryPoolSlot *slot; - + for (i = 0; (gNumberOfMemoryPools ^ 0) >= i; i++) { if (i && i) {} // Fakematch slot = &gMemoryPools[i].slots[0]; diff --git a/src/memory.h b/src/memory.h index 9b0f8a02..c69cd442 100644 --- a/src/memory.h +++ b/src/memory.h @@ -88,10 +88,11 @@ void render_memory_colour_tags(void); void func_80071CE8(void); MemoryPoolSlot *new_memory_pool(MemoryPoolSlot *slots, s32 poolSize, s32 numSlots); void free_memory_pool_slot(s32 poolIndex, s32 slotIndex); -s32 allocate_memory_pool_slot(s32 memoryPoolIndex, s32 slotIndex, s32 size, s32 slotIsTaken, s32 newSlotIsTaken, u32 colourTag); +s32 allocate_memory_pool_slot(s32 poolIndex, s32 slotIndex, s32 size, s32 slotIsTaken, s32 newSlotIsTaken, + u32 colourTag); s32 get_memory_colour_tag_count(u32 colourTag); void free_slot_containing_address(u8 *address); -MemoryPoolSlot *allocate_from_memory_pool(s32 memoryPoolIndex, s32 size, u32 colourTag); -void *allocate_at_address_in_main_pool(s32 size, u8 *address, u32 colourTag); +MemoryPoolSlot *allocate_from_memory_pool(s32 poolIndex, s32 size, u32 colourTag); +void *allocate_at_address_in_main_pool(s32 size, u8 *address, u32 colorTag); #endif diff --git a/src/menu.c b/src/menu.c index 9163e83e..8002f036 100644 --- a/src/menu.c +++ b/src/menu.c @@ -40,8 +40,8 @@ // The bss section needs to stay above the data section! // Otherwise the bss variables will get reordered, which is bad. -char D_80126390[4]; //course initials -char D_80126394[4]; //flap initials +char D_80126390[4]; // course initials +char D_80126394[4]; // flap initials s32 gSaveGhostDelayCounter; s32 gPreviousMenuID; Gfx *sMenuCurrDisplayList; @@ -54,12 +54,13 @@ unk801263C0 D_801263B8; s32 gOptionBlinkTimer; unk801263C0 gMenuCurrentCharacter; -s32 gIgnorePlayerInputTime; // A set amount of time to ignore player input. +s32 gIgnorePlayerInputTime; // A set amount of time to ignore player input. UNUSED s32 sUnused_801263C8; // Set to 0 in menu_init, and never again. -CharacterSelectData (*gCurrCharacterSelectData)[10]; //Some sort of character list? Cares if T.T. and Drumstick are unlocked +CharacterSelectData ( + *gCurrCharacterSelectData)[10]; // Some sort of character list? Cares if T.T. and Drumstick are unlocked -s32 D_801263D0; //Compared for equality to gTrackIdForPreview -s8 gActivePlayersArray[MAXCONTROLLERS]; //Boolean value for each controller if it's active with a player. +s32 D_801263D0; // Compared for equality to gTrackIdForPreview +s8 gActivePlayersArray[MAXCONTROLLERS]; // Boolean value for each controller if it's active with a player. s32 gOpacityDecayTimer; s8 D_801263DC[MAXCONTROLLERS]; s32 gMenuOptionCount; @@ -70,21 +71,21 @@ s32 D_801263F8[8]; u8 D_80126418[8]; u8 D_80126420[8]; u8 D_80126428[8]; -u8 D_80126430[8]; //Contains the order of racer indices that tell you what place they are in. +u8 D_80126430[8]; // Contains the order of racer indices that tell you what place they are in. s8 D_80126438[16]; -//Eeeprom save data bits stored at address 0xF -//bit 0 = Adventure Two is Unlocked -//bit 1 = Used to set the CHEAT_CONTROL_DRUMSTICK magic code flag. Drumstick is unlocked flag? -//bits 2-3 = Current language value -//bits 4-23 = Used to set the CHEAT_CONTROL_TT magic code flag. Could be tracks where TT has been beat? -//bit 24 = Unknown, but it's set as a default high bit. -//bit 25 = Seems to be a flag for whether subtitles are enabled or not. -//bits 26-55 = Unknown, but it could be a set of flags for unlocked tracks -//bits 56-63 = Checksum bits. These are calculated from the previous bits, -// and validated using calculate_eeprom_settings_checksum. -// If the checksum fails, the settings are reset to just -// bits 24/25 being high. +// Eeeprom save data bits stored at address 0xF +// bit 0 = Adventure Two is Unlocked +// bit 1 = Used to set the CHEAT_CONTROL_DRUMSTICK magic code flag. Drumstick is unlocked flag? +// bits 2-3 = Current language value +// bits 4-23 = Used to set the CHEAT_CONTROL_TT magic code flag. Could be tracks where TT has been beat? +// bit 24 = Unknown, but it's set as a default high bit. +// bit 25 = Seems to be a flag for whether subtitles are enabled or not. +// bits 26-55 = Unknown, but it could be a set of flags for unlocked tracks +// bits 56-63 = Checksum bits. These are calculated from the previous bits, +// and validated using calculate_eeprom_settings_checksum. +// If the checksum fails, the settings are reset to just +// bits 24/25 being high. u64 sEepromSettings; f32 sBootScreenTimer; @@ -111,18 +112,18 @@ s32 D_8012649C; SavefileInfo gSavefileInfo[4]; s32 D_801264D0; -s32 D_801264D4; //Count of elements in some arrays? D_80126540, D_80126508, D_80126510, D_80126518, D_80126520? +s32 D_801264D4; // Count of elements in some arrays? D_80126540, D_80126508, D_80126510, D_80126518, D_80126520? s8 gDialogueSubmenu; -u8 D_801264DC[4]; //gGhostLevelIDs? +u8 D_801264DC[4]; // gGhostLevelIDs? s8 D_801264E0; s8 D_801264E1; s8 sCurrentMenuID; -u8 D_801264E4[4]; //gGhostSomethings? +u8 D_801264E4[4]; // gGhostSomethings? s32 D_801264E8; -u8 D_801264EC[4]; //gGhostVehicleIds? +u8 D_801264EC[4]; // gGhostVehicleIds? s32 D_801264F0[2]; -u16 D_801264F8[6]; //gGhostChecksums? +u16 D_801264F8[6]; // gGhostChecksums? s8 sDialogueOptionMax; u8 D_80126508[6]; s8 gDialogueOptionYOffset; @@ -134,14 +135,14 @@ Settings *gSavefileData[4]; u8 D_80126540[8]; s32 gMultiplayerSelectedNumberOfRacersCopy; // Saved version gMultiplayerSelectedNumberOfRacers? void *gMenuObjects[128]; // lookup table? Contains Textures, Objects, and Sprites. Need to change name and type. -u8 D_80126750[128]; // Seems to be a boolean for "This texture exists" for the above array. +u8 D_80126750[128]; // Seems to be a boolean for "This texture exists" for the above array. s32 D_801267D0; s32 D_801267D4; -s32 D_801267D8[5]; //Buttons pressed per player plus an extra? +s32 D_801267D8[5]; // Buttons pressed per player plus an extra? s8 *D_801267EC; s32 D_801267F0[5]; s8 *D_80126804; -s32 D_80126808[MAXCONTROLLERS]; //Soundmask values +s32 D_80126808[MAXCONTROLLERS]; // Soundmask values s16 D_80126818[5]; s32 D_80126824; UNUSED s8 sUnused_80126828; // Set to 0 in menu_init, and never used again. @@ -153,7 +154,7 @@ s32 D_80126840; s32 D_80126844; s32 D_80126848; s32 D_8012684C; -s32 *D_80126850; //Never set, but it's read? Is it part of a larger struct being set? +s32 *D_80126850; // Never set, but it's read? Is it part of a larger struct being set? s32 D_80126854; s32 D_80126858; s32 D_8012685C; @@ -162,13 +163,13 @@ s32 gTitleDemoIndex; s16 gTitleDemoTimer; s32 gTitleRevealTimer; f32 gTitleAudioCounter; -s8 *sTitleScreenDemoIds; //Misc Asset 66 - title_screen_demo_ids.bin - 12 or 13 values. +s8 *sTitleScreenDemoIds; // Misc Asset 66 - title_screen_demo_ids.bin - 12 or 13 values. unk80126878 D_80126878[8]; f32 D_801268D8; s32 D_801268DC; s32 D_801268E0; s32 D_801268E4; -s16 D_801268E8[4][6]; //Track Select values? +s16 D_801268E8[4][6]; // Track Select values? s16 gFFLUnlocked; UNUSED s32 D_8012691C; UNUSED s32 D_80126920; @@ -199,14 +200,15 @@ s32 D_80126A14; s32 D_80126A18; s32 D_80126A1C; s32 sControllerPakNotesFree[MAXCONTROLLERS]; // Looks to be an array for number notes free in each controller memory pak -u8 sControllerPakIssueNotFound[MAXCONTROLLERS]; //Flag to see if there's no known issues for the given controller pak -u8 sControllerPakFatalErrorFound[MAXCONTROLLERS]; //Flag to see if there's a fatal error for the given controller pak -u8 sControllerPakNoFreeSpace[MAXCONTROLLERS]; //Flag to see if there's no free space for the given controller pak -u8 sControllerPakBadData[MAXCONTROLLERS]; //Flag to see if there's bad data for the given controller pak -char *gMenuOptionText[8]; //Menu Text -u8 sControllerPakDataPresent[MAXCONTROLLERS]; //Flag to see if there's data present for the given controller pak? Not sure +u8 sControllerPakIssueNotFound[MAXCONTROLLERS]; // Flag to see if there's no known issues for the given controller pak +u8 sControllerPakFatalErrorFound[MAXCONTROLLERS]; // Flag to see if there's a fatal error for the given controller pak +u8 sControllerPakNoFreeSpace[MAXCONTROLLERS]; // Flag to see if there's no free space for the given controller pak +u8 sControllerPakBadData[MAXCONTROLLERS]; // Flag to see if there's bad data for the given controller pak +char *gMenuOptionText[8]; // Menu Text +u8 sControllerPakDataPresent[MAXCONTROLLERS]; // Flag to see if there's data present for the given controller pak? Not + // sure char *D_80126A64; -s32 gMenuOption; //sCurrentControllerIndex? +s32 gMenuOption; // sCurrentControllerIndex? s32 D_80126A6C; char **gDeviceStatusStrings; s32 D_80126A74; @@ -217,13 +219,13 @@ s32 D_80126A90; s32 D_80126A94; s32 D_80126A98; s32 D_80126A9C; -char *D_80126AA0[16]; //Text to render -u8 *sCurrentControllerPakAllFileNames[16]; //Every file name on the controller pak -u8 *sCurrentControllerPakAllFileExtensions[16]; //Every file extension on the controller pak -u8 sCurrentControllerPakAllFileTypes[16]; //File type of all files on controller pak -u32 sCurrentControllerPakAllFileSizes[16]; //File size of all files on controller pak -u32 sCurrentControllerPakFreeSpace; //Space available in current controller pak -s32 sControllerPakMenuNumberOfRows; //8 if PAL, 7 if not +char *D_80126AA0[16]; // Text to render +u8 *sCurrentControllerPakAllFileNames[16]; // Every file name on the controller pak +u8 *sCurrentControllerPakAllFileExtensions[16]; // Every file extension on the controller pak +u8 sCurrentControllerPakAllFileTypes[16]; // File type of all files on controller pak +u32 sCurrentControllerPakAllFileSizes[16]; // File size of all files on controller pak +u32 sCurrentControllerPakFreeSpace; // Space available in current controller pak +s32 sControllerPakMenuNumberOfRows; // 8 if PAL, 7 if not TextureHeader *D_80126BB8; TextureHeader *D_80126BBC; s32 D_80126BC0; @@ -285,17 +287,17 @@ s32 gTitleScreenCurrentOption = 0; // 0 = "Start", 1 = "Options" // Currently selected index for all menus. s32 gMenuCurIndex = 0; -s32 unused_800DF464 = 4; +s32 unused_800DF464 = 4; s32 unused_800DF468 = 0; // Used as a short delay before printing the missing controller text. s32 gMissingControllerDelay = 0; -s32 gCurrentMenuId = 0; +s32 gCurrentMenuId = 0; s32 unused_800DF474 = 0; // A boolean, set to TRUE when a track is loaded using gTrackIdToLoad. -s32 gTrackSpecifiedWithTrackIdToLoad = 0; +s32 gTrackSpecifiedWithTrackIdToLoad = 0; s32 gMenuDelay = 0; s32 gNumberOfReadyPlayers = 0; @@ -316,19 +318,19 @@ u8 sMenuGuiColourBlendFactor = 0; // Flags for menu/HUD sprites. Used in func_8009CA60() // Seems like it doesn't matter what you set it as? -s32 gMenuSpriteFlags = 0; +s32 gMenuSpriteFlags = 0; -s32 gIsInTracksMode = 1; -s32 gNumberOfActivePlayers = 1; +s32 gIsInTracksMode = 1; +s32 gNumberOfActivePlayers = 1; s32 gIsInTwoPlayerAdventure = 0; -s32 gTrackIdForPreview = ASSET_LEVEL_CENTRALAREAHUB; -s32 gTrackSelectRow = 0; // 1 = Dino Domain, 2 = Sherbet Island, etc. -s32 gSaveFileIndex = 0; -s32 unused_800DF4D0 = 0; -s32 gTrackIdToLoad = 0; -s8 unused_800DF4D8 = 1; -s8 gNextTajChallengeMenu = FALSE; -s8 gNeedToCloseDialogueBox = FALSE; +s32 gTrackIdForPreview = ASSET_LEVEL_CENTRALAREAHUB; +s32 gTrackSelectRow = 0; // 1 = Dino Domain, 2 = Sherbet Island, etc. +s32 gSaveFileIndex = 0; +s32 unused_800DF4D0 = 0; +s32 gTrackIdToLoad = 0; +s8 unused_800DF4D8 = 1; +s8 gNextTajChallengeMenu = FALSE; +s8 gNeedToCloseDialogueBox = FALSE; // Array of booleans, set to TRUE when you are done talking to an NPC. // This has (atleast) 5 elements, not 4! @@ -337,34 +339,32 @@ s8 gDoneTalkingToNPC[5] = { FALSE, // Unused? FALSE, // T.T. FALSE, // Taj Challenge - FALSE // Trophy Cabinet + FALSE // Trophy Cabinet }; s8 gDialogueOptionTangible = FALSE; -s32 unused_800DF4F0[] = { - 0x4000, 0x8000, 0x1000, 0x2000, 0x8000, 0x10, 0x400, 0x00 -}; +s32 unused_800DF4F0[] = { 0x4000, 0x8000, 0x1000, 0x2000, 0x8000, 0x10, 0x400, 0x00 }; unk800DF510 sMenuImageProperties[18] = { - { 0, 0, 0, 0x00, 1.0f, 0.0f, 0.0f, -32.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x01, 1.0f, 0.0f, 0.0f, -32.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x02, 1.0f, 0.0f, 0.0f, -32.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x03, 1.0f, 0.0f, 0.0f, -32.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x05, 0.215f, 0.0f, 0.0f, -500.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x06, 0.215f, 0.0f, 0.0f, -500.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x07, 0.215f, 0.0f, 0.0f, -500.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x00, 1.0f, 0.0f, 0.0f, -32.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x01, 1.0f, 0.0f, 0.0f, -32.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x02, 1.0f, 0.0f, 0.0f, -32.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x03, 1.0f, 0.0f, 0.0f, -32.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x05, 0.215f, 0.0f, 0.0f, -500.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x06, 0.215f, 0.0f, 0.0f, -500.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x07, 0.215f, 0.0f, 0.0f, -500.0f, 0, 0, 0, 0, 0, { 0 } }, { 0, 0, 0, 0x04, 0.125f, 0.0f, -40.0f, -500.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x5B, 0.75f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x5C, 0.75f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x42, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x40, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x41, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x4C, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x4D, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x4E, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x4F, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, - { 0, 0, 0, 0x5D, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x5B, 0.75f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x5C, 0.75f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x42, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x40, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x41, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x4C, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x4D, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x4E, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x4F, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, + { 0, 0, 0, 0x5D, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, { 0 } }, }; s16 *gAssetsMenuElementIds[1] = { NULL }; @@ -379,8 +379,10 @@ s32 unused_800DF768 = 1; FadeTransition sMenuTransitionFadeInFast = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_BLACK, 10, -1); FadeTransition sMenuTransitionFadeIn = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_BLACK, 18, -1); FadeTransition sMenuTransitionFadeOut = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_OUT, FADE_COLOR_BLACK, 18, 0); -UNUSED FadeTransition sMenuTransitionFadeInWhite = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_WHITE, 18, -1); -UNUSED FadeTransition sMenuTransitionFadeOutWhite = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_OUT, FADE_COLOR_WHITE, 18, 0); +UNUSED FadeTransition sMenuTransitionFadeInWhite = + FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_WHITE, 18, -1); +UNUSED FadeTransition sMenuTransitionFadeOutWhite = + FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_OUT, FADE_COLOR_WHITE, 18, 0); s32 gTrophyRankingsState = 4; MenuElement *gTrophyRankingsMenuElements = NULL; @@ -393,48 +395,38 @@ char *gTitleMenuStrings[3] = { 0, 0, 0 }; char gVersionDisplayText[20] = "VERSION XXXXXXXX"; // "Diddy Kong Racing" logo texture indices -s16 sGameTitleTileTextures[12] = { - TEXTURE_TITLE_SEGMENT_01, - TEXTURE_TITLE_SEGMENT_02, - TEXTURE_TITLE_SEGMENT_03, - TEXTURE_TITLE_SEGMENT_04, - TEXTURE_TITLE_SEGMENT_05, - TEXTURE_TITLE_SEGMENT_06, - TEXTURE_TITLE_SEGMENT_07, - TEXTURE_TITLE_SEGMENT_08, - TEXTURE_TITLE_SEGMENT_09, - TEXTURE_TITLE_SEGMENT_10, - TEXTURE_TITLE_SEGMENT_11, - -1 -}; +s16 sGameTitleTileTextures[12] = { TEXTURE_TITLE_SEGMENT_01, TEXTURE_TITLE_SEGMENT_02, TEXTURE_TITLE_SEGMENT_03, + TEXTURE_TITLE_SEGMENT_04, TEXTURE_TITLE_SEGMENT_05, TEXTURE_TITLE_SEGMENT_06, + TEXTURE_TITLE_SEGMENT_07, TEXTURE_TITLE_SEGMENT_08, TEXTURE_TITLE_SEGMENT_09, + TEXTURE_TITLE_SEGMENT_10, TEXTURE_TITLE_SEGMENT_11, -1 }; -DrawTexture sGameTitleTileOffsets[12] = { - { NULL, -75, -32 }, - { NULL, -60, -32 }, - { NULL, -45, -32 }, - { NULL, -30, -32 }, - { NULL, -15, -32 }, - { NULL, 0, -32 }, - { NULL, 15, -32 }, - { NULL, 30, -32 }, - { NULL, 45, -32 }, - { NULL, 60, -32 }, - { NULL, 75, -32 }, - { NULL, 0, 0 } -}; +DrawTexture sGameTitleTileOffsets[12] = { { NULL, -75, -32 }, { NULL, -60, -32 }, { NULL, -45, -32 }, + { NULL, -30, -32 }, { NULL, -15, -32 }, { NULL, 0, -32 }, + { NULL, 15, -32 }, { NULL, 30, -32 }, { NULL, 45, -32 }, + { NULL, 60, -32 }, { NULL, 75, -32 }, { NULL, 0, 0 } }; // Title screen cinematic text unk800DF83C gTitleCinematicText[10] = { - { "TIMBER", 14.0f, 14.5f, 16.5f, 17.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, - { "BUMPER", 19.0f, 19.5f, 21.5f, 22.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, - { "CONKER", 24.0f, 24.5f, 26.5f, 27.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, - { "TIPTUP", 29.0f, 29.5f, 31.5f, 32.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, - { "DRUMSTICK", 35.0f, 35.5f, 37.5f, 38.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, - { "PIPSY", 40.0f, 40.5f, 42.5f, 43.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, - { "BANJO", 45.0f, 45.5f, 47.5f, 48.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, - { "KRUNCH", 50.0f, 50.5f, 52.5f, 53.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, - { "WIZPIG", 57.5f, 58.0f, 60.0f, 60.5f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, - { "DIDDY", 63.5f, 64.0f, 66.0f, 66.5f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f } + { "TIMBER", 14.0f, 14.5f, 16.5f, 17.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, + SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, + { "BUMPER", 19.0f, 19.5f, 21.5f, 22.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, + SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, + { "CONKER", 24.0f, 24.5f, 26.5f, 27.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, + SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, + { "TIPTUP", 29.0f, 29.5f, 31.5f, 32.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, + SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, + { "DRUMSTICK", 35.0f, 35.5f, 37.5f, 38.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, + SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, + { "PIPSY", 40.0f, 40.5f, 42.5f, 43.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, + SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, + { "BANJO", 45.0f, 45.5f, 47.5f, 48.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, + SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, + { "KRUNCH", 50.0f, 50.5f, 52.5f, 53.0f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, + SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, + { "WIZPIG", 57.5f, 58.0f, 60.0f, 60.5f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, + SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f }, + { "DIDDY", 63.5f, 64.0f, 66.0f, 66.5f, -80.0f, SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT_HALF, + SCREEN_HEIGHT_FLOAT - 32.0f, SCREEN_WIDTH_FLOAT + 80.0f, SCREEN_HEIGHT_FLOAT - 32.0f } }; // Number of active colours used in the title screen cinematic. @@ -442,36 +434,26 @@ s32 gTitleCinematicTextColourCount = 0; // Colours used for the Character Names during the title screen cinematic MenuColour gTitleCinematicTextColours[4] = { - { 255, 255, 0, 255, 204 }, // Yellow - { 0, 255, 0, 255, 153 }, // Green - { 0, 255, 255, 255, 102 }, // Cyan - { 0, 0, 255, 255, 51 } // Blue + { 255, 255, 0, 255, 204 }, // Yellow + { 0, 255, 0, 255, 153 }, // Green + { 0, 255, 255, 255, 102 }, // Cyan + { 0, 0, 255, 255, 51 } // Blue }; -UNUSED u8 unused_800DFA10[4] = { - 0, 0, 15, 120 -}; +UNUSED u8 unused_800DFA10[4] = { 0, 0, 15, 120 }; -char *gOptionMenuStrings[7] = { - NULL, NULL, NULL, NULL, NULL, NULL, NULL -}; +char *gOptionMenuStrings[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; -s16 gOptionMenuTextures[8] = { - 0x3D, 0x3C, 0x3F, 0x3E, 0x44, -1, -1, 0 -}; +s16 gOptionMenuTextures[8] = { 0x3D, 0x3C, 0x3F, 0x3E, 0x44, -1, -1, 0 }; unk800DFA3C gAudioMenuStrings[8] = { - { 160, 80, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, - { 160, 104, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, - { 160, 144, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, - { 160, 192, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, - { 161, 35, 0, 0, 0, 0xFF, 0x80, 2, 0, 12, NULL }, - { 160, 32, 0xFF, 0x80, 0xFF, 0, 0xFF, 2, 0, 12, NULL }, - { 160, 188, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, + { 160, 80, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, { 160, 104, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, + { 160, 144, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, { 160, 192, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, + { 161, 35, 0, 0, 0, 0xFF, 0x80, 2, 0, 12, NULL }, { 160, 32, 0xFF, 0x80, 0xFF, 0, 0xFF, 2, 0, 12, NULL }, + { 160, 188, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, }; -// Current song index used in the music test (from JUKEBOX magic code) +// Current song index used in the music test (from JUKEBOX magic code) s32 gMusicTestSongIndex = 0; s32 gSfxVolumeSliderValue = 256; // Value from 0 to 256 @@ -502,12 +484,20 @@ char *gContPakRumbleDetectedStrings[6] = { 0, 0, 0, 0, 0, 0 }; char *gContPakSwitchToRumbleStrings[6] = { 0, 0, 0, 0, 0, 0 }; char *gContPakNeed2ndAdvStrings[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; -//Associated with SIDeviceStatus enum values. -char **gContPakStrings[11] = { - NULL, gContPakNotPresentStrings, gContPakCorruptDataRepairStrings, gContPakDamagedStrings, gContPakFullStrings, gContPakDiffContStrings, gContPakNoRoomForGhostsStrings, gContPakRumbleDetectedStrings, gContPakSwitchToRumbleStrings, gContPakCorruptDataStrings, gContPakNeed2ndAdvStrings -}; +// Associated with SIDeviceStatus enum values. +char **gContPakStrings[11] = { NULL, + gContPakNotPresentStrings, + gContPakCorruptDataRepairStrings, + gContPakDamagedStrings, + gContPakFullStrings, + gContPakDiffContStrings, + gContPakNoRoomForGhostsStrings, + gContPakRumbleDetectedStrings, + gContPakSwitchToRumbleStrings, + gContPakCorruptDataStrings, + gContPakNeed2ndAdvStrings }; -s32 unused_800DFC08 = 0; +s32 unused_800DFC08 = 0; s32 unused_800DFC0C = 0xFFFF; /*** Icons in the save options menu. ***/ @@ -520,28 +510,20 @@ DrawTexture gDrawTexTrashIcon[2] = { { NULL, 0, 0 }, { NULL, 0, 0 } }; u8 unused_800DFC70[8] = { 0x40, 0x40, 0x04, 0x04, 0xFF, 0, 0, 0 }; -s16 gSaveMenuObjectIndices[26] = { - 0x0024, 0x0025, 0x0018, 0x0019, - 0x001A, 0x001B, 0x001C, 0x001D, - 0x003D, 0x003F, 0x003E, 0x003C, - 0x0043, 0x0044, 0x0045, 0x0046, - 0x0047, 0x0048, 0x0049, 0x004A, - 0x004B, 0x0040, 0x0041, 0x0002, - 0xFFFF, 0x0000 -}; +s16 gSaveMenuObjectIndices[26] = { 0x0024, 0x0025, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x003D, + 0x003F, 0x003E, 0x003C, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, + 0x0049, 0x004A, 0x004B, 0x0040, 0x0041, 0x0002, 0xFFFF, 0x0000 }; -s16 gSaveMenuImageIndices[4] = { - 0x000B, 0x000C, 0x0002, 0xFFFF -}; +s16 gSaveMenuImageIndices[4] = { 0x000B, 0x000C, 0x0002, 0xFFFF }; MenuElement gControllerPakMenuElement[7] = { - { 161, 32, 161, 33, 161, 32, 0, 0, 0, 255, 128, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 160, 30, 160, 30, 160, 30, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 160, 112, 160, 112, 160, 112, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 160, 128, 160, 128, 160, 128, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 160, 192, 160, 192, 160, 192, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 160, 208, 160, 208, 160, 208, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ASSET_FONTS_FUNFONT, 0, 0, { NULL }, {{ 0, 0, 0, 0 }} }, + { 161, 32, 161, 33, 161, 32, 0, 0, 0, 255, 128, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 160, 30, 160, 30, 160, 30, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 160, 112, 160, 112, 160, 112, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 160, 128, 160, 128, 160, 128, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 160, 192, 160, 192, 160, 192, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 160, 208, 160, 208, 160, 208, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ASSET_FONTS_FUNFONT, 0, 0, { NULL }, { { 0, 0, 0, 0 } } }, }; s32 gShowControllerPakMenu = FALSE; @@ -552,16 +534,8 @@ s32 gUnlockedMagicCodes = 0; char *gMagicCodeMenuStrings[5] = { 0, 0, 0, 0, 0 }; u8 gCharacterVolumes[10][2] = { - { 0x0F, 0x64 }, - { 0x0C, 0x07 }, - { 0x09, 0x64 }, - { 0x0A, 0x64 }, - { 0x08, 0x64 }, - { 0x0B, 0x64 }, - { 0x0D, 0x64 }, - { 0x0E, 0x64 }, - { 0x05, 0x64 }, - { 0x04, 0x64 }, + { 0x0F, 0x64 }, { 0x0C, 0x07 }, { 0x09, 0x64 }, { 0x0A, 0x64 }, { 0x08, 0x64 }, + { 0x0B, 0x64 }, { 0x0D, 0x64 }, { 0x0E, 0x64 }, { 0x05, 0x64 }, { 0x04, 0x64 }, }; s16 gCharSelectObjectIndices[2] = { -1, 0 }; @@ -591,67 +565,95 @@ s16 gCharSelectImageIndices[2] = { -1, 0 }; * of which characters are available to select. This system is far from conventional. * Unfortunately, because each entry is explicitly 14 bytes, it means a struct would not match, because * a struct would align itself to 16 bytes, creating an extra 2 bytes of padding inbetween. - * + * * The layout shows which character is in each cardinal direction. Presumably so it knows * where to place extra cursors when a new player joins. * Frankly, this is a comically overcomplicated method. -*/ + */ // Default character select screen with the initial 8 characters. -/* Name Up Down Left Right Voice ID */ +/* Name Up Down Left Right Voice ID */ CharacterSelectData gCharacterSelectBytesDefault[] = { - /*Krunch*/ { { NONE, NONE }, { CONKER, NONE }, { NONE, NONE, NONE, NONE }, { DIDDY, BUMPER, BANJO, NONE }, 0x0000 }, - /*Diddy*/ { { NONE, NONE }, { TIPTUP, NONE }, { KRUNCH, NONE, NONE, NONE }, { BUMPER, BANJO, NONE, NONE }, 0x0009 }, - /*Bumper*/ { { NONE, NONE }, { PIPSY, NONE }, { DIDDY, KRUNCH, NONE, NONE }, { BANJO, NONE, NONE, NONE }, 0x0001 }, - /*Banjo*/ { { NONE, NONE }, { TIMBER, NONE }, { BUMPER, DIDDY, KRUNCH, NONE }, { NONE, NONE, NONE, NONE }, 0x0005 }, - /*Conker*/ { { KRUNCH, NONE }, { NONE, NONE }, { NONE, NONE, NONE, NONE }, { TIPTUP, PIPSY, TIMBER, NONE }, 0x0003 }, - /*Tiptup*/ { { DIDDY, NONE }, { NONE, NONE }, { CONKER, NONE, NONE, NONE }, { PIPSY, TIMBER, NONE, NONE }, 0x0002 }, - /*Pipsy*/ { { BUMPER, NONE }, { NONE, NONE }, { TIPTUP, CONKER, NONE, NONE }, { TIMBER, NONE, NONE, NONE }, 0x0007 }, - /*Timber*/ { { BANJO, NONE }, { NONE, NONE }, { PIPSY, TIPTUP, CONKER, NONE }, { NONE, NONE, NONE, NONE }, 0x0004 } + /*Krunch*/ { { NONE, NONE }, { CONKER, NONE }, { NONE, NONE, NONE, NONE }, { DIDDY, BUMPER, BANJO, NONE }, 0x0000 }, + /*Diddy*/ { { NONE, NONE }, { TIPTUP, NONE }, { KRUNCH, NONE, NONE, NONE }, { BUMPER, BANJO, NONE, NONE }, 0x0009 }, + /*Bumper*/ { { NONE, NONE }, { PIPSY, NONE }, { DIDDY, KRUNCH, NONE, NONE }, { BANJO, NONE, NONE, NONE }, 0x0001 }, + /*Banjo*/ { { NONE, NONE }, { TIMBER, NONE }, { BUMPER, DIDDY, KRUNCH, NONE }, { NONE, NONE, NONE, NONE }, 0x0005 }, + /*Conker*/ + { { KRUNCH, NONE }, { NONE, NONE }, { NONE, NONE, NONE, NONE }, { TIPTUP, PIPSY, TIMBER, NONE }, 0x0003 }, + /*Tiptup*/ { { DIDDY, NONE }, { NONE, NONE }, { CONKER, NONE, NONE, NONE }, { PIPSY, TIMBER, NONE, NONE }, 0x0002 }, + /*Pipsy*/ + { { BUMPER, NONE }, { NONE, NONE }, { TIPTUP, CONKER, NONE, NONE }, { TIMBER, NONE, NONE, NONE }, 0x0007 }, + /*Timber*/ { { BANJO, NONE }, { NONE, NONE }, { PIPSY, TIPTUP, CONKER, NONE }, { NONE, NONE, NONE, NONE }, 0x0004 } }; // Drumstick is unlocked, but T.T is not. -/* Name Up Down Left Right Voice ID */ +/* Name Up Down Left Right Voice ID */ CharacterSelectData gCharacterSelectBytesDrumStick[] = { - /*Krunch*/ { { NONE, NONE }, { CONKER, NONE }, { NONE, NONE, NONE, NONE }, { DIDDY, DRUMSTICK, BUMPER, BANJO }, 0x0000 }, - /*Diddy*/ { { NONE, NONE }, { CONKER, TIPTUP }, { KRUNCH, NONE, NONE, NONE }, { DRUMSTICK, BUMPER, BANJO, NONE }, 0x0009 }, - /*Bumper*/ { { NONE, NONE }, { PIPSY, TIMBER }, { DRUMSTICK, DIDDY, KRUNCH, NONE }, { BANJO, NONE, NONE, NONE }, 0x0001 }, - /*Banjo*/ { { NONE, NONE }, { TIMBER, NONE }, { BUMPER, DRUMSTICK, DIDDY, KRUNCH }, { NONE, NONE, NONE, NONE }, 0x0005 }, - /*Conker*/ { { KRUNCH, DIDDY }, { NONE, NONE }, { NONE, NONE, NONE, NONE }, { TIPTUP, PIPSY, TIMBER, NONE }, 0x0003 }, - /*Tiptup*/ { { DIDDY, DRUMSTICK }, { NONE, NONE }, { CONKER, NONE, NONE, NONE }, { PIPSY, TIMBER, NONE, NONE }, 0x0002 }, - /*Pipsy*/ { { DRUMSTICK, BUMPER }, { NONE, NONE }, { TIPTUP, CONKER, NONE, NONE }, { TIMBER, NONE, NONE, NONE }, 0x0007 }, - /*Timber*/ { { BUMPER, BANJO }, { NONE, NONE }, { PIPSY, TIPTUP, CONKER, NONE }, { NONE, NONE, NONE, NONE }, 0x0004 }, - /*Drumstick*/ { { NONE, NONE }, { TIPTUP, PIPSY }, { DIDDY, KRUNCH, NONE, NONE }, { BUMPER, BANJO, NONE, NONE }, 0x0006 } + /*Krunch*/ { + { NONE, NONE }, { CONKER, NONE }, { NONE, NONE, NONE, NONE }, { DIDDY, DRUMSTICK, BUMPER, BANJO }, 0x0000 }, + /*Diddy*/ + { { NONE, NONE }, { CONKER, TIPTUP }, { KRUNCH, NONE, NONE, NONE }, { DRUMSTICK, BUMPER, BANJO, NONE }, 0x0009 }, + /*Bumper*/ + { { NONE, NONE }, { PIPSY, TIMBER }, { DRUMSTICK, DIDDY, KRUNCH, NONE }, { BANJO, NONE, NONE, NONE }, 0x0001 }, + /*Banjo*/ + { { NONE, NONE }, { TIMBER, NONE }, { BUMPER, DRUMSTICK, DIDDY, KRUNCH }, { NONE, NONE, NONE, NONE }, 0x0005 }, + /*Conker*/ + { { KRUNCH, DIDDY }, { NONE, NONE }, { NONE, NONE, NONE, NONE }, { TIPTUP, PIPSY, TIMBER, NONE }, 0x0003 }, + /*Tiptup*/ + { { DIDDY, DRUMSTICK }, { NONE, NONE }, { CONKER, NONE, NONE, NONE }, { PIPSY, TIMBER, NONE, NONE }, 0x0002 }, + /*Pipsy*/ + { { DRUMSTICK, BUMPER }, { NONE, NONE }, { TIPTUP, CONKER, NONE, NONE }, { TIMBER, NONE, NONE, NONE }, 0x0007 }, + /*Timber*/ + { { BUMPER, BANJO }, { NONE, NONE }, { PIPSY, TIPTUP, CONKER, NONE }, { NONE, NONE, NONE, NONE }, 0x0004 }, + /*Drumstick*/ + { { NONE, NONE }, { TIPTUP, PIPSY }, { DIDDY, KRUNCH, NONE, NONE }, { BUMPER, BANJO, NONE, NONE }, 0x0006 } }; // Under the unlikely chance you have T.T unlocked, but not Drumstick. -/* Name Up Down Left Right Voice ID */ +/* Name Up Down Left Right Voice ID */ CharacterSelectData gCharacterSelectBytesTT[] = { - /*Krunch*/ { { NONE, NONE }, { CONKER, NONE }, { NONE, NONE, NONE, NONE }, { DIDDY, BUMPER, BANJO, NONE }, 0x0000 }, - /*Diddy*/ { { NONE, NONE }, { TIPTUP, TICTOC_8 }, { KRUNCH, NONE, NONE, NONE }, { BUMPER, BANJO, NONE, NONE }, 0x0009 }, - /*Bumper*/ { { NONE, NONE }, { TICTOC_8, PIPSY }, { DIDDY, KRUNCH, NONE, NONE }, { BANJO, NONE, NONE, NONE }, 0x0001 }, - /*Banjo*/ { { NONE, NONE }, { PIPSY, TIMBER }, { BUMPER, DIDDY, KRUNCH, NONE }, { NONE, NONE, NONE, NONE }, 0x0005 }, - /*Conker*/ { { KRUNCH, NONE }, { NONE, NONE }, { NONE, NONE, NONE, NONE }, { TIPTUP, TICTOC_8, PIPSY, TIMBER }, 0x0003 }, - /*Tiptup*/ { { KRUNCH, DIDDY }, { NONE, NONE }, { CONKER, NONE, NONE, NONE }, { TICTOC_8, PIPSY, TIMBER, NONE }, 0x0002 }, - /*Pipsy*/ { { BUMPER, BANJO }, { NONE, NONE }, { TICTOC_8, TIPTUP, CONKER, NONE }, { TIMBER, NONE, NONE, NONE }, 0x0007 }, - /*Timber*/ { { BANJO, NONE }, { NONE, NONE }, { PIPSY, TICTOC_8, TIPTUP, CONKER }, { NONE, NONE, NONE, NONE }, 0x0004 }, - /*T.T*/ { { DIDDY, BUMPER }, { NONE, NONE }, { TIPTUP, CONKER, NONE, NONE }, { PIPSY, TIMBER, NONE, NONE }, 0x0008 } + /*Krunch*/ { { NONE, NONE }, { CONKER, NONE }, { NONE, NONE, NONE, NONE }, { DIDDY, BUMPER, BANJO, NONE }, 0x0000 }, + /*Diddy*/ + { { NONE, NONE }, { TIPTUP, TICTOC_8 }, { KRUNCH, NONE, NONE, NONE }, { BUMPER, BANJO, NONE, NONE }, 0x0009 }, + /*Bumper*/ + { { NONE, NONE }, { TICTOC_8, PIPSY }, { DIDDY, KRUNCH, NONE, NONE }, { BANJO, NONE, NONE, NONE }, 0x0001 }, + /*Banjo*/ + { { NONE, NONE }, { PIPSY, TIMBER }, { BUMPER, DIDDY, KRUNCH, NONE }, { NONE, NONE, NONE, NONE }, 0x0005 }, + /*Conker*/ + { { KRUNCH, NONE }, { NONE, NONE }, { NONE, NONE, NONE, NONE }, { TIPTUP, TICTOC_8, PIPSY, TIMBER }, 0x0003 }, + /*Tiptup*/ + { { KRUNCH, DIDDY }, { NONE, NONE }, { CONKER, NONE, NONE, NONE }, { TICTOC_8, PIPSY, TIMBER, NONE }, 0x0002 }, + /*Pipsy*/ + { { BUMPER, BANJO }, { NONE, NONE }, { TICTOC_8, TIPTUP, CONKER, NONE }, { TIMBER, NONE, NONE, NONE }, 0x0007 }, + /*Timber*/ + { { BANJO, NONE }, { NONE, NONE }, { PIPSY, TICTOC_8, TIPTUP, CONKER }, { NONE, NONE, NONE, NONE }, 0x0004 }, + /*T.T*/ { { DIDDY, BUMPER }, { NONE, NONE }, { TIPTUP, CONKER, NONE, NONE }, { PIPSY, TIMBER, NONE, NONE }, 0x0008 } }; // With everyone unlocked. -/* Name Up Down Left Right Voice ID */ +/* Name Up Down Left Right Voice ID */ CharacterSelectData gCharacterSelectBytesComplete[] = { - /*Krunch*/ { { NONE, NONE }, { CONKER, NONE }, { NONE, NONE, NONE, NONE }, { DIDDY, DRUMSTICK, BUMPER, BANJO }, 0x0000 }, - /*Diddy*/ { { NONE, NONE }, { TIPTUP, NONE }, { KRUNCH, NONE, NONE, NONE }, { DRUMSTICK, BUMPER, BANJO, NONE }, 0x0009 }, - /*Bumper*/ { { NONE, NONE }, { PIPSY, NONE }, { DRUMSTICK, DIDDY, KRUNCH, NONE }, { BANJO, NONE, NONE, NONE }, 0x0001 }, - /*Banjo*/ { { NONE, NONE }, { TIMBER, NONE }, { BUMPER, DRUMSTICK, DIDDY, KRUNCH }, { NONE, NONE, NONE, NONE }, 0x0005 }, - /*Conker*/ { { KRUNCH, NONE }, { NONE, NONE }, { NONE, NONE, NONE, NONE }, { TIPTUP, TICTOC_9, PIPSY, TIMBER }, 0x0003 }, - /*Tiptup*/ { { DIDDY, NONE }, { NONE, NONE }, { CONKER, NONE, NONE, NONE }, { TICTOC_9, PIPSY, TIMBER, NONE }, 0x0002 }, - /*Pipsy*/ { { BUMPER, NONE }, { NONE, NONE }, { TICTOC_9, TIPTUP, CONKER, NONE }, { TIMBER, NONE, NONE, NONE }, 0x0007 }, - /*Timber*/ { { BANJO, NONE }, { NONE, NONE }, { PIPSY, TICTOC_9, TIPTUP, CONKER }, { NONE, NONE, NONE, NONE }, 0x0004 }, - /*Drumstick*/ { { NONE, NONE }, { TICTOC_9, NONE }, { DIDDY, KRUNCH, NONE, NONE }, { BUMPER, BANJO, NONE, NONE }, 0x0006 }, - /*T.T*/ { { DRUMSTICK, NONE }, { TIPTUP, NONE }, { TIPTUP, CONKER, NONE, NONE }, { PIPSY, TIMBER, NONE, NONE }, 0x0008 } -//!@bug T.T's down input selects Tiptup. It should be set to NONE. + /*Krunch*/ { + { NONE, NONE }, { CONKER, NONE }, { NONE, NONE, NONE, NONE }, { DIDDY, DRUMSTICK, BUMPER, BANJO }, 0x0000 }, + /*Diddy*/ + { { NONE, NONE }, { TIPTUP, NONE }, { KRUNCH, NONE, NONE, NONE }, { DRUMSTICK, BUMPER, BANJO, NONE }, 0x0009 }, + /*Bumper*/ + { { NONE, NONE }, { PIPSY, NONE }, { DRUMSTICK, DIDDY, KRUNCH, NONE }, { BANJO, NONE, NONE, NONE }, 0x0001 }, + /*Banjo*/ + { { NONE, NONE }, { TIMBER, NONE }, { BUMPER, DRUMSTICK, DIDDY, KRUNCH }, { NONE, NONE, NONE, NONE }, 0x0005 }, + /*Conker*/ + { { KRUNCH, NONE }, { NONE, NONE }, { NONE, NONE, NONE, NONE }, { TIPTUP, TICTOC_9, PIPSY, TIMBER }, 0x0003 }, + /*Tiptup*/ + { { DIDDY, NONE }, { NONE, NONE }, { CONKER, NONE, NONE, NONE }, { TICTOC_9, PIPSY, TIMBER, NONE }, 0x0002 }, + /*Pipsy*/ + { { BUMPER, NONE }, { NONE, NONE }, { TICTOC_9, TIPTUP, CONKER, NONE }, { TIMBER, NONE, NONE, NONE }, 0x0007 }, + /*Timber*/ + { { BANJO, NONE }, { NONE, NONE }, { PIPSY, TICTOC_9, TIPTUP, CONKER }, { NONE, NONE, NONE, NONE }, 0x0004 }, + /*Drumstick*/ + { { NONE, NONE }, { TICTOC_9, NONE }, { DIDDY, KRUNCH, NONE, NONE }, { BUMPER, BANJO, NONE, NONE }, 0x0006 }, + /*T.T*/ + { { DRUMSTICK, NONE }, { TIPTUP, NONE }, { TIPTUP, CONKER, NONE, NONE }, { PIPSY, TIMBER, NONE, NONE }, 0x0008 } + //!@bug T.T's down input selects Tiptup. It should be set to NONE. }; s32 unused_800DFFCC = 0; @@ -659,7 +661,7 @@ s32 unused_800DFFCC = 0; // Set from func_8008AEB4() // Is either 0, 1, or 2. However it is never set to 2? // Set to 0 upon entering the Character Select menu normally. -// Set to 1 upon entering the Char Select from the +// Set to 1 upon entering the Char Select from the // "Select Character" option on the "Pause Options" screen in a race. s32 gEnteredCharSelectFrom = 0; @@ -669,69 +671,416 @@ s32 gEnteredCharSelectFrom = 0; s32 unused_800DFFD4 = -1; MenuElement gCautionMenuTextElements[14] = { - { SCREEN_WIDTH_HALF + 1, 35, SCREEN_WIDTH_HALF + 1, 35, SCREEN_WIDTH_HALF + 1, 35, 0, 0, 0, 255, 128, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 32, SCREEN_WIDTH_HALF, 32, SCREEN_WIDTH_HALF, 32, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 72, SCREEN_WIDTH_HALF, 68, SCREEN_WIDTH_HALF, 72, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 86, SCREEN_WIDTH_HALF, 82, SCREEN_WIDTH_HALF, 86, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 100, SCREEN_WIDTH_HALF, 96, SCREEN_WIDTH_HALF, 100, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 114, SCREEN_WIDTH_HALF, 110, SCREEN_WIDTH_HALF, 114, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 128, SCREEN_WIDTH_HALF, 124, SCREEN_WIDTH_HALF, 128, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 142, SCREEN_WIDTH_HALF, 138, SCREEN_WIDTH_HALF, 142, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 156, SCREEN_WIDTH_HALF, 152, SCREEN_WIDTH_HALF, 156, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 156, SCREEN_WIDTH_HALF, 166, SCREEN_WIDTH_HALF, 156, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 186, SCREEN_WIDTH_HALF, 180, SCREEN_WIDTH_HALF, 186, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 200, SCREEN_WIDTH_HALF, 194, SCREEN_WIDTH_HALF, 200, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 200, SCREEN_WIDTH_HALF, 208, SCREEN_WIDTH_HALF, 200, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, {{ 0, 0, 0, 0 }} }, + { SCREEN_WIDTH_HALF + 1, + 35, + SCREEN_WIDTH_HALF + 1, + 35, + SCREEN_WIDTH_HALF + 1, + 35, + 0, + 0, + 0, + 255, + 128, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 32, + SCREEN_WIDTH_HALF, + 32, + SCREEN_WIDTH_HALF, + 32, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 72, + SCREEN_WIDTH_HALF, + 68, + SCREEN_WIDTH_HALF, + 72, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 86, + SCREEN_WIDTH_HALF, + 82, + SCREEN_WIDTH_HALF, + 86, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 100, + SCREEN_WIDTH_HALF, + 96, + SCREEN_WIDTH_HALF, + 100, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 114, + SCREEN_WIDTH_HALF, + 110, + SCREEN_WIDTH_HALF, + 114, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 128, + SCREEN_WIDTH_HALF, + 124, + SCREEN_WIDTH_HALF, + 128, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 142, + SCREEN_WIDTH_HALF, + 138, + SCREEN_WIDTH_HALF, + 142, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 156, + SCREEN_WIDTH_HALF, + 152, + SCREEN_WIDTH_HALF, + 156, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 156, + SCREEN_WIDTH_HALF, + 166, + SCREEN_WIDTH_HALF, + 156, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 186, + SCREEN_WIDTH_HALF, + 180, + SCREEN_WIDTH_HALF, + 186, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 200, + SCREEN_WIDTH_HALF, + 194, + SCREEN_WIDTH_HALF, + 200, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 200, + SCREEN_WIDTH_HALF, + 208, + SCREEN_WIDTH_HALF, + 200, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, { { 0, 0, 0, 0 } } }, }; MenuElement gGameSelectTextElemsNoAdv2[7] = { - { SCREEN_WIDTH_HALF + 1, 35, SCREEN_WIDTH_HALF + 1, 35, SCREEN_WIDTH_HALF + 1, 35, 0, 0, 0, 255, 128, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 32, SCREEN_WIDTH_HALF, 32, SCREEN_WIDTH_HALF, 32, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { -96, 39, -96, 39, -96, 39, 176, 224, 192, 255, 255, ASSET_FONTS_FUNFONT, 0, 7, { NULL }, {{ 192, 44, 4, 4 }} }, - { SCREEN_WIDTH_HALF, 104, SCREEN_WIDTH_HALF, 104, SCREEN_WIDTH_HALF, 104, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { -96, -9, -96, -9, -96, -9, 176, 224, 192, 255, 255, ASSET_FONTS_FUNFONT, 0, 7, { NULL }, {{ 192, 44, 4, 4 }} }, - { SCREEN_WIDTH_HALF, 152, SCREEN_WIDTH_HALF, 152, SCREEN_WIDTH_HALF, 152, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, {{ 0, 0, 0, 0 }} }, + { SCREEN_WIDTH_HALF + 1, + 35, + SCREEN_WIDTH_HALF + 1, + 35, + SCREEN_WIDTH_HALF + 1, + 35, + 0, + 0, + 0, + 255, + 128, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 32, + SCREEN_WIDTH_HALF, + 32, + SCREEN_WIDTH_HALF, + 32, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { -96, 39, -96, 39, -96, 39, 176, 224, 192, 255, 255, ASSET_FONTS_FUNFONT, 0, 7, { NULL }, { { 192, 44, 4, 4 } } }, + { SCREEN_WIDTH_HALF, + 104, + SCREEN_WIDTH_HALF, + 104, + SCREEN_WIDTH_HALF, + 104, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { -96, -9, -96, -9, -96, -9, 176, 224, 192, 255, 255, ASSET_FONTS_FUNFONT, 0, 7, { NULL }, { { 192, 44, 4, 4 } } }, + { SCREEN_WIDTH_HALF, + 152, + SCREEN_WIDTH_HALF, + 152, + SCREEN_WIDTH_HALF, + 152, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, { { 0, 0, 0, 0 } } }, }; MenuElement gGameSelectTextElemsWithAdv2[9] = { - { SCREEN_WIDTH_HALF + 1, 35, SCREEN_WIDTH_HALF + 1, 35, SCREEN_WIDTH_HALF + 1, 35, 0, 0, 0, 255, 128, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { SCREEN_WIDTH_HALF, 32, SCREEN_WIDTH_HALF, 32, SCREEN_WIDTH_HALF, 32, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { -112, 55, -112, 55, -112, 55, 176, 224, 192, 255, 255, ASSET_FONTS_FUNFONT, 0, 7, { NULL }, {{ 224, 44, 4, 4 }} }, - { SCREEN_WIDTH_HALF, 88, SCREEN_WIDTH_HALF, 88, SCREEN_WIDTH_HALF, 88, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { -112, 7, -112, 7, -112, 7, 176, 224, 192, 255, 255, ASSET_FONTS_FUNFONT, 0, 7, { NULL }, {{ 224, 44, 4, 4 }} }, - { SCREEN_WIDTH_HALF, 136, SCREEN_WIDTH_HALF, 136, SCREEN_WIDTH_HALF, 136, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { -112, -41, -112, -41, -112, -41, 176, 224, 192, 255, 255, ASSET_FONTS_FUNFONT, 0, 7, { NULL }, {{ 224, 44, 4, 4 }} }, - { SCREEN_WIDTH_HALF, 184, SCREEN_WIDTH_HALF, 184, SCREEN_WIDTH_HALF, 184, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }}}, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, {{ 0, 0, 0, 0 }} }, + { SCREEN_WIDTH_HALF + 1, + 35, + SCREEN_WIDTH_HALF + 1, + 35, + SCREEN_WIDTH_HALF + 1, + 35, + 0, + 0, + 0, + 255, + 128, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { SCREEN_WIDTH_HALF, + 32, + SCREEN_WIDTH_HALF, + 32, + SCREEN_WIDTH_HALF, + 32, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { -112, + 55, + -112, + 55, + -112, + 55, + 176, + 224, + 192, + 255, + 255, + ASSET_FONTS_FUNFONT, + 0, + 7, + { NULL }, + { { 224, 44, 4, 4 } } }, + { SCREEN_WIDTH_HALF, + 88, + SCREEN_WIDTH_HALF, + 88, + SCREEN_WIDTH_HALF, + 88, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { -112, 7, -112, 7, -112, 7, 176, 224, 192, 255, 255, ASSET_FONTS_FUNFONT, 0, 7, { NULL }, { { 224, 44, 4, 4 } } }, + { SCREEN_WIDTH_HALF, + 136, + SCREEN_WIDTH_HALF, + 136, + SCREEN_WIDTH_HALF, + 136, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { -112, + -41, + -112, + -41, + -112, + -41, + 176, + 224, + 192, + 255, + 255, + ASSET_FONTS_FUNFONT, + 0, + 7, + { NULL }, + { { 224, 44, 4, 4 } } }, + { SCREEN_WIDTH_HALF, + 184, + SCREEN_WIDTH_HALF, + 184, + SCREEN_WIDTH_HALF, + 184, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_BIGFONT, + 12, + 0, + { NULL }, + { { 0, 0, 0, 0 } } }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, { { 0, 0, 0, 0 } } }, }; -s16 gFileSelectObjectIndices[6] = { - 0x00, 0x43, 0x40, 0x41, 0x42, -1 -}; +s16 gFileSelectObjectIndices[6] = { 0x00, 0x43, 0x40, 0x41, 0x42, -1 }; -s16 gFileSelectImageIndices[6] = { - 0x00, 0x0B, 0x0C, 0x0A, -1, 0 -}; +s16 gFileSelectImageIndices[6] = { 0x00, 0x0B, 0x0C, 0x0A, -1, 0 }; -char *gFilenames[3] = { - NULL, NULL, NULL -}; +char *gFilenames[3] = { NULL, NULL, NULL }; u16 unused_800E03BC[8] = { - 0x004C, - 0x0070, - 0x00F4, - 0x0070, - 0x004C, - 0x00D0, - 0x00F4, - 0x00D0, + 0x004C, 0x0070, 0x00F4, 0x0070, 0x004C, 0x00D0, 0x00F4, 0x00D0, }; ButtonElement gFileSelectButtons[3] = { - { 24, 81, 88, 64, 4, 4, GPACK_RGBA5551(64, 16, 0, 0), GPACK_RGBA5551(255, 255, 0, 0) }, // File A + { 24, 81, 88, 64, 4, 4, GPACK_RGBA5551(64, 16, 0, 0), GPACK_RGBA5551(255, 255, 0, 0) }, // File A { 116, 81, 88, 64, 4, 4, GPACK_RGBA5551(64, 16, 0, 0), GPACK_RGBA5551(255, 255, 0, 0) }, // File B { 208, 81, 88, 64, 4, 4, GPACK_RGBA5551(64, 16, 0, 0), GPACK_RGBA5551(255, 255, 0, 0) }, // File C }; @@ -757,11 +1106,10 @@ s32 gTracksMenuTimeTrialHighlightIndex = 0; // 1 = Adventure 2 (Mirrored) s32 gTracksMenuAdventureHighlightIndex = 0; - -DrawTexture gMenuSelectionArrowUp[2] = { { NULL, -12, -8 }, { NULL, 0, 0 }}; -DrawTexture gMenuSelectionArrowLeft[2] = { { NULL, -8, -12 }, { NULL, 0, 0 }}; -DrawTexture gMenuSelectionArrowDown[2] = { { NULL, -12, -8 }, { NULL, 0, 0 }}; -DrawTexture gMenuSelectionArrowRight[2] = { { NULL, -8, -12 }, { NULL, 0, 0 }}; +DrawTexture gMenuSelectionArrowUp[2] = { { NULL, -12, -8 }, { NULL, 0, 0 } }; +DrawTexture gMenuSelectionArrowLeft[2] = { { NULL, -8, -12 }, { NULL, 0, 0 } }; +DrawTexture gMenuSelectionArrowDown[2] = { { NULL, -12, -8 }, { NULL, 0, 0 } }; +DrawTexture gMenuSelectionArrowRight[2] = { { NULL, -8, -12 }, { NULL, 0, 0 } }; DrawTexture gRaceSelectionCarTex[3] = { { NULL, 0, 0 }, { NULL, 0, 32 }, { NULL, 0, 0 } }; DrawTexture gRaceSelectionHoverTex[3] = { { NULL, 0, 0 }, { NULL, 0, 32 }, { NULL, 0, 0 } }; @@ -789,21 +1137,21 @@ DrawTexture D_800E05F4[4] = { { NULL, 0, -48 }, { NULL, 0, -16 }, { NULL, 0, 16 DrawTexture gRaceSelectionTTTexture[2] = { { NULL, -16, -16 }, { NULL, 0, 0 } }; DrawTexture *gRaceSelectionImages[9] = { - gRaceSelectionCarTex, gRaceSelectionCarOptHighlight, gRaceSelectionCarOpt, gRaceSelectionHoverTex, gRaceSelectionHoverOptHighlight, gRaceSelectionHoverOpt, gRaceSelectionPlaneTex, gRaceSelectionPlaneOptHighlight, gRaceSelectionPlaneOpt + gRaceSelectionCarTex, gRaceSelectionCarOptHighlight, gRaceSelectionCarOpt, + gRaceSelectionHoverTex, gRaceSelectionHoverOptHighlight, gRaceSelectionHoverOpt, + gRaceSelectionPlaneTex, gRaceSelectionPlaneOptHighlight, gRaceSelectionPlaneOpt }; -DrawTexture *gTrackSelectTTImage[6] = { - gRaceSelectionTTOff, gRaceSelectionTTOffOptHighlight, gRaceSelectionTTOffOpt, gRaceSelectionTTOn, gRaceSelectionTTOnOptHighlight, gRaceSelectionTTOnOpt -}; +DrawTexture *gTrackSelectTTImage[6] = { gRaceSelectionTTOff, gRaceSelectionTTOffOptHighlight, gRaceSelectionTTOffOpt, + gRaceSelectionTTOn, gRaceSelectionTTOnOptHighlight, gRaceSelectionTTOnOpt }; -DrawTexture *gTrackSelectPlayerImage[6] = { - gRaceSelectionPlayer1Texture, gRaceSelectionPlayer2Texture, gRaceSelectionPlayer3Texture, gRaceSelectionPlayer4Texture, gRaceSelectionVehicleTitleTexture, gRaceSelectionTTTitleTexture -}; +DrawTexture *gTrackSelectPlayerImage[6] = { gRaceSelectionPlayer1Texture, gRaceSelectionPlayer2Texture, + gRaceSelectionPlayer3Texture, gRaceSelectionPlayer4Texture, + gRaceSelectionVehicleTitleTexture, gRaceSelectionTTTitleTexture }; -DrawTexture *gMenuSelectionArrows[4] = { - gMenuSelectionArrowUp, gMenuSelectionArrowLeft, gMenuSelectionArrowDown, gMenuSelectionArrowRight -}; +DrawTexture *gMenuSelectionArrows[4] = { gMenuSelectionArrowUp, gMenuSelectionArrowLeft, gMenuSelectionArrowDown, + gMenuSelectionArrowRight }; // X/Y offsets for the "Player" icon s16 gTracksMenuPlayerNamePositions[20] = { @@ -816,26 +1164,20 @@ s16 gTracksMenuPlayerNamePositions[20] = { // X offsets for "Car", "Hover", and "Plane" choices in track select. s16 gTracksMenuVehicleNamePositions[10] = { - 0x68, // 1 player - 0x21, 0xFB, // 2 players - 0x27, 0x8E, 0xF5, // 3 players - 0x27, 0x6C, 0xB0, 0xF5 // 4 players + 0x68, // 1 player + 0x21, 0xFB, // 2 players + 0x27, 0x8E, 0xF5, // 3 players + 0x27, 0x6C, 0xB0, 0xF5 // 4 players }; -//Paired X / Y Offsets. X Is First, Y is Second. For NTSC. +// Paired X / Y Offsets. X Is First, Y is Second. For NTSC. s16 gTracksMenuArrowPositionsNTSC[8] = { - 0x0000, 0xFFC2, - 0x0055, 0x0000, - 0x0000, 0x003E, - 0xFFAB, 0x0000, + 0x0000, 0xFFC2, 0x0055, 0x0000, 0x0000, 0x003E, 0xFFAB, 0x0000, }; -//Paired X / Y Offsets. X Is First, Y is Second. For PAL. +// Paired X / Y Offsets. X Is First, Y is Second. For PAL. s16 gTracksMenuArrowPositionsPAL[8] = { - 0x0000, 0xFFB6, - 0x0055, 0x0000, - 0x0000, 0x004A, - 0xFFAB, 0x0000, + 0x0000, 0xFFB6, 0x0055, 0x0000, 0x0000, 0x004A, 0xFFAB, 0x0000, }; ButtonTextElement gTwoPlayerRacerCountMenu = { @@ -844,9 +1186,7 @@ ButtonTextElement gTwoPlayerRacerCountMenu = { // Adventure 1/2 button in the track select menu. // Note: The first element (.x) is not actually used. -ButtonElement gTracksMenuAdventureButton = { - 80, 152, 160, 40, 4, 4, 80, 14 -}; +ButtonElement gTracksMenuAdventureButton = { 80, 152, 160, 40, 4, 4, 80, 14 }; // Often access like D_800E0710[i * 3 + 1]. // Texture indices for the backgrounds in the Track Select @@ -869,89 +1209,72 @@ TextureHeader *gTracksMenuBgTextures[10] = { // ID for T.Ts voice lines for each track id. // T.T. will say nothing for tracks with -1 -s16 gTTVoiceLines[53] = { - -1, - -1, - SOUND_VOICE_TT_DRAGON_FOREST, - SOUND_VOICE_TT_FOSSIL_CANYON, - SOUND_VOICE_TT_PIRATE_LAGOON, - SOUND_VOICE_TT_ANCIENT_LAKE, - SOUND_VOICE_TT_WALRUS_COVE, - SOUND_VOICE_TT_HOT_TOP_VOLCANO, - SOUND_VOICE_TT_WHALE_BAY, - SOUND_VOICE_TT_SNOWBALL_VALLEY, - SOUND_VOICE_TT_CRESCENT_ISLAND, - SOUND_VOICE_TT_FIRE_MOUNTAIN, - SOUND_VOICE_TT_DINO_DOMAIN, - SOUND_VOICE_TT_EVERFROST_PEAK, - SOUND_VOICE_TT_SHERBET_ISLAND, - SOUND_VOICE_TT_SPACEPORT_ALPHA, - -1, - SOUND_VOICE_TT_SPACEDUST_VALLEY, - SOUND_VOICE_TT_GREENWOOD_VILLAGE, - SOUND_VOICE_TT_BOULDER_CANYON, - SOUND_VOICE_TT_WINDMILL_PLAINS, - -1, - -1, - -1, - SOUND_VOICE_TT_SNOWFLAKE_MOUNTAIN, - SOUND_VOICE_TT_SMOKEY_CASTLE, - SOUND_VOICE_TT_DARKWATER_BEACH, - SOUND_VOICE_TT_ICICLE_PYRAMID, - SOUND_VOICE_TT_FROSTY_VILLAGE, - SOUND_VOICE_TT_JUNGLE_FALLS, - SOUND_VOICE_TT_TREASURE_CAVES, - SOUND_VOICE_TT_HAUNTED_WOODS, - SOUND_VOICE_TT_DARKMOON_CAVERNS, - SOUND_VOICE_TT_STAR_CITY, - SOUND_VOICE_TT_TROPHY_RACE, - SOUND_VOICE_TT_FUTURE_FUN_LAND, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1 -}; +s16 gTTVoiceLines[53] = { -1, + -1, + SOUND_VOICE_TT_DRAGON_FOREST, + SOUND_VOICE_TT_FOSSIL_CANYON, + SOUND_VOICE_TT_PIRATE_LAGOON, + SOUND_VOICE_TT_ANCIENT_LAKE, + SOUND_VOICE_TT_WALRUS_COVE, + SOUND_VOICE_TT_HOT_TOP_VOLCANO, + SOUND_VOICE_TT_WHALE_BAY, + SOUND_VOICE_TT_SNOWBALL_VALLEY, + SOUND_VOICE_TT_CRESCENT_ISLAND, + SOUND_VOICE_TT_FIRE_MOUNTAIN, + SOUND_VOICE_TT_DINO_DOMAIN, + SOUND_VOICE_TT_EVERFROST_PEAK, + SOUND_VOICE_TT_SHERBET_ISLAND, + SOUND_VOICE_TT_SPACEPORT_ALPHA, + -1, + SOUND_VOICE_TT_SPACEDUST_VALLEY, + SOUND_VOICE_TT_GREENWOOD_VILLAGE, + SOUND_VOICE_TT_BOULDER_CANYON, + SOUND_VOICE_TT_WINDMILL_PLAINS, + -1, + -1, + -1, + SOUND_VOICE_TT_SNOWFLAKE_MOUNTAIN, + SOUND_VOICE_TT_SMOKEY_CASTLE, + SOUND_VOICE_TT_DARKWATER_BEACH, + SOUND_VOICE_TT_ICICLE_PYRAMID, + SOUND_VOICE_TT_FROSTY_VILLAGE, + SOUND_VOICE_TT_JUNGLE_FALLS, + SOUND_VOICE_TT_TREASURE_CAVES, + SOUND_VOICE_TT_HAUNTED_WOODS, + SOUND_VOICE_TT_DARKMOON_CAVERNS, + SOUND_VOICE_TT_STAR_CITY, + SOUND_VOICE_TT_TROPHY_RACE, + SOUND_VOICE_TT_FUTURE_FUN_LAND, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 }; s16 gTrackSelectObjectIndices[14] = { - 0x05, 0x06, 0x07, 0x3D, - 0x3C, 0x3F, 0x3E, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, - 0x0D, -1 + 0x05, 0x06, 0x07, 0x3D, 0x3C, 0x3F, 0x3E, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, -1 }; -s16 gTrackSelectImageIndices[4] = { - 0x04, 0x05, 0x06, -1 -}; +s16 gTrackSelectImageIndices[4] = { 0x04, 0x05, 0x06, -1 }; -s16 gTrackSelectPreviewObjectIndices[36] = { - 0x0004, 0x0000, 0x0001, 0x0002, - 0x0003, 0x0018, 0x0019, 0x001A, - 0x001B, 0x001C, 0x001D, 0x0024, - 0x0025, 0x0026, 0x0027, 0x0028, - 0x0029, 0x002A, 0x002B, 0x001E, - 0x001F, 0x0020, 0x0021, 0x0022, - 0x0023, 0x002C, 0x002D, 0x002E, - 0x002F, 0x0030, 0x0031, 0x0040, - 0x0041, 0x0043, 0x005E, 0xFFFF -}; +s16 gTrackSelectPreviewObjectIndices[36] = { 0x0004, 0x0000, 0x0001, 0x0002, 0x0003, 0x0018, 0x0019, 0x001A, 0x001B, + 0x001C, 0x001D, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, + 0x002B, 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023, 0x002C, 0x002D, + 0x002E, 0x002F, 0x0030, 0x0031, 0x0040, 0x0041, 0x0043, 0x005E, 0xFFFF }; -s16 gTrackSelectPreviewImageIndices[8] = { - 0x07, 0x00, 0x01, 0x02, - 0x03, 0x0B, 0x0C, -1 -}; +s16 gTrackSelectPreviewImageIndices[8] = { 0x07, 0x00, 0x01, 0x02, 0x03, 0x0B, 0x0C, -1 }; // Not a struct, since the entries can *technically* be either 4 or 5 bytes. But it is always 5 in the final game. /* @@ -962,73 +1285,26 @@ s16 gTrackSelectPreviewImageIndices[8] = { Offset 4: u8 texCoordUFactor; */ u8 gTrackSelectBgData[295] = { - 0, 0, 255, 255, 0, - 1, 1, 255, 255, 0, - 2, 0, 255, 255, 0, - 3, 1, 255, 255, 0, - 4, 0, 255, 255, 0, - 5, 1, 255, 255, 0, - 6, 0, 255, 255, 0, - 6, 2, 0, 64, 0, - 7, 1, 255, 255, 0, - 7, 3, 64, 128, 0, - 8, 0, 255, 255, 0, - 8, 2, 128, 192, 32, - 9, 1, 255, 255, 0, - 9, 3, 192, 255, 32, - 10, 2, 255, 255, 0, - 11, 3, 255, 255, 0, - 12, 2, 255, 255, 32, - 13, 3, 255, 255, 32, - 14, 2, 255, 255, 0, - 14, 4, 0, 64, 0, - 15, 3, 255, 255, 0, - 15, 5, 64, 128, 0, - 16, 2, 255, 255, 32, - 16, 4, 128, 192, 0, - 17, 3, 255, 255, 32, - 17, 5, 192, 255, 0, - 18, 4, 255, 255, 0, - 19, 5, 255, 255, 0, - 20, 4, 255, 255, 0, - 21, 5, 255, 255, 0, - 22, 4, 255, 255, 0, - 22, 6, 0, 64, 0, - 23, 5, 255, 255, 0, - 23, 7, 64, 128, 0, - 24, 4, 255, 255, 0, - 24, 6, 128, 192, 32, - 25, 5, 255, 255, 0, - 25, 7, 192, 255, 32, - 26, 6, 255, 255, 0, - 27, 7, 255, 255, 0, - 28, 6, 255, 255, 32, - 29, 7, 255, 255, 32, - 30, 6, 255, 255, 0, - 30, 8, 0, 64, 0, - 31, 7, 255, 255, 0, - 31, 9, 64, 128, 0, - 32, 6, 255, 255, 32, - 32, 8, 128, 192, 32, - 33, 7, 255, 255, 32, - 33, 9, 192, 255, 32, - 34, 8, 255, 255, 0, - 35, 9, 255, 255, 0, - 36, 8, 255, 255, 32, - 37, 9, 255, 255, 32, - 38, 8, 255, 255, 0, - 39, 9, 255, 255, 0, - 40, 8, 255, 255, 32, - 41, 9, 255, 255, 32, - 255, 0, 0, 0, 0 + 0, 0, 255, 255, 0, 1, 1, 255, 255, 0, 2, 0, 255, 255, 0, 3, 1, 255, 255, 0, 4, 0, 255, 255, 0, + 5, 1, 255, 255, 0, 6, 0, 255, 255, 0, 6, 2, 0, 64, 0, 7, 1, 255, 255, 0, 7, 3, 64, 128, 0, + 8, 0, 255, 255, 0, 8, 2, 128, 192, 32, 9, 1, 255, 255, 0, 9, 3, 192, 255, 32, 10, 2, 255, 255, 0, + 11, 3, 255, 255, 0, 12, 2, 255, 255, 32, 13, 3, 255, 255, 32, 14, 2, 255, 255, 0, 14, 4, 0, 64, 0, + 15, 3, 255, 255, 0, 15, 5, 64, 128, 0, 16, 2, 255, 255, 32, 16, 4, 128, 192, 0, 17, 3, 255, 255, 32, + 17, 5, 192, 255, 0, 18, 4, 255, 255, 0, 19, 5, 255, 255, 0, 20, 4, 255, 255, 0, 21, 5, 255, 255, 0, + 22, 4, 255, 255, 0, 22, 6, 0, 64, 0, 23, 5, 255, 255, 0, 23, 7, 64, 128, 0, 24, 4, 255, 255, 0, + 24, 6, 128, 192, 32, 25, 5, 255, 255, 0, 25, 7, 192, 255, 32, 26, 6, 255, 255, 0, 27, 7, 255, 255, 0, + 28, 6, 255, 255, 32, 29, 7, 255, 255, 32, 30, 6, 255, 255, 0, 30, 8, 0, 64, 0, 31, 7, 255, 255, 0, + 31, 9, 64, 128, 0, 32, 6, 255, 255, 32, 32, 8, 128, 192, 32, 33, 7, 255, 255, 32, 33, 9, 192, 255, 32, + 34, 8, 255, 255, 0, 35, 9, 255, 255, 0, 36, 8, 255, 255, 32, 37, 9, 255, 255, 32, 38, 8, 255, 255, 0, + 39, 9, 255, 255, 0, 40, 8, 255, 255, 32, 41, 9, 255, 255, 32, 255, 0, 0, 0, 0 }; Vertex *gTrackSelectBgVertices[2] = { NULL, NULL }; -Triangle *gTrackSelectBgTriangles[2] = {NULL, NULL }; +Triangle *gTrackSelectBgTriangles[2] = { NULL, NULL }; char *gQMarkPtr = "?"; // Boolean. Set to TRUE once in the Track Select menu, then // set to FALSE when leaving the menu. -// This is effectively unused, since it is only read from the +// This is effectively unused, since it is only read from the // unused function func_8008E790() s32 gIsInTracksMenu = FALSE; @@ -1040,17 +1316,17 @@ s32 gMenuSubOption = 0; s32 gLastPlayerWhoPaused = 0; ColourRGBA gPlayerPauseBgColour[4] = { - {{{ 64, 64, 255, 160 }}}, // Blue for player 1 - {{{ 255, 64, 64, 160 }}}, // Red for player 2 - {{{ 208, 192, 32, 176 }}}, // Yellow for player 3 - {{{ 32, 192, 64, 176 }}}, // Green for player 4 + { { { 64, 64, 255, 160 } } }, // Blue for player 1 + { { { 255, 64, 64, 160 } } }, // Red for player 2 + { { { 208, 192, 32, 176 } } }, // Yellow for player 3 + { { { 32, 192, 64, 176 } } }, // Green for player 4 }; ColourRGBA gPlayerPauseOptionsTextColour[4] = { - {{{ 0, 255, 0, 128 }}}, // Green for Player 1 - {{{ 0, 255, 0, 96 }}}, // Green for Player 2 - {{{ 0, 0, 255, 96 }}}, // Blue for Player 3 - {{{ 0, 0, 255, 128 }}}, // Blue for Player 4 + { { { 0, 255, 0, 128 } } }, // Green for Player 1 + { { { 0, 255, 0, 96 } } }, // Green for Player 2 + { { { 0, 0, 255, 96 } } }, // Blue for Player 3 + { { { 0, 0, 255, 128 } } }, // Blue for Player 4 }; // BAD CONTROLLER PAK / If you wish to change / Controller Pak or Rumble Pak, / please do so now. @@ -1070,20 +1346,15 @@ char *D_800E09F8[3] = { 0, 0, 0 }; // If you wish to use / the Controller Pak / insert it now! char *sInsertControllerPakMenuText[3] = { 0, 0, 0 }; -s16 D_800E0A10[2] = { - 0x0000, 0x0000 -}; +s16 D_800E0A10[2] = { 0x0000, 0x0000 }; -//If you wish to use / the Rumble Pak / insert it now! +// If you wish to use / the Rumble Pak / insert it now! char *sInsertRumblePakMenuText[4] = { 0, 0, 0, 0 }; -s16 gRaceResultsObjectIndices[14] = { - 0x0005, 0x003B, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0039, 0x0037, 0x0038, 0x003A, 0x0000, 0x0001, 0xFFFF -}; +s16 gRaceResultsObjectIndices[14] = { 0x0005, 0x003B, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, + 0x0039, 0x0037, 0x0038, 0x003A, 0x0000, 0x0001, 0xFFFF }; -s16 gRaceResultsImageIndices[8] = { - 0x0004, 0x0000, 0x0001, 0xFFFF, 0x0300, 0x0000, 0x0012, 0xFFFF -}; +s16 gRaceResultsImageIndices[8] = { 0x0004, 0x0000, 0x0001, 0xFFFF, 0x0300, 0x0000, 0x0012, 0xFFFF }; DrawTexture gMenuPortraitKrunch[2] = { { NULL, 0, 0 }, { NULL, 0, 0 } }; DrawTexture gMenuPortraitDiddy[2] = { { NULL, 0, 0 }, { NULL, 0, 0 } }; @@ -1096,84 +1367,232 @@ DrawTexture gMenuPortraitTT[2] = { { NULL, 0, 0 }, { NULL, 0, 0 } }; DrawTexture gMenuPortraitPipsy[2] = { { NULL, 0, 0 }, { NULL, 0, 0 } }; DrawTexture gMenuPortraitTimber[2] = { { NULL, 0, 0 }, { NULL, 0, 0 } }; -DrawTexture *gRacerPortraits[10] = { - gMenuPortraitKrunch, gMenuPortraitDiddy, gMenuPortraitDrumstick, gMenuPortraitBumper, - gMenuPortraitBanjo, gMenuPortraitConker, gMenuPortraitTiptup, gMenuPortraitTT, - gMenuPortraitPipsy, gMenuPortraitTimber -}; +DrawTexture *gRacerPortraits[10] = { gMenuPortraitKrunch, gMenuPortraitDiddy, gMenuPortraitDrumstick, + gMenuPortraitBumper, gMenuPortraitBanjo, gMenuPortraitConker, + gMenuPortraitTiptup, gMenuPortraitTT, gMenuPortraitPipsy, + gMenuPortraitTimber }; -s16 unused_800E0B18[74] = { - 0x0140, 0x017C, 0x01B8, 0x01F4, - 0x0230, 0x026C, 0x02A8, 0x02E4, - 0x01E0, 0x0000, 0x0018, 0x0039, - 0x005A, 0x007B, 0x009C, 0x00BD, - 0x00DE, 0x00FF, 0x00A0, 0x0000, - 0x0140, 0x01B8, 0x0230, 0x02A8, - 0x01E0, 0x0000, 0x0018, 0x0065, - 0x00B3, 0x0100, 0x00A0, 0x0000, - 0x0140, 0x01F4, 0x02A8, 0x01E0, - 0x0028, 0x008C, 0x00F0, 0x00A0, - 0x01E0, 0x00C0, 0x00A0, 0x00C0, - 0xFF60, 0x00C0, 0xFF80, 0xFFEC, - 0xFFE4, 0xFFE6, 0x0050, 0xFFF8, - 0xFFE4, 0xFFF4, 0xFFE4, 0x0006, - 0xFFE4, 0x0018, 0x0050, 0x0008, - 0x0000, 0x0078, 0x0000, 0x003C, - 0x0000, 0x001E, 0x0000, 0x0384, - 0x0000, 0x001E, 0x0000, 0x001E, - 0x0000, 0x0384 -}; +s16 unused_800E0B18[74] = { 0x0140, 0x017C, 0x01B8, 0x01F4, 0x0230, 0x026C, 0x02A8, 0x02E4, 0x01E0, 0x0000, 0x0018, + 0x0039, 0x005A, 0x007B, 0x009C, 0x00BD, 0x00DE, 0x00FF, 0x00A0, 0x0000, 0x0140, 0x01B8, + 0x0230, 0x02A8, 0x01E0, 0x0000, 0x0018, 0x0065, 0x00B3, 0x0100, 0x00A0, 0x0000, 0x0140, + 0x01F4, 0x02A8, 0x01E0, 0x0028, 0x008C, 0x00F0, 0x00A0, 0x01E0, 0x00C0, 0x00A0, 0x00C0, + 0xFF60, 0x00C0, 0xFF80, 0xFFEC, 0xFFE4, 0xFFE6, 0x0050, 0xFFF8, 0xFFE4, 0xFFF4, 0xFFE4, + 0x0006, 0xFFE4, 0x0018, 0x0050, 0x0008, 0x0000, 0x0078, 0x0000, 0x003C, 0x0000, 0x001E, + 0x0000, 0x0384, 0x0000, 0x001E, 0x0000, 0x001E, 0x0000, 0x0384 }; -char gFirstPlace[4] = "1ST"; -char gSecondPlace[4] = "2ND"; -char gThirdPlace[4] = "3RD"; -char gFourthPlace[4] = "4TH"; -char gFifthPlace[4] = "5TH"; -char gSixthPlace[4] = "6TH"; +char gFirstPlace[4] = "1ST"; +char gSecondPlace[4] = "2ND"; +char gThirdPlace[4] = "3RD"; +char gFourthPlace[4] = "4TH"; +char gFifthPlace[4] = "5TH"; +char gSixthPlace[4] = "6TH"; char gSeventhPlace[4] = "7TH"; -char gEighthPlace[4] = "8TH"; +char gEighthPlace[4] = "8TH"; -char *gRacePlacementsArray[8] = { - gFirstPlace, gSecondPlace, gThirdPlace, gFourthPlace, - gFifthPlace, gSixthPlace, gSeventhPlace, gEighthPlace -}; +char *gRacePlacementsArray[8] = { gFirstPlace, gSecondPlace, gThirdPlace, gFourthPlace, + gFifthPlace, gSixthPlace, gSeventhPlace, gEighthPlace }; MenuElement gRaceResultsMenuElements[8] = { - { 352, 172, 32, 172, -288, 172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 452, 166, 132, 166, -188, 166, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 560, 184, 240, 184, -80, 184, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 452, 180, 132, 180, -188, 180, 255, 192, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, {{ 0, 0, 0, 0 }} }, - { 452, 198, 132, 198, -188, 198, 255, 192, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, {{ 0, 0, 0, 0 }} }, - { 452, 216, 132, 216, -188, 216, 255, 192, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, {{ 0, 0, 0, 0 }} }, - { 560, 200, 240, 200, -80, 200, 128, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, {{ 0, 0, 0, 0 }} }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, {{ 0, 0, 0, 0 }} }, + { 352, + 172, + 32, + 172, + -288, + 172, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 452, 166, 132, 166, -188, 166, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 560, 184, 240, 184, -80, 184, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 452, 180, 132, 180, -188, 180, 255, 192, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, { { 0, 0, 0, 0 } } }, + { 452, 198, 132, 198, -188, 198, 255, 192, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, { { 0, 0, 0, 0 } } }, + { 452, 216, 132, 216, -188, 216, 255, 192, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, { { 0, 0, 0, 0 } } }, + { 560, 200, 240, 200, -80, 200, 128, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, { { 0, 0, 0, 0 } } }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, { { 0, 0, 0, 0 } } }, }; MenuElement gRaceOrderMenuElements[11] = { - { 575, 172, 255, 172, -65, 172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 542, 172, 222, 172, -98, 172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 509, 172, 189, 172, -131, 172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 476, 172, 156, 172, -164, 172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 443, 172, 123, 172, -197, 172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 410, 172, 90, 172, -230, 172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 377, 172, 57, 172, -263, 172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 344, 172, 24, 172, -296, 166, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 481, 166, 161, 166, -159, 166, 0, 0, 0, 255, 128, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 479, 164, 159, 164, -161, 164, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, {{ 0, 0, 0, 0 }} }, + { 575, + 172, + 255, + 172, + -65, + 172, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 542, + 172, + 222, + 172, + -98, + 172, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 509, + 172, + 189, + 172, + -131, + 172, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 476, + 172, + 156, + 172, + -164, + 172, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 443, + 172, + 123, + 172, + -197, + 172, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 410, + 172, + 90, + 172, + -230, + 172, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 377, + 172, + 57, + 172, + -263, + 172, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 344, + 172, + 24, + 172, + -296, + 166, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 481, 166, 161, 166, -159, 166, 0, 0, 0, 255, 128, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 479, 164, 159, 164, -161, 164, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, { { 0, 0, 0, 0 } } }, }; MenuElement gRecordTimesMenuElements[9] = { - { 481, 174, 161, 174, -159, 174, 0, 0, 0, 255, 128, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 479, 172, 159, 172, -161, 172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 368, 192, 48, 192, -272, 192, 255, 64, 64, 96, 255, ASSET_FONTS_FUNFONT, 8, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 506, 187, 186, 187, -134, 187, 255, 192, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, {{ 0, 0, 0, 0 }} }, - { 578, 192, 258, 192, -62, 192, 255, 128, 255, 96, 255, ASSET_FONTS_FUNFONT, 12, 0, { &D_80126390 }, {{ 0, 0, 0, 0 }} }, - { 368, 212, 48, 212, -272, 212, 255, 64, 64, 96, 255, ASSET_FONTS_FUNFONT, 8, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 506, 207, 186, 207, -134, 207, 128, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, {{ 0, 0, 0, 0 }} }, - { 578, 212, 258, 212, -62, 212, 255, 128, 255, 96, 255, ASSET_FONTS_FUNFONT, 12, 0, { &D_80126394 }, {{ 0, 0, 0, 0 }} }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, {{ 0, 0, 0, 0 }} }, + { 481, 174, 161, 174, -159, 174, 0, 0, 0, 255, 128, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 479, 172, 159, 172, -161, 172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 12, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 368, 192, 48, 192, -272, 192, 255, 64, 64, 96, 255, ASSET_FONTS_FUNFONT, 8, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 506, 187, 186, 187, -134, 187, 255, 192, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, { { 0, 0, 0, 0 } } }, + { 578, + 192, + 258, + 192, + -62, + 192, + 255, + 128, + 255, + 96, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { &D_80126390 }, + { { 0, 0, 0, 0 } } }, + { 368, 212, 48, 212, -272, 212, 255, 64, 64, 96, 255, ASSET_FONTS_FUNFONT, 8, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 506, 207, 186, 207, -134, 207, 128, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 1, { NULL }, { { 0, 0, 0, 0 } } }, + { 578, + 212, + 258, + 212, + -62, + 212, + 255, + 128, + 255, + 96, + 255, + ASSET_FONTS_FUNFONT, + 12, + 0, + { &D_80126394 }, + { { 0, 0, 0, 0 } } }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, { { 0, 0, 0, 0 } } }, }; // Valid characters for name input. Must be u8, not char. @@ -1191,205 +1610,538 @@ char gCheckAdvEnterInitials[4] = "DKR"; // Default file name? s32 D_800E0FAC = 0; s32 gIndexOfCurInputCharacter = 0; -s16 gAdvTrackInitObjectIndices[18] = { - 0x0004, 0x0000, 0x0001, 0x0018, - 0x0019, 0x001A, 0x001B, 0x001C, - 0x001D, 0x001E, 0x001F, 0x0020, - 0x0021, 0x0022, 0x0023, 0x0030, - 0x005E, -1 -}; +s16 gAdvTrackInitObjectIndices[18] = { 0x0004, 0x0000, 0x0001, 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, + 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023, 0x0030, 0x005E, -1 }; -s16 gAdvTrackInitImageIndices[6] = { - 7, 0, 1, 2, 3, -1 -}; +s16 gAdvTrackInitImageIndices[6] = { 7, 0, 1, 2, 3, -1 }; s32 gRankingPlayerCount = 8; // Number of racers in trophy race? (1 to 8) s32 gTrophyRaceWorldId = 0; s32 gTrophyRaceRound = 0; // Rounds 1 - 4 (as 0 - 3) s32 gPrevTrophyRaceRound = 0; -u32 unused_800E0FF4[4] = { - 0x01FFFFFF, 0x0012FFFF, 0x81FFFFFF, 0x00120000 -}; +u32 unused_800E0FF4[4] = { 0x01FFFFFF, 0x0012FFFF, 0x81FFFFFF, 0x00120000 }; // Number of points to award in trophy race for each place. -s32 gTrophyRacePointsArray[8] = { - 9, 7, 5, 3, 1, 0, 0, 0 -}; +s32 gTrophyRacePointsArray[8] = { 9, 7, 5, 3, 1, 0, 0, 0 }; -s16 gTrophyRankingsObjectIndices[14] = { - 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x00, 0x01, -1, 0x00 -}; +s16 gTrophyRankingsObjectIndices[14] = { 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x3A, 0x3B, 0x00, 0x01, -1, 0x00 }; -s16 gTrophyRaceImageIndices[3] = { - 0, 1, -1 -}; +s16 gTrophyRaceImageIndices[3] = { 0, 1, -1 }; MenuElement gTrophyRankingsTitle[] = { - { 320 + 160 + 1, 35, (320 / 2) + 1, 35, -159, 35, 0, 0, 0, 255, 128, ASSET_FONTS_BIGFONT, 12, 0, { 0 }, {{ 0, 0, 0, 0 }} }, - { 320 + 160, 32, (320 / 2), 32, -160, 32, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 12, 0, { 0 }, {{ 0, 0, 0, 0 }} }, + { 320 + 160 + 1, + 35, + (320 / 2) + 1, + 35, + -159, + 35, + 0, + 0, + 0, + 255, + 128, + ASSET_FONTS_BIGFONT, + 12, + 0, + { 0 }, + { { 0, 0, 0, 0 } } }, + { 320 + 160, + 32, + (320 / 2), + 32, + -160, + 32, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_BIGFONT, + 12, + 0, + { 0 }, + { { 0, 0, 0, 0 } } }, }; MenuElement gTrophyRankingsRacers[] = { - { 64, -192, 64, 48, 64, 288, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 32, -192, 32, 48, 32, 288, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 0, { gFirstPlace }, {{ 0, 0, 0, 0 }} }, - { 130, -172, 130, 68, 130, 308, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 4, 2, { &gTrophyRacePointsArray[0] }, {{ 0, 0, 0, 0 }} }, - { 64, -150, 64, 90, 64, 330, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 32, -150, 32, 90, 32, 330, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 0, { gSecondPlace }, {{ 0, 0, 0, 0 }} }, - { 130, -130, 130, 110, 130, 350, 255, 192, 255, 0, 255, ASSET_FONTS_FUNFONT, 4, 2, { &gTrophyRacePointsArray[1] }, {{ 0, 0, 0, 0 }} }, - { 64, -108, 64, 132, 64, 372, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 32, -108, 32, 132, 32, 372, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 0, { gThirdPlace }, {{ 0, 0, 0, 0 }} }, - { 130, -88, 130, 152, 130, 392, 255, 128, 255, 0, 255, ASSET_FONTS_FUNFONT, 4, 2, { &gTrophyRacePointsArray[2] }, {{ 0, 0, 0, 0 }} }, - { 64, -66, 64, 174, 64, 414, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 32, -66, 32, 174, 32, 414, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 0, { gFourthPlace }, {{ 0, 0, 0, 0 }} }, - { 130, -46, 130, 194, 130, 434, 255, 64, 255, 0, 255, ASSET_FONTS_FUNFONT, 4, 2, { &gTrophyRacePointsArray[3] }, {{ 0, 0, 0, 0 }} }, - { 220, 288, 220, 48, 220, -192, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 188, 288, 188, 48, 188, -192, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 0, { gFifthPlace }, {{ 0, 0, 0, 0 }} }, - { 286, 308, 286, 68, 286, -172, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 4, 2, { &gTrophyRacePointsArray[4] }, {{ 0, 0, 0, 0 }} }, - { 220, 330, 220, 90, 220, -160, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 188, 330, 188, 90, 188, -150, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 0, { gSixthPlace }, {{ 0, 0, 0, 0 }} }, - { 286, 350, 286, 110, 286, -130, 255, 192, 255, 0, 255, ASSET_FONTS_FUNFONT, 4, 2, { &gTrophyRacePointsArray[5] }, {{ 0, 0, 0, 0 }} }, - { 220, 372, 220, 132, 220, -108, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 188, 372, 188, 132, 188, -108, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 0, { gSeventhPlace }, {{ 0, 0, 0, 0 }} }, - { 286, 392, 286, 152, 286, -88, 255, 128, 255, 0, 255, ASSET_FONTS_FUNFONT, 4, 2, { &gTrophyRacePointsArray[6] }, {{ 0, 0, 0, 0 }} }, - { 220, 414, 220, 174, 220, -66, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 3, { &gMenuPortraitKrunch }, {{ 0, 0, 0, 0 }} }, - { 188, 414, 188, 174, 188, -66, 255, 255, 255, 0, 255, ASSET_FONTS_FUNFONT, 0, 0, { gEighthPlace }, {{ 0, 0, 0, 0 }} }, - { 286, 434, 286, 194, 286, -46, 255, 64, 255, 0, 255, ASSET_FONTS_FUNFONT, 4, 2, { &gTrophyRacePointsArray[7] }, {{ 0, 0, 0, 0 }} }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ASSET_FONTS_FUNFONT, 0, 0, { 0 }, {{ 0, 0, 0, 0 }} } + { 64, + -192, + 64, + 48, + 64, + 288, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 32, + -192, + 32, + 48, + 32, + 288, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 0, + { gFirstPlace }, + { { 0, 0, 0, 0 } } }, + { 130, + -172, + 130, + 68, + 130, + 308, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 4, + 2, + { &gTrophyRacePointsArray[0] }, + { { 0, 0, 0, 0 } } }, + { 64, + -150, + 64, + 90, + 64, + 330, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 32, + -150, + 32, + 90, + 32, + 330, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 0, + { gSecondPlace }, + { { 0, 0, 0, 0 } } }, + { 130, + -130, + 130, + 110, + 130, + 350, + 255, + 192, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 4, + 2, + { &gTrophyRacePointsArray[1] }, + { { 0, 0, 0, 0 } } }, + { 64, + -108, + 64, + 132, + 64, + 372, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 32, + -108, + 32, + 132, + 32, + 372, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 0, + { gThirdPlace }, + { { 0, 0, 0, 0 } } }, + { 130, + -88, + 130, + 152, + 130, + 392, + 255, + 128, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 4, + 2, + { &gTrophyRacePointsArray[2] }, + { { 0, 0, 0, 0 } } }, + { 64, + -66, + 64, + 174, + 64, + 414, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 32, + -66, + 32, + 174, + 32, + 414, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 0, + { gFourthPlace }, + { { 0, 0, 0, 0 } } }, + { 130, + -46, + 130, + 194, + 130, + 434, + 255, + 64, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 4, + 2, + { &gTrophyRacePointsArray[3] }, + { { 0, 0, 0, 0 } } }, + { 220, + 288, + 220, + 48, + 220, + -192, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 188, + 288, + 188, + 48, + 188, + -192, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 0, + { gFifthPlace }, + { { 0, 0, 0, 0 } } }, + { 286, + 308, + 286, + 68, + 286, + -172, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 4, + 2, + { &gTrophyRacePointsArray[4] }, + { { 0, 0, 0, 0 } } }, + { 220, + 330, + 220, + 90, + 220, + -160, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 188, + 330, + 188, + 90, + 188, + -150, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 0, + { gSixthPlace }, + { { 0, 0, 0, 0 } } }, + { 286, + 350, + 286, + 110, + 286, + -130, + 255, + 192, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 4, + 2, + { &gTrophyRacePointsArray[5] }, + { { 0, 0, 0, 0 } } }, + { 220, + 372, + 220, + 132, + 220, + -108, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 188, + 372, + 188, + 132, + 188, + -108, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 0, + { gSeventhPlace }, + { { 0, 0, 0, 0 } } }, + { 286, + 392, + 286, + 152, + 286, + -88, + 255, + 128, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 4, + 2, + { &gTrophyRacePointsArray[6] }, + { { 0, 0, 0, 0 } } }, + { 220, + 414, + 220, + 174, + 220, + -66, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 3, + { &gMenuPortraitKrunch }, + { { 0, 0, 0, 0 } } }, + { 188, + 414, + 188, + 174, + 188, + -66, + 255, + 255, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 0, + 0, + { gEighthPlace }, + { { 0, 0, 0, 0 } } }, + { 286, + 434, + 286, + 194, + 286, + -46, + 255, + 64, + 255, + 0, + 255, + ASSET_FONTS_FUNFONT, + 4, + 2, + { &gTrophyRacePointsArray[7] }, + { { 0, 0, 0, 0 } } }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ASSET_FONTS_FUNFONT, 0, 0, { 0 }, { { 0, 0, 0, 0 } } } }; s16 gTrophyRankingsRawIconPositions[138] = { - 0x0040, 0x0020, 0x0082, 0x0040, 0x0020, 0x0082, 0x0040, 0x0020, - 0x0082, 0x0040, 0x0020, 0x0082, 0x00DC, 0x00BC, 0x011E, 0x00DC, - 0x00BC, 0x011E, 0x00DC, 0x00BC, 0x011E, 0x00DC, 0x00BC, 0x011E, - 0x0030, 0x0030, 0x0044, 0x005A, 0x005A, 0x006E, 0x0084, 0x0084, - 0x0098, 0x00AE, 0x00AE, 0x00C2, 0x0030, 0x0030, 0x0044, 0x005A, - 0x005A, 0x006E, 0x0084, 0x0084, 0x0098, 0x00AE, 0x00AE, 0x00C2, - 0x0038, 0x0038, 0x0040, 0x006A, 0x006A, 0x0072, 0x009C, 0x009C, - 0x00A4, 0x00CE, 0x00CE, 0x00D6, 0x0038, 0x0038, 0x0040, 0x006A, - 0x006A, 0x0072, 0x009C, 0x009C, 0x00A4, 0x00CE, 0x00CE, 0x00D6, - 0x0040, 0x0020, 0x0082, 0x0040, 0x0020, 0x0082, 0x0040, 0x0020, - 0x0082, 0x00DC, 0x00BC, 0x011E, 0x00DC, 0x00BC, 0x011E, 0x00DC, - 0x00BC, 0x011E, 0x0034, 0x0034, 0x0048, 0x006F, 0x006F, 0x0083, - 0x00AA, 0x00AA, 0x00BE, 0x0034, 0x0034, 0x0048, 0x006F, 0x006F, - 0x0083, 0x00AA, 0x00AA, 0x00BE, 0x004C, 0x004C, 0x0054, 0x007E, - 0x007E, 0x0086, 0x00B0, 0x00B0, 0x00B8, 0x004C, 0x004C, 0x0054, - 0x007E, 0x007E, 0x0086, 0x00B0, 0x00B0, 0x00B8, 0x008C, 0x006C, - 0x00CE, 0x008C, 0x006C, 0x00CE, 0x008C, 0x006C, 0x00CE, 0x008C, - 0x006C, 0x00CE + 0x0040, 0x0020, 0x0082, 0x0040, 0x0020, 0x0082, 0x0040, 0x0020, 0x0082, 0x0040, 0x0020, 0x0082, 0x00DC, 0x00BC, + 0x011E, 0x00DC, 0x00BC, 0x011E, 0x00DC, 0x00BC, 0x011E, 0x00DC, 0x00BC, 0x011E, 0x0030, 0x0030, 0x0044, 0x005A, + 0x005A, 0x006E, 0x0084, 0x0084, 0x0098, 0x00AE, 0x00AE, 0x00C2, 0x0030, 0x0030, 0x0044, 0x005A, 0x005A, 0x006E, + 0x0084, 0x0084, 0x0098, 0x00AE, 0x00AE, 0x00C2, 0x0038, 0x0038, 0x0040, 0x006A, 0x006A, 0x0072, 0x009C, 0x009C, + 0x00A4, 0x00CE, 0x00CE, 0x00D6, 0x0038, 0x0038, 0x0040, 0x006A, 0x006A, 0x0072, 0x009C, 0x009C, 0x00A4, 0x00CE, + 0x00CE, 0x00D6, 0x0040, 0x0020, 0x0082, 0x0040, 0x0020, 0x0082, 0x0040, 0x0020, 0x0082, 0x00DC, 0x00BC, 0x011E, + 0x00DC, 0x00BC, 0x011E, 0x00DC, 0x00BC, 0x011E, 0x0034, 0x0034, 0x0048, 0x006F, 0x006F, 0x0083, 0x00AA, 0x00AA, + 0x00BE, 0x0034, 0x0034, 0x0048, 0x006F, 0x006F, 0x0083, 0x00AA, 0x00AA, 0x00BE, 0x004C, 0x004C, 0x0054, 0x007E, + 0x007E, 0x0086, 0x00B0, 0x00B0, 0x00B8, 0x004C, 0x004C, 0x0054, 0x007E, 0x007E, 0x0086, 0x00B0, 0x00B0, 0x00B8, + 0x008C, 0x006C, 0x00CE, 0x008C, 0x006C, 0x00CE, 0x008C, 0x006C, 0x00CE, 0x008C, 0x006C, 0x00CE }; -s16 *gTrophyRankingsIconPositions[32] = { - NULL, NULL, NULL, NULL, - &gTrophyRankingsRawIconPositions[126], &gTrophyRankingsRawIconPositions[90], &gTrophyRankingsRawIconPositions[126], &gTrophyRankingsRawIconPositions[24], - NULL, NULL , &gTrophyRankingsRawIconPositions[72], &gTrophyRankingsRawIconPositions[90], - NULL, NULL, &gTrophyRankingsRawIconPositions[0], &gTrophyRankingsRawIconPositions[24], - NULL, NULL, NULL, NULL, - &gTrophyRankingsRawIconPositions[126], &gTrophyRankingsRawIconPositions[108], &gTrophyRankingsRawIconPositions[126], &gTrophyRankingsRawIconPositions[48], - NULL, NULL, &gTrophyRankingsRawIconPositions[72], &gTrophyRankingsRawIconPositions[108], - NULL, NULL, &gTrophyRankingsRawIconPositions[0], &gTrophyRankingsRawIconPositions[48] -}; +s16 *gTrophyRankingsIconPositions[32] = { NULL, + NULL, + NULL, + NULL, + &gTrophyRankingsRawIconPositions[126], + &gTrophyRankingsRawIconPositions[90], + &gTrophyRankingsRawIconPositions[126], + &gTrophyRankingsRawIconPositions[24], + NULL, + NULL, + &gTrophyRankingsRawIconPositions[72], + &gTrophyRankingsRawIconPositions[90], + NULL, + NULL, + &gTrophyRankingsRawIconPositions[0], + &gTrophyRankingsRawIconPositions[24], + NULL, + NULL, + NULL, + NULL, + &gTrophyRankingsRawIconPositions[126], + &gTrophyRankingsRawIconPositions[108], + &gTrophyRankingsRawIconPositions[126], + &gTrophyRankingsRawIconPositions[48], + NULL, + NULL, + &gTrophyRankingsRawIconPositions[72], + &gTrophyRankingsRawIconPositions[108], + NULL, + NULL, + &gTrophyRankingsRawIconPositions[0], + &gTrophyRankingsRawIconPositions[48] }; // DrawTextures for Dino Domain ghost background. -DrawTexture gDrawTexDinoDomainGhostBg[] = { - { NULL, 0, 0 }, - { NULL, 64, 0 }, - { NULL, 128, 0 }, - { NULL, 192, 0 }, - { NULL, 256, 0 }, - { NULL, 0, 32 }, - { NULL, 64, 32 }, - { NULL, 128, 32 }, - { NULL, 192, 32 }, - { NULL, 256, 32 }, - { NULL, 0, 0 } -}; +DrawTexture gDrawTexDinoDomainGhostBg[] = { { NULL, 0, 0 }, { NULL, 64, 0 }, { NULL, 128, 0 }, { NULL, 192, 0 }, + { NULL, 256, 0 }, { NULL, 0, 32 }, { NULL, 64, 32 }, { NULL, 128, 32 }, + { NULL, 192, 32 }, { NULL, 256, 32 }, { NULL, 0, 0 } }; // DrawTextures for Sherbet Island ghost background. -DrawTexture gDrawTexSherbetIslandGhostBg[] = { - { NULL, 0, 0 }, - { NULL, 64, 0 }, - { NULL, 128, 0 }, - { NULL, 192, 0 }, - { NULL, 256, 0 }, - { NULL, 0, 32 }, - { NULL, 64, 32 }, - { NULL, 128, 32 }, - { NULL, 192, 32 }, - { NULL, 256, 32 }, - { NULL, 0, 0 } -}; +DrawTexture gDrawTexSherbetIslandGhostBg[] = { { NULL, 0, 0 }, { NULL, 64, 0 }, { NULL, 128, 0 }, + { NULL, 192, 0 }, { NULL, 256, 0 }, { NULL, 0, 32 }, + { NULL, 64, 32 }, { NULL, 128, 32 }, { NULL, 192, 32 }, + { NULL, 256, 32 }, { NULL, 0, 0 } }; // DrawTextures for Snowflake Mountain ghost background. -DrawTexture gDrawTexSnowflakeMountainGhostBg[] = { - { NULL, 0, 0 }, - { NULL, 64, 0 }, - { NULL, 128, 0 }, - { NULL, 192, 0 }, - { NULL, 256, 0 }, - { NULL, 0, 32 }, - { NULL, 64, 32 }, - { NULL, 128, 32 }, - { NULL, 192, 32 }, - { NULL, 256, 32 }, - { NULL, 0, 0 } -}; +DrawTexture gDrawTexSnowflakeMountainGhostBg[] = { { NULL, 0, 0 }, { NULL, 64, 0 }, { NULL, 128, 0 }, + { NULL, 192, 0 }, { NULL, 256, 0 }, { NULL, 0, 32 }, + { NULL, 64, 32 }, { NULL, 128, 32 }, { NULL, 192, 32 }, + { NULL, 256, 32 }, { NULL, 0, 0 } }; // DrawTextures for Dragon Forest ghost background. -DrawTexture gDrawTexDragonForestGhostBg[] = { - { NULL, 0, 0 }, - { NULL, 64, 0 }, - { NULL, 128, 0 }, - { NULL, 192, 0 }, - { NULL, 256, 0 }, - { NULL, 0, 32 }, - { NULL, 64, 32 }, - { NULL, 128, 32 }, - { NULL, 192, 32 }, - { NULL, 256, 32 }, - { NULL, 0, 0 } -}; +DrawTexture gDrawTexDragonForestGhostBg[] = { { NULL, 0, 0 }, { NULL, 64, 0 }, { NULL, 128, 0 }, { NULL, 192, 0 }, + { NULL, 256, 0 }, { NULL, 0, 32 }, { NULL, 64, 32 }, { NULL, 128, 32 }, + { NULL, 192, 32 }, { NULL, 256, 32 }, { NULL, 0, 0 } }; // DrawTextures for Future Fun Land ghost background. -DrawTexture gDrawTexFutureFunLandGhostBg[] = { - { NULL, 0, 0 }, - { NULL, 64, 0 }, - { NULL, 128, 0 }, - { NULL, 192, 0 }, - { NULL, 256, 0 }, - { NULL, 0, 32 }, - { NULL, 64, 32 }, - { NULL, 128, 32 }, - { NULL, 192, 32 }, - { NULL, 256, 32 }, - { NULL, 0, 0 } -}; +DrawTexture gDrawTexFutureFunLandGhostBg[] = { { NULL, 0, 0 }, { NULL, 64, 0 }, { NULL, 128, 0 }, + { NULL, 192, 0 }, { NULL, 256, 0 }, { NULL, 0, 32 }, + { NULL, 64, 32 }, { NULL, 128, 32 }, { NULL, 192, 32 }, + { NULL, 256, 32 }, { NULL, 0, 0 } }; DrawTexture *gDrawTexWorldBgs[5] = { - gDrawTexDinoDomainGhostBg, // Dino Domain - gDrawTexSherbetIslandGhostBg, // Sherbet Island + gDrawTexDinoDomainGhostBg, // Dino Domain + gDrawTexSherbetIslandGhostBg, // Sherbet Island gDrawTexSnowflakeMountainGhostBg, // Snowflake Mountain - gDrawTexDragonForestGhostBg, // Dragon Forest - gDrawTexFutureFunLandGhostBg // Future Fun Land + gDrawTexDragonForestGhostBg, // Dragon Forest + gDrawTexFutureFunLandGhostBg // Future Fun Land }; -s16 gGhostDataObjectIndices[34] = { - 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, - 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, - 0x32, 0x33, 0x34, 0x36, 0x35, 0x37, 0x38, 0x39, - 0x3A, 0x3B, 0x00, 0x01, 0x04, 0x3D, 0x3C, 0x3F, - 0x3E, -1 -}; +s16 gGhostDataObjectIndices[34] = { 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, + 0x1A, 0x1B, 0x1C, 0x1D, 0x32, 0x33, 0x34, 0x36, 0x35, 0x37, 0x38, 0x39, + 0x3A, 0x3B, 0x00, 0x01, 0x04, 0x3D, 0x3C, 0x3F, 0x3E, -1 }; -s16 gGhostDataImageIndices[4] = { - 0, 1, 7, -1 -}; +s16 gGhostDataImageIndices[4] = { 0, 1, 7, -1 }; -s16 gGhostDataElementPositions[10] = { - 0x78, 0x12, 0x08, 0x06, 0xC0, 0x06, 0xD4, 0x1A, 0x78, 0x22 -}; +s16 gGhostDataElementPositions[10] = { 0x78, 0x12, 0x08, 0x06, 0xC0, 0x06, 0xD4, 0x1A, 0x78, 0x22 }; -s16 gIntroCinematicObjectIndices[12] = { - 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, -1, 0 -}; +s16 gIntroCinematicObjectIndices[12] = { 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, -1, 0 }; Gfx dCreditsFade[11] = { gsDPPipeSync(), @@ -1409,152 +2161,280 @@ s16 gCreditsObjectIndices[12] = { 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, -1, 0 }; -s16 gCreditsImageIndices[2] = { - -1, 0 -}; - +s16 gCreditsImageIndices[2] = { -1, 0 }; #define CREDITS_END (0x1000) -#define CREDITS_NEW_TITLE(seconds) (0x2000 | ((s16)(seconds * 60.0))) -#define CREDITS_CONTINUE_TITLE(seconds) (0x3000 | ((s16)(seconds * 60.0))) +#define CREDITS_NEW_TITLE(seconds) (0x2000 | ((s16) (seconds * 60.0))) +#define CREDITS_CONTINUE_TITLE(seconds) (0x3000 | ((s16) (seconds * 60.0))) #define CREDITS_NEXT_LEVEL (0x4000) -#define CREDITS_DEV_TIMES(seconds) (0x6000 | ((s16)(seconds * 60.0))) +#define CREDITS_DEV_TIMES(seconds) (0x6000 | ((s16) (seconds * 60.0))) // Number of seconds for each section in the credits. #define CREDITS_DEFAULT_TITLE_TIME 2.75 -#define CREDITS_MAGIC_CODE_TIME 4.5 +#define CREDITS_MAGIC_CODE_TIME 4.5 #define CREDITS_DEV_TIMES_TIME 8.334 // Data used to control the credits. s16 gCreditsControlData[] = { CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 0, // "CREDITS" - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 1, 2, // "Software Director", "R.Harrison" - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 3, 4, 5, 6, - CREDITS_NEXT_LEVEL, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 7, 8, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 9, 10, 11, 12, - CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 13, 14, 15, - CREDITS_NEXT_LEVEL, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 16, 17, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 18, 19, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 20, - CREDITS_NEXT_LEVEL, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 21, 22, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 23, 24, + 0, // "CREDITS" CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 25, 26, - CREDITS_NEXT_LEVEL, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 27, 28, 29, 30, 31, - CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 32, 33, 34, 35, - CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 36, 37, 38, - CREDITS_NEXT_LEVEL, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 39, 40, 41, 42, 43, - CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 44, 45, 46, - CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 47, 48, 49, - CREDITS_NEXT_LEVEL, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 50, 51, 52, 53, 54, - CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 55, 56, 57, 58, - CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 59, 60, 61, 62, - CREDITS_NEXT_LEVEL, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 63, 64, 65, + 1, + 2, // "Software Director", "R.Harrison" CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 66, 67, 68, 69, 70, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 71, 72, 73, - CREDITS_NEXT_LEVEL, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 74, 75, // "Special Thanks To", "J.HOCHBERG" - CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 76, // "H.LINCOLN" + 3, + 4, + 5, + 6, + CREDITS_NEXT_LEVEL, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 7, + 8, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 9, + 10, + 11, + 12, CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 77, // "M.ARAKAWA" - CREDITS_NEXT_LEVEL, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 78, 79, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 80, 81, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 82, 83, - CREDITS_NEXT_LEVEL, - CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), - 84, // "THE END" + 13, + 14, + 15, + CREDITS_NEXT_LEVEL, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 16, + 17, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 18, + 19, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 20, + CREDITS_NEXT_LEVEL, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 21, + 22, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 23, + 24, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 25, + 26, + CREDITS_NEXT_LEVEL, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 27, + 28, + 29, + 30, + 31, + CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 32, + 33, + 34, + 35, + CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 36, + 37, + 38, + CREDITS_NEXT_LEVEL, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 39, + 40, + 41, + 42, + 43, + CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 44, + 45, + 46, + CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 47, + 48, + 49, + CREDITS_NEXT_LEVEL, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 50, + 51, + 52, + 53, + 54, + CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 55, + 56, + 57, + 58, + CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 59, + 60, + 61, + 62, + CREDITS_NEXT_LEVEL, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 63, + 64, + 65, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 66, + 67, + 68, + 69, + 70, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 71, + 72, + 73, + CREDITS_NEXT_LEVEL, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 74, + 75, // "Special Thanks To", "J.HOCHBERG" + CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 76, // "H.LINCOLN" + CREDITS_CONTINUE_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 77, // "M.ARAKAWA" + CREDITS_NEXT_LEVEL, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 78, + 79, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 80, + 81, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 82, + 83, + CREDITS_NEXT_LEVEL, + CREDITS_NEW_TITLE(CREDITS_DEFAULT_TITLE_TIME), + 84, // "THE END" CREDITS_NEW_TITLE(CREDITS_MAGIC_CODE_TIME), - 85, 86, // Magic Code Description, Magic Code + 85, + 86, // Magic Code Description, Magic Code CREDITS_NEXT_LEVEL, CREDITS_END, // Set to CREDITS_DEV_TIMES(CREDITS_DEV_TIMES_TIME) if you've beaten wizpig 2. - 0, 1, 2, 3, + 0, + 1, + 2, + 3, CREDITS_NEXT_LEVEL, - CREDITS_DEV_TIMES(CREDITS_DEV_TIMES_TIME), - 4, 5, 6, 7, - CREDITS_NEXT_LEVEL, - CREDITS_DEV_TIMES(CREDITS_DEV_TIMES_TIME), - 8, 9, 10, 11, - CREDITS_NEXT_LEVEL, - CREDITS_DEV_TIMES(CREDITS_DEV_TIMES_TIME), - 12, 13, 14, 15, - CREDITS_NEXT_LEVEL, CREDITS_DEV_TIMES(CREDITS_DEV_TIMES_TIME), - 16, 17, 18, 19, + 4, + 5, + 6, + 7, + CREDITS_NEXT_LEVEL, + CREDITS_DEV_TIMES(CREDITS_DEV_TIMES_TIME), + 8, + 9, + 10, + 11, + CREDITS_NEXT_LEVEL, + CREDITS_DEV_TIMES(CREDITS_DEV_TIMES_TIME), + 12, + 13, + 14, + 15, + CREDITS_NEXT_LEVEL, + CREDITS_DEV_TIMES(CREDITS_DEV_TIMES_TIME), + 16, + 17, + 18, + 19, CREDITS_NEXT_LEVEL, CREDITS_END }; // List of amazing people. -char *gCreditsArray[87] = { - "CREDITS", - "Software Director", "R.Harrison", - "Software Engineers", "P.Mountain", "J.Pegg", "R.Gale", - "Art Director", "K.Bayliss", - "3D Artists", "L.Musgrave", "K.Rabbette", "D.Smith", "J.Christensen", "B.Smyth", "P.Cunningham", - "Music", "D.Wise", - "Sound Effects", "G.Norgate", - "ALSO", - "Additional Design", "M.Wakeley", - "Documentation", "L.Loveday", "Liason", "E.Hochberg", - "Character Voices", "K.Bayliss", "J.Christensen", "E.Fischer", "K.Rabbette", "L.Ray", - "L.Schuneman", "C.Seavor", "D.Smith", "J.Stamper", "K.Stamper", "C.Sutherland", - "Rare Quality Assurance", "H.Ward", "G.Richards", "S.Farmer", "J.Williams", "D.Wong", - "G.Jones", "M.Penny", "S.Brand", "S.Malpass", "A.Wilson", - "NOA Thanks To", "M.Fukuda", "K.Lobb", "M.Kelbaugh", "A.Williams", "R.Johnson", "M.Forrest", - "P.Sandhop", "H.Sterchi", "T.Hertzog", "D.Bridgham", "G.Richardson", "B.Smith", - "NOA Thanks To", "NOA Tree House", "NOA Tree Branch", - "NCL Thank You's", "K.Terasaki", "M.Goto", "H.Yamada", "Mario Club", - "NOE Thank You's", "J.Kraft", "J.Bardakoff", - "Special Thanks To", "J.Hochberg", "H.Lincoln", "M.Arakawa", - "Game Director", "L.Schuneman", - "Producer", "C.Stamper", - "Executive Producer", "T.Stamper", - NULL, NULL, NULL -}; +char *gCreditsArray[87] = { "CREDITS", + "Software Director", + "R.Harrison", + "Software Engineers", + "P.Mountain", + "J.Pegg", + "R.Gale", + "Art Director", + "K.Bayliss", + "3D Artists", + "L.Musgrave", + "K.Rabbette", + "D.Smith", + "J.Christensen", + "B.Smyth", + "P.Cunningham", + "Music", + "D.Wise", + "Sound Effects", + "G.Norgate", + "ALSO", + "Additional Design", + "M.Wakeley", + "Documentation", + "L.Loveday", + "Liason", + "E.Hochberg", + "Character Voices", + "K.Bayliss", + "J.Christensen", + "E.Fischer", + "K.Rabbette", + "L.Ray", + "L.Schuneman", + "C.Seavor", + "D.Smith", + "J.Stamper", + "K.Stamper", + "C.Sutherland", + "Rare Quality Assurance", + "H.Ward", + "G.Richards", + "S.Farmer", + "J.Williams", + "D.Wong", + "G.Jones", + "M.Penny", + "S.Brand", + "S.Malpass", + "A.Wilson", + "NOA Thanks To", + "M.Fukuda", + "K.Lobb", + "M.Kelbaugh", + "A.Williams", + "R.Johnson", + "M.Forrest", + "P.Sandhop", + "H.Sterchi", + "T.Hertzog", + "D.Bridgham", + "G.Richardson", + "B.Smith", + "NOA Thanks To", + "NOA Tree House", + "NOA Tree Branch", + "NCL Thank You's", + "K.Terasaki", + "M.Goto", + "H.Yamada", + "Mario Club", + "NOE Thank You's", + "J.Kraft", + "J.Bardakoff", + "Special Thanks To", + "J.Hochberg", + "H.Lincoln", + "M.Arakawa", + "Game Director", + "L.Schuneman", + "Producer", + "C.Stamper", + "Executive Producer", + "T.Stamper", + NULL, + NULL, + NULL }; // Developer's best times for each track char *gCreditsBestTimesArray[20] = { -/***** Dino Domain *****/ "0:53:43", "1:21:55", "0:54:13", "1:22:48", -/** Snowflake Mountain */ "1:04:11", "1:13:51", "1:25:01", "0:55:05", -/**** Sherbet Island ***/ "1:37:63", "1:56:60", "0:57:81", "1:28:01", -/**** Dragon Forest ****/ "1:51:15", "1:31:80", "2:03:16", "0:58:25", -/*** Future Fun Land ***/ "2:00:38", "2:05:68", "1:52:96", "1:55:00" + /***** Dino Domain *****/ "0:53:43", "1:21:55", "0:54:13", "1:22:48", + /** Snowflake Mountain */ "1:04:11", "1:13:51", "1:25:01", "0:55:05", + /**** Sherbet Island ***/ "1:37:63", "1:56:60", "0:57:81", "1:28:01", + /**** Dragon Forest ****/ "1:51:15", "1:31:80", "2:03:16", "0:58:25", + /*** Future Fun Land ***/ "2:00:38", "2:05:68", "1:52:96", "1:55:00" }; char *gCreditsLastMessageArray[5] = { @@ -1564,43 +2444,41 @@ char *gCreditsLastMessageArray[5] = { }; // Cheats that are shown in the credits. -s32 gCheatsInCreditsArray[21] = { - CHEAT_BIG_CHARACTERS, - CHEAT_SMALL_CHARACTERS, - CHEAT_MUSIC_MENU, - CHEAT_START_WITH_10_BANANAS, - CHEAT_HORN_CHEAT, - CHEAT_DISPLAY_CREDITS, - CHEAT_DISABLE_WEAPONS, - CHEAT_DISABLE_BANANAS, - CHEAT_BANANAS_REDUCE_SPEED, - CHEAT_NO_LIMIT_TO_BANANAS, - CHEAT_ALL_BALLOONS_ARE_RED, - CHEAT_ALL_BALLOONS_ARE_GREEN, - CHEAT_ALL_BALLOONS_ARE_BLUE, - CHEAT_ALL_BALLOONS_ARE_YELLOW, - CHEAT_ALL_BALLOONS_ARE_RAINBOW, - CHEAT_MAXIMUM_POWER_UP, - CHEAT_TURN_OFF_ZIPPERS, - CHEAT_SELECT_SAME_PLAYER, - CHEAT_FOUR_WHEEL_DRIVER, - CHEAT_TWO_PLAYER_ADVENTURE, - CHEAT_ULTIMATE_AI -}; +s32 gCheatsInCreditsArray[21] = { CHEAT_BIG_CHARACTERS, + CHEAT_SMALL_CHARACTERS, + CHEAT_MUSIC_MENU, + CHEAT_START_WITH_10_BANANAS, + CHEAT_HORN_CHEAT, + CHEAT_DISPLAY_CREDITS, + CHEAT_DISABLE_WEAPONS, + CHEAT_DISABLE_BANANAS, + CHEAT_BANANAS_REDUCE_SPEED, + CHEAT_NO_LIMIT_TO_BANANAS, + CHEAT_ALL_BALLOONS_ARE_RED, + CHEAT_ALL_BALLOONS_ARE_GREEN, + CHEAT_ALL_BALLOONS_ARE_BLUE, + CHEAT_ALL_BALLOONS_ARE_YELLOW, + CHEAT_ALL_BALLOONS_ARE_RAINBOW, + CHEAT_MAXIMUM_POWER_UP, + CHEAT_TURN_OFF_ZIPPERS, + CHEAT_SELECT_SAME_PLAYER, + CHEAT_FOUR_WHEEL_DRIVER, + CHEAT_TWO_PLAYER_ADVENTURE, + CHEAT_ULTIMATE_AI }; #define NUMBER_CHEATS_IN_CREDITS sizeof(gCheatsInCreditsArray) / sizeof(s32) s32 gViewingCreditsFromCheat = FALSE; // Set to 1 if viewing credits from "WHODIDTHIS" cheat MenuElement gCreditsMenuElements[9] = { - { 480, 104, 160, 104, -160, 104, 255, 0, 255, 48, 255, ASSET_FONTS_FUNFONT, 4, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 480, 104, 160, 104, -160, 104, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 480, 104, 160, 104, -160, 104, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 480, 104, 160, 104, -160, 104, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, {{ 0, 0, 0, 0 }} }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, {{ 0, 0, 0, 0 }} }, + { 480, 104, 160, 104, -160, 104, 255, 0, 255, 48, 255, ASSET_FONTS_FUNFONT, 4, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 480, 104, 160, 104, -160, 104, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 480, 104, 160, 104, -160, 104, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 480, 104, 160, 104, -160, 104, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, ASSET_FONTS_BIGFONT, 4, 0, { NULL }, { { 0, 0, 0, 0 } } }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL }, { { 0, 0, 0, 0 } } }, }; Gfx dMenuHudSettings[] = { @@ -1628,52 +2506,34 @@ UNUSED Gfx dMenuHudDrawModes[][2] = { }; // Triangle indices for the wood panels used in multiple menus. -s8 gWoodPanelsIndices[32] = { - 0, 1, 2, 0, 2, 3, 4, 5, - 6, 4, 6, 7, 8, 9, 10, 8, - 10, 11, 12, 13, 14, 12, 14, 15, - 16, 17, 18, 16, 18, 19, 0, 0 -}; +s8 gWoodPanelsIndices[32] = { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, + 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 0, 0 }; // UV coordinate indices the wood panels. -u8 gWoodPanelTexCoords[5][12] = { - { 0, 0, 3, 0, 2, 1, 0, 0, 2, 1, 1, 1 }, - { 2, 1, 3, 0, 3, 3, 2, 1, 3, 3, 2, 2 }, - { 1, 2, 2, 2, 3, 3, 1, 2, 3, 3, 0, 3 }, - { 0, 0, 1, 1, 1, 2, 0, 0, 1, 2, 0, 3 }, - { 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2 } -}; +u8 gWoodPanelTexCoords[5][12] = { { 0, 0, 3, 0, 2, 1, 0, 0, 2, 1, 1, 1 }, + { 2, 1, 3, 0, 3, 3, 2, 1, 3, 3, 2, 2 }, + { 1, 2, 2, 2, 3, 3, 1, 2, 3, 3, 0, 3 }, + { 0, 0, 1, 1, 1, 2, 0, 0, 1, 2, 0, 3 }, + { 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2 } }; // Position offsets for the wood panels. -u16 gWoodPanelVertCoords[10][4] = { - { 0, 0, 256, 0 }, - { 511, 255, 1, 255 }, - { 511, 255, 256, 0 }, - { 256, -256, 511, -255 }, - { 1, -255, 511, -255 }, - { 256, -256, 0, -256 }, - { 0, 0, 1, 255 }, - { 1, -255, 0, -256 }, - { 1, 255, 511, 255 }, - { 511, -255, 1, -255 } -}; +u16 gWoodPanelVertCoords[10][4] = { { 0, 0, 256, 0 }, { 511, 255, 1, 255 }, { 511, 255, 256, 0 }, + { 256, -256, 511, -255 }, { 1, -255, 511, -255 }, { 256, -256, 0, -256 }, + { 0, 0, 1, 255 }, { 1, -255, 0, -256 }, { 1, 255, 511, 255 }, + { 511, -255, 1, -255 } }; // Colour filter, used for the shadows on the side of the panels. s16 gWoodPanelVertColours[5][4] = { { 216, 216, 216, 256 }, // Colour for top part of the panel { 176, 176, 176, 256 }, // Colour for right part of the panel - { 96, 96, 96, 256 }, // Colour for bottom part of the panel + { 96, 96, 96, 256 }, // Colour for bottom part of the panel { 136, 136, 136, 256 }, // Colour for left part of the panel { 256, 256, 256, 256 } // Colour for the center of the panel }; -s32 *gWoodPanelVertices[2] = { - NULL, NULL -}; +s32 *gWoodPanelVertices[2] = { NULL, NULL }; -s32 *gWoodPanelTriangles[2] = { - NULL, NULL -}; +s32 *gWoodPanelTriangles[2] = { NULL, NULL }; s32 D_800E1DB4 = 0; s32 gWoodPanelCount = 0; @@ -1685,9 +2545,7 @@ s32 gWoodPanelTexScaleU = 32; s32 gWoodPanelTexScaleV = 32; // Related to the file select wood panel highlight. -s16 D_800E1DC8[16] = { - 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1 -}; +s16 D_800E1DC8[16] = { 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1 }; // Fade transition from the logo screen to the title screen. FadeTransition gFadeLogoToTitleScreen = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_BLACK, 120, -1); @@ -1701,7 +2559,6 @@ FadeTransition gFadeTitleScreenDemo = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG // So the first save in the pak would be (ADV.A), second save (ADV.B), etc. char *gConPakAdvSavePrefix = " (ADV."; - /*******************************/ /************ .rodata ************/ @@ -1753,89 +2610,91 @@ void load_menu_text(s32 language) { load_asset_to_address(ASSET_MENU_TEXT, gMenuText, start, gMenuTextLangTable[langIndex + 1] - start); // Fill up the lookup table with proper RAM addresses for (i = 0; i < gMenuTextLangTable[0]; i++) { - if ((s32)gMenuText[i] == -1) { + if ((s32) gMenuText[i] == -1) { gMenuText[i] = NULL; } else { - gMenuText[i] = &((u8 *)gMenuText)[(s32)gMenuText[i]]; + gMenuText[i] = &((u8 *) gMenuText)[(s32) gMenuText[i]]; } } - gAudioOutputStrings[0] = gMenuText[ASSET_MENU_TEXT_STEREO]; // "STEREO" - gAudioOutputStrings[1] = gMenuText[ASSET_MENU_TEXT_MONO]; // "MONO" - gAudioOutputStrings[2] = gMenuText[ASSET_MENU_TEXT_HEADPHONES]; // "HEADPHONES" - gAudioMenuStrings[1].unkC = gMenuText[ASSET_MENU_TEXT_SFXVOLUME]; // "SFX VOLUME" - gAudioMenuStrings[2].unkC = gMenuText[ASSET_MENU_TEXT_MUSICVOLUME]; // "MUSIC VOLUME" - gAudioMenuStrings[3].unkC = gMenuText[ASSET_MENU_TEXT_RETURN]; // "RETURN" - gAudioMenuStrings[4].unkC = gMenuText[ASSET_MENU_TEXT_AUDIOOPTIONS]; // "AUDIO OPTIONS" - gAudioMenuStrings[5].unkC = gMenuText[ASSET_MENU_TEXT_AUDIOOPTIONS]; // "AUDIO OPTIONS" - gMusicTestString = gMenuText[ASSET_MENU_TEXT_MUSICTEST]; // "MUSIC TEST 00" - gMagicCodeMenuStrings[0] = gMenuText[ASSET_MENU_TEXT_ENTERCODE]; // "ENTER CODE" - gMagicCodeMenuStrings[1] = gMenuText[ASSET_MENU_TEXT_CLEARALLCODES]; // "CLEAR ALL CODES" - gMagicCodeMenuStrings[2] = gMenuText[ASSET_MENU_TEXT_CODELIST]; // "CODE LIST" - gMagicCodeMenuStrings[3] = gMenuText[ASSET_MENU_TEXT_RETURN]; // "RETURN" - gRaceResultsMenuElements[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_LAPTIMES]; // "LAP TIMES" - gRaceResultsMenuElements[2].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_OVERALLTIME]; // "OVERALL TIME" - gRaceOrderMenuElements[8].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_RACEORDER]; // "RACE ORDER" - gRaceOrderMenuElements[9].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_RACEORDER]; // "RACE ORDER" - gRecordTimesMenuElements[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_RECORDTIMES]; // "RECORD TIMES" - gRecordTimesMenuElements[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_RECORDTIMES]; // "RECORD TIMES" - gRecordTimesMenuElements[2].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_BESTTIME]; // "BEST TIME" - gRecordTimesMenuElements[5].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_BESTLAP]; // "BEST LAP" - gOptionMenuStrings[0] = gMenuText[ASSET_MENU_TEXT_LANGUAGE]; // "ENGLISH" + gAudioOutputStrings[0] = gMenuText[ASSET_MENU_TEXT_STEREO]; // "STEREO" + gAudioOutputStrings[1] = gMenuText[ASSET_MENU_TEXT_MONO]; // "MONO" + gAudioOutputStrings[2] = gMenuText[ASSET_MENU_TEXT_HEADPHONES]; // "HEADPHONES" + gAudioMenuStrings[1].unkC = gMenuText[ASSET_MENU_TEXT_SFXVOLUME]; // "SFX VOLUME" + gAudioMenuStrings[2].unkC = gMenuText[ASSET_MENU_TEXT_MUSICVOLUME]; // "MUSIC VOLUME" + gAudioMenuStrings[3].unkC = gMenuText[ASSET_MENU_TEXT_RETURN]; // "RETURN" + gAudioMenuStrings[4].unkC = gMenuText[ASSET_MENU_TEXT_AUDIOOPTIONS]; // "AUDIO OPTIONS" + gAudioMenuStrings[5].unkC = gMenuText[ASSET_MENU_TEXT_AUDIOOPTIONS]; // "AUDIO OPTIONS" + gMusicTestString = gMenuText[ASSET_MENU_TEXT_MUSICTEST]; // "MUSIC TEST 00" + gMagicCodeMenuStrings[0] = gMenuText[ASSET_MENU_TEXT_ENTERCODE]; // "ENTER CODE" + gMagicCodeMenuStrings[1] = gMenuText[ASSET_MENU_TEXT_CLEARALLCODES]; // "CLEAR ALL CODES" + gMagicCodeMenuStrings[2] = gMenuText[ASSET_MENU_TEXT_CODELIST]; // "CODE LIST" + gMagicCodeMenuStrings[3] = gMenuText[ASSET_MENU_TEXT_RETURN]; // "RETURN" + gRaceResultsMenuElements[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_LAPTIMES]; // "LAP TIMES" + gRaceResultsMenuElements[2].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_OVERALLTIME]; // "OVERALL TIME" + gRaceOrderMenuElements[8].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_RACEORDER]; // "RACE ORDER" + gRaceOrderMenuElements[9].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_RACEORDER]; // "RACE ORDER" + gRecordTimesMenuElements[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_RECORDTIMES]; // "RECORD TIMES" + gRecordTimesMenuElements[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_RECORDTIMES]; // "RECORD TIMES" + gRecordTimesMenuElements[2].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_BESTTIME]; // "BEST TIME" + gRecordTimesMenuElements[5].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_BESTLAP]; // "BEST LAP" + gOptionMenuStrings[0] = gMenuText[ASSET_MENU_TEXT_LANGUAGE]; // "ENGLISH" if (sEepromSettings & 0x2000000) { - gOptionMenuStrings[1] = gMenuText[ASSET_MENU_TEXT_SUBTITLESON]; // "SUBTITLES ON" + gOptionMenuStrings[1] = gMenuText[ASSET_MENU_TEXT_SUBTITLESON]; // "SUBTITLES ON" } else { - gOptionMenuStrings[1] = gMenuText[ASSET_MENU_TEXT_SUBTITLESOFF]; // "SUBTITLES OFF" + gOptionMenuStrings[1] = gMenuText[ASSET_MENU_TEXT_SUBTITLESOFF]; // "SUBTITLES OFF" } - gOptionMenuStrings[2] = gMenuText[ASSET_MENU_TEXT_AUDIOOPTIONS]; // "AUDIO OPTIONS" - gOptionMenuStrings[3] = gMenuText[ASSET_MENU_TEXT_SAVEOPTIONS]; // "SAVE OPTIONS" - gOptionMenuStrings[4] = gMenuText[ASSET_MENU_TEXT_MAGICCODES]; // "MAGIC CODES" - gOptionMenuStrings[5] = gMenuText[ASSET_MENU_TEXT_RETURN]; // "RETURN" - gFilenames[0] = gMenuText[ASSET_MENU_TEXT_GAMEA]; // "GAME A" - gFilenames[1] = gMenuText[ASSET_MENU_TEXT_GAMEB]; // "GAME B" - gFilenames[2] = gMenuText[ASSET_MENU_TEXT_GAMEC]; // "GAME C" - gContPakNotPresentStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" - gContPakNotPresentStrings[1] = gMenuText[ASSET_MENU_TEXT_CONTPAKNOTPRESENT]; // "IS NOT PRESENT." - gContPakNotPresentStrings[3] = gMenuText[ASSET_MENU_TEXT_CANCEL]; // "CANCEL" - gContPakCorruptDataRepairStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" - gContPakCorruptDataRepairStrings[1] = gMenuText[ASSET_MENU_TEXT_CONTPAKHASCORRUPTDATA_0]; // "CONTAINS CORRUPT DATA." - gContPakCorruptDataRepairStrings[3] = gMenuText[ASSET_MENU_TEXT_CONTPAKHASCORRUPTDATA_1]; // "ATTEMPT TO REPAIR" - gContPakCorruptDataRepairStrings[4] = gMenuText[ASSET_MENU_TEXT_CANCEL]; // "CANCEL" - gContPakDamagedStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" - gContPakDamagedStrings[1] = gMenuText[ASSET_MENU_TEXT_CONTPAKISDAMAGED_0]; // "IRREPARABLY DAMAGED." - gContPakDamagedStrings[3] = gMenuText[ASSET_MENU_TEXT_CONTPAKISDAMAGED_1]; // "REFORMAT PAK" - gContPakDamagedStrings[4] = gMenuText[ASSET_MENU_TEXT_CANCEL]; // "CANCEL" - gContPakFullStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" - gContPakFullStrings[1] = gMenuText[ASSET_MENU_TEXT_CONTPAKISFULL]; // "FULL." - gContPakFullStrings[3] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // "CONTINUE" - gContPakDiffContStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" - gContPakDiffContStrings[1] = gMenuText[ASSET_MENU_TEXT_CONTPAKDIFFERENT_0]; // "DIFFERENT CONTROLLER" - gContPakDiffContStrings[2] = gMenuText[ASSET_MENU_TEXT_CONTPAKDIFFERENT_1]; // "PAK IS INSERTED." - gContPakDiffContStrings[4] = gMenuText[ASSET_MENU_TEXT_CANCEL]; // "CANCEL" - gContPakNoRoomForGhostsStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" - gContPakNoRoomForGhostsStrings[1] = gMenuText[ASSET_MENU_TEXT_CANNOTSTOREANYMOREGHOSTS_0]; // "CANNOT STORE ANY" - gContPakNoRoomForGhostsStrings[2] = gMenuText[ASSET_MENU_TEXT_CANNOTSTOREANYMOREGHOSTS_1]; // "MORE GHOSTS." - gContPakNoRoomForGhostsStrings[4] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // "CONTINUE" - gContPakCorruptDataStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" - gContPakCorruptDataStrings[1] = gMenuText[ASSET_MENU_TEXT_CORRUPTDATA_0]; // "CORRUPT DATA." - gContPakCorruptDataStrings[3] = gMenuText[ASSET_MENU_TEXT_TRYAGAIN]; // "TRY AGAIN" - gContPakCorruptDataStrings[4] = gMenuText[ASSET_MENU_TEXT_CANCEL]; // "CANCEL" - gContPakRumbleDetectedStrings[0] = gMenuText[ASSET_MENU_TEXT_RUMBLEPAKDETECTED_0]; // "Rumble Pak Detected" - gContPakRumbleDetectedStrings[1] = gMenuText[ASSET_MENU_TEXT_RUMBLEPAKDETECTED_1]; // "Insert any Controller Paks" - gContPakRumbleDetectedStrings[2] = gMenuText[ASSET_MENU_TEXT_RUMBLEPAKDETECTED_2]; // "you wish to use now!" - gContPakRumbleDetectedStrings[4] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // "CONTINUE" - gContPakSwitchToRumbleStrings[0] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_0]; // "If you wish to use any" - gContPakSwitchToRumbleStrings[1] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_1]; // "Rumble Paks then please" - gContPakSwitchToRumbleStrings[2] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_2]; // "insert them now." - gContPakSwitchToRumbleStrings[4] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // "CONTINUE" - gContPakNeed2ndAdvStrings[0] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_0]; // "SORRY, BUT YOU" - gContPakNeed2ndAdvStrings[1] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_1]; // "CAN'T LOAD GAMES" - gContPakNeed2ndAdvStrings[2] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_2]; // "FOR THE SECOND" - gContPakNeed2ndAdvStrings[3] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_3]; // "ADVENTURE UNTIL" - gContPakNeed2ndAdvStrings[4] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_4]; // "YOU HAVE COMPLETED" - gContPakNeed2ndAdvStrings[5] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_5]; // "THE FIRST." - gContPakNeed2ndAdvStrings[7] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // "CONTINUE" - gTitleMenuStrings[0] = gMenuText[ASSET_MENU_TEXT_START]; // "START" - gTitleMenuStrings[1] = gMenuText[ASSET_MENU_TEXT_OPTIONS]; // "OPTIONS" + gOptionMenuStrings[2] = gMenuText[ASSET_MENU_TEXT_AUDIOOPTIONS]; // "AUDIO OPTIONS" + gOptionMenuStrings[3] = gMenuText[ASSET_MENU_TEXT_SAVEOPTIONS]; // "SAVE OPTIONS" + gOptionMenuStrings[4] = gMenuText[ASSET_MENU_TEXT_MAGICCODES]; // "MAGIC CODES" + gOptionMenuStrings[5] = gMenuText[ASSET_MENU_TEXT_RETURN]; // "RETURN" + gFilenames[0] = gMenuText[ASSET_MENU_TEXT_GAMEA]; // "GAME A" + gFilenames[1] = gMenuText[ASSET_MENU_TEXT_GAMEB]; // "GAME B" + gFilenames[2] = gMenuText[ASSET_MENU_TEXT_GAMEC]; // "GAME C" + gContPakNotPresentStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" + gContPakNotPresentStrings[1] = gMenuText[ASSET_MENU_TEXT_CONTPAKNOTPRESENT]; // "IS NOT PRESENT." + gContPakNotPresentStrings[3] = gMenuText[ASSET_MENU_TEXT_CANCEL]; // "CANCEL" + gContPakCorruptDataRepairStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" + gContPakCorruptDataRepairStrings[1] = + gMenuText[ASSET_MENU_TEXT_CONTPAKHASCORRUPTDATA_0]; // "CONTAINS CORRUPT DATA." + gContPakCorruptDataRepairStrings[3] = gMenuText[ASSET_MENU_TEXT_CONTPAKHASCORRUPTDATA_1]; // "ATTEMPT TO REPAIR" + gContPakCorruptDataRepairStrings[4] = gMenuText[ASSET_MENU_TEXT_CANCEL]; // "CANCEL" + gContPakDamagedStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" + gContPakDamagedStrings[1] = gMenuText[ASSET_MENU_TEXT_CONTPAKISDAMAGED_0]; // "IRREPARABLY DAMAGED." + gContPakDamagedStrings[3] = gMenuText[ASSET_MENU_TEXT_CONTPAKISDAMAGED_1]; // "REFORMAT PAK" + gContPakDamagedStrings[4] = gMenuText[ASSET_MENU_TEXT_CANCEL]; // "CANCEL" + gContPakFullStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" + gContPakFullStrings[1] = gMenuText[ASSET_MENU_TEXT_CONTPAKISFULL]; // "FULL." + gContPakFullStrings[3] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // "CONTINUE" + gContPakDiffContStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" + gContPakDiffContStrings[1] = gMenuText[ASSET_MENU_TEXT_CONTPAKDIFFERENT_0]; // "DIFFERENT CONTROLLER" + gContPakDiffContStrings[2] = gMenuText[ASSET_MENU_TEXT_CONTPAKDIFFERENT_1]; // "PAK IS INSERTED." + gContPakDiffContStrings[4] = gMenuText[ASSET_MENU_TEXT_CANCEL]; // "CANCEL" + gContPakNoRoomForGhostsStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" + gContPakNoRoomForGhostsStrings[1] = gMenuText[ASSET_MENU_TEXT_CANNOTSTOREANYMOREGHOSTS_0]; // "CANNOT STORE ANY" + gContPakNoRoomForGhostsStrings[2] = gMenuText[ASSET_MENU_TEXT_CANNOTSTOREANYMOREGHOSTS_1]; // "MORE GHOSTS." + gContPakNoRoomForGhostsStrings[4] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // "CONTINUE" + gContPakCorruptDataStrings[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKX]; // "CONTROLLER PAK ~" + gContPakCorruptDataStrings[1] = gMenuText[ASSET_MENU_TEXT_CORRUPTDATA_0]; // "CORRUPT DATA." + gContPakCorruptDataStrings[3] = gMenuText[ASSET_MENU_TEXT_TRYAGAIN]; // "TRY AGAIN" + gContPakCorruptDataStrings[4] = gMenuText[ASSET_MENU_TEXT_CANCEL]; // "CANCEL" + gContPakRumbleDetectedStrings[0] = gMenuText[ASSET_MENU_TEXT_RUMBLEPAKDETECTED_0]; // "Rumble Pak Detected" + gContPakRumbleDetectedStrings[1] = + gMenuText[ASSET_MENU_TEXT_RUMBLEPAKDETECTED_1]; // "Insert any Controller Paks" + gContPakRumbleDetectedStrings[2] = gMenuText[ASSET_MENU_TEXT_RUMBLEPAKDETECTED_2]; // "you wish to use now!" + gContPakRumbleDetectedStrings[4] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // "CONTINUE" + gContPakSwitchToRumbleStrings[0] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_0]; // "If you wish to use any" + gContPakSwitchToRumbleStrings[1] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_1]; // "Rumble Paks then please" + gContPakSwitchToRumbleStrings[2] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_2]; // "insert them now." + gContPakSwitchToRumbleStrings[4] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // "CONTINUE" + gContPakNeed2ndAdvStrings[0] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_0]; // "SORRY, BUT YOU" + gContPakNeed2ndAdvStrings[1] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_1]; // "CAN'T LOAD GAMES" + gContPakNeed2ndAdvStrings[2] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_2]; // "FOR THE SECOND" + gContPakNeed2ndAdvStrings[3] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_3]; // "ADVENTURE UNTIL" + gContPakNeed2ndAdvStrings[4] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_4]; // "YOU HAVE COMPLETED" + gContPakNeed2ndAdvStrings[5] = gMenuText[ASSET_MENU_TEXT_ADVTWOLOADERROR_5]; // "THE FIRST." + gContPakNeed2ndAdvStrings[7] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // "CONTINUE" + gTitleMenuStrings[0] = gMenuText[ASSET_MENU_TEXT_START]; // "START" + gTitleMenuStrings[1] = gMenuText[ASSET_MENU_TEXT_OPTIONS]; // "OPTIONS" gGameSelectTextElemsNoAdv2[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_GAMESELECT]; // "GAME SELECT" gGameSelectTextElemsNoAdv2[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_GAMESELECT]; // "GAME SELECT" gGameSelectTextElemsNoAdv2[3].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_ADVENTURE]; // "ADVENTURE" @@ -1845,13 +2704,13 @@ void load_menu_text(s32 language) { gGameSelectTextElemsWithAdv2[3].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_ADVENTURE]; // "ADVENTURE" gGameSelectTextElemsWithAdv2[5].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_ADVENTURETWO]; // "ADVENTURE TWO" gGameSelectTextElemsWithAdv2[7].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_TRACKS]; // "TRACKS" - sBadControllerPakMenuText[0] = gMenuText[ASSET_MENU_TEXT_BADCONTPAK]; // "BAD CONTROLLER PAK" - sControllerPakFullMenuText[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKFULL]; // "CONTROLLER PAK FULL" - sNoControllerPakMenuText[0] = gMenuText[ASSET_MENU_TEXT_NOCONTPAK]; // 'NO CONTROLLER PAK" + sBadControllerPakMenuText[0] = gMenuText[ASSET_MENU_TEXT_BADCONTPAK]; // "BAD CONTROLLER PAK" + sControllerPakFullMenuText[0] = gMenuText[ASSET_MENU_TEXT_CONTPAKFULL]; // "CONTROLLER PAK FULL" + sNoControllerPakMenuText[0] = gMenuText[ASSET_MENU_TEXT_NOCONTPAK]; // 'NO CONTROLLER PAK" sCorruptDataMenuText[4] = NULL; sCorruptDataMenuText[5] = NULL; - sCorruptDataMenuText[0] = gMenuText[ASSET_MENU_TEXT_CORRUPTDATA_0]; // "CORRUPT DATA." - //Three messages + sCorruptDataMenuText[0] = gMenuText[ASSET_MENU_TEXT_CORRUPTDATA_0]; // "CORRUPT DATA." + // Three messages //"If you wish to change" / "Controller Pak or Rumble Pak," / "please do so now." for (i = 0; i < 2; i++) { sBadControllerPakMenuText[i + 1] = gMenuText[177 + i]; @@ -1863,15 +2722,15 @@ void load_menu_text(s32 language) { while (sCorruptDataMenuText[j] != NULL) { j++; } - sCorruptDataMenuText[j] = gMenuText[ASSET_MENU_TEXT_CORRUPTDATA_1]; // "TRY AGAIN!" - sInsertControllerPakMenuText[0] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_3]; // "If you wish to use" - sInsertControllerPakMenuText[1] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_4]; // "the Controller Pak" - sInsertControllerPakMenuText[2] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_6]; // "insert it now!" - sInsertRumblePakMenuText[0] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_3]; // "If you wish to use" - sInsertRumblePakMenuText[1] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_5]; // "the Rumble Pak" - sInsertRumblePakMenuText[2] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_6]; // "insert it now!" - gCautionMenuTextElements[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // "CAUTION" - gCautionMenuTextElements[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // "CAUTION" + sCorruptDataMenuText[j] = gMenuText[ASSET_MENU_TEXT_CORRUPTDATA_1]; // "TRY AGAIN!" + sInsertControllerPakMenuText[0] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_3]; // "If you wish to use" + sInsertControllerPakMenuText[1] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_4]; // "the Controller Pak" + sInsertControllerPakMenuText[2] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_6]; // "insert it now!" + sInsertRumblePakMenuText[0] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_3]; // "If you wish to use" + sInsertRumblePakMenuText[1] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_5]; // "the Rumble Pak" + sInsertRumblePakMenuText[2] = gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_6]; // "insert it now!" + gCautionMenuTextElements[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // "CAUTION" + gCautionMenuTextElements[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // "CAUTION" for (i = 2; i < 13; i++) { // Caution message lines starting from gMenuText[166] gCautionMenuTextElements[i].unk14_a.asciiText = gMenuText[166 + (i - 2)]; @@ -1902,21 +2761,22 @@ void func_80080518(f32 arg0, f32 arg1) { gWoodPanelTexScaleV = (s32) (arg1 * 32.0f); } -//https://decomp.me/scratch/W0adv +// https://decomp.me/scratch/W0adv #ifdef NON_EQUIVALENT -void func_80080580(Gfx** dlist, s32 startX, s32 startY, s32 width, s32 height, s32 borderWidth, s32 borderHeight, s32 colour, TextureHeader *tex) { +void func_80080580(Gfx **dlist, s32 startX, s32 startY, s32 width, s32 height, s32 borderWidth, s32 borderHeight, + s32 colour, TextureHeader *tex) { s32 uVals[4]; s32 vVals[4]; - Vertex* verts; - Triangle* tris; + Vertex *verts; + Triangle *tris; s32 j; s32 i; s32 texEnabled; //((unk80080BC8*)((u8*)D_80126C2C[gWoodPanelCount] + (D_800E1DB4 * 4)))->texture = tex; - ((unk80080BC8*)((u8*)D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)))->texture = tex; + ((unk80080BC8 *) ((u8 *) D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)))->texture = tex; //(&(*D_80126C2C)[gWoodPanelCount] + (D_800E1DB4 * 4))->texture = tex; - //D_80126C2C[gWoodPanelCount][D_800E1DB4].texture = tex; + // D_80126C2C[gWoodPanelCount][D_800E1DB4].texture = tex; if (tex != NULL) { uVals[0] = 0; vVals[0] = 0; @@ -1926,25 +2786,25 @@ void func_80080580(Gfx** dlist, s32 startX, s32 startY, s32 width, s32 height, s vVals[1] = gWoodPanelTexScaleV * borderHeight; vVals[2] = (height - borderHeight) * gWoodPanelTexScaleV; vVals[3] = gWoodPanelTexScaleV * height; - tris = ((unk80080BC8*)((u8*)D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)))->triangles; + tris = ((unk80080BC8 *) ((u8 *) D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)))->triangles; for (i = 0; i < 5; i++) { - tris[i*2].uv0.u = uVals[gWoodPanelTexCoords[i][0]]; - tris[i*2].uv0.v = vVals[gWoodPanelTexCoords[i][1]]; - tris[i*2].uv1.u = uVals[gWoodPanelTexCoords[i][2]]; - tris[i*2].uv1.v = vVals[gWoodPanelTexCoords[i][3]]; - tris[i*2].uv2.u = uVals[gWoodPanelTexCoords[i][4]]; - tris[i*2].uv2.v = vVals[gWoodPanelTexCoords[i][5]]; - tris[i*2+1].uv0.u = uVals[gWoodPanelTexCoords[i][6]]; - tris[i*2+1].uv0.v = vVals[gWoodPanelTexCoords[i][7]]; - tris[i*2+1].uv1.u = uVals[gWoodPanelTexCoords[i][8]]; - tris[i*2+1].uv1.v = vVals[gWoodPanelTexCoords[i][9]]; - tris[i*2+1].uv2.u = uVals[gWoodPanelTexCoords[i][10]]; - tris[i*2+1].uv2.v = vVals[gWoodPanelTexCoords[i][11]]; + tris[i * 2].uv0.u = uVals[gWoodPanelTexCoords[i][0]]; + tris[i * 2].uv0.v = vVals[gWoodPanelTexCoords[i][1]]; + tris[i * 2].uv1.u = uVals[gWoodPanelTexCoords[i][2]]; + tris[i * 2].uv1.v = vVals[gWoodPanelTexCoords[i][3]]; + tris[i * 2].uv2.u = uVals[gWoodPanelTexCoords[i][4]]; + tris[i * 2].uv2.v = vVals[gWoodPanelTexCoords[i][5]]; + tris[i * 2 + 1].uv0.u = uVals[gWoodPanelTexCoords[i][6]]; + tris[i * 2 + 1].uv0.v = vVals[gWoodPanelTexCoords[i][7]]; + tris[i * 2 + 1].uv1.u = uVals[gWoodPanelTexCoords[i][8]]; + tris[i * 2 + 1].uv1.v = vVals[gWoodPanelTexCoords[i][9]]; + tris[i * 2 + 1].uv2.u = uVals[gWoodPanelTexCoords[i][10]]; + tris[i * 2 + 1].uv2.v = vVals[gWoodPanelTexCoords[i][11]]; } } - verts = ((unk80080BC8*)((u8*)D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)))->vertices; + verts = ((unk80080BC8 *) ((u8 *) D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)))->vertices; for (i = 0; i < 5; i++) { - for(j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) { verts[j].x = startX; verts[j].y = startY; verts[j].x += (gWoodPanelVertCoords[j][0] * width); @@ -1959,8 +2819,8 @@ void func_80080580(Gfx** dlist, s32 startX, s32 startY, s32 width, s32 height, s } } if (dlist != NULL) { - ((unk80080BC8*)((u8*)D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)))->unk18 = 1; - gSPDisplayList((*dlist)++, &dMenuHudSettings); + ((unk80080BC8 *) ((u8 *) D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)))->unk18 = 1; + gSPDisplayList((*dlist)++, &dMenuHudSettings); if (tex != NULL) { texEnabled = TRUE; gDkrDmaDisplayList((*dlist)++, OS_K0_TO_PHYSICAL(&dMenuHudSettings[8]), 2); @@ -1973,20 +2833,25 @@ void func_80080580(Gfx** dlist, s32 startX, s32 startY, s32 width, s32 height, s /* temp_v0_6 = *dlist; *dlist = temp_v0_6 + 8; - temp_v0_6->words.w0 = (((((*(D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)) + 0x80000000) & 6) | 0x98) & 0xFF) << 0x10) | 0x04000000 | 0x170; - temp_v0_6->words.w1 = *(D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)) + 0x80000000; + temp_v0_6->words.w0 = (((((*(D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4)) + 0x80000000) & 6) | 0x98) + & 0xFF) << 0x10) | 0x04000000 | 0x170; temp_v0_6->words.w1 = *(D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 + * 4)) + 0x80000000; */ - gSPVertexDKR((*dlist)++, OS_K0_TO_PHYSICAL(((unk80080BC8*)((u8*)D_80126C2C + (i * 32) + (D_800E1DB4 * 4)))->vertices), 20, 0); - /* + gSPVertexDKR((*dlist)++, + OS_K0_TO_PHYSICAL(((unk80080BC8 *) ((u8 *) D_80126C2C + (i * 32) + (D_800E1DB4 * 4)))->vertices), + 20, 0); + /* temp_v0_7 = *dlist; *dlist = temp_v0_7 + 8; temp_v0_7->words.w0 = (((texEnabled | 0x90) & 0xFF) << 0x10) | 0x05000000 | 0xA0; temp_v0_7->words.w1 = (D_80126C2C + (gWoodPanelCount << 5) + (D_800E1DB4 * 4))->unk8 + 0x80000000; */ - gSPPolygon((*dlist)++, OS_K0_TO_PHYSICAL(((unk80080BC8*)((u8*)D_80126C2C + (i * 32) + (D_800E1DB4 * 4)))->triangles), 10, texEnabled); + gSPPolygon((*dlist)++, + OS_K0_TO_PHYSICAL(((unk80080BC8 *) ((u8 *) D_80126C2C + (i * 32) + (D_800E1DB4 * 4)))->triangles), + 10, texEnabled); reset_render_settings(dlist); } else { - ((unk80080BC8*)((u8*)D_80126C2C + (gWoodPanelCount * 32) + (D_800E1DB4 * 4)))->unk18 = 0; + ((unk80080BC8 *) ((u8 *) D_80126C2C + (gWoodPanelCount * 32) + (D_800E1DB4 * 4)))->unk18 = 0; } gWoodPanelCount++; } @@ -1994,24 +2859,24 @@ void func_80080580(Gfx** dlist, s32 startX, s32 startY, s32 width, s32 height, s GLOBAL_ASM("asm/non_matchings/menu/func_80080580.s") #endif -//https://decomp.me/scratch/lS3f5 +// https://decomp.me/scratch/lS3f5 #ifdef NON_EQUIVALENT -void func_80080BC8(Gfx** dlist) { +void func_80080BC8(Gfx **dlist) { s16 temp_a1; s32 i; s32 var_t0; TextureHeader *tex; TextureHeader *lastTex; - - gSPDisplayList((*dlist)++, &dMenuHudSettings); + + gSPDisplayList((*dlist)++, &dMenuHudSettings); var_t0 = -1; lastTex = NULL; - + for (i = 0; i < gWoodPanelCount; i++) { //((unk80080BC8*)((u8*)D_80126C2C + (i << 5) + (D_800E1DB4 * 4)))->texture if (!D_80126C2C[i][D_800E1DB4].unk18) { tex = D_80126C2C[i][D_800E1DB4].texture; - if (tex != NULL) { + if (tex != NULL) { if (var_t0 != 1) { var_t0 = 1; gDkrDmaDisplayList((*dlist)++, OS_K0_TO_PHYSICAL(&dMenuHudSettings[8]), 2); @@ -2039,10 +2904,10 @@ GLOBAL_ASM("asm/non_matchings/menu/func_80080BC8.s") void func_80080E6C(void) { gWoodPanelCount = 0; - D_800E1DB4 = (s32)(1 - D_800E1DB4); + D_800E1DB4 = (s32) (1 - D_800E1DB4); } -//https://decomp.me/scratch/IZ1Gq +// https://decomp.me/scratch/IZ1Gq GLOBAL_ASM("asm/non_matchings/menu/func_80080E90.s") // init_save_data @@ -2060,19 +2925,19 @@ void func_80081218(void) { sp28 = numLevels * 4; gSavefileData[0] = allocate_from_main_pool_safe(sp20 * 4, COLOUR_TAG_WHITE); gSavefileData[0] = gSavefileData[0]; - gSavefileData[0]->courseFlagsPtr = (u8 *)gSavefileData[0] + sizeof(Settings); - gSavefileData[0]->balloonsPtr = (u8 *)gSavefileData[0]->courseFlagsPtr + sp28; - gSavefileData[1] = (u8 *)gSavefileData[0] + sp20; - gSavefileData[1]->courseFlagsPtr = (u8 *)gSavefileData[1] + sizeof(Settings); - gSavefileData[1]->balloonsPtr = (u8 *)gSavefileData[1]->courseFlagsPtr + sp28; - gSavefileData[2] = (u8 *)gSavefileData[1] + sp20; - gSavefileData[2]->courseFlagsPtr = (u8 *)gSavefileData[2] + sizeof(Settings); - gSavefileData[2]->balloonsPtr = (u8 *)gSavefileData[2]->courseFlagsPtr + sp28; - gSavefileData[3] = (u8 *)gSavefileData[2] + sp20; - gSavefileData[3]->courseFlagsPtr = (u8 *)gSavefileData[3] + sizeof(Settings); - gSavefileData[3]->balloonsPtr = (u8 *)gSavefileData[3]->courseFlagsPtr + sp28; + gSavefileData[0]->courseFlagsPtr = (u8 *) gSavefileData[0] + sizeof(Settings); + gSavefileData[0]->balloonsPtr = (u8 *) gSavefileData[0]->courseFlagsPtr + sp28; + gSavefileData[1] = (u8 *) gSavefileData[0] + sp20; + gSavefileData[1]->courseFlagsPtr = (u8 *) gSavefileData[1] + sizeof(Settings); + gSavefileData[1]->balloonsPtr = (u8 *) gSavefileData[1]->courseFlagsPtr + sp28; + gSavefileData[2] = (u8 *) gSavefileData[1] + sp20; + gSavefileData[2]->courseFlagsPtr = (u8 *) gSavefileData[2] + sizeof(Settings); + gSavefileData[2]->balloonsPtr = (u8 *) gSavefileData[2]->courseFlagsPtr + sp28; + gSavefileData[3] = (u8 *) gSavefileData[2] + sp20; + gSavefileData[3]->courseFlagsPtr = (u8 *) gSavefileData[3] + sizeof(Settings); + gSavefileData[3]->balloonsPtr = (u8 *) gSavefileData[3]->courseFlagsPtr + sp28; gCheatsAssetData = get_misc_asset(ASSET_MISC_MAGIC_CODES); - gNumberOfCheats = (s32)(*gCheatsAssetData); + gNumberOfCheats = (s32) (*gCheatsAssetData); gMenuText = allocate_from_main_pool_safe(1024 * sizeof(char *), COLOUR_TAG_WHITE); load_menu_text(LANGUAGE_ENGLISH); for (i = 0; i < 128; i++) { @@ -2085,7 +2950,7 @@ GLOBAL_ASM("asm/non_matchings/menu/func_80081218.s") /** * Sets the title reveal timer to zero when the menu boots, meaning it may not automatically appear. -*/ + */ void reset_title_logo_scale(void) { gResetTitleScale = TRUE; } @@ -2104,8 +2969,11 @@ void menu_init(u32 menuId) { sUnused_801263C8 = 0; sUnused_80126828 = 0; - //Needs to be one line + // clang-format off + // Needs to be one line for (i = 0; i < ARRAY_COUNT(D_80126808); i++) { D_80126808[i] = 0; } + // clang-format on + music_stop(); switch (gCurrentMenuId) { case MENU_LOGOS: @@ -2175,7 +3043,8 @@ void menu_init(u32 menuId) { /** * Runs every frame. Calls the loop function of the current menu id */ -s32 menu_loop(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, TriangleList **currHudTris, s32 updateRate) { +s32 menu_loop(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, TriangleList **currHudTris, + s32 updateRate) { s32 ret; sMenuCurrDisplayList = *currDisplayList; @@ -2328,9 +3197,9 @@ void show_timestamp(s32 frameCount, s32 xPos, s32 yPos, u8 red, u8 green, u8 blu func_80068508(FALSE); sprite_opaque(TRUE); - sMenuGuiColourR = (u8)255; - sMenuGuiColourG = (u8)255; - sMenuGuiColourB = (u8)255; + sMenuGuiColourR = (u8) 255; + sMenuGuiColourG = (u8) 255; + sMenuGuiColourB = (u8) 255; } void func_80081C04(s32 number, s32 x, s32 y, s32 r, s32 g, s32 b, s32 a, UNUSED s32 font, s32 alignment) { @@ -2345,7 +3214,7 @@ void func_80081C04(s32 number, s32 x, s32 y, s32 r, s32 g, s32 b, s32 a, UNUSED strLen = 0; powerOfTen = 1000000000; hasProcessedDigit = FALSE; - + while (powerOfTen >= 10) { if (number >= powerOfTen) { curDigit = number / powerOfTen; @@ -2492,11 +3361,11 @@ void draw_menu_elements(s32 flags, MenuElement *elems, f32 scale) { set_ortho_matrix_view(&sMenuCurrDisplayList, &sMenuCurrHudMat); while (elems->unk14_a.element != NULL) { - if ((elems->unk14_a.element != &D_80126850)) { //fakematch - if (flags == ((elems->unk14_a.element != (&D_80126850)) * 0)) { //fakematch + if ((elems->unk14_a.element != &D_80126850)) { // fakematch + if (flags == ((elems->unk14_a.element != (&D_80126850)) * 0)) { // fakematch xPos = ((s32) ((elems->center - elems->left) * scale)) + elems->left; yPos = ((s32) ((elems->middle - elems->top) * scale)) + elems->top; - } else if((flags == 1)) { + } else if ((flags == 1)) { xPos = elems->center; yPos = elems->middle; } else { @@ -2504,15 +3373,15 @@ void draw_menu_elements(s32 flags, MenuElement *elems, f32 scale) { yPos = ((s32) ((elems->bottom - elems->middle) * scale)) + elems->middle; } switch (elems->elementType) { - case 0: //ascii text + case 0: // ascii text set_text_background_colour( - elems->details.background.backgroundRed, - elems->details.background.backgroundGreen, - elems->details.background.backgroundBlue, - elems->details.background.backgroundAlpha); - set_text_colour(elems->filterRed, elems->filterGreen, elems->filterBlue, elems->filterBlendFactor, elems->opacity); + elems->details.background.backgroundRed, elems->details.background.backgroundGreen, + elems->details.background.backgroundBlue, elems->details.background.backgroundAlpha); + set_text_colour(elems->filterRed, elems->filterGreen, elems->filterBlue, elems->filterBlendFactor, + elems->opacity); set_text_font(elems->textFont); - draw_text(&sMenuCurrDisplayList, xPos, yPos + gDrawElementsRegionYOffset, elems->unk14_a.asciiText, elems->textAlignFlags); + draw_text(&sMenuCurrDisplayList, xPos, yPos + gDrawElementsRegionYOffset, elems->unk14_a.asciiText, + elems->textAlignFlags); break; case 1: if (shouldResetRenderSettings) { @@ -2520,52 +3389,30 @@ void draw_menu_elements(s32 flags, MenuElement *elems, f32 scale) { reset_render_settings(&sMenuCurrDisplayList); } sMenuGuiOpacity = elems->opacity; - show_timestamp( - *elems->unk14_a.numberU16, - xPos - 160, - (-yPos - gDrawElementsYOffset) + 120, - elems->filterRed, - elems->filterGreen, - elems->filterBlue, - elems->textFont); + show_timestamp(*elems->unk14_a.numberU16, xPos - 160, (-yPos - gDrawElementsYOffset) + 120, + elems->filterRed, elems->filterGreen, elems->filterBlue, elems->textFont); break; - case 2: //Number + case 2: // Number if (shouldResetRenderSettings) { shouldResetRenderSettings = FALSE; reset_render_settings(&sMenuCurrDisplayList); } - func_80081C04( - *elems->unk14_a.number, - xPos - 160, - (-yPos - gDrawElementsYOffset) + 120, - elems->filterRed, - elems->filterGreen, - elems->filterBlue, - elems->opacity, - elems->textFont, - elems->textAlignFlags); + func_80081C04(*elems->unk14_a.number, xPos - 160, (-yPos - gDrawElementsYOffset) + 120, + elems->filterRed, elems->filterGreen, elems->filterBlue, elems->opacity, + elems->textFont, elems->textAlignFlags); break; case 3: - render_textured_rectangle( - &sMenuCurrDisplayList, - elems->unk14_a.drawTexture, - xPos, - yPos + gDrawElementsRegionYOffset, - elems->filterRed, - elems->filterGreen, - elems->filterBlue, - elems->opacity); + render_textured_rectangle(&sMenuCurrDisplayList, elems->unk14_a.drawTexture, xPos, + yPos + gDrawElementsRegionYOffset, elems->filterRed, elems->filterGreen, + elems->filterBlue, elems->opacity); shouldResetRenderSettings = TRUE; break; case 4: render_texture_rectangle_scaled( - &sMenuCurrDisplayList, - elems->unk14_a.element, - xPos, - yPos + gDrawElementsRegionYOffset, - elems->details.texture.width / 256.0f, - elems->details.texture.height / 256.0f, - (elems->filterRed << 24) | (elems->filterGreen << 16) | (elems->filterBlue << 8) | elems->opacity, + &sMenuCurrDisplayList, elems->unk14_a.element, xPos, yPos + gDrawElementsRegionYOffset, + elems->details.texture.width / 256.0f, elems->details.texture.height / 256.0f, + (elems->filterRed << 24) | (elems->filterGreen << 16) | (elems->filterBlue << 8) | + elems->opacity, elems->textAlignFlags); shouldResetRenderSettings = TRUE; break; @@ -2593,30 +3440,18 @@ void draw_menu_elements(s32 flags, MenuElement *elems, f32 scale) { sprite_opaque(TRUE); break; case 6: - func_80080E90( - &sMenuCurrDisplayList, - xPos, - yPos + gDrawElementsYOffset, - elems->details.texture.width, - elems->details.texture.height, - elems->details.texture.borderWidth, - elems->details.texture.borderHeight, - elems->filterRed, - elems->filterGreen, - elems->filterBlue, - elems->opacity); + func_80080E90(&sMenuCurrDisplayList, xPos, yPos + gDrawElementsYOffset, + elems->details.texture.width, elems->details.texture.height, + elems->details.texture.borderWidth, elems->details.texture.borderHeight, + elems->filterRed, elems->filterGreen, elems->filterBlue, elems->opacity); break; - case 7: //Texture - func_80080580( - &sMenuCurrDisplayList, - xPos, - yPos + gDrawElementsYOffset, - elems->details.texture.width, - elems->details.texture.height, - elems->details.texture.borderWidth, - elems->details.texture.borderHeight, - (elems->filterRed << 24) | (elems->filterGreen << 16) | (elems->filterBlue << 8) | elems->opacity, - elems->unk14_a.element); + case 7: // Texture + func_80080580(&sMenuCurrDisplayList, xPos, yPos + gDrawElementsYOffset, + elems->details.texture.width, elems->details.texture.height, + elems->details.texture.borderWidth, elems->details.texture.borderHeight, + (elems->filterRed << 24) | (elems->filterGreen << 16) | (elems->filterBlue << 8) | + elems->opacity, + elems->unk14_a.element); break; } } @@ -2693,7 +3528,7 @@ void menu_logos_screen_init(void) { viewport_menu_set(0, 0, 40, SCREEN_WIDTH, SCREEN_HEIGHT - 44); set_viewport_properties(0, VIEWPORT_AUTO, VIEWPORT_AUTO, SCREEN_WIDTH, SCREEN_HEIGHT); } - copy_viewports_to_stack(); //Init viewports + copy_viewports_to_stack(); // Init viewports camEnableUserView(0, 1); } @@ -2726,7 +3561,7 @@ s32 menu_logo_screen_loop(s32 updateRate) { init_title_screen_variables(); menu_init(MENU_TITLE); } -// This uses doubles instead of floats for precision in the counting. + // This uses doubles instead of floats for precision in the counting. if (sBootScreenTimer < 8.5) { set_text_font(ASSET_FONTS_SMALLFONT); set_text_background_colour(0, 0, 0, 0); @@ -2802,19 +3637,25 @@ void func_80083098(f32 arg0) { set_text_background_colour(0, 0, 0, 0); i = 0; while (i < gTitleCinematicTextColourCount) { - // set_text_colour(gTitleCinematicTextColours[D_80126878[i].colourIndex].red, gTitleCinematicTextColours[D_80126878[i].colourIndex].green, gTitleCinematicTextColours[D_80126878[i].colourIndex].blue, gTitleCinematicTextColours[D_80126878[i].colourIndex].alpha, gTitleCinematicTextColours[D_80126878[i].colourIndex].opacity); + // set_text_colour(gTitleCinematicTextColours[D_80126878[i].colourIndex].red, + // gTitleCinematicTextColours[D_80126878[i].colourIndex].green, + // gTitleCinematicTextColours[D_80126878[i].colourIndex].blue, + // gTitleCinematicTextColours[D_80126878[i].colourIndex].alpha, + // gTitleCinematicTextColours[D_80126878[i].colourIndex].opacity); j = D_80126878[i].colourIndex; // This seems super fake, but I can't do any better. - set_text_colour(gTitleCinematicTextColours[j].red, gTitleCinematicTextColours[j].green, gTitleCinematicTextColours[j].blue, gTitleCinematicTextColours[j].alpha, gTitleCinematicTextColours[j].opacity); + set_text_colour(gTitleCinematicTextColours[j].red, gTitleCinematicTextColours[j].green, + gTitleCinematicTextColours[j].blue, gTitleCinematicTextColours[j].alpha, + gTitleCinematicTextColours[j].opacity); draw_text(&sMenuCurrDisplayList, D_80126878[i].x, D_80126878[i].y, D_80126878[i].text, ALIGN_MIDDLE_CENTER); D_80126878[i].colourIndex++; if (D_80126878[i].colourIndex >= 4) { j = i; gTitleCinematicTextColourCount--; - while(j < gTitleCinematicTextColourCount) { - D_80126878[j].text = D_80126878[j+1].text; - D_80126878[j].x = D_80126878[j+1].x; - D_80126878[j].y = D_80126878[j+1].y; - D_80126878[j].colourIndex = D_80126878[j+1].colourIndex; + while (j < gTitleCinematicTextColourCount) { + D_80126878[j].text = D_80126878[j + 1].text; + D_80126878[j].x = D_80126878[j + 1].x; + D_80126878[j].y = D_80126878[j + 1].y; + D_80126878[j].colourIndex = D_80126878[j + 1].colourIndex; j++; } } else { @@ -2842,7 +3683,7 @@ void func_80083098(f32 arg0) { text = introCharData->unk0; didUpdate = TRUE; } else { - if (!gTitleCinematicTextColours[0].red){} // Fake + if (!gTitleCinematicTextColours[0].red) {} // Fake D_801268E0++; } } @@ -2867,7 +3708,7 @@ GLOBAL_ASM("asm/non_matchings/menu/func_80083098.s") * Initialise the title screen menu. * Load the title textures and reset player allocation. * Set the current level and demo. -*/ + */ void menu_title_screen_init(void) { s32 i; s32 numberOfPlayers; @@ -2920,7 +3761,7 @@ void menu_title_screen_init(void) { /** * Scale and render the game title on the screen based on the reveal timer. * Also render the selection options. -*/ + */ void render_title_screen(UNUSED s32 updateRate, f32 updateRateF) { UNUSED u32 foo[2]; s32 alpha; @@ -2934,16 +3775,18 @@ void render_title_screen(UNUSED s32 updateRate, f32 updateRateF) { sMenuGuiOpacity = (gTitleRevealTimer * 8) - 1; func_80068508(FALSE); if (scale != 1.0f) { - render_texture_rectangle_scaled(&sMenuCurrDisplayList, sGameTitleTileOffsets, SCREEN_WIDTH_FLOAT_HALF, 52.0f, scale, scale, 0xFFFFFFFE, TEXRECT_POINT); + render_texture_rectangle_scaled(&sMenuCurrDisplayList, sGameTitleTileOffsets, SCREEN_WIDTH_FLOAT_HALF, + 52.0f, scale, scale, 0xFFFFFFFE, TEXRECT_POINT); } else { - render_textured_rectangle(&sMenuCurrDisplayList, sGameTitleTileOffsets, SCREEN_WIDTH_HALF, 52, 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, sGameTitleTileOffsets, SCREEN_WIDTH_HALF, 52, 255, 255, + 255, 255); } if (!is_controller_missing()) { - i = 0; + i = 0; posY = (osTvType == TV_TYPE_PAL) ? SCREEN_HEIGHT - 22 : SCREEN_HEIGHT - 48; set_text_font(ASSET_FONTS_FUNFONT); set_text_background_colour(0, 0, 0, 0); - while(gTitleMenuStrings[i] != NULL) { + while (gTitleMenuStrings[i] != NULL) { if (i == gTitleScreenCurrentOption) { alpha = (gOptionBlinkTimer & 0x1F) * 16; if (alpha > 255) { @@ -2968,14 +3811,14 @@ void render_title_screen(UNUSED s32 updateRate, f32 updateRateF) { /** * Handle the countdown when the title screen starts to show the logo coming in. * Fade music to make voice clips more audible. -*/ + */ s32 menu_title_screen_loop(s32 updateRate) { UNUSED s32 temp_v0_5; s32 sp28; s8 *demo; s32 contrIndex; f32 updateRateF; - ObjectSegment* sp18; + ObjectSegment *sp18; s8 playerCount; sp18 = get_active_camera_segment(); @@ -3010,7 +3853,7 @@ s32 menu_title_screen_loop(s32 updateRate) { gTitleDemoTimer = 0; } if (gMenuDelay == 0 && (func_800214C4() || sp28)) { - if (gTitleDemoTimer){} // Fakematch + if (gTitleDemoTimer) {} // Fakematch gTitleDemoIndex += DEMO_INDEX_SIZE; demo = &sTitleScreenDemoIds[gTitleDemoIndex]; if (demo[0] == -1) { @@ -3067,7 +3910,7 @@ s32 menu_title_screen_loop(s32 updateRate) { } else if (gTitleAudioCounter < 5.0f) { music_volume_set((s32) ((f32) sMenuMusicVolume * (gTitleAudioCounter - 4.0f))); } else { - music_volume_set(*((s8*)&sMenuMusicVolume + 3)); + music_volume_set(*((s8 *) &sMenuMusicVolume + 3)); } } if (gTitleRevealTimer == 0) { @@ -3087,7 +3930,8 @@ s32 menu_title_screen_loop(s32 updateRate) { sound_play(SOUND_MENU_PICK2, (s32 *) (0 * contrIndex)); // TODO: The `* contrIndex` here is a fake match. } if (D_801267D8[4] & (A_BUTTON | START_BUTTON)) { - for(contrIndex = 3; contrIndex > 0 && !(D_801267D8[contrIndex] & (A_BUTTON | START_BUTTON)); contrIndex--){} + for (contrIndex = 3; contrIndex > 0 && !(D_801267D8[contrIndex] & (A_BUTTON | START_BUTTON)); + contrIndex--) {} set_active_player_index(contrIndex); gMenuDelay = 1; transition_begin(&sMenuTransitionFadeIn); @@ -3122,7 +3966,7 @@ s32 menu_title_screen_loop(s32 updateRate) { /** * Unloads the title screen logo and sets all audio back to default. -*/ + */ void title_screen_exit(void) { func_8009C4A8(sGameTitleTileTextures); music_voicelimit_set(16); @@ -3134,7 +3978,7 @@ void title_screen_exit(void) { /** * Initialise the root options menu. * Loads required fonts and sets the background music. -*/ + */ void menu_options_init(void) { gOptionBlinkTimer = 0; gMenuDelay = 0; @@ -3146,7 +3990,7 @@ void menu_options_init(void) { music_change_off(); } -//Draws options menu screen +// Draws options menu screen void render_options_menu_ui(UNUSED s32 updateRate) { s32 optionMenuTextIndex; s32 alpha; @@ -3155,9 +3999,11 @@ void render_options_menu_ui(UNUSED s32 updateRate) { set_text_font(ASSET_FONTS_BIGFONT); set_text_background_colour(0, 0, 0, 0); set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_OPTIONS], ALIGN_MIDDLE_CENTER); // OPTIONS + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_OPTIONS], + ALIGN_MIDDLE_CENTER); // OPTIONS set_text_colour(255, 255, 255, 0, 255); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_OPTIONS], ALIGN_MIDDLE_CENTER); // OPTIONS + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_OPTIONS], + ALIGN_MIDDLE_CENTER); // OPTIONS optionMenuTextIndex = 0; yPos = 76; @@ -3174,7 +4020,8 @@ void render_options_menu_ui(UNUSED s32 updateRate) { alpha = 0; } set_text_colour(255, 255, 255, alpha, 255); - draw_text(&sMenuCurrDisplayList, POS_CENTRED, yPos, gOptionMenuStrings[optionMenuTextIndex], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, POS_CENTRED, yPos, gOptionMenuStrings[optionMenuTextIndex], + ALIGN_MIDDLE_CENTER); optionMenuTextIndex++; yPos += 28; @@ -3183,7 +4030,7 @@ void render_options_menu_ui(UNUSED s32 updateRate) { /** * Draw the text list and accept input for going to specific option menus. -*/ + */ s32 menu_options_loop(s32 updateRate) { s32 buttonsPressed; s32 i; @@ -3209,8 +4056,9 @@ s32 menu_options_loop(s32 updateRate) { analogueY = 0; if (gIgnorePlayerInputTime == 0 && gMenuDelay == 0) { s8 *xAxisPtr; - s8 *yAxisPtr; - for (i = 0, xAxisPtr = gControllersXAxisDirection, yAxisPtr = gControllersYAxisDirection; i < MAXCONTROLLERS; i++) { + s8 *yAxisPtr; + for (i = 0, xAxisPtr = gControllersXAxisDirection, yAxisPtr = gControllersYAxisDirection; i < MAXCONTROLLERS; + i++) { buttonsPressed |= get_buttons_pressed_from_player(i); analogueX += *(xAxisPtr++); analogueY += *(yAxisPtr++); @@ -3226,12 +4074,12 @@ s32 menu_options_loop(s32 updateRate) { // Go to a sub-menu gMenuDelay = 31; sound_play(SOUND_SELECT2, NULL); - + } else if (gMenuCurIndex == 0 && analogueX != 0) { switch ((u64) get_language()) { case LANGUAGE_ENGLISH: - set_language(LANGUAGE_FRENCH); - break; + set_language(LANGUAGE_FRENCH); + break; default: set_language(LANGUAGE_ENGLISH); break; @@ -3239,11 +4087,11 @@ s32 menu_options_loop(s32 updateRate) { sound_play(SOUND_MENU_PICK2, NULL); } else if (gMenuCurIndex == 1 && analogueX != 0) { if (sEepromSettings & 0x2000000) { - //0x2000000 SUBTITLES ENABLED? + // 0x2000000 SUBTITLES ENABLED? sound_play(SOUND_MENU_PICK2, NULL); unset_eeprom_settings_value(0x2000000); set_subtitles(0); - gOptionMenuStrings[1] = gMenuText[ASSET_MENU_TEXT_SUBTITLESOFF]; + gOptionMenuStrings[1] = gMenuText[ASSET_MENU_TEXT_SUBTITLESOFF]; } else { sound_play(SOUND_MENU_PICK2, NULL); set_eeprom_settings_value(0x2000000); @@ -3306,7 +4154,7 @@ void unload_big_font_1(void) { * Initialise the audio options menu. * Loads necessary textures and fonts. * Gets global audio volume and checks if the jukebox cheat is active to set the lower Y bounds. -*/ + */ void menu_audio_options_init(void) { gOptionsMenuItemIndex = 0; gOptionBlinkTimer = 0; @@ -3336,7 +4184,7 @@ void menu_audio_options_init(void) { GLOBAL_ASM("asm/non_matchings/menu/func_80084854.s") s32 menu_audio_options_loop(s32 updateRate) { - s32 i; + s32 i; u32 buttonsPressed; s32 contX; s32 contY; @@ -3361,7 +4209,7 @@ s32 menu_audio_options_loop(s32 updateRate) { if (gMenuDelay == 0) { buttonsPressed = 0; contXAxis = 0; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { buttonsPressed |= get_buttons_pressed_from_player(i); contXAxis += clamp_joystick_x_axis(i); contX += gControllersXAxisDirection[i]; @@ -3379,12 +4227,12 @@ s32 menu_audio_options_loop(s32 updateRate) { } } contXAxis >>= 2; - if (((buttonsPressed & (A_BUTTON | START_BUTTON)) && (gMenuOptionCount == gOptionsMenuItemIndex + 1)) || (buttonsPressed & B_BUTTON)) { + if (((buttonsPressed & (A_BUTTON | START_BUTTON)) && (gMenuOptionCount == gOptionsMenuItemIndex + 1)) || + (buttonsPressed & B_BUTTON)) { gMenuDelay = -1; transition_begin(&sMenuTransitionFadeIn); if (gOpacityDecayTimer >= 0) { music_fade(-128); - } sp30 = 3; } else if (contY < 0 && gOptionsMenuItemIndex < (gMenuOptionCount - 1)) { @@ -3394,7 +4242,7 @@ s32 menu_audio_options_loop(s32 updateRate) { gOptionsMenuItemIndex--; sp30 = 1; } else if (gOptionsMenuItemIndex == 0 && contX != 0) { - if (contX < 0) { + if (contX < 0) { gAudioOutputType--; } else { gAudioOutputType++; @@ -3458,7 +4306,7 @@ s32 menu_audio_options_loop(s32 updateRate) { sound_play(SOUND_VOICE_DIDDY_POSITIVE5, (s32 *) &D_801269FC); } } else if (D_801269FC != NULL) { - func_8000488C((u8* ) D_801269FC); + func_8000488C((u8 *) D_801269FC); } if (sp30 == 3) { sound_play(SOUND_MENU_BACK3, NULL); @@ -3538,7 +4386,7 @@ void func_800853D0(SaveFileData *arg0, s32 x, s32 y) { char buffer[16]; TextureHeader *texture; s32 temp; - + sp70 = 11; switch (arg0->saveFileType) { case SAVE_FILE_TYPE_UNK1: @@ -3551,7 +4399,7 @@ void func_800853D0(SaveFileData *arg0, s32 x, s32 y) { text2 = buffer; sp78 = *gSavefileData[arg0->controllerIndex]->balloonsPtr / 10; sp74 = *gSavefileData[arg0->controllerIndex]->balloonsPtr - (sp78 * 10); - //Is Adventure Two? + // Is Adventure Two? if (gSavefileData[arg0->controllerIndex]->cutsceneFlags & 4) { sp70 = 12; } @@ -3575,11 +4423,11 @@ void func_800853D0(SaveFileData *arg0, s32 x, s32 y) { decompress_filename_string(arg0->compressedFilename, buffer, 3); // char *gConPakAdvSavePrefix = " (ADV."; for (i = 0; gConPakAdvSavePrefix[i] != '\0'; i++) { - buffer[i+3] = gConPakAdvSavePrefix[i]; + buffer[i + 3] = gConPakAdvSavePrefix[i]; } - buffer[i+3] = arg0->saveFileExt[0]; - buffer[i+4] = ')'; - buffer[i+5] = '\0'; + buffer[i + 3] = arg0->saveFileExt[0]; + buffer[i + 4] = ')'; + buffer[i + 5] = '\0'; text = gMenuText[86 + arg0->controllerIndex]; sp78 = arg0->unk2 / 10; sp74 = arg0->unk2 % 10; @@ -3641,7 +4489,8 @@ void func_800853D0(SaveFileData *arg0, s32 x, s32 y) { if (osTvType == TV_TYPE_PAL) { y += 12; } - if (arg0->saveFileType == SAVE_FILE_TYPE_GAME_DATA || (arg0->saveFileType == SAVE_FILE_TYPE_UNK1 && gSavefileData[arg0->controllerIndex]->newGame == FALSE)) { + if (arg0->saveFileType == SAVE_FILE_TYPE_GAME_DATA || + (arg0->saveFileType == SAVE_FILE_TYPE_UNK1 && gSavefileData[arg0->controllerIndex]->newGame == FALSE)) { if (osTvType == TV_TYPE_PAL) { i = 134; } else { @@ -3733,19 +4582,22 @@ void func_80085B9C(UNUSED s32 updateRate) { set_text_background_colour(0, 0, 0, 0); set_text_font(2); set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_SAVEOPTIONS], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_SAVEOPTIONS], + ALIGN_MIDDLE_CENTER); set_text_colour(255, 255, 255, 0, 255); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_SAVEOPTIONS], ALIGN_MIDDLE_CENTER); - + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_SAVEOPTIONS], + ALIGN_MIDDLE_CENTER); + if (drawTexturedRectangle) { temp = (osTvType == TV_TYPE_PAL) ? SCREEN_HEIGHT_HALF_PAL : SCREEN_HEIGHT_HALF; temp += ((s32) (gOptionBlinkTimer & 0x1F) >> 1); - + for (var_s2 = 0; var_s2 < 2; var_s2 += 1, temp += 16) { - render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowDown, SCREEN_WIDTH_HALF, temp, 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowDown, SCREEN_WIDTH_HALF, temp, 255, 255, + 255, 255); } } - + if (var_s3) { var_s2 = (s32) D_80126BDC; temp = var_s2; @@ -3758,13 +4610,13 @@ void func_80085B9C(UNUSED s32 updateRate) { } temp = var_s2; var_s1 = sp5C; - while((var_s1 > 0) && (temp > 0)) { + while ((var_s1 > 0) && (temp > 0)) { temp--; var_s1 -= 164; func_800853D0(&D_80126A0C[temp], var_s1, 64); } } - + if (drawTexturedRectangle) { var_s2 = (s32) D_80126BEC; temp = var_s2; @@ -3783,14 +4635,15 @@ void func_80085B9C(UNUSED s32 updateRate) { func_800853D0(&D_80126A04[temp], var_s1, 144); } } - + set_text_font(2); set_text_colour(255, 255, 255, 0, 255); if (drawOk) { draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 128, (char *) D_800E8208, ALIGN_MIDDLE_CENTER); // "OK?" } if (drawPleaseWait) { - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 128, gMenuText[ASSET_MENU_TEXT_PLEASEWAIT], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 128, gMenuText[ASSET_MENU_TEXT_PLEASEWAIT], + ALIGN_MIDDLE_CENTER); } if (drawDialogueBox) { render_dialogue_box(&sMenuCurrDisplayList, NULL, NULL, 7); @@ -3798,7 +4651,8 @@ void func_80085B9C(UNUSED s32 updateRate) { func_80080E6C(); } -SIDeviceStatus func_800860A8(s32 controllerIndex, s32 *arg1, SaveFileData *arg2, s32 *arg3, s32 fileSize, UNUSED s32 arg5) { +SIDeviceStatus func_800860A8(s32 controllerIndex, s32 *arg1, SaveFileData *arg2, s32 *arg3, s32 fileSize, + UNUSED s32 arg5) { SIDeviceStatus ret = CONTROLLER_PAK_GOOD; if (*arg1 != 0) { @@ -3810,15 +4664,12 @@ SIDeviceStatus func_800860A8(s32 controllerIndex, s32 *arg1, SaveFileData *arg2, (*arg3)++; } } else { - SIDeviceStatus status = ret & 0xFF; //The upper bytes could be controllerIndex, so focus on the status + SIDeviceStatus status = ret & 0xFF; // The upper bytes could be controllerIndex, so focus on the status if ((*arg1 < 0) && status == CONTROLLER_PAK_RUMBLE_PAK_FOUND) { *arg1 = 0; ret = CONTROLLER_PAK_GOOD; - } else if - (status != CONTROLLER_PAK_WITH_BAD_ID && - status != CONTROLLER_PAK_INCONSISTENT && - status != CONTROLLER_PAK_BAD_DATA) - { + } else if (status != CONTROLLER_PAK_WITH_BAD_ID && status != CONTROLLER_PAK_INCONSISTENT && + status != CONTROLLER_PAK_BAD_DATA) { ret = CONTROLLER_PAK_GOOD; } } @@ -3853,7 +4704,7 @@ SIDeviceStatus func_800862C4(void) { Settings *settings; u32 fileSizes[16]; char *temp_D_80126A64; - + settings = gSavefileData[3]; D_80126A08 = 0; D_80126BD4 = 0; @@ -3868,7 +4719,7 @@ SIDeviceStatus func_800862C4(void) { D_80126A08++; } } - + D_80126A0C[D_80126A08].saveFileType = SAVE_FILE_TYPE_UNK2; D_80126A0C[D_80126A08].unk1 = 1; D_80126A0C[D_80126A08++].fileSize = get_time_data_file_size(); @@ -3878,36 +4729,40 @@ SIDeviceStatus func_800862C4(void) { numAttempts = 1; if (D_80126A18 != 0) { D_80126A14 = 0; - + do { result = get_controller_pak_file_list(0, 16, fileNames, fileExts, fileSizes, fileTypes); - temp = result & 0xFF; //strip the controller index from the result to just get the SI Device Status + temp = result & 0xFF; // strip the controller index from the result to just get the SI Device Status numAttempts++; } while ((temp == CONTROLLER_PAK_CHANGED) && (numAttempts < 3)); if (result == CONTROLLER_PAK_GOOD) { for (fileIndex = 0; fileIndex < 16; fileIndex++) { - if ((fileTypes[fileIndex] >= SAVE_FILE_TYPE_GAME_DATA) && (fileTypes[fileIndex] <= SAVE_FILE_TYPE_UNKNOWN)) { + if ((fileTypes[fileIndex] >= SAVE_FILE_TYPE_GAME_DATA) && + (fileTypes[fileIndex] <= SAVE_FILE_TYPE_UNKNOWN)) { (*sControllerPakNotesFree)--; D_80126A0C[D_80126A08].saveFileType = fileTypes[fileIndex]; D_80126A0C[D_80126A08].controllerIndex = 0; D_80126A0C[D_80126A08].saveFileNumber = fileIndex; D_80126A0C[D_80126A08].fileSize = fileSizes[fileIndex]; if (fileTypes[fileIndex] == SAVE_FILE_TYPE_GAME_DATA) { - if (read_game_data_from_controller_pak(0, fileExts[fileIndex], settings) == CONTROLLER_PAK_GOOD) { + if (read_game_data_from_controller_pak(0, fileExts[fileIndex], settings) == + CONTROLLER_PAK_GOOD) { D_80126A0C[D_80126A08].saveFileExt = temp_D_80126A64; temp_D_80126A64[0] = *fileExts[fileIndex]; temp_D_80126A64[1] = 0; temp_D_80126A64 += 2; D_80126A0C[D_80126A08].unk2 = *settings->balloonsPtr; - D_80126A0C[D_80126A08].unk3 = (settings->cutsceneFlags & 4) != 0; // Is in Adventure Two? + D_80126A0C[D_80126A08].unk3 = + (settings->cutsceneFlags & 4) != 0; // Is in Adventure Two? D_80126A0C[D_80126A08].compressedFilename = settings->filename; } else { D_80126A08--; } } else { temp = 0; - if ((fileTypes[fileIndex] == SAVE_FILE_TYPE_UNKNOWN) || (fileTypes[fileIndex] == SAVE_FILE_TYPE_TIME_DATA)) { + if ((fileTypes[fileIndex] == SAVE_FILE_TYPE_UNKNOWN) || + (fileTypes[fileIndex] == SAVE_FILE_TYPE_TIME_DATA)) { if (fileTypes[fileIndex] == SAVE_FILE_TYPE_TIME_DATA) { temp = CONTROLLER_PAK_BAD_DATA; } @@ -3917,7 +4772,7 @@ SIDeviceStatus func_800862C4(void) { temp++; temp_D_80126A64++; } - + if ((fileExts[fileIndex] != NULL) && (fileExts[fileIndex][0] != '\0')) { *temp_D_80126A64 = '.'; temp_D_80126A64++; @@ -3951,8 +4806,7 @@ SIDeviceStatus func_800862C4(void) { numAttempts = 0; } } - } - while (numAttempts == 0); + } while (numAttempts == 0); return result; } @@ -3972,15 +4826,18 @@ SIDeviceStatus func_800867D4(void) { break; case SAVE_FILE_TYPE_GAME_DATA: func_800861C8(D_80126A04, &D_80126A00); - ret = func_800860A8(1, &D_80126A1C, D_80126A04, &D_80126A00, get_game_data_file_size(), D_80126A0C[D_80126BD4].controllerIndex); + ret = func_800860A8(1, &D_80126A1C, D_80126A04, &D_80126A00, get_game_data_file_size(), + D_80126A0C[D_80126BD4].controllerIndex); break; case SAVE_FILE_TYPE_TIME_DATA: D_80126A04[D_80126A00++].saveFileType = SAVE_FILE_TYPE_UNK2; - ret = func_800860A8(1, &D_80126A1C, D_80126A04, &D_80126A00, get_time_data_file_size(), D_80126A0C[D_80126BD4].controllerIndex); + ret = func_800860A8(1, &D_80126A1C, D_80126A04, &D_80126A00, get_time_data_file_size(), + D_80126A0C[D_80126BD4].controllerIndex); break; case SAVE_FILE_TYPE_GHOST_DATA: D_80126A04[D_80126A00++].saveFileType = SAVE_FILE_TYPE_UNK9; - ret = func_800860A8(1, &D_80126A1C, D_80126A04, &D_80126A00, get_ghost_data_file_size(), D_80126A0C[D_80126BD4].controllerIndex); + ret = func_800860A8(1, &D_80126A1C, D_80126A04, &D_80126A00, get_ghost_data_file_size(), + D_80126A0C[D_80126BD4].controllerIndex); break; } @@ -4042,13 +4899,15 @@ SIDeviceStatus func_80086AFC(void) { } else { clear_lap_records(settings, 3); mark_to_write_flap_and_course_times(); - unset_eeprom_settings_value(0xFFFFF0); //Reset most eeprom save data, but keep Adventure 2, and Drumstick. + unset_eeprom_settings_value( + 0xFFFFF0); // Reset most eeprom save data, but keep Adventure 2, and Drumstick. } break; case SAVE_FILE_TYPE_GAME_DATA: switch (D_80126A04[D_80126BE4].saveFileType) { case SAVE_FILE_TYPE_UNK1: - ret = read_game_data_from_controller_pak(D_80126A0C[D_80126BD4].controllerIndex, D_80126A0C[D_80126BD4].saveFileExt, settings); + ret = read_game_data_from_controller_pak(D_80126A0C[D_80126BD4].controllerIndex, + D_80126A0C[D_80126BD4].saveFileExt, settings); if (settings->cutsceneFlags & 4 && !is_adventure_two_unlocked()) { ret = CONTROLLER_PAK_NEED_SECOND_ADVENTURE; } @@ -4061,9 +4920,11 @@ SIDeviceStatus func_80086AFC(void) { } break; case SAVE_FILE_TYPE_UNK8: - ret = read_game_data_from_controller_pak(D_80126A0C[D_80126BD4].controllerIndex, D_80126A0C[D_80126BD4].saveFileExt, gSavefileData[3]); + ret = read_game_data_from_controller_pak(D_80126A0C[D_80126BD4].controllerIndex, + D_80126A0C[D_80126BD4].saveFileExt, gSavefileData[3]); if (ret == CONTROLLER_PAK_GOOD) { - ret = write_game_data_to_controller_pak(D_80126A04[D_80126BE4].controllerIndex, gSavefileData[3]); + ret = + write_game_data_to_controller_pak(D_80126A04[D_80126BE4].controllerIndex, gSavefileData[3]); } break; case SAVE_FILE_TYPE_UNK7: @@ -4103,7 +4964,9 @@ SIDeviceStatus func_80086AFC(void) { D_801264D0 = D_80126A0C[D_80126BD4].controllerIndex; } } else { - ret = copy_controller_pak_data(D_80126A0C[D_80126BD4].controllerIndex, D_80126A0C[D_80126BD4].saveFileNumber, D_80126A04[D_80126BE4].controllerIndex); + ret = copy_controller_pak_data(D_80126A0C[D_80126BD4].controllerIndex, + D_80126A0C[D_80126BD4].saveFileNumber, + D_80126A04[D_80126BE4].controllerIndex); } } else { ret = delete_file(D_80126A0C[D_80126BD4].controllerIndex, D_80126A0C[D_80126BD4].saveFileNumber); @@ -4116,7 +4979,8 @@ SIDeviceStatus func_80086AFC(void) { break; case SAVE_FILE_TYPE_UNKA: if (D_80126A04[D_80126BE4].saveFileType == SAVE_FILE_TYPE_UNK7) { - unset_eeprom_settings_value(0xFFFFF3); //Reset most eeprom save data including Adventure Two unlock and Drumstick unlock. + unset_eeprom_settings_value( + 0xFFFFF3); // Reset most eeprom save data including Adventure Two unlock and Drumstick unlock. gActiveMagicCodes &= ~(CHEAT_CONTROL_TT | CHEAT_CONTROL_DRUMSTICK); gUnlockedMagicCodes &= ~(CHEAT_CONTROL_TT | CHEAT_CONTROL_DRUMSTICK); } @@ -4134,27 +4998,29 @@ void func_800871D8(SIDeviceStatus deviceStatus) { s32 k; s32 y; char *text; - - gControllerIndex = (deviceStatus >> 30) & 3; //Gets the controller index from the device status. - deviceStatus &= 0x3FFFFFFF; //Removes the controller index from the device status value. + + gControllerIndex = (deviceStatus >> 30) & 3; // Gets the controller index from the device status. + deviceStatus &= 0x3FFFFFFF; // Removes the controller index from the device status value. gDeviceStatusStrings = gContPakStrings[deviceStatus]; D_800DFADC = deviceStatus; D_80126A74 = 0; - + for (k = 0; gDeviceStatusStrings[k] != NULL; k++) {} k++; for (; gDeviceStatusStrings[k] != NULL; D_80126A74++, k++) {} - + D_80126A78 = D_80126A74 - 1; - + assign_dialogue_box_id(7); - set_current_dialogue_box_coords(7, 40, SCREEN_HEIGHT_HALF - (((k * 16) + 44) >> 1), 280, (((k * 16) + 44) >> 1) + SCREEN_HEIGHT_HALF); + set_current_dialogue_box_coords(7, 40, SCREEN_HEIGHT_HALF - (((k * 16) + 44) >> 1), 280, + (((k * 16) + 44) >> 1) + SCREEN_HEIGHT_HALF); set_current_dialogue_background_colour(7, 0, 0, 0, 160); set_current_text_background_colour(7, 0, 0, 0, 0); set_dialogue_font(7, 2); set_current_text_colour(7, 255, 255, 255, 0, 255); text = gMenuText[ASSET_MENU_TEXT_PAKERROR]; - if (gDeviceStatusStrings == gContPakRumbleDetectedStrings || gDeviceStatusStrings == gContPakSwitchToRumbleStrings) { + if (gDeviceStatusStrings == gContPakRumbleDetectedStrings || + gDeviceStatusStrings == gContPakSwitchToRumbleStrings) { text = gMenuText[ASSET_MENU_TEXT_CAUTION]; } else if (gDeviceStatusStrings == gContPakNeed2ndAdvStrings) { text = gMenuText[ASSET_MENU_TEXT_GAMEERROR]; @@ -4174,7 +5040,6 @@ void func_800871D8(SIDeviceStatus deviceStatus) { gMenuOptionCount |= 8; } - s32 func_800874D0(s32 buttonsPressed, s32 arg1) { s32 ret; @@ -4242,14 +5107,15 @@ s32 func_80087734(s32 buttonsPressed, s32 yAxis) { temp = 511 - temp; } sp1C = (gMenuOptionCount & 7); - for(i = 0; i < D_80126A74; i++) { + for (i = 0; i < D_80126A74; i++) { if (i == D_80126A78) { D_80126A80[i]->unk13 = temp; } else { D_80126A80[i]->unk13 = 0; } } - if (buttonsPressed & B_BUTTON || (buttonsPressed & (START_BUTTON | A_BUTTON) && (u32) D_80126A74 == (u32) (D_80126A78 + 1))) { + if (buttonsPressed & B_BUTTON || + (buttonsPressed & (START_BUTTON | A_BUTTON) && (u32) D_80126A74 == (u32) (D_80126A78 + 1))) { sound_play(SOUND_MENU_BACK3, NULL); gMenuOptionCount &= ~8; switch (sp1C) { @@ -4390,7 +5256,7 @@ s32 menu_save_options_loop(s32 updateRate) { xAxis = 0; yAxis = 0; if (gIgnorePlayerInputTime == 0) { - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { xAxis += gControllersXAxisDirection[i]; yAxis += gControllersYAxisDirection[i]; buttonsPressed |= get_buttons_pressed_from_player(i); @@ -4400,63 +5266,63 @@ s32 menu_save_options_loop(s32 updateRate) { gMenuDelay = func_80087734(buttonsPressed, yAxis); } else { switch (gMenuOptionCount) { - case 0: - gMenuDelay = -1; - break; - case 1: - gOpacityDecayTimer++; - if (gOpacityDecayTimer >= 11) { - gMenuOptionCount = 2; - } - break; - case 2: - D_80126BD4 = 0; - D_80126BDC = 0.0f; - result = func_800862C4(); - if (result != 0) { - func_800871D8(result); - } else { - gMenuOptionCount = 3; - } - break; - case 3: - gMenuDelay = func_800874D0(buttonsPressed, xAxis); - break; - case 4: - D_80126BE4 = 0; - D_80126BEC = 0.0f; - result = func_800867D4(); - if (result != CONTROLLER_PAK_GOOD) { - func_800871D8(result); - } else { - gMenuOptionCount = 5; - } - break; - case 5: - gMenuDelay = func_800875E4(buttonsPressed, xAxis); - break; - case 6: - gMenuDelay = func_800876CC(buttonsPressed, xAxis); - break; - case 7: - gOpacityDecayTimer++; - if (gOpacityDecayTimer >= 4) { - result = func_80086AFC(); + case 0: + gMenuDelay = -1; + break; + case 1: + gOpacityDecayTimer++; + if (gOpacityDecayTimer >= 11) { + gMenuOptionCount = 2; + } + break; + case 2: + D_80126BD4 = 0; + D_80126BDC = 0.0f; + result = func_800862C4(); + if (result != 0) { + func_800871D8(result); + } else { + gMenuOptionCount = 3; + } + break; + case 3: + gMenuDelay = func_800874D0(buttonsPressed, xAxis); + break; + case 4: + D_80126BE4 = 0; + D_80126BEC = 0.0f; + result = func_800867D4(); if (result != CONTROLLER_PAK_GOOD) { func_800871D8(result); } else { - gOpacityDecayTimer = 6; - gMenuOptionCount = 1; + gMenuOptionCount = 5; } - } - break; + break; + case 5: + gMenuDelay = func_800875E4(buttonsPressed, xAxis); + break; + case 6: + gMenuDelay = func_800876CC(buttonsPressed, xAxis); + break; + case 7: + gOpacityDecayTimer++; + if (gOpacityDecayTimer >= 4) { + result = func_80086AFC(); + if (result != CONTROLLER_PAK_GOOD) { + func_800871D8(result); + } else { + gOpacityDecayTimer = 6; + gMenuOptionCount = 1; + } + } + break; } if (gMenuDelay != 0) { transition_begin(&sMenuTransitionFadeIn); } } gIgnorePlayerInputTime = 0; - + return MENU_RESULT_CONTINUE; } @@ -4465,12 +5331,12 @@ void func_80087EB8(void) { func_8007FF88(); func_8009C4A8(gSaveMenuObjectIndices); assign_dialogue_box_id(7); - free_from_memory_pool((void *)D_80126A0C); - free_from_memory_pool((void *)D_80126A64); + free_from_memory_pool((void *) D_80126A0C); + free_from_memory_pool((void *) D_80126A64); } #ifdef NON_EQUIVALENT -//Nearly complete +// Nearly complete SIDeviceStatus func_80087F14(s32 *controllerIndex, s32 arg1) { s32 ret; s32 j = 0; @@ -4489,14 +5355,14 @@ SIDeviceStatus func_80087F14(s32 *controllerIndex, s32 arg1) { pakStatusError3 = 0; pakStatusError9 = 0; pakStatusErrorNoFreeSpace = 0; - //Is this really <= 0? + // Is this really <= 0? for (i = 0; i <= 0; i++) { - //sControllerPakIssueNotFound[i] = 0; + // sControllerPakIssueNotFound[i] = 0; sControllerPakFatalErrorFound[i] = 0; sControllerPakNoFreeSpace[i] = 0; sControllerPakBadData[i] = 0; ret = get_free_space(i, &bytesFree, ¬esFree); - pakStatus = ret & 0xFF; //Upper 2 bits are controller index + pakStatus = ret & 0xFF; // Upper 2 bits are controller index if (ret == CONTROLLER_PAK_GOOD) { sControllerPakIssueNotFound[i] = 1; if (bytesFree == 0 || notesFree == 0) { @@ -4508,27 +5374,25 @@ SIDeviceStatus func_80087F14(s32 *controllerIndex, s32 arg1) { pakStatusSuccess++; } else { sControllerPakIssueNotFound[i] = 0; - //Bad data + // Bad data if (pakStatus == CONTROLLER_PAK_BAD_DATA) { sControllerPakBadData[i] = 1; pakStatusError9++; } - //Error inconsistent + // Error inconsistent if (pakStatus == CONTROLLER_PAK_INCONSISTENT) { - //Repair file system + // Repair file system repair_controller_pak(i); } - //fatal error + // fatal error if (pakStatus == CONTROLLER_PAK_WITH_BAD_ID) { sControllerPakFatalErrorFound[i] = 1; pakStatusError3++; } } } - if ( (pakStatusSuccess == 0) - || (pakStatusError3 != 0) - || (pakStatusErrorNoFreeSpace != 0) - || (pakStatusError9 != 0)) { + if ((pakStatusSuccess == 0) || (pakStatusError3 != 0) || (pakStatusErrorNoFreeSpace != 0) || + (pakStatusError9 != 0)) { return CONTROLLER_PAK_NOT_FOUND; // Return unsuccessfully? } @@ -4558,7 +5422,8 @@ SIDeviceStatus func_80087F14(s32 *controllerIndex, s32 arg1) { do { controllerIndexVal--; i--; - if (controllerIndexVal < 0) {; + if (controllerIndexVal < 0) { + ; controllerIndexVal++; i++; } @@ -4566,7 +5431,9 @@ SIDeviceStatus func_80087F14(s32 *controllerIndex, s32 arg1) { } *controllerIndex = controllerIndexVal; - ret = get_controller_pak_file_list(controllerIndexVal, 16, &sCurrentControllerPakAllFileNames, &sCurrentControllerPakAllFileExtensions, &sCurrentControllerPakAllFileSizes, &sCurrentControllerPakAllFileTypes); + ret = get_controller_pak_file_list(controllerIndexVal, 16, &sCurrentControllerPakAllFileNames, + &sCurrentControllerPakAllFileExtensions, &sCurrentControllerPakAllFileSizes, + &sCurrentControllerPakAllFileTypes); if (ret == CONTROLLER_PAK_GOOD) { i = 0; @@ -4579,7 +5446,8 @@ SIDeviceStatus func_80087F14(s32 *controllerIndex, s32 arg1) { D_80126AA0[i][j] = sCurrentControllerPakAllFileNames[i][k]; } - if ((sCurrentControllerPakAllFileExtensions[i] != 0) && (*sCurrentControllerPakAllFileExtensions[i] != 0)) { + if ((sCurrentControllerPakAllFileExtensions[i] != 0) && + (*sCurrentControllerPakAllFileExtensions[i] != 0)) { D_80126AA0[i][j] = '.'; j++; k = 0; @@ -4596,10 +5464,11 @@ SIDeviceStatus func_80087F14(s32 *controllerIndex, s32 arg1) { D_80126AA0[i - 1][j] = 0; } while (&D_80126AA0 != &sCurrentControllerPakAllFileNames); - packDirectoryFree(); //Free D_800DE440 from memory - get_free_space(*controllerIndex, &sCurrentControllerPakFreeSpace, NULL); //Get Available Space in Controller Pak - sCurrentControllerPakFreeSpace = sCurrentControllerPakFreeSpace / 256; //Bytes - ret = pakStatus; //Really? + packDirectoryFree(); // Free D_800DE440 from memory + get_free_space(*controllerIndex, &sCurrentControllerPakFreeSpace, NULL); // Get Available Space in Controller + // Pak + sCurrentControllerPakFreeSpace = sCurrentControllerPakFreeSpace / 256; // Bytes + ret = pakStatus; // Really? } return ret; @@ -4623,33 +5492,41 @@ PakError check_for_controller_pak_errors(void) { errorFound = 0; sControllerPakError = PAK_ERROR_NONE; - // This has been hard limited to just the first controller pak, but can easily be modified to check the rest with i <= MAXCONTROLLERS + // This has been hard limited to just the first controller pak, but can easily be modified to check the rest with i + // <= MAXCONTROLLERS for (i = 0; i <= 0 && errorFound == 0; i++) { if (sControllerPakFatalErrorFound[i] != 0) { - gControllerPakMenuElement[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_PAKERROR]; // PAK ERROR - gControllerPakMenuElement[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_PAKERROR]; // PAK ERROR - gControllerPakMenuElement[2].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CONTPAK1 + i]; // CONTROLLER PAK 1 / 2 / 3 / 4 - gControllerPakMenuElement[3].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CONTPAKISDAMAGED_0]; // IRREPARABLY DAMAGED. - gControllerPakMenuElement[4].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_TURNOFFN64_0]; // Switch off the N64 - gControllerPakMenuElement[5].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_TURNOFFN64_1]; // and remove the controller pak. + gControllerPakMenuElement[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_PAKERROR]; // PAK ERROR + gControllerPakMenuElement[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_PAKERROR]; // PAK ERROR + gControllerPakMenuElement[2].unk14_a.asciiText = + gMenuText[ASSET_MENU_TEXT_CONTPAK1 + i]; // CONTROLLER PAK 1 / 2 / 3 / 4 + gControllerPakMenuElement[3].unk14_a.asciiText = + gMenuText[ASSET_MENU_TEXT_CONTPAKISDAMAGED_0]; // IRREPARABLY DAMAGED. + gControllerPakMenuElement[4].unk14_a.asciiText = + gMenuText[ASSET_MENU_TEXT_TURNOFFN64_0]; // Switch off the N64 + gControllerPakMenuElement[5].unk14_a.asciiText = + gMenuText[ASSET_MENU_TEXT_TURNOFFN64_1]; // and remove the controller pak. sControllerPakError = PAK_ERROR_FATAL; errorFound = 1; } else if ((sControllerPakNoFreeSpace[i] != 0) && (sControllerPakDataPresent[i] == 0)) { - gControllerPakMenuElement[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // CAUTION - gControllerPakMenuElement[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // CAUTION - gControllerPakMenuElement[2].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CONTPAK1 + i]; // CONTROLLER PAK 1 / 2 / 3 / 4 - gControllerPakMenuElement[3].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CONTPAKFULL]; // CONTROLLER PAK FULL - gControllerPakMenuElement[4].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // CONTINUE + gControllerPakMenuElement[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // CAUTION + gControllerPakMenuElement[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // CAUTION + gControllerPakMenuElement[2].unk14_a.asciiText = + gMenuText[ASSET_MENU_TEXT_CONTPAK1 + i]; // CONTROLLER PAK 1 / 2 / 3 / 4 + gControllerPakMenuElement[3].unk14_a.asciiText = + gMenuText[ASSET_MENU_TEXT_CONTPAKFULL]; // CONTROLLER PAK FULL + gControllerPakMenuElement[4].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CONTINUE]; // CONTINUE gControllerPakMenuElement[5].unk14_a.asciiText = NULL; sControllerPakDataPresent[i] = 1; sControllerPakError = PAK_ERROR_FULL; errorFound = 1; } else if (sControllerPakBadData[i] != 0) { - gControllerPakMenuElement[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // CAUTION - gControllerPakMenuElement[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // CAUTION - gControllerPakMenuElement[2].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CONTPAK1 + i]; // CONTROLLER PAK 1 / 2 / 3 / 4 - gControllerPakMenuElement[3].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CORRUPTDATA_0]; // CORRUPT DATA. - gControllerPakMenuElement[4].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CORRUPTDATA_1]; // TRY AGAIN! + gControllerPakMenuElement[0].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // CAUTION + gControllerPakMenuElement[1].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CAUTION]; // CAUTION + gControllerPakMenuElement[2].unk14_a.asciiText = + gMenuText[ASSET_MENU_TEXT_CONTPAK1 + i]; // CONTROLLER PAK 1 / 2 / 3 / 4 + gControllerPakMenuElement[3].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CORRUPTDATA_0]; // CORRUPT DATA. + gControllerPakMenuElement[4].unk14_a.asciiText = gMenuText[ASSET_MENU_TEXT_CORRUPTDATA_1]; // TRY AGAIN! gControllerPakMenuElement[5].unk14_a.asciiText = NULL; sControllerPakError = PAK_ERROR_CORRUPT; errorFound = 1; @@ -4662,7 +5539,7 @@ PakError check_for_controller_pak_errors(void) { /** * Initialise boot screen menu. * Load the title textures into RAM. -*/ + */ void menu_boot_init(void) { s32 i; @@ -4730,7 +5607,8 @@ s32 menu_boot_loop(s32 updateRate) { } if (temp < 300) { - render_textured_rectangle(&sMenuCurrDisplayList, sGameTitleTileOffsets, SCREEN_WIDTH_HALF, temp, 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, sGameTitleTileOffsets, SCREEN_WIDTH_HALF, temp, 255, 255, 255, + 255); reset_render_settings(&sMenuCurrDisplayList); } @@ -4738,7 +5616,7 @@ s32 menu_boot_loop(s32 updateRate) { } void func_800887C4(void) { - func_8009C4A8((s16 *)sGameTitleTileTextures); + func_8009C4A8((s16 *) sGameTitleTileTextures); } void func_800887E8(void) { @@ -4749,7 +5627,7 @@ void func_800887E8(void) { // Fills in the table. for (i = 1; i < 16; i++) { - D_80126AA0[i] = (char *)(((u32)D_80126AA0[0]) + (i * 0x20)); + D_80126AA0[i] = (char *) (((u32) D_80126AA0[0]) + (i * 0x20)); } for (i = 0; i < 1; i++) { @@ -4781,7 +5659,7 @@ void func_800887E8(void) { load_font(ASSET_FONTS_BIGFONT); } -//Visual Aid : https://i.imgur.com/7T2Scdr.png +// Visual Aid : https://i.imgur.com/7T2Scdr.png void render_controller_pak_ui(UNUSED s32 updateRate) { s32 alpha; s32 i; @@ -4801,9 +5679,11 @@ void render_controller_pak_ui(UNUSED s32 updateRate) { } else if (gShowControllerPakMenu != 0) { set_text_font(ASSET_FONTS_BIGFONT); set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 33, gMenuText[ASSET_MENU_TEXT_CONTPAK], ALIGN_MIDDLE_CENTER); //CONTROLLER PAK - Drop Shadow + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 33, gMenuText[ASSET_MENU_TEXT_CONTPAK], + ALIGN_MIDDLE_CENTER); // CONTROLLER PAK - Drop Shadow set_text_colour(255, 255, 255, 0, 255); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 30, gMenuText[ASSET_MENU_TEXT_CONTPAK], ALIGN_MIDDLE_CENTER); //CONTROLLER PAK - Main Text + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 30, gMenuText[ASSET_MENU_TEXT_CONTPAK], + ALIGN_MIDDLE_CENTER); // CONTROLLER PAK - Main Text yPos += 48; @@ -4819,11 +5699,13 @@ void render_controller_pak_ui(UNUSED s32 updateRate) { set_dialogue_font(6, ASSET_FONTS_FUNFONT); set_current_text_colour(6, 255, 255, 255, 0, 255); set_current_text_background_colour(6, 0, 0, 0, 0); - render_dialogue_text(6, POS_CENTRED, 2, gMenuText[86 + gMenuOption], 1, HORZ_ALIGN_CENTER); //ASSET_MENU_TEXT_CONTPAK1 - CONTROLLER PAK 1 / 2 / 3 / 4 - render_dialogue_text(6, POS_CENTRED, 16, gMenuText[ASSET_MENU_TEXT_FREEPAGESX], sCurrentControllerPakFreeSpace, HORZ_ALIGN_CENTER); //FREE PAGES: ~ + render_dialogue_text(6, POS_CENTRED, 2, gMenuText[86 + gMenuOption], 1, + HORZ_ALIGN_CENTER); // ASSET_MENU_TEXT_CONTPAK1 - CONTROLLER PAK 1 / 2 / 3 / 4 + render_dialogue_text(6, POS_CENTRED, 16, gMenuText[ASSET_MENU_TEXT_FREEPAGESX], sCurrentControllerPakFreeSpace, + HORZ_ALIGN_CENTER); // FREE PAGES: ~ render_dialogue_box(&sMenuCurrDisplayList, NULL, NULL, 6); - yPos += 34; //To 82 + yPos += 34; // To 82 set_dialogue_font(6, ASSET_FONTS_SMALLFONT); set_current_text_background_colour(6, 0, 0, 0, 0); @@ -4831,24 +5713,24 @@ void render_controller_pak_ui(UNUSED s32 updateRate) { assign_dialogue_box_id(6); set_current_dialogue_box_coords(6, 28, yPos, 292, yPos + 14); if (i < 0) { - //Red background for table header + // Red background for table header set_current_dialogue_background_colour(6, 224, 48, 48, 224); set_current_text_colour(6, 224, 224, 48, 255, 255); - noteText = gMenuText[ASSET_MENU_TEXT_NOTE]; //NOTE - fileNameText = gMenuText[ASSET_MENU_TEXT_FILENAME]; //FILENAME - pagesText = gMenuText[ASSET_MENU_TEXT_PAGES]; //PAGES + noteText = gMenuText[ASSET_MENU_TEXT_NOTE]; // NOTE + fileNameText = gMenuText[ASSET_MENU_TEXT_FILENAME]; // FILENAME + pagesText = gMenuText[ASSET_MENU_TEXT_PAGES]; // PAGES numberOfPages = 1; } else { if (gMenuCurIndex == (i + gOpacityDecayTimer)) { - //White background for currently selected row + // White background for currently selected row set_current_dialogue_background_colour(6, 255, 255, 255, (alpha >> 1) + 128); } else { - //Yellow background for all other rows + // Yellow background for all other rows set_current_dialogue_background_colour(6, 224, 224, 48, 224); } set_current_text_colour(6, 16, 16, 160, 255, 255); - noteText = (char *)&D_800E820C; //~ - pagesText = (char *)&D_800E820C; //~ + noteText = (char *) &D_800E820C; //~ + pagesText = (char *) &D_800E820C; //~ fileNameText = D_80126AA0[gOpacityDecayTimer + i]; numberOfPages = sCurrentControllerPakAllFileSizes[gOpacityDecayTimer + i]; } @@ -4860,7 +5742,8 @@ void render_controller_pak_ui(UNUSED s32 updateRate) { } if (gOpacityDecayTimer < (16 - sControllerPakMenuNumberOfRows)) { if ((gOptionBlinkTimer & 8) != 0) { - render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowDown, SCREEN_WIDTH_HALF, yPos + 8, 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowDown, SCREEN_WIDTH_HALF, yPos + 8, + 255, 255, 255, 255); reset_render_settings(&sMenuCurrDisplayList); } } else { @@ -4870,7 +5753,8 @@ void render_controller_pak_ui(UNUSED s32 updateRate) { } else { set_text_colour(255, 255, 255, 0, 255); } - draw_text(&sMenuCurrDisplayList, POS_CENTRED, yPos, gMenuText[ASSET_MENU_TEXT_EXIT], ALIGN_TOP_CENTER); //EXIT + draw_text(&sMenuCurrDisplayList, POS_CENTRED, yPos, gMenuText[ASSET_MENU_TEXT_EXIT], + ALIGN_TOP_CENTER); // EXIT } if ((gMenuOptionCount != 0) && (D_80126C10 == 0)) { if (osTvType == TV_TYPE_PAL) { @@ -4893,11 +5777,12 @@ void render_controller_pak_ui(UNUSED s32 updateRate) { set_current_text_colour(6, 255, 255, 255, 0, 255); } - //Render these three lines in this order - //ASSET_MENU_TEXT_DELETENOTEX - DELETE NOTE ~ ? - //ASSET_MENU_TEXT_DELETE - DELETE - //ASSET_MENU_TEXT_CANCELDELETE - CANCEL - render_dialogue_text(6, POS_CENTRED, yPos, gMenuText[ASSET_MENU_TEXT_DELETENOTEX + i], gMenuCurIndex + 1, HORZ_ALIGN_CENTER); + // Render these three lines in this order + // ASSET_MENU_TEXT_DELETENOTEX - DELETE NOTE ~ ? + // ASSET_MENU_TEXT_DELETE - DELETE + // ASSET_MENU_TEXT_CANCELDELETE - CANCEL + render_dialogue_text(6, POS_CENTRED, yPos, gMenuText[ASSET_MENU_TEXT_DELETENOTEX + i], + gMenuCurIndex + 1, HORZ_ALIGN_CENTER); if (i != 0) { yPos += 16; @@ -4907,11 +5792,12 @@ void render_controller_pak_ui(UNUSED s32 updateRate) { } render_dialogue_box(&sMenuCurrDisplayList, NULL, NULL, 6); } - //Deleting File + // Deleting File if (D_80126C10 != 0) { set_text_colour(255, 255, 255, 0, 255); set_text_font(ASSET_FONTS_BIGFONT); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 128, gMenuText[ASSET_MENU_TEXT_PLEASEWAIT], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 128, gMenuText[ASSET_MENU_TEXT_PLEASEWAIT], + ALIGN_MIDDLE_CENTER); } } } @@ -4960,12 +5846,12 @@ s32 menu_controller_pak_loop(s32 updateRate) { D_80126C10--; if (D_80126C10 == 0) { if (delete_file(gMenuOption, gMenuCurIndex) != CONTROLLER_PAK_GOOD) { - //Failed to delete the file + // Failed to delete the file playCancelSound = TRUE; gMenuDelay = 1; transition_begin(&sMenuTransitionFadeIn); } else { - //File deleted successfully + // File deleted successfully playSelectedSound = TRUE; if (func_80087F14(&gMenuOption, xStick) != CONTROLLER_PAK_GOOD) { playCancelSound = TRUE; @@ -4992,75 +5878,77 @@ s32 menu_controller_pak_loop(s32 updateRate) { gMenuOptionCount = 2; playMoveSound = TRUE; } - } else if ((pressedButtons & B_BUTTON) || (gMenuCurIndex == 16 && (pressedButtons & (A_BUTTON | START_BUTTON)))) { + } else if ((pressedButtons & B_BUTTON) || + (gMenuCurIndex == 16 && (pressedButtons & (A_BUTTON | START_BUTTON)))) { playCancelSound = 1; gMenuDelay = 1; transition_begin(&sMenuTransitionFadeIn); } else { - //gMenuCurIndex = selected menu index? + // gMenuCurIndex = selected menu index? switch (gMenuCurIndex) { - case -1: - if (yStick < 0) { - if(!xStick){} // Fakematch - gMenuCurIndex = 0; - playMoveSound = TRUE; - } - break; - case 16: - if (yStick > 0) { - gMenuCurIndex = 15; - playMoveSound = TRUE; - } - break; - default: - if (pressedButtons & (A_BUTTON | START_BUTTON)) { - //Check if the selected menu item is a file or blank - if ((sCurrentControllerPakAllFileTypes[gMenuCurIndex] >= SAVE_FILE_TYPE_GAME_DATA) && (sCurrentControllerPakAllFileTypes[gMenuCurIndex] <= SAVE_FILE_TYPE_UNKNOWN)) { - D_80126C10 = 0; - gMenuOptionCount = 2; - playSelectedSound = TRUE; - } else { - //If it's not, just play the "back" sound - playCancelSound = TRUE; - } - } else { - if (yStick > 0) { - gMenuCurIndex--; - if (gMenuCurIndex < 0) { - gMenuCurIndex = 0; - } else { - playMoveSound = TRUE; - } - } else if (yStick < 0) { - gMenuCurIndex++; + case -1: + if (yStick < 0) { + if (!xStick) {} // Fakematch + gMenuCurIndex = 0; playMoveSound = TRUE; } - } - if (gMenuCurIndex >= (gOpacityDecayTimer + sControllerPakMenuNumberOfRows)) { - gOpacityDecayTimer = (gMenuCurIndex - sControllerPakMenuNumberOfRows) + 1; - } - if (gMenuCurIndex < gOpacityDecayTimer) { - gOpacityDecayTimer = gMenuCurIndex; - } - temp_v1_2 = 16 - sControllerPakMenuNumberOfRows; - if (temp_v1_2 < gOpacityDecayTimer) { - gOpacityDecayTimer = temp_v1_2; - } - if (gOpacityDecayTimer < 0) { - gOpacityDecayTimer = 0; - } - break; + break; + case 16: + if (yStick > 0) { + gMenuCurIndex = 15; + playMoveSound = TRUE; + } + break; + default: + if (pressedButtons & (A_BUTTON | START_BUTTON)) { + // Check if the selected menu item is a file or blank + if ((sCurrentControllerPakAllFileTypes[gMenuCurIndex] >= SAVE_FILE_TYPE_GAME_DATA) && + (sCurrentControllerPakAllFileTypes[gMenuCurIndex] <= SAVE_FILE_TYPE_UNKNOWN)) { + D_80126C10 = 0; + gMenuOptionCount = 2; + playSelectedSound = TRUE; + } else { + // If it's not, just play the "back" sound + playCancelSound = TRUE; + } + } else { + if (yStick > 0) { + gMenuCurIndex--; + if (gMenuCurIndex < 0) { + gMenuCurIndex = 0; + } else { + playMoveSound = TRUE; + } + } else if (yStick < 0) { + gMenuCurIndex++; + playMoveSound = TRUE; + } + } + if (gMenuCurIndex >= (gOpacityDecayTimer + sControllerPakMenuNumberOfRows)) { + gOpacityDecayTimer = (gMenuCurIndex - sControllerPakMenuNumberOfRows) + 1; + } + if (gMenuCurIndex < gOpacityDecayTimer) { + gOpacityDecayTimer = gMenuCurIndex; + } + temp_v1_2 = 16 - sControllerPakMenuNumberOfRows; + if (temp_v1_2 < gOpacityDecayTimer) { + gOpacityDecayTimer = temp_v1_2; + } + if (gOpacityDecayTimer < 0) { + gOpacityDecayTimer = 0; + } + break; } } } if (playCancelSound) { - //Menu Cancel Sound + // Menu Cancel Sound sound_play(SOUND_MENU_BACK3, NULL); } else if (playSelectedSound) { - //Menu Item Selected Sound + // Menu Item Selected Sound sound_play(SOUND_SELECT2, NULL); } else if (playMoveSound) { - //Menu Moving Sound + // Menu Moving Sound sound_play(SOUND_MENU_PICK2, NULL); } } else { @@ -5113,12 +6001,14 @@ void render_magic_codes_ui(UNUSED s32 updateRate) { render_dialogue_box(&sMenuCurrDisplayList, NULL, NULL, 7); set_text_font(ASSET_FONTS_BIGFONT); set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_MAGICCODES], ALIGN_MIDDLE_CENTER); // "MAGIC CODES" + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_MAGICCODES], + ALIGN_MIDDLE_CENTER); // "MAGIC CODES" set_text_colour(255, 255, 255, 0, 255); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_MAGICCODES], ALIGN_MIDDLE_CENTER); // "MAGIC CODES" + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_MAGICCODES], + ALIGN_MIDDLE_CENTER); // "MAGIC CODES" temp = 'A'; set_text_font(ASSET_FONTS_FUNFONT); - set_text_colour(255, 255, 255, 0, 255); + set_text_colour(255, 255, 255, 0, 255); // Draw the input table for (i = 0, yPos = 60; i < 4; i++, yPos += 22) { for (j = 0, xPos = 64; j < 7; j++, xPos += 32) { @@ -5175,16 +6065,19 @@ void render_magic_codes_ui(UNUSED s32 updateRate) { set_text_background_colour(0, 0, 128, 128); if (gOptionsMenuItemIndex == 4) { if (D_80126C4C == -1) { - draw_text(&sMenuCurrDisplayList, POS_CENTRED, 144, gMenuText[ASSET_MENU_TEXT_BADCODE], ALIGN_MIDDLE_CENTER); //"Sorry, the code was incorrect" + draw_text(&sMenuCurrDisplayList, POS_CENTRED, 144, gMenuText[ASSET_MENU_TEXT_BADCODE], + ALIGN_MIDDLE_CENTER); //"Sorry, the code was incorrect" } else { // Draw cheat code name. cheatData = (*gCheatsAssetData) + 1; - draw_text(&sMenuCurrDisplayList, POS_CENTRED, 144, &((char*)(*gCheatsAssetData))[cheatData[D_80126C4C + 1]], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, POS_CENTRED, 144, + &((char *) (*gCheatsAssetData))[cheatData[D_80126C4C + 1]], ALIGN_MIDDLE_CENTER); } } else if (5 == gOptionsMenuItemIndex) { draw_text(&sMenuCurrDisplayList, POS_CENTRED, 144, D_80126C58, ALIGN_MIDDLE_CENTER); } else if (gOptionsMenuItemIndex == 6) { - draw_text(&sMenuCurrDisplayList, POS_CENTRED, 144, gMenuText[ASSET_MENU_TEXT_ALLCODESDELETED], ALIGN_MIDDLE_CENTER); //"All cheats have been deleted" + draw_text(&sMenuCurrDisplayList, POS_CENTRED, 144, gMenuText[ASSET_MENU_TEXT_ALLCODESDELETED], + ALIGN_MIDDLE_CENTER); //"All cheats have been deleted" } if (gMenuOptionCount != 0) { if (osTvType == TV_TYPE_PAL) { @@ -5268,7 +6161,7 @@ s32 menu_magic_codes_loop(s32 updateRate) { xDir = 0; yDir = 0; if (gIgnorePlayerInputTime == 0 && gMenuDelay == 0) { - for(i = 0; i < MAXCONTROLLERS; i++) { + for (i = 0; i < MAXCONTROLLERS; i++) { buttonsPressed |= get_buttons_pressed_from_player(i); xDir += gControllersXAxisDirection[i]; yDir += gControllersYAxisDirection[i]; @@ -5314,7 +6207,8 @@ s32 menu_magic_codes_loop(s32 updateRate) { someBool2 = TRUE; } else if (gCheatInputStringLength <= 18) { playSelectSound = TRUE; - D_80126C58[gCheatInputStringLength] = (gCheatInputCurrentRow * 7) + gCheatInputCurrentColumn + 'A'; //Convert to upper case? + D_80126C58[gCheatInputStringLength] = + (gCheatInputCurrentRow * 7) + gCheatInputCurrentColumn + 'A'; // Convert to upper case? gCheatInputStringLength++; D_80126C58[gCheatInputStringLength] = '\0'; } @@ -5343,7 +6237,7 @@ s32 menu_magic_codes_loop(s32 updateRate) { } else { cheatDataEntries = &(*gCheatsAssetData)[1]; D_80126C4C = 0; // Index into the gCheatsAssetData cheatsTable - while((D_80126C4C < (gNumberOfCheats * 2)) && !foundCheat) { + while ((D_80126C4C < (gNumberOfCheats * 2)) && !foundCheat) { foundCheat = TRUE; cheatCodeText = ((char *) (*gCheatsAssetData)) + cheatDataEntries[D_80126C4C]; // D_80126C58 = char *gPlayerEnteredCode; (Or something like that) @@ -5353,12 +6247,15 @@ s32 menu_magic_codes_loop(s32 updateRate) { if (cheatCodeText[i] != D_80126C58[i]) { foundCheat = FALSE; } - if(!foundCheat) { - do { } while (0); // Fakematch + if (!foundCheat) { + do { + } while (0); // Fakematch break; } - } while(cheatCodeText[i] != '\0' && D_80126C58[i] != '\0'); - if(foundCheat) continue; + } while (cheatCodeText[i] != '\0' && D_80126C58[i] != '\0'); + if (foundCheat) { + continue; + } D_80126C4C += 2; } if (!foundCheat) { @@ -5380,7 +6277,7 @@ s32 menu_magic_codes_loop(s32 updateRate) { if (gMenuOptionCount == 1) { gActiveMagicCodes = 0; gOptionsMenuItemIndex = 6; - playSelectSound = TRUE; + playSelectSound = TRUE; gUnlockedMagicCodes &= 3; gOpacityDecayTimer = 0xF0; } else { @@ -5448,7 +6345,7 @@ s32 menu_magic_codes_loop(s32 updateRate) { } else if (playPickSound) { sound_play(SOUND_MENU_PICK2, NULL); } - + gIgnorePlayerInputTime = 0; if (gMenuDelay < -30 || gMenuDelay > 30) { unload_big_font_2(); @@ -5478,7 +6375,7 @@ void unload_big_font_2(void) { /** * Initialise the magic list menu. * Sets the max list height based on region, and loads the arrows for scrolling. -*/ + */ void menu_magic_codes_list_init(void) { gOptionBlinkTimer = 0; gMenuDelay = 0; @@ -5506,9 +6403,11 @@ void render_magic_codes_list_menu_text(UNUSED s32 updateRate) { set_text_background_colour(0, 0, 0, 0); set_text_font(ASSET_FONTS_BIGFONT); set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_MAGICCODESLIST], ALIGN_MIDDLE_CENTER); // MAGIC CODES LIST + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_MAGICCODESLIST], + ALIGN_MIDDLE_CENTER); // MAGIC CODES LIST set_text_colour(255, 255, 255, 0, 255); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_MAGICCODESLIST], ALIGN_MIDDLE_CENTER); // MAGIC CODES LIST + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_MAGICCODESLIST], + ALIGN_MIDDLE_CENTER); // MAGIC CODES LIST for (i = 0, code = 1, numOfUnlockedCheats = 0; i < 32; i++, code <<= 1) { if (code & gUnlockedMagicCodes) { @@ -5523,11 +6422,13 @@ void render_magic_codes_list_menu_text(UNUSED s32 updateRate) { } set_text_font(ASSET_FONTS_FUNFONT); set_text_colour(255, 255, 255, 0, 255); - for (i = gMenuOptionCount, cheatData = (*gCheatsAssetData) + 1; (i < gMenuOptionCount + gNumOnscreenMagicCodes) && (i < numOfUnlockedCheats); i++, yPos += 16) { + for (i = gMenuOptionCount, cheatData = (*gCheatsAssetData) + 1; + (i < gMenuOptionCount + gNumOnscreenMagicCodes) && (i < numOfUnlockedCheats); i++, yPos += 16) { if (i == gOptionsMenuItemIndex) { set_text_colour(255, 255, 255, alpha, 255); } - draw_text(&sMenuCurrDisplayList, 48, yPos, (char *) (*gCheatsAssetData) + cheatData[(D_80126C80[i] << 1) + 1], ALIGN_TOP_LEFT); + draw_text(&sMenuCurrDisplayList, 48, yPos, (char *) (*gCheatsAssetData) + cheatData[(D_80126C80[i] << 1) + 1], + ALIGN_TOP_LEFT); if ((1 << D_80126C80[i]) & gActiveMagicCodes) { draw_text(&sMenuCurrDisplayList, 256, yPos, gMenuText[ASSET_MENU_TEXT_ON], ALIGN_TOP_LEFT); // ON } else { @@ -5541,11 +6442,13 @@ void render_magic_codes_list_menu_text(UNUSED s32 updateRate) { if (numOfUnlockedCheats == gOptionsMenuItemIndex) { set_text_colour(255, 255, 255, alpha, 255); } - draw_text(&sMenuCurrDisplayList, POS_CENTRED, yPos, gMenuText[ASSET_MENU_TEXT_RETURN], ALIGN_TOP_CENTER); // RETURN + draw_text(&sMenuCurrDisplayList, POS_CENTRED, yPos, gMenuText[ASSET_MENU_TEXT_RETURN], + ALIGN_TOP_CENTER); // RETURN return; } if (gOptionBlinkTimer & 8) { - render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowDown, SCREEN_WIDTH_HALF, yPos + 8, 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowDown, SCREEN_WIDTH_HALF, yPos + 8, 255, 255, + 255, 255); } } @@ -5600,25 +6503,31 @@ s32 menu_magic_codes_list_loop(s32 updateRate) { if (((xAxis < 0) || (xAxis > 0)) && (numUnlockedCodes != gOptionsMenuItemIndex)) { sound_play(SOUND_SELECT2, NULL); code = 1 << D_80126C80[gOptionsMenuItemIndex]; - gActiveMagicCodes ^= code; // Toggle active cheats? + gActiveMagicCodes ^= code; // Toggle active cheats? func_8008A8F8(code, 0x10, CHEAT_SMALL_CHARACTERS); // func_8008A8F8() = Clear flags? func_8008A8F8(code, 0x20, CHEAT_BIG_CHARACTERS); - func_8008A8F8(code, 0x1000, (CHEAT_NO_LIMIT_TO_BANANAS | CHEAT_BANANAS_REDUCE_SPEED | CHEAT_START_WITH_10_BANANAS)); + func_8008A8F8(code, 0x1000, + (CHEAT_NO_LIMIT_TO_BANANAS | CHEAT_BANANAS_REDUCE_SPEED | CHEAT_START_WITH_10_BANANAS)); func_8008A8F8(code, 0x6080, CHEAT_DISABLE_BANANAS); - func_8008A8F8(code, 0x800, (CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | - CHEAT_ALL_BALLOONS_ARE_BLUE | CHEAT_ALL_BALLOONS_ARE_YELLOW | - CHEAT_ALL_BALLOONS_ARE_RAINBOW | CHEAT_MAXIMUM_POWER_UP)); + func_8008A8F8(code, 0x800, + (CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | CHEAT_ALL_BALLOONS_ARE_BLUE | + CHEAT_ALL_BALLOONS_ARE_YELLOW | CHEAT_ALL_BALLOONS_ARE_RAINBOW | CHEAT_MAXIMUM_POWER_UP)); func_8008A8F8(code, 0x1F8000, CHEAT_DISABLE_WEAPONS); - func_8008A8F8(code, 0x8000, (CHEAT_ALL_BALLOONS_ARE_GREEN | CHEAT_ALL_BALLOONS_ARE_BLUE | - CHEAT_ALL_BALLOONS_ARE_YELLOW | CHEAT_ALL_BALLOONS_ARE_RAINBOW)); - func_8008A8F8(code, 0x10000, (CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_BLUE | - CHEAT_ALL_BALLOONS_ARE_YELLOW | CHEAT_ALL_BALLOONS_ARE_RAINBOW)); - func_8008A8F8(code, 0x20000, (CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | - CHEAT_ALL_BALLOONS_ARE_YELLOW | CHEAT_ALL_BALLOONS_ARE_RAINBOW)); - func_8008A8F8(code, 0x40000, (CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | - CHEAT_ALL_BALLOONS_ARE_BLUE | CHEAT_ALL_BALLOONS_ARE_RAINBOW)); - func_8008A8F8(code, 0x80000, (CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | - CHEAT_ALL_BALLOONS_ARE_BLUE | CHEAT_ALL_BALLOONS_ARE_YELLOW)); + func_8008A8F8(code, 0x8000, + (CHEAT_ALL_BALLOONS_ARE_GREEN | CHEAT_ALL_BALLOONS_ARE_BLUE | CHEAT_ALL_BALLOONS_ARE_YELLOW | + CHEAT_ALL_BALLOONS_ARE_RAINBOW)); + func_8008A8F8(code, 0x10000, + (CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_BLUE | CHEAT_ALL_BALLOONS_ARE_YELLOW | + CHEAT_ALL_BALLOONS_ARE_RAINBOW)); + func_8008A8F8(code, 0x20000, + (CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | CHEAT_ALL_BALLOONS_ARE_YELLOW | + CHEAT_ALL_BALLOONS_ARE_RAINBOW)); + func_8008A8F8(code, 0x40000, + (CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | CHEAT_ALL_BALLOONS_ARE_BLUE | + CHEAT_ALL_BALLOONS_ARE_RAINBOW)); + func_8008A8F8(code, 0x80000, + (CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | CHEAT_ALL_BALLOONS_ARE_BLUE | + CHEAT_ALL_BALLOONS_ARE_YELLOW)); } previousMenuItemIndex = gOptionsMenuItemIndex; @@ -5672,8 +6581,8 @@ void func_8008AD1C(void) { } void calculate_and_display_rom_checksum(void) { - static u32 cksum=0; - static u32 calculated=0; + static u32 cksum = 0; + static u32 calculated = 0; s32 blockOffs; s32 size; s32 numBytes, numLeft; @@ -5712,25 +6621,19 @@ void calculate_and_display_rom_checksum(void) { render_printf(gROMChecksum, cksum, numLeft); // gROMChecksum = "ROM checksum %08X,%d\n" } -//These vars have to be defined after calculate_and_display_rom_checksum since that function has a static var in it. +// These vars have to be defined after calculate_and_display_rom_checksum since that function has a static var in it. s32 D_800E1E1C = 0; -s8 D_800E1E20[8] = { - 0, -1, 1, 0, 0, 1, -1, 0 -}; +s8 D_800E1E20[8] = { 0, -1, 1, 0, 0, 1, -1, 0 }; s8 D_800E1E28 = 0; // TT Game Status textures, think these are potentially multi-part images. -s16 D_800E1E2C[10] = { - 0x4C, 0x4D, 0x4E, 0x4F, 0x5B, 0x5C, 0x00, 0x42, -1, 0 -}; +s16 D_800E1E2C[10] = { 0x4C, 0x4D, 0x4E, 0x4F, 0x5B, 0x5C, 0x00, 0x42, -1, 0 }; // TT game status textures. And these maybe just standalone ones. -s16 D_800E1E40[10] = { - 0x0D, 0x0E, 0x0F, 0x10, 0x08, 0x09, 0x00, 0x0A, -1, 0 -}; +s16 D_800E1E40[10] = { 0x0D, 0x0E, 0x0F, 0x10, 0x08, 0x09, 0x00, 0x0A, -1, 0 }; void func_8008AEB4(s32 arg0, s32 *arg1) { switch (arg0) { @@ -5769,7 +6672,7 @@ void set_active_player_index(s32 controllerIndex) { /** * Initialises the character select menu. Checks which characters are available and sets the vars used for selection. * Sets up sound channels with the background music based on which characters are selected. -*/ + */ void menu_character_select_init(void) { s32 breakTheLoop; s32 i; @@ -5779,14 +6682,14 @@ void menu_character_select_init(void) { initialise_player_ids(); if (is_drumstick_unlocked()) { if (is_tt_unlocked()) { - gCurrCharacterSelectData = (CharacterSelectData (*)[10]) &gCharacterSelectBytesComplete; + gCurrCharacterSelectData = (CharacterSelectData(*)[10]) & gCharacterSelectBytesComplete; } else { - gCurrCharacterSelectData = (CharacterSelectData (*)[10]) &gCharacterSelectBytesDrumStick; + gCurrCharacterSelectData = (CharacterSelectData(*)[10]) & gCharacterSelectBytesDrumStick; } } else if (is_tt_unlocked()) { - gCurrCharacterSelectData = (CharacterSelectData (*)[10]) &gCharacterSelectBytesTT; + gCurrCharacterSelectData = (CharacterSelectData(*)[10]) & gCharacterSelectBytesTT; } else { - gCurrCharacterSelectData = (CharacterSelectData (*)[10]) &gCharacterSelectBytesDefault; + gCurrCharacterSelectData = (CharacterSelectData(*)[10]) & gCharacterSelectBytesDefault; } for (i = 0; i < ARRAY_COUNT(D_801263DC); i++) { D_801263DC[i] = 0; @@ -5835,16 +6738,19 @@ void draw_character_select_text(UNUSED s32 arg0) { set_text_background_colour(0, 0, 0, 0); set_text_colour(0, 0, 0, 255, 128); // Draw "Player Select" text drop shadow - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_PLAYERSELECT], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_PLAYERSELECT], + ALIGN_MIDDLE_CENTER); set_text_colour(255, 255, 255, 0, 255); // Draw "Player Select" text - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_PLAYERSELECT], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_PLAYERSELECT], + ALIGN_MIDDLE_CENTER); if (gNumberOfReadyPlayers == gNumberOfActivePlayers && gNumberOfActivePlayers > 0) { yPos = 208; if (osTvType == TV_TYPE_PAL) { yPos = 234; } - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, (char *) D_800E8230 /* "OK?" */, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, (char *) D_800E8230 /* "OK?" */, + ALIGN_MIDDLE_CENTER); } reset_render_settings(&sMenuCurrDisplayList); update_camera_fov(40.0f); @@ -5857,7 +6763,7 @@ void func_8008B358(void) { s32 var_a0; s32 var_a2; - for(i = 0; i < MAXCONTROLLERS; i++) { + for (i = 0; i < MAXCONTROLLERS; i++) { if (!gActivePlayersArray[i]) { var_a2 = -1; if (D_801267D8[i] & (A_BUTTON | START_BUTTON)) { @@ -5895,12 +6801,12 @@ void func_8008B4C8(void) { } if (buttonsPressedAllPlayers & (A_BUTTON | START_BUTTON)) { - //Character Selected + // Character Selected gMenuDelay = 1; mark_read_all_save_files(); transition_begin(&sMenuTransitionFadeIn); characterSelected = -1; - //!@bug: This loop condition is doing a bitwise & instead of a boolean && + //!@bug: This loop condition is doing a bitwise & instead of a boolean && for (i = 0; (i < MAXCONTROLLERS) & (characterSelected < 0); i++) { if (D_801267D8[i] & (A_BUTTON | START_BUTTON)) { characterSelected = i; @@ -5909,12 +6815,16 @@ void func_8008B4C8(void) { if (D_80126808[characterSelected] != 0) { func_8000488C(D_80126808[characterSelected]); } - sound_play(((*gCurrCharacterSelectData)[gPlayersCharacterArray[characterSelected]].voiceID + SOUND_VOICE_CHARACTER_SELECTED), &D_80126808[characterSelected]); - if ((gNumberOfActivePlayers > 2) || ((gNumberOfActivePlayers > 1) && !(gActiveMagicCodes & CHEAT_TWO_PLAYER_ADVENTURE)) || (gEnteredCharSelectFrom == 1)) { + sound_play(((*gCurrCharacterSelectData)[gPlayersCharacterArray[characterSelected]].voiceID + + SOUND_VOICE_CHARACTER_SELECTED), + &D_80126808[characterSelected]); + if ((gNumberOfActivePlayers > 2) || + ((gNumberOfActivePlayers > 1) && !(gActiveMagicCodes & CHEAT_TWO_PLAYER_ADVENTURE)) || + (gEnteredCharSelectFrom == 1)) { music_fade(-128); } } else { - //Character Deselected + // Character Deselected for (i = 0; i < ARRAY_COUNT(gActivePlayersArray); i++) { if (gActivePlayersArray[i] && D_801263DC[i] != 0) { if (D_801267D8[i] & B_BUTTON) { @@ -5923,7 +6833,9 @@ void func_8008B4C8(void) { if (D_80126808[i] != 0) { func_8000488C(D_80126808[i]); } - sound_play(((*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID + SOUND_VOICE_CHARACTER_DESELECTED), &D_80126808[i]); + sound_play(((*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID + + SOUND_VOICE_CHARACTER_DESELECTED), + &D_80126808[i]); } } } @@ -5945,19 +6857,23 @@ void func_8008B758(s8 *activePlayers) { if (D_80126808[i] != 0) { func_8000488C(D_80126808[i]); } - sound_play(((*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID + SOUND_VOICE_CHARACTER_DESELECTED), &D_80126808[i]); + sound_play(((*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID + + SOUND_VOICE_CHARACTER_DESELECTED), + &D_80126808[i]); } } else { if (D_801267D8[i] & B_BUTTON) { gNumberOfActivePlayers--; gActivePlayersArray[i] = 0; if (gNumberOfActivePlayers > 0) { - if (gMenuSelectedCharacter.channelIndex == (*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID) { + if (gMenuSelectedCharacter.channelIndex == + (*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID) { if (gMenuCurrentCharacter.unk1 <= 0) { for (found = FALSE, j = 0; j < ARRAY_COUNT(gActivePlayersArray) && !found; j++) { if (gActivePlayersArray[j]) { found = TRUE; - gMenuCurrentCharacter.channelIndex = (*gCurrCharacterSelectData)[gPlayersCharacterArray[j]].voiceID; + gMenuCurrentCharacter.channelIndex = + (*gCurrCharacterSelectData)[gPlayersCharacterArray[j]].voiceID; gMenuCurrentCharacter.unk2 = 0; gMenuCurrentCharacter.unk1 = 20; } @@ -5976,20 +6892,27 @@ void func_8008B758(s8 *activePlayers) { if (D_80126808[i] != 0) { func_8000488C(D_80126808[i]); } - sound_play(((*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID + SOUND_VOICE_CHARACTER_SELECT), &D_80126808[i]); + sound_play( + ((*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID + SOUND_VOICE_CHARACTER_SELECT), + &D_80126808[i]); } else { charSelectData = (*gCurrCharacterSelectData) + gPlayersCharacterArray[i]; if (D_80126830[i] > 0) { - func_8008BFE8(i, charSelectData->upInput, ARRAY_COUNT(charSelectData->upInput), SOUND_MENU_PICK3, SOUND_HORN_DRUMSTICK); + func_8008BFE8(i, charSelectData->upInput, ARRAY_COUNT(charSelectData->upInput), + SOUND_MENU_PICK3, SOUND_HORN_DRUMSTICK); } else if (D_80126830[i] < 0) { - func_8008BFE8(i, charSelectData->downInput, ARRAY_COUNT(charSelectData->downInput), SOUND_MENU_PICK3, SOUND_HORN_DRUMSTICK); + func_8008BFE8(i, charSelectData->downInput, ARRAY_COUNT(charSelectData->downInput), + SOUND_MENU_PICK3, SOUND_HORN_DRUMSTICK); } else if (D_80126818[i] < 0) { - func_8008BFE8(i, charSelectData->rightInput, ARRAY_COUNT(charSelectData->rightInput), SOUND_MENU_PICK3, SOUND_HORN_DRUMSTICK); + func_8008BFE8(i, charSelectData->rightInput, ARRAY_COUNT(charSelectData->rightInput), + SOUND_MENU_PICK3, SOUND_HORN_DRUMSTICK); } else if (D_80126818[i] > 0) { - func_8008BFE8(i, charSelectData->leftInput, ARRAY_COUNT(charSelectData->leftInput), SOUND_MENU_PICK3, SOUND_HORN_DRUMSTICK); + func_8008BFE8(i, charSelectData->leftInput, ARRAY_COUNT(charSelectData->leftInput), + SOUND_MENU_PICK3, SOUND_HORN_DRUMSTICK); } if (charSelectData->voiceID != (*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID) { - gMenuCurrentCharacter.channelIndex = (*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID; + gMenuCurrentCharacter.channelIndex = + (*gCurrCharacterSelectData)[gPlayersCharacterArray[i]].voiceID; gMenuCurrentCharacter.unk2 = 0; gMenuCurrentCharacter.unk1 = 20; } @@ -6055,8 +6978,10 @@ s32 menu_character_select_loop(s32 updateRate) { } gIgnorePlayerInputTime = 0; if (gMenuDelay == 0) { + // clang-format off // THIS MUST BE ON ONE LINE! for (i = 0; i < ARRAY_COUNT(gActivePlayersArray); i++) { activePlayers[i] = gActivePlayersArray[i]; } + // clang-format on func_8008B358(); if (gNumberOfReadyPlayers == gNumberOfActivePlayers) { func_8008B4C8(); // Cancel/Confirm selected character? @@ -6180,7 +7105,8 @@ void func_8008C168(s32 updateRate) { gMenuSelectedCharacter.unk2 = 127; } music_channel_fade_set(gCharacterVolumes[gMenuSelectedCharacter.channelIndex][0], gMenuSelectedCharacter.unk2); - music_channel_fade_set(gCharacterVolumes[0][gMenuSelectedCharacter.channelIndex * 2 + 1], gMenuSelectedCharacter.unk3); + music_channel_fade_set(gCharacterVolumes[0][gMenuSelectedCharacter.channelIndex * 2 + 1], + gMenuSelectedCharacter.unk3); } if (D_801263B8.channelIndex >= 0) { D_801263B8.unk2 -= updateRate * 4; @@ -6218,7 +7144,8 @@ void menu_caution_init(void) { s32 menu_caution_loop(s32 updateRate) { if (gMenuDelay) { gMenuDelay += updateRate; - } else if (gIgnorePlayerInputTime <= 0 && (get_buttons_pressed_from_player(PLAYER_ONE) & (A_BUTTON | B_BUTTON | START_BUTTON))) { + } else if (gIgnorePlayerInputTime <= 0 && + (get_buttons_pressed_from_player(PLAYER_ONE) & (A_BUTTON | B_BUTTON | START_BUTTON))) { sound_play(SOUND_SELECT2, NULL); gMenuDelay = 1; transition_begin(&sMenuTransitionFadeIn); @@ -6246,7 +7173,7 @@ void unload_big_font_3(void) { /** * Initialises the selection menu that contains the options for adventure one, two and tracks mode. * Loads all save file data to determine whether to show adventure two. -*/ + */ void menu_game_select_init(void) { s32 i; @@ -6281,7 +7208,7 @@ void menu_game_select_init(void) { } for (i = 0; i <= gMenuOptionCount; i++) { - //Fakematch? What's the (i ^ 0)? + // Fakematch? What's the (i ^ 0)? gGameSelectElements[((i ^ 0) * 2) + 2].unk14_a.texture = gMenuObjects[TEXTURE_SURFACE_BUTTON_WOOD]; } } @@ -6304,7 +7231,7 @@ void func_8008C698(UNUSED s32 updateRate) { if (i == gMenuCurIndex) { filterBlendFactor = fade; } - //Fakematch? What's the (i ^ 0)? + // Fakematch? What's the (i ^ 0)? gGameSelectElements[((i ^ 0) * 2) + 3].filterBlendFactor = filterBlendFactor; } @@ -6350,7 +7277,7 @@ s32 menu_game_select_loop(s32 updateRate) { music_change_on(); gIsInTracksMode = TRUE; init_racer_headers(); - load_level_for_menu((s32)SPECIAL_MAP_ID_NO_LEVEL, -1, 0); + load_level_for_menu((s32) SPECIAL_MAP_ID_NO_LEVEL, -1, 0); menu_init(MENU_TRACK_SELECT); } else { gIsInAdventureTwo = gMenuCurIndex; @@ -6422,7 +7349,7 @@ void func_8008CACC(void) { /** * Initialises the file selection menu. Loads the relevant textures for the menu. * Sets the audio channels to match the selected character. -*/ + */ void menu_file_select_init(void) { s32 i; UNUSED s32 numLevels; @@ -6463,7 +7390,7 @@ void render_menu_image(s32 imageID, s32 xOffset, s32 yOffset, s32 red, s32 green s32 tempGreen = sMenuGuiColourG; s32 tempBlue = sMenuGuiColourB; s32 tempOpacity = sMenuGuiOpacity; -// This first section is the shadow + // This first section is the shadow sMenuGuiColourR = red; sMenuGuiColourG = green; sMenuGuiColourB = blue; @@ -6471,7 +7398,7 @@ void render_menu_image(s32 imageID, s32 xOffset, s32 yOffset, s32 red, s32 green gMenuImageStack[imageID].unkC = xOffset - 159; gMenuImageStack[imageID].unk10 = 119 - yOffset; func_8009CA60(imageID); -// And this then draws it again, with colour + // And this then draws it again, with colour sMenuGuiColourR = tempRed; sMenuGuiColourG = tempGreen; sMenuGuiColourB = tempBlue; @@ -6504,8 +7431,9 @@ void render_file_select_menu(UNUSED s32 updateRate) { } else { colour = COLOUR_RGBA32(106, 144, 115, 255); } - func_80080580(NULL, gFileSelectButtons[i].x - SCREEN_WIDTH_HALF, SCREEN_HEIGHT_HALF - gFileSelectButtons[i].y, gFileSelectButtons[i].width, - gFileSelectButtons[i].height, gFileSelectButtons[i].borderWidth, gFileSelectButtons[i].borderHeight, colour, gMenuObjects[TEXTURE_SURFACE_BUTTON_WOOD]); + func_80080580(NULL, gFileSelectButtons[i].x - SCREEN_WIDTH_HALF, SCREEN_HEIGHT_HALF - gFileSelectButtons[i].y, + gFileSelectButtons[i].width, gFileSelectButtons[i].height, gFileSelectButtons[i].borderWidth, + gFileSelectButtons[i].borderHeight, colour, gMenuObjects[TEXTURE_SURFACE_BUTTON_WOOD]); } func_80080BC8(&sMenuCurrDisplayList); if (gOpacityDecayTimer == 0) { @@ -6518,22 +7446,28 @@ void render_file_select_menu(UNUSED s32 updateRate) { if (gSavefileInfo[i].isAdventure2) { var_s2 = 12; } - render_menu_image(var_s2, gFileSelectButtons[i].x + gFileSelectElementPos[2], gFileSelectButtons[i].y + gFileSelectElementPos[3], 0, 0, 0, 128); + render_menu_image(var_s2, gFileSelectButtons[i].x + gFileSelectElementPos[2], + gFileSelectButtons[i].y + gFileSelectElementPos[3], 0, 0, 0, 128); func_80068508(TRUE); gMenuImageStack->unk18 = gSavefileInfo[i].balloonCount / 10; - render_menu_image(0, gFileSelectButtons[i].x + gFileSelectElementPos[6] - 6, gFileSelectButtons[i].y + gFileSelectElementPos[7], 0, 0, 0, 128); + render_menu_image(0, gFileSelectButtons[i].x + gFileSelectElementPos[6] - 6, + gFileSelectButtons[i].y + gFileSelectElementPos[7], 0, 0, 0, 128); gMenuImageStack->unk18 = gSavefileInfo[i].balloonCount % 10; - render_menu_image(0, gFileSelectButtons[i].x + gFileSelectElementPos[6] + 6, gFileSelectButtons[i].y + gFileSelectElementPos[7], 0, 0, 0, 128); + render_menu_image(0, gFileSelectButtons[i].x + gFileSelectElementPos[6] + 6, + gFileSelectButtons[i].y + gFileSelectElementPos[7], 0, 0, 0, 128); func_80068508(FALSE); sMenuGuiColourG = 64; sMenuGuiColourB = 64; - render_menu_image(10, gFileSelectButtons[i].x + gFileSelectElementPos[8], gFileSelectButtons[i].y + gFileSelectElementPos[9], 0, 0, 0, 128); + render_menu_image(10, gFileSelectButtons[i].x + gFileSelectElementPos[8], + gFileSelectButtons[i].y + gFileSelectElementPos[9], 0, 0, 0, 128); sMenuGuiColourG = 255; sMenuGuiColourB = 255; sprite_opaque(TRUE); } else { set_text_colour(255, 255, 255, 64, 255); - draw_text(&sMenuCurrDisplayList, gFileSelectButtons[i].x + gFileSelectElementPos[4], gFileSelectButtons[i].y + gFileSelectElementPos[5] + yPos, gMenuText[ASSET_MENU_TEXT_NEW], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, gFileSelectButtons[i].x + gFileSelectElementPos[4], + gFileSelectButtons[i].y + gFileSelectElementPos[5] + yPos, gMenuText[ASSET_MENU_TEXT_NEW], + ALIGN_MIDDLE_CENTER); } } } @@ -6561,8 +7495,9 @@ void render_file_select_menu(UNUSED s32 updateRate) { } if (var_s2) { colour = temp | ~0xFF; - func_80080E90(&sMenuCurrDisplayList, gFileSelectButtons[i].x, gFileSelectButtons[i].y + yPos, gFileSelectButtons[i].width, gFileSelectButtons[i].height, - gFileSelectButtons[i].borderWidth, gFileSelectButtons[i].borderHeight, colour, colour, colour, colour); + func_80080E90(&sMenuCurrDisplayList, gFileSelectButtons[i].x, gFileSelectButtons[i].y + yPos, + gFileSelectButtons[i].width, gFileSelectButtons[i].height, gFileSelectButtons[i].borderWidth, + gFileSelectButtons[i].borderHeight, colour, colour, colour, colour); } if (!D_80126CC0 || i != gSaveFileIndex) { trim_filename_string(gSavefileInfo[i].name, trimmedFilename); @@ -6570,16 +7505,16 @@ void render_file_select_menu(UNUSED s32 updateRate) { trim_filename_string(gFilenames[i], trimmedFilename); } if (trimmedFilename) { - draw_text(&sMenuCurrDisplayList, - gFileSelectButtons[i].x + gFileSelectElementPos[0], - gFileSelectButtons[i].y + gFileSelectElementPos[1] + yPos, - trimmedFilename, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, gFileSelectButtons[i].x + gFileSelectElementPos[0], + gFileSelectButtons[i].y + gFileSelectElementPos[1] + yPos, trimmedFilename, + ALIGN_MIDDLE_CENTER); } } } set_text_font(ASSET_FONTS_BIGFONT); set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 19, gMenuText[ASSET_MENU_TEXT_GAMESELECT], ALIGN_TOP_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 19, gMenuText[ASSET_MENU_TEXT_GAMESELECT], + ALIGN_TOP_CENTER); set_text_colour(255, 255, 255, 0, 255); draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 16, gMenuText[ASSET_MENU_TEXT_GAMESELECT], ALIGN_TOP_CENTER); set_text_colour(255, 255, 255, 0, 255); @@ -6587,19 +7522,24 @@ void render_file_select_menu(UNUSED s32 updateRate) { if (D_80126484) { if (D_80126494 == 0) { set_text_font(ASSET_FONTS_FUNFONT); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, gMenuText[ASSET_MENU_TEXT_GAMETOCOPY], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, gMenuText[ASSET_MENU_TEXT_GAMETOCOPY], + ALIGN_MIDDLE_CENTER); } else if (D_80126494 == 1) { set_text_font(ASSET_FONTS_FUNFONT); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, gMenuText[ASSET_MENU_TEXT_GAMETOCOPYTO], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, gMenuText[ASSET_MENU_TEXT_GAMETOCOPYTO], + ALIGN_MIDDLE_CENTER); } else { - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, (char *) &D_800E8234 /* "OK?" */, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, (char *) &D_800E8234 /* "OK?" */, + ALIGN_MIDDLE_CENTER); } } else if (D_80126488) { if (D_80126494 == 0) { set_text_font(ASSET_FONTS_FUNFONT); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, gMenuText[ASSET_MENU_TEXT_GAMETOERASE], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, gMenuText[ASSET_MENU_TEXT_GAMETOERASE], + ALIGN_MIDDLE_CENTER); } else { - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, (char *) &D_800E8238 /* "OK?" */, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos, (char *) &D_800E8238 /* "OK?" */, + ALIGN_MIDDLE_CENTER); } } else if (!D_80126CC0) { if (gMenuOptionCount == 1) { @@ -6826,14 +7766,14 @@ void func_8008DC7C(UNUSED s32 updateRate) { temp = gSaveFileIndex3; - //Left + // Left if (controllerXAxisDirection < 0) { if (gSaveFileIndex3 > 0) { gSaveFileIndex3--; } } - //Right + // Right if (controllerXAxisDirection > 0) { if (gSaveFileIndex3 < 2) { gSaveFileIndex3++; @@ -6874,7 +7814,7 @@ s32 menu_file_select_loop(s32 updateRate) { func_8008C168(updateRate); if (gOpacityDecayTimer) { gOpacityDecayTimer++; - + if (gOpacityDecayTimer >= 3) { for (i = 0; i < NUMBER_OF_SAVE_FILES; i++) { gSavefileInfo[i].isAdventure2 = 0; @@ -6953,7 +7893,8 @@ s32 menu_file_select_loop(s32 updateRate) { i = 12; } func_80097874(i + 187, gFileSelectButtons[gSaveFileIndex].x + gFileSelectElementPos[0], - gFileSelectButtons[gSaveFileIndex].y + gFileSelectElementPos[1] + i, 0, &gIndexOfCurInputCharacter, gSavefileInfo[gSaveFileIndex].name, 3); + gFileSelectButtons[gSaveFileIndex].y + gFileSelectElementPos[1] + i, 0, + &gIndexOfCurInputCharacter, gSavefileInfo[gSaveFileIndex].name, 3); currentMenuDelay = 0; } } @@ -6999,8 +7940,7 @@ s32 menu_file_select_loop(s32 updateRate) { func_8008E428(); menu_init(MENU_GAME_SELECT); return MENU_RESULT_CONTINUE; - } - else { + } else { return MENU_RESULT_CONTINUE; } } @@ -7013,7 +7953,7 @@ void func_8008E428(void) { /** * Set the texture IDs of the vehicle ID elements. -*/ + */ void assign_vehicle_icon_textures(void) { gRaceSelectionCarTex[0].texture = gMenuObjects[TEXTURE_ICON_VEHICLE_CAR_TOP]; gRaceSelectionCarTex[1].texture = gMenuObjects[TEXTURE_ICON_VEHICLE_CAR_BOTTOM]; @@ -7025,7 +7965,7 @@ void assign_vehicle_icon_textures(void) { /** * Set the texture IDs of the menu arrow elements. -*/ + */ void assign_menu_arrow_textures(void) { gMenuSelectionArrowUp[0].texture = gMenuObjects[TEXTURE_ICON_ARROW_UP]; gMenuSelectionArrowLeft[0].texture = gMenuObjects[TEXTURE_ICON_ARROW_LEFT]; @@ -7038,12 +7978,12 @@ void func_8008E4EC(void) { s32 buttonsPressed[ARRAY_COUNT(D_80126818)]; if (gIgnorePlayerInputTime == 0) { - for(i = 0; i < ARRAY_COUNT(D_80126818); i++) { + for (i = 0; i < ARRAY_COUNT(D_80126818); i++) { buttonsPressed[i] = 0; D_80126818[i] = 0; D_80126830[i] = 0; } - for(i = 0; i < MAXCONTROLLERS; i++) { + for (i = 0; i < MAXCONTROLLERS; i++) { buttonsPressed[i] = get_buttons_held_from_player(i); D_80126818[i] = gControllersXAxisDirection[i]; D_80126830[i] = gControllersYAxisDirection[i]; @@ -7053,13 +7993,13 @@ void func_8008E4EC(void) { D_80126830[ARRAY_COUNT(D_80126818) - 1] += gControllersYAxisDirection[i]; } } - for(i = 0; i < ARRAY_COUNT(D_80126818); i++) { + for (i = 0; i < ARRAY_COUNT(D_80126818); i++) { D_801267D8[i] = buttonsPressed[i] & ~D_801267F0[i]; D_801267F0[i] = buttonsPressed[i]; } return; } - for(i = 0; i < ARRAY_COUNT(D_80126818); i++) { + for (i = 0; i < ARRAY_COUNT(D_80126818); i++) { D_801267F0[i] = (START_BUTTON | B_BUTTON | A_BUTTON); D_801267D8[i] = 0; D_80126818[i] = 0; @@ -7138,9 +8078,9 @@ void menu_track_select_init(void) { } } gTrackSelectBgTriangles[0] = (Triangle *) allocate_from_main_pool_safe(2880, COLOUR_TAG_YELLOW); - gTrackSelectBgTriangles[1] = (s32) (&gTrackSelectBgTriangles[0][40]); //640 bytes forward - gTrackSelectBgVertices[0] = (s32) (&gTrackSelectBgTriangles[1][80]); //1280 bytes forward - //gTrackSelectBgVertices[1] = (s32) (&gTrackSelectBgVertices[0][80]); //800 bytes past gTrackSelectBgVertices + gTrackSelectBgTriangles[1] = (s32) (&gTrackSelectBgTriangles[0][40]); // 640 bytes forward + gTrackSelectBgVertices[0] = (s32) (&gTrackSelectBgTriangles[1][80]); // 1280 bytes forward + // gTrackSelectBgVertices[1] = (s32) (&gTrackSelectBgVertices[0][80]); //800 bytes past gTrackSelectBgVertices var_a0 = -160; var_v0 = 0; for (var_v0 = 0; var_v0 < 80; var_v0++) { @@ -7159,7 +8099,8 @@ void menu_track_select_init(void) { } D_80126924 = 0; set_background_draw_function(func_8008F618); - viewport_menu_set(0, 80, gTrackSelectViewPortHalfY - (gTrackSelectViewPortHalfY >> 1), SCREEN_HEIGHT, (gTrackSelectViewPortHalfY >> 1) + gTrackSelectViewPortHalfY); + viewport_menu_set(0, 80, gTrackSelectViewPortHalfY - (gTrackSelectViewPortHalfY >> 1), SCREEN_HEIGHT, + (gTrackSelectViewPortHalfY >> 1) + gTrackSelectViewPortHalfY); copy_viewports_to_stack(); camEnableUserView(0, 0); gIsInTracksMenu = TRUE; @@ -7182,8 +8123,7 @@ void menu_track_select_init(void) { if (idx < 4) { *var_s2 = trackMenuIds[idx][idx2]; } - } - else if (idx2 < 4) { + } else if (idx2 < 4) { if ((trackMenuIds[idx][idx2] != -1) && (settings->courseFlagsPtr[trackMenuIds[idx][idx2]] & 1)) { *var_s2 = trackMenuIds[idx][idx2]; } @@ -7191,7 +8131,8 @@ void menu_track_select_init(void) { var_a1_2 = 0; // This is almost definitely wrong. for (var_a0_2 = 0; var_a0_2 < 2; var_a0_2++) { - if ((trackMenuIds[idx][var_a0_2] != -1) && ((settings->courseFlagsPtr[trackMenuIds[idx][var_a0_2]] & 6) == 6)) { + if ((trackMenuIds[idx][var_a0_2] != -1) && + ((settings->courseFlagsPtr[trackMenuIds[idx][var_a0_2]] & 6) == 6)) { var_a1_2++; } } @@ -7247,10 +8188,10 @@ void func_8008F00C(s32 arg0) { if ((D_801267D0 != -1) && (D_801267D0 != 0) && (D_801267D0 == 1)) { func_8009C4A8(gTrackSelectPreviewObjectIndices); } - + D_801267D0 = arg0; temp = D_801267D0; - + if ((temp >= 0) && (temp < 2)) { switch (D_801267D0) { case 0: @@ -7274,7 +8215,8 @@ void func_8008F00C(s32 arg0) { gRaceSelectionTTOff[1].texture = gMenuObjects[TEXTURE_ICON_TIMETRIAL_OFF_BOTTOM]; gRaceSelectionCarOptHighlight[0].texture = gMenuObjects[TEXTURE_ICON_VEHICLE_SELECT_CAR_HIGHLIGHT]; gRaceSelectionCarOpt[0].texture = gMenuObjects[TEXTURE_ICON_VEHICLE_SELECT_CAR]; - gRaceSelectionHoverOptHighlight[0].texture = gMenuObjects[TEXTURE_ICON_VEHICLE_SELECT_HOVERCRAFT_HIGHLIGHT]; + gRaceSelectionHoverOptHighlight[0].texture = + gMenuObjects[TEXTURE_ICON_VEHICLE_SELECT_HOVERCRAFT_HIGHLIGHT]; gRaceSelectionHoverOpt[0].texture = gMenuObjects[TEXTURE_ICON_VEHICLE_SELECT_HOVERCRAFT]; gRaceSelectionPlaneOptHighlight[0].texture = gMenuObjects[TEXTURE_ICON_VEHICLE_SELECT_PLANE_HIGHLIGHT]; gRaceSelectionPlaneOpt[0].texture = gMenuObjects[TEXTURE_ICON_VEHICLE_SELECT_PLANE]; @@ -7332,12 +8274,13 @@ s32 menu_track_select_loop(s32 updateRate) { if (sMenuMusicVolume >= 81) { sMenuMusicVolume = 80; } - music_volume_set((u8)sMenuMusicVolume); + music_volume_set((u8) sMenuMusicVolume); } if (D_801267D0 < 0) { func_8008F534(); gTrackSpecifiedWithTrackIdToLoad = 0; - if (gNumberOfActivePlayers >= 3 || (gNumberOfActivePlayers == 2 && !(gActiveMagicCodes & CHEAT_TWO_PLAYER_ADVENTURE))) { + if (gNumberOfActivePlayers >= 3 || + (gNumberOfActivePlayers == 2 && !(gActiveMagicCodes & CHEAT_TWO_PLAYER_ADVENTURE))) { cutsceneId = 0; if (is_drumstick_unlocked()) { cutsceneId = 1; @@ -7421,25 +8364,27 @@ s32 func_8008F618(Gfx **dlist, MatrixS **mtx) { TextureHeader *bgTexture; s32 prevAlpha2; s32 curIndex; - + numVertices = 0; - camDisableUserView(0, TRUE); - camera_init_tracks_menu(dlist, mtx); - set_ortho_matrix_view(dlist, mtx); + camDisableUserView(0, TRUE); + camera_init_tracks_menu(dlist, mtx); + set_ortho_matrix_view(dlist, mtx); reset_render_settings(dlist); - gDPPipeSync((*dlist)++); - sp7C = gTrackSelectX; - temp2 = -gTrackSelectY; - temp = temp2 / (gTrackSelectViewportY >> 3); - if (temp >= 42) { return 1; } - temp2 -= (temp * (gTrackSelectViewportY >> 3)); + gDPPipeSync((*dlist)++); + sp7C = gTrackSelectX; + temp2 = -gTrackSelectY; + temp = temp2 / (gTrackSelectViewportY >> 3); + if (temp >= 42) { + return 1; + } + temp2 -= (temp * (gTrackSelectViewportY >> 3)); yPos = gTrackSelectViewPortHalfY + temp2; gDPSetPrimColor((*dlist)++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor((*dlist)++, 255, 255, 255, 0); vertices = (&gTrackSelectBgVertices)[D_80126924]; triangles = (&gTrackSelectBgTriangles)[D_80126924]; for (index = 0; gTrackSelectBgData[index] < temp; index += 5) {} - + data = &gTrackSelectBgData[index]; while ((yPos >= -gTrackSelectViewPortHalfY) && (data[0] < 42) && (numVertices < 64)) { bgTexture = gTracksMenuBgTextures[data[1]]; @@ -7472,10 +8417,10 @@ s32 func_8008F618(Gfx **dlist, MatrixS **mtx) { triangles[1].uv1.v = texV; triangles[1].uv2.u = texU + 0x2800; triangles[1].uv2.v = texV; - + triangles += 2; vertices += 4; - + if (bgTexture != 0) { hasTexture = 1; } else { @@ -7483,12 +8428,12 @@ s32 func_8008F618(Gfx **dlist, MatrixS **mtx) { } // If both alphas are 255, then don't set the transparency flags. - if ((prevAlpha + prevAlpha2) == 255+255) { + if ((prevAlpha + prevAlpha2) == 255 + 255) { flags = 0; } else { flags = RENDER_VTX_ALPHA | RENDER_Z_UPDATE; } - + load_and_set_texture(dlist, bgTexture, flags, 0); gSPVertexDKR((*dlist)++, OS_PHYSICAL_TO_K0(vertices), 4, 0); gSPPolygon((*dlist)++, OS_PHYSICAL_TO_K0(triangles), 2, hasTexture); @@ -7505,7 +8450,8 @@ s32 func_8008F618(Gfx **dlist, MatrixS **mtx) { GLOBAL_ASM("asm/non_matchings/menu/func_8008F618.s") #endif -void render_track_select(s32 x, s32 y, char *hubName, char *trackName, s32 rectOpacity, s32 imageId, s32 copyViewPort, DrawTexture *arg7, s32 arg8) { +void render_track_select(s32 x, s32 y, char *hubName, char *trackName, s32 rectOpacity, s32 imageId, s32 copyViewPort, + DrawTexture *arg7, s32 arg8) { s32 xTemp; s32 yTemp; s32 opacity; @@ -7551,7 +8497,8 @@ void render_track_select(s32 x, s32 y, char *hubName, char *trackName, s32 rectO set_text_colour(255, 255, 255, 0, opacity); draw_text(&sMenuCurrDisplayList, xTemp, sp6C + yTemp + 88, trackName, ALIGN_MIDDLE_CENTER); if (rectOpacity > 0) { - if (((yTemp - (gTrackSelectViewportY >> 2)) < gTrackSelectViewportY) && (((gTrackSelectViewportY >> 2) + yTemp) > 0)) { + if (((yTemp - (gTrackSelectViewportY >> 2)) < gTrackSelectViewportY) && + (((gTrackSelectViewportY >> 2) + yTemp) > 0)) { sp58 = 1.25f; sp54 = 1.25f; if (osTvType == TV_TYPE_PAL) { @@ -7568,10 +8515,12 @@ void render_track_select(s32 x, s32 y, char *hubName, char *trackName, s32 rectO } x1 = temp; if (temp < SCREEN_WIDTH && xTemp > 0) { - render_texture_rectangle_scaled(&sMenuCurrDisplayList, arg7, xTemp, yTemp, sp58, sp54, (rectOpacity & 0xFF) | ~0xFF, 0x1000); + render_texture_rectangle_scaled(&sMenuCurrDisplayList, arg7, xTemp, yTemp, sp58, sp54, + (rectOpacity & 0xFF) | ~0xFF, 0x1000); } if (xTemp < SCREEN_WIDTH && x2 > 0) { - render_texture_rectangle_scaled(&sMenuCurrDisplayList, arg7, xTemp, yTemp, sp58, sp54, (rectOpacity & 0xFF) | ~0xFF, 0); + render_texture_rectangle_scaled(&sMenuCurrDisplayList, arg7, xTemp, yTemp, sp58, sp54, + (rectOpacity & 0xFF) | ~0xFF, 0); } reset_render_settings(&sMenuCurrDisplayList); } @@ -7586,10 +8535,12 @@ void render_track_select(s32 x, s32 y, char *hubName, char *trackName, s32 rectO } func_8009CA60(imageId); gTrackSelectWoodFrameHeightScale = 1.0f; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { if ((1 << i) & arg8) { - render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrows[i], offsets[(i << 1)] + xTemp + 1, offsets[(i << 1) + 1] + yTemp + 1, 0, 0, 0, 128); - render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrows[i], offsets[(i << 1)] + xTemp - 1, offsets[(i << 1) + 1] + yTemp - 1, 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrows[i], offsets[(i << 1)] + xTemp + 1, + offsets[(i << 1) + 1] + yTemp + 1, 0, 0, 0, 128); + render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrows[i], offsets[(i << 1)] + xTemp - 1, + offsets[(i << 1) + 1] + yTemp - 1, 255, 255, 255, 255); } } reset_render_settings(&sMenuCurrDisplayList); @@ -7612,7 +8563,7 @@ void func_8008FF1C(UNUSED s32 updateRate) { s32 trackY; s32 j; s32 startIndex; - + settings = get_settings(); trackMenuIds = (s8 *) get_misc_asset(ASSET_MISC_TRACKS_MENU_IDS); if (gMenuDelay > -23 && gMenuDelay < 23) { @@ -7625,8 +8576,8 @@ void func_8008FF1C(UNUSED s32 updateRate) { temp = (gTrackSelectY / -gTrackSelectViewportY); trackY = temp - 1; startIndex = -1; - for(i = startIndex, cur = gTrackSelectRenderDetails; i < 2; i++) { - for(j = startIndex; j < 2; j++) { + for (i = startIndex, cur = gTrackSelectRenderDetails; i < 2; i++) { + for (j = startIndex; j < 2; j++) { trackX = trackSelectX + j; if ((trackY < 0) || (maxTrackY < trackY) || (trackX < 0) || (trackX >= 6)) { cur->visible = 0; @@ -7641,14 +8592,14 @@ void func_8008FF1C(UNUSED s32 updateRate) { if (((settings->trophies >> (trackY * 2)) & 3) == 3) { cur->visible = 2; } - } else if((settings->courseFlagsPtr[trackMenuIds[(trackY * 6) + trackX]] & 2)) { + } else if ((settings->courseFlagsPtr[trackMenuIds[(trackY * 6) + trackX]] & 2)) { cur->visible = 2; } } else { - cur->trackName = (char*) gQMarkPtr; + cur->trackName = (char *) gQMarkPtr; } cur->xOff = ((trackX * 320) - gTrackSelectX); - if (1){ } //Fakematch + if (1) {} // Fakematch cur->yOff = ((-trackY * gTrackSelectViewportY) - gTrackSelectY); cur->opacity = 0xFF; if ((trackX == gSelectedTrackX) && (trackY == gSelectedTrackY)) { @@ -7662,27 +8613,33 @@ void func_8008FF1C(UNUSED s32 updateRate) { cur->copyViewPort = cur->copyViewPort & 0xFF80; if (gMenuDelay == 0) { if (trackY > 0) { - cur->copyViewPort = (((cur->copyViewPort & 0xFF) | 1) & 0x7F) | (cur->copyViewPort & 0xFF80); + cur->copyViewPort = + (((cur->copyViewPort & 0xFF) | 1) & 0x7F) | (cur->copyViewPort & 0xFF80); } if (trackX < 5) { - cur->copyViewPort = (((cur->copyViewPort & 0xFF) | 2) & 0x7F) | (cur->copyViewPort & 0xFF80); + cur->copyViewPort = + (((cur->copyViewPort & 0xFF) | 2) & 0x7F) | (cur->copyViewPort & 0xFF80); } if (trackY < maxTrackY) { - cur->copyViewPort = (((cur->copyViewPort & 0xFF) | 4) & 0x7F) | (cur->copyViewPort & 0xFF80); + cur->copyViewPort = + (((cur->copyViewPort & 0xFF) | 4) & 0x7F) | (cur->copyViewPort & 0xFF80); } if (trackX > 0) { - cur->copyViewPort = (((cur->copyViewPort & 0xFF) | 8) & 0x7F) | (cur->copyViewPort & 0xFF80); + cur->copyViewPort = + (((cur->copyViewPort & 0xFF) | 8) & 0x7F) | (cur->copyViewPort & 0xFF80); } if (trackX == 4 && trackY == 4) { - cur->copyViewPort = ((cur->copyViewPort & 0xFF & 0xFF) & 0x7D) | (cur->copyViewPort & 0xFF80); + cur->copyViewPort = + ((cur->copyViewPort & 0xFF & 0xFF) & 0x7D) | (cur->copyViewPort & 0xFF80); } if (trackX == 5 && trackY == 3) { - cur->copyViewPort = ((cur->copyViewPort & 0xFF & 0xFF) & 0x7B) | (cur->copyViewPort & 0xFF80); + cur->copyViewPort = + ((cur->copyViewPort & 0xFF & 0xFF) & 0x7B) | (cur->copyViewPort & 0xFF80); } } if (trackX == 4) { cur->border = 6; - } else if(trackX == 5) { + } else if (trackX == 5) { cur->border = 5; } else { cur->border = 4; @@ -7700,19 +8657,14 @@ void func_8008FF1C(UNUSED s32 updateRate) { D_80126928 = 64; D_8012692C = 32; D_801269F0 = NULL; - for(i = 0; i < ARRAY_COUNT(gTrackSelectRenderDetails); i++) { + for (i = 0; i < ARRAY_COUNT(gTrackSelectRenderDetails); i++) { if (gTrackSelectRenderDetails[i].visible != 0) { - render_track_select( - gTrackSelectRenderDetails[i].xOff, - gTrackSelectRenderDetails[i].yOff, - gTrackSelectRenderDetails[i].hubName, - gTrackSelectRenderDetails[i].trackName, - gTrackSelectRenderDetails[i].opacity, - gTrackSelectRenderDetails[i].border, - ((u32) gTrackSelectRenderDetails[i].viewPort) >> 0xF, - (gTrackSelectRenderDetails[i].visible == 1) ? D_800E05D4 : D_800E05F4, - gTrackSelectRenderDetails[i].copyViewPort & 0x7F - ); + render_track_select(gTrackSelectRenderDetails[i].xOff, gTrackSelectRenderDetails[i].yOff, + gTrackSelectRenderDetails[i].hubName, gTrackSelectRenderDetails[i].trackName, + gTrackSelectRenderDetails[i].opacity, gTrackSelectRenderDetails[i].border, + ((u32) gTrackSelectRenderDetails[i].viewPort) >> 0xF, + (gTrackSelectRenderDetails[i].visible == 1) ? D_800E05D4 : D_800E05F4, + gTrackSelectRenderDetails[i].copyViewPort & 0x7F); } } D_80126924 = 1 - D_80126924; @@ -7730,7 +8682,7 @@ void func_800904E8(s32 updateRate) { s32 i; tick_thread30(); - for(i = 0; i < updateRate; i++) { + for (i = 0; i < updateRate; i++) { gTrackSelectX += (D_801269E8 - gTrackSelectX) * 0.1; gTrackSelectY += (D_801269EC - gTrackSelectY) * 0.1; } @@ -7738,7 +8690,8 @@ void func_800904E8(s32 updateRate) { if (gTrackIdForPreview == D_801263D0) { gSelectedTrackX = D_801269C8; gSelectedTrackY = D_801269CC; - } else if (gTrackIdForPreview != D_801263D0 && gTrackIdForPreview != -1 && set_level_to_load_in_background(gTrackIdForPreview, 1)) { + } else if (gTrackIdForPreview != D_801263D0 && gTrackIdForPreview != -1 && + set_level_to_load_in_background(gTrackIdForPreview, 1)) { D_801263D0 = gTrackIdForPreview; gSelectedTrackX = D_801269C8; gSelectedTrackY = D_801269CC; @@ -7747,7 +8700,8 @@ void func_800904E8(s32 updateRate) { } x1 = ((gSelectedTrackX * SCREEN_WIDTH) - gTrackSelectX) + SCREEN_WIDTH_FLOAT_HALF - 80.0f; x2 = x1 + SCREEN_WIDTH_HALF; - y1 = gTrackSelectViewPortHalfY - ((gSelectedTrackY * -gTrackSelectViewportY) - gTrackSelectY) - (gTrackSelectViewportY >> 2); + y1 = gTrackSelectViewPortHalfY - ((gSelectedTrackY * -gTrackSelectViewportY) - gTrackSelectY) - + (gTrackSelectViewportY >> 2); y2 = y1 + gTrackSelectViewPortHalfY; viewport_menu_set(0, x1, y1, x2, y2); copy_viewport_background_size_to_coords(0, &x1, &y1, &x2, &y2); @@ -7767,7 +8721,8 @@ void func_80090918(s32 updateRate) { sp24 = gMenuDelay; if (gMenuDelay > 0) { - if ((D_801269E8 - gTrackSelectX > 4.0f) || (D_801269E8 - gTrackSelectX < -4.0f) || ((D_801269EC - gTrackSelectY > 4.0f)) || (D_801269EC - gTrackSelectY < -4.0f)) { + if ((D_801269E8 - gTrackSelectX > 4.0f) || (D_801269E8 - gTrackSelectX < -4.0f) || + ((D_801269EC - gTrackSelectY > 4.0f)) || (D_801269EC - gTrackSelectY < -4.0f)) { gMenuDelay = 1; } else if (D_800E1E1C) { sound_play(SOUND_SELECT2, NULL); @@ -7880,12 +8835,12 @@ void func_80090ED8(UNUSED s32 updateRate) { void render_track_select_setup_ui(UNUSED s32 updateRate) { // Had to mess around with shifting the local variables, so they all probably need to be renamed. - s32 k; + s32 k; s32 y; s32 temp2; s32 temp; s32 sp84; - s32 regionOffset; // sp80 + s32 regionOffset; // sp80 s32 availableVehicleFlags; // sp7C union { char buffer[4]; @@ -7895,7 +8850,7 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { Settings *settings; // sp70 s32 i; s32 j; - + regionOffset = 0; filename.word = 0; // Set all 4 bytes as '\0'? sp74 = FALSE; @@ -7912,7 +8867,7 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { if (gMenuDelay < 0) { if (gSelectedTrackX == 4) { sp84 = 6; - } else if((gSelectedTrackX == 5)) { + } else if ((gSelectedTrackX == 5)) { sp84 = 5; } else { sp84 = 4; @@ -7944,7 +8899,7 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { if (gMenuOptionCount == -1 || (gMenuOptionCount == 2 && D_801269C8 == 4 && is_adventure_two_unlocked())) { temp2 = get_text_width(gMenuText[ASSET_MENU_TEXT_ADVENTURE2], 0, 0); // "ADVENTURE" k = get_text_width(gMenuText[ASSET_MENU_TEXT_ADVENTURETWO2], 0, 0); // "ADVENTURE TWO" - if (temp2 < k) { + if (temp2 < k) { temp2 = k; } if (temp2 < gTracksMenuAdventureButton.width) { @@ -7952,16 +8907,19 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { } else { temp2 += 12; } - func_80080580(&sMenuCurrDisplayList, -(temp2 >> 1), SCREEN_HEIGHT_HALF - gTracksMenuAdventureButton.y, temp2, - gTracksMenuAdventureButton.height, gTracksMenuAdventureButton.borderWidth, gTracksMenuAdventureButton.borderHeight, sMenuGuiOpacity + COLOUR_RGBA32(176, 224, 192, 0), - gMenuObjects[67]); + func_80080580(&sMenuCurrDisplayList, -(temp2 >> 1), SCREEN_HEIGHT_HALF - gTracksMenuAdventureButton.y, + temp2, gTracksMenuAdventureButton.height, gTracksMenuAdventureButton.borderWidth, + gTracksMenuAdventureButton.borderHeight, sMenuGuiOpacity + COLOUR_RGBA32(176, 224, 192, 0), + gMenuObjects[67]); func_80080E6C(); set_text_font(ASSET_FONTS_FUNFONT); - for(temp = 0, temp2 = 0, y = gTracksMenuAdventureButton.colourMax + gTracksMenuAdventureButton.y + regionOffset + 1; temp2 < 2; temp2++, temp++, y += 16) { - for(j = 0, i = y; j < 4; j += 2, i -= 2) { + for (temp = 0, temp2 = 0, + y = gTracksMenuAdventureButton.colourMax + gTracksMenuAdventureButton.y + regionOffset + 1; + temp2 < 2; temp2++, temp++, y += 16) { + for (j = 0, i = y; j < 4; j += 2, i -= 2) { if (j == 0) { set_text_colour(0, 0, 0, 255, sMenuGuiOpacity >> 1); - } else { + } else { k = 0; if (temp2 == gTracksMenuAdventureHighlightIndex) { k = sp84; @@ -7969,51 +8927,66 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { set_text_colour(255, 255, 255, k, sMenuGuiOpacity); } // gMenuText[146] = "ADVENTURE", gMenuText[147] = "ADVENTURE TWO" - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1 - j, i, gMenuText[ASSET_MENU_TEXT_ADVENTURE2 + temp], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1 - j, i, + gMenuText[ASSET_MENU_TEXT_ADVENTURE2 + temp], ALIGN_MIDDLE_CENTER); } } } if (D_801269C8 < 4) { set_text_font(ASSET_FONTS_FUNFONT); set_text_colour(255, 64, 64, 96, sMenuGuiOpacity); - draw_text(&sMenuCurrDisplayList, 56, 72 + regionOffset, gMenuText[ASSET_MENU_TEXT_BESTTIME], ALIGN_MIDDLE_LEFT); // "BEST TIME" - draw_text(&sMenuCurrDisplayList, 56, 92 + regionOffset, gMenuText[ASSET_MENU_TEXT_BESTLAP], ALIGN_MIDDLE_LEFT); // "BEST LAP" + draw_text(&sMenuCurrDisplayList, 56, 72 + regionOffset, gMenuText[ASSET_MENU_TEXT_BESTTIME], + ALIGN_MIDDLE_LEFT); // "BEST TIME" + draw_text(&sMenuCurrDisplayList, 56, 92 + regionOffset, gMenuText[ASSET_MENU_TEXT_BESTLAP], + ALIGN_MIDDLE_LEFT); // "BEST LAP" set_text_colour(255, 128, 255, 96, sMenuGuiOpacity); - decompress_filename_string(settings->courseInitialsPtr[gPlayerSelectVehicle[0]][gTrackIdForPreview], filename.buffer, 3); + decompress_filename_string(settings->courseInitialsPtr[gPlayerSelectVehicle[0]][gTrackIdForPreview], + filename.buffer, 3); draw_text(&sMenuCurrDisplayList, 250, regionOffset + 72, filename.buffer, ALIGN_MIDDLE_CENTER); - decompress_filename_string(settings->flapInitialsPtr[gPlayerSelectVehicle[0]][gTrackIdForPreview], filename.buffer, 3); + decompress_filename_string(settings->flapInitialsPtr[gPlayerSelectVehicle[0]][gTrackIdForPreview], + filename.buffer, 3); draw_text(&sMenuCurrDisplayList, 250, regionOffset + 92, filename.buffer, ALIGN_MIDDLE_CENTER); - show_timestamp(settings->courseTimesPtr[gPlayerSelectVehicle[PLAYER_ONE]][gTrackIdForPreview], 22, 53, 128, 255, 255, FONT_COLOURFUL); - show_timestamp(settings->flapTimesPtr[gPlayerSelectVehicle[PLAYER_ONE]][gTrackIdForPreview], 22, 33, 255, 192, 255, FONT_COLOURFUL); + show_timestamp(settings->courseTimesPtr[gPlayerSelectVehicle[PLAYER_ONE]][gTrackIdForPreview], 22, 53, 128, + 255, 255, FONT_COLOURFUL); + show_timestamp(settings->flapTimesPtr[gPlayerSelectVehicle[PLAYER_ONE]][gTrackIdForPreview], 22, 33, 255, + 192, 255, FONT_COLOURFUL); if (gMenuOptionCount != -1) { if (gNumberOfActivePlayers == 1) { set_current_dialogue_box_coords(7, 134, regionOffset + 112, 186, regionOffset + 137); render_dialogue_box(&sMenuCurrDisplayList, NULL, NULL, 7); if (gMenuOptionCount <= 0) { - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionVehicleTitleTexture, 136, regionOffset + 114, 255, 255, 255, sMenuGuiOpacity); + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionVehicleTitleTexture, 136, + regionOffset + 114, 255, 255, 255, sMenuGuiOpacity); } else { - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionTTTitleTexture, 136, regionOffset + 114, 255, 255, 255, sMenuGuiOpacity); + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionTTTitleTexture, 136, + regionOffset + 114, 255, 255, 255, sMenuGuiOpacity); for (k = 0, y = regionOffset + 151; k < 2; k++, y += 24) { if (k == gTracksMenuTimeTrialHighlightIndex) { - render_textured_rectangle(&sMenuCurrDisplayList, gTrackSelectTTImage[k * 3 + 1], 104, y, 255, 255, 255, sMenuGuiOpacity); + render_textured_rectangle(&sMenuCurrDisplayList, gTrackSelectTTImage[k * 3 + 1], 104, y, + 255, 255, 255, sMenuGuiOpacity); } else { - render_textured_rectangle(&sMenuCurrDisplayList, gTrackSelectTTImage[k * 3 + 2], 104, y, 255, 255, 255, sMenuGuiOpacity); + render_textured_rectangle(&sMenuCurrDisplayList, gTrackSelectTTImage[k * 3 + 2], 104, y, + 255, 255, 255, sMenuGuiOpacity); } } } - } else if (!sp74) { + } else if (!sp74) { // Probably fake y = gNumberOfActivePlayers; j = ((y - 1) * y); - for(k = 0; (k < y) ^ 0; k++) { - if ((gNumberOfActivePlayers == 1 && k == gMenuOptionCount) || (gNumberOfActivePlayers > 1 && D_801269C4[k] == 0)) { - set_current_dialogue_box_coords(7, gTracksMenuPlayerNamePositions[j] - 2, gTracksMenuPlayerNamePositions[j + 1] + regionOffset - 2, - gTracksMenuPlayerNamePositions[j] + 50, gTracksMenuPlayerNamePositions[j + 1] + regionOffset + 23); + for (k = 0; (k < y) ^ 0; k++) { + if ((gNumberOfActivePlayers == 1 && k == gMenuOptionCount) || + (gNumberOfActivePlayers > 1 && D_801269C4[k] == 0)) { + set_current_dialogue_box_coords(7, gTracksMenuPlayerNamePositions[j] - 2, + gTracksMenuPlayerNamePositions[j + 1] + regionOffset - 2, + gTracksMenuPlayerNamePositions[j] + 50, + gTracksMenuPlayerNamePositions[j + 1] + regionOffset + 23); render_dialogue_box(&sMenuCurrDisplayList, NULL, NULL, 7); } - render_textured_rectangle(&sMenuCurrDisplayList, gTrackSelectPlayerImage[k], gTracksMenuPlayerNamePositions[j], + render_textured_rectangle( + &sMenuCurrDisplayList, gTrackSelectPlayerImage[k], gTracksMenuPlayerNamePositions[j], gTracksMenuPlayerNamePositions[j + 1] + regionOffset, 255, 255, 255, sMenuGuiOpacity); - j+=2; + j += 2; } } if ((gNumberOfActivePlayers > 1 || gMenuOptionCount == 0) && !sp74) { @@ -8024,17 +8997,20 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { for (temp2 = 0; temp2 < gNumberOfActivePlayers; temp2++) { if (k == gPlayerSelectVehicle[temp2]) { // Highlighted - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[(k * 3) + 1], - gTracksMenuVehicleNamePositions[j+temp2], y, 255, 255, 255, sMenuGuiOpacity); - } else if(settings->courseFlagsPtr[gTrackIdForPreview] & 2) { + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[(k * 3) + 1], + gTracksMenuVehicleNamePositions[j + temp2], y, 255, 255, + 255, sMenuGuiOpacity); + } else if (settings->courseFlagsPtr[gTrackIdForPreview] & 2) { // Not highlighted - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[(k * 3) + 2], - gTracksMenuVehicleNamePositions[j+temp2], y, 255, 255, 255, sMenuGuiOpacity); + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[(k * 3) + 2], + gTracksMenuVehicleNamePositions[j + temp2], y, 255, 255, + 255, sMenuGuiOpacity); } else { // Not available (Ghosted out) - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[(k * 3) + 2], - gTracksMenuVehicleNamePositions[j+temp2], y, 255, 255, 255, (sMenuGuiOpacity / 2)); - } + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[(k * 3) + 2], + gTracksMenuVehicleNamePositions[j + temp2], y, 255, 255, + 255, (sMenuGuiOpacity / 2)); + } } y += 24; } @@ -8047,25 +9023,29 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { if (gNumberOfActivePlayers == 1) { if (gMenuOptionCount == 0) { // Draw vehicle image for one player - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[gPlayerSelectVehicle[PLAYER_ONE] * 3], - 149, y, 255, 255, 255, sMenuGuiOpacity); + render_textured_rectangle(&sMenuCurrDisplayList, + gRaceSelectionImages[gPlayerSelectVehicle[PLAYER_ONE] * 3], 149, y, + 255, 255, 255, sMenuGuiOpacity); } else { // Draw T.T. image for one player - render_textured_rectangle(&sMenuCurrDisplayList, gTrackSelectTTImage[gTracksMenuTimeTrialHighlightIndex * 3], - 149, regionOffset + 139, 255, 255, 255, sMenuGuiOpacity); + render_textured_rectangle(&sMenuCurrDisplayList, + gTrackSelectTTImage[gTracksMenuTimeTrialHighlightIndex * 3], 149, + regionOffset + 139, 255, 255, 255, sMenuGuiOpacity); } } if (gNumberOfActivePlayers == 2 && !sp74) { // Draw vehicle image for first player - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[gPlayerSelectVehicle[PLAYER_ONE] * 3], - 79, y, 255, 255, 255, sMenuGuiOpacity); - y = regionOffset + 139; + render_textured_rectangle(&sMenuCurrDisplayList, + gRaceSelectionImages[gPlayerSelectVehicle[PLAYER_ONE] * 3], 79, y, 255, + 255, 255, sMenuGuiOpacity); + y = regionOffset + 139; if (gPlayerSelectVehicle[PLAYER_TWO] == 2) { y += 2; } // Draw vehicle image for second player - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[gPlayerSelectVehicle[PLAYER_TWO] * 3], - 176, y, 255, 255, 255, sMenuGuiOpacity); + render_textured_rectangle(&sMenuCurrDisplayList, + gRaceSelectionImages[gPlayerSelectVehicle[PLAYER_TWO] * 3], 176, y, 255, + 255, 255, sMenuGuiOpacity); } reset_render_settings(&sMenuCurrDisplayList); if (gNumberOfActivePlayers <= 2 && !sp74) { @@ -8088,17 +9068,25 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { } else { temp2 = gTwoPlayerRacerCountMenu.width; } - func_80080580(&sMenuCurrDisplayList, -(temp2 >> 1), 120 - gTwoPlayerRacerCountMenu.y, temp2, gTwoPlayerRacerCountMenu.height, - gTwoPlayerRacerCountMenu.borderWidth, gTwoPlayerRacerCountMenu.borderHeight, COLOUR_RGBA32(176, 224, 192, 255), gMenuObjects[67]); + func_80080580(&sMenuCurrDisplayList, -(temp2 >> 1), 120 - gTwoPlayerRacerCountMenu.y, temp2, + gTwoPlayerRacerCountMenu.height, gTwoPlayerRacerCountMenu.borderWidth, + gTwoPlayerRacerCountMenu.borderHeight, COLOUR_RGBA32(176, 224, 192, 255), + gMenuObjects[67]); func_80080E6C(); set_text_font(ASSET_FONTS_FUNFONT); set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, gTwoPlayerRacerCountMenu.textPos[0] + gTwoPlayerRacerCountMenu.x + 1, gTwoPlayerRacerCountMenu.textPos[1] + gTwoPlayerRacerCountMenu.y + regionOffset + 1, gMenuText[ASSET_MENU_TEXT_NUMBEROFRACERS], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, + gTwoPlayerRacerCountMenu.textPos[0] + gTwoPlayerRacerCountMenu.x + 1, + gTwoPlayerRacerCountMenu.textPos[1] + gTwoPlayerRacerCountMenu.y + regionOffset + 1, + gMenuText[ASSET_MENU_TEXT_NUMBEROFRACERS], ALIGN_MIDDLE_CENTER); set_text_colour(255, 255, 255, 0, 255); - draw_text(&sMenuCurrDisplayList, (gTwoPlayerRacerCountMenu.textPos[0] + gTwoPlayerRacerCountMenu.x) - 1, (gTwoPlayerRacerCountMenu.textPos[1] + gTwoPlayerRacerCountMenu.y + regionOffset) - 1, gMenuText[ASSET_MENU_TEXT_NUMBEROFRACERS], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, + (gTwoPlayerRacerCountMenu.textPos[0] + gTwoPlayerRacerCountMenu.x) - 1, + (gTwoPlayerRacerCountMenu.textPos[1] + gTwoPlayerRacerCountMenu.y + regionOffset) - 1, + gMenuText[ASSET_MENU_TEXT_NUMBEROFRACERS], ALIGN_MIDDLE_CENTER); func_80068508(TRUE); sprite_opaque(FALSE); - + for (temp2 = 0; temp2 < 3; temp2++) { if (temp2 == gMultiplayerSelectedNumberOfRacers) { if (gMenuOptionCount < 3) { @@ -8109,8 +9097,11 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { sMenuGuiColourB = 0; } } - gMenuImageStack->unkC = (gTwoPlayerRacerCountMenu.textPos[(temp2 << 1) + 2] + gTwoPlayerRacerCountMenu.x) - 160; - gMenuImageStack->unk10 = (-gTwoPlayerRacerCountMenu.textPos[(temp2 << 1) + 2 + 1] - gTwoPlayerRacerCountMenu.y) + 120; + gMenuImageStack->unkC = + (gTwoPlayerRacerCountMenu.textPos[(temp2 << 1) + 2] + gTwoPlayerRacerCountMenu.x) - 160; + gMenuImageStack->unk10 = + (-gTwoPlayerRacerCountMenu.textPos[(temp2 << 1) + 2 + 1] - gTwoPlayerRacerCountMenu.y) + + 120; gMenuImageStack->unk18 = (temp2 << 1) + 2; func_8009CA60(0); sMenuGuiColourG = 255; @@ -8139,7 +9130,8 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { sprite_opaque(TRUE); } if (gNumberOfActivePlayers == 1 && gMenuOptionCount >= 0 && func_80092BE0(gTrackIdForPreview) >= 0) { - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionTTTexture, 204, regionOffset + 122, 255, 255, 255, sMenuGuiOpacity); + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionTTTexture, 204, regionOffset + 122, 255, 255, + 255, sMenuGuiOpacity); reset_render_settings(&sMenuCurrDisplayList); } if (D_801269C8 != 5) { @@ -8149,7 +9141,8 @@ void render_track_select_setup_ui(UNUSED s32 updateRate) { if (D_801269C8 >= 4) { regionOffset += 24; } - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, regionOffset + 172, (char *) D_800E823C /* "OK?" */, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, regionOffset + 172, (char *) D_800E823C /* "OK?" */, + ALIGN_MIDDLE_CENTER); } } sMenuGuiOpacity = 255; @@ -8191,7 +9184,7 @@ s32 func_80092BE0(s32 mapId) { /** * Load and initialise the track setup gui for use when entering a track in adventure mode. -*/ + */ void menu_adventure_track_init(void) { Settings *settings; s32 result; @@ -8259,7 +9252,7 @@ void render_adventure_track_setup(UNUSED s32 arg0, s32 arg1, s32 arg2) { s32 mask; s32 sp58; char *filename; - Settings* settings; + Settings *settings; char *levelName; filename = NULL; @@ -8268,7 +9261,7 @@ void render_adventure_track_setup(UNUSED s32 arg0, s32 arg1, s32 arg2) { if (osTvType == TV_TYPE_PAL) { yOffset = 12; } - sp58 = ((Settings4C *)((u8 *) settings->unk4C + gTrackIdForPreview))->unk2; + sp58 = ((Settings4C *) ((u8 *) settings->unk4C + gTrackIdForPreview))->unk2; gSPClearGeometryMode(sMenuCurrDisplayList++, G_CULL_FRONT); func_8009BD5C(); set_ortho_matrix_view(&sMenuCurrDisplayList, &sMenuCurrHudMat); @@ -8279,26 +9272,40 @@ void render_adventure_track_setup(UNUSED s32 arg0, s32 arg1, s32 arg2) { set_text_font(FONT_LARGE); set_text_background_colour(0, 0, 0, 0); set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 46, levelName, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 46, levelName, ALIGN_MIDDLE_CENTER); set_text_colour(255, 255, 255, 0, 255); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 43, levelName, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 43, levelName, ALIGN_MIDDLE_CENTER); if (!(get_map_race_type(sp58) & 0x40)) { if (arg2 == 0) { if (is_time_trial_enabled()) { if (func_80092BE0(sp58) >= 0) { - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionTTTexture, SCREEN_HEIGHT - 36, yOffset + 122, 255, 255, 255, sMenuGuiOpacity); + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionTTTexture, + SCREEN_HEIGHT - 36, yOffset + 122, 255, 255, 255, + sMenuGuiOpacity); } set_text_font(0); set_text_colour(255, 64, 64, 96, 255); - draw_text(&sMenuCurrDisplayList, 88, yOffset + 72, gMenuText[ASSET_MENU_TEXT_BESTTIME], ALIGN_MIDDLE_CENTER); - draw_text(&sMenuCurrDisplayList, 88, yOffset + 92, gMenuText[ASSET_MENU_TEXT_BESTLAP], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, 88, yOffset + 72, gMenuText[ASSET_MENU_TEXT_BESTTIME], + ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, 88, yOffset + 92, gMenuText[ASSET_MENU_TEXT_BESTLAP], + ALIGN_MIDDLE_CENTER); set_text_colour(255, 128, 255, 96, 255); - decompress_filename_string(settings->courseInitialsPtr[gPlayerSelectVehicle[0]][sp58], (char *) &filename, 3); - draw_text(&sMenuCurrDisplayList, 258, yOffset + 72, (char*) &filename, ALIGN_MIDDLE_CENTER); - decompress_filename_string(settings->flapInitialsPtr[gPlayerSelectVehicle[0]][sp58], (char *) &filename, 3); - draw_text(&sMenuCurrDisplayList, 258, yOffset + 92, (char*) &filename, ALIGN_MIDDLE_CENTER); - show_timestamp(settings->courseTimesPtr[gPlayerSelectVehicle[0]][((Settings4C *)((u8 *) settings->unk4C + gTrackIdForPreview))->unk2], 26, 53, 128, 255, 255, 0); - show_timestamp(settings->flapTimesPtr[gPlayerSelectVehicle[0]][((Settings4C *)((u8 *) settings->unk4C + gTrackIdForPreview))->unk2], 26, 33, 255, 192, 255, 0); + decompress_filename_string(settings->courseInitialsPtr[gPlayerSelectVehicle[0]][sp58], + (char *) &filename, 3); + draw_text(&sMenuCurrDisplayList, 258, yOffset + 72, (char *) &filename, ALIGN_MIDDLE_CENTER); + decompress_filename_string(settings->flapInitialsPtr[gPlayerSelectVehicle[0]][sp58], + (char *) &filename, 3); + draw_text(&sMenuCurrDisplayList, 258, yOffset + 92, (char *) &filename, ALIGN_MIDDLE_CENTER); + show_timestamp( + settings + ->courseTimesPtr[gPlayerSelectVehicle[0]] + [((Settings4C *) ((u8 *) settings->unk4C + gTrackIdForPreview))->unk2], + 26, 53, 128, 255, 255, 0); + show_timestamp( + settings + ->flapTimesPtr[gPlayerSelectVehicle[0]] + [((Settings4C *) ((u8 *) settings->unk4C + gTrackIdForPreview))->unk2], + 26, 33, 255, 192, 255, 0); } greenAmount = gOptionBlinkTimer * 8; if (greenAmount > 255) { @@ -8307,18 +9314,21 @@ void render_adventure_track_setup(UNUSED s32 arg0, s32 arg1, s32 arg2) { set_current_dialogue_background_colour(7, 255, greenAmount, 0, 255); set_current_dialogue_box_coords(7, 134, yOffset + 112, 186, yOffset + 137); render_dialogue_box(&sMenuCurrDisplayList, NULL, NULL, 7); - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionVehicleTitleTexture, 136, yOffset + 114, 255, 255, 255, 255); - + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionVehicleTitleTexture, 136, + yOffset + 114, 255, 255, 255, 255); + y = yOffset + 139; savedY = y; - + for (i = 0; i < 3; i++) { alpha = (arg1 < 2 && get_map_default_vehicle(sp58) != (Vehicle) i) ? 128 : 255; if ((1 << i) & mask) { if (i == gPlayerSelectVehicle[0]) { - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[i*3+1], 104, y, 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[i * 3 + 1], 104, + y, 255, 255, 255, 255); } else { - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[i*3+2], 104, y, 255, 255, 255, alpha); + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[i * 3 + 2], 104, + y, 255, 255, 255, alpha); } y += 24; } @@ -8327,7 +9337,8 @@ void render_adventure_track_setup(UNUSED s32 arg0, s32 arg1, s32 arg2) { if (gPlayerSelectVehicle[0] == 2) { y += 2; } - render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[gPlayerSelectVehicle[0]*3], 149, y, 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, gRaceSelectionImages[gPlayerSelectVehicle[0] * 3], + 149, y, 255, 255, 255, 255); reset_render_settings(&sMenuCurrDisplayList); gMenuImageStack[7].unkC = 21.0f; gMenuImageStack[7].unk10 = -52.0f; @@ -8336,7 +9347,8 @@ void render_adventure_track_setup(UNUSED s32 arg0, s32 arg1, s32 arg2) { set_text_font(FONT_LARGE); set_text_background_colour(0, 0, 0, 0); set_text_colour(255, 255, 255, 0, 255); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yOffset + 172, (char*) D_800E8240, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yOffset + 172, (char *) D_800E8240, + ALIGN_MIDDLE_CENTER); } } else { set_text_font(FONT_LARGE); @@ -8361,7 +9373,7 @@ void render_adventure_track_setup(UNUSED s32 arg0, s32 arg1, s32 arg2) { /** * Process the logic for the track setup selection after entering a door in adventure mode. * This also includes drawing all the gui. -*/ + */ s32 menu_adventure_track_loop(s32 updateRate) { s32 vehicle; s32 sp30; @@ -8376,7 +9388,7 @@ s32 menu_adventure_track_loop(s32 updateRate) { return gTrackIdForPreview | 0x80; } settings = get_settings(); - mapId = ((Settings4C *)((u8 *)settings->unk4C + gTrackIdForPreview))->unk2; + mapId = ((Settings4C *) ((u8 *) settings->unk4C + gTrackIdForPreview))->unk2; sp28 = FALSE; sp1C = 0; if (settings->courseFlagsPtr[mapId] & RACE_CLEARED) { @@ -8473,12 +9485,12 @@ s32 menu_adventure_track_loop(s32 updateRate) { } void func_80093A0C(void) { - func_8009C4A8((s16 *)&gAdvTrackInitObjectIndices); + func_8009C4A8((s16 *) &gAdvTrackInitObjectIndices); unload_font(ASSET_FONTS_BIGFONT); music_change_on(); } -//Pause Menu +// Pause Menu void func_80093A40(void) { s32 raceType; s32 i; @@ -8506,11 +9518,13 @@ void func_80093A40(void) { } else if ((settings->worldId > WORLD_CENTRAL_AREA) && (raceType != RACETYPE_BOSS)) { if (raceType & RACETYPE_CHALLENGE) { gMenuOptionText[1] = gMenuText[ASSET_MENU_TEXT_RESTARTCHALLENGE]; - gMenuOptionText[2] = (!gIsInTracksMode) ? gMenuText[ASSET_MENU_TEXT_RETURNTOLOBBY] : gMenuText[ASSET_MENU_TEXT_SELECTTRACK]; + gMenuOptionText[2] = (!gIsInTracksMode) ? gMenuText[ASSET_MENU_TEXT_RETURNTOLOBBY] + : gMenuText[ASSET_MENU_TEXT_SELECTTRACK]; gMenuOptionCap = 3; } else if (raceType == RACETYPE_DEFAULT) { gMenuOptionText[1] = gMenuText[ASSET_MENU_TEXT_RESTARTRACE]; - gMenuOptionText[2] = (!gIsInTracksMode) ? gMenuText[ASSET_MENU_TEXT_RETURNTOLOBBY] : gMenuText[ASSET_MENU_TEXT_SELECTTRACK]; + gMenuOptionText[2] = (!gIsInTracksMode) ? gMenuText[ASSET_MENU_TEXT_RETURNTOLOBBY] + : gMenuText[ASSET_MENU_TEXT_SELECTTRACK]; gMenuOptionCap = 3; } } else if ((!gIsInTracksMode) && (raceType == RACETYPE_BOSS)) { @@ -8543,7 +9557,7 @@ void func_80093D40(UNUSED s32 updateRate) { s32 i; s32 y; s32 alpha; - + for (i = 0, x = SCREEN_WIDTH_HALF; i < gMenuOptionCap; i++) { textWidth = get_text_width(gMenuOptionText[i], 0, 0) + 8; if (x < textWidth) { @@ -8574,9 +9588,11 @@ void func_80093D40(UNUSED s32 updateRate) { if (gMenuSubOption != 0) { i = halfTemp - 26; if (gTrophyRaceWorldId != 0) { - render_dialogue_text(7, POS_CENTRED, i + 8, gMenuText[ASSET_MENU_TEXT_QUITTROPHYRACETITLE], 1, ALIGN_MIDDLE_CENTER); + render_dialogue_text(7, POS_CENTRED, i + 8, gMenuText[ASSET_MENU_TEXT_QUITTROPHYRACETITLE], 1, + ALIGN_MIDDLE_CENTER); } else { - render_dialogue_text(7, POS_CENTRED, i + 8, gMenuText[ASSET_MENU_TEXT_QUITGAMETITLE], 1, ALIGN_MIDDLE_CENTER); + render_dialogue_text(7, POS_CENTRED, i + 8, gMenuText[ASSET_MENU_TEXT_QUITGAMETITLE], 1, + ALIGN_MIDDLE_CENTER); } if (gMenuSubOption == 1) { set_current_text_colour(7, 255, 255, 255, alpha, 255); @@ -8592,7 +9608,8 @@ void func_80093D40(UNUSED s32 updateRate) { render_dialogue_text(7, POS_CENTRED, i + 44, gMenuText[ASSET_MENU_TEXT_CANCEL], 1, ALIGN_MIDDLE_CENTER); } else { i = gLastPlayerWhoPaused + 1; // Fakematch. Seems to fix stuff? - render_dialogue_text(7, POS_CENTRED, 12, gMenuText[ASSET_MENU_TEXT_PAUSEOPTIONS], gLastPlayerWhoPaused + 1, ALIGN_MIDDLE_CENTER); + render_dialogue_text(7, POS_CENTRED, 12, gMenuText[ASSET_MENU_TEXT_PAUSEOPTIONS], gLastPlayerWhoPaused + 1, + ALIGN_MIDDLE_CENTER); for (i = 0, y = 32; i < gMenuOptionCap; i++, y += 16) { if (i == gMenuOption) { set_current_text_colour(7, 255, 255, 255, alpha, 255); @@ -8601,7 +9618,6 @@ void func_80093D40(UNUSED s32 updateRate) { } render_dialogue_text(7, POS_CENTRED, y, gMenuOptionText[i], 1, ALIGN_MIDDLE_CENTER); } - } open_dialogue_box(7); } @@ -8655,7 +9671,8 @@ s32 render_pause_menu(UNUSED Gfx **dl, s32 updateRate) { } else if (buttonsPressed & (A_BUTTON | START_BUTTON)) { sound_play(SOUND_SELECT2, NULL); if ((gMenuOptionText[gMenuOption] == gMenuText[ASSET_MENU_TEXT_QUITGAME]) || - ((gTrophyRaceWorldId != 0) && (gMenuOptionText[gMenuOption] == gMenuText[ASSET_MENU_TEXT_QUITTROPHYRACE]))) { + ((gTrophyRaceWorldId != 0) && + (gMenuOptionText[gMenuOption] == gMenuText[ASSET_MENU_TEXT_QUITTROPHYRACE]))) { gMenuSubOption = 2; } else { gMenuDelay = 1; @@ -8698,7 +9715,8 @@ s32 render_pause_menu(UNUSED Gfx **dl, s32 updateRate) { sound_volume_change(VOLUME_NORMAL); return 1; } - if ((gMenuOptionText[gMenuOption] == gMenuText[ASSET_MENU_TEXT_RESTARTRACE]) || (gMenuOptionText[gMenuOption] == gMenuText[ASSET_MENU_TEXT_RESTARTCHALLENGE])) { + if ((gMenuOptionText[gMenuOption] == gMenuText[ASSET_MENU_TEXT_RESTARTRACE]) || + (gMenuOptionText[gMenuOption] == gMenuText[ASSET_MENU_TEXT_RESTARTCHALLENGE])) { if ((gIsInTracksMode == 0) && (gTTVoiceLines[get_ingame_map_id()] != -1)) { sound_play_delayed(gTTVoiceLines[get_ingame_map_id()], NULL, 1.0f); } @@ -8739,7 +9757,7 @@ void n_alSeqpDelete(void) { /** * Set the racer portrait element textures for their respective characters. -*/ + */ void assign_racer_portrait_textures(void) { gMenuPortraitKrunch[0].texture = gMenuObjects[TEXTURE_ICON_PORTRAIT_KRUNCH]; gMenuPortraitDiddy[0].texture = gMenuObjects[TEXTURE_ICON_PORTRAIT_DIDDY]; @@ -8858,12 +9876,14 @@ void func_80094A5C(void) { allocate_menu_images(gRaceResultsImageIndices); assign_racer_portrait_textures(); settings = get_settings(); - gRaceResultsMenuElements->unk14_a.element = gRacerPortraits[settings->racers[settings->timeTrialRacer].character]; + gRaceResultsMenuElements->unk14_a.element = + gRacerPortraits[settings->racers[settings->timeTrialRacer].character]; if (!is_time_trial_enabled()) { for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { if (i == settings->racers[j].starting_position) { - gRaceOrderMenuElements[7 - i].unk14_a.element = gRacerPortraits[settings->racers[j].character]; + gRaceOrderMenuElements[7 - i].unk14_a.element = + gRacerPortraits[settings->racers[j].character]; } } } @@ -8921,7 +9941,7 @@ void func_80094D28(UNUSED s32 updateRate) { s32 i; s32 sp3C; s32 temp; - + settings = get_settings(); if (gNumberOfActivePlayers == 1) { set_ortho_matrix_view(&sMenuCurrDisplayList, &sMenuCurrHudMat); @@ -8938,7 +9958,8 @@ void func_80094D28(UNUSED s32 updateRate) { temp = 60; } viewportULY = ((gTrackSelectViewPortHalfY - ((gTrackSelectViewPortHalfY * 4) / 5)) * temp) / 60; - viewportLRY = gTrackSelectViewportY - (((gTrackSelectViewPortHalfY - (gTrackSelectViewPortHalfY / 5)) * temp) / 60); + viewportLRY = + gTrackSelectViewportY - (((gTrackSelectViewPortHalfY - (gTrackSelectViewPortHalfY / 5)) * temp) / 60); viewportULX = (temp * 80) / 60; viewport_menu_set(0, viewportULX, viewportULY, SCREEN_WIDTH - viewportULX, viewportLRY); gMenuImageStack[4].unkC = 0.0f; @@ -8946,13 +9967,13 @@ void func_80094D28(UNUSED s32 updateRate) { gMenuImageStack[4].unk8 = sMenuImageProperties[4].unk8 * (2.0f - (temp / 60.0f)); break; case 2: - for(i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) { if (settings->display_times && settings->racers[0].best_times & (1 << i)) { - gRaceResultsMenuElements[i+3].filterGreen = 192 - ((textAlpha * 3) >> 2); - gRaceResultsMenuElements[i+3].filterBlue = 255 - textAlpha; + gRaceResultsMenuElements[i + 3].filterGreen = 192 - ((textAlpha * 3) >> 2); + gRaceResultsMenuElements[i + 3].filterBlue = 255 - textAlpha; } else { - gRaceResultsMenuElements[i+3].filterGreen = 192; - gRaceResultsMenuElements[i+3].filterBlue = 255; + gRaceResultsMenuElements[i + 3].filterGreen = 192; + gRaceResultsMenuElements[i + 3].filterBlue = 255; } } if (settings->display_times && settings->racers[0].best_times & (1 << 7)) { @@ -8966,7 +9987,7 @@ void func_80094D28(UNUSED s32 updateRate) { } break; case 3: - for(j = 0; j < 8; j++) { + for (j = 0; j < 8; j++) { i = j; sp3C = 255; if (is_in_two_player_adventure()) { @@ -8978,7 +9999,7 @@ void func_80094D28(UNUSED s32 updateRate) { if (i == settings->racers[0].starting_position) { sp3C = (textAlpha >> 1) + 128; } - if (y){} // Fake + if (y) {} // Fake gRaceOrderMenuElements[7 - j].filterRed = sp3C; gRaceOrderMenuElements[7 - j].filterGreen = sp3C; gRaceOrderMenuElements[7 - j].filterBlue = sp3C; @@ -9009,7 +10030,7 @@ void func_80094D28(UNUSED s32 updateRate) { assign_dialogue_box_id(7); set_dialogue_font(7, FONT_COLOURFUL); set_current_text_background_colour(7, 0, 0, 0, 0); - + if (D_80126A98 != 0) { temp = 1; } else if (D_80126C1C != NULL) { @@ -9028,8 +10049,9 @@ void func_80094D28(UNUSED s32 updateRate) { temp = 192; if (osTvType == TV_TYPE_PAL) { temp = 218; - } - set_current_dialogue_box_coords(7, 0, temp - viewportULY - viewportULX - 4, SCREEN_WIDTH, temp + viewportULY + viewportULX + 4); + } + set_current_dialogue_box_coords(7, 0, temp - viewportULY - viewportULX - 4, SCREEN_WIDTH, + temp + viewportULY + viewportULX + 4); set_current_dialogue_background_colour(7, 64, 64, 255, 0); set_current_text_colour(7, 255, 0, 255, 64, 255); if (D_80126A98 != 0) { @@ -9039,22 +10061,25 @@ void func_80094D28(UNUSED s32 updateRate) { render_dialogue_text(7, POS_CENTRED, y, D_80126C1C[temp], 1, ALIGN_MIDDLE_CENTER); } } else { - if (y && y){} //fake + if (y && y) {} // fake viewportULY -= 24; if (gMenuSubOption != 0) { - render_dialogue_text(7, POS_CENTRED, viewportULY + 8, gMenuText[ASSET_MENU_TEXT_QUITGAMETITLE], 1, ALIGN_MIDDLE_CENTER); + render_dialogue_text(7, POS_CENTRED, viewportULY + 8, gMenuText[ASSET_MENU_TEXT_QUITGAMETITLE], 1, + ALIGN_MIDDLE_CENTER); temp = 0; if (gMenuSubOption == 1) { temp = textAlpha; } set_current_text_colour(7, 255, 255, 255, temp, 255); - render_dialogue_text(7, POS_CENTRED, viewportULY + 26, gMenuText[ASSET_MENU_TEXT_OK], 1, ALIGN_MIDDLE_CENTER); + render_dialogue_text(7, POS_CENTRED, viewportULY + 26, gMenuText[ASSET_MENU_TEXT_OK], 1, + ALIGN_MIDDLE_CENTER); temp = 0; if (gMenuSubOption == 2) { temp = textAlpha; } set_current_text_colour(7, 255, 255, 255, temp, 255); - render_dialogue_text(7, POS_CENTRED, viewportULY + 42, gMenuText[ASSET_MENU_TEXT_CANCEL], 1, ALIGN_MIDDLE_CENTER); + render_dialogue_text(7, POS_CENTRED, viewportULY + 42, gMenuText[ASSET_MENU_TEXT_CANCEL], 1, + ALIGN_MIDDLE_CENTER); } else { for (y = 12, temp = 0; temp < gResultOptionCount; temp++, y += viewportLRY) { if (temp == gMenuOption) { @@ -9089,6 +10114,8 @@ GLOBAL_ASM("asm/non_matchings/menu/func_80094D28.s") void func_80095624(SIDeviceStatus status) { // status may contain controllerIndex in it's upper bits // so grab the lower bits for the SIDeviceStatus + + // clang-format off switch (status & 0xFF) { case CONTROLLER_PAK_NOT_FOUND: case CONTROLLER_PAK_CHANGED: /*Required to match*/ \ @@ -9103,7 +10130,7 @@ void func_80095624(SIDeviceStatus status) { D_80126C1C = sInsertControllerPakMenuText; break; case CONTROLLER_PAK_SWITCH_TO_RUMBLE: - //If you wish to use / the Rumble Pak / insert it now! + // If you wish to use / the Rumble Pak / insert it now! D_80126C1C = sInsertRumblePakMenuText; break; case CONTROLLER_PAK_BAD_DATA: @@ -9113,9 +10140,9 @@ void func_80095624(SIDeviceStatus status) { D_80126C1C = sBadControllerPakMenuText; break; } + // clang-format on - for (D_80126C24 = 0; D_80126C1C[D_80126C24] != 0; D_80126C24++) { - } + for (D_80126C24 = 0; D_80126C1C[D_80126C24] != 0; D_80126C24++) {} } s32 func_80095728(Gfx **dlist, MatrixS **matrices, Vertex **vertices, s32 updateRate) { @@ -9132,7 +10159,7 @@ s32 func_80095728(Gfx **dlist, MatrixS **matrices, Vertex **vertices, s32 update Settings *settings; Racer *racer; char *temp_v1_14; - + sp54 = 0; sp50 = 0; sp4C = 0; @@ -9154,7 +10181,7 @@ s32 func_80095728(Gfx **dlist, MatrixS **matrices, Vertex **vertices, s32 update } if (D_80126A90) { if (has_ghost_to_save()) { - gResultOptionText[gResultOptionCount-1] = gMenuText[ASSET_MENU_TEXT_SAVEGHOST]; + gResultOptionText[gResultOptionCount - 1] = gMenuText[ASSET_MENU_TEXT_SAVEGHOST]; gResultOptionText[gResultOptionCount] = gMenuText[ASSET_MENU_TEXT_QUIT]; gResultOptionCount++; } @@ -9172,7 +10199,7 @@ s32 func_80095728(Gfx **dlist, MatrixS **matrices, Vertex **vertices, s32 update update_controller_sticks(); buttonsPressed = 0; if (gIgnorePlayerInputTime == FALSE && D_80126C54.unk0_s32 < 0) { - for(i = 0; i < numPlayers; i++) { + for (i = 0; i < numPlayers; i++) { buttonsPressed |= get_buttons_pressed_from_player(i); } } @@ -9185,7 +10212,8 @@ s32 func_80095728(Gfx **dlist, MatrixS **matrices, Vertex **vertices, s32 update break; case 1: if (D_80126A94 > 60 || buttonsPressed & (A_BUTTON | START_BUTTON)) { - viewport_menu_set(0, 80, gTrackSelectViewPortHalfY - ((gTrackSelectViewPortHalfY * 4) / 5), SCREEN_HEIGHT, (gTrackSelectViewPortHalfY / 5) + gTrackSelectViewPortHalfY); + viewport_menu_set(0, 80, gTrackSelectViewPortHalfY - ((gTrackSelectViewPortHalfY * 4) / 5), + SCREEN_HEIGHT, (gTrackSelectViewPortHalfY / 5) + gTrackSelectViewPortHalfY); gMenuImageStack[4].unkC = 0.0f; gMenuImageStack[4].unk10 = 36.0f; gMenuImageStack[4].unk8 = sMenuImageProperties[4].unk8; @@ -9212,10 +10240,14 @@ s32 func_80095728(Gfx **dlist, MatrixS **matrices, Vertex **vertices, s32 update transition_begin(&sMenuTransitionFadeIn); gMenuOptionCount = 8; } else if (settings->display_times) { - gRecordTimesMenuElements[3].unk14_a.numberU16 = &settings->courseTimesPtr[*gPlayerSelectVehicle][settings->courseId]; - gRecordTimesMenuElements[6].unk14_a.numberU16 = &settings->flapTimesPtr[*gPlayerSelectVehicle][settings->courseId]; - decompress_filename_string(settings->courseInitialsPtr[*gPlayerSelectVehicle][settings->courseId], D_80126390, 3); - decompress_filename_string(settings->flapInitialsPtr[*gPlayerSelectVehicle][settings->courseId], D_80126394, 3); + gRecordTimesMenuElements[3].unk14_a.numberU16 = + &settings->courseTimesPtr[*gPlayerSelectVehicle][settings->courseId]; + gRecordTimesMenuElements[6].unk14_a.numberU16 = + &settings->flapTimesPtr[*gPlayerSelectVehicle][settings->courseId]; + decompress_filename_string(settings->courseInitialsPtr[*gPlayerSelectVehicle][settings->courseId], + D_80126390, 3); + decompress_filename_string(settings->flapInitialsPtr[*gPlayerSelectVehicle][settings->courseId], + D_80126394, 3); if (settings->racers[0].best_times != 0) { gMenuOptionCount = 4; if ((gIsInTracksMode == 0) && (D_800E0FAC)) { @@ -9241,12 +10273,16 @@ s32 func_80095728(Gfx **dlist, MatrixS **matrices, Vertex **vertices, s32 update case 4: if (menu_enter_filename_loop(updateRate) != 0) { if (settings->racers[0].best_times & 0x7F) { - settings->flapInitialsPtr[*gPlayerSelectVehicle][settings->courseId] = compress_filename_string(gCheckAdvEnterInitials, 3); - decompress_filename_string(settings->flapInitialsPtr[*gPlayerSelectVehicle][settings->courseId], D_80126394, 3); + settings->flapInitialsPtr[*gPlayerSelectVehicle][settings->courseId] = + compress_filename_string(gCheckAdvEnterInitials, 3); + decompress_filename_string(settings->flapInitialsPtr[*gPlayerSelectVehicle][settings->courseId], + D_80126394, 3); } if (settings->racers[0].best_times & 0x80) { - settings->courseInitialsPtr[*gPlayerSelectVehicle][settings->courseId] = compress_filename_string(gCheckAdvEnterInitials, 3); - decompress_filename_string(settings->courseInitialsPtr[*gPlayerSelectVehicle][settings->courseId], D_80126390, 3); + settings->courseInitialsPtr[*gPlayerSelectVehicle][settings->courseId] = + compress_filename_string(gCheckAdvEnterInitials, 3); + decompress_filename_string(settings->courseInitialsPtr[*gPlayerSelectVehicle][settings->courseId], + D_80126390, 3); } func_80081E54(gRecordTimesMenuElements, 0.5f, 15.0f, 0.5f, sp38, sp34); gMenuOptionCount = 5; @@ -9312,7 +10348,7 @@ s32 func_80095728(Gfx **dlist, MatrixS **matrices, Vertex **vertices, s32 update sp54 = 1; gMenuSubOption = 0; } else { - for(i = 0; i < numPlayers; i++) { + for (i = 0; i < numPlayers; i++) { if ((gControllersYAxisDirection[i] > 0) && (gMenuSubOption == 2)) { gMenuSubOption = 1; } @@ -9339,7 +10375,7 @@ s32 func_80095728(Gfx **dlist, MatrixS **matrices, Vertex **vertices, s32 update } } else { prevMenuOption = gMenuOption; - for(i = 0; i < numPlayers; i++) { + for (i = 0; i < numPlayers; i++) { if (gControllersYAxisDirection[i] < 0) { if (gMenuOption < (gResultOptionCount - 1)) { gMenuOption++; @@ -9393,9 +10429,9 @@ s32 func_80095728(Gfx **dlist, MatrixS **matrices, Vertex **vertices, s32 update func_8009ABD8((s8 *) get_misc_asset(ASSET_MISC_25), D_80126C28, 0x101, 0, 0, NULL); } ret = 13; - } else if((gTrophyRaceWorldId != 0)) { + } else if ((gTrophyRaceWorldId != 0)) { ret = 10; - } else if((gNumberOfActivePlayers >= 2)) { + } else if ((gNumberOfActivePlayers >= 2)) { ret = 8; } else { temp_v1_14 = gResultOptionText[gMenuOption]; @@ -9433,7 +10469,7 @@ void func_80096790(void) { s32 temp; s8 *temp2; - temp2 = (s8 *)get_current_level_header(); + temp2 = (s8 *) get_current_level_header(); func_8009C4A8(gRaceResultsObjectIndices); temp = *temp2 - 1; @@ -9454,7 +10490,7 @@ void func_80096790(void) { /** * Initialise the race results menu. * Set the text for the options and set the order of the racer portraits based on finishing position. -*/ + */ void menu_results_init(void) { Settings *settings; u16 *placements; @@ -9504,7 +10540,7 @@ void func_80096978(UNUSED s32 updateRate, f32 opacity) { UNUSED s32 pad; s32 i; Settings *settings; - + settings = get_settings(); sp98 = 0; if (osTvType == TV_TYPE_PAL) { @@ -9523,9 +10559,9 @@ void func_80096978(UNUSED s32 updateRate, f32 opacity) { set_text_colour(255, 255, 255, 0, sMenuGuiOpacity); draw_text(&sMenuCurrDisplayList, POS_CENTRED, 34, gMenuText[ASSET_MENU_TEXT_RANKINGS], ALIGN_MIDDLE_CENTER); sMenuGuiOpacity = 255; - spA4 = 160 - ((gNumberOfActivePlayers - 1) << 5);; + spA4 = 160 - ((gNumberOfActivePlayers - 1) << 5); x2 = spA4; - + for (i = 0; i < gNumberOfActivePlayers; i++) { if (settings->racers[i].starting_position == 0) { if (gOptionBlinkTimer < 32) { @@ -9536,11 +10572,11 @@ void func_80096978(UNUSED s32 updateRate, f32 opacity) { } else { spA0 = 255; } - render_textured_rectangle(&sMenuCurrDisplayList, gRacerPortraits[settings->racers[i].character], - x2 - 20, 54 - (s32) (240 * opacity), spA0, spA0, spA0, 255); + render_textured_rectangle(&sMenuCurrDisplayList, gRacerPortraits[settings->racers[i].character], x2 - 20, + 54 - (s32) (240 * opacity), spA0, spA0, spA0, 255); x2 += 64; } - + spA4 = spA4 + (s32) (320 * opacity); // Cannot use += here? set_text_font(ASSET_FONTS_FUNFONT); y2 = 0x68; @@ -9567,7 +10603,7 @@ void func_80096978(UNUSED s32 updateRate, f32 opacity) { time -= (hundredths * 100); tens = time / 10; time -= tens * 10; - + // I'm 99% sure these need to be gMenuImageStack[0] // Changing it to gMenuImageStack[spA0] or gMenuImageStack[i] makes the score worse. gMenuImageStack[0].unk10 = (SCREEN_HEIGHT_HALF - y2); @@ -9579,7 +10615,7 @@ void func_80096978(UNUSED s32 updateRate, f32 opacity) { gMenuImageStack[0].unk18 = tens; func_8009CA60(0); gMenuImageStack[0].unkC += 12.0f; - } else if((tens > 0)) { + } else if (tens > 0) { gMenuImageStack[0].unkC = (x2 - 166); gMenuImageStack[0].unk18 = tens; func_8009CA60(0); @@ -9610,7 +10646,8 @@ void func_80096978(UNUSED s32 updateRate, f32 opacity) { } if (gMenuSubOption != 0) { y2 -= 24; - render_dialogue_text(7, POS_CENTRED, y2 + 8, gMenuText[ASSET_MENU_TEXT_QUITGAMETITLE], 1, ALIGN_MIDDLE_CENTER); + render_dialogue_text(7, POS_CENTRED, y2 + 8, gMenuText[ASSET_MENU_TEXT_QUITGAMETITLE], 1, + ALIGN_MIDDLE_CENTER); if (gMenuSubOption == 1) { set_current_text_colour(7, 255, 255, 255, spA0, 255); } else { @@ -9624,8 +10661,8 @@ void func_80096978(UNUSED s32 updateRate, f32 opacity) { } render_dialogue_text(7, POS_CENTRED, y2 + 0x2A, gMenuText[ASSET_MENU_TEXT_CANCEL], 1, ALIGN_MIDDLE_CENTER); } else { - - for (i = 0, y2 = 12; i < gResultOptionCount; ) { + + for (i = 0, y2 = 12; i < gResultOptionCount;) { if (i == gMenuOption) { set_current_text_colour(7, 255, 255, 255, spA0, 255); } else { @@ -9640,7 +10677,6 @@ void func_80096978(UNUSED s32 updateRate, f32 opacity) { } } - s32 menu_results_loop(s32 updateRate) { s32 playBackSound; s32 playSelectSound; @@ -9729,7 +10765,7 @@ s32 menu_results_loop(s32 updateRate) { } else if (playPickSound) { sound_play(SOUND_MENU_PICK2, NULL); } - + } else { gMenuDelay += updateRate; if (gMenuDelay > 30) { @@ -9737,7 +10773,7 @@ s32 menu_results_loop(s32 updateRate) { close_dialogue_box(7); assign_dialogue_box_id(7); if (gResultOptionText[gMenuOption] == gMenuText[ASSET_MENU_TEXT_TRYAGAIN]) { - return (0x100 | 0x2); //This gets parsed in menu_logic_loop as a flag and an ID from the bottom 7 bits. + return (0x100 | 0x2); // This gets parsed in menu_logic_loop as a flag and an ID from the bottom 7 bits. } if (gResultOptionText[gMenuOption] == gMenuText[ASSET_MENU_TEXT_SELECTTRACK]) { load_level_for_menu(SPECIAL_MAP_ID_NO_LEVEL, -1, 0); @@ -9799,7 +10835,7 @@ s32 compress_filename_string(char *filename, s32 length) { while (currentChar != gFileNameValidChars[charIndex]) { charIndex++; - if (charIndex >= (s32)(sizeof(gFileNameValidChars) - 1)) { + if (charIndex >= (s32) (sizeof(gFileNameValidChars) - 1)) { break; } } @@ -9811,18 +10847,18 @@ s32 compress_filename_string(char *filename, s32 length) { return output; } -void trim_filename_string(char* input, char* output) { - s32 some_ptr; +void trim_filename_string(char *input, char *output) { + s32 some_ptr; u32 zxChar; - char* ptr_to_input; + char *ptr_to_input; char new_var; s32 another_ptr; - char* one_more_ptr; + char *one_more_ptr; some_ptr = 0; if (*input != 0) { new_var = input[some_ptr]; - ptr_to_input = input; + ptr_to_input = input; zxChar = new_var; do { another_ptr = some_ptr; @@ -9873,7 +10909,7 @@ void func_80097874(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 *arg4, char *file * Draw menu for "Enter your initials" when starting a new game. * The text entry is a horizontal list of characters you scroll through. * Visual Aid: https://imgur.com/llVwdTy -*/ + */ void render_enter_filename_ui(UNUSED s32 updateRate) { s32 xIncrement; s32 charIndexIncrement; @@ -9893,20 +10929,22 @@ void render_enter_filename_ui(UNUSED s32 updateRate) { // Draw "Enter Initials" shadow set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 2, gEnterInitalsY - 22, gMenuText[ASSET_MENU_TEXT_ENTERINITIALS], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 2, gEnterInitalsY - 22, + gMenuText[ASSET_MENU_TEXT_ENTERINITIALS], ALIGN_MIDDLE_CENTER); // Draw "Enter Initials" text set_text_colour(255, 128, 255, 96, 255); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, gEnterInitalsY - 24, gMenuText[ASSET_MENU_TEXT_ENTERINITIALS], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, gEnterInitalsY - 24, gMenuText[ASSET_MENU_TEXT_ENTERINITIALS], + ALIGN_MIDDLE_CENTER); y = gEnterInitalsY; - + // Doesn't match with a for loop. i = 0; while (i < 2) { x = xStart; charIndex = startCharacterIndex; - if (i != 0) { + if (i != 0) { x = xStart - 40; charIndex = startCharacterIndex - 1; xIncrement = -40; @@ -9915,7 +10953,7 @@ void render_enter_filename_ui(UNUSED s32 updateRate) { xIncrement = 40; charIndexIncrement = 1; } - while(((x >= -15) && (x < 336))) { + while (((x >= -15) && (x < 336))) { if (charIndex < 0) { charIndex = 30; } @@ -10116,7 +11154,7 @@ void func_80098208(void) { /** * Initialise the trophy race intro. * Finds which level should be next, then loads it for the preview. -*/ + */ void menu_trophy_race_round_init(void) { s32 i; s32 index; @@ -10135,7 +11173,9 @@ void menu_trophy_race_round_init(void) { // Is this a fakematch? I can't tell. do { index = levelIds[((gTrophyRaceWorldId - 1) * 6) + gTrophyRaceRound]; - if(index != -1) continue; + if (index != -1) { + continue; + } index = (index + 1) & 3; } while (index == -1); @@ -10164,7 +11204,7 @@ void draw_trophy_race_text(UNUSED s32 updateRate) { char *levelName; s8 *levelIds; - levelIds = (s8 *)get_misc_asset(ASSET_MISC_TRACKS_MENU_IDS); + levelIds = (s8 *) get_misc_asset(ASSET_MISC_TRACKS_MENU_IDS); if (osTvType == TV_TYPE_PAL) { yPos = 18; } else { @@ -10175,15 +11215,19 @@ void draw_trophy_race_text(UNUSED s32 updateRate) { levelName = get_level_name(levelIds[((gTrophyRaceWorldId - 1) * 6) + gTrophyRaceRound]); set_text_background_colour(0, 0, 0, 0); set_text_font(ASSET_FONTS_BIGFONT); - //Text Shadows first + // Text Shadows first set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, (char *)worldName, ALIGN_MIDDLE_CENTER); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 67, gMenuText[ASSET_MENU_TEXT_TROPHYRACE], ALIGN_MIDDLE_CENTER); // TROPHY RACE + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, (char *) worldName, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 67, gMenuText[ASSET_MENU_TEXT_TROPHYRACE], + ALIGN_MIDDLE_CENTER); // TROPHY RACE set_text_colour(255, 255, 255, 0, 255); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, (char *)worldName, ALIGN_MIDDLE_CENTER); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 64, gMenuText[ASSET_MENU_TEXT_TROPHYRACE], ALIGN_MIDDLE_CENTER); // TROPHY RACE - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos + 176, gMenuText[ASSET_MENU_TEXT_ROUNDONE + gTrophyRaceRound], ALIGN_MIDDLE_CENTER); // ROUND ONE / ROUND TWO / ROUND THREE / ROUND FOUR - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos + 208, (char *)levelName, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, (char *) worldName, ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 64, gMenuText[ASSET_MENU_TEXT_TROPHYRACE], + ALIGN_MIDDLE_CENTER); // TROPHY RACE + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos + 176, + gMenuText[ASSET_MENU_TEXT_ROUNDONE + gTrophyRaceRound], + ALIGN_MIDDLE_CENTER); // ROUND ONE / ROUND TWO / ROUND THREE / ROUND FOUR + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, yPos + 208, (char *) levelName, ALIGN_MIDDLE_CENTER); } s32 menu_trophy_race_round_loop(s32 updateRate) { @@ -10191,11 +11235,11 @@ s32 menu_trophy_race_round_loop(s32 updateRate) { s16 ttVoiceLine; s32 temp; - trackMenuIds = (s8 *)get_misc_asset(ASSET_MISC_TRACKS_MENU_IDS); //tracks_menu_ids + trackMenuIds = (s8 *) get_misc_asset(ASSET_MISC_TRACKS_MENU_IDS); // tracks_menu_ids if (gTrackNameVoiceDelay != 0) { gTrackNameVoiceDelay -= updateRate; if (gTrackNameVoiceDelay <= 0) { - //This is mostly likely supposed to be a multi dimensional array + // This is mostly likely supposed to be a multi dimensional array temp = trackMenuIds[(((gTrophyRaceWorldId - 1) * 6) + gTrophyRaceRound)]; ttVoiceLine = gTTVoiceLines[temp]; if (ttVoiceLine != -1) { @@ -10269,24 +11313,24 @@ void func_80098774(s32 isRankings) { menuElemIndex = 2; if (xPositions != NULL && yPositions != NULL) { for (racerIndex = 0; racerIndex < gRankingPlayerCount; racerIndex++) { - for(temp = 0; temp < 3; temp++) { - gTrophyRankingsTitle[menuElemIndex+temp].left = *xPositions; - gTrophyRankingsTitle[menuElemIndex+temp].center = *xPositions; - gTrophyRankingsTitle[menuElemIndex+temp].right = *xPositions; + for (temp = 0; temp < 3; temp++) { + gTrophyRankingsTitle[menuElemIndex + temp].left = *xPositions; + gTrophyRankingsTitle[menuElemIndex + temp].center = *xPositions; + gTrophyRankingsTitle[menuElemIndex + temp].right = *xPositions; xPositions++; if ((gRankingPlayerCount >= 5) && (racerIndex >= (gRankingPlayerCount >> 1))) { - gTrophyRankingsTitle[menuElemIndex+temp].top = *yPositions - yOffset; - gTrophyRankingsTitle[menuElemIndex+temp].middle = *yPositions; - gTrophyRankingsTitle[menuElemIndex+temp].bottom = *yPositions + yOffset; + gTrophyRankingsTitle[menuElemIndex + temp].top = *yPositions - yOffset; + gTrophyRankingsTitle[menuElemIndex + temp].middle = *yPositions; + gTrophyRankingsTitle[menuElemIndex + temp].bottom = *yPositions + yOffset; yPositions++; } else { - gTrophyRankingsTitle[menuElemIndex+temp].top = *yPositions + yOffset; - gTrophyRankingsTitle[menuElemIndex+temp].middle = *yPositions; - gTrophyRankingsTitle[menuElemIndex+temp].bottom = *yPositions - yOffset; + gTrophyRankingsTitle[menuElemIndex + temp].top = *yPositions + yOffset; + gTrophyRankingsTitle[menuElemIndex + temp].middle = *yPositions; + gTrophyRankingsTitle[menuElemIndex + temp].bottom = *yPositions - yOffset; yPositions++; } } - + // Regalloc issue here. temp = gRankingPlayerCount & 3; if (temp) { @@ -10298,17 +11342,18 @@ void func_80098774(s32 isRankings) { greenAmount = racerIndex & 3; } temp = 255 - (greenAmount << 6); - - gTrophyRankingsTitle[menuElemIndex+2].filterGreen = temp; + + gTrophyRankingsTitle[menuElemIndex + 2].filterGreen = temp; if (isRankings) { - gTrophyRankingsTitle[menuElemIndex].unk14_a.drawTexture = gRacerPortraits[settings->racers[D_80126430[racerIndex]].character]; - gTrophyRankingsTitle[menuElemIndex+2].unk14_a.element = &settings->racers[D_80126430[racerIndex]]; + gTrophyRankingsTitle[menuElemIndex].unk14_a.drawTexture = + gRacerPortraits[settings->racers[D_80126430[racerIndex]].character]; + gTrophyRankingsTitle[menuElemIndex + 2].unk14_a.element = &settings->racers[D_80126430[racerIndex]]; } else { - gTrophyRankingsTitle[menuElemIndex].unk14_a.drawTexture = gRacerPortraits[settings->racers[D_80126428[racerIndex]].character]; - gTrophyRankingsTitle[menuElemIndex+2].unk14_a.number = &gTrophyRacePointsArray[racerIndex]; + gTrophyRankingsTitle[menuElemIndex].unk14_a.drawTexture = + gRacerPortraits[settings->racers[D_80126428[racerIndex]].character]; + gTrophyRankingsTitle[menuElemIndex + 2].unk14_a.number = &gTrophyRacePointsArray[racerIndex]; } menuElemIndex += 3; - } } gTrophyRankingsTitle[menuElemIndex].unk14_a.asciiText = NULL; @@ -10321,7 +11366,7 @@ GLOBAL_ASM("asm/non_matchings/menu/func_80098774.s") /** * Initialise trophy race points screen. * Sets the order of the racer portraits based on points position. -*/ + */ void menu_trophy_race_rankings_init(void) { UNUSED s32 pad0; UNUSED s32 pad1; @@ -10345,9 +11390,11 @@ void menu_trophy_race_rankings_init(void) { allocate_menu_images(gTrophyRaceImageIndices); gPrevTrophyRaceRound = gTrophyRaceRound; do { - if(++gTrophyRaceRound >= 4) break; - } while((trackMenuIds[((gTrophyRaceWorldId - 1) * 6) + (gTrophyRaceRound)] == -1)); - + if (++gTrophyRaceRound >= 4) { + break; + } + } while ((trackMenuIds[((gTrophyRaceWorldId - 1) * 6) + (gTrophyRaceRound)] == -1)); + if (gTrophyRaceRound < 4) { gResultOptionText[0] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; gResultOptionText[1] = gMenuText[ASSET_MENU_TEXT_QUITTROPHYRACE]; @@ -10358,7 +11405,7 @@ void menu_trophy_race_rankings_init(void) { } gMenuOption = 0; assign_racer_portrait_textures(); - + if (gNumberOfActivePlayers > 2) { gRankingPlayerCount = gNumberOfActivePlayers; } else if ((gNumberOfActivePlayers == 2) || (is_in_two_player_adventure())) { @@ -10366,8 +11413,8 @@ void menu_trophy_race_rankings_init(void) { } else { gRankingPlayerCount = 8; } - for(i = 0; i < gRankingPlayerCount; i++) { - for(j = 0; j < gRankingPlayerCount; j++) { + for (i = 0; i < gRankingPlayerCount; i++) { + for (j = 0; j < gRankingPlayerCount; j++) { if (i == settings->racers[j].starting_position) { D_80126428[i] = j; if (j < gNumberOfActivePlayers) { @@ -10377,34 +11424,34 @@ void menu_trophy_race_rankings_init(void) { } } } - } - for(i = 0; i < gRankingPlayerCount; i++){ + } + for (i = 0; i < gRankingPlayerCount; i++) { D_801263F8[i] = gTrophyRacePointsArray[settings->racers[i].starting_position]; } - for(i = 0; i < gRankingPlayerCount; i++){ + for (i = 0; i < gRankingPlayerCount; i++) { D_80126430[i] = i; sp48[i] = settings->racers[i].trophy_points + D_801263F8[i]; } - - for (i = gRankingPlayerCount-1; i > 0; i--) { + + for (i = gRankingPlayerCount - 1; i > 0; i--) { for (j = 0; j < i; j++) { - if(sp48[j] < sp48[j+1]) { + if (sp48[j] < sp48[j + 1]) { tempForSwap = sp48[j]; - sp48[j] = sp48[j+1]; - sp48[j+1] = tempForSwap; + sp48[j] = sp48[j + 1]; + sp48[j + 1] = tempForSwap; tempForSwap = D_80126430[j]; - D_80126430[j] = D_80126430[j+1]; - D_80126430[j+1] = tempForSwap; + D_80126430[j] = D_80126430[j + 1]; + D_80126430[j + 1] = tempForSwap; } } } - + if (is_in_two_player_adventure()) { j = 2; } else { j = gNumberOfActivePlayers; } - for(i = 0; i < gRankingPlayerCount; i++) { + for (i = 0; i < gRankingPlayerCount; i++) { if (D_80126430[i] < j) { D_80126420[i] = 1; } else { @@ -10425,7 +11472,7 @@ void func_80098EBC(s32 updateRate) { s32 fade; s32 i; UNUSED MenuElement *test2; - + gOptionBlinkTimer = (gOptionBlinkTimer + updateRate) & 0x3F; test = gOptionBlinkTimer * 8; if (test > 255) { @@ -10433,12 +11480,13 @@ void func_80098EBC(s32 updateRate) { } for (i = 0; i < gRankingPlayerCount; i++) { fade = 255; - if (gNumberOfActivePlayers <= 2 && ((gMenuOptionCount == 0 && D_80126418[i]) || (gMenuOptionCount != 0 && D_80126420[i]))) { + if (gNumberOfActivePlayers <= 2 && + ((gMenuOptionCount == 0 && D_80126418[i]) || (gMenuOptionCount != 0 && D_80126420[i]))) { fade = (test >> 1) + 128; } - gTrophyRankingsRacers[i*3].filterRed = fade; - gTrophyRankingsRacers[i*3].filterGreen = fade; - gTrophyRankingsRacers[i*3].filterBlue = fade; + gTrophyRankingsRacers[i * 3].filterRed = fade; + gTrophyRankingsRacers[i * 3].filterGreen = fade; + gTrophyRankingsRacers[i * 3].filterBlue = fade; } new_var2 = gMenuOptionCount; if (new_var2 == 2 || new_var2 == 3) { @@ -10466,128 +11514,129 @@ s32 menu_trophy_race_rankings_loop(s32 updateRate) { } update_controller_sticks(); switch (gMenuOptionCount) { // gMenuOptionCount = current Trophy Race Rankings state? - case 0: - if (func_80081F4C(updateRate) != 0) { - gMenuOptionCount = 1; - func_80098774(1); - func_80081E54(gTrophyRankingsTitle, 0.5f, 0.0f, 0.0f, 0, 0); - } - break; - case 1: - if (func_80081F4C(updateRate) != 0) { - gMenuOptionCount = 2; - draw_menu_elements(1, gTrophyRankingsTitle, 1.0f); - } - break; - case 2: - gOpacityDecayTimer += updateRate; - if (gOpacityDecayTimer > 10) { - gOpacityDecayTimer -= 10; - temp5 = 0; - for(i = 0; i < gRankingPlayerCount; i++) { - if (D_801263F8[i] > 0) { - D_801263F8[i]--; - temp5 = 1; - settings->racers[i].trophy_points++; - } + case 0: + if (func_80081F4C(updateRate) != 0) { + gMenuOptionCount = 1; + func_80098774(1); + func_80081E54(gTrophyRankingsTitle, 0.5f, 0.0f, 0.0f, 0, 0); } - if (temp5) { - sound_play(SOUND_TING_HIGH, NULL); + break; + case 1: + if (func_80081F4C(updateRate) != 0) { + gMenuOptionCount = 2; + draw_menu_elements(1, gTrophyRankingsTitle, 1.0f); } - } - - buttonsPressed = 0; - temp1 = gMenuOption; - for (i = 0; i < gNumberOfActivePlayers; i++) { - buttonsPressed |= get_buttons_pressed_from_player(i); - if (gControllersYAxisDirection[i] < 0) { - gMenuOption++; - } - if (gControllersYAxisDirection[i] > 0) { - gMenuOption--; - } - } - if (gMenuOption < 0) { - gMenuOption = 0; - } - if (gMenuOption >= gResultOptionCount) { - gMenuOption = gResultOptionCount - 1; - } - if (temp1 != gMenuOption) { - sound_play(SOUND_MENU_PICK2, NULL); - } - if (buttonsPressed & (A_BUTTON | START_BUTTON)) { - music_fade(-128); - transition_begin(&sMenuTransitionFadeIn); - gMenuOptionCount = 3; - for(i = 0; i < gRankingPlayerCount; i++){ - settings->racers[i].trophy_points += D_801263F8[i]; - } - } - break; - case 3: - gMenuDelay += updateRate; - if (gMenuDelay >= 31) { - func_80099600(); - close_dialogue_box(7); - assign_dialogue_box_id(7); - if (gTrophyRaceRound < 4) { - menu_init(MENU_TROPHY_RACE_ROUND); - } else { - for(temp6 = 0, i = 0; i < gRankingPlayerCount; i++) { - if (D_80126420[i] != 0) { - temp7 = settings->racers[D_80126430[i]].character; - if (temp6 == 0) { - sp34 = i; - D_80126438[temp6++] = temp7; - continue; - } - if (settings->racers[D_80126430[i]].trophy_points == settings->racers[D_80126430[sp34]].trophy_points) { - D_80126438[temp6++] = temp7; - } + break; + case 2: + gOpacityDecayTimer += updateRate; + if (gOpacityDecayTimer > 10) { + gOpacityDecayTimer -= 10; + temp5 = 0; + for (i = 0; i < gRankingPlayerCount; i++) { + if (D_801263F8[i] > 0) { + D_801263F8[i]--; + temp5 = 1; + settings->racers[i].trophy_points++; } } - - if (gNumberOfActivePlayers == 1 && !is_in_two_player_adventure()) { - temp6 = 0; + if (temp5) { + sound_play(SOUND_TING_HIGH, NULL); } - D_80126438[temp6] = -1; - if (gIsInTracksMode == 1) { - if (sp34 >= 3) { - menu_init(MENU_TRACK_SELECT); - } else { - ret = MENU_RESULT_FLAGS_100 | MENU_RESULT_TRACKS_MODE; - } + } + + buttonsPressed = 0; + temp1 = gMenuOption; + for (i = 0; i < gNumberOfActivePlayers; i++) { + buttonsPressed |= get_buttons_pressed_from_player(i); + if (gControllersYAxisDirection[i] < 0) { + gMenuOption++; + } + if (gControllersYAxisDirection[i] > 0) { + gMenuOption--; + } + } + if (gMenuOption < 0) { + gMenuOption = 0; + } + if (gMenuOption >= gResultOptionCount) { + gMenuOption = gResultOptionCount - 1; + } + if (temp1 != gMenuOption) { + sound_play(SOUND_MENU_PICK2, NULL); + } + if (buttonsPressed & (A_BUTTON | START_BUTTON)) { + music_fade(-128); + transition_begin(&sMenuTransitionFadeIn); + gMenuOptionCount = 3; + for (i = 0; i < gRankingPlayerCount; i++) { + settings->racers[i].trophy_points += D_801263F8[i]; + } + } + break; + case 3: + gMenuDelay += updateRate; + if (gMenuDelay >= 31) { + func_80099600(); + close_dialogue_box(7); + assign_dialogue_box_id(7); + if (gTrophyRaceRound < 4) { + menu_init(MENU_TROPHY_RACE_ROUND); } else { - ret = MENU_RESULT_RETURN_TO_GAME; - settings->courseId = get_hub_area_id(settings->worldId); - if (gInAdvModeTrophyRace != 0) { - gInAdvModeTrophyRace = 0; - ret = settings->courseId | MENU_RESULT_FLAGS_200; - if (sp34 < 3) { - temp0 = settings->worldId - 1; - temp0 <<= 1; - temp1 = ((3 - sp34) & 3); - temp6 = (settings->trophies >> temp0) & 3; - if (temp6 < temp1) { - settings->trophies &= ~(3 << temp0); - settings->trophies |= (temp1 << temp0); - safe_mark_write_save_file(get_save_file_index()); + for (temp6 = 0, i = 0; i < gRankingPlayerCount; i++) { + if (D_80126420[i] != 0) { + temp7 = settings->racers[D_80126430[i]].character; + if (temp6 == 0) { + sp34 = i; + D_80126438[temp6++] = temp7; + continue; + } + if (settings->racers[D_80126430[i]].trophy_points == + settings->racers[D_80126430[sp34]].trophy_points) { + D_80126438[temp6++] = temp7; } } } + + if (gNumberOfActivePlayers == 1 && !is_in_two_player_adventure()) { + temp6 = 0; + } + D_80126438[temp6] = -1; + if (gIsInTracksMode == 1) { + if (sp34 >= 3) { + menu_init(MENU_TRACK_SELECT); + } else { + ret = MENU_RESULT_FLAGS_100 | MENU_RESULT_TRACKS_MODE; + } + } else { + ret = MENU_RESULT_RETURN_TO_GAME; + settings->courseId = get_hub_area_id(settings->worldId); + if (gInAdvModeTrophyRace != 0) { + gInAdvModeTrophyRace = 0; + ret = settings->courseId | MENU_RESULT_FLAGS_200; + if (sp34 < 3) { + temp0 = settings->worldId - 1; + temp0 <<= 1; + temp1 = ((3 - sp34) & 3); + temp6 = (settings->trophies >> temp0) & 3; + if (temp6 < temp1) { + settings->trophies &= ~(3 << temp0); + settings->trophies |= (temp1 << temp0); + safe_mark_write_save_file(get_save_file_index()); + } + } + } + } + if (sp34 < 3) { + miscAsset31 = (s8 *) get_misc_asset(ASSET_MISC_31); + temp0 = ((gTrophyRaceWorldId * 3) + sp34) - 3; + func_8009ABD8(miscAsset31, temp0, ret, 0, 0, D_80126438); + ret = MENU_RESULT_CONTINUE; + menu_init(MENU_NEWGAME_CINEMATIC); + } + gTrophyRaceWorldId = 0; } - if (sp34 < 3) { - miscAsset31 = (s8 *) get_misc_asset(ASSET_MISC_31); - temp0 = ((gTrophyRaceWorldId * 3) + sp34) - 3; - func_8009ABD8(miscAsset31, temp0, ret, 0, 0, D_80126438); - ret = MENU_RESULT_CONTINUE; - menu_init(MENU_NEWGAME_CINEMATIC); - } - gTrophyRaceWorldId = 0; } - } - break; + break; } gIgnorePlayerInputTime = 0; return ret; @@ -10606,17 +11655,17 @@ void func_8009963C(void) { u8 *mainTrackIds; s32 i; s32 j; - u16 sp44[4]; + u16 sp44[4]; u16 swap; u16 swapByte; UNUSED s32 pad; D_801264D4 = 0; mainTrackIds = (u8 *) get_misc_asset(ASSET_MISC_MAIN_TRACKS_IDS); - - for(i = 0; i < 6; i++) { + + for (i = 0; i < 6; i++) { if (D_801264DC[i] != 0xFF) { - for(j = 0; mainTrackIds[j] != 0xFF && mainTrackIds[j] != D_801264DC[i]; j++) {} + for (j = 0; mainTrackIds[j] != 0xFF && mainTrackIds[j] != D_801264DC[i]; j++) {} if (mainTrackIds[j] != 0xFF) { D_80126540[D_801264D4] = i; sp44[D_801264D4] = (j * 8) + D_801264EC[i]; @@ -10625,20 +11674,20 @@ void func_8009963C(void) { } } - for(i = D_801264D4-1; i > 0; i--) { + for (i = D_801264D4 - 1; i > 0; i--) { for (j = 0; j < i; j++) { - if(sp44[j+1] < sp44[j]) { + if (sp44[j + 1] < sp44[j]) { swap = sp44[j]; - sp44[j] = sp44[j+1]; - sp44[j+1] = swap; + sp44[j] = sp44[j + 1]; + sp44[j + 1] = swap; swapByte = D_80126540[j]; - D_80126540[j] = D_80126540[j+1]; - D_80126540[j+1] = swapByte; + D_80126540[j] = D_80126540[j + 1]; + D_80126540[j + 1] = swapByte; } } } - - for(i = 0; i < D_801264D4; i++) { + + for (i = 0; i < D_801264D4; i++) { D_80126508[i] = D_801264DC[D_80126540[i]]; D_80126510[i] = D_801264E4[D_80126540[i]]; D_80126518[i] = D_801264EC[D_80126540[i]]; @@ -10659,15 +11708,15 @@ s32 func_800998E0(s32 arg0) { if (result == 0) { D_801264DC[temp_s0] = 0xFF; D_801264D4--; - for(i = arg0; i < D_801264D4; i++) { + for (i = arg0; i < D_801264D4; i++) { D_80126540[i] = D_80126540[i + 1]; D_80126508[i] = D_80126508[i + 1]; D_80126510[i] = D_80126510[i + 1]; D_80126518[i] = D_80126518[i + 1]; D_80126520[i] = D_80126520[i + 1]; } - for(i = 0; i < D_801264D4; i++) { - if(temp_s0 < D_80126540[i]) { + for (i = 0; i < D_801264D4; i++) { + if (temp_s0 < D_80126540[i]) { D_80126540[i]--; } } @@ -10763,13 +11812,15 @@ void func_80099E8C(UNUSED s32 updateRate) { set_text_font(FONT_LARGE); set_text_background_colour(0, 0, 0, 0); set_text_colour(0, 0, 0, 255, 128); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_GHOSTDATA], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF + 1, 35, gMenuText[ASSET_MENU_TEXT_GHOSTDATA], + ALIGN_MIDDLE_CENTER); set_text_colour(255, 255, 255, 0, 255); draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, 32, gMenuText[ASSET_MENU_TEXT_GHOSTDATA], ALIGN_MIDDLE_CENTER); y = 56; if (D_801264D4 <= 0) { set_text_colour(255, 255, 255, 0, 255); - draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, heightAdjust + SCREEN_HEIGHT_HALF, gMenuText[ASSET_MENU_TEXT_NOGHOSTSSAVED], ALIGN_MIDDLE_CENTER); + draw_text(&sMenuCurrDisplayList, SCREEN_WIDTH_HALF, heightAdjust + SCREEN_HEIGHT_HALF, + gMenuText[ASSET_MENU_TEXT_NOGHOSTSSAVED], ALIGN_MIDDLE_CENTER); return; } spE8 = 3; @@ -10781,32 +11832,38 @@ void func_80099E8C(UNUSED s32 updateRate) { set_text_font(FONT_SMALL); x = 40; while (spE4 < D_801264D4 && spE8 > 0) { - if (gGhostDataElementPositions[0]){} // Fakematch + if (gGhostDataElementPositions[0]) {} // Fakematch currentWorldId = get_map_world_id(D_80126508[spE4]) - 1; if (currentWorldId < 0 || currentWorldId >= 5) { currentWorldId = 0; } levelName = get_level_name(D_80126508[spE4]); - for(i = 0; (levelName[i] != '\0') && (i < 63); i++) { + for (i = 0; (levelName[i] != '\0') && (i < 63); i++) { textBuffer[i] = levelName[i]; if ((textBuffer[i] >= 'a') && (textBuffer[i] <= 'z')) { textBuffer[i] ^= 0x20; // Force uppercase. } } textBuffer[i] = '\0'; // Set NULL terminator - render_texture_rectangle_scaled(&sMenuCurrDisplayList, gDrawTexWorldBgs[currentWorldId], x, y, 0.75f, 0.8125f, COLOUR_RGBA32(255, 255, 255, 255), 0); + render_texture_rectangle_scaled(&sMenuCurrDisplayList, gDrawTexWorldBgs[currentWorldId], x, y, 0.75f, 0.8125f, + COLOUR_RGBA32(255, 255, 255, 255), 0); func_80080E90(&sMenuCurrDisplayList, 40, y, 240, 52, 4, 4, 32, 80, 176, 128); if (spE4 == D_80126498) { - func_80080E90(&sMenuCurrDisplayList, 40, y, 240, 52, 4, 4, colourIntensity, colourIntensity, colourIntensity, colourIntensity); + func_80080E90(&sMenuCurrDisplayList, 40, y, 240, 52, 4, 4, colourIntensity, colourIntensity, + colourIntensity, colourIntensity); } set_text_colour(0, 0, 0, 255, 255); - for(i = 0; i < 4; i++) { - draw_text(&sMenuCurrDisplayList, gGhostDataElementPositions[0] + 40 + D_800E1E20[(i<<1)], y + gGhostDataElementPositions[1] + D_800E1E20[(i<<1)+1], textBuffer, ALIGN_MIDDLE_CENTER); + for (i = 0; i < 4; i++) { + draw_text(&sMenuCurrDisplayList, gGhostDataElementPositions[0] + 40 + D_800E1E20[(i << 1)], + y + gGhostDataElementPositions[1] + D_800E1E20[(i << 1) + 1], textBuffer, ALIGN_MIDDLE_CENTER); } set_text_colour(200, 228, 80, 255, 255); - draw_text(&sMenuCurrDisplayList, gGhostDataElementPositions[0] + 40, gGhostDataElementPositions[1] + y, textBuffer, ALIGN_MIDDLE_CENTER); - render_textured_rectangle(&sMenuCurrDisplayList, gRacerPortraits[D_80126510[spE4]], gGhostDataElementPositions[2] + 40, gGhostDataElementPositions[3] + y, 255, 255, 255, 255); + draw_text(&sMenuCurrDisplayList, gGhostDataElementPositions[0] + 40, gGhostDataElementPositions[1] + y, + textBuffer, ALIGN_MIDDLE_CENTER); + render_textured_rectangle(&sMenuCurrDisplayList, gRacerPortraits[D_80126510[spE4]], + gGhostDataElementPositions[2] + 40, gGhostDataElementPositions[3] + y, 255, 255, 255, + 255); switch (D_80126518[spE4]) { case 1: vehicleSelectTex = gRaceSelectionHoverTex; @@ -10818,17 +11875,23 @@ void func_80099E8C(UNUSED s32 updateRate) { vehicleSelectTex = gRaceSelectionCarTex; break; } - render_texture_rectangle_scaled(&sMenuCurrDisplayList, vehicleSelectTex, (gGhostDataElementPositions[4] + 40), (gGhostDataElementPositions[5] + y), 0.625f, 0.625f, COLOUR_RGBA32(255, 255, 255, 255), 0); + render_texture_rectangle_scaled(&sMenuCurrDisplayList, vehicleSelectTex, (gGhostDataElementPositions[4] + 40), + (gGhostDataElementPositions[5] + y), 0.625f, 0.625f, + COLOUR_RGBA32(255, 255, 255, 255), 0); reset_render_settings(&sMenuCurrDisplayList); gMenuImageStack[7].unkC = (gGhostDataElementPositions[6] - SCREEN_HEIGHT_HALF); gMenuImageStack[7].unk10 = ((-gGhostDataElementPositions[7] - y) + heightAdjust + SCREEN_HEIGHT_HALF); gMenuImageStack[7].unk8 = 0.075f; func_8009CA60(7); sMenuGuiOpacity = 128; - //Timestamp Shadow gets drawn first - show_timestamp(D_80126520[spE4], gGhostDataElementPositions[8] - (SCREEN_HEIGHT_HALF - 1), (-gGhostDataElementPositions[9] - y) + heightAdjust + (SCREEN_HEIGHT_HALF - 1), 0, 0, 0, FONT_COLOURFUL); + // Timestamp Shadow gets drawn first + show_timestamp(D_80126520[spE4], gGhostDataElementPositions[8] - (SCREEN_HEIGHT_HALF - 1), + (-gGhostDataElementPositions[9] - y) + heightAdjust + (SCREEN_HEIGHT_HALF - 1), 0, 0, 0, + FONT_COLOURFUL); sMenuGuiOpacity = 255; - show_timestamp(D_80126520[spE4], gGhostDataElementPositions[8] - (SCREEN_HEIGHT_HALF + 1), (-gGhostDataElementPositions[9] - y) + heightAdjust + (SCREEN_HEIGHT_HALF + 1), 255, 192, 255, FONT_COLOURFUL); + show_timestamp(D_80126520[spE4], gGhostDataElementPositions[8] - (SCREEN_HEIGHT_HALF + 1), + (-gGhostDataElementPositions[9] - y) + heightAdjust + (SCREEN_HEIGHT_HALF + 1), 255, 192, 255, + FONT_COLOURFUL); spE4++; spE8--; y += 54; @@ -10857,12 +11920,16 @@ void func_80099E8C(UNUSED s32 updateRate) { } if (gOptionBlinkTimer & 0x10) { if ((gOpacityDecayTimer + 3) < D_801264D4) { - render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowDown, SCREEN_WIDTH_HALF + 1, y + 3, 0, 0, 0, 128); - render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowDown, SCREEN_WIDTH_HALF - 1, y + 1, 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowDown, SCREEN_WIDTH_HALF + 1, y + 3, 0, + 0, 0, 128); + render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowDown, SCREEN_WIDTH_HALF - 1, y + 1, 255, + 255, 255, 255); } if (gOpacityDecayTimer > 0) { - render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowUp, SCREEN_WIDTH_HALF + 1, 54, 0, 0, 0, 128); - render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowUp, SCREEN_WIDTH_HALF - 1, 52, 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowUp, SCREEN_WIDTH_HALF + 1, 54, 0, 0, 0, + 128); + render_textured_rectangle(&sMenuCurrDisplayList, gMenuSelectionArrowUp, SCREEN_WIDTH_HALF - 1, 52, 255, 255, + 255, 255); } reset_render_settings(&sMenuCurrDisplayList); } @@ -10906,7 +11973,8 @@ s32 menu_ghost_data_loop(s32 updateRate) { if ((pressedButtons & (START_BUTTON | A_BUTTON)) && (D_801264D4 > 0)) { gMenuOptionCount = 2; sound_play(SOUND_SELECT2, NULL); - } else if ((pressedButtons & B_BUTTON) || ((pressedButtons & (START_BUTTON | A_BUTTON)) && (D_801264D4 == 0))) { + } else if ((pressedButtons & B_BUTTON) || + ((pressedButtons & (START_BUTTON | A_BUTTON)) && (D_801264D4 == 0))) { gMenuDelay = 1; transition_begin(&sMenuTransitionFadeIn); sound_play(SOUND_MENU_BACK3, NULL); @@ -11023,7 +12091,7 @@ s32 menu_cinematic_loop(UNUSED s32 updateRate) { buttonsPressed = 0; if (gIgnorePlayerInputTime == 0) { - for(i = 0; i < gNumberOfActivePlayers; i++) { + for (i = 0; i < gNumberOfActivePlayers; i++) { buttonsPressed |= get_buttons_pressed_from_player(i); } } @@ -11049,15 +12117,14 @@ s32 menu_cinematic_loop(UNUSED s32 updateRate) { } if (D_80126804 != NULL) { for (i = 0; D_80126804[i] != -1; i++) { - render_textured_rectangle(&sMenuCurrDisplayList, gRacerPortraits[D_80126804[i]], 24, 16 + (44 * i), 255, 255, 255, 255); + render_textured_rectangle(&sMenuCurrDisplayList, gRacerPortraits[D_80126804[i]], 24, 16 + (44 * i), 255, + 255, 255, 255); } } gIgnorePlayerInputTime = 0; return MENU_RESULT_CONTINUE; } - - void func_8009AF18(void) { if (D_80126804 != NULL) { func_8009C4A8(gIntroCinematicObjectIndices); @@ -11067,7 +12134,7 @@ void func_8009AF18(void) { /** * Initialise credits sequence. * Sets the ending text depending on when the credits were called. -*/ + */ void menu_credits_init(void) { s32 cheat; s32 cheatIndex; @@ -11109,7 +12176,7 @@ void menu_credits_init(void) { } else { if (settings->bosses & 0x20) { music_play(SEQUENCE_CRESCENT_ISLAND); - gCreditsArray[84] = gCreditsLastMessageArray[1]; // "TO BE CONTINUED ..." + gCreditsArray[84] = gCreditsLastMessageArray[1]; // "TO BE CONTINUED ..." gCreditsControlData[130] = CREDITS_DEV_TIMES(CREDITS_DEV_TIMES_TIME); // Show developer times. D_80126BCC = 9; } else { @@ -11127,8 +12194,8 @@ void menu_credits_init(void) { // The first u16 of gCheatsAssetData is the total number of cheats. // After that is the offsets to the cheat strings. cheatOffsets = *gCheatsAssetData + 1; - gCreditsArray[85] = (char *)(*gCheatsAssetData) + (cheatOffsets)[(cheatIndex << 1) + 1]; // Cheat name - gCreditsArray[86] = (char *)(*gCheatsAssetData) + (cheatOffsets)[(cheatIndex << 1)]; // Cheat code + gCreditsArray[85] = (char *) (*gCheatsAssetData) + (cheatOffsets)[(cheatIndex << 1) + 1]; // Cheat name + gCreditsArray[86] = (char *) (*gCheatsAssetData) + (cheatOffsets)[(cheatIndex << 1)]; // Cheat code } music_change_off(); enable_new_screen_transitions(); @@ -11180,7 +12247,7 @@ void func_8009BD5C(void) { set_active_viewports_and_max(0); set_active_camera(0); - temp_v0 = (unk80069D20 *)get_active_camera_segment(); + temp_v0 = (unk80069D20 *) get_active_camera_segment(); sp2A = temp_v0->unk0; sp28 = temp_v0->unk2; @@ -11211,7 +12278,7 @@ void func_8009BE54() { /** * Reset all menu related joystick inputs for each player. -*/ + */ void reset_controller_sticks(void) { s32 i; for (i = 0; i < 4; i++) { @@ -11230,7 +12297,7 @@ void reset_controller_sticks(void) { /** * Reads the stick inputs, then with the aid of a maximum range and a deadzone, writes it to the menu inputs. * Stick input delay is not time corrected, meaning holding the stick is slower at lower framerates. -*/ + */ void update_controller_sticks(void) { s32 XClamp, YClamp; s32 i; @@ -11391,14 +12458,16 @@ void set_magic_code_flags(s32 flags) { gUnlockedMagicCodes |= flags; } -#define CHEATS_ALLOWED_IN_ADVENTURE_AND_TIME_TRIAL (CHEAT_CONTROL_TT | CHEAT_CONTROL_DRUMSTICK | \ - CHEAT_BIG_CHARACTERS | CHEAT_SMALL_CHARACTERS | CHEAT_HORN_CHEAT | CHEAT_SELECT_SAME_PLAYER | \ - CHEAT_TWO_PLAYER_ADVENTURE | CHEAT_ULTIMATE_AI | CHEAT_EPC_LOCK_UP_DISPLAY | CHEAT_ROM_CHECKSUM) \ +#define CHEATS_ALLOWED_IN_ADVENTURE_AND_TIME_TRIAL \ + (CHEAT_CONTROL_TT | CHEAT_CONTROL_DRUMSTICK | CHEAT_BIG_CHARACTERS | CHEAT_SMALL_CHARACTERS | CHEAT_HORN_CHEAT | \ + CHEAT_SELECT_SAME_PLAYER | CHEAT_TWO_PLAYER_ADVENTURE | CHEAT_ULTIMATE_AI | CHEAT_EPC_LOCK_UP_DISPLAY | \ + CHEAT_ROM_CHECKSUM) // Remember that ~ means NOT. So the challenge maps only allow cheats NOT included here. -#define CHEATS_ALLOWED_IN_CHALLENGES ~(CHEAT_START_WITH_10_BANANAS | CHEAT_DISABLE_BANANAS | \ - CHEAT_DISABLE_WEAPONS | CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | \ - CHEAT_ALL_BALLOONS_ARE_BLUE | CHEAT_ALL_BALLOONS_ARE_YELLOW | CHEAT_ALL_BALLOONS_ARE_RAINBOW) +#define CHEATS_ALLOWED_IN_CHALLENGES \ + ~(CHEAT_START_WITH_10_BANANAS | CHEAT_DISABLE_BANANAS | CHEAT_DISABLE_WEAPONS | CHEAT_ALL_BALLOONS_ARE_RED | \ + CHEAT_ALL_BALLOONS_ARE_GREEN | CHEAT_ALL_BALLOONS_ARE_BLUE | CHEAT_ALL_BALLOONS_ARE_YELLOW | \ + CHEAT_ALL_BALLOONS_ARE_RAINBOW) /** * Filters active cheats based on different conditions. Also enables mirroring for Adventure 2. @@ -11433,7 +12502,7 @@ s32 get_number_of_active_players(void) { * as it would otherwise return 1. */ s32 get_active_player_count(void) { - unk8006BDB0 *temp = (unk8006BDB0 *)get_current_level_header(); + unk8006BDB0 *temp = (unk8006BDB0 *) get_current_level_header(); if (gIsInTwoPlayerAdventure && !gIsInTracksMode) { if (temp->unk4C == 0 || (temp->unk4C & 0x40) != 0) { return 2; @@ -11457,7 +12526,7 @@ s32 get_multiplayer_racer_count(void) { } Settings **get_all_save_files_ptr(void) { - return (Settings **)gSavefileData; + return (Settings **) gSavefileData; } UNUSED void func_8009C49C(void) { @@ -11485,7 +12554,7 @@ void func_8009C508(s32 arg0) { if ((*gAssetsMenuElementIds)[arg0] & 0x4000) { free_object((Object *) (u32) gMenuObjects[arg0]); } else { - free_3d_model((ObjectModel**)(u32)gMenuObjects[arg0]); + free_3d_model((ObjectModel **) (u32) gMenuObjects[arg0]); } } } @@ -11503,7 +12572,7 @@ void func_8009C508(s32 arg0) { if (*gAssetsMenuElementIds != NULL) { free_from_memory_pool(*gAssetsMenuElementIds); *gAssetsMenuElementIds = NULL; - gMenuElementIdCount = (u16)0; + gMenuElementIdCount = (u16) 0; } } } @@ -11518,26 +12587,26 @@ void func_8009C674(s16 *textureIndex) { void func_8009C6D4(s32 arg0) { s32 i; LevelObjectEntryCommon entry; - + if (*gAssetsMenuElementIds == NULL) { *gAssetsMenuElementIds = (s16 *) load_asset_section_from_rom(ASSET_MENU_ELEMENT_IDS); - for(gMenuElementIdCount = 0; (*gAssetsMenuElementIds)[gMenuElementIdCount] != -1; gMenuElementIdCount++){} + for (gMenuElementIdCount = 0; (*gAssetsMenuElementIds)[gMenuElementIdCount] != -1; gMenuElementIdCount++) {} gMenuObjectsCount = 0; - for(i = 0; i < gMenuElementIdCount; i++) { + for (i = 0; i < gMenuElementIdCount; i++) { D_80126750[i] = FALSE; } } if (!D_80126750[arg0]) { i = (*gAssetsMenuElementIds)[arg0]; - - if (((!arg0) && (!arg0)) && (!arg0)){} // Fakematch - + + if (((!arg0) && (!arg0)) && (!arg0)) {} // Fakematch + if ((i & 0xC000) == 0xC000) { gMenuObjects[arg0] = (TextureHeader *) load_texture(i & 0x3FFF); } else if (i & 0x8000) { gMenuObjects[arg0] = (TextureHeader *) func_8007C12C(i & 0x3FFF, 0); } else if (i & 0x4000) { - if (gMenuElementIdCount){} // Fakematch + if (gMenuElementIdCount) {} // Fakematch entry.objectID = i & 0xFFFF; entry.size = 8; entry.x = 0; @@ -11553,7 +12622,6 @@ void func_8009C6D4(s32 arg0) { } } - void allocate_menu_images(s16 *imageSet) { s32 index = 0; while (imageSet[index] != -1) { @@ -11589,12 +12657,12 @@ void func_8009CA60(s32 stackIndex) { unk8009CA602 *new_var2; Sprite *sprite; ObjectModel **temp; - + if (gMenuObjects[gMenuImageStack[stackIndex].unk6] != 0) { if (((*gAssetsMenuElementIds)[gMenuImageStack[stackIndex].unk6] & 0xC000) != 0xC000) { if ((*gAssetsMenuElementIds)[gMenuImageStack[stackIndex].unk6] & 0x4000) { if (0) {} // Fakematch - new_var = (Object*)gMenuObjects[gMenuImageStack[stackIndex].unk6]; + new_var = (Object *) gMenuObjects[gMenuImageStack[stackIndex].unk6]; new_var2 = (unk8009CA602 *) &gMenuImageStack[stackIndex]; new_var->segment.trans.y_rotation = new_var2->trans.y_rotation; new_var->segment.trans.x_rotation = new_var2->trans.x_rotation; @@ -11612,9 +12680,12 @@ void func_8009CA60(s32 stackIndex) { } else { if ((*gAssetsMenuElementIds)[gMenuImageStack[stackIndex].unk6] & 0x8000) { sprite = (Sprite *) gMenuObjects[gMenuImageStack[stackIndex].unk6]; - gDPSetPrimColor(sMenuCurrDisplayList++, 0, 0, sMenuGuiColourR, sMenuGuiColourG, sMenuGuiColourB, sMenuGuiOpacity); + gDPSetPrimColor(sMenuCurrDisplayList++, 0, 0, sMenuGuiColourR, sMenuGuiColourG, sMenuGuiColourB, + sMenuGuiOpacity); gDPSetEnvColor(sMenuCurrDisplayList++, 255, 255, 255, 0); - render_ortho_triangle_image(&sMenuCurrDisplayList, &sMenuCurrHudMat, &sMenuCurrHudVerts, (ObjectSegment *)(&gMenuImageStack[stackIndex]), sprite, gMenuSpriteFlags); + render_ortho_triangle_image(&sMenuCurrDisplayList, &sMenuCurrHudMat, &sMenuCurrHudVerts, + (ObjectSegment *) (&gMenuImageStack[stackIndex]), sprite, + gMenuSpriteFlags); gDPSetPrimColor(sMenuCurrDisplayList++, 0, 0, 255, 255, 255, 255); } else { if (sMenuGuiOpacity < 255) { @@ -11623,7 +12694,9 @@ void func_8009CA60(s32 stackIndex) { gDPSetPrimColor(sMenuCurrDisplayList++, 0, 0, 255, 255, 255, 255); }; gDPSetEnvColor(sMenuCurrDisplayList++, 255, 255, 255, 0); - camera_push_model_mtx(&sMenuCurrDisplayList, &sMenuCurrHudMat, (ObjectTransform *) (&gMenuImageStack[stackIndex]), gTrackSelectWoodFrameHeightScale, 0); + camera_push_model_mtx(&sMenuCurrDisplayList, &sMenuCurrHudMat, + (ObjectTransform *) (&gMenuImageStack[stackIndex]), + gTrackSelectWoodFrameHeightScale, 0); temp = ((ObjectModel **) gMenuObjects[gMenuImageStack[stackIndex].unk6]); render_track_selection_viewport_border(*temp); apply_matrix_from_stack(&sMenuCurrDisplayList); @@ -11668,7 +12741,7 @@ void render_track_selection_viewport_border(ObjectModel *objMdl) { verts = &objMdl->vertices[vertOffset]; tris = &objMdl->triangles[triOffset]; //!@bug Never true, since textureIndex is unsigned. This should've been either `== (u8)-1` or `== 0xFF`. - if (objMdl->batches[i].textureIndex == -1) { + if (objMdl->batches[i].textureIndex == -1) { tex = NULL; texEnabled = FALSE; texOffset = 0; @@ -11678,7 +12751,7 @@ void render_track_selection_viewport_border(ObjectModel *objMdl) { texOffset = objMdl->batches[i].unk7 << 14; } load_and_set_texture(&sMenuCurrDisplayList, tex, flags, texOffset); - + gSPVertexDKR(sMenuCurrDisplayList++, OS_PHYSICAL_TO_K0(verts), numVerts, 0); gSPPolygon(sMenuCurrDisplayList++, OS_PHYSICAL_TO_K0(tris), numTris, texEnabled); } @@ -11699,7 +12772,7 @@ void func_8009CF68(s32 arg0) { /** * If the call to close dialogue has been made, this will begin hiding it. * It then also resets the menus stick inputs. -*/ + */ void try_close_dialogue_box(void) { if (gNeedToCloseDialogueBox) { gNeedToCloseDialogueBox = FALSE; @@ -11711,7 +12784,7 @@ void try_close_dialogue_box(void) { /** * Top level function for controlling dialogue with NPC's. * Returning nonzero will trigger those NPC's to stop dialogue. -*/ + */ s32 npc_dialogue_loop(u32 dialogueOption) { s32 result; @@ -11759,12 +12832,12 @@ void set_option_text_colour(s32 condition) { if (condition == FALSE) { set_current_text_colour(1, 0, 0, 0x7F, 0x5A, 0xFF); // Normal if (gDialogueOptionTangible != FALSE) { - set_current_text_colour(1, 0, 0, 0x7F, 0x5A, 0x78); //Locked + set_current_text_colour(1, 0, 0, 0x7F, 0x5A, 0x78); // Locked } } else { set_current_text_colour(1, 0xCF, 0xCF, 0xCF, 0x5A, 0xFF); // Selected Option } - gDialogueOptionTangible = (u8)FALSE; + gDialogueOptionTangible = (u8) FALSE; } /** @@ -11776,8 +12849,8 @@ void render_dialogue_option(char *text, s32 yOffset, s32 optionID) { gDialogueItemSelection = optionID; } render_dialogue_text(1, POS_CENTRED, gDialogueOptionYOffset, text, 1, HORZ_ALIGN_CENTER); - gDialogueOptionYOffset = (s8)(gDialogueOptionYOffset + yOffset); - sDialogueOptionMax = (s8)(sDialogueOptionMax + 1); + gDialogueOptionYOffset = (s8) (gDialogueOptionYOffset + yOffset); + sDialogueOptionMax = (s8) (sDialogueOptionMax + 1); } /** @@ -11808,7 +12881,7 @@ void func_8009D324(void) { /** * Sets the variable controlling which Taj Challenge dialogue is to be used. -*/ + */ void set_next_taj_challenge_menu(s32 arg0) { gNextTajChallengeMenu = arg0; } @@ -11848,16 +12921,18 @@ s32 taj_menu_loop(void) { switch (sCurrentMenuID) { case 2: case 0x62: - render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_VEHICLESELECT], 1, HORZ_ALIGN_CENTER); // VEHICLE SELECT + render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_VEHICLESELECT], 1, + HORZ_ALIGN_CENTER); // VEHICLE SELECT gDialogueOptionYOffset = 30; - render_dialogue_option(gMenuText[ASSET_MENU_TEXT_CAR], 20, 0); // CAR + render_dialogue_option(gMenuText[ASSET_MENU_TEXT_CAR], 20, 0); // CAR render_dialogue_option(gMenuText[ASSET_MENU_TEXT_HOVERCRAFT], 20, 1); // HOVERCRAFT - render_dialogue_option(gMenuText[ASSET_MENU_TEXT_PLANE], 20, 2); // PLANE - render_dialogue_option(gMenuText[ASSET_MENU_TEXT_MAINMENU], 20, 3); // MAIN MENU + render_dialogue_option(gMenuText[ASSET_MENU_TEXT_PLANE], 20, 2); // PLANE + render_dialogue_option(gMenuText[ASSET_MENU_TEXT_MAINMENU], 20, 3); // MAIN MENU break; case 3: case 0x63: - render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_CHALLENGESELECT], 1, HORZ_ALIGN_CENTER); // CHALLENGE SELECT + render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_CHALLENGESELECT], 1, + HORZ_ALIGN_CENTER); // CHALLENGE SELECT gDialogueOptionYOffset = 30; if (settings->tajFlags & TAJ_FLAGS_CAR_CHAL_UNLOCKED) { gDialogueOptionTangible = settings->tajFlags & TAJ_FLAGS_CAR_CHAL_COMPLETED; @@ -11887,7 +12962,8 @@ s32 taj_menu_loop(void) { break; case 1: gNextTajChallengeMenu = 0; - render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_OPTIONS], 1, HORZ_ALIGN_CENTER); // OPTIONS + render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_OPTIONS], 1, + HORZ_ALIGN_CENTER); // OPTIONS gDialogueOptionYOffset = 30; render_dialogue_option(gMenuText[ASSET_MENU_TEXT_CHANGEVEHICLE], 20, 0); // CHANGE VEHICLE if (settings->tajFlags & TAJ_FLAGS_UNLOCKED_A_CHALLENGE) { @@ -12010,11 +13086,13 @@ s32 dialogue_race_defeat(void) { playerInput = get_buttons_pressed_from_player(PLAYER_ONE); sDialogueOptionMax = 0; gNextTajChallengeMenu = 0; - render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_LOSETOTAJ_0], 1, HORZ_ALIGN_CENTER); // BETTER LUCK - render_dialogue_text(1, POS_CENTRED, 20, gMenuText[ASSET_MENU_TEXT_LOSETOTAJ_1], 1, HORZ_ALIGN_CENTER); // NEXT TIME! + render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_LOSETOTAJ_0], 1, + HORZ_ALIGN_CENTER); // BETTER LUCK + render_dialogue_text(1, POS_CENTRED, 20, gMenuText[ASSET_MENU_TEXT_LOSETOTAJ_1], 1, + HORZ_ALIGN_CENTER); // NEXT TIME! gDialogueOptionYOffset = 50; render_dialogue_option(gMenuText[ASSET_MENU_TEXT_TRYAGAIN], 20, 0); // TRY AGAIN - render_dialogue_option(gMenuText[ASSET_MENU_TEXT_EXIT], 20, 1); // EXIT + render_dialogue_option(gMenuText[ASSET_MENU_TEXT_EXIT], 20, 1); // EXIT handle_menu_joystick_input(); if (playerInput & A_BUTTON) { sound_play(SOUND_SELECT2, NULL); @@ -12034,7 +13112,7 @@ s32 dialogue_race_defeat(void) { * Main function for TT dialogue. * Handles the controls for navigating the main options, selecting time trial and viewing the game status. * Also has unused functions to handle pak swapping as well as displaying the messages about them. -*/ + */ s32 tt_menu_loop(void) { s32 currentOption; s32 buttonsPressed; @@ -12068,8 +13146,9 @@ s32 tt_menu_loop(void) { switch (sCurrentMenuID) { case TT_MENU_ROOT: case TT_MENU_EXIT: - render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_OPTIONS], 1, HORZ_ALIGN_CENTER); // OPTIONS - render_dialogue_option(gMenuText[ASSET_MENU_TEXT_STATUS], 20, 3); // STATUS + render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_OPTIONS], 1, + HORZ_ALIGN_CENTER); // OPTIONS + render_dialogue_option(gMenuText[ASSET_MENU_TEXT_STATUS], 20, 3); // STATUS if (!is_in_two_player_adventure()) { if (is_time_trial_enabled()) { render_dialogue_option(gMenuText[ASSET_MENU_TEXT_TIMETRIALON], 20, 0); // TIME TRIAL ON @@ -12096,7 +13175,7 @@ s32 tt_menu_loop(void) { } } if ((buttonsPressed & A_BUTTON) && (sCurrentMenuID != TT_MENU_EXIT)) { - if(gPreviousMenuID && !gPreviousMenuID && !gPreviousMenuID){} // Fakematch + if (gPreviousMenuID && !gPreviousMenuID && !gPreviousMenuID) {} // Fakematch switch (gDialogueItemSelection) { case 1: sound_play(SOUND_SELECT2, NULL); @@ -12156,38 +13235,39 @@ s32 tt_menu_loop(void) { play_tt_voice_clip(SOUND_VOICE_TT_OKAY, TRUE); } break; - case TT_MENU_INTRODUCTION: - { + case TT_MENU_INTRODUCTION: { /* 0: HI, I'M TT. - 1: + 1: 2: YOU CAN ASK ME 3: ABOUT YOUR GAME 4: STATUS OR SELECT 5: MY TIME TRIAL MODE 6: TO PRACTICE A 7: LEVEL. - 8: + 8: 9: I CAN ALSO SAVE 10: YOUR BEST GHOSTS 11: {NULL TO END THE CHAT} */ - //TT Has 12 different intro text lines. This will render them one by one until it hits the NULL line. + // TT Has 12 different intro text lines. This will render them one by one until it hits the NULL line. i = ASSET_MENU_TEXT_TTINTRO_0; while (gMenuText[i] != NULL) { - render_dialogue_text(1, POS_CENTRED, 6 + ((i-52) * 16), gMenuText[i], 1, HORZ_ALIGN_CENTER); + render_dialogue_text(1, POS_CENTRED, 6 + ((i - 52) * 16), gMenuText[i], 1, HORZ_ALIGN_CENTER); i++; } if (buttonsPressed & (A_BUTTON | B_BUTTON)) { settings->cutsceneFlags |= CUTSCENE_TT_HELP; sCurrentMenuID = TT_MENU_ROOT; } - } - break; + } break; case TT_MENU_INSERT_CONT_PAK: - render_dialogue_text(1, POS_CENTRED, 34, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_3], 1, HORZ_ALIGN_CENTER); // If you wish to use - render_dialogue_text(1, POS_CENTRED, 50, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_4], 1, HORZ_ALIGN_CENTER); // the Controller Pak - render_dialogue_text(1, POS_CENTRED, 66, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_6], 1, HORZ_ALIGN_CENTER); // insert it now! + render_dialogue_text(1, POS_CENTRED, 34, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_3], 1, + HORZ_ALIGN_CENTER); // If you wish to use + render_dialogue_text(1, POS_CENTRED, 50, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_4], 1, + HORZ_ALIGN_CENTER); // the Controller Pak + render_dialogue_text(1, POS_CENTRED, 66, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_6], 1, + HORZ_ALIGN_CENTER); // insert it now! if (buttonsPressed & (A_BUTTON | START_BUTTON)) { sound_play(SOUND_SELECT2, NULL); gSaveGhostDelayCounter = 0; @@ -12199,15 +13279,19 @@ s32 tt_menu_loop(void) { } break; case TT_MENU_INSERT_RUMBLE_PAK: - render_dialogue_text(1, POS_CENTRED, 34, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_3], 1, HORZ_ALIGN_CENTER); // If you wish to use - render_dialogue_text(1, POS_CENTRED, 50, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_5], 1, HORZ_ALIGN_CENTER); // the Rumble Pak - render_dialogue_text(1, POS_CENTRED, 66, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_6], 1, HORZ_ALIGN_CENTER); // insert it now! + render_dialogue_text(1, POS_CENTRED, 34, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_3], 1, + HORZ_ALIGN_CENTER); // If you wish to use + render_dialogue_text(1, POS_CENTRED, 50, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_5], 1, + HORZ_ALIGN_CENTER); // the Rumble Pak + render_dialogue_text(1, POS_CENTRED, 66, gMenuText[ASSET_MENU_TEXT_INSERTDEVICE_6], 1, + HORZ_ALIGN_CENTER); // insert it now! if (buttonsPressed & (A_BUTTON | B_BUTTON | START_BUTTON)) { sCurrentMenuID = TT_MENU_ROOT; } break; case TT_MENU_SAVE_GHOST: - render_dialogue_text(1, POS_CENTRED, 50, gMenuText[ASSET_MENU_TEXT_PLEASEWAIT], 1, HORZ_ALIGN_CENTER); // PLEASE WAIT + render_dialogue_text(1, POS_CENTRED, 50, gMenuText[ASSET_MENU_TEXT_PLEASEWAIT], 1, + HORZ_ALIGN_CENTER); // PLEASE WAIT gSaveGhostDelayCounter++; if (gSaveGhostDelayCounter >= 5) { result = func_8001B738(0); @@ -12255,8 +13339,7 @@ s32 tt_menu_loop(void) { } break; } - if ((sCurrentMenuID == TT_MENU_CONT_PAK_ERROR_1) || - (sCurrentMenuID == TT_MENU_CONT_PAK_ERROR_2) || + if ((sCurrentMenuID == TT_MENU_CONT_PAK_ERROR_1) || (sCurrentMenuID == TT_MENU_CONT_PAK_ERROR_2) || (sCurrentMenuID == TT_MENU_CONT_PAK_ERROR_3)) { render_dialogue_text(1, POS_CENTRED, 6, gMenuText[ASSET_MENU_TEXT_PAKERROR], 1, HORZ_ALIGN_CENTER); // PAK ERROR } @@ -12298,7 +13381,7 @@ void func_8009E3D0(void) { gMenuImageStack[0].unkC = tempX; gMenuImageStack[0].unk10 = (98 - y); gMenuImageStack[0].unkC -= 6.0f; - + flag = (settings->balloonsPtr[0] / 10); // settings->balloonsPtr[0] is the total balloon count. numBalloonsTensDigit = flag; if (numBalloonsTensDigit != 0) { @@ -12324,7 +13407,7 @@ void func_8009E3D0(void) { gMenuImageStack[16].unk10 = (95 - y); gMenuImageStack[16].unk18 = settings->ttAmulet; func_8009CA60(16); - + for (flag = 3, numOfItem = 0, i = 0; i < 16; flag <<= 2, i++) { if (flag == (settings->trophies & flag)) { numOfItem++; @@ -12360,7 +13443,6 @@ void func_8009E3D0(void) { func_80068508(FALSE); } - /** * Dialogue menu for the trophy cabinets in each world hub. */ @@ -12385,7 +13467,8 @@ s32 trophy_race_cabinet_menu_loop(void) { gDialogueSubmenu = 1; } set_option_text_colour(gDialogueSubmenu == 0); - render_dialogue_text(1, POS_CENTRED, 30, gMenuText[ASSET_MENU_TEXT_ENTERTROPHYRACE], 1, HORZ_ALIGN_CENTER); // ENTER TROPHY RACE + render_dialogue_text(1, POS_CENTRED, 30, gMenuText[ASSET_MENU_TEXT_ENTERTROPHYRACE], 1, + HORZ_ALIGN_CENTER); // ENTER TROPHY RACE set_option_text_colour(gDialogueSubmenu == 1); render_dialogue_text(1, POS_CENTRED, 50, gMenuText[ASSET_MENU_TEXT_EXIT], 1, HORZ_ALIGN_CENTER); // EXIT if (buttonsPressed & A_BUTTON) { @@ -12488,8 +13571,8 @@ void set_language(s32 language) { break; } - sEepromSettings &= ~0xC; //Set bits 3 and 4 low first - sEepromSettings |= langFlag; //Then set them according to the selected lang + sEepromSettings &= ~0xC; // Set bits 3 and 4 low first + sEepromSettings |= langFlag; // Then set them according to the selected lang load_menu_text(language); mark_write_eeprom_settings(); diff --git a/src/menu.h b/src/menu.h index af5950d0..313be429 100644 --- a/src/menu.h +++ b/src/menu.h @@ -338,7 +338,7 @@ void func_80081E54(MenuElement *arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4, s3 void func_800828B8(void); void print_missing_controller_text(Gfx **dl, s32 updateRate); void menu_logos_screen_init(void); -s32 menu_logo_screen_loop(s32 arg0); +s32 menu_logo_screen_loop(s32 updateRate); void init_title_screen_variables(void); void menu_title_screen_init(void); void title_screen_exit(void); @@ -366,13 +366,13 @@ void func_8008AEB4(s32 arg0, s32 *arg1); void set_active_player_index(s32 controllerIndex); void menu_character_select_init(void); void draw_character_select_text(s32 arg0); -void func_8008BFE8(s32 arg0, s8 *arg1, s32 arg2, u16 arg3, u16 arg4); +void func_8008BFE8(s32 arg0, s8 *arg1, s32 arg2, u16 menuPickSoundId, u16 menuPickFailedSoundId); void func_8008C128(void); void menu_caution_init(void); void unload_big_font_3(void); void func_8008CACC(void); void menu_file_select_init(void); -void render_menu_image(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6); +void render_menu_image(s32 imageID, s32 xOffset, s32 yOffset, s32 red, s32 green, s32 blue, s32 opacity); void func_8008E428(void); void assign_vehicle_icon_textures(void); void assign_menu_arrow_textures(void); @@ -402,7 +402,7 @@ void func_8009ABD8(s8 *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s8 *arg5); void menu_cinematic_init(void); void func_8009AF18(void); void menu_credits_init(void); -void render_credits_fade(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4); +void render_credits_fade(s32 x1, s32 y1, s32 x2, s32 y2, s32 a); void func_8009BCF0(void); void func_8009BD5C(void); void func_8009BE54(); @@ -426,13 +426,13 @@ s32 get_multiplayer_racer_count(void); Settings **get_all_save_files_ptr(void); void func_8009C4A8(s16 *arg0); void func_8009C508(s32 arg0); -void func_8009C674(s16 *arg0); +void func_8009C674(s16 *textureIndex); void allocate_menu_images(s16 *imageSet); void allocate_and_set_menu_image_properties(s32 imageID); void func_8009CA58(void); void func_8009CF68(s32 arg0); void try_close_dialogue_box(void); -s32 npc_dialogue_loop(u32 arg0); +s32 npc_dialogue_loop(u32 dialogueOption); void set_option_text_colour(s32 condition); void render_dialogue_option(char *text, s32 yOffset, s32 optionID); void handle_menu_joystick_input(void); @@ -444,7 +444,7 @@ s32 dialogue_race_defeat(void); s32 trophy_race_cabinet_menu_loop(void); void dialogue_open_stub(void); void dialogue_close_stub(void); -f32 func_8009E9B0(DialogueBoxBackground *arg0, Gfx **dlist, MatrixS **mat, Vertex **vtx); +f32 func_8009E9B0(DialogueBoxBackground *arg0, Gfx **dlist, MatrixS **mat, Vertex **verts); u64 *get_eeprom_settings_pointer(void); s32 set_eeprom_settings_value(u64 valueToSet); s32 unset_eeprom_settings_value(u64 valueToUnset); @@ -461,7 +461,7 @@ s32 menu_caution_loop(s32 updateRate); void func_8008DC7C(UNUSED s32 updateRate); s32 menu_adventure_track_loop(s32 updateRate); void func_80095624(SIDeviceStatus status); -s32 menu_boot_loop(s32 arg0); +s32 menu_boot_loop(s32 updateRate); void menu_magic_codes_init(void); s32 menu_game_select_loop(s32 updateRate); s32 menu_ghost_data_loop(s32 updateRate); @@ -539,7 +539,7 @@ s32 menu_magic_codes_loop(s32 updateRate); s32 menu_credits_loop(s32 updateRate); void func_8007FFEC(s32 arg0); SIDeviceStatus func_80087F14(s32 *controllerIndex, s32 arg1); -void set_gIntDisFlag(s8 bool); +void set_gIntDisFlag(s8 setting); void func_80081218(void); void func_80080580(Gfx **dlist, s32 startX, s32 startY, s32 width, s32 height, s32 borderWidth, s32 borderHeight, s32 colour, TextureHeader *tex); void func_8008D8BC(s32 updateRate); diff --git a/src/object_functions.c b/src/object_functions.c index 1b239a56..137c0bde 100644 --- a/src/object_functions.c +++ b/src/object_functions.c @@ -39,88 +39,56 @@ FadeTransition gTajTransformTransitionEnd = FADE_TRANSITION(FADE_FULLSCREEN, FAD FadeTransition gTajTransition = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_BLACK, 30, -1); Vertex gCharacterFlagVertices[4] = { - { -256, 256, 0, 255, 255, 255, 255 }, - { 256, 256, 0, 255, 255, 255, 255 }, - { 256, -256, 0, 255, 255, 255, 255 }, + { -256, 256, 0, 255, 255, 255, 255 }, + { 256, 256, 0, 255, 255, 255, 255 }, + { 256, -256, 0, 255, 255, 255, 255 }, { -256, -256, 0, 255, 255, 255, 255 }, }; VertexPosition D_800DC9A8[6] = { - { 0, 64, -64 }, - { 0, -64, -64 }, - { 0, 64, 32 }, - { 0, -64, 32 }, - { 0, 64, 64 }, - { 0, -64, 64 }, + { 0, 64, -64 }, { 0, -64, -64 }, { 0, 64, 32 }, { 0, -64, 32 }, { 0, 64, 64 }, { 0, -64, 64 }, }; UNUSED s32 D_800DC9C8 = 0; // Fish Object Related Triangle D_800DC9D0[8] = { - { {{ 0, 0, 3, 1 }}, {{{ 4, 0 }}}, {{{ 1, 4 }}}, {{{ 4, 4 }}} }, - { {{ 0, 0, 2, 3 }}, {{{ 4, 0 }}}, {{{ 1, 0 }}}, {{{ 1, 4 }}} }, - { {{ 0, 2, 5, 3 }}, {{{ 1, 0 }}}, {{{ 0, 4 }}}, {{{ 1, 4 }}} }, - { {{ 0, 2, 4, 5 }}, {{{ 1, 0 }}}, {{{ 0, 0 }}}, {{{ 0, 4 }}} }, - { {{ 0, 0, 1, 3 }}, {{{ 4, 0 }}}, {{{ 4, 4 }}}, {{{ 1, 4 }}} }, - { {{ 0, 0, 3, 2 }}, {{{ 4, 0 }}}, {{{ 1, 4 }}}, {{{ 1, 0 }}} }, - { {{ 0, 2, 3, 5 }}, {{{ 1, 0 }}}, {{{ 1, 4 }}}, {{{ 0, 4 }}} }, - { {{ 0, 2, 5, 4 }}, {{{ 1, 0 }}}, {{{ 0, 4 }}}, {{{ 0, 0 }}} }, + { { { 0, 0, 3, 1 } }, { { { 4, 0 } } }, { { { 1, 4 } } }, { { { 4, 4 } } } }, + { { { 0, 0, 2, 3 } }, { { { 4, 0 } } }, { { { 1, 0 } } }, { { { 1, 4 } } } }, + { { { 0, 2, 5, 3 } }, { { { 1, 0 } } }, { { { 0, 4 } } }, { { { 1, 4 } } } }, + { { { 0, 2, 4, 5 } }, { { { 1, 0 } } }, { { { 0, 0 } } }, { { { 0, 4 } } } }, + { { { 0, 0, 1, 3 } }, { { { 4, 0 } } }, { { { 4, 4 } } }, { { { 1, 4 } } } }, + { { { 0, 0, 3, 2 } }, { { { 4, 0 } } }, { { { 1, 4 } } }, { { { 1, 0 } } } }, + { { { 0, 2, 3, 5 } }, { { { 1, 0 } } }, { { { 1, 4 } } }, { { { 0, 4 } } } }, + { { { 0, 2, 5, 4 } }, { { { 1, 0 } } }, { { { 0, 4 } } }, { { { 0, 0 } } } }, }; -u8 D_800DCA50[8] = { - 2, 5, 6, 3, 10, 8, 7, 9 -}; -u8 D_800DCA58[9] = { - 2, 5, 6, 3, 10, 8, 7, 9, 11 -}; -u8 D_800DCA64[9] = { - 2, 5, 6, 3, 10, 8, 7, 9, 12 -}; -u8 D_800DCA70[10] = { - 2, 5, 6, 3, 10, 8, 7, 9, 11, 12 -}; -u8 D_800DCA7C[12] = { - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0 -}; +u8 D_800DCA50[8] = { 2, 5, 6, 3, 10, 8, 7, 9 }; +u8 D_800DCA58[9] = { 2, 5, 6, 3, 10, 8, 7, 9, 11 }; +u8 D_800DCA64[9] = { 2, 5, 6, 3, 10, 8, 7, 9, 12 }; +u8 D_800DCA70[10] = { 2, 5, 6, 3, 10, 8, 7, 9, 11, 12 }; +u8 D_800DCA7C[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -u8 D_800DCA88[12] = { - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0 -}; +u8 D_800DCA88[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -s8 D_800DCA94[8] = { - 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00 -}; +s8 D_800DCA94[8] = { 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00 }; -s8 D_800DCA9C[12] = { - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; +s8 D_800DCA9C[12] = { 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Butterfly Object Related Triangle D_800DCAA8[8] = { - { {{ 0, 0, 3, 1 }}, {{{ 0, 0 }}}, {{{ -1, -1 }}}, {{{ 0, -1 }}} }, - { {{ 0, 0, 2, 3 }}, {{{ 0, 0 }}}, {{{ -1, 0 }}}, {{{ -1, -1 }}} }, - { {{ 0, 2, 5, 3 }}, {{{ -1, 0 }}}, {{{ 0, -1 }}}, {{{ -1, -1 }}} }, - { {{ 0, 2, 4, 5 }}, {{{ -1, 0 }}}, {{{ 0, 0 }}}, {{{ 0, -1 }}} }, - { {{ 0, 0, 1, 3 }}, {{{ 0, 0 }}}, {{{ 0, -1 }}}, {{{ -1, -1 }}} }, - { {{ 0, 0, 3, 2 }}, {{{ 0, 0 }}}, {{{ -1, -1 }}}, {{{ -1, 0 }}} }, - { {{ 0, 2, 3, 5 }}, {{{ -1, 0 }}}, {{{ -1, -1 }}}, {{{ 0, -1 }}} }, - { {{ 0, 2, 5, 4 }}, {{{ -1, 0 }}}, {{{ 0, -1 }}}, {{{ 0, 0 }}} }, + { { { 0, 0, 3, 1 } }, { { { 0, 0 } } }, { { { -1, -1 } } }, { { { 0, -1 } } } }, + { { { 0, 0, 2, 3 } }, { { { 0, 0 } } }, { { { -1, 0 } } }, { { { -1, -1 } } } }, + { { { 0, 2, 5, 3 } }, { { { -1, 0 } } }, { { { 0, -1 } } }, { { { -1, -1 } } } }, + { { { 0, 2, 4, 5 } }, { { { -1, 0 } } }, { { { 0, 0 } } }, { { { 0, -1 } } } }, + { { { 0, 0, 1, 3 } }, { { { 0, 0 } } }, { { { 0, -1 } } }, { { { -1, -1 } } } }, + { { { 0, 0, 3, 2 } }, { { { 0, 0 } } }, { { { -1, -1 } } }, { { { -1, 0 } } } }, + { { { 0, 2, 3, 5 } }, { { { -1, 0 } } }, { { { -1, -1 } } }, { { { 0, -1 } } } }, + { { { 0, 2, 5, 4 } }, { { { -1, 0 } } }, { { { 0, -1 } } }, { { { 0, 0 } } } }, }; VertexPosition D_800DCB28[6] = { - { -64, 0, 32 }, - { -64, 0, -32 }, - { 0, 0, 32 }, - { 0, 0, -32 }, - { 64, 0, 32 }, - { 64, 0, -32 }, + { -64, 0, 32 }, { -64, 0, -32 }, { 0, 0, 32 }, { 0, 0, -32 }, { 64, 0, 32 }, { 64, 0, -32 }, }; /*******************************/ @@ -140,7 +108,7 @@ s16 gTajSoundID; // Taj Voice clips * Level scenery init behaviour. * Set rotation and scale based off spawn info. * Also have the option based off spawn info to add solidity to the hitbox. -*/ + */ void obj_init_scenery(Object *obj, LevelObjectEntry_Scenery *entry) { f32 radius; obj->segment.trans.flags |= OBJ_FLAGS_UNK_0002; @@ -171,10 +139,10 @@ void obj_init_scenery(Object *obj, LevelObjectEntry_Scenery *entry) { /** * Level scenery loop behaviour. * When hit by a racer, give it an elastic behaviour as feedback. -*/ + */ void obj_loop_scenery(Object *obj, s32 updateRate) { - ObjPropertyScenery *properties; - s32 temp_v0; + ObjPropertyScenery *properties; + s32 temp_v0; if (obj->interactObj != NULL) { properties = &obj->properties.scenery; @@ -182,7 +150,8 @@ void obj_loop_scenery(Object *obj, s32 updateRate) { properties->hitTimer -= updateRate; } if (obj->interactObj->flags & INTERACT_FLAGS_COLLIDED && properties->hitTimer <= 0) { - play_sound_at_position(SOUND_TWANG, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + play_sound_at_position(SOUND_TWANG, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, NULL); properties->interactObj = obj->interactObj->obj; properties->angleVel = 0x71C; properties->hitTimer = 10; @@ -241,7 +210,8 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { obj->segment.trans.y_position = 0.0f; obj->segment.trans.z_position = 0.0f; ignore_bounds_check(); - move_object(obj, someObj->segment.trans.x_position, someObj->segment.trans.y_position, someObj->segment.trans.z_position); + move_object(obj, someObj->segment.trans.x_position, someObj->segment.trans.y_position, + someObj->segment.trans.z_position); } else { diff = (someObj->segment.trans.x_position - obj->segment.trans.x_position) * 0.1; if (diff > 10.0) { @@ -267,11 +237,13 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { diff = -10.0f; } obj->segment.z_velocity += (diff - obj->segment.z_velocity) * 0.125 * updateRateF; - if (sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + (obj->segment.z_velocity * obj->segment.z_velocity)) > 0.5) { + if (sqrtf((obj->segment.x_velocity * obj->segment.x_velocity) + + (obj->segment.z_velocity * obj->segment.z_velocity)) > 0.5) { obj->segment.trans.y_rotation = arctan2_f(obj->segment.x_velocity, obj->segment.z_velocity); obj->segment.trans.x_rotation -= updateRate * 0x200; } - move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, obj->segment.z_velocity * updateRateF); + move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, + obj->segment.z_velocity * updateRateF); if (obj->unk4A == 298) { if (get_wave_properties(obj->segment.trans.y_position, &waveHeight, NULL)) { obj->segment.trans.y_position = waveHeight; @@ -281,7 +253,7 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { obj->segment.animFrame += updateRate * 10; weapon = (Object_Fireball_Octoweapon *) obj->unk64; interactObj = obj->interactObj; - if ((interactObj->obj)) { + if ((interactObj->obj)) { if ((interactObj->distance < 60)) { someObj = interactObj->obj; if ((someObj->segment.header->behaviorId == BHV_RACER)) { @@ -290,7 +262,8 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { if (obj->behaviorId == BHV_FIREBALL_OCTOWEAPON) { racer->attackType = ATTACK_EXPLOSION; obj->properties.fireball.timer = 20; - func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 44, SOUND_EXPLOSION, 1.0f, 1); + func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 44, SOUND_EXPLOSION, 1.0f, 1); free_object(obj); } else if (obj->properties.fireball.timer > 0) { racer->bubbleTrapTimer = 60; @@ -309,7 +282,8 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { if (obj->properties.fireball.timer < 0) { if (obj->unk4A == 298) { free_object(obj); - func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, BHV_LENS_FLARE_SWITCH, SOUND_EXPLOSION, 1.0f, 1); + func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, BHV_LENS_FLARE_SWITCH, SOUND_EXPLOSION, 1.0f, 1); } obj->segment.trans.scale *= 0.9; //!@Delta if (obj->segment.trans.scale < 0.5) { @@ -333,7 +307,8 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { if (soundMask != NULL) { func_8000488C(soundMask); } - play_sound_at_position(SOUND_POP, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + play_sound_at_position(SOUND_POP, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, NULL); free_object(obj); } } @@ -343,7 +318,7 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { * Laser gun init function. * Sets the face direction and active behaviour modes based on entry data. * This includes a targeting system and rate of fire. -*/ + */ void obj_init_lasergun(Object *obj, LevelObjectEntry_Lasergun *entry) { Object_LaserGun *laserGun; obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE | INTERACT_FLAGS_UNK_0020; @@ -362,7 +337,7 @@ void obj_init_lasergun(Object *obj, LevelObjectEntry_Lasergun *entry) { * Laser gun loop behaviour. * A static mounted gun that shoots laserbeams at wherever it's facing. * The fire rate is adjustable per object and can be set to target racers. -*/ + */ void obj_loop_lasergun(Object *obj, s32 updateRate) { Object_LaserGun *lasergun; Object *laserBoltObj; @@ -404,7 +379,8 @@ void obj_loop_lasergun(Object *obj, s32 updateRate) { spawnObj.z = obj->segment.trans.z_position; spawnObj.size = 8; spawnObj.objectID = 0xC6; - play_sound_at_position(SOUND_LASER_GUN, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + play_sound_at_position(SOUND_LASER_GUN, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, NULL); laserBoltObj = spawn_object(&spawnObj, 1); if (laserBoltObj != NULL) { laserBoltObj->segment.level_entry = NULL; @@ -424,7 +400,8 @@ void obj_loop_lasergun(Object *obj, s32 updateRate) { if (lasergun->targeting == FALSE) { diffX = 45.0f; } - guMtxXFMF(mtx, 0.0f, 0.0f, diffX, &laserBoltObj->segment.x_velocity, &laserBoltObj->segment.y_velocity, &laserBoltObj->segment.z_velocity); + guMtxXFMF(mtx, 0.0f, 0.0f, diffX, &laserBoltObj->segment.x_velocity, &laserBoltObj->segment.y_velocity, + &laserBoltObj->segment.z_velocity); } } } @@ -433,7 +410,7 @@ void obj_loop_lasergun(Object *obj, s32 updateRate) { /** * Laser Bolt init behaviour. * Sets hitbox data so it can be interacted with. -*/ + */ void obj_init_laserbolt(Object *obj, UNUSED LevelObjectEntry_Laserbolt *entry) { obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; obj->interactObj->unk11 = 0; @@ -442,23 +419,22 @@ void obj_init_laserbolt(Object *obj, UNUSED LevelObjectEntry_Laserbolt *entry) { /** * Laser Bolt init behaviour. * Move in a set direction, until it either times out, hits a racer, or hits a wall. -*/ + */ void obj_loop_laserbolt(Object *obj, s32 updateRate) { - f32 updateRateF; + f32 updateRateF; - Object *racerObj; + Object *racerObj; - Object_LaserGun *laserGun; - Object_Laser *laser; - - s8 delete; // Boolean - s8 surface; - f32 dirZ; - f32 dirY; - f32 dirX; - f32 radius; - s32 hasCollision; // Boolean + Object_LaserGun *laserGun; + Object_Laser *laser; + s8 delete; // Boolean + s8 surface; + f32 dirZ; + f32 dirY; + f32 dirX; + f32 radius; + s32 hasCollision; // Boolean delete = FALSE; updateRateF = updateRate; @@ -478,9 +454,11 @@ void obj_loop_laserbolt(Object *obj, s32 updateRate) { obj->segment.y_velocity = (dirY - obj->segment.trans.y_position) / updateRateF; obj->segment.z_velocity = (dirZ - obj->segment.trans.z_position) / updateRateF; } - move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, obj->segment.z_velocity * updateRateF); + move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, + obj->segment.z_velocity * updateRateF); if (hasCollision) { - func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position - 36.0f, obj->segment.trans.z_position, 44, SOUND_NONE, 0.2, 0); + func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position - 36.0f, + obj->segment.trans.z_position, 44, SOUND_NONE, 0.2, 0); delete = TRUE; } @@ -503,7 +481,8 @@ void obj_loop_laserbolt(Object *obj, s32 updateRate) { laserGun->fireTimer = 180; } delete = TRUE; - func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position - 36.0f, obj->segment.trans.z_position, BHV_LENS_FLARE_SWITCH, SOUND_EXPLOSION, 0.5, 0); + func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position - 36.0f, + obj->segment.trans.z_position, BHV_LENS_FLARE_SWITCH, SOUND_EXPLOSION, 0.5, 0); } } if (delete) { @@ -514,7 +493,7 @@ void obj_loop_laserbolt(Object *obj, s32 updateRate) { /** * Torch / Mist init behaviour. * Sets scale and animation speed based off spawn info. -*/ + */ void obj_init_torch_mist(Object *obj, LevelObjectEntry_Torch_Mist *entry) { f32 radius = entry->radius & 0xFF; if (radius < 10.0f) { @@ -528,7 +507,7 @@ void obj_init_torch_mist(Object *obj, LevelObjectEntry_Torch_Mist *entry) { /** * Torch / Mist loop behaviour. * Updates the animation frame based on spawn info's animation speed. -*/ + */ void obj_loop_torch_mist(Object *obj, s32 updateRate) { obj->segment.animFrame += obj->properties.speed.speed * updateRate; } @@ -536,7 +515,7 @@ void obj_loop_torch_mist(Object *obj, s32 updateRate) { /** * Effect box init behaviour. * Does nothing. -*/ + */ void obj_init_effectbox(UNUSED Object *obj, UNUSED LevelObjectEntry_EffectBox *entry) { } @@ -544,7 +523,7 @@ void obj_init_effectbox(UNUSED Object *obj, UNUSED LevelObjectEntry_EffectBox *e * Effect box loop behaviour. * Searches for any racers that are inside the region. * Applies an effect to their weight and velocity. -*/ + */ void obj_loop_effectbox(Object *obj, UNUSED s32 updateRate) { Object **racers; LevelObjectEntry_EffectBox *effectBoxEntry; @@ -569,7 +548,7 @@ void obj_loop_effectbox(Object *obj, UNUSED s32 updateRate) { xExtents = effectBoxEntry->unk8 * 3; yExtents = effectBoxEntry->unk9 * 3; zExtents = effectBoxEntry->unkA * 3; - for(i = 0; i < numRacers; i++) { + for (i = 0; i < numRacers; i++) { curRacerObj = racers[i]; xDiff = curRacerObj->segment.trans.x_position - obj->segment.trans.x_position; yDiff = curRacerObj->segment.trans.y_position - obj->segment.trans.y_position; @@ -594,11 +573,10 @@ void obj_loop_effectbox(Object *obj, UNUSED s32 updateRate) { } } - /** * Trophy Cabinet loop behaviour. * Sets rotation and hitbox data so it can be collided with. -*/ + */ void obj_init_trophycab(Object *obj, LevelObjectEntry_TrophyCab *entry) { obj->interactObj->flags = INTERACT_FLAGS_SOLID; obj->interactObj->unk11 = 2; @@ -609,14 +587,14 @@ void obj_init_trophycab(Object *obj, LevelObjectEntry_TrophyCab *entry) { * Trophy Cabinet loop behaviour. * Displays the dialogue when ran into. * Has unused behaviour that presumably would've handled activating the dialogue from here. -*/ + */ void obj_loop_trophycab(Object *obj, s32 updateRate) { - Settings* settings; + Settings *settings; Object_TrophyCabinet *gfxData; UNUSED f32 dist; LevelObjectEntryCommon newObject; - LevelHeader* header; - Object* tempObj; + LevelHeader *header; + Object *tempObj; f32 diffX; s32 dialogueID; f32 diffZ; @@ -665,7 +643,8 @@ void obj_loop_trophycab(Object *obj, s32 updateRate) { sound_play(SOUND_VOICE_TT_TROPHY_RACE, NULL); func_800A3870(); } else { - // Text for "TROPHY RACE" "TO ENTER THE TROPHY RACE, YOU MUST COMPLETE ALL THE TASKS FROM THIS WORLD. KEEP RACING!" + // Text for "TROPHY RACE" "TO ENTER THE TROPHY RACE, YOU MUST COMPLETE ALL THE TASKS FROM THIS + // WORLD. KEEP RACING!" set_current_text(ASSET_GAME_TEXT_4); gfxData->unk4 = 180; gfxData->unk0 = 140; @@ -719,7 +698,7 @@ void obj_loop_trophycab(Object *obj, s32 updateRate) { /** * Fire Mountain egg init function. * Sets up hitbox data so it can be picked up. -*/ + */ void obj_init_collectegg(Object *obj, UNUSED LevelObjectEntry_CollectEgg *entry) { obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; obj->interactObj->unk11 = 0; @@ -730,7 +709,7 @@ void obj_init_collectegg(Object *obj, UNUSED LevelObjectEntry_CollectEgg *entry) /** * Fire Mountain egg loop function. * Spawn on SURFACE_EGG_SPAWN, and if dropped on surfaces SURFACE_EGG_01 to SURFACE_EGG_04, begin ticking down to hatch. -*/ + */ void obj_loop_collectegg(Object *obj, s32 updateRate) { Object_CollectEgg *egg; Object *racerObj; @@ -747,91 +726,92 @@ void obj_loop_collectegg(Object *obj, s32 updateRate) { updateRateF *= 1.2; } switch (egg->status) { - case EGG_SPAWNED: - try_to_collect_egg(obj, egg); - break; - case EGG_MOVING: - obj->segment.trans.flags &= (0xFFFF - OBJ_FLAGS_INVISIBLE); - dir[0] = obj->segment.trans.x_position + (obj->segment.x_velocity * updateRateF); - dir[1] = obj->segment.trans.y_position + (obj->segment.y_velocity * updateRateF); - dir[2] = obj->segment.trans.z_position + (obj->segment.z_velocity * updateRateF); - radius = 9.0f; - func_80031130(1, &obj->segment.trans.x_position, dir, -1); - hasCollision = FALSE; - surface = SURFACE_DEFAULT; - func_80031600(&obj->segment.trans.x_position, dir, &radius, &surface, TRUE, &hasCollision); - obj->segment.x_velocity = (dir[0] - obj->segment.trans.x_position) / updateRateF; - obj->segment.y_velocity = (dir[1] - obj->segment.trans.y_position) / updateRateF; - obj->segment.z_velocity = (dir[2] - obj->segment.trans.z_position) / updateRateF; - obj->segment.trans.x_position = dir[0]; - obj->segment.trans.y_position = dir[1]; - obj->segment.trans.z_position = dir[2]; - obj->segment.y_velocity -= 0.5; - obj->segment.x_velocity *= 0.98; - obj->segment.z_velocity *= 0.98; - obj->segment.y_velocity *= 0.95; - // Destroy the egg if it lands on an invalid surface. - if (obj->segment.trans.y_position < -2000.0f || (hasCollision && (surface < SURFACE_EGG_SPAWN || surface > SURFACE_EGG_04))) { - if (egg->spawnerObj != NULL) { - egg->spawnerObj->properties.eggSpawner.egg = NULL; + case EGG_SPAWNED: + try_to_collect_egg(obj, egg); + break; + case EGG_MOVING: + obj->segment.trans.flags &= (0xFFFF - OBJ_FLAGS_INVISIBLE); + dir[0] = obj->segment.trans.x_position + (obj->segment.x_velocity * updateRateF); + dir[1] = obj->segment.trans.y_position + (obj->segment.y_velocity * updateRateF); + dir[2] = obj->segment.trans.z_position + (obj->segment.z_velocity * updateRateF); + radius = 9.0f; + func_80031130(1, &obj->segment.trans.x_position, dir, -1); + hasCollision = FALSE; + surface = SURFACE_DEFAULT; + func_80031600(&obj->segment.trans.x_position, dir, &radius, &surface, TRUE, &hasCollision); + obj->segment.x_velocity = (dir[0] - obj->segment.trans.x_position) / updateRateF; + obj->segment.y_velocity = (dir[1] - obj->segment.trans.y_position) / updateRateF; + obj->segment.z_velocity = (dir[2] - obj->segment.trans.z_position) / updateRateF; + obj->segment.trans.x_position = dir[0]; + obj->segment.trans.y_position = dir[1]; + obj->segment.trans.z_position = dir[2]; + obj->segment.y_velocity -= 0.5; + obj->segment.x_velocity *= 0.98; + obj->segment.z_velocity *= 0.98; + obj->segment.y_velocity *= 0.95; + // Destroy the egg if it lands on an invalid surface. + if (obj->segment.trans.y_position < -2000.0f || + (hasCollision && (surface < SURFACE_EGG_SPAWN || surface > SURFACE_EGG_04))) { + if (egg->spawnerObj != NULL) { + egg->spawnerObj->properties.eggSpawner.egg = NULL; + } + free_object(obj); } - free_object(obj); - } - if (hasCollision && surface == SURFACE_EGG_SPAWN) { - egg->status = EGG_SPAWNED; - obj->segment.x_velocity = 0.0f; - obj->segment.z_velocity = 0.0f; - } - if (hasCollision && surface >= SURFACE_EGG_01 && surface <= SURFACE_EGG_04) { - egg->racerID = surface - SURFACE_EGG_01; - egg->status = EGG_IN_BASE; + if (hasCollision && surface == SURFACE_EGG_SPAWN) { + egg->status = EGG_SPAWNED; + obj->segment.x_velocity = 0.0f; + obj->segment.z_velocity = 0.0f; + } + if (hasCollision && surface >= SURFACE_EGG_01 && surface <= SURFACE_EGG_04) { + egg->racerID = surface - SURFACE_EGG_01; + egg->status = EGG_IN_BASE; + racerObj = get_racer_object(egg->racerID); + if (racerObj != NULL) { + racer = (Object_Racer *) racerObj->unk64; + racer->eggHudCounter += 1; + } + egg->hatchTimer = 600; + obj->segment.x_velocity = 0.0f; + obj->segment.z_velocity = 0.0f; + } + break; + case EGG_IN_BASE: + egg->hatchTimer -= updateRate; racerObj = get_racer_object(egg->racerID); if (racerObj != NULL) { racer = (Object_Racer *) racerObj->unk64; - racer->eggHudCounter += 1; } - egg->hatchTimer = 600; - obj->segment.x_velocity = 0.0f; - obj->segment.z_velocity = 0.0f; - } - break; - case EGG_IN_BASE: - egg->hatchTimer -= updateRate; - racerObj = get_racer_object(egg->racerID); - if (racerObj != NULL) { - racer = (Object_Racer *) racerObj->unk64; - } - if (egg->hatchTimer <= 0) { + if (egg->hatchTimer <= 0) { + if (racerObj != NULL) { + racer->lap += 1; + } + egg->status = EGG_HATCHED; + egg->spawnerObj->properties.eggSpawner.egg = NULL; + } + if (egg->hatchTimer < 540) { + try_to_collect_egg(obj, egg); + } + if (racerObj != NULL && egg->status != EGG_IN_BASE) { + racer->eggHudCounter -= 1; + } + break; + case EGG_HATCHED: + racerObj = get_racer_object(egg->racerID); if (racerObj != NULL) { - racer->lap += 1; + racer = (Object_Racer *) racerObj->unk64; + if (racer->lap >= 3) { + racer->raceFinished = TRUE; + } } - egg->status = EGG_HATCHED; - egg->spawnerObj->properties.eggSpawner.egg = NULL; - } - if (egg->hatchTimer < 540) { - try_to_collect_egg(obj, egg); - } - if (racerObj != NULL && egg->status != EGG_IN_BASE) { - racer->eggHudCounter -= 1; - } - break; - case EGG_HATCHED: - racerObj = get_racer_object(egg->racerID); - if (racerObj != NULL) { - racer = (Object_Racer *) racerObj->unk64; - if (racer->lap >= 3) { - racer->raceFinished = TRUE; - } - } - obj->segment.animFrame = 128; - break; + obj->segment.animFrame = 128; + break; } } /** * Egg Spawner init behaviour. * Does nothing. -*/ + */ void obj_init_eggcreator(UNUSED Object *obj, UNUSED LevelObjectEntry_EggCreator *entry) { } @@ -839,7 +819,7 @@ void obj_init_eggcreator(UNUSED Object *obj, UNUSED LevelObjectEntry_EggCreator * Egg Spawner Sign init behaviour. * Action is set to 0 if it has no egg child object. * Spawns an egg and tracks its existence. -*/ + */ void obj_loop_eggcreator(Object *obj, UNUSED s32 updateRate) { LevelObjectEntryCommon spawnObj; Object *eggObj; @@ -863,7 +843,7 @@ void obj_loop_eggcreator(Object *obj, UNUSED s32 updateRate) { /** * Trophy Race Sign init behaviour. * Sets size and rotation based off spawn info. -*/ + */ void obj_init_lighthouse_rocketsignpost(Object *obj, LevelObjectEntry_Lighthouse_RocketSignpost *entry) { f32 radius = entry->radius & 0xFF; if (radius < 10) { @@ -885,7 +865,7 @@ void obj_init_lighthouse_rocketsignpost(Object *obj, LevelObjectEntry_Lighthouse * Trophy Race Sign loop behaviour. * Checks if the player is nearby and if they have tried to initiate dialogue. * It then calls the function to check if it should start the lighthouse cutscene. -*/ + */ void obj_loop_rocketsignpost(Object *obj, UNUSED s32 updateRate) { Object *playerObj; ObjectInteraction *interactObj; @@ -908,7 +888,7 @@ void obj_loop_rocketsignpost(Object *obj, UNUSED s32 updateRate) { /** * Air/Water Zipper init behaviour. * Sets scale and angle based on entry data. -*/ + */ void obj_init_airzippers_waterzippers(Object *obj, LevelObjectEntry_AirZippers_WaterZippers *entry) { ObjectHeader *objHeader; f32 radius; @@ -938,7 +918,7 @@ void obj_init_airzippers_waterzippers(Object *obj, LevelObjectEntry_AirZippers_W * Searches for a racer among its interactions. * If a racer passes over it, set the value to initiate a boost on their end to true. * Will turn invisible and intangible if there are no hovercraft or airplanes being used. -*/ + */ void obj_loop_airzippers_waterzippers(Object *obj, UNUSED s32 updateRate) { Object *curRacerObj; Object_Racer *racer; @@ -946,7 +926,7 @@ void obj_loop_airzippers_waterzippers(Object *obj, UNUSED s32 updateRate) { f32 diffY; f32 diffZ; s32 numObjects; - Object** racerObjs; + Object **racerObjs; s32 i; if (find_non_car_racers() == FALSE) { @@ -975,7 +955,7 @@ void obj_loop_airzippers_waterzippers(Object *obj, UNUSED s32 updateRate) { /** * Ground Zipper init behaviour. * Sets scale and angle based on entry data. -*/ + */ void obj_init_groundzipper(Object *obj, LevelObjectEntry_GroundZipper *entry) { ObjectHeader *header; f32 radius; @@ -1014,7 +994,7 @@ void obj_init_groundzipper(Object *obj, LevelObjectEntry_GroundZipper *entry) { * Ground Zipper loop behaviour. * Searches for a racer among its interactions. * If a racer passes over it, initiate a boost, which can be empowered by releasing the A button. -*/ + */ void obj_loop_groundzipper(Object *obj, UNUSED s32 updateRate) { Object *racerObj; Object_Racer *racer; @@ -1022,7 +1002,7 @@ void obj_loop_groundzipper(Object *obj, UNUSED s32 updateRate) { f32 diffY; s32 numObjects; f32 diffZ; - Object** racerObjs; + Object **racerObjs; s32 i; obj->segment.trans.flags &= (0xFFFF - OBJ_FLAGS_INVISIBLE); @@ -1039,7 +1019,9 @@ void obj_loop_groundzipper(Object *obj, UNUSED s32 updateRate) { diffZ = racerObj->segment.trans.z_position - obj->segment.trans.z_position; if ((s32) sqrtf((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)) < obj->properties.zipper.radius) { if (racer->playerIndex != PLAYER_COMPUTER) { - sound_play_spatial(SOUND_ZIP_PAD_BOOST, racerObj->segment.trans.x_position, racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, NULL); + sound_play_spatial(SOUND_ZIP_PAD_BOOST, racerObj->segment.trans.x_position, + racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, + NULL); } racer->boostTimer = normalise_time(45); racer->boostType = BOOST_LARGE; @@ -1122,7 +1104,7 @@ void obj_loop_characterflag(Object *obj, UNUSED s32 updateRate) { flag->texture = (TextureHeader *) &obj->unk68[obj->properties.characterFlag.characterID]->texHeader; temp_t4 = (flag->texture->width - 1) << 21; temp_t5 = (flag->texture->height - 1) << 5; - //0x40 = Draw backface + // 0x40 = Draw backface flag->triangles[0].vertices = (0x40 << 24) | (0 << 16) | (1 << 8) | 3; flag->triangles[0].uv0.texCoords = 0; flag->triangles[0].uv1.texCoords = temp_t4; @@ -1138,7 +1120,7 @@ void obj_loop_characterflag(Object *obj, UNUSED s32 updateRate) { /** * If interacted by a racer, attach itself to the player and mark as invisible * if the player is not already carrying an egg. -*/ + */ void try_to_collect_egg(Object *obj, Object_CollectEgg *egg) { Object_64 *racer; Object *interactedObj; @@ -1161,9 +1143,9 @@ void try_to_collect_egg(Object *obj, Object_CollectEgg *egg) { transF.y_position = -interactedObj->segment.trans.y_position; transF.z_position = -interactedObj->segment.trans.z_position; object_transform_to_matrix_2(mat, &transF); - guMtxXFMF(mat, - obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, - &obj->segment.trans.x_position, &obj->segment.trans.y_position, &obj->segment.trans.z_position); + guMtxXFMF(mat, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, &obj->segment.trans.x_position, &obj->segment.trans.y_position, + &obj->segment.trans.z_position); obj->segment.trans.x_position /= interactedObj->segment.trans.scale; obj->segment.trans.y_position /= interactedObj->segment.trans.scale; obj->segment.trans.z_position /= interactedObj->segment.trans.scale; @@ -1175,7 +1157,7 @@ void try_to_collect_egg(Object *obj, Object_CollectEgg *egg) { /** * Hub world T.T init behaviour. * Sets hitbox data to make him solid. -*/ + */ void obj_init_stopwatchman(Object *obj, UNUSED LevelObjectEntry_StopWatchMan *entry) { Object_TT *tt; obj->interactObj->flags = INTERACT_FLAGS_SOLID; @@ -1192,7 +1174,7 @@ void obj_init_stopwatchman(Object *obj, UNUSED LevelObjectEntry_StopWatchMan *en * Hub world T.T loop behaviour. * Handles all the behaviour for the T.T NPC found in the overworld. * This uses a state machine to handle whether to wander around, approach the player and engage dialogue. -*/ + */ void obj_loop_stopwatchman(Object *obj, s32 updateRate) { f32 updateRateF; f32 diffX; @@ -1227,10 +1209,14 @@ void obj_loop_stopwatchman(Object *obj, s32 updateRate) { racerObj = get_racer_object(PLAYER_ONE); if (racerObj != NULL) { racer = (Object_Racer *) racerObj->unk64; - diffX = ((racerObj->segment.trans.x_position - (racer->ox1 * 50.0f)) - (racer->ox3 * 5.0f)) - obj->segment.trans.x_position; - diffZ = ((racerObj->segment.trans.z_position - (racer->oz1 * 50.0f)) - (racer->oz3 * 5.0f)) - obj->segment.trans.z_position; + diffX = ((racerObj->segment.trans.x_position - (racer->ox1 * 50.0f)) - (racer->ox3 * 5.0f)) - + obj->segment.trans.x_position; + diffZ = ((racerObj->segment.trans.z_position - (racer->oz1 * 50.0f)) - (racer->oz3 * 5.0f)) - + obj->segment.trans.z_position; distance = sqrtf((diffX * diffX) + (diffZ * diffZ)); - angleDiff = arctan2_f(racerObj->segment.trans.x_position - obj->segment.trans.x_position, racerObj->segment.trans.z_position - obj->segment.trans.z_position) - (racerObj->segment.trans.y_rotation & 0xFFFF); + angleDiff = arctan2_f(racerObj->segment.trans.x_position - obj->segment.trans.x_position, + racerObj->segment.trans.z_position - obj->segment.trans.z_position) - + (racerObj->segment.trans.y_rotation & 0xFFFF); if (angleDiff > 0x8000) { angleDiff = -0xFFFF; } @@ -1245,7 +1231,8 @@ void obj_loop_stopwatchman(Object *obj, s32 updateRate) { index = get_buttons_pressed_from_player(PLAYER_ONE); if (obj->properties.npc.action == TT_MODE_ROAM && distance < 300.0 && obj->properties.npc.timer == 0) { if (angleDiff > -0x2000 && angleDiff < 0x2000) { - if ((obj->interactObj->flags & INTERACT_FLAGS_PUSHING && racerObj == obj->interactObj->obj) || index & Z_TRIG) { + if ((obj->interactObj->flags & INTERACT_FLAGS_PUSHING && racerObj == obj->interactObj->obj) || + index & Z_TRIG) { if (index & Z_TRIG) { play_char_horn_sound(racerObj, racer); } @@ -1272,14 +1259,47 @@ void obj_loop_stopwatchman(Object *obj, s32 updateRate) { index = 0; } switch (obj->properties.npc.action) { - case TT_MODE_APPROACH_PLAYER: - obj->segment.object.animationID = 0; - tt->unkD = 255; - if (distance < 100.0) { + case TT_MODE_APPROACH_PLAYER: + obj->segment.object.animationID = 0; + tt->unkD = 255; + if (distance < 100.0) { + racer_set_dialogue_camera(); + } + if (distance > 10.0) { + angleDiff = + (arctan2_f(diffX / distance, diffZ / distance) - (obj->segment.trans.y_rotation & 0xFFFF)) + 0x8000; + if (angleDiff > 0x8000) { + angleDiff -= 0xFFFF; + } + if (angleDiff < -0x8000) { + angleDiff += 0xFFFF; + } + if (angleDiff > 0) { + if (angleDiff < 0x10) { + angleDiff = 0x10; + } + } + obj->segment.trans.y_rotation += angleDiff >> 4; + distance = -2.0f; + if (angleDiff > 0x800 || angleDiff < -0x800) { + distance = -0.5f; + } + tt->forwardVel += (distance - tt->forwardVel) * 0.125; + obj->segment.x_velocity = sins_f(obj->segment.trans.y_rotation) * tt->forwardVel; + obj->segment.z_velocity = coss_f(obj->segment.trans.y_rotation) * tt->forwardVel; + tt->animFrameF -= (tt->forwardVel * 2 * updateRateF); + } else { + obj->properties.npc.action = TT_MODE_TURN_TOWARDS_PLAYER; + } + move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, + obj->segment.z_velocity * updateRateF); + set_pause_lockout_timer(1); + break; + case TT_MODE_TURN_TOWARDS_PLAYER: racer_set_dialogue_camera(); - } - if (distance > 10.0) { - angleDiff = (arctan2_f(diffX / distance, diffZ / distance) - (obj->segment.trans.y_rotation & 0xFFFF)) + 0x8000; + obj->segment.object.animationID = 0; + tt->animFrameF += 3.0 * updateRateF; + angleDiff = (racerObj->segment.trans.y_rotation - (obj->segment.trans.y_rotation & 0xFFFF)) + 0x8000; if (angleDiff > 0x8000) { angleDiff -= 0xFFFF; } @@ -1291,101 +1311,75 @@ void obj_loop_stopwatchman(Object *obj, s32 updateRate) { angleDiff = 0x10; } } - obj->segment.trans.y_rotation += angleDiff >> 4; - distance = -2.0f; - if (angleDiff > 0x800 || angleDiff < -0x800) { - distance = -0.5f; + obj->segment.trans.y_rotation += (angleDiff >> 4); + obj->segment.x_velocity = diffX * 0.05; + obj->segment.z_velocity = diffZ * 0.05; + if (angleDiff < 0x500) { + if (angleDiff >= -0x4FF) { + obj->properties.npc.action = TT_MODE_DIALOGUE; + play_tt_voice_clip(SOUND_VOICE_TT_INTRO, 1); // Hi there, I'm T.T! + } } - tt->forwardVel += (distance - tt->forwardVel) * 0.125; - obj->segment.x_velocity = sins_f(obj->segment.trans.y_rotation) * tt->forwardVel; - obj->segment.z_velocity = coss_f(obj->segment.trans.y_rotation) * tt->forwardVel; - tt->animFrameF -= (tt->forwardVel * 2 * updateRateF); - } else { - obj->properties.npc.action = TT_MODE_TURN_TOWARDS_PLAYER; - } - move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, obj->segment.z_velocity * updateRateF); - set_pause_lockout_timer(1); - break; - case TT_MODE_TURN_TOWARDS_PLAYER: - racer_set_dialogue_camera(); - obj->segment.object.animationID = 0; - tt->animFrameF += 3.0 * updateRateF; - angleDiff = (racerObj->segment.trans.y_rotation - (obj->segment.trans.y_rotation & 0xFFFF)) + 0x8000; - if (angleDiff > 0x8000) { - angleDiff -= 0xFFFF; - } - if (angleDiff < -0x8000) { - angleDiff += 0xFFFF; - } - if (angleDiff > 0) { - if (angleDiff < 0x10) { - angleDiff = 0x10; + move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, + obj->segment.z_velocity * updateRateF); + break; + case TT_MODE_DIALOGUE: + obj->segment.x_velocity = diffX * 0.05; + obj->segment.z_velocity = diffZ * 0.05; + obj->segment.object.animationID = 1; + tt->animFrameF += 1.0 * updateRateF; + racer_set_dialogue_camera(); + if (index == 3) { + obj->properties.npc.action = TT_MODE_DIALOGUE_END; + if (is_time_trial_enabled()) { + play_tt_voice_clip(SOUND_VOICE_TT_SEE_YOU, 1); + } else { + play_tt_voice_clip(SOUND_VOICE_TT_OK, 1); + } + slowly_change_fog(PLAYER_ONE, tt->fogR, tt->fogG, tt->fogB, tt->fogNear, tt->fogFar, 180); + music_play(header->music); + music_dynamic_set(header->instruments); + racer->vehicleSound = func_80004B40(racer->characterId, racer->vehicleID); } - } - obj->segment.trans.y_rotation += (angleDiff >> 4); - obj->segment.x_velocity = diffX * 0.05; - obj->segment.z_velocity = diffZ * 0.05; - if (angleDiff < 0x500) { - if (angleDiff >= -0x4FF) { - obj->properties.npc.action = TT_MODE_DIALOGUE; - play_tt_voice_clip(SOUND_VOICE_TT_INTRO, 1); // Hi there, I'm T.T! + obj->properties.npc.timer = 180; + move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, + obj->segment.z_velocity * updateRateF); + break; + case TT_MODE_DIALOGUE_END: + tt->animFrameF += 1.0 * updateRateF; + racer_set_dialogue_camera(); + if (obj->properties.npc.timer < 140) { + obj->properties.npc.timer += 60; + obj->properties.npc.action = TT_MODE_ROAM; + obj->segment.object.animationID = 0; } - } - move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, obj->segment.z_velocity * updateRateF); - break; - case TT_MODE_DIALOGUE: - obj->segment.x_velocity = diffX * 0.05; - obj->segment.z_velocity = diffZ * 0.05; - obj->segment.object.animationID = 1; - tt->animFrameF += 1.0 * updateRateF; - racer_set_dialogue_camera(); - if (index == 3) { - obj->properties.npc.action = TT_MODE_DIALOGUE_END; - if (is_time_trial_enabled()) { - play_tt_voice_clip(SOUND_VOICE_TT_SEE_YOU, 1); - } else { - play_tt_voice_clip(SOUND_VOICE_TT_OK, 1); - } - slowly_change_fog(PLAYER_ONE, tt->fogR, tt->fogG, tt->fogB, tt->fogNear, tt->fogFar, 180); - music_play(header->music); - music_dynamic_set(header->instruments); - racer->vehicleSound = func_80004B40(racer->characterId, racer->vehicleID); - } - obj->properties.npc.timer = 180; - move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, obj->segment.z_velocity * updateRateF); - break; - case TT_MODE_DIALOGUE_END: - tt->animFrameF += 1.0 * updateRateF; - racer_set_dialogue_camera(); - if (obj->properties.npc.timer < 140) { - obj->properties.npc.timer += 60; - obj->properties.npc.action = TT_MODE_ROAM; + break; + default: obj->segment.object.animationID = 0; - } - break; - default: - obj->segment.object.animationID = 0; - tt->forwardVel = 0.0f; - if (tt->unkD == 0xFF) { - tt->unkD = func_8001C524(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 0); - if (tt->unkD != 0xFF) { - tt->unkE = func_8001CC48(tt->unkD, -1, 0); - tt->unkF = func_8001CC48(tt->unkE, tt->unkD, 0); - tt->unk10 = func_8001CC48(tt->unkF, tt->unkE, 0); - tt->unkC = tt->unkD; + tt->forwardVel = 0.0f; + if (tt->unkD == 0xFF) { + tt->unkD = func_8001C524(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 0); + if (tt->unkD != 0xFF) { + tt->unkE = func_8001CC48(tt->unkD, -1, 0); + tt->unkF = func_8001CC48(tt->unkE, tt->unkD, 0); + tt->unk10 = func_8001CC48(tt->unkF, tt->unkE, 0); + tt->unkC = tt->unkD; + } + } else { + diffZ = func_8001C6C4((Object_64 *) tt, obj, updateRateF, 1.0f, 0); + tt->animFrameF += diffZ * 1.5; } - } else { - diffZ = func_8001C6C4((Object_64 *) tt, obj, updateRateF, 1.0f, 0); - tt->animFrameF += diffZ * 1.5; - } - break; + break; } obj->segment.trans.y_position = tempPosY; - index = func_8002B0F4(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position, &water); - if(index != 0) { + index = func_8002B0F4(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position, + &water); + if (index != 0) { index--; - while(index >= 0) { - if ((water[index]->type != WATER_CALM) && (water[index]->type != WATER_WAVY) && (water[index]->rotY > 0.0)) { + while (index >= 0) { + if ((water[index]->type != WATER_CALM) && (water[index]->type != WATER_WAVY) && + (water[index]->rotY > 0.0)) { obj->segment.trans.y_position = water[index]->waveHeight; } index--; @@ -1398,7 +1392,7 @@ void obj_loop_stopwatchman(Object *obj, s32 updateRate) { } obj->segment.animFrame = 1.0 * tt->animFrameF; func_80061C0C(obj); - if (0) { } // Fakematch + if (0) {} // Fakematch if (obj->properties.npc.timer > 0) { obj->properties.npc.timer -= updateRate; } else { @@ -1406,14 +1400,13 @@ void obj_loop_stopwatchman(Object *obj, s32 updateRate) { } } - /** * If TT is currently talking, clear the audio associated with gTTSoundMask, * then play the new sound ID in its place. */ void play_tt_voice_clip(u16 soundID, s32 interrupt) { if (gTTSoundMask && interrupt & 1) { - func_8000488C(gTTSoundMask); //This is likely wrong and will need to be fixed + func_8000488C(gTTSoundMask); // This is likely wrong and will need to be fixed gTTSoundMask = NULL; } if (gTTSoundMask == NULL) { @@ -1455,21 +1448,21 @@ void obj_init_fish(Object *fishObj, LevelObjectEntry_Fish *fishEntry, s32 param) fishObj->segment.trans.x_position = fish->unk108; xPos = (sinsFE * coss104) + (cossFE * sins104); - + fishObj->segment.trans.z_position = fish->unk110; zPos = (cossFE * coss104) - (sinsFE * sins104); ignore_bounds_check(); move_object(fishObj, xPos, 0.0f, zPos); if (param == 0) { - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { fish->triangles[i].flags = D_800DC9D0[i].flags; fish->triangles[i].vi0 = D_800DC9D0[i].vi0; fish->triangles[i].vi1 = D_800DC9D0[i].vi1; fish->triangles[i].vi2 = D_800DC9D0[i].vi2; } uMask = 0; - for(i = 0; i < 6; i++) { + for (i = 0; i < 6; i++) { fish->vertices[uMask].x = D_800DC9A8[uMask].x; fish->vertices[uMask].y = D_800DC9A8[uMask].y; fish->vertices[uMask].z = D_800DC9A8[uMask].z; @@ -1477,13 +1470,13 @@ void obj_init_fish(Object *fishObj, LevelObjectEntry_Fish *fishEntry, s32 param) fish->vertices[uMask].g = 255; fish->vertices[uMask].b = 255; fish->vertices[uMask].a = 255; - fish->vertices[uMask+6].x = D_800DC9A8[uMask].x; - fish->vertices[uMask+6].y = D_800DC9A8[uMask].y; - fish->vertices[uMask+6].z = D_800DC9A8[uMask].z; - fish->vertices[uMask+6].r = 255; - fish->vertices[uMask+6].g = 255; - fish->vertices[uMask+6].b = 255; - fish->vertices[uMask+6].a = 255; + fish->vertices[uMask + 6].x = D_800DC9A8[uMask].x; + fish->vertices[uMask + 6].y = D_800DC9A8[uMask].y; + fish->vertices[uMask + 6].z = D_800DC9A8[uMask].z; + fish->vertices[uMask + 6].r = 255; + fish->vertices[uMask + 6].g = 255; + fish->vertices[uMask + 6].b = 255; + fish->vertices[uMask + 6].a = 255; uMask++; } fish->unkFC = 1; @@ -1501,7 +1494,7 @@ void obj_init_fish(Object *fishObj, LevelObjectEntry_Fish *fishEntry, s32 param) uMask = 0; vMask = 0; } - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { fish->triangles[i].uv0.u = D_800DC9D0[i].uv0.u * uMask >> 2; fish->triangles[i].uv0.v = D_800DC9D0[i].uv0.v * vMask >> 2; fish->triangles[i].uv1.u = D_800DC9D0[i].uv1.u * uMask >> 2; @@ -1530,10 +1523,10 @@ void obj_loop_fish(Object *fishObj, s32 updateRate) { s32 temp_s0_2; s32 temp_t1; s32 temp_t9; - f32 prevXThing, prevZThing; + f32 prevXThing, prevZThing; Vertex *verts; s32 randNumber; - + if (get_viewport_count() > 0) { free_object(fishObj); return; @@ -1554,8 +1547,9 @@ void obj_loop_fish(Object *fishObj, s32 updateRate) { fish->unkFD = get_random_number_from_range(160, 255); randNumber = get_random_number_from_range(0, fish->unk118); fishObj->segment.y_velocity = fish->unk10C - fishObj->segment.trans.y_position; - fishObj->segment.y_velocity = (fishObj->segment.trans.y_position < fish->unk10C) ? (fishObj->segment.y_velocity + randNumber) : - (fishObj->segment.y_velocity - randNumber); + fishObj->segment.y_velocity = (fishObj->segment.trans.y_position < fish->unk10C) + ? (fishObj->segment.y_velocity + randNumber) + : (fishObj->segment.y_velocity - randNumber); fishObj->segment.y_velocity /= fish->unkFD; } } @@ -1565,7 +1559,7 @@ void obj_loop_fish(Object *fishObj, s32 updateRate) { sinUnk104 = sins_f(fish->unk104); cosUnk104 = coss_f(fish->unk104); dist3D += 0; // Fakematch - prevXThing = zThing; + prevXThing = zThing; prevZThing = xThing; zThing = prevXThing; // Fakematch? zThing = (zThing * cosUnk104) + (prevZThing * sinUnk104); @@ -1580,7 +1574,7 @@ void obj_loop_fish(Object *fishObj, s32 updateRate) { fishObj->segment.trans.z_position = 0.0f; ignore_bounds_check(); move_object(fishObj, zThing, yThing, xThing); - dist2D = (xDiff * xDiff) + (zDiff * zDiff); + dist2D = (xDiff * xDiff) + (zDiff * zDiff); dist3D = sqrtf((yDiff * yDiff) + dist2D); dist2D = sqrtf(dist2D); fish->unk106 += (s32) (dist3D * 0x600); @@ -1598,7 +1592,7 @@ void obj_loop_fish(Object *fishObj, s32 updateRate) { randNumber = sins(fish->unk106) >> 3; temp_s0_2 = (s32) (coss_f(randNumber) * 32); temp_t1 = (s32) (sins_f(randNumber) * 32); - verts[4].x = (verts[2].x + temp_t1); + verts[4].x = (verts[2].x + temp_t1); verts[4].z = (verts[2].z + temp_s0_2); verts[5].x = (verts[3].x + temp_t1); verts[5].z = (verts[3].z + temp_s0_2); @@ -1607,7 +1601,7 @@ void obj_loop_fish(Object *fishObj, s32 updateRate) { /** * Lava Spurt init behaviour. * Set the timer between animations, and also set the timer to wait before playing the first animation. -*/ + */ void obj_init_lavaspurt(Object *obj, LevelObjectEntry_LavaSpurt *entry) { obj->properties.lavaSpurt.actionTimer = entry->initialTimer * 2; obj->properties.lavaSpurt.delayTimer = entry->delayTimer; @@ -1615,8 +1609,9 @@ void obj_init_lavaspurt(Object *obj, LevelObjectEntry_LavaSpurt *entry) { /** * Lava Spurt loop behaviour. - * Count down until zero, then play an animation, after which, set the down time to a random amount with an offset based on spawn properties. -*/ + * Count down until zero, then play an animation, after which, set the down time to a random amount with an offset based + * on spawn properties. + */ void obj_loop_lavaspurt(Object *obj, s32 updateRate) { if (obj->properties.lavaSpurt.actionTimer > 0) { obj->properties.lavaSpurt.actionTimer -= updateRate; @@ -1626,7 +1621,8 @@ void obj_loop_lavaspurt(Object *obj, s32 updateRate) { obj->segment.animFrame += updateRate * 4; if (obj->segment.animFrame > 255) { obj->segment.animFrame = 0; - obj->properties.lavaSpurt.actionTimer = get_random_number_from_range(0, 30) + obj->properties.lavaSpurt.delayTimer; + obj->properties.lavaSpurt.actionTimer = + get_random_number_from_range(0, 30) + obj->properties.lavaSpurt.delayTimer; } } } @@ -1665,7 +1661,8 @@ void obj_init_animator(Object *obj, LevelObjectEntry_Animator *entry, s32 param) obj64->batchId = entry->batchID; obj64->speedFactorX = entry->speedFactorX; obj64->speedFactorY = entry->speedfactorY; - obj64->segmentId = get_level_segment_index_from_position(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + obj64->segmentId = get_level_segment_index_from_position( + obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); // Always true. if (param == 0) { obj64->xSpeed = 0; @@ -1690,10 +1687,10 @@ void obj_init_animator(Object *obj, LevelObjectEntry_Animator *entry, s32 param) // Has minor issues void obj_loop_animator(Object *obj, s32 updateRate) { - Object_Animator* obj64; // 3C + Object_Animator *obj64; // 3C s32 sp20; s32 sp1C; - LevelModel* levelModel; + LevelModel *levelModel; s32 temp, temp2, segmentId, batchId; s32 i; s32 nextFacesOffset; @@ -1703,7 +1700,7 @@ void obj_loop_animator(Object *obj, s32 updateRate) { TextureInfo *texInfo; TriangleBatchInfo *triangleBatchInfo; LevelModelSegment *levelModelSegment; - Triangle* triangle; + Triangle *triangle; TextureHeader *tex; s32 maxSpeed; @@ -1772,7 +1769,7 @@ GLOBAL_ASM("asm/non_matchings/object_functions/obj_loop_animator.s") #endif void obj_init_animation(Object *obj, LevelObjectEntry_Animation *entry, s32 arg2) { - Object_Animation* obj64; + Object_Animation *obj64; s8 tempOrderIndex; f32 scalef; @@ -1819,7 +1816,8 @@ void obj_init_animation(Object *obj, LevelObjectEntry_Animation *entry, s32 arg2 if (arg2 != 0 && (get_buttons_pressed_from_player(PLAYER_ONE) & R_CBUTTONS)) { obj->properties.animatedObj.action = 2; } - if (((get_cutscene_id() == entry->channel) || (entry->channel == 20)) && (obj->unk64 == NULL) && (entry->order == 0) && (entry->objectIdToSpawn != -1)) { + if (((get_cutscene_id() == entry->channel) || (entry->channel == 20)) && (obj->unk64 == NULL) && + (entry->order == 0) && (entry->objectIdToSpawn != -1)) { func_8001F23C(obj, entry); } obj64 = &obj->unk64->animation; @@ -1835,7 +1833,6 @@ void obj_init_animation(Object *obj, LevelObjectEntry_Animation *entry, s32 arg2 } } - void obj_loop_animobject(Object *obj, s32 updateRate) { func_8001F460(obj, updateRate, obj); } @@ -1861,14 +1858,14 @@ UNUSED void obj_loop_overridepos(UNUSED Object *obj, UNUSED s32 arg1) { /** * Wizpig ship initilisation. * Does nothing. -*/ + */ void obj_init_wizpigship(UNUSED Object *obj, UNUSED LevelObjectEntry_WizpigShip *entry) { } /** * Wizpig ship loop behaviour. * Periodically shoots laserbeams in front of it. -*/ + */ void obj_loop_wizpigship(Object *wizShipObj, s32 updateRate) { s32 i; s32 index; @@ -1902,7 +1899,7 @@ void obj_loop_wizpigship(Object *wizShipObj, s32 updateRate) { trans.x_rotation = wizShipObj->segment.trans.x_rotation; trans.z_rotation = 0; object_transform_to_matrix(laserMtx, &trans); - + for (i = 0; i < wizShipObj->unk60->unk0; i++) { index = wizShipObj->unk60->unk2C[i]; if ((index >= 0) && (index < wizShipModel->unk18)) { @@ -1921,9 +1918,12 @@ void obj_loop_wizpigship(Object *wizShipObj, s32 updateRate) { newObj->segment.level_entry = NULL; newObj->segment.trans.y_rotation = wizShipObj->segment.trans.y_rotation + 0x8000; newObj->segment.trans.x_rotation = -wizShipObj->segment.trans.x_rotation; - newObj->properties.lasergun.timer = 0x3C; - guMtxXFMF(laserMtx, 0.0f, 0.0f, -30.0f, &newObj->segment.x_velocity, &newObj->segment.y_velocity, &newObj->segment.z_velocity); - play_sound_at_position(SOUND_LASER_GUN, wizShipObj->segment.trans.x_position, wizShipObj->segment.trans.y_position, wizShipObj->segment.trans.z_position, 4, NULL); + newObj->properties.lasergun.timer = 0x3C; + guMtxXFMF(laserMtx, 0.0f, 0.0f, -30.0f, &newObj->segment.x_velocity, + &newObj->segment.y_velocity, &newObj->segment.z_velocity); + play_sound_at_position(SOUND_LASER_GUN, wizShipObj->segment.trans.x_position, + wizShipObj->segment.trans.y_position, + wizShipObj->segment.trans.z_position, 4, NULL); } } } @@ -2000,9 +2000,11 @@ void obj_loop_snowball(Object *obj, s32 updateRate) { } if (obj64->unk24 != 0) { if (obj64->soundMask == NULL) { - play_sound_at_position(obj64->unk24, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 1, (SoundMask **) &obj64->soundMask); + play_sound_at_position(obj64->unk24, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 1, (SoundMask **) &obj64->soundMask); } else { - update_spatial_audio_position((SoundMask *) obj64->soundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + update_spatial_audio_position((SoundMask *) obj64->soundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } } func_8001F460(obj, updateRate, obj); @@ -2028,7 +2030,7 @@ void obj_loop_char_select(Object *charSelectObj, s32 updateRate) { u8 sp50[4]; u8 sp4F; u8 *var_a2; - + var_s0 = 0; func_8001F460(charSelectObj, updateRate, NULL); charSelect = &charSelectObj->unk64->characterSelect; @@ -2052,7 +2054,7 @@ void obj_loop_char_select(Object *charSelectObj, s32 updateRate) { var_a2 = D_800DCA50; var_a0 = 8; } - + for (i = 0; i < var_a0 && !var_s0; i++) { if (charSelect->unk28 == var_a2[i]) { var_s0 = 1; @@ -2061,7 +2063,7 @@ void obj_loop_char_select(Object *charSelectObj, s32 updateRate) { i--; if (var_s0) { charSelectObj->segment.object.animationID = 1; - for(var_s0 = 0, sp4F = 0; var_s0 < MAXCONTROLLERS; var_s0++) { + for (var_s0 = 0, sp4F = 0; var_s0 < MAXCONTROLLERS; var_s0++) { if (get_player_character(var_s0) == i) { sp50[sp4F++] = var_s0; } @@ -2082,9 +2084,10 @@ void obj_loop_char_select(Object *charSelectObj, s32 updateRate) { func_800AFC3C(charSelectObj, 2); } } - + for (i2 = 0; i2 < objMdl->numberOfBatches; i2++) { - //Unneccessary check for textureIndex to be greater than or equal to zero since it's a u8 and can't be less. + // Unneccessary check for textureIndex to be greater than or equal to zero since it's a u8 and + // can't be less. if (objMdl->batches[i2].textureIndex >= 0 && objMdl->batches[i2].textureIndex < 4) { objMdl->batches[i2].textureIndex = sp50[D_800DCA88[i]]; } @@ -2094,8 +2097,8 @@ void obj_loop_char_select(Object *charSelectObj, s32 updateRate) { } if (charSelectObj->segment.object.animationID >= 0) { if ((charSelectObj->segment.object.animationID < objMdl->numberOfAnimations)) { - i = (objMdl->animations[charSelectObj->segment.object.animationID].unk4 - 1) << 4; - if((charSelect->unk2C == 1)) { + i = (objMdl->animations[charSelectObj->segment.object.animationID].unk4 - 1) << 4; + if ((charSelect->unk2C == 1)) { temp_f0 = music_animation_fraction(); if (temp_f0 > 0.5) { temp_f0 -= 0.5; @@ -2127,7 +2130,9 @@ void obj_loop_animcamera(Object *obj, s32 updateRate) { phi_v1 = 1; } if (phi_v1) { - write_to_object_render_stack(obj64->unk30, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 0x8000 - obj->segment.trans.y_rotation, -obj->segment.trans.x_rotation, obj->segment.trans.z_rotation); + write_to_object_render_stack(obj64->unk30, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 0x8000 - obj->segment.trans.y_rotation, + -obj->segment.trans.x_rotation, obj->segment.trans.z_rotation); } } } @@ -2265,7 +2270,8 @@ void obj_loop_bombexplosion(Object *obj, s32 updateRate) { temp_t8 = (obj->properties.bombExplosion.unk4 >> 8) & 0xFF; if (obj->properties.bombExplosion.timer > 10 && temp_t8 != 0) { obj->properties.bombExplosion.unk4 ^= (temp_t8 << 8); - func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, BHV_LENS_FLARE_SWITCH, SOUND_NONE, 1.0f, temp_t8 - 1); + func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, + BHV_LENS_FLARE_SWITCH, SOUND_NONE, 1.0f, temp_t8 - 1); } if (obj->properties.bombExplosion.timer < 20) { obj->segment.trans.scale = ((obj->properties.bombExplosion.timer / 20.0f) * 10.0f) + 0.5f; @@ -2276,7 +2282,7 @@ void obj_loop_bombexplosion(Object *obj, s32 updateRate) { } else { free_object(obj); } - + if (obj->unk74 != 0) { if (get_number_of_active_players() < THREE_PLAYERS) { func_800AFC3C(obj, 2); @@ -2289,7 +2295,7 @@ void obj_loop_bombexplosion(Object *obj, s32 updateRate) { * Future Fun Land Teleport init behaviour. * Sets hitbox data based off spawn info. * If the player has seen the lighthouse cutscene, enable the object. -*/ + */ void obj_init_teleport(Object *obj, UNUSED LevelObjectEntry_Teleport *entry) { obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; obj->interactObj->unk11 = 0; @@ -2303,7 +2309,7 @@ void obj_init_teleport(Object *obj, UNUSED LevelObjectEntry_Teleport *entry) { /** * Future Fun Land Teleport loop behaviour. * Triggers a warp to the space hub world when entered, if active. -*/ + */ void obj_loop_teleport(Object *obj, UNUSED s32 updateRate) { if (obj->properties.lighthouse.active) { LevelObjectEntry_Teleport *level_entry = &obj->segment.level_entry->teleport; @@ -2320,7 +2326,7 @@ void obj_loop_teleport(Object *obj, UNUSED s32 updateRate) { * Exit init behaviour. * Sets scale, rotation and hitbox from spawn info. * Also applies a face direction used to account for node rotation relative to the angle difference of the racer. -*/ + */ void obj_init_exit(Object *obj, LevelObjectEntry_Exit *entry) { f32 radius; Object_Exit *exit; @@ -2335,7 +2341,8 @@ void obj_init_exit(Object *obj, LevelObjectEntry_Exit *entry) { exit->directionX = sins_f(obj->segment.trans.y_rotation); exit->directionY = 0.0f; exit->directionZ = coss_f(obj->segment.trans.y_rotation); - exit->rotationDiff = -((exit->directionX * obj->segment.trans.x_position) + (exit->directionZ * obj->segment.trans.z_position)); + exit->rotationDiff = + -((exit->directionX * obj->segment.trans.x_position) + (exit->directionZ * obj->segment.trans.z_position)); exit->radius = entry->radius; exit->bossFlag = entry->bossFlag; obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; @@ -2346,8 +2353,9 @@ void obj_init_exit(Object *obj, LevelObjectEntry_Exit *entry) { /** * Exit loop behaviour. - * Waits for a racer to interact with it, then sets the exit ID for the racer, triggering a level transition on their end. -*/ + * Waits for a racer to interact with it, then sets the exit ID for the racer, triggering a level transition on their + * end. + */ void obj_loop_exit(Object *obj, UNUSED s32 updateRate) { Object *racerObj; Object_Racer *racer; @@ -2359,7 +2367,7 @@ void obj_loop_exit(Object *obj, UNUSED s32 updateRate) { f32 diffY; Object_Exit *exit; s32 enableWarp; - Object** racerObjects; + Object **racerObjects; s32 i; f32 rotDiff; @@ -2374,7 +2382,8 @@ void obj_loop_exit(Object *obj, UNUSED s32 updateRate) { if (exit->bossFlag == WARP_BOSS_REMATCH && settings->balloonsPtr[settings->worldId] < 8) { enableWarp = FALSE; } - // The above ensures only one of the boss warps is active so they don't overlap. This could also probably have been done in the initialiser. + // The above ensures only one of the boss warps is active so they don't overlap. This could also probably have been + // done in the initialiser. if (enableWarp && obj->interactObj->distance < exit->radius) { dist = exit->radius; racerObjects = get_racer_objects(&numberOfRacers); @@ -2386,7 +2395,8 @@ void obj_loop_exit(Object *obj, UNUSED s32 updateRate) { diffY = racerObj->segment.trans.y_position - obj->segment.trans.y_position; diffZ = racerObj->segment.trans.z_position - obj->segment.trans.z_position; if ((sqrtf((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)) < dist)) { - rotDiff = (exit->directionX * racerObj->segment.trans.x_position) + (exit->directionZ * racerObj->segment.trans.z_position) + exit->rotationDiff; + rotDiff = (exit->directionX * racerObj->segment.trans.x_position) + + (exit->directionZ * racerObj->segment.trans.z_position) + exit->rotationDiff; if (rotDiff < 0.0f) { racer->exitObj = obj; racer->transitionTimer = -120; @@ -2397,7 +2407,6 @@ void obj_loop_exit(Object *obj, UNUSED s32 updateRate) { } } - void obj_init_cameracontrol(Object *obj, LevelObjectEntry_CameraControl *entry) { obj->properties.common.unk0 = entry->unk8; func_80011390(); @@ -2418,7 +2427,7 @@ void obj_loop_setuppoint(UNUSED Object *obj, UNUSED s32 updateRate) { /** * Dinosaur init behaviour. * Walks around, playing footstep sounds and roaring when nearby. -*/ + */ void obj_init_dino_whale(Object *obj, UNUSED LevelObjectEntry_Dino_Whale *entry) { obj->interactObj->flags = INTERACT_FLAGS_SOLID; obj->interactObj->unk11 = 3; @@ -2429,7 +2438,7 @@ void obj_init_dino_whale(Object *obj, UNUSED LevelObjectEntry_Dino_Whale *entry) /** * Dinosaur loop behaviour. * Walks around, playing footstep sounds and roaring when nearby. -*/ + */ void obj_loop_dino_whale(Object *obj, s32 updateRate) { s32 animFrame; @@ -2445,7 +2454,8 @@ void obj_loop_dino_whale(Object *obj, s32 updateRate) { if (obj->interactObj->distance < 255) { if (obj->properties.common.unk0 == 0) { obj->properties.common.unk0 = 60; - play_sound_at_position(SOUND_VOICE_BRONTO_ROAR, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + play_sound_at_position(SOUND_VOICE_BRONTO_ROAR, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); } } } @@ -2453,7 +2463,7 @@ void obj_loop_dino_whale(Object *obj, s32 updateRate) { /** * Hub world Taj init behaviour. * Sets hitbox data to give him solidity. -*/ + */ void obj_init_parkwarden(Object *obj, UNUSED LevelObjectEntry_Parkwarden *entry) { Object_NPC *taj; obj->interactObj->flags = INTERACT_FLAGS_SOLID; @@ -2473,17 +2483,18 @@ void obj_init_parkwarden(Object *obj, UNUSED LevelObjectEntry_Parkwarden *entry) /** * Sets the sound ID of Taj's next voice line when spoken to. -*/ + */ void set_taj_voice_line(s16 soundID) { - //Set to SOUND_VOICE_TAJ_CHALLENGE_RACE in func_800CC7C + // Set to SOUND_VOICE_TAJ_CHALLENGE_RACE in func_800CC7C gTajSoundID = soundID; } /** * Hub world Taj loop behaviour. * Handles all the behaviour for the Taj NPC found in the overworld. - * This uses a state machine to handle whether to wander around, approach the player, change their vehicle and teleport away. -*/ + * This uses a state machine to handle whether to wander around, approach the player, change their vehicle and teleport + * away. + */ void obj_loop_parkwarden(Object *obj, s32 updateRate) { f32 updateRateF; f32 xPosDiff; @@ -2535,18 +2546,15 @@ void obj_loop_parkwarden(Object *obj, s32 updateRate) { } buttonsPressed = get_buttons_pressed_from_player(PLAYER_ONE); var_a2 = FALSE; - if ( - (obj->properties.npc.action == NULL) && - (distance < 300.0) && - ( - ((obj->interactObj->flags & INTERACT_FLAGS_PUSHING) && (racerObj == obj->interactObj->obj)) || - (buttonsPressed & Z_TRIG) - ) - ) { + if ((obj->properties.npc.action == NULL) && (distance < 300.0) && + (((obj->interactObj->flags & INTERACT_FLAGS_PUSHING) && (racerObj == obj->interactObj->obj)) || + (buttonsPressed & Z_TRIG))) { if (buttonsPressed & Z_TRIG) { play_char_horn_sound(racerObj, racer); } - arctan = arctan2_f(racerObj->segment.trans.x_position - obj->segment.trans.x_position, racerObj->segment.trans.z_position - obj->segment.trans.z_position) - (racerObj->segment.trans.y_rotation & 0xFFFF); + arctan = arctan2_f(racerObj->segment.trans.x_position - obj->segment.trans.x_position, + racerObj->segment.trans.z_position - obj->segment.trans.z_position) - + (racerObj->segment.trans.y_rotation & 0xFFFF); if (arctan > 0x8000) { arctan = -0xFFFF; } @@ -2559,7 +2567,8 @@ void obj_loop_parkwarden(Object *obj, s32 updateRate) { } } obj->interactObj->flags = INTERACT_FLAGS_SOLID; - if ((should_taj_teleport() || var_a2) && (obj->properties.npc.action == TAJ_MODE_ROAM || obj->properties.npc.action == TAJ_MODE_UNK1F)) { + if ((should_taj_teleport() || var_a2) && + (obj->properties.npc.action == TAJ_MODE_ROAM || obj->properties.npc.action == TAJ_MODE_UNK1F)) { music_channel_reset_all(); music_voicelimit_set(24); music_play(SEQUENCE_ENTRANCED); @@ -2568,14 +2577,13 @@ void obj_loop_parkwarden(Object *obj, s32 updateRate) { racer->vehicleSound = NULL; } func_80008140(); - arctan = arctan2_f( - racerObj->segment.trans.x_position - obj->segment.trans.x_position, - racerObj->segment.trans.z_position - obj->segment.trans.z_position - ); + arctan = arctan2_f(racerObj->segment.trans.x_position - obj->segment.trans.x_position, + racerObj->segment.trans.z_position - obj->segment.trans.z_position); arctan -= (racerObj->segment.trans.y_rotation & 0xFFFF); - if((arctan > 0x8000)) { + if ((arctan > 0x8000)) { // Probably had a debug statement here. - if ((obj->properties.npc.action) && (!obj->properties.npc.action) && (!obj->properties.npc.action)){} // Fakematch + if ((obj->properties.npc.action) && (!obj->properties.npc.action) && (!obj->properties.npc.action)) { + } // Fakematch } if (var_a2) { obj->properties.npc.action = TAJ_MODE_APPROACH_PLAYER; @@ -2588,10 +2596,11 @@ void obj_loop_parkwarden(Object *obj, s32 updateRate) { taj->animFrameF = 0.0f; } - if (!(obj->properties.npc.action == TAJ_MODE_ROAM || obj->properties.npc.action == TAJ_MODE_RACE || - obj->properties.npc.action == TAJ_MODE_TELEPORT_AWAY_BEGIN || obj->properties.npc.action == TAJ_MODE_TELEPORT_AWAY_END)) { - disable_racer_input(); - func_800AB194(3); + if (!(obj->properties.npc.action == TAJ_MODE_ROAM || obj->properties.npc.action == TAJ_MODE_RACE || + obj->properties.npc.action == TAJ_MODE_TELEPORT_AWAY_BEGIN || + obj->properties.npc.action == TAJ_MODE_TELEPORT_AWAY_END)) { + disable_racer_input(); + func_800AB194(3); } switch (obj->properties.npc.action) { @@ -2625,14 +2634,45 @@ void obj_loop_parkwarden(Object *obj, s32 updateRate) { obj->properties.npc.action = TAJ_MODE_DIALOGUE; } switch (obj->properties.npc.action) { - case TAJ_MODE_APPROACH_PLAYER: - obj->segment.object.animationID = 0; - taj->unkD = 0xFF; - if (distance < 100.0) { + case TAJ_MODE_APPROACH_PLAYER: + obj->segment.object.animationID = 0; + taj->unkD = 0xFF; + if (distance < 100.0) { + racer_set_dialogue_camera(); + } + if (distance > 10.0) { + arctan = + (arctan2_f(xPosDiff / distance, zPosDiff / distance) - (obj->segment.trans.y_rotation & 0xFFFF)) + + 0x8000; + if (arctan > 0x8000) { + arctan -= 0xFFFF; + } + if (arctan < -0x8000) { + arctan += 0xFFFF; + } + if (arctan > 0 && arctan < 16) { + arctan = 16; + } + obj->segment.trans.y_rotation += (arctan >> 4); + var_f2 = -2.0f; + if (arctan > 0x800 || arctan < -0x800) { + var_f2 = -0.5f; + } + taj->forwardVel += (var_f2 - taj->forwardVel) * 0.125; + obj->segment.x_velocity = sins_f(obj->segment.trans.y_rotation) * taj->forwardVel; + obj->segment.z_velocity = coss_f(obj->segment.trans.y_rotation) * taj->forwardVel; + taj->animFrameF -= taj->forwardVel * 2 * updateRateF; + } else { + obj->properties.npc.action = TAJ_MODE_TURN_TOWARDS_PLAYER; + } + move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, + obj->segment.z_velocity * updateRateF); + break; + case TAJ_MODE_TURN_TOWARDS_PLAYER: racer_set_dialogue_camera(); - } - if (distance > 10.0) { - arctan = (arctan2_f(xPosDiff / distance, zPosDiff / distance) - (obj->segment.trans.y_rotation & 0xFFFF)) + 0x8000; + obj->segment.object.animationID = 0; + taj->animFrameF += updateRateF * 2.0; + arctan = (racerObj->segment.trans.y_rotation - (obj->segment.trans.y_rotation & 0xFFFF)) + 0x8000; if (arctan > 0x8000) { arctan -= 0xFFFF; } @@ -2642,424 +2682,397 @@ void obj_loop_parkwarden(Object *obj, s32 updateRate) { if (arctan > 0 && arctan < 16) { arctan = 16; } - obj->segment.trans.y_rotation += (arctan >> 4); - var_f2 = -2.0f; - if (arctan > 0x800 || arctan < -0x800) { - var_f2 = -0.5f; - } - taj->forwardVel += (var_f2 - taj->forwardVel) * 0.125; - obj->segment.x_velocity = sins_f(obj->segment.trans.y_rotation) * taj->forwardVel; - obj->segment.z_velocity = coss_f(obj->segment.trans.y_rotation) * taj->forwardVel; - taj->animFrameF -= taj->forwardVel * 2 * updateRateF; - } else { - obj->properties.npc.action = TAJ_MODE_TURN_TOWARDS_PLAYER; - } - move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, obj->segment.z_velocity * updateRateF); - break; - case TAJ_MODE_TURN_TOWARDS_PLAYER: - racer_set_dialogue_camera(); - obj->segment.object.animationID = 0; - taj->animFrameF += updateRateF * 2.0; - arctan = (racerObj->segment.trans.y_rotation - (obj->segment.trans.y_rotation & 0xFFFF)) + 0x8000; - if (arctan > 0x8000) { - arctan -= 0xFFFF; - } - if (arctan < -0x8000) { - arctan += 0xFFFF; - } - if (arctan > 0 && arctan < 16) { - arctan = 16; - } - obj->segment.trans.y_rotation += arctan >> 3; - if (arctan < 0x400 && arctan > -0x400 && distance < 2.0) { - obj->properties.npc.action = TAJ_MODE_GREET_PLAYER; - taj->animFrameF = 0; - play_taj_voice_clip(gTajSoundID, TRUE); - gTajSoundID = SOUND_VOICE_TAJ_HELLO; - } - obj->segment.x_velocity = xPosDiff * 0.125; - obj->segment.y_velocity = 0; - obj->segment.z_velocity = zPosDiff * 0.125; - move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, obj->segment.z_velocity * updateRateF); - break; - case TAJ_MODE_GREET_PLAYER: - obj->segment.object.animationID = 1; - taj->forwardVel = 0.0f; - taj->animFrameF += updateRateF * 1.0; - if (taj->animFrameF > 77.0) { - taj->animFrameF = 77.0; - taj->unk18 = -1.0f; - obj->properties.npc.action = TAJ_MODE_DIALOGUE; - } - arctan = (racerObj->segment.trans.y_rotation - (obj->segment.trans.y_rotation & 0xFFFF)) + 0x8000; - if (arctan > 0x8000) { - arctan -= 0xFFFF; - } - if (arctan < -0x8000) { - arctan += 0xFFFF; - } - if (arctan > 0 && arctan < 16) { - arctan = 16; - } - obj->segment.trans.y_rotation = obj->segment.trans.y_rotation + (arctan >> 4); - racer_set_dialogue_camera(); - break; - case TAJ_MODE_DIALOGUE: - obj->segment.object.animationID = 4; - taj->animFrameF += updateRateF * 1.0; - racer_set_dialogue_camera(); - if (dialogueID == 3 || dialogueID == 4) { - obj->properties.npc.action = (dialogueID == 4) ? TAJ_MODE_END_DIALOGUE_UNUSED : TAJ_MODE_END_DIALOGUE; - taj->animFrameF = 0.1f; - obj->segment.object.animationID = 2; - taj->unk1C = 0; - play_taj_voice_clip(SOUND_VOICE_TAJ_BYE, TRUE); - slowly_change_fog(PLAYER_ONE, taj->fogR, taj->fogG, taj->fogB, taj->fogNear, taj->fogFar, 180); - music_voicelimit_set(levelHeader->voiceLimit); - music_play(levelHeader->music); - music_dynamic_set(levelHeader->instruments); - func_80008168(); - } - if (dialogueID & 0x80) { - gTajDialogueChoice = dialogueID & 0x7F; - if (gTajDialogueChoice != racer->vehicleID) { - obj->properties.npc.action = TAJ_MODE_TRANSFORM_BEGIN; + obj->segment.trans.y_rotation += arctan >> 3; + if (arctan < 0x400 && arctan > -0x400 && distance < 2.0) { + obj->properties.npc.action = TAJ_MODE_GREET_PLAYER; taj->animFrameF = 0; - // Voice clips: Abrakadabra, Alakazam, Alakazoom? - play_taj_voice_clip((racer->vehicleID + SOUND_VOICE_TAJ_ABRAKADABRA), TRUE); - } else { - set_menu_id_if_option_equal(0x62, 2); + play_taj_voice_clip(gTajSoundID, TRUE); + gTajSoundID = SOUND_VOICE_TAJ_HELLO; } - } - if (dialogueID & 0x40) { - gTajDialogueChoice = dialogueID & 0xF; - if (gTajDialogueChoice != racer->vehicleID) { - gTajDialogueChoice |= 0x80; - obj->properties.npc.action = TAJ_MODE_TRANSFORM_BEGIN; - taj->animFrameF = 0.0f; - // Voice clips: Abrakadabra, Alakazam, Alakazoom? - play_taj_voice_clip((racer->vehicleID + SOUND_VOICE_TAJ_ABRAKADABRA), TRUE); - } else { - obj->properties.npc.action = TAJ_MODE_SET_CHALLENGE; - transition_begin(&gTajTransition); - sp6B = 1; - play_taj_voice_clip(SOUND_WHOOSH4, TRUE); - taj->animFrameF = 0.0f; + obj->segment.x_velocity = xPosDiff * 0.125; + obj->segment.y_velocity = 0; + obj->segment.z_velocity = zPosDiff * 0.125; + move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, + obj->segment.z_velocity * updateRateF); + break; + case TAJ_MODE_GREET_PLAYER: + obj->segment.object.animationID = 1; + taj->forwardVel = 0.0f; + taj->animFrameF += updateRateF * 1.0; + if (taj->animFrameF > 77.0) { + taj->animFrameF = 77.0; + taj->unk18 = -1.0f; + obj->properties.npc.action = TAJ_MODE_DIALOGUE; } - } - break; - case TAJ_MODE_TRANSFORM_BEGIN: - obj->segment.object.animationID = 5; - racer_set_dialogue_camera(); - taj->animFrameF += updateRateF * 2.0; - if (taj->animFrameF > 25.0) { - obj->unk74 = 11; - } - if (taj->animFrameF > 50.0) { - obj->unk74 = 0; - } - if (taj->animFrameF > 60.0) { - taj->animFrameF = 60.0f; - if (racer->transparency > (updateRate * 16)) { - racer->transparency -= (updateRate * 16); - } else { - racer->transparency = 0; - despawn_player_racer(racerObj, gTajDialogueChoice & 0xF); - obj->properties.npc.action = TAJ_MODE_TRANSFORM_END; - sound_play(SOUND_CYMBAL, NULL); - transition_begin(&gTajTransformTransitionEnd); + arctan = (racerObj->segment.trans.y_rotation - (obj->segment.trans.y_rotation & 0xFFFF)) + 0x8000; + if (arctan > 0x8000) { + arctan -= 0xFFFF; } - } - break; - case TAJ_MODE_TRANSFORM_END: - racer_set_dialogue_camera(); - if (racerObj != NULL) { - if (taj->animFrameF != 0.0f) { - taj->animFrameF += 8.0; + if (arctan < -0x8000) { + arctan += 0xFFFF; } - var_a2 = updateRate; - if (var_a2 > 4) { - var_a2 = 4; + if (arctan > 0 && arctan < 16) { + arctan = 16; } - var_a2 <<= 5; - if (racer->transparency < (255 - (var_a2))) { - racer->transparency += var_a2; - } else { - racer->transparency = 255; - if (taj->animFrameF == 0.0) { - if (gTajDialogueChoice & 0x80) { - transition_begin(&gTajTransition); - sp6B = 1; - obj->properties.npc.action = TAJ_MODE_SET_CHALLENGE; - sound_play(SOUND_WHOOSH4, NULL); - taj->animFrameF = 0.0f; - } else { - obj->properties.npc.action = TAJ_MODE_DIALOGUE; - set_menu_id_if_option_equal(0x62, 2); + obj->segment.trans.y_rotation = obj->segment.trans.y_rotation + (arctan >> 4); + racer_set_dialogue_camera(); + break; + case TAJ_MODE_DIALOGUE: + obj->segment.object.animationID = 4; + taj->animFrameF += updateRateF * 1.0; + racer_set_dialogue_camera(); + if (dialogueID == 3 || dialogueID == 4) { + obj->properties.npc.action = (dialogueID == 4) ? TAJ_MODE_END_DIALOGUE_UNUSED : TAJ_MODE_END_DIALOGUE; + taj->animFrameF = 0.1f; + obj->segment.object.animationID = 2; + taj->unk1C = 0; + play_taj_voice_clip(SOUND_VOICE_TAJ_BYE, TRUE); + slowly_change_fog(PLAYER_ONE, taj->fogR, taj->fogG, taj->fogB, taj->fogNear, taj->fogFar, 180); + music_voicelimit_set(levelHeader->voiceLimit); + music_play(levelHeader->music); + music_dynamic_set(levelHeader->instruments); + func_80008168(); + } + if (dialogueID & 0x80) { + gTajDialogueChoice = dialogueID & 0x7F; + if (gTajDialogueChoice != racer->vehicleID) { + obj->properties.npc.action = TAJ_MODE_TRANSFORM_BEGIN; + taj->animFrameF = 0; + // Voice clips: Abrakadabra, Alakazam, Alakazoom? + play_taj_voice_clip((racer->vehicleID + SOUND_VOICE_TAJ_ABRAKADABRA), TRUE); + } else { + set_menu_id_if_option_equal(0x62, 2); + } + } + if (dialogueID & 0x40) { + gTajDialogueChoice = dialogueID & 0xF; + if (gTajDialogueChoice != racer->vehicleID) { + gTajDialogueChoice |= 0x80; + obj->properties.npc.action = TAJ_MODE_TRANSFORM_BEGIN; + taj->animFrameF = 0.0f; + // Voice clips: Abrakadabra, Alakazam, Alakazoom? + play_taj_voice_clip((racer->vehicleID + SOUND_VOICE_TAJ_ABRAKADABRA), TRUE); + } else { + obj->properties.npc.action = TAJ_MODE_SET_CHALLENGE; + transition_begin(&gTajTransition); + sp6B = 1; + play_taj_voice_clip(SOUND_WHOOSH4, TRUE); + taj->animFrameF = 0.0f; + } + } + break; + case TAJ_MODE_TRANSFORM_BEGIN: + obj->segment.object.animationID = 5; + racer_set_dialogue_camera(); + taj->animFrameF += updateRateF * 2.0; + if (taj->animFrameF > 25.0) { + obj->unk74 = 11; + } + if (taj->animFrameF > 50.0) { + obj->unk74 = 0; + } + if (taj->animFrameF > 60.0) { + taj->animFrameF = 60.0f; + if (racer->transparency > (updateRate * 16)) { + racer->transparency -= (updateRate * 16); + } else { + racer->transparency = 0; + despawn_player_racer(racerObj, gTajDialogueChoice & 0xF); + obj->properties.npc.action = TAJ_MODE_TRANSFORM_END; + sound_play(SOUND_CYMBAL, NULL); + transition_begin(&gTajTransformTransitionEnd); + } + } + break; + case TAJ_MODE_TRANSFORM_END: + racer_set_dialogue_camera(); + if (racerObj != NULL) { + if (taj->animFrameF != 0.0f) { + taj->animFrameF += 8.0; + } + var_a2 = updateRate; + if (var_a2 > 4) { + var_a2 = 4; + } + var_a2 <<= 5; + if (racer->transparency < (255 - (var_a2))) { + racer->transparency += var_a2; + } else { + racer->transparency = 255; + if (taj->animFrameF == 0.0) { + if (gTajDialogueChoice & 0x80) { + transition_begin(&gTajTransition); + sp6B = 1; + obj->properties.npc.action = TAJ_MODE_SET_CHALLENGE; + sound_play(SOUND_WHOOSH4, NULL); + taj->animFrameF = 0.0f; + } else { + obj->properties.npc.action = TAJ_MODE_DIALOGUE; + set_menu_id_if_option_equal(0x62, 2); + } } } } - } - break; - case TAJ_MODE_END_DIALOGUE: - case TAJ_MODE_END_DIALOGUE_UNUSED: - if (taj->animFrameF != 0.0) { - taj->animFrameF = taj->animFrameF + (0.5 * updateRateF); - } - if (taj->animFrameF == 0) { - sp6B = 1; - if (obj->properties.npc.action == TAJ_MODE_END_DIALOGUE_UNUSED) { - func_80022CFC( - obj->segment.object.segmentID, - obj->segment.trans.x_position - (racer->ox1 * 50.0f), - obj->segment.trans.y_position, - obj->segment.trans.z_position - (racer->oz1 * 50.0f) - ); + break; + case TAJ_MODE_END_DIALOGUE: + case TAJ_MODE_END_DIALOGUE_UNUSED: + if (taj->animFrameF != 0.0) { + taj->animFrameF = taj->animFrameF + (0.5 * updateRateF); + } + if (taj->animFrameF == 0) { + sp6B = 1; + if (obj->properties.npc.action == TAJ_MODE_END_DIALOGUE_UNUSED) { + func_80022CFC(obj->segment.object.segmentID, obj->segment.trans.x_position - (racer->ox1 * 50.0f), + obj->segment.trans.y_position, obj->segment.trans.z_position - (racer->oz1 * 50.0f)); + } + obj->properties.npc.action = TAJ_MODE_TELEPORT_AWAY_BEGIN; + sound_play(SOUND_WHOOSH4, NULL); + racer->vehicleSound = func_80004B40(racer->characterId, racer->vehicleID); + } + break; + case TAJ_MODE_TELEPORT_TO_PLAYER_BEGIN: + obj->segment.object.animationID = 3; + taj->unkD = 0xFF; + taj->forwardVel = 0.0f; + taj->animFrameF += updateRateF * 2.0; + if (taj->animFrameF > 79.0f) { + taj->animFrameF = 79.0f; } - obj->properties.npc.action = TAJ_MODE_TELEPORT_AWAY_BEGIN; - sound_play(SOUND_WHOOSH4, NULL); - racer->vehicleSound = func_80004B40(racer->characterId, racer->vehicleID); - } - break; - case TAJ_MODE_TELEPORT_TO_PLAYER_BEGIN: - obj->segment.object.animationID = 3; - taj->unkD = 0xFF; - taj->forwardVel = 0.0f; - taj->animFrameF += updateRateF * 2.0; - if (taj->animFrameF > 79.0f) { - taj->animFrameF = 79.0f; - } - var_a2 = updateRate * 8; - if (taj->animFrameF < 20.0f) { - var_a2 = 0; - } - if (obj->segment.object.opacity > var_a2) { - obj->segment.object.opacity -= var_a2; - } else { - sound_play(SOUND_WHOOSH4, NULL); - sp6B = 1; - obj->segment.object.opacity = 0; - obj->properties.npc.action = TAJ_MODE_TELEPORT_TO_PLAYER_END; - obj->segment.trans.x_position = racerObj->segment.trans.x_position - (racer->ox1 * 150.0f); - obj->segment.trans.z_position = racerObj->segment.trans.z_position - (racer->oz1 * 150.0f); - obj->segment.object.segmentID = get_level_segment_index_from_position(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); - obj->segment.trans.y_rotation = racerObj->segment.trans.y_rotation + 0x8000; - } - break; - case TAJ_MODE_TELEPORT_TO_PLAYER_END: - obj->segment.object.animationID = 3; - taj->animFrameF -= updateRateF * 2.0; - if (taj->animFrameF < 0.0f) { - taj->animFrameF = 0.0f; - } - var_a2 = updateRate * 4; - if (obj->segment.object.opacity < (255 - var_a2)) { - obj->segment.object.opacity += var_a2; - } else { - obj->segment.object.opacity = 255; - obj->properties.npc.action = TAJ_MODE_APPROACH_PLAYER; - } - break; - case TAJ_MODE_SET_CHALLENGE: - obj->segment.object.animationID = 3; - taj->unkD = 0xFF; - taj->forwardVel = 0.0f; - taj->animFrameF += updateRateF * 2.0; - if (taj->animFrameF > 79.0f) { - taj->animFrameF = 79.0f; - } - var_a2 = updateRate * 8; - if (taj->animFrameF < 20.0f) { - var_a2 = 0; - } - if (obj->segment.object.opacity > var_a2) { - obj->segment.object.opacity -= var_a2; - } else { - racer->vehicleSound = func_80004B40(racer->characterId, racer->vehicleID); - slowly_change_fog(PLAYER_ONE, taj->fogR, taj->fogG, taj->fogB, taj->fogNear, taj->fogFar, 180); - music_voicelimit_set(levelHeader->voiceLimit); - music_play(levelHeader->music); - music_dynamic_set(levelHeader->instruments); - init_racer_for_challenge(racer->vehicleID); - telepoint = find_furthest_telepoint(obj->segment.trans.x_position, obj->segment.trans.z_position); - if (telepoint != NULL) { - obj->segment.trans.x_position = telepoint->segment.trans.x_position; - obj->segment.trans.z_position = telepoint->segment.trans.z_position; - obj->segment.object.segmentID = telepoint->segment.object.segmentID; + var_a2 = updateRate * 8; + if (taj->animFrameF < 20.0f) { + var_a2 = 0; + } + if (obj->segment.object.opacity > var_a2) { + obj->segment.object.opacity -= var_a2; + } else { + sound_play(SOUND_WHOOSH4, NULL); + sp6B = 1; + obj->segment.object.opacity = 0; + obj->properties.npc.action = TAJ_MODE_TELEPORT_TO_PLAYER_END; + obj->segment.trans.x_position = racerObj->segment.trans.x_position - (racer->ox1 * 150.0f); + obj->segment.trans.z_position = racerObj->segment.trans.z_position - (racer->oz1 * 150.0f); + obj->segment.object.segmentID = get_level_segment_index_from_position( + obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); obj->segment.trans.y_rotation = racerObj->segment.trans.y_rotation + 0x8000; } - obj->properties.npc.action = TAJ_MODE_RACE; - } - break; - case TAJ_MODE_TELEPORT_AWAY_BEGIN: - obj->segment.object.animationID = 3; - taj->unkD = 0xFF; - taj->forwardVel = 0.0f; - taj->animFrameF += updateRateF * 2.0; - if (taj->animFrameF > 79.0f) { - taj->animFrameF = 79.0f; - } - var_a2 = updateRate * 8; - if (taj->animFrameF < 20.0f) { - var_a2 = 0; - } - if (obj->segment.object.opacity > var_a2) { - obj->segment.object.opacity -= var_a2; - } else { - obj->segment.object.opacity = 0; - obj->properties.npc.action = TAJ_MODE_TELEPORT_AWAY_END; - telepoint = find_furthest_telepoint(obj->segment.trans.x_position, obj->segment.trans.z_position); - if (telepoint != NULL) { - obj->segment.trans.x_position = telepoint->segment.trans.x_position; - obj->segment.trans.z_position = telepoint->segment.trans.z_position; - obj->segment.object.segmentID = telepoint->segment.object.segmentID; - obj->segment.trans.y_rotation = racerObj->segment.trans.y_rotation + 0x8000; + break; + case TAJ_MODE_TELEPORT_TO_PLAYER_END: + obj->segment.object.animationID = 3; + taj->animFrameF -= updateRateF * 2.0; + if (taj->animFrameF < 0.0f) { + taj->animFrameF = 0.0f; } - } - break; - case TAJ_MODE_TELEPORT_AWAY_END: - obj->segment.object.animationID = 3; - taj->animFrameF -= updateRateF * 2.0; - if (taj->animFrameF < 0.0f) { - taj->animFrameF = 0.0f; - } - var_a2 = updateRate * 4; - if (obj->segment.object.opacity < (255 - var_a2)) { - obj->segment.object.opacity += var_a2; - } else { + var_a2 = updateRate * 4; + if (obj->segment.object.opacity < (255 - var_a2)) { + obj->segment.object.opacity += var_a2; + } else { + obj->segment.object.opacity = 255; + obj->properties.npc.action = TAJ_MODE_APPROACH_PLAYER; + } + break; + case TAJ_MODE_SET_CHALLENGE: + obj->segment.object.animationID = 3; + taj->unkD = 0xFF; + taj->forwardVel = 0.0f; + taj->animFrameF += updateRateF * 2.0; + if (taj->animFrameF > 79.0f) { + taj->animFrameF = 79.0f; + } + var_a2 = updateRate * 8; + if (taj->animFrameF < 20.0f) { + var_a2 = 0; + } + if (obj->segment.object.opacity > var_a2) { + obj->segment.object.opacity -= var_a2; + } else { + racer->vehicleSound = func_80004B40(racer->characterId, racer->vehicleID); + slowly_change_fog(PLAYER_ONE, taj->fogR, taj->fogG, taj->fogB, taj->fogNear, taj->fogFar, 180); + music_voicelimit_set(levelHeader->voiceLimit); + music_play(levelHeader->music); + music_dynamic_set(levelHeader->instruments); + init_racer_for_challenge(racer->vehicleID); + telepoint = find_furthest_telepoint(obj->segment.trans.x_position, obj->segment.trans.z_position); + if (telepoint != NULL) { + obj->segment.trans.x_position = telepoint->segment.trans.x_position; + obj->segment.trans.z_position = telepoint->segment.trans.z_position; + obj->segment.object.segmentID = telepoint->segment.object.segmentID; + obj->segment.trans.y_rotation = racerObj->segment.trans.y_rotation + 0x8000; + } + obj->properties.npc.action = TAJ_MODE_RACE; + } + break; + case TAJ_MODE_TELEPORT_AWAY_BEGIN: + obj->segment.object.animationID = 3; + taj->unkD = 0xFF; + taj->forwardVel = 0.0f; + taj->animFrameF += updateRateF * 2.0; + if (taj->animFrameF > 79.0f) { + taj->animFrameF = 79.0f; + } + var_a2 = updateRate * 8; + if (taj->animFrameF < 20.0f) { + var_a2 = 0; + } + if (obj->segment.object.opacity > var_a2) { + obj->segment.object.opacity -= var_a2; + } else { + obj->segment.object.opacity = 0; + obj->properties.npc.action = TAJ_MODE_TELEPORT_AWAY_END; + telepoint = find_furthest_telepoint(obj->segment.trans.x_position, obj->segment.trans.z_position); + if (telepoint != NULL) { + obj->segment.trans.x_position = telepoint->segment.trans.x_position; + obj->segment.trans.z_position = telepoint->segment.trans.z_position; + obj->segment.object.segmentID = telepoint->segment.object.segmentID; + obj->segment.trans.y_rotation = racerObj->segment.trans.y_rotation + 0x8000; + } + } + break; + case TAJ_MODE_TELEPORT_AWAY_END: + obj->segment.object.animationID = 3; + taj->animFrameF -= updateRateF * 2.0; + if (taj->animFrameF < 0.0f) { + taj->animFrameF = 0.0f; + } + var_a2 = updateRate * 4; + if (obj->segment.object.opacity < (255 - var_a2)) { + obj->segment.object.opacity += var_a2; + } else { + obj->segment.object.opacity = 255; + obj->properties.npc.action = TAJ_MODE_ROAM; + } + break; + case TAJ_MODE_RACE: + obj->interactObj->flags = INTERACT_FLAGS_NONE; + obj->segment.object.animationID = 6; obj->segment.object.opacity = 255; - obj->properties.npc.action = TAJ_MODE_ROAM; - } - break; - case TAJ_MODE_RACE: - obj->interactObj->flags = INTERACT_FLAGS_NONE; - obj->segment.object.animationID = 6; - obj->segment.object.opacity = 255; - taj->animFrameF += updateRateF * 1.0; - break; - default: - obj->segment.object.animationID = 0; - taj->forwardVel = 0.0f; - if (taj->unkD == 0xFF) { - taj->unkD = func_8001C524(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 0); - if (taj->unkD != 0xFF) { - taj->unkE = func_8001CC48(taj->unkD, -1, 0); - taj->unkF = func_8001CC48(taj->unkE, taj->unkD, 0); - taj->unk10 = func_8001CC48(taj->unkF, taj->unkE, 0); - taj->unkC = taj->unkD; - } - } else { - if ((distance < 55.0f) && (taj->unk1C == 0) && (racerObj != NULL)) { - taj->unk1C = 240; - taj->unk1E = (s16) (arctan2_f(xPosDiff / distance, zPosDiff / distance) + 0x4000); - } - if (taj->unk1C > 0) { - taj->unk1C -= updateRate; - } else { - taj->unk1C = 0; - } - if (taj->unk1C < 120) { - taj->animFrameF += func_8001C6C4((Object_64*)taj, obj, updateRateF, 1.0f, 0); - } else { - var_a2 = taj->unk1E - (obj->segment.trans.y_rotation & 0xFFFF); - if (var_a2 > 0x8000) { - var_a2 -= 0xFFFF; - } - if (var_a2 < -0x8000) { - var_a2 += 0xFFFF; - } - obj->segment.trans.y_rotation += ((var_a2 * updateRate) >> 4); - xPosDiff = sins_f(obj->segment.trans.y_rotation + 0x8000); - zPosDiff = coss_f(obj->segment.trans.y_rotation + 0x8000); - move_object(obj, (updateRateF2 * xPosDiff) * 1.1, 0.0f, (updateRateF2 * zPosDiff) * 1.1); - taj->animFrameF += updateRate * 2.2; - } - } - racerObjs = get_racer_objects(&numRacers); - if (racerObjs[PLAYER_ONE] != NULL) { - xPosDiff = racerObjs[PLAYER_ONE]->segment.trans.x_position - obj->segment.trans.x_position; - distance = racerObjs[PLAYER_ONE]->segment.trans.y_position - obj->segment.trans.y_position; - zPosDiff = racerObjs[PLAYER_ONE]->segment.trans.z_position - obj->segment.trans.z_position; - var_f2 = sqrtf((xPosDiff * xPosDiff) + (distance * distance) + (zPosDiff * zPosDiff)); - if (var_f2 < 1000.0f) { - var_f2 = 1000.0f - var_f2; - sp3C = (127.0f * var_f2) / 1000.0f; - temp_v0_22 = get_cutscene_camera_segment(); - xPosDiff = obj->segment.trans.x_position - temp_v0_22->trans.x_position; - zPosDiff = obj->segment.trans.z_position - temp_v0_22->trans.z_position; - arctan = func_800090C0(xPosDiff, zPosDiff, temp_v0_22->trans.y_rotation); - temp = arctan; - music_channel_fade_set(10, sp3C); - music_channel_fade_set(11, sp3C); - music_channel_fade_set(15, sp3C); - music_channel_pan_set(10, temp); - music_channel_pan_set(11, temp); - music_channel_pan_set(15, temp); - music_channel_on(10); - music_channel_on(11); - music_channel_on(15); - music_channel_fade_set(3, 127 - sp3C); - } else { - music_channel_off(10); - music_channel_off(11); - music_channel_off(15); - } - } - switch (taj->unk36) { - case 0: - if (taj->musicFade > updateRate << 7) { - taj->musicFade -= updateRate << 7; - music_channel_on(14); - music_channel_fade_set(14, taj->musicFade >> 8); - taj->unk30 = 0; - } else { - taj->musicFade = 0; - music_channel_off(14); - if (taj->unk30 == 0) { - taj->unk30 = get_random_number_from_range(600, 900); - taj->unk2C = 0; - } - } - if ((taj->unk30 != 0) && ((music_channel_get_mask() & ~0x4000) == 0xB)) { - taj->unk2C += updateRate; - if (taj->unk30 < taj->unk2C) { - taj->unk36 = 1; - taj->unk2C = get_random_number_from_range(600, 900); - } - } else { - taj->unk2C = 0; - taj->unk30 = 0; - } + taj->animFrameF += updateRateF * 1.0; break; - case 1: - if ((music_channel_get_mask() & ~0x4000) == 0xB) { - taj->musicFade += (updateRate * 128); - if (taj->musicFade > 0x7F00) { - taj->musicFade = 0x7F00; + default: + obj->segment.object.animationID = 0; + taj->forwardVel = 0.0f; + if (taj->unkD == 0xFF) { + taj->unkD = func_8001C524(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 0); + if (taj->unkD != 0xFF) { + taj->unkE = func_8001CC48(taj->unkD, -1, 0); + taj->unkF = func_8001CC48(taj->unkE, taj->unkD, 0); + taj->unk10 = func_8001CC48(taj->unkF, taj->unkE, 0); + taj->unkC = taj->unkD; } - taj->unk2C -= updateRate; - if (taj->unk2C < 0) { - taj->unk36 = 0; - } - music_channel_on(14); - music_channel_fade_set(14, taj->musicFade >> 8); } else { - taj->unk36 = 0; - taj->unk2C = 0; - taj->unk30 = 0; + if ((distance < 55.0f) && (taj->unk1C == 0) && (racerObj != NULL)) { + taj->unk1C = 240; + taj->unk1E = (s16) (arctan2_f(xPosDiff / distance, zPosDiff / distance) + 0x4000); + } + if (taj->unk1C > 0) { + taj->unk1C -= updateRate; + } else { + taj->unk1C = 0; + } + if (taj->unk1C < 120) { + taj->animFrameF += func_8001C6C4((Object_64 *) taj, obj, updateRateF, 1.0f, 0); + } else { + var_a2 = taj->unk1E - (obj->segment.trans.y_rotation & 0xFFFF); + if (var_a2 > 0x8000) { + var_a2 -= 0xFFFF; + } + if (var_a2 < -0x8000) { + var_a2 += 0xFFFF; + } + obj->segment.trans.y_rotation += ((var_a2 * updateRate) >> 4); + xPosDiff = sins_f(obj->segment.trans.y_rotation + 0x8000); + zPosDiff = coss_f(obj->segment.trans.y_rotation + 0x8000); + move_object(obj, (updateRateF2 * xPosDiff) * 1.1, 0.0f, (updateRateF2 * zPosDiff) * 1.1); + taj->animFrameF += updateRate * 2.2; + } } + racerObjs = get_racer_objects(&numRacers); + if (racerObjs[PLAYER_ONE] != NULL) { + xPosDiff = racerObjs[PLAYER_ONE]->segment.trans.x_position - obj->segment.trans.x_position; + distance = racerObjs[PLAYER_ONE]->segment.trans.y_position - obj->segment.trans.y_position; + zPosDiff = racerObjs[PLAYER_ONE]->segment.trans.z_position - obj->segment.trans.z_position; + var_f2 = sqrtf((xPosDiff * xPosDiff) + (distance * distance) + (zPosDiff * zPosDiff)); + if (var_f2 < 1000.0f) { + var_f2 = 1000.0f - var_f2; + sp3C = (127.0f * var_f2) / 1000.0f; + temp_v0_22 = get_cutscene_camera_segment(); + xPosDiff = obj->segment.trans.x_position - temp_v0_22->trans.x_position; + zPosDiff = obj->segment.trans.z_position - temp_v0_22->trans.z_position; + arctan = func_800090C0(xPosDiff, zPosDiff, temp_v0_22->trans.y_rotation); + temp = arctan; + music_channel_fade_set(10, sp3C); + music_channel_fade_set(11, sp3C); + music_channel_fade_set(15, sp3C); + music_channel_pan_set(10, temp); + music_channel_pan_set(11, temp); + music_channel_pan_set(15, temp); + music_channel_on(10); + music_channel_on(11); + music_channel_on(15); + music_channel_fade_set(3, 127 - sp3C); + } else { + music_channel_off(10); + music_channel_off(11); + music_channel_off(15); + } + } + switch (taj->unk36) { + case 0: + if (taj->musicFade > updateRate << 7) { + taj->musicFade -= updateRate << 7; + music_channel_on(14); + music_channel_fade_set(14, taj->musicFade >> 8); + taj->unk30 = 0; + } else { + taj->musicFade = 0; + music_channel_off(14); + if (taj->unk30 == 0) { + taj->unk30 = get_random_number_from_range(600, 900); + taj->unk2C = 0; + } + } + if ((taj->unk30 != 0) && ((music_channel_get_mask() & ~0x4000) == 0xB)) { + taj->unk2C += updateRate; + if (taj->unk30 < taj->unk2C) { + taj->unk36 = 1; + taj->unk2C = get_random_number_from_range(600, 900); + } + } else { + taj->unk2C = 0; + taj->unk30 = 0; + } + break; + case 1: + if ((music_channel_get_mask() & ~0x4000) == 0xB) { + taj->musicFade += (updateRate * 128); + if (taj->musicFade > 0x7F00) { + taj->musicFade = 0x7F00; + } + taj->unk2C -= updateRate; + if (taj->unk2C < 0) { + taj->unk36 = 0; + } + music_channel_on(14); + music_channel_fade_set(14, taj->musicFade >> 8); + } else { + taj->unk36 = 0; + taj->unk2C = 0; + taj->unk30 = 0; + } + break; + } + taj->unk28 = music_channel_get_mask() & 0xBFFF; break; - } - taj->unk28 = music_channel_get_mask() & 0xBFFF; - break; } obj->segment.trans.y_position = tempPosY; - var_a2 = func_8002B0F4(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position, &water); - if(var_a2 != 0) { + var_a2 = func_8002B0F4(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position, + &water); + if (var_a2 != 0) { var_a2--; - while(var_a2 >= 0) { - if ((water[var_a2]->type != WATER_CALM) && (water[var_a2]->type != WATER_WAVY) && (water[var_a2]->rotY > 0.0)) { + while (var_a2 >= 0) { + if ((water[var_a2]->type != WATER_CALM) && (water[var_a2]->type != WATER_WAVY) && + (water[var_a2]->rotY > 0.0)) { obj->segment.trans.y_position = water[var_a2]->waveHeight; } var_a2--; @@ -3071,7 +3084,8 @@ void obj_loop_parkwarden(Object *obj, s32 updateRate) { gNPCPosY = obj->segment.trans.y_position; } if (sp6B != 0) { - func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, BHV_DINO_WHALE, SOUND_NONE, 1.0f, 0); + func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, + BHV_DINO_WHALE, SOUND_NONE, 1.0f, 0); } obj->segment.animFrame = taj->animFrameF * 1.0; func_80061C0C(obj); @@ -3097,7 +3111,7 @@ void obj_loop_gbparkwarden(UNUSED Object *obj, UNUSED s32 updateRate) { /** * Return the Y pos of an NPC when they're in dialogue. -*/ + */ f32 get_npc_pos_y(void) { return gNPCPosY; } @@ -3106,7 +3120,7 @@ f32 get_npc_pos_y(void) { * Checkpoint initialisation function. * Sets direction and scale based off spawn info. * Uses bit shifting to convert a u8 angle to an s16 angle. -*/ + */ void obj_init_checkpoint(Object *obj, LevelObjectEntry_Checkpoint *entry, UNUSED s32 arg2) { f32 scale = (s32) (entry->scale & 0xFF); if (scale < 5.0f) { @@ -3121,14 +3135,14 @@ void obj_init_checkpoint(Object *obj, LevelObjectEntry_Checkpoint *entry, UNUSED /** * Checkpoint initialisation function. * Does nothing, since the racers themselves iterate checkpoints and use their data. -*/ + */ void obj_loop_checkpoint(UNUSED Object *obj, UNUSED s32 updateRate) { } /** * Vehicle mode changer initialisation function. * Sets direction and vehicleID based off spawn info. -*/ + */ void obj_init_modechange(Object *obj, LevelObjectEntry_ModeChange *entry) { f32 radius; Object_Trigger *obj64; @@ -3143,7 +3157,8 @@ void obj_init_modechange(Object *obj, LevelObjectEntry_ModeChange *entry) { obj64->directionX = sins_f(obj->segment.trans.y_rotation); obj64->directionY = 0.0f; obj64->directionZ = coss_f(obj->segment.trans.y_rotation); - obj64->rotationDiff = -((obj64->directionX * obj->segment.trans.x_position) + (obj64->directionZ * obj->segment.trans.z_position)); + obj64->rotationDiff = + -((obj64->directionX * obj->segment.trans.x_position) + (obj64->directionZ * obj->segment.trans.z_position)); obj64->radius = entry->radius; obj64->vehicleID = entry->vehicleID; obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; @@ -3155,7 +3170,7 @@ void obj_init_modechange(Object *obj, LevelObjectEntry_ModeChange *entry) { /** * Vehicle mode changer loop behaviour. * Racers that pass through will have their vehicle type changed. This is usually used for loop-de-loops. -*/ + */ void obj_loop_modechange(Object *obj, UNUSED s32 updateRate) { Object *racerObj; Object **racerObjects; @@ -3169,7 +3184,7 @@ void obj_loop_modechange(Object *obj, UNUSED s32 updateRate) { s32 i; f32 radiusF; f32 dist; - + modeChange = (Object_Trigger *) obj->unk64; if (obj->interactObj->distance < modeChange->radius) { radiusF = modeChange->radius; @@ -3183,7 +3198,8 @@ void obj_loop_modechange(Object *obj, UNUSED s32 updateRate) { diffZ = racerObj->segment.trans.z_position - obj->segment.trans.z_position; dist = sqrtf((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)); if (dist < radiusF) { - dist = ((modeChange->directionX * racerObj->segment.trans.x_position) + (modeChange->directionZ * racerObj->segment.trans.z_position) + modeChange->rotationDiff); + dist = ((modeChange->directionX * racerObj->segment.trans.x_position) + + (modeChange->directionZ * racerObj->segment.trans.z_position) + modeChange->rotationDiff); if (dist < 0.0f) { racer->unk1E0 = 0; if (modeChange->vehicleID == VEHICLE_CAR) { @@ -3195,7 +3211,9 @@ void obj_loop_modechange(Object *obj, UNUSED s32 updateRate) { if (racer->raceFinished == FALSE) { func_80072348(racer->playerIndex, 8); } - radius_3 = func_8001C524(racerObj->segment.trans.x_position, racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, 0); + radius_3 = + func_8001C524(racerObj->segment.trans.x_position, racerObj->segment.trans.y_position, + racerObj->segment.trans.z_position, 0); if (radius_3 != 0xFF) { racer->unk158 = func_8001D214(radius_3); } else { @@ -3210,10 +3228,8 @@ void obj_loop_modechange(Object *obj, UNUSED s32 updateRate) { } } } - } - void obj_init_bonus(Object *obj, LevelObjectEntry_Bonus *entry) { f32 radius; Object_Trigger *bonus; @@ -3228,7 +3244,8 @@ void obj_init_bonus(Object *obj, LevelObjectEntry_Bonus *entry) { bonus->directionX = sins_f(obj->segment.trans.y_rotation); bonus->directionY = 0.0f; bonus->directionZ = coss_f(obj->segment.trans.y_rotation); - bonus->rotationDiff = -((bonus->directionX * obj->segment.trans.x_position) + (bonus->directionZ * obj->segment.trans.z_position)); + bonus->rotationDiff = + -((bonus->directionX * obj->segment.trans.x_position) + (bonus->directionZ * obj->segment.trans.z_position)); bonus->radius = entry->radius; bonus->unk14 = entry->unkA; // Unused? obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; @@ -3263,12 +3280,17 @@ void obj_loop_bonus(Object *obj, UNUSED s32 updateRate) { diffX = racerObj->segment.trans.x_position - obj->segment.trans.x_position; diffZ = racerObj->segment.trans.z_position - obj->segment.trans.z_position; if (sqrtf((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)) < dist) { - f32 temp = (obj64->directionX * racerObj->segment.trans.x_position) + (obj64->directionZ * racerObj->segment.trans.z_position) + obj64->rotationDiff; + f32 temp = (obj64->directionX * racerObj->segment.trans.x_position) + + (obj64->directionZ * racerObj->segment.trans.z_position) + obj64->rotationDiff; if (temp < 0.0f) { if (racer->bananas < 10) { racer->bananas = 10; - play_sound_at_position(SOUND_SELECT, racerObj->segment.trans.x_position, racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, 4, NULL); - sound_play_spatial(racer->characterId + SOUND_UNK_7B, racerObj->segment.trans.x_position, racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, NULL); + play_sound_at_position(SOUND_SELECT, racerObj->segment.trans.x_position, + racerObj->segment.trans.y_position, + racerObj->segment.trans.z_position, 4, NULL); + sound_play_spatial(racer->characterId + SOUND_UNK_7B, racerObj->segment.trans.x_position, + racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, + NULL); } } } @@ -3363,13 +3385,14 @@ void obj_loop_goldenballoon(Object *obj, s32 updateRate) { racer = &racerObj->unk64->racer; if (racer->playerIndex == PLAYER_ONE) { settings->balloonsPtr[settings->worldId]++; - if(isPirated == 1) { } // Fakematch + if (isPirated == 1) {} // Fakematch if (settings->worldId != 0) { settings->balloonsPtr[0]++; } settings->courseFlagsPtr[settings->courseId] |= flag; if (1) {} // Fakematch - sound_play_spatial(SOUND_COLLECT_BALLOON, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, NULL); + sound_play_spatial(SOUND_COLLECT_BALLOON, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, NULL); obj->properties.npc.timer = 16; obj->unk74 = 2; obj->segment.trans.flags |= OBJ_FLAGS_INVISIBLE; @@ -3382,7 +3405,8 @@ void obj_loop_goldenballoon(Object *obj, s32 updateRate) { obj64->forwardVel = 0.0f; speedf = (obj->segment.object.opacity < 255) ? 0 : 1; if (obj64->unkD == 255) { - obj64->unkD = func_8001C524(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 0); + obj64->unkD = func_8001C524(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 0); if (obj64->unkD != 255) { obj64->unkE = func_8001CC48(obj64->unkD, -1, 0); obj64->unkF = func_8001CC48(obj64->unkE, obj64->unkD, 0); @@ -3443,7 +3467,7 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { volatile s32 sp54; // ??? s32 sp50; s32 sp4C; - Object_Racer *racer; + Object_Racer *racer; Object_Door *door; Settings *settings; Object *racerObj; @@ -3452,9 +3476,9 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { f32 updateRateF; UNUSED s32 pad; s32 sp28; - + doorEntry = &doorObj->segment.level_entry->door; - updateRateF = updateRate; + updateRateF = updateRate; if (osTvType == TV_TYPE_PAL) { updateRateF *= 1.2; } @@ -3462,10 +3486,10 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { temp2 = settings->courseFlagsPtr[settings->courseId]; door = &doorObj->unk64->door; if (door->unkE >= 0) { - sp54 = 0x10000 << door->unkE; + sp54 = 0x10000 << door->unkE; racerObjInter = doorObj->interactObj; sp50 = racerObjInter->distance; - if (!(door->unkF & 1)) { + if (!(door->unkF & 1)) { sp50 = 0; } sp28 = temp2 & sp54; @@ -3491,14 +3515,14 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { } } if (door->unk8 != 0 && music_jingle_playing() == SEQUENCE_NONE) { - if (updateRate < door->unk8) { - door->unk8 -= updateRate; - } else { - door->unk8 = 0; - music_fade(8); - music_jingle_voicelimit_set(6); - func_80008168(); - } + if (updateRate < door->unk8) { + door->unk8 -= updateRate; + } else { + door->unk8 = 0; + music_fade(8); + music_jingle_voicelimit_set(6); + func_80008168(); + } } if (door->unkA > 0) { door->unkA -= updateRate; @@ -3511,7 +3535,7 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { racerObj = racerObjInter->obj; if (racerObj != NULL && racerObj->segment.header->behaviorId == BHV_RACER) { racer = &racerObj->unk64->racer; - switch (racer->vehicleID) { + switch (racer->vehicleID) { case VEHICLE_HOVERCRAFT: sp4C = 2; break; @@ -3519,7 +3543,7 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { sp4C = 4; break; default: - sp4C = 1; + sp4C = 1; break; } } @@ -3561,7 +3585,7 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { temp2 = 1; doorObj->segment.trans.y_position += 2.0 * updateRateF; } - } else if(door->unk14[1] == -1) { + } else if (door->unk14[1] == -1) { if (door->homeY < doorObj->segment.trans.y_position) { temp2 = 1; doorObj->segment.trans.y_position -= (2.0 * updateRateF); @@ -3605,9 +3629,10 @@ void obj_loop_door(Object *doorObj, s32 updateRate) { } if (temp2) { if (door->unk4 == NULL) { - play_sound_at_position(SOUND_DOOR_OPEN, doorObj->segment.trans.x_position, doorObj->segment.trans.y_position, - doorObj->segment.trans.z_position, 1, &door->unk4); - } + play_sound_at_position(SOUND_DOOR_OPEN, doorObj->segment.trans.x_position, + doorObj->segment.trans.y_position, doorObj->segment.trans.z_position, 1, + &door->unk4); + } } else { door->unk14[1] = 0; if (door->unk4 != NULL) { @@ -3674,7 +3699,7 @@ void obj_init_ttdoor(Object *obj, LevelObjectEntry_TTDoor *entry) { * T.T Door loop behaviour. * Checks if the player has complete the T.T amulet and has all 47 balloons. * If so, it will open, otherwise it opens dialogue telling the player to get them. -*/ + */ void obj_loop_ttdoor(Object *obj, s32 updateRate) { Settings *settings; Object_TTDoor *ttDoor; @@ -3734,7 +3759,7 @@ void obj_loop_ttdoor(Object *obj, s32 updateRate) { angle = 0x200; } if (angle < -0x200) { - angle = -0x200; + angle = -0x200; } obj->segment.trans.y_rotation -= angle; if (angle == 0) { @@ -3742,10 +3767,11 @@ void obj_loop_ttdoor(Object *obj, s32 updateRate) { } if (openDoor) { if (ttDoor->soundMask == NULL) { - play_sound_at_position(SOUND_DOOR_OPEN, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 1, &ttDoor->soundMask); + play_sound_at_position(SOUND_DOOR_OPEN, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 1, &ttDoor->soundMask); } } else if (ttDoor->soundMask != NULL) { - func_800096F8((SoundMask *)((s32)ttDoor->soundMask)); + func_800096F8((SoundMask *) ((s32) ttDoor->soundMask)); ttDoor->soundMask = NULL; } obj->interactObj->distance = 0xFF; @@ -3754,7 +3780,6 @@ void obj_loop_ttdoor(Object *obj, s32 updateRate) { obj->unk5C->unk100 = NULL; } - void obj_init_trigger(Object *obj, LevelObjectEntry_Trigger *entry) { f32 radius; Object_Trigger *obj64; @@ -3767,7 +3792,7 @@ void obj_init_trigger(Object *obj, LevelObjectEntry_Trigger *entry) { if (entry->index == -1) { rmonPrintf("Illegal door no!!!\n"); } - radius = (s32)entry->scale & 0xFF; + radius = (s32) entry->scale & 0xFF; if (radius < 5.0f) { radius = 5.0f; } @@ -3778,7 +3803,8 @@ void obj_init_trigger(Object *obj, LevelObjectEntry_Trigger *entry) { obj64->directionX = sins_f(obj->segment.trans.y_rotation); obj64->directionY = 0.0f; obj64->directionZ = coss_f(obj->segment.trans.y_rotation); - obj64->rotationDiff = -((obj64->directionX * obj->segment.trans.x_position) + (obj64->directionZ * obj->segment.trans.z_position)); + obj64->rotationDiff = + -((obj64->directionX * obj->segment.trans.x_position) + (obj64->directionZ * obj->segment.trans.z_position)); obj64->radius = entry->scale; obj64->unk14 = entry->unkD; obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; @@ -3787,7 +3813,6 @@ void obj_init_trigger(Object *obj, LevelObjectEntry_Trigger *entry) { obj->interactObj->pushForce = 0; } - void obj_loop_trigger(Object *obj, UNUSED s32 updateRate) { s32 i; s32 curRaceType; @@ -3820,13 +3845,16 @@ void obj_loop_trigger(Object *obj, UNUSED s32 updateRate) { for (i = 0; i < numRacers; i++) { racerObj = racers[i]; racer = (Object_Racer *) racerObj->unk64; - if ((!(trigger->unk14 & 1) && racer->playerIndex == PLAYER_COMPUTER) || (!(trigger->unk14 & 2) && racer->playerIndex != PLAYER_COMPUTER)) { + if ((!(trigger->unk14 & 1) && racer->playerIndex == PLAYER_COMPUTER) || + (!(trigger->unk14 & 2) && racer->playerIndex != PLAYER_COMPUTER)) { diffX = racerObj->segment.trans.x_position - obj->segment.trans.x_position; diffY = racerObj->segment.trans.y_position - obj->segment.trans.y_position; diffZ = racerObj->segment.trans.z_position - obj->segment.trans.z_position; distance = sqrtf((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)); if (distance < radiusF) { - distance = (trigger->directionX * racerObj->segment.trans.x_position) + (trigger->directionZ * racerObj->segment.trans.z_position) + trigger->rotationDiff; + distance = (trigger->directionX * racerObj->segment.trans.x_position) + + (trigger->directionZ * racerObj->segment.trans.z_position) + + trigger->rotationDiff; if (distance < 0.0f) { settings->courseFlagsPtr[settings->courseId] |= flags; if (triggerEntry->unkB != 0xFF) { @@ -3864,7 +3892,7 @@ void obj_init_bridge_whaleramp(Object *obj, LevelObjectEntry_Bridge_WhaleRamp *e * In Whale Bay and Boulder Canyon, there exist two bridge objects you can use. * This function makes the whale oscillate and move upwards when a player gets near. * For the boulder canyon bridge, it raises and plays a bell sound while it's set to be raised. -*/ + */ void obj_loop_bridge_whaleramp(Object *obj, s32 updateRate) { Object *racerObj; UNUSED ObjectTransform *temp_v0_4; @@ -3880,15 +3908,15 @@ void obj_loop_bridge_whaleramp(Object *obj, s32 updateRate) { f32 sp40; f32 sp3C; Object_Racer *racer; - + whaleRamp = (Object_Bridge_WhaleRamp *) obj->unk64; entry = (LevelObjectEntry_Bridge_WhaleRamp *) obj->segment.level_entry; updateRateF = updateRate; - + if (osTvType == TV_TYPE_PAL) { updateRateF *= 1.2; } - + if (entry->unkB != 3) { if (obj->properties.common.unk0 != 0) { temp_f2 = (2.0 * (f32) entry->unkE); @@ -3934,47 +3962,47 @@ void obj_loop_bridge_whaleramp(Object *obj, s32 updateRate) { } } } - + switch (entry->unkB) { - case 0: - obj->properties.common.unk0 = 0; - if (obj->interactObj->distance < entry->radius) { - obj->properties.common.unk0 = 1; - } - break; - case 2: - obj->properties.common.unk0 = 1; - racerObj = get_racer_object(PLAYER_ONE); - if (racerObj != NULL) { - racer = (Object_Racer *) racerObj->unk64; - switch(racer->vehicleID) { - default: - vehicleID = VEHICLE_HOVERCRAFT; - break; - case 1: - vehicleID = VEHICLE_PLANE; - break; - case 2: - vehicleID = VEHICLE_LOOPDELOOP; - break; - } - if (entry->allowedVehicles & vehicleID) { - obj->properties.common.unk0 = NULL; - } - } - break; - default: - if (func_8001E2EC(entry->unkA) != 0) { - obj->properties.common.unk0 = (entry->unkD * 2); - } - if (obj->properties.common.unk0 > 0) { - obj->properties.common.unk0 -= updateRate; - } else { + case 0: obj->properties.common.unk0 = 0; - } - break; + if (obj->interactObj->distance < entry->radius) { + obj->properties.common.unk0 = 1; + } + break; + case 2: + obj->properties.common.unk0 = 1; + racerObj = get_racer_object(PLAYER_ONE); + if (racerObj != NULL) { + racer = (Object_Racer *) racerObj->unk64; + switch (racer->vehicleID) { + default: + vehicleID = VEHICLE_HOVERCRAFT; + break; + case 1: + vehicleID = VEHICLE_PLANE; + break; + case 2: + vehicleID = VEHICLE_LOOPDELOOP; + break; + } + if (entry->allowedVehicles & vehicleID) { + obj->properties.common.unk0 = NULL; + } + } + break; + default: + if (func_8001E2EC(entry->unkA) != 0) { + obj->properties.common.unk0 = (entry->unkD * 2); + } + if (obj->properties.common.unk0 > 0) { + obj->properties.common.unk0 -= updateRate; + } else { + obj->properties.common.unk0 = 0; + } + break; } - + obj->interactObj->distance = 255; obj->interactObj->obj = NULL; obj->interactObj->flags &= ~INTERACT_FLAGS_PUSHING; @@ -4012,7 +4040,7 @@ void obj_init_fogchanger(Object *obj, LevelObjectEntry_FogChanger *entry) { /** * Skydome control init behaviour. * Sets hitbox data and on or off setting based off spawn info. -*/ + */ void obj_init_skycontrol(Object *obj, LevelObjectEntry_SkyControl *entry) { obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; obj->interactObj->unk11 = 0; @@ -4025,7 +4053,7 @@ void obj_init_skycontrol(Object *obj, LevelObjectEntry_SkyControl *entry) { * Skydome control loop behaviour. * When a player goes through this object, enable or disable rendering the skydome depending on setting. * Used for transitions between indoors and outdoors. -*/ + */ void obj_loop_skycontrol(Object *obj, UNUSED s32 updateRate) { if (obj->interactObj->distance < obj->properties.skyControl.radius) { set_skydome_visbility(obj->properties.skyControl.setting); @@ -4046,7 +4074,7 @@ void obj_loop_ainode(UNUSED Object *obj, UNUSED s32 updateRate) { /** * Smokey's castle treasure box init function. * Sets up player ID, making sure the value doesn't go over 4 players. -*/ + */ void obj_init_treasuresucker(Object *obj, LevelObjectEntry_TreasureSucker *entry) { obj->segment.animFrame = 120; obj->properties.treasureSucker.playerID = (entry->playerID - 1) & 3; @@ -4055,7 +4083,7 @@ void obj_init_treasuresucker(Object *obj, LevelObjectEntry_TreasureSucker *entry /** * Smokey's castle treasure box loop function. * When the player approaches carrying bananas, it spawns visual objects to enter it, then takes them from the player. -*/ + */ void obj_loop_treasuresucker(Object *obj, s32 updateRate) { Object *racerObj; f32 scale; @@ -4106,8 +4134,10 @@ void obj_loop_treasuresucker(Object *obj, s32 updateRate) { newObj->segment.level_entry = NULL; newObj->segment.y_velocity = 10.0f; scale = (newObj->segment.y_velocity * 2) / 0.5; - newObj->segment.x_velocity = (obj->segment.trans.x_position - racerObj->segment.trans.x_position) / scale; - newObj->segment.z_velocity = (obj->segment.trans.z_position - racerObj->segment.trans.z_position) / scale; + newObj->segment.x_velocity = + (obj->segment.trans.x_position - racerObj->segment.trans.x_position) / scale; + newObj->segment.z_velocity = + (obj->segment.trans.z_position - racerObj->segment.trans.z_position) / scale; newObj->properties.treasureBanana.racer = racer; newObj->properties.treasureBanana.diff = scale; } @@ -4115,7 +4145,6 @@ void obj_loop_treasuresucker(Object *obj, s32 updateRate) { } } - void obj_init_flycoin(UNUSED Object *obj, UNUSED LevelObjectEntry_FlyCoin *entry) { } @@ -4129,7 +4158,8 @@ void obj_loop_flycoin(Object *obj, s32 updateRate) { updateRateF *= 1.2; } obj->segment.y_velocity -= 0.5 * updateRateF; - move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, obj->segment.z_velocity * updateRateF); + move_object(obj, obj->segment.x_velocity * updateRateF, obj->segment.y_velocity * updateRateF, + obj->segment.z_velocity * updateRateF); obj->properties.treasureBanana.diff -= updateRate; if (obj->properties.treasureBanana.diff <= 0) { racerObj = obj->properties.treasureBanana.racer; @@ -4170,14 +4200,14 @@ void obj_loop_bananacreator(Object *obj, s32 updateRate) { newBananaObj->segment.level_entry = NULL; newBananaObj64 = &newBananaObj->unk64->banana; newBananaObj64->spawner = obj; - func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position - 14.0f, obj->segment.trans.z_position, BHV_LENS_FLARE_SWITCH, SOUND_SELECT, 0.25f, 0); + func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position - 14.0f, + obj->segment.trans.z_position, BHV_LENS_FLARE_SWITCH, SOUND_SELECT, 0.25f, 0); obj->properties.bananaSpawner.spawn = FALSE; } obj->properties.bananaSpawner.timer = TIME_SECONDS(20); // Set delay to respawn banana to 20 seconds. } } - void obj_init_banana(Object *obj, UNUSED LevelObjectEntry_Banana *entry) { obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; obj->interactObj->unk11 = 0; @@ -4193,7 +4223,7 @@ void obj_init_banana(Object *obj, UNUSED LevelObjectEntry_Banana *entry) { * Banana loop behaviour. * When dropped by a player, will have initial velocity to give some spread. * When touched by a player, will increase their banana count. -*/ + */ void obj_loop_banana(Object *obj, s32 updateRate) { Object *racerObj; Object_Racer *racer; @@ -4217,7 +4247,7 @@ void obj_loop_banana(Object *obj, s32 updateRate) { obj->segment.animFrame += updateRate * 8; properties = (ObjPropertyBanana *) &obj->properties.banana; if (properties->unk0 == -1) { - obj->segment.trans.flags |= OBJ_FLAGS_INVISIBLE; + obj->segment.trans.flags |= OBJ_FLAGS_INVISIBLE; properties->unk6 -= updateRate; obj->unk74 = 1; func_800AFC3C(obj, updateRate); @@ -4275,7 +4305,7 @@ void obj_loop_banana(Object *obj, s32 updateRate) { if (banana->unk9 != 2) { sp44 = 55; } - + if (properties->unk4 > 0) { properties->unk4 -= updateRate; } else { @@ -4294,16 +4324,20 @@ void obj_loop_banana(Object *obj, s32 updateRate) { } if (obj->interactObj->distance < sp44 && properties->unk4 == 0) { racerObj = obj->interactObj->obj; - if (racerObj != NULL && racerObj->segment.header->behaviorId == BHV_RACER) { + if (racerObj != NULL && racerObj->segment.header->behaviorId == BHV_RACER) { racer = (Object_Racer *) racerObj->unk64; if ((get_current_level_race_type() != RACETYPE_CHALLENGE_BANANAS) || racer->bananas < 2) { prevSoundMask = racer->bananaSoundMask; - play_sound_at_position(SOUND_SELECT, racerObj->segment.trans.x_position, racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, 4, &racer->bananaSoundMask); + play_sound_at_position(SOUND_SELECT, racerObj->segment.trans.x_position, + racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, 4, + &racer->bananaSoundMask); if (prevSoundMask) { func_800096F8(prevSoundMask); } if (racer->playerIndex != PLAYER_COMPUTER && racer->bananas == 9) { - sound_play_spatial(racer->characterId + SOUND_UNK_7B, racerObj->segment.trans.x_position, racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, NULL); + sound_play_spatial(racer->characterId + SOUND_UNK_7B, racerObj->segment.trans.x_position, + racerObj->segment.trans.y_position, racerObj->segment.trans.z_position, + NULL); } racer->bananas++; if (banana->spawner != NULL) { @@ -4322,13 +4356,12 @@ void obj_loop_banana(Object *obj, s32 updateRate) { } } - /** * Race silver coin init behaviour. * Checks if in the correct modes, then sets the flag to active, otherwise inactive. * If the flag is inactive, destroy the object. * Rareware duplicated this function just to check for adventure 2... -*/ + */ void obj_init_silvercoin_adv2(Object *obj, UNUSED LevelObjectEntry_SilverCoinAdv2 *entry) { obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; obj->interactObj->unk11 = 0; @@ -4352,7 +4385,7 @@ void obj_init_silvercoin_adv2(Object *obj, UNUSED LevelObjectEntry_SilverCoinAdv * Race silver coin init behaviour. * Checks if in the correct modes, then sets the flag to active, otherwise inactive. * If the flag is inactive, destroy the object. -*/ + */ void obj_init_silvercoin(Object *obj, UNUSED LevelObjectEntry_SilverCoin *entry) { obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; obj->interactObj->unk11 = 0; @@ -4377,22 +4410,24 @@ void obj_init_silvercoin(Object *obj, UNUSED LevelObjectEntry_SilverCoin *entry) * Can only be collected by players. Sets a flag equal to the player number when collected. * Under normal gameplay, that's 1 and 2, since the silver coin challenge can be done with at most two players. * When collected, the coins are hidden for that player, rather than being removed outright. -*/ + */ void obj_loop_silvercoin(Object *obj, s32 updateRate) { ObjectInteraction *interactObj; - Object_Racer* racer; + Object_Racer *racer; Object *racerObj; s32 twoPlayerAdv; twoPlayerAdv = is_two_player_adventure_race(); - if ((twoPlayerAdv && obj->properties.npc.action != SILVER_COIN_INACTIVE) || (!twoPlayerAdv && obj->properties.npc.action == SILVER_COIN_ACTIVE)) { + if ((twoPlayerAdv && obj->properties.npc.action != SILVER_COIN_INACTIVE) || + (!twoPlayerAdv && obj->properties.npc.action == SILVER_COIN_ACTIVE)) { interactObj = obj->interactObj; if (interactObj->distance < 80) { racerObj = interactObj->obj; if (racerObj != NULL && racerObj->segment.header->behaviorId == BHV_RACER) { racer = (Object_Racer *) racerObj->unk64; if (racer->playerIndex != PLAYER_COMPUTER) { - if (racer->raceFinished == FALSE && !(obj->properties.npc.action & (SILVER_COIN_COLLECTED << racer->playerIndex))) { + if (racer->raceFinished == FALSE && + !(obj->properties.npc.action & (SILVER_COIN_COLLECTED << racer->playerIndex))) { obj->properties.npc.action |= SILVER_COIN_COLLECTED << racer->playerIndex; obj->properties.npc.timer = 16; obj->segment.trans.flags |= OBJ_FLAGS_INVIS_PLAYER1 << racer->playerIndex; @@ -4452,7 +4487,7 @@ void obj_loop_worldkey(Object *worldKeyObj, s32 updateRate) { music_jingle_play(SEQUENCE_KEY_COLLECT); settings = get_settings(); settings->keys |= 1 << worldKeyObj->properties.worldKey.keyID; // Set key flag - free_object(worldKeyObj); // Makes the key unload. + free_object(worldKeyObj); // Makes the key unload. } } } @@ -4466,7 +4501,7 @@ void obj_loop_worldkey(Object *worldKeyObj, s32 updateRate) { * Weapon Balloon init behaviour. * Sets scale and rotation based off spawn info. * Sets model ID based on balloon ID. -*/ + */ void obj_init_weaponballoon(Object *obj, LevelObjectEntry_WeaponBalloon *entry) { s32 cheats; Object_WeaponBalloon *balloon; @@ -4578,7 +4613,8 @@ void obj_loop_weaponballoon(Object *weaponBalloonObj, s32 updateRate) { racer->balloon_level = 1; } } - levelMask = 3; // 3 isn't an attainable level so the future check won't be true if the item's already max level. + levelMask = 3; // 3 isn't an attainable level so the future check won't be true if the item's + // already max level. if (get_filtered_cheats() & CHEAT_MAXIMUM_POWER_UP) { racer->balloon_level = 2; } @@ -4595,7 +4631,8 @@ void obj_loop_weaponballoon(Object *weaponBalloonObj, s32 updateRate) { } if (racer->playerIndex == PLAYER_COMPUTER) { play_sound_at_position(SOUND_BALLOON_POP, weaponBalloonObj->segment.trans.x_position, - weaponBalloonObj->segment.trans.y_position, weaponBalloonObj->segment.trans.z_position, 4, NULL); + weaponBalloonObj->segment.trans.y_position, + weaponBalloonObj->segment.trans.z_position, 4, NULL); } else { if (levelMask == racer->balloon_level) { if (racer->raceFinished == FALSE) { @@ -4607,8 +4644,10 @@ void obj_loop_weaponballoon(Object *weaponBalloonObj, s32 updateRate) { } sound_play(SOUND_COLLECT_ITEM + prevBalloonQuantity, NULL); } else { - play_sound_at_position(SOUND_BALLOON_POP, weaponBalloonObj->segment.trans.x_position, - weaponBalloonObj->segment.trans.y_position, weaponBalloonObj->segment.trans.z_position, 4, NULL); + play_sound_at_position(SOUND_BALLOON_POP, + weaponBalloonObj->segment.trans.x_position, + weaponBalloonObj->segment.trans.y_position, + weaponBalloonObj->segment.trans.z_position, 4, NULL); } } } else if (racer->raceFinished == FALSE) { @@ -4630,14 +4669,14 @@ void obj_loop_weaponballoon(Object *weaponBalloonObj, s32 updateRate) { /** * Balloon Burst Effect init behaviour. * Does nothing. -*/ + */ void obj_init_wballoonpop(UNUSED Object *obj, UNUSED LevelObjectEntry_WBalloonPop *entry) { } /** * Balloon Burst Effect loop behaviour. * Does nothing. -*/ + */ void obj_loop_wballoonpop(UNUSED Object *obj, UNUSED s32 updateRate) { } @@ -4645,7 +4684,7 @@ void obj_loop_wballoonpop(UNUSED Object *obj, UNUSED s32 updateRate) { * Racer weapon init behaviour. * Sets hitbox info so racers can interact with it. * Also sets a timer to remove the object after that many frames. -*/ + */ void obj_init_weapon(Object *obj, UNUSED LevelObjectEntry_Weapon *entry) { obj->interactObj->flags = INTERACT_FLAGS_TANGIBLE; obj->interactObj->unk11 = 0; @@ -4659,7 +4698,7 @@ void obj_init_weapon(Object *obj, UNUSED LevelObjectEntry_Weapon *entry) { * Racer weapon loop behaviour. * Rockets will move forwards, or towards their victim. * Stationary traps will drop to the floor and stay there for a while before self-detonating. -*/ + */ void obj_loop_weapon(Object *obj, s32 updateRate) { Object_Weapon *weapon = &obj->unk64->weapon; switch (weapon->weaponID) { @@ -4681,7 +4720,7 @@ void obj_loop_weapon(Object *obj, s32 updateRate) { * Firing a standard rocket makes it fly forward. * A homing rocket uses the checkpoint system to path towards its victim. * When it collides with a racer, they're launched into the air. -*/ + */ void handle_rocket_projectile(Object *obj, s32 updateRate) { Object *interactObj; Object_Racer *weaponOwner; @@ -4720,7 +4759,8 @@ void handle_rocket_projectile(Object *obj, s32 updateRate) { trans.z_position = 0.0f; trans.scale = 1.0f; object_transform_to_matrix(mtxf, &trans); - guMtxXFMF(mtxf, 0.0f, 0.0f, weapon->forwardVel, &obj->segment.x_velocity, &obj->segment.y_velocity, &obj->segment.z_velocity); + guMtxXFMF(mtxf, 0.0f, 0.0f, weapon->forwardVel, &obj->segment.x_velocity, &obj->segment.y_velocity, + &obj->segment.z_velocity); updateRateF = updateRate; if (osTvType == TV_TYPE_PAL) { updateRateF *= 1.2; @@ -4754,7 +4794,8 @@ void handle_rocket_projectile(Object *obj, s32 updateRate) { if (weapon->weaponID == WEAPON_ROCKET_HOMING) { numCheckpoints = get_checkpoint_count(); if (numCheckpoints > 0) { - if (func_800185E4(weapon->checkpoint, obj, posX, posY, posZ, &weapon->checkpointDist, (u8 *) &surface) == FALSE) { + if (func_800185E4(weapon->checkpoint, obj, posX, posY, posZ, &weapon->checkpointDist, (u8 *) &surface) == + FALSE) { weapon->checkpoint++; if (weapon->checkpoint >= numCheckpoints) { weapon->checkpoint = 0; @@ -4769,7 +4810,7 @@ void handle_rocket_projectile(Object *obj, s32 updateRate) { } else { rocket_prevent_overshoot(obj, updateRate, weapon); } - //TODO: Fix these gotos. + // TODO: Fix these gotos. if (obj->interactObj->obj != NULL) { interactObj = obj->interactObj->obj; if (interactObj == weapon->owner) { @@ -4778,7 +4819,7 @@ void handle_rocket_projectile(Object *obj, s32 updateRate) { } goto block_37; } -block_25: + block_25: if (weapon->weaponID == WEAPON_ROCKET_HOMING) { if (interactObj == weapon->target) { size = 75; @@ -4800,7 +4841,8 @@ block_25: func_80072348(racer->playerIndex, 9); } } - func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, BHV_LENS_FLARE_SWITCH, SOUND_EXPLOSION, 1.0f, 1); + func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, + BHV_LENS_FLARE_SWITCH, SOUND_EXPLOSION, 1.0f, 1); free_object(obj); return; } @@ -4819,7 +4861,8 @@ block_37: } obj->properties.projectile.timer -= updateRate; if (obj->properties.projectile.timer < 0) { - func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, BHV_LENS_FLARE_SWITCH, SOUND_EXPLOSION, 1.0f, 1); + func_8003FC44(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, + BHV_LENS_FLARE_SWITCH, SOUND_EXPLOSION, 1.0f, 1); free_object(obj); return; } @@ -4829,7 +4872,7 @@ block_37: * If a collision target is found for a level 1 or 3 rocket, reverse the velocity and set the next position target * to be right on top of them. This ensures a collision is guaranteed this frame. * This function also calls the function that plays the incoming rocket sound. -*/ + */ void rocket_prevent_overshoot(Object *obj, UNUSED s32 updateRate, Object_Weapon *rocket) { Object *interactedObj; f32 dist; @@ -4871,7 +4914,7 @@ void rocket_prevent_overshoot(Object *obj, UNUSED s32 updateRate, Object_Weapon * If a collision target is found for a level 2 rocket, reverse the velocity and set the next position target * to be right on top of them. This ensures a collision is guaranteed this frame. * This function also calls the function that plays the incoming rocket sound. -*/ + */ void homing_rocket_prevent_overshoot(Object *obj, s32 updateRate, Object_Weapon *rocket) { Object *targetObj; Object_64 *racer; @@ -4879,7 +4922,7 @@ void homing_rocket_prevent_overshoot(Object *obj, s32 updateRate, Object_Weapon f32 diffX; f32 diffY; f32 diffZ; - f32 distY; + f32 distY; s32 sp58; s32 angle; s32 sineY; @@ -4902,7 +4945,8 @@ void homing_rocket_prevent_overshoot(Object *obj, s32 updateRate, Object_Weapon } dist = sqrtf(dist + distY); if (dist > 300.0f && rocket->checkpoint != -1 && rocket->hitObj == NULL) { - sp58 = func_8001955C(obj, rocket->checkpoint, racer->racer.unk1C8, rocket->unk14, rocket->unk16, rocket->checkpointDist, &diffX, &diffY, &diffZ); + sp58 = func_8001955C(obj, rocket->checkpoint, racer->racer.unk1C8, rocket->unk14, rocket->unk16, + rocket->checkpointDist, &diffX, &diffY, &diffZ); sineY = arctan2_f(diffY, 500.0f) & 0xFFFF; shift = 3; } else { @@ -4924,10 +4968,9 @@ void homing_rocket_prevent_overshoot(Object *obj, s32 updateRate, Object_Weapon obj->interactObj->distance = 1; } obj->segment.trans.x_rotation = arctan2_f(diffY, dist) & 0xFFFFu; - + obj->segment.trans.y_rotation = angle; } - } play_rocket_trailing_sound(obj, rocket, SOUND_HOMING_ROCKET); if (get_number_of_active_players() < 3) { @@ -4938,14 +4981,14 @@ void homing_rocket_prevent_overshoot(Object *obj, s32 updateRate, Object_Weapon /** * Set the rocket sound timer back to zero. -*/ + */ void reset_rocket_sound_timer(void) { gRocketSoundTimer = 0; } /** * Reduce the rocket sound timer by 1 increment. -*/ + */ void decrease_rocket_sound_timer(void) { gRocketSoundTimer--; } @@ -4953,7 +4996,7 @@ void decrease_rocket_sound_timer(void) { /** * Existing flying rockets that don't belong to that player will play a sound when flying. * This will check if that player is close enough to hear it, and whether to update an existing sound or play a new one. -*/ + */ void play_rocket_trailing_sound(Object *obj, struct Object_Weapon *weapon, u16 soundID) { Object *racer; Object **racerGroup; @@ -4982,11 +5025,13 @@ void play_rocket_trailing_sound(Object *obj, struct Object_Weapon *weapon, u16 s if (shouldPlaySound) { if (weapon->soundMask == NULL) { if (gRocketSoundTimer < 8) { - play_sound_at_position(soundID, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 1, &weapon->soundMask); + play_sound_at_position(soundID, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 1, &weapon->soundMask); gRocketSoundTimer++; } } else { - update_spatial_audio_position(weapon->soundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + update_spatial_audio_position(weapon->soundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } } else { if (weapon->soundMask) { @@ -5009,9 +5054,9 @@ void func_8003F2E8(Object *weaponObj, s32 updateRate) { s8 surface; Object_Weapon *weapon; ObjPropertyWeapon *weaponProperties; - + weapon = &weaponObj->unk64->weapon; - weaponOwner = &weapon->owner->unk64->racer; + weaponOwner = &weapon->owner->unk64->racer; updateRateF = (f32) updateRate; weaponProperties = &weaponObj->properties.weapon; if (osTvType == TV_TYPE_PAL) { @@ -5082,8 +5127,8 @@ void func_8003F2E8(Object *weaponObj, s32 updateRate) { weaponObj->segment.trans.y_position = 0.0f; weaponObj->segment.trans.z_position = 0.0f; ignore_bounds_check(); - move_object(weaponObj, weapon->target->segment.trans.x_position, - weapon->target->segment.trans.y_position, weapon->target->segment.trans.z_position); + move_object(weaponObj, weapon->target->segment.trans.x_position, weapon->target->segment.trans.y_position, + weapon->target->segment.trans.z_position); } if (weaponProperties->unk4 == 1 || weaponProperties->unk4 == 2) { weaponProperties->unk6 += updateRate; @@ -5100,7 +5145,8 @@ void func_8003F2E8(Object *weaponObj, s32 updateRate) { weapon->soundMask = NULL; } play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, - weaponObj->segment.trans.y_position, weaponObj->segment.trans.z_position, 4, NULL); + weaponObj->segment.trans.y_position, weaponObj->segment.trans.z_position, 4, + NULL); } } if (weaponProperties->unk4 == 3) { @@ -5142,23 +5188,26 @@ void func_8003F2E8(Object *weaponObj, s32 updateRate) { weaponHit->attackType = ATTACK_EXPLOSION; if (weapon->weaponID == WEAPON_TRIPMINE) { func_8003FC44(weaponObj->segment.trans.x_position, weaponObj->segment.trans.y_position, - weaponObj->segment.trans.z_position, 44, SOUND_EXPLOSION, 1.0f, 1); - } else if(weapon->weaponID == WEAPON_BUBBLE_TRAP) { + weaponObj->segment.trans.z_position, 44, SOUND_EXPLOSION, 1.0f, 1); + } else if (weapon->weaponID == WEAPON_BUBBLE_TRAP) { if (weaponHit->shieldTimer > 0 && weaponHit->shieldType >= SHIELD_LEVEL3) { weaponProperties->unk4 = 3; - - play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, - weaponObj->segment.trans.y_position, weaponObj->segment.trans.z_position, 4, NULL); + + play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, + weaponObj->segment.trans.y_position, + weaponObj->segment.trans.z_position, 4, NULL); } else { weapon->target = weaponInteractObj; - + play_sound_at_position(SOUND_BUBBLE, weaponInteractObj->segment.trans.x_position, - weaponInteractObj->segment.trans.y_position, weaponInteractObj->segment.trans.z_position, 4, &weapon->soundMask); + weaponInteractObj->segment.trans.y_position, + weaponInteractObj->segment.trans.z_position, 4, + &weapon->soundMask); weaponHit->attackType = ATTACK_BUBBLE; weaponProperties->unk4 = 2; weaponProperties->unk5 = 0; } - } else if(weapon->weaponID == WEAPON_OIL_SLICK) { + } else if (weapon->weaponID == WEAPON_OIL_SLICK) { weaponHit->attackType = ATTACK_SPIN; weaponProperties->unk4 = 2; } @@ -5182,13 +5231,14 @@ void func_8003F2E8(Object *weaponObj, s32 updateRate) { if (weaponProperties->unk0 < normalise_time(-1320)) { if (weapon->weaponID == WEAPON_OIL_SLICK) { weaponProperties->unk4 = 2; - } else if((weapon->weaponID == WEAPON_BUBBLE_TRAP)) { + } else if ((weapon->weaponID == WEAPON_BUBBLE_TRAP)) { weaponProperties->unk4 = 3; play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, - weaponObj->segment.trans.y_position, weaponObj->segment.trans.z_position, 4, NULL); + weaponObj->segment.trans.y_position, weaponObj->segment.trans.z_position, 4, + NULL); } else { func_8003FC44(weaponObj->segment.trans.x_position, weaponObj->segment.trans.y_position, - weaponObj->segment.trans.z_position, 44, SOUND_EXPLOSION, 1.0f, 1); + weaponObj->segment.trans.z_position, 44, SOUND_EXPLOSION, 1.0f, 1); free_object(weaponObj); } } @@ -5232,13 +5282,11 @@ void obj_init_audio(Object *obj, LevelObjectEntry_Audio *entry) { obj64->unkD = entry->unk10; obj64->soundMask = NULL; if (gSoundBank_GetSoundDecayTime(obj64->soundId)) { - func_8000974C(obj64->soundId, entry->common.x, entry->common.y, entry->common.z, - 9, obj64->unk5, obj64->unk4, obj64->unk2, obj64->unkC, - obj64->unk6, obj64->unkD, &obj64->soundMask); + func_8000974C(obj64->soundId, entry->common.x, entry->common.y, entry->common.z, 9, obj64->unk5, obj64->unk4, + obj64->unk2, obj64->unkC, obj64->unk6, obj64->unkD, &obj64->soundMask); } else { - func_8000974C(obj64->soundId, entry->common.x, entry->common.y, entry->common.z, - 10, obj64->unk5, obj64->unk4, obj64->unk2, obj64->unkC, - obj64->unk6, obj64->unkD, &obj64->soundMask); + func_8000974C(obj64->soundId, entry->common.x, entry->common.y, entry->common.z, 10, obj64->unk5, obj64->unk4, + obj64->unk2, obj64->unkC, obj64->unk6, obj64->unkD, &obj64->soundMask); } free_object(obj); } @@ -5259,9 +5307,8 @@ void obj_init_audioline(Object *obj, LevelObjectEntry_AudioLine *entry) { obj64->unkE = entry->unk9; obj64->unkF = entry->unk10; obj64->unk12 = entry->unk13; - func_800098A4(obj64->unk0, obj64->soundID, entry->common.x, entry->common.y, entry->common.z, - obj64->unkF, obj64->unkE, obj64->unk10, obj64->unk12, obj64->unk4, obj64->unk11, - obj64->unkC, obj64->unkD); + func_800098A4(obj64->unk0, obj64->soundID, entry->common.x, entry->common.y, entry->common.z, obj64->unkF, + obj64->unkE, obj64->unk10, obj64->unk12, obj64->unk4, obj64->unk11, obj64->unkC, obj64->unkD); free_object(obj); } @@ -5310,9 +5357,10 @@ void obj_init_rgbalight(Object *obj, LevelObjectEntry_RgbaLight *entry, UNUSED s /** * Floating buoy init behaviour. * Sets hitbox data from spawn info. -*/ + */ void obj_init_buoy_pirateship(Object *obj, UNUSED LevelObjectEntry_Buoy_PirateShip *entry, UNUSED s32 arg2) { - obj->unk64 = func_800BE654(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position); + obj->unk64 = + func_800BE654(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position); obj->interactObj->flags = INTERACT_FLAGS_SOLID; obj->interactObj->unk11 = 0; obj->interactObj->hitboxRadius = 30; @@ -5323,7 +5371,7 @@ void obj_init_buoy_pirateship(Object *obj, UNUSED LevelObjectEntry_Buoy_PirateSh * Floating buoy loop behaviour. * Exists to serve as an outer bound for water courses. * All it does is stays afloat on water and scrolls through each texture. -*/ + */ void obj_loop_buoy_pirateship(Object *obj, s32 updateRate) { if (obj->unk64 != NULL) { obj->segment.trans.y_position = get_wave_height((Object_Log *) obj->unk64, updateRate); @@ -5334,10 +5382,11 @@ void obj_loop_buoy_pirateship(Object *obj, s32 updateRate) { /** * Spinning log init behaviour. * Sets scale, angle and hitbox data based off the spawn info. -*/ + */ void obj_init_log(Object *obj, LevelObjectEntry_Log *entry, UNUSED s32 arg2) { f32 radius; - obj->unk64 = func_800BE654(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position); + obj->unk64 = + func_800BE654(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position); obj->interactObj->flags = INTERACT_FLAGS_SOLID; obj->interactObj->unk11 = 2; obj->interactObj->hitboxRadius = 30; @@ -5354,7 +5403,7 @@ void obj_init_log(Object *obj, LevelObjectEntry_Log *entry, UNUSED s32 arg2) { /** * Spinning log loop behaviour. * Exists as a physical obstruction, will start spinning around on the spot when hit. -*/ + */ void obj_loop_log(Object *obj, s32 updateRate) { Object *racerObj; Object_Log *log; @@ -5381,7 +5430,7 @@ void obj_loop_log(Object *obj, s32 updateRate) { } sine = sins_f(-obj->segment.trans.y_rotation); cosine = coss_f(-obj->segment.trans.y_rotation); - + // This looks a bit messy, but is required to match. diffX = obj->segment.trans.x_position - racerObj->segment.trans.x_position; diffZ = obj->segment.trans.z_position - racerObj->segment.trans.z_position; @@ -5389,7 +5438,7 @@ void obj_loop_log(Object *obj, s32 updateRate) { diffZ = (racerObj->segment.x_velocity * sine) - (racerObj->segment.z_velocity * cosine); diffX *= diffZ; obj->properties.log.angleVel -= (s32) (diffX / 4); - + if (obj->properties.log.angleVel > 0x200) { obj->properties.log.angleVel = 0x200; } @@ -5429,7 +5478,7 @@ void obj_init_weather(Object *obj, LevelObjectEntry_Weather *entry) { * Weather updater loop behaviour. * When passed through by the player, it will update the current weather settings. * Can be used to stop, start or change the intensity of the current weather. -*/ + */ void obj_loop_weather(Object *obj, UNUSED s32 updateRate) { s32 currViewport; s32 numberOfObjects; @@ -5442,7 +5491,7 @@ void obj_loop_weather(Object *obj, UNUSED s32 updateRate) { s32 cur; s32 last; f32 dist; - + currViewport = get_current_viewport(); objects = get_racer_objects(&numberOfObjects); cur = -1; @@ -5452,14 +5501,16 @@ void obj_loop_weather(Object *obj, UNUSED s32 updateRate) { curObj = objects[cur + 1]; curObj64 = (Object_Racer *) curObj->unk64; } while (++cur < last && currViewport != curObj64->playerIndex); - + diffX = obj->segment.trans.x_position - curObj->segment.trans.x_position; diffZ = obj->segment.trans.z_position - curObj->segment.trans.z_position; dist = obj->properties.distance.radius; - entry = (LevelObjectEntry_Weather *)obj->segment.level_entry; - if ((diffX * diffX) + (diffZ * diffZ) <= dist){ - if (((!obj->segment.level_entry) && (!obj->segment.level_entry)) && (!obj->segment.level_entry)){} // Fakematch - changeWeather(entry->unkA * 256, entry->unkC * 256, entry->unkE * 256, entry->unk10 * 257, entry->unk11 * 257, entry->unk12); + entry = (LevelObjectEntry_Weather *) obj->segment.level_entry; + if ((diffX * diffX) + (diffZ * diffZ) <= dist) { + if (((!obj->segment.level_entry) && (!obj->segment.level_entry)) && (!obj->segment.level_entry)) { + } // Fakematch + changeWeather(entry->unkA * 256, entry->unkC * 256, entry->unkE * 256, entry->unk10 * 257, + entry->unk11 * 257, entry->unk12); } } } @@ -5483,7 +5534,7 @@ void obj_init_butterfly(Object *butterflyObj, LevelObjectEntry_Butterfly *butter s32 uMask; s32 vMask; s32 i; - + butterfly = &butterflyObj->unk64->butterfly; if (param == 0) { butterflyObj->segment.y_velocity = 0.0f; @@ -5493,14 +5544,14 @@ void obj_init_butterfly(Object *butterflyObj, LevelObjectEntry_Butterfly *butter butterfly->unkFD = 0; butterfly->unk106 = 0x180; butterfly->unk108 = 0.0f; - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { butterfly->triangles[i].flags = D_800DCAA8[i].flags; butterfly->triangles[i].vi0 = D_800DCAA8[i].vi0; butterfly->triangles[i].vi1 = D_800DCAA8[i].vi1; butterfly->triangles[i].vi2 = D_800DCAA8[i].vi2; } uMask = 0; - for(i = 0; i < 6; i++) { + for (i = 0; i < 6; i++) { butterfly->vertices[uMask].x = D_800DCB28[uMask].x; butterfly->vertices[uMask].y = D_800DCB28[uMask].y; butterfly->vertices[uMask].z = D_800DCB28[uMask].z; @@ -5508,13 +5559,13 @@ void obj_init_butterfly(Object *butterflyObj, LevelObjectEntry_Butterfly *butter butterfly->vertices[uMask].g = 255; butterfly->vertices[uMask].b = 255; butterfly->vertices[uMask].a = 255; - butterfly->vertices[uMask+6].x = D_800DCB28[uMask].x; - butterfly->vertices[uMask+6].y = D_800DCB28[uMask].y; - butterfly->vertices[uMask+6].z = D_800DCB28[uMask].z; - butterfly->vertices[uMask+6].r = 255; - butterfly->vertices[uMask+6].g = 255; - butterfly->vertices[uMask+6].b = 255; - butterfly->vertices[uMask+6].a = 255; + butterfly->vertices[uMask + 6].x = D_800DCB28[uMask].x; + butterfly->vertices[uMask + 6].y = D_800DCB28[uMask].y; + butterfly->vertices[uMask + 6].z = D_800DCB28[uMask].z; + butterfly->vertices[uMask + 6].r = 255; + butterfly->vertices[uMask + 6].g = 255; + butterfly->vertices[uMask + 6].b = 255; + butterfly->vertices[uMask + 6].a = 255; uMask++; } butterfly->unkFC = 1; @@ -5532,7 +5583,7 @@ void obj_init_butterfly(Object *butterflyObj, LevelObjectEntry_Butterfly *butter uMask = 0; vMask = 0; } - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { butterfly->triangles[i].uv0.u = D_800DCAA8[i].uv0.u & uMask; butterfly->triangles[i].uv0.v = D_800DCAA8[i].uv0.v & vMask; butterfly->triangles[i].uv1.u = D_800DCAA8[i].uv1.u & uMask; @@ -5542,10 +5593,9 @@ void obj_init_butterfly(Object *butterflyObj, LevelObjectEntry_Butterfly *butter } } - GLOBAL_ASM("asm/non_matchings/object_functions/obj_loop_butterfly.s") -//Scratch: https://decomp.me/scratch/h4CcJ +// Scratch: https://decomp.me/scratch/h4CcJ GLOBAL_ASM("asm/non_matchings/object_functions/obj_init_midifade.s") void obj_init_midifadepoint(Object *obj, LevelObjectEntry_MidiFadePoint *entry) { @@ -5631,7 +5681,8 @@ void obj_loop_rangetrigger(Object *obj, s32 updateRate) { Object *objs[8]; level_entry = &obj->segment.level_entry->rangeTrigger; - if (func_80016DE8(obj->segment.trans.x_position, 0, obj->segment.trans.z_position, level_entry->unk8, 1, objs) > 0) { + if (func_80016DE8(obj->segment.trans.x_position, 0, obj->segment.trans.z_position, level_entry->unk8, 1, objs) > + 0) { obj->unk74 = level_entry->unkA; } else { obj->unk74 = 0; @@ -5658,9 +5709,9 @@ void obj_init_frog(Object *obj, LevelObjectEntry_Frog *entry) { if (obj64->drumstick) { obj->segment.object.modelIndex = TRUE; /** - * Don't spawn the chicken frog if drumstick is already unlocked, or - * if the player hasn't completed the trophy races yet. - */ + * Don't spawn the chicken frog if drumstick is already unlocked, or + * if the player hasn't completed the trophy races yet. + */ if (is_drumstick_unlocked() || (get_settings()->trophies & 0xFF) != 0xFF) { free_object(obj); } @@ -5672,8 +5723,9 @@ void obj_init_frog(Object *obj, LevelObjectEntry_Frog *entry) { /** * Overworld frog loop function. * Hops, skips, jumps around. Can be flattened by players. - * If a Drumstick frog exists after beating all 4 trophy races, he can be squashed and will be unlocked as a playable character. -*/ + * If a Drumstick frog exists after beating all 4 trophy races, he can be squashed and will be unlocked as a playable + * character. + */ void obj_loop_frog(Object *obj, s32 updateRate) { UNUSED s32 pad0; s32 i; @@ -5697,136 +5749,146 @@ void obj_loop_frog(Object *obj, s32 updateRate) { frog = (Object_Frog *) obj->unk64; switch (frog->action) { - case FROG_IDLE: - hopping = FALSE; - if (frog->squishCooldown > 0) { - frog->squishCooldown -= updateRate; - } - if (func_80016DE8(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 96.0f, 1, &racerObj) > 0) { - diffX = obj->segment.trans.x_position - racerObj->segment.trans.x_position; - diffY = obj->segment.trans.y_position - racerObj->segment.trans.y_position; - diffZ = obj->segment.trans.z_position - racerObj->segment.trans.z_position; - if (frog->squishCooldown <= 0 && (diffX * diffX) + (diffY * diffY) + (diffZ * diffZ) < 40.0f * 40.0f) { - if (frog->drumstick) { - play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE2, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); - set_eeprom_settings_value(2); - set_magic_code_flags(CHEAT_CONTROL_DRUMSTICK); - set_drumstick_unlock_transition(); - free_object(obj); - break; + case FROG_IDLE: + hopping = FALSE; + if (frog->squishCooldown > 0) { + frog->squishCooldown -= updateRate; + } + if (func_80016DE8(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 96.0f, 1, &racerObj) > 0) { + diffX = obj->segment.trans.x_position - racerObj->segment.trans.x_position; + diffY = obj->segment.trans.y_position - racerObj->segment.trans.y_position; + diffZ = obj->segment.trans.z_position - racerObj->segment.trans.z_position; + if (frog->squishCooldown <= 0 && (diffX * diffX) + (diffY * diffY) + (diffZ * diffZ) < 40.0f * 40.0f) { + if (frog->drumstick) { + play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE2, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + set_eeprom_settings_value(2); + set_magic_code_flags(CHEAT_CONTROL_DRUMSTICK); + set_drumstick_unlock_transition(); + free_object(obj); + break; + } else { + frog->action = 2; + play_sound_at_position(SOUND_SPLAT, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + } } else { - frog->action = 2; - play_sound_at_position(SOUND_SPLAT, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + frog->forwardVel = 72.0f; + if (frog->drumstick) { + frog->forwardVel *= 1.34f; + } + frog->hopDirection = arctan2_f(-diffX, -diffZ) + 0x8000; + hopping = TRUE; } } else { - frog->forwardVel = 72.0f; - if (frog->drumstick) { - frog->forwardVel *= 1.34f; + frog->hopTimer -= updateRate; + if (frog->hopTimer < 0) { + hopping = TRUE; + frog->forwardVel = get_random_number_from_range(40, 72); + frog->hopDirection = get_random_number_from_range(-0x4000, 0x4000) + obj->segment.trans.y_rotation; } - frog->hopDirection = arctan2_f(-diffX, -diffZ) + 0x8000; - hopping = TRUE; } - } else { + if (hopping) { + for (i = 0, var_v1 = FALSE; i < 4 && var_v1 == FALSE; i++) { + frog->hopTargetX = sins_f(frog->hopDirection) * frog->forwardVel; + frog->hopTargetZ = coss_f(frog->hopDirection) * -frog->forwardVel; + diffX = (obj->segment.trans.x_position + frog->hopTargetX) - frog->homeX; + diffZ = (obj->segment.trans.z_position + frog->hopTargetZ) - frog->homeZ; + if ((diffX * diffX) + (diffZ * diffZ) < frog->homeRadiusSquare) { + var_v1 = TRUE; + } else { + frog->hopDirection += 0x4000; + } + } + if (var_v1 == FALSE) { + diffX = frog->homeX - obj->segment.trans.x_position; + diffZ = frog->homeZ - obj->segment.trans.z_position; + frog->hopDirection = arctan2_f(diffX, diffZ); + } + if (frog->drumstick) { + play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE6, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + } else { + play_sound_at_position(SOUND_RIBBIT, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, NULL); + } + frog->action = FROG_HOP; + frog->hopStartX = obj->segment.trans.x_position; + frog->hopStartZ = obj->segment.trans.z_position; + frog->hopFrame = 32; + obj->segment.trans.y_rotation = -frog->hopDirection; + } + default: + break; + case FROG_HOP: + frog->hopFrame -= updateRate; + if (frog->squishCooldown > 0) { + frog->squishCooldown -= updateRate; + } + if (frog->hopFrame < 0) { + frog->action = FROG_IDLE; + frog->hopTimer = get_random_number_from_range(0, 300); + frog->hopFrame = 0; + } + obj->segment.animFrame = ((32 - frog->hopFrame) << 3) / 3; + cosine = (coss_f(frog->hopFrame << 10) + 1.0f) * 0.5f; + obj->segment.trans.x_position = frog->hopStartX; + obj->segment.trans.z_position = frog->hopStartZ; + obj->segment.x_velocity = frog->hopTargetX * cosine; + obj->segment.z_velocity = frog->hopTargetZ * cosine; + ignore_bounds_check(); + move_object(obj, obj->segment.x_velocity, 0.0f, obj->segment.z_velocity); + if (func_8002BAB0(obj->segment.object.segmentID, obj->segment.trans.x_position, + obj->segment.trans.z_position, &sp6C) != 0) { + obj->segment.trans.y_position = 0.0f; + ignore_bounds_check(); + move_object(obj, 0.0f, sp6C, 0.0f); + } + if (frog->squishCooldown <= 0 && (frog->hopFrame < 6 || frog->hopFrame >= 27)) { + if (func_80016DE8(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 40.0f, 0, &racerObj)) { + if (frog->drumstick) { + play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE2, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + set_eeprom_settings_value(2); + set_magic_code_flags(CHEAT_CONTROL_DRUMSTICK); + set_drumstick_unlock_transition(); + free_object(obj); + } else { + frog->action = FROG_SQUISH; + play_sound_at_position(SOUND_SPLAT, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + } + } + } + break; + case FROG_SQUISH: + frog->scaleY -= 0.15f * updateRateF; + if (frog->scaleY < 0.05f) { + frog->scaleY = 0.05f; + frog->action = FROG_FLAT; + frog->hopTimer = 40; + } + break; + case FROG_FLAT: frog->hopTimer -= updateRate; if (frog->hopTimer < 0) { - hopping = TRUE; - frog->forwardVel = get_random_number_from_range(40, 72); - frog->hopDirection = get_random_number_from_range(-0x4000, 0x4000) + obj->segment.trans.y_rotation; + frog->action = FROG_UNSQUISH; + play_sound_at_position(SOUND_PLOP2, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, NULL); } - } - if (hopping) { - for(i = 0, var_v1 = FALSE; i < 4 && var_v1 == FALSE; i++) { - frog->hopTargetX = sins_f(frog->hopDirection) * frog->forwardVel; - frog->hopTargetZ = coss_f(frog->hopDirection) * -frog->forwardVel; - diffX = (obj->segment.trans.x_position + frog->hopTargetX) - frog->homeX; - diffZ = (obj->segment.trans.z_position + frog->hopTargetZ) - frog->homeZ; - if ((diffX * diffX) + (diffZ * diffZ) < frog->homeRadiusSquare) { - var_v1 = TRUE; - } else { - frog->hopDirection += 0x4000; - } - } - if (var_v1 == FALSE) { - diffX = frog->homeX - obj->segment.trans.x_position; - diffZ = frog->homeZ - obj->segment.trans.z_position; - frog->hopDirection = arctan2_f(diffX, diffZ); - } - if (frog->drumstick) { - play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE6, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + break; + case FROG_UNSQUISH: + if (frog->scaleY > 1.0f) { + frog->scaleY = 1.0f; + frog->action = FROG_IDLE; + frog->hopTimer = 0; + frog->squishCooldown = 60; } else { - play_sound_at_position(SOUND_RIBBIT, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + frog->scaleY += 0.15f * updateRateF; } - frog->action = FROG_HOP; - frog->hopStartX = obj->segment.trans.x_position; - frog->hopStartZ = obj->segment.trans.z_position; - frog->hopFrame = 32; - obj->segment.trans.y_rotation = -frog->hopDirection; - } - default: - break; - case FROG_HOP: - frog->hopFrame -= updateRate; - if (frog->squishCooldown > 0) { - frog->squishCooldown -= updateRate; - } - if (frog->hopFrame < 0) { - frog->action = FROG_IDLE; - frog->hopTimer = get_random_number_from_range(0, 300); - frog->hopFrame = 0; - } - obj->segment.animFrame = ((32 - frog->hopFrame) << 3) / 3; - cosine = (coss_f(frog->hopFrame << 10) + 1.0f) * 0.5f; - obj->segment.trans.x_position = frog->hopStartX; - obj->segment.trans.z_position = frog->hopStartZ; - obj->segment.x_velocity = frog->hopTargetX * cosine; - obj->segment.z_velocity = frog->hopTargetZ * cosine; - ignore_bounds_check(); - move_object(obj, obj->segment.x_velocity, 0.0f, obj->segment.z_velocity); - if (func_8002BAB0(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position, &sp6C) != 0) { - obj->segment.trans.y_position = 0.0f; - ignore_bounds_check(); - move_object(obj, 0.0f, sp6C, 0.0f); - } - if (frog->squishCooldown <= 0 && (frog->hopFrame < 6 || frog->hopFrame >= 27)) { - if (func_80016DE8(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 40.0f, 0, &racerObj)) { - if (frog->drumstick) { - play_sound_at_position(SOUND_VOICE_DRUMSTICK_POSITIVE2, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); - set_eeprom_settings_value(2); - set_magic_code_flags(CHEAT_CONTROL_DRUMSTICK); - set_drumstick_unlock_transition(); - free_object(obj); - } else { - frog->action = FROG_SQUISH; - play_sound_at_position(SOUND_SPLAT, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); - } - } - } - break; - case FROG_SQUISH: - frog->scaleY -= 0.15f * updateRateF; - if (frog->scaleY < 0.05f) { - frog->scaleY = 0.05f; - frog->action = FROG_FLAT; - frog->hopTimer = 40; - } - break; - case FROG_FLAT: - frog->hopTimer -= updateRate; - if (frog->hopTimer < 0) { - frog->action = FROG_UNSQUISH; - play_sound_at_position(SOUND_PLOP2, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); - } - break; - case FROG_UNSQUISH: - if (frog->scaleY > 1.0f) { - frog->scaleY = 1.0f; - frog->action = FROG_IDLE; - frog->hopTimer = 0; - frog->squishCooldown = 60; - } else { - frog->scaleY += 0.15f * updateRateF; - } - break; + break; } } @@ -5852,7 +5914,7 @@ void obj_loop_pigrocketeer(Object *obj, s32 updateRate) { /** * Overworld level name init behaviour. * Sets level name and radius based off spawn info. -*/ + */ void obj_init_levelname(Object *obj, LevelObjectEntry_LevelName *entry) { obj->properties.levelName.radius = entry->radius * 8.0f; obj->properties.levelName.radius *= obj->properties.levelName.radius; @@ -5867,7 +5929,7 @@ void obj_init_levelname(Object *obj, LevelObjectEntry_LevelName *entry) { /** * Overworld level name loop behaviour. * Placed at a level entrance, when a player gets near, display the level name on screen. -*/ + */ void obj_loop_levelname(Object *obj, s32 updateRate) { s32 textWidth; s32 x1; diff --git a/src/object_functions.h b/src/object_functions.h index 3d1a97d9..8a41c47b 100644 --- a/src/object_functions.h +++ b/src/object_functions.h @@ -269,7 +269,7 @@ void obj_init_stopwatchman(Object *obj, LevelObjectEntry_StopWatchMan *entry); void play_tt_voice_clip(u16 soundID, s32 interrupt); void obj_init_lavaspurt(Object *obj, LevelObjectEntry_LavaSpurt *entry); void obj_init_posarrow(Object *obj, LevelObjectEntry_PosArrow *entry); -void obj_init_animator(Object *obj, LevelObjectEntry_Animator *entry, s32 arg2); +void obj_init_animator(Object *obj, LevelObjectEntry_Animator *entry, s32 param); void obj_loop_animobject(Object *obj, s32 updateRate); void obj_loop_dooropener(Object *obj, s32 updateRate); void obj_init_overridepos(Object *obj, LevelObjectEntry_OverridePos *entry); @@ -302,7 +302,7 @@ void obj_loop_setuppoint(Object *obj, s32 updateRate); void obj_init_dino_whale(Object *obj, LevelObjectEntry_Dino_Whale *entry); void obj_loop_dino_whale(Object *obj, s32 updateRate); void obj_init_parkwarden(Object *obj, LevelObjectEntry_Parkwarden *entry); -void set_taj_voice_line(s16 voiceClip); +void set_taj_voice_line(s16 soundID); void play_taj_voice_clip(u16 soundID, s32 interrupt); void obj_loop_gbparkwarden(Object *obj, s32 updateRate); f32 get_npc_pos_y(void); @@ -361,7 +361,7 @@ void obj_loop_wizpigship(Object* wizShipObj, s32 updateRate); void obj_loop_silvercoin(Object *obj, s32 updateRate); void obj_loop_bombexplosion(Object *obj, s32 updateRate); void obj_loop_flycoin(Object *obj, s32 updateRate); -void func_8003FC44(f32 x, f32 y, f32 z, s32 objectID, s32 arg4, f32 scale, s32 arg6); +void func_8003FC44(f32 x, f32 y, f32 z, s32 objectID, s32 soundID, f32 scale, s32 arg6); void obj_loop_stopwatchman(Object *obj, s32 updateRate); void obj_loop_parkwarden(Object *obj, s32 updateRate); void obj_loop_bridge_whaleramp(Object *obj, s32 updateRate); @@ -370,7 +370,7 @@ void obj_loop_levelname(Object *obj, s32 updateRate); void obj_loop_banana(Object *obj, s32 updateRate); void obj_loop_collectegg(Object *obj, s32 updateRate); void obj_loop_weather(Object *obj, s32 updateRate); -void obj_init_groundzipper(Object *arg0, LevelObjectEntry_GroundZipper *entry); +void obj_init_groundzipper(Object *obj, LevelObjectEntry_GroundZipper *entry); void obj_init_goldenballoon(Object *obj, LevelObjectEntry_GoldenBalloon *entry); void obj_init_midifadepoint(Object *obj, LevelObjectEntry_MidiFadePoint *entry); void obj_loop_trigger(Object *obj, s32 updateRate); @@ -417,12 +417,12 @@ void handle_rocket_projectile(Object *obj, s32 updateRate); //Non Matching void calc_env_mapping_for_object(ObjectModel *, s16, s16, s16); -void obj_init_fish(Object *obj, LevelObjectEntry_Fish *entry, s32 param); +void obj_init_fish(Object *fishObj, LevelObjectEntry_Fish *fishEntry, s32 param); void obj_init_midifade(Object *obj, LevelObjectEntry_MidiFade *entry); void obj_loop_texscroll(Object *obj, s32 updateRate); void obj_loop_butterfly(Object *obj, s32 updateRate); void obj_loop_animator(Object *obj, s32 updateRate); -s32 func_8001C524(f32 x, f32 y, f32 z, s32 arg3); +s32 func_8001C524(f32 diffX, f32 diffY, f32 diffZ, s32 someFlag); s32 func_8001CC48(s32, s32, s32); f32 func_8001C6C4(Object_64 *, Object *, f32, f32, s32); void func_8000CBF0(Object*, s32); diff --git a/src/object_models.c b/src/object_models.c index c3f33fea..186aac7c 100644 --- a/src/object_models.c +++ b/src/object_models.c @@ -46,7 +46,7 @@ s32 D_8011D644; /** * Allocate memory for object model ID's and animation tables. -*/ + */ void allocate_object_model_pools(void) { s32 i; s32 checksum; @@ -69,7 +69,7 @@ void allocate_object_model_pools(void) { // Antipiracy measure checksum = 0; for (i = 0; i < gTrackRenderFuncLength; i++) { - checksum += *(u8 *)(((s32) &render_scene) + i); + checksum += *(u8 *) (((s32) &render_scene) + i); } if (checksum != gTractionTableChecksum) { antipiracy_modify_surface_traction_table(); @@ -79,7 +79,7 @@ void allocate_object_model_pools(void) { /** * Load the associated model ID and assign it to the objects gfx data. * Also loads textures and animations. -*/ + */ Object_68 *object_model_init(s32 modelID, s32 flags) { s32 i; s32 sp50; @@ -97,8 +97,8 @@ Object_68 *object_model_init(s32 modelID, s32 flags) { } // Check if the model already exists in the cache. - for(i = 0; i < D_8011D62C; i++) { - if(modelID == D_8011D624[(i << 1)]) { + for (i = 0; i < D_8011D62C; i++) { + if (modelID == D_8011D624[(i << 1)]) { objMdl = (ObjectModel *) D_8011D624[(i << 1) + 1]; ret = func_8005FCD0(objMdl, flags); if (ret != NULL) { @@ -107,7 +107,7 @@ Object_68 *object_model_init(s32 modelID, s32 flags) { return ret; } } - + if (D_8011D634 > 0) { D_8011D634--; sp50 = D_8011D628[D_8011D634]; @@ -128,7 +128,7 @@ Object_68 *object_model_init(s32 modelID, s32 flags) { gzip_inflate((u8 *) compressedData, (u8 *) objMdl); objMdl->textures = (TextureInfo *) ((s32) objMdl->textures + (u8 *) objMdl); objMdl->vertices = (Vertex *) ((s32) objMdl->vertices + (u8 *) objMdl); - objMdl->triangles = (Triangle*) ((s32) objMdl->triangles + (u8 *) objMdl); + objMdl->triangles = (Triangle *) ((s32) objMdl->triangles + (u8 *) objMdl); objMdl->batches = (TriangleBatchInfo *) ((s32) objMdl->batches + (u8 *) objMdl); objMdl->unk14 = (s16 *) ((s32) objMdl->unk14 + (u8 *) objMdl); objMdl->unk1C = (s16 *) ((s32) objMdl->unk1C + (u8 *) objMdl); @@ -149,8 +149,9 @@ Object_68 *object_model_init(s32 modelID, s32 flags) { } } if (!sp3F) { - for(i = 0; i < objMdl->numberOfBatches; i++) { - if ((objMdl->batches[i].textureIndex != 0xFF) && (objMdl->batches[i].textureIndex >= objMdl->numberOfTextures)) { + for (i = 0; i < objMdl->numberOfBatches; i++) { + if ((objMdl->batches[i].textureIndex != 0xFF) && + (objMdl->batches[i].textureIndex >= objMdl->numberOfTextures)) { stubbed_printf(D_800E6B4C); goto block_30; } @@ -168,7 +169,7 @@ Object_68 *object_model_init(s32 modelID, s32 flags) { } } block_30: - free_model_data((ObjectModel* ) objMdl); + free_model_data((ObjectModel *) objMdl); return NULL; } @@ -232,8 +233,8 @@ Object_68 *func_8005FCD0(ObjectModel *model, s32 arg1) { vertex++; mdlVertex++; temp++; - } while(temp < model->numberOfVertices); - + } while (temp < model->numberOfVertices); + temp = 0; vertex = result->unk4[1]; mdlVertex = &model->vertices[0]; @@ -248,20 +249,20 @@ Object_68 *func_8005FCD0(ObjectModel *model, s32 arg1) { vertex++; mdlVertex++; temp++; - } while(temp < model->numberOfVertices); + } while (temp < model->numberOfVertices); } return result; } /** * Attempts to free the object model from RAM. -*/ + */ void free_3d_model(ObjectModel **modelPtr) { UNUSED s32 pad; s32 modelIndex; ObjectModel *model; s32 i; - + if (modelPtr != 0) { model = *modelPtr; model->references--; @@ -269,14 +270,14 @@ void free_3d_model(ObjectModel **modelPtr) { free_from_memory_pool(modelPtr); return; } - + modelIndex = -1; for (i = 0; i < D_8011D62C; i++) { if ((s32) model == D_8011D624[(i << 1) + 1]) { modelIndex = i; } } - + if (modelIndex != -1) { free_model_data(model); D_8011D628[D_8011D634] = modelIndex; @@ -290,7 +291,7 @@ void free_3d_model(ObjectModel **modelPtr) { /** * Frees all associated meshes, textures and animations from the model. -*/ + */ void free_model_data(ObjectModel *mdl) { // free the textures s16 numTextures = mdl->numberOfTextures; @@ -379,9 +380,8 @@ s32 func_80060C58(Vertex *vertices, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { } } } - end: +end: return 0; - } GLOBAL_ASM("asm/non_matchings/object_models/func_80060EA8.s") @@ -405,7 +405,7 @@ s32 func_80061A00(ObjectModel *model, s32 animTableIndex) { s32 *temp; start = gAnimationTable[animTableIndex]; - end = gAnimationTable[animTableIndex+1]; + end = gAnimationTable[animTableIndex + 1]; if (start == end) { model->numberOfAnimations = 0; return 0; @@ -425,12 +425,12 @@ s32 func_80061A00(ObjectModel *model, s32 animTableIndex) { i2 = 0; do { assetOffset = gObjectAnimationTable[start]; - animAddress = gObjectAnimationTable[start+1] - assetOffset; + animAddress = gObjectAnimationTable[start + 1] - assetOffset; assetSize = animAddress; size = get_asset_uncompressed_size(ASSET_OBJECT_ANIMATIONS, assetOffset) + 0x80; model->animations[i].animData = (u8 *) allocate_from_main_pool(size, COLOUR_TAG_RED); if (model->animations[i].animData == NULL) { - for(j = 0; j < i2; j++) { + for (j = 0; j < i2; j++) { free_from_memory_pool(model->animations[j].animData); } free_from_memory_pool(model->animations); @@ -439,7 +439,7 @@ s32 func_80061A00(ObjectModel *model, s32 animTableIndex) { } animAddress = (u32) (model->animations[i].animData + size) - assetSize; load_asset_to_address(ASSET_OBJECT_ANIMATIONS, animAddress, assetOffset, assetSize); - gzip_inflate((u8* ) animAddress, (u8 *) model->animations[i].anim); + gzip_inflate((u8 *) animAddress, (u8 *) model->animations[i].anim); temp = model->animations[i].anim; model->animations[i].unk4 = *temp; model->animations[i].anim++; diff --git a/src/object_models.h b/src/object_models.h index d0cb10e9..3212aed6 100644 --- a/src/object_models.h +++ b/src/object_models.h @@ -21,9 +21,9 @@ void free_3d_model(ObjectModel **modelPtr); s32 func_80061A00(ObjectModel *model, s32 animTableIndex); s32 check_nearby_vertices(Vertex *vertices, s32 arg1, s32 arg2, s32 arg3, s32 arg4); Object_68 *func_8005FCD0(ObjectModel *model, s32 arg1); -Object_68 *object_model_init(s32 arg0, s32 arg1); +Object_68 *object_model_init(s32 modelID, s32 flags); -void free_model_data(ObjectModel *model); //Non Matching +void free_model_data(ObjectModel *mdl); // Non Matching void func_80060910(ObjectModel *); s32 func_80060AC8(ObjectModel *mdl, s32 arg1, s32 arg2, s32 arg3, s32 *outBatchIndex, s32 *outVertexIndex); s32 func_80060EA8(ObjectModel *); diff --git a/src/objects.c b/src/objects.c index b2b78de1..a34c4e78 100644 --- a/src/objects.c +++ b/src/objects.c @@ -35,7 +35,7 @@ #define OBJECT_POOL_SIZE 0x15800 #define OBJECT_SPAWN_HEAP_SIZE 0x800 #define OBJECT_SLOT_COUNT 512 -#define ASSET_OBJECT_HEADER_TABLE_LENGTH 304 //This isn't important, but it's the number of object headers +#define ASSET_OBJECT_HEADER_TABLE_LENGTH 304 // This isn't important, but it's the number of object headers /************ .data ************/ @@ -61,57 +61,100 @@ s8 D_800DC73C = 0; s8 D_800DC740 = 0; s8 gSwapLeadPlayer = FALSE; s8 D_800DC748 = 0; -s32 D_800DC74C[2] = {0, 0}; // Have a feeling these are both the same array. -s32 D_800DC754[2] = {0, 0}; +s32 D_800DC74C[2] = { 0, 0 }; // Have a feeling these are both the same array. +s32 D_800DC754[2] = { 0, 0 }; Object *gShieldEffectObject = NULL; s32 D_800DC760 = 9; // Currently unknown, might be a different type. Object *gMagnetEffectObject = NULL; s32 D_800DC768 = 0; // Currently unknown, might be a different type. UNUSED f32 D_800DC76C[15] = { - 1.0f, 0.70711f, 0.70711f, 1.0f, - 0.0f, 0.70711f, -0.70711f, 0.0f, - -1.0f, -0.70711f, -0.70711f, -1.0f, - 0.0f, -0.70711f, 0.70711f, + 1.0f, 0.70711f, 0.70711f, 1.0f, 0.0f, 0.70711f, -0.70711f, 0.0f, + -1.0f, -0.70711f, -0.70711f, -1.0f, 0.0f, -0.70711f, 0.70711f, }; u16 D_800DC7A8[8] = { - BHV_RACER, BHV_SCENERY, BHV_FISH, BHV_ANIMATOR, - BHV_ANIMATED_OBJECT_2, BHV_WIZPIG_SHIP, BHV_ANIMATED_OBJECT_3, BHV_ANIMATED_OBJECT_4, + BHV_RACER, + BHV_SCENERY, + BHV_FISH, + BHV_ANIMATOR, + BHV_ANIMATED_OBJECT_2, + BHV_WIZPIG_SHIP, + BHV_ANIMATED_OBJECT_3, + BHV_ANIMATED_OBJECT_4, }; s16 D_800DC7B8[52] = { - 0x00ED, 0x00FF, BHV_TRIGGER, BHV_VEHICLE_ANIMATION, - BHV_ZIPPER_WATER, BHV_UNK_3A, BHV_TAJ_TELEPOINT, BHV_SILVER_COIN, - BHV_BOOST, BHV_WARDEN_SMOKE, 0x00F3, 0x00FD, - BHV_TREASURE_SUCKER, BHV_LOG, BHV_LAVA_SPURT, BHV_POS_ARROW, - BHV_UNK_5B, BHV_UNK_5C, BHV_ZIPPER_AIR, BHV_UNK_5E, - 0x00F4, 0x0101, BHV_RACER, BHV_SCENERY, - BHV_FISH, BHV_ANIMATOR, BHV_ANIMATED_OBJECT_2, BHV_WIZPIG_SHIP, - BHV_ANIMATED_OBJECT_3, BHV_ANIMATED_OBJECT_4, 0x00ED, 0x00FF, - BHV_RACER, BHV_SCENERY, BHV_FISH, BHV_ANIMATOR, - BHV_ANIMATED_OBJECT_2, BHV_WIZPIG_SHIP, BHV_ANIMATED_OBJECT_3, BHV_ANIMATED_OBJECT_4, - 0x00ED, 0x00FF, 0x00D9, 0x00DF, - 0x00E0, 0x0105, 0x008A, 0x00DA, - 0x00E8, 0x0115, 0x0118, BHV_NONE, + 0x00ED, + 0x00FF, + BHV_TRIGGER, + BHV_VEHICLE_ANIMATION, + BHV_ZIPPER_WATER, + BHV_UNK_3A, + BHV_TAJ_TELEPOINT, + BHV_SILVER_COIN, + BHV_BOOST, + BHV_WARDEN_SMOKE, + 0x00F3, + 0x00FD, + BHV_TREASURE_SUCKER, + BHV_LOG, + BHV_LAVA_SPURT, + BHV_POS_ARROW, + BHV_UNK_5B, + BHV_UNK_5C, + BHV_ZIPPER_AIR, + BHV_UNK_5E, + 0x00F4, + 0x0101, + BHV_RACER, + BHV_SCENERY, + BHV_FISH, + BHV_ANIMATOR, + BHV_ANIMATED_OBJECT_2, + BHV_WIZPIG_SHIP, + BHV_ANIMATED_OBJECT_3, + BHV_ANIMATED_OBJECT_4, + 0x00ED, + 0x00FF, + BHV_RACER, + BHV_SCENERY, + BHV_FISH, + BHV_ANIMATOR, + BHV_ANIMATED_OBJECT_2, + BHV_WIZPIG_SHIP, + BHV_ANIMATED_OBJECT_3, + BHV_ANIMATED_OBJECT_4, + 0x00ED, + 0x00FF, + 0x00D9, + 0x00DF, + 0x00E0, + 0x0105, + 0x008A, + 0x00DA, + 0x00E8, + 0x0115, + 0x0118, + BHV_NONE, }; // A table of which vehicles to use for boss races. // https://www.youtube.com/watch?v=WQJAtns_rMk BossRaceVehicles gBossVehicles[] = { - {VEHICLE_CAR, VEHICLE_TRICKY}, // Tricky 1 - {VEHICLE_HOVERCRAFT, VEHICLE_BLUEY}, // Bluey 1 - {VEHICLE_PLANE, VEHICLE_SMOKEY}, // Smokey 1 - {VEHICLE_CAR, VEHICLE_TRICKY}, // Tricky 2 - {VEHICLE_HOVERCRAFT, VEHICLE_BLUEY}, // Bluey 2 - {VEHICLE_HOVERCRAFT, VEHICLE_BUBBLER}, // Bubbler 1 - {VEHICLE_HOVERCRAFT, VEHICLE_BUBBLER}, // Bubbler 2 - {VEHICLE_PLANE, VEHICLE_SMOKEY}, // Smokey 2 - {VEHICLE_CAR, VEHICLE_WIZPIG}, // Wizpig 1 - {VEHICLE_PLANE, VEHICLE_ROCKET}, // Wizpig 2 + { VEHICLE_CAR, VEHICLE_TRICKY }, // Tricky 1 + { VEHICLE_HOVERCRAFT, VEHICLE_BLUEY }, // Bluey 1 + { VEHICLE_PLANE, VEHICLE_SMOKEY }, // Smokey 1 + { VEHICLE_CAR, VEHICLE_TRICKY }, // Tricky 2 + { VEHICLE_HOVERCRAFT, VEHICLE_BLUEY }, // Bluey 2 + { VEHICLE_HOVERCRAFT, VEHICLE_BUBBLER }, // Bubbler 1 + { VEHICLE_HOVERCRAFT, VEHICLE_BUBBLER }, // Bubbler 2 + { VEHICLE_PLANE, VEHICLE_SMOKEY }, // Smokey 2 + { VEHICLE_CAR, VEHICLE_WIZPIG }, // Wizpig 1 + { VEHICLE_PLANE, VEHICLE_ROCKET }, // Wizpig 2 }; -s8 D_800DC820[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +s8 D_800DC820[10] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; s8 D_800DC840[8] = { 9, 1, 2, 3, 4, 5, 7, 0 }; @@ -158,7 +201,7 @@ f32 D_8011AD28; s32 D_8011AD2C; f32 gCurrentLightIntensity; Object *D_8011AD34; -s32 D_8011AD38; //D_8011AD38 is ultimately set by func_80074B34, and is almost definitely SIDeviceStatus +s32 D_8011AD38; // D_8011AD38 is ultimately set by func_80074B34, and is almost definitely SIDeviceStatus s8 D_8011AD3C; s8 D_8011AD3D; s8 D_8011AD3E; @@ -200,9 +243,9 @@ s8 (*D_8011ADCC)[8]; f32 D_8011ADD0; s8 D_8011ADD4; s8 D_8011ADD5; -Object *D_8011ADD8[10]; //Array of OverRidePos objects -s8 D_8011AE00; //Number of OverRidePos objects in D_8011ADD8 -s8 D_8011AE01; //A boolean? I've seen it either as 0 or 1 +Object *D_8011ADD8[10]; // Array of OverRidePos objects +s8 D_8011AE00; // Number of OverRidePos objects in D_8011ADD8 +s8 D_8011AE01; // A boolean? I've seen it either as 0 or 1 s8 gIsNonCarRacers; s8 gIsSilverCoinRace; Object *D_8011AE08[16]; @@ -217,13 +260,13 @@ s32 gParticleCount; Object *gObjectMemoryPool; Object **D_8011AE6C; s32 D_8011AE70; -Object **D_8011AE74; //Pointer to an array of Animation objects -s16 D_8011AE78; //Number of Animation objects in D_8011AE74 +Object **D_8011AE74; // Pointer to an array of Animation objects +s16 D_8011AE78; // Number of Animation objects in D_8011AE74 s16 gCutsceneID; s16 D_8011AE7C; s8 D_8011AE7E; s16 gTTGhostTimeToBeat; -s16 D_8011AE82; //Current Vehicle being used in track? +s16 D_8011AE82; // Current Vehicle being used in track? s16 gMapDefaultVehicle; // Vehicle enum s32 D_8011AE88; Gfx *gObjectCurrDisplayList; @@ -243,7 +286,7 @@ s32 gNumberOfCheckpoints; s32 D_8011AED4; s16 gTajChallengeType; Object *(*gCameraObjList)[20]; // Camera objects with a maximum of 20 -s32 gCameraObjCount; //The number of camera objects in the above list +s32 gCameraObjCount; // The number of camera objects in the above list Object *(*gRacers)[10]; // Similar to gRacers, but sorts the pointer by the players' current position in the race. Object **gRacersByPosition; @@ -294,8 +337,8 @@ GLOBAL_ASM("asm/non_matchings/objects/func_8000B020.s") struct TempStruct9 { u8 pad[0x78]; - Sprite* unk78; - TextureHeader* unk7C; + Sprite *unk78; + TextureHeader *unk7C; }; void func_8000B290(void) { @@ -307,7 +350,7 @@ void func_8000B290(void) { temp_a0 = D_800DC754[0]; if (temp_a0 != 0) { - free_from_memory_pool((void* ) temp_a0); + free_from_memory_pool((void *) temp_a0); D_800DC754[0] = 0; D_800DC754[1] = 0; D_800DC74C[0] = 0; @@ -326,12 +369,14 @@ void func_8000B290(void) { var_s0[i].unk7C = 0; } } - if (gShieldEffectObject) + if (gShieldEffectObject) { free_object(gShieldEffectObject); + } gShieldEffectObject = NULL; - if (gMagnetEffectObject) + if (gMagnetEffectObject) { free_object(gMagnetEffectObject); + } gMagnetEffectObject = NULL; gParticlePtrList_flush(); } @@ -346,7 +391,7 @@ void func_8000BADC(s32 updateRate) { Asset20 *asset20; f32 updateRateF; Object_Racer *racer; - + D_8011B008 = 1 - D_8011B008; D_8011AFFC = 0; D_8011B004 = 0; @@ -393,7 +438,7 @@ void func_8000BADC(s32 updateRate) { if (asset20Part->unk74 > 1.0f) { asset20Part->unk74 = 1.0f; } - } + } } } else { if (asset20Part->unk73 > 0) { @@ -454,7 +499,7 @@ Object *func_8000BF44(s32 arg0) { /** * Allocate memory for objects and object related systems. * This includes the objects themselves, particles, and all of the pointer lists for tracking objects. -*/ + */ void allocate_object_pools(void) { s32 i; @@ -497,8 +542,10 @@ void allocate_object_pools(void) { gAssetsMiscTableLength++; } - decrypt_magic_codes(&gAssetsMiscSection[gAssetsMiscTable[ASSET_MISC_MAGIC_CODES]], - (gAssetsMiscTable[ASSET_MISC_TITLE_SCREEN_DEMO_IDS] - gAssetsMiscTable[ASSET_MISC_MAGIC_CODES]) * sizeof(s32 *)); + decrypt_magic_codes( + &gAssetsMiscSection[gAssetsMiscTable[ASSET_MISC_MAGIC_CODES]], + (gAssetsMiscTable[ASSET_MISC_TITLE_SCREEN_DEMO_IDS] - gAssetsMiscTable[ASSET_MISC_MAGIC_CODES]) * + sizeof(s32 *)); gObjPtrList = allocate_from_main_pool_safe(sizeof(uintptr_t) * OBJECT_SLOT_COUNT, COLOUR_TAG_BLUE); gFirstTimeFinish = 0; gTimeTrialEnabled = 0; @@ -514,15 +561,18 @@ void decrypt_magic_codes(s32 *data, s32 length) { u8 sp2; u8 sp1; u8 sp0; - //s32 numWords; + // s32 numWords; s32 i; - //numWords = length / 4; + // numWords = length / 4; for (i = 0; i < length; i++) { - sp0 = ((data[i + 3] & 0xC0) >> 6) | (data[i + 0] & 0xC0) | ((data[i + 1] & 0xC0) >> 2) | ((data[i + 2] & 0xC0) >> 4); - sp1 = ((data[i + 3] & 0x30) >> 4) | ((data[i + 0] & 0x30) << 2) | (data[i + 1] & 0x30) | ((data[i + 2] & 0x30) >> 2); - sp2 = ((data[i + 3] & 0xC) >> 2) | ((data[i + 0] & 0xC) << 4) | ((data[i + 1] & 0xC) << 2) | (data[i + 2] & 0xC); + sp0 = ((data[i + 3] & 0xC0) >> 6) | (data[i + 0] & 0xC0) | ((data[i + 1] & 0xC0) >> 2) | + ((data[i + 2] & 0xC0) >> 4); + sp1 = ((data[i + 3] & 0x30) >> 4) | ((data[i + 0] & 0x30) << 2) | (data[i + 1] & 0x30) | + ((data[i + 2] & 0x30) >> 2); + sp2 = + ((data[i + 3] & 0xC) >> 2) | ((data[i + 0] & 0xC) << 4) | ((data[i + 1] & 0xC) << 2) | (data[i + 2] & 0xC); sp3 = (data[i + 3] & 3) | (data[i + 0] << 6) | ((data[i + 1] & 3) << 4) | ((data[i + 2] & 3) << 2); data[i + 0] = ((sp0 & 0x55) << 1) | ((sp0 & 0xAA) >> 1); data[i + 1] = ((sp1 & 0x55) << 1) | ((sp1 & 0xAA) >> 1); @@ -535,8 +585,9 @@ GLOBAL_ASM("asm/non_matchings/objects/decrypt_magic_codes.s") #endif /** - * Set all object counters and headers to zero, effectively telling the game there are no objects currently in the scene. -*/ + * Set all object counters and headers to zero, effectively telling the game there are no objects currently in the + * scene. + */ void clear_object_pointers(void) { s32 i; @@ -586,7 +637,7 @@ void clear_object_pointers(void) { /** * Clear all objects from memory. Also clear rumble. * Swap lead player in adventure two if the other player finished ahead of the lead player. -*/ + */ void free_all_objects(void) { s32 i, len; free_tt_ghost_data(); @@ -616,7 +667,7 @@ void free_all_objects(void) { * Set the object's header. * Search if the intended header is already loaded and use that. * Otherwise, allocate space and load it into ROM and set it to that. -*/ + */ ObjectHeader *load_object_header(s32 index) { s32 assetOffset; s32 size; @@ -632,7 +683,8 @@ ObjectHeader *load_object_header(s32 index) { if (address != NULL) { load_asset_to_address(ASSET_OBJECT_HEADERS, (u32) address, assetOffset, size); address->unk24 = (ObjectHeader24 *) ((uintptr_t) address + (uintptr_t) address->unk24); - address->objectParticles = (ObjHeaderParticleEntry *) ((uintptr_t) address + (uintptr_t) address->objectParticles); + address->objectParticles = + (ObjHeaderParticleEntry *) ((uintptr_t) address + (uintptr_t) address->objectParticles); address->vehiclePartIds = (s32 *) ((uintptr_t) address + (uintptr_t) address->vehiclePartIds); address->vehiclePartIndices = (s8 *) ((uintptr_t) address + (uintptr_t) address->vehiclePartIndices); address->modelIds = (s32 *) ((uintptr_t) address + (uintptr_t) address->modelIds); @@ -647,7 +699,7 @@ ObjectHeader *load_object_header(s32 index) { /** * Remove this object from the loaded header's references. * If the reference number is zero, free the header. -*/ + */ void try_free_object_header(s32 index) { if ((*gObjectHeaderReferences)[index] != 0) { (*gObjectHeaderReferences)[index]--; @@ -684,8 +736,9 @@ void func_8000C8F8(s32 arg0, s32 arg1) { settings = get_settings(); assetOffset = settings->bosses | 0x820; // 0x820 = Wizpig 2 and some unknown 0x800 boss bit - gIsSilverCoinRace = ((settings->courseFlagsPtr[settings->courseId] & 4) == 0) && (((1 << settings->worldId) & assetOffset) != 0); - + gIsSilverCoinRace = + ((settings->courseFlagsPtr[settings->courseId] & 4) == 0) && (((1 << settings->worldId) & assetOffset) != 0); + if (!(settings->courseFlagsPtr[settings->courseId] & 2)) { gIsSilverCoinRace = 0; } @@ -695,7 +748,7 @@ void func_8000C8F8(s32 arg0, s32 arg1) { if (get_current_level_race_type()) { gIsSilverCoinRace = 0; } - + D_8011AD3E = 0; mem = allocate_from_main_pool_safe(0x3000, COLOUR_TAG_BLUE); D_8011AEB0[arg1] = mem; @@ -703,17 +756,19 @@ void func_8000C8F8(s32 arg0, s32 arg1) { D_8011AEA0[arg1] = 0; D_8011AEA8[arg1] = arg0; objMapTable = (u32 *) load_asset_section_from_rom(ASSET_LEVEL_OBJECT_MAPS_TABLE); - for (i = 0; objMapTable[i] != 0xFFFFFFFF; i++) { } + for (i = 0; objMapTable[i] != 0xFFFFFFFF; i++) {} i--; if (arg0 >= i) { arg0 = 0; } assetOffset = objMapTable[arg0]; - assetSize = objMapTable[arg0+1] - assetOffset; + assetSize = objMapTable[arg0 + 1] - assetOffset; if (assetSize != 0) { compressedAsset = (u8 *) mem; - compressedAsset = ((compressedAsset + get_asset_uncompressed_size(ASSET_LEVEL_OBJECT_MAPS, assetOffset)) - (0, assetSize)) + 0x20; + compressedAsset = + ((compressedAsset + get_asset_uncompressed_size(ASSET_LEVEL_OBJECT_MAPS, assetOffset)) - (0, assetSize)) + + 0x20; load_asset_to_address(ASSET_LEVEL_OBJECT_MAPS, (u32) compressedAsset, assetOffset, assetSize); gzip_inflate(compressedAsset, (u8 *) mem); free_from_memory_pool(objMapTable); @@ -721,7 +776,7 @@ void func_8000C8F8(s32 arg0, s32 arg1) { D_8011AEA0[arg1] = *mem; D_8011AEC0 = arg1; for (var_s0 = 0; var_s0 < D_8011AEA0[arg1]; var_s0 += temp_t3) { - spawn_object((LevelObjectEntryCommon *) D_8011AE98[arg1], 1); + spawn_object((LevelObjectEntryCommon *) D_8011AE98[arg1], 1); D_8011AE98[arg1] = &D_8011AE98[arg1][temp_t3 = D_8011AE98[arg1][1] & 0x3F]; } D_8011AE98[arg1] = (u8 *) (D_8011AEB0[arg1] + 4); @@ -739,8 +794,10 @@ void func_8000C8F8(s32 arg0, s32 arg1) { // Reset all values of D_8011AE08 to NULL void func_8000CBC0(void) { - s32 i; //Required to be one line to match + s32 i; // Required to be one line to match + // clang-format off for (i = 0; i < ARRAY_COUNT(D_8011AE08); i++) { D_8011AE08[i] = NULL; } + // clang-format on } // Set the object value for the given index if it's not already set @@ -748,7 +805,7 @@ void func_8000CBF0(Object *obj, s32 index) { if (D_8011AE08[index] == NULL) { D_8011AE08[index] = obj; } else { - if(D_8011AE08[index]){} + if (D_8011AE08[index]) {} } } @@ -774,29 +831,29 @@ s32 func_8000CC20(Object *obj) { void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { s32 numPlayers; // sp144 enum GameMode gameMode; - s32 cutsceneID; //sp130 - s8* miscAsset16; + s32 cutsceneID; // sp130 + s8 *miscAsset16; s8 sp11C[8]; s8 sp114[8]; s32 spF4[8]; s32 spD4[8]; s32 spB4[8]; - s32 sp94[8]; - LevelHeader* levelHeader; - ObjectSegment* cutsceneCameraSegment; // sp74 + s32 sp94[8]; + LevelHeader *levelHeader; + ObjectSegment *cutsceneCameraSegment; // sp74 s16 objectId; s8 sp127; u8 raceType; s8 tempVehicle; u8 var_a1; s32 isChallengeMode; // sp64 - s32 i6; // sp54 - LevelObjectEntry_Unk8000CC7C* entry; - Object* curObj; - Object* curRacerObj; - Object* newRacerObj; + s32 i6; // sp54 + LevelObjectEntry_Unk8000CC7C *entry; + Object *curObj; + Object *curRacerObj; + Object *newRacerObj; Object_Racer *curRacer; - Settings* settings; + Settings *settings; s32 spawnObjFlags; s32 racerPos; s32 i2; @@ -813,7 +870,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { levelHeader = get_current_level_header(); raceType = levelHeader->race_type; if (raceType == RACETYPE_CUTSCENE_1 || raceType == RACETYPE_CUTSCENE_2) { - return; + return; } if (raceType == RACETYPE_BOSS || raceType & RACETYPE_CHALLENGE) { gIsTimeTrial = 0; @@ -827,7 +884,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } gameMode = get_game_mode(); settings = get_settings(); - miscAsset16 = (s8*) get_misc_asset(3); + miscAsset16 = (s8 *) get_misc_asset(3); D_8011AE82 = D_8011ADC5; tajFlags = settings->courseFlagsPtr[settings->courseId]; if (!(tajFlags & 1)) { // Check if the player has not visited the course yet. @@ -837,12 +894,12 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { if (raceType != RACETYPE_DEFAULT) { D_8011AF00 = 2; } - for(i2 = 0; i2 < 8; i2++) { + for (i2 = 0; i2 < 8; i2++) { spB4[i2] = 0; spF4[i2] = 0; spD4[i2] = 0; } - for(i2 = 0; i2 < gObjectCount; i2++) { + for (i2 = 0; i2 < gObjectCount; i2++) { curObj = gObjPtrList[i2]; if (!(curObj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED)) { if (curObj->behaviorId == BHV_SETUP_POINT) { @@ -874,7 +931,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { if (raceType == RACETYPE_HUBWORLD) { gTimeTrialEnabled = 0; } - + gIsTimeTrial = gTimeTrialEnabled; if (gIsTimeTrial) { raceType = RACETYPE_HUBWORLD; // ??? @@ -889,7 +946,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } else if (numPlayers == 2) { gNumRacers = get_multiplayer_racer_count(); } - + if (isChallengeMode != 0) { gNumRacers = 4; } @@ -905,13 +962,13 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { D_800DC71C = 1; D_8011AD3C = 2; } - - for(i2 = 0; i2 < gNumRacers; i2++) { + + for (i2 = 0; i2 < gNumRacers; i2++) { sp11C[i2] = 0; } - + var_a1 = 0; - for(i2 = 0; i2 < numPlayers; i2++) { + for (i2 = 0; i2 < numPlayers; i2++) { racerPos = settings->racers[i2].starting_position; if (racerPos < gNumRacers) { if (sp11C[racerPos] == 0) { @@ -921,7 +978,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } sp114[var_a1++] = (u16) i2; } - + for (i2 = numPlayers; i2 < gNumRacers; i2++) { racerPos = settings->racers[i2].starting_position; if (racerPos < gNumRacers) { @@ -932,7 +989,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } sp114[var_a1++] = (u16) i2; } - + for (i6 = 0; i6 < var_a1; i6++) { for (j = 0; j < gNumRacers; j++) { if (sp11C[j] == 0) { @@ -942,7 +999,8 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } } } - if (((!(curObj->segment.trans.y_rotation)) && (!(curObj->segment.trans.y_rotation))) && (!(curObj->segment.trans.y_rotation))) {} + if (((!(curObj->segment.trans.y_rotation)) && (!(curObj->segment.trans.y_rotation))) && + (!(curObj->segment.trans.y_rotation))) {} entry = allocate_from_main_pool_safe(sizeof(LevelObjectEntry_Unk8000CC7C), COLOUR_TAG_YELLOW); entry->unkC = 0; entry->unkA = 0; @@ -955,12 +1013,12 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { sp127 = -1; i2 = gNumRacers; D_8011AD24[1] = levelHeader->unkB8; - for (i6 = 0; i6 < gNumRacers; i6++) { + for (i6 = 0; i6 < gNumRacers; i6++) { var_s4 = i6; if (raceType != RACETYPE_HUBWORLD && isChallengeMode == 0 && D_8011AD3C == 0) { var_s4 = 0; // This might not be a for loop? - for(j = 0; j < gNumRacers; j++) { + for (j = 0; j < gNumRacers; j++) { if (i6 == settings->racers[j].starting_position) { var_s4 = j; j = i2; @@ -989,7 +1047,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { vehicle = get_player_selected_vehicle(entry->unkE); } } - + // Are these assignments correct? Seems weird. if (D_8011AD3C == 2) { objectId = D_800DC7A8[D_800DC840[i6] + (vehicle * 10)]; @@ -998,13 +1056,13 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } else { objectId = D_800DC7B8[vehicle]; } - + entry->common.objectID = objectId; entry->common.size = ((objectId & 0x100) >> 1) | 0x10; entry->common.x = spF4[i6]; entry->common.y = spD4[i6]; entry->common.z = spB4[i6]; - entry->unkC = sp94[i6]; + entry->unkC = sp94[i6]; if (entry->unkE == 4) { func_800619F4(1); } @@ -1023,7 +1081,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { spawnObjFlags = 1; func_800619F4(0); } - newRacerObj = spawn_object((LevelObjectEntryCommon*)entry, spawnObjFlags); + newRacerObj = spawn_object((LevelObjectEntryCommon *) entry, spawnObjFlags); newRacerObj->segment.trans.y_rotation = sp94[i6]; (*gRacers)[i6] = newRacerObj; gRacersByPosition[i6] = newRacerObj; @@ -1036,7 +1094,8 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { D_8011AD20 = 1; } sp127 = vehicle; - if (curRacer->vehicleID == VEHICLE_PLANE || curRacer->vehicleID == VEHICLE_SMOKEY || curRacer->vehicleID == VEHICLE_PTERODACTYL) { + if (curRacer->vehicleID == VEHICLE_PLANE || curRacer->vehicleID == VEHICLE_SMOKEY || + curRacer->vehicleID == VEHICLE_PTERODACTYL) { gIsNonCarRacers = TRUE; } curRacer->unk1CB = vehicle; @@ -1066,7 +1125,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } else { curRacer->vehicleSound = NULL; } - + newRacerObj->interactObj->pushForce = miscAsset16[curRacer->characterId] + 1; switch (curRacer->vehicleID) { case VEHICLE_TRICKY: @@ -1092,7 +1151,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { D_8011AD20 = 0; } if (get_game_mode() == GAMEMODE_INGAME) { - for(j = 0; j < gObjectCount; j++) { + for (j = 0; j < gObjectCount; j++) { curObj = gObjPtrList[j]; tajFlags = curObj->segment.header->flags; if ((tajFlags & 0x20) && (gIsTimeTrial)) { @@ -1120,7 +1179,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { entry->common.y = spD4[0]; entry->common.z = spB4[0]; entry->unkC = sp94[0]; - newRacerObj = spawn_object((LevelObjectEntryCommon*) entry, 1); + newRacerObj = spawn_object((LevelObjectEntryCommon *) entry, 1); newRacerObj->segment.level_entry = NULL; newRacerObj->behaviorId = BHV_UNK_3A; newRacerObj->shadow->scale = 0.01f; @@ -1136,7 +1195,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { entry->common.y = spD4[0]; entry->common.z = spB4[0]; entry->unkC = sp94[0]; - newRacerObj = spawn_object((LevelObjectEntryCommon*) entry, 1); + newRacerObj = spawn_object((LevelObjectEntryCommon *) entry, 1); newRacerObj->segment.level_entry = NULL; newRacerObj->behaviorId = BHV_UNK_3A; newRacerObj->shadow->scale = 0.01f; @@ -1149,7 +1208,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { for (j = 0; j < gNumRacers; j++) { curRacerObj = (*gRacers)[j]; curRacer = &curRacerObj->unk64->racer; - for(i2 = 0; i2 < 10; i2++) { + for (i2 = 0; i2 < 10; i2++) { update_player_racer(curRacerObj, LOGIC_30FPS); // Simulate 10 updates? } if (curRacer->playerIndex == PLAYER_COMPUTER) { @@ -1187,13 +1246,13 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } if (raceType == RACETYPE_DEFAULT && numPlayers == 1 && !is_in_adventure_two()) { if (is_two_player_adventure_race() == 0) { - for(i2 = 0; i2 < 3; i2++) { + for (i2 = 0; i2 < 3; i2++) { entry->common.objectID = BHV_ANIMATED_OBJECT; entry->common.size = 8; entry->common.x = 0; entry->common.y = 0; entry->common.z = 0; - newRacerObj = spawn_object((LevelObjectEntryCommon*)entry, 1); + newRacerObj = spawn_object((LevelObjectEntryCommon *) entry, 1); newRacerObj->properties.common.unk0 = i2; newRacerObj->segment.level_entry = NULL; } @@ -1205,9 +1264,9 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { if (settings->worldId == WORLD_CENTRAL_AREA) { if (!is_in_tracks_mode()) { var_s4 = 0; - miscAsset16 = (s8*)get_misc_asset(ASSET_MISC_16); + miscAsset16 = (s8 *) get_misc_asset(ASSET_MISC_16); tajFlags = settings->tajFlags; - + // settings->balloonsPtr[0] is the total balloon count. if (!(tajFlags & TAJ_FLAGS_CAR_CHAL_UNLOCKED) && (settings->balloonsPtr[0] >= miscAsset16[0])) { var_s4 = 1; @@ -1216,7 +1275,7 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { } else if (!(tajFlags & TAJ_FLAGS_PLANE_CHAL_UNLOCKED) && (settings->balloonsPtr[0] >= miscAsset16[2])) { var_s4 = 3; } - + if (var_s4) { set_taj_voice_line(SOUND_VOICE_TAJ_CHALLENGE_RACE); settings->tajFlags |= 1 << (var_s4 + 31); @@ -1238,7 +1297,6 @@ void func_8000CC7C(Vehicle vehicle, u32 arg1, s32 arg2) { set_free_queue_state(0); free_from_memory_pool(entry); set_free_queue_state(2); - } #else GLOBAL_ASM("asm/non_matchings/objects/func_8000CC7C.s") @@ -1247,7 +1305,7 @@ GLOBAL_ASM("asm/non_matchings/objects/func_8000CC7C.s") /** * Return an error status for the controller pak. * Categorises multiple different controller pak messages into one for fewer cases. -*/ + */ s32 get_contpak_error(void) { // D_8011AD38 is likely an SIDeviceStatus value, but not 100% sure yet. switch (D_8011AD38) { @@ -1322,7 +1380,7 @@ s8 check_if_silver_coin_race(void) { /** * Store some things about the racer object then remove it. -*/ + */ void despawn_player_racer(Object *obj, s32 vehicleID) { gTransformObject = obj; gTransformTimer = 4; @@ -1338,7 +1396,7 @@ void despawn_player_racer(Object *obj, s32 vehicleID) { /** * Spawn a new racer object and set the initial position and rotation to what was set * before the old one was freed. -*/ + */ void transform_player_vehicle(void) { Object *player; LevelObjectEntry8000E2B4 spawnObj; @@ -1410,7 +1468,7 @@ u8 is_time_trial_enabled(void) { /** * Returns true if the player is currently performaing a time trial. -*/ + */ u8 is_in_time_trial(void) { return gIsTimeTrial; } @@ -1425,14 +1483,16 @@ UNUSED void func_8000E4E8(s32 index) { temp_v0[3] = 0; temp_v0[2] = 0; temp_v0[1] = 0; - temp_a1 = &D_8011AE98[index][D_8011AEA0[index]]; - + temp_a1 = &D_8011AE98[index][D_8011AEA0[index]]; + // The backslash here is needed to match. And no, a for loop doesn't match. + // clang-format off i = 0; \ - while(i < 16) { + while (i < 16) { temp_a1[i] = 0; i++; } + // clang-format on } UNUSED s32 func_8000E558(Object *arg0) { @@ -1479,7 +1539,7 @@ UNUSED u8 *func_8000E898(u8 *arg0, s32 arg1) { /** * Returns the object at the current offset by ID. * Official name: objGetObject -*/ + */ Object *get_object(s32 index) { if (index < 0 || index >= gObjectCount) { return 0; @@ -1489,7 +1549,7 @@ Object *get_object(s32 index) { /** * Return the standard object list index and how many objects are in that list. -*/ + */ Object **objGetObjList(s32 *arg0, s32 *cnt) { *arg0 = gObjectListStart; *cnt = gObjectCount; @@ -1498,14 +1558,14 @@ Object **objGetObjList(s32 *arg0, s32 *cnt) { /** * Return the number of objects currently existing. -*/ + */ UNUSED s32 get_object_count(void) { return gObjectCount; } /** * Return the number of particles currently existing. -*/ + */ UNUSED s32 get_particle_count(void) { return gParticleCount; } @@ -1514,7 +1574,7 @@ void func_8000E9D0(Object *arg0) { arg0->segment.trans.flags |= OBJ_FLAGS_DEACTIVATED; func_800245B4(arg0->segment.object.unk2C | (OBJ_FLAGS_DEACTIVATED | OBJ_FLAGS_INVISIBLE)); gObjPtrList[gObjectCount++] = arg0; - if (1) {} // Fakematch + if (1) {} // Fakematch gParticleCount++; } @@ -1567,7 +1627,8 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { curObj->segment.trans.x_position = entry->x; curObj->segment.trans.y_position = entry->y; curObj->segment.trans.z_position = entry->z; - curObj->segment.object.segmentID = get_level_segment_index_from_position(curObj->segment.trans.x_position, curObj->segment.trans.y_position, curObj->segment.trans.z_position); + curObj->segment.object.segmentID = get_level_segment_index_from_position( + curObj->segment.trans.x_position, curObj->segment.trans.y_position, curObj->segment.trans.z_position); curObj->segment.object.unk2C = var_a0; curObj->segment.level_entry = (LevelObjectEntry *) entry; curObj->unk4A = objType; @@ -1585,48 +1646,48 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { } var_a2 = 0; switch (curObj->segment.header->behaviorId) { - case BHV_PARK_WARDEN: - if ((entry->z && entry->z) && entry->z){} //fakematch - func_800619F4(7); - break; - case BHV_ANIMATED_OBJECT_4: - var_a2 = get_character_id_from_slot(PLAYER_ONE); - curObj->segment.object.modelIndex = var_a2; - assetCount = var_a2 + 1; - break; - case BHV_UNK_5B: - var_a2 = (settings->trophies >> (((settings->worldId - 1) ^ 0) * 2)) & 3; //fakematch - if (var_a2) { - var_a2--; - assetCount = var_a2 + 1; + case BHV_PARK_WARDEN: + if ((entry->z && entry->z) && entry->z) {} // fakematch + func_800619F4(7); + break; + case BHV_ANIMATED_OBJECT_4: + var_a2 = get_character_id_from_slot(PLAYER_ONE); curObj->segment.object.modelIndex = var_a2; - } - break; - case BHV_DYNAMIC_LIGHT_OBJECT_2: - var_a2 = settings->wizpigAmulet; - assetCount = var_a2 + 1; - curObj->segment.object.modelIndex = settings->wizpigAmulet; - break; - case BHV_ROCKET_SIGNPOST_2: - objType = settings->trophies; - //Thanks, I hate it. - for (i = 0; i < 4; i = (i + 1) & 0xFFFFFFFF) { - if ((objType & 3) == 3) { - var_a2++; + assetCount = var_a2 + 1; + break; + case BHV_UNK_5B: + var_a2 = (settings->trophies >> (((settings->worldId - 1) ^ 0) * 2)) & 3; // fakematch + if (var_a2) { + var_a2--; + assetCount = var_a2 + 1; + curObj->segment.object.modelIndex = var_a2; } - objType >>= 2; - } - curObj->segment.object.modelIndex = var_a2; - assetCount = var_a2 + 1; - break; - case BHV_GOLDEN_BALLOON: - assetCount = 1; - var_a2 = 0; - if (is_in_adventure_two()) { - curObj->segment.header->modelIds[0] = curObj->segment.header->modelIds[1]; - } - curObj->segment.header->numberOfModelIds = 1; - break; + break; + case BHV_DYNAMIC_LIGHT_OBJECT_2: + var_a2 = settings->wizpigAmulet; + assetCount = var_a2 + 1; + curObj->segment.object.modelIndex = settings->wizpigAmulet; + break; + case BHV_ROCKET_SIGNPOST_2: + objType = settings->trophies; + // Thanks, I hate it. + for (i = 0; i < 4; i = (i + 1) & 0xFFFFFFFF) { + if ((objType & 3) == 3) { + var_a2++; + } + objType >>= 2; + } + curObj->segment.object.modelIndex = var_a2; + assetCount = var_a2 + 1; + break; + case BHV_GOLDEN_BALLOON: + assetCount = 1; + var_a2 = 0; + if (is_in_adventure_two()) { + curObj->segment.header->modelIds[0] = curObj->segment.header->modelIds[1]; + } + curObj->segment.header->numberOfModelIds = 1; + break; } if (!(arg1 & 2)) { if (curObj->unk4A != 0x19) { @@ -1651,7 +1712,7 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { var_v1 = FALSE; if (objType == 0) { for (var_a2 = var_a2; var_a2 < assetCount; var_a2++) { - if(assetCount){} //FAKEMATCH? + if (assetCount) {} // FAKEMATCH? if (var_a2 == 0 && arg1 & 4) { curObj->unk68[var_a2] = NULL; } else if (var_a2 == 1 && arg1 & 8) { @@ -1705,7 +1766,7 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { address = (u32 *) ((uintptr_t) address + sizeOfobj); if (sizeOfobj == 0) { if (D_8011AE50 != NULL) { - free_texture((u32)D_8011AE50); + free_texture((u32) D_8011AE50); } objFreeAssets(curObj, assetCount, objType); try_free_object_header(var_a0); @@ -1726,18 +1787,17 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { address = (u32 *) ((uintptr_t) address + func_8000FAC4(curObj, (Object_6C *) address)); } sizeOfobj = (uintptr_t) address - (uintptr_t) curObj; - if (curObj->segment.header->numLightSources > 0) - { + if (curObj->segment.header->numLightSources > 0) { curObj->lightData = address; sizeOfobj = (s32) ((uintptr_t) address + (curObj->segment.header->numLightSources * 4)) - (uintptr_t) curObj; } newObj = allocate_from_pool_containing_slots((MemoryPoolSlot *) gObjectMemoryPool, sizeOfobj); if (newObj == NULL) { if (D_8011AE50 != NULL) { - free_texture((u32)D_8011AE50); + free_texture((u32) D_8011AE50); } if (D_8011AE54 != NULL) { - free_texture((u32)D_8011AE54); + free_texture((u32) D_8011AE54); } objFreeAssets(curObj, assetCount, objType); try_free_object_header(var_a0); @@ -1747,44 +1807,49 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { sizeOfobj = (sizeOfobj & ~0xF) + 0x10; } sizeOfobj >>= 2; - + // for (var_s0_5 = 0; var_s0_5 < objSize; var_s0_5++) { // u32 *temp = &newObj[var_s0_5]; // temp = (u32)&(*gSpawnObjectHeap)[var_s0_5]; // } - //WRONG WRONG WRONG - Is this really just trying to set up the first several values in a weird way? - for (var_s0_5 = 0; var_s0_5 < sizeOfobj; var_s0_5+=4) { + // WRONG WRONG WRONG - Is this really just trying to set up the first several values in a weird way? + for (var_s0_5 = 0; var_s0_5 < sizeOfobj; var_s0_5 += 4) { newObj[var_s0_5].segment.trans.y_rotation = (*gSpawnObjectHeap)[var_s0_5]->segment.trans.y_rotation; } if (newObj->waterEffect != NULL) { - newObj->waterEffect = (ShadowData *)(((uintptr_t) newObj + (uintptr_t) newObj->waterEffect) - (uintptr_t) gSpawnObjectHeap); + newObj->waterEffect = + (ShadowData *) (((uintptr_t) newObj + (uintptr_t) newObj->waterEffect) - (uintptr_t) gSpawnObjectHeap); } if (newObj->shadow != NULL) { - newObj->shadow = (ShadowData *)(((uintptr_t) newObj + (uintptr_t)newObj->shadow) - (uintptr_t) gSpawnObjectHeap); + newObj->shadow = + (ShadowData *) (((uintptr_t) newObj + (uintptr_t) newObj->shadow) - (uintptr_t) gSpawnObjectHeap); } if (newObj->shading != NULL) { - newObj->shading = (ShadeProperties *)(((uintptr_t) newObj + (uintptr_t) newObj->shading) - (uintptr_t) gSpawnObjectHeap); + newObj->shading = + (ShadeProperties *) (((uintptr_t) newObj + (uintptr_t) newObj->shading) - (uintptr_t) gSpawnObjectHeap); } if (newObj->unk64 != NULL) { - newObj->unk64 = (Object_64 *)(((uintptr_t) newObj + (uintptr_t) newObj->unk64) - (uintptr_t) gSpawnObjectHeap); + newObj->unk64 = (Object_64 *) (((uintptr_t) newObj + (uintptr_t) newObj->unk64) - (uintptr_t) gSpawnObjectHeap); } if (newObj->interactObj != NULL) { - newObj->interactObj = (ObjectInteraction *)(((uintptr_t) newObj + (uintptr_t) newObj->interactObj) - (uintptr_t) gSpawnObjectHeap); + newObj->interactObj = (ObjectInteraction *) (((uintptr_t) newObj + (uintptr_t) newObj->interactObj) - + (uintptr_t) gSpawnObjectHeap); } if (newObj->unk5C != NULL) { - newObj->unk5C = (Object_5C *)(((uintptr_t) newObj + (uintptr_t) newObj->unk5C) - (uintptr_t) gSpawnObjectHeap); + newObj->unk5C = (Object_5C *) (((uintptr_t) newObj + (uintptr_t) newObj->unk5C) - (uintptr_t) gSpawnObjectHeap); } if (newObj->unk60 != NULL) { - newObj->unk60 = (Object_60 *)(((uintptr_t) newObj + (uintptr_t )newObj->unk60) - (uintptr_t) gSpawnObjectHeap); + newObj->unk60 = (Object_60 *) (((uintptr_t) newObj + (uintptr_t) newObj->unk60) - (uintptr_t) gSpawnObjectHeap); } if (newObj->segment.header->unk57 > 0) { - newObj->unk6C = (Object_6C *)(((uintptr_t) newObj + (uintptr_t )newObj->unk6C) - (uintptr_t) gSpawnObjectHeap); + newObj->unk6C = (Object_6C *) (((uintptr_t) newObj + (uintptr_t) newObj->unk6C) - (uintptr_t) gSpawnObjectHeap); } if (newObj->segment.header->numLightSources > 0) { - newObj->lightData = (u32 *)(((uintptr_t) newObj + (uintptr_t) newObj->lightData) - (uintptr_t) gSpawnObjectHeap); + newObj->lightData = + (u32 *) (((uintptr_t) newObj + (uintptr_t) newObj->lightData) - (uintptr_t) gSpawnObjectHeap); } - newObj->unk68 = (Object_68 **)((uintptr_t) newObj + (uintptr_t) 0x80); + newObj->unk68 = (Object_68 **) ((uintptr_t) newObj + (uintptr_t) 0x80); if (arg1 & 1) { gObjPtrList[gObjectCount] = newObj; gObjectCount++; @@ -1824,7 +1889,7 @@ GLOBAL_ASM("asm/non_matchings/objects/spawn_object.s") /** * Run functions that will attempt to free the graphics data of the object * if there are no other references. -*/ + */ void objFreeAssets(Object *obj, s32 count, s32 objType) { s32 i; if (objType == OBJECT_MODEL_TYPE_3D_MODEL) { // 3D model @@ -1832,13 +1897,13 @@ void objFreeAssets(Object *obj, s32 count, s32 objType) { if (obj->unk68[i] != NULL) { free_3d_model((ObjectModel **) (s32) obj->unk68[i]); } - } + } } else if (objType == OBJECT_MODEL_TYPE_MISC) { for (i = 0; i < count; i++) { if (obj->unk68[i] != NULL) { free_texture((TextureHeader *) (s32) obj->unk68[i]); } - } + } } else { // Sprite for (i = 0; i < count; i++) { if (obj->unk68[i] != NULL) { @@ -1859,7 +1924,7 @@ void light_setup_light_sources(Object *obj) { /** * Sets the shading properties of the object. -*/ + */ s32 init_object_shading(Object *obj, ShadeProperties *shadeData) { s32 returnSize; s32 i; @@ -1867,10 +1932,11 @@ s32 init_object_shading(Object *obj, ShadeProperties *shadeData) { obj->shading = shadeData; returnSize = 0; if (obj->segment.header->modelType == OBJECT_MODEL_TYPE_3D_MODEL) { - for (i = 0; obj->unk68[i] == NULL; i++) { } + for (i = 0; obj->unk68[i] == NULL; i++) {} if (obj->unk68[i] != NULL && obj->unk68[i]->objModel->unk40 != NULL) { - set_shading_properties(obj->shading, obj->segment.header->shadeBrightness, obj->segment.header->shadeAmbient, - 0, obj->segment.header->shadeAngleY, obj->segment.header->shadeAngleZ); + set_shading_properties(obj->shading, obj->segment.header->shadeBrightness, + obj->segment.header->shadeAmbient, 0, obj->segment.header->shadeAngleY, + obj->segment.header->shadeAngleZ); if (obj->segment.header->unk3D != 0) { obj->shading->unk4 = obj->segment.header->unk3A; obj->shading->unk5 = obj->segment.header->unk3B; @@ -1904,10 +1970,10 @@ s32 func_8000F99C(Object *obj) { obj60 = obj->unk60; obj60->unk0 = obj->segment.header->unk56; - obj60->unk0 = obj60->unk0; //Fakematch? + obj60->unk0 = obj60->unk0; // Fakematch? var_s4 = FALSE; for (i = 0; i < obj60->unk0; i++) { - obj60->unk4[i] = func_8000FD54(obj->segment.header->vehiclePartIds[i ^ 0]); //i ^ 0 fakematch + obj60->unk4[i] = func_8000FD54(obj->segment.header->vehiclePartIds[i ^ 0]); // i ^ 0 fakematch if (obj60->unk4[i] == NULL) { var_s4 = TRUE; } @@ -1933,17 +1999,14 @@ s32 func_8000FAC4(Object *obj, Object_6C *arg1) { obj->unk6C = arg1; particleDataEntry = obj->segment.header->objectParticles; - for(i = 0; i < obj->segment.header->unk57; i++) { + for (i = 0; i < obj->segment.header->unk57; i++) { if ((particleDataEntry[i].upper & 0xFFFF0000) == 0xFFFF0000) { - partInitTrigger((Particle *) &obj->unk6C[i], (particleDataEntry[i].upper >> 8) & 0xFF, particleDataEntry[i].upper & 0xFF); + partInitTrigger((Particle *) &obj->unk6C[i], (particleDataEntry[i].upper >> 8) & 0xFF, + particleDataEntry[i].upper & 0xFF); } else { - func_800AF29C((Particle *) &obj->unk6C[i], - (particleDataEntry[i].upper >> 0x18) & 0xFF, - (particleDataEntry[i].upper >> 0x10) & 0xFF, - particleDataEntry[i].upper & 0xFFFF, - (particleDataEntry[i].lower >> 0x10) & 0xFFFF, - particleDataEntry[i].lower & 0xFFFF - ); + func_800AF29C((Particle *) &obj->unk6C[i], (particleDataEntry[i].upper >> 0x18) & 0xFF, + (particleDataEntry[i].upper >> 0x10) & 0xFF, particleDataEntry[i].upper & 0xFFFF, + (particleDataEntry[i].lower >> 0x10) & 0xFFFF, particleDataEntry[i].lower & 0xFFFF); } } return ((obj->segment.header->unk57 << 5) + 3) & ~3; @@ -1952,7 +2015,7 @@ s32 func_8000FAC4(Object *obj, Object_6C *arg1) { /** * Assigns shadow data to an object. Loads and assigns the shadow texture, too. * Returns zero if the texture is missing. -*/ + */ s32 init_object_shadow(Object *obj, ShadowData *shadow) { ObjectHeader *objHeader; @@ -1975,7 +2038,7 @@ s32 init_object_shadow(Object *obj, ShadowData *shadow) { /** * Assigns water effect data to an object. Loads and assigns the effect texture, too. * Returns zero if the texture is missing. -*/ + */ s32 init_object_water_effect(Object *obj, WaterEffect *waterEffect) { obj->waterEffect = waterEffect; waterEffect->scale = obj->segment.header->unk8; @@ -1996,7 +2059,7 @@ s32 init_object_water_effect(Object *obj, WaterEffect *waterEffect) { /** * Writes object interatction properties to the object. * Returns 40, to offset the pointer position used -*/ + */ s32 init_object_interaction_data(Object *obj, ObjectInteraction *interactObj) { obj->interactObj = interactObj; interactObj->distance = 0xFF; @@ -2034,10 +2097,12 @@ Object *func_8000FD54(s32 objectHeaderIndex) { try_free_object_header(objectHeaderIndex); return NULL; } - + + // clang-format off objectAsRawBytes = (u8 *) object; for (i = 0; i < objSize; i++) { objectAsRawBytes[i] = 0; } // Must be one line! (Why not use bzero?) - + // clang-format on + object->segment.trans.flags = OBJ_FLAGS_UNK_0002; object->segment.header = objHeader; object->segment.object.unk2C = objectHeaderIndex; @@ -2048,18 +2113,18 @@ Object *func_8000FD54(s32 objectHeaderIndex) { } numModelIds = object->segment.header->numberOfModelIds; modelType = object->segment.header->modelType; - object->unk68 = (Object_68 **) &object->unk80; - + object->unk68 = (Object_68 **) &object->unk80; + failedToLoadModel = FALSE; if (modelType == OBJECT_MODEL_TYPE_3D_MODEL) { - for(i = 0; i < numModelIds; i++) { + for (i = 0; i < numModelIds; i++) { object->unk68[i] = object_model_init(object->segment.header->modelIds[i], 0); if (object->unk68[i] == NULL) { failedToLoadModel = TRUE; } } } else { - for(i = 0; i < numModelIds; i++) { + for (i = 0; i < numModelIds; i++) { object->unk68[i] = (Object_68 *) func_8007C12C(object->segment.header->modelIds[i], 10); if (object->unk68[i] == NULL) { failedToLoadModel = TRUE; @@ -2072,7 +2137,7 @@ Object *func_8000FD54(s32 objectHeaderIndex) { free_from_memory_pool(object); return NULL; } - + return object; } @@ -2080,7 +2145,7 @@ Object *func_8000FD54(s32 objectHeaderIndex) { * Adds the object to the free list. * This object will be deallocated on the next update cycle. * Official Name: objFreeObject -*/ + */ void free_object(Object *object) { func_800245B4(object->unk4A | OBJ_FLAGS_DEACTIVATED); gParticlePtrList[gFreeListCount] = object; @@ -2108,11 +2173,12 @@ void gParticlePtrList_flush(void) { searchObj = gParticlePtrList[i]; for (j = 0; j < gObjectCount; j++) { - if (searchObj == gObjPtrList[j]) + if (searchObj == gObjPtrList[j]) { search_indx = j; + } } - //if object found + // if object found if (search_indx != -1) { if (search_indx < D_8011AE7C) { D_8011AE7C--; @@ -2131,7 +2197,7 @@ void gParticlePtrList_flush(void) { GLOBAL_ASM("asm/non_matchings/objects/func_800101AC.s") #ifdef NON_MATCHING -//Minor regalloc diffs +// Minor regalloc diffs void func_80010994(s32 updateRate) { s32 i; s32 tempVal; @@ -2162,7 +2228,7 @@ void func_80010994(s32 updateRate) { racer->prev_y_position = (f32) (*gRacers)[i]->segment.trans.y_position; racer->prev_z_position = (f32) (*gRacers)[i]->segment.trans.z_position; } - i = 1; //FAKEMATCH + i = 1; // FAKEMATCH func_800142B8(); process_object_interactions(); func_8001E89C(); @@ -2177,7 +2243,8 @@ void func_80010994(s32 updateRate) { for (i = gObjectListStart; i < tempVal; i++) { obj = gObjPtrList[i]; if (!(obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED)) { - if ((obj->behaviorId != BHV_LIGHT_RGBA) && (obj->behaviorId != BHV_WEAPON) && (obj->behaviorId != BHV_FOG_CHANGER)) { + if ((obj->behaviorId != BHV_LIGHT_RGBA) && (obj->behaviorId != BHV_WEAPON) && + (obj->behaviorId != BHV_FOG_CHANGER)) { if (obj->interactObj != NULL) { if (obj->interactObj->unk11 != 2) { run_object_loop_func(obj, updateRate); @@ -2189,11 +2256,11 @@ void func_80010994(s32 updateRate) { for (sp54 = 0; sp54 < obj->segment.header->numberOfModelIds; sp54++) { obj68 = obj->unk68[sp54]; - //FAKEMATCH - if (!gObjPtrList){} + // FAKEMATCH + if (!gObjPtrList) {} if (obj68 != NULL) { - if (1){ } //FAKEMATCH + if (1) {} // FAKEMATCH obj68->objModel->unk52 = updateRate; } } @@ -2212,14 +2279,15 @@ void func_80010994(s32 updateRate) { racer = &gRacersByPosition[i]->unk64->racer; if (racer->playerIndex != -1) { increment_ai_behaviour_chances(gRacersByPosition[i], racer, updateRate); - i = gNumRacers; //Why not just break? + i = gNumRacers; // Why not just break? } } } func_8000BADC(updateRate); for (i = gObjectListStart; i < tempVal; i++) { obj = gObjPtrList[i]; - if ((!(obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && (obj->behaviorId == BHV_WEAPON)) || (obj->behaviorId == BHV_FOG_CHANGER)) { + if ((!(obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && (obj->behaviorId == BHV_WEAPON)) || + (obj->behaviorId == BHV_FOG_CHANGER)) { run_object_loop_func(obj, updateRate); } } @@ -2227,47 +2295,47 @@ void func_80010994(s32 updateRate) { for (i = gObjectListStart; i < tempVal; i++) { obj = gObjPtrList[i]; if (obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) { - //Why is this object being treated as a Particle? + // Why is this object being treated as a Particle? handle_particle_movement((Particle *) obj, updateRate); } } } - do { //FAKEMATCH - lightUpdateLights(updateRate); - if (get_light_count() > 0) { - for (i = gObjectListStart; i < gObjectCount; i++) { - obj = gObjPtrList[i]; - if (!(obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && (obj->shading != NULL)) { - func_80032C7C(obj); + do { // FAKEMATCH + lightUpdateLights(updateRate); + if (get_light_count() > 0) { + for (i = gObjectListStart; i < gObjectCount; i++) { + obj = gObjPtrList[i]; + if (!(obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && (obj->shading != NULL)) { + func_80032C7C(obj); + } } } - } - func_8001E6EC(0); - if (D_8011AEF7 != 0) { - func_80022948(); - } - if (D_8011ADAC == 0) { - gParticlePtrList_flush(); - func_80017E98(); - func_8001BC54(); - func_8001E93C(); - } - if (gNumRacers != 0) { - if (D_8011AD4E == 0) { - func_80019808(updateRate); - } else { - func_8001A8F4(updateRate); + func_8001E6EC(0); + if (D_8011AEF7 != 0) { + func_80022948(); } - } - func_80008438(gRacersByPort, gNumRacers, updateRate); - D_8011ADAC = 1; - gObjectUpdateRateF = (f32) updateRate; - D_8011AD24[0] = 0; - D_8011AD53 = 0; - transform_player_vehicle(); - try_close_dialogue_box(); - func_800179D0(); - } while(0); //FAKEMATCH + if (D_8011ADAC == 0) { + gParticlePtrList_flush(); + func_80017E98(); + func_8001BC54(); + func_8001E93C(); + } + if (gNumRacers != 0) { + if (D_8011AD4E == 0) { + func_80019808(updateRate); + } else { + func_8001A8F4(updateRate); + } + } + func_80008438(gRacersByPort, gNumRacers, updateRate); + D_8011ADAC = 1; + gObjectUpdateRateF = (f32) updateRate; + D_8011AD24[0] = 0; + D_8011AD53 = 0; + transform_player_vehicle(); + try_close_dialogue_box(); + func_800179D0(); + } while (0); // FAKEMATCH if (D_8011AF00 == 1) { if ((gEventCountdown == 0x50) && (gCutsceneID == 0)) { sp54 = 0; @@ -2279,7 +2347,7 @@ void func_80010994(s32 updateRate) { if (sp54 & A_BUTTON) { func_8001E45C(CUTSCENE_ID_UNK_64); } else if ((sp54 & B_BUTTON) && (get_trophy_race_world_id() == 0) && (is_in_tracks_mode() == 0)) { - func_8006F140(1); //FADE_BARNDOOR_HORIZONTAL? + func_8006F140(1); // FADE_BARNDOOR_HORIZONTAL? } } } else if (D_8011AF00 == 0) { @@ -2306,7 +2374,7 @@ void func_80011134(Object *arg0, s32 arg1) { temp_s4 = temp_s3->batches; for (var_s1 = 0; temp_s5 > 0 && var_s1 < temp_s3->numberOfBatches; var_s1++) { var_s0 = &temp_s4[var_s1]; - if (var_s0->flags & 0x10000) { //Texture is animated + if (var_s0->flags & 0x10000) { // Texture is animated temp_v0 = var_s0->textureIndex; if (temp_v0 != 0xFF) { var_t5 = temp_s3->textures[temp_v0].texture; @@ -2322,8 +2390,8 @@ GLOBAL_ASM("asm/non_matchings/objects/func_80011134.s") #endif #ifdef NON_EQUIVALENT -//Probably NON_MATCHING, but not sure. -//This is a function for doors +// Probably NON_MATCHING, but not sure. +// This is a function for doors void func_80011264(ObjectModel *model, Object *obj) { s32 current; s32 remaining; @@ -2335,9 +2403,9 @@ void func_80011264(ObjectModel *model, Object *obj) { batch = &model->batches[0]; door = &obj->unk64->door; current = ((door->unk10 / 10) - 1) << 2; - if (model->textures[batch->textureIndex].texture){} //fakematch - if (1) { //fakematch - remaining = ((door->unk10 % 10) << 2); + if (model->textures[batch->textureIndex].texture) {} // fakematch + if (1) { // fakematch + remaining = ((door->unk10 % 10) << 2); } for (i = 0; i < model->numberOfBatches; i++, batch++) { if (batch->flags & 0x10000) { @@ -2347,7 +2415,7 @@ void func_80011264(ObjectModel *model, Object *obj) { } else if (current >= 0) { batch->unk7 = current; } - if (door){} //fakematch + if (door) {} // fakematch } } } @@ -2359,7 +2427,7 @@ GLOBAL_ASM("asm/non_matchings/objects/func_80011264.s") /** * Do nothing. Unused. -*/ + */ UNUSED void do_nothing_func_80011364(UNUSED s32 unused) { } @@ -2367,9 +2435,12 @@ UNUSED void do_nothing_func_80011364(UNUSED s32 unused) { * Return the opposite of D_8011ADAC's value */ UNUSED s32 is_not_D_8011ADAC(void) { - //Ever hear of return !D_8011ADAC? - if (D_8011ADAC) return FALSE; - else return TRUE; + // Ever hear of return !D_8011ADAC? + if (D_8011ADAC) { + return FALSE; + } else { + return TRUE; + } } void func_80011390(void) { @@ -2378,7 +2449,7 @@ void func_80011390(void) { /** * Return the current race countdown timer. -*/ + */ s32 get_race_countdown(void) { return gEventCountdown; } @@ -2398,8 +2469,9 @@ UNUSED s32 func_800113BC(void) { } /** - * When the object reaches a certain anim frame, play a sound and shake the camera to emphasise the effect of their movement. -*/ + * When the object reaches a certain anim frame, play a sound and shake the camera to emphasise the effect of their + * movement. + */ s32 play_footstep_sounds(Object *obj, s32 arg1, s32 frame, s32 oddSoundId, s32 evenSoundId) { s8 *asset; f32 shakeDist; @@ -2413,7 +2485,8 @@ s32 play_footstep_sounds(Object *obj, s32 arg1, s32 frame, s32 oddSoundId, s32 e ret = 0; if (arg1 < obj->segment.header->unk5B) { - //TODO: Figure this one out better. The index could be something like this: obj->segment.header->internalName[arg1 - 4] + // TODO: Figure this one out better. The index could be something like this: + // obj->segment.header->internalName[arg1 - 4] asset = (s8 *) get_misc_asset(*(&obj->segment.header->unk5C + arg1)); asset0 = asset[0]; shakeDist = (asset[1] & 0xFF) * 8.0f; @@ -2421,19 +2494,19 @@ s32 play_footstep_sounds(Object *obj, s32 arg1, s32 frame, s32 oddSoundId, s32 e frame >>= 4; animFrame = obj->segment.animFrame >> 4; for (i = 0; i < asset0; i++) { - nextAsset = asset[i+3]; + nextAsset = asset[i + 3]; if ((animFrame >= nextAsset && frame < nextAsset) || (nextAsset >= animFrame && nextAsset < frame)) { set_camera_shake_by_distance(obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, shakeDist, shakeMagnitude); + obj->segment.trans.z_position, shakeDist, shakeMagnitude); if (i & 1) { - soundId = oddSoundId; //Always set to SOUND_STOMP2 + soundId = oddSoundId; // Always set to SOUND_STOMP2 } else { - soundId = evenSoundId; //Always set to SOUND_STOMP3 + soundId = evenSoundId; // Always set to SOUND_STOMP3 } play_sound_at_position(soundId, obj->segment.trans.x_position, obj->segment.trans.y_position, - obj->segment.trans.z_position, 4, NULL); + obj->segment.trans.z_position, 4, NULL); ret = i + 1; - i = asset0; //Come on, just use break! + i = asset0; // Come on, just use break! } } } @@ -2443,7 +2516,7 @@ s32 play_footstep_sounds(Object *obj, s32 arg1, s32 frame, s32 oddSoundId, s32 e /** * Make the next call of move_object never mark the object as out of bounds. * Official Name: objMoveXYZnocheck -*/ + */ void ignore_bounds_check(void) { gNoBoundsCheck = TRUE; } @@ -2452,7 +2525,7 @@ void ignore_bounds_check(void) { * Sets the new position of the object using the differences given. * Compares against the outer edges of the level geometry to decide wether or not to apply a segment ID. * Official Name: objMoveXYZ -*/ + */ s32 move_object(Object *obj, f32 xPos, f32 yPos, f32 zPos) { s32 segmentID; f32 x1, x2, y1, y2, z1, z2; @@ -2483,7 +2556,9 @@ s32 move_object(Object *obj, f32 xPos, f32 yPos, f32 zPos) { if (obj->segment.trans.x_position < x1) { outOfBounds = TRUE; } - if (1) { } if (1) { } if (1) { } // Fakematch + if (1) {} + if (1) {} + if (1) {} // Fakematch y2 = (levelModel->upperYBounds + 3000.0); if (obj->segment.trans.y_position > y2) { outOfBounds = TRUE; @@ -2503,7 +2578,7 @@ s32 move_object(Object *obj, f32 xPos, f32 yPos, f32 zPos) { if (gNoBoundsCheck) { outOfBounds = FALSE; } - + gNoBoundsCheck = FALSE; if (outOfBounds) { obj->segment.object.segmentID = -1; @@ -2515,9 +2590,9 @@ s32 move_object(Object *obj, f32 xPos, f32 yPos, f32 zPos) { obj->segment.trans.z_position = newZPos; box = get_segment_bounding_box(obj->segment.object.segmentID); - //For some reason the XYZ positions are converted into integers for the next section + // For some reason the XYZ positions are converted into integers for the next section intXPos = newXPos, intYPos = newYPos, intZPos = newZPos; - + if (box == NULL) { obj->segment.object.segmentID = get_level_segment_index_from_position(intXPos, intYPos, intZPos); return 0; @@ -2545,8 +2620,9 @@ s32 move_object(Object *obj, f32 xPos, f32 yPos, f32 zPos) { /** * Set up the basic model view matrix, load a texture, then render the mesh. * A much simpler, faster way to render an object model as opposed to render_3d_model -*/ -void render_misc_model(Object *obj, Vertex *verts, u32 numVertices, Triangle *triangles, u32 numTriangles, TextureHeader *tex, u32 flags, u32 texOffset, f32 scale) { + */ +void render_misc_model(Object *obj, Vertex *verts, u32 numVertices, Triangle *triangles, u32 numTriangles, + TextureHeader *tex, u32 flags, u32 texOffset, f32 scale) { s32 hasTexture = FALSE; camera_push_model_mtx(&gObjectCurrDisplayList, &gObjectCurrMatrix, &obj->segment.trans, scale, 0.0f); gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, 255, 255, 255, 255); @@ -2554,7 +2630,7 @@ void render_misc_model(Object *obj, Vertex *verts, u32 numVertices, Triangle *tr if (tex != NULL) { hasTexture = TRUE; } - load_and_set_texture(&gObjectCurrDisplayList, (TextureHeader* ) tex, flags, texOffset); + load_and_set_texture(&gObjectCurrDisplayList, (TextureHeader *) tex, flags, texOffset); gSPVertexDKR(gObjectCurrDisplayList++, OS_K0_TO_PHYSICAL(verts), numVertices, 0); gSPPolygon(gObjectCurrDisplayList++, OS_K0_TO_PHYSICAL(triangles), numTriangles, hasTexture); apply_matrix_from_stack(&gObjectCurrDisplayList); @@ -2562,7 +2638,7 @@ void render_misc_model(Object *obj, Vertex *verts, u32 numVertices, Triangle *tr /** * A few objects use unconventional means to render. They are handled here. -*/ + */ void render_3d_misc(Object *obj) { f32 scale; Object_64 *objData; @@ -2571,21 +2647,23 @@ void render_3d_misc(Object *obj) { case BHV_CHARACTER_FLAG: if (obj->properties.characterFlag.characterID >= 0) { objData = obj->unk64; - render_misc_model(obj, objData->character_flag.vertices, 4, objData->character_flag.triangles, 2, objData->character_flag.texture, - RENDER_ANTI_ALIASING | RENDER_Z_COMPARE | RENDER_FOG_ACTIVE, 0, 1.0f); + render_misc_model(obj, objData->character_flag.vertices, 4, objData->character_flag.triangles, 2, + objData->character_flag.texture, + RENDER_ANTI_ALIASING | RENDER_Z_COMPARE | RENDER_FOG_ACTIVE, 0, 1.0f); } break; case BHV_BUTTERFLY: objData = obj->unk64; - render_misc_model(obj, &objData->butterfly.vertices[objData->butterfly.unkFC * 6], 6, objData->butterfly.triangles, 8, objData->butterfly.texture, - RENDER_Z_COMPARE | RENDER_FOG_ACTIVE, 0, 1.0f); + render_misc_model(obj, &objData->butterfly.vertices[objData->butterfly.unkFC * 6], 6, + objData->butterfly.triangles, 8, objData->butterfly.texture, + RENDER_Z_COMPARE | RENDER_FOG_ACTIVE, 0, 1.0f); break; case BHV_FISH: objData = obj->unk64; scale = obj->segment.level_entry->fish.unkD; scale *= 0.01f; - render_misc_model(obj, &objData->fish.vertices[objData->fish.unkFC * 6], 6, objData->fish.triangles, 8, objData->fish.texture, - RENDER_Z_COMPARE | RENDER_FOG_ACTIVE | RENDER_CUTOUT, 0, scale); + render_misc_model(obj, &objData->fish.vertices[objData->fish.unkFC * 6], 6, objData->fish.triangles, 8, + objData->fish.texture, RENDER_Z_COMPARE | RENDER_FOG_ACTIVE | RENDER_CUTOUT, 0, scale); break; case BHV_BOOST: if (obj->properties.common.unk0 && (obj->unk64->boost.unk70 > 0 || obj->unk64->boost.unk74 > 0.0f)) { @@ -2608,7 +2686,7 @@ void render_3d_billboard(Object *obj) { s32 hasEnvCol; ObjectTransformExt objTrans; Object *bubbleTrap; - Object_68* gfxData; + Object_68 *gfxData; intensity = 255; hasPrimCol = FALSE; @@ -2625,10 +2703,11 @@ void render_3d_billboard(Object *obj) { if (obj->segment.object.opacity > 255) { obj->segment.object.opacity = obj->properties.bombExplosion.unk4 & 0xFF; } else { - obj->segment.object.opacity = (obj->segment.object.opacity * (obj->properties.bombExplosion.unk4 & 0xFF)) >> 8; + obj->segment.object.opacity = + (obj->segment.object.opacity * (obj->properties.bombExplosion.unk4 & 0xFF)) >> 8; } } - + alpha = obj->segment.object.opacity; if (alpha > 255) { alpha = 255; @@ -2638,7 +2717,7 @@ void render_3d_billboard(Object *obj) { if (obj->behaviorId == BHV_WIZPIG_GHOSTS) { alpha >>= 1; } - + if (alpha < 255) { flags |= RENDER_SEMI_TRANSPARENT; hasPrimCol = TRUE; @@ -2646,7 +2725,7 @@ void render_3d_billboard(Object *obj) { if ((obj->behaviorId == 5) && (obj->segment.trans.scale == 6.0f)) { gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, (intensity * 3) >> 2, intensity, intensity >> 1, alpha); hasPrimCol = TRUE; - } else if (obj->behaviorId == BHV_WIZPIG_GHOSTS) { // If the behavior is a wizpig ghost + } else if (obj->behaviorId == BHV_WIZPIG_GHOSTS) { // If the behavior is a wizpig ghost gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, 150, 230, 255, alpha); hasPrimCol = TRUE; } else if (hasPrimCol || alpha < 255) { @@ -2655,7 +2734,8 @@ void render_3d_billboard(Object *obj) { gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, 255, 255, 255, 255); } if (hasEnvCol) { - gDPSetEnvColor(gObjectCurrDisplayList++, obj->shading->unk4, obj->shading->unk5, obj->shading->unk6, obj->shading->unk7); + gDPSetEnvColor(gObjectCurrDisplayList++, obj->shading->unk4, obj->shading->unk5, obj->shading->unk6, + obj->shading->unk7); } else if (obj->behaviorId == BHV_LAVA_SPURT) { hasEnvCol = TRUE; gDPSetEnvColor(gObjectCurrDisplayList++, 255, 255, 0, 255); @@ -2670,9 +2750,9 @@ void render_3d_billboard(Object *obj) { bubbleTrap = obj; } } - + // 5 = OilSlick, SmokeCloud, Bomb, BubbleWeapon - if(bubbleTrap != NULL || !(obj->behaviorId != BHV_WEAPON || obj->unk64->weapon.weaponID != WEAPON_BUBBLE_TRAP)) { + if (bubbleTrap != NULL || !(obj->behaviorId != BHV_WEAPON || obj->unk64->weapon.weaponID != WEAPON_BUBBLE_TRAP)) { objTrans.trans.z_rotation = 0; objTrans.trans.x_rotation = 0; objTrans.trans.y_rotation = 0; @@ -2688,9 +2768,11 @@ void render_3d_billboard(Object *obj) { bubbleTrap = obj; } } - render_bubble_trap(&bubbleTrap->segment.trans, gfxData, (Object *) &objTrans, RENDER_Z_COMPARE | RENDER_SEMI_TRANSPARENT | RENDER_Z_UPDATE); + render_bubble_trap(&bubbleTrap->segment.trans, gfxData, (Object *) &objTrans, + RENDER_Z_COMPARE | RENDER_SEMI_TRANSPARENT | RENDER_Z_UPDATE); } else { - render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, obj, (unk80068514_arg4 *) gfxData, flags); + render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, obj, + (unk80068514_arg4 *) gfxData, flags); } if (hasPrimCol) { gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, 255, 255, 255, 255); @@ -2705,7 +2787,7 @@ void render_3d_billboard(Object *obj) { * Loads materials, and sets environment and/or primitive colours based on the material type. * Computes the view matrix for the model, and calls a function to draw meshes. * Loops through racers to find vehicle parts, which are wheels and propellers. -*/ + */ void render_3d_model(Object *obj) { s32 i; s32 intensity; @@ -2724,7 +2806,7 @@ void render_3d_model(Object *obj) { s8 var_v0_2; Object *loopObj; Object_68 *obj68; - Object_Racer *racerObj; + Object_Racer *racerObj; ObjectModel *objModel; Object_68 *something; @@ -2752,7 +2834,8 @@ void render_3d_model(Object *obj) { } if (obj68->unk1E && objModel->unk40 != NULL) { flags = TRUE; - if (racerObj != NULL && racerObj->vehicleID < VEHICLE_TRICKY && racerObj->playerIndex == PLAYER_COMPUTER) { + if (racerObj != NULL && racerObj->vehicleID < VEHICLE_TRICKY && + racerObj->playerIndex == PLAYER_COMPUTER) { flags = FALSE; } if (get_viewport_count() != VIEWPORTS_COUNT_1_PLAYER) { @@ -2767,7 +2850,8 @@ void render_3d_model(Object *obj) { func_800245F0(objModel, obj, gCurrentLightIntensity); } } - if ((racerObj != NULL) && (racerObj->playerIndex == PLAYER_COMPUTER) && (racerObj->vehicleID < VEHICLE_TRICKY)) { + if ((racerObj != NULL) && (racerObj->playerIndex == PLAYER_COMPUTER) && + (racerObj->vehicleID < VEHICLE_TRICKY)) { obj68->unk20 = 2; } else { obj68->unk20 = 1; @@ -2804,12 +2888,14 @@ void render_3d_model(Object *obj) { hasOpacity = TRUE; } if (hasEnvCol) { - gDPSetEnvColor(gObjectCurrDisplayList++, obj->shading->unk4, obj->shading->unk5, obj->shading->unk6, obj->shading->unk7); + gDPSetEnvColor(gObjectCurrDisplayList++, obj->shading->unk4, obj->shading->unk5, obj->shading->unk6, + obj->shading->unk7); } else { gDPSetEnvColor(gObjectCurrDisplayList++, 255, 255, 255, 0); } if (obj->segment.header->unk71) { - gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, obj->shading->unk18, obj->shading->unk19, obj->shading->unk1A, alpha); + gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, obj->shading->unk18, obj->shading->unk19, + obj->shading->unk1A, alpha); enable_primitive_colour(); } else if (hasOpacity) { gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, intensity, intensity, intensity, alpha); @@ -2855,7 +2941,7 @@ void render_3d_model(Object *obj) { flags |= RENDER_SEMI_TRANSPARENT; } cicFailed = FALSE; - //Anti-Piracy check + // Anti-Piracy check if (osCicId != CIC_ID) { cicFailed = TRUE; } @@ -2869,7 +2955,9 @@ void render_3d_model(Object *obj) { gDPSetEnvColor(gObjectCurrDisplayList++, 255, 255, 255, 0); gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, intensity, intensity, intensity, alpha); } - loopObj->properties.common.unk0 = render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, loopObj, (unk80068514_arg4 *) something, flags); + loopObj->properties.common.unk0 = render_sprite_billboard( + &gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, loopObj, + (unk80068514_arg4 *) something, flags); if (var_v0_2) { gDkrInsertMatrix(gObjectCurrDisplayList++, 0, 0); func_80012CE8(&gObjectCurrDisplayList); @@ -2897,14 +2985,16 @@ void render_3d_model(Object *obj) { loopObj->segment.trans.y_position += (vtxY - loopObj->segment.trans.y_position) * 0.25; loopObj->segment.trans.z_position += (vtxZ - loopObj->segment.trans.z_position) * 0.25; if (loopObj->segment.header->modelType == OBJECT_MODEL_TYPE_SPRITE_BILLBOARD) { - render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, loopObj, (unk80068514_arg4 *)something, flags); + render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, + loopObj, (unk80068514_arg4 *) something, flags); } } } } if (meshBatch != -1) { if (obj->segment.header->unk71) { - gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, obj->shading->unk18, obj->shading->unk19, obj->shading->unk1A, alpha); + gDPSetPrimColor(gObjectCurrDisplayList++, 0, 0, obj->shading->unk18, obj->shading->unk19, + obj->shading->unk1A, alpha); enable_primitive_colour(); } render_mesh(objModel, obj, meshBatch, RENDER_SEMI_TRANSPARENT, spB0); @@ -2951,11 +3041,12 @@ void func_80012CE8(Gfx **dlist) { /** * Update the object stack trace, set the draw pointers, then begin rendering the object. * Official Name: objPrintObject -*/ + */ void render_object(Gfx **dList, MatrixS **mtx, Vertex **verts, Object *obj) { f32 scale; - if (obj->segment.trans.flags & (OBJ_FLAGS_INVISIBLE | OBJ_FLAGS_SHADOW_ONLY)) + if (obj->segment.trans.flags & (OBJ_FLAGS_INVISIBLE | OBJ_FLAGS_SHADOW_ONLY)) { return; + } update_object_stack_trace(OBJECT_DRAW, obj->unk4A); gObjectCurrDisplayList = *dList; gObjectCurrMatrix = *mtx; @@ -2969,10 +3060,9 @@ void render_object(Gfx **dList, MatrixS **mtx, Vertex **verts, Object *obj) { update_object_stack_trace(OBJECT_DRAW, OBJECT_CLEAR); } - /** * Official Name: objDoPlayerTumble -*/ + */ void object_do_player_tumble(Object *this) { UNUSED s32 unused1; Object_Racer *sp_20; @@ -2997,7 +3087,7 @@ void object_do_player_tumble(Object *this) { tmp_f0 = (tmp_f0 < 0.0f) ? 0.0f : tmp_f0 * tmp_f0; temp = (1.0f - tmp_f0) * 24.0f + sp_20->unkD0; - if(0){} // Fakematch + if (0) {} // Fakematch sp_1c = temp; } this->segment.trans.y_position = this->segment.trans.y_position + sp_1c; @@ -3007,7 +3097,7 @@ void object_do_player_tumble(Object *this) { /** * Official Name: objUndoPlayerTumble -*/ + */ void object_undo_player_tumble(Object *obj) { if (obj->behaviorId == BHV_RACER) { Object_Racer *racer = &obj->unk64->racer; @@ -3056,17 +3146,17 @@ void func_80012F94(Object *obj) { var_t0 = 0; batchNum = 0; } else { - if (obj->behaviorId == BHV_UNK_3A) { //Ghost Object? + if (obj->behaviorId == BHV_UNK_3A) { // Ghost Object? var_t0 = 1; batchNum = 0; } else { - //Loads vehicles between VEHICLE_TRICKY and VEHICLE_SMOKEY. So all boss vehicles except wizpig. + // Loads vehicles between VEHICLE_TRICKY and VEHICLE_SMOKEY. So all boss vehicles except wizpig. var_t0 = objRacer->vehicleID + VEHICLE_TRICKY; if (objRacer->vehicleID >= NUMBER_OF_PLAYER_VEHICLES) { var_t0 = VEHICLE_TRICKY; } batchNum = 0; - bossAsset = (u8 *) get_misc_asset(var_t0); //40 bytes of data u8[8][5]? + bossAsset = (u8 *) get_misc_asset(var_t0); // 40 bytes of data u8[8][5]? bossAsset = &bossAsset[(get_viewport_count() * 10)]; var_a1 = bossAsset; if (get_current_viewport() != objRacer->playerIndex) { @@ -3080,8 +3170,8 @@ void func_80012F94(Object *obj) { var_f0_2 = 3500.0f; } obj->segment.trans.scale *= (var_f0_2 / 2700.0f) + 1.0f; - temp_f6 = (s32) ((f32) temp_v1 * *((f32 *)get_misc_asset(ASSET_MISC_4)[objRacer->characterId])); - //ASSET_MISC_4 is just 10 floats of 1.0f. One for each playable character. + temp_f6 = (s32) ((f32) temp_v1 * *((f32 *) get_misc_asset(ASSET_MISC_4)[objRacer->characterId])); + // ASSET_MISC_4 is just 10 floats of 1.0f. One for each playable character. if (temp_f6 < -50) { var_t0 = 5; } else { @@ -3174,7 +3264,7 @@ GLOBAL_ASM("asm/non_matchings/objects/func_80012F94.s") * Determine which model type the object is using, then call the related function to render it. * Beforehand, call a function to apply a temporary transformation, mostly for racers. * Afterwards, undo that. -*/ + */ void render_object_parts(Object *obj) { func_80012F94(obj); if (obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) { @@ -3193,7 +3283,7 @@ void render_object_parts(Object *obj) { /** * After rendering, sets the object position back to normal. -*/ + */ void unset_temp_model_transforms(Object *obj) { if (!(obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && obj->segment.header->behaviorId == BHV_RACER) { obj->segment.trans.x_position -= obj->unk64->racer.carBobX; @@ -3206,7 +3296,7 @@ GLOBAL_ASM("asm/non_matchings/objects/func_800135B8.s") /** * Render the bubble trap weapon. -*/ + */ void render_bubble_trap(ObjectTransform *trans, Object_68 *gfxData, Object *obj, s32 flags) { f32 x; f32 y; @@ -3232,7 +3322,8 @@ void render_bubble_trap(ObjectTransform *trans, Object_68 *gfxData, Object *obj, obj->segment.trans.x_position += x; obj->segment.trans.y_position += y; obj->segment.trans.z_position += z; - render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, obj, (unk80068514_arg4 *) gfxData, flags); + render_sprite_billboard(&gObjectCurrDisplayList, &gObjectCurrMatrix, &gObjectCurrVertexList, obj, + (unk80068514_arg4 *) gfxData, flags); } /** @@ -3240,10 +3331,10 @@ void render_bubble_trap(ObjectTransform *trans, Object_68 *gfxData, Object *obj, * Afterwards, render the graphics with opacity scaling with the fadetimer. */ void render_racer_shield(Gfx **dList, MatrixS **mtx, Vertex **vtxList, Object *obj) { - struct Object_Racer* racer; + struct Object_Racer *racer; Object_68 *gfxData; ObjectModel *mdl; - struct RacerShieldGfx* shield; + struct RacerShieldGfx *shield; s32 shieldType; s32 vehicleID; s32 var_a2; @@ -3264,7 +3355,7 @@ void render_racer_shield(Gfx **dList, MatrixS **mtx, Vertex **vtxList, Object *o vehicleID = VEHICLE_CAR; } shield = ((struct RacerShieldGfx *) get_misc_asset(ASSET_MISC_SHIELD_DATA)); - vehicleID = (vehicleID * 10) + var_a2; + vehicleID = (vehicleID * 10) + var_a2; shield = shield + vehicleID; gShieldEffectObject->segment.trans.x_position = shield->x_position; gShieldEffectObject->segment.trans.y_position = shield->y_position; @@ -3315,7 +3406,7 @@ void render_racer_magnet(Gfx **dList, MatrixS **mtx, Vertex **vtxList, Object *o Object_Racer *racer; Object_68 *gfxData; ObjectModel *mdl; - f32* magnet; + f32 *magnet; s32 vehicleID; s32 var_t0; s32 opacity; @@ -3354,7 +3445,8 @@ void render_racer_magnet(Gfx **dList, MatrixS **mtx, Vertex **vtxList, Object *o mdl = gfxData->objModel; gMagnetEffectObject->unk44 = (Vertex *) gfxData->unk4[gfxData->animationTaskNum]; opacity = ((D_8011B078[(var_t0 * 4) + 1] * 8) & 0x7F) + 0x80; - func_8007F594(&gObjectCurrDisplayList, 2, COLOUR_RGBA32(255, 255, 255, opacity), gMagnetColours[racer->magnetModelID]); + func_8007F594(&gObjectCurrDisplayList, 2, COLOUR_RGBA32(255, 255, 255, opacity), + gMagnetColours[racer->magnetModelID]); apply_object_shear_matrix(&gObjectCurrDisplayList, &gObjectCurrMatrix, gMagnetEffectObject, obj, shear); gObjectTexAnim = TRUE; render_mesh(mdl, gMagnetEffectObject, 0, RENDER_SEMI_TRANSPARENT, 0); @@ -3379,7 +3471,8 @@ void func_800142B8(void) { for (; i < gObjectCount; i++) { currObj = gObjPtrList[i]; - if (!(currObj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && currObj->segment.header->modelType == OBJECT_MODEL_TYPE_3D_MODEL) { + if (!(currObj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && + currObj->segment.header->modelType == OBJECT_MODEL_TYPE_3D_MODEL) { for (j = 0; j < currObj->segment.header->numberOfModelIds; j++) { curr_68 = currObj->unk68[j]; if (curr_68 != NULL && curr_68->unk20 > 0) { @@ -3393,7 +3486,7 @@ void func_800142B8(void) { /** * Renders every triangle batch in an objects mesh. -*/ + */ s32 render_mesh(ObjectModel *objModel, Object *obj, s32 startIndex, s32 flags, s32 someBool) { s32 i; s32 textureIndex; @@ -3416,9 +3509,9 @@ s32 render_mesh(ObjectModel *objModel, Object *obj, s32 startIndex, s32 flags, s endLoop = FALSE; while (i < objModel->numberOfBatches && !endLoop) { if (!(objModel->batches[i].flags & BATCH_FLAGS_UNK00000004) || flags & RENDER_SEMI_TRANSPARENT) { - //Hidden/Invisible geometry + // Hidden/Invisible geometry textureIndex = objModel->batches[i].flags & BATCH_FLAGS_HIDDEN; - //Probably a fakematch to use textureIndex here, but it works. + // Probably a fakematch to use textureIndex here, but it works. if (!textureIndex) { vertOffset = objModel->batches[i].verticesOffset; triOffset = objModel->batches[i].facesOffset; @@ -3428,7 +3521,7 @@ s32 render_mesh(ObjectModel *objModel, Object *obj, s32 startIndex, s32 flags, s tris = &objModel->triangles[triOffset]; vtx = &obj->unk44[vertOffset]; textureIndex = objModel->batches[i].textureIndex; - //textureIndex of 0xFF is no texture + // textureIndex of 0xFF is no texture if (textureIndex == 0xFF) { texOffset = 0; texToSet = NULL; @@ -3439,14 +3532,16 @@ s32 render_mesh(ObjectModel *objModel, Object *obj, s32 startIndex, s32 flags, s texToSet = objModel->textures[textureIndex].texture; } texToSetFlags = objModel->batches[i].flags | BATCH_FLAGS_UNK00000008; - if (flags & RENDER_SEMI_TRANSPARENT && !(objModel->batches[i].flags & (flags & ~RENDER_SEMI_TRANSPARENT))) { + if (flags & RENDER_SEMI_TRANSPARENT && + !(objModel->batches[i].flags & (flags & ~RENDER_SEMI_TRANSPARENT))) { texToSetFlags |= RENDER_SEMI_TRANSPARENT; } if (gObjectTexAnim == FALSE) { load_and_set_texture(&dlist, texToSet, texToSetFlags, texOffset); } else { texToSet = set_animated_texture_header(texToSet, texOffset); - gDkrDmaDisplayList(gObjectCurrDisplayList++, OS_K0_TO_PHYSICAL(texToSet->cmd), texToSet->numberOfCommands); + gDkrDmaDisplayList(gObjectCurrDisplayList++, OS_K0_TO_PHYSICAL(texToSet->cmd), + texToSet->numberOfCommands); } if (offsetStartVertex == numVertices) { gSPVertexDKR(dlist++, OS_K0_TO_PHYSICAL(vtx), numVertices, 0); @@ -3454,7 +3549,8 @@ s32 render_mesh(ObjectModel *objModel, Object *obj, s32 startIndex, s32 flags, s if (offsetStartVertex > 0) { gSPVertexDKR(dlist++, OS_K0_TO_PHYSICAL(vtx), offsetStartVertex, 0); gDkrInsertMatrix(dlist++, 0, G_MTX_DKR_INDEX_2); - gSPVertexDKR(dlist++, OS_K0_TO_PHYSICAL(&vtx[offsetStartVertex]), (numVertices - offsetStartVertex), 1); + gSPVertexDKR(dlist++, OS_K0_TO_PHYSICAL(&vtx[offsetStartVertex]), + (numVertices - offsetStartVertex), 1); } else { gDkrInsertMatrix(dlist++, 0, G_MTX_DKR_INDEX_2); gSPVertexDKR(dlist++, OS_K0_TO_PHYSICAL(vtx), numVertices, 0); @@ -3544,7 +3640,7 @@ GLOBAL_ASM("asm/non_matchings/objects/func_80014B50.s") /** * Takes every object and sorts the main object list by distance to the camera. -*/ + */ void sort_objects_by_dist(s32 startIndex, s32 lastIndex) { s32 i; s32 didNotSwap; @@ -3552,25 +3648,28 @@ void sort_objects_by_dist(s32 startIndex, s32 lastIndex) { if (lastIndex < startIndex) { return; - } + } for (i = startIndex; i <= lastIndex; i++) { obj = gObjPtrList[i]; if (obj != NULL) { if (obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) { // get_distance_to_camera calculates the distance to the camera from a XYZ location. - obj->segment.object.distanceToCamera = -get_distance_to_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + obj->segment.object.distanceToCamera = -get_distance_to_camera( + obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); } else if (obj->segment.header->flags & OBJ_FLAGS_UNK_0080) { obj->segment.object.distanceToCamera += -16000.0f; } else { - obj->segment.object.distanceToCamera = -get_distance_to_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + obj->segment.object.distanceToCamera = -get_distance_to_camera( + obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); } } else { - //!@bug obj is NULL here, so it would probably cause a crash. Thankfully, gObjPtrList shouldn't have NULL objects in it. + //!@bug obj is NULL here, so it would probably cause a crash. Thankfully, gObjPtrList shouldn't have NULL + //! objects in it. obj->segment.object.distanceToCamera = 0.0f; } } - + // Keep swapping until all objects are sorted by the distance to the camera. do { didNotSwap = TRUE; @@ -3588,7 +3687,7 @@ void sort_objects_by_dist(s32 startIndex, s32 lastIndex) { /** * Go through each object and detect potential interactions between each. * Add candidates to a list and calcualte their distances. -*/ + */ void process_object_interactions(void) { Object *obj2; Object *obj; @@ -3600,7 +3699,7 @@ void process_object_interactions(void) { s32 j; s32 i; s32 objsWithInteractives; - Object *objList[257]; //257 seems random, but it works for now. + Object *objList[257]; // 257 seems random, but it works for now. objsWithInteractives = 0; for (i = gObjectListStart; i < gObjectCount; i++) { @@ -3618,7 +3717,7 @@ void process_object_interactions(void) { } } } - + D_8011AE70 = 0; for (i = 0; i < objsWithInteractives; i++) { @@ -3640,9 +3739,9 @@ void process_object_interactions(void) { xDiff = obj->segment.trans.x_position - obj2->segment.trans.x_position; zDiff = obj->segment.trans.z_position - obj2->segment.trans.z_position; if (objInteract2->flags & INTERACT_FLAGS_UNK_0020) { - radius = 0x400000; //4194304.0f; + radius = 0x400000; // 4194304.0f; } else { - radius = 0x40000; //262144.0f; + radius = 0x40000; // 262144.0f; } if (((xDiff * xDiff) + (zDiff * zDiff)) < radius) { func_800159C8(obj, obj2); @@ -3689,12 +3788,12 @@ void func_80016500(Object *obj, Object_Racer *racer) { if (racer->vehicleID == VEHICLE_CAR) { if (racer->drift_direction != 0) { angle += racer->unk10C; - angle = (s16)angle; + angle = (s16) angle; } } cosAngle = coss_f(-angle); sinAngle = sins_f(-angle); - racer->lateral_velocity = ( obj->segment.x_velocity * cosAngle) + (obj->segment.z_velocity * sinAngle); + racer->lateral_velocity = (obj->segment.x_velocity * cosAngle) + (obj->segment.z_velocity * sinAngle); racer->velocity = (-obj->segment.x_velocity * sinAngle) + (obj->segment.z_velocity * cosAngle); if (racer->playerIndex != -1) { angle = (startVelocity - racer->velocity) * 14.0f; @@ -3741,7 +3840,7 @@ void func_80016748(Object *obj0, Object *obj1) { #else // THIS IS A HACK! Supposed to be a Matrix, but the stack ended up being too big. f32 pad[2]; - f32 obj1TransformMtx[4][3]; + f32 obj1TransformMtx[4][3]; #endif f32 xDiff; @@ -3762,13 +3861,13 @@ void func_80016748(Object *obj0, Object *obj1) { zDiff = obj0->segment.trans.z_position - obj1->segment.trans.z_position; if (!((objModel->unk3C + 50.0) < sqrtf((xDiff * xDiff) + (yDiff * yDiff) + (zDiff * zDiff)))) { obj0Interact = obj0->interactObj; - obj1Interact = obj1->interactObj; - object_transform_to_matrix((float (*)[4]) obj1TransformMtx, &obj1->segment.trans); - for(i = 0; i < objModel->unk20; i += 2) { + obj1Interact = obj1->interactObj; + object_transform_to_matrix((float(*)[4]) obj1TransformMtx, &obj1->segment.trans); + for (i = 0; i < objModel->unk20; i += 2) { xDiff = obj1->unk44[objModel->unk1C[i]].x; yDiff = obj1->unk44[objModel->unk1C[i]].y; zDiff = obj1->unk44[objModel->unk1C[i]].z; - guMtxXFMF((float (*)[4]) obj1TransformMtx, xDiff, yDiff, zDiff, &xDiff, &yDiff, &zDiff); + guMtxXFMF((float(*)[4]) obj1TransformMtx, xDiff, yDiff, zDiff, &xDiff, &yDiff, &zDiff); temp = (((f32) objModel->unk1C[i + 1] / 64) * obj1->segment.trans.scale) * 50.0; xDiff -= obj0->segment.trans.x_position; yDiff -= obj0->segment.trans.y_position; @@ -3791,7 +3890,7 @@ void func_80016748(Object *obj0, Object *obj1) { obj0->segment.trans.x_position -= xDiff; obj0->segment.trans.y_position -= yDiff; obj0->segment.trans.z_position -= zDiff; - + if (obj0->behaviorId == BHV_RACER) { racer = &obj0->unk64->racer; if (!racer->raceFinished) { @@ -3835,7 +3934,7 @@ Object *func_80016C68(f32 x, f32 y, f32 z, f32 maxDistCheck, s32 dontCheckYAxis) f32 distance; s32 i; Object *curObj; - + for (i = 0; i < gObjectCount; i++) { curObj = gObjPtrList[i]; if (!(curObj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && (curObj->behaviorId == BHV_ANIMATED_OBJECT_3)) { @@ -3870,7 +3969,7 @@ s32 func_80016DE8(f32 x, f32 y, f32 z, f32 radius, s32 is2dCheck, Object **arg5) result = 0; if (gNumRacers > 0) { - for(i = 0; i < gNumRacers; i++) { + for (i = 0; i < gNumRacers; i++) { racerObj = (*gRacers)[i]; racer = &racerObj->unk64->racer; if ((racer->playerIndex >= 0) && (racer->playerIndex < 4)) { @@ -3892,16 +3991,16 @@ s32 func_80016DE8(f32 x, f32 y, f32 z, f32 radius, s32 is2dCheck, Object **arg5) } } if (result >= 2) { - for(i = result - 1; i > 0; i--) { - for(j = 0; j < i; j++) { - if(distances[j+1] < distances[j]) { - swapf = distances[j]; - swapObj = arg5[j]; - distances[j] = distances[j+1]; - arg5[j] = arg5[j+1]; - distances[j+1] = swapf; - arg5[j+1] = swapObj; - } + for (i = result - 1; i > 0; i--) { + for (j = 0; j < i; j++) { + if (distances[j + 1] < distances[j]) { + swapf = distances[j]; + swapObj = arg5[j]; + distances[j] = distances[j + 1]; + arg5[j] = arg5[j + 1]; + distances[j + 1] = swapf; + arg5[j + 1] = swapObj; + } } } } @@ -3916,9 +4015,9 @@ void func_8001709C(Object *obj) { Matrix *sp6C; Matrix sp2C; Object_5C *obj5C; - + obj5C = obj->unk5C; - obj5C->unk104 = (obj5C->unk104 + 1) & 1; + obj5C->unk104 = (obj5C->unk104 + 1) & 1; sp6C = (Matrix *) &obj5C->_matrices[obj5C->unk104 << 1]; sp78.y_rotation = -obj->segment.trans.y_rotation; sp78.x_rotation = -obj->segment.trans.x_rotation; @@ -3927,7 +4026,7 @@ void func_8001709C(Object *obj) { sp78.x_position = -obj->segment.trans.x_position; sp78.y_position = -obj->segment.trans.y_position; sp78.z_position = -obj->segment.trans.z_position; - object_transform_to_matrix_2((float (*)[4]) sp6C, (ObjectTransform* ) &sp78); + object_transform_to_matrix_2((float(*)[4]) sp6C, (ObjectTransform *) &sp78); inverseScale = 1.0 / obj->segment.trans.scale; i = 0; while (i < 16) { @@ -3946,7 +4045,7 @@ void func_8001709C(Object *obj) { sp78.x_position = obj->segment.trans.x_position; sp78.y_position = obj->segment.trans.y_position; sp78.z_position = obj->segment.trans.z_position; - object_transform_to_matrix(obj5C->_matrices[(obj5C->unk104 + 2) << 1], (ObjectTransform* ) &sp78); + object_transform_to_matrix(obj5C->_matrices[(obj5C->unk104 + 2) << 1], (ObjectTransform *) &sp78); obj5C->unk100 = NULL; } @@ -3956,7 +4055,7 @@ unk800179D0 *func_8001790C(u32 *arg0, u32 *arg1) { unk800179D0 *entry; s16 i; - for(i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) { entry = &D_8011AFF4[i]; if (entry->unk0 != 0 && entry->unk04 == arg0 && entry->unk08 == arg1) { entry->unk0 = 0; @@ -3970,7 +4069,7 @@ unk800179D0 *func_80017978(s32 arg0, s32 arg1) { unk800179D0 *entry; s16 i; - for(i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) { entry = &D_8011AFF4[i]; if (entry->unk0 == 0) { entry->unk04 = (u32 *) arg0; @@ -3997,7 +4096,7 @@ GLOBAL_ASM("asm/non_matchings/objects/func_80017A18.s") /** * Sets the active Taj challenge. -*/ + */ void set_taj_challenge_type(s32 vehicleID) { gTajChallengeType = vehicleID; D_8011ADAC = 0; @@ -4005,7 +4104,7 @@ void set_taj_challenge_type(s32 vehicleID) { /** * Returns which Taj challenge is currently active. -*/ + */ UNUSED s16 get_taj_challenge_type(void) { return gTajChallengeType; } @@ -4016,13 +4115,14 @@ GLOBAL_ASM("asm/non_matchings/objects/func_800185E4.s") /** * Search and return Taj's overworld object. * Used for drawing his minimap position. -*/ + */ Object *find_taj_object(void) { s32 i; Object *current_obj; for (i = gObjectListStart; i < gObjectCount; i++) { current_obj = gObjPtrList[i]; - if (!(current_obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && (current_obj->behaviorId == BHV_PARK_WARDEN)) { + if (!(current_obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && + (current_obj->behaviorId == BHV_PARK_WARDEN)) { return current_obj; } } @@ -4031,8 +4131,9 @@ Object *find_taj_object(void) { GLOBAL_ASM("asm/non_matchings/objects/func_80018CE0.s") -//Rocket Path -s32 func_8001955C(Object *obj, s32 checkpoint, u8 arg2, s32 arg3, s32 arg4, f32 checkpointDist, f32 *outX, f32 *outY, f32 *outZ) { +// Rocket Path +s32 func_8001955C(Object *obj, s32 checkpoint, u8 arg2, s32 arg3, s32 arg4, f32 checkpointDist, f32 *outX, f32 *outY, + f32 *outZ) { s32 numCheckpoints; s32 checkpointIndex; s32 i; @@ -4056,7 +4157,7 @@ s32 func_8001955C(Object *obj, s32 checkpoint, u8 arg2, s32 arg3, s32 arg4, f32 if (checkpointIndex < 0) { checkpointIndex += numCheckpoints; } - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { checkpointNode = find_next_checkpoint_node(checkpointIndex, arg2); xData[i] = checkpointNode->x + (checkpointNode->scale * checkpointNode->rotationZFrac * arg3); yData[i] = checkpointNode->y + (checkpointNode->scale * arg4); @@ -4095,7 +4196,7 @@ GLOBAL_ASM("asm/non_matchings/objects/func_80019808.s") * Mark the course as finished for the appropriate mode. * Check if it's the first race or the silver coin race before deciding which flag to write. * Return whether something was written. -*/ + */ s8 set_course_finish_flags(Settings *settings) { Object_Racer *racer; @@ -4185,7 +4286,7 @@ void func_8001A8F4(s32 updateRate) { if (gNumRacersSaved > 0) { i = 0; while (i < gNumRacers && gRacersByPosition[i] != (*gRacers)[gNumRacersSaved]) { - i++; + i++; } if (i < gNumRacers) { for (; i < (gNumRacers - 1); i++) { @@ -4195,7 +4296,7 @@ void func_8001A8F4(s32 updateRate) { free_object((*gRacers)[gNumRacersSaved]); (*gRacers)[gNumRacersSaved] = NULL; gNumRacers--; - + } else { D_8011AD50 = 2; } @@ -4253,7 +4354,7 @@ s16 func_8001AE44(void) { /** * Return the timer used for the collectable balloon cutscene. -*/ + */ u32 get_balloon_cutscene_timer(void) { return gBalloonCutsceneTimer; } @@ -4269,7 +4370,7 @@ void func_8001AE64(void) { Object_Racer *curRacer; Object_Racer *bestRacer; Settings *settings; - LevelHeader* levelHeader; + LevelHeader *levelHeader; levelHeader = get_current_level_header(); settings = get_settings(); @@ -4287,8 +4388,8 @@ void func_8001AE64(void) { temp = curRacer->vehicleIDPrev; if ((temp >= 0) && (temp < 3)) { courseTime = 0; - for(j = 0; j < levelHeader->laps && j < 5; j++) { - settings->racers[curRacer->unk2].lap_times[j] = curRacer->lap_times[j]; + for (j = 0; j < levelHeader->laps && j < 5; j++) { + settings->racers[curRacer->unk2].lap_times[j] = curRacer->lap_times[j]; curRacerLapTime = curRacer->lap_times[j]; courseTime += curRacerLapTime; if (curRacerLapTime < bestRacerTime) { @@ -4315,20 +4416,23 @@ void func_8001AE64(void) { } settings->display_times = 1; if ((settings->unk115[0] == 0)) { - if((settings->flapTimesPtr[temp][settings->courseId] == 0) || (bestRacerTime < settings->flapTimesPtr[temp][settings->courseId])) { + if ((settings->flapTimesPtr[temp][settings->courseId] == 0) || + (bestRacerTime < settings->flapTimesPtr[temp][settings->courseId])) { settings->flapTimesPtr[temp][settings->courseId] = bestRacerTime; settings->racers[settings->unk115[0]].best_times |= 1 << settings->unk115[1]; } } if ((settings->timeTrialRacer == 0)) { - if((settings->courseTimesPtr[temp][settings->courseId] == 0) || (bestCourseTime < settings->courseTimesPtr[temp][settings->courseId])) { + if ((settings->courseTimesPtr[temp][settings->courseId] == 0) || + (bestCourseTime < settings->courseTimesPtr[temp][settings->courseId])) { settings->courseTimesPtr[temp][settings->courseId] = bestCourseTime; settings->racers[settings->timeTrialRacer].best_times |= 0x80; } } - if (((!temp) && (!temp)) && (!temp)){} // Fakematch + if (((!temp) && (!temp)) && (!temp)) {} // Fakematch if (settings->timeTrialRacer == 0) { - if ((bestCourseTime < 10800) && ((temp != D_800DC728) || ((func_800599A8() != get_current_map_id())) || (bestCourseTime < D_800DC724))) { + if ((bestCourseTime < 10800) && ((temp != D_800DC728) || ((func_800599A8() != get_current_map_id())) || + (bestCourseTime < D_800DC724))) { D_800DC724 = bestCourseTime; D_800DC728 = D_8011AE82; D_800DC72C = settings->racers[0].character; @@ -4394,17 +4498,18 @@ s32 func_8001B2F0(s32 mapId) { ret = 1; if (prevGhostTable->mapId != 0xFF) { - ret = load_tt_ghost(nextGhostTable->ghostOffset, nextGhostTable[1].ghostOffset - nextGhostTable->ghostOffset, &gTTGhostTimeToBeat); + ret = load_tt_ghost(nextGhostTable->ghostOffset, nextGhostTable[1].ghostOffset - nextGhostTable->ghostOffset, + &gTTGhostTimeToBeat); } free_from_memory_pool(ghostTable); return ret; } -/** +/** * Return true if this object is the time trial ghost. -*/ -s32 is_time_trial_ghost(Object* obj) { + */ +s32 is_time_trial_ghost(Object *obj) { return obj == gGhostObj; } @@ -4412,7 +4517,7 @@ s32 is_time_trial_ghost(Object* obj) { * Free ghost data then save the players victory. * Check if the player has beaten every time and unlock TT. * Otherwise, tell them to try another track. -*/ + */ void tt_ghost_beaten(s32 arg0, s16 *playerId) { s32 trackIdCount; s8 *mainTrackIds; @@ -4426,18 +4531,19 @@ void tt_ghost_beaten(s32 arg0, s16 *playerId) { trackIdCount++; } if (gBeatStaffGhost) { - //Save that TT has been beaten for this track. + // Save that TT has been beaten for this track. set_eeprom_settings_value(16 << trackIdCount); - //Check if TT has been beaten for all tracks. + // Check if TT has been beaten for all tracks. if ((get_eeprom_settings() & 0xFFFFF0) == 0xFFFFF0) { set_magic_code_flags(CHEAT_CONTROL_TT); sound_play(SOUND_VOICE_TT_BEAT_ALL_TIMES, NULL); sound_play_delayed(SOUND_VOICE_TT_UNLOCKED, NULL, 1.5f); - set_current_text(ASSET_GAME_TEXT_84); //Text for "You have beaten all my times!" and then "Now you can PICK me!" + set_current_text( + ASSET_GAME_TEXT_84); // Text for "You have beaten all my times!" and then "Now you can PICK me!" } else { sound_play(SOUND_VOICE_TT_WELL_DONE, NULL); sound_play_delayed(SOUND_VOICE_TT_TRY_ANOTHER_TRACK, NULL, 1.0f); - set_current_text(ASSET_GAME_TEXT_83); //Text for "Well Done! Now try another track." + set_current_text(ASSET_GAME_TEXT_83); // Text for "Well Done! Now try another track." } gBeatStaffGhost = FALSE; return; @@ -4457,11 +4563,11 @@ u8 func_8001B4FC(s32 trackId) { if (get_map_default_vehicle(trackId) == (Vehicle) D_8011AE82) { mainTrackIds = (s8 *) get_misc_asset(ASSET_MISC_MAIN_TRACKS_IDS); temp_v0 = (u16 *) get_misc_asset(ASSET_MISC_24); - for (i = 0; mainTrackIds[i] != -1 && trackId != mainTrackIds[i]; i++) { } + for (i = 0; mainTrackIds[i] != -1 && trackId != mainTrackIds[i]; i++) {} if (mainTrackIds[i] != -1) { if (temp_v0[i] >= settings->courseTimesPtr[D_8011AE82][trackId]) { - //Check if TT has been beaten? - if (!(get_eeprom_settings() & ((1 << 4) << i) )) { + // Check if TT has been beaten? + if (!(get_eeprom_settings() & ((1 << 4) << i))) { gBeatStaffGhost = TRUE; } if (func_8001B2F0(trackId) == 0) { @@ -4475,14 +4581,14 @@ u8 func_8001B4FC(s32 trackId) { /** * Return the time trial ghost object. -*/ + */ Object *get_time_trial_ghost(void) { return gGhostObj; } /** * Return true if the tt ghost is unbeaten for this track. -*/ + */ s32 unbeaten_staff_time(void) { return gBeatStaffGhost == FALSE; } @@ -4512,14 +4618,14 @@ SIDeviceStatus func_8001B738(s32 controllerIndex) { /** * Returns whether there's valid ghost data to save. -*/ + */ u8 has_ghost_to_save(void) { return gHasGhostToSave; } /** * Resets the variables used for ghost data saving. -*/ + */ void set_ghost_none(void) { D_8011D5AC = -1; gHasGhostToSave = FALSE; @@ -4582,7 +4688,7 @@ f32 func_8001B834(Object_Racer *racer1, Object_Racer *racer2) { return var_f2; } -UNUSED f32 func_8001B974(Object_Racer* racer) { +UNUSED f32 func_8001B974(Object_Racer *racer) { f32 distLeft; s32 checkpointID; @@ -4603,7 +4709,7 @@ UNUSED f32 func_8001B974(Object_Racer* racer) { /** * Returns a pointer to a specific checkpoint. -*/ + */ CheckpointNode *get_checkpoint_node(s32 checkpointID) { return &gTrackCheckpoints[checkpointID]; } @@ -4611,7 +4717,7 @@ CheckpointNode *get_checkpoint_node(s32 checkpointID) { /** * Takes the position along the checkpoint path, and finds the next applicable node. * If an alternative path is available, use that node instead. -*/ + */ CheckpointNode *find_next_checkpoint_node(s32 splinePos, s32 arg1) { CheckpointNode *checkpointNode = &gTrackCheckpoints[splinePos]; if (arg1 != 0 && checkpointNode->altRouteID != -1) { @@ -4622,14 +4728,14 @@ CheckpointNode *find_next_checkpoint_node(s32 splinePos, s32 arg1) { /** * Returns the number of active checkpoints in the current level. -*/ + */ s32 get_checkpoint_count(void) { return gNumberOfCheckpoints; } /** * Returns the group of racer objects. -*/ + */ Object **get_racer_objects(s32 *numRacers) { *numRacers = gNumRacers; return *gRacers; @@ -4637,7 +4743,7 @@ Object **get_racer_objects(s32 *numRacers) { /** * Returns the group of racer objects, ordered by player index. -*/ + */ Object **get_racer_objects_by_port(s32 *numRacers) { *numRacers = gNumRacers; return gRacersByPort; @@ -4645,7 +4751,7 @@ Object **get_racer_objects_by_port(s32 *numRacers) { /** * Returns the group of racer objects, ordered by current race position. -*/ + */ Object **get_racer_objects_by_position(s32 *numRacers) { *numRacers = gNumRacers; return gRacersByPosition; @@ -4653,7 +4759,7 @@ Object **get_racer_objects_by_position(s32 *numRacers) { /** * Returns the racer object specified by the ID -*/ + */ Object *get_racer_object(s32 index) { if (gNumRacers == 0) { return NULL; @@ -4666,7 +4772,7 @@ Object *get_racer_object(s32 index) { /** * Returns the racer object specified by the player ID. -*/ + */ Object *get_racer_object_by_port(s32 index) { if (gNumRacers == 0) { return NULL; @@ -4680,7 +4786,7 @@ Object *get_racer_object_by_port(s32 index) { /** * Unused function that would've iterated through all active checkpoints to render their visual nodes. * The function it calls is completely stubbed out. -*/ + */ UNUSED void debug_render_checkpoints(Gfx **dlist, MatrixS **mtx, Vertex **vtx) { s32 i; @@ -4690,7 +4796,7 @@ UNUSED void debug_render_checkpoints(Gfx **dlist, MatrixS **mtx, Vertex **vtx) { // Ground path debug_render_checkpoint_node(i, 0, dlist, mtx, vtx); } - for (i = 0; i < gNumberOfCheckpoints; i++){ + for (i = 0; i < gNumberOfCheckpoints; i++) { // Air path debug_render_checkpoint_node(i, 1, dlist, mtx, vtx); } @@ -4698,10 +4804,11 @@ UNUSED void debug_render_checkpoints(Gfx **dlist, MatrixS **mtx, Vertex **vtx) { } /** - * Would've rendered an individual checkpoint node. On https://noclip.website, with dev objects enabled, you can see a visual representation of - * what these checkpoints would've looked like ingame. -*/ -UNUSED void debug_render_checkpoint_node(UNUSED s32 checkpointID, UNUSED s32 pathID, UNUSED Gfx **dList, UNUSED MatrixS **mtx, UNUSED Vertex **vtx) { + * Would've rendered an individual checkpoint node. On https://noclip.website, with dev objects enabled, you can see a + * visual representation of what these checkpoints would've looked like ingame. + */ +UNUSED void debug_render_checkpoint_node(UNUSED s32 checkpointID, UNUSED s32 pathID, UNUSED Gfx **dList, + UNUSED MatrixS **mtx, UNUSED Vertex **vtx) { } void func_8001BC54(void) { @@ -4726,11 +4833,11 @@ void func_8001BC54(void) { do { continueLoop = TRUE; for (i = 0; i < gCameraObjCount - 1; i++) { - objPtr = (*gCameraObjList)[i+1]; + objPtr = (*gCameraObjList)[i + 1]; temp = (*gCameraObjList)[i]; if (temp->properties.common.unk0 > objPtr->properties.common.unk0) { - (*gCameraObjList)[i] = (*gCameraObjList)[i+1]; - (*gCameraObjList)[i+1] = temp; + (*gCameraObjList)[i] = (*gCameraObjList)[i + 1]; + (*gCameraObjList)[i + 1] = temp; continueLoop = FALSE; } } @@ -4747,7 +4854,7 @@ Object *get_camera_object(s32 cameraIndex) { /** * Take the current camera passed through the function and compare distances between the next and previous camera. * Set the camera to be whichever's closest to the object. -*/ + */ Object *find_nearest_spectate_camera(Object *obj, s32 *cameraId) { Object *nextCamera; Object *prevCamera; @@ -4807,13 +4914,13 @@ void func_8001BF20(void) { LevelObjectEntry_AiNode *aiNodeEntry; Object *obj; s16 sp186; - Object* nextAiNodeObj; + Object *nextAiNodeObj; f32 xDiff; f32 zDiff; f32 yDiff; s32 i; s32 j; - s8 index; // Must be an s8 + s8 index; // Must be an s8 u8 index2; // Must be an u8 s16 swap; Object_AiNode *aiNodeObj64; @@ -4822,11 +4929,11 @@ void func_8001BF20(void) { if (D_8011AF10[0] != 0) { D_8011AF10[0] = 0; - for(i = 0; i < 128; i++) { + for (i = 0; i < 128; i++) { (*D_8011AF04)[i] = 0; } sp186 = 0; - for(i = 0; i < gObjectCount; i++) { + for (i = 0; i < gObjectCount; i++) { obj = gObjPtrList[i]; if (!(obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && (obj->behaviorId == BHV_AINODE)) { aiNodeEntry = &obj->segment.level_entry->aiNode; @@ -4840,12 +4947,12 @@ void func_8001BF20(void) { } } if (sp186 != 0) { - for(i = 0; i < 128; i++) { + for (i = 0; i < 128; i++) { obj = (*D_8011AF04)[i]; if (obj != NULL) { - aiNodeObj64 = (Object_AiNode *)obj->unk64; + aiNodeObj64 = (Object_AiNode *) obj->unk64; aiNodeEntry = &obj->segment.level_entry->aiNode; - for(j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) { index2 = aiNodeEntry->unkA[j]; if (!(index2 & 128)) { nextAiNodeObj = (*D_8011AF04)[index2]; @@ -4865,8 +4972,9 @@ void func_8001BF20(void) { do { j = TRUE; - for(i = 0; i < (sp186 - 1); i++) { - if((*D_8011AF04)[spE4[i + 1]]->segment.trans.y_position < (*D_8011AF04)[spE4[i]]->segment.trans.y_position) { + for (i = 0; i < (sp186 - 1); i++) { + if ((*D_8011AF04)[spE4[i + 1]]->segment.trans.y_position < + (*D_8011AF04)[spE4[i]]->segment.trans.y_position) { swap = spE4[i]; spE4[i] = spE4[i + 1]; spE4[i + 1] = swap; @@ -4876,14 +4984,14 @@ void func_8001BF20(void) { j = FALSE; } } - } while(!j); // Keep doing this until no more swaps are needed. + } while (!j); // Keep doing this until no more swaps are needed. - if(1){} // Fakematch - - for(i = 0; i < 5; i++) { + if (1) {} // Fakematch + + for (i = 0; i < 5; i++) { D_8011AF18[i] = -20000.0f; } - + index = sp64[0]; for (i = 0; i < (sp186 - 1);) { while ((i < (sp186 - 1)) && (index >= sp64[i])) { @@ -4891,13 +4999,15 @@ void func_8001BF20(void) { } if (index < sp64[i]) { index = sp64[i]; - D_8011AF18[index] = (f32) ((f64) ((*D_8011AF04)[spE4[i]]->segment.trans.y_position + (*D_8011AF04)[spE4[i-1]]->segment.trans.y_position) * 0.5); + D_8011AF18[index] = (f32) ((f64) ((*D_8011AF04)[spE4[i]]->segment.trans.y_position + + (*D_8011AF04)[spE4[i - 1]]->segment.trans.y_position) * + 0.5); } else { i = sp186; } } D_8011AF18[0] = -10000.0f; - + D_8011AF18[4] = -D_8011AF18[0]; } } @@ -4906,7 +5016,7 @@ void func_8001BF20(void) { s16 func_8001C418(f32 yPos) { s16 i = 0; s16 out = 0; - for(; i < 4; i++) { + for (; i < 4; i++) { if ((D_8011AF18[i] != -20000.0f) && (D_8011AF18[i] < yPos)) { out = i; } @@ -4916,7 +5026,7 @@ s16 func_8001C418(f32 yPos) { s32 func_8001C48C(Object *obj) { s32 i; - for(i = 0; i < 128; i++) { + for (i = 0; i < 128; i++) { if ((*D_8011AF04)[i] == 0) { (*D_8011AF04)[i] = obj; return i; @@ -4945,7 +5055,7 @@ s32 func_8001C524(f32 diffX, f32 diffY, f32 diffZ, s32 someFlag) { dist = (f32) 50000.0; result = 0xFF; for (numSteps = 0; numSteps != 128; numSteps++) { - segment = (ObjectSegment*) (*D_8011AF04)[numSteps]; + segment = (ObjectSegment *) (*D_8011AF04)[numSteps]; if (segment) { levelObj = &((segment->level_entry)->ttDoor); var_a0 = 1; @@ -5000,22 +5110,22 @@ s32 func_8001CC48(s32 arg0, s32 arg1, s32 arg2) { if (someObj == NULL) { return 255; } - entry = (LevelObjectEntry_Unknown8001CC48 *)someObj->segment.level_entry; - someObj64 = (Object_Unknown8001CC48*)someObj->unk64; + entry = (LevelObjectEntry_Unknown8001CC48 *) someObj->segment.level_entry; + someObj64 = (Object_Unknown8001CC48 *) someObj->unk64; test = arg2 & 3; - + // Swapping these messes up the registers. someCount = 0; someIndex = (someObj64->unk18[test] + 1) & 3; - + for (i = 0; i < 4; i++) { if (entry->unkA[someIndex] != 255) { if (entry->unkA[someIndex] != arg1) { someObj64->unk18[test] = someIndex; i = 4; someCount++; - } - } + } + } someIndex = (someIndex + 1) & 3; } if (someCount == 0) { @@ -5029,18 +5139,18 @@ GLOBAL_ASM("asm/non_matchings/objects/func_8001CC48.s") #ifdef NON_MATCHING s16 func_8001CD28(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - s16 result; - s32 sp370; + s16 result; + s32 sp370; s16 var_t1; - s16 sp36C; - s16 temp2; + s16 sp36C; + s16 temp2; s16 i; LevelObjectEntry_AiNode *aiNodeEntry; s8 someBool; s8 var_s3; s8 var_s5; - s8 temp; - s32 var_ra; + s8 temp; + s32 var_ra; Object_AiNode *aiNode; Object *aiNodeObj; s32 sp154[128]; @@ -5053,7 +5163,7 @@ s16 func_8001CD28(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { sp154[i] = 0; i++; } while (i < 128); - + aiNodeObj = (*D_8011AF04)[arg0]; aiNode = (Object_AiNode *) aiNodeObj->unk64; aiNodeEntry = &aiNodeObj->segment.level_entry->aiNode; @@ -5068,7 +5178,8 @@ s16 func_8001CD28(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { if (aiNode->nodeObj[i] != 0) { temp2 = aiNodeEntry->unkA[i]; temp = 1; - if (((arg0 == aiNodeEntry->unk9) && (temp2 == arg2)) || ((arg2 == aiNodeEntry->unk9) && (temp2 == arg0))) { + if (((arg0 == aiNodeEntry->unk9) && (temp2 == arg2)) || + ((arg2 == aiNodeEntry->unk9) && (temp2 == arg0))) { temp = 0; if (var_s5 != 0) { temp = 1; @@ -5081,7 +5192,7 @@ s16 func_8001CD28(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { while ((sp36C < var_t1) && (temp2 != spD4[sp36C])) { sp36C++; } - + sp370 = aiNode->distToNode[i] + var_ra; if (sp36C == var_t1) { temp = 2; @@ -5099,12 +5210,12 @@ s16 func_8001CD28(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { var_t1++; } sp154[temp2] = sp370; - + sp36C = var_t1 - 1; - + sp54[sp36C] = (someBool) ? aiNodeEntry->unkA[i] : var_s3; spD4[sp36C] = aiNodeEntry->unkA[i]; - + while ((sp36C > 0) && (sp154[spD4[sp36C - 1]] < sp154[spD4[sp36C]])) { temp = spD4[sp36C]; spD4[sp36C] = spD4[sp36C - 1]; @@ -5114,11 +5225,10 @@ s16 func_8001CD28(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { sp54[sp36C - 1] = temp; sp36C--; } - } } } - + if (var_t1 > 0) { var_t1--; aiNodeObj = (*D_8011AF04)[spD4[var_t1]]; @@ -5139,11 +5249,11 @@ s16 func_8001CD28(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { } } } while ((result == 0xFF) && (var_t1 > 0)); - + if (result != 0xFF) { aiNodeObj = (*D_8011AF04)[arg0]; aiNodeEntry = &aiNodeObj->segment.level_entry->aiNode; - aiNode = &aiNodeObj->unk64->ai_node; + aiNode = &aiNodeObj->unk64->ai_node; for (i = 0; (i < 4) && (result != aiNodeEntry->unkA[i]); i++) {} if (i < 4) { aiNode->unk18[arg3] = i; @@ -5184,7 +5294,7 @@ UNUSED void func_8001D23C(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { /** * Applies shading properties to a global variable. * Presumably intended for level geometry, which supports shading, but never uses it. -*/ + */ void set_world_shading(f32 brightness, f32 ambient, s16 angleX, s16 angleY, s16 angleZ) { set_shading_properties((ShadeProperties *) &gWorldShading, brightness, ambient, angleX, angleY, angleZ); } @@ -5192,8 +5302,9 @@ void set_world_shading(f32 brightness, f32 ambient, s16 angleX, s16 angleY, s16 /** * Add values onto the existing properties of an objects shading. * Resets the shading based off the new values. -*/ -UNUSED void add_shading_properties(Object *obj, f32 brightnessChange, f32 ambientChange, s16 angleX, s16 angleY, s16 angleZ) { + */ +UNUSED void add_shading_properties(Object *obj, f32 brightnessChange, f32 ambientChange, s16 angleX, s16 angleY, + s16 angleZ) { if (obj->shading != NULL) { obj->shading->brightness += brightnessChange; if (obj->shading->brightness < 0.0f) { @@ -5209,9 +5320,8 @@ UNUSED void add_shading_properties(Object *obj, f32 brightnessChange, f32 ambien obj->shading->ambient = 1.99f; } set_shading_properties(obj->shading, obj->shading->brightness, obj->shading->ambient, - (obj->shading->unk22 + angleX), - (obj->shading->unk24 + angleY), - (obj->shading->unk26 + angleZ)); + (obj->shading->unk22 + angleX), (obj->shading->unk24 + angleY), + (obj->shading->unk26 + angleZ)); if (obj->segment.header->unk3D != 0) { obj->shading->unk4 = obj->segment.header->unk3A; obj->shading->unk5 = obj->segment.header->unk3B; @@ -5252,7 +5362,7 @@ void set_shading_properties(ShadeProperties *arg0, f32 brightness, f32 ambient, /** * Take the normalised length of the position set by the perspective and set the world angle for the envmap. * Official name: setObjectViewNormal -*/ + */ void update_envmap_position(f32 x, f32 y, f32 z) { f32 vecLength = sqrtf((x * x) + (y * y) + (z * z)); f32 normalizedLength; @@ -5270,7 +5380,7 @@ void update_envmap_position(f32 x, f32 y, f32 z) { /** * If the triangle batch allows for it, compute envmap normals for the mesh. * Some objects will prefer some extra additions on top before calculating, like light intensity. -*/ + */ void calc_dyn_light_and_env_map_for_object(ObjectModel *model, Object *object, s32 arg2, f32 intensity) { s16 environmentMappingEnabled; s32 dynamicLightingEnabled; @@ -5301,7 +5411,8 @@ void calc_dyn_light_and_env_map_for_object(ObjectModel *model, Object *object, s if (environmentMappingEnabled) { // Calculates environment mapping for the object - calc_env_mapping_for_object(model, object->segment.trans.z_rotation, object->segment.trans.x_rotation, object->segment.trans.y_rotation); + calc_env_mapping_for_object(model, object->segment.trans.z_rotation, object->segment.trans.x_rotation, + object->segment.trans.y_rotation); } } @@ -5310,7 +5421,7 @@ GLOBAL_ASM("asm/non_matchings/objects/calc_env_mapping_for_object.s") /** * Find the racer object representing the player and directly set position and angle to new values. -*/ + */ UNUSED void set_racer_position_and_angle(s16 player, s16 *x, s16 *y, s16 *z, s16 *angleZ, s16 *angleX, s16 *angleY) { Object *obj; Object_Racer *racer; @@ -5328,7 +5439,7 @@ UNUSED void set_racer_position_and_angle(s16 player, s16 *x, s16 *y, s16 *z, s16 *angleZ = obj->segment.trans.z_rotation; *angleX = obj->segment.trans.x_rotation; *angleY = obj->segment.trans.y_rotation; - i = gObjectCount; //Feels like it should be a break instead. + i = gObjectCount; // Feels like it should be a break instead. } } } @@ -5344,7 +5455,7 @@ s32 *get_misc_asset(s32 index) { if (index < 0 || index >= gAssetsMiscTableLength) { return gAssetsMiscSection; } - return (s32 *)&gAssetsMiscSection[gAssetsMiscTable[index]]; + return (s32 *) &gAssetsMiscSection[gAssetsMiscTable[index]]; } s32 func_8001E2EC(s32 arg0) { @@ -5372,10 +5483,8 @@ void func_8001E36C(s32 arg0, f32 *arg1, f32 *arg2, f32 *arg3) { for (i = 0; i < gObjectCount; i++) { current_obj = gObjPtrList[i]; - if (current_obj != NULL - && !(current_obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) - && current_obj->behaviorId == BHV_RAMP_SWITCH - && current_obj->properties.common.unk0 == arg0) { + if (current_obj != NULL && !(current_obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && + current_obj->behaviorId == BHV_RAMP_SWITCH && current_obj->properties.common.unk0 == arg0) { *arg1 = current_obj->segment.trans.x_position; *arg2 = current_obj->segment.trans.y_position; *arg3 = current_obj->segment.trans.z_position; @@ -5385,14 +5494,14 @@ void func_8001E36C(s32 arg0, f32 *arg1, f32 *arg2, f32 *arg3) { /** * Return the index of the currently active cutscene. -*/ + */ s16 get_cutscene_id(void) { return gCutsceneID; } /** * Set the current cutscene index. -*/ + */ void set_cutscene_id(s32 cutsceneID) { gCutsceneID = cutsceneID; } @@ -5411,7 +5520,7 @@ void func_8001E45C(s32 cutsceneID) { /** * Returns the index of the standard object list. * Goes unused, since objGetObjList exists -*/ + */ UNUSED s32 get_object_list_index(void) { return gObjectListStart; } @@ -5430,9 +5539,11 @@ void func_8001E6EC(s8 arg0) { for (i = 0; i < D_8011AE00; i++) { overridePosObj = D_8011ADD8[i]; overridePosEntry = &overridePosObj->segment.level_entry->overridePos; - overridePos = (Object_OverridePos*)overridePosObj->unk64; + overridePos = (Object_OverridePos *) overridePosObj->unk64; if ((overridePosEntry->cutsceneId == gCutsceneID) || ((overridePosEntry->cutsceneId == 20))) { - for (j = 0; (j < D_8011AE78) && (overridePosEntry->behaviorId != D_8011AE74[j]->properties.animatedObj.behaviourID); j++) {} + for (j = 0; (j < D_8011AE78) && + (overridePosEntry->behaviorId != D_8011AE74[j]->properties.animatedObj.behaviourID); + j++) {} if (j != D_8011AE78 && D_8011AE74[j]->unk64 != NULL) { someBool = (D_8011AE74[j]->unk64->animation.unk5C) ? FALSE : TRUE; if (arg0 != someBool) { @@ -5459,7 +5570,7 @@ void func_8001E89C(void) { Object_64 *obj64; // some flag, flips to 1 when loading a new zone - if (D_8011AE01 != 0) { + if (D_8011AE01 != 0) { D_8011AE01 = 0; return; } @@ -5529,7 +5640,7 @@ void func_8001EFA4(Object *arg0, Object *animObj) { anim->unk26 = 0; anim->unk3D = animEntry->channel; anim->unk28 = animEntry->actorIndex; - anim->unk8 = (f32)animEntry->nodeSpeed * 0.1; + anim->unk8 = (f32) animEntry->nodeSpeed * 0.1; anim->unk2A = normalise_time(animEntry->animationStartDelay); animObj->segment.object.animationID = animEntry->objAnimIndex; animObj->segment.animFrame = animEntry->unk16; @@ -5543,7 +5654,7 @@ void func_8001EFA4(Object *arg0, Object *animObj) { anim->unk32 = animEntry->rollSpinSpeed; anim->unk33 = animEntry->pitchSpinSpeed; anim->unk34 = animEntry->unk20; - anim->unk2D = 0; + anim->unk2D = 0; anim->unk4 = 0; anim->unk0 = 0; arg0->unk6C = NULL; @@ -5575,9 +5686,10 @@ void func_8001F23C(Object *obj, LevelObjectEntry_Animation *animEntry) { Object_AnimCamera *camera; s32 viewportCount; - NEW_OBJECT_ENTRY(newObjEntry, animEntry->objectIdToSpawn, 8, animEntry->common.x, animEntry->common.y, animEntry->common.z); + NEW_OBJECT_ENTRY(newObjEntry, animEntry->objectIdToSpawn, 8, animEntry->common.x, animEntry->common.y, + animEntry->common.z); - obj->unk64 = (Object_64*)spawn_object((LevelObjectEntryCommon* ) &newObjEntry, 1); + obj->unk64 = (Object_64 *) spawn_object((LevelObjectEntryCommon *) &newObjEntry, 1); newObj = (Object *) obj->unk64; // (newObj->behaviorId == BHV_DINO_WHALE) is Dinosaur1, Dinosaur2, Dinosaur3, Whale, and Dinoisle if ((obj->unk64 != NULL) && (newObj->behaviorId == BHV_DINO_WHALE) && (gTimeTrialEnabled)) { @@ -5623,7 +5735,7 @@ void func_8001F3C8(s32 arg0) { D_8011ADD4 = arg0; } -s32 func_8001F3EC(s32 arg0){ +s32 func_8001F3EC(s32 arg0) { s32 i; s32 count; if (D_8011AE78 == 0) { @@ -5632,7 +5744,7 @@ s32 func_8001F3EC(s32 arg0){ count = 0; for (i = 0; i < D_8011AE78; i++) { - if (D_8011AE74[i]->properties.common.unk4 == arg0){ + if (D_8011AE74[i]->properties.common.unk4 == arg0) { count++; } } @@ -5686,7 +5798,8 @@ void func_80021104(Object *obj, Object_Animation *animObj, LevelObjectEntry_Anim } } -void func_8002125C(Object *charSelectObj, LevelObjectEntry_CharacterSelect *entry, Object_CharacterSelect *charSelect, UNUSED s32 index) { +void func_8002125C(Object *charSelectObj, LevelObjectEntry_CharacterSelect *entry, Object_CharacterSelect *charSelect, + UNUSED s32 index) { s32 initialAnimFrame; initialAnimFrame = entry->unk12; @@ -5730,7 +5843,6 @@ void func_80021400(s32 arg0) { s32 i; arg0 &= 0xFF; //? - for (i = 0; i < D_8011AE78 && (arg0 != (D_8011AE74[i]->properties.common.unk4 & 0xFF)); i++) {} if (i < D_8011AE78) { @@ -5766,7 +5878,7 @@ s8 func_800214E4(Object *obj, s32 updateRate) { if (animObj->unk36 <= 0) { obj->segment.trans.flags |= OBJ_FLAGS_INVISIBLE; for (i = 0; (i < D_8011AE78 && animObj->unk28 != D_8011AE74[i]->properties.common.unk4); i++) { - if (FALSE) {} //FAKEMATCH + if (FALSE) {} // FAKEMATCH } func_8001EFA4(D_8011AE74[i], obj); return 1; @@ -5779,45 +5891,45 @@ GLOBAL_ASM("asm/non_matchings/objects/func_80021600.s") f32 catmull_rom_interpolation(f32 *data, s32 index, f32 x) { f32 ret; f32 temp3, temp2, temp; - - temp = (-0.5 * data[index]) + ( 1.5 * data[index + 1]) + (-1.5 * data[index + 2]) + ( 0.5 * data[index + 3]); - temp2 = ( 1.0 * data[index]) + (-2.5 * data[index + 1]) + ( 2.0 * data[index + 2]) + (-0.5 * data[index + 3]); - temp3 = (data[index + 2] * 0.5) + ( 0.0 * data[index + 1]) + (-0.5 * data[index]) + ( 0.0 * data[index + 3]); - + + temp = (-0.5 * data[index]) + (1.5 * data[index + 1]) + (-1.5 * data[index + 2]) + (0.5 * data[index + 3]); + temp2 = (1.0 * data[index]) + (-2.5 * data[index + 1]) + (2.0 * data[index + 2]) + (-0.5 * data[index + 3]); + temp3 = (data[index + 2] * 0.5) + (0.0 * data[index + 1]) + (-0.5 * data[index]) + (0.0 * data[index + 3]); + ret = (1.0 * data[index + 1]); ret = (((((temp * x) + temp2) * x) + temp3) * x) + ret; - + return ret; } /** * Interpolates x along a spline and returns the resultant progress along the spline. -*/ + */ f32 cubic_spline_interpolation(f32 *data, s32 index, f32 x, f32 *derivative) { f32 ret; f32 temp3, temp2, temp; - - temp = (-0.5 * data[index]) + ( 1.5 * data[index + 1]) + (-1.5 * data[index + 2]) + ( 0.5 * data[index + 3]); - temp2 = ( 1.0 * data[index]) + (-2.5 * data[index + 1]) + ( 2.0 * data[index + 2]) + (-0.5 * data[index + 3]); - temp3 = (data[index + 2] * 0.5) + ( 0.0 * data[index + 1]) + (-0.5 * data[index]) + ( 0.0 * data[index + 3]); - + + temp = (-0.5 * data[index]) + (1.5 * data[index + 1]) + (-1.5 * data[index + 2]) + (0.5 * data[index + 3]); + temp2 = (1.0 * data[index]) + (-2.5 * data[index + 1]) + (2.0 * data[index + 2]) + (-0.5 * data[index + 3]); + temp3 = (data[index + 2] * 0.5) + (0.0 * data[index + 1]) + (-0.5 * data[index]) + (0.0 * data[index + 3]); + ret = (1.0 * data[index + 1]); *derivative = (((temp * 3 * x) + (2 * temp2)) * x) + temp3; ret = (((((temp * x) + temp2) * x) + temp3) * x) + ret; - + return ret; } f32 func_8002277C(f32 *data, s32 index, f32 x) { f32 derivative; f32 temp3, temp2, temp; - - temp = (-0.5 * data[index]) + ( 1.5 * data[index + 1]) + (-1.5 * data[index + 2]) + ( 0.5 * data[index + 3]); - temp2 = ( 1.0 * data[index]) + (-2.5 * data[index + 1]) + ( 2.0 * data[index + 2]) + (-0.5 * data[index + 3]); - temp3 = (data[index + 2] * 0.5) + ( 0.0 * data[index + 1]) + (-0.5 * data[index]) + ( 0.0 * data[index + 3]); - + + temp = (-0.5 * data[index]) + (1.5 * data[index + 1]) + (-1.5 * data[index + 2]) + (0.5 * data[index + 3]); + temp2 = (1.0 * data[index]) + (-2.5 * data[index + 1]) + (2.0 * data[index + 2]) + (-0.5 * data[index + 3]); + temp3 = (data[index + 2] * 0.5) + (0.0 * data[index + 1]) + (-0.5 * data[index]) + (0.0 * data[index + 3]); + derivative = (((temp * 3 * x) + (2 * temp2)) * x) + temp3; - + return derivative; } @@ -5845,7 +5957,7 @@ UNUSED void func_800228DC(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { /** * Prepares the player racer for a Taj Challenge race. * Prevents them from pausing for 10 frames. -*/ + */ void init_racer_for_challenge(s32 vehicleID) { Object_Racer *racer; @@ -5870,9 +5982,9 @@ void func_80022948(void) { Settings *settings; Object *racerObj; Object_Racer *racer; - UNUSED s32 pad2[7]; + UNUSED s32 pad2[7]; f32 sp2C; - + D_8011AEF7 -= 1; if (D_8011AEF7 == 0) { levelHeader = get_current_level_header(); @@ -5902,11 +6014,15 @@ void func_80022948(void) { levelHeader->laps = 3; levelHeader->race_type = 0; func_8009F034(); - for (i = 0; i < ARRAY_COUNT(racer->lap_times); i++) racer->lap_times[i] = 0; // Must be a single line. + // clang-format off + for (i = 0; i < ARRAY_COUNT(racer->lap_times); i++) { racer->lap_times[i] = 0; } // Must be a single line. + // clang-format on newRacerEntry.common.x = (checkpointNode->x + (checkpointNode->rotationZFrac * 35.0f)); newRacerEntry.common.z = (checkpointNode->z - (checkpointNode->rotationXFrac * 35.0f)); - lvlSeg = get_level_segment_index_from_position(newRacerEntry.common.x, checkpointNode->y, newRacerEntry.common.z); - newRacerEntry.common.y = func_8002BAB0(lvlSeg, newRacerEntry.common.x, newRacerEntry.common.z, &sp2C) ? sp2C : checkpointNode->y; + lvlSeg = + get_level_segment_index_from_position(newRacerEntry.common.x, checkpointNode->y, newRacerEntry.common.z); + newRacerEntry.common.y = + func_8002BAB0(lvlSeg, newRacerEntry.common.x, newRacerEntry.common.z, &sp2C) ? sp2C : checkpointNode->y; newRacerEntry.common.size = 16; newRacerEntry.angleY = racer->steerVisualRotation; newRacerEntry.angleX = 0; @@ -5931,9 +6047,10 @@ void func_80022948(void) { racer->transparency = 0xFF; racer->vehicleSound = NULL; racerObj->interactObj->pushForce = 2; - + for (j = gObjectListStart; j < gObjectCount; j++) { - if (!(gObjPtrList[j]->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && gObjPtrList[j]->behaviorId == BHV_PARK_WARDEN) { + if (!(gObjPtrList[j]->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && + gObjPtrList[j]->behaviorId == BHV_PARK_WARDEN) { racer->unk154 = gObjPtrList[j]; } } @@ -5948,7 +6065,7 @@ void func_80022CFC(s32 arg0, f32 x, f32 y, f32 z) { Settings *settings = get_settings(); for (index = 0; index < gObjectCount; index += 1) { - obj = ((unk80022CFC_1*) gObjPtrList[index]); + obj = ((unk80022CFC_1 *) gObjPtrList[index]); if (obj->unk48 == 0x4D) { if (obj->unk3C != NULL) { if (obj->unk3C->unkA > 0) { @@ -5984,18 +6101,19 @@ void func_80022E18(s32 arg0) { i = 0; do { racer = &(*gRacers)[i]->unk64->racer; - if (!racer){} + if (!racer) {} racer->raceFinished = 0; racer->lap = 0; racer->checkpoint = 0; racer->courseCheckpoint = 0; - } while(++i < gNumRacers); - + } while (++i < gNumRacers); + free_object((*gRacers)[1]); gRacersByPosition[0] = (*gRacers)[0]; gNumRacers = 1; for (i = gObjectListStart; i < gObjectCount; i++) { - if (!(gObjPtrList[i]->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && (gObjPtrList[i]->behaviorId == BHV_PARK_WARDEN)) { + if (!(gObjPtrList[i]->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) && + (gObjPtrList[i]->behaviorId == BHV_PARK_WARDEN)) { obj = gObjPtrList[i]; } } @@ -6043,14 +6161,14 @@ GLOBAL_ASM("asm/non_matchings/objects/func_800230D0.s") /** * Returns true if a taj challenge is currently active. -*/ + */ s8 is_taj_challenge(void) { return gIsTajChallenge; } /** * Searches for the furthest teleport anchor and returns it. -*/ + */ Object *find_furthest_telepoint(f32 x, f32 z) { Object *tempObj; Object *bestObj; @@ -6082,7 +6200,6 @@ Object *find_furthest_telepoint(f32 x, f32 z) { return bestObj; } - s32 func_80023568(void) { if (D_8011AD3C != 0) { return D_8011AD24[1] + 1; @@ -6102,7 +6219,7 @@ void func_800235D0(s32 arg0) { /** * Return the size of the object property struct intended to be used with the object. -*/ + */ s32 get_object_property_size(Object *obj, Object_64 *obj64) { s32 temp_v0; s32 ret = 0; @@ -6110,133 +6227,133 @@ s32 get_object_property_size(Object *obj, Object_64 *obj64) { obj->unk64 = obj64; switch (obj->segment.header->behaviorId) { - case BHV_RACER: - ret = sizeof(Object_Racer); - break; - case BHV_DOOR: - case BHV_TT_DOOR: - ret = sizeof(Object_TTDoor); - break; - case BHV_EXIT: - ret = sizeof(Object_Exit); - break; - case BHV_ANIMATOR: - ret = sizeof(Object_Animator); - break; - case BHV_AUDIO: - ret = sizeof(Object_Audio); - break; - case BHV_AUDIO_LINE: - case BHV_AUDIO_LINE_2: - ret = sizeof(Object_AudioLine); - break; - case BHV_AINODE: - ret = 0x1C; - break; - case BHV_MODECHANGE: - case BHV_BONUS: - case BHV_TRIGGER: - ret = sizeof(Object_Trigger); - break; - case BHV_AUDIO_REVERB: - ret = sizeof(Object_AudioReverb); - break; - case BHV_TEXTURE_SCROLL: - ret = sizeof(Object_TexScroll); - break; - case BHV_WEAPON: - case BHV_WEAPON_2: - ret = sizeof(Object_Weapon); - break; - case BHV_WEAPON_BALLOON: - ret = sizeof(Object_WeaponBalloon); - break; - case BHV_BANANA: - ret = sizeof(Object_Banana); - break; - case BHV_BRIDGE_WHALE_RAMP: - ret = sizeof(Object_Bridge_WhaleRamp); - break; - case BHV_SEA_MONSTER: - ret = 0x18; - break; - case BHV_COLLECT_EGG: - ret = sizeof(Object_CollectEgg); - break; - case BHV_STOPWATCH_MAN: - case BHV_PARK_WARDEN: - case BHV_GOLDEN_BALLOON: - ret = sizeof(Object_NPC); - break; - case BHV_LASER_GUN: - ret = sizeof(Object_LaserGun); - break; - case BHV_OVERRIDE_POS: - ret = 0x10; - break; - case BHV_DINO_WHALE: - case BHV_ANIMATED_OBJECT: - case BHV_CAMERA_ANIMATION: - case BHV_CAR_ANIMATION: - case BHV_CHARACTER_SELECT: - case BHV_VEHICLE_ANIMATION: - case BHV_HIT_TESTER: - case BHV_HIT_TESTER_2: - case BHV_PARK_WARDEN_2: - case BHV_ANIMATED_OBJECT_2: - case BHV_WIZPIG_SHIP: - case BHV_ANIMATED_OBJECT_3: - case BHV_ANIMATED_OBJECT_4: - case BHV_SNOWBALL: - case BHV_SNOWBALL_2: - case BHV_SNOWBALL_3: - case BHV_SNOWBALL_4: - case BHV_HIT_TESTER_3: - case BHV_HIT_TESTER_4: - case BHV_DOOR_OPENER: - case BHV_PIG_ROCKETEER: - case BHV_WIZPIG_GHOSTS: - ret = sizeof(Object_AnimatedObject); - break; - case BHV_MIDI_FADE: - ret = sizeof(Object_MidiFade); - break; - case BHV_MIDI_FADE_POINT: - ret = sizeof(Object_MidiFadePoint); - break; - case BHV_MIDI_CHANNEL_SET: - ret = 0x4; - break; - case BHV_BUTTERFLY: - temp_v0 = 0x10 - ((s32) obj64 & 0xF); - obj->unk64 = (Object_64 *) &obj64->butterfly.triangles[0].verticesArray[temp_v0]; - ret = (temp_v0 + sizeof(Object_Butterfly)); - break; - case BHV_FISH: - temp_v0 = 0x10 - ((s32) obj64 & 0xF); - obj->unk64 = (Object_64 *) &obj64->fish.triangles[0].verticesArray[temp_v0]; - ret = (temp_v0 + sizeof(Object_Fish)); - break; - case BHV_CHARACTER_FLAG: - temp_v0 = 0x10 - ((s32) obj64 & 0xF); - obj->unk64 = (Object_64 *) &obj64->character_flag.triangles[0].verticesArray[temp_v0]; - ret = (temp_v0 + sizeof(Object_CharacterFlag)); - break; - case BHV_UNK_5E: - ret = 0x60; - break; - case BHV_TROPHY_CABINET: - ret = sizeof(Object_TrophyCabinet); - break; - case BHV_FROG: - ret = sizeof(Object_Frog); - break; - case BHV_FIREBALL_OCTOWEAPON_2: - ret = sizeof(Object_Fireball_Octoweapon); - break; - default: - obj->unk64 = NULL; - break; + case BHV_RACER: + ret = sizeof(Object_Racer); + break; + case BHV_DOOR: + case BHV_TT_DOOR: + ret = sizeof(Object_TTDoor); + break; + case BHV_EXIT: + ret = sizeof(Object_Exit); + break; + case BHV_ANIMATOR: + ret = sizeof(Object_Animator); + break; + case BHV_AUDIO: + ret = sizeof(Object_Audio); + break; + case BHV_AUDIO_LINE: + case BHV_AUDIO_LINE_2: + ret = sizeof(Object_AudioLine); + break; + case BHV_AINODE: + ret = 0x1C; + break; + case BHV_MODECHANGE: + case BHV_BONUS: + case BHV_TRIGGER: + ret = sizeof(Object_Trigger); + break; + case BHV_AUDIO_REVERB: + ret = sizeof(Object_AudioReverb); + break; + case BHV_TEXTURE_SCROLL: + ret = sizeof(Object_TexScroll); + break; + case BHV_WEAPON: + case BHV_WEAPON_2: + ret = sizeof(Object_Weapon); + break; + case BHV_WEAPON_BALLOON: + ret = sizeof(Object_WeaponBalloon); + break; + case BHV_BANANA: + ret = sizeof(Object_Banana); + break; + case BHV_BRIDGE_WHALE_RAMP: + ret = sizeof(Object_Bridge_WhaleRamp); + break; + case BHV_SEA_MONSTER: + ret = 0x18; + break; + case BHV_COLLECT_EGG: + ret = sizeof(Object_CollectEgg); + break; + case BHV_STOPWATCH_MAN: + case BHV_PARK_WARDEN: + case BHV_GOLDEN_BALLOON: + ret = sizeof(Object_NPC); + break; + case BHV_LASER_GUN: + ret = sizeof(Object_LaserGun); + break; + case BHV_OVERRIDE_POS: + ret = 0x10; + break; + case BHV_DINO_WHALE: + case BHV_ANIMATED_OBJECT: + case BHV_CAMERA_ANIMATION: + case BHV_CAR_ANIMATION: + case BHV_CHARACTER_SELECT: + case BHV_VEHICLE_ANIMATION: + case BHV_HIT_TESTER: + case BHV_HIT_TESTER_2: + case BHV_PARK_WARDEN_2: + case BHV_ANIMATED_OBJECT_2: + case BHV_WIZPIG_SHIP: + case BHV_ANIMATED_OBJECT_3: + case BHV_ANIMATED_OBJECT_4: + case BHV_SNOWBALL: + case BHV_SNOWBALL_2: + case BHV_SNOWBALL_3: + case BHV_SNOWBALL_4: + case BHV_HIT_TESTER_3: + case BHV_HIT_TESTER_4: + case BHV_DOOR_OPENER: + case BHV_PIG_ROCKETEER: + case BHV_WIZPIG_GHOSTS: + ret = sizeof(Object_AnimatedObject); + break; + case BHV_MIDI_FADE: + ret = sizeof(Object_MidiFade); + break; + case BHV_MIDI_FADE_POINT: + ret = sizeof(Object_MidiFadePoint); + break; + case BHV_MIDI_CHANNEL_SET: + ret = 0x4; + break; + case BHV_BUTTERFLY: + temp_v0 = 0x10 - ((s32) obj64 & 0xF); + obj->unk64 = (Object_64 *) &obj64->butterfly.triangles[0].verticesArray[temp_v0]; + ret = (temp_v0 + sizeof(Object_Butterfly)); + break; + case BHV_FISH: + temp_v0 = 0x10 - ((s32) obj64 & 0xF); + obj->unk64 = (Object_64 *) &obj64->fish.triangles[0].verticesArray[temp_v0]; + ret = (temp_v0 + sizeof(Object_Fish)); + break; + case BHV_CHARACTER_FLAG: + temp_v0 = 0x10 - ((s32) obj64 & 0xF); + obj->unk64 = (Object_64 *) &obj64->character_flag.triangles[0].verticesArray[temp_v0]; + ret = (temp_v0 + sizeof(Object_CharacterFlag)); + break; + case BHV_UNK_5E: + ret = 0x60; + break; + case BHV_TROPHY_CABINET: + ret = sizeof(Object_TrophyCabinet); + break; + case BHV_FROG: + ret = sizeof(Object_Frog); + break; + case BHV_FIREBALL_OCTOWEAPON_2: + ret = sizeof(Object_Fireball_Octoweapon); + break; + default: + obj->unk64 = NULL; + break; } return (ret & ~3) + 4; @@ -6246,7 +6363,7 @@ s32 get_object_property_size(Object *obj, Object_64 *obj64) { * Run when an object is created. * Used to do one-time things like initialising variables * Arg2 is always zero. Effectively unused. -*/ + */ void run_object_init_func(Object *obj, void *entry, s32 param) { obj->behaviorId = obj->segment.header->behaviorId; switch (obj->behaviorId) { @@ -6254,7 +6371,7 @@ void run_object_init_func(Object *obj, void *entry, s32 param) { obj_init_racer(obj, (LevelObjectEntry_Racer *) entry); break; case BHV_SCENERY: - obj_init_scenery(obj, (LevelObjectEntry_Scenery*) entry); + obj_init_scenery(obj, (LevelObjectEntry_Scenery *) entry); break; case BHV_FISH: obj_init_fish(obj, (LevelObjectEntry_Fish *) entry, param); @@ -6512,142 +6629,144 @@ void run_object_init_func(Object *obj, void *entry, s32 param) { /** * Set initialisation property flags based off object ID. * This includes things like shadow data, interaction and visuals. -*/ + */ s32 obj_init_property_flags(s32 behaviorId) { s32 flags = OBJECT_SPAWN_NONE; - switch (behaviorId){ - case BHV_RACER: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK04 | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE; - break; - case BHV_SCENERY: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_INTERACTIVE; - break; - case BHV_WEAPON: - flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK04 | OBJECT_SPAWN_INTERACTIVE; - break; - case BHV_DINO_WHALE: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE; - break; - case BHV_DOOR: - case BHV_TT_DOOR: - flags = OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; - break; - case BHV_WEAPON_BALLOON: - case BHV_GOLDEN_BALLOON: - flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_INTERACTIVE; - break; - case BHV_HIT_TESTER: - case BHV_HIT_TESTER_2: - case BHV_SNOWBALL: - case BHV_SNOWBALL_2: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; - break; - case BHV_SNOWBALL_3: - case BHV_SNOWBALL_4: - case BHV_HIT_TESTER_3: - case BHV_HIT_TESTER_4: - flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; - break; - case BHV_UNK_18: - flags = OBJECT_SPAWN_UNK04; - break; - case BHV_STOPWATCH_MAN: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE; - break; - case BHV_BANANA: - case BHV_WORLD_KEY: - case BHV_SILVER_COIN: - case BHV_SILVER_COIN_2: - flags = OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_SHADOW; - break; - case BHV_LOG: - flags = OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; - break; - case BHV_BRIDGE_WHALE_RAMP: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; - break; - case BHV_RAMP_SWITCH: - flags = OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_SHADOW; - break; - case BHV_SEA_MONSTER: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_UNK08; - break; - case BHV_COLLECT_EGG: - flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_INTERACTIVE; - break; - case BHV_UNK_30: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_UNK08; - break; - case BHV_UNK_3F: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_UNK08; - break; - case BHV_ANIMATED_OBJECT: - case BHV_VEHICLE_ANIMATION: - case BHV_PARK_WARDEN_2: - case BHV_WIZPIG_SHIP: - case BHV_ANIMATED_OBJECT_4: - case BHV_PIG_ROCKETEER: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08; - break; - case BHV_CHARACTER_SELECT: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08; - break; - case BHV_TROPHY_CABINET: - case BHV_DYNAMIC_LIGHT_OBJECT_2: - case BHV_ROCKET_SIGNPOST: - case BHV_ROCKET_SIGNPOST_2: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; - break; - case BHV_UNK_5B: - flags = OBJECT_SPAWN_UNK01; - break; - case BHV_ANIMATED_OBJECT_2: - flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08; - break; - case BHV_EXIT: - case BHV_CHECKPOINT: - case BHV_WEAPON_2: - case BHV_SKY_CONTROL: - case BHV_MODECHANGE: - case BHV_BUOY_PIRATE_SHIP: - case BHV_BONUS: - case BHV_INFO_POINT: - case BHV_TRIGGER: - case BHV_ZIPPER_WATER: - case BHV_LAVA_SPURT: - case BHV_LASER_BOLT: - case BHV_LASER_GUN: - case BHV_ZIPPER_AIR: - case BHV_TELEPORT: - case BHV_FIREBALL_OCTOWEAPON: - case BHV_FIREBALL_OCTOWEAPON_2: - flags = OBJECT_SPAWN_INTERACTIVE; - break; - case BHV_ZIPPER_GROUND: - flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_INTERACTIVE; - break; - case BHV_ANIMATION: - case BHV_CAMERA_ANIMATION: - case BHV_BUTTERFLY: - flags = OBJECT_SPAWN_SHADOW; - break; - case BHV_PARK_WARDEN: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE; - break; - case BHV_FROG: - flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08; - break; - case BHV_UNK_72: - flags = OBJECT_SPAWN_UNK01; - break; - } - return flags; + switch (behaviorId) { + case BHV_RACER: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK04 | OBJECT_SPAWN_UNK08 | + OBJECT_SPAWN_INTERACTIVE; + break; + case BHV_SCENERY: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_INTERACTIVE; + break; + case BHV_WEAPON: + flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK04 | OBJECT_SPAWN_INTERACTIVE; + break; + case BHV_DINO_WHALE: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE; + break; + case BHV_DOOR: + case BHV_TT_DOOR: + flags = OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; + break; + case BHV_WEAPON_BALLOON: + case BHV_GOLDEN_BALLOON: + flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_INTERACTIVE; + break; + case BHV_HIT_TESTER: + case BHV_HIT_TESTER_2: + case BHV_SNOWBALL: + case BHV_SNOWBALL_2: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE | + OBJECT_SPAWN_UNK20; + break; + case BHV_SNOWBALL_3: + case BHV_SNOWBALL_4: + case BHV_HIT_TESTER_3: + case BHV_HIT_TESTER_4: + flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; + break; + case BHV_UNK_18: + flags = OBJECT_SPAWN_UNK04; + break; + case BHV_STOPWATCH_MAN: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE; + break; + case BHV_BANANA: + case BHV_WORLD_KEY: + case BHV_SILVER_COIN: + case BHV_SILVER_COIN_2: + flags = OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_SHADOW; + break; + case BHV_LOG: + flags = OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; + break; + case BHV_BRIDGE_WHALE_RAMP: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; + break; + case BHV_RAMP_SWITCH: + flags = OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_SHADOW; + break; + case BHV_SEA_MONSTER: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_UNK08; + break; + case BHV_COLLECT_EGG: + flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_INTERACTIVE; + break; + case BHV_UNK_30: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_UNK08; + break; + case BHV_UNK_3F: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_UNK08; + break; + case BHV_ANIMATED_OBJECT: + case BHV_VEHICLE_ANIMATION: + case BHV_PARK_WARDEN_2: + case BHV_WIZPIG_SHIP: + case BHV_ANIMATED_OBJECT_4: + case BHV_PIG_ROCKETEER: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08; + break; + case BHV_CHARACTER_SELECT: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08; + break; + case BHV_TROPHY_CABINET: + case BHV_DYNAMIC_LIGHT_OBJECT_2: + case BHV_ROCKET_SIGNPOST: + case BHV_ROCKET_SIGNPOST_2: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_INTERACTIVE | OBJECT_SPAWN_UNK20; + break; + case BHV_UNK_5B: + flags = OBJECT_SPAWN_UNK01; + break; + case BHV_ANIMATED_OBJECT_2: + flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08; + break; + case BHV_EXIT: + case BHV_CHECKPOINT: + case BHV_WEAPON_2: + case BHV_SKY_CONTROL: + case BHV_MODECHANGE: + case BHV_BUOY_PIRATE_SHIP: + case BHV_BONUS: + case BHV_INFO_POINT: + case BHV_TRIGGER: + case BHV_ZIPPER_WATER: + case BHV_LAVA_SPURT: + case BHV_LASER_BOLT: + case BHV_LASER_GUN: + case BHV_ZIPPER_AIR: + case BHV_TELEPORT: + case BHV_FIREBALL_OCTOWEAPON: + case BHV_FIREBALL_OCTOWEAPON_2: + flags = OBJECT_SPAWN_INTERACTIVE; + break; + case BHV_ZIPPER_GROUND: + flags = OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_INTERACTIVE; + break; + case BHV_ANIMATION: + case BHV_CAMERA_ANIMATION: + case BHV_BUTTERFLY: + flags = OBJECT_SPAWN_SHADOW; + break; + case BHV_PARK_WARDEN: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08 | OBJECT_SPAWN_INTERACTIVE; + break; + case BHV_FROG: + flags = OBJECT_SPAWN_UNK01 | OBJECT_SPAWN_SHADOW | OBJECT_SPAWN_UNK08; + break; + case BHV_UNK_72: + flags = OBJECT_SPAWN_UNK01; + break; + } + return flags; } /** * Run every frame for most objects with set behaviours. * One big switch statement for whichever object. -*/ + */ void run_object_loop_func(Object *obj, s32 updateRate) { update_object_stack_trace(OBJECT_UPDATE, obj->unk4A); switch (obj->behaviorId) { diff --git a/src/objects.h b/src/objects.h index 2d6e1b81..e5a3be90 100644 --- a/src/objects.h +++ b/src/objects.h @@ -332,7 +332,7 @@ void clear_object_pointers(void); void free_all_objects(void); s32 normalise_time(s32 timer); void func_8000CBC0(void); -s32 func_8000CC20(Object *arg0); +s32 func_8000CC20(Object *obj); s32 get_contpak_error(void); void instShowBearBar(void); s8 func_8000E138(void); @@ -344,7 +344,7 @@ void fontUseFont(void); s8 find_non_car_racers(void); s8 check_if_silver_coin_race(void); void despawn_player_racer(Object *obj, s32 vehicleID); -void set_time_trial_enabled(s32 arg0); +void set_time_trial_enabled(s32 status); u8 is_time_trial_enabled(void); u8 is_in_time_trial(void); Object *get_object(s32 index); @@ -360,16 +360,16 @@ s32 get_race_countdown(void); s32 get_race_start_timer(void); void ignore_bounds_check(void); void func_80012C30(void); -void func_80012C3C(Gfx** dList); -void func_80012C98(Gfx **dList); -void func_80012CE8(Gfx **dList); +void func_80012C3C(Gfx **dlist); +void func_80012C98(Gfx **dlist); +void func_80012CE8(Gfx **dlist); void render_object(Gfx **dList, MatrixS **mtx, Vertex **verts, Object *obj); void object_undo_player_tumble(Object *obj); void render_object_parts(Object *obj); -void unset_temp_model_transforms(Object *arg0); +void unset_temp_model_transforms(Object *obj); void func_800142B8(void); u32 func_800179D0(void); -void set_taj_challenge_type(s32 arg0); +void set_taj_challenge_type(s32 vehicleID); s16 get_taj_challenge_type(void); Object *find_taj_object(void); void func_8001A8D4(s32 arg0); @@ -384,8 +384,8 @@ SIDeviceStatus func_8001B738(s32 controllerIndex); u8 has_ghost_to_save(void); void set_ghost_none(void); f32 func_8001B834(Object_Racer *racer1, Object_Racer *racer2); -CheckpointNode *get_checkpoint_node(s32 arg0); -CheckpointNode *find_next_checkpoint_node(s32 arg0, s32 arg1); +CheckpointNode *get_checkpoint_node(s32 checkpointID); +CheckpointNode *find_next_checkpoint_node(s32 splinePos, s32 arg1); s32 get_checkpoint_count(void); Object **get_racer_objects(s32 *numRacers); Object **get_racer_objects_by_port(s32 *numRacers); @@ -398,14 +398,14 @@ void func_8001D1BC(s32 arg0); Object *func_8001D1E4(s32 *arg0); Object *func_8001D214(s32 arg0); void set_world_shading(f32 brightness, f32 ambient, s16 angleX, s16 angleY, s16 angleZ); -void set_shading_properties(ShadeProperties *shading, f32 brightness, f32 ambient, s16 angleX, s16 angleY, s16 angleZ); +void set_shading_properties(ShadeProperties *arg0, f32 brightness, f32 ambient, s16 angleX, s16 angleY, s16 angleZ); void calc_dyn_light_and_env_map_for_object(ObjectModel *model, Object *object, s32 arg2, f32 intensity); s32 *get_misc_asset(s32 index); s32 func_8001E2EC(s32 arg0); void func_8001E344(s32 arg0); void func_8001E36C(s32 arg0, f32 *arg1, f32 *arg2, f32 *arg3); s16 get_cutscene_id(void); -void set_cutscene_id(s32 arg0); +void set_cutscene_id(s32 cutsceneID); void func_8001E45C(s32 cutsceneID); s32 get_object_list_index(void); s8 func_8001F3B8(void); @@ -415,13 +415,13 @@ s32 func_800210CC(s8 arg0); s8 func_800214C4(void); f32 lerp(f32 *arg0, u32 arg1, f32 arg2); void func_800228DC(s32 arg0, s32 arg1, s32 arg2); -void init_racer_for_challenge(s32 arg0); +void init_racer_for_challenge(s32 vehicleID); s8 is_taj_challenge(void); s32 func_80023568(void); s8 func_800235C0(void); void func_800235D0(s32 arg0); -void run_object_init_func(Object *arg0, void *arg1, s32 arg2); -void run_object_loop_func(Object *obj, s32 arg1); +void run_object_init_func(Object *obj, void *entry, s32 param); +void run_object_loop_func(Object *obj, s32 updateRate); s16 *func_80024594(s32 *currentCount, s32 *maxCount); void func_800245B4(s16 arg0); void object_do_player_tumble(Object *this); @@ -435,33 +435,34 @@ Object *get_racer_object_by_port(s32 index); void render_racer_shield(Gfx **dList, MatrixS **mtx, Vertex **vtxList, Object *obj); void render_racer_magnet(Gfx **dList, MatrixS **mtx, Vertex **vtxList, Object *obj); void update_envmap_position(f32 x, f32 y, f32 z); -s32 init_object_water_effect(Object *obj, WaterEffect *shadow); +s32 init_object_water_effect(Object *obj, WaterEffect *waterEffect); s32 func_8001B2F0(s32 mapId); void render_3d_billboard(Object *obj); -void render_misc_model(Object *obj, Vertex *verts, u32 numVertices, Triangle *triangles, u32 numTriangles, TextureHeader *tex, u32 flags, u32 offset, f32 yScale); +void render_misc_model(Object *obj, Vertex *verts, u32 numVertices, Triangle *triangles, u32 numTriangles, + TextureHeader *tex, u32 flags, u32 texOffset, f32 scale); void func_8000B290(void); void func_80016BC4(Object *obj); s32 func_8001C48C(Object *obj); void func_80022CFC(s32 arg0, f32 x, f32 y, f32 z); Object *func_8001B7A8(Object *racer, s32 position, f32 *distance); -s32 func_8000FD34(Object *arg0, Object_5C *arg1); +s32 func_8000FD34(Object *obj, Object_5C *matrices); void func_8000E4E8(s32 index); void objFreeAssets(Object *obj, s32 count, s32 objType); void func_8001709C(Object *obj); s32 play_footstep_sounds(Object *obj, s32 arg1, s32 frame, s32 oddSoundId, s32 evenSoundId); -void render_3d_misc(Object *this); -Object *find_nearest_spectate_camera(Object *obj, s32 *cameraID); +void render_3d_misc(Object *obj); +Object *find_nearest_spectate_camera(Object *obj, s32 *cameraId); s32 init_object_shadow(Object *obj, ShadowData *shadow); s32 render_mesh(ObjectModel *objModel, Object *obj, s32 startIndex, s32 flags, s32 someBool); void render_bubble_trap(ObjectTransform *trans, Object_68 *gfxData, Object *obj, s32 flags); void gParticlePtrList_flush(void); -s32 init_object_shading(Object *obj, ShadeProperties *shading); +s32 init_object_shading(Object *obj, ShadeProperties *shadeData); ObjectHeader *load_object_header(s32 index); s32 func_8000F99C(Object *); -void try_free_object_header(s32 arg0); +void try_free_object_header(s32 index); s32 get_object_property_size(Object *obj, Object_64 *obj64); void light_setup_light_sources(Object *obj); -s32 init_object_interaction_data(Object *arg0, ObjectInteraction *arg1); +s32 init_object_interaction_data(Object *obj, ObjectInteraction *interactObj); s32 func_8000FAC4(Object *obj, Object_6C *arg1); s32 obj_init_property_flags(s32 behaviorId); void tt_ghost_beaten(s32 arg0, s16 *playerId); @@ -492,7 +493,7 @@ void func_8001A8F4(s32 updateRate); //Non Matching void calc_dynamic_lighting_for_object_1(Object *, ObjectModel *, s16, Object *, f32, f32); void calc_dynamic_lighting_for_object_2(Object *, ObjectModel *, s16, f32); -void decrypt_magic_codes(s32 *arg0, s32 length); +void decrypt_magic_codes(s32 *data, s32 length); s32 func_80014814(s32 *); Object *spawn_object(LevelObjectEntryCommon *entry, s32); s32 func_8001F460(Object*, s32, Object*); diff --git a/src/particles.c b/src/particles.c index 2ebc945f..2534a9b1 100644 --- a/src/particles.c +++ b/src/particles.c @@ -64,7 +64,7 @@ ParticleProperties **gParticlesAssetTable = NULL; s32 gParticleBehavioursAssetTableCount = 0; s32 *gParticleBehavioursAssets = NULL; ParticleBehavior **gParticleBehavioursAssetTable = NULL; -ColourRGBA D_800E2D00[2] = {{{{ 0 }}}, {{{ 0 }}}}; +ColourRGBA D_800E2D00[2] = { { { { 0 } } }, { { { 0 } } } }; // Are these just Triangles? unk800E2D08 D_800E2D08[5] = { @@ -76,11 +76,8 @@ unk800E2D08 D_800E2D08[5] = { }; Vec3s D_800E2D58[5] = { - {{{ 0x0000, 0x01FF, 0x01FF }}}, - {{{ 0x0000, 0x01FF, 0x01FF }}}, - {{{ 0x0000, 0x0000, 0x01FF }}}, - {{{ 0x0000, 0x0000, 0x01FF }}}, - {{{ 0x0000, 0x01FF, 0x01FF }}}, + { { { 0x0000, 0x01FF, 0x01FF } } }, { { { 0x0000, 0x01FF, 0x01FF } } }, { { { 0x0000, 0x0000, 0x01FF } } }, + { { { 0x0000, 0x0000, 0x01FF } } }, { { { 0x0000, 0x01FF, 0x01FF } } }, }; // Are these just Triangles? @@ -96,21 +93,14 @@ unk800E2D08 D_800E2D78[8] = { }; Vec3s D_800E2DF8[8] = { - {{{ 0x0000, 0x0000, 0x01FF }}}, - {{{ 0x0000, 0x01FF, 0x01FF }}}, - {{{ 0x0000, 0x0000, 0x01FF }}}, - {{{ 0x0000, 0x01FF, 0x01FF }}}, - {{{ 0x0000, 0x0000, 0x01FF }}}, - {{{ 0x0000, 0x01FF, 0x01FF }}}, - {{{ 0x0000, 0x0000, 0x01FF }}}, - {{{ 0x0000, 0x01FF, 0x01FF }}}, + { { { 0x0000, 0x0000, 0x01FF } } }, { { { 0x0000, 0x01FF, 0x01FF } } }, { { { 0x0000, 0x0000, 0x01FF } } }, + { { { 0x0000, 0x01FF, 0x01FF } } }, { { { 0x0000, 0x0000, 0x01FF } } }, { { { 0x0000, 0x01FF, 0x01FF } } }, + { { { 0x0000, 0x0000, 0x01FF } } }, { { { 0x0000, 0x01FF, 0x01FF } } }, }; s16 D_800E2E28 = 0; -f32 gParticleGravityTable[8] = { - 0.0f, 0.1, 0.2f, 0.3f, 0.45f, 0.525f, 0.6f, 0.8f -}; +f32 gParticleGravityTable[8] = { 0.0f, 0.1, 0.2f, 0.3f, 0.45f, 0.525f, 0.6f, 0.8f }; s32 D_800E2E4C = 0; s32 D_800E2E50 = 0; @@ -121,29 +111,26 @@ Sprite **D_800E2E60 = NULL; s32 D_800E2E64 = 0; XYStruct gParticleCoordListTri[3] = { - { 0, 8 }, + { 0, 8 }, { 7, -4 }, { -7, -4 }, }; XYStruct gParticleCoordListQuad[4] = { - { -6, 6 }, - { 6, 6 }, + { -6, 6 }, + { 6, 6 }, { 6, -6 }, { -6, -6 }, }; s32 D_800E2E84[16] = { - 0x00000000, 0xC00840FF, 0xFF6008FF, 0x404040FF, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x1070FFFF, 0x00000000, 0x00000000 + 0x00000000, 0xC00840FF, 0xFF6008FF, 0x404040FF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1070FFFF, 0x00000000, 0x00000000, }; s32 D_800E2EC4[10] = { - 0x404040FF, 0x404040FF, 0x002D00FF, 0x002D00FF, - 0x403C0AFF, 0x403C0AFF, 0x4040FFFF, 0x4040FFFF, - 0x404040FF, 0x404040FF + 0x404040FF, 0x404040FF, 0x002D00FF, 0x002D00FF, 0x403C0AFF, + 0x403C0AFF, 0x4040FFFF, 0x4040FFFF, 0x404040FF, 0x404040FF, }; s32 gParticleOpacity = 256; @@ -155,8 +142,8 @@ s32 gParticleOpacity = 256; s32 gParticleUpdateRate; s32 D_80127C84; s32 D_80127C88[6]; -//printf.c -//thread0_epc +// printf.c +// thread0_epc /******************************/ void func_800AE270(void) { @@ -242,27 +229,29 @@ void init_particle_assets(void) { func_800AE490(); gParticlesAssetTable = (ParticleProperties **) load_asset_section_from_rom(ASSET_PARTICLES_TABLE); - gParticlesAssetTableCount = -1; + gParticlesAssetTableCount = -1; while (((s32) gParticlesAssetTable[gParticlesAssetTableCount + 1]) != -1) { gParticlesAssetTableCount++; } gParticlesAssets = (s32 *) load_asset_section_from_rom(ASSET_PARTICLES); for (i = 0; i < gParticlesAssetTableCount; i++) { - gParticlesAssetTable[i] = (ParticleProperties *) (((u8 *) gParticlesAssets) + ((s32) gParticlesAssetTable[i])); + gParticlesAssetTable[i] = (ParticleProperties *) (((u8 *) gParticlesAssets) + ((s32) gParticlesAssetTable[i])); } gParticleBehavioursAssetTable = (ParticleBehavior **) load_asset_section_from_rom(ASSET_PARTICLE_BEHAVIORS_TABLE); - gParticleBehavioursAssetTableCount = -1; + gParticleBehavioursAssetTableCount = -1; while (((s32) gParticleBehavioursAssetTable[gParticleBehavioursAssetTableCount + 1]) != -1) { gParticleBehavioursAssetTableCount++; } gParticleBehavioursAssets = (s32 *) load_asset_section_from_rom(ASSET_PARTICLE_BEHAVIORS); for (i = 0; i < gParticleBehavioursAssetTableCount; i++) { - gParticleBehavioursAssetTable[i] = (ParticleBehavior *) (((u8 *) gParticleBehavioursAssets) + ((s32) gParticleBehavioursAssetTable[i])); + gParticleBehavioursAssetTable[i] = + (ParticleBehavior *) (((u8 *) gParticleBehavioursAssets) + ((s32) gParticleBehavioursAssetTable[i])); if (((u32) gParticleBehavioursAssetTable[i]->unk9C) != 0xFFFFFFFF) { - gParticleBehavioursAssetTable[i]->unk9C = (s32 *) get_misc_asset((s32) gParticleBehavioursAssetTable[i]->unk9C); + gParticleBehavioursAssetTable[i]->unk9C = + (s32 *) get_misc_asset((s32) gParticleBehavioursAssetTable[i]->unk9C); } } } @@ -272,7 +261,7 @@ GLOBAL_ASM("asm/non_matchings/particles/func_800AE728.s") /** * Generate a triangle shaped particle mesh. * Use a lookup table to generate the vertices. -*/ + */ void generate_particle_shape_triangle(ParticleModel *model, Vertex **vtx, Triangle **triangles) { s16 i; Vertex *tempVtx; @@ -309,7 +298,7 @@ void generate_particle_shape_triangle(ParticleModel *model, Vertex **vtx, Triang /** * Generate a square shaped particle mesh. * Use a lookup table to generate the vertices. -*/ + */ void generate_particle_shape_quad(ParticleModel *model, Vertex **vtx, Triangle **triangles) { s16 i; Vertex *tempVtx; @@ -400,7 +389,7 @@ void func_800AF0A4(Particle *particle) { temp_v0 = (Object_44 *) particle->modelData; temp_v1 = temp_v0->unkC; temp_t8_0 = (temp_v0->unk0->unk0 - 1) << 5; - temp_t8 = (s32)temp_t8_0; + temp_t8 = (s32) temp_t8_0; temp_t1 = (temp_v0->unk0->unk1 - 1) << 5; temp_v1->unk4 = temp_t8 >> 1; temp_v1->unk6 = 0; @@ -479,7 +468,8 @@ void func_800AF29C(Particle *arg0, s32 behaviourID, s32 propertyID, s16 velX, s1 } else { arg0->data.lifeTime = 255; } - arg0->data.unkC_400.unkC = (s32 *) allocate_from_main_pool_safe(arg0->data.lifeTime * sizeof(uintptr_t), COLOUR_TAG_SEMITRANS_GREY); + arg0->data.unkC_400.unkC = + (s32 *) allocate_from_main_pool_safe(arg0->data.lifeTime * sizeof(uintptr_t), COLOUR_TAG_SEMITRANS_GREY); arg0->data.unkC_400.unk10 = behaviour->unk14; arg0->data.unkC_400.unk12 = behaviour->unk16; arg0->data.unkC_400.unk14 = behaviour->unk22; @@ -535,7 +525,7 @@ void func_800AF52C(Object *obj, s32 arg1) { temp_v0->data.opacity = gParticlesAssetTable[temp_v0->data.propertyID]->colour.a << 8; if (temp_v0->data.unk6 > 0) { // Useless if statement, since the loop already does this. - for (i = 0; i < temp_v0->data.unk6; i++){ + for (i = 0; i < temp_v0->data.unk6; i++) { temp = temp_v0->data.unkC_60[i]; temp->segment.particle.destroyTimer = 0; } @@ -586,17 +576,17 @@ void func_800AFC3C(Object *obj, s32 updateRate) { UNUSED s32 pad; s32 var_a3; u32 bits; - + bits = obj->unk74; var_a3 = obj->segment.header->unk57; - for(i = 0; i < var_a3; i++) { + for (i = 0; i < var_a3; i++) { if (bits & 1) { if (!(obj->unk6C[i].unk4 & 0x8000)) { func_800AF52C(obj, i); } if (obj->unk6C[i].unk4 & 0x4000) { func_800AFE5C((Particle *) obj, (Particle *) &obj->unk6C[i]); - } else if((obj->unk6C[i].unk4 & 0x400)) { + } else if ((obj->unk6C[i].unk4 & 0x400)) { func_800AFE5C((Particle *) obj, (Particle *) &obj->unk6C[i]); } else { obj->unk6C[i].unkA += updateRate; @@ -620,7 +610,7 @@ void func_800AFC3C(Object *obj, s32 updateRate) { func_800AF6E4(obj, i); } var_a3 = obj->segment.header->unk57; - } else if((obj->unk6C[i].unk4 & 0x400)) { + } else if ((obj->unk6C[i].unk4 & 0x400)) { temp_s1_2 = &obj->unk6C[i]; obj->unk6C[i].unk4 |= 0x200; if (temp_s1_2->unk6 == 0) { @@ -637,7 +627,7 @@ void func_800AFC3C(Object *obj, s32 updateRate) { } } -//TODO: Should this be void func_800AFE5C(Object *arg0, Object_6C *arg1)? +// TODO: Should this be void func_800AFE5C(Object *arg0, Object_6C *arg1)? void func_800AFE5C(Particle *arg0, Particle *arg1) { Particle *temp_s0; Particle *tempObj; @@ -701,13 +691,16 @@ void func_800B0010(Particle *arg0, Particle *arg1, Particle *arg2, ParticleBehav flags = arg3->behaviourFlags & (PARTICLE_VEL_Z | PARTICLE_VEL_Y | PARTICLE_VEL_X); if (flags) { if (flags & PARTICLE_VEL_X) { - arg0->segment.x_velocity += (f32) get_random_number_from_range(-arg3->velocityRangeX1, arg3->velocityRangeX1) * 0.00001525878906; + arg0->segment.x_velocity += + (f32) get_random_number_from_range(-arg3->velocityRangeX1, arg3->velocityRangeX1) * 0.00001525878906; } if (flags & PARTICLE_VEL_Y) { - arg0->segment.y_velocity += (f32) get_random_number_from_range(-arg3->velocityRangeY1, arg3->velocityRangeY1) * 0.00001525878906; + arg0->segment.y_velocity += + (f32) get_random_number_from_range(-arg3->velocityRangeY1, arg3->velocityRangeY1) * 0.00001525878906; } if (flags & PARTICLE_VEL_Z) { - arg0->segment.z_velocity += (f32) get_random_number_from_range(-arg3->velocityRangeZ1, arg3->velocityRangeZ1) * 0.00001525878906; + arg0->segment.z_velocity += + (f32) get_random_number_from_range(-arg3->velocityRangeZ1, arg3->velocityRangeZ1) * 0.00001525878906; } } switch (arg3->flags & (0x40 | 0x20 | 0x10)) { @@ -728,7 +721,8 @@ void func_800B0010(Particle *arg0, Particle *arg1, Particle *arg2, ParticleBehav velocityPos.z = -arg3->unk3C; flags = arg3->behaviourFlags; if (flags & PARTICLE_UNK00000010) { - velocityPos.z += (f32) get_random_number_from_range(-arg3->gravityRange2, arg3->gravityRange2) * 0.00001525878906; + velocityPos.z += + (f32) get_random_number_from_range(-arg3->gravityRange2, arg3->gravityRange2) * 0.00001525878906; } if (flags & (PARTICLE_UNK00000040 | PARTICLE_UNK00000020)) { angle.y_rotation = arg2->data.angle.y_direction; @@ -739,11 +733,11 @@ void func_800B0010(Particle *arg0, Particle *arg1, Particle *arg2, ParticleBehav if (flags & PARTICLE_UNK00000040) { angle.x_rotation += get_random_number_from_range(-arg3->angleRangeX2, arg3->angleRangeX2); } - f32_vec3_apply_object_rotation3((ObjectTransform* ) &angle, (f32*) &velocityPos); + f32_vec3_apply_object_rotation3((ObjectTransform *) &angle, (f32 *) &velocityPos); } else { - f32_vec3_apply_object_rotation3((ObjectTransform* ) &arg2->data.angle.y_direction, (f32*) &velocityPos); + f32_vec3_apply_object_rotation3((ObjectTransform *) &arg2->data.angle.y_direction, (f32 *) &velocityPos); } - f32_vec3_apply_object_rotation((ObjectTransform* ) arg0->segment.unk3C, (f32*) &velocityPos); + f32_vec3_apply_object_rotation((ObjectTransform *) arg0->segment.unk3C, (f32 *) &velocityPos); arg0->segment.x_velocity += velocityPos.x; arg0->segment.y_velocity += velocityPos.y; arg0->segment.z_velocity += velocityPos.z; @@ -760,7 +754,9 @@ void func_800B03C0(Particle *particle, Particle *arg1, Particle *arg2, ParticleB particle->baseVelZ = arg2->data.baseVelZ; particle->forwardVel = behaviour->forwardVel; if (behaviour->behaviourFlags & PARTICLE_FORWARDVEL) { - particle->forwardVel += (f32) get_random_number_from_range(-behaviour->velocityRange, behaviour->velocityRange) * 0.00001525878906; // 0.00001525878906 ~= 1.0/65536.0 + particle->forwardVel += + (f32) get_random_number_from_range(-behaviour->velocityRange, behaviour->velocityRange) * + 0.00001525878906; // 0.00001525878906 ~= 1.0/65536.0 } if (behaviour->flags & 1) { posVel.x = 0.0f; @@ -768,7 +764,8 @@ void func_800B03C0(Particle *particle, Particle *arg1, Particle *arg2, ParticleB posVel.z = -behaviour->unk10; flags = behaviour->behaviourFlags; if (flags & PARTICLE_GRAVITY) { - posVel.z += (f32) get_random_number_from_range(-behaviour->gravityRange1, behaviour->gravityRange1) * 0.00001525878906; + posVel.z += (f32) get_random_number_from_range(-behaviour->gravityRange1, behaviour->gravityRange1) * + 0.00001525878906; } if (flags & (PARTICLE_UNK00000004 | PARTICLE_UNK00000002)) { angle.y_rotation = arg2->data.angle.y_rotation; @@ -779,9 +776,9 @@ void func_800B03C0(Particle *particle, Particle *arg1, Particle *arg2, ParticleB if (flags & PARTICLE_UNK00000004) { angle.x_rotation += get_random_number_from_range(-behaviour->angleRangeX1, behaviour->angleRangeX1); } - f32_vec3_apply_object_rotation3((ObjectTransform* ) &angle, (f32 *) &posVel); + f32_vec3_apply_object_rotation3((ObjectTransform *) &angle, (f32 *) &posVel); } else { - f32_vec3_apply_object_rotation((ObjectTransform* ) &arg2->data.angle.y_rotation, (f32 *) &posVel); + f32_vec3_apply_object_rotation((ObjectTransform *) &arg2->data.angle.y_rotation, (f32 *) &posVel); } particle->baseVelX += posVel.x; particle->baseVelY += posVel.y; @@ -853,7 +850,8 @@ Particle *func_800B0698(Particle *arg0, Particle *arg1) { } } if (var_v0->opacityTimer < var_v0->segment.particle.destroyTimer) { - var_v0->opacityVel = ((properties->opacityVel << 8) - (var_v0->opacity & 0xFFFF)) / (var_v0->segment.particle.destroyTimer - var_v0->opacityTimer); + var_v0->opacityVel = ((properties->opacityVel << 8) - (var_v0->opacity & 0xFFFF)) / + (var_v0->segment.particle.destroyTimer - var_v0->opacityTimer); } else { var_v0->opacityVel = 0; } @@ -921,20 +919,20 @@ GLOBAL_ASM("asm/non_matchings/particles/func_800B0BAC.s") Particle *func_800B1130(Particle *arg0, Particle *arg1) { s32 flags; ParticleProperties *properties; - Particle* var_v0; + Particle *var_v0; TextureHeader **texture; ParticleBehavior *behaviour; unk800B1130_SP28 *sp28; f32 sp24; s8 sp23; - + properties = gParticlesAssetTable[arg1->data.propertyID]; if (properties->unk0 == 3 || properties->unk0 == 4) { return NULL; } behaviour = arg1->data.behaviour; sp28 = (unk800B1130_SP28 *) behaviour->unk9C; - + var_v0 = func_800B1CB8(properties->unk0); if (var_v0 == NULL) { return var_v0; @@ -959,11 +957,15 @@ Particle *func_800B1130(Particle *arg0, Particle *arg1) { sp24 += (f32) get_random_number_from_range(-behaviour->unk90, behaviour->unk90) * 0.00001525878906; } if (behaviour->flags & 0x1000) { - var_v0->segment.scaleVel = sqrtf((arg0->segment.x_velocity * arg0->segment.x_velocity) + (arg0->segment.y_velocity * arg0->segment.y_velocity) + (arg0->segment.z_velocity * arg0->segment.z_velocity)) * sp24 * 0.1f; + var_v0->segment.scaleVel = sqrtf((arg0->segment.x_velocity * arg0->segment.x_velocity) + + (arg0->segment.y_velocity * arg0->segment.y_velocity) + + (arg0->segment.z_velocity * arg0->segment.z_velocity)) * + sp24 * 0.1f; } else { var_v0->segment.scaleVel = properties->scale * sp24; } - var_v0->segment.particle.destroyTimer = get_random_number_from_range(-properties->lifeTimeRange, properties->lifeTimeRange) + properties->lifeTime; + var_v0->segment.particle.destroyTimer = + get_random_number_from_range(-properties->lifeTimeRange, properties->lifeTimeRange) + properties->lifeTime; var_v0->segment.particle.unk38 = 0.0f; var_v0->segment.particle.unk34 = 0.0f; if (D_800E2D00[0].word != 0) { @@ -983,7 +985,8 @@ Particle *func_800B1130(Particle *arg0, Particle *arg1) { var_v0->colour.b = properties->colour.b; var_v0->colour.a = properties->colour.a; } - flags = behaviour->behaviourFlags & (PARTICLE_COLOURVEL_ALPHA | PARTICLE_COLOURVEL_BLUE | PARTICLE_COLOURVEL_GREEN | PARTICLE_COLOURVEL_RED); + flags = behaviour->behaviourFlags & + (PARTICLE_COLOURVEL_ALPHA | PARTICLE_COLOURVEL_BLUE | PARTICLE_COLOURVEL_GREEN | PARTICLE_COLOURVEL_RED); if (flags) { if (flags & PARTICLE_COLOURVEL_RED) { var_v0->colour.r += get_random_number_from_range(-behaviour->colourRangeR, behaviour->colourRangeR); @@ -1008,7 +1011,8 @@ Particle *func_800B1130(Particle *arg0, Particle *arg1) { } } if (var_v0->opacityTimer < var_v0->segment.particle.destroyTimer) { - var_v0->opacityVel = (s16) (((properties->opacityVel - properties->opacity) * gParticleOpacity) / (var_v0->segment.particle.destroyTimer - var_v0->opacityTimer)); + var_v0->opacityVel = (s16) (((properties->opacityVel - properties->opacity) * gParticleOpacity) / + (var_v0->segment.particle.destroyTimer - var_v0->opacityTimer)); } else { var_v0->opacityVel = 0; } @@ -1050,7 +1054,8 @@ Particle *func_800B1130(Particle *arg0, Particle *arg1) { } } if (behaviour->flags & 0x800) { - var_v0->segment.textureFrame = get_random_number_from_range(0, ((*texture)->numOfTextures >> 8) - 1) << 8; + var_v0->segment.textureFrame = get_random_number_from_range(0, ((*texture)->numOfTextures >> 8) - 1) + << 8; if ((var_v0->segment.unk40 & 3) == 2) { var_v0->segment.textureFrame |= 0xFF; } @@ -1085,13 +1090,16 @@ Particle *func_800B1130(Particle *arg0, Particle *arg1) { flags = behaviour->behaviourFlags & (PARTICLE_ANGLE_Z | PARTICLE_ANGLE_X | PARTICLE_ANGLE_Y); if (flags != 0) { if (flags & PARTICLE_ANGLE_Y) { - var_v0->segment.trans.y_rotation += get_random_number_from_range(-behaviour->angleRangeY3, behaviour->angleRangeY3); + var_v0->segment.trans.y_rotation += + get_random_number_from_range(-behaviour->angleRangeY3, behaviour->angleRangeY3); } if (flags & PARTICLE_ANGLE_X) { - var_v0->segment.trans.x_rotation += get_random_number_from_range(-behaviour->angleRangeX3, behaviour->angleRangeX3); + var_v0->segment.trans.x_rotation += + get_random_number_from_range(-behaviour->angleRangeX3, behaviour->angleRangeX3); } if (flags & PARTICLE_ANGLE_Z) { - var_v0->segment.trans.z_rotation += get_random_number_from_range(-behaviour->angleRangeZ3, behaviour->angleRangeZ3); + var_v0->segment.trans.z_rotation += + get_random_number_from_range(-behaviour->angleRangeZ3, behaviour->angleRangeZ3); } } var_v0->angleVelY = behaviour->angleVelY; @@ -1112,7 +1120,9 @@ Particle *func_800B1130(Particle *arg0, Particle *arg1) { func_800B0010(var_v0, arg0, arg1, behaviour); var_v0->gravity = gParticleGravityTable[(var_v0->segment.unk40 >> 4) & 7]; if (var_v0->segment.particle.movementType == PARTICLE_MOVEMENT_VELOCITY) { - var_v0->forwardVel = sqrtf((var_v0->segment.x_velocity * var_v0->segment.x_velocity) + (var_v0->segment.y_velocity * var_v0->segment.y_velocity) + (var_v0->segment.z_velocity * var_v0->segment.z_velocity)); + var_v0->forwardVel = sqrtf((var_v0->segment.x_velocity * var_v0->segment.x_velocity) + + (var_v0->segment.y_velocity * var_v0->segment.y_velocity) + + (var_v0->segment.z_velocity * var_v0->segment.z_velocity)); } if (behaviour->flags & 2) { arg1->data.unk6++; @@ -1135,12 +1145,11 @@ Particle *func_800B1130(Particle *arg0, Particle *arg1) { if (var_v0->modelData == NULL) { func_800B2040(var_v0); return NULL; - } else { + } else { return var_v0; } } - Particle *func_800B1CB8(s32 arg0) { s32 i; Particle *var_v1; @@ -1148,7 +1157,7 @@ Particle *func_800B1CB8(s32 arg0) { var_v1 = NULL; i = 0; - switch(arg0) { + switch (arg0) { case 0x80: if ((D_800E2CC0 != NULL)) { if (D_800E2CB8 >= D_800E2E54 - 1) { @@ -1156,7 +1165,7 @@ Particle *func_800B1CB8(s32 arg0) { D_800E2CBC = 1; } } else { - while(D_800E2CC0[i].unk2C != 0) { + while (D_800E2CC0[i].unk2C != 0) { i++; } D_800E2CC0[i].unk2C = 0x80; @@ -1240,62 +1249,61 @@ void func_800B2040(Particle *arg0) { TextureHeader *tex; switch (arg0->segment.particle.unk2C) { - case 0x80: - if (D_800E2CB8 > 0) { - if (arg0->modelData) { - free_sprite((Sprite *) &arg0->modelData->texture); + case 0x80: + if (D_800E2CB8 > 0) { + if (arg0->modelData) { + free_sprite((Sprite *) &arg0->modelData->texture); + } + D_800E2CB8--; + arg0->segment.particle.unk2C = 0; } - D_800E2CB8--; - arg0->segment.particle.unk2C = 0; - } - break; - case 0: - return; - case 1: - if (D_800E2CA0 > 0) { - tex = arg0->modelData->texture; - if (tex != NULL) { - free_texture(tex); + break; + case 0: + return; + case 1: + if (D_800E2CA0 > 0) { + tex = arg0->modelData->texture; + if (tex != NULL) { + free_texture(tex); + } + D_800E2CA0--; + arg0->segment.particle.unk2C = 0; } - D_800E2CA0--; - arg0->segment.particle.unk2C = 0; - } - break; - case 2: - if (D_800E2CAC > 0) { - tex = arg0->modelData->texture; - if (tex != NULL) { - free_texture(tex); + break; + case 2: + if (D_800E2CAC > 0) { + tex = arg0->modelData->texture; + if (tex != NULL) { + free_texture(tex); + } + D_800E2CAC--; + arg0->segment.particle.unk2C = 0; } - D_800E2CAC--; - arg0->segment.particle.unk2C = 0; - } - break; - case 3: - if (D_800E2CC4 > 0) { - tex = arg0->modelData->texture; - if (tex != NULL) { - free_texture(tex); + break; + case 3: + if (D_800E2CC4 > 0) { + tex = arg0->modelData->texture; + if (tex != NULL) { + free_texture(tex); + } + D_800E2CC4--; + arg0->segment.particle.unk2C = 0; } - D_800E2CC4--; - arg0->segment.particle.unk2C = 0; - } - break; - case 4: - if (D_800E2CD0 > 0) { - func_800B263C(arg0); - tex = arg0->modelData->texture; - if (tex != NULL) { - free_texture(tex); + break; + case 4: + if (D_800E2CD0 > 0) { + func_800B263C(arg0); + tex = arg0->modelData->texture; + if (tex != NULL) { + free_texture(tex); + } + D_800E2CD0--; + arg0->segment.particle.unk2C = 0; } - D_800E2CD0--; - arg0->segment.particle.unk2C = 0; - } - break; + break; } } - void func_800B2260(Particle *arg0) { Particle *temp_v0; s32 i; @@ -1316,7 +1324,7 @@ void func_800B2260(Particle *arg0) { /** * Call a function to update the current particle texture frame if applicable. * Applies movement, gets block ID and then shifts the opacity. -*/ + */ void handle_particle_movement(Particle *particle, s32 updateRate) { LevelModelSegmentBoundingBox *boundingBox; Particle *tempParticle; @@ -1351,17 +1359,24 @@ void handle_particle_movement(Particle *particle, s32 updateRate) { } boundingBox = get_segment_bounding_box(particle->segment.particle.blockID); if (boundingBox != NULL) { - if (particle->segment.trans.x_position < boundingBox->x1 || boundingBox->x2 < particle->segment.trans.x_position || - particle->segment.trans.y_position < boundingBox->y1 || boundingBox->y2 < particle->segment.trans.y_position || - particle->segment.trans.z_position < boundingBox->z1 || boundingBox->z2 < particle->segment.trans.z_position) { - particle->segment.particle.blockID = get_level_segment_index_from_position(particle->segment.trans.x_position, particle->segment.trans.y_position, particle->segment.trans.z_position); + if (particle->segment.trans.x_position < boundingBox->x1 || + boundingBox->x2 < particle->segment.trans.x_position || + particle->segment.trans.y_position < boundingBox->y1 || + boundingBox->y2 < particle->segment.trans.y_position || + particle->segment.trans.z_position < boundingBox->z1 || + boundingBox->z2 < particle->segment.trans.z_position) { + particle->segment.particle.blockID = get_level_segment_index_from_position( + particle->segment.trans.x_position, particle->segment.trans.y_position, + particle->segment.trans.z_position); } } else { - particle->segment.particle.blockID = get_level_segment_index_from_position(particle->segment.trans.x_position, particle->segment.trans.y_position, particle->segment.trans.z_position); + particle->segment.particle.blockID = get_level_segment_index_from_position( + particle->segment.trans.x_position, particle->segment.trans.y_position, + particle->segment.trans.z_position); } particle->segment.particle.destroyTimer -= gParticleUpdateRate; if (particle->segment.particle.destroyTimer <= 0) { - free_object((Object*) particle); + free_object((Object *) particle); } else { if (particle->opacityTimer == 0) { particle->opacity += gParticleUpdateRate * particle->opacityVel; @@ -1369,7 +1384,7 @@ void handle_particle_movement(Particle *particle, s32 updateRate) { if (particle->segment.unk40 & 0x1000) { particle->segment.trans.flags |= OBJ_FLAGS_UNK_0100; } else { - particle->segment.trans.flags |= OBJ_FLAGS_UNK_0080; + particle->segment.trans.flags |= OBJ_FLAGS_UNK_0080; } } } else { @@ -1383,7 +1398,6 @@ void handle_particle_movement(Particle *particle, s32 updateRate) { } } - void func_800B263C(Particle *arg0) { Particle *new_var; Particle *new_var2; @@ -1416,7 +1430,7 @@ void set_particle_texture_frame(Particle *particle) { s32 someFlag2; s32 someFlag3; s32 someFlag4; - + keepGoing = -1; i = 128; // This is needed to match. @@ -1470,7 +1484,7 @@ void set_particle_texture_frame(Particle *particle) { /** * Apply translation, rotation and scale based off the velocities of the particle. * Applies further translation based on the position of the parent. -*/ + */ void move_particle_basic_parent(Particle *particle) { s32 i; ObjectSegment *parent; @@ -1497,12 +1511,11 @@ void move_particle_basic_parent(Particle *particle) { } } - /** * Apply translation, rotation and scale based off the velocities of the particle. * Velocity is set from forward velocity. * Applies further translation based on the position of the parent. -*/ + */ void move_particle_velocity_parent(Particle *particle) { s32 i; ObjectSegment *parent; @@ -1532,7 +1545,7 @@ void move_particle_velocity_parent(Particle *particle) { /** * Apply translation, rotation and scale based off the velocities of the particle. * Uses base velocity, then applies additional velocity based off the forward moving direction. -*/ + */ void move_particle_with_velocities(Particle *particle) { s32 i; Vec3f vel; @@ -1558,7 +1571,7 @@ void move_particle_with_velocities(Particle *particle) { /** * Apply translation, rotation and scale based off the velocities of the particle. -*/ + */ void move_particle_basic(Particle *particle) { s32 i; @@ -1577,7 +1590,7 @@ void move_particle_basic(Particle *particle) { /** * Apply translation, rotation and scale based off the velocities of the particle. * Velocity is set from forward velocity. -*/ + */ void move_particle_with_velocity(Particle *particle) { s32 i; @@ -1598,7 +1611,7 @@ void move_particle_with_velocity(Particle *particle) { /** * Iterate through every object and render it as particle if applicable. -*/ + */ UNUSED void render_active_particles(Gfx **dList, MatrixS **arg1, Vertex **arg2) { UNUSED s32 pad; UNUSED s32 pad2; @@ -1618,7 +1631,7 @@ UNUSED void render_active_particles(Gfx **dList, MatrixS **arg1, Vertex **arg2) /** * Load a texture then render a sprite or a billboard. -*/ + */ void render_particle(Particle *particle, Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 flags) { s32 renderFlags; s32 alpha; @@ -1627,7 +1640,7 @@ void render_particle(Particle *particle, Gfx **dList, MatrixS **mtx, Vertex **vt Vertex *tempvtx; renderFlags = (RENDER_FOG_ACTIVE | RENDER_Z_COMPARE); - + // Never true if (particle->segment.unk40 & flags && D_800E2CDC < 512) { return; @@ -1648,15 +1661,18 @@ void render_particle(Particle *particle, Gfx **dList, MatrixS **mtx, Vertex **vt temp = particle->segment.textureFrame; particle->segment.textureFrame >>= 8; particle->segment.textureFrame = (particle->segment.textureFrame * 255) / (particle->unk44_1->textureCount); - render_sprite_billboard(dList, mtx, vtx, (Object *) particle, (unk80068514_arg4 *) particle->modelData, renderFlags); + render_sprite_billboard(dList, mtx, vtx, (Object *) particle, (unk80068514_arg4 *) particle->modelData, + renderFlags); particle->segment.textureFrame = temp; } else { modelData = particle->modelData; if (modelData->texture) { camera_push_model_mtx(dList, mtx, &particle->segment.trans, 1.0f, 0.0f); - load_and_set_texture(dList, (TextureHeader *) modelData->texture, renderFlags, particle->segment.textureFrame << 8); + load_and_set_texture(dList, (TextureHeader *) modelData->texture, renderFlags, + particle->segment.textureFrame << 8); gSPVertexDKR((*dList)++, OS_K0_TO_PHYSICAL(modelData->vertices), modelData->vertexCount, 0); - gSPPolygon((*dList)++, OS_K0_TO_PHYSICAL(modelData->triangles), modelData->triangleCount, TRIN_ENABLE_TEXTURE); + gSPPolygon((*dList)++, OS_K0_TO_PHYSICAL(modelData->triangles), modelData->triangleCount, + TRIN_ENABLE_TEXTURE); apply_matrix_from_stack(dList); } } @@ -1667,11 +1683,13 @@ void render_particle(Particle *particle, Gfx **dList, MatrixS **mtx, Vertex **vt gDPSetEnvColor((*dList)++, 255, 255, 255, 0); } } else { - renderFlags = (RENDER_VTX_ALPHA | RENDER_Z_UPDATE | RENDER_FOG_ACTIVE | RENDER_Z_COMPARE | RENDER_ANTI_ALIASING); + renderFlags = + (RENDER_VTX_ALPHA | RENDER_Z_UPDATE | RENDER_FOG_ACTIVE | RENDER_Z_COMPARE | RENDER_ANTI_ALIASING); gDPSetEnvColor((*dList)++, 255, 255, 255, 0); if (particle->segment.object.unk2C == 4) { if (particle->segment.camera.unk3A > 0) { - gDPSetPrimColor((*dList)++, 0, 0, particle->brightness, particle->brightness, particle->brightness, 255); + gDPSetPrimColor((*dList)++, 0, 0, particle->brightness, particle->brightness, particle->brightness, + 255); if (particle->unk77 == 0) { func_800B3E64((Object *) particle); } @@ -1681,7 +1699,8 @@ void render_particle(Particle *particle, Gfx **dList, MatrixS **mtx, Vertex **vt tempvtx = &modelData->vertices[temp]; load_and_set_texture(dList, modelData->texture, renderFlags, particle->segment.textureFrame << 8); gSPVertexDKR((*dList)++, OS_K0_TO_PHYSICAL(tempvtx), modelData->vertexCount, 0); - gSPPolygon((*dList)++, OS_K0_TO_PHYSICAL(modelData->triangles), modelData->triangleCount, TRIN_ENABLE_TEXTURE); + gSPPolygon((*dList)++, OS_K0_TO_PHYSICAL(modelData->triangles), modelData->triangleCount, + TRIN_ENABLE_TEXTURE); if (particle->brightness != 255) { gDPSetPrimColor((*dList)++, 0, 0, 255, 255, 255, 255); } @@ -1692,12 +1711,13 @@ void render_particle(Particle *particle, Gfx **dList, MatrixS **mtx, Vertex **vt modelData = particle->modelData; load_and_set_texture(dList, modelData->texture, renderFlags, particle->segment.textureFrame << 8); gSPVertexDKR((*dList)++, OS_K0_TO_PHYSICAL(modelData->vertices), modelData->vertexCount, 0); - gSPPolygon((*dList)++, OS_K0_TO_PHYSICAL(modelData->triangles), modelData->triangleCount, 1); + gSPPolygon((*dList)++, OS_K0_TO_PHYSICAL(modelData->triangles), modelData->triangleCount, 1); } else if (particle->unk68b > 0) { modelData = particle->modelData; load_and_set_texture(dList, modelData->texture, renderFlags, particle->segment.textureFrame << 8); gSPVertexDKR((*dList)++, OS_K0_TO_PHYSICAL(modelData->vertices), 4, 0); - gSPPolygon((*dList)++, OS_K0_TO_PHYSICAL(&modelData->triangles[modelData->triangleCount]), 1, TRIN_ENABLE_TEXTURE); + gSPPolygon((*dList)++, OS_K0_TO_PHYSICAL(&modelData->triangles[modelData->triangleCount]), 1, + TRIN_ENABLE_TEXTURE); } if (alpha != 255 || particle->brightness != 255) { gDPSetPrimColor((*dList)++, 0, 0, 255, 255, 255, 255); @@ -1718,7 +1738,7 @@ void func_800B3E64(Object *obj) { Vertex *otherVerts; Vertex *verts; Object_LightData_UnkC_Unk44 *prev_s1; - + lightData = (Object_LightData *) obj->lightData; prev_s0 = NULL; prev_s1 = NULL; @@ -1740,7 +1760,12 @@ void func_800B3E64(Object *obj) { // It seems super odd to do negative indices. Why not just increment by 4 and add up from there? verts = &temp_s1->unk8[temp_s0->unk75 << 3]; - if (1) { } if (1) { } if (1) { } if (1) { } if (1) { } if (1) { } // Fake + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} // Fake verts += 7; verts[-3].x = temp_s0->trans.x_position + vec3_0.f[0]; verts[-3].y = temp_s0->trans.y_position + vec3_0.f[1]; @@ -1770,23 +1795,22 @@ void func_800B3E64(Object *obj) { verts[0].g = temp_s0->unk6D; verts[0].b = temp_s0->unk6E; verts[0].a = temp_s0->unk5C >> 8; - + verts = &temp_s1->unk8[temp_s0->unk75 << 3]; if (prev_s1 != NULL) { - if(1) { // Fake - otherVerts = &prev_s1->unk8[prev_s0->unk75 << 3]; + if (1) { // Fake + otherVerts = &prev_s1->unk8[prev_s0->unk75 << 3]; } otherVerts += 4; } else { otherVerts = &temp_s1->unk8[temp_s0->unk75 << 3]; otherVerts += 4; } - - + index--; verts += 3; otherVerts += 3; - + prev_s0 = temp_s0; prev_s1 = temp_s1; @@ -1818,9 +1842,9 @@ void func_800B3E64(Object *obj) { verts[0].g = otherVerts[0].g; verts[0].b = otherVerts[0].b; verts[0].a = otherVerts[0].a; - + temp_s0->unk77 = -1; - + continue; } break; @@ -1831,7 +1855,7 @@ void func_800B3E64(Object *obj) { /** * Return a specific particle asset table from the main table. -*/ + */ UNUSED ParticleProperties *get_particle_asset_table(s32 idx) { if (idx < gParticlesAssetTableCount) { return gParticlesAssetTable[idx]; @@ -1842,7 +1866,7 @@ UNUSED ParticleProperties *get_particle_asset_table(s32 idx) { /** * Return the next particle table after the index. * Make sure the index is in range by wrapping it. -*/ + */ UNUSED ParticleProperties *get_next_particle_table(s32 *idx) { *idx = *idx + 1; while (*idx >= gParticlesAssetTableCount) { @@ -1854,7 +1878,7 @@ UNUSED ParticleProperties *get_next_particle_table(s32 *idx) { /** * Return the previous particle table before the index. * Make sure the index is in range by wrapping it. -*/ + */ UNUSED ParticleProperties *get_previous_particle_table(s32 *idx) { *idx = *idx - 1; while (*idx < 0) { @@ -1865,7 +1889,7 @@ UNUSED ParticleProperties *get_previous_particle_table(s32 *idx) { /** * Return the particle behaviour ID from the behaviour table. -*/ + */ UNUSED ParticleBehavior *get_particle_behaviour(s32 idx) { if (idx < gParticleBehavioursAssetTableCount) { return gParticleBehavioursAssetTable[idx]; @@ -1892,7 +1916,7 @@ UNUSED ParticleBehavior *func_800B461C(s32 *idx) { void func_800B4668(Object *obj, s32 idx, s32 arg2, s32 arg3) { s32 temp_v0; - arg3 <<= 8; + arg3 <<= 8; temp_v0 = (obj->unk6C[idx].unkA & 0xFFFF) + arg2; if (arg3 < temp_v0) { obj->unk6C[idx].unkA = arg3; @@ -1905,7 +1929,7 @@ void func_800B4668(Object *obj, s32 idx, s32 arg2, s32 arg3) { void func_800B46BC(Object *obj, s32 idx, s32 arg2, s32 arg3) { s32 temp_v0; - arg3 <<= 8; + arg3 <<= 8; temp_v0 = (obj->unk6C[idx].unkA & 0xFFFF) - arg2; if (temp_v0 < arg3) { obj->unk6C[idx].unkA = arg3; diff --git a/src/particles.h b/src/particles.h index 23a70b08..bc4220b6 100644 --- a/src/particles.h +++ b/src/particles.h @@ -211,20 +211,20 @@ void func_800AE2D8(void); void func_800AE374(void); void func_800AE438(void); void func_800AE490(void); -void generate_particle_shape_triangle(ParticleModel *arg0, Vertex **arg1, Triangle **arg2); -void generate_particle_shape_quad(ParticleModel *arg0, Vertex **arg1, Triangle **arg2); -void func_800AEF88(ParticleModel *arg0, Vertex **arg1, Triangle **arg2); -void func_800AF024(ParticleModel *arg0, Vertex **arg1, Triangle **arg2); +void generate_particle_shape_triangle(ParticleModel *model, Vertex **vtx, Triangle **triangles); +void generate_particle_shape_quad(ParticleModel *model, Vertex **vtx, Triangle **triangles); +void func_800AEF88(ParticleModel *model, Vertex **vtx, Triangle **triangles); +void func_800AF024(ParticleModel *model, Vertex **vtx, Triangle **triangles); void func_800AF0A4(Particle *particle); void func_800AF0F0(Particle *particle); -void partInitTrigger(Particle *arg0, s32 arg1, s32 arg2); -void func_800AF29C(Particle *arg0, s32 arg1, s32 arg2, s16 arg3, s16 arg4, s16 arg5); +void partInitTrigger(Particle *particle, s32 behaviourID, s32 propertyID); +void func_800AF29C(Particle *arg0, s32 behaviourID, s32 propertyID, s16 velX, s16 velY, s16 velZ); void func_800AF6E4(Object *obj, s32 arg1); void func_800B2260(Particle *arg0); void func_800B263C(Particle *arg0); void init_particle_assets(void); -void set_particle_texture_frame(Particle *arg0); -void func_800B03C0(Particle *arg0, Particle *arg1, Particle *arg2, ParticleBehavior *arg3); +void set_particle_texture_frame(Particle *particle); +void func_800B03C0(Particle *particle, Particle *arg1, Particle *arg2, ParticleBehavior *behaviour); void func_800B2040(Particle *arg0); void handle_particle_movement(Particle *particle, s32 updateRate); void func_800B0010(Particle *arg0, Particle *arg1, Particle *arg2, ParticleBehavior *arg3); @@ -233,7 +233,7 @@ Particle *func_800B1CB8(s32 arg0); void func_800AFE5C(Particle *arg0, Particle *arg1); Particle *func_800B1130(Particle *arg0, Particle *arg1); void func_800AF52C(Object *obj, s32 arg1); -void func_800AF134(Particle *arg0, s32 arg1, s32 arg2, s16 arg3, s16 arg4, s16 arg5); +void func_800AF134(Particle *particle, s32 behaviourID, s32 propertyID, s16 velX, s16 velY, s16 velZ); void render_particle(Particle *particle, Gfx **dList, MatrixS **mtx, Vertex **vtx, s32 flags); void func_800B4668(Object *obj, s32 idx, s32 arg2, s32 arg3); void func_800B46BC(Object *obj, s32 idx, s32 arg2, s32 arg3); diff --git a/src/printf.c b/src/printf.c index cf1cd3d2..77ff099e 100644 --- a/src/printf.c +++ b/src/printf.c @@ -14,117 +14,117 @@ s32 D_800E2EF0 = 0; -//Char width is (v - u) + 1 +// Char width is (v - u) + 1 TexFontCoords gDebugFontCoords[3][32] = { - //ASCII symbols and numbers - //(This is out of order since they subtract 0x21 instead of 0x20) - //!"#$%&'()*+,-./0123456789:;<=>?{SPACE} - { - { 0x02, 0x04, }, //! - { 0x06, 0x08, }, //" - { 0x0A, 0x0F, }, //# - { 0x11, 0x15, }, //$ - { 0x17, 0x1F, }, //% - { 0x21, 0x27, }, //& - { 0x29, 0x2B, }, //' - { 0x2D, 0x2F, }, //( - { 0x31, 0x33, }, //) - { 0x35, 0x38, }, //* - { 0x3A, 0x3F, }, //+ - { 0x41, 0x43, }, //, - { 0x45, 0x48, }, //- - { 0x4A, 0x4B, }, //. - { 0x4D, 0x50, }, /// - { 0x52, 0x56, }, //0 - { 0x58, 0x5B, }, //1 - { 0x5D, 0x62, }, //2 - { 0x64, 0x68, }, //3 - { 0x6A, 0x6F, }, //4 - { 0x71, 0x76, }, //5 - { 0x78, 0x7D, }, //6 - { 0x7F, 0x84, }, //7 - { 0x86, 0x8B, }, //8 - { 0x8D, 0x92, }, //9 - { 0x94, 0x96, }, //: - { 0x98, 0x9A, }, //; - { 0x9D, 0xA2, }, //< - { 0xA5, 0xA9, }, //= - { 0xAB, 0xB0, }, //> - { 0xB3, 0xB8, }, //? - { 0x00, 0x01, }, //{SPACE} - }, - //ASCII Upper Case - //@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ + // ASCII symbols and numbers + // (This is out of order since they subtract 0x21 instead of 0x20) + // !"#$%&'()*+,-./0123456789:;<=>?{SPACE} { - { 0x00, 0x09, }, //@ - { 0x0B, 0x11, }, //A - { 0x13, 0x19, }, //B - { 0x1B, 0x21, }, //C - { 0x23, 0x29, }, //D - { 0x2B, 0x31, }, //E - { 0x33, 0x38, }, //F - { 0x3A, 0x41, }, //G - { 0x43, 0x49, }, //H - { 0x4B, 0x4C, }, //I - { 0x4E, 0x53, }, //J - { 0x55, 0x5B, }, //K - { 0x5D, 0x62, }, //L - { 0x64, 0x6B, }, //M - { 0x6D, 0x73, }, //N - { 0x75, 0x7B, }, //O - { 0x7D, 0x83, }, //P - { 0x85, 0x8B, }, //Q - { 0x8D, 0x93, }, //R - { 0x95, 0x9B, }, //S - { 0x9D, 0xA3, }, //T - { 0xA5, 0xAA, }, //U - { 0xAC, 0xB2, }, //V - { 0xB4, 0xBC, }, //W - { 0xBE, 0xC4, }, //X - { 0xC6, 0xCC, }, //Y - { 0xCE, 0xD3, }, //Z - { 0xD5, 0xD7, }, //[ - { 0xD9, 0xDC, }, //{backslash} - { 0xDE, 0xE0, }, //] - { 0xE2, 0xE7, }, //^ - { 0xE9, 0xEF, }, //_ + { 0x02, 0x04 }, // ! + { 0x06, 0x08 }, // " + { 0x0A, 0x0F }, // # + { 0x11, 0x15 }, // $ + { 0x17, 0x1F }, // % + { 0x21, 0x27 }, // & + { 0x29, 0x2B }, // ' + { 0x2D, 0x2F }, // ( + { 0x31, 0x33 }, // ) + { 0x35, 0x38 }, // * + { 0x3A, 0x3F }, // + + { 0x41, 0x43 }, // , + { 0x45, 0x48 }, // - + { 0x4A, 0x4B }, // . + { 0x4D, 0x50 }, // / + { 0x52, 0x56 }, // 0 + { 0x58, 0x5B }, // 1 + { 0x5D, 0x62 }, // 2 + { 0x64, 0x68 }, // 3 + { 0x6A, 0x6F }, // 4 + { 0x71, 0x76 }, // 5 + { 0x78, 0x7D }, // 6 + { 0x7F, 0x84 }, // 7 + { 0x86, 0x8B }, // 8 + { 0x8D, 0x92 }, // 9 + { 0x94, 0x96 }, // : + { 0x98, 0x9A }, // ; + { 0x9D, 0xA2 }, // < + { 0xA5, 0xA9 }, // = + { 0xAB, 0xB0 }, // > + { 0xB3, 0xB8 }, // ? + { 0x00, 0x01 }, // {SPACE} }, - //ASCII Lower Case - //`abcdefghijklmnopqrstuvwxyz{|}~ - { - { 0x00, 0x01, }, //` - { 0x03, 0x08, }, //a - { 0x09, 0x0F, }, //b - { 0x11, 0x16, }, //c - { 0x18, 0x1D, }, //d - { 0x1F, 0x24, }, //e - { 0x26, 0x28, }, //f - { 0x2A, 0x2F, }, //g - { 0x31, 0x36, }, //h - { 0x38, 0x39, }, //i - { 0x3B, 0x3D, }, //j - { 0x3F, 0x43, }, //k - { 0x45, 0x46, }, //l - { 0x48, 0x4F, }, //m - { 0x51, 0x56, }, //n - { 0x58, 0x5D, }, //o - { 0x5F, 0x64, }, //p - { 0x66, 0x6B, }, //q - { 0x6C, 0x70, }, //r - { 0x72, 0x77, }, //s - { 0x79, 0x7C, }, //t - { 0x7E, 0x82, }, //u - { 0x84, 0x89, }, //v - { 0x8B, 0x92, }, //w - { 0x94, 0x99, }, //x - { 0x9B, 0xA0, }, //y - { 0xA2, 0xA6, }, //z - { 0xA8, 0xAB, }, //{ - { 0xAD, 0xAE, }, //| - { 0xB0, 0xB3, }, //} - { 0xB5, 0xB9, }, //~ - { 0xB5, 0xB9, }, //ASCII DEL, so it just reuses the tilde above. - }, + // ASCII Upper Case + // @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ + { + { 0x00, 0x09 }, // @ + { 0x0B, 0x11 }, // A + { 0x13, 0x19 }, // B + { 0x1B, 0x21 }, // C + { 0x23, 0x29 }, // D + { 0x2B, 0x31 }, // E + { 0x33, 0x38 }, // F + { 0x3A, 0x41 }, // G + { 0x43, 0x49 }, // H + { 0x4B, 0x4C }, // I + { 0x4E, 0x53 }, // J + { 0x55, 0x5B }, // K + { 0x5D, 0x62 }, // L + { 0x64, 0x6B }, // M + { 0x6D, 0x73 }, // N + { 0x75, 0x7B }, // O + { 0x7D, 0x83 }, // P + { 0x85, 0x8B }, // Q + { 0x8D, 0x93 }, // R + { 0x95, 0x9B }, // S + { 0x9D, 0xA3 }, // T + { 0xA5, 0xAA }, // U + { 0xAC, 0xB2 }, // V + { 0xB4, 0xBC }, // W + { 0xBE, 0xC4 }, // X + { 0xC6, 0xCC }, // Y + { 0xCE, 0xD3 }, // Z + { 0xD5, 0xD7 }, // [ + { 0xD9, 0xDC }, // {backslash} + { 0xDE, 0xE0 }, // ] + { 0xE2, 0xE7 }, // ^ + { 0xE9, 0xEF }, // _ + }, + // ASCII Lower Case + // `abcdefghijklmnopqrstuvwxyz{|}~ + { + { 0x00, 0x01 }, // ` + { 0x03, 0x08 }, // a + { 0x09, 0x0F }, // b + { 0x11, 0x16 }, // c + { 0x18, 0x1D }, // d + { 0x1F, 0x24 }, // e + { 0x26, 0x28 }, // f + { 0x2A, 0x2F }, // g + { 0x31, 0x36 }, // h + { 0x38, 0x39 }, // i + { 0x3B, 0x3D }, // j + { 0x3F, 0x43 }, // k + { 0x45, 0x46 }, // l + { 0x48, 0x4F }, // m + { 0x51, 0x56 }, // n + { 0x58, 0x5D }, // o + { 0x5F, 0x64 }, // p + { 0x66, 0x6B }, // q + { 0x6C, 0x70 }, // r + { 0x72, 0x77 }, // s + { 0x79, 0x7C }, // t + { 0x7E, 0x82 }, // u + { 0x84, 0x89 }, // v + { 0x8B, 0x92 }, // w + { 0x94, 0x99 }, // x + { 0x9B, 0xA0 }, // y + { 0xA2, 0xA6 }, // z + { 0xA8, 0xAB }, // { + { 0xAD, 0xAE }, // | + { 0xB0, 0xB3 }, // } + { 0xB5, 0xB9 }, // ~ + { 0xB5, 0xB9 } // ASCII DEL, so it just reuses the tilde above. + } }; Gfx dDebugFontSettings[] = { @@ -182,15 +182,15 @@ char *_itoa(u64 n, char *outBuffer, u32 radix, s32 useUpperCase) { char *buffer; alphabet = (useUpperCase) ? (char *) gUpperCase : (char *) gLowerCase; - + for (buffer = outBuffer; n > 0; n /= radix) { *(--buffer) = alphabet[n % radix]; } - + return buffer; } -//Official Name: sprintfSetSpacingCodes +// Official Name: sprintfSetSpacingCodes void func_800B4A08(s32 arg0) { D_800E2EF0 = arg0; } @@ -203,7 +203,7 @@ UNUSED int sprintf(char *s, const char *format, ...) { va_end(args); } -//Official Name: vsprintf +// Official Name: vsprintf GLOBAL_ASM("asm/non_matchings/printf/vsprintf.s") void diPrintfInit(void) { @@ -213,7 +213,7 @@ void diPrintfInit(void) { gDebugPrintBufferEnd = gDebugPrintBufferStart; } -//Official Name: diPrintf +// Official Name: diPrintf s32 render_printf(const char *format, ...) { va_list args; s32 written; @@ -253,7 +253,7 @@ void print_debug_strings(Gfx **dList) { D_80127CB4 = 0; D_80127CB0 = D_80127CAC; D_80127CB2 = D_80127CAE; - while ((s32)buffer != (s32)gDebugPrintBufferEnd) { + while ((s32) buffer != (s32) gDebugPrintBufferEnd) { D_80127CB8 = FALSE; buffer += func_800B653C(dList, buffer); } @@ -262,7 +262,7 @@ void print_debug_strings(Gfx **dList) { func_800B6EE0(); gDebugFontTexture = -1; D_80127CB4 = 0; - while ((s32)buffer != (s32)gDebugPrintBufferEnd) { + while ((s32) buffer != (s32) gDebugPrintBufferEnd) { D_80127CB8 = TRUE; buffer += func_800B653C(dList, buffer); } @@ -293,15 +293,13 @@ void set_render_printf_background_colour(u8 red, u8 green, u8 blue, u8 alpha) { /** * Sets the character position of further prints to the given coordinates. * Official name: diPrintfSetXY -*/ -void set_render_printf_position(u16 x, u16 y) { - RENDER_PRINTF_CMD_SET_POSITION(x, y) -} + */ +void set_render_printf_position(u16 x, u16 y){ RENDER_PRINTF_CMD_SET_POSITION(x, y) } /** * Definitely has some fakematch shenanigans. * This will return the length in pixels of a given string using the debug small font. -*/ + */ UNUSED s32 func_800B63F4(const char *format, ...) { s32 pad; s32 fontCharU; @@ -320,18 +318,18 @@ UNUSED s32 func_800B63F4(const char *format, ...) { if (*ch != (0, '\n')) { if (pad == ' ') { stringLength += 6; - if (1){ } + if (1) {} } else { if (*ch < 0x40) { - //Character is a symbol or number and not a letter + // Character is a symbol or number and not a letter gDebugFontTexture = 0; - *ch-= 0x21; + *ch -= 0x21; } else if (*ch < 0x60) { - //Character is a upper case letter + // Character is a upper case letter gDebugFontTexture = 1; *ch -= 0x40; } else if (*ch < 0x80) { - //Character is a lower case letter + // Character is a lower case letter gDebugFontTexture = 2; *ch -= 0x60; } @@ -357,34 +355,37 @@ void func_800B695C(Gfx **dList, u32 ulx, u32 uly, u32 lrx, u32 lry) { } } -//Loads a font texture and returns the width of the character given. +// Loads a font texture and returns the width of the character given. s32 func_800B69FC(Gfx **dList, s32 asciiVal) { s32 fontCharWidth; s32 fontCharU; if (asciiVal < 0x40) { - //Character is a symbol or number and not a letter + // Character is a symbol or number and not a letter if (gDebugFontTexture != 0) { if (D_80127CB8) { - gDPLoadTextureBlock((*dList)++, OS_PHYSICAL_TO_K0(gTexture[0] + 1), G_IM_FMT_IA, G_IM_SIZ_8b, 192, 11, 0, 2, 2, 0, 0, 0, 0); + gDPLoadTextureBlock((*dList)++, OS_PHYSICAL_TO_K0(gTexture[0] + 1), G_IM_FMT_IA, G_IM_SIZ_8b, 192, 11, + 0, 2, 2, 0, 0, 0, 0); } gDebugFontTexture = 0; } asciiVal -= 0x21; } else if (asciiVal < 0x60) { - //Character is a upper case letter + // Character is a upper case letter if (gDebugFontTexture != 1) { if (D_80127CB8) { - gDPLoadTextureBlock((*dList)++, OS_PHYSICAL_TO_K0(gTexture[1] + 1), G_IM_FMT_IA, G_IM_SIZ_8b, 248, 11, 0, 2, 2, 0, 0, 0, 0); + gDPLoadTextureBlock((*dList)++, OS_PHYSICAL_TO_K0(gTexture[1] + 1), G_IM_FMT_IA, G_IM_SIZ_8b, 248, 11, + 0, 2, 2, 0, 0, 0, 0); } gDebugFontTexture = 1; } asciiVal -= 0x40; } else if (asciiVal < 0x80) { - //Character is a lower case letter + // Character is a lower case letter if (gDebugFontTexture != 2) { if (D_80127CB8) { - gDPLoadTextureBlock((*dList)++, OS_PHYSICAL_TO_K0(gTexture[2] + 1), G_IM_FMT_IA, G_IM_SIZ_8b, 192, 11, 0, 2, 2, 0, 0, 0, 0); + gDPLoadTextureBlock((*dList)++, OS_PHYSICAL_TO_K0(gTexture[2] + 1), G_IM_FMT_IA, G_IM_SIZ_8b, 192, 11, + 0, 2, 2, 0, 0, 0, 0); } gDebugFontTexture = 2; } @@ -394,7 +395,8 @@ s32 func_800B69FC(Gfx **dList, s32 asciiVal) { fontCharWidth = (gDebugFontCoords[gDebugFontTexture][asciiVal].v - fontCharU) + 1; if (D_80127CB8) { gDPSetCombineMode((*dList)++, DKR_CC_UNK12, DKR_CC_UNK12); - gSPTextureRectangle((*dList)++, (D_80127CAC << 2), (D_80127CAE << 2), ((D_80127CAC + fontCharWidth) << 2), ((D_80127CAE + 10) << 2), 0, (fontCharU << 5), 0, 1024, 1024); + gSPTextureRectangle((*dList)++, (D_80127CAC << 2), (D_80127CAE << 2), ((D_80127CAC + fontCharWidth) << 2), + ((D_80127CAE + 10) << 2), 0, (fontCharU << 5), 0, 1024, 1024); } return fontCharWidth; } diff --git a/src/racer.c b/src/racer.c index ab0945e1..bdfc2852 100644 --- a/src/racer.c +++ b/src/racer.c @@ -46,75 +46,52 @@ s32 D_800DCB5C = 0; // Currently unknown, might be a different type. // Not sure if D_800DCB58 & D_800DCB5C are actually a part of this array. f32 D_800DCB60[14] = { - -10.0f, 5.0f, 0.0f, 0.0f, - 10.0f, 5.0f, 0.0f, 0.0f, - -10.0f, 10.0f, 0.0f, 0.0f, - 10.0f, 10.0f, + -10.0f, 5.0f, 0.0f, 0.0f, 10.0f, 5.0f, 0.0f, 0.0f, -10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f, }; s32 gNumViewports = 0; // Currently unknown, might be a different type. -// Table used for quantifying speed reduction while the car drives over it, like how grass will slow you down more than the road. -// An antipiracy trigger can set the first index to 0.5f, which makes that surface type impossible to drive on. +// Table used for quantifying speed reduction while the car drives over it, like how grass will slow you down more than +// the road. An antipiracy trigger can set the first index to 0.5f, which makes that surface type impossible to drive +// on. f32 gSurfaceTractionTable[19] = { - 0.004f, 0.007f, 0.01f, 0.004f, - 0.01f, 0.01f, 0.01f, 0.01f, - 0.01f, 0.01f, 0.004f, 0.004f, - 0.004f, 0.004f, 0.004f, 0.004f, - 0.004f, 0.004f, 0.004f, + 0.004f, 0.007f, 0.01f, 0.004f, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, 0.01f, + 0.004f, 0.004f, 0.004f, 0.004f, 0.004f, 0.004f, 0.004f, 0.004f, 0.004f, }; // Can only assume this is surface related too. Not incline thresholds though. f32 D_800DCBE8[19] = { - 0.8f, 0.85f, 0.85f, 0.5f, - 0.5f, 0.5f, 0.5f, 0.5f, - 0.5f, 0.5f, 0.5f, 0.8f, - 0.8f, 0.84f, 0.8f, 0.8f, - 0.8f, 0.8f, 0.8f, + 0.8f, 0.85f, 0.85f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.8f, 0.8f, 0.84f, 0.8f, 0.8f, 0.8f, 0.8f, 0.8f, }; // When driving over this surface, the car begins to bob up and down to give the effect of roughness. s32 gSurfaceBobbingTable[19] = { - 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; // When landing on this surface, it makes a sound. // Strangely, they did only two surface types then called it a day. s32 gSurfaceSoundTable[13] = { - SOUND_NONE, SOUND_LAND_GRASS, SOUND_LAND_SAND, SOUND_NONE, - SOUND_NONE, SOUND_NONE, SOUND_NONE, SOUND_NONE, - SOUND_NONE, SOUND_NONE, SOUND_NONE, SOUND_NONE, - SOUND_NONE + SOUND_NONE, SOUND_LAND_GRASS, SOUND_LAND_SAND, SOUND_NONE, SOUND_NONE, SOUND_NONE, SOUND_NONE, + SOUND_NONE, SOUND_NONE, SOUND_NONE, SOUND_NONE, SOUND_NONE, SOUND_NONE, }; // Unused? s16 D_800DCCB4[12] = { - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; u16 D_800DCCCC[20] = { - 0x010C, 0x010B, 0x0009, 0x010C, - 0x010C, 0x010C, 0x010C, 0x010C, - 0x010C, 0x010C, 0x010C, 0x0005, - 0x010C, 0x010C, 0x010C, 0x010C, - 0x010C, 0x010C, 0x010C, 0x0000, + 0x010C, 0x010B, 0x0009, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, + 0x010C, 0x0005, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x0000, }; s32 gSurfaceFlagTable[19] = { - 1, 4, 0x10, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0x100, 1, 1, 1, 1, 1, + 1, 4, 0x10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0x100, 1, 1, 1, 1, 1, }; s32 gSurfaceFlagTable4P[20] = { - 0, 4, 16, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0x100, 0, 0, 0, 0, - 0, 0, + 0, 4, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x100, 0, 0, 0, 0, 0, 0, }; // Used to know how the AI should use a balloon when they have one. -s8 gRacerAIBalloonActionTable[NUM_WEAPON_TYPES] = { - 1, 1, 2, 2, 4, 3, 0, 6, - 4, 3, 2, 2, 5, 5, 5, 0 -}; +s8 gRacerAIBalloonActionTable[NUM_WEAPON_TYPES] = { 1, 1, 2, 2, 4, 3, 0, 6, 4, 3, 2, 2, 5, 5, 5, 0 }; // Unused? s8 D_800DCDA0[8] = { @@ -126,22 +103,9 @@ s8 D_800DCDA8[8] = { }; s8 D_800DCDB0[16][2] = { - {0x02,0xFE}, - {0x03, 0xFE}, - {0x02, 0xFC}, - {0x02, 0xFB}, - {0x02, 0xFB}, - {0x02, 0xFE}, - {0x02, 0xFD}, - {0x02, 0xFE}, - {0x03, 0xFD}, - {0x05, 0xFC}, - {0x04, 0xFE}, - {0x02, 0xFE}, - {0x02, 0xFA}, - {0x02, 0xFE}, - {0x08, 0xF8}, - {0x03, 0xFD}, + { 0x02, 0xFE }, { 0x03, 0xFE }, { 0x02, 0xFC }, { 0x02, 0xFB }, { 0x02, 0xFB }, { 0x02, 0xFE }, + { 0x02, 0xFD }, { 0x02, 0xFE }, { 0x03, 0xFD }, { 0x05, 0xFC }, { 0x04, 0xFE }, { 0x02, 0xFE }, + { 0x02, 0xFA }, { 0x02, 0xFE }, { 0x08, 0xF8 }, { 0x03, 0xFD }, }; // Checksum count for obj_loop_goldenballoon @@ -205,7 +169,7 @@ GhostNode *gGhostData[3]; s8 D_8011D59C; s8 D_8011D59D; s16 D_8011D59E; -s16 D_8011D5A0[3]; //gTTGhostNodeCount? +s16 D_8011D5A0[3]; // gTTGhostNodeCount? s16 D_8011D5A8[2]; s16 D_8011D5AC; // Previous MapId? s8 gRacerWaveCount; @@ -296,7 +260,8 @@ void func_80042D20(Object *obj, Object_Racer *racer, s32 updateRate) { if (temp_v0 == FALSE) { play_random_character_voice(obj, SOUND_VOICE_CHARACTER_NEGATIVE, 8, 3); } else { - func_8005CA84(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 5); + func_8005CA84(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 5); } play_random_character_voice(racerGroup[temp_v1_2], SOUND_VOICE_CHARACTER_POSITIVE, 8, 2); } @@ -308,7 +273,8 @@ void func_80042D20(Object *obj, Object_Racer *racer, s32 updateRate) { if (temp_v0 == FALSE) { play_random_character_voice(obj, SOUND_VOICE_CHARACTER_POSITIVE, 8, 3); } else { - func_8005CA84(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 3); + func_8005CA84(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 3); } } } @@ -403,7 +369,8 @@ void func_80042D20(Object *obj, Object_Racer *racer, s32 updateRate) { } } } - racer->unk209 &= (0x8000 | 0x4000 | 0x2000 | 0x1000 | 0x800 | 0x400 | 0x200 | 0x100 | 0x80 | 0x40 | 0x20 | 0x10 | 0x8 | 0x4 | 0x2); + racer->unk209 &= (0x8000 | 0x4000 | 0x2000 | 0x1000 | 0x800 | 0x400 | 0x200 | 0x100 | 0x80 | 0x40 | + 0x20 | 0x10 | 0x8 | 0x4 | 0x2); } if (racer->boostTimer != 0) { if (!(racer->unk209 & 2)) { @@ -429,7 +396,8 @@ void func_80042D20(Object *obj, Object_Racer *racer, s32 updateRate) { gCurrentButtonsReleased |= Z_TRIG; } racer->unk1C9 = 0; - if (sp58 != NULL && sp58->racer.playerIndex != PLAYER_COMPUTER && sp90 < 200.0f && var_t5 != 0 && var_t4 < 3 && miscAsset1[racer->characterId + (sp3F * 10)] < 5) { + if (sp58 != NULL && sp58->racer.playerIndex != PLAYER_COMPUTER && sp90 < 200.0f && var_t5 != 0 && + var_t4 < 3 && miscAsset1[racer->characterId + (sp3F * 10)] < 5) { racer->unk1C9 = 5; } if (D_8011D544 == 0.0f) { @@ -457,26 +425,26 @@ void func_80042D20(Object *obj, Object_Racer *racer, s32 updateRate) { racer->unk1CA = 2; } switch (racer->unk1C9) { - case 0: - if (sp5C != NULL && sp5C->racer.playerIndex == PLAYER_COMPUTER && sp5C->racer.unk1C9 == 0) { - if (racer->unk1CA == sp5C->racer.unk1CA && sp94 < 100.0) { - racer->unk1CA++; - if (racer->unk1CA > 3) { - racer->unk1CA = 3; + case 0: + if (sp5C != NULL && sp5C->racer.playerIndex == PLAYER_COMPUTER && sp5C->racer.unk1C9 == 0) { + if (racer->unk1CA == sp5C->racer.unk1CA && sp94 < 100.0) { + racer->unk1CA++; + if (racer->unk1CA > 3) { + racer->unk1CA = 3; + } } } - } - break; - case 4: - if (sp5C != NULL) { - racer->unk1BA = sp5C->racer.unk1BA; - } - break; - case 5: - if (sp58 != NULL) { - racer->unk1BA = sp58->racer.unk1BA; - } - break; + break; + case 4: + if (sp5C != NULL) { + racer->unk1BA = sp5C->racer.unk1BA; + } + break; + case 5: + if (sp58 != NULL) { + racer->unk1BA = sp58->racer.unk1BA; + } + break; } temp_v0_10 = (u16) is_taj_challenge(); if (temp_v0_10 != 0 || temp_v0 != 0) { @@ -549,7 +517,7 @@ GLOBAL_ASM("asm/non_matchings/racer/func_80042D20.s") /** * During specific or nonspecific actions, increase the steps in the AI behaviour table. * Increment percent chances of them performing specific actions, with a maximum of 100%. -*/ + */ void increment_ai_behaviour_chances(Object *obj, Object_Racer *racer, s32 updateRate) { AIBehaviourTable *aiTable; s8 *test; @@ -608,8 +576,8 @@ void increment_ai_behaviour_chances(Object *obj, Object_Racer *racer, s32 update if (aiTable->percentages[AI_GETS_BALLOON][i] > 100 || aiTable->percentages[AI_GETS_BALLOON][i] < 0) { aiTable->percentages[AI_GETS_BALLOON][i] = 100; } - if (aiTable->percentages[AI_EMPOWERED_BOOST][i] > 100 || aiTable->percentages[AI_EMPOWERED_BOOST][i] < 0) { - aiTable->percentages[AI_EMPOWERED_BOOST][i] = 100; + if (aiTable->percentages[AI_EMPOWERED_BOOST][i] > 100 || aiTable->percentages[AI_EMPOWERED_BOOST][i] < 0) { + aiTable->percentages[AI_EMPOWERED_BOOST][i] = 100; } if (aiTable->percentages[AI_BLUE_BALLOON][i] > 100 || aiTable->percentages[AI_BLUE_BALLOON][i] < 0) { aiTable->percentages[AI_BLUE_BALLOON][i] = 100; @@ -623,7 +591,7 @@ void increment_ai_behaviour_chances(Object *obj, Object_Racer *racer, s32 update /** * Depending on the race type, call a function that handles pathing. * During those functions, the racer inputs will be set to simulate control. -*/ + */ void racer_AI_pathing_inputs(Object *obj, Object_Racer *racer, s32 updateRate) { s32 raceType; @@ -649,7 +617,8 @@ void racer_AI_pathing_inputs(Object *obj, Object_Racer *racer, s32 updateRate) { } } - if (racer->velocity > -1.0 && racer->unk214 == 0 && !gRaceStartTimer && D_8011D544 == 0.0f && racer->groundedWheels && racer->unk215 == 0) { + if (racer->velocity > -1.0 && racer->unk214 == 0 && !gRaceStartTimer && D_8011D544 == 0.0f && + racer->groundedWheels && racer->unk215 == 0) { racer->unk213 += updateRate; if (racer->unk213 > 60) { @@ -690,7 +659,7 @@ void racer_AI_pathing_inputs(Object *obj, Object_Racer *racer, s32 updateRate) { /** * Rolls a number between 0 and 99. * Effectively, this is to make a 1-100% chance of it returning true, based on the number passed. -*/ + */ s32 roll_percent_chance(s32 chance) { return get_random_number_from_range(0, 99) < chance; } @@ -784,7 +753,7 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r var_v1 = gCurrentStickX - racer->steerAngle; var_a3 = (var_v1 * updateRateF) / var_f2; - + if (var_v1 != 0 && var_a3 == 0) { if (var_v1 > 0) { var_a3 = 1; @@ -798,13 +767,13 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r handle_racer_items(obj, racer, updateRate); func_800535C4(obj, racer); racer_attack_handler_hovercraft(obj, racer); - + if (gCurrentPlayerIndex != PLAYER_COMPUTER) { handle_racer_head_turning(obj, racer, updateRate); } else { slowly_reset_head_angle(racer); } - + if (gCurrentRacerInput & A_BUTTON) { racer->throttle += updateRateF * 0.016; if (racer->throttle > 1.0) { @@ -816,12 +785,12 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r racer->throttle = 0.0f; } } - + sp11C = racer->throttle; if ((racer->velocity > 0.0f) && (gCurrentRacerInput & A_BUTTON)) { sp11C = 1.0f; } - + sp11C = sp11C * 3.0f; spF4 = (sp11C * sp11C) / 9.0f; if (racer->exitObj != 0) { @@ -854,7 +823,11 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r } // Fake, fixes f12 & f14 swap. - if (1) { } if (1) { } if (1) { } if (1) { } if (1) { } + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} if (!racer->zipperDirCorrection) { gCurrentStickX = 0; @@ -872,7 +845,8 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r racer->steerVisualRotation += (var_v1 * updateRate) >> 3; if ((var_v1 < 0x400 && var_v1 > -0x400) || (racer->playerIndex == PLAYER_COMPUTER)) { if (racer->playerIndex != PLAYER_COMPUTER) { - sound_play_spatial(SOUND_ZIP_PAD_BOOST, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, NULL); + sound_play_spatial(SOUND_ZIP_PAD_BOOST, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, NULL); play_random_character_voice(obj, SOUND_VOICE_CHARACTER_POSITIVE, 8, (0x80 | 0x2)); } racer->boostTimer = normalise_time(45); @@ -913,22 +887,19 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r if (racer->unk1D4 > 10) { racer->unk1D4 = 10; } - } - else if (racer->spinout_timer < 0) { + } else if (racer->spinout_timer < 0) { racer->unk1D4 -= updateRate; if (racer->unk1D4 < (-10)) { racer->unk1D4 = -10; } - } - else if (racer->unk1D4 < 0) { + } else if (racer->unk1D4 < 0) { racer->unk1D4 += updateRate; if (racer->unk1D4 > 0) { racer->unk1D4 = 0; racer->unk1D5 = 1; } - } - else if (racer->unk1D4 > 0) { - racer->unk1D4 -= updateRate; + } else if (racer->unk1D4 > 0) { + racer->unk1D4 -= updateRate; if (racer->unk1D4 < 0) { racer->unk1D4 = 0; racer->unk1D5 = 1; @@ -938,7 +909,7 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r obj->segment.trans.x_rotation -= (obj->segment.trans.x_rotation * updateRate) >> 6; racer->x_rotation_vel -= (racer->x_rotation_vel * updateRate) >> 6; } - + if (racer->unk1D4 != 0) { i = racer->y_rotation_offset; racer->unk1D5 = 0; @@ -1049,8 +1020,7 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r sound_play(SOUND_BOUNCE, &racer->unk21C); sound_volume_set_relative(SOUND_BOUNCE, (void *) racer->unk21C, (racer->unk1E0 * 2) + 0x32); } - } - else if (racer->approachTarget == 0) { + } else if (racer->approachTarget == 0) { racer_play_sound(obj, SOUND_UNK_AF); obj->unk74 |= 0x30; } @@ -1094,7 +1064,8 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r play_random_character_voice(obj, SOUND_VOICE_CHARACTER_POSITIVE, SOUND_NUMBER_OF_RACERS, (0x80 | 0x2)); func_80072348(racer->playerIndex, 8); } - temp_f0 = sqrtf((obj->segment.z_velocity * obj->segment.z_velocity) + (obj->segment.x_velocity * obj->segment.x_velocity)); + temp_f0 = sqrtf((obj->segment.z_velocity * obj->segment.z_velocity) + + (obj->segment.x_velocity * obj->segment.x_velocity)); if (temp_f0 > 0.25) { racer->unk168 = arctan2_f(obj->segment.x_velocity, obj->segment.z_velocity) + 0x8000; var_v1 = ((0x8000 - racer->unk168) & 0xFFFF) - (racer->cameraYaw & 0xFFFF); @@ -1235,9 +1206,9 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r spE8 += racer->unk84 * updateRateF; spE4 += racer->unk88 * updateRateF; } - if (move_object(obj, (var_f16 * updateRateF) + spE8, obj->segment.y_velocity * updateRateF, (var_f12 * updateRateF) + spE4) - && gCurrentPlayerIndex != PLAYER_COMPUTER) - { + if (move_object(obj, (var_f16 * updateRateF) + spE8, obj->segment.y_velocity * updateRateF, + (var_f12 * updateRateF) + spE4) && + gCurrentPlayerIndex != PLAYER_COMPUTER) { sp67 = 1; } } else { @@ -1255,7 +1226,8 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r } var_f14 = 5.0f; sp118 = -10000.0f; - temp_v0_10 = get_wave_properties(obj->segment.trans.y_position, &sp118, &spD4); /* Linebreak skip for better codegen. Thanks IDO. */ \ + temp_v0_10 = get_wave_properties(obj->segment.trans.y_position, &sp118, + &spD4); /* Linebreak skip for better codegen. Thanks IDO. */ if (temp_v0_10) { var_f14 = racer->velocity; if (var_f14 < 0.0f) { @@ -1315,7 +1287,8 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r obj->segment.y_velocity = 4.0f; } if (gNumViewports < 2 && obj->segment.header->unk57 >= 9) { - if ((gCurrentRacerInput & (A_BUTTON | R_TRIG)) == (A_BUTTON | R_TRIG) && (gCurrentStickX < -30 || gCurrentStickX > 30)) { + if ((gCurrentRacerInput & (A_BUTTON | R_TRIG)) == (A_BUTTON | R_TRIG) && + (gCurrentStickX < -30 || gCurrentStickX > 30)) { func_800B4668(obj, 8, updateRate << 10, 0x80); } else { func_800B46BC(obj, 8, updateRate << 9, 0x20); @@ -1323,7 +1296,9 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r } if (gCurrentPlayerIndex >= PLAYER_ONE && racer->buoyancy > 0.0) { if (gNumViewports < 3) { - temp_f2 = ((obj->segment.x_velocity * obj->segment.x_velocity) + (obj->segment.y_velocity * obj->segment.y_velocity)) + (obj->segment.z_velocity * obj->segment.z_velocity); + temp_f2 = ((obj->segment.x_velocity * obj->segment.x_velocity) + + (obj->segment.y_velocity * obj->segment.y_velocity)) + + (obj->segment.z_velocity * obj->segment.z_velocity); if (temp_f2 > 16.0f) { if (temp_f2 < 80.0f) { obj->unk74 |= 0x8 | 0x4; @@ -1374,7 +1349,8 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r gCurrentRacerTransform.y_position = 0.0f; gCurrentRacerTransform.z_position = 0.0f; object_transform_to_matrix_2(sp68, &gCurrentRacerTransform); - guMtxXFMF(sp68, obj->segment.x_velocity, obj->segment.y_velocity, obj->segment.z_velocity, &racer->lateral_velocity, (f32 *) (&racer->unk34), &racer->velocity); + guMtxXFMF(sp68, obj->segment.x_velocity, obj->segment.y_velocity, obj->segment.z_velocity, &racer->lateral_velocity, + (f32 *) (&racer->unk34), &racer->velocity); if (racer->groundedWheels == 0 && racer->waterTimer == 0) { var_v1 = ((-gCurrentStickY * 0x40) & 0xFFFF) - (obj->segment.trans.x_rotation & 0xFFFF); if (var_v1 > 0x8000) { @@ -1400,7 +1376,8 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r if (racer->buoyancy != 0.0f || racer->groundedWheels == 4) { racer->unk1FB = 0; } - if (((gCurrentButtonsPressed & R_TRIG) && ((racer->buoyancy > 0.0f) || (racer->groundedWheels >= 2))) && (racer->unk1FB == 0)) { + if (((gCurrentButtonsPressed & R_TRIG) && ((racer->buoyancy > 0.0f) || (racer->groundedWheels >= 2))) && + (racer->unk1FB == 0)) { if (racer->buoyancy != 0.0f) { obj->segment.y_velocity += 4.5; if (obj->segment.y_velocity > 5.5) { @@ -1456,40 +1433,40 @@ void racer_attack_handler_hovercraft(Object *obj, Object_Racer *racer) { } play_random_character_voice(obj, SOUND_VOICE_CHARACTER_NEGATIVE, 8, 129); switch (racer->attackType) { - // Getting hit by a rocket, running into a landmine or an oil slick. - case ATTACK_EXPLOSION: - case ATTACK_SPIN: - racer->unk1F1 = 1; - if (bananas == 0) { - obj->segment.x_velocity = 0.0f; - obj->segment.z_velocity = 0.0f; - obj->segment.y_velocity = 8.0f; - } else { - obj->segment.x_velocity = obj->segment.x_velocity * 0.5; - obj->segment.z_velocity = obj->segment.z_velocity * 0.5; - obj->segment.y_velocity = 6.0f; - } - break; - // Crushed by something big, like a snowball. - case ATTACK_SQUISHED: - racer->squish_timer = 60; - break; - // Running into a bubble trap. - case ATTACK_BUBBLE: - racer->bubbleTrapTimer = 120; - obj->segment.x_velocity *= 0.7; - if (obj->segment.y_velocity > 2.0f) { - obj->segment.y_velocity = 2.0f; - } - obj->segment.z_velocity *= 0.7; - break; - // This goes unused. - case ATTACK_FLUNG: - racer->unk1F1 = 1; - racer->velocity = 0.0f; - obj->segment.y_velocity += 20.5; - racer_play_sound(obj, SOUND_WHEE); - break; + // Getting hit by a rocket, running into a landmine or an oil slick. + case ATTACK_EXPLOSION: + case ATTACK_SPIN: + racer->unk1F1 = 1; + if (bananas == 0) { + obj->segment.x_velocity = 0.0f; + obj->segment.z_velocity = 0.0f; + obj->segment.y_velocity = 8.0f; + } else { + obj->segment.x_velocity = obj->segment.x_velocity * 0.5; + obj->segment.z_velocity = obj->segment.z_velocity * 0.5; + obj->segment.y_velocity = 6.0f; + } + break; + // Crushed by something big, like a snowball. + case ATTACK_SQUISHED: + racer->squish_timer = 60; + break; + // Running into a bubble trap. + case ATTACK_BUBBLE: + racer->bubbleTrapTimer = 120; + obj->segment.x_velocity *= 0.7; + if (obj->segment.y_velocity > 2.0f) { + obj->segment.y_velocity = 2.0f; + } + obj->segment.z_velocity *= 0.7; + break; + // This goes unused. + case ATTACK_FLUNG: + racer->unk1F1 = 1; + racer->velocity = 0.0f; + obj->segment.y_velocity += 20.5; + racer_play_sound(obj, SOUND_WHEE); + break; } racer->attackType = ATTACK_NONE; } @@ -1536,19 +1513,19 @@ void update_camera_hovercraft(f32 updateRate, Object *obj, Object_Racer *racer) tempZoom = gCameraObject->zoom; baseSpeed = racer->forwardVel; switch (gCameraObject->zoom) { - case 1: - phi_f14 += 35.0f; - break; - case 2: - phi_f14 -= 35.0f; - phi_f18 -= 10.0f; - break; - case 3: - phi_f14 -= 53.0f; - phi_f18 -= 5.0f; - baseSpeed *= 0.250; - brakeVar = 0.0f; - break; + case 1: + phi_f14 += 35.0f; + break; + case 2: + phi_f14 -= 35.0f; + phi_f18 -= 10.0f; + break; + case 3: + phi_f14 -= 53.0f; + phi_f18 -= 5.0f; + baseSpeed *= 0.250; + brakeVar = 0.0f; + break; } if (racer->unk1E4 == 0) { angle = (obj->segment.trans.x_rotation); @@ -1626,7 +1603,8 @@ void update_camera_hovercraft(f32 updateRate, Object *obj, Object_Racer *racer) coss_f(racer->cameraYaw + 0x4000); // Unused function call that wasn't fully optimised out. gCameraObject->trans.z_position = obj->segment.trans.z_position + zVel; gCameraObject->trans.y_rotation = racer->cameraYaw; - segmentIndex = get_level_segment_index_from_position(gCameraObject->trans.x_position, gCameraObject->trans.y_position, gCameraObject->trans.z_position); + segmentIndex = get_level_segment_index_from_position( + gCameraObject->trans.x_position, gCameraObject->trans.y_position, gCameraObject->trans.z_position); if (segmentIndex != SEGMENT_NONE) { gCameraObject->segmentIndex = segmentIndex; } @@ -1634,7 +1612,7 @@ void update_camera_hovercraft(f32 updateRate, Object *obj, Object_Racer *racer) /** * When on water, apply a rotation effect based on the movement of the waves and turning direction. -*/ + */ f32 rotate_racer_in_water(Object *obj, Object_Racer *racer, Vec3f *pos, s8 arg3, s32 updateRate, s32 arg5, f32 arg6) { Matrix mtxF; f32 velocity; @@ -1648,7 +1626,7 @@ f32 rotate_racer_in_water(Object *obj, Object_Racer *racer, Vec3f *pos, s8 arg3, if (velocity < 0.0f) { velocity = -velocity; } - velocity = 1.0 - (velocity * (1.0/6.0)); + velocity = 1.0 - (velocity * (1.0 / 6.0)); if (velocity < 0.0f) { velocity = 0.0f; } @@ -1666,15 +1644,15 @@ f32 rotate_racer_in_water(Object *obj, Object_Racer *racer, Vec3f *pos, s8 arg3, gCurrentRacerTransform.scale = 1.0f; object_transform_to_matrix_2(mtxF, &gCurrentRacerTransform); guMtxXFMF(mtxF, pos->x, pos->y, pos->z, &pos->x, &pos->y, &pos->z); - angle = -((s16) (u16)arctan2_f(pos->x, pos->y)) * velocity; + angle = -((s16) (u16) arctan2_f(pos->x, pos->y)) * velocity; angle = (u16) (angle - (arg5 << 6)) - (u16) racer->x_rotation_vel; angle = angle > 0x8000 ? angle - 0xffff : angle; angle = angle < -0x8000 ? angle + 0xffff : angle; racer->x_rotation_vel += (angle * updateRate) >> 4; - angleVel = ((s16) (u16)arctan2_f(pos->z, pos->y) * velocity); + angleVel = ((s16) (u16) arctan2_f(pos->z, pos->y) * velocity); angleVel += -gCurrentStickY * 32; angleVel += 0x3C0; - angle = (u16)angleVel - ((u16) obj->segment.trans.x_rotation); + angle = (u16) angleVel - ((u16) obj->segment.trans.x_rotation); angle = angle > 0x8000 ? angle - 0xffff : angle; angle = angle < -0x8000 ? angle + 0xffff : angle; obj->segment.trans.x_rotation += (angle * updateRate) >> 4; @@ -1686,7 +1664,7 @@ GLOBAL_ASM("asm/non_matchings/racer/func_80049794.s") /** * When turning left and right in a plane, apply the tilting animation to the character. * There's a few safeguards in place to ensure the animation frame is not out of bounds. -*/ + */ void apply_plane_tilt_anim(s32 updateRate, Object *obj, Object_Racer *racer) { s32 animDiff; s32 animAdd; @@ -1776,7 +1754,7 @@ void racer_attack_handler_plane(Object *obj, Object_Racer *racer) { } #ifdef NON_EQUIVALENT -void update_camera_plane(f32 updateRate, Object* obj, Object_Racer* racer) { +void update_camera_plane(f32 updateRate, Object *obj, Object_Racer *racer) { s32 segmentIndex; f32 baseSpeed; f32 tempVel; @@ -1870,19 +1848,19 @@ void update_camera_plane(f32 updateRate, Object* obj, Object_Racer* racer) { brakeVar = racer->brake; baseSpeed = racer->forwardVel; switch (gCameraObject->zoom) { - case 1: - baseFloat2 += 35.0f; - break; - case 2: - baseFloat1 -= 10.0f; - baseFloat2 -= 35.0f; - break; - case 3: - baseFloat2 -= 53.0f; - baseFloat1 -= 5.0f; - baseSpeed *= 0.25; - brakeVar = 0.0f; - break; + case 1: + baseFloat2 += 35.0f; + break; + case 2: + baseFloat1 -= 10.0f; + baseFloat2 -= 35.0f; + break; + case 3: + baseFloat2 -= 53.0f; + baseFloat1 -= 5.0f; + baseSpeed *= 0.25; + brakeVar = 0.0f; + break; } if (numViewports < 2) { phi_f14 = baseSpeed * 60.0f; @@ -1897,7 +1875,9 @@ void update_camera_plane(f32 updateRate, Object* obj, Object_Racer* racer) { if (65.0 < tempVel) { tempVel = 65.0f; } - if (yOffset); + if (yOffset) { + ; + } phi_f14 -= tempVel; } if (!gRaceStartTimer) { @@ -1946,7 +1926,8 @@ void update_camera_plane(f32 updateRate, Object* obj, Object_Racer* racer) { yVel = yOffset; } gCameraObject->trans.y_position -= yVel; - gCameraObject->trans.z_position = zOffset + obj->segment.trans.z_position + (-coss_f(racer->cameraYaw + 0x4000) * 3.0f * racer->lateral_velocity); + gCameraObject->trans.z_position = + zOffset + obj->segment.trans.z_position + (-coss_f(racer->cameraYaw + 0x4000) * 3.0f * racer->lateral_velocity); gCameraObject->trans.y_rotation = racer->cameraYaw; if (racer->unk1E0 || gDialogueCameraAngle) { angle = -(u16) gCameraObject->trans.z_rotation; @@ -1969,7 +1950,8 @@ void update_camera_plane(f32 updateRate, Object* obj, Object_Racer* racer) { gCameraObject->trans.z_rotation += angle >> 3; } tempVel = gCameraObject->trans.x_position; - segmentIndex = get_level_segment_index_from_position(tempVel, gCameraObject->trans.y_position, gCameraObject->trans.z_position); + segmentIndex = get_level_segment_index_from_position(tempVel, gCameraObject->trans.y_position, + gCameraObject->trans.z_position); if (segmentIndex != -1) { gCameraObject->segmentIndex = segmentIndex; } @@ -1979,7 +1961,6 @@ void update_camera_plane(f32 updateRate, Object* obj, Object_Racer* racer) { GLOBAL_ASM("asm/non_matchings/racer/update_camera_plane.s") #endif - GLOBAL_ASM("asm/non_matchings/racer/func_8004CC20.s") /** @@ -1999,7 +1980,7 @@ void update_camera_loop(f32 updateRateF, Object *obj, Object_Racer *racer) { Matrix mtx; s32 angleDiff; - UpdateRate = (s32) updateRateF; + UpdateRate = (s32) updateRateF; zoom = 120.0f; if (gRaceStartTimer > 60) { zoom += ((f32) (gRaceStartTimer - 60) * 4.0f); @@ -2041,7 +2022,8 @@ void update_camera_loop(f32 updateRateF, Object *obj, Object_Racer *racer) { WRAP(angle, -0x8000, 0x8000); gCameraObject->trans.x_rotation += ((angle * UpdateRate) >> 4); gCameraObject->trans.y_rotation = racer->cameraYaw; - segmentIndex = get_level_segment_index_from_position(gCameraObject->trans.x_position, gCameraObject->trans.y_position, gCameraObject->trans.z_position); + segmentIndex = get_level_segment_index_from_position( + gCameraObject->trans.x_position, gCameraObject->trans.y_position, gCameraObject->trans.z_position); if (segmentIndex != SEGMENT_NONE) { gCameraObject->segmentIndex = segmentIndex; } @@ -2053,7 +2035,7 @@ void update_camera_loop(f32 updateRateF, Object *obj, Object_Racer *racer) { /** * Updates the carpet vehicle that Taj uses during the overworld race challenges. -*/ + */ void update_carpet(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer) { s16 sp26; @@ -2180,11 +2162,12 @@ void obj_init_racer(Object *obj, LevelObjectEntry_Racer *racer) { tempRacer->unk1C6 = 100; D_8011D580 = 0; + // clang-format off // This needs to be on one line to match. - for (i = 0; i < 4; i++) { \ - D_8011D58C[i] = 0; - } - if (1) {} if (1) {} // Fakematch + for (i = 0; i < 4; i++) { D_8011D58C[i] = 0; } + // clang-format on + if (1) {} + if (1) {} // Fakematch increment_ai_behaviour_chances(NULL, NULL, 0); gRacerDialogueCamera = i; gStartBoostTime = 0; @@ -2284,7 +2267,8 @@ void update_player_racer(Object *obj, s32 updateRate) { // Print player 1's coordinates to the screen if the debug cheat is enabled. if (gRaceStartTimer == 0 && tempRacer->playerIndex == PLAYER_ONE) { if (get_filtered_cheats() & CHEAT_PRINT_COORDS) { - render_printf(gRacerDebugCoords, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + render_printf(gRacerDebugCoords, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position); } } set_render_printf_background_colour(0, 0, 0, 128); @@ -2331,9 +2315,9 @@ void update_player_racer(Object *obj, s32 updateRate) { tempRacer->unk84 -= tempRacer->unk84 * 0.0625 * updateRateF; tempRacer->unk88 -= tempRacer->unk88 * 0.0625 * updateRateF; } - gCurrentRacerMiscAssetPtr = (f32*) get_misc_asset(obj->segment.header->unk5C); + gCurrentRacerMiscAssetPtr = (f32 *) get_misc_asset(obj->segment.header->unk5C); D_8011D568 = (f32 *) get_misc_asset(obj->segment.header->unk5D); - + if (obj->segment.y_velocity < 4.0 && (tempRacer->groundedWheels > 2 || tempRacer->buoyancy != 0.0)) { tempRacer->unk1F1 = 0; } @@ -2364,7 +2348,7 @@ void update_player_racer(Object *obj, s32 updateRate) { if (func_8000E158()) { tempVar = 1 - tempVar; } - //Cap the joystick tilt and write the button inputs to the current buffer. + // Cap the joystick tilt and write the button inputs to the current buffer. gCurrentStickX = clamp_joystick_x_axis(tempVar); // Flip the steering for adventure 2. if (get_filtered_cheats() & CHEAT_MIRRORED_TRACKS) { @@ -2380,11 +2364,12 @@ void update_player_racer(Object *obj, s32 updateRate) { } else { racer_AI_pathing_inputs(obj, tempRacer, updateRate); } - //Set the value that decides whether to get an empowered boost. + // Set the value that decides whether to get an empowered boost. if (!(gCurrentRacerInput & A_BUTTON)) { tempRacer->throttleReleased = TRUE; } - if (check_if_showing_cutscene_camera() || gRaceStartTimer == 100 || tempRacer->unk1F1 || gRacerInputBlocked || tempRacer->approachTarget || tempRacer->bubbleTrapTimer > 0) { + if (check_if_showing_cutscene_camera() || gRaceStartTimer == 100 || tempRacer->unk1F1 || gRacerInputBlocked || + tempRacer->approachTarget || tempRacer->bubbleTrapTimer > 0) { gCurrentStickX = 0; gCurrentStickY = 0; gCurrentRacerInput = 0; @@ -2394,7 +2379,7 @@ void update_player_racer(Object *obj, s32 updateRate) { } if (tempRacer->bubbleTrapTimer > 0) { tempRacer->bubbleTrapTimer -= updateRate; - tempRacer->velocity *= 0.9f; //!@Delta + tempRacer->velocity *= 0.9f; //!@Delta obj->segment.x_velocity *= 0.87f; //!@Delta if (obj->segment.y_velocity > 2.0f) { obj->segment.y_velocity = 2.0f; @@ -2420,7 +2405,7 @@ void update_player_racer(Object *obj, s32 updateRate) { } // Zero out input before the race has begun. if (gRaceStartTimer && (header->race_type == RACETYPE_DEFAULT || - header->race_type == RACETYPE_HORSESHOE_GULCH || header->race_type == RACETYPE_BOSS)) { + header->race_type == RACETYPE_HORSESHOE_GULCH || header->race_type == RACETYPE_BOSS)) { gCurrentStickX = 0; gCurrentStickY = 0; gCurrentRacerInput = 0; @@ -2438,7 +2423,8 @@ void update_player_racer(Object *obj, s32 updateRate) { if (gCurrentPlayerIndex != PLAYER_COMPUTER) { gCameraObject = (ObjectCamera *) get_active_camera_segment_no_cutscenes(); } - gRacerWaveCount = func_8002B0F4(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position, &gRacerCurrentWave); + gRacerWaveCount = func_8002B0F4(obj->segment.object.segmentID, obj->segment.trans.x_position, + obj->segment.trans.z_position, &gRacerCurrentWave); if (gRacerWaveCount) { for (i = 0; i < gRacerWaveCount; i++) { if (gRacerCurrentWave[i]->type == WATER_UNK_F) { @@ -2473,19 +2459,47 @@ void update_player_racer(Object *obj, s32 updateRate) { } func_8002ACC8(0); switch (tempRacer->vehicleID) { - case VEHICLE_CAR: func_8004F7F4(updateRate, updateRateF, obj, tempRacer); break; - case VEHICLE_LOOPDELOOP: func_8004CC20(updateRate, updateRateF, obj, tempRacer); break; - case VEHICLE_HOVERCRAFT: func_80046524(updateRate, updateRateF, obj, tempRacer); break; - case VEHICLE_PLANE: func_80049794(updateRate, updateRateF, obj, tempRacer); break; - case VEHICLE_FLYING_CAR: /* fall through */ - case VEHICLE_CARPET: update_carpet(updateRate, updateRateF, obj, tempRacer); break; - case VEHICLE_TRICKY: update_tricky(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentButtonsPressed, &gRaceStartTimer); break; - case VEHICLE_BLUEY: update_bluey(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentButtonsPressed, &gRaceStartTimer); break; - case VEHICLE_SMOKEY: /* fall through */ - case VEHICLE_PTERODACTYL: update_smokey(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentStickX, &gRaceStartTimer); break; - case VEHICLE_BUBBLER: update_bubbler(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentButtonsPressed, &gRaceStartTimer); break; - case VEHICLE_WIZPIG: update_wizpig(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentButtonsPressed, &gRaceStartTimer); break; - case VEHICLE_ROCKET: update_rocket(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentButtonsPressed, &gRaceStartTimer); break; + case VEHICLE_CAR: + func_8004F7F4(updateRate, updateRateF, obj, tempRacer); + break; + case VEHICLE_LOOPDELOOP: + func_8004CC20(updateRate, updateRateF, obj, tempRacer); + break; + case VEHICLE_HOVERCRAFT: + func_80046524(updateRate, updateRateF, obj, tempRacer); + break; + case VEHICLE_PLANE: + func_80049794(updateRate, updateRateF, obj, tempRacer); + break; + case VEHICLE_FLYING_CAR: /* fall through */ + case VEHICLE_CARPET: + update_carpet(updateRate, updateRateF, obj, tempRacer); + break; + case VEHICLE_TRICKY: + update_tricky(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentButtonsPressed, + &gRaceStartTimer); + break; + case VEHICLE_BLUEY: + update_bluey(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentButtonsPressed, + &gRaceStartTimer); + break; + case VEHICLE_SMOKEY: /* fall through */ + case VEHICLE_PTERODACTYL: + update_smokey(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentStickX, + &gRaceStartTimer); + break; + case VEHICLE_BUBBLER: + update_bubbler(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentButtonsPressed, + &gRaceStartTimer); + break; + case VEHICLE_WIZPIG: + update_wizpig(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentButtonsPressed, + &gRaceStartTimer); + break; + case VEHICLE_ROCKET: + update_rocket(updateRate, updateRateF, obj, tempRacer, &gCurrentRacerInput, &gCurrentButtonsPressed, + &gRaceStartTimer); + break; } if (tempRacer->magnetTimer == 0) { if (tempRacer->magnetSoundMask) { @@ -2502,12 +2516,14 @@ void update_player_racer(Object *obj, s32 updateRate) { racer_sound_update(obj, gCurrentButtonsPressed, gCurrentRacerInput, updateRate); } lastCheckpointDist = tempRacer->checkpoint_distance; - tempVar = func_800185E4(tempRacer->checkpoint, obj, xTemp, yTemp, zTemp, &tempRacer->checkpoint_distance, &tempRacer->unk1C8); + tempVar = func_800185E4(tempRacer->checkpoint, obj, xTemp, yTemp, zTemp, &tempRacer->checkpoint_distance, + &tempRacer->unk1C8); if (tempVar == -100) { func_8005C270(tempRacer); } checkpointNode = find_next_checkpoint_node(tempRacer->checkpoint, tempRacer->unk1C8); - if (tempRacer->playerIndex == PLAYER_COMPUTER && checkpointNode->unk36[tempRacer->unk1CA] == 5 && tempRacer->waterTimer) { + if (tempRacer->playerIndex == PLAYER_COMPUTER && checkpointNode->unk36[tempRacer->unk1CA] == 5 && + tempRacer->waterTimer) { tempRacer->unk1C8 = 1; } if (checkpointNode->unk36[tempRacer->unk1CA] == 6) { @@ -2526,8 +2542,8 @@ void update_player_racer(Object *obj, s32 updateRate) { tempRacer->lap++; } } - if (tempRacer->playerIndex != PLAYER_COMPUTER && tempRacer->lap + 1 == header->laps - && !D_8011D580 && get_current_level_race_type() == RACETYPE_DEFAULT) { + if (tempRacer->playerIndex != PLAYER_COMPUTER && tempRacer->lap + 1 == header->laps && !D_8011D580 && + get_current_level_race_type() == RACETYPE_DEFAULT) { music_tempo_set_relative(1.12f); D_8011D580 = 1; } @@ -2601,7 +2617,8 @@ void update_player_racer(Object *obj, s32 updateRate) { } else { stretch = -0.02f; } - tempRacer->stretch_height += (((tempRacer->stretch_height_cap - tempRacer->stretch_height) * 0.125) + stretch) * updateRateF; + tempRacer->stretch_height += + (((tempRacer->stretch_height_cap - tempRacer->stretch_height) * 0.125) + stretch) * updateRateF; if ((stretch < 0.0f && tempRacer->stretch_height <= tempRacer->stretch_height_cap) || (stretch > 0.0f && tempRacer->stretch_height >= tempRacer->stretch_height_cap)) { tempRacer->stretch_height = tempRacer->stretch_height_cap; @@ -2629,9 +2646,11 @@ void update_player_racer(Object *obj, s32 updateRate) { if (tempRacer->shieldTimer > 0) { if (tempRacer->shieldTimer > 60) { if (tempRacer->shieldSoundMask) { - update_spatial_audio_position(tempRacer->shieldSoundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + update_spatial_audio_position(tempRacer->shieldSoundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } else if (tempRacer->vehicleSound) { - play_sound_at_position(SOUND_SHIELD, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 1, &tempRacer->shieldSoundMask); + play_sound_at_position(SOUND_SHIELD, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 1, &tempRacer->shieldSoundMask); } } else if (tempRacer->shieldSoundMask) { func_800096F8(tempRacer->shieldSoundMask); @@ -2643,21 +2662,24 @@ void update_player_racer(Object *obj, s32 updateRate) { } } if (tempRacer->bananaSoundMask) { - update_spatial_audio_position(tempRacer->bananaSoundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + update_spatial_audio_position(tempRacer->bananaSoundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } if (is_in_time_trial() && tempRacer->playerIndex == PLAYER_ONE && gRaceStartTimer == 0) { func_80059BF0(obj, updateRate); } if (tempRacer->soundMask) { - update_spatial_audio_position(tempRacer->soundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + update_spatial_audio_position(tempRacer->soundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } gRacerInputBlocked = 0; if (tempRacer->unk150 && gRaceStartTimer == 0) { s8 *yAsset; tempRacer->unk150->segment.trans.x_position = obj->segment.trans.x_position; yAsset = (s8 *) get_misc_asset(ASSET_MISC_0); - - tempRacer->unk150->segment.trans.y_position = obj->segment.trans.y_position + yAsset[tempRacer->characterId]; + + tempRacer->unk150->segment.trans.y_position = + obj->segment.trans.y_position + yAsset[tempRacer->characterId]; tempRacer->unk150->segment.trans.z_position = obj->segment.trans.z_position; tempRacer->unk150->segment.trans.scale = obj->segment.object.distanceToCamera / 265.0f; if (obj->segment.object.distanceToCamera < 1500.0 || get_filtered_cheats() & CHEAT_MIRRORED_TRACKS) { @@ -2677,9 +2699,11 @@ void update_player_racer(Object *obj, s32 updateRate) { } else { tempRacer->delaySoundTimer = 0; if (tempRacer->playerIndex == PLAYER_COMPUTER) { - play_sound_at_position(tempRacer->delaySoundID, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + play_sound_at_position(tempRacer->delaySoundID, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); } else { - sound_play_spatial(tempRacer->delaySoundID, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, NULL); + sound_play_spatial(tempRacer->delaySoundID, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, NULL); } tempRacer->delaySoundID = SOUND_NONE; } @@ -2699,7 +2723,7 @@ void update_player_racer(Object *obj, s32 updateRate) { * When braking or driving in a place considered dark, a timer counts up and then sets flags. * These flags correspond to the lights on the back of the car being enabled and what colour they are. * When you exit this dark place, the timer counts back down and the lights stop. -*/ + */ void set_racer_tail_lights(Object_Racer *racer) { s32 lightTimer; @@ -2729,7 +2753,7 @@ GLOBAL_ASM("asm/non_matchings/racer/func_8004F7F4.s") /** * At this point, control is taken away from the player. * Instead, they'll automatically move towards a specific object. -*/ + */ void racer_approach_object(Object *obj, Object_Racer *racer, f32 divisor) { f32 diffX; f32 diffY; @@ -2771,7 +2795,7 @@ void apply_vehicle_rotation_offset(Object_Racer *obj, s32 max, s16 yRotation, s1 if (diff < tempAngle) { tempAngle = diff; } - obj->y_rotation_offset += tempAngle; + obj->y_rotation_offset += tempAngle; } else if (tempAngle < 0) { diff = -(max * 0x600); if (tempAngle < diff) { @@ -2860,7 +2884,7 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR temp_v0->x_position = (f32) (-racer->carBobX * scale); temp_v0->y_position = (f32) (-racer->carBobY * scale); temp_v0->z_position = (f32) (-racer->carBobZ * scale); - } + } } } else { racer->carBobX = 0.0f; @@ -2908,7 +2932,8 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR gCurrentStickX += racer->unk1D1; } // If moving fast enough, enable drifting if the R button is held - if (racer->drifting == 0 && racer->velocity > 2.0 && gCurrentRacerInput & R_TRIG && (gCurrentStickX > 50 || gCurrentStickX < -50)) { + if (racer->drifting == 0 && racer->velocity > 2.0 && gCurrentRacerInput & R_TRIG && + (gCurrentStickX > 50 || gCurrentStickX < -50)) { if (gCurrentStickX > 0) { racer->drifting = 1; } else { @@ -2956,7 +2981,8 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR } } // Decide which way to drift when the R button is held - if (racer->drift_direction == 0 && gCurrentRacerInput & R_TRIG && racer->velocity < -3.0 && (gCurrentStickX > 15 || gCurrentStickX < -15)) { + if (racer->drift_direction == 0 && gCurrentRacerInput & R_TRIG && racer->velocity < -3.0 && + (gCurrentStickX > 15 || gCurrentStickX < -15)) { if (gCurrentStickX < 0) { racer->drift_direction = -1; } @@ -2987,8 +3013,8 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR racer->unk10C -= i; // racer->unk10C -= ((racer->unk10C - (racer->drift_direction << 13)) * updateRate) >> 4; // sounds for drifting and sliding - if (!(racer->y_rotation_vel <= 0x1800 && racer->y_rotation_vel >= -0x1800 && - racer->drift_direction == 0 && racer->drifting == 0 && racer->unk1FB == 0)) { + if (!(racer->y_rotation_vel <= 0x1800 && racer->y_rotation_vel >= -0x1800 && racer->drift_direction == 0 && + racer->drifting == 0 && racer->unk1FB == 0)) { sp60 = 1; if (racer->unk1FB != 0 && racer->raceFinished == FALSE) { func_80072348(racer->playerIndex, 0); @@ -3000,9 +3026,11 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR } if (racer->drift_direction != 0 || racer->drifting != 0 || racer->unk1FB != 0) { if (racer->unk10 == 0) { - sound_play_spatial(SOUND_CAR_SLIDE, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, (s32 **) &racer->unk10); + sound_play_spatial(SOUND_CAR_SLIDE, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, (s32 **) &racer->unk10); } else { - func_80009B7C((void *) racer->unk10, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + func_80009B7C((void *) racer->unk10, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position); } if (racer->unk14) { func_8000488C(racer->unk14); @@ -3039,7 +3067,7 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR if (racer->velocity > 0.3) { SteeringVel = -steerAngle * velocityS; } - // Set final turn velocity by taking the steering velocity and multiplying it by the handling stat of the character. + // Set final turn velocity by taking the steering velocity and multiplying it by the handling stat of the character. racer->steerVisualRotation -= (s32) (((SteeringVel * updateRate) >> 1) * gCurrentRacerHandlingStat); // Now steer the car. handle_car_steering(racer); @@ -3064,7 +3092,7 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR } surfaceTraction = 0.0f; velocityDiff = 0.0f; - sp68 = 0; // Number of wheels contacting grass or sand + sp68 = 0; // Number of wheels contacting grass or sand stoneWheels = 0; // Number of wheels contacting the stone surface type // Iterate through each wheel and find which surface they're on. for (i = 0; i < 4; i++) { @@ -3092,7 +3120,8 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR surfaceTraction /= velocityDiff; } // If on the Taj pad and the horn is honked, summon Taj - if (racer->playerIndex == PLAYER_ONE && racer->groundedWheels && surfaceType == SURFACE_TAJ_PAD && gCurrentButtonsPressed & Z_TRIG) { + if (racer->playerIndex == PLAYER_ONE && racer->groundedWheels && surfaceType == SURFACE_TAJ_PAD && + gCurrentButtonsPressed & Z_TRIG) { gTajInteractStatus = 2; } // Set grip levels to basically zero when floating on water. @@ -3100,7 +3129,7 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR traction = 0.02f; surfaceTraction = 0.0f; } - // no clue :) + // no clue :) if (surfaceType == SURFACE_SAND && racer->velocity < -2.0 && racer->raceFinished == FALSE) { func_80072348(racer->playerIndex, 0); } @@ -3225,7 +3254,8 @@ void func_80050A28(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR } else { racer->boostTimer = 0; } - if (racer->velocity > -2.0 && racer->velocity < 3.0 && (racer->playerIndex != PLAYER_COMPUTER || racer->unk214 != 0)) { + if (racer->velocity > -2.0 && racer->velocity < 3.0 && + (racer->playerIndex != PLAYER_COMPUTER || racer->unk214 != 0)) { tempVel = (3.0 - racer->velocity) * 0.15; if (soundID == 4) { tempVel *= 0.25; @@ -3294,7 +3324,7 @@ GLOBAL_ASM("asm/non_matchings/racer/func_80050A28.s") /** * Checks if Taj's interaction status is set to try make him teleport and return true. -*/ + */ s32 should_taj_teleport(void) { if (gTajInteractStatus == TAJ_TELEPORT) { gTajInteractStatus = TAJ_DIALOGUE; @@ -3305,7 +3335,7 @@ s32 should_taj_teleport(void) { /** * Sets Taj's interaction status. -*/ + */ void set_taj_status(s32 status) { gTajInteractStatus = status; } @@ -3313,7 +3343,7 @@ void set_taj_status(s32 status) { /** * Find a nearby racer and set the head to turn to face them. * Otherwise, if stationary, set a random angle to turn to periodically. -*/ + */ void handle_racer_head_turning(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) { Object *tempObj; s8 foundObj; @@ -3359,7 +3389,7 @@ void handle_racer_head_turning(Object *obj, Object_Racer *racer, UNUSED s32 upda /** * Over time, set the head angle target to zero. * The character's head will start to face forward. -*/ + */ void slowly_reset_head_angle(Object_Racer *racer) { racer->headAngleTarget -= racer->headAngleTarget >> 3; if (racer->headAngleTarget > -10 && racer->headAngleTarget < 10) { @@ -3370,7 +3400,7 @@ void slowly_reset_head_angle(Object_Racer *racer) { /** * Compute angle between objects, then set the intended angle for the character's head to face * an object. -*/ + */ s32 turn_head_towards_object(Object *obj, Object_Racer *racer, Object *targetObj, f32 distance) { s32 intendedAngle; f32 diffX; @@ -3402,7 +3432,7 @@ s32 turn_head_towards_object(Object *obj, Object_Racer *racer, Object *targetObj return ret; } -void func_8005250C(Object* obj, Object_Racer* racer, s32 updateRate) { +void func_8005250C(Object *obj, Object_Racer *racer, s32 updateRate) { s8 *balloonAsset; s32 angleVel; s32 newAngle; @@ -3411,7 +3441,7 @@ void func_8005250C(Object* obj, Object_Racer* racer, s32 updateRate) { angleVel = 0; if (racer->balloon_quantity > 0) { balloonAsset = (s8 *) get_misc_asset(ASSET_MISC_12); - + angleVel = balloonAsset[(racer->balloon_type * 10) + (racer->balloon_level * 2)]; } if (gCurrentButtonsPressed & Z_TRIG && angleVel != 4 && angleVel != 8) { @@ -3439,77 +3469,78 @@ void func_8005250C(Object* obj, Object_Racer* racer, s32 updateRate) { racer->unk1F3 = 0; } switch (racer->unk1F2) { - case 0: // Sliding, creating tyre marks - angleVel = (s32) ((-racer->y_rotation_vel >> 8) / gCurrentRacerHandlingStat); - angleVel = 40 - angleVel; - if (angleVel < 0) { + case 0: // Sliding, creating tyre marks + angleVel = (s32) ((-racer->y_rotation_vel >> 8) / gCurrentRacerHandlingStat); + angleVel = 40 - angleVel; + if (angleVel < 0) { + angleVel = 0; + } + if (angleVel > 73) { + angleVel = 73; + } + newAngle = angleVel - obj->segment.animFrame; angleVel = 0; - } - if (angleVel > 73) { - angleVel = 73; - } - newAngle = angleVel - obj->segment.animFrame; - angleVel = 0; - if (newAngle > 0) { - angleVel = updateRate * 3; - if (newAngle < angleVel) { - angleVel = newAngle; + if (newAngle > 0) { + angleVel = updateRate * 3; + if (newAngle < angleVel) { + angleVel = newAngle; + } } - } - if (newAngle < 0) { - angleVel = updateRate * -3; - if (angleVel < newAngle) { - angleVel = newAngle; + if (newAngle < 0) { + angleVel = updateRate * -3; + if (angleVel < newAngle) { + angleVel = newAngle; + } } - } - obj->segment.animFrame += angleVel; - obj->segment.object.animationID = 0; - if (angleVel) {} // Fakematch - if (racer->unk1F3 & 4) { - racer->unk1F2 = 3; + obj->segment.animFrame += angleVel; + obj->segment.object.animationID = 0; + if (angleVel) {} // Fakematch + if (racer->unk1F3 & 4) { + racer->unk1F2 = 3; + racer->unk1F3 &= 0xFFFB; + } + if (racer->velocity > 0.0 && gCurrentRacerInput & B_BUTTON) { + racer->unk1F2 = 6; + } + break; + case 3: // Boost + actionStatus = 2; + if (racer->unk1F3 & 4) { + actionStatus = 4 | 2; + } + func_80052988(obj, racer, 2, 0, 32, 4, actionStatus, updateRate); racer->unk1F3 &= 0xFFFB; - } - if (racer->velocity > 0.0 && gCurrentRacerInput & B_BUTTON) { - racer->unk1F2 = 6; - } - break; - case 3: // Boost - actionStatus = 2; - if (racer->unk1F3 & 4) { - actionStatus = 4 | 2; - } - func_80052988(obj, racer, 2, 0, 32, 4, actionStatus, updateRate); - racer->unk1F3 &= 0xFFFB; - break; - case 4: // Crash - func_80052988(obj, racer, 3, 0, 32, 2, 0, updateRate); - racer->unk1F3 &= 0xFFF7; - break; - case 5: // Horn - actionStatus = 2; - if (gCurrentRacerInput & Z_TRIG) { - actionStatus = 4 | 2; - } - func_80052988(obj, racer, 4, 0, 48, 4, actionStatus, updateRate); - break; - case 6: - actionStatus = 3; - if (racer->velocity > 0.0 && gCurrentRacerInput & B_BUTTON) { - actionStatus = 4 | 2 | 1; // Reverse - } - func_80052988(obj, racer, 1, 0, 80, 3, actionStatus, updateRate); - break; - case 7: - func_80052988(obj, racer, 5, 0, 96, 4, 0, updateRate); - if (racer->unk1F2 == 0) { + break; + case 4: // Crash + func_80052988(obj, racer, 3, 0, 32, 2, 0, updateRate); + racer->unk1F3 &= 0xFFF7; + break; + case 5: // Horn + actionStatus = 2; + if (gCurrentRacerInput & Z_TRIG) { + actionStatus = 4 | 2; + } + func_80052988(obj, racer, 4, 0, 48, 4, actionStatus, updateRate); + break; + case 6: + actionStatus = 3; + if (racer->velocity > 0.0 && gCurrentRacerInput & B_BUTTON) { + actionStatus = 4 | 2 | 1; // Reverse + } + func_80052988(obj, racer, 1, 0, 80, 3, actionStatus, updateRate); + break; + case 7: func_80052988(obj, racer, 5, 0, 96, 4, 0, updateRate); - } - break; + if (racer->unk1F2 == 0) { + func_80052988(obj, racer, 5, 0, 96, 4, 0, updateRate); + } + break; } } // Anims related to the car I think -void func_80052988(Object *obj, Object_Racer *racer, s32 action, s32 arg3, s32 duration, s32 arg5, s32 flags, s32 arg7) { +void func_80052988(Object *obj, Object_Racer *racer, s32 action, s32 arg3, s32 duration, s32 arg5, s32 flags, + s32 arg7) { arg5 *= arg7; if (gCurrentPlayerIndex == PLAYER_COMPUTER && action >= 3) { @@ -3671,8 +3702,8 @@ void update_car_velocity_offground(Object *obj, Object_Racer *racer, s32 updateR } canSteer = TRUE; racer->lateral_velocity *= 0.87; //!@Delta - racer->velocity *= 0.87; //!@Delta - obj->segment.y_velocity *= 0.9; //!@Delta + racer->velocity *= 0.87; //!@Delta + obj->segment.y_velocity *= 0.9; //!@Delta rotate_racer_in_water(obj, racer, &gCurrentRacerWaterPos, gRacerWaveType, updateRate, gCurrentStickX, 6.0f); } if (racer->playerIndex == PLAYER_COMPUTER) { @@ -3708,7 +3739,7 @@ void update_car_velocity_offground(Object *obj, Object_Racer *racer, s32 updateR } if (racer->unk1FE == 1 || racer->unk1FE == 3) { racer->lateral_velocity *= 0.97; //!@Delta - racer->velocity *= 0.97; //!@Delta + racer->velocity *= 0.97; //!@Delta if (yStick > 50) { racer->velocity -= 0.2; //!@Delta } @@ -3865,39 +3896,39 @@ void racer_attack_handler_car(Object *obj, Object_Racer *racer, s32 updateRate) if (racer->vehicleID < VEHICLE_TRICKY) { play_random_character_voice(obj, SOUND_VOICE_CHARACTER_NEGATIVE, 8, 129); switch (racer->attackType) { - // Getting hit by a rocket, or running into a landmine. - case ATTACK_EXPLOSION: - racer->unk1F1 = 1; - if (bananas == 0) { + // Getting hit by a rocket, or running into a landmine. + case ATTACK_EXPLOSION: + racer->unk1F1 = 1; + if (bananas == 0) { + racer->velocity = 0.0f; + obj->segment.y_velocity += 10.5; + } else { + racer->velocity /= 4; + obj->segment.y_velocity += 8.5; + } + break; + // Running into an oil slick. + case ATTACK_SPIN: + racer->spinout_timer = 2; + racer->y_rotation_vel = 0x1002; + racer_play_sound(obj, SOUND_TYRE_SCREECH); + break; + // Crushed by something big, like a snowball. + case ATTACK_SQUISHED: + racer->squish_timer = 60; + break; + // Running into a bubble trap. + case ATTACK_BUBBLE: + racer->bubbleTrapTimer = 120; + racer->velocity *= 0.5; + break; + // This goes unused. + case ATTACK_FLUNG: + racer->unk1F1 = 1; racer->velocity = 0.0f; - obj->segment.y_velocity += 10.5; - } else { - racer->velocity /= 4; - obj->segment.y_velocity += 8.5; - } - break; - // Running into an oil slick. - case ATTACK_SPIN: - racer->spinout_timer = 2; - racer->y_rotation_vel = 0x1002; - racer_play_sound(obj, SOUND_TYRE_SCREECH); - break; - // Crushed by something big, like a snowball. - case ATTACK_SQUISHED: - racer->squish_timer = 60; - break; - // Running into a bubble trap. - case ATTACK_BUBBLE: - racer->bubbleTrapTimer = 120; - racer->velocity *= 0.5; - break; - // This goes unused. - case ATTACK_FLUNG: - racer->unk1F1 = 1; - racer->velocity = 0.0f; - obj->segment.y_velocity += 20.5; - racer_play_sound(obj, SOUND_WHEE); - break; + obj->segment.y_velocity += 20.5; + racer_play_sound(obj, SOUND_WHEE); + break; } racer->attackType = ATTACK_NONE; } @@ -3909,7 +3940,7 @@ void racer_attack_handler_car(Object *obj, Object_Racer *racer, s32 updateRate) * Only ran when onscreen or nearby, this function handles more authentic, but computationally expensive looking * behaviour for AI controlled racers. * This function also calls pathing, using splines, to know where to go. -*/ + */ void update_onscreen_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateRateF) { f32 tempVel; f32 xVel; @@ -3995,7 +4026,8 @@ void update_onscreen_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, gCurrentRacerTransform.z_position = 0.0f; gCurrentRacerTransform.scale = 1.0f; object_transform_to_matrix_2(mtx, &gCurrentRacerTransform); - guMtxXFMF(mtx, racer->lateral_velocity, 0.0f, racer->velocity, &obj->segment.x_velocity, &tempVel, &obj->segment.z_velocity); + guMtxXFMF(mtx, racer->lateral_velocity, 0.0f, racer->velocity, &obj->segment.x_velocity, &tempVel, + &obj->segment.z_velocity); } if (racer->magnetTimer) { obj->segment.x_velocity = gRacerMagnetVelX; @@ -4015,7 +4047,7 @@ void update_onscreen_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, racer_approach_object(obj, racer, updateRateF); } if (gCurrentPlayerIndex == PLAYER_COMPUTER && !func_80023568()) { - onscreen_ai_racer_physics(obj, racer, updateRate); + onscreen_ai_racer_physics(obj, racer, updateRate); } else { func_80054FD0(obj, racer, updateRate); } @@ -4113,7 +4145,7 @@ void update_car_velocity_ground(Object *obj, Object_Racer *racer, s32 updateRate xStick = -rawStick * stickMultiplier; } xStick *= updateRate; - temp = (s32) ((xStick >> 1) * gCurrentRacerHandlingStat); + temp = (s32) ((xStick >> 1) * gCurrentRacerHandlingStat); temp2 = temp; racer->steerVisualRotation -= temp2; //!@Delta handle_car_steering(racer); @@ -4165,7 +4197,8 @@ void update_car_velocity_ground(Object *obj, Object_Racer *racer, s32 updateRate } velocityS = (s32) vel; temp_f0_2 = vel - (f32) velocityS; - vel = (gCurrentRacerMiscAssetPtr[velocityS+1] * temp_f0_2) + (gCurrentRacerMiscAssetPtr[velocityS] * (1.0 - temp_f0_2)); + vel = (gCurrentRacerMiscAssetPtr[velocityS + 1] * temp_f0_2) + + (gCurrentRacerMiscAssetPtr[velocityS] * (1.0 - temp_f0_2)); vel *= 1.7; vel *= multiplier; if (racer->boostTimer > 0) { @@ -4187,7 +4220,7 @@ void update_car_velocity_ground(Object *obj, Object_Racer *racer, s32 updateRate racer->velocity += reverseVel; //!@Delta } } - forwardVel = (vel * racer->brake) * 0.32; //!@Delta + forwardVel = (vel * racer->brake) * 0.32; //!@Delta racer->velocity -= vel * racer->throttle; //!@Delta if (racer->velocity > -0.04 && racer->velocity < 0.04) { racer->velocity = 0.0f; @@ -4215,13 +4248,12 @@ void update_car_velocity_ground(Object *obj, Object_Racer *racer, s32 updateRate obj->segment.y_velocity -= weight * updateRateF; } - GLOBAL_ASM("asm/non_matchings/racer/func_80054FD0.s") /** * Update the collision of the racer. * Also update wheel contacts and hitbox size. -*/ + */ void onscreen_ai_racer_physics(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) { f32 angleZ; f32 distance; @@ -4308,13 +4340,15 @@ void onscreen_ai_racer_physics(Object *obj, Object_Racer *racer, UNUSED s32 upda obj->segment.trans.x_rotation = xRot; } if (racer->vehicleID == VEHICLE_LOOPDELOOP) { - if (1) // Fakematch - xRot -= (u16) obj->segment.trans.x_rotation; + if (1) { // Fakematch + xRot -= (u16) obj->segment.trans.x_rotation; + } WRAP(xRot, -0x8000, 0x8000); obj->segment.trans.x_rotation += xRot >> 2; } } - if (racer->vehicleID != VEHICLE_LOOPDELOOP && racer->vehicleID != VEHICLE_PLANE && racer->vehicleID != VEHICLE_CARPET && racer->vehicleID != VEHICLE_SMOKEY) { + if (racer->vehicleID != VEHICLE_LOOPDELOOP && racer->vehicleID != VEHICLE_PLANE && + racer->vehicleID != VEHICLE_CARPET && racer->vehicleID != VEHICLE_SMOKEY) { CLAMP(racer->x_rotation_vel, -0x3400, 0x3400); CLAMP(obj->segment.trans.x_rotation, -0x3400, 0x3400); } @@ -4362,9 +4396,12 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) } } } - heldObj->segment.trans.x_position = obj->segment.trans.x_position + (racer->ox1 * scaleZ) + (racer->ox2 * scaleY); - heldObj->segment.trans.y_position = obj->segment.trans.y_position + (racer->oy1 * scaleZ) + (racer->oy2 * scaleY); - heldObj->segment.trans.z_position = obj->segment.trans.z_position + (racer->oz1 * scaleZ) + (racer->oz2 * scaleY); + heldObj->segment.trans.x_position = + obj->segment.trans.x_position + (racer->ox1 * scaleZ) + (racer->ox2 * scaleY); + heldObj->segment.trans.y_position = + obj->segment.trans.y_position + (racer->oy1 * scaleZ) + (racer->oy2 * scaleY); + heldObj->segment.trans.z_position = + obj->segment.trans.z_position + (racer->oz1 * scaleZ) + (racer->oz2 * scaleY); heldObj->segment.object.segmentID = obj->segment.object.segmentID; heldObj->segment.x_velocity = obj->segment.x_velocity * 0.7; heldObj->segment.y_velocity = obj->segment.y_velocity - 2.0; @@ -4413,7 +4450,7 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) if (gCurrentRacerInput & Z_TRIG || gCurrentButtonsReleased & Z_TRIG) { switch (weaponID) { case WEAPON_ROCKET_HOMING: - intendedTarget = func_8005698C(obj, racer, &objDist); \ + intendedTarget = func_8005698C(obj, racer, &objDist); racer->magnetTimer = 0; racer->magnetTargetObj = intendedTarget; break; @@ -4437,12 +4474,12 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) intendedTarget = NULL; } break; - } } - objID = 29; - if (gCurrentButtonsReleased & Z_TRIG) { - velocity = 30.0f; - switch (weaponID) { + } + objID = 29; + if (gCurrentButtonsReleased & Z_TRIG) { + velocity = 30.0f; + switch (weaponID) { case WEAPON_ROCKET_HOMING: objDist = -10.0f; objID = 229; @@ -4474,23 +4511,25 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) case WEAPON_NITRO_LEVEL_1: case WEAPON_NITRO_LEVEL_2: case WEAPON_NITRO_LEVEL_3: - switch(weaponID) { + // clang-format off + switch (weaponID) { case WEAPON_NITRO_LEVEL_3: - // IDO demands this to be on 1 line. + // IDO demands this to be on 1 line. racer->boostTimer = normalise_time(75); \ racer->boostType = BOOST_LARGE; break; case WEAPON_NITRO_LEVEL_2: - // Ditto + // Ditto racer->boostTimer = normalise_time(55); \ racer->boostType = BOOST_MEDIUM; break; default: - // :( + // :( racer->boostTimer = normalise_time(35); \ racer->boostType = BOOST_SMALL; break; } + // clang-format on if (racer->throttleReleased) { racer->boostType |= EMPOWER_BOOST; } @@ -4555,33 +4594,34 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) default: objDist = 0; break; - } - play_random_character_voice(obj, SOUND_VOICE_CHARACTER_POSITIVE, 8, 129); - newObject.x = obj->segment.trans.x_position + (racer->ox1 * objDist); - newObject.y = obj->segment.trans.y_position + (racer->oy1 * objDist) + (10.0f * racer->oy2); - newObject.z = obj->segment.trans.z_position + (racer->oz1 * objDist); - newObject.size = 8; - newObject.objectID = objID; - spawnedObj = spawn_object(&newObject, 1); - if (spawnedObj != NULL) { - spawnedObj->segment.level_entry = NULL; - spawnedObj->segment.x_velocity = obj->segment.x_velocity - (racer->ox1 * velocity); - spawnedObj->segment.y_velocity = obj->segment.y_velocity - (racer->oy1 * velocity); - spawnedObj->segment.z_velocity = obj->segment.z_velocity - (racer->oz1 * velocity); - spawnedObj->segment.trans.y_rotation = obj->segment.trans.y_rotation; - spawnedObj->segment.trans.x_rotation = obj->segment.trans.x_rotation; - if (racer->vehicleID == VEHICLE_HOVERCRAFT && racer->waterTimer) { - if (spawnedObj->segment.trans.x_rotation > -0x400 && spawnedObj->segment.trans.x_rotation < 0x400) { - spawnedObj->segment.trans.x_rotation = 0; - } + } + play_random_character_voice(obj, SOUND_VOICE_CHARACTER_POSITIVE, 8, 129); + newObject.x = obj->segment.trans.x_position + (racer->ox1 * objDist); + newObject.y = obj->segment.trans.y_position + (racer->oy1 * objDist) + (10.0f * racer->oy2); + newObject.z = obj->segment.trans.z_position + (racer->oz1 * objDist); + newObject.size = 8; + newObject.objectID = objID; + spawnedObj = spawn_object(&newObject, 1); + if (spawnedObj != NULL) { + spawnedObj->segment.level_entry = NULL; + spawnedObj->segment.x_velocity = obj->segment.x_velocity - (racer->ox1 * velocity); + spawnedObj->segment.y_velocity = obj->segment.y_velocity - (racer->oy1 * velocity); + spawnedObj->segment.z_velocity = obj->segment.z_velocity - (racer->oz1 * velocity); + spawnedObj->segment.trans.y_rotation = obj->segment.trans.y_rotation; + spawnedObj->segment.trans.x_rotation = obj->segment.trans.x_rotation; + if (racer->vehicleID == VEHICLE_HOVERCRAFT && racer->waterTimer) { + if (spawnedObj->segment.trans.x_rotation > -0x400 && + spawnedObj->segment.trans.x_rotation < 0x400) { + spawnedObj->segment.trans.x_rotation = 0; } - objData = spawnedObj->unk64; - objData->weapon.owner = obj; - objData->weapon.target = intendedTarget; - objData->weapon.checkpoint = racer->checkpoint; - objData->weapon.forwardVel = (racer->velocity - velocity); - objData->weapon.weaponID = weaponID; - switch (objData->weapon.weaponID) { + } + objData = spawnedObj->unk64; + objData->weapon.owner = obj; + objData->weapon.target = intendedTarget; + objData->weapon.checkpoint = racer->checkpoint; + objData->weapon.forwardVel = (racer->velocity - velocity); + objData->weapon.weaponID = weaponID; + switch (objData->weapon.weaponID) { case WEAPON_ROCKET_HOMING: soundID = SOUND_NYOOM2; break; @@ -4591,7 +4631,7 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) case WEAPON_TRIPMINE: soundID = SOUND_PLOP; break; - case WEAPON_OIL_SLICK: + case WEAPON_OIL_SLICK: if (racer->vehicleID != VEHICLE_PLANE) { spawnedObj->shadow->scale = 0; } @@ -4603,22 +4643,25 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) case WEAPON_UNK_11: spawnedObj->segment.animFrame = 0; break; - } - if (soundID != SOUND_NONE) { - if (racer->playerIndex == PLAYER_COMPUTER) { - play_sound_at_position(soundID, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); - } else { - if (racer->weaponSoundMask) { - func_8000488C(racer->weaponSoundMask); - } - sound_play_spatial(soundID, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, (s32** ) &racer->weaponSoundMask); + } + if (soundID != SOUND_NONE) { + if (racer->playerIndex == PLAYER_COMPUTER) { + play_sound_at_position(soundID, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position, 4, + NULL); + } else { + if (racer->weaponSoundMask) { + func_8000488C(racer->weaponSoundMask); } + sound_play_spatial(soundID, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, (s32 **) &racer->weaponSoundMask); } } - if (racer->balloon_quantity > 0) { - racer->balloon_quantity = racer->balloon_quantity - 1; - } else { - racer->balloon_quantity = 0; + } + if (racer->balloon_quantity > 0) { + racer->balloon_quantity = racer->balloon_quantity - 1; + } else { + racer->balloon_quantity = 0; } } } @@ -4627,7 +4670,7 @@ void handle_racer_items(Object *obj, Object_Racer *racer, UNUSED s32 updateRate) /** * Honk honk -*/ + */ void play_char_horn_sound(Object *obj, Object_Racer *racer) { if (get_filtered_cheats() & CHEAT_HORN_CHEAT) { // Play character voice instead of horn. @@ -4644,7 +4687,7 @@ GLOBAL_ASM("asm/non_matchings/racer/func_8005698C.s") * When active, takes the magnet target, calculates the distance then sets the player's velocity * and movement direction towards the target until they either get close, or the timer runs out. * Shields will also cancel out the magnet. -*/ + */ void racer_activate_magnet(Object *obj, Object_Racer *racer, s32 updateRate) { f32 diffX; f32 diffZ; @@ -4702,14 +4745,15 @@ void racer_activate_magnet(Object *obj, Object_Racer *racer, s32 updateRate) { void racer_play_sound(Object *obj, s32 soundID) { Object_Racer *racer = &obj->unk64->racer; if (gCurrentPlayerIndex != PLAYER_COMPUTER && racer->exitObj == NULL) { - sound_play_spatial(soundID, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, NULL); + sound_play_spatial(soundID, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, NULL); } } /** * Set a timer and sound ID. * When that timer counts zero in the racer's update loop, it plays the sound passed through here. -*/ + */ void racer_play_sound_after_delay(Object *obj, s32 soundID, s32 delay) { Object_Racer *racer = &obj->unk64->racer; racer->delaySoundID = soundID; @@ -4743,7 +4787,8 @@ void play_random_character_voice(Object *obj, s32 soundID, s32 range, s32 flags) soundIndex = (get_random_number_from_range(0, range - 1) * 12) + soundID; } } - play_sound_at_position(soundIndex, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, &tempRacer->soundMask); + play_sound_at_position(soundIndex, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, &tempRacer->soundMask); tempRacer->lastSoundID = soundIndex; } } @@ -4787,7 +4832,7 @@ f32 handle_racer_top_speed(Object *obj, Object_Racer *racer) { timer = 0; } } - timer2 = 24 - timer; + timer2 = 24 - timer; racer->boostTimer = normalise_time(timer2 >> 1); if (timer2 == 24) { racer_play_sound(obj, SOUND_SELECT); @@ -4805,7 +4850,8 @@ f32 handle_racer_top_speed(Object *obj, Object_Racer *racer) { gStartBoostTime = racer->boostTimer; } // For the AI, expert AI will match the players start, and master AI will get a good start always. - if (racer->playerIndex == PLAYER_COMPUTER && (racer->aiSkill == AI_MASTER || (racer->aiSkill == AI_EXPERT && gStartBoostTime))) { + if (racer->playerIndex == PLAYER_COMPUTER && + (racer->aiSkill == AI_MASTER || (racer->aiSkill == AI_EXPERT && gStartBoostTime))) { if (gStartBoostTime) { racer->boostTimer = gStartBoostTime; } else { @@ -4821,7 +4867,7 @@ f32 handle_racer_top_speed(Object *obj, Object_Racer *racer) { } } if (racer->boostTimer && !gRaceStartTimer && timer3 && racer->raceFinished == FALSE) { - func_80072348(racer->playerIndex, 6); + func_80072348(racer->playerIndex, 6); } if (gRaceStartTimer < 80 && gCurrentButtonsPressed & A_BUTTON) { racer->startInput = 1; @@ -4884,14 +4930,14 @@ void func_800575EC(Object *obj, Object_Racer *racer) { /** * Racers struck by most weapons will drop up to 2 bananas on the ground. * During challenge mode, no bananas are spawned, though the number still drops. -*/ + */ void drop_bananas(Object *obj, Object_Racer *racer, s32 number) { LevelObjectEntryCommon newObject; Object_Banana *banana; s32 i; s16 angle[3]; s16 pos[3]; - Object* bananaObj; + Object *bananaObj; f32 variance; if (!(get_filtered_cheats() & CHEAT_START_WITH_10_BANANAS)) { @@ -4906,7 +4952,7 @@ void drop_bananas(Object *obj, Object_Racer *racer, s32 number) { pos[0] = 0; pos[1] = 8; pos[2] = 12; - s16_vec3_apply_object_rotation((ObjectTransform* ) angle, pos); + s16_vec3_apply_object_rotation((ObjectTransform *) angle, pos); newObject.x = pos[0] + (s32) obj->segment.trans.x_position; newObject.y = pos[1] + (s32) obj->segment.trans.y_position; newObject.z = pos[2] + (s32) obj->segment.trans.z_position; @@ -4937,12 +4983,11 @@ void drop_bananas(Object *obj, Object_Racer *racer, s32 number) { } number--; racer->bananas--; - } while(number > 0); + } while (number > 0); } } } - /** * Generate the steer velocity by taking the current steer velocity and getting the difference between the stick tilt. * Get the velocity from a fraction of the difference. @@ -4964,7 +5009,6 @@ void handle_base_steering(Object_Racer *racer, UNUSED s32 updateRate, f32 update } racer->steerAngle += turnVel; - } /** @@ -4973,9 +5017,9 @@ void handle_base_steering(Object_Racer *racer, UNUSED s32 updateRate, f32 update * Afterwards, writes position data to the current camera object. */ void update_player_camera(Object *obj, Object_Racer *racer, f32 updateRateF) { - f32 dialogueAngle; + f32 dialogueAngle; s32 tempUpdateRateF; - s32 angle; + s32 angle; if (gCurrentButtonsPressed & U_CBUTTONS && func_800A0190()) { gCameraObject->zoom++; @@ -4986,61 +5030,67 @@ void update_player_camera(Object *obj, Object_Racer *racer, f32 updateRateF) { func_80066060(racer->playerIndex, gCameraObject->zoom); } switch (gCameraObject->zoom) { - case ZOOM_MEDIUM: - sound_play(SOUND_MENU_BACK, NULL); - break; - case ZOOM_FAR: - sound_play(SOUND_MENU_BACK2, NULL); - break; - default: - sound_play(SOUND_UNK_6A, NULL); - break; + case ZOOM_MEDIUM: + sound_play(SOUND_MENU_BACK, NULL); + break; + case ZOOM_FAR: + sound_play(SOUND_MENU_BACK2, NULL); + break; + default: + sound_play(SOUND_UNK_6A, NULL); + break; } } if (racer->raceFinished == TRUE && gCameraObject->mode != CAMERA_FINISH_CHALLENGE) { - gCameraObject->mode = CAMERA_FINISH_RACE; + gCameraObject->mode = CAMERA_FINISH_RACE; } if (racer->exitObj) { gCameraObject->mode = CAMERA_FIXED; } // Set the camera behaviour based on current mode. switch (gCameraObject->mode) { - default: - break; - case CAMERA_CAR: - // Driving a car. - update_camera_car(updateRateF, obj, racer); - break; - case CAMERA_PLANE: - // Flying a plane. - update_camera_plane(updateRateF, obj, racer); - break; - case CAMERA_FIXED: - // Fixes the camera in place, continuing to look at the player. Used when entering doors. - update_camera_fixed(updateRateF, obj, racer); - break; - case CAMERA_HOVERCRAFT: - // Driving a hovercraft. - update_camera_hovercraft(updateRateF, obj, racer); - break; - case CAMERA_FINISH_CHALLENGE: - // When you finish a challenge, the camera will rotate around the player, or around a set path, if the player's been KO'd. - update_camera_finish_challenge(updateRateF, obj, racer); - break; - case CAMERA_LOOP: - // Used for loop-the-loops. Follows the face direction of the player exactly, the standard camera modes do not. - update_camera_loop(updateRateF, obj, racer); - break; - case CAMERA_FINISH_RACE: - // When you finish a race, the camera will go into a more cinematic mode, following the player. - update_camera_finish_race(updateRateF, obj, racer); - break; + default: + break; + case CAMERA_CAR: + // Driving a car. + update_camera_car(updateRateF, obj, racer); + break; + case CAMERA_PLANE: + // Flying a plane. + update_camera_plane(updateRateF, obj, racer); + break; + case CAMERA_FIXED: + // Fixes the camera in place, continuing to look at the player. Used when entering doors. + update_camera_fixed(updateRateF, obj, racer); + break; + case CAMERA_HOVERCRAFT: + // Driving a hovercraft. + update_camera_hovercraft(updateRateF, obj, racer); + break; + case CAMERA_FINISH_CHALLENGE: + // When you finish a challenge, the camera will rotate around the player, or around a set path, if the + // player's been KO'd. + update_camera_finish_challenge(updateRateF, obj, racer); + break; + case CAMERA_LOOP: + // Used for loop-the-loops. Follows the face direction of the player exactly, the standard camera modes do + // not. + update_camera_loop(updateRateF, obj, racer); + break; + case CAMERA_FINISH_RACE: + // When you finish a race, the camera will go into a more cinematic mode, following the player. + update_camera_finish_race(updateRateF, obj, racer); + break; } dialogueAngle = gDialogueCameraAngle / 10240.0f; // Goes between 0-1 - gCameraObject->offsetX = (((obj->segment.trans.x_position + (91.75 * racer->ox1) + (90.0 * racer->ox3)) - gCameraObject->trans.x_position) * dialogueAngle); - gCameraObject->offsetZ = (((obj->segment.trans.z_position + (91.75 * racer->oz1) + (90.0 * racer->oz3)) - gCameraObject->trans.z_position) * dialogueAngle); + gCameraObject->offsetX = (((obj->segment.trans.x_position + (91.75 * racer->ox1) + (90.0 * racer->ox3)) - + gCameraObject->trans.x_position) * + dialogueAngle); + gCameraObject->offsetZ = (((obj->segment.trans.z_position + (91.75 * racer->oz1) + (90.0 * racer->oz3)) - + gCameraObject->trans.z_position) * + dialogueAngle); gCameraObject->offsetY = (((get_npc_pos_y() + 48.5) - gCameraObject->trans.y_position) * dialogueAngle); - gCameraObject->pitchOffset = -gCameraObject->trans.x_rotation * dialogueAngle; + gCameraObject->pitchOffset = -gCameraObject->trans.x_rotation * dialogueAngle; gCameraObject->trans.x_position += gCameraObject->offsetX; gCameraObject->trans.y_position += gCameraObject->offsetY + gCameraObject->unk30; gCameraObject->trans.z_position += gCameraObject->offsetZ; @@ -5080,7 +5130,7 @@ void update_player_camera(Object *obj, Object_Racer *racer, f32 updateRateF) { /** * After the racer logic is all done, update the camera once more. * This time it will create the smooth following effect when turning. -*/ + */ void second_racer_camera_update(Object *obj, Object_Racer *racer, s32 mode, f32 updateRateF) { f32 xPos, yPos, zPos; if (gCurrentPlayerIndex != PLAYER_COMPUTER && racer->raceFinished != TRUE) { @@ -5163,19 +5213,19 @@ void update_camera_car(f32 updateRate, Object *obj, Object_Racer *racer) { brakeVar = racer->brake; baseSpeed = racer->forwardVel; switch (gCameraObject->zoom) { - case 1: - baseDistance += 35.0f; - break; - case 2: - baseDistance -= 35.0f; - yVel -= 10.0f; - break; - case 3: - baseDistance -= 53.0f; - yVel -= 5.0f; - brakeVar = 0.0f; - baseSpeed *= 0.25; - break; + case 1: + baseDistance += 35.0f; + break; + case 2: + baseDistance -= 35.0f; + yVel -= 10.0f; + break; + case 3: + baseDistance -= 53.0f; + yVel -= 5.0f; + brakeVar = 0.0f; + baseSpeed *= 0.25; + break; } if (racer->groundedWheels > 2 || racer->waterTimer != 0) { angle = (obj->segment.trans.x_rotation); @@ -5293,7 +5343,8 @@ void update_camera_car(f32 updateRate, Object *obj, Object_Racer *racer) { } gCameraObject->trans.y_position -= racer->unkC8 * sins_f(gCameraObject->trans.z_rotation); lateralOffset = (yOffset = gCameraObject->trans.x_position); - segmentIndex = get_level_segment_index_from_position(lateralOffset, gCameraObject->trans.y_position, gCameraObject->trans.z_position); + segmentIndex = get_level_segment_index_from_position(lateralOffset, gCameraObject->trans.y_position, + gCameraObject->trans.z_position); if (segmentIndex != -1) { gCameraObject->segmentIndex = segmentIndex; } @@ -5330,7 +5381,8 @@ void update_camera_finish_challenge(UNUSED f32 updateRate, Object *obj, Object_R gCameraObject->trans.y_position = obj->segment.trans.y_position + 45.0f; } gCameraObject->trans.z_position = obj->segment.trans.z_position + zOffset; - segmentIndex = get_level_segment_index_from_position(gCameraObject->trans.x_position, gCameraObject->trans.y_position, gCameraObject->trans.z_position); + segmentIndex = get_level_segment_index_from_position( + gCameraObject->trans.x_position, gCameraObject->trans.y_position, gCameraObject->trans.z_position); if (segmentIndex != SEGMENT_NONE) { gCameraObject->segmentIndex = segmentIndex; } @@ -5366,7 +5418,8 @@ void update_camera_finish_race(UNUSED f32 updateRate, Object *obj, Object_Racer gCameraObject->trans.y_rotation = 0x8000 - atan2s(diffX, diffZ); gCameraObject->trans.x_rotation = atan2s((s32) diffY, (s32) distance); gCameraObject->trans.z_rotation = 0; - gCameraObject->segmentIndex = get_level_segment_index_from_position(gCameraObject->trans.x_position, racer->oy1, gCameraObject->trans.z_position); + gCameraObject->segmentIndex = get_level_segment_index_from_position(gCameraObject->trans.x_position, racer->oy1, + gCameraObject->trans.z_position); } /** @@ -5380,16 +5433,18 @@ void update_camera_fixed(f32 updateRate, Object *obj, Object_Racer *racer) { updateRateF = (s32) updateRate; diffX = gCameraObject->trans.x_position - obj->segment.trans.x_position; diffZ = gCameraObject->trans.z_position - obj->segment.trans.z_position; - gCameraObject->trans.y_rotation += ((((-atan2s(diffX, diffZ)) - gCameraObject->trans.y_rotation) + 0x8000) * updateRateF) >> 4; + gCameraObject->trans.y_rotation += + ((((-atan2s(diffX, diffZ)) - gCameraObject->trans.y_rotation) + 0x8000) * updateRateF) >> 4; gCameraObject->trans.z_rotation -= ((s32) (gCameraObject->trans.z_rotation * updateRateF)) >> 4; - gCameraObject->segmentIndex = get_level_segment_index_from_position(gCameraObject->trans.x_position, racer->oy1, gCameraObject->trans.z_position); + gCameraObject->segmentIndex = get_level_segment_index_from_position(gCameraObject->trans.x_position, racer->oy1, + gCameraObject->trans.z_position); } /** * Iterate through every checkpoint and find the current location of the racer. * Sets the position arguments based on the intended location the spline functions return. * These coordinates are then used to generate a velocity. -*/ + */ void set_position_goal_from_path(UNUSED Object *obj, Object_Racer *racer, f32 *x, f32 *y, f32 *z) { CheckpointNode *checkpoint; s32 splinePos; @@ -5457,7 +5512,7 @@ void func_80059208(Object *obj, Object_Racer *racer, s32 updateRate) { f32 scale; s32 splineIndex; s32 i; - + temp_v0 = get_checkpoint_count(); if (temp_v0 == 0) { return; @@ -5573,10 +5628,10 @@ GLOBAL_ASM("asm/non_matchings/racer/func_80059208.s") /** * Writes a human readable time to the passed arguments. * Used to visualise a standard time to the player for a stopwatch, or a record. -*/ + */ void get_timestamp_from_frames(s32 frameCount, s32 *minutes, s32 *seconds, s32 *hundredths) { if (gVideoRefreshRate == REFRESH_50HZ) { - frameCount = (f32)frameCount * 1.2; + frameCount = (f32) frameCount * 1.2; } // (REFRESH_60HZ * 60) is just frames per minute basically *minutes = frameCount / (REFRESH_60HZ * 60); @@ -5587,9 +5642,10 @@ void get_timestamp_from_frames(s32 frameCount, s32 *minutes, s32 *seconds, s32 * /** * Allocate the ghost data heap into memory. * The path node pool is globally loaded, despite only being used in time trial. -*/ + */ void allocate_ghost_data(void) { - gGhostData[0] = allocate_from_main_pool_safe((sizeof(GhostNode) + sizeof(GhostDataFrame)) * MAX_NUMBER_OF_GHOST_NODES, COLOUR_TAG_RED); + gGhostData[0] = allocate_from_main_pool_safe( + (sizeof(GhostNode) + sizeof(GhostDataFrame)) * MAX_NUMBER_OF_GHOST_NODES, COLOUR_TAG_RED); gGhostData[1] = ((GhostNode *) gGhostData[0] + MAX_NUMBER_OF_GHOST_NODES); gGhostData[2] = NULL; // T.T. Ghost D_8011D5A0[0] = 0; @@ -5612,7 +5668,7 @@ void func_80059984(s32 arg0) { D_8011D59D = ((D_8011D59C + 1) & 1); D_8011D5AC = arg0; } - //get_previous_map_id? +// get_previous_map_id? s32 func_800599A8(void) { return D_8011D5AC; } @@ -5668,12 +5724,13 @@ void free_tt_ghost_data(void) { } SIDeviceStatus func_80059B7C(s32 controllerIndex, s32 mapId, s16 arg2, s16 arg3, s16 arg4) { - return func_80075000(controllerIndex, (s16) mapId, arg2, arg3, arg4, D_8011D5A0[D_8011D59C], (GhostHeader *) gGhostData[D_8011D59C]); + return func_80075000(controllerIndex, (s16) mapId, arg2, arg3, arg4, D_8011D5A0[D_8011D59C], + (GhostHeader *) gGhostData[D_8011D59C]); } void func_80059BF0(Object *obj, s32 updateRate) { f32 yOffset; - Object_Racer* racer; + Object_Racer *racer; GhostNode *ghostNode; racer = &obj->unk64->racer; @@ -5684,7 +5741,7 @@ void func_80059BF0(Object *obj, s32 updateRate) { yOffset = 17.0f - (yOffset * 17.0f); D_8011D59E -= updateRate; if (D_8011D59E > 0) { - return; + return; } while (D_8011D59E <= 0) { D_8011D59E += 30; @@ -5732,12 +5789,12 @@ s32 set_ghost_position_and_rotation(Object *obj) { if (is_time_trial_ghost(obj)) { ghostDataIndex = 2; } - + commonUnk0f32 = (f32) obj->properties.common.unk0 / 30.0f; if (osTvType == TV_TYPE_PAL && ghostDataIndex == 2) { commonUnk0f32 = ((f32) obj->properties.common.unk0 * 1.2) / 30.0f; } - commonUnk0s32 = commonUnk0f32; //Truncate the float to an integer? + commonUnk0s32 = commonUnk0f32; // Truncate the float to an integer? ghostNodeCount = D_8011D5A0[ghostDataIndex]; if (commonUnk0s32 >= (ghostNodeCount - 2)) { @@ -5750,7 +5807,7 @@ s32 set_ghost_position_and_rotation(Object *obj) { nodeIndex = commonUnk0s32 - 1; curGhostNode = &ghostData[nodeIndex]; - //This whole loop is a bit of a mystery still... The i < 4 is a complete guess... + // This whole loop is a bit of a mystery still... The i < 4 is a complete guess... for (i = 0; i < 3; i++) { if (nodeIndex == -1) { vectorX[i] = ((curGhostNode + 1)->x * 2) - (curGhostNode + 2)->x; @@ -5768,7 +5825,7 @@ s32 set_ghost_position_and_rotation(Object *obj) { nodeIndex++; curGhostNode++; } - + catmullX = commonUnk0f32 - commonUnk0s32; obj->segment.trans.x_position = catmull_rom_interpolation(vectorX, 0, catmullX); obj->segment.trans.y_position = catmull_rom_interpolation(vectorY, 0, catmullX); @@ -5776,7 +5833,7 @@ s32 set_ghost_position_and_rotation(Object *obj) { curGhostNode = &ghostData[commonUnk0s32]; - //Y Rotation + // Y Rotation rot = curGhostNode->yRotation; nextGhostNode = curGhostNode + 1; rotDiff = nextGhostNode->yRotation - (rot & 0xFFFF); @@ -5787,8 +5844,8 @@ s32 set_ghost_position_and_rotation(Object *obj) { rotDiff += 0xFFFF; } obj->segment.trans.y_rotation = rot + (s32) (rotDiff * catmullX); - - //X Rotation + + // X Rotation rot = curGhostNode->xRotation; nextGhostNode = curGhostNode + 1; rotDiff = nextGhostNode->xRotation - (rot & 0xFFFF); @@ -5799,8 +5856,8 @@ s32 set_ghost_position_and_rotation(Object *obj) { rotDiff += 0xFFFF; } obj->segment.trans.x_rotation = rot + (s32) (rotDiff * catmullX); - - //Z Rotation + + // Z Rotation rot = curGhostNode->zRotation; nextGhostNode = curGhostNode + 1; rotDiff = nextGhostNode->zRotation - (rot & 0xFFFF); @@ -5811,9 +5868,10 @@ s32 set_ghost_position_and_rotation(Object *obj) { rotDiff += 0xFFFF; } obj->segment.trans.z_rotation = rot + (s32) (rotDiff * catmullX); - + obj->unk74 = 0; - obj->segment.object.segmentID = get_level_segment_index_from_position(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + obj->segment.object.segmentID = get_level_segment_index_from_position( + obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); if (ghostNodeCount == (commonUnk0s32 + 3)) { racer = &obj->unk64->racer; if (catmullX >= 0.8) { @@ -5831,7 +5889,7 @@ GLOBAL_ASM("asm/non_matchings/racer/set_ghost_position_and_rotation.s") /** * Blocks the player's movement until the end of their update cycle. * Called for every frame the player shouldn't be able to drive. -*/ + */ void disable_racer_input(void) { gRacerInputBlocked = TRUE; } @@ -5839,7 +5897,7 @@ void disable_racer_input(void) { /** * Tells the camera to start rotating to the side for the dialogue camera. * Called for every frame the player should experience subtle cinematography. -*/ + */ void racer_set_dialogue_camera(void) { gRacerDialogueCamera = TRUE; } @@ -5847,7 +5905,7 @@ void racer_set_dialogue_camera(void) { /** * Antipiracy function that loops over an address of a function a number of times. * It compares the number it gets to a generated checksum to determine if the game has been tampered with at all. -*/ + */ void compare_balloon_checksums(void) { s32 i; s32 count = 0; @@ -5867,14 +5925,14 @@ void compare_balloon_checksums(void) { * Get the angle to the door object, and drive towards it. * After a timer hits 0, execute the transition. */ -void racer_enter_door(Object_Racer* racer, s32 updateRate) { +void racer_enter_door(Object_Racer *racer, s32 updateRate) { struct Object_Exit *exit; f32 updateRateF; s32 angle; exit = (struct Object_Exit *) racer->exitObj->unk64; racer->playerIndex = PLAYER_COMPUTER; - angle = (u16) arctan2_f(exit->directionX, exit->directionZ) - (racer->steerVisualRotation & 0xFFFF); + angle = (u16) arctan2_f(exit->directionX, exit->directionZ) - (racer->steerVisualRotation & 0xFFFF); WRAP(angle, -0x8000, 0x8000); angle = -angle >> 5; gCurrentStickX = angle; @@ -5890,7 +5948,13 @@ void racer_enter_door(Object_Racer* racer, s32 updateRate) { updateRateF = (f32) updateRate; gCameraObject->trans.x_position += (exit->directionX * updateRateF) * 1.5; gCameraObject->trans.z_position += (exit->directionZ * updateRateF) * 1.5; - if (gCurrentStickX > 75) { gCurrentStickX = 75; gCurrentRacerInput |= A_BUTTON | B_BUTTON; } // Only matches if it's on the same line + // clang-format off + // Only matches if it's on the same line + if (gCurrentStickX > 75) { \ + gCurrentStickX = 75; \ + gCurrentRacerInput |= A_BUTTON | B_BUTTON; \ + } + // clang-format on if (gCurrentStickX < -75) { gCurrentStickX = -75; gCurrentRacerInput |= A_BUTTON | B_BUTTON; @@ -5911,7 +5975,7 @@ void racer_enter_door(Object_Racer* racer, s32 updateRate) { if (racer->transitionTimer > 0) { racer->transitionTimer -= updateRate; if (racer->transitionTimer <= 0) { - func_8006D968((s8* ) racer->exitObj->segment.level_entry); + func_8006D968((s8 *) racer->exitObj->segment.level_entry); racer->transitionTimer = 0; } } @@ -5919,8 +5983,9 @@ void racer_enter_door(Object_Racer* racer, s32 updateRate) { /** * The top level function for handling the actions of a computer controlled racer. - * Mostly the same as how the player controlled one works, minus controller input and includes some decisionmaking logic. -*/ + * Mostly the same as how the player controlled one works, minus controller input and includes some decision making + * logic. + */ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateRateF) { s32 var_t2; Object **objects; @@ -5968,20 +6033,21 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat xPos = obj->segment.trans.x_position; yPos = obj->segment.trans.y_position; zPos = obj->segment.trans.z_position; - + if (racer->unk1B2 > 0) { racer->unk1B2 -= updateRate; if (racer->unk1B2 < 0) { racer->unk1B2 = 0; } } - + racer->miscAnimCounter++; //!@Delta - - if (is_taj_challenge() || func_80023568() || racer->vehicleID == VEHICLE_LOOPDELOOP || D_8011D544 > 120.0f || gRaceStartTimer != 0 || levelHeader->race_type & RACETYPE_CHALLENGE_BATTLE) { + + if (is_taj_challenge() || func_80023568() || racer->vehicleID == VEHICLE_LOOPDELOOP || D_8011D544 > 120.0f || + gRaceStartTimer != 0 || levelHeader->race_type & RACETYPE_CHALLENGE_BATTLE) { racer->unk201 = 30; } - + var_fv1 = 1000000; if (racer->unk201 == 0) { objects = get_racer_objects(&countOfObjects); @@ -5992,7 +6058,7 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat playerOneObj = objects[var_t2]; } if (tempRacer->playerIndex == PLAYER_TWO) { - playerTwoObj = objects[var_t2]; + playerTwoObj = objects[var_t2]; } } if (playerOneObj != NULL) { @@ -6034,7 +6100,7 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat } if (racer->unk1FE == 2) { racer->unk84 += ((((sins_f(racer->unk1FF << 8) * 4) - racer->unk84) * 0.0625 * updateRateF)); - racer->unk88 += ((((coss_f (racer->unk1FF << 8) * 4) - racer->unk88) * 0.0625 * updateRateF)); + racer->unk88 += ((((coss_f(racer->unk1FF << 8) * 4) - racer->unk88) * 0.0625 * updateRateF)); } else { racer->unk84 -= racer->unk84 * 0.0625 * updateRateF; racer->unk88 -= racer->unk88 * 0.0625 * updateRateF; @@ -6053,7 +6119,8 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat racer->buoyancy = 0; gRacerWaveCount = 0; } else { - gRacerWaveCount = func_8002B0F4(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position, &gRacerCurrentWave); + gRacerWaveCount = func_8002B0F4(obj->segment.object.segmentID, obj->segment.trans.x_position, + obj->segment.trans.z_position, &gRacerCurrentWave); } func_8002ACC8(0); if (racer->approachTarget != NULL || gRaceStartTimer != 0 || racer->bubbleTrapTimer > 0) { @@ -6063,6 +6130,8 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat gCurrentButtonsReleased = 0; gCurrentButtonsPressed = 0; } + + // clang-format off // The case statements break must be on the same line as the function call in order to match switch (racer->vehicleID) { case VEHICLE_CAR: func_8004F7F4(updateRate, updateRateF, obj, racer); break; @@ -6079,6 +6148,8 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat case VEHICLE_WIZPIG: update_wizpig(updateRate, updateRateF, obj, racer, &gCurrentRacerInput, &gCurrentButtonsPressed, &gRaceStartTimer); break; case VEHICLE_ROCKET: update_rocket(updateRate, updateRateF, obj, racer, &gCurrentRacerInput, &gCurrentButtonsPressed, &gRaceStartTimer); break; } + // clang-format on + if (gameMode != GAMEMODE_MENU) { racer_sound_update(obj, gCurrentButtonsPressed, gCurrentRacerInput, updateRate); } @@ -6156,10 +6227,13 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat } else { temp_fv1_2 = -0.02f; } - racer->stretch_height = (racer->stretch_height + ((((racer->stretch_height_cap - racer->stretch_height) * 0.125) + temp_fv1_2) * updateRateF)); - if (((temp_fv1_2 < 0.0f) && (racer->stretch_height <= racer->stretch_height_cap)) || ((temp_fv1_2 > 0.0f) && (racer->stretch_height_cap <= racer->stretch_height))) { + racer->stretch_height = + (racer->stretch_height + + ((((racer->stretch_height_cap - racer->stretch_height) * 0.125) + temp_fv1_2) * updateRateF)); + if (((temp_fv1_2 < 0.0f) && (racer->stretch_height <= racer->stretch_height_cap)) || + ((temp_fv1_2 > 0.0f) && (racer->stretch_height_cap <= racer->stretch_height))) { racer->stretch_height = racer->stretch_height_cap; - racer->stretch_height_cap = 1.0f; + racer->stretch_height_cap = 1.0f; } var_t2 = ((racer->headAngleTarget - racer->headAngle) * updateRate) >> 3; CLAMP(var_t2, -0x800, 0x800) @@ -6171,9 +6245,11 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat if (racer->shieldTimer > 0) { if (racer->shieldTimer > 60) { if (racer->shieldSoundMask) { - update_spatial_audio_position(racer->shieldSoundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + update_spatial_audio_position(racer->shieldSoundMask, obj->segment.trans.x_position, + obj->segment.trans.y_position, obj->segment.trans.z_position); } else if (racer->vehicleSound) { - play_sound_at_position(SOUND_SHIELD, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 1, &racer->shieldSoundMask); + play_sound_at_position(SOUND_SHIELD, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 1, &racer->shieldSoundMask); } } else { if (racer->shieldSoundMask) { @@ -6187,7 +6263,8 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat } } if (racer->soundMask != NULL) { - update_spatial_audio_position(racer->soundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + update_spatial_audio_position(racer->soundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position); } gRacerInputBlocked = FALSE; if ((racer->unk150 != NULL) && (gRaceStartTimer == 0)) { @@ -6210,25 +6287,25 @@ void update_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updat } #ifdef NON_EQUIVALENT -//WIP +// WIP void func_8005B818(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateRateF) { s32 sp11C; f32 sp100; f32 spEC; - f32 spC0; //s32? + f32 spC0; // s32? f32 spD8; - f32 spBC; //s32? + f32 spBC; // s32? f32 spB8; - f32 spAC; //s32? - f32 spA8; //s32? - f32 spA4; //struct? + f32 spAC; // s32? + f32 spA8; // s32? + f32 spA4; // struct? f32 sp9C; f32 sp98; f32 sp94; - f32 sp8C; //What sets this? - LevelHeader *levelHeader; //sp80 + f32 sp8C; // What sets this? + LevelHeader *levelHeader; // sp80 f32 *sp70; - f32 *var_t0; //struct? + f32 *var_t0; // struct? f32 *var_a2; f32 *var_a3; f32 *var_t1; @@ -6291,7 +6368,7 @@ void func_8005B818(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR if (var_v0 < 0) { var_v0 = 0; } - sp94 = (f32)var_v0 / 150.0; + sp94 = (f32) var_v0 / 150.0; var_f12_2 = var_f12 - sp94; if (var_f12_2 < 2.0) { var_f12_2 = 2.0f; @@ -6329,7 +6406,7 @@ void func_8005B818(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateR var_a0 = 0; } } - + if (racer->velocity < 0.0f) { racer->velocity = -racer->velocity; } diff --git a/src/racer.h b/src/racer.h index cc33a5d9..0af0e393 100644 --- a/src/racer.h +++ b/src/racer.h @@ -159,20 +159,20 @@ s32 roll_percent_chance(s32 chance); void apply_plane_tilt_anim(s32 updateRate, Object *obj, Object_Racer *racer); void racer_attack_handler_plane(Object *obj, Object_Racer *racer); void update_carpet(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer); -void set_racer_tail_lights(Object_Racer *arg0); +void set_racer_tail_lights(Object_Racer *racer); s32 should_taj_teleport(void); -void set_taj_status(s32 arg0); +void set_taj_status(s32 status); void slowly_reset_head_angle(Object_Racer *racer); -void func_80052988(Object *obj, Object_Racer *arg1, s32 action, s32 arg3, s32 duration, s32 arg5, s32 arg6, s32 arg7); +void func_80052988(Object *obj, Object_Racer *racer, s32 action, s32 arg3, s32 duration, s32 arg5, s32 flags, s32 arg7); void handle_car_steering(Object_Racer *racer); void func_800535C4(Object *obj, Object_Racer *racer); void handle_car_velocity_control(Object_Racer *racer); void play_char_horn_sound(Object *obj, Object_Racer *racer); void racer_play_sound(Object *obj, s32 soundID); -void racer_play_sound_after_delay(Object *obj, s32 arg1, s32 arg2); +void racer_play_sound_after_delay(Object *obj, s32 soundID, s32 delay); void func_800575EC(Object *obj, Object_Racer *racer); void handle_base_steering(Object_Racer *racer, s32 updateRate, f32 updateRateF); -void second_racer_camera_update(Object *obj, Object_Racer *racer, s32 mode, f32 arg3); +void second_racer_camera_update(Object *obj, Object_Racer *racer, s32 mode, f32 updateRateF); void get_timestamp_from_frames(s32 frameCount, s32 *minutes, s32 *seconds, s32 *hundredths); void allocate_ghost_data(void); void func_80059944(void); @@ -191,31 +191,31 @@ s32 turn_head_towards_object(Object *obj, Object_Racer *racer, Object *targetObj void onscreen_ai_racer_physics(Object *obj, Object_Racer *racer, s32 arg2); void func_8005C270(Object_Racer *racer); f32 handle_racer_top_speed(Object *obj, Object_Racer *racer); -void play_random_character_voice(Object *obj, s32 soundID, s32 range, s32 arg3); +void play_random_character_voice(Object *obj, s32 soundID, s32 range, s32 flags); void apply_vehicle_rotation_offset(Object_Racer *obj, s32 max, s16 yRotation, s16 xRotation, s16 zRotation); void set_position_goal_from_path(Object *obj, Object_Racer *racer, f32 *x, f32 *y, f32 *z); void update_onscreen_AI_racer(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateRateF); void update_camera_hovercraft(f32 updateRate, Object *obj, Object_Racer *racer); void update_camera_plane(f32 updateRate, Object *obj, Object_Racer *racer); -void update_camera_loop(f32 updateRate, Object *obj, Object_Racer *racer); +void update_camera_loop(f32 updateRateF, Object *obj, Object_Racer *racer); void update_camera_car(f32 updateRate, Object *obj, Object_Racer *racer); void update_camera_finish_challenge(f32 arg0, Object *obj, Object_Racer *racer); void update_camera_finish_race(f32 arg0, Object *obj, Object_Racer *racer); -void update_camera_fixed(f32 arg0, Object *obj, Object_Racer *racer); +void update_camera_fixed(f32 updateRate, Object *obj, Object_Racer *racer); void handle_racer_head_turning(Object *obj, Object_Racer *racer, s32 updateRate); void racer_approach_object(Object *obj, Object_Racer *racer, f32 divisor); void obj_init_racer(Object *obj, LevelObjectEntry_Racer *racer); void racer_AI_pathing_inputs(Object *obj, Object_Racer *racer, s32 updateRate); void increment_ai_behaviour_chances(Object *obj, Object_Racer *racer, s32 updateRate); void onscreen_ai_racer_physics(Object *obj, Object_Racer *racer, s32 updateRate); -void update_player_camera(Object *obj, Object_Racer *racer, f32 updateRate); +void update_player_camera(Object *obj, Object_Racer *racer, f32 updateRateF); void racer_spinout_car(Object* obj, Object_Racer* racer, s32 updateRate, f32 updateRateF); void racer_attack_handler_car(Object* obj, Object_Racer* racer, s32 updateRate); void racer_attack_handler_hovercraft(Object* obj, Object_Racer* racer); void racer_enter_door(Object_Racer *racer, s32 updateRate); void func_8005250C(Object* obj, Object_Racer* racer, s32 updateRate); void update_car_velocity_ground(Object* obj, Object_Racer* racer, s32 updateRate, f32 updateRateF); -f32 rotate_racer_in_water(Object* obj1, Object_Racer* racer, Vec3f *pos, s8 arg3, s32 updateRate, s32 arg5, f32 arg6); +f32 rotate_racer_in_water(Object *obj, Object_Racer *racer, Vec3f *pos, s8 arg3, s32 updateRate, s32 arg5, f32 arg6); void update_AI_racer(Object* obj, Object_Racer* racer, s32 updateRate, f32 updateRateF); void func_80042D20(Object *obj, Object_Racer *racer, s32 updateRate); void handle_racer_items(Object *obj, Object_Racer *racer, s32 updateRate); diff --git a/src/rcp.c b/src/rcp.c index 32efdadc..148e5433 100644 --- a/src/rcp.c +++ b/src/rcp.c @@ -11,10 +11,7 @@ /************ .data ************/ -s16 gGfxTaskMesgNums[16] = { - 2, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; +s16 gGfxTaskMesgNums[16] = { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; u8 sBackgroundPrimColourR = 0; u8 sBackgroundPrimColourG = 0; @@ -32,8 +29,8 @@ s32 gfxBufCounter2 = 0; s32 gGfxTaskIsRunning = FALSE; Gfx dRspInit[] = { - gsSPClearGeometryMode(G_SHADE | G_SHADING_SMOOTH | G_CULL_FRONT | G_CULL_BACK | - G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD), + gsSPClearGeometryMode(G_SHADE | G_SHADING_SMOOTH | G_CULL_FRONT | G_CULL_BACK | G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD), gsSPTexture(0, 0, 0, 0, 0), gsSPSetGeometryMode(G_SHADING_SMOOTH | G_SHADE), gsSPClipRatio(FRUSTRATIO_2), @@ -107,20 +104,28 @@ Gfx dScaledRectangleBaseModes[] = { Gfx dTextureRectangleScaledOpa[][2] = { // Bilinear Filtered texture - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP_NOPERSP, G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP_NOPERSP, G_RM_OPA_SURF, G_RM_OPA_SURF2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP_NOPERSP, G_RM_AA_OPA_SURF, + G_RM_AA_OPA_SURF2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP_NOPERSP, G_RM_OPA_SURF, + G_RM_OPA_SURF2), // Point Sampled texture - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT_NOPERSP, G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT_NOPERSP, G_RM_OPA_SURF, G_RM_OPA_SURF2) + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT_NOPERSP, G_RM_AA_OPA_SURF, + G_RM_AA_OPA_SURF2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT_NOPERSP, G_RM_OPA_SURF, + G_RM_OPA_SURF2) }; Gfx dTextureRectangleScaledXlu[][2] = { // Bilinear Filtered texture - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP_NOPERSP, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP_NOPERSP, G_RM_XLU_SURF, G_RM_XLU_SURF2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP_NOPERSP, G_RM_AA_XLU_SURF, + G_RM_AA_XLU_SURF2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP_NOPERSP, G_RM_XLU_SURF, + G_RM_XLU_SURF2), // Point Sampled texture - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT_NOPERSP, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT_NOPERSP, G_RM_XLU_SURF, G_RM_XLU_SURF2) + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT_NOPERSP, G_RM_AA_XLU_SURF, + G_RM_AA_XLU_SURF2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT_NOPERSP, G_RM_XLU_SURF, + G_RM_XLU_SURF2) }; /*******************************/ @@ -160,7 +165,7 @@ OSMesgQueue *osScInterruptQ; * Sends a message to the scheduler to start processing an RSP task once set up. * Official Name: rcpFast3d */ -s32 setup_ostask_xbus(Gfx* dlBegin, Gfx* dlEnd, UNUSED s32 recvMesg) { +s32 setup_ostask_xbus(Gfx *dlBegin, Gfx *dlEnd, UNUSED s32 recvMesg) { DKR_OSTask *dkrtask; gGfxTaskIsRunning = TRUE; @@ -203,7 +208,7 @@ s32 setup_ostask_xbus(Gfx* dlBegin, Gfx* dlEnd, UNUSED s32 recvMesg) { * Unused variant of the xbus task function. * Probably intended to be a secondary task system, since it doesn't set the var saying there's a task running. */ -UNUSED void setup_ostask_xbus_2(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg) { +UNUSED void setup_ostask_xbus_2(Gfx *dlBegin, Gfx *dlEnd, s32 recvMesg) { DKR_OSTask *dkrtask; OSMesg mesgBuf; @@ -238,7 +243,7 @@ UNUSED void setup_ostask_xbus_2(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg) { dkrtask->unused60 = 0xFF; dkrtask->unused64 = 0xFF; dkrtask->unk68 = 0; - + if (recvMesg) { dkrtask->mesgQueue = &D_80125EA0; } @@ -250,12 +255,12 @@ UNUSED void setup_ostask_xbus_2(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg) { } /** - * + * * Prepare the gfx task for the F3DDKR FIFO microcode. * Sends a message to the scheduler to start processing an RSP task once set up. * Goes unused, and is broken. */ -UNUSED void setup_ostask_fifo(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg) { +UNUSED void setup_ostask_fifo(Gfx *dlBegin, Gfx *dlEnd, s32 recvMesg) { DKR_OSTask *dkrtask; OSMesg mesgBuf; @@ -265,7 +270,7 @@ UNUSED void setup_ostask_fifo(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg) { if (gfxBufCounter2 == 2) { gfxBufCounter2 = 0; } - + dkrtask->task.data_ptr = (u64 *) dlBegin; dkrtask->task.ucode_boot = (u64 *) rspF3DDKRBootStart; dkrtask->task.data_size = (s32) (dlEnd - dlBegin) * sizeof(Gfx); @@ -291,13 +296,13 @@ UNUSED void setup_ostask_fifo(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg) { dkrtask->unused60 = 0xFF; dkrtask->unused64 = 0xFF; dkrtask->unk68 = 0; - + if (recvMesg) { - dkrtask->mesgQueue = &D_80125EA0; + dkrtask->mesgQueue = &D_80125EA0; } osWritebackDCacheAll(); osSendMesg(osScInterruptQ, dkrtask, 1); - + if (recvMesg) { osRecvMesg(&D_80125EA0, &mesgBuf, OS_MESG_BLOCK); } @@ -307,7 +312,7 @@ UNUSED void setup_ostask_fifo(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg) { * Unused variant of the FIFO task function. * Probably intended to be a secondary task system, since it doesn't set the var saying there's a task running. */ -UNUSED void setup_ostask_fifo_2(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg) { +UNUSED void setup_ostask_fifo_2(Gfx *dlBegin, Gfx *dlEnd, s32 recvMesg) { DKR_OSTask *dkrtask; OSMesg mesgBuf; @@ -318,7 +323,7 @@ UNUSED void setup_ostask_fifo_2(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg) { if (gfxBufCounter == 3) { gfxBufCounter = 0; } - + dkrtask->task.data_size = (s32) (dlEnd - dlBegin) * sizeof(Gfx); dkrtask->task.data_ptr = (u64 *) dlBegin; dkrtask->task.type = M_GFXTASK; @@ -361,10 +366,10 @@ UNUSED void setup_ostask_fifo_2(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg) { */ s32 wait_for_gfx_task(void) { OSMesg *mesg = NULL; - if (gGfxTaskIsRunning == FALSE) { + if (gGfxTaskIsRunning == FALSE) { return 0; } - osRecvMesg(&gGfxTaskMesgQueue, (OSMesg) &mesg, OS_MESG_BLOCK); + osRecvMesg(&gGfxTaskMesgQueue, (OSMesg) &mesg, OS_MESG_BLOCK); gGfxTaskIsRunning = FALSE; return (s32) mesg[1]; } @@ -400,7 +405,7 @@ void set_background_fill_colour(s32 red, s32 green, s32 blue) { * over the colour buffer. DrawBG if set to 0 (which never happens) will completely skip * over clearing the colour buffer. * Official Name: rcpClearScreen -*/ + */ void render_background(Gfx **dList, Matrix *mtx, s32 drawBG) { s32 widthAndHeight; s32 w; @@ -435,10 +440,12 @@ void render_background(Gfx **dList, Matrix *mtx, s32 drawBG) { gDPSetFillColor((*dList)++, sBackgroundFillColour); gDPFillRectangle((*dList)++, 0, 0, w - 1, h - 1); } - // Used for secondary viewport backgrounds. This does not need to be 1 cycle, this could easily work with fillmode. + // Used for secondary viewport backgrounds. This does not need to be 1 cycle, this could easily work with + // fillmode. if (copy_viewport_background_size_to_coords(0, &x1, &y1, &x2, &y2)) { gDPSetCycleType((*dList)++, G_CYC_1CYCLE); - gDPSetPrimColor((*dList)++, 0, 0, sBackgroundPrimColourR, sBackgroundPrimColourG, sBackgroundPrimColourB, 255); + gDPSetPrimColor((*dList)++, 0, 0, sBackgroundPrimColourR, sBackgroundPrimColourG, + sBackgroundPrimColourB, 255); gDPSetCombineMode((*dList)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); gDPSetRenderMode((*dList)++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gDPFillRectangle((*dList)++, x1, y1, x2, y2); @@ -451,7 +458,10 @@ void render_background(Gfx **dList, Matrix *mtx, s32 drawBG) { } else if (gBackgroundDrawFunc.ptr != NULL) { gBackgroundDrawFunc.function((Gfx *) dList, mtx); } else { - gDPSetFillColor((*dList)++, (GPACK_RGBA5551(sBackgroundPrimColourR, sBackgroundPrimColourG, sBackgroundPrimColourB, 1) << 16) | GPACK_RGBA5551(sBackgroundPrimColourR, sBackgroundPrimColourG, sBackgroundPrimColourB, 1)); + gDPSetFillColor( + (*dList)++, + (GPACK_RGBA5551(sBackgroundPrimColourR, sBackgroundPrimColourG, sBackgroundPrimColourB, 1) << 16) | + GPACK_RGBA5551(sBackgroundPrimColourR, sBackgroundPrimColourG, sBackgroundPrimColourB, 1)); gDPFillRectangle((*dList)++, 0, 0, w - 1, h - 1); } } @@ -489,7 +499,7 @@ void setup_gfx_mesg_queues(OSSched *sc) { osCreateMesgQueue(&gGfxTaskMesgQueue, gGfxTaskMesgBuf, ARRAY_COUNT(gGfxTaskMesgBuf)); } -//Called after finishing a race. Sets values during single player races. Set to zero during trophy races. +// Called after finishing a race. Sets values during single player races. Set to zero during trophy races. void func_80078170(TextureHeader *arg0, TextureHeader *arg1, u32 arg2) { D_800DE4C4 = arg0; D_800DE4C8 = arg1; @@ -501,7 +511,7 @@ void func_80078170(TextureHeader *arg0, TextureHeader *arg1, u32 arg2) { * Seems to render the background screen after a race finishes while you're at the menu deciding what to do next. * https://i.imgur.com/MHbUD2a.png is an example. The left is correct, and the right is incorrect rendering. * Official Name: rcpMosaicClear -*/ + */ void func_80078190(Gfx **dlist) { s32 texture1And2UpperHeight; s32 videoHeight; @@ -510,16 +520,16 @@ void func_80078190(Gfx **dlist) { s32 upperVideoHeight; s32 texture1UpperWidth; s32 texture1UpperHeight; - //s32 texture2UpperHeight; + // s32 texture2UpperHeight; s32 widthAndHeight; s32 yPos; s32 var_s3; - s32 uly; //the y-coordinate of upper-left corner of rectangle (10.2, 0.0~1023.75) - s32 ulx; //the y-coordinate of upper-left corner of rectangle (10.2, 0.0~1023.75) - s32 lry; //the y-coordinate of lower-right corner of rectangle (10.2, 0.0~1023.75) - s32 lrx; //the x-coordinate of lower-right corner of rectangle (10.2, 0.0~1023.75) - s32 t; //the texture coordinate t of upper-left corner of rectangle (s10.5) - s32 s; //the texture coordinate s of upper-left corner of rectangle (s10.5) + s32 uly; // the y-coordinate of upper-left corner of rectangle (10.2, 0.0~1023.75) + s32 ulx; // the y-coordinate of upper-left corner of rectangle (10.2, 0.0~1023.75) + s32 lry; // the y-coordinate of lower-right corner of rectangle (10.2, 0.0~1023.75) + s32 lrx; // the x-coordinate of lower-right corner of rectangle (10.2, 0.0~1023.75) + s32 t; // the texture coordinate t of upper-left corner of rectangle (s10.5) + s32 s; // the texture coordinate s of upper-left corner of rectangle (s10.5) widthAndHeight = get_video_width_and_height_as_s32(); videoWidth = GET_VIDEO_WIDTH(widthAndHeight); @@ -557,7 +567,7 @@ void func_80078190(Gfx **dlist) { upperVideoHeight = videoHeight << 2; texture1UpperWidth = D_800DE4C4->width << 2; texture1UpperHeight = D_800DE4C4->height << 2; - //texture2UpperHeight = D_800DE4C8->height << 2; + // texture2UpperHeight = D_800DE4C8->height << 2; texture1And2UpperHeight = (D_800DE4C8->height << 2) + texture1UpperHeight; var_s3 = 0; for (yPos = 0; yPos < upperVideoHeight; yPos += texture1And2UpperHeight) { @@ -609,7 +619,7 @@ GLOBAL_ASM("asm/non_matchings/rcp/func_80078190.s") /** * Enables the chequer background and sets up its properties. -*/ + */ UNUSED void set_chequer_background(s32 colourA, s32 colourB, s32 width, s32 height) { gChequerBGColourR1 = (colourA >> 24) & 0xFF; gChequerBGColourG1 = (colourA >> 16) & 0xFF; @@ -626,7 +636,7 @@ UNUSED void set_chequer_background(s32 colourA, s32 colourB, s32 width, s32 heig /** * Disables the chequer background. -*/ + */ UNUSED void disable_chequer_background(void) { gChequerBGEnabled = FALSE; } @@ -635,7 +645,7 @@ UNUSED void disable_chequer_background(void) { * Uses global chequerboard settings to render a background using two different alternating colours. * Goes unused. * Official Name: rcpCheckClear -*/ + */ void render_chequer_background(Gfx **dList) { s32 height; s32 width; @@ -646,31 +656,31 @@ void render_chequer_background(Gfx **dList) { width = get_video_width_and_height_as_s32(); height = GET_VIDEO_HEIGHT(width) & 0xFFFF; width = GET_VIDEO_WIDTH(width); - + gSPDisplayList((*dList)++, dChequerBGSettings); gDPSetPrimColor((*dList)++, 0, 0, gChequerBGColourR1, gChequerBGColourG1, gChequerBGColourB1, gChequerBGColourA1); for (y = 0, flip = 0; y < height; y += gChequerBGHeight, flip ^= 1) { for (x = flip * gChequerBGWidth; x < width; x += gChequerBGWidth * 2) { - gDPFillRectangle((*dList)++, x, y, x + gChequerBGWidth, y + gChequerBGHeight); + gDPFillRectangle((*dList)++, x, y, x + gChequerBGWidth, y + gChequerBGHeight); } } - + gDPSetPrimColor((*dList)++, 0, 0, gChequerBGColourR2, gChequerBGColourG2, gChequerBGColourB2, gChequerBGColourA2); - + for (y = 0, flip = 1; y < height; y += gChequerBGHeight, flip ^= 1) { for (x = flip * gChequerBGWidth; x < width; x += gChequerBGWidth * 2) { - gDPFillRectangle((*dList)++, x, y, x + gChequerBGWidth, y + gChequerBGHeight); + gDPFillRectangle((*dList)++, x, y, x + gChequerBGWidth, y + gChequerBGHeight); } } - + gDPPipeSync((*dList)++); } /** * Sets the function pointer to whatever's passed through. * If nonzero, will override the background drawing section. -*/ + */ void set_background_draw_function(void *func) { gBackgroundDrawFunc.ptr = func; } @@ -679,8 +689,9 @@ void set_background_draw_function(void *func) { * Renders one or more textures directly on screen resulting from the passed image properties. * Texture rectangle coordinates use 10.2 precision and texture coords use 10.5 precision. * Typically, you do these shifts in the draw call itself, but Rare decided to do it beforehand. -*/ -void render_textured_rectangle(Gfx **dList, DrawTexture *element, s32 xPos, s32 yPos, u8 red, u8 green, u8 blue, u8 alpha) { + */ +void render_textured_rectangle(Gfx **dList, DrawTexture *element, s32 xPos, s32 yPos, u8 red, u8 green, u8 blue, + u8 alpha) { TextureHeader *tex; s32 i; s32 uly; @@ -691,7 +702,7 @@ void render_textured_rectangle(Gfx **dList, DrawTexture *element, s32 xPos, s32 s32 s; gSPDisplayList((*dList)++, dTextureRectangleModes); - gDPSetPrimColor((*dList)++, 0, 0, red, green, blue, alpha); + gDPSetPrimColor((*dList)++, 0, 0, red, green, blue, alpha); xPos <<= 2; yPos <<= 2; for (i = 0; (tex = element[i].texture); i++) { @@ -718,20 +729,21 @@ void render_textured_rectangle(Gfx **dList, DrawTexture *element, s32 xPos, s32 gDPSetPrimColor((*dList)++, 0, 0, 255, 255, 255, 255); } -void render_texture_rectangle_scaled(Gfx **dlist, DrawTexture *element, f32 xPos, f32 yPos, f32 xScale, f32 yScale, u32 colour, s32 flags) { +void render_texture_rectangle_scaled(Gfx **dlist, DrawTexture *element, f32 xPos, f32 yPos, f32 xScale, f32 yScale, + u32 colour, s32 flags) { TextureHeader *tex; Gfx *dmaDlist; s32 i; s32 bFlipX; s32 bFlipY; - s32 s; //the texture coordinate s of upper-left corner of rectangle (s10.5) - s32 t; //the texture coordinate t of upper-left corner of rectangle (s10.5) - s32 dsdx;//the change in s for each change in x (s5.10) - s32 dtdy;//the change in t for each change in y (s5.10) - s32 ulx; //the y-coordinate of upper-left corner of rectangle (10.2, 0.0~1023.75) - s32 uly; //the y-coordinate of upper-left corner of rectangle (10.2, 0.0~1023.75) - s32 lrx; //the x-coordinate of lower-right corner of rectangle (10.2, 0.0~1023.75) - s32 lry; //the y-coordinate of lower-right corner of rectangle (10.2, 0.0~1023.75) + s32 s; // the texture coordinate s of upper-left corner of rectangle (s10.5) + s32 t; // the texture coordinate t of upper-left corner of rectangle (s10.5) + s32 dsdx; // the change in s for each change in x (s5.10) + s32 dtdy; // the change in t for each change in y (s5.10) + s32 ulx; // the y-coordinate of upper-left corner of rectangle (10.2, 0.0~1023.75) + s32 uly; // the y-coordinate of upper-left corner of rectangle (10.2, 0.0~1023.75) + s32 lrx; // the x-coordinate of lower-right corner of rectangle (10.2, 0.0~1023.75) + s32 lry; // the y-coordinate of lower-right corner of rectangle (10.2, 0.0~1023.75) s32 xPos4x; s32 yPos4x; s32 width; @@ -741,11 +753,11 @@ void render_texture_rectangle_scaled(Gfx **dlist, DrawTexture *element, f32 xPos width = GET_VIDEO_WIDTH(height) * 4; height = (GET_VIDEO_HEIGHT(height) & 0xFFFF) * 4; - //If the colour is fully opaque + // If the colour is fully opaque if ((colour & 0xFF) == 0xFF) { - dmaDlist = dTextureRectangleScaledOpa[(u8)flags & 0xFF]; + dmaDlist = dTextureRectangleScaledOpa[(u8) flags & 0xFF]; } else { - dmaDlist = dTextureRectangleScaledXlu[(u8)flags & 0xFF]; + dmaDlist = dTextureRectangleScaledXlu[(u8) flags & 0xFF]; } gSPDisplayList((*dlist)++, dScaledRectangleBaseModes); diff --git a/src/rcp.h b/src/rcp.h index 8249320b..b9109e0d 100644 --- a/src/rcp.h +++ b/src/rcp.h @@ -63,19 +63,20 @@ extern s8 rspF3DDKRFifoStart[]; extern s8 rspF3DDKRDataFifoStart[]; s32 wait_for_gfx_task(void); -void func_80077AAC(void *bufPtr, s32 arg1, UNUSED s32 arg2); -void set_background_prim_colour(u8 arg0, u8 arg1, u8 arg2); +void func_80077AAC(void *bufPtr, s32 bufSize, UNUSED s32 arg2); +void set_background_prim_colour(u8 red, u8 green, u8 blue); void set_background_fill_colour(s32 red, s32 green, s32 blue); -void init_rdp_and_framebuffer(Gfx **dlist); -void init_rsp(Gfx **dlist); +void init_rdp_and_framebuffer(Gfx **dList); +void init_rsp(Gfx **dList); void setup_gfx_mesg_queues(OSSched *sc); void func_80078170(TextureHeader *arg0, TextureHeader *arg1, u32 arg2); s32 setup_ostask_xbus(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg); void setup_ostask_fifo(Gfx* dlBegin, Gfx* dlEnd, s32 recvMesg); -void render_textured_rectangle(Gfx **dlist, DrawTexture *img, s32 xPos, s32 yPos, u8 red, u8 green, u8 blue, u8 alpha); +void render_textured_rectangle(Gfx **dList, DrawTexture *element, s32 xPos, s32 yPos, u8 red, u8 green, u8 blue, + u8 alpha); void render_chequer_background(Gfx** dList); -void render_background(Gfx **dlist, Matrix *mtx, s32 drawBG); -void set_background_draw_function(void *arg0); +void render_background(Gfx **dList, Matrix *mtx, s32 drawBG); +void set_background_draw_function(void *func); void render_texture_rectangle_scaled(Gfx **dlist, DrawTexture *element, f32 xPos, f32 yPos, f32 xScale, f32 yScale, u32 colour, s32 flags); //Non Matching diff --git a/src/save_data.c b/src/save_data.c index 87436b27..94fdfc18 100644 --- a/src/save_data.c +++ b/src/save_data.c @@ -19,7 +19,8 @@ s8 *D_800DE440 = 0; u8 gN64FontCodes[] = "\0 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#'*+,-./:=?@"; -u8 sControllerPaksPresent = 0; // Bits 0, 1, 2, and 3 of the bit pattern correspond to Controllers 1, 2, 3, and 4. 1 if a controller pak is present +u8 sControllerPaksPresent = 0; // Bits 0, 1, 2, and 3 of the bit pattern correspond to Controllers 1, 2, 3, and 4. + // 1 if a controller pak is present s32 D_800DE48C = 0; /*******************************/ @@ -81,31 +82,32 @@ typedef struct unk_801241B8 { } unk_801241B8; unk_801241B8 D_801241B8[MAXCONTROLLERS]; -s16 *sUnkMiscAsset19; //Misc Asset 19 +s16 *sUnkMiscAsset19; // Misc Asset 19 /** * Values for Misc Asset 19 - * 00 2D 00 12 + * 00 2D 00 12 * 00 46 00 0A - * 00 3C 00 3C - * 00 64 00 0F - * 00 3C 00 36 - * 00 32 00 0F - * 00 32 00 34 - * 00 46 00 3C - * 00 55 00 3C - * 00 46 00 16 - * 00 50 00 4B - * 00 64 00 0C - * 00 3C 00 18 - * 00 50 00 1E - * 00 64 00 2A - * 00 32 00 3C - * 00 28 00 0A - * 00 28 00 0A + * 00 3C 00 3C * 00 64 00 0F -**/ + * 00 3C 00 36 + * 00 32 00 0F + * 00 32 00 34 + * 00 46 00 3C + * 00 55 00 3C + * 00 46 00 16 + * 00 50 00 4B + * 00 64 00 0C + * 00 3C 00 18 + * 00 50 00 1E + * 00 64 00 2A + * 00 32 00 3C + * 00 28 00 0A + * 00 28 00 0A + * 00 64 00 0F + **/ u8 D_801241E4; -u8 sRumblePaksPresent; // Bits 0, 1, 2, and 3 of the bit pattern correspond to Controllers 1, 2, 3, and 4. 1 if a rumble pak is present +u8 sRumblePaksPresent; // Bits 0, 1, 2, and 3 of the bit pattern correspond to Controllers 1, 2, 3, and 4. + // 1 if a rumble pak is present u8 D_801241E6; u8 D_801241E7; s32 gRumbleDetectionTimer; @@ -252,7 +254,8 @@ void rumble_controllers(s32 updateRate) { if (D_800DE48C != 0) { osPfsIsPlug(sControllerMesgQueue, &pfsBitPattern); } - for (i = 0, controllerToCheck = 1, temp = D_801241B8; i < MAXCONTROLLERS; i++, controllerToCheck <<= 1, temp++) { + for (i = 0, controllerToCheck = 1, temp = D_801241B8; i < MAXCONTROLLERS; + i++, controllerToCheck <<= 1, temp++) { if (D_800DE48C != 0) { temp->unk0 = temp->unk6 = temp->unk4 = -1; if (!(pfsBitPattern & controllerToCheck)) { @@ -300,7 +303,7 @@ void rumble_controllers(s32 updateRate) { } temp->unk6 += temp->unk2 + 4; } - if (1) { } // fakematch + if (1) {} // fakematch } } } @@ -332,7 +335,7 @@ s32 func_80072C54(s32 arg0) { // After shifting D_801241F4 right 8 times if (D_801241F4 == 0) { D_801241F0 = *D_801241EC++; - D_801241F4 = 128; //1000 0000 in binary. + D_801241F4 = 128; // 1000 0000 in binary. } if (D_801241F0 & D_801241F4) { ret |= var_v0; @@ -352,11 +355,11 @@ void func_80072E28(s32 arg0, u32 arg1) { if (arg0 > 0) { var_v0 = 1 << (arg0 - 1); - while (arg0 != 0 ) { + while (arg0 != 0) { if (D_801241F4 == 0) { *D_801241EC++ = D_801241F0; D_801241F0 = 0; - D_801241F4 = 128; //Reset the byte counter, so we can shift 8 times before coming back here. + D_801241F4 = 128; // Reset the byte counter, so we can shift 8 times before coming back here. } if (arg1 & var_v0) { D_801241F0 |= D_801241F4; @@ -383,7 +386,10 @@ void populate_settings_from_save_data(Settings *settings, u8 *saveData) { D_801241EC = saveData; D_801241F0 = D_801241F4 = 0; var_a0 = func_80072C54(0x10) - 5; - for (i = 2; i < 40; i++) { var_a0 -= saveData[i]; } // Must be one line + // clang-format off + // Must be one line + for (i = 2; i < 40; i++) { var_a0 -= saveData[i]; } + // clang-format on if (var_a0 == 0) { for (i = 0, var_s1 = 0; i < levelCount; i++) { temp_v0 = get_map_race_type(i); @@ -440,7 +446,7 @@ void func_800732E8(Settings *settings, u8 *saveData) { func_80072E28(16, 0); for (i = 0, var_s0 = 0; i < levelCount; i++) { temp_v0 = get_map_race_type(i); - if ((temp_v0 == 0) || (temp_v0 & 0x40) || (temp_v0 == 8)) { + if ((temp_v0 == 0) || (temp_v0 & 0x40) || (temp_v0 == 8)) { courseStatus = 0; // Map visited if (settings->courseFlagsPtr[i] & RACE_VISITED) { @@ -483,8 +489,8 @@ void func_800732E8(Settings *settings, u8 *saveData) { func_80072E28(16, var_v0); } -//arg1 is eepromData, from read_eeprom_data -//arg2 seems to be a flag for either lap times or course initials? +// arg1 is eepromData, from read_eeprom_data +// arg2 seems to be a flag for either lap times or course initials? void func_80073588(Settings *settings, u8 *saveData, u8 arg2) { s16 availableVehicles; s32 levelCount; @@ -600,7 +606,7 @@ void func_800738A4(Settings *settings, u8 *saveData) { } } - if (vehicleCount) { } // Fakematch + if (vehicleCount) {} // Fakematch D_801241EC = saveData; D_801241F0 = 0; @@ -651,7 +657,7 @@ s32 get_time_data_file_size(void) { } SIDeviceStatus get_file_extension(s32 controllerIndex, s32 fileType, char *fileExt) { - #define BLANK_EXT_CHAR ' ' +#define BLANK_EXT_CHAR ' ' char *fileNames[16]; char *fileExtensions[16]; u8 fileTypes[16]; @@ -670,10 +676,11 @@ SIDeviceStatus get_file_extension(s32 controllerIndex, s32 fileType, char *fileE continue; } if (fileType == SAVE_FILE_TYPE_GAME_DATA) { - if((bcmp((u8 *) fileNames[fileNum], (char *) sDKRacingAdv1, strlen((char *) sDKRacingAdv2)) != 0)) { + if ((bcmp((u8 *) fileNames[fileNum], (char *) sDKRacingAdv1, strlen((char *) sDKRacingAdv2)) != 0)) { continue; } - } else if((bcmp((u8 *) fileNames[fileNum], (char *) sDKRacingTimes1, strlen((char *) sDKRacingTimes2)) != 0)) { + } else if ((bcmp((u8 *) fileNames[fileNum], (char *) sDKRacingTimes1, strlen((char *) sDKRacingTimes2)) != + 0)) { continue; } @@ -701,14 +708,14 @@ SIDeviceStatus get_file_extension(s32 controllerIndex, s32 fileType, char *fileE return ret; } -//Read DKRACING-ADV data into settings? +// Read DKRACING-ADV data into settings? s32 read_game_data_from_controller_pak(s32 controllerIndex, char *fileExt, Settings *settings) { s32 *alloc; s32 ret; s32 fileNumber; s32 fileSize; - //Initialize controller pak + // Initialize controller pak ret = get_si_device_status(controllerIndex); if (ret != CONTROLLER_PAK_GOOD) { start_reading_controller_data(controllerIndex); @@ -722,7 +729,7 @@ s32 read_game_data_from_controller_pak(s32 controllerIndex, char *fileExt, Setti } if (ret == CONTROLLER_PAK_GOOD) { alloc = allocate_from_main_pool_safe(fileSize, COLOUR_TAG_BLACK); - ret = read_data_from_controller_pak(controllerIndex, fileNumber, (u8 *)alloc, fileSize); + ret = read_data_from_controller_pak(controllerIndex, fileNumber, (u8 *) alloc, fileSize); if (ret == CONTROLLER_PAK_GOOD) { if (*alloc == GAMD) { @@ -730,8 +737,7 @@ s32 read_game_data_from_controller_pak(s32 controllerIndex, char *fileExt, Setti if (settings->newGame) { ret = CONTROLLER_PAK_CHANGED; } - } - else { + } else { ret = CONTROLLER_PAK_BAD_DATA; } } @@ -750,17 +756,18 @@ s32 read_game_data_from_controller_pak(s32 controllerIndex, char *fileExt, Setti s32 write_game_data_to_controller_pak(s32 controllerIndex, Settings *arg1) { UNUSED s32 pad; char *fileExt; - u8 *gameData; //Probably a struct where the first s32 is GAMD + u8 *gameData; // Probably a struct where the first s32 is GAMD s32 ret; s32 fileSize; fileSize = get_game_data_file_size(); // 256 bytes gameData = allocate_from_main_pool_safe(fileSize, COLOUR_TAG_WHITE); - *((s32 *)gameData) = GAMD; + *((s32 *) gameData) = GAMD; func_800732E8(arg1, gameData + 4); - ret = get_file_extension(controllerIndex, 3, (char *)&fileExt); + ret = get_file_extension(controllerIndex, 3, (char *) &fileExt); if (ret == CONTROLLER_PAK_GOOD) { - ret = write_controller_pak_file(controllerIndex, -1, (char *) sDKRacingAdv4, (char *) &fileExt, gameData, fileSize); + ret = write_controller_pak_file(controllerIndex, -1, (char *) sDKRacingAdv4, (char *) &fileExt, gameData, + fileSize); } free_from_memory_pool(gameData); if (ret != CONTROLLER_PAK_GOOD) { @@ -769,7 +776,7 @@ s32 write_game_data_to_controller_pak(s32 controllerIndex, Settings *arg1) { return ret; } -//Read time data from controller pak into settings +// Read time data from controller pak into settings s32 read_time_data_from_controller_pak(s32 controllerIndex, char *fileExt, Settings *settings) { s32 *cpakData; s32 status; @@ -792,10 +799,11 @@ s32 read_time_data_from_controller_pak(s32 controllerIndex, char *fileExt, Setti if (status == CONTROLLER_PAK_GOOD) { cpakData = allocate_from_main_pool_safe(fileSize, COLOUR_TAG_BLACK); - status = read_data_from_controller_pak(controllerIndex, fileNumber, (u8 *)cpakData, fileSize); + status = read_data_from_controller_pak(controllerIndex, fileNumber, (u8 *) cpakData, fileSize); if (status == CONTROLLER_PAK_GOOD) { if (*cpakData == TIMD) { - func_80073588(settings, (u8 *) (cpakData + 1), SAVE_DATA_FLAG_READ_FLAP_TIMES | SAVE_DATA_FLAG_READ_COURSE_TIMES); + func_80073588(settings, (u8 *) (cpakData + 1), + SAVE_DATA_FLAG_READ_FLAP_TIMES | SAVE_DATA_FLAG_READ_COURSE_TIMES); } else { status = CONTROLLER_PAK_BAD_DATA; } @@ -814,7 +822,7 @@ s32 read_time_data_from_controller_pak(s32 controllerIndex, char *fileExt, Setti } s32 write_time_data_to_controller_pak(s32 controllerIndex, Settings *arg1) { - u8 *timeData; //Should probably be a struct or maybe an array? + u8 *timeData; // Should probably be a struct or maybe an array? s32 ret; s32 fileSize; UNUSED s32 pad; @@ -822,11 +830,12 @@ s32 write_time_data_to_controller_pak(s32 controllerIndex, Settings *arg1) { fileSize = get_time_data_file_size(); // 512 bytes timeData = allocate_from_main_pool_safe(fileSize, COLOUR_TAG_WHITE); - *((s32 *)timeData) = TIMD; + *((s32 *) timeData) = TIMD; func_800738A4(arg1, timeData + 4); - ret = get_file_extension(controllerIndex, 4, (char *)&fileExt); + ret = get_file_extension(controllerIndex, 4, (char *) &fileExt); if (ret == CONTROLLER_PAK_GOOD) { - ret = write_controller_pak_file(controllerIndex, -1, (char *) sDKRacingTimes4, (char *) &fileExt, timeData, fileSize); + ret = write_controller_pak_file(controllerIndex, -1, (char *) sDKRacingTimes4, (char *) &fileExt, timeData, + fileSize); } free_from_memory_pool(timeData); if (ret != CONTROLLER_PAK_GOOD) { @@ -847,7 +856,7 @@ s32 read_save_file(s32 saveFileNum, Settings *settings) { if (osEepromProbe(get_si_mesg_queue()) == 0) { return -1; } - switch(saveFileNum) { + switch (saveFileNum) { case 0: startingAddress = 0; break; @@ -864,7 +873,7 @@ s32 read_save_file(s32 saveFileNum, Settings *settings) { blocks = 5; saveData = allocate_from_main_pool_safe(blocks * sizeof(u64), COLOUR_TAG_WHITE); for (block = 0, address = startingAddress; block < blocks; block++, address++) { - osEepromRead(get_si_mesg_queue(), address, (u8 *)&saveData[block]); + osEepromRead(get_si_mesg_queue(), address, (u8 *) &saveData[block]); } populate_settings_from_save_data(settings, (u8 *) saveData); free_from_memory_pool(saveData); @@ -899,7 +908,7 @@ void erase_save_file(s32 saveFileNum, Settings *settings) { settings->tajFlags = 0; settings->cutsceneFlags = 0; settings->newGame = TRUE; - switch(saveFileNum) { + switch (saveFileNum) { case 0: startingAddress = 0; break; @@ -915,12 +924,16 @@ void erase_save_file(s32 saveFileNum, Settings *settings) { } blockSize = 5; alloc = allocate_from_main_pool_safe(blockSize * sizeof(u64), COLOUR_TAG_WHITE); - saveData = (u8 *)alloc; + saveData = (u8 *) alloc; + + // clang-format off // Blank out the data before writing it. - for (i = 0; i < blockSize * (s32)sizeof(u64); i++) { saveData[i] = 0xFF; } // Must be one line + for (i = 0; i < blockSize * (s32) sizeof(u64); i++) { saveData[i] = 0xFF; } // Must be one line + // clang-format on + if (!is_reset_pressed()) { for (i = 0, address = startingAddress; i < blockSize; i++, address++) { - osEepromWrite(get_si_mesg_queue(), address, (u8 *)&alloc[i]); + osEepromWrite(get_si_mesg_queue(), address, (u8 *) &alloc[i]); } } free_from_memory_pool(alloc); @@ -945,7 +958,7 @@ s32 write_save_data(s32 saveFileNum, Settings *settings) { return -1; } - switch(saveFileNum) { + switch (saveFileNum) { case 0: startingAddress = 0; break; @@ -962,11 +975,11 @@ s32 write_save_data(s32 saveFileNum, Settings *settings) { blocks = 5; alloc = allocate_from_main_pool_safe(blocks * sizeof(u64), COLOUR_TAG_WHITE); - func_800732E8(settings, (u8 *)alloc); + func_800732E8(settings, (u8 *) alloc); if (!is_reset_pressed()) { for (i = 0, address = startingAddress; i < blocks; i++, address++) { - osEepromWrite(get_si_mesg_queue(), address, (u8 *)&alloc[i]); + osEepromWrite(get_si_mesg_queue(), address, (u8 *) &alloc[i]); } } @@ -995,7 +1008,7 @@ s32 read_eeprom_data(Settings *settings, u8 flags) { if (flags & SAVE_DATA_FLAG_READ_FLAP_TIMES) { s32 blocks = 24; for (i = 0; i < blocks; i++) { - osEepromRead(get_si_mesg_queue(), i + 0x10, (u8 *)&alloc[i]); + osEepromRead(get_si_mesg_queue(), i + 0x10, (u8 *) &alloc[i]); } func_80073588(settings, (u8 *) alloc, SAVE_DATA_FLAG_READ_FLAP_TIMES); } @@ -1003,7 +1016,7 @@ s32 read_eeprom_data(Settings *settings, u8 flags) { if (flags & SAVE_DATA_FLAG_READ_COURSE_TIMES) { s32 blocks = 24; for (i = 0; i < blocks; i++) { - osEepromRead(get_si_mesg_queue(), i + 0x28, (u8 *)(&alloc[24] + i)); + osEepromRead(get_si_mesg_queue(), i + 0x28, (u8 *) (&alloc[24] + i)); } func_80073588(settings, (u8 *) alloc, SAVE_DATA_FLAG_READ_COURSE_TIMES); } @@ -1030,14 +1043,14 @@ s32 write_eeprom_data(Settings *settings, u8 flags) { alloc = allocate_from_main_pool_safe(0x200, COLOUR_TAG_WHITE); - func_800738A4(settings, (u8 *)alloc); + func_800738A4(settings, (u8 *) alloc); if (flags & SAVE_DATA_FLAG_READ_FLAP_TIMES) { s32 size = 24; - if (1){} //Fake Match + if (1) {} // Fake Match if (!is_reset_pressed()) { for (i = 0; i != size; i++) { - osEepromWrite(get_si_mesg_queue(), i + 16, (u8 *)&alloc[i]); + osEepromWrite(get_si_mesg_queue(), i + 16, (u8 *) &alloc[i]); } } } @@ -1046,7 +1059,7 @@ s32 write_eeprom_data(Settings *settings, u8 flags) { s32 size = 24; if (!is_reset_pressed()) { for (i = 0; i != size; i++) { - osEepromWrite(get_si_mesg_queue(), i + 40, (u8 *)(&alloc[24] + i)); + osEepromWrite(get_si_mesg_queue(), i + 40, (u8 *) (&alloc[24] + i)); } } } @@ -1065,7 +1078,7 @@ s32 calculate_eeprom_settings_checksum(u64 eepromSettings) { ret = 5; for (i = 0; i <= 13; i++) { - ret += (u16)(eepromSettings >> (i << 2)) & 0xF; + ret += (u16) (eepromSettings >> (i << 2)) & 0xF; } return ret; } @@ -1085,14 +1098,14 @@ s32 read_eeprom_settings(u64 *eepromSettings) { osEepromRead(get_si_mesg_queue(), 0xF, (u8 *) eepromSettings); sp20 = calculate_eeprom_settings_checksum(*eepromSettings); - temp = *eepromSettings >> 56; + temp = *eepromSettings >> 56; if (sp20 != temp) { - //bit 24 = Unknown - //bit 25 = Seems to be a flag for whether subtitles are enabled or not. - *eepromSettings = 0x3000000; //Sets bits 24 and 25 high + // bit 24 = Unknown + // bit 25 = Seems to be a flag for whether subtitles are enabled or not. + *eepromSettings = 0x3000000; // Sets bits 24 and 25 high *eepromSettings <<= 8; *eepromSettings >>= 8; - *eepromSettings |= (u64)calculate_eeprom_settings_checksum(*eepromSettings) << 56; + *eepromSettings |= (u64) calculate_eeprom_settings_checksum(*eepromSettings) << 56; } return 1; @@ -1109,7 +1122,7 @@ s32 write_eeprom_settings(u64 *eepromSettings) { } *eepromSettings <<= 8; *eepromSettings >>= 8; - *eepromSettings |= (s64)(calculate_eeprom_settings_checksum(*eepromSettings)) << 56; + *eepromSettings |= (s64) (calculate_eeprom_settings_checksum(*eepromSettings)) << 56; if (is_reset_pressed() == 0) { osEepromWrite(get_si_mesg_queue(), 0xF, (u8 *) eepromSettings); } @@ -1122,9 +1135,9 @@ s16 calculate_ghost_header_checksum(GhostHeader *ghostHeader) { s16 sum; sum = 0; - len = (s16)(ghostHeader->nodeCount * sizeof(GhostDataFrame)) + sizeof(GhostHeader); + len = (s16) (ghostHeader->nodeCount * sizeof(GhostDataFrame)) + sizeof(GhostHeader); for (i = 2; i < len; i++) { - sum += ((u8 *)ghostHeader)[i]; + sum += ((u8 *) ghostHeader)[i]; } return sum; } @@ -1135,11 +1148,11 @@ void func_80074AA8(GhostHeader *ghostHeader, s16 characterID, s16 time, s16 node ghostHeader->unk3 = 0; ghostHeader->time = time; ghostHeader->nodeCount = nodeCount; - bcopy(dest, (u8 *)ghostHeader + 8, nodeCount * sizeof(GhostDataFrame)); + bcopy(dest, (u8 *) ghostHeader + 8, nodeCount * sizeof(GhostDataFrame)); ghostHeader->checksum = calculate_ghost_header_checksum(ghostHeader); } -//Seems to only be called when used as an argument for func_800860A8. Effectively just returns 0x6700 +// Seems to only be called when used as an argument for func_800860A8. Effectively just returns 0x6700 s32 get_ghost_data_file_size(void) { int x = 0x1100; return (&x)[0] * 6 + 0x100; @@ -1159,9 +1172,10 @@ typedef struct unkGhostData { u8 unkB; u8 unkC; } unkGhostData; -s32 func_80074B34(s32 controllerIndex, s16 levelId, s16 vehicleId, u16 *ghostCharacterId, s16 *ghostTime, s16 *ghostNodeCount, GhostHeader *ghostData) { - #define GHSS_FILE_SIZE 0x100 - static OSPfs *pfs; //Maybe static? +s32 func_80074B34(s32 controllerIndex, s16 levelId, s16 vehicleId, u16 *ghostCharacterId, s16 *ghostTime, + s16 *ghostNodeCount, GhostHeader *ghostData) { +#define GHSS_FILE_SIZE 0x100 + static OSPfs *pfs; // Maybe static? s32 i; u8 *cPakFile; s32 bytesFree; @@ -1187,14 +1201,14 @@ s32 func_80074B34(s32 controllerIndex, s16 levelId, s16 vehicleId, u16 *ghostCha ret = get_file_number(controllerIndex, (char *) sDKRacingGhosts, (char *) sDKRacingGhostFileExt, &fileNumber); if (ret == CONTROLLER_PAK_GOOD) { cPakFile = allocate_from_main_pool_safe(GHSS_FILE_SIZE, COLOUR_TAG_BLACK); - pfs = &pfs[controllerIndex]; //This should be uninintialized? + pfs = &pfs[controllerIndex]; // This should be uninintialized? if (!(pfs->status & PFS_INITIALIZED)) { osPfsInit(sControllerMesgQueue, &pfs, controllerIndex); } ret = read_data_from_controller_pak(controllerIndex, fileNumber, cPakFile, GHSS_FILE_SIZE); if (ret == CONTROLLER_PAK_GOOD) { - //The first 4 bytes of any data from the controller pak will have initials declaring it's type. - if (*((s32 *)cPakFile) == GHSS) { + // The first 4 bytes of any data from the controller pak will have initials declaring it's type. + if (*((s32 *) cPakFile) == GHSS) { fileData = (GhostHeader *) (cPakFile + 4); for (i = 0; i < 5; i++) { if (levelId == fileData[i].unk0.levelID && vehicleId == fileData[i].unk0.vehicleID) { @@ -1260,8 +1274,7 @@ s32 func_80074B34(s32 controllerIndex, s16 levelId, s16 vehicleId, u16 *ghostCha if (bytesFree < get_ghost_data_file_size() || notesFree == 0) { return CONTROLLER_PAK_FULL; } - } - else { + } else { return CONTROLLER_PAK_BAD_DATA; } } @@ -1272,22 +1285,22 @@ GLOBAL_ASM("asm/non_matchings/save_data/func_80074B34.s") #endif typedef struct GhostHeaderAltUnk0 { - u8 levelID; - u8 vehicleID; // 0 = Car, 1 = Hovercraft, 2 = Plane + u8 levelID; + u8 vehicleID; // 0 = Car, 1 = Hovercraft, 2 = Plane } GhostHeaderAltUnk0; /* Size: 4 bytes */ typedef struct GhostHeaderAlt { union { - GhostHeaderAltUnk0 unk0; - s16 checksum; + GhostHeaderAltUnk0 unk0; + s16 checksum; }; union { - struct { - u8 characterID; // 9 = T.T. - u8 unk3; - }; - s16 unk2; + struct { + u8 characterID; // 9 = T.T. + u8 unk3; + }; + s16 unk2; }; } GhostHeaderAlt; @@ -1308,8 +1321,8 @@ typedef struct GhostDataData { typedef struct GhostData { /* 0x00 */ s32 headerId; union { - /* 0x04 */ GhostHeader *ghostHeader; - /* 0x04 */ GhostDataData *ghostData; + /* 0x04 */ GhostHeader *ghostHeader; + /* 0x04 */ GhostDataData *ghostData; }; /* 0x08 */ u8 unk8_pad[0x14]; /* 0x1C */ u8 unk1C; @@ -1317,9 +1330,10 @@ typedef struct GhostData { } GhostData; #ifdef NON_EQUIVALENT -//This is just a mess until we can figure out the ghost data structs properly. -SIDeviceStatus func_80074EB8(s32 controllerIndex, s16 arg1, s16 arg2, s16 ghostCharacterId, s16 ghostTime, s16 ghostNodeCount, u8 *dest) { - #define GHSS_FILE_SIZE 0x100 +// This is just a mess until we can figure out the ghost data structs properly. +SIDeviceStatus func_80074EB8(s32 controllerIndex, s16 arg1, s16 arg2, s16 ghostCharacterId, s16 ghostTime, + s16 ghostNodeCount, u8 *dest) { +#define GHSS_FILE_SIZE 0x100 SIDeviceStatus ret; s32 fileSize; u8 *temp_v0_3; @@ -1330,13 +1344,13 @@ SIDeviceStatus func_80074EB8(s32 controllerIndex, s16 arg1, s16 arg2, s16 ghostC fileSize = 0x1100 * 6; temp_v0_3 = allocate_from_main_pool_safe(fileSize + 0x200, COLOUR_TAG_BLACK); - *((s32 *)temp_v0_3) = GHSS; + *((s32 *) temp_v0_3) = GHSS; ghost = (GhostHeader *) (temp_v0_3 + 4); - //temp_v0_3->unk0 = GHSS; + // temp_v0_3->unk0 = GHSS; ghost->unk0.levelID = arg1; ghost->nodeCount = 0x100; temp_v1 = ghost + 4; - //ghost->unkA = (s16) (ghost->nodeCount + 0x1100); + // ghost->unkA = (s16) (ghost->nodeCount + 0x1100); ghost->unk5 = arg2; temp_v0_4 = temp_v1 + 4; temp_v0_4->unk0 = 0xFF; @@ -1353,7 +1367,8 @@ SIDeviceStatus func_80074EB8(s32 controllerIndex, s16 arg1, s16 arg2, s16 ghostC // temp_v0_5->unkA = (s16) temp_v1->time; // temp_v0_5->unkE = (s16) temp_v1->time; func_80074AA8((GhostHeader *) &ghost[temp_v1->unk2], ghostCharacterId, ghostTime, ghostNodeCount, dest); - ret = write_controller_pak_file(controllerIndex, -1, "DKRACING-GHOSTS", "", (u8 *) ghost, fileSize + GHSS_FILE_SIZE); + ret = + write_controller_pak_file(controllerIndex, -1, "DKRACING-GHOSTS", "", (u8 *) ghost, fileSize + GHSS_FILE_SIZE); free_from_memory_pool(ghost); return ret; } @@ -1362,7 +1377,8 @@ GLOBAL_ASM("asm/non_matchings/save_data/func_80074EB8.s") #endif #ifdef NON_EQUIVALENT -SIDeviceStatus func_80075000(s32 controllerIndex, s16 levelId, s16 vehicleId, s16 ghostCharacterId, s16 ghostTime, s16 ghostNodeCount, GhostHeader *ghostData) { +SIDeviceStatus func_80075000(s32 controllerIndex, s16 levelId, s16 vehicleId, s16 ghostCharacterId, s16 ghostTime, + s16 ghostNodeCount, GhostHeader *ghostData) { GhostHeaderAlt *sp70; s32 sp58; s32 fileSize; @@ -1383,7 +1399,8 @@ SIDeviceStatus func_80075000(s32 controllerIndex, s16 levelId, s16 vehicleId, s1 ret = get_file_number(controllerIndex, "DKRACING-GHOSTS", "", &fileNumber); if (ret == CONTROLLER_PAK_CHANGED) { start_reading_controller_data(controllerIndex); - return func_80074EB8(controllerIndex, levelId, vehicleId, ghostCharacterId, ghostTime, ghostNodeCount, &ghostData->unk0.levelID); + return func_80074EB8(controllerIndex, levelId, vehicleId, ghostCharacterId, ghostTime, ghostNodeCount, + &ghostData->unk0.levelID); } if (ret != CONTROLLER_PAK_GOOD) { start_reading_controller_data(controllerIndex); @@ -1406,13 +1423,15 @@ SIDeviceStatus func_80075000(s32 controllerIndex, s16 levelId, s16 vehicleId, s1 ghostFileDataAlt = (GhostHeaderAlt *) &fileData->ghostHeader; for (i = 0, ghostIndex = -1; i < 6; i++) { - if (levelId == ghostFileDataAlt[i].unk0.levelID && vehicleId == ghostFileDataAlt[i].unk0.vehicleID) { + if (levelId == ghostFileDataAlt[i].unk0.levelID && + vehicleId == ghostFileDataAlt[i].unk0.vehicleID) { ghostIndex = i; break; } } - if ((ghostIndex != -1) && (fileData[ghostFileDataAlt[ghostIndex].unk2].ghostHeader->time < ghostTime)) { + if ((ghostIndex != -1) && + (fileData[ghostFileDataAlt[ghostIndex].unk2].ghostHeader->time < ghostTime)) { ghostIndex = -2; } @@ -1444,12 +1463,15 @@ SIDeviceStatus func_80075000(s32 controllerIndex, s16 levelId, s16 vehicleId, s1 } else { sp70[i].unk2 = (ghostFileData[i].unk2 + sp58); } - bcopy(&fileData[ghostFileData[i].unk2], &fileDataToWrite[sp70[i].unk2], ghostFileData[i].nodeCount - ghostFileData[i].unk2); + bcopy(&fileData[ghostFileData[i].unk2], &fileDataToWrite[sp70[i].unk2], + ghostFileData[i].nodeCount - ghostFileData[i].unk2); } - func_80074AA8((GhostHeader *) &fileDataToWrite[sp70[ghostIndex].unk2], ghostCharacterId, ghostTime, ghostNodeCount, &ghostData->unk0.levelID); + func_80074AA8((GhostHeader *) &fileDataToWrite[sp70[ghostIndex].unk2], ghostCharacterId, + ghostTime, ghostNodeCount, &ghostData->unk0.levelID); sp70[ghostIndex].unk0.levelID = levelId; sp70[ghostIndex].unk0.vehicleID = vehicleId; - ret = write_controller_pak_file(controllerIndex, fileNumber, "DKRACING-GHOSTS", "", fileDataToWrite, fileSize); + ret = write_controller_pak_file(controllerIndex, fileNumber, "DKRACING-GHOSTS", "", + fileDataToWrite, fileSize); free_from_memory_pool(fileDataToWrite); } } @@ -1463,10 +1485,8 @@ SIDeviceStatus func_80075000(s32 controllerIndex, s16 levelId, s16 vehicleId, s1 GLOBAL_ASM("asm/non_matchings/save_data/func_80075000.s") #endif - - #ifdef NON_EQUIVALENT -//I give up. Ghost data structs have be beat for now. +// I give up. Ghost data structs have be beat for now. s32 func_800753D8(s32 controllerIndex, s32 arg1) { GhostData *dataToWrite; @@ -1509,16 +1529,16 @@ s32 func_800753D8(s32 controllerIndex, s32 arg1) { start_reading_controller_data(controllerIndex); return ret; } - fileData = (GhostData *)allocate_from_main_pool_safe(fileLength + 0x100, COLOUR_TAG_BLACK); - ret = read_data_from_controller_pak(controllerIndex, fileNumber, (u8 *)fileData, fileLength); + fileData = (GhostData *) allocate_from_main_pool_safe(fileLength + 0x100, COLOUR_TAG_BLACK); + ret = read_data_from_controller_pak(controllerIndex, fileNumber, (u8 *) fileData, fileLength); start_reading_controller_data(controllerIndex); if (ret == CONTROLLER_PAK_GOOD) { ret = CONTROLLER_PAK_BAD_DATA; if (fileData->headerId == GHSS) { temp_t8 = arg1 * 4; - temp_v0_5 = (GhostDataData *)&fileData[temp_t8]; + temp_v0_5 = (GhostDataData *) &fileData[temp_t8]; temp_a3 = temp_v0_5->unk6 - temp_v0_5->unkA; - temp_v0_6 = (GhostData *)allocate_from_main_pool_safe(fileLength + 0x100, COLOUR_TAG_BLACK); + temp_v0_6 = (GhostData *) allocate_from_main_pool_safe(fileLength + 0x100, COLOUR_TAG_BLACK); temp_v1 = fileData->ghostHeader; dataToWrite = temp_v0_6; temp_t1 = &temp_v1[temp_t8]; @@ -1526,7 +1546,8 @@ s32 func_800753D8(s32 controllerIndex, s32 arg1) { sp28 = temp_v1; bcopy(fileData, temp_v0_6, temp_t1->unk2); if (arg1 != 5) { - bcopy(&fileData[temp_t1->unk6], &(&dataToWrite[temp_t1->unk6])[temp_a3], fileData->ghostData->unk1A - temp_t1->unk6); + bcopy(&fileData[temp_t1->unk6], &(&dataToWrite[temp_t1->unk6])[temp_a3], + fileData->ghostData->unk1A - temp_t1->unk6); } var_v0 = &dataToWrite[arg1].ghostData; for (var_v1_4 = arg1; var_v1_4 < 6; var_v1_4++) { @@ -1535,7 +1556,8 @@ s32 func_800753D8(s32 controllerIndex, s32 arg1) { var_v0[var_v1_4].unk1A = var_v0[var_v1_4].unk5; } dataToWrite->ghostData->unk1A = dataToWrite->ghostData->unk16; - ret = write_controller_pak_file(controllerIndex, fileNumber, "DKRACING-GHOSTS", "", (u8 *) dataToWrite, fileLength); + ret = write_controller_pak_file(controllerIndex, fileNumber, "DKRACING-GHOSTS", "", (u8 *) dataToWrite, + fileLength); } free_from_memory_pool(dataToWrite); } @@ -1576,17 +1598,18 @@ SIDeviceStatus func_800756D4(s32 controllerIndex, u8 *arg1, u8 *arg2, u8 *arg3, ret = get_file_size(controllerIndex, fileNumber, &fileSize); if (ret == CONTROLLER_PAK_GOOD) { fileData = allocate_from_main_pool_safe(fileSize + 0x100, COLOUR_TAG_BLACK); - ret = read_data_from_controller_pak(controllerIndex, fileNumber, (u8 *)fileData, fileSize); + ret = read_data_from_controller_pak(controllerIndex, fileNumber, (u8 *) fileData, fileSize); if (ret == CONTROLLER_PAK_GOOD) { for (i = 0, var_s1 = (GhostHeaderAlt *) (&fileData[4]); i < 6; i++) { if (var_s1[i].unk0.levelID != 0xFF) { - if (calculate_ghost_header_checksum((GhostHeader *) &fileData[var_s1[i].unk2]) != ((GhostHeaderAlt*)&fileData[var_s1[i].unk2])->checksum) { + if (calculate_ghost_header_checksum((GhostHeader *) &fileData[var_s1[i].unk2]) != + ((GhostHeaderAlt *) &fileData[var_s1[i].unk2])->checksum) { ret = CONTROLLER_PAK_BAD_DATA; break; } else { arg1[i] = var_s1[i].unk0.levelID; arg2[i] = var_s1[i].unk0.vehicleID; - arg3[i] = fileData[var_s1[i].unk2+2]; + arg3[i] = fileData[var_s1[i].unk2 + 2]; arg4[i] = ((GhostHeaderAlt *) &fileData[var_s1[i].unk2] + 1)->checksum; } } @@ -1607,12 +1630,12 @@ SIDeviceStatus get_si_device_status(s32 controllerIndex) { s32 i; if (sControllerMesgQueue->validCount == 0) { - if (osMotorInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex) == 0) { + if (osMotorInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex) == 0) { return CONTROLLER_PAK_RUMBLE_PAK_FOUND; } } - //Couldn't get a for loop to match this + // Couldn't get a for loop to match this i = 0; while (sControllerMesgQueue->validCount != 0 && i < 10) { osRecvMesg(sControllerMesgQueue, &unusedMsg, OS_MESG_NOBLOCK); @@ -1620,18 +1643,18 @@ SIDeviceStatus get_si_device_status(s32 controllerIndex) { } for (i = 0; i <= 4; i++) { - ret = osPfsFreeBlocks( &pfs[controllerIndex], &bytes_not_used); + ret = osPfsFreeBlocks(&pfs[controllerIndex], &bytes_not_used); if (ret == PFS_ERR_INVALID) { - ret = osPfsInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex); + ret = osPfsInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex); } if (ret == PFS_ERR_ID_FATAL) { - if (osMotorInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex) == 0) { + if (osMotorInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex) == 0) { return CONTROLLER_PAK_RUMBLE_PAK_FOUND; } } if (ret == PFS_ERR_NEW_PACK) { - if ((osPfsInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex) == PFS_ERR_ID_FATAL) - && (osMotorInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex) == 0)) { + if ((osPfsInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex) == PFS_ERR_ID_FATAL) && + (osMotorInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex) == 0)) { return CONTROLLER_PAK_RUMBLE_PAK_FOUND; } return CONTROLLER_PAK_CHANGED; @@ -1670,38 +1693,38 @@ void init_controller_paks(void) { s8 maxControllers; sControllerMesgQueue = get_si_mesg_queue(); - sUnkMiscAsset19 = (s16 *)get_misc_asset(ASSET_MISC_19); + sUnkMiscAsset19 = (s16 *) get_misc_asset(ASSET_MISC_19); D_801241E6 = D_801241E7 = 0xF; D_801241E4 = TRUE; gRumbleDetectionTimer = 0; D_800DE48C = 1; sControllerPaksPresent = sRumblePaksPresent = 0; - //pakPattern will set the first 4 bits representing each controller - //and it will be 1 if there's something attached. + // pakPattern will set the first 4 bits representing each controller + // and it will be 1 if there's something attached. osPfsIsPlug(sControllerMesgQueue, &pakPattern); - for (controllerIndex = 0, controllerBit = 1, maxControllers = MAXCONTROLLERS; (0, controllerIndex) != maxControllers; controllerIndex++, controllerBit <<= 1) { + for (controllerIndex = 0, controllerBit = 1, maxControllers = MAXCONTROLLERS; + (0, controllerIndex) != maxControllers; controllerIndex++, controllerBit <<= 1) { D_801241B8[controllerIndex].unk2 = 0; D_801241B8[controllerIndex].unk4 = -1; D_801241B8[controllerIndex].unk0 = -1; D_801241B8[controllerIndex].unk6 = D_801241B8[controllerIndex].unk2; - //If something is plugged into the controller + // If something is plugged into the controller if (pakPattern & controllerBit) { ret = osPfsInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex); if (ret == PFS_ERR_NEW_PACK) { ret = osPfsInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex); } if (ret == 0) { - //If we found a controller pak, set the bit that has one + // If we found a controller pak, set the bit that has one sControllerPaksPresent |= controllerBit; - } - else if (ret == PFS_ERR_ID_FATAL) { - if (controllerIndex) { } // Fakematch + } else if (ret == PFS_ERR_ID_FATAL) { + if (controllerIndex) {} // Fakematch ret = osMotorInit(sControllerMesgQueue, &pfs[controllerIndex], controllerIndex); if (ret == 0) { - //If we found a rumble pak, set the bit that has one + // If we found a rumble pak, set the bit that has one sRumblePaksPresent |= controllerBit; } } @@ -1725,7 +1748,7 @@ UNUSED SIDeviceStatus check_for_rumble_pak(s32 controllerIndex) { return ret; } -//Inspects and repairs the Controller Pak's file system +// Inspects and repairs the Controller Pak's file system /* Official name: packRepair */ SIDeviceStatus repair_controller_pak(s32 controllerIndex) { s32 ret; @@ -1746,12 +1769,13 @@ SIDeviceStatus repair_controller_pak(s32 controllerIndex) { return ret; } -//Reformat Controller Pak +// Reformat Controller Pak /* Official name: packFormat */ SIDeviceStatus reformat_controller_pak(s32 controllerIndex) { s32 ret; s32 status = get_si_device_status(controllerIndex); - if (status == CONTROLLER_PAK_GOOD || status == CONTROLLER_PAK_INCONSISTENT || status == CONTROLLER_PAK_WITH_BAD_ID) { + if (status == CONTROLLER_PAK_GOOD || status == CONTROLLER_PAK_INCONSISTENT || + status == CONTROLLER_PAK_WITH_BAD_ID) { status = osPfsReFormat(&pfs[controllerIndex], sControllerMesgQueue, controllerIndex); if (status == 0) { ret = CONTROLLER_PAK_GOOD; @@ -1768,7 +1792,8 @@ SIDeviceStatus reformat_controller_pak(s32 controllerIndex) { } /* Official Name: packDirectory */ -s32 get_controller_pak_file_list(s32 controllerIndex, s32 maxNumOfFilesToGet, char **fileNames, char **fileExtensions, u32 *fileSizes, u8 *fileTypes) { +s32 get_controller_pak_file_list(s32 controllerIndex, s32 maxNumOfFilesToGet, char **fileNames, char **fileExtensions, + u32 *fileSizes, u8 *fileTypes) { OSPfsState state; s32 ret; s32 maxNumOfFilesOnCpak; @@ -1795,21 +1820,21 @@ s32 get_controller_pak_file_list(s32 controllerIndex, s32 maxNumOfFilesToGet, ch } else { gameCode = NTSC_GAME_CODE; } - + if (maxNumOfFilesToGet < maxNumOfFilesOnCpak) { maxNumOfFilesOnCpak = maxNumOfFilesToGet; } - + if (D_800DE440 != NULL) { free_from_memory_pool(D_800DE440); } - + files_used = maxNumOfFilesOnCpak * 24; D_800DE440 = allocate_from_main_pool_safe(files_used, COLOUR_TAG_BLACK); bzero(D_800DE440, files_used); temp_D_800DE440 = D_800DE440; - - //TODO: There's probably an unidentified struct here + + // TODO: There's probably an unidentified struct here for (i = 0; i < maxNumOfFilesOnCpak; i++) { fileNames[i] = (char *) temp_D_800DE440; temp_D_800DE440 += 0x12; @@ -1818,7 +1843,7 @@ s32 get_controller_pak_file_list(s32 controllerIndex, s32 maxNumOfFilesToGet, ch fileTypes[i] = SAVE_FILE_TYPE_UNSET; temp_D_800DE440 += 6; } - + while (i < maxNumOfFilesToGet) { fileExtensions[i] = 0; fileNames[i] = 0; @@ -1826,34 +1851,34 @@ s32 get_controller_pak_file_list(s32 controllerIndex, s32 maxNumOfFilesToGet, ch fileTypes[i] = SAVE_FILE_TYPE_UNSET; i++; } - + for (i = 0; i < maxNumOfFilesOnCpak; i++) { ret = osPfsFileState(&pfs[controllerIndex], i, &state); if (ret == PFS_ERR_INVALID) { fileNames[i] = 0; continue; } - + if (ret != 0) { start_reading_controller_data(controllerIndex); return CONTROLLER_PAK_BAD_DATA; } - - font_codes_to_string((char *)&state.game_name, (char *)fileNames[i], PFS_FILE_NAME_LEN); - font_codes_to_string((char *)&state.ext_name, (char *)fileExtensions[i], PFS_FILE_EXT_LEN); + + font_codes_to_string((char *) &state.game_name, (char *) fileNames[i], PFS_FILE_NAME_LEN); + font_codes_to_string((char *) &state.ext_name, (char *) fileExtensions[i], PFS_FILE_EXT_LEN); fileSizes[i] = state.file_size; fileTypes[i] = SAVE_FILE_TYPE_UNKNOWN; - + if ((state.game_code == gameCode) && (state.company_code == COMPANY_CODE)) { fileTypes[i] = get_file_type(controllerIndex, i); } } - + start_reading_controller_data(controllerIndex); return CONTROLLER_PAK_GOOD; } -//Free D_800DE440 +// Free D_800DE440 void packDirectoryFree(void) { if (D_800DE440 != 0) { free_from_memory_pool(D_800DE440); @@ -1861,8 +1886,8 @@ void packDirectoryFree(void) { D_800DE440 = 0; } -//Get Available Space in Controller Pak -//Upper bytes of return value could be controllerIndex +// Get Available Space in Controller Pak +// Upper bytes of return value could be controllerIndex /* Official Name: packFreeSpace */ s32 get_free_space(s32 controllerIndex, u32 *bytesFree, s32 *notesFree) { s32 ret; @@ -1913,7 +1938,8 @@ s32 delete_file(s32 controllerIndex, s32 fileNum) { ret = (controllerIndex << 30) | CONTROLLER_PAK_BAD_DATA; if (osPfsFileState(&pfs[controllerIndex], fileNum, &state) == 0) { - if (osPfsDeleteFile(&pfs[controllerIndex], state.company_code, state.game_code, (u8 *)&state.game_name, (u8 *)&state.ext_name) == 0) { + if (osPfsDeleteFile(&pfs[controllerIndex], state.company_code, state.game_code, (u8 *) &state.game_name, + (u8 *) &state.ext_name) == 0) { ret = CONTROLLER_PAK_GOOD; } } @@ -1991,8 +2017,8 @@ SIDeviceStatus get_file_number(s32 controllerIndex, char *fileName, char *fileEx gameCode = NTSC_GAME_CODE; } - - ret = osPfsFindFile(&pfs[controllerIndex], COMPANY_CODE, gameCode, (u8 *)fileNameAsFontCodes, (u8 *)fileExtAsFontCodes, fileNumber); + ret = osPfsFindFile(&pfs[controllerIndex], COMPANY_CODE, gameCode, (u8 *) fileNameAsFontCodes, + (u8 *) fileExtAsFontCodes, fileNumber); if (ret == 0) { return CONTROLLER_PAK_GOOD; } @@ -2008,7 +2034,7 @@ SIDeviceStatus get_file_number(s32 controllerIndex, char *fileName, char *fileEx if (ret == PFS_ERR_INVALID) { return CONTROLLER_PAK_CHANGED; } - + return CONTROLLER_PAK_BAD_DATA; } @@ -2035,9 +2061,10 @@ SIDeviceStatus read_data_from_controller_pak(s32 controllerIndex, s32 fileNum, u return CONTROLLER_PAK_BAD_DATA; } -//If fileNumber -1, it creates a new file? +// If fileNumber -1, it creates a new file? /* Official name: packWriteFile */ -SIDeviceStatus write_controller_pak_file(s32 controllerIndex, s32 fileNumber, char *fileName, char *fileExt, u8 *dataToWrite, s32 fileSize) { +SIDeviceStatus write_controller_pak_file(s32 controllerIndex, s32 fileNumber, char *fileName, char *fileExt, + u8 *dataToWrite, s32 fileSize) { s32 temp; u8 fileNameAsFontCodes[PFS_FILE_NAME_LEN]; UNUSED s32 temp2; @@ -2059,8 +2086,8 @@ SIDeviceStatus write_controller_pak_file(s32 controllerIndex, s32 fileNumber, ch bytesToSave = (fileSize - temp) + 0x100; } - string_to_font_codes(fileName, (char *)fileNameAsFontCodes, PFS_FILE_NAME_LEN); - string_to_font_codes(fileExt, (char *)fileExtAsFontCodes, PFS_FILE_EXT_LEN); + string_to_font_codes(fileName, (char *) fileNameAsFontCodes, PFS_FILE_NAME_LEN); + string_to_font_codes(fileExt, (char *) fileExtAsFontCodes, PFS_FILE_EXT_LEN); if (get_language() == LANGUAGE_JAPANESE) { game_code = JPN_GAME_CODE; @@ -2079,7 +2106,8 @@ SIDeviceStatus write_controller_pak_file(s32 controllerIndex, s32 fileNumber, ch if (fileNumber != -1) { ret = CONTROLLER_PAK_BAD_DATA; } else { - temp = osPfsAllocateFile(&pfs[controllerIndex], COMPANY_CODE, game_code, fileNameAsFontCodes, fileExtAsFontCodes, bytesToSave, &file_number); + temp = osPfsAllocateFile(&pfs[controllerIndex], COMPANY_CODE, game_code, fileNameAsFontCodes, + fileExtAsFontCodes, bytesToSave, &file_number); if (temp == 0) { ret = CONTROLLER_PAK_GOOD; } else if (temp == PFS_DATA_FULL || temp == PFS_DIR_FULL) { @@ -2100,8 +2128,7 @@ SIDeviceStatus write_controller_pak_file(s32 controllerIndex, s32 fileNumber, ch ret = CONTROLLER_PAK_INCONSISTENT; } else if (temp == PFS_ERR_ID_FATAL) { ret = CONTROLLER_PAK_WITH_BAD_ID; - } - else { + } else { ret = CONTROLLER_PAK_BAD_DATA; } } @@ -2110,7 +2137,7 @@ SIDeviceStatus write_controller_pak_file(s32 controllerIndex, s32 fileNumber, ch return ret; } -//Get File size for given controller's Control Pak +// Get File size for given controller's Control Pak /* Official name: packFileSize */ SIDeviceStatus get_file_size(s32 controllerIndex, s32 fileNum, s32 *fileSize) { OSPfsState state; @@ -2123,7 +2150,7 @@ SIDeviceStatus get_file_size(s32 controllerIndex, s32 fileNum, s32 *fileSize) { return CONTROLLER_PAK_BAD_DATA; } -//Converts N64 Font codes used in controller pak file names, into C ASCII a coded string +// Converts N64 Font codes used in controller pak file names, into C ASCII a coded string char *font_codes_to_string(char *inString, char *outString, s32 stringLength) { s32 index = *inString; char *ret = outString; @@ -2135,7 +2162,7 @@ char *font_codes_to_string(char *inString, char *outString, s32 stringLength) { *outString = gN64FontCodes[index]; outString++; } else { - //Replace invalid characters with a hyphen + // Replace invalid characters with a hyphen *outString = '-'; outString++; } @@ -2145,18 +2172,18 @@ char *font_codes_to_string(char *inString, char *outString, s32 stringLength) { index = *inString; } - //Pad any extra characters with NULL font code + // Pad any extra characters with NULL font code while (stringLength != 0) { *outString = 0; stringLength--; outString++; } - + *outString = 0; return ret; } -//Converts a C ASCII string into N64 Font codes for controller pak file names +// Converts a C ASCII string into N64 Font codes for controller pak file names char *string_to_font_codes(char *inString, char *outString, s32 stringLength) { s32 i; char currentChar; @@ -2182,7 +2209,7 @@ char *string_to_font_codes(char *inString, char *outString, s32 stringLength) { stringLength--; outString++; } - + *outString = 0; return ret; } diff --git a/src/save_data.h b/src/save_data.h index c7dfa30d..38cce2d1 100644 --- a/src/save_data.h +++ b/src/save_data.h @@ -64,7 +64,7 @@ size_t strlen(const char *str); u8 func_80072250(s32 arg0); void func_80072298(u8 arg0); -s32 func_800722E8(s16 arg0); +s32 func_800722E8(s16 controllerIndex); void func_80072708(void); s32 get_game_data_file_size(void); s32 get_time_data_file_size(void); @@ -119,7 +119,8 @@ char *string_to_font_codes(char *inString, char *outString, s32 stringLength); //Reasonably certain about these names for now. SIDeviceStatus func_80074EB8(s32 controllerIndex, s16 arg1, s16 arg2, s16 ghostCharacterId, s16 ghostTime, s16 ghostNodeCount, u8 *dest); -SIDeviceStatus func_80075000(s32 controllerIndex, s16 arg1, s16 arg2, s16 ghostCharacterId, s16 ghostTime, s16 ghostNodeCount, GhostHeader *arg6); +SIDeviceStatus func_80075000(s32 controllerIndex, s16 levelId, s16 vehicleId, s16 ghostCharacterId, s16 ghostTime, + s16 ghostNodeCount, GhostHeader *ghostData); s32 func_800753D8(s32 controllerIndex, s32 arg1); #endif diff --git a/src/screen_asset.c b/src/screen_asset.c index 6531725b..ad83aa9c 100644 --- a/src/screen_asset.c +++ b/src/screen_asset.c @@ -33,7 +33,7 @@ UNUSED u32 load_screen(s32 screenIndex) { // since there are no screen assets in the ROM. if (screenTableCount == 0) { free_from_memory_pool(screenTable); - return (u32)OS_PHYSICAL_TO_K0(0x100000); + return (u32) OS_PHYSICAL_TO_K0(0x100000); } else { if (screenIndex < 0 || screenIndex >= screenTableCount) { rmonPrintf("SCREEN: No out of range!!\n"); @@ -42,7 +42,7 @@ UNUSED u32 load_screen(s32 screenIndex) { start = screenTable[screenIndex]; size = screenTable[screenIndex + 1] - start; - someAddr = (u32)allocate_from_main_pool_safe(size, COLOUR_TAG_BLUE); + someAddr = (u32) allocate_from_main_pool_safe(size, COLOUR_TAG_BLUE); load_asset_to_address(ASSET_SCREENS, someAddr, start, size); free_from_memory_pool(screenTable); @@ -58,7 +58,8 @@ UNUSED u32 load_screen(s32 screenIndex) { UNUSED void render_screen(Gfx **dlist, u8 *screenAddress) { s32 y_pos; - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(&gRdpSetModeScreenAsset), numberOfGfxCommands(gRdpSetModeScreenAsset)); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(&gRdpSetModeScreenAsset), + numberOfGfxCommands(gRdpSetModeScreenAsset)); // Screen header is 16 bytes. screenAddress += 16; @@ -67,12 +68,12 @@ UNUSED void render_screen(Gfx **dlist, u8 *screenAddress) { y_pos = 0; while (y_pos != SCREEN_HEIGHT) { // Load the texture. - gDPLoadTextureBlockS((*dlist)++, OS_PHYSICAL_TO_K0(screenAddress), G_IM_FMT_RGBA, G_IM_SIZ_16b, - SCREEN_WIDTH, SCREEN_HEIGHT_PART, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); + gDPLoadTextureBlockS((*dlist)++, OS_PHYSICAL_TO_K0(screenAddress), G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, + SCREEN_HEIGHT_PART, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); // Draw the texture. - gSPTextureRectangle((*dlist)++, 0, (y_pos << 2), SCREEN_WIDTH << 2, - ((y_pos + SCREEN_HEIGHT_PART) << 2), G_TX_RENDERTILE, 0, 0, 1 << 12, 1 << 10); + gSPTextureRectangle((*dlist)++, 0, (y_pos << 2), SCREEN_WIDTH << 2, ((y_pos + SCREEN_HEIGHT_PART) << 2), + G_TX_RENDERTILE, 0, 0, 1 << 12, 1 << 10); // Advance to the next slice. screenAddress += SCREEN_WIDTH * SCREEN_HEIGHT_PART * 2; diff --git a/src/textures_sprites.c b/src/textures_sprites.c index 721d2f4c..7b9be3d5 100644 --- a/src/textures_sprites.c +++ b/src/textures_sprites.c @@ -21,106 +21,139 @@ s32 gSpriteOpaque = TRUE; Gfx dRenderSettingsVtxAlpha[][2] = { // Semitransparent Vertex Alpha'd surface (Zsorted) - DRAW_TABLE_GROUP(G_CC_MODULATEIA, DKR_CC_UNK0, DKR_OMH_2CYC_BILERP, - DKR_RM_UNKNOWN0, G_RM_XLU_SURF2, DKR_RM_UNKNOWN0, G_RM_AA_XLU_SURF2, DKR_RM_UNKNOWN0, G_RM_ZB_XLU_SURF2, DKR_RM_UNKNOWN0, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIA, DKR_CC_UNK0, DKR_OMH_2CYC_BILERP, DKR_RM_UNKNOWN0, G_RM_XLU_SURF2, + DKR_RM_UNKNOWN0, G_RM_AA_XLU_SURF2, DKR_RM_UNKNOWN0, G_RM_ZB_XLU_SURF2, DKR_RM_UNKNOWN0, + G_RM_AA_ZB_XLU_SURF2), // Semitransparent Vertex Alpha'd surface (No Zsort) - DRAW_TABLE_GROUP(G_CC_MODULATEIA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, - DKR_RM_UNKNOWN1, G_RM_XLU_SURF2, DKR_RM_UNKNOWN1, G_RM_AA_XLU_SURF2, DKR_RM_UNKNOWN1, G_RM_ZB_XLU_SURF2, DKR_RM_UNKNOWN1, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, DKR_RM_UNKNOWN1, G_RM_XLU_SURF2, + DKR_RM_UNKNOWN1, G_RM_AA_XLU_SURF2, DKR_RM_UNKNOWN1, G_RM_ZB_XLU_SURF2, DKR_RM_UNKNOWN1, + G_RM_AA_ZB_XLU_SURF2), }; Gfx dRenderSettingsSpriteCld[][2] = { // Semitransparent Sprite (Preserve coverage) DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, G_RM_CLD_SURF, G_RM_CLD_SURF2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2) + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, G_RM_ZB_CLD_SURF, + G_RM_ZB_CLD_SURF2) }; // Should probably be merged with dRenderSettingsSpriteCld Gfx dRenderSettingsSpriteXlu[][2] = { // Semitransparent Sprite (Overwrite coverage) DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, G_RM_XLU_SURF, G_RM_XLU_SURF2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, DKR_RM_UNKNOWN2_1, DKR_RM_UNKNOWN2_2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, DKR_RM_UNKNOWN3_1, DKR_RM_UNKNOWN3_2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, G_RM_AA_ZB_XLU_INTER, G_RM_AA_ZB_XLU_INTER2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, DKR_RM_UNKNOWN2_1, + DKR_RM_UNKNOWN2_2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, DKR_RM_UNKNOWN3_1, + DKR_RM_UNKNOWN3_2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, G_RM_AA_ZB_XLU_INTER, + G_RM_AA_ZB_XLU_INTER2), // Semitransparent Sprite (Overwrite coverage) (Copy) DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, G_RM_XLU_SURF, G_RM_XLU_SURF2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, DKR_RM_UNKNOWN2_1, DKR_RM_UNKNOWN2_2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, DKR_RM_UNKNOWN3_1, DKR_RM_UNKNOWN3_2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, G_RM_AA_ZB_XLU_INTER, G_RM_AA_ZB_XLU_INTER2) + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, DKR_RM_UNKNOWN2_1, + DKR_RM_UNKNOWN2_2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, DKR_RM_UNKNOWN3_1, + DKR_RM_UNKNOWN3_2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_POINT, G_RM_AA_ZB_XLU_INTER, + G_RM_AA_ZB_XLU_INTER2) }; Gfx dRenderSettingsCommon[][2] = { // Opaque Surface - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, - G_RM_OPA_SURF, G_RM_OPA_SURF2, G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2, G_RM_ZB_OPA_SURF, G_RM_ZB_OPA_SURF2, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, G_RM_OPA_SURF, G_RM_OPA_SURF2, + G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2, G_RM_ZB_OPA_SURF, G_RM_ZB_OPA_SURF2, G_RM_AA_ZB_OPA_SURF, + G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, - G_RM_XLU_SURF, G_RM_XLU_SURF2, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, G_RM_XLU_SURF, G_RM_XLU_SURF2, + G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2, G_RM_AA_ZB_XLU_SURF, + G_RM_AA_ZB_XLU_SURF2), // Opaque Surface with fog - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, - G_RM_FOG_SHADE_A, G_RM_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_OPA_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface with fog - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_ZB_XLU_SURF2), // Cutout Surface with primitive colour - DRAW_TABLE_GROUP(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP, - G_RM_XLU_SURF, G_RM_XLU_SURF2, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2, G_RM_AA_ZB_XLU_INTER, G_RM_AA_ZB_XLU_INTER2), + DRAW_TABLE_GROUP(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP, G_RM_XLU_SURF, G_RM_XLU_SURF2, + G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2, + G_RM_AA_ZB_XLU_INTER, G_RM_AA_ZB_XLU_INTER2), // Cutout Surface with primitive colour (Copy) - DRAW_TABLE_GROUP(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP, - G_RM_XLU_SURF, G_RM_XLU_SURF2, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2, G_RM_AA_ZB_XLU_INTER, G_RM_AA_ZB_XLU_INTER2), + DRAW_TABLE_GROUP(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP, G_RM_XLU_SURF, G_RM_XLU_SURF2, + G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2, + G_RM_AA_ZB_XLU_INTER, G_RM_AA_ZB_XLU_INTER2), // Cutout Surface with primitive colour and fog - DRAW_TABLE_GROUP(G_CC_MODULATEIA_PRIM, DKR_CC_UNK2, DKR_OMH_2CYC_BILERP, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2), + DRAW_TABLE_GROUP(G_CC_MODULATEIA_PRIM, DKR_CC_UNK2, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, + G_RM_AA_ZB_XLU_INTER2), // Cutout Surface with primitive colour and fog (Zsorted interpenetrating) - DRAW_TABLE_GROUP(G_CC_MODULATEIA_PRIM, DKR_CC_UNK2, DKR_OMH_2CYC_BILERP, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2 | Z_UPD, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2), + DRAW_TABLE_GROUP(G_CC_MODULATEIA_PRIM, DKR_CC_UNK2, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2 | Z_UPD, + G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2), // Opaque Surface with indexed texture - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, - G_RM_OPA_SURF, G_RM_OPA_SURF2, G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2, G_RM_ZB_OPA_SURF, G_RM_ZB_OPA_SURF2, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_OPA_SURF, G_RM_OPA_SURF2, + G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2, G_RM_ZB_OPA_SURF, G_RM_ZB_OPA_SURF2, G_RM_AA_ZB_OPA_SURF, + G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface with indexed texture - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, - G_RM_XLU_SURF, G_RM_XLU_SURF2, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_XLU_SURF, G_RM_XLU_SURF2, + G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2, G_RM_AA_ZB_XLU_SURF, + G_RM_AA_ZB_XLU_SURF2), // Opqaue Surface with indexed texture and fog - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_PASS2, DKR_OMH_2CYC_CI_BILERP, - G_RM_FOG_SHADE_A, G_RM_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_PASS2, DKR_OMH_2CYC_CI_BILERP, G_RM_FOG_SHADE_A, G_RM_OPA_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface with indexed texture and fog - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_PASS2, DKR_OMH_2CYC_CI_BILERP, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_PASS2, DKR_OMH_2CYC_CI_BILERP, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_ZB_XLU_SURF2), // Opaque Surface with indexed texture. (Cutout) - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, - G_RM_OPA_SURF, G_RM_OPA_SURF2, G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2, G_RM_ZB_OPA_SURF, G_RM_ZB_OPA_SURF2, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_OPA_SURF, G_RM_OPA_SURF2, + G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2, G_RM_ZB_OPA_SURF, G_RM_ZB_OPA_SURF2, G_RM_AA_ZB_OPA_SURF, + G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface with indexed texture (Cutout) - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, - G_RM_XLU_SURF, G_RM_XLU_SURF2, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2, G_RM_AA_ZB_XLU_INTER, G_RM_AA_ZB_XLU_INTER2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_XLU_SURF, G_RM_XLU_SURF2, + G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2, + G_RM_AA_ZB_XLU_INTER, G_RM_AA_ZB_XLU_INTER2), // Opqaue Surface with indexed texture and fog (Cutout) - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_PASS2, DKR_OMH_2CYC_CI_BILERP, - G_RM_FOG_SHADE_A, G_RM_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_PASS2, DKR_OMH_2CYC_CI_BILERP, G_RM_FOG_SHADE_A, G_RM_OPA_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface with indexed texture and fog (Cutout) - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_PASS2, DKR_OMH_2CYC_CI_BILERP, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_INTER2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_PASS2, DKR_OMH_2CYC_CI_BILERP, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, + G_RM_AA_ZB_XLU_INTER2), }; Gfx dRenderSettingsCutout[][2] = { // Semitransparent Surface - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP, - G_RM_XLU_SURF, G_RM_XLU_SURF2, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2, DKR_RM_UNKNOWN4_1, DKR_RM_UNKNOWN4_2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP, G_RM_XLU_SURF, G_RM_XLU_SURF2, + G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2, DKR_RM_UNKNOWN4_1, + DKR_RM_UNKNOWN4_2), // Semitransparent Surface (Copy) - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP, - G_RM_XLU_SURF, G_RM_XLU_SURF2, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2, DKR_RM_UNKNOWN4_1, DKR_RM_UNKNOWN4_2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, G_CC_MODULATEIA_PRIM, DKR_OMH_1CYC_BILERP, G_RM_XLU_SURF, G_RM_XLU_SURF2, + G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2, DKR_RM_UNKNOWN4_1, + DKR_RM_UNKNOWN4_2), // Semitransparent Surface with fog - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, DKR_RM_UNKNOWN4_2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, + DKR_RM_UNKNOWN4_2), // Semitransparent Surface with fog (Copy) - DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, DKR_RM_UNKNOWN4_2), + DRAW_TABLE_GROUP(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, + DKR_RM_UNKNOWN4_2), }; Gfx dRenderSettingsDecal[][2] = { // Opaque Decal. - DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, G_RM_ZB_OPA_DECAL, G_RM_ZB_OPA_DECAL2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, G_RM_AA_ZB_OPA_DECAL, G_RM_AA_ZB_OPA_DECAL2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, G_RM_ZB_OPA_DECAL, + G_RM_ZB_OPA_DECAL2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, G_RM_AA_ZB_OPA_DECAL, + G_RM_AA_ZB_OPA_DECAL2), // Semitransparent Decal. - DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, G_RM_ZB_XLU_DECAL, G_RM_ZB_XLU_DECAL2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, G_RM_AA_ZB_XLU_DECAL, G_RM_AA_ZB_XLU_DECAL2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, G_RM_ZB_XLU_DECAL, + G_RM_ZB_XLU_DECAL2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_BILERP, G_RM_AA_ZB_XLU_DECAL, + G_RM_AA_ZB_XLU_DECAL2), // Opaque Decal with fog. DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_DECAL2), DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_DECAL2), @@ -128,11 +161,15 @@ Gfx dRenderSettingsDecal[][2] = { DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_DECAL2), DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, DKR_CC_UNK1, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_DECAL2), // Opaque Decal with indexed texture. - DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_ZB_OPA_DECAL, G_RM_ZB_OPA_DECAL2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_AA_ZB_OPA_DECAL, G_RM_AA_ZB_OPA_DECAL2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_ZB_OPA_DECAL, + G_RM_ZB_OPA_DECAL2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_AA_ZB_OPA_DECAL, + G_RM_AA_ZB_OPA_DECAL2), // Semitransparent Decal with indexed texture. - DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_ZB_XLU_DECAL, G_RM_ZB_XLU_DECAL2), - DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_AA_ZB_XLU_DECAL, G_RM_AA_ZB_XLU_DECAL2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_ZB_XLU_DECAL, + G_RM_ZB_XLU_DECAL2), + DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_MODULATEIDECALA, DKR_OMH_1CYC_CI_BILERP, G_RM_AA_ZB_XLU_DECAL, + G_RM_AA_ZB_XLU_DECAL2), // Opaque Decal with indexed texture and fog. DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_PASS2, DKR_OMH_2CYC_CI_BILERP, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_DECAL2), DRAW_TABLE_ENTRY(G_CC_MODULATEIDECALA, G_CC_PASS2, DKR_OMH_2CYC_CI_BILERP, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_DECAL2), @@ -142,82 +179,93 @@ Gfx dRenderSettingsDecal[][2] = { }; Gfx dRenderSettingsSolidColourVtxAlpha[][2] = { - DRAW_TABLE_GROUP(DKR_CC_UNK3, G_CC_MODULATEIA_PRIM2, DKR_OMH_2CYC_POINT, - G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_ZB_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK3, G_CC_MODULATEIA_PRIM2, DKR_OMH_2CYC_POINT, G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, + G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_ZB_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_XLU_SURF2), }; Gfx dRenderSettingsSolidColour[][2] = { // Opaque Surface - DRAW_TABLE_GROUP(DKR_CC_UNK4, DKR_CC_UNK4, DKR_OMH_1CYC_POINT, - G_RM_OPA_SURF, G_RM_OPA_SURF2, G_RM_AA_OPA_SURF, G_RM_AA_OPA_SURF2, G_RM_ZB_OPA_SURF, G_RM_ZB_OPA_SURF2, G_RM_AA_ZB_OPA_INTER, G_RM_AA_ZB_OPA_INTER2), + DRAW_TABLE_GROUP(DKR_CC_UNK4, DKR_CC_UNK4, DKR_OMH_1CYC_POINT, G_RM_OPA_SURF, G_RM_OPA_SURF2, G_RM_AA_OPA_SURF, + G_RM_AA_OPA_SURF2, G_RM_ZB_OPA_SURF, G_RM_ZB_OPA_SURF2, G_RM_AA_ZB_OPA_INTER, + G_RM_AA_ZB_OPA_INTER2), // Semitransparent Surface - DRAW_TABLE_GROUP(DKR_CC_UNK4, DKR_CC_UNK4, DKR_OMH_1CYC_POINT, - G_RM_XLU_SURF, G_RM_XLU_SURF2, G_RM_AA_XLU_SURF, G_RM_AA_XLU_SURF2, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK4, DKR_CC_UNK4, DKR_OMH_1CYC_POINT, G_RM_XLU_SURF, G_RM_XLU_SURF2, G_RM_AA_XLU_SURF, + G_RM_AA_XLU_SURF2, G_RM_ZB_XLU_SURF, G_RM_ZB_XLU_SURF2, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2), // Opaque Surface with fog - DRAW_TABLE_GROUP(DKR_CC_UNK4, G_CC_MODULATEIA_PRIM2, DKR_OMH_2CYC_POINT, - G_RM_FOG_SHADE_A, G_RM_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK4, G_CC_MODULATEIA_PRIM2, DKR_OMH_2CYC_POINT, G_RM_FOG_SHADE_A, G_RM_OPA_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface - DRAW_TABLE_GROUP(DKR_CC_UNK4, G_CC_MODULATEIA_PRIM2, DKR_OMH_2CYC_POINT, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK4, G_CC_MODULATEIA_PRIM2, DKR_OMH_2CYC_POINT, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, + G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_ZB_XLU_SURF2), }; // Some kind of texture on top of a solid colour Gfx dRenderSettingsPrimOverlay[][2] = { // Opaque Surface - DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_BILERP, G_RM_ZB_OPA_DECAL, G_RM_ZB_OPA_DECAL2), - DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_BILERP, G_RM_AA_ZB_OPA_DECAL, G_RM_AA_ZB_OPA_DECAL2), + DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_BILERP, G_RM_ZB_OPA_DECAL, + G_RM_ZB_OPA_DECAL2), + DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_BILERP, G_RM_AA_ZB_OPA_DECAL, + G_RM_AA_ZB_OPA_DECAL2), // Semitransparent Surface - DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_BILERP, G_RM_ZB_XLU_DECAL, G_RM_ZB_XLU_DECAL2), - DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_BILERP, G_RM_AA_ZB_XLU_DECAL, G_RM_AA_ZB_XLU_DECAL2), + DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_BILERP, G_RM_ZB_XLU_DECAL, + G_RM_ZB_XLU_DECAL2), + DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_BILERP, G_RM_AA_ZB_XLU_DECAL, + G_RM_AA_ZB_XLU_DECAL2), // Opaque Surface with indexed texture - DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_CI_BILERP, G_RM_ZB_OPA_DECAL, G_RM_ZB_OPA_DECAL2), - DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_CI_BILERP, G_RM_AA_ZB_OPA_DECAL, G_RM_AA_ZB_OPA_DECAL2), + DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_CI_BILERP, G_RM_ZB_OPA_DECAL, + G_RM_ZB_OPA_DECAL2), + DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_CI_BILERP, G_RM_AA_ZB_OPA_DECAL, + G_RM_AA_ZB_OPA_DECAL2), // Semitransparent Surface with indexed texture - DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_CI_BILERP, G_RM_ZB_XLU_DECAL, G_RM_ZB_XLU_DECAL2), - DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_CI_BILERP, G_RM_AA_ZB_XLU_DECAL, G_RM_AA_ZB_XLU_DECAL2) + DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_CI_BILERP, G_RM_ZB_XLU_DECAL, + G_RM_ZB_XLU_DECAL2), + DRAW_TABLE_ENTRY(DKR_CC_DECALFADEPRIM, DKR_CC_DECALFADEPRIM, DKR_OMH_1CYC_CI_BILERP, G_RM_AA_ZB_XLU_DECAL, + G_RM_AA_ZB_XLU_DECAL2) }; // Not sure what it is specifically, but some onscreen actors like TT and Taj use it. Gfx dRenderSettingsPrimCol[][2] = { // Opaque Surface - DRAW_TABLE_GROUP(DKR_CC_UNK5, DKR_CC_UNK6, DKR_OMH_2CYC_BILERP, - G_RM_NOOP, G_RM_OPA_SURF2, G_RM_NOOP, G_RM_AA_OPA_SURF2, G_RM_NOOP, G_RM_ZB_OPA_SURF2, G_RM_NOOP, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK5, DKR_CC_UNK6, DKR_OMH_2CYC_BILERP, G_RM_NOOP, G_RM_OPA_SURF2, G_RM_NOOP, + G_RM_AA_OPA_SURF2, G_RM_NOOP, G_RM_ZB_OPA_SURF2, G_RM_NOOP, G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface - DRAW_TABLE_GROUP(DKR_CC_UNK5, DKR_CC_UNK6, DKR_OMH_2CYC_BILERP, - G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_ZB_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK5, DKR_CC_UNK6, DKR_OMH_2CYC_BILERP, G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, + G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_ZB_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_XLU_SURF2), // Opaque Surface with indexed texture - DRAW_TABLE_GROUP(DKR_CC_UNK5, DKR_CC_UNK6, DKR_OMH_2CYC_CI_BILERP, - G_RM_NOOP, G_RM_OPA_SURF2, G_RM_NOOP, G_RM_AA_OPA_SURF2, G_RM_NOOP, G_RM_ZB_OPA_SURF2, G_RM_NOOP, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK5, DKR_CC_UNK6, DKR_OMH_2CYC_CI_BILERP, G_RM_NOOP, G_RM_OPA_SURF2, G_RM_NOOP, + G_RM_AA_OPA_SURF2, G_RM_NOOP, G_RM_ZB_OPA_SURF2, G_RM_NOOP, G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface with indexed texture - DRAW_TABLE_GROUP(DKR_CC_UNK5, DKR_CC_UNK6, DKR_OMH_2CYC_CI_BILERP, - G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_TEX_EDGE2, G_RM_NOOP, G_RM_AA_ZB_XLU_INTER2), + DRAW_TABLE_GROUP(DKR_CC_UNK5, DKR_CC_UNK6, DKR_OMH_2CYC_CI_BILERP, G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, + G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_TEX_EDGE2, G_RM_NOOP, G_RM_AA_ZB_XLU_INTER2), }; Gfx dRenderSettingsBlinkingLights[][2] = { // Opaque Surface - DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, - G_RM_NOOP, G_RM_OPA_SURF2, G_RM_NOOP, G_RM_AA_OPA_SURF2, G_RM_NOOP, G_RM_ZB_OPA_SURF2, G_RM_NOOP, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, G_RM_NOOP, G_RM_OPA_SURF2, G_RM_NOOP, + G_RM_AA_OPA_SURF2, G_RM_NOOP, G_RM_ZB_OPA_SURF2, G_RM_NOOP, G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface - DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, - G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_ZB_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, + G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_ZB_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_XLU_SURF2), // Opaque Surface with fog - DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, - G_RM_FOG_SHADE_A, G_RM_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_OPA_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_OPA_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), // Semitransparent Surface with fog - DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2), + DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_ZB_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2), // Cutout Surface - DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, - G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_TEX_EDGE2, G_RM_NOOP, DKR_RM_UNKNOWN4_2), + DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, + G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_TEX_EDGE2, G_RM_NOOP, DKR_RM_UNKNOWN4_2), // Cutout Surface (Copy) - DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, - G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_TEX_EDGE2, G_RM_NOOP, DKR_RM_UNKNOWN4_2), + DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, G_RM_NOOP, G_RM_XLU_SURF2, G_RM_NOOP, + G_RM_AA_XLU_SURF2, G_RM_NOOP, G_RM_AA_ZB_TEX_EDGE2, G_RM_NOOP, DKR_RM_UNKNOWN4_2), // Cutout Surface with fog - DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, DKR_RM_UNKNOWN4_2), + DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, DKR_RM_UNKNOWN4_2), // Cutout Surface with fog (Copy) - DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, - G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, DKR_RM_UNKNOWN4_2), + DRAW_TABLE_GROUP(DKR_CC_UNK7, DKR_CC_UNK8, DKR_OMH_2CYC_BILERP, G_RM_FOG_SHADE_A, G_RM_XLU_SURF2, G_RM_FOG_SHADE_A, + G_RM_AA_XLU_SURF2, G_RM_FOG_SHADE_A, G_RM_AA_ZB_TEX_EDGE2, G_RM_FOG_SHADE_A, DKR_RM_UNKNOWN4_2), }; Gfx D_800DF3A8[] = { @@ -298,7 +346,7 @@ s16 gUsePrimColour; /** * Load the texture table from ROM and allocate space for all the texture asset management. -*/ + */ void tex_init_textures(void) { s32 i; @@ -307,14 +355,14 @@ void tex_init_textures(void) { gNumberOfLoadedTextures = 0; gCiPalettesSize = 0; gTextureAssetTable[TEX_TABLE_2D] = (s32 *) load_asset_section_from_rom(ASSET_TEXTURES_2D_TABLE); - gTextureAssetTable[TEX_TABLE_3D] = (s32 *) load_asset_section_from_rom(ASSET_TEXTURES_3D_TABLE); - - for (i = 0; gTextureAssetTable[TEX_TABLE_2D][i] != -1; i++) { } + gTextureAssetTable[TEX_TABLE_3D] = (s32 *) load_asset_section_from_rom(ASSET_TEXTURES_3D_TABLE); + + for (i = 0; gTextureAssetTable[TEX_TABLE_2D][i] != -1; i++) {} gTextureAssetID[TEX_TABLE_2D] = --i; - - for (i = 0; gTextureAssetTable[TEX_TABLE_3D][i] != -1; i++) { } + + for (i = 0; gTextureAssetTable[TEX_TABLE_3D][i] != -1; i++) {} gTextureAssetID[TEX_TABLE_3D] = --i; - + gSpriteCache = allocate_from_main_pool_safe(sizeof(Sprite) * TEX_SPRITE_COUNT, COLOUR_TAG_MAGENTA); gCurrentSprite = allocate_from_main_pool_safe(sizeof(Sprite) * 32, COLOUR_TAG_MAGENTA); D_80126358 = 0; @@ -332,7 +380,7 @@ void tex_init_textures(void) { /** * Official Name: texDisableModes * Add flags to the block list so they are removed when drawn. -*/ + */ void tex_disable_modes(s32 flags) { gBlockedRenderFlags |= flags; } @@ -340,7 +388,7 @@ void tex_disable_modes(s32 flags) { /** * Official Name: texEnableModes * Remove flags to the block list so they are no longer removed when drawn. -*/ + */ void tex_enable_modes(s32 flags) { gBlockedRenderFlags &= ~flags; } @@ -348,7 +396,7 @@ void tex_enable_modes(s32 flags) { /** * Return the texture asset ID table for 2D textures. * Goes unused. -*/ + */ UNUSED s32 get_loaded_2D_textures(void) { return gTextureAssetID[TEX_TABLE_2D]; } @@ -356,7 +404,7 @@ UNUSED s32 get_loaded_2D_textures(void) { /** * Return the texture asset ID table for 3D textures. * Goes unused. -*/ + */ UNUSED s32 get_loaded_3D_textures(void) { return gTextureAssetID[TEX_TABLE_3D]; } @@ -367,7 +415,7 @@ UNUSED s32 func_8007AE64(void) { #ifdef NON_EQUIVALENT // Minor matching issues with loops, but should be functionally the same. -//Official Name: texLoadTexture +// Official Name: texLoadTexture TextureHeader *load_texture(s32 arg0) { s32 assetSection; s32 assetIndex; @@ -424,7 +472,7 @@ TextureHeader *load_texture(s32 arg0) { if (tex == NULL) { return NULL; } - temp_a1 = ((s32)tex + sp3C) - assetSize; + temp_a1 = ((s32) tex + sp3C) - assetSize; temp_a1 -= temp_a1 % 0x10; load_asset_to_address(assetSection, temp_a1, assetOffset, assetSize); gzip_inflate(temp_a1 + 0x20, tex); @@ -460,7 +508,7 @@ TextureHeader *load_texture(s32 arg0) { } D_80126344 = 0; texTemp = tex; - alignedAddress = align16((u8 *)((s32)texTemp + assetSize)); + alignedAddress = align16((u8 *) ((s32) texTemp + assetSize)); for (i = 0; i < numberOfTextures; i++) { build_tex_display_list(texTemp, alignedAddress); if (paletteOffset >= 0) { @@ -468,7 +516,7 @@ TextureHeader *load_texture(s32 arg0) { alignedAddress += 0x30; // I'm guessing it takes 6 f3d commands to load the palette } alignedAddress += 0x60; // I'm guessing it takes 12 f3d commands to load the texture - texTemp = (TextureHeader *)((s32)texTemp + texTemp->textureSize); + texTemp = (TextureHeader *) ((s32) texTemp + texTemp->textureSize); } if (gCiPalettesSize >= 0x280) { return NULL; @@ -485,14 +533,14 @@ GLOBAL_ASM("asm/non_matchings/textures_sprites/load_texture.s") /** * This function frees textures * Official Name: texFreeTexture -*/ + */ void free_texture(TextureHeader *tex) { s32 i; - - if (tex != 0) { + + if (tex != 0) { if ((--tex->numberOfInstances) <= 0) { for (i = 0; i < gNumberOfLoadedTextures; i++) { - if ((s32)tex == gTextureCache[(i << 1) + 1]) { + if ((s32) tex == gTextureCache[(i << 1) + 1]) { free_from_memory_pool(tex); gTextureCache[(i << 1)] = -1; @@ -508,7 +556,7 @@ void free_texture(TextureHeader *tex) { * Set the colour tag that determines which memory pool textures will be loaded into. * By default, this generally stays as COLOUR_TAG_MAGENTA * Official Name: setTexMemColour -*/ + */ void set_texture_colour_tag(s32 tagID) { gTexColourTag = tagID; } @@ -527,7 +575,7 @@ UNUSED s32 func_8007B380(s32 arg0) { * Resets all render settings to the default state. * The next draw call will be forced to apply all settings instead of skipping unecessary steps. * Official Name: texDPInit -*/ + */ void reset_render_settings(Gfx **dlist) { gCurrentTextureHeader = NULL; gCurrentRenderFlags = RENDER_NONE; @@ -541,7 +589,7 @@ void reset_render_settings(Gfx **dlist) { /** * Enables usage of combiners utilising the indidual primitive colours. -*/ + */ void enable_primitive_colour(void) { gUsePrimColour = TRUE; gForceFlags = TRUE; @@ -549,22 +597,22 @@ void enable_primitive_colour(void) { /** * Disables usage of combiners utilising the indidual primitive colours. -*/ + */ void disable_primitive_colour(void) { gUsePrimColour = FALSE; gForceFlags = TRUE; } /** - * Shift the texture header by the offset and return the result. + * Shift the texture header by the offset and return the result. * Official Name: texFrame -*/ + */ TextureHeader *set_animated_texture_header(TextureHeader *texHead, s32 offset) { if (offset > 0) { if (offset < texHead->numOfTextures << 8) { - texHead = (TextureHeader *) (((u8 *)texHead) + ((offset >> 16) * texHead->textureSize)); + texHead = (TextureHeader *) (((u8 *) texHead) + ((offset >> 16) * texHead->textureSize)); } else { - texHead = (TextureHeader *) (((u8 *)texHead) + ((texHead->numOfTextures >> 8) - 1) * texHead->textureSize); + texHead = (TextureHeader *) (((u8 *) texHead) + ((texHead->numOfTextures >> 8) - 1) * texHead->textureSize); } } return texHead; @@ -572,7 +620,7 @@ TextureHeader *set_animated_texture_header(TextureHeader *texHead, s32 offset) { /** * A version of the function below that chooses not to pass along an offset. -*/ + */ void load_and_set_texture_no_offset(Gfx **dlist, TextureHeader *texhead, u32 flags) { load_and_set_texture(dlist, texhead, flags, 0); } @@ -583,7 +631,7 @@ void load_and_set_texture_no_offset(Gfx **dlist, TextureHeader *texhead, u32 fla * Also tracks which modes are active, to prevent setting them again if they're already active. * A number can be attached that adds a texture address offset. An example of this being used is * the numbered doors in the hub, to change what number is written on it. -*/ + */ void load_and_set_texture(Gfx **dlist, TextureHeader *texhead, s32 flags, s32 texOffset) { s32 forceFlags; s32 doPipeSync; @@ -612,8 +660,11 @@ void load_and_set_texture(Gfx **dlist, TextureHeader *texhead, s32 flags, s32 te gUsingTexture = FALSE; } - flags = (gUsePrimColour) ? (flags & (RENDER_DECAL | RENDER_COLOUR_INDEX | RENDER_ANTI_ALIASING | RENDER_Z_COMPARE | RENDER_SEMI_TRANSPARENT)) : - (flags & (RENDER_VTX_ALPHA | RENDER_DECAL | RENDER_Z_UPDATE | RENDER_COLOUR_INDEX | RENDER_CUTOUT | RENDER_FOG_ACTIVE | RENDER_SEMI_TRANSPARENT | RENDER_Z_COMPARE | RENDER_ANTI_ALIASING)); + flags = (gUsePrimColour) + ? (flags & (RENDER_DECAL | RENDER_COLOUR_INDEX | RENDER_ANTI_ALIASING | RENDER_Z_COMPARE | + RENDER_SEMI_TRANSPARENT)) + : (flags & (RENDER_VTX_ALPHA | RENDER_DECAL | RENDER_Z_UPDATE | RENDER_COLOUR_INDEX | RENDER_CUTOUT | + RENDER_FOG_ACTIVE | RENDER_SEMI_TRANSPARENT | RENDER_Z_COMPARE | RENDER_ANTI_ALIASING)); flags &= ~gBlockedRenderFlags; flags = (flags & RENDER_VTX_ALPHA) ? flags & ~RENDER_FOG_ACTIVE : flags & ~RENDER_Z_UPDATE; @@ -642,10 +693,18 @@ void load_and_set_texture(Gfx **dlist, TextureHeader *texhead, s32 flags, s32 te gCurrentRenderFlags = flags; if (!gUsingTexture) { if (flags & RENDER_VTX_ALPHA) { - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsSolidColourVtxAlpha[flags & (RENDER_ANTI_ALIASING | RENDER_Z_COMPARE)]), numberOfGfxCommands(dRenderSettingsSolidColourVtxAlpha[0])); + gDkrDmaDisplayList( + (*dlist)++, + OS_PHYSICAL_TO_K0( + dRenderSettingsSolidColourVtxAlpha[flags & (RENDER_ANTI_ALIASING | RENDER_Z_COMPARE)]), + numberOfGfxCommands(dRenderSettingsSolidColourVtxAlpha[0])); return; } - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsSolidColour[flags & (RENDER_FOG_ACTIVE | RENDER_SEMI_TRANSPARENT | RENDER_Z_COMPARE | RENDER_ANTI_ALIASING)]), numberOfGfxCommands(dRenderSettingsSolidColour[0])); + gDkrDmaDisplayList( + (*dlist)++, + OS_PHYSICAL_TO_K0(dRenderSettingsSolidColour[flags & (RENDER_FOG_ACTIVE | RENDER_SEMI_TRANSPARENT | + RENDER_Z_COMPARE | RENDER_ANTI_ALIASING)]), + numberOfGfxCommands(dRenderSettingsSolidColour[0])); return; } @@ -661,13 +720,15 @@ void load_and_set_texture(Gfx **dlist, TextureHeader *texhead, s32 flags, s32 te if (flags & RENDER_COLOUR_INDEX) { dlIndex |= 4; // Colour Index } - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsPrimOverlay[dlIndex]), numberOfGfxCommands(dRenderSettingsPrimOverlay[0])); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsPrimOverlay[dlIndex]), + numberOfGfxCommands(dRenderSettingsPrimOverlay[0])); return; } if (flags & RENDER_COLOUR_INDEX) { flags = (flags ^ RENDER_COLOUR_INDEX) | RENDER_FOG_ACTIVE; } - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsPrimCol[flags]), numberOfGfxCommands(dRenderSettingsPrimCol[0])); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsPrimCol[flags]), + numberOfGfxCommands(dRenderSettingsPrimCol[0])); return; } @@ -685,7 +746,8 @@ void load_and_set_texture(Gfx **dlist, TextureHeader *texhead, s32 flags, s32 te if (flags & RENDER_COLOUR_INDEX) { dlIndex |= 8; // Colour Index } - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsDecal[dlIndex]), numberOfGfxCommands(dRenderSettingsDecal[0])); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsDecal[dlIndex]), + numberOfGfxCommands(dRenderSettingsDecal[0])); return; } @@ -694,7 +756,8 @@ void load_and_set_texture(Gfx **dlist, TextureHeader *texhead, s32 flags, s32 te if (flags & RENDER_FOG_ACTIVE) { dlIndex |= 8; // Fog } - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsCutout[dlIndex]), numberOfGfxCommands(dRenderSettingsCutout[0])); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsCutout[dlIndex]), + numberOfGfxCommands(dRenderSettingsCutout[0])); return; } @@ -707,36 +770,38 @@ void load_and_set_texture(Gfx **dlist, TextureHeader *texhead, s32 flags, s32 te gSPSetGeometryMode((*dlist)++, G_ZBUFFER); gCurrentRenderFlags |= RENDER_Z_COMPARE; } - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsVtxAlpha[dlIndex]), numberOfGfxCommands(dRenderSettingsVtxAlpha[0])); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsVtxAlpha[dlIndex]), + numberOfGfxCommands(dRenderSettingsVtxAlpha[0])); return; } - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsCommon[flags]), numberOfGfxCommands(dRenderSettingsCommon[0])); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsCommon[flags]), + numberOfGfxCommands(dRenderSettingsCommon[0])); return; } } /** * Loads the texture and render settings for the blinking lights seen in Spaceport Alpha. -*/ + */ void load_blinking_lights_texture(Gfx **dlist, TextureHeader *texture_list, u32 flags, s32 texture_index) { u16 *mblock; u16 *tblock; if ((texture_index != 0) && (texture_index < (texture_list->numOfTextures * 256))) { texture_list = (TextureHeader *) ((s32) texture_list + ((texture_index >> 16) * texture_list->textureSize)); } - mblock = (u16*)(texture_list + 1); + mblock = (u16 *) (texture_list + 1); tblock = mblock + 0x400; if (texture_list->width == 64) { - gDPLoadMultiBlock((*dlist)++, OS_K0_TO_PHYSICAL(mblock), 256, 1, - G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 16, 0, 0, 0, 6, 4, 0, 0); - gDPLoadTextureBlock((*dlist)++, OS_K0_TO_PHYSICAL(tblock), - G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 16, 0, 0, 0, 6, 4, 0, 0); + gDPLoadMultiBlock((*dlist)++, OS_K0_TO_PHYSICAL(mblock), 256, 1, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 16, 0, 0, 0, + 6, 4, 0, 0); + gDPLoadTextureBlock((*dlist)++, OS_K0_TO_PHYSICAL(tblock), G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 16, 0, 0, 0, 6, 4, + 0, 0); } else { - gDPLoadMultiBlock((*dlist)++, OS_K0_TO_PHYSICAL(mblock), 256, 1, - G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0, 0, 0, 5, 5, 0, 0); - gDPLoadTextureBlock((*dlist)++, OS_K0_TO_PHYSICAL(tblock), - G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0, 0, 0, 5, 5, 0, 0); + gDPLoadMultiBlock((*dlist)++, OS_K0_TO_PHYSICAL(mblock), 256, 1, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0, 0, 0, + 5, 5, 0, 0); + gDPLoadTextureBlock((*dlist)++, OS_K0_TO_PHYSICAL(tblock), G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0, 0, 0, 5, 5, + 0, 0); } gDPPipeSync((*dlist)++); @@ -751,12 +816,13 @@ void load_blinking_lights_texture(Gfx **dlist, TextureHeader *texture_list, u32 } gForceFlags = TRUE; gCurrentRenderFlags = RENDER_NONE; - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsBlinkingLights[flags]), numberOfGfxCommands(dRenderSettingsBlinkingLights[0])); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsBlinkingLights[flags]), + numberOfGfxCommands(dRenderSettingsBlinkingLights[0])); } /** * Set whether to use an opaque render mode for sprites. -*/ + */ void sprite_opaque(s32 setting) { gSpriteOpaque = setting; gForceFlags = TRUE; @@ -788,12 +854,15 @@ void func_8007BF34(Gfx **dlist, s32 arg1) { temp_t8 = temp_a1 & ~0x800; if (gSpriteOpaque == 0) { if ((gCurrentRenderFlags & 0x200) != 0) { - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsSpriteCld[((temp_t8 >> 1) & 1) * 16]), numberOfGfxCommands(dRenderSettingsSpriteCld[0])); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsSpriteCld[((temp_t8 >> 1) & 1) * 16]), + numberOfGfxCommands(dRenderSettingsSpriteCld[0])); } else { - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsSpriteXlu[(temp_t8 - 16) * 16]), numberOfGfxCommands(dRenderSettingsSpriteXlu[0])); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsSpriteXlu[(temp_t8 - 16) * 16]), + numberOfGfxCommands(dRenderSettingsSpriteXlu[0])); } } else { - gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsCommon[temp_t8 * 16]), numberOfGfxCommands(dRenderSettingsCommon[0])); + gDkrDmaDisplayList((*dlist)++, OS_PHYSICAL_TO_K0(dRenderSettingsCommon[temp_t8 * 16]), + numberOfGfxCommands(dRenderSettingsCommon[0])); } gCurrentTextureHeader = NULL; gUsingTexture = 1; @@ -805,7 +874,7 @@ GLOBAL_ASM("asm/non_matchings/textures_sprites/func_8007BF34.s") /** * Official Name: texLoadSprite -*/ + */ GLOBAL_ASM("asm/non_matchings/textures_sprites/func_8007C12C.s") Sprite *func_8007C52C(s32 arg0) { @@ -816,7 +885,7 @@ Sprite *func_8007C52C(s32 arg0) { if (gSpriteCache[(arg0 << 1) + 1] == -1) { return NULL; } - return (Sprite *) gSpriteCache[(arg0 << 1) + 1]; + return (Sprite *) gSpriteCache[(arg0 << 1) + 1]; } s32 get_texture_size_from_id(s32 id) { @@ -829,7 +898,7 @@ s32 get_texture_size_from_id(s32 id) { s32 textureTableType; s32 numOfTextures; TempTexHeader *new_var4; - + textureTable = ASSET_TEXTURES_2D; textureTableType = 0; if (id & 0x8000) { @@ -870,7 +939,8 @@ UNUSED u8 func_8007C660(s32 arg0) { } for (i = 0; i < gSpriteTableNum; i++) { temp_s1 = gCurrentSprite; - load_asset_to_address(ASSET_SPRITES, (u32) temp_s1, gSpriteOffsetTable[i], gSpriteOffsetTable[i + 1] - gSpriteOffsetTable[i]); + load_asset_to_address(ASSET_SPRITES, (u32) temp_s1, gSpriteOffsetTable[i], + gSpriteOffsetTable[i + 1] - gSpriteOffsetTable[i]); temp_v1 = temp_s1->unkC.val[temp_s1->numberOfFrames]; for (j = 0; j < temp_v1; j++) { D_80126370[temp_s1->baseTextureId + j] = 1; @@ -894,7 +964,8 @@ UNUSED s32 func_8007C8A0(s32 spriteIndex) { return gSpriteCache[spriteIndex << 1]; } -s32 load_sprite_info(s32 spriteIndex, s32 *numOfInstancesOut, s32 *unkOut, s32 *numFramesOut, s32 *formatOut, s32 *sizeOut) { +s32 load_sprite_info(s32 spriteIndex, s32 *numOfInstancesOut, s32 *unkOut, s32 *numFramesOut, s32 *formatOut, + s32 *sizeOut) { TextureHeader *tex; s32 i; Sprite *new_var2; @@ -904,7 +975,7 @@ s32 load_sprite_info(s32 spriteIndex, s32 *numOfInstancesOut, s32 *unkOut, s32 * s32 new_var; if ((spriteIndex < 0) || (spriteIndex >= gSpriteTableNum)) { - textureCouldNotBeLoaded: + textureCouldNotBeLoaded: *numOfInstancesOut = 0; *unkOut = 0; *numFramesOut = 0; @@ -944,7 +1015,7 @@ void free_sprite(Sprite *sprite) { sprite->numberOfInstances--; if (sprite->numberOfInstances <= 0) { for (i = 0; i < D_80126358; i++) { - if ((s32)sprite == gSpriteCache[(i << 1) + 1]) { + if ((s32) sprite == gSpriteCache[(i << 1) + 1]) { for (frame = 0; frame < sprite->numberOfFrames; frame++) { free_texture(sprite->frames[frame]); } @@ -1007,7 +1078,7 @@ void func_8007CDC0(Sprite *sprite1, Sprite *sprite2, s32 arg2) { yTemp = (sprUnk6 - tex->unk4); y0 = yTemp - 1; y1 = (yTemp - texHeight); - curVerts = vertices; + curVerts = vertices; vertices[0].x = x0; vertices[0].y = y0; vertices[0].z = 0; @@ -1047,9 +1118,9 @@ void func_8007CDC0(Sprite *sprite1, Sprite *sprite2, s32 arg2) { } gSPPolygon(dlptr++, OS_K0_TO_PHYSICAL(triangles), 2, 1); triangles[0].flags = 0x40; - triangles[0].vi0 = curVertIndex + 3; - triangles[0].vi1 = curVertIndex + 2; - triangles[0].vi2 = curVertIndex + 1; + triangles[0].vi0 = curVertIndex + 3; + triangles[0].vi1 = curVertIndex + 2; + triangles[0].vi2 = curVertIndex + 1; triangles[0].uv0.u = (texWidth - 1) << 5; triangles[0].uv0.v = (texHeight - 1) << 5; triangles[0].uv1.u = (texWidth - 1) << 5; @@ -1057,9 +1128,9 @@ void func_8007CDC0(Sprite *sprite1, Sprite *sprite2, s32 arg2) { triangles[0].uv2.u = 1; triangles[0].uv2.v = 0; triangles[1].flags = 0x40; - triangles[1].vi0 = curVertIndex + 4; - triangles[1].vi1 = curVertIndex + 3; - triangles[1].vi2 = curVertIndex + 1; + triangles[1].vi0 = curVertIndex + 4; + triangles[1].vi1 = curVertIndex + 3; + triangles[1].vi2 = curVertIndex + 1; triangles[1].uv0.u = 1; triangles[1].uv0.v = (texHeight - 1) << 5; triangles[1].uv1.u = (texWidth - 1) << 5; @@ -1086,8 +1157,8 @@ GLOBAL_ASM("asm/non_matchings/textures_sprites/func_8007CDC0.s") #endif #ifdef NON_EQUIVALENT -//HEAVILY WIP -//Alternative attempt: https://decomp.me/scratch/TbR8j +// HEAVILY WIP +// Alternative attempt: https://decomp.me/scratch/TbR8j void build_tex_display_list(TextureHeader *tex, Gfx *dlist) { s32 texFlags; s32 cms; @@ -1142,19 +1213,22 @@ void build_tex_display_list(TextureHeader *tex, Gfx *dlist) { } if (!(tex->flags & 0x400)) { if (texFormat == 0) { - gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_32b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_32b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); if ((texFlags == 0) || (texFlags == 2)) { tex->flags |= 4; } } if (texFormat == 1) { - gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_16b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_16b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); if ((texFlags == 0) || (texFlags == 2)) { tex->flags |= 4; } } if (texFormat == 7) { - gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_CI, G_IM_SIZ_16b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_CI, G_IM_SIZ_16b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); temp_v0_4 = func_8007EF64(tex->ciPaletteOffset); gDPLoadTLUT_pal16(dlist++, 0, temp_v0_4); @@ -1164,40 +1238,48 @@ void build_tex_display_list(TextureHeader *tex, Gfx *dlist) { } } if (texFormat == 4) { - gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_16b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_16b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); tex->flags |= 4; } if (texFormat == 5) { - gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); tex->flags |= 4; } if (texFormat == 6) { - gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_4b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_4b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); tex->flags |= 4; } if (texFormat == 2) { - gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_8b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_8b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); } if (texFormat == 3) { - gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_4b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlock(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_4b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); } - tex->numberOfCommands = ((s32) ((s32)dlist - (s32)tex->cmd) >> 3); + tex->numberOfCommands = ((s32) ((s32) dlist - (s32) tex->cmd) >> 3); } else { - + if (texFormat == 0) { - gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_32b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_32b, width, height, 0, + cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); if ((texFlags == 0) || (texFlags == 2)) { tex->flags |= 4; } } if (texFormat == 1) { - gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_16b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_RGBA, G_IM_SIZ_16b, width, height, 0, + cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); if ((texFlags == 0) || (texFlags == 2)) { tex->flags |= 4; } } if (texFormat == 7) { - gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_CI, G_IM_SIZ_16b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_CI, G_IM_SIZ_16b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); temp_v0_4 = func_8007EF64(tex->ciPaletteOffset); gDPLoadTLUT_pal16(dlist++, 0, temp_v0_4); @@ -1207,24 +1289,29 @@ void build_tex_display_list(TextureHeader *tex, Gfx *dlist) { } } if (texFormat == 4) { - gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_16b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_16b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); tex->flags |= 4; } if (texFormat == 5) { - gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); tex->flags |= 4; } if (texFormat == 6) { - gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_4b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_IA, G_IM_SIZ_4b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); tex->flags |= 4; } if (texFormat == 2) { - gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_8b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_8b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); } if (texFormat == 3) { - gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_4b, width, height, 0, cms, cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); + gDPLoadTextureBlockS(dlist++, OS_PHYSICAL_TO_K0(tex + 1), G_IM_FMT_I, G_IM_SIZ_4b, width, height, 0, cms, + cmt, masks, maskt, G_TX_NOLOD, G_TX_NOLOD); } - tex->numberOfCommands = ((s32) ((s32)dlist - (s32)tex->cmd) >> 3); + tex->numberOfCommands = ((s32) ((s32) dlist - (s32) tex->cmd) >> 3); } } #else @@ -1236,7 +1323,7 @@ s32 func_8007EF64(s16 arg0) { } /** * Official Name: texAnimateTexture -*/ + */ void tex_animate_texture(TextureHeader *texture, u32 *triangleBatchInfoFlags, s32 *arg2, s32 updateRate) { s32 bit23Set; s32 bit25Set; @@ -1299,7 +1386,7 @@ void tex_animate_texture(TextureHeader *texture, u32 *triangleBatchInfoFlags, s3 while (*arg2 < 0) { *arg2 += texture->numOfTextures; } - } + } } void func_8007F1E8(LevelHeader_70 *arg0) { @@ -1319,7 +1406,7 @@ void func_8007F1E8(LevelHeader_70 *arg0) { /** * Official name: updateColourCycle -*/ + */ void update_colour_cycle(LevelHeader_70 *arg0, s32 updateRate) { s32 temp; s32 curIndex; @@ -1338,7 +1425,7 @@ void update_colour_cycle(LevelHeader_70 *arg0, s32 updateRate) { if (arg0->unk0 >= 2) { arg0->unk8 += updateRate; while (arg0->unk8 >= arg0->unkC) { - if (!temp){} + if (!temp) {} arg0->unk8 -= arg0->unkC; } while (arg0->unk8 >= arg0->unk18[arg0->unk4].unk0) { @@ -1354,20 +1441,20 @@ void update_colour_cycle(LevelHeader_70 *arg0, s32 updateRate) { if (nextIndex >= arg0->unk0) { nextIndex = 0; } - - cur = (LevelHeader_70 *) (&((LevelHeader_70_18 *)arg0)[curIndex]); + + cur = (LevelHeader_70 *) (&((LevelHeader_70_18 *) arg0)[curIndex]); temp = (arg0->unk8 << 16) / (cur->unk18->unk0); cur_red = cur->red2; cur_green = cur->green2; cur_blue = cur->blue2; cur_alpha = cur->alpha2; - next = (LevelHeader_70 *) (&((LevelHeader_70_18 *)arg0)[nextIndex]); + next = (LevelHeader_70 *) (&((LevelHeader_70_18 *) arg0)[nextIndex]); next_red = next->red2; next_green = next->green2; next_blue = next->blue2; next_alpha = next->alpha2; - + next = arg0; arg0->red = (((next_red - cur_red) * temp) >> 16) + cur_red; arg0->green = (((next_green - cur_green) * temp) >> 16) + cur_green; @@ -1378,7 +1465,7 @@ void update_colour_cycle(LevelHeader_70 *arg0, s32 updateRate) { /** * Official name: resetMixCycle -*/ + */ void init_pulsating_light_data(PulsatingLightData *data) { s32 i; data->currentFrame = 0; @@ -1392,7 +1479,7 @@ void init_pulsating_light_data(PulsatingLightData *data) { /** * Official Name: updateMixCycle -*/ + */ void update_pulsating_light_data(PulsatingLightData *data, s32 timeDelta) { s32 thisFrameIndex, nextFrameIndex; diff --git a/src/textures_sprites.h b/src/textures_sprites.h index a7f4b5ab..ce1b348e 100644 --- a/src/textures_sprites.h +++ b/src/textures_sprites.h @@ -121,7 +121,7 @@ void disable_primitive_colour(void); void load_and_set_texture_no_offset(Gfx **dlist, TextureHeader *texhead, u32 flags); void sprite_opaque(s32 setting); s32 func_8007EF64(s16 arg0); -void load_and_set_texture(Gfx **dlist, TextureHeader *texhead, s32 flags, s32 offset); +void load_and_set_texture(Gfx **dlist, TextureHeader *texhead, s32 flags, s32 texOffset); void free_sprite(Sprite *sprite); void free_texture(TextureHeader *tex); @@ -130,18 +130,19 @@ void tex_animate_texture(TextureHeader *texture, u32 *triangleBatchInfoFlags, s3 void func_8007F1E8(LevelHeader_70 *arg0); void init_pulsating_light_data(PulsatingLightData *data); void update_pulsating_light_data(PulsatingLightData *data, s32 timeDelta); -TextureHeader *set_animated_texture_header(TextureHeader *arg0, s32 arg1); +TextureHeader *set_animated_texture_header(TextureHeader *texHead, s32 offset); TextureHeader *load_texture(s32 arg0); // Non Matching -s32 get_texture_size_from_id(s32 arg0); // Non Matching +s32 get_texture_size_from_id(s32 id); // Non Matching s32 func_8007C860(s32 spriteIndex); // Non Matching -s32 load_sprite_info(s32 spriteID, s32 *numOfInstancesOut, s32 *unkOut, - s32 *numFramesOut, s32 *formatOut, s32 *sizeOut); // Non Matching +s32 load_sprite_info(s32 spriteIndex, s32 *numOfInstancesOut, s32 *unkOut, s32 *numFramesOut, s32 *formatOut, + s32 *sizeOut); // Non Matching void func_8007F594(Gfx **dlist, u32 index, u32 primitiveColor, u32 environmentColor); // Non Matching void func_8007CA68(s32 spriteID, s32 arg1, s32 *arg2, s32 *arg3, s32 *arg4); // Non Matching MemoryPoolSlot *func_8007C12C(s32 spriteID, s32 arg1); // Non Matching void tex_init_textures(void); // Non Matching void func_8007BF34(Gfx **dlist, s32 arg1); // Non Matching -void load_blinking_lights_texture(Gfx **dlist, TextureHeader *arg1, u32 flags, s32 arg3); // Non Matching +void load_blinking_lights_texture(Gfx **dlist, TextureHeader *texture_list, u32 flags, + s32 texture_index); // Non Matching void build_tex_display_list(TextureHeader *tex, Gfx *dlist); // Non Matching void func_8007CDC0(Sprite *sprite1, Sprite *sprite2, s32 arg2); // Non Matching diff --git a/src/thread0_epc.c b/src/thread0_epc.c index 0e7d9e43..48f3361a 100644 --- a/src/thread0_epc.c +++ b/src/thread0_epc.c @@ -38,7 +38,7 @@ OSMesgQueue D_801297E8; /** * Start the exception program counter thread. * Official Name: diCpuTraceInit -*/ + */ void thread0_create(void) { s32 i; @@ -84,14 +84,14 @@ void enable_interupts_on_main(void) { OSThread *node = __osGetActiveQueue(); while (node->priority != -1) { if (node->priority == OS_PRIORITY_IDLE) { - //Clear all existing interrupts and disable them. + // Clear all existing interrupts and disable them. node->context.sr &= ~(SR_IMASK | SR_IE); - - //Enable interrupts - //IP3 Int1 pin (N64: Cartridge) - //IP4 Int2 pin (N64: Pre-NMI (Reset button)) - //IP6 Int4 pin (N64: RDB Write) - //IP7 Timer interrupt + + // Enable interrupts + // IP3 Int1 pin (N64: Cartridge) + // IP4 Int2 pin (N64: Pre-NMI (Reset button)) + // IP6 Int4 pin (N64: RDB Write) + // IP7 Timer interrupt node->context.sr |= (SR_IBIT7 | SR_IBIT6 | SR_IBIT4 | SR_IBIT3 | SR_IE); break; } @@ -125,7 +125,7 @@ void write_epc_data_to_cpak(void) { s32 currentCount; s32 maxCount; u8 zero; - + for (thread = __osGetActiveQueue(); thread->priority != -1; thread = thread->tlnext) { if (thread->priority > OS_PRIORITY_IDLE && thread->priority <= OS_PRIORITY_APPMAX) { if (thread->flags & 2 || thread->flags & 1) { @@ -133,7 +133,7 @@ void write_epc_data_to_cpak(void) { } } } - + if (thread->priority != -1) { thread->context.fp0.f.f_odd = gObjectStackTrace[0]; thread->context.fp0.f.f_even = gObjectStackTrace[1]; @@ -155,7 +155,7 @@ void write_epc_data_to_cpak(void) { } /** - * Writes epc data to the controller pak when a memory allocation has failed, + * Writes epc data to the controller pak when a memory allocation has failed, * but only if CHEAT_EPC_LOCK_UP_DISPLAY is active. */ void dump_memory_to_cpak(s32 epc, s32 size, u32 colourTag) { @@ -171,7 +171,7 @@ void dump_memory_to_cpak(s32 epc, s32 size, u32 colourTag) { // This is checking if the EPC cheat is active if (get_filtered_cheats() & CHEAT_EPC_LOCK_UP_DISPLAY) { bzero(&epcinfo, sizeof(epcInfo)); - epcinfo.epc = epc & 0xFFFFFFFFFFFFFFFF; //fakematch + epcinfo.epc = epc & 0xFFFFFFFFFFFFFFFF; // fakematch epcinfo.a0 = size; epcinfo.a1 = colourTag; epcinfo.cause = -1; @@ -188,16 +188,16 @@ void dump_memory_to_cpak(s32 epc, s32 size, u32 colourTag) { currentCount += size; } } - i = sizeof(sp40) + sizeof(sp240) + sizeof(sp440); //fakematch? + i = sizeof(sp40) + sizeof(sp240) + sizeof(sp440); // fakematch? write_controller_pak_file(0, -1, "CORE", "", sp40, i); while (1) {} // Infinite loop; waiting for the player to reset the console? } } /** - * Mark the object type given, so if the game crashes while processing it, the debug screen will tell you which object ID is to blame. - * Split into three sections, for spawning an object, updating an object and for rendering an object. -*/ + * Mark the object type given, so if the game crashes while processing it, the debug screen will tell you which object + * ID is to blame. Split into three sections, for spawning an object, updating an object and for rendering an object. + */ void update_object_stack_trace(s32 index, s32 value) { if (index >= OBJECT_SPAWN && index <= OBJECT_DRAW) { gObjectStackTrace[index] = value; @@ -212,7 +212,7 @@ s32 get_lockup_status(void) { s32 controllerIndex = 0; s64 sp420[128]; // Overwrite epcStack? s64 sp220[64]; - u8 dataFromControllerPak[512]; //Looks to be sizeof(epcInfo), aligned to 64 + u8 dataFromControllerPak[512]; // Looks to be sizeof(epcInfo), aligned to 64 extern epcInfo gEpcInfo; extern s32 D_801299B0[64]; @@ -223,7 +223,8 @@ s32 get_lockup_status(void) { // Looks like it reads EpcInfo data from the controller pak, which is interesting if ((get_si_device_status(controllerIndex) == CONTROLLER_PAK_GOOD) && (get_file_number(controllerIndex, "CORE", "", &fileNum) == CONTROLLER_PAK_GOOD) && - (read_data_from_controller_pak(controllerIndex, fileNum, dataFromControllerPak, 0x800) == CONTROLLER_PAK_GOOD)) { + (read_data_from_controller_pak(controllerIndex, fileNum, dataFromControllerPak, 0x800) == + CONTROLLER_PAK_GOOD)) { bcopy(&dataFromControllerPak, &gEpcInfo, sizeof(epcInfo)); bcopy(&sp220, &D_801299B0, sizeof(sp220)); bcopy(&sp420, &D_80129BB0, sizeof(sp420)); @@ -250,7 +251,7 @@ void lockup_screen_loop(s32 updateRate) { } } -#define GET_REG(reg) (s32)gEpcInfo.reg +#define GET_REG(reg) (s32) gEpcInfo.reg /** * Draw onscreen the four pages of the crash screen. @@ -260,14 +261,14 @@ void lockup_screen_loop(s32 updateRate) { */ void render_epc_lock_up_display(void) { u16 *temp; - char *objStatusString[3] = {"setup", "control", "print"}; + char *objStatusString[3] = { "setup", "control", "print" }; s32 offset; s32 s3; s32 j; s32 i; static epcInfo gEpcInfo; static s32 D_801299B0[64]; - + s3 = 0; set_render_printf_position(16, 32); @@ -307,7 +308,7 @@ void render_epc_lock_up_display(void) { render_printf("%s %d ", objStatusString[i], gObjectStackTrace[i]); } } - render_printf("\n"); + render_printf("\n"); render_printf(" at 0x%08x v0 0x%08x v1 0x%08x\n", GET_REG(at), GET_REG(v0), GET_REG(v1)); render_printf(" a0 0x%08x a1 0x%08x a2 0x%08x\n", GET_REG(a0), GET_REG(a1), GET_REG(a2)); render_printf(" a3 0x%08x t0 0x%08x t1 0x%08x\n", GET_REG(a3), GET_REG(t0), GET_REG(t1)); @@ -324,7 +325,7 @@ void render_epc_lock_up_display(void) { case EPC_PAGE_STACK_BOTTOM: offset = (sLockupPage - 1) * 48; for (j = (s32) &D_801299B0[offset], i = 0; i < 16; i++) { - render_printf(" %08x %08x %08x\n", ((u8**)j)[0], ((u8**)j)[16], ((u8**)j)[32]); + render_printf(" %08x %08x %08x\n", ((u8 **) j)[0], ((u8 **) j)[16], ((u8 **) j)[32]); j = (s32) ((s32 *) j + 1); } break; @@ -332,7 +333,7 @@ void render_epc_lock_up_display(void) { offset = (sLockupPage - 4) * 128; for (temp = (u16 *) &D_80129BB0[offset], i = 0; i < 16; i++) { render_printf(" "); - for(j = 0; j < 8; j++) { + for (j = 0; j < 8; j++) { render_printf("%04x ", temp[0]); temp++; } diff --git a/src/thread0_epc.h b/src/thread0_epc.h index 57ea56b2..6a2ccccb 100644 --- a/src/thread0_epc.h +++ b/src/thread0_epc.h @@ -86,9 +86,9 @@ enum ObjectStackTraceID { void enable_interupts_on_main(void); void stop_all_threads_except_main(void); -void update_object_stack_trace(s32 arg0, s32 arg1); +void update_object_stack_trace(s32 index, s32 value); s32 get_lockup_status(void); -void lockup_screen_loop(s32 arg0); +void lockup_screen_loop(s32 updateRate); void thread0_create(void); void write_epc_data_to_cpak(void); void dump_memory_to_cpak(s32 epc, s32 size, u32 colourTag); diff --git a/src/thread30_track_loading.c b/src/thread30_track_loading.c index 1f9d63b0..0f457d3f 100644 --- a/src/thread30_track_loading.c +++ b/src/thread30_track_loading.c @@ -19,7 +19,8 @@ s32 gThread30LoadDelay = 0; /************ .bss ************/ // Used for __osException, but .bss file order is weird. Need to fix later. -u8 leoDiskStack[16]; //technically should have a OS_LEO_STACKSIZE or something. This is something like 4096 in libreultra... +u8 leoDiskStack[16]; // technically should have a OS_LEO_STACKSIZE or something. + // This is something like 4096 in libreultra... OSThread gThread30; OSMesgQueue gThread30MesgQueue; OSMesg gThread30Message[2]; diff --git a/src/thread3_main.c b/src/thread3_main.c index 32721553..0c0ba36b 100644 --- a/src/thread3_main.c +++ b/src/thread3_main.c @@ -47,11 +47,7 @@ /************ .rodata ************/ -UNUSED char *sDebugRomBuildInfo[] = { - "1.1605", - "02/10/97 16:03", - "pmountain" -}; +UNUSED char *sDebugRomBuildInfo[] = { "1.1605", "02/10/97 16:03", "pmountain" }; const char D_800E7134[] = "BBB\n"; // Functionally unused. @@ -63,7 +59,7 @@ UNUSED char gBuildString[40] = "Version 7.7 29/09/97 15.00 L.Schuneman"; s8 sAntiPiracyTriggered = 0; UNUSED s32 D_800DD378 = 1; -s32 gSaveDataFlags = 0; //Official Name: load_save_flags +s32 gSaveDataFlags = 0; // Official Name: load_save_flags s32 gScreenStatus = OSMESG_SWAP_BUFFER; s32 sControllerStatus = 0; UNUSED s32 D_800DD388 = 0; @@ -85,9 +81,7 @@ FadeTransition D_800DD3F4 = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_OUT, FADE UNUSED FadeTransition D_800DD3FC = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_WHITE, 20, -1); s32 sLogicUpdateRate = LOGIC_5FPS; FadeTransition gDrumstickSceneTransition = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_WHITE, 30, -1); -UNUSED char *D_800DD410[3] = { - "CAR", "HOV", "PLN" -}; +UNUSED char *D_800DD410[3] = { "CAR", "HOV", "PLN" }; FadeTransition gLevelFadeOutTransition = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_BLACK, 30, -1); FadeTransition D_800DD424 = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_NONE, FADE_COLOR_BLACK, 260, -1); @@ -136,12 +130,11 @@ s32 gCurrNumHudVertsPerPlayer; OSScClient *gNMISched[3]; OSMesg gNMIOSMesg; OSMesgQueue gNMIMesgQueue; -s32 gNMIMesgBuf; //Official Name: resetPressed +s32 gNMIMesgBuf; // Official Name: resetPressed UNUSED s32 D_80123568[3]; // BSS Padding /******************************/ - /** * Main looping function for the main thread. * Official Name: mainThread @@ -156,11 +149,13 @@ void thread3_main(UNUSED void *unused) { func_80072708(); audioStopThread(); stop_thread30(); - __osSpSetStatus(SP_SET_HALT | SP_CLR_INTR_BREAK | SP_CLR_YIELD | SP_CLR_YIELDED | SP_CLR_TASKDONE | SP_CLR_RSPSIGNAL - | SP_CLR_CPUSIGNAL | SP_CLR_SIG5 | SP_CLR_SIG6 | SP_CLR_SIG7); - osDpSetStatus(DPC_SET_XBUS_DMEM_DMA | DPC_CLR_FREEZE | DPC_CLR_FLUSH | DPC_CLR_TMEM_CTR | DPC_CLR_PIPE_CTR - | DPC_CLR_CMD_CTR | DPC_CLR_CMD_CTR); - while (1); // Infinite loop + __osSpSetStatus(SP_SET_HALT | SP_CLR_INTR_BREAK | SP_CLR_YIELD | SP_CLR_YIELDED | SP_CLR_TASKDONE | + SP_CLR_RSPSIGNAL | SP_CLR_CPUSIGNAL | SP_CLR_SIG5 | SP_CLR_SIG6 | SP_CLR_SIG7); + osDpSetStatus(DPC_SET_XBUS_DMEM_DMA | DPC_CLR_FREEZE | DPC_CLR_FLUSH | DPC_CLR_TMEM_CTR | DPC_CLR_PIPE_CTR | + DPC_CLR_CMD_CTR | DPC_CLR_CMD_CTR); + while (1) { + ; // Infinite loop + } } main_game_loop(); thread3_verify_stack(); @@ -219,7 +214,7 @@ void init_game(void) { func_80081218(); // init_save_data create_and_start_thread30(); osCreateMesgQueue(&gNMIMesgQueue, &gNMIOSMesg, 1); - osScAddClient(&gMainSched, (OSScClient*) gNMISched, &gNMIMesgQueue, OS_SC_ID_PRENMI); + osScAddClient(&gMainSched, (OSScClient *) gNMISched, &gNMIMesgQueue, OS_SC_ID_PRENMI); gNMIMesgBuf = 0; gGameCurrentEntrance = 0; gGameCurrentCutscene = 0; @@ -270,7 +265,7 @@ void main_game_loop(void) { set_rsp_segment(&gCurrDisplayList, 4, (s32) gVideoLastFramebuffer - 0x500); init_rsp(&gCurrDisplayList); init_rdp_and_framebuffer(&gCurrDisplayList); - render_background(&gCurrDisplayList, (Matrix *) &gGameCurrMatrix, TRUE); + render_background(&gCurrDisplayList, (Matrix *) &gGameCurrMatrix, TRUE); gSaveDataFlags = handle_save_data_and_read_controller(gSaveDataFlags, sLogicUpdateRate); if (get_lockup_status()) { render_epc_lock_up_display(); @@ -336,7 +331,7 @@ void main_game_loop(void) { if (gDrawFrameTimer == 2) { framebufferSize = SCREEN_WIDTH * SCREEN_HEIGHT * 2; if (osTvType == TV_TYPE_PAL) { - framebufferSize = (s32)((SCREEN_WIDTH * SCREEN_HEIGHT * 2) * 1.1f); + framebufferSize = (s32) ((SCREEN_WIDTH * SCREEN_HEIGHT * 2) * 1.1f); } dmacopy_doubleword(gVideoLastFramebuffer, gVideoCurrFramebuffer, (s32) gVideoCurrFramebuffer + framebufferSize); } @@ -354,7 +349,7 @@ void main_game_loop(void) { /** * Loads a level for gameplay based on what the next track ID is, with the option to override. -*/ + */ void load_next_ingame_level(s32 numPlayers, s32 trackID, Vehicle vehicle) { gGameNumPlayers = numPlayers - 1; if (trackID == -1) { @@ -388,7 +383,7 @@ void load_level_game(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle v * Call numerous functions to clear data in RAM. * Then call to free particles, HUD and text. * Waits for a GFX task before unloading. -*/ + */ void unload_level_game(void) { set_free_queue_state(0); if (gSkipGfxTask == FALSE) { @@ -411,7 +406,7 @@ void unload_level_game(void) { /** * The main behaviour function involving all of the ingame stuff. * Involves the updating of all objects and setting up the render scene. -*/ + */ void ingame_logic_loop(s32 updateRate) { s32 buttonPressedInputs, buttonHeldInputs, i, loadContext, sp3C; @@ -432,8 +427,9 @@ void ingame_logic_loop(s32 updateRate) { if (!gIsPaused) { func_80010994(updateRate); if (check_if_showing_cutscene_camera() == 0 || get_race_countdown()) { - if (buttonPressedInputs & START_BUTTON && get_level_property_stack_pos() == 0 && gDrumstickSceneLoadTimer == 0 - && gGameMode == GAMEMODE_INGAME && gPostRaceViewPort == NULL && gLevelLoadTimer == 0 && gPauseLockTimer == 0) { + if (buttonPressedInputs & START_BUTTON && get_level_property_stack_pos() == 0 && + gDrumstickSceneLoadTimer == 0 && gGameMode == GAMEMODE_INGAME && gPostRaceViewPort == NULL && + gLevelLoadTimer == 0 && gPauseLockTimer == 0) { buttonPressedInputs = 0; gIsPaused = TRUE; func_80093A40(); @@ -457,7 +453,7 @@ void ingame_logic_loop(s32 updateRate) { buttonHeldInputs &= ~(L_TRIG | R_TRIG | Z_TRIG); } if (gPostRaceViewPort) { - i = func_80095728(&gCurrDisplayList, &gGameCurrMatrix, &gGameCurrVertexList, updateRate); + i = func_80095728(&gCurrDisplayList, &gGameCurrMatrix, &gGameCurrVertexList, updateRate); switch (i) { case 2: buttonHeldInputs |= (L_TRIG | Z_TRIG); @@ -467,37 +463,30 @@ void ingame_logic_loop(s32 updateRate) { func_8006D8F0(-1); break; case 4: - clear_level_property_stack(); + clear_level_property_stack(); gDrumstickSceneLoadTimer = 0; buttonHeldInputs |= (L_TRIG | R_TRIG); break; case 5: - buttonHeldInputs |= L_TRIG, - loadContext = LEVEL_CONTEXT_TRACK_SELECT; + buttonHeldInputs |= L_TRIG, loadContext = LEVEL_CONTEXT_TRACK_SELECT; break; case 8: - buttonHeldInputs |= L_TRIG, - loadContext = LEVEL_CONTEXT_RESULTS; + buttonHeldInputs |= L_TRIG, loadContext = LEVEL_CONTEXT_RESULTS; break; case 9: - buttonHeldInputs |= L_TRIG, - loadContext = LEVEL_CONTEXT_TROPHY_ROUND; + buttonHeldInputs |= L_TRIG, loadContext = LEVEL_CONTEXT_TROPHY_ROUND; break; case 10: - buttonHeldInputs |= L_TRIG, - loadContext = LEVEL_CONTEXT_TROPHY_RESULTS; + buttonHeldInputs |= L_TRIG, loadContext = LEVEL_CONTEXT_TROPHY_RESULTS; break; case 11: - buttonHeldInputs |= L_TRIG, - loadContext = LEVEL_CONTEXT_UNUSED; + buttonHeldInputs |= L_TRIG, loadContext = LEVEL_CONTEXT_UNUSED; break; case 12: - buttonHeldInputs |= L_TRIG, - loadContext = LEVEL_CONTEXT_CHARACTER_SELECT; + buttonHeldInputs |= L_TRIG, loadContext = LEVEL_CONTEXT_CHARACTER_SELECT; break; case 13: - buttonHeldInputs |= L_TRIG, - loadContext = LEVEL_CONTEXT_UNK7; + buttonHeldInputs |= L_TRIG, loadContext = LEVEL_CONTEXT_UNK7; break; } } @@ -745,7 +734,7 @@ void ingame_logic_loop(s32 updateRate) { /** * Reset dialogue and set the transition effect for the cutscene showing an unlocked Drumstick. -*/ + */ void set_drumstick_unlock_transition(void) { gDrumstickSceneLoadTimer = 44; gIsPaused = 0; @@ -780,15 +769,15 @@ void func_8006D968(s8 *arg0) { if (gGameMode != GAMEMODE_UNUSED_4) { gLevelSettings[0] = gPlayableMapId; for (i = 0; i < 2; i++) { - gLevelSettings[i + 2] = arg0[i + 8]; //0x8-0x9 - destinationMapId - gLevelSettings[i + 4] = arg0[i + 10]; //0xA-0xB - overworldSpawnIndex - gLevelSettings[i + 6] = arg0[i + 12]; //0xC-0xD - ? - gLevelSettings[i + 8] = arg0[i + 14]; //0xE-0xF - ? - gLevelSettings[i + 10] = arg0[i + 18]; //0x12-0x13 - ? - gLevelSettings[i + 12] = arg0[i + 20]; //0x14-0x15 - ? + gLevelSettings[i + 2] = arg0[i + 8]; // 0x8-0x9 - destinationMapId + gLevelSettings[i + 4] = arg0[i + 10]; // 0xA-0xB - overworldSpawnIndex + gLevelSettings[i + 6] = arg0[i + 12]; // 0xC-0xD - ? + gLevelSettings[i + 8] = arg0[i + 14]; // 0xE-0xF - ? + gLevelSettings[i + 10] = arg0[i + 18]; // 0x12-0x13 - ? + gLevelSettings[i + 12] = arg0[i + 20]; // 0x14-0x15 - ? } - gLevelSettings[14] = arg0[22]; //0x16 - ? - gLevelSettings[15] = arg0[23]; //0x17 returnSpawnIndex + gLevelSettings[14] = arg0[22]; // 0x16 - ? + gLevelSettings[15] = arg0[23]; // 0x17 returnSpawnIndex D_801234FC = 1; } } @@ -811,7 +800,7 @@ UNUSED void set_game_mode(s32 changeTo) { /** * Sets up and loads a level to be used in the background of the menu that's about to be set up. * Used for every kind of menu that's not ingame. -*/ + */ void load_menu_with_level_background(s32 menuId, s32 levelId, s32 cutsceneId) { alloc_displaylist_heap(PLAYER_ONE); gGameMode = GAMEMODE_MENU; @@ -845,7 +834,7 @@ void set_level_default_vehicle(Vehicle vehicleID) { /** * Sets the vehicle option that the next level loaded for a menu may use. -*/ + */ void set_vehicle_id_for_menu(Vehicle vehicleId) { stubbed_printf("Swapping\n"); gMenuVehicleID = vehicleId; @@ -877,7 +866,7 @@ void load_level_menu(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle v /** * Call numerous functions to clear data in RAM. * Then call to free particles, HUD and text. -*/ + */ void unload_level_menu(void) { if (!gIsLoading) { gIsLoading = TRUE; @@ -895,7 +884,7 @@ void unload_level_menu(void) { /** * Used in menus, update objects and draw the game. * In the tracks menu, this only runs if there's a track actively loaded. -*/ + */ void update_menu_scene(s32 updateRate) { if (get_thread30_level_id_to_load() == NULL) { func_80010994(updateRate); @@ -912,19 +901,20 @@ void update_menu_scene(s32 updateRate) { /** * Main function for handling behaviour in menus. * Runs the menu code, with a simplified object update and scene rendering system. -*/ + */ void menu_logic_loop(s32 updateRate) { s32 menuLoopResult; s32 temp; s32 playerVehicle; s32 temp5; - + gIsPaused = FALSE; gPostRaceViewPort = NULL; if (!gIsLoading && gRenderMenu) { update_menu_scene(updateRate); } - menuLoopResult = menu_loop(&gCurrDisplayList, &gGameCurrMatrix, &gGameCurrVertexList, &gGameCurrTriList, updateRate); + menuLoopResult = + menu_loop(&gCurrDisplayList, &gGameCurrMatrix, &gGameCurrVertexList, &gGameCurrTriList, updateRate); gRenderMenu = TRUE; if (menuLoopResult == -2) { gRenderMenu = FALSE; @@ -1006,10 +996,10 @@ void menu_logic_loop(s32 updateRate) { gLevelSettings[1] = menuLoopResult; gLevelSettings[0] = gPlayableMapId; - gPlayableMapId = gLevelSettings[menuLoopResult+2]; - gGameCurrentEntrance = gLevelSettings[menuLoopResult+4]; + gPlayableMapId = gLevelSettings[menuLoopResult + 2]; + gGameCurrentEntrance = gLevelSettings[menuLoopResult + 4]; gGameMode = GAMEMODE_INGAME; - gGameCurrentCutscene = gLevelSettings[menuLoopResult+12]; + gGameCurrentCutscene = gLevelSettings[menuLoopResult + 12]; playerVehicle = get_player_selected_vehicle(PLAYER_ONE); gGameNumPlayers = gSettingsPtr->gNumRacers - 1; load_level_game(gPlayableMapId, gGameNumPlayers, gGameCurrentEntrance, playerVehicle); @@ -1034,7 +1024,7 @@ void menu_logic_loop(s32 updateRate) { /** * Loads a level, intended to be used in a menu. * Skips loading many things, otherwise used in gameplay. -*/ + */ void load_level_for_menu(s32 levelId, s32 numberOfPlayers, s32 cutsceneId) { if (!gIsLoading) { unload_level_menu(); @@ -1045,7 +1035,8 @@ void load_level_for_menu(s32 levelId, s32 numberOfPlayers, s32 cutsceneId) { } } if (levelId != (s32) SPECIAL_MAP_ID_NO_LEVEL) { - //!@bug: Forcing the plane here makes all AI use plane paths. This can be seen most evidently in the Ancient Lake demo. + //!@bug: Forcing the plane here makes all AI use plane paths. + //! This can be seen most evidently in the Ancient Lake demo. load_level_menu(levelId, numberOfPlayers, 0, VEHICLE_PLANE, cutsceneId); gIsLoading = FALSE; return; @@ -1056,7 +1047,7 @@ void load_level_for_menu(s32 levelId, s32 numberOfPlayers, s32 cutsceneId) { /** * Initialise global game settings data. * Allocate space to accomodate it then set the start points for each data point. -*/ + */ void calc_and_alloc_heap_for_settings(void) { s32 dataSize; u32 sizes[15]; @@ -1083,33 +1074,31 @@ void calc_and_alloc_heap_for_settings(void) { sizes[14] = sizes[13] + dataSize; // total size gSettingsPtr = allocate_from_main_pool_safe(sizes[14], COLOUR_TAG_WHITE); - gSettingsPtr->courseFlagsPtr = (s32 *)((u8 *)gSettingsPtr + sizes[0]); - gSettingsPtr->balloonsPtr = (s16 *)((u8 *)gSettingsPtr + sizes[1]); + gSettingsPtr->courseFlagsPtr = (s32 *) ((u8 *) gSettingsPtr + sizes[0]); + gSettingsPtr->balloonsPtr = (s16 *) ((u8 *) gSettingsPtr + sizes[1]); gSettingsPtr->tajFlags = 0; - gSettingsPtr->flapInitialsPtr[0] = (u16 *)((u8 *)gSettingsPtr + sizes[2]); - gSettingsPtr->flapInitialsPtr[1] = (u16 *)((u8 *)gSettingsPtr + sizes[3]); - gSettingsPtr->flapInitialsPtr[2] = (u16 *)((u8 *)gSettingsPtr + sizes[4]); - gSettingsPtr->flapTimesPtr[0] = (u16 *)((u8 *)gSettingsPtr + sizes[5]); - gSettingsPtr->flapTimesPtr[1] = (u16 *)((u8 *)gSettingsPtr + sizes[6]); - gSettingsPtr->flapTimesPtr[2] = (u16 *)((u8 *)gSettingsPtr + sizes[7]); - gSettingsPtr->courseInitialsPtr[0] = (u16 *)((u8 *)gSettingsPtr + sizes[8]); - gSettingsPtr->courseInitialsPtr[1] = (u16 *)((u8 *)gSettingsPtr + sizes[9]); - gSettingsPtr->courseInitialsPtr[2] = (u16 *)((u8 *)gSettingsPtr + sizes[10]); - gSettingsPtr->courseTimesPtr[0] = (u16 *)((u8 *)gSettingsPtr + sizes[11]); - gSettingsPtr->courseTimesPtr[1] = (u16 *)((u8 *)gSettingsPtr + sizes[12]); - gSettingsPtr->courseTimesPtr[2] = (u16 *)((u8 *)gSettingsPtr + sizes[13]); + gSettingsPtr->flapInitialsPtr[0] = (u16 *) ((u8 *) gSettingsPtr + sizes[2]); + gSettingsPtr->flapInitialsPtr[1] = (u16 *) ((u8 *) gSettingsPtr + sizes[3]); + gSettingsPtr->flapInitialsPtr[2] = (u16 *) ((u8 *) gSettingsPtr + sizes[4]); + gSettingsPtr->flapTimesPtr[0] = (u16 *) ((u8 *) gSettingsPtr + sizes[5]); + gSettingsPtr->flapTimesPtr[1] = (u16 *) ((u8 *) gSettingsPtr + sizes[6]); + gSettingsPtr->flapTimesPtr[2] = (u16 *) ((u8 *) gSettingsPtr + sizes[7]); + gSettingsPtr->courseInitialsPtr[0] = (u16 *) ((u8 *) gSettingsPtr + sizes[8]); + gSettingsPtr->courseInitialsPtr[1] = (u16 *) ((u8 *) gSettingsPtr + sizes[9]); + gSettingsPtr->courseInitialsPtr[2] = (u16 *) ((u8 *) gSettingsPtr + sizes[10]); + gSettingsPtr->courseTimesPtr[0] = (u16 *) ((u8 *) gSettingsPtr + sizes[11]); + gSettingsPtr->courseTimesPtr[1] = (u16 *) ((u8 *) gSettingsPtr + sizes[12]); + gSettingsPtr->courseTimesPtr[2] = (u16 *) ((u8 *) gSettingsPtr + sizes[13]); gSettingsPtr->unk4C = (Settings4C *) &gLevelSettings; gSaveDataFlags = // Set bits 0/1/2/8 and wipe out all others - SAVE_DATA_FLAG_READ_FLAP_TIMES | - SAVE_DATA_FLAG_READ_COURSE_TIMES | - SAVE_DATA_FLAG_READ_SAVE_DATA | + SAVE_DATA_FLAG_READ_FLAP_TIMES | SAVE_DATA_FLAG_READ_COURSE_TIMES | SAVE_DATA_FLAG_READ_SAVE_DATA | SAVE_DATA_FLAG_READ_EEPROM_SETTINGS; } /** * Set the init values for each racer based on which character they are and which player they are. * Then reset race status. -*/ + */ void init_racer_headers(void) { s32 i, j; gSettingsPtr->gNumRacers = get_number_of_active_players(); @@ -1142,7 +1131,7 @@ void init_racer_headers(void) { /** * Depending on flags, clear fastest lap times and/or overall course times. -*/ + */ void clear_lap_records(Settings *settings, s32 flags) { s32 i, j; s32 numWorlds, numLevels; @@ -1168,7 +1157,7 @@ void clear_lap_records(Settings *settings, s32 flags) { /** * Set all game progression values to their default, as if it were a new game. -*/ + */ void clear_game_progress(Settings *settings) { s32 i; s32 worldCount; @@ -1196,7 +1185,7 @@ void clear_game_progress(Settings *settings) { /** * Call functions to set all game save data to the default. -*/ + */ UNUSED void reset_save_data(void) { clear_lap_records(gSettingsPtr, 3); clear_game_progress(gSettingsPtr); @@ -1205,7 +1194,7 @@ UNUSED void reset_save_data(void) { /** * Return the global game settings. * This is where global game records and perferences are stored. -*/ + */ Settings *get_settings(void) { return gSettingsPtr; } @@ -1219,7 +1208,7 @@ s8 is_game_paused(void) { /** * Returns the status of the post-race shrunken viewport. -*/ + */ s8 is_postrace_viewport_active(void) { return gPostRaceViewPort; } @@ -1230,14 +1219,14 @@ s8 is_postrace_viewport_active(void) { */ s32 is_reset_pressed(void) { if (gNMIMesgBuf == 0) { - gNMIMesgBuf = (s32)((osRecvMesg(&gNMIMesgQueue, NULL, OS_MESG_NOBLOCK) + 1) != 0); + gNMIMesgBuf = (s32) ((osRecvMesg(&gNMIMesgQueue, NULL, OS_MESG_NOBLOCK) + 1) != 0); } return gNMIMesgBuf; } /** * Returns the current map ID if ingame, since this var is only set ingame. -*/ + */ s32 get_ingame_map_id(void) { return gPlayableMapId; } @@ -1267,9 +1256,9 @@ void mark_to_read_flap_and_course_times(void) { * Marks a flag to read the save file from the passed index from flash. */ void mark_read_save_file(s32 saveFileIndex) { - //Wipe out bits 8 and 9 + // Wipe out bits 8 and 9 gSaveDataFlags &= ~(SAVE_DATA_FLAG_READ_EEPROM_SETTINGS | SAVE_DATA_FLAG_WRITE_EEPROM_SETTINGS); - //Place saveFileIndex at bits 8 and 9 and set bit 2 + // Place saveFileIndex at bits 8 and 9 and set bit 2 gSaveDataFlags |= (SAVE_DATA_FLAG_READ_SAVE_DATA | ((saveFileIndex & SAVE_DATA_FLAG_INDEX_VALUE) << 8)); } @@ -1277,7 +1266,7 @@ void mark_read_save_file(s32 saveFileIndex) { * Marks a flag to read all save file data from flash. */ void mark_read_all_save_files(void) { - gSaveDataFlags |= SAVE_DATA_FLAG_READ_ALL_SAVE_DATA; //Set bit 3 + gSaveDataFlags |= SAVE_DATA_FLAG_READ_ALL_SAVE_DATA; // Set bit 3 } /** @@ -1306,19 +1295,20 @@ void mark_to_write_flap_and_course_times(void) { * Official Name: mainSaveGame */ void force_mark_write_save_file(s32 saveFileIndex) { - gSaveDataFlags &= ~SAVE_DATA_FLAG_WRITE_SAVE_FILE_NUMBER_BITS; //Wipe out bits 10 and 11 - gSaveDataFlags |= (SAVE_DATA_FLAG_WRITE_SAVE_DATA | ((saveFileIndex & 3) << 10)); //Set bit 6 and place saveFileIndex into bits 10 and 11 + gSaveDataFlags &= ~SAVE_DATA_FLAG_WRITE_SAVE_FILE_NUMBER_BITS; // Wipe out bits 10 and 11 + gSaveDataFlags |= (SAVE_DATA_FLAG_WRITE_SAVE_DATA | + ((saveFileIndex & 3) << 10)); // Set bit 6 and place saveFileIndex into bits 10 and 11 } /** - * Marks a flag to write a save file to flash as long as we're not in tracks mode, and we're in the draw game render context. - * This should prevent save data from being overwritten outside of Adventure Mode. - * Official Name: mainSaveGame2 + * Marks a flag to write a save file to flash as long as we're not in tracks mode, and we're in the draw game render + * context. This should prevent save data from being overwritten outside of Adventure Mode. Official Name: mainSaveGame2 */ void safe_mark_write_save_file(s32 saveFileIndex) { if (gGameMode == GAMEMODE_INGAME && !is_in_tracks_mode()) { - gSaveDataFlags &= ~SAVE_DATA_FLAG_WRITE_SAVE_FILE_NUMBER_BITS; //Wipe out bits 10 and 11 - gSaveDataFlags |= (SAVE_DATA_FLAG_WRITE_SAVE_DATA | ((saveFileIndex & 3) << 10));; //Set bit 6 and place saveFileIndex into bits 10 and 11 + gSaveDataFlags &= ~SAVE_DATA_FLAG_WRITE_SAVE_FILE_NUMBER_BITS; // Wipe out bits 10 and 11 + gSaveDataFlags |= (SAVE_DATA_FLAG_WRITE_SAVE_DATA | ((saveFileIndex & 3) << 10)); + ; // Set bit 6 and place saveFileIndex into bits 10 and 11 } } @@ -1326,7 +1316,7 @@ void safe_mark_write_save_file(s32 saveFileIndex) { * Marks a flag to erase a save file from flash later */ void mark_save_file_to_erase(s32 saveFileIndex) { - //Set bit 7 and and place saveFileIndex into bits 10 and 11 while wiping everything else + // Set bit 7 and and place saveFileIndex into bits 10 and 11 while wiping everything else gSaveDataFlags = SAVE_DATA_FLAG_ERASE_SAVE_DATA | ((saveFileIndex & 3) << 10); } @@ -1361,13 +1351,11 @@ void alloc_displaylist_heap(s32 numberOfPlayers) { set_free_queue_state(0); free_from_memory_pool(gDisplayLists[0]); free_from_memory_pool(gDisplayLists[1]); - totalSize = - ((gNumF3dCmdsPerPlayer[num] * sizeof(Gwords))) - + ((gNumHudMatPerPlayer[num] * sizeof(Matrix))) - + ((gNumHudVertsPerPlayer[num] * sizeof(Vertex))) - + ((gNumHudTrisPerPlayer[num] * sizeof(Triangle))); + totalSize = ((gNumF3dCmdsPerPlayer[num] * sizeof(Gwords))) + ((gNumHudMatPerPlayer[num] * sizeof(Matrix))) + + ((gNumHudVertsPerPlayer[num] * sizeof(Vertex))) + ((gNumHudTrisPerPlayer[num] * sizeof(Triangle))); gDisplayLists[0] = (Gfx *) allocate_at_address_in_main_pool(totalSize, (u8 *) gDisplayLists[0], COLOUR_TAG_RED); - gDisplayLists[1] = (Gfx *) allocate_at_address_in_main_pool(totalSize, (u8 *) gDisplayLists[1], COLOUR_TAG_YELLOW); + gDisplayLists[1] = + (Gfx *) allocate_at_address_in_main_pool(totalSize, (u8 *) gDisplayLists[1], COLOUR_TAG_YELLOW); if ((gDisplayLists[0] == NULL) || gDisplayLists[1] == NULL) { if (gDisplayLists[0] != NULL) { free_from_memory_pool(gDisplayLists[0]); @@ -1379,12 +1367,12 @@ void alloc_displaylist_heap(s32 numberOfPlayers) { } default_alloc_displaylist_heap(); } - gMatrixHeap[0] = (MatrixS *)((u8 *) gDisplayLists[0] + ((gNumF3dCmdsPerPlayer[num] * sizeof(Gwords)))); - gTriangleHeap[0] = (TriangleList *)((u8 *) gMatrixHeap[0] + ((gNumHudMatPerPlayer[num] * sizeof(Matrix)))); - gVertexHeap[0] = (Vertex *)((u8 *) gTriangleHeap[0] + ((gNumHudTrisPerPlayer[num] * sizeof(Triangle)))); - gMatrixHeap[1] = (MatrixS *)((u8 *) gDisplayLists[1] + ((gNumF3dCmdsPerPlayer[num] * sizeof(Gwords)))); - gTriangleHeap[1] = (TriangleList *)((u8 *) gMatrixHeap[1] + ((gNumHudMatPerPlayer[num] * sizeof(Matrix)))); - gVertexHeap[1] = (Vertex *)((u8 *) gTriangleHeap[1] + ((gNumHudTrisPerPlayer[num] * sizeof(Triangle)))); + gMatrixHeap[0] = (MatrixS *) ((u8 *) gDisplayLists[0] + ((gNumF3dCmdsPerPlayer[num] * sizeof(Gwords)))); + gTriangleHeap[0] = (TriangleList *) ((u8 *) gMatrixHeap[0] + ((gNumHudMatPerPlayer[num] * sizeof(Matrix)))); + gVertexHeap[0] = (Vertex *) ((u8 *) gTriangleHeap[0] + ((gNumHudTrisPerPlayer[num] * sizeof(Triangle)))); + gMatrixHeap[1] = (MatrixS *) ((u8 *) gDisplayLists[1] + ((gNumF3dCmdsPerPlayer[num] * sizeof(Gwords)))); + gTriangleHeap[1] = (TriangleList *) ((u8 *) gMatrixHeap[1] + ((gNumHudMatPerPlayer[num] * sizeof(Matrix)))); + gVertexHeap[1] = (Vertex *) ((u8 *) gTriangleHeap[1] + ((gNumHudTrisPerPlayer[num] * sizeof(Triangle)))); gCurrNumF3dCmdsPerPlayer = gNumF3dCmdsPerPlayer[num]; gCurrNumHudMatPerPlayer = gNumHudMatPerPlayer[num]; gCurrNumHudTrisPerPlayer = gNumHudTrisPerPlayer[num]; @@ -1419,20 +1407,22 @@ void default_alloc_displaylist_heap(void) { numberOfPlayers = FOUR_PLAYERS; gPrevPlayerCount = numberOfPlayers; - totalSize = (gNumF3dCmdsPerPlayer[numberOfPlayers] * sizeof(Gwords)) - + (gNumHudMatPerPlayer[numberOfPlayers] * sizeof(Matrix)) - + (gNumHudVertsPerPlayer[numberOfPlayers] * sizeof(Vertex)) - + (gNumHudTrisPerPlayer[numberOfPlayers] * sizeof(Triangle)); + totalSize = (gNumF3dCmdsPerPlayer[numberOfPlayers] * sizeof(Gwords)) + + (gNumHudMatPerPlayer[numberOfPlayers] * sizeof(Matrix)) + + (gNumHudVertsPerPlayer[numberOfPlayers] * sizeof(Vertex)) + + (gNumHudTrisPerPlayer[numberOfPlayers] * sizeof(Triangle)); gDisplayLists[0] = (Gfx *) allocate_from_main_pool_safe(totalSize, COLOUR_TAG_RED); gMatrixHeap[0] = (MatrixS *) ((u8 *) gDisplayLists[0] + (gNumF3dCmdsPerPlayer[numberOfPlayers] * sizeof(Gwords))); gVertexHeap[0] = (Vertex *) ((u8 *) gMatrixHeap[0] + (gNumHudMatPerPlayer[numberOfPlayers] * sizeof(Matrix))); - gTriangleHeap[0] = (TriangleList *) ((u8 *) gVertexHeap[0] + (gNumHudVertsPerPlayer[numberOfPlayers] * sizeof(Vertex))); + gTriangleHeap[0] = + (TriangleList *) ((u8 *) gVertexHeap[0] + (gNumHudVertsPerPlayer[numberOfPlayers] * sizeof(Vertex))); gDisplayLists[1] = (Gfx *) allocate_from_main_pool_safe(totalSize, COLOUR_TAG_YELLOW); gMatrixHeap[1] = (MatrixS *) ((u8 *) gDisplayLists[1] + (gNumF3dCmdsPerPlayer[numberOfPlayers] * sizeof(Gwords))); gVertexHeap[1] = (Vertex *) ((u8 *) gMatrixHeap[1] + (gNumHudMatPerPlayer[numberOfPlayers] * sizeof(Matrix))); - gTriangleHeap[1] = (TriangleList *) ((u8 *) gVertexHeap[1] + (gNumHudVertsPerPlayer[numberOfPlayers] * sizeof(Vertex))); + gTriangleHeap[1] = + (TriangleList *) ((u8 *) gVertexHeap[1] + (gNumHudVertsPerPlayer[numberOfPlayers] * sizeof(Vertex))); gCurrNumF3dCmdsPerPlayer = gNumF3dCmdsPerPlayer[numberOfPlayers]; gCurrNumHudMatPerPlayer = gNumHudMatPerPlayer[numberOfPlayers]; @@ -1445,18 +1435,18 @@ void func_8006F140(s32 arg0) { gLevelLoadTimer = 40; gLevelLoadType = LEVEL_LOAD_NORMAL; D_80123526 = 0; - if (arg0 == 1) { //FADE_BARNDOOR_HORIZONTAL? + if (arg0 == 1) { // FADE_BARNDOOR_HORIZONTAL? transition_begin(&gLevelFadeOutTransition); } - if (arg0 == 3) { //FADE_CIRCLE? + if (arg0 == 3) { // FADE_CIRCLE? gLevelLoadTimer = 282; transition_begin(&D_800DD424); } - if (arg0 == 4) { //FADE_WAVES? + if (arg0 == 4) { // FADE_WAVES? gLevelLoadTimer = 360; transition_begin(&D_800DD424); } - if (arg0 == 0) { //FADE_FULLSCREEN? + if (arg0 == 0) { // FADE_FULLSCREEN? gLevelLoadTimer = 2; } } @@ -1472,7 +1462,7 @@ UNUSED void func_8006F20C(void) { /** * Begins a fade transition, then signals to the level loading that it wants to be a trophy race. -*/ + */ void begin_trophy_race_teleport(void) { if (gLevelLoadTimer == 0) { transition_begin(&gLevelFadeOutTransition); @@ -1483,10 +1473,11 @@ void begin_trophy_race_teleport(void) { /** * Check if all available trophy races and Wizpig 1 has been beaten, and if the cutscene has not yet played. -*/ + */ void begin_lighthouse_rocket_cutscene(void) { if (gLevelLoadTimer == 0) { - if ((gSettingsPtr->trophies & 0xFF) == 0xFF && !(gSettingsPtr->cutsceneFlags & CUTSCENE_LIGHTHOUSE_ROCKET) && gSettingsPtr->bosses & 1) { + if ((gSettingsPtr->trophies & 0xFF) == 0xFF && !(gSettingsPtr->cutsceneFlags & CUTSCENE_LIGHTHOUSE_ROCKET) && + gSettingsPtr->bosses & 1) { gSettingsPtr->cutsceneFlags |= CUTSCENE_LIGHTHOUSE_ROCKET; transition_begin(&gLevelFadeOutTransition); gLevelLoadTimer = 40; @@ -1499,7 +1490,7 @@ void begin_lighthouse_rocket_cutscene(void) { /** * Begin a transition, then set the next level to the passed argument. * This is used only to warp to Future Fun Land from the hub area. -*/ + */ void begin_level_teleport(s32 levelID) { if (gLevelLoadTimer == 0) { gNextMap = levelID; @@ -1511,7 +1502,7 @@ void begin_level_teleport(s32 levelID) { /** * Set the number of frames to disallow pausing for. -*/ + */ void set_pause_lockout_timer(u8 time) { gPauseLockTimer = time; } @@ -1519,7 +1510,7 @@ void set_pause_lockout_timer(u8 time) { /** * Switch the data around for player 1 and 2 for two player adventure, * effectively passing the lead over to the other player. -*/ + */ void swap_lead_player(void) { s32 i; u8 temp; @@ -1529,8 +1520,8 @@ void swap_lead_player(void) { swap_player_1_and_2_ids(); func_8000E194(); - first_racer_data = (u8 *)(gSettingsPtr->racers); - second_racer_data = (u8 *)(gSettingsPtr->racers + 1); + first_racer_data = (u8 *) (gSettingsPtr->racers); + second_racer_data = (u8 *) (gSettingsPtr->racers + 1); for (i = 0; i < (s32) sizeof(Racer); i++) { temp = first_racer_data[i]; @@ -1542,7 +1533,7 @@ void swap_lead_player(void) { /** * Sets the timer to delay drawing new frames. * When set to 2, the game will copy the previous framebuffer over to the next. -*/ + */ void set_frame_blackout_timer(void) { gDrawFrameTimer = 2; } @@ -1579,9 +1570,10 @@ s32 is_controller_missing(void) { } /** - * Ran on boot, will make sure the CIC chip (CIC6103) is to spec. Will return true if it's all good, otherwise it returns false. - * The intention of this function, is an attempt to check that the cartridge is a legitimate copy. - * A false read, meaning you're caught running an illegitimate copy, will force the game to pause when you enter the world. + * Ran on boot, will make sure the CIC chip (CIC6103) is to spec. Will return true if it's all good, otherwise it + * returns false. The intention of this function, is an attempt to check that the cartridge is a legitimate copy. A + * false read, meaning you're caught running an illegitimate copy, will force the game to pause when you enter the + * world. */ s32 check_imem_validity(void) { if (IO_READ(SP_IMEM_START) != CIC_ID) { diff --git a/src/thread3_main.h b/src/thread3_main.h index 5e4ae6e3..2260e9bc 100644 --- a/src/thread3_main.h +++ b/src/thread3_main.h @@ -126,12 +126,12 @@ void func_8006D8F0(s32 arg0); void func_8006D968(s8 *arg0); GameMode get_game_mode(void); void load_menu_with_level_background(s32 menuId, s32 levelId, s32 cutsceneId); -void set_level_default_vehicle(Vehicle arg0); +void set_level_default_vehicle(Vehicle vehicleID); void set_vehicle_id_for_menu(Vehicle vehicleId); Vehicle get_level_default_vehicle(void); void load_level_menu(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicleId, s32 cutsceneId); void unload_level_menu(void); -void update_menu_scene(s32 arg0); +void update_menu_scene(s32 updateRate); void load_level_for_menu(s32 levelId, s32 numberOfPlayers, s32 cutsceneId); void calc_and_alloc_heap_for_settings(void); void init_racer_headers(void); @@ -161,7 +161,7 @@ void func_8006F140(s32 arg0); void func_8006F20C(void); void begin_trophy_race_teleport(void); void begin_lighthouse_rocket_cutscene(void); -void begin_level_teleport(s32 arg0); +void begin_level_teleport(s32 levelID); void set_pause_lockout_timer(u8 time); void swap_lead_player(void); void set_frame_blackout_timer(void); diff --git a/src/tracks.c b/src/tracks.c index c487d8fa..51b98061 100644 --- a/src/tracks.c +++ b/src/tracks.c @@ -35,17 +35,15 @@ s32 D_800DC870 = 0; // Currently unknown, might be a different type. FadeTransition gFullFadeToBlack = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_OUT, FADE_COLOR_BLACK, 40, -1); FadeTransition gCircleFadeToBlack = FADE_TRANSITION(FADE_CIRCLE, FADE_FLAG_OUT, FADE_COLOR_BLACK, 70, -1); -f32 D_800DC884[10] = { - 0.0f, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f -}; +f32 D_800DC884[10] = { 0.0f, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f }; Vec3f D_800DC8AC[3][3] = { - { {{{ 50.0f, 0.0f, 32.0f }}}, {{{ -50.0f, 0.0f, 32.0f }}}, {{{ -50.0f, 100.0f, 32.0f }}} }, - { {{{ 0.0f, 0.0f, 32.0f }}}, {{{ 130.0f, 60.0f, -68.0f }}}, {{{ 130.0f, -60.0f, -68.0f }}} }, - { {{{ 0.0f, 0.0f, 32.0f }}}, {{{ -130.0f, -60.0f, -68.0f }}}, {{{ -130.0f, 60.0f, -68.0f }}} }, + { { { { 50.0f, 0.0f, 32.0f } } }, { { { -50.0f, 0.0f, 32.0f } } }, { { { -50.0f, 100.0f, 32.0f } } } }, + { { { { 0.0f, 0.0f, 32.0f } } }, { { { 130.0f, 60.0f, -68.0f } } }, { { { 130.0f, -60.0f, -68.0f } } } }, + { { { { 0.0f, 0.0f, 32.0f } } }, { { { -130.0f, -60.0f, -68.0f } } }, { { { -130.0f, 60.0f, -68.0f } } } }, }; -LevelModel *gCurrentLevelModel = NULL; //Official Name: track +LevelModel *gCurrentLevelModel = NULL; // Official Name: track LevelHeader *gCurrentLevelHeader2 = NULL; s32 D_800DC920 = -1; @@ -53,7 +51,8 @@ s32 *D_800DC924 = NULL; s32 D_800DC928 = 0; // Currently unknown, might be a different type. s8 D_800DC92C[24] = { - 0, 1, 4, 1, 2, 4, 2, 3, 4, 3, 0, 4, 5, 6, 1, 1, 0, 5, 3, 2, 7, 7, 8, 3 + 0, 1, 4, 1, 2, 4, 2, 3, 4, 3, 0, 4, 5, + 6, 1, 1, 0, 5, 3, 2, 7, 7, 8, 3 // There may or may not be extra zeroes here. }; @@ -70,10 +69,11 @@ ObjectSegment *gSceneActiveCamera; s32 gSceneCurrentPlayerID; Object *gSkydomeSegment; -UNUSED s32 gIsNearCurrBBox; // Set to true if the current visible segment is close to the camera. Never actually used though. +UNUSED s32 + gIsNearCurrBBox; // Set to true if the current visible segment is close to the camera. Never actually used though. UNUSED s32 D_8011B0C0; // Set to 0 then never read. UNUSED s32 gDisableShadows; // Never not 0. -s32 gShadowHeapFlip; // Flips between 0 and 1 to prevent incorrect access between frames. +s32 gShadowHeapFlip; // Flips between 0 and 1 to prevent incorrect access between frames. s32 D_8011B0CC; s32 gShadowIndex; s32 gSceneStartSegment; @@ -88,7 +88,7 @@ f32 D_8011B0E8; f32 D_8011B0EC; s32 D_8011B0F0; s32 D_8011B0F4; -s32 D_8011B0F8; //gIsInCutscene? +s32 D_8011B0F8; // gIsInCutscene? s32 gAntiAliasing; s32 D_8011B100; s32 D_8011B104; @@ -98,12 +98,12 @@ s32 D_8011B110; u32 D_8011B114; s32 D_8011B118; s32 D_8011B11C; -unk8011B120 D_8011B120[32]; //Struct sizeof(0x10) / sizeof(16) +unk8011B120 D_8011B120[32]; // Struct sizeof(0x10) / sizeof(16) s32 D_8011B320[4]; -unk8011B330 D_8011B330[120]; //Struct sizeof(0x20) / sizeof(32) +unk8011B330 D_8011B330[120]; // Struct sizeof(0x20) / sizeof(32) s32 D_8011C230; s32 D_8011C234; -unk8011C238 D_8011C238[32]; //Struct sizeof(0xC) / sizeof(12) +unk8011C238 D_8011C238[32]; // Struct sizeof(0xC) / sizeof(12) s32 D_8011C3B8[320]; s32 D_8011C8B8[512]; s32 D_8011D0B8; @@ -144,8 +144,8 @@ UNUSED s32 D_8011D34C; DrawTexture *gShadowHeapTextures[4]; DrawTexture *gCurrentShadowTexture; s32 D_8011D364; -s32 D_8011D368; //xOffset? -s32 D_8011D36C; //yOffset? +s32 D_8011D368; // xOffset? +s32 D_8011D36C; // yOffset? s32 *D_8011D370; s32 *D_8011D374; s32 D_8011D378; @@ -181,7 +181,7 @@ s16 D_8011D4BC; * Sets the number of expected viewports in the scene. * Like most other viewport vars, it's 0-3 rather than 1-4. * Set as an s32 for some reason. -*/ + */ s32 set_scene_viewport_num(s32 numPorts) { gScenePlayerViewports = numPorts; return 0; @@ -190,8 +190,9 @@ s32 set_scene_viewport_num(s32 numPorts) { /** * Initialises the level. * Allocates RAM to load generate the level geometry, spawn objects and generate shadows. -*/ -void init_track(u32 geometry, u32 skybox, s32 numberOfPlayers, Vehicle vehicle, u32 entranceId, u32 collectables, u32 arg6) { + */ +void init_track(u32 geometry, u32 skybox, s32 numberOfPlayers, Vehicle vehicle, u32 entranceId, u32 collectables, + u32 arg6) { s32 i; gCurrentLevelHeader2 = get_current_level_header(); @@ -200,15 +201,16 @@ void init_track(u32 geometry, u32 skybox, s32 numberOfPlayers, Vehicle vehicle, D_8011B104 = 0; D_8011B108 = 0; D_8011B10C = 0; - - if (gCurrentLevelHeader2->race_type == RACETYPE_CUTSCENE_1 || gCurrentLevelHeader2->race_type == RACETYPE_CUTSCENE_2) { + + if (gCurrentLevelHeader2->race_type == RACETYPE_CUTSCENE_1 || + gCurrentLevelHeader2->race_type == RACETYPE_CUTSCENE_2) { D_8011B0F8 = TRUE; } func_8002C0C4(geometry); gWaveBlockCount = 0; - + if (numberOfPlayers < 2) { for (i = 0; i < gCurrentLevelModel->numberOfSegments; i++) { if (gCurrentLevelModel->segments[i].hasWaves != 0) { @@ -218,16 +220,17 @@ void init_track(u32 geometry, u32 skybox, s32 numberOfPlayers, Vehicle vehicle, } } - if (is_in_two_player_adventure() && (gCurrentLevelHeader2->race_type == RACETYPE_DEFAULT || gCurrentLevelHeader2->race_type & RACETYPE_CHALLENGE)) { + if (is_in_two_player_adventure() && + (gCurrentLevelHeader2->race_type == RACETYPE_DEFAULT || gCurrentLevelHeader2->race_type & RACETYPE_CHALLENGE)) { i = 2; } else { i = numberOfPlayers + 1; } - + if (gWaveBlockCount) { func_800B82B4(gCurrentLevelModel, gCurrentLevelHeader2, i); } - + set_active_viewports_and_max(numberOfPlayers); spawn_skydome(skybox); D_8011B110 = 0; @@ -238,7 +241,7 @@ void init_track(u32 geometry, u32 skybox, s32 numberOfPlayers, Vehicle vehicle, gScenePlayerViewports = numberOfPlayers; func_8000CC7C(vehicle, entranceId, numberOfPlayers); func_8000B020(72, 64); - + if (geometry == 0 && entranceId == 0) { transition_begin(&gCircleFadeToBlack); } else { @@ -249,7 +252,8 @@ void init_track(u32 geometry, u32 skybox, s32 numberOfPlayers, Vehicle vehicle, numberOfPlayers = gScenePlayerViewports; gAntiAliasing = 0; for (i = 0; i < ARRAY_COUNT(gShadowHeapTextures); i++) { - gShadowHeapTextures[i] = (DrawTexture *) allocate_from_main_pool_safe(sizeof(DrawTexture) * 400, COLOUR_TAG_YELLOW); + gShadowHeapTextures[i] = + (DrawTexture *) allocate_from_main_pool_safe(sizeof(DrawTexture) * 400, COLOUR_TAG_YELLOW); gShadowHeapTris[i] = (Triangle *) allocate_from_main_pool_safe(sizeof(Triangle) * 800, COLOUR_TAG_YELLOW); gShadowHeapVerts[i] = (Vertex *) allocate_from_main_pool_safe(sizeof(Vertex) * 2000, COLOUR_TAG_YELLOW); } @@ -272,7 +276,7 @@ void init_track(u32 geometry, u32 skybox, s32 numberOfPlayers, Vehicle vehicle, /** * The root function for rendering the entire scene. * Handles drawing the track, objects and the majority of the HUD in single player. -*/ + */ void render_scene(Gfx **dList, MatrixS **mtx, Vertex **vtx, TriangleList **tris, s32 updateRate) { s32 i; s32 numViewports; @@ -318,9 +322,11 @@ void render_scene(Gfx **dList, MatrixS **mtx, Vertex **vtx, TriangleList **tris, } if (gCurrentLevelHeader2->skyDome == -1) { i = (gCurrentLevelHeader2->unkA4->width << 9) - 1; - gCurrentLevelHeader2->unkA8 = (gCurrentLevelHeader2->unkA8 + (gCurrentLevelHeader2->unkA2 * tempUpdateRate)) & i; + gCurrentLevelHeader2->unkA8 = + (gCurrentLevelHeader2->unkA8 + (gCurrentLevelHeader2->unkA2 * tempUpdateRate)) & i; i = (gCurrentLevelHeader2->unkA4->height << 9) - 1; - gCurrentLevelHeader2->unkAA = (gCurrentLevelHeader2->unkAA + (gCurrentLevelHeader2->unkA3 * tempUpdateRate)) & i; + gCurrentLevelHeader2->unkAA = + (gCurrentLevelHeader2->unkAA + (gCurrentLevelHeader2->unkA3 * tempUpdateRate)) & i; tex_animate_texture(gCurrentLevelHeader2->unkA4, &D_8011B114, &D_8011B110, tempUpdateRate); } flip = FALSE; @@ -377,15 +383,18 @@ void render_scene(Gfx **dList, MatrixS **mtx, Vertex **vtx, TriangleList **tris, set_weather_limits(-1, -512); // Show weather effects in single player. if (gCurrentLevelHeader2->weatherEnable > 0 && numViewports < 2) { - process_weather(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, &gSceneCurrTriList, tempUpdateRate); + process_weather(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, &gSceneCurrTriList, + tempUpdateRate); } func_800AD030(get_active_camera_segment()); func_800ACA20(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, get_active_camera_segment()); - render_hud(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, get_racer_object_by_port(gSceneCurrentPlayerID), updateRate); + render_hud(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, + get_racer_object_by_port(gSceneCurrentPlayerID), updateRate); } // Show TT Cam toggle for the fourth viewport when playing 3 player. - if (numViewports == 3 && get_current_level_race_type() != RACETYPE_CHALLENGE_EGGS && - get_current_level_race_type() != RACETYPE_CHALLENGE_BATTLE && get_current_level_race_type() != RACETYPE_CHALLENGE_BANANAS) { + if (numViewports == 3 && get_current_level_race_type() != RACETYPE_CHALLENGE_EGGS && + get_current_level_race_type() != RACETYPE_CHALLENGE_BATTLE && + get_current_level_race_type() != RACETYPE_CHALLENGE_BANANAS) { if (get_hud_setting() == 0) { if (flip) { gSPSetGeometryMode(gSceneCurrDisplayList++, G_CULL_FRONT); @@ -405,7 +414,8 @@ void render_scene(Gfx **dList, MatrixS **mtx, Vertex **vtx, TriangleList **tris, initialise_player_viewport_vars(updateRate); set_weather_limits(-1, -512); func_800AD030(get_active_camera_segment()); - func_800ACA20(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, get_active_camera_segment()); + func_800ACA20(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, + get_active_camera_segment()); set_text_font(FONT_COLOURFUL); if (osTvType == TV_TYPE_PAL) { posX = SCREEN_WIDTH_HALF + 6; @@ -448,7 +458,7 @@ void func_800257D0(void) { void func_80026070(LevelModelSegmentBoundingBox *, f32, f32, f32); void func_80026430(LevelModelSegment *, f32, f32, f32); void func_80026E54(s16 arg0, s8 *arg1, f32 arg2, f32 arg3); -//Alternative Attempt: https://decomp.me/scratch/2C6dJ +// Alternative Attempt: https://decomp.me/scratch/2C6dJ void func_8002581C(u8 *segmentIds, s32 numberOfSegments, s32 viewportIndex) { Vertex *spAC; s8 *spA8; @@ -528,9 +538,9 @@ void func_8002581C(u8 *segmentIds, s32 numberOfSegments, s32 viewportIndex) { } } } - func_80026C14( 300, (gCurrentLevelModel->lowerYBounds - 195), 1); + func_80026C14(300, (gCurrentLevelModel->lowerYBounds - 195), 1); func_80026C14(-300, (gCurrentLevelModel->lowerYBounds - 195), 1); - func_80026C14( 300, (gCurrentLevelModel->upperYBounds + 195), 0); + func_80026C14(300, (gCurrentLevelModel->upperYBounds + 195), 0); func_80026C14(-300, (gCurrentLevelModel->upperYBounds + 195), 0); if (D_8011D49E < D_8011D4BA && D_8011D49E != 0) { continueLoop = TRUE; @@ -539,9 +549,9 @@ void func_8002581C(u8 *segmentIds, s32 numberOfSegments, s32 viewportIndex) { if (D_8011D478[i].unk7 < D_8011D478[i].unk0) { temp_t3 = D_8011D478[i].unk7; D_8011D478[i].unk7 = D_8011D478[i].unk0; - temp_t4 = D_8011D478[i+1].unk0; + temp_t4 = D_8011D478[i + 1].unk0; D_8011D478[i].unk0 = temp_t3; - D_8011D478[i+1].unk0 = D_8011D478[i].unk4; + D_8011D478[i + 1].unk0 = D_8011D478[i].unk4; D_8011D478[i].unk4 = temp_t4; continueLoop = FALSE; } @@ -603,7 +613,7 @@ void func_8002581C(u8 *segmentIds, s32 numberOfSegments, s32 viewportIndex) { } if (D_8011D4B6 != 0) { gSPVertexDKR(gSceneCurrDisplayList++, OS_PHYSICAL_TO_K0(D_8011D488), D_8011D4B6, 0); - gSPPolygon(gSceneCurrDisplayList++, OS_PHYSICAL_TO_K0(D_8011D498), (D_8011D4B6 >> 1), TRIN_DISABLE_TEXTURE); + gSPPolygon(gSceneCurrDisplayList++, OS_PHYSICAL_TO_K0(D_8011D498), (D_8011D4B6 >> 1), TRIN_DISABLE_TEXTURE); } gSceneCurrVertexList = spAC; gSceneCurrTriList = spA8; @@ -625,15 +635,15 @@ void func_80026C14(s16 arg0, s16 arg1, s32 arg2) { while (i < D_8011D49E && D_8011D478[i].unk0 < arg0) { i++; } - while(i < D_8011D49E && arg0 == D_8011D478[i].unk0 && D_8011D478[i].unk2 < arg1) { + while (i < D_8011D49E && arg0 == D_8011D478[i].unk0 && D_8011D478[i].unk2 < arg1) { i++; } j = D_8011D49E; while (i < j) { - D_8011D478[j].unk0 = D_8011D478[j-1].unk0; - D_8011D478[j].unk2 = D_8011D478[j-1].unk2; - D_8011D478[j].unk7 = D_8011D478[j-1].unk7; - D_8011D478[j].unk6 = D_8011D478[j-1].unk6; + D_8011D478[j].unk0 = D_8011D478[j - 1].unk0; + D_8011D478[j].unk2 = D_8011D478[j - 1].unk2; + D_8011D478[j].unk7 = D_8011D478[j - 1].unk7; + D_8011D478[j].unk6 = D_8011D478[j - 1].unk6; j--; } D_8011D478[i].unk0 = arg0; @@ -656,7 +666,7 @@ GLOBAL_ASM("asm/non_matchings/tracks/func_800278E8.s") /** * Handle the flipbook effect for level geometry textures. -*/ + */ void animate_level_textures(s32 updateRate) { s32 segmentNumber, batchNumber; LevelModelSegment *segment; @@ -692,7 +702,7 @@ void animate_level_textures(s32 updateRate) { * Spawns and initialises the skydome object seen ingame. * Skipped if the object ID doesn't exist. * Also compares a checksum which can potentially trigger anti-tamper measures. -*/ + */ void spawn_skydome(s32 objectID) { LevelObjectEntryCommon spawnObject; @@ -717,20 +727,20 @@ void spawn_skydome(s32 objectID) { /** * Sets the status to render the sky. * If set to false, will skip the background and skydome rendering. -*/ + */ void set_skydome_visbility(s32 renderSky) { gSceneRenderSkyDome = renderSky; } // init_skydome -//https://decomp.me/scratch/jmbc1 +// https://decomp.me/scratch/jmbc1 GLOBAL_ASM("asm/non_matchings/tracks/func_80028050.s") /** * Instead of drawing the skydome with textures, draw a solid coloured background. * Using different colours set in the level header, the vertices are coloured and * it gives the background a gradient effect. -*/ + */ void draw_gradient_background(void) { s32 set_zero; s16 y0; @@ -745,7 +755,7 @@ void draw_gradient_background(void) { Triangle *tris; s32 also_one; s64 set_twenty; - + verts = (Vertex *) gSceneCurrVertexList; tris = (Triangle *) gSceneCurrTriList; headerRed0 = gCurrentLevelHeader2->BGColourTopR; @@ -828,11 +838,12 @@ void draw_gradient_background(void) { /** * Sets the position to the current camera's position then renders the skydome if set to be visible. -*/ + */ void render_skydome(void) { ObjectSegment *cam; - if (gSkydomeSegment == NULL) + if (gSkydomeSegment == NULL) { return; + } cam = get_active_camera_segment(); if (gCurrentLevelHeader2->skyDome == 0) { @@ -849,8 +860,8 @@ void render_skydome(void) { /** * Sets up all of the required variables for the player's view perspective. - * This includes setting up the camera index, viewport and -*/ + * This includes setting up the camera index, viewport and + */ void initialise_player_viewport_vars(s32 updateRate) { s32 i; s32 numRacers; @@ -862,7 +873,8 @@ void initialise_player_viewport_vars(s32 updateRate) { gSceneActiveCamera = get_active_camera_segment(); viewportID = get_current_viewport(); compute_scene_camera_transform_matrix(); - update_envmap_position(gScenePerspectivePos.x / 65536.0f, gScenePerspectivePos.y / 65536.0f, gScenePerspectivePos.z / 65536.0f); + update_envmap_position(gScenePerspectivePos.x / 65536.0f, gScenePerspectivePos.y / 65536.0f, + gScenePerspectivePos.z / 65536.0f); segmentIndex = gSceneActiveCamera->object.cameraSegmentID; if (segmentIndex > -1 && (segmentIndex < gCurrentLevelModel->numberOfSegments)) { gSceneStartSegment = gCurrentLevelModel->segments[segmentIndex].unk28; @@ -876,14 +888,16 @@ void initialise_player_viewport_vars(s32 updateRate) { func_800B8B8C(); racers = get_racer_objects(&numRacers); if (gSceneActiveCamera->object.unk36 != 7 && numRacers > 0 && !check_if_showing_cutscene_camera()) { - i = -1; + i = -1; do { i++; racer = &racers[i]->unk64->racer; - } while(i < numRacers - 1 && viewportID != racer->playerIndex); - func_800B8C04(racers[i]->segment.trans.x_position, racers[i]->segment.trans.y_position, racers[i]->segment.trans.z_position, get_current_viewport(), updateRate); + } while (i < numRacers - 1 && viewportID != racer->playerIndex); + func_800B8C04(racers[i]->segment.trans.x_position, racers[i]->segment.trans.y_position, + racers[i]->segment.trans.z_position, get_current_viewport(), updateRate); } else { - func_800B8C04(gSceneActiveCamera->trans.x_position, gSceneActiveCamera->trans.y_position, gSceneActiveCamera->trans.z_position, get_current_viewport(), updateRate); + func_800B8C04(gSceneActiveCamera->trans.x_position, gSceneActiveCamera->trans.y_position, + gSceneActiveCamera->trans.z_position, get_current_viewport(), updateRate); } } get_current_level_header()->unk3 = 1; @@ -893,7 +907,7 @@ void initialise_player_viewport_vars(s32 updateRate) { /** * Enable or disable anti aliasing. * Improves visual quality at the cost of performance. -*/ + */ void set_anti_aliasing(s32 setting) { gAntiAliasing = setting; } @@ -902,7 +916,7 @@ void set_anti_aliasing(s32 setting) { * Find which segments can and should be rendered, then render their opaque geometry. * Render all objects inside visible segments then render the level's semitransparent geometry. * Afterwards, render particles. -*/ + */ void render_level_geometry_and_objects(void) { s32 objCount; s32 numberOfSegments; @@ -964,7 +978,8 @@ void render_level_geometry_and_objects(void) { if (objFlags & visibleFlags) { visible = 0; } - if (obj != NULL && visible == 255 && check_if_in_draw_range(obj) && (objectsVisible[obj->segment.object.segmentID + 1] || obj->segment.camera.unk34 > 1000.0)) { + if (obj != NULL && visible == 255 && check_if_in_draw_range(obj) && + (objectsVisible[obj->segment.object.segmentID + 1] || obj->segment.camera.unk34 > 1000.0)) { if (obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) { render_object(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj); continue; @@ -986,7 +1001,8 @@ void render_level_geometry_and_objects(void) { } else { visible = TRUE; } - if (obj != NULL && visible && objFlags & OBJ_FLAGS_UNK_0100 && objectsVisible[obj->segment.object.segmentID + 1] && check_if_in_draw_range(obj)) { + if (obj != NULL && visible && objFlags & OBJ_FLAGS_UNK_0100 && + objectsVisible[obj->segment.object.segmentID + 1] && check_if_in_draw_range(obj)) { if (obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) { render_object(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj); continue; @@ -1030,7 +1046,8 @@ void render_level_geometry_and_objects(void) { if (obj->behaviorId == BHV_RACER && visible >= 255) { visible = 0; } - if (obj != NULL && visible < 255 && objectsVisible[obj->segment.object.segmentID + 1] && check_if_in_draw_range(obj)) { + if (obj != NULL && visible < 255 && objectsVisible[obj->segment.object.segmentID + 1] && + check_if_in_draw_range(obj)) { if (visible > 0) { if (obj->segment.trans.flags & OBJ_FLAGS_DEACTIVATED) { render_object(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj); @@ -1043,7 +1060,7 @@ void render_level_geometry_and_objects(void) { render_object_water_effects(obj, obj->waterEffect); } } -skip: + skip: if (obj->behaviorId == BHV_RACER) { render_racer_shield(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj); render_racer_magnet(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, obj); @@ -1061,7 +1078,7 @@ skip: * Render a batch of level geometry. * Since opaque and transparent are done in two separate runs, it will skip over the other. * Has a special case for the flashing lights in Spaceport Alpha, too. -*/ + */ void render_level_segment(s32 segmentId, s32 nonOpaque) { LevelModelSegment *segment; s32 i; @@ -1110,7 +1127,8 @@ void render_level_segment(s32 segmentId, s32 nonOpaque) { if (!(batchFlags & BATCH_FLAGS_DEPTH_WRITE) && !(batchFlags & BATCH_FLAGS_RECEIVE_SHADOWS)) { batchFlags |= gAntiAliasing; } - if ((!(textureFlags & RENDER_SEMI_TRANSPARENT) && !(batchFlags & BATCH_FLAGS_WATER)) || batchFlags & BATCH_FLAGS_RECEIVE_SHADOWS) { + if ((!(textureFlags & RENDER_SEMI_TRANSPARENT) && !(batchFlags & BATCH_FLAGS_WATER)) || + batchFlags & BATCH_FLAGS_RECEIVE_SHADOWS) { renderBatch = TRUE; } if (nonOpaque) { @@ -1123,7 +1141,7 @@ void render_level_segment(s32 segmentId, s32 nonOpaque) { continue; } numberTriangles = batchInfo->facesOffset; - do { //Fakematch + do { // Fakematch numberVertices = (batchInfo + 1)->verticesOffset - batchInfo->verticesOffset; numberTriangles = (batchInfo + 1)->facesOffset - numberTriangles; vertices = (s32) &segment->vertices[batchInfo->verticesOffset]; @@ -1132,11 +1150,12 @@ void render_level_segment(s32 segmentId, s32 nonOpaque) { texOffset = batchInfo->unk7 << 14; levelHeaderIndex = (batchFlags >> 28) & 7; if (levelHeaderIndex != (batchInfo->verticesOffset * 0)) { - gDPSetEnvColor(gSceneCurrDisplayList++, - ((LevelHeader_70 *)((u8 **)(&((LevelHeader **) gCurrentLevelHeader2)[levelHeaderIndex]))[28])->red, - ((LevelHeader_70 *)((u8 **)(&((LevelHeader **) gCurrentLevelHeader2)[levelHeaderIndex]))[28])->green, - ((LevelHeader_70 *)((u8 **)(&((LevelHeader **) gCurrentLevelHeader2)[levelHeaderIndex]))[28])->blue, - ((LevelHeader_70 *)((u8 **)(&((LevelHeader **) gCurrentLevelHeader2)[levelHeaderIndex]))[28])->alpha); + gDPSetEnvColor( + gSceneCurrDisplayList++, + ((LevelHeader_70 *) ((u8 **) (&((LevelHeader **) gCurrentLevelHeader2)[levelHeaderIndex]))[28])->red, + ((LevelHeader_70 *) ((u8 **) (&((LevelHeader **) gCurrentLevelHeader2)[levelHeaderIndex]))[28])->green, + ((LevelHeader_70 *) ((u8 **) (&((LevelHeader **) gCurrentLevelHeader2)[levelHeaderIndex]))[28])->blue, + ((LevelHeader_70 *) ((u8 **) (&((LevelHeader **) gCurrentLevelHeader2)[levelHeaderIndex]))[28])->alpha); } else { gDPSetEnvColor(gSceneCurrDisplayList++, 255, 255, 255, 0); } @@ -1162,8 +1181,9 @@ void render_level_segment(s32 segmentId, s32 nonOpaque) { /** * Parse through applicable segments in the level. * Uses function recursion to ensure adjacent segments remain next to each other in the list. -*/ -void traverse_segments_bsp_tree(s32 nodeIndex, s32 segmentIndex, s32 segmentIndex2, u8 *segmentsOrder, s32 *segmentsOrderIndex) { + */ +void traverse_segments_bsp_tree(s32 nodeIndex, s32 segmentIndex, s32 segmentIndex2, u8 *segmentsOrder, + s32 *segmentsOrderIndex) { BspTreeNode *curNode; s32 camValue; @@ -1178,25 +1198,29 @@ void traverse_segments_bsp_tree(s32 nodeIndex, s32 segmentIndex, s32 segmentInde if (camValue < curNode->splitValue) { if (curNode->leftNode != -1) { - traverse_segments_bsp_tree(curNode->leftNode, segmentIndex, curNode->segmentIndex - 1, segmentsOrder, segmentsOrderIndex); + traverse_segments_bsp_tree(curNode->leftNode, segmentIndex, curNode->segmentIndex - 1, segmentsOrder, + segmentsOrderIndex); } else { add_segment_to_order(segmentIndex, segmentsOrderIndex, segmentsOrder); } if (curNode->rightNode != -1) { - traverse_segments_bsp_tree(curNode->rightNode, curNode->segmentIndex, segmentIndex2, segmentsOrder, segmentsOrderIndex); + traverse_segments_bsp_tree(curNode->rightNode, curNode->segmentIndex, segmentIndex2, segmentsOrder, + segmentsOrderIndex); } else { add_segment_to_order(segmentIndex2, segmentsOrderIndex, segmentsOrder); } } else { if (curNode->rightNode != -1) { - traverse_segments_bsp_tree(curNode->rightNode, curNode->segmentIndex, segmentIndex2, segmentsOrder, segmentsOrderIndex); + traverse_segments_bsp_tree(curNode->rightNode, curNode->segmentIndex, segmentIndex2, segmentsOrder, + segmentsOrderIndex); } else { add_segment_to_order(segmentIndex2, segmentsOrderIndex, segmentsOrder); } if (curNode->leftNode != -1) { - traverse_segments_bsp_tree(curNode->leftNode, segmentIndex, curNode->segmentIndex - 1, segmentsOrder, segmentsOrderIndex); + traverse_segments_bsp_tree(curNode->leftNode, segmentIndex, curNode->segmentIndex - 1, segmentsOrder, + segmentsOrderIndex); } else { add_segment_to_order(segmentIndex, segmentsOrderIndex, segmentsOrder); } @@ -1205,7 +1229,7 @@ void traverse_segments_bsp_tree(s32 nodeIndex, s32 segmentIndex, s32 segmentInde /** * Add this segment index to the specified segment ordering table if the segment in question is in view of the camera. -*/ + */ void add_segment_to_order(s32 segmentIndex, s32 *segmentsOrderIndex, u8 *segmentsOrder) { u32 temp; if (segmentIndex < gCurrentLevelModel->numberOfSegments) { @@ -1226,7 +1250,7 @@ void add_segment_to_order(s32 segmentIndex, s32 *segmentsOrderIndex, u8 *segment * Checks if the active camera is currently inside this segment. * Has a small inner margin where it doesn't consider the camera inside. * Goes unused. -*/ + */ UNUSED s32 check_if_inside_segment(Object *obj, s32 segmentIndex) { LevelModelSegmentBoundingBox *bb; s32 x, y, z; @@ -1237,8 +1261,7 @@ UNUSED s32 check_if_inside_segment(Object *obj, s32 segmentIndex) { x = obj->segment.trans.x_position; y = obj->segment.trans.y_position; z = obj->segment.trans.z_position; - if ((x < (bb->x2 + 25)) && ((bb->x1 - 25) < x) && - (z < (bb->z2 + 25)) && ((bb->z1 - 25) < z) && + if ((x < (bb->x2 + 25)) && ((bb->x1 - 25) < x) && (z < (bb->z2 + 25)) && ((bb->z1 - 25) < z) && (y < (bb->y2 + 25)) && ((bb->y1 - 25) < y)) { return TRUE; } @@ -1251,7 +1274,7 @@ UNUSED s32 check_if_inside_segment(Object *obj, s32 segmentIndex) { * Uses mainly a two dimensional axis check here, instead of the function above. * Returns the segment currently inside. * Official Name: trackGetBlock -*/ + */ s32 get_level_segment_index_from_position(f32 xPos, f32 yPos, f32 zPos) { LevelModelSegmentBoundingBox *bb; s32 i; @@ -1293,15 +1316,14 @@ s32 get_level_segment_index_from_position(f32 xPos, f32 yPos, f32 zPos) { * Increments a counter based on if it's got a camera inside. * Because there's a tiny margin, multiple segments can be considered populated, * meaning that sometimes it will 2 instead of 1. -*/ + */ s32 get_inside_segment_count_xz(s32 x, s32 z, s32 *arg2) { s32 i; s32 cnt = 0; LevelModelSegmentBoundingBox *bb; for (i = 0; i < gCurrentLevelModel->numberOfSegments; i++) { bb = gCurrentLevelModel->segmentsBoundingBoxes + i; - if (x < bb->x2 + 4 && bb->x1 - 4 < x - && z < bb->z2 + 4 && bb->z1 - 4 < z) { + if (x < bb->x2 + 4 && bb->x1 - 4 < x && z < bb->z2 + 4 && bb->z1 - 4 < z) { *arg2 = i; cnt++; arg2++; @@ -1313,7 +1335,7 @@ s32 get_inside_segment_count_xz(s32 x, s32 z, s32 *arg2) { /** * Carbon copy of the above function, but takes into account the Y axis, too. * Official name: trackGetCubeBlockList -*/ + */ s32 get_inside_segment_count_xyz(s32 *arg0, s16 xPos1, s16 yPos1, s16 zPos1, s16 xPos2, s16 yPos2, s16 zPos2) { s32 cnt; s32 i; @@ -1331,9 +1353,8 @@ s32 get_inside_segment_count_xyz(s32 *arg0, s16 xPos1, s16 yPos1, s16 zPos1, s16 while (i < gCurrentLevelModel->numberOfSegments) { bb = &gCurrentLevelModel->segmentsBoundingBoxes[i]; - if ((bb->x2 >= xPos1) && (xPos2 >= bb->x1) && - (bb->z2 >= zPos1) && (zPos2 >= bb->z1) && - (bb->y2 >= yPos1) && (yPos2 >= bb->y1)) { + if ((bb->x2 >= xPos1) && (xPos2 >= bb->x1) && (bb->z2 >= zPos1) && (zPos2 >= bb->z1) && (bb->y2 >= yPos1) && + (yPos2 >= bb->y1)) { cnt++; *arg0++ = i; } @@ -1344,10 +1365,11 @@ s32 get_inside_segment_count_xyz(s32 *arg0, s16 xPos1, s16 yPos1, s16 zPos1, s16 /** * Returns this segment data. -*/ + */ LevelModelSegment *get_segment(s32 segmentID) { - if (segmentID < 0 || gCurrentLevelModel->numberOfSegments < segmentID) + if (segmentID < 0 || gCurrentLevelModel->numberOfSegments < segmentID) { return NULL; + } return &gCurrentLevelModel->segments[segmentID]; } @@ -1355,10 +1377,11 @@ LevelModelSegment *get_segment(s32 segmentID) { /** * Returns the bounding box data of this segment. * Official name: trackBlockDim -*/ + */ LevelModelSegmentBoundingBox *get_segment_bounding_box(s32 segmentID) { - if (segmentID < 0 || gCurrentLevelModel->numberOfSegments < segmentID) + if (segmentID < 0 || gCurrentLevelModel->numberOfSegments < segmentID) { return NULL; + } return &gCurrentLevelModel->segmentsBoundingBoxes[segmentID]; } @@ -1426,7 +1449,7 @@ void func_8002A31C(void) { * Takes a normalised (0-1) face direction of the active camera, then adds together a magnitude * to a total figure to determine whether or not a segment should be visible. * There's a large unused portion at the bottom writing to two vars, that are never later read. -*/ + */ s32 should_segment_be_visible(LevelModelSegmentBoundingBox *bb) { UNUSED u8 unknown[0x28]; s64 sp48; @@ -1434,13 +1457,13 @@ s32 should_segment_be_visible(LevelModelSegmentBoundingBox *bb) { s32 isVisible; f32 dirX, dirY, dirZ, dirW; f32 x, y, z; - + for (j = 0; j < 3; j++) { dirX = D_8011D0F8[j].x; dirY = D_8011D0F8[j].y; dirZ = D_8011D0F8[j].z; dirW = D_8011D0F8[j].w; - + for (i = 0, isVisible = FALSE; i < 8 && !isVisible; i++) { if (i & 1) { sp48 = bb->x1 * dirX; @@ -1483,7 +1506,7 @@ s32 should_segment_be_visible(LevelModelSegmentBoundingBox *bb) { * Get the draw distance of the object, then compare it to the active camera position. * At the edge of its view distance, it will set its alpha based on distance, giving it a fade in or out effect. * Objects in range return true, objects out of range return false. -*/ + */ s32 check_if_in_draw_range(Object *obj) { f32 w; f32 y; @@ -1506,12 +1529,13 @@ s32 check_if_in_draw_range(Object *obj) { viewDistance *= 0.5; } - dist = get_distance_to_active_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); - + dist = get_distance_to_active_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position); + if (viewDistance < dist) { return FALSE; } - + fadeDist = viewDistance * 0.8; if (fadeDist < dist) { temp2 = viewDistance - fadeDist; @@ -1529,7 +1553,7 @@ s32 check_if_in_draw_range(Object *obj) { obj64 = obj->unk64; obj->segment.object.opacity = ((obj64->racer.transparency + 1) * alpha) >> 8; break; - case BHV_UNK_3A: //Ghost Object? + case BHV_UNK_3A: // Ghost Object? obj64 = obj->unk64; obj->segment.object.opacity = obj64->racer.transparency; break; @@ -1538,8 +1562,8 @@ s32 check_if_in_draw_range(Object *obj) { case BHV_CAR_ANIMATION: case BHV_CHARACTER_SELECT: case BHV_VEHICLE_ANIMATION: // Title screen actor - case BHV_HIT_TESTER: // hittester - case BHV_HIT_TESTER_2: // animated objects? + case BHV_HIT_TESTER: // hittester + case BHV_HIT_TESTER_2: // animated objects? case BHV_ANIMATED_OBJECT_2: // space ships obj64 = obj->unk64; obj->segment.object.opacity = obj64->effect_box.pad0[0x42]; @@ -1557,7 +1581,8 @@ s32 check_if_in_draw_range(Object *obj) { z = D_8011D0F8[i].z; w = D_8011D0F8[i].w; y = D_8011D0F8[i].y; - accum = (x * obj->segment.trans.x_position) + (y * obj->segment.trans.y_position) + (z * obj->segment.trans.z_position) + w + obj->segment.camera.unk34; + accum = (x * obj->segment.trans.x_position) + (y * obj->segment.trans.y_position) + + (z * obj->segment.trans.z_position) + w + obj->segment.camera.unk34; if (accum < 0.0f) { return FALSE; } @@ -1605,7 +1630,7 @@ s32 func_8002ACD4(f32 *arg0, f32 *arg1, f32 *arg2) { * Iterates through active waves on the track, then saves its rotation vector and height if found. * Returns zero if no waves are found, or if too high up. * Two types exist: calm, which have no means of displacement, and wavy, which do. -*/ + */ s32 get_wave_properties(f32 yPos, f32 *waterHeight, Vec3f *rotation) { s32 var_a0; WaterProperties **wave; @@ -1613,7 +1638,7 @@ s32 get_wave_properties(f32 yPos, f32 *waterHeight, Vec3f *rotation) { s32 index; s32 len; f32 height; - + len = D_8011D308; if (rotation != NULL) { rotation->f[0] = 0.0f; @@ -1637,8 +1662,7 @@ s32 get_wave_properties(f32 yPos, f32 *waterHeight, Vec3f *rotation) { if (yPos < height + 25.0 && (wave[i]->rotY > 0.5 || var_a0 == 1)) { index = i; } - } else - if (index >= 0 && var_a0 >= 2 && yPos < height - 20.0) { + } else if (index >= 0 && var_a0 >= 2 && yPos < height - 20.0) { index = -1; } } @@ -1664,12 +1688,14 @@ s32 func_8002B9BC(Object *obj, f32 *arg1, f32 *arg2, s32 arg3) { arg2[2] = 0.0f; arg2[1] = 1.0f; } - if ((obj->segment.object.segmentID < 0) || (obj->segment.object.segmentID >= gCurrentLevelModel->numberOfSegments)) { + if ((obj->segment.object.segmentID < 0) || + (obj->segment.object.segmentID >= gCurrentLevelModel->numberOfSegments)) { return FALSE; } seg = &gCurrentLevelModel->segments[obj->segment.object.segmentID]; if ((seg->hasWaves != 0) && (gWaveBlockCount != 0) && (arg3 == 1)) { - *arg1 = func_800BB2F4(obj->segment.object.segmentID, obj->segment.trans.x_position, obj->segment.trans.z_position, arg2); + *arg1 = func_800BB2F4(obj->segment.object.segmentID, obj->segment.trans.x_position, + obj->segment.trans.z_position, arg2); return TRUE; } else { *arg1 = seg->unk38; @@ -1722,8 +1748,8 @@ s32 func_8002BAB0(s32 levelSegmentIndex, f32 xIn, f32 zIn, f32 *yOut) { return 0; } - // if (!temp_v1_4){} //Fake, but fixes one regalloc, at the cost of a much worse stack. - vert = NULL; //fake? + // if (!temp_v1_4){} //Fake, but fixes one regalloc, at the cost of a much worse stack. + vert = NULL; // fake? currentSegment = &gCurrentLevelModel->segments[levelSegmentIndex]; currentBoundingBox = &gCurrentLevelModel->segmentsBoundingBoxes[levelSegmentIndex]; var_a1 = 1; @@ -1741,9 +1767,9 @@ s32 func_8002BAB0(s32 levelSegmentIndex, f32 xIn, f32 zIn, f32 *yOut) { var_t0 += temp_a2; var_t1 += temp_a2; var_a1 *= 2; - } - - //Same as above, but for Z + } + + // Same as above, but for Z temp_a2 = ((currentBoundingBox->z2 - currentBoundingBox->z1) >> 3) + 1; var_t0 = temp_a2 + currentBoundingBox->z1; var_t1 = currentBoundingBox->z1; @@ -1758,7 +1784,7 @@ s32 func_8002BAB0(s32 levelSegmentIndex, f32 xIn, f32 zIn, f32 *yOut) { yOutCount = 0; for (batchNum = 0; batchNum < currentSegment->numberOfBatches; batchNum++) { - if (1) { } // fake + if (1) {} // fake currentBatch = ¤tSegment->batches[batchNum]; currentFaceOffset = currentBatch->facesOffset; nextFaceOffset = (currentBatch + 1)->facesOffset; @@ -1778,7 +1804,7 @@ s32 func_8002BAB0(s32 levelSegmentIndex, f32 xIn, f32 zIn, f32 *yOut) { temp_ra_1 = ((((XInInt - vert2X) * (vert3Z - vert2Z)) - ((vert3X - vert2X) * (ZInInt - vert2Z))) >= 0); temp_ra_2 = ((((XInInt - vert1X) * (vert2Z - vert1Z)) - ((vert2X - vert1X) * (ZInInt - vert1Z))) >= 0); temp_ra_3 = ((((XInInt - vert1X) * (vert3Z - vert1Z)) - ((vert3X - vert1X) * (ZInInt - vert1Z))) >= 0); - var_v0 = faceNum; //fake? + var_v0 = faceNum; // fake? if (temp_ra_1 == temp_ra_2 && temp_ra_2 != temp_ra_3) { new_var = currentSegment->unk14; temp = new_var[faceNum * 4]; @@ -1795,7 +1821,7 @@ s32 func_8002BAB0(s32 levelSegmentIndex, f32 xIn, f32 zIn, f32 *yOut) { } } } - + do { stopSorting = TRUE; for (var_v0 = 0; var_v0 < yOutCount - 1; var_v0++) { @@ -1823,82 +1849,88 @@ void func_8002C0C4(s32 modelId) { s32 temp_s4; s32 temp; LevelModel *mdl; - + set_texture_colour_tag(COLOUR_TAG_GREEN); gTrackModelHeap = allocate_from_main_pool_safe(LEVEL_MODEL_MAX_SIZE, COLOUR_TAG_YELLOW); gCurrentLevelModel = gTrackModelHeap; D_8011D370 = allocate_from_main_pool_safe(0x7D0, COLOUR_TAG_YELLOW); D_8011D374 = allocate_from_main_pool_safe(0x1F4, COLOUR_TAG_YELLOW); D_8011D378 = 0; - gLevelModelTable = (s32*)load_asset_section_from_rom(ASSET_LEVEL_MODELS_TABLE); - - for(i = 0; gLevelModelTable[i] != -1; i++); + gLevelModelTable = (s32 *) load_asset_section_from_rom(ASSET_LEVEL_MODELS_TABLE); + + for (i = 0; gLevelModelTable[i] != -1; i++) {} i--; if (modelId >= i) { modelId = 0; } - - //offset = gLevelModelTable[modelId]; + + // offset = gLevelModelTable[modelId]; temp_s4 = gLevelModelTable[modelId + 1] - gLevelModelTable[modelId]; // temp = compressedRamAddr temp = (s32) gCurrentLevelModel; - temp += (LEVEL_MODEL_MAX_SIZE - temp_s4); - temp -= ((s32)temp % 16); // Align to 16-byte boundary. - + temp += (LEVEL_MODEL_MAX_SIZE - temp_s4); + temp -= ((s32) temp % 16); // Align to 16-byte boundary. + load_asset_to_address(ASSET_LEVEL_MODELS, temp, gLevelModelTable[modelId], temp_s4); - gzip_inflate((u8*) temp, (u8*) gCurrentLevelModel); + gzip_inflate((u8 *) temp, (u8 *) gCurrentLevelModel); free_from_memory_pool(gLevelModelTable); // Done with the level models table, so free it. - + mdl = gCurrentLevelModel; - + LOCAL_OFFSET_TO_RAM_ADDRESS(TextureInfo *, gCurrentLevelModel->textures); LOCAL_OFFSET_TO_RAM_ADDRESS(LevelModelSegment *, gCurrentLevelModel->segments); LOCAL_OFFSET_TO_RAM_ADDRESS(LevelModelSegmentBoundingBox *, gCurrentLevelModel->segmentsBoundingBoxes); LOCAL_OFFSET_TO_RAM_ADDRESS(u8 *, gCurrentLevelModel->unkC); LOCAL_OFFSET_TO_RAM_ADDRESS(u8 *, gCurrentLevelModel->segmentsBitfields); LOCAL_OFFSET_TO_RAM_ADDRESS(BspTreeNode *, gCurrentLevelModel->segmentsBspTree); - - if(1){}if(1){}if(1){}if(1){}if(1){}if(1){} // Fakematch - - for(k = 0; k < gCurrentLevelModel->numberOfSegments; k++) { + + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} // Fakematch + + for (k = 0; k < gCurrentLevelModel->numberOfSegments; k++) { LOCAL_OFFSET_TO_RAM_ADDRESS(Vertex *, gCurrentLevelModel->segments[k].vertices); LOCAL_OFFSET_TO_RAM_ADDRESS(Triangle *, gCurrentLevelModel->segments[k].triangles); LOCAL_OFFSET_TO_RAM_ADDRESS(TriangleBatchInfo *, gCurrentLevelModel->segments[k].batches); LOCAL_OFFSET_TO_RAM_ADDRESS(u16 *, gCurrentLevelModel->segments[k].unk14); } - for(k = 0; k < gCurrentLevelModel->numberOfTextures; k++) { - gCurrentLevelModel->textures[k].texture = load_texture(((s32)gCurrentLevelModel->textures[k].texture) | 0x8000); + for (k = 0; k < gCurrentLevelModel->numberOfTextures; k++) { + gCurrentLevelModel->textures[k].texture = + load_texture(((s32) gCurrentLevelModel->textures[k].texture) | 0x8000); } - j = (s32)gCurrentLevelModel + gCurrentLevelModel->modelSize; - for(k = 0; k < gCurrentLevelModel->numberOfSegments; k++) { + j = (s32) gCurrentLevelModel + gCurrentLevelModel->modelSize; + for (k = 0; k < gCurrentLevelModel->numberOfSegments; k++) { gCurrentLevelModel->segments[k].unk10 = (s16 *) j; j = (s32) align16(((u8 *) (gCurrentLevelModel->segments[k].numberOfTriangles * 2)) + j); gCurrentLevelModel->segments[k].unk18 = (f32 *) j; - j = (s32) &((u8*)j)[func_8002CC30(&gCurrentLevelModel->segments[k])]; + j = (s32) & ((u8 *) j)[func_8002CC30(&gCurrentLevelModel->segments[k])]; func_8002C954(&gCurrentLevelModel->segments[k], &gCurrentLevelModel->segmentsBoundingBoxes[k], k); gCurrentLevelModel->segments[k].unk30 = 0; gCurrentLevelModel->segments[k].unk34 = (s16 *) j; func_8002C71C(&gCurrentLevelModel->segments[k]); j = (s32) align16(((u8 *) (gCurrentLevelModel->segments[k].unk32 * 2)) + j); } - temp_s4 = j - (s32)gCurrentLevelModel; + temp_s4 = j - (s32) gCurrentLevelModel; if (temp_s4 > LEVEL_MODEL_MAX_SIZE) { rmonPrintf("ERROR!! TrackMem overflow .. %d\n", temp_s4); } set_free_queue_state(0); free_from_memory_pool(gTrackModelHeap); - allocate_at_address_in_main_pool(temp_s4, (u8* ) gTrackModelHeap, COLOUR_TAG_YELLOW); + allocate_at_address_in_main_pool(temp_s4, (u8 *) gTrackModelHeap, COLOUR_TAG_YELLOW); set_free_queue_state(2); minimap_init(gCurrentLevelModel); - for(i = 0; i < gCurrentLevelModel->numberOfSegments; i++) { - for(temp_s4 = 0; temp_s4 < gCurrentLevelModel->segments[i].numberOfBatches; temp_s4++) { - for(k = gCurrentLevelModel->segments[i].batches[temp_s4].verticesOffset; - k < gCurrentLevelModel->segments[i].batches[temp_s4+1].verticesOffset; - k++) { + for (i = 0; i < gCurrentLevelModel->numberOfSegments; i++) { + for (temp_s4 = 0; temp_s4 < gCurrentLevelModel->segments[i].numberOfBatches; temp_s4++) { + for (k = gCurrentLevelModel->segments[i].batches[temp_s4].verticesOffset; + k < gCurrentLevelModel->segments[i].batches[temp_s4 + 1].verticesOffset; k++) { // Why do this? Why not just set the vertex colors in the model itself? - if(gCurrentLevelModel->segments[i].vertices[k].r == 1 && gCurrentLevelModel->segments[i].vertices[k].g == 1) { + if (gCurrentLevelModel->segments[i].vertices[k].r == 1 && + gCurrentLevelModel->segments[i].vertices[k].g == 1) { gCurrentLevelModel->segments[i].vertices[k].a = gCurrentLevelModel->segments[i].vertices[k].b; gCurrentLevelModel->segments[i].vertices[k].r = 0x80; gCurrentLevelModel->segments[i].vertices[k].g = 0x80; @@ -1936,14 +1968,14 @@ void func_8002C71C(LevelModelSegment *segment) { /** * Returns the current loaded level geometry * Official Name: trackGetTrack -*/ + */ LevelModel *get_current_level_model(void) { return gCurrentLevelModel; } /** * Frees and unloads level data from RAM. -*/ + */ void free_track(void) { s32 i; @@ -1995,7 +2027,7 @@ void func_8002C954(LevelModelSegment *segment, LevelModelSegmentBoundingBox *bbo for (i = 0; i < segment->numberOfBatches; i++) { startTri = segment->batches[i].facesOffset; - endTri = segment->batches[i+1].facesOffset; + endTri = segment->batches[i + 1].facesOffset; vertsOffset = segment->batches[i].verticesOffset; for (j = startTri; j < endTri; j++) { if (segment->triangles[j].flags & 0x80) { @@ -2005,10 +2037,11 @@ void func_8002C954(LevelModelSegment *segment, LevelModelSegmentBoundingBox *bbo maxZ = -32000; minZ = 32000; minX = 32000; - + for (l = 0; l < 3; l++) { vert = &segment->vertices[segment->triangles[j].verticesArray[l + 1] + vertsOffset]; - k = vert->x; vertX = k; // This is probably fake, but it matches. + k = vert->x; + vertX = k; // This is probably fake, but it matches. vertZ = vert->z; if (maxX < vertX) { maxX = vertX; @@ -2050,7 +2083,7 @@ void func_8002C954(LevelModelSegment *segment, LevelModelSegmentBoundingBox *bbo segment->unk10[j] = val; } } - } + } } GLOBAL_ASM("asm/non_matchings/tracks/func_8002CC30.s") @@ -2062,15 +2095,15 @@ typedef struct unk8002D30C_a0 { } unk8002D30C_a0; void trackMakeAbsolute(unk8002D30C_a0 *arg0, s32 arg1) { - while(1) { - if(!arg0) { + while (1) { + if (!arg0) { return; } if (arg0->unk04) { - arg0->unk04 = (unk8002D30C_a0 *)((s32)arg0->unk04 + arg1); + arg0->unk04 = (unk8002D30C_a0 *) ((s32) arg0->unk04 + arg1); } if (arg0->unk08) { - arg0->unk08 = (unk8002D30C_a0 *)((s32)arg0->unk08 + arg1); + arg0->unk08 = (unk8002D30C_a0 *) ((s32) arg0->unk08 + arg1); } trackMakeAbsolute(arg0->unk04, arg1); @@ -2094,7 +2127,7 @@ void render_object_shadow(Object *obj, ShadowData *shadow) { s32 offsetY; s32 offsetX; s32 alpha; - + if (obj->segment.header->shadowGroup) { if (shadow->meshStart != -1 && gDisableShadows == FALSE) { D_8011B0CC = gShadowHeapFlip; @@ -2127,7 +2160,7 @@ void render_object_shadow(Object *obj, ShadowData *shadow) { gSPPolygon(gSceneCurrDisplayList++, OS_K0_TO_PHYSICAL(tri), numTris, 1); i++; } - + if (flags != RENDER_Z_COMPARE) { gDPSetPrimColor(gSceneCurrDisplayList++, 0, 0, 255, 255, 255, 255); } @@ -2156,7 +2189,8 @@ void render_object_water_effects(Object *obj, WaterEffect *effect) { if (obj->segment.header->waterEffectGroup == SHADOW_SCENERY) { gShadowIndex = gShadowHeapFlip; gShadowIndex += 2; - if (get_distance_to_active_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position) > 768.0f) { + if (get_distance_to_active_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position) > 768.0f) { i = effect->meshEnd; // Just return. } } @@ -2184,7 +2218,7 @@ void render_object_water_effects(Object *obj, WaterEffect *effect) { * Updates shadow and water effect properties for each relevant object in the scene. * The first argument decides whether to update shadows for static objects or moving objects. * Checks how many players there are before deciding whether to cast a shadow for that object. -*/ + */ void update_shadows(s32 group, s32 waterGroup, s32 updateRate) { s32 objIndex; s32 objectCount; @@ -2195,7 +2229,7 @@ void update_shadows(s32 group, s32 waterGroup, s32 updateRate) { s32 numViewports; Object **objects; s32 skipShading; - TextureHeader* waterTex; + TextureHeader *waterTex; ShadowData *shadow; WaterEffect *waterEffect; s32 playerIndex; @@ -2223,13 +2257,15 @@ void update_shadows(s32 group, s32 waterGroup, s32 updateRate) { } if (shadow != NULL && shadow->scale > 0.0f && group == objHeader->shadowGroup) { shadow->meshStart = -1; - } + } if (obj->segment.trans.flags & OBJ_FLAGS_INVISIBLE) { shadow = NULL; } - if ((shadow != NULL && objHeader->shadowGroup == SHADOW_ACTORS) || (waterEffect != NULL && objHeader->waterEffectGroup == SHADOW_ACTORS)) { - dist = get_distance_to_active_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); - } else { + if ((shadow != NULL && objHeader->shadowGroup == SHADOW_ACTORS) || + (waterEffect != NULL && objHeader->waterEffectGroup == SHADOW_ACTORS)) { + dist = get_distance_to_active_camera(obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position); + } else { dist = 0; } if (shadow != NULL && shadow->scale > 0.0f && group == objHeader->shadowGroup) { @@ -2251,7 +2287,7 @@ void update_shadows(s32 group, s32 waterGroup, s32 updateRate) { radius = objHeader->unk4A; if (dist < radius) { if (objHeader->unk4C < dist) { - gShadowOpacity = (radius - dist) / ( radius - objHeader->unk4C); + gShadowOpacity = (radius - dist) / (radius - objHeader->unk4C); } func_8002E234(obj, FALSE); skipShading = TRUE; @@ -2269,9 +2305,9 @@ void update_shadows(s32 group, s32 waterGroup, s32 updateRate) { waterEffect->textureFrame += waterEffect->animationSpeed; while (waterTex->numOfTextures < waterEffect->textureFrame) { waterEffect->textureFrame -= waterTex->numOfTextures; - } + } } - + if (objHeader->shadowGroup == SHADOW_ACTORS && numViewports > ONE_PLAYER && numViewports <= FOUR_PLAYERS) { if (obj->behaviorId == BHV_RACER) { playerIndex = obj->unk64->racer.playerIndex; @@ -2316,24 +2352,24 @@ void func_8002DE30(Object *obj) { blockId = obj->segment.object.segmentID; foundResult = FALSE; if (blockId != -1) { - var_t3 = func_800314DC( - &gCurrentLevelModel->segmentsBoundingBoxes[blockId], - obj->segment.trans.x_position - 16.0f, obj->segment.trans.z_position - 16.0f, - obj->segment.trans.x_position + 16.0f, obj->segment.trans.z_position + 16.0f - ); - block = &gCurrentLevelModel->segments[blockId]; - for(i = 0; i < block->numberOfBatches && !foundResult; i++) { - if (!(block->batches[i].flags & (BATCH_FLAGS_HIDDEN | BATCH_FLAGS_RECEIVE_SHADOWS | BATCH_FLAGS_WATER | BATCH_FLAGS_FORCE_NO_SHADOWS))) { - batchFlags = (block->batches[i].flags >> 19) & (BATCH_FLAGS_UNK00000001 | BATCH_FLAGS_UNK00000002 | BATCH_FLAGS_UNK00000004); + var_t3 = func_800314DC(&gCurrentLevelModel->segmentsBoundingBoxes[blockId], + obj->segment.trans.x_position - 16.0f, obj->segment.trans.z_position - 16.0f, + obj->segment.trans.x_position + 16.0f, obj->segment.trans.z_position + 16.0f); + block = &gCurrentLevelModel->segments[blockId]; + for (i = 0; i < block->numberOfBatches && !foundResult; i++) { + if (!(block->batches[i].flags & (BATCH_FLAGS_HIDDEN | BATCH_FLAGS_RECEIVE_SHADOWS | BATCH_FLAGS_WATER | + BATCH_FLAGS_FORCE_NO_SHADOWS))) { + batchFlags = (block->batches[i].flags >> 19) & + (BATCH_FLAGS_UNK00000001 | BATCH_FLAGS_UNK00000002 | BATCH_FLAGS_UNK00000004); vertices = &block->vertices[block->batches[i].verticesOffset]; - for(j = block->batches[i].facesOffset; j < block->batches[i+1].facesOffset && !foundResult; j++) { + for (j = block->batches[i].facesOffset; j < block->batches[i + 1].facesOffset && !foundResult; j++) { blockId = block->unk10[j] & var_t3; - if(blockId){} + if (blockId) {} if (((block->unk10[j] & var_t3) & 0xFF) && ((block->unk10[j] & var_t3) & 0xFF00)) { triangle = &block->triangles[j]; minYPos = vertices[triangle->verticesArray[1]].y; maxYPos = minYPos; - for(k = 1; k < 3; k++) { + for (k = 1; k < 3; k++) { if (vertices[triangle->verticesArray[k + 1]].y < minYPos) { minYPos = vertices[triangle->verticesArray[k + 1]].y; } else if (maxYPos < vertices[triangle->verticesArray[k + 1]].y) { @@ -2342,12 +2378,9 @@ void func_8002DE30(Object *obj) { } if (maxYPos >= sp90 && sp94 >= minYPos) { if (point_triangle_2d_xz_intersection( - obj->segment.trans.x_position, - obj->segment.trans.z_position, - &vertices[triangle->verticesArray[1]].x, - &vertices[triangle->verticesArray[2]].x, - &vertices[triangle->verticesArray[3]].x) - ) { + obj->segment.trans.x_position, obj->segment.trans.z_position, + &vertices[triangle->verticesArray[1]].x, &vertices[triangle->verticesArray[2]].x, + &vertices[triangle->verticesArray[3]].x)) { foundResult = TRUE; obj->shading->unk0 += (((1.0f - D_800DC884[batchFlags]) - obj->shading->unk0) * 0.2); } @@ -2355,7 +2388,6 @@ void func_8002DE30(Object *obj) { } } } - } } } @@ -2386,10 +2418,10 @@ void func_8002E234(Object *obj, s32 bool) { character_scale = 0.714f; } } - + D_8011D0C4 = obj; D_8011D0C8 = 2.0f; - if (D_8011D0C4) { } //fakematch + if (D_8011D0C4) {} // fakematch if (bool) { D_8011D0B8 = 0; @@ -2432,19 +2464,25 @@ void func_8002E234(Object *obj, s32 bool) { D_8011D0F0 = -D_8011D0F0; } D_8011D0F4 = (7.0f * D_8011D0F0); - if (1) { } if (1) { } if (1) { } if (1) { } if (1) { } if (1) { } + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} D_8011D0D0 = -0x8000; } D_8011D0D8 = 144.0f / D_8011D0D8; xPos = obj->segment.trans.x_position; zPos = obj->segment.trans.z_position; - segs = get_inside_segment_count_xyz(inSegs, (xPos - D_8011D0DC), D_8011D0CC, (zPos - D_8011D0E0), (xPos + D_8011D0DC), D_8011D0CE, (zPos + D_8011D0E0)); + segs = get_inside_segment_count_xyz(inSegs, (xPos - D_8011D0DC), D_8011D0CC, (zPos - D_8011D0E0), + (xPos + D_8011D0DC), D_8011D0CE, (zPos + D_8011D0E0)); D_8011C230 = 0; D_8011B118 = 0; for (i = 0; i < ARRAY_COUNT(D_8011B320); i++) { D_8011B320[i] = 0; } - new_var = inSegs; //fake? + new_var = inSegs; // fake? D_8011D0E8 = -1; D_8011D0EC = -1; for (i = 0; i < segs; i++) { @@ -2452,12 +2490,11 @@ void func_8002E234(Object *obj, s32 bool) { if (bool && (gCurrentLevelModel->segments[inSegs[i]].hasWaves != 0) && (gWaveBlockCount != 0)) { func_8002EEEC(); } else { - test = func_800314DC( - &gCurrentLevelModel->segmentsBoundingBoxes[new_var[i]], - (obj->segment.trans.x_position - D_8011D0DC), //x1 - (obj->segment.trans.z_position - D_8011D0E0), //z1 - (obj->segment.trans.x_position + D_8011D0DC), //x2 - (obj->segment.trans.z_position + D_8011D0E0) //z2 + test = func_800314DC(&gCurrentLevelModel->segmentsBoundingBoxes[new_var[i]], + (obj->segment.trans.x_position - D_8011D0DC), // x1 + (obj->segment.trans.z_position - D_8011D0E0), // z1 + (obj->segment.trans.x_position + D_8011D0DC), // x2 + (obj->segment.trans.z_position + D_8011D0E0) // z2 ); func_8002E904(&gCurrentLevelModel->segments[new_var[i]], test, bool); } @@ -2472,8 +2509,7 @@ void func_8002E234(Object *obj, s32 bool) { } if (!bool) { obj->shadow->meshEnd = D_8011D364; - } - else { + } else { obj->waterEffect->meshEnd = D_8011D364; } } @@ -2502,14 +2538,14 @@ void func_8002F2AC(void) { D_8011B120[i].y = (f32) (-(temp_f16 + temp_f12 + temp_f10) / temp_f8); } - for (i = 0; D_8011B320[i] > 0 ; i++) { + for (i = 0; D_8011B320[i] > 0; i++) { for (j = 0; j < D_8011B320[i]; j++) { var_v0 = D_8011B330[i].unkC; temp_f16 = D_8011B330[i].x * var_v0->unk0; temp_f10 = var_v0->unkC; temp_f8 = var_v0->unk4; temp_f12 = D_8011B330[i].z * var_v0->unk8; - D_8011B330[i].z = (f32) (-(temp_f16 + temp_f12 + temp_f10) / temp_f8); + D_8011B330[i].z = (f32) (-(temp_f16 + temp_f12 + temp_f10) / temp_f8); } } } @@ -2519,7 +2555,7 @@ GLOBAL_ASM("asm/non_matchings/tracks/func_8002F2AC.s") GLOBAL_ASM("asm/non_matchings/tracks/func_8002F440.s") -//Transition points between different lighting levels, used by certain objects +// Transition points between different lighting levels, used by certain objects f32 func_8002FA64(void) { f32 var_f2; f32 x0, z0, x1, z1, x2, z2; @@ -2569,7 +2605,7 @@ f32 func_8002FA64(void) { } } } - + if (D_8011D0E4 < var_f2) { var_f2 = D_8011D0E4 * 0.99f; } @@ -2578,14 +2614,14 @@ f32 func_8002FA64(void) { } s32 func_8002FD74(f32 x0, f32 z0, f32 x1, f32 x2, s32 count, Vec4f *arg5) { - if(count > 0) { + if (count > 0) { f32 minX = arg5[0].x; f32 maxX = arg5[0].x; f32 minZ = arg5[0].z; f32 maxZ = arg5[0].z; s32 i; - for(i = 1; i < count; i++) { + for (i = 1; i < count; i++) { if (arg5[i].x < minX) { minX = arg5[i].x; } else if (maxX < arg5[i].x) { @@ -2597,13 +2633,13 @@ s32 func_8002FD74(f32 x0, f32 z0, f32 x1, f32 x2, s32 count, Vec4f *arg5) { maxZ = arg5[i].z; } } - + if ((x0 <= maxX) && (z0 <= maxZ) && (minX <= x1) && (minZ <= x2)) { return -1; } } - return 0; + return 0; } GLOBAL_ASM("asm/non_matchings/tracks/func_8002FF6C.s") @@ -2617,7 +2653,7 @@ void func_800304C8(Vec4f *arg0) { f32 arg02x; f32 arg00z; f32 compare; - + found1 = FALSE; found2 = FALSE; found3 = FALSE; @@ -2625,21 +2661,27 @@ void func_800304C8(Vec4f *arg0) { arg00z = temp; compare = 0.0f; temp = (D_8011D0C4->segment.trans.z_position - arg0[1].z); - - if ((((D_8011D0C4->segment.trans.x_position - arg0[0].x) * (arg0[1].z - arg00z)) - ((arg0[1].x - arg0[0].x) * (((0, D_8011D0C4->segment.trans.z_position)) - arg00z))) >= compare) { + + if ((((D_8011D0C4->segment.trans.x_position - arg0[0].x) * (arg0[1].z - arg00z)) - + ((arg0[1].x - arg0[0].x) * (((0, D_8011D0C4->segment.trans.z_position)) - arg00z))) >= compare) { found1 = TRUE; } - if ((((D_8011D0C4->segment.trans.x_position - arg0[1].x) * (arg0[2].z - arg0[1].z)) - (temp * (arg0[2].x - arg0[1].x))) >= compare) { + if ((((D_8011D0C4->segment.trans.x_position - arg0[1].x) * (arg0[2].z - arg0[1].z)) - + (temp * (arg0[2].x - arg0[1].x))) >= compare) { found2 = TRUE; } arg02x = arg0[2].x; if (found1 == found2) { f32 zPosDiff = (arg00z - arg0[2].z); - if ((((D_8011D0C4->segment.trans.x_position - arg02x) * zPosDiff) - ((arg0[0].x - arg02x) * (arg02x - arg0[2].z))) >= compare) { + if ((((D_8011D0C4->segment.trans.x_position - arg02x) * zPosDiff) - + ((arg0[0].x - arg02x) * (arg02x - arg0[2].z))) >= compare) { found3 = TRUE; } if (found2 == found3) { - f32 test = (-(((D_8011D0BC->x * D_8011D0C4->segment.trans.x_position) + (D_8011D0BC->z * D_8011D0C4->segment.trans.z_position)) + D_8011D0BC->w)) / D_8011D0BC->y; + f32 test = (-(((D_8011D0BC->x * D_8011D0C4->segment.trans.x_position) + + (D_8011D0BC->z * D_8011D0C4->segment.trans.z_position)) + + D_8011D0BC->w)) / + D_8011D0BC->y; if (D_8011D0D0 < test) { D_8011D0D0 = test; } @@ -2652,19 +2694,19 @@ GLOBAL_ASM("asm/non_matchings/tracks/func_800304C8.s") /** * Instantly update current fog properties. -*/ + */ void set_fog(s32 fogIdx, s16 near, s16 far, u8 red, u8 green, u8 blue) { s32 tempNear; FogData *fogData; - + fogData = &gFogData[fogIdx]; - + if (far < near) { tempNear = near; near = far; far = tempNear; } - + if (far > 1023) { far = 1023; } @@ -2694,7 +2736,7 @@ void set_fog(s32 fogIdx, s16 near, s16 far, u8 red, u8 green, u8 blue) { /** * Writes the current fog settings to the arguments. * Pre-shifts the data, so the raw values are correct. -*/ + */ void get_fog_settings(s32 playerID, s16 *near, s16 *far, u8 *r, u8 *g, u8 *b) { *near = gFogData[playerID].fog.near >> 16; *far = gFogData[playerID].fog.far >> 16; @@ -2706,7 +2748,7 @@ void get_fog_settings(s32 playerID, s16 *near, s16 *far, u8 *r, u8 *g, u8 *b) { /** * Sets the fog of the player ID to the default values. * Current fog attributes are rightshifted 16 bytes. -*/ + */ void reset_fog(s32 playerID) { gFogData[playerID].addFog.near = 0; gFogData[playerID].addFog.far = 0; @@ -2727,7 +2769,7 @@ void reset_fog(s32 playerID) { /** * If the fog override timer is active, apply that and slowly degrade. * Otherwise, set the current fog to the intended fog settings. -*/ + */ void update_fog(s32 viewportCount, s32 updateRate) { s32 i; for (i = 0; i < viewportCount; i++) { @@ -2753,9 +2795,10 @@ void update_fog(s32 viewportCount, s32 updateRate) { /** * Sets the fog settings for the active viewport based on the parameters of the environment data. -*/ + */ void apply_fog(s32 playerID) { - gDPSetFogColor(gSceneCurrDisplayList++, gFogData[playerID].fog.r >> 0x10, gFogData[playerID].fog.g >> 0x10, gFogData[playerID].fog.b >> 0x10, 0xFF); + gDPSetFogColor(gSceneCurrDisplayList++, gFogData[playerID].fog.r >> 0x10, gFogData[playerID].fog.g >> 0x10, + gFogData[playerID].fog.b >> 0x10, 0xFF); gSPFogPosition(gSceneCurrDisplayList++, gFogData[playerID].fog.near >> 0x10, gFogData[playerID].fog.far >> 0x10); } @@ -2763,7 +2806,7 @@ void apply_fog(s32 playerID) { * Sets the active viewport's fog target when passed through. * Used in courses to make less, or more dense. * @bug: Timer doesn't account for PAL, meaning fog will scroll 20% slower on PAL systems. -*/ + */ void obj_loop_fogchanger(Object *obj) { s32 nearTemp; s32 fogNear; @@ -2785,19 +2828,19 @@ void obj_loop_fogchanger(Object *obj) { UNUSED s32 pad2; FogData *fog; ObjectSegment *camera; - + racers = NULL; fogChanger = (LevelObjectEntry_FogChanger *) obj->segment.level_entry; camera = NULL; - + if (check_if_showing_cutscene_camera()) { camera = get_cutscene_camera_segment(); views = get_viewport_count() + 1; } else { racers = get_racer_objects(&views); } - - for(i = 0; i < views; i++) { + + for (i = 0; i < views; i++) { index = PLAYER_COMPUTER; if (racers != NULL) { racer = &racers[i]->unk64->racer; @@ -2856,26 +2899,26 @@ void obj_loop_fogchanger(Object *obj) { /** * Set the fog properties from the current values to the target, over a time specified by switchTimer. * @bug: Timer doesn't account for PAL, meaning fog will scroll 20% slower on PAL systems. -*/ + */ void slowly_change_fog(s32 fogIdx, s32 red, s32 green, s32 blue, s32 near, s32 far, s32 switchTimer) { s32 temp; FogData *fogData; fogData = &gFogData[fogIdx]; - + if (far < near) { temp = near; near = far; far = temp; } - + if (far > 1023) { far = 1023; } if (near >= far - 5) { near = far - 5; } - + fogData->intendedFog.r = red; fogData->intendedFog.g = green; fogData->intendedFog.b = blue; @@ -2892,16 +2935,17 @@ void slowly_change_fog(s32 fogIdx, s32 red, s32 green, s32 blue, s32 near, s32 f /** * Updates the stored perspective of the camera, as well as the envmap values derived from it. -*/ + */ UNUSED void update_perspective_and_envmap(void) { gSceneActiveCamera = get_active_camera_segment(); compute_scene_camera_transform_matrix(); - update_envmap_position((f32) gScenePerspectivePos.x / 65536.0f, (f32) gScenePerspectivePos.y / 65536.0f, (f32) gScenePerspectivePos.z / 65536.0f); + update_envmap_position((f32) gScenePerspectivePos.x / 65536.0f, (f32) gScenePerspectivePos.y / 65536.0f, + (f32) gScenePerspectivePos.z / 65536.0f); } /** * Take the current camera position and calculate the perspective position, for envmapping. -*/ + */ void compute_scene_camera_transform_matrix(void) { Matrix mtx; ObjectTransform trans; @@ -2921,7 +2965,7 @@ void compute_scene_camera_transform_matrix(void) { object_transform_to_matrix(mtx, &trans); guMtxXFMF(mtx, x, y, z, &x, &y, &z); - //Store x/y/z as integers + // Store x/y/z as integers gScenePerspectivePos.x = x; gScenePerspectivePos.y = y; gScenePerspectivePos.z = z; diff --git a/src/tracks.h b/src/tracks.h index a85d9f11..e175d096 100644 --- a/src/tracks.h +++ b/src/tracks.h @@ -145,15 +145,15 @@ enum WaveTypes { s32 set_scene_viewport_num(s32 numPorts); void func_800257D0(void); -void spawn_skydome(s32 arg0); +void spawn_skydome(s32 objectID); void set_skydome_visbility(s32 renderSky); void render_skydome(void); -void set_anti_aliasing(s32 settings); +void set_anti_aliasing(s32 setting); void add_segment_to_order(s32 segmentIndex, s32 *segmentsOrderIndex, u8 *segmentsOrder); s32 get_inside_segment_count_xz(s32 x, s32 z, s32 *arg2); s32 get_inside_segment_count_xyz(s32 *arg0, s16 xPos1, s16 yPos1, s16 zPos1, s16 xPos2, s16 yPos2, s16 zPos2); -LevelModelSegment *get_segment(s32 arg0); -LevelModelSegmentBoundingBox *get_segment_bounding_box(s32 arg0); +LevelModelSegment *get_segment(s32 segmentID); +LevelModelSegmentBoundingBox *get_segment_bounding_box(s32 segmentID); void func_8002ACC8(s32 arg0); s32 func_8002ACD4(f32 *arg0, f32 *arg1, f32 *arg2); s32 func_8002B9BC(Object *obj, f32 *arg1, f32 *arg2, s32 arg3); @@ -161,7 +161,7 @@ void func_8002C71C(LevelModelSegment *segment); LevelModel *get_current_level_model(void); void get_fog_settings(s32 playerID, s16 *near, s16 *far, u8 *r, u8 *g, u8 *b); void reset_fog(s32 playerID); -void update_fog(s32 playerID, s32 updateRate); +void update_fog(s32 viewportCount, s32 updateRate); void apply_fog(s32 playerID); void compute_scene_camera_transform_matrix(void); void animate_level_textures(s32 updateRate); @@ -169,13 +169,13 @@ s32 check_if_inside_segment(Object *obj, s32 segmentIndex); s32 get_level_segment_index_from_position(f32 xPos, f32 yPos, f32 zPos); void traverse_segments_bsp_tree(s32 nodeIndex, s32 segmentIndex, s32 segmentIndex2, u8 *segmentsOrder, s32 *segmentsOrderIndex); void render_level_geometry_and_objects(void); -void render_object_water_effects(Object *obj, WaterEffect *shadow); +void render_object_water_effects(Object *obj, WaterEffect *effect); void render_object_shadow(Object *obj, ShadowData *shadow); s32 should_segment_be_visible(LevelModelSegmentBoundingBox *bb); s32 check_if_in_draw_range(Object *obj); void func_8002C954(LevelModelSegment *segment, LevelModelSegmentBoundingBox *bbox, s32 arg2); void draw_gradient_background(void); -void update_shadows(s32 group, s32 waterGroup, s32 arg2); +void update_shadows(s32 group, s32 waterGroup, s32 updateRate); void obj_loop_fogchanger(Object* obj); void initialise_player_viewport_vars(s32 updateRate); s32 get_wave_properties(f32 yPos, f32 *waterHeight, Vec3f *rotation); @@ -187,7 +187,7 @@ s32 func_8002FD74(f32 x0, f32 z0, f32 x1, f32 x2, s32 count, Vec4f *arg5); void func_80026C14(s16 arg0, s16 arg1, s32 arg2); void free_track(void); -void func_8002581C(u8 *segmentIds, s32 numberOfSegments, s32 currentViewportIndex); +void func_8002581C(u8 *segmentIds, s32 numberOfSegments, s32 viewportIndex); s32 func_80027568(void); s32 func_8002CC30(LevelModelSegment*); s8 func_8002B0F4(s16, f32 xPos, f32 zPos, WaterProperties***); // Definitely not triple pointer, but easiest way to fix warns. @@ -195,7 +195,7 @@ void func_800278E8(s32); void func_80028050(void); void initialise_player_viewport_vars(s32); void func_8002A31C(void); -void update_colour_cycle(LevelHeader_70 *arg0, s32 arg1); +void update_colour_cycle(LevelHeader_70 *arg0, s32 updateRate); void func_800B9C18(s32); void func_800BA8E4(Gfx**, MatrixS**, s32); void func_8002DE30(Object*); diff --git a/src/unused_string.c b/src/unused_string.c index 8aa5034d..95520943 100644 --- a/src/unused_string.c +++ b/src/unused_string.c @@ -7,98 +7,100 @@ /** * Copy a string to a given location. * Return the address of the destrination. -*/ + */ UNUSED char *strcpy(char *src, const char *dest) { char *ret = src; - while ((*src++ = *dest++) != '\0'); + while ((*src++ = *dest++) != '\0') {} return ret; } /** * Append a string to the end of a given string. * Return the address of the destrination. -*/ + */ UNUSED char *strcat(char *dest, const char *src) { char *ret = dest; - - while (*dest != '\0') dest++; - while ((*dest++ = *src++) != '\0'); - + + while (*dest != '\0') { + dest++; + } + while ((*dest++ = *src++) != '\0') {} + return ret; } /** * Compare two strings, with no case sensitivity. * Return zero if they match. -*/ + */ UNUSED int strcasecmp(const char *s1, const char *s2) { - unsigned char c1; - unsigned char c2; + unsigned char c1; + unsigned char c2; - while (*s1 || *s2) { - c1 = *s1; - - if (c1 >= 'a' && c1 <= 'z') { - c1 -= 0x20; - } + while (*s1 || *s2) { + c1 = *s1; - c2 = *s2; - - if (c2 >= 'a' && c2 <= 'z') { - c2 -= 0x20; - } + if (c1 >= 'a' && c1 <= 'z') { + c1 -= 0x20; + } - if (c1 < c2) { - return -1; - } + c2 = *s2; - if (c2 < c1) { - return 1; - } + if (c2 >= 'a' && c2 <= 'z') { + c2 -= 0x20; + } - s1++; - s2++; - } - - return 0; + if (c1 < c2) { + return -1; + } + + if (c2 < c1) { + return 1; + } + + s1++; + s2++; + } + + return 0; } /** * Compare an arbitrary amount of characters in two strings, with no case sensitivity. * Return zero if they match. -*/ + */ UNUSED int strncasecmp(const char *s1, const char *s2, size_t n) { - unsigned char c1; - unsigned char c2; + unsigned char c1; + unsigned char c2; - while ((*s1 || *s2) && n) { - c1 = *s1; - - if (c1 >= 'a' && c1 <= 'z') { - c1 -= 0x20; - } + while ((*s1 || *s2) && n) { + c1 = *s1; - c2 = *s2; - - if (c2 >= 'a' && c2 <= 'z') { - c2 -= 0x20; - } + if (c1 >= 'a' && c1 <= 'z') { + c1 -= 0x20; + } - if (c1 < c2) { - return -1; - } + c2 = *s2; - if (c2 < c1) { - return 1; - } + if (c2 >= 'a' && c2 <= 'z') { + c2 -= 0x20; + } - s1++; - s2++; + if (c1 < c2) { + return -1; + } + + if (c2 < c1) { + return 1; + } + + s1++; + s2++; n--; - } + } - return 0; + return 0; } /** diff --git a/src/vehicle_bluey.c b/src/vehicle_bluey.c index f30b532b..208bc8af 100644 --- a/src/vehicle_bluey.c +++ b/src/vehicle_bluey.c @@ -42,18 +42,13 @@ s8 gBlueyStartBoost; /******************************/ -enum BlueAnimations { - ANIM_BLUEY_RUN, - ANIM_BLUEY_WALK, - ANIM_BLUEY_IDLE, - ANIM_BLUEY_TURN, - ANIM_BLUEY_DAMAGE -}; +enum BlueAnimations { ANIM_BLUEY_RUN, ANIM_BLUEY_WALK, ANIM_BLUEY_IDLE, ANIM_BLUEY_TURN, ANIM_BLUEY_DAMAGE }; /** * Top level function for the Bluey vehicle, as seen in the Snowflake Mountain boss stage. -*/ -void update_bluey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, u32 *buttonsPressed, s32 *startTimer) { + */ +void update_bluey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, u32 *buttonsPressed, + s32 *startTimer) { s16 animID; s16 animFrame; s16 tempHeadAngle; @@ -84,7 +79,7 @@ void update_bluey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *ra if (racer->playerIndex == PLAYER_COMPUTER) { if (*startTimer != 100) { *startTimer -= 15; - if (*startTimer < 0) { + if (*startTimer < 0) { if (gBlueyStartBoost == FALSE) { play_random_boss_sound(BOSS_SOUND_POSITIVE); racer->boostTimer = 3; @@ -97,7 +92,7 @@ void update_bluey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *ra } } } - + func_8004F7F4(updateRate, updateRateF, obj, racer); *startTimer = tempStartTimer; racer->lateral_velocity = 0.0f; @@ -201,7 +196,8 @@ void update_bluey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *ra racer->headAngleTarget = 0; } racer = (Object_Racer *) firstRacerObj->unk64; - if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && obj->segment.object.animationID == ANIM_BLUEY_WALK) { + if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && + obj->segment.object.animationID == ANIM_BLUEY_WALK) { racer->attackType = ATTACK_SQUISHED; } if (racer->raceFinished) { diff --git a/src/vehicle_bubbler.c b/src/vehicle_bubbler.c index 54cada0e..7878d3bb 100644 --- a/src/vehicle_bubbler.c +++ b/src/vehicle_bubbler.c @@ -41,17 +41,15 @@ s8 gBubblerStartBoost; /******************************/ -enum BubblerAnimations { - ANIM_BUBBLER_IDLE, - ANIM_BUBBLER_MOVE, - ANIM_BUBBLER_DAMAGE -}; +enum BubblerAnimations { ANIM_BUBBLER_IDLE, ANIM_BUBBLER_MOVE, ANIM_BUBBLER_DAMAGE }; /** * Top level function for updating the "Bubbler" vehicle. - * Basically this controls the Bubbler boss on Sherbert Island, who follows a path, then throws special tripmines and bubble traps on the course. -*/ -void update_bubbler(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, u32 *buttonsPressed, s32 *startTimer) { + * Basically this controls the Bubbler boss on Sherbert Island, who follows a path, then throws special tripmines and + * bubble traps on the course. + */ +void update_bubbler(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, u32 *buttonsPressed, + s32 *startTimer) { s16 animID; s16 animFrame; s16 tempHeadAngle; @@ -65,7 +63,7 @@ void update_bubbler(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer * Object *firstRacerObj; f32 diffX; s32 temp2; - + set_boss_voice_clip_offset(gBubblerVoiceTable); *buttonsPressed &= ~R_TRIG; *input &= ~R_TRIG; @@ -148,15 +146,15 @@ void update_bubbler(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer * func_800AFC3C(obj, updateRate); fade_when_near_camera(obj, racer, 40); switch (obj->segment.object.animationID) { - case ANIM_BUBBLER_MOVE: - headAngleRange = 0x2500; - break; - case ANIM_BUBBLER_DAMAGE: - headAngleRange = 0x100; - break; - default: - headAngleRange = 0x1500; - break; + case ANIM_BUBBLER_MOVE: + headAngleRange = 0x2500; + break; + case ANIM_BUBBLER_DAMAGE: + headAngleRange = 0x100; + break; + default: + headAngleRange = 0x1500; + break; } firstRacerObj = get_racer_object(PLAYER_ONE); diffX = firstRacerObj->segment.trans.x_position - obj->segment.trans.x_position; @@ -173,13 +171,14 @@ void update_bubbler(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer * } } racer = (Object_Racer *) firstRacerObj->unk64; - if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && obj->segment.object.animationID == ANIM_BUBBLER_MOVE) { + if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && + obj->segment.object.animationID == ANIM_BUBBLER_MOVE) { racer->attackType = ATTACK_SQUISHED; } if (racer->raceFinished) { if (gBubblerCutsceneTimer == 0) { - gBubblerCutsceneTimer = 1; - func_8005CB68(racer, &gBubblerCutsceneTimer); + gBubblerCutsceneTimer = 1; + func_8005CB68(racer, &gBubblerCutsceneTimer); } } } diff --git a/src/vehicle_misc.h b/src/vehicle_misc.h index c65d8b9f..a1a7e820 100644 --- a/src/vehicle_misc.h +++ b/src/vehicle_misc.h @@ -16,8 +16,8 @@ void update_rocket(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r void spawn_boss_hazard(Object *obj, Object_Racer *racer, f32 offset, s32 objectID, s32 soundID); void racer_special_init(Object *object, Object_Racer *racer); void set_boss_voice_clip_offset(u16 *soundID); -void func_8005CA84(f32 x, f32 y, f32 z, s32 arg3); -void play_random_boss_sound(s32 arg0); +void func_8005CA84(f32 x, f32 y, f32 z, s32 offset); +void play_random_boss_sound(s32 offset); void fade_when_near_camera(Object *object, Object_Racer *racer, s32 distance); void func_8005CB68(Object_Racer *racer, s8 *arg1); diff --git a/src/vehicle_rocket.c b/src/vehicle_rocket.c index 2eb5ab0f..b0004f44 100644 --- a/src/vehicle_rocket.c +++ b/src/vehicle_rocket.c @@ -13,22 +13,15 @@ /************ .data ************/ -//sSoundEffectsPool index values? +// sSoundEffectsPool index values? s16 gRocketVoiceTable[14] = { - SOUND_VOICE_BOSS_LAUGH2, - SOUND_VOICE_TRICKY_HM, - SOUND_VOICE_TRICKY_HMMM, - SOUND_VOICE_WIZPIG_LAUGH4, - SOUND_VOICE_WIZPIG_LAUGH2, - SOUND_VOICE_WIZPIG_GROAN, - SOUND_VOICE_WIZPIG_LAUGH3, - SOUND_VOICE_SMOKEY_HAH, - SOUND_VOICE_SMOKEY_LAUGH, - SOUND_VOICE_SMOKEY_HM, - SOUND_VOICE_SMOKEY_HM2, - SOUND_VOICE_CONKER_YEHAHA, - SOUND_VOICE_TIMBER_WOW, - SOUND_WHOOSH2 + SOUND_VOICE_BOSS_LAUGH2, SOUND_VOICE_TRICKY_HM, + SOUND_VOICE_TRICKY_HMMM, SOUND_VOICE_WIZPIG_LAUGH4, + SOUND_VOICE_WIZPIG_LAUGH2, SOUND_VOICE_WIZPIG_GROAN, + SOUND_VOICE_WIZPIG_LAUGH3, SOUND_VOICE_SMOKEY_HAH, + SOUND_VOICE_SMOKEY_LAUGH, SOUND_VOICE_SMOKEY_HM, + SOUND_VOICE_SMOKEY_HM2, SOUND_VOICE_CONKER_YEHAHA, + SOUND_VOICE_TIMBER_WOW, SOUND_WHOOSH2, }; /*******************************/ @@ -40,15 +33,13 @@ s8 gRocketStartBoost; /******************************/ -enum RocketAnimations { - ANIM_ROCKET_IDLE, - ANIM_ROCKET_DAMAGE -}; +enum RocketAnimations { ANIM_ROCKET_IDLE, ANIM_ROCKET_DAMAGE }; /** * Top level update function for the Wizpig Rocket vehicle, used in the Wizpig rematch. -*/ -void update_rocket(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, u32 *buttonsPressed, s32 *startTimer) { + */ +void update_rocket(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, u32 *buttonsPressed, + s32 *startTimer) { s16 animID; s16 animFrame; s16 tempHeadAngle; @@ -61,7 +52,7 @@ void update_rocket(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r Object_68 *gfxData; ObjectModel *objModel; - set_boss_voice_clip_offset((u16* ) gRocketVoiceTable); + set_boss_voice_clip_offset((u16 *) gRocketVoiceTable); racer->unk1EC = 0; animID = obj->segment.object.animationID; animFrame = obj->segment.animFrame; @@ -158,7 +149,8 @@ void update_rocket(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r } firstRacerObj = get_racer_object(PLAYER_ONE); racer = (Object_Racer *) firstRacerObj->unk64; - if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && obj->segment.object.animationID == ANIM_ROCKET_DAMAGE) { + if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && + obj->segment.object.animationID == ANIM_ROCKET_DAMAGE) { racer->attackType = ATTACK_SQUISHED; } if (racer->raceFinished != 0) { diff --git a/src/vehicle_smokey.c b/src/vehicle_smokey.c index 8e5f941a..167654cd 100644 --- a/src/vehicle_smokey.c +++ b/src/vehicle_smokey.c @@ -54,8 +54,9 @@ enum SmokeyAnimations { /** * Top level function for updating the "Smokey" vehicle as seen in the Dragon Forest boss stage. * Also controls the pteradactyl found in Dino domain, from when it had a larger role ingame. -*/ -void update_smokey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, s32 *stickMag, s32 *startTimer) { + */ +void update_smokey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, s32 *stickMag, + s32 *startTimer) { s16 animID; s16 animFrame; s16 tempHeadAngle; @@ -68,7 +69,7 @@ void update_smokey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r UNUSED s32 pad; s16 stepFrame; Object *firstRacerObj; - + set_boss_voice_clip_offset(gSmokeyVoiceTable); animID = obj->segment.object.animationID; animFrame = obj->segment.animFrame; @@ -134,44 +135,43 @@ void update_smokey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r animVelocity = (racer->velocity * updateRateF) * 0.45; if (animVelocity <= 0.0) { if (animVelocity > -2.0) { - animVelocity = -2.0f; + animVelocity = -2.0f; } } else if (animVelocity < 2.0) { animVelocity = 2.0f; } switch (obj->segment.object.animationID) { - case 0: - racer->unk1CD = 0; - racer->animationSpeed += 1.0 * updateRateF; - break; - case 1: - if (racer->unk1CD == 2) { - racer->animationSpeed += animVelocity; - } else { + case 0: + racer->unk1CD = 0; + racer->animationSpeed += 1.0 * updateRateF; + break; + case 1: + if (racer->unk1CD == 2) { + racer->animationSpeed += animVelocity; + } else { + racer->animationSpeed -= animVelocity; + } + break; + case 2: + racer->unk1CD = 2; racer->animationSpeed -= animVelocity; - } - break; - case 2: - racer->unk1CD = 2; - racer->animationSpeed -= animVelocity; - break; - case 3: - if (racer->unk1CD == 4) { - racer->animationSpeed -= 2.0 * updateRateF; - } - else { + break; + case 3: + if (racer->unk1CD == 4) { + racer->animationSpeed -= 2.0 * updateRateF; + } else { + racer->animationSpeed += 2.0 * updateRateF; + } + break; + case 4: + racer->unk1CD = 4; racer->animationSpeed += 2.0 * updateRateF; - } - break; - case 4: - racer->unk1CD = 4; - racer->animationSpeed += 2.0 * updateRateF; - break; - case 5: - racer->animationSpeed += 2.0 * updateRateF; - break; - default: - break; + break; + case 5: + racer->animationSpeed += 2.0 * updateRateF; + break; + default: + break; } while (diffX <= racer->animationSpeed) { racer->animationSpeed -= diffX; @@ -230,7 +230,8 @@ void update_smokey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r stepFrame = 3; } if (animFrame == stepFrame && stepFrame + 1 == obj->segment.animFrame >> 4) { - play_sound_at_position(SOUND_UNK_223, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + play_sound_at_position(SOUND_UNK_223, obj->segment.trans.x_position, obj->segment.trans.y_position, + obj->segment.trans.z_position, 4, NULL); } } if (racer->vehicleIDPrev == VEHICLE_SMOKEY && racer->playerIndex == PLAYER_COMPUTER && func_80023568()) { @@ -263,7 +264,8 @@ void update_smokey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r } } racer = (Object_Racer *) firstRacerObj->unk64; - if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && obj->segment.object.animationID == ANIM_SMOKEY_RUN) { + if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && + obj->segment.object.animationID == ANIM_SMOKEY_RUN) { racer->attackType = ATTACK_SQUISHED; } if (racer->raceFinished != FALSE) { @@ -277,7 +279,7 @@ void update_smokey(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r /** * Compare distance to any boss hazard triggers found throughout the course. * When close enough to one, spawn a hazard, set by the caller of the function. -*/ + */ void spawn_boss_hazard(Object *obj, Object_Racer *racer, f32 offset, s32 objectID, s32 soundID) { Object **objList; s32 objListID; @@ -297,16 +299,17 @@ void spawn_boss_hazard(Object *obj, Object_Racer *racer, f32 offset, s32 objectI spawnObj.x = obj->segment.trans.x_position - (racer->ox1 * offset); spawnObj.y = obj->segment.trans.y_position - (racer->oy1 * offset); spawnObj.z = obj->segment.trans.z_position - (racer->oz1 * offset); - + for (i = 0; i < objListCount; i++) { tempObj = objList[i]; if (tempObj->behaviorId == BHV_BOSS_HAZARD_TRIGGER) { - entry = tempObj->segment.level_entry; + entry = tempObj->segment.level_entry; if ((s8) entry->animation.z_rotation == racer->lap + 1 || (s8) entry->animation.z_rotation == 0) { diffX = tempObj->segment.trans.x_position - obj->segment.trans.x_position; diffY = tempObj->segment.trans.y_position - obj->segment.trans.y_position; diffZ = tempObj->segment.trans.z_position - obj->segment.trans.z_position; - if (sqrtf((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)) < (f32) ((s8) entry->animation.x_rotation & 0xFF) * 4.0) { + if (sqrtf((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ)) < + (f32) ((s8) entry->animation.x_rotation & 0xFF) * 4.0) { if (tempObj->properties.racer.unk0 == 0) { tempObj->properties.racer.unk0 = (Object *) 1; // ??? newObj = spawn_object(&spawnObj, 1); @@ -318,7 +321,9 @@ void spawn_boss_hazard(Object *obj, Object_Racer *racer, f32 offset, s32 objectI newObj->properties.racer.unk0 = tempObj; newObj->properties.racer.unk4 = (s8) entry->animation.y_rotation * 60; newObj->segment.animFrame = get_random_number_from_range(0, 255); - play_sound_at_position(soundID, newObj->segment.trans.x_position, newObj->segment.trans.y_position, newObj->segment.trans.z_position, 4, NULL); + play_sound_at_position(soundID, newObj->segment.trans.x_position, + newObj->segment.trans.y_position, newObj->segment.trans.z_position, + 4, NULL); } } } else { diff --git a/src/vehicle_tricky.c b/src/vehicle_tricky.c index bd651862..eb72a489 100644 --- a/src/vehicle_tricky.c +++ b/src/vehicle_tricky.c @@ -33,7 +33,7 @@ u16 gTrickyVoiceTable[16] = { SOUND_VOICE_TIMBER_WOW, SOUND_WHOOSH2, SOUND_NONE, - SOUND_NONE + SOUND_NONE, }; /*******************************/ @@ -47,17 +47,12 @@ s8 gTrickyStartBoost; /******************************/ -enum TrickyAnimations { - ANIM_TRICKY_IDLE, - ANIM_TRICKY_RUN, - ANIM_TRICKY_WALK, - ANIM_TRICKY_DAMAGE -}; +enum TrickyAnimations { ANIM_TRICKY_IDLE, ANIM_TRICKY_RUN, ANIM_TRICKY_WALK, ANIM_TRICKY_DAMAGE }; /** * Overrides some basic racer properties that are either not needed or intended to work differently. * Also frees the engine sound data, since it won't be used. -*/ + */ void racer_special_init(Object *object, Object_Racer *racer) { object->interactObj->flags = INTERACT_FLAGS_SOLID | INTERACT_FLAGS_UNK_0004; object->interactObj->unk11 = 0; @@ -73,8 +68,9 @@ void racer_special_init(Object *object, Object_Racer *racer) { /** * Top level function for updating the Tricky vehicle as seen in the Dino Domain boss. -*/ -void update_tricky(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, u32 *buttonsPressed, s32 *startTimer) { + */ +void update_tricky(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, u32 *buttonsPressed, + s32 *startTimer) { s16 animID; s16 animFrame; s16 tempHeadAngle; @@ -114,7 +110,7 @@ void update_tricky(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r } } } - + func_8004F7F4(updateRate, updateRateF, obj, racer); *startTimer = tempStartTimer; racer->lateral_velocity = 0.0f; @@ -174,7 +170,7 @@ void update_tricky(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r } func_800AFC3C(obj, updateRate); fade_when_near_camera(obj, racer, 120); - switch( obj->segment.object.animationID) { + switch (obj->segment.object.animationID) { case ANIM_TRICKY_RUN: headAngleRange = 0x2500; break; @@ -210,7 +206,8 @@ void update_tricky(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r } func_8006F140(1); } - if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && obj->segment.object.animationID == ANIM_TRICKY_RUN) { + if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && + obj->segment.object.animationID == ANIM_TRICKY_RUN) { racer->attackType = ATTACK_SQUISHED; } if (racer->raceFinished != FALSE) { @@ -223,7 +220,7 @@ void update_tricky(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r /** * Set the sound ID offset for a given boss clip. -*/ + */ void set_boss_voice_clip_offset(u16 *soundID) { gBossSoundIDOffset = soundID; } @@ -239,7 +236,7 @@ void func_8005CA84(f32 x, f32 y, f32 z, s32 offset) { /** * Add a random amount to offset, then play a random voice clip within that range. -*/ + */ void play_random_boss_sound(s32 offset) { s8 randomOffset = get_random_number_from_range(0, 1); if (offset == 0) { @@ -276,11 +273,12 @@ void func_8005CB68(Object_Racer *racer, s8 *arg1) { ASSET_LEVELNAME_LASTBIT, ASSET_LEVELNAME_LASTBITB */ - asset = (s8 *) get_misc_asset(ASSET_MISC_68); //8 bytes - 2F 31 30 32 2A 38 3F 40 - LevelIds for the world animations? - miscAsset68Byte5 = asset[5]; //0x38 - 56 - ASSET_LEVELNAME_PARTYSEQUENCE? - miscAsset68Byte6 = asset[6]; //0x3F - 63 - ASSET_LEVELNAME_LASTBIT? - miscAsset68Byte7 = asset[7]; //0x40 - 64 - ASSET_LEVELNAME_LASTBITB? - asset = (s8 *) get_misc_asset(ASSET_MISC_67); //20 bytes - course id's array with world id index? + asset = + (s8 *) get_misc_asset(ASSET_MISC_68); // 8 bytes - 2F 31 30 32 2A 38 3F 40 - LevelIds for the world animations? + miscAsset68Byte5 = asset[5]; // 0x38 - 56 - ASSET_LEVELNAME_PARTYSEQUENCE? + miscAsset68Byte6 = asset[6]; // 0x3F - 63 - ASSET_LEVELNAME_LASTBIT? + miscAsset68Byte7 = asset[7]; // 0x40 - 64 - ASSET_LEVELNAME_LASTBITB? + asset = (s8 *) get_misc_asset(ASSET_MISC_67); // 20 bytes - course id's array with world id index? for (i = 0; settings->courseId != asset[i]; i += 2) {} i = asset[i + 1]; racerUnk1AC = racer->unk1AC; @@ -305,7 +303,7 @@ void func_8005CB68(Object_Racer *racer, s8 *arg1) { push_level_property_stack(i, 0, -1, 2); } } else if (racerUnk1AC == 1) { - set_eeprom_settings_value(1); //Set Adventure Two Unlocked + set_eeprom_settings_value(1); // Set Adventure Two Unlocked push_level_property_stack(SPECIAL_MAP_ID_UNK_NEG2, 0, VEHICLE_CAR, 0); push_level_property_stack(miscAsset68Byte7, 0, -1, 0); push_level_property_stack(miscAsset68Byte6, 0, -1, 0); @@ -358,7 +356,8 @@ void func_8005CB68(Object_Racer *racer, s8 *arg1) { } if (worldBit != 0) { push_level_property_stack(SPECIAL_MAP_ID_NO_LEVEL, 0, VEHICLE_CAR, 0); - push_level_property_stack(ASSET_LEVELNAME_WIZPIGAMULETSEQUENCE, 0, -1, settings->wizpigAmulet - 1); + push_level_property_stack(ASSET_LEVELNAME_WIZPIGAMULETSEQUENCE, 0, -1, + settings->wizpigAmulet - 1); push_level_property_stack(i, 6, -1, 6); } else { push_level_property_stack(SPECIAL_MAP_ID_NO_LEVEL, 0, VEHICLE_CAR, 0); diff --git a/src/vehicle_wizpig.c b/src/vehicle_wizpig.c index a055fe0d..beb99bc5 100644 --- a/src/vehicle_wizpig.c +++ b/src/vehicle_wizpig.c @@ -13,20 +13,13 @@ /************ .data ************/ s16 gWizpigVoiceTable[14] = { - SOUND_VOICE_BOSS_LAUGH2, - SOUND_VOICE_TRICKY_HM, - SOUND_VOICE_TRICKY_HMMM, - SOUND_VOICE_WIZPIG_LAUGH4, - SOUND_VOICE_WIZPIG_LAUGH2, - SOUND_VOICE_WIZPIG_GROAN, - SOUND_VOICE_WIZPIG_LAUGH3, - SOUND_VOICE_SMOKEY_HAH, - SOUND_VOICE_SMOKEY_LAUGH, - SOUND_VOICE_SMOKEY_HM, - SOUND_VOICE_SMOKEY_HM2, - SOUND_VOICE_CONKER_YEHAHA, - SOUND_VOICE_TIMBER_WOW, - SOUND_WHOOSH2 + SOUND_VOICE_BOSS_LAUGH2, SOUND_VOICE_TRICKY_HM, + SOUND_VOICE_TRICKY_HMMM, SOUND_VOICE_WIZPIG_LAUGH4, + SOUND_VOICE_WIZPIG_LAUGH2, SOUND_VOICE_WIZPIG_GROAN, + SOUND_VOICE_WIZPIG_LAUGH3, SOUND_VOICE_SMOKEY_HAH, + SOUND_VOICE_SMOKEY_LAUGH, SOUND_VOICE_SMOKEY_HM, + SOUND_VOICE_SMOKEY_HM2, SOUND_VOICE_CONKER_YEHAHA, + SOUND_VOICE_TIMBER_WOW, SOUND_WHOOSH2, }; /*******************************/ @@ -49,8 +42,9 @@ enum WizpigAnimations { /** * Top level function for updating the wizpig vehicle from the first boss race against him. -*/ -void update_wizpig(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, u32 *buttonsPressed, s32 *startTimer) { + */ +void update_wizpig(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *racer, u32 *input, u32 *buttonsPressed, + s32 *startTimer) { s16 animID; s16 animFrame; s16 tempHeadAngle; @@ -63,7 +57,7 @@ void update_wizpig(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r ObjectModel *objModel; Object_68 *gfxData; - set_boss_voice_clip_offset((u16* ) gWizpigVoiceTable); + set_boss_voice_clip_offset((u16 *) gWizpigVoiceTable); racer->unk1EC = 0; animID = obj->segment.object.animationID; animFrame = obj->segment.animFrame; @@ -144,44 +138,44 @@ void update_wizpig(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r animVelocity = 2.0f; } switch (obj->segment.object.animationID) { - case ANIM_WIZPIG_IDLE: - racer->unk1CD = 0; - racer->animationSpeed += 1.0 * updateRateF; - break; - case ANIM_WIZPIG_WALK: - if (racer->unk1CD == 2) { - racer->animationSpeed += animVelocity; - } else { + case ANIM_WIZPIG_IDLE: + racer->unk1CD = 0; + racer->animationSpeed += 1.0 * updateRateF; + break; + case ANIM_WIZPIG_WALK: + if (racer->unk1CD == 2) { + racer->animationSpeed += animVelocity; + } else { + racer->animationSpeed -= animVelocity; + } + break; + case ANIM_WIZPIG_RUN: + racer->unk1CD = 2; racer->animationSpeed -= animVelocity; - } - break; - case ANIM_WIZPIG_RUN: - racer->unk1CD = 2; - racer->animationSpeed -= animVelocity; - break; - case ANIM_WIZPIG_JUMP: - if (racer->unk1CD == 4) { - racer->animationSpeed -= 2.0 * updateRateF; - } else { + break; + case ANIM_WIZPIG_JUMP: + if (racer->unk1CD == 4) { + racer->animationSpeed -= 2.0 * updateRateF; + } else { + racer->animationSpeed += 2.0 * updateRateF; + } + break; + case ANIM_WIZPIG_FLY: + racer->unk1CD = 4; racer->animationSpeed += 2.0 * updateRateF; - } - break; - case ANIM_WIZPIG_FLY: - racer->unk1CD = 4; - racer->animationSpeed += 2.0 * updateRateF; - break; - case ANIM_WIZPIG_DAMAGE: - racer->animationSpeed += 2.0 * updateRateF; - break; - default: - break; + break; + case ANIM_WIZPIG_DAMAGE: + racer->animationSpeed += 2.0 * updateRateF; + break; + default: + break; } - + while (diffX <= racer->animationSpeed) { racer->animationSpeed -= diffX; gfxData->animationID = -1; } - while (racer->animationSpeed <= 0.0f){ + while (racer->animationSpeed <= 0.0f) { racer->animationSpeed += diffX; gfxData->animationID = -1; } @@ -240,7 +234,8 @@ void update_wizpig(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r fade_when_near_camera(obj, racer, 40); firstRacerObj = get_racer_object(PLAYER_ONE); racer = (Object_Racer *) firstRacerObj->unk64; - if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && obj->segment.object.animationID == ANIM_WIZPIG_WALK) { + if (obj == firstRacerObj->interactObj->obj && firstRacerObj->interactObj->flags & INTERACT_FLAGS_PUSHING && + obj->segment.object.animationID == ANIM_WIZPIG_WALK) { racer->attackType = ATTACK_SQUISHED; } if (racer->raceFinished) { diff --git a/src/video.c b/src/video.c index a01a2334..18a8cf4e 100644 --- a/src/video.c +++ b/src/video.c @@ -11,10 +11,10 @@ UNUSED s32 D_800DE774 = 0; UNUSED s8 D_800DE778 = 2; VideoModeResolution gVideoModeResolutions[] = { - { SCREEN_WIDTH, SCREEN_HEIGHT }, // 320x240 - { SCREEN_WIDTH, SCREEN_HEIGHT }, // 320x240 - { HIGH_RES_SCREEN_WIDTH, SCREEN_HEIGHT }, // 640x240 - { HIGH_RES_SCREEN_WIDTH, SCREEN_HEIGHT }, // 640x240 + { SCREEN_WIDTH, SCREEN_HEIGHT }, // 320x240 + { SCREEN_WIDTH, SCREEN_HEIGHT }, // 320x240 + { HIGH_RES_SCREEN_WIDTH, SCREEN_HEIGHT }, // 640x240 + { HIGH_RES_SCREEN_WIDTH, SCREEN_HEIGHT }, // 640x240 { HIGH_RES_SCREEN_WIDTH, HIGH_RES_SCREEN_HEIGHT }, // 640x480 { HIGH_RES_SCREEN_WIDTH, HIGH_RES_SCREEN_HEIGHT }, // 640x480 { HIGH_RES_SCREEN_WIDTH, HIGH_RES_SCREEN_HEIGHT }, // 640x480 @@ -28,7 +28,7 @@ VideoModeResolution gVideoModeResolutions[] = { /************ .bss ************/ -s32 gVideoRefreshRate; //Official Name: viFramesPerSecond +s32 gVideoRefreshRate; // Official Name: viFramesPerSecond f32 gVideoAspectRatio; f32 gVideoHeightRatio; UNUSED s32 D_8012617C; @@ -41,10 +41,10 @@ u16 *gVideoFramebuffers[2]; s32 gVideoCurrFbIndex; s32 gVideoModeIndex; s32 sBlackScreenTimer; -u16 *gVideoCurrFramebuffer; //Official Name: currentScreen -u16 *gVideoLastFramebuffer; //Official Name: otherScreen +u16 *gVideoCurrFramebuffer; // Official Name: currentScreen +u16 *gVideoLastFramebuffer; // Official Name: otherScreen u16 *gVideoCurrDepthBuffer; -u16 *gVideoLastDepthBuffer; //Official Name: otherZbuf +u16 *gVideoLastDepthBuffer; // Official Name: otherZbuf u8 D_801262E4; UNUSED OSMesg D_801262E8[8]; u8 gVideoDeltaCounter; @@ -89,8 +89,8 @@ void init_video(s32 videoModeIndex, OSSched *sc) { init_framebuffer(1); gVideoCurrFbIndex = 1; swap_framebuffers(); - osCreateMesgQueue((OSMesgQueue *)&gVideoMesgQueue, gVideoMesgBuf, ARRAY_COUNT(gVideoMesgBuf)); - osScAddClient(sc, &gVideoSched, (OSMesgQueue *)&gVideoMesgQueue, OS_SC_ID_VIDEO); + osCreateMesgQueue((OSMesgQueue *) &gVideoMesgQueue, gVideoMesgBuf, ARRAY_COUNT(gVideoMesgBuf)); + osScAddClient(sc, &gVideoSched, (OSMesgQueue *) &gVideoMesgQueue, OS_SC_ID_VIDEO); init_vi_settings(); sBlackScreenTimer = 12; osViBlack(TRUE); @@ -154,9 +154,9 @@ void init_vi_settings(void) { break; case VIDEO_MODE_LOWRES_LPN: //@bug: The video mode being set here is Point sampled - //but the printf implies it was intended to be Anti-aliased. - //By my understanding, this is the case we will always hit in code, - //So maybe it was swapped out late in development? + // but the printf implies it was intended to be Anti-aliased. + // By my understanding, this is the case we will always hit in code, + // So maybe it was swapped out late in development? stubbed_printf("320 by 240 Anti-aliased, Non interlaced.\n"); tvViMode = &osViModeNtscLpn1; if (osTvType == TV_TYPE_PAL) { @@ -164,9 +164,9 @@ void init_vi_settings(void) { } else if (osTvType == TV_TYPE_MPAL) { tvViMode = &osViModeMpalLpn1; } - memory_copy((u8 *)tvViMode, (u8 *)&gTvViMode, sizeof(OSViMode)); + memory_copy((u8 *) tvViMode, (u8 *) &gTvViMode, sizeof(OSViMode)); if (osTvType == TV_TYPE_PAL) { - //A simple osViExtendVStart to add an additional 24 scanlines? + // A simple osViExtendVStart to add an additional 24 scanlines? gTvViMode.fldRegs[0].vStart -= (PAL_HEIGHT_DIFFERENCE << 16); gTvViMode.fldRegs[1].vStart -= (PAL_HEIGHT_DIFFERENCE << 16); gTvViMode.fldRegs[0].vStart += PAL_HEIGHT_DIFFERENCE; @@ -183,7 +183,7 @@ void init_vi_settings(void) { tvViMode = &osViModeMpalLpn1; } - memory_copy((u8 *)tvViMode, (u8 *)&gTvViMode, sizeof(OSViMode)); + memory_copy((u8 *) tvViMode, (u8 *) &gTvViMode, sizeof(OSViMode)); gTvViMode.comRegs.width = WIDTH(HIGH_RES_SCREEN_WIDTH); gTvViMode.comRegs.xScale = SCALE(1, 0); gTvViMode.fldRegs[0].origin = ORIGIN(HIGH_RES_SCREEN_WIDTH * 2); @@ -198,7 +198,7 @@ void init_vi_settings(void) { } else if (osTvType == TV_TYPE_MPAL) { tvViMode = &osViModeMpalLan1; } - memory_copy((u8 *)tvViMode, (u8 *)&gTvViMode, sizeof(OSViMode)); + memory_copy((u8 *) tvViMode, (u8 *) &gTvViMode, sizeof(OSViMode)); gTvViMode.comRegs.width = WIDTH(HIGH_RES_SCREEN_WIDTH); gTvViMode.comRegs.xScale = SCALE(1, 0); gTvViMode.fldRegs[0].origin = ORIGIN(HIGH_RES_SCREEN_WIDTH * 2); @@ -233,24 +233,28 @@ void init_vi_settings(void) { */ void init_framebuffer(s32 index) { if (gVideoFramebuffers[index] != 0) { - memory_slot_exists((u8 *)gVideoFramebuffers[index]); // Effectively unused. + memory_slot_exists((u8 *) gVideoFramebuffers[index]); // Effectively unused. free_from_memory_pool(gVideoFramebuffers[index]); } gVideoFbWidths[index] = gVideoModeResolutions[gVideoModeIndex & NUM_RESOLUTION_MODES].width; gVideoFbHeights[index] = gVideoModeResolutions[gVideoModeIndex & NUM_RESOLUTION_MODES].height; if (gVideoModeIndex >= VIDEO_MODE_MIDRES_MASK) { - gVideoFramebuffers[index] = allocate_from_main_pool_safe((HIGH_RES_SCREEN_WIDTH * HIGH_RES_SCREEN_HEIGHT * 2) + 0x30, COLOUR_TAG_WHITE); - gVideoFramebuffers[index] = (u16 *)(((s32)gVideoFramebuffers[index] + 0x3F) & ~0x3F); + gVideoFramebuffers[index] = + allocate_from_main_pool_safe((HIGH_RES_SCREEN_WIDTH * HIGH_RES_SCREEN_HEIGHT * 2) + 0x30, COLOUR_TAG_WHITE); + gVideoFramebuffers[index] = (u16 *) (((s32) gVideoFramebuffers[index] + 0x3F) & ~0x3F); if (gVideoDepthBuffer == NULL) { - gVideoDepthBuffer = allocate_from_main_pool_safe((HIGH_RES_SCREEN_WIDTH * HIGH_RES_SCREEN_HEIGHT * 2) + 0x30, COLOUR_TAG_WHITE); - gVideoDepthBuffer = (u16 *)(((s32)gVideoDepthBuffer + 0x3F) & ~0x3F); + gVideoDepthBuffer = allocate_from_main_pool_safe( + (HIGH_RES_SCREEN_WIDTH * HIGH_RES_SCREEN_HEIGHT * 2) + 0x30, COLOUR_TAG_WHITE); + gVideoDepthBuffer = (u16 *) (((s32) gVideoDepthBuffer + 0x3F) & ~0x3F); } } else { - gVideoFramebuffers[index] = allocate_from_main_pool_safe((gVideoFbWidths[index] * gVideoFbHeights[index] * 2) + 0x30, COLOUR_TAG_WHITE); - gVideoFramebuffers[index] = (u16 *)(((s32)gVideoFramebuffers[index] + 0x3F) & ~0x3F); + gVideoFramebuffers[index] = + allocate_from_main_pool_safe((gVideoFbWidths[index] * gVideoFbHeights[index] * 2) + 0x30, COLOUR_TAG_WHITE); + gVideoFramebuffers[index] = (u16 *) (((s32) gVideoFramebuffers[index] + 0x3F) & ~0x3F); if (gVideoDepthBuffer == NULL) { - gVideoDepthBuffer = allocate_from_main_pool_safe((gVideoFbWidths[index] * gVideoFbHeights[index] * 2) + 0x30, COLOUR_TAG_WHITE); - gVideoDepthBuffer = (u16 *)(((s32)gVideoDepthBuffer + 0x3F) & ~0x3F); + gVideoDepthBuffer = allocate_from_main_pool_safe( + (gVideoFbWidths[index] * gVideoFbHeights[index] * 2) + 0x30, COLOUR_TAG_WHITE); + gVideoDepthBuffer = (u16 *) (((s32) gVideoDepthBuffer + 0x3F) & ~0x3F); } } } @@ -322,7 +326,7 @@ void func_8007AB24(u8 arg0) { * Perhaps may have been used originally to calculate the factor in which to handle frameskipping with. */ UNUSED s32 get_video_refresh_speed(void) { - return (s32)((f32)gVideoRefreshRate / (f32)gVideoDeltaTime); + return (s32) ((f32) gVideoRefreshRate / (f32) gVideoDeltaTime); } /** diff --git a/src/video.h b/src/video.h index e17a5185..95a6151d 100644 --- a/src/video.h +++ b/src/video.h @@ -99,8 +99,6 @@ void func_8007AB24(u8 arg0); s32 get_video_refresh_speed(void); void swap_framebuffers(void); void memory_copy(u8 *src, u8 *dest, s32 len); - -//Non Matching -s32 swap_framebuffer_when_ready(s32 arg0); +s32 swap_framebuffer_when_ready(s32 mesg); #endif diff --git a/src/waves.c b/src/waves.c index ec1a2a08..3e3078ed 100644 --- a/src/waves.c +++ b/src/waves.c @@ -35,34 +35,26 @@ typedef struct unk800E3090 { } unk800E3090; unk800E3090 D_800E3090[4] = { - { 0x4000, 0x0201, 0, 0, 0, 0, 0, 0, }, - { 0x4001, 0x0203, 0, 0, 0, 0, 0, 0, }, - { 0x4000, 0x0201, 0, 0, 0, 0, 0, 0, }, - { 0x4001, 0x0203, 0, 0, 0, 0, 0, 0, }, + { 0x4000, 0x0201, 0, 0, 0, 0, 0, 0 }, + { 0x4001, 0x0203, 0, 0, 0, 0, 0, 0 }, + { 0x4000, 0x0201, 0, 0, 0, 0, 0, 0 }, + { 0x4001, 0x0203, 0, 0, 0, 0, 0, 0 }, }; TextureHeader *D_800E30D0 = NULL; s32 *D_800E30D4 = NULL; LevelModel_Alternate *D_800E30D8 = NULL; -s32 D_800E30DC = 0; //Tracks an index into D_8012A1E8 -s16 *D_800E30E0 = NULL; //Points to either D_800E30E8 or D_800E3110 -s16 *D_800E30E4 = NULL; //Points to either D_800E30FC or D_800E3144 +s32 D_800E30DC = 0; // Tracks an index into D_8012A1E8 +s16 *D_800E30E0 = NULL; // Points to either D_800E30E8 or D_800E3110 +s16 *D_800E30E4 = NULL; // Points to either D_800E30FC or D_800E3144 -s16 D_800E30E8[10] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 -}; +s16 D_800E30E8[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; -s16 D_800E30FC[10] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 0 -}; +s16 D_800E30FC[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 0 }; -s16 D_800E3110[26] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0 -}; +s16 D_800E3110[26] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0 }; -s16 D_800E3144[26] = { - 0, 1, 1, 1, 2, 3, 4, 4, 4, 5, 3, 4, 4, 4, 5, 3, 4, 4, 4, 5, 6, 7, 7, 7, 8, 0 -}; +s16 D_800E3144[26] = { 0, 1, 1, 1, 2, 3, 4, 4, 4, 5, 3, 4, 4, 4, 5, 3, 4, 4, 4, 5, 6, 7, 7, 7, 8, 0 }; s32 *D_800E3178 = NULL; s32 D_800E317C = 0; @@ -141,11 +133,11 @@ s32 D_8012A728; free_from_memory_pool(tempMem); \ mem = NULL; \ } -#define FREE_TEX(tex) \ - tempTex = tex; \ - if (tempTex != NULL) { \ - free_texture(tempTex); \ - tex = NULL; \ +#define FREE_TEX(tex) \ + tempTex = tex; \ + if (tempTex != NULL) { \ + free_texture(tempTex); \ + tex = NULL; \ } void free_waves(void) { @@ -183,10 +175,11 @@ void func_800B7EB4(void) { free_waves(); D_800E3040 = (s32 *) allocate_from_main_pool_safe(D_80129FC8->unk20 << 2, COLOUR_TAG_CYAN); D_800E3044 = (s32 *) allocate_from_main_pool_safe((D_80129FC8->unk4 << 2) * D_80129FC8->unk4, COLOUR_TAG_CYAN); - D_800E3048 = (s32 *) allocate_from_main_pool_safe(((D_80129FC8->unk0 + 1) << 2) * (D_80129FC8->unk0 + 1), COLOUR_TAG_CYAN); + D_800E3048 = + (s32 *) allocate_from_main_pool_safe(((D_80129FC8->unk0 + 1) << 2) * (D_80129FC8->unk0 + 1), COLOUR_TAG_CYAN); temp_lo = ((D_80129FC8->unk0 + 1) << 2) * (D_80129FC8->unk0 + 1); D_800E304C = allocate_from_main_pool_safe(temp_lo * 9, COLOUR_TAG_CYAN); - + // for (var_a1 = 1; var_a1 < 4; var_a1++) { // D_800E3050[var_a1] = (s32 *) ((u32) D_800E304C + (temp_lo * var_a1)); // } @@ -202,12 +195,12 @@ void func_800B7EB4(void) { var_a1 += 4; } while (var_a1 < 9); - //temp_lo = (D_80129FC8->unk0 + 1) * 250 * (D_80129FC8->unk0 + 1); - temp_lo = ((((D_80129FC8->unk0 + 1) << 5) - D_80129FC8->unk0) * 10) * (D_80129FC8->unk0 + 1); + // temp_lo = (D_80129FC8->unk0 + 1) * 250 * (D_80129FC8->unk0 + 1); + temp_lo = ((((D_80129FC8->unk0 + 1) << 5) - D_80129FC8->unk0) * 10) * (D_80129FC8->unk0 + 1); if (D_8012A078 != 2) { D_800E3070[0] = (s32 *) allocate_from_main_pool_safe(temp_lo << 1, COLOUR_TAG_CYAN); D_800E3070[1] = (s32 *) ((u32) D_800E3070[0] + temp_lo); - } else { + } else { D_800E3070[0] = (s32 *) allocate_from_main_pool_safe(temp_lo << 2, COLOUR_TAG_CYAN); D_800E3070[1] = (s32 *) ((u32) D_800E3070[0] + temp_lo); D_800E3070[2] = (s32 *) ((u32) D_800E3070[1] + temp_lo); @@ -299,12 +292,12 @@ GLOBAL_ASM("asm/non_matchings/waves/func_800B9C18.s") void func_800BA288(s32 arg0, s32 arg1) { s32 i; s32 j; - + arg1 <<= 3; for (i = 0; i < D_8012A0E0; i++) { if (D_8012A0E8[D_800E30D8[i].unkB] & (1 << D_800E30D8[i].unkA)) { if (D_80129FC8->unk28 != 0) { - for(j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) { s32 ti = j << 3; if (D_800E30D4[D_800E30D8[i].unkC] & (0xFF << ti)) { if (arg1 < D_800E30D8[i].unk14[arg0].unk0[j]) { @@ -316,7 +309,7 @@ void func_800BA288(s32 arg0, s32 arg1) { if (D_800E30D8[i].unk14[arg0].unk0[j] + arg1 < 128) { D_800E30D8[i].unk14[arg0].unk0[j] += arg1; } else { - D_800E30D8[i].unk14[arg0].unk0[j] = 128; + D_800E30D8[i].unk14[arg0].unk0[j] = 128; } } } @@ -339,7 +332,7 @@ void func_800BA288(s32 arg0, s32 arg1) { } } -//https://decomp.me/scratch/h4uac +// https://decomp.me/scratch/h4uac GLOBAL_ASM("asm/non_matchings/waves/func_800BA4B8.s") GLOBAL_ASM("asm/non_matchings/waves/func_800BA8E4.s") GLOBAL_ASM("asm/non_matchings/waves/func_800BB2F4.s") @@ -349,7 +342,7 @@ void func_800BBDDC(LevelModel *level, LevelHeader *header) { func_800BBF78(level); } -//TODO: arg1 should be a LevelHeader +// TODO: arg1 should be a LevelHeader void func_800BBE08(LevelModel *level, unk800BBE08_arg1 *arg1) { s16 numSegments; s32 j; @@ -361,16 +354,17 @@ void func_800BBE08(LevelModel *level, unk800BBE08_arg1 *arg1) { numSegments = level->numberOfSegments; curBatch = 0; - + for (i = 0; curBatch == 0 && i < numSegments; i++) { segment = &level->segments[i]; for (j = 0; curBatch == 0 && j < segment->numberOfBatches; j++) { - if ((segment->batches[j].flags & (BATCH_FLAGS_UNK01000000 | BATCH_FLAGS_WATER | BATCH_FLAGS_HIDDEN)) == (BATCH_FLAGS_UNK01000000 | BATCH_FLAGS_WATER)) { + if ((segment->batches[j].flags & (BATCH_FLAGS_UNK01000000 | BATCH_FLAGS_WATER | BATCH_FLAGS_HIDDEN)) == + (BATCH_FLAGS_UNK01000000 | BATCH_FLAGS_WATER)) { curBatch = &segment->batches[j]; } } } - + if (curBatch == 0) { i = 0; } else { @@ -509,7 +503,7 @@ void func_800BF3E4(Object *obj) { unk800E3184 *temp_a1; if (D_800E3190 != NULL) { - + for (i = 0, m = 0; i < D_800E3188 && m == 0; i++) { if (obj == D_800E3194[i]) { m = -1; @@ -547,11 +541,13 @@ void func_800BF524(Object *obj) { if (temp_v0->unk11 != 0) { var_v1 |= 2; } - func_800BF634(obj, obj->segment.trans.x_position, obj->segment.trans.z_position, (f32) temp_v0->unkA, temp_v0->unk9 << 8, - (f32) temp_v0->unk8 / 16.0, (f32) temp_v0->unkE, (f32) temp_v0->unkC / 16.0, var_v1); + func_800BF634(obj, obj->segment.trans.x_position, obj->segment.trans.z_position, (f32) temp_v0->unkA, + temp_v0->unk9 << 8, (f32) temp_v0->unk8 / 16.0, (f32) temp_v0->unkE, (f32) temp_v0->unkC / 16.0, + var_v1); } -unk800E3190 *func_800BF634(Object *obj, f32 xPos, f32 zPos, f32 arg3, s32 arg4, f32 arg5, f32 arg6, f32 arg7, s32 arg8) { +unk800E3190 *func_800BF634(Object *obj, f32 xPos, f32 zPos, f32 arg3, s32 arg4, f32 arg5, f32 arg6, f32 arg7, + s32 arg8) { f32 var_f0; s32 var_a0; s32 var_a0_2; @@ -564,7 +560,7 @@ unk800E3190 *func_800BF634(Object *obj, f32 xPos, f32 zPos, f32 arg3, s32 arg4, result = NULL; if (D_800E3190 != NULL) { - for(i = 0, var_a0 = 0; i < 32 && var_a0 == 0; i++) { + for (i = 0, var_a0 = 0; i < 32 && var_a0 == 0; i++) { if (D_800E3194[i] == NULL) { var_a0 = -1; } @@ -591,7 +587,7 @@ unk800E3190 *func_800BF634(Object *obj, f32 xPos, f32 zPos, f32 arg3, s32 arg4, if (var_a2_2 >= D_800E318C) { var_a2_2 = D_800E318C - 1; } - + for (j = var_a0_2; j <= var_a2_2; j++) { temp = &D_800E3184[j]; if (temp->unk0[7] == 0xFF) { @@ -612,12 +608,12 @@ unk800E3190 *func_800BF634(Object *obj, f32 xPos, f32 zPos, f32 arg3, s32 arg4, result->unk14 = arg3 * arg3; result->unk1A = arg4; if (osTvType == TV_TYPE_PAL) { - result->unk1C = arg5 * 20971.52;//(f64) (0x80000 / 25.0); + result->unk1C = arg5 * 20971.52; //(f64) (0x80000 / 25.0); } else { - result->unk1C = arg5 * 17476.27;//(f64) ((0x80000 / 1.2) / 25.0); + result->unk1C = arg5 * 17476.27; //(f64) ((0x80000 / 1.2) / 25.0); } result->unk20 = 65536.0f / arg6; - result->unk24 = arg7; + result->unk24 = arg7; result->unk28 = arg5; result->unk31 = arg8 & 1; result->unk32 = arg8 & 2; @@ -668,7 +664,7 @@ void func_800BF9F8(unk800BF9F8 *arg0, f32 arg1, f32 arg2) { j = 0; if (iteration != 0) { if (var_a2_2[7] == 0xFF) { - while(var_a2_2[0] != 0xFF) { + while (var_a2_2[0] != 0xFF) { var_a2_2++; } var_a2_2[0] = temp_v1; @@ -676,8 +672,8 @@ void func_800BF9F8(unk800BF9F8 *arg0, f32 arg1, f32 arg2) { } else { while (j < 8) { if (temp_v1 == var_a2_2[j]) { - while(j < 7){ - var_a2_2[j] = var_a2_2[j+1]; + while (j < 7) { + var_a2_2[j] = var_a2_2[j + 1]; j++; } var_a2_2[j] = 0xFF; @@ -709,15 +705,15 @@ UNUSED void func_800BFC54(unk800BFC54_arg0 *arg0, f32 arg1, f32 arg2, f32 arg3, arg0->unk4 = (arg0->unkC + arg0->unk10); arg0->unk28 += arg2; if (osTvType == TV_TYPE_PAL) { - arg0->unk1C = arg0->unk28 * 20971.52;//(f64) (0x80000 / 25.0); + arg0->unk1C = arg0->unk28 * 20971.52; //(f64) (0x80000 / 25.0); } else { - arg0->unk1C = arg0->unk28 * 17476.27;//(f64) ((0x80000 / 1.2) / 25.0); + arg0->unk1C = arg0->unk28 * 17476.27; //(f64) ((0x80000 / 1.2) / 25.0); } arg0->unk2C = (arg0->unk2C + arg3); if (arg0->unk2C < 1.0) { arg0->unk2C = 1.0f; } - arg0->unk20 = (65536.0f / arg0->unk2C); //0x10000 + arg0->unk20 = (65536.0f / arg0->unk2C); // 0x10000 arg0->unk24 = (arg0->unk24 + arg4); } } @@ -725,7 +721,7 @@ UNUSED void func_800BFC54(unk800BFC54_arg0 *arg0, f32 arg1, f32 arg2, f32 arg3, void func_800BFE98(s32 arg0) { s32 i; - for(i = 0; i < 32; i++) { + for (i = 0; i < 32; i++) { if (D_800E3194[i] != NULL) { D_800E3190[i].unk1A += ((0, D_800E3190[i].unk1C * arg0)) >> 4; } @@ -763,7 +759,7 @@ void obj_loop_wavepower(Object *obj) { diffZ = racerObj->segment.trans.z_position - obj->segment.trans.z_position; if ((diffX * diffX) + (diffY * diffY) + (diffZ * diffZ) < distance) { D_8012A720 = entry->unkA / 256.0f; - D_8012A724 = (D_8012A720 - D_80129FC8->unk40) / (f32) entry->unkC; + D_8012A724 = (D_8012A720 - D_80129FC8->unk40) / (f32) entry->unkC; D_8012A728 = entry->unkC; gWaveGeneratorObj = obj; } diff --git a/src/waves.h b/src/waves.h index 4e593b18..dc44b553 100644 --- a/src/waves.h +++ b/src/waves.h @@ -126,7 +126,7 @@ void func_800BF3E4(Object *obj); f32 get_wave_height(Object_Log *log, s32 updateRate); void func_800BA288(s32 arg0, s32 arg1); void func_800BF9F8(unk800BF9F8 *arg0, f32 arg1, f32 arg2); -unk800E3190 *func_800BF634(Object *obj, f32 arg1, f32 arg2, f32 arg3, s32 arg4, f32 arg5, f32 arg6, f32 arg7, s32 arg8); +unk800E3190 *func_800BF634(Object *obj, f32 xPos, f32 zPos, f32 arg3, s32 arg4, f32 arg5, f32 arg6, f32 arg7, s32 arg8); Object_64 *func_800BE654(s16, f32, f32); // Non Matching void func_800BBF78(LevelModel *arg0); // Non Matching diff --git a/src/weather.c b/src/weather.c index c399a418..30bdf5c0 100644 --- a/src/weather.c +++ b/src/weather.c @@ -23,9 +23,12 @@ const char D_800E87F0[] = "\nMaximum limit of %d lens flare switches, per level, /************ .data ************/ unk800E2850 D_800E2850[3] = { - { 0, 0x40, (TextureHeader *)0, 0xFE000000, 0xFE000000, 0xFE000000, 0x03FFFFFF, 0x03FFFFFF, 0x03FFFFFF, 4, 4, 8, 8 }, - { 0, 0x100, (TextureHeader *)1, 0xFE000000, 0xFE000000, 0xFE000000, 0x03FFFFFF, 0x03FFFFFF, 0x03FFFFFF, 4, 4, 8, 8 }, - { 0, 0x08, (TextureHeader *)2, 0xFE000000, 0xFE000000, 0xFE000000, 0x03FFFFFF, 0x03FFFFFF, 0x03FFFFFF, 4, 4, 8, 8 }, + { 0, 0x40, (TextureHeader *) 0, 0xFE000000, 0xFE000000, 0xFE000000, 0x03FFFFFF, 0x03FFFFFF, 0x03FFFFFF, 4, 4, 8, + 8 }, + { 0, 0x100, (TextureHeader *) 1, 0xFE000000, 0xFE000000, 0xFE000000, 0x03FFFFFF, 0x03FFFFFF, 0x03FFFFFF, 4, 4, 8, + 8 }, + { 0, 0x08, (TextureHeader *) 2, 0xFE000000, 0xFE000000, 0xFE000000, 0x03FFFFFF, 0x03FFFFFF, 0x03FFFFFF, 4, 4, 8, + 8 }, }; unk800E28D4 *D_800E28D4 = NULL; @@ -37,7 +40,7 @@ s32 D_800E2908 = 0; s32 *D_800E290C = NULL; s16 *D_800E2910 = NULL; Vertex *D_800E2914[2] = { NULL, NULL }; -s32 *gWeatherAssetTable = NULL; // List of Ids +s32 *gWeatherAssetTable = NULL; // List of Ids s32 gWeatherAssetTableLength = 0; // Set, but never read. Gfx D_800E2928[] = { @@ -56,30 +59,30 @@ Gfx D_800E2928[] = { unk800E2980 D_800E2980[2] = { { 1, 0xFFFF, 0xC090, 3.0f, 0.0f }, - { 0, 0, 0, 0.0f, 0.0f }, + { 0, 0, 0, 0.0f, 0.0f }, }; unk800E2980 D_800E29A0[4] = { - { 3, 0xFFFF, 0x0090, 0.75f, -32.0f }, - { 2, 0x0050, 0xFF60, 0.8f, -96.0f }, + { 3, 0xFFFF, 0x0090, 0.75f, -32.0f }, + { 2, 0x0050, 0xFF60, 0.8f, -96.0f }, { 2, 0x00FF, 0x0090, 0.75f, -192.0f }, - { 0, 0, 0, 0.0f, 0.0f }, + { 0, 0, 0, 0.0f, 0.0f }, }; unk800E2980 D_800E29E0[5] = { - { 3, 0xFF80, 0x1490, 0.65f, -64.0f }, - { 2, 0xFFFF, 0xFF90, 1.0f, -128.0f }, - { 3, 0xFFFF, 0x8090, 0.5f, -176.0f }, + { 3, 0xFF80, 0x1490, 0.65f, -64.0f }, + { 2, 0xFFFF, 0xFF90, 1.0f, -128.0f }, + { 3, 0xFFFF, 0x8090, 0.5f, -176.0f }, { 3, 0xFF28, 0x2890, 0.75f, -224.0f }, - { 0, 0, 0, 0.0f, 0.0f }, + { 0, 0, 0, 0.0f, 0.0f }, }; unk800E2980 D_800E2A30[5] = { - { 3, 0xFF80, 0xFF80, 0.5f, -64.0f }, + { 3, 0xFF80, 0xFF80, 0.5f, -64.0f }, { 1, 0xFFFF, 0xC090, 0.75f, -128.0f }, - { 2, 0xFF28, 0x0080, 0.6f, -176.0f }, + { 2, 0xFF28, 0x0080, 0.6f, -176.0f }, { 1, 0xFFC0, 0xFF90, 0.75f, -224.0f }, - { 0, 0, 0, 0.0f, 0.0f }, + { 0, 0, 0, 0.0f, 0.0f }, }; Object *D_800E2A80 = NULL; @@ -95,38 +98,24 @@ f32 D_800E2AA4 = -200.0f; f32 D_800E2AA8 = -200.0f; Vertex D_800E2AAC[16] = { - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, - { 0, 0, 0, 255, 255, 255, 255 }, + { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, + { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, + { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, + { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, + { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, { 0, 0, 0, 255, 255, 255, 255 }, }; unk800E2B4C D_800E2B4C[8] = { - { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, - { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, - { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, - { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, - { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, - { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, - { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, - { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, + { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, + { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, + { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, + { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, }; unk800E2C2C gRainGfx[2] = { { 0, 0, 0x400, 0x400, 0x000A, 0xFFC4, NULL, 128, 255, 255, 128, 128, 255, 128, 0 }, - { 0, 0, 0x600, 0x600, 0x0020, 0xFF40, NULL, 255, 255, 255, 0, 128, 255, 255, 0 } + { 0, 0, 0x600, 0x600, 0x0020, 0xFF40, NULL, 255, 255, 255, 0, 128, 255, 255, 0 }, }; s32 gWeatherType = WEATHER_SNOW; @@ -145,7 +134,6 @@ Sprite *gRainSplashGfx = 0; s32 D_800E2C90 = 0; SoundMask *gWeatherSoundMask = NULL; - FadeTransition gThunderTransition = FADE_TRANSITION(FADE_FULLSCREEN, FADE_FLAG_INVERT, FADE_COLOR_WHITE, 5, 2); /*******************************/ @@ -175,7 +163,7 @@ Object *D_80127C40[16]; /** * Official Name: initWeather -*/ + */ void init_weather(void) { D_800E28D8.unk0 = 0; D_800E28D8.unk4 = 0; @@ -193,7 +181,7 @@ void init_weather(void) { D_800E2A84 = TRUE; D_800E2A88 = 0; if (gWeatherAssetTable == NULL) { - gWeatherAssetTable = (s32 *)load_asset_section_from_rom(ASSET_WEATHER_PARTICLES); + gWeatherAssetTable = (s32 *) load_asset_section_from_rom(ASSET_WEATHER_PARTICLES); gWeatherAssetTableLength = 0; while ((s32) gWeatherAssetTable[gWeatherAssetTableLength] != -1) { gWeatherAssetTableLength++; @@ -204,7 +192,7 @@ void init_weather(void) { /** * Official Name: setWeatherLimits -*/ + */ void set_weather_limits(s16 arg0, s16 arg1) { if (D_80127BF8.unk2 < D_80127BF8.unk0) { D_80127BF8.unk0 = arg0; @@ -221,11 +209,11 @@ void set_weather_limits(s16 arg0, s16 arg1) { free_from_memory_pool(tempMem); \ mem = NULL; \ } -#define FREE_TEX(tex) \ - tempTex = tex; \ - if (tempTex != NULL) { \ - free_texture(tempTex); \ - tex = NULL; \ +#define FREE_TEX(tex) \ + tempTex = tex; \ + if (tempTex != NULL) { \ + free_texture(tempTex); \ + tex = NULL; \ } /** @@ -263,7 +251,7 @@ void func_800ABB34(void) { temp_v0 = 0x10000 / D_800E28D8.unk4; phi_s1 = 0; - for(i = 0; i < D_800E28D8.unk4; i++) { + for (i = 0; i < D_800E28D8.unk4; i++) { D_800E28D8.unk0[i].unk0 = coss(phi_s1 & 0xFFFF) << 3; D_800E28D8.unk0[i].unk4 = 0xFFFC0000; D_800E28D8.unk0[i].unk8 = sins(phi_s1 & 0xFFFF) << 1; @@ -273,10 +261,9 @@ void func_800ABB34(void) { D_800E28D8.unk8 = load_texture(*gWeatherAssetTable); } - void changeWeather(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { - if ((arg5 > 0) && ((arg0 != D_80127BB8[5]) || (arg1 != D_80127BB8[8]) || (arg2 != D_80127BB8[11]) - || (arg3 != D_80127BB8[0]) || (arg4 != D_80127BB8[12]))) { + if ((arg5 > 0) && ((arg0 != D_80127BB8[5]) || (arg1 != D_80127BB8[8]) || (arg2 != D_80127BB8[11]) || + (arg3 != D_80127BB8[0]) || (arg4 != D_80127BB8[12]))) { D_80127BB8[5] = arg0; D_80127BB8[8] = arg1; D_80127BB8[11] = arg2; @@ -302,7 +289,8 @@ void changeWeather(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { * The root function for handling all weather. * Decide whether to perform rain or snow logic, execute it, then set it to render right after. */ -void process_weather(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, TriangleList **currHudTris, s32 updateRate) { +void process_weather(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, TriangleList **currHudTris, + s32 updateRate) { UNUSED s32 unused; gCurrWeatherDisplayList = *currDisplayList; gCurrWeatherMatrix = *currHudMat; @@ -349,18 +337,21 @@ void process_weather(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currH // This is the snow physics that makes it move void func_800AC0C8(s32 updateRate) { - unk800E2850_unk0* temp_v1; + unk800E2850_unk0 *temp_v1; s32 i; for (i = 0; i < D_80127BB0; i++) { temp_v1 = &D_800E28D8.unk0[D_800E28D4[i].unkF]; - D_800E28D4[i].unk0 = ((((temp_v1->unk0 + (D_80127BB8[3] * 2)) * updateRate) >> 1) + D_800E28D4[i].unk0) & D_800E28D8.unk18; - D_800E28D4[i].unk4 = ((((temp_v1->unk4 + (D_80127BB8[6] * 2)) * updateRate) >> 1) + D_800E28D4[i].unk4) & D_800E28D8.unk1C; - D_800E28D4[i].unk8 = ((((temp_v1->unk8 + (D_80127BB8[9] * 2)) * updateRate) >> 1) + D_800E28D4[i].unk8) & D_800E28D8.unk20; + D_800E28D4[i].unk0 = + ((((temp_v1->unk0 + (D_80127BB8[3] * 2)) * updateRate) >> 1) + D_800E28D4[i].unk0) & D_800E28D8.unk18; + D_800E28D4[i].unk4 = + ((((temp_v1->unk4 + (D_80127BB8[6] * 2)) * updateRate) >> 1) + D_800E28D4[i].unk4) & D_800E28D8.unk1C; + D_800E28D4[i].unk8 = + ((((temp_v1->unk8 + (D_80127BB8[9] * 2)) * updateRate) >> 1) + D_800E28D4[i].unk8) & D_800E28D8.unk20; D_800E28D4[i].unkF++; if (D_800E28D4[i].unkF >= D_800E28D8.unk4) { D_800E28D4[i].unkF -= D_800E28D8.unk4; - } + } } } @@ -379,7 +370,7 @@ void func_800AC21C(void) { sp54 = (gWeatherCamera->trans.y_position * 65536.0f); sp50 = (gWeatherCamera->trans.z_position * 65536.0f); D_800E2908 = 0; - for(i = 0; i < D_80127BB4; i++) { + for (i = 0; i < D_80127BB4; i++) { sp64[0][0] = (f32) (((D_800E28D4[i].unk0 - sp58) & D_800E28D8.unk18) + D_800E28D8.unkC) * (1.0f / 65536.0f); sp64[0][1] = (f32) (((D_800E28D4[i].unk4 - sp54) & D_800E28D8.unk1C) + D_800E28D8.unk10) * (1.0f / 65536.0f); sp64[0][2] = (f32) (((D_800E28D4[i].unk8 - sp50) & D_800E28D8.unk20) + D_800E28D8.unk14) * (1.0f / 65536.0f); @@ -391,18 +382,18 @@ void func_800AC21C(void) { D_800E2904[i].x = xPos - D_800E28D8.unk24; D_800E2904[i].y = yPos + D_800E28D8.unk26; D_800E2904[i].z = zPos; - D_800E2904[i+1].x = xPos + D_800E28D8.unk24; - D_800E2904[i+1].y = yPos + D_800E28D8.unk26; - D_800E2904[i+1].z = zPos; - D_800E2904[i+2].x = xPos + D_800E28D8.unk24; - D_800E2904[i+2].y = yPos - D_800E28D8.unk26; - D_800E2904[i+2].z = zPos; - D_800E2904[i+3].x = xPos - D_800E28D8.unk24; - D_800E2904[i+3].y = yPos - D_800E28D8.unk26; - D_800E2904[i+3].z = zPos; + D_800E2904[i + 1].x = xPos + D_800E28D8.unk24; + D_800E2904[i + 1].y = yPos + D_800E28D8.unk26; + D_800E2904[i + 1].z = zPos; + D_800E2904[i + 2].x = xPos + D_800E28D8.unk24; + D_800E2904[i + 2].y = yPos - D_800E28D8.unk26; + D_800E2904[i + 2].z = zPos; + D_800E2904[i + 3].x = xPos - D_800E28D8.unk24; + D_800E2904[i + 3].y = yPos - D_800E28D8.unk26; + D_800E2904[i + 3].z = zPos; D_800E2908 += 4; D_800E2910[D_800E2908 >> 2] = i; - if ((!i) && (!i)){} // Fakematch + if ((!i) && (!i)) {} // Fakematch } } } @@ -463,37 +454,37 @@ void func_800AC8A8(Object *lensflareObj) { D_800E2A80 = lensflareObj; D_800E2A84 = 0; entry = &D_800E2A80->segment.level_entry->lensFlare; - + switch (entry->unkC) { - default: - D_80127C24 = 0; - break; - case 1: - D_80127C24 = (s32) D_800E29A0; - break; - case 2: - D_80127C24 = (s32) D_800E29E0; - break; - case 3: - D_80127C24 = (s32) D_800E2A30; - break; + default: + D_80127C24 = 0; + break; + case 1: + D_80127C24 = (s32) D_800E29A0; + break; + case 2: + D_80127C24 = (s32) D_800E29E0; + break; + case 3: + D_80127C24 = (s32) D_800E2A30; + break; } switch (entry->unkD) { - default: - D_80127C28 = 0; - break; - case 1: - D_80127C28 = (s32) D_800E29A0; - break; - case 2: - D_80127C28 = (s32) D_800E29E0; - break; - case 3: - D_80127C28 = (s32) D_800E2A30; - break; + default: + D_80127C28 = 0; + break; + case 1: + D_80127C28 = (s32) D_800E29A0; + break; + case 2: + D_80127C28 = (s32) D_800E29E0; + break; + case 3: + D_80127C28 = (s32) D_800E2A30; + break; } - + if (entry->unkE == 1) { D_80127C2C = (Matrix *) D_800E2980; } else { @@ -501,7 +492,7 @@ void func_800AC8A8(Object *lensflareObj) { } sp1C.y_rotation = entry->unkA; - sp1C.x_rotation = entry->unk8; + sp1C.x_rotation = entry->unk8; sp1C.z_rotation = 0; D_80127C30.x = 0; D_80127C30.y = 0; @@ -512,7 +503,7 @@ void func_800AC8A8(Object *lensflareObj) { D_80127C30.z = -D_80127C30.z; } -//https://decomp.me/scratch/mYuMJ +// https://decomp.me/scratch/mYuMJ GLOBAL_ASM("asm/non_matchings/weather/func_800ACA20.s") void cameraAddOverrideObject(Object *arg0) { @@ -522,7 +513,7 @@ void cameraAddOverrideObject(Object *arg0) { } } -void func_800ACF98(Object* arg0) { +void func_800ACF98(Object *arg0) { s32 i; s32 isFound = FALSE; @@ -539,7 +530,6 @@ void func_800ACF98(Object* arg0) { D_80127C40[i] = D_80127C40[i + 1]; } } - } void func_800AD030(ObjectSegment *cameraSegment) { @@ -547,10 +537,10 @@ void func_800AD030(ObjectSegment *cameraSegment) { f32 xDiff; f32 zDiff; f32 yDiff; - s32 i; + s32 i; D_800E2A84 = FALSE; if (D_800E2A88 > 0 && D_800E2A80 != 0) { - if(D_80127C40[0]){} // Fakematch + if (D_80127C40[0]) {} // Fakematch for (i = 0; i < D_800E2A88; i++) { xDiff = cameraSegment->trans.x_position - D_80127C40[i]->segment.trans.x_position; yDiff = cameraSegment->trans.y_position - D_80127C40[i]->segment.trans.y_position; @@ -577,7 +567,7 @@ void func_800AD144(s32 arg0, s32 arg1) { D_800E2C90 = 0; gRainGfx[0].tex = load_texture(gWeatherAssetTable[1]); gRainGfx[1].tex = load_texture(gWeatherAssetTable[1]); - gRainSplashGfx = (Sprite *)func_8007C12C(gWeatherAssetTable[3], 0); + gRainSplashGfx = (Sprite *) func_8007C12C(gWeatherAssetTable[3], 0); gWeatherType = WEATHER_RAIN; } @@ -655,13 +645,13 @@ void handle_weather_rain(s32 updateRate) { handle_rain_lightning(updateRate); if (gLightningFrequency >= 256) { set_ortho_matrix_view(&gCurrWeatherDisplayList, &gCurrWeatherMatrix); - for(i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { render_rain_overlay(&gRainGfx[i], updateRate); } gDPSetPrimColor(gCurrWeatherDisplayList++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(gCurrWeatherDisplayList++, 255, 255, 255, 0); reset_render_settings(&gCurrWeatherDisplayList); // Pipesync and some stuff idk yet - viewport_reset(&gCurrWeatherDisplayList); // Looks to create a viewport scissor. + viewport_reset(&gCurrWeatherDisplayList); // Looks to create a viewport scissor. } } } @@ -670,8 +660,8 @@ GLOBAL_ASM("asm/non_matchings/weather/render_rain_splashes.s") /** * On a randomly set timer, based on the weather intensity, count down and make the sound of thunder. - * Set a second timer, that then counts down to zero and creates a flash of lightning in the form of a screen transition. - * Afterwards, set the thunder timer back. + * Set a second timer, that then counts down to zero and creates a flash of lightning in the form of a screen + * transition. Afterwards, set the thunder timer back. */ void handle_rain_lightning(s32 updateRate) { if (gThunderTimer > 0) { @@ -776,7 +766,9 @@ void render_rain_overlay(unk800E2C2C *arg0, s32 arg1) { tris[1].uv2.u = altHorizontal; tris[1].uv2.v = altVertical; sp64 = tris + 0x20; - func_8007F594(&gCurrWeatherDisplayList, 0, COLOUR_RGBA32(arg0->primitiveRed, arg0->primitiveGreen, arg0->primitiveBlue, opacity), COLOUR_RGBA32(arg0->environmentRed, arg0->environmentGreen, arg0->environmentBlue, 0)); + func_8007F594(&gCurrWeatherDisplayList, 0, + COLOUR_RGBA32(arg0->primitiveRed, arg0->primitiveGreen, arg0->primitiveBlue, opacity), + COLOUR_RGBA32(arg0->environmentRed, arg0->environmentGreen, arg0->environmentBlue, 0)); gDkrDmaDisplayList(gCurrWeatherDisplayList++, OS_PHYSICAL_TO_K0(tex->cmd), tex->numberOfCommands); gSPVertexDKR(gCurrWeatherDisplayList++, OS_PHYSICAL_TO_K0(&D_800E2AAC[D_800E2C90]), 4, 0); gSPPolygon(gCurrWeatherDisplayList++, OS_PHYSICAL_TO_K0(gCurrWeatherTriList), 2, 1); diff --git a/tools/format.py b/tools/format.py new file mode 100755 index 00000000..cd6d0f09 --- /dev/null +++ b/tools/format.py @@ -0,0 +1,196 @@ +#!/usr/bin/env python3 + +import argparse +import glob +import multiprocessing +import os +import re +import shutil +import subprocess +import sys +import tempfile +from functools import partial +from typing import List + + +# clang-format, clang-tidy and clang-apply-replacements default version +# This specific version is used when available, for more consistency between contributors +CLANG_VER = 14 + +# Clang-Format options (see .clang-format for rules applied) +FORMAT_OPTS = "-i -style=file" + +# Clang-Tidy options (see .clang-tidy for checks enabled) +TIDY_OPTS = "-p ." +TIDY_FIX_OPTS = "--fix --fix-errors" + +# Clang-Apply-Replacements options (used for multiprocessing) +APPLY_OPTS = "" + +# Compiler options used with Clang-Tidy +# Normal warnings are disabled with -Wno-everything to focus only on tidying +INCLUDES = "-Iinclude -Isrc -Ibuild -I. -Ilib/src" +DEFINES = "-D_LANGUAGE_C -DNON_MATCHING -D_MIPS_SZLONG=32 -DNON_EQUIVALENT" +COMPILER_OPTS = f"-fno-builtin -std=gnu90 -m32 -Wno-everything {INCLUDES} {DEFINES}" + + +def get_clang_executable(allowed_executables: List[str]): + for executable in allowed_executables: + try: + subprocess.check_call( + [executable, "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return executable + except FileNotFoundError or subprocess.CalledProcessError: + pass + return None + + +def get_tidy_version(tidy_executable: str): + tidy_version_run = subprocess.run( + [tidy_executable, "--version"], stdout=subprocess.PIPE, universal_newlines=True) + match = re.search(r"LLVM version ([0-9]+)", tidy_version_run.stdout) + return int(match.group(1)) + + +CLANG_FORMAT = get_clang_executable([f"clang-format-{CLANG_VER}", "clang-format"]) +if CLANG_FORMAT is None: + sys.exit(f"Error: clang-format-{CLANG_VER} not found") + +CLANG_TIDY = get_clang_executable([f"clang-tidy-{CLANG_VER}", "clang-tidy"]) +if CLANG_TIDY is None: + sys.exit(f"Error: neither clang-tidy-{CLANG_VER} nor clang-tidy found") + +CLANG_APPLY_REPLACEMENTS = get_clang_executable( + [f"clang-apply-replacements-{CLANG_VER}", "clang-apply-replacements"]) + +# Try to detect the clang-tidy version and add --fix-notes for version 13+ +# This is used to ensure all fixes are applied properly in recent versions +if get_tidy_version(CLANG_TIDY) >= 13: + TIDY_FIX_OPTS += " --fix-notes" + + +def list_chunks(list: List, chunk_length: int): + for i in range(0, len(list), chunk_length): + yield list[i: i + chunk_length] + + +def run_clang_format(files: List[str]): + exec_str = f"{CLANG_FORMAT} {FORMAT_OPTS} {' '.join(files)}" + subprocess.run(exec_str, shell=True) + + +def run_clang_tidy(files: List[str]): + exec_str = f"{CLANG_TIDY} {TIDY_OPTS} {TIDY_FIX_OPTS} {' '.join(files)} -- {COMPILER_OPTS}" + subprocess.run(exec_str, shell=True, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + + +def run_clang_tidy_with_export(tmp_dir: str, files: List[str]): + (handle, tmp_file) = tempfile.mkstemp(suffix=".yaml", dir=tmp_dir) + os.close(handle) + + exec_str = f"{CLANG_TIDY} {TIDY_OPTS} --export-fixes={tmp_file} {' '.join(files)} -- {COMPILER_OPTS}" + subprocess.run(exec_str, shell=True, + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + + +def run_clang_apply_replacements(tmp_dir: str): + exec_str = f"{CLANG_APPLY_REPLACEMENTS} {APPLY_OPTS} {tmp_dir}" + subprocess.run(exec_str, shell=True) + + +def add_final_new_line(file: str): + # https://backreference.org/2010/05/23/sanitizing-files-with-no-trailing-newline/index.html + # "gets the last character of the file pipes it into read, which will exit with a nonzero exit + # code if it encounters EOF before newline (so, if the last character of the file isn't a newline). + # If read exits nonzero, then append a newline onto the file using echo (if read exits 0, + # that satisfies the ||, so the echo command isn't run)." (https://stackoverflow.com/a/34865616) + exec_str = f"tail -c1 {file} | read -r _ || echo >> {file}" + subprocess.run(exec_str, shell=True) + + +def format_files(src_files: List[str], extra_files: List[str], nb_jobs: int): + if nb_jobs != 1: + print(f"Formatting files with {nb_jobs} jobs") + else: + print(f"Formatting files with a single job (consider using -j to make this faster)") + + # Format files in chunks to improve performance while still utilizing jobs + file_chunks = list(list_chunks(src_files, (len(src_files) // nb_jobs) + 1)) + + print("Running clang-format...") + # clang-format only applies changes in the given files, so it's safe to run in parallel + with multiprocessing.get_context("fork").Pool(nb_jobs) as pool: + pool.map(run_clang_format, file_chunks) + + print("Running clang-tidy...") + if nb_jobs > 1: + # clang-tidy may apply changes in #included files, so when running it in parallel we use --export-fixes + # then we call clang-apply-replacements to apply all suggested fixes at the end + tmp_dir = tempfile.mkdtemp() + + try: + with multiprocessing.get_context("fork").Pool(nb_jobs) as pool: + pool.map(partial(run_clang_tidy_with_export, tmp_dir), file_chunks) + + run_clang_apply_replacements(tmp_dir) + finally: + shutil.rmtree(tmp_dir) + else: + run_clang_tidy(src_files) + + print("Adding missing final new lines...") + # Adding final new lines is safe to do in parallel and can be applied to all types of files + with multiprocessing.get_context("fork").Pool(nb_jobs) as pool: + pool.map(add_final_new_line, src_files + extra_files) + + print("Done formatting files.") + + +def main(): + parser = argparse.ArgumentParser( + description="Format files in the codebase to enforce most style rules") + parser.add_argument("files", metavar="file", nargs="*") + parser.add_argument( + "--show-paths", + dest="show_paths", + action="store_true", + help="Print the paths to the clang-* binaries used", + ) + parser.add_argument( + "-j", + dest="jobs", + type=int, + nargs="?", + default=1, + help="number of jobs to run (default: 1 without -j, number of cpus with -j)", + ) + args = parser.parse_args() + + if args.show_paths: + import shutil + + print("CLANG_FORMAT ->", shutil.which(CLANG_FORMAT)) + print("CLANG_TIDY ->", shutil.which(CLANG_TIDY)) + print("CLANG_APPLY_REPLACEMENTS ->", + shutil.which(CLANG_APPLY_REPLACEMENTS)) + + nb_jobs = args.jobs or multiprocessing.cpu_count() + if nb_jobs > 1: + if CLANG_APPLY_REPLACEMENTS is None: + sys.exit( + f"Error: neither clang-apply-replacements-{CLANG_VER} nor clang-apply-replacements found (required to use -j)" + ) + + if args.files: + files = args.files + extra_files = [] + else: + files = glob.glob("src/**/*.c", recursive=True) + extra_files = glob.glob("assets/**/*.xml", recursive=True) + + format_files(files, extra_files, nb_jobs) + + +if __name__ == "__main__": + main()