Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
Guest

Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Post by Guest »

Hi everyone, I hope it's okay to ask one thing that I'm curious about, I apologize if anything here sounds too dumb.

For some reason, the offical English translation of Kid Dracula, extracted directly from the game data, will not run on any other emulator (e.g. on fceux it will hang on grey screen), and it is the only rom from Castlevania/Contra Anniversary Collections that has this problem.

Both English and Japanese versions have the same size and header (the NES roms inside the gamedata archive are already headered), but the Japanese one seems to run just fine on any emulator.

Capture-1.png

Interestingly enough, the dump of Kid Dracula that is currently in the No-Intro database is not the same (it was presumably dumped from RAM), it's bigger and is actually playable on other emulators.

Capture-2.png

Side note: the No-Intro dump is apparently incomplete and will softlock during credits.
To quote a user from Reddit:
The "dump" is "incomplete", so to speak. The reason it softlocks is because it's trying to read SRAM which is missing near the very end. I don't know how whoever extracted the ROM missed that. I was able to extract the missing SRAM from the Castlevania collection and put it back into the game with a hex editor and it works perfectly.
On the left is the original No-Intro rom, and on the right is the same rom after fixing.

Capture-3.png

So, why exactly the 384KB one dumped from RAM will boot on other emulators, while the "properly extracted" clean 256KB rom won't, and could it ever be possible to use that clean rom without modifying it?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Post by lidnariq »

There's really too many variables to say what could be going wrong with the 256KB dump you've extracted. My only suggestion is sitting down with the debugger in Mesen or FCEUX and see if you can figure out why it's crashing.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Post by Dwedit »

Kid Dracula should be 384kb, not 256kb? Probably an underdump of some kind.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Guest

Re: Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Post by Guest »

The original Japanese Boku Dracula-kun is 256KB, no?
Either way, that's how this English rom is actually stored in the filesystem (all of the emulator's data and roms are packed into a single compressed/encrypted archive that can be unpacked).
If it's an underdump then it looks like this is how the devs actually intended it to be in there, although I'm not sure why.

Unfortunately, I'm not really knowledgeable about NES stuff myself…
I would try using a debugger, but I'm afraid that I wouldn't really understand anything.
The best I can do is examine the difference between those roms visually, using a hex editor.

