nesdev.com
https://forums.nesdev.com/

Question about the SNES reset vector
https://forums.nesdev.com/viewtopic.php?f=12&t=16602
Page 1 of 1

Author:  melanokardios [ Fri Oct 20, 2017 4:37 pm ]
Post subject:  Question about the SNES reset vector

I'm wondering how the SNES finds the reset vector in my ROM file. I understand that the 65816 processor looks at the last 16 bytes for the reset, NMI, IRQ, etc. addresses(both for emulation and native mode).

I have written a little program, that will load some sprite data into VRAM, set some registers, and display a sprite. This is working fine. But here is what I don't understand: I made my ROM 32 kilobytes in size, the idea being that I (for now) have only one bank to deal with(so my ROM's $0000 - $7FFF are mapped to $00:$8000-$00:$FFFF). Now, I wrote the address of my reset routine ($21b5 + $8000) to the emulation mode reset vector at $7FFC and $7FFD of my ROM.

Now, when I load my ROM into a emulator and look into the memory debugger, I see that my reset vector is (mirrored?) at $FF:$FFFC and $FF:$FFFD. This is confusing me, how does the SNES know how to map/mirror $00:$7FFC to $FF:$FFFC? Again, the ROM is running fine and showing all the sprites I draw exactly the way I want them to show.

Thing is, I was planing to burn this ROM on a EPROM and try run it on a console, since I did that on a NES in the past for fun. If I've understood the SNES specs correctly, the smallest possible EROM size is 1 Mbit, so I'd have to mirror my ROM four times to fit into a 1Mbit EROM nicely. Yet how does the SNES find my reset vector?

EDIT: I assume it has something to do with the Map Mode($FFD5) set in the header, yet it eludes me.

Author:  93143 [ Fri Oct 20, 2017 4:57 pm ]
Post subject:  Re: Question about the SNES reset vector

It doesn't. It just checks $FFFC in bank $00, and it's the cartridge's job to ensure that the correct memory is mapped there.

Author:  melanokardios [ Fri Oct 20, 2017 5:03 pm ]
Post subject:  Re: Question about the SNES reset vector

Thank you for your quick reply! I just found a document showing that the SNES will on reset "Jump to the address indicated by Reset Vector (00FFDH, 00FFCH)". Now off to some joypad input and movement :)

Author:  lidnariq [ Fri Oct 20, 2017 5:15 pm ]
Post subject:  Re: Question about the SNES reset vector

A SNES ROM image is easily well-defined for any power of two in size; for the ones that are 32 KiB and smaller the map mode doesn't matter.

Author:  dougeff [ Fri Oct 20, 2017 5:29 pm ]
Post subject:  Re: Question about the SNES reset vector

Quote:
Reset Vector (00FFDH, 00FFCH)


00fffd, you forgot an f.

Also, this is actually at position 007ffc-d of the ROM, due to the way ROMs are always loaded to 8000-ffff in the memory map. (At least for LoROM)

Quote:
how does the SNES know how to map/mirror $00:$7FFC to $FF:$FFFC?


This is my very dumb answer. One of the pins isn't connected. A15. Maybe one of the smart kids can explain it better.


Edit. Bazz explains it here...

https://www.cs.umb.edu/~bazz/snes/cartridges/lorom.html

"The 32K gets mapped twice for the whole 64K, because of the A15 ordeal."

Author:  melanokardios [ Fri Oct 20, 2017 5:41 pm ]
Post subject:  Re: Question about the SNES reset vector

dougeff wrote:
Quote:
Reset Vector (00FFDH, 00FFCH)


00fffd, you forgot an f.

Also, this is actually at position 007ffc-d of the ROM, due to the way ROMs are always loaded to 8000-ffff in the memory map. (At least for LoROM)

Quote:
how does the SNES know how to map/mirror $00:$7FFC to $FF:$FFFC?


This is my very dumb answer. One of the pins isn't connected. A15.


Yes, just a typo. I found that article about the "missing" A15 pin, information on the SNES from a system architecture point of view is quiet rare - then again, Nintendo was and still is very, very, very protective of their IPs.

But I think I got it now and will once again embark om my quest to write the most glorious RPG there ever was - right after I get this sprite to move not just in one direction.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/