CopyNES - Works great! :)

Discuss hardware-related topics, such as development cartridges, CopyNES, PowerPak, EPROMs, or whatever.

Moderator: Moderators

Great Hierophant
Posts: 780
Joined: Tue Nov 23, 2004 9:35 pm

Post by Great Hierophant »

I recall there being two versions of RC Pro-Am, one with an MMC1 and the other with an A*ROM board.
User avatar
kevtris
Posts: 504
Joined: Sat Oct 29, 2005 2:09 am
Location: Indianapolis
Contact:

Post by kevtris »

Great Hierophant wrote:How does CopyNES detect how many KB of ROM there is inside a cartridge (if it does)? For example, the TLROM board, by far the most common among the MMC3 boards, has a maximum size of 512KB PRG and 256KB CHR. No TLROM game that I know maxes out the board. If the game has 256KB of PRG, for example, will CopyNES return a ROM larger than 256KB? If so, what will the extra 256KB show? A mirror of the lower 256KB, all 0s or 1s, or random reads?
Several methods are used.

The first method (if there are multiple PRG/CHR banks available) is a simple compare operation. CopyNES will set up two PRG banks that are a ROM size multiple apart, then do a complete compare. The code checks from small to large generally, in binary steps. i.e. 32K, then 64K, 128K, 256K, and finally 512K for MMC3. It then checks for WRAM by enabling it and then reading location 6000h, then writing data to 6000h twice, checking to see if the value changed indicating RAM. It writes something like aah then 55h or something to make sure it's really RAM. Then it finally writes that byte back so as not to corrupt the saved game.

Then it dumps CHR in a similar fashion to the PRG with the size determination.

---

For other kinds of carts (i.e. AMROM) where there is just a single 32K PRG bank, it will CRC-32 one of the banks and then CRC banks on even binary boundaries to determine the size.

CNROM is kind of a special case, since on some carts, if you map in like bank 2 or 3, it will result in open bus on the PPU since it totally unmaps the ROM. I check for a "magic" CRC value in this case, to detect this condition and return the size accordingly.

So that's the very super basics. :-)
/* this is a comment */
Great Hierophant
Posts: 780
Joined: Tue Nov 23, 2004 9:35 pm

Post by Great Hierophant »


The first method (if there are multiple PRG/CHR banks available) is a simple compare operation. CopyNES will set up two PRG banks that are a ROM size multiple apart, then do a complete compare. The code checks from small to large generally, in binary steps. i.e. 32K, then 64K, 128K, 256K, and finally 512K for MMC3. It then checks for WRAM by enabling it and then reading location 6000h, then writing data to 6000h twice, checking to see if the value changed indicating RAM. It writes something like aah then 55h or something to make sure it's really RAM. Then it finally writes that byte back so as not to corrupt the saved game.
I see, so you begin by comparing ROM bytes 0-8191 (0-1FFFh) with bytes 16383-24575 (3FFFh-5FFFh). If the two banks do not differ, then you have a 16KB game, the commercial minimum for NES/Famicom games. If they differ you have more game code to dump and compare banks of a greater order of magnitude.
gannon
Posts: 162
Joined: Sun Nov 20, 2005 9:38 pm
Contact:

Post by gannon »

Just got my stuff in today. Now I need to decide whether to assemble it now, or make pie instead :P
Post Reply