Decompile goronMerchant

This commit is contained in:
octorock
2021-04-30 19:39:16 +02:00
parent 5ad4559642
commit e702bffca9
14 changed files with 94 additions and 119 deletions
+2 -2
View File
@@ -469,7 +469,7 @@ bool32 sub_0802915C(Entity* this) {
return TRUE;
break;
case 0x1c:
if (CheckGlobalFlag(0x5a) == 0)
if (CheckGlobalFlag(AKINDO_BOTTLE_SELL) == 0)
return TRUE;
break;
case 0x5c:
@@ -486,7 +486,7 @@ bool32 sub_08029198(const struct SalesOffering* offer) {
if ((offer->field_0x0 & 0xfc) != 0xc) {
switch (offer->field_0x8) {
case 0x1c:
tmp = CheckGlobalFlag(0x5a);
tmp = CheckGlobalFlag(AKINDO_BOTTLE_SELL);
break;
case 0x9:
case 0x44:
+1 -1
View File
@@ -1009,7 +1009,7 @@ void HandleFileDelete(void) {
sub_08050A64(gUnk_02019EE0.unk6);
}
void FUN_080515c8(void) {
void sub_080515c8(void) {
sub_080A7114(1);
}
+1 -1
View File
@@ -247,7 +247,7 @@ void InitializePlayer(void) {
MemClear((void*)pl, 0x88);
gRoomControls.cameraTarget = pl;
gPlayerState.playerAction = gUnk_080FCAC8[gScreenTransition.field_0xf];
if (!CheckGlobalFlag(0x14)) {
if (!CheckGlobalFlag(EZERO_1ST)) {
gPlayerState.flags.all |= 8;
}
switch (gScreenTransition.field_0xf) {
+1 -1
View File
@@ -119,7 +119,7 @@ void sub_08068AFC(Entity* this) {
sub_0807DD50(this);
}
void FUN_08068b2c(Entity* this) {
void sub_08068b2c(Entity* this) {
u32 uVar1;
if (this->interactType == '\x02') {
+78 -22
View File
@@ -6,13 +6,16 @@
#include "room.h"
#include "flags.h"
#include "script.h"
#include "save.h"
extern u32 sub_080696BC(Entity*);
extern u32 GoronMerchant_GetSalePrice(Entity*);
extern void (*const gUnk_08111B88[])(Entity*);
extern void (*const gUnk_08111B98[])(Entity*);
extern u16 gUnk_08111BA0[];
const u16 GoronMerchant_KinstonePrices[];
extern u32 sub_0801E7D0(u32);
void GoronMerchant(Entity* this) {
if ((this->flags & 2) != 0) {
@@ -78,7 +81,7 @@ void sub_08069660(Entity* this) {
u32 uVar1;
TextboxNoOverlap(0x2c1c, this);
gTextBox.field_0x10 = (u16)sub_080696BC(this);
gTextBox.field_0x10 = (u16)GoronMerchant_GetSalePrice(this);
}
void sub_08069684(void) {
@@ -98,33 +101,86 @@ void sub_080696B0(void) {
gRoomVars.itemForSaleIndex = 0;
}
u32 sub_080696BC(Entity* this) {
u32 uVar1;
u32 GoronMerchant_GetSalePrice(Entity* this) {
u32 restockCount;
u32 temp;
u32 iVar3;
s32 temp2;
u32 kinstoneType;
s32 itemForSale;
temp2 = gRoomVars.field_0x7;
if (temp2 > 0x70) {
iVar3 = 1;
itemForSale = gRoomVars.field_0x7;
if (itemForSale > 0x70) {
kinstoneType = 1;
} else {
iVar3 = 0;
kinstoneType = 0;
}
if (temp2 > 0x72) {
iVar3 = 2;
if (itemForSale > 0x72) {
kinstoneType = 2;
}
temp = CheckGlobalFlag(0x3e);
uVar1 = BOOLCAST(temp);
temp = CheckGlobalFlag(GORON_KAKERA_LV2);
restockCount = BOOLCAST(temp);
if (CheckGlobalFlag(0x3f)) {
uVar1 = 2;
if (CheckGlobalFlag(GORON_KAKERA_LV3)) {
restockCount = 2;
}
if (CheckGlobalFlag(0x40)) {
uVar1 = 3;
if (CheckGlobalFlag(GORON_KAKERA_LV4)) {
restockCount = 3;
}
if (CheckGlobalFlag(0x41)) {
uVar1 = 4;
if (CheckGlobalFlag(GORON_KAKERA_LV5)) {
restockCount = 4;
}
return gUnk_08111BA0[uVar1 * 3 + iVar3];
return GoronMerchant_KinstonePrices[restockCount * 3 + kinstoneType];
}
void GoronMerchant_TryToBuyKinstone(Entity* this, ScriptExecutionContext* context) {
s32 salePrice = GoronMerchant_GetSalePrice(this);
if (salePrice <= gSave.stats.rupees) {
if (sub_0801E7D0(gRoomVars.field_0x7) < 99) {
ModRupees(-salePrice);
sub_080A7C18(0x5c, gRoomVars.field_0x7, 0);
gRoomVars.itemForSaleIndex = 0;
gRoomVars.field_0x7 = 0;
context->condition = 1;
} else {
TextboxNoOverlap(0x2c1f, this);
context->condition = 0;
}
} else {
TextboxNoOverlap(0x2c1e, this);
context->condition = 0;
}
gActiveScriptInfo.flags = gActiveScriptInfo.flags | 1;
}
void (*const gUnk_08111B88[])(Entity*) = {
sub_08069584,
sub_080695AC,
sub_080695E8,
sub_0806961C,
};
void (*const gUnk_08111B98[])(Entity*) = {
sub_0806963C,
sub_08069654,
};
const u16 GoronMerchant_KinstonePrices[] = {
300,
200,
50,
// prices after restock 1
300,
200,
50,
// prices after restock 2
300,
200,
50,
// prices after restock 3
300,
200,
50,
// prices after restock 4
300,
200,
50,
};
+1 -1
View File
@@ -43,7 +43,7 @@ void sub_0806B260(Entity* this, ScriptExecutionContext* context) {
context->condition = 0;
// flippers
if (!GetInventoryValue(0x46)) {
if (CheckGlobalFlag(0x29)) {
if (CheckGlobalFlag(MIZUKAKI_START)) {
index = 2;
context->condition = 1;
} else if (!CheckLocalFlag(0x7a)) {
+4 -4
View File
@@ -256,7 +256,7 @@ void sub_0806AFE8(Entity* this, ScriptExecutionContext* context) {
void sub_0806B004(Entity* this, ScriptExecutionContext* context) {
int idx = 0;
if (CheckGlobalFlag(0x29)) {
if (CheckGlobalFlag(MIZUKAKI_START)) {
if (CheckLocalFlag(0x73)) {
if (GetInventoryValue(0x46) == 0) {
idx = 3;
@@ -279,7 +279,7 @@ void sub_0806B004(Entity* this, ScriptExecutionContext* context) {
void sub_0806B064(Entity* this) {
int idx = 0;
if (CheckGlobalFlag(0x29)) {
if (CheckGlobalFlag(MIZUKAKI_START)) {
idx = 1;
if (CheckLocalFlag(0x73)) {
idx = 2;
@@ -294,8 +294,8 @@ void sub_0806B098(Entity* this) {
if (GetInventoryValue(0x46) == 0) {
idx = 1;
if (CheckGlobalFlag(0x29)) {
f = CheckGlobalFlag(0x2a);
if (CheckGlobalFlag(MIZUKAKI_START)) {
f = CheckGlobalFlag(MIZUKAKI_HARIFALL);
idx = BOOLCAST(f);
}
}
+2 -2
View File
@@ -1003,13 +1003,13 @@ extern EntityData gUnk_080D9108;
extern EntityData gUnk_080D9098;
void sub_0804C018(void) {
if (!CheckGlobalFlag(0x20)) {
if (!CheckGlobalFlag(HAKA_KEY_LOST)) {
// graveyard key
if (GetInventoryValue(0x3c) == 1) {
LoadRoomEntityList(&gUnk_080D90C8);
LoadRoomEntityList(&gUnk_080D9108);
}
} else if (!CheckGlobalFlag(0x21))
} else if (!CheckGlobalFlag(HAKA_KEY_FOUND))
LoadRoomEntityList(&gUnk_080D9108);
if (GetInventoryValue(0x3c) != 2) {