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: sid_patch.inc 44 2008-01-30 21:39:30Z tk $
1 tk 2
;
3
; SID Patch routines
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
;;  Init Routine for patch parameters
15
;;  IN: patch in SID_PATCH_BUFFER(_SHADOW)
16
;; --------------------------------------------------------------------------
17
SID_PATCH_Init
18
	;; disable SID engine
19
	bsf	SID_STAT, SID_STAT_ENGINE_DISABLE
20
 
21
	;; clear the whole SID SFR memory space
22
	movlw	SIDSE_CLEAR_128B_BLOCKS
23
	movwf	TABLAT
24
	lfsr	FSR0, SIDSE_CLEAR_BEGIN
25
SID_PATCH_Init_ClearLoop
26
	clrf	POSTINC0
27
	movf	FSR0L, W
28
	andlw	0x7f
29
	bnz	SID_PATCH_Init_ClearLoop
30
	decfsz	TABLAT, F
31
	rgoto	SID_PATCH_Init_ClearLoop
32
 
33
	;; clear non-active notes
34
	lfsr	FSR2, SID_MV1_BASE + SID_MVx_NOTE_STACK_0
35
	call	SID_MIDI_Hlp_ClrNonActive
36
	lfsr	FSR2, SID_MV2_BASE + SID_MVx_NOTE_STACK_0
37
	call	SID_MIDI_Hlp_ClrNonActive
38
	lfsr	FSR2, SID_MV3_BASE + SID_MVx_NOTE_STACK_0
39
	call	SID_MIDI_Hlp_ClrNonActive
40
	lfsr	FSR2, SID_MV4_BASE + SID_MVx_NOTE_STACK_0
41
	call	SID_MIDI_Hlp_ClrNonActive
42
	lfsr	FSR2, SID_MV5_BASE + SID_MVx_NOTE_STACK_0
43
	call	SID_MIDI_Hlp_ClrNonActive
44
	lfsr	FSR2, SID_MV6_BASE + SID_MVx_NOTE_STACK_0
45
	call	SID_MIDI_Hlp_ClrNonActive
46
 
47
	;; clear parts of the MIDI voices
48
	clrf	TABLAT
49
SID_PATCH_Init_ClearMVLoop
50
	lfsr	FSR0, SID_MV1_BASE
51
	movf	TABLAT, W
52
	mullw	SID_MVx_RECORD_LEN
53
	movf	PRODL, W
54
	addlw	SID_MVx_PITCHBENDER
55
	addwf	FSR0L, F
56
 
57
	;; clear variable area
58
	movlw	(SID_MVx_WT_STACK_0-1)-SID_MVx_PITCHBENDER+1
59
	movwf	PRODL
60
SID_PATCH_Init_ClearMVLoop_I1
61
	clrf	POSTINC0
62
	decfsz	PRODL, F
63
	rgoto	SID_PATCH_Init_ClearMVLoop_I1
64
 
65
 
66
	;; clear note stack if new engine != old engine
67
	SET_BSR	SID_PATCH_BUFFER + SID_Ix_ENGINE
68
	movf	SID_PATCH_BUFFER + SID_Ix_ENGINE, W, BANKED
69
	SET_BSR	SID_PATCH_BUFFER_SHADOW + SID_Ix_ENGINE
70
	xorwf	SID_PATCH_BUFFER_SHADOW + SID_Ix_ENGINE, W, BANKED
71
	andlw	0x03
72
	bz	SID_PATCH_Init_ClearMVLoop_Next
73
 
74
	;; clear sustain flags
75
	clrf	SID_MIDIVOICE_SUSTAIN, BANKED
76
 
77
	;; clear note stack (+ptr)
78
	movlw	SID_MVx_NOTE_STACK_LEN + 1
79
	movwf	PRODL
80
SID_PATCH_Init_ClearMVLoop_I2
81
	clrf	POSTINC0
82
	decfsz	PRODL, F
83
	rgoto	SID_PATCH_Init_ClearMVLoop_I2
