From 53293e824380176d8f203eed978d8d03b421c69e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 25 Nov 2022 19:17:34 -0800 Subject: [PATCH] closer --- dither4.s | 96 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 39 deletions(-) diff --git a/dither4.s b/dither4.s index 4f49dd7..067544c 100644 --- a/dither4.s +++ b/dither4.s @@ -20,12 +20,21 @@ NMIEN = $D40E .import framebuffer displaylist: + ; @fixme resolve the line counts .repeat 3 .byte $70 ; 8 blank lines .endrep - .byte $4e ; ANTIC mode e (160px 2bpp, 1 scan line per line) + ; Note the framebuffer cannot cross a 4KiB boundary + ; so this is split in half + ; ANTIC mode e (160px 2bpp, 1 scan line per line) + .byte $4e .addr framebuffer - .repeat 191 + .repeat 95 + .byte $0e + .endrep + .byte $4e + .addr framebuffer + 96*40 + .repeat 95 .byte $0e .endrep .byte $41 ; jump and blank @@ -36,8 +45,39 @@ displaylist: .export start -; Loop through scan lines updating the palette -.proc update_palette +.proc start + ; Disable display DMA + lda #$00 + sta SDMCTL + ; Set up the display list + lda #.lobyte(displaylist) + sta SDLSTL + lda #.hibyte(displaylist) + sta SDLSTH + + ; Turn off interrupts except reset button + ;lda #$20 + ;sta NMIEN + + ; Manually wait for first scan line +wait_vblank: + lda VCOUNT + bne wait_vblank + + ; Re-enable display DMA + lda #$22 + sta SDMCTL + +wait_start: + lda VCOUNT + cmp #12 + bne wait_start + ldy #0 + +each_scanline: + tya + pha + lda palette1,y pha ldx palette2,y @@ -52,40 +92,18 @@ displaylist: sta COLPF0 stx COLPF1 sty COLPF2 + + pla + tay + iny + cpy #192 + bne each_scanline + + jmp wait_start + +.endproc + +; Loop through scan lines updating the palette +.proc update_palette rts .endproc - -.proc start - ; Disable display DMA - lda #$00 - sta SDMCTL - ; Set up the display list - lda #.lobyte(displaylist) - sta SDLSTL - lda #.hibyte(displaylist) - sta SDLSTH - - ; Turn off interrupts except reset button - lda #$20 - sta NMIEN - - ; Manually wait for first scan line -wait_vblank: - lda VCOUNT - bne wait_vblank - - ; Re-enable display DMA - lda #$22 - sta SDMCTL - -even_scanline: - ldy VCOUNT - jsr update_palette - -odd_scanline: - ldy VCOUNT - iny - jsr update_palette - jmp even_scanline - -.endproc