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.

173 lines
6.3 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. ; $2100: Screen display initialization [INIDISP]
  19. ; Format: x000bbbb
  20. ; x: 0 = screen on, 1 = screen off, bbbb: Brightness ($0-$F)
  21. .define INIDISP $2100
  22. ; $2105: Screen mode register [BGMODE]
  23. ; abcdefff a: BG4 tile size (0=8x8, 1=16x16).
  24. ; b: BG3 tile size (0=8x8, 1=16x16).
  25. ; c: BG2 tile size (0=8x8, 1=16x16).
  26. ; d: BG1 tile size (0=8x8, 1=16x16).
  27. ; e: Highest priority for BG3 in MODE 1.
  28. ; f: MODE definition.
  29. .define BGMODE $2105
  30. ; $2107-210A: BG1-4 VRAM location registers [BGxSC]
  31. ; xxxxxxab x: Base address
  32. ; ab: SC size
  33. .define BG1SC $2107
  34. .define BG2SC $2108
  35. .define BG3SC $2109
  36. .define BG4SC $210A
  37. ; $210B: BG1 & BG2 VRAM location register [BG12NBA]
  38. ; $210C: BG3 & BG4 VRAM location register [BG34NBA]
  39. ; aaaabbbb a: Base address for BG2 (or BG4).
  40. ; b: Base address for BG1 (or BG3).
  41. .define BG12NBA $210B
  42. .define BG34NBA $210C
  43. ; BG1 horizontal scroll offset. [BG1HOFS]
  44. ; BG1 vertical scroll offset. [BG1VOFS]
  45. ; ... and similar registers for BG2-4.
  46. ; Write to all of these twice, as they want 2 bytes of data.
  47. ; mmmmmaaa aaaaaaaa a: Horizontal offset.
  48. ; m: Only set with MODE 7.
  49. .define BG1HOFS $210D
  50. .define BG1VOFS $210E
  51. .define BG2HOFS $210F
  52. .define BG2VOFS $2110
  53. .define BG3HOFS $2111
  54. .define BG3VOFS $2112
  55. .define BG4HOFS $2113
  56. .define BG4VOFS $2114
  57. ; $2115: Video port control [VMAIN]
  58. ; i000abcd i: 0 = Address increment after writing to $2118 or reading
  59. ; from $2139.
  60. ; 1 = Address increment after writing to $2119 or reading
  61. ; from $213A.
  62. ; ab: Full graphic (see table below).
  63. ; cd: SC increment (see table below).
  64. ;
  65. ; abcd Result
  66. ; 0100 Increment by 8 for 32 times (2-bit formation).
  67. ; 1000 Increment by 8 for 64 times (4-bit formation).
  68. ; 1100 Increment by 8 for 128 times (8-bit formation).
  69. ; 0000 Address increments 1x1.
  70. ; 0001 Address increments 32x32.
  71. ; 0010 Address increments 64x64.
  72. ; 0011 Address increments 128x128.
  73. .define VMAIN $2115
  74. ; $2116-$2117: Video port address. 2 bytes. [VMADDL/VMADDH]
  75. .define VMADDR $2116
  76. ; $2118-$2119: Video port data. 2 bytes. [VMDATAL/VMDATAH]
  77. ; According to bit 7 of VMAIN, the data can be stored as:
  78. ; Bit 7
  79. ; 0 Write to $2118 only. Lower 8-bits written then
  80. ; address is increased.
  81. ; 0 Write to $2119 then $2118. Address increased when both
  82. ; are written to (in order).
  83. ; 1 Write to $2119 only. Upper 8-bits written, then
  84. ; address is increased.
  85. ; 1 Write to $2118 then $2119. Address increased when both
  86. ; are written to (in order).
  87. .define VMDATA $2118
  88. ; $2121: Color palette selection register [CGADD]
  89. ; Entry 0 corresponds to the SNES background color.
  90. .define CGADDR $2121
  91. ; $2122: Color data register [CGDATA]
  92. ; The palette color format is 15-bit: [0bbbbbgg][gggrrrrr].
  93. ; You will typically write to this register twice in a row: first for the
  94. ; low-order byte (containing green and red) and then for the high-order byte
  95. ; (containing blue and green).
  96. .define CGDATA $2122
  97. ; $212C: Main screen designation [TM]
  98. ; 000abcde a: OBJ/OAM disable/enable.
  99. ; b: Disable/enable BG4.
  100. ; c: Disable/enable BG3.
  101. ; d: Disable/enable BG2.
  102. ; e: Disable/enable BG1.
  103. .define MSENABLE $212C
  104. ; $4200: Counter enable [NMITIMEN]
  105. ; n-vh---j n: NMI interrupt enable v: vertical counter enable
  106. ; h: horizontal counter enable j: joypad enable
  107. .define NMITIMEN $4200
  108. ; $420B: DMA enable [MDMAEN]
  109. ; Each bit that's set enables one channel: 76543210
  110. .define DMAENABLE $420B
  111. ; $4218: Joypad #1 status [JOY1L]
  112. ; Format: AXLR0000
  113. .define JOY1L $4218
  114. ; $4219: Joypad #1 status [JOY1H]
  115. ; Format: BYsSudlr (s=select, S=start, udlr = joypad)
  116. .define JOY1H $4219
  117. ; $421A: Joypad #2 status [JOY2L]
  118. ; Format: AXLR0000
  119. .define JOY2L $421A
  120. ; $421B: Joypad #2 status [JOY2H]
  121. ; Format: BYsSudlr (s=select, S=start, udlr = joypad)
  122. .define JOY2H $421B
  123. ; $43x0: DMA control for channel x. [DMAPX]
  124. ; vh0cbaaa v: 0 = CPU memory -> PPU.
  125. ; 1 = PPU -> CPU memory.
  126. ; h: For HDMA only:
  127. ; 0 = Absolute addressing.
  128. ; 1 = Indirect addressing.
  129. ; c: 0 = Auto address inc/decrement.
  130. ; 1 = Fixed address (for VRAM, etc.).
  131. ; b: 0 = Automatic increment.
  132. ; 1 = Automatic decrement.
  133. ; a: Transfer type:
  134. ; 000 = 1 address write twice: LH.
  135. ; 001 = 2 addresses: LH.
  136. ; 010 = 1 address write once.
  137. ; 011 = 2 addresses write twice: LLHH
  138. ; 100 = 4 addresses: LHLH
  139. .define DMA0CTRL $4300
  140. ; $43x1: DMA destination for channel x. [BBADX]
  141. ; The upper byte is assumed to be $21, so the possible destinations are
  142. ; $2100-$21FF.
  143. .define DMA0DST $4301
  144. ; $43x2-$43x3: DMA source address for channel x. 2 bytes. [AITXL/AITXH]
  145. .define DMA0SRC $4302
  146. ; $43x4: DMA source bank for channel x [AIBX]
  147. .define DMA0SRCBANK $4304
  148. ; $43x5: DMA transfer size & HDMA address. 2 bytes. [DASXL/DASXH]
  149. ; When using DMA, $43x5 defines the # of bytes to be transferred via DMA
  150. ; itself. When using HDMA, $43x5 defines the data address ($43x5 = low byte,
  151. ; $43x6 = hi byte).
  152. .define DMA0SIZE $4305