;; BEGIN inserted by fixasm.pl
;; MPASM workarounds:
BANKED  EQU 1
;; END inserted by fixasm.pl
;--------------------------------------------------------
; File Created by SDCC : FreeWare ANSI-C Compiler
; Version 2.5.0 #1020 (May  8 2005)
; This file generated Sat Feb 10 01:08:16 2007
;--------------------------------------------------------
; PIC16 port for the Microchip 16-bit core micros
;--------------------------------------------------------
	list	p=18f452

	radix dec

;--------------------------------------------------------
; extern variables in this module
;--------------------------------------------------------
	extern _MIOS_BOX_CFG0
	extern _MIOS_BOX_CFG1
	extern _MIOS_BOX_STAT
	extern _MIOS_PARAMETER1
	extern _MIOS_PARAMETER2
	extern _MIOS_PARAMETER3
	extern _PORTAbits
	extern _PORTBbits
	extern _PORTCbits
	extern _PORTDbits
	extern _PORTEbits
	extern _LATAbits
	extern _LATBbits
	extern _LATCbits
	extern _LATDbits
	extern _LATEbits
	extern _TRISAbits
	extern _TRISBbits
	extern _TRISCbits
	extern _TRISDbits
	extern _TRISEbits
	extern _PIE1bits
	extern _PIR1bits
	extern _IPR1bits
	extern _PIE2bits
	extern _PIR2bits
	extern _IPR2bits
	extern _EECON1bits
	extern _RCSTAbits
	extern _TXSTAbits
	extern _T3CONbits
	extern _CCP2CONbits
	extern _CCP1CONbits
	extern _ADCON1bits
	extern _ADCON0bits
	extern _SSPCON2bits
	extern _SSPCON1bits
	extern _SSPSTATbits
	extern _T2CONbits
	extern _T1CONbits
	extern _RCONbits
	extern _WDTCONbits
	extern _LVDCONbits
	extern _OSCCONbits
	extern _T0CONbits
	extern _STATUSbits
	extern _INTCON3bits
	extern _INTCON2bits
	extern _INTCONbits
	extern _STKPTRbits
	extern _mclock_state
	extern _mclock_pin_state
	extern _mclock_ctr_24
	extern _mclock_ctr_beats
	extern _mclock_ctr_measures
	extern _sm_button_column
	extern _sm_button_row
	extern _sm_button_value
	extern _PORTA
	extern _PORTB
	extern _PORTC
	extern _PORTD
	extern _PORTE
	extern _LATA
	extern _LATB
	extern _LATC
	extern _LATD
	extern _LATE
	extern _TRISA
	extern _TRISB
	extern _TRISC
	extern _TRISD
	extern _TRISE
	extern _PIE1
	extern _PIR1
	extern _IPR1
	extern _PIE2
	extern _PIR2
	extern _IPR2
	extern _EECON1
	extern _EECON2
	extern _EEDATA
	extern _EEADR
	extern _RCSTA
	extern _TXSTA
	extern _TXREG
	extern _RCREG
	extern _SPBRG
	extern _T3CON
	extern _TMR3L
	extern _TMR3H
	extern _CCP2CON
	extern _CCPR2L
	extern _CCPR2H
	extern _CCP1CON
	extern _CCPR1L
	extern _CCPR1H
	extern _ADCON1
	extern _ADCON0
	extern _ADRESL
	extern _ADRESH
	extern _SSPCON2
	extern _SSPCON1
	extern _SSPSTAT
	extern _SSPADD
	extern _SSPBUF
	extern _T2CON
	extern _PR2
	extern _TMR2
	extern _T1CON
	extern _TMR1L
	extern _TMR1H
	extern _RCON
	extern _WDTCON
	extern _LVDCON
	extern _OSCCON
	extern _T0CON
	extern _TMR0L
	extern _TMR0H
	extern _STATUS
	extern _FSR2L
	extern _FSR2H
	extern _PLUSW2
	extern _PREINC2
	extern _POSTDEC2
	extern _POSTINC2
	extern _INDF2
	extern _BSR
	extern _FSR1L
	extern _FSR1H
	extern _PLUSW1
	extern _PREINC1
	extern _POSTDEC1
	extern _POSTINC1
	extern _INDF1
	extern _WREG
	extern _FSR0L
	extern _FSR0H
	extern _PLUSW0
	extern _PREINC0
	extern _POSTDEC0
	extern _POSTINC0
	extern _INDF0
	extern _INTCON3
	extern _INTCON2
	extern _INTCON
	extern _PRODL
	extern _PRODH
	extern _TABLAT
	extern _TBLPTRL
	extern _TBLPTRH
	extern _TBLPTRU
	extern _PCL
	extern _PCLATH
	extern _PCLATU
	extern _STKPTR
	extern _TOSL
	extern _TOSH
	extern _TOSU
	extern _MIOS_MIDI_TxBufferPut
	extern _MIOS_AIN_DeadbandSet
	extern _MIOS_AIN_NumberSet
	extern _MIOS_AIN_UnMuxed
	extern _MIOS_DOUT_SRSet
	extern _MIOS_SRIO_NumberSet
	extern _MIOS_SRIO_TS_SensitivitySet
	extern _MIOS_SRIO_UpdateFrqSet
	extern _MIOS_LCD_CursorSet
	extern _MIOS_LCD_PrintBCD1
	extern _MIOS_LCD_PrintBCD2
	extern _MIOS_LCD_PrintBCD3
	extern _MIOS_LCD_PrintCString
	extern _MIOS_CLCD_SpecialCharsInit
	extern _MCLOCK_Init
	extern _MCLOCK_Tick
	extern _MCLOCK_Timer
	extern _MCLOCK_BPMSet
	extern _MCLOCK_DoStop
	extern _MCLOCK_DoPlay
	extern _SM_Init
	extern _SM_PrepareCol
	extern _SM_GetRow
	extern _SM_ButtonHandler
	extern _MIOS_MPROC_EVENT_TABLE
	extern _MIOS_ENC_PIN_TABLE

;--------------------------------------------------------
; public variables in this module
;--------------------------------------------------------
	global _pg
	global _hold2
	global _hold1
	global _lastep
	global _pattern
	global _PUSH
	global _SM_NotifyToggle
	global _midi_channel
	global _transpose
	global _last_mx_pin
	global _prg
	global __tik
	global _step
	global _app_flags
	global _kb
	global _led_num
	global _Init
	global _PRG_CHNG
	global _CTROL
	global _ALL_NOTE_OFF
	global _KEY_NOTE
	global _GET_NCHR
	global _Tick
	global _Timer
	global _DISPLAY_Init
	global _DISPLAY_Tick
	global _MPROC_NotifyReceivedEvnt
	global _MPROC_NotifyFoundEvent
	global _MPROC_NotifyTimeout
	global _MPROC_NotifyReceivedByte
	global _SR_Service_Prepare
	global _SR_Service_Finish
	global _DIN_NotifyToggle
	global _ENC_NotifyChange
	global _note_map
	global _lcd_charset
	global _led_pos
	global _chans
	global _patchans
	global _note_name
