Rev 1177 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
955 | tk | 1 | ;$Id: main.inc 1231 2019-01-05 16:35:29Z tk $ |
2 | ; |
||
1045 | tk | 3 | ; Source Code of MBHP_MF_NG Firmware |
955 | tk | 4 | ; |
5 | ; ========================================================================== |
||
6 | ; |
||
7 | ; Copyright 1998-2010 Thorsten Klose (tk@midibox.org) |
||
8 | ; Licensed for personal non-commercial use only. |
||
9 | ; All other rights reserved. |
||
10 | ; |
||
11 | ; ========================================================================== |
||
12 | |||
13 | ;; ---[ MIOS header file ]--- |
||
14 | #include <mios.h> |
||
15 | |||
16 | ;; ---[ useful macros ]--- |
||
17 | #include <macros.h> |
||
18 | |||
19 | ;; ---[ vectors to MIOS functions (never change!) ]--- |
||
20 | #include <mios_vectors.inc> |
||
21 | |||
22 | ;; ---[ user hooks (never change!) ]--- |
||
23 | #include <user_vectors.inc> |
||
24 | |||
25 | ;; ========================================================================== |
||
26 | ;; General Application Settings |
||
27 | ;; ========================================================================== |
||
28 | |||
29 | ;; ---[ variables used by application ]--- |
||
30 | #include "app_defines.h" |
||
31 | |||
32 | ; ========================================================================== |
||
33 | |||
34 | ;; ---[ configuration table for MIDI processor and rotary encoders ]--- |
||
35 | #include "mios_tables.inc" |
||
36 | |||
37 | ;; ---[ Custom LCD driver ]--- |
||
38 | #include <app_lcd.inc> |
||
39 | |||
40 | |||
41 | ;; ---[ Custom AIN Driver ]--- |
||
42 | #include <ain.inc> |
||
43 | |||
44 | ;; ---[ Custom MF Driver ]--- |
||
45 | #include <mf.inc> |
||
46 | |||
47 | ;; ---[ SysEx/Bank Handling ]--- |
||
48 | #include <mf_bank.inc> |
||
49 | #include <mf_dump.inc> |
||
50 | #include <mf_sysex.inc> |
||
998 | tk | 51 | #include <lc_sysex.inc> |
955 | tk | 52 | |
53 | ;; ========================================================================== |
||
54 | ;; All MIOS hooks in one file |
||
55 | ;; ========================================================================== |
||
56 | |||
57 | ;; -------------------------------------------------------------------------- |
||
58 | ;; This function is called by MIOS after startup to initialize the |
||
59 | ;; application |
||
60 | ;; -------------------------------------------------------------------------- |
||
61 | USER_Init |
||
62 | ;; ------------------------------------------------------------------ |
||
1045 | tk | 63 | ;; no LCD is connected to MBHP_MF_NG module |
955 | tk | 64 | ;; -> enable "dummy" LCD driver to avoid J15 port accesses |
65 | ;; ------------------------------------------------------------------ |
||
66 | clrf MIOS_PARAMETER1 |
||
67 | clrf MIOS_PARAMETER2 |
||
68 | movlw 0x07 ; select dummy driver in modules/app_lcd/dummy |
||
69 | call MIOS_LCD_TypeSet |
||
70 | |||
71 | ;; ------------------------------------------------------------------ |
||
72 | ;; configure IOs (a bit different compared to common MIOS applications) |
||
73 | ;; ------------------------------------------------------------------ |
||
74 | bsf INTCON2, NOT_RBPU ; Disable Pull-Ups of PortB |
||
75 | |||
76 | clrf PORTA ; Reset PortA |
||
77 | clrf PORTB ; Reset PortB |
||
78 | movlw 0x40 ; Reset PortC (TX Pin = 1) |
||
79 | movwf PORTC |
||
80 | clrf PORTD ; Reset PortD |
||
81 | clrf PORTE ; Reset PortE |
||
82 | |||
83 | movlw b'11101111' ; all PORTA pins beside if RA4 are tristate |
||
84 | movwf TRISA |
||
85 | clrf TRISB ; PORTB driver enabled by default (display data port) |
||
86 | movlw b'10000000' ; Rx Pin tristate, all other outputs |
||
87 | movwf TRISC |
||
88 | movlw b'00000010' ; DIN pin tristate, all other outputs |
||
89 | movwf TRISD |
||
90 | movlw b'00000111' ; all PORTE pins are tristate |
||
91 | movwf TRISE |
||
92 | |||
93 | ;; ------------------------------------------------------------------ |
||
94 | ;; configure SRIO (only a single DIN SR is connected for touchsensors) |
||
95 | ;; ------------------------------------------------------------------ |
||
1177 | tk | 96 | movlw 1 ; use 1 shift register |
955 | tk | 97 | call MIOS_SRIO_NumberSet |
1177 | tk | 98 | movlw 1 ; set update frequncy to 1/1 mS |
955 | tk | 99 | call MIOS_SRIO_UpdateFrqSet |
100 | movlw 10 ; 10 mS debouncing |
||
101 | call MIOS_SRIO_DebounceSet |
||
102 | |||
103 | ;; ------------------------------------------------------------------ |
||
104 | ;; Restore Dump from EEPROM |
||
105 | ;; this will also configure and enable AIN/MF driver! |
||
106 | ;; ------------------------------------------------------------------ |
||
107 | call MF_DUMP_RestoreAll |
||
108 | |||
109 | ;; ------------------------------------------------------------------ |
||
110 | ;; initialize the user timer (used for generating PWM) |
||
111 | ;; timer should be called every 50 uS == 500 ticks |
||
112 | ;; ------------------------------------------------------------------ |
||
113 | movlw 500 & 0xff ; low-byte |
||
114 | movwf MIOS_PARAMETER1 |
||
115 | movlw 500 >> 8 ; high-byte |
||
116 | movwf MIOS_PARAMETER2 |
||
117 | movlw 0x00 ; no prescaler (1:1) |
||
118 | call MIOS_TIMER_Init |
||
119 | |||
120 | return |
||
121 | |||
122 | |||
123 | ;; -------------------------------------------------------------------------- |
||
124 | ;; This function is called by MIOS in the mainloop when nothing else is to do |
||
125 | ;; -------------------------------------------------------------------------- |
||
126 | USER_Tick |
||
127 | ;; check if trace should be sent |
||
128 | SET_BSR MF_BASE |
||
129 | BRA_IFCLR MF_TRACE_STATE, MF_TRACE_STATE_FLAG_FINISHED, BANKED, USER_Tick_NoTraceDump |
||
130 | BRA_IFSET MF_TRACE_STATE, MF_TRACE_STATE_FLAG_SENT, BANKED, USER_Tick_NoTraceDump |
||
131 | USER_Tick_TraceDump |
||
132 | bsf MF_TRACE_STATE, MF_TRACE_STATE_FLAG_SENT, BANKED |
||
133 | call MF_SYSEX_SendTraceDump |
||
134 | USER_Tick_NoTraceDump |
||
135 | |||
136 | ;; AIN handler will call USER_AIN_NotifyChange on pot changes |
||
137 | call AIN_Handler |
||
1071 | tk | 138 | |
139 | ;; for mackie HUI pin handling |
||
140 | BRA_IFCLR PERIODIC_S_OVERRUN, 0, ACCESS, USER_Tick_NoPing |
||
141 | USER_Tick_Ping |
||
142 | bcf PERIODIC_S_OVERRUN, 0 |
||
143 | |||
144 | SET_BSR MF_BASE |
||
145 | movf MF_OPERATION_MODE, W, BANKED |
||
146 | xorlw 24 ; Mackie HUI |
||
147 | bnz USER_Tick_NoPing |
||
148 | |||
149 | ;; for MIDIbox Link: notify begin of stream |
||
150 | call MIOS_MIDI_BeginStream |
||
151 | |||
152 | movlw 0x90 |
||
153 | call MIOS_MIDI_TxBufferPut |
||
154 | movlw 0x00 |
||
155 | call MIOS_MIDI_TxBufferPut |
||
156 | movlw 0x7f |
||
157 | call MIOS_MIDI_TxBufferPut |
||
158 | |||
159 | ;; for MIDIbox Link: notify end of stream |
||
160 | call MIOS_MIDI_EndStream |
||
161 | |||
162 | USER_Tick_NoPing |
||
955 | tk | 163 | return |
164 | |||
165 | |||
166 | ;; -------------------------------------------------------------------------- |
||
167 | ;; This function is periodically called by MIOS. The frequency has to be |
||
168 | ;; initialized with MIOS_Timer_Set |
||
169 | ;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0 |
||
170 | ;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible! |
||
171 | ;; -------------------------------------------------------------------------- |
||
172 | USER_Timer |
||
173 | ;; this timer is called each 50 uS |
||
174 | |||
175 | ;; call period MF tick each mS |
||
176 | incf PERIODIC_MS_CTR, F |
||
177 | movf PERIODIC_MS_CTR, W |
||
178 | xorlw 20 ; 1 mS = 20*50uS |
||
179 | bnz USER_Timer_Periodic_mS_Skip |
||
180 | USER_Timer_Periodic_mS |
||
181 | clrf PERIODIC_MS_CTR |
||
182 | call MF_Periodic_mS_Tick |
||
1071 | tk | 183 | |
184 | USER_Timer_Periodic_S |
||
185 | ;; for Mackie HUI ping handling |
||
186 | incf PERIODIC_S_CTR_L, F |
||
187 | skpnz |
||
188 | incf PERIODIC_S_CTR_H, F |
||
189 | |||
190 | movlw LOW(1000) |
||
191 | xorwf PERIODIC_S_CTR_L, W |
||
192 | bnz USER_Timer_Periodic_S_Skip |
||
193 | movlw HIGH(1000) |
||
194 | xorwf PERIODIC_S_CTR_H, W |
||
195 | bnz USER_Timer_Periodic_S_Skip |
||
196 | USER_Timer_Periodic_S_Overrun |
||
197 | clrf PERIODIC_S_CTR_L |
||
198 | clrf PERIODIC_S_CTR_H |
||
199 | bsf PERIODIC_S_OVERRUN, 0 |
||
200 | USER_Timer_Periodic_S_Skip |
||
955 | tk | 201 | USER_Timer_Periodic_mS_Skip |
202 | |||
203 | ;; call AIN interrupt handler each 100 uS |
||
204 | ;; it starts conversions, stores the result of previous conversions, and calls the MF_Tick handler |
||
205 | btfsc PERIODIC_MS_CTR, 0 |
||
206 | call AIN_Tick |
||
207 | |||
208 | ;; call PWM handler |
||
209 | ;; it generates PWM on all motor control lines |
||
210 | call MF_PWM_Tick |
||
211 | |||
212 | ;; ------------------------------------------------------------------ |
||
213 | ;; Status LED sweep effect |
||
214 | ;; ------------------------------------------------------------------ |
||
215 | USER_Timer_LedSweep |
||
216 | SET_BSR MF_BASE |
||
217 | incf MF_PWM_STATUS_LED_SWEEP_CTR, F, BANKED |
||
218 | bnz USER_Timer_LedSweepEnd |
||
219 | USER_Timer_LedSweepNext |
||
220 | movf MF_PWM_STATUS_LED_SWEEP_DIR, W, BANKED |
||
221 | bnz USER_Timer_LedSweepNext_Down |
||
222 | USER_Timer_LedSweepNext_Up |
||
223 | incf MF_PWM_DUTY_STATUS_LED, F, BANKED |
||
224 | movlw 0x40 ; sweep between 0x00..0x40 |
||
225 | cpfsgt MF_PWM_DUTY_STATUS_LED, BANKED |
||
226 | rgoto USER_Timer_LedSweepEnd |
||
227 | setf MF_PWM_STATUS_LED_SWEEP_DIR, BANKED |
||
228 | rgoto USER_Timer_LedSweepEnd |
||
229 | |||
230 | USER_Timer_LedSweepNext_Down |
||
231 | decf MF_PWM_DUTY_STATUS_LED, F, BANKED |
||
232 | skpnz |
||
233 | clrf MF_PWM_STATUS_LED_SWEEP_DIR, BANKED |
||
234 | ;; rgoto USER_Timer_LedSweepEnd |
||
235 | |||
236 | USER_Timer_LedSweepEnd |
||
237 | |||
238 | return |
||
239 | |||
240 | |||
241 | ;; -------------------------------------------------------------------------- |
||
242 | ;; This function is called by MIOS when a debug command has been received |
||
243 | ;; via SysEx |
||
244 | ;; Input: |
||
245 | ;; o WREG, MIOS_PARAMETER1, MIOS_PARAMETER2, MIOS_PARAMETER3 like |
||
246 | ;; specified in the debug command |
||
247 | ;; Output: |
||
248 | ;; o return values WREG, MIOS_PARAMETER1, MIOS_PARAMETER2, MIOS_PARAMETER3 |
||
249 | ;; -------------------------------------------------------------------------- |
||
250 | USER_MPROC_DebugTrigger |
||
251 | return |
||
252 | |||
253 | |||
254 | ;; -------------------------------------------------------------------------- |
||
255 | ;; This function is called by MIOS when the display content should be |
||
256 | ;; initialized. Thats the case during startup and after a temporary message |
||
257 | ;; has been printed on the screen |
||
258 | ;; -------------------------------------------------------------------------- |
||
259 | USER_DISPLAY_Init |
||
260 | ;; NO DISPLAY CONNECTED!!! |
||
261 | return |
||
262 | |||
263 | ;; -------------------------------------------------------------------------- |
||
264 | ;; This function is called in the mainloop when no temporary message is shown |
||
265 | ;; on screen. Print the realtime messages here |
||
266 | ;; -------------------------------------------------------------------------- |
||
267 | USER_DISPLAY_Tick |
||
268 | ;; NO DISPLAY CONNECTED!!! |
||
269 | return |
||
270 | |||
271 | |||
272 | ;; -------------------------------------------------------------------------- |
||
273 | ;; This function is called by MIOS when a complete MIDI event has been received |
||
274 | ;; Input: |
||
275 | ;; o first MIDI event byte in MIOS_PARAMETER1 |
||
276 | ;; o second MIDI event byte in MIOS_PARAMETER2 |
||
277 | ;; o third MIDI event byte in MIOS_PARAMETER3 |
||
278 | ;; -------------------------------------------------------------------------- |
||
279 | USER_MPROC_NotifyReceivedEvent |
||
998 | tk | 280 | ;; branch depending on selected operation mode |
281 | SET_BSR MF_BASE |
||
282 | movf MF_OPERATION_MODE, W, BANKED |
||
1071 | tk | 283 | JUMPTABLE_2BYTES 26 ; entries |
998 | tk | 284 | rgoto USER_MPROC_M0 ; Pitchbender Chn1..8 |
285 | rgoto USER_MPROC_M1 ; Pitchbender Chn9..16 |
||
286 | rgoto USER_MPROC_M2 ; CC7 Chn1..8 |
||
287 | rgoto USER_MPROC_M3 ; CC7 Chn9..16 |
||
1045 | tk | 288 | rgoto USER_MPROC_M4 ; CC0..7 |
289 | rgoto USER_MPROC_M5 ; CC8..15 |
||
290 | rgoto USER_MPROC_M6 ; CC16..23 |
||
291 | rgoto USER_MPROC_M7 ; CC24..31 |
||
292 | rgoto USER_MPROC_M8 ; CC32..39 |
||
293 | rgoto USER_MPROC_M9 ; CC40..47 |
||
294 | rgoto USER_MPROC_M10 ; CC48..55 |
||
295 | rgoto USER_MPROC_M11 ; CC56..63 |
||
296 | rgoto USER_MPROC_M12 ; CC64..71 |
||
297 | rgoto USER_MPROC_M13 ; CC72..79 |
||
298 | rgoto USER_MPROC_M14 ; CC80..87 |
||
299 | rgoto USER_MPROC_M15 ; CC88..95 |
||
300 | rgoto USER_MPROC_M16 ; CC96..103 |
||
301 | rgoto USER_MPROC_M17 ; CC104..111 |
||
302 | rgoto USER_MPROC_M18 ; CC112..119 |
||
303 | rgoto USER_MPROC_M19 ; CC120..127 |
||
304 | rgoto USER_MPROC_M20 ; Logic Control |
||
305 | rgoto USER_MPROC_M21 ; Logic Control Extension |
||
306 | rgoto USER_MPROC_M22 ; Mackie Control |
||
307 | rgoto USER_MPROC_M23 ; Mackie Control Extension |
||
1071 | tk | 308 | rgoto USER_MPROC_M24 ; Mackie HUI |
309 | rgoto USER_MPROC_M25 ; Motormix |
||
998 | tk | 310 | |
311 | |||
312 | USER_MPROC_M0 ; Pitchbender Chn1..8 |
||
1045 | tk | 313 | USER_MPROC_M20 ; Logic Control |
314 | USER_MPROC_M21 ; Logic Control Extension |
||
315 | USER_MPROC_M22 ; Mackie Control |
||
316 | USER_MPROC_M23 ; Mackie Control Extension |
||
959 | tk | 317 | ;; branch to USER_MPROC_Received_Ex if pitch bender event (for motorfaders) has been received |
318 | movf MIOS_PARAMETER1, W |
||
998 | tk | 319 | andlw 0xf8 |
959 | tk | 320 | xorlw 0xe0 |
998 | tk | 321 | bz USER_MPROC_Ex |
959 | tk | 322 | |
323 | ;; nothing else to parse |
||
955 | tk | 324 | return |
998 | tk | 325 | |
326 | USER_MPROC_M1 ; Pitchbender Chn9..16 |
||
327 | ;; branch to USER_MPROC_Ex if pitch bender event (for motorfaders) has been received |
||
328 | movf MIOS_PARAMETER1, W |
||
329 | andlw 0xf8 |
||
330 | xorlw 0xe8 |
||
331 | bz USER_MPROC_Ex |
||
955 | tk | 332 | |
998 | tk | 333 | ;; nothing else to parse |
334 | return |
||
955 | tk | 335 | |
998 | tk | 336 | |
337 | USER_MPROC_Ex |
||
959 | tk | 338 | ;; mask out MIDI channel (== fader number) |
998 | tk | 339 | movlw 0x07 |
959 | tk | 340 | andwf MIOS_PARAMETER1, F |
341 | |||
342 | ;; save fader number in LC_FADER_NUMBER |
||
343 | movf MIOS_PARAMETER1, W |
||
344 | movwf LC_FADER_NUMBER |
||
345 | |||
346 | ;; reset touch detection if touch sensor mode >= 1 |
||
347 | SET_BSR MF_BASE |
||
348 | movf MF_TOUCHSENSOR_MODE, W, BANKED |
||
1116 | tk | 349 | bz USER_MPROC_Ex_NoTs |
998 | tk | 350 | USER_MPROC_Ex_Ts |
959 | tk | 351 | movf LC_FADER_NUMBER, W |
352 | call MF_TouchDetectionReset |
||
998 | tk | 353 | USER_MPROC_Ex_NoTs |
959 | tk | 354 | |
355 | ;; derive 10-bit value from received 14-bit value. Store result in LC_FADER_POS_[LH] |
||
356 | movff MIOS_PARAMETER2, LC_FADER_POS_L ; MIDI LSB -> LC_FADER_POS_L |
||
357 | movff MIOS_PARAMETER3, LC_FADER_POS_H ; MIDI MSB -> LC_FADER_POS_H |
||
358 | |||
359 | ;; LSB = MSB[0] | MIDI LSB |
||
360 | btfsc LC_FADER_POS_H, 0 |
||
361 | bsf LC_FADER_POS_L, 7 |
||
362 | ;; MSB = MIDI MSB >> 1 |
||
363 | clrc |
||
364 | rrf LC_FADER_POS_H, F |
||
365 | |||
366 | ;; 10-bit value = 14-bit value >> 4 |
||
367 | clrc |
||
368 | rrf LC_FADER_POS_H, F ; 1 |
||
369 | rrf LC_FADER_POS_L, F |
||
370 | clrc |
||
371 | rrf LC_FADER_POS_H, F ; 2 |
||
372 | rrf LC_FADER_POS_L, F |
||
373 | clrc |
||
374 | rrf LC_FADER_POS_H, F ; 3 |
||
375 | rrf LC_FADER_POS_L, F |
||
376 | clrc |
||
377 | rrf LC_FADER_POS_H, F ; 4 |
||
378 | rrf LC_FADER_POS_L, F |
||
379 | |||
380 | ;; finally move fader |
||
381 | movff LC_FADER_POS_L, MIOS_PARAMETER1 |
||
382 | movff LC_FADER_POS_H, MIOS_PARAMETER2 |
||
383 | movf LC_FADER_NUMBER, W |
||
384 | goto MF_FaderMove |
||
385 | |||
386 | |||
998 | tk | 387 | ;; --------------------------------------------------------- |
388 | USER_MPROC_M2 ; CC7 Chn1..8 |
||
389 | movf MIOS_PARAMETER1, W ; CC Chn1..8? |
||
390 | andlw 0xf8 |
||
391 | xorlw 0xb0 |
||
392 | bnz USER_MPROC_M2_End |
||
393 | |||
394 | movf MIOS_PARAMETER2, W ; CC#7? |
||
395 | xorlw 7 |
||
396 | bnz USER_MPROC_M2_End |
||
397 | |||
398 | ;; mask out MIDI channel (== fader number) |
||
399 | movf MIOS_PARAMETER1, W |
||
400 | andlw 0x07 |
||
401 | movwf LC_FADER_NUMBER |
||
402 | rgoto USER_MPROC_Bx |
||
403 | |||
404 | USER_MPROC_M2_End |
||
405 | return |
||
406 | |||
407 | ;; --------------------------------------------------------- |
||
408 | USER_MPROC_M3 ; CC7 Chn9..16 |
||
409 | movf MIOS_PARAMETER1, W ; CC Chn9..16? |
||
410 | andlw 0xf8 |
||
411 | xorlw 0xb8 |
||
412 | bnz USER_MPROC_M3_End |
||
413 | |||
414 | movf MIOS_PARAMETER2, W ; CC#7? |
||
415 | xorlw 7 |
||
416 | bnz USER_MPROC_M3_End |
||
417 | |||
418 | ;; mask out MIDI channel (== fader number) |
||
419 | movf MIOS_PARAMETER1, W |
||
420 | andlw 0x07 |
||
421 | movwf LC_FADER_NUMBER |
||
422 | rgoto USER_MPROC_Bx |
||
423 | |||
424 | USER_MPROC_M3_End |
||
425 | return |
||
426 | |||
427 | ;; --------------------------------------------------------- |
||
1045 | tk | 428 | USER_MPROC_M4 ; CC0..7 |
429 | USER_MPROC_M5 ; CC8..15 |
||
430 | USER_MPROC_M6 ; CC16..23 |
||
431 | USER_MPROC_M7 ; CC24..31 |
||
432 | USER_MPROC_M8 ; CC32..39 |
||
433 | USER_MPROC_M9 ; CC40..47 |
||
434 | USER_MPROC_M10 ; CC48..55 |
||
435 | USER_MPROC_M11 ; CC56..63 |
||
436 | USER_MPROC_M12 ; CC64..71 |
||
437 | USER_MPROC_M13 ; CC72..79 |
||
438 | USER_MPROC_M14 ; CC80..87 |
||
439 | USER_MPROC_M15 ; CC88..95 |
||
440 | USER_MPROC_M16 ; CC96..103 |
||
441 | USER_MPROC_M17 ; CC104..111 |
||
442 | USER_MPROC_M18 ; CC112..119 |
||
443 | USER_MPROC_M19 ; CC120..127 |
||
1074 | tk | 444 | movf MIDI_CHANNEL, W ; CC over selected MIDI channel? |
445 | andlw 0x0f |
||
446 | iorlw 0xb0 |
||
447 | xorwf MIOS_PARAMETER1, W |
||
998 | tk | 448 | bnz USER_MPROC_M4_End |
449 | |||
1045 | tk | 450 | movf MF_OPERATION_MODE, W, BANKED ; CC matching? |
451 | addlw -4 |
||
452 | rlf WREG, W |
||
453 | rlf WREG, W |
||
454 | rlf WREG, W |
||
455 | xorwf MIOS_PARAMETER2, W ; CC matching? |
||
998 | tk | 456 | andlw 0xf8 |
457 | bnz USER_MPROC_M4_End |
||
458 | |||
459 | ;; mask out CC LSBs (== fader number) |
||
460 | movf MIOS_PARAMETER2, W |
||
461 | andlw 0x07 |
||
462 | movwf LC_FADER_NUMBER |
||
463 | rgoto USER_MPROC_Bx |
||
464 | |||
465 | USER_MPROC_M4_End |
||
466 | return |
||
467 | |||
468 | |||
469 | USER_MPROC_Bx |
||
470 | ;; reset touch detection if touch sensor mode >= 1 |
||
471 | SET_BSR MF_BASE |
||
472 | movf MF_TOUCHSENSOR_MODE, W, BANKED |
||
1116 | tk | 473 | bz USER_MPROC_Bx_NoTs |
998 | tk | 474 | USER_MPROC_Bx_Ts |
475 | movf LC_FADER_NUMBER, W |
||
476 | call MF_TouchDetectionReset |
||
477 | USER_MPROC_Bx_NoTs |
||
478 | |||
479 | ;; derive 10-bit value from received 7-bit value. Store result in LC_FADER_POS_[LH] |
||
480 | movff MIOS_PARAMETER3, LC_FADER_POS_L ; MIDI LSB -> LC_FADER_POS_L |
||
481 | clrf LC_FADER_POS_H ; MIDI MSB -> LC_FADER_POS_H |
||
482 | |||
483 | ;; 10-bit value = 7-bit value << 3 |
||
484 | clrc |
||
485 | rlf LC_FADER_POS_L, F ; 1 |
||
486 | rlf LC_FADER_POS_H, F |
||
487 | clrc |
||
488 | rlf LC_FADER_POS_L, F ; 2 |
||
489 | rlf LC_FADER_POS_H, F |
||
490 | clrc |
||
491 | rlf LC_FADER_POS_L, F ; 3 |
||
492 | rlf LC_FADER_POS_H, F |
||
493 | |||
494 | ;; finally move fader |
||
495 | movff LC_FADER_POS_L, MIOS_PARAMETER1 |
||
496 | movff LC_FADER_POS_H, MIOS_PARAMETER2 |
||
497 | movf LC_FADER_NUMBER, W |
||
498 | goto MF_FaderMove |
||
499 | |||
1071 | tk | 500 | |
501 | ;; --------------------------------------------------------- |
||
502 | USER_MPROC_M24 ; Mackie HUI |
||
503 | USER_MPROC_M25 ; Motormix |
||
504 | |||
505 | ;; Position transfered via two events: |
||
1074 | tk | 506 | ;; Bn 0x <high> |
507 | ;; Bn 2x <low> (+ fader move) |
||
1071 | tk | 508 | |
1074 | tk | 509 | movf MIDI_CHANNEL, W ; CC over selected MIDI channel? |
510 | andlw 0x0f |
||
511 | iorlw 0xb0 |
||
512 | xorwf MIOS_PARAMETER1, W |
||
1071 | tk | 513 | bnz USER_MPROC_NoHUI |
514 | USER_MPROC_HUI |
||
515 | movf MIOS_PARAMETER2, W |
||
516 | andlw 0xf8 |
||
517 | bz USER_MPROC_HUI_H |
||
518 | |||
519 | movf MIOS_PARAMETER2, W |
||
520 | andlw 0xf8 |
||
521 | xorlw 0x20 |
||
522 | bz USER_MPROC_HUI_L |
||
523 | |||
524 | USER_MPROC_NoHUI |
||
525 | ;; nothing else to parse |
||
526 | return |
||
527 | |||
528 | |||
529 | USER_MPROC_HUI_H |
||
530 | ;; store high-byte in array |
||
531 | lfsr FSR1, HUI_HIGH_BYTES_0 |
||
532 | movf MIOS_PARAMETER2, W ; fader number coded into CC number |
||
533 | andlw 0x07 |
||
534 | movff MIOS_PARAMETER3, PLUSW1 |
||
535 | return |
||
536 | |||
537 | USER_MPROC_HUI_L |
||
538 | ;; save fader number in LC_FADER_NUMBER |
||
539 | movf MIOS_PARAMETER2, W |
||
540 | andlw 0x07 |
||
541 | movwf LC_FADER_NUMBER |
||
542 | |||
543 | ;; reset touch detection if touch sensor mode >= 1 |
||
544 | SET_BSR MF_BASE |
||
545 | movf MF_TOUCHSENSOR_MODE, W, BANKED |
||
1116 | tk | 546 | bz USER_MPROC_HUI_L_NoTs |
1071 | tk | 547 | USER_MPROC_HUI_L_Ts |
548 | movf LC_FADER_NUMBER, W |
||
549 | call MF_TouchDetectionReset |
||
550 | USER_MPROC_HUI_L_NoTs |
||
551 | |||
552 | ;; derive 10-bit value from received 14-bit value. Store result in LC_FADER_POS_[LH] |
||
1116 | tk | 553 | movff MIOS_PARAMETER3, LC_FADER_POS_L ; MIDI LSB -> LC_FADER_POS_L |
1071 | tk | 554 | lfsr FSR1, HUI_HIGH_BYTES_0 |
555 | movf LC_FADER_NUMBER, W |
||
556 | movff PLUSW1, LC_FADER_POS_H ; MIDI MSB -> LC_FADER_POS_H |
||
557 | |||
558 | ;; LSB = MSB[0] | MIDI LSB |
||
559 | btfsc LC_FADER_POS_H, 0 |
||
560 | bsf LC_FADER_POS_L, 7 |
||
561 | ;; MSB = MIDI MSB >> 1 |
||
562 | clrc |
||
563 | rrf LC_FADER_POS_H, F |
||
564 | |||
565 | ;; 10-bit value = 14-bit value >> 4 |
||
566 | clrc |
||
567 | rrf LC_FADER_POS_H, F ; 1 |
||
568 | rrf LC_FADER_POS_L, F |
||
569 | clrc |
||
570 | rrf LC_FADER_POS_H, F ; 2 |
||
571 | rrf LC_FADER_POS_L, F |
||
572 | clrc |
||
573 | rrf LC_FADER_POS_H, F ; 3 |
||
574 | rrf LC_FADER_POS_L, F |
||
575 | clrc |
||
576 | rrf LC_FADER_POS_H, F ; 4 |
||
577 | rrf LC_FADER_POS_L, F |
||
578 | |||
579 | ;; finally move fader |
||
580 | movff LC_FADER_POS_L, MIOS_PARAMETER1 |
||
581 | movff LC_FADER_POS_H, MIOS_PARAMETER2 |
||
582 | movf LC_FADER_NUMBER, W |
||
583 | goto MF_FaderMove |
||
584 | |||
585 | |||
955 | tk | 586 | ;; -------------------------------------------------------------------------- |
587 | ;; This function is called by MIOS when a MIDI event has been received |
||
588 | ;; which has been specified in the CONFIG_MIDI_IN table |
||
589 | ;; Input: |
||
590 | ;; o number of entry in WREG |
||
591 | ;; o first MIDI event byte in MIOS_PARAMETER1 |
||
592 | ;; o second MIDI event byte in MIOS_PARAMETER2 |
||
593 | ;; o third MIDI event byte in MIOS_PARAMETER3 |
||
594 | ;; -------------------------------------------------------------------------- |
||
595 | USER_MPROC_NotifyFoundEvent |
||
596 | return |
||
597 | |||
598 | |||
599 | ;; -------------------------------------------------------------------------- |
||
600 | ;; This function is called by MIOS when a MIDI event has not been completly |
||
601 | ;; received within 2 seconds |
||
602 | ;; -------------------------------------------------------------------------- |
||
603 | USER_MPROC_NotifyTimeout |
||
604 | ;; -> jump to "ActionInvalid" for a proper reset of the sysex parser |
||
998 | tk | 605 | call MF_SYSEX_ActionInvalid |
606 | goto LC_SYSEX_ActionInvalid |
||
955 | tk | 607 | |
608 | |||
609 | ;; -------------------------------------------------------------------------- |
||
610 | ;; This function is called by MIOS when a MIDI byte has been received |
||
611 | ;; Input: |
||
612 | ;; o received MIDI byte in WREG and MIOS_PARAMETER1 |
||
613 | ;; -------------------------------------------------------------------------- |
||
614 | USER_MPROC_NotifyReceivedByte |
||
998 | tk | 615 | movwf LC_RECEIVED_SYSEX_BYTE ; store byte |
955 | tk | 616 | |
998 | tk | 617 | ;; -> branch to SysEx parsers |
618 | call MF_SYSEX_Parser |
||
619 | movf LC_RECEIVED_SYSEX_BYTE, W ; restore byte for next parser |
||
620 | goto LC_SYSEX_Parser |
||
621 | |||
955 | tk | 622 | ;; -------------------------------------------------------------------------- |
623 | ;; This function is called by MIOS before the transfer of a MIDI byte. |
||
624 | ;; It can be used to monitor the Tx activity or to do any other actions |
||
625 | ;; (e.g. to switch a pin for multiplexed MIDI Outs) before the byte will |
||
626 | ;; be sent. |
||
627 | ;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0 |
||
628 | ;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible! |
||
629 | ;; Input: |
||
630 | ;; o transmitted byte in WREG |
||
631 | ;; -------------------------------------------------------------------------- |
||
632 | USER_MIDI_NotifyTx |
||
633 | return |
||
634 | |||
635 | ;; -------------------------------------------------------------------------- |
||
636 | ;; This function is called by MIOS when a MIDI byte has been received. |
||
637 | ;; It can be used to monitor the Rx activity or to do any action - e.g. |
||
638 | ;; to react on realtime events like MIDI clock (0xf8) with a minimum latency |
||
639 | ;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0 |
||
640 | ;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible! |
||
641 | ;; Input: |
||
642 | ;; o received byte in WREG |
||
643 | ;; -------------------------------------------------------------------------- |
||
644 | USER_MIDI_NotifyRx |
||
645 | return |
||
646 | |||
647 | ;; -------------------------------------------------------------------------- |
||
648 | ;; This function is called by MIOS when an button has been toggled |
||
649 | ;; Input: |
||
650 | ;; o Button number in WREG and MIOS_PARAMETER1 |
||
651 | ;; o Button value MIOS_PARAMETER2: |
||
652 | ;; - 1 if button has been released (=5V) |
||
653 | ;; - 0 if button has been pressed (=0V) |
||
654 | ;; -------------------------------------------------------------------------- |
||
655 | USER_DIN_NotifyToggle |
||
957 | tk | 656 | ;; exit if touch sensors have been disabled |
657 | SET_BSR MF_BASE |
||
658 | movf MF_TOUCHSENSOR_MODE, W, BANKED |
||
659 | skpnz |
||
660 | return |
||
661 | |||
955 | tk | 662 | ;; only button 0..7 should toggle - exit function if button >= 8 |
663 | andlw 0xf8 |
||
664 | skpz |
||
665 | return |
||
666 | |||
957 | tk | 667 | ;; TOUCH_SENSOR_MODE >= 2 |
668 | SET_BSR MF_BASE |
||
669 | movlw 2-1 |
||
670 | cpfsgt MF_TOUCHSENSOR_MODE, BANKED |
||
671 | rgoto USER_DIN_NotifyToggle_NoSuspend |
||
672 | |||
673 | ;; in this mode, motorfaders will be suspended if touch sensors active |
||
674 | USER_DIN_NotifyToggle_Suspend |
||
675 | movf MIOS_PARAMETER2, W |
||
676 | bz USER_DIN_NotifyToggle_Suspend1 |
||
677 | USER_DIN_NotifyToggle_Suspend0 |
||
678 | movf MIOS_PARAMETER1, W |
||
679 | call MF_SuspendDisable |
||
680 | rgoto USER_DIN_NotifyToggle_Cont |
||
681 | USER_DIN_NotifyToggle_Suspend1 |
||
682 | movf MIOS_PARAMETER1, W |
||
683 | call MF_SuspendEnable |
||
684 | ;; rgoto USER_DIN_NotifyToggle_Cont |
||
685 | USER_DIN_NotifyToggle_Cont |
||
686 | USER_DIN_NotifyToggle_NoSuspend |
||
687 | |||
1071 | tk | 688 | ;; generate MIDI event depending on mode |
689 | ;; branch depending on selected operation mode |
||
690 | SET_BSR MF_BASE |
||
691 | movf MF_OPERATION_MODE, W, BANKED |
||
692 | JUMPTABLE_2BYTES 26 ; entries |
||
693 | rgoto USER_DIN_NotifyToggle_End ; Pitchbender Chn1..8 |
||
694 | rgoto USER_DIN_NotifyToggle_End ; Pitchbender Chn9..16 |
||
695 | rgoto USER_DIN_NotifyToggle_End ; CC7 Chn1..8 |
||
696 | rgoto USER_DIN_NotifyToggle_End ; CC7 Chn9..16 |
||
697 | rgoto USER_DIN_NotifyToggle_End ; CC0..7 |
||
698 | rgoto USER_DIN_NotifyToggle_End ; CC8..15 |
||
699 | rgoto USER_DIN_NotifyToggle_End ; CC16..23 |
||
700 | rgoto USER_DIN_NotifyToggle_End ; CC24..31 |
||
701 | rgoto USER_DIN_NotifyToggle_End ; CC32..39 |
||
702 | rgoto USER_DIN_NotifyToggle_End ; CC40..47 |
||
703 | rgoto USER_DIN_NotifyToggle_End ; CC48..55 |
||
704 | rgoto USER_DIN_NotifyToggle_End ; CC56..63 |
||
705 | rgoto USER_DIN_NotifyToggle_End ; CC64..71 |
||
706 | rgoto USER_DIN_NotifyToggle_End ; CC72..79 |
||
707 | rgoto USER_DIN_NotifyToggle_End ; CC80..87 |
||
708 | rgoto USER_DIN_NotifyToggle_End ; CC88..95 |
||
709 | rgoto USER_DIN_NotifyToggle_End ; CC96..103 |
||
710 | rgoto USER_DIN_NotifyToggle_End ; CC104..111 |
||
711 | rgoto USER_DIN_NotifyToggle_End ; CC112..119 |
||
712 | rgoto USER_DIN_NotifyToggle_End ; CC120..127 |
||
713 | rgoto USER_DIN_NotifyToggle_M20 ; Logic Control |
||
714 | rgoto USER_DIN_NotifyToggle_M21 ; Logic Control Extension |
||
715 | rgoto USER_DIN_NotifyToggle_M22 ; Mackie Control |
||
716 | rgoto USER_DIN_NotifyToggle_M23 ; Mackie Control Extension |
||
717 | rgoto USER_DIN_NotifyToggle_M24 ; Mackie HUI |
||
718 | rgoto USER_DIN_NotifyToggle_M25 ; Motormix |
||
957 | tk | 719 | |
1071 | tk | 720 | ;; --------------------------------------------------------- |
721 | USER_DIN_NotifyToggle_M20 ; Logic Control |
||
722 | USER_DIN_NotifyToggle_M21 ; Logic Control Extension |
||
723 | USER_DIN_NotifyToggle_M22 ; Mackie Control |
||
724 | USER_DIN_NotifyToggle_M23 ; Mackie Control Extension |
||
725 | |||
957 | tk | 726 | ;; for MIDIbox Link: notify begin of stream |
727 | call MIOS_MIDI_BeginStream |
||
728 | |||
955 | tk | 729 | ;; Note On/Off 0x68..0x6f complies to Mackie Control Spec |
1231 | tk | 730 | ;; UPDATED: added +12, see also http://midibox.org/forums/topic/15004-upcoming-mbhp_mf_ng-module/?do=findComment&comment=178903 |
955 | tk | 731 | movlw 0x90 ; Note Event Channel #1 |
732 | call MIOS_MIDI_TxBufferPut |
||
733 | |||
1231 | tk | 734 | movlw 0x68 + 12 ; 0x68..0x6f depending on button number |
955 | tk | 735 | addwf MIOS_PARAMETER1, W |
736 | call MIOS_MIDI_TxBufferPut |
||
737 | |||
738 | movlw 0x00 ; velocity 0 if button released, otherwise 0x7f |
||
739 | movf MIOS_PARAMETER2, F |
||
740 | skpnz |
||
741 | movlw 0x7f |
||
742 | call MIOS_MIDI_TxBufferPut |
||
743 | |||
957 | tk | 744 | ;; for MIDIbox Link: notify end of stream |
745 | call MIOS_MIDI_EndStream |
||
746 | |||
1071 | tk | 747 | rgoto USER_DIN_NotifyToggle_End |
748 | |||
749 | |||
750 | ;; --------------------------------------------------------- |
||
751 | USER_DIN_NotifyToggle_M24 ; Mackie HUI |
||
752 | USER_DIN_NotifyToggle_M25 ; Motormix |
||
753 | |||
754 | ;; for MIDIbox Link: notify begin of stream |
||
755 | call MIOS_MIDI_BeginStream |
||
756 | |||
1074 | tk | 757 | ;; Touch Fader: Bn 0F <fader> 2F 40 |
758 | ;; Release Fader: Bn 0F <fader> 2F 00 |
||
1071 | tk | 759 | |
1074 | tk | 760 | movf MIDI_CHANNEL, W |
761 | andlw 0x0f |
||
762 | iorlw 0xb0 |
||
1071 | tk | 763 | call MIOS_MIDI_TxBufferPut |
764 | |||
765 | movlw 0x0f |
||
766 | call MIOS_MIDI_TxBufferPut |
||
767 | |||
768 | movf MIOS_PARAMETER1, W ; fader number |
||
769 | call MIOS_MIDI_TxBufferPut |
||
770 | |||
771 | movlw 0x2f |
||
772 | call MIOS_MIDI_TxBufferPut |
||
773 | |||
774 | movlw 0x00 ; value 0 if button released, otherwise 0x40 |
||
775 | movf MIOS_PARAMETER2, F |
||
776 | skpnz |
||
777 | movlw 0x40 |
||
778 | call MIOS_MIDI_TxBufferPut |
||
779 | |||
780 | ;; for MIDIbox Link: notify end of stream |
||
781 | call MIOS_MIDI_EndStream |
||
782 | |||
783 | rgoto USER_DIN_NotifyToggle_End |
||
784 | |||
785 | |||
786 | ;; --------------------------------------------------------- |
||
998 | tk | 787 | USER_DIN_NotifyToggle_End |
955 | tk | 788 | return |
789 | |||
790 | |||
791 | ;; -------------------------------------------------------------------------- |
||
792 | ;; This function is called by MIOS when an encoder has been moved |
||
793 | ;; Input: |
||
794 | ;; o Encoder number in WREG and MIOS_PARAMETER1 |
||
795 | ;; o signed incrementer value in MIOS_PARAMETER2: |
||
796 | ;; - is positive when encoder has been turned clockwise |
||
797 | ;; - is negative when encoder has been turned counter clockwise |
||
798 | ;; -------------------------------------------------------------------------- |
||
799 | USER_ENC_NotifyChange |
||
800 | return |
||
801 | |||
802 | |||
803 | ;; -------------------------------------------------------------------------- |
||
804 | ;; This function is called by MIOS before the shift register are loaded |
||
805 | ;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0 |
||
806 | ;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible |
||
807 | ;; -------------------------------------------------------------------------- |
||
808 | USER_SR_Service_Prepare |
||
809 | return |
||
810 | |||
811 | |||
812 | ;; -------------------------------------------------------------------------- |
||
813 | ;; This function is called by MIOS after the shift register have been loaded |
||
814 | ;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0 |
||
815 | ;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible |
||
816 | ;; -------------------------------------------------------------------------- |
||
817 | USER_SR_Service_Finish |
||
818 | return |
||
819 | |||
820 | ;; -------------------------------------------------------------------------- |
||
821 | ;; This function is called by MIOS when a pot has been moved |
||
822 | ;; Input: |
||
823 | ;; o Pot number in WREG and MIOS_PARAMETER1 |
||
824 | ;; o LSB value in MIOS_PARAMETER2 |
||
825 | ;; o MSB value in MIOS_PARAMETER3 |
||
826 | ;; -------------------------------------------------------------------------- |
||
827 | USER_AIN_NotifyChange |
||
828 | |||
829 | ;; save the fader number in LC_FADER_NUMBER |
||
830 | movwf LC_FADER_NUMBER |
||
831 | |||
957 | tk | 832 | ;; TOUCH_SENSOR_MODE >= 3 |
833 | SET_BSR MF_BASE |
||
834 | movlw 3-1 |
||
835 | cpfsgt MF_TOUCHSENSOR_MODE, BANKED |
||
836 | rgoto USER_AIN_NotifyChange_SendAlways |
||
837 | |||
838 | ;; in this mode, no value will be sent if touch sensor not active (fader not suspended) |
||
839 | USER_AIN_NotifyChange_SendIfAct |
||
955 | tk | 840 | movf LC_FADER_NUMBER, W |
957 | tk | 841 | call MF_SuspendGet |
998 | tk | 842 | skpnz |
843 | rgoto LC_MF_FaderEvent_End |
||
955 | tk | 844 | |
957 | tk | 845 | USER_AIN_NotifyChange_SendAlways |
998 | tk | 846 | |
1177 | tk | 847 | ;; map MIOS_PARAMETER[23] to calibration table |
848 | clrc |
||
849 | rlf MIOS_PARAMETER2, W |
||
850 | movwf TBLPTRL |
||
851 | rlf MIOS_PARAMETER3, W |
||
852 | movwf TBLPTRH |
||
853 | clrf TBLPTRU |
||
854 | |||
855 | movlw LOW(CAL_FADER_TABLE) |
||
856 | addwf TBLPTRL, F |
||
857 | movlw HIGH(CAL_FADER_TABLE) |
||
858 | addwfc TBLPTRH, F |
||
859 | tblrd*+ |
||
860 | movff TABLAT, MIOS_PARAMETER2 |
||
861 | tblrd*+ |
||
862 | movff TABLAT, MIOS_PARAMETER3 |
||
863 | |||
864 | |||
998 | tk | 865 | ;; branch depending on selected operation mode |
866 | SET_BSR MF_BASE |
||
867 | movf MF_OPERATION_MODE, W, BANKED |
||
1071 | tk | 868 | JUMPTABLE_2BYTES 26 ; entries |
998 | tk | 869 | rgoto USER_AIN_NotifyChange_M0 ; Pitchbender Chn1..8 |
870 | rgoto USER_AIN_NotifyChange_M1 ; Pitchbender Chn9..16 |
||
871 | rgoto USER_AIN_NotifyChange_M2 ; CC7 Chn1..8 |
||
872 | rgoto USER_AIN_NotifyChange_M3 ; CC7 Chn9..16 |
||
1045 | tk | 873 | rgoto USER_AIN_NotifyChange_M4 ; CC0..7 |
874 | rgoto USER_AIN_NotifyChange_M5 ; CC8..15 |
||
875 | rgoto USER_AIN_NotifyChange_M6 ; CC16..23 |
||
876 | rgoto USER_AIN_NotifyChange_M7 ; CC24..31 |
||
877 | rgoto USER_AIN_NotifyChange_M8 ; CC32..39 |
||
878 | rgoto USER_AIN_NotifyChange_M9 ; CC40..47 |
||
879 | rgoto USER_AIN_NotifyChange_M10 ; CC48..55 |
||
880 | rgoto USER_AIN_NotifyChange_M11 ; CC56..63 |
||
881 | rgoto USER_AIN_NotifyChange_M12 ; CC64..71 |
||
882 | rgoto USER_AIN_NotifyChange_M13 ; CC72..79 |
||
883 | rgoto USER_AIN_NotifyChange_M14 ; CC80..87 |
||
884 | rgoto USER_AIN_NotifyChange_M15 ; CC88..95 |
||
885 | rgoto USER_AIN_NotifyChange_M16 ; CC96..103 |
||
886 | rgoto USER_AIN_NotifyChange_M17 ; CC104..111 |
||
887 | rgoto USER_AIN_NotifyChange_M18 ; CC112..119 |
||
888 | rgoto USER_AIN_NotifyChange_M19 ; CC120..127 |
||
889 | rgoto USER_AIN_NotifyChange_M20 ; Logic Control |
||
890 | rgoto USER_AIN_NotifyChange_M21 ; Logic Control Extension |
||
891 | rgoto USER_AIN_NotifyChange_M22 ; Mackie Control |
||
892 | rgoto USER_AIN_NotifyChange_M23 ; Mackie Control Extension |
||
1071 | tk | 893 | rgoto USER_AIN_NotifyChange_M24 ; Mackie HUI |
894 | rgoto USER_AIN_NotifyChange_M25 ; Motormix |
||
998 | tk | 895 | |
896 | |||
897 | USER_AIN_NotifyChange_M0 ; Pitchbender Chn1..8 |
||
1045 | tk | 898 | USER_AIN_NotifyChange_M20 ; Logic Control |
899 | USER_AIN_NotifyChange_M21 ; Logic Control Extension |
||
900 | USER_AIN_NotifyChange_M22 ; Mackie Control |
||
901 | USER_AIN_NotifyChange_M23 ; Mackie Control Extension |
||
998 | tk | 902 | movlw 0x00 ; channel offset |
903 | movwf TMP1 |
||
904 | rgoto USER_AIN_NotifyChange_PB |
||
905 | |||
906 | USER_AIN_NotifyChange_M1 ; Pitchbender Chn9..16 |
||
907 | movlw 0x08 ; channel offset |
||
908 | movwf TMP1 |
||
909 | ;; rgoto USER_AIN_NotifyChange_PB |
||
910 | |||
911 | USER_AIN_NotifyChange_PB ; expecting channel offset in TMP1 (0 or 8) |
||
912 | |||
955 | tk | 913 | ;; store 10-bit LSB value in LC_FADER_POS_L |
914 | movff MIOS_PARAMETER2, LC_FADER_POS_L |
||
915 | |||
916 | ;; store 10-bit MSB value in LC_FADER_POS_H |
||
917 | movff MIOS_PARAMETER3, LC_FADER_POS_H |
||
918 | |||
919 | ;; shift the values to the right position like descriped in |
||
920 | ;; the Logic Control MIDI implementation, chapter 12 |
||
921 | |||
922 | ;; 10 bit -> 14 bit (LC_FADER_POS_[LH] << 4) |
||
923 | clrc |
||
924 | rlf LC_FADER_POS_L, F ; 1 |
||
925 | rlf LC_FADER_POS_H, F |
||
926 | rlf LC_FADER_POS_L, F ; 2 |
||
927 | rlf LC_FADER_POS_H, F |
||
928 | rlf LC_FADER_POS_L, F ; 3 |
||
929 | rlf LC_FADER_POS_H, F |
||
930 | rlf LC_FADER_POS_L, F ; 4 |
||
931 | rlf LC_FADER_POS_H, F |
||
932 | |||
933 | ;; MIDI MSB: (LC_FADER_POS_H << 1) | LC_FADER_POS_L[7] |
||
934 | clrc |
||
935 | rlf LC_FADER_POS_H, W |
||
936 | btfsc LC_FADER_POS_L, 7 |
||
998 | tk | 937 | iorlw 0x01 |
955 | tk | 938 | movwf LC_FADER_POS_H |
939 | |||
940 | ;; MIDI LSB: LC_FADER_POS_L & 0x7f |
||
941 | movlw 0x7f |
||
942 | andwf LC_FADER_POS_L, F |
||
943 | |||
944 | ;; for MIDIbox Link: notify begin of stream |
||
945 | call MIOS_MIDI_BeginStream |
||
946 | |||
947 | ;; finally send value: E<fader> LSB MSB |
||
948 | movf LC_FADER_NUMBER, W |
||
998 | tk | 949 | addwf TMP1, W ; add channel offset |
955 | tk | 950 | andlw 0x0f |
951 | iorlw 0xe0 |
||
952 | call MIOS_MIDI_TxBufferPut |
||
953 | |||
954 | movf LC_FADER_POS_L, W |
||
955 | call MIOS_MIDI_TxBufferPut |
||
956 | |||
957 | movf LC_FADER_POS_H, W |
||
958 | call MIOS_MIDI_TxBufferPut |
||
959 | |||
960 | ;; for MIDIbox Link: notify end of stream |
||
961 | call MIOS_MIDI_EndStream |
||
998 | tk | 962 | |
963 | rgoto LC_MF_FaderEvent_End |
||
964 | |||
955 | tk | 965 | |
998 | tk | 966 | ;; --------------------------------------------------------- |
967 | USER_AIN_NotifyChange_M2 ; CC7 Chn1..8 |
||
968 | ;; for MIDIbox Link: notify begin of stream |
||
969 | call MIOS_MIDI_BeginStream |
||
970 | |||
971 | ;; finally send value: E<fader> LSB MSB |
||
972 | movf LC_FADER_NUMBER, W |
||
973 | andlw 0x0f |
||
974 | iorlw 0xb0 |
||
975 | call MIOS_MIDI_TxBufferPut |
||
976 | |||
977 | movlw 0x07 |
||
978 | call MIOS_MIDI_TxBufferPut |
||
979 | |||
980 | movf LC_FADER_NUMBER, W |
||
981 | call MIOS_AIN_Pin7bitGet |
||
982 | call MIOS_MIDI_TxBufferPut |
||
983 | |||
984 | ;; for MIDIbox Link: notify end of stream |
||
985 | call MIOS_MIDI_EndStream |
||
986 | |||
987 | rgoto LC_MF_FaderEvent_End |
||
988 | |||
989 | ;; --------------------------------------------------------- |
||
990 | USER_AIN_NotifyChange_M3 ; CC7 Chn9..16 |
||
991 | ;; for MIDIbox Link: notify begin of stream |
||
992 | call MIOS_MIDI_BeginStream |
||
993 | |||
994 | ;; finally send value: E<fader> LSB MSB |
||
995 | movf LC_FADER_NUMBER, W |
||
996 | addlw 8 |
||
997 | andlw 0x0f |
||
998 | iorlw 0xb0 |
||
999 | call MIOS_MIDI_TxBufferPut |
||
1000 | |||
1001 | movlw 0x07 |
||
1002 | call MIOS_MIDI_TxBufferPut |
||
1003 | |||
1004 | movf LC_FADER_NUMBER, W |
||
1005 | call MIOS_AIN_Pin7bitGet |
||
1006 | call MIOS_MIDI_TxBufferPut |
||
1007 | |||
1008 | ;; for MIDIbox Link: notify end of stream |
||
1009 | call MIOS_MIDI_EndStream |
||
1010 | |||
1011 | rgoto LC_MF_FaderEvent_End |
||
1012 | |||
1013 | ;; --------------------------------------------------------- |
||
1045 | tk | 1014 | USER_AIN_NotifyChange_M4 ; CC0..7 |
1015 | USER_AIN_NotifyChange_M5 ; CC8..15 |
||
1016 | USER_AIN_NotifyChange_M6 ; CC16..23 |
||
1017 | USER_AIN_NotifyChange_M7 ; CC24..31 |
||
1018 | USER_AIN_NotifyChange_M8 ; CC32..39 |
||
1019 | USER_AIN_NotifyChange_M9 ; CC40..47 |
||
1020 | USER_AIN_NotifyChange_M10 ; CC48..55 |
||
1021 | USER_AIN_NotifyChange_M11 ; CC56..63 |
||
1022 | USER_AIN_NotifyChange_M12 ; CC64..71 |
||
1023 | USER_AIN_NotifyChange_M13 ; CC72..79 |
||
1024 | USER_AIN_NotifyChange_M14 ; CC80..87 |
||
1025 | USER_AIN_NotifyChange_M15 ; CC88..95 |
||
1026 | USER_AIN_NotifyChange_M16 ; CC96..103 |
||
1027 | USER_AIN_NotifyChange_M17 ; CC104..111 |
||
1028 | USER_AIN_NotifyChange_M18 ; CC112..119 |
||
1029 | USER_AIN_NotifyChange_M19 ; CC120..127 |
||
998 | tk | 1030 | ;; for MIDIbox Link: notify begin of stream |
1031 | call MIOS_MIDI_BeginStream |
||
1032 | |||
1074 | tk | 1033 | ;; finally send value: Bn CC MSB |
1034 | movf MIDI_CHANNEL, W |
||
1035 | andlw 0x0f |
||
1036 | iorlw 0xb0 |
||
998 | tk | 1037 | call MIOS_MIDI_TxBufferPut |
1038 | |||
1045 | tk | 1039 | movff MF_OPERATION_MODE, WREG |
1040 | addlw -4 |
||
1041 | rlf WREG, W |
||
1042 | rlf WREG, W |
||
1043 | rlf WREG, W |
||
1044 | andlw 0x78 |
||
1045 | addwf LC_FADER_NUMBER, W |
||
998 | tk | 1046 | call MIOS_MIDI_TxBufferPut |
1047 | |||
1048 | movf LC_FADER_NUMBER, W |
||
1049 | call MIOS_AIN_Pin7bitGet |
||
1050 | call MIOS_MIDI_TxBufferPut |
||
1051 | |||
1052 | ;; for MIDIbox Link: notify end of stream |
||
1053 | call MIOS_MIDI_EndStream |
||
1054 | |||
1055 | rgoto LC_MF_FaderEvent_End |
||
1056 | |||
1071 | tk | 1057 | |
1058 | ;; --------------------------------------------------------- |
||
1059 | USER_AIN_NotifyChange_M24 ; Mackie HUI |
||
1060 | USER_AIN_NotifyChange_M25 ; Motormix |
||
1061 | ;; store 10-bit LSB value in LC_FADER_POS_L |
||
1062 | movff MIOS_PARAMETER2, LC_FADER_POS_L |
||
1063 | |||
1064 | ;; store 10-bit MSB value in LC_FADER_POS_H |
||
1065 | movff MIOS_PARAMETER3, LC_FADER_POS_H |
||
1066 | |||
1067 | ;; shift the values to the right position like descriped in |
||
1068 | ;; the Logic Control MIDI implementation, chapter 12 |
||
1069 | |||
1070 | ;; 10 bit -> 14 bit (LC_FADER_POS_[LH] << 4) |
||
1071 | clrc |
||
1072 | rlf LC_FADER_POS_L, F ; 1 |
||
1073 | rlf LC_FADER_POS_H, F |
||
1074 | rlf LC_FADER_POS_L, F ; 2 |
||
1075 | rlf LC_FADER_POS_H, F |
||
1076 | rlf LC_FADER_POS_L, F ; 3 |
||
1077 | rlf LC_FADER_POS_H, F |
||
1078 | rlf LC_FADER_POS_L, F ; 4 |
||
1079 | rlf LC_FADER_POS_H, F |
||
1080 | |||
1081 | ;; MIDI MSB: (LC_FADER_POS_H << 1) | LC_FADER_POS_L[7] |
||
1082 | clrc |
||
1083 | rlf LC_FADER_POS_H, W |
||
1084 | btfsc LC_FADER_POS_L, 7 |
||
1085 | iorlw 0x01 |
||
1086 | movwf LC_FADER_POS_H |
||
1087 | |||
1088 | ;; MIDI LSB: LC_FADER_POS_L & 0x7f |
||
1089 | movlw 0x7f |
||
1090 | andwf LC_FADER_POS_L, F |
||
1091 | |||
1092 | ;; for MIDIbox Link: notify begin of stream |
||
1093 | call MIOS_MIDI_BeginStream |
||
1094 | |||
1074 | tk | 1095 | ;; finally send value: Bn 0<fader> MSB 2<fader> LSB |
1096 | movf MIDI_CHANNEL, W |
||
1097 | andlw 0x0f |
||
1098 | iorlw 0xb0 |
||
1071 | tk | 1099 | call MIOS_MIDI_TxBufferPut |
1100 | |||
1101 | movf LC_FADER_NUMBER, W |
||
1102 | call MIOS_MIDI_TxBufferPut |
||
1103 | |||
1104 | movf LC_FADER_POS_H, W |
||
1105 | call MIOS_MIDI_TxBufferPut |
||
1106 | |||
1107 | movf LC_FADER_NUMBER, W |
||
1108 | iorlw 0x20 |
||
1109 | call MIOS_MIDI_TxBufferPut |
||
1110 | |||
1111 | movf LC_FADER_POS_L, W |
||
1112 | call MIOS_MIDI_TxBufferPut |
||
1113 | |||
1114 | ;; for MIDIbox Link: notify end of stream |
||
1115 | call MIOS_MIDI_EndStream |
||
1116 | |||
1117 | rgoto LC_MF_FaderEvent_End |
||
998 | tk | 1118 | |
1071 | tk | 1119 | |
998 | tk | 1120 | ;; --------------------------------------------------------- |
955 | tk | 1121 | LC_MF_FaderEvent_End |
1122 | ;; thats all |
||
1123 | return |
||
1124 | |||
1177 | tk | 1125 | ;; ---[ Calibration Tables ]--- |
955 | tk | 1126 | |
1177 | tk | 1127 | org 0x6000 |
1128 | CAL_MOTOR_TABLE |
||
1129 | #include "cal_motor.inc" |
||
1130 | |||
1131 | org 0x6800 |
||
1132 | CAL_FADER_TABLE |
||
1133 | #include "cal_fader.inc" |
||
1134 | |||
1135 | |||
955 | tk | 1136 | ;; ---[ EEPROM content ]--- |
1137 | #include "mf_presets.inc" |
||
1138 | |||
1177 | tk | 1139 | |
955 | tk | 1140 | END |