84
 
85
SID_PATCH_Init_ClearMVLoop_Next
86
	incf	TABLAT, F
87
	movlw	SID_MVx_NUM-1
88
	cpfsgt	TABLAT, ACCESS
89
	rgoto SID_PATCH_Init_ClearMVLoop
90
	SET_BSR	SID_BASE
91
 
92
 
93
	;; transfer patch buffer to shadow buffer
94
	lfsr	FSR0, SID_PATCH_BUFFER
95
	lfsr	FSR1, SID_PATCH_BUFFER_SHADOW
96
	movlw	2
97
	movwf	PRODL
98
SID_PATCH_Init_CopyLoop
99
	movff	POSTINC0, POSTINC1
100
	movf	FSR0L, W
101
	bnz	SID_PATCH_Init_CopyLoop
102
	decfsz	PRODL, F
103
	rgoto	SID_PATCH_Init_CopyLoop
104
 
105
#if 0	; disabled - could cause confusion! see also comment on bassline knob function issues at the end of the ChangeLog
106
	;; update knob values
107
	call	SID_KNOB_UpdateAll
108
#endif
109
 
110
	;; already set volume and filter values to right value to avoid crackling sound in some cases
111
	;; doesn't prevent crackle if filter channels/mode are switched between two patterns!
112
	;; note: I tried a slow fade-in of volume, but this leads to even worse
113
	;; results since volume influences the offset voltage at the audio output
114
 
115
	;; works for all engines so long it is ensured, that filters are located at same patch position
116
	IRQ_DISABLE
117
	clrf	SID_SE_ELEMENT_NUM, BANKED
118
	lfsr	FSR0, SID_PATCH_BUFFER_SHADOW + SID_Ix_L_S1F_BASE
119
	lfsr	FSR1, SID_MOD_TARG_FIL1_L
120
	lfsr	FSR2, SIDL_BASE
121
	call	SIDSE_Filter
122
 
123
	incf	SID_SE_ELEMENT_NUM, F, BANKED
124
	lfsr	FSR0, SID_PATCH_BUFFER_SHADOW + SID_Ix_L_S2F_BASE
125
	lfsr	FSR1, SID_MOD_TARG_FIL2_L
126
	lfsr	FSR2, SIDR_BASE
127
	call	SIDSE_Filter
128
	IRQ_ENABLE
129
 
130
	;; force a refresh of all registers
131
 	call	SID_SR_Refresh
132
 
133
	;; clear voice queue
134
	call	SID_VOICE_Init
135
 
136
	;; if a note was played during patch change, play it again
137
	;; works only with lead engine when superpoly not enabled
138
	movff	SID_PATCH_BUFFER_SHADOW + SID_Ix_ENGINE, WREG
139
	andlw	0x03
140
	bnz	SID_PATCH_Init_NoNote
141
	movff	SID_LOCAL_ENS + SID_ENSx_SUPERPOLY_CTRL, WREG
142
	andlw	0x07
143
	bnz	SID_PATCH_Init_NoNote
144
	SET_BSR	SID_BASE
145
	lfsr	FSR0, SID_MV1_BASE
146
	movlw	SID_MVx_NOTE_STACK_PTR
147
	movf	PLUSW0, W
148
	bz	SID_PATCH_Init_NoNote
149
SID_PATCH_Init_PlayNoteAgain
150
 
151
	;; 	lfsr	FSR0, SID_MV1_BASE  ; (already in FSR0)
152
	lfsr	FSR1, SIDL_V1_BASE
153
	clrf	SID_CURRENT_VOICE, BANKED
154
SID_PATCH_Init_PlayNoteAgainLoop
155
	movlw	SID_MVx_NOTE_STACK_0
156
	movf	PLUSW0, W
157
	andlw	0x7f
158
	movwf	SID_MIDI_PARAMETER1, BANKED	; note number
159
	movlw	0x64
160
	movwf	SID_MIDI_PARAMETER2, BANKED	; velocity
161
	call	SID_MIDI_L_Hlp_NoteOn
162
 
163
	movlw	SID_MVx_RECORD_LEN
164
	addwf	FSR0L, F
165
	movlw	SID_Vx_RECORD_LEN
166
	addwf	FSR1L, F
167
	incf	SID_CURRENT_VOICE, F, BANKED
168
	movlw	SID_Vx_NUM - 1
169
	cpfsgt	SID_CURRENT_VOICE, BANKED
170
	rgoto SID_PATCH_Init_PlayNoteAgainLoop
171
SID_PATCH_Init_NoNote
172
 
173
	;; LFOs should start with random offset (for best freerunning results - especially in multi mode)
174
	lfsr	FSR1, SID_LFO1_BASE
175
	movlw	SID_LFOx_NUM
176
	movwf	TABLAT		; using TABLAT as counter
177
SID_PATCH_Init_LFO_Loop
178
	call	SID_RND_GenRandomNumber
179
	movff	SID_RANDOM_SEED_L, POSTINC1
180
	movff	SID_RANDOM_SEED_H, POSTDEC1
181
	movlw	SID_LFOx_RECORD_LEN
182
	addwf	FSR1L, F
183
	decfsz	TABLAT, F
184
	rgoto	SID_PATCH_Init_LFO_Loop
185
 
186
 
187
	;; enable SID engine again
188
	bcf	SID_STAT, SID_STAT_ENGINE_DISABLE
189
 
190
	return
191
 
192
 
193
;; --------------------------------------------------------------------------
194
;;  This routine plays a note on all selected instruments (depends on engine)
195
;;  IN: current instrument number in CS_MENU_SELECTED_INS (used for multi and drum engine)
196
;;      selected SID flags (L/R) in CS_MENU_SELECTED_SID_LR
197
;;
198
;;      If function is called via MBNet (-> SID_MBNET_RxSpecial_NON), the
199
;;      variables have to be set from there!
200
;; --------------------------------------------------------------------------
201
SID_PATCH_NotesOn
202
	;; branch depending on engine
203
	movff	SID_PATCH_BUFFER_SHADOW + SID_Ix_ENGINE, WREG
204
	BRA_IFSET WREG, 1, ACCESS, SID_PATCH_NotesOn_DM
205
SID_PATCH_NotesOn_LB
206
	BRA_IFSET WREG, 0, ACCESS, SID_PATCH_NotesOn_B
207
SID_PATCH_NotesOn_L
208
	;; only single instrument
209
	movlw	0
210
	rgoto	SID_PATCH_NotesOn_Hlp
211
 
212
SID_PATCH_NotesOn_B
213
	;; the selected instruments
214
	;; note or sequence number is selected inside help function
215
	movlw	0
216
	RCALL_IFSET CS_MENU_SELECTED_SID_LR, 0, ACCESS, SID_PATCH_NotesOn_Hlp
217
	movlw	1
218
	RCALL_IFSET CS_MENU_SELECTED_SID_LR, 1, ACCESS, SID_PATCH_NotesOn_Hlp
219
	return
220
 
221
SID_PATCH_NotesOn_DM
222
	BRA_IFSET WREG, 0, ACCESS, SID_PATCH_NotesOn_M
223
SID_PATCH_NotesOn_D
224
	;; one instrument
225
	;; note or sequence number is selected inside help function
226
	movlw	0
227
	rcall	SID_PATCH_NotesOn_Hlp
228
	return
229
 
230
SID_PATCH_NotesOn_M
231
	;; selected instrument
232
	movf	CS_MENU_SELECTED_INS, W
233
	;; 	rgoto	SID_PATCH_NotesOn_Hlp
234
 
235
 
236
SID_PATCH_NotesOn_Hlp
237
	;; temporary store instrument number in MIOS_PARAMETER3
238
	movwf	MIOS_PARAMETER3
239
 
240
	;; determine pointer to MIDI voice
241
	lfsr	FSR1, SID_MV1_BASE
242
	mullw	SID_MVx_RECORD_LEN
243
	movf	PRODL, W
244
	addwf	FSR1L, F
245
 
246
	;; exit if MIDI voice disabled (channel > 16)
247
	movlw	SID_MVx_MIDI_CHANNEL
248
	movf	PLUSW1, W
249
	movwf	MIOS_PARAMETER1
250
	andlw	0xf0
251
	bnz	SID_PATCH_NotesOn_Hlp_End
252
 
253
	movlw	0x90		; MIDI note
254
	iorwf	MIOS_PARAMETER1, F
255
 
256
	movlw	0x3c		; C-4
257
	movwf	MIOS_PARAMETER2
258
 
259
	;; increase if split point is higher
260
	movlw	SID_MVx_SPLIT_LOWER
261
	movf	PLUSW1, W
262
	cpfsgt	MIOS_PARAMETER2, ACCESS
263
	movwf MIOS_PARAMETER2
264
 
265
	;; branch depending on engine
266
	movff	SID_PATCH_BUFFER_SHADOW + SID_Ix_ENGINE, WREG
267
	BRA_IFSET WREG, 1, ACCESS, SID_PATCH_NotesOn_Hlp_DM
268
SID_PATCH_NotesOn_Hlp_LB
269
	BRA_IFSET WREG, 0, ACCESS, SID_PATCH_NotesOn_Hlp_B
270
SID_PATCH_NotesOn_Hlp_L
271
	;; no additional measure
272
	rgoto	SID_PATCH_NotesOn_Hlp_Cont
273
 
274
SID_PATCH_NotesOn_Hlp_B
275
	;; don't increase note number if sequencer disabled
276
	movff	SID_PATCH_BUFFER_SHADOW + SID_Ix_B_S1V1_BASE + SID_Ix_B_Vx_FLAGS2, WREG
277
	btfsc	MIOS_PARAMETER3, 0
278
	movff	SID_PATCH_BUFFER_SHADOW + SID_Ix_B_S2V1_BASE + SID_Ix_B_Vx_FLAGS2, WREG
279
	BRA_IFCLR WREG, SID_I_B_V_FLAGS2_WT_ONLY, ACCESS, SID_PATCH_NotesOn_Hlp_Cont
280
 
281
	;; select sequence
282
	movff	SID_PATCH_BUFFER_SHADOW + SID_Ix_B_S1V1_BASE + SID_Ix_B_Vx_SEQ_NUM, WREG
283
	btfsc	MIOS_PARAMETER3, 0
284
	movff	SID_PATCH_BUFFER_SHADOW + SID_Ix_B_S2V1_BASE + SID_Ix_B_Vx_SEQ_NUM, WREG
285
	andlw	0x07	; if sequence disabled, start with first (8 -> 0)
286
	addwf	MIOS_PARAMETER2, F
287
	rgoto	SID_PATCH_NotesOn_Hlp_Cont
288
 
289
SID_PATCH_NotesOn_Hlp_DM
290
	BRA_IFSET WREG, 0, ACCESS, SID_PATCH_NotesOn_Hlp_M
291
SID_PATCH_NotesOn_Hlp_D
292
	;; sequencer enabled?
293
	movff	SID_PATCH_BUFFER_SHADOW + SID_Ix_D_SEQ_SPEED, WREG
294
	BRA_IFCLR WREG, SID_I_V_SEQ_ON, ACCESS, SID_PATCH_NotesOn_Hlp_D_NoSeq
295
SID_PATCH_NotesOn_Hlp_D_Seq
296
	;; select sequence
297
	movff	SID_PATCH_BUFFER_SHADOW + SID_Ix_D_SEQ_NUM, WREG
298
	andlw	0x07	; if sequence disabled, start with first (8 -> 0)
299
	addwf	MIOS_PARAMETER2, F
300
	rgoto	SID_PATCH_NotesOn_Hlp_Cont
301
 
302
SID_PATCH_NotesOn_Hlp_D_NoSeq
303
	;; add instrument number to note
