Subversion Repositories svn.mios

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1221 Antichambr 1
; $Id: tia_patch.inc bdupeyron.tech@gmail.com(Antichambre)
2
;
3
; TIA Patch routines
4
;
5
; ==========================================================================
6
;
7
;  Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
8
;  Licensed for personal non-commercial use only.
9
;  All other rights reserved.
10
;
11
; ==========================================================================
12
 
13
 
14
;; --------------------------------------------------------------------------
15
;;  Init Routine for patch parameters
16
;;  Note that the MIDI events are initialized separately, this routine will
17
;;  be called on power-on and after a new MIDI dump has been loaded
18
;; --------------------------------------------------------------------------
19
TIA_PATCH_Init
20
	;; disable TIA engine
21
	bsf	TIA_STAT, TIA_STAT_ENGINE_DISABLE
22
 
23
	;; clear the whole TIA SFR memory space
24
	movlw	((TIA_SW_CLEAR_END-TIA_SW_CLEAR_BEGIN)+1) & 0xff
25
	movwf	TMP1
26
	lfsr	FSR0, TIA_SW_CLEAR_BEGIN
27
TIA_PATCH_Init_ClearLoop
28
	clrf	POSTINC0
29
	decfsz	TMP1, F
30
	rgoto	TIA_PATCH_Init_ClearLoop
31
 
32
	;; fetch 128 TIA parameters from EEPROM
33
	clrf	TMP1
34
    movlw   EEPROM_PATCH & 0xff
35
	movwf	EEADR
36
    movlw   (EEPROM_PATCH >> 8) & 0xff
37
    movwf   EEADRH
38
    movff   TIA_PBANK, TIA_BANK
39
    movff   TIA_PATCH, TIA_PRESET
40
TIA_PATCH_InitEELoop
41
	movf	TMP1, W
42
	call	TIA_SYSEX_TABLE_Get; get CC number
43
	movwf	TMP2		; temporary store number in TMP2
44
 
45
	movff	TMP1, EEADR	; read parameter from current TIA bank
46
	call	TIA_BANK_Read
47
    movwf	MIOS_PARAMETER1	; store value in MIOS_PARAMETER1
48
 
49
	;; branch depending on TMP2[7..4]
50
	BRA_IFSET TMP2, 7, ACCESS, TIA_PATCH_InitEELoopS
51
TIA_PATCH_InitEELoopN
52
	;; if TMP2[7] == 0, then set CC parameter
53
	movf	TMP2, W
54
	call	TIA_CCIN_Set
55
	rgoto	TIA_PATCH_InitEELoopC
56
TIA_PATCH_InitEELoopS
57
	;; if TMP2[7..4] == 9, then set split point
58
	movf	TMP2, W
59
	andlw	0xf0
60
	xorlw	0x90
61
	bnz	TIA_PATCH_InitEELoopC
62
	movf	TMP2, W
63
	rcall	TIA_PATCH_GetSplitPointer
64
	movff	MIOS_PARAMETER1, INDF1
65
TIA_PATCH_InitEELoopC
66
 
67
	incf	TMP1, F		; increment CC counter, loop until 0x80
68
	BRA_IFCLR TMP1, 7, ACCESS, TIA_PATCH_InitEELoop
69
 
70
	;; get and store the MIDI channels
71
	movlw	EEPROM_CFG_BASE & 0xff
72
	movwf	EEADR
73
	call	MIOS_EEPROM_Read
74
	movff	WREG, TIA_V2_BASE + TIA_Vx_MIDI_CHANNEL
75
	call	MIOS_EEPROM_Read
76
	movff	WREG, TIA_V1_BASE + TIA_Vx_MIDI_CHANNEL
77
	;; get and store the device ID
78
	call	MIOS_EEPROM_Read
79
#if AUTO_DEVICE_ID
80
	;; if AUTO_ID enabled, derive the TIA device ID from the MIOS device ID instead
81
	call	MIOS_MIDI_DeviceIDGet
82
#endif
83
	movwf	TIA_MIDI_DEVICE
84
 
85
    call	MIOS_EEPROM_Read
86
    ;; Empty
87
 
88
	;; force a refresh of all registers
89
	bsf	TIA_STAT, TIA_STAT_FORCE_REFRESH
90
 
91
	;; enable TIA engine again
92
	bcf	TIA_STAT, TIA_STAT_ENGINE_DISABLE
93
 
94
#if DEFAULT_TIA_DEBUG_ON == 1
95
    bsf TIA_DEBUG_EE_REGA, TIA_DEBUG_EE_PINIT
96
    call    TIA_Debug_EE_Do
97
    bsf TIA_DEBUG_BS_REGA, TIA_DEBUG_EE_PINIT
98
    call    TIA_Debug_BS_Do
99
#endif
100
	return
101
 
102
 
103
 
104
;; --------------------------------------------------------------------------
105
;;  This help routine returns the pointer to TIA_Vx_SPLIT_xxx depending
106
;;  on WREG
107
;;  OUT: pointer in FSR1
108
;; --------------------------------------------------------------------------
109
TIA_PATCH_GetSplitPointer
110
	lfsr	FSR1, TIA_V1_BASE + TIA_Vx_SPLIT_LOWER
111
	btfsc	WREG, 0
112
	lfsr	FSR1, TIA_V1_BASE + TIA_Vx_SPLIT_UPPER
113
 
114
	rrf	WREG, W
115
	andlw	0x01
116
	mullw	TIA_Vx_RECORD_LEN
117
	movf	PRODL, W
118
	addwf	FSR1L, F
119
	return