Subversion Repositories svn.mios

Rev

Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
44 tk 1
; $Id: cs_menu_p2r_r2p.inc 44 2008-01-30 21:39:30Z tk $
1 tk 2
;
3
; SID Control Surface Menu Parameter Copy Functions
4
;
5
; ==========================================================================
6
;
7
;  Copyright 1998-2007 Thorsten Klose (tk@midibox.org)
8
;  Licensed for personal non-commercial use only.
9
;  All other rights reserved.
10
;
11
; ==========================================================================
12
 
13
; ==========================================================================
14
; ==========================================================================
15
;  refered by cs_menu_tables.inc
16
; ==========================================================================
17
; ==========================================================================
18
 
19
; ==========================================================================
20
;  All supported R2PP2R_* indices
21
; ==========================================================================
22
R2PP2R_NOP		EQU	0x00
23
 
24
R2PP2R_PAR8		EQU	0x01
25
R2PP2R_PAR16		EQU	0x02
26
 
27
R2PP2R_VAR		EQU	0x03
28
R2PP2R_VAR_SID		EQU	0x04
29
R2PP2R_VAR_OSC		EQU	0x05
30
R2PP2R_VAR_SIDLR	EQU	0x06
31
R2PP2R_VAR_CALI		EQU	0x07
32
R2PP2R_SAVE_NAME	EQU	0x08
33
R2PP2R_EDIT_SEQ		EQU	0x09
34
 
35
R2PP2R_Vx		EQU	0x0a
36
R2PP2R_Vx_4U		EQU	0x0b
37
R2PP2R_Vx_4L		EQU	0x0c
38
R2PP2R_Vx_PMD		EQU	0x0d
39
R2PP2R_Vx_GSA		EQU	0x0e
40
R2PP2R_Vx_12		EQU	0x0f
41
R2PP2R_Vx_WAV		EQU	0x10
42
R2PP2R_Vx_S_R		EQU	0x11
43
R2PP2R_Vx_ARP_ON	EQU	0x12
44
R2PP2R_Vx_ARP_DIR	EQU	0x13
45
R2PP2R_Vx_ARP_SOR	EQU	0x14
46
R2PP2R_Vx_ARP_HLD	EQU	0x15
47
R2PP2R_Vx_ARP_SNC	EQU	0x16
48
R2PP2R_Vx_ARP_CAC	EQU	0x17
49
R2PP2R_Vx_ARP_GLN	EQU	0x18
50
R2PP2R_Vx_ARP_RNG	EQU	0x19
51
R2PP2R_Vx_ARP_SPD	EQU	0x1a
52
R2PP2R_Vx_ARP_ONE	EQU	0x1b
53
 
54
R2PP2R_M_Vx_PHASE	EQU	0x1c
55
R2PP2R_M_Vx_POL		EQU	0x1d
56
R2PP2R_M_Vx_LEG		EQU	0x1e
57
R2PP2R_M_Vx_WTO		EQU	0x1f
58
R2PP2R_M_Vx_SUK		EQU	0x20
59
R2PP2R_M_Vx_VAS		EQU	0x21
60
R2PP2R_M_D_Vx_ASG	EQU	0x22
61
 
62
R2PP2R_B_Vx_MODE	EQU	0x23
63
R2PP2R_B_Vx_SEQ_SPD	EQU	0x24
64
R2PP2R_B_Vx_SEQ_S16	EQU	0x25
65
 
66
R2PP2R_D_Vx_VAS		EQU	0x26
67
 
68
R2PP2R_Fx_CHN		EQU	0x27
69
R2PP2R_Fx_CUTOFF	EQU	0x28
70
R2PP2R_Fx_RESON		EQU	0x29
71
R2PP2R_Fx_KTR		EQU	0x2a
72
R2PP2R_Fx_MOD		EQU	0x2b
73
R2PP2R_Fx_EXT		EQU	0x2c
74
R2PP2R_Fx_3OF		EQU	0x2d
75
R2PP2R_Fx_FIP		EQU	0x2e
76
 
77
R2PP2R_LFOx		EQU	0x2f
78
R2PP2R_LFOx_WAV		EQU	0x30
79
R2PP2R_LFOx_SNC		EQU	0x31
80
R2PP2R_LFOx_SNC_M	EQU	0x32
81
R2PP2R_LFOx_ONE		EQU	0x33
82
R2PP2R_LFOx_CSN		EQU	0x34
83
 
84
R2PP2R_ENVx		EQU	0x35
85
R2PP2R_ENVx_LPB		EQU	0x36
86
R2PP2R_ENVx_LPE		EQU	0x37
87
R2PP2R_ENVx_CSN		EQU	0x38
88
 
89
R2PP2R_MODx		EQU	0x39
90
R2PP2R_MODx_SRC		EQU	0x3a
91
R2PP2R_MODx_OP		EQU	0x3b
92
R2PP2R_MODx_INV1	EQU	0x3c
93
R2PP2R_MODx_INV2	EQU	0x3d
94
R2PP2R_MODx_Nx		EQU	0x3e
95
 
96
R2PP2R_TRGx_Nx		EQU	0x3f
97
 
98
R2PP2R_CHN		EQU	0x40
99
R2PP2R_BNK		EQU	0x41
100
R2PP2R_PAT		EQU	0x42
101
R2PP2R_B0		EQU	0x43
102
R2PP2R_B1		EQU	0x44
103
R2PP2R_B2		EQU	0x45
104
 
105
R2PP2R_CLK_BPM		EQU	0x46
106
R2PP2R_CLK_SLAVE	EQU	0x47
107
 
108
R2PP2R_KNB_VALUE	EQU	0x48
109
R2PP2R_KNB_P		EQU	0x49
110
R2PP2R_KNB_ASG		EQU	0x4a
111
 
112
R2PP2R_EXT_VALUE	EQU	0x4b
113
R2PP2R_EXT_SWITCH	EQU	0x4c
114
 
115
R2PP2R_WTx_PAR		EQU	0x4d
116
R2PP2R_WTx_SID		EQU	0x4e
117
R2PP2R_WTx_SPD		EQU	0x4f
118
R2PP2R_WTx_B6		EQU	0x50
119
R2PP2R_WTx_B7		EQU	0x51
120
R2PP2R_WTx_POS		EQU	0x52
121
R2PP2R_WTx_LOP		EQU	0x53
122
 
123
R2PP2R_WTE_PAR		EQU	0x54
124
R2PP2R_WT_VAL		EQU	0x55
125
 
126
R2PP2R_B_SEQ_VAL	EQU	0x56
127
 
128
R2PP2R_ENSx_VAL		EQU	0x57
129
R2PP2R_ENSxIx_VAL	EQU	0x58
130
R2PP2R_ENSx_X2A		EQU	0x59
131
R2PP2R_ENSx_RESERVED	EQU	0x5a
132
R2PP2R_ENSx_MONO	EQU	0x5b
133
R2PP2R_ENSx_SPV		EQU	0x5c
134
R2PP2R_ENSx_EXTINV	EQU	0x5d
135
 
136
R2PP2R_303_CUTOFF	EQU	0x5e
137
R2PP2R_303_DEP		EQU	0x5f
138
R2PP2R_303_DEC		EQU	0x60
139
 
140
 
141
	;; help macro
142
R2PP2R_TARGET MACRO p2r_func, r2p_func
143
	bra	p2r_func
144
	bra	r2p_func
145
	ENDM
146
 
147
; ==========================================================================
148
;  The P2R handler
149
;; IN: R2PP2R_xxx ID in WREG
150
; ==========================================================================
151
CS_MENU_P2R_Handler
152
	mullw	4
153
	rgoto	CS_MENU_P2R_Handler_Jmp
154
 
155
; ==========================================================================
156
;  The R2P handler
157
;; IN: R2PP2R_xxx ID in WREG
158
; ==========================================================================
159
CS_MENU_R2P_Handler
160
	mullw	4
161
	movlw	2
162
	addwf	PRODL, F
163
 
164
CS_MENU_P2R_Handler_Jmp
165
	call	CS_MENU_P2RR2P_GetIndex_2bytes	; special variant of MIOS_HLP_GetIndex_2bytes which allows to add 16bit values (PROD[LH])
166
	R2PP2R_TARGET	CS_MENU_P2R_NOP, CS_MENU_R2P_NOP
167
 
168
	R2PP2R_TARGET	CS_MENU_P2R_PAR8, CS_MENU_R2P_PAR8
169
	R2PP2R_TARGET	CS_MENU_P2R_PAR16, CS_MENU_R2P_PAR16
170
 
171
	R2PP2R_TARGET	CS_MENU_P2R_VAR, CS_MENU_R2P_VAR
172
	R2PP2R_TARGET	CS_MENU_P2R_VAR_SID, CS_MENU_R2P_VAR_SID
173
	R2PP2R_TARGET	CS_MENU_P2R_VAR_OSC, CS_MENU_R2P_VAR_OSC
174
	R2PP2R_TARGET	CS_MENU_P2R_VAR_SIDLR, CS_MENU_R2P_VAR_SIDLR
175
	R2PP2R_TARGET	CS_MENU_P2R_VAR_CALI, CS_MENU_R2P_VAR_CALI
176
	R2PP2R_TARGET	CS_MENU_P2R_SAVE_NAME, CS_MENU_R2P_SAVE_NAME
177
	R2PP2R_TARGET	CS_MENU_P2R_EDIT_SEQ, CS_MENU_R2P_EDIT_SEQ
178
 
179
	R2PP2R_TARGET	CS_MENU_P2R_Vx, CS_MENU_R2P_Vx
180
	R2PP2R_TARGET	CS_MENU_P2R_Vx_4U, CS_MENU_R2P_Vx_4U
181
	R2PP2R_TARGET	CS_MENU_P2R_Vx_4L, CS_MENU_R2P_Vx_4L
182
	R2PP2R_TARGET	CS_MENU_P2R_Vx_PMD,CS_MENU_R2P_Vx_PMD
183
	R2PP2R_TARGET	CS_MENU_P2R_Vx_GSA,CS_MENU_R2P_Vx_GSA
184
	R2PP2R_TARGET	CS_MENU_P2R_Vx_12, CS_MENU_R2P_Vx_12
185
	R2PP2R_TARGET	CS_MENU_P2R_Vx_WAV, CS_MENU_R2P_Vx_WAV
186
	R2PP2R_TARGET	CS_MENU_P2R_Vx_S_R, CS_MENU_R2P_Vx_S_R
187
	R2PP2R_TARGET	CS_MENU_P2R_Vx_ARP_ON, CS_MENU_R2P_Vx_ARP_ON
188
	R2PP2R_TARGET	CS_MENU_P2R_Vx_ARP_DIR, CS_MENU_R2P_Vx_ARP_DIR
189
	R2PP2R_TARGET	CS_MENU_P2R_Vx_ARP_SOR, CS_MENU_R2P_Vx_ARP_SOR
190
	R2PP2R_TARGET	CS_MENU_P2R_Vx_ARP_HLD, CS_MENU_R2P_Vx_ARP_HLD
191
	R2PP2R_TARGET	CS_MENU_P2R_Vx_ARP_SNC, CS_MENU_R2P_Vx_ARP_SNC
192
	R2PP2R_TARGET	CS_MENU_P2R_Vx_ARP_CAC, CS_MENU_R2P_Vx_ARP_CAC
193
	R2PP2R_TARGET	CS_MENU_P2R_Vx_ARP_GLN, CS_MENU_R2P_Vx_ARP_GLN
194
	R2PP2R_TARGET	CS_MENU_P2R_Vx_ARP_RNG, CS_MENU_R2P_Vx_ARP_RNG
195
	R2PP2R_TARGET	CS_MENU_P2R_Vx_ARP_SPD, CS_MENU_R2P_Vx_ARP_SPD
196
	R2PP2R_TARGET	CS_MENU_P2R_Vx_ARP_ONE, CS_MENU_R2P_Vx_ARP_ONE
197
 
198
	R2PP2R_TARGET	CS_MENU_P2R_M_Vx_PHASE, CS_MENU_R2P_M_Vx_PHASE
199
	R2PP2R_TARGET	CS_MENU_P2R_M_Vx_POL, CS_MENU_R2P_M_Vx_POL
200
	R2PP2R_TARGET	CS_MENU_P2R_M_Vx_LEG, CS_MENU_R2P_M_Vx_LEG
201
	R2PP2R_TARGET	CS_MENU_P2R_M_Vx_WTO, CS_MENU_R2P_M_Vx_WTO
202
	R2PP2R_TARGET	CS_MENU_P2R_M_Vx_SUK, CS_MENU_R2P_M_Vx_SUK
203
	R2PP2R_TARGET	CS_MENU_P2R_M_Vx_VAS, CS_MENU_R2P_M_Vx_VAS
204
	R2PP2R_TARGET	CS_MENU_P2R_M_D_Vx_ASG, CS_MENU_R2P_M_D_Vx_ASG
205
 
206
	R2PP2R_TARGET	CS_MENU_P2R_B_Vx_MODE, CS_MENU_R2P_B_Vx_MODE
207
	R2PP2R_TARGET	CS_MENU_P2R_B_Vx_SEQ_SPD, CS_MENU_R2P_B_Vx_SEQ_SPD
208
	R2PP2R_TARGET	CS_MENU_P2R_B_Vx_SEQ_S16, CS_MENU_R2P_B_Vx_SEQ_S16
209
 
210
	R2PP2R_TARGET	CS_MENU_P2R_D_Vx_VAS, CS_MENU_R2P_D_Vx_VAS
211
 
212
	R2PP2R_TARGET	CS_MENU_P2R_Fx_CHN, CS_MENU_R2P_Fx_CHN
213
	R2PP2R_TARGET	CS_MENU_P2R_Fx_CUTOFF, CS_MENU_R2P_Fx_CUTOFF
214
	R2PP2R_TARGET	CS_MENU_P2R_Fx_RESON, CS_MENU_R2P_Fx_RESON
215
	R2PP2R_TARGET	CS_MENU_P2R_Fx_KTR, CS_MENU_R2P_Fx_KTR
