z_sram_NES with 2 NON_MATCHINGs and 1 NON_EQUIVALENTs (#531)

* Rename Sram_InitDebugSave

* Sram_InitDebugSave

* err

* Sram_IncrementDay

* non_matchings

* func_80146F5C and protos

* func_80146EE8

* func_80145698

* func_80143A54

* Split SaveContext

* problems with bss

* Fix bss

* more

* a small bunch

* Fix warnings

* almost everything

* two attempts

* at least compiles

* import data

* bss

* format

* stuff?

* Progress?

* More progress

* clean up data a little

* More progress

* disaster

* re split data

* A bit less of a disaster

* Fix renamed stuff

* data stuff

* fix conflicts

* format

* CycleSceneFlags

* some enums

* cleanup

* Fix merge issues

* format

* some changes

* format

* Lots of progress on z_sram_NES, but no matches yet

* SaveContent Documentation

* Oops

* Oops2

* Document more SaveContext

* Oops, don't need that anymore

* add small comment

* Another comment

* dekuPlaygroundPlayerName

* Fix merge issues

* format

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* remove magic number

* format

* fix merge issues

* bss

* format

* macro cleanup

* review

* merge issues

* review

* cleanup

* UNK_TYPE1

* Fix

* Remove comment

* small change

* conflicts

* review

* fix

* fixes

* format

* Update actorCtx renames part

* Match func_80143B0C thanks to Petrie and Anon

* minor cleaning pass

* format

* cleanup

* more minor cleanups

* Macros for accessing gSaveContext.save.stolenItems

* Introduce STOLEN_ITEM_NONE and remove CLEAR_STOLEN_ITEM_

* format

* Update include/macros.h

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* Update src/code/z_sram_NES.c

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* Update src/code/z_sram_NES.c

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* Update src/code/z_sram_NES.c

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* Update src/code/z_sram_NES.c

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* Update src/code/z_sram_NES.c

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* Update src/code/z_sram_NES.c

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* Update src/code/z_sram_NES.c

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* @hensldm review

* Update include/functions.h

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update include/functions.h

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Rename QUEST_SONG_NEW_WAVE

* Add scene name comments to D_801C5FC0

* rename horseData.yaw

* Update include/functions.h

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Update src/code/z_sram_NES.c

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* // = CUR_UPG_VALUE(UPG_WALLET);

* run actorfixer and format

* fix bss

* Fix merge problems and run format

* Some improvements to func_801457CC by anon

* bss

* format

* run actorfixer

* actorfixer, bss and format

* Use original names for the RESPAWN_MODE enum because the current ones are bad

* QUEST_SONG_BOSSA_NOVA

* some minor fixes on the SaveContext struct according to the debug rom

* Merge Inventory.items and Inventory.masks

* a

* simplify saveBuf accesses

* A few func renames

* actorfixer

* bss

* fixes

* bss

* actorfixer

* actorfixer and format

* actorfixer

* whoops

* whops

* bss

Co-authored-by: engineer124 <engineer124engineer124@gmail.com>
Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
This commit is contained in:
Anghelo Carvajal
2022-03-27 12:37:02 -03:00
committed by GitHub
parent 95c6ddbcc8
commit b08880f7a7
201 changed files with 4584 additions and 2880 deletions
+21 -21
View File
@@ -81,7 +81,7 @@ void EnMs_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void func_80952734(EnMs* this, GlobalContext* globalCtx) {
s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y;
if (gSaveContext.inventory.items[10] == ITEM_NONE) {
if (gSaveContext.save.inventory.items[10] == ITEM_NONE) {
this->actor.textId = 0x92E;
} else {
this->actor.textId = 0x932;
@@ -187,12 +187,12 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
return;
}
func_801477B4(globalCtx);
if ((s32) gSaveContext.rupees < 0xA) {
if ((s32) gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
return;
}
if ((s32) gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
return;
@@ -275,14 +275,14 @@ block_7:
goto block_16;
block_11:
func_801477B4(globalCtx);
if ((s32) gSaveContext.rupees >= 0xA) {
if ((s32) gSaveContext.save.playerData.rupees >= 0xA) {
goto block_13;
}
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
return;
block_13:
if ((s32) gSaveContext.inventory.ammo[gItemSlots[0xA]] < 0x14) {
if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] < 0x14) {
goto block_15;
}
play_sound(0x4806U);
@@ -312,7 +312,7 @@ which in many ways looks worse: you can see why the use of gotos in code is stro
The simplest sort of block label to eliminate is one that is only used once, and where the corresponding goto jumps over a simple block of code with no extra internal control flow structure. There are two obvious examples of this here, the first being
```C
if ((s32) gSaveContext.rupees >= 0xA) {
if ((s32) gSaveContext.save.playerData.rupees >= 0xA) {
goto block_13;
}
play_sound(0x4806U);
@@ -324,7 +324,7 @@ block_13:
Currently, this says to jump over the code block `play_sound...` if the condition in the if is satisfied. In non-goto terms, this means that the block should be run if the condition is *not* satisfied. This also illustrates a general property of goto-only mode: you have to reverse the senses of all of the ifs. Therefore the appropriate approach is to swap the if round, put the code block inside, and remove the goto and the label:
```C
if (gSaveContext.rupees < 0xA) {
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
return;
@@ -378,12 +378,12 @@ block_7:
block_11:
func_801477B4(globalCtx);
if (gSaveContext.rupees < 0xA) {
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
return;
}
if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
return;
@@ -448,12 +448,12 @@ block_7:
block_11:
func_801477B4(globalCtx);
if (gSaveContext.rupees < 0xA) {
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
return;
}
if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
return;
@@ -497,12 +497,12 @@ So let us rewrite the entire second half as a switch:
case 0:
func_801477B4(globalCtx);
if (gSaveContext.rupees < 0xA) {
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
return;
}
if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
return;
@@ -532,10 +532,10 @@ There's a couple of other obvious things here:
case 0:
func_801477B4(globalCtx);
if (gSaveContext.rupees < 0xA) {
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
} else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
} else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
} else {
@@ -597,10 +597,10 @@ block_7:
case 0:
func_801477B4(globalCtx);
if (gSaveContext.rupees < 0xA) {
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
} else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
} else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
} else {
@@ -661,10 +661,10 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
case 0:
func_801477B4(globalCtx);
if (gSaveContext.rupees < 0xA) {
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
} else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
} else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
} else {
@@ -713,10 +713,10 @@ void func_809527F8(EnMs *this, GlobalContext *globalCtx) {
case 0:
func_801477B4(globalCtx);
if (gSaveContext.rupees < 0xA) {
if (gSaveContext.save.playerData.rupees < 0xA) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x935U);
} else if (gSaveContext.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
} else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) {
play_sound(0x4806U);
func_80151938(globalCtx, 0x937U);
} else {
+3 -3
View File
@@ -182,12 +182,12 @@ void func_80C102D4(EnRecepgirl *this, GlobalContext *globalCtx) {
func_80C10148(this);
return;
}
if ((temp_v0_2 == 5) && (Message_ShouldAdvance(globalCtx) != 0)) {
if (this->actor.textId == 0x2AD9) {
Flags_SetSwitch(globalCtx, this->actor.params);
Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f);
if ((gSaveContext.weekEventReg[63] & 0x80)) {
if ((gSaveContext.save.weekEventReg[63] & 0x80)) {
this->actor.textId = 0x2ADF;
} else {
this->actor.textId = 0x2ADA;
@@ -504,7 +504,7 @@ void func_80C102D4(EnRecepgirl* this, GlobalContext* globalCtx) {
if (this->actor.textId == 0x2AD9) { // "Welcome..."
Flags_SetSwitch(globalCtx, this->actor.params);
Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f);
if (gSaveContext.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting
if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting
this->actor.textId = 0x2ADF; // Mayor's office is on the left (meeting ended)
} else {
this->actor.textId = 0x2ADA; // Mayor's office is on the left (meeting ongoing)
+1 -1
View File
@@ -378,7 +378,7 @@ There remains one thing we need to fix before trying to compile it, namely `*(&g
/* 0x0EF8 */ u8 weekEventReg[100]; // "week_event_reg"
/* 0x0F5C */ u32 mapsVisited; // "area_arrival"
```
so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.weekEventReg[63] & 0x80)` will do.
so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.save.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.save.weekEventReg[63] & 0x80)` will do.
Running `./diff.py -mwo3 func_80C102D4` and scrolling down, we discover that this doesn't match!