Skip to content

Commit

Permalink
Fix N163 portamento shift in linear period
Browse files Browse the repository at this point in the history
Fixes #276.
  • Loading branch information
Gumball2415 committed Jul 22, 2024
1 parent 4ce047d commit 718183d
Show file tree
Hide file tree
Showing 9 changed files with 2,537 additions and 2,488 deletions.
45 changes: 42 additions & 3 deletions Source/drivers/asm/effects.s
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,10 @@ ft_calc_period:
;
ft_portamento:
lda var_ch_EffParam, x ; Check portamento, if speed > 0
beq @NoPortamento
jeq @NoPortamento
lda var_ch_PortaToLo, x ; and if freq > 0, else stop
ora var_ch_PortaToHi, x
beq @NoPortamento
jeq @NoPortamento
lda var_ch_TimerPeriodHi, x ; Compare high byte
cmp var_ch_PortaToHi, x
bcc @Increase
Expand All @@ -487,6 +487,24 @@ ft_portamento:
sta var_Temp16
lda #$00
sta var_Temp16 + 1
.if .defined(USE_N163)
.if .defined(USE_LINEARPITCH)
lda var_SongFlags
and #FLAG_LINEARPITCH
bne :+
;; !! !! only apply N163 pitch slide shift when linear pitch is disabled
; see CChannelHandlerN163::SetupSlide()
.endif
lda ft_channel_type, x
cmp #CHAN_N163
bne :+
; Multiply by 4
asl var_Temp16
rol var_Temp16 + 1
asl var_Temp16
rol var_Temp16 + 1
:
.endif
jsr ft_period_remove

.if 0
Expand Down Expand Up @@ -515,6 +533,24 @@ ft_portamento:
sta var_Temp16
lda #$00
sta var_Temp16 + 1
.if .defined(USE_N163)
.if .defined(USE_LINEARPITCH)
lda var_SongFlags
and #FLAG_LINEARPITCH
bne :+
;; !! !! only apply N163 pitch slide shift when linear pitch is disabled
; see CChannelHandlerN163::SetupSlide()
.endif
lda ft_channel_type, x
cmp #CHAN_N163
bne :+
; Multiply by 4
asl var_Temp16
rol var_Temp16 + 1
asl var_Temp16
rol var_Temp16 + 1
:
.endif
jsr ft_period_add
.if 0
clc
Expand Down Expand Up @@ -557,6 +593,7 @@ ft_portamento_up:
and #FLAG_LINEARPITCH
bne :+
;; !! !! only apply N163 pitch slide shift when linear pitch is disabled
; see CChannelHandlerN163::HandleEffect()
.endif
lda ft_channel_type, x
cmp #CHAN_N163
Expand Down Expand Up @@ -584,6 +621,7 @@ ft_portamento_down:
and #FLAG_LINEARPITCH
bne :+
;; !! !! only apply N163 pitch slide shift when linear pitch is disabled
; see CChannelHandlerN163::HandleEffect()
.endif
lda ft_channel_type, x
cmp #CHAN_N163
Expand Down Expand Up @@ -831,7 +869,7 @@ ft_vibrato:
beq @Inverted
.endif

; TODO use ft_period_remove
; ft_period_remove applies clamp. we don't need that yet
sec
lda var_ch_PeriodCalcLo, x
sbc var_Temp16
Expand All @@ -842,6 +880,7 @@ ft_vibrato:
rts

@Inverted:
; ft_period_add applies clamp. we don't need that yet
clc
lda var_ch_PeriodCalcLo, x
adc var_Temp16
Expand Down
516 changes: 258 additions & 258 deletions Source/drivers/drv_2a03.h

Large diffs are not rendered by default.

1,006 changes: 505 additions & 501 deletions Source/drivers/drv_all.h

Large diffs are not rendered by default.

600 changes: 300 additions & 300 deletions Source/drivers/drv_fds.h

Large diffs are not rendered by default.

524 changes: 263 additions & 261 deletions Source/drivers/drv_mmc5.h

Large diffs are not rendered by default.

601 changes: 302 additions & 299 deletions Source/drivers/drv_n163.h

Large diffs are not rendered by default.

548 changes: 274 additions & 274 deletions Source/drivers/drv_s5b.h

Large diffs are not rendered by default.

557 changes: 279 additions & 278 deletions Source/drivers/drv_vrc6.h

Large diffs are not rendered by default.

628 changes: 314 additions & 314 deletions Source/drivers/drv_vrc7.h

Large diffs are not rendered by default.

0 comments on commit 718183d

Please sign in to comment.