reset.a65 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ; This file is part of the snescom-asm demo - a demo of how to build a SNES program.
  2. ; See http://bisqwit.iki.fi/source/snescom.html for details.
  3. #include "memmap.i65"
  4. #include "dma.i65"
  5. #define TILE_ADDR_REG_VAL(addr, scsize) \
  6. (((addr & $FC00) >> 8) + scsize)
  7. #define BMAP_ADDR_REG_VAL(addr, addr2) \
  8. (((addr & $F000) >> 12) | (((addr2 & $F000) >> 12) << 4))
  9. ; NMI - called on VBlank
  10. NMI_ROUTINE:
  11. sep #$20 : .as
  12. rep #$10 : .xl
  13. lda #$00
  14. pha
  15. plb
  16. lda $4210
  17. ldx #BG1_TILE_BASE+32*9
  18. stx $2116
  19. DMA0(#$01, #36*64, #^BG1_TILE_BUF, #!BG1_TILE_BUF+64*9, #$18)
  20. ldx #BG2_TILE_BASE+32*9
  21. stx $2116
  22. DMA0(#$01, #36*64, #^BG2_TILE_BUF, #!BG2_TILE_BUF+64*9, #$18)
  23. ldx #BG2_TILE_BASE
  24. stx $2116
  25. DMA0(#$01, #64*9, #^BG2_TILE_BUF, #!BG2_TILE_BUF, #$18)
  26. lda bar_yl
  27. asl
  28. asl
  29. tax
  30. lda barstep
  31. php
  32. txa
  33. dec
  34. plp
  35. bne small_bar
  36. asl
  37. bra normal_bar
  38. small_bar
  39. clc
  40. adc #31
  41. normal_bar
  42. sta bar_y
  43. lda bar_y
  44. cmp #224
  45. bne +
  46. lda #1
  47. +
  48. sta bar_y
  49. cmp #113
  50. bcs lower_half
  51. sta hdma_math
  52. lda #$01
  53. sta hdma_math+3
  54. bra math_cont
  55. lower_half
  56. clc
  57. sbc #110
  58. sta hdma_math+3
  59. lda #112
  60. sta hdma_math
  61. math_cont
  62. lda #$3e ; ch. 1-5
  63. sta @$420c ; trigger HDMA
  64. lda #$01
  65. sta isr_done
  66. rtl
  67. ; IRQ - called when triggered
  68. IRQ_ROUTINE:
  69. sep #$20 : .as
  70. lda $4211 ;Acknowledge irq
  71. rtl