216
	R2PP2R_TARGET	CS_MENU_P2R_Fx_MOD, CS_MENU_R2P_Fx_MOD
217
	R2PP2R_TARGET	CS_MENU_P2R_Fx_EXT, CS_MENU_R2P_Fx_EXT
218
	R2PP2R_TARGET	CS_MENU_P2R_Fx_3OF, CS_MENU_R2P_Fx_3OF
219
	R2PP2R_TARGET	CS_MENU_P2R_Fx_FIP, CS_MENU_R2P_Fx_FIP
220
 
221
	R2PP2R_TARGET	CS_MENU_P2R_LFOx, CS_MENU_R2P_LFOx
222
	R2PP2R_TARGET	CS_MENU_P2R_LFOx_WAV, CS_MENU_R2P_LFOx_WAV
223
	R2PP2R_TARGET	CS_MENU_P2R_LFOx_SNC, CS_MENU_R2P_LFOx_SNC
224
	R2PP2R_TARGET	CS_MENU_P2R_LFOx_SNC_M, CS_MENU_R2P_LFOx_SNC_M
225
	R2PP2R_TARGET	CS_MENU_P2R_LFOx_ONE, CS_MENU_R2P_LFOx_ONE
226
	R2PP2R_TARGET	CS_MENU_P2R_LFOx_CSN, CS_MENU_R2P_LFOx_CSN
227
 
228
	R2PP2R_TARGET	CS_MENU_P2R_ENVx, CS_MENU_R2P_ENVx
229
	R2PP2R_TARGET	CS_MENU_P2R_ENVx_LPB, CS_MENU_R2P_ENVx_LPB
230
	R2PP2R_TARGET	CS_MENU_P2R_ENVx_LPE, CS_MENU_R2P_ENVx_LPE
231
	R2PP2R_TARGET	CS_MENU_P2R_ENVx_CSN, CS_MENU_R2P_ENVx_CSN
232
 
233
	R2PP2R_TARGET	CS_MENU_P2R_MODx, CS_MENU_R2P_MODx
234
	R2PP2R_TARGET	CS_MENU_P2R_MODx_SRC, CS_MENU_R2P_MODx_SRC
235
	R2PP2R_TARGET	CS_MENU_P2R_MODx_OP, CS_MENU_R2P_MODx_OP
236
	R2PP2R_TARGET	CS_MENU_P2R_MODx_INV1, CS_MENU_R2P_MODx_INV1
237
	R2PP2R_TARGET	CS_MENU_P2R_MODx_INV2, CS_MENU_R2P_MODx_INV2
238
	R2PP2R_TARGET	_CS_MENU_P2R_MODx_Nx, _CS_MENU_R2P_MODx_Nx
239
 
240
	R2PP2R_TARGET	_CS_MENU_P2R_TRGx_Nx, _CS_MENU_R2P_TRGx_Nx
241
 
242
	R2PP2R_TARGET	CS_MENU_P2R_CHN, CS_MENU_R2P_CHN
243
	R2PP2R_TARGET	CS_MENU_P2R_BNK, CS_MENU_R2P_BNK
244
	R2PP2R_TARGET	CS_MENU_P2R_PAT, CS_MENU_R2P_PAT
245
	R2PP2R_TARGET	CS_MENU_P2R_B0, CS_MENU_R2P_B0
246
	R2PP2R_TARGET	CS_MENU_P2R_B1, CS_MENU_R2P_B1
247
	R2PP2R_TARGET	CS_MENU_P2R_B2, CS_MENU_R2P_B2
248
 
249
	R2PP2R_TARGET	CS_MENU_P2R_CLK_BPM, CS_MENU_R2P_CLK_BPM
250
	R2PP2R_TARGET	CS_MENU_P2R_CLK_SLAVE, CS_MENU_R2P_CLK_SLAVE
251
 
252
	R2PP2R_TARGET	CS_MENU_P2R_KNB_VALUE, CS_MENU_R2P_KNB_VALUE
253
	R2PP2R_TARGET	CS_MENU_P2R_KNB_P, CS_MENU_R2P_KNB_P
254
	R2PP2R_TARGET	CS_MENU_P2R_KNB_ASG, CS_MENU_R2P_KNB_ASG
255
 
256
	R2PP2R_TARGET	CS_MENU_P2R_EXT_VALUE, CS_MENU_R2P_EXT_VALUE
257
	R2PP2R_TARGET	CS_MENU_P2R_EXT_SWITCH, CS_MENU_R2P_EXT_SWITCH
258
 
259
	R2PP2R_TARGET	CS_MENU_P2R_WTx_PAR, CS_MENU_R2P_WTx_PAR
260
	R2PP2R_TARGET	CS_MENU_P2R_WTx_SID, CS_MENU_R2P_WTx_SID
261
	R2PP2R_TARGET	CS_MENU_P2R_WTx_SPD, CS_MENU_R2P_WTx_SPD
262
	R2PP2R_TARGET	CS_MENU_P2R_WTx_B6, CS_MENU_R2P_WTx_B6
263
	R2PP2R_TARGET	CS_MENU_P2R_WTx_B7, CS_MENU_R2P_WTx_B7
264
	R2PP2R_TARGET	CS_MENU_P2R_WTx_POS, CS_MENU_R2P_WTx_POS
265
	R2PP2R_TARGET	CS_MENU_P2R_WTx_LOP, CS_MENU_R2P_WTx_LOP
266
 
267
	R2PP2R_TARGET	CS_MENU_P2R_WTE_PAR, CS_MENU_R2P_WTE_PAR
268
	R2PP2R_TARGET	CS_MENU_P2R_WT_VAL, CS_MENU_R2P_WT_VAL
269
 
270
	R2PP2R_TARGET	CS_MENU_P2R_B_SEQ_VAL, CS_MENU_R2P_B_SEQ_VAL
271
 
272
	R2PP2R_TARGET	CS_MENU_P2R_ENSx_VAL, CS_MENU_R2P_ENSx_VAL
273
	R2PP2R_TARGET	CS_MENU_P2R_ENSxIx_VAL, CS_MENU_R2P_ENSxIx_VAL
274
	R2PP2R_TARGET	CS_MENU_P2R_ENSx_X2A, CS_MENU_R2P_ENSx_X2A
275
	R2PP2R_TARGET	CS_MENU_P2R_ENSx_RESERVED, CS_MENU_R2P_ENSx_RESERVED
276
	R2PP2R_TARGET	CS_MENU_P2R_ENSx_MONO, CS_MENU_R2P_ENSx_MONO
277
	R2PP2R_TARGET	CS_MENU_P2R_ENSx_SPV, CS_MENU_R2P_ENSx_SPV
278
	R2PP2R_TARGET	CS_MENU_P2R_ENSx_EXTINV, CS_MENU_R2P_ENSx_EXTINV
279
 
280
	R2PP2R_TARGET	CS_MENU_P2R_303_CUTOFF, CS_MENU_R2P_303_CUTOFF
281
	R2PP2R_TARGET	CS_MENU_P2R_303_DEP, CS_MENU_R2P_303_DEP
282
	R2PP2R_TARGET	CS_MENU_P2R_303_DEC, CS_MENU_R2P_303_DEC
283
 
284
 
285
; --------------------------------------------------------------------------
286
; Macros used for passing parameter values to the selected SIDs
287
; TODO: replace macro by function to save code space!
288
; --------------------------------------------------------------------------
289
CS_MENU_P2R_VX_SEND_MACRO MACRO
290
	;; dirty trick:	this call puts the address behind the instruction into the caller stack
291
	;; the address is visible in TOS[LHU] and will be taken by CS_MENU_P2R_Vx_Send to determine
292
	;; the function which should be called multiple times
293
	;; at the end a "pop" instruction will be executed, which turns the "call" into a "goto"!
294
	rcall	CS_MENU_P2R_Vx_Send
295
	ENDM
296
 
297
CS_MENU_P2R_FX_SEND_MACRO MACRO
298
	;; see comments for CS_MENU_P2R_VX_SEND_MACRO
299
	rcall	CS_MENU_P2R_Fx_Send
300
	ENDM
301
 
302
; --------------------------------------------------------------------------
303
CS_MENU_P2R_NOP
304
CS_MENU_R2P_NOP
305
	return
306
 
307
; --------------------------------------------------------------------------
308
CS_MENU_P2R_PAR8
309
	movff	CS_MENU_PARAMETER_L, INDF0
310
	goto	CS_MENU_P2R_Hlp_ParSend
311
 
312
CS_MENU_R2P_PAR8
313
	movf	INDF0, W
314
	goto	CS_MENU_R2P_SetPar
315
 
316
; --------------------------------------------------------------------------
317
CS_MENU_P2R_PAR16
318
	movff	CS_MENU_PARAMETER_L, POSTINC0
319
	movff	CS_MENU_PARAMETER_H, POSTDEC0
320
	goto	CS_MENU_P2R_Hlp_ParSend
321
 
322
CS_MENU_R2P_PAR16
323
	movff	POSTINC0, CS_MENU_PARAMETER_L
324
	movff	POSTDEC0, CS_MENU_PARAMETER_H
325
	return
326
 
327
; --------------------------------------------------------------------------
328
CS_MENU_P2R_VAR
329
	goto	CS_MENU_P2RR2P_SetVAR
330
 
331
CS_MENU_R2P_VAR
332
	call	CS_MENU_P2RR2P_GetVAR
333
	goto	CS_MENU_R2P_SetPar
334
 
335
; --------------------------------------------------------------------------
336
CS_MENU_P2R_VAR_SID
337
	;; set new SID number
338
	;; check if new SID available - if not, increment/decrement until an available one has been found
339
 
340
	;; store available flags in PRODL
341
	movff	MBNET_NODE_AVAIL, PRODL
342
 
343
	;; branch depending on current SID
344
	movf	CS_MENU_SID, W
345
	cpfsgt	CS_MENU_PARAMETER_L, ACCESS
346
	rgoto CS_MENU_P2R_VAR_SID_Dec
347
CS_MENU_P2R_VAR_SID_Inc
348
	movf	CS_MENU_PARAMETER_L, W
349
	call	MIOS_HLP_GetBitORMask
350
	andwf	PRODL, W
351
	bnz	CS_MENU_P2R_VAR_SID_Ok
352
	incf	CS_MENU_PARAMETER_L, W
353
	andlw	0x03
354
	movwf	CS_MENU_PARAMETER_L
355
	bnz	CS_MENU_P2R_VAR_SID
356
 
357
CS_MENU_P2R_VAR_SID_Old
358
	movf	CS_MENU_SID, W
359
	movwf	CS_MENU_PARAMETER_L
360
 	rgoto	CS_MENU_P2R_VAR_SID_Ok
361
 
362
CS_MENU_P2R_VAR_SID_Dec
363
	movf	CS_MENU_PARAMETER_L, W
364
	call	MIOS_HLP_GetBitORMask
365
	andwf	PRODL, W
366
	bnz	CS_MENU_P2R_VAR_SID_Ok
367
	decf	CS_MENU_PARAMETER_L, W
368
	andlw	0x03
369
	movwf	CS_MENU_PARAMETER_L
370
	xorlw	0x03
371
	bnz	CS_MENU_P2R_VAR_SID
372
	rgoto	CS_MENU_P2R_VAR_SID_Old
373
 
374
 
375
CS_MENU_P2R_VAR_SID_Ok
376
	movf	CS_MENU_PARAMETER_L, W
377
	call	MIOS_HLP_GetBitORMask
378
	iorlw	0xf0		; (for button pressed detection)
379
	movwf	CS_MENU_SELECTED_SID_FLAGS
380
	;; request edit buffer update
381
	bsf	CS_STAT2, CS_STAT2_EDIT_UPDATE_REQ
382
	return
383
 
384
CS_MENU_R2P_VAR_SID
385
	movf	CS_MENU_SID, W		; (already derived from CS_MENU_SELECTED_SID_FLAGS)
386
	rgoto	CS_MENU_R2P_SetPar
387
 
388
; --------------------------------------------------------------------------
389
CS_MENU_P2R_VAR_OSC
390
	movff	CS_MENU_PARAMETER_L, CS_MENU_SELECTED_OSC
391
	goto	CS_MENU_Hlp_UpdateOSCFlags	; update of "osc_flags" register
392
 
393
CS_MENU_R2P_VAR_OSC
394
	movf	CS_MENU_SELECTED_OSC, W
395
	rgoto	CS_MENU_R2P_SetPar
396
 
397
; --------------------------------------------------------------------------
398
CS_MENU_P2R_VAR_SIDLR
399
	;; 0: L, 1: R, 2: LR
400
	incf	CS_MENU_PARAMETER_L, W
401
	movwf	CS_MENU_SELECTED_SID_LR
402
	return
403
 
404
CS_MENU_R2P_VAR_SIDLR
405
	;; L: 0, R: 1, LR: 2
406
	decf	CS_MENU_SELECTED_SID_LR, W
407
	andlw	0x03
408
	rgoto	CS_MENU_R2P_SetPar
409
 
410
; --------------------------------------------------------------------------
411
CS_MENU_P2R_VAR_CALI
412
	call	CS_MENU_FSR0_ENS
413
	RCALL_IFSET CS_MENU_SELECTED_SID_LR, 0, ACCESS, CS_MENU_P2R_VAR_CALI_Sub
414
	movlw	4
415
	addwf	CS_MENU_PARAMETER_IX, F
416
	call	CS_MENU_FSR0_ENS
417
	RCALL_IFSET CS_MENU_SELECTED_SID_LR, 1, ACCESS, CS_MENU_P2R_VAR_CALI_Sub
418
	return
419
 
420
CS_MENU_P2R_VAR_CALI_Sub
421
	swapf	CS_MENU_PARAMETER_L, W	; 12bit -> 16bit
422
	andlw	0xf0
423
	movwf	POSTINC0
424
	swapf	CS_MENU_PARAMETER_L, W
425
	andlw	0x0f
426
	movwf	INDF0
427
	swapf	CS_MENU_PARAMETER_H, W
428
	andlw	0xf0
429
	iorwf	POSTDEC0, F
430
 
431
	;; forward 16bit parameter to master/slave
432
	call	CS_MENU_MS_SendEnsParameter
