mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-05 21:34: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
|
||||
|
||||
|
||||
|
||||
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
|
||||
beq amp_slide_down
|
||||
amp_slide_up:
|
||||
; if (a->amplitude_sliding < 15) {
|
||||
; a pain to do signed compares
|
||||
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
||||
cmp #15
|
||||
bcs done_amp_sliding ; bge
|
||||
; if (a->amplitude_sliding < 15) {
|
||||
inc note_a+NOTE_AMPLITUDE_SLIDING,X ; a->amplitude_sliding++;
|
||||
sec
|
||||
sbc #15
|
||||
bvc asu_signed
|
||||
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
|
||||
amp_slide_down:
|
||||
; if (a->amplitude_sliding > -15) {
|
||||
; a pain to do signed compares
|
||||
lda note_a+NOTE_AMPLITUDE_SLIDING,X
|
||||
cmp #$f2 ; -14 1111 0010
|
||||
bcc done_amp_sliding ; if (a->amplitude_sliding > -15) {
|
||||
dec note_a+NOTE_AMPLITUDE_SLIDING,X ; ; a->amplitude_sliding--;
|
||||
sec
|
||||
sbc #$f1 ; -15
|
||||
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:
|
||||
|
||||
@ -710,6 +722,8 @@ last_envelope:
|
||||
adc pt3_envelope_add
|
||||
sta pt3_envelope_add ; pt3->envelope_add+=j;
|
||||
|
||||
jmp noise_slide_done ; skip else
|
||||
|
||||
noise_slide:
|
||||
; Noise slide
|
||||
; else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user