123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- ; This file is part of the snescom-asm demo - a demo of how to build a SNES program.
- ; See http://bisqwit.iki.fi/source/snescom.html for details.
- #include "memmap.i65"
- #include "dma.i65"
- #define TILE_ADDR_REG_VAL(addr, scsize) \
- (((addr & $FC00) >> 8) + scsize)
- #define BMAP_ADDR_REG_VAL(addr, addr2) \
- (((addr & $F000) >> 12) | (((addr2 & $F000) >> 12) << 4))
- ; NMI - called on VBlank
- NMI_ROUTINE:
- sep #$20 : .as
- rep #$10 : .xl
- lda #$00
- pha
- plb
- lda $4210 ; ack interrupt
- ldx #BG1_TILE_BASE+32*9
- stx $2116
- DMA0(#$01, #40*64, #^BG1_TILE_BUF, #!BG1_TILE_BUF+64*9, #$18)
- ldx #BG2_TILE_BASE+32*9
- stx $2116
- DMA0(#$01, #40*64, #^BG2_TILE_BUF, #!BG2_TILE_BUF+64*9, #$18)
- ldx #BG2_TILE_BASE
- stx $2116
- DMA0(#$01, #64*9, #^BG2_TILE_BUF, #!BG2_TILE_BUF, #$18)
- lda bar_yl
- asl
- asl
- tax
- lda barstep
- php
- txa
- dec
- dec
- dec
- plp
- bne small_bar
- asl
- bra normal_bar
- small_bar
- clc
- adc #31
- normal_bar
- sta bar_y
- lda bar_y
- cmp #224
- bne +
- lda #1
- +
- sta bar_y
- cmp #113
- bcs lower_half
- sta hdma_math
- lda #$01
- sta hdma_math+3
- bra math_cont
- lower_half
- clc
- sbc #110
- sta hdma_math+3
- lda #112
- sta hdma_math
- math_cont
- lda bar_xl ; get logical cursor X pos
- asl
- dec
- asl ; logical pos * 4
- sta bar_x ; physical pos = logical pos * 4
- sta $2126 ; window 1 left
- lda bar_wl ; get logical cursor width
- asl
- asl ; pixel width = logical width * 4
- inc
- sta bar_w ; = physical width
- clc
- adc bar_x ; + X start coord
- sta $2127 ; window 1 right
- ; lda #$3e ; ch. 1-5
- ; sta @$420c ; trigger HDMA
- lda cur_bright
- cmp tgt_bright
- beq +
- bpl bright_down
- bright_up
- inc
- sta cur_bright
- lda $2100
- and #$f0
- ora cur_bright
- sta $2100
- bra +
- bright_down
- dec
- sta cur_bright
- lda $2100
- and #$f0
- ora cur_bright
- sta $2100
- + lda #$01
- sta isr_done
- rtl
- ; IRQ - called when triggered
- IRQ_ROUTINE:
- sep #$20 : .as
- lda $4211 ;Acknowledge irq
- rtl
|