This commit is contained in:
Brooke Vibber 2022-12-11 13:31:48 -08:00
parent 79ac4b750e
commit 659b77c5c0

View file

@ -27,6 +27,7 @@ sample_ptrh = $85
sample_ptr = sample_ptrl sample_ptr = sample_ptrl
scanline = $86 scanline = $86
audiotemp = $87 audiotemp = $87
sample_index = $80
frame_counter = $89 frame_counter = $89
height = 160 height = 160
@ -94,6 +95,8 @@ audio_high_byte:
sta sample_ptrl sta sample_ptrl
lda #.hibyte(audio_samples) lda #.hibyte(audio_samples)
sta sample_ptrh sta sample_ptrh
lda #0
sta sample_index
; Disable display DMA ; Disable display DMA
lda #$00 lda #$00
@ -168,7 +171,7 @@ wait_loop:
.macro audio_play_raw .macro audio_play_raw
;ldy VCOUNT ; set on entry ;ldy VCOUNT ; set on entry
ldy #0 ; 2 cycles ldy sample_index ; 3 cycles
lda (sample_ptr),y ; 5/6 cyc lda (sample_ptr),y ; 5/6 cyc
sta AUDC1 ; 4 cyc sta AUDC1 ; 4 cyc
.endmacro .endmacro
@ -187,20 +190,17 @@ wait_loop:
.endmacro .endmacro
.macro audio_inc .macro audio_inc
; Increment sample ptr
; 7 cycles ; 7 cycles
inc sample_ptrl ; 5 inc sample_index ; 5 cycles
bne audio_cont ; 2 bne audio_cont ; 2
; 7 cycles, optional ; 12 cycles, optional
inc sample_ptrh ; 5 inc sample_ptrh ; 5
lda sample_ptrh ; 3 lda sample_ptrh ; 3
cmp #.hibyte(audio_samples_end) ; 2 cmp #.hibyte(audio_samples_end) ; 2
bmi audio_cont ; 2 bmi audio_cont ; 2
; 10 cycles, optional ; 5 cycles, optional
lda #.lobyte(audio_samples) ; 2
sta sample_ptrl ; 3
lda #.hibyte(audio_samples) ; 2 lda #.hibyte(audio_samples) ; 2
sta sample_ptrh ; 3 sta sample_ptrh ; 3
@ -210,18 +210,15 @@ wait_loop:
.macro run_frame frame_offset .macro run_frame frame_offset
.scope .scope
each_scanline_pair: each_scanline_pair:
;audio_prep
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
audio_play_raw ; 11-12 cycles audio_play_raw ; 11-12 cycles
ldy scanline ; 3 cycles ldy scanline ; 3 cycles
;audio_play_lo
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_inc ; 7-24 cycles audio_inc ; 7-24 cycles
;audio_play_raw
;audio_play_hi ; too slow
; save for later lookup ; save for later lookup
ldy VCOUNT ; 4 cycles ldy VCOUNT ; 4 cycles