Post subject: Harry Potter and the Chamber of Secrets
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
This was requested, and apparently there's a route of it for a TAS, so I'll use this thread to put some findings here. Known glitches: *New game stat smuggle https://www.youtube.com/watch?v=DyDmD-ocSPs *Getting Ron to the last boss https://www.youtube.com/watch?v=Dv4hFya5wsE *Burrow cutscene skip https://www.youtube.com/watch?v=R40BX0YzPY0 *Nick cutscene skip https://www.youtube.com/watch?v=wD78ZgszSBs *McGonagall cutscene skip https://www.youtube.com/watch?v=Ta_Rjz2cOo8 *Cutscene thing https://www.youtube.com/watch?v=GjufoyTP8b8 *Pausing before a cutscene still messes things up (opening menus causes softlock) *If the enemy is faster than you, you can skip their turn by attempting to run, fail, then press "A" on their turn. Turboing allows you to even skip your partners turn. Addresses: System Bus: CD54 - Unsigned 2 byte big endian - Message countdown (0 allows you to press A) CE4B to 0xCE56 - Binary, Flags for Folio Bruti unlocks FFD0 - Game state? Similar to the prequel, changing to certain values gives a CHEAT menu. https://tcrf.net/Harry_Potter_and_the_Chamber_of_Secrets_(Game_Boy_Color)#CHEAT_menus FFD8 - Unsigned 1 byte, Map ID WRAM: 0B56 - Unsigned 2 byte - First minigame timer 0E3E - Unsigned 2 byte little? endian - RNG 0C36 - Unsigned 1 byte - Counter to next enemy spawn 06AE - Unsigned 1 byte - Hitsplat digit color (can be either 1's or 10's digit) 0692 - Unsigned 1 byte - Hitsplat digit number corresponding to above 065E - Unsigned 1 byte - Hitsplat digit color (can be either 1's or 10's digit) 063E - Unsigned 1 byte - Hitsplat digit number corresponding to above 05EA - Unsigned 1 byte - Hitsplat digit color (can be either 1's or 10's digit) 0606 - Unsigned 1 byte - Hitsplat digit number corresponding to above 5050 - Hp1 NPC. Also exists in 0572 WRAM, and C572, E572 in System Bus, but changing them don't seem to do anything. Note: Digit colors can be used for scripts to detect if a crit or miss has landed. Crits are red colored with value of 2, and miss has value of 3. To get the actual number, use either 0BCA, 061A in WRAM instead. The X/Y addresses seems to be all over the place. A simple search for Y in system bus gave: C2D8, C2DC, C2E6, CABB, CABD, CD74, CDBB, E2D8, E2DC, E2E6, EABB, EABD, ED74, EDBB. Changing any one of them all work for some reason. For partners maybe? Edit: Thanks for SuperMonkeypotato for providing details on routes, some addresses, glitches, etc. Download hpcs.lua
Language: lua

