Simple SNES shoot-'em-up game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

248 lines
8.9 KiB

  1. ; Definitions of commonly-used special memory addresses.
  2. ;
  3. ; These are commonly called "registers" in online documentation, even though
  4. ; that feels like a misnomer; these aren't necessarily hardware registers in
  5. ; the same sense as PC, A, X, Y, and so on. Despite that, I call them
  6. ; "registers" too, since that's what everyone else calls them.
  7. ;
  8. ; I've often named these register definitions in the same way that they're
  9. ; named in Yoshi's venerable snes.txt document. In some cases (where the
  10. ; mnemonic is too obscure) I've invented a different name. In particular,
  11. ; I've changed "ADD" to "ADDR" to reduce possible confusion between "addresses"
  12. ; and "addition". The original name from Yoshi's doc is still listed in
  13. ; brackets, like [CGADD], for easy cross-referencing.
  14. ;
  15. ; I've also heavily borrowed from Yoshi's descriptions of what these registers
  16. ; do, though in many cases I've clarified / simplified the descriptions based
  17. ; on my own understanding, or simply reformatted them a bit.
  18. ;
  19. ; Here is a link to an online version of Yoshi's doc (v. 2.30):
  20. ; http://patpend.net/technical/snes/snes.txt
  21. ; Anomie's register doc is more up-to-date and might have better info:
  22. ; http://www.dforce3000.de/pub/doc/anomie_regs.txt
  23. ; $2100: Screen display initialization [INIDISP]
  24. ; x000bbbb x: 0 = screen on, 1 = screen off, bbbb: Brightness ($0-$F)
  25. .define INIDISP $2100
  26. ; $2101: OAM size [OBSEL]
  27. ; The upper 3 bits select the size of "small" and "large" sprites.
  28. ; sssnnbbb s: 000 = 8x8 or 16x16.
  29. ; 001 = 8x8 or 32x32.
  30. ; 010 = 8x8 or 64x64.
  31. ; 011 = 16x16 or 32x32.
  32. ; 100 = 16x16 or 64x64.
  33. ; 101 = 32x32 or 64x64.
  34. ; 110 = 16x32 or 32x64 ('undocumented')
  35. ; 111 = 16x32 or 32x32 ('undocumented')
  36. ; n: Name selection (upper 4k word addr).
  37. ; b: Base selection (8k word seg. addr).
  38. .define OAMSIZE $2101
  39. ; $2102-$2103: OAM address register [OAMADDL/OAMADDH]
  40. ; aaaaaaaa r000000m a: OAM address.
  41. ; r: OAM priority rotation.
  42. ; m: OAM address MSB.
  43. .define OAMADDR $2102
  44. ; $2105: Screen mode register [BGMODE]
  45. ; abcdefff a: BG4 tile size (0=8x8, 1=16x16).
  46. ; b: BG3 tile size (0=8x8, 1=16x16).
  47. ; c: BG2 tile size (0=8x8, 1=16x16).
  48. ; d: BG1 tile size (0=8x8, 1=16x16).
  49. ; e: Highest priority for BG3 in MODE 1.
  50. ; f: MODE definition.
  51. .define BGMODE $2105
  52. ; $2107-210A: BG1-4 tilemap registers [BGxSC]
  53. ; xxxxxxab x: Base address (in VRAM, shifted left 11 bits).
  54. ; ab: SC size (00=32x32 01=64x32 10=32x64 11=64x64)
  55. .define BG1TILEMAP $2107
  56. .define BG2TILEMAP $2108
  57. .define BG3TILEMAP $2109
  58. .define BG4TILEMAP $210A
  59. ; $210B: BG1 & BG2 VRAM location register [BG12NBA]
  60. ; $210C: BG3 & BG4 VRAM location register [BG34NBA]
  61. ; aaaabbbb a: Base address for BG2 (or BG4).
  62. ; b: Base address for BG1 (or BG3).
  63. .define BG12NBA $210B
  64. .define BG34NBA $210C
  65. ; BG1 horizontal scroll offset. [BG1HOFS]
  66. ; BG1 vertical scroll offset. [BG1VOFS]
  67. ; ... and similar registers for BG2-4.
  68. ; Write to all of these twice, as they want 2 bytes of data.
  69. ; mmmmmaaa aaaaaaaa a: Horizontal offset.
  70. ; m: Only set with MODE 7.
  71. .define BG1HOFS $210D
  72. .define BG1VOFS $210E
  73. .define BG2HOFS $210F
  74. .define BG2VOFS $2110
  75. .define BG3HOFS $2111
  76. .define BG3VOFS $2112
  77. .define BG4HOFS $2113
  78. .define BG4VOFS $2114
  79. ; $2115: Video port control [VMAIN]
  80. ; i000abcd i: 0 = Address increment after writing to $2118 or reading
  81. ; from $2139.
  82. ; 1 = Address increment after writing to $2119 or reading
  83. ; from $213A.
  84. ; ab: Full graphic (see table below).
  85. ; cd: SC increment (see table below).
  86. ;
  87. ; abcd Result
  88. ; 0100 Increment by 8 for 32 times (2-bit formation).
  89. ; 1000 Increment by 8 for 64 times (4-bit formation).
  90. ; 1100 Increment by 8 for 128 times (8-bit formation).
  91. ; 0000 Address increments 1x1.
  92. ; 0001 Address increments 32x32.
  93. ; 0010 Address increments 64x64.
  94. ; 0011 Address increments 128x128.
  95. .define VMAIN $2115
  96. ; $2116-$2117: Video port address. 2 bytes. [VMADDL/VMADDH]
  97. ; Sets the initial address of a VRAM upload or download.
  98. .define VMADDR $2116
  99. ; $2118-$2119: Video port data. 2 bytes. [VMDATAL/VMDATAH]
  100. ; According to bit 7 of VMAIN, the data can be stored as:
  101. ; Bit 7
  102. ; 0 Write to $2118 only. Lower 8-bits written then
  103. ; address is increased.
  104. ; 0 Write to $2119 then $2118. Address increased when both
  105. ; are written to (in order).
  106. ; 1 Write to $2119 only. Upper 8-bits written, then
  107. ; address is increased.
  108. ; 1 Write to $2118 then $2119. Address increased when both
  109. ; are written to (in order).
  110. .define VMDATA $2118
  111. ; $2121: Color palette selection register [CGADD]
  112. ; Entry 0 corresponds to the SNES background color.
  113. .define CGADDR $2121
  114. ; $2122: Color data register [CGDATA]
  115. ; The palette color format is 15-bit: [0bbbbbgg][gggrrrrr].
  116. ; You will typically write to this register twice in a row: first for the
  117. ; low-order byte (containing green and red) and then for the high-order byte
  118. ; (containing blue and green).
  119. .define CGDATA $2122
  120. ; $212C: Main screen designation [TM]
  121. ; 000abcde a: OBJ/OAM disable/enable.
  122. ; b: Disable/enable BG4.
  123. ; c: Disable/enable BG3.
  124. ; d: Disable/enable BG2.
  125. ; e: Disable/enable BG1.
  126. .define MSENABLE $212C
  127. ; $4200: Counter enable [NMITIMEN]
  128. ; n-vh---j n: NMI interrupt enable v: vertical counter enable
  129. ; h: horizontal counter enable j: joypad enable
  130. .define NMITIMEN $4200
  131. ; $420B: DMA enable [MDMAEN]
  132. ; Each bit that's set enables one channel: 76543210
  133. .define DMAENABLE $420B
  134. ; $4212: VBlank/HBlank/Joypad status [HVBJOY]
  135. ; vh-----a
  136. ; v = V-Blank Flag. If we're currently in V-Blank, this flag is set,
  137. ; otherwise it is clear. The setting seems to occur at H Counter
  138. ; about $16-$17 when V Counter is $E1, and the clearing at about $1E
  139. ; with V Counter 0.
  140. ; h = H-Blank Flag. If we're currently in H-Blank, this flag is set,
  141. ; otherwise it is clear. The setting seems to occur at H Counter
  142. ; about $121-$122, and the clearing at about $12-$18.
  143. ; a = Auto-Joypad Status. This is set while Auto-Joypad Read is in
  144. ; progress, and cleared when complete. It typically turns on at
  145. ; the start of V-Blank, and completes 3 scanlines later.
  146. .define HVBJOY $4212
  147. ; $4218: Joypad #1 status [JOY1L]
  148. ; Format: AXLR0000
  149. .define JOY1L $4218
  150. ; $4219: Joypad #1 status [JOY1H]
  151. ; Format: BYsSudlr (s=select, S=start, udlr = joypad)
  152. .define JOY1H $4219
  153. ; $421A: Joypad #2 status [JOY2L]
  154. ; Format: AXLR0000
  155. .define JOY2L $421A
  156. ; $421B: Joypad #2 status [JOY2H]
  157. ; Format: BYsSudlr (s=select, S=start, udlr = joypad)
  158. .define JOY2H $421B
  159. ; $43x0: DMA control for channel x. [DMAPX]
  160. ; vh0cbaaa v: 0 = CPU memory -> PPU.
  161. ; 1 = PPU -> CPU memory.
  162. ; h: For HDMA only:
  163. ; 0 = Absolute addressing.
  164. ; 1 = Indirect addressing.
  165. ; c: 0 = Auto address inc/decrement.
  166. ; 1 = Fixed address (for VRAM, etc.).
  167. ; b: 0 = Automatic increment.
  168. ; 1 = Automatic decrement.
  169. ; a: Transfer type:
  170. ; 000 = 1 address write twice: LH.
  171. ; 001 = 2 addresses: LH.
  172. ; 010 = 1 address write once.
  173. ; 011 = 2 addresses write twice: LLHH
  174. ; 100 = 4 addresses: LHLH
  175. .define DMA0CTRL $4300
  176. .define DMA1CTRL $4310
  177. .define DMA2CTRL $4320
  178. .define DMA3CTRL $4330
  179. .define DMA4CTRL $4340
  180. .define DMA5CTRL $4350
  181. .define DMA6CTRL $4360
  182. .define DMA7CTRL $4370
  183. ; $43x1: DMA destination for channel x. [BBADX]
  184. ; The upper byte is assumed to be $21, so the possible destinations are
  185. ; $2100-$21FF.
  186. .define DMA0DST $4301
  187. .define DMA1DST $4311
  188. .define DMA2DST $4321
  189. .define DMA3DST $4331
  190. .define DMA4DST $4341
  191. .define DMA5DST $4351
  192. .define DMA6DST $4361
  193. .define DMA7DST $4371
  194. ; $43x2-$43x3: DMA source address for channel x. 2 bytes. [AITXL/AITXH]
  195. .define DMA0SRC $4302
  196. .define DMA1SRC $4312
  197. .define DMA2SRC $4322
  198. .define DMA3SRC $4332
  199. .define DMA4SRC $4342
  200. .define DMA5SRC $4352
  201. .define DMA6SRC $4362
  202. .define DMA7SRC $4372
  203. ; $43x4: DMA source bank for channel x [AIBX]
  204. .define DMA0SRCBANK $4304
  205. .define DMA1SRCBANK $4314
  206. .define DMA2SRCBANK $4324
  207. .define DMA3SRCBANK $4334
  208. .define DMA4SRCBANK $4344
  209. .define DMA5SRCBANK $4354
  210. .define DMA6SRCBANK $4364
  211. .define DMA7SRCBANK $4374
  212. ; $43x5: DMA transfer size & HDMA address. 2 bytes. [DASXL/DASXH]
  213. ; When using DMA, $43x5 defines the # of bytes to be transferred via DMA
  214. ; itself. When using HDMA, $43x5 defines the data address ($43x5 = low byte,
  215. ; $43x6 = hi byte).
  216. .define DMA0SIZE $4305
  217. .define DMA1SIZE $4315
  218. .define DMA2SIZE $4325
  219. .define DMA3SIZE $4335
  220. .define DMA4SIZE $4345
  221. .define DMA5SIZE $4355
  222. .define DMA6SIZE $4365
  223. .define DMA7SIZE $4375