433
	incf	FSR0L, F
434
	goto	CS_MENU_MS_SendEnsParameter
435
 
436
 
437
CS_MENU_R2P_VAR_CALI
438
	call	CS_MENU_FSR0_ENS
439
	;; add offset 4 if left SID is not selected
440
	movlw	0x00
441
	btfss	CS_MENU_SELECTED_SID_LR, 0
442
	addlw 4
443
	addwf	FSR0L, F
444
	swapf	POSTINC0, W	; 16bit -> 12bit
445
	andlw	0x0f
446
	movwf	CS_MENU_PARAMETER_L
447
	swapf	INDF0, W
448
	andlw	0xf0
449
	iorwf	CS_MENU_PARAMETER_L, F
450
	swapf	INDF0, W
451
	andlw	0x0f
452
	movwf	CS_MENU_PARAMETER_H
453
	return
454
 
455
; --------------------------------------------------------------------------
456
CS_MENU_P2R_SAVE_NAME
457
	movf	CS_MENU_NAME_POS, W
458
	movff	CS_MENU_PARAMETER_L, PLUSW0
459
	return
460
 
461
CS_MENU_R2P_SAVE_NAME
462
	movf	CS_MENU_NAME_POS, W
463
	movf	PLUSW0, W
464
	rgoto	CS_MENU_R2P_SetPar
465
 
466
; --------------------------------------------------------------------------
467
CS_MENU_P2R_EDIT_SEQ
468
	;; if rotate function active: branch to special routine which is doing the rotation
469
	BRA_IFSET CS_STAT3, CS_STAT3_MODIFY_SEQ_ROTATE, ACCESS, CS_MENU_P2R_RotateSeqTrack
470
	rgoto	CS_MENU_P2R_VAR
471
 
472
CS_MENU_R2P_EDIT_SEQ
473
	;; nothing to do here if rotate function active
474
	btfsc	CS_STAT3, CS_STAT3_MODIFY_SEQ_ROTATE
475
	return
476
	rgoto	CS_MENU_R2P_VAR
477
 
478
; --------------------------------------------------------------------------
479
CS_MENU_P2R_Vx
480
	CS_MENU_P2R_VX_SEND_MACRO
481
	movff	CS_MENU_PARAMETER_L, INDF0
482
	rgoto	CS_MENU_P2R_Hlp_ParSend
483
 
484
CS_MENU_R2P_Vx
485
	rcall	CS_MENU_FSR0_Voice
486
	rgoto	CS_MENU_R2P_PAR8
487
 
488
; --------------------------------------------------------------------------
489
CS_MENU_P2R_Vx_4U
490
	CS_MENU_P2R_VX_SEND_MACRO
491
	movlw	0x0f
492
	andwf	INDF0, F
493
	swapf	CS_MENU_PARAMETER_L, W
494
	andlw	0xf0
495
	iorwf	INDF0, F
496
	rgoto	CS_MENU_P2R_Hlp_ParSend
497
 
498
CS_MENU_R2P_Vx_4U
499
	rcall	CS_MENU_FSR0_Voice
500
	swapf	INDF0, W
501
	andlw	0x0f
502
	rgoto	CS_MENU_R2P_SetPar
503
 
504
; --------------------------------------------------------------------------
505
CS_MENU_P2R_Vx_4L
506
	CS_MENU_P2R_VX_SEND_MACRO
507
	movlw	0xf0
508
	andwf	INDF0, F
509
	movf	CS_MENU_PARAMETER_L, W
510
	andlw	0x0f
511
	iorwf	INDF0, F
512
	rgoto	CS_MENU_P2R_Hlp_ParSend
513
 
514
CS_MENU_R2P_Vx_4L
515
	rcall	CS_MENU_FSR0_Voice
516
	movf	INDF0, W
517
	andlw	0x0f
518
	rgoto	CS_MENU_R2P_SetPar
519
 
520
; --------------------------------------------------------------------------
521
CS_MENU_P2R_Vx_PMD
522
	CS_MENU_P2R_VX_SEND_MACRO
523
	movlw	0xfc
524
	andwf	INDF0, F
525
	movf	CS_MENU_PARAMETER_L, W
526
	andlw	0x03
527
	iorwf	INDF0, F
528
	rgoto	CS_MENU_P2R_Hlp_ParSend
529
 
530
CS_MENU_R2P_Vx_PMD
531
	rcall	CS_MENU_FSR0_Voice
532
	movf	INDF0, W
533
	andlw	0x03
534
	rgoto	CS_MENU_R2P_SetPar
535
 
536
; --------------------------------------------------------------------------
537
CS_MENU_P2R_Vx_GSA
538
	CS_MENU_P2R_VX_SEND_MACRO
539
	movlw	SID_I_V_FLAGS1_GSA
540
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
541
 
542
CS_MENU_R2P_Vx_GSA
543
	rcall	CS_MENU_FSR0_Voice
544
	movlw	SID_I_V_FLAGS1_GSA
545
	rgoto	CS_MENU_R2P_SetParFlag
546
 
547
; --------------------------------------------------------------------------
548
CS_MENU_P2R_Vx_12
549
	CS_MENU_P2R_VX_SEND_MACRO
550
	movff	CS_MENU_PARAMETER_L, INDF0	; send low byte
551
	rcall	CS_MENU_P2R_Hlp_ParSend
552
	movf	POSTINC0, W
553
	movff	CS_MENU_PARAMETER_H, INDF0	; send high byte
554
	rcall	CS_MENU_P2R_Hlp_ParSend
555
	movf	POSTDEC0, W
556
	return
557
 
558
CS_MENU_R2P_Vx_12
559
	rcall	CS_MENU_FSR0_Voice
560
	movff	POSTINC0, CS_MENU_PARAMETER_L
561
	movff	POSTDEC0, CS_MENU_PARAMETER_H
562
	return
563
 
564
; --------------------------------------------------------------------------
565
CS_MENU_P2R_Vx_WAV
566
	CS_MENU_P2R_VX_SEND_MACRO
567
	movlw	0xe0
568
	andwf	INDF0, F
569
 
570
	movf	CS_MENU_PARAMETER_L, W
571
	iorwf	INDF0, F
572
	movf	CS_MENU_PARAMETER_L, W
573
	skpnz
574
	bsf	INDF0, 4
575
	rgoto	CS_MENU_P2R_Hlp_ParSend
576
 
577
CS_MENU_R2P_Vx_WAV
578
	rcall	CS_MENU_FSR0_Voice
579
	movf	INDF0, W
580
	andlw	0x07
581
	btfsc	INDF0, 3
582
	movlw 0x08
583
	btfsc	INDF0, 4
584
	movlw 0x00
585
	rgoto	CS_MENU_R2P_SetPar
586
 
587
; --------------------------------------------------------------------------
588
CS_MENU_P2R_Vx_S_R
589
	CS_MENU_P2R_VX_SEND_MACRO
590
	movlw	0x1f
591
	andwf	INDF0, F
592
	swapf	CS_MENU_PARAMETER_L, W
593
	rlf	WREG, W
594
	andlw	0x60
595
	iorwf	INDF0, F
596
	rgoto	CS_MENU_P2R_Hlp_ParSend
597
 
598
CS_MENU_R2P_Vx_S_R
599
	rcall	CS_MENU_FSR0_Voice
600
	swapf	INDF0, W
601
	rrf	WREG, W
602
	andlw	0x03
603
	rgoto	CS_MENU_R2P_SetPar
604
 
605
; --------------------------------------------------------------------------
606
CS_MENU_P2R_Vx_ARP_ON
607
	CS_MENU_P2R_VX_SEND_MACRO
608
	movlw	SID_I_V_ARP_MODE_ENABLE
609
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
610
 
611
CS_MENU_R2P_Vx_ARP_ON
612
	rcall	CS_MENU_FSR0_Voice
613
	movlw	SID_I_V_ARP_MODE_ENABLE
614
	rgoto	CS_MENU_R2P_SetParFlag
615
 
616
; --------------------------------------------------------------------------
617
CS_MENU_P2R_Vx_ARP_DIR
618
	CS_MENU_P2R_VX_SEND_MACRO
619
	movlw	0xf1
620
	andwf	INDF0, F
621
	rlf	CS_MENU_PARAMETER_L, W
622
	andlw	0x0e
623
	iorwf	INDF0, F
624
	rgoto	CS_MENU_P2R_Hlp_ParSend
625
 
626
CS_MENU_R2P_Vx_ARP_DIR
627
	rcall	CS_MENU_FSR0_Voice
628
	rrf	INDF0, W
629
	andlw	0x07
630
	rgoto	CS_MENU_R2P_SetPar
631
 
632
; --------------------------------------------------------------------------
633
CS_MENU_P2R_Vx_ARP_SOR
634
	CS_MENU_P2R_VX_SEND_MACRO
635
	movlw	SID_I_V_ARP_MODE_SORTED
636
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
637
 
638
CS_MENU_R2P_Vx_ARP_SOR
639
	rcall	CS_MENU_FSR0_Voice
640
	movlw	SID_I_V_ARP_MODE_SORTED
641
	rgoto	CS_MENU_R2P_SetParFlag
642
 
643
; --------------------------------------------------------------------------
644
CS_MENU_P2R_Vx_ARP_HLD
645
	CS_MENU_P2R_VX_SEND_MACRO
646
	movlw	SID_I_V_ARP_MODE_HOLD
647
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
648
 
649
CS_MENU_R2P_Vx_ARP_HLD
650
	rcall	CS_MENU_FSR0_Voice
651
	movlw	SID_I_V_ARP_MODE_HOLD
652
	rgoto	CS_MENU_R2P_SetParFlag
653
 
654
; --------------------------------------------------------------------------
655
CS_MENU_P2R_Vx_ARP_SNC
656
	CS_MENU_P2R_VX_SEND_MACRO
657
	movlw	SID_I_V_ARP_MODE_DIV_SYNC
658
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
659
 
660
CS_MENU_R2P_Vx_ARP_SNC
661
	rcall	CS_MENU_FSR0_Voice
662
	movlw	SID_I_V_ARP_MODE_DIV_SYNC
663
	rgoto	CS_MENU_R2P_SetParFlag
664
 
665
; --------------------------------------------------------------------------
666
CS_MENU_P2R_Vx_ARP_CAC
667
	CS_MENU_P2R_VX_SEND_MACRO
668
	movlw	SID_I_V_ARP_MODE_CAC
669
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
670
 
671
CS_MENU_R2P_Vx_ARP_CAC
672
	rcall	CS_MENU_FSR0_Voice
673
	movlw	SID_I_V_ARP_MODE_CAC
674
	rgoto	CS_MENU_R2P_SetParFlag
675
 
676
; --------------------------------------------------------------------------
677
CS_MENU_P2R_Vx_ARP_GLN
678
	CS_MENU_P2R_VX_SEND_MACRO
679
	movlw	0xe0
680
	andwf	INDF0, F
681
	movf	CS_MENU_PARAMETER_L, W
682
	iorwf	INDF0, F
683
	rgoto	CS_MENU_P2R_Hlp_ParSend
684
 
685
CS_MENU_R2P_Vx_ARP_GLN
686
	rcall	CS_MENU_FSR0_Voice
687
	movf	INDF0, W
688
	andlw	0x1f
689
	rgoto	CS_MENU_R2P_SetPar
690
 
691
; --------------------------------------------------------------------------
692
CS_MENU_P2R_Vx_ARP_RNG
693
	CS_MENU_P2R_VX_SEND_MACRO
694
	movlw	0x1f
695
	andwf	INDF0, F
696
	swapf	CS_MENU_PARAMETER_L, W
697
	rlf	WREG, W
698
	andlw	0xe0
699
	iorwf	INDF0, F
700
	rgoto	CS_MENU_P2R_Hlp_ParSend
701
 
702
CS_MENU_R2P_Vx_ARP_RNG
703
	rcall	CS_MENU_FSR0_Voice
704
	swapf	INDF0, W
705
	rrf	WREG, W
706
	andlw	0x07
707
	rgoto	CS_MENU_R2P_SetPar
708
 
709
; --------------------------------------------------------------------------
710
CS_MENU_P2R_Vx_ARP_SPD
711
	CS_MENU_P2R_VX_SEND_MACRO
712
	movlw	0xc0
713
	andwf	INDF0, F
714
	movf	CS_MENU_PARAMETER_L, W
715
	andlw	0x3f
716
	iorwf	INDF0, F
717
	rgoto	CS_MENU_P2R_Hlp_ParSend
718
 
719
CS_MENU_R2P_Vx_ARP_SPD
720
	rcall	CS_MENU_FSR0_Voice
721
	movf	INDF0, W
722
	andlw	0x3f
723
	rgoto	CS_MENU_R2P_SetPar
724
 
725
; --------------------------------------------------------------------------
726
CS_MENU_P2R_Vx_ARP_ONE
727
	CS_MENU_P2R_VX_SEND_MACRO
728
	movlw	SID_I_V_ARP_SPEED_DIV_ONESHOT
729
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
730
 
731
CS_MENU_R2P_Vx_ARP_ONE
732
	rcall	CS_MENU_FSR0_Voice
733
	movlw	SID_I_V_ARP_SPEED_DIV_ONESHOT
734
	rgoto	CS_MENU_R2P_SetParFlag
735
 
736
; --------------------------------------------------------------------------
737
CS_MENU_P2R_M_Vx_PHASE
738
	CS_MENU_P2R_VX_SEND_MACRO
739
	movlw	SID_I_M_V_FLAGS2_PHASE
740
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
741
 
742
CS_MENU_R2P_M_Vx_PHASE
743
	rcall	CS_MENU_FSR0_Voice
744
	movlw	SID_I_M_V_FLAGS2_PHASE
745
	rgoto	CS_MENU_R2P_SetParFlag
746
 
747
; --------------------------------------------------------------------------
748
CS_MENU_P2R_M_Vx_POL
749
	CS_MENU_P2R_VX_SEND_MACRO
750
	movlw	SID_I_M_V_FLAGS2_POLY
751
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
752
 
753
CS_MENU_R2P_M_Vx_POL
754
	rcall	CS_MENU_FSR0_Voice
