diff options
| author | Random <28494085+Random06457@users.noreply.github.com> | 2020-08-15 19:23:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-15 13:23:29 -0400 |
| commit | d8d789d2a538f9468d1e9009423acf67a3e0af0f (patch) | |
| tree | 6a9f1a63ce810ce95b6c3f41a19b3017cfee755a /src/code | |
| parent | d3b88e1b1cc371388abe9f34e4880342da136bf6 (diff) | |
Match a few functions (#324)
* match a few functions
* run formath.sh
* minor fixes
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/fault.c | 23 | ||||
| -rw-r--r-- | src/code/sched.c | 38 | ||||
| -rwxr-xr-x | src/code/sys_math3d.c | 10 | ||||
| -rw-r--r-- | src/code/z_lights.c | 4 | ||||
| -rw-r--r-- | src/code/z_play.c | 174 | ||||
| -rw-r--r-- | src/code/z_room.c | 2 |
6 files changed, 114 insertions, 137 deletions
diff --git a/src/code/fault.c b/src/code/fault.c index c5972c3a3..3862d381f 100644 --- a/src/code/fault.c +++ b/src/code/fault.c @@ -719,12 +719,10 @@ void Fault_DrawMemDumpPage(const char* title, u32* addr, u32 param_3) { FaultDrawer_SetCharPad(0, 0); } -#ifdef NON_MATCHING -// regalloc differences void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1) { Input* curInput = &sFaultStructPtr->padInput; u32 addr = pc; - u32 count; + s32 count; u32 off; do { @@ -766,34 +764,33 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1) { if (CHECK_PAD(curInput->cur, Z_TRIG)) { off = 0x100; } + if (CHECK_PAD(curInput->cur, B_BUTTON)) { off <<= 8; } - if (CHECK_PAD(curInput->cur, U_JPAD)) { + + if (CHECK_PAD(curInput->press, U_JPAD)) { addr -= off; } - if (CHECK_PAD(curInput->cur, D_JPAD)) { + if (CHECK_PAD(curInput->press, D_JPAD)) { addr += off; } - if (CHECK_PAD(curInput->cur, U_CBUTTONS)) { + if (CHECK_PAD(curInput->press, U_CBUTTONS)) { addr = pc; } - if (CHECK_PAD(curInput->cur, D_CBUTTONS)) { + if (CHECK_PAD(curInput->press, D_CBUTTONS)) { addr = sp; } - if (CHECK_PAD(curInput->cur, L_CBUTTONS)) { + if (CHECK_PAD(curInput->press, L_CBUTTONS)) { addr = unk0; } - if (CHECK_PAD(curInput->cur, R_CBUTTONS)) { + if (CHECK_PAD(curInput->press, R_CBUTTONS)) { addr = unk1; } - } while (!CHECK_PAD(curInput->cur, L_TRIG)); + } while (!CHECK_PAD(curInput->press, L_TRIG)); sFaultStructPtr->faultActive = true; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/fault/Fault_DrawMemDump.s") -#endif void Fault_WalkStack(u32* spPtr, u32* pcPtr, u32* raPtr) { u32 sp = *spPtr; diff --git a/src/code/sched.c b/src/code/sched.c index ee91cfe6a..9b159894f 100644 --- a/src/code/sched.c +++ b/src/code/sched.c @@ -186,7 +186,7 @@ s32 Sched_Schedule(SchedContext* sc, OSScTask** sp, OSScTask** dp, s32 state) { OSScTask* gfxTask = sc->gfxListHead; OSScTask* audioTask = sc->audioListHead; - if (sc->doAudio && ret & OS_SC_SP) { + if (sc->doAudio && (ret & OS_SC_SP)) { *sp = audioTask; ret &= ~OS_SC_SP; sc->doAudio = 0; @@ -194,27 +194,23 @@ s32 Sched_Schedule(SchedContext* sc, OSScTask** sp, OSScTask** dp, s32 state) { if (sc->audioListHead == NULL) { sc->audioListTail = NULL; } - } else { - if (gfxTask != NULL) { - if (gfxTask->state & OS_SC_YIELDED || !(sc->gfxListHead->flags & OS_SC_NEEDS_RDP)) { - if (ret & OS_SC_SP) { - *sp = gfxTask; - ret &= ~OS_SC_SP; - sc->gfxListHead = sc->gfxListHead->next; - if (sc->gfxListHead == NULL) { - sc->gfxListTail = NULL; - } + } else if (gfxTask != NULL) { + if (gfxTask->state & OS_SC_YIELDED || !(sc->gfxListHead->flags & OS_SC_NEEDS_RDP)) { + if (ret & OS_SC_SP) { + *sp = gfxTask; + ret &= ~OS_SC_SP; + sc->gfxListHead = sc->gfxListHead->next; + if (sc->gfxListHead == NULL) { + sc->gfxListTail = NULL; } - } else { - if (ret == (OS_SC_SP | OS_SC_DP)) { - if (sc->gfxListHead->framebuffer == NULL || func_800C89D4(sc, gfxTask) != NULL) { - *sp = *dp = gfxTask; - ret &= ~(OS_SC_SP | OS_SC_DP); - sc->gfxListHead = sc->gfxListHead->next; - if (sc->gfxListHead == NULL) { - sc->gfxListTail = NULL; - } - } + } + } else if (ret == (OS_SC_SP | OS_SC_DP)) { + if (sc->gfxListHead->framebuffer == NULL || func_800C89D4(sc, gfxTask) != NULL) { + *sp = *dp = gfxTask; + ret &= ~(OS_SC_SP | OS_SC_DP); + sc->gfxListHead = sc->gfxListHead->next; + if (sc->gfxListHead == NULL) { + sc->gfxListTail = NULL; } } } diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 64f4a0d4c..4e7114efa 100755 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -357,7 +357,7 @@ s32 func_800CB934(Vec3f* arg0, Vec3f* arg1, Vec3f* arg2) { s32 ret = 0; if ((arg2->y - arg1->x) < (arg0->y - arg0->x)) { - ret = 1; + ret |= 1; } if ((arg0->y - arg0->x) < (arg1->y - arg2->x)) { @@ -413,19 +413,19 @@ s32 func_800CBAE4(Vec3f* v0, Vec3f* v1, Vec3f* v2) { s32 ret = 0; if ((v2->x + v2->y + v2->z) < (v0->x + v0->y + v0->z)) { - ret = 0x01; + ret |= 1; } if ((-v1->x + v2->y + v2->z) < (-v0->x + v0->y + v0->z)) { - ret |= 0x02; + ret |= 2; } if ((-v1->x + v2->y - v1->z) < (-v0->x + v0->y - v0->z)) { - ret |= 0x04; + ret |= 4; } if ((v2->x + v2->y - v1->z) < (v0->x + v0->y - v0->z)) { - ret |= 0x08; + ret |= 8; } if ((v2->x - v1->y + v2->z) < (v0->x - v0->y + v0->z)) { diff --git a/src/code/z_lights.c b/src/code/z_lights.c index 7abfb6a25..327c4f2d1 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -1,7 +1,7 @@ #include <ultra64.h> #include <global.h> -extern LightsList sLightsList; +LightsList sLightsList; void Lights_InitPositionalLight(LightInfoPositional* info, s16 posX, s16 posY, s16 posZ, u8 red, u8 green, u8 blue, s16 radius, u32 type) { @@ -59,7 +59,7 @@ Light* Lights_MapperGetNextFreeSlot(LightMapper* mapper) { return &mapper->lights[mapper->numLights++]; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_lights/func_8007A084.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_lights/func_8007A0B4.s") void func_8007A40C(LightMapper* mapper, LightInfoDirectionalParams* params, GlobalContext* globalCtx) { Light* light = Lights_MapperGetNextFreeSlot(mapper); diff --git a/src/code/z_play.c b/src/code/z_play.c index 160a9b291..5e40fce7b 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -65,74 +65,74 @@ void func_800BC5E0(GlobalContext* globalCtx, s32 transitionType) { transitionCtx->setType = TransitionCircle_SetType; transitionCtx->setColor = TransitionCircle_SetColor; transitionCtx->setEnvColor = TransitionCircle_SetEnvColor; - return; - } - - switch (transitionCtx->transitionType) { - case 1: - transitionCtx->init = TransitionTriforce_Init; - transitionCtx->destroy = TransitionTriforce_Destroy; - transitionCtx->start = TransitionTriforce_Start; - transitionCtx->isDone = TransitionTriforce_IsDone; - transitionCtx->draw = TransitionTriforce_Draw; - transitionCtx->update = TransitionTriforce_Update; - transitionCtx->setType = TransitionTriforce_SetType; - transitionCtx->setColor = TransitionTriforce_SetColor; - transitionCtx->setEnvColor = NULL; - return; - case 0: - case 8: - transitionCtx->init = TransitionWipe_Init; - transitionCtx->destroy = TransitionWipe_Destroy; - transitionCtx->start = TransitionWipe_Start; - transitionCtx->isDone = TransitionWipe_IsDone; - transitionCtx->draw = TransitionWipe_Draw; - transitionCtx->update = TransitionWipe_Update; - transitionCtx->setType = TransitionWipe_SetType; - transitionCtx->setColor = TransitionWipe_SetColor; - transitionCtx->setEnvColor = NULL; - return; - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 17: - case 18: - case 19: - transitionCtx->init = TransitionFade_Init; - transitionCtx->destroy = TransitionFade_Destroy; - transitionCtx->start = TransitionFade_Start; - transitionCtx->isDone = TransitionFade_IsDone; - transitionCtx->draw = TransitionFade_Draw; - transitionCtx->update = TransitionFade_Update; - transitionCtx->setType = TransitionFade_SetType; - transitionCtx->setColor = TransitionFade_SetColor; - transitionCtx->setEnvColor = NULL; - return; - case 9: - case 10: - globalCtx->transitionMode = 4; - return; - case 11: - globalCtx->transitionMode = 10; - return; - case 12: - globalCtx->transitionMode = 7; - return; - case 14: - globalCtx->transitionMode = 12; - return; - case 15: - globalCtx->transitionMode = 14; - return; - case 16: - globalCtx->transitionMode = 16; - return; + } else { + switch (transitionCtx->transitionType) { + case 1: + transitionCtx->init = TransitionTriforce_Init; + transitionCtx->destroy = TransitionTriforce_Destroy; + transitionCtx->start = TransitionTriforce_Start; + transitionCtx->isDone = TransitionTriforce_IsDone; + transitionCtx->draw = TransitionTriforce_Draw; + transitionCtx->update = TransitionTriforce_Update; + transitionCtx->setType = TransitionTriforce_SetType; + transitionCtx->setColor = TransitionTriforce_SetColor; + transitionCtx->setEnvColor = NULL; + break; + case 0: + case 8: + transitionCtx->init = TransitionWipe_Init; + transitionCtx->destroy = TransitionWipe_Destroy; + transitionCtx->start = TransitionWipe_Start; + transitionCtx->isDone = TransitionWipe_IsDone; + transitionCtx->draw = TransitionWipe_Draw; + transitionCtx->update = TransitionWipe_Update; + transitionCtx->setType = TransitionWipe_SetType; + transitionCtx->setColor = TransitionWipe_SetColor; + transitionCtx->setEnvColor = NULL; + break; + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 17: + case 18: + case 19: + transitionCtx->init = TransitionFade_Init; + transitionCtx->destroy = TransitionFade_Destroy; + transitionCtx->start = TransitionFade_Start; + transitionCtx->isDone = TransitionFade_IsDone; + transitionCtx->draw = TransitionFade_Draw; + transitionCtx->update = TransitionFade_Update; + transitionCtx->setType = TransitionFade_SetType; + transitionCtx->setColor = TransitionFade_SetColor; + transitionCtx->setEnvColor = NULL; + break; + case 9: + case 10: + globalCtx->transitionMode = 4; + break; + case 11: + globalCtx->transitionMode = 10; + break; + case 12: + globalCtx->transitionMode = 7; + break; + case 14: + globalCtx->transitionMode = 12; + break; + case 15: + globalCtx->transitionMode = 14; + break; + case 16: + globalCtx->transitionMode = 16; + break; + default: + Fault_AddHungupAndCrash("../z_play.c", 2290); + break; + } } - - Fault_AddHungupAndCrash("../z_play.c", 2290); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_800BC5E0.s") @@ -1589,19 +1589,15 @@ Camera* Gameplay_GetCamera(GlobalContext* globalCtx, s16 camId) { } s32 func_800C04D8(GlobalContext* globalCtx, s16 camId, Vec3f* arg2, Vec3f* arg3) { - u32 ret; + s32 ret = 0; s16 camIdx = (camId == -1) ? globalCtx->activeCamera : camId; - Camera* camera; + Camera* camera = globalCtx->cameraPtrs[camIdx]; Player* player; - camera = globalCtx->cameraPtrs[camIdx]; - - ret = Camera_SetParam(camera, 1, arg2); - ret *= 2; + ret |= Camera_SetParam(camera, 1, arg2); + ret <<= 1; ret |= Camera_SetParam(camera, 2, arg3); - if (1) {} // Necessary to match - camera->dist = Math3D_Vec3f_DistXYZ(arg2, arg3); player = camera->player; @@ -1618,22 +1614,16 @@ s32 func_800C04D8(GlobalContext* globalCtx, s16 camId, Vec3f* arg2, Vec3f* arg3) return ret; } -#ifdef NON_MATCHING -// missing an extra stack store/load instruction pair s32 func_800C05E4(GlobalContext* globalCtx, s16 camId, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4) { - u32 ret; + s32 ret = 0; s16 camIdx = (camId == -1) ? globalCtx->activeCamera : camId; - Camera* camera; + Camera* camera = globalCtx->cameraPtrs[camIdx]; Player* player; - camera = globalCtx->cameraPtrs[camIdx]; - - if (1) {} // Probably necessary to match - - ret = Camera_SetParam(camera, 1, arg2); - ret *= 2; + ret |= Camera_SetParam(camera, 1, arg2); + ret <<= 1; ret |= Camera_SetParam(camera, 2, arg3); - ret *= 2; + ret <<= 1; ret |= Camera_SetParam(camera, 4, arg4); camera->dist = Math3D_Vec3f_DistXYZ(arg2, arg3); @@ -1651,18 +1641,12 @@ s32 func_800C05E4(GlobalContext* globalCtx, s16 camId, Vec3f* arg2, Vec3f* arg3, return ret; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_800C05E4.s") -#endif -#ifdef NON_MATCHING -// missing an extra move instruction s32 func_800C0704(GlobalContext* globalCtx, s16 camId, f32 arg2) { - return (Camera_SetParam(globalCtx->cameraPtrs[camId], 32, &arg2) & 1); + s32 ret = Camera_SetParam(globalCtx->cameraPtrs[camId], 32, &arg2) & 1; + if (1) {} + return ret; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_800C0704.s") -#endif s32 func_800C0744(GlobalContext* globalCtx, s16 camId, s16 arg2) { s16 camIdx = (camId == -1) ? globalCtx->activeCamera : camId; diff --git a/src/code/z_room.c b/src/code/z_room.c index 129b6c2f5..2294bf201 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -273,7 +273,7 @@ void func_8009638C(Gfx** displayList, u32 source, u32 tlut, u16 width, u16 heigh func_80096238(SEGMENTED_TO_VIRTUAL(source)); displayListHead++; - gSPBranchList(displayListHead, displayListHead + 5); + gSPBranchList(displayListHead, (u8*)displayListHead + sizeof(uObjBg)); bg = (void*)displayListHead; bg->b.imageX = 0; bg->b.imageW = width * 4; |
