Castlevania Dungeon Forums

The Castlevania Dungeon Forums => General Castlevania Discussion => Topic started by: TheouAegis on May 12, 2016, 12:17:55 PM

Title: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: TheouAegis on May 12, 2016, 12:17:55 PM
I hated crows in CV1. Not because of their annoying flight pattern (fly straight toward you, then swoop up or down toward you, then repeat, then fly off the screen), but because of the fact that they flew straight at you unnaturally. Well, I was reading the code and that is exactly what the code tells it to do.

...Except that wasn't what the code intended crows to do.

Code: [Select]
//Check if crow has flown horizontally past Belmont
$886E:A9 08     LDA #$08                   
$8870:BC F8 04  LDY $04F8,X @ $0501 = #$01
$8873:F0 0B     BEQ $8880                 
$8875:49 FF     EOR #$FF                   
$8877:6D 8C 03  ADC $038C = #$80           
$887A:DD 8C 03  CMP $038C,X @ $0395 = #$77
$887D:B0 09     BCS $8888                 

//Find out if Belmont is above or below the crow
$8888:20 9A 87  JSR $879A                 
$879A:A0 00     LDY #$00                   
$879C:AD 54 03  LDA $0354 = #$4C           
$879F:DD 54 03  CMP $0354,X @ $035D = #$75
$87A2:B0 01     BCS $87A5                 
$87A4:C8        INY                       
$87A5:98        TYA                       
$87A6:9D DC 04  STA $04DC,X @ $04E5 = #$01
$87A9:60        RTS                     

//Set the HORIZONTAL speed to 1/2
$888B:A9 00     LDA #$00                   
$888D:A0 80     LDY #$80                 
$888F:20 DF EC  JSR $ECDF                 
$ECDF:9D FC 03  STA $03FC,X @ $0405 = #$01
$ECE2:98        TYA                       
$ECE3:9D 18 04  STA $0418,X @ $0421 = #$98

See that second half? The crow checks its vertical relation to Belmont and then sets its horizontal speed. The programmers called the wrong subroutine! At this point in the code, the horizontal speed had already been set, hence the check if the crow had flown past Belmont yet.

If you want to see how the game was meant to run, open up the Japanese ROM of CV1 (addressing may be different in the US or PAL versions), jump to address 0148A0 which should be set to DF and change it to 57. Then set address 0148A1 which should be set to EC to ED.'

It will still fly straight toward you, but now it won't just fly backwards off the screen. It will swoop much more often, even if its pattern is still seemingly erratic.

UPDATE In the US version of Castlevania, you only need to change 0148A0 which should be 4E by default to C6 (if I read it correctly).
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: XombieMike on May 12, 2016, 05:20:25 PM
I don't know how to do any of that, but it sounds great. I'd like to see a video of it. Did you discover this? That's really cool, man!

I bet the programmers just left it like that thinking they are fine as unintended.
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: TheouAegis on May 12, 2016, 06:00:41 PM
If you have a hex editor, you can open the ROM (if you have a ROM) in the hex editor, go to the address I said, and do the changes. If you have the FCEUX emulator, open the ROM, open the built-in hex editor, change the view to PROM or whatever it's labeled as, find the address I said, and do the changes.

If you want to see what bug I'm talking about, get to the 3rd level (where you first meet Fleamen) and climb the first set of stairs. Inch forward until the first Crow appears. Duck at the edge of that ledge until the Crow swoops down. It should stop at about foot level. Wait for it to start to fly toward you, then fall off the ledge before the Crow hits you. Now stay where you are ducking the whole time. The crow should swoop down and stop just above your head. It will then start flying back and forth without hitting you. After 2 or 3 passes, it will just fly straight off the screen.

My fix will prevent that last glitch from ever happening.
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: Ratty on May 13, 2016, 06:53:19 AM
Huh, fascinating. I actually always liked the fact that the crows didn't dive bomb as much as they did in some of the later games (Bloodlines is the one that comes to mind) and if you were just able to dodge them long enough they would fly away. Seemed like great design to keep them from being too cheap or annoying. I guess that's what you call art through adversity! Or maybe even accidental art.
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: TheouAegis on May 13, 2016, 10:06:15 AM
Well the good news is that it still doesn't move naturally and it's very likely to miss you even at that point. When I tested the corrected code, instead of flying backwards off-screen (see, that's what really irked me about the code - it flew BACKWARDS!), it swooped down below Simon and then around to the other side. If I remember right, it came really close, but I think it stopped in whip range.

At least Crows go POOF when they hit you, rather than hounding you indefinitely.
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: Inccubus on May 13, 2016, 08:12:50 PM
Really nice find.
If it's alright with you I'm going to turn it into IPS patch so people can use it more easily.

I tried it out and if anything they seem to be a little easier to deal with if you are patient and don't rush in.
They can be a handful if there are several of them or there are other enemies forcing you to move around, but it's still way more organic than before.

I can't seem to find the code in the "(USA) Rev A" version, any ideas?
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: TheouAegis on May 14, 2016, 12:54:09 AM
I think I used an unedited USA rom. I was pretty sure the pointer in the ROM data itself was in the same location, just the location of the routine had changed.

Just locate this code in the ROM:

4EECA979A0044C10EDDE4C05D0034CB5

And change it to this code:

C6ECA979A0044C10EDDE4C05D0034CB5


More 'accidental art' for Ratty:
The giant bats just before fighting Dracula have a bugged code as well. Rather than recycling the bat boss' code, new code was written up. It has two typos in it. I fixed them, but the difference when you actually run the game is pretty negligible. You wouldn't know the code was changed even with side-by-side comparisons.
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: MooMilk on May 14, 2016, 10:33:05 AM
I too also vote for a youtube video. You might wanna show people your discovery.
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: TheouAegis on May 14, 2016, 11:39:46 AM
Inccubus, add this to your patch:

For the Japanese version, jump to address 0153B0 and paste this in:

A5029DE003A900A0C020DFEC4CC093A6
4EA40220DFECA9009DC403A9C09DE003

For the US version, jump to the same address and paste this in:

A5029DE003A900A0C0204EEC4CC093A6
4EA402204EECA9009DC403A9C09DE003


That will take care of the typo in the Giant Bats.But like I said, it's a minor difference - the bat's still going to move diagonally, just along a slightly different vector.


Update: The lesser vampire bat's whole code is a bit of a mess - almost like they wrote it up near the end of the game as an afterthought and they ran out of energy drinks.
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: Inccubus on December 04, 2019, 06:58:57 PM
Sorry for the necro bump, but I wanted to say that I never did find the correct code in the USA version.
But in the mean time I'm going to make that IPS I promised ages ago and get it submitted to ROMHacking.net
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: Jorge D. Fuentes on December 07, 2019, 10:44:43 AM
For the love of all that is good and wholesome, make a video!
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: Gaawa-chan on December 12, 2019, 12:42:11 AM
Speaking of the original Castlevania,
https://www.youtube.com/watch?v=AtDUnJCoTb8 (https://www.youtube.com/watch?v=AtDUnJCoTb8)

But seriously, would be cool if we could see a video of this.
Title: Re: Oh. My. God. Game-breaking bug in CV1 crow's code!
Post by: Inccubus on December 15, 2019, 09:54:44 PM
Didn't have access to a computer for a long while, but sure.
I'll see if can get one up.