Virazek / Spyro2-Decomp

Disassembly of Spyro 2
MIT License
1 stars 0 forks source link

Write custom anti-softlock protection script for hubworlds #9

Open Virazek opened 4 months ago

Virazek commented 4 months ago

In the function PAUSE_MENU, there is a branch at 0x80018334 that executes after a pause menu selection. It first checks if the option was not invoked from a submenu, and if the current pause menu selection was 0x05, which corresponds to >Exit Level. However, if the option was invoked from submenu ID 0x04 (which is the confirmation prompt for >Quit Game), it instead initiates the game over process. So, there's a good chance we can just modify the game over function call to just initiate a map transition to reload the current map instead, and then modify some of the text to make sense.

Virazek commented 4 months ago

Tested with a proof of concept.

_LAB80018430 (start of the branch that handles >Quit Game) was modified to:

lw a0,offset WRAM_CURRENT_MAP_ID  
j LAB_800184F4  
_nop (removes the jump to the return)

so that >Quit Game instead tries to initiate a map transition to the current map. This succeeds for Summer Forest and Autumn Plains, but fails for Winter Tundra since for whatever reason, the map transition initation subroutine doesn't take 0x15 (Winter Tundra's map ID) as a parameter for loading Winter Tundra, but instead takes 0x0D (which is actually Zephyr's ID, but I think this function takes some other form of transition ID). So, we'll probably have to have the code jump elsewhere to handle all cases. As well, the current size of the text table is perfect to replace 'Quit Game?' and 'Quit Game' (0x80010284 and 0x80102E4 respectively) to 'Reload Hub?' and 'Reload Hub'.

Virazek commented 4 months ago

There are potential accessibility concerns with a future entrance randomization implementation, since this solution spawns you at the default spawn for the world. Thus, it will always give you access to pre-swim Summer Forest, and for glitchless logic will lock you out of post-headbash Winter Tundra after the first visit unless you re-transition hubworlds, which may not be accessible (this is always accessible in glitched logic due to penguin proxy). This may be avoidable by changing the default hubworld spawn position as part of the entrance randomizer implementation.