Merge branch 'master' into Inputs

This commit is contained in:
Reinmmar 2023-08-23 00:04:08 +02:00 committed by GitHub
commit 03eacc3c04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 134 additions and 134 deletions

View File

@ -57,24 +57,24 @@ extern const struct_08128AD8 gUnk_08128AD8[];
Subtask FigurineMenu0_Type0; Subtask FigurineMenu0_Type0;
Subtask FigurineMenu0_Type1; Subtask FigurineMenu0_Type1;
Subtask FigurineMenu0_Type2; Subtask FigurineMenu0_Type2;
Subtask FigurineMenu0_Type3; Subtask FigurineMenu0_ViewFigurineAfterDrawing;
Subtask FigurineMenu1_Type0; Subtask FigurineMenu1_Type0;
Subtask FigurineMenu1_Type1; Subtask FigurineMenu1_ViewAllFigurines;
Subtask FigurineMenu1_Type2; Subtask FigurineMenu1_Type2;
Subtask FigurineMenu1_Type3; Subtask FigurineMenu1_ExitMenu;
void Subtask_FigurineMenu(void) { void Subtask_FigurineMenu(void) {
static Subtask* const figurineMenu1_Types[] = { static Subtask* const figurineMenu1_Types[] = {
FigurineMenu0_Type0, FigurineMenu0_Type0,
FigurineMenu0_Type1, FigurineMenu0_Type1,
FigurineMenu0_Type2, FigurineMenu0_Type2,
FigurineMenu0_Type3, FigurineMenu0_ViewFigurineAfterDrawing,
}; };
static Subtask* const figurineMenu0_Types[] = { static Subtask* const figurineMenu0_Types[] = {
FigurineMenu1_Type0, FigurineMenu1_Type0,
FigurineMenu1_Type1, FigurineMenu1_ViewAllFigurines,
FigurineMenu1_Type2, FigurineMenu1_Type2,
FigurineMenu1_Type3, FigurineMenu1_ExitMenu,
}; };
#if !(defined(DEMO_USA) || defined(DEMO_JP)) #if !(defined(DEMO_USA) || defined(DEMO_JP))
FlushSprites(); FlushSprites();
@ -94,7 +94,7 @@ void Subtask_FigurineMenu(void) {
} }
void FigurineMenu_080A4608(void) { void FigurineMenu_080A4608(void) {
s32 iVar2, r1, r2; s32 iVar2, r1, maxFigurines;
SetBgmVolume(0x80); SetBgmVolume(0x80);
sub_080A4DA8(3); sub_080A4DA8(3);
@ -112,15 +112,15 @@ void FigurineMenu_080A4608(void) {
} }
r1 = gUI.field_0x3; r1 = gUI.field_0x3;
r2 = !gSave.saw_staffroll ? 0x82 : 0x88; maxFigurines = !gSave.saw_staffroll ? 130 : 136;
if (r2 < r1) { if (maxFigurines < r1) {
r1 = 1; r1 = 1;
} }
gFigurineMenu.figure_idx = r1; gFigurineMenu.figure_idx = r1;
SetFade(FADE_INSTANT, 8); SetFade(FADE_INSTANT, 8);
} }
void FigurineMenu_080A46C0(void) { void FigurineMenu_ExitMenu(void) {
SetBgmVolume(0x100); SetBgmVolume(0x100);
SoundReq(SFX_MENU_CANCEL); SoundReq(SFX_MENU_CANCEL);
ClearRoomFlag(2); ClearRoomFlag(2);
@ -175,32 +175,32 @@ void FigurineMenu0_Type2(void) {
} }
} }
void FigurineMenu0_Type3(void) { void FigurineMenu0_ViewFigurineAfterDrawing(void) {
s32 uVar1; s32 infoY;
s32 t; s32 t;
uVar1 = gFigurineMenu.unk1f; infoY = gFigurineMenu.unk1f;
switch (gInput.unk4) { switch (gInput.unk4) {
case B_BUTTON: case B_BUTTON:
case START_BUTTON: case START_BUTTON:
FigurineMenu_080A46C0(); FigurineMenu_ExitMenu();
break; break;
case DPAD_RIGHT: case DPAD_RIGHT:
uVar1 += 8; infoY += 8;
break; break;
case DPAD_LEFT: case DPAD_LEFT:
uVar1 -= 8; infoY -= 8;
break; break;
} }
t = gFigurineMenu.unk1e; t = gFigurineMenu.unk1e;
if (uVar1 < 0) { if (infoY < 0) {
uVar1 = 0; infoY = 0;
} }
if (t < uVar1) { if (t < infoY) {
uVar1 = t; infoY = t;
} }
gFigurineMenu.unk1f = uVar1; gFigurineMenu.unk1f = infoY;
gScreen.bg1.yOffset = uVar1 - 0x70; gScreen.bg1.yOffset = infoY - 112;
} }
void FigurineMenu1_Type0(void) { void FigurineMenu1_Type0(void) {
@ -211,85 +211,85 @@ void FigurineMenu1_Type0(void) {
SetMenuType(1); SetMenuType(1);
} }
void FigurineMenu1_Type1(void) { void FigurineMenu1_ViewAllFigurines(void) {
int r0, r1, r4, r5; int prevFigurineIndex, maxFigurines, figurineIndex, infoY;
if (gFadeControl.active) if (gFadeControl.active)
return; return;
r5 = gFigurineMenu.unk1f; infoY = gFigurineMenu.unk1f;
r4 = gFigurineMenu.figure_idx; figurineIndex = gFigurineMenu.figure_idx;
switch (gInput.unk4) { switch (gInput.unk4) {
case B_BUTTON: case B_BUTTON:
case START_BUTTON: case START_BUTTON:
SetMenuType(3); SetMenuType(3);
break; break;
case L_BUTTON: case L_BUTTON:
r4 -= 5; figurineIndex -= 5;
break; break;
case R_BUTTON: case R_BUTTON:
r4 += 5; figurineIndex += 5;
break; break;
case DPAD_UP: case DPAD_UP:
r4--; figurineIndex--;
break; break;
case DPAD_DOWN: case DPAD_DOWN:
r4++; figurineIndex++;
break; break;
case DPAD_RIGHT: case DPAD_RIGHT:
r5 += 8; infoY += 8;
break; break;
case DPAD_LEFT: case DPAD_LEFT:
r5 -= 8; infoY -= 8;
break; break;
case A_BUTTON: case A_BUTTON:
break; break;
} }
r1 = !gSave.saw_staffroll ? 0x82 : 0x88; maxFigurines = !gSave.saw_staffroll ? 130 : 136;
if (r4 <= 0) { if (figurineIndex <= 0) {
r4 = 1; figurineIndex = 1;
} }
if (r1 < r4) { if (maxFigurines < figurineIndex) {
r4 = r1; figurineIndex = maxFigurines;
} }
r0 = gFigurineMenu.figure_idx; prevFigurineIndex = gFigurineMenu.figure_idx;
if (r0 != r4) { if (prevFigurineIndex != figurineIndex) {
gFigurineMenu.figure_idx = r4; gFigurineMenu.figure_idx = figurineIndex;
SoundReq(SFX_TEXTBOX_CHOICE); SoundReq(SFX_TEXTBOX_CHOICE);
SetMenuType(2); SetMenuType(2);
r5 = 0; infoY = 0;
} }
r0 = gFigurineMenu.unk1e; prevFigurineIndex = gFigurineMenu.unk1e;
if (r5 < 0) { if (infoY < 0) {
r5 = 0; infoY = 0;
} }
if (r0 < r5) { if (prevFigurineIndex < infoY) {
r5 = r0; infoY = prevFigurineIndex;
} }
gFigurineMenu.unk1f = r5; gFigurineMenu.unk1f = infoY;
gScreen.bg1.yOffset = r5 - 0x70; gScreen.bg1.yOffset = infoY - 112;
} }
void FigurineMenu1_Type2(void) { void FigurineMenu1_Type2(void) {
SetMenuType(1); SetMenuType(1);
} }
void FigurineMenu1_Type3(void) { void FigurineMenu1_ExitMenu(void) {
FigurineMenu_080A46C0(); FigurineMenu_ExitMenu();
} }
u32 sub_080A4948(s32 param_1) { u32 FigurineMenu_isFigurineOwned(s32 figurineIndex) {
s32 iVar1; s32 maxFigurines;
u32 uVar2; u32 hasFigurine;
uVar2 = 0; hasFigurine = 0;
iVar1 = !gSave.saw_staffroll ? 0x82 : 0x88; maxFigurines = !gSave.saw_staffroll ? 130 : 136;
if ((0 < param_1) || (iVar1 >= param_1)) { if ((0 < figurineIndex) || (maxFigurines >= figurineIndex)) {
if (ReadBit((u32*)gSave.figurines, param_1)) { if (ReadBit(gSave.figurines, figurineIndex)) {
uVar2 = 1; hasFigurine = 1;
} }
} }
return uVar2; return hasFigurine;
} }
typedef struct { typedef struct {
@ -307,7 +307,7 @@ extern const Figurine gFigurines[];
#define sub_080A4978_draw_constant 0x1fc #define sub_080A4978_draw_constant 0x1fc
#endif #endif
void FigurineMenu_080A4978(void) { void FigurineMenu_080A4978(void) {
int r0, r2, r4, r6; int r0, maxFigurines, r4, r6;
gOamCmd._4 = 0; gOamCmd._4 = 0;
gOamCmd._6 = 0; gOamCmd._6 = 0;
@ -315,11 +315,11 @@ void FigurineMenu_080A4978(void) {
gOamCmd.x = 0x9c; gOamCmd.x = 0x9c;
gOamCmd.y = 0x48; gOamCmd.y = 0x48;
DrawDirect(sub_080A4978_draw_constant, 0); DrawDirect(sub_080A4978_draw_constant, 0);
r2 = !gSave.saw_staffroll ? 0x82 : 0x88; maxFigurines = !gSave.saw_staffroll ? 130 : 136;
if ((gMenu.column_idx & 2) != 0) { if ((gMenu.column_idx & 2) != 0) {
if (r2 >= (gFigurineMenu.figure_idx)) { if (maxFigurines >= (gFigurineMenu.figure_idx)) {
gOamCmd.x = 0xe8; gOamCmd.x = 0xe8;
r0 = (0x5000 / r2) * (gFigurineMenu.figure_idx - 1); r0 = (0x5000 / maxFigurines) * (gFigurineMenu.figure_idx - 1);
if (r0 < 0) { if (r0 < 0) {
r0 += 0xff; r0 += 0xff;
} }
@ -367,7 +367,7 @@ void FigurineMenu_080A4978(void) {
} }
} }
if (gMenu.column_idx & 1) { if (gMenu.column_idx & 1) {
if (sub_080A4948(gFigurineMenu.figure_idx)) { if (FigurineMenu_isFigurineOwned(gFigurineMenu.figure_idx)) {
gOamCmd.x = 0x2c; gOamCmd.x = 0x2c;
gOamCmd.y = 0x48; gOamCmd.y = 0x48;
gOamCmd._8 = 0xd4 << 7; gOamCmd._8 = 0xd4 << 7;
@ -447,7 +447,7 @@ extern void ShowTextBox(u32, const struct_0812816C*);
void sub_080A4BA0(u32 arg1, u32 arg2) { void sub_080A4BA0(u32 arg1, u32 arg2) {
int r0, r5, r6; int r0, r5, r6;
int tmp; int maxFigurines;
struct_0812816C s0; struct_0812816C s0;
u8 buffer[0x30]; u8 buffer[0x30];
@ -465,13 +465,13 @@ void sub_080A4BA0(u32 arg1, u32 arg2) {
s0.unk14 = arg2; s0.unk14 = arg2;
} }
tmp = !gSave.saw_staffroll ? 0x82 : 0x88; maxFigurines = !gSave.saw_staffroll ? 130 : 136;
if (r5 <= 0 || tmp < r5) { if (r5 <= 0 || maxFigurines < r5) {
r5 = -1; r5 = -1;
} else { } else {
sub_08057044(r5, gUnk_020227E8, 0x303030); sub_08057044(r5, gUnk_020227E8, 0x303030);
if (sub_080A4948(r5) == 0) { if (FigurineMenu_isFigurineOwned(r5) == 0) {
r5 += 0x8000; r5 += 0x8000;
} else { } else {
r5 += 0x800; r5 += 0x800;
@ -526,18 +526,18 @@ const struct_0812816C gUnk_08128190 = {
0x5u, 0x5u,
}; };
u32 sub_080A4CBC(u32 param_1) { u32 sub_080A4CBC(u32 figurineIndex) {
s32 iVar1; s32 ownsFigurine;
const u16* psVar2; const u16* psVar2;
u32 uVar3; u32 uVar3;
if (gFigurineMenu.unk1a != param_1) { if (gFigurineMenu.unk1a != figurineIndex) {
gFigurineMenu.unk1a = param_1; gFigurineMenu.unk1a = figurineIndex;
MemClear(&gBG1Buffer, sizeof(gBG1Buffer)); MemClear(&gBG1Buffer, sizeof(gBG1Buffer));
MemCopy(&gBG1Buffer, (void*)0x600e000, sizeof(gBG1Buffer)); MemCopy(&gBG1Buffer, (void*)0x600e000, sizeof(gBG1Buffer));
iVar1 = sub_080A4948(param_1); ownsFigurine = FigurineMenu_isFigurineOwned(figurineIndex);
if (iVar1 != 0) { if (ownsFigurine != 0) {
ShowTextBox(param_1 + 0x900, &gUnk_08128190); ShowTextBox(figurineIndex + 0x900, &gUnk_08128190);
} }
gScreen.bg1.updated = 1; gScreen.bg1.updated = 1;
} }

View File

@ -50,8 +50,8 @@ void sub_08088328(FigurineDeviceEntity*);
void sub_0808826C(FigurineDeviceEntity*); void sub_0808826C(FigurineDeviceEntity*);
void sub_080882A8(FigurineDeviceEntity*); void sub_080882A8(FigurineDeviceEntity*);
void sub_080880D8(FigurineDeviceEntity*); void sub_080880D8(FigurineDeviceEntity*);
void sub_08087F94(FigurineDeviceEntity*, s32); void FigurineDevice_ChangeShellAmount(FigurineDeviceEntity*, s32);
void sub_08088034(FigurineDeviceEntity*); void FigurineDevice_PlayErrorSound(FigurineDeviceEntity*);
bool32 sub_08088160(FigurineDeviceEntity*, s32); bool32 sub_08088160(FigurineDeviceEntity*, s32);
void sub_08088424(FigurineDeviceEntity*); void sub_08088424(FigurineDeviceEntity*);
void FigurineDevice_Init(FigurineDeviceEntity*); void FigurineDevice_Init(FigurineDeviceEntity*);
@ -265,10 +265,10 @@ void FigurineDevice_Action4(FigurineDeviceEntity* this) {
switch (gInput.unk4 & 0xfffffeff) { switch (gInput.unk4 & 0xfffffeff) {
#endif #endif
case DPAD_UP: case DPAD_UP:
sub_08087F94(this, tmp); FigurineDevice_ChangeShellAmount(this, tmp);
break; break;
case DPAD_DOWN: case DPAD_DOWN:
sub_08087F94(this, -tmp); FigurineDevice_ChangeShellAmount(this, -tmp);
break; break;
} }
if (old_81 != this->unk_81) { if (old_81 != this->unk_81) {
@ -277,10 +277,10 @@ void FigurineDevice_Action4(FigurineDeviceEntity* this) {
#else #else
switch (gInput.unk4) { switch (gInput.unk4) {
case DPAD_UP: case DPAD_UP:
sub_08087F94(this, 1); FigurineDevice_ChangeShellAmount(this, 1);
break; break;
case DPAD_DOWN: case DPAD_DOWN:
sub_08087F94(this, -1); FigurineDevice_ChangeShellAmount(this, -1);
break; break;
} }
if (old_81 != this->unk_81) { if (old_81 != this->unk_81) {
@ -313,124 +313,124 @@ void sub_08087F58(FigurineDeviceEntity* this) {
} }
} }
void sub_08087F94(FigurineDeviceEntity* this, s32 param_2) { void FigurineDevice_ChangeShellAmount(FigurineDeviceEntity* this, s32 shellDifference) {
#ifdef EU #ifdef EU
u32 uVar8; u32 newAmount2;
u32 iVar9; u32 newAmount;
iVar9 = this->unk_83 + param_2; newAmount = this->unk_83 + shellDifference;
if (CheckLocalFlag(SHOP07_COMPLETE)) { if (CheckLocalFlag(SHOP07_COMPLETE)) {
sub_08088034(this); FigurineDevice_PlayErrorSound(this);
return; return;
} }
if (param_2 < 0) { if (shellDifference < 0) {
if (iVar9 < this->unk_82) { if (newAmount < this->unk_82) {
if (this->unk_83 != this->unk_82) { if (this->unk_83 != this->unk_82) {
this->unk_83 = this->unk_82; this->unk_83 = this->unk_82;
this->unk_81 = 1; this->unk_81 = 1;
SoundReq(SFX_TEXTBOX_CHOICE); SoundReq(SFX_TEXTBOX_CHOICE);
} else { } else {
sub_08088034(this); FigurineDevice_PlayErrorSound(this);
} }
} else { } else {
this->unk_83 = iVar9; this->unk_83 = newAmount;
this->unk_81 += param_2; this->unk_81 += shellDifference;
SoundReq(SFX_TEXTBOX_CHOICE); SoundReq(SFX_TEXTBOX_CHOICE);
} }
return; return;
} }
uVar8 = this->unk_81 + param_2; newAmount2 = this->unk_81 + shellDifference;
if (uVar8 > (s32)gSave.stats.shells) { if (newAmount2 > (s32)gSave.stats.shells) {
if (gSave.stats.shells != this->unk_81) { if (gSave.stats.shells != this->unk_81) {
uVar8 = gSave.stats.shells; newAmount2 = gSave.stats.shells;
param_2 = (gSave.stats.shells - this->unk_81); shellDifference = (gSave.stats.shells - this->unk_81);
iVar9 = this->unk_83 + param_2; newAmount = this->unk_83 + shellDifference;
} else { } else {
sub_08088034(this); FigurineDevice_PlayErrorSound(this);
return; return;
} }
} else if (iVar9 > 100) { } else if (newAmount > 100) {
if (this->unk_83 == 100) { if (this->unk_83 == 100) {
sub_08088034(this); FigurineDevice_PlayErrorSound(this);
return; return;
} else { } else {
iVar9 = 100; newAmount = 100;
param_2 = (iVar9 - this->unk_83); shellDifference = (newAmount - this->unk_83);
uVar8 = this->unk_81 + param_2; newAmount2 = this->unk_81 + shellDifference;
} }
} }
#else #else
s32 uVar8; s32 newAmount2;
s32 iVar9; s32 newAmount;
s32 t1, t2; s32 prevAmount, prevAmount2;
if (CheckLocalFlag(SHOP07_COMPLETE)) { if (CheckLocalFlag(SHOP07_COMPLETE)) {
sub_08088034(this); FigurineDevice_PlayErrorSound(this);
return; return;
} }
// This could probably be done without t1 and t2 // This could probably be done without prevAmount and prevAmount2
t1 = this->unk_83; prevAmount = this->unk_83;
iVar9 = t1 + param_2; newAmount = prevAmount + shellDifference;
if (param_2 < 0) { if (shellDifference < 0) {
if (iVar9 < this->unk_82) { if (newAmount < this->unk_82) {
if (this->unk_83 != this->unk_82) { if (this->unk_83 != this->unk_82) {
this->unk_83 = this->unk_82; this->unk_83 = this->unk_82;
this->unk_81 = 1; this->unk_81 = 1;
SoundReq(SFX_TEXTBOX_CHOICE); SoundReq(SFX_TEXTBOX_CHOICE);
} else { } else {
sub_08088034(this); FigurineDevice_PlayErrorSound(this);
} }
} else { } else {
this->unk_83 = iVar9; this->unk_83 = newAmount;
this->unk_81 += param_2; this->unk_81 += shellDifference;
SoundReq(SFX_TEXTBOX_CHOICE); SoundReq(SFX_TEXTBOX_CHOICE);
} }
return; return;
} }
t2 = this->unk_81; prevAmount2 = this->unk_81;
uVar8 = t2 + param_2; newAmount2 = prevAmount2 + shellDifference;
if (uVar8 > gSave.stats.shells) { if (newAmount2 > gSave.stats.shells) {
if (gSave.stats.shells != this->unk_81) { if (gSave.stats.shells != this->unk_81) {
uVar8 = gSave.stats.shells; newAmount2 = gSave.stats.shells;
param_2 = (gSave.stats.shells - this->unk_81); shellDifference = (gSave.stats.shells - this->unk_81);
iVar9 = t1 + param_2; newAmount = prevAmount + shellDifference;
#ifdef JP #ifdef JP
if (iVar9 > 100) { if (newAmount > 100) {
iVar9 = 100; newAmount = 100;
param_2 = (iVar9 - t1); shellDifference = (newAmount - prevAmount);
uVar8 = t2 + param_2; newAmount2 = prevAmount2 + shellDifference;
} }
#endif #endif
} else { } else {
sub_08088034(this); FigurineDevice_PlayErrorSound(this);
return; return;
} }
} }
#ifdef JP #ifdef JP
else if (iVar9 > 100) { else if (newAmount > 100) {
#else #else
if (iVar9 > 100) { if (newAmount > 100) {
#endif #endif
if (this->unk_83 == 100) { if (this->unk_83 == 100) {
sub_08088034(this); FigurineDevice_PlayErrorSound(this);
return; return;
} else { } else {
iVar9 = 100; newAmount = 100;
param_2 = (iVar9 - t1); shellDifference = (newAmount - prevAmount);
uVar8 = t2 + param_2; newAmount2 = prevAmount2 + shellDifference;
} }
} }
#endif #endif
this->unk_83 = iVar9; this->unk_83 = newAmount;
this->unk_81 = uVar8; this->unk_81 = newAmount2;
SoundReq(SFX_TEXTBOX_CHOICE); SoundReq(SFX_TEXTBOX_CHOICE);
} }
void sub_08088034(FigurineDeviceEntity* this) { void FigurineDevice_PlayErrorSound(FigurineDeviceEntity* this) {
if (super->timer == 0) { if (super->timer == 0) {
super->timer = 20; super->timer = 20;
SoundReq(SFX_MENU_ERROR); SoundReq(SFX_MENU_ERROR);