From 813705850a8f61137cfe46ba234684041807e19e Mon Sep 17 00:00:00 2001 From: Ryan Myers Date: Thu, 3 Jul 2025 13:02:34 -0400 Subject: [PATCH] Header shuffle, cleanup, and fix UB (#661) * Cleanup and formatting * Fix typos * formatter * Start working on header cleanup * More include changes * WIP MORE * Finished the first pass of include updates. * More include updates * Handle some UB * Formatter --- README.md | 2 +- include/structs.h | 2 +- libultra/src/audio/mips1/drvrnew.c | 1 + libultra/src/audio/mips1/seqplayer.c | 2 +- src/asset_loading.c | 2 + src/asset_loading.h | 2 - src/audio.h | 29 ++------- src/audio_spatial.c | 1 + src/audio_spatial.h | 3 - src/audio_vehicle.c | 1 + src/audio_vehicle.h | 1 - src/audiomgr.c | 1 + src/audiomgr.h | 8 +-- src/audiosfx.h | 15 +---- src/borders.h | 3 +- src/camera.c | 2 + src/camera.h | 4 -- src/fade_transition.c | 2 + src/fade_transition.h | 3 +- src/font.c | 3 + src/font.h | 9 --- src/game.c | 1 + src/game.h | 2 - src/game_text.c | 4 ++ src/game_text.h | 5 -- src/game_ui.c | 3 + src/game_ui.h | 3 +- src/gzip.c | 1 + src/gzip.h | 2 - src/hasm/math_util.c | 1 - src/joypad.c | 3 + src/joypad.h | 4 +- src/lights.c | 1 + src/lights.h | 1 - src/main.c | 2 + src/main.h | 2 - src/math_util.h | 2 +- src/memory.c | 1 + src/memory.h | 3 - src/menu.c | 38 +++++++++++- src/menu.h | 46 ++++++++++++++- src/object_functions.c | 2 + src/object_functions.h | 2 - src/object_models.c | 2 + src/object_models.h | 2 - src/objects.c | 88 ++++++++++++++++------------ src/objects.h | 3 +- src/particles.c | 7 +++ src/particles.h | 2 - src/printf.c | 1 + src/printf.h | 3 - src/racer.c | 8 ++- src/racer.h | 1 - src/rcp_dkr.c | 2 + src/rcp_dkr.h | 8 +-- src/save_data.c | 3 + src/save_data.h | 5 -- src/screen_asset.c | 10 +++- src/screen_asset.h | 14 ----- src/textures_sprites.c | 1 + src/textures_sprites.h | 4 -- src/thread30_bgload.c | 1 + src/thread3_main.c | 2 + src/thread3_main.h | 44 -------------- src/tracks.c | 8 ++- src/tracks.h | 3 - src/vehicle_bluey.c | 2 + src/vehicle_bubbler.c | 2 + src/vehicle_rocket.c | 27 ++++++--- src/vehicle_smokey.c | 2 + src/vehicle_tricky.c | 2 + src/vehicle_wizpig.c | 29 ++++++--- src/video.c | 2 + src/video.h | 4 -- src/waves.c | 3 +- src/waves.h | 1 - src/weather.c | 4 ++ src/weather.h | 2 - 78 files changed, 277 insertions(+), 250 deletions(-) delete mode 100644 src/screen_asset.h diff --git a/README.md b/README.md index fd55918b..21022892 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ To make progress in Adventure 2, a function must be properly named (must not sta For example: ```c /** - * Returns 1 if Drumstick is avaliable to use, or 0 if not. + * Returns 1 if Drumstick is available to use, or 0 if not. */ s32 is_drumstick_unlocked(void) { return gActiveMagicCodes & 2; diff --git a/include/structs.h b/include/structs.h index f50a52c2..33f975a1 100644 --- a/include/structs.h +++ b/include/structs.h @@ -7,7 +7,7 @@ #include "level_object_entries.h" #include "object_properties.h" #include "gbi.h" -#include "audio.h" +#include "audiosfx.h" typedef struct Vec4f { union { diff --git a/libultra/src/audio/mips1/drvrnew.c b/libultra/src/audio/mips1/drvrnew.c index f9023e44..e98f6065 100644 --- a/libultra/src/audio/mips1/drvrnew.c +++ b/libultra/src/audio/mips1/drvrnew.c @@ -23,6 +23,7 @@ #include #include "initfx.h" #include "src/memory.h" +#include "macros.h" // TODO: this comes from a header #ident "$Revision: 1.49 $" diff --git a/libultra/src/audio/mips1/seqplayer.c b/libultra/src/audio/mips1/seqplayer.c index 6a019783..d536c1e7 100644 --- a/libultra/src/audio/mips1/seqplayer.c +++ b/libultra/src/audio/mips1/seqplayer.c @@ -458,6 +458,6 @@ void __seqpStopOsc(ALSeqPlayer *seqp, ALVoiceState *vs) /** * The voice limit bytes seem to be unique to this game. */ -void set_voice_limit(ALCSPlayer *seqp, s8 voiceLimit) { +void set_voice_limit(ALCSPlayer *seqp, u8 voiceLimit) { seqp->voiceLimit = voiceLimit; } diff --git a/src/asset_loading.c b/src/asset_loading.c index 3258a11d..4ce87c27 100644 --- a/src/asset_loading.c +++ b/src/asset_loading.c @@ -3,6 +3,8 @@ #include "common.h" #include "macros.h" #include "ultra64.h" +#include "gzip.h" +#include "memory.h" /************ .bss ************/ diff --git a/src/asset_loading.h b/src/asset_loading.h index c96b50c4..dfa15823 100644 --- a/src/asset_loading.h +++ b/src/asset_loading.h @@ -2,8 +2,6 @@ #define _ASSET_LOADING_H_ #include "types.h" -#include "gzip.h" -#include "memory.h" void init_PI_mesg_queue(void); u32 *load_asset_section_from_rom(u32 assetIndex); diff --git a/src/audio.h b/src/audio.h index 4e67fb0d..b81ddb31 100644 --- a/src/audio.h +++ b/src/audio.h @@ -1,8 +1,8 @@ #ifndef _AUDIO_H_ #define _AUDIO_H_ -#include "types.h" #include "sched.h" +#include "audiosfx.h" #define AUDIO_CHANNELS 16 #define MUSIC_CHAN_MASK_NONE 0xFFFFFFFF @@ -14,8 +14,6 @@ enum AudioVolumeBehaviour { VOLUME_UNK03, }; -typedef struct ALSoundState* SoundHandle; - /* Size: 0x0A bytes */ typedef struct SoundData { u16 soundBite; // Audio file index. @@ -28,7 +26,6 @@ typedef struct SoundData { u8 unk9; } SoundData; - /* Size: 0x03 bytes */ typedef struct MusicData { u8 volume; @@ -43,23 +40,11 @@ typedef struct DelayedSound { /* 0x04 */ SoundHandle *handlePtr; } DelayedSound; -void alCSPNew(ALCSPlayer *seqp, ALSeqpConfig *config); //lib/src/al/csplayer.c -void alCSPSetBank(ALCSPlayer *seqp, ALBank *b); //lib/src/unknown_0C8660.c -void set_voice_limit(ALCSPlayer *seqp, u8 voiceLimit); //lib/src/mips1/alseqplayer.c -void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size); //lib/src/al/alHeapDBAlloc.c -void alCSPSetChlPan(ALCSPlayer *seqp, u8 channel, ALPan pan); //lib/src/unknown_0C84E0.c -void alCSPSetChlVol(ALCSPlayer *, u8 channel, u8 volume); //lib/src/unknown_0C84E0.c -u8 alCSPGetChlVol(ALCSPlayer *seqp, u8 channel); //lib/src/al -void alCSPSetFadeIn(ALCSPlayer *seqp, u8 channel, ALPan pan); //lib/src/unknown_0647A0.c -u8 alCSPGetFadeIn(ALCSPlayer *seqp, u8 channel); //lib/src/mips1/al/unknown_064800.c -u8 alSeqpGetChlFXMix(ALSeqPlayer *seqp, u8 channel); //lib/src/al/alSeqpGetChlFXMix.c -void alFxReverbSet(u8 arg0); //lib/src/mips1/al/reverb.c -u8 _alFxEnabled(); //lib/src/mips1/al/reverb.c -void alHeapInit(ALHeap *hp, u8 *base, s32 len); //lib/src/al/alHeapInit.c -void alBnkfNew(ALBankFile *ctl, u8 *tbl); //lib/src/al/global_asm.c -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 +// These are all functions in libultra that seem to have been created by Rare, so they're not in the standard headers. +extern void set_voice_limit(ALCSPlayer *seqp, u8 voiceLimit); // seqplayer.c +extern void alCSPSetFadeIn(ALCSPlayer *seqp, u8 chan, ALPan pan); // cspsetfadein.c +extern void alFxReverbSet(u8 setting); // reverb.c +extern u8 alCSPGetFadeIn(ALCSPlayer *seqp, u8 chan); // cspgetfadein.c void audio_init(OSSched *sc); void sound_volume_reset(u8 skipReset); @@ -116,12 +101,10 @@ ALCSPlayer *sound_seqplayer_init(s32 maxVoices, s32 maxEvents); void music_sequence_start(u8 seqID, ALCSPlayer *seqPlayer); void music_sequence_stop(ALCSPlayer *seqPlayer); void sound_reverb_set(u8 setting); -void alSeqFileNew(ALSeqFile *file, u8 *base); void func_80063A90(ALCSPlayer *seqp, u8 channel); void sound_volume_set_relative(u16 soundID, SoundHandle soundHandle, u8 volume); void music_sequence_init(ALCSPlayer *seqp, void *sequence, u8 *seqID, ALCSeq *seq); void sound_play(u16 soundID, SoundHandle* handlePtr); -void sound_play(u16 soundID, SoundHandle* handlePtr); f32 music_animation_fraction(void); #endif diff --git a/src/audio_spatial.c b/src/audio_spatial.c index 49a77ad4..29c03eba 100644 --- a/src/audio_spatial.c +++ b/src/audio_spatial.c @@ -9,6 +9,7 @@ #include "audiosfx.h" #include "tracks.h" #include "math_util.h" +#include "menu.h" #define MAX_AUDIO_POINTS 40 #define MAX_AUDIO_LINES 7 diff --git a/src/audio_spatial.h b/src/audio_spatial.h index 820e35e8..36d011a2 100644 --- a/src/audio_spatial.h +++ b/src/audio_spatial.h @@ -2,11 +2,8 @@ #define _AUDIO_SPATIAL_H_ #include "types.h" -#include "libc/math.h" #include "structs.h" #include "PR/gbi.h" -#include "PR/libaudio.h" -#include "camera.h" #define AUDIO_LINE_TYPE_SOUND 0 #define AUDIO_LINE_TYPE_JINGLE 1 diff --git a/src/audio_vehicle.c b/src/audio_vehicle.c index 53b2abdd..4a58b121 100644 --- a/src/audio_vehicle.c +++ b/src/audio_vehicle.c @@ -11,6 +11,7 @@ #include "game_ui.h" #include "math_util.h" #include "printf.h" +#include "asset_loading.h" /************ .data ************/ diff --git a/src/audio_vehicle.h b/src/audio_vehicle.h index 4c0d050d..76ff66da 100644 --- a/src/audio_vehicle.h +++ b/src/audio_vehicle.h @@ -1,7 +1,6 @@ #ifndef _AUDIO_VEHICLE_H_ #define _AUDIO_VEHICLE_H_ -#include "types.h" #include "structs.h" #include "audio.h" #include "camera.h" diff --git a/src/audiomgr.c b/src/audiomgr.c index 8dce204f..11c5a62e 100644 --- a/src/audiomgr.c +++ b/src/audiomgr.c @@ -7,6 +7,7 @@ #include "PR/abi.h" #include "common.h" #include "stacks.h" +#include "rcp_dkr.h" /**** type define's for structures unique to audiomgr ****/ typedef union { diff --git a/src/audiomgr.h b/src/audiomgr.h index 70f052df..1a34e729 100644 --- a/src/audiomgr.h +++ b/src/audiomgr.h @@ -6,6 +6,7 @@ #include "asset_enums.h" #include #include "sched.h" +#include "PR/libaudio.h" #define MAX_UPDATES 32 #define MAX_EVENTS 32 @@ -39,13 +40,6 @@ #define MAX_SEQ_LENGTH 20000 -extern Acmd *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen); -extern void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size); -extern void alInit(ALGlobals *g, ALSynConfig *c); - -extern s8 rspF3DDKRBootStart[]; -extern s8 rspF3DDKRDramStart[]; - void audioStartThread(void); void audioStopThread(void); void amCreateAudioMgr(ALSynConfig *c, OSPri pri, OSSched *audSched); diff --git a/src/audiosfx.h b/src/audiosfx.h index 28cd649b..ab6616d1 100644 --- a/src/audiosfx.h +++ b/src/audiosfx.h @@ -1,13 +1,8 @@ #ifndef _AUDIOSFX_H_ #define _AUDIOSFX_H_ -#include "types.h" #include "macros.h" -#include "asset_enums.h" -#include -#include "sched.h" -#include "structs.h" -#include "audio.h" +#include "PR/libaudio.h" #define AL_SNDP_PLAY_EVT (1 << 0) #define AL_SNDP_RELEASE_EVT (1 << 1) @@ -61,6 +56,8 @@ typedef struct ALSoundState { /* 0x3F */ u8 state; } ALSoundState; +typedef struct ALSoundState* SoundHandle; + typedef struct ALSoundStateLists { /* 0x00 */ ALSoundState *allocHead; /* 0x04 */ ALSoundState *allocTail; @@ -109,12 +106,6 @@ typedef struct audioMgrConfig_s{ /* 0x10 */ u16 numGroups; } audioMgrConfig; -extern void *alHeapDBAlloc(u8 *file, s32 line, ALHeap *hp, s32 num, s32 size); -extern void alEvtqNew(ALEventQueue *evtq, ALEventListItem *items, s32 itemCount); -extern ALMicroTime alEvtqNextEvent(ALEventQueue *evtq, ALEvent *evt); -extern void alSynAddPlayer(ALSynth *drvr, ALPlayer *client); -extern void alEvtqPostEvent(ALEventQueue *evtq, ALEvent *evt, ALMicroTime delta); - void sndp_set_global_volume(u32 volume); s32 sndp_get_global_volume(void); void sndp_set_active_sound_limit(s32 numSounds); diff --git a/src/borders.h b/src/borders.h index 799904e5..58251894 100644 --- a/src/borders.h +++ b/src/borders.h @@ -1,8 +1,7 @@ #ifndef _BORDERS_H_ #define _BORDERS_H_ -#include "types.h" -#include "f3ddkr.h" +#include "PR/gbi.h" void divider_draw(Gfx **dList); void divider_clear_coverage(Gfx **dList); diff --git a/src/camera.c b/src/camera.c index 1f630646..a2256724 100644 --- a/src/camera.c +++ b/src/camera.c @@ -9,6 +9,8 @@ #include "weather.h" #include "PRinternal/piint.h" #include "PRinternal/viint.h" +#include "textures_sprites.h" +#include "menu.h" #define CAMERA_MODEL_STACK_SIZE 5 diff --git a/src/camera.h b/src/camera.h index da289e35..81022faf 100644 --- a/src/camera.h +++ b/src/camera.h @@ -2,12 +2,8 @@ #define _CAMERA_H_ #include "types.h" -#include "macros.h" #include "structs.h" #include "f3ddkr.h" -#include "menu.h" -#include -#include "libc/math.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 diff --git a/src/fade_transition.c b/src/fade_transition.c index 73f25ce4..b6e830e4 100644 --- a/src/fade_transition.c +++ b/src/fade_transition.c @@ -9,6 +9,8 @@ #include "textures_sprites.h" #include "math_util.h" #include "PRinternal/viint.h" +#include "camera.h" +#include "video.h" /************ .data ************/ diff --git a/src/fade_transition.h b/src/fade_transition.h index 87501416..87b81d40 100644 --- a/src/fade_transition.h +++ b/src/fade_transition.h @@ -2,7 +2,8 @@ #define _FADE_TRANSITION_H_ #include "types.h" -#include "camera.h" +#include "structs.h" +#include "PR/gbi.h" #define FADE_FULLSCREEN 0 #define FADE_BARNDOOR_HORIZONTAL 1 diff --git a/src/font.c b/src/font.c index e672dc88..ac790042 100644 --- a/src/font.c +++ b/src/font.c @@ -3,6 +3,9 @@ #include "textures_sprites.h" #include "camera.h" #include "common.h" +#include "video.h" +#include "asset_loading.h" +#include "memory.h" /************ .data ************/ diff --git a/src/font.h b/src/font.h index 1697f66a..4cb35812 100644 --- a/src/font.h +++ b/src/font.h @@ -1,17 +1,8 @@ #ifndef _FONT_H_ #define _FONT_H_ -#include "memory.h" -#include "video.h" - -#include "asset_loading.h" #include "structs.h" #include "types.h" -#include "macros.h" -#include "asset_enums.h" -#include -#include "f3ddkr.h" -#include "textures_sprites.h" #define POS_CENTRED -0x8000 diff --git a/src/game.c b/src/game.c index 135910e8..b5b50b21 100644 --- a/src/game.c +++ b/src/game.c @@ -23,6 +23,7 @@ #include "racer.h" #include "joypad.h" #include "common.h" +#include "thread3_main.h" /************ .data ************/ diff --git a/src/game.h b/src/game.h index 8b36db9e..2e1aeffc 100644 --- a/src/game.h +++ b/src/game.h @@ -3,9 +3,7 @@ #include "types.h" #include "structs.h" -#include "fade_transition.h" #include "racer.h" -#include "thread3_main.h" /* Size: 6 bytes */ typedef struct LevelGlobalData { diff --git a/src/game_text.c b/src/game_text.c index 485407a4..8a75431b 100644 --- a/src/game_text.c +++ b/src/game_text.c @@ -6,6 +6,10 @@ #include "game.h" #include "joypad.h" #include "PRinternal/viint.h" +#include "asset_loading.h" +#include "thread3_main.h" +#include "memory.h" +#include "camera.h" /************ .data ************/ diff --git a/src/game_text.h b/src/game_text.h index fb9038cf..36bfa2a5 100644 --- a/src/game_text.h +++ b/src/game_text.h @@ -2,11 +2,6 @@ #define _GAME_TEXT_H_ #include "types.h" -#include "macros.h" -#include "f3ddkr.h" -#include "asset_enums.h" -#include "memory.h" -#include "font.h" #define SET_TEXTBOX_BOUNDARY(leftVal, topVal, rightVal, bottomVal) \ textBox.left = leftVal; \ diff --git a/src/game_ui.c b/src/game_ui.c index 1395365e..0164c8c3 100644 --- a/src/game_ui.c +++ b/src/game_ui.c @@ -20,6 +20,9 @@ #include "audio_spatial.h" #include "joypad.h" #include "PRinternal/viint.h" +#include "asset_loading.h" +#include "thread3_main.h" +#include "menu.h" /************ .data ************/ diff --git a/src/game_ui.h b/src/game_ui.h index 393fea79..eed5b015 100644 --- a/src/game_ui.h +++ b/src/game_ui.h @@ -1,9 +1,8 @@ #ifndef _GAME_UI_H_ #define _GAME_UI_H_ -#include "types.h" #include "structs.h" -#include +#include "PR/sptask.h" #define ASSET_MASK_MODEL 0x0000 #define ASSET_MASK_OBJECT 0x4000 diff --git a/src/gzip.c b/src/gzip.c index cca8e921..c11a36c2 100644 --- a/src/gzip.c +++ b/src/gzip.c @@ -1,6 +1,7 @@ #include "gzip.h" #include "asset_loading.h" #include "PR/os_libc.h" +#include "memory.h" /************ .data ************/ diff --git a/src/gzip.h b/src/gzip.h index f6c8ccee..44947e77 100644 --- a/src/gzip.h +++ b/src/gzip.h @@ -1,9 +1,7 @@ #ifndef _GZIP_H_ #define _GZIP_H_ -#include "memory.h" #include "types.h" -#include "macros.h" typedef struct huft { u8 e; /* number of extra bits or operation */ diff --git a/src/hasm/math_util.c b/src/hasm/math_util.c index 97dce274..efa8e8b1 100644 --- a/src/hasm/math_util.c +++ b/src/hasm/math_util.c @@ -203,7 +203,6 @@ void mtxf_to_mtx(MtxF *mf, Mtx *m) { } } } -} #else GLOBAL_ASM("asm/math_util/mtxf_to_mtx.s") #endif diff --git a/src/joypad.c b/src/joypad.c index 2e3633ef..fa5ddba1 100644 --- a/src/joypad.c +++ b/src/joypad.c @@ -1,5 +1,8 @@ #include "joypad.h" #include "game.h" +#include "menu.h" +#include "thread3_main.h" +#include "save_layout.h" s32 sNoControllerPluggedIn = FALSE; // Looks to be a boolean for whether a controller is plugged in. FALSE if plugged in, and TRUE if not. diff --git a/src/joypad.h b/src/joypad.h index a963b203..8555a1c3 100644 --- a/src/joypad.h +++ b/src/joypad.h @@ -2,9 +2,7 @@ #define _JOYPAD_H_ #include "types.h" -#include "macros.h" -#include "structs.h" -#include +#include "PR/os_message.h" #define CONTROLLER_MISSING -1 #define CONTROLLER_EXISTS 0 diff --git a/src/lights.c b/src/lights.c index 8e13d068..f714043b 100644 --- a/src/lights.c +++ b/src/lights.c @@ -6,6 +6,7 @@ #include "objects.h" #include "game.h" #include "math_util.h" +#include "libc/math.h" /************ .data ************/ diff --git a/src/lights.h b/src/lights.h index adc5e683..b0c2b35d 100644 --- a/src/lights.h +++ b/src/lights.h @@ -3,7 +3,6 @@ #include "types.h" #include "structs.h" -#include "libc/math.h" enum LightType { LIGHT_UNK0, diff --git a/src/main.c b/src/main.c index eadbb619..aae441a6 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,8 @@ #include "thread0_epc.h" #include "game.h" #include "stacks.h" +#include "memory.h" +#include "thread3_main.h" /************ .bss ************/ diff --git a/src/main.h b/src/main.h index 7f139333..3c5aac07 100644 --- a/src/main.h +++ b/src/main.h @@ -2,8 +2,6 @@ #define _MAIN_H_ #include "types.h" -#include "macros.h" -#include extern u8 *main_BSS_START[]; diff --git a/src/math_util.h b/src/math_util.h index 7fd21cee..ceeda0b1 100644 --- a/src/math_util.h +++ b/src/math_util.h @@ -47,7 +47,7 @@ void mtxf_to_mtxs(MtxF *mf, MtxS *mi); void mtxf_transform_point(MtxF *mf, float x, float y, float z, float *ox, float *oy, float *oz); void mtxf_transform_dir(MtxF *mf, Vec3f *in, Vec3f *out); void mtxf_mul(MtxF *mat1, MtxF *mat2, MtxF *output); -void mtxf_to_mtx(MtxF *input, Mtx *output); +void mtxf_to_mtx(MtxF *mf, Mtx *m); void vec3s_reflect(Vec3s *vec, Vec3s *n); void mtxs_transform_dir(MtxS *mi, Vec3s *vec); void mtxf_from_transform(MtxF *mtx, ObjectTransform *trans); diff --git a/src/memory.c b/src/memory.c index 9e08bbad..bbaf10d4 100644 --- a/src/memory.c +++ b/src/memory.c @@ -2,6 +2,7 @@ #include "printf.h" #include "thread0_epc.h" #include "math_util.h" +#include "config.h" /************ .bss ************/ diff --git a/src/memory.h b/src/memory.h index 38dbcf82..123eb820 100644 --- a/src/memory.h +++ b/src/memory.h @@ -1,10 +1,7 @@ #ifndef _MEMORY_H_ #define _MEMORY_H_ -#include "structs.h" #include "types.h" -#include "macros.h" -#include "config.h" typedef enum MemoryPools { POOL_MAIN, diff --git a/src/menu.c b/src/menu.c index ceea54b7..341182b3 100644 --- a/src/menu.c +++ b/src/menu.c @@ -30,6 +30,10 @@ #include "math_util.h" #include "PRinternal/viint.h" #include "save_layout.h" +#include "asset_loading.h" +#include "thread3_main.h" +#include "PR/os_convert.h" +#include "PR/os_system.h" /** * @file Contains all the code used for every menu in the game. @@ -2646,6 +2650,10 @@ s32 menu_loop(Gfx **currDisplayList, Mtx **currHudMat, Vertex **currHudVerts, Tr case MENU_CAUTION: ret = menu_caution_loop(updateRate); break; +#ifdef AVOID_UB + default: + ret = MENU_RESULT_CONTINUE; +#endif } *currDisplayList = sMenuCurrDisplayList; *currHudMat = sMenuCurrHudMat; @@ -4526,6 +4534,11 @@ SIDeviceStatus savemenu_load_sources(void) { u32 fileSizes[16]; char *temp_D_80126A64; +#ifdef AVOID_UB + // If gSaveMenuSourceState == 0, then result will be undefined. + result = CONTROLLER_PAK_GOOD; +#endif + settings = gSavefileData[3]; gSaveMenuOptionCountUpper = 0; gSaveMenuOptionSource = 0; @@ -4713,6 +4726,11 @@ SIDeviceStatus savemenu_write(void) { char fileExt[PFS_FILE_EXT_LEN]; Settings *settings; +#ifdef AVOID_UB + // ret can be unset if certain conditions are met. + ret = CONTROLLER_PAK_GOOD; +#endif + settings = get_settings(); switch (gSaveMenuFilesSource[gSaveMenuOptionSource].saveFileType) { case SAVE_FILE_TYPE_CART_SAVE: @@ -7993,6 +8011,11 @@ s32 menu_file_select_loop(s32 updateRate) { u32 buttonsPressed; Settings *settings; +#ifdef AVOID_UB + // i can be undefined in certain cases, and it's used for the save file number. + i = 0; +#endif; + settings = get_settings(); charselect_music_channels(updateRate); if (gOpacityDecayTimer) { @@ -8630,6 +8653,13 @@ s32 func_8008F618(Gfx **dList, Mtx **mtx) { index++; texV = bgTexture->height << 5; } +#ifdef AVOID_UB + else { + // texU and texV aren't set if bgTexture is NULL + texU = 0; + texV = 0; + } +#endif triangles[0].uv0.u = texU; triangles[0].uv0.v = 0; triangles[0].uv1.u = texU; @@ -12344,6 +12374,10 @@ s32 menu_trophy_race_rankings_loop(s32 updateRate) { if (gTrophyRaceRound < 4) { menu_init(MENU_TROPHY_RACE_ROUND); } else { +#ifdef AVOID_UB + // This value isn't set if certain conditions are met. + sp34 = 0; +#endif for (temp6 = 0, i = 0; i < gRankingPlayerCount; i++) { if (gRankingsPlayers[i] != 0) { temp7 = settings->racers[gRankingsPlayerIDs[i]].character; @@ -14853,14 +14887,14 @@ s32 is_in_two_player_adventure(void) { } /** - * Returns 1 if T.T. is avaliable to use, or 0 if not. + * Returns 1 if T.T. is available to use, or 0 if not. */ s32 is_tt_unlocked(void) { return gActiveMagicCodes & CHEAT_CONTROL_TT; } /** - * Returns 1 if Drumstick is avaliable to use, or 0 if not. + * Returns 1 if Drumstick is available to use, or 0 if not. */ s32 is_drumstick_unlocked(void) { return gActiveMagicCodes & CHEAT_CONTROL_DRUMSTICK; diff --git a/src/menu.h b/src/menu.h index ab80cd72..5d9030f6 100644 --- a/src/menu.h +++ b/src/menu.h @@ -1,11 +1,8 @@ #ifndef _MENU_H_ #define _MENU_H_ -#include "types.h" #include "structs.h" #include "PR/gbi.h" -#include "audio.h" -#include "fade_transition.h" #include "font.h" #include "save_data.h" @@ -252,6 +249,49 @@ typedef enum MENU_ID { MENU_CAUTION } MENU_ID; +enum MenuResult { + MENU_RESULT_CONTINUE, + MENU_RESULT_RETURN_TO_GAME, + MENU_RESULT_UNK2, + MENU_RESULT_UNK3, + MENU_RESULT_UNK4, + MENU_RESULT_TRACKS_MODE, + MENU_RESULT_UNK6, + MENU_RESULT_UNK7, + MENU_RESULT_UNK8, + MENU_RESULT_UNK9, + MENU_RESULT_UNK10, + MENU_RESULT_UNK11, + MENU_RESULT_UNK12, + MENU_RESULT_UNK13, + MENU_RESULT_UNK14, + MENU_RESULT_UNK15, + MENU_RESULT_UNK16, + MENU_RESULT_UNK17, + MENU_RESULT_UNK18, +}; + +enum MenuResultFlags { + MENU_RESULT_FLAGS_0, + MENU_RESULT_FLAGS_1 = (1 << 0), + MENU_RESULT_FLAGS_2 = (1 << 1), + MENU_RESULT_FLAGS_4 = (1 << 2), + MENU_RESULT_FLAGS_8 = (1 << 3), + MENU_RESULT_FLAGS_10 = (1 << 4), + MENU_RESULT_FLAGS_20 = (1 << 5), + MENU_RESULT_FLAGS_40 = (1 << 6), + MENU_RESULT_FLAGS_80 = (1 << 7), + MENU_RESULT_FLAGS_100 = (1 << 8), + MENU_RESULT_FLAGS_200 = (1 << 9), +}; + +enum TrackFinishBits { + RACE_UNATTEMPTED, + RACE_VISITED = (1 << 0), + RACE_CLEARED = (1 << 1), + RACE_CLEARED_SILVER_COINS = (1 << 2), +}; + typedef enum PakError { PAK_ERROR_NONE, PAK_ERROR_FATAL, diff --git a/src/object_functions.c b/src/object_functions.c index 1524dd33..8cd9c441 100644 --- a/src/object_functions.c +++ b/src/object_functions.c @@ -30,6 +30,8 @@ #include "printf.h" #include "PRinternal/viint.h" #include "common.h" +#include "thread3_main.h" +#include "textures_sprites.h" /************ .data ************/ diff --git a/src/object_functions.h b/src/object_functions.h index 09658fea..0471f595 100644 --- a/src/object_functions.h +++ b/src/object_functions.h @@ -1,11 +1,9 @@ #ifndef _OBJECT_FUNCTIONS_H_ #define _OBJECT_FUNCTIONS_H_ -#include "macros.h" #include "types.h" #include "structs.h" #include "level_object_entries.h" -#include "libc/math.h" #define WORLD_KEY_GRAB_CHECK_RADIUS 50 diff --git a/src/object_models.c b/src/object_models.c index 3911905d..a8490e7e 100644 --- a/src/object_models.c +++ b/src/object_models.c @@ -8,6 +8,8 @@ #include "textures_sprites.h" #include "racer.h" #include "objects.h" +#include "gzip.h" +#include "libc/math.h" #define MODEL_LOADED_MAX 70 diff --git a/src/object_models.h b/src/object_models.h index 561b1f52..ac2adf1d 100644 --- a/src/object_models.h +++ b/src/object_models.h @@ -1,8 +1,6 @@ #ifndef _OBJECT_MODELS_H_ #define _OBJECT_MODELS_H_ -#include "types.h" -#include "PR/gbi.h" #include "structs.h" typedef enum AnimType { diff --git a/src/objects.c b/src/objects.c index acb11f1c..aaa97eae 100644 --- a/src/objects.c +++ b/src/objects.c @@ -31,6 +31,15 @@ #include "printf.h" #include "weather.h" #include "PRinternal/piint.h" +#include "gzip.h" +#include "video.h" +#include "thread3_main.h" +#include "textures_sprites.h" +#include "fade_transition.h" +#include "PR/os_system.h" +#include "PR/os_cont.h" +#include "PR/os_convert.h" +#include "PR/rcp.h" #define MAX_CHECKPOINTS 60 #define OBJECT_POOL_SIZE 0x15800 @@ -632,7 +641,7 @@ void racerfx_update(s32 updateRate) { boostObj->unk74 += updateRateF * 0.25f; updateRateF = 0.0f; if (boostObj->unk74 > 2.4f) { - boostObj->unk74 = (f32) (4.8f - boostObj->unk74); + boostObj->unk74 = 4.8f - boostObj->unk74; boostObj->unk70 = 1; } } @@ -1770,6 +1779,11 @@ void func_8000E5EC(LevelObjectEntryCommon *arg0) { } else if ((s32) arg0 >= (s32) D_8011AE98[1] && (s32) arg0 < sp30[1]) { sp1C = 1; } +#ifdef AVOID_UB + else { + sp1C = 0; + } +#endif dst = (u8 *) arg0; src = (u8 *) ((s32) arg0 + size); @@ -5875,11 +5889,10 @@ s32 func_800185E4(s32 checkpointIndex, Object *obj, f32 objX, f32 objY, f32 objZ sp68 = sp4C->rotationXFrac * objX + sp4C->rotationYFrac * objY + sp4C->rotationZFrac * objZ + sp4C->unkC; if (sp68 > 0) { if (obj->behaviorId == BHV_RACER) { - Object_Racer *racer; - racer = obj->racer; + Object_Racer *objRacer = obj->racer; if (sp4C->unk3B != 0) { - racer->indicator_type = sp4C->unk3B; - racer->indicator_timer = 120; + objRacer->indicator_type = sp4C->unk3B; + objRacer->indicator_timer = 120; } } @@ -8839,7 +8852,7 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { f32 spB4; s8 *miscAsset; s32 pad; - FadeTransition fadeTransition; // spA4 + FadeTransition fadeTransition; if (gCutsceneID < 0) { return 1; @@ -8858,20 +8871,20 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { if (obj64->startDelay < 0) { var_t0 = 0; if (obj64->unk34 & 1) { - var_t0 = 0x8000; + var_t0 = A_BUTTON; } if (obj64->unk34 & 2) { - var_t0 |= 0x4000; + var_t0 |= B_BUTTON; } if (obj64->unk34 & 4) { - var_t0 |= 0x1000; + var_t0 |= CONT_START; } var_s2 = 0; - var_s0 = 0; - do { - var_s2 |= input_pressed(var_s0); - } while (++var_s0 < 4); + + // clang-format off + for (var_s0 = 0; var_s0 < MAXCONTROLLERS; var_s0++) { var_s2 |= input_pressed(var_s0); } + // clang-format on if (var_s2 & var_t0) { obj64->startDelay = 1; @@ -8882,7 +8895,7 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { obj64->startDelay -= arg1; if (obj64->startDelay <= 0) { obj64->unk45 = 1; - temp_s1 = (LevelObjectEntry_Animation *) obj64->unk1C->level_entry; + temp_s1 = &obj64->unk1C->level_entry->animation; func_80021104(arg0, obj64, temp_s1); obj64->startDelay = 0; func_8002125C(arg0, temp_s1, obj64, -1); @@ -8890,7 +8903,7 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { } if (obj64->startDelay != 0) { if (obj64->unk3A != 0) { - arg0->trans.flags |= 0x4000; + arg0->trans.flags |= OBJ_FLAGS_INVISIBLE; obj64->unk42 = 0; return 1; } else { @@ -8898,7 +8911,7 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { } } - arg0->trans.flags &= ~0x4000; + arg0->trans.flags &= ~OBJ_FLAGS_INVISIBLE; if (obj64->unk39 > 0) { if (obj64->unk39 != music_current_sequence()) { music_play(obj64->unk39); @@ -8942,31 +8955,31 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { var_t0 -= (arg1 * 8); } else { var_t0 = 0; - arg0->trans.flags |= 0x4000; + arg0->trans.flags |= OBJ_FLAGS_INVISIBLE; } } else { if (obj64->unk41 & 2) { var_t0 = 0xFF; } var_t0 += arg1 * 8; - if (var_t0 >= 0x100) { + if (var_t0 > 0xFF) { var_t0 = 0xFF; } - arg0->trans.flags &= ~0x4000; + arg0->trans.flags &= ~OBJ_FLAGS_INVISIBLE; } var_s2 = obj64->unk3B & 0x7F; obj64->unk42 = var_t0; if (var_s2 != 0x7F) { if (var_s2 >= 8) { - miscAsset = ((s8 *) get_misc_asset(0xD) + (var_s2 * 5)); + miscAsset = ((s8 *) get_misc_asset(ASSET_MISC_13) + (var_s2 * 5)); miscAsset -= 0x28; - var_t0 = (miscAsset[0] & 0xFF) + 0x384; - var_s0 = (miscAsset[1] & 0xFF) + 0x384; + var_t0 = (miscAsset[0] & 0xFF) + 900; + var_s0 = (miscAsset[1] & 0xFF) + 900; slowly_change_fog(0, miscAsset[2] & 0xFF, miscAsset[3] & 0xFF, miscAsset[4] & 0xFF, var_t0, var_s0, normalise_time(6) * obj64->unk3C); } else if (var_s2 >= 6) { - fadeTransition.type = 0x40; + fadeTransition.type = FADE_FLAG_INVERT; // clang-format off if (var_s2 == 7) { fadeTransition.red = 200; fadeTransition.green = 200; fadeTransition.blue = 255; @@ -8979,7 +8992,7 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { transition_begin(&fadeTransition); } else { fadeTransition.type = obj64->unk3B; - miscAsset = (s8 *) get_misc_asset(0xE) + (obj64->unk40 * 3); + miscAsset = (s8 *) get_misc_asset(ASSET_MISC_14) + (obj64->unk40 * 3); fadeTransition.red = miscAsset[0]; fadeTransition.green = miscAsset[1]; fadeTransition.blue = miscAsset[2]; @@ -9242,7 +9255,6 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { sp124 *= var_f2; sp120 *= var_f2; sp11C *= var_f2; - // sp11C *= (sp120 *= (sp124 *= (f32) (100.0 / var_f2))); // fake!!! } arg0->trans.rotation.y_rotation = arctan2_f(sp124, sp11C) - 0x8000; arg0->trans.rotation.x_rotation = arctan2_f(sp120, 100.0f); @@ -9251,39 +9263,39 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { break; default: for (var_t0 = 1; var_t0 < 5; var_t0++) { - f32 var_f0 = 0; + f32 temp = 0; f32 delta; delta = spE0[var_t0] - spE0[var_t0 - 1]; if (delta > 32768.0) { - var_f0 -= 65536.0; + temp -= 65536.0; } else if (delta < -32768.0) { - var_f0 += 65536.0; + temp += 65536.0; } // clang-format off - for (var_s0 = var_t0; var_s0 < 5; var_s0++) { spE0[var_s0] += var_f0; } + for (var_s0 = var_t0; var_s0 < 5; var_s0++) { spE0[var_s0] += temp; } // clang-format on - var_f0 = 0; + temp = 0; delta = spCC[var_t0] - spCC[var_t0 - 1]; if (delta > 32768.0) { - var_f0 -= 65536.0; + temp -= 65536.0; } else if (delta < -32768.0) { - var_f0 += 65536.0; + temp += 65536.0; } // clang-format off - for (var_s0 = var_t0; var_s0 < 5; var_s0++) {spCC[var_s0] += var_f0; } + for (var_s0 = var_t0; var_s0 < 5; var_s0++) {spCC[var_s0] += temp; } // clang-format on - var_f0 = 0; + temp = 0; delta = spB8[var_t0] - spB8[var_t0 - 1]; if (delta > 32768.0) { - var_f0 -= 65536.0; + temp -= 65536.0; } else if (delta < -32768.0) { - var_f0 += 65536.0; + temp += 65536.0; } // clang-format off - for (var_s0 = var_t0; var_s0 < 5; var_s0++) { spB8[var_s0] += var_f0; } + for (var_s0 = var_t0; var_s0 < 5; var_s0++) { spB8[var_s0] += temp; } // clang-format on } if (obj64->unk3F == 0) { @@ -9300,7 +9312,7 @@ s32 func_8001F460(Object *arg0, s32 arg1, Object *arg2) { var_t0 = obj64->unk26; obj64->unk0 = var_f20; - if ((sp168 != -1) && (var_t0 >= var_s5)) { + if (sp168 != -1 && var_t0 >= var_s5) { var_t0 = (var_t0 - var_s5) + sp168; } diff --git a/src/objects.h b/src/objects.h index b3b84110..f9a90767 100644 --- a/src/objects.h +++ b/src/objects.h @@ -1,12 +1,11 @@ #ifndef _OBJECTS_H_ #define _OBJECTS_H_ -#include "types.h" #include "structs.h" #include "f3ddkr.h" #include "object_functions.h" -#include "camera.h" #include "particles.h" +#include "save_data.h" #define NEW_OBJECT_ENTRY(entryVar, entryId, entrySize, xPos, yPos, zPos) \ { \ diff --git a/src/particles.c b/src/particles.c index 2435dc67..f06a1092 100644 --- a/src/particles.c +++ b/src/particles.c @@ -2,6 +2,13 @@ #include "objects.h" #include "math_util.h" #include "tracks.h" +#include "textures_sprites.h" +#include "asset_loading.h" +#include +#include "camera.h" +#include "libc/math.h" +#include "PR/os_system.h" +#include "PR/os_convert.h" /************ .rodata ************/ diff --git a/src/particles.h b/src/particles.h index 763b3dd1..332bb5ba 100644 --- a/src/particles.h +++ b/src/particles.h @@ -1,9 +1,7 @@ #ifndef _PARTICLES_H_ #define _PARTICLES_H_ -#include "types.h" #include "structs.h" -#include enum ParticleKind { PARTICLE_KIND_NONE = 0, diff --git a/src/printf.c b/src/printf.c index 42a6eb6b..e6c70690 100644 --- a/src/printf.c +++ b/src/printf.c @@ -6,6 +6,7 @@ #include "libc/string.h" #include "textures_sprites.h" #include "rcp_dkr.h" +#include "video.h" /************ .data ************/ diff --git a/src/printf.h b/src/printf.h index 1a9cf748..4e0bab84 100644 --- a/src/printf.h +++ b/src/printf.h @@ -1,9 +1,6 @@ #ifndef _PRINTF_H_ #define _PRINTF_H_ -#include "types.h" -#include "structs.h" -#include "macros.h" #include "stdarg.h" #include diff --git a/src/racer.c b/src/racer.c index 179bf0de..317c1f91 100644 --- a/src/racer.c +++ b/src/racer.c @@ -16,7 +16,6 @@ #include "printf.h" #include "math_util.h" #include "tracks.h" -#include "weather.h" #include "vehicle_misc.h" #include "audio_vehicle.h" #include "game_ui.h" @@ -27,6 +26,13 @@ #include "particles.h" #include "PRinternal/viint.h" #include "common.h" +#include "asset_loading.h" +#include "thread3_main.h" +#include "textures_sprites.h" +#include "fade_transition.h" +#include "PR/os_system.h" +#include "PR/os_cont.h" +#include "PR/os_libc.h" #define MAX_NUMBER_OF_GHOST_NODES 360 diff --git a/src/racer.h b/src/racer.h index 2e8c6bc0..b55ebc8f 100644 --- a/src/racer.h +++ b/src/racer.h @@ -1,7 +1,6 @@ #ifndef _RACER_H_ #define _RACER_H_ -#include "types.h" #include "structs.h" #include "level_object_entries.h" #include "save_data.h" diff --git a/src/rcp_dkr.c b/src/rcp_dkr.c index c6dcba48..a0374389 100644 --- a/src/rcp_dkr.c +++ b/src/rcp_dkr.c @@ -6,6 +6,8 @@ #include "camera.h" #include "set_rsp_segment.h" #include "racer.h" +#include "textures_sprites.h" +#include "memory.h" /************ .data ************/ diff --git a/src/rcp_dkr.h b/src/rcp_dkr.h index 921db31a..ac0a6b67 100644 --- a/src/rcp_dkr.h +++ b/src/rcp_dkr.h @@ -1,14 +1,10 @@ #ifndef _RCP_DKR_H_ #define _RCP_DKR_H_ -#include "types.h" -#include "structs.h" -#include "f3ddkr.h" -#include "sched.h" #include - +#include "structs.h" +#include "sched.h" #include "game_ui.h" -#include "video.h" // Recommended size is around 100KB, or 0x19000. This is unused though so it doesn't matter. #define OUTPUT_BUFFER_SIZE 0x1800 diff --git a/src/save_data.c b/src/save_data.c index 5656d026..847d7659 100644 --- a/src/save_data.c +++ b/src/save_data.c @@ -13,6 +13,9 @@ #include "PRinternal/viint.h" #include "PR/os_motor.h" #include "save_layout.h" +#include "libc/string.h" +#include "save_layout.h" +#include "menu.h" /************ .data ************/ diff --git a/src/save_data.h b/src/save_data.h index 2a5b8cf2..68787da8 100644 --- a/src/save_data.h +++ b/src/save_data.h @@ -1,13 +1,8 @@ #ifndef _SAVE_DATA_H_ #define _SAVE_DATA_H_ -#include "types.h" #include "structs.h" -#include "save_layout.h" #include "PR/os_pfs.h" -#include "PR/os_cont.h" -#include "PR/os_libc.h" -#include "libc/string.h" #include "common.h" #define GAMD 0x47414D44 // 'GAMD' ASCII - Game Data? diff --git a/src/screen_asset.c b/src/screen_asset.c index d4695e12..4768b568 100644 --- a/src/screen_asset.c +++ b/src/screen_asset.c @@ -1,4 +1,12 @@ -#include "screen_asset.h" +#include "video.h" +#include "memory.h" +#include "types.h" +#include "macros.h" +#include "f3ddkr.h" +#include "asset_enums.h" +#include "asset_loading.h" + +#define SCREEN_HEIGHT_PART 6 // Render settings for the screens Gfx gRdpSetModeScreenAsset[] = { diff --git a/src/screen_asset.h b/src/screen_asset.h deleted file mode 100644 index fa4c6875..00000000 --- a/src/screen_asset.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _SCREEN_ASSET_H_ -#define _SCREEN_ASSET_H_ - -#include "video.h" -#include "memory.h" -#include "types.h" -#include "macros.h" -#include "f3ddkr.h" -#include "asset_enums.h" -#include "asset_loading.h" - -#define SCREEN_HEIGHT_PART 6 - -#endif diff --git a/src/textures_sprites.c b/src/textures_sprites.c index dcf2f93d..7de70ad8 100644 --- a/src/textures_sprites.c +++ b/src/textures_sprites.c @@ -5,6 +5,7 @@ #include "math_util.h" #include "tracks.h" #include "game_ui.h" +#include #define MAX_NUM_TEXTURES 700 #define MAX_NUM_SPRITES 100 diff --git a/src/textures_sprites.h b/src/textures_sprites.h index 556af38d..62dfb49a 100644 --- a/src/textures_sprites.h +++ b/src/textures_sprites.h @@ -1,13 +1,9 @@ #ifndef _TEXTURES_SPRITES_H_ #define _TEXTURES_SPRITES_H_ -#include "asset_enums.h" #include "types.h" #include "f3ddkr.h" #include "structs.h" -#include "macros.h" -#include "memory.h" -#include #define TEX_TABLE_2D 0 #define TEX_TABLE_3D 1 diff --git a/src/thread30_bgload.c b/src/thread30_bgload.c index 9a497117..b86ae0f7 100644 --- a/src/thread30_bgload.c +++ b/src/thread30_bgload.c @@ -3,6 +3,7 @@ #include #include "game.h" #include "stacks.h" +#include "thread3_main.h" /************ .data ************/ diff --git a/src/thread3_main.c b/src/thread3_main.c index c7352d05..d375d49f 100644 --- a/src/thread3_main.c +++ b/src/thread3_main.c @@ -45,6 +45,8 @@ #include "PRinternal/viint.h" #include "font.h" #include "stacks.h" +#include "save_layout.h" +#include "game.h" /************ .rodata ************/ diff --git a/src/thread3_main.h b/src/thread3_main.h index 99a62017..c27ba774 100644 --- a/src/thread3_main.h +++ b/src/thread3_main.h @@ -4,7 +4,6 @@ #include "types.h" #include "macros.h" #include "structs.h" -#include "game.h" typedef enum GameMode { GAMEMODE_INTRO = -1, @@ -36,49 +35,6 @@ enum LevelLoadContext { LEVEL_CONTEXT_CREDITS }; -enum MenuResult { - MENU_RESULT_CONTINUE, - MENU_RESULT_RETURN_TO_GAME, - MENU_RESULT_UNK2, - MENU_RESULT_UNK3, - MENU_RESULT_UNK4, - MENU_RESULT_TRACKS_MODE, - MENU_RESULT_UNK6, - MENU_RESULT_UNK7, - MENU_RESULT_UNK8, - MENU_RESULT_UNK9, - MENU_RESULT_UNK10, - MENU_RESULT_UNK11, - MENU_RESULT_UNK12, - MENU_RESULT_UNK13, - MENU_RESULT_UNK14, - MENU_RESULT_UNK15, - MENU_RESULT_UNK16, - MENU_RESULT_UNK17, - MENU_RESULT_UNK18, -}; - -enum MenuResultFlags { - MENU_RESULT_FLAGS_0, - MENU_RESULT_FLAGS_1 = (1 << 0), - MENU_RESULT_FLAGS_2 = (1 << 1), - MENU_RESULT_FLAGS_4 = (1 << 2), - MENU_RESULT_FLAGS_8 = (1 << 3), - MENU_RESULT_FLAGS_10 = (1 << 4), - MENU_RESULT_FLAGS_20 = (1 << 5), - MENU_RESULT_FLAGS_40 = (1 << 6), - MENU_RESULT_FLAGS_80 = (1 << 7), - MENU_RESULT_FLAGS_100 = (1 << 8), - MENU_RESULT_FLAGS_200 = (1 << 9), -}; - -enum TrackFinishBits { - RACE_UNATTEMPTED, - RACE_VISITED = (1 << 0), - RACE_CLEARED = (1 << 1), - RACE_CLEARED_SILVER_COINS = (1 << 2), -}; - /** * Bit 00: Read Eeprom Data flap times * Bit 01: Read Eeprom Data course times diff --git a/src/tracks.c b/src/tracks.c index ad93bc40..3a9a7f3a 100644 --- a/src/tracks.c +++ b/src/tracks.c @@ -15,12 +15,16 @@ #include "game_ui.h" #include "weather.h" #include "particles.h" -#include "objects.h" #include "math_util.h" -#include "printf.h" #include "collision.h" #include "PRinternal/viint.h" #include "common.h" +#include "gzip.h" +#include "asset_loading.h" +#include "video.h" +#include "thread3_main.h" +#include "fade_transition.h" +#include "menu.h" // Maximum size for a level model is 522.5 KiB #define LEVEL_MODEL_MAX_SIZE 0x82A00 diff --git a/src/tracks.h b/src/tracks.h index 0b887a35..32e2eb4a 100644 --- a/src/tracks.h +++ b/src/tracks.h @@ -1,11 +1,8 @@ #ifndef _TRACKS_H_ #define _TRACKS_H_ -#include "types.h" #include "structs.h" #include "f3ddkr.h" -#include "racer.h" -#include "fade_transition.h" #define LOCAL_OFFSET_TO_RAM_ADDRESS(type, ptr) ptr = (type) ((s32) ((u8 *) ptr) + (s32) ((u8 *) mdl)) diff --git a/src/vehicle_bluey.c b/src/vehicle_bluey.c index 0585d94a..558927f2 100644 --- a/src/vehicle_bluey.c +++ b/src/vehicle_bluey.c @@ -7,6 +7,8 @@ #include "audio_spatial.h" #include "racer.h" #include "particles.h" +#include "audio.h" +#include "camera.h" /************ .data ************/ diff --git a/src/vehicle_bubbler.c b/src/vehicle_bubbler.c index 0d65c44f..c1ce16c3 100644 --- a/src/vehicle_bubbler.c +++ b/src/vehicle_bubbler.c @@ -7,6 +7,8 @@ #include "objects.h" #include "particles.h" #include "printf.h" +#include "audio.h" +#include "camera.h" /************ .data ************/ diff --git a/src/vehicle_rocket.c b/src/vehicle_rocket.c index 79adfd6d..0b9fbb35 100644 --- a/src/vehicle_rocket.c +++ b/src/vehicle_rocket.c @@ -11,14 +11,23 @@ /************ .data ************/ // 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, +u16 gRocketVoiceTable[16] = { + 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_NONE, + SOUND_NONE, }; /*******************************/ @@ -49,7 +58,7 @@ void update_rocket(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r ModelInstance *modInst; ObjectModel *objModel; - set_boss_voice_clip_offset((u16 *) gRocketVoiceTable); + set_boss_voice_clip_offset(gRocketVoiceTable); racer->tappedR = 0; animID = obj->animationID; animFrame = obj->animFrame; diff --git a/src/vehicle_smokey.c b/src/vehicle_smokey.c index 3f07aa52..70efdf14 100644 --- a/src/vehicle_smokey.c +++ b/src/vehicle_smokey.c @@ -8,6 +8,8 @@ #include "audio_spatial.h" #include "racer.h" #include "particles.h" +#include "audio.h" +#include "camera.h" /************ .data ************/ diff --git a/src/vehicle_tricky.c b/src/vehicle_tricky.c index bec43d0d..25794b20 100644 --- a/src/vehicle_tricky.c +++ b/src/vehicle_tricky.c @@ -11,6 +11,8 @@ #include "game.h" #include "particles.h" #include "math_util.h" +#include "thread3_main.h" +#include "fade_transition.h" /************ .data ************/ diff --git a/src/vehicle_wizpig.c b/src/vehicle_wizpig.c index f36d3eb1..e44c9faa 100644 --- a/src/vehicle_wizpig.c +++ b/src/vehicle_wizpig.c @@ -6,17 +6,28 @@ #include "objects.h" #include "object_functions.h" #include "particles.h" +#include "audio.h" +#include "camera.h" /************ .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, +u16 gWizpigVoiceTable[16] = { + 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_NONE, + SOUND_NONE, }; /*******************************/ @@ -54,7 +65,7 @@ void update_wizpig(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r ObjectModel *objModel; ModelInstance *modInst; - set_boss_voice_clip_offset((u16 *) gWizpigVoiceTable); + set_boss_voice_clip_offset(gWizpigVoiceTable); racer->tappedR = 0; animID = obj->animationID; animFrame = obj->animFrame; diff --git a/src/video.c b/src/video.c index 5f74930a..d0eb0822 100644 --- a/src/video.c +++ b/src/video.c @@ -1,5 +1,7 @@ #include "video.h" #include "PRinternal/viint.h" +#include "types.h" +#include "memory.h" /************ .data ************/ diff --git a/src/video.h b/src/video.h index 40ac590f..3476cbf3 100644 --- a/src/video.h +++ b/src/video.h @@ -1,10 +1,6 @@ #ifndef _VIDEO_H_ #define _VIDEO_H_ -#include "types.h" -#include "macros.h" -#include "memory.h" -#include "PR/os_message.h" #include "PR/os_vi.h" #include "sched.h" diff --git a/src/waves.c b/src/waves.c index caba07f2..530d7950 100644 --- a/src/waves.c +++ b/src/waves.c @@ -8,8 +8,9 @@ #include "tracks.h" #include "math_util.h" #include "PRinternal/viint.h" - +#include "racer.h" #include "printf.h" +#include "camera.h" /************ .data ************/ diff --git a/src/waves.h b/src/waves.h index 5165dfa6..466ffcd3 100644 --- a/src/waves.h +++ b/src/waves.h @@ -1,7 +1,6 @@ #ifndef _WAVES_H_ #define _WAVES_H_ -#include "types.h" #include "structs.h" /* Size: 4 bytes */ diff --git a/src/weather.c b/src/weather.c index 95c46ad9..79b2dc8d 100644 --- a/src/weather.c +++ b/src/weather.c @@ -11,6 +11,10 @@ #include "objects.h" #include "PRinternal/viint.h" #include "common.h" +#include "video.h" +#include "asset_loading.h" +#include "audio.h" +#include "fade_transition.h" #define WEATHER_OVERRIDE_COUNT 16 diff --git a/src/weather.h b/src/weather.h index a42f5a74..c1a1df2e 100644 --- a/src/weather.h +++ b/src/weather.h @@ -2,8 +2,6 @@ #define _WEATHER_H_ #include "types.h" -#include "textures_sprites.h" -#include "audio.h" #include "camera.h" typedef enum WeatherType {