;--------------------------------------------------------
;	Equates to used internal registers
;--------------------------------------------------------
STATUS	equ	0xfd8
WREG	equ	0xfe8
TBLPTRL	equ	0xff6
TBLPTRH	equ	0xff7
TBLPTRU	equ	0xff8
TABLAT	equ	0xff5
FSR0L	equ	0xfe1 ;; normaly 0xfe9, changed by fixasm.pl
FSR0H	equ	0xfe2 ;; normaly 0xfea, changed by fixasm.pl
FSR1L	equ	0xfe9 ;; normaly 0xfe1, changed by fixasm.pl
FSR2L	equ	0xfd9
INDF0	equ	0xfe7 ;; normaly 0xfef, changed by fixasm.pl
POSTDEC1	equ	0xfed ;; normaly 0xfe5, changed by fixasm.pl
PREINC1	equ	0xfec ;; normaly 0xfe4, changed by fixasm.pl
PLUSW2	equ	0xfdb
PRODL	equ	0xff3
PRODH	equ	0xff4


	idata
_midi_channel	db	0x00
_transpose	db	0x00
__tik	db	0x00
_step	db	0x00
_lastep	db	0x00


; Internal registers
.registers	udata_ovr	0x010
r0x00	res	1
r0x01	res	1
r0x02	res	1
r0x03	res	1
r0x04	res	1
r0x05	res	1
r0x06	res	1

udata_main_0	udata
_pattern	res	256

udata_main_1	udata
_hold1	res	16

udata_main_2	udata
_hold2	res	16

udata_main_3	udata
_pg	res	1

udata_main_4	udata
_prg	res	16

udata_main_5	udata
_last_mx_pin	res	1

udata_main_6	udata
_app_flags	res	1

udata_main_7	udata
_kb	res	1

;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
; I code from now on!
; ; Starting pCode block
S_main__SM_NotifyToggle	code
_SM_NotifyToggle:
;	.line	231; main.c	void SM_NotifyToggle(unsigned char pin, unsigned char value) __wparam
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVWF	r0x00
	MOVLW	0x02
	MOVFF	PLUSW2, r0x01
;	.line	233; main.c	last_mx_pin=pin;		//MAP KEYBOARD
	MOVFF	r0x00, _last_mx_pin
;	.line	288; main.c	switch(pin){//SPECIAL KEYS
	MOVF	r0x00, W
	BNZ	_00394_DS_
	BRA	_00366_DS_
_00394_DS_:
	MOVF	r0x00, W
	XORLW	0x04
	BNZ	_00396_DS_
	BRA	_00364_DS_
_00396_DS_:
	MOVF	r0x00, W
	XORLW	0x05
	BNZ	_00398_DS_
	BRA	_00363_DS_
_00398_DS_:
	MOVF	r0x00, W
	XORLW	0x06
	BNZ	_00400_DS_
	BRA	_00362_DS_
_00400_DS_:
	MOVF	r0x00, W
	XORLW	0x07
	BNZ	_00402_DS_
	BRA	_00361_DS_
_00402_DS_:
	MOVF	r0x00, W
	XORLW	0x0c
	BNZ	_00404_DS_
	BRA	_00353_DS_
_00404_DS_:
	MOVF	r0x00, W
	XORLW	0x0f
	BNZ	_00406_DS_
	BRA	_00357_DS_
_00406_DS_:
	MOVF	r0x00, W
	XORLW	0x3a
	BZ	_00341_DS_
	MOVF	r0x00, W
	XORLW	0x3b
	BZ	_00335_DS_
	MOVF	r0x00, W
	XORLW	0x3c
	BZ	_00349_DS_
	MOVF	r0x00, W
	XORLW	0x3d
	BZ	_00345_DS_
	BRA	_00366_DS_
_00335_DS_:
;	.line	291; main.c	if(!value)return;
	MOVF	r0x01, W
	BNZ	_00337_DS_
	BRA	_00371_DS_
_00337_DS_:
;	.line	292; main.c	if(kb.RUNSTOP==0){//PLAY
	CLRF	WREG
	BANKSEL	_kb
	BTFSC	_kb, 6, B
	INCF	WREG, F
	MOVWF	r0x02
	MOVF	r0x02, W
	BNZ	_00339_DS_
_00416_DS_:
	BANKSEL	_kb
;	.line	293; main.c	kb.RUNSTOP=1;
	BSF	_kb, 6, B
;	.line	294; main.c	MCLOCK_DoPlay();
	CALL	_MCLOCK_DoPlay
	BRA	_00366_DS_
_00339_DS_:
	BANKSEL	_kb
;	.line	296; main.c	kb.RUNSTOP=0;
	BCF	_kb, 6, B
;	.line	297; main.c	MCLOCK_DoStop();
	CALL	_MCLOCK_DoStop
	BANKSEL	__tik
;	.line	298; main.c	_tik=0;//16 step reset
	CLRF	__tik, B
	BANKSEL	_step
;	.line	299; main.c	step=0;//16 step reset
	CLRF	_step, B
;	.line	301; main.c	break;
	BRA	_00366_DS_
_00341_DS_:
;	.line	307; main.c	case 58:if(value){kb.CTRL=0; }else{kb.CTRL=1;}break;//CTRL
	MOVF	r0x01, W
	BZ	_00343_DS_
	BANKSEL	_kb
	BCF	_kb, 0, B
	BRA	_00366_DS_
_00343_DS_:
	BANKSEL	_kb
	BSF	_kb, 0, B
	BRA	_00366_DS_
_00345_DS_:
;	.line	308; main.c	case 61:if(value){kb.COMMODORE=0;}else{kb.COMMODORE=1;}break;//COMMODORE
	MOVF	r0x01, W
	BZ	_00347_DS_
	BANKSEL	_kb
	BCF	_kb, 4, B
	BRA	_00366_DS_
_00347_DS_:
	BANKSEL	_kb
	BSF	_kb, 4, B
	BRA	_00366_DS_
_00349_DS_:
;	.line	309; main.c	case 60:if(value){kb.SPACE=0;}else{kb.SPACE=1;}break;//SPACE
	MOVF	r0x01, W
	BZ	_00351_DS_
	BANKSEL	_kb
	BCF	_kb, 5, B
	BRA	_00366_DS_
_00351_DS_:
	BANKSEL	_kb
	BSF	_kb, 5, B
	BRA	_00366_DS_
_00353_DS_:
;	.line	310; main.c	case 12:if(value){kb.RSHIFT=0;}else{kb.RSHIFT=1;}break;//RSHIFT
	MOVF	r0x01, W
	BZ	_00355_DS_
	BANKSEL	_kb
	BCF	_kb, 1, B
	BRA	_00366_DS_
_00355_DS_:
	BANKSEL	_kb
	BSF	_kb, 1, B
	BRA	_00366_DS_
_00357_DS_:
;	.line	311; main.c	case 15:if(value){kb.LSHIFT=0;}else{kb.LSHIFT=1;}break;//LSHIFT
	MOVF	r0x01, W
	BZ	_00359_DS_
	BANKSEL	_kb
	BCF	_kb, 2, B
	BRA	_00366_DS_
_00359_DS_:
	BANKSEL	_kb
	BSF	_kb, 2, B
	BRA	_00366_DS_
_00361_DS_:
;	.line	313; main.c	case 7:transpose=72;break;// F1-F2
	MOVLW	0x48
	BANKSEL	_transpose
	MOVWF	_transpose, B
	BRA	_00366_DS_
_00362_DS_:
;	.line	314; main.c	case 6:transpose=60;break;// F3-F4
	MOVLW	0x3c
	BANKSEL	_transpose
	MOVWF	_transpose, B
	BRA	_00366_DS_
_00363_DS_:
;	.line	315; main.c	case 5:transpose=48;break;// F5-F6
	MOVLW	0x30
	BANKSEL	_transpose
	MOVWF	_transpose, B
	BRA	_00366_DS_
_00364_DS_:
;	.line	316; main.c	case 4:transpose=36;break;// F7-F8
	MOVLW	0x24
	BANKSEL	_transpose
	MOVWF	_transpose, B
_00366_DS_:
;	.line	324; main.c	if(kb.CTRL==1){if(value)CTROL(pin);return;}// (keyboard.c)
	CLRF	WREG
	BANKSEL	_kb
	BTFSC	_kb, 0, B
	INCF	WREG, F
	MOVWF	r0x02
	MOVF	r0x02, W
	XORLW	0x01
	BNZ	_00370_DS_
	MOVF	r0x01, W
	BZ	_00368_DS_
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	CALL	_CTROL
	INCF	FSR1L, F
_00368_DS_:
	BRA	_00371_DS_
_00370_DS_:
;	.line	333; main.c	KEY_NOTE(value);//FREE PLAY (freeplay.c)
	MOVF	r0x01, W
	MOVWF	POSTDEC1
	CALL	_KEY_NOTE
	INCF	FSR1L, F
_00371_DS_:
;	.line	335; main.c	return;
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_main__ENC_NotifyChange	code
_ENC_NotifyChange:
;	.line	215; main.c	void ENC_NotifyChange(unsigned char encoder, char incrementer) __wparam
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
;	.line	217; main.c	}
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_main__DIN_NotifyToggle	code
_DIN_NotifyToggle:
;	.line	206; main.c	void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
;	.line	208; main.c	}
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_main__SR_Service_Finish	code
_SR_Service_Finish:
;	.line	199; main.c	SM_GetRow();
	CALL	_SM_GetRow
	RETURN	

