restore to 131-line audio for now

still glitching intermittently
This commit is contained in:
Brooke Vibber 2022-12-11 17:23:41 -08:00
parent bef2600d91
commit 2b9c14449a
3 changed files with 19 additions and 20 deletions

View file

@ -21,6 +21,6 @@ SEGMENTS {
RODATA: load = MAIN, type = ro optional = yes;
DATA: load = MAIN, type = rw optional = yes;
BSS: load = MAIN, type = bss, optional = yes, define = yes;
AUDIO: load = MAIN, type = ro, optional = yes, define = yes, align = 256;
AUDIO: load = MAIN, type = ro, optional = yes, define = yes;
BUFFERS: load = MAIN, type = ro, optional = yes, define = yes, align = 4096;
}

View file

@ -27,7 +27,6 @@ sample_ptrh = $85
sample_ptr = sample_ptrl
scanline = $86
audiotemp = $87
sample_index = $80
frame_counter = $89
height = 160
@ -95,8 +94,6 @@ audio_high_byte:
sta sample_ptrl
lda #.hibyte(audio_samples)
sta sample_ptrh
lda #0
sta sample_index
; Disable display DMA
lda #$00
@ -171,7 +168,6 @@ wait_loop:
.macro audio_play_raw
;ldy VCOUNT ; set on entry
ldy sample_index ; 3 cycles
lda (sample_ptr),y ; 5/6 cyc
sta AUDC1 ; 4 cyc
.endmacro
@ -190,17 +186,20 @@ wait_loop:
.endmacro
.macro audio_inc
; 7 cycles
inc sample_index ; 5 cycles
bne audio_cont ; 2
; 22 cycles
lda sample_ptrl ; 3 cyc
clc ; 2 cyc
adc #131 ; 2 cyc
sta sample_ptrl ; 3 cyc
lda sample_ptrh ; 3 cyc
adc #0 ; 2 cyc
sta sample_ptrh ; 3 cyc
cmp #.hibyte(audio_samples_end) ; 2 cyc
bmi audio_cont ; 2 cyc
; 12 cycles, optional
inc sample_ptrh ; 5 <- here is the current hard limit
lda sample_ptrh ; 3
cmp #.hibyte(audio_samples_end) ; 2
bmi audio_cont ; 2
; 5 cycles, optional
; 10 cycles, optional
lda #.lobyte(audio_samples) ; 2
sta sample_ptrl ; 3
lda #.hibyte(audio_samples) ; 2
sta sample_ptrh ; 3
@ -217,16 +216,17 @@ wait_loop:
sty scanline ; 3 cycles
inner_scanline frame_offset, 0 ; 23-26 cycles before break, 12 cycles after
audio_play_raw ; 11-12 cycles
ldy scanline ; 3 cycles
audio_play_raw ; 8-10 cycles
inner_scanline frame_offset, 128 ; 23-26 cycles before break, 12 cycles after
audio_inc ; 7-24 cycles
; pair cleanup: 6 cycles
ldy VCOUNT ; 4 cycles
bne each_scanline_pair ; 2 cycles
audio_inc ; 22-32 cycles
; frame cleanup: 11 cycles
lda frame_counter ; 3 cycles
eor #1 ; 2 cycles

View file

@ -49,7 +49,6 @@ function audio2assembly(audio) {
.export audio_samples
.export audio_samples_end
.align 256
audio_samples:
${byte2byte(pack(audio))}
audio_samples_end:
@ -61,7 +60,7 @@ audio_samples_end:
function wav2assembly(buffer) {
let wav = new WaveFile(buffer);
let samples = wav.getSamples();
let n = samples.length - (samples.length % 256);
let n = samples.length - (samples.length % 131);
return audio2assembly(samples.slice(0, n));
}