diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2023-04-18 18:54:32 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-18 18:54:32 -0400 |
| commit | 3c107cb148d784e2af4a347dc78f25b1697410be (patch) | |
| tree | b67a051ee5851deec190356461b7575507c33785 /docs | |
| parent | b8af819165ea4f31f34940d59a13ef19a5aabd2f (diff) | |
Add `SaveInfo` substruct to `SaveContext` (#1191)
* SaveInfo
* fix accesses in sram_NES.c
* some more fixing
* more fixes
* format
* fix unk
* namefixer
* format
* bss
* review
* weekeventregconvert
* namefixer
* bss
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/tutorial/advanced_control_flow.md | 42 | ||||
| -rw-r--r-- | docs/tutorial/documenting.md | 4 | ||||
| -rw-r--r-- | docs/tutorial/other_functions.md | 2 |
3 files changed, 24 insertions, 24 deletions
diff --git a/docs/tutorial/advanced_control_flow.md b/docs/tutorial/advanced_control_flow.md index 528b052f9..43e9e6d46 100644 --- a/docs/tutorial/advanced_control_flow.md +++ b/docs/tutorial/advanced_control_flow.md @@ -81,7 +81,7 @@ void EnMs_Destroy(Actor* thisx, PlayState* play) { void func_80952734(EnMs* this, PlayState* play) { s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.save.inventory.items[10] == ITEM_NONE) { + if (gSaveContext.save.saveInfo.inventory.items[10] == ITEM_NONE) { this->actor.textId = 0x92E; } else { this->actor.textId = 0x932; @@ -187,12 +187,12 @@ void func_809527F8(EnMs* this, PlayState* play) { return; } Message_CloseTextbox(play); - if ((s32) gSaveContext.save.playerData.rupees < 0xA) { + if ((s32) gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x935U); return; } - if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if ((s32) gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x937U); return; @@ -274,14 +274,14 @@ block_7: goto block_16; block_11: Message_CloseTextbox(play); - if ((s32) gSaveContext.save.playerData.rupees >= 0xA) { + if ((s32) gSaveContext.save.saveInfo.playerData.rupees >= 0xA) { goto block_13; } play_sound(0x4806U); Message_ContinueTextbox(play, 0x935U); return; block_13: - if ((s32) gSaveContext.save.inventory.ammo[gItemSlots[0xA]] < 0x14) { + if ((s32) gSaveContext.save.saveInfo.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.save.playerData.rupees >= 0xA) { + if ((s32) gSaveContext.save.saveInfo.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.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x935U); return; @@ -378,12 +378,12 @@ block_7: block_11: Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x935U); return; } - if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x937U); return; @@ -447,12 +447,12 @@ block_7: block_11: Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x935U); return; } - if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x937U); return; @@ -497,12 +497,12 @@ So let us rewrite the entire second half as a switch: case 0: Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x935U); return; } - if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x937U); return; @@ -533,10 +533,10 @@ There's a couple of other obvious things here: case 0: Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x935U); - } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x937U); } else { @@ -598,10 +598,10 @@ block_7: case 0: Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x935U); - } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x937U); } else { @@ -663,10 +663,10 @@ void func_809527F8(EnMs* this, PlayState* play) { case 0: Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x935U); - } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x937U); } else { @@ -715,10 +715,10 @@ void func_809527F8(EnMs* this, PlayState* play) { case 0: Message_CloseTextbox(play); - if (gSaveContext.save.playerData.rupees < 0xA) { + if (gSaveContext.save.saveInfo.playerData.rupees < 0xA) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x935U); - } else if (gSaveContext.save.inventory.ammo[gItemSlots[0xA]] >= 0x14) { + } else if (gSaveContext.save.saveInfo.inventory.ammo[gItemSlots[0xA]] >= 0x14) { play_sound(0x4806U); Message_ContinueTextbox(play, 0x937U); } else { diff --git a/docs/tutorial/documenting.md b/docs/tutorial/documenting.md index 7ecd37ccb..71f3347e3 100644 --- a/docs/tutorial/documenting.md +++ b/docs/tutorial/documenting.md @@ -185,7 +185,7 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { if (this->actor.textId == 0x2AD9) { Flags_SetSwitch(play, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if ((gSaveContext.save.weekEventReg[63] & 0x80)) { + if ((gSaveContext.save.saveInfo.weekEventReg[63] & 0x80)) { this->actor.textId = 0x2ADF; } else { this->actor.textId = 0x2ADA; @@ -516,7 +516,7 @@ void func_80C102D4(EnRecepgirl* this, PlayState* play) { if (this->actor.textId == 0x2AD9) { // "Welcome..." Flags_SetSwitch(play, this->actor.params); Animation_MorphToPlayOnce(&this->skelAnime, &object_bg_Anim_00AD98, 10.0f); - if (gSaveContext.save.weekEventReg[63] & 0x80) { // showed Couple's Mask to meeting + if (gSaveContext.save.saveInfo.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) diff --git a/docs/tutorial/other_functions.md b/docs/tutorial/other_functions.md index c6ac63a64..f73902ca5 100644 --- a/docs/tutorial/other_functions.md +++ b/docs/tutorial/other_functions.md @@ -404,7 +404,7 @@ There remains one thing we need to fix before trying to compile it, namely `*(&g /* 0x0F5C */ u32 regionsVisited; // "area_arrival" ``` -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. +so it's somewhere in `weekEventReg`. `0xF37 - 0xEF8 = 0x3F = 63`, and it's a byte array, so the access is actually `gSaveContext.save.saveInfo.weekEventReg[63] & 0x80`. Now it will compile. We also don't use `!= 0` for flag comparisons: just `if (gSaveContext.save.saveInfo.weekEventReg[63] & 0x80)` will do. Running `./diff.py -mwo3 func_80C102D4` and scrolling down, we discover that this doesn't match! |
