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:
AmountItemCost in Sickles
Antidotes629,300
Wiggenweld Potions5750
Collapsible Cauldron22411,424
Copper Cauldron21021,210
Best Blowing Gum49196
Pumpkin Pasties2492,490
Licorice Wands201402
Cauldron Cakes2071656
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:
CAB7:  00        nop                 A:ff F:c0 B:00 C:00 D:41 E:fe H:d1 L:05 LY:3b SP:3630  Cy:1305888464
CAB8:  01 7C 71  ld bc, $717C        A:ff F:c0 B:00 C:00 D:41 E:fe H:d1 L:05 LY:3b SP:3630  Cy:1305888465
CABB:  C3 0A F0  jp $F00A            A:ff F:c0 B:71 C:7c D:41 E:fe H:d1 L:05 LY:3b SP:3630  Cy:1305888468
F00A:  00        nop                 A:ff F:c0 B:71 C:7c D:41 E:fe H:d1 L:05 LY:3b SP:3630  Cy:1305888472
Here register D has $41, H has $D1, L has $05 These are already values we need. So the payload was changed to reflect that:
LD A, D
LD C, H
INC BC
LDH [$F0D2], A
LD SP, $CFF9
RET
For the values:
7A
4C
03
E2
31 F9 CF
C9
Since there's now 4 independent values to choose from, we could then use the cheaper cloth items as well for payload. The payload now became
122 Leather Belt (366 sickles)
76 Plain Boots (380 sickles)
3 Pack of Name Tags  (30 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)
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
1 Dragonskin Gloves (62 sickles)
1 Pointed Hat (58 sickles)
3 Plain Work Robe (240 sickles)
1 Winter Cloak (150 sickles)
1 Collapsible Cauldron (51 sickles)
1 School Books (143 sickles)
26 Chocolate Frogs (260 sickles)
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:
Quoting Sanqui
Unfortunately, there's Hagrid on that map, and a NPC breaks the setup and yeah, a different set of items would be necessary, but that's not the issue current set of items is simply optimized for dungeons unfortunately, the address we use is not actually harry's X position, but a temporary variable holding the bounding box coordinates used to calculate character collisions and if there's a npc other than harry on the map, it holds their value (at time of menuing) so OOB is useless
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:
ItemAmountCostHexOpcode
Leather Belt1223667ALD A,D
Hardened Boots3003INC BC
Superlative Boots01001LD BC, 0000
Bulwark Boots0000-
Optimum Boots0000-
Pack of Name Tags767604CLD C, H
Antidote345003INC BC
Potion Kit Bag2262260E2LD (FF00 + C), A
Collapsible Cauldron015101LD BC, 0000
Copper Cauldron0000-
Brass Cauldron0000-
Spellbook01001LD BC, 0101
School Books114300-
Folio Triplicus1000-
Folio Magi01001LD BC, 0000
Notebook0000-
Curse Book0000-
Harry's Wand01001LD BC, 0000
Ordinary Broom0000-
Comet 2600000-
Best Blowing Gum4919631LD SP, CFF9
Pumpkin Pasties2492,490F9-
Cauldron Cakes2071656CF-
Licorice Wands201402C9RET
Possible improvement:
  1. 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.
  2. The RNG can be improved. Right now, there's some delay to make sure the following:
    1. The giant rat fight results in 2 critical hits from me.
    2. The giant rat fight results in a drop of 1 pair of hardened boots only
    3. NPCs wont move in to my way
    4. The next time I used cards, there will be no drop, to prevent crashing
    5. The frog fight needs to have at least 1 critical
    6. The frog fight needs to drop item 127, "Yes" to get OoB later
    7. 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.
  1. 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.
  2. 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
  3. 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.

arkiandruski: Claiming for judging.
arkiandruski: Looks good. Accepting as a fastest completion

despoa: Processing...


TASVideoAgent
They/Them
Moderator
Joined: 8/3/2004
Posts: 15558
Location: 127.0.0.1
Player (246)
Joined: 6/16/2020
Posts: 28
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!
Skilled player (1738)
Joined: 9/17/2009
Posts: 4980
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
OnehundredthCoin wrote:
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
Post subject: Movie published
TASVideoAgent
They/Them
Moderator
Joined: 8/3/2004
Posts: 15558
Location: 127.0.0.1
This movie has been published. The posts before this message apply to the submission, and posts after this message apply to the published movie. ---- [5694] GBC Harry Potter and the Sorcerer's Stone "game end glitch" by jlun2 & Sanqui in 10:02.03