Question about the SNES reset vector

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
melanokardios
Posts: 17
Joined: Wed Apr 26, 2017 2:26 pm

Question about the SNES reset vector

Post by melanokardios »

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.
93143
Posts: 1717
Joined: Fri Jul 04, 2014 9:31 pm

Re: Question about the SNES reset vector

Post by 93143 »

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.
melanokardios
Posts: 17
Joined: Wed Apr 26, 2017 2:26 pm

Re: Question about the SNES reset vector

Post by melanokardios »

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 :)
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Question about the SNES reset vector

Post by lidnariq »

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.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Question about the SNES reset vector

Post by dougeff »

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)
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."
Last edited by dougeff on Fri Oct 20, 2017 5:41 pm, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES
melanokardios
Posts: 17
Joined: Wed Apr 26, 2017 2:26 pm

Re: Question about the SNES reset vector

Post by melanokardios »

dougeff wrote:
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)
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.
Post Reply