Virazek / Spyro2-Decomp

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

Modify boss level scripts to force you to warp back to their hubworld on completion #4

Open Virazek opened 5 months ago

Virazek commented 5 months ago

Function PREPARE_MAP_TRANSITION_THROUGH_CUTSCENE (starting at address 0x80019230 and returning at 0x8001935C) handles map transitions out of boss levels (at least for Crush and Gulp). This function checks if the map transition being loaded is one for the cutscenes after bosses (0x07 for Crush>Autumn Plains, 0x0B for Gulp>Winter Tundra) and if the corresponding hubworld has been discovered in the Guidebook. If so, it tells this subroutine to load the map after the cutscene instead, skipping the cutscene altogether.

Thus, we can tell this subroutine to simply load a different map transition to return back to that boss' hubworld (and have it ignore the Guidebook entry check).

Doing that change naively sends you back to the default spawn for that hubworld (e.g., outside of Glimmer for Summer Forest), so some additional testing needs to be done to hopefully spawn you outside of the boss portal instead. This subroutine is executed when leaving boss levels from the 'Exit Level' in the pause menu which puts you outside the boss portal, so clearly it must be possible.

Virazek commented 4 months ago

Function PAUSE_MENU seems to handle this case instead. The function checks as part of its branches if the pause menu selection was invoked from a submenu. If not, it then checks to see if >Exit Level was selected. If so, it does some logic with the current map sector ID ((m / 10) * 10 != m - 6). I'm not sure what sectors this aligns with (preliminarily, it seems to be all non-boss levels), but boss levels (sectors 0x1A, 0x2E, 0x42 respectively) don't line up. The script then explicitly checks sector IDs corresponding to bosses, sets which map transition to do (0x05, 0x09, and 0x0D respectively) and then prepares the map transition. I can't see how it's setting the spawn coordinates however, so simply calling PREPARE_MAP_TRANSITION_THROUGH_CUTSCENE with these input values (like how this subroutine does) still spawns you at the default spawn for that world. Maybe the completion script is already setting WRAM_WARP_SOURCE_MAP already so it is considering it as coming from a different map?