sorta runs but not in time

This commit is contained in:
Brooke Vibber 2022-12-07 16:35:07 -08:00
parent 1523865db4
commit ce569211b8

View file

@ -26,6 +26,7 @@ sample_ptrl = $84
sample_ptrh = $85 sample_ptrh = $85
sample_ptr = sample_ptrl sample_ptr = sample_ptrl
scanline = $86 scanline = $86
audiotemp = $87
height = 160 height = 160
bytes_per_line = 40 bytes_per_line = 40
@ -66,6 +67,29 @@ displaylist:
.byte $41 ; jump and blank .byte $41 ; jump and blank
.addr displaylist .addr displaylist
audio_high_byte:
.scope
.macro byteseq val
.repeat 16
.byte val | $10
.endrep
.endmacro
byteseq $0
byteseq $1
byteseq $2
byteseq $3
byteseq $4
byteseq $5
byteseq $7
byteseq $8
byteseq $9
byteseq $a
byteseq $b
byteseq $c
byteseq $d
byteseq $e
byteseq $f
.endscope
.code .code
@ -125,21 +149,28 @@ wait_start:
; Resynchronize the scanline counter ; Resynchronize the scanline counter
wait_loop: wait_loop:
lda VCOUNT lda VCOUNT
tay ; save for audio lookup
bne wait_loop bne wait_loop
lda #(256 - scanline_offset) lda #(256 - scanline_offset)
sta scanline sta scanline
each_scanline: each_scanline:
.macro audio_prep
ldy VCOUNT ; 4 cycles
lda (sample_ptr),y ; 5/6 cyc
sta audiotemp ; 3 cyc
.endmacro
.macro inner_scanline .macro inner_scanline
; it'll fire on unused lines, but harmlessly ; it'll fire on unused lines, but harmlessly
ldy scanline ; 3 cyc ldy scanline ; 3 cyc
inc scanline ; 5 cyc inc scanline ; 5 cyc
; Leisurely memory fetches ; Leisurely memory fetches
lda palette1,y lda palette1,y ; 5
pha pha ; ...3?
ldx palette2,y ldx palette2,y ; 5
lda palette3,y lda palette3,y ; 5
tay tay
pla pla
@ -152,14 +183,18 @@ each_scanline:
sty COLPF2 sty COLPF2
.endmacro .endmacro
.macro audio_play .macro audio_play_lo ; 11 cycles
ldy VCOUNT ; 4 cycles lda audiotemp ; 3 cyc
lda (sample_ptr),y ; 5/6 cyc and #$0f ; 2 cyc
ora #$10 ; 2 cyc
sta AUDC1 ; 4 cyc sta AUDC1 ; 4 cyc
.endmacro .endmacro
inner_scanline .macro audio_play_hi ; 12 cycles
audio_play ldy audiotemp ; 3 cyc
lda audio_high_byte,y ; 5 cyc
sta AUDC1 ; 4 cyc
.endmacro
.macro audio_inc .macro audio_inc
; Increment sample ptr ; Increment sample ptr
@ -186,8 +221,11 @@ each_scanline:
audio_cont: audio_cont:
.endmacro .endmacro
audio_prep
inner_scanline inner_scanline
audio_play_lo
inner_scanline
audio_play_hi
lda VCOUNT lda VCOUNT
cmp #130 ;#130 cmp #130 ;#130