Skip to content

Commit

Permalink
Restoration: RBA Values (HarbourMasters#2672)
Browse files Browse the repository at this point in the history
* Restore RBA Values

Matches all rba scenarios achievable in game to their original outcomes. This only ends up affecting certain trade items.

* tooltip rewrite

* rba cases generalised

* re-add to menu bar

* better byteswap and checks for endianness

* remove leftover defines
  • Loading branch information
inspectredc authored Oct 17, 2023
1 parent da92ac6 commit cff2e37
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions soh/soh/Enhancements/presets.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const std::vector<const char*> enhancementsCvars = {
"gBombchusOOB",
"gQuickPutaway",
"gGsCutscene",
"gRestoreRBAValues",
"gSkipSaveConfirmation",
"gAutosave",
"gDisableCritWiggle",
Expand Down
2 changes: 2 additions & 0 deletions soh/soh/SohMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,8 @@ void DrawEnhancementsMenu() {
UIWidgets::PaddedEnhancementCheckbox("Restore old Gold Skulltula cutscene", "gGsCutscene", true, false);
UIWidgets::PaddedEnhancementCheckbox("Quick Bongo Kill", "gQuickBongoKill", true, false);
UIWidgets::Tooltip("Restore a bug from NTSC 1.0 that allows bypassing Bongo Bongo's intro cutscene to quickly kill him");
UIWidgets::PaddedEnhancementCheckbox("Original RBA Values", "gRestoreRBAValues", true, false);
UIWidgets::Tooltip("Restores the original outcomes when performing Reverse Bottle Adventure.");

ImGui::EndMenu();
}
Expand Down
16 changes: 15 additions & 1 deletion soh/src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2782,6 +2782,13 @@ s32 Inventory_HasSpecificBottle(u8 bottleItem) {
}
}

void byteSwapInventory() {
gSaveContext.inventory.equipment = BE16SWAP(gSaveContext.inventory.equipment);
gSaveContext.inventory.upgrades = BE32SWAP(gSaveContext.inventory.upgrades);
gSaveContext.inventory.questItems = BE32SWAP(gSaveContext.inventory.questItems);
gSaveContext.inventory.gsTokens = BE16SWAP(gSaveContext.inventory.gsTokens);
}

void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 button) {
osSyncPrintf("item_no=%x, c_no=%x, Pt=%x Item_Register=%x\n", item, button,
gSaveContext.equips.cButtonSlots[button - 1],
Expand All @@ -2793,7 +2800,14 @@ void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 button) {
item = ITEM_MILK_HALF;
}

gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] = item;
if (CVarGetInteger("gRestoreRBAValues",0)) {
byteSwapInventory();
gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] = item;
byteSwapInventory();
} else {
gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] = item;
}

gSaveContext.equips.buttonItems[button] = item;

Interface_LoadItemIcon1(play, button);
Expand Down

0 comments on commit cff2e37

Please sign in to comment.