304
	movf	CS_MENU_SELECTED_INS, W
305
	addlw	0x0c		; +1 octave
306
	addwf	MIOS_PARAMETER2, F
307
	rgoto	SID_PATCH_NotesOn_Hlp_Cont
308
 
309
SID_PATCH_NotesOn_Hlp_M
310
	;; no additional measure
311
	;; 	rgoto	SID_PATCH_NotesOn_Hlp_Cont
312
 
313
SID_PATCH_NotesOn_Hlp_Cont
314
	movlw	0x40		; mid velocity
315
	movwf	MIOS_PARAMETER3
316
 
317
	;; forward MIDI event
318
	call	SID_MIDI_NotifyReceivedEvent
319
 
320
SID_PATCH_NotesOn_Hlp_End
321
	return
322
 
323
 
324
;; --------------------------------------------------------------------------
325
;;  This routine disables all notes, stops the arp and WT
326
;; --------------------------------------------------------------------------
327
SID_PATCH_NotesOff
328
	IRQ_DISABLE
329
 
330
	;; if drum engine:
331
	movff	SID_PATCH_BUFFER_SHADOW + SID_Ix_ENGINE, WREG
332
	andlw	0x03
333
	xorlw	0x02
334
	bnz	SID_PATCH_NotesOff_NoDrums
335
SID_PATCH_NotesOff_Drums
336
	;; request note off for all voices
337
	clrf	SID_CURRENT_MIDIVOICE, BANKED
338
  	call	SID_SE_D_NoteOff
339
	rgoto	SID_PATCH_NotesOff_Drums_Cont
340
 
341
SID_PATCH_NotesOff_NoDrums
342
	;; disable voices
343
	SET_BSR	SID_BASE
344
	lfsr	FSR1, SIDL_V1_BASE
345
	clrf	SID_CURRENT_VOICE, BANKED
346
SID_PATCH_NotesOff_DisVLoop
347
	movlw	SID_Vx_STATE
348
	bcf	PLUSW1, SID_V_STATE_VOICE_ACTIVE
349
	bcf	PLUSW1, SID_V_STATE_GATE_SET_REQ
350
	bsf	PLUSW1, SID_V_STATE_GATE_CLR_REQ
351
 
352
	movlw	SID_Vx_RECORD_LEN
353
	addwf	FSR1L, F
354
	incf	SID_CURRENT_VOICE, F, BANKED
355
	movlw	SID_Vx_NUM - 1
356
	cpfsgt	SID_CURRENT_VOICE, BANKED
357
	rgoto SID_PATCH_NotesOff_DisVLoop
358
 
359
SID_PATCH_NotesOff_Drums_Cont
360
	;; clear all runtime variables of MIDI voices
361
	clrf	TABLAT
362
SID_PATCH_NotesOff_ClearMVLoopO
363
	lfsr	FSR0, SID_MV1_BASE
364
	movf	TABLAT, W
365
	mullw	SID_MVx_RECORD_LEN
366
	movf	PRODL, W
367
	addlw	SID_MVx_PITCHBENDER
368
	addwf	FSR0L, F
369
 
370
	;; clear variable area
371
	movlw	SID_MVx_RECORD_LEN-SID_MVx_PITCHBENDER
372
	movwf	PRODL
373
SID_PATCH_NotesOff_ClearMVLoopI
374
	clrf	POSTINC0
375
	decfsz	PRODL, F
376
	rgoto	SID_PATCH_NotesOff_ClearMVLoopI
377
 
378
	incf	TABLAT, F
379
	movlw	SID_MVx_NUM-1
380
	cpfsgt	TABLAT, ACCESS
381
	rgoto SID_PATCH_NotesOff_ClearMVLoopO
382
 
383
	;; clear all sustain flags
384
	clrf	SID_MIDIVOICE_SUSTAIN, BANKED
385
 
386
	;; clear sequencer running flag
387
	SET_BSR	SID_SEQ1_BASE