755
	movlw	SID_I_M_V_FLAGS2_POLY
756
	rgoto	CS_MENU_R2P_SetParFlag
757
 
758
; --------------------------------------------------------------------------
759
CS_MENU_P2R_M_Vx_LEG
760
	CS_MENU_P2R_VX_SEND_MACRO
761
	movlw	SID_I_M_V_FLAGS2_LEGATO
762
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
763
 
764
CS_MENU_R2P_M_Vx_LEG
765
	rcall	CS_MENU_FSR0_Voice
766
	movlw	SID_I_M_V_FLAGS2_LEGATO
767
	rgoto	CS_MENU_R2P_SetParFlag
768
 
769
; --------------------------------------------------------------------------
770
CS_MENU_P2R_M_Vx_WTO
771
	CS_MENU_P2R_VX_SEND_MACRO
772
	movlw	SID_I_M_V_FLAGS2_WT_ONLY
773
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
774
 
775
CS_MENU_R2P_M_Vx_WTO
776
	rcall	CS_MENU_FSR0_Voice
777
	movlw	SID_I_M_V_FLAGS2_WT_ONLY
778
	rgoto	CS_MENU_R2P_SetParFlag
779
 
780
; --------------------------------------------------------------------------
781
CS_MENU_P2R_M_Vx_SUK
782
	CS_MENU_P2R_VX_SEND_MACRO
783
	movlw	SID_I_M_V_FLAGS2_SUS_KEY
784
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
785
 
786
CS_MENU_R2P_M_Vx_SUK
787
	rcall	CS_MENU_FSR0_Voice
788
	movlw	SID_I_M_V_FLAGS2_SUS_KEY
789
	rgoto	CS_MENU_R2P_SetParFlag
790
 
791
; --------------------------------------------------------------------------
792
CS_MENU_P2R_M_Vx_VAS
793
	rcall	CS_MENU_P2R_Vx
794
	;; re-init exclusive voice assignments
795
	goto	CS_MENU_MS_VoiceReInit
796
 
797
CS_MENU_R2P_M_Vx_VAS
798
	rgoto	CS_MENU_R2P_Vx
799
 
800
; --------------------------------------------------------------------------
801
CS_MENU_P2R_M_D_Vx_ASG
802
	rcall	CS_MENU_P2R_Vx
803
	;; update shadow buffer (so that the old assignment has no effect anymore)
804
	goto	CS_MENU_MS_UpdateShadow
805
 
806
CS_MENU_R2P_M_D_Vx_ASG
807
	rgoto	CS_MENU_R2P_Vx
808
 
809
; --------------------------------------------------------------------------
810
CS_MENU_P2R_B_Vx_MODE
811
	CS_MENU_P2R_VX_SEND_MACRO
812
	;; ensure that Legato and SusKey always activated
813
	movlw	(1 << SID_I_B_V_FLAGS2_LEGATO) | (1 << SID_I_B_V_FLAGS2_SUS_KEY)
814
	iorwf	INDF0, F
815
	;; switch WTO flag
816
	movlw	SID_I_B_V_FLAGS2_WT_ONLY
817
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
818
 
819
CS_MENU_R2P_B_Vx_MODE
820
	rcall	CS_MENU_FSR0_Voice
821
	movlw	SID_I_B_V_FLAGS2_WT_ONLY
822
	rgoto	CS_MENU_R2P_SetParFlag
823
 
824
; --------------------------------------------------------------------------
825
CS_MENU_P2R_B_Vx_SEQ_SPD
826
	CS_MENU_P2R_VX_SEND_MACRO
827
	movlw	0xc0
828
	andwf	INDF0, F
829
	movf	CS_MENU_PARAMETER_L, W
830
	andlw	0x3f
831
	iorwf	INDF0, F
832
	rgoto	CS_MENU_P2R_Hlp_ParSend
833
 
834
CS_MENU_R2P_B_Vx_SEQ_SPD
835
	rcall	CS_MENU_FSR0_Voice
836
	movf	INDF0, W
837
	andlw	0x3f
838
	rgoto	CS_MENU_R2P_SetPar
839
 
840
; --------------------------------------------------------------------------
841
CS_MENU_P2R_B_Vx_SEQ_S16
842
	CS_MENU_P2R_VX_SEND_MACRO
843
	movlw	SID_I_V_SEQ_SYNC16
844
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
845
 
846
CS_MENU_R2P_B_Vx_SEQ_S16
847
	rcall	CS_MENU_FSR0_Voice
848
	movlw	SID_I_V_SEQ_SYNC16
849
	rgoto	CS_MENU_R2P_SetParFlag
850
 
851
; --------------------------------------------------------------------------
852
CS_MENU_P2R_D_Vx_VAS
853
	rcall	CS_MENU_P2R_Vx_4U
854
	;; re-init voice assignments
855
	goto	CS_MENU_MS_VoiceReInit
856
 
857
CS_MENU_R2P_D_Vx_VAS
858
	rgoto	CS_MENU_R2P_Vx_4U
859
 
860
; --------------------------------------------------------------------------
861
CS_MENU_P2R_Fx_CHN
862
	CS_MENU_P2R_FX_SEND_MACRO
863
	movlw	0xf8
864
	andwf	INDF0, F
865
	movf	CS_MENU_PARAMETER_L, W
866
	andlw	0x07
867
	iorwf	INDF0, F
868
	rgoto	CS_MENU_P2R_Hlp_ParSend
869
 
870
CS_MENU_R2P_Fx_CHN
871
	rcall	CS_MENU_FSR0_Filter
872
	movf	INDF0, W
873
	andlw	0x07
874
	rgoto	CS_MENU_R2P_SetPar
875
 
876
; --------------------------------------------------------------------------
877
CS_MENU_P2R_Fx_MOD
878
	CS_MENU_P2R_FX_SEND_MACRO
879
	movlw	0x8f
880
	andwf	INDF0, F
881
	swapf	CS_MENU_PARAMETER_L, W
882
	andlw	0x70
883
	iorwf	INDF0, F
884
	rgoto	CS_MENU_P2R_Hlp_ParSend
885
 
886
CS_MENU_R2P_Fx_MOD
887
	rcall	CS_MENU_FSR0_Filter
888
	swapf	INDF0, W
889
	andlw	0x07
890
	rgoto	CS_MENU_R2P_SetPar
891
 
892
; --------------------------------------------------------------------------
893
CS_MENU_P2R_Fx_CUTOFF
894
	CS_MENU_P2R_FX_SEND_MACRO
895
	movff	CS_MENU_PARAMETER_L, INDF0	; send low byte
896
	rcall	CS_MENU_P2R_Hlp_ParSend
897
	movf	POSTINC0, W
898
	movlw	0xf0				; send high byte
899
	andwf	INDF0, F
900
	movf	CS_MENU_PARAMETER_H, W
901
	iorwf	INDF0, F
902
	rcall	CS_MENU_P2R_Hlp_ParSend
903
	movf	POSTDEC0, W
904
	return
905
 
906
CS_MENU_R2P_Fx_CUTOFF
907
	rcall	CS_MENU_FSR0_Filter
908
	movff	POSTINC0, CS_MENU_PARAMETER_L
909
	movf	POSTDEC0, W
910
	andlw	0x0f
911
	movwf	CS_MENU_PARAMETER_H
912
	return
913
 
914
; --------------------------------------------------------------------------
915
CS_MENU_P2R_Fx_RESON
916
CS_MENU_P2R_Fx_KTR
917
	CS_MENU_P2R_FX_SEND_MACRO
918
	movf	CS_MENU_PARAMETER_L, W
919
	movwf	INDF0
920
	rgoto	CS_MENU_P2R_Hlp_ParSend
921
 
922
CS_MENU_R2P_Fx_RESON
923
CS_MENU_R2P_Fx_KTR
924
	rcall	CS_MENU_FSR0_Filter
925
	movff	INDF0, CS_MENU_PARAMETER_L
926
	clrf	CS_MENU_PARAMETER_H
927
	return
928
 
929
; --------------------------------------------------------------------------
930
CS_MENU_P2R_Fx_EXT
931
	CS_MENU_P2R_FX_SEND_MACRO
932
	movlw	3
933
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
934
 
935
CS_MENU_R2P_Fx_EXT
936
	rcall	CS_MENU_FSR0_Filter
937
	movlw	3
938
	rgoto	CS_MENU_R2P_SetParFlag
939
 
940
; --------------------------------------------------------------------------
941
CS_MENU_P2R_Fx_3OF
942
CS_MENU_P2R_Fx_FIP
943
	CS_MENU_P2R_FX_SEND_MACRO
944
	movlw	7
945
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
946
 
947
CS_MENU_R2P_Fx_3OF
948
CS_MENU_R2P_Fx_FIP
949
	rcall	CS_MENU_FSR0_Filter
950
	movlw	7
951
	rgoto	CS_MENU_R2P_SetParFlag
952
 
953
; --------------------------------------------------------------------------
954
CS_MENU_P2R_LFOx
955
	rcall	CS_MENU_FSR0_LFO
956
	rgoto	CS_MENU_P2R_PAR8
957
 
958
CS_MENU_R2P_LFOx
959
	rcall	CS_MENU_FSR0_LFO
960
	rgoto	CS_MENU_R2P_PAR8
961
 
962
; --------------------------------------------------------------------------
963
CS_MENU_P2R_LFOx_WAV
964
	rcall	CS_MENU_FSR0_LFO
965
	movlw	0x0e
966
	andwf	INDF0, F
967
 
968
	decf	CS_MENU_PARAMETER_L, W
969
	swapf	WREG, W
970
	andlw	0xf0
971
	iorwf	INDF0, F
972
	movf	CS_MENU_PARAMETER_L, W
973
	skpz
974
	bsf	INDF0, 0
975
	rgoto	CS_MENU_P2R_Hlp_ParSend
976
 
977
CS_MENU_R2P_LFOx_WAV
978
	rcall	CS_MENU_FSR0_LFO
979
	swapf	INDF0, W
980
	andlw	0x0f
981
	addlw	1
982
	btfss	INDF0, 0
983
	movlw 0x00
984
	rgoto	CS_MENU_R2P_SetPar
985
 
986
; --------------------------------------------------------------------------
987
CS_MENU_P2R_LFOx_SNC
988
	;; controlled from trigger matrix (Note On Event)
989
	;; index already in CS_MENU_PARAMETER_IX, add LFO offset
990
	movf	CS_MENU_SELECTED_LFO, W
991
	addwf	CS_MENU_PARAMETER_IX, F
992
	movff	CS_MENU_SELECTED_TRG, TMP5	; store current trigger number
993
	clrf	CS_MENU_SELECTED_TRG; (Note On)
994
	rcall	CS_MENU_P2R_TRGx_Nx
995
	movff	TMP5, CS_MENU_SELECTED_TRG	; restore old trigger number
996
	return
997
 
998
CS_MENU_R2P_LFOx_SNC
999
	;; controlled from trigger matrix (Note On Event)
1000
	;; index already in CS_MENU_PARAMETER_IX, add LFO offset
1001
	movf	CS_MENU_SELECTED_LFO, W
1002
	addwf	CS_MENU_PARAMETER_IX, F
1003
	movff	CS_MENU_SELECTED_TRG, TMP5	; store current trigger number
1004
	clrf	CS_MENU_SELECTED_TRG; (Note On)
1005
	call	CS_MENU_R2P_TRGx_Nx
1006
	movff	TMP5, CS_MENU_SELECTED_TRG	; restore old trigger number
1007
	return
1008
 
1009
; --------------------------------------------------------------------------
1010
CS_MENU_P2R_LFOx_SNC_M
1011
	call	CS_MENU_FSR0_LFO
1012
	movlw	SID_I_LFO_MODE_SYNC_M
1013
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1014
 
1015
CS_MENU_R2P_LFOx_SNC_M
1016
	call	CS_MENU_FSR0_LFO
1017
	movlw	SID_I_LFO_MODE_SYNC_M
1018
	rgoto	CS_MENU_R2P_SetParFlag
1019
 
1020
; --------------------------------------------------------------------------
1021
CS_MENU_P2R_LFOx_ONE
1022
	call	CS_MENU_FSR0_LFO
1023
	movlw	SID_I_LFO_MODE_ONESHOT
1024
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1025
 
1026
CS_MENU_R2P_LFOx_ONE
1027
	call	CS_MENU_FSR0_LFO
1028
	movlw	SID_I_LFO_MODE_ONESHOT
1029
	rgoto	CS_MENU_R2P_SetParFlag
1030
 
1031
; --------------------------------------------------------------------------
1032
CS_MENU_P2R_LFOx_CSN
1033
	call	CS_MENU_FSR0_LFO
1034
	movlw	SID_I_LFO_MODE_CLKSYNC
1035
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1036
 
1037
CS_MENU_R2P_LFOx_CSN
1038
	call	CS_MENU_FSR0_LFO
1039
	movlw	SID_I_LFO_MODE_CLKSYNC
1040
	rgoto	CS_MENU_R2P_SetParFlag
1041
 
1042
; --------------------------------------------------------------------------
1043
CS_MENU_P2R_ENVx
1044
	call	CS_MENU_FSR0_ENV
1045
	rgoto	CS_MENU_P2R_PAR8
1046
 
1047
CS_MENU_R2P_ENVx
1048
	call	CS_MENU_FSR0_ENV
1049
	rgoto	CS_MENU_R2P_PAR8
1050
 
1051
; --------------------------------------------------------------------------
1052
CS_MENU_P2R_ENVx_LPB
1053
	call	CS_MENU_FSR0_ENV
1054
	movlw	0xf8
1055
	andwf	INDF0, F
1056
	movf	CS_MENU_PARAMETER_L, W
1057
	andlw	0x07
1058
	iorwf	INDF0, F
1059
	rgoto	CS_MENU_P2R_Hlp_ParSend
1060
 
1061
CS_MENU_R2P_ENVx_LPB
1062
	call	CS_MENU_FSR0_ENV
1063
	movf	INDF0, W
1064
	andlw	0x07
1065
	rgoto	CS_MENU_R2P_SetPar
1066
 
