From ce569211b842c20c10e55e15032e1aed06c401c0 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 7 Dec 2022 16:35:07 -0800 Subject: [PATCH] sorta runs but not in time --- dither4.s | 58 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/dither4.s b/dither4.s index 3f1e314..e3cc121 100644 --- a/dither4.s +++ b/dither4.s @@ -26,6 +26,7 @@ sample_ptrl = $84 sample_ptrh = $85 sample_ptr = sample_ptrl scanline = $86 +audiotemp = $87 height = 160 bytes_per_line = 40 @@ -66,6 +67,29 @@ displaylist: .byte $41 ; jump and blank .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 @@ -125,21 +149,28 @@ wait_start: ; Resynchronize the scanline counter wait_loop: lda VCOUNT + tay ; save for audio lookup bne wait_loop lda #(256 - scanline_offset) sta 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 ; it'll fire on unused lines, but harmlessly ldy scanline ; 3 cyc inc scanline ; 5 cyc ; Leisurely memory fetches - lda palette1,y - pha - ldx palette2,y - lda palette3,y + lda palette1,y ; 5 + pha ; ...3? + ldx palette2,y ; 5 + lda palette3,y ; 5 tay pla @@ -152,14 +183,18 @@ each_scanline: sty COLPF2 .endmacro - .macro audio_play - ldy VCOUNT ; 4 cycles - lda (sample_ptr),y ; 5/6 cyc + .macro audio_play_lo ; 11 cycles + lda audiotemp ; 3 cyc + and #$0f ; 2 cyc + ora #$10 ; 2 cyc sta AUDC1 ; 4 cyc .endmacro - inner_scanline - audio_play + .macro audio_play_hi ; 12 cycles + ldy audiotemp ; 3 cyc + lda audio_high_byte,y ; 5 cyc + sta AUDC1 ; 4 cyc + .endmacro .macro audio_inc ; Increment sample ptr @@ -186,8 +221,11 @@ each_scanline: audio_cont: .endmacro - + audio_prep inner_scanline + audio_play_lo + inner_scanline + audio_play_hi lda VCOUNT cmp #130 ;#130