pret / pokeemerald

Decompilation of Pokémon Emerald

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Battle factory softlocks the game when building with modern

kageru opened this issue · comments

As the title says, when building the current master with make modern, the game softlocks when entering Pokemon selection in the battle factory. The music keeps playing, and menu sounds are still being played whenever A or B is pressed, but the game doesn’t respond to inputs beyond that.
The selection menu is also visibly broken, see https://i.kageru.moe/k36PRH.png
When building without modern, everything works as intended.

To quickly get a fresh save to factory to reproduce the issue, you can modify littleroot as follows:

--- a/data/maps/LittlerootTown/scripts.inc
+++ b/data/maps/LittlerootTown/scripts.inc
@@ -407,6 +407,8 @@ LittlerootTown_EventScript_GoSaveBirchTrigger:: @ 81E811F

 LittlerootTown_EventScript_TownSign:: @ 81E8151
 	msgbox LittlerootTown_Text_TownSign, MSGBOX_SIGN
+        warpteleport MAP_BATTLE_FRONTIER_BATTLE_FACTORY_LOBBY, 255, 9, 10
+        waitstate
 	end

 LittlerootTown_EventScript_BirchsLabSign:: @ 81E815A

Talking to the town sign in littleroot will then warp you to the factory.

For questions, I’m kageru#7213 on pret discord.

Edit: Tested on mgba 0.8.3 and built with gcc 10.2.0 from devkitARM.

Confirmed this is an issue on gcc 10, though not on 9. Looks to be from dereferencing a null pointer. CB2_InitSelectScreen is used to initialize the screen on first open and on return from the summary screen, and there are several assumptions in that function that sFactorySelectScreen is not NULL, which it is on first run