1067
; --------------------------------------------------------------------------
1068
CS_MENU_P2R_ENVx_LPE
1069
	call	CS_MENU_FSR0_ENV
1070
	movlw	0x8f
1071
	andwf	INDF0, F
1072
	swapf	CS_MENU_PARAMETER_L, W
1073
	andlw	0x70
1074
	iorwf	INDF0, F
1075
	rgoto	CS_MENU_P2R_Hlp_ParSend
1076
 
1077
CS_MENU_R2P_ENVx_LPE
1078
	call	CS_MENU_FSR0_ENV
1079
	swapf	INDF0, W
1080
	andlw	0x07
1081
	rgoto	CS_MENU_R2P_SetPar
1082
 
1083
; --------------------------------------------------------------------------
1084
CS_MENU_P2R_ENVx_CSN
1085
	call	CS_MENU_FSR0_ENV
1086
	movlw	SID_I_ENV_MODE_CLKSYNC
1087
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1088
 
1089
CS_MENU_R2P_ENVx_CSN
1090
	call	CS_MENU_FSR0_ENV
1091
	movlw	SID_I_ENV_MODE_CLKSYNC
1092
	rgoto	CS_MENU_R2P_SetParFlag
1093
 
1094
; --------------------------------------------------------------------------
1095
CS_MENU_P2R_MODx
1096
	call	CS_MENU_FSR0_MOD
1097
	rgoto	CS_MENU_P2R_PAR8
1098
 
1099
CS_MENU_R2P_MODx
1100
	call	CS_MENU_FSR0_MOD
1101
	rgoto	CS_MENU_R2P_PAR8
1102
 
1103
; --------------------------------------------------------------------------
1104
CS_MENU_P2R_MODx_SRC
1105
	call	CS_MENU_FSR0_MOD
1106
	movf	CS_MENU_PARAMETER_L, W
1107
	addlw	-SID_MOD_SRC_NUM-1
1108
	BRA_IFSET WREG, 7, ACCESS, CS_MENU_P2R_MODx_SRC_Norm
1109
	addlw	0x80
1110
	movwf	INDF0
1111
	rgoto	CS_MENU_P2R_Hlp_ParSend
1112
CS_MENU_P2R_MODx_SRC_Norm
1113
	rgoto	CS_MENU_P2R_PAR8
1114
 
1115
CS_MENU_R2P_MODx_SRC
1116
	call	CS_MENU_FSR0_MOD
1117
	movf	INDF0, W
1118
	btfsc	INDF0, 7
1119
	addlw -0x80+SID_MOD_SRC_NUM
1120
 
1121
	rgoto	CS_MENU_R2P_SetPar
1122
 
1123
; --------------------------------------------------------------------------
1124
CS_MENU_P2R_MODx_OP
1125
	call	CS_MENU_FSR0_MOD
1126
	movlw	0xf0
1127
	andwf	INDF0, F
1128
	movf	CS_MENU_PARAMETER_L, W
1129
	iorwf	INDF0, F
1130
	rgoto	CS_MENU_P2R_Hlp_ParSend
1131
 
1132
CS_MENU_R2P_MODx_OP
1133
	call	CS_MENU_FSR0_MOD
1134
	movf	INDF0, W
1135
	andlw	0x0f
1136
	rgoto	CS_MENU_R2P_SetPar
1137
 
1138
; --------------------------------------------------------------------------
1139
CS_MENU_P2R_MODx_INV1
1140
	call	CS_MENU_FSR0_MOD
1141
	movlw	6
1142
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1143
 
1144
CS_MENU_R2P_MODx_INV1
1145
	call	CS_MENU_FSR0_MOD
1146
	movlw	6
1147
	rgoto	CS_MENU_R2P_SetParFlag
1148
 
1149
; --------------------------------------------------------------------------
1150
CS_MENU_P2R_MODx_INV2
1151
	call	CS_MENU_FSR0_MOD
1152
	movlw	7
1153
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1154
 
1155
CS_MENU_R2P_MODx_INV2
1156
	call	CS_MENU_FSR0_MOD
1157
	movlw	7
1158
	rgoto	CS_MENU_R2P_SetParFlag
1159
 
1160
; --------------------------------------------------------------------------
1161
_CS_MENU_P2R_MODx_Nx
1162
	rgoto	CS_MENU_P2R_MODx_Nx	; link to final code (ensures that jumptable still works with rgoto branches)
1163
_CS_MENU_R2P_MODx_Nx
1164
	rgoto	CS_MENU_R2P_MODx_Nx	; link to final code (ensures that jumptable still works with rgoto branches)
1165
 
1166
; --------------------------------------------------------------------------
1167
_CS_MENU_P2R_TRGx_Nx
1168
	rgoto	CS_MENU_P2R_TRGx_Nx	; link to final code (ensures that jumptable still works with rgoto branches)
1169
_CS_MENU_R2P_TRGx_Nx
1170
	rgoto	CS_MENU_R2P_TRGx_Nx	; link to final code (ensures that jumptable still works with rgoto branches)
1171
 
1172
; --------------------------------------------------------------------------
1173
CS_MENU_P2R_CHN
1174
	;; update channel stored in ENS structure
1175
	rcall	CS_MENU_P2R_ENSxIx_VAL
1176
 
1177
	;; update channel stored in CS structure (only for first instrument)
1178
	movf	CS_MENU_SELECTED_INS, W
1179
	bnz	CS_MENU_P2R_CHN_End
1180
	lfsr	FSR1, CS_MENU_SID_M_CHN
1181
	movf	CS_MENU_SID, W
1182
	andlw	0x03
1183
	addwf	FSR1L, F
1184
	movff	CS_MENU_PARAMETER_L, INDF1
1185
CS_MENU_P2R_CHN_End
1186
	return
1187
 
1188
CS_MENU_R2P_CHN
1189
	rgoto	CS_MENU_R2P_ENSxIx_VAL
1190
 
1191
; --------------------------------------------------------------------------
1192
CS_MENU_P2R_BNK
1193
	;; update bank stored in ENS structure
1194
	rcall	CS_MENU_P2R_ENSx_VAL
1195
 
1196
	;; update bank stored in CS structure
1197
	call	CS_MENU_MS_GetSIDBank
1198
	movff	CS_MENU_PARAMETER_L, INDF1
1199
	rcall	CS_MENU_P2R_CFG_Hlp_PatchUpdate
1200
 
1201
	;; 	rgoto	CS_MENU_R2P_BNK
1202
 
1203
CS_MENU_R2P_BNK
1204
	rgoto	CS_MENU_R2P_ENSx_VAL
1205
 
1206
; --------------------------------------------------------------------------
1207
CS_MENU_P2R_PAT
1208
	;; update bank stored in ENS structure
1209
	rcall	CS_MENU_P2R_ENSx_VAL
1210
 
1211
	;; update bank stored in CS structure
1212
	call	CS_MENU_MS_GetSIDPatch
1213
	movff	CS_MENU_PARAMETER_L, INDF1
1214
	rcall	CS_MENU_P2R_CFG_Hlp_PatchUpdate
1215
	;; 	rgoto	CS_MENU_R2P_PAT
1216
 
1217
CS_MENU_R2P_PAT
1218
	rgoto	CS_MENU_R2P_ENSx_VAL
1219
 
1220
; --------------------------------------------------------------------------
1221
CS_MENU_P2R_B0
1222
	movlw	0
1223
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1224
 
1225
CS_MENU_R2P_B0
1226
	movlw	0
1227
	rgoto	CS_MENU_R2P_SetParFlag
1228
 
1229
; --------------------------------------------------------------------------
1230
CS_MENU_P2R_B1
1231
	movlw	1
1232
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1233
 
1234
CS_MENU_R2P_B1
1235
	movlw	1
1236
	rgoto	CS_MENU_R2P_SetParFlag
1237
 
1238
; --------------------------------------------------------------------------
1239
CS_MENU_P2R_B2
1240
	movlw	2
1241
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1242
 
1243
CS_MENU_R2P_B2
1244
	movlw	2
1245
	rgoto	CS_MENU_R2P_SetParFlag
1246
 
1247
; --------------------------------------------------------------------------
1248
CS_MENU_P2R_CLK_BPM
1249
	call	CS_MENU_FSR0_ENS
1250
	movf	CS_MENU_PARAMETER_L, W
1251
	addlw	50
1252
	skpnc
1253
	movlw	255
1254
	movwf	INDF0
1255
	goto	CS_MENU_MS_SendEnsParameter
1256
 
1257
CS_MENU_R2P_CLK_BPM
1258
	call	CS_MENU_FSR0_ENS
1259
	movf	INDF0, W
1260
	addlw	-50
1261
	skpc
1262
	movlw	0
1263
	rgoto	CS_MENU_R2P_SetPar
1264
 
1265
; --------------------------------------------------------------------------
1266
CS_MENU_P2R_CLK_SLAVE
1267
	call	CS_MENU_FSR0_ENS
1268
	movlw	~((1 << SID_ENS_CTRL1_CLK_SLAVE) | (1 << SID_ENS_CTRL1_CLK_AUTO))
1269
	andwf	INDF0, F
1270
	btfsc	CS_MENU_PARAMETER_L, 0
1271
	bsf	INDF0, SID_ENS_CTRL1_CLK_SLAVE
1272
	btfsc	CS_MENU_PARAMETER_L, 1
1273
	bsf	INDF0, SID_ENS_CTRL1_CLK_AUTO
1274
	;; forward to master/slave
1275
	goto	CS_MENU_MS_SendEnsParameter
1276
 
1277
CS_MENU_R2P_CLK_SLAVE
1278
	call	CS_MENU_FSR0_ENS
1279
	movlw	0
1280
	btfsc	INDF0, SID_ENS_CTRL1_CLK_SLAVE
1281
	iorlw 0x01
1282
	btfsc	INDF0, SID_ENS_CTRL1_CLK_AUTO
1283
	iorlw 0x02
1284
	rgoto	CS_MENU_R2P_SetPar
1285
 
1286
; --------------------------------------------------------------------------
1287
CS_MENU_P2R_KNB_VALUE
1288
	movf	CS_MENU_PARAMETER_IX, W
1289
	call	SID_KNOB_GetPtr
1290
	movf	FSR1L, W
1291
	addlw	SID_Ix_Px_VALUE
1292
	movwf	FSR0L
1293
	movf	FSR1H, W
1294
	addlw	HIGH(SID_EDIT_BUFFER)-HIGH(SID_PATCH_BUFFER)
1295
	movwf	FSR0H
1296
	movff	CS_MENU_PARAMETER_L, INDF0
1297
 
1298
	;; special sending routine knob values
1299
	goto	CS_MENU_MS_SendKnob
1300
 
1301
CS_MENU_R2P_KNB_VALUE
1302
	movf	CS_MENU_PARAMETER_IX, W
1303
	call	SID_KNOB_GetPtr
1304
	movlw	HIGH(SID_EDIT_BUFFER)-HIGH(SID_PATCH_BUFFER)
1305
	addwf	FSR1H, F
1306
	movlw	SID_Ix_Px_VALUE
1307
	movf	PLUSW1, W
1308
	rgoto	CS_MENU_R2P_SetPar
1309
 
1310
; --------------------------------------------------------------------------
1311
CS_MENU_P2R_KNB_P
1312
	call	CS_MENU_FSR0_Knob
1313
	rcall	CS_MENU_P2R_PAR8
1314
	;; update knob depending on new Min/Max boundary
1315
	goto	CS_MENU_MS_UpdateKnob
1316
 
1317
CS_MENU_R2P_KNB_P
1318
	call	CS_MENU_FSR0_Knob
1319
	rgoto	CS_MENU_R2P_PAR8
1320
 
1321
; --------------------------------------------------------------------------
1322
CS_MENU_P2R_KNB_ASG
1323
	call	CS_MENU_FSR0_Knob
1324
	rcall	CS_MENU_P2R_PAR8
1325
	;; update shadow buffer (so that the old assignment has no effect anymore)
1326
	goto	CS_MENU_MS_UpdateShadow
1327
 
1328
CS_MENU_R2P_KNB_ASG
1329
	call	CS_MENU_FSR0_Knob
1330
	rgoto	CS_MENU_R2P_PAR8
1331
 
1332
; --------------------------------------------------------------------------
1333
CS_MENU_P2R_EXT_VALUE
1334
	;; convert 12bit -> 16bit
1335
	swapf	CS_MENU_PARAMETER_H, W
1336
	andlw	0xf0
1337
	movwf	PRODH
1338
	swapf	CS_MENU_PARAMETER_L, W
1339
	andlw	0x0f
1340
	iorwf	PRODH, F
1341
	swapf	CS_MENU_PARAMETER_L, W
1342
	andlw	0xf0
1343
	movwf	PRODL
1344
 
1345
	movff	PRODL, INDF0		; send low byte
1346
	rcall	CS_MENU_P2R_Hlp_ParSend
1347
	movf	POSTINC0, W
1348
	movff	PRODH, INDF0		; send high byte
1349
	rcall	CS_MENU_P2R_Hlp_ParSend
1350
	movf	POSTDEC0, W
1351
	return
1352
 
1353
CS_MENU_R2P_EXT_VALUE
1354
	;; convert 16bit -> 12bit
1355
	movff	POSTINC0, PRODL
1356
	movff	POSTDEC0, PRODH
1357
 
1358
	swapf	PRODH, W
1359
	andlw	0x0f
1360
	movwf	CS_MENU_PARAMETER_H
1361
	swapf	PRODH, W
1362
	andlw	0xf0
1363
	movwf	CS_MENU_PARAMETER_L
1364
	swapf	PRODL, W
1365
	andlw	0x0f
1366
	iorwf	CS_MENU_PARAMETER_L, F
1367
	return
1368
 
1369
; --------------------------------------------------------------------------
1370
CS_MENU_P2R_EXT_SWITCH
1371
	;; change address to custom switch register
1372
	movlw	SID_Ix_CUSTOM_SW
1373
	movwf	FSR0L
1374
	;; turn on/off switch flag which is stored in CS_MENU_PARAMETER_IX
1375
	movf	CS_MENU_PARAMETER_IX, W
