summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorRandom <28494085+Random06457@users.noreply.github.com>2020-05-22 14:33:10 +0200
committerGitHub <noreply@github.com>2020-05-22 08:33:10 -0400
commit89b0977e39a744838ce7053a40ad3c3e37a2f491 (patch)
tree98921654498a18f7ee58e08e2ba0c6396d28408a /src/code
parent9a478a96ec3fe329e643383a6a246d5553831158 (diff)
Decompile code_8008E6A0.c / Add CHECK_PAD macro (#156)
* Decompile code_8008E6A0.c * Delete "counter" file
Diffstat (limited to 'src/code')
-rw-r--r--src/code/code_8008E6A0.c38
-rw-r--r--src/code/fault.c24
-rw-r--r--src/code/game.c4
-rw-r--r--src/code/graph.c4
-rw-r--r--src/code/z_camera.c8
-rw-r--r--src/code/z_debug.c20
-rw-r--r--src/code/z_demo.c13
-rw-r--r--src/code/z_map_exp.c4
-rw-r--r--src/code/z_parameter.c6
-rw-r--r--src/code/z_play.c4
-rw-r--r--src/code/z_player_lib.c3
-rw-r--r--src/code/z_sample.c2
12 files changed, 83 insertions, 47 deletions
diff --git a/src/code/code_8008E6A0.c b/src/code/code_8008E6A0.c
new file mode 100644
index 000000000..6a1fe8c31
--- /dev/null
+++ b/src/code/code_8008E6A0.c
@@ -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;
+}
diff --git a/src/code/fault.c b/src/code/fault.c
index 7350ac1ac..bc6e57dfe 100644
--- a/src/code/fault.c
+++ b/src/code/fault.c
@@ -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;
}
}
diff --git a/src/code/game.c b/src/code/game.c
index 5a7c14985..7bbfb965a 100644
--- a/src/code/game.c
+++ b/src/code/game.c
@@ -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) {
diff --git a/src/code/graph.c b/src/code/graph.c
index b8c8605d6..e8c5a6393 100644
--- a/src/code/graph.c
+++ b/src/code/graph.c
@@ -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;
diff --git a/src/code/z_camera.c b/src/code/z_camera.c
index 68366d27e..fb5a9bd19 100644
--- a/src/code/z_camera.c
+++ b/src/code/z_camera.c
@@ -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) {
diff --git a/src/code/z_debug.c b/src/code/z_debug.c
index fc663c3d2..bcb40d16e 100644
--- a/src/code/z_debug.c
+++ b/src/code/z_debug.c
@@ -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) {
diff --git a/src/code/z_demo.c b/src/code/z_demo.c
index e67cd5176..36b47ee59 100644
--- a/src/code/z_demo.c
+++ b/src/code/z_demo.c
@@ -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;
}
diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c
index 729542bea..aea0719ba 100644
--- a/src/code/z_map_exp.c
+++ b/src/code/z_map_exp.c
@@ -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); }
diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c
index 5c32f70c2..ab88d7f02 100644
--- a/src/code/z_parameter.c
+++ b/src/code/z_parameter.c
@@ -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);
}
diff --git a/src/code/z_play.c b/src/code/z_play.c
index 0c8bc8540..2f1411a92 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -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) {
diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c
index 862a10f33..677ae8a68 100644
--- a/src/code/z_player_lib.c
+++ b/src/code/z_player_lib.c
@@ -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);
diff --git a/src/code/z_sample.c b/src/code/z_sample.c
index 1ad2e6e28..74e7639f2 100644
--- a/src/code/z_sample.c
+++ b/src/code/z_sample.c
@@ -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;
}