It is currently Sat Nov 18, 2017 6:11 pm

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Fri Oct 20, 2017 4:37 pm 
Offline

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


Top
 Profile  
 
PostPosted: Fri Oct 20, 2017 4:57 pm 
Offline

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


Top
 Profile  
 
PostPosted: Fri Oct 20, 2017 5:03 pm 
Offline

Joined: Wed Apr 26, 2017 2:26 pm
Posts: 14
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 :)


Top
 Profile  
 
PostPosted: Fri Oct 20, 2017 5:15 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6442
Location: UK (temporarily)
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.


Top
 Profile  
 
PostPosted: Fri Oct 20, 2017 5:29 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1823
Location: DIGDUG
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."

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Last edited by dougeff on Fri Oct 20, 2017 5:41 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Oct 20, 2017 5:41 pm 
Offline

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group