1376
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1377
 
1378
CS_MENU_R2P_EXT_SWITCH
1379
	;; change address to custom switch register
1380
	movlw	SID_Ix_CUSTOM_SW
1381
	movwf	FSR0L
1382
	;; flag number in CS_MENU_PARAMETER_IX
1383
	movf	CS_MENU_PARAMETER_IX, W
1384
	rgoto	CS_MENU_R2P_SetParFlag
1385
 
1386
; --------------------------------------------------------------------------
1387
CS_MENU_P2R_WTx_PAR
1388
	call	CS_MENU_FSR0_WT
1389
	rcall	CS_MENU_P2R_PAR8
1390
	;; update shadow buffer (so that the old assignment has no effect anymore)
1391
	goto	CS_MENU_MS_UpdateShadow
1392
 
1393
CS_MENU_R2P_WTx_PAR
1394
	call	CS_MENU_FSR0_WT
1395
	rgoto	CS_MENU_R2P_PAR8
1396
 
1397
; --------------------------------------------------------------------------
1398
CS_MENU_P2R_WTx_SID
1399
	call	CS_MENU_FSR0_WT
1400
	bcf	INDF0, 6
1401
	bcf	INDF0, 7
1402
	btfsc	CS_MENU_PARAMETER_L, 0
1403
	bsf	INDF0, 6
1404
	btfsc	CS_MENU_PARAMETER_L, 1
1405
	bsf	INDF0, 7
1406
	rgoto	CS_MENU_P2R_Hlp_ParSend
1407
 
1408
CS_MENU_R2P_WTx_SID
1409
	call	CS_MENU_FSR0_WT
1410
	movlw	0x00
1411
	btfsc	INDF0, 6
1412
	movlw 0x01
1413
	btfsc	INDF0, 7
1414
	iorlw 0x02
1415
	rgoto	CS_MENU_R2P_SetPar
1416
 
1417
; --------------------------------------------------------------------------
1418
CS_MENU_P2R_WTx_SPD
1419
	call	CS_MENU_FSR0_WT
1420
	movlw	0xc0
1421
	andwf	INDF0, F
1422
	movf	CS_MENU_PARAMETER_L, W
1423
	andlw	0x3f
1424
	iorwf	INDF0, F
1425
	rgoto	CS_MENU_P2R_Hlp_ParSend
1426
 
1427
CS_MENU_R2P_WTx_SPD
1428
	call	CS_MENU_FSR0_WT
1429
	movf	INDF0, W
1430
	andlw	0x3f
1431
	rgoto	CS_MENU_R2P_SetPar
1432
 
1433
; --------------------------------------------------------------------------
1434
CS_MENU_P2R_WTx_B6
1435
	call	CS_MENU_FSR0_WT
1436
	movlw	6
1437
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1438
 
1439
CS_MENU_R2P_WTx_B6
1440
	call	CS_MENU_FSR0_WT
1441
	movlw	6
1442
	rgoto	CS_MENU_R2P_SetParFlag
1443
 
1444
; --------------------------------------------------------------------------
1445
CS_MENU_P2R_WTx_B7
1446
	call	CS_MENU_FSR0_WT
1447
	movlw	7
1448
	rgoto	CS_MENU_P2R_Hlp_ParSendFlag
1449
 
1450
CS_MENU_R2P_WTx_B7
1451
	call	CS_MENU_FSR0_WT
1452
	movlw	7
1453
	rgoto	CS_MENU_R2P_SetParFlag
1454
 
1455
; --------------------------------------------------------------------------
1456
CS_MENU_P2R_WTx_POS
1457
	call	CS_MENU_FSR0_WT
1458
	movlw	0x80
1459
	andwf	INDF0, F
1460
	movf	CS_MENU_PARAMETER_L, W
1461
	andlw	0x7f
1462
	iorwf	INDF0, F
1463
	rgoto	CS_MENU_P2R_Hlp_ParSend
1464
 
1465
CS_MENU_R2P_WTx_POS
1466
	call	CS_MENU_FSR0_WT
1467
	movf	INDF0, W
1468
	andlw	0x7f
1469
	rgoto	CS_MENU_R2P_SetPar
1470
 
1471
 
1472
; --------------------------------------------------------------------------
1473
CS_MENU_P2R_WTx_LOP
1474
	call	CS_MENU_FSR0_WT
1475
	decf	CS_MENU_PARAMETER_L, W
1476
	andlw	0x7f
1477
	movf	CS_MENU_PARAMETER_L, F
1478
	skpnz
1479
	movlw	0x80
1480
	movwf	INDF0
1481
	rgoto	CS_MENU_P2R_Hlp_ParSend
1482
 
1483
CS_MENU_R2P_WTx_LOP
1484
	call	CS_MENU_FSR0_WT
1485
	incf	INDF0, W
1486
	btfsc	INDF0, 7
1487
	movlw 0x00
1488
	rgoto	CS_MENU_R2P_SetPar
1489
 
1490
 
1491
; --------------------------------------------------------------------------
1492
CS_MENU_P2R_WTE_PAR
1493
	rgoto	CS_MENU_P2R_Hlp_WTP
1494
 
1495
CS_MENU_R2P_WTE_PAR
1496
	call	CS_MENU_FSR0_WTPos
1497
	skpz
1498
	goto	CS_MENU_R2P_PAR8
1499
	rgoto	CS_MENU_R2P_SetPar
1500
 
1501
 
1502
; --------------------------------------------------------------------------
1503
CS_MENU_P2R_WT_VAL
1504
	rcall	CS_MENU_P2RR2P_GetVAR
1505
	bcf	INDF0, CS_STAT2_WT_DEC_VIEW
1506
	btfsc	CS_MENU_PARAMETER_L, 0
1507
	bsf	INDF0, CS_STAT2_WT_DEC_VIEW
1508
	return
1509
 
1510
CS_MENU_R2P_WT_VAL
1511
	rcall	CS_MENU_P2RR2P_GetVAR
1512
	movlw	0x00
1513
	btfsc	INDF0, CS_STAT2_WT_DEC_VIEW
1514
	movlw 0x01
1515
	rgoto	CS_MENU_R2P_SetPar
1516
 
1517
; --------------------------------------------------------------------------
1518
CS_MENU_P2R_B_SEQ_VAL
1519
	rgoto	CS_MENU_P2R_B_SEQ_VAL_Sub
1520
 
1521
 
1522
CS_MENU_R2P_B_SEQ_VAL
1523
	rgoto	CS_MENU_R2P_B_SEQ_VAL_Sub
1524
 
1525
; --------------------------------------------------------------------------
1526
CS_MENU_P2R_ENSx_VAL
1527
	call	CS_MENU_FSR0_ENS
1528
	movf	CS_MENU_PARAMETER_L, W
1529
	movwf	INDF0
1530
	goto	CS_MENU_MS_SendEnsParameter
1531
 
1532
CS_MENU_R2P_ENSx_VAL
1533
	call	CS_MENU_FSR0_ENS
1534
	movf	INDF0, W
1535
	rgoto	CS_MENU_R2P_SetPar
1536
 
1537
; --------------------------------------------------------------------------
1538
CS_MENU_P2R_ENSxIx_VAL
1539
	call	CS_MENU_FSR0_ENS_Ix
1540
	movf	CS_MENU_PARAMETER_L, W
1541
	movwf	INDF0
1542
	goto	CS_MENU_MS_SendEnsParameter
1543
 
1544
CS_MENU_R2P_ENSxIx_VAL
1545
	call	CS_MENU_FSR0_ENS_Ix
1546
	movf	INDF0, W
1547
	rgoto	CS_MENU_R2P_SetPar
1548
 
1549
; --------------------------------------------------------------------------
1550
CS_MENU_P2R_ENSx_X2A
1551
	call	CS_MENU_FSR0_ENS_CTRL2
1552
	movf	CS_MENU_PARAMETER_IX, W		; contains x2A flag
1553
	call	MIOS_HLP_GetBitORMask
1554
	BRA_IFSET CS_MENU_PARAMETER_L, 0, ACCESS, CS_MENU_P2R_ENSx_X2A_1
1555
CS_MENU_P2R_ENSx_X2A_0
1556
	xorlw	0xff
1557
	andwf	INDF0, F
1558
	rgoto	CS_MENU_P2R_ENSx_X2A_Cont
1559
CS_MENU_P2R_ENSx_X2A_1
1560
	iorwf	INDF0, F
1561
CS_MENU_P2R_ENSx_X2A_Cont
1562
	;; forward to master/slave
1563
	goto	CS_MENU_MS_SendEnsParameter
1564
 
1565
CS_MENU_R2P_ENSx_X2A
1566
	call	CS_MENU_FSR0_ENS_CTRL2
1567
	movf	CS_MENU_PARAMETER_IX, W		; contains x2A flag
1568
	call	MIOS_HLP_GetBitORMask
1569
	andwf	INDF0, W
1570
	skpz
1571
	movlw	0x01
1572
	rgoto	CS_MENU_R2P_SetPar
1573
 
1574
 
1575
; --------------------------------------------------------------------------
1576
CS_MENU_P2R_ENSx_RESERVED
1577
	return
1578
 
1579
CS_MENU_R2P_ENSx_RESERVED
1580
	return
1581
 
1582
; --------------------------------------------------------------------------
1583
CS_MENU_P2R_ENSx_MONO
1584
	call	CS_MENU_FSR0_ENS
1585
	bcf	INDF0, SID_ENS_CTRL1_MONO
1586
	btfsc	CS_MENU_PARAMETER_L, 0
1587
	bsf	INDF0, SID_ENS_CTRL1_MONO
1588
	;; forward to master/slave
1589
	goto	CS_MENU_MS_SendEnsParameter
1590
 
1591
CS_MENU_R2P_ENSx_MONO
1592
	call	CS_MENU_FSR0_ENS
1593
	movlw	0
1594
	btfsc	INDF0, SID_ENS_CTRL1_MONO
1595
	movlw 1
1596
	rgoto	CS_MENU_R2P_SetPar
1597
 
1598
 
1599
; --------------------------------------------------------------------------
1600
CS_MENU_P2R_ENSx_SPV
1601
	call	CS_MENU_FSR0_ENS
1602
	movlw	0xf8
1603
	andwf	INDF0, F
1604
	movf	CS_MENU_PARAMETER_L, W
1605
	iorwf	INDF0, F
1606
	;; forward to master/slave
1607
	call	CS_MENU_MS_SendEnsParameter
1608
	;; re-initialize voice queue
1609
	goto	CS_MENU_MS_SP_ReInit
1610
 
1611
CS_MENU_R2P_ENSx_SPV
1612
	call	CS_MENU_FSR0_ENS
1613
	movf	INDF0, W
1614
	andlw	0x07
1615
	rgoto	CS_MENU_R2P_SetPar
1616
 
1617
 
1618
; --------------------------------------------------------------------------
1619
CS_MENU_P2R_ENSx_EXTINV
1620
	rcall	CS_MENU_R2P_ENSx_EXTINV_GetAddr
1621
	movf	CS_MENU_PARAMETER_IX, W
1622
	call	MIOS_HLP_GetBitANDMask
1623
	andwf	INDF0, F
1624
	xorlw	0xff
1625
	movf	CS_MENU_PARAMETER_L, F
1626
	skpz
1627
	iorwf	INDF0, F
1628
	;; forward to master/slave
1629
	goto	CS_MENU_MS_SendEnsParameter
1630
 
1631
CS_MENU_R2P_ENSx_EXTINV
1632
	rcall	CS_MENU_R2P_ENSx_EXTINV_GetAddr
1633
	movf	CS_MENU_PARAMETER_IX, W
1634
	call	MIOS_HLP_GetBitORMask
1635
	andwf	INDF0, W
1636
	skpz
1637
	movlw	0x01
1638
	rgoto	CS_MENU_R2P_SetPar
1639
 
1640
CS_MENU_R2P_ENSx_EXTINV_GetAddr
1641
	call	CS_MENU_FSR0_ENS
1642
	movf	FSR0L, W	; (CS_MENU_PARAMETER_IX and FSR0L contain offset to bit instead of address)
1643
	andlw	0xf0
1644
	addlw	SID_ENSx_AOUT_INVERTED
1645
	movwf	FSR0L
1646
	return
1647
 
1648
; --------------------------------------------------------------------------
1649
CS_MENU_P2R_303_CUTOFF
1650
	CS_MENU_P2R_FX_SEND_MACRO
1651
	;; scaled by factor 32 (2^5)
1652
	movf	CS_MENU_PARAMETER_L, W
1653
	mullw	32
1654
	movff	PRODL, INDF0
1655
	rcall	CS_MENU_P2R_Hlp_ParSend		; send low byte
1656
	movf	POSTINC0, W
1657
 
1658
	movf	CS_MENU_PARAMETER_L, W
1659
	mullw	32
1660
	movlw	0xf0
1661
	andwf	INDF0, F
1662
	movf	PRODH, W
1663
	iorwf	INDF0, F
1664
	rcall	CS_MENU_P2R_Hlp_ParSend		; send high byte
1665
	movf	POSTDEC0, W
1666
	return
1667
 
1668
CS_MENU_R2P_303_CUTOFF
1669
	call	CS_MENU_FSR0_Filter
1670
	swapf	POSTINC0, W
1671
	rrf	WREG, W
1672
	andlw	0x07
1673
	movwf	CS_MENU_PARAMETER_L
1674
 
1675
	swapf	POSTDEC0, W
1676
	rrf	WREG, W
1677
	andlw	0x78
1678
	iorwf	CS_MENU_PARAMETER_L, F
1679
	clrf	CS_MENU_PARAMETER_H
1680
	return
1681
 
1682
 
1683
; --------------------------------------------------------------------------
1684
CS_MENU_P2R_303_DEP
1685
	;; 7bit -> 8bit (+0x80, positive range only)
1686
	call	CS_MENU_FSR0_ENV
1687
	movf	CS_MENU_PARAMETER_L, W
1688
	addlw	0x80
1689
	btfss	WREG, 7
1690
	movlw 0x80
1691
	movwf	INDF0
1692
	rgoto	CS_MENU_P2R_Hlp_ParSend
