In the first Harry Potter game for the Game Boy Color, the story of Harry's first year at Hogwarts School of Witchcraft and Wizardry is told in the form of a traditional role-playing game. Harry realizes the power of
Game objectives
Emulator used: BizHawk 2.8 (Syncs on 2.9.1 as well)
Fastest time
All glitches are allowed
Comments
Sanqui discovered that holding Right while using the "Chocolate Frog" item lead to the game jumping to WRAM, but at the cost of messing up the stack.
I realized it jumped to 0xCABB, which changes based on your X position. However, I wasn't able to figure out how to reach items, since when I checked, items were never loaded as it was located in bank 6 in WRAM. Earlier this month, Sanqui was investigating this glitch again, and realized in the middle of the frame, the game does swap to bank 6 of WRAM, so items are indeed able to be executed as code. They made the following payload
LD A, $05
LDH [$F0D2], A
LD SP, $CFF9
RET
This is the following values:
3E 05
E0 D2
31 F9 CF
C9
This needed 2 items right next to each other, followed by another 2 items next to each other, followed by 3 items next to each other.
This gave:
Antidote, Wiggenweld Potion: LD A, $05
Collapsible Cauldron, Copper Cauldron: LDH [$F0D2], A
Best Blowing Gum, Pumpkin Pasties, Cauldron Cakes: LD SP, $CFF9
Licorice Wands: RET
Corresponds to:
Amount
Item
Cost in Sickles
Antidotes
62
9,300
Wiggenweld Potions
5
750
Collapsible Cauldron
224
11,424
Copper Cauldron
210
21,210
Best Blowing Gum
49
196
Pumpkin Pasties
249
2,490
Licorice Wands
201
402
Cauldron Cakes
207
1656
For a total of 47,428 sickles. This was basically inpractical without an hour of grinding at the start for sickles. You could get 57K sickles at the train area, but then you be away from the stores unless you used "yes" item to reset the game, maintaining your sickles.
Sanqui then tried to reduce the amount of sickles needed with the following:
LD A, $05
LD C, $D2
LDH [$F0D2], A
LD SP, $CFF9
RET
Where it now corresponds to:
3E 05
01 D2
E2
31 F9 CF
C9
This allowed E2 to be a much cheaper item, since it does not need to be next to another item in WRAM. Then we can just skip buying the expensive cauldrons, and instead buy 226 Every Flavor Beans for 1,356 sickles. Unfortunatly, between the cauldrons and the candy are story related items that you are forced to obtain. Mainly:
Spellbook
School Books
Folio Triplicus
Folio Magi
Harry's Wand
You obtain 1 of each, which means the opcode LD BC, _ _ _ _ is unavoidable. If this had worked, it would bring the amount of sickles needed down to ~28k.
I then went and made a trace log of the game when you used the chocolate frog at X position 61,462 to see if there's anything else that was useable.
This was the trace log:
We couldn't use Chocolate Frog as part of the payload, since it gets used during the glitch, so 226 potion kits was chosen since we needed it anyways.
This reduced the amount of sickles needed to 7,780, which made it viable for RTA. The time for this game dropped from 2 hours, to 20 minutes real time.
When I actually tried this payload, I ran into a problem. To skip the train section, you must use cards. If I used a card, it would give me 3 more items. In this case, 3 Hardened Boots from the first giant rat boss. I couldn't use 1 name tag, since it would mess up register C, so I bought 25 instead, taking 1 extra frame.
After resyncing everything, I ran across another problem. It appeared whenever I tried to use the "yes" item to bring up the menu to skip the lake, it would always give me 1 pair of Superlative Boots. This caused me to modify the what I needed again to the following:
122 Leather Belt (366 sickles)
3 Superior Boots (Free, required to get off train)
1 Superlative Boots (Free, required to get out of battle using Yes)
76 Pack of Name Tags (760 sickles)
3 Antidotes (450 sickles)
226 Potion Kit Bags (2,260 sickles)
49 Best Blowing Gum (196 sickles)
249 Pumpkin Pasties (2,490 sickles)
201 Licorice Wands (402 sickles)
207 Cauldron Cakes (1656 sickles)
I also needed to take account into the school items
For a total of 9,554 sickles. I actually ran out of money on the way to Cauldron shop, so I duped once more to get enough. This also gave me 3 more pair of boots, but it doesn't mess with the payload.
Unfortunatly again, after I bought all this and resynced to the lake, the game refuses to actually bring up the menu during a fight with the dragonflies. I actually wanted to skip using the frog, and just play the lake and beat the knight as normal, but
1. Setting up lake skip just barely faster than doing it normally, ignoring the frog.
2. Knight using 3 turns took 1700 frames.
3. Beating the frog, but doing the lake normally completely loses all time.
I realized the lake was a huge problem to overcome, so I thought of a different way to get to 0,0.
There was an idea to use the 1st giant rat encounter to get to 0,0, but Sanqui tried, it turns out 0xCABB isn't X position. From discord:
This also made the OoB bug from pressing Start near the purple cloaked npc at Diagon Alley worthless.
However, I remembered that the train also had a warp to Forbidden Forest. It is completely useless in most cases, since it does not update the story progress counter, so it just softlocks you. However, the map itself is completely empty of other NPCs. Additionally, it also has NPC layouts that would let the "yes" item bring up the menu. So I tried using the Forbidden Forest to warp to the credits, and it worked.
This saved 6k frames over using the lake, without using frog during lake.
This is what gets run when I use chocolate frog:
Item
Amount
Cost
Hex
Opcode
Leather Belt
122
366
7A
LD A,D
Hardened Boots
3
0
03
INC BC
Superlative Boots
01
0
01
LD BC, 0000
Bulwark Boots
0
0
00
-
Optimum Boots
0
0
00
-
Pack of Name Tags
76
760
4C
LD C, H
Antidote
3
450
03
INC BC
Potion Kit Bag
226
2260
E2
LD (FF00 + C), A
Collapsible Cauldron
01
51
01
LD BC, 0000
Copper Cauldron
0
0
00
-
Brass Cauldron
0
0
00
-
Spellbook
01
0
01
LD BC, 0101
School Books
1
143
00
-
Folio Triplicus
1
0
00
-
Folio Magi
01
0
01
LD BC, 0000
Notebook
0
0
00
-
Curse Book
0
0
00
-
Harry's Wand
01
0
01
LD BC, 0000
Ordinary Broom
0
0
00
-
Comet 260
0
0
00
-
Best Blowing Gum
49
196
31
LD SP, CFF9
Pumpkin Pasties
249
2,490
F9
-
Cauldron Cakes
207
1656
CF
-
Licorice Wands
201
402
C9
RET
Possible improvement:
The blue deck, "Gulliver Pokeby" Deck, has Sickle Seek. This quadruples the amount of sickles gained after battle. The flag only gets reset at the start of the next fight, so it should be possible to use it for duping. However, I'm not sure how to get enough cards for it before the giant rat fight to make a difference.
The RNG can be improved. Right now, there's some delay to make sure the following:
The giant rat fight results in 2 critical hits from me.
The giant rat fight results in a drop of 1 pair of hardened boots only
NPCs wont move in to my way
The next time I used cards, there will be no drop, to prevent crashing
The frog fight needs to have at least 1 critical
The frog fight needs to drop item 127, "Yes" to get OoB later
The last encounter must have a layout that doesn't result in HALT, or invalid opcode in C000 area.
I do not understand the RNG enough to manipulate it outside delaying. There might be a way to get better RNG.
The "Yes" item actually jumps to C000 when used. That's where battle sprites are stored. I don't understand the game enough to make it jump to inventory, but if that was possible that bypasses the need to move OoB entirely.
The final payload can be changed from C9 (201, for RET), to C8 (200, for RET Z) for Licorice Wands. This would save 48 frames from having to buy a single Licorice Wand at the end, but I was not able to get "Yes" to leave the battle when I tried resyncing it. If anyone wants to try, here's the wip up to the fight at the end: https://tasvideos.org/UserFiles/Info/638317929758634206
The final opcode before return is LD SP, $CFF9. This is needed, since the game crashes due to corrupted stack. If a lower value for SP can be found, or a function that magically fixes the stack appears, it can potentially save time from having to buy over 200 candies twice.
The bytes that form your inventory being read as code is always a fascinating optimization problem, and I love how in your author comments you talk about where you started and the ways you reduced the cost of items to achieve the same desired effect.
In your author comments, you mention where the item jumps the PC, but you don't mention where the inventory is stored in WRAM, which would really help clear things up for those of us who don't know much about the game but are trying to follow along with what the ACE is doing. You share a tracelog where $CABB is a jump instruction. I assume the end result makes this a jump to the inventory (presumably at $F00A). At the end of the comments, consider showing the full tracelog from using the item to the end of your payload. I think it would help me follow along.
Great discovery, and nice TAS!
Thanks for the comment!
IIRC it was in WRAM bank 6. Items start at 0x6000 in BizHawk.
Here's the log of the payload:
https://drive.google.com/file/d/1_TeRgq4284u6sTFm4niW3EoEbL3TrWAZ/view?usp=sharing
Here's the log for leaving the fight using the glitched item. It also jumps to WRAM, but I can't figure out how to control it outside waiting:
https://drive.google.com/file/d/1_Vpy0ennHQsXuPIpr12lxgebGe71Po2S/view?usp=sharing
I haven't touched the run in a while since I got distracted playing BoTW, but there was an attempt on the Harry Potter discord to try a RTA-viable payload to get all cards/combos using ACE, but it turns out Hogwarts Dungeon was the only way RTA can do ACE right now using the knight boss to jump OOB. In a TAS, this can be done anytime since you have the "yes" glitch item to leave fights and appear at 0,0.
The other 2 areas that has a boss you can pause at, Muggle Secret Room, Gringotts Vault, for some reason has an invisible NPC, that makes this payload impossible (it doesn't jump to your X/Y).
If you're interested, it would be really nice finding a payload that can get cards/combos, using only diagon ally items. I know it sorta is possible, given I accidentally gave myself a ton of glitch items while trying to skip the lake:
https://tasvideos.org/UserFiles/Info/638314350640159042
And the tracelog on the frame I pressed A
https://drive.google.com/file/d/1_Wy7qpkpLarwf2KEFn5UgFr3hNWQooRh/view?usp=sharing
Here's the symbol file for debugging:
https://github.com/Sanqui/romhacking/blob/master/hp/hp1.sym