memory_mapping_overview.txt 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. SNES Memory Mapping
  2. by
  3. Duncanthrax of ShadowCraft
  4. Version: 1.0
  5. Date: August 28, 1997
  6. Introduction:
  7. This is a little document I'm throwing together as I go. It probably has a few innacuracies, but it's certainly better than nothing. I became frustrated with the lack of solid knowledge and documentation regarding memory in the SNES, all the other maps were very incomplete. So, since I'm building an emulator at the moment, I figured I'd write all this down for posterity.
  8. If you find anything in here that is wrong, or if you have an additions or questions, or suggestions... or if you want to help with the emulator, mail me at:
  9. odin@ccs.neu.edu
  10. Or check out ShadowCraft's web page at:
  11. http://shadowguild.home.ml.org
  12. Have fun, and I hope this is helpful.
  13. *---------------------------------------------------*
  14. SNES Memory Map in LoROM Mode (Mode 0x20):
  15. Bank: Address: Purpose:
  16. ----- -------- --------
  17. 00-3F 0000-1FFF Shadow RAM
  18. 2000-5FFF Hardware Registers
  19. 6000-7FFF Expansion RAM
  20. 8000-FFFF 32k ROM Chunk
  21. 40-7C 0000-7FFF 32k ROM Chunk
  22. 8000-FFFF 32k ROM Chunk
  23. 7D 0000-FFFF SRAM
  24. 7E 0000-1FFF Shadow RAM
  25. 2000-FFFF System RAM
  26. 7F 0000-FFFF System RAM
  27. 80-BF 0000-1FFF Shadow RAM
  28. 2000-5FFF Hardware Registers
  29. 6000-7FFF Expansion RAM
  30. 8000-FFFF 32k ROM Chunk
  31. C0-FC 0000-7FFF 32k ROM Chunk
  32. 8000-FFFF 32k ROM Chunk
  33. FD 0000-FFFF SRAM
  34. FE 0000-1FFF Shadow RAM
  35. 2000-FFFF System RAM
  36. FF 0000-FFxx System RAM
  37. FFxx-FFFF Reset and NMI Vectors
  38. SNES Memory Map in HiROM Mode (Mode 0x21):
  39. Bank: Address: Purpose:
  40. ----- -------- --------
  41. 00-3F 0000-1FFF Shadow RAM
  42. 2000-5FFF Hardware Registers
  43. 6000-7FFF SRAM
  44. 8000-FFFF 32k ROM Chunk
  45. 40-7D 0000-FFFF 64k ROM Chunk
  46. 7E 0000-1FFF Shadow RAM
  47. 2000-FFFF System RAM
  48. 7F 0000-FFFF System RAM
  49. 80-BF 0000-1FFF Shadow RAM
  50. 2000-5FFF Hardware Registers
  51. 6000-7FFF SRAM
  52. 8000-FFFF 32k ROM Chunk
  53. C0-FE 0000-FFFF 64k ROM Chunk
  54. FF 0000-FFxx 64k ROM Chunk
  55. FFxx-FFFF Reset and NMI Vectors
  56. *--------------------------------------------*
  57. Now that I've given you the overview of the memory layout, perhaps a little explanation would be in order. We'll start at 00.0000 and work our way up... in LoROM first, then HiROM - to avoid confusion.
  58. 00-3F 0000-1FFF Shadow RAM
  59. What's going on here? Well, this is RAM that is the same in every bank up to and including 7E. It's the first 8k of System RAM. So, if you write 0x42 to 00.1001, you'll read a 0x42 from 7E.1001. Simple, huh?
  60. 00-3F 2000-5FFF Hardware Registers
  61. This is where you do graphics hardware calls, BIOS calls, DMA calls, and all that stuff. There are lots and lots of documents on this, all of them confusing. I may write one later on that clarifies a bunch of stuff, but for now I won't go into greater detail, as this is pretty straightforward... read and write values that interact with hardware.
  62. 00-3F 6000-7FFF Expansion RAM
  63. This is one of those areas in which I draw a blank. I'm not certain where this RAM is supposed to map, whether it is part of system RAM or what. Anybody who wants to clarify the purpose of this area of RAM can feel free. I've seen at least two cartridges that access this area...
  64. 00-3F 8000-FFFF 32k ROM Chunk
  65. 40-7C 0000-7FFF 32k ROM Chunk
  66. 8000-FFFF 32k ROM Chunk
  67. This bears a little explanation. When the LoROM is loaded into memory, this is where it is mapped (in a real SNES it isn't "loaded" at all - just mapped). The first 64 32k chunks are loaded into the upper half of banks 00-3F. Then, you continue at 40, mapping two (2!) 32k chunks in each bank from 40-7C. This should take care of an entire LoROM. I know that theoretically a LoROM could be slightly bigger than this, but I've never seen one that is...
  68. 7D 0000-FFFF SRAM
  69. OK, this is pretty obvious. This is where the battery-backed SRAM on cartridges is mapped. Very simple. Most have 64kb. DOOM, I've heard, has 256kb. Copiers have 256kb. Simple.
  70. 7E 0000-1FFF Shadow RAM
  71. 2000-FFFF System RAM
  72. 7F 0000-FFFF System RAM
  73. Also very simple. This is the SNES's 128k of RAM. There, that was easy, right?
  74. 80-FF 0000-FFFF MIRROR!
  75. The upper area of the SNES's addressing space is for "Fast ROM". Games will use this area instead of the lower area (they're mapped exactly the same) when they want to run faster. The SNES gains 1Mhz of speed this way.
  76. The only thing that is different about the upper area is that the vectors for reset and NMI get stored in the FF.FFxx last 32 bytes...
  77. *-------------------------------------------*
  78. LoROM vs. HiROM!
  79. OK, this is the most interesting part of SNES mapping, and also the part where I'm most likely to get something wrong. As always, if this is incorrect or confusing, let me know!
  80. 00-3F 0000-5FFF Same as LoROM
  81. 00-3F 6000-7FFF 8k SRAM Chunk
  82. 00-3F 8000-FFFF 32k ROM Chunk
  83. 40-7D 0000-FFFF 64k ROM Chunk
  84. Ok, this is not too hard, with one caveat... the first 64 32k chunks of the HiROM cartridge get loaded into 00-3F, and then it REPEATS FROM THE BEGINNING starting at 40.0000, this time going in 64k chunks until the end of the file. Now, people are about to start yelling about how this doesn't leave room for the last 2 64k chunks of a 32mb ROM. Yes, I know... keep reading.
  85. 7E-7F 0000-FFFF Same as LoROM
  86. Note 7D is no longer the SRAM, which is now in the expansion ram area.
  87. 80-FD 0000-FFFF Same as LoROM
  88. FE-FF 0000-FFFF 64k ROM Chunk
  89. Aha! Here it is... the last two chunks of a 32mb ROM (i.e. Chrono Trigger, etc.) get loaded here. Remember as always that the last 16 bytes are for vectors, and you're all set!
  90. *--------------------------------------------*
  91. Ok kiddies! That was a quick tour through the SNES memory map. Tune in next time for "Dr. Duncanthrax teaches CPU!" - same Bat Time, same Bat Channel!
  92. Fin