diff --git a/.gitignore b/.gitignore index a5a35aa4..7d58e8c2 100755 --- a/.gitignore +++ b/.gitignore @@ -72,5 +72,6 @@ tools/n64crc m2cfiles/ gcc_safe_files.mk tools/ido-recomp -tools/binutils *.DS_Store +tools/binutils +*.d diff --git a/Makefile b/Makefile index 45855f7c..1e9d9466 100755 --- a/Makefile +++ b/Makefile @@ -8,8 +8,8 @@ COMPILER ?= ido $(eval $(call validate-option,NON_MATCHING,ido gcc)) # Define a custom boot file if desired to use something other than the vanilla one -BOOT_CUSTOM ?= boot_custom.bin -BOOT_CIC ?= 6102 +BOOT_CUSTOM ?= mods/boot_custom.bin +BOOT_CIC ?= 6103 $(eval $(call validate-option,BOOT_CIC,6102 6103)) LIBULTRA_VERSION_DEFINE := -DBUILD_VERSION=4 -DBUILD_VERSION_STRING=\"2.0G\" @@ -87,7 +87,6 @@ O_FILES := $(foreach file,$(S_FILES),$(BUILD_DIR)/$(file).o) \ $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file).o) \ $(foreach file,$(BIN_FILES),$(BUILD_DIR)/$(file).o) - find-command = $(shell which $(1) 2>/dev/null) # Tools @@ -98,6 +97,7 @@ else ifeq ($(shell type mips64-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0 CROSS := mips64-linux-gnu- else ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0) CROSS := mips64-elf- +else # No binutil packages were found, so we have to download the source & build it. ifeq ($(wildcard $(TOOLS_DIR)/binutils/.*),) DUMMY != $(TOOLS_DIR)/get-binutils.sh >&2 || echo FAIL @@ -124,31 +124,39 @@ MIPSISET = -mips1 DEFINES := _FINALROM NDEBUG TARGET_N64 F3DDKR_GBI DEFINES += VERSION_$(REGION)_$(VERSION) +MATCHDEFS := VERIFY = verify ifeq ($(NON_MATCHING),1) - DEFINES += NON_MATCHING - DEFINES += AVOID_UB + MATCHDEFS += NON_MATCHING=1 + MATCHDEFS += AVOID_UB=1 VERIFY = no_verify + MIPSISET = -mips2 C_STANDARD := -std=gnu99 else - DEFINES += ANTI_TAMPER + MATCHDEFS += ANTI_TAMPER=1 # Override compiler choice on matching builds. COMPILER := ido - C_STANDARD := -std=gnu99 + BOOT_CIC := 6103 + C_STANDARD := -std=gnu90 endif +DEFINES += $(MATCHDEFS) C_DEFINES := $(foreach d,$(DEFINES),-D$(d)) $(LIBULTRA_VERSION_DEFINE) -D_MIPS_SZLONG=32 -ASM_DEFINES = --defsym _MIPS_SIM=1 --defsym mips=1 --defsym VERSION_$(REGION)_$(VERSION)=1 +ASM_DEFINES = $(foreach d,$(DEFINES),$(if $(findstring =,$(d)),--defsym $(d),)) --defsym _MIPS_SIM=1 --defsym mips=1 --defsym VERSION_$(REGION)_$(VERSION)=1 # If NON_MATCHING and using a custom boot file, (Right now just 6102). # Define this so it will change the entrypoint in the header ifeq ($(NON_MATCHING),1) -ifneq ("$(wildcard $(BOOT_CUSTOM))","") +ifeq ("$(wildcard $(BOOT_CUSTOM))","") +BOOT_CIC := 6103 +endif +endif + ASM_DEFINES += --defsym BOOT_$(BOOT_CIC)=1 -endif -endif + +C_DEFINES += -DCIC_ID=$(BOOT_CIC) INCLUDE_CFLAGS = -I . -I include -I include/libc -I include/PR -I include/sys -I $(BIN_DIRS) -I $(SRC_DIR) -I $(LIBULTRA_DIR) INCLUDE_CFLAGS += -I $(LIBULTRA_DIR)/src/gu -I $(LIBULTRA_DIR)/src/libc -I $(LIBULTRA_DIR)/src/io -I $(LIBULTRA_DIR)/src/sc @@ -166,24 +174,28 @@ endif #IDO Warnings to Ignore. These are coding style warnings we don't follow -CC_WARNINGS := -fullwarn -Xfullwarn -woff 838,649,624 +CC_WARNINGS := -fullwarn -Xfullwarn -woff 838,649,624,835,516 CFLAGS := -G 0 -non_shared -verbose -Xcpluscomm -nostdinc -Wab,-r4300_mul CFLAGS += $(C_DEFINES) CFLAGS += $(INCLUDE_CFLAGS) -CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wunused-function -Wno-unused-parameter -Werror-implicit-function-declaration -CHECK_WARNINGS += -Werror-implicit-function-declaration -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-main -CHECK_WARNINGS += -Wno-builtin-declaration-mismatch -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-switch -# Disable GCC complaining about fakematches necessary to match if building a matching ROM. Example: "var2 = (0, var1)" -ifeq ($(NON_MATCHING),0) - CHECK_WARNINGS += -Wno-unused-value -endif -CC_CHECK := $(GCC) -fsyntax-only -fno-builtin -funsigned-char $(C_STANDARD) -D_LANGUAGE_C -DNON_MATCHING -DNON_EQUIVALENT $(CHECK_WARNINGS) $(INCLUDE_CFLAGS) $(C_DEFINES) $(GCC_COLOR) -ifeq ($(shell getconf LONG_BIT), 64) - # Ensure that gcc treats the code as 32-bit - CC_CHECK += -m32 +CHECK_WARNINGS := -Wall -Wextra -Werror-implicit-function-declaration -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-missing-braces \ + -Wno-main -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-switch -Wno-pointer-sign +ifeq ($(DETECTED_OS), macos) + CHECK_WARNINGS += -Wno-constant-conversion -Wno-for-loop-analysis + # Disable GCC complaining about fakematches necessary to match if building a matching ROM. Example: "var2 = (0, var1)" + ifeq ($(NON_MATCHING),0) + CHECK_WARNINGS += -Wno-unused-value -Wno-deprecated-non-prototype -Wno-array-bounds -Wno-self-assign -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable + endif +else + CHECK_WARNINGS += -Wno-builtin-declaration-mismatch + # Disable GCC complaining about fakematches necessary to match if building a matching ROM. Example: "var2 = (0, var1)" + ifeq ($(NON_MATCHING),0) + CHECK_WARNINGS += -Wno-unused-value -Wno-array-bounds -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable + endif endif +CC_CHECK := $(GCC) -fsyntax-only -fno-builtin -funsigned-char $(C_STANDARD) -m32 -DAVOID_UB -D_LANGUAGE_C -DNON_MATCHING -DNON_EQUIVALENT $(CHECK_WARNINGS) $(INCLUDE_CFLAGS) $(C_DEFINES) $(GCC_COLOR) TARGET = $(BUILD_DIR)/$(BASENAME).$(REGION).$(VERSION) LD_SCRIPT = ver/$(BASENAME).$(REGION).$(VERSION).ld @@ -410,14 +422,14 @@ $(TARGET).elf: dirs $(LD_SCRIPT) $(O_FILES) | $(ALL_ASSETS_BUILT) ifndef PERMUTER $(GLOBAL_ASM_O_FILES): $(BUILD_DIR)/%.c.o: %.c | $(ALL_ASSETS_BUILT) $(call print,Compiling:,$<,$@) - $(V)$(CC_CHECK) $< + $(V)$(CC_CHECK) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $< $(V)$(CC) -c $(CFLAGS) $(CC_WARNINGS) $(OPT_FLAGS) $(MIPSISET) -o $@ $< endif # non asm-processor recipe $(BUILD_DIR)/%.c.o: %.c | $(ALL_ASSETS_BUILT) $(call print,Compiling:,$<,$@) - $(V)$(CC_CHECK) $< + $(V)$(CC_CHECK) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $< $(V)$(CC) -c $(CFLAGS) $(CC_WARNINGS) $(OPT_FLAGS) $(MIPSISET) -o $@ $< $(BUILD_DIR)/$(LIBULTRA_DIR)/src/libc/llcvt.c.o: $(LIBULTRA_DIR)/src/libc/llcvt.c | $(ALL_ASSETS_BUILT) @@ -432,7 +444,7 @@ $(BUILD_DIR)/$(LIBULTRA_DIR)/src/libc/ll.c.o: $(LIBULTRA_DIR)/src/libc/ll.c | $( $(BUILD_DIR)/%.s.o: %.s | $(ALL_ASSETS_BUILT) $(call print,Assembling:,$<,$@) - $(V)$(AS) $(ASFLAGS) -o $@ $< + $(V)$(AS) $(ASFLAGS) -MD $(BUILD_DIR)/$*.d -o $@ $< # Specifically override the assets bin output location to match what splat output to the ld file. $(BUILD_DIR)/asm/assets/assets.s.o: asm/assets/assets.s | $(ALL_ASSETS_BUILT) @@ -473,3 +485,5 @@ $(TARGET).z64: $(TARGET).bin | $(ALL_ASSETS_BUILT) ### Settings .PHONY: all clean cleanextract default assets SHELL = /bin/bash -e -o pipefail + +-include $(BUILD_DIR)/**/*.d diff --git a/include/macros.h b/include/macros.h index 2d7a3f47..f38a7a52 100644 --- a/include/macros.h +++ b/include/macros.h @@ -46,6 +46,20 @@ #define ALIGNED16 #endif +// Use built-in pseudocode where possible in NON_MATCHING builds +#ifdef __GNUC__ +#define abs(x) __builtin_abs(x) +#define fabsf(x) __builtin_fabsf(x) +#define sqrtf(f) __builtin_sqrtf(f) +#undef ABS +#undef ABSF +#define ABS(x) __builtin_abs(x) +#define ABSF(x) __builtin_fabsf(x) +#else +#define inline +#define ABSF(x) (x < 0.f ? -x : x) +#endif + // convert a virtual address to physical. #define VIRTUAL_TO_PHYSICAL(addr) ((uintptr_t)(addr) & 0x1FFFFFFF) @@ -55,8 +69,6 @@ // another way of converting virtual to physical #define VIRTUAL_TO_PHYSICAL2(addr) ((u8 *)(addr) - 0x80000000U) -#define ABSF(x) (x < 0.f ? -x : x) - // Used to suppress warnings in the ./generate_ctx.sh script. #define INCONSISTENT diff --git a/libultra/src/audio/mips1/csplayer.c b/libultra/src/audio/mips1/csplayer.c index 7cbbbe95..710624a0 100644 --- a/libultra/src/audio/mips1/csplayer.c +++ b/libultra/src/audio/mips1/csplayer.c @@ -43,6 +43,7 @@ #include "seqp.h" #include "cseqp.h" #include "cseq.h" +#include "synthInternals.h" /************ .rodata ************/ const char D_800E6C20[] = "CSP: oh oh \n"; @@ -55,6 +56,7 @@ static void __CSPHandleMIDIMsg(ALCSPlayer_Custom *seqp, ALEvent *eve static void __CSPHandleMetaMsg(ALCSPlayer *seqp, ALEvent *event); static void __CSPRepostEvent(ALEventQueue *evtq, ALEventListItem *item); static void __setUsptFromTempo(ALCSPlayer *seqp, f32 tempo); /* sct 1/8/96 */ + void func_80065A80(ALSynth *arg0, PVoice *arg1, s16 arg2); /* @@ -144,7 +146,7 @@ static ALMicroTime __CSPVoiceHandler(void *node) switch (seqp->nextEvent.type) { case (AL_SEQ_REF_EVT): - __CSPHandleNextSeqEvent(seqp); + __CSPHandleNextSeqEvent((ALCSPlayer *) seqp); break; case (AL_SEQP_API_EVT): @@ -210,7 +212,7 @@ static ALMicroTime __CSPVoiceHandler(void *node) break; case (AL_SEQP_META_EVT): - __CSPHandleMetaMsg(seqp, &seqp->nextEvent); + __CSPHandleMetaMsg((ALCSPlayer *) seqp, &seqp->nextEvent); break; case (AL_SEQP_VOL_EVT): @@ -227,7 +229,7 @@ static ALMicroTime __CSPVoiceHandler(void *node) if (seqp->state != AL_PLAYING) { seqp->state = AL_PLAYING; - __CSPPostNextSeqEvent(seqp); /* seqp must be AL_PLAYING before we call this routine. */ + __CSPPostNextSeqEvent((ALCSPlayer *) seqp); /* seqp must be AL_PLAYING before we call this routine. */ } break; @@ -396,7 +398,7 @@ __CSPHandleNextSeqEvent(ALCSPlayer *seqp) switch (evt.type) { case AL_SEQ_MIDI_EVT: - __CSPHandleMIDIMsg(seqp, &evt); + __CSPHandleMIDIMsg((ALCSPlayer_Custom *) seqp, &evt); __CSPPostNextSeqEvent(seqp); break; diff --git a/libultra/src/os/sethwinterrupt.c b/libultra/src/os/sethwinterrupt.c index 31b2dd4f..90882464 100644 --- a/libultra/src/os/sethwinterrupt.c +++ b/libultra/src/os/sethwinterrupt.c @@ -26,7 +26,7 @@ extern struct s32 (*__osHwIntTable[])(void); void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void)) { register u32 saveMask = __osDisableInt(); - __osHwIntTable[interrupt] = handler; + __osHwIntTable[interrupt] = (void *) handler; __osRestoreInt(saveMask); } diff --git a/src/audio.c b/src/audio.c index 5bc90b17..1bfe7ece 100644 --- a/src/audio.c +++ b/src/audio.c @@ -808,7 +808,6 @@ void sound_play(u16 soundID, s32 *soundMask) { if (soundMask != NULL) { *soundMask = NULL; } - stubbed_printf("amSndPlayDirect: Somebody tried to play illegal sound %d\n", soundID); return; } pitch = gSoundTable[soundID].pitch / 100.0f; @@ -847,6 +846,7 @@ void sound_play_spatial(u16 soundID, f32 x, f32 y, f32 z, s32 **soundMask) { void func_80001F14(u16 soundID, s32 *soundMask) { if (soundID <= 0 || sound_count() < soundID) { + stubbed_printf("amSndPlayDirect: Somebody tried to play illegal sound %d\n", soundID); if (soundMask) { *soundMask = NULL; } diff --git a/src/audio_spatial.c b/src/audio_spatial.c index c9ddb255..ecbf8030 100644 --- a/src/audio_spatial.c +++ b/src/audio_spatial.c @@ -91,7 +91,7 @@ void func_80008174(void) { s32 j; for (gFreeMasks = 0; gFreeMasks < 40; gFreeMasks++) { - gSoundMaskHeapFree[gFreeMasks] = gSoundMaskHeap[gFreeMasks]; + gSoundMaskHeapFree[gFreeMasks] = (SoundMask *) gSoundMaskHeap[gFreeMasks]; } gFreeMasks--; diff --git a/src/audio_vehicle.c b/src/audio_vehicle.c index 6275c7be..fd2dab7e 100644 --- a/src/audio_vehicle.c +++ b/src/audio_vehicle.c @@ -80,8 +80,8 @@ VehicleSoundData *func_80004B40(s8 characterId, s8 vehicleId) { temp_v0_3 = (VehicleSoundData *) mempool_alloc_safe(sizeof(VehicleSoundData), COLOUR_TAG_CYAN); // Not really sure this is right... - memset = temp_v0_3; - for (var_a3 = 0; var_a3 < sizeof(VehicleSoundData); var_a3++) { + memset = (u8 *) temp_v0_3; + for (var_a3 = 0; var_a3 < (s32) sizeof(VehicleSoundData); var_a3++) { memset[var_a3] = 0; } @@ -106,11 +106,11 @@ VehicleSoundData *func_80004B40(s8 characterId, s8 vehicleId) { var_v1_2 = &temp_v0_2[1]; temp_v0_3->unk4[0][0] = temp_v0_2->unk4[2]; var_a1 = temp_v0_2 + 2; - temp_v0_3->unk18[0] = temp_v0_2->unk18; + temp_v0_3->unk18[0] = (s32) temp_v0_2->unk18; var_a0 = temp_v0_3 + 1; 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; + var_a2 = (VehicleSoundData *) &temp_v0_3->unk0[1]; + temp_v0_3->unk2C[0] = (s32) temp_v0_2->unk2C; loop_10: var_a3_2 += 2; var_a0->unk4[0][0] = (u8) var_v1_2->unk4[0]; @@ -335,9 +335,9 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR if (var_f20 > 12.0f) { var_f20 = 12.0f; } - func_80001F14(25, &gRacerSound->unkA8); + func_80001F14(25, (s32 *) &gRacerSound->unkA8); sp6C = (((var_f20 * 0.5) / 12.0) + 0.5); - temp_a0_4 = gRacerSound->unkA8; + temp_a0_4 = (s32) gRacerSound->unkA8; if (temp_a0_4 != 0) { sound_event_update(temp_a0_4, 16, *((u32 *) &sp6C)); } @@ -351,9 +351,9 @@ void func_80005254(Object *obj, u32 buttonsPressed, u32 buttonsHeld, s32 updateR gRacerSound->unkD0 = 0; } if (gRacerSound->unkD0 >= 10) { - sound_event_update(gRacerSound->unkA8, 8, 0); + sound_event_update((s32) gRacerSound->unkA8, 8, 0); } else { - sound_event_update(gRacerSound->unkA8, 8, gRacerSound->unkAC << 8); + sound_event_update((s32) 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); } @@ -559,7 +559,7 @@ void func_800063EC(Object *obj, UNUSED u32 buttonsPressed, u32 buttonsHeld, s32 if ((gSoundRacerObj->playerIndex != PLAYER_COMPUTER) && (gSoundRacerObj->spinout_timer != 0) && !gRacerSound->brakeSound) { gRacerSound->brakeSound = TRUE; - sound_play(SOUND_UNK_13D, &gRacerSound->brakeSoundMask); + sound_play(SOUND_UNK_13D, (s32 *) &gRacerSound->brakeSoundMask); } else if (gSoundRacerObj->spinout_timer == 0) { gRacerSound->brakeSound = FALSE; if (gRacerSound->brakeSoundMask != NULL) { @@ -746,10 +746,10 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 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((s32) gRacerSound->unk50, 8, temp_s3 << 8); + sound_event_update((s32) gRacerSound->unk50, 16, *((u32 *) &sp8C)); func_80004604(gRacerSound->unk50, 80); - sound_event_update(gRacerSound->unk50, 4, gRacerSound->unk91[0]); + sound_event_update((s32) gRacerSound->unk50, 4, gRacerSound->unk91[0]); } } else if (gRacerSound->unk50 != NULL) { sound_stop(gRacerSound->unk50); @@ -783,13 +783,13 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 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((s32) gRacerSound->unk48[loopCount2], 8, temp_s3 << 8); + sound_event_update((s32) gRacerSound->unk48[loopCount2], 16, *((u32 *) &sp8C)); func_80004604(gRacerSound->unk48[loopCount2], 80); if (arg3 != 1) { gRacerSound->unk91[0] = 64; } - sound_event_update(gRacerSound->unk48[loopCount2], 4, gRacerSound->unk91[0]); + sound_event_update((s32) gRacerSound->unk48[loopCount2], 4, gRacerSound->unk91[0]); } } } @@ -810,7 +810,7 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 racer = &objs[loopCount1]->unk64->racer; for (loopCount2 = arg3; loopCount2 < numRacers; loopCount2++) { if (objs[loopCount2]->unk64 != NULL) { - gRacerSound = (VehicleSoundData *) objs[loopCount2]->unk64->racer.cameraYaw; + gRacerSound = (VehicleSoundData *) (s32) objs[loopCount2]->unk64->racer.cameraYaw; if (gRacerSound != 0) { if (racer->raceFinished != 0) { tempxPos = @@ -924,12 +924,12 @@ void func_80006FC8(Object **objs, s32 numRacers, ObjectSegment *segment, u8 arg3 if (temp->unk48[0] != NULL) { 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((s32) temp->unk48[0], 8, temp->unk88 << 8); + sound_event_update((s32) temp->unk48[0], 16, *((u32 *) &temp->unk8C)); if (arg3 != 1) { temp->unk91[0] = 64; } - sound_event_update(temp->unk48[0], 4, temp->unk91[0]); + sound_event_update((s32) temp->unk48[0], 4, temp->unk91[0]); func_80004604(temp->unk48[0], 70); } } diff --git a/src/audiomgr.c b/src/audiomgr.c index df996926..ad5d4ab2 100644 --- a/src/audiomgr.c +++ b/src/audiomgr.c @@ -7,6 +7,7 @@ #include "objects.h" #include "PR/abi.h" #include "common.h" +#include "stacks.h" /**** type define's for structures unique to audiomgr ****/ typedef union { @@ -63,7 +64,7 @@ OSSched *gAudioSched; ALHeap *gAudioHeap; // Set but not used AMAudioMgr __am; -static u64 audioStack[AUDIO_STACKSIZE / sizeof(u64)]; +static u64 audioStack[STACKSIZE(STACK_AUD)]; AMDMAState dmaState; AMDMABuffer dmaBuffs[NUM_DMA_BUFFERS]; @@ -192,8 +193,7 @@ void amCreateAudioMgr(ALSynConfig *c, OSPri pri, OSSched *audSched) { osCreateMesgQueue(&__am.audioReplyMsgQ, __am.audioReplyMsgBuf, MAX_MESGS); 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 + STACKSIZE(STACK_AUD)), pri); } /** diff --git a/src/audiomgr.h b/src/audiomgr.h index 2c49a652..de17893d 100644 --- a/src/audiomgr.h +++ b/src/audiomgr.h @@ -38,9 +38,6 @@ /* be deleted as quickly. This results in fewer */ /* DMA's but you need more buffers. */ - -#define AUDIO_STACKSIZE 0x3010 - #define MAX_SEQ_LENGTH 20000 extern Acmd *alAudioFrame(Acmd *cmdList, s32 *cmdLen, s16 *outBuf, s32 outLen); diff --git a/src/audiosfx.c b/src/audiosfx.c index 76dd6da2..34b145fb 100644 --- a/src/audiosfx.c +++ b/src/audiosfx.c @@ -64,7 +64,7 @@ void alSndPNew(audioMgrConfig *c) { 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_800DC6B0.unk8 = gAlSndPlayerPtr->unk40; + D_800DC6B0.unk8 = (ALSoundState *) gAlSndPlayerPtr->unk40; for (i = 1; i < c->unk00; i++) { tmp1 = gAlSndPlayerPtr->unk40; alLink((ALLink *) (i + tmp1), (ALLink *) (i + tmp1 - 1)); @@ -174,27 +174,27 @@ u16 func_800042CC(u16 *lastAllocListIndex, u16 *lastFreeListIndex) { u16 freeListNextIndex; u16 allocListNextIndex; u16 freeListLastIndex; - ALLink *nextAllocList; - ALLink *nextFreeList; - ALLink *prevFreeList; + ALSoundState *nextAllocList; + ALSoundState *nextFreeList; + ALSoundState *prevFreeList; ALSoundState *queue; mask = osSetIntMask(OS_IM_NONE); queue = (ALSoundState *) &D_800DC6B0; - nextFreeList = (ALLink *) queue->next; - nextAllocList = (ALLink *) queue->unk8; - prevFreeList = (ALLink *) queue->prev; + nextFreeList = queue->next; + nextAllocList = queue->unk8; + prevFreeList = queue->prev; for (freeListNextIndex = 0; nextFreeList != 0; freeListNextIndex++) { - nextFreeList = (ALLink *) nextFreeList->next; + nextFreeList = nextFreeList->next; } for (allocListNextIndex = 0; nextAllocList != 0; allocListNextIndex++) { - nextAllocList = (ALLink *) nextAllocList->next; + nextAllocList = nextAllocList->next; } for (freeListLastIndex = 0; prevFreeList != 0; freeListLastIndex++) { - prevFreeList = (ALLink *) prevFreeList->prev; + prevFreeList = prevFreeList->prev; } *lastAllocListIndex = allocListNextIndex; @@ -219,18 +219,18 @@ ALSound *func_80004384(UNUSED ALBank *arg0, ALSound *arg1) { temp_a2 = arg1->keyMap; if (nextAllocList != NULL) { mask = osSetIntMask(OS_IM_NONE); - D_800DC6B0.unk8 = (ALLink *) nextAllocList->next; + D_800DC6B0.unk8 = nextAllocList->next; alUnlink((ALLink *) nextAllocList); if (D_800DC6B0.next != NULL) { - nextAllocList->next = (ALLink *) D_800DC6B0.next; + nextAllocList->next = D_800DC6B0.next; nextAllocList->prev = NULL; - ((ALLink *) (D_800DC6B0.next))->prev = (ALLink *) nextAllocList; - D_800DC6B0.next = (ALLink *) nextAllocList; + D_800DC6B0.next->prev = (ALSoundState *) nextAllocList; + D_800DC6B0.next = (ALSoundState *) nextAllocList; } else { nextAllocList->prev = NULL; nextAllocList->next = NULL; - D_800DC6B0.next = (ALLink *) nextAllocList; - D_800DC6B0.prev = (ALLink *) nextAllocList; + D_800DC6B0.next = (ALSoundState *) nextAllocList; + D_800DC6B0.prev = (ALSoundState *) nextAllocList; } osSetIntMask(mask); temp = ((arg1->envelope->decayTime + 1) == 0); @@ -239,7 +239,7 @@ ALSound *func_80004384(UNUSED ALBank *arg0, ALSound *arg1) { nextAllocList->unk36 = temp_a1; nextAllocList->unk3F = 5; nextAllocList->unk38 = 2; - nextAllocList->unk8 = arg1; + nextAllocList->unk8 = (ALSoundState *) arg1; nextAllocList->unk2C = 1.0f; nextAllocList->unk3E = temp_a2->keyMax & 0xF0; nextAllocList->unk30 = 0; @@ -279,6 +279,7 @@ s32 func_80004638(ALBank *bnk, s16 sndIndx, SoundMask *soundMask) { #ifdef NON_EQUIVALENT s32 func_80004668(ALBank *bnk, s16 sndIndx, u8 arg2, SoundMask *soundMask) { + return 0; } #else #pragma GLOBAL_ASM("asm/nonmatchings/audiosfx/func_80004668.s") diff --git a/src/fade_transition.c b/src/fade_transition.c index cdaaedf6..e7180f03 100644 --- a/src/fade_transition.c +++ b/src/fade_transition.c @@ -196,6 +196,9 @@ u32 check_fadeout_transition(void) { } } //!@bug: This doesn't seem to guarantee a return. +#ifdef AVOID_UB + return FALSE; +#endif } /** diff --git a/src/game.c b/src/game.c index da04e34f..1bd076fc 100644 --- a/src/game.c +++ b/src/game.c @@ -123,7 +123,7 @@ void init_level_globals(void) { D_80121178[i] = -1; } for (i = 0; i < gNumberOfLevelHeaders; i++) { - if ((gGlobalLevelTable[i].raceType == 5)) { + if (gGlobalLevelTable[i].raceType == 5) { D_80121178[gGlobalLevelTable[i].world] = i; } } diff --git a/src/hasm/header.s b/src/hasm/header.s index f3a344f8..44604cd3 100644 --- a/src/hasm/header.s +++ b/src/hasm/header.s @@ -30,30 +30,46 @@ .word 0xF7D9879F /* Checksum 2 */ .endif +.ifdef NON_MATCHING +.word main_BSS_START /* Unknown 1 */ +.else .word 0x00000000 /* Unknown 1 */ +.endif .word 0x00000000 /* Unknown 2 */ .ascii "Diddy Kong Racing " /* Internal name */ .word 0x00000000 /* Unknown 3 */ .word 0x0000004E /* Cartridge */ +.ifdef NON_MATCHING +.ascii "ED" /* Cartridge ID */ +.else .ascii "DY" /* Cartridge ID */ +.endif .ifdef VERSION_us_v77 .ascii "E" /* Country code */ -.byte 0x00 /* Version */ +.equ revision, 0x0 .endif .ifdef VERSION_pal_v77 .ascii "P" /* Country code */ -.byte 0x00 /* Version */ +.equ revision, 0x0 .endif .ifdef VERSION_jpn_v79 .ascii "J" /* Country code */ -.byte 0x00 /* Version */ +.equ revision, 0x0 .endif .ifdef VERSION_us_v80 .ascii "E" /* Country code */ -.byte 0x01 /* Version */ +.equ revision, 0x1 .endif .ifdef VERSION_pal_v80 .ascii "P" /* Country code */ -.byte 0x01 /* Version */ +.equ revision, 0x1 .endif + +.ifdef NON_MATCHING +.equ savetype, 0x1 +.else +.equ savetype, 0x0 +.endif + +.byte (revision | (savetype << 4)) /* Version */ diff --git a/src/lights.c b/src/lights.c index d306af4e..21ecf752 100644 --- a/src/lights.c +++ b/src/lights.c @@ -110,14 +110,14 @@ ObjectLight *func_80031CAC(Object *light, LevelObjectEntry_RgbaLight *lightEntry if (lightEntry->unk1C < 7) { test = (LevelHeader_70 *) get_current_level_header()->unk74[lightEntry->unk1C]; if (((s32) test) != -1) { - newLight->unk44 = &test->unk4; - newLight->unk44 = &test->unk0; + newLight->unk44 = (SubMiscAssetObjectHeader24 *) &test->unk4; + newLight->unk44 = (SubMiscAssetObjectHeader24 *) &test->unk0; newLight->unk4A = 0; if (lightEntry && lightEntry && lightEntry) {} newLight->unk4C = 0; newLight->unk4E = 0; - newLight->unk48 = (u16) &test->red2; - temp_a0 = (u16) &test->red2; + newLight->unk48 = (u16) (u32) &test->red2; + temp_a0 = (u16) (u32) &test->red2; for (i = 0; i < temp_a0;) { newLight->unk4E += test->unk18[i++].unk0; } @@ -473,7 +473,7 @@ void func_80032C7C(Object *object) { (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; + D_800DC960[D_800DC968].unk0 = (s32) entry->unk0; D_800DC960[D_800DC968].unk4 = entry->unk1C >> 0x10; D_800DC960[D_800DC968].unk8 = entry->unk20 >> 0x10; D_800DC960[D_800DC968].unkC = entry->unk24 >> 0x10; @@ -513,7 +513,7 @@ void func_80032C7C(Object *object) { D_800DC964[D_800DC968].y = gLightDiffY; D_800DC964[D_800DC968].z = gLightDiffZ; } - D_800DC960[D_800DC968].unk0 = entry; + D_800DC960[D_800DC968].unk0 = (s32) entry; D_800DC960[D_800DC968].unk4 = entry->unk1C >> 0x10; D_800DC960[D_800DC968].unk8 = entry->unk20 >> 0x10; D_800DC960[D_800DC968].unkC = entry->unk24 >> 0x10; diff --git a/src/main.c b/src/main.c index cc374668..b8f92306 100644 --- a/src/main.c +++ b/src/main.c @@ -2,11 +2,12 @@ #include "thread0_epc.h" #include "game.h" #include "libultra/src/libc/rmonPrintf.h" +#include "stacks.h" /************ .bss ************/ -u64 gThread1Stack[0x21]; -u64 gThread3Stack[0x401]; +u64 gThread1Stack[STACKSIZE(STACK_IDLE) + 1]; +u64 gThread3Stack[STACKSIZE(STACK_GAME) + 1]; OSThread gThread1; // OSThread for thread 1 OSThread gThread3; // OSThread for thread 3 @@ -23,7 +24,7 @@ void mainproc(void) { #ifdef AVOID_UB bzero(&gMainMemoryPool, RAM_END - (s32)(&gMainMemoryPool)); #endif - osCreateThread(&gThread1, 1, &thread1_main, 0, &gThread1Stack[0x20], OS_PRIORITY_IDLE); + osCreateThread(&gThread1, 1, &thread1_main, 0, &gThread1Stack[STACKSIZE(STACK_IDLE)], OS_PRIORITY_IDLE); osStartThread(&gThread1); } @@ -34,8 +35,8 @@ void mainproc(void) { */ void thread1_main(UNUSED void *unused) { thread0_create(); - osCreateThread(&gThread3, 3, &thread3_main, 0, &gThread3Stack[0x400], 10); - gThread3Stack[0x400] = 0; + osCreateThread(&gThread3, 3, &thread3_main, 0, &gThread3Stack[STACKSIZE(STACK_GAME)], 10); + gThread3Stack[STACKSIZE(STACK_GAME)] = 0; gThread3Stack[0] = 0; osStartThread(&gThread3); osSetThreadPri(NULL, OS_PRIORITY_IDLE); @@ -48,9 +49,9 @@ void thread1_main(UNUSED void *unused) { * Official Name: bootCheckStack */ void thread3_verify_stack(void) { - gThread3Stack[0x400]++; + gThread3Stack[STACKSIZE(STACK_GAME)]++; gThread3Stack[0]++; - if ((gThread3Stack[0x400] != gThread3Stack[0])) { + if ((gThread3Stack[STACKSIZE(STACK_GAME)] != gThread3Stack[0])) { rmonPrintf("WARNING: Stack overflow/underflow!!!\n"); } } diff --git a/src/memory.c b/src/memory.c index aaaf8ab6..b4834abb 100644 --- a/src/memory.c +++ b/src/memory.c @@ -639,6 +639,9 @@ UNUSED s32 find_active_pool_slot_colours(void) { stubbed_printf("Unable to record %d slots, colours overflowed table.\n", numOverflows); } numOverflows = slotColour; +#ifdef AVOID_UB + return 0; +#endif } /** diff --git a/src/menu.c b/src/menu.c index fa7079f7..280f9d9d 100644 --- a/src/menu.c +++ b/src/menu.c @@ -280,7 +280,7 @@ char **gTTSaveGhostPakErrorText; MatrixS *sMenuCurrHudMat; #endif Vertex *sMenuCurrHudVerts; -TriangleList *sMenuCurrHudTris; +Triangle *sMenuCurrHudTris; unk801263C0 gMenuSelectedCharacter; unk801263C0 D_801263B8; s32 gOptionBlinkTimer; @@ -1909,7 +1909,7 @@ s16 gWoodPanelVertColours[5][4] = { { 256, 256, 256, 256 } // Colour for the center of the panel }; -s32 *gWoodPanelVertices[2] = { NULL, NULL }; +Vertex *gWoodPanelVertices[2] = { NULL, NULL }; Triangle *gWoodPanelTriangles[2] = { NULL, NULL }; @@ -2158,16 +2158,16 @@ void func_8007FFEC(s32 arg0) { alloc = mempool_alloc_safe(arg0 * 0x2F0, COLOUR_TAG_WHITE); gWoodPanelTriangles[0] = alloc; gWoodPanelTriangles[1] = gWoodPanelTriangles[0] + sp20; - gMenuGeometry = gWoodPanelTriangles[1] + sp20; - gWoodPanelVertices[1] = gMenuGeometry; + gMenuGeometry = (unk80080BC8 *) gWoodPanelTriangles[1] + sp20; + gWoodPanelVertices[1] = (Vertex *) gMenuGeometry; gWoodPanelVertices[1] = gWoodPanelVertices[0] + arg0; // This loop isn't quite right. for (i = 0; i < arg0; i++) { - gMenuGeometry[i].vertices[0] = gWoodPanelVertices[0] + i; - gMenuGeometry[i].vertices[1] = gWoodPanelVertices[1] + i; - gMenuGeometry[i].triangles[0] = gWoodPanelTriangles[0] + i; - gMenuGeometry[i].triangles[1] = gWoodPanelTriangles[1] + i; + gMenuGeometry[i].vertices[0] = (Vertex *) gWoodPanelVertices[0] + i; + gMenuGeometry[i].vertices[1] = (Vertex *) gWoodPanelVertices[1] + i; + gMenuGeometry[i].triangles[0] = (Triangle *) gWoodPanelTriangles[0] + i; + gMenuGeometry[i].triangles[1] = (Triangle *) gWoodPanelTriangles[1] + i; gMenuGeometry[i].texture[0] = 0; gMenuGeometry[i].texture[1] = 0; gMenuGeometry[i].unk18[0] = 0; @@ -2580,7 +2580,7 @@ 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 menu_loop(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, Triangle **currHudTris, s32 updateRate) { s32 ret; @@ -2923,7 +2923,7 @@ void draw_menu_elements(s32 state, MenuElement *elems, f32 scale) { if (state == ((elems->t.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 ((state == 1)) { + } else if (state == 1) { xPos = elems->center; yPos = elems->middle; } else { @@ -8569,8 +8569,8 @@ s32 func_8008F618(Gfx **dList, MatrixS **mtx) { yPos = gTrackSelectViewPortHalfY + temp2; gDPSetPrimColor((*dList)++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor((*dList)++, 255, 255, 255, 0); - vertices = (&gTrackSelectBgVertices)[gTrackSelectVertsFlip]; - triangles = (&gTrackSelectBgTriangles)[gTrackSelectVertsFlip]; + vertices = (Vertex *) (&gTrackSelectBgVertices)[gTrackSelectVertsFlip]; + triangles = (Triangle *) (&gTrackSelectBgTriangles)[gTrackSelectVertsFlip]; for (index = 0; gTrackSelectBgData[index] < temp; index += 5) {} data = &gTrackSelectBgData[index]; @@ -12104,7 +12104,7 @@ void menu_trophy_race_rankings_init(void) { if (++gTrophyRaceRound >= 4) { break; } - } while ((trackMenuIds[((gTrophyRaceWorldId - 1) * 6) + (gTrophyRaceRound)] == -1)); + } while (trackMenuIds[((gTrophyRaceWorldId - 1) * 6) + gTrophyRaceRound] == -1); if (gTrophyRaceRound < 4) { gResultOptionText[0] = gMenuText[ASSET_MENU_TEXT_CONTINUE]; diff --git a/src/menu.h b/src/menu.h index 93ea36db..072ce17b 100644 --- a/src/menu.h +++ b/src/menu.h @@ -475,7 +475,7 @@ void menu_button_free(void); void menu_geometry_end(void); void reset_title_logo_scale(void); void menu_init(u32 menuId); -s32 menu_loop(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, TriangleList **currHudTris, s32 updateRate); +s32 menu_loop(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, Triangle **currHudTris, s32 updateRate); void menu_timestamp_render(s32 frameCount, s32 xPos, s32 yPos, u8 red, u8 green, u8 blue, u8 fontID); void postrace_offsets(MenuElement *elements, f32 in, f32 mid, f32 out, s32 textOffset, s32 timestampOffset); void trackmenu_set_records(void); diff --git a/src/object_functions.c b/src/object_functions.c index 90187bcf..63338ced 100644 --- a/src/object_functions.c +++ b/src/object_functions.c @@ -256,7 +256,7 @@ void obj_loop_fireball_octoweapon(Object *obj, s32 updateRate) { if ((interactObj->obj)) { if ((interactObj->distance < 60)) { someObj = interactObj->obj; - if ((someObj->segment.header->behaviorId == BHV_RACER)) { + if (someObj->segment.header->behaviorId == BHV_RACER) { racer = (Object_Racer *) someObj->unk64; if (racer->playerIndex != PLAYER_COMPUTER) { if (obj->behaviorId == BHV_FIREBALL_OCTOWEAPON) { @@ -2119,7 +2119,7 @@ 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)) { + if (charSelect->unk2C == 1) { temp_f0 = music_animation_fraction(); if (temp_f0 > 0.5) { temp_f0 -= 0.5; @@ -5346,7 +5346,7 @@ void weapon_trap(Object *weaponObj, s32 updateRate) { if (weaponProperties->decayTimer < normalise_time(-1320)) { if (weapon->weaponID == WEAPON_OIL_SLICK) { weaponProperties->status = WEAPON_TRIGGERED; - } else if ((weapon->weaponID == WEAPON_BUBBLE_TRAP)) { + } else if (weapon->weaponID == WEAPON_BUBBLE_TRAP) { weaponProperties->status = WEAPON_DESTROY; play_sound_at_position(SOUND_POP, weaponObj->segment.trans.x_position, weaponObj->segment.trans.y_position, weaponObj->segment.trans.z_position, 4, @@ -5525,7 +5525,7 @@ void obj_loop_texscroll(Object *obj, s32 updateRate) { for (i = 0; i < levelModel->numberOfSegments; i++) { curBatch = curBlock[i].batches; for (j = 0; j < curBlock[i].numberOfBatches; j++) { - if ((curBatch[j].textureIndex == obj64->tex_scroll.textureIndex)) { + if (curBatch[j].textureIndex == obj64->tex_scroll.textureIndex) { for (tri = curBatch[j].facesOffset; tri < curBatch[j + 1].facesOffset; tri++) { curTriangle = &curBlock[i].triangles[tri]; if (!(curTriangle->flags & 0x80)) { @@ -6122,36 +6122,28 @@ void obj_loop_butterfly(Object *butterflyObj, s32 updateRate) { void obj_init_midifade(Object *obj, LevelObjectEntry_MidiFade *entry) { Object_64 *obj64; - s32 pad0; + Object_68 *obj68; ObjectTransform transform; f32 ox; f32 oy; f32 oz; - s32 pad[10]; - Object_68 *obj68; ObjectModel *objModel; - Vertex *vertices; - Vertex *vertex; - // TODO: find a way to have matching builds use this Matrix temp. -#ifdef AVOID_UB + UNUSED s32 pad; Matrix mtx; -#else - f32 mtx[4]; -#endif f32 sinYRot; f32 tempF3; f32 minX; f32 minZ; - f32 scaleF; f32 minY; + f32 maxY; f32 maxX; f32 maxZ; f32 cosYRot; + f32 scaleF; + Vertex *vertex; f32 tempF2; - f32 maxY; - s32 numOfVertices; s32 i; - f32 scaleF2; + obj->segment.trans.rotation.y_rotation = entry->angleY << 8 << 2; // Two shifts needed to skip a register. obj64 = obj->unk64; diff --git a/src/objects.c b/src/objects.c index 0e98b22d..5ad21d31 100644 --- a/src/objects.c +++ b/src/objects.c @@ -1665,7 +1665,7 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { for (i = 0; i < 0x200; i++) { (*gSpawnObjectHeap)[i] = NULL; } - curObj = &(*gSpawnObjectHeap)[0]; + curObj = (Object *) &(*gSpawnObjectHeap)[0]; curObj->segment.trans.flags = 2; curObj->segment.header = load_object_header(var_a0); if (curObj->segment.header == NULL) { @@ -1817,11 +1817,11 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { } } if (sp50 & 4) { - sizeOfobj = init_object_water_effect(curObj, (ShadowData *) address); + sizeOfobj = init_object_water_effect(curObj, (WaterEffect *) address); address = (u32 *) ((uintptr_t) address + sizeOfobj); if (sizeOfobj == 0) { if (D_8011AE50 != NULL) { - free_texture((u32) D_8011AE50); + free_texture((TextureHeader *) D_8011AE50); } objFreeAssets(curObj, assetCount, objType); try_free_object_header(var_a0); @@ -1843,16 +1843,16 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { } sizeOfobj = (uintptr_t) address - (uintptr_t) curObj; if (curObj->segment.header->numLightSources > 0) { - curObj->lightData = address; + curObj->lightData = (Object_LightData **) address; sizeOfobj = (s32) ((uintptr_t) address + (curObj->segment.header->numLightSources * 4)) - (uintptr_t) curObj; } newObj = mempool_alloc_pool((MemoryPoolSlot *) gObjectMemoryPool, sizeOfobj); if (newObj == NULL) { if (D_8011AE50 != NULL) { - free_texture((u32) D_8011AE50); + free_texture((TextureHeader *) D_8011AE50); } if (D_8011AE54 != NULL) { - free_texture((u32) D_8011AE54); + free_texture((TextureHeader *) D_8011AE54); } objFreeAssets(curObj, assetCount, objType); try_free_object_header(var_a0); @@ -1875,7 +1875,7 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { } if (newObj->waterEffect != NULL) { newObj->waterEffect = - (ShadowData *) (((uintptr_t) newObj + (uintptr_t) newObj->waterEffect) - (uintptr_t) gSpawnObjectHeap); + (WaterEffect *) (((uintptr_t) newObj + (uintptr_t) newObj->waterEffect) - (uintptr_t) gSpawnObjectHeap); } if (newObj->shadow != NULL) { newObj->shadow = @@ -1904,7 +1904,7 @@ Object *spawn_object(LevelObjectEntryCommon *entry, s32 arg1) { } if (newObj->segment.header->numLightSources > 0) { newObj->lightData = - (u32 *) (((uintptr_t) newObj + (uintptr_t) newObj->lightData) - (uintptr_t) gSpawnObjectHeap); + (Object_LightData **) (((uintptr_t) newObj + (uintptr_t) newObj->lightData) - (uintptr_t) gSpawnObjectHeap); } newObj->unk68 = (Object_68 **) ((uintptr_t) newObj + (uintptr_t) 0x80); if (arg1 & 1) { @@ -2443,7 +2443,7 @@ void func_80011134(Object *arg0, s32 arg1) { if (temp_v0 != 0xFF) { var_t5 = temp_s3->textures[temp_v0].texture; sp5C = var_s0->unk7 << 6; - tex_animate_texture(var_t5, temp_s4[var_s1].flags, &sp5C, arg1); + tex_animate_texture(var_t5, (u32 *) temp_s4[var_s1].flags, &sp5C, arg1); var_s0->unk7 = sp5C >> 6; } } @@ -3009,12 +3009,16 @@ void render_3d_model(Object *obj) { if (alpha < 255) { flags |= RENDER_SEMI_TRANSPARENT; } +#ifdef ANTI_TAMPER cicFailed = FALSE; // Anti-Piracy check if (osCicId != CIC_ID) { cicFailed = TRUE; } if (!cicFailed) { +#else + if (1) { +#endif var_v0_2 = (loopObj->segment.trans.flags & OBJ_FLAGS_UNK_0080 && obj60_unk0 == 3); if (racerObj != NULL && racerObj->transparency < 255) { var_v0_2 = FALSE; @@ -4292,6 +4296,9 @@ u32 func_800179D0(void) { } i++; } +#ifdef AVOID_UB + return 0; +#endif } #pragma GLOBAL_ASM("asm/nonmatchings/objects/func_80017A18.s") diff --git a/src/objects.h b/src/objects.h index 5d5541be..c6fadd96 100644 --- a/src/objects.h +++ b/src/objects.h @@ -334,7 +334,6 @@ typedef struct Asset20 { TextureHeader *unk7C; } Asset20; -#define CIC_ID 6103 extern s32 osCicId; // Used for an Anti-Piracy check in render_3d_model Object *func_8000BF44(s32 arg0); diff --git a/src/particles.c b/src/particles.c index 20e4392e..9b26c05b 100644 --- a/src/particles.c +++ b/src/particles.c @@ -927,7 +927,7 @@ void func_800B03C0(Particle *particle, Particle *arg1, Particle *arg2, ParticleB } f32_vec3_apply_object_rotation3(&angle, (f32 *) &posVel); } else { - f32_vec3_apply_object_rotation((Vec3s *) &arg2->data.angle.rotation.y_rotation, (f32 *) &posVel); + f32_vec3_apply_object_rotation((ObjectTransform *) &arg2->data.angle.rotation, (f32 *) &posVel); } particle->baseVelX += posVel.x; particle->baseVelY += posVel.y; @@ -1152,7 +1152,7 @@ Particle *func_800B0BAC(Object *arg0, Particle *arg1) { sp2C->vertices->x = arg1->segment.trans.x_position; sp2C->vertices->y = arg1->segment.trans.y_position; sp2C->vertices->z = arg1->segment.trans.z_position; - if ((s32) sp24 != -1U) { + if ((u32) sp24 != -1U) { arg1->data.unk1E += 1; if (arg1->data.unk1E >= sp24[0].unk0) { arg1->data.unk1E = 0; @@ -1997,7 +1997,7 @@ void move_particle_with_velocity(Particle *particle) { particle->segment.x_velocity = 0.0f; particle->segment.y_velocity = 0.0f; particle->segment.z_velocity = -particle->forwardVel; - f32_vec3_apply_object_rotation3(&particle->segment.trans, &particle->segment.x_velocity); + f32_vec3_apply_object_rotation3(&particle->segment.trans.rotation, &particle->segment.x_velocity); particle->segment.trans.x_position += particle->segment.x_velocity; particle->segment.trans.y_position += particle->segment.y_velocity - particle->gravity; particle->segment.trans.z_position += particle->segment.z_velocity; diff --git a/src/printf.c b/src/printf.c index 56942d13..45a9a740 100644 --- a/src/printf.c +++ b/src/printf.c @@ -201,6 +201,9 @@ UNUSED int sprintf(char *s, const char *format, ...) { va_start(args, format); vsprintf(s, format, args); va_end(args); +#ifdef AVOID_UB + return 0; +#endif } // Official Name: vsprintf diff --git a/src/racer.c b/src/racer.c index b26ad8c8..351c27e0 100644 --- a/src/racer.c +++ b/src/racer.c @@ -985,7 +985,7 @@ void func_80046524(s32 updateRate, f32 updateRateF, Object *obj, Object_Racer *r if (racer->trickType != 0) { if (racer->groundedWheels) { if (gRaceStartTimer != 100 && racer->playerIndex != PLAYER_COMPUTER && racer->trickType >= 6) { - sound_play(SOUND_BOUNCE, &racer->unk21C); + sound_play(SOUND_BOUNCE, (s32 *) &racer->unk21C); sound_volume_set_relative(SOUND_BOUNCE, racer->unk21C, (racer->trickType * 2) + 50); } } else if (racer->approachTarget == NULL) { @@ -2748,7 +2748,7 @@ void func_8004F7F4(s32 updateRate, f32 updateRateF, Object *racerObj, Object_Rac f32 spA8; f32 spA4; f32 spA0; - f32 sp60[4 * 4]; + Matrix sp60; LevelHeader *currentLevelHeader; Asset20 *asset20; s32 var_v1; @@ -2895,7 +2895,7 @@ void func_8004F7F4(s32 updateRate, f32 updateRateF, Object *racerObj, Object_Rac if (D_8011D550) { if (gCurrentPlayerIndex != PLAYER_COMPUTER && D_8011D550 != SOUND_STOMP5) { sound_play_spatial(D_8011D550, racerObj->segment.trans.x_position, racerObj->segment.trans.y_position, - racerObj->segment.trans.z_position, &racer->unk21C); + racerObj->segment.trans.z_position, (s32 **) &racer->unk21C); sound_volume_set_relative(D_8011D550, racer->unk21C, D_8011D552); } racer->stretch_height_cap = (1.0 - ((f32) (D_8011D552 - 40) * 0.004)); @@ -4662,8 +4662,8 @@ void func_80054FD0(Object *racerObj, Object_Racer *racer, s32 updateRate) { f32 sp108[5]; f32 spF4[5]; f32 spE0[5]; - f32 spA0[4 * 4]; - f32 sp60[4 * 4]; + Matrix spA0; + Matrix sp60; s8 sp5C; s8 sp58[4]; @@ -4718,9 +4718,9 @@ void func_80054FD0(Object *racerObj, Object_Racer *racer, s32 updateRate) { sp5C = 1; } } - func_80031130(4, &racer->unkD8, &sp134, racer->vehicleID); + func_80031130(4, (f32 *) &racer->unkD8, sp134, racer->vehicleID); sp190 = 0; - racer->unk1E3 = func_80031600(&racer->unkD8, &sp134, &spE0, &sp58, 4, &sp190); + racer->unk1E3 = func_80031600((f32 *) &racer->unkD8, sp134, spE0, sp58, 4, &sp190); sp184 = func_8002ACD4(&sp180, &sp178, &sp17C); if (sp184 != 0) { temp_s16 = (u16) arctan2_f(sp180 * 255.0f, sp17C * 255.0f); diff --git a/src/stacks.h b/src/stacks.h index 74e6c6d9..855823ee 100644 --- a/src/stacks.h +++ b/src/stacks.h @@ -3,6 +3,14 @@ #include "types.h" +#define STACK_IDLE 0x100 +#define STACK_SCHED 0x2000 +#define STACK_AUD 0x3010 +#define STACK_GAME 0x2000 +#define STACK_BGLOAD 0x2000 + +#define STACKSIZE(x) (x / sizeof(u64)) + extern u8 D_80129AB0[0x100]; extern u16 D_80129BB0[512]; extern s32 gObjectStackTrace[3]; diff --git a/src/textures_sprites.c b/src/textures_sprites.c index f3050d9f..64b47ccf 100644 --- a/src/textures_sprites.c +++ b/src/textures_sprites.c @@ -446,34 +446,34 @@ TextureHeader *load_texture(s32 arg0) { } for (i = 0; i < gNumberOfLoadedTextures; i++) { if (arg0 == gTextureCache[(i << 1)]) { - tex = gTextureCache[(i << 1) + 1]; + tex = (TextureHeader *) gTextureCache[(i << 1) + 1]; tex->numberOfInstances++; return tex; } } assetOffset = gTextureAssetTable[assetTable][assetIndex]; assetSize = gTextureAssetTable[assetTable][assetIndex + 1] - assetOffset; - load_asset_to_address(assetSection, gTempTextureHeader, assetOffset, 0x28); + load_asset_to_address(assetSection, (u32) gTempTextureHeader, assetOffset, 0x28); numberOfTextures = (gTempTextureHeader->header.numOfTextures >> 8) & 0xFFFF; if (!gTempTextureHeader->header.isCompressed) { - tex = mempool_alloc((numberOfTextures * 0x60) + assetSize, gTexColourTag); + tex = (TextureHeader * )mempool_alloc((numberOfTextures * 0x60) + assetSize, gTexColourTag); if (tex == NULL) { return NULL; } - load_asset_to_address(assetSection, tex, assetOffset, assetSize); + load_asset_to_address(assetSection, (u32) tex, assetOffset, assetSize); } else { - temp_v0_5 = byteswap32(&gTempTextureHeader->uncompressedSize); + temp_v0_5 = byteswap32((u8 *) &gTempTextureHeader->uncompressedSize); temp_a0 = (numberOfTextures * 0x60) + temp_v0_5; sp3C = temp_v0_5 + 0x20; - tex = mempool_alloc(temp_a0 + 0x20, gTexColourTag); + tex = (TextureHeader *) mempool_alloc(temp_a0 + 0x20, gTexColourTag); if (tex == NULL) { return NULL; } 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); + gzip_inflate((u8 *) (temp_a1 + 0x20), (u8 *) tex); assetSize = sp3C - 0x20; } texIndex = -1; @@ -486,11 +486,11 @@ TextureHeader *load_texture(s32 arg0) { texIndex = gNumberOfLoadedTextures++; } gTextureCache[(texIndex << 1)] = arg0; - gTextureCache[(texIndex << 1) + 1] = tex; + gTextureCache[(texIndex << 1) + 1] = (s32) tex; paletteOffset = -1; if ((tex->format & 0xF) == TEX_FORMAT_CI4) { if (D_80126344 == 0) { - load_asset_to_address(ASSET_EMPTY_14, &gCiPalettes[gCiPalettesSize], tex->ciPaletteOffset, 32); + load_asset_to_address(ASSET_EMPTY_14, (u32) &gCiPalettes[gCiPalettesSize], tex->ciPaletteOffset, 32); tex->ciPaletteOffset = gCiPalettesSize; gCiPalettesSize += 32; // (32 bytes / 2 bytes per color) = 16 colors. } @@ -498,7 +498,7 @@ TextureHeader *load_texture(s32 arg0) { } if ((tex->format & 0xF) == TEX_FORMAT_CI8) { if (D_80126344 == 0) { - load_asset_to_address(ASSET_EMPTY_14, &gCiPalettesSize[gCiPalettes], tex->ciPaletteOffset, 128); + load_asset_to_address(ASSET_EMPTY_14, (u32) &gCiPalettesSize[gCiPalettes], tex->ciPaletteOffset, 128); tex->ciPaletteOffset = gCiPalettesSize; gCiPalettesSize += 128; // (128 bytes / 2 bytes per color) = 64 colors. } @@ -508,7 +508,7 @@ TextureHeader *load_texture(s32 arg0) { texTemp = tex; alignedAddress = align16((u8 *) ((s32) texTemp + assetSize)); for (i = 0; i < numberOfTextures; i++) { - build_tex_display_list(texTemp, alignedAddress); + build_tex_display_list(texTemp, (Gfx *) alignedAddress); if (paletteOffset >= 0) { texTemp->ciPaletteOffset = paletteOffset; alignedAddress += 0x30; // I'm guessing it takes 6 f3d commands to load the palette diff --git a/src/thread0_epc.c b/src/thread0_epc.c index 30ece8ea..6eb6e9e6 100644 --- a/src/thread0_epc.c +++ b/src/thread0_epc.c @@ -140,7 +140,7 @@ void write_epc_data_to_cpak(void) { thread->context.fp0.f.f_even = gObjectStackTrace[1]; thread->context.fp2.f.f_odd = gObjectStackTrace[2]; bcopy(thread, sp44, sizeof(epcInfo)); - bcopy((void *) thread->context.sp, sp244, sizeof(sp244)); + bcopy((void *) (u32) thread->context.sp, sp244, sizeof(sp244)); zero = 0; // Why is this needed to match? v0 = func_80024594(¤tCount, &maxCount); for (i = zero; i < maxCount; i++) { diff --git a/src/thread30_track_loading.c b/src/thread30_track_loading.c index 2552d04b..fe5b3272 100644 --- a/src/thread30_track_loading.c +++ b/src/thread30_track_loading.c @@ -2,6 +2,7 @@ #include "macros.h" #include #include "game.h" +#include "stacks.h" /************ .data ************/ @@ -17,7 +18,7 @@ s32 gThread30LoadDelay = 0; OSThread gThread30; OSMesgQueue gThread30MesgQueue; OSMesg gThread30Message[2]; -u64 gThread30Stack[0x400]; +u64 gThread30Stack[STACKSIZE(STACK_BGLOAD)]; /*****************************/ @@ -26,7 +27,7 @@ u64 gThread30Stack[0x400]; */ void create_and_start_thread30(void) { osCreateMesgQueue(&gThread30MesgQueue, &gThread30Message[0], ARRAY_COUNT(gThread30Message)); - osCreateThread(&gThread30, 30, &thread30_track_loading, NULL, &gThread30Stack[0x400], 8); + osCreateThread(&gThread30, 30, &thread30_track_loading, NULL, &gThread30Stack[STACKSIZE(STACK_BGLOAD)], 8); osStartThread(&gThread30); } diff --git a/src/thread3_main.c b/src/thread3_main.c index 898ea08a..ec4db787 100644 --- a/src/thread3_main.c +++ b/src/thread3_main.c @@ -44,6 +44,7 @@ #include "joypad.h" #include "PRinternal/viint.h" #include "font.h" +#include "stacks.h" /************ .rodata ************/ @@ -106,12 +107,12 @@ MatrixS *gMatrixHeap[2]; MatrixS *gGameCurrMatrix; Vertex *gVertexHeap[2]; Vertex *gGameCurrVertexList; -TriangleList *gTriangleHeap[2]; -TriangleList *gGameCurrTriList; +Triangle *gTriangleHeap[2]; +Triangle *gGameCurrTriList; UNUSED s32 D_80121230[8]; s8 gLevelSettings[16]; OSSched gMainSched; // 0x288 / 648 bytes -u64 gSchedStack[0x400]; +u64 gSchedStack[STACKSIZE(STACK_SCHED)]; s32 gSPTaskNum; s32 gGameMode; s32 gRenderMenu; // I don't think this is ever not 1 @@ -199,8 +200,7 @@ void init_game(void) { } else if (osTvType == OS_TV_TYPE_MPAL) { viMode = OS_VI_MPAL_LPN1; } - - osCreateScheduler(&gMainSched, &gSchedStack[0x400], /*priority*/ 13, viMode, 1); + osCreateScheduler(&gMainSched, &gSchedStack[STACKSIZE(STACK_SCHED)], /*priority*/ 13, viMode, 1); #ifdef ANTI_TAMPER // Antipiracy measure. gDmemInvalid = FALSE; @@ -1390,10 +1390,10 @@ 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)))); + gTriangleHeap[0] = (Triangle *) ((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)))); + gTriangleHeap[1] = (Triangle *) ((u8 *) gMatrixHeap[1] + ((gNumHudMatPerPlayer[num] * sizeof(Matrix)))); gVertexHeap[1] = (Vertex *) ((u8 *) gTriangleHeap[1] + ((gNumHudTrisPerPlayer[num] * sizeof(Triangle)))); gCurrNumF3dCmdsPerPlayer = gNumF3dCmdsPerPlayer[num]; gCurrNumHudMatPerPlayer = gNumHudMatPerPlayer[num]; @@ -1440,13 +1440,13 @@ void default_alloc_displaylist_heap(void) { 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))); + (Triangle *) ((u8 *) gVertexHeap[0] + (gNumHudVertsPerPlayer[numberOfPlayers] * sizeof(Vertex))); gDisplayLists[1] = (Gfx *) mempool_alloc_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))); + (Triangle *) ((u8 *) gVertexHeap[1] + (gNumHudVertsPerPlayer[numberOfPlayers] * sizeof(Vertex))); gCurrNumF3dCmdsPerPlayer = gNumF3dCmdsPerPlayer[numberOfPlayers]; gCurrNumHudMatPerPlayer = gNumHudMatPerPlayer[numberOfPlayers]; diff --git a/src/tracks.c b/src/tracks.c index 24a047da..04c21105 100644 --- a/src/tracks.c +++ b/src/tracks.c @@ -286,7 +286,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) { +void render_scene(Gfx **dList, MatrixS **mtx, Vertex **vtx, Triangle **tris, s32 updateRate) { s32 i; s32 numViewports; s32 tempUpdateRate; @@ -546,7 +546,7 @@ void func_8002581C(u8 *segmentIds, s32 numberOfSegments, s32 viewportIndex) { check4 = TRUE; } if (((s16) ((s16) (check1 + check2) + check3) + check4) & 3) { - func_80026430(bbox, yCameraSins, yCameraCoss, temp_f22); + func_80026430((LevelModelSegment *) bbox, yCameraSins, yCameraCoss, temp_f22); if (gCurrentLevelModel->segments[segmentIndex].unk3C & 2) { func_80026070(bbox, yCameraSins, yCameraCoss, temp_f22); } @@ -583,8 +583,8 @@ void func_8002581C(u8 *segmentIds, s32 numberOfSegments, s32 viewportIndex) { } temp_t6 = gSceneCurrVertexList; gSceneCurrVertexList = D_8011D480[D_8011D4B4]; - temp_t7 = gSceneCurrTriList; - gSceneCurrTriList = D_8011D490[D_8011D4B4]; + temp_t7 = (s8 *) gSceneCurrTriList; + gSceneCurrTriList = (Triangle *) D_8011D490[D_8011D4B4]; D_8011D4B4 = 1 - D_8011D4B4; var_s4 = D_8011D478->unk0; D_8011D488 = gSceneCurrVertexList; @@ -631,7 +631,7 @@ void func_8002581C(u8 *segmentIds, s32 numberOfSegments, s32 viewportIndex) { TRIN_DISABLE_TEXTURE); } gSceneCurrVertexList = spAC; - gSceneCurrTriList = spA8; + gSceneCurrTriList = (Triangle *) spA8; } } #else @@ -983,7 +983,7 @@ s32 func_80027568(void) { ret = FALSE; // bug? var_ra can be undefined? for (var_t4 = 0; var_t4 < D_8011D378 && ret == FALSE; var_t4++) { - var_v0_1 = D_8011D370[var_t4]; + var_v0_1 = (s32) D_8011D370[var_t4]; if (var_v0_1 > 0) { var_ra = (void *) PHYS_TO_K0(var_v0_1); } else { @@ -1299,7 +1299,7 @@ void draw_gradient_background(void) { verts += 4; gSceneCurrVertexList = verts; tris += 2; - gSceneCurrTriList = (TriangleList *) tris; + gSceneCurrTriList = (Triangle *) tris; } /** diff --git a/src/tracks.h b/src/tracks.h index 5ce607a8..a60d0449 100644 --- a/src/tracks.h +++ b/src/tracks.h @@ -180,7 +180,7 @@ void obj_loop_fogchanger(Object* obj); void initialise_player_viewport_vars(s32 updateRate); s32 get_wave_properties(f32 yPos, f32 *waterHeight, Vec3f *rotation); void render_level_segment(s32 segmentId, s32 nonOpaque); -void render_scene(Gfx** dList, MatrixS** mtx, Vertex** vtx, TriangleList** tris, s32 updateRate); +void render_scene(Gfx** dList, MatrixS** mtx, Vertex** vtx, Triangle** tris, s32 updateRate); void set_fog(s32 fogIdx, s16 near, s16 far, u8 red, u8 green, u8 blue); void slowly_change_fog(s32 fogIdx, s32 red, s32 green, s32 blue, s32 near, s32 far, s32 switchTimer); s32 func_8002FD74(f32 x0, f32 z0, f32 x1, f32 x2, s32 count, Vec4f *arg5); diff --git a/src/weather.c b/src/weather.c index 064e0863..f3955e45 100644 --- a/src/weather.c +++ b/src/weather.c @@ -136,7 +136,7 @@ s32 gSnowVertexFlip; Gfx *gCurrWeatherDisplayList; MatrixS *gCurrWeatherMatrix; Vertex *gCurrWeatherVertexList; -TriangleList *gCurrWeatherTriList; +Triangle *gCurrWeatherTriList; ObjectSegment *gWeatherCamera; Matrix *gWeatherCameraMatrix; LensFlareData *gLensFlareSet1; @@ -397,7 +397,7 @@ void weather_set(s32 velX, s32 velY, s32 velZ, s32 intensity, s32 opacity, s32 t * 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 weather_update(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, TriangleList **currHudTris, +void weather_update(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, Triangle **currHudTris, s32 updateRate) { UNUSED s32 unused; gCurrWeatherDisplayList = *currDisplayList; diff --git a/src/weather.h b/src/weather.h index 44a8e5f0..d46891d7 100644 --- a/src/weather.h +++ b/src/weather.h @@ -111,7 +111,7 @@ void rain_sound(s32 updateRate); void rain_render_splashes(s32 updateRate); void rain_lightning(s32 updateRate); void render_rain_overlay(RainGfxData*, s32); -void weather_update(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, TriangleList **currHudTris, s32 updateRate); +void weather_update(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, Triangle **currHudTris, s32 updateRate); void snow_render(void); void weather_free(void); void weather_set(s32 velX, s32 velY, s32 velZ, s32 intensity, s32 opacity, s32 time); diff --git a/tools/python/extract_custom_boot.py b/tools/python/extract_custom_boot.py index d0df78c9..a6ad863e 100644 --- a/tools/python/extract_custom_boot.py +++ b/tools/python/extract_custom_boot.py @@ -33,16 +33,26 @@ def boot_extract(input_file, output_file="boot_custom.bin"): output_file = "./mods/boot_custom.bin" mods_missing = False cictype = N64GetCIC(data) - if os.path.isfile("makefile"): + if (cictype == 0): + if data.find(b"Libdragon IPL3"): + print("CIC: Libdragon") + else: + print("Unknown CIC, assume 6102 just in case, but don't assume the CIC itself is valid.") + cictype = 6102 + else: + print("CIC: " + str(cictype)) + if os.path.isfile("Makefile"): print("Makefile detected, modifying CIC type.") - with open("makefile", 'r') as f: + with open("Makefile", 'r') as f: lines = f.readlines() - with open("makefile", 'w') as f: + with open("Makefile", 'w') as f: for line in lines: if line.startswith("BOOT_CIC ?="): f.write("BOOT_CIC ?= " + str(cictype) + "\n") else: f.write(line) + if os.path.isfile("./build/asm/header.s.o"): + os.remove("./build/asm/header.s.o") with open(output_file, "wb") as f: