Subversion Repositories svn.mios

Rev

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

Rev Author Line No. Line
44 tk 1
; $Id: cs_menu_buttons.inc 1230 2018-08-25 23:22:37Z tk $
1 tk 2
;
3
; SID Control Surface Button Handler
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
;;  This handler has to be called by USER_DIN_NotifyToggle when a button
15
;;  has been pressed/depressed
279 tk 16
;;  It goes through the CS_MENU_DIN_TABLE in "setup_*.asm",
1 tk 17
;;  searches for a matching DIN pin and calls the appr. function
18
;;
19
;;  Input:
20
;;     o Button number in MIOS_PARAMETER1
21
;;         0-127: "normal" DIN button
22
;;       128-255: matrix button (only first 64 are implemented)
23
;;
24
;;     o Button value MIOS_PARAMETER2:
25
;;       - 1 if button has been released (=5V)
26
;;       - 0 if button has been pressed (=0V)
27
;; --------------------------------------------------------------------------
28
CS_MENU_BUTTON_Handler
29
	;; stop MIOS based LCD message if button pressed
30
	CALL_IFCLR MIOS_PARAMETER2, 0, ACCESS, MIOS_LCD_MessageStop
31
 
32
	;; get SID number
33
	call	CS_MENU_MS_GetSIDNumber
34
 
35
	;; go through the DIN map
36
	TABLE_ADDR CS_MENU_DIN_TABLE
37
CS_MENU_BUTTON_Handler_Loop
38
	tblrd*+				; get low-byte of function pointer
39
	movf	TABLAT, W		; load it in WREG
40
	movwf	TMP1			; and store it in TMP1
41
	tblrd*+				; get high byte
42
	movff	TABLAT, TMP2		; store it in TMP2 without touching WREG
43
	iorwf	TABLAT, W		; or the byte with WREG --- if both bytes are zero, the result will be zero
44
	bz	CS_MENU_BUTTON_Handler_End; in this case jump to the end
45
 
46
	tblrd*+				; get pin-number
47
	movf	TABLAT, W
48
	tblrd*+				; and read dummy entry
49
	;; pin number still in WREG, compare it with MIOS_PARAMETER1
50
	xorwf	MIOS_PARAMETER1, W
51
	bnz	CS_MENU_BUTTON_Handler_Loop; next loop if not equal
52
 
53
	;; else: matching pin has been found
54
	;; jump indirectly to the function (pointer in TMP1/TMP2)
55
	IRQ_DISABLE		; (IRQs have to be disabled when TOSL/TOSH is modified)
56
	push
57
	movf	TMP1, W
58
	movwf	TOSL
59
	movf	TMP2, W
60
	movwf	TOSH
61
	IRQ_ENABLE
62
	return			; this return leads to a jump to the function stored in TOSL/TOSH
63
 
64
CS_MENU_BUTTON_Handler_End
65
	;; no matching pin found, exit handler
66
	return
67
 
68
 
69
;; --------------------------------------------------------------------------
70
;; the button functions are defined here
71
;; --------------------------------------------------------------------------
72
CS_MENU_BUTTON_Dec
73
	;; do nothing if button has been depressed
74
	btfsc	MIOS_PARAMETER2, 0
75
	return
76
	;; exit with message if SID player mode enabled and SID1 selected
