This commit is contained in:
Brooke Vibber 2024-09-07 12:12:11 -07:00
parent 8302f2132f
commit 9242ffc4e6

View file

@ -159,25 +159,24 @@ wait_loop:
sta AUDC1 ; 4 cyc sta AUDC1 ; 4 cyc
.endmacro .endmacro
.macro audio_prep .macro audio_prep ; 8-9 cycles
; Y is VCOUNT at entry ; Y is VCOUNT at entry
lda (sample_ptr),y ; 5/6 cyc lda (sample_ptr),y ; 5/6 cyc
sta audiotemp ; 3 cyc sta audiotemp ; 3 cyc
.endmacro .endmacro
; call with A pre-loaded to audiotemp .macro audio_play_lo ; 8 cycles
.macro audio_play_lo ; A is loaded with packed audio byte at entry
;lda audiotemp ; 3 cyc and #$0f ; 2 cyc
and #$0f ; 2 cyc ora #$10 ; 2 cyc
ora #$10 ; 2 cyc sta AUDC1 ; 4 cyc
sta AUDC1 ; 4 cyc
.endmacro .endmacro
; clobbers Y ; clobbers Y
.macro audio_play_hi ; 12 cycles .macro audio_play_hi ; 12 cycles
ldy audiotemp ; 3 cyc ldy audiotemp ; 3 cyc
lda audio_high_byte,y ; 5 cyc lda audio_high_byte,y ; 5 cyc
sta AUDC1 ; 4 cyc sta AUDC1 ; 4 cyc
.endmacro .endmacro
.macro audio_inc .macro audio_inc
@ -216,26 +215,25 @@ wait_loop:
sty scanline ; 3 cycles sty scanline ; 3 cycles
inner_scanline frame_offset, 0 ; 23-26 cycles before break, 12 cycles after inner_scanline frame_offset, 0 ; 23-26 cycles before break, 12 cycles after
ldy scanline ; 3 cycles ldy scanline ; 3 cycles
audio_prep audio_prep ; 8-9 cycles
audio_play_lo audio_play_lo ; 8 cycles
ldy scanline ; 3 cycles ldy scanline ; 3 cycles
inner_scanline frame_offset, 128 ; 23-26 cycles before break, 12 cycles after inner_scanline frame_offset, 128 ; 23-26 cycles before break, 12 cycles after
audio_play_hi audio_play_hi ; 12 cycles
; pair cleanup: 6 cycles
ldy VCOUNT ; 4 cycles ldy VCOUNT ; 4 cycles
bne each_scanline_pair ; 2 cycles bne each_scanline_pair ; 2 cycles
; Do bookkeeping during vblank!
audio_inc ; 22-32 cycles audio_inc ; 22-32 cycles
; frame cleanup: 11 cycles ; frame cleanup: 11 cycles
lda frame_counter ; 3 cycles lda frame_counter ; 3 cycles
eor #1 ; 2 cycles eor #1 ; 2 cycles
sta frame_counter ; 3 cycles sta frame_counter ; 3 cycles
;jmp wait_start ; 3 cycles
jmp each_frame ; 3 cycles jmp each_frame ; 3 cycles
.endscope .endscope
.endmacro .endmacro