; ; Starting pCode block
S_main__SR_Service_Prepare	code
_SR_Service_Prepare:
	BANKSEL	_mclock_pin_state
;	.line	173; main.c	if( mclock_pin_state.CLK_REQ ) {// Send one byte on j14 :)
	BTFSS	_mclock_pin_state, 0, B
	BRA	_00317_DS_
; removed redundant BANKSEL
;	.line	174; main.c	mclock_pin_state.CLK_REQ = 0;
	BCF	_mclock_pin_state, 0, B
;	.line	175; main.c	PORTDbits.RD4 = 1;    PORTDbits.RD4 = 0;
	BSF	_PORTDbits, 4
	BCF	_PORTDbits, 4
;	.line	176; main.c	PORTDbits.RD4 = 1;    PORTDbits.RD4 = 0;
	BSF	_PORTDbits, 4
	BCF	_PORTDbits, 4
;	.line	177; main.c	PORTDbits.RD4 = 1;    PORTDbits.RD4 = 0;
	BSF	_PORTDbits, 4
	BCF	_PORTDbits, 4
;	.line	178; main.c	PORTDbits.RD4 = 1;    PORTDbits.RD4 = 0;
	BSF	_PORTDbits, 4
	BCF	_PORTDbits, 4
;	.line	179; main.c	PORTDbits.RD4 = 1;    PORTDbits.RD4 = 0;
	BSF	_PORTDbits, 4
	BCF	_PORTDbits, 4
;	.line	180; main.c	PORTDbits.RD4 = 1;    PORTDbits.RD4 = 0;
	BSF	_PORTDbits, 4
	BCF	_PORTDbits, 4
;	.line	181; main.c	PORTDbits.RD4 = 1;    PORTDbits.RD4 = 0;
	BSF	_PORTDbits, 4
	BCF	_PORTDbits, 4
;	.line	182; main.c	PORTDbits.RD4 = 1;    PORTDbits.RD4 = 0;
	BSF	_PORTDbits, 4
	BCF	_PORTDbits, 4
	BRA	_00318_DS_
_00317_DS_:
;	.line	184; main.c	PORTDbits.RD4 = 0;
	BCF	_PORTDbits, 4
_00318_DS_:
;	.line	189; main.c	SM_PrepareCol();
	CALL	_SM_PrepareCol
	RETURN	

; ; Starting pCode block
S_main__MPROC_NotifyReceivedByte	code
_MPROC_NotifyReceivedByte:
;	.line	162; main.c	void MPROC_NotifyReceivedByte(unsigned char byte) __wparam
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
;	.line	164; main.c	}
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_main__MPROC_NotifyTimeout	code
_MPROC_NotifyTimeout:
;	.line	157; main.c	}
	RETURN	

; ; Starting pCode block
S_main__MPROC_NotifyFoundEvent	code
_MPROC_NotifyFoundEvent:
;	.line	147; main.c	void MPROC_NotifyFoundEvent(unsigned entry, unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
;	.line	149; main.c	}
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_main__MPROC_NotifyReceivedEvnt	code
_MPROC_NotifyReceivedEvnt:
;	.line	139; main.c	void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
;	.line	141; main.c	}
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_main__DISPLAY_Tick	code
_DISPLAY_Tick:
	BANKSEL	_app_flags
;	.line	109; main.c	if( !app_flags.DISPLAY_UPDATE_REQ )
	BTFSC	_app_flags, 0, B
	BRA	_00294_DS_
;	.line	110; main.c	return;
	BRA	_00295_DS_
_00294_DS_:
	BANKSEL	_app_flags
;	.line	111; main.c	app_flags.DISPLAY_UPDATE_REQ = 0;
	BCF	_app_flags, 0, B
_00295_DS_:
	RETURN	

; ; Starting pCode block
S_main__DISPLAY_Init	code
_DISPLAY_Init:
	BANKSEL	_app_flags
;	.line	93; main.c	app_flags.DISPLAY_UPDATE_REQ = 1;
	BSF	_app_flags, 0, B
;	.line	94; main.c	led_num(0);//LITE LED 1
	MOVLW	0x00
	MOVWF	POSTDEC1
	CALL	_led_num
	INCF	FSR1L, F
;	.line	95; main.c	MIOS_LCD_CursorSet(0x00);
	MOVLW	0x00
	CALL	_MIOS_LCD_CursorSet
