mirror of https://github.com/zeldaret/tmc.git
Name and organize Cucco Minigame stuff
This commit is contained in:
parent
3073318124
commit
3dd2ccc211
|
@ -16,7 +16,7 @@ script_0801015A:
|
||||||
WaitUntilTextboxCloses
|
WaitUntilTextboxCloses
|
||||||
CheckTextboxResult
|
CheckTextboxResult
|
||||||
JumpIfNot script_080101A6
|
JumpIfNot script_080101A6
|
||||||
Call sub_080A1608
|
Call CuccoMinigame_TellObjective
|
||||||
WaitUntilTextboxCloses
|
WaitUntilTextboxCloses
|
||||||
EnablePlayerControl
|
EnablePlayerControl
|
||||||
CallWithArg CuccoMinigame_Init, script_080101AC
|
CallWithArg CuccoMinigame_Init, script_080101AC
|
||||||
|
@ -25,7 +25,7 @@ script_0801015A:
|
||||||
SetRoomFlag 0x0001
|
SetRoomFlag 0x0001
|
||||||
Jump script_0801015A
|
Jump script_0801015A
|
||||||
script_0801019E:
|
script_0801019E:
|
||||||
Call sub_080A1608
|
Call CuccoMinigame_TellObjective
|
||||||
WaitUntilTextboxCloses
|
WaitUntilTextboxCloses
|
||||||
script_080101A6:
|
script_080101A6:
|
||||||
EnablePlayerControl
|
EnablePlayerControl
|
||||||
|
@ -60,14 +60,14 @@ script_080101AC:
|
||||||
SetFade4
|
SetFade4
|
||||||
WaitForFadeFinish
|
WaitForFadeFinish
|
||||||
PlayBGM
|
PlayBGM
|
||||||
Call sub_080A13B4
|
Call CuccoMinigame_Results
|
||||||
WaitUntilTextboxCloses
|
WaitUntilTextboxCloses
|
||||||
JumpIfNot script_08010240
|
JumpIfNot script_08010240
|
||||||
Call sub_080A13E8
|
Call CuccoMinigame_WinItem
|
||||||
WaitPlayerGetItem
|
WaitPlayerGetItem
|
||||||
Call sub_080A1460
|
Call CuccoMinigame_WinRupees
|
||||||
WaitUntilTextboxCloses
|
WaitUntilTextboxCloses
|
||||||
Call sub_080A14A8
|
Call CuccoMinigame_AdvanceLevel
|
||||||
script_08010240:
|
script_08010240:
|
||||||
Call EnablePauseMenu
|
Call EnablePauseMenu
|
||||||
EnablePlayerControl
|
EnablePlayerControl
|
||||||
|
|
|
@ -13,23 +13,28 @@
|
||||||
#include "npc.h"
|
#include "npc.h"
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
#include "script.h"
|
#include "script.h"
|
||||||
|
#include "item.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Entity base;
|
Entity base;
|
||||||
s16 unk68;
|
s16 timer;
|
||||||
s16 unk6a;
|
s16 currentCuccos;
|
||||||
s16 unk6c;
|
s16 targetCuccos;
|
||||||
u16 unk6e;
|
u16 unk6e;
|
||||||
u8 unk70[0x18];
|
u8 returnedCuccoTypes[0x18];
|
||||||
} CuccoMinigameEntity;
|
} CuccoMinigameEntity;
|
||||||
|
|
||||||
typedef Entity* CuccoMinigameHeap[10];
|
typedef Entity* CuccoMinigameHeap[10];
|
||||||
|
|
||||||
u32 sub_080A1514();
|
u32 CuccoMinigame_GetLevel();
|
||||||
|
|
||||||
const u16 gUnk_08124C20[] = {
|
typedef struct {
|
||||||
25, 0x2, 25, 0x3, 30, 0x4, 45, 0x5, 50, 0x5, 45, 0x5, 50, 0x6, 60, 0x7, 55, 0x2, 55, 0x3,
|
u16 time;
|
||||||
};
|
u16 numCuccos;
|
||||||
|
} CuccoMinigameGoal;
|
||||||
|
|
||||||
|
const CuccoMinigameGoal goalData[10] = { { 25, 2}, { 25, 3}, { 30, 4}, { 45, 5}, { 50, 5},
|
||||||
|
{ 45, 5}, { 50, 6}, { 60, 7}, { 55, 2}, { 55, 3} };
|
||||||
|
|
||||||
static const u16 pCuccoMinigame_MinigameCuccoDefs[][30] = {
|
static const u16 pCuccoMinigame_MinigameCuccoDefs[][30] = {
|
||||||
{ 0x0001, 0x02E9, 0x0318, 0x0001, 0x0280, 0x0380, 0x0002, 0x0277, 0x0314, 0x0001,
|
{ 0x0001, 0x02E9, 0x0318, 0x0001, 0x0280, 0x0380, 0x0002, 0x0277, 0x0314, 0x0001,
|
||||||
|
@ -66,9 +71,23 @@ static const u16 pCuccoMinigame_MinigameCuccoDefs[][30] = {
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const u8 gUnk_08124EA0[] = { 0x3F, 0x0A, 0x01, 0x00, 0x3F, 0x0A, 0x01, 0x00, 0x3F, 0x14, 0x01, 0x00, 0x3F, 0x14,
|
typedef struct {
|
||||||
0x01, 0x00, 0x3F, 0x1E, 0x01, 0x00, 0x3F, 0x1E, 0x01, 0x00, 0x5C, 0x6E, 0x01, 0x00,
|
u8 item;
|
||||||
0x5C, 0x6F, 0x01, 0x00, 0x5C, 0x70, 0x01, 0x00, 0x63, 0x00, 0x01, 0x00 };
|
u8 subtype;
|
||||||
|
u8 unk2;
|
||||||
|
u8 unk3;
|
||||||
|
} CuccoMinigamePrizeData;
|
||||||
|
|
||||||
|
static const CuccoMinigamePrizeData prizeData[10] = { { ITEM_SHELLS, 10, 1, 0 },
|
||||||
|
{ ITEM_SHELLS, 10, 1, 0 },
|
||||||
|
{ ITEM_SHELLS, 20, 1, 0 },
|
||||||
|
{ ITEM_SHELLS, 20, 1, 0 },
|
||||||
|
{ ITEM_SHELLS, 30, 1, 0 },
|
||||||
|
{ ITEM_SHELLS, 30, 1, 0 },
|
||||||
|
{ ITEM_KINSTONE, 0x6E, 1, 0 },
|
||||||
|
{ ITEM_KINSTONE, 0x6F, 1, 0 },
|
||||||
|
{ ITEM_KINSTONE, 0x70, 1, 0 },
|
||||||
|
{ ITEM_HEART_PIECE, 0, 1, 0 } };
|
||||||
|
|
||||||
static const u16 CuccoMinigame_Sounds[] = { SFX_VO_CUCCO5, SFX_VO_CUCCO_CALL };
|
static const u16 CuccoMinigame_Sounds[] = { SFX_VO_CUCCO5, SFX_VO_CUCCO_CALL };
|
||||||
|
|
||||||
|
@ -78,17 +97,17 @@ void CuccoMinigame(CuccoMinigameEntity* this) {
|
||||||
int index;
|
int index;
|
||||||
u32 val;
|
u32 val;
|
||||||
u8* puVar2;
|
u8* puVar2;
|
||||||
const u16* ptr;
|
const CuccoMinigameGoal* ptr;
|
||||||
|
|
||||||
if (super->action == 0) {
|
if (super->action == 0) {
|
||||||
super->action++;
|
super->action++;
|
||||||
ptr = gUnk_08124C20 + sub_080A1514() * 2;
|
ptr = &goalData[CuccoMinigame_GetLevel()];
|
||||||
this->unk68 = ptr[0] * 0x3c;
|
this->timer = ptr->time * 60;
|
||||||
this->unk6a = 0;
|
this->currentCuccos = 0;
|
||||||
this->unk6c = ptr[1];
|
this->targetCuccos = ptr->numCuccos;
|
||||||
this->unk6e = 1;
|
this->unk6e = 1;
|
||||||
|
|
||||||
for (puVar2 = this->unk70, val = 0, index = 9; index >= 0; index--) {
|
for (puVar2 = this->returnedCuccoTypes, val = 0, index = 9; index >= 0; index--) {
|
||||||
*puVar2++ = val;
|
*puVar2++ = val;
|
||||||
}
|
}
|
||||||
sub_0807DD64(super);
|
sub_0807DD64(super);
|
||||||
|
@ -110,7 +129,7 @@ NONMATCH("asm/non_matching/objectB9/sub_080A1270.inc", void sub_080A1270(CuccoMi
|
||||||
|
|
||||||
sVar6 = 0;
|
sVar6 = 0;
|
||||||
entArray = ((Entity**)super->myHeap);
|
entArray = ((Entity**)super->myHeap);
|
||||||
ptr = this->unk70;
|
ptr = this->returnedCuccoTypes;
|
||||||
iVar1 = (gRoomControls.origin_x + 0x360);
|
iVar1 = (gRoomControls.origin_x + 0x360);
|
||||||
iVar4 = (gRoomControls.origin_y + 0x350);
|
iVar4 = (gRoomControls.origin_y + 0x350);
|
||||||
iVar1 = (iVar1 << 16) >> 16;
|
iVar1 = (iVar1 << 16) >> 16;
|
||||||
|
@ -147,9 +166,9 @@ NONMATCH("asm/non_matching/objectB9/sub_080A1270.inc", void sub_080A1270(CuccoMi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->unk6a = sVar6;
|
this->currentCuccos = sVar6;
|
||||||
gPlayerState.field_0x27[0] = 0xff;
|
gPlayerState.field_0x27[0] = 0xff;
|
||||||
if (--this->unk68 < 1) {
|
if (--this->timer < 1) {
|
||||||
SoundReq(SFX_CUCCO_MINIGAME_BELL);
|
SoundReq(SFX_CUCCO_MINIGAME_BELL);
|
||||||
sub_08050384();
|
sub_08050384();
|
||||||
} else {
|
} else {
|
||||||
|
@ -163,7 +182,7 @@ void CuccoMinigame_Cleanup(CuccoMinigameEntity* this) {
|
||||||
s8* pcVar2;
|
s8* pcVar2;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
pcVar2 = this->unk70;
|
pcVar2 = this->returnedCuccoTypes;
|
||||||
puVar1 = super->myHeap;
|
puVar1 = super->myHeap;
|
||||||
|
|
||||||
for (index = 9; index >= 0; index--, pcVar2++, puVar1++) {
|
for (index = 9; index >= 0; index--, pcVar2++, puVar1++) {
|
||||||
|
@ -174,8 +193,8 @@ void CuccoMinigame_Cleanup(CuccoMinigameEntity* this) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_080A13B4(CuccoMinigameEntity* this, ScriptExecutionContext* context) {
|
void CuccoMinigame_Results(CuccoMinigameEntity* this, ScriptExecutionContext* context) {
|
||||||
if (this->unk6a >= this->unk6c) {
|
if (this->currentCuccos >= this->targetCuccos) {
|
||||||
MessageFromTarget(TEXT_INDEX(TEXT_ANJU, 0xc));
|
MessageFromTarget(TEXT_INDEX(TEXT_ANJU, 0xc));
|
||||||
context->condition = 1;
|
context->condition = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -184,115 +203,115 @@ void sub_080A13B4(CuccoMinigameEntity* this, ScriptExecutionContext* context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_080A13E8(CuccoMinigameEntity* this) {
|
void CuccoMinigame_WinItem(CuccoMinigameEntity* this) {
|
||||||
bool32 bVar2;
|
bool32 skipItem;
|
||||||
const u8* ptr = &gUnk_08124EA0[sub_080A1514() * 4];
|
const CuccoMinigamePrizeData* prize = &prizeData[CuccoMinigame_GetLevel()];
|
||||||
|
|
||||||
bVar2 = 0;
|
skipItem = 0;
|
||||||
switch (ptr[0]) {
|
switch (prize->item) {
|
||||||
case 0x3f:
|
case ITEM_SHELLS:
|
||||||
if (gSave.stats.hasAllFigurines) {
|
if (gSave.stats.hasAllFigurines) {
|
||||||
bVar2 = 1;
|
skipItem = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x5c:
|
case ITEM_KINSTONE:
|
||||||
if (gSave.didAllFusions) {
|
if (gSave.didAllFusions) {
|
||||||
bVar2 = 1;
|
skipItem = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x63:
|
case ITEM_HEART_PIECE:
|
||||||
if (!CheckGlobalFlag(ANJU_HEART)) {
|
if (!CheckGlobalFlag(ANJU_HEART)) {
|
||||||
SetGlobalFlag(ANJU_HEART);
|
SetGlobalFlag(ANJU_HEART);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bVar2 = 1;
|
skipItem = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bVar2) {
|
if (!skipItem) {
|
||||||
InitItemGetSequence(ptr[0], ptr[1], 0);
|
InitItemGetSequence(prize->item, prize->subtype, 0);
|
||||||
} else {
|
} else {
|
||||||
this->unk6e = 2;
|
this->unk6e = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_080A1460(CuccoMinigameEntity* this) {
|
void CuccoMinigame_WinRupees(CuccoMinigameEntity* this) {
|
||||||
s8* pcVar1;
|
s8* cuccoTypes;
|
||||||
int iVar2;
|
int index;
|
||||||
s32 rupees;
|
s32 rupees;
|
||||||
const u8* ptr;
|
const u8* rupeeValues;
|
||||||
|
|
||||||
sub_080A1514();
|
CuccoMinigame_GetLevel(); // Rupees previously dependent on level?
|
||||||
pcVar1 = this->unk70;
|
cuccoTypes = this->returnedCuccoTypes;
|
||||||
rupees = 0;
|
rupees = 0;
|
||||||
ptr = CuccoMinigameRupees;
|
rupeeValues = CuccoMinigameRupees;
|
||||||
|
|
||||||
for (iVar2 = 9; iVar2 >= 0; iVar2--) {
|
for (index = 9; index >= 0; index--) { // Only first 10 count?
|
||||||
// Weird register addition
|
// Weird register addition
|
||||||
// ptr[*pcVar1] translates to add r0,r3,r0 but should be add r0,r3
|
// rupeeValues[*cuccoTypes] translates to add r0,r3,r0 but should be add r0,r3
|
||||||
u32 temp = *pcVar1;
|
u32 temp = *cuccoTypes;
|
||||||
temp += (int)ptr;
|
temp += (int)rupeeValues;
|
||||||
rupees += *(u8*)temp;
|
rupees += *(u8*)temp;
|
||||||
pcVar1++;
|
cuccoTypes++;
|
||||||
}
|
}
|
||||||
ModRupees(rupees);
|
ModRupees(rupees);
|
||||||
MessageNoOverlap(TEXT_INDEX(TEXT_ANJU, 0x7), super);
|
MessageNoOverlap(TEXT_INDEX(TEXT_ANJU, 0x7), super);
|
||||||
gMessage.rupees = (u16)rupees;
|
gMessage.rupees = (u16)rupees;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_080A14A8(void) {
|
void CuccoMinigame_AdvanceLevel(void) {
|
||||||
int iVar1;
|
int level;
|
||||||
|
|
||||||
iVar1 = sub_080A1514();
|
level = CuccoMinigame_GetLevel();
|
||||||
iVar1++;
|
level++;
|
||||||
if (iVar1 > 9) {
|
if (level > 9) {
|
||||||
iVar1 = 9;
|
level = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iVar1 & 1) {
|
if (level & 1) {
|
||||||
SetGlobalFlag(ANJU_LV_BIT0);
|
SetGlobalFlag(ANJU_LV_BIT0);
|
||||||
} else {
|
} else {
|
||||||
ClearGlobalFlag(ANJU_LV_BIT0);
|
ClearGlobalFlag(ANJU_LV_BIT0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iVar1 & 2) {
|
if (level & 2) {
|
||||||
SetGlobalFlag(ANJU_LV_BIT1);
|
SetGlobalFlag(ANJU_LV_BIT1);
|
||||||
} else {
|
} else {
|
||||||
ClearGlobalFlag(ANJU_LV_BIT1);
|
ClearGlobalFlag(ANJU_LV_BIT1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iVar1 & 4) {
|
if (level & 4) {
|
||||||
SetGlobalFlag(ANJU_LV_BIT2);
|
SetGlobalFlag(ANJU_LV_BIT2);
|
||||||
} else {
|
} else {
|
||||||
ClearGlobalFlag(ANJU_LV_BIT2);
|
ClearGlobalFlag(ANJU_LV_BIT2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iVar1 & 8) {
|
if (level & 8) {
|
||||||
SetGlobalFlag(ANJU_LV_BIT3);
|
SetGlobalFlag(ANJU_LV_BIT3);
|
||||||
} else {
|
} else {
|
||||||
ClearGlobalFlag(ANJU_LV_BIT3);
|
ClearGlobalFlag(ANJU_LV_BIT3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 sub_080A1514(void) {
|
u32 CuccoMinigame_GetLevel(void) {
|
||||||
u32 rv = 0;
|
u32 level = 0;
|
||||||
|
|
||||||
if (CheckGlobalFlag(ANJU_LV_BIT0)) {
|
if (CheckGlobalFlag(ANJU_LV_BIT0)) {
|
||||||
rv = 1;
|
level = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckGlobalFlag(ANJU_LV_BIT1)) {
|
if (CheckGlobalFlag(ANJU_LV_BIT1)) {
|
||||||
rv |= 2;
|
level |= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckGlobalFlag(ANJU_LV_BIT2)) {
|
if (CheckGlobalFlag(ANJU_LV_BIT2)) {
|
||||||
rv |= 4;
|
level |= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckGlobalFlag(ANJU_LV_BIT3)) {
|
if (CheckGlobalFlag(ANJU_LV_BIT3)) {
|
||||||
rv |= 8;
|
level |= 8;
|
||||||
}
|
}
|
||||||
return rv;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) {
|
void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) {
|
||||||
|
@ -311,7 +330,7 @@ void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) {
|
||||||
} else {
|
} else {
|
||||||
*(ScriptExecutionContext**)&((GenericEntity*)pEnt)->cutsceneBeh =
|
*(ScriptExecutionContext**)&((GenericEntity*)pEnt)->cutsceneBeh =
|
||||||
(ScriptExecutionContext*)StartCutscene(pEnt, (u16*)context->intVariable);
|
(ScriptExecutionContext*)StartCutscene(pEnt, (u16*)context->intVariable);
|
||||||
pCuccoMinigameDef = pCuccoMinigame_MinigameCuccoDefs[sub_080A1514()];
|
pCuccoMinigameDef = pCuccoMinigame_MinigameCuccoDefs[CuccoMinigame_GetLevel()];
|
||||||
ppEVar5 = (Entity**)pEnt->myHeap;
|
ppEVar5 = (Entity**)pEnt->myHeap;
|
||||||
room = &gRoomControls;
|
room = &gRoomControls;
|
||||||
for (index = 9; index >= 0; index--, pCuccoMinigameDef += 3) {
|
for (index = 9; index >= 0; index--, pCuccoMinigameDef += 3) {
|
||||||
|
@ -332,9 +351,9 @@ void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_080A1608(void) {
|
void CuccoMinigame_TellObjective(void) {
|
||||||
u16 messageIndex;
|
u16 messageIndex;
|
||||||
const u16* ptr;
|
const CuccoMinigameGoal* ptr;
|
||||||
|
|
||||||
messageIndex = TEXT_INDEX(TEXT_ANJU, 0x2);
|
messageIndex = TEXT_INDEX(TEXT_ANJU, 0x2);
|
||||||
if (CheckRoomFlag(1)) {
|
if (CheckRoomFlag(1)) {
|
||||||
|
@ -343,9 +362,9 @@ void sub_080A1608(void) {
|
||||||
MessageFromTarget(messageIndex);
|
MessageFromTarget(messageIndex);
|
||||||
gMessage.textWindowPosX = 1;
|
gMessage.textWindowPosX = 1;
|
||||||
gMessage.textWindowPosY = 0;
|
gMessage.textWindowPosY = 0;
|
||||||
ptr = &gUnk_08124C20[sub_080A1514() * 2];
|
ptr = &goalData[CuccoMinigame_GetLevel()];
|
||||||
gMessage.rupees = ptr[0];
|
gMessage.rupees = ptr->time;
|
||||||
gMessage.field_0x14 = ptr[1];
|
gMessage.field_0x14 = ptr->numCuccos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_080A1648(void) {
|
void sub_080A1648(void) {
|
||||||
|
|
Loading…
Reference in New Issue