1693
 
1694
CS_MENU_R2P_303_DEP
1695
	;; 8bit -> 7bit (-0x80, positive range only)
1696
	call	CS_MENU_FSR0_ENV
1697
	movf	INDF0, W
1698
	addlw	-0x80
1699
	btfsc	WREG, 7
1700
	movlw 0x00
1701
	rgoto	CS_MENU_R2P_SetPar
1702
 
1703
 
1704
; --------------------------------------------------------------------------
1705
CS_MENU_P2R_303_DEC
1706
	;; scaled by two
1707
	call	CS_MENU_FSR0_ENV
1708
	clrc
1709
	rlf	CS_MENU_PARAMETER_L, W
1710
	movwf	INDF0
1711
	rgoto	CS_MENU_P2R_Hlp_ParSend
1712
 
1713
CS_MENU_R2P_303_DEC
1714
	call	CS_MENU_FSR0_ENV
1715
	clrc
1716
	rrf	INDF0, W
1717
	rgoto	CS_MENU_R2P_SetPar
1718
 
1719
 
1720
; ==========================================================================
1721
; ==========================================================================
1722
;  Help Functions
1723
; ==========================================================================
1724
; ==========================================================================
1725
 
1726
; --------------------------------------------------------------------------
1727
;; get variable (value in WREG, pointer in FSR0)
1728
CS_MENU_P2RR2P_GetVAR
1729
	clrf	FSR0H
1730
	bcf	FSR0L, 7
1731
	movf	INDF0, W
1732
	return
1733
 
1734
; --------------------------------------------------------------------------
1735
;; set variable
1736
CS_MENU_P2RR2P_SetVAR
1737
	rcall	CS_MENU_P2RR2P_GetVAR
1738
	movff	CS_MENU_PARAMETER_L, INDF0
1739
	return
1740
 
1741
; --------------------------------------------------------------------------
1742
;; set common value
1743
CS_MENU_R2P_SetPar
1744
	movwf	CS_MENU_PARAMETER_L
1745
	clrf	CS_MENU_PARAMETER_H
1746
	return
1747
 
1748
; --------------------------------------------------------------------------
1749
;; update patch (used on BNK and PAT changes)
1750
CS_MENU_P2R_CFG_Hlp_PatchUpdate
1751
	call	CS_MENU_MS_GetSIDPatch
1752
	bcf	INDF1, 7	; force save of patch/bank
1753
	movff	INDF1, CS_MENU_PARAMETER_L
1754
	goto	CS_MENU_PatchUpdateSingle
1755
 
1756
 
1757
; --------------------------------------------------------------------------
1758
;; set flag (address in FSR0)
1759
CS_MENU_R2P_SetParFlag
1760
	call	MIOS_HLP_GetBitORMask
1761
	andwf	INDF0, W
1762
	movlw	0
1763
	skpz
1764
	movlw	1
1765
	rgoto	CS_MENU_R2P_SetPar
1766
 
1767
; --------------------------------------------------------------------------
1768
;; rotate the selected sequencer track
1769
CS_MENU_P2R_RotateSeqTrack
1770
	;; pointer to 16bit entry -> FSR0
1771
	call	CS_MENU_FSR0_WTPos
1772
 
1773
	;; re-arrange order of 4 bytes for better handling
1774
	movff	POSTINC0, TMP1	; gate shift register (Step 1-8)
1775
	movff	POSTINC0, TMP3	; accent shift register (Step 1-8)
1776
	movff	POSTINC0, TMP2	; gate shift register (Step 9-16)
1777
	movff	INDF0, TMP4	; accent shift register (Step 9-16)
1778
	movlw	-3		; (switch back to initial offset)
1779
	addwf	FSR0L, F
1780
 
1781
	;; direction depends on incrementer
1782
	BRA_IFCLR CS_MENU_ENC_INCREMENTER, 7, ACCESS, CS_MENU_P2R_RotateSeqTrack_R
1783
CS_MENU_P2R_RotateSeqTrack_L
1784
	;; rotate gates and accent to the left (by using rrf - no programming error, bits are mirrored)
1785
	clrc
1786
	rrf	TMP2, F
1787
	rrf	TMP1, F
1788
	skpnc
1789
	bsf	TMP2, 7
1790
 
1791
	clrc
1792
	rrf	TMP4, F
1793
	rrf	TMP3, F
1794
	skpnc
1795
	bsf	TMP4, 7
1796
	rgoto	CS_MENU_P2R_RotateSeqTrack_End
1797
 
1798
CS_MENU_P2R_RotateSeqTrack_R
1799
	;; rotate gates and accent to the right (by using rlf - no programming error, bits are mirrored)
1800
	clrc
1801
	rlf	TMP1, F
1802
	rlf	TMP2, F
1803
	skpnc
1804
	bsf	TMP1, 0
1805
 
1806
	clrc
1807
	rlf	TMP3, F
1808
	rlf	TMP4, F
1809
	skpnc
1810
	bsf	TMP3, 0
1811
	;; 	rgoto	CS_MENU_P2R_RotateSeqTrack_End
1812
CS_MENU_P2R_RotateSeqTrack_End
1813
 
1814
	;; copy-back results
1815
	movff	TMP1, INDF0	; gate shift register (Step 1-8)
1816
	rcall	CS_MENU_P2R_Hlp_ParSend
1817
	movff	TMP3, PREINC0	; accent shift register (Step 1-8)
1818
	rcall	CS_MENU_P2R_Hlp_ParSend
1819
	movff	TMP2, PREINC0	; gate shift register (Step 9-16)
1820
	rcall	CS_MENU_P2R_Hlp_ParSend
1821
	movff	TMP4, PREINC0	; accent shift register (Step 9-16)
1822
	rgoto	CS_MENU_P2R_Hlp_ParSend
1823
 
1824
 
1825
; ==========================================================================
1826
;  Function to send a parameter to all selected SIDs
1827
;  expecting value in INDF0
1828
; ==========================================================================
1829
CS_MENU_P2R_Hlp_ParSend
1830
	goto	CS_MENU_MS_SendParameter
1831
 
1832
 
1833
; ==========================================================================
1834
;  Function to copy CS_MENU_PARAMETER_L[0] to a given flag
1835
;; modified parameter is sent to all selected SIDs
1836
;  expecting address in of register which should be modified in FSR0
1837
; ==========================================================================
1838
CS_MENU_P2R_Hlp_ParSendFlag
1839
	BRA_IFSET CS_MENU_PARAMETER_L, 0, ACCESS, CS_MENU_P2R_Hlp_ParSendFlag_1
1840
 
1841
CS_MENU_P2R_Hlp_ParSendFlag_0
1842
	call	MIOS_HLP_GetBitANDMask
1843
	andwf	INDF0, F
1844
	rgoto	CS_MENU_P2R_Hlp_ParSend
1845
 
1846
CS_MENU_P2R_Hlp_ParSendFlag_1
1847
	call	MIOS_HLP_GetBitORMask
1848
	iorwf	INDF0, F
1849
	rgoto	CS_MENU_P2R_Hlp_ParSend
1850
 
1851
 
1852
; ==========================================================================
1853
;  Function to execute P2R filter handlers for all selected SIDs
1854
;  expecting pointer to handler function in TOS[LHU] (!)
1855
; ==========================================================================
1856
CS_MENU_P2R_Fx_Send
1857
	;; save TOS[LHU] (the return pointer) in TBLPTR[LHU]
1858
	movff	TOSL, TBLPTRL
1859
	movff	TOSH, TBLPTRH
1860
	movff	TOSU, TBLPTRU
1861
 
1862
	;; branch depending on engine
1863
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
1864
	BRA_IFSET WREG, 1, ACCESS, CS_MENU_P2R_Fx_Send_DM
1865
CS_MENU_P2R_Fx_Send_LB
1866
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_P2R_Fx_Send_B
1867
 
1868
CS_MENU_P2R_Fx_Send_L
1869
	movlw	SID_Ix_L_S1F_BASE
1870
	addwf	FSR0L, F
1871
	RCALL_IFSET CS_MENU_SELECTED_SID_LR, 0, ACCESS, CS_MENU_P2R_CallSub
1872
	movlw	SID_Ix_L_S2F_BASE-SID_Ix_L_S1F_BASE
1873
	addwf	FSR0L, F
1874
	RCALL_IFSET CS_MENU_SELECTED_SID_LR, 1, ACCESS, CS_MENU_P2R_CallSub
1875
 
1876
	;; jump back to the previous caller!
1877
	pop
1878
	return
1879
 
1880
 
1881
CS_MENU_P2R_Fx_Send_B		; bassline engine
1882
	rgoto	CS_MENU_P2R_Fx_Send_L	; same as for lead engine
1883
 
1884
 
1885
CS_MENU_P2R_Fx_Send_DM
1886
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_P2R_Fx_Send_M
1887
 
1888
CS_MENU_P2R_Fx_Send_D		; drum engine
1889
	;; (same as for multi engine)
1890
CS_MENU_P2R_Fx_Send_M		; multi engine
1891
	rgoto	CS_MENU_P2R_Fx_Send_L	; same as for lead engine
1892
 
1893
 
1894
; ==========================================================================
1895
;  Function to execute P2R voice handlers for all selected voices and SIDs
1896
;  expecting pointer to handler function in TOS[LHU] (!)
1897
; ==========================================================================
1898
CS_MENU_P2R_Vx_Send
1899
	;; save TOS[LHU] (the return pointer) in TBLPTR[LHU]
1900
	movff	TOSL, TBLPTRL
1901
	movff	TOSH, TBLPTRH
1902
	movff	TOSU, TBLPTRU
1903
 
1904
	;; branch depending on engine
1905
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
1906
	BRA_IFSET WREG, 1, ACCESS, CS_MENU_P2R_Vx_Send_DM
1907
CS_MENU_P2R_Vx_Send_LB
1908
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_P2R_Vx_Send_B
1909
 
1910
CS_MENU_P2R_Vx_Send_L		; lead engine
1911
	BRA_IFCLR CS_MENU_SELECTED_SID_LR, 0, ACCESS, CS_MENU_P2R_Vx_Send_L_SR
1912
CS_MENU_P2R_Vx_Send_L_SL
1913
	movlw	SID_Ix_L_S1V1_BASE
1914
	addwf	CS_MENU_PARAMETER_IX, W
1915
	movwf	FSR0L
1916
	RCALL_IFSET CS_MENU_SELECTED_OSC_FLAGS, 0, ACCESS, CS_MENU_P2R_CallSub
1917
	movlw	SID_Ix_L_S1V2_BASE-SID_Ix_L_S1V1_BASE
1918
	addwf	FSR0L, F
1919
	RCALL_IFSET CS_MENU_SELECTED_OSC_FLAGS, 1, ACCESS, CS_MENU_P2R_CallSub
1920
	movlw	SID_Ix_L_S1V3_BASE-SID_Ix_L_S1V2_BASE
1921
	addwf	FSR0L, F
1922
	RCALL_IFSET CS_MENU_SELECTED_OSC_FLAGS, 2, ACCESS, CS_MENU_P2R_CallSub
1923
CS_MENU_P2R_Vx_Send_L_SR
1924
	BRA_IFCLR CS_MENU_SELECTED_SID_LR, 1, ACCESS, CS_MENU_P2R_Vx_Send_L_End
1925
	movlw	SID_Ix_L_S2V1_BASE
1926
	addwf	CS_MENU_PARAMETER_IX, W
1927
	movwf	FSR0L
1928
	RCALL_IFSET CS_MENU_SELECTED_OSC_FLAGS, 0, ACCESS, CS_MENU_P2R_CallSub
1929
	movlw	SID_Ix_L_S2V2_BASE-SID_Ix_L_S2V1_BASE
1930
	addwf	FSR0L, F
1931
	RCALL_IFSET CS_MENU_SELECTED_OSC_FLAGS, 1, ACCESS, CS_MENU_P2R_CallSub
1932
	movlw	SID_Ix_L_S2V3_BASE-SID_Ix_L_S2V2_BASE
1933
	addwf	FSR0L, F
1934
	RCALL_IFSET CS_MENU_SELECTED_OSC_FLAGS, 2, ACCESS, CS_MENU_P2R_CallSub
1935
CS_MENU_P2R_Vx_Send_L_End
1936
	;; jump back to the previous caller!
1937
	pop
1938
	return
1939
 
1940
 
1941
CS_MENU_P2R_Vx_Send_B		; bassline engine
1942
	BRA_IFCLR CS_MENU_SELECTED_SID_LR, 0, ACCESS, CS_MENU_P2R_Vx_Send_B_SR
1943
CS_MENU_P2R_Vx_Send_B_SL
1944
	movlw	SID_Ix_B_S1V1_BASE
1945
	addwf	CS_MENU_PARAMETER_IX, W
1946
	movwf	FSR0L
1947
	rcall	CS_MENU_P2R_CallSub
1948
CS_MENU_P2R_Vx_Send_B_SR
1949
	BRA_IFCLR CS_MENU_SELECTED_SID_LR, 1, ACCESS, CS_MENU_P2R_Vx_Send_B_End
1950
	movlw	SID_Ix_B_S2V1_BASE
1951
	addwf	CS_MENU_PARAMETER_IX, W
1952
	movwf	FSR0L
1953
	rcall	CS_MENU_P2R_CallSub
1954
CS_MENU_P2R_Vx_Send_B_End
1955
	;; jump back to the previous caller!
1956
	pop
1957
	return
1958
 
1959
 
1960
CS_MENU_P2R_Vx_Send_DM
1961
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_P2R_Vx_Send_M
1962
 
1963
CS_MENU_P2R_Vx_Send_D		; drum engine
1964
	;; (same as for multi engine)
1965
CS_MENU_P2R_Vx_Send_M		; multi engine
1966
	call	CS_MENU_FSR0_Voice
1967
	rcall	CS_MENU_P2R_CallSub
1968
 
1969
	;; jump back to the previous caller!
1970
	pop
1971
	return
1972
 
1973
 
1974
 
1975
CS_MENU_P2R_CallSub
1976
	;; copy TBLPTR[LHU] to TOS[LHU] and return
