Advertisement
Arnethegreat

regs_vars.asm

Mar 4th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.62 KB | None | 0 0
  1. ;PPU registers
  2.  
  3. !reg_inidisp = $2100 ; f--- xxxx, Force vblank and set screen brightness
  4.  
  5. ;OAM control registers
  6. !reg_obsel = $2101 ; sssn nbbb, s = obj size, n = name select b = name base addr>>14
  7. ; Object size and tile address
  8. ; sssnnbbb
  9. ; sss = size
  10. ;000 = 8x8 and 16x16 sprites
  11. ;001 = 8x8 and 32x32 sprites
  12. ;010 = 8x8 and 64x64 sprites
  13. ;011 = 16x16 and 32x32 sprites
  14. ;100 = 16x16 and 64x64 sprites
  15. ;101 = 32x32 and 64x64 sprites
  16. ; nn = name select, bbb = name base select
  17. ; Each sprite entry in oam is 4 bytes (+2 bits in the high table), format is:
  18. ; 1 xxxx xxxx
  19. ; 2 yyyy yyyy
  20. ; 3 tttt tttt Note that this could also be considered as 'rrrrcccc' specifying the row and column of the tile in the 16x16 character table.
  21. ; 4 hvoo pppN N = msb of tile number, p = set palette 0-7, o = priority, h/v flip
  22. ; Each byte in the high table contains settings for 4 sprites, ie 2 bits per sprite.
  23. ; first bit = X "sign" bit for x position
  24. ; second bit = S size bit, used to determine which size to use, each sss setting in $2101 has two different sizes see above. Set to 0 for small 1 for large
  25. ; Sprite tile table in vram:
  26. ; The first table is at the address specified by the Name Base bits of $2101, and the offset of the second is determined by the Name bits of $2101.
  27. ; The word address in VRAM of a sprite's first tile may be calculated as:
  28. ; ((Base<<13) + (cccccccc<<4) + (N ? ((Name+1)<<12) : 0)) & 0x7fff
  29. !reg_objsel = $2101
  30. !reg_oamaddl = $2102 ; aaaa aaaa, a = OAM address low byte
  31. !reg_oamaddh = $2103 ; p--- ---b, OAM address high bit and priority
  32. ; Changing sprite priority sprite to sprite (not sprite to BG, see byte 4 of sprite entry for this):
  33. ; Write 1 to b to index the high table
  34. ; p can be used for rotating priority order in OAM
  35. ; step 1: set p to 1
  36. ; step 2: write the highest priority OBJ number (0-127) to $2102
  37. ; during V-blank every frame
  38. ; step 3: repeat
  39.  
  40. !reg_oam_data = $2104 ; bbbb bbbb, OAM Data write register
  41. ;Write 1 byte at a time to OAM, changes won't take effect until 2 bytes are written
  42.  
  43. !reg_bgmode = $2105 ; DCBA emmm, e = mode 1 bg3 prio bit, mmm = BG mode
  44. ; A/B/C/D = tile size for BG1/BG2/BG3/BG4, if set 16x16 else 8x8
  45. !reg_mosaic = $2106 ; xxxx DCBA, xxxx = size, DCBA = bg 4321
  46.  
  47. ;BG tile and map vram address
  48. ; a = map address>>10, x = horizontal flip, y = vertical flip
  49. !reg_bg1sc = $2107 ; aaaa aayx
  50. !reg_bg2sc = $2108 ; aaaa aayx
  51. !reg_bg3sc = $2109 ; aaaa aayx
  52. !reg_bg4sc = $210A ; aaaa aayx
  53. !reg_bg12nba = $210B ; bbbb aaaa, tile address>>12: a = BG1/3, b = BG2/4
  54. !reg_bg34nba = $210C ; bbbb aaaa
  55.  
  56. ;BG Scroll registers
  57. ; The registers for BG1 behave differently in mode 7 from mode 0-6, see below
  58. !reg_bg1hofs = $210D ; ---- --xx xxxx xxxx, unsigned, 10 bit x scroll
  59. !reg_bg1vofs = $210E ; ---- --yy yyyy yyyy, unsigned, 10 bit y scroll
  60. ; signed, 13 bit twos complement x,y scroll for the mode7 background
  61. !reg_m7hofs = $210D ; ---x xxxx xxxx xxxx
  62. !reg_m7vofs = $210E ; ---y yyyy yyyy yyyy
  63. ; Same as BG1H/VOFS
  64. !reg_bg2hofs = $210F ; ---- --xx xxxx xxxx
  65. !reg_bg2vofs = $2110 ; ---- --yy yyyy yyyy
  66. !reg_bg3hofs = $2111 ; ---- --xx xxxx xxxx
  67. !reg_bg3vofs = $2112 ; ---- --yy yyyy yyyy
  68. !reg_bg4hofs = $2113 ; ---- --xx xxxx xxxx
  69. !reg_bg4vofs = $2114 ; ---- --yy yyyy yyyy
  70.  
  71. ;VRAM write stuff
  72. !reg_vmain = $2115 ; i---mmaa
  73. ; i = set to 0/1 for increment after writing $2118/2119
  74. ; mm = Address translation
  75. ; aa = Address increment step (0..3 = Increment Word-Address by 1,32,128,128)
  76. ; m m a a Increment value for $2116 and $2117
  77. ; 0 1 0 0 Increment by 8 (for 32 times) (4 color mode)
  78. ; 1 0 0 0 Increment by 8 (for 64 times) (16 color mode)
  79. ; 1 1 0 0 Increment by 8 (for 128 times) (256 color mode)
  80. ; 0 0 0 0 Address Increments 1x1
  81. ; 0 0 0 1 Address Increments 32x32
  82. ; 0 0 1 0 Address Increments 128x128 (64x64?)
  83. ; 0 0 1 1 Address Increments 128x128
  84. ; Step 32 (without translation) is useful for updating BG Map columns (eg. after horizontal scrolling).
  85. ; $89 to write 4bpp (bit) column, $85 seems to work as well?
  86. !reg_vmadd = $2116
  87. !reg_vmaddl = $2116 ; Low byte of VRAM read/write address
  88. !reg_vmaddh = $2117 ; High byte of VRAM read/write address
  89. !reg_vmdatawl = $2118 ; Write register for low VRAM
  90. !reg_vmdatawh = $2119 ; Write register for high VRAM
  91. ; VRAM writes are done as such: write $2118, write 2119, write 2118, write 2119 etc.
  92.  
  93. ;Mode7 settings and matrix
  94. !reg_m7sel = $211A ; rc----yx
  95. ; r = When clear, the playing field is 1024x1024 pixels (so the tilemap completely fills it). When set, the playing field is much larger, and the ‘empty space’ fill is controlled by bit 6
  96. ; c = Empty space fill, when bit r is set: 0 = Transparent. 1 = Fill with character 0.
  97. ; x/y = Horizontal/Veritcal mirroring. If the bit is set, flip the 256x256 pixel 'screen' in that direction.
  98.  
  99. ; Mode7 affine matrix, all are write twice registers
  100. ; M7A and M7B can also be used for signed multiplication.
  101. ; Write a 16 bit value to M7A and an 8 bit value to M7B and the 24 bit product
  102. ; can be read from registers $2134 to $2136 with trivial delay.
  103. ; However this is not possible during scanning in mode 7.
  104. !reg_m7a = $211B ; aaaa aaaa aaaa aaaa
  105. !reg_m7b = $211C ; bbbb bbbb bbbb bbbb
  106. !reg_m7c = $211D ; you get the idea
  107. !reg_m7d = $211E ; format is 16 bit two's complement signed, 7.8 fixeds
  108.  
  109. !reg_m7x = $211F ; ---x xxxx xxxx xxxx
  110. !reg_m7y = $2120 ; ---y yyyy yyyy yyyy
  111. ; 13 bit two's complement signed, origin X,Y for mode7 affine transformation
  112.  
  113. ;CGRAM write stuff
  114. !reg_cgadd = $2121 ; cccc cccc, destination address in CGRAM for read/write
  115. !reg_cgdataw = $2122 ; -bbb bbgg gggr rrrr, color to be written, write twice register low byte then high
  116.  
  117. ; Window mask settings
  118. ; The following 3 registers have the format:
  119. ; ABCD abcd
  120. ; c/a = Enable window 1/2 for BG1/BG3/OBJ
  121. ; C/A = Enable window 1/2 for BG2/BG4/Color
  122. ; d/b = Window 1/2 Inversion for BG1/BG3/OBJ
  123. ; D/B = Window 1/2 Inversion for BG2/BG4/Color
  124. ; Example: window 2 enabled for BG1 outside and window 1 enabled for BG2 inside
  125. ; lda #%00101100
  126. ; sta $2123
  127. !reg_w12sel = $2123 ; Window Mask Settings for BG1 and BG2
  128. !reg_w34sel = $2124 ; Window Mask Settings for BG3 and BG4
  129. !reg_wobjsel = $2125 ; Window Mask Settings for OBJ and Color Window
  130.  
  131. ; Window position
  132. ; All 1 byte unsigned
  133. !reg_wh0 = $2126 ; Window 1 Left Position
  134. !reg_wh1 = $2127 ; Window 1 Right Position
  135. !reg_wh2 = $2128 ; Window 2 Left Position
  136. !reg_wh3 = $2129 ; Window 2 Right Position
  137.  
  138. ; Window BG, OBJ and Color logic
  139. ; 44/33/22/11/oo/cc = Mask logic for BG1/BG2/BG3/BG4/OBJ/Color
  140. !reg_wbglog = $212A ; 4433 2211
  141. !reg_wobjlog = $212B ; ---- ccoo
  142.  
  143. !reg_tm = $212C ; ---o 4321 Main screen designation
  144. !reg_ts = $212D ; ---o 4321 Subscreen designation
  145. !reg_tmw = $212E ; ---o 4321 Window Mask Designation for the Main Screen
  146. !reg_tsw = $212F ; ---o 4321 Window Mask Designation for the Subscreen
  147.  
  148. ; Color math registers
  149. !reg_cgwsel = $2130 ; ccmm --sd Color Addition Select
  150. !reg_cgadsub = $2131 ; shbo 4321 Color math designation
  151. !reg_coldata = $2132 ; bgrc cccc Color for color math
  152.  
  153. !reg_setini = $2133 ; se-- poIi Screen Mode/Video Select
  154.  
  155. ; You can read the two's complement product from M7A*(M7B>>8) here
  156. !reg_mpyl = $2134 ; xxxx xxxx, low byte of fractional part of the product
  157. !reg_mpym = $2135 ; xxxx xxxx, high byte of fractional part of the product
  158. !reg_mpyh = $2136 ; xxxx xxxx, integer part of the product
  159.  
  160. !reg_slhv = $2137 ; When read, the H/V counter (as read from $213C and $213D) will be latched to the current X and Y position if bit 7 of $4201 is set (really?). The data actually read is open bus.
  161. !reg_oamdatar = $2138 ; OAM data read
  162. !reg_vmdatarl = $2139 ; VRAM read low
  163. !reg_vmdatarh = $213A ; VRAM read high
  164. !reg_cgdatar = $213B ; Read cgram
  165.  
  166. ; $2137, $213C and $213D
  167. ; Operation goes something like this:
  168. ; Read register $2137 to latch counter
  169. ; Read register twice for position (9 bits, bits 1-7 of high byte are ppu2 open bus)
  170. ; Each register ($213C, $213D) keeps seperate track of whether to return the low or high byte. The high/low selector is reset to ‘low’ when $213f is read (the selector is NOT reset when the counter is latched).
  171. ; H Counter values range from 0 to 339, with 22-277 being visible on the screen. V Counter values range from 0 to 261 in NTSC mode (262 is possible every other frame when interlace is active) and 0 to 311 in PAL mode (312 in interlace?), with 1-224 (or 1-239(?) if overscan is enabled) visible on the screen.
  172. !reg_ophct = $213C ; ---- ---h hhhh hhhh, Horizontal scanline location
  173. !reg_opvct = $213D ; ---- ---v vvvv vvvv, Vertical scanline location
  174. !reg_stat77 = $213E ; trm- vvvv, OAM overflow flags
  175. !reg_stat78 = $213F ; fl-pvvvv, p = if PAL SNES this bit is 1, else 0.
  176.  
  177. ;APU registers
  178. ; Always write to $2140 / $2141 with 8-bit writes
  179. !reg_apu_port0 = $2140
  180. !reg_apu_port1 = $2141
  181. !reg_apu_port2 = $2142
  182. !reg_apu_port3 = $2143
  183.  
  184. !reg_apuio0 = $2140
  185. !reg_apuio1 = $2141
  186. !reg_apuio2 = $2142
  187. !reg_apuio3 = $2143
  188.  
  189. ;WRAM registers
  190. !reg_wmdata = $2180 ; dddd dddd, read or write one byte at a time
  191. !reg_wmaddl = $2181 ; aaaa aaaa, wram address low byte
  192. !reg_wmaddm = $2182 ; aaaa aaaa, wram address high byte
  193. !reg_wmaddh = $2183 ; ---- ---b, bank 7F/7E
  194.  
  195. !reg_debug = $21FC ; NO$SNS debug port, write ascii character
  196. ; The char_out function can be used with ASCII chars 20h..7Fh, line breaks may be
  197. ; send as 0Dh, 0Ah, or 0Dh+0Ah (all three variations supported)
  198.  
  199. ;Old style joypad registers, these registers have extra slow access time
  200. !reg_joyser0 = $4016 ; Write 0 to enable joypad auto read something
  201. ; Note: bit 2-7 is open bus!
  202. !reg_joyser1 = $4017 ; bit 5-7 open bus
  203. ; Supposedly you want to read these two "if expanded bit is exist" (lol)
  204.  
  205. ;CPU registers
  206. !reg_nmitimen = $4200 ; n-yx ---a
  207. ; n = NMI, y & x = IRQ, a = auto-joy
  208. !reg_wrio = $4201 ; ab-- ----
  209. ; b = controller 1 (and 3?), a = controller 2 (and 4?)
  210.  
  211. ;Hardware multiplication write registers, the multiplication is unsigned.
  212. !reg_wrmpya = $4202 ; mmmm mmmm. Write $4202, then $4203. 8 "machine cycles" (probably 48 master cycles) after $4203 is set, the product may be read from $4216/7.
  213. !reg_wrmpyb = $4203 ; mmmm mmmm. $4202 will not be altered by this process, thus a new value may be written to $4203 to perform another multiplication without resetting $4202.
  214. !reg_multa = $4202
  215. !reg_multb = $4203
  216.  
  217. ;Hardware division write registers, the division is unsigned.
  218. !reg_wrdivl = $4204 ; xxxx xxxx
  219. !reg_wrdivh = $4205 ; xxxx xxxx
  220. !reg_wrdivb = $4206 ; 1 byte divisor
  221. ; Write $4204/5 then 6, 16 cycles after 6 is written the result may be read
  222. ; from $4214/15 and the remainder from $4216/17
  223. !reg_divl = $4204 ;\same as WRDIVx
  224. !reg_divh = $4205 ;|
  225. !reg_divb = $4206 ;/
  226.  
  227. ;IRQ timing
  228. !reg_htimel = $4207 ; hhhh hhhh
  229. !reg_htimeh = $4208 ; ---- ---h
  230. !reg_vtimel = $4209 ; vvvv vvvv
  231. !reg_vtimeh = $420A ; ---- ---v
  232. ; h = set the pixel where HIRQ fires if bit 4 is set in $4200
  233. ; v = set the scanline where VIRQ fires if bit 5 is set in $4200.
  234. ; If both V+H IRQ are enabled in $4200, IRQ fires just after scanline V pixel H
  235.  
  236. !reg_mdmaen = $420B ; 7654 3210 - Enable DMA flags, channels 0-7
  237. !reg_hdmaen = $420C ; 7654 3210 - Enable HDMA flags, channels 0-7
  238.  
  239. !reg_memsel = $420D ; -------f
  240. ; set f for FastROM, must access rom through banks $80-$FF
  241.  
  242. !reg_rdnmi = $4210 ; n---vvvv, bits 4-6 are open bus
  243. ; n = NMI flag, this bit is set at the start of V-Blank (happens even if NMIs
  244. ; are disabled, we suspect when H-Counter is somewhere between $28 and $4E),
  245. ; and cleared on read or at the end of V-Blank.
  246. ; Supposedly, it is required that this register be read during NMI.
  247. ; v = cpu version
  248.  
  249. !reg_timeup = $4211 ; i-------, i = IRQ flag, is set when IRQ is triggered, bits 0-6 is open bus
  250. !reg_hvbjoy = $4212 ; vh-----a, bits 1-5 is open bus
  251. ; v = currently in V-Blank if set. h = currently in H-Blank if set.
  252. ; a = Auto-Joypad reading pads if set.
  253.  
  254. !reg_rdio = $4213 ; ab-- ----
  255. ; a = controller 1 pin 6, b = controller 2 pin 6
  256. ; Reading this register reads data from the I/O Port.
  257. ; The way the I/O Port works, any bit set to 0 in $4201 will be 0 here.
  258. ; Any bit set to 1 in $4201 may be 1 or 0 here, depending on whether any
  259. ; other device connected to the I/O Port has set a 0 to that bit.
  260. ; Bit ‘b’ is connected to pin 6 of Controller Port 1. Bit ‘a’ is connected
  261. ; to pin 6 of Controller Port 2, and to the PPU Latch line.
  262. ; See register $4201 for the O side of the I/O Port
  263.  
  264. ;Hardware division read registers, see $4204/6
  265. !reg_rddivl = $4214 ; qqqq qqqq, low byte of quotient
  266. !reg_rddivh = $4215 ; qqqq qqqq, high byte of quotient
  267. ;Hardware multiplication read registers, see $4202/3
  268. !reg_rdmpyl = $4216 ; xxxx xxxx, low byte of product/remainder
  269. !reg_rdmpyh = $4217 ; xxxx xxxx, high byte of product/remainder
  270. !reg_productl = $4216
  271. !reg_producth = $4217
  272.  
  273. ;Joypad registers, one word per pad read high to low
  274. !reg_joy1l = $4218 ; axlr0000 = A/X/L/R button status
  275. !reg_joy1h = $4219 ; byetUDLR = B/Y/SELECT/START/UP/DOWN/LEFT/RIGHT
  276. !reg_joy2l = $421A ;
  277. !reg_joy2h = $421B ;
  278. !reg_joy3l = $421C ;
  279. !reg_joy3h = $421D ; These registers are only updated when the Auto-Joypad Read bit (bit 0) of $4200 is set.
  280. !reg_joy4l = $421E ; They are being updated while the Auto-Joypad Status bit (bit 0) of $4212 is set.
  281. !reg_joy4h = $421F ; Reading during this time will return incorrect values.
  282. ;.endscope
  283.  
  284. ;(H)DMA stuff, these registers can be read or written at any time, fast access time
  285. !reg_dmap0 = $4300
  286. !reg_bbad0 = $4301
  287. !reg_a1t0l = $4302
  288. !reg_a1t0h = $4303
  289. !reg_a1b0 = $4304
  290. !reg_das0l = $4305
  291. !reg_das0h = $4306
  292. !reg_dasb0 = $4307
  293. !reg_a2a0l = $4308
  294. !reg_a2a0h = $4309
  295. !reg_ntlr0 = $430A
  296.  
  297.  
  298. !dma_b_to_a = #$80
  299. !dma_fixed = #$08
  300.  
  301. ; <---Registers used for DMA--->
  302. ; DMA transfers take 8 master cycles per byte transferred, no matter if fastROM or not.
  303. ; There is also an overhead of 8 master cycles per channel, and an overhead of 12-24 cycles for the whole transfer.
  304. ;DMA Control Register $43x0 ; d--i fttt
  305. ; d = Transfer direction, 0 = A bus to B bus, 1 = B to A.
  306. ; i = Address increment, 0 = increment DMA address for each byte. 1 = decrement
  307. ; f = DMA fixed transfer
  308. ; 0 = source address will be adjusted as specified by bit 4
  309. ; 1 = source address will not be adjusted
  310. ; t = How data is written/read, see table below (dest = byte in $43x1):
  311. ; 000 => 1 register write once (1 byte: p )
  312. ; 001 => 2 registers write once (2 bytes: p, p+1 )
  313. ; 010 => 1 register write twice (2 bytes: p, p )
  314. ; 011 => 2 registers write twice each (4 bytes: p, p, p+1, p+1)
  315. ; 100 => 4 registers write once (4 bytes: p, p+1, p+2, p+3)
  316. ; 101 => 2 registers write twice alternate (4 bytes: p, p+1, p, p+1)
  317. ; 110 => 1 register write twice (2 bytes: p, p )
  318. ; 111 => 2 registers write twice each (4 bytes: p, p, p+1, p+1)
  319.  
  320. ;DMA Destination $43x1 ; aaaa aaaa
  321. ; a = Destination register for DMA write on address bus B ($21xx)
  322.  
  323. ;DMA Source Address (Low) $43x2 ; llll llll
  324. ;DMA Source Address (High) $43x3 ; hhhh hhhh
  325. ;DMA Source Bank $43x4 ; bbbb bbbb
  326. ; bhl = bank:address for the source on A bus in DMA transfer (eg. $80BEEF)
  327.  
  328. ;DMA Transfer Size (Low) $43x5 ; llll llll
  329. ;DMA Transfer Size (High) $43x6 ; hhhh hhhh
  330. ; Size of the transfer, 2 bytes ($0000 = 64k transfer,$8000 = 32k transfer)
  331.  
  332.  
  333. ; <---Registers used for HDMA--->
  334. ; HDMA overhead is ~18 master cycles, plus 8 master cycles for each channel set for direct HDMA and 24 master cycles for each channel set for indirect HDMA.
  335. ;HDMA Control Register $43x0 ; da-- -ttt
  336. ; d and t are same as DMA
  337. ; a = Set to 1 for indirect addressing, 0 for direct.
  338.  
  339. ;HDMA Destination $43x1 ; aaaa aaaa
  340. ; a = same as DMA
  341. ;HDMA Table Address (Low) $43x2 ; llll llll
  342. ;HDMA Table Address (High) $43x3 ; hhhh hhhh
  343. ;HDMA Table Bank $43x4 ; bbbb bbbb
  344. ; bhl = same as DMA
  345.  
  346. ;HDMA Indirect Address (Low) $43x5 ; llll llll
  347. ;HDMA Indirect Address (High) $43x6 ; hhhh hhhh
  348. ;HDMA Indirect Bank $43x7 ; bbbb bbbb
  349. ; bhl = bank:address for indirect HDMA (eg. $7EFACE)
  350. ; You only need to set the bank byte for indirect HDMA.
  351. ; The resulting bank:address is the pointer used in the HDMA transfer.
  352.  
  353. ;HDMA Mid Frame Table Address (Low) $43x8 ; aaaa aaaa,
  354. ;HDMA Mid Frame Table Address (High)$43x9 ; aaaa aaaa,
  355. ; At the beginning of the frame $43x2/3 are copied into $43x8/9 registers for all active HDMA channels,
  356. ; and then this register is updated as the table is read.
  357.  
  358. ;HDMA Line Counter Register $43xA ; rccc cccc, r = Repeat, c = Line count
  359. ; About $43xA:
  360. ; The register is decremeted before being checked for r status or c==0.
  361. ; Thus, setting a value of $80 is really "128 lines with no repeat" rather than "0 lines with repeat".
  362. ; Similarly, a value of $00 will be "128 lines with repeat" when it doesn't mean "terminate the channel"(assuming this can only happen if you manually write $43xA?).
  363. ; This register is initialized at the end of V-Blank for every active HDMA channel.
  364. ; Note that if a game wishes to begin HDMA during the frame, it will most likely have to initalize this register.
  365. ;
  366.  
  367. ; GSU registers
  368.  
  369. ; During GSU operation, only SFR, SCMR, and VCR may be accessed by the SNES CPU.
  370. !gsu_r0 = $3000 ;Default source/destination register
  371. !gsu_r1 = $3002 ;PLOT instruction X coordinate
  372. !gsu_r2 = $3004 ;PLOT instruction Y coordinate
  373. !gsu_r3 = $3006 ; General purpose
  374. !gsu_r4 = $3008 ;LMULT instruction lower 16 bits of result
  375. !gsu_r5 = $300A ; General purpose
  376. !gsu_r6 = $300C ;FMULT and LMULT instructions, multiplier
  377. !gsu_r7 = $300E ;MERGE instruction, source 1
  378. !gsu_r8 = $3010 ;MERGE instruction, source 2
  379. !gsu_r9 = $3012 ; General purpose
  380. !gsu_r10 = $3014 ; General purpose (conventionally stack pointer)
  381. !gsu_r11 = $3016 ;LINK instruction destination register, used for return address
  382. !gsu_r12 = $3018 ;LOOP instruction counter
  383. !gsu_r13 = $301A ;LOOP instruction branch address
  384. !gsu_r14 = $301C ;Gamepak ROM address pointer for GETxx opcodes
  385. !gsu_r15 = $301E ;Program counter, write MSB to start operation
  386. ; Access from snes cpu for R0-R15: R/W
  387.  
  388. ; SNES CPU access disabled for COLR and POR registers
  389. ;!gsu_colr Color register
  390. ; Access from snes cpu: -
  391. ; $pppp pppp, p = palette entry used by plot instruction
  392. ;!gsu_por Plot option register
  393. ; Access from snes cpu: -
  394. ; $---o fhdt
  395. ; t = Transparency flag or rather whether to plot color 0 or not, 1 = plot color 0, 0 = don't plot color 0 (transparency on)
  396. ; If t is on and the color register is 0, the plot circuit only changes the X coordinate (R1)
  397. ; d = Dither flag, 1 = on (only valid in 4bpp mode?)
  398. ; if(R1&1 == R2&1) lower 4 bit sin the color register are plotted.
  399. ; else plot upper 4 bits of color register
  400. ; h = Upper 4 bits color, 1 = on (4bpp, or 8bpp with f set)
  401. ; When enabled, the upper 4 bits in the source register are stored in the lower 4 bits
  402. ; of the color register when using COLOR and GETC instructions.
  403. ; This allows the data for 2 pixels to be stored in one byte.
  404. ; f = Freeze upper 4 bits, 1 = on (8bpp only)
  405. ; lock the upper 4 bits of the color register while processing the COLOR and GETC instructions and change the lower 4 bits only.
  406. ; o = Sprite mode, set to 1 to specify the bitmap in sprite mode.
  407. ; Plot option register flags:
  408. !gsu_por_opaque = #$01
  409. !gsu_por_dither = #$02
  410. !gsu_por_color_src_high = #$04
  411. !gsu_por_fix_high_4bits = #$08
  412. !gsu_por_obj = #$10
  413.  
  414. !gsu_sfr = $3030 ;Status/flag registers
  415. ; Access from snes cpu: R/W
  416. ; I--B HL21 -RGV SCZ-
  417. ; Z = Zero flag
  418. ; C = Carry flag
  419. ; S = Sign flag
  420. ; V = Overflow flag
  421. ; G = GSU is running (cleared on STOP) (set 0 to force GSU stop)
  422. ; R = ROM[R14] read (0 = no, 1 = reading ROM via R14 address)
  423. ; 1 = Prefix flag \for ALT1, ALT2, ALT3
  424. ; 2 = Prefix flag /
  425. ; L = Immediate lower 8 bit flag \Unknown, probably set/reset internally
  426. ; H = Immediate upper 8 bit flag /when processing opcodes with imm operands
  427. ; B = Prefix flag (for WITH prefix, used by MOVE/MOVES opcodes)
  428. ; I = Interrupt Flag (reset on read, set on STOP) (also set if IRQ masked in $3037?)
  429. !gsu_go_bit = #$20
  430.  
  431. !gsu_bramr = $3033 ;Back-up (s)ram register
  432. ; Access from snes cpu: W
  433. ; ---- ---B, B = 0/1 disable/enable
  434. ; Some info from nocash:
  435. ; This register would be used only if the PCB does have a separate "Backup" RAM chip
  436. ; mapped to 780000h-79FFFFh (additionally to the Game Pak RAM chip).
  437. ; None of the existing PCBs have that extra SRAM chip, so the register has no practical function.
  438. ; (Note: However, some PCBs do include a battery wired to Game Pak RAM chip, regardless,
  439. ; that type of "backup" isn't affected by this register).
  440. ; The "real" back-up RAM is also the game pak RAM (aka buffer RAM) and resides in bank $70-$71 (max 128KiB)
  441. ; Book says: Data becomes protected when the BRAM flag is reset (0) after saving data to the back-up RAM.
  442.  
  443. !gsu_pbr = $3034 ;Program bank register
  444. ; Access from snes cpu: R/W
  445. ; bbbb bbbb, works like SNES CPU program bank register
  446. !gsu_rombr = $3036 ;Game pak rom bank register
  447. ; Access from snes cpu: R
  448. ; bbbb bbbb, used for ROM buffering, specifies the bank for ops using the ROM buffer
  449.  
  450. !gsu_cfgr = $3037 ;Config register
  451. ; Access from snes cpu: W
  452. ; I-M- ----, I = IRQ mask, set to 1 to mask GSU triggered IRQ
  453. ; M = multiplier speed select, 0 standard 1 high speed
  454. ; When operating at 21MHz (CLSR = $01) M must be 0(?) seems to work in 21mhz tho so screw that, give 1 cycle mult!
  455. !gsu_cfgr_fastmul = #$20
  456. !gsu_cfgr_irq_mask = #$80
  457.  
  458.  
  459. !gsu_scbr = $3038 ;Screen base register
  460. ; Access from snes cpu: W
  461. ; aaaa aaaa, a = start address (in 1KiB units ) in character data storage area
  462.  
  463. !gsu_clsr = $3039 ;Clock select register
  464. ; Access from snes cpu: W
  465. ; ---- ---S, S = Clock speed, 0 = 10.7MHz 1 = 21.4MHz
  466.  
  467. ; RON/RAN flags
  468. !gsu_scmr = $303A ;Screen mode register
  469. ; Access from snes cpu: W
  470. ; --hO Ahcc, O = RON, A = RAN, h = screen height, c = color depth mode
  471. ; Write 0 to RON/RAN (ROM/RAM enable) flags to temporarily put GSU in
  472. ; WAIT mode, this allows SCPU access to game pak ROM/RAM respectively.
  473. ; Write 1 to give game pak ROM/RAM access back to GSU and it will resume processing.
  474. ; hh settings: 00 = 128px, 01 = 160px, 10 = 192px, 11 = obj mode
  475. ; cc settings: 00 = 2bpp, 01 = 4bpp, 10 = not used, 11 = 8bpp
  476. !gsu_ron = #$10
  477. !gsu_ran = #$08
  478. !gsu_scmr_2bpp = #$00
  479. !gsu_scmr_4bpp = #$01
  480. !gsu_scmr_8bpp = #$03
  481. !gsu_scmr_h128 = #$00
  482. !gsu_scmr_h160 = #$04
  483. !gsu_scmr_h192 = #$20
  484. !gsu_scmr_obj = #$24
  485.  
  486. !gsu_vcr = $303B ;Version code register read only, 1 byte.
  487. ; Access from snes cpu: R
  488. ; There are 4 known versions, $01 = MARIO, $04 = GSU-2 ($02 = GSU? $03 = GSU-1 ????)
  489.  
  490. !gsu_rambr = $303C ;Game pak ram bank register
  491. ; Access from snes cpu: R
  492. ; ---- ---A, A = bank select ($70-71)
  493.  
  494. !gsu_cbr = $303E ;Cache base register
  495. ; Access from snes cpu: R
  496. ; cccc cccc cccc ----, This register specifies the starting address when data is loaded from ROM or gamepak RAM to cache RAM.
  497.  
  498. !gsu_cache = $3100 ;GSU cache start
  499. ;!ccccccccc = $32FF ;GSU cache end
  500.  
  501. ;!bbbbbbbbb = $347F ; ?
  502.  
  503. ; GSU2 (and probably 1) information below courtesy of nocash.emubase.de
  504. ; GSU2 memory map at SNES side
  505. ; 00-3F/80-BF:6000-7FFF Mirror of 70:0000-1FFF (ie. FIRST 8K of Game Pak RAM)
  506. ; 70-71:0000-FFFF Game Pak RAM (128KiB max, usually 32K or 64K)
  507. ; 78-79:0000-FFFF Additional "Backup" RAM (128KiB max, usually none)
  508. ;
  509. ; GSU2 memory map at GSU Side
  510. ; 00-3F:0000-7FFF Mirror of LoROM at 00-3F:8000-FFFF (for "GETB R15" vectors)
  511. ; 00-3F:8000-FFFF Game Pak ROM in LoRom mapping (2MiB max)
  512. ; 40-5F:0000-FFFF Game Pak ROM in HiRom mapping (mirror of above 2MiB)
  513. ; 70-71:0000-FFFF Game Pak RAM (128KiB max, usually 32K or 64K)
  514. ; PBR:0000-01FF Code-Cache (when having manually stored opcodes in it)
  515. ; PBR can be set to both ROM/RAM regions (or cache region), ROMBR only to ROM region (00h-5Fh), RAMBR only to RAM region (70h-71h).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement