Skip to content

Commit 9d955b9

Browse files
committed
Files required to for RA8KEY (Remote Atari 8-Bit Keyboard)
Folders: COMMON - - CIO-Routines: Common Routines for displaying output - DRIVER_PROTECTION - Protect driver from reset - KEYCODE - routines to inject ATASCII into the Atari RA8KEY - Atari side of Remote Keyboard RA8-win - Windows side to inject keystrokes into Atari
1 parent a7d6e70 commit 9d955b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3932
-0
lines changed

COMMON/CIO-Routines.asm

Lines changed: 631 additions & 0 deletions
Large diffs are not rendered by default.

COMMON/CIO-Routines.lab

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mads 2.0.6 build 58 (28 Jan 17)
2+
Label table:

COMMON/DRIVER_PROTECTION.ASM

Lines changed: 374 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,374 @@
1+
; Driver protection
2+
;
3+
; Make generic by Norman Davie
4+
; Adapted from code by Thomas Cherryhomes
5+
;
6+
7+
; Pointers used by relocator.
8+
9+
RELOCATE_TABLE = $A2
10+
RELOCATE_TABLE_LO = $A2
11+
RELOCATE_TABLE_HI = $A3
12+
13+
SRC_ADDR = $A4
14+
SRC_ADDR_LO = $A4
15+
SRC_ADDR_HI = $A5
16+
17+
FROM: = $A6
18+
FROM_LO: = $A6
19+
FROM_HI: = $A7
20+
21+
TO: = $A8
22+
TO_LO = $A8
23+
TO_HI = $A9
24+
25+
MOD_ADDR = $AA
26+
MOD_ADDR_LO = $AA
27+
MOD_ADDR_HI = $AB
28+
29+
; INTERRUPT VECTORS
30+
; AND OTHER PAGE 2 VARS
31+
32+
VPRCED = $0202 ; PROCEED VCTR
33+
MEMLO = $02E7 ; MEM LO
34+
35+
SETVBV = $E45C
36+
XITVBV = $E462
37+
38+
; HARDWARE REGISTERS
39+
40+
PACTL = $D302 ; PIA CTRL A
41+
42+
;DEBUG = $AD
43+
44+
; A = Low byte of relocation table
45+
; Y = high byte of relocation table
46+
47+
48+
;;; RESET HANDLER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
49+
;
50+
;RESET:
51+
; JSR $FFFF ; Modified for original DOSINI
52+
; LDA #$FF ; Driver end LO
53+
; STA MEMLO
54+
; LDA #$FF ; Driver end HI
55+
; STA MEMLO+1
56+
; JSR INIT ; call any inits.
57+
; JSR CLALL
58+
; RTS
59+
;;; END RESET HANDLER ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
60+
61+
RELOCATE_TO_MEMLO:
62+
63+
STA RELOCATE_TABLE_LO
64+
STY RELOCATE_TABLE_HI
65+
66+
67+
.ifdef DEBUG
68+
LDA #$00
69+
STA DEBUG
70+
.endif
71+
LDA MEMLO
72+
STA TO_LO
73+
LDA MEMLO+1
74+
STA TO_HI
75+
76+
; First entry in relocation table
77+
; is the SOURCE ADDRESS of the block
78+
79+
LDY #$00
80+
81+
LDA (RELOCATE_TABLE),Y
82+
STA SRC_ADDR_LO
83+
STA FROM_LO
84+
INY
85+
LDA (RELOCATE_TABLE),Y
86+
STA SRC_ADDR_HI
87+
STA FROM_HI
88+
89+
; Second entry in relocation table
90+
; is the size of the block
91+
92+
INY
93+
LDA (RELOCATE_TABLE),Y
94+
STA RELOCATE_SIZE_LO
95+
STA COPY_SIZE_LO
96+
INY
97+
LDA (RELOCATE_TABLE),Y
98+
STA RELOCATE_SIZE_HI
99+
STA COPY_SIZE_HI
100+
101+
.ifdef DEBUG
102+
; It may appear this is unnecessary since we're
103+
; dong it twice, but actually we need the data
104+
; present in order to use these routines
105+
; while we're moving
106+
107+
LDA MEMLO
108+
STA TO_LO
109+
LDA MEMLO+1
110+
STA TO_HI
111+
112+
TYA
113+
PHA
114+
JSR MOVE_TO_TARGET
115+
PLA
116+
TAY
117+
118+
LDA MEMLO
119+
STA TO_LO
120+
LDA MEMLO+1
121+
STA TO_HI
122+
.endif
123+
124+
125+
; Third entry is the number of relocation entries
126+
127+
INY
128+
LDA (RELOCATE_TABLE),Y
129+
TAX
130+
131+
; Figure out how much we need to modify
132+
; the addresses by
133+
134+
LDA SRC_ADDR_LO
135+
SEC
136+
SBC TO_LO
137+
STA DIFF_LO
138+
139+
LDA SRC_ADDR_HI
140+
SBC TO_HI
141+
STA DIFF_HI
142+
143+
; For easier calculations of the more than
144+
; 128 entries, we're going to reset the Y
145+
; to zero and work from the start of the table entries.
146+
; That way we just need to update the high
147+
; order byte by one when we go back to zero
148+
149+
INY
150+
STY START_OF_TABLE
151+
152+
LDA RELOCATE_TABLE_LO
153+
CLC
154+
ADC START_OF_TABLE
155+
STA RELOCATE_TABLE_LO
156+
157+
LDA RELOCATE_TABLE_HI
158+
ADC #$00
159+
STA RELOCATE_TABLE_HI
160+
161+
LDY #$00
162+
163+
164+
MODIFY_TABLE:
165+
166+
; add one byte to the address
167+
; (we were currently pointing at the instruction)
168+
169+
CLC ; add one to the relocation table address
170+
LDA (RELOCATE_TABLE),Y
171+
ADC #$01
172+
STA (RELOCATE_TABLE),Y
173+
174+
INY
175+
LDA (RELOCATE_TABLE),Y
176+
ADC #$00
177+
STA (RELOCATE_TABLE),Y
178+
179+
DEY ; back to the original table address
180+
181+
; now the table is pointing at the address
182+
183+
MODIFY_CODE:
184+
185+
; we've updated the table entry to point at the address
186+
; we are to modify, calculate the new destination address
187+
188+
189+
; read the address we're to modify
190+
191+
LDA (RELOCATE_TABLE),Y ; The lo address in the table
192+
STA MOD_ADDR_LO
193+
194+
INY
195+
LDA (RELOCATE_TABLE),Y ; the hi address in the table
196+
STA MOD_ADDR_HI
197+
198+
; Need the Y for later; save it
199+
TYA
200+
PHA
201+
202+
.ifdef DEBUG
203+
LDA DEBUG
204+
BEQ DEBUG_SKIP1
205+
206+
TXA
207+
PHA
208+
TYA
209+
PHA
210+
JSR PRINT_HEX_NO_EOL
211+
LDA #<DEBUG_ARROW
212+
LDY #>DEBUG_ARROW
213+
JSR PRINT_STRING_NO_EOL
214+
215+
PLA
216+
TAY
217+
218+
LDA (RELOCATE_TABLE),Y ; the hi address in the table
219+
JSR PRINT_HEX_NO_EOL
220+
DEY
221+
LDA (RELOCATE_TABLE),Y
222+
JSR PRINT_HEX_NO_EOL
223+
224+
TYA
225+
PHA
226+
LDA #<DEBUG_ARROW
227+
LDY #>DEBUG_ARROW
228+
JSR PRINT_STRING_NO_EOL
229+
PLA
230+
TAY
231+
232+
PLA
233+
TAX
234+
DEBUG_SKIP1
235+
.endif
236+
237+
; load the address and subtract the difference
238+
; save the new address back
239+
240+
LDY #$00
241+
LDA (MOD_ADDR),Y;
242+
SEC
243+
SBC DIFF_LO
244+
STA (MOD_ADDR),Y
245+
246+
INY
247+
LDA (MOD_ADDR),Y
248+
SBC DIFF_HI
249+
STA (MOD_ADDR),Y
250+
251+
.ifdef DEBUG
252+
LDA DEBUG
253+
BEQ DEBUG_SKIP2
254+
LDA (MOD_ADDR),Y
255+
JSR PRINT_HEX_NO_EOL
256+
DEY
257+
LDA (MOD_ADDR),Y
258+
JSR PRINT_HEX
259+
INY
260+
DEBUG_SKIP2
261+
262+
; JSR WAIT_FOR_RETURN
263+
.endif
264+
265+
; get our y back
266+
PLA
267+
TAY
268+
269+
.ifdef DEBUG
270+
CPY #$B1
271+
BNE SKIP3
272+
LDA #$01
273+
STA DEBUG
274+
SKIP3:
275+
.endif
276+
DEX
277+
BEQ TABLE_EXHAUSTED
278+
279+
INY ; next entry
280+
BNE MODIFY_TABLE
281+
; We've wrapped back to zero
282+
LDY #$00
283+
INC RELOCATE_TABLE_HI
284+
CLC
285+
BCC MODIFY_TABLE
286+
287+
TABLE_EXHAUSTED:
288+
289+
LDA MEMLO
290+
STA TO_LO
291+
LDA MEMLO+1
292+
STA TO_HI
293+
294+
JSR MOVE_TO_TARGET
295+
JSR ADJUST_MEMLO
296+
RTS
297+
298+
MOVE_TO_TARGET:
299+
300+
LDY #0
301+
LDX COPY_SIZE_HI
302+
BEQ MD2
303+
MD1 LDA (FROM),Y ; move a page at a time
304+
STA (TO),Y
305+
INY
306+
BNE MD1
307+
INC FROM+1
308+
INC TO+1
309+
DEX
310+
BNE MD1
311+
MD2 LDX COPY_SIZE_LO
312+
BEQ MOVE_COMPLETED
313+
MD3 LDA (FROM),Y ; move the remaining bytes
314+
STA (TO),Y
315+
INY
316+
DEX
317+
BNE MD3
318+
319+
MOVE_COMPLETED
320+
RTS
321+
322+
ADJUST_MEMLO:
323+
324+
; ADJUST MEMLO TO PROTECT US
325+
326+
SEI
327+
CLC
328+
LDA MEMLO
329+
ADC RELOCATE_SIZE_LO
330+
STA MEMLO
331+
LDA MEMLO+1
332+
ADC RELOCATE_SIZE_HI
333+
STA MEMLO+1
334+
CLI
335+
336+
RTS
337+
338+
339+
; Each entry is points to the instruction
340+
; (not the address) we need to relocate
341+
342+
343+
RELOCATE_SIZE:
344+
RELOCATE_SIZE_LO: .BYTE $00
345+
RELOCATE_SIZE_HI: .BYTE $00
346+
347+
COPY_SIZE:
348+
COPY_SIZE_LO: .BYTE $00
349+
COPY_SIZE_HI: .BYTE $00
350+
351+
DIFF:
352+
DIFF_LO: .BYTE $00
353+
DIFF_HI: .BYTE $00
354+
355+
START_OF_TABLE .BYTE $00
356+
FIRST_TIME .BYTE $01
357+
358+
359+
360+
DEBUG1:
361+
DEBUG1_LO: .BYTE $00
362+
DEBUG1_HI .BYTE $00
363+
364+
DEBUG2:
365+
DEBUG2_LO: .BYTE $00
366+
DEBUG2_HI .BYTE $00
367+
368+
DEBUG3:
369+
DEBUG3_LO: .BYTE $00
370+
DEBUG3_HI: .BYTE $00
371+
372+
Y: .BYTE $00
373+
374+
DEBUG_ARROW: .BYTE ' -> ',0

COMMON/DRIVER_PROTECTION.lab

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mads 2.0.6 build 58 (28 Jan 17)
2+
Label table:

0 commit comments

Comments
 (0)