388
	bcf	SID_SEQ1_BASE + SID_SEQx_MISC, SID_SEQ_MISC_SEQ_RUNNING, BANKED
389
	bcf	SID_SEQ2_BASE + SID_SEQx_MISC, SID_SEQ_MISC_SEQ_RUNNING, BANKED
390
	SET_BSR	SID_BASE
391
 
392
	IRQ_ENABLE
393
 
394
	return
395
 
396
 
397
;; --------------------------------------------------------------------------
398
;;  This routine transfers the patch buffer into the shadow buffer
399
;; --------------------------------------------------------------------------
400
SID_PATCH_UpdateShadowBuffer
401
	movlw	2
402
	movwf	PRODL
403
	lfsr	FSR0, SID_PATCH_BUFFER
404
	lfsr	FSR1, SID_PATCH_BUFFER_SHADOW
405
SID_PATCH_UpdateShadowBufferLoop
406
	movff	POSTINC0, POSTINC1
407
	movf	FSR0L, W
408
	bnz	SID_PATCH_UpdateShadowBufferLoop
409
	decfsz	PRODL, F
410
	rgoto	SID_PATCH_UpdateShadowBufferLoop
411
 
412
	;; special measure for pitchbender: since it is not part of the shadow buffer, we should clear it here
413
	;; for non-destructive knob assignment changes
414
	SET_BSR	SID_MV1_BASE
415
	clrf	SID_MV1_BASE + SID_MVx_PITCHBENDER, BANKED
416
	clrf	SID_MV2_BASE + SID_MVx_PITCHBENDER, BANKED
417
	clrf	SID_MV3_BASE + SID_MVx_PITCHBENDER, BANKED
418
	clrf	SID_MV4_BASE + SID_MVx_PITCHBENDER, BANKED
419
	clrf	SID_MV5_BASE + SID_MVx_PITCHBENDER, BANKED
420
	clrf	SID_MV6_BASE + SID_MVx_PITCHBENDER, BANKED
421
 
422
	SET_BSR	SIDL_V1_BASE
423
	clrf	SIDL_V1_BASE + SID_Vx_PITCHBENDER, BANKED
424
	clrf	SIDL_V2_BASE + SID_Vx_PITCHBENDER, BANKED
425
	clrf	SIDL_V3_BASE + SID_Vx_PITCHBENDER, BANKED
426
	clrf	SIDR_V1_BASE + SID_Vx_PITCHBENDER, BANKED
427
	clrf	SIDR_V2_BASE + SID_Vx_PITCHBENDER, BANKED
428
	clrf	SIDR_V3_BASE + SID_Vx_PITCHBENDER, BANKED
429
 
430
	;; update all knob values
431
	goto	SID_KNOB_UpdateAll
432
 
433
 
434
;; --------------------------------------------------------------------------
435
;;  This routine transfers the patch buffer into the edit buffer if the
436
;;  master SID is selected in the CS
437
;; --------------------------------------------------------------------------
438
SID_PATCH_UpdateEditBuffer
439
	;; copy into edit buffer if SID is selected
440
	movf	CS_MENU_EDIT_BUFFER_SID, W
441
	cpfseq	CS_MENU_SID, ACCESS
442
	rgoto SID_PATCH_UpdateEditBuffer_End
443
	movlw	2
444
	movwf	PRODL
445
	lfsr	FSR0, SID_PATCH_BUFFER
446
	lfsr	FSR1, SID_EDIT_BUFFER
447
SID_PATCH_UpdateEditBufferLoop
448
	movff	POSTINC0, POSTINC1
449
	movf	FSR0L, W
450
	bnz	SID_PATCH_UpdateEditBufferLoop
451
	decfsz	PRODL, F
452
	rgoto	SID_PATCH_UpdateEditBufferLoop
453
SID_PATCH_UpdateEditBuffer_End
454
	return
455
 
