Skip to content

Commit f002f23

Browse files
committed
NSS: fix legato FX trigger
Legato and Quick legato FX are distinguished by flags in the pipeline, and this caused an issue when enabling the FX. Fixed.
1 parent 35db3d0 commit f002f23

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

nullsound/fx-legato.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ _legato_update_pos:
9393
;; (otherwise a dedicated opcode must be used to disable legato)
9494
ld LEGATO_TRANSPOSE(ix), #0
9595
bit BIT_FX_QUICK_LEGATO, NOTE_FX(ix)
96-
jr nz, _legato_update_end
96+
jr z, _legato_update_end
9797
res BIT_FX_LEGATO, NOTE_FX(ix)
98-
_legato_update_end:
9998
res BIT_FX_QUICK_LEGATO, NOTE_FX(ix)
99+
_legato_update_end:
100100

101101
ret
102102

nullsound/nss-adpcm-b.s

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ _state_adpcm_b_end:
108108
.area CODE
109109

110110

111-
;;; context: channel action functions for FM
111+
;;; context: channel action functions for ADPCM-B
112112
state_b_action_funcs::
113113
.dw adpcm_b_configure_note_on
114114
.dw adpcm_b_configure_vol
@@ -454,18 +454,25 @@ _b_cfg_note_update:
454454
ld NOTE(ix), a
455455
ld NOTE16+1(ix), a
456456
ld NOTE16(ix), #0
457-
;; do not stop the current note if a legato is in progress
457+
;; legato have a special treatment below, otherwise prepare
458+
;; state for playing a new note from the start
458459
bit BIT_FX_LEGATO, NOTE_FX(ix)
459460
jr z, _b_post_cfg_note_update
461+
;; legato is like regular note start when no note is playing...
462+
bit BIT_PLAYING, PIPELINE(ix)
463+
jr z, _b_cfg_start_new_note
464+
;; ... otherwise it just consist in reloading a note frequency
460465
set BIT_LOAD_NOTE, PIPELINE(ix)
461466
jr _b_cfg_note_end
462467
_b_post_cfg_note_update:
463468
res BIT_NOTE_STARTED, PIPELINE(ix)
464469
_b_cfg_note_prepare_ym2610:
465-
;; stop playback on the channel, and let the pipeline restart it
470+
;; stop playback on the current channel, and let the pipeline
471+
;; restart the ADPCM-B note from start, including its macro state
466472
ld b, #REG_ADPCM_B_START_STOP
467473
ld c, #1 ; reset flag (clears start and repeat in YM2610)
468474
call ym2610_write_port_a
475+
_b_cfg_start_new_note:
469476
ld a, PIPELINE(ix)
470477
or #(STATE_PLAYING|STATE_LOAD_NOTE)
471478
ld PIPELINE(ix), a
@@ -496,7 +503,7 @@ _b_cfg_vol_end:
496503

497504

498505
;;; ADPCM_B_NOTE_ON
499-
;;; Emit a specific note (frequency) on an FM channel
506+
;;; Emit a specific note (frequency) on the ADPCM-B channel
500507
;;; ------
501508
;;; [ hl ]: note
502509
adpcm_b_note_on::

nullsound/nss-fm.s

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,19 +994,26 @@ _fm_cfg_note_update:
994994
ld NOTE(ix), a
995995
ld NOTE16+1(ix), a
996996
ld NOTE16(ix), #0
997-
;; do not stop the current note if a legato is in progress
997+
;; legato have a special treatment below, otherwise prepare
998+
;; state for playing a new note from the start
998999
bit BIT_FX_LEGATO, NOTE_FX(ix)
9991000
jr z, _fm_post_cfg_note_update
1001+
;; legato is like regular note start when no note is playing...
1002+
bit BIT_PLAYING, PIPELINE(ix)
1003+
jr z, _fm_cfg_start_new_note
1004+
;; ... otherwise it just consist in reloading a note frequency
10001005
set BIT_LOAD_NOTE, PIPELINE(ix)
10011006
jr _fm_cfg_note_end
10021007
_fm_post_cfg_note_update:
10031008
res BIT_NOTE_STARTED, PIPELINE(ix)
10041009
_fm_cfg_note_prepare_ym2610:
1005-
;; stop playback on the channel, and let the pipeline restart it
1010+
;; stop playback on the current channel, and let the pipeline
1011+
;; restart the FM note from start, including the start of macro state
10061012
ld a, (state_fm_ym2610_channel)
10071013
ld c, a
10081014
ld b, #REG_FM_KEY_ON_OFF_OPS
10091015
call ym2610_write_port_a
1016+
_fm_cfg_start_new_note:
10101017
ld a, PIPELINE(ix)
10111018
or #(STATE_PLAYING|STATE_EVAL_MACRO|STATE_LOAD_NOTE)
10121019
ld PIPELINE(ix), a

nullsound/nss-ssg.s

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -848,20 +848,26 @@ _ssg_cfg_note_update:
848848
ld NOTE(ix), a
849849
ld NOTE16+1(ix), a
850850
ld NOTE16(ix), #0
851-
;; do not stop the current note if a legato is in progress
851+
;; legato have a special treatment below, otherwise prepare
852+
;; state for playing a new note from the start
852853
bit BIT_FX_LEGATO, NOTE_FX(ix)
853854
jr z, _ssg_post_cfg_note_update
855+
;; legato is like regular note start when no note is playing...
856+
bit BIT_PLAYING, PIPELINE(ix)
857+
jr z, _ssg_cfg_start_new_note
858+
;; ... otherwise it just consist in reloading a note frequency
854859
set BIT_LOAD_NOTE, PIPELINE(ix)
855860
jr _ssg_cfg_note_end
856861
_ssg_post_cfg_note_update:
857862
res BIT_NOTE_STARTED, PIPELINE(ix)
858863
_ssg_cfg_note_prepare_ym2610:
859-
;; init macro position
864+
;; reset the SSG macro, and let the pipeline restart the
865+
;; SSG note from the start
860866
ld a, MACRO_DATA(ix)
861867
ld MACRO_POS(ix), a
862868
ld a, MACRO_DATA+1(ix)
863869
ld MACRO_POS+1(ix), a
864-
;; reload all registers at the next pipeline run
870+
_ssg_cfg_start_new_note:
865871
ld a, PIPELINE(ix)
866872
or #(STATE_PLAYING|STATE_EVAL_MACRO|STATE_LOAD_NOTE)
867873
ld PIPELINE(ix), a

0 commit comments

Comments
 (0)