PacManPlus, on Thu Oct 12, 2006 6:25 PM, said:
Hi:
I am trying to figure out what the last 8 bytes in a ROM image specify and I am having some trouble. Can someone help me?
For example, Ms.Pac-Man has the following bytes:
$FF
$C7
$4D
$F3
$20
$CA
$1C
$F4
I believe the $FF and the $C7 mean something as $C7FF I would imagine, because I know that $CA20 is the entry point to the program (the 5th and 6th bytes reversed).
I just cannot figure out what the $4D, $F3 and the $1C, $F4 mean.
Thanks in advance for your time.
Bob
As everybody else has already said, the last six bytes are the standard 6502 reset/IRQ/NMI vectors, low byte first. I seem to recall that NMI is generated by the Maria, and IRQ is generated from the cartridge slot.
$FFF8 and $FFF9 have special meanings. I'm looking at the documentation from my sign7800 program, and here's a quick summary:
$FFF8 is used for the region checking. The high 4 bits must always be set ($Fx), and on a US machine (EDIT: apparently this is not true!), the low bit must be set. Presumably there is no region check in the PAL version, but I would have to check. - - - Hmm, I just checked my disassembly where I merged in the NTSC source where possible, and it checks the same bit in PAL.
$FFF9 is used for the signature check and for the rainbow ATARI screen. The high 4 bits are the high nibble of the lowest address in the digital signature range. The ROM is hashed from that address to $FF7F, then the hash is run through the crypto routine. This should not include bank-switched memory, so in larger games this will be $Cx, $Dx, $Ex, or $Fx. The higher this number, the faster the startup, so just 4K ($Fx) is optimal. The low nibble must be $x3 or $x7. $x3 will disable the rainbow ATARI, but the game won't start up any faster.
And the reset/IRQ/NMI vectors MUST point into the address range that is checked for the digital signature.
REGION EQU $FE ;MASK FOR COUNTRY
...
LDA $FFF8 ;CHECK FOR REGION VERIFICATI...
ORA #REGION
CMP #$FF
BNE BADCART
LDA $FFF9 ;SEE IF MARIA SIGNATURE EXIS...
AND #$0B ;$07 OR $03 VALID
CMP #$03
BNE BADCART
LDA $FFF9 ;GET BOTTOM OF CART ADDRESS
AND #$F0
STA CARTBOTM
STA CSCMOD0+2-CODEDIF;SET UP FOR START OF CHECKSU...
CMP #$40 ;MAKE SURE IT IS NOT TOO LOW
BCC BADCART
Edited by Bruce Tomlin, Fri Oct 13, 2006 5:03 PM.