Skip to content

Commit

Permalink
Refactor Pitch/HiPitch bend logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Gumball2415 committed Jul 19, 2024
1 parent 8a3ee83 commit d92a3a1
Show file tree
Hide file tree
Showing 9 changed files with 2,147 additions and 2,129 deletions.
52 changes: 33 additions & 19 deletions Source/drivers/asm/instrument.s
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,28 @@ ft_run_instrument:
ldy #$03 ;;; ;; ; 050B
lda (var_Temp_Pointer), y
beq :+
; absolute pitch mode
; m_pInterface->SetPeriod(m_pInterface->TriggerNote(m_pInterface->GetNote()) + Value);
lda var_ch_Note, x
jsr ft_translate_freq_only

; relative pitch mode
; m_pInterface->SetPeriod(m_pInterface->GetPeriod() + Value);
; Check this
: lda #$00
sta var_Temp16 + 1
sta var_Temp16 + 1 ; 0 either way
lda var_sequence_result
sta var_Temp16
bpl @PositivePitch
@NegativePitch:
;; !! !! change the sign
;; this is stupid, but what more can i do
;; we could easily just use the same addition macro
;; but the code explicitly checks for overflow
lda #$FF
eor var_Temp16
sta var_Temp16
inc var_Temp16
inc var_Temp16
jsr ft_period_remove
jmp :+
@PositivePitch:
Expand All @@ -213,37 +220,44 @@ ft_run_instrument:
sta var_ch_SequencePtr4, x

; Check this
;m_pInterface->SetPeriod(m_pInterface->GetPeriod() + (Value << 4));
lda #$00
sta var_Temp16 + 1
sta var_Temp16 + 1 ; 0 either way
lda var_sequence_result
sta var_Temp16
ldy #$04
: clc
rol var_Temp16 ; multiply by 16
rol var_Temp16 + 1
dey
bne :-

lda var_sequence_result
bpl @PositiveHiPitch
@NegativeHiPitch:
;; !! !! change the sign
lda #$FF
eor var_Temp16 + 1
sta var_Temp16 + 1
;; !! !! this is stupid, but what more can i do
lda #$FF
eor var_Temp16
clc
adc #$01
sta var_Temp16
lda #$00
adc var_Temp16 + 1
sta var_Temp16 + 1
inc var_Temp16
; left shift 4
clc
asl var_Temp16
rol var_Temp16 + 1
asl var_Temp16
rol var_Temp16 + 1
asl var_Temp16
rol var_Temp16 + 1
asl var_Temp16
rol var_Temp16 + 1
jsr ft_period_remove
; check for over/underflow
; limitperiod()
jmp :+
@PositiveHiPitch:
; left shift 4
clc
asl var_Temp16
rol var_Temp16 + 1
asl var_Temp16
rol var_Temp16 + 1
asl var_Temp16
rol var_Temp16 + 1
asl var_Temp16
rol var_Temp16 + 1
jsr ft_period_add
: jsr ft_limit_freq
; ^^^^^^^^^^
Expand Down
419 changes: 210 additions & 209 deletions Source/drivers/drv_2a03.h

Large diffs are not rendered by default.

917 changes: 459 additions & 458 deletions Source/drivers/drv_all.h

Large diffs are not rendered by default.

504 changes: 252 additions & 252 deletions Source/drivers/drv_fds.h

Large diffs are not rendered by default.

431 changes: 216 additions & 215 deletions Source/drivers/drv_mmc5.h

Large diffs are not rendered by default.

504 changes: 252 additions & 252 deletions Source/drivers/drv_n163.h

Large diffs are not rendered by default.

452 changes: 226 additions & 226 deletions Source/drivers/drv_s5b.h

Large diffs are not rendered by default.

466 changes: 233 additions & 233 deletions Source/drivers/drv_vrc6.h

Large diffs are not rendered by default.

531 changes: 266 additions & 265 deletions Source/drivers/drv_vrc7.h

Large diffs are not rendered by default.

0 comments on commit d92a3a1

Please sign in to comment.