From what I can tell, the PRG ROM data in the 256KB dump is identical to the first half of 384KB's PRG ROM, and the CHR ROM data is also identical, so the only difference is the second 128KB of PRG ROM, it seems?
Though, I'm not entirely sure where that data came from, as I don't see it in the memory while the application (Castlevania Anniversary Collection itself) is running.
To be exact, I can see in memory only the first 0x1200 bytes of that data, preceded by the word "SRAM" (original Japanese cart didn't have SRAM, did it?).

I'm sorry, I feel that nothing of what I'm saying makes any sense…

Thank you for your replies, I'll try to look for more information. :oops:
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Post by NewRisingSun »

I had previously posted a long explanation, but decided to rescind it until I have access to both the original .NES file, as it is included in the collection, plus the original .SAV file, also as it must be included in the collection.
Guest

Re: Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Post by Guest »

Well, I was lucky to read that explanation, and I would really like to thank you for this, NewRisingSun!

I hope you won't mind if I still reply to that. ^^

Indeed, the rom included in the collection (filename "kid-dracula.nes") has CRC32 of 64AFD592 without header and CRC32 of PRG-ROM is C24B972C.

To be honest, I don't really know how the 384KB one was actually dumped. :P
It was just a dumb guess based on the fact that there was no convenient ways to extract the archive's filesystem at the time the dump first appeared.
Now I see that it doesn't really matter whether one extracts it from the archive or dumps it from RAM, because even in the RAM only the same "bad" PRG-ROM data can be found, so it'd still has to be fixed the way you described.

By the way, the data with CRC32 D2955961 is actually the one that was reported on Reddit to have that minor problem with softlocking during credits, the "fixed" one (3d screenshot in the original post) should have CRC32 82A98993.

I haven't actually seen any kind of .sav or anything similar among extracted files, but I could have missed it, though.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Post by NewRisingSun »

I now have extracted the "alldata" archive myself, using the method you linked to, and am now searching for the .SAV data. Should I be successful, I will posted an updated explanation.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Post by NewRisingSun »

Having extracted both the original translation's game ROM file as well as the .SAV file from the Collection, I can now post my updated analysis with certainty.

The correct ROM file of the translated English version of "Kid Dracula" Famicom, that debuted with the Castlevania Collection, can be found in the Collection's directory tree as "system\roms\kid-dracula.nes". The .NES file with header has a CRC32 of 68047B59. There are 128 KiB of PRG-ROM (CRC32 C24B972C) and 128 KiB of CHR-ROM (CRC32 2BC4EF48), for a total of 256 KiB of ROM data without header (CRC32: 64AFD592).

However, this ROM file does not contain all the game needs to run. Because the translators could not fit everything into 128 KiB of PRG-ROM, they abused the CPU $6000-$7FFF range to store additional translation data. The game code reads from this address any time that text is printed, yet never writes anything there. The correct data is instead loaded from an SRAM .SAV file, which is why the file has the "battery" header bit set. The .SAV file does not exist directly in the Collection's directory tree, but is created when the game is launched by the Collection's menu scripting engine. The script that does this lies in the path "073\script\title_standalone.nut", starting in line 107 ("m_sram_data ="). This correct SRAM file has a size of 8,192 bytes (as usual) and a CRC32 of ABA5001B.

The correct "Kid Dracula" NES file, as extracted from the Collection with the CRC32s listed above, will run perfectly when the correct SRAM file is provided to the emulator. Without that SRAM file, the game cannot function.

Now, for the No-Intro .NES ROMs.

There is a 384 KiB .NES ROM file (headerless CRC32: E3A1CE4D) with 256 KiB of PRG-ROM (CRC32: 9DFE63BB) and 128 KiB of CHR-ROM (2BC4EF48). This means that the PRG-ROM is twice as large as it should be. The first half matches the PRG-ROM found in the correct ROM file, as extracted from the Collection. The second half is the same with two changes:
- It replaces the first 4,626 bytes with SRAM data that would be copied to $6000.
- It replaces the unused space in the fixed 8 KiB bank at PRG-ROM offset 1FFA8/3FFA8 with code that performs said copying to SRAM, and modifies four bytes at PRG-ROM offset 1FCC2/3FCC2 with a jump to that position.
With these changes, the game can now run without the SRAM file provided to the emulator. The ROM had to be doubled in size because there was no space to put the 4,626 bytes of SRAM data in there. This changed, or "SRAM-initialize fix" ROM, is in No-Intro. As "redunka" has pointed out, it still has one problem: The SRAM data in this file was somewhat incomplete, leading to a glitch in the ending credits. A second 384 KiB .NES ROM file (headerless CRC32: 166C2418) was posted by "farmerbb" in the Steam forums thread linked to by "redunka", which corrects that glitch. It is therefore an "SRAM-initialize fix, fixed ending".

Finally, there is a "trimmed" ROM floating around the internet that is 256 KiB in size, 128 KiB PRG (CRC32: D2955961) plus 128 KiB CHR, headerless CRC32 927DD49F. The trimming it did was to discard the first 128 KiB of PRG-ROM of the full "SRAM-initialize fix" and only keep the second half. This works for a while, until the original PRG-ROM bank 0 is accessed, at which point the game will behave erratically. I don't know when exactly this is, but in any case, this ROM can only be considered "bad".

To summarize:

Code: Select all

PRG-ROM Size&CRC	CHR-ROM Size&CRC	Headerless Size&CRC	Meaning
128 KiB, C24B972C	128 KiB, 2BC4EF48	256 KiB, 64AFD592	Original ROM, requires SRAM file (8 KiB, CRC32 ABA5001B) to function ("[!]")
256 KiB, 9DFE63BB	128 KiB, 2BC4EF48	384 KiB, E3A1CE4D	SRAM initialize fix with glitched ending ("[f1]")
256 KiB, CDC2B349	128 KiB, 2BC4EF48	384 KiB, 166C2418	SRAM initialize fix with fixed ending ("[f2]")
128 KiB, D2955961	128 KiB, 2BC4EF48	256 KiB, 927DD49F	"Trimmed" SRAM initialize fix with glitched ending, bad! ("[f1][b]")
I'm tired.
Edit:typo.
Last edited by NewRisingSun on Thu Jan 09, 2020 1:42 am, edited 1 time in total.
Guest

Re: Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Post by Guest »

I can't thank you enough for such an amazing writeup explaining every little aspect of this case!

The only thing I can add here (even though it might be not that important) is that it's come to my attention that there's apparently at least one more dump floating around the web.

It's also 384KiB in size, CRC32 without header is 394AC7B2.
The first half of PRG-ROM is C24B972C again, while the second half is 075D2ABE this time, but it's actually identical to the glitched one with CRC32 D2955961 (the only difference is that the "Lemmy" string near the end is replaced with FF's.
What's the most interesting thing about this rom is that the CHR-ROM is modified here, so its CRC32 is 230F08D3 and it seems to be a decensor hack: it restores manji symbols on bosses' heads, although they are missing in this collection's re-release of the Japanese version too.

Apparently, that uncensored hack originated from the same 4chan thread where the "SRAM-initialize fix" ROM came from, except it originally still had that "Lemmy" string near the end of PRG, so CRC32 of its PRG is 9DFE63BB once again (SRAM-initialize fix with glitched ending), and CRC32 of full headerless ROM is EB6A29D6.

Oh, and I'm not sure if the "fixed" 384KiB rom with CRC32 166C2418 was ever posted in the Steam forums (it shouldn't even be allowed there), I believe it was originally posted on Reddit by a user "CnRM", I'm not linking it here because of the copyrighted content, but it shouldn't be hard to find.

I apologize for bothering you this much, and thank you so much again, now that I've got a proper .sav file from that script I can finally play the clean unmodified dump. ^_^

Very late edit: added some more info regarding the hack with restored graphics.
NewRisingSun
Posts: 1510
Joined: Thu May 19, 2005 11:30 am

Re: Kid Dracula from Castlevania Anniversary Collection - incompatibility with emulators

Post by NewRisingSun »

I am reviving this old thread to share a related finding: the translation would not work as-is on an original VRC4-chip-bearing donor board even if one were to either initialize the battery-backed SRAM properly or were to replace it with an 8 KiB ROM chip containing the necessary data. Why?

Because it was recently discovered that the VRC4 ASIC has a WRAM enable bit, similar to the MMC3's. I have verified on another cartridge (Parodius da!) that when the bit is disabled, CPU $6000-$7FFF reads return open bus even if the circuit board has WRAM. And of course, this game disables that bit, since the original Japanese version did not have WRAM. The official translation relies on pre-filled WRAM content being readable, yet still contains the $9008 write that disables the bit.

I have created an IPS patch that changes the game's initialization code to set the WRAM enable bit. Should you want to put the official Kid Dracula on a VRC4-with-WRAM donor board, you will need to apply this patch to the ROM content first (in addition to figuring out a way to ensure that WRAM is pre-filled with the correct content, one way or the other).
Attachments
Kid Dracula (Castlevania Anniversary Collection)[WRAM enable].ips
(18 Bytes) Downloaded 233 times
Post Reply