456
;; --------------------------------------------------------------------------
457
;;  This routine loads the EEPROM/BankStick content into the SID Patch Buffer
458
;;  and initialises the patch
459
;;  IN: Patch in SID_BANK/SID_PATCH
460
;; --------------------------------------------------------------------------
461
SID_PATCH_LoadPatchBuffer
462
	clrf	EEADR
463
	clrf	EEADRH
464
	lfsr	FSR1, SID_PATCH_BUFFER
465
SID_PATCH_LoadPatchBufferLoop
466
 	call	SID_PBANK_ReadPage		; transfer 64 bytes
467
 
468
	movlw	0x40				; increment FSR1 pointer
469
	addwf	FSR1L, F
470
	movlw	0
471
	addwfc	FSR1H, F
472
 
473
	movf	EEADR, W			; loop 8 times
474
	bnz	SID_PATCH_LoadPatchBufferLoop
475
	movlw	2-1
476
	cpfsgt	EEADRH, ACCESS
477
	rgoto SID_PATCH_LoadPatchBufferLoop
478
 
479
	;; update edit buffer if required
480
	rcall	SID_PATCH_UpdateEditBuffer
481
 
482
	;; re-init patch and exit
483
	rgoto	SID_PATCH_Init
484
 
485
 
486
;; --------------------------------------------------------------------------
487
;;  This function initialises the edit buffer depending on the selected engine
488
;; --------------------------------------------------------------------------
489
SID_PATCH_LoadPresetIntoEdit
490
	;; select engine
491
	movff	SID_EDIT_BUFFER + SID_Ix_ENGINE, WREG
492
	BRA_IFSET WREG, 1, ACCESS, SID_PATCH_LoadPresetIntoEdit_DM
493
SID_PATCH_LoadPresetIntoEdit_LB
494
	BRA_IFSET WREG, 0, ACCESS, SID_PATCH_LoadPresetIntoEdit_B
495
SID_PATCH_LoadPresetIntoEdit_L
496
	TABLE_ADDR SID_PATCH_PRESET_LEAD
497
	rgoto	SID_PATCH_LoadPresetIntoEdit_Cnt
498
SID_PATCH_LoadPresetIntoEdit_B
499
	TABLE_ADDR SID_PATCH_PRESET_BASSLINE
500
	rgoto	SID_PATCH_LoadPresetIntoEdit_Cnt
501
 
502
SID_PATCH_LoadPresetIntoEdit_DM
503
	BRA_IFSET WREG, 0, ACCESS, SID_PATCH_LoadPresetIntoEdit_M
504
SID_PATCH_LoadPresetIntoEdit_D
505
	TABLE_ADDR SID_PATCH_PRESET_DRUM
506
	rgoto	SID_PATCH_LoadPresetIntoEdit_Cnt
507
SID_PATCH_LoadPresetIntoEdit_M
508
	TABLE_ADDR SID_PATCH_PRESET_MULTI
509
	;; 	rgoto	SID_PATCH_LoadPresetIntoEdit_Cnt
510
 
511
SID_PATCH_LoadPresetIntoEdit_Cnt
512
 
513
	lfsr	FSR0, SID_EDIT_BUFFER
514
	movlw	2
515
	movwf	PRODL
516
SID_PATCH_LoadPresetIntoEditLoop
517
	tblrd*+
518
	movff	TABLAT, POSTINC0
519
	movf	FSR0L, W
520
	bnz	SID_PATCH_LoadPresetIntoEditLoop
521
	decfsz	PRODL, F
522
	rgoto	SID_PATCH_LoadPresetIntoEditLoop
523
 
524
	return
525
 
526
	;; include the preset tables (512 bytes)
527
SID_PATCH_PRESET_LEAD
528
#include "src/sid_preset_lead.inc"
529
SID_PATCH_PRESET_BASSLINE
530
#include "src/sid_preset_bassline.inc"
531
SID_PATCH_PRESET_DRUM
532
#include "src/sid_preset_drum.inc"
533
SID_PATCH_PRESET_MULTI
534
#include "src/sid_preset_multi.inc"
535