;; 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:15 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 _app_flags
	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_TIMER_ReInit
	extern _PUSH
	extern _MIOS_MPROC_EVENT_TABLE
	extern _MIOS_ENC_PIN_TABLE

;--------------------------------------------------------
; public variables in this module
;--------------------------------------------------------
	global _REMB1
	global _REMB0
	global _LOOPCOUNT
	global _BARGB1
	global _BARGB0
	global _AARGB2
	global _AARGB1
	global _AARGB0
	global _MCLOCK_Init
	global _MCLOCK_Tick
	global _MCLOCK_Timer
	global _MCLOCK_GetTimerValue
	global _MCLOCK_BPMSet
	global _MCLOCK_BPMGet
	global _MCLOCK_ResetMeter
	global _MCLOCK_SendMeter
	global _MCLOCK_DoStop
	global _MCLOCK_DoPause
	global _MCLOCK_DoPlay
	global _MCLOCK_DoRew
	global _MCLOCK_DoFwd
	global _mclock_state
	global _mclock_pin_state
	global _mclock_tick_ctr
	global _bpm
	global _mclock_ctr_24
	global _mclock_ctr_beats
	global _mclock_ctr_measures
;--------------------------------------------------------
;	Equates to used internal registers
;--------------------------------------------------------
STATUS	equ	0xfd8
WREG	equ	0xfe8
FSR1L	equ	0xfe9 ;; normaly 0xfe1, changed by fixasm.pl
FSR2L	equ	0xfd9
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


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

udata_mclock_0	udata
_AARGB0	res	1

udata_mclock_1	udata
_AARGB1	res	1

udata_mclock_2	udata
_AARGB2	res	1

udata_mclock_3	udata
_BARGB0	res	1

udata_mclock_4	udata
_BARGB1	res	1

udata_mclock_5	udata
_LOOPCOUNT	res	1

udata_mclock_6	udata
_REMB0	res	1

udata_mclock_7	udata
_REMB1	res	1

udata_mclock_8	udata
_mclock_tick_ctr	res	1

udata_mclock_9	udata
_mclock_state	res	1

udata_mclock_10	udata
_mclock_pin_state	res	1

udata_mclock_11	udata
_mclock_ctr_24	res	1

udata_mclock_12	udata
_mclock_ctr_beats	res	1

udata_mclock_13	udata
_mclock_ctr_measures	res	1

udata_mclock_14	udata
_bpm	res	1

;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
; I code from now on!
; ; Starting pCode block
S_mclock__MCLOCK_DoFwd	code
_MCLOCK_DoFwd:
	BANKSEL	_mclock_ctr_measures
;	.line	377; mclock.c	++mclock_ctr_measures;
	INCF	_mclock_ctr_measures, F, B
	BANKSEL	_mclock_ctr_24
;	.line	378; mclock.c	mclock_ctr_24 = 0;
	CLRF	_mclock_ctr_24, B
	BANKSEL	_mclock_ctr_beats
;	.line	379; mclock.c	mclock_ctr_beats = 0;
	CLRF	_mclock_ctr_beats, B
;	.line	382; mclock.c	MCLOCK_SendMeter();
	CALL	_MCLOCK_SendMeter
	BANKSEL	_app_flags
;	.line	385; mclock.c	app_flags.DISPLAY_UPDATE_REQ = 1;
	BSF	_app_flags, 0, B
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_DoRew	code
_MCLOCK_DoRew:
	BANKSEL	_mclock_ctr_measures
;	.line	363; mclock.c	if( mclock_ctr_measures ) --mclock_ctr_measures;
	MOVF	_mclock_ctr_measures, W, B
	BZ	_00197_DS_
; removed redundant BANKSEL
	DECF	_mclock_ctr_measures, F, B
_00197_DS_:
	BANKSEL	_mclock_ctr_24
;	.line	364; mclock.c	mclock_ctr_24 = 0;
	CLRF	_mclock_ctr_24, B
	BANKSEL	_mclock_ctr_beats
