getting closer

This commit is contained in:
Brooke Vibber 2022-12-07 20:37:52 -08:00
parent 589ccdc7f1
commit 1c7a7551d7
2 changed files with 54 additions and 55 deletions

View file

@ -741,9 +741,11 @@ ${byte2byte(frames[1].bitmap.slice(half))}
.align 1024
displaylist:
; 40 lines overscan
.repeat 5
.repeat 4
.byte $70 ; 8 blank lines
.endrep
; include a DLI to mark us as frame 0
.byte $f0 ; 8 blank lines
; 160 lines graphics
; ANTIC mode e (160px 2bpp, 1 scan line per line)

View file

@ -1,4 +1,7 @@
SAVMSC = $58
VDSLST = $200
VDSLSTL = $200
VDSLSTH = $201
COLPF0 = $D016
COLPF1 = $D017
COLPF2 = $D018
@ -24,6 +27,7 @@ sample_ptrh = $85
sample_ptr = sample_ptrl
scanline = $86
audiotemp = $87
frame_counter = $89
height = 160
bytes_per_line = 40
@ -99,6 +103,16 @@ audio_high_byte:
lda #.hibyte(displaylist)
sta DLISTH
; Set up the DLI handler
lda #.lobyte(dli_handler)
sta VDSLSTL
lda #.hibyte(dli_handler)
sta VDSLSTH
; Disable VBI but allow Reset and DLI
lda #$a0
sta NMIEN
; Manually wait for first scan line
wait_vblank:
sta WSYNC
@ -113,25 +127,28 @@ wait_start:
; Wait for the vblank
; Resynchronize the scanline counter
wait_loop:
lda VCOUNT
tay ; save for audio lookup
ldy VCOUNT
bne wait_loop
lda #(256 - scanline_offset)
sta scanline
each_scanline:
.macro audio_prep
; Y is VCOUNT at entry
lda (sample_ptr),y ; 5/6 cyc
sta audiotemp ; 3 cyc
.endmacro
.macro inner_scanline frame_base
.macro inner_scanline palette1, palette2, palette3
; it'll fire on unused lines, but harmlessly
ldy scanline ; 3 cyc
inc scanline ; 5 cyc
; Leisurely memory fetches
; lda palette1,y ; 5 @FIXME alternate
; pha ; ...3?
; ldx palette2,y ; 5
; lda palette3,y ; 5
; tay
; pla
lda frame1_palette1,y ; 5 @FIXME alternate
pha ; ...3?
ldx frame1_palette2,y ; 5
@ -186,57 +203,37 @@ each_scanline:
audio_cont:
.endmacro
.macro run_frame palette1, palette2, palette3
.scope
each_scanline:
;audio_prep
inner_scanline
inner_scanline palette1, palette2, palette3
;audio_play_lo
inner_scanline
inner_scanline palette1, palette2, palette3
;audio_play_hi
lda VCOUNT
tay ; save for audio lookup
cmp #130 ;#130
ldy VCOUNT ; save for audio lookup
cpy #130
bne each_scanline
audio_inc
;audio_inc
inc frame_counter
jmp wait_start
.endscope
.endmacro
lda #(256 - scanline_offset)
sta scanline
lda frame_counter
bne run_frame2
run_frame frame1_palette1, frame1_palette2, frame1_palette3
run_frame2:
run_frame frame2_palette1, frame2_palette2, frame2_palette3
.endproc
; temp1 contains source address
; temp2 contains dest address
; clobbers a/x/y
; incremepts temp1 and temp2 to the end of their regions
.proc copy_half_frame
ldx #0
copy_loop_lines:
ldy #00
copy_loop_bytes:
lda (temp1),y
sta (temp2),y
iny
cpy #bytes_per_line
bne copy_loop_bytes
clc
lda temp1l
adc #bytes_per_line
sta temp1l
lda temp1h
adc #00
sta temp1h
clc
lda temp2l
adc #bytes_per_line
sta temp2l
lda temp2h
adc #00
sta temp2h
inx
cpx #(height / 2)
bne copy_loop_lines
rts
.proc dli_handler
lda #0
sta frame_counter
rti
.endproc