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.

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