main.a65 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. GAME_MAIN:
  2. jsr snes_init
  3. jsr font_dma
  4. jsr tests
  5. - wai
  6. bra -
  7. font_dma:
  8. sep #$20 : .as
  9. rep #$10 : .xl
  10. stz $420b
  11. stz $420c
  12. lda #$01 ;A to B; (direct); non-fixed, inc, two reg
  13. sta $4300 ;to DMA ch.0 ctrl
  14. lda #^font ;font source bank
  15. ldy #!font ;font source address
  16. sty $4302 ;address -> 4302,4303
  17. sta $4304 ;bank -> 4304
  18. ldx #$1000 ;transfer size
  19. stx $4305 ;to reg
  20. stz $2116 ;VRAM address 0
  21. stz $2117 ;
  22. lda #$18 ;VRAM data port
  23. sta $4301 ;to channel 0 tgt address
  24. lda #$01 ;ch 0 enable
  25. sta $420b ;GPDMA GO!
  26. lda #$09 ;A to B; fixed, two reg
  27. sta $4300
  28. lda #^zero
  29. ldy #!zero
  30. sty $4302
  31. sta $4304
  32. ldx #$1000
  33. stx $4305 ;zero 4096b of VRAM
  34. ldx #$3000
  35. stx $2116 ;from 0x6000-0x6fff
  36. lda #$18 ;VRAM data port
  37. sta $4301 ;to channel 0 tgt address
  38. lda #$01
  39. sta $420b
  40. ; copy logo
  41. lda #$01 ;A to B; (direct); non-fixed, inc, two reg
  42. sta $4300 ;to DMA ch.0 ctrl
  43. lda #^logo ;font source bank
  44. ldy #!logo ;font source address
  45. sty $4302 ;address -> 4302,4303
  46. sta $4304 ;bank -> 4304
  47. ldx #$4b00 ;transfer size
  48. stx $4305 ;to reg
  49. ldx #$800 ;after font
  50. stx $2116 ;VRAM address 0x1000
  51. lda #$18 ;VRAM data port
  52. sta $4301 ;to channel 0 tgt address
  53. lda #$01 ;ch 0 enable
  54. sta $420b ;GPDMA GO!
  55. ; copy logo tilemap
  56. lda #$01 ;A to B; (direct); non-fixed, inc, two reg
  57. sta $4300 ;to DMA ch.0 ctrl
  58. lda #^logomap ;font source bank
  59. ldy #!logomap ;font source address
  60. sty $4302 ;address -> 4302,4303
  61. sta $4304 ;bank -> 4304
  62. ldx #$300 ;transfer size
  63. stx $4305 ;to reg
  64. ldx #$3400 ;BG1 tilemap
  65. stx $2116 ;VRAM address 0x6800
  66. lda #$18 ;VRAM data port
  67. sta $4301 ;to channel 0 tgt address
  68. lda #$01 ;ch 0 enable
  69. sta $420b ;GPDMA GO!
  70. ;copy test text
  71. lda #$00 ;A->B, inc, 1 reg
  72. sta $4300
  73. lda #^hello
  74. ldy #!hello
  75. sty $4302
  76. sta $4304
  77. ldx #$c ;24 bytes
  78. stx $4305
  79. ldx #$3020
  80. stx $2116
  81. lda #$18
  82. sta $4301
  83. stz $2115 ;increment after LOW byte (write to 2118)
  84. lda #$01
  85. sta $420b
  86. lda #$08 ;A->B, fixed, 1 reg
  87. sta $4300
  88. lda #^bg2tile
  89. ldy #!bg2tile
  90. sty $4302
  91. sta $4304
  92. ldx #$c ;24 bytes
  93. stx $4305
  94. ldx #$3020
  95. stx $2116
  96. lda #$19
  97. sta $4301
  98. lda #$80
  99. sta $2115 ;increment after HIGH byte (write to 2119)
  100. lda #$01
  101. sta $420b
  102. stz $2121 ;palette index 0
  103. lda #$00
  104. sta $4300
  105. lda #^palette
  106. ldy #!palette
  107. sty $4302
  108. sta $4304
  109. ldx #$200
  110. stx $4305
  111. lda #$22 ;CG RAM port
  112. sta $4301
  113. lda #$01
  114. sta $420b
  115. rts
  116. tests:
  117. sep #$30 : .as : .xs ;8-bit accumulator and index
  118. lda #$0f
  119. sta $2100 ;screen on, full brightness
  120. lda #$04 ;mode 4, mode 5 is a bitch :(
  121. sta $2105
  122. lda #$34 ;Tilemap addr 0x6800
  123. sta $2107 ;for BG1
  124. lda #$30 ;Tilemap addr 0x6000
  125. sta $2108 ;for BG2
  126. lda #$03 ;enable BG1+BG2
  127. sta $212c ;BG Main
  128. sta $212d ;BG Sub
  129. lda #$00 ;224
  130. sta $2133 ;
  131. lda #$00
  132. sta $2130
  133. stz $2121
  134. lda #$0
  135. ldx #$0
  136. ldy #$0
  137. - bra -
  138. -
  139. inx
  140. bne +
  141. iny
  142. +
  143. stz $2121
  144. stx $2122
  145. sty $2122
  146. bra -
  147. rts
  148. snes_init:
  149. sep #$20 : .as ;8-bit accumulator
  150. lda #$01
  151. sta $420d ; FAAAAAST
  152. lda #$8f
  153. sta $2100 ;INIDISP: force blank
  154. stz $2101 ;
  155. stz $2102 ;
  156. stz $2103 ;
  157. stz $2104 ; (OAM Data?!)
  158. stz $2104 ; (OAM Data?!)
  159. stz $2105 ;
  160. stz $2106 ;
  161. stz $2107 ;
  162. stz $2108 ;
  163. stz $2109 ;
  164. stz $210a ;
  165. stz $210b ;
  166. stz $210c ;
  167. stz $210d ;
  168. stz $210d ;
  169. stz $210e ;
  170. stz $210e ;
  171. stz $210f ;
  172. stz $210f ;
  173. lda #$00
  174. sta $2110 ;
  175. stz $2110 ;
  176. stz $2111 ;
  177. stz $2111 ;
  178. stz $2112 ;
  179. stz $2112 ;
  180. stz $2113 ;
  181. stz $2113 ;
  182. stz $2114 ;
  183. stz $2114 ;
  184. lda #$80
  185. sta $2115 ;
  186. stz $2116 ;
  187. stz $2117 ;
  188. stz $2118 ;(VRAM Data?!)
  189. stz $2119 ;(VRAM Data?!)
  190. stz $211a ;
  191. stz $211b ;
  192. lda #$01
  193. sta $211b ;
  194. stz $211c ;
  195. stz $211c ;
  196. stz $211d ;
  197. stz $211d ;
  198. stz $211e ;
  199. sta $211e ;
  200. stz $211f ;
  201. stz $211f ;
  202. stz $2120 ;
  203. stz $2120 ;
  204. stz $2121 ;
  205. stz $2122 ; (CG Data?!)
  206. stz $2123 ;
  207. stz $2124 ;
  208. stz $2125 ;
  209. stz $2126 ;
  210. stz $2127 ;
  211. stz $2128 ;
  212. stz $2129 ;
  213. stz $212a ;
  214. stz $212b ;
  215. stz $212c ;
  216. stz $212d ;
  217. stz $212e ;
  218. lda #$30
  219. sta $2130 ;
  220. stz $2131 ;
  221. lda #$e0
  222. sta $2132 ;
  223. stz $2133 ;
  224. stz $4200 ;
  225. lda #$ff
  226. sta $4201 ;
  227. stz $4202 ;
  228. stz $4203 ;
  229. stz $4204 ;
  230. stz $4205 ;
  231. stz $4206 ;
  232. stz $4207 ;
  233. stz $4208 ;
  234. stz $4209 ;
  235. stz $420a ;
  236. stz $420b ;
  237. stz $420c ;
  238. rts