SaveFile cleanup part 1

This commit is contained in:
Henny022p 2023-08-02 20:50:18 +02:00
parent 064bc43e78
commit bc22015987
28 changed files with 160 additions and 117 deletions

View File

@ -145,4 +145,11 @@ union SplitHWord {
/* forward decls */
struct Entity_;
/**
* bitset macros
*/
#define BIT(bit) (1 << (bit))
#define IS_BIT_SET(value, bit) ((value) & BIT(bit))
#endif // GLOBAL_H

View File

@ -133,7 +133,7 @@ typedef struct {
/* 0x04 */ s16 start_pos_x;
/* 0x06 */ s16 start_pos_y;
/* 0x08 */ u8 layer;
/* 0x09 */ u8 field_0x15;
/* 0x09 */ u8 filler9;
/* 0x0a */ u8 dungeon_area;
/* 0x0b */ u8 dungeon_room;
/* 0x0c */ s16 dungeon_x;
@ -142,7 +142,7 @@ typedef struct {
/* 0x12 */ u16 dungeon_map_y;
/* 0x14 */ u16 overworld_map_x;
/* 0x16 */ u16 overworld_map_y;
/* 0x18 */ u8 field_0x24[8];
/* 0x18 */ u8 filler18[8];
} PlayerRoomStatus;
static_assert(sizeof(PlayerRoomStatus) == 0x20);
@ -155,7 +155,14 @@ typedef struct {
/* 0x0a */ u16 stairs_idx; // seems to be a tile type
/* 0x0c */ PlayerRoomStatus player_status;
/* 0x2c */ u8 entity_update_type; // differentiates entity priority on kinstone menu?
/* 0x2d */ u8 field_0x2c[0x8];
/* 0x2d */ u8 field2d;
/* 0x2e */ u8 location;
/* 0x2f */ u8 field2f;
/* 0x30 */ u8 field30;
/* 0x31 */ u8 field31;
/* 0x32 */ u8 field32;
/* 0x33 */ u8 field33;
/* 0x34 */ u8 hint_heightEU;
/* 0x35 */ u8 hint_height;
/* 0x36 */ u16 hint_idx;
/* 0x38 */ u8 field_0x38;

View File

@ -33,25 +33,27 @@ extern SaveResult HandleSave(u32 idx);
* The contents of this structure are read from and written to EEPROM.
*/
typedef struct {
/*0x000*/ u8 invalid; /**< File is invalid. */
/*0x001*/ u8 initialized; /**< File is initialized. */
/*0x002*/ u8 msg_speed; /**< Message speed. */
/*0x003*/ u8 brightness; /**< Brightness. */
/*0x004*/ u8 filler4[0x2];
/*0x006*/ u8 saw_staffroll;
/*0x007*/ u8 unk7; // TODO rolling barrel state?
/*0x008*/ u8 global_progress; /**< @see UpdateGlobalProgress */
/*0x009*/ u8 field_0x9[0x17];
/*0x020*/ u16 field_0x20;
/*0x022*/ u8 field_0x22[0x1e];
/*0x040*/ u32 windcrests; /**< Windcrest flags. */
/*0x044*/ u8 filler44[0xC];
/*0x050*/ u32 unk50;
/*0x054*/ u8 filler54[0x8];
/*0x05C*/ u32 unk5C;
/*0x060*/ u32 areaVisitFlags[8]; /**< Area visit flags. */
/*0x080*/ char name[FILENAME_LENGTH]; /**< Save file name. */
/*0x086*/ u8 filler86[0x2];
/*0x000*/ u8 invalid; /**< File is invalid. */
/*0x001*/ u8 initialized; /**< File is initialized. */
/*0x002*/ u8 msg_speed; /**< Message speed. */
/*0x003*/ u8 brightness; /**< Brightness. */
/*0x004*/ u8 filler4[0x2]; /**< unused filler */
/*0x006*/ u8 saw_staffroll; /**< beat the game and watched the credits */
/*0x007*/ u8 dws_barrel_state; /**< state of the big barrel in DWS, 0 or 2 */
/*0x008*/ u8 global_progress; /**< @see UpdateGlobalProgress */
/*0x009*/ u8 available_figurines; /**< figurines available to get */
/*0x00A*/ u8 fillerA[0x16]; /**< unused filler */
/*0x020*/ u16 map_hints; /**< bitmask, used by subtask MapHint */
/*0x022*/ u8 filler22[0x1e]; /**< unused filler */
/*0x040*/ u32 windcrests; /**< upper 8 bit Windcrest flags @see WindcrestID
* lower bits used for other things */
/*0x044*/ u8 filler44[0xC]; /**< unused filler */
/*0x050*/ u32 enemies_killed; /**< number of enemies killed */
/*0x054*/ u8 filler54[0x8]; /**< unused filler */
/*0x05C*/ u32 items_bought; /**< number of items bought in stockwells shop */
/*0x060*/ u32 areaVisitFlags[8]; /**< Area visit flags. */
/*0x080*/ char name[FILENAME_LENGTH]; /**< Save file name. */
/*0x086*/ u8 filler86[0x2]; /**< unused filler */
/*0x088*/ PlayerRoomStatus saved_status; /**< Player room status. */
/*0x0A8*/ Stats stats; /**< Player stats. */
/*0x0D0*/ u8 fillerD0[34];

15
include/windcrest.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef SAVEFILE_WINDCREST_H
#define SAVEFILE_WINDCREST_H
typedef enum WindcrestID {
WINDCREST_MT_CRENEL = 24,
WINDCREST_VEIL_FALLS,
WINDCREST_CLOUD_TOPS,
WINDCREST_HYRULE_TOWN,
WINDCREST_LAKE_HYLIA,
WINDCREST_CASTOR_WILDS,
WINDCREST_SOUTH_HYRULE_FIELD,
WINDCREST_MINISH_WOODS,
} WindcrestID;
#endif // SAVEFILE_WINDCREST_H

View File

@ -53,7 +53,7 @@ void CopyOAM(void) {
void DrawEntities(void) {
void (*fn)(void);
gOAMControls._0[6] = gRoomTransition.field_0x2c[2] ? 15 : 0;
gOAMControls._0[6] = gRoomTransition.field2f ? 15 : 0;
gOAMControls._4 = gRoomControls.aff_x + gRoomControls.scroll_x;
gOAMControls._6 = gRoomControls.aff_y + gRoomControls.scroll_y;
gOAMControls.field_0x1++;

View File

@ -1024,7 +1024,7 @@ void sub_0801AE44(bool32 loadGfx) {
}
sub_080809D4();
UpdateIsDiggingCave();
if (gRoomTransition.field_0x2c[0] != 0) {
if (gRoomTransition.field2d != 0) {
sub_0807C898();
}
if (gArea.lightType != 0) {
@ -1061,7 +1061,7 @@ void SetMultipleTiles(const TileData* tileData, u32 basePosition, u32 layer) {
// Add a new entry at the end of gUnk_0200B240
void sub_0801AF48(u32 data, u32 position, u32 layer) {
u32 index;
if ((data < 0x4000) && (gRoomTransition.field_0x2c[3] == 0)) {
if ((data < 0x4000) && (gRoomTransition.field30 == 0)) {
index = gRoomVars.unk_0e;
if (index < 0x100) {
gUnk_0200B240[index].data = data;

View File

@ -183,7 +183,7 @@ u32 ConvInputToState(u32 keys) {
}
void sub_0805EE88(void) {
if ((gRoomTransition.field_0x2c[2] != 0) && ((gRoomTransition.frameCount & 3) == 0)) {
if ((gRoomTransition.field2f != 0) && ((gRoomTransition.frameCount & 3) == 0)) {
LoadPaletteGroup((((u32)gRoomTransition.frameCount & 0xc) >> 2) + 0x2f);
}
}

View File

@ -54,7 +54,7 @@ void sub_0801D000(u32 a1) {
tmp = 0;
}
roomTransition->field_0x2c[2] = tmp;
roomTransition->field2f = tmp;
if (a1) {
CleanUpObjPalettes();
sub_0801CFD0(0xf);

View File

@ -192,7 +192,7 @@ void CreateDeathFx(GenericEntity* parent, u32 parentId, u32 fixedItem) {
int tmp = parent->base.gustJarState & 2;
if (tmp == 0) {
sub_08049CF4(&(parent->base));
gSave.unk50++;
gSave.enemies_killed++;
parent->base.gustJarState |= 2;
parent->base.timer = 255;
SetDefaultPriority(&(parent->base), 3);

View File

@ -229,7 +229,7 @@ static void GameMain_ChangeRoom(void) {
sub_0801855C();
}
#elif defined(DEMO_JP)
if (gRoomTransition.field_0x2c[4])
if (gRoomTransition.field31)
CheckAreaDiscovery();
if (gArea.unk28.textBaseIndex != 0xff) {
sub_0801855C();

View File

@ -449,15 +449,17 @@ void DisplayEzloMessage(void) {
u32 height;
u32 idx;
#if defined(JP) || defined(EU)
idx = 0x10;
if (gRoomTransition.hint_heightEU == 0) {
#else
idx = 0x11;
if (gRoomTransition.hint_height == 0) {
#endif
if (gRoomTransition.player_status.field_0x24[idx] == 0) {
height = gPlayerEntity.y.HALF.HI - gRoomControls.scroll_y > 96 ? 1 : 13;
} else {
height = gRoomTransition.player_status.field_0x24[idx];
#if defined(JP) || defined(EU)
height = gRoomTransition.hint_heightEU;
#else
height = gRoomTransition.hint_height;
#endif
}
MessageAtHeight(gRoomTransition.hint_idx, height);
}
@ -466,11 +468,11 @@ void DisplayEzloMessage(void) {
void CreateMiscManager(void) {
Entity* e = NULL;
if (gRoomTransition.player_status.field_0x24[13])
if (gRoomTransition.field31)
return;
gRoomTransition.player_status.field_0x24[13] = 1;
gRoomTransition.field31 = 1;
#ifndef DEMO_JP
gRoomTransition.player_status.field_0x24[10] = gArea.locationIndex;
gRoomTransition.location = gArea.locationIndex;
#endif
e = (Entity*)GetEmptyManager();
if (e == NULL)
@ -714,7 +716,7 @@ u32 sub_08053144(void) {
return 0;
ret = 0;
if (gArea.locationIndex != 0)
ret = !!(gRoomTransition.player_status.field_0x24[10] ^ gArea.locationIndex);
ret = !!(gRoomTransition.location ^ gArea.locationIndex);
return ret;
}
@ -722,7 +724,7 @@ void CheckAreaDiscovery(void) {
if (!sub_08053144())
return;
gRoomTransition.player_status.field_0x24[10] = gArea.locationIndex;
gRoomTransition.location = gArea.locationIndex;
if (!CheckGlobalFlag(TABIDACHI))
return;
@ -772,7 +774,7 @@ void sub_0805329C(void) {
if (sub_08053144()) {
switch (gRoomControls.area) {
case AREA_DEEPWOOD_SHRINE:
gSave.unk7 = 0;
gSave.dws_barrel_state = 0;
break;
case AREA_CAVE_OF_FLAMES:
sub_080530B0();

View File

@ -24,30 +24,30 @@ void sub_08077534(ItemBehavior* this, u32 index) {
sub_08077BB8(this);
this->priority |= 0xf;
tmp = this->behaviorId;
this->timer = gSave.filler86[tmp + 0x14];
this->timer = gSave.stats.bottles[tmp - ITEM_BOTTLE1];
switch (this->timer) {
case 0x20:
case ITEM_BOTTLE_EMPTY:
SetItemAnim(this, 0x614);
return;
case 0x21:
case 0x22:
case 0x23:
case 0x24:
case 0x25:
case 0x29:
case 0x2a:
case 0x2b:
case 0x2c:
case 0x2d:
case 0x2e:
case ITEM_BOTTLE_BUTTER:
case ITEM_BOTTLE_MILK:
case ITEM_BOTTLE_HALF_MILK:
case ITEM_BOTTLE_RED_POTION:
case ITEM_BOTTLE_BLUE_POTION:
case ITEM_BOTTLE_PICOLYTE_RED:
case ITEM_BOTTLE_PICOLYTE_ORANGE:
case ITEM_BOTTLE_PICOLYTE_YELLOW:
case ITEM_BOTTLE_PICOLYTE_GREEN:
case ITEM_BOTTLE_PICOLYTE_BLUE:
case ITEM_BOTTLE_PICOLYTE_WHITE:
this->stateID = 3;
gPlayerEntity.animationState = 4;
gPlayerEntity.spriteSettings.flipX = 0;
SetItemAnim(this, 0x2df);
break;
case 0x2f:
case 0x30:
case 0x31:
case BOTTLE_CHARM_NAYRU:
case BOTTLE_CHARM_FARORE:
case BOTTLE_CHARM_DIN:
default:
this->stateID = 3;
SetItemAnim(this, 0x610);

View File

@ -385,7 +385,7 @@ void sub_08054524(void) {
bVar1 = gArea.locationIndex;
if (gArea.locationIndex == 0) {
bVar1 = gRoomTransition.player_status.field_0x24[0xa];
bVar1 = gRoomTransition.location;
}
if (bVar1 > 0x16) {
bVar1 = 0;

View File

@ -180,8 +180,7 @@ void GenerateAreaHint(void) {
gPlayerState.queued_action = PLAYER_TALKEZLO;
#if defined(EU) || defined(JP)
// TODO what fields of the room transition are switched in these variants?
gRoomTransition.field_0x2c[7] = 0;
gRoomTransition.hint_heightEU = 0;
#else
gRoomTransition.hint_height = 0;
#endif

View File

@ -192,7 +192,7 @@ void sub_08058B5C(RollingBarrelManager* this, u32 unk1) {
gRoomTransition.player_status.start_anim = unk1 & 1 ? 4 : 0;
gRoomTransition.player_status.start_pos_x = gUnk_081082E8[unk1 * 3];
gRoomTransition.player_status.start_pos_y = gUnk_081082E8[unk1 * 3 + 1];
gSave.unk7 = gUnk_081082E8[unk1 * 3 + 2];
gSave.dws_barrel_state = gUnk_081082E8[unk1 * 3 + 2];
SoundReq(SFX_STAIRS);
}

View File

@ -431,7 +431,7 @@ void PauseMenu_ItemMenu_Update(void) {
case MENU_SLOT_BOTTLE2:
case MENU_SLOT_BOTTLE3:
if (item != 0) {
item = gSave.saved_status.field_0x24[item - 6];
item = gSave.stats.bottles[item - ITEM_BOTTLE1];
}
break;
case MENU_SLOT_SAVE_BUTTON:
@ -1232,7 +1232,7 @@ bool32 sub_080A5F24(void) {
return result;
}
void sub_080A5F48(u32 param_1, u32 param_2) {
void sub_080A5F48(Item item, u32 param_2) {
extern u32 gSprite_082E68F4[];
u32 ammoCount;
u32 tensDigit;
@ -1242,19 +1242,24 @@ void sub_080A5F48(u32 param_1, u32 param_2) {
u32 temp3;
register u32 rem asm("r1");
switch (param_1) {
case 0x1c ... 0x1f:
param_1 = (u32)gSave.saved_status.field_0x24[param_1 - 6];
switch (item) {
case ITEM_BOTTLE1:
case ITEM_BOTTLE2:
case ITEM_BOTTLE3:
case ITEM_BOTTLE4:
item = gSave.stats.bottles[item - ITEM_BOTTLE1];
break;
default:
break;
}
temp1 = param_2 * 0x20 + 0x6010000;
temp3 = gSpriteAnimations_322[param_1]->index;
temp3 = gSpriteAnimations_322[item]->index;
temp2 = &gMoreSpritePtrs[1][temp3 * 2];
DmaCopy32(3, &gMoreSpritePtrs[2][temp2[1] * 0x10], temp1, 0x40 * 4);
ammoCount = -1;
switch (param_1) {
switch (item) {
case 7:
case 8:
ammoCount = gSave.stats.bombCount;
@ -1267,12 +1272,12 @@ void sub_080A5F48(u32 param_1, u32 param_2) {
if (-1 < (int)ammoCount) {
tensDigit = Div(ammoCount, 10);
param_1 = rem;
item = rem;
if ((int)tensDigit >= 10) {
tensDigit = 9;
}
DmaCopy32(3, gUnk_085C4620 + tensDigit * 0x8, temp1, 0x8 * 4);
DmaCopy32(3, gUnk_085C4620 + (param_1 + 10) * 0x8, temp1 + 0x20, 0x8 * 4);
DmaCopy32(3, gUnk_085C4620 + (item + 10) * 0x8, temp1 + 0x20, 0x8 * 4);
}
}
@ -1431,7 +1436,7 @@ void sub_080A62E0(void) {
switch (gInput.newKeys) {
case A_BUTTON:
if ((gSave.windcrests & (1 << gMenu.field_0x3)) != 0) {
if (IS_BIT_SET(gSave.windcrests, gMenu.field_0x3)) {
SoundReq(SFX_TEXTBOX_SELECT);
sub_080A4E84(6);
windcrest = -1;
@ -1495,7 +1500,7 @@ void sub_080A6438(void) {
gOamCmd._4 = 0x400;
gOamCmd._6 = 0;
gOamCmd._8 = 0;
uVar1 = gSave.field_0x20 & gGenericMenu.unk10.h[0];
uVar1 = gSave.map_hints & gGenericMenu.unk10.h[0];
for (pcVar2 = gUnk_08128F58, uVar3 = 0; pcVar2->frameIndex != 0; uVar3++, pcVar2++) {
if ((1 << uVar3 & uVar1) != 0) {
gOamCmd.x = pcVar2->unk1;
@ -1512,7 +1517,7 @@ void sub_080A6498(void) {
gOamCmd._6 = 0;
gOamCmd._8 = 0;
for (i = 0; i <= 0x10; i++) {
if ((gSave.windcrests & (1 << i)) == 0) {
if (!IS_BIT_SET(gSave.windcrests, i)) {
gUnk_08128DE8_struct* ptr = &gUnk_08128DE8[i];
gOamCmd.x = ptr->unk6;
gOamCmd.y = ptr->unk7;

View File

@ -196,7 +196,7 @@ void sub_080A68D4(void) {
sub_080A698C(gRoomTransition.player_status.overworld_map_x, gRoomTransition.player_status.overworld_map_y,
DRAW_DIRECT_SPRITE_INDEX, iVar6 + 0x100);
uVar1 = sub_080A6F40();
uVar1 &= gSave.field_0x20;
uVar1 &= gSave.map_hints;
for (pcVar4 = gUnk_08128F58, i = 0; pcVar4->frameIndex != 0; i++, pcVar4++) {
if (((1 << i) & uVar1) != 0) {

View File

@ -706,13 +706,13 @@ void sub_08060318(void) {
}
void sub_08060340(void) {
gSave.timers[1] = gSave.unk50;
gSave.timers[1] = gSave.enemies_killed;
}
u32 sub_08060354(void) {
s32 iVar2;
iVar2 = gSave.unk50 - gSave.timers[1];
iVar2 = gSave.enemies_killed - gSave.timers[1];
if (CheckGlobalFlag(DRUG_1) == 0) {
if (4 < iVar2) {
return 0x8444;

View File

@ -251,11 +251,11 @@ void sub_08065370(Entity* this, ScriptExecutionContext* context) {
if (localFlag) {
SetLocalFlag(localFlag);
}
if (gSave.unk5C <= ~1u) {
gSave.unk5C++;
if (gSave.items_bought <= ~1u) {
gSave.items_bought++;
}
if (gSave.unk5C >= 10) {
if (gSave.items_bought >= 10) {
context->intVariable = TEXT_INDEX(TEXT_STOCKWELL, 0x11);
} else {
if (itemPrice >= 100) {

View File

@ -53,9 +53,9 @@ void sub_08088A68(BigBarrelEntity* this) {
super->spriteSettings.draw = 3;
super->updatePriority = 3;
if (CheckGlobalFlag(LV1TARU_OPEN)) {
super->frameIndex = gSave.unk7 + 1;
super->frameIndex = gSave.dws_barrel_state + 1;
} else {
super->frameIndex = gSave.unk7;
super->frameIndex = gSave.dws_barrel_state;
}
sub_08088BE0(this);
if (CheckPlayerInRegion(super->x.HALF.HI - gRoomControls.origin_x, super->y.HALF.HI - gRoomControls.origin_y,

View File

@ -474,11 +474,11 @@ void sub_080880D8(FigurineDeviceEntity* this) {
it++;
}
if (++this->unk_7b == 4) {
if (gSave.field_0x9[0] != this->unk_80) {
if (gSave.field_0x9[0] != 0) {
if (gSave.available_figurines != this->unk_80) {
if (gSave.available_figurines != 0) {
SetRoomFlag(6);
}
gSave.field_0x9[0] = this->unk_80;
gSave.available_figurines = this->unk_80;
}
if (CheckLocalFlag(SHOP07_COMPLETE) && (this->unk_80 != gSave.stats.filler[0])) {
ClearLocalFlag(SHOP07_COMPLETE);

View File

@ -1289,8 +1289,7 @@ void CreateEzloHint(u32 hintId, u32 hintHeight) {
gPlayerState.queued_action = PLAYER_TALKEZLO;
gRoomTransition.hint_idx = hintId;
#if defined(EU) || defined(JP)
// TODO what fields of the room transition are switched in these variants?
gRoomTransition.field_0x2c[7] = hintHeight;
gRoomTransition.hint_heightEU = hintHeight;
#else
gRoomTransition.hint_height = hintHeight;
#endif
@ -3509,10 +3508,10 @@ void LoadRoomGfx(void) {
MemClear(gMapBottom.mapData, sizeof(gMapBottom.mapData));
tmp = TRUE;
}
if (gRoomTransition.field_0x2c[0] == 0) {
if (gRoomTransition.field2d == 0) {
MemCopy(gMapBottom.mapData, gMapBottom.mapDataClone, sizeof(gMapBottom.mapData));
MemCopy(gMapTop.mapData, gMapTop.mapDataClone, sizeof(gMapBottom.mapData));
} else if (gRoomTransition.field_0x2c[0] == 2) {
} else if (gRoomTransition.field2d == 2) {
MemCopy(gMapBottom.mapData, gMapBottom.unkData3, 0x1000);
MemCopy(gMapBottom.mapDataClone, gMapBottom.mapData, 0x1000);
MemCopy(gMapBottom.unkData3, gMapBottom.mapDataClone, 0x1000);
@ -3844,15 +3843,15 @@ void sub_0807C810(void) {
* This function is used to create a copy of the map data for temporary cutscene changes.
*/
void CloneMapData(void) {
gRoomTransition.field_0x2c[0] = 1;
gRoomTransition.field2d = 1;
MemCopy(&gMapBottom.mapData, &gMapBottom.mapDataClone, 0x2000);
MemCopy(&gMapTop.mapData, &gMapTop.mapDataClone, 0x2000);
}
void sub_0807C898(void) {
gRoomTransition.field_0x2c[0] = 2;
gRoomTransition.field2d = 2;
LoadRoomGfx();
gRoomTransition.field_0x2c[0] = 0;
gRoomTransition.field2d = 0;
}
ASM_FUNC("asm/non_matching/playerUtils/sub_0807C8B0.inc", void sub_0807C8B0(u16* a, u32 b, u32 c))

View File

@ -13,6 +13,7 @@
#include "screen.h"
#include "screenTransitions.h"
#include "sound.h"
#include "windcrest.h"
extern u32 sub_08060354(void);
extern void sub_08057E64(void);
@ -1219,7 +1220,7 @@ void sub_StateChange_CastorWilds_Main(void) {
if (CheckKinstoneFused(KINSTONE_5B))
LoadRoomEntityList(&gUnk_080D9CC8);
if ((gSave.windcrests & 0x20000000) == 0)
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_CASTOR_WILDS))
LoadRoomEntityList(&gUnk_080D9CE8);
if (!GetInventoryValue(ITEM_PEGASUS_BOOTS))
@ -1227,7 +1228,7 @@ void sub_StateChange_CastorWilds_Main(void) {
}
void sub_unk1_CastorWilds_Main(void) {
if ((gSave.windcrests & 0x20000000) == 0)
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_CASTOR_WILDS))
LoadRoomEntityList(&gUnk_080D9CE8);
}
@ -2003,13 +2004,13 @@ u32 sub_unk3_CloudTops_House(void) {
extern EntityData gUnk_080DD364;
void sub_StateChange_CloudTops_House(void) {
if (!(gSave.windcrests & 0x4000000)) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_CLOUD_TOPS)) {
LoadRoomEntityList(&gUnk_080DD364);
}
}
void sub_unk1_CloudTops_House(void) {
if (!(gSave.windcrests & 0x4000000)) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_CLOUD_TOPS)) {
LoadRoomEntityList(&gUnk_080DD364);
}
}
@ -2187,7 +2188,7 @@ u32 sub_unk3_DeepwoodShrine_Barrel(void) {
}
void sub_StateChange_DeepwoodShrine_Barrel(void) {
switch (gSave.unk7) {
switch (gSave.dws_barrel_state) {
case 0:
default:
SetTileType(0x90, 0x20b, 1);
@ -4420,7 +4421,7 @@ void sub_StateChange_HyruleTown_0(void) {
if ((gSave.global_progress < 6) && !CheckGlobalFlag(MIZUKAKI_START)) {
LoadRoomEntityList(&gUnk_080EEA9C);
}
if ((gSave.windcrests & 0x8000000) == 0) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_HYRULE_TOWN)) {
LoadRoomEntityList(&gUnk_080EEBAC);
}
sub_0804E150();
@ -4428,7 +4429,7 @@ void sub_StateChange_HyruleTown_0(void) {
}
void sub_unk1_HyruleTown_8(void) {
if ((gSave.windcrests & 0x8000000) == 0) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_HYRULE_TOWN)) {
LoadRoomEntityList(&gUnk_080EEBAC);
}
}
@ -5207,7 +5208,7 @@ void sub_StateChange_MinishWoods_Main(void) {
if (CheckKinstoneFused(KINSTONE_4E)) {
LoadRoomEntityList(&gUnk_080F4F10);
}
if ((s32)gSave.windcrests > -1) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_MINISH_WOODS)) {
LoadRoomEntityList(&gUnk_080F4E10);
}
#ifdef DEMO_USA
@ -5217,7 +5218,7 @@ void sub_StateChange_MinishWoods_Main(void) {
}
void sub_unk1_MinishWoods_Main(void) {
if ((s32)gSave.windcrests > -1) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_MINISH_WOODS)) {
LoadRoomEntityList(&gUnk_080F4E10);
}
}
@ -5652,7 +5653,7 @@ void sub_StateChange_HyruleField_SouthHyruleField(void) {
if (!CheckGlobalFlag(TABIDACHI)) {
gArea.queued_bgm = BGM_FESTIVAL_APPROACH;
}
if ((gSave.windcrests & 0x40000000) == 0) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_SOUTH_HYRULE_FIELD)) {
LoadRoomEntityList(&gUnk_080F70D8);
}
if (gSave.global_progress > 3) {
@ -5661,7 +5662,7 @@ void sub_StateChange_HyruleField_SouthHyruleField(void) {
}
void sub_unk1_HyruleField_SouthHyruleField(void) {
if ((gSave.windcrests & 0x40000000) == 0) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_SOUTH_HYRULE_FIELD)) {
LoadRoomEntityList(&gUnk_080F70D8);
}
}
@ -6169,13 +6170,13 @@ u32 sub_unk3_VeilFalls_Main(void) {
extern EntityData gUnk_080F9304;
void sub_StateChange_VeilFalls_Main(void) {
if ((gSave.windcrests & 0x2000000) == 0) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_VEIL_FALLS)) {
LoadRoomEntityList(&gUnk_080F9304);
}
}
void sub_unk1_VeilFalls_Main(void) {
if ((gSave.windcrests & 0x2000000) == 0) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_VEIL_FALLS)) {
LoadRoomEntityList(&gUnk_080F9304);
}
}
@ -6581,7 +6582,7 @@ void sub_StateChange_MtCrenel_CaveOfFlamesEntrance(void) {
if (CheckGlobalFlag(LV2_CLEAR) && !CheckLocalFlag(LV1_CLEAR)) {
LoadRoomEntityList(&gUnk_080FAFE4);
}
if ((gSave.windcrests & 0x1000000) == 0) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_MT_CRENEL)) {
LoadRoomEntityList(&gUnk_080FB004);
}
if (GetInventoryValue(ITEM_GREEN_SWORD)) {
@ -6590,7 +6591,7 @@ void sub_StateChange_MtCrenel_CaveOfFlamesEntrance(void) {
}
void sub_unk1_MtCrenel_CaveOfFlamesEntrance(void) {
if ((gSave.windcrests & 0x1000000) == 0) {
if (!IS_BIT_SET(gSave.windcrests, WINDCREST_MT_CRENEL)) {
LoadRoomEntityList(&gUnk_080FB004);
}
}

View File

@ -13,6 +13,7 @@
#include "screen.h"
#include "subtask.h"
#include "ui.h"
#include "windcrest.h"
extern Screen gUnk_03001020;
extern u8 gPaletteBufferBackup[];
@ -61,7 +62,7 @@ void sub_080A6F6C(u32 textIndexOrPtr) {
gScreen.bg0.yOffset = 2;
}
void sub_080A6FB4(u32 param_1, u32 param_2) {
void sub_080A6FB4(WindcrestID windcrest, u32 param_2) {
extern u16 gUnk_08128FF0[];
extern Font gUnk_08128FD8;
extern Font gUnk_08128FC0;
@ -71,16 +72,20 @@ void sub_080A6FB4(u32 param_1, u32 param_2) {
textIndexOrPtr = 0;
switch (param_2) {
case 0:
if ((gSave.windcrests & (1 << param_1)) == 0)
if (!IS_BIT_SET(gSave.windcrests, windcrest))
break;
case 2:
textIndexOrPtr = gUnk_08127F94[param_1]._6;
// TODO this probably references later data with index param_1-24
textIndexOrPtr = gUnk_08127F94[windcrest]._6;
font = &gUnk_08128FC0;
break;
case 1:
textIndexOrPtr = gUnk_08128FF0[param_1];
// TODO this probably references later data with index param_1-24
textIndexOrPtr = gUnk_08128FF0[windcrest];
font = &gUnk_08128FD8;
break;
default:
break;
}
if (gGenericMenu.unk2e.HWORD != textIndexOrPtr) {
@ -211,7 +216,7 @@ void Subtask_FadeIn(void) {
MemCopy(gUnk_03000420, gUI.unk_2a8, sizeof(gUI.unk_2a8));
MemCopy(&gActiveScriptInfo, &gUI.activeScriptInfo, sizeof(ActiveScriptInfo));
sub_0805E958();
gUI.unk_d = gRoomTransition.field_0x2c[2];
gUI.unk_d = gRoomTransition.field2f;
gUI.controlMode = gPlayerState.controlMode;
gUI.currentRoomProperties = gCurrentRoomProperties;
gUI.mapBottomBgSettings = gMapBottom.bgSettings;
@ -234,7 +239,7 @@ void Subtask_Init(void) {
ResetPaletteTable(0);
gGFXSlots.unk0 = 1;
gUI.nextToLoad = 2; // Subtask_Update
gRoomTransition.field_0x2c[3] = 1;
gRoomTransition.field30 = 1;
}
}
@ -263,7 +268,7 @@ void Subtask_FadeOut(void) {
SetFadeInverted(gUI.fadeInTime);
}
gUI.nextToLoad = 4; // Subtask_Die
gRoomTransition.field_0x2c[3] = 0;
gRoomTransition.field30 = 0;
}
}

View File

@ -168,7 +168,7 @@ void sub_080A6E70(void) {
DrawDirect(DRAW_DIRECT_SPRITE_INDEX, frameIndex);
for (i = 0; i < 8; i++) {
if ((gSave.windcrests & (1 << (i + 0x18))) != 0) {
if (IS_BIT_SET(gSave.windcrests, i + 24)) {
sub_080A6EE0(i);
DrawDirect(DRAW_DIRECT_SPRITE_INDEX, 0x5c);
}

View File

@ -38,7 +38,7 @@ void Subtask_MapHint_0(void) {
gScreen.lcd.displayControl = gScreen.lcd.displayControl & 0xf7ff;
SetColor(0, gPaletteBuffer[0x51]);
val = gUnk_08128F4C[gUI.field_0x3];
gSave.field_0x20 |= val;
gSave.map_hints |= val;
gGenericMenu.unk10.h[1] = val & gGenericMenu.unk10.h[0];
gGenericMenu.unk10.h[0] = 0;
gMenu.transitionTimer = 60;

View File

@ -72,9 +72,9 @@ static const SaveFile gDemoSave = {
.msg_speed = 1,
.brightness = 1,
.global_progress = 1,
.field_0x20 = 0x1F,
.map_hints = 0x1F,
.windcrests = 0x00013780,
.unk50 = 7,
.enemies_killed = 7,
.areaVisitFlags = { 0x0114C300 },
.name = "\x97\x7f\xdd",
.saved_status = {

View File

@ -8,6 +8,7 @@
#include "player.h"
#include "area.h"
#include "game.h"
#include "item.h"
extern void sub_0805ECEC(u32, u32, u32, u32);
extern u32 sub_08000E44(u32);
@ -664,7 +665,7 @@ u32 sub_0801CC80(UIElement* element) {
u32 buttonId = (type ^ 3) != 0;
u32 itemId = gSave.stats.itemButtons[buttonId];
if (ItemIsBottle(itemId)) {
itemId = gSave.saved_status.field_0x24[itemId - 6];
itemId = gSave.stats.bottles[itemId - ITEM_BOTTLE1];
}
return itemId;
}