vertical wave
[snes_test1] / test.asm
index e3a31e8..eff673c 100644 (file)
--- a/test.asm
+++ b/test.asm
@@ -3,16 +3,26 @@
 
        .segment "rodata"
        .include "data.inc"
+       .include "sintab.inc"
 
        .segment "code"
 
+       .macro A16
+       rep #$20
+       .a16
+       .endmacro
+       .macro A8
+       sep #$20
+       .a8
+       .endmacro
+
        ; VMEM map
        ; 0000: tilemap for BG1 (32x32 4bpp: 512b)
        ; 2048: BG3-base (h/v offsets)
        ; 8192: tile data (16k)
-
        vmem_tiles_offs = 4096  ; 4k words
-       hoffs_offs = 1024       ; 2k words
+       vmem_hoffs_offs = 1024  ; 2k words
+       vmem_voffs_offs = vmem_hoffs_offs + 32
 
        sei
        clc
        .i8
 
        jsr snes_init
+       setreg REG_SETINI, $4   ; 239 lines
        setreg REG_BGMODE, $02  ; mode 2, 8x8 tiles
        setreg REG_BG12NBA, $1  ; tiles at offs 8kb
        setreg REG_TM, $1       ; main screen: BG1
+       setreg REG_BG3SC, (vmem_hoffs_offs / 1024) << 2
 
        ldx #0
 cmap_loop:
@@ -48,30 +60,79 @@ cmap_loop:
        pea logo4bpp_tiles
        pea vmem_tiles_offs
        jsr copy_vmem
-       rep #$20
-       .a16
+       A16
        pla
        pla
        pla
-       sep #$20
-       .a8
+       A8
 
        pea logo4bpp_tilemap_rows * logo4bpp_tilemap_cols * 2
        pea logo4bpp_tilemap
        pea 0
        jsr copy_vmem
-       rep #$20
-       .a16
+       A16
        pla
        pla
        pla
-       sep #$20
-       .a8
+       A8
 
        fblank 0
 
-halt:
-       jmp halt
+       ; main loop
+       nframe = 0
+       ncol = 2
+       anim = 4
+
+       A16
+       stz nframe
+       A8
+mainloop:
+       wait_vblank
+
+       A16
+       lda nframe
+       lsr
+       lsr
+       sta anim
+       inc nframe
+       A8
+
+       lda #(vmem_voffs_offs & $ff)
+       sta REG_VMADDL
+       lda #(vmem_voffs_offs >> 8)
+       sta REG_VMADDH
+
+       stz ncol
+@cloop:
+       lda anim
+       clc
+       adc ncol
+       asl
+       tax
+       lda sintab,x
+       lsr
+       lsr
+       lsr
+
+       ldx ncol
+       bne @per_tile_offs
+       ; global scroll for the first column
+       sta REG_BG1VOFFS
+       stz REG_BG1VOFFS
+       bra @end
+
+@per_tile_offs:
+       sta REG_VMDATAL
+       lda #$20        ; enable for BG1
+       sta REG_VMDATAH
+@end:
+
+       inc ncol
+       lda ncol
+       and #$1f
+       bne @cloop
+
+       bra mainloop
 
        ; copy_vmem(vmem_offset, src, num_words)
 copy_vmem: