Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.64 KB | None | 0 0
  1. ; NVMX DIZC
  2. ; |||| ||||
  3. ; |||| |||+- Carry
  4. ; |||| ||+-- Zero
  5. ; |||| |+--- Interrupt Disable
  6. ; |||| +---- Decimal Mode
  7. ; |||+------ Index Register Size (0 = 16 bit, 1 = 8-bit)
  8. ; ||+------- Accumulator Size (0 = 16 bit, 1 = 8-bit)
  9. ; |+-------- Overflow
  10. ; +--------- Negative
  11.  
  12. .p816 ; Enable SNES instruction set
  13.  
  14. .include "registers.inc"
  15.  
  16. .segment "ZEROPAGE"
  17.  
  18. temp_addr: .res 2
  19.  
  20. joypad_press: .res 2
  21. joypad_hold: .res 2
  22. joypad_prev: .res 2
  23.  
  24. inidisp: .res 1
  25. obj_sel: .res 1
  26. bg_mode: .res 1
  27. mosaic: .res 1
  28. bg1_sc: .res 1
  29. bg2_sc: .res 1
  30. bg3_sc: .res 1
  31. bg4_sc: .res 1
  32. cg_wsel: .res 1
  33. cg_adsub: .res 1
  34. tm: .res 1
  35. ts: .res 1
  36. memsel: .res 1
  37. nmitimen: .res 1
  38. bg1_scroll_x: .res 2
  39. bg2_scroll_x: .res 2
  40. bg3_scroll_x: .res 2
  41. bg4_scroll_x: .res 2
  42. bg1_scroll_y: .res 2
  43. bg2_scroll_y: .res 2
  44. bg3_scroll_y: .res 2
  45. bg4_scroll_y: .res 2
  46. wh0: .res 1
  47. wh1: .res 1
  48. wh2: .res 1
  49. wh3: .res 1
  50. mdma_en: .res 1
  51. hdma_en: .res 1
  52.  
  53. main_loop_done: .res 1
  54.  
  55. .segment "RAM"
  56.  
  57. .include "lorom128.inc"
  58.  
  59. .segment "BANK0"
  60.  
  61. ;;================================================================================================================================;;
  62. ;;--------------------------------------------------------------------------------------------------------------------------------;;
  63. ;;================================================================================================================================;;
  64.  
  65. RESET:
  66. CLC ; Set native mode
  67. XCE
  68. SEI
  69. CLD
  70. SEP #$30 ; Set A/X/Y to 8 bit
  71. .a8
  72. .i8
  73.  
  74. LDA #$80 ; Enable FBlank
  75. STA INIDISP
  76. STZ MEMSEL
  77. STZ NMITIMEN ; Disable interrupts and auto-joypad
  78. STZ MDMAEN ; Stop DMAs
  79. STZ HDMAEN
  80.  
  81. LDX #$00
  82. INX
  83.  
  84. MemClear:
  85. STZ WMADDL ; Set WRAM address for DMA
  86. STZ WMADDM
  87. STX WMADDH
  88.  
  89. LDA #%00001000 ; Set DMA with fixed Source
  90. STA DMAP0
  91.  
  92. LDA #$80 ; Set DMA destination to $2180
  93. STA BBAD0
  94.  
  95. LDA #$18 ; Set DMA source to $00:8018
  96. STA A1T0L ; This points to $00 in 'LDX #$00'
  97. LDA #$80
  98. STA A1T0H
  99. STZ A1B0
  100.  
  101. LDA #$FF ; Set DMA transfer to $FFFF bytes
  102. STA DAS0L
  103. STA DAS0H
  104. LDA #%00000001
  105.  
  106. STA MDMAEN ; Start DMA transfer
  107. DEX ; Decrement X and loop to clear the second page
  108. BPL MemClear
  109.  
  110. LDA #$00
  111. TCD ; Set Direct Page
  112. PHA
  113. PLB ; Pull Data Bank
  114. TAX
  115. DEX
  116. TXS ; Set Stack Pointer
  117.  
  118. JSR RegisterSetup
  119.  
  120. LoadGraphics:
  121. .i16 ; Set for compiled, REP #$10 is in subroutine above
  122. LDX #$C000
  123. STX VMADDL ; Set VRAM address for DMA to $C000
  124.  
  125. LDA #%00000001 ; Set DMA mode to write to two registers
  126. STA DMAP0
  127.  
  128. LDA #$18 ; Set DMA destination to $2118
  129. STA BBAD0
  130.  
  131. STZ A1T0L ; Set DMA source to $01:0000
  132. STZ A1T0H
  133. LDA #$01
  134. STA A1B0
  135.  
  136. LDA #$FF ; Set DMA transfer to $FFFF bytes
  137. STA DAS0L
  138. STA DAS0H
  139. LDA #%00000001
  140.  
  141. STA MDMAEN ; Start DMA transfer
  142.  
  143. LDA #$80
  144. STA CGADD
  145.  
  146. SEP #$10
  147. .i8
  148.  
  149. REP #$20
  150. .a16
  151.  
  152. LDX #$03
  153. PHX
  154. PLB
  155.  
  156. LDX #$00
  157.  
  158. : LDA PaletteZangetsu,X
  159. STA CGDATA
  160. INX
  161. INX
  162. CMP #$20
  163. BNE :-
  164.  
  165. LDA #$81 ; Enable NMI and auto-joypad
  166. STA nmitimen
  167. STA NMITIMEN
  168.  
  169. SEP #$30
  170. .a8
  171. .i8
  172.  
  173. MainLoop:
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182. LDX #$01
  183. STX main_loop_done
  184.  
  185. NMIWait:
  186. LDX main_loop_done
  187. BNE NMIWait
  188. JMP MainLoop
  189.  
  190. ;;================================================================================================================================;;
  191. ;;--------------------------------------------------------------------------------------------------------------------------------;;
  192. ;;================================================================================================================================;;
  193.  
  194. RegisterSetup:
  195. REP #$10
  196. .i16
  197.  
  198. LDX #$0000
  199. LDA #$80 ; Enable FBlank
  200. STA inidisp
  201. STA INIDISP
  202. LDA #$03 ; Object Size 8x8 and 16x16, OAM 1 at $C000, OAM 2 at $E000
  203. STA obj_sel
  204. STA OBSEL
  205. STX OAMADDL ; Reset OAM address (OAMADDL/H)
  206.  
  207. LDA #$09 ; BG Mode 1 with BG3 priority
  208. STA bg_mode
  209. STA BGMODE
  210. STZ MOSAIC
  211.  
  212. LDA #%00000011 ; 2x2 tilemap starting from $0000
  213. STA bg1_sc
  214. STA BG1SC
  215. LDA #%00010011 ; 2x2 tilemap starting from $2000
  216. STA bg2_sc
  217. STA BG2SC
  218. LDA #%01011001 ; 2x1 tilemap starting from $B000
  219. STA bg3_sc
  220. STA BG3SC
  221. STZ BG4SC
  222. LDA #$22 ; Set BG 1 & 2 CHR address to $4000
  223. STA BG12NBA
  224. LDA #$05 ; Set BG 3 CHR address to $A000
  225. STA BG34NBA
  226.  
  227. STZ BG1HOFS ; Reset scroll positions
  228. STZ BG1HOFS
  229. STZ BG1VOFS
  230. STZ BG1VOFS
  231. STZ BG2HOFS
  232. STZ BG2HOFS
  233. STZ BG2VOFS
  234. STZ BG2VOFS
  235. STZ BG3HOFS
  236. STZ BG3HOFS
  237. STZ BG3VOFS
  238. STZ BG3VOFS
  239. STZ BG4HOFS
  240. STZ BG4HOFS
  241. STZ BG4VOFS
  242. STZ BG4VOFS
  243.  
  244. STZ VMAIN ; Reset video port controls
  245. STX VMADDL ; Reset VRAM address (VMADDL/H)
  246.  
  247. STZ M7SEL ; Reset Mode 7 settings
  248. LDA #$01
  249. STA M7A ; Set $0001 to Mode 7 A & B parameters
  250. STZ M7A
  251. STA M7B
  252. STZ M7B
  253. STZ M7C ; Set Mode 7 parameters C, D, X & Y to $0000
  254. STZ M7C
  255. STZ M7D
  256. STZ M7D
  257. STZ M7X
  258. STZ M7X
  259. STZ M7Y
  260. STZ M7Y
  261.  
  262. STZ CGADD ; Reset CGRAM address
  263. STZ W12SEL ; Reset Window Mask settings
  264. STZ W34SEL
  265. STZ WOBJSEL
  266. STZ WH0
  267. STZ WH1
  268. STZ WH2
  269. STZ WH3
  270. STZ WBGLOG
  271. STZ WOBJLOG
  272. STZ TM ; Reset main and sub-screen settings
  273. STZ TS
  274. STZ TMW
  275. STZ TSW
  276. STZ CGWSEL
  277. STZ CGADSUB
  278. LDA #$E0 ; Set fixed color data to black
  279. STA COLDATA
  280.  
  281. STZ SETINI ; Reset screen mode
  282. STZ WMADDL
  283. STZ WMADDM
  284. STZ WMADDH
  285. STZ HTIMEL ; Clear H/VBlank counters
  286. STZ HTIMEH
  287. STZ VTIMEL
  288. STZ VTIMEH
  289. RTS
  290.  
  291. ;;================================================================================================================================;;
  292. ;;--------------------------------------------------------------------------------------------------------------------------------;;
  293. ;;================================================================================================================================;;
  294.  
  295. NMI:
  296. PHA
  297. PHX
  298. PHY
  299.  
  300. LDA main_loop_done
  301. BEQ SkipNMI
  302.  
  303. REP #$10
  304. .i16
  305.  
  306.  
  307.  
  308.  
  309.  
  310. : LDA HVBJOY
  311. AND #$01
  312. BEQ :-
  313. LDX JOY1L
  314. STX joypad_hold
  315.  
  316. ; Add press and release
  317.  
  318. STZ main_loop_done
  319.  
  320. SkipNMI:
  321. PLY
  322. PLX
  323. PLA
  324. RTI
  325.  
  326. ;;================================================================================================================================;;
  327. ;;--------------------------------------------------------------------------------------------------------------------------------;;
  328. ;;================================================================================================================================;;
  329.  
  330. IRQ:
  331. PHA
  332. PHX
  333. PHY
  334.  
  335. PLY
  336. PLX
  337. PLA
  338. RTI
  339.  
  340. ;;================================================================================================================================;;
  341. ;;--------------------------------------------------------------------------------------------------------------------------------;;
  342. ;;================================================================================================================================;;
  343.  
  344. ABORT:
  345. COPROCESSOR:
  346. BREAK:
  347. RTI
  348.  
  349. ;;================================================================================================================================;;
  350. ;;--------------------------------------------------------------------------------------------------------------------------------;;
  351. ;;================================================================================================================================;;
  352.  
  353. .segment "BANK1"
  354.  
  355. .incbin "graphics0.chr"
  356. .incbin "graphics1.chr"
  357.  
  358. .segment "BANK2"
  359.  
  360. .incbin "graphics2.chr"
  361. .incbin "graphics3.chr"
  362.  
  363. .segment "BANK3"
  364.  
  365. PaletteZangetsu:
  366. .word $0000,$577F,$31DF,$39CE,$0014,$7F95,$7E4B,$0000,$7E39,$7810,$7F3A,$7FFF,$7DFE,$4C08,$59DF,$6F1F
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement