2022-11-20 23:43:34 +00:00
|
|
|
SAVMSC = $58
|
2022-11-25 19:51:27 +00:00
|
|
|
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:
|
2022-11-26 03:17:34 +00:00
|
|
|
; @fixme resolve the line counts
|
2022-11-25 19:51:27 +00:00
|
|
|
.repeat 3
|
|
|
|
.byte $70 ; 8 blank lines
|
|
|
|
.endrep
|
2022-11-26 03:17:34 +00:00
|
|
|
; 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
|
2022-11-25 19:51:27 +00:00
|
|
|
.addr framebuffer
|
2022-11-26 03:17:34 +00:00
|
|
|
.repeat 95
|
|
|
|
.byte $0e
|
|
|
|
.endrep
|
|
|
|
.byte $4e
|
|
|
|
.addr framebuffer + 96*40
|
|
|
|
.repeat 95
|
2022-11-25 19:51:27 +00:00
|
|
|
.byte $0e
|
|
|
|
.endrep
|
|
|
|
.byte $41 ; jump and blank
|
|
|
|
.addr displaylist
|
|
|
|
|
2022-11-20 23:43:34 +00:00
|
|
|
|
|
|
|
.code
|
|
|
|
|
|
|
|
.export start
|
|
|
|
|
|
|
|
.proc start
|
2022-11-25 19:51:27 +00:00
|
|
|
; Disable display DMA
|
|
|
|
lda #$00
|
|
|
|
sta SDMCTL
|
|
|
|
; Set up the display list
|
2022-11-26 01:35:10 +00:00
|
|
|
lda #.lobyte(displaylist)
|
2022-11-25 19:51:27 +00:00
|
|
|
sta SDLSTL
|
2022-11-26 01:35:10 +00:00
|
|
|
lda #.hibyte(displaylist)
|
2022-11-25 19:51:27 +00:00
|
|
|
sta SDLSTH
|
|
|
|
|
|
|
|
; Turn off interrupts except reset button
|
2022-11-26 03:17:34 +00:00
|
|
|
;lda #$20
|
|
|
|
;sta NMIEN
|
2022-11-25 19:51:27 +00:00
|
|
|
|
|
|
|
; Manually wait for first scan line
|
|
|
|
wait_vblank:
|
|
|
|
lda VCOUNT
|
2022-11-26 01:35:10 +00:00
|
|
|
bne wait_vblank
|
2022-11-25 19:51:27 +00:00
|
|
|
|
|
|
|
; Re-enable display DMA
|
|
|
|
lda #$22
|
|
|
|
sta SDMCTL
|
|
|
|
|
2022-11-26 03:17:34 +00:00
|
|
|
wait_start:
|
|
|
|
lda VCOUNT
|
|
|
|
cmp #12
|
|
|
|
bne wait_start
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
each_scanline:
|
|
|
|
tya
|
|
|
|
pha
|
2022-11-25 19:51:27 +00:00
|
|
|
|
2022-11-26 03:17:34 +00:00
|
|
|
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
|
2022-11-20 23:43:34 +00:00
|
|
|
iny
|
2022-11-26 03:17:34 +00:00
|
|
|
cpy #192
|
|
|
|
bne each_scanline
|
|
|
|
|
|
|
|
jmp wait_start
|
2022-11-25 19:51:27 +00:00
|
|
|
|
2022-11-20 23:43:34 +00:00
|
|
|
.endproc
|
2022-11-26 03:17:34 +00:00
|
|
|
|
|
|
|
; Loop through scan lines updating the palette
|
|
|
|
.proc update_palette
|
|
|
|
rts
|
|
|
|
.endproc
|