1977
	IRQ_DISABLE
1978
	push
1979
	movf	TBLPTRL, W
1980
	movwf	TOSL
1981
	movf	TBLPTRH, W
1982
	movwf	TOSH
1983
	movf	TBLPTRU, W
1984
	movwf	TOSU
1985
	IRQ_ENABLE
1986
	return
1987
 
1988
 
1989
; ==========================================================================
1990
;  special variant of MIOS_HLP_GetIndex_2bytes which allows to add 16bit values (PROD[LH])
1991
; ==========================================================================
1992
CS_MENU_P2RR2P_GetIndex_2bytes
1993
	movf	PRODL, W
1994
        addwf   TOSL, F
1995
	movf	PRODH, W
1996
	addwfc	TOSH, F
1997
#if PIC_DERIVATIVE_CODE_SIZE > 0x10000
1998
	movlw	0x00
1999
	addwfc	TOSU, F
2000
#endif
2001
        return
2002
 
2003
 
2004
; ==========================================================================
2005
;  memory intensive P2R/R2P routines for MOD and TRG nodes located here to
2006
;  ensure that the rgoto based jumptable still accesses code within 1024 byte range
2007
; ==========================================================================
2008
CS_MENU_P2R_MODx_Nx
2009
	;; NOTE: also used by CS_MENU_BUTTON_M_* routines to toggle modulation matrix node
2010
	;; bit number stored in CS_MENU_PARAMETER_IX
2011
 
2012
	;; get pointer to modulation nodes
2013
	call	CS_MENU_FSR0_MOD_TARG_L
2014
 
2015
	;; determine masks
2016
	movf	CS_MENU_PARAMETER_IX, W
2017
	call	MIOS_HLP_GetBitORMask
2018
	movwf	TMP1
2019
	movf	CS_MENU_PARAMETER_IX, W
2020
	call	MIOS_HLP_GetBitANDMask
2021
	movwf	TMP2
2022
 
2023
	;; copy bits to SID_Ix_MODx_TARG_[LR]
2024
	;; 	movf	TMP2, W
2025
	andwf	INDF0, F
2026
	movf	TMP1, W
2027
	btfsc	CS_MENU_PARAMETER_L, 0
2028
	iorwf	INDF0, F
2029
	rcall	CS_MENU_P2R_Hlp_ParSend
2030
 
2031
	movf	TMP2, W
2032
	andwf	PREINC0, F
2033
	movf	TMP1, W
2034
	btfsc	CS_MENU_PARAMETER_L, 1
2035
	iorwf	INDF0, F
2036
	rgoto	CS_MENU_P2R_Hlp_ParSend
2037
 
2038
 
2039
CS_MENU_R2P_MODx_Nx
2040
	;; NOTE: also used by CS_MENU_BUTTON_M_* routines to toggle modulation matrix node
2041
	;; bit number stored in CS_MENU_PARAMETER_IX
2042
 
2043
	;; get pointer to modulation nodes
2044
	call	CS_MENU_FSR0_MOD_TARG_L
2045
 
2046
	;; determine mask
2047
	movf	CS_MENU_PARAMETER_IX, W
2048
	call	MIOS_HLP_GetBitORMask
2049
	movwf	TMP1
2050
 
2051
	;; build up CS_MENU_PARAMETER_[LH]
2052
	clrf	CS_MENU_PARAMETER_L
2053
	clrf	CS_MENU_PARAMETER_H
2054
 
2055
	movf	POSTINC0, W
2056
	andwf	TMP1, W
2057
	skpz
2058
	bsf	CS_MENU_PARAMETER_L, 0
2059
 
2060
	movf	POSTDEC0, W
2061
	andwf	TMP1, W
2062
	skpz
2063
	bsf	CS_MENU_PARAMETER_L, 1
2064
 
2065
	return
2066
 
2067
CS_MENU_P2R_TRGx_Nx
2068
	;; also used by CS_MENU_P2R_LFOx_SNC
2069
	;; don't overwrite TMP5 !!!
2070
 
2071
	;; get pointer to trigger target
2072
	call	CS_MENU_FSR0_TRG
2073
 
2074
	;; determine masks
2075
	movf	CS_MENU_PARAMETER_IX, W
2076
	call	MIOS_HLP_GetBitORMask
2077
	movwf	TMP1
2078
	movf	CS_MENU_PARAMETER_IX, W
2079
	call	MIOS_HLP_GetBitANDMask
2080
	movwf	TMP2
2081
 
2082
	;; copy bit to SID_Ix_TRG_xxx_BASE
2083
	;; 	movf	TMP2, W
2084
	andwf	INDF0, F
2085
	movf	TMP1, W
2086
	btfsc	CS_MENU_PARAMETER_L, 0
2087
	iorwf	INDF0, F
2088
	rgoto	CS_MENU_P2R_Hlp_ParSend
2089
 
2090
 
2091
CS_MENU_R2P_TRGx_Nx
2092
	;; also used by CS_MENU_R2P_LFOx_SNC
2093
	;; don't overwrite TMP5 !!!
2094
 
2095
	;; get pointer to trigger target
2096
	call	CS_MENU_FSR0_TRG
2097
 
2098
	;; determine mask
2099
	movf	CS_MENU_PARAMETER_IX, W
2100
	call	MIOS_HLP_GetBitORMask
2101
	movwf	TMP1
2102
 
2103
	;; build up CS_MENU_PARAMETER_[LH]
2104
	clrf	CS_MENU_PARAMETER_L
2105
	clrf	CS_MENU_PARAMETER_H
2106
 
2107
	movf	INDF0, W
2108
	andwf	TMP1, W
2109
	skpz
2110
	bsf	CS_MENU_PARAMETER_L, 0
2111
 
2112
	return
2113
 
2114
; ==========================================================================
2115
;  Function to set a WT parameter
2116
; ==========================================================================
2117
CS_MENU_P2R_Hlp_WTP
2118
	;; store parameter
2119
	call	CS_MENU_FSR0_WTPos		; sets ZERO flag if value outside range
2120
	skpnz
2121
	return
2122
 
2123
	movf	CS_MENU_WT_POS, W
2124
	xorlw	0x80
2125
	bz	CS_MENU_P2R_Hlp_WTP_All
2126
CS_MENU_P2R_Hlp_WTP_Single
2127
	movff	CS_MENU_PARAMETER_L, INDF0
2128
	rgoto	CS_MENU_P2R_Hlp_ParSend
2129
 
2130
CS_MENU_P2R_Hlp_WTP_All
2131
	;; modify all entries from begin to end position
2132
	clrf	CS_MENU_WT_POS
2133
CS_MENU_P2R_Hlp_WTP_AllLoop
2134
	call	CS_MENU_FSR0_WTPos		; sets ZERO flag if value outside range
2135
	bz	CS_MENU_P2R_Hlp_WTP_AllLoopBreak
2136
	movff	CS_MENU_PARAMETER_L, INDF0
2137
	rcall	CS_MENU_P2R_Hlp_ParSend
2138
	incf	CS_MENU_WT_POS, F
2139
	BRA_IFCLR CS_MENU_WT_POS, 7, ACCESS, CS_MENU_P2R_Hlp_WTP_AllLoop
2140
CS_MENU_P2R_Hlp_WTP_AllLoopBreak
2141
	;; set back CS_MENU_WT_POS to original value (0x80)
2142
	movlw	0x80
2143
	movwf	CS_MENU_WT_POS
2144
	return
2145
 
2146
; ==========================================================================
2147
;  Function to set a SEQ parameter
2148
; ==========================================================================
2149
CS_MENU_P2R_B_SEQ_VAL_Sub
2150
	;; if WTPOS >= 0x10, modify all entries
2151
	movf	CS_MENU_WT_POS, W
2152
	andlw	0xf0
2153
	bz	CS_MENU_P2R_B_SEQ_VAL_Sub_Single
2154
 
2155
CS_MENU_P2R_B_SEQ_VAL_Sub_All
2156
	clrf	CS_MENU_WT_POS		; used as loop counter - 16 steps
2157
CS_MENU_P2R_B_SEQ_VAL_Sub_All_Lp
2158
	rcall	CS_MENU_P2R_B_SEQ_VAL_Sub_Single
2159
	incf	CS_MENU_WT_POS, F
2160
	BRA_IFCLR CS_MENU_WT_POS, 4, ACCESS, CS_MENU_P2R_B_SEQ_VAL_Sub_All_Lp
2161
 
2162
	;; CS_MENU_WT_POS is 0x10 again - thats fine!
2163
	return
2164
 
2165
 
2166
CS_MENU_P2R_B_SEQ_VAL_Sub_Single
2167
	;; determine pointer to parameter depending on CS_MENU_WT_SEQ/CS_MENU_WT_POS
2168
	call	CS_MENU_FSR0_WTPos
2169
 
2170
	;; branch depending on parameter part:
2171
	;; 0 = note, 1 = Octave, 2 = Slide/Gate, 3 = Accent, 4 = Parameter
2172
	movf	CS_MENU_PARAMETER_IX, W
2173
	bz	CS_MENU_P2R_B_SEQ_VAL_Note
2174
	addlw	-1
2175
	bz	CS_MENU_P2R_B_SEQ_VAL_Oct
2176
	addlw	-1
2177
	bz	CS_MENU_P2R_B_SEQ_VAL_S_G
2178
	addlw	-1
2179
	bz	CS_MENU_P2R_B_SEQ_VAL_Acc
2180
	rgoto	CS_MENU_P2R_B_SEQ_VAL_Par
2181
CS_MENU_P2R_B_SEQ_VAL_Note
2182
	movlw	0xf0
2183
	andwf	INDF0, F
2184
	movf	CS_MENU_PARAMETER_L, W
2185
	andlw	0x0f
2186
	iorwf	INDF0, F
2187
	rgoto	CS_MENU_P2R_Hlp_ParSend
2188
 
2189
CS_MENU_P2R_B_SEQ_VAL_Oct
2190
	movlw	0xcf
2191
	andwf	INDF0, F
2192
	swapf	CS_MENU_PARAMETER_L, W
2193
	andlw	0x30
2194
	btfsc	WREG, 5	; for mapping: 0=0, 1=1, 2=3, 3=2
2195
	btg	WREG, 4
2196
	iorwf	INDF0, F
2197
	rgoto	CS_MENU_P2R_Hlp_ParSend
2198
 
2199
CS_MENU_P2R_B_SEQ_VAL_S_G
2200
	movlw	0x3f
2201
	andwf	INDF0, F
2202
	swapf	CS_MENU_PARAMETER_L, W
2203
	rlf	WREG, W
2204
	rlf	WREG, W
2205
	andlw	0xc0
2206
	iorwf	INDF0, F
2207
	rgoto	CS_MENU_P2R_Hlp_ParSend
2208
 
2209
CS_MENU_P2R_B_SEQ_VAL_Acc
2210
	;; accent is located in upper bank
2211
	movlw	0x80
2212
	addwf	FSR0L, F
2213
 
2214
	bcf	INDF0, 7
2215
	btfsc	CS_MENU_PARAMETER_L, 0
2216
	bsf	INDF0, 7
2217
	rgoto	CS_MENU_P2R_Hlp_ParSend
2218
 
2219
CS_MENU_P2R_B_SEQ_VAL_Par
2220
	;; 7bit parameter is located in upper bank
2221
	movlw	0x80
2222
	addwf	FSR0L, F
2223
 
2224
	movlw	0x80
2225
	andwf	INDF0, F
2226
	movf	CS_MENU_PARAMETER_L, W
2227
	andlw	0x7f
2228
	iorwf	INDF0, F
2229
	rgoto	CS_MENU_P2R_Hlp_ParSend
2230
 
2231
 
2232
 
2233
CS_MENU_R2P_B_SEQ_VAL_Sub
2234
	;; determine pointer to parameter depending on CS_MENU_WT_SEQ/CS_MENU_WT_POS
2235
	call	CS_MENU_FSR0_WTPos
2236
 
2237
	;; branch depending on parameter part:
2238
	;; 0 = note, 1 = Octave, 2 = Slide/Gate, 3 = Accent, 4 = Parameter
2239
	movf	CS_MENU_PARAMETER_IX, W
2240
	bz	CS_MENU_R2P_B_SEQ_VAL_Note
2241
	addlw	-1
2242
	bz	CS_MENU_R2P_B_SEQ_VAL_Oct
2243
	addlw	-1
2244
	bz	CS_MENU_R2P_B_SEQ_VAL_S_G
2245
	addlw	-1
2246
	bz	CS_MENU_R2P_B_SEQ_VAL_Acc
2247
	rgoto	CS_MENU_R2P_B_SEQ_VAL_Par
2248
CS_MENU_R2P_B_SEQ_VAL_Note
2249
	movf	INDF0, W
2250
	andlw	0x0f
2251
	rgoto	CS_MENU_R2P_SetPar
2252
 
2253
CS_MENU_R2P_B_SEQ_VAL_Oct
2254
	swapf	INDF0, W
2255
	andlw	0x03
2256
	btfsc	WREG, 1	; for mapping: 0=0, 1=1, 2=3, 3=2
2257
	btg	WREG, 0
2258
	rgoto	CS_MENU_R2P_SetPar
2259
 
2260
CS_MENU_R2P_B_SEQ_VAL_S_G
2261
	swapf	INDF0, W
2262
	rrf	WREG, W
2263
	rrf	WREG, W
2264
	andlw	0x03
2265
	rgoto	CS_MENU_R2P_SetPar
2266
 
2267
CS_MENU_R2P_B_SEQ_VAL_Acc
2268
	;; accent is located in upper bank
2269
	movlw	0x80
2270
	addwf	FSR0L, F
2271
	movlw	0x00
2272
	btfsc	INDF0, 7
2273
	movlw 0x01
2274
	rgoto	CS_MENU_R2P_SetPar
2275
 
2276
CS_MENU_R2P_B_SEQ_VAL_Par
2277
	;; 7bit parameter is located in upper bank
2278
	movlw	0x80
2279
	addwf	FSR0L, F
2280
	movf	INDF0, W
2281
	andlw	0x7f
2282
	rgoto	CS_MENU_R2P_SetPar