Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/help.asm @ 1020:c1a5613ffe7b
changes
author | boisy |
---|---|
date | Thu, 06 Mar 2003 01:41:03 +0000 |
parents | 5c80e10a5d03 |
children | 89684462df13 |
rev | line source |
---|---|
322 | 1 ******************************************************************** |
943 | 2 * Help - Show help |
322 | 3 * |
4 * $Id$ | |
5 * | |
6 * Ed. Comments Who YY/MM/DD | |
7 * ------------------------------------------------------------------ | |
943 | 8 * 6 Rewrote in assembler for size BGP 03/01/21 |
322 | 9 |
943 | 10 nam Help |
11 ttl Show help | |
322 | 12 |
13 ifp1 | |
14 use defsfile | |
15 endc | |
16 | |
943 | 17 COLWIDTH set 10 |
18 | |
322 | 19 tylg set Prgrm+Objct |
20 atrv set ReEnt+rev | |
21 rev set $01 | |
943 | 22 edition set 6 |
322 | 23 |
943 | 24 mod eom,name,tylg,atrv,start,size |
322 | 25 |
943 | 26 name fcs /Help/ |
322 | 27 fcb edition |
28 | |
943 | 29 org 0 |
30 exitvec rmb 2 | |
31 ncols rmb 1 | |
32 colcopy rmb 1 | |
33 bufptr rmb 2 | |
34 path rmb 1 | |
35 same rmb 1 | |
36 prmptr rmb 2 | |
946
5c80e10a5d03
renamed variable that was clashing with one in systype
boisy
parents:
943
diff
changeset
|
37 prmend rmb 2 |
943 | 38 length rmb 2 |
39 colbuff rmb 128 | |
40 userbuf rmb 128 | |
41 parbuff rmb 256 | |
42 filbuff rmb 256 | |
43 stack rmb 350 | |
44 size equ . | |
45 | |
46 * Ask user for subjects | |
47 askuser leax askusr2,pcr | |
48 stx <exitvec | |
49 leax prompt1,pcr | |
50 lda #1 | |
51 ldy #128 | |
52 os9 I$WritLn | |
53 askusr2 leax prompt2,pcr | |
54 lda #1 | |
55 ldy #prompt2l | |
56 os9 I$Write | |
57 clra | |
58 ldy #127 | |
59 leax userbuf,u | |
60 os9 I$ReadLn | |
61 lbcc askusr3 | |
62 cmpb #E$EOF | |
63 lbne exit | |
64 lbra exitok | |
322 | 65 |
943 | 66 * Show topics (if user enters nothing at prompt) |
67 showtopics | |
68 lda #1 | |
69 leax >avail,pcr | |
70 ldy #128 | |
71 os9 I$WritLn | |
72 lbsr seek0 rewind the file | |
73 resetcl lda <ncols | |
74 sta <colcopy | |
75 leax colbuff,u | |
76 stx <bufptr | |
77 readlp lbsr readlin | |
78 bcc readlp2 | |
79 lbsr printcr | |
80 bra askusr2 | |
81 readlp2 leax filbuff,u | |
82 lda ,x+ | |
83 cmpa #'@ | |
84 bne readlp | |
85 ldy <bufptr | |
86 strcpy clra | |
87 clrb | |
88 pshs d | |
89 strc0 lda ,x+ | |
90 cmpa #C$SPAC | |
91 ble strc1 | |
92 sta ,y+ | |
93 ldd ,s | |
94 addd #$0001 | |
95 std ,s | |
96 bra strc0 do again | |
97 strc1 puls d | |
98 dec <colcopy | |
99 beq doeol | |
100 cmpb #COLWIDTH | |
101 bge onesp | |
102 pshs b | |
103 ldb #COLWIDTH | |
104 subb ,s+ | |
105 fcb $8C | |
106 onesp ldb #1 | |
107 lda #C$SPAC | |
108 spacelp sta ,y+ | |
109 decb | |
110 bne spacelp | |
111 sty <bufptr | |
112 bra readlp | |
113 doeol sty <bufptr | |
114 lda #C$CR | |
115 sta ,y | |
116 leax colbuff,u | |
117 lda #1 | |
118 ldy #128 | |
119 os9 I$WritLn | |
120 bra resetcl | |
121 | |
122 askusr3 lda ,x | |
123 cmpa #C$CR | |
124 beq showtopics | |
125 lbsr seek0 rewind the file | |
126 bra entrya | |
127 | |
128 start pshs d,x,y | |
129 lda #8 | |
130 sta <ncols assume 8 columns | |
131 lda #1 | |
132 ldb #SS.ScSiz | |
133 os9 I$GetStt | |
134 bcs start2 | |
135 cmpx #9 | |
136 ble start1 A = 1 here | |
137 tfr x,d | |
138 clra | |
139 * Divide screen X by COLWIDTH to determine number of columns | |
140 Div10 subb #COLWIDTH | |
141 bcs start1 | |
142 inca | |
143 bra Div10 | |
144 start1 sta <ncols | |
322 | 145 |
943 | 146 start2 leax exit,pcr |
147 stx <exitvec | |
148 puls d,x,y | |
149 tfr d,y length of parameters | |
150 bsr open | |
151 bcs exit | |
152 cmpy #$0001 no parameters? | |
153 lbeq askuser | |
154 entrya | |
155 pshs u | |
156 leau parbuff,u point to buffer | |
157 entry0 lda ,x+ | |
158 cmpa #C$SPAC is it a space (between parameters?) | |
159 beq entry1 | |
160 cmpa #C$CR | |
161 bne nocr | |
162 entry1 clra yes, null it | |
163 nocr sta ,u+ store in buffer | |
164 leay -1,y decrement length counter | |
165 bne entry0 | |
166 clr ,u | |
167 tfr u,y | |
168 puls u | |
946
5c80e10a5d03
renamed variable that was clashing with one in systype
boisy
parents:
943
diff
changeset
|
169 sty <prmend store end of all parameters |
943 | 170 leax parbuff,u load address of parbuff into X |
171 stx <prmptr save parameter pointer | |
172 entry2 lda ,x | |
173 bne strlen | |
174 leax 1,x | |
175 bra rered2 | |
176 strlen pshs x | |
177 ldy #0 initialise count | |
178 strl0 lda ,x+ is it a char > null | |
179 cmpa #C$SPAC | |
180 ble strl1 nope, exit | |
181 leay 1,y yep, increment count | |
182 bra strl0 do again | |
183 strl1 puls x | |
184 sty <length store it | |
185 | |
186 reread bsr readlin read line from helpfile file | |
187 bcc rered0 | |
188 cmpb #E$EOF did we find end-of-file? | |
189 lbeq unknown yep, tell user we don't know his command | |
190 rered0 lbsr compare compare user number with 1st 3 chars of line | |
191 beq reread compare returns 0 if failed | |
192 bsr print else go print the helpfile line | |
193 bcc rered1 exit if I$WritLn problem | |
194 cmpb #E$EOF | |
195 bcs exit | |
196 rered1 ldd <length get length | |
197 ldx prmptr get parameter pointer | |
198 leax d,x add length to it | |
199 leax 1,x increment past null byte | |
200 rered2 clrb | |
946
5c80e10a5d03
renamed variable that was clashing with one in systype
boisy
parents:
943
diff
changeset
|
201 cmpx <prmend |
943 | 202 blt rered25 |
203 jmp [exitvec,u] | |
204 rered25 stx <prmptr store it | |
205 rered3 lbsr seek0 rewind the file | |
206 bra entry2 loop around again | |
207 | |
208 exitok clrb | |
209 exit os9 F$Exit | |
210 | |
211 open pshs x | |
212 leax helpfile,pcr point to file name | |
213 lda #READ. read mode | |
214 os9 I$Open | |
215 bcs open0 | |
216 sta <path store path number | |
217 open0 puls x,pc | |
218 | |
219 readlin pshs x,y | |
220 lda <path get file path number | |
221 ldy #256 read max 256 bytes | |
222 leax filbuff,u into memory pointed to by filbuff | |
223 os9 I$ReadLn | |
224 puls x,y,pc | |
322 | 225 |
943 | 226 print pshs x,y,a |
227 print2 bsr readlin | |
228 bcs printout | |
229 print3 lda ,x | |
230 cmpa #'@ | |
231 beq printout | |
232 lda #1 STDOUT | |
233 leax filbuff,u into memory pointed to by filbuff | |
234 ldy #256 max of 256 chars | |
235 os9 I$WritLn | |
236 bra print2 | |
237 printout | |
238 bsr printcr | |
239 puls x,y,a,pc | |
240 | |
241 printcr | |
242 lda #1 | |
243 leax return,pcr | |
244 ldy #256 max of 256 chars | |
245 os9 I$WritLn | |
246 rts | |
247 | |
248 compare pshs x,y | |
249 clr <same comparison indicator | |
250 leay filbuff,u point to file buffer | |
251 lda ,y+ get first char | |
252 cmpa #'@ @ sign? | |
253 bne comp2 branch if not | |
254 ldx prmptr get address of next cmd line param | |
255 comp0 lda ,x+ get char from cmd line | |
256 beq comp1 is it null (end of param) | |
257 ldb ,y+ | |
258 anda #$DF | |
259 andb #$DF | |
260 pshs a | |
261 cmpb ,s+ | |
262 bne comp2 not same, exit | |
263 inc <same yep, in comparison counter | |
264 bra comp0 'round again | |
265 comp1 lda ,y | |
266 cmpa #C$CR was it end of string in helpfile file? | |
267 bne comp2 | |
268 tst <same test indicator | |
269 puls x,y,pc | |
270 comp2 clr <same clear the counter | |
271 puls x,y,pc | |
272 | |
273 unknown | |
274 ldx prmptr put pointer into parameter buffer in X | |
275 lda #1 STDOUT | |
276 ldy <length get length of user's param | |
277 os9 I$Write | |
278 lbcs exit | |
279 leax unkmsg,pcr point to message | |
280 ldy #unkmsgl num of chars to print | |
281 lda #1 to STDOUT | |
282 os9 I$WritLn | |
283 lbcs exit exit if problem with I$Write | |
284 ldx prmptr put point into parameter buffer in X | |
285 ldd <length get length of user's param | |
286 leax d,x add to X | |
287 leax 1,x increment past null byte | |
288 clrb | |
946
5c80e10a5d03
renamed variable that was clashing with one in systype
boisy
parents:
943
diff
changeset
|
289 cmpx prmend |
943 | 290 lblt unk2 |
291 jmp [exitvec,u] | |
292 unk2 stx <prmptr store X | |
293 bsr seek0 rewind file | |
294 lbra entry2 | |
295 | |
296 seek0 pshs x,u | |
297 lda <path | |
298 ldx #0 | |
299 ldu #0 | |
300 os9 I$Seek | |
301 puls x,u,pc | |
302 | |
303 helpfile fcc "/DD/SYS/helpmsg" | |
304 fcb 0 | |
305 unkmsg fcc /: no help available/ | |
306 return fcb C$CR | |
307 unkmsgl equ *-unkmsg | |
308 prompt1 fcc /Hit [ESC] to exit/ | |
309 fcb C$CR | |
310 prompt2 fcc /What Subject(s)? / | |
311 prompt2l equ *-prompt2 | |
312 avail fcc /Help available on:/ | |
313 fcb C$CR | |
314 | |
315 emod | |
316 eom equ * | |
317 end |