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.

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