2242
|
1 *********************************************************************************
|
|
2 * dw - send commands to DriveWire server
|
|
3 *
|
|
4 * using a virtual channel from DriveWire, send commands and write results
|
|
5 * to stdout.
|
|
6 *
|
|
7 * version 0.1 - 12/17/09 - AAW - bare minimum implementation
|
|
8 *
|
|
9
|
|
10 nam dw
|
|
11 ttl program module
|
|
12
|
|
13 ifp1
|
|
14 use defsfile
|
|
15 endc
|
|
16
|
|
17 tylg set Prgrm+Objct
|
|
18 atrv set ReEnt+rev
|
|
19 rev set $00
|
|
20 edition set 1
|
|
21
|
|
22 mod eom,name,tylg,atrv,start,size
|
|
23 pbuffer rmb 256
|
|
24 portdev rmb 10
|
|
25 portpath rmb 1
|
|
26 numbyt rmb 1
|
|
27
|
|
28 size equ .
|
|
29
|
|
30 name fcs /dw/
|
|
31 fcb edition
|
|
32
|
|
33 ******************************************
|
|
34 * writech - write character in A to screen
|
|
35 * In:
|
|
36 * A = character to write
|
|
37 *
|
|
38
|
|
39 writech pshs y,x,a ;preserve regs + put A on stack for write
|
|
40 lda #1 ;path 1
|
|
41 ldy #1 ;1 character
|
|
42 leax ,s ;write from stack
|
|
43 os9 I$Write ;write it
|
|
44 puls a,x,y,pc ;return
|
|
45
|
|
46 * write out the contents of pbuffer.. length is in numbyt
|
|
47 writepb clra
|
|
48 ldb numbyt,u
|
|
49 tfr d,y
|
|
50 lda #1
|
|
51 leax pbuffer,u
|
|
52 os9 I$Write
|
|
53 wrpb02 rts
|
|
54
|
|
55 *************************************
|
|
56 * dw main
|
|
57 *
|
|
58
|
|
59 * default to port /t0.. and use it no matter what, maybe set on cmdline in future?
|
|
60 defport fcc '/t0'
|
|
61 fcb C$CR
|
|
62 fcb $00,$00
|
|
63
|
|
64 * initialization/startup?
|
|
65 start nop
|
|
66
|
|
67 * save parameters for later
|
|
68 pshs d
|
|
69 pshs x
|
|
70
|
2286
|
71 * see if we can find a port to use
|
2242
|
72
|
2286
|
73 * first setup pbuffer
|
|
74 leax pbuffer,u
|
|
75 lda #47
|
|
76 sta ,x+
|
|
77 lda #85
|
|
78 sta ,x+
|
|
79 lda #48
|
|
80 sta ,x+
|
|
81 lda #13
|
|
82 sta ,x
|
|
83
|
|
84 tryport lda #UPDAT. get mode for modem path
|
|
85 leax pbuffer,u point to modem path
|
|
86 os9 I$Open open it
|
|
87 bcc gotport
|
2242
|
88
|
2286
|
89 cmpb #250 ;in use?
|
|
90 lbne errex1 ;other error, bail out
|
|
91 leax pbuffer,u
|
|
92 lda 2,x
|
|
93 inca
|
|
94 sta 2,x
|
|
95 bra tryport
|
|
96
|
|
97 gotport sta portpath,u
|
|
98
|
|
99
|
2242
|
100 * write our name
|
|
101 ldy #0001
|
|
102 leax <name,pc
|
|
103 wrnlp lda ,x+
|
|
104 bmi wrnout ;this is the last char
|
|
105 pshs x
|
|
106 pshs a
|
|
107 lda portpath,u
|
|
108 leax ,s
|
|
109 os9 I$Write
|
|
110 leas 1,s
|
|
111 puls x
|
|
112 lbcs errex2
|
|
113 bra wrnlp
|
|
114
|
|
115 wrnout ldb #C$CR ;end with a CR
|
|
116 anda #$7F
|
|
117 pshs d
|
|
118 ldy #0002
|
|
119 lda portpath,u
|
|
120 leax ,s
|
|
121 os9 I$Write
|
|
122 leas 2,s
|
|
123 lbcs errex2
|
|
124
|
|
125
|
|
126 * write parameters to port - X = start addr, y = # bytes, A = path#
|
|
127
|
|
128 puls x
|
|
129 puls y
|
|
130 lda portpath,u
|
|
131
|
|
132 os9 I$Write
|
|
133 lbcs errex2
|
|
134
|
|
135 * response loop
|
|
136 * read 1 byte, this is how many bytes follow in this set. 0 for end of response
|
|
137
|
|
138 rloop ldy #0001 ;read one byte
|
|
139 leax numbyt,u ;put it in our numbyt
|
|
140 lda portpath,u ;read from port path
|
|
141 os9 I$Read
|
|
142 lbcs errex2
|
|
143
|
|
144 * if Y = 1, we got our byte, otherwise bail out
|
|
145 cmpy #0001
|
|
146 bne errex2
|
|
147
|
|
148 * if byte was 0, we're done
|
|
149 ldb numbyt,u
|
|
150 beq done
|
|
151
|
|
152 *otherwise read the number of bytes announced
|
|
153 clra
|
|
154 tfr d,y
|
|
155 leax pbuffer,u
|
|
156 lda portpath,u
|
|
157 os9 I$Read
|
|
158 lbcs errex2
|
|
159
|
|
160 * did we get the right # of bytes?
|
|
161 tfr y,d
|
|
162 cmpb numbyt,u
|
|
163 bne errex2 ; gives bytes actually read as error #.. wrong but handy
|
|
164
|
|
165 * write out pbuffer
|
|
166 lbsr writepb
|
|
167
|
|
168 * next set
|
|
169 bra rloop
|
|
170
|
|
171
|
|
172
|
|
173
|
|
174 done clrb ;no errors here
|
|
175 * close port
|
|
176 errex2 lda portpath,u
|
|
177 os9 I$Close
|
|
178
|
|
179 errex1 os9 F$Exit ;goodbye
|
|
180
|
|
181
|
|
182
|
|
183
|
|
184
|
|
185
|
|
186 *end of mod
|
|
187 emod
|
|
188 eom equ *
|
|
189 end
|
|
190
|