mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-09-13 12:56:30 +00:00
pt3: fix an issue with signed 8-bit comparisons
signed 8-bit comparisons are a huge pain on 6502
This commit is contained in:
parent
4672350134
commit
91c154ea7b
@ -3,3 +3,19 @@ PT3_player
|
|||||||
|
|
||||||
|
|
||||||
ASR = CMP #$80 / ROR
|
ASR = CMP #$80 / ROR
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
signed 8-bit comparison
|
||||||
|
see http://6502.org/tutorials/compare_beyond.html#2.2
|
||||||
|
|
||||||
|
SEC ; prepare carry for SBC
|
||||||
|
SBC NUM ; A-NUM
|
||||||
|
BVC LABEL ; if V is 0, N eor V = N, otherwise N eor V = N eor 1
|
||||||
|
EOR #$80 ; A = A eor $80, and N = N eor 1
|
||||||
|
LABEL
|
||||||
|
|
||||||
|
If the N flag is 1, then A (signed) < NUM (signed) and BMI will branch
|
||||||
|
If the N flag is 0, then A (signed) >= NUM (signed) and BPL will branch
|
||||||
|
@ -601,17 +601,29 @@ no_tone_sliding:
|
|||||||
and #$40
|
and #$40
|
||||||
beq amp_slide_down
|
beq amp_slide_down
|
||||||
amp_slide_up:
|
amp_slide_up:
|
||||||
|
; if (a->amplitude_sliding < 15) {
|
||||||
|
; a pain to do signed compares
|
||||||
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
||||||
cmp #15
|
sec
|
||||||
bcs done_amp_sliding ; bge
|
sbc #15
|
||||||
; if (a->amplitude_sliding < 15) {
|
bvc asu_signed
|
||||||
inc note_a+NOTE_AMPLITUDE_SLIDING,X ; a->amplitude_sliding++;
|
eor #$80
|
||||||
|
asu_signed:
|
||||||
|
bpl done_amp_sliding ; skip if A>=15
|
||||||
|
inc note_a+NOTE_AMPLITUDE_SLIDING,X ; a->amplitude_sliding++;
|
||||||
jmp done_amp_sliding
|
jmp done_amp_sliding
|
||||||
amp_slide_down:
|
amp_slide_down:
|
||||||
|
; if (a->amplitude_sliding > -15) {
|
||||||
|
; a pain to do signed compares
|
||||||
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
||||||
cmp #$f2 ; -14 1111 0010
|
sec
|
||||||
bcc done_amp_sliding ; if (a->amplitude_sliding > -15) {
|
sbc #$f1 ; -15
|
||||||
dec note_a+NOTE_AMPLITUDE_SLIDING,X ; ; a->amplitude_sliding--;
|
bvc asd_signed
|
||||||
|
eor #$80
|
||||||
|
asd_signed:
|
||||||
|
bmi done_amp_sliding ; if A < -15, skip subtract
|
||||||
|
|
||||||
|
dec note_a+NOTE_AMPLITUDE_SLIDING,X ; a->amplitude_sliding--;
|
||||||
|
|
||||||
done_amp_sliding:
|
done_amp_sliding:
|
||||||
|
|
||||||
@ -710,6 +722,8 @@ last_envelope:
|
|||||||
adc pt3_envelope_add
|
adc pt3_envelope_add
|
||||||
sta pt3_envelope_add ; pt3->envelope_add+=j;
|
sta pt3_envelope_add ; pt3->envelope_add+=j;
|
||||||
|
|
||||||
|
jmp noise_slide_done ; skip else
|
||||||
|
|
||||||
noise_slide:
|
noise_slide:
|
||||||
; Noise slide
|
; Noise slide
|
||||||
; else {
|
; else {
|
||||||
|
Loading…
Reference in New Issue
Block a user