Restoration: RBA Values#2672
Conversation
Matches all rba scenarios achievable in game to their original outcomes. This only ends up affecting certain trade items.
|
@inspectredc RBA still isn't in my bag of tricks, I assume you have validated this to be working for all scenarios? |
|
Been a while since I went through this so I will double check but I may want to look into a less hardcoded fix instead. The main problem is that it only appears to be only the queststatus and upgrades which are flipped, which is unlike 3ds which also differs for item amounts. |
aMannus
left a comment
There was a problem hiding this comment.
I'm still a little on the fence about re-introducing glitch(-behaviour) with hard coded changes (ie unloading the Royal Tomb), but this seems small enough of an adjustment for a pretty big payoff.
|
@aMannus yea i wasnt so keen on it either but I think I've come up with a slightly less hardcoded method, would love to hear your thoughts: (rough draft) #define RBA_EQUIPMENT_OFFSET 0x28
#define RBA_UPGRADE_OFFSET 0x2C
#define RBA_QUEST_OFFSET 0x30
#define RBA_GS_OFFSET 0x5C
void byteSwapInventory() {
u8 equipment[2];
u8 upgrades[4];
u8 questItems[4];
u8 gsTokens[2];
equipment[0] = gSaveContext.inventory.items[RBA_EQUIPMENT_OFFSET + 1];
equipment[1] = gSaveContext.inventory.items[RBA_EQUIPMENT_OFFSET + 0];
gSaveContext.inventory.equipment = *(u16*)equipment;
upgrades[0] = gSaveContext.inventory.items[RBA_UPGRADE_OFFSET + 3];
upgrades[1] = gSaveContext.inventory.items[RBA_UPGRADE_OFFSET + 2];
upgrades[2] = gSaveContext.inventory.items[RBA_UPGRADE_OFFSET + 1];
upgrades[3] = gSaveContext.inventory.items[RBA_UPGRADE_OFFSET + 0];
gSaveContext.inventory.upgrades = *(u32*)upgrades;
questItems[0] = gSaveContext.inventory.items[RBA_QUEST_OFFSET + 3];
questItems[1] = gSaveContext.inventory.items[RBA_QUEST_OFFSET + 2];
questItems[2] = gSaveContext.inventory.items[RBA_QUEST_OFFSET + 1];
questItems[3] = gSaveContext.inventory.items[RBA_QUEST_OFFSET + 0];
gSaveContext.inventory.questItems = *(u32*)questItems;
gsTokens[0] = gSaveContext.inventory.items[RBA_GS_OFFSET + 1];
gsTokens[1] = gSaveContext.inventory.items[RBA_GS_OFFSET + 0];
gSaveContext.inventory.gsTokens = *(s16*)gsTokens;
}
.
.
.
....
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;
} |
|
I've re-done this now in the style of the above comment and updated so there arent any merge conflicts. This hopefully is a better approach than matching per-case but I can move back to that if there are any issues |
|
So is it correct to say that the RBA differences were strictly endianness related? If so, I think we need to be careful not to assume all platforms running SoH have the same endiannes. I can't remember, but I think Wii U is different? |
That is the case yes, I'm not an expert on platform differences but had tested the platforms i have available (mac/windows) which unfortunately does not include wiiu. If that is the case then rba should work on wiiu correctly as is, would the best approach then be to add an ifdef for wiiu? I also understand that linux requires the swapping but not sure how much the architectures can vary with how SoH is built |
| byteSwapInventory(); | ||
| gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] = item; | ||
| byteSwapInventory(); |
There was a problem hiding this comment.
Correct me if I'm wrong, but is the need to byteswap before and after just to negate changes to the values not being updated by RBA?
I wonder if maybe instead we should explicitly only byteswap the value being updated by RBA so we dont have to do the double negation. I'm not sure how easy that can be detected.
There was a problem hiding this comment.
I was trying to think of ways where I would only swap the values being affected but to me it always ends up feeling bloated or gives off the same hard coded feeling I had before with just swapping every case individually. Regardless you would need to swap the value affected by RBA too as the game would otherwise interpret it incorrectly.
I think we can start with just an ifdef for wiiu for now, and if we find we need runtime checks for other archs we can handle that in a follow up |
|
got around to updating this using the LUS byte swap stuff, looks like theres a byte swap which checks against big-endianness too so solution looks neater now :D |
This PR adds an option to restore Reverse Bottle Adventure values found on the original game.
It achieves this case by case by matching all RBA scenarios achievable in game to their original outcomes. This only ends up affecting certain trade items as all other items equippable in game match their original outcomes.
Build Artifacts