dither4/dither4.s
Brion Vibber e20b8503ab half works :D
need to:
* align the framebuffer on 4096 byte boundary?
* fix color reversal
2022-11-25 20:10:17 -08:00

110 lines
1.6 KiB
ArmAsm

SAVMSC = $58
SDMCTL = $22F
SDLSTL = $230
SDLSTH = $231
COLPF0 = $D016
COLPF1 = $D017
COLPF2 = $D018
COLPF3 = $D019
COLBK = $D01A
WSYNC = $D40A
VCOUNT = $D40B
NMIEN = $D40E
.data
.import palette1
.import palette2
.import palette3
.import framebuffer
displaylist:
; @fixme resolve the line counts
.repeat 3
.byte $70 ; 8 blank lines
.endrep
; 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 95
.byte $0e
.endrep
.byte $4e
.addr framebuffer + 96*40
.repeat 95
.byte $0e
.endrep
.byte $41 ; jump and blank
.addr displaylist
.code
.export start
.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:
sta WSYNC
lda VCOUNT
cmp #15
bne wait_start
ldy #0
each_scanline:
tya
pha
lda palette1,y
pha
ldx palette2,y
lda palette3,y
tay
pla
; Wait for horizontal blank
sta WSYNC
; Update color registers as fast as possible
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