memory.usememorydomain("System Bus") local addresses = { --WRAM npc_top_id = 0x504B, npc_top_max_hp = 0x504C, npc_top_cur_hp = 0x5050, npc_mid_id = 0x5064, npc_mid_max_hp = 0x5065, npc_mid_cur_hp = 0x5069, npc_bottom_id = 0x507D, npc_bottom_max_hp = 0x507E, npc_bottom_cur_hp = 0x5082, --System Bus x = 0xC2D4, y = 0xC2D7, rng = 0x0E3E, message_countdown = 0xCD54, folio_bruti_start = 0xCE4B, folio_bruti_end = 0xCE56, frame = 0xFFC3, second = 0xFFC4, minute = 0xFFC5, game_state = 0xFFD0, area = 0xFFD8 } local drawtext = gui.drawText function text(x, y, message, font) local font = (font == nil) and 10 or font drawtext(x, y, message,nil,nil,font,nil,nil) end local npc_offset = 0x19 function display_battle() --[[ Game states for battle: 25 using cards 26 choose action (spell, thing, item, run, folio bruti) 27 choose spell 28 choose spell version 29 choose item 30 using an item 31 run 32 pack rat? 33 npc attacking 34 select npc + attack 35 win screen 36 select team mate 39 scabbers attack 47 card attack ]]-- local line = "" local start_adr = addresses.npc_top_id local offset = 10 for i = 0,2 do local id = memory.read_u8(start_adr+(npc_offset*i),"WRAM") local max_hp = memory.read_s16_le(start_adr+(npc_offset*i)+1,"WRAM") local current_hp = memory.read_s16_be(start_adr+(npc_offset*i)+4,"WRAM") line = "E"..(i+1).." ".." ID:"..id.." HP:"..current_hp.."/"..max_hp text(0,offset,line) offset = offset + 10 end end while true do local x = string.format('%.6f',memory.read_u24_le(addresses.x)/4096.0) local y = string.format('%.6f',memory.read_u24_le(addresses.y)/4096.0) local game_state = memory.read_u8(addresses.game_state) text(0,50,"State "..memory.readbyte(addresses.game_state)) text(0,60,"RNG"..memory.read_u16_le(addresses.rng,"WRAM")) text(0,80,memory.readbyte(addresses.minute)..":"..memory.readbyte(addresses.second)..":"..memory.readbyte(addresses.frame)) if game_state >= 25 or game_state <= 47 then display_battle() else text(0,30,"X"..x.."Y"..y) text(0,40,"MSG"..memory.read_s16_be(addresses.message_countdown)) end emu.frameadvance() end
Player (43)
Joined: 1/7/2016
Posts: 51
With the known glitches only two have any relevance here, Nick and Burrow cutscene skip, unless something can be found with the last one, which may allow for skips but seeing how this game has to have a quest update before certain things can happen, that might not actually be able to happen. If any new skips can be found they will probably be used if they can help. The only change that is going to be needed in the new TAS is that we lose to Crabbe and Goyle as it is easier to do, and don't need the experience from their fight, have enough health for the next fight. I would give the TAS file that I have, but the file for that TAS has a desync now and I don't know how. One more address of value is: 0569 - IWRAM, Unsigned 1 byte is Enemy HP
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
Found some glitches: http://imgur.com/a/vb42z Talking + First encounter, and grabbing a wizard card just as Floo Powder cutscene starts. Edit: Skip Hagrid getting you out of Knock turn Alley by pausing then unpausing. Edit 2: It appears the first boss may need 3 critical hits to defeat without healing. The RNG values seems to never decrement outside looping, so it may be possible to check all near values for RNG to see if 3 crits are close.
Player (43)
Joined: 1/7/2016
Posts: 51
Yes, the first fight will require 3 crits without healing, unless you grab the Wiggenweld Grand before the fight. It is in the window going on the first left turn going to the fight. That is the only other thing that I can think of, the only thing that is bad about it is that it doesn't advance RNG during the fight, so you have plan it properly.
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
I forgot to post, but the 2nd minigame with Ron seems to be RNG based during Ron's turn. He had different throw distances than the videos linked. Not sure how much time can it saved, but just posting it here.
Player (43)
Joined: 1/7/2016
Posts: 51
jlun2 wrote:
I forgot to post, but the 2nd minigame with Ron seems to be RNG based during Ron's turn. He had different throw distances than the videos linked. Not sure how much time can it saved, but just posting it here.
I noticed that RNG constantly changes throughout his throw, so if you are able to control the distance he throws first throw, then you could manipulate his subsequent throws by changing the frame you throw.
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
I believe I found where enemy HP addresses are stored. For some reason, just like the first game, it's mirrored several locations in System Bus, but only changing certain addresses in WRAM actually affects it. Unlike the original game however, it seems the location of the "real" address moves around every battle in WRAM. Actually, it appears to be the same 3 addresses. Just that the enemies from the same spot may use either 3. Example mirror address in WRAM 0x0572 Example mirror address in System Bus 0xC572, 0xE572 At least now I know the first boss has 100 HP now. Edit:"Real" addresses in WRAM 0x5082, 0x5069, 0x5050
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
SuperMonkeypotato wrote:
Yes, the first fight will require 3 crits without healing, unless you grab the Wiggenweld Grand before the fight. It is in the window going on the first left turn going to the fight. That is the only other thing that I can think of, the only thing that is bad about it is that it doesn't advance RNG during the fight, so you have plan it properly.
Sorry for the silence, but I noticed something about the RNG. The RNG address you found, when frozen to a specific value, gives different outcomes than when changed to said value, but not frozen. Example: Right before the knight boss, I frozed the RNG at 6407 (little endian). The knight attacks Ron and hits 36 damage. I reload the savestate, and this time, change the value back to 6407, before the knight attacks. This time, I don't freeze it at 6407. The knight then hits Ron at 34 damage instead. Both times this was at the first turn, when the Knight strikes first. This also affects criticals; freezing the RNG address at a value may give a crit but does not when it's at the same value, but allowed to advance. Probably something else also affects hits. Edit: Oh, and I also froze the values around the RNG, and this still occurs.
Player (43)
Joined: 1/7/2016
Posts: 51
The silence is fine, something else that I noticed is that, and I don't know if you have tried and tested it; I also haven't any idea of its help, but the frame that you press A to go to the New Game screen changes the RNG value. If press it the first frame possible it gives a certain value, but when pressed on the next frame the RNG count goes up by 1 and when you wait another then goes up by another 1 and so on. Maybe this might lead to something, just thought it should be mentioned
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
SuperMonkeypotato wrote:
jlun2 wrote:
I forgot to post, but the 2nd minigame with Ron seems to be RNG based during Ron's turn. He had different throw distances than the videos linked. Not sure how much time can it saved, but just posting it here.
I noticed that RNG constantly changes throughout his throw, so if you are able to control the distance he throws first throw, then you could manipulate his subsequent throws by changing the frame you throw.
Ok, tried some things: Pressing Up immediately on this minigame will knock Harry down once the gnome lands. This appears slower than pressing A,B,A then Up. I made some tests, using only 1 single Up press Start: 13201 Press Up - 13504 Press A, Up - 13474 Press A,B, Up - 13474 Press A,B,A, Up - 13478 Press A,B,A,B Up - 13484 Press A,B,A,B,A, Up - 13448 Press A,B,A,B,A,B Up - 13424 Press A,B,A,B,A,B,A Up - 13442 Press A,B,A,B,A,B,A,B Up - 13444 The fastest start to finish with Harry seems to be pressing A,B,A,B,A,B then UP. I'm going to try if throwing higher so it doesn't hop makes it even faster. Edit: Holding UP more seems to take longer. Also holding UP so that the gnome doesn't bounce seems to take far too long as well. Also this is probably not what you had in mind about new glitches, but this happened: http://imgur.com/ibT6Dnk Edit2: Nothing related to the TAS, but the furtherest distance I got was 2057:http://imgur.com/YvIO7CJ
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
Hey, while messing around with Harry and Ron, I seemed to have accidentally skipped an enemy's turn. This happened at the first boss fight, where Ron went first, then I tried to flee with Harry. The game was paused a bit, so I pressed "A", and suddenly it was Ron's turn again. I think the first boss is much more approachable now, just let me try and see if I could make something work first. Edit: Nevermind; unfortunately, this does not advance the RNG, so it still won't work since I would only be able to use Ron, and he'll end up out of MP. I mean, of course unless using only Ron to cast Flipendo 17+ times while Harry skips the turn over and over ends up being faster. lol In other words, right now, if I get the knight to 2 more hits left, it appears I'm left with only Harry. Allowing Ron to live would work, but ends up using Flipendo since Harry has to keep skipping turns. Maybe advance the RNG with Flipendo? IDK. Edit 2: http://tasvideos.org/userfiles/info/35962672901060452 Quick input file where I used this trick + Flipendo to advance the RNG so Ron could crit the knight. It works, but I'm not sure if it would be faster than to heal.
Pokota
He/Him
Joined: 2/5/2014
Posts: 779
Encode for those who won't go grab it: Link to video
Adventures in Lua When did I get a vest?
Player (43)
Joined: 1/7/2016
Posts: 51
jlun2 wrote:
http://tasvideos.org/userfiles/info/35962672901060452 Quick input file where I used this trick + Flipendo to advance the RNG so Ron could crit the knight. It works, but I'm not sure if it would be faster than to heal.
This is a good start, the only real issue with this that we need to have Ron not die as well because he needs to be able to cast during the next fight, though he could be healed in Diagon Alley at the healing shop, costs a good chunk of frames to do that though. There are a few ways that this fight has to go, which is unfortunate but this is how it has to be, we need to somehow when the fight without either one dying without healing, get the Wiggenweld Grand that is in the pathway to the fight and heal with that, or get the Revive Potion in Knockturn Alley and use that. Of all of these solutions, the Revive Potion might be the fastest for the fight, even though it takes way more frames to get overall, but it may save manipulation frames for the fight, not sure if it is enough to counteract the amount spent to get it though. The Wiggenweld Grand is second fastest, just because it does heal though anything other than casting does not advance RNG, which is annoying just like how skipping an enemy's doesn't. The thing with the Wiggenweld is that might end up being the fastest method just because it isn't too far out of the way and it may be easier to manipulate the fight with it even though it doesn't advance RNG. And that of course leaves us with going through the entire fight trying not to heal, which is the fastest in getting to the fight but not necessarily the fastest for the fight itself, and still even then you may have to wait frames in the overworld just to get the right RNG seed for the fight which may cost more frames than it saves. So even though this obviously what we are going for, it just is really hard to get the right fight setup.
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
http://tasvideos.org/userfiles/info/36050262009454538 I believe I did it. This beats the boss in 5 turns, with both alive. However, attempting to optimize the input causes the last hit to land 13 rather than 28. I'm worried it may be some desync, given the RNG appears to be the same, so can you please check if this syncs for you? Edit: Delaying the last "A" press also changes the hit from 28 to 13 for some reason.
Player (43)
Joined: 1/7/2016
Posts: 51
jlun2 wrote:
http://tasvideos.org/userfiles/info/36050262009454538 I believe I did it. This beats the boss in 5 turns, with both alive. However, attempting to optimize the input causes the last hit to land 13 rather than 28. I'm worried it may be some desync, given the RNG appears to be the same, so can you please check if this syncs for you?
I tried to optimize stuff, and I have the same issue with trying to optimize it that you do. End up that up with the 13 instead of the 28 we get if we don't mess with it. So just leave it be I guess. Annoying, but that's how it is for now. Even though there are a ton of frames that could be saved by optimizing everything. But we carry on for now. The next little while should be easier for now. Edit: So we have both of them at level 4, which should make the next fight easier. The next things needed some crits because there has to be some MP management.
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
I'll see if optimizing the input, but pressing "A" on Harry at the same frame as the movie would allow the "28" to occur. Also, can you please check if there's some 2nd RNG affecting this? Edit: It doesn't work; even if the last "A" press is the same frame, changing the previous A makes it 13. Changing 0x00F8 in WRAM ~5 frames before 0BCA (damage dealt) is set changes to 13. Although the addresses around it seems to be for sprite animation. I suspect its the frame that changes 0x0BCA that's responsible, since if the hit changes it at frame 26166 it hits 28, but it hits 13 at other frames. Edit 2: Nevermind, landed a different hit at 26166 and it was 13. Edit 3: Brute force check every frame naively by delaying 1 frame then pressing "A"
Language: lua

