1 | gplink-0.13.6 alpha
|
---|
2 | Copyright (c) 1998-2005 gputils project
|
---|
3 | Listing File Generated: 6-27-2008 15:24:01
|
---|
4 |
|
---|
5 |
|
---|
6 | Address Value Disassembly Source
|
---|
7 | ------- ----- ----------- ------
|
---|
8 | ; -------------------------------------
|
---|
9 | ; PS/2 Mouse to Amiga Mouse Converter
|
---|
10 | ; -------------------------------------
|
---|
11 | ;
|
---|
12 | ; Version: V1.0 (30-Jun-2001) Author : N. Baricevic <nogoth@yahoo.com>
|
---|
13 | ; Version: V1.1 (26-mai-2006) modified by sundance
|
---|
14 | ; version v1.2 (28/06/2006) modified by sundance
|
---|
15 | ; V1.3 19/06/08 by PulkoMandy
|
---|
16 | ;-------------------------------------------
|
---|
17 | ;
|
---|
18 | ;modif : standard mplab project
|
---|
19 | ; configuration pic
|
---|
20 | ; support wheel mouse
|
---|
21 | ; sync xa/xb and ya/yb
|
---|
22 | ; compatibility with atari st
|
---|
23 | ; auto-detect amiga/atari
|
---|
24 | ;V1.3
|
---|
25 | ; Some more optimisations/reorganisation
|
---|
26 | ; New parity code (smaller)
|
---|
27 | ; 16f628 compatibility
|
---|
28 | ;-------------------------------------------
|
---|
29 |
|
---|
30 | ; ------------------------------------------
|
---|
31 | ; includes
|
---|
32 | ; ------------------------------------------;
|
---|
33 | list f=inhx8m ;Enter device name
|
---|
34 | LIST p=16F628
|
---|
35 | IFDEF __16F628
|
---|
36 | include p16f628.inc
|
---|
37 | LIST
|
---|
38 | ; P16F628.INC Standard Header File, Version 1.01 Microchip Technology, Inc.
|
---|
39 | NOLIST
|
---|
40 | __config _PWRTE_ON & _WDT_OFF & _CP_OFF & _BODEN_OFF & _DATA_CP_OFF & _INTRC_OSC_NOCLKOUT & _MCLRE_ON & _LVP_OFF
|
---|
41 | #define VAR_BEGIN 0x20
|
---|
42 | MESSG "Compiling for 16f628"
|
---|
43 | ELSE
|
---|
44 | include p16f84a.inc
|
---|
45 | #define VAR_BEGIN 0x0C
|
---|
46 | MESSG "Compiling for 16f84"
|
---|
47 | ENDIF
|
---|
48 | ; ------------------------------------------
|
---|
49 |
|
---|
50 | ; ---------- registers definition -----------
|
---|
51 |
|
---|
52 | byte equ VAR_BEGIN ; byte to receive or send
|
---|
53 | parity equ VAR_BEGIN+1 ; parity bit is held here
|
---|
54 | parcnt equ VAR_BEGIN+2 ; counter for calculating parity
|
---|
55 | roller equ VAR_BEGIN+3 ; help for 8 data bits to byte conversion
|
---|
56 | pack1 equ VAR_BEGIN+4 ; 1st byte of mouse data packet
|
---|
57 | pack2 equ VAR_BEGIN+5 ; 2nd byte of mouse data packet
|
---|
58 | pack3 equ VAR_BEGIN+6 ; 3rd byte of mouse data packet
|
---|
59 | togglex equ VAR_BEGIN+7
|
---|
60 | toggley equ VAR_BEGIN+8
|
---|
61 | delcnt equ VAR_BEGIN+9 ; delay counter
|
---|
62 | tempxa equ VAR_BEGIN+0xA ; temp to sync xa and xb
|
---|
63 | tempxb equ VAR_BEGIN+0xB
|
---|
64 | tempya equ VAR_BEGIN+0xC ; temp to sync ya and yb
|
---|
65 | tempyb equ VAR_BEGIN+0xD
|
---|
66 | temp equ VAR_BEGIN+0xE
|
---|
67 | maskx equ VAR_BEGIN+0xF
|
---|
68 | masky equ VAR_BEGIN+0x10
|
---|
69 | delay equ VAR_BEGIN+0x11
|
---|
70 | savb equ VAR_BEGIN+0x12
|
---|
71 | bitya equ VAR_BEGIN+0x13
|
---|
72 | bityb equ VAR_BEGIN+0x14
|
---|
73 | bitxa equ VAR_BEGIN+0x15
|
---|
74 | bitxb equ VAR_BEGIN+0x16
|
---|
75 |
|
---|
76 | ; --------- main routine -----------
|
---|
77 | org 0x0
|
---|
78 | 000000 2805 goto 0x5 goto main
|
---|
79 |
|
---|
80 | ;EN 0x04 il y a les vecteurs d'interruption !
|
---|
81 | ORG 0x04
|
---|
82 | 000004 2961 goto 0x161 goto inter ;interrupt handler
|
---|
83 |
|
---|
84 | ORG 0x05
|
---|
85 | main:
|
---|
86 | ;set port direction
|
---|
87 | 000005 1683 bsf 0x3, 0x5 bsf STATUS,RP0 ; page 1
|
---|
88 |
|
---|
89 | 000006 30fb movlw 0xfb movlw 0xFB ; OUT ON RA2 FOR ERROR LED
|
---|
90 | 000007 0085 movwf 0x5 movwf TRISA ; port A, bit 0 and 1 is input
|
---|
91 |
|
---|
92 | 000008 3002 movlw 0x2 movlw b'00000010'
|
---|
93 | 000009 0086 movwf 0x6 movwf TRISB ; port B is all outputs
|
---|
94 |
|
---|
95 | ; Set port values
|
---|
96 | 00000a 1283 bcf 0x3, 0x5 bcf STATUS,RP0 ; page 0
|
---|
97 |
|
---|
98 | ;Pour désactiver le CNA du 16f628
|
---|
99 | IFDEF __16F628
|
---|
100 | 00000b 3007 movlw 0x7 movlw 0x07
|
---|
101 | 00000c 009f movwf 0x1f movwf CMCON
|
---|
102 | ENDIF
|
---|
103 |
|
---|
104 | 00000d 30ff movlw 0xff movlw b'11111111'
|
---|
105 | 00000e 0086 movwf 0x6 movwf PORTB
|
---|
106 | 00000f 0185 clrf 0x5 clrf PORTA ; port A out pins to 0
|
---|
107 | 000010 307f movlw 0x7f movlw b'01111111' ;PULL UP ON on portb for detect amiga or atari
|
---|
108 | 000011 0081 movwf 0x1 movwf OPTION_REG
|
---|
109 |
|
---|
110 | ; set port out level
|
---|
111 |
|
---|
112 | 000012 01a0 clrf 0x20 clrf byte
|
---|
113 | 000013 01a1 clrf 0x21 clrf parity
|
---|
114 | 000014 01a2 clrf 0x22 clrf parcnt
|
---|
115 | 000015 01a3 clrf 0x23 clrf roller
|
---|
116 | 000016 01a7 clrf 0x27 clrf togglex
|
---|
117 | 000017 01a8 clrf 0x28 clrf toggley
|
---|
118 | 000018 01a4 clrf 0x24 clrf pack1
|
---|
119 | 000019 01a5 clrf 0x25 clrf pack2
|
---|
120 | 00001a 01a6 clrf 0x26 clrf pack3
|
---|
121 |
|
---|
122 | check_mouse_init
|
---|
123 | 00001b 2087 call 0x87 call REC ; receive byte from mouse
|
---|
124 | 00001c 20a8 call 0xa8 call INHIB ; pull CLK low to inhibit furhter sending
|
---|
125 | 00001d 0820 movf 0x20, w movf byte,W
|
---|
126 | 00001e 3aaa xorlw 0xaa xorlw 0xaa ; if it's $AA mouse self test passed
|
---|
127 | 00001f 1d03 btfss 0x3, 0x2 btfss STATUS,Z
|
---|
128 | 000020 281b goto 0x1b goto check_mouse_init ;If error, restart the init
|
---|
129 |
|
---|
130 | ;check mouse id =00
|
---|
131 | 000021 20ab call 0xab call REL ; release CLK (allow mouse to send)
|
---|
132 | 000022 2087 call 0x87 call REC ; receive byte from mouse
|
---|
133 | 000023 20a8 call 0xa8 call INHIB
|
---|
134 | 000024 0820 movf 0x20, w movf byte,W
|
---|
135 | 000025 3a00 xorlw 0 xorlw 0x00 ; mouse ID code should be $00
|
---|
136 | 000026 1d03 btfss 0x3, 0x2 btfss STATUS,Z
|
---|
137 | 000027 281b goto 0x1b goto check_mouse_init ; restart the init
|
---|
138 |
|
---|
139 | ;allow mouse to send the data
|
---|
140 | 000028 30f4 movlw 0xf4 movlw 0xf4 ; "Enable Data Reporting" command to mouse
|
---|
141 | 000029 00a0 movwf 0x20 movwf byte
|
---|
142 | 00002a 20e3 call 0xe3 call NEWPAR ; calculate parity for $F4
|
---|
143 | 00002b 20ab call 0xab call REL ; release CLK (allow mouse to send)
|
---|
144 |
|
---|
145 | ;wait
|
---|
146 | 00002c 207d call 0x7d call DEL200 ;wait 200µs
|
---|
147 |
|
---|
148 | ;receive ack = fa
|
---|
149 | 00002d 20c8 call 0xc8 call SEND ; send command to mouse
|
---|
150 | 00002e 2087 call 0x87 call REC ; receive acknowledge ($FA) from mouse)
|
---|
151 | 00002f 20a8 call 0xa8 call INHIB
|
---|
152 | 000030 0820 movf 0x20, w movf byte,W
|
---|
153 | 000031 3afa xorlw 0xfa xorlw 0xfa
|
---|
154 | 000032 1d03 btfss 0x3, 0x2 btfss STATUS,Z
|
---|
155 | 000033 281b goto 0x1b goto check_mouse_init ;restart init if wrong
|
---|
156 |
|
---|
157 | 000034 3040 movlw 0x40 movlw 0x40
|
---|
158 | 000035 00b0 movwf 0x30 movwf masky
|
---|
159 | 000036 01ae clrf 0x2e clrf temp
|
---|
160 | megatempo
|
---|
161 | 000037 207d call 0x7d call DEL200 ; WAIT INSERTION
|
---|
162 | 000038 0bae decfsz 0x2e, f decfsz temp,f
|
---|
163 | 000039 2837 goto 0x37 goto megatempo
|
---|
164 |
|
---|
165 | 00003a 1886 btfsc 0x6, 0x1 btfsc PORTB,1 ;MIDDLE BUTTON CONNECTED ?
|
---|
166 | 00003b 2853 goto 0x53 goto amiga_pattern
|
---|
167 |
|
---|
168 | ;atari_pattern
|
---|
169 | 00003c 307c movlw 0x7c movlw 0x7C
|
---|
170 | 00003d 00b1 movwf 0x31 movwf delay
|
---|
171 | ; pattern atari xa b'00100000'
|
---|
172 | ; pattern atari xb b'00010000'
|
---|
173 | 00003e 3010 movlw 0x10 movlw b'00010000'
|
---|
174 | 00003f 00aa movwf 0x2a movwf tempxa
|
---|
175 | 000040 3020 movlw 0x20 movlw b'00100000'
|
---|
176 | 000041 00ab movwf 0x2b movwf tempxb
|
---|
177 | ; pattern atari ya b'00001000'
|
---|
178 | ; pattern atari yb b'00000100'
|
---|
179 | 000042 3008 movlw 0x8 movlw b'00001000'
|
---|
180 | 000043 00ad movwf 0x2d movwf tempyb
|
---|
181 | 000044 3004 movlw 0x4 movlw b'00000100'
|
---|
182 | 000045 00ac movwf 0x2c movwf tempya
|
---|
183 | ;mask atari x/y
|
---|
184 | 000046 30cf movlw 0xcf movlw b'11001111'
|
---|
185 | 000047 00af movwf 0x2f movwf maskx
|
---|
186 | 000048 30f3 movlw 0xf3 movlw b'11110011'
|
---|
187 | 000049 00b0 movwf 0x30 movwf masky
|
---|
188 | 00004a 3010 movlw 0x10 movlw b'00010000'
|
---|
189 | 00004b 00b5 movwf 0x35 movwf bitxa
|
---|
190 | 00004c 3020 movlw 0x20 movlw b'00100000'
|
---|
191 | 00004d 00b6 movwf 0x36 movwf bitxb
|
---|
192 | 00004e 3004 movlw 0x4 movlw b'00000100'
|
---|
193 | 00004f 00b3 movwf 0x33 movwf bitya
|
---|
194 | 000050 3008 movlw 0x8 movlw b'00001000'
|
---|
195 | 000051 00b4 movwf 0x34 movwf bityb
|
---|
196 |
|
---|
197 | 000052 2869 goto 0x69 goto start
|
---|
198 |
|
---|
199 | amiga_pattern
|
---|
200 | 000053 303b movlw 0x3b movlw 0x3B
|
---|
201 | 000054 00b1 movwf 0x31 movwf delay
|
---|
202 | ; pattern amiga xa b'00000100'
|
---|
203 | ; pattern amiga xb b'00010000'
|
---|
204 | 000055 3004 movlw 0x4 movlw b'00000100'
|
---|
205 | 000056 00ab movwf 0x2b movwf tempxb
|
---|
206 | 000057 3010 movlw 0x10 movlw b'00010000'
|
---|
207 | 000058 00aa movwf 0x2a movwf tempxa
|
---|
208 | ; pattern amiga ya b'00001000'
|
---|
209 | ; pattern amiga yb b'00100000'
|
---|
210 | 000059 3008 movlw 0x8 movlw b'00001000'
|
---|
211 | 00005a 00ad movwf 0x2d movwf tempyb
|
---|
212 | 00005b 3020 movlw 0x20 movlw b'00100000'
|
---|
213 | 00005c 00ac movwf 0x2c movwf tempya
|
---|
214 | ;mask amiga x/y
|
---|
215 | 00005d 30eb movlw 0xeb movlw b'11101011'
|
---|
216 | 00005e 00af movwf 0x2f movwf maskx
|
---|
217 | 00005f 30d7 movlw 0xd7 movlw b'11010111'
|
---|
218 | 000060 00b0 movwf 0x30 movwf masky
|
---|
219 | 000061 3010 movlw 0x10 movlw b'00010000'
|
---|
220 | 000062 00b5 movwf 0x35 movwf bitxa
|
---|
221 | 000063 3004 movlw 0x4 movlw b'00000100'
|
---|
222 | 000064 00b6 movwf 0x36 movwf bitxb
|
---|
223 | 000065 3020 movlw 0x20 movlw b'00100000'
|
---|
224 | 000066 00b3 movwf 0x33 movwf bitya
|
---|
225 | 000067 3008 movlw 0x8 movlw b'00001000'
|
---|
226 | 000068 00b4 movwf 0x34 movwf bityb
|
---|
227 | start
|
---|
228 | 000069 1683 bsf 0x3, 0x5 bsf STATUS,RP0 ; page 1
|
---|
229 | 00006a 0186 clrf 0x6 clrf TRISB ; port B is all outputs
|
---|
230 | 00006b 1283 bcf 0x3, 0x5 bcf STATUS,RP0 ; page 0
|
---|
231 | ;main loop
|
---|
232 | CHK:
|
---|
233 | ; lecture trame de 3 octets
|
---|
234 | 00006c 20ab call 0xab call REL
|
---|
235 | 00006d 2087 call 0x87 call REC ; receive byte1 from mouse packet
|
---|
236 | 00006e 20a8 call 0xa8 call INHIB
|
---|
237 | 00006f 0820 movf 0x20, w movf byte,W
|
---|
238 | 000070 00a4 movwf 0x24 movwf pack1
|
---|
239 | 000071 20ab call 0xab call REL
|
---|
240 | 000072 2087 call 0x87 call REC ; receive byte2 from mouse packet
|
---|
241 | 000073 20a8 call 0xa8 call INHIB
|
---|
242 | 000074 0820 movf 0x20, w movf byte,W
|
---|
243 | 000075 00a5 movwf 0x25 movwf pack2
|
---|
244 | 000076 20ab call 0xab call REL
|
---|
245 | 000077 2087 call 0x87 call REC ; receive byte3 from mouse packet
|
---|
246 | 000078 20a8 call 0xa8 call INHIB
|
---|
247 | 000079 0820 movf 0x20, w movf byte,W
|
---|
248 | 00007a 00a6 movwf 0x26 movwf pack3
|
---|
249 | ;convertion ps2 > amiga
|
---|
250 | 00007b 20f8 call 0xf8 call CONV
|
---|
251 | 00007c 286c goto 0x6c goto CHK ; receive another packet
|
---|
252 |
|
---|
253 |
|
---|
254 | ; --------------------------------------------------------
|
---|
255 |
|
---|
256 |
|
---|
257 | 00007d 0831 movf 0x31, w DEL200: movfw delay
|
---|
258 | 00007e 00a9 movwf 0x29 movwf delcnt
|
---|
259 | 00007f 0ba9 decfsz 0x29, f DEL2: decfsz delcnt,f
|
---|
260 | 000080 287f goto 0x7f goto DEL2
|
---|
261 | 000081 0000 nop DEL10: nop ; delay 10us
|
---|
262 | 000082 0000 nop nop
|
---|
263 | 000083 0000 nop nop
|
---|
264 | 000084 0000 nop nop
|
---|
265 | 000085 0000 nop nop
|
---|
266 | 000086 0008 return return
|
---|
267 |
|
---|
268 | ; --------- byte receiving subroutine -------------
|
---|
269 | 000087 1805 btfsc 0x5, 0 REC: btfsc PORTA,0 ; wait clock (start bit)
|
---|
270 | 000088 2887 goto 0x87 goto REC
|
---|
271 | 000089 1c05 btfss 0x5, 0 RL1: btfss PORTA,0
|
---|
272 | 00008a 2889 goto 0x89 goto RL1
|
---|
273 | 00008b 209e call 0x9e call RECBIT ; receive 8 data bits
|
---|
274 | 00008c 209e call 0x9e call RECBIT
|
---|
275 | 00008d 209e call 0x9e call RECBIT
|
---|
276 | 00008e 209e call 0x9e call RECBIT
|
---|
277 | 00008f 209e call 0x9e call RECBIT
|
---|
278 | 000090 209e call 0x9e call RECBIT
|
---|
279 | 000091 209e call 0x9e call RECBIT
|
---|
280 | 000092 209e call 0x9e call RECBIT
|
---|
281 | 000093 1805 btfsc 0x5, 0 RL2: btfsc PORTA,0 ; receive parity bit
|
---|
282 | 000094 2893 goto 0x93 goto RL2
|
---|
283 | 000095 1885 btfsc 0x5, 0x1 btfsc PORTA,1
|
---|
284 | 000096 289c goto 0x9c goto RL3
|
---|
285 | 000097 1021 bcf 0x21, 0 bcf parity,0
|
---|
286 | RL4:
|
---|
287 | 000098 20c3 call 0xc3 call wait_h
|
---|
288 | 000099 1c05 btfss 0x5, 0 RL8: btfss PORTA,0
|
---|
289 | 00009a 2899 goto 0x99 goto RL8
|
---|
290 | 00009b 0008 return return
|
---|
291 |
|
---|
292 | 00009c 1421 bsf 0x21, 0 RL3: bsf parity,0
|
---|
293 | 00009d 2898 goto 0x98 goto RL4
|
---|
294 |
|
---|
295 | ; ---------- bit receiving subroutine ------------
|
---|
296 |
|
---|
297 | 00009e 1805 btfsc 0x5, 0 RECBIT: btfsc PORTA,0 ;Attend que l'horloge passe à 0
|
---|
298 | 00009f 289e goto 0x9e goto RECBIT
|
---|
299 | 0000a0 0805 movf 0x5, w movf PORTA,W ;Lit le port A
|
---|
300 | 0000a1 00a3 movwf 0x23 movwf roller ;Ne garde que le bit intéressant
|
---|
301 | 0000a2 0ca3 rrf 0x23, f rrf roller,f
|
---|
302 | 0000a3 0ca3 rrf 0x23, f rrf roller,f
|
---|
303 | 0000a4 0ca0 rrf 0x20, f rrf byte,f
|
---|
304 | 0000a5 1c05 btfss 0x5, 0 RL5: btfss PORTA,0 ;Attend que l'horloge repasse à 1
|
---|
305 | 0000a6 28a5 goto 0xa5 goto RL5
|
---|
306 | 0000a7 0008 return return
|
---|
307 |
|
---|
308 | ; ---------- subroutines -----------------
|
---|
309 |
|
---|
310 | 0000a8 20af call 0xaf INHIB: call CLKLO ; inhibit mouse sending (CLK low)
|
---|
311 | 0000a9 207d call 0x7d call DEL200
|
---|
312 | 0000aa 0008 return return
|
---|
313 |
|
---|
314 | REL: ; allow mouse to send data
|
---|
315 | 0000ab 1683 bsf 0x3, 0x5 CLKHI: bsf STATUS,RP0 ; CLK high
|
---|
316 | 0000ac 1405 bsf 0x5, 0 bsf TRISA,0
|
---|
317 | 0000ad 1283 bcf 0x3, 0x5 bcf STATUS,RP0
|
---|
318 | 0000ae 0008 return return
|
---|
319 |
|
---|
320 | 0000af 1683 bsf 0x3, 0x5 CLKLO: bsf STATUS,RP0 ; CLK low
|
---|
321 | 0000b0 1005 bcf 0x5, 0 bcf TRISA,0
|
---|
322 | 0000b1 1283 bcf 0x3, 0x5 bcf STATUS,RP0
|
---|
323 | 0000b2 1005 bcf 0x5, 0 bcf PORTA,0
|
---|
324 | 0000b3 0008 return return
|
---|
325 |
|
---|
326 | 0000b4 1683 bsf 0x3, 0x5 DATLO: bsf STATUS,RP0 ; DATA low
|
---|
327 | 0000b5 1085 bcf 0x5, 0x1 bcf TRISA,1
|
---|
328 | 0000b6 1283 bcf 0x3, 0x5 bcf STATUS,RP0
|
---|
329 | 0000b7 1085 bcf 0x5, 0x1 bcf PORTA,1
|
---|
330 | 0000b8 0008 return return
|
---|
331 |
|
---|
332 | 0000b9 1683 bsf 0x3, 0x5 DATHI: bsf STATUS,RP0 ; DATA high
|
---|
333 | 0000ba 1485 bsf 0x5, 0x1 bsf TRISA,1
|
---|
334 | 0000bb 1283 bcf 0x3, 0x5 bcf STATUS,RP0
|
---|
335 | 0000bc 0008 return return
|
---|
336 |
|
---|
337 | send_bit
|
---|
338 | 0000bd 0ca0 rrf 0x20, f rrf byte,f ; send data bit
|
---|
339 | 0000be 1803 btfsc 0x3, 0 btfsc STATUS,C
|
---|
340 | 0000bf 28c2 goto 0xc2 goto DHIGH
|
---|
341 | 0000c0 20b4 call 0xb4 call DATLO
|
---|
342 | 0000c1 28c3 goto 0xc3 goto wait_h
|
---|
343 | 0000c2 20b9 call 0xb9 DHIGH: call DATHI
|
---|
344 | 0000c3 1c05 btfss 0x5, 0 wait_h: btfss PORTA,0
|
---|
345 | 0000c4 28c3 goto 0xc3 goto wait_h
|
---|
346 | 0000c5 1805 btfsc 0x5, 0 wait_l: btfsc PORTA,0
|
---|
347 | 0000c6 28c5 goto 0xc5 goto wait_l
|
---|
348 | 0000c7 0008 return return
|
---|
349 | ; ------------- send to mouse --------------
|
---|
350 |
|
---|
351 | 0000c8 20a8 call 0xa8 SEND: call INHIB ; CLK low
|
---|
352 | 0000c9 2081 call 0x81 call DEL10
|
---|
353 | 0000ca 20b4 call 0xb4 call DATLO ; DATA low
|
---|
354 | 0000cb 2081 call 0x81 call DEL10
|
---|
355 | 0000cc 20ab call 0xab call REL ; CLK high
|
---|
356 | 0000cd 1805 btfsc 0x5, 0 SL1: btfsc PORTA,0 ; wait for CLK
|
---|
357 | 0000ce 28cd goto 0xcd goto SL1
|
---|
358 | 0000cf 20bd call 0xbd call send_bit
|
---|
359 | 0000d0 20bd call 0xbd call send_bit
|
---|
360 | 0000d1 20bd call 0xbd call send_bit
|
---|
361 | 0000d2 20bd call 0xbd call send_bit
|
---|
362 | 0000d3 20bd call 0xbd call send_bit
|
---|
363 | 0000d4 20bd call 0xbd call send_bit
|
---|
364 | 0000d5 20bd call 0xbd call send_bit
|
---|
365 | 0000d6 20bd call 0xbd call send_bit
|
---|
366 | 0000d7 20e0 call 0xe0 call SNDPAR ; send parity bit
|
---|
367 | 0000d8 20c3 call 0xc3 call wait_h
|
---|
368 | 0000d9 20b9 call 0xb9 call DATHI ; release bus
|
---|
369 | 0000da 20c3 call 0xc3 call wait_h
|
---|
370 | 0000db 1c05 btfss 0x5, 0 SL7: btfss PORTA,0
|
---|
371 | 0000dc 28db goto 0xdb goto SL7
|
---|
372 | 0000dd 1c85 btfss 0x5, 0x1 SL8: btfss PORTA,1
|
---|
373 | 0000de 28dd goto 0xdd goto SL8
|
---|
374 | 0000df 0008 return return
|
---|
375 |
|
---|
376 | ; -------------- subroutines --------------
|
---|
377 |
|
---|
378 |
|
---|
379 | 0000e0 1821 btfsc 0x21, 0 SNDPAR: btfsc parity,0 ; send parity bit
|
---|
380 | 0000e1 28b9 goto 0xb9 goto DATHI
|
---|
381 | 0000e2 28b4 goto 0xb4 goto DATLO
|
---|
382 |
|
---|
383 | NEWPAR: ; calculate parity bit
|
---|
384 | 0000e3 01a2 clrf 0x22 clrf parcnt
|
---|
385 | 0000e4 1820 btfsc 0x20, 0 btfsc byte,0
|
---|
386 | 0000e5 0aa2 incf 0x22, f incf parcnt,f
|
---|
387 | 0000e6 18a0 btfsc 0x20, 0x1 btfsc byte,1
|
---|
388 | 0000e7 0aa2 incf 0x22, f incf parcnt,f
|
---|
389 | 0000e8 1920 btfsc 0x20, 0x2 btfsc byte,2
|
---|
390 | 0000e9 0aa2 incf 0x22, f incf parcnt,f
|
---|
391 | 0000ea 19a0 btfsc 0x20, 0x3 btfsc byte,3
|
---|
392 | 0000eb 0aa2 incf 0x22, f incf parcnt,f
|
---|
393 | 0000ec 1a20 btfsc 0x20, 0x4 btfsc byte,4
|
---|
394 | 0000ed 0aa2 incf 0x22, f incf parcnt,f
|
---|
395 | 0000ee 1aa0 btfsc 0x20, 0x5 btfsc byte,5
|
---|
396 | 0000ef 0aa2 incf 0x22, f incf parcnt,f
|
---|
397 | 0000f0 1b20 btfsc 0x20, 0x6 btfsc byte,6
|
---|
398 | 0000f1 0aa2 incf 0x22, f incf parcnt,f
|
---|
399 | 0000f2 1ba0 btfsc 0x20, 0x7 btfsc byte,7
|
---|
400 | 0000f3 0aa2 incf 0x22, f incf parcnt,f
|
---|
401 | 0000f4 1021 bcf 0x21, 0 bcf parity,0
|
---|
402 | 0000f5 1c22 btfss 0x22, 0 btfss parcnt,0
|
---|
403 | 0000f6 1421 bsf 0x21, 0 bsf parity,0
|
---|
404 | 0000f7 0008 return return
|
---|
405 |
|
---|
406 | ; --------------- conversion to Amiga format --------------
|
---|
407 |
|
---|
408 | CONV:
|
---|
409 | 0000f8 1332 bcf 0x32, 0x6 bcf savb,6
|
---|
410 | 0000f9 1c24 btfss 0x24, 0 btfss pack1,0 ; left button
|
---|
411 | 0000fa 1732 bsf 0x32, 0x6 bsf savb,6
|
---|
412 | 0000fb 1032 bcf 0x32, 0 bcf savb,0
|
---|
413 | 0000fc 1ca4 btfss 0x24, 0x1 btfss pack1,1 ; right button
|
---|
414 | 0000fd 1432 bsf 0x32, 0 bsf savb,0
|
---|
415 | 0000fe 10b2 bcf 0x32, 0x1 bcf savb,1
|
---|
416 | 0000ff 1d24 btfss 0x24, 0x2 btfss pack1,2 ; middle button
|
---|
417 | 000100 14b2 bsf 0x32, 0x1 bsf savb,1
|
---|
418 |
|
---|
419 | 000101 0806 movf 0x6, w movf PORTB,w ;read port b
|
---|
420 | 000102 39bc andlw 0xbc andlw b'10111100' ;keep button state
|
---|
421 | 000103 0432 iorwf 0x32, w iorwf savb,w ;merge with new x and y patterns
|
---|
422 | 000104 0086 movwf 0x6 movwf PORTB ;ouput patterns
|
---|
423 |
|
---|
424 | 000105 0825 movf 0x25, w movf pack2,W ; mouvement conversion
|
---|
425 | 000106 39ff andlw 0xff andlw 0xff
|
---|
426 | 000107 1d03 btfss 0x3, 0x2 btfss STATUS,Z
|
---|
427 | 000108 2137 call 0x137 call MOVEX
|
---|
428 | 000109 0826 movf 0x26, w movf pack3,W
|
---|
429 | 00010a 39ff andlw 0xff andlw 0xff
|
---|
430 | 00010b 1903 btfsc 0x3, 0x2 btfsc STATUS,Z
|
---|
431 | 00010c 0008 return return
|
---|
432 |
|
---|
433 | 00010d 1ea4 btfss 0x24, 0x5 MOVEY: btfss pack1,5
|
---|
434 | 00010e 2923 goto 0x123 goto DOWN
|
---|
435 |
|
---|
436 | 00010f 207d call 0x7d UP: call DEL200 ; send V and VQ for up movement
|
---|
437 | 000110 0aa8 incf 0x28, f incf toggley,f
|
---|
438 | 000111 1828 btfsc 0x28, 0 btfsc toggley,0
|
---|
439 | 000112 0eac swapf 0x2c, f swapf tempya,f
|
---|
440 | 000113 082c movf 0x2c, w movfw tempya
|
---|
441 | 000114 0533 andwf 0x33, w andwf bitya,w
|
---|
442 | 000115 00ae movwf 0x2e movwf temp
|
---|
443 | 000116 1c28 btfss 0x28, 0 btfss toggley,0
|
---|
444 | 000117 0ead swapf 0x2d, f swapf tempyb,f
|
---|
445 | 000118 082d movf 0x2d, w movfw tempyb
|
---|
446 | 000119 0534 andwf 0x34, w andwf bityb,w
|
---|
447 | 00011a 07ae addwf 0x2e, f addwf temp,f
|
---|
448 | 00011b 0832 movf 0x32, w movfw savb
|
---|
449 | 00011c 0530 andwf 0x30, w andwf masky,w ;b'11001111'
|
---|
450 | 00011d 072e addwf 0x2e, w addwf temp,w
|
---|
451 | 00011e 0086 movwf 0x6 movwf PORTB ;ouput patterns
|
---|
452 | 00011f 00b2 movwf 0x32 movwf savb
|
---|
453 | 000120 0fa6 incfsz 0x26, f incfsz pack3,f
|
---|
454 | 000121 290f goto 0x10f goto UP
|
---|
455 | 000122 0008 return return
|
---|
456 |
|
---|
457 | 000123 207d call 0x7d DOWN: call DEL200 ; send V and VQ for down movement
|
---|
458 | 000124 0aa8 incf 0x28, f incf toggley,f
|
---|
459 | 000125 1c28 btfss 0x28, 0 btfss toggley,0
|
---|
460 | 000126 0eac swapf 0x2c, f swapf tempya,f
|
---|
461 | 000127 082c movf 0x2c, w movfw tempya
|
---|
462 | 000128 0533 andwf 0x33, w andwf bitya,w
|
---|
463 | 000129 00ae movwf 0x2e movwf temp
|
---|
464 | 00012a 1828 btfsc 0x28, 0 btfsc toggley,0
|
---|
465 | 00012b 0ead swapf 0x2d, f swapf tempyb,f
|
---|
466 | 00012c 082d movf 0x2d, w movfw tempyb
|
---|
467 | 00012d 0534 andwf 0x34, w andwf bityb,w
|
---|
468 | 00012e 07ae addwf 0x2e, f addwf temp,f
|
---|
469 | 00012f 0832 movf 0x32, w movfw savb
|
---|
470 | 000130 0530 andwf 0x30, w andwf masky,w ;b'11001111'
|
---|
471 | 000131 072e addwf 0x2e, w addwf temp,w
|
---|
472 | 000132 0086 movwf 0x6 movwf PORTB ;ouput patterns
|
---|
473 | 000133 00b2 movwf 0x32 movwf savb
|
---|
474 | 000134 0ba6 decfsz 0x26, f decfsz pack3,f
|
---|
475 | 000135 2923 goto 0x123 goto DOWN
|
---|
476 | 000136 0008 return return
|
---|
477 |
|
---|
478 | 000137 1e24 btfss 0x24, 0x4 MOVEX: btfss pack1,4
|
---|
479 | 000138 294d goto 0x14d goto LEFT
|
---|
480 |
|
---|
481 | 000139 207d call 0x7d RIGHT: call DEL200 ; send H and HQ for right movement
|
---|
482 | 00013a 0aa7 incf 0x27, f incf togglex,f ; bon la c'est bobo la tete !
|
---|
483 | 00013b 1c27 btfss 0x27, 0 btfss togglex,0 ; le pattern est sur un nibble
|
---|
484 | 00013c 0eaa swapf 0x2a, f swapf tempxa,f ; nibble = 4 bits
|
---|
485 | 00013d 082a movf 0x2a, w movfw tempxa ; seul un bit est urilisé dans le pattern
|
---|
486 | 00013e 0535 andwf 0x35, w andwf bitxa,w
|
---|
487 | 00013f 00ae movwf 0x2e movwf temp ; donc on swap les nibble un fois sur deux avec un decalage
|
---|
488 | 000140 1827 btfsc 0x27, 0 btfsc togglex,0 ; entre x et y (c'est la le bobo la tete)
|
---|
489 | 000141 0eab swapf 0x2b, f swapf tempxb,f ; de facon a se retouvé avec le pattern suivant
|
---|
490 | 000142 082b movf 0x2b, w movfw tempxb ; 00 , 01, 11 puis 10 aye!
|
---|
491 | 000143 0536 andwf 0x36, w andwf bitxb,w
|
---|
492 | 000144 07ae addwf 0x2e, f addwf temp,f ; pourquoi ? > marche quelque soit le pattern!!(amiga / atari)
|
---|
493 | 000145 0832 movf 0x32, w movfw savb
|
---|
494 | 000146 052f andwf 0x2f, w andwf maskx,w ;b'11001111'
|
---|
495 | 000147 072e addwf 0x2e, w addwf temp,w
|
---|
496 | 000148 0086 movwf 0x6 movwf PORTB ;ouput patterns
|
---|
497 | 000149 00b2 movwf 0x32 movwf savb
|
---|
498 | 00014a 0fa5 incfsz 0x25, f incfsz pack2,f
|
---|
499 | 00014b 2939 goto 0x139 goto RIGHT
|
---|
500 | 00014c 0008 return return
|
---|
501 | LEFT:
|
---|
502 | 00014d 207d call 0x7d call DEL200 ; send H and HQ for left movement
|
---|
503 | 00014e 0aa7 incf 0x27, f incf togglex,f
|
---|
504 | 00014f 1827 btfsc 0x27, 0 btfsc togglex,0
|
---|
505 | 000150 0eaa swapf 0x2a, f swapf tempxa,f
|
---|
506 | 000151 082a movf 0x2a, w movfw tempxa
|
---|
507 | 000152 0535 andwf 0x35, w andwf bitxa,w
|
---|
508 | 000153 00ae movwf 0x2e movwf temp
|
---|
509 | 000154 1c27 btfss 0x27, 0 btfss togglex,0
|
---|
510 | 000155 0eab swapf 0x2b, f swapf tempxb,f
|
---|
511 | 000156 082b movf 0x2b, w movfw tempxb
|
---|
512 | 000157 0536 andwf 0x36, w andwf bitxb,w
|
---|
513 | 000158 07ae addwf 0x2e, f addwf temp,f
|
---|
514 | 000159 0832 movf 0x32, w movfw savb
|
---|
515 | 00015a 052f andwf 0x2f, w andwf maskx,w ;b'11001111'
|
---|
516 | 00015b 072e addwf 0x2e, w addwf temp,w
|
---|
517 | 00015c 0086 movwf 0x6 movwf PORTB ;ouput patterns
|
---|
518 | 00015d 00b2 movwf 0x32 movwf savb
|
---|
519 | 00015e 0ba5 decfsz 0x25, f decfsz pack2,f
|
---|
520 | 00015f 294d goto 0x14d goto LEFT
|
---|
521 | 000160 0008 return return
|
---|
522 |
|
---|
523 | inter: ;Gestion des interruptions
|
---|
524 | 000161 0009 retfie retfie ;ne fait rien
|
---|
525 | end
|
---|
526 |
|
---|