;	.line	96; main.c	MIOS_LCD_PrintCString(" .: SIDABITBOX64 :. ");
	MOVLW	UPPER(__str_6)
	MOVWF	POSTDEC1
	MOVLW	HIGH(__str_6)
	MOVWF	POSTDEC1
	MOVLW	LOW(__str_6)
	CALL	_MIOS_LCD_PrintCString
	MOVLW	0x02
	ADDWF	FSR1L, F
	RETURN	

; ; Starting pCode block
S_main__Timer	code
_Timer:
;	.line	81; main.c	MCLOCK_Timer();
	CALL	_MCLOCK_Timer
	RETURN	

; ; Starting pCode block
S_main__Tick	code
_Tick:
;	.line	69; main.c	SM_ButtonHandler();
	CALL	_SM_ButtonHandler
;	.line	71; main.c	MCLOCK_Tick();
	CALL	_MCLOCK_Tick
	RETURN	

; ; Starting pCode block
S_main__GET_NCHR	code
_GET_NCHR:
;	.line	70; freeplay.c	void GET_NCHR(unsigned char note){// DISPLAY LITTERAL NOTES !!!
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
;	.line	75; freeplay.c	if(note==0x80){
	MOVF	r0x00, W
	XORLW	0x80
	BNZ	_00261_DS_
;	.line	76; freeplay.c	MIOS_LCD_CursorSet(0x51);
	MOVLW	0x51
	CALL	_MIOS_LCD_CursorSet
;	.line	77; freeplay.c	MIOS_LCD_PrintCString("NUL");//
	MOVLW	UPPER(__str_4)
	MOVWF	POSTDEC1
	MOVLW	HIGH(__str_4)
	MOVWF	POSTDEC1
	MOVLW	LOW(__str_4)
	CALL	_MIOS_LCD_PrintCString
	MOVLW	0x02
	ADDWF	FSR1L, F
;	.line	78; freeplay.c	return;
	BRA	_00267_DS_
_00261_DS_:
;	.line	81; freeplay.c	if(note==0x81){
	MOVF	r0x00, W
	XORLW	0x81
	BNZ	_00271_DS_
;	.line	82; freeplay.c	MIOS_LCD_CursorSet(0x51);
	MOVLW	0x51
	CALL	_MIOS_LCD_CursorSet
;	.line	83; freeplay.c	MIOS_LCD_PrintCString("PAD");//
	MOVLW	UPPER(__str_5)
	MOVWF	POSTDEC1
	MOVLW	HIGH(__str_5)
	MOVWF	POSTDEC1
	MOVLW	LOW(__str_5)
	CALL	_MIOS_LCD_PrintCString
	MOVLW	0x02
	ADDWF	FSR1L, F
;	.line	84; freeplay.c	return;
	BRA	_00267_DS_
_00271_DS_:
;	.line	87; freeplay.c	do{
	CLRF	r0x01
	CLRF	r0x02
_00264_DS_:
;	.line	88; freeplay.c	oct++;
	MOVLW	0x0c
	ADDWF	r0x02, F
	INCF	r0x01, F
;	.line	92; freeplay.c	while(n<=note);
	MOVF	r0x02, W
	SUBWF	r0x00, W
	BC	_00264_DS_
;	.line	93; freeplay.c	oct--;
	DECF	r0x01, F
;	.line	96; freeplay.c	MIOS_LCD_CursorSet(0x51);
	MOVLW	0x51
	CALL	_MIOS_LCD_CursorSet
; ;multiply lit val:0X0c by variable r0x01 and store in r0x02
; ;Unrolled 8 X 8 multiplication
; ;FIXME: the function does not support result==WREG
;	.line	97; freeplay.c	MIOS_LCD_PrintCString(note_name[note-12*oct]);//
	MOVF	r0x01, W
	MULLW	0x0c
	MOVFF	PRODL, r0x02
	MOVF	r0x02, W
	SUBWF	r0x00, F
; ;multiply lit val:0X03 by variable r0x00 and store in r0x00
; ;Unrolled 8 X 8 multiplication
; ;FIXME: the function does not support result==WREG
	MOVF	r0x00, W
	MULLW	0x03
	MOVFF	PRODL, r0x00
	MOVFF	PRODH, r0x02
	MOVLW	LOW(_note_name)
	ADDWF	r0x00, F
	MOVLW	HIGH(_note_name)
	ADDWFC	r0x02, F
	MOVLW	UPPER(_note_name)
	CLRF	r0x03
	ADDWFC	r0x03, F
	MOVF	r0x03, W
	MOVWF	POSTDEC1
	MOVF	r0x02, W
	MOVWF	POSTDEC1
	MOVF	r0x00, W
	CALL	_MIOS_LCD_PrintCString
	MOVLW	0x02
	ADDWF	FSR1L, F
;	.line	98; freeplay.c	MIOS_LCD_PrintBCD1(oct);
	MOVF	r0x01, W
	CALL	_MIOS_LCD_PrintBCD1
_00267_DS_:
;	.line	99; freeplay.c	return ; 
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_main__KEY_NOTE	code
_KEY_NOTE:
;	.line	22; freeplay.c	void KEY_NOTE(unsigned char value) // SEND A NOTE ON KEY PRESS
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	MOVFF	r0x05, POSTDEC1
	MOVFF	r0x06, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
	BANKSEL	_last_mx_pin
;	.line	26; freeplay.c	if(last_mx_pin==0){
	MOVF	_last_mx_pin, W, B
	BNZ	_00242_DS_
;	.line	27; freeplay.c	MIOS_LCD_CursorSet(0x00);	
	MOVLW	0x00
	CALL	_MIOS_LCD_CursorSet
;	.line	28; freeplay.c	MIOS_LCD_PrintCString("ALL NOTES OFF");
	MOVLW	UPPER(__str_3)
	MOVWF	POSTDEC1
	MOVLW	HIGH(__str_3)
	MOVWF	POSTDEC1
	MOVLW	LOW(__str_3)
	CALL	_MIOS_LCD_PrintCString
	MOVLW	0x02
	ADDWF	FSR1L, F
;	.line	29; freeplay.c	ALL_NOTE_OFF();
	CALL	_ALL_NOTE_OFF
;	.line	30; freeplay.c	return;
	BRA	_00245_DS_
; ;multiply lit val:0X02 by variable _last_mx_pin and store in r0x01
; ;Unrolled 8 X 8 multiplication
; ;FIXME: the function does not support result==WREG
_00242_DS_:
;	.line	44; freeplay.c	if(note_map[last_mx_pin][0]==0x80){
	CLRF	r0x02
	BCF	STATUS, 0
	BANKSEL	_last_mx_pin
	RLCF	_last_mx_pin, W, B
	MOVWF	r0x01
	RLCF	r0x02, F
	MOVLW	LOW(_note_map)
	ADDWF	r0x01, F
	MOVLW	HIGH(_note_map)
	ADDWFC	r0x02, F
	MOVLW	UPPER(_note_map)
	CLRF	r0x03
	ADDWFC	r0x03, F
	MOVFF	r0x01, TBLPTRL
	MOVFF	r0x02, TBLPTRH
	MOVFF	r0x03, TBLPTRU
	TBLRD*+	
	MOVFF	TABLAT, r0x01
	MOVF	r0x01, W
	XORLW	0x80
;	.line	50; freeplay.c	return;//Do not send stupid datas !
	BZ	_00245_DS_
;	.line	54; freeplay.c	MIOS_MIDI_TxBufferPut(144 + midi_channel);
	MOVLW	0x90
	BANKSEL	_midi_channel
	ADDWF	_midi_channel, W, B
	MOVWF	r0x01
	MOVF	r0x01, W
	CALL	_MIOS_MIDI_TxBufferPut
; ;multiply lit val:0X02 by variable _last_mx_pin and store in r0x01
; ;Unrolled 8 X 8 multiplication
; ;FIXME: the function does not support result==WREG
;	.line	55; freeplay.c	MIOS_MIDI_TxBufferPut(note_map[last_mx_pin][0]+transpose);
	CLRF	r0x04
	BCF	STATUS, 0
	BANKSEL	_last_mx_pin
	RLCF	_last_mx_pin, W, B
	MOVWF	r0x01
	RLCF	r0x04, F
	MOVLW	LOW(_note_map)
	ADDWF	r0x01, F
	MOVLW	HIGH(_note_map)
	ADDWFC	r0x04, F
	MOVLW	UPPER(_note_map)
	CLRF	r0x05
	ADDWFC	r0x05, F
	MOVFF	r0x01, TBLPTRL
	MOVFF	r0x04, TBLPTRH
	MOVFF	r0x05, TBLPTRU
	TBLRD*+	
	MOVFF	TABLAT, r0x01
	MOVFF	_transpose, r0x06
	MOVF	r0x06, W
	ADDWF	r0x01, F
	MOVF	r0x01, W
	CALL	_MIOS_MIDI_TxBufferPut
;	.line	56; freeplay.c	MIOS_MIDI_TxBufferPut(value ? 0x00 : 0x7F);
	MOVF	r0x00, W
	BZ	_00247_DS_
	CLRF	r0x00
	BRA	_00248_DS_
_00247_DS_:
	MOVLW	0x7f
	MOVWF	r0x00
_00248_DS_:
	MOVF	r0x00, W
	CALL	_MIOS_MIDI_TxBufferPut
_00245_DS_:
;	.line	60; freeplay.c	return ; 
	MOVFF	PREINC1, r0x06
	MOVFF	PREINC1, r0x05
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_main__ALL_NOTE_OFF	code
_ALL_NOTE_OFF:
;	.line	6; freeplay.c	void ALL_NOTE_OFF(){//KILL EVERY NOTES 
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
;	.line	9; freeplay.c	for(i=0;i<15;i++){
	CLRF	r0x00
_00233_DS_:
	MOVLW	0x0f
	SUBWF	r0x00, W
	BC	_00237_DS_
;	.line	10; freeplay.c	MIOS_MIDI_TxBufferPut(176 + i);//Controller Chn i
	MOVLW	0xb0
	ADDWF	r0x00, W
	MOVWF	r0x01
	MOVF	r0x01, W
	CALL	_MIOS_MIDI_TxBufferPut
;	.line	11; freeplay.c	MIOS_MIDI_TxBufferPut(123);//ALL NOTE OFF // http://www.borg.com/~jglatt/tech/midispec/ctllist.htm
	MOVLW	0x7b
	CALL	_MIOS_MIDI_TxBufferPut
;	.line	12; freeplay.c	MIOS_MIDI_TxBufferPut(0x00);
	MOVLW	0x00
	CALL	_MIOS_MIDI_TxBufferPut
;	.line	9; freeplay.c	for(i=0;i<15;i++){
	INCF	r0x00, F
	BRA	_00233_DS_
_00237_DS_:
;	.line	14; freeplay.c	return;
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	RETURN	

; ; Starting pCode block
S_main__PUSH	code
_PUSH:
;	.line	39; push.c	void PUSH(){
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	BANKSEL	__tik
;	.line	43; push.c	if( _tik == 24 )_tik=0;  
	MOVF	__tik, W, B
	XORLW	0x18
	BNZ	_00202_DS_
_00218_DS_:
	BANKSEL	__tik
	CLRF	__tik, B
_00202_DS_:
	BANKSEL	__tik
;	.line	46; push.c	if(_tik==0 || _tik==6 || _tik==12 || _tik==18){ // ON MORE STEP :)
	MOVF	__tik, W, B
	BZ	_00205_DS_
_00220_DS_:
	BANKSEL	__tik
	MOVF	__tik, W, B
	XORLW	0x06
	BZ	_00205_DS_
_00222_DS_:
	BANKSEL	__tik
	MOVF	__tik, W, B
	XORLW	0x0c
	BZ	_00205_DS_
_00224_DS_:
	BANKSEL	__tik
	MOVF	__tik, W, B
	XORLW	0x12
	BZ	_00205_DS_
	BRA	_00206_DS_
_00205_DS_:
	BANKSEL	_step
;	.line	48; push.c	if(step==16)step=0;//16 step reset
	MOVF	_step, W, B
	XORLW	0x10
	BNZ	_00204_DS_
_00228_DS_:
	BANKSEL	_step
	CLRF	_step, B
; ;multiply lit val:0X02 by variable _step and store in r0x00
; ;Unrolled 8 X 8 multiplication
; ;FIXME: the function does not support result==WREG
_00204_DS_:
;	.line	119; push.c	MIOS_DOUT_SRSet(1,led_pos[step][0]);
	CLRF	r0x01
	BCF	STATUS, 0
	BANKSEL	_step
	RLCF	_step, W, B
	MOVWF	r0x00
	RLCF	r0x01, F
	MOVLW	LOW(_led_pos)
	ADDWF	r0x00, F
	MOVLW	HIGH(_led_pos)
	ADDWFC	r0x01, F
	MOVLW	UPPER(_led_pos)
	CLRF	r0x02
	ADDWFC	r0x02, F
	MOVFF	r0x00, TBLPTRL
	MOVFF	r0x01, TBLPTRH
	MOVFF	r0x02, TBLPTRU
	TBLRD*+	
	MOVFF	TABLAT, r0x00
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	MOVLW	0x01
	CALL	_MIOS_DOUT_SRSet
	INCF	FSR1L, F
; ;multiply lit val:0X02 by variable _step and store in r0x00
; ;Unrolled 8 X 8 multiplication
; ;FIXME: the function does not support result==WREG
;	.line	120; push.c	MIOS_DOUT_SRSet(2,led_pos[step][1]);
	CLRF	r0x03
	BCF	STATUS, 0
	BANKSEL	_step
	RLCF	_step, W, B
	MOVWF	r0x00
	RLCF	r0x03, F
	MOVLW	LOW(_led_pos)
	ADDWF	r0x00, F
	MOVLW	HIGH(_led_pos)
	ADDWFC	r0x03, F
	MOVLW	UPPER(_led_pos)
	CLRF	r0x04
	ADDWFC	r0x04, F
	INCF	r0x00, F
	BTFSC	STATUS, 0
	INCF	r0x03, F
	BTFSC	STATUS, 0
	INCF	r0x04, F
	MOVFF	r0x00, TBLPTRL
	MOVFF	r0x03, TBLPTRH
	MOVFF	r0x04, TBLPTRU
	TBLRD*+	
	MOVFF	TABLAT, r0x00
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	MOVLW	0x02
	CALL	_MIOS_DOUT_SRSet
	INCF	FSR1L, F
;	.line	122; push.c	lastep=step;//mem last step
	MOVFF	_step, _lastep
;	.line	123; push.c	step++;//16 step counter
	INCF	_step, F, B
_00206_DS_:
	BANKSEL	__tik
;	.line	127; push.c	_tik++;
	INCF	__tik, F, B
;	.line	128; push.c	return;
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	RETURN	

; ; Starting pCode block
S_main__CTROL	code
_CTROL:
;	.line	2; keyboard.c	void CTROL(unsigned char pin){
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
;	.line	3; keyboard.c	MIOS_LCD_CursorSet(0x00);
	MOVLW	0x00
	CALL	_MIOS_LCD_CursorSet
;	.line	6; keyboard.c	switch(pin){//SPECIAL KEYS
	MOVF	r0x00, W
	BNZ	_00161_DS_
	BRA	_00134_DS_
_00161_DS_:
	MOVF	r0x00, W
	XORLW	0x02
	BNZ	_00163_DS_
	BRA	_00135_DS_
_00163_DS_:
	MOVF	r0x00, W
	XORLW	0x03
	BNZ	_00165_DS_
	BRA	_00136_DS_
_00165_DS_:
	MOVF	r0x00, W
	XORLW	0x08
	BNZ	_00167_DS_
	BRA	_00132_DS_
_00167_DS_:
	MOVF	r0x00, W
	XORLW	0x0f
	BNZ	_00169_DS_
	BRA	_00133_DS_
_00169_DS_:
	MOVF	r0x00, W
	XORLW	0x10
	BNZ	_00171_DS_
	BRA	_00130_DS_
_00171_DS_:
	MOVF	r0x00, W
	XORLW	0x17
	BNZ	_00173_DS_
	BRA	_00131_DS_
_00173_DS_:
	MOVF	r0x00, W
	XORLW	0x18
	BNZ	_00175_DS_
	BRA	_00128_DS_
_00175_DS_:
	MOVF	r0x00, W
	XORLW	0x1f
	BNZ	_00177_DS_
	BRA	_00129_DS_
_00177_DS_:
	MOVF	r0x00, W
	XORLW	0x20
	BNZ	_00179_DS_
	BRA	_00126_DS_
_00179_DS_:
	MOVF	r0x00, W
	XORLW	0x27
	BNZ	_00181_DS_
	BRA	_00127_DS_
_00181_DS_:
	MOVF	r0x00, W
	XORLW	0x28
	BZ	_00124_DS_
	MOVF	r0x00, W
	XORLW	0x2f
	BZ	_00125_DS_
	MOVF	r0x00, W
	XORLW	0x30
	BZ	_00122_DS_
	MOVF	r0x00, W
	XORLW	0x36
	BNZ	_00189_DS_
	BRA	_00137_DS_
_00189_DS_:
	MOVF	r0x00, W
	XORLW	0x37
	BZ	_00123_DS_
	MOVF	r0x00, W
	XORLW	0x38
	BZ	_00120_DS_
	MOVF	r0x00, W
	XORLW	0x39
	BZ	_00119_DS_
	MOVF	r0x00, W
	XORLW	0x3f
	BZ	_00121_DS_
	BRA	_00138_DS_
_00119_DS_:
	BANKSEL	_midi_channel
;	.line	8; keyboard.c	case 57:midi_channel=0;break;//MIDICHAN 1  (keyb:esc)
	CLRF	_midi_channel, B
	BRA	_00138_DS_
_00120_DS_:
;	.line	9; keyboard.c	case 56:midi_channel=1;break;//MIDICHAN 2  (keyb:1)
	MOVLW	0x01
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00121_DS_:
;	.line	10; keyboard.c	case 63:midi_channel=2;break;//MIDICHAN 3  (keyb:2)
	MOVLW	0x02
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00122_DS_:
;	.line	11; keyboard.c	case 48:midi_channel=3;break;//MIDICHAN 4  (keyb:3)
	MOVLW	0x03
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00123_DS_:
;	.line	12; keyboard.c	case 55:midi_channel=4;break;//MIDICHAN 5  (keyb:4)
	MOVLW	0x04
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00124_DS_:
;	.line	13; keyboard.c	case 40:midi_channel=5;break;//MIDICHAN 6  (keyb:5)
	MOVLW	0x05
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00125_DS_:
;	.line	14; keyboard.c	case 47:midi_channel=6;break;//MIDICHAN 7  (keyb:6)
	MOVLW	0x06
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00126_DS_:
;	.line	15; keyboard.c	case 32:midi_channel=7;break;//MIDICHAN 8  (keyb:7)
	MOVLW	0x07
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00127_DS_:
;	.line	16; keyboard.c	case 39:midi_channel=8;break;//MIDICHAN 9  (keyb:8)
	MOVLW	0x08
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00128_DS_:
;	.line	17; keyboard.c	case 24:midi_channel=9;break;//MIDICHAN 10 (keyb:9)
	MOVLW	0x09
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00129_DS_:
;	.line	18; keyboard.c	case 31:midi_channel=10;break;//MIDICHAN 11 (keyb:0)
	MOVLW	0x0a
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00130_DS_:
;	.line	19; keyboard.c	case 16:midi_channel=11;break;//MIDICHAN 12 (keyb:+)
	MOVLW	0x0b
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00131_DS_:
;	.line	20; keyboard.c	case 23:midi_channel=12;break;//MIDICHAN 13 (keyb:-)
	MOVLW	0x0c
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00132_DS_:
;	.line	21; keyboard.c	case 8: midi_channel=13;break;//MIDICHAN 14 (keyb:£)
	MOVLW	0x0d
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00133_DS_:
;	.line	22; keyboard.c	case 15:midi_channel=14;break;//MIDICHAN 15 (keyb:clr-home)
	MOVLW	0x0e
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00134_DS_:
;	.line	23; keyboard.c	case 0 :midi_channel=15;break;//MIDICHAN 16 (keyb:inst-del)
	MOVLW	0x0f
	BANKSEL	_midi_channel
	MOVWF	_midi_channel, B
	BRA	_00138_DS_
_00135_DS_:
;	.line	26; keyboard.c	case 2:PRG_CHNG(prg[midi_channel]+1);break;//CRSR RIGHT :PRG++
	MOVLW	LOW(_prg)
	BANKSEL	_midi_channel
	ADDWF	_midi_channel, W, B
	MOVWF	r0x00
	CLRF	r0x01
	MOVLW	HIGH(_prg)
	ADDWFC	r0x01, F
	MOVFF	r0x00, FSR0L
	MOVFF	r0x01, FSR0H
	MOVFF	INDF0, r0x00
	INCF	r0x00, F
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	CALL	_PRG_CHNG
	INCF	FSR1L, F
	BRA	_00138_DS_
_00136_DS_:
;	.line	27; keyboard.c	case 3:PRG_CHNG(prg[midi_channel]-1);break;//CRSR LEFT  :PRG--
	MOVLW	LOW(_prg)
	BANKSEL	_midi_channel
	ADDWF	_midi_channel, W, B
	MOVWF	r0x00
	CLRF	r0x02
	MOVLW	HIGH(_prg)
	ADDWFC	r0x02, F
	MOVFF	r0x00, FSR0L
	MOVFF	r0x02, FSR0H
	MOVFF	INDF0, r0x00
	DECF	r0x00, F
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	CALL	_PRG_CHNG
	INCF	FSR1L, F
	BRA	_00138_DS_
_00137_DS_:
;	.line	31; keyboard.c	MIOS_LCD_PrintCString("EDIT PATTERN");
	MOVLW	UPPER(__str_2)
	MOVWF	POSTDEC1
	MOVLW	HIGH(__str_2)
	MOVWF	POSTDEC1
	MOVLW	LOW(__str_2)
	CALL	_MIOS_LCD_PrintCString
	MOVLW	0x02
	ADDWF	FSR1L, F
_00138_DS_:
	BANKSEL	_midi_channel
;	.line	48; keyboard.c	led_num(midi_channel);
	MOVF	_midi_channel, W, B
	MOVWF	POSTDEC1
	CALL	_led_num
	INCF	FSR1L, F
;	.line	49; keyboard.c	return;
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_main__PRG_CHNG	code
_PRG_CHNG:
;	.line	9; prg_change.c	void PRG_CHNG(unsigned char prgnum){//CHANGE PROGRAM FOR CURRENT MIDI CHANNEL
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
;	.line	10; prg_change.c	if(prgnum>127)prgnum=127;
	MOVLW	0x80
	SUBWF	r0x00, W
	BNC	_00114_DS_
	MOVLW	0x7f
	MOVWF	r0x00
_00114_DS_:
;	.line	11; prg_change.c	prg[midi_channel]=prgnum;
	MOVLW	LOW(_prg)
	BANKSEL	_midi_channel
	ADDWF	_midi_channel, W, B
	MOVWF	r0x01
	CLRF	r0x02
	MOVLW	HIGH(_prg)
	ADDWFC	r0x02, F
	MOVFF	r0x01, FSR0L
	MOVFF	r0x02, FSR0H
	MOVFF	r0x00, INDF0
;	.line	12; prg_change.c	MIOS_LCD_CursorSet(0x00);
	MOVLW	0x00
	CALL	_MIOS_LCD_CursorSet
;	.line	13; prg_change.c	MIOS_LCD_PrintCString("CHN");
	MOVLW	UPPER(__str_0)
	MOVWF	POSTDEC1
	MOVLW	HIGH(__str_0)
	MOVWF	POSTDEC1
	MOVLW	LOW(__str_0)
	CALL	_MIOS_LCD_PrintCString
	MOVLW	0x02
	ADDWF	FSR1L, F
	BANKSEL	_midi_channel
;	.line	14; prg_change.c	MIOS_LCD_PrintBCD2(midi_channel+1);
	INCF	_midi_channel, W, B
	MOVWF	r0x01
	MOVF	r0x01, W
	CALL	_MIOS_LCD_PrintBCD2
;	.line	15; prg_change.c	MIOS_LCD_PrintCString(" PRG");
	MOVLW	UPPER(__str_1)
	MOVWF	POSTDEC1
	MOVLW	HIGH(__str_1)
	MOVWF	POSTDEC1
	MOVLW	LOW(__str_1)
	CALL	_MIOS_LCD_PrintCString
	MOVLW	0x02
	ADDWF	FSR1L, F
;	.line	16; prg_change.c	MIOS_LCD_PrintBCD3(prg[midi_channel]);
	MOVLW	LOW(_prg)
	BANKSEL	_midi_channel
	ADDWF	_midi_channel, W, B
	MOVWF	r0x01
	CLRF	r0x02
	MOVLW	HIGH(_prg)
	ADDWFC	r0x02, F
	MOVFF	r0x01, FSR0L
	MOVFF	r0x02, FSR0H
	MOVFF	INDF0, r0x01
	MOVF	r0x01, W
	CALL	_MIOS_LCD_PrintBCD3
;	.line	18; prg_change.c	MIOS_MIDI_TxBufferPut(192 + midi_channel);//PRG CHANGE
	MOVLW	0xc0
	BANKSEL	_midi_channel
	ADDWF	_midi_channel, W, B
	MOVWF	r0x01
	MOVF	r0x01, W
	CALL	_MIOS_MIDI_TxBufferPut
;	.line	19; prg_change.c	MIOS_MIDI_TxBufferPut(prgnum);//PRG CHANGE NUM
	MOVF	r0x00, W
	CALL	_MIOS_MIDI_TxBufferPut
;	.line	21; prg_change.c	return;
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_main__Init	code
_Init:
;	.line	24; init.c	MIOS_CLCD_SpecialCharsInit(lcd_charset);
	MOVLW	UPPER(_lcd_charset)
	MOVWF	POSTDEC1
	MOVLW	HIGH(_lcd_charset)
	MOVWF	POSTDEC1
	MOVLW	LOW(_lcd_charset)
	CALL	_MIOS_CLCD_SpecialCharsInit
	MOVLW	0x02
	ADDWF	FSR1L, F
;	.line	27; init.c	MIOS_SRIO_NumberSet(16);           // use up to 16 shift registers
	MOVLW	0x10
	CALL	_MIOS_SRIO_NumberSet
;	.line	28; init.c	MIOS_SRIO_UpdateFrqSet(1);         // set update frequency
	MOVLW	0x01
	CALL	_MIOS_SRIO_UpdateFrqSet
;	.line	31; init.c	MIOS_SRIO_TS_SensitivitySet(0);    // disable touch sensors
	MOVLW	0x00
	CALL	_MIOS_SRIO_TS_SensitivitySet
;	.line	34; init.c	MIOS_AIN_NumberSet(8);   // nb pots connected
	MOVLW	0x08
	CALL	_MIOS_AIN_NumberSet
;	.line	35; init.c	MIOS_AIN_UnMuxed();      // no AINX4 modules are used
	CALL	_MIOS_AIN_UnMuxed
;	.line	36; init.c	MIOS_AIN_DeadbandSet(7); // should be 7 when 7bit resolution is used
	MOVLW	0x07
	CALL	_MIOS_AIN_DeadbandSet
;	.line	39; init.c	SM_Init();
	CALL	_SM_Init
;	.line	42; init.c	MCLOCK_Init();
	CALL	_MCLOCK_Init
;	.line	43; init.c	MCLOCK_BPMSet(120);
	MOVLW	0x78
	MOVWF	POSTDEC1
	CALL	_MCLOCK_BPMSet
	INCF	FSR1L, F
;	.line	47; init.c	transpose=36;
	MOVLW	0x24
	BANKSEL	_transpose
	MOVWF	_transpose, B
	RETURN	

; ; Starting pCode block
S_main__led_num	code
_led_num:
;	.line	23; leds.c	void led_num(unsigned char num){//LIT LED
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, r0x00
; ;multiply lit val:0X02 by variable r0x00 and store in r0x00
; ;Unrolled 8 X 8 multiplication
; ;FIXME: the function does not support result==WREG
;	.line	24; leds.c	MIOS_DOUT_SRSet(1,led_pos[num][0]);
	CLRF	r0x01
	BCF	STATUS, 0
	RLCF	r0x00, F
	RLCF	r0x01, F
	MOVLW	LOW(_led_pos)
	ADDWF	r0x00, W
	MOVWF	r0x02
	MOVLW	HIGH(_led_pos)
	ADDWFC	r0x01, W
	MOVWF	r0x03
	CLRF	r0x04
	MOVLW	UPPER(_led_pos)
	ADDWFC	r0x04, F
	MOVFF	r0x02, TBLPTRL
	MOVFF	r0x03, TBLPTRH
	MOVFF	r0x04, TBLPTRU
	TBLRD*+	
	MOVFF	TABLAT, r0x02
	MOVF	r0x02, W
	MOVWF	POSTDEC1
	MOVLW	0x01
	CALL	_MIOS_DOUT_SRSet
	INCF	FSR1L, F
;	.line	25; leds.c	MIOS_DOUT_SRSet(2,led_pos[num][1]);
	MOVLW	LOW(_led_pos)
	ADDWF	r0x00, F
	MOVLW	HIGH(_led_pos)
	ADDWFC	r0x01, F
	MOVLW	UPPER(_led_pos)
	CLRF	r0x02
	ADDWFC	r0x02, F
	INCF	r0x00, F
	BTFSC	STATUS, 0
	INCF	r0x01, F
	BTFSC	STATUS, 0
	INCF	r0x02, F
	MOVFF	r0x00, TBLPTRL
	MOVFF	r0x01, TBLPTRH
	MOVFF	r0x02, TBLPTRU
	TBLRD*+	
	MOVFF	TABLAT, r0x00
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	MOVLW	0x02
	CALL	_MIOS_DOUT_SRSet
	INCF	FSR1L, F
;	.line	26; leds.c	return;
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block for Ival
	code
_note_map:
	DB	0x80, 0x3f, 0x80, 0x3f, 0x80, 0x7e, 0x80, 0x7f
	DB	0x80, 0xc0, 0x80, 0xc1, 0x80, 0xc2, 0x80, 0xc3
	DB	0x20, 0x24, 0x1f, 0x2a, 0x80, 0x5d, 0x10, 0x3f
	DB	0x80, 0xdb, 0x80, 0x3d, 0x21, 0x3f, 0x22, 0x3f
	DB	0x80, 0x2b, 0x1c, 0x50, 0x0d, 0x4c, 0x0c, 0x3c
	DB	0x0e, 0x3e, 0x0f, 0x5b, 0x1d, 0x40, 0x1e, 0x2d
	DB	0x19, 0x39, 0x18, 0x49, 0x0a, 0x4a, 0x09, 0x4e
	DB	0x0b, 0x4d, 0x80, 0x4b, 0x1a, 0x4f, 0x1b, 0x30
	DB	0x16, 0x37, 0x15, 0x59, 0x06, 0x47, 0x05, 0x56
	DB	0x07, 0x42, 0x08, 0x48, 0x17, 0x55, 0x80, 0x38
	DB	0x12, 0x35, 0x11, 0x52, 0x03, 0x44, 0x02, 0x58
	DB	0x04, 0x43, 0x80, 0x46, 0x13, 0x54, 0x14, 0x36
	DB	0x0f, 0x33, 0x0e, 0x57, 0x80, 0x41, 0x80, 0xdb
	DB	0x00, 0x5a, 0x01, 0x53, 0x10, 0x45, 0x80, 0x34
	DB	0x80, 0x31, 0x80, 0xf8, 0x80, 0xff, 0x80, 0xe0
	DB	0x80, 0x20, 0x80, 0xfc, 0x0c, 0x51, 0x0d, 0x32
; ; Starting pCode block for Ival
_lcd_charset:
	DB	0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x1f
	DB	0x00, 0x00, 0x00, 0x00, 0x1f, 0x11, 0x11, 0x1f
	DB	0x1f, 0x0e, 0x04, 0x00, 0x1f, 0x1f, 0x1f, 0x1f
	DB	0x1f, 0x0e, 0x04, 0x00, 0x1f, 0x11, 0x11, 0x1f
	DB	0x08, 0x0c, 0x0e, 0x0f, 0x0f, 0x0e, 0x0c, 0x08
; ; Starting pCode block for Ival
_led_pos:
	DB	0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00
	DB	0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80, 0x00
	DB	0x00, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08
	DB	0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x80
; ; Starting pCode block
__str_0:
	DB	0x43, 0x48, 0x4e, 0x00
; ; Starting pCode block
__str_1:
	DB	0x20, 0x50, 0x52, 0x47, 0x00
; ; Starting pCode block
__str_2:
	DB	0x45, 0x44, 0x49, 0x54, 0x20, 0x50, 0x41, 0x54
	DB	0x54, 0x45, 0x52, 0x4e, 0x00
; ; Starting pCode block for Ival
_chans:
	DB	0x00, 0x08, 0x07, 0x00
; ; Starting pCode block for Ival
_patchans:
	DB	0x00, 0x00, 0x00, 0x00
; ; Starting pCode block
__str_3:
	DB	0x41, 0x4c, 0x4c, 0x20, 0x4e, 0x4f, 0x54, 0x45
	DB	0x53, 0x20, 0x4f, 0x46, 0x46, 0x00
; ; Starting pCode block for Ival
_note_name:
	DB	0x43, 0x2d, 0x00, 0x43, 0x23, 0x00, 0x44, 0x2d
	DB	0x00, 0x44, 0x23, 0x00, 0x45, 0x2d, 0x00, 0x46
	DB	0x2d, 0x00, 0x46, 0x23, 0x00, 0x47, 0x2d, 0x00
	DB	0x47, 0x23, 0x00, 0x41, 0x2d, 0x00, 0x41, 0x23
	DB	0x00, 0x42, 0x2d, 0x00
; ; Starting pCode block
__str_4:
	DB	0x4e, 0x55, 0x4c, 0x00
; ; Starting pCode block
__str_5:
	DB	0x50, 0x41, 0x44, 0x00
; ; Starting pCode block
__str_6:
	DB	0x20, 0x2e, 0x3a, 0x20, 0x53, 0x49, 0x44, 0x41
	DB	0x42, 0x49, 0x54, 0x42, 0x4f, 0x58, 0x36, 0x34
	DB	0x20, 0x3a, 0x2e, 0x20, 0x00


; Statistics:
; code size:	 2212 (0x08a4) bytes (1.69%)
;           	 1106 (0x0452) words
; udata size:	  308 (0x0134) bytes (24.06%)
; access size:	    7 (0x0007) bytes


	end
