Re: Glitch Pokémon Pokédex ACE in Generation I
Posted by: jfb1337
Date: 2017-04-26 10:47:28
Anyway, I decided to do a search for jp [hl] to find other potential ACE entry points (besides the ones that mess with the stack such as trade centre RCE, or exotic stuff like cartswap and HRAm manip, or potentially anything that messes with the ROM bank in an unexpected manor, or anything which pushes something to the stack and then rets to it, though I don't know if the game ever does this):
pokered$ git grep "jp \[hl\]"
engine/battle/animations.asm: jp [hl] ; jump to special effect function
engine/battle/animations.asm: jp [hl]
engine/battle/animations.asm: jp [hl]
engine/battle/animations.asm: jp [hl]
engine/battle/battle_transitions.asm: jp [hl]
engine/battle/core.asm: jp [hl]
engine/battle/core.asm: jp [hl]
engine/battle/core.asm: jp [hl] ; jump to special effect handler
engine/battle/trainer_ai.asm: jp [hl] ; execute modification function
engine/battle/trainer_ai.asm: jp [hl]
engine/cable_club.asm: jp [hl]
engine/items/items.asm: jp [hl]
engine/menu/start_sub_menus.asm: jp [hl]
engine/menu/text_box.asm: jp [hl] ; jump to the function
engine/overworld/player_state.asm: jp [hl]
engine/overworld/ssanne.asm: jp [hl]
engine/palettes.asm: jp [hl]
engine/slot_machine.asm: jp [hl]
engine/trade.asm: jp [hl] ; call trade func, which will return to the top of the loop
home.asm: jp [hl]
home.asm: jp [hl]
home.asm: jp [hl]
home/overworld.asm: jp [hl] ; jump to script
home/predef.asm: jp [hl]
OK so that's 24 possibilities (for R/B at least, haven't checked Y):
- The 4 in animations.asm look like they're either non-manipulable, or fall under Glitch Move ACE (via animation pointers)
- The 1 in battle_transitions.asm is non-manipulable (only influenced by bc which is set to 0, then only set by a few functions that never set bc to something invalid)
- The 3 in core.asm are either non manipulable or fall under Glitch Move ACE (via move effects)
- The 1 in trainer_ai.asm is the ZZAZZ trainer ACE (are there other glitch trainers that trigger ACE too?)
- The 1 in cable_club.asm is seemed interesting, but it turns out that the address it reads from to determine the jump, CC38 aka wTradeCenterPointerTableIndex, is set right before every time the function that contains the jump is called, so it's unmanipulable.
- The 1 in items.asm is Glitch Item ACE, the 8F that we all know and love
- The 1 in start_submenus.asm is for out of battle moves, which seemed interesting since there is an unused field move $B4, but it would just act like surf since in its place is an extra pointer to the surf function. But maybe $cd3d AKA wFieldMoves could be manipulated somehow? Though this is very unlikely.
- The 1 in text_box.asm doesn't seem manipulable since it searches through a table that is properly terminated by $FF
- The 1 in player_state.asm looks interesting: It's determined by wSpriteStateData1 + 9, aka $C109, the player's current direction. Could that be potentially manipulated somehow?
- The 1 in ssanne.asm is ALSO based on wSpriteStateData1 + 9
- The 1 is palletes.asm is about SGB pallete commands. But it seems like every time RunPaletteCommand is called, b is set to a valid palette command already, so there doesn't seem to be room for manipulation.
- The 1 in slot_machine.asm is for a pointer to a reward function that's based on the symbol on the wheel that matched. Unfortunately that doesn't seem possible to manipulate.
- The 1 in trade.asm is non manipulable, as the pointer it uses is only ever set to a valid trade animation function which just follows a fixed sequence defined entirely in ROM.
- The 3 in home.asm are in Bankswitch, CallFunctionInTable, and CheckForHiddenObjectOrBookshelfOrCardKeyDoor.
–The latter is non manipulable since it searches for a pointer in a well-terminated array so it only loads valid hidden object pointers.
–Bankswitch is also non manipulable since it always sets hl properly before being called.
–CallFunctionInTable is only used in scripts (which would fall under the map script ACE methods) and a couple of places in home.asm, one also to do with map scripts, and the other for NPC movement scripts, which after a quick glance over where the addresses involved are used, they seem to all be only set to constant values, unless $CC57 or $CF10 could be manipulated somehow.
- The 1 in overworld.asm is the map script, which covers 3 types of map pointer ACEs.
- Finally, the one in Predef.asm is for Predef pointers. Probably not manipulable since a predef ID is always set before calling Predef.
I was surprised that TextCommandProcessor doesn't show up, but I discovered that actually uses "jp hl" instead of "jp [hl]" like I was searching for.
There are 2 other instances of "jp hl": One also in text.asm to a non manipulable function table, since it's only used when a < 0xE [even if this were manipulable, it wouldn't be very useful since it's part of the text command processor which you can already use 08 to turn into ACE anyway]. The other is in naming_screen.asm, on a non-manipulable table for button input.
Anyway, the next interesting thing to search for is TextCommandProcessor itself:
pokered$ git grep TextCommandProcessor
engine/cable_club.asm: call TextCommandProcessor
engine/menu/pokedex.asm: call TextCommandProcessor ; print pokedex description text
home.asm: call TextCommandProcessor
home.asm: jp TextCommandProcessor
home/text.asm: call TextCommandProcessor
home/text.asm:TextCommandProcessor::
home/text.asm: call TextCommandProcessor
The calls in text.asm are the handlers for TX_FAR, and Char55, which points to a fixed text in ROM.
The call in cable_club.asm is also a fixed text string.
The call in pokedex.asm is this ACE method!
The calls in home.asm are part of PrintText, which gives us something else to search for, and TrainerEndBattletext. Could we possibly manipulate the win/lose text pointers at d08c from within battle?
At this point I searched for PrintText… and there are TONS of results., too many to list here and more than I'm willing to check at the moment. They probably fall into the category of glitch text box ACE though.
But if anyone wants to add a 13th method to the list, PrintText is a good place to start.
Also, note that ACE doesn't necessarily need to point to RAM - Maybe there's something which points somewhere in ROM that's in the middle of a function that messes with the push/pop balance, causing the game to jump again to somewhere else when it hits a ret? A bit like how Coin Case ACE works.
Also, research into what unlocks SRAM would be nice, since sometimes when I hit an rst 38 I lose my save, and sometimes I don't, with no pattern I can see, so it would be nice to know what unlocks SRAM so I could take precautions.