alt audio
This commit is contained in:
parent
539ecdc5ae
commit
79ac4b750e
3 changed files with 17 additions and 21 deletions
|
@ -21,5 +21,6 @@ SEGMENTS {
|
||||||
RODATA: load = MAIN, type = ro optional = yes;
|
RODATA: load = MAIN, type = ro optional = yes;
|
||||||
DATA: load = MAIN, type = rw optional = yes;
|
DATA: load = MAIN, type = rw optional = yes;
|
||||||
BSS: load = MAIN, type = bss, optional = yes, define = yes;
|
BSS: load = MAIN, type = bss, optional = yes, define = yes;
|
||||||
|
AUDIO: load = MAIN, type = ro, optional = yes, define = yes, align = 256;
|
||||||
BUFFERS: load = MAIN, type = ro, optional = yes, define = yes, align = 4096;
|
BUFFERS: load = MAIN, type = ro, optional = yes, define = yes, align = 4096;
|
||||||
}
|
}
|
||||||
|
|
30
dither4.s
30
dither4.s
|
@ -168,6 +168,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
|
||||||
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,22 +188,14 @@ wait_loop:
|
||||||
|
|
||||||
.macro audio_inc
|
.macro audio_inc
|
||||||
; Increment sample ptr
|
; Increment sample ptr
|
||||||
; 18 cycles
|
; 7 cycles
|
||||||
clc ; 2
|
inc sample_ptrl ; 5
|
||||||
lda sample_ptrl ; 3
|
bne audio_cont ; 2
|
||||||
adc #131 ; 2
|
|
||||||
sta sample_ptrl ; 3
|
|
||||||
lda sample_ptrh ; 3
|
|
||||||
adc #0 ; 2
|
|
||||||
sta sample_ptrh ; 3
|
|
||||||
|
|
||||||
; 4 cycles
|
|
||||||
cmp #.hibyte(audio_samples_end) ; 2
|
|
||||||
bmi audio_cont ; 2
|
|
||||||
|
|
||||||
; 7 cycles, optional
|
; 7 cycles, optional
|
||||||
lda sample_ptrl ; 3
|
inc sample_ptrh ;5
|
||||||
cmp #.lobyte(audio_samples_end) ; 2
|
lda sample_ptrh ; 3
|
||||||
|
cmp #.hibyte(audio_samples_end) ; 2
|
||||||
bmi audio_cont ; 2
|
bmi audio_cont ; 2
|
||||||
|
|
||||||
; 10 cycles, optional
|
; 10 cycles, optional
|
||||||
|
@ -221,21 +214,20 @@ 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
|
||||||
|
|
||||||
|
audio_play_raw ; 11-12 cycles
|
||||||
ldy scanline ; 3 cycles
|
ldy scanline ; 3 cycles
|
||||||
audio_play_raw ; 9-10 cycles
|
|
||||||
;audio_play_lo
|
;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_play_raw
|
;audio_play_raw
|
||||||
;audio_play_hi ; too slow
|
;audio_play_hi ; too slow
|
||||||
|
|
||||||
; save for audio lookup
|
; save for later lookup
|
||||||
ldy VCOUNT ; 4 cycles
|
ldy VCOUNT ; 4 cycles
|
||||||
cpy #0 ; 2 cycles
|
cpy #0 ; 2 cycles
|
||||||
bne each_scanline_pair ; 2 cycles
|
bne each_scanline_pair ; 2 cycles
|
||||||
|
|
||||||
; only once when we hit scanline 0:
|
|
||||||
audio_inc ; 22-39 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
|
||||||
|
|
|
@ -43,10 +43,13 @@ function pack(audio) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function audio2assembly(audio) {
|
function audio2assembly(audio) {
|
||||||
return `.data
|
return `
|
||||||
|
.segment "AUDIO"
|
||||||
|
|
||||||
.export audio_samples
|
.export audio_samples
|
||||||
.export audio_samples_end
|
.export audio_samples_end
|
||||||
|
|
||||||
|
.align 256
|
||||||
audio_samples:
|
audio_samples:
|
||||||
${byte2byte(pack(audio))}
|
${byte2byte(pack(audio))}
|
||||||
audio_samples_end:
|
audio_samples_end:
|
||||||
|
@ -58,7 +61,7 @@ audio_samples_end:
|
||||||
function wav2assembly(buffer) {
|
function wav2assembly(buffer) {
|
||||||
let wav = new WaveFile(buffer);
|
let wav = new WaveFile(buffer);
|
||||||
let samples = wav.getSamples();
|
let samples = wav.getSamples();
|
||||||
let n = samples.length - (samples.length % 131);
|
let n = samples.length - (samples.length % 256);
|
||||||
return audio2assembly(samples.slice(0, n));
|
return audio2assembly(samples.slice(0, n));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue