dma.a65 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. setup_hdma:
  2. sep #$20 : .as
  3. rep #$10 : .xl
  4. stz $420b
  5. stz $420c
  6. lda #$02 ;A to B; direct; 2x single reg
  7. sta $4320 ;we use ch. 2 for color data
  8. lda #$22 ;2122 = CG RAM
  9. sta $4321 ;dest: CG RAM
  10. lda #^hdma_pal
  11. ldy #!hdma_pal
  12. sty $4322
  13. sta $4324
  14. lda #$00 ;A to B; direct; 1x single reg
  15. sta $4310 ;ch. 1 for color address
  16. lda #$21 ;2121 = CG addr
  17. sta $4311 ;dest: CG Address
  18. lda #^hdma_cg_addr
  19. ldy #!hdma_cg_addr
  20. sty $4312
  21. sta $4314
  22. lda #$00 ;A to B; direct; 1x single reg
  23. sta $4330 ;ch. 3 for mode switch
  24. lda #$05 ;2105 = BG mode
  25. sta $4331
  26. lda #^hdma_mode
  27. ldy #!hdma_mode
  28. sty $4332
  29. sta $4334
  30. lda #$03 ;A to B; direct; 2x 2x single reg
  31. sta $4340 ;ch. 4 for scroll
  32. lda #$0d ;210d = BG1HOFS
  33. sta $4341
  34. lda #^hdma_scroll
  35. ldy #!hdma_scroll
  36. sty $4342
  37. sta $4344
  38. lda #$01 ;A to B; direct; 1x two reg
  39. sta $4350 ;ch. 5 for color math
  40. lda #$31 ;2131 + 2132 = math, color constant
  41. sta $4351
  42. lda #^hdma_math
  43. ldy #!hdma_math
  44. sty $4352
  45. sta $4354
  46. lda #$3a
  47. sta $420c ;enable HDMA ch. 1+3+4+5
  48. jsr waitblank
  49. lda #$3e
  50. sta $420c ;enable HDMA ch. 2 too
  51. lda #$81 ;VBlank NMI + Auto Joypad Read
  52. sta $4200 ;enable V-BLANK NMI
  53. rts