reset.a65 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 ; ack interrupt
  17. ldx #BG1_TILE_BASE+32*9
  18. stx $2116
  19. DMA0(#$01, #40*64, #^BG1_TILE_BUF, #!BG1_TILE_BUF+64*9, #$18)
  20. ldx #BG2_TILE_BASE+32*9
  21. stx $2116
  22. DMA0(#$01, #40*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. dec
  35. dec
  36. plp
  37. bne small_bar
  38. asl
  39. bra normal_bar
  40. small_bar
  41. clc
  42. adc #31
  43. normal_bar
  44. sta bar_y
  45. lda bar_y
  46. cmp #224
  47. bne +
  48. lda #1
  49. +
  50. sta bar_y
  51. cmp #113
  52. bcs lower_half
  53. sta hdma_math
  54. lda #$01
  55. sta hdma_math+3
  56. bra math_cont
  57. lower_half
  58. clc
  59. sbc #110
  60. sta hdma_math+3
  61. lda #112
  62. sta hdma_math
  63. math_cont
  64. lda bar_xl ; get logical cursor X pos
  65. asl
  66. dec
  67. asl ; logical pos * 4
  68. sta bar_x ; physical pos = logical pos * 4
  69. sta $2126 ; window 1 left
  70. lda bar_wl ; get logical cursor width
  71. asl
  72. asl ; pixel width = logical width * 4
  73. inc
  74. sta bar_w ; = physical width
  75. clc
  76. adc bar_x ; + X start coord
  77. sta $2127 ; window 1 right
  78. ; lda #$3e ; ch. 1-5
  79. ; sta @$420c ; trigger HDMA
  80. lda cur_bright
  81. cmp tgt_bright
  82. beq +
  83. bpl bright_down
  84. bright_up
  85. inc
  86. sta cur_bright
  87. lda $2100
  88. and #$f0
  89. ora cur_bright
  90. sta $2100
  91. bra +
  92. bright_down
  93. dec
  94. sta cur_bright
  95. lda $2100
  96. and #$f0
  97. ora cur_bright
  98. sta $2100
  99. + lda #$01
  100. sta isr_done
  101. rtl
  102. ; IRQ - called when triggered
  103. IRQ_ROUTINE:
  104. sep #$20 : .as
  105. lda $4211 ;Acknowledge irq
  106. rtl