77
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
78
	;; enable auto repeat (should normaly be done in the _init.inc file,
79
	;; but we want to handle it more flexible
80
	movf	MIOS_PARAMETER1, W
81
	call	MIOS_DIN_PinAutoRepeatEnable
82
	;; decrement 1
83
	movlw	0xff
84
	;; branch to ENC handler
85
	goto	CS_MENU_ENC_Handler
86
 
87
	;; ------------------------------------------------------------------
88
CS_MENU_BUTTON_Inc
89
	;; do nothing if button has been depressed
90
	btfsc	MIOS_PARAMETER2, 0
91
	return
92
	;; exit with message if SID player mode enabled and SID1 selected
93
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
94
	;; enable auto repeat (should normaly be done in the _init.inc file,
95
	;; but we want to handle it more flexible
96
	movf	MIOS_PARAMETER1, W
97
	call	MIOS_DIN_PinAutoRepeatEnable
98
	;; increment 1
99
	movlw	0x01
100
	;; branch to ENC handler
101
	goto	CS_MENU_ENC_Handler
102
 
103
	;; ------------------------------------------------------------------
104
CS_MENU_BUTTON_Exec
105
	;; special startup condition: if MENU button pressed while CS_MENU_REINIT_CFG_CTR is != 0, clone slaves
106
	movf	CS_MENU_REINIT_CFG_CTR, W
107
	bz	CS_MENU_BUTTON_Exec_NoStartup
108
	btfsc	MIOS_PARAMETER2, 0
109
	return
110
 
111
	goto	MBNET_Clone_Me
112
 
113
 
114
CS_MENU_BUTTON_Exec_NoStartup
115
	;; activate/deactivate menu button function
116
	bcf	CS_MENU_MODE, CS_MENU_MODE_MENU_PRESSED
117
	btfss	MIOS_PARAMETER2, 0; if button is pressed
118
	bsf	CS_MENU_MODE, CS_MENU_MODE_MENU_PRESSED
119
 
120
	;; do nothing if button has been depressed
121
	btfsc	MIOS_PARAMETER2, 0
122
	return
123
 
124
	;; EXTRA for Exec/Menu button:
125
	;; exit SID player mode if CS is disabled
126
	GOTO_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, SIDPLAY_Disable
127
 
128
	goto	CS_MENU_Exec
129
 
130
	;; ------------------------------------------------------------------
131
CS_MENU_BUTTON_Sel10
132
	;; select button #10, set cursor to 10th position
133
	movlw	0x09
134
	rgoto	CS_MENU_BUTTON_Select_Cont
135
 
136
CS_MENU_BUTTON_Sel9
137
	;; select button #9, set cursor to 9th position
138
	movlw	0x08
139
	rgoto	CS_MENU_BUTTON_Select_Cont
140
 
141
CS_MENU_BUTTON_Sel8
142
	;; select button #8, set cursor to 8th position
143
	movlw	0x07
144
	rgoto	CS_MENU_BUTTON_Select_Cont
145
 
146
CS_MENU_BUTTON_Sel7
147
	;; select button #7, set cursor to 7th position
148
	movlw	0x06
149
	rgoto	CS_MENU_BUTTON_Select_Cont
150
 
151
CS_MENU_BUTTON_Sel6
152
	;; select button #6, set cursor to 6th position
153
	movlw	0x05
154
	rgoto	CS_MENU_BUTTON_Select_Cont
155
 
156
CS_MENU_BUTTON_Sel5
157
	;; select button #5, set cursor to 5th position
158
	movlw	0x04
159
	rgoto	CS_MENU_BUTTON_Select_Cont
160
 
161
CS_MENU_BUTTON_Sel4
162
	;; select button #4, set cursor to 4th position
163
	movlw	0x03
164
	rgoto	CS_MENU_BUTTON_Select_Cont
165
 
166
CS_MENU_BUTTON_Sel3
167
	;; select button #3, set cursor to 3rd position
168
	movlw	0x02
169
	rgoto	CS_MENU_BUTTON_Select_Cont
170
 
171
CS_MENU_BUTTON_Sel2
172
	;; select button #2, set cursor to 2nd position
173
	movlw	0x01
174
	rgoto	CS_MENU_BUTTON_Select_Cont
175
 
176
CS_MENU_BUTTON_Sel1
177
	;; select button #1, set cursor to 1st position
178
	movlw	0x00
179
	;; 	rgoto	CS_MENU_BUTTON_Select_Cont
180
 
181
CS_MENU_BUTTON_Select_Cont
182
	;; do nothing if button has been depressed
183
	btfsc	MIOS_PARAMETER2, 0
184
	return
185
	;; exit with message if SID player mode enabled and SID1 selected
186
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
187
 
296 tk 188
	;; branch if in SHIFT page
189
	GOTO_IFSET CS_STAT3, CS_STAT3_SHIFT_PAGE, ACCESS, CS_MENU_SHIFT_Button
1 tk 190
 
191
	;; set cursor to: CS_MENU_PAGE_OFFSET + number in WREG
192
	addwf	CS_MENU_PAGE_OFFSET, W
193
 
194
	;; branch to the CS_MENU_Select function
195
	goto	CS_MENU_Select
196
 
197
	;; ------------------------------------------------------------------
198
CS_MENU_BUTTON_SID1
199
	movlw	1 << 0
200
	rgoto	CS_MENU_BUTTON_SID_Cont
201
 
202
CS_MENU_BUTTON_SID2
203
	movlw	1 << 1
204
	rgoto	CS_MENU_BUTTON_SID_Cont
205
 
206
CS_MENU_BUTTON_SID3
207
	movlw	1 << 2
208
	rgoto	CS_MENU_BUTTON_SID_Cont
209
 
210
CS_MENU_BUTTON_SID4
211
	movlw	1 << 3
212
	;; 	rgoto	CS_MENU_BUTTON_SID_Cont
213
 
214
CS_MENU_BUTTON_SID_Cont
215
	movwf	TMP1
216
 
217
	;; always request new display-initialization
218
	bsf	CS_STAT, CS_STAT_DISPLAY_INIT_REQ
219
 
220
	;; only save button state if button has been depressed and exit
221
	BRA_IFSET MIOS_PARAMETER2, 0, ACCESS, CS_MENU_BUTTON_SID_Hlp_Off
222
 
223
	;; else branch depending on state of all 4 SID buttons:
224
	;; if only one SID button pressed: radio-button function (1 of 4)
225
	;; if more than one SID button pressed: toggle function (4 of 4)
226
	movf	CS_MENU_SELECTED_SID_FLAGS, W
227
	andlw	0xf0
228
	xorlw	0xf0
229
	bz	CS_MENU_BUTTON_SID_Radio
230
CS_MENU_BUTTON_SID_Select
231
	;; toggle SID flag
232
	movf	TMP1, W
233
	xorwf	CS_MENU_SELECTED_SID_FLAGS, F
234
 	rgoto	CS_MENU_BUTTON_SID_End
235
CS_MENU_BUTTON_SID_Radio
236
	;; select 1 of 4
237
	movlw	0xf0
238
	andwf	CS_MENU_SELECTED_SID_FLAGS, F
239
	movf	TMP1, W
240
	iorwf	CS_MENU_SELECTED_SID_FLAGS, F
241
	;; 	rgoto	CS_MENU_BUTTON_SID_End
242
 
243
CS_MENU_BUTTON_SID_End
244
	;; save button state
245
	rcall	CS_MENU_BUTTON_SID_Hlp_Sav
246
 
247
	;; save patch/bank number of newly selected SID into CS_MENU_SAVE_PATCH/Bank
248
	call	CS_MENU_MS_GetSIDNumber
249
	call	CS_MENU_MS_GetSIDPatch; sets FSR1 to patch register
250
	movf	INDF1, W
251
	andlw	0x7f
252
	movwf	CS_MENU_SAVE_PATCH
253
	call	CS_MENU_MS_GetSIDBank; sets FSR1 to bank register
254
	movf	INDF1, W
255
	andlw	0x07
256
	movwf	CS_MENU_SAVE_BANK
257
 
258
	;; when we are switching from one to another engine, the menu page could be invalid
259
	;; therefore the pages of the appr. engines are stored in an array, and restored
260
	;; whenever required. In order to save menu, the cursor position and page offset
261
	;; is not stored...
262
	;; this measure is only required if we are neither in ensemble, nor main menu
263
	movf	CS_MENU, W
264
	andlw	0xc0
265
	bnz	CS_MENU_BUTTON_SID_End_NoEngPage
266
CS_MENU_BUTTON_SID_End_EngPage
267
	lfsr	FSR1, CS_MENU_LASTPAGE_ENG_0
268
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
269
	andlw	0x03
270
	movwf	SAVED_CS_ENGINE		; store in SAVED_CS_ENGINE for later comparison
271
	movff	CS_MENU, PLUSW1
272
CS_MENU_BUTTON_SID_End_NoEngPage
273
 
274
	;; checks if a slave is available - if not, a connection will be retried
275
	call	CS_MENU_MBNET_Retry
276
 
277
	;; update edit buffer
278
	call	CS_MENU_MS_UpdateEditBuffer
279
 
280
	;; if not in main/ensemble menu, and engine has been changed: use last stored CS_MENU of the appr. engine
281
	movf	CS_MENU, W
282
	andlw	0xc0
283
	bnz	CS_MENU_BUTTON_SID_End_NoEngPag2
284
CS_MENU_BUTTON_SID_End_EngPag2
285
	;; check if engine has been changed
286
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
287
	xorwf	SAVED_CS_ENGINE, W
288
	andlw	0x03
289
	bz	CS_MENU_BUTTON_SID_End_NoEngPag2
290
 
291
	;; change page depending on newly selected engine and enter it
292
	lfsr	FSR1, CS_MENU_LASTPAGE_ENG_0
293
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
294
	andlw	0x03
295
	movf	PLUSW1, W
296
	rcall	CS_MENU_BUTTON_Hlp_MenuChangeOk	; (w/o check)
297
CS_MENU_BUTTON_SID_End_NoEngPag2
298
 
299
	;; update parameter
300
	call	CS_MENU_EncParameterSet
301
 
302
	;; request reinitialization of complete CS
303
	rcall	CS_MENU_BUTTON_DisplayUpdateReq
304
 
305
	;; if SID1 selected, and SID player is active: re-initialize screen
306
	BRA_IFCLR CS_MENU_SELECTED_SID_FLAGS, 0, ACCESS, CS_MENU_BUTTON_SID_End_NoSP
307
	BRA_IFCLR SID_STAT, SID_STAT_SIDPLAYER, ACCESS, CS_MENU_BUTTON_SID_End_NoSP
308
CS_MENU_BUTTON_SID_End_SP
309
	;; init LCD for SID player
310
	call	SIDPLAY_InitLCD
311
	;; disable CS (dirty, but USER_Tick not called before next update)
312
	bsf	SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE
313
	;; dirty: update LEDs as well (not done anywhere else...)
314
	call	CS_MENU_LED_Update
315
CS_MENU_BUTTON_SID_End_NoSP
316
	return
317
 
318
CS_MENU_BUTTON_SID_Hlp_Off
319
	;; button has been depressed
320
 
321
CS_MENU_BUTTON_SID_Hlp_Sav
322
	;; mask out old button status
323
	swapf	TMP1, W
324
	xorlw	0xff
325
	andwf	CS_MENU_SELECTED_SID_FLAGS, F
326
 
327
	;; store new button status (pressed/depressed) in CS_MENU_SELECTED_SID_FLAGS[7..4]
328
	swapf	TMP1, W
329
	btfsc	MIOS_PARAMETER2, 0
330
	iorwf	CS_MENU_SELECTED_SID_FLAGS, F
331
	return
332
 
333
 
334
	;; ------------------------------------------------------------------
335
CS_MENU_BUTTON_Shift
336
	;; exit with message if SID player mode enabled and SID1 selected
337
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
338
 
339
	;; activate/deactivate shift function
340
	bcf	CS_MENU_MODE, CS_MENU_MODE_SHIFT_PRESSED
341
	btfss	MIOS_PARAMETER2, 0; if button is pressed
342
	bsf	CS_MENU_MODE, CS_MENU_MODE_SHIFT_PRESSED
343
 
296 tk 344
	;; change to SHIFT page
345
	bcf	CS_STAT3, CS_STAT3_SHIFT_PAGE
1 tk 346
	btfss	MIOS_PARAMETER2, 0; if button is pressed
296 tk 347
	bsf	CS_STAT3, CS_STAT3_SHIFT_PAGE
1 tk 348
 
349
	;; always request new display-initialization
350
	bsf	CS_STAT, CS_STAT_DISPLAY_INIT_REQ
351
 
352
	return
353
 
354
	;; ------------------------------------------------------------------
355
CS_MENU_BUTTON_CC
356
	;; do nothing if button has been depressed
357
	btfsc	MIOS_PARAMETER2, 0
358
	return
359
	;; exit with message if SID player mode enabled and SID1 selected
360
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
361
	;; toggle CC mode
362
	btg	CS_MENU_MODE, CS_MENU_MODE_CC
363
	;; print message
364
	rgoto	CS_MENU_BUTTON_DisplayUpdateReq
365
 
366
	;; ------------------------------------------------------------------
367
CS_MENU_BUTTON_Edit
368
	;; do nothing if button has been depressed
369
	btfsc	MIOS_PARAMETER2, 0
370
	return
371
	;; exit with message if SID player mode enabled and SID1 selected
372
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
373
	;; toggle edit mode
374
	btg	CS_MENU_MODE, CS_MENU_MODE_EDIT
375
	;; copy value to flashed LED flag
376
	bcf	CS_MENU_MODE, CS_MENU_MODE_EDIT_FLASHED
377
	btfsc	CS_MENU_MODE, CS_MENU_MODE_EDIT
378
	bsf	CS_MENU_MODE, CS_MENU_MODE_EDIT_FLASHED
379
	;; set the cursor counter which is also used to flash the LED
380
	movlw	5*2
381
	movwf	CS_CURSOR_CTR
382
	rgoto	CS_MENU_BUTTON_DisplayUpdateReq
383
 
384
	;; ------------------------------------------------------------------
385
CS_MENU_BUTTON_Play
386
	;; do nothing if button has been depressed
387
	btfsc	MIOS_PARAMETER2, 0
388
	return
296 tk 389
 
1 tk 390
	;; exit with message if SID player mode enabled and SID1 selected
391
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
296 tk 392
 
653 tk 393
	;; if master is running in superpoly mode: chord will be played on all SIDs
394
	movff	SID_LOCAL_ENS + SID_ENSx_SUPERPOLY_CTRL, WREG
395
	andlw	0x07
396
	bz	CS_MENU_BUTTON_Play_NoSuperPoly
397
CS_MENU_BUTTON_Play_SuperPoly
398
	movlw	0x00		; master will send all 4 notes to the SIDs in SP mode
806 tk 399
	call	CS_MENU_MS_PlayNote_SuperPoly
400
	rgoto	CS_MENU_BUTTON_Play_End
653 tk 401
 
402
CS_MENU_BUTTON_Play_NoSuperPoly
1 tk 403
 
806 tk 404
	;; new (for more comfortable usage)
405
	;; play Note On/Off on all SIDs regardless of selection
406
	;; for more intuitive usage (especially in live situations, e.g. when a single SID sound
407
	;; is edited, this has advantages)
408
 
409
	;; dedicated SIDs can be played by pressing & holding the appr. SID buttons before pressing PLAY
410
	movf	CS_MENU_SELECTED_SID_FLAGS, W
411
	andlw	0xf0
412
	xorlw	0xf0
413
	bnz	CS_MENU_BUTTON_Play_Toggle
414
 
415
CS_MENU_BUTTON_Play_NoToggle
416
	movf	CS_STAT2, W
417
	andlw	0xf0		; CS_STAT2_PLAY_SID1..4
418
	bnz	CS_MENU_BUTTON_Play_Off
419
 
420
CS_MENU_BUTTON_Play_On
421
	IRQ_DISABLE		; CS_STAT2 also changed by interrupts - operation must be atomic
422
	movlw	0xf0
423
	iorwf	CS_STAT2, F
424
	IRQ_ENABLE
425
 
426
	clrf	CS_MENU_SID
427
	call	CS_MENU_MS_NotesOn
428
	incf	CS_MENU_SID, F
429
	call	CS_MENU_MS_NotesOn
430
	incf	CS_MENU_SID, F
431
	call	CS_MENU_MS_NotesOn
432
	incf	CS_MENU_SID, F
433
	call	CS_MENU_MS_NotesOn
434
 
435
	rgoto	CS_MENU_BUTTON_Play_End
436
 
437
CS_MENU_BUTTON_Play_Off
438
	IRQ_DISABLE		; CS_STAT2 also changed by interrupts - operation must be atomic
439
	movlw	0x0f
440
	andwf	CS_STAT2, F
441
	IRQ_ENABLE
442
 
443
	clrf	CS_MENU_SID
444
	call	CS_MENU_MS_NotesOff
445
	incf	CS_MENU_SID, F
446
	call	CS_MENU_MS_NotesOff
447
	incf	CS_MENU_SID, F
448
	call	CS_MENU_MS_NotesOff
449
	incf	CS_MENU_SID, F
450
	call	CS_MENU_MS_NotesOff
451
 
452
	rgoto	CS_MENU_BUTTON_Play_End
453
 
454
 
455
CS_MENU_BUTTON_Play_Toggle
456
        ;; CS_MENU_SELECTED_SID_FLAGS[3:0] contain the current selected SIDs
457
        movlw   0x00
458
        CALL_IFSET CS_MENU_SELECTED_SID_FLAGS, 0, ACCESS, CS_MENU_MS_PlayNote
459
        movlw   0x01
460
        CALL_IFSET CS_MENU_SELECTED_SID_FLAGS, 1, ACCESS, CS_MENU_MS_PlayNote
461
        movlw   0x02
462
        CALL_IFSET CS_MENU_SELECTED_SID_FLAGS, 2, ACCESS, CS_MENU_MS_PlayNote
463
        movlw   0x03
464
        CALL_IFSET CS_MENU_SELECTED_SID_FLAGS, 3, ACCESS, CS_MENU_MS_PlayNote
465
 
466
	;; 	rgoto	CS_MENU_BUTTON_Play_End
467
 
468
CS_MENU_BUTTON_Play_End
1 tk 469
	bsf	CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ
470
	return
471
 
806 tk 472
 
473
 
1 tk 474
	;; ------------------------------------------------------------------
475
CS_MENU_BUTTON_SID_LR
476
	;; do nothing if button has been depressed
477
	btfsc	MIOS_PARAMETER2, 0
478
	return
479
	;; exit with message if SID player mode enabled and SID1 selected
480
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
481
 
482
	;; toggle L/R
483
	incf	CS_MENU_SELECTED_SID_LR, W
484
	andlw	0x03
485
	skpnz
486
	addlw	1
487
	movwf	CS_MENU_SELECTED_SID_LR
368 tk 488
 
489
#if DEFAULT_LCD_LINES >= 3
490
	;; update menu label
491
	call	CS_MENU_UpdateLabel
492
#endif
493
 
494
	;; request display update
1 tk 495
	bsf	CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ
368 tk 496
 
1 tk 497
	return
498
 
499
	;; ------------------------------------------------------------------
500
CS_MENU_BUTTON_Sync
501
	;; do nothing if button has been depressed
502
	btfsc	MIOS_PARAMETER2, 0
503
	return
504
	;; exit with message if SID player mode enabled and SID1 selected
505
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
506
	;; branch to ENS->CLK menu
507
	movlw	CS_MENU_E_CLK
508
	rgoto	CS_MENU_BUTTON_Hlp_MenuChange
509
 
510
	;; ------------------------------------------------------------------
511
CS_MENU_BUTTON_Osc_Sel
512
	;; do nothing if button has been depressed
513
	btfsc	MIOS_PARAMETER2, 0
514
	return
515
	;; exit with message if SID player mode enabled and SID1 selected
516
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
517
 
869 tk 518
	;; only change to OSC page if not already selected
519
	call	CS_MENU_GetMenuID_OSC
520
	xorwf	CS_MENU, W
521
	bnz	CS_MENU_BUTTON_Osc_Sel_End
522
 
523
	;; otherwise increment oscillator
524
 
1 tk 525
	;; branch depending on engine
526
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
527
	BRA_IFSET WREG, 1, ACCESS, CS_MENU_BUTTON_Osc_Sel_DM
528
CS_MENU_BUTTON_Osc_Sel_LB
529
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_BUTTON_Osc_Sel_B
530
 
531
CS_MENU_BUTTON_Osc_Sel_L
745 tk 532
	;; select one or all OSC (4 states)
533
	movf	CS_MENU_SELECTED_OSC_FLAGS, W
534
	andlw	0x07
535
	TABLE_ADDR_MUL_W CS_MENU_BUTTON_Osc_Sel_Next_Tab, 1
536
	tblrd*+
537
	movf	TABLAT, W
1 tk 538
	movwf	CS_MENU_SELECTED_OSC
745 tk 539
 
747 tk 540
	;; update OSC flags
541
	call	CS_MENU_Hlp_UpdateOSCFlags
869 tk 542
	rgoto	CS_MENU_BUTTON_Osc_Sel_End
747 tk 543
 
1 tk 544
 
747 tk 545
	;; maps current OSC selection flags to next CS_MENU_SELECTED_OSC (and not flags!)
745 tk 546
CS_MENU_BUTTON_Osc_Sel_Next_Tab
747 tk 547
	;; from 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07   ; FLAGS
548
	db	0x00, 0x01, 0x02, 0x03, 0x06, 0x06, 0x06, 0x00   ; next OSC selection (see CS_MENU_Hlp_UpdateOSCFlags)
745 tk 549
 
1 tk 550
CS_MENU_BUTTON_Osc_Sel_B
551
	;; toggle L/R, oscillator always 1
552
	incf	CS_MENU_SELECTED_SID_LR, W
553
	andlw	0x03
554
	skpnz
555
	addlw	1
556
	movwf	CS_MENU_SELECTED_SID_LR
557
 
558
	movlw	0x01
559
	movwf	CS_MENU_SELECTED_OSC_FLAGS
869 tk 560
	rgoto	CS_MENU_BUTTON_Osc_Sel_End
1 tk 561
 
562
 
563
CS_MENU_BUTTON_Osc_Sel_DM
564
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_BUTTON_Osc_Sel_M
565
 
566
CS_MENU_BUTTON_Osc_Sel_D
567
	;; always select OSC1 (flag not really used by CS, we are working with instruments)
568
	movlw	0x01
569
	movwf	CS_MENU_SELECTED_OSC_FLAGS
869 tk 570
	rgoto	CS_MENU_BUTTON_Osc_Sel_End
1 tk 571
 
572
CS_MENU_BUTTON_Osc_Sel_M
573
	;; always select OSC1 (flag not really used by CS, we are working with instruments)
574
	movlw	0x01
575
	movwf	CS_MENU_SELECTED_OSC_FLAGS
869 tk 576
	rgoto	CS_MENU_BUTTON_Osc_Sel_End
577
 
578
 
579
CS_MENU_BUTTON_Osc_Sel_End
1 tk 580
	;; change to OSC page
581
	call	CS_MENU_GetMenuID_OSC
582
	rgoto	CS_MENU_BUTTON_Hlp_MenuChange
583
 
584
 
585
	;; ------------------------------------------------------------------
586
CS_MENU_BUTTON_Osc_Wav
587
	;; do nothing if button has been depressed
588
	btfsc	MIOS_PARAMETER2, 0
589
	return
590
	;; exit with message if SID player mode enabled and SID1 selected
591
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
592
 
593
	;; no function in drum mode
594
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
595
	andlw	0x03
596
	xorlw	0x02
597
	skpnz
598
	return
599
 
600
	;; else increment WAV setting
601
	movlw	0x01		; cursor pos
602
	movwf	MIOS_PARAMETER1
603
	movlw	0x00		; page offset
604
	movwf	MIOS_PARAMETER2
605
	call	CS_MENU_GetMenuID_OSC	; menu page
606
	goto	CS_MENU_ButtonInc
607
 
608
	;; ------------------------------------------------------------------
609
CS_MENU_BUTTON_Osc_RS
610
	;; do nothing if button has been depressed
611
	btfsc	MIOS_PARAMETER2, 0
612
	return
613
	;; exit with message if SID player mode enabled and SID1 selected
614
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
615
 
616
	;; no function in drum mode
617
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
618
	andlw	0x03
619
	xorlw	0x02
620
	skpnz
621
	return
622
 
623
	;; else increment R/S setting
624
	movlw	0x02		; cursor pos
625
	movwf	MIOS_PARAMETER1
626
	movlw	0x00		; page offset
627
	movwf	MIOS_PARAMETER2
628
	call	CS_MENU_GetMenuID_OSC	; menu page
629
	goto	CS_MENU_ButtonInc
630
 
631
	;; ------------------------------------------------------------------
632
CS_MENU_BUTTON_Osc_Ctrl
633
	;; do nothing if button has been depressed
634
	btfsc	MIOS_PARAMETER2, 0
635
	return
636
	;; exit with message if SID player mode enabled and SID1 selected
637
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
638
	;; increment OSC Ctrl parameter (0x00-0x02)
639
	incf	CS_MENU_SELECTED_OSC_CTRL, F
640
	movlw	0x02+1
641
	cpfslt	CS_MENU_SELECTED_OSC_CTRL, ACCESS
642
	clrf CS_MENU_SELECTED_OSC_CTRL
643
	CALL_IFCLR CS_MENU_SELECTED_OSC_CTRL, 1, ACCESS, CS_MENU_GetMenuID_OSC
644
	CALL_IFSET CS_MENU_SELECTED_OSC_CTRL, 1, ACCESS, CS_MENU_GetMenuID_KNB
645
	rcall	CS_MENU_BUTTON_Hlp_MenuChange
646
 
647
	;; set page offset and cursor pos depending on selected layer
648
	movf	CS_MENU_SELECTED_OSC_CTRL, W
649
	bnz	CS_MENU_BUTTON_Osc_Ctrl_Not0
650
CS_MENU_BUTTON_Osc_Ctrl_0
651
	movlw	0x03
652
	rgoto	CS_MENU_BUTTON_Osc_Ctrl_Cont
653
CS_MENU_BUTTON_Osc_Ctrl_Not0
654
	BRA_IFSET CS_MENU_SELECTED_OSC_CTRL, 1, ACCESS, CS_MENU_BUTTON_Osc_Ctrl_Not1
655
CS_MENU_BUTTON_Osc_Ctrl_1
656
	;; different offset for drum engine
657
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
658
	andlw	0x03
659
	xorlw	0x02
660
	bnz	CS_MENU_BUTTON_Osc_Ctrl_1_LBM
661
CS_MENU_BUTTON_Osc_Ctrl_1_D
662
	movlw	0x06
663
	rgoto	CS_MENU_BUTTON_Osc_Ctrl_Cont
664
CS_MENU_BUTTON_Osc_Ctrl_1_LBM
665
	movlw	0x09
666
	rgoto	CS_MENU_BUTTON_Osc_Ctrl_Cont
667
CS_MENU_BUTTON_Osc_Ctrl_Not1
668
	movlw	0x00
669
CS_MENU_BUTTON_Osc_Ctrl_Cont
670
	movwf	CS_MENU_PAGE_OFFSET
671
	movwf	CS_MENU_CURSOR_POS
672
 
673
	;; deselect parameter (and update CS_MENU_PARAMETER_L for new cursor pos)
674
	bsf	CS_STAT, CS_STAT_MODIFY_PARAMETER
675
	goto	CS_MENU_EXEC_Hlp_ChangeMenu
676
 
677
	;; ------------------------------------------------------------------
678
CS_MENU_BUTTON_LFO_Sel
679
	;; do nothing if button has been depressed
680
	btfsc	MIOS_PARAMETER2, 0
681
	return
869 tk 682
	;; exit with message if SID player mode enabled and SID1 selected
683
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
684
 
685
	;; only change to LFO page if not already selected
686
	call	CS_MENU_GetMenuID_LFO
687
	xorwf	CS_MENU, W
688
	bz	CS_MENU_BUTTON_LFO_Sel_Inc
689
	call	CS_MENU_GetMenuID_LFO
880 tk 690
	goto	CS_MENU_BUTTON_Hlp_MenuChange
869 tk 691
 
692
 
693
	;; otherwise increment LFO
694
CS_MENU_BUTTON_LFO_Sel_Inc
1 tk 695
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
696
	andlw	0x03
697
	movlw	0x00		; cursor pos Lead is 0
698
	skpz
699
	movlw	0x01		; cursor pos Bassline/Drum/Multi is 1
700
	movwf	MIOS_PARAMETER1
701
	movlw	0x00		; page offset
702
	movwf	MIOS_PARAMETER2
703
	call	CS_MENU_GetMenuID_LFO	; menu page
704
	goto	CS_MENU_ButtonInc
705
 
706
	;; ------------------------------------------------------------------
707
CS_MENU_BUTTON_LFO_Wav
708
	;; do nothing if button has been depressed
709
	btfsc	MIOS_PARAMETER2, 0
710
	return
711
	;; exit with message if SID player mode enabled and SID1 selected
712
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
713
	;; else increment LFO setting
714
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
715
	andlw	0x03
716
	movlw	0x01		; cursor pos Lead is 1
717
	skpz
718
	movlw	0x02		; cursor pos Bassline/Drum/Multi is 2
719
	movwf	MIOS_PARAMETER1
720
	movlw	0x00		; page offset
721
	movwf	MIOS_PARAMETER2
722
	call	CS_MENU_GetMenuID_LFO	; menu page
723
	goto	CS_MENU_ButtonInc
724
 
725
	;; ------------------------------------------------------------------
726
CS_MENU_BUTTON_Env_Sel
727
	;; do nothing if button has been depressed
728
	btfsc	MIOS_PARAMETER2, 0
729
	return
730
	;; exit with message if SID player mode enabled and SID1 selected
731
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
732
 
869 tk 733
	;; only change to ENV page if not already selected
734
	call	CS_MENU_GetMenuID_ENV
735
	xorwf	CS_MENU, W
736
	bnz	CS_MENU_BUTTON_Env_Sel_End
737
 
738
	;; otherwise increment envelope
739
 
1 tk 740
	;; branch depending on engine
741
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
742
	BRA_IFSET WREG, 1, ACCESS, CS_MENU_BUTTON_Env_Sel_DM
743
CS_MENU_BUTTON_Env_Sel_LB
744
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_BUTTON_Env_Sel_B
745
 
746
CS_MENU_BUTTON_Env_Sel_L
747
	;; increment ENV setting
748
	movlw	0x00		; cursor pos
749
	movwf	MIOS_PARAMETER1
750
	movlw	0x00		; page offset
751
	movwf	MIOS_PARAMETER2
752
	call	CS_MENU_GetMenuID_ENV	; menu page
753
	goto	CS_MENU_ButtonInc
754
 
755
CS_MENU_BUTTON_Env_Sel_B
756
	;; toggle L/R
757
	incf	CS_MENU_SELECTED_SID_LR, W
758
	andlw	0x03
759
	skpnz
760
	addlw	1
761
	movwf	CS_MENU_SELECTED_SID_LR
869 tk 762
 	rgoto	CS_MENU_BUTTON_Env_Sel_End
1 tk 763
 
764
CS_MENU_BUTTON_Env_Sel_DM
765
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_BUTTON_Env_Sel_M
766
 
767
CS_MENU_BUTTON_Env_Sel_D
869 tk 768
	;; 	rgoto	CS_MENU_BUTTON_Env_Sel_End
1 tk 769
 
770
CS_MENU_BUTTON_Env_Sel_M
869 tk 771
	;; 	rgoto	CS_MENU_BUTTON_Env_Sel_End
772
 
773
CS_MENU_BUTTON_Env_Sel_End
1 tk 774
	call	CS_MENU_GetMenuID_ENV
775
	rgoto	CS_MENU_BUTTON_Hlp_MenuChange
776
 
777
 
778
	;; ------------------------------------------------------------------
779
CS_MENU_BUTTON_Env_Curve
780
	;; do nothing if button has been depressed
781
	btfsc	MIOS_PARAMETER2, 0
782
	return
783
	;; exit with message if SID player mode enabled and SID1 selected
784
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
785
	;; else increment ENV setting
786
	movlw	0x07		; cursor pos
787
	movwf	MIOS_PARAMETER1
788
	movlw	0x03		; page offset
789
	movwf	MIOS_PARAMETER2
790
	call	CS_MENU_GetMenuID_ENV	; menu page
791
	goto	CS_MENU_ButtonInc
792
 
793
	;; ------------------------------------------------------------------
794
CS_MENU_BUTTON_Env_Ctrl
795
	;; do nothing if button has been depressed
796
	btfsc	MIOS_PARAMETER2, 0
797
	return
798
	;; exit with message if SID player mode enabled and SID1 selected
799
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
800
#if DEFAULT_MB6582_CS
801
	;; else decrement ENV Ctrl parameter (0x00-0x02)
802
	;; this takes care of "Misc" layer being 0x02 but in middle of toggle/LED order,
803
	;; i.e. order is 0x00, 0x02, 0x01
804
	decf	CS_MENU_SELECTED_ENV_CTRL, F
805
	movlw	0x02
806
	btfsc	CS_MENU_SELECTED_ENV_CTRL, 1
807
	movwf CS_MENU_SELECTED_ENV_CTRL
808
#else
809
	;; else increment ENV Ctrl parameter (0x00-0x01)
810
	incf	CS_MENU_SELECTED_ENV_CTRL, F
811
	movlw	0x01+1
812
	cpfslt	CS_MENU_SELECTED_ENV_CTRL, ACCESS
813
	clrf CS_MENU_SELECTED_ENV_CTRL
814
#endif
815
#if 0
816
	call	CS_MENU_GetMenuID_ENV	; menu page
817
	rcall	CS_MENU_BUTTON_Hlp_MenuChange
818
 
819
	;; set page offset and cursor pos depending on selected layer
820
	movf	CS_MENU_SELECTED_ENV_CTRL, W
821
	bnz	CS_MENU_BUTTON_Env_Ctrl_Not0
822
CS_MENU_BUTTON_Env_Ctrl_0
823
	movlw	0x00
824
	rgoto	CS_MENU_BUTTON_Env_Ctrl_Cont
825
CS_MENU_BUTTON_Env_Ctrl_Not0
826
	movlw	0x01
827
CS_MENU_BUTTON_Env_Ctrl_Cont
828
	movwf	CS_MENU_PAGE_OFFSET
829
	movwf	CS_MENU_CURSOR_POS
830
 
831
	;; deselect parameter (and update CS_MENU_PARAMETER_L for new cursor pos)
832
	bsf	CS_STAT, CS_STAT_MODIFY_PARAMETER
833
	goto	CS_MENU_EXEC_Hlp_ChangeMenu
834
#else
835
	;; do nothing else...
836
	;; this is to allow the visible menu items on a more comfortable way (no unwanted menu switching)
837
	rgoto	CS_MENU_BUTTON_DisplayUpdateReq
838
#endif
839
 
840
	;; ------------------------------------------------------------------
841
CS_MENU_BUTTON_Fil_Sel
842
	;; do nothing if button has been depressed
843
	btfsc	MIOS_PARAMETER2, 0
844
	return
845
	;; exit with message if SID player mode enabled and SID1 selected
846
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
869 tk 847
 
848
	;; only change to FIL page if not already selected
849
	call	CS_MENU_GetMenuID_FIL
850
	xorwf	CS_MENU, W
851
	bz	CS_MENU_BUTTON_FIL_Sel_Inc
852
	call	CS_MENU_GetMenuID_FIL
880 tk 853
	goto	CS_MENU_BUTTON_Hlp_MenuChange
869 tk 854
 
1 tk 855
	;; else increment Filter setting
869 tk 856
CS_MENU_BUTTON_FIL_Sel_Inc
857
	movlw	0x01		; cursor pos
1 tk 858
	movwf	MIOS_PARAMETER1
859
	movlw	0x00		; page offset
860
	movwf	MIOS_PARAMETER2
861
	call	CS_MENU_GetMenuID_FIL	; menu page
862
	goto	CS_MENU_ButtonInc
863
 
864
	;; ------------------------------------------------------------------
865
CS_MENU_BUTTON_Fil_Mod
866
	;; do nothing if button has been depressed
867
	btfsc	MIOS_PARAMETER2, 0
868
	return
869
	;; exit with message if SID player mode enabled and SID1 selected
870
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
869 tk 871
 
872
	;; only change to FIL page if not already selected
873
	call	CS_MENU_GetMenuID_FIL
874
	xorwf	CS_MENU, W
875
	bz	CS_MENU_BUTTON_FIL_Mod_Inc
876
	call	CS_MENU_GetMenuID_FIL
880 tk 877
	goto	CS_MENU_BUTTON_Hlp_MenuChange
869 tk 878
 
879
CS_MENU_BUTTON_FIL_Mod_Inc
1 tk 880
	;; else increment Filter setting
869 tk 881
	movlw	0x04		; cursor pos
1 tk 882
	movwf	MIOS_PARAMETER1
883
	movlw	0x00		; page offset
884
	movwf	MIOS_PARAMETER2
885
	call	CS_MENU_GetMenuID_FIL	; menu page
886
	goto	CS_MENU_ButtonInc
887
 
888
	;; ------------------------------------------------------------------
889
CS_MENU_BUTTON_Fil_ExtIn
890
	;; do nothing if button has been depressed
891
	btfsc	MIOS_PARAMETER2, 0
892
	return
893
	;; exit with message if SID player mode enabled and SID1 selected
894
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
869 tk 895
 
1 tk 896
	;; else increment Filter setting
897
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
360 tk 898
	andlw	0x02		; different cursor pos in drum and multi mode (bit #1 of engine mode set)
899
	xorlw	0x02
1 tk 900
 
869 tk 901
	movlw	0x05		; cursor pos drum and multi
360 tk 902
	skpz
869 tk 903
	movlw	0x06		; cursor pos lead/bassline mode
1 tk 904
	movwf	MIOS_PARAMETER1
905
 
869 tk 906
	movlw	0x01		; page offset drum and multi
360 tk 907
	skpz
869 tk 908
	movlw	0x02		; page offset lead/bassline mode
1 tk 909
	movwf	MIOS_PARAMETER2
910
	call	CS_MENU_GetMenuID_FIL	; menu page
911
	goto	CS_MENU_ButtonInc
912
 
745 tk 913
 
1 tk 914
	;; ------------------------------------------------------------------
745 tk 915
CS_MENU_BUTTON_Arp
916
	;; Arp button enables/disables the arpeggiator of *all* oscillators
917
 
918
	;; do nothing if button has been depressed
919
	btfsc	MIOS_PARAMETER2, 0
920
	return
921
 
747 tk 922
	;; get SID number -> CS_MENU_SID
923
	;; note: multi-SID selection not supported, as ARP_MODE is not always in edit buffer
924
	;; (a special MBNet Command would be required...)
925
	call	CS_MENU_MS_GetSIDNumber
926
 
745 tk 927
	;; branch depending on engine
928
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
929
	BRA_IFSET WREG, 1, ACCESS, CS_MENU_BUTTON_Arp_DM
930
CS_MENU_BUTTON_Arp_LB
931
	BRA_IFSET WREG, 1, ACCESS, CS_MENU_BUTTON_Arp_B
932
CS_MENU_BUTTON_Arp_L
933
	;; reference flag in V1
934
	movff	SID_EDIT_BUFFER + SID_Ix_L_S1V1_BASE + SID_Ix_Vx_ARP_MODE, TMP1
935
	btg	TMP1, SID_I_V_ARP_MODE_ENABLE	; toggle ARP enable flag
936
 
937
	;; 2*3 oscillators
938
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_L_S1V1_BASE + SID_Ix_Vx_ARP_MODE
939
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
940
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_L_S1V2_BASE + SID_Ix_Vx_ARP_MODE
941
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
942
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_L_S1V3_BASE + SID_Ix_Vx_ARP_MODE
943
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
944
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_L_S2V1_BASE + SID_Ix_Vx_ARP_MODE
945
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
946
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_L_S2V2_BASE + SID_Ix_Vx_ARP_MODE
947
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
948
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_L_S2V3_BASE + SID_Ix_Vx_ARP_MODE
949
	rgoto	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
950
 
951
 
952
CS_MENU_BUTTON_Arp_B
953
	;; reference flag in V1
954
	movff	SID_EDIT_BUFFER + SID_Ix_B_S1V1_BASE + SID_Ix_Vx_ARP_MODE, TMP1
955
	btg	TMP1, SID_I_V_ARP_MODE_ENABLE	; toggle ARP enable flag
956
 
957
	;; 2 oscillators
958
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_B_S1V1_BASE + SID_Ix_Vx_ARP_MODE
959
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
960
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_B_S2V1_BASE + SID_Ix_Vx_ARP_MODE
961
	rgoto	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
962
 
963
 
964
CS_MENU_BUTTON_Arp_DM
965
	BRA_IFSET WREG, 1, ACCESS, CS_MENU_BUTTON_Arp_M
966
CS_MENU_BUTTON_Arp_D
967
	;; no function in drum mode
968
	return
969
 
970
CS_MENU_BUTTON_Arp_M
971
	;; reference flag in I1
972
	movff	SID_EDIT_BUFFER + SID_Ix_M_I1_BASE + SID_Ix_Vx_ARP_MODE, TMP1
973
	btg	TMP1, SID_I_V_ARP_MODE_ENABLE	; toggle ARP enable flag
974
 
975
	;; 6 oscillators
976
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_M_I1_BASE + SID_Ix_Vx_ARP_MODE
977
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
978
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_M_I2_BASE + SID_Ix_Vx_ARP_MODE
979
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
980
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_M_I3_BASE + SID_Ix_Vx_ARP_MODE
981
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
982
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_M_I4_BASE + SID_Ix_Vx_ARP_MODE
983
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
984
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_M_I5_BASE + SID_Ix_Vx_ARP_MODE
985
	rcall	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
986
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_M_I6_BASE + SID_Ix_Vx_ARP_MODE
987
	rgoto	CS_MENU_BUTTON_Arp_Hlp_ToggleArp
988
 
989
 
990
CS_MENU_BUTTON_Arp_Hlp_ToggleArp
991
	;; copy arp mode flag into parameter
992
	bcf	INDF0, SID_I_V_ARP_MODE_ENABLE
993
	btfsc	TMP1, SID_I_V_ARP_MODE_ENABLE
994
	bsf	INDF0, SID_I_V_ARP_MODE_ENABLE
995
 
996
	;; send parameter
997
	goto	CS_MENU_MS_SendParameter
998
 
999
 
1000
	;; ------------------------------------------------------------------
869 tk 1001
CS_MENU_BUTTON_Knob
1002
	;; do nothing if button has been depressed
1003
	btfsc	MIOS_PARAMETER2, 0
1004
	return
1005
	;; exit with message if SID player mode enabled and SID1 selected
1006
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
1007
	;; change to Knobs page
1008
	call	CS_MENU_GetMenuID_KNB
1009
	rgoto	CS_MENU_BUTTON_Hlp_MenuChange
1010
 
1011
	;; ------------------------------------------------------------------
1 tk 1012
CS_MENU_BUTTON_PageUp
1013
	;; exit with message if SID player mode enabled and SID1 selected
1014
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
1015
 
1016
	BRA_IFCLR MIOS_PARAMETER2, 0, ACCESS, CS_MENU_BUTTON_PageUp_On
1017
CS_MENU_BUTTON_PageUp_Off
1018
CS_MENU_BUTTON_PageDown_Off
1019
	;; in main menu: request display update and exit
1020
	BRA_IFCLR CS_MENU, 7, ACCESS, CS_MENU_BUTTON_PageDown_NotMain
1021
CS_MENU_BUTTON_PageDown_Main
1022
	bsf	CS_STAT, CS_STAT_DISPLAY_INIT_REQ	; will also clear PAGE_MSG flag
1023
	return
1024
CS_MENU_BUTTON_PageDown_NotMain
1025
	;; disable page message and DISABLE request display update
1026
	bcf	CS_STAT, CS_STAT_PAGE_MSG
1027
	bcf	CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ
1028
	;; clear counter so that cs_menu_timer.inc counts from zero and the message is still visible for a short time
1029
	clrf	CS_CURSOR_CTR
1030
	;; clear "CS_STAT_CURSOR_FLASH" bit (see cs_menu.inc for the handling)
1031
	bcf	CS_STAT, CS_STAT_CURSOR_FLASH
1032
	return
1033
 
1034
CS_MENU_BUTTON_PageUp_On
1035
	;; incrementer in WREG
1036
	movlw	1
1037
	goto	CS_MENU_PageUpDown
1038
 
1039
	;; ------------------------------------------------------------------
1040
CS_MENU_BUTTON_PageDown
1041
	;; exit with message if SID player mode enabled and SID1 selected
1042
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
1043
 
1044
	BRA_IFSET MIOS_PARAMETER2, 0, ACCESS, CS_MENU_BUTTON_PageDown_Off
1045
CS_MENU_BUTTON_PageDown_On
1046
	;; incrementer in WREG
1047
	movlw	-1
1048
	goto	CS_MENU_PageUpDown
1049
 
1050
	;; ------------------------------------------------------------------
1051
CS_MENU_BUTTON_CC_PageUp
1052
	;; Control CC flag if Shift Button *set* (no error)
1053
	;; otherwise Page Up
1054
	GOTO_IFSET CS_MENU_MODE, CS_MENU_MODE_SHIFT_PRESSED, ACCESS, CS_MENU_BUTTON_CC
1055
	rgoto	CS_MENU_BUTTON_PageUp
1056
 
1057
	;; ------------------------------------------------------------------
1058
CS_MENU_BUTTON_Edit_PageDown
1059
	;; Control Edit flag if Shift Button *set* (no error)
1060
	;; otherwise Page Down
1061
	GOTO_IFSET CS_MENU_MODE, CS_MENU_MODE_SHIFT_PRESSED, ACCESS, CS_MENU_BUTTON_Edit
1062
	rgoto	CS_MENU_BUTTON_PageDown
1063
 
1064
	;; ------------------------------------------------------------------
1065
 
1066
CS_MENU_BUTTON_M_Mode
1067
	;; do nothing if button has been depressed
1068
	btfsc	MIOS_PARAMETER2, 0
1069
	return
1070
	;; exit with message if SID player mode enabled and SID1 selected
1071
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
1072
	;; else toggle matrix/meter flag
1073
	btg	CS_MENU_MODE, CS_MENU_MODE_MATRIX_METER
1074
	rgoto	CS_MENU_BUTTON_DisplayUpdateReq
1075
 
1076
CS_MENU_BUTTON_M_O1Ptch
1077
	movlw	0x00
1078
	rgoto	CS_MENU_BUTTON_M_SetCol
1079
CS_MENU_BUTTON_M_O2Ptch
1080
	movlw	0x01
1081
	rgoto	CS_MENU_BUTTON_M_SetCol
1082
CS_MENU_BUTTON_M_O3Ptch
1083
	movlw	0x02
1084
	rgoto	CS_MENU_BUTTON_M_SetCol
1085
CS_MENU_BUTTON_M_O1PW
1086
	movlw	0x03
1087
	rgoto	CS_MENU_BUTTON_M_SetCol
1088
CS_MENU_BUTTON_M_O2PW
1089
	movlw	0x04
1090
	rgoto	CS_MENU_BUTTON_M_SetCol
1091
CS_MENU_BUTTON_M_O3PW
1092
	movlw	0x05
1093
	rgoto	CS_MENU_BUTTON_M_SetCol
1094
CS_MENU_BUTTON_M_Filter
1095
	movlw	0x06
1096
	rgoto	CS_MENU_BUTTON_M_SetCol
1097
CS_MENU_BUTTON_M_Vol
1098
	movlw	0x07
1099
	;; 	rgoto	CS_MENU_BUTTON_M_SetCol
1100
CS_MENU_BUTTON_M_SetCol
1101
	;; store index in CS_MENU_SELECTED_MOD_TARG
1102
	movwf	CS_MENU_SELECTED_MOD_TARG
1103
 
1104
	;; exit with message if SID player mode enabled and SID1 selected
1105
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
1106
 
1107
 
1108
	;; set/clear flag depending on button state
1109
	BRA_IFCLR MIOS_PARAMETER2, 0, ACCESS, CS_MENU_BUTTON_M_SetCol_1
1110
CS_MENU_BUTTON_M_SetCol_0	; button depressed
1111
	movf	CS_MENU_SELECTED_MOD_TARG, W
1112
	call	MIOS_HLP_GetBitANDMask
1113
	andwf	CS_MENU_MATRIX_SELECTED_COL, F
1114
	rgoto	CS_MENU_BUTTON_M_SetCol_End
1115
 
1116
CS_MENU_BUTTON_M_SetCol_1	; button pressed
1117
	;; if one mod target button already pressed: toggle led matrix mode
1118
	movf	CS_MENU_MATRIX_SELECTED_COL, W
1119
	bz	CS_MENU_BUTTON_M_SetCol_1_NoTog
1120
CS_MENU_BUTTON_M_SetCol_1_Tog
1121
	btg	CS_MENU_MODE, CS_MENU_MODE_MATRIX_METER
1122
	;; matrix/meter LEDs needs updating
1123
	call	CS_MENU_BUTTON_DisplayUpdateReq
1124
CS_MENU_BUTTON_M_SetCol_1_NoTog
1125
	;; set flag
1126
	movf	CS_MENU_SELECTED_MOD_TARG, W
1127
	call	MIOS_HLP_GetBitORMask
1128
	iorwf	CS_MENU_MATRIX_SELECTED_COL, F
1129
 
1130
	;; branch depending on engine
1131
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
1132
	BRA_IFSET WREG, 1, ACCESS, CS_MENU_BUTTON_M_SetCol_1_DM
1133
CS_MENU_BUTTON_M_SetCol_1_LB
1134
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_BUTTON_M_SetCol_1_B
1135
 
1136
CS_MENU_BUTTON_M_SetCol_1_L
1137
	;; init flash counter
1138
	clrf	CS_MENU_MATRIX_FLASH_CTR
1139
 
1140
	;; if row is selected:
1141
	movf	CS_MENU_SELECTED_MOD_SRC, W
1142
	call	MIOS_HLP_GetBitORMask
1143
	andwf	CS_MENU_MATRIX_SELECTED_ROW, W
1144
	bz	CS_MENU_BUTTON_M_SetCol_NoTog
1145
	;; toggle modmatrix entry
1146
	;; expecting bit number in CS_MENU_SELECTED_MOD_SRC, modulation target in CS_MENU_SELECTED_MOD_TARG
1147
CS_MENU_BUTTON_M_SetCol_Tog
1148
	movff	CS_MENU_SELECTED_MOD_SRC, CS_MENU_SELECTED_MOD
1149
	movf	CS_MENU_SELECTED_MOD_TARG, W
1150
	rcall	CS_MENU_BUTTON_ToggleMODFlag
1151
CS_MENU_BUTTON_M_SetCol_NoTog
1152
 
1153
CS_MENU_BUTTON_M_SetCol_End
1154
	return
1155
 
1156
 
1157
CS_MENU_BUTTON_M_SetCol_1_B
1158
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_B_S1V1_BASE + SID_Ix_B_Vx_SEQ_NUM
1230 tk 1159
	;; special handling: if same sequence already selected, disable it
1160
	movf	CS_MENU_SELECTED_MOD_TARG, W
1161
	xorwf	INDF0, W
1162
	bnz	CS_MENU_BUTTON_M_SetCol_1_B_NotEq
1163
	movlw	0x08
1164
	movwf	INDF0
1165
	rgoto	CS_MENU_BUTTON_M_SetCol_1_B_Eq
1166
CS_MENU_BUTTON_M_SetCol_1_B_NotEq
1 tk 1167
	movff	CS_MENU_SELECTED_MOD_TARG, INDF0
1230 tk 1168
CS_MENU_BUTTON_M_SetCol_1_B_Eq
1 tk 1169
	call	CS_MENU_MS_SendParameter
1170
	;; change sequence (don't switch to SEQ menu, this disturbs the useflow)
1171
	movff	CS_MENU_SELECTED_MOD_TARG, CS_MENU_WT_SEQ
1172
	rgoto	CS_MENU_BUTTON_DisplayUpdateReq
1173
 
1174
 
1175
CS_MENU_BUTTON_M_SetCol_1_DM
1176
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_BUTTON_M_SetCol_1_M
1177
CS_MENU_BUTTON_M_SetCol_1_D
1178
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_D_SEQ_NUM
1230 tk 1179
	;; special handling: if same sequence already selected, disable it
1180
	movf	CS_MENU_SELECTED_MOD_TARG, W
1181
	xorwf	INDF0, W
1182
	bnz	CS_MENU_BUTTON_M_SetCol_1_D_NotEq
1183
	movlw	0x08
1184
	movwf	INDF0
1185
	rgoto	CS_MENU_BUTTON_M_SetCol_1_D_Eq
1186
CS_MENU_BUTTON_M_SetCol_1_D_NotEq
1 tk 1187
	movff	CS_MENU_SELECTED_MOD_TARG, INDF0
1230 tk 1188
CS_MENU_BUTTON_M_SetCol_1_D_Eq
1 tk 1189
	call	CS_MENU_MS_SendParameter
1190
	;; change sequence
1191
	movff	CS_MENU_SELECTED_MOD_TARG, CS_MENU_WT_SEQ
1192
	rgoto	CS_MENU_BUTTON_DisplayUpdateReq
1193
	return
1194
 
1195
CS_MENU_BUTTON_M_SetCol_1_M
1196
	;; TODO: not implemented yet
1197
	return
1198
 
1199
 
1200
	;; ------------------------------------------------------------------
1201
CS_MENU_BUTTON_M_E1
1202
	movlw	0x00
1203
	rgoto	CS_MENU_BUTTON_M_SetRow
1204
CS_MENU_BUTTON_M_E2
1205
	movlw	0x01
1206
	rgoto	CS_MENU_BUTTON_M_SetRow
1207
CS_MENU_BUTTON_M_L1
1208
	movlw	0x02
1209
	rgoto	CS_MENU_BUTTON_M_SetRow
1210
CS_MENU_BUTTON_M_L2
1211
	movlw	0x03
1212
	rgoto	CS_MENU_BUTTON_M_SetRow
1213
CS_MENU_BUTTON_M_L3
1214
	movlw	0x04
1215
	rgoto	CS_MENU_BUTTON_M_SetRow
1216
CS_MENU_BUTTON_M_L4
1217
	movlw	0x05
1218
	rgoto	CS_MENU_BUTTON_M_SetRow
1219
CS_MENU_BUTTON_M_L5
1220
	movlw	0x06
1221
	rgoto	CS_MENU_BUTTON_M_SetRow
1222
CS_MENU_BUTTON_M_L6
1223
	movlw	0x07
1224
	;; 	rgoto	CS_MENU_BUTTON_M_SetRow
1225
CS_MENU_BUTTON_M_SetRow
1226
	;; set/clear flag depending on button state
1227
	BRA_IFCLR MIOS_PARAMETER2, 0, ACCESS, CS_MENU_BUTTON_M_SetRow_1
1228
CS_MENU_BUTTON_M_SetRow_0	; button depressed
1229
	call	MIOS_HLP_GetBitANDMask
1230
	andwf	CS_MENU_MATRIX_SELECTED_ROW, F
1231
	return
1232
 
1233
CS_MENU_BUTTON_M_SetRow_1	; button pressed
1234
	;; store index in CS_MENU_SELECTED_MOD_SRC and CS_MENU_SELECTED_MOD
1235
	movwf	CS_MENU_SELECTED_MOD_SRC
1236
	movwf	CS_MENU_SELECTED_MOD
1237
 
1238
	;; exit with message if SID player mode enabled and SID1 selected
1239
	BRA_IFSET SID_STAT, SID_STAT_SIDPLAYER_CS_DISABLE, ACCESS, CS_MENU_BUTTON_SP_IgnoreMsg
1240
 
1241
	;; branch depending on engine
1242
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
1243
	BRA_IFSET WREG, 1, ACCESS, CS_MENU_BUTTON_M_SetRow_DM
1244
CS_MENU_BUTTON_M_SetRow_LB
1245
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_BUTTON_M_SetRow_B
1246
 
1247
CS_MENU_BUTTON_M_SetRow_L
1248
	;; set flag
1249
	movf	CS_MENU_SELECTED_MOD, W
1250
	call	MIOS_HLP_GetBitORMask
1251
	iorwf	CS_MENU_MATRIX_SELECTED_ROW, F
1252
 
1253
	;; init flash counter
1254
	clrf	CS_MENU_MATRIX_FLASH_CTR
1255
 
1256
	;; if column is selected:
1257
	movf	CS_MENU_SELECTED_MOD_TARG, W
1258
	call	MIOS_HLP_GetBitORMask
1259
	andwf	CS_MENU_MATRIX_SELECTED_COL, W
1260
	bz	CS_MENU_BUTTON_Chg_NoTog
1261
	;; toggle modmatrix entry
1262
	;; expecting bit number in CS_MENU_SELECTED_TARG, modulation target in CS_MENU_SELECTED_MOD
1263
CS_MENU_BUTTON_Chg_Tog
1264
	movf	CS_MENU_SELECTED_MOD_TARG, W
1265
	rcall	CS_MENU_BUTTON_ToggleMODFlag
1266
CS_MENU_BUTTON_Chg_NoTog
1267
 
1268
	;; if shift function is active, use the buttons to switch into ENV/LFO page
1269
	;; otherwise switch into MOD page
1270
	BRA_IFSET CS_MENU_MODE, CS_MENU_MODE_SHIFT_PRESSED, ACCESS, CS_MENU_BUTTON_M_EorLPage
1271
 
1272
CS_MENU_BUTTON_M_ModPage
1273
	;; change to MOD page
1274
	call	CS_MENU_GetMenuID_MOD
1275
	rgoto	CS_MENU_BUTTON_Hlp_MenuChange
1276
 
1277
 
1278
CS_MENU_BUTTON_M_EorLPage
296 tk 1279
	;; disable SHIFT menu (for combined shift/CFG button)
1280
	bcf	CS_STAT3, CS_STAT3_SHIFT_PAGE
1 tk 1281
 
1282
	;; select new menu depending on mod button
1283
	movf	CS_MENU_SELECTED_MOD_SRC, W
1284
	andlw	0xfe
1285
	bz	CS_MENU_BUTTON_Chg_Ex
1286
	rgoto	CS_MENU_BUTTON_Chg_Lx
1287
 
1288
CS_MENU_BUTTON_Chg_Ex
1289
	;; change to ENV menu
1290
	movf	CS_MENU_SELECTED_MOD_SRC, W
1291
	movwf	CS_MENU_SELECTED_ENV
1292
	call	CS_MENU_GetMenuID_ENV	; menu page
1293
	rgoto	CS_MENU_BUTTON_Hlp_MenuChange
1294
 
1295
CS_MENU_BUTTON_Chg_Lx
1296
	;; change to LFO menu
1297
	movf	CS_MENU_SELECTED_MOD_SRC, W
1298
	addlw	-2
1299
	movwf	CS_MENU_SELECTED_LFO
1300
	call	CS_MENU_GetMenuID_LFO	; menu page
1301
	rgoto	CS_MENU_BUTTON_Hlp_MenuChange
1302
 
1303
 
1304
CS_MENU_BUTTON_M_SetRow_B
1305
	lfsr	FSR0, SID_EDIT_BUFFER + SID_Ix_B_S2V1_BASE + SID_Ix_B_Vx_SEQ_NUM
1230 tk 1306
	;; special handling: if same sequence already selected, disable it
1307
	movf	CS_MENU_SELECTED_MOD_SRC, W
1308
	xorwf	INDF0, W
1309
	bnz	CS_MENU_BUTTON_M_SetRow_B_NotEq
1310
	movlw	0x08
1311
	movwf	INDF0
1312
	rgoto	CS_MENU_BUTTON_M_SetRow_B_Eq
1313
CS_MENU_BUTTON_M_SetRow_B_NotEq
1 tk 1314
	movff	CS_MENU_SELECTED_MOD_SRC, INDF0
1230 tk 1315
CS_MENU_BUTTON_M_SetRow_B_Eq
1 tk 1316
	call	CS_MENU_MS_SendParameter
1317
	;; change sequence (don't switch to SEQ menu, this disturbs the useflow)
1318
	movff	CS_MENU_SELECTED_MOD_SRC, CS_MENU_WT_SEQ
1319
	rgoto	CS_MENU_BUTTON_DisplayUpdateReq
1320
 
1321
 
1322
CS_MENU_BUTTON_M_SetRow_DM
1323
	BRA_IFSET WREG, 0, ACCESS, CS_MENU_BUTTON_M_SetRow_M
1324
CS_MENU_BUTTON_M_SetRow_D
1325
	;; select track depending on button
1326
	movff	CS_MENU_SELECTED_MOD, CS_MENU_SELECTED_TRK
1327
	;; first change to SEQ page
1328
	movlw	CS_MENU_D_SEQ
1329
	rcall	CS_MENU_BUTTON_Hlp_MenuChange
1330
	;; now change to edit sequence page
1331
	;; DIRTY: ensure that cursor pos and page offset are selected the EDT menu entry
1332
	movlw	2
1333
	movwf	CS_MENU_CURSOR_POS
1334
	clrf	CS_MENU_PAGE_OFFSET
1335
	goto	CS_MENU_EXEC_EditSeq
1336
 
1337
CS_MENU_BUTTON_M_SetRow_M
1338
	;; TODO: not implemented yet
1339
	return
1340
 
1341
	;; ------------------------------------------------------------------
1342
CS_MENU_BUTTON_Hlp_MenuChange
1343
	;; don't change if already in menu (only update screen)
1344
	cpfseq	CS_MENU, ACCESS
1345
	rgoto CS_MENU_BUTTON_Hlp_MenuChangeOk
368 tk 1346
#if DEFAULT_LCD_LINES >= 3
1347
	call	CS_MENU_UpdateLabel		; update menu label
1348
#endif
1 tk 1349
	rgoto	CS_MENU_BUTTON_DisplayUpdateReq
1350
 
1351
CS_MENU_BUTTON_Hlp_MenuChangeOk
1352
	;; init menu page
1353
	movwf	CS_MENU
1354
	clrf	CS_MENU_CURSOR_POS
1355
	clrf	CS_MENU_PAGE_OFFSET
1356
	call	CS_MENU_Page_Init
1357
 
1358
	;; deselect parameter
1359
	bsf	CS_STAT, CS_STAT_MODIFY_PARAMETER
1360
	call	CS_MENU_EXEC_Hlp_ChangeMenu
1361
 
1362
	;; rgoto	CS_MENU_BUTTON_DisplayUpdateReq
1363
 
1364
CS_MENU_BUTTON_DisplayUpdateReq
1365
	;; force a display update and exit
1366
	bsf	CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ
1367
	return
1368
 
1369
	;; ------------------------------------------------------------------
1370
CS_MENU_BUTTON_ToggleMODFlag
1371
	;; IN: bit number in WREG, modulation target in CS_MENU_SELECTED_MOD
1372
 
1373
	;; force a display update
1374
	bsf	CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ
1375
 
1376
	;; store target number in CS_MENU_PARAMETER_IX
1377
	movwf	CS_MENU_PARAMETER_IX
1378
 
1379
	;; get current value -> CS_MENU_PARAMETER_L
1380
	lfsr	FSR0, SID_EDIT_BUFFER
1381
	call	CS_MENU_R2P_MODx_Nx
1382
 
653 tk 1383
	;; toggle depending on L/R SID
1 tk 1384
	movf	CS_MENU_SELECTED_SID_LR, W
1385
	xorwf	CS_MENU_PARAMETER_L, F
1386
 
653 tk 1387
	;; transfer too all selected SIDs
1388
	clrf	CS_MENU_SID
1389
CS_MENU_BUTTON_ToggleMODFlagLoop
1390
	movf	CS_MENU_SID, W
1391
	call	MIOS_HLP_GetBitORMask
1392
	andwf	CS_MENU_SELECTED_SID_FLAGS, W
1393
	bz	CS_MENU_BUTTON_ToggleMODFlagNext
1 tk 1394
	lfsr	FSR0, SID_EDIT_BUFFER
653 tk 1395
	call	CS_MENU_P2R_MODx_Nx
1396
CS_MENU_BUTTON_ToggleMODFlagNext
1397
	incf	CS_MENU_SID, F
1398
	BRA_IFCLR CS_MENU_SID, 2, ACCESS, CS_MENU_BUTTON_ToggleMODFlagLoop
1399
	return
1 tk 1400
 
1401
;; ------------------------------------------------------------------
1402
CS_MENU_BUTTON_SP_IgnoreMsg
1403
	;; message print when SID1 selected and SIDplayer active
1404
	goto	SIDPLAY_NoCSMessage
1405