reset.a65 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. 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 bar_xl ; get logical cursor X pos
  63. asl
  64. dec
  65. asl ; logical pos * 4
  66. sta bar_x ; physical pos = logical pos * 4
  67. sta $2126 ; window 1 left
  68. lda bar_wl ; get logical cursor width
  69. asl
  70. asl ; pixel width = logical width * 4
  71. inc
  72. sta bar_w ; = physical width
  73. clc
  74. adc bar_x ; + X start coord
  75. sta $2127 ; window 1 right
  76. lda #$3e ; ch. 1-5
  77. sta @$420c ; trigger HDMA
  78. lda #$01
  79. sta isr_done
  80. rtl
  81. ; IRQ - called when triggered
  82. IRQ_ROUTINE:
  83. sep #$20 : .as
  84. lda $4211 ;Acknowledge irq
  85. rtl