memory.usememorydomain("System Bus") local frame_start = emu.framecount() local state = {"Checklag","Wait","Reload","Fix","Done"} function waitframe(frame) while (frame >= 0) do emu.frameadvance() frame = frame-1 end end --[[ algorthim for checking rng start before land hits 1. save state at enemy select 2. press "A" not on lag frame 3. wait 200 frames and see if crit 4. reload save 5. advance frame 6. repeat ]]-- --0BCA local damage_dealt = 0 --needs to be outside loop so it won't get reset while true do local frame_now = emu.framecount() local frame_dif = 0 --difference between this frame and start frame local statenow = state[1] savestate.saveslot(1) while statenow == state[1] do frame_now = emu.framecount() --C3A1 at 37 == cursor gone. 36 == cursor here savestate.saveslot(1) console.log("Reached 1 "..emu.framecount()) if memory.readbyte(0xC3A1) == 37 then --just in case statenow = state[2] break end if memory.readbyte(0xC3A1) == 36 then joypad.set({A = 1}) emu.frameadvance() statenow = state[2] break end emu.frameadvance() end while statenow == state[2] do console.log("Reached 2") waitframe(5) if memory.readbyte(0xC3A1) == 36 then --the enemy select cursor still exists, something went wrong with state1 statenow = state[4] break else waitframe(200)--200 if you want to crit, 400 for npc statenow = state[3] break end end while statenow == state[3] do console.log("Damage: "..memory.readbyte(0x0BCA,"WRAM").." prev "..damage_dealt) if damage_dealt == 0 then damage_dealt = memory.readbyte(0x0BCA,"WRAM") elseif damage_dealt == memory.readbyte(0x0BCA,"WRAM") then frame_dif = frame_dif + 1 savestate.loadslot(1) emu.frameadvance() statenow = state[1] break elseif damage_dealt ~= memory.readbyte(0x0BCA,"WRAM") then console.log("Done. Frame pressed at: "..frame_now.." Started at frame: "..frame_start) console.log("You waited "..frame_now-frame_start.." frames") client.pause() statenow = state[5] break else console.log("IDFK?") client.pause() statenow = state[5] break end end while statenow == state[4] do --something went wrong with state2, go try reload console.log("Reached 4") savestate.loadslot(1) emu.frameadvance() joypad.set({A = 1}) emu.frameadvance() statenow = state[2] break end while statenow == state[5] do emu.frameadvance() end emu.frameadvance() end
Edit: Made the script take account into damage and damage from previous delay, in case some other goal is in mind.
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
1. If you entered Hagrid's hut, then left, it becomes day. 2. It seems the cutscene right after the Willow fight can be triggered (by cheats), allowing the story to progress without fighting said boss. 3. Unlike the first game, you're severely low level, so I might need to test if deathwarping would help, since in empty classrooms, things like the knights kill you in 1 hit.
Player (43)
Joined: 1/7/2016
Posts: 51
I know that dying in Herbology class sends you back to the beginning of the back of the greenhouse (I know that sounds weird, but it is true) so we could die after the 3rd mandrake fight after taking some decent damage from it, so that will save a lot of movement time, there are some creatures that are faster than you and deal good damage. Other than that the only other place that I know of saving movement is in the garden, but the problem with that is that you level after the boss fight there, and with the way that I routed the movement in there you shouldn't take a death, unless there happens to be faster way to do all of that. I don't think that any other spots would be of use to death warp for because it would be slower, there are either faster ways of moving or you would have to take out multiple people against creatures that are slower than you while manipulating 0 rolls or not fleeing when attempting to. (though that might be faster, depending on the situation, I might just be missing something)
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
Alright. I'm also curious if other languages may be faster, but I have no idea how much dialogue would be encountered in the case new skips would be found.
Player (43)
Joined: 1/7/2016
Posts: 51
I know that if there was a JP release, like there is for Sorcerer's Stone, then that would be the fastest. But other than that I have not done any kind of testing for language difference.
Skilled player (1742)
Joined: 9/17/2009
Posts: 4986
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
Hey, sorry for the silence. I'm having some trouble at the moment, since it seems: 1. For this particular section, if the NPCs (or Harry) hits 0, it does not appear to be able to make it critical 2. I level up after the turtle, so I get fully healed. The mandrake hits ~25, and ~50 for normal hit and crit respectively. To make it such that the next time Harry encounters an NPC kills him, I need the following: *Mandrake hits normal hit + crit *Harry lands 1 normal hit + 2 crits Point 1, along with rather terrible luck makes this section tricky. And by terrible luck I mean waiting 300+ frames for each crit. Might have to check how long would a somewhat "ideal" non-deathwarp route would take then see how much waiting is possible before it ends up slower. Sorry about that.
Player (43)
Joined: 1/7/2016
Posts: 51
Okay, so I know that this may take a little more time than initially thought, but have we tried doing the movement to the class differently to get another RNG value at the start? I know that might make things take a tad longer, but it may be able to help ease this section.
Player (43)
Joined: 1/7/2016
Posts: 51
Just an update since the thread hasn't been updated in a bit. http://tasvideos.org/userfiles/info/37787688677426503 This is up through the Crabbe and Goyle fight. Thought that I would update since there hasn't a post in the thread in a while.
Pokota
He/Him
Joined: 2/5/2014
Posts: 779
Adventures in Lua When did I get a vest?
Player (43)
Joined: 1/7/2016
Posts: 51
https://www.youtube.com/watch?v=oT6xLMDaq1Y&t=2476s (changed put wrong video somehow...) I know that this isn't a proper encode, but this is the recording that I made for the TAS. After going through it a few times in the last week or so, I did find some noticeable improvements. This is the input file for it. http://tasvideos.org/userfiles/info/37878563935691611 Firstly, Herbology could be done in a different way, probably meaning different movement to the class to change RNG. What can be changed is a faster deathwarp at the end, but despite my best efforts and multiple different types of movement out of the last Mandrake fight, the result that I got was what I had to work with. Basically all of the Quidditch can be done faster by getting slightly better RNG for so that you don't have to sit in a spot and wait for the Snitch to come to us, or at least that is how I feel, maybe all of them are fine and I am thinking that something is wrong. I do find Quidditch 3 my favorite, in the submitted file it starts at around frame 147250 and in the video it starts at 41:05. Garden fight can be done faster, didn't feel like spending 100's of frames trying to get crits at the time so I ended up neglecting to attempt Hermione getting them after Harry casting after each attempt, so that can be done faster in two different ways. I don't know if it can be done, but Nick Skip could potentially be done faster though in my best efforts I always missed the mark just barely every time I tried something different then I just did RTA method, so I don't quite know if that can be done faster or not. At the Deathday Party there a wonderful game of Bowling that we play. Here there are a few things that should be considered: When Harry gets a strike or a gutter ball, he has an extra animation. There is a lot of lag in this game, so we need to minimize this as much as possible while still doing things as fast as possible (obviously). Despite strikes having an extra animation, they let us not have to throw another ball (head in this case) so it is slightly faster than going for two non strike throws. So essentially this game is all about getting strikes while having the least possible amount of lag. For my result of this game, I do get strikes for the first 9 sets and the last set have 1 throw hit as many pins as I can get with the least amount of lag and the last throw hit nothing. There is some room for improvement with the lag and trying not to have to move around so much, both Harry and the ball. The only other thing that is worth noting, but should be obvious, is just some better RNG manipulation for having to wait less frames between criticals or having certain things happen faster in fights or things not happen at all. Happening faster being the break free of Aragog's stun, which was rather fast but could be faster if both are freed. Certain things not happening are Garden boss not stunning, which didn't happen in the submission, and Lockhart not curing his poison, which isn't done either and shouldn't have to be worried about as that is the whole point of the fight to begin with.