Skip to content

Commit a9b3dec

Browse files
committed
Create CARDUTIL.FTH
1 parent f6fb0ae commit a9b3dec

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

LIB.ITC/Utilities/CARDUTIL.FTH

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
\ CARDUTIL.FTH lets you search for and examine cards in your system
2+
NEEDS .S FROM DSK1.TOOLS
3+
NEEDS COMPARE FROM DSK1.COMPARE
4+
NEEDS MARKER FROM DSK1.MARKER
5+
6+
MARKER /CARDS
7+
8+
HEX
9+
\ *set the CRU address in 'R12 before using these words*
10+
CODE 0SBO ( -- ) 1D00 , NEXT, ENDCODE
11+
CODE 0SBZ ( -- ) 1E00 , NEXT, ENDCODE
12+
13+
4000 CONSTANT 'ID \ address of 'AA' byte
14+
00AA CONSTANT 'AA' \ id byte for TI-99 cards
15+
16+
DECIMAL
17+
24 USER 'R12 \ address of R12 in any Camel99 Forth task
18+
19+
: ?CARD ( c -- ) 'ID C@ <> ABORT" Bad card address" ; \ test ID byte
20+
21+
: CARDON ( CRUaddr -- ) 'R12 ! 0SBO ;
22+
: CARDOFF 'R12 ! 0SBZ ;
23+
24+
HEX
25+
26+
: CARDDUMP ( CRUaddr -- ) DUP>R CARDON 4000 200 DUMP R> CARDOFF ;
27+
28+
: ALLCARDS ( -- )
29+
BASE @ >R
30+
HEX
31+
0F00 \ dummy CRU address
32+
BEGIN
33+
0100 + \ next card address
34+
DUP CARDON
35+
'ID C@ 'AA' = \ test if card present
36+
IF
37+
CR ." Card found at:>" DUP U.
38+
THEN
39+
0SBZ \ turn the card off
40+
DUP 2000 = \ last address ?
41+
UNTIL
42+
DROP
43+
R> BASE ! ;
44+
45+
: DSRLIST ( CARDaddr -- )
46+
CARDON 'AA' ?CARD \ test ID byte
47+
CR ." DSR Code Address
48+
CR ." ----- ------------
49+
'ID 08 + \ fetch pointer to DSR list
50+
BEGIN
51+
@ \ fetch list item
52+
DUP \ test it for zero (end of list)
53+
WHILE
54+
DUP 4 + COUNT \ get the counted string as addr,len
55+
CR TYPE \ Print name
56+
DUP 4 + COUNT + ALIGNED CELL+ @ 12 OUT @ - SPACES U.
57+
REPEAT
58+
0SBZ
59+
DROP ;
60+
61+
: SUBLIST ( CARDaddr -- )
62+
CARDON 'AA' ?CARD \ test ID byte
63+
'ID 0A + \ fetch pointer to DSR list
64+
BEGIN
65+
@ \ fetch list item
66+
DUP \ test it for zero (end of list)
67+
WHILE
68+
DUP 4 + \ get address of the id field
69+
DUP C@ 1 =
70+
IF
71+
@ . ." , " \ it's a number
72+
ELSE
73+
COUNT TYPE \ convert to addr,len & type with comma
74+
THEN . ." , "
75+
REPEAT
76+
0SBZ
77+
DROP ;
78+
79+
: /CUT ( caddr len char -- caddr len') >R 2DUP R> SCAN NIP - ;
80+
81+
CREATE DEV$ 8 ALLOT
82+
83+
: DSRFIND ( caddr len CARDaddr -- 0 | length)
84+
CARDON 'AA' ?CARD
85+
[CHAR] . /CUT DEV$ PLACE
86+
FALSE \ false flag is default result
87+
'ID 8 + \ rpush pointer to DSR list
88+
BEGIN
89+
@ DUP \ fetch next list item
90+
WHILE
91+
DUP 4 + COUNT DEV$ COUNT COMPARE
92+
0= IF
93+
\ DROP DROP
94+
DEV$ C@ \ return length of device string
95+
EXIT
96+
THEN
97+
REPEAT
98+
DROP ;
99+
100+
101+
102+
: GO
103+
WARM
104+
CR ." TI-99 Card utility, Brian Fox"
105+
CR
106+
CR ." ALLCARDS List of cards with CRU"
107+
CR ." <cruaddr> DSRLIST shows DSR names"
108+
CR ." <cruaddr> CARDON Turn on card"
109+
CR ." <cruaddr> CARDOFF Turn off card"
110+
CR ." <cruaddr> SUBLIST list subprograms"
111+
CR ." <string> <cruaddr> DSRFIND "
112+
CR ." <cruaddd> CARDDUMP HEX dump card"
113+
ABORT
114+
;
115+
116+
117+
LOCK
118+
INCLUDE DSK1.SAVESYS
119+
120+
' GO SAVESYS DSK8.CARDUTIL

0 commit comments

Comments
 (0)