;	.line	365; mclock.c	mclock_ctr_beats = 0;
	CLRF	_mclock_ctr_beats, B
;	.line	368; mclock.c	MCLOCK_SendMeter();
	CALL	_MCLOCK_SendMeter
	BANKSEL	_app_flags
;	.line	371; mclock.c	app_flags.DISPLAY_UPDATE_REQ = 1;
	BSF	_app_flags, 0, B
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_DoPlay	code
_MCLOCK_DoPlay:
;	.line	350; mclock.c	MCLOCK_ResetMeter();
	CALL	_MCLOCK_ResetMeter
;	.line	352; mclock.c	MCLOCK_SendMeter();
	CALL	_MCLOCK_SendMeter
	BANKSEL	_mclock_state
;	.line	354; mclock.c	mclock_state.START_REQ = 1;
	BSF	_mclock_state, 2, B
	BANKSEL	_app_flags
;	.line	357; mclock.c	app_flags.DISPLAY_UPDATE_REQ = 1;
	BSF	_app_flags, 0, B
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_DoPause	code
_MCLOCK_DoPause:
;	.line	328; mclock.c	void MCLOCK_DoPause(void)
	MOVFF	r0x00, POSTDEC1
	BANKSEL	_mclock_state
;	.line	331; mclock.c	if( mclock_state.RUN ) {
	BTFSS	_mclock_state, 0, B
	BRA	_00182_DS_
; removed redundant BANKSEL
;	.line	333; mclock.c	if( mclock_state.PAUSE ) {
	BTFSS	_mclock_state, 1, B
	BRA	_00179_DS_
; removed redundant BANKSEL
;	.line	334; mclock.c	mclock_state.CONT_REQ = 1;
	BSF	_mclock_state, 4, B
	BRA	_00183_DS_
_00179_DS_:
	BANKSEL	_mclock_state
;	.line	336; mclock.c	mclock_state.PAUSE = 1;
	BSF	_mclock_state, 1, B
	BRA	_00183_DS_
_00182_DS_:
	BANKSEL	_mclock_state
;	.line	340; mclock.c	mclock_state.PAUSE = mclock_state.PAUSE ? 0 : 1;
	BTFSS	_mclock_state, 1, B
	BRA	_00186_DS_
	CLRF	r0x00
	BRA	_00187_DS_
_00186_DS_:
	MOVLW	0x01
	MOVWF	r0x00
_00187_DS_:
	MOVF	r0x00, W
	ANDLW	0x01
	RLNCF	WREG, W
	ANDLW	0xfe
	MOVWF	PRODH
	BANKSEL	_mclock_state
	MOVF	_mclock_state, W, B
	ANDLW	0xfd
	IORWF	PRODH, W
; removed redundant BANKSEL
	MOVWF	_mclock_state, B
_00183_DS_:
	BANKSEL	_app_flags
;	.line	344; mclock.c	app_flags.DISPLAY_UPDATE_REQ = 1;
	BSF	_app_flags, 0, B
	MOVFF	PREINC1, r0x00
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_DoStop	code
_MCLOCK_DoStop:
;	.line	313; mclock.c	void MCLOCK_DoStop(void)
	MOVFF	r0x00, POSTDEC1
;	.line	315; mclock.c	if( mclock_state.RUN == 0 ) {
	CLRF	WREG
	BANKSEL	_mclock_state
	BTFSC	_mclock_state, 0, B
	INCF	WREG, F
	MOVWF	r0x00
	MOVF	r0x00, W
	BNZ	_00168_DS_
;	.line	317; mclock.c	MCLOCK_ResetMeter();
	CALL	_MCLOCK_ResetMeter
;	.line	319; mclock.c	MCLOCK_SendMeter();
	CALL	_MCLOCK_SendMeter
_00168_DS_:
	BANKSEL	_mclock_state
;	.line	322; mclock.c	mclock_state.STOP_REQ = 1;
	BSF	_mclock_state, 3, B
	BANKSEL	_app_flags
;	.line	325; mclock.c	app_flags.DISPLAY_UPDATE_REQ = 1;
	BSF	_app_flags, 0, B
	MOVFF	PREINC1, r0x00
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_SendMeter	code
_MCLOCK_SendMeter:
;	.line	300; mclock.c	void MCLOCK_SendMeter(void)
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVFF	r0x02, POSTDEC1
	MOVFF	r0x03, POSTDEC1
	MOVFF	r0x04, POSTDEC1
	MOVFF	r0x05, POSTDEC1
;	.line	302; mclock.c	unsigned int songpos = (mclock_ctr_beats << 2) | (mclock_ctr_measures << 4);
	MOVFF	_mclock_ctr_beats, r0x00
	CLRF	r0x01
	MOVF	r0x00, W
	MOVWF	r0x02
	ADDWF	r0x02, F
	RLCF	r0x01, W
	MOVWF	r0x03
	BCF	STATUS, 0
	RLCF	r0x02, F
	RLCF	r0x03, F
	MOVFF	_mclock_ctr_measures, r0x00
	CLRF	r0x01
	SWAPF	r0x01, W
	ANDLW	0xf0
	MOVWF	r0x05
	SWAPF	r0x00, W
	MOVWF	r0x04
	ANDLW	0x0f
	XORWF	r0x04, F
	ADDWF	r0x05, F
	MOVF	r0x04, W
	IORWF	r0x02, F
	MOVF	r0x05, W
	IORWF	r0x03, F
;	.line	304; mclock.c	MIOS_MIDI_TxBufferPut(0xf2);
	MOVLW	0xf2
	CALL	_MIOS_MIDI_TxBufferPut
;	.line	305; mclock.c	MIOS_MIDI_TxBufferPut((unsigned char)(songpos & 0x7f));
	MOVLW	0x7f
	ANDWF	r0x02, W
	MOVWF	r0x00
	CLRF	r0x01
	MOVF	r0x00, W
	CALL	_MIOS_MIDI_TxBufferPut
;	.line	306; mclock.c	MIOS_MIDI_TxBufferPut((unsigned char)(songpos >> 7) & 0x7f);
	RLCF	r0x02, W
	RLCF	r0x03, W
	MOVWF	r0x02
	CLRF	r0x03
	RLCF	r0x03, F
	BCF	r0x02, 7
	MOVF	r0x02, W
	CALL	_MIOS_MIDI_TxBufferPut
	MOVFF	PREINC1, r0x05
	MOVFF	PREINC1, r0x04
	MOVFF	PREINC1, r0x03
	MOVFF	PREINC1, r0x02
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_ResetMeter	code
_MCLOCK_ResetMeter:
	BANKSEL	_mclock_ctr_24
;	.line	292; mclock.c	mclock_ctr_24 = 0;
	CLRF	_mclock_ctr_24, B
	BANKSEL	_mclock_ctr_beats
;	.line	293; mclock.c	mclock_ctr_beats = 0;
	CLRF	_mclock_ctr_beats, B
	BANKSEL	_mclock_ctr_measures
;	.line	294; mclock.c	mclock_ctr_measures = 0;
	CLRF	_mclock_ctr_measures, B
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_BPMGet	code
_MCLOCK_BPMGet:
	BANKSEL	_bpm
;	.line	279; mclock.c	return bpm;
	MOVF	_bpm, W, B
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_BPMSet	code
_MCLOCK_BPMSet:
;	.line	270; mclock.c	void MCLOCK_BPMSet(unsigned char _bpm)
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVFF	r0x00, POSTDEC1
	MOVFF	r0x01, POSTDEC1
	MOVLW	0x02
	MOVFF	PLUSW2, _bpm
	BANKSEL	_bpm
;	.line	274; mclock.c	MIOS_TIMER_ReInit(3, MCLOCK_GetTimerValue(bpm));
	MOVF	_bpm, W, B
	MOVWF	POSTDEC1
	CALL	_MCLOCK_GetTimerValue
	MOVWF	r0x00
	MOVFF	PRODL, r0x01
	INCF	FSR1L, F
	MOVF	r0x01, W
	MOVWF	POSTDEC1
	MOVF	r0x00, W
	MOVWF	POSTDEC1
	MOVLW	0x03
	CALL	_MIOS_TIMER_ReInit
	MOVLW	0x02
	ADDWF	FSR1L, F
	MOVFF	PREINC1, r0x01
	MOVFF	PREINC1, r0x00
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_GetTimerValue	code
_MCLOCK_GetTimerValue:
;	.line	183; mclock.c	unsigned int MCLOCK_GetTimerValue(unsigned char bpm)
	MOVFF	FSR2L, POSTDEC1
	MOVFF	FSR1L, FSR2L
	MOVLW	0x02
	MOVFF	PLUSW2, _BARGB1
;	.line	195; mclock.c	LOOPCOUNT = 24;
	MOVLW	0x18
	BANKSEL	_LOOPCOUNT
	MOVWF	_LOOPCOUNT, B
;	.line	196; mclock.c	AARGB0 = (unsigned char)(3125000L >> 16L);
	MOVLW	0x2f
	BANKSEL	_AARGB0
	MOVWF	_AARGB0, B
;	.line	197; mclock.c	AARGB1 = (unsigned char)(3125000L >>  8L);
	MOVLW	0xaf
	BANKSEL	_AARGB1
	MOVWF	_AARGB1, B
;	.line	198; mclock.c	AARGB2 = (unsigned char)(3125000L >>  0L);
	MOVLW	0x08
	BANKSEL	_AARGB2
	MOVWF	_AARGB2, B
	BANKSEL	_BARGB0
;	.line	199; mclock.c	BARGB0 = 0;
	CLRF	_BARGB0, B
;	.line	202; mclock.c	REMB0 = 1;
	MOVLW	0x01
	BANKSEL	_REMB0
	MOVWF	_REMB0, B
	banksel _LOOPCOUNT;
	CLRF _REMB0
	CLRF _REMB1
	MOVLW 24
	MOVWF _LOOPCOUNT
LOOPU2416:
	RLCF _AARGB2, W ;shift dividend left to move next bit to remainder
	RLCF _AARGB1, F ;
	RLCF _AARGB0, F ;
	RLCF _REMB1, F ;shift carry (next dividend bit) into remainder
	RLCF _REMB0, F
	RLCF _AARGB2, F ;finish shifting the dividend and save carry in AARGB2.0,
	;since remainder can be 17 bit long in some cases
	;(e.g. 0x800000/0xFFFF). This bit will also serve
	;as the next result bit.
	MOVF _BARGB1, W ;substract divisor from 16-bit remainder
	SUBWF _REMB1, F ;
	MOVF _BARGB0, W ;
	SKPC ;
	INCFSZ _BARGB0, W ;
	SUBWF _REMB0, F ;
	;here we also need to take into account the 17th bit of remainder, which
	;is in AARGB2.0. If we dont have a borrow after subtracting from lower
	;16 bits of remainder, then there is no borrow regardless of 17th bit
	;value. But, if we have the borrow, then that will depend on 17th bit
	;value. If it is 1, then no final borrow will occur. If it is 0, borrow
	;will occur. These values match the borrow flag polarity.
	SKPNC ;if no borrow after 16 bit subtraction
	BSF _AARGB2, 0 ;then there is no borrow in result. Overwrite
	;AARGB2.0 with 1 to indicate no
	;borrow.
	;if borrow did occur, AARGB2.0 already
	;holds the final borrow value (0-borrow,
	;1-no borrow)
	BTFSC _AARGB2, 0 ;if no borrow after 17-bit subtraction
	BRA UOK46LL ;skip remainder restoration.
	ADDWF _REMB0, F ;restore higher byte of remainder. (w
	;contains the value subtracted from it
	;previously)
	MOVF _BARGB1, W ;restore lower byte of remainder
	ADDWF _REMB1, F ;
UOK46LL:
	DECFSZ _LOOPCOUNT, f ;decrement counter
	BRA LOOPU2416 ;and repeat the loop if not zero.
	movff _AARGB1, _PRODL
	movf _AARGB2, W
	return
;	.line	264; mclock.c	return 0; // dummy return 
	CLRF	PRODL
	CLRF	WREG
	MOVFF	PREINC1, FSR2L
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_Timer	code
_MCLOCK_Timer:
	BANKSEL	_mclock_state
;	.line	157; mclock.c	if( mclock_state.RUN && !mclock_state.PAUSE) {
	BTFSS	_mclock_state, 0, B
	BRA	_00142_DS_
; removed redundant BANKSEL
	BTFSC	_mclock_state, 1, B
	BRA	_00142_DS_
	BANKSEL	_mclock_tick_ctr
;	.line	158; mclock.c	++mclock_tick_ctr;
	INCF	_mclock_tick_ctr, F, B
	BANKSEL	_mclock_pin_state
;	.line	159; mclock.c	mclock_pin_state.CLK_REQ = 1;
	BSF	_mclock_pin_state, 0, B
_00142_DS_:
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_Tick	code
_MCLOCK_Tick:
	BANKSEL	_mclock_state
;	.line	85; mclock.c	if( mclock_state.START_REQ ) {
	BTFSS	_mclock_state, 2, B
	BRA	_00110_DS_
; removed redundant BANKSEL
;	.line	86; mclock.c	mclock_state.START_REQ = 0;
	BCF	_mclock_state, 2, B
;	.line	87; mclock.c	MIOS_MIDI_TxBufferPut(0xfa);
	MOVLW	0xfa
	CALL	_MIOS_MIDI_TxBufferPut
	BANKSEL	_mclock_state
;	.line	88; mclock.c	mclock_state.RUN = 1;
	BSF	_mclock_state, 0, B
	BANKSEL	_app_flags
;	.line	91; mclock.c	app_flags.DISPLAY_UPDATE_REQ = 1;
	BSF	_app_flags, 0, B
_00110_DS_:
	BANKSEL	_mclock_state
;	.line	95; mclock.c	if( mclock_state.CONT_REQ ) {
	BTFSS	_mclock_state, 4, B
	BRA	_00112_DS_
; removed redundant BANKSEL
;	.line	96; mclock.c	mclock_state.CONT_REQ = 0;
	BCF	_mclock_state, 4, B
;	.line	97; mclock.c	MIOS_MIDI_TxBufferPut(0xfb);
	MOVLW	0xfb
	CALL	_MIOS_MIDI_TxBufferPut
	BANKSEL	_mclock_state
;	.line	98; mclock.c	mclock_state.PAUSE = 0;
	BCF	_mclock_state, 1, B
	BANKSEL	_app_flags
;	.line	101; mclock.c	app_flags.DISPLAY_UPDATE_REQ = 1;
	BSF	_app_flags, 0, B
_00112_DS_:
	BANKSEL	_mclock_state
;	.line	105; mclock.c	if( mclock_state.STOP_REQ ) {
	BTFSS	_mclock_state, 3, B
	BRA	_00119_DS_
; removed redundant BANKSEL
;	.line	106; mclock.c	mclock_state.STOP_REQ = 0;
	BCF	_mclock_state, 3, B
;	.line	107; mclock.c	MIOS_MIDI_TxBufferPut(0xfc);
	MOVLW	0xfc
	CALL	_MIOS_MIDI_TxBufferPut
	BANKSEL	_mclock_state
;	.line	108; mclock.c	mclock_state.RUN = 0;
	BCF	_mclock_state, 0, B
;	.line	109; mclock.c	mclock_state.PAUSE = 0;
	BCF	_mclock_state, 1, B
	BANKSEL	_mclock_tick_ctr
;	.line	110; mclock.c	mclock_tick_ctr = 0; // prevent that any requested 0xf8 will be sent
	CLRF	_mclock_tick_ctr, B
	BANKSEL	_app_flags
;	.line	113; mclock.c	app_flags.DISPLAY_UPDATE_REQ = 1;
	BSF	_app_flags, 0, B
_00119_DS_:
	BANKSEL	_mclock_tick_ctr
;	.line	117; mclock.c	while( mclock_tick_ctr ) {
	MOVF	_mclock_tick_ctr, W, B
	BZ	_00122_DS_
;	.line	118; mclock.c	MIOS_MIDI_TxBufferPut(0xf8);
	MOVLW	0xf8
	CALL	_MIOS_MIDI_TxBufferPut
;	.line	125; mclock.c	INTCONbits.GIE = 0; // disable interrupts
	BCF	_INTCONbits, 7
	BANKSEL	_mclock_tick_ctr
;	.line	126; mclock.c	--mclock_tick_ctr;
	DECF	_mclock_tick_ctr, F, B
;	.line	127; mclock.c	INTCONbits.GIE = 1; // enable interrupts
	BSF	_INTCONbits, 7
;	.line	130; mclock.c	PUSH();
	CALL	_PUSH
	BANKSEL	_mclock_ctr_24
;	.line	131; mclock.c	if( ++mclock_ctr_24 == 24 ) {
	INCF	_mclock_ctr_24, F, B
	MOVF	_mclock_ctr_24, W, B
	XORLW	0x18
	BNZ	_00118_DS_
_00132_DS_:
	BANKSEL	_mclock_ctr_24
;	.line	132; mclock.c	mclock_ctr_24 = 0;
	CLRF	_mclock_ctr_24, B
	BANKSEL	_mclock_ctr_beats
;	.line	133; mclock.c	if( ++mclock_ctr_beats == 4 ) {
	INCF	_mclock_ctr_beats, F, B
	MOVF	_mclock_ctr_beats, W, B
	XORLW	0x04
	BNZ	_00118_DS_
_00134_DS_:
	BANKSEL	_mclock_ctr_beats
;	.line	134; mclock.c	mclock_ctr_beats = 0;
	CLRF	_mclock_ctr_beats, B
	BANKSEL	_mclock_ctr_measures
;	.line	135; mclock.c	++mclock_ctr_measures;
	INCF	_mclock_ctr_measures, F, B
_00118_DS_:
	BANKSEL	_app_flags
;	.line	140; mclock.c	app_flags.DISPLAY_UPDATE_REQ = 1;
	BSF	_app_flags, 0, B
	BRA	_00119_DS_
_00122_DS_:
	RETURN	

; ; Starting pCode block
S_mclock__MCLOCK_Init	code
_MCLOCK_Init:
;	.line	64; mclock.c	mclock_state.ALL = 0;
	MOVLW	0x00
	BANKSEL	_mclock_state
	MOVWF	_mclock_state, B
;	.line	65; mclock.c	mclock_pin_state.ALL = 0;
	MOVLW	0x00
	BANKSEL	_mclock_pin_state
	MOVWF	_mclock_pin_state, B
	BANKSEL	_mclock_tick_ctr
;	.line	66; mclock.c	mclock_tick_ctr = 0;
	CLRF	_mclock_tick_ctr, B
;	.line	68; mclock.c	MCLOCK_ResetMeter();
	CALL	_MCLOCK_ResetMeter
	RETURN	



; Statistics:
; code size:	  736 (0x02e0) bytes (0.56%)
;           	  368 (0x0170) words
; udata size:	   15 (0x000f) bytes (1.17%)
; access size:	    6 (0x0006) bytes


	end
