mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-03-09 23:29:39 +00:00
pt3: optimize amplitude code
This commit is contained in:
parent
089d963d23
commit
90b8a76a4b
@ -796,7 +796,6 @@ calc_amplitude:
|
|||||||
|
|
||||||
lda sample_b1 ; a->amplitude= (b1 & 0xf);
|
lda sample_b1 ; a->amplitude= (b1 & 0xf);
|
||||||
and #$f
|
and #$f
|
||||||
sta note_a+NOTE_AMPLITUDE,X
|
|
||||||
|
|
||||||
;========================================
|
;========================================
|
||||||
; if b0 top bit is set, it means sliding
|
; if b0 top bit is set, it means sliding
|
||||||
@ -805,32 +804,31 @@ calc_amplitude:
|
|||||||
|
|
||||||
bit sample_b0 ; if ((b0 & 0x80)!=0) {
|
bit sample_b0 ; if ((b0 & 0x80)!=0) {
|
||||||
bpl done_amp_sliding ; so if top bit not set, skip
|
bpl done_amp_sliding ; so if top bit not set, skip
|
||||||
|
tay
|
||||||
|
|
||||||
;================================
|
;================================
|
||||||
; if top bits 0b11 then slide up
|
; if top bits 0b11 then slide up
|
||||||
; if top buts 0b10 then slide down
|
; if top bits 0b10 then slide down
|
||||||
|
|
||||||
; if ((b0 & 0x40)!=0) {
|
; if ((b0 & 0x40)!=0) {
|
||||||
|
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
||||||
|
sec
|
||||||
bvc amp_slide_down
|
bvc amp_slide_down
|
||||||
|
|
||||||
amp_slide_up:
|
amp_slide_up:
|
||||||
; if (a->amplitude_sliding < 15) {
|
; if (a->amplitude_sliding < 15) {
|
||||||
; a pain to do signed compares
|
; a pain to do signed compares
|
||||||
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
|
||||||
sec
|
|
||||||
sbc #15
|
sbc #15
|
||||||
bvc asu_signed
|
bvc asu_signed
|
||||||
eor #$80
|
eor #$80
|
||||||
asu_signed:
|
asu_signed:
|
||||||
bpl done_amp_sliding ; skip if A>=15
|
bpl done_amp_sliding ; skip if A>=15
|
||||||
inc note_a+NOTE_AMPLITUDE_SLIDING,X ; a->amplitude_sliding++;
|
inc note_a+NOTE_AMPLITUDE_SLIDING,X ; a->amplitude_sliding++;
|
||||||
bne done_amp_sliding
|
bne done_amp_sliding_y
|
||||||
|
|
||||||
amp_slide_down:
|
amp_slide_down:
|
||||||
; if (a->amplitude_sliding > -15) {
|
; if (a->amplitude_sliding > -15) {
|
||||||
; a pain to do signed compares
|
; a pain to do signed compares
|
||||||
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
|
||||||
sec
|
|
||||||
sbc #$f1 ; -15
|
sbc #$f1 ; -15
|
||||||
bvc asd_signed
|
bvc asd_signed
|
||||||
eor #$80
|
eor #$80
|
||||||
@ -839,28 +837,29 @@ asd_signed:
|
|||||||
|
|
||||||
dec note_a+NOTE_AMPLITUDE_SLIDING,X ; a->amplitude_sliding--;
|
dec note_a+NOTE_AMPLITUDE_SLIDING,X ; a->amplitude_sliding--;
|
||||||
|
|
||||||
|
done_amp_sliding_y:
|
||||||
|
tya
|
||||||
|
|
||||||
done_amp_sliding:
|
done_amp_sliding:
|
||||||
|
|
||||||
; a->amplitude+=a->amplitude_sliding;
|
; a->amplitude+=a->amplitude_sliding;
|
||||||
clc
|
clc
|
||||||
lda note_a+NOTE_AMPLITUDE,X
|
|
||||||
adc note_a+NOTE_AMPLITUDE_SLIDING,X
|
adc note_a+NOTE_AMPLITUDE_SLIDING,X
|
||||||
sta note_a+NOTE_AMPLITUDE,X
|
|
||||||
|
|
||||||
; clamp amplitude to 0 - 15
|
; clamp amplitude to 0 - 15
|
||||||
|
|
||||||
lda note_a+NOTE_AMPLITUDE,X
|
|
||||||
check_amp_lo:
|
check_amp_lo:
|
||||||
bpl check_amp_hi
|
bmi write_clamp_amplitude
|
||||||
lda #0
|
|
||||||
beq write_clamp_amplitude
|
|
||||||
|
|
||||||
check_amp_hi:
|
check_amp_hi:
|
||||||
cmp #16
|
cmp #16
|
||||||
bcc done_clamp_amplitude ; blt
|
bcc write_amplitude ; blt
|
||||||
lda #15
|
lda #15
|
||||||
|
.byte $2C
|
||||||
write_clamp_amplitude:
|
write_clamp_amplitude:
|
||||||
sta note_a+NOTE_AMPLITUDE,X
|
lda #0
|
||||||
|
write_amplitude:
|
||||||
|
sta note_amp_smc+1
|
||||||
|
|
||||||
done_clamp_amplitude:
|
done_clamp_amplitude:
|
||||||
|
|
||||||
@ -874,7 +873,8 @@ done_clamp_amplitude:
|
|||||||
asl ; 2
|
asl ; 2
|
||||||
asl ; 2
|
asl ; 2
|
||||||
asl ; 2
|
asl ; 2
|
||||||
ora note_a+NOTE_AMPLITUDE,X ; 4+
|
note_amp_smc:
|
||||||
|
ora #0 ; 4+
|
||||||
|
|
||||||
tay ; 2
|
tay ; 2
|
||||||
lda VolumeTable,Y ; 4+
|
lda VolumeTable,Y ; 4+
|
||||||
|
Loading…
x
Reference in New Issue
Block a user