diff --git a/assets/xml/objects/object_kujiya.xml b/assets/xml/objects/object_kujiya.xml index 3b17d43c08..f657e8bd8d 100644 --- a/assets/xml/objects/object_kujiya.xml +++ b/assets/xml/objects/object_kujiya.xml @@ -1,25 +1,31 @@  + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c index 0e2bbf3eb0..caf235b058 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.c @@ -2,6 +2,8 @@ * File: z_en_kujiya.c * Overlay: ovl_En_Kujiya * Description: Clock Town - Lottery Shop + * + * (kuji = lottery, ya = shop) */ #include "z_en_kujiya.h" @@ -16,21 +18,21 @@ void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx); void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80BB09A8(EnKujiya* this); -void func_80BB09BC(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0E44(EnKujiya* this); -void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0F24(EnKujiya* this); -void func_80BB0F38(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB0F94(EnKujiya* this); -void func_80BB0FA8(EnKujiya* this, GlobalContext* globalCtx); -s32 func_80BB0FF8(void); -void func_80BB1088(void); -void func_80BB10F8(void); -void func_80BB1168(EnKujiya* this); -void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx); -void func_80BB1250(EnKujiya* this); -void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupWait(EnKujiya* this); +void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupTalk(EnKujiya* this); +void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupGivePrize(EnKujiya* this); +void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupFinishGivePrize(EnKujiya* this); +void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx); +s32 EnKujiya_CheckBoughtTicket(void); +void EnKujiya_SetBoughtTicket(void); +void EnKujiya_UnsetBoughtTicket(void); +void EnKujiya_SetupTurnToOpen(EnKujiya* this); +void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx); +void EnKujiya_SetupTurnToClosed(EnKujiya* this); +void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx); const ActorInit En_Kujiya_InitVars = { ACTOR_EN_KUJIYA, @@ -63,141 +65,138 @@ void EnKujiya_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 30.0f; - if (func_80BB0FF8() && (gSaveContext.save.time >= CLOCK_TIME(6, 0)) && + if (EnKujiya_CheckBoughtTicket() && (gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { this->actor.shape.rot.y = 0; } else { this->actor.shape.rot.y = 0x7555; } - func_80BB09A8(this); + EnKujiya_SetupWait(this); } void EnKujiya_Destroy(Actor* thisx, GlobalContext* globalCtx) { } -void func_80BB09A8(EnKujiya* this) { - this->actionFunc = func_80BB09BC; +void EnKujiya_SetupWait(EnKujiya* this) { + this->actionFunc = EnKujiya_Wait; } -void func_80BB09BC(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_Wait(EnKujiya* this, GlobalContext* globalCtx) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { if ((gSaveContext.save.time >= CLOCK_TIME(6, 0)) && (gSaveContext.save.time < CLOCK_TIME(18, 0))) { - if (func_80BB0FF8()) { + if (EnKujiya_CheckBoughtTicket()) { Message_StartTextbox(globalCtx, 0x2B61, &this->actor); - this->unk_14A = 0x2B61; + this->textId = 0x2B61; // Come back tomorrow } else { Message_StartTextbox(globalCtx, 0x2B5C, &this->actor); - this->unk_14A = 0x2B5C; + this->textId = 0x2B5C; // Pick 3 numbers } - } else if (func_80BB0FF8()) { + } else if (EnKujiya_CheckBoughtTicket()) { Message_StartTextbox(globalCtx, 0x2B64, &this->actor); - this->unk_14A = 0x2B64; + this->textId = 0x2B64; // Announce winning numbers } else { Message_StartTextbox(globalCtx, 0x2B63, &this->actor); - this->unk_14A = 0x2B63; + this->textId = 0x2B63; // Exchanging winning tickets } - func_80BB0E44(this); - } else if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && func_80BB0FF8() && (this->actor.shape.rot.y == 0)) { - func_80BB1168(this); + + EnKujiya_SetupTalk(this); + } else if ((gSaveContext.save.time >= CLOCK_TIME(18, 0)) && EnKujiya_CheckBoughtTicket() && + (this->actor.shape.rot.y == 0)) { + EnKujiya_SetupTurnToOpen(this); } else if (this->actor.xzDistToPlayer < 100.0f) { func_800B8614(&this->actor, globalCtx, 100.0f); } } -void func_80BB0B28(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_HandlePlayerChoice(EnKujiya* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { + if (globalCtx->msgCtx.choiceIndex == 0) { // Buy if (gSaveContext.save.playerData.rupees < 10) { play_sound(NA_SE_SY_ERROR); Message_StartTextbox(globalCtx, 0x2B62, &this->actor); - this->unk_14A = 0x2B62; + this->textId = 0x2B62; // Not enough Rupees } else { func_8019F208(); func_801159EC(-10); Message_StartTextbox(globalCtx, 0x2B5F, &this->actor); - this->unk_14A = 0x2B5F; + this->textId = 0x2B5F; // Enter number } - } else { + } else { // Don't buy func_8019F230(); Message_StartTextbox(globalCtx, 0x2B5E, &this->actor); - this->unk_14A = 0x2B5E; + this->textId = 0x2B5E; // Too bad } } } -void func_80BB0BF8(EnKujiya* this, GlobalContext* globalCtx) { - u32 lotteryCode; - s8 digit1; - s8 digit2; - s8 digit3; - s8* lotteryCodes; - - if (this->unk_14A == 0x2B65) { - if (this->unk_148 != 0) { - this->unk_148--; +void EnKujiya_ChooseNextDialogue(EnKujiya* this, GlobalContext* globalCtx) { + // Build suspense + if (this->textId == 0x2B65) { // Your numbers vs winning numbers + if (this->timer != 0) { + this->timer--; return; } } if (Message_ShouldAdvance(globalCtx)) { - switch (this->unk_14A) { + switch (this->textId) { case 0x2B5C: Message_StartTextbox(globalCtx, 0x2B5D, &this->actor); - this->unk_14A = 0x2B5D; + this->textId = 0x2B5D; // Buy or not break; case 0x2B60: - func_80BB1088(); + EnKujiya_SetBoughtTicket(); func_801477B4(globalCtx); - func_80BB1250(this); + EnKujiya_SetupTurnToClosed(this); break; case 0x2B64: - func_80BB10F8(); - this->unk_148 = 0x14; + EnKujiya_UnsetBoughtTicket(); + this->timer = 20; Message_StartTextbox(globalCtx, 0x2B65, &this->actor); - this->unk_14A = 0x2B65; + this->textId = 0x2B65; // Your numbers vs winning numbers break; case 0x2B65: if (CHECK_LOTTERY_NUMBERS) { Message_StartTextbox(globalCtx, 0x2B66, &this->actor); - this->unk_14A = 0x2B66; + this->textId = 0x2B66; // Won 50 Rupees } else { Message_StartTextbox(globalCtx, 0x2B67, &this->actor); - this->unk_14A = 0x2B67; + this->textId = 0x2B67; // Lost, come back tomorrow } break; case 0x2B66: func_801477B4(globalCtx); - func_80BB0F24(this); - func_80BB0F38(this, globalCtx); + EnKujiya_SetupGivePrize(this); + EnKujiya_GivePrize(this, globalCtx); break; } } } -void func_80BB0E44(EnKujiya* this) { - this->actionFunc = func_80BB0E58; +void EnKujiya_SetupTalk(EnKujiya* this) { + this->actionFunc = EnKujiya_Talk; } -void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_Talk(EnKujiya* this, GlobalContext* globalCtx) { switch (Message_GetState(&globalCtx->msgCtx)) { case 0: break; case 4: - func_80BB0B28(this, globalCtx); + EnKujiya_HandlePlayerChoice(this, globalCtx); break; case 5: - func_80BB0BF8(this, globalCtx); + EnKujiya_ChooseNextDialogue(this, globalCtx); break; case 6: if (Message_ShouldAdvance(globalCtx)) { - func_80BB09A8(this); + EnKujiya_SetupWait(this); } break; @@ -205,35 +204,35 @@ void func_80BB0E58(EnKujiya* this, GlobalContext* globalCtx) { if (Message_ShouldAdvance(globalCtx)) { Inventory_SaveLotteryCodeGuess(globalCtx); Message_StartTextbox(globalCtx, 0x2B60, &this->actor); - this->unk_14A = 0x2B60; + this->textId = 0x2B60; // Will announce winning numbers after 6 } break; } } -void func_80BB0F24(EnKujiya* this) { - this->actionFunc = func_80BB0F38; +void EnKujiya_SetupGivePrize(EnKujiya* this) { + this->actionFunc = EnKujiya_GivePrize; } -void func_80BB0F38(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_GivePrize(EnKujiya* this, GlobalContext* globalCtx) { if (Actor_HasParent(&this->actor, globalCtx)) { - func_80BB0F94(this); + EnKujiya_SetupFinishGivePrize(this); } else { Actor_PickUp(&this->actor, globalCtx, GI_RUPEE_PURPLE, 500.0f, 100.0f); } } -void func_80BB0F94(EnKujiya* this) { - this->actionFunc = func_80BB0FA8; +void EnKujiya_SetupFinishGivePrize(EnKujiya* this) { + this->actionFunc = EnKujiya_FinishGivePrize; } -void func_80BB0FA8(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_FinishGivePrize(EnKujiya* this, GlobalContext* globalCtx) { if ((Message_GetState(&globalCtx->msgCtx) == 6) && Message_ShouldAdvance(globalCtx)) { - func_80BB09A8(this); + EnKujiya_SetupWait(this); } } -s32 func_80BB0FF8(void) { +s32 EnKujiya_CheckBoughtTicket(void) { switch (CURRENT_DAY) { case 1: if (gSaveContext.save.weekEventReg[33] & 0x10) { @@ -256,7 +255,7 @@ s32 func_80BB0FF8(void) { return false; } -void func_80BB1088(void) { +void EnKujiya_SetBoughtTicket(void) { switch (CURRENT_DAY) { case 1: gSaveContext.save.weekEventReg[33] |= 0x10; @@ -272,7 +271,10 @@ void func_80BB1088(void) { } } -void func_80BB10F8(void) { +/** + * Used when player turns in a ticket + */ +void EnKujiya_UnsetBoughtTicket(void) { switch (CURRENT_DAY) { case 1: gSaveContext.save.weekEventReg[33] &= (u8)~0x10; @@ -288,12 +290,12 @@ void func_80BB10F8(void) { } } -void func_80BB1168(EnKujiya* this) { - this->unk_148 = 0; - this->actionFunc = func_80BB1180; +void EnKujiya_SetupTurnToOpen(EnKujiya* this) { + this->timer = 0; + this->actionFunc = EnKujiya_TurnToOpen; } -void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_TurnToOpen(EnKujiya* this, GlobalContext* globalCtx) { if (this->actor.cutscene != -1) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); @@ -303,25 +305,25 @@ void func_80BB1180(EnKujiya* this, GlobalContext* globalCtx) { } if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0x7555, 0xA, 0x16C, 0x16C)) { - if (this->unk_148 > 20) { + if (this->timer > 20) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); } - func_80BB09A8(this); + EnKujiya_SetupWait(this); } else { - this->unk_148++; + this->timer++; } } else { func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); } } -void func_80BB1250(EnKujiya* this) { - this->unk_148 = 0; - this->actionFunc = func_80BB1268; +void EnKujiya_SetupTurnToClosed(EnKujiya* this) { + this->timer = 0; + this->actionFunc = EnKujiya_TurnToClosed; } -void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx) { +void EnKujiya_TurnToClosed(EnKujiya* this, GlobalContext* globalCtx) { if (this->actor.cutscene != -1) { if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { ActorCutscene_StartAndSetUnkLinkFields(this->actor.cutscene, &this->actor); @@ -331,13 +333,13 @@ void func_80BB1268(EnKujiya* this, GlobalContext* globalCtx) { } if (!Math_SmoothStepToS(&this->actor.shape.rot.y, 0, 0xA, 0x16C, 0x16C)) { - if (this->unk_148 > 20) { + if (this->timer > 20) { if (ActorCutscene_GetCurrentIndex() == this->actor.cutscene) { ActorCutscene_Stop(this->actor.cutscene); } - func_80BB09A8(this); + EnKujiya_SetupWait(this); } else { - this->unk_148++; + this->timer++; } } else { func_800B9010(&this->actor, NA_SE_EV_WINDMILL_LEVEL - SFX_FLAG); @@ -353,23 +355,23 @@ void EnKujiya_Update(Actor* thisx, GlobalContext* globalCtx) { void EnKujiya_Draw(Actor* thisx, GlobalContext* globalCtx) { EnKujiya* this = THIS; - AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(object_kujiya_Matanimheader_006198)); + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(gLotteryShopTexAnim)); OPEN_DISPS(globalCtx->state.gfxCtx); func_8012C28C(globalCtx->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_002A80); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003030); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003248); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003358); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0034A8); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0035B8); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0036B0); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_0037C0); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003C80); - gSPDisplayList(POLY_OPA_DISP++, object_kujiya_DL_003D58); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopCylinderDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopBackSignDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopOpenBoxDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingEffectsDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopRedRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopGreenRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopBlueRupeesDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopTargetArrowAndSignDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopScrollingArrowDL); + gSPDisplayList(POLY_OPA_DISP++, gLotteryShopMaskDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h index bfb50e5afb..b95a5bb366 100644 --- a/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h +++ b/src/overlays/actors/ovl_En_Kujiya/z_en_kujiya.h @@ -10,8 +10,8 @@ typedef void (*EnKujiyaActionFunc)(struct EnKujiya*, GlobalContext*); typedef struct EnKujiya { /* 0x000 */ Actor actor; /* 0x144 */ EnKujiyaActionFunc actionFunc; - /* 0x148 */ s16 unk_148; - /* 0x14A */ s16 unk_14A; + /* 0x148 */ s16 timer; + /* 0x14A */ s16 textId; } EnKujiya; // size = 0x14C extern const ActorInit En_Kujiya_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a9893775d9..d1bc43e784 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15274,23 +15274,23 @@ 0x80BB03E8:("EnZod_Draw",), 0x80BB08E0:("EnKujiya_Init",), 0x80BB0998:("EnKujiya_Destroy",), - 0x80BB09A8:("func_80BB09A8",), - 0x80BB09BC:("func_80BB09BC",), - 0x80BB0B28:("func_80BB0B28",), - 0x80BB0BF8:("func_80BB0BF8",), - 0x80BB0E44:("func_80BB0E44",), - 0x80BB0E58:("func_80BB0E58",), - 0x80BB0F24:("func_80BB0F24",), - 0x80BB0F38:("func_80BB0F38",), - 0x80BB0F94:("func_80BB0F94",), - 0x80BB0FA8:("func_80BB0FA8",), - 0x80BB0FF8:("func_80BB0FF8",), - 0x80BB1088:("func_80BB1088",), - 0x80BB10F8:("func_80BB10F8",), - 0x80BB1168:("func_80BB1168",), - 0x80BB1180:("func_80BB1180",), - 0x80BB1250:("func_80BB1250",), - 0x80BB1268:("func_80BB1268",), + 0x80BB09A8:("EnKujiya_SetupWait",), + 0x80BB09BC:("EnKujiya_Wait",), + 0x80BB0B28:("EnKujiya_HandlePlayerChoice",), + 0x80BB0BF8:("EnKujiya_ChooseNextDialogue",), + 0x80BB0E44:("EnKujiya_SetupTalk",), + 0x80BB0E58:("EnKujiya_Talk",), + 0x80BB0F24:("EnKujiya_SetupGivePrize",), + 0x80BB0F38:("EnKujiya_GivePrize",), + 0x80BB0F94:("EnKujiya_SetupFinishGivePrize",), + 0x80BB0FA8:("EnKujiya_FinishGivePrize",), + 0x80BB0FF8:("EnKujiya_CheckBoughtTicket",), + 0x80BB1088:("EnKujiya_SetBoughtTicket",), + 0x80BB10F8:("EnKujiya_UnsetBoughtTicket",), + 0x80BB1168:("EnKujiya_SetupTurnToOpen",), + 0x80BB1180:("EnKujiya_TurnToOpen",), + 0x80BB1250:("EnKujiya_SetupTurnToClosed",), + 0x80BB1268:("EnKujiya_TurnToClosed",), 0x80BB1338:("EnKujiya_Update",), 0x80BB135C:("EnKujiya_Draw",), 0x80BB16D0:("func_80BB16D0",),