-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMKT.ASM
More file actions
346 lines (314 loc) · 6.42 KB
/
MKT.ASM
File metadata and controls
346 lines (314 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
; -------------- Multi Key Test ----------------
; (c) PASCAL BOURON , bouron@ens-cachan.fr
; ----------------------------------------------
;
; For several games, ( 2 players game , game
; with 8 directions move, or fire with movement)
; you must test if two (or plus) key is pressed
; So I have do this small example for show how
; you can do that. I test also if a byte is
; receive in the link port ( If you want do
; a game with 4 players (2 TI))
;
; I test exit,F1,F2,F3,F4,F5
;
; To quit press exit or send a $00 in the link port
;
;
; If you have questions or suggestions e-mail me.
;
#INCLUDE "TI-85.H"
;-------------------------------------------
; Program data stored in text memory (80DF)
;-------------------------------------------
x =$80DF
error_nb =$80E0
bit =$80E1
counter =$80E2
last =$80E3
;---------------------------------------------
; Program Title
;---------------------------------------------
.org 0
.db " Multi-Key Test by BP",0
ROM_CALL(CLEARLCD)
ld de,(PROGRAM_ADDR)
ld hl,Titre
add hl,de
ROM_CALL(D_ZT_STR)
;
key_loop1:
call GET_KEY ; Classic call ...
or a ; set flag
jr z, key_loop1
DI
cp $37 ; Exit pressed ?
jr nz,no_key
;-======================-
; Exit
;-======================-
exit:
EI
RET
;------------------------
no_key:
ROM_CALL(CLEARLCD)
wait_key:
CALL_(Read_byte)
ld a,(error_nb)
cp 1
jr z,next2
ld a,(x)
;----------------------------------------------------
; You can do some actions with the value
; of the received byte .
; Here , if it's a $00 : exit
;
; Put your different test here :
; cp value
; jr z, routine
cp 0
jr z, exit
;
;
;
;
;
;
;---------------------------------------------------
next2:
ld hl,$0000
ld (CURSOR_ROW),hl
ld a,$BF ; $BF = 1011 1111b
out (1),a
in a,(1) ;
cp $ff ; A key is pressed ?
jr z,no_key ;
;Bit 6
in a,(1)
bit 6,a ; bit 6 => EXIT
jr z,exit
ld b,a
ld a,(last)
cp b
jr z,wait_key
ROM_CALL(CLEARLCD)
ld a,b
ld (last),a
;Bit 7
in a,(1)
bit 7,a ; bit 7 => MORE
CALL_Z(kp_more)
;Bit 5
in a,(1)
bit 5,a ; bit 5 => 2NDE
CALL_Z(kp_2nd)
;Bit 4
in a,(1)
bit 4,a ; bit 4 => F1
CALL_Z(kp_f1)
;Bit 3
in a,(1)
bit 3,a ; bit 3 => F2
CALL_Z(kp_f2)
;Bit 2
in a,(1)
bit 2,a ; bit 2 => F3
CALL_Z(kp_f3)
;Bit 1
in a,(1)
bit 1,a ; bit 1 => F4
CALL_Z(kp_f4)
;Bit 0
in a,(1)
bit 0,a ; bit 0 => F5
CALL_Z(kp_f5)
; -------------- end of the tests --------
bit_end:
JUMP_(wait_key)
;-==============================================-
; ACTIONS
;-==============================================-
kp_more :
ld a,0
ld (CURSOR_ROW),a
ld a,0
ld (CURSOR_COL),a
ld de,(PROGRAM_ADDR)
ld hl,data
add hl,de
ROM_CALL(D_ZT_STR)
ret
kp_2nd :
ld a,1
ld (CURSOR_ROW),a
ld a,0
ld (CURSOR_COL),a
ld hl,8
ld de,(PROGRAM_ADDR)
add hl,de
ld de,data
add hl,de
ROM_CALL(D_ZT_STR)
ret
kp_f1 :
ld l,$10
jr kp_f
kp_f2 :
ld l,$14
jr kp_f
kp_f3 :
ld l,$18
jr kp_f
kp_f4 :
ld l,$1C
jr kp_f
kp_f5 :
ld l,$20
kp_f:
ld a,l
sub $10
rr a
rr a
and $7
add a,3
ld (CURSOR_ROW),a
ld a,0
ld (CURSOR_COL),a
ld h,0
ld de,(PROGRAM_ADDR)
add hl,de
ld de,data
add hl,de
ROM_CALL(D_ZT_STR)
ret
data:
.db "MORE ",0
.db "2 nde ",0
.db "F1 ",0
.db "F2 ",0
.db "F3 ",0
.db "F4 ",0
.db "F5 ",0
;-===========================================-
; Read_byte
;-===========================================-
; INPUT : no
; OUTPUT :(x) =Read byte value
; (error_nb) =# of the error
; MODIFIED:(bit)
; (counter)
Read_byte:
push af
push bc
push de
push hl
ld a,1 ; for the OR
ld (bit),a
ld a,0 ; byte receive
ld (x),a
ld a,8 ; counter
ld (counter),a
ld a,$C0
out (7),a
rb_Loop_wait_1st_bit:
jr rb_Loop_wait_bit
rb_Loop_wait_bit2:
ld a,b
ld (counter),a
rb_Loop_wait_bit:
ld d,$10 ; timer
rb_w_Start:
in a,(7)
and 3
cp 3
jr nz,rb_get_bit
CALL_(rb_delay)
dec d ;d=0 => erreur
jr nz,rb_w_Start ;Attend le un bit
ld a,1
jr rb_error
rb_Loop_tmp:
jr rb_Loop_wait_bit2
rb_get_bit:
cp 2
jr z,rb_receive_zero
ld a,(bit)
ld e,a
ld a,(x)
or e
ld (x),a
ld a,$D4
out (7),a
ld d,$10
rb_wait_Stop1:
in a,(7)
and 2
cp 2
jr z,rb_suite_receive
CALL_(rb_delay)
dec d
jr nz,rb_wait_Stop1
; If error ...
ld a,2
rb_error:
ld (error_nb),a
ld a,$C0
out (7),a
jr rb_fin
rb_receive_zero:
ld a,$E8
out (7),a
ld d,$10
rb_wait_Stop0:
in a,(7)
and 1
cp 1
jr z,rb_suite_receive
CALL_(rb_delay)
dec d
jr nz,rb_wait_Stop0
; If error ...
ld a,3
jr rb_error
rb_suite_receive:
ld a,$c0
out (7),a
ld a,(bit)
add a,a
ld (bit),a
ld a,(counter)
ld b,a
djnz rb_Loop_tmp
ld a,$FF ; No error
ld (error_nb),a
rb_fin:
pop hl
pop de
pop bc
pop af
ret
;
; DELAY
;
rb_delay:
push af
push bc
ld bc, $80
rb_delayLoop:
dec bc
ld a, b
or c
jr nz, rb_delayLoop
pop bc
pop af
ret
Titre:
.db " "
.db " Multi Key Test "
.db " (c) Pascal Bouron "
.db " "
.db " Press a key,then : "
.db "Try F1 F2 F3 F4 F5 "
.db " 2nd and more.",0
.END