1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 06:54:33 +00:00

Decompile code_8008E6A0.c / Add CHECK_PAD macro (#156)

* Decompile code_8008E6A0.c

* Delete "counter" file
This commit is contained in:
Random 2020-05-22 14:33:10 +02:00 committed by GitHub
parent 9a478a96ec
commit 89b0977e39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 88 additions and 111 deletions

38
src/code/code_8008E6A0.c Normal file
View file

@ -0,0 +1,38 @@
#include <global.h>
void func_8008E6A0(SubGlobalContext7B8* this) {
this->counter = 0;
this->toggle = false;
}
u32 func_8008E6AC(SubGlobalContext7B8* this, Input* input) {
if (CHECK_PAD(input->cur, R_TRIG) && CHECK_PAD(input->press, D_JPAD)) {
this->toggle = !this->toggle;
}
if (!this->toggle) {
goto ret_true;
}
if (CHECK_PAD(input->cur, Z_TRIG)) {
if (CHECK_PAD(input->press, R_TRIG)) {
goto ret_true;
}
if (CHECK_PAD(input->cur, R_TRIG)) {
this->counter++;
if (this->counter >= 9) {
goto ret_true;
}
}
}
goto ret_false;
ret_true:
this->counter = 0;
return true;
ret_false:
return false;
}

View file

@ -583,7 +583,7 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1) {
count--;
Fault_Sleep(0x10);
Fault_UpdatePadImpl();
if (!~(curInput->press.in.button | ~L_TRIG)) {
if (CHECK_PAD(curInput->press, L_TRIG)) {
sFaultStructPtr->faultActive = false;
}
}
@ -593,40 +593,40 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1) {
Fault_UpdatePadImpl();
} while (curInput->press.in.button == 0);
if (!~(curInput->press.in.button | ~START_BUTTON)) {
if (CHECK_PAD(curInput->press, START_BUTTON)) {
return;
}
if (!~(curInput->cur.in.button | ~A_BUTTON)) {
if (CHECK_PAD(curInput->cur, A_BUTTON)) {
return;
}
off = 0x10;
if (!~(curInput->cur.in.button | ~Z_TRIG)) {
if (CHECK_PAD(curInput->cur, Z_TRIG)) {
off = 0x100;
}
if (!~(curInput->cur.in.button | ~B_BUTTON)) {
if (CHECK_PAD(curInput->cur, B_BUTTON)) {
off <<= 8;
}
if (!~(curInput->cur.in.button | ~U_JPAD)) {
if (CHECK_PAD(curInput->cur, U_JPAD)) {
addr -= off;
}
if (!~(curInput->cur.in.button | ~D_JPAD)) {
if (CHECK_PAD(curInput->cur, D_JPAD)) {
addr += off;
}
if (!~(curInput->cur.in.button | ~U_CBUTTONS)) {
if (CHECK_PAD(curInput->cur, U_CBUTTONS)) {
addr = pc;
}
if (!~(curInput->cur.in.button | ~D_CBUTTONS)) {
if (CHECK_PAD(curInput->cur, D_CBUTTONS)) {
addr = sp;
}
if (!~(curInput->cur.in.button | ~L_CBUTTONS)) {
if (CHECK_PAD(curInput->cur, L_CBUTTONS)) {
addr = unk0;
}
if (!~(curInput->cur.in.button | ~R_CBUTTONS)) {
if (CHECK_PAD(curInput->cur, R_CBUTTONS)) {
addr = unk1;
}
if (!~(curInput->cur.in.button | ~L_TRIG)) {
if (CHECK_PAD(curInput->cur, L_TRIG)) {
break;
}
}

View file

@ -88,8 +88,8 @@ void func_800C4344(GameState* gameState) {
HREG(89) = selectedInput->cur.in.x;
HREG(90) = selectedInput->cur.in.y;
HREG(93) = (selectedInput->cur.in.button == hReg82);
HREG(94) = (~(selectedInput->cur.in.button | ~hReg82) == 0);
HREG(95) = (~(selectedInput->press.in.button | ~hReg82) == 0);
HREG(94) = CHECK_PAD(selectedInput->cur, hReg82);
HREG(95) = CHECK_PAD(selectedInput->press, hReg82);
}
if (D_8012DBC0 != 0) {

View file

@ -386,8 +386,8 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
}
sGraphUpdateTime = time;
if (D_8012DBC0 && (!~(gameState->input[0].press.in.button | ~Z_TRIG)) &&
(!~(gameState->input[0].cur.in.button | ~(L_TRIG | R_TRIG)))) {
if (D_8012DBC0 && CHECK_PAD(gameState->input[0].press, Z_TRIG) &&
CHECK_PAD(gameState->input[0].cur, L_TRIG | R_TRIG)) {
gSaveContext.gameMode = 0;
SET_NEXT_GAMESTATE(gameState, func_80801E44, char[0x240]); // TODO : SelectContext
gameState->running = false;

View file

@ -1360,19 +1360,19 @@ s32 func_80058D34(Camera* camera) {
if (D_8011D394 == 0) {
if (camera->globalCtx->activeCamera == 0) {
if (~(D_8015BD7C->state.input[2].press.in.button | ~U_CBUTTONS) == 0) {
if (CHECK_PAD(D_8015BD7C->state.input[2].press, U_CBUTTONS)) {
osSyncPrintf("attention sound URGENCY\n");
func_80078884(NA_SE_SY_ATTENTION_URGENCY);
}
if (~(D_8015BD7C->state.input[2].press.in.button | ~D_CBUTTONS) == 0) {
if (CHECK_PAD(D_8015BD7C->state.input[2].press, D_CBUTTONS)) {
osSyncPrintf("attention sound NORMAL\n");
func_80078884(NA_SE_SY_ATTENTION_ON);
}
if (~(D_8015BD7C->state.input[2].press.in.button | ~R_CBUTTONS) == 0) {
if (CHECK_PAD(D_8015BD7C->state.input[2].press, R_CBUTTONS)) {
phi_a2 = 1;
}
if (~(D_8015BD7C->state.input[2].press.in.button | ~L_CBUTTONS) == 0) {
if (CHECK_PAD(D_8015BD7C->state.input[2].press, L_CBUTTONS)) {
phi_a2 = -1;
}
if (phi_a2 != 0) {

View file

@ -115,8 +115,7 @@ void func_8006390C(Input* input) {
regGroup = (gGameInfo->regGroup * REG_PAGES + gGameInfo->regPage) * REG_PER_PAGE - REG_PER_PAGE;
dpad = input->cur.in.button & (U_JPAD | L_JPAD | R_JPAD | D_JPAD);
if (!~(input->cur.in.button | ~L_TRIG) || !~(input->cur.in.button | ~R_TRIG) ||
!~(input->cur.in.button | ~START_BUTTON)) {
if (CHECK_PAD(input->cur, L_TRIG) || CHECK_PAD(input->cur, R_TRIG) || CHECK_PAD(input->cur, START_BUTTON)) {
input_combo = inputCombos;
for (i = 0; i < REG_GROUPS; i++) {
if (~(~input_combo->push | input->cur.in.button) || ~(~input_combo->held | input->press.in.button)) {
@ -157,16 +156,15 @@ void func_8006390C(Input* input) {
increment =
(dpad & R_JPAD)
? (!~(input->cur.in.button | ~(A_BUTTON | B_BUTTON))
? (CHECK_PAD(input->cur, A_BUTTON | B_BUTTON)
? 1000
: !~(input->cur.in.button | ~A_BUTTON) ? 100
: !~(input->cur.in.button | ~B_BUTTON) ? 10 : 1)
: (dpad & L_JPAD) ? (!~(input->cur.in.button | ~(A_BUTTON | B_BUTTON))
? -1000
: !~(input->cur.in.button | ~A_BUTTON)
? -100
: !~(input->cur.in.button | ~B_BUTTON) ? -10 : -1)
: 0;
: CHECK_PAD(input->cur, A_BUTTON) ? 100 : CHECK_PAD(input->cur, B_BUTTON) ? 10 : 1)
: (dpad & L_JPAD)
? (CHECK_PAD(input->cur, A_BUTTON | B_BUTTON)
? -1000
: CHECK_PAD(input->cur, A_BUTTON) ? -100
: CHECK_PAD(input->cur, B_BUTTON) ? -10 : -1)
: 0;
gGameInfo->data[gGameInfo->regCur + regGroup] += increment;
if (dpad & U_JPAD) {

View file

@ -99,13 +99,13 @@ void func_80064558(GlobalContext* globalCtx, CutsceneContext* csCtx) {
void func_800645A0(GlobalContext* globalCtx, CutsceneContext* csCtx) {
Input* pad1 = &globalCtx->state.input[0];
if (!~(pad1->press.in.button | ~L_JPAD) && (csCtx->state == CS_STATE_IDLE) && (gSaveContext.sceneSetupIndex >= 4)) {
if (CHECK_PAD(pad1->press, L_JPAD) && (csCtx->state == CS_STATE_IDLE) && (gSaveContext.sceneSetupIndex >= 4)) {
D_8015FCC8 = 0;
gSaveContext.cutsceneIndex = 0xFFFD;
gSaveContext.cutsceneTrigger = 1;
}
if (!~(pad1->press.in.button | ~U_JPAD) && (csCtx->state == CS_STATE_IDLE) && (gSaveContext.sceneSetupIndex >= 4) &&
if (CHECK_PAD(pad1->press, U_JPAD) && (csCtx->state == CS_STATE_IDLE) && (gSaveContext.sceneSetupIndex >= 4) &&
(D_8011D394 == 0)) {
D_8015FCC8 = 1;
gSaveContext.cutsceneIndex = 0xFFFD;
@ -443,16 +443,15 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt
if ((gSaveContext.gameMode != 0) && (gSaveContext.gameMode != 3) && (globalCtx->sceneNum != SCENE_SPOT00) &&
(csCtx->frames > 20) &&
(!~(globalCtx->state.input[0].press.in.button | ~A_BUTTON) ||
!~(globalCtx->state.input[0].press.in.button | ~B_BUTTON) ||
!~(globalCtx->state.input[0].press.in.button | ~START_BUTTON)) &&
(CHECK_PAD(globalCtx->state.input[0].press, A_BUTTON) || CHECK_PAD(globalCtx->state.input[0].press, B_BUTTON) ||
CHECK_PAD(globalCtx->state.input[0].press, START_BUTTON)) &&
(gSaveContext.fileNum != 0xFEDC) && (globalCtx->sceneLoadFlag == 0)) {
Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
temp = 1;
}
if ((csCtx->frames == cmd->startFrame) || (temp != 0) ||
((csCtx->frames > 20) && (!~(globalCtx->state.input[0].press.in.button | ~START_BUTTON)) &&
((csCtx->frames > 20) && CHECK_PAD(globalCtx->state.input[0].press, START_BUTTON) &&
(gSaveContext.fileNum != 0xFEDC))) {
csCtx->state = CS_STATE_UNSKIPPABLE_EXEC;
func_800F68BC(0);
@ -1524,7 +1523,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
return;
}
if (!~(globalCtx->state.input[0].press.in.button | ~R_JPAD)) {
if (CHECK_PAD(globalCtx->state.input[0].press, R_JPAD)) {
csCtx->state = CS_STATE_UNSKIPPABLE_INIT;
return;
}

View file

@ -413,7 +413,7 @@ void Minimap_Draw(GlobalContext* globalCtx) {
}
}
if (!~(globalCtx->state.input[0].press.in.button | ~L_TRIG) && !Gameplay_InCsMode(globalCtx)) {
if (CHECK_PAD(globalCtx->state.input[0].press, L_TRIG) && !Gameplay_InCsMode(globalCtx)) {
osSyncPrintf("Game_play_demo_mode_check=%d\n", Gameplay_InCsMode(globalCtx));
// clang-format off
if (!R_MINIMAP_TOGGLED) { Audio_PlaySoundGeneral(NA_SE_SY_CAMERA_ZOOM_UP, &D_801333D4, 4,
@ -494,7 +494,7 @@ void Minimap_Draw(GlobalContext* globalCtx) {
Minimap_DrawCompassIcons(globalCtx); // Draw icons for the player spawn and current position
}
if (!~(globalCtx->state.input[0].press.in.button | ~L_TRIG) && !Gameplay_InCsMode(globalCtx)) {
if (CHECK_PAD(globalCtx->state.input[0].press, L_TRIG) && !Gameplay_InCsMode(globalCtx)) {
// clang-format off
if (!R_MINIMAP_TOGGLED) { Audio_PlaySoundGeneral(NA_SE_SY_CAMERA_ZOOM_UP, &D_801333D4, 4,
&D_801333E0, &D_801333E0, &D_801333E8); }

View file

@ -3979,13 +3979,13 @@ void Interface_Update(GlobalContext* globalCtx) {
u16 action;
Input* input = &globalCtx->state.input[2];
if (!~(input->press.in.button | ~L_JPAD)) {
if (CHECK_PAD(input->press, L_JPAD)) {
gSaveContext.language = 0;
osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language);
} else if (!~(input->press.in.button | ~U_JPAD)) {
} else if (CHECK_PAD(input->press, U_JPAD)) {
gSaveContext.language = 1;
osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language);
} else if (!~(input->press.in.button | ~R_JPAD)) {
} else if (CHECK_PAD(input->press, R_JPAD)) {
gSaveContext.language = 2;
osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language);
}

View file

@ -924,7 +924,7 @@ void Gameplay_Update(GlobalContext* globalCtx) {
}
if (globalCtx->unk_1242B != 0) {
if (!~(input[0].press.in.button | ~8)) {
if (CHECK_PAD(input[0].press, U_CBUTTONS)) {
if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.flag != 0)) {
// Translates to: "Changing viewpoint is prohibited due to the kaleidoscope"
osSyncPrintf(VT_FGCOL(CYAN) "カレイドスコープ中につき視点変更を禁止しております\n" VT_RST);
@ -1823,7 +1823,7 @@ s32 func_800C0CB8(GlobalContext* globalCtx) {
}
s32 func_800C0D28(GlobalContext* globalCtx) {
return (globalCtx->sub_7B8.unk_0 != 0);
return (globalCtx->sub_7B8.toggle != 0);
}
s32 func_800C0D34(GlobalContext* globalCtx, Actor* actor, s16* yaw) {

View file

@ -505,7 +505,8 @@ void func_800906D4(GlobalContext* globalCtx, Player* player, ColliderTrisItemDim
Matrix_MultVec3f(&D_801260BC, &sp44);
if (func_80090480(globalCtx, NULL, &player->swordDimensions, &trisInit->vtx[0], &sp2C) != 0 &&
(s32)(player->stateFlags1 << 9) >= 0) {
EffectBlure_AddVertex(Effect_GetByIndex(player->swordEffectId), &player->swordDimensions.tip, &player->swordDimensions.base);
EffectBlure_AddVertex(Effect_GetByIndex(player->swordEffectId), &player->swordDimensions.tip,
&player->swordDimensions.base);
}
if (player->swordState > 0 && ((player->swordAnimation < 0x18) || ((s32)(player->stateFlags2 << 0xE) < 0))) {
func_80090480(globalCtx, &player->unk_4E4, &player->unk_8D0, &trisInit->vtx[1], &sp38);

View file

@ -3,7 +3,7 @@
#include <PR/os_cont.h>
void Sample_HandleStateChange(SampleContext* this) {
if (!~(this->state.input[0].press.in.button | ~START_BUTTON)) {
if (CHECK_PAD(this->state.input[0].press, START_BUTTON)) {
SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext);
this->state.running = false;
}