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.

232 lines
8.0 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. ; Format: x000bbbb
  25. ; x: 0 = screen on, 1 = screen off, bbbb: Brightness ($0-$F)
  26. .define INIDISP $2100
  27. ; $2101: OAM size [OBSEL]
  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. ; n: Name selection (upper 4k word addr).
  35. ; b: Base selection (8k word seg. addr).
  36. .define OAMSIZE $2101
  37. ; $2102-$2103: OAM address register [OAMADDL/OAMADDH]
  38. ; aaaaaaaa r000000m a: OAM address.
  39. ; r: OAM priority rotation.
  40. ; m: OAM address MSB.
  41. .define OAMADDR $2102
  42. ; $2105: Screen mode register [BGMODE]
  43. ; abcdefff a: BG4 tile size (0=8x8, 1=16x16).
  44. ; b: BG3 tile size (0=8x8, 1=16x16).
  45. ; c: BG2 tile size (0=8x8, 1=16x16).
  46. ; d: BG1 tile size (0=8x8, 1=16x16).
  47. ; e: Highest priority for BG3 in MODE 1.
  48. ; f: MODE definition.
  49. .define SCREENMODE $2105
  50. ; $2107-210A: BG1-4 tilemap registers [BGxSC]
  51. ; xxxxxxab x: Base address (in VRAM, shifted left 11 bits).
  52. ; ab: SC size (00=32x32 01=64x32 10=32x64 11=64x64)
  53. .define BG1TILEMAP $2107
  54. .define BG2TILEMAP $2108
  55. .define BG3TILEMAP $2109
  56. .define BG4TILEMAP $210A
  57. ; $210B: BG1 & BG2 VRAM location register [BG12NBA]
  58. ; $210C: BG3 & BG4 VRAM location register [BG34NBA]
  59. ; aaaabbbb a: Base address for BG2 (or BG4).
  60. ; b: Base address for BG1 (or BG3).
  61. .define BG12NBA $210B
  62. .define BG34NBA $210C
  63. ; BG1 horizontal scroll offset. [BG1HOFS]
  64. ; BG1 vertical scroll offset. [BG1VOFS]
  65. ; ... and similar registers for BG2-4.
  66. ; Write to all of these twice, as they want 2 bytes of data.
  67. ; mmmmmaaa aaaaaaaa a: Horizontal offset.
  68. ; m: Only set with MODE 7.
  69. .define BG1HOFS $210D
  70. .define BG1VOFS $210E
  71. .define BG2HOFS $210F
  72. .define BG2VOFS $2110
  73. .define BG3HOFS $2111
  74. .define BG3VOFS $2112
  75. .define BG4HOFS $2113
  76. .define BG4VOFS $2114
  77. ; $2115: Video port control [VMAIN]
  78. ; i000abcd i: 0 = Address increment after writing to $2118 or reading
  79. ; from $2139.
  80. ; 1 = Address increment after writing to $2119 or reading
  81. ; from $213A.
  82. ; ab: Full graphic (see table below).
  83. ; cd: SC increment (see table below).
  84. ;
  85. ; abcd Result
  86. ; 0100 Increment by 8 for 32 times (2-bit formation).
  87. ; 1000 Increment by 8 for 64 times (4-bit formation).
  88. ; 1100 Increment by 8 for 128 times (8-bit formation).
  89. ; 0000 Address increments 1x1.
  90. ; 0001 Address increments 32x32.
  91. ; 0010 Address increments 64x64.
  92. ; 0011 Address increments 128x128.
  93. .define VMAIN $2115
  94. ; $2116-$2117: Video port address. 2 bytes. [VMADDL/VMADDH]
  95. ; Sets the initial address of a VRAM upload or download.
  96. .define VMADDR $2116
  97. ; $2118-$2119: Video port data. 2 bytes. [VMDATAL/VMDATAH]
  98. ; According to bit 7 of VMAIN, the data can be stored as:
  99. ; Bit 7
  100. ; 0 Write to $2118 only. Lower 8-bits written then
  101. ; address is increased.
  102. ; 0 Write to $2119 then $2118. Address increased when both
  103. ; are written to (in order).
  104. ; 1 Write to $2119 only. Upper 8-bits written, then
  105. ; address is increased.
  106. ; 1 Write to $2118 then $2119. Address increased when both
  107. ; are written to (in order).
  108. .define VMDATA $2118
  109. ; $2121: Color palette selection register [CGADD]
  110. ; Entry 0 corresponds to the SNES background color.
  111. .define CGADDR $2121
  112. ; $2122: Color data register [CGDATA]
  113. ; The palette color format is 15-bit: [0bbbbbgg][gggrrrrr].
  114. ; You will typically write to this register twice in a row: first for the
  115. ; low-order byte (containing green and red) and then for the high-order byte
  116. ; (containing blue and green).
  117. .define CGDATA $2122
  118. ; $212C: Main screen designation [TM]
  119. ; 000abcde a: OBJ/OAM disable/enable.
  120. ; b: Disable/enable BG4.
  121. ; c: Disable/enable BG3.
  122. ; d: Disable/enable BG2.
  123. ; e: Disable/enable BG1.
  124. .define MSENABLE $212C
  125. ; $4200: Counter enable [NMITIMEN]
  126. ; n-vh---j n: NMI interrupt enable v: vertical counter enable
  127. ; h: horizontal counter enable j: joypad enable
  128. .define NMITIMEN $4200
  129. ; $420B: DMA enable [MDMAEN]
  130. ; Each bit that's set enables one channel: 76543210
  131. .define DMAENABLE $420B
  132. ; $4218: Joypad #1 status [JOY1L]
  133. ; Format: AXLR0000
  134. .define JOY1L $4218
  135. ; $4219: Joypad #1 status [JOY1H]
  136. ; Format: BYsSudlr (s=select, S=start, udlr = joypad)
  137. .define JOY1H $4219
  138. ; $421A: Joypad #2 status [JOY2L]
  139. ; Format: AXLR0000
  140. .define JOY2L $421A
  141. ; $421B: Joypad #2 status [JOY2H]
  142. ; Format: BYsSudlr (s=select, S=start, udlr = joypad)
  143. .define JOY2H $421B
  144. ; $43x0: DMA control for channel x. [DMAPX]
  145. ; vh0cbaaa v: 0 = CPU memory -> PPU.
  146. ; 1 = PPU -> CPU memory.
  147. ; h: For HDMA only:
  148. ; 0 = Absolute addressing.
  149. ; 1 = Indirect addressing.
  150. ; c: 0 = Auto address inc/decrement.
  151. ; 1 = Fixed address (for VRAM, etc.).
  152. ; b: 0 = Automatic increment.
  153. ; 1 = Automatic decrement.
  154. ; a: Transfer type:
  155. ; 000 = 1 address write twice: LH.
  156. ; 001 = 2 addresses: LH.
  157. ; 010 = 1 address write once.
  158. ; 011 = 2 addresses write twice: LLHH
  159. ; 100 = 4 addresses: LHLH
  160. .define DMA0CTRL $4300
  161. .define DMA1CTRL $4310
  162. .define DMA2CTRL $4320
  163. .define DMA3CTRL $4330
  164. .define DMA4CTRL $4340
  165. .define DMA5CTRL $4350
  166. .define DMA6CTRL $4360
  167. .define DMA7CTRL $4370
  168. ; $43x1: DMA destination for channel x. [BBADX]
  169. ; The upper byte is assumed to be $21, so the possible destinations are
  170. ; $2100-$21FF.
  171. .define DMA0DST $4301
  172. .define DMA1DST $4311
  173. .define DMA2DST $4321
  174. .define DMA3DST $4331
  175. .define DMA4DST $4341
  176. .define DMA5DST $4351
  177. .define DMA6DST $4361
  178. .define DMA7DST $4371
  179. ; $43x2-$43x3: DMA source address for channel x. 2 bytes. [AITXL/AITXH]
  180. .define DMA0SRC $4302
  181. .define DMA1SRC $4312
  182. .define DMA2SRC $4322
  183. .define DMA3SRC $4332
  184. .define DMA4SRC $4342
  185. .define DMA5SRC $4352
  186. .define DMA6SRC $4362
  187. .define DMA7SRC $4372
  188. ; $43x4: DMA source bank for channel x [AIBX]
  189. .define DMA0SRCBANK $4304
  190. .define DMA1SRCBANK $4314
  191. .define DMA2SRCBANK $4324
  192. .define DMA3SRCBANK $4334
  193. .define DMA4SRCBANK $4344
  194. .define DMA5SRCBANK $4354
  195. .define DMA6SRCBANK $4364
  196. .define DMA7SRCBANK $4374
  197. ; $43x5: DMA transfer size & HDMA address. 2 bytes. [DASXL/DASXH]
  198. ; When using DMA, $43x5 defines the # of bytes to be transferred via DMA
  199. ; itself. When using HDMA, $43x5 defines the data address ($43x5 = low byte,
  200. ; $43x6 = hi byte).
  201. .define DMA0SIZE $4305
  202. .define DMA1SIZE $4315
  203. .define DMA2SIZE $4325
  204. .define DMA3SIZE $4335
  205. .define DMA4SIZE $4345
  206. .define DMA5SIZE $4355
  207. .define DMA6SIZE $4365
  208. .define DMA7SIZE $4375