diff --git a/Makefile b/Makefile index 8a54fc6baf..8a996fd22e 100644 --- a/Makefile +++ b/Makefile @@ -167,10 +167,10 @@ CFLAGS += -G 0 -non_shared -Xcpluscomm -nostdinc -Wab,-r4300_mul WARNINGS := -fullwarn -verbose -woff 624,649,838,712,516,513,596,564,594 ASFLAGS := -march=vr4300 -32 -G0 -COMMON_DEFINES := -D_MIPS_SZLONG=32 GBI_DEFINES := -DF3DEX_GBI_2 -DF3DEX_GBI_PL -DGBI_DOWHILE -AS_DEFINES := $(COMMON_DEFINES) $(GBI_DEFINES) -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_ULTRA64 -C_DEFINES := $(COMMON_DEFINES) $(GBI_DEFINES) -DLANGUAGE_C -D_LANGUAGE_C +COMMON_DEFINES := -D_MIPS_SZLONG=32 $(GBI_DEFINES) +AS_DEFINES := $(COMMON_DEFINES) -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_ULTRA64 +C_DEFINES := $(COMMON_DEFINES) -DLANGUAGE_C -D_LANGUAGE_C ENDIAN := -EB OPTFLAGS := -O2 -g3 diff --git a/include/variables.h b/include/variables.h index b257b01d51..5c99e6a264 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3,6 +3,7 @@ #include "z64.h" #include "segment_symbols.h" +#include "stack.h" #include "macros.h" // data @@ -43,7 +44,7 @@ extern f32 gHeadsetPanVolume[]; extern f32 gStereoPanVolume[]; extern f32 gDefaultPanVolume[]; extern s32 gAudioCtxInitalized; -extern u8 D_801D6200[0x400]; +extern STACK(aspMainStack, 0x400); extern u8 gAudioSpecId; extern u8 gAudioHeapResetState; diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 3c69ae162c..9aa61a055b 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -11,9 +11,8 @@ struct DynaPolyActor; #define SS_NULL 0xFFFF -#define COLPOLY_NORMAL_FRAC (1.0f / SHRT_MAX) #define COLPOLY_SNORMAL(x) ((s16)((x) * SHRT_MAX)) -#define COLPOLY_GET_NORMAL(n) ((n)*COLPOLY_NORMAL_FRAC) +#define COLPOLY_GET_NORMAL(n) ((n) * (1.0f / SHRT_MAX)) #define COLPOLY_VIA_FLAG_TEST(vIA, flags) ((vIA) & (((flags)&7) << 13)) #define COLPOLY_VTX_INDEX(vI) ((vI)&0x1FFF) diff --git a/src/audio/lib/thread.c b/src/audio/lib/thread.c index 988d1580f2..13c3f07577 100644 --- a/src/audio/lib/thread.c +++ b/src/audio/lib/thread.c @@ -174,7 +174,7 @@ AudioTask* AudioThread_UpdateImpl(void) { task->ucode = aspMainTextStart; task->ucode_data = aspMainDataStart; task->ucode_size = SP_UCODE_SIZE; - task->dram_stack = (u64*)D_801D6200; + task->dram_stack = aspMainStack; task->dram_stack_size = 0; task->output_buff = NULL; task->output_buff_size = NULL; diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 060954255f..1b3c11ed6d 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -413,8 +413,8 @@ s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0) { dpA += a0->poly->normal.z * a0->posA->z; dpB += a0->poly->normal.z * a0->posB->z; - dpA *= COLPOLY_NORMAL_FRAC; - dpB *= COLPOLY_NORMAL_FRAC; + dpA = COLPOLY_GET_NORMAL(dpA); + dpB = COLPOLY_GET_NORMAL(dpB); planeDistA += dpA; planeDistB += dpB; diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 6002bc5c4a..674e7e2e06 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2368,7 +2368,7 @@ void Interface_UpdateButtonsPart1(PlayState* play) { if (!CHECK_EVENTINF(EVENTINF_41) || (CHECK_EVENTINF(EVENTINF_41) && (CutsceneManager_GetCurrentCsId() == CS_ID_NONE))) { Audio_PlaySfx(NA_SE_SY_CAMERA_SHUTTER); - SREG(89) = 1; + R_PICTO_PHOTO_STATE = PICTO_PHOTO_STATE_SETUP; play->haltAllActors = true; sPictoState = PICTO_BOX_STATE_SETUP_PHOTO; sPictoPhotoBeingTaken = true; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index 67e7b35c6e..ac4b81d9b3 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -29,9 +29,9 @@ * system is mainly used to manage their blinking. */ -#include "prevent_bss_reordering.h" -#include "sys_cfb.h" #include "z_en_invadepoh.h" + +#include "sys_cfb.h" #include "z64horse.h" #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h" diff --git a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c index 7cff76a489..07f2e46968 100644 --- a/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c +++ b/src/overlays/actors/ovl_En_Invadepoh_Demo/z_en_invadepoh_demo.c @@ -14,8 +14,9 @@ * 4. The UFO (which appears as a spinning ball of light) * 5. A cow tail */ -#include "prevent_bss_reordering.h" + #include "z_en_invadepoh_demo.h" + #include "sys_cfb.h" #define FLAGS (ACTOR_FLAG_10) diff --git a/src/overlays/actors/ovl_En_Test5/z_en_test5.h b/src/overlays/actors/ovl_En_Test5/z_en_test5.h index 7a4b656b50..62ca56acd8 100644 --- a/src/overlays/actors/ovl_En_Test5/z_en_test5.h +++ b/src/overlays/actors/ovl_En_Test5/z_en_test5.h @@ -16,7 +16,7 @@ typedef struct EnTest5 { /* 0x144 */ Vec3f minPos; /* 0x150 */ f32 xLength; /* 0x154 */ f32 zLength; - /* 0x158 */ EnTest5ActionFunc actionFunc; + /* 0x158 */ EnTest5ActionFunc actionFunc; } EnTest5; // size = 0x15C #endif // Z_EN_TEST5_H diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index a5b0fafb6e..d60fd82675 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -964,7 +964,7 @@ void func_80AEE374(EnTk* this, PlayState* play) { sp30.unk_04 = FLT_MAX; SubS_FindActorCustom(play, &this->actor, NULL, ACTORCAT_NPC, ACTOR_EN_TK, &sp30, func_80AEE300); - if (sp30.unk_00 == 0) { + if (sp30.unk_00 == NULL) { Actor_Kill(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c index 8896888e50..b22bdc5de8 100644 --- a/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c +++ b/src/overlays/actors/ovl_En_Warp_tag/z_en_warp_tag.c @@ -86,7 +86,7 @@ void EnWarptag_Destroy(Actor* thisx, PlayState* play) { void EnWarpTag_CheckDungeonKeepObject(EnWarptag* this, PlayState* play) { if (Object_IsLoaded(&play->objectCtx, this->dangeonKeepObjectSlot)) { this->actionFunc = EnWarpTag_WaitForPlayer; - DynaPolyActor_Init(&this->dyna, 0x1); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); DynaPolyActor_LoadMesh(play, &this->dyna, &gWarpTagGoronTrialBaseCol); this->dyna.actor.objectSlot = this->dangeonKeepObjectSlot; this->dyna.actor.draw = EnWarpTag_Draw; diff --git a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c index 14a30cd058..8edc513476 100644 --- a/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c +++ b/src/overlays/actors/ovl_Obj_Driftice/z_obj_driftice.c @@ -268,7 +268,7 @@ void ObjDriftice_Init(Actor* thisx, PlayState* play) { ObjDriftice* this = THIS; f32* sp2C = D_80A67620[OBJDRIFTICE_GET_3(&this->dyna.actor)]; Path* path; - s32 phi_a1; + s32 transformFlags; s32 sp20; Actor_ProcessInitChain(&this->dyna.actor, sInitChain); @@ -289,18 +289,18 @@ void ObjDriftice_Init(Actor* thisx, PlayState* play) { sp20 = 1; } - this->unk_244 = thisx->home.rot.z * 45.511112f; + this->unk_244 = thisx->home.rot.z * (0x8000 / 720.0f); - phi_a1 = 0; + transformFlags = 0; if (sp20 == 0) { - phi_a1 = 1; + transformFlags = DYNA_TRANSFORM_POS; } if (thisx->home.rot.z != 0) { - phi_a1 |= 3; + transformFlags |= DYNA_TRANSFORM_ROT_Y | DYNA_TRANSFORM_POS; } - DynaPolyActor_Init(&this->dyna, phi_a1); + DynaPolyActor_Init(&this->dyna, transformFlags); DynaPolyActor_LoadMesh(play, &this->dyna, &object_driftice_Colheader_001AA8); if (sp20 != 0) { diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 6607e27a5b..6693fc1fcd 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -4,6 +4,8 @@ * Description: Player */ +#include "z64player.h" + #include "global.h" #include "z64horse.h" #include "z64lifemeter.h" diff --git a/tools/calc_bss.sh b/tools/calc_bss.sh index 2283aa670c..a0d56c261e 100755 --- a/tools/calc_bss.sh +++ b/tools/calc_bss.sh @@ -35,7 +35,7 @@ echo "char measurement;" >> $TEMPC $(pwd)/tools/ido_recomp/linux/7.1/cc -G 0 -non_shared \ -Xfullwarn -Xcpluscomm -O2 -g3 -Xcpluscomm -mips2 \ -D_LANGUAGE_C -DF3DEX_GBI_2 -DF3DEX_GBI_PL -DGBI_DOWHILE \ - -I $(pwd)/ -I $(pwd)/include/ -I $(pwd)/include/libc/ -I $(pwd)/src/ -I $(pwd)/assets/ -I $(pwd)/build/n64-us/ \ + -I $(pwd)/include/ -I $(pwd)/include/libc/ -I $(pwd)/src/ -I $(pwd)/assets/ -I $(pwd)/build/n64-us/ -I $(pwd)/\ -Wab,-r4300_mul -woff 624,649,838,712 -c $TEMPC -o $TEMPO LINE=$(${CROSS}objdump -t $TEMPO | grep measurement | cut -d' ' -f1) diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 0c89d7c489..6bc6556339 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2164,7 +2164,7 @@ 0x801D6190:("D_801D6190","f32","",0x4), 0x801D6194:("D_801D6194","UNK_TYPE4","",0x4), 0x801D61A0:("sSeqInstructionArgsTable","u8","[96]",0x60), - 0x801D6200:("D_801D6200","UNK_TYPE1","",0x1), + 0x801D6200:("aspMainStack","UNK_TYPE1","",0x1), 0x801D6600:("gIsLargeSfxBank","UNK_TYPE1","",0x1), 0x801D6608:("D_801D6608","UNK_TYPE1","",0x1), 0x801D6610:("gChannelsPerBank","UNK_TYPE1","",0x1), diff --git a/tools/m2ctx.py b/tools/m2ctx.py index 2a971eea89..4f859460c9 100755 --- a/tools/m2ctx.py +++ b/tools/m2ctx.py @@ -17,9 +17,12 @@ CPP_FLAGS = [ "-Iinclude/libc", "-Isrc", "-Iassets", - "-Ibuild", + "-Ibuild/n64-us", "-I.", + "-DF3DEX_GBI_2", + "-DF3DEX_GBI_PL", + "-DGBI_DOWHILE", "-D__sgi", "-D_LANGUAGE_C", "-DNON_MATCHING",