home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / appleii / appmai.m65 < prev    next >
Text File  |  2020-01-01  |  609KB  |  17,699 lines

  1. .SBTTL    6502  version - Antonino N. J. Mione/PT/MP/TH
  2.  
  3. ;     Version 3.0
  4.  
  5. ;     Based on the KERMIT Protocol.
  6.  
  7. ;    $Header: appmai.m65,v 1.17 89/11/06 10:40:26 medin Locked $
  8. .SBTTL    Define start address for assembly
  9.  
  10.     .=$1000          ;[58][39] Start assembly at hex 1000
  11.     .nlst        ;[84]
  12. .SBTTL    Revision History
  13.  
  14. ;
  15. ; Edit #     Description
  16. ; ------     -----------
  17. ;
  18.  
  19. ;
  20. ;   1         By: Antonino N.J. Mione         On: 26-APR-1983
  21. ;         Fix I/O hooks so that Kermit-65 may be BRUN 
  22. ;         instead of requiring that it be BLOADED and then
  23. ;         executed.
  24. ;
  25.  
  26. ;
  27. ;   2         By: Antonino N.J. Mione         On: 26-APR-1983
  28. ;         Make quoting work for characters with parity bit on.
  29. ;
  30.  
  31. ;
  32. ;   3         By: Antonino N.J. Mione         On: 04-MAY-1983
  33. ;         Make Kermit write last buffer on receive. Do this 
  34. ;         by making sure AC is zero on entry to 'Closef' so 
  35. ;         'Closef' knows that there were no errors. Also, 
  36. ;         put address of buffer into the right place in the
  37. ;         file manager parameter list.
  38. ;
  39.  
  40. ;
  41. ;   4         By: Antonino N.J. Mione         On: 17-MAY-1983
  42. ;         Reduce max packet length by one so we don't get
  43. ;         a <Del> character when we quote it.
  44. ;         Make escape sequence read '^'<esc-char>'C'.
  45. ;         Make VT52-EMULATION be ON by default.
  46. ;
  47.  
  48. ;
  49. ;   5         By: Antonino N.J. Mione         On: 27-JUN-1983
  50. ;         Make the default time-out interval default to a 
  51. ;         reasonable amount of time instead of 0. The default 
  52. ;         is now 15 seconds for both send and receive. 
  53. ;
  54.  
  55. ;
  56. ;   6         By: Antonino N.J. Mione         On: 28-JUN-1983
  57. ;         Make Kermit locate the actual end-of-file instead 
  58. ;         of sending blindly to the end of the last sector
  59. ;         of the file. 
  60. ;
  61.  
  62. ;
  63. ;   7         By: Antonino N.J. Mione         On: 28-JUN-1983
  64. ;         Don't send trailing spaces in the file header 
  65. ;         packets. 
  66. ;
  67.  
  68. ;
  69. ;   8         By: Antonino N.J. Mione         On: 28-JUN-1983
  70. ;         Convert <cr> to <cr><lf> line terminator on the way 
  71. ;         out and <cr><lf> to <cr> on the way in for text 
  72. ;         files. 
  73. ;
  74.  
  75. ;
  76. ;   9         By: Antonino N.J. Mione         On: 29-JUN-1983
  77. ;         Account for carry in jump table calculations for 
  78. ;         those cases where the table starts on a page 
  79. ;         boundary. 
  80. ;
  81.  
  82. ;
  83. ;  10         By: Antonino N.J. Mione         On: 21-JUL-1983
  84. ;         Fix edit [7] so that it works all the time. The 
  85. ;         operand in the compare should be immediate since 
  86. ;         a space is what we are looking for. 
  87. ;
  88.  
  89. ;
  90. ;  11         By: Antonino N.J. Mione         On: 25-JUL-1983
  91. ;         Fix how we set eight-bit quoting from the init 
  92. ;         packet. Also, make sure we don't quote the 8-bit 
  93. ;         quote character unless 8-bit quoting is turned on. 
  94. ;
  95.  
  96. ;     VERSION 1.1 Starts here
  97.  
  98. ;
  99. ;  12         By: Antonino N.J. Mione         On: 22-SEP-1983
  100. ;         Add 'SET SLOT' and 'SHOW SLOT' commands to make
  101. ;         the I/O port settable by the user. Add
  102. ;         'SET DEVICE-DRIVER' and 'SHOW DEVICE-DRIVER'
  103. ;         commands to make the I/O device user-selectable.
  104. ;         Also, make some of the option initialization
  105. ;         static as opposed to wasting instructions on it.
  106. ;
  107.  
  108. ;
  109. ;  13         By: Antonino N.J. Mione         On: 05-OCT-1983
  110. ;         Alter the calling sequence for some references
  111. ;         to Comnd. This is due to a standardization of the 
  112. ;         parameter calling and returning conventions. 
  113. ;
  114.  
  115. ;
  116. ;  14         By: Antonino N.J. Mione         On: 11-OCT-1983
  117. ;         Add code for Kermit-65 to talk to a Server-mode 
  118. ;         Kermit. Includes the new commands 'BYE', 'FINISH',
  119. ;         and 'GET'.
  120. ;
  121.  
  122. ;
  123. ;  15         By: Antonino N.J. Mione         On: 26-OCT-1983
  124. ;         For cases where 8-bit quote is 'Y' or 'N' make 
  125. ;         sure that Rpar places the value in Sebq AND sets
  126. ;         8-bit quoting off.
  127. ;
  128.  
  129. ;
  130. ;  16         By: Antonino N.J. Mione         On: 26-OCT-1983
  131. ;         Change display during transfers to show a total 
  132. ;         packet count as oppossed to the packet number being
  133. ;         sent in the packet itself.
  134. ;
  135.  
  136. ;
  137. ;  17         By: Antonino N.J. Mione         On: 31-OCT-1983
  138. ;         Make Kermit suppress printing <lf>s while CONNECTed
  139. ;         to a host which sends <cr><lf> as a line terminator.
  140. ;
  141.  
  142. ;
  143. ;  18         By: Antonino N.J. Mione         On: 31-OCT-1983
  144. ;         Move call to Closef before code to send ACK in Rdat
  145. ;         after the Eof-packet has been received. This will
  146. ;         fix the problem with Kermit-65 hanging just before
  147. ;         the break packet.
  148. ;
  149.  
  150. ;
  151. ;  19         By: Antonino N.J. Mione         On: 31-OCT-1983
  152. ;         Fix Closef right by making it insert the filename
  153. ;         into the buffer in negative ascii. Previously, DOS
  154. ;         was running out of buffers on long sessions because
  155. ;         the files being transferred were not being closed
  156. ;         and thus the buffers were not being released.
  157. ;
  158.  
  159. ;
  160. ;  20         By: Antonino N.J. Mione         On: 01-NOV-1983
  161. ;         Make sure Pdlen does not get clobbered. Make Pdbuf
  162. ;         long enough for a full packet. It was 2 characters
  163. ;         too short.
  164. ;
  165.  
  166. ;
  167. ;  21         By: Antonino N.J. Mione         On: 02-NOV-1983
  168. ;         Add IBM-mode support.
  169. ;
  170.  
  171. ;
  172. ;  22         By: Mark Paczkowski         On: 03-NOV-1983
  173. ;         Put in support for super serial card.
  174. ;
  175.  
  176. ;
  177. ;  23         By: Antonino N.J. Mione         On: 03-NOV-1983
  178. ;         Put checks into the command parser to ensure that
  179. ;         the command buffer does not overflow.
  180. ;
  181.  
  182. ;
  183. ;  24         By: Antonino N.J. Mione         On: 03-NOV-1983
  184. ;         Fix local-echo so that the H.O. bit is one when
  185. ;         printing the character locally.
  186. ;
  187.  
  188. ;
  189. ;  25         By: Antonino N.J. Mione         On: 15-NOV-1983
  190. ;         Change the way Kermit sends packets. Build up the
  191. ;         entire packet first, then send it all at once.
  192. ;
  193.  
  194. ;
  195. ;  26         By: Antonino N.J. Mione         On: 15-NOV-1983
  196. ;         Implement Terse-mode debugging.
  197. ;
  198.  
  199. ;
  200. ;  27         By: Antonino N.J. Mione         On: 18-NOV-1983
  201. ;         Make 'gobble' smarter so it sees start-of-header
  202. ;         as well as end-of-line. This aids us in talking
  203. ;         to crufty IBM machines.
  204. ;
  205.  
  206. ;
  207. ;  28         By: Antonino N.J. Mione         On: 28-NOV-1983
  208. ;         Make sure the primary filename buffer is space
  209. ;         filled after the filename.
  210. ;
  211.  
  212. ;
  213. ;  29         By: Antonino N.J. Mione         On: 28-NOV-1983
  214. ;         Make sure fcb is cleared so that filename does not
  215. ;         get currupted.
  216. ;
  217.  
  218. ;
  219. ;  30         By: Antonino N.J. Mione         On: 28-NOV-1983
  220. ;         Make this look like Version 2.0. Fix the Version
  221. ;         message.
  222. ;
  223.  
  224. ;     VERSION 2.0 Starts here
  225.  
  226. ;
  227. ;  31         By: Peter Trei             On: 10-Feb-1984
  228. ;         Added support for visible cursor. See CURON and
  229. ;         CUROFF routines.
  230. ;                 oc.trei%cu20b@columbia-20
  231. ;
  232.  
  233. ;
  234. ;  32         By: Peter Trei             On: 12-Feb-1984
  235. ;         Fixed bug in SSC support software ; altered RRF
  236. ;         flag mask from $#04 to $#08.
  237. ;                 oc.trei%cu20b@columbia-20
  238. ;
  239.  
  240. ;
  241. ;  33         By: Peter Trei             On:  21-FEB-1984
  242. ;         Corrected definitions of BASL and BASH.
  243. ;                 oc.trei%cu20b@columbia-20
  244. ;
  245.  
  246. ;
  247. ;  34         By: Peter Trei             On:  23-FEB-1984
  248. ;         Adjustments to make uppercase and weird chars appear
  249. ;         inverse.
  250. ;
  251.  
  252. ;
  253. ;  35         By Peter Trei             On:  17-MAR-84
  254. ;         Installed CHRCON routine to allow the 2/2+
  255. ;         keyboard to enter lowercase, rubout, and other
  256. ;         'missing' characters. This also involved adding the
  257. ;         'SET KEYBOARD' switch, with positions for 2P and 2E.
  258. ;
  259.  
  260. ;
  261. ;  36         By: Antonino N.J. Mione         On: 22-JUN-1984
  262. ;         Make the FILE-BYTE-SIZE default sensible (i.e.
  263. ;         Seven-bit since we are defaulting the FILE-TYPE-MODE
  264. ;         to TEXT).
  265. ;
  266.  
  267. ;
  268. ;  37         By: Antonino N.J. Mione         On: 25-JUN-1984
  269. ;         Fix 'Get' so that the first time it is used,
  270. ;         it will work. 
  271. ;
  272.  
  273. ;
  274. ;  38         By: Antonino N.J. Mione         On: 25-JUN-1984
  275. ;         Handle error packet processing correctly. 
  276. ;
  277.  
  278. ;
  279. ;  39         By:  Tim Heuser             On: 26-JUN-1984
  280. ;         Start assembly at $801 so we don't break Applesoft. 
  281. ;
  282.  
  283. ;
  284. ;  40         By: Antonino N.J. Mione         On: 29-JUN-1984
  285. ;         Add capability to set drive for file transfers.
  286. ;         Added the 'SET DEFAULT-DISK' and 'SHOW DEFAULT-DISK'
  287. ;         commands. 
  288. ;
  289.  
  290. ;
  291. ;  41         By: Antonino N.J. Mione         On: 29-JUN-1984
  292. ;         Add capabilities to code which processes Escaping
  293. ;         from CONNECT mode. Give user ability to send a
  294. ;         BREAK signal, a nul character, or the Escape
  295. ;         character itself. Also, add these to the online
  296. ;         help message. 
  297. ;
  298.  
  299. ;
  300. ;  42         By: Antonino N.J. Mione         On: 02-JUL-1984
  301. ;         Fix the 'GET' command. When receiving files, have
  302. ;         KERMIT-65 use the filenames from the File-header
  303. ;         packets. 
  304. ;
  305.  
  306. ;
  307. ;  43         By: Antonino N.J. Mione         On: 11-JUL-1984
  308. ;         Clear the FCB when fetching a filename from the
  309. ;         packet buffer. Previously when receiving files,
  310. ;         if subsequent filenames where shorter than filenames
  311. ;         in the beginning of the session, the name of the
  312. ;         file created on disk would be incorrect. 
  313. ;
  314.  
  315. ;
  316. ;  44         By: Antonino N.J. Mione         On: 12-JUL-1984
  317. ;         Fix 'No buffers available' problem when doing
  318. ;         >3 SENDs in one session. Make the SDAT routine
  319. ;         reset the eofinp flag and close the file when
  320. ;         the BUFILL routine returns an end-of-file. 
  321. ;
  322.  
  323. ;
  324. ;  45         By: Antonino N.J. Mione         On: 12-JUL-1984
  325. ;         Make version read '2.1'. 
  326. ;
  327.  
  328. ;     VERSION 2.1 Established here
  329.  
  330. ;
  331. ;  46         By: Peter Trei             On: 30-JUL-1984
  332. ;         The new Apple 2c does not have inverse capitals ; these codes
  333. ;         are used for a bunch of graphics characters. Thus, the method
  334. ;         of showing true caps as inverse and lowercase as normal caps
  335. ;         will not work. This mod involves a switch to indicate whether
  336. ;         the users apple can show lowercase (2e/2c) or caps only (2/2+).
  337. ;         If the user CAN show these, DSPCHR (edit 34) just prints
  338. ;         characters 'as is' without any reformatting.
  339. ;
  340.  
  341. ;     VERSION 2.1A Established here
  342.  
  343. ;
  344. ;  47         By: Ted Medin             On: 22-JUN-1985
  345. ;         Initialize the Super Serial card from within the program.
  346. ;         Most of the code was translated from the cp4 code in cp/m
  347. ;         apple.
  348. ;
  349. ;  48         By: Ted Medin             On: 29-JUN-1985
  350. ;         Initialize the Hayes micro modem card from within the program.
  351. ;         Most of the code was translated from the cp4 code in cp/m
  352. ;         apple.
  353. ;
  354. ;  49         By: Ted Medin             On: 19-JUL-1985
  355. ;         Support a 80 col card display. Display was debuged on a Franklin
  356. ;         but should work on a 2e 80 col or equivalent. The Franklin is
  357. ;         an apple ][+ done right. The special codes required for the
  358. ;         the display follows:
  359. ;         $0c-form feed     - clear screen and position top left
  360. ;         $1d-gs         - clear line from cursor to end of line
  361. ;         $0b-vt         - clear screen from cursor
  362. ;         $0a-line feed     - move cursor down one line
  363. ;         $1f-us         - move cursor up one line
  364. ;         $1c-nak     - move cursor right one
  365. ;         $1e,ch,cv     - 3 chs in a row,position cursor to ch,cv 
  366. ;                 - ch & cv each have a bias of 32
  367. ;
  368. ;  50         By: Ted Medin             On: 25-JUL-1985
  369. ;         Error in code checking for cr,lf. The a reg was destroyed
  370. ;         so code was rewritten and shortened. Code now depends on "on"
  371. ;         being non zero and "off" being zero.
  372. ;
  373. ;  
  374. ;  51        By: Ted Medin            On: '85 Oct 29
  375. ;        Use interupts to drive the Super Serial card, sw2-6 must be on.
  376. ;        That is the switch that allows the interupts to occur. The code
  377. ;        uses two buffers of 256 bytes each for the input and output
  378. ;        characters. No checking is done for overuns on these buffers
  379. ;        in the interest of speed. We have had the ][+ with a Videx
  380. ;        80 col card runing at 9600 baud with out fail.
  381. ;
  382. ;
  383. ;  52         By: Sam Lam             On: '85 Nov
  384. ;         Correct 8 bit quoting problem in rpar
  385. ;
  386. ;  53        By: Ted Medin             On: '85 Dec 24
  387. ;         Correct bad checksum response to rpar on received packet
  388. ;    
  389. ;
  390. ;     Version 3.0 
  391. ;
  392. ;  54         By: Ted Medin             On: '86 Jan 7
  393. ;         Rearrange and remove all com card code. This will allow
  394. ;         the com card code to be separately assembled. Communications
  395. ;         with the main Kermit routine will be thru a vector of data
  396. ;         and jumps to routines in the main routine and the com routine.
  397. ;
  398. ;  55         By: Ted Medin             On: '86 Jan 14
  399. ;         Add printer control. Take into account the display may be
  400. ;         a 80 col card.
  401. ;
  402. ;  56         By: Ted Medin             On: '86 Jan15
  403. ;         Add logging of connected session. File closed when control
  404. ;         is returned to kermit.
  405. ;
  406. ;  57         By: Ted Medin             On: '86 Jan 17
  407. ;         Add flow control via xon/xoff with remote. This is about the
  408. ;         only way printer and loging can work.
  409. ;
  410. ;  58        By: Ted Medin            On: '86 Jan 24
  411. ;        Correct problems with vt52 emulation. Vtab & vtabz were not
  412. ;        being handled. The problem with reverse scrolling and a 80
  413. ;        col card is not handled correctly at this time.
  414. ;
  415. ;  59        By: Ted Medin            On: '86 Mar 7
  416. ;        Allow kermit to run with prodos or dos 3.3. Add the two commands
  417. ;        "set prefix" and "show prefix" for the prodos environment.
  418. ;        Allow flow control from/to remote.
  419. ;
  420. ;  60        By: Ted Medin            On: '86 May 30
  421. ;        Allow vol specification for the default disk. Fix bug in file
  422. ;        warning checking wrong diskette. Allow file xfer from a diskette
  423. ;        when file protect tab is on.
  424. ;
  425. ;  61        By: Ted Medin            On: '86 June 19
  426. ;        Fix several problems with the //e 80 col display. Apparently
  427. ;        there is a lot i dont know about those banks so let basic
  428. ;        initialize the display and then use the pascal entries.
  429. ;
  430. ;  62        By: Ted Medin            On: '86 july 29
  431. ;        Allow server mode. Initially only get and put but more later.
  432. ;        Fix vt52 mode with 40 col display(drop cntr ch printing)
  433. ;
  434. ;  63        By: Ted Medin            On: '86 Aug 4
  435. ;        Put in code for terminal program. Special string from remote
  436. ;        site puts kermit 65 into server mode.
  437. ;
  438. ;  64        By: Ted Medin            On: '86 Aug 6
  439. ;        Put in code for fuzzy timer. This code does a timeout on
  440. ;        file transfer when no communications is received from the 
  441. ;        remote. Also allow seting timer on/off.
  442. ;
  443. ;  65        By: Ted Medin            On: '86 Aug 21
  444. ;        Remove file-byte-size since it is redundant. The type of file
  445. ;        determines the file byte size. Text is 7 with high bit on all
  446. ;        other types are 8 bits.Also fix bug in file xfer when the 
  447. ;        parity bit is on.
  448. ;
  449. ;  66        By: Ted Medin            On: '86 Aug 24
  450. ;        Begin to show more info while file xfering. Start by
  451. ;        displaying the local file name being xfered.
  452. ;
  453. ;  67        By: Ted Medin            On: '86 Sep 1
  454. ;        Fix bug in file xfer when failure to complete xfer
  455. ;        leaves local file open. Fix loop in fin command when
  456. ;        local and remote get into a nak loop. Fix problem with
  457. ;        received error packets.
  458. ;
  459. ;  68        By: Ted Medin            On: '86 Sep 29
  460. ;        Remove ibmmod since all ibm controllers do not use mark
  461. ;        parity. Thanks to Mark Johnson %irishmvs
  462. ;
  463. ;  69        By: Ted Medin            On: '86 Oct 10
  464. ;        Put delay at end of file transfer so operator can read
  465. ;        any messages. Correct problem in file transfer when bad
  466. ;        packet happens to be going from $37 to 0. Check was
  467. ;        not handling the modulo $37 correctly.
  468. ;
  469. ;  70        By: Ted Medin            On: '86 Oct 27
  470. ;        Correct problem with interupts using $45 and the pasal 80 col
  471. ;        routines using $44 & $45. Also slight speed up of prchr rtn.
  472. ;
  473. ;  71        By: Ted Medin            On: '86 Oct 28
  474. ;        Change pascal screen & keyboard routines so they are not so
  475. ;        rom dependent.
  476. ;
  477. ;  72        By: Ted Medin            On: '86 Nov 3
  478. ;        Change eight bit quoting to follow the file type. If file type
  479. ;        is not text then eight bit quoting will be used providing the
  480. ;        other kermit agrees.
  481. ;        Correct bug in logo used by bye and fin. Initialize the com 
  482. ;        card and the send/rec routines
  483. ;        Fix bug in binary file xfer. The other kermit needs to
  484. ;        know what our 8 bit prefix character is.
  485. ;        Allow verbose debug output in all xmission states.
  486. ;        Correct bug in send-sometimes file is truncated
  487. ;        Remove set & show 8 bit quoting flag
  488. ;  73        By: Ted Medin            On: '86 Nov 26
  489. ;        Install function keys. Allow vt52 keypad starting with keys 
  490. ;        678&9 when open/close apple (joystick buttons) are also pressed,
  491. ;        use h19 function keys for keys 1-5 and help function on key 0.
  492. ;        Ignore vt52 mode when using printer instead of screen
  493. ;        Allow swap of the del and bs keys from the keyboard.
  494. ;        If terminal pgm then start directly with the com command.
  495.  
  496. ;  74        By: Ted Medin            On: '87 Jan 23
  497. ;        Minor change to clear to end of line, scr13 & clear to end
  498. ;        of page to check for flow control
  499. ;        Some pgms send lf & cr rather than cr & lf so we now check
  500. ;        for both orders.
  501. ;        Minor change to dspchr to speed things up a bit.    
  502. ;        Change telnet to drop nulls. You wouldnt believe and i couldnt
  503. ;        find the problems this caused on a //e. Problem didnt exist
  504. ;        on a //e+ so PTL dropping nulls solved it and i dont know why.
  505. ;  75        By: Ted Medin            On: '87 Jan 28
  506. ;        Add extended length packets
  507. ;        Fix problems caused by packet lengths > 128. Had to us bcs &
  508. ;        bcc instead of bpl & bmi. Fix problem in flow control if com
  509. ;        initialization was not done.
  510. ;        Fix problems with 8 bit data path.
  511. ;        Fix nak loop in get file & purge com buffers when starting up
  512. ;        any filexfer functions.
  513. ;  76        By: Ted Medin            On: '87 Mar 17
  514. ;        Allow toggle of swap del & bs key via the escape
  515. ;        Terminal type vt100
  516. ;        Change display of control chs to inverse
  517. ;        Flow control only when connected, not file xfer etc
  518. ;  77        By: Ted Medin            On: '87 May 15
  519. ;        Fix bug in set disp 80 col to properly init the card
  520. ;        Remove the lf cr look and only remove the cr lf sequence
  521. ;        Allow the operator to look at some of the defaults in terminal
  522. ;  78        By: Ted Medin            On: '87 May 24
  523. ;        Add the catalog command
  524. ;        Add the modem command which reads file kermit.modem database
  525. ;        Initialize kermit by reading file kermit.init for commands
  526. ;        Replace help with alan kalkers version
  527. ;        Use basic.system to get prefix. Thanks Rick Fincher
  528. ;        Add the delete file command
  529. ;        Remove the delay while printing locally
  530. ;        Correct bug in open for eof, eodind now cleared on open
  531. ;        Replace wait routine with rom wait 220=125ms
  532. ;        Force the aux in prodos to be $801 for applesoft
  533. ;        Add wraparound on/off for vt100 & vt52 mode
  534. ;        Get the defaults correctly for prefix or drive if the user
  535. ;        doesnt specify a default. One should now startup with the
  536. ;        path the binary begain executing at unless the user specifies
  537. ;        the path or drive.
  538. ;        Lots of fixes tto vt52 & vt100 emulation.
  539. ;        Add other to file-type so user can set any type he wants.
  540. ;  79        By: Ted Medin            On: '87 Aug 31
  541. ;        Fix vt100 prob with //c & //gs (they reset the regions).
  542. ;        Thanks to Grant Delaney for his help on the above.
  543. ;        Fix filename in file xfer to be the current file
  544. ;  80        By: ted medin            on: '87 sep 29
  545. ;        Fix vt100 mode so screen mode works and bold blink &
  546. ;        underscore use revers video.
  547. ;        Add keypad for gs & new e, change modem delay to &
  548. ;        Add save and restore irq & correct dos vectors save & restore
  549. ;        Add print screen - argggggggg
  550. ;        Improve initial prefix get - thanks Sean Noland
  551. ;        Allow cursor keys to be vt100 cursor keys
  552. ;        Improve vt52 <--> vt100 and keypad
  553. ;  81        by: ted medin            on: '88 jan 11
  554. ;        add wildcard send - thanks dick atlee
  555. ;        add end of com routine to main vectors
  556. ;        fix upper/lower case problems in comnd
  557. ;        clear com buffers when we initialize com driver
  558. ;        allow server mode to do any command via local
  559. ;        add keypad application set
  560. ;        server mode remote command
  561. ;        server mode process x packets
  562. ;        fix keypad bug
  563. ;        fix vt100 cursor keys bug
  564. ;        redo help
  565. ;  82        by ted medin            on: '88 apr 8
  566. ;        allow prodos text to use 8 bit width
  567. ;        fix vt100 bugs
  568. ;        fix flow control bugs and less of it
  569. ;        shorten up jmp tables
  570. ;        change wait loops for non interupt drivers
  571. ;        allow start of packet to be varied
  572. ;        help for crimmins mouse support
  573. ;  83        by ted medin            on: '88 may 16
  574. ;        more fixes for vt100, add xmodem protocol,
  575. ;        speed up rskp, add take command, add restore screen,
  576. ;        show version with show all, fixes for debug display
  577. ;  84        by ted medin            on: '88 may
  578. ;        fix dos to use file manager-thanks to bob holley
  579. ;        more vt100 fixes & drop the display of unknown esc seq
  580. ;        exit now uses prodos quit
  581. ;        fix u/l case problem in syntax scanner
  582. ;        file xfer now shows bytes xfered
  583. ;        cr<-->cr,lf option added to file xfer
  584. ;        long packets only used when size dictates
  585. ;        fix remote command initialization loop
  586. ;  85        by ted medin            on: '88 dec
  587. ;        speed up where possible
  588. ;        time constant added
  589. ;        help now from kermit.help
  590. ;        modem command now has escape ch \
  591. ;        type command
  592. ;        wildcard xfers now use the hardware stack
  593. ;  86        by ted medin            on: '89 jan
  594.  
  595. ;+ Dont forget to update version and help version !!!!!!!!!!!!!!!!!
  596. ;$Log:    appmai.m65,v $
  597. ;Revision 1.17  89/11/06  10:40:26  medin
  598. ; These are the changes in 3.86
  599. ;1. Prodos quit is fixed
  600. ;2. vt100 bug fixes (will it ever stop)
  601. ;3. //c+ now works - thanks Steve Kunz
  602. ;4. blinking cursor when connected
  603. ;5. connect escape menu now has modem and quit added
  604. ;6. file xfer downloads in prodos, illegal characters are now replaced with
  605. ;   periods. it was Klaus Schnathmeier's (hamberg germany) idea, unfortulately
  606. ;   i missunderstood so klaus didnt get what he wanted. His english is 1000%
  607. ;   better than my german. so hope someone needs this. after looking at this
  608. ;   you may think anybodys english is 1000% better than mine. :-(
  609. ;7. wildcard file xfer uploads sometimes missed one file - fixed (it says here)
  610. ;8. Nice new install by Les Ferch of university of british columbia
  611. ;   if you like the new install send him a thank you <les_ferch@mtsg.ubc.ca>
  612. ;9. apple cat serial driver - thanks Dick Wotiz
  613. ;10.comands lock,unlock & rename added
  614. ;11.get & send commands now allow two filespecs so one can change the name
  615. ;   of the file during file xfer. Maybe this is what Klaus wanted? :-)
  616.  
  617. ;Revision 1.16  88/12/22  09:32:19  medin
  618. ;version 3.85 with these changes:
  619. ;1. time constant added so different speed cpus can give same wall clock time
  620. ;2. speed up wherever possible
  621. ;3. help is now read from kermit.help
  622. ;4. modem command now has escape character "\"
  623. ;5. type command added
  624. ;6. wildcard send now uses the hardware stack which may overflow
  625. ;   if the wild cards are too wild????
  626.  
  627. ;Revision 1.15  88/07/20  18:06:39  medin
  628. ; corresponds to 3.84
  629. ;dos 3.3 now uses file mgr - more robust
  630. ;vt100 fixes, drop display of unknown esc seq
  631. ;exit uses prodos quit
  632. ;fix u/l case pbms in scanner
  633. ;file xfer now shows bytes xfered
  634. ;cr<->cr,lf option 
  635. ;long packets used when length dictates
  636. ;fix remote command init loop
  637. ;Revision 1.14  88/05/16  11:16:41  medin
  638. ; Add xmodem protocol, add take command, add restore screen,
  639. ;fixes for vt100, fixes for debug display, speed up rskp
  640. ;and show all now showes the version.
  641.  
  642. ;Revision 1.13  88/04/08  20:50:28  medin
  643. ;This corresponds to 3.82 with the following:
  644. ;Prodos text 8 bit width
  645. ;fix vt100 bugs
  646. ;fix flow control problems and less of it
  647. ;help for crimmins mouse support
  648. ;wait loops for non interupt drivers
  649. ;allow variable start of packet character
  650. ;shorter up jmp tables
  651.  
  652. ;Revision 1.12  88/02/24  16:59:48  medin
  653. ;version 3.81 changes:
  654. ;wildcard send, indicate end of kermit for buffer area
  655. ;fix upper/lower case problem in comnd, clear com buffers when initializing
  656. ;server mode command remote, keypad application set
  657. ;server mode process x packets, fix keypad bug
  658. ;fix vt100 cursor bug, redo help
  659.  
  660. ;Revision 1.11  87/12/10  10:28:24  medin
  661. ;Corresponds to 3.80
  662. ;1. Fix vt100 screen mode
  663. ;2. Bold blink and underscore use reverse video
  664. ;3. Add keypad for gs & new e
  665. ;4. Change modem delay to &
  666. ;5. Correct save and restore irq vectors and dos vectors
  667. ;6. Add print screen when connected
  668. ;7. Fix initial prefix so it works better
  669. ;8. Allow cursor keys to be vt100 keys
  670. ;9. Improve vt52 keypad
  671.  
  672. ;Revision 1.10  87/09/29  15:23:31  medin
  673. ; Fix //gs & //c problems in vt100 mode. The computers reset the 
  674. ;scrolling region in their rom. Thanks to Grant Delaney for these
  675. ;fixes.
  676. ;This should correspond to 3.79.
  677.  
  678. ;Revision 1.9  87/08/13  16:15:10  medin
  679. ;Add the catalog, modem, delete file commands.
  680. ;Initialize by reading file kermit.init.
  681. ;Replace the wait rtn with the rom wait.
  682. ;Add wraparound option to vt52 & vt100.
  683. ;Add other option to the file-type.
  684. ;Lots of fixes to vt52 & vt100.
  685.  
  686. ;Revision 1.8  87/05/24  15:31:42  medin
  687. ; Bug fix in set 80 col, remove check for lf cr, bring kermit up to level
  688. ;3.77 so alans version and ours match.
  689.  
  690. ;Revision 1.7  87/05/13  18:01:09  medin
  691. ; Kermit-65 version 3.76
  692. ;1.Vt100 terminal emulation
  693. ;2.Allow swap of del and bs via the interupt character
  694. ;3.Display control chs in inverse instead of ^whatever
  695. ;4.Flow control only when "connect" not in file xfer etc
  696.  
  697. ;Revision 1.6  87/03/12  15:56:29  medin
  698. ;Changes for 3.75  1. Extended len packets with fixes for > 127 bytes.
  699. ;2. Flow control prblms because initialization not done.
  700. ;3. Fix 8 bit data path. Now one can xfer binary with parity none.
  701. ;4. Purge com buffers when file xfer starts up.
  702.  
  703. ;Revision 1.5  87/01/28  08:10:02  medin
  704. ;Change telnet to drop null and linefeeds when they are preceeded or followed
  705. ;by carrage returns. Minor changes to the telnet loop to speed things up a 
  706. ;bit.
  707.  
  708. ;Revision 1.4  86/12/09  13:24:34  medin
  709. ;CHANGES for 3.72
  710. ;1. 8 bit quoting now followes file type.
  711. ;2. A bug in bye & fin. We forgot to initialize the com card.
  712. ;3. A bug in non text file xfer. 8 bit quoting incorrect
  713. ;4. Allow verbose debug in all states.
  714. ;5. Bug in end of file truncation.
  715. ;6. Remove set & show eight bit quoting.
  716. ;CHANGES for 3.73
  717. ;1. Add vt52 keypad emulation also add h19 f1-f5 & help keys.
  718. ;2. Fix terminal so it starts with the connect command.
  719.  
  720. ;Revision 1.3  86/10/31  11:42:57  medin
  721. ; This is 3.71 the change was to the //e & c 80 col drivers. There was a
  722. ;bug in duplicate use of loc $45 by the drivers and the super serial driver.
  723. ;The 80 col driver was changed to use the pascal entries completely. No 
  724. ;more reliance on loc $mode. If a cr was detected then a lf was added.
  725.  
  726. ;Revision 1.2  86/10/28  12:40:49  medin
  727. ;3.70 fixed bug in pascal screen routines using $45 while the super serial
  728. ;routine also required $45 due to the interupts. Also make a slight change
  729. ;to the prchr routine to speed up returns.
  730.     .list        ;[84]
  731.  
  732. .SBTTL    Jump  to start of code
  733.  
  734. kst:    jmp   kstart          ; Go past the data to the beginning of the code
  735. ;
  736. ;
  737. rskp    =     rskp.0          ;[78] Routine to skip 3 bytes on return
  738. setbrk    =     sbrk.0          ;[78] Routine to set a break character in brkwrd
  739. rstbrk    =     rbrk.0          ;[78] Routine to reset break character in brkwrd
  740. comnd    =    comand        ;[78]
  741. ;[87]mul16    =    ml16        ;[78]
  742. mul24    =    ml24        ;[87][78]
  743. ;[87]div16    =    dv16        ;[78]
  744. div24    =    dv24        ;[78]
  745. prstr    =    prst.0        ;[78]
  746. ;
  747. ;     Vector for com cards starts here 
  748. ;        location $1003 for data
  749. ;        location $1020 for com routines
  750. ;        location $1040 for main routines
  751. ;
  752. sscdbd: .byte 6           ;[54] start with 300 baud(ala super serial)
  753.                ;         6 - 300 baud
  754.                ;         7 - 600
  755.                ;          etc
  756.      .byte           ;
  757. ddrnm:    .word ermesa+1      ;[54] com card name-max 27 chs
  758. kersli: .byte $20      ;[54] com slot $n0
  759. kerins: .byte           ;[54] force initialization flag-when 0
  760.     .word endker      ;[54] address of end of main kermit
  761. flowfg: .byte 0           ;[57] xon/xoff flow control flag b7=1 - yes
  762. tl0end    .word $c300        ;[81] end of com rtns-try c300
  763. timect    .byte    17    ;[85] 1ms delay thru rom rtn $fca8
  764. escsv    .word    $c000    ;[87] end of screen save memory
  765. fscsv    .byte    0    ;[87] flag if screen saved
  766.     .=kst+$20       ;[54] future expansion
  767. tlinit:               ;[54] initialize com card
  768. ;[75]    .byte 0,0,0           ;[54] room for jump
  769.     lda    #0        ;[75] must be exactly 3 bytes
  770.     rts            ;[75] this gives a false retrun
  771. tl0cmd:               ;[54] command for ACIA
  772.     .byte 0,0,0           ;[54] room for jump
  773.             ;
  774.             ;[54] command is in the A reg as follows:
  775.             ;
  776.             ;[54] 0    - hang up 
  777.             ;[54] $b - set baud
  778.             ;[54] $c - set break on the line
  779.             ;[57] $91 - xon the remote
  780.             ;[57] $93 - xoff the remote
  781.             ;
  782.             ;[54] routine will return false(0) if unable
  783.             ;
  784. tl0cp:               ;[54] check for input ch ready-0 false
  785.     .byte 0,0,0           ;[54] room for jump
  786. tl0gpc:               ;[54] get input ch
  787.     .byte 0,0,0           ;[54] room for jump
  788. tl0ppc:               ;[54] put output character
  789.     .byte 0,0,0           ;[54] room for jump
  790. tl0exi:               ;[54] reset card and restore initialized
  791.     .byte 0,0,0           ;[54] room for jump
  792.     .=kst+$40
  793. vwait:    jmp   wait      ;[54] wait routine-a reg used in rom wait rtn
  794. vprstr: jmp   prstr      ;[54] print string
  795. vrdkey: jmp   rdkey      ;[54] read keyboard
  796. veol:    jmp   prcrlf      ;[54] print cr and lf
  797. vtelcn: jmp   telcnc      ;[54] check for keyboard character
  798. vtelsp: jmp   telspa      ;[57] set parity correctly
  799. ;[86]prdqut    .byte    0,0,0,0,0    ;[84] just need 5 0's for prodos quit
  800. prdqut    .byte    4,0,0,0,0,0,0    ;[86] just need 0's for prodos quit
  801. ;[78]    .=kst+$60      ;[54] room for expansion
  802.  
  803. .SBTTL    Feature test definitions
  804.  
  805. ;     Machines
  806.  
  807. ftappl    =     $01          ; Apple (under DOS 3.3)
  808.  
  809. .SBTTL    Kermit feature test options
  810.  
  811. ftcom    =     ftappl          ; Assemble for Apple ][ under DOS 3.3
  812.  
  813. .SBTTL    Terminal feature for easy file transfers
  814. termnl    =    1        ;[63] 0 if you want terminal else non 0
  815. .SBTTL    Function keys feature    ;[73]
  816. funkey    =    0        ;[73] 0 if you want function keys else non 0
  817. .SBTTL    Alans help feature    ;[78]
  818. akhelp    =    0        ;[78] 0 if you want alan kalkers help version
  819.     .ifeq     <ftcom-ftappl>
  820. .SBTTL    Apple monitor support
  821.  
  822. rdkey    =     $fd0c          ; Routine - Read a char from curr input device
  823. keyin    =     $fd1b          ; Routine - Read a char from keyboard
  824. crout    =    $fd8e        ;[58] send cr to current out
  825. prcrlf    =    crout        ;[58] nice rom routine
  826. cout    =     $fded          ; Routine - Print char in AC
  827. cout1    =     $fdf0          ; Routine - Print char in AC to screen
  828. setio1    =     $fe89          ;[1] Routine - take I/O control away from DOS
  829. setio2    =     $fe93          ;[1] Routine -         ...
  830. prbl2    =     $f94a          ; Routine - Print (X) spaces
  831. prbl3    =     $f94c          ; Routine - Print char in AC and (X)-1 spaces
  832. prbyte    =     $fdda          ; Routine - Print A-reg as 2 hex nibbles
  833. prhex    =    $fde3        ;[78] print a reg low hex nibble
  834. prntyx    =     $f940          ; Routine - Print hex of y,x regs
  835. prntax    =     $f941          ; Routine - Print hex of a,x regs
  836. dscrl3    =     $fc95          ; [49] Routine - Clear entire current line
  837. bell    =     $ff3a          ; Routine - Sound bell
  838. dhome    =     $fc58          ; [49] Routine - Home cursor and clr screen
  839. dlfeed    =     $fc66          ; [49] Routine - Output a line-feed to screen
  840. duplin    =     $fc1a          ; [49] Routine - Go up one line if possible
  841. dadvan    =     $fbf4          ; [49] Routine - Go forward (right) one character
  842. dbsp    =     $fc10          ; [49] Routine - Go back (left) one character
  843. dclrel    =     $fc9c          ; [49] Routine - Clear from cursor to end of line
  844. dclrep    =     $fc42          ; [49] Routine - Clear from cursor to end of page
  845. clreoz    =     $fc9e          ; Routine - Clear current line
  846. dvtab    =     $fc22          ;[58] Routine - calculate base addr of line CV
  847. vtabz    =     $fc24          ;[58] Routine - calculate base addr of line in AC
  848. wait    =    $fca8        ;[78] wait rtn-a=220(125ms),a=25(2ms) us=.5(26+27a+5a*a)
  849. ;[81]dely    =    cout        ;[78] go directly to cout
  850. dos    =     $03d0          ; Dos entry point
  851. kbd    =     $c000          ; Keyboard character input location
  852. kbdstr    =     $c010          ; Keyboard strobe location
  853. mode    =    $4fb        ;[58] //e 80 col flag byte
  854. ;0....... - esc-r inactive    ;[76]
  855. ;1....... - esc-r active    ;[76]
  856. ;.0...... - basic print        ;[76]
  857. ;.1...... - basic input        ;[76]
  858. ;..0..... - language basic    ;[76]
  859. ;..1..... -  " pascal        ;[76]
  860. ;...0.... - u/c restrice    ;[76]
  861. ;...1.... - literal u/l case    ;[76]
  862. ;....1... - goto in process    ;[76]
  863. ;.....0.. - normal video    ;[76]
  864. ;.....1.. - inverse        ;[76]
  865. ;......0. - pascal 1.1        ;[76]
  866. ;......1. -    1.0        ;[76]
  867. ;.......0 - normal mode pascal    ;[76] resets windows to std
  868. ;.......1 - xparent        ;[76] trusts windows & no wrap arround
  869. pvect    =    $c30d        ;[59] pascal rtns vector init,read,write&stat
  870. pinit    =    $c34b        ;[58] //e pascal initialization point
  871. pread    =    $c351        ;[58]     "    read
  872. pwrite    =    $c357        ;[58]     "      output point
  873.  
  874.  
  875. bsp:    lda   dsptyp          ;[49] get display type
  876.     bpl   bsp1          ;[49] is this 80 col?,no
  877.     jsr    dchch        ;[76]
  878.     lda   #bs          ;[49] do a real back space to the card
  879.     jmp   cout          ;[49] position cursor and return
  880. bsp1:    jmp   dbsp          ;[49] let 40 col do its thing
  881. upline:                ;[49]
  882.     lda   dsptyp          ;[49] get display type
  883.     bpl   uplin1          ;[49] is this 80 col?,no
  884.     jsr    dchcv        ;[76]
  885.     lda   #$1f          ;[49] tell card to do an upline
  886.     jmp   cout          ;[49] position cursor and return
  887. uplin1:            ;[55][49] restore a
  888.     jmp   duplin          ;[49] let os go up one line
  889. home:    lda   dsptyp          ;[49] get display type
  890.     bpl   home1          ;[49] is this 80 col?,no
  891.     lda   #ffd          ;[49] form feed should home
  892.     jmp     cout          ;[49] 80 col and return
  893. home1:    jmp   dhome          ;[49] just return
  894. clreol: lda   dsptyp          ;[49] get display type
  895.     bpl   clrel1          ;[49] is this 80 col?,no
  896.     jsr    fflow        ;[74] force flow check
  897.     lda   #$1d          ;[49] 80 col clear to end of line
  898.     jmp   cout          ;[49] give to 80 col card
  899. clrel1: jmp   dclrel          ;[49] let os do it
  900. scrl3:    lda   dsptyp          ;[49] get display type
  901.     bpl   scrl9          ;[49] is this 80 col?,no
  902.     jsr   pos80c          ;[49] pos cursor at start of line
  903. ;[76] let pos80c do the flow*****    jsr    fflow        ;[74] force flow check
  904.     jsr    fflow        ;[82] force flow control
  905.     lda   #$1d          ;[49] erase to end of line
  906.     jmp   cout          ;[49]
  907. scrl9:    jmp   dscrl3          ;[49] let os clear line
  908. ;[74]clreop    lda    #hlf        ;[57] force the test
  909. ;[74]    ldx    #hcr        ;[57] limit is cr-1 to lf
  910. ;[74]    jsr    ckflow        ;[57] now for flow control
  911. clreop                ;[74]
  912.     lda   dsptyp          ;[49] get display type
  913.     bpl   clreo1          ;[49] is this 80 col?,no
  914.     jsr    fflow        ;[74] force flow check
  915.     lda   #$b          ;[49] clear to end of page
  916.     jmp   cout          ;[49] hope all card handle this
  917. clreo1: jmp   dclrep          ;[49] os thing
  918. ;[85]fflow    lda    #hlf        ;[74] force the test
  919. ;[85]    ldx    #hcr+1        ;[74] limit is cr to lf
  920. ;[85]    jmp    ckflow        ;[74] now for flow control & rtn to caller
  921. ;
  922. ;     These are some monitor scratch areas that may be needed
  923. ;
  924.  
  925. a1l    =     $3c
  926. a1h    =     $3d
  927. a2l    =     $3e
  928. a2h    =     $3f
  929. a3l    =     $40
  930. a3h    =     $41
  931. a4l    =     $42
  932. a4h    =     $43
  933. a5l    =     $44
  934. ;[70] used by interupts a5h    =     $45
  935. ;***************************************************************
  936. ;
  937. ; PART 1: DATA DEFINITIONS -- zero page locations were used where
  938. ;                             speed or indirect addressing were
  939. ;                             deemed important.  These locations
  940. ;                             avoid conflicts with DOS.
  941. ;
  942. ;***************************************************************
  943. ;
  944. .SBTTL Symbol definitions
  945. samef    =    $ff         ;[81]WCHPAT settings: apply curr pat to curr fname
  946. samep    =    0          ;[81]  curr pattern on remainder of name
  947. dosrdk    =    $ae39    ;[81] dos 3.3 read key during catalog
  948. remnp    =    1          ;[81]  remainder of pattern on remainder of name
  949. .SBTTL Kermit zero-page usage
  950. name    =    $5a    ;[81]Current start of name being checked
  951. pat    =    $5c    ;[81]Current start of pattern being checked
  952. stack    =    $60    ;[81]Current page-base of stack
  953. stix    =    $62    ;[81]Stack index
  954. ;
  955.     .endc
  956.  
  957.  
  958. .SBTTL    Character and string definitions
  959.  
  960. nul    =     $00          ; <null>
  961. soh    =     $01          ; <soh>
  962. eot    =    4        ;[83] end of transmission
  963. ack    =    6        ;[83] acknowledge
  964. bel    =    7        ;[82] ring those bells
  965. bs    =     $08          ; <bs>
  966. lftarw    =     $08          ;[35] <left-arrow>
  967. tab    =     $09          ; <tab> (ctrl/I)
  968. lf    =     $0a          ; <lf>
  969. ctrlk    =    $b        ;[76] <vt>
  970. ffd    =     $0c          ; Form feed
  971. cr    =     $0d          ; <cr>
  972. so    =    $e        ;[76] shift out normal video
  973. si    =    $f        ;[73] shift in invers video
  974. nak    =    $15        ;[83] negative acknowledge
  975. ctrlu    =     $15          ; <ctrl/U>
  976. rhtarw    =     $15          ;[35] <right-arrow>
  977. ctrlx    =     $18          ;[0] <ctrl/X>
  978. ctrlz    =    $1a        ;[57] ^Z
  979. esc    =     $1b          ; <esc>
  980. sp    =     $20          ; <space>
  981. del    =     $7f          ; <del>
  982. hbs    =     $88          ; <bs> with H.O. bit on
  983. hctrlh    =     hbs          ;[1] <ctrl/H> with H.O. bit on
  984. htab    =     $89          ; <tab> with H.O. bit on
  985. hlf    =     $8a          ; <lf> with H.O. bit on
  986. hffd    =     $8c          ; <ff> wiht H.O. bit on
  987. hcr    =     $8d          ; <cr> with H.O. bit on
  988. hxon    =     $91          ;[57] ^Q with h.o. bit on
  989. hxoff    =     $93          ;[57] ^S  "
  990. hctrlu    =     $95          ; <ctrl/U> with H.O. bit on
  991. hctrlw    =     $97          ;[1] <ctrl/W> with H.O. bit on
  992. hctrlx    =     $98          ;[0] <ctrl/X> with H.O. bit on
  993. hesc    =     $9b          ; <esc> with H.O. bit on
  994. hspace    =     $a0          ; <sp> with H.O. bit on
  995. hdquot    =     $a2          ;[1] '"' with H.O. bit on
  996. hapos    =     $a7          ;[1] Apostrophy with H.O. bit on
  997. hslash    =     $af          ;[1] '/' with H.O. bit on
  998. hcolon    =     $ba          ;[1] ':' with H.O. bit on
  999. hrabr    =     $be          ;[1] '>' with H.O. bit on
  1000. hquest    =     $bf          ; '?' with H.O. bit on
  1001. hquote    =     $e0          ;[1] "'" with H.O. bit on
  1002. hdel    =     $ff          ; <del> with H.O. bit on
  1003.     .ifeq <ftcom-ftappl>
  1004. wndlft    =     $20          ; Left side of scroll window <0-39>
  1005. wndwth    =     $21          ; Width of scroll window <1-(40-(wndlft)>
  1006. wndtop    =     $22          ; Top of scroll window <0-22>
  1007. wndbtm    =     $23          ; Bottom of scroll window <((wintop)+1)-24>
  1008. ch    =     $24          ; Cursor Horizontal position
  1009. cv    =     $25          ; Cursor Vertical position
  1010. basl    =     $28          ;[33] L.O.B. of base address of current line
  1011. bash    =     $29          ;[33] H.O.B. of base address of current line
  1012. bas2l    =     $2a          ; Base address work area
  1013. bas2h    =     $2b          ; Base address work area
  1014. textfm    =    $32        ;[76] normal/inverse text mode
  1015. ;[31] These two locs are in a 'hole' on page 0 which neither basic nor the
  1016. ;[31] monitor use.
  1017. obasl    =     $F9          ;[31] Save loc for cursor address
  1018. obash    =     $FA          ;[31] Save loc for cursor address
  1019. ourch    =    $57b        ;[49] //3 80 col cards ch
  1020. ourcv    =    $5fb        ;[49]    "              cv
  1021. coldch    =    $47b        ;[49]   "         oldch
  1022. pos80c:                ;[76]
  1023. ;[82]    jsr    fflow        ;[76] is this really rqd? *****
  1024.     lda    cv        ;[58] save this from card
  1025.     sta    hcv        ;[76] need to keep track for ourselves
  1026.     pha        ;[58]
  1027.     lda    ch        ;[58] save this from card
  1028.     sta    hch        ;[76] need to keep track for ourselves
  1029.     pha        ;[58]
  1030.     lda   #$1e          ;[49] this is the positioning command
  1031.     jsr   cout          ;[49] first of three
  1032.     pla        ;[58][49] horizontal position
  1033.     clc          ;[49]
  1034.     adc   #32          ;[49] add the bias
  1035.     jsr   cout          ;[49] and give second to card
  1036.     clc          ;[49] clear the carry flag for add
  1037.     pla        ;[58][49] vertical pos
  1038.     adc   #32          ;[49] and the bias
  1039.     jmp   cout          ;[49] let 80 col return
  1040. vtab:    lda    dsptyp        ;[58] 80 col display ?
  1041.     bpl    vtab1        ;[58] no
  1042.     jmp    pos80c        ;[58] tell 80 col about the move
  1043. vtab1:    jmp    dvtab        ;[58] now let 40 col do its thing
  1044. lfeed:                ;[49]
  1045. ;[74]    lda    #hlf        ;[57] force the test
  1046. ;[74]    ldx    #hcr        ;[57] limit is cr-1 to lf
  1047. ;[74]    jsr    ckflow        ;[57] now for flow control
  1048.     jsr    fflow        ;[74] force flow control
  1049.     lda   dsptyp          ;[49] get display type
  1050.     bpl   lfeed1          ;[49] is this 80 col?,no
  1051.     jsr    bphcv        ;[76] got to keep track of cv
  1052.     lda   #$a          ;[49] would you believe a line feed
  1053.     jmp   cout          ;[49] let the card do it now
  1054. lfeed1: jmp   dlfeed          ;[49] os thing
  1055. advanc: lda   dsptyp          ;[49] get display type
  1056.     bpl   advan1          ;[49] is this 80 col?,no
  1057.     inc    hch        ;[58] move one to the right
  1058. ;[76]    lda    #80        ;[58] off screen ?
  1059.     lda    #79        ;[76][58] off screen ?
  1060.     cmp    hch        ;[58]
  1061.     bpl    advan0        ;[58] no
  1062.     jsr    bphcv        ;[76] yes scrool or bump
  1063.     lda    #0        ;[58] yes we scrool
  1064.     sta    hch        ;[58] left edge now
  1065. advan0                ;[58]
  1066.     lda   #$1c          ;[49] move cursor one to the right
  1067.     jmp   cout          ;[49] position the cursor
  1068. advan1: jmp   dadvan          ;[49] os thing
  1069.     .endc
  1070. ;[87]    .nlst        ;[84]
  1071.  
  1072. .SBTTL    Flag  definitions
  1073.  
  1074. ;     The following are flags passed in the Y register
  1075.  
  1076. cmfehf    =     1          ;[1] Extra help available
  1077. cmfdff    =     2          ;[1] Default value present
  1078.  
  1079. .SBTTL    Parse types
  1080.  
  1081. ;     The following are different items to parse for
  1082.  
  1083. cmini    =     0          ; Token to indicate parser init
  1084. cmkey    =     1          ; Token to parse for keyword
  1085. cmifi    =     2          ; Token to parse for input file
  1086. cmofi    =     3          ; Token to parse for output file
  1087. cmcfm    =     4          ; Token to parse for confirm
  1088. cmnum    =     5          ; Token to parse for a number
  1089. cmswi    =     6          ; Token to parse for a switch
  1090. cmfls    =     7          ; Token to parse for a floating-point number
  1091. cmtxt    =     8          ;[1] Token to parse for an unquoted string
  1092. cmtok    =     9          ;[1] Token to barse for a single char token
  1093.  
  1094. .SBTTL    Parser support
  1095.  
  1096. ;  Define storage for pointers into command buffer. They must be
  1097. ;  on zero-page to take advantage of pre- and post-indexed indirect
  1098. ;  and also the simulated indirect addressing mode.
  1099.  
  1100. saddr    =     $00          ; Saved string address - must be on page zero
  1101. cm.rty    =     $02          ; Byte pointer to CTRL/R Text
  1102. cm.bfp    =     $04          ; Byte pointer to start of text buffer
  1103. cm.ptr    =     $06          ; Byte pointer to Next Input to be parsed
  1104. cm.inc    =     $08          ; Number of characters left in buffer
  1105. cm.cnt    =     $09          ; Space left in buffer
  1106. cminf1    =     $0a          ; Information passed to comnd routines
  1107. cminf2    =     $0c          ;         ...
  1108. cmdptr    =     cminf2          ;[1] Pointer to default for parse
  1109. cmkptr    =     $0e          ; Pointer for Cmkeyw routine
  1110. cmsptr    =     $10          ; Saved character pointer
  1111. cmspt2    =     $12          ; Saved keyword table pointer
  1112. cmspt3    =     $14          ; Saved buffer pointer
  1113. cmhptr    =     $16          ; Ptr. to current help text
  1114. cmptab    =     $18          ; Ptr. to beginning of current keyword table
  1115. cmfcb    =     $1a          ; Pointer to FCB
  1116. cmehpt    =     $1c          ;[1] Pointer to help commands
  1117. irqsva    =     $45          ;[51] interupt saves areg here
  1118.  
  1119. .SBTTL    COMND package entry points
  1120.  
  1121. ;
  1122. ;     The following addresses are locations in a jump table which
  1123. ;     dispatch to appropriate routines in the Comnd package.
  1124. ;
  1125.  
  1126. ;[78]rskp    =     prstr+3          ;[1] Routine to skip 3 bytes on return
  1127. ;[78]setbrk    =     rskp+3          ;[1] Routine to set a break character in brkwrd
  1128. ;[78]rstbrk    =     setbrk+3      ;[1] Routine to reset break character in brkwrd
  1129.  
  1130. .SBTTL    COMND JSYS routines
  1131.  
  1132. ;
  1133. ;     The following set of routines provides a user oriented way of parsing
  1134. ;     commands. It is similar to that of the COMND JSYS in TOPS-20. For 
  1135. ;     convenience, a dispatch table is used.
  1136. ;
  1137.  
  1138. ;[78]comnd:    jmp   comand          ; Dispatch to main command routine
  1139. ;[78]mul16:    jmp   ml16          ; Dispatch to 16-bit multiply routine
  1140. ;[78]div16    jmp    dv16        ;[75]  "               divide  
  1141. ;[75]    jmp   prcl.0          ;[13] Dispatch to Prcrlf
  1142. ;[78]prstr:    jmp   prst.0          ;[13] Dispatch to Prstr
  1143. ;[78]    jmp   rskp.0          ;[13] Dispatch to Rskp
  1144. ;[78]    jmp   sbrk.0          ;[13] Dispatch to Setbrk
  1145. ;[78]    jmp   rbrk.0          ;[13] Dispatch to Rstbrk
  1146.  
  1147. .SBTTL    Storage Declarations
  1148.  
  1149. ;
  1150. ;     Following is the storage declarations for the Comnd routines.
  1151. ;
  1152.  
  1153. ;[78]cmbuf:    .blkb $100          ;[13] Input command buffer
  1154. ;[78]atmbuf: .blkb $100          ;[13] Atombuffer, (for cmtxt and cmifil)
  1155. cmbuf:    .blkb 100          ;[78] Input command buffer
  1156. atmbuf: .blkb 100          ;[78] Atombuffer, (for cmtxt and cmifil)
  1157. lenabf: .byte          ;[13] Length of atom in Atombuffer
  1158. brkwrd: .blkb $16          ;[13] Break mask
  1159. savea:    .byte          ;
  1160. savex:    .byte          ;
  1161. savey:    .byte          ;
  1162. cmbase: .byte          ; Base of integer to be parsed
  1163. cmmres: .blkb 4          ; Return value from cmmult call
  1164. cmintg: .blkb 4          ; Return value for cminum call
  1165. cmfltp: .blkb 6          ; Return value for cmflot call
  1166. cmflen: .byte          ; Field length
  1167. cmescf    .byte    0    ;[87] escape ch flag, 0 = no
  1168. cmcdrv: .byte          ; Current drive
  1169. cmostp: .word          ; Save area for stack pointer
  1170. cmrprs: .word          ; Reparse address
  1171. cmaflg: .byte          ; Non-zero when an action char has been found
  1172. cmcffl: .byte 0          ;[13] Non-zero when privious command failed
  1173. cmfrcf: .byte 0          ;[13] Non-zero when signif. char has been seen
  1174. cmccnt: .byte          ; Non-zero if a significant char is found
  1175. cmocnt: .byte          ;[13] Saved length of command buffer
  1176. cmoptr: .word          ;[13] Saved ptr to command buffer for <ctrl/H>
  1177. cmsflg: .byte          ; Non-zero when the last char was a space
  1178. cmstat: .byte          ; Save area for parse type
  1179. cmprmx: .byte          ;[13] Hold area for Comnd parameters
  1180. cmprmy: .byte          ;[13] Hold area for Comnd flags
  1181. cmkyln: .byte          ; Keyword length
  1182. cmtlen: .byte          ; Test length (for ?-prompting)
  1183. cmscrs: .byte          ; Screen output switch
  1184. cmentr: .byte          ; Number of remaining entries in table
  1185. cmehix: .byte          ;[13] Index to extra help command buffer
  1186. keylen: .byte          ; Keyword length
  1187. cmwrk1: .byte          ; Command processing scratch area
  1188. cmwrk2: .byte          ;         ...
  1189. cmwrk3: .byte          ;         ...
  1190. cmwrk4: .byte          ;         ...
  1191.  
  1192. .SBTTL    Symbol definitions
  1193.  
  1194. true    =     $01          ; Symbol for true return code
  1195. false    =     $00          ; Symbol for false return code
  1196. on    =     $01          ; Symbol for value of 'on' keyword
  1197. off    =     $00          ; Symbol for value of 'off' keyword
  1198. yes    =     $01          ; Symbol for value of 'yes' keyword
  1199. no    =     $00          ; Symbol for value of 'no' keyword
  1200.  
  1201. .SBTTL    Prompt subroutine
  1202.  
  1203. ;
  1204. ;     This routine prints the prompt for the program and specifies the
  1205. ;     reparse address.
  1206. ;
  1207. ;         Inputs:         X - L.O. byte address of prompt
  1208. ;                 Y - H.O. byte address of prompt
  1209. ;
  1210. ;         Outputs:
  1211. ;
  1212. ;         Registers destroyed:     A,X,Y
  1213. ;
  1214.  
  1215. prompt: pla          ; Get Low order byte of return address
  1216.     sta   cmrprs          ; Save that half of reparse address
  1217.     pla          ; Get High order byte
  1218.     sta   cmrprs+1      ; Save the half
  1219.     pha          ; Restore the return
  1220.     lda   cmrprs          ;  address to
  1221.     pha          ;   the stack
  1222. ;    clc          ; Clear the carry
  1223. ;    adc   #$01          ; Increment this address since it is one
  1224. ;    sta   cmrprs          ;     short of the desired target.
  1225. ;    lda   cmrprs+1      ; Account for the carry, if any
  1226. ;    adc   #$00          ;         ...
  1227. ;    sta   cmrprs+1      ;         ...
  1228.     inc    cmrprs
  1229.     bne    promp0
  1230.     inc    cmrprs+1
  1231. promp0
  1232.     stx   cm.rty          ;[13] Save address of the prompt in
  1233.     sty   cm.rty+1      ;[13]     the pointer to the ctrl/r text
  1234.     tsx          ; Get the stack pointer
  1235.     stx   cmostp          ; Save it for later restoral
  1236.     lda   #cmbuf\          ; Get Low order byte of buffer address
  1237.     sta   cm.bfp          ; Init start of text buffer
  1238.     sta   cm.ptr          ; Init next input to be parsed
  1239.     lda   #cmbuf^          ; Get High order byte of buffer address
  1240.     sta   cm.bfp+1      ; H.O. byte of text buffer pointer
  1241.     sta   cm.ptr+1      ; H.O. byte of next input pointer
  1242.     lda   #$00          ; Clear AC
  1243.     sta   cmaflg          ; Clear the flags
  1244.     sta   cmccnt          ;
  1245.     sta   cmsflg          ;
  1246.     jsr   prcrlf          ; Print crlf
  1247.     ldx   cm.rty          ; Get L.O. byte of prompt address to be passed
  1248.     ldy   cm.rty+1      ; Get H.O. byte of prompt address
  1249.     jsr   prstr          ; Print the prompt
  1250.     rts          ; Return
  1251.  
  1252. .SBTTL    Repars routine
  1253.  
  1254. ;
  1255. ;     This routine sets stuff up to reparse the current command
  1256. ;     buffer.
  1257. ;
  1258. ;         Input:
  1259. ;
  1260. ;         Output:         Reinitialize comnd pointers and flags
  1261. ;
  1262. ;         Registers destroyed:     A,X
  1263. ;
  1264.  
  1265. repars: ldx   cmostp          ; Fetch old Stack pointer
  1266.     txs          ; Make it the current one
  1267.     lda   #cmbuf\          ; Get L.O. byte address of cmbuf
  1268.     sta   cm.ptr          ; Stuff it
  1269.     lda   #cmbuf^          ; Get H.O. byte address of cmbuf
  1270.     sta   cm.ptr+1      ; The buffer pointer is now reset
  1271.     lda   #$00          ; Clear AC
  1272.     sta   cmsflg          ; Clear the space flag
  1273.     jmp   (cmrprs)      ; Jump at the reparse address
  1274.  
  1275. .SBTTL    Prserr routine
  1276.  
  1277. ;
  1278. ;     This routine is used when a parsing error occurs. It resets ALL
  1279. ;     of the pointers and flags and then goes to the reparse address.
  1280. ;
  1281. ;         Input:
  1282. ;
  1283. ;         Output:
  1284. ;
  1285. ;         Registers destroyed:
  1286. ;
  1287.  
  1288. prserr: lda   cm.ptr          ;[13] Store old command line pointer
  1289.     sta   cmoptr          ;[13]         ...
  1290.     lda   cm.ptr+1      ;[13]         ...
  1291.     sta   cmoptr+1      ;[13]         ...
  1292.     lda   cmccnt          ;[13] Store old character count
  1293.     sta   cmocnt          ;[13]         ...
  1294.     lda   #$ff          ;[13] Set the failure flag
  1295.     sta   cmcffl          ;[13]         ...
  1296.     ldx   cmostp          ; Fetch the saved SP
  1297.     txs          ; Make it the current one
  1298.     lda   #cmbuf\          ; Set up the command buffer
  1299.     sta   cm.bfp          ;     address in both the
  1300.     sta   cm.ptr          ;     buffer pointer and the
  1301.     lda   #cmbuf^          ;     next input pointer.
  1302.     sta   cm.bfp+1      ;         ...
  1303.     sta   cm.ptr+1      ;         ...
  1304.     lda   #$00          ; Clear AC
  1305.     sta   cmaflg          ; Zero the action flag
  1306.     sta   cmccnt          ;     the character count
  1307.     sta   cmsflg          ;     and the space flag
  1308.     jsr   prcrlf          ; Print a crelf
  1309.     ldx   cm.rty          ; Get the address of the prompt
  1310.     ldy   cm.rty+1      ;[13]         ...
  1311.     jsr   prstr          ; Reprint the prompt
  1312.     jmp   (cmrprs)      ; Jump at the reparse address
  1313.  
  1314. .SBTTL    COMND - Entry point for command Jsys stuff
  1315.  
  1316. ;
  1317. ;     COMND routine - This routine checks the code in the AC for
  1318. ;     what parse type is wanted and then dispatches to an appropriate
  1319. ;     routine to look for it. Additional information is located in
  1320. ;     CMINF1 and CMINF2 on page zero.
  1321. ;
  1322. ;         Input:         A - parse type
  1323. ;                 X,Y - optional parameters
  1324. ;
  1325. ;         Output:         A - +1 = success
  1326. ;                     +4 = failure (assumes JMP after call)
  1327. ;
  1328. ;         Registers destroyed:     A
  1329. ;
  1330.  
  1331. comand: sta   cmstat          ; Save what we are parsing
  1332.     stx   cmprmx          ;[13] Save these parameters also
  1333.     sty   cmprmy          ;[13]         ...
  1334.     cmp   #cmini          ; Initialize the world?
  1335.     bne   comn0          ; No, handle like a normal parse type
  1336.     jmp   prompt          ; Do the prompt routine to set things up
  1337. comn0:    jsr   cminbf          ; Get characters until action or erase
  1338.     cmp   #cmcfm          ; Parse a confirm?
  1339.     bne   comn1          ; Nope
  1340.     jmp   cmcfrm          ; Yes, try for the confirm
  1341. comn1:    cmp   #cmkey          ; Parse a keyword perhaps?
  1342.     bne   comn2          ; No, next item
  1343.     jmp   cmkeyw          ; Get the keyword
  1344. comn2:    cmp   #cmifi          ; Parse an input file?
  1345.     bne   comn3          ; No, try next one
  1346.     jmp   cmifil          ; Get the input file
  1347. comn3:    cmp   #cmofi          ; Parse an output file?
  1348.     bne   comn4          ; No, try next
  1349.     jmp   cmofil          ; Get the output file
  1350. comn4:    cmp   #cmswi          ; Parse a switch?
  1351.     bne   comn5          ; No, try next again
  1352.     jmp   cmswit          ; Yes, do a switch
  1353. comn5:    cmp   #cmnum          ; Parse an integer?
  1354.     bne   comn6          ; No, try next type
  1355.     jmp   cminum          ; Do the parse integer routine
  1356. comn6:    cmp   #cmfls          ; Parse a floating point?????
  1357.     bne   comn7          ; Nope, try next one
  1358.     jmp   cmflot          ; Yes, go get a floating point number
  1359. comn7:    cmp   #cmtxt          ;[13] Parse for Unquoted string?
  1360.     bne   comn8          ;[13] Nope, go try last type
  1361.     jmp   cmunqs          ;[13] Go parse the string
  1362. comn8:    cmp   #cmtok          ;[13] Parse for a Single Character?
  1363.     bne   comn9          ;[13] Nope, no more parse types
  1364.     jmp   cmtokn          ;[13] Go parse for char
  1365. comn9:    ldx   #cmer00\      ; Error 0 - Bad parse type
  1366.     ldy   #cmer00^      ;         ...
  1367.     jsr   prstr          ; Print the error text
  1368.     lda   #$04          ; Fail
  1369.     rts          ; Return to caller
  1370.  
  1371. .SBTTL    Cmcfrm routine - get a confirm
  1372.  
  1373. ;
  1374. ;     This routine tries to get a confirm from the command input
  1375. ;     buffer.
  1376. ;
  1377. ;         Input:     Cm.ptr     - Beginning of next field to be parsed
  1378. ;
  1379. ;         Output:     On success, routine skip returns
  1380. ;
  1381. ;         Registers destroyed:     A,X,Y
  1382. ;
  1383.  
  1384. cmcfrm: lda   cm.ptr          ; Save the current command line pointer
  1385.     pha          ;     on the stack in case the user
  1386.     lda   cm.ptr+1      ;     wants to parse for an alternate item
  1387.     pha          ;         ...
  1388. cmcfr0: jsr   cmgtch          ; Get a character
  1389.     cmp   #$00          ; Is it negative?
  1390.     bpl   cmcfrr          ; No, fail
  1391.     and   #$7f          ; Yes, zero the sign bit
  1392.     cmp   #esc          ; An escape?
  1393.     bne   cmcfr2          ; No, continue
  1394.     jsr   bell          ; Sound bell, error...
  1395.     lda   #$00          ; Clear AC
  1396.     sta   cmaflg          ; Clear the action flag
  1397.     sec          ; Set carry for subtraction
  1398.     lda   cm.bfp          ; Get L.O. byte
  1399.     sbc   #$01          ; Decrement it once
  1400.     sta   cm.bfp          ; Store it back
  1401.     sta   cm.ptr          ; Make this pointer look like the other one
  1402.     bcs   cmcfr1          ; If set, we don't have to do H.O. byte
  1403.     dec   cm.bfp+1      ; Adjust H.O. byte
  1404. cmcfr1: lda   cm.bfp+1      ; Move this to H.O. byte of the other pointer
  1405.     sta   cm.ptr+1      ;         ...
  1406.     dec   cmccnt          ; Decrement the character count
  1407.     jmp   cmcfr0          ; Try again.
  1408. cmcfr2: cmp   #'?          ; User need help??
  1409.     bne   cmcfr3          ; Nope
  1410.     ora   #$80          ; Make sure this is negative ascii
  1411.     jsr   cout          ; Print the '?'
  1412.     ldx   #cmin00\      ; Get address of some help info
  1413.     ldy   #cmin00^      ;         ...
  1414. ;[79]    jsr   prstr          ; Print it.
  1415. ;[79]    jsr   prcrlf          ; Print the crelf
  1416.     jsr    prstrl        ;[79]
  1417.     ldx   cm.rty          ;[13] Get address of prompt
  1418.     ldy   cm.rty+1      ;[13]     reprint it
  1419.     jsr   prstr          ; Reprint the prompt
  1420.     lda   #$00          ; Clear AC
  1421.     ldy   #$00          ; Clear Y
  1422.     sta   (cm.ptr),y      ; Drop null at end of command buffer
  1423. ;[87]    sec          ; Set carry for subtraction
  1424. ;[87]    lda   cm.bfp          ; Get L.O. byte
  1425. ;[87]    sbc   #$01          ; Decrement it
  1426. ;[87]    sta   cm.bfp          ; Store it back
  1427. ;[87]    lda   cm.bfp+1      ; Now do H.O. byte
  1428. ;[87]    sbc   #$00          ;         ...
  1429. ;[87]    sta   cm.bfp+1      ;         ...
  1430.     ldx    cm.bfp        ;[87] lsb
  1431.     dex            ;[87]
  1432.     stx    cm.bfp        ;[87]
  1433.     cpx    #$ff        ;[87] did we carry?
  1434.     bne    .+5        ;[87] no
  1435.     dec    cm.bfp+1    ;[87]
  1436.     ldx   #cmbuf\          ; Get address of the command buffer
  1437.     ldy   #cmbuf^          ;         ...
  1438.     jsr   prstr          ; Reprint the command line
  1439.     lda   #$00          ; Clear AC
  1440.     sta   cmaflg          ; Action flag off
  1441.     jmp   repars          ; Go reparse the line
  1442. cmcfr3: cmp   #ffd          ; Is it a form feed?
  1443.     bne   cmcfr4          ; Nope
  1444.     jsr   home          ; Yes, blank the screen
  1445. cmcfr4: pla          ; Since this succeeded, we can flush the
  1446.     pla          ;     old command line pointer
  1447.     lda   #$00          ;[13] Reset the failure flag
  1448.     sta   cmcffl          ;[13]         ...
  1449.     jmp   rskp          ; Do a return skip
  1450.  
  1451. cmcfrr: pla          ; Restore the old comand line pointer
  1452.     sta   cm.ptr+1      ;         ...
  1453.     sta   cmoptr+1      ;[13]         ...
  1454.     pla          ;         ...
  1455.     sta   cm.ptr          ;         ...
  1456.     sta   cmoptr          ;[13]         ...
  1457.     lda   cmccnt          ;[13] Save count in case of <ctrl/H>
  1458.     sta   cmocnt          ;[13]         ...
  1459.     lda   #$ff          ;[13] Set failure
  1460.     sta   cmcffl          ;[13]         ...
  1461.     rts          ; Return
  1462.  
  1463. .SBTTL    Cmkeyw - Try to parse a keyword next
  1464.  
  1465. ;
  1466. ;     This routine tries to parse a keyword from the table
  1467. ;     pointed to by cminf1. The keywords must be in alphabetical
  1468. ;     order. The routine returns the two bytes of data associated
  1469. ;     with the keyword. The format of the table is as follows:
  1470. ;
  1471. ;     addr:     .byte     n      ; Where n is the # of entries in the table.
  1472. ;         .byte     m      ; m is the size of the next keyword
  1473. ;         .asciz     /string/ ; keyword ending in a null
  1474. ;         .byte     a,b      ; 16 bits of data related to keyword
  1475. ;
  1476. ;         Input:     Cminf1-     Pointer to keyword table
  1477. ;
  1478. ;         Output:     X-     byte a
  1479. ;             Y-     byte b
  1480. ;
  1481. ;         Registers destroyed:     A,X,Y
  1482. ;
  1483.  
  1484. cmkeyw: lda   cm.ptr          ; Save current comand line pointer
  1485.     pha          ;         ...
  1486.     lda   cm.ptr+1      ;         ...
  1487.     pha          ;         ...
  1488.     lda   #$00          ;[13] Clear the 'real character' flag
  1489.     sta   cmfrcf          ;[13]         ...
  1490.     lda   cminf1          ; Copy to address of
  1491.     sta   cmptab          ;     the keyword table
  1492.     clc          ; Clear the carry
  1493.     adc   #$01          ; Add one to the addr. (pass the table length)
  1494.     sta   cmkptr          ; Save the keyword pointer (L.O. byte)
  1495.     lda   cminf1+1      ; Get H.O. byte
  1496.     sta   cmptab+1      ; Save a copy of that
  1497. ;[73]    bcc   cmkey1          ; Carry?
  1498.     adc   #$00          ; Add in the carry for cmkptr
  1499. cmkey1: sta   cmkptr+1      ; Save it
  1500.     ldy   #$00          ; Clear Y
  1501.     lda   (cmptab),y      ; Get the table length
  1502.     sta   cmentr          ; Save number of entries in the table     
  1503. cmky10: jsr   cmgtch          ; Get first character
  1504.     cmp   #$00          ; Was the first character a terminator?
  1505.     bmi   cmky11          ; Yup, the saved pointer does not get decr.
  1506.     sec          ; Make sure saved buffer pointer is correct
  1507.     lda   cm.ptr          ; Now, reset it back one character for later
  1508.     sbc   #$01          ;         ...
  1509.     sta   cm.ptr          ;         ...
  1510.     sta   cmsptr          ;         ...
  1511.     lda   cm.ptr+1      ;         ...
  1512.     sbc   #$00          ;         ...
  1513.     sta   cm.ptr+1      ;         ...
  1514.     sta   cmsptr+1      ;         ...
  1515.     jmp   cmkey2          ; Continue
  1516. cmky11: ldy   cm.ptr          ;[13] Just move the pointer to the save area
  1517.     sty   cmsptr          ;[13]         ...
  1518.     ldy   cm.ptr+1      ;[13]         ...
  1519.     sty   cmsptr+1      ;[13]         ...
  1520.     cmp   #hesc          ;[13] Was the first terminator an escape?
  1521.     beq   cmky12          ;[13] Yes, handle this
  1522.     jmp   cmkey2          ;[13] No, continue
  1523. cmky12: lda   #cmfdff          ;[13] Is there a default?
  1524.     bit   cmprmy          ;[13]         ...
  1525.     bne   cmky13          ;[13] Yes, go copy it
  1526.     lda   #$00          ;[13] Shut the action flag
  1527.     sta   cmaflg          ;[13]         ...
  1528.     jsr   bell          ;[13] Yes, start by feeping terminal
  1529.     sec          ;[13] Set the carry bit for subtraction
  1530.     lda   cm.bfp          ;[13] Take L.O. byte of buffer pointer
  1531.     sbc   #$01          ;[13] Decrement it (back up before escape)
  1532.     sta   cm.bfp          ;[13] Store it
  1533.     sta   cm.ptr          ;[13] And stuff it in next input char pointer
  1534.     bcs   cmkync          ;[13] If carry is clear, we are done
  1535.     dec   cm.bfp+1      ;[13] Do the carry on H.O. byte
  1536. cmkync: lda   cm.bfp+1      ;[13] Copy this to next char to parse pointer
  1537.     sta   cm.ptr+1      ;[13]         ...
  1538.     jmp   cmky10          ;[13] Continue by fetching a character again
  1539. cmky13: lda   #$00          ;[13] Zero the action flag
  1540.     sta   cmaflg          ;[13]         ...
  1541.     jmp   cmcpdf          ;[13] Do the copy     
  1542. cmkey2: lda   cmentr          ; Get number of entries left
  1543. ;    cmp   #$00          ; 0 entries left?
  1544.     bne   cmky21          ; No, go try next entry
  1545.     pla          ; Fetch back to previous comand line pointer
  1546.     sta   cm.ptr+1      ;         ...
  1547.     sta   cmoptr+1      ;[13]         ...
  1548.     pla          ;         ...
  1549.     sta   cm.ptr          ;         ...
  1550.     sta   cmoptr          ;[13]         ...
  1551.     lda   cmccnt          ;[13] Save count in case of <ctrl/H>
  1552.     sta   cmocnt          ;[13]         ...
  1553.     lda   #$ff          ;[13] Set the command-failure flag
  1554.     sta   cmcffl          ;[13]         ...
  1555.     rts
  1556. cmky21: ldy   #$00          ; Clear Y
  1557.     lda   (cmkptr),y      ; Get length of keyword
  1558.     sta   keylen          ; Store it
  1559.     lda   cmkptr          ; Get the new table pointer
  1560.     sta   cmspt2          ;     and save it for later
  1561.     lda   cmkptr+1      ;         ...
  1562.     sta   cmspt2+1      ;         ...
  1563.     inc   cmkptr          ; Increment the L.O. byte once
  1564.     bne   cmkey3          ; If it didn't wrap, there is no carry
  1565.     inc   cmkptr+1      ; There was a carry, add it in.
  1566. cmkey3: dec   keylen          ; Decrement the number of chars. left
  1567.     lda   keylen          ; Get the remaining length
  1568.     cmp   #$ff          ; Have we passed the end
  1569.     bpl   cmk3a          ; No
  1570.     jmp   cmkey5          ; Yes
  1571. cmk3a:    jsr   cmgtch          ; Get a character
  1572.     cmp   #$00          ; Is it a terminator?
  1573.     bmi   cmk3b          ; Yup, it is negative
  1574.     jmp   cmkey4          ; Nope, it's positive
  1575. cmk3b:    and   #$7f          ; Shut off the minus bit
  1576.     cmp   #'?          ; Need any help?
  1577.     bne   cmky31          ; Nope
  1578.     ora   #$80          ; Set the H.O. bit
  1579.     jsr   cout          ; And print the question mark
  1580.     lda   #$00          ; Clear AC
  1581.     sta   cmaflg          ; Clear the action flag
  1582.     lda   cmstat          ; Get saved parse type
  1583.     cmp   #cmswi          ; Are we really doing a switch?
  1584.     beq   cmk3b1          ; Yes, give that message instead
  1585.     ldx   #cmin01\      ; L.O. byte addr of informational message
  1586.     ldy   #cmin01^      ; H.O. byte of address
  1587.     jmp   cmk3b2          ; Go print the message
  1588. cmk3b1: ldx   #cmin02\      ; Load address of switch message
  1589.     ldy   #cmin02^      ;         ...
  1590. ;[79]cmk3b2: jsr   prstr          ; Print the message
  1591. ;[79]    jsr   prcrlf          ; Print a crelf
  1592. cmk3b2    jsr    prstrl        ;[79]
  1593.     jsr   cmktp          ;     and the valid entries in keyword table
  1594.     jsr   prcrlf          ; Print another crlf
  1595.     lda   #cmfehf          ;[13] Load extra help flag
  1596.     bit   cmprmy          ;[13] Test bit
  1597.     beq   cmk3b3          ;[13] No extra help
  1598.     jsr   cmehlp          ;[13] Go give extra help
  1599. cmk3b3: ldx   cm.rty          ;[13] Get L.O. address of prompt
  1600.     ldy   cm.rty+1      ;[13] And H.O. address of prompt
  1601.     jsr   prstr          ; Reprint the prompt
  1602.     lda   #$00          ; Clear AC
  1603.     ldy   #$00          ; Clear Y
  1604.     sta   (cm.ptr),y      ; Stuff a null in the buffer at that point
  1605.     sec          ; Set the carry
  1606.     lda   cm.bfp          ; Get ready to decrement buffer pointer
  1607.     sbc   #$01          ; Subtract it
  1608.     sta   cm.bfp          ; Store it
  1609.     bcs   cmky3a          ; Do we have to account for carry
  1610.     dec   cm.bfp+1      ; Decrement the H.O. byte
  1611. cmky3a: ldx   #cmbuf\          ; Get L.O. byte address of buffer
  1612.     ldy   #cmbuf^          ;     and H.O. byte
  1613.     jsr   prstr          ; Reprint the command line
  1614.     jmp   repars          ; Go reparse all of it
  1615. cmky31: cmp   #esc          ; escape character?
  1616.     beq   cmk3c          ; Yup, process it
  1617.     jmp   cmky35          ; Nope.
  1618. cmk3c:    lda   #$00          ; Clear AC
  1619.     sta   cmaflg          ; Clear action flag
  1620.     lda   keylen          ; Save on the stack, the
  1621.     pha          ;     keylength
  1622.     lda   cmentr          ;     number of entries left
  1623.     pha          ;         ...
  1624.     lda   cmkptr          ;     L.O. byte of keyword table pointer
  1625.     pha          ;         ...
  1626.     lda   cmkptr+1      ;     H.O. byte of keyword table pointer
  1627.     pha          ;         ...
  1628.     jsr   cmambg          ; Is it ambiguous?
  1629.           jmp     cmky32          ; Nope
  1630.     lda   #cmfdff          ;[13] Load default-present flag
  1631.     bit   cmprmy          ;[13] Check against flags
  1632.     beq   cmk3d          ;[13] No, complain to user
  1633.     lda   cmfrcf          ;[13] Have we seen a real character yet?
  1634.     bne   cmk3d          ;[13] No, tell user
  1635.     jmp   cmcpdf          ;[13] Yes, Go copy the default
  1636. cmk3d:    jsr   bell          ; Yes, start by feeping terminal
  1637.     sec          ; Set the carry bit for subtraction
  1638.     lda   cm.bfp          ; Take L.O. byte of buffer pointer
  1639.     sbc   #$01          ; Decrement it (back up before escape)
  1640.     sta   cm.bfp          ; Store it
  1641.     sta   cm.ptr          ; And stuff it in next input char pointer
  1642.     bcs   cmky3b          ; If carry is clear, we are done
  1643.     dec   cm.bfp+1      ; Do the carry on H.O. byte
  1644. cmky3b: lda   cm.bfp+1      ; Copy this to the next char to parse pointer
  1645.     sta   cm.ptr+1      ;         ...
  1646.     dec   cmccnt          ; Decrement the character count
  1647.     pla          ; Restore the
  1648.     sta   cmkptr+1      ;     H.O. byte of keyword table pointer
  1649.     pla          ;         ...
  1650.     sta   cmkptr          ;     L.O. byte of keyword table pointer
  1651.     pla          ;         ...
  1652.     sta   cmentr          ;     Number of entries left in table
  1653.     pla          ;         ...
  1654.     sta   keylen          ;     And the remaining keylength
  1655.     inc   keylen          ; Adjust the keylength to make it correct
  1656.     jmp   cmkey3          ; And go back to try again
  1657. cmky32: ldy   #$00          ; Clear Y
  1658.     sec          ; Set the carry flag
  1659.     lda   cm.bfp          ; Move buffer pointer behind the escape
  1660.     sbc   #$01          ;         ...
  1661.     sta   cm.bfp          ;         ...
  1662.     sta   cm.ptr          ;         ...
  1663.     bcs   cmk32c          ;         ...
  1664.     dec   cm.bfp+1      ; Have to adjust the H.O. byte
  1665. cmk32c: lda   cm.bfp+1      ;         ...
  1666.     sta   cm.ptr+1      ;         ...
  1667.     pla          ; Fetch the old keytable pointer
  1668.     sta   cmkptr+1      ;         ...
  1669.     pla          ;         ...
  1670.     sta   cmkptr          ;         ...
  1671.     pha          ; Now push it back on the stack
  1672.     lda   cmkptr+1      ;         ...
  1673.     pha          ;         ...
  1674. cmky33: lda   (cmkptr),y      ; Get next character
  1675. ;    cmp   #$00          ; Done?
  1676.     beq   cmky34          ; Yes
  1677. ;[73]    tax          ; No, hold on to the byte
  1678. ;[73]    clc          ; Clear the carry flag
  1679. ;[73]    lda   cmkptr          ; Adjust the keyword pointer up one place
  1680. ;[73]    adc   #$01          ; Do L.O. byte
  1681. ;[73]    sta   cmkptr          ; Store it
  1682. ;[73]    bcc   cmky3c          ; Carry?
  1683.     inc    cmkptr        ;[73]
  1684.     bne    cmky3c        ;[73]
  1685.     inc   cmkptr+1      ; Yes, increment H.O. byte
  1686. cmky3c: ;[73]txa          ; Get the data
  1687.     ora   #$80          ; Make sure H.O. bit is set for consistency
  1688.     sta   (cm.ptr),y      ; Stuff it in the buffer
  1689. ;[73]    clc          ; Clear the carry flag again
  1690. ;[73]    lda   cm.ptr          ; Get L.O byte of buffer pointer
  1691. ;[73]    adc   #$01          ; Increment it
  1692. ;[73]    sta   cm.ptr          ; Store it
  1693. ;[73]    bcc   cmky3d          ; Carry?
  1694.     inc    cm.ptr        ;[73]
  1695.     bne    cmky3d        ;[73]
  1696.     inc   cm.ptr+1      ; Increment H.O. byte
  1697. cmky3d: inc   cmccnt          ; Increment character count
  1698.     jmp   cmky33          ; Get next character from table
  1699. cmky34: inc   cmccnt          ; Incrment the character count
  1700.     lda   #$a0          ; Clear AC
  1701.     sta   (cm.ptr),y      ; Stuff a null in the buffer
  1702.     ldx   cm.bfp          ; Get L.O. byte of buffer pointer
  1703.     ldy   cm.bfp+1      ;     and H.O byte - save these for later
  1704.     clc          ; Clear carry
  1705.     lda   cm.ptr          ; Increment next char of input pointer
  1706.     adc   #$01          ;         ...
  1707.     sta   cm.ptr          ;         ...
  1708.     sta   cm.bfp          ;         ...
  1709.     bcc   cmky3e          ; Carry?
  1710.     inc   cm.ptr+1      ; Do H.O. byte
  1711. cmky3e: lda   cm.ptr+1      ; Make buffer pointer match next char pointer
  1712.     sta   cm.bfp+1      ;         ...
  1713.     sty   savey          ; Hold y for a bit
  1714.     lda   #$00          ; Put a null in the buffer to terminate string
  1715.     ldy   #$00          ;         ...
  1716.     sta   (cm.ptr),y      ;         ...
  1717.     ldy   savey          ; Get Y value back
  1718.     jsr   prstr          ; Print remainder of keyword
  1719.     pla          ; Restore the
  1720.     sta   cmkptr+1      ;     H.O. byte of keyword table pointer
  1721.     pla          ;         ...
  1722.     sta   cmkptr          ;     L.O. byte of keyword table pointer
  1723.     pla          ;         ...
  1724.     sta   cmentr          ;     Number of entries left in table
  1725.     pla          ;         ...
  1726.     sta   keylen          ;     And the remaining keylength
  1727.     jmp   cmky37          ; Go get some data to return
  1728. cmky35: lda   cmkptr          ; Save on the stack the
  1729.     pha          ;     L.O. byte of keyword table pointer
  1730.     lda   cmkptr+1      ;         ...
  1731.     pha          ;     H.O. byte of keyword table pointer
  1732.     lda   keylen          ;         ...
  1733.     pha          ;     The keylength
  1734.     jsr   cmambg          ; Check for ambiguity
  1735.           jmp     cmky36          ; Not ambiguous
  1736.     ldx   #cmer01\      ; Get addr of ambiguous error
  1737.     ldy   #cmer01^      ;         ...
  1738.     jsr   prstr          ; Print the error message
  1739.     jmp   prserr          ; Go do parsing error stuff
  1740. cmky36: pla          ; Fetch off of the stack the
  1741.     sta   keylen          ;     remaining keylength
  1742.     pla          ;         ...
  1743.     sta   cmkptr+1      ;     H.O. byte of keyword table address
  1744.     pla          ;         ...
  1745.     sta   cmkptr          ;     L.O. byte of keyword table address
  1746. cmky37: inc   keylen          ; Adjust the remaining keylength
  1747.     inc   keylen          ;         ...
  1748.     clc          ; Clear the carry flag
  1749.     lda   cmkptr          ; Get the keyword table pointer     
  1750.     adc   keylen          ; Add in remaining keylength
  1751.     sta   cmkptr          ; Store it
  1752.     bcc   cmky3f          ; Carry?
  1753.     inc   cmkptr+1      ; Yes, adjust H.O. byte
  1754. cmky3f: ldy   #$00          ; Make sure Y is clear
  1755.     lda   (cmkptr),y      ; Get first data byte
  1756.     tax          ; Put it in X
  1757.     iny          ; Up the index once
  1758.     lda   (cmkptr),y      ; Get the second data byte
  1759.     tay          ; Put that in Y
  1760.     pla          ; Flush the old comand line pointer
  1761.     pla          ;         ...
  1762.     lda   #$00          ;[13] Reset the failure flag
  1763.     sta   cmcffl          ;[13]         ...
  1764.     jmp   rskp          ; Return skip means it succeeds!
  1765. ;[81]cmkey4: cmp   #'a          ; Check range for lower case
  1766. ;[81]    bmi   cmky41          ;         ...
  1767. ;[81]    cmp   #<'z+1>          ;         ...
  1768. ;[81]    bpl   cmky41          ;         ...
  1769. ;[81]    and   #^o137          ; Cutesy way to capitalize it
  1770. cmkey4    jsr    convuc        ;[81] convert to upper case
  1771. ;[81]cmky41: sta   cmwrk3          ; Save the character
  1772.     sta   cmwrk3          ; Save the character
  1773.     lda   #$ff          ;[13] Set the 'real character' flag
  1774.     sta   cmfrcf          ;[13]         ...
  1775.     ldy   #$00          ; Clear Y again
  1776.     lda   (cmkptr),y      ; Get next keyword byte
  1777.     sta   cmwrk4          ; Hold that for now
  1778. ;[73]    clc          ; Clear the carry flag
  1779. ;[73]    lda   cmkptr          ; Get L.O. byte of keyword pointer
  1780. ;[73]    adc   #$01          ; Add one
  1781. ;[73]    sta   cmkptr          ; Store it
  1782. ;[73]    bcc   cmky4a          ; Need to do carry?
  1783.     inc    cmkptr        ;[73]
  1784.     bne    cmky4a        ;[73]
  1785.     inc   cmkptr+1      ; Yes, do H.O. byte
  1786. cmky4a: lda   cmwrk3          ; Get input character
  1787.     cmp   cmwrk4          ; Does it match keyword character?
  1788.     bne   cmkey5          ; No, advance to next keyword in table
  1789.     jmp   cmkey3          ; Yup, try next input byte
  1790. cmkey5: inc   keylen          ; Adjust keylength so that it is correct
  1791.     inc   keylen          ;         ...
  1792.     inc   keylen          ;         ...
  1793.     clc          ; Clear carry
  1794.     lda   cmkptr          ; Ok, get keyword pointer and
  1795.     adc   keylen          ; Add the remaining keylength
  1796.     sta   cmkptr          ; Store it
  1797.     bcc   cmky5a          ; See if we have to do carry
  1798.     inc   cmkptr+1      ; Yes, increment H.O. byte
  1799. cmky5a: dec   cmentr          ; Decrement the number of entries left
  1800.     lda   cmsptr          ; Get the saved buffer pointer and
  1801.     sta   cm.ptr          ;     restore it
  1802.     lda   cmsptr+1      ;         ...
  1803.     sta   cm.ptr+1      ;         ...
  1804.     jmp   cmkey2          ; Try to parse this keyword now
  1805.  
  1806. .SBTTL    Cmambg - check if keyword prefix is ambiguous
  1807.  
  1808. ;
  1809. ;     This routine looks at the next keyword in the table and
  1810. ;     determines if the prefix entered in the buffer is ambiguous
  1811. ;     or not. If it is ambiguous, it skip returns, otherwise it
  1812. ;     returns normally.
  1813. ;
  1814. ;         Input:     Cmentr-     number of entries left in table
  1815. ;             Cmkptr- current keyword table pointer
  1816. ;             Keylen-     remaining keyword length
  1817. ;
  1818. ;         Output:     If ambiguous, does a skip return
  1819. ;
  1820. ;         Registers destroyed:     A,X,Y
  1821. ;
  1822.  
  1823. cmambg: dec   cmentr          ; Start by decrementing remaining entries
  1824.     bpl   cma1          ; We still have stuff left
  1825.     rts          ; Nothing left, it can't be ambiguous
  1826. cma1:    inc   keylen          ; Adjust this up by one
  1827.     lda   keylen          ; Save character count
  1828.     sta   cmwrk3          ;         ...
  1829.     clc          ; Clear the carry
  1830.     adc   #$03          ; Adjust the keylength to include terminator
  1831.     sta   keylen          ;     and data bytes
  1832.     clc          ; Clear carry
  1833.     lda   cmkptr          ; Up the keyword table pointer
  1834.     adc   keylen          ;     by remaining keylength
  1835.     sta   cmkptr          ; Save it
  1836.     bcc   cma2          ; Need to adjust H.O byte?
  1837.     inc   cmkptr+1      ; Yes, do it
  1838. cma2:    ldy   #$00          ; Clear Y
  1839.     lda   (cmkptr),y      ; Get keyword length
  1840.     sta   cmwrk4          ; Hold that byte
  1841. ;    clc          ; Clear carry
  1842. ;    lda   cmkptr          ; Advance keyword table pointer
  1843. ;    adc   #$01          ;         ...
  1844. ;    sta   cmkptr          ;         ...
  1845. ;    bcc   cma3          ;         ...
  1846.     inc    cmkptr        ;[58]
  1847.     bne    cma3        ;[58]
  1848.     inc   cmkptr+1      ;         ...
  1849. cma3:    lda   (cmspt2),y      ; Get previous keyword length
  1850.     sec          ; Set carry
  1851.     sbc   cmwrk3          ; Subtract number of characters left
  1852.     beq   cmambs          ;[13] If test length is 0, don't bother trying
  1853.     sta   cmtlen          ; This is the testing length
  1854.     cmp   cmwrk4          ; Check this against length of new keyword
  1855.     bmi   cmamb0          ; This may be ambiguous
  1856.     rts          ; Test length is longer, cannot be ambiguous
  1857. cmamb0: ldy   #$00          ; Clear Y
  1858. cmamb1: dec   cmtlen          ; Decrement the length to test
  1859.     bpl   cma4          ; Still characters left to check
  1860. cmambs: jmp   rskp          ;[13] The whole thing matched, it is ambiguous
  1861. cma4:    lda   (cmkptr),y      ; Get next character of keyword
  1862.     sta   cmwrk3          ; Hold that for now
  1863.     lda   (cmsptr),y      ; Get next parsed character
  1864.     iny          ; Up the pointer once
  1865. ;[81]~    cmp   #'a          ; Check the range for lower case
  1866. ;[81]    bmi   cmamb2          ;         ...
  1867. ;[81]    cmp   #<'z+1>          ;         ...
  1868. ;[81]    bpl   cmamb2          ;         ...
  1869. ;[81]    and   #^o137          ; Capitalize it
  1870. ;[81]cmamb2: and   #$7f          ; Reset H.O. bit
  1871.     jsr    convuc        ;[81]
  1872.     cmp   cmwrk3          ; Same as keyword table character
  1873.     beq   cmamb1          ; Yup, check next character
  1874.     rts          ; Nope, prefix is not ambiguous
  1875.  
  1876.  
  1877. .SBTTL    Cmktp - print entries in keyword table matching prefix
  1878.  
  1879. ;
  1880. ;     This routine steps through the keyword table passed to cmkeyw
  1881. ;     and prints all the keywords with the prefix currently in the
  1882. ;     command buffer. If there is no prefix, it issues an error.
  1883. ;
  1884. ;         Input:     Cmptab-     ptr to beginning of table
  1885. ;             Cmsptr- saved buffer pointer
  1886. ;             Cm.ptr- current buffer pointer
  1887. ;
  1888. ;         Output:     List of possible keywords to screen
  1889. ;
  1890. ;         Registers destroyed:     A,X,Y
  1891. ;
  1892.  
  1893. cmktp:    lda   cmptab          ; Get a copy of the pointer
  1894.     sta   cminf2          ;     to the beginning of
  1895.     lda   cmptab+1      ;     the current keyword table
  1896.     sta   cminf2+1      ;         ...
  1897.     ldy   #$00          ; Clear Y
  1898.     sty   cmscrs          ; Clear the 'which half of screen' switch
  1899.     sty   cmwrk3          ; Clear the 'print any keywords?' switch
  1900.     lda   (cminf2),y      ; Get the table length
  1901.     sta   cmwrk1          ;     and save it in a safe place
  1902.     sec          ; Prepare for some subtracting
  1903.     lda   cm.ptr          ; Get difference between the current pointer
  1904.     sbc   cmsptr          ;     and pointer to beginning of keyword
  1905.     sta   cmtlen          ; That is how much we must test
  1906. ;    clc          ; Clear carry
  1907. ;    lda   cminf2          ; Increment the pointer to the table
  1908. ;    adc   #$01          ;         ...
  1909. ;    sta   cminf2          ;         ...
  1910. ;    bcc   cmktp1          ; Need to increment H.O. byte?
  1911.     inc    cminf2        ;[58]
  1912.     bne    cmktp1        ;[58]
  1913.     inc   cminf2+1      ; Yup
  1914. cmktp1: dec   cmwrk1          ; 1 less keyword to do
  1915.     lda   cmwrk1          ; Now...
  1916.     bmi   cmkdon          ; No keywords left, we are done
  1917.     lda   (cminf2),y      ; Get the keyword length
  1918.     sta   cmkyln          ;     and stuff it
  1919. ;    clc          ; Clear carry
  1920. ;    lda   cminf2          ; Increment pointer to table again
  1921. ;    adc   #$01          ;         ...
  1922. ;    sta   cminf2          ;         ...
  1923. ;    bcc   cmktp2          ; Need to up the H.O. byte?
  1924.     inc    cminf2        ;[58]
  1925.     bne    cmktp2        ;[58]
  1926.     inc   cminf2+1      ; Yup
  1927. cmktp2: lda   cmtlen          ; Get test length
  1928.     beq   cmktp3          ; If test length is zero, just print keyword
  1929. ;[84]cmkp21: lda   (cminf2),y      ; Get character from table
  1930. cmkp21: lda   (cmsptr),y      ;[84] Get character from buffer
  1931.     jsr    convuc        ;[84] convert to upper case ascii
  1932. ;[84]    ora   #$80          ; Set the H.O. bit so the compare works
  1933. ;[84]    cmp   (cmsptr),y      ; Compare it to the buffer character
  1934.     cmp   (cminf2),y      ;[84] Compare it to the table
  1935.     bne   cmadk          ; Nope, advance to next keyword
  1936.     iny          ; Up the index
  1937.     cpy   cmtlen          ; Compare with the test length
  1938.     bmi   cmkp21          ; Not yet, do next character
  1939. cmktp3: jsr   cmprk          ; Print the keyword
  1940.  
  1941. cmadk:    inc   cmkyln          ; Adjust cmkyln to include terminator and data
  1942.     inc   cmkyln          ;         ...
  1943.     inc   cmkyln          ;         ...
  1944.     clc          ; Clear the carry
  1945.     lda   cminf2          ; Get the L.O. byte
  1946.     adc   cmkyln          ; Add in the keyword length
  1947.     sta   cminf2          ; Store it away
  1948.     bcc   cmadk2          ; Need to do the H.O. byte?
  1949.     inc   cminf2+1      ; Yup
  1950. cmadk2: ldy   #$00          ; Zero the index
  1951.     jmp   cmktp1          ; Go back to the top of the loop
  1952.  
  1953. cmkdon: lda   cmwrk3          ; See if we printed anything
  1954.     bne   cmkdn2          ; Yup, go exit
  1955.     lda   cmstat          ; Are we parsing switches or keywords?
  1956.     cmp   #cmswi          ;         ...
  1957.     beq   cmkdse          ; The error should be for switches
  1958.     ldx   #cmer03\      ; Nope, get address of error message
  1959.     ldy   #cmer03^      ;         ...
  1960.     jmp   cmkdn1          ; Go print the message now
  1961. cmkdse: ldx   #cmer04\      ; Get address of switch error message
  1962.     ldy   #cmer04^      ;         ...
  1963. ;[79]cmkdn1: jsr   prstr          ; Print error
  1964. ;[79]    jsr   prcrlf          ; Print a crelf
  1965. cmkdn1    jsr    prstrl        ;[79]
  1966. cmkdn2: lda   cmscrs          ; Where did we end up?
  1967.     beq   cmkdn3          ; Beginning of line, good
  1968.     jsr   prcrlf          ; Print a crelf
  1969. cmkdn3: rts          ; Return
  1970.  
  1971. ;
  1972. ;     Cmprk - prints one keyword from the table. Consults the
  1973. ;         cmscrs switch to see which half of the line it
  1974. ;         is going to and acts accordingly.
  1975. ;
  1976. ;         Input:     Cmscrs-     Which half of screen
  1977. ;             Cminf2- Pointer to string to print
  1978. ;
  1979. ;         Output:     print keyword on screen
  1980. ;
  1981. ;         Registers destroyed:     A,X,Y
  1982. ;
  1983.  
  1984. cmprk:    lda   #on          ; Make sure to tell them we printed something
  1985.     sta   cmwrk3          ; Put it back
  1986.     lda   cmstat          ; Get saved parse type
  1987.     cmp   #cmswi          ; Is it a switch we are looking for?
  1988.     bne   cmpr2          ; No...
  1989.     lda   #'/+$80          ;[64] Yes, do not forget slash prefix
  1990. ;[64]    ora   #$80          ; Make sure it is negative ascii
  1991.     jsr   cout          ; Print slash
  1992. cmpr2:    ldx   cminf2          ; L.O. byte of string pointer
  1993.     ldy   cminf2+1      ; H.O. byte of string pointer
  1994.     jsr   prstr          ; Print the keyword
  1995.     lda   cmscrs          ; Where were we?
  1996.     bne   cmprms          ; Mid screen
  1997. ;    jsr   clreol          ; Clear to end of line
  1998.     lda   #$14          ; Advance cursor to middle of screen
  1999.     sta   ch          ;         ...
  2000.     jsr    vtab        ;[58] so it works for 80 col card too
  2001.     jmp   cmprdn          ; We are done
  2002. cmprms: jsr   prcrlf          ; Print a crelf
  2003. cmprdn: lda   cmscrs          ; Flip the switch now
  2004.     eor   #$01          ;         ...
  2005.     sta   cmscrs          ; Stuff it back
  2006.     rts          ; Return
  2007.  
  2008.  
  2009. .SBTTL    Cmswit - try to parse a switch next
  2010.  
  2011. ;
  2012. ;     This routine tries to parse a switch from the command buffer. It
  2013. ;     first looks for the / and then calls cmkeyw to handle the keyword
  2014. ;     lookup.
  2015. ;
  2016. ;         Input:     Cminf1-     Address of keyword table
  2017. ;
  2018. ;         Output:     X-     byte a
  2019. ;             Y-     byte b
  2020. ;
  2021. ;         Registers destroyed:     A,X,Y
  2022. ;
  2023.  
  2024. cmswit: lda   cm.ptr          ; Save old comand line pointer in case the
  2025.     pha          ;     user wants to try another item
  2026.     lda   cm.ptr+1      ;         ...
  2027.     pha          ;         ...
  2028. cmswi0: jsr   cmgtch          ; Go get a character
  2029.     cmp   #$00          ; Action?
  2030.     bmi   cmswi1          ; Yes, process it
  2031.     jmp   cmswi3          ; No, it is a real character
  2032. cmswi1: and   #$7f          ; Turn off the minus
  2033.     cmp   #'?          ; Does the user need help?
  2034.     bne   cmsw12          ; No
  2035.     ora   #$80          ; Set the H.O. bit
  2036.     jsr   cout          ; And print the question mark
  2037.     lda   #$00          ; Clear AC
  2038.     sta   cmaflg          ; Clear Action flag
  2039.     ldx   #cmin02\      ; Low order byte addr of info message
  2040.     ldy   #cmin02^      ; High order byte addr of info message
  2041. ;[79]    jsr   prstr          ; Print the message
  2042. ;[79]    jsr   prcrlf          ; Print a crelf
  2043.     jsr    prstrl        ;[79]
  2044.     jsr   cmktp          ; Any valid entries from keyword table
  2045.     jsr   prcrlf          ; And another crelf
  2046.     lda   #cmfehf          ;[13] Load extra help flag
  2047.     bit   cmprmy          ;[13] Test bit
  2048.     beq   cmsw10          ;[13] No extra help
  2049.     jsr   cmehlp          ;[13] Go give extra help
  2050. cmsw10: ldx   cm.rty          ;[13] Load
  2051.     ldy   cm.rty+1      ;[13]     the address of the prompt
  2052.     jsr   prstr          ; Reprint it
  2053.     lda   #$00          ; Clear AC
  2054.     ldy   #$00          ; Clear Y
  2055.     sta   (cm.ptr),y      ; Stuff a null at the end of the buffer
  2056.     sec          ; Set the carry flag
  2057.     lda   cm.bfp          ; Increment buffer pointer
  2058.     sbc   #$01          ;         ...
  2059.     sta   cm.bfp          ;         ...
  2060.     bcs   cmsw1a          ; Borrow?
  2061.     dec   cm.bfp+1      ; Yup
  2062. cmsw1a: ldx   #cmbuf\          ; L.O. byte addr of command buffer
  2063.     ldy   #cmbuf^          ; H.O. byte
  2064.     jsr   prstr          ; Reprint the command line
  2065.     jmp   repars          ; Go reparse everything
  2066. cmsw12: cmp   #esc          ; Lazy??
  2067.     beq   cmsw2a          ; Yes, try to help
  2068.     jmp   cmswi2          ; No, this is something else
  2069. cmsw2a: lda   #$00          ; Clear AC
  2070.     sta   cmaflg          ; Clear action flag
  2071.     lda   #cmfdff          ;[13] See if there is a default
  2072.     bit   cmprmy          ;[13]         ...
  2073.     beq   cmswnd          ;[13] No help, tell user
  2074.     jmp   cmcpdf          ;[13] Go copy the default
  2075. cmswnd: jsr   bell          ; Yes, it is ambiguous - ring bell
  2076.     sec          ; Set carry
  2077.     lda   cm.bfp          ; Decrement buffer pointer
  2078.     sbc   #$01          ;         ...
  2079.     sta   cm.bfp          ;         ...
  2080.     sta   cm.ptr          ; Make this pointer point there too
  2081.     bcs   cmsw2b          ; No carry to handle
  2082.     dec   cm.bfp+1      ; Do H.O. byte
  2083. cmsw2b: lda   cm.bfp+1      ; Now make H.O. byte match
  2084.     sta   cm.ptr+1      ;         ...
  2085.     dec   cmccnt          ; Decrement the character count
  2086.     jmp   cmswi0          ; Try again
  2087. cmsw2c: lda   #'/          ; Load a slash
  2088.     ora   #$80          ; Make sure this character is negative ascii
  2089.     jsr   cout          ; Print slash
  2090.     clc          ; Clear carry
  2091.     lda   cminf1          ; Set the keyword table pointer
  2092.     adc   #$02          ;     to point at the beginning
  2093.     sta   cmkptr          ;     of the keyword and move it
  2094.     lda   cminf1+1      ;     to cmkptr
  2095. ;[73]    bcc   cmsw2d          ;         ...
  2096.     adc   #$00          ;         ...
  2097. cmsw2d: sta   cmkptr+1      ;         ...
  2098.     ldy   #$00          ; Clear Y
  2099.     sec          ; Set carry
  2100.     lda   cm.bfp          ; Increment the buffer pointer
  2101.     sbc   #$01          ;         ...
  2102.     sta   cm.bfp          ;         ...
  2103.     bcs   cmsw2e          ;         ...
  2104.     dec   cm.bfp+1      ;         ...
  2105. cmsw2e: lda   (cmkptr),y      ; Get next character
  2106. ;    cmp   #$00          ; Done?
  2107.     beq   cmsw13          ; Yes
  2108. ;[73]    tax          ; No, hold on to the byte
  2109. ;[73]    clc          ;     while we increment the pointer
  2110. ;[73]    lda   cmkptr          ; Do L.O. byte
  2111. ;[73]    adc   #$01          ;         ...
  2112. ;[73]    sta   cmkptr          ;         ...
  2113. ;[73]    bcc   cmsw2f          ; And, if neccesary
  2114.     inc    cmkptr        ;[73] do it the easy way
  2115.     bne    cmsw2f        ;[73]
  2116.     inc   cmkptr+1      ;     the H.O. byte as well
  2117. cmsw2f: ;[73]txa          ; Get the data
  2118.     sta   (cm.ptr),y      ; Stuff it in the buffer
  2119. ;[73]    clc          ; Clear carry
  2120. ;[73]    lda   cm.ptr          ; Increment the next character pointer
  2121. ;[73]    adc   #$01          ;         ...
  2122. ;[73]    sta   cm.ptr          ;         ...
  2123. ;[73]    bcc   cmsw2g          ;         ...
  2124.     inc    cm.ptr        ;[73] do it the easy way
  2125.     bne    cmsw2g        ;[73]
  2126.     inc   cm.ptr+1      ;         ...
  2127. cmsw2g: inc   cmccnt          ; Increment the character count
  2128.     jmp   cmsw2e          ; Get next character from table
  2129. cmsw13: inc   cmccnt          ; Increment the character count
  2130.     lda   #$00          ; Clear AC
  2131.     sta   (cm.ptr),y      ; Stuff a null in the buffer
  2132.     ldx   cm.bfp          ; Hold on to this pointer
  2133.     ldy   cm.bfp+1      ;     for later printing of switch
  2134.     clc          ; Clear carry
  2135.     lda   cm.ptr          ; Now make both pointers look like
  2136.     adc   #$01          ;     (cm.ptr)+1
  2137.     sta   cm.ptr          ;         ...
  2138.     sta   cm.bfp          ;         ...
  2139.     bcc   cmsw3a          ;         ...
  2140.     inc   cm.ptr+1      ;         ...
  2141. cmsw3a: lda   cm.ptr+1      ; Copy H.O. byte
  2142.     sta   cm.bfp+1      ;         ...
  2143.     jsr   prstr          ; Now print string with pointer saved earlier
  2144.     ldx   #$01          ; Set up argument
  2145.     jsr   prbl2          ; Print one blank
  2146. cmsw14: ;[73]clc          ; Clear carry
  2147. ;[73]    lda   cmkptr          ; Increment keyword pointer
  2148. ;[73]    adc   #$01          ; Past null terminator
  2149. ;[73]    sta   cmkptr          ;         ...
  2150. ;[73]    bcc   cmsw4a          ;         ...
  2151.     inc    cmkptr        ;[73] do it the easy way
  2152.     bne    cmsw4a        ;[73]
  2153.     inc   cmkptr+1      ;         ...
  2154. cmsw4a: ldy   #$00          ; Clear Y
  2155.     lda   (cmkptr),y      ; Get first data byte
  2156.     tax          ; Put it here
  2157.     iny          ; Up the index
  2158.     lda   (cmkptr),y      ; Get second data byte
  2159.     tay          ; Put that in Y
  2160.     pla          ; Flush the old comand line pointer
  2161.     pla          ;         ...
  2162.     lda   #$00          ;[13] Clear the failure flag
  2163.     sta   cmcffl          ;[13]         ...
  2164.     jmp   rskp          ; And give a skip return
  2165. cmswi2: ldy   #$00          ; Clear Y
  2166.     lda   (cminf1),y      ; Get length of table
  2167.     cmp   #$02          ; Greater than 1
  2168.     bmi   cmsw21          ; No, go fetch data
  2169.     ldx   #cmer01\      ; Yes, fetch pointer to error message
  2170.     ldy   #cmer01^      ;         ...
  2171.     jsr   prstr          ; Print the error
  2172.     jmp   prserr          ; And go handle the parser error
  2173. cmsw21: iny          ; Add one to the index
  2174.     lda   (cminf1),y      ; Get the length of the keyword
  2175.     sta   keylen          ; Save that
  2176.     lda   cminf1+1      ; Copy pointer to table
  2177.     sta   cmkptr+1      ;         ...
  2178.     clc          ; Get set to increment an address
  2179.     lda   cminf1          ; Do L.O. byte last for efficiency
  2180.     adc   keylen          ; Add in the keyword length
  2181.     adc   #$02          ; Now account for table length and terminator
  2182.     sta   cmkptr          ; Save the new pointer
  2183.     bcc   cmsw22          ; If no carry, continue
  2184.     inc   cmkptr+1      ; Adjust H.O. byte
  2185. cmsw22: jmp   cmsw4a          ; Go to load data and skip return
  2186. cmswi3: cmp   #'/          ; Is the real character a slash?
  2187.     beq   cmswi4          ; Yes, go do the rest
  2188.     tax          ; Move the data byte
  2189.     lda   #$00          ; Clear AC
  2190.     pla          ; Fetch back the old comand line pointer
  2191.     sta   cm.ptr+1      ;         ...
  2192.     sta   cmoptr+1      ;[13]         ...
  2193.     pla          ;         ...
  2194.     sta   cm.ptr          ;         ...
  2195.     sta   cmoptr          ;[13]         ...
  2196.     lda   cmccnt          ;[13] Save count in case of <ctrl/H>
  2197.     sta   cmocnt          ;[13]         ...
  2198.     lda   #$ff          ;[13] Set failure flag
  2199.     sta   cmcffl          ;[13]         ...
  2200.     rts          ; Fail - non-skip return
  2201. cmswi4: jsr   cmkeyw          ; Let Keyw do the work for us
  2202.           jmp     cmswi5          ; We had problems, restore comand ptr and ret.
  2203.     pla          ; Flush the old comand pointer
  2204.     pla          ;         ...
  2205.     lda   #$00          ;[13] Reset the failure flag
  2206.     sta   cmcffl          ;[13]         ...
  2207.     jmp   rskp          ; Success - skip return!
  2208. cmswi5: pla          ; Retore the old comand line pointer
  2209.     sta   cm.ptr+1      ;         ...
  2210.     sta   cmoptr+1      ;[13]         ...
  2211.     pla          ;         ...
  2212.     sta   cm.ptr          ;         ...
  2213.     sta   cmoptr          ;[13]         ...
  2214.     lda   cmccnt          ;[13] Save count in case of <ctrl/H>
  2215.     sta   cmocnt          ;[13]         ...
  2216.     lda   #$ff          ;[13] Set failure flag
  2217.     sta   cmcffl          ;[13]         ...
  2218.     rts          ; Now return
  2219.  
  2220.  
  2221. .SBTTL    Cmifil - try to parse an input file spec next
  2222.  
  2223. ;
  2224. ;     This routine attempts to parse an input file spec.
  2225. ;
  2226. ;         Input:     X - Max filname length
  2227. ;
  2228. ;         Output:     Filename parsed is in the atom buffer pointed to
  2229. ;                 by X,Y
  2230. ;
  2231. ;         Registers destroyed:     A,X,Y
  2232. ;
  2233.  
  2234. ;[81]cmifil: inx          ;[13] Increment Max file length for tests
  2235. ;[86]cmifil: lda    #0        ;[81] init wildcard flag
  2236. ;[86]    sta    wcpres        ;[81]
  2237. cmifil            ;[86]
  2238.     inx          ;[13] Increment Max file length for tests
  2239.     stx   cmprmx          ;[13] Maximum filename length
  2240.     lda   cm.ptr          ; Save the old comand line pointer in case
  2241.     pha          ;     the user wants to parse for an
  2242.     lda   cm.ptr+1      ;     alternate item
  2243.     pha          ;         ...
  2244.     lda   #$00          ; Zero the
  2245.     sta   lenabf          ;[13]     length of the atom buffer
  2246. cmifl0: ldy   #$00          ; Zero Y
  2247.     lda   #'          ; Blank the AC
  2248.     ora   #$80          ; Turn on the H.O. bit
  2249. cmifi0: sta   atmbuf,y      ; Now blank the buffer
  2250.     iny          ;         ...
  2251.     cpy   cmprmx          ;[13] Done?
  2252. ;[86]    bpl   cmifi1          ; Yes, start parsing
  2253. ;[86]    jmp   cmifi0          ; No, continue blanking
  2254.     bmi   cmifi0          ;[86] No, continue blanking
  2255. cmifi1: jsr   cmgtch          ; Get a character from command buffer
  2256.     cmp   #$00          ; Is it an action character
  2257.     bmi   cmif10          ;[13] Yes, check it out
  2258.     jmp   cmifi2          ;[13] No, process it as a normal character
  2259. cmif10: and   #$7f          ;[13] Yes, turn off the minus bit
  2260.     cmp   #'?          ; Does the user need help?
  2261.     bne   cmif12          ; Nope
  2262.     ora   #$80          ; Set the H.O. bit
  2263.     jsr   cout          ; And print the question mark
  2264.     ldy   #$00          ; Yes
  2265.     sty   cmaflg          ; Clear the action flag
  2266.     ldx   #cmin03\      ; Now get set to give the 'file spec' message
  2267.     ldy   #cmin03^      ;         ...
  2268. ;[79]    jsr   prstr          ; Print it
  2269. ;[79]    jsr   prcrlf          ; Print a crelf
  2270.     jsr    prstrl        ;[79]
  2271.     lda   #cmfehf          ;[13] Load extra help flag
  2272.     bit   cmprmy          ;[13] Test bit
  2273.     beq   cmifnh          ;[13] No extra help
  2274.     jsr   cmehlp          ;[13] Go give extra help
  2275. cmifnh: ldx   cm.rty          ;[13] Set up to reprint the prompt
  2276.     ldy   cm.rty+1      ;[13]         ...
  2277.     jsr   prstr          ; Do it
  2278.     sec          ; Set the carry flag for subtraction
  2279.     lda   cm.bfp          ; Get the buffer pointer
  2280.     sbc   #$01          ; Decrement it once
  2281.     sta   cm.bfp          ;         ...
  2282.     bcs   cmif11          ; If it's set, we need not do H.O. byte
  2283.     dec   cm.bfp+1      ; Adjust the H.O. byte
  2284. cmif11: dec   cmccnt          ; Decrement the character count
  2285.     ldy   #$00          ; Clear Y
  2286.     lda   #$00          ; Clear AC
  2287.     sta   (cm.bfp),y      ; Stuff a null at the end of the command buffer
  2288.     ldx   #cmbuf\          ; Now get the address of the command buffer
  2289.     ldy   #cmbuf^          ;         ...
  2290.     jsr   prstr          ; Reprint the command line
  2291.     jmp   cmifi1          ; Go back and continue
  2292. cmif12: cmp   #esc          ; Got an escape?
  2293.     bne   cmif13          ; No
  2294.     lda   #$00          ; Yup, clear the action flag
  2295.     sta   cmaflg          ;         ...
  2296.     lda   #cmfdff          ;[13] Load default-present flag
  2297.     bit   cmprmy          ;[13] Test bit
  2298.     beq   cmifnd          ;[13] No default
  2299.     lda   lenabf          ;[13] Now check if user typed anything
  2300.     bne   cmifnd          ;[13] Yup, can't use default
  2301.     jmp   cmcpdf          ;[13] Go copy the default
  2302. cmifnd: jsr   bell          ; Escape does not work here, ring the bell
  2303.     sec          ; Set carry for subtraction
  2304.     lda   cm.bfp          ; Decrement the buffer pointer
  2305.     sbc   #$01          ;     once
  2306.     sta   cm.bfp          ;         ...
  2307.     sta   cm.ptr          ; Make both pointers look at the same spot
  2308.     lda   cm.bfp+1      ;         ...
  2309.     sbc   #$00          ; H.O. byte adjustment
  2310.     sta   cm.bfp+1      ;         ...
  2311.     sta   cm.ptr+1      ;         ...
  2312.     dec   cmccnt          ; Decrement the character count
  2313.     jmp   repars          ;     and go reparse everything
  2314. cmif13: lda   lenabf          ;[13] Get the length of the buffer
  2315. ;    cmp   #$00          ; Is it zero?
  2316.     bne   cmif14          ; No, continue
  2317.     jmp   cmifi9          ; Yes, this is not good
  2318. cmif14: cmp   cmprmx          ;[13] Are we over the maximum file length?
  2319. ;[86]    bmi   cmif15          ; Not quite yet
  2320. ;[86]    jmp   cmifi9          ; Yes, blow up
  2321.     bpl   cmifi9          ;[86] Yes, blow up
  2322. cmif15: ldy   lenabf          ;[13] Get the filename length
  2323.     lda   #nul          ;     and stuff a null at that point
  2324.     sta   atmbuf,y      ;[13]         ...
  2325.     pla          ; Flush the old comand line pointer
  2326.     pla          ;         ...
  2327.     ldx   #atmbuf\      ;[13] Set up the atom buffer address
  2328.     ldy   #atmbuf^      ;[13]         ...
  2329.     lda   #$00          ;[13] Reset the failure flag
  2330.     sta   cmcffl          ;[13]         ...
  2331.     lda   lenabf          ;[13] Load length into AC to be passed back
  2332.     jmp   rskp          ; No, we are successful
  2333. cmifi2: cmp   #sp          ;[13] Bad character?         
  2334.     bmi   cmifi9          ; Yes, blow up
  2335.     cmp   #del          ;[13]         ...
  2336.     bpl   cmifi9          ; This is bad, punt
  2337. ;[81]    cmp   #'a          ;[13] Is character a lower-case alpha?
  2338. ;[81]    bmi   cmifi8          ;[13] No, don't capitalize
  2339. ;[81]    cmp   #<'z+1>          ;[13]         ...
  2340. ;[81]    bpl   cmifi8          ;[13]         ...
  2341. ;[81]    and   #$5f          ; Capitalize
  2342.     jsr    convuc        ;[81] convert to upper case
  2343. cmifi8: ldy   lenabf          ;[13] Set up length of buffer in Y
  2344. ;[86]    cmp    #wcmult        ;[81]
  2345. ;[86]    beq    cmif85        ;[81] wc present
  2346. ;[86]    cmp    #wcsing        ;[81]
  2347. ;[86]    bne    cmif86        ;[81] not a single ch wc
  2348. ;[86]cmif85    sta    wcpres        ;[81] got one
  2349. ;[86]cmif86                ;[81]
  2350.     sta   atmbuf,y      ;[13] Stuff character in FCB
  2351.     inc   lenabf          ;[13] Increment the length of the name
  2352.     jmp   cmifi1          ; Go back for next character
  2353. cmifi9: pla          ; Restore the old comand line pointer
  2354.     sta   cm.ptr+1      ;     in case the user wants to parse
  2355.     sta   cmoptr+1      ;[13]         ...
  2356.     pla          ;     for something else
  2357.     sta   cm.ptr          ;         ...
  2358.     sta   cmoptr          ;[13]         ...
  2359.     lda   cmccnt          ;[13] Save count in case of <ctrl/H>
  2360.     sta   cmocnt          ;[13]         ...
  2361.     lda   #$ff          ;[13] Set failure flag
  2362.     sta   cmcffl          ;[13]         ...
  2363.     rts
  2364.  
  2365.  
  2366. .SBTTL    Cmofil - try to parse an output file spec
  2367.  
  2368. ;
  2369. ;     This routine attempts to parse an output file spec from the
  2370. ;     command buffer.
  2371. ;
  2372. ;         Input:     cminf1-     Pointer to FCB
  2373. ;
  2374. ;         Output:
  2375. ;
  2376. ;         Registers destroyed:
  2377. ;
  2378.  
  2379. cmofil: jmp   cmifil          ; Same as parsing input file spec for now
  2380.  
  2381.  
  2382. .SBTTL    Cminum - Try to parse an integer number
  2383.  
  2384. ;
  2385. ;     This routine tries to parse an integer number in the base
  2386. ;     specified. It will return a 16-bit number in cmintg.
  2387. ;     Cmintg is formatted H.O. byte first!
  2388. ;
  2389. ;         Input:     X-     Base of integer (2<=x<=16)
  2390. ;
  2391. ;         Output:     X - L.O. byte of 16-bit integer parsed
  2392. ;             Y - H.O. byte of 16-bit integer parsed
  2393. ;
  2394. ;         Registers destroyed:     A,X,Y
  2395. ;
  2396.  
  2397. cminum: lda   cm.ptr          ; Save the old comand line pointer
  2398.     pha          ;         ...
  2399.     lda   cm.ptr+1      ;         ...
  2400.     pha          ;         ...
  2401.     cpx   #$11          ; Are we within the proper range?
  2402.     bmi   cmin1          ; If so, check high range
  2403.     jmp   cmine1          ; No, tell them about it
  2404. cmin1:    cpx   #$02          ; Too small of a base??
  2405.     bpl   cmin2          ; No, continue
  2406.     jmp   cmine1          ; Base too small, tell them about it
  2407. cmin2:    stx   cmbase          ; The base requested is good, store it
  2408.     lda   #$00          ; Clear AC
  2409.     sta   cmmres          ;     and initialize these areas
  2410.     sta   cmmres+1      ;         ...
  2411.     sta   cmmres+2      ;         ...
  2412.     sta   cmmres+3      ;         ...
  2413.     sta   cmintg          ;         ...
  2414.     sta   cmintg+1      ;         ...
  2415.     sta   cmintg+2      ;         ...
  2416.     sta   cmintg+3      ;         ...
  2417. cminm1: jsr   cmgtch          ; Get next character from command buffer
  2418.     cmp   #$00          ; Is this an action character
  2419.     bmi   cmin1a          ; Yes, handle it
  2420.     jmp   cminm4          ; No, look for a digit
  2421. cmin1a: and   #$7f          ; It is, turn off the H.O. bit
  2422.     cmp   #esc          ; Is it an escape?
  2423.     bne   cminm2          ; No, try something else
  2424.     lda   #cmfdff          ;[13] Load default-present flag
  2425.     bit   cmprmy          ;[13] Test bit
  2426.     beq   cminnd          ;[13] No default
  2427.     lda   cmmres          ;[13] Check if user typed anything significant
  2428.     ora   cmmres+1      ;[13]         ...
  2429.     bne   cminnd          ;[13] Yup, can't use default
  2430.     jmp   cmcpdf          ;[13] Go copy the default
  2431. cminnd: jsr   bell          ; Yes, but escape is not allowed, ring bell
  2432.     lda   #$00          ; Zero
  2433.     sta   cmaflg          ;     the action flag
  2434.     sec          ; Set the carry flag for subtraction
  2435.     lda   cm.bfp          ; Get the command buffer pointer
  2436.     sbc   #$01          ; Decrement it once
  2437.     sta   cm.bfp          ; Store it away
  2438.     sta   cm.ptr          ; Make this pointer look like it also
  2439.     bcs   cmin11          ; If carry set don't adjust H.O. byte
  2440.     dec   cm.bfp+1      ; Adjust the H.O. byte
  2441. cmin11: lda   cm.bfp+1      ; Move a copy of this H.O. byte
  2442.     sta   cm.ptr+1      ;     to this pointer
  2443.     dec   cmccnt          ; Decrement the character count
  2444.     jmp   cminm1          ; Go try for another character
  2445. cminm2: cmp   #'?          ; Does the user need help?
  2446.     bne   cminm3          ; If not, back up the pointer and accept
  2447.     ora   #$80          ; Set the H.O. bit
  2448.     jsr   cout          ; And print the question mark
  2449.     ldx   #cmin05\      ; Set up the pointer to info message to be
  2450.     ldy   #cmin05^      ;     printed
  2451.     jsr   prstr          ; Print the text of the message
  2452.     lda   cmbase          ; Get the base of the integer number
  2453.     cmp   #$0a          ; Is it greater than decimal 10?
  2454.     bmi   cmin21          ; No, just print the L.O. digit
  2455.     clc          ; Clear the carry
  2456.     lda   #$01          ; Print the H.O. digit as a 1
  2457.     adc   #$b0          ; Make it printable
  2458.     jsr   cout          ; Print the '1'
  2459.     lda   cmbase          ; Get the base back
  2460.     sec          ; Set the carry flag for subtraction
  2461.     sbc   #$0a          ; Subtract off decimal 10
  2462. cmin21: clc          ; Clear carry for addition
  2463.     adc   #$b0          ; Make it printable
  2464. ;[79]    jsr   cout          ; Print the digit
  2465. ;[79]    jsr   prcrlf          ; Print a crelf
  2466.     jsr   coutl          ;[79] Print the digit & crlf
  2467.     lda   #cmfehf          ;[13] Load extra help flag
  2468.     bit   cmprmy          ;[13] Test bit
  2469.     beq   cminnh          ;[13] No extra help
  2470.     jsr   cmehlp          ;[13] Go give extra help
  2471. cminnh: ldx   cm.rty          ;[13] Set up pointer so we can print the prompt
  2472.     ldy   cm.rty+1      ;[13]         ...
  2473.     jsr   prstr          ; Reprint the prompt
  2474.     lda   #$00          ; Clear AC
  2475.     ldy   #$00          ; Clear Y
  2476.     sta   (cm.ptr),y      ; Drop a null at the end of the command buffer
  2477.     sec          ; Set the carry flag for subtraction
  2478.     lda   cm.bfp          ; Get the L.O. byte of the address
  2479.     sbc   #$01          ; Decrement it once
  2480.     sta   cm.bfp          ; Store it back
  2481.     bcs   cmin22          ; If carry set, don't adjust H.O. byte
  2482.     dec   cm.bfp+1      ; Adjust H.O. byte
  2483. cmin22: ldx   #cmbuf\          ; Get the address of the command buffer
  2484.     ldy   #cmbuf^          ;         ...
  2485.     jsr   prstr          ; Reprint the command buffer
  2486.     lda   #$00          ; Clear the
  2487.     sta   cmaflg          ;     action flag
  2488.     jmp   repars          ; Reparse everything
  2489. cminm3: ldx   cmmres          ;[13] Move L.O. byte
  2490.     ldy   cmmres+1      ;[13] Move H.O. byte
  2491.     pla          ; Flush the old comand line pointer
  2492.     pla          ;         ...
  2493.     lda   #$00          ;[13] Reset the failure flag
  2494.     sta   cmcffl          ;[13]         ...
  2495.     jmp   rskp          ;
  2496. cminm4: cmp   #$40          ; Is this a letter?
  2497.     bmi   cmin41          ; Nope, skip this stuff
  2498.     and #$df        ;[75] make it upper case
  2499.     sec          ; It is, bring it into the proper range
  2500.     sbc   #$07          ;         ...
  2501. cmin41: sec          ; Set carry for subtraction
  2502.     sbc   #$30          ; Make the number unprintable
  2503. ;    cmp   #$00          ; Is the number in the proper range?
  2504.     bmi   cminm5          ; No, give an error
  2505.     cmp   cmbase          ;         ...
  2506.     bmi   cminm6          ; This number is good
  2507. cminm5: pla          ; Restore the old comand line pointer
  2508.     sta   cm.ptr+1      ;         ...
  2509.     sta   cmoptr+1      ;[13]         ...
  2510.     pla          ;         ...
  2511.     sta   cm.ptr          ;         ...
  2512.     sta   cmoptr          ;[13]         ...
  2513.     lda   cmccnt          ;[13] Save count in case of <ctrl/H>
  2514.     sta   cmocnt          ;[13]         ...
  2515.     lda   #$ff          ;[13] Set failure flag
  2516.     sta   cmcffl          ;[13]         ...
  2517.     rts          ; Then return
  2518. cminm6: pha          ; Save the number to add in
  2519.     lda    #0        ;[87] msb
  2520.     pha            ;[87]
  2521.     lda   cmmres+1      ; Move the number to multiply
  2522.     pha          ;     onto the stack for
  2523.     lda   cmmres          ;     call to mul16
  2524.     pha          ;         ...
  2525.     lda   #$00          ; Move base onto the stack (H.O. byte first)
  2526.     pha          ;[87] msb
  2527.     pha          ;         ...
  2528.     lda   cmbase          ;         ...
  2529.     pha          ;         ...
  2530. ;[87]    jsr   mul16          ; Multiply this out
  2531.     jsr   mul24          ;[87] Multiply this out
  2532.     pla          ; Get L.O. byte of product
  2533.     sta   cmmres          ; Store it for now
  2534.     pla          ; Get H.O. byte of product
  2535.     sta   cmmres+1      ; Store that too
  2536.     pla        ;[87] msb thro away
  2537.     pla          ; Get the digit to add in
  2538.     clc          ; Clear the carry for the add
  2539.     adc   cmmres          ; Add in L.O. byte of result
  2540.     sta   cmmres          ; Store it back
  2541.     lda   cmmres+1      ; Get the H.O. byte
  2542.     adc   #$00          ; Add in the carry
  2543.     sta   cmmres+1      ; Save the H.O. byte
  2544.     bcs   cmine2          ; Wrong, we overflowed
  2545.     jmp   cminm1          ; Try for the next digit
  2546. cmine1: ldx   #cmer06\      ; Get the address of the error message
  2547.     ldy   #cmer06^      ;         ...
  2548.     jsr   prstr          ; Print the error
  2549.     jmp   prserr          ; Handle the parse error
  2550. cmine2: ldx   #cmer07\      ; Get the address of the error message
  2551.     ldy   #cmer07^      ;         ...
  2552.     jsr   prstr          ; Print the error message
  2553.     jmp   prserr          ; Handle the error
  2554.  
  2555.  
  2556. .SBTTL    Cmflot - Try to parse a floating point number
  2557.  
  2558. ;
  2559. ;     This routine tries to parse a floating point number in the
  2560. ;     format:
  2561. ;         sd-d.d-dEsddd
  2562. ;
  2563. ;         s is an optional sign bit
  2564. ;         d is a decimal digit
  2565. ;         E is the letter 'E'
  2566. ;         . is a decimal point
  2567. ;
  2568. ;         Input:     
  2569. ;
  2570. ;         Output:     Cmfltp-     6 byte floating point number
  2571. ;                 4.5 byte signed mantissa
  2572. ;                 1.5 byte signed exponent
  2573. ;
  2574. ;             s b........b  s  e.....e
  2575. ;         bit     0 1       35 36 37    47   
  2576. ;
  2577. ;         Registers destroyed:     A,X,Y
  2578. ;
  2579.  
  2580. cmflot: rts
  2581.  
  2582. .SBTTL    Cmunqs - Try to parse an unquoted string
  2583.  
  2584. ;
  2585. ;     This routine tries to parse an unquoted string terminating
  2586. ;     with one of the break characters in brkwrd.
  2587. ;
  2588. ;         Input:     
  2589. ;
  2590. ;         Output:     X - L.O. byte address of ASCII string
  2591. ;             Y - H.O. byte address of ASCII string
  2592. ;             A - Length of string parsed
  2593. ;
  2594. ;         Registers destroyed:     A,X,Y
  2595. ;
  2596.  
  2597. ;[86]cmunqs: lda   cm.ptr          ;[13] Save the command buffer pointer
  2598. cmunqs:                ;[86]
  2599.     lda    #0        ;[86] init wildcard flag
  2600.     sta    wcpres        ;[86]
  2601.     lda   cm.ptr          ;[86] Save the command buffer pointer
  2602.     pha          ;[13]         ...
  2603.     lda   cm.ptr+1      ;[13]         ...
  2604.     pha          ;[13]         ...
  2605.     lda   #$00          ;[13] Zero length of Atom buffer
  2606.     sta   lenabf          ;[13]         ...
  2607. cmunq1: jsr   cmgtch          ;[13] Get a character
  2608.     jsr   chkbrk          ;[13] Is it one of the break characters?
  2609.           jmp     cmunq3          ;[13] Yes, handle that condition
  2610.     cmp   #$00          ;[13] No, is it an action character?
  2611.     bpl   cmunq2          ;[13] No, handle it as normal text
  2612.     and   #$7f          ;[13] We don't need the H.O. bit
  2613.     cmp   #'?          ;[13] Does the user need help?
  2614.     bne   cmun13          ;[13] Nope, try next possibility
  2615.     ora   #$80          ;[13] Have to print this, set H.O. bit
  2616.     jsr   cout          ;[13] Print '?'
  2617.     ldy   #$00          ;[13] Zero the action flag
  2618.     sty   cmaflg          ;[13]         ...
  2619.     ldx   #cmin06\      ;[13] Get the help message
  2620.     ldy   #cmin06^      ;[13]         ...
  2621. ;[79]    jsr   prstr          ;[13]     and print it.
  2622. ;[79]    jsr   prcrlf          ;[13] Print a crelf after it
  2623.     jsr    prstrl        ;[79]
  2624.     lda   #cmfehf          ;[13] Check for extra help.
  2625.     bit   cmprmy          ;[13]         ...
  2626.     beq   cmun11          ;[13] If no help, continue
  2627.     jsr   cmehlp          ;[13] Process extra help
  2628. cmun11: ldx   cm.rty          ;[13] Go reprint prompt
  2629.     ldy   cm.rty+1      ;[13]         ...
  2630.     jsr   prstr          ;[13]         ...
  2631.     sec          ;[13] Adjust buffer pointer
  2632.     lda   cm.bfp          ;[13]         ...
  2633.     sbc   #$01          ;[13]         ...
  2634.     sta   cm.bfp          ;[13]         ...
  2635.     bcs   cmun12          ;[13]         ...
  2636.     dec   cm.bfp+1      ;[13] Adjust H.O. byte
  2637. cmun12: dec   cmccnt          ;[13] Correct character count
  2638.     ldy   #$00          ;[13] Stuff a null at end of usable buffer
  2639.     lda   #$00          ;[13]         ...
  2640.     sta   (cm.bfp),y      ;[13]         ...
  2641.     ldx   #cmbuf\          ;[13] Reprint command line
  2642.     ldy   #cmbuf^          ;[13]         ...
  2643.     jsr   prstr          ;[13]         ...
  2644.     jmp   cmunq1          ;[13] Go back for more characters
  2645. cmun13: cmp   #esc          ;[13] Did the user type <esc>?
  2646.     bne   cmunq2          ;[13] No, just stuff the character and cont.
  2647.     lda   #$00          ;[13] Clear the action flag
  2648.     sta   cmaflg          ;[13]         ...
  2649.     lda   #cmfdff          ;[13] Check if there is a default value
  2650.     bit   cmprmy          ;[13]         ...
  2651.     beq   cmun14          ;[13] If not, the <esc> loses
  2652.     lda   lenabf          ;[13] Ok, there is a default, but if
  2653.     bne   cmun14          ;[13]     something has been typed, <esc> loses
  2654.     jmp   cmcpdf          ;[13] Go copy default and reparse
  2655. cmun14: jsr   bell          ;[13] Feep at user
  2656.     sec          ;[13]     and reset the buffer pointer
  2657.     lda   cm.bfp          ;[13]         ...
  2658.     sbc   #$01          ;[13]         ...
  2659.     sta   cm.bfp          ;[13]         ...
  2660.     sta   cm.ptr          ;[13]         ...
  2661.     lda   cm.bfp+1      ;[13]         ...
  2662.     sbc   #$00          ;[13]         ...
  2663.     sta   cm.bfp+1      ;[13]         ...
  2664.     sta   cm.ptr+1      ;[13]         ...
  2665.     dec   cmccnt          ;[13] Adjust the character count
  2666.     jmp   repars          ;[13]     and reparse the command line
  2667. cmunq2: ldy   lenabf          ;[13] Fetch where we are in atmbuf
  2668.     jsr    convuc        ;[86] now for files we need upper case
  2669.     cmp    #wcmult        ;[86]
  2670.     beq    cmif85        ;[86] wc present
  2671.     cmp    #wcsing        ;[86]
  2672.     bne    cmif86        ;[86] not a single ch wc
  2673. cmif85    sta    wcpres        ;[86] got one
  2674. cmif86                ;[86]
  2675.     sta   atmbuf,y      ;[13]     and store our character there
  2676.     inc   lenabf          ;[13] Reflect increased length
  2677.     jmp   cmunq1          ;[13] Go back for more characters
  2678. cmunq3: lda   lenabf          ;[13] Get the length
  2679.     beq   cmunqf          ;[13] If we parsed a null string, fail
  2680.     pla          ;[13] Flush old command line pointer
  2681.     pla          ;[13]         ...
  2682.     ldx   #atmbuf\      ;[13] Now, set up the return parameter
  2683.     ldy   #atmbuf^      ;[13]         ...
  2684.     lda   #$00          ;[13] Reset the failure flag
  2685.     sta   cmcffl          ;[13]         ...
  2686.     lda   lenabf          ;[13] Set up atom length
  2687.     jmp   rskp          ;[13] Return
  2688. cmunqf: pla          ;[13] Restore old command line pointer
  2689.     sta   cm.ptr+1      ;         ...
  2690.     sta   cmoptr+1      ;[13]         ...
  2691.     pla          ;         ...
  2692.     sta   cm.ptr          ;         ...
  2693.     sta   cmoptr          ;[13]         ...
  2694.     lda   cmccnt          ;[13] Save count in case of <ctrl/H>
  2695.     sta   cmocnt          ;[13]         ...
  2696.     lda   #$ff          ;[13] Set failure flag
  2697.     sta   cmcffl          ;[13]         ...
  2698.     rts          ;[13] Return
  2699.  
  2700. .SBTTL    Cmtokn - Try to parse for a single character token
  2701.  
  2702. ;
  2703. ;     This routine tries to parse for the character in the X-register.
  2704. ;
  2705. ;         Input:     X - Character to be parsed     
  2706. ;
  2707. ;         Output: +1 - failed to find character
  2708. ;             +4 - success, found character
  2709. ;
  2710. ;         Registers destroyed:     A,X,Y
  2711. ;
  2712.  
  2713. cmtokn: lda   cm.ptr          ;[13] First, save the old command pointer
  2714.     pha          ;[13]     on the stack
  2715.     lda   cm.ptr+1      ;[13]         ...
  2716.     pha          ;[13]         ...
  2717. cmtk0:    jsr   cmgtch          ;[13] Fetch the next character
  2718.     bpl   cmtk3          ;[13] Not an action character
  2719.     and   #$7f          ;[13] It's an action character
  2720.     cmp   #esc          ;[13] User trying to be lazy?
  2721.     bne   cmtk2          ;[13] Nope, tyr next option
  2722.     jsr   bell          ;[13] Yes, well, he's not allowed to be lazy
  2723.     lda   #$00          ;[13] Clear the action flag
  2724.     sta   cmaflg          ;[13]         ...
  2725.     sec          ;[13] Adjust the buffer pointer back once
  2726.     lda   cm.bfp          ;[13]         ...
  2727.     sbc   #$01          ;[13]         ...
  2728.     sta   cm.bfp          ;[13]         ...
  2729.     sta   cm.ptr          ;[13] Copy it into command pointer
  2730.     bcs   cmtk1          ;[13] Need to adjust H.O. byte?
  2731.     dec   cm.bfp+1      ;[13] Yes, do it
  2732. cmtk1:    lda   cm.bfp+1      ;[13] Copy it to command pointer
  2733.     sta   cm.ptr+1      ;[13]         ...
  2734.     dec   cmccnt          ;[13] Adjust the character count
  2735.     jmp   cmtk0          ;[13]     and try again
  2736. cmtk2:    cmp   #'?          ;[13] User need help?
  2737.     bne   cmtk4          ;[13] No, go fail
  2738.     ora   #$80          ;[13] Yes, set bit to print char
  2739.     jsr   cout          ;[13] Print it
  2740.     ldx   #cmin07\      ;[13] Point to the information message
  2741.     ldy   #cmin07^      ;[13]         ...
  2742.     jsr   prstr          ;[13]     and print it
  2743.     lda   #hdquot          ;[13] Print the character we are looking for
  2744.     jsr   cout          ;[13]     in between double quotes
  2745.     lda   cmprmx          ;[13]         ...
  2746.     ora   #$80          ;[13]         ...
  2747.     jsr   cout          ;[13]         ...
  2748.     lda   #hdquot          ;[13]         ...
  2749. ;[79]    jsr   cout          ;[13]         ...
  2750. ;[79]    jsr   prcrlf          ;[13] End it with a crelf
  2751.     jsr    coutl        ;[79] print ch & crlf
  2752.     lda   #cmfehf          ;[13] Load extra help flag
  2753.     bit   cmprmy          ;[13] Test bit
  2754.     beq   cmtknh          ;[13] No extra help
  2755.     jsr   cmehlp          ;[13] Go give extra help
  2756. cmtknh: ldx   cm.rty          ;[13] Point to prompt
  2757.     ldy   cm.rty+1      ;[13]         ...
  2758.     jsr   prstr          ;[13]     and print it
  2759.     sec          ;[13] Adjust the buffer pointer back one
  2760.     lda   cm.bfp          ;[13]         ...
  2761.     sbc   #$01          ;[13]         ...
  2762.     sta   cm.bfp          ;[13]         ...
  2763.     lda   cm.bfp+1      ;[13]         ...
  2764.     sbc   #$00          ;[13]         ...
  2765.     sta   cm.bfp+1      ;[13]         ...
  2766.     lda   #$00          ;[13] Stuff a null at the end of the buffer
  2767.     ldy   #$00          ;[13]         ...
  2768.     sta   (cm.ptr),y      ;[13]         ...
  2769.     ldx   #cmbuf\          ;[13] Point to command buffer
  2770.     ldy   #cmbuf^          ;[13]         ...
  2771.     jsr   prstr          ;[13]     and reprint it
  2772.     lda   #$00          ;[13] Clear action flag
  2773.     sta   cmaflg          ;[13]         ...
  2774.     jmp   repars          ;[13]     and go reparse
  2775. cmtk3:    cmp   cmprmx          ;[13] Ok, this either is or is not the
  2776.     bne   cmtk4          ;[13]     char we want. If not, go fail.
  2777.     pla          ;[13] It is, flush the old address
  2778.     pla          ;[13]         ...
  2779.     lda   #$00          ;[13] Reset the failure flag
  2780.     sta   cmcffl          ;[13]         ...
  2781.     jmp   rskp          ;[13]     and skip return
  2782. cmtk4:    pla          ;[13] Restore old pointer
  2783.     sta   cm.ptr+1      ;[13]         ...
  2784.     sta   cmoptr+1      ;[13]         ...
  2785.     pla          ;[13]         ...
  2786.     sta   cm.ptr          ;[13]         ...
  2787.     sta   cmoptr          ;[13]         ...
  2788.     lda   cmccnt          ;[13] Save the count for <ctrl/H>
  2789.     sta   cmocnt          ;[13]         ...
  2790.     lda   #$ff          ;[13] Set failure flag
  2791.     sta   cmcffl          ;[13]         ...
  2792.     rts          ;[13] Return
  2793.  
  2794. .SBTTL    Cminbf - read characters from keyboard
  2795.  
  2796. ;
  2797. ;     This routine reads characters from the keyboard until
  2798. ;     an action or editing character comes up.
  2799. ;
  2800. ;         Input:
  2801. ;
  2802. ;         Output:         Cmbuf- characters from keyboard
  2803. ;
  2804. ;         Registers destroyed:
  2805. ;
  2806.  
  2807. cminbf: pha          ; Save the AC
  2808.     txa          ;     and X
  2809.     pha          ;         ...
  2810.     tya          ;     and Y
  2811.     pha          ;         ...
  2812.     php          ; Save the processor status
  2813.     ldy   #$00          ; Clear Y
  2814.     lda   cmaflg          ; Fetch the action flag
  2815.     beq   cminb1          ; Nope
  2816.     jmp   cminb9          ; Yes, so leave
  2817. cminb1: inc   cmccnt          ; Up the character count once
  2818.     bne   cminb0          ;[23] If we are overflowing the command buffer
  2819.     jsr   bell          ;[23]     Feep at the user and do Prserr
  2820.     dec   cmccnt          ;[23] Make sure this doesn't happen again
  2821.     jmp   prserr          ;[23]     for same string
  2822. cminb0: jsr   rdkey          ; Get next character from keyboard
  2823.     ldy    cmescf        ;[87] are we escaping this ch?
  2824.     beq    cminba        ;[87] no
  2825.     ldy    #0        ;[87] stuff it asis
  2826.     sty    cmescf        ;[87] only once
  2827.     and    #$7f        ;[87] hope this hides it
  2828.     sta    (cm.bfp),y    ;[87]
  2829.     inc    cm.bfp        ;[87] and tattle
  2830.     bne    .+4        ;[87] hate this & its page 0
  2831.     inc    cm.bfp+1    ;[87]
  2832.     jmp    cmnb72        ;[87] print it & next
  2833. cminba                ;[87]
  2834.     cmp   #hctrlh          ;[13] User want a retry?
  2835.     bne   cmnbnh          ;[13] Nope, go on
  2836.     ldx   cmccnt          ;[13] Check character count
  2837.     cpx   #$01          ;[13] Is this the first character?
  2838.     bne   cmnbnh          ;[13] Nope, can't help him
  2839.     ldx   cmcffl          ;[13] Did the previous command fail?
  2840.     bpl   cmnbnh          ;[13] No, we can't reparse a good command
  2841.     lda   cmoptr          ;[13] Ok, get the old pointer and set up
  2842.     sta   cm.ptr          ;[13]     the old command line again
  2843.     sta   cm.bfp          ;[13]         ...
  2844.     lda   cmoptr+1      ;[13]         ...
  2845.     sta   cm.ptr+1      ;[13]         ...
  2846.     sta   cm.bfp+1      ;[13]         ...
  2847.     lda   cmocnt          ;[13] Restore the character count
  2848.     sta   cmccnt          ;[13]         ...
  2849.     lda   #$00          ;[13] Zero this so we can safely use the
  2850.     sta   cmwrk2          ;[13]     code that reprints a line after ^W
  2851.     jmp   cmnbna          ;[13] Go reprint the line
  2852. cmnbnh: ldy   #$00          ;
  2853.     cmp    #'\+$80        ;[87] escape ch?
  2854.     bne    cmnb10        ;[87] no
  2855.     dec    cmccnt        ;[87] yup
  2856.     sta    cmescf        ;[87] set the flag
  2857.     jmp    cmnb72        ;[87] print it but thats all
  2858. cmnb10                ;[87]
  2859.     sta   (cm.bfp),y      ; Stuff character in buffer
  2860.     inc   cm.bfp          ; Increment the buffer pointer
  2861.     bne   cmnb11          ; Carry?
  2862.     inc   cm.bfp+1      ; Yup, do H.O. byte
  2863. cmnb11
  2864.     cmp   #hctrlu          ; Is it a ^U
  2865.     bne   cminb2          ; Nope
  2866. cmnb12: jsr   scrl3          ; Yes, clear the whole line
  2867.     ldx   cm.rty          ;[13] Get L.O. byte addr.
  2868.     ldy   cm.rty+1      ;[13]     and H.O. byte addr of prompt
  2869.     lda   #$00          ; Reset cursor position to beginning of line
  2870.     sta   ch          ;         ...
  2871.     jsr    vtab        ;[58] position 80 col too
  2872.     jsr   prstr          ; Reprint the prompt
  2873. ;[49]     jsr     clreol          ; Get rid of garbage on that line
  2874.     lda   #cmbuf\          ; Now reset the buffer pointer
  2875.     sta   cm.bfp          ;     to the beginning of the buffer
  2876.     lda   #cmbuf^          ;         ...
  2877.     sta   cm.bfp+1      ;         ...
  2878.     lda   #$00          ; Clear AC
  2879.     sta   cmccnt          ; Clear the character count
  2880.     jmp   repars          ; Reparse new line from beginning
  2881. cminb2: cmp   #hbs          ; Is it a <bs>?
  2882.     beq   cminb3          ; Yes
  2883.     cmp   #hdel          ; A <del>?
  2884.     bne   cminb4          ; No
  2885. cminb3: jsr   bsp          ; [49] Backup cursor horizontal position
  2886.     jsr   clreol          ; Now clear from there to end of line
  2887.     dec   cmccnt          ; Decrement the character count
  2888.     dec   cmccnt          ;     twice.
  2889. ;    lda   cmccnt          ; Now fetch it
  2890. ;    cmp   #$00          ; Did we back up too far??
  2891.     bpl   cmnb32          ; No, go on
  2892.     jsr   bell          ; Yes, ring the bell and
  2893.     jmp   cmnb12          ;     go reprint prompt and reparse line
  2894. cmnb32: sec          ; Set the carry
  2895.     lda   cm.bfp          ; Now decrement the buffer pointer
  2896.     sbc   #$02          ;     twice.
  2897.     sta   cm.bfp          ; Store it
  2898.     bcs   cmnb33          ;         ...
  2899.     dec   cm.bfp+1      ; Decrement to account for the borrow
  2900. cmnb33: jmp   repars          ; Time to reparse everything
  2901. cminb4: cmp   #hctrlw          ;[13] Delete a word?
  2902.     beq   cmnb41          ;[13] Yes, go take care of that
  2903.     jmp   cmib40          ;[13] Nope, continue
  2904. cmnb41: lda   #$03          ;[13] Set up negative offset count
  2905.     sta   cmwrk2          ;[13]         ...
  2906.     sec          ;[13] Set up to adjust buffer pointer
  2907.     lda   cm.bfp          ;[13] Get the L.O. byte
  2908.     sbc   #$03          ;[13] Adjust pointer down by 3
  2909.     sta   cm.bfp          ;[13] Store it back
  2910.     bcs   cmnb42          ;[13] Don't worry about H.O. byte
  2911.     dec   cm.bfp+1      ;[13] Adjust H.O. byte also
  2912. cmnb42: lda   cmwrk2          ;[13] First, check the count
  2913.     cmp   cmccnt          ;[13] Cmwrk2 > cmccnt?
  2914.     bmi   cmints          ;[13] No, go test characters
  2915.     jmp   cmnb12          ;[13] Yes, go clear the whole line
  2916. cmints: ldy   #$00          ;[13] Zero Y
  2917.     lda   (cm.bfp),y      ;[13] Get previous character
  2918.     cmp   #hlf          ;[13] Start to test ranges...
  2919.     bpl   cmits1          ;[13]     Between <lf> and <cr>?
  2920.     jmp   cminac          ;[13] No, not in range at all
  2921. cmits1: cmp   #hcr+1          ;[13]         ...
  2922.     bmi   cmnb43          ;[13] Yes, handle it
  2923.     cmp   #hspace          ;[13] Between <sp> and '"'?
  2924.     bpl   cmits2          ;[13] Possible, continue
  2925.     jmp   cminac          ;[13] No, advance to previous character
  2926. cmits2: cmp   #hdquot+1      ;[13]         ...
  2927.     bmi   cmnb43          ;[13] Yes, delete back to there
  2928.     cmp   #hapos          ;[13] Between Apostrophy and '/'?
  2929.     bpl   cmits3          ;[13] Could be, continue
  2930.     jmp   cminac          ;[13] Nope, advance character
  2931. cmits3: cmp   #hslash+1      ;[13]         ...
  2932.     bmi   cmnb43          ;[13] Yup, found a delimiter
  2933.     cmp   #hcolon          ;[13] Between ':' and '>' perhaps?
  2934.     bpl   cmits4          ;[13] Maybe
  2935.     jmp   cminac          ;[13] Nope, advance to previous character     
  2936. cmits4: cmp   #hrabr+1      ;[13]         ...
  2937.     bmi   cmnb43          ;[13] It is, go delete back to there
  2938.     cmp   #hquote          ;[13] Is it a "'"?
  2939.     bne   cminac          ;[13] No, advance
  2940. cmnb43: dec   cmwrk2          ;[13] Adjust this count
  2941. ;[73]    clc          ;[13]     and the buffer pointer
  2942. ;[73]    lda   cm.bfp          ;[13]         ...
  2943. ;[73]    adc   #$01          ;[13]         ...
  2944. ;[73]    sta   cm.bfp          ;[13]         ...
  2945. ;[73]    bcc   cmnb44          ;[13]         ...
  2946.     inc    cm.bfp        ;[73] better way to do it
  2947.     bne    cmnb44        ;[73]
  2948.     inc   cm.bfp+1      ;[13]         ...
  2949. cmnb44: lda   cmccnt          ;[13] Get the command buffer length
  2950. cmnbcc: cmp   ch          ;[13] Check against horizontal cursor position
  2951.     bmi   cmnbna          ;[13] It's smaller, skip veritcal cursor adjust
  2952.     pha            ;[49] save a since upline doesnt
  2953.     jsr   upline          ;[49] [13] Adjust cursor vertical position
  2954.     pla            ;[49]
  2955.     sec          ;[13] Reflect this in number of characters
  2956.     sbc   #$28          ;[13]     we skipped back over
  2957.     jmp   cmnbcc          ;[13] Go check again
  2958. cmnbna: lda   #$00          ;[13] Put a null at the end of the buffer
  2959.     ldy   #$00          ;[13]         ...
  2960.     sta   (cm.bfp),y      ;[13]         ...
  2961.     sta   ch          ;[13] Zero position on current line
  2962.     jsr   scrl3          ;[13] Clear current line
  2963.     ldx   cm.rty          ;[13] Reprint prompt
  2964.     ldy   cm.rty+1      ;[13]         ...
  2965.     jsr   prstr          ;[13]         ...
  2966.     ldx   #cmbuf\          ;[13] Reprint command buffer
  2967.     ldy   #cmbuf^          ;[13]         ...
  2968.     jsr   prstr          ;[13]         ...
  2969.     sec          ;[13] Now adjust the command character count
  2970.     lda   cmccnt          ;[13]         ...
  2971.     sbc   cmwrk2          ;[13]     by what we have accumulated
  2972.     sta   cmccnt          ;[13]         ...
  2973.     jsr   clreol          ;[13] Clear to the end of this line
  2974.     jmp   repars          ;[13] Go reparse the command
  2975. cminac: inc   cmwrk2          ;[13] Increment count of chars to back up
  2976.     sec          ;[13] Adjust the buffer pointer down again
  2977.     lda   cm.bfp          ;[13]         ...
  2978.     sbc   #$01          ;[13]         ...
  2979.     sta   cm.bfp          ;[13]         ...
  2980.     bcs   cmnb45          ;[13] If carry set, skip H.O. byte adjustment
  2981.     dec   cm.bfp+1      ;[13] Adjust this
  2982. cmnb45: jmp   cmnb42          ;[13] Go around once again
  2983.  
  2984. cmib40: cmp   #hquest          ; Need help?
  2985.     beq   cminb6          ;         ...
  2986.     cmp   #hesc          ; Is he lazy?
  2987.     beq   cminb6          ;         ...
  2988.     cmp   #hcr          ; Are we at end of line?
  2989.     beq   cminb5          ;         ...
  2990.     cmp   #hlf          ; End of line?
  2991.     beq   cminb5          ;         ...
  2992.     cmp   #hffd          ; Is it a form feed?
  2993. ;[87]    bne   cminb7          ; None of the above
  2994.     bne   cmnb71          ;[87] None of the above
  2995.     jsr   home          ; Clear the whole screen
  2996. cminb5: lda   cmccnt          ; Fetch character count
  2997.     cmp   #$01          ; Any characters yet?
  2998.     bne   cminb6          ; Yes
  2999.     jmp   prserr          ; No, parser error
  3000. cminb6: lda   #$ff          ; Go
  3001.     sta   cmaflg          ;     and set the action flag
  3002.     jmp   cminb9          ; Leave
  3003. ;[87]cminb7: cmp   #'          ; Is the character a space?
  3004. ;[87]    bne   cmnb71          ; No
  3005. ;[87]    jsr   cout          ; Output the character
  3006. ;[87]    jmp   cminb1          ; Yes, get another character
  3007. cmnb71: cmp   #htab          ; Is it a <tab>?
  3008.     bne   cmnb72          ; No
  3009.     jsr   cout          ; Output the character
  3010.     jmp   cminb1          ; Yes, get more characters
  3011. cmnb72: jsr   cout          ; Print the character on the screen
  3012.     jmp   cminb1          ; Get more characters
  3013. cminb9: dec   cmccnt          ; Decrement the count once
  3014.     plp          ; Restore the processor status
  3015.     pla          ;     the Y register
  3016.     tay          ;         ...
  3017.     pla          ;     the X register
  3018.     tax          ;         ...
  3019.     pla          ;     and the AC
  3020.     rts          ;     and return!
  3021.  
  3022.  
  3023. .SBTTL    Cmgtch - get a character from the command buffer
  3024.  
  3025. ;
  3026. ;     This routine takes the next character out of the command
  3027. ;     buffer, does some checking (action character, space, etc.)
  3028. ;     and then returns it to the calling program in the AC
  3029. ;
  3030. ;         Input:     NONE
  3031. ;
  3032. ;         Output:     A-     Next character from command buffer
  3033. ;
  3034. ;         Registers destroyed:     A,X,Y
  3035. ;
  3036.  
  3037. cmgtch: ldy   #$00          ; Y should always be zero here to index buffer
  3038.     lda   cmaflg          ; Fetch the action flag
  3039. ;    cmp   #$00          ; Set??
  3040.     bne   cmgt1          ; Yes
  3041.     jsr   cminbf          ; No, go fetch some more input
  3042. cmgt1:    lda   (cm.ptr),y      ; Get the next character
  3043. ;[73]    tax          ; Hold on to it here for a moment
  3044. ;[73]    clc          ; Clear the carry flag
  3045. ;[73]    lda   cm.ptr          ; Increment
  3046. ;[73]    adc   #$01          ;     the next character pointer
  3047. ;[73]    sta   cm.ptr          ;         ...
  3048. ;[73]    bcc   cmgt2          ;         ...
  3049.     inc    cm.ptr        ;[73] another way to do it
  3050.     bne    cmgt2        ;[73]
  3051.     inc   cm.ptr+1      ; Have carry, increment H.O. byte
  3052. cmgt2:    ;[73]txa          ; Now, get the data
  3053.     cmp   #hspace          ; Space?
  3054.     beq   cmgtc2          ; Yes
  3055.     cmp   #htab          ; <tab>?
  3056.     bne   cmgtc3          ; Neither space nor <tab>
  3057. cmgtc2: pha          ;[13] Hold the character here till we need it
  3058.     lda   #cmtxt          ;[13] Are we parsing a string?
  3059.     cmp   cmstat          ;[13]         ...
  3060.     beq   cmgtis          ;[13] Yes, ignore space flag test
  3061.     lda   #cmifi          ;[13] Are we parsing a file name?
  3062.     cmp   cmstat          ;[13]         ...
  3063.     beq   cmgtis          ;[13] Yes, ignore space flag test
  3064.     lda   cmsflg          ; Get the space flag
  3065. ;    cmp   #$00          ; Was the last character a space?
  3066.     beq   cmgtis          ;[13] No, go set space flag
  3067.     pla          ;[13] Pop the character off
  3068.     jmp   cmgtch          ;[13] But ignore it and get another
  3069. cmgtis: lda   #$ff          ; Set
  3070.     sta   cmsflg          ;     the space flag
  3071.     pla          ;[13] Restore the space or <tab>
  3072. ;[73]    jmp   cmgtc5          ; Go return
  3073.     rts        ;[73] if u only knew the trouble this caused
  3074. cmgtc3: php          ; Save the processor status
  3075.     pha          ; Save this so it doesn't get clobbered
  3076.     lda   #$00          ; Clear AC
  3077.     sta   cmsflg          ; Clear space flag
  3078.     pla          ; Restore old AC
  3079.     plp          ; Restore the processor status
  3080.     cmp   #hesc          ; Escape?
  3081. ;[73]    beq   cmgtc5          ;         ...
  3082.     beq    cmgtc7        ;[73] sigh! trouble maker
  3083.     cmp   #hquest          ; Need help?
  3084.     beq   cmgtc4          ;         ...
  3085.     cmp   #hcr          ; <cr>?
  3086.     beq   cmgtc4          ;         ...
  3087.     cmp   #hlf          ; <lf>?
  3088.     beq   cmgtc4          ;         ...
  3089.     cmp   #hffd          ; <ff>?
  3090.     beq   cmgtc4          ;         ...
  3091.     and   #$7f          ; Make sure the character is positive
  3092.     rts          ; Not an action character, just return
  3093. cmgtc4: tax          ; Hold the data
  3094.     sec          ; Set the carry flag
  3095.     lda   cm.ptr          ; Get the next character pointer
  3096.     sbc   #$01          ;     and decrement it
  3097.     sta   cm.ptr          ;         ...
  3098.     bcs   cmgtc5          ;         ...
  3099.     dec   cm.ptr+1      ;         ...
  3100. cmgtc5: txa          ; Now, fetch the data
  3101.     ora   #$80          ; Make it look like a terminator
  3102. cmgtc7            ;[73]
  3103.     rts          ; Go back
  3104.  
  3105.  
  3106. .SBTTL    Prcrlf subroutine - print a crelf
  3107.  
  3108. ;
  3109. ;     This routine sets up a call to prstr pointing to the crlf
  3110. ;     string.
  3111. ;
  3112. ;         Registers destroyed:     A
  3113. ;
  3114.  
  3115. ;[75]prcl.0: lda   #hcr          ; Get a cr in the AC
  3116. ;[75]    jsr   cout          ;     and print it out
  3117. ;[75]    rts          ; Return
  3118.  
  3119.  
  3120. .SBTTL    Prstr subroutine
  3121.  
  3122. ;
  3123. ;     This routine prints a string ending in a null.
  3124. ;
  3125. ;         Input:     X-     Low order byte address of string
  3126. ;             Y-     High order byte address of string
  3127. ;
  3128. ;         Output:         Prints string on screen
  3129. ;
  3130. ;         Registers destroyed:     A,X,Y
  3131.  
  3132. ;
  3133.  
  3134.  
  3135. prst.0: stx   saddr          ; Save Low order byte
  3136.     sty   saddr+1          ; Save High order byte
  3137.     ldy   #$00          ; Clear Y reg
  3138.  
  3139. prst1:    lda   (saddr),y      ; Get the next byte of the string
  3140.     beq   prsdon          ; If it is null, we are done
  3141.     ora   #$80          ; Make sure it is printable
  3142.     jsr   dely          ; Call screen output routine
  3143.     iny          ; Up the index
  3144.     bne   prst1          ; [49]If it is zero, the string is <256, continue
  3145.     inc   saddr+1          ; Increment page number
  3146. prst2:    jmp   prst1          ; Go back to print next byte
  3147.  
  3148. prsdon: rts          ; Return
  3149.  
  3150. dely:    pha          ; Hold the AC
  3151. ;[85]    lda   #$32          ; Set delay
  3152.     lda    timect        ;[85] Set delay
  3153.     rol    a        ;[85] just double it
  3154. ;[78]    jsr   $fca8          ; Do the delay
  3155.     jsr   wait          ;[78] Do the delay
  3156.     pla          ; Fetch the character back
  3157.     jmp   cout          ; [49] Print the character
  3158. ;[49]     rts              ; Return
  3159.  
  3160. ;[87].SBTTL    Mul16 - 16-bit multiply routine
  3161. .SBTTL    Mul24 - 24-bit multiply routine
  3162.  
  3163. ;
  3164. ;     This and the following four routines is math support for the
  3165. ;     Comnd package. These routines come from '6502 Assembly Language
  3166. ;     Subroutines' by Lance A. Leventhal. Refer to that source for
  3167. ;     more complete documentation.
  3168. ;
  3169. ;    ENTRY    top of stack
  3170. ;
  3171. ;        low rtn
  3172. ;        high rtn
  3173. ;        low multiplier
  3174. ;             "
  3175. ;        high "
  3176. ;        low multiplican
  3177. ;             "
  3178. ;        high "
  3179.  
  3180. ;    EXIT
  3181. ;        low product
  3182. ;             "
  3183. ;        high "
  3184.  
  3185. ;[87]ml16:    pla          ; Save the return address
  3186. ml24:    pla          ;[87] Save the return address
  3187.     sta   rtaddr          ;         ...
  3188.     pla          ;         ...
  3189.     sta   rtaddr+1      ;         ...
  3190.     pla          ; Get multiplier
  3191.     sta   mlier          ;         ...
  3192.     pla          ;         ...
  3193.     sta   mlier+1          ;         ...
  3194.     pla          ;[87]         ...
  3195.     sta   mlier+2          ;[87]         ...
  3196.     pla          ; Get multiplicand
  3197.     sta   mcand          ;         ...
  3198.     pla          ;         ...
  3199.     sta   mcand+1          ;         ...
  3200.     pla          ;[87]         ...
  3201.     sta   mcand+2          ;[87]         ...
  3202.     lda   #$00          ; Zero
  3203.     sta   hiprod          ;     high word of product
  3204.     sta   hiprod+1      ;         ...
  3205.     sta   hiprod+2      ;[87]         ...
  3206. ;[87]    ldx   #17          ; Number of bits in multiplier plus 1, the
  3207.     ldx   #25          ;[87] Number of bits in multiplier plus 1, the
  3208.               ;     extra loop is to move the last carry
  3209.               ;     into the product.
  3210.     clc          ; Clear carry for first timehrough the loop
  3211. ;[87]mullp:    ror   hiprod+1      ; Shift the whole thing down
  3212. mullp:    ror    hiprod+2    ;[87]
  3213.     ror   hiprod+1      ;[87] Shift the whole thing down
  3214.     ror   hiprod          ;         ...
  3215.     ror   mlier+2          ;[87]         ...
  3216.     ror   mlier+1          ;         ...
  3217.     ror   mlier          ;         ...
  3218.     bcc   deccnt          ; Branch if next bit of multiplier is 0
  3219.     clc          ; next bit is 1 so add multiplicand to product
  3220.     lda   mcand          ;         ...
  3221.     adc   hiprod          ;         ...
  3222.     sta   hiprod          ;         ...
  3223.     lda   mcand+1          ;         ...
  3224.     adc   hiprod+1      ;         ...
  3225.     sta   hiprod+1      ; Carry = overflow from add
  3226.     lda   mcand+2          ;[87]         ...
  3227.     adc   hiprod+2      ;[87]         ...
  3228.     sta   hiprod+2      ;[87] Carry = overflow from add
  3229. deccnt: dex          ;         ...
  3230.     bne   mullp          ; Continue until done
  3231.     lda   mlier+2          ;[87] Get low word of product and push it
  3232.     pha          ;[87]     onto the stack
  3233.     lda   mlier+1          ; Get low word of product and push it
  3234.     pha          ;     onto the stack
  3235.     lda   mlier          ;         ...
  3236.     pha          ;         ...
  3237.     lda   rtaddr+1      ; Restore the return address
  3238.     pha          ;         ...
  3239.     lda   rtaddr          ;         ...
  3240.     pha          ;         ...
  3241.     rts          ; Return
  3242.  
  3243. ;[87]mcand:    .blkb 2          ; Multiplicand
  3244. ;[87]mlier:    .blkb 2          ; Multiplier and low word of product
  3245. ;[87]hiprod: .blkb 2          ; High word of product
  3246. mcand:    .blkb 3          ;[87] Multiplicand
  3247. mlier:    .blkb 3          ;[87] Multiplier and low word of product
  3248. hiprod: .blkb 3          ;[87] High word of product
  3249. rtaddr: .blkb 2          ; Save area for return address
  3250.  
  3251. ;[87].SBTBL    16 bit unsigned division        ;[75]
  3252. .SBTBL    24 bit unsigned division        ;[87]
  3253.  
  3254. ;    entry    top of stack        ;[75]
  3255. ;
  3256. ;        low rtn        ;[75]
  3257. ;        high rtn        ;[75]
  3258. ;        low divisor        ;[75]
  3259. ;            divisor        ;[87]
  3260. ;        high divisor - most significant byte        ;[75]
  3261. ;        low dividend        ;[75]
  3262. ;            dividend        ;[87]
  3263. ;        high dividend - most significant byte        ;[75]
  3264.  
  3265. ;    exit    top of stack        ;[75]
  3266. ;
  3267. ;        low byte of quotient        ;[75]
  3268. ;                quotient        ;[87]
  3269. ;        high     "        ;[75]
  3270. ;        low byte of remainder        ;[75]
  3271. ;                remainder        ;[87]
  3272. ;        high     "        ;[75]
  3273. ;
  3274. ;        if no errors then carry is clear (0)        ;[75]
  3275. ;    REGISTERS A X & Y USED AND NOT RESTORED            ;[75]
  3276.  
  3277. ;[87]dv16    pla            ;[75]
  3278. dv24    pla            ;[87]
  3279.     sta    retadr    ;[75] save the return
  3280.     pla            ;[75]
  3281.     sta    retadr+1        ;[75]
  3282.     pla        ;[75]
  3283.     sta    dvsor    ;[75] get the divisor
  3284.     pla        ;[75]
  3285.     sta    dvsor+1        ;[75]
  3286.     pla        ;[87]
  3287.     sta    dvsor+2        ;[87]
  3288.     pla            ;[75]
  3289.     sta    dvend    ;[75] get the dividend
  3290.     pla        ;[75]
  3291.     sta    dvend+1        ;[75]
  3292.     pla        ;[87]
  3293.     sta    dvend+2        ;[87]
  3294.     jsr    udiv    ;[75] now for the divide
  3295.     bcc    divok    ;[75] good 
  3296.     lda    #0    ;[75] set q & rem to 0
  3297.     sta    dvend        ;[75]
  3298.     sta    dvend+1        ;[75]
  3299.     sta    dvend+2        ;[75]
  3300.     sta    dvend+3        ;[75]
  3301.     sta    dvend+4        ;[87]
  3302.     sta    dvend+5        ;[87]
  3303. ;[87]divok    lda    dvend+3    ;[75] first the remainder
  3304. divok    lda    dvend+5    ;[87] first the remainder
  3305.     pha        ;[87]
  3306.     lda    dvend+4            ;[87]
  3307.     pha            ;[87]
  3308.     lda    dvend+3    ;[75] now the q
  3309.     pha            ;[75]
  3310.     lda    dvend+2    ;[75] now the q
  3311.     pha            ;[75]
  3312.     lda    dvend+1    ;[75] now the q
  3313.     pha        ;[75]
  3314.     lda    dvend        ;[75]
  3315.     pha        ;[75]
  3316.     lda    retadr+1    ;[75] now the return address
  3317.     pha        ;[75]
  3318.     lda    retadr        ;[75]
  3319.     pha        ;[75]
  3320.     rts        ;[75] thats all
  3321. ;*********************************        ;[75]
  3322. ;    udiv        ;[75]
  3323. ;[87]; divide a 16 bit div by a 16 bit divisor        ;[75]
  3324. ; divide a 24 bit div by a 24 bit divisor        ;[87]
  3325. ;entry    dvend = dividend        ;[75]
  3326. ;    dvsor = divisor        ;[75]
  3327. ;exit    dvend = quotient        ;[75]
  3328. ;[87];    dvend+2 = remainder        ;[75]
  3329. ;    dvend+3 = remainder        ;[87]
  3330. ;*********************************        ;[75]
  3331. udiv        ;[75]
  3332.     lda    #0    ;[75] 0 upper word of dividend
  3333. ;[87]    sta    dvend+2        ;[75]
  3334.     sta    dvend+3        ;[75]
  3335.     sta    dvend+4        ;[87]
  3336.     sta    dvend+5    ;[87] called dividend[1] later
  3337.     lda    dvsor    ;[75] check for div by 0
  3338.     ora    dvsor+1        ;[75]
  3339.     ora    dvsor+2        ;[87]
  3340.     bne    okudiv    ;[75] it not 0
  3341.     sec        ;[75] error
  3342.     rts        ;[75] tell the bad news
  3343. ;[87]okudiv    ldx    #16    ;[75] loop thru 16 bits
  3344. okudiv    ldx    #24    ;[87] loop thru 24 bits
  3345.     stx    savex    ;[87]
  3346. divlp            ;[75]
  3347.     rol    dvend    ;[75] shift the carry into bit 0 of dividend
  3348.     rol    dvend+1    ;[75] which will be the q
  3349.     rol    dvend+2    ;[75] shift dividend 
  3350.     rol    dvend+3    ;[75] also
  3351.     rol    dvend+4    ;[87]
  3352.     rol    dvend+5 ;[87]
  3353. ; check if dividend[1] is less than divisor        ;[75]
  3354. chklt        ;[75]
  3355.     sec        ;[75]
  3356. ;[87]    lda    dvend+2    ;[75] first the low byte
  3357.     lda    dvend+3    ;[87] first the low byte
  3358.     sbc    dvsor            ;[75]
  3359.     tay        ;[75] save the low byte in y
  3360. ;[87]    lda    dvend+3        ;[75]
  3361.     lda    dvend+4        ;[87]
  3362.     sbc    dvsor+1    ;[75] now the high bytes
  3363.     tax        ;[87] hold it here
  3364.     lda    dvend+5    ;[87]
  3365.     sbc    dvsor+2    ;[87]
  3366.     bcc    divcnt    ;[75] brandch if dividend < divisor & carry
  3367. ;[87]    sty    dvend+2    ;[75] else div[1] = div[1] - divisor
  3368.     sty    dvend+3    ;[87] else div[1] = div[1] - divisor
  3369.     stx    dvend+4    ;[87]
  3370. ;[87]    sta    dvend+3        ;[75]
  3371.     sta    dvend+5        ;[87]
  3372. ;[87]divcnt    dex        ;[75] next bit
  3373. divcnt    dec    savex        ;[87] next bit
  3374.     bne    divlp    ;[75] yes
  3375.     rol    dvend    ;[75] no shift in last carry for the q
  3376.     rol    dvend+1        ;[75]
  3377.     rol    dvend+2        ;[87]
  3378.     clc        ;[75] no errors so tattle
  3379.     rts        ;[75]
  3380. dvsor    =    mcand        ;[75]
  3381. dvend    =    mlier    ;[75] dividend[0] & q
  3382. ;dvend+2        ;[75] div[1] & remainder    
  3383.  
  3384. ;[87]
  3385. ;[87]    binary to ascii
  3386. ;[87]
  3387. ;[87]    convert a 24 bit unsigned binary number to ascii
  3388. ;[87]
  3389. ;[87]    ENTRY:    top of stack
  3390. ;[87]        lsb    of jsr address
  3391. ;[87]        msb    "
  3392. ;[87]        lsb    of output address
  3393. ;[87]        msb    "
  3394. ;[87]        lsb    value to convert
  3395. ;[87]        2nd    "
  3396. ;[87]        msb    "
  3397. ;[87]
  3398. ;[87]    EXIT:    1st byte of output is binary length
  3399. ;[87]        followed by the ascii chs
  3400. ;[87]
  3401. ;[87]    REGISTERS USER:    all
  3402. ;[87]
  3403. bn2asc    pla            ;[87] save parameters
  3404.     sta    rtaddr        ;[87]
  3405.     pla            ;[87]
  3406.     sta    rtaddr+1    ;[87]
  3407.     pla            ;[87]
  3408.     sta    a4l        ;[87] page 0 a4 will have the address of output
  3409.     pla            ;[87]
  3410.     sta    a4h        ;[87]
  3411.     pla            ;[87]
  3412.     sta    value        ;[87] this is the binary to convert
  3413.     pla            ;[87]
  3414.     sta    value+1        ;[87]
  3415.     pla            ;[87]
  3416.     sta    value+2        ;[87]
  3417.     lda    #0        ;[87] set length to 0
  3418.     tay            ;[87]
  3419.     sta    (a4l),y        ;[87]
  3420. cnvert    lda    #0        ;[87] convert value to ascii chs
  3421.     sta    mod10        ;[87] value -> value/10
  3422.     sta    mod10+1        ;[87] mod10 -> value mod 10
  3423.     sta    mod10+2        ;[87]
  3424.     ldx    #24        ;[87] 3 bytes of them
  3425.     clc            ;[87]
  3426. dvloop    rol    value        ;[87] carry into dividend bit 0
  3427.     rol    value+1        ;[87]
  3428.     rol    value+2        ;[87]
  3429.     rol    mod10        ;[87]
  3430.     rol    mod10+1        ;[87]
  3431.     rol    mod10+2        ;[87]
  3432.     sec            ;[87] now dividend - divisor
  3433.     lda    mod10        ;[87] lsb
  3434.     sbc    #10        ;[87]
  3435.     tay            ;[87] save this for later
  3436.     lda    mod10+1        ;[87]
  3437.     sbc    #0        ;[87] for the carry
  3438.     sta    savea        ;[87] save it here
  3439.     lda    mod10+2        ;[87]
  3440.     sbc    #0        ;[87] finally
  3441.     bcc    bn2dcn        ;[87] br if dividend < divisor
  3442.     sty    mod10        ;[87] no got to try agn
  3443.     sta    mod10+2        ;[87]
  3444.     lda    savea        ;[87]
  3445.     sta    mod10+1        ;[87]
  3446. bn2dcn    dex            ;[87]
  3447.     bne    dvloop        ;[87] all done no
  3448.     rol    value        ;[87]
  3449.     rol    value+1        ;[87]
  3450.     rol    value+2        ;[87]
  3451. conch    lda    mod10        ;[87] add this to output
  3452.     ora    #'0        ;[87] bin to ascii
  3453.     jsr    concat        ;[87]
  3454.     lda    value        ;[87]
  3455.     ora    value+1        ;[87] any left?
  3456.     ora    value+2        ;[87]
  3457.     bne    cnvert        ;[87] yes, its a long loop :-)
  3458.     lda    rtaddr+1    ;[87] return
  3459.     pha            ;[87]
  3460.     lda    rtaddr        ;[87]
  3461.     pha            ;[87]
  3462.     rts            ;[87] thats all folks
  3463.  
  3464. concat    pha            ;[87] add this ch to the front of output
  3465.     ldy    #0        ;[87] shift chs right one
  3466.     lda    (a4l),y        ;[87] this is the length
  3467.     tay            ;[87]
  3468.     beq    exitmr        ;[87] first time? yes
  3469. mvelp    lda    (a4l),y        ;[87] ascii ch
  3470.     iny            ;[87]
  3471.     sta    (a4l),y        ;[87] shift one
  3472.     dey            ;[87]
  3473.     dey            ;[87]
  3474.     bne    mvelp        ;[87] shift another ch
  3475. exitmr    pla            ;[87] now for the original ch
  3476.     ldy    #1        ;[87]
  3477.     sta    (a4l),y        ;[87]
  3478.     dey            ;[87]
  3479.     lda    (a4l),y        ;[87] length
  3480.     clc            ;[87] bump
  3481.     adc    #1        ;[87]
  3482.     sta    (a4l),y        ;[87]
  3483.     rts            ;[87] bye
  3484. value    =    mcand        ;[87] need 6 in a row
  3485. mod10    =    mcand+3        ;[87]
  3486.  
  3487. convuc    and    #$7f        ; first make it ascii
  3488.     cmp   #'a          ; Is character a lower-case alpha?
  3489.     bcc   convrt          ; No, don't capitalize
  3490.     cmp   #<'z+1>          ;         ...
  3491.     bcs   convrt          ;         ...
  3492.     and   #$5f          ; Capitalize
  3493. convrt    rts
  3494. .SBTTL    Rskp  - Do a skip return
  3495.  
  3496. ;
  3497. ;     This routine returns, skipping the instruction following the
  3498. ;     original call. It is assumed that the instruction following the
  3499. ;     call is a JMP.
  3500. ;
  3501. ;         Input:
  3502. ;
  3503. ;         Output:
  3504. ;
  3505. ;         Registers destroyed:     None
  3506. ;
  3507.  
  3508. rskp.0: sta   savea          ; Save the registers
  3509. ;[83]    stx   savex          ;
  3510. ;[83]    sty   savey          ;
  3511.     pla          ; Get Low order byte of return address
  3512. ;[83]    tax          ; Hold it
  3513. ;[83]    pla          ; Get High order byte
  3514. ;[83]    tay          ; Hold that
  3515. ;[83]    txa          ; Get Low order byte
  3516.     clc          ; Clear the carry flag
  3517.     adc   #$04          ; Add 4 to the address
  3518. ;[83]    bcc   rskp2          ; No carry
  3519. ;[83]    iny          ; Increment the high order byte
  3520.     sta   saddr          ; Store L.O. byte
  3521.     pla        ;[83] high order return address
  3522.     adc    #0    ;[83] just involve the carry
  3523.     sta   saddr+1          ; Store H.O. byte
  3524.     lda   savea          ; Restore the registers
  3525. ;[83]    ldx   savex          ;
  3526. ;[83]    ldy   savey          ;
  3527.     jmp   (saddr)          ; Jump at the new address
  3528.  
  3529. .SBTTL    Setbrk and Rstbrk
  3530.  
  3531. ;
  3532. ;     These routines are called from the user program to set or reset
  3533. ;     break characters to be used by Cmunqs. The byte to set or reset
  3534. ;     is located in the Accumulator. Rstbrk has the option to reset
  3535. ;     the entire break-word. This occurs if the H.O. bit of AC is on.
  3536. ;
  3537.  
  3538. sbrk.0: and   #$7f          ;[13] We don't want the H.O. bit
  3539.     ldy   #$00          ;[13] Set up Y to index the byte we want
  3540. sbrkts: cmp   #$08          ;[13] Is the offset > 8
  3541.     bmi   sbrkfw          ;[13] No, we are at the right byte now
  3542.     sec          ;[13] Yes, adjust it down again
  3543.     sbc   #$08          ;[13]         ...
  3544.     iny          ;[13] Advance index
  3545.     jmp   sbrkts          ;[13]     and try again
  3546. sbrkfw: tax          ;[13] This is the remaining offset
  3547.     lda   #$80          ;[13] Start with H.O. bit on
  3548. sbrklp: cpx   #$00          ;[13] Is it necessary to shift down?
  3549.     beq   sbrkfb          ;[13] No, we are done
  3550.     dex          ;[13] Yes, adjust offset
  3551.     lsr   a          ;[13] Shift bit down once
  3552.     jmp   sbrklp          ;[13] Go back and try again
  3553. sbrkfb: ora   brkwrd,y      ;[13] We found the bit, use the byte offset
  3554.     sta   brkwrd,y      ;[13]     from above, set the bit and resave
  3555.     rts          ;[13] Return
  3556.  
  3557. rbrk.0: asl   a          ;[13] Check H.O. bit
  3558.     bcs   rbrkal          ;[13] If that was on, Zero entire brkwrd
  3559.     lsr   a          ;[13] Else shift back (H.O. bit is zeroed)
  3560. rbrkts: cmp   #$08          ;[13] Are we in the right word?
  3561.     bmi   rbrkfw          ;[13] Yes, go figure the rest of the offset
  3562.     sec          ;[13] No, Adjust the offset down
  3563.     sbc   #$08          ;[13]         ...
  3564.     iny          ;[13]     and the index up
  3565.     jmp   rbrkts          ;[13] Try again
  3566. rbrkfw: tax          ;[13] Stuff the remaining offset in X
  3567.     lda   #$7f          ;[13] Start with H.O. bit off
  3568. rbrklp: cpx   #$00          ;[13] Do we need to offset some more?
  3569.     beq   rbrkfb          ;[13] No, we have the correct bit
  3570.     dex          ;[13] Yes, decrement the offset
  3571.     sec          ;[13] Make sure carry is on
  3572.     ror   a          ;[13]     and rotate a 1 bit into mask
  3573.     jmp   rbrklp          ;[13] Go back and try again
  3574. rbrkfb: and   brkwrd,y      ;[13] We found the bit, now shut it off
  3575.     sta   brkwrd,y      ;[13]         ...
  3576.     rts          ;[13]     and return
  3577. rbrkal: lda   #$00          ;[13] Go stuff zeros in the entire word
  3578.     ldy   #$00          ;[13]         ...
  3579. rbrksz: sta   brkwrd,y      ;[13] Stuff the zero
  3580.     iny          ;[13] Up the index once
  3581.     cpy   #$10          ;[13] Are we done?
  3582.     bmi   rbrksz          ;[13] Not yet
  3583.     rts          ;[13] Yes, return
  3584.  
  3585. .SBTTL    Chkbrk
  3586.  
  3587. ;
  3588. ;     Chkbrk - This routine looks for the flag in the break word
  3589. ;     which represents the character passed to it. If this bit is
  3590. ;     on, it is a break character and the routine will simply
  3591. ;     return. If it is not a break character, the routine skips..
  3592. ;
  3593.  
  3594. chkbrk: sta   savea          ;[13] Save byte to be checked
  3595.     and   #$7f          ;[13] Shut H.O. bit
  3596.     ldy   #$00          ;[13] Zero this index
  3597. cbrkts: cmp   #$08          ;[13] Are we at the right word?
  3598.     bmi   cbrkfw          ;[13] Yes, go calculate bit position
  3599.     sec          ;[13] No, adjust offset down
  3600.     sbc   #$08          ;[13]         ...
  3601.     iny          ;[13] Increment the index
  3602.     jmp   cbrkts          ;[13] Go back and test again
  3603. cbrkfw: tax          ;[13] Stuff the remaining offset in X
  3604.     lda   #$80          ;[13] Set H.O. bit on for testing
  3605. cbrklp: cpx   #$00          ;[13] Are we in position yet?
  3606.     beq   cbrkfb          ;[13] Yes, go test the bit
  3607.     dex          ;[13] No, decrement the offset
  3608.     lsr   a          ;[13]     and adjust the bit position
  3609.     jmp   cbrklp          ;[13] Go and try again
  3610. cbrkfb: and   brkwrd,y      ;[13] See if the bit is on
  3611.     bne   cbrkbc          ;[13] It is a break character
  3612.     lda   savea          ;[13] Restore the character
  3613.     jmp   rskp          ;[13] Not a break character, skip return
  3614. cbrkbc: lda   savea          ;[13] Restore the character
  3615.     rts          ;[13] Return
  3616.  
  3617. .SBTTL    Cmehlp - Do extra help on Question-mark prompting
  3618.  
  3619. ;
  3620. ;     Cmehlp - This routine uses a string of commands passed to it
  3621. ;     in order to display alternate valid parse types to the user.
  3622. ;
  3623. ;         Input:     Cmehpt-     Pointer to valid parse types (end in 00)
  3624. ;
  3625. ;         Output:     Display on screen, alternate parse types
  3626. ;
  3627. ;         Registers destroyed:     A,X,Y
  3628. ;
  3629.  
  3630. cmehlp: lda   cmstat          ;[13] We are going to need this so
  3631.     pha          ;[13]     save it across the call
  3632.     ldy   #$00          ;[13] Zero out the help index
  3633.     sty   cmehix          ;[13]         ...
  3634. cmehl1: ldy   cmehix          ;[13] Load the extra help index
  3635.     lda   (cmehpt),y      ;[13] Fetch next type
  3636.     sta   cmstat          ;[13] Store it here
  3637.     inc   cmehix          ;[13] Increase the index by one
  3638.     cmp   #$00          ;[13] Is the type null?
  3639.     bne   cmeh0          ;[13] No, continue
  3640.     jmp   cmehrt          ;[13] Yes, terminate
  3641. cmeh0:    cmp   #cmtok+1      ;[13] If the type is out of range, leave
  3642.     bmi   cmeh1          ;[13]         ...
  3643.     jmp   cmehrt          ;[13]         ...
  3644. cmeh1:    pha          ;[13] Save the type across the call
  3645.     ldx   #cmors\          ;[13] Set up address of 'OR ' string
  3646.     ldy   #cmors^          ;[13]         ...
  3647.     jsr   prstr          ;[13]     and print it
  3648.     pla          ;[13] Restore AC
  3649.     cmp   #cmkey          ;[13] Compare with keyword
  3650.     bne   cmeh2          ;[13] No, try next type
  3651. cmeh10: tax          ;[13] Hold type in X register
  3652.     lda   cmsptr          ;[13] Save these parms so they can be restored
  3653.     pha          ;[13]         ...
  3654.     lda   cmsptr+1      ;[13]         ...
  3655.     pha          ;[13]         ...
  3656.     lda   cm.ptr          ;[13] Copy the pointer to the saved pointer
  3657.     sta   cmsptr          ;[13]     so the keyword print routine prints
  3658.     pha          ;[13]     the entire table. Also, save it on
  3659.     lda   cm.ptr+1      ;[13]     the stack so it can be restored later
  3660.     sta   cmsptr+1      ;[13]         ...
  3661.     pha          ;[13]         ...
  3662.     lda   cmptab          ;[13] Save the table address also
  3663.     pha          ;[13]         ...
  3664.     lda   cmptab+1      ;[13]         ...
  3665.     pha          ;[13]         ...
  3666.     txa          ;[13] Restore type
  3667.     cmp   #cmkey          ;[13] Keyword?
  3668.     bne   cmeh11          ;[13] No, it must be a switch table
  3669.     ldx   #cmin01\      ;[13] Set up address of message
  3670.     ldy   #cmin01^      ;[13]         ...
  3671.     jmp   cmeh12          ;[13] Go print the string
  3672. cmeh11: ldx   #cmin02\      ;[13] Set up address of 'switch' string
  3673.     ldy   #cmin02^      ;[13]         ...
  3674. cmeh12: jsr   prstr          ;[13] Print the message
  3675.     ldy   cmehix          ;[13] Get the index into help string
  3676.     lda   (cmehpt),y      ;[13] Fetch L.O. byte of table address
  3677.     sta   cmptab          ;[13] Set that up for Cmktp
  3678.     iny          ;[13] Increment the index
  3679.     lda   (cmehpt),y      ;[13] Get H.O. byte
  3680.     sta   cmptab+1      ;[13] Set it up for Cmktp
  3681.     iny          ;[13] Advance the index
  3682.     sty   cmehix          ;[13]     and store it
  3683.     jsr   cmktp          ;[13] Print the keyword table
  3684.     pla          ;[13] Now restore all the stuff we saved before
  3685.     sta   cmptab+1      ;[13]         ...
  3686.     pla          ;[13]         ...
  3687.     sta   cmptab          ;[13]         ...
  3688.     pla          ;[13]         ...
  3689.     sta   cm.ptr+1      ;[13]         ...
  3690.     pla          ;[13]         ...
  3691.     sta   cm.ptr          ;[13]         ...
  3692.     pla          ;[13]         ...
  3693.     sta   cmsptr+1      ;[13]         ...
  3694.     pla          ;[13]         ...
  3695.     sta   cmsptr          ;[13]         ...
  3696.     jmp   cmehl1          ;[13] See if there is more to do
  3697. cmeh2:    cmp   #cmswi          ;[13] Type is switch?
  3698.     bne   cmeh3          ;[13] No, continue
  3699.     jmp   cmeh10          ;[13] We can treat this just like a keyword
  3700. cmeh3:    cmp   #cmifi          ;[13] Input file?
  3701.     bne   cmeh4          ;[13] No, go on
  3702.     ldx   #cmin03\      ;[13] Set up the message address
  3703.     ldy   #cmin03^      ;[13]         ...
  3704.     jmp   cmehps          ;[13] Go print it
  3705. cmeh4:    cmp   #cmofi          ;[13] Output file?
  3706.     bne   cmeh5          ;[13] Nope, try again
  3707.     ldx   #cmin04\      ;[13] Set up message address
  3708.     ldy   #cmin04^      ;[13]         ...
  3709.     jmp   cmehps          ;[13] Go print the string
  3710. cmeh5:    cmp   #cmcfm          ;[13] Confirm?
  3711.     bne   cmeh6          ;[13] No
  3712.     ldx   #cmin00\      ;[13] Set up address
  3713.     ldy   #cmin00^      ;[13]         ...
  3714.     jmp   cmehps          ;[13] Print the string
  3715. cmeh6:    cmp   #cmtxt          ;[13] Unquoted string?
  3716.     bne   cmeh7          ;[13] No, try next one
  3717.     ldx   #cmin06\      ;[13] Set up address
  3718.     ldy   #cmin06^      ;[13]         ...
  3719.     jmp   cmehps          ;[13] Print
  3720. cmeh7:    cmp   #cmnum          ;[13] Integer?
  3721.     bne   cmeh8          ;[13] Try again
  3722.     ldx   #cmin05\      ;[13] Set up message
  3723.     ldy   #cmin05^      ;[13]         ...
  3724.     jsr   prstr          ;[13] Print it
  3725.     ldy   cmehix          ;[13] Get index
  3726.     inc   cmehix          ;[13] Advance index
  3727.     lda   (cmehpt),y      ;[13] Get base of integer
  3728.     cmp   #$0a          ;[13] Is it greater than decimal 10?
  3729.     bmi   cmeh71          ;[13] No, just print the L.O. digit
  3730.     lda   #$b1          ;[13] Print the H.O. digit as a 1
  3731.     jsr   cout          ;[13] Print the '1'
  3732.     ldy   cmehix          ;[13] Load index
  3733.     dey          ;[13] Point back to last byte
  3734.     lda   (cmehpt),y      ;[13] Get the base back
  3735.     sec          ;[13] Set the carry flag for subtraction
  3736.     sbc   #$0a          ;[13] Subtract off decimal 10
  3737. cmeh71: clc          ;[13] Clear carry for addition
  3738.     adc   #$b0          ;[13] Make it printable
  3739. ;[79]    jsr   cout          ;[13] Print the digit
  3740. ;[79]    jsr   prcrlf          ;[13] Print a crelf
  3741.     jsr    coutl        ;[79] print ch & crlf
  3742.     jsr   prbyte          ;[13] Print the byte
  3743.     jmp   cmehl1          ;[13] Go back for more
  3744. cmeh8:    ldx   #cmin07\      ;[13] Assume it's a token
  3745.     ldy   #cmin07^      ;[13]         ...
  3746. ;[79]cmehps: jsr   prstr          ;[13] Print string
  3747. ;[79]    jsr   prcrlf          ;[13] Print a crelf
  3748. cmehps    jsr    prstrl        ;[79]
  3749.     jmp   cmehl1          ;[13] Go back
  3750. cmehrt: pla          ;[13] Restore
  3751.     sta   cmstat          ;[13]     current parse type
  3752.     rts
  3753.  
  3754. .SBTTL    Cmcpdf - Copy a default string into the command buffer
  3755.  
  3756. ;
  3757. ;     Cmcpdf - This routine copies a default for a field
  3758. ;     into the command buffer andreparses the string.
  3759. ;
  3760. ;         Input:     Cmdptr-     Pointer to default field value (asciz)
  3761. ;
  3762. ;         Output:
  3763. ;
  3764. ;         Registers destroyed:     A,X,Y
  3765. ;
  3766.  
  3767. cmcpdf: sec          ;[13] Reset the buffer pointer
  3768.     lda   cm.bfp          ;[13]         ...
  3769.     sbc   #$01          ;[13]         ...
  3770.     sta   cm.bfp          ;[13]         ...
  3771.     bcs   cmcpst          ;[13] If carry set, don't adjust H.O. byte
  3772.     dec   cm.bfp+1      ;[13]         ...
  3773. cmcpst: dec   cmccnt          ;[13] Adjust the character count
  3774.     ldy   #$00          ;[13] Zero the index
  3775. cmcplp: lda   (cmdptr),y      ;[13] Get byte
  3776.     beq   cmcpdn          ;[13] Copy finished, leave
  3777.     ldx   cmccnt          ;[23] Check character count
  3778.     inx          ;[23] If it is just short of wrapping
  3779.     bne   cmcpl1          ;[23]     then we are overflowing buffer
  3780.     jsr   bell          ;[23] If that is the case, tell the user
  3781.     dec   cmccnt          ;[23] Make sure it doesn't happen again
  3782.     jmp   prserr          ;[23]     for same string.
  3783. cmcpl1: ora   #$80          ;[13] Be consistent, make sure H.O. bit is on
  3784.     sta   (cm.bfp),y      ;[13] Stuff it in the buffer
  3785.     inc   cmccnt          ;[13] Adjust character count
  3786.     iny          ;[13] Up the buffer index
  3787.     jmp   cmcplp          ;[13] Go to top of loop
  3788. cmcpdn: lda   #hspace          ;[13] Get a space
  3789.     sta   (cm.bfp),y      ;[13]     and place it in buffer after keyword
  3790.     iny          ;[13] Increment the buffer index
  3791.     lda   #nul          ;[13] Get a null
  3792.     sta   (cm.bfp),y      ;[13]     and stuff that at the end of buffer
  3793.     clc          ;[13] Now recompute the end of usable buffer
  3794.     tya          ;[13] Get the number of chars added
  3795.     adc   cm.bfp          ;[13] Add that to the buffer pointer
  3796.     sta   cm.bfp          ;[13]         ...
  3797.     lda   #$00          ;[13]         ...
  3798.     adc   cm.bfp+1      ;[13]         ...
  3799.     sta   cm.bfp+1      ;[13]         ...
  3800.     lda   #$00          ;[13] Reset the action flag
  3801.     sta   cmaflg          ;[13]         ...
  3802.     sec          ;[13] Now adjust the command pointer to the
  3803.     lda   cm.ptr          ;[13]     beginning of the copied field
  3804.     sbc   #$01          ;[13]         ...
  3805.     tax          ;[13] Set it up in X and Y so we can call Prstr
  3806.     lda   cm.ptr+1      ;[13]         ...
  3807.     sbc   #$00          ;[13]         ...
  3808.     tay          ;[13]         ...
  3809.     jsr   prstr          ;[13] Print the added field
  3810.     jmp   repars          ;[13] Now go reparse the whole command
  3811.     .list        ;[84]
  3812. .SBTTL    Comnd Jsys messages and table storage
  3813.     .nlst            ;[57] save a tree
  3814.  
  3815. cmer00: .byte hcr,hlf
  3816.     nasc  <?PROGRAM ERROR:    INVALID COMND CALL> 1
  3817. cmer01: .byte hcr,hlf
  3818.     nasc  <?AMBIGUOUS> 1
  3819. cmer02: .byte hcr,hlf
  3820.     nasc  <?ILLEGAL INPUT FILE SPEC> 1
  3821. cmer03: .byte hcr,hlf
  3822.     nasc  <?NO KEYWORDS MATCH THIS PREFIX> 1
  3823. cmer04: .byte hcr,hlf
  3824.     nasc  <?NO SWITCHES MATCH THIS PREFIX> 1
  3825. cmer05: .byte hcr,hlf
  3826.     nasc  <?BAD CHARACTER IN INTEGER NUMBER> 1
  3827. cmer06: .byte hcr,hlf
  3828.     nasc  <?BASE OF INTEGER OUT OF RANGE> 1
  3829. cmer07: .byte hcr,hlf
  3830.     nasc  <?OVERFLOW WHILE READING INTEGER NUMBER> 1
  3831. cmin00: nasc  < CONFIRM WITH CARRIAGE RETURN> 1
  3832. cmin01: nasc  < KEYWORD, ONE OF THE FOLLOWING:> 1
  3833. cmin02: nasc  < SWITCH, ONE OF THE FOLLOWING:> 1
  3834. cmin03: nasc  < INPUT FILE SPEC> 1
  3835. cmin04: nasc  < OUTPUT FILE SPEC> 1
  3836. cmin05: nasc  < INTEGER NUMBER IN BASE > 1
  3837. cmin06: nasc  < UNQUOTED TEXT STRING > 1
  3838. cmin07: nasc  < SINGLE CHARACTER TOKEN > 1
  3839. cmors:    nasc  < OR > 1          ;[13] 'OR ' string for extra help
  3840.     .list        ;[57]
  3841. .SBTTL    Kermit defaults for operational parameters
  3842.  
  3843. ;
  3844. ;     The following are the defaults which this Kermit uses for
  3845. ;     the protocol.
  3846. ;
  3847.  
  3848. dquote    =     '#          ; The quote character
  3849. dpakln    =     $5e          ;[4] The packet length
  3850. dpadch    =     nul          ; The padding character
  3851. dpadln    =     0          ; The padding length
  3852. dmaxtr    =     $14          ; The maximum number of tries
  3853. debq    =     '&          ; The eight-bit-quote character
  3854. dtime    =     15          ;[5] The default time-out amount
  3855. deol    =     cr          ; The end-of-line character
  3856.  
  3857. .SBTTL    Kermit data
  3858.  
  3859. ;
  3860. ;     The following is data storage used by Kermit
  3861. ;
  3862.  
  3863. mxpack    =     dpakln          ; Maximum packet size
  3864. mxfnl    =     $1e          ; Maximum file-name length
  3865. eof    =     $01          ; This is the value for End-of-file
  3866. buflen    =     $ff          ; Buffer length for received data
  3867. kerbf1    =     $1a          ; This always points to packet buffer
  3868. kerbf2    =     $1c          ; This always points to data buffer
  3869. terse    =     $01          ;[26] Symbol for terse debug mode
  3870. verbose =     $02          ;[26] Symbol for verbose debug mode
  3871. xon    =     $11          ;[21] Xon for Ibm-mode
  3872. ;[65]fbsbit    =     $01          ; Value for SEVEN-BIT FILE-BYTE-SIZE
  3873. ;[65]fbebit    =     $00          ; Value for EIGHT-BIT FILE-BYTE-SIZE
  3874. nparit    =     $00          ;[21] Value for PARITY NONE
  3875. sparit    =     $01          ;[21] Value for PARITY SPACE
  3876. mparit    =     $02          ;[21] Value for PARITY MARK
  3877. oparit    =     $03          ;[21] Value for PARITY ODD
  3878. eparit    =     $04          ;[21] Value for PARITY EVEN
  3879. eprflg    =     $40          ;[38] 'Error packet received' flag
  3880. errcri    =     $01          ; Error code - cannot receive init
  3881. errcrf    =     $02          ; Error code - cannot receive file-header
  3882. errcrd    =     $03          ; Error code - cannot receive data
  3883. errmrc    =     $04          ; Error code - maximum retry count exceeded
  3884. errbch    =     $05          ; Error code - bad checksum
  3885. errfae    =     $0a          ; Error code - file already exists
  3886. emesln    =     $19          ; Standard error message length
  3887. ;[64]kerrns    =     $1f          ; Routine name and action string length
  3888. kerdel    =     $15          ; Disk error length
  3889. kerems    =     $19          ; Error message size
  3890. kerfts    =     $0b          ; Size of file-type strings (incl. term. nul)
  3891. kerdsz    =     $09          ;[26] Length of debug mode strings
  3892. kerpsl    =     $06          ;[21] Size of parity strings
  3893. kbdl    =     $05          ;[35] Size of keyboard-type strings.
  3894. dspl    =     13          ;[49] [46] Size of display-type strings.
  3895. kerfrm    =     cminf1          ;[13] 'From string' pointer for Kercpy routine
  3896. kerto    =     cminf2          ;[13] 'To string' pointer for Kercpy routine
  3897.     .ifeq <ftcom-ftappl>
  3898. invflg    =     $32          ;[34] Location used to indicate display mode.
  3899. nrmdsp    =     $ff          ;[34] Mode is normal.
  3900. invdsp    =     $3f          ;[34] Mode is inverse.
  3901. flsdsp    =     $7f          ;[34] Mode is flashing.
  3902. cswl    =     $36          ; Character out routine pointer (z-pag)
  3903. cswh    =     $37          ;         ...
  3904. kswl    =     $38          ; Keyboard character in routine pointer (z-pag)
  3905. kswh    =     $39          ;         ...
  3906. kbap2p    =     $00          ;[35] Keyboard is apple 2/2+ type
  3907. kbap2e    =     $01          ;[35] Keyboard is apple 2e type
  3908. kmnorm    =     $00          ;[35] Keyboard mode is normal
  3909. kmpref    =     $01          ;[35] Keyboard mode is prefixed
  3910. kmlit    =     $02          ;[35] Keyboard mode is literal.
  3911. ds40up    =     $00          ;[46] Display is 40 col, uppercase only (2/2+)
  3912. ds40mx    =     $01          ;[46] Display is 40 col, full set (2e/2c)
  3913. ds80mx    =     $80          ;[49] Display is 80 col, full set (2e/2c)
  3914. errptr    =     $9d5a          ; DOS error handler vector
  3915. basws    =     $9d5e          ; DOS basic warmstart vector
  3916.     .endc
  3917. ;[75]pdbuf:    .blkb mxpack-2      ;[20] Packet buffer
  3918. ;[75]pdlen:    .byte          ; Common area to place data length
  3919. ;[75]ptype:    .byte          ; Common area to place current packet type
  3920. ;[75]pnum:    .byte          ; Common area to put packet number received
  3921. ;[75]plnbuf: .blkb $100          ;[25] Port line buffer
  3922. ;[75]pdtend: .byte          ; End of plnbuf pointer
  3923. ;[75]pdtind: .byte          ; Index for plnbuf
  3924. rstat:    .byte          ; Return status
  3925. kerrta: .word          ; Save area for return address
  3926. ; ******************** begin area for install pgm, no adds or deletes pls
  3927. kbd1:    .byte $00          ;[35] Keyboard-type string index.
  3928. dsp1:    .byte $00          ;[46] Display-type string index.
  3929.     .ifeq    termnl        ;[63]
  3930. prmt:    nasc  <TERMINAL > 0      ;[63] Prompting text
  3931.     .endc            ;[63]
  3932.     .ifne    termnl        ;[63]
  3933. prmt:    nasc  <KERMIT-65> 0      ;[13] Prompting text
  3934.     .endc            ;[63]
  3935.  
  3936.     .byte $80!'>          ;[13] Kludge to add '>' to prompt
  3937.     .byte $00          ;[13] End of kludge
  3938. lprmt    =     .-prmt          ;[13] Length of prompting text
  3939. escp:    .byte          ; Character for escape from connection
  3940. ;[65]fbsize: .byte fbsbit          ;[36] File-byte-size (Default = 7-bit)
  3941. filmod: .byte          ; Current file type
  3942. ;ascii    .byte            ;[82] ascii 7bit text files for prodos text
  3943. prtcl    .byte    0    ;[83] protocol
  3944. sfxmd    =    128    ;[83] size of xmodem data
  3945. usehdr: .byte off          ;[12] Where to get filename (on=file-head)
  3946. lecho:    .byte off          ;[12] Local-echo switch
  3947. ;ibmmod: .byte off          ;[68][12] Ibm-mode switch
  3948. ;[76]vtmod:    .byte off          ;[51][12] VT-52 Emulation mode switch
  3949. vtmod:    .byte    1      ;[76] terminal Emulation switch - start with none
  3950. timer    .byte    on        ;[64] receive timeout on/off
  3951.     .ifeq    termnl        ;[63]
  3952. termct    .byte    0        ;[63] count of characters in term init string
  3953. ;[82]    mcp string -> ^_^_^_^_^_s{S/R}name,ascii chs of size,{t/b/a/i}
  3954. ;[82]                 send/recfile name,count,file type
  3955. termst    .byte    $1f,$1f,$1f,$1f,$1f,$73    ;[63] (5)us,s - term init string
  3956. lterms    =    .-termst    ;[63] length of term init string
  3957. termco    .byte    "solid"        ;[63] ack for mcp pgm
  3958.     .byte    cr        ;[63] terminate with carrage return
  3959. ltermc    =    .-termco    ;[63] len of above
  3960. termsc    .byte    0        ;[63]
  3961. stoft    .byte    't        ;[63]
  3962.     .byte    0        ;[63] text filemode
  3963.     .byte    'a        ;[63]
  3964.     .byte    2        ;[63] applesoft filemode
  3965.     .byte    'i        ;[63]
  3966.     .byte    1        ;[63] integer basic filemode
  3967.     .byte    'b        ;[63]
  3968.     .byte    4        ;[63] binary filemode
  3969. etoft                ;[63]
  3970.     .endc            ;[63]
  3971. twrk1    .blkb    3        ;[64] working space for fuzzy timer
  3972. lpcycl    .word            ;[64] getc cycles to convert to rtime in sec
  3973. cv2lp    =    50        ;[64] convert seconds to loops in getc
  3974. kbdtyp: .byte kbap2p          ;[35] Keyboard type 2/2+,2e,etc
  3975. kbmode: .byte kmnorm          ;[35] Mode for keyboard input
  3976. kbcase: .byte off          ;[35] Default case of keyboard
  3977. dsptyp: .byte ds40up          ;[46] Display type default.
  3978. dsp2:    .byte 3          ;[49] Display 80 col default slot.
  3979. ; ******************** end area for install pgm, no adds or deletes pls
  3980. ; ************** dont add anything new above this ***********************
  3981. swapf    .byte    0        ;[73] swap bs & del keypress flag
  3982.     .ifeq    funkey        ;[73]
  3983. usfkey    .byte            ;[73] should we look for function keys
  3984.     .endc            ;[73]
  3985. prnfg:    .byte          ;[55] Printer flag off=0
  3986. prnsl:    .byte          ;[55] Printer slot
  3987. logfg:    .byte          ;[56] logging flag $80=yes,0=no
  3988. xonfg    .byte          ;[57] flow control flag
  3989. flowdl    .byte    $0    ;[57] delay for xon/xoff to take effect
  3990. ;[74]flowlp    .byte        ;[57] times to wait 1 ms
  3991. ;[76]confg    .byte        ;[57] are we talking to a remote ? yes non 0
  3992. confg    .byte        ;[76] flowfg when not connected
  3993. softvc    =    $3f2    ;[57] soft vector entry when reset is pushed
  3994. warmst    =    $fb6f    ;[57] calculate new power up byte
  3995. dosflg    .byte        ;[59] which dos 0=3.3 , <>0 prodos
  3996. errcnt    .word        ;[59] retry count for file xfer
  3997. rplocv    =    0    ;[59] line for recv msg
  3998. pclocv    =    10    ;[87] starting loc of % of xfer-0 is first
  3999. lensh    =    22    ;[87] length of show line to variable print pos
  4000. rploch    =    35    ;[66][59] starting ch in rplocv line
  4001. ellocv    =    1    ;[75] line for error message
  4002. splocv    =    2    ;[59] line for send msg
  4003. erlocv    =    3    ;[59] line for error count msg
  4004. dblocv    =    4    ;[59] line for debug msg
  4005. dbloch    =    0    ;[59] starting ch in dblocv line
  4006. fnflag    .byte    0    ;[66] flag to write file name when file xfering
  4007. getfg    .byte    0    ;[75] get file flag
  4008. parity: .byte          ; Parity setting
  4009. delay:    .byte          ; Amount of delay before first send
  4010. filwar: .byte on          ;[51][12] File-warning switch
  4011. debug:    .byte off          ;[12] Debug switch
  4012. ;[66]ebqmod: .byte off          ;[12] Eight-bit-quoting mode
  4013. ebqmod: .byte on          ;[66][12] Eight-bit-quoting mode
  4014. datind: .byte          ; Data index into packet buffer
  4015. chebo:    .byte          ; Switch to tell if 8th-bit was on
  4016. getfln    .byte    0    ;[86] get file name length
  4017. vtcnlm    .byte    0    ;[86] new line mode vt100
  4018. itse80    .word    0    ;[86] its //e or better in 80 col screen
  4019. itsefl    .byte    1    ;[86] times we have inverted cursor
  4020. ;exqufl    .byte    0    ;[87] exit quit flag
  4021. sch    .byte        ;[87] hch when screen saved
  4022. scv    .byte    0    ;[87] hcv when screen saved
  4023. fgetgn    .byte    0    ;[87] fget flag for getting file name
  4024. lcurfl    .word    0    ;[87] length of current file xfer
  4025.     .byte    0    ;[87] " its 3 bytes long
  4026. cvaflw    .byte        ;[87] length of current print ascii field    
  4027. flatr    .byte        ;[87] file attribute flag on = yes
  4028. csfg    .byte    1    ;[87] clear screen flag is on
  4029. vtcorm    .byte    0    ;[78] org mode 0=abs else relative to region
  4030. vtcsgr    .byte    $e        ;[76] vt100 special graphics rendition
  4031. vtcmod    .byte    0        ;[76] vt100 modes flag
  4032. vtcscs    .byte    0        ;[76] vt100 g1 special ch sset
  4033. vtcso    .byte    0        ;[76] are we using vtcscs?
  4034. nita    .byte    0        ;[76] number in tab arrray
  4035. ;[76]escflg: .byte          ; Flag indicating we have seen and escape ($1b)
  4036. fillen: .word          ;[6] Length of current file left to send
  4037. fetfl:    .byte          ;[6] Flag indicating we need the file length
  4038. addlf:    .byte          ;[8] Add a <lf> flag
  4039. lffg    .byte    0    ;[74]
  4040. dellf:    .byte          ;[8] Flush a <lf> flag
  4041. jtaddr: .word          ;[9] Jump table address hold area
  4042. hch:    .byte          ;[13] Hold horizontal cursor position
  4043. hcv:    .byte          ;[13] Hold vertical cursor position
  4044. ohcv    .byte        ;[76] saved hcv
  4045. ohch    .byte        ;[76] saved hch
  4046. ovtcsc    .byte        ;[76] saved which character set
  4047. ovtcsg    .byte        ;[76] saved graphics rendition
  4048. ovtcso    .byte        ;[78] saved graphics action
  4049. wrapar    .byte    on    ;[76] start in set mode
  4050. ;owntop    .byte    0    ;[76] our wndtop, since pascal keeps changing wndtop
  4051. ;ownbtm    .byte    24    ;[76] our wndbtm             "
  4052. kerrki    .byte    0    ;[78] initializing reading file kermit.ini etc
  4053. kersft    .byte        ;[78] initializing save current file type
  4054. kpfl    .byte        ;[80] do we have a keypad?
  4055. kpafl    .byte        ;[80] is the keypad in applications mode?
  4056. ckfl    .byte        ;[80] curson keys application mode ?
  4057. match   .byte        ;[81]Got-a-match flag
  4058. wchpat   .byte        ;[81]What versions of pattern & name being checked?
  4059. patl     .byte          ;[81] pattern
  4060. patbuf   .blkb   mxfnl+1   ;[81] wildcard pattern
  4061. fnl      =    nfcb1          ;[81]Lengths: filename
  4062. infind   .blkb   1          ;[81]Now in a wildcard search (recursion monitor)
  4063. wcpres   .blkb   1          ;[81]Wildcard-found-during-parsing flag
  4064. wcmult   =    '*    ;[81] multiple-char
  4065. wcsing   =    '=      ;[81] single-char
  4066. gfcol    .byte        ;[81] current col
  4067. lgfcol    .byte        ;[81] last non blank col in name
  4068. filect    .byte        ;[81] current matching file in catalog
  4069. catlin    .byte        ;[81] current file in catalog
  4070. msgfl    .byte        ;[81] message file
  4071. putcut    .byte        ;[81] put packet to cout
  4072. kwrk01: .byte          ; Work area for Kermit
  4073. kwrk02: .byte          ; Work area for Kermit
  4074. kertpc: .byte          ;[21] Hold area for parity check
  4075. ksavea: .byte          ;[12] Save area for accumulator
  4076. ksavex: .byte          ;[12] Save area for X reg
  4077. ksavey: .byte          ;[12] Save area for Y reg
  4078. kerchr: .byte          ; Current character read off port
  4079. kermbs: .word          ; Base address of message table
  4080. ;[75]kerhcs: .word          ; Hold area for char out routine address
  4081. ;[75]kerhks: .word          ; Hold area for input routine address
  4082. hsoftv    .word        ;[75] hold area for original soft vector
  4083. ;[84]herrpt: .word          ; Hold area for DOS error routine vector
  4084. ;[84]hbasws: .word          ; Hold area for DOS basic warmstart vector
  4085. ;[83]debchk: .byte          ; Checksum for debug routine
  4086. debinx: .byte          ; Debug routine action index
  4087. fld:    .byte          ; State of receive in rpak routine
  4088. retadr: .word          ; Hold area for return address
  4089. n:    .byte          ; Message #
  4090. numtry: .byte          ; Number of tries for this packet
  4091. oldtry: .byte          ; Number of tries for previous packet
  4092. maxtry: .byte dmaxtr          ;[12] Maximum tries allowed for a packet
  4093. state:    .byte          ; Current state of system
  4094. local:    .byte          ; Local/Remote switch
  4095. size:    .byte          ; Size of present data
  4096. chksum: .byte          ; Checksum for packet
  4097. rtot:    .word          ; Total number of characters received
  4098.     .byte        ;[87] need 3 bytes
  4099. stot:    .word          ; Total number of characters sent
  4100.     .byte        ;[87] need 3 bytes
  4101. rchr:    .word          ; Number characters received, current file
  4102.     .byte        ;[84] need 3 bytes for size
  4103. schr:    .word          ; Number of characters sent, current file
  4104.     .byte        ;[84] need 3 bytes for size
  4105. rovr:    .word          ; Number of overhead characters on receive
  4106. sovr:    .word          ; Number of overhead characters on send
  4107. tpak:    .word          ;[16] Number of packets for this transfer
  4108. eofinp: .byte          ; End-of-file (no characters left to send)
  4109. eodind: .byte          ;[6] End-of-data reached on disk
  4110. errcod: .byte          ; Error indicator
  4111. ;[87]errrkm: .blkb mxpack-2      ;[38] Error message from remote Kermit
  4112. errrkm: =    getln      ;[87] Error message from remote Kermit
  4113. kerosp: .byte          ; Save area for stack pointer
  4114. oldch:    .byte          ;[31] Save loc for cursor address x coord.
  4115. curchr: .byte          ;[31] True value for char under cursor
  4116.  
  4117. ;
  4118. ;     These fields are set parameters and should be kept in this
  4119. ;     order to insure integrity when setting and showing values
  4120. ;
  4121.  
  4122. srind:    .byte          ; Switch to indicate which parm to print
  4123. ebq:    .byte debq          ; Eight-bit quote character (rec. and send) 
  4124.     .byte debq          ;         ...
  4125. pad:    .byte dpadln          ; Number of padding characters (rec. and send)
  4126.     .byte dpadln          ;         ...
  4127. padch:    .byte dpadch          ; Padding character (receive and send)
  4128.     .byte dpadch          ;         ...
  4129. eol:    .byte deol          ; End-of-line character (recevie and send)
  4130.     .byte deol          ;         ...
  4131. ;[75]psiz:    .byte dpakln          ; Packet size (receive and send)
  4132. psiz:    .byte maxxdl          ;[75] Packet size (receive and send)
  4133.     .byte dpakln          ;         ...
  4134. time:    .byte dtime          ;[5] Time-out interval (receive and send)
  4135.     .byte dtime          ;[5]         ...
  4136. ;     .word     $0000          ;[5] Time out interval (receive and send)
  4137. quote:    .byte dquote          ; Quote character (receive and send)
  4138.     .byte dquote          ;         ...
  4139. sop    .byte    soh        ;[82] start of packet
  4140.     .byte    soh        ;[82]
  4141. xcrlf    .byte    on        ;[84] should we xlate cr<->cr,lf for rec
  4142.     .byte    on        ;[84] for send
  4143.  
  4144. ;
  4145. ;     Some definitions to make life easier when referencing the above
  4146. ;     fields.
  4147. ;
  4148.  
  4149. rebq    =     ebq          ; Receive eight-bit-quote char
  4150. sebq    =     ebq+1          ; Send eight-bit-quote char
  4151. rpad    =     pad          ; Receive padding amount
  4152. spad    =     pad+1          ; Send padding amount
  4153. rpadch    =     padch          ; Receive padding character
  4154. spadch    =     padch+1          ; Send padding character
  4155. reol    =     eol          ; Receive end-of-line character
  4156. seol    =     eol+1          ; Send end-of-line character
  4157. rpsiz    =     psiz          ; Receive packet length
  4158. spsiz    =     psiz+1          ; Send packet length
  4159. rtime    =     time          ; Receive time out interval
  4160. stime    =     time+1          ; Send time out interval
  4161. rquote    =     quote          ; Receive quote character
  4162. squote    =     quote+1          ; Send quote character
  4163.  
  4164. ;[35] Table for prefixed conversions by CHRCON.
  4165. chrtab: .byte '<          ;[35] replace <
  4166.     .byte '{          ;[35] with left curly brace.
  4167.  
  4168.     .byte '.          ;[35]
  4169.     .byte '|          ;[35] vertical bar.
  4170.  
  4171.     .byte '>          ;[35]
  4172.     .byte '}          ;[35] right curly brace.
  4173.  
  4174.     .byte $27          ;[35]
  4175.     .byte $40          ;[35] accent grave
  4176.  
  4177.     .byte ')          ;[35]
  4178.     .byte ']          ;[35] right square bracket
  4179.  
  4180.     .byte '(          ;[35]
  4181.     .byte '[          ;[35] left square bracket
  4182.  
  4183.     .byte '/          ;[35]
  4184.     .byte '\          ;[35] backslash
  4185.  
  4186.     .byte '-          ;[35]
  4187.     .byte '_          ;[35] underline
  4188.  
  4189.     .byte '^          ;[35]
  4190.     .byte '~          ;[35] tilde
  4191.  
  4192.     .byte $ff          ;[35] end of table.
  4193.  
  4194.     .ifeq <ftcom-ftappl>
  4195. .SBTTL    Kermit - Apple DOS and File Manager support
  4196.  
  4197. ;
  4198. ;     The following definitions and storage will be used when setting
  4199. ;     up and executing calls to the File manager in DOS.
  4200. ;
  4201.  
  4202. kdvol    =     $aa66          ;[40] Keyboard or default volume
  4203. kddisk    =     $aa68          ;[40] Keyboard or default disk drive
  4204. kdslot    =     $aa6a          ;[40] Keyboard or default slot
  4205. primfn    =     $aa75          ; Filename buffers
  4206. scndfn    =     $aa93          ;         ...
  4207. fmpars    =     $b5bb          ; File manager parameter list address
  4208. opcod    =     fmpars          ; Operation code
  4209. subcod    =     fmpars+1      ; Operation subcode
  4210. reclh    =     fmpars+2      ; Record length (H.O. byte)
  4211. recll    =     fmpars+3      ; Record length (L.O. byte)
  4212. cvol    =     fmpars+4      ; Current volume
  4213. cdisk    =     fmpars+5      ; Current disk drive
  4214. cslot    =     fmpars+6      ; Current slot
  4215. ftype    =     fmpars+7      ; File type
  4216. fnadrl    =     fmpars+8      ; File name address (L.O.)
  4217. fnadrh    =     fmpars+9      ; File name address (H.O.)
  4218. fmrcod    =     fmpars+10      ; File manager return code
  4219. fmwadl    =     fmpars+12      ; File manager work area address (L.O.)
  4220. fmwadh    =     fmpars+13      ; File manager work area address (H.O.)
  4221. tslbfl    =     fmpars+14      ; Track/sector list address (L.O.)
  4222. tslbfh    =     fmpars+15      ; Track/sector list address (H.O.)
  4223. dsbufl    =     fmpars+16      ; Data sector buffer address (L.O.)
  4224. dsbufh    =     fmpars+17      ; Data sector buffer address (H.O.)
  4225. rnumh    =     fmpars+2      ; Record number (H.O.)
  4226. rnuml    =     fmpars+3      ; Record number (L.O.)
  4227. bytofh    =     fmpars+4      ; Byte offset in file (H.O.)
  4228. bytofl    =     fmpars+5      ; Byte offset in file (L.O.)
  4229. rnglnh    =     fmpars+7      ; Range length (H.O.)
  4230. rnglnl    =     fmpars+6      ; Range length (L.O.)
  4231.  
  4232. fncopn    =     $01          ; Open function code
  4233. fncclo    =     $02          ; Close function code
  4234. fncrea    =     $03          ; Read function code
  4235. fncwrt    =     $04          ; Write function code
  4236. fncdel    =    5        ;[78] delete file function code
  4237. fnccat    =    6        ;[78] catalog function code
  4238. fnclck    =    7        ; lock function code
  4239. fnculk    =    8        ; unlock function code
  4240. fncren    =    9        ; rename function code
  4241. fncpos    =     $0a          ; Position function code
  4242. sfntrn    =     $02          ; Trnasfer range of bytes sub-code
  4243. sfnptr    =     $04          ; Position then transfer range sub-code
  4244.  
  4245. dosopn    =     $a3d5          ; DOS open routine address
  4246. dosonc    =     $a2a8          ; DOS open address, no type checking
  4247. dosclo    =     $a2ea          ; DOS close routine address
  4248. dosdel    =     $a263          ; DOS delete routine address
  4249. dosfmn    =     $ab06          ; DOS file manager entry point
  4250. locent    =     $b1c9          ; DOS locate directory entry routine
  4251.  
  4252. doscmi    =     $aa5f          ; DOS comand index - used when calling dosopn
  4253. dosfmg    =    $3d6        ;[78] entry to dos file manager
  4254. dosfmi    =    $3dc        ;[78] entry to dos file mgr initialize
  4255.  
  4256. getln    =    $200        ;[78] address of get line buffer
  4257. ;
  4258. ;     Error codes
  4259. ;
  4260.  
  4261. dsener    =     $00          ; No error
  4262. dsebct    =     $02          ; Bad call type
  4263. dsebst    =     $03          ; Bad sub-call type
  4264. dsewpr    =     $04          ; Write protected
  4265. dseeod    =     $05          ; End-of-data
  4266. dsefnf    =     $06          ; File not found
  4267. dsevmm    =     $07          ; Volume mismatch
  4268. dsedio    =     $08          ; Disk I/O
  4269. dsedfl    =     $09          ; Disk full
  4270. dseflk    =     $0a          ; File locked
  4271.  
  4272. kerfcb    =     $1e          ; Pointer to file control block
  4273.  
  4274. mxdb    =     $7f          ; Maximum DOS buffer size<limit 255>
  4275. mxpfn    =    15        ;[59] max prodos file name length
  4276. mxppth    =    64        ;[59] max prodos path name length
  4277. minslt    =     $01          ;[40] Minimum slot number
  4278. maxslt    =     $07          ;[40] Maximum slot number
  4279. mindrv    =     $01          ;[40] Minimum drive number
  4280. maxdrv    =     $02          ;[40] Maximum drive number
  4281.  
  4282. ;
  4283. ;     Data area
  4284. ;
  4285.  
  4286. ;[78]defslt: .byte $06          ;[40] Default slot for file transfers
  4287. ;[78]defdrv: .byte $01          ;[40] Default drive for file transfers
  4288. ;[78]defvol    .byte    0        ;[60] default vol for file xfers
  4289. defslt: .byte 0          ;[78][40] Default slot for file transfers
  4290. defdrv: .byte 0          ;[78][40] Default drive for file transfers
  4291. defvol    .byte    0        ;[60] default vol for file xfers
  4292. servef    .byte    0        ;[62] server mode default off (0)
  4293. dsbfcc: .byte $00
  4294. dsbind: .byte $00          ; DOS buffer index
  4295. dsbend: .byte $00          ; Current DOS buffer length (last char pointer)
  4296. dosffm: .byte $00          ; 'First file modification done' switch
  4297. dosfni: .byte $00          ; Filename index
  4298. dosfvn: .byte $00          ; File version number for the alter routine
  4299. ;[75]nfcb1    .byte            ;[59] part 1 of 2
  4300. ;[75]fcb1:    .blkb mxppth      ; [59]Fcb for file being transmitted part 2 of 2
  4301. ;[75]    .byte    0        ;[59] terminate string with a null
  4302. ;[75]    .byte    0        ;[59] terminate string with a null
  4303. ;[75]dosbuf: .blkb $100          ; DOS file buffer
  4304. pbasic    =    $be00        ;[59] basic.system
  4305. prodos    =     $bf00        ;[59] prodos entry
  4306. devnum    =    $bf30        ;[80] last vol number
  4307. gfilin    =    $c4        ;[59] prodos get file info
  4308. online    =    $c5        ;[80] online vols
  4309. setpre    =    $c6        ;[59] prodos set prefix call
  4310. getpre    =    $c7        ;[59] prodos get prefix call
  4311. seteof    =    $d0        ;[59] prodos set end of file
  4312. geteof    =    $d1        ;[87] prodos get end of file
  4313. getmk    =    $cf        ;[59] prodos get file mark
  4314. wrfil    =    $cb        ;[59] prodos write
  4315. prdfil    =    $ca        ;[59] prodos read
  4316. peof    =    $4c        ;[59] prodos error end of file
  4317. nofile    =    $46        ;[59] prodos error file not found
  4318. opnfl    =    $c8        ;[59] prodos open file
  4319. clofl    =    $cc        ;[59] prodos close file
  4320. crefil    =    $c0        ;[59] prodos create file
  4321. pdquit    =    $65        ;[84] prodos quit
  4322. pttxt    =    4        ;[59] prodos text type file
  4323. ptibas    =    $fa        ;[59] prodos integer basic type file
  4324. ptbas    =    $fc        ;[59] prodos basic type file
  4325. ptbin    =    6        ;[59] prodos binary type file
  4326. volbuf    =    dosbuf        ;[87] hope we can use this
  4327. pvols    .byte    2        ;[87]
  4328.     .byte    0        ;[87] all the vols
  4329.     .word    volbuf        ;[87] need 256 it says
  4330. ponline    .byte    2        ;[80] get online vol name
  4331. pdvnum    .byte            ;[80] vol #
  4332.     .word    prefix+1    ;[80] where to put name
  4333. propen    .byte    3        ;[59] prodos open par list
  4334.     .word    nfcb1        ;[59] path
  4335.     .word    buffer        ;[59]prodos buffer
  4336. refnu    .byte            ;[59] prodos ref number
  4337. prdwr    .byte    4        ;[59] prodos read write par list
  4338.     .byte            ;[59] ref number
  4339.     .word    dosbuf        ;[59] where were coming/going from/to
  4340.     .word    mxdb        ;[59] how many bytes to read/write
  4341. pnrdwr    .word            ;[59] how many actually got read/written
  4342. pmark    .byte    2        ;[59] prodos mark/eof parameter list
  4343.     .byte            ;[59] ref #
  4344.     .blkb    3        ;[59] number of bytes in file
  4345. pclose    .byte    1        ;[59] prodos close par list
  4346.     .byte            ;[59] ref #
  4347. create    .byte    7        ;[59] -> prodos create parameter list
  4348.     .word    nfcb1        ;[59] pathname
  4349.     .byte     $c3        ;[59] file access
  4350. pfilty    .byte    0        ;[59] file type
  4351. pfilta    .word    0        ;[59] aux type
  4352.     .byte    1        ;[59] storage type
  4353. pcrdat                ;[87] create date
  4354.     .word    0        ;[59] create date
  4355. pcrtim                ;[87] create time
  4356.     .word    0        ;[59] create time
  4357. predel    .byte    1        ;[59] -> prodos delete/prefix par list
  4358.     .word    prefix        ;[59] pathname
  4359. gsinfo    .byte    10        ;[59] get/set file info par list
  4360.     .word    nfcb1        ;[59] path
  4361. gfilac    .byte            ;[59] file access
  4362. gfilty    .byte            ;[59] file type
  4363.     .word            ;[59] aux type
  4364.     .byte            ;[59] storage type
  4365.     .word            ;[59] blocks
  4366.     .word            ;[59] change date
  4367.     .word            ;[59] change time:lsb=min,msb=hr
  4368.     .word            ;[59] create date
  4369.     .word            ;[59] create time:lsb=min,msb=hr
  4370. brkorg                ;[75] break the org here
  4371.     .=$800        ;[75] use this space for buffer
  4372. prdsbl    =    1024        ;[75] prodos buffer len
  4373. maxxlp    =    256        ;[75] max extended packet len
  4374. maxxdl    =    250        ;[75] max extended data len - 6 already out
  4375. buffer    .blkb    prdsbl        ;[75] prodos buffer ******* must start on $x00 *******
  4376. ;[78] ************* begining of keep following in order
  4377. pdbuf    .blkb    maxxlp        ;[75] packet buffer
  4378. pdlen    .blkb    1            ;[75] packet data length
  4379. ptype    .blkb    1            ;[75] type of packet
  4380. pnum    .blkb    1            ;[75] packet number modulo $37
  4381. plnbuf    .blkb    maxxlp        ;[75] line buffer
  4382. pdtend    .blkb    1            ;[75] end pointer
  4383. pdtind    .blkb    1            ;[75] index into buf
  4384. exfg    .blkb    1            ;[75] ex len flag
  4385. hcrc    .blkb    1            ;[75] ex len header crc
  4386. exchs    .blkb    3        ;[75] 3 chs of the ex header
  4387. rpkexx    .blkb    1            ;[75]
  4388.     .blkb    $3b        ;[78] ******* filler *******
  4389. ;[78] ************* end of keep above + nfcb1 in order
  4390. nfcb1    .blkb    1            ;[59] part 1 of 2
  4391. fcb1:    .blkb mxppth      ; [59]Fcb for file being transmitted part 2 of 2
  4392.     .blkb    1        ;[59] terminate string with a null
  4393.     .blkb    1        ;[59] terminate string with a null
  4394. chssvd    .blkb    17        ;[76] saved chs
  4395. dosbuf: .blkb $100          ; DOS file buffer ******* used by prodos
  4396. kicrct    =    dosbuf        ;[81] remote kermit count of cr's
  4397. cmdctr    =    dosbuf+1    ;[81] cmd counter
  4398. cmdlen    =    dosbuf+2    ;[81] length of cmd
  4399. cmdbuf    =    dosbuf+3    ;[81] buffer for command
  4400. ;[76]    *************** begining of zero bytes
  4401. nisc    .blkb    1        ;[76] number of saved chs
  4402. vtcesc    .blkb    1        ;[76] esc flag
  4403. escflg: =    vtcesc        ;[76] Flag indicating we have seen and escape ($1b)
  4404. vtcpnm    .blkb    1        ;[76] param #
  4405. ;[85]vtcpar    .blkb    17    ;[76] params
  4406. vtcpar    .blkb    10        ;[85] params
  4407. ;[85]vtcqmf    .blkb    1        ;[76] vt100 ? flag in esc sequence
  4408. ;[76]    *************** end of zeroing bytes
  4409. tabary    .blkb    80    ;[76] tabs array
  4410. orgend                ;[75] end of buf should be < $1000
  4411.     .=brkorg        ;[75] hope this sets us back
  4412. prefix
  4413.     .byte    0        ;[59] First time we have no prefix
  4414.     .blkb    mxppth+1    ;[59]  "         max 64 chs
  4415. sprerr    .byte    nofile        ;[59] file not found prodos error
  4416.     .byte    dsefnf+$80    ;[59] dos error - must be in pairs
  4417.     .byte    1        ;[59] bad system call #
  4418.     .byte    dsebct+$80    ;[59] bad call type
  4419.     .byte    4        ;[59] bad call parameter count
  4420.     .byte    dsebst+$80    ;[59] bad subtype call
  4421.     .byte     $27        ;[59] i/o error
  4422.     .byte     dsedio+$80    ;[59] disk i/o
  4423.     .byte    $2b        ;[59] disk write protected
  4424.     .byte    dsewpr+$80    ;[59] "
  4425.     .byte    $40        ;[62] invalid pathname
  4426.     .byte    $8b        ;[62]
  4427.     .byte    $45        ;[59] vol not found
  4428.     .byte    dsevmm+$80    ;[59] vol mismatch
  4429.     .byte    $48        ;[59] vol full
  4430.     .byte    dsedfl+$80    ;[59]
  4431.     .byte    $4a        ;[62] incompatible file format(directory)?
  4432.     .byte    $8c        ;[62]
  4433.     .byte    $4c        ;[62] end of file
  4434.     .byte    dseeod+$80        ;[62] "
  4435.     .byte    $4e        ;[59] file access error or file locked
  4436.     .byte    dseflk+$80    ;[59]                       "
  4437.     .byte    $50        ;[62] file already open
  4438.     .byte    $8d        ;[62]
  4439.     .byte    $53        ;[59] invalid system call parameter
  4440.     .byte    dsebct+$80    ;[59] bad call type
  4441. eprerr                ;[59] end of 2 entry error table
  4442. perror    sta    kwrk01        ;[59] prodos error 
  4443.     jsr    crout        ;[59] cr
  4444.     ldx    #erms1g\    ;[59]
  4445.     ldy    #erms1g^    ;[59]
  4446.     jsr    prstr        ;[59] comment about prodos error and address
  4447.     lda    #'$        ;[59]
  4448.     jsr    cout        ;[59] 
  4449.     lda    kwrk01        ;[59] get error code
  4450.     jsr    prbyte        ;[59] and print it
  4451.     lda    #hspace        ;[59]
  4452.     jsr    cout        ;[59]
  4453.     pla            ;[59] get return from stack
  4454.     tax            ;[59]
  4455.     pla            ;[59]
  4456. ;[79]    jsr    prntax        ;[59] print return address
  4457. ;[79]    jsr    crout        ;[59] cr
  4458.     jsr    prntal        ;[79] pr a,x in hex & crlf
  4459.     lda    #0        ;[59] all files
  4460.     sta    pclose+1    ;[59]
  4461.     jsr    prodos        ;[59] close files
  4462.     .byte    clofl        ;[59]
  4463.     .word    pclose        ;[59]
  4464.     ldx   kerosp          ;[59] Get the old stack pointer
  4465.     txs          ;[59]     and restore it
  4466.     lda    kwrk01        ;[59] get the error
  4467.     ldy    #eprerr-sprerr    ;[59] size of table
  4468. perro2    cmp    sprerr-2,y    ;[59] do we have a matching dos msg?
  4469.     beq    perr04        ;[59] yes
  4470.     dey            ;[59]
  4471.     dey            ;[59]
  4472.     bne    perro2        ;[59] are we thru with table? no
  4473.     lda    servef        ;[62] are we in server mode?
  4474.     beq    perr30        ;[62] no
  4475.     lda    #'E        ;[62] yes send error back to remote
  4476.     sta    ptype        ;[62]
  4477.     ldy    #lerm1g+3        ;]62] length of total message
  4478.     sty    pdlen        ;[62]
  4479.     ldx    #erms1g\        ;[62] boiler plate part
  4480.     stx    saddr        ;[62]
  4481.     ldx    #erms1g^        ;[62]
  4482.     stx    saddr+1        ;[62]
  4483.     ldy    #0        ;[62] now to move the message
  4484. perr03    lda    (saddr),y        ;[62]
  4485.     and    #$7f        ;[62] forget about that high bit
  4486.     sta    (kerbf1),y        ;[62] hope srini set this up
  4487.     iny            ;[62]
  4488.     cpy    #lerm1g        ;[62] are we thru
  4489.     bne    perr03        ;[62] no
  4490.     lda    #'$        ;[62] now to tell its hex
  4491.     sta    (kerbf1),y        ;[62]
  4492.     iny            ;[62]
  4493.     lda    kwrk01        ;[62] get the prodos error
  4494.     pha            ;[62] and send it 
  4495.     lsr    a        ;[62]
  4496.     lsr    a        ;[62]
  4497.     lsr    a        ;[62]
  4498.     lsr    a        ;[62]
  4499.     ora    #$b0        ;[62]
  4500.     cmp    #$ba        ;[62]
  4501. ;[76]    bcc    .+4        ;[62] hate to do this
  4502.     bcc    dtpt1        ;[76][62] hate to do this
  4503.     adc    #6        ;[62]
  4504. dtpt1                ;[76]
  4505.     sta    (kerbf1),y        ;[62] first hex ch
  4506.     iny            ;[62]
  4507.     pla            ;[62]
  4508.     and    #$f        ;[62] now for the second hex ch
  4509.     ora    #$b0        ;[62]
  4510.     cmp    #$ba        ;[62] there is a gap between 9 & a
  4511.     bcc    .+4        ;[62] sigh!
  4512.     adc    #6        ;[62]
  4513.     sta    (kerbf1),y        ;[62]
  4514.     jsr    spak        ;[62] finally send msg to rmt
  4515.     jmp    server        ;[62]
  4516. perr30                ;[62]
  4517.     jmp   kermit          ;[59] Go back to top of loop
  4518. perr04    lda    sprerr-1,y    ;[59] get dos error
  4519.     sta    errcod        ;[59] and ready for the comment
  4520.     jmp    stat07        ;[59] use the status rtn
  4521.     .endc
  4522.  
  4523. ;    
  4524. ;    routines for pascal i/o on //e 80 col
  4525. ;
  4526. pin    sta    (basl),y    ;[58] restore rdkey cursor
  4527. ;[71]    lda    #$40        ;[58] tell firmware we are basic input
  4528. ;[71]    ora    mode        ;[58] got to keep video & gotoxy,ignore pascal
  4529. ;[71]    sta    mode        ;[58] but use the pascal rtns
  4530. prent    jsr    pread        ;[58] get keystroke
  4531.     ora    #$80        ;[58] we expect the high bit
  4532.     rts            ;[58]
  4533. pcout                ;[59] got to save a reg
  4534.     pha            ;[59]
  4535.     and    #$7f        ;[58] pascal doesnt want high bit
  4536.     stx    a1h        ;[85] save x since cout restors x
  4537.     sty    a1l        ;[85] save y
  4538. ;[85]    pha            ;[58] now say we are basic output
  4539.     cmp    #cr        ;[59] first lets check for ^S hold
  4540. ;[85]    bne    pcout2        ;[59] not yet
  4541.     bne    pwent        ;[85] not yet
  4542. ;[85]    lda    kbd        ;[59] do we have a key press
  4543.     ldx    kbd        ;[85] do we have a key press
  4544.     bpl    pcout2        ;[59] not yet
  4545. ;[85]    cmp    #hxoff        ;[59] how about a ^S
  4546.     cpx    #hxoff        ;[85] how about a ^S
  4547.     bne    pcout2        ;[59] no must not be a hold screen
  4548.     bit    kbdstr        ;[59] yes, reset keyboard strobe
  4549. ;[85]pcout3    lda    kbd        ;[59] get next keypress
  4550. pcout3    ldx    kbd        ;[85] get next keypress
  4551.     bpl    pcout3        ;[59] not yet
  4552. ;[85]    cmp    #$83        ;[59] yes, now is it a ^C
  4553.     cpx    #$83        ;[85] yes, now is it a ^C
  4554.     beq    pcout2        ;[59] yes, keep the keypress for later
  4555.     bit    kbdstr        ;[59] no, reset strobe throw away keypress
  4556. pcout2                ;[59]
  4557. ;[71]    lda    #$c        ;[58] this is the gotoxy & video flag
  4558. ;[71]    and    mode        ;[58] say we are basic output with gotoxy flag
  4559. ;[71]    sta    mode        ;[58]
  4560. ;[71]    and    #8        ;[58] are we doing gotoxy ?
  4561. ;[71]    beq    pcout0        ;[58] no
  4562. ;[71]    lda    #$20        ;[58] this is the pascal flag
  4563. ;[71]    ora    mode        ;[58] we must till it so gotoxy works ok
  4564. ;[71]    sta    mode        ;[58]
  4565. ;[71]pcout0                ;[58] just a plact to hang ones hat
  4566. ;[85]    pla            ;[58] restore print ch
  4567. ;[85]    stx    a1h        ;[70][58] save x since cout restors x
  4568. ;[85]    sty    a1l        ;[70][58] save y
  4569. ;[85]    cmp    #cr        ;[71] pascal rtn requires a line feed
  4570. ;[85]    bne    pwent        ;[71]
  4571.     pha            ;[71] save the cr
  4572.     lda    #lf        ;[71] and send the lf first
  4573. pwent1    jsr    pwrite        ;[71] output the lf
  4574.     pla            ;[71] get cr back
  4575. pwent    jsr    pwrite        ;[58] pascal rtn
  4576.     pla            ;[59] restore a reg
  4577.     ldy    a1l        ;[70][58] restore
  4578.     ldx    ourcv        ;[58] keep track of the verticle pos
  4579.     stx    cv        ;[58]
  4580.     ldx    a1h        ;[70][58] now all regs are restored
  4581. pcout1    rts        ;[58]
  4582. pcoee    jsr    $c36d        ;[78] stupid rom, leave 
  4583.     tax            ;[78] the window
  4584.     jsr    $ced7        ;[78] alone
  4585.     jmp    $c9f6        ;[78] blah! blah! blah!
  4586. pcoec    ora    #$80        ;[79] leave the window alone
  4587.     ldx    $cfff        ;[86] first free up all of it
  4588.     ldx    $c332        ;[79] get the bank in
  4589. ;[86]    ldx    $cfff        ;[79] all of it
  4590.     tax            ;[79]
  4591.     jsr    $cf59        ;[79] 
  4592.     jmp    $cec8        ;[79]
  4593. pcoeg    jsr    $c38f        ;[79] leave the window alone
  4594.     tax            ;[79]
  4595.     jsr    $ce6c        ;[79]
  4596.     jmp    $c9f0        ;[79]
  4597.  
  4598. ;     apple machine id
  4599. ;rom add -->    $fbb3    $fbbf    $fbc0    $c333    $c35a    $c37c
  4600. ; II        $38
  4601. ; II+        $ea
  4602. ; franklin 1000 $c1     0
  4603. ; //e        $06    $c1    $ea
  4604. ; //e+ enhanced $06    0    $e0    $f0
  4605. ; laser128 2.90    $06             $e0        $00    $13
  4606. ; //c(org)    $06    $ff    $00
  4607. ; //c(3.5)    $06    $00    $00
  4608. ; //c(v3)    $06    $03    $00    $c2
  4609. ; //c+        $06    $04    $00    $c2
  4610. ; //gs        $06    0    $e0            $8f
  4611. ; to distinguish the gs from the e+
  4612. ;    sec
  4613. ;    jsr    $fe1f
  4614. ;    bcc    gs
  4615. ;
  4616. ;     prodos address $bf98
  4617. ; II,II+,//e    bit 3 = 0
  4618. ; others    bit 3 = 1
  4619. ; //c        bits 7,6 = 10
  4620. test2h    jmp    home        ;[79][68] clear screen for every one & rtn
  4621. test2e    lda    $fbb3        ;[58] is this a //e
  4622.     cmp    #6        ;[58]
  4623.     bne    test2h        ;[68][58] no
  4624.     lda    dsptyp        ;[58] is it //e 80 col ?
  4625.     bpl    test2h        ;[68][58] no
  4626.     lda   dsp2          ;[61] get slot number for pr#n
  4627.     sta    itse80        ;[86] ist //e or better in 80 col
  4628.     jsr   setio2+2          ;[61]
  4629.     jsr    home        ;[61] let basic initialize 2e 80 col
  4630.     lda    #pcout^        ;[58] change the cout
  4631.     sta    cswh        ;[58] routine
  4632.     lda    #pcout\        ;[58]
  4633.     sta    cswl        ;[58]
  4634.     lda    #pin^        ;[58] set up the read also
  4635.     sta    kswh        ;[58] reads will go to pin
  4636.     lda    #pin\        ;[58]
  4637.     sta    kswl        ;[58]
  4638.     lda    pvect        ;[59]set up the pascal initilize jmp
  4639.     sta    pient+1        ;[59]
  4640.     lda    pvect+1        ;[59] now for the read entry
  4641.     sta    prent+1        ;[59]
  4642.     lda    pvect+2        ;[59] now for the write entry
  4643.     ldx    #pwrite^    ;[78] stupid enhanced rom
  4644.     ldy    $fbc0        ;[78]
  4645.     bne    itsnac        ;[79] its not a //c
  4646.     ldy    $c333        ;[79] just another
  4647.     cpy    #$c2        ;[79] check
  4648.     bne    test23        ;[79] different //c rom?????????
  4649.     ldx    #pcoec^        ;[79] get around the reset
  4650.     lda    #pcoec\        ;[79] region
  4651.     jmp    test23        ;[79] thats all
  4652. itsnac                ;[79]
  4653.     cpy    #$e0        ;[78] is this enhanced //e ?
  4654.     bne    test23        ;[78] no
  4655.     ldy    $c37c        ;[79] maybe, try //gs first
  4656.     cpy    #$8f        ;[79]
  4657.     bne    itsnag        ;[79] its not a //gs
  4658.     sty    kpfl        ;[80] tell we have the keypad
  4659.     ldx    #pcoeg^        ;[79]
  4660.     lda    #pcoeg\        ;[79] //gs address
  4661.     jmp    test23        ;[79]
  4662. itsnag                ;[79]
  4663.     ldy    $c35a        ;[78] one final check for the e+
  4664.     cpy    #$f0        ;[78] hope the rom versions stay the same
  4665.     bne    test23        ;[78]
  4666.     ldx    #pcoee^        ;[78] yes skip redoing the windows
  4667.     lda    #pcoee\        ;[78]
  4668. test23                ;[78]
  4669.     stx    pwent+2        ;[78] 80 col better be slot 3
  4670.     stx    pwent1+2    ;[78] sigh!!
  4671.     sta    pwent+1        ;[59]
  4672.     sta    pwent1+1    ;[71]
  4673. ;[76]pient    jmp    pinit        ;[58] now initilize pascal rtns
  4674. pient    jsr    pinit        ;[76][58] now initilize pascal rtns
  4675.     lda    vtmod        ;[76]
  4676.     cmp    #1        ;[76] is this vt52?
  4677.     beq    pient2        ;[76] yup
  4678.     cmp    #2        ;[76] how about vt100
  4679.     bne    pientr        ;[76] no
  4680. pient2    lda    mode        ;[76] use xparent so windowing will work
  4681.     ora    #1        ;[76]
  4682.     sta    mode        ;[76]
  4683. pientr    rts            ;[76] thats all folks
  4684. ;[78]dfsv    lda    #27        ;[69] wait a few seconds
  4685. dfsv    lda    #54        ;[78] wait a few seconds
  4686.     sta    kwrk01        ;[69] so operator can read any messages
  4687. dfsv3    lda    #125        ;[85] 1 ms at a time
  4688.     sta    kwrk02        ;[85] hope this is available
  4689. ;[78]test2l    lda    #255        ;[69] 255 ms
  4690. ;[85]test2l    lda    #220        ;[78] 125 ms
  4691. test2l    lda    timect        ;[85] 125 ms
  4692.     jsr    wait        ;[69]
  4693.     lda    kbd        ;[73] allow any keypress to exit also
  4694.     bmi    test27        ;[73]
  4695.     dec    kwrk02        ;[85]
  4696.     bne    test2l        ;[85]
  4697.     dec    kwrk01        ;[69] all 7 secs?
  4698. ;[85]    bne    test2l        ;[69]
  4699.     bne    dfsv3        ;[85]
  4700. test27    rts            ;[73][69] thats all
  4701. sucout    lda    #0        ;[78] assume 40 col
  4702.     ldy    #40        ;[78] set the window width correctly
  4703.     ldx   dsptyp          ;[78] get display type
  4704.     bpl   kstar1          ;[78] is this 80 col?,no
  4705.     ldy    #80        ;[78] just in case card doesnt
  4706.     lda   dsp2          ;[78] get slot number for pr#n
  4707. kstar1:              ;[78]
  4708.     sty    wndwth        ;[78] set this
  4709.     jsr   setio2+2          ;[78] DOS does not interfere with Kermit
  4710.     jmp    test2e        ;[78] test for //e 80 co1 & rts
  4711.  
  4712. .SBTTL    Kermit initialization
  4713.  
  4714. ;
  4715. ;     The following code sets up Kermit-65 for normal operation.
  4716. ;
  4717.  
  4718. kstart: jsr   setio1          ;[1] Set I/O hooks appropriately so that
  4719.     lda    #0        ;[49] just in case a pr#0
  4720.     sta    $c000        ;[58] //e 80store off
  4721.     sta    $c002        ;[58] "   read main mem
  4722.     sta    $c004        ;[58] "  write main mem
  4723.     sta    $c008        ;[58] main mem stack & z.p.
  4724.     sta    $c051        ;[58] text mode on
  4725.     sta    $c054        ;[58] page 1
  4726. ;[81]    sta   kerins      ;[75][47] make sure we initialize
  4727.     sta    servef        ;[75][62] and get out of server mode
  4728. ;[80]    sta    dosflg        ;[75][59] assume dos 3.3
  4729.     sta    kerrki        ;[78] allow initialization each time
  4730. ;[78]    ldy    #40        ;[78] set the window width correctly
  4731. ;[78]    ldx   dsptyp          ;[49] get display type
  4732. ;[78]    bpl   kstar1          ;[49] is this 80 col?,no
  4733. ;[78]    lda    #80        ;[76] just in case card doesnt
  4734. ;[78]    ldy    #80        ;[78][76] just in case card doesnt
  4735. ;[78]    sta    wndwth        ;[76] set this
  4736. ;[78]    lda   dsp2          ;[49] get slot number for pr#n
  4737. ;[78]kstar1:              ;[49]
  4738. ;[78]    sty    wndwth        ;[78] set this
  4739. ;[78]    jsr   setio2+2          ;[49][1] DOS does not interfere with Kermit
  4740. ;[78]    jsr    test2e        ;[58] test for //e 80 co1
  4741.     jsr    sucout        ;[78] set up cout
  4742. ;[68]    jsr    home        ; start by clearing screen
  4743. ;[87]    lda    #0        ;[64]
  4744. ;[87]    pha            ;[64]
  4745. ;[87]    pha            ;[87]
  4746. ;[87]    lda    #cv2lp        ;[64] convert sec to loops thru getc
  4747. ;[87]    pha            ;[64]
  4748. ;[87]    lda    #0        ;[64]
  4749. ;[87]    pha            ;[64]
  4750. ;[87]    pha            ;[87]
  4751. ;[87]    lda    rtime        ;[64] rec timeout in seconds
  4752. ;[87]    pha            ;[64]
  4753. ;[87]    jsr    mul16        ;[64] now for the multiply
  4754. ;[87]    pla            ;[64]
  4755. ;[87]    sta    lpcycl        ;[64] answer in here
  4756. ;[87]    pla            ;[64]
  4757. ;[87]    sta    lpcycl+1    ;[64]
  4758. ;[87]    pla            ;[87] throw away msb
  4759.     jsr    cvs2lp        ;[87] convert seconds to loops
  4760.     ldx   #versio\      ; Get Low order byte of version message
  4761.     ldy   #versio^      ; And H.O. byte
  4762. ;[79]    jsr   prstr          ; Print the version
  4763. ;[79]    jsr   prcrlf          ; Print a crlf
  4764.     jsr    prstrl        ;[79]
  4765.     .ifeq    funkey        ;[73]
  4766.     ldy    #$ff        ;[73] got to check and see if game plug exists
  4767.     lda    $fbb3        ;[73] how about //e or c
  4768.     cmp    #6        ;[73]
  4769.     beq    kstar9        ;[73] yes switches are built in
  4770.     sty    $c070        ;[73] first reset timing circut
  4771. kstar7    lda    $c064        ;[73] now check for decay
  4772.     bpl    kstar9        ;[73] if hi bit drops we must have game plug
  4773.     dey            ;[73] give it lots of time
  4774.     bne    kstar7        ;[73] thru,no
  4775. kstar9    sty    usfkey        ;[73] tell if we can check for funct keys
  4776.     .endc            ;[73]
  4777.     .ifeq <ftcom-ftappl>
  4778. ;[80]    lda    herrpt        ;[75] only do this once (it says here)
  4779. ;[80]    ora    herrpt+1    ;[75]
  4780.     lda    hsoftv+1        ;[80] only do this once (it says here)
  4781. ;[80]    bne    kstara        ;[75] only once
  4782.     beq    kstarb        ;[80] unable to make the long jump
  4783.     jmp    kstara        ;[80]
  4784. kstarb                ;[80]
  4785.     sta    dosflg        ;[80] assume dos 3.3
  4786.     lda    softvc        ;[75] save the soft vector
  4787.     sta    hsoftv        ;[75]
  4788.     lda    softvc+1    ;[75]
  4789.     sta    hsoftv+1    ;[75]
  4790.     lda    #theend\    ;[57] setup reset for monitor stop
  4791.     sta    softvc        ;[57]
  4792.     lda    #theend^    ;[57]
  4793.     sta    softvc+1    ;[57]
  4794.     jsr    warmst        ;[57] so we wont do a cold start
  4795.     lda    tl0end+1    ;[87] init screen save
  4796.     clc            ;[87] now for the end of 1920 bytes
  4797.     adc    #1920^        ;[87]
  4798.     sta    escsv+1        ;[87] for the next block of memory
  4799.     lda    tl0end        ;[87]
  4800.     clc            ;[87]
  4801.     adc    #1920\        ;[87]
  4802.     sta    escsv        ;[87]
  4803.     bcc    .+5        ;[87] did we carry?
  4804.     inc    escsv+1        ;[87] yup its one more
  4805. ;[80]    lda   errptr          ; Move DOS vectors to a hold area
  4806. ;[80]    sta   herrpt          ;         ...
  4807. ;[80]    lda   errptr+1      ;         ...
  4808. ;[80]    sta   herrpt+1      ;         ...
  4809. ;[80]    lda   basws          ;         ...
  4810. ;[80]    sta   hbasws          ;         ...
  4811. ;[80]    lda   basws+1          ;         ...
  4812. ;[80]    sta   hbasws+1      ;         ...
  4813. ;[80]    lda   #nonftl\      ; Point dos error handler pointer
  4814. ;[80]    sta   errptr          ;     at our error routine
  4815. ;[80]    lda   #nonftl^      ;         ...
  4816. ;[80]    sta   errptr+1      ;         ...
  4817. ;[80]    lda   #nonftl\      ; Point basic warmstart at us
  4818. ;[80]    sta   basws          ;         ...
  4819. ;[80]    lda   #nonftl^      ;         ...
  4820. ;[80]    sta   basws+1          ;         ...
  4821. ;[80]kstara                ;[75]
  4822. ;[75]    lda   #0      ;[47] we must go thru init at least once
  4823. ;[75]    sta   kerins      ;[47]
  4824. ;[75]    sta    servef        ;[62] and get out of server mode
  4825. ;[75]    sta    dosflg        ;[59] assume dos 3.3
  4826.     lda    #$8d        ;[59] lets look and see if 3.3 open rtn
  4827.     cmp    dosopn        ;[59] should be a "sta b5c2"
  4828.     bne    kstar2        ;[59] its prodos
  4829.     lda    #$c2    ;[59] maybe prodos
  4830.     cmp    dosopn+1        ;[59] well
  4831.     bne    kstar2        ;[59] its prodos
  4832.     lda    #$b5    ;[59] final chance
  4833.     cmp    dosopn+2        ;[59]
  4834. ;[78]    beq    kstar3        ;[59] as i said before its 3.3
  4835.     bne    kstar2        ;[78] its prodos
  4836. ;[84]    lda   errptr          ;[80] Move DOS vectors to a hold area
  4837. ;[84]    sta   herrpt          ;[80]         ...
  4838. ;[84]    lda   errptr+1      ;[80]         ...
  4839. ;[84]    sta   herrpt+1      ;[80]         ...
  4840. ;[84]    lda   basws          ;[80]         ...
  4841. ;[84]    sta   hbasws          ;[80]         ...
  4842. ;[84]    lda   basws+1          ;[80]         ...
  4843. ;[84]    sta   hbasws+1      ;[80]         ...
  4844. ;[84]    lda   #nonftl\      ;[80] Point dos error handler pointer
  4845. ;[84]    sta   errptr          ;[80]     at our error routine
  4846. ;[84]    lda   #nonftl^      ;[80]         ...
  4847. ;[84]    sta   errptr+1      ;[80]         ...
  4848. ;[84]    lda   #nonftl\      ;[80] Point basic warmstart at us
  4849. ;[84]    sta   basws          ;[80]         ...
  4850. ;[84]    lda   #nonftl^      ;[80]         ...
  4851. ;[84]    sta   basws+1          ;[80]         ...
  4852. ;[80]    lda    defslt        ;[78]
  4853. ;[80]    ora    defdrv        ;[78]
  4854. ;[80]    bne    kstar3        ;[78] the default is already set
  4855.     lda    kdslot        ;[78] no use dos 3.3 setings
  4856.     sta    defslt        ;[78]
  4857.     lda    kddisk        ;[78]
  4858.     sta    defdrv        ;[78]
  4859.     lda    kdvol        ;[78] and finally the vol
  4860.     sta    defvol        ;[78]
  4861.     jmp    kstar3        ;[78]
  4862. ;[80]kstarp    stx    kwrk01        ;[78] routine to field output from basic.system
  4863. ;[80]    ldx    prefix        ;[78] have we found the leading / ?
  4864. ;[80]    bne    kstarq        ;[78] yes
  4865. ;[80]    cmp    #'/+$80        ;[78] no, do we have one now
  4866. ;[80]    bne    kstarr        ;[78] no just return waiting for one
  4867. ;[80]kstarq    cmp    #hcr        ;[78] throw away these
  4868. ;[80]    beq    kstarr        ;[78]
  4869. ;[80]    sta    prefix+1,x    ;[78] save the prefix from basic.system
  4870. ;[80]    inc    prefix        ;[78] and tell how many
  4871. ;[80]kstarr    ldx    kwrk01        ;[78] now restore x
  4872. ;[80]    rts            ;[78]
  4873. kstar2    sta    dosflg        ;[59] say its prodos
  4874.     lda    prefix        ;[62] does user have a prefix already??
  4875.     bne    kstar4        ;[62] yes use his
  4876. ;[80]    lda    cswh        ;[78] interupt cout
  4877. ;[80]    pha            ;[78]
  4878. ;[80]    lda    #kstarp^    ;[78]
  4879. ;[80]    sta    cswh        ;[78] with our routine
  4880. ;[80]    lda    cswl        ;[78]
  4881. ;[80]    pha            ;[78]
  4882. ;[80]    lda    #kstarp\    ;[78]
  4883. ;[80]    sta    cswl        ;[78]
  4884. ;[80]    ldx    prefsz        ;[78]
  4885. ;[80]    lda    #hcr        ;[78] terminate it
  4886. ;[80]    sta    getln,x        ;[78]
  4887. ;[80]kstloo    lda    prefsz,x    ;[78] move command
  4888. ;[80]    sta    getln-1,x    ;[78] to get line for basic.system
  4889. ;[80]    dex            ;[78]
  4890. ;[80]    bne    kstloo        ;[78]
  4891. ;[80]    jsr    pbasic+3    ;[78] let basic system put out prefix
  4892. ;[80]    ldx    prefix        ;[78]
  4893. ;[80]    lda    #0        ;[78] null terminate the prefix for listing
  4894. ;[80]    sta    prefix+1,x    ;[78]
  4895. ;[80]    pla            ;[78]
  4896. ;[80]    sta    cswl        ;[78] now restore cout
  4897. ;[80]    pla            ;[78]
  4898. ;[80]    sta    cswh        ;[78]
  4899.     jsr    prodos        ;[62] no see if there is one?
  4900.     .byte    getpre        ;[62] get prefix
  4901.     .word    predel        ;[62] 
  4902.     bcc    .+5        ;[62] good call? yes
  4903.     jsr    perror        ;[62] no
  4904.     ldy    prefix        ;[62] got to null terminate the string
  4905.     beq    kstarc        ;[80] no prefix try for vol name
  4906.     lda    #0        ;[62]
  4907.     sta    prefix+1,y        ;[^2]
  4908.     jmp    kstar3
  4909. kstarc                ;[80]
  4910.     lda    devnum        ;[80] thanks to sean nolan
  4911.     sta    pdvnum        ;[80] for this code, we have brun vol #
  4912.     jsr    prodos        ;[80] get vol name
  4913.     .byte    online        ;[80]
  4914.     .word    ponline        ;[80]
  4915.     bcc    .+5        ;[80] good call? yes
  4916.     jsr    perror        ;[80] no
  4917.     lda    prefix+1    ;[80] get count
  4918.     and    #$f        ;[80]
  4919.     tax            ;[80]
  4920.     inx            ;[80] one more for the /
  4921.     stx    prefix        ;[80] this is the total count
  4922.     lda    #'/        ;[80] start the vol name 
  4923.     sta    prefix+1    ;[80] with a / so its now a prefix
  4924. kstar4                    ;[62]
  4925.     jsr    prodos        ;[59] set the prefix
  4926.     .byte    setpre        ;[59]
  4927.     .word    predel        ;[59]
  4928.     bcc    kstar3        ;[59] good call? yes
  4929.     jsr    perror        ;[59] no sigh!
  4930. kstar3                ;[59]
  4931.     .endc
  4932.     tsx          ;[67] Get the stack pointer
  4933.     stx   kerosp          ;[67]     and save it in case of a fatal error
  4934. kstara                ;[80] end of one time stuff
  4935.     .ifeq    termnl        ;[73] is this terminal pgm?
  4936.     jsr    shvt        ;[73] tell the user about
  4937.     jsr    shfw        ;[73] some of the
  4938.     jsr    shddsk        ;[73] defaults
  4939.     jsr    shbaud        ;[73]
  4940.     jsr    shswp        ;[73]
  4941.     jsr    dfsv        ;[77] let the operator look at it
  4942.     jsr    telne3        ;[73] yes start out immeadiately with connect
  4943.     .endc            ;[73]
  4944.     .ifne    termnl        ;[73] otherwise carry on normaly
  4945.     jsr    vtccom        ;[76] start vt100 with clean start
  4946.     jsr    clrfcb        ;[83] clear fcb for dos,for kermit.init
  4947.     ldy    #kercmd-kerinn-1 ;[83] now for the size of the file name - null
  4948.     sty    nfcb1        ;[83]
  4949. kerin2    lda    kerinn-1,y    ;[83] now move the file name to fcb1
  4950.     sta    fcb1-1,y    ;[83]
  4951.     dey            ;[83]
  4952.     bne    kerin2        ;[83] are we thru? no
  4953.     jsr   kermit          ; Go execute kermit
  4954.     .endc            ;[73]
  4955.     .ifeq <ftcom-ftappl>
  4956.     lda    dosflg        ;[59]prodos?
  4957.     beq    .+5        ;[59] no
  4958.     jmp    pbasic        ;[59] restart basic
  4959.     jmp   dos          ; Restart dos
  4960.     .endc
  4961. theend    brk          ; Break
  4962.  
  4963.  
  4964. .SBTTL    Kermit - main routine
  4965.  
  4966. ;
  4967. ;     This routine is the main KERMIT loop. It prompts for commands
  4968. ;     and then it dispatches to the appropriate routine.
  4969. ;
  4970.  
  4971. kermit:        ;[67]tsx    ; Get the stack pointer
  4972.         ;[67]stx   kerosp  ;and save it in case of a fatal error
  4973.     ldx   #prmt\          ;[13] Fetch the address of the prompt
  4974.     ldy   #prmt^          ;[13]     for Comnd routines
  4975.     lda   #cmini          ; Argument for comnd call
  4976.     jsr   comnd          ; Set up the parser and print the prompt
  4977. kermt0                ;[81]
  4978.     jsr    kerini        ;[78] read the initialize file
  4979.     lda   #kercmd\      ; L.O. byte addr of command table
  4980.     sta   cminf1          ; Stuff it
  4981.     lda   #kercmd^      ; H.O. byte addr of command table
  4982.     sta   cminf1+1      ; Stuff that too
  4983. ;[85]    lda   #kerhlp\      ; L.O. byte addr of help text
  4984. ;[85]    sta   cmhptr          ; Store it in help pointer
  4985. ;[85]    lda   #kerhlp^      ; H.O. byte addr of help text
  4986. ;[85]    sta   cmhptr+1      ; Store H.O. byte
  4987.     ldy   #$00          ;[13] No special flags needed
  4988.     lda   #cmkey          ; Set up for keyword parse
  4989.     jsr   comnd          ; Try to parse it
  4990.           jmp     kermt2          ; Failed
  4991. xjmp    stx    xjmp1+1        ;[82] set up jmp address
  4992.     sty    xjmp1+2        ;[82]
  4993. xjmp1    jmp    xjmp1        ;[82] now do it
  4994. ;[81]    lda   #kermtb\      ;[9] Get the L.O. byte of jump table
  4995. ;[81]    sta   jtaddr      ;[9]
  4996. ;[82]    ldy   #kermtb\      ;[9] Get the L.O. byte of jump table
  4997. ;[82]    lda   #kermtb^      ;[9] Get the H.O. byte
  4998. ;[82]    jmp    indexj        ; its easier this way
  4999. ;[82]kermtb: jmp   telnet          ; Connect command
  5000. ;[82]    jmp   exit          ; Exit command
  5001. ;[82]    jmp   help          ; Help command
  5002. ;[82]    jmp   log          ; Log command
  5003. ;[82]    jmp   exit          ; Quit command
  5004. ;[82]    jmp   receve          ; Receive command
  5005. ;[82]    jmp   send          ; Send command
  5006. ;[82]    jmp   setcom          ; Set command
  5007. ;[82]    jmp   show          ; Show command
  5008. ;[82]    jmp   status          ; Status command
  5009. ;[82]    jmp   bye          ;[14] Shut and logout remote server command
  5010. ;[82]    jmp   finish          ;[14] Shut remote server
  5011. ;[82]    jmp   getfrs          ;[14] Get file from remote server
  5012. ;[82]    jmp    server        ;[62] server mode
  5013. ;[82]kercat    jmp    catlog        ;[78] catalog command
  5014. ;[82]kerdil    jmp    modem        ;[78] modem command
  5015. ;[82]kerdlf    jmp    deletf        ;[78] delete file command
  5016. ;[82]kerrmt    jmp    remote        ;[81] remote command
  5017. kermt2: ldx   #ermes1\      ; L.O. byte of error message
  5018.     ldy   #ermes1^      ; H.O. byte of error message
  5019. ;[83]    jsr   prstr          ; Print the error
  5020. ;[83]    jmp   kermit          ; Go back
  5021.     jmp    kermtx        ;[83] thats all
  5022. kermt3: ldx   #ermes3\      ; L.O. byte of error
  5023.     ldy   #ermes3^      ; H.O. byte of error
  5024. ;[83]    jsr   prstr          ; Print it
  5025. ;[83]    jmp   kermit          ; Try again
  5026.     jmp    kermtx        ;[83] thats all
  5027. kermt4: ldx   #ermes4\      ; L.O. byte of error
  5028.     ldy   #ermes4^      ; H.O. byte of error
  5029. ;[83]    jsr   prstr          ; Print the text
  5030. ;[83]    jmp   kermit          ; Try again
  5031.     jmp    kermtx        ;[83] thats all
  5032. kermt5: ldx   #ermes6\      ; L.O. byte of error
  5033.     ldy   #ermes6^      ; H.O. byte of error
  5034. ;[83]    jsr   prstr          ; Print error text ('keyword')
  5035. ;[83]    jmp   kermit          ; Start at the beginning again
  5036.     jmp    kermtx        ;[83] thats all
  5037. kermt6: ldx   #ermes7\      ; L.O. byte of error
  5038.     ldy   #ermes7^      ; H.O. byte of error message
  5039. ;[83]    jsr   prstr          ; Print the error message ('file spec')
  5040. ;[83]    jmp   kermit          ;     and try again
  5041.     jmp    kermtx        ;[83] thats all
  5042. kermt7: ldx   #ermes8\      ; L.O. byte of error message text
  5043.     ldy   #ermes8^      ; H.O. byte of error message
  5044. ;[83]    jsr   prstr          ; Print it ('integer')
  5045. ;[83]    jmp   kermit          ; Try for another command line
  5046.     jmp    kermtx        ;[83] thats all
  5047. kermt8: ldx   #ermes9\      ; L.O. byte of error
  5048.     ldy   #ermes9^      ; H.O. byte of error
  5049. ;[83]    jsr   prstr          ; Print the message ('switch')
  5050. ;[83]    jmp   kermit          ; Go back to top of loop
  5051.     jmp    kermtx        ;[83] thats all
  5052. kermt9: ldx   #ermesa\      ;[12] L.O. byte of error message text
  5053.     ldy   #ermesa^      ;[12] H.O. byte of error message
  5054. ;[83]    jsr   prstr          ;[12] Print message ('invalid device driver')
  5055. ;[83]    jmp   kermit          ;[12] Go back to top of loop
  5056.     jmp    kermtx        ;[83] thats all
  5057. kermta: ldx   #ermesb\      ;[13] L.O. byte of error message text
  5058.     ldy   #ermesb^      ;[13] H.O. byte of error message
  5059. ;[83]    jsr   prstr          ;[13] Print message ('null string found')
  5060. ;[83]    jmp   kermit          ;[13] Go back to top of loop
  5061.     jmp    kermtx        ;[83] thats all
  5062. kerrtn    rts            ;[78]
  5063. svcmd    stx    cminb0+1    ;[81] rather than reading keyboard
  5064.     sty    cminb0+2    ;[81]
  5065.     rts            ;[81]
  5066. rscmd    lda    #rdkey\        ;[81] restore cminb0
  5067.     sta    cminb0+1    ;[81] to read from the keyboard
  5068.     lda    #rdkey^        ;[81]
  5069.     sta    cminb0+2    ;[81]
  5070.     rts            ;[81]
  5071. kerini    lda    kerrki        ;[78] are we reading the init file?
  5072.     beq    kerin1        ;[78] just starting
  5073.     cmp    #1        ;[78] are we trying to open
  5074.     bne    kerrtn        ;[78] no, just keep reading kermit.ini or keyboard
  5075.     jsr    kerin9        ;[78] yes and failing
  5076.     ldx    kerosp        ;[78] restore stack pointer
  5077.     txs            ;[78] keep the stack straight
  5078.     jsr    setio1        ;[78] stop dos 3.3
  5079.     lda    #24        ;[78] wait 3 sec for viewer
  5080.     sta    kwrk01        ;[78]
  5081. kerint    lda    #125        ;[85] 125 ms
  5082.     sta    kwrk02        ;[85] 1 ms at a time
  5083. ;[85]kerina    lda    #220        ;[78]
  5084. kerina    lda    timect        ;[85]
  5085.     jsr    wait        ;[78]
  5086.     dec    kwrk02        ;[85]
  5087.     bne    kerina        ;[85]
  5088.     dec    kwrk01        ;[78] thru?
  5089. ;[85]    bne    kerina        ;[78] no
  5090.     bne    kerint        ;[85] no
  5091.     jsr    sucout        ;[78] stop dos 3.3
  5092.     jmp    kermit        ;[78] around we go again
  5093. ;[81]kerin1    lda    #kerin3\    ;[78] set command reader to go here
  5094. ;[81]    sta    cminb0+1    ;[78] rather than reading keyboard
  5095. ;[81]    lda    #kerin3^    ;[78]
  5096. ;[81]    sta    cminb0+2    ;[78]
  5097. kerin1    ldx    #kerin3\    ;[81]
  5098.     ldy    #kerin3^    ;[81]
  5099.     jsr    svcmd        ;[81] redirect cmd reader
  5100.     inc    kerrki        ;[78] say were trying to open
  5101. ;[83]    jsr    clrfcb        ;[78] clear fcb for dos
  5102. ;[83]    ldy    #kercmd-kerinn-1 ;[78] now for the size of the file name - null
  5103. ;[83]    sty    nfcb1        ;[78]
  5104. ;[83]kerin2    lda    kerinn-1,y    ;[78] now move the file name to fcb1
  5105. ;[83]    sta    fcb1-1,y    ;[78]
  5106. ;[83]    dey            ;[78]
  5107. ;[83]    bne    kerin2        ;[78] are we thru? no
  5108.     jsr    prcrlf        ;[78]
  5109.     ldx    #kerinm\    ;[78] tell what
  5110.     ldy    #kerinm^    ;[78] were going to do
  5111. ;[83]    jsr    prstr        ;[78]
  5112. ;[83]    ldx    #kerinn\    ;[78] now for the
  5113. ;[83]    ldy    #kerinn^    ;[78] file name
  5114. ;[79]    jsr    prstr        ;[78]
  5115. ;[79]    jsr    prcrlf        ;[78]
  5116.     jsr    prstrl        ;[79]
  5117.     jsr    opentf        ;[78] save current and open text file
  5118.     inc    kerrki        ;[78] if we get here its a good open so tattle
  5119.     rts            ;[78]
  5120. kerin3    jsr    fgetc        ;[78] get a ch from file
  5121.     jmp    kerin9        ;[78] eof return
  5122.     ora    #$80        ;[78] make sure its negative ascii
  5123. kerin5    rts            ;[78] got a ch give it to cminb0
  5124. kerin7    lda    kerrki        ;[78] have we already closed
  5125.     cmp    #3        ;[78] should be>2
  5126.     bcs    kerin5        ;[78]
  5127. kerin9    jsr    clostf        ;[78] close file and restore filmod
  5128. ;[81]    lda    #rdkey\        ;[78] restore cminb0
  5129. ;[81]    sta    cminb0+1    ;[78] to read from the keyboard
  5130. ;[81]    lda    #rdkey^        ;[78]
  5131. ;[81]    sta    cminb0+2    ;[78]
  5132.     jsr    rscmd        ;[81] restore cmd reader
  5133.     sta    kerrki        ;[78] say weve read kermit.ini > 2
  5134. ;[85]    lda    #hesc        ;[78] give cminb0 the last ch
  5135.     lda    #hctrlu        ;[85] give cminb0 the last ch
  5136.     rts            ;[78] thats all folks
  5137. opentf    lda    filmod        ;[78] save current file
  5138.     sta    kersft        ;[78] file type
  5139.     lda    #0        ;[78] set file type = text
  5140.     sta    filmod        ;[78]
  5141.     lda    #fncrea        ;[78] say we are reading
  5142.     jsr    openf        ;[78] try to open the file
  5143.     rts            ;[78]
  5144. clostf    lda    #1        ;[78] say were reading
  5145.     jsr    closef        ;[78] close the text file
  5146.     lda    kersft        ;[78] now restore current file type
  5147.     sta    filmod        ;[78]
  5148.     rts            ;[78]
  5149. telcom    jsr    test2e        ;[85] clear the screen & allow windowing
  5150.     ldx   #inf01a\      ;[85] Get address of first half of message
  5151.     ldy   #inf01a^      ;[85]         ...
  5152.     jsr   prstr          ;[85] Print it out
  5153.     lda   escp          ;[85] Get the 'break connection' character
  5154.     jsr   prchr          ;[85] Print that as a special character
  5155.     ldx   #inf01b\      ;[85] Get address of second half of message
  5156.     ldy    confg        ;[85]
  5157.     sty    flowfg        ;[85] now set up flow flag
  5158.     ldy   #inf01b^      ;[85]         ...
  5159.     jsr    prstrl        ;[85]
  5160.     jmp    sutljp        ;[85] set up screen distributor
  5161.  
  5162.  
  5163. .SBTTL    Telnet routine
  5164.  
  5165. ;
  5166. ;     This routine handles the connect command. After connecting
  5167. ;     to a host system, this routine alternates calling routines
  5168. ;     which will pass input from the port to the screen and pass
  5169. ;     output from the keyboard to the port. This kermit will
  5170. ;     ignore all characters until it sees and assigned escape
  5171. ;     character.
  5172. ;
  5173. ;         Input:     NONE
  5174. ;
  5175. ;         Output:     NONE
  5176. ;
  5177. ;         Registers destroyed:     A,X,Y
  5178. ;
  5179.  
  5180. telnet: ;[74]sta   ksavea      ;[12] Save the AC so it isn't destroyed
  5181.     jsr   prcfm          ; Parse and print a confirm
  5182. telne3                ;[73] place for terminal to begin
  5183.     jsr    kerin7        ;[78] just in case were reading kermit.ini
  5184. ;[85]    jsr    test2e        ;[76] clear the screen & allow windowing
  5185. ;[85]    ldx   #inf01a\      ; Get address of first half of message
  5186. ;[85]    ldy   #inf01a^      ;         ...
  5187. ;[85]    jsr   prstr          ; Print it out
  5188. ;[85]    lda   escp          ; Get the 'break connection' character
  5189. ;[85]    jsr   prchr          ; Print that as a special character
  5190. ;[85]    ldx   #inf01b\      ; Get address of second half of message
  5191. ;[85]    ldy    confg        ;[76]
  5192. ;[85]    sty    flowfg        ;[76] now set up flow flag
  5193. ;[85]    ldy   #inf01b^      ;         ...
  5194. ;[76]    sty    confg        ;[57] say we are talking to a remote
  5195. ;[79]    jsr   prstr          ; Print that
  5196. ;[79]    jsr   prcrlf          ;     and a crelf
  5197. ;[85]    jsr    prstrl        ;[79]
  5198. ;[85]    jsr    sutljp        ;[85] set up screen distributor
  5199.     jsr    telcom        ;[85] common code
  5200. ;[81]    jsr   tlinit      ;[47] initialize the serial port
  5201.     jsr    comint        ;[81] common init
  5202. ;[87]    bne    ch0lup        ;[58] good init so go ahead
  5203. ;[81]    jsr    u2icc        ;[62] tell someone
  5204. ;[81]    jmp   kermit        ;[58] failure so try again
  5205.     jsr    rstscr        ;[87] restore screen
  5206.     jmp    ch0lup        ;[87] good init so go ahead
  5207. rstscr    lda    fscsv        ;[87] is the screen saved?
  5208.     beq    rstrts        ;[87] no
  5209.     lda    scv        ;[87] restore ch & cv
  5210.     sta    cv        ;[87]
  5211.     ldx    sch        ;[87]
  5212.     stx    ch        ;[87]
  5213.     jsr    pos80c        ;[87] now pos to original
  5214.     ldx    #0        ;[87] 
  5215.     stx    itsefl        ;[87] now we know its off
  5216.     lda    tl0end+1    ;[87] set up the restore address
  5217.     sta    gscsv+2        ;[87]
  5218.     lda    tl0end        ;[87]
  5219.     sta    gscsv+1        ;[87]
  5220.     ldx    #gscsv^        ;[87] set up screen put
  5221.     ldy    #gscsv\        ;[87]
  5222.     jsr    scrsvr        ;[87]
  5223.     ldx    #cffke^        ;[87] set up end of line (nada)
  5224.     ldy    #cffke\        ;[87]
  5225.     jsr    ssceln        ;[87]
  5226.     ldx    #0        ;[87] set up first and last rows(+1)
  5227.     ldy    #24        ;[87]
  5228.     jsr    ssclns        ;[87]
  5229.     jmp    scrrtn        ;[87] now for the screen routine & rts
  5230. gscsv    lda    $c000        ;[87] place to get restore chs
  5231.     sta    (a1l,x)        ;[87]
  5232.     sta    $c054        ;[87] got to do this for correct bank
  5233.     inc    gscsv+1        ;[87]
  5234.     bne    .+5        ;[87]
  5235.     inc    gscsv+2        ;[87]
  5236. rstrts    rts            ;[87]
  5237.  
  5238. telppc:
  5239.     jsr   telspa          ;set parity
  5240.     jmp   tl0ppc          ;[54] 
  5241.  
  5242. ;[87]telcp:
  5243. ;[87]    jmp   tl0cp          ;[54] 
  5244. telcp    =    tl0cp        ;[87]
  5245.  
  5246. ;[87]telgpc:
  5247. ;[87]    jmp   tl0gpc          ;[54]
  5248. telgpc    =    tl0gpc        ;[87]
  5249.  
  5250. telb2k    jsr    rstrcr        ;[86] restore cursor
  5251.     lda    csfg        ;[87] should we clear screen?
  5252.     beq    .+5        ;[87] no
  5253.     jsr    home        ;[87] clear screen
  5254.     jmp    kermit        ;[86]
  5255.  
  5256. ;[85]    jmp    .+3        ;[82] needed for crimmins mouse support
  5257. ;[86]    nop            ;[85] 3 in a row for you crimmins
  5258. ;[86]    nop            ;[85] 3 in a row for you crimmins
  5259. ;[86]    nop            ;[85] 3 in a row for you crimmins
  5260. ch0lup: jsr   tl0prc          ;[12] Check for port character, write to screen
  5261. ;[85]    jmp    .+3        ;[82] needed for crimmins mouse support
  5262.     jsr   telcnc          ;[12] Check for console char, write to port
  5263. ;[86]          jmp     kermit          ;[12] This means user wants to shut connection
  5264.     jmp    telb2k        ;[86] This means user wants to shut connection
  5265.     lda    itse80        ;[86] a //e or better?
  5266.     ora    itse80+1    ;[86]
  5267.     beq    ch0lu3        ;[86] no
  5268.     inc    itse80        ;[86] blinking cursor
  5269.     bne    ch0lu3        ;[86]
  5270.     ldx    itse80+1    ;[86]
  5271.     inx            ;[86] lets see if its time to reverse
  5272.     cpx    timect        ;[86] lets see if this is acceptable
  5273.     bne    ch0lu0        ;[86] no
  5274.     jsr    rstclc        ;[86] now invert- requires x=0 on exit <----
  5275. ch0lu0    stx    itse80+1    ;[86]
  5276. ch0lu3                ;[86]
  5277.     ldx    xonfg        ;[57] are we waiting for a wake up call
  5278.     beq    ch0lup        ;[57] no
  5279. ;[74]    ldx    flowlp        ;[57] have we waited long enough ?
  5280. ;[74]    beq    ch0la        ;[57] yes
  5281. ;[74]    lda    #2        ;[57] yes wait 2 ms
  5282. ;[74]    jsr    wait        ;[57]
  5283. ;[74]    dec    flowlp        ;[57] long enough
  5284. ;[74]    jmp    ch0lup        ;[57] around the loop again
  5285. ;[74]ch0la:
  5286.     ldx    #0        ;[74] tattle
  5287.     stx    xonfg        ;[57] dont forget 
  5288.     lda    #hxon        ;[57]
  5289.     jsr    tl0cmd        ;[57] start the com up again
  5290.     jmp   ch0lup          ;[12] Go back and do all that again
  5291.  
  5292. tl0prr: rts          ;[74][12] Return
  5293. tl0prc: jsr   tl0cp          ;[12] Check for a port character
  5294. ;[63]    beq   tl0prr          ;[12] Return
  5295. ;[74]    bne    .+3          ;[63] hate to do this
  5296. ;[74]    rts            ;[63] only way to reach this
  5297.     beq   tl0prr          ;[74] Return
  5298.     jsr   tl0gpc          ;[12] Go fetch the character
  5299.     and   #$7f          ;[17] Make sure H.O. bit is off for testing
  5300. ;[74]    tay          ;[12] Hold the character here
  5301.     beq    tl0prc    ;[74] ignore nulls
  5302.     sta   ksavea      ;[74] Save the AC so it isn't destroyed
  5303.     jsr    rstrcr        ;[86] restore cursor
  5304.     .ifeq    termnl        ;[63]
  5305.     ldx    termsc        ;[63] get count of commas
  5306.     beq    tl0pra        ;[63] are we searching for commas,no
  5307.     cmp    #cr        ;[63] yes ,did we get to the end of line?
  5308.     beq    tl0pr6        ;[63] yes, just assume text file xfer
  5309.     cpx    #3        ;[63] have we seen 2 commas?
  5310.     bne    tl0pr5        ;[63] no, keep looking
  5311.     ldy    #etoft-stoft    ;[63] we have the type in a (lower case)
  5312. tl0pr7    cmp    stoft-2,y    ;[63] is it in table?
  5313.     beq    tl0pr8        ;[63] yes, set type of file xfer
  5314.     dey            ;[63]
  5315.     dey            ;[63]
  5316.     bne    tl0pr7        ;[63] have we searched all of table?,no
  5317. tl0pr6    ldy    #2        ;[63] yes, assume text file xfer
  5318. tl0pr8    lda    stoft-1,y    ;[63] get file mode
  5319.     sta    filmod        ;[63] and set it
  5320. ;    lda    #0        ;[82] make sure ascii type is off
  5321. ;    sta    ascii        ;[82]
  5322.     jmp    tl0pr1        ;[63] now to server mode
  5323. tl0pr5    cmp    #',        ;[63] is this a comma?
  5324.     bne    tl0pr2        ;[63] no, try next
  5325. tl0pr9    inc    termsc        ;[63] bump the count of commas seen
  5326.     jmp    tl0pr2        ;[63] get next ch from remote
  5327. tl0pra                ;[63]
  5328.     ldx    termct        ;[63] index into term init string
  5329.     cmp    termst,x    ;[63] is this part of term init string?
  5330.     bne    tl0pro        ;[63] no
  5331.     inx            ;[63] yes
  5332.     cpx    #lterms        ;[63] have we got the whole string?
  5333.     beq    tl0pr9        ;[63] yes, go to server mode
  5334.     stx    termct        ;[63] no, wait for next ch of string
  5335.     jmp    tl0pr2        ;[63]
  5336. tl0pr1    ldx    #0        ;[63] use ctr for the ack message
  5337.     stx    termct        ;[63]
  5338.     stx    termsc        ;[63] ready to start again
  5339. tl0prl    lda    termco,x    ;[63] get ch from mcp ack
  5340.     inc    termct        ;[63]
  5341.     jsr    telppc        ;[63] send ch to remote (mcp)
  5342.     ldx    termct        ;[63]
  5343.     cpx    #ltermc        ;[63] have we sent all the ack?
  5344.     bne    tl0prl        ;[63] no
  5345. ;    Probably should wait for the "cool" ack from mcp
  5346.     ldx    #0        ;[63] ctr must be 0 initially
  5347.     stx    flowfg        ;[78] stop flow control while in file xfer
  5348.     stx    termct        ;[63]
  5349.     jsr    sutljp        ;[85] set up screen distributor
  5350.     ldx    kerosp        ;[63] restart the stack
  5351.     txs            ;[63]
  5352.     jmp    server        ;[63] away we go
  5353. tl0pro    ldx    #0        ;[63] start at the begining
  5354.     stx    termct        ;[63]
  5355. tl0pr2                ;[63]
  5356.     .endc            ;[63]
  5357. ;[76]    ldx    vtmod        ;[58] how about vt52 mode ?
  5358. ;[76]    beq    tl0pr4        ;[58] no
  5359. ;[76]    ldx    prnfg        ;[73] forget about vt52 mode if printer is on
  5360. ;[76]    bne    tl0pr4        ;[73] on?, yes
  5361. ;[76]    jsr    logput        ;[56] may have to record this ch
  5362. ;[76]    ldx    vtmod        ;[76] how about vt52 mode ?
  5363. ;[76]    cpx    #2        ;[76]
  5364. ;[76]    bne    jmvtc        ;[76] is this vt52?
  5365. ;[76]    jmp    vt52        ;[58] yes
  5366. ;[76]jmvtc    jmp    vt100        ;[76]
  5367. tl0jmp    jmp    tl0pr4        ;[76] term emulation jump
  5368. tl0pr4                ;[58]
  5369.     jsr   logput          ;[85] this must immediatly follow tl0pr4
  5370. ;[74]    cmp   #cr          ;[17] Do we have a <cr>?
  5371. ;[74]    bne   tl0pcl          ;[17] No, then check for <lf>
  5372. ;[74]    lda   #on          ;[17] Yes, set the 'Delete <lf>' flag
  5373. ;[74]    sta   dellf          ;[17]         ...
  5374. ;[74]    jmp   tl0poc          ;[17] And then continue
  5375. ;[74]tl0pcl: cmp   #lf          ;[17] Do we have a <lf>?
  5376. ;[74]    bne   tl0pnl          ;[17] Nope, We must go shut the Dellf flag.
  5377. ;[74]    lda   dellf          ;[17] We have a <lf>, is the flag on?
  5378. ;[74]    beq   tl0poc          ;[50][17] If not, continue normally
  5379. ;[74]    lda   #off          ;[17] Flag is on, <lf> follows <cr>, ignore it
  5380. ;[74]    sta   dellf          ;[17] Start by zeroing flag
  5381. ;[74]    jmp   tl0prc          ;[17] Now go to top of loop and try again
  5382. ;[74]tl0pnl: lda   #off          ;[17] Zero Dellf
  5383. ;[74]    sta   dellf          ;[17]         ...
  5384. ;[77]    cmp    #cr        ;[74] 
  5385. ;[77]    bne    tl0pcl        ;[74] not cr
  5386. ;[77]    lda    lffg        ;[74] have we delayed a lf?
  5387. ;[77]    beq    tl0p11        ;[74] no
  5388. ;[77]    lda    #off        ;[74] yes ignore it
  5389. ;[77]    sta    lffg        ;[74]
  5390. ;[77]    jmp    tl0poc        ;[74] print this ch
  5391. ;[77]tl0p11    lda    #on        ;[74] turn on cr flag
  5392. ;[77]    sta    dellf        ;[74]
  5393. ;[77]    jmp    tl0prc        ;[74] get next ch
  5394. ;[77]tl0pcl    cmp    #lf        ;[74] 
  5395. ;[77]    bne    tl0p21        ;[74] not a lf
  5396. ;[77]    lda    dellf        ;[74] have we delayed a cr
  5397. ;[77]    beq    tl0p23        ;[74] no
  5398. ;[77]    lda    #cr        ;[74] yes print it now
  5399. ;[77]    jsr    tl0prt        ;[74]
  5400. ;[77]    lda    #off        ;[74] and tell we did it
  5401. ;[77]    sta    dellf        ;[74]
  5402. ;[77]    jmp    tl0prc        ;[74] get next ch
  5403. ;[77]tl0p23    lda    lffg        ;[74] have we delayed a lf?
  5404. ;[77]    beq    tl0p25        ;[74] no
  5405. ;[77]    lda    #lf        ;[74] yes now print it
  5406. ;[77]    jsr    tl0prt        ;[74]
  5407. ;[77]    jmp    tl0prc        ;[74] next
  5408. ;[77]tl0p25    lda    #on        ;[74] tell were delaying a lf
  5409. ;[77]    sta    lffg        ;[74]
  5410. ;[77]    jmp    tl0prc        ;[74] next
  5411. ;[77]tl0p21    lda    dellf        ;[74] have we delayed a cr?
  5412. ;[77]    beq    tl0p27        ;[74] no
  5413. ;[77]    lda    #cr        ;[74] yes do it now
  5414. ;[77]    jsr    tl0prt        ;[74]
  5415. ;[77]    lda    #off        ;[74] and tattle
  5416. ;[77]    sta    dellf        ;[74]
  5417. ;[77]tl0p27    lda    lffg        ;[74] have we delayed a lf?
  5418. ;[77]    beq    tl0poc        ;[74] no
  5419. ;[77]    lda    #lf        ;[74] yes do it now
  5420. ;[77]    jsr    tl0prt        ;[74]
  5421. ;[77]    lda    #off        ;[74] and tattle
  5422. ;[77]    sta    lffg        ;[74]
  5423.     cmp   #cr          ;[77][17] Do we have a <cr>?
  5424.     bne   tl0pcl          ;[77][17] No, then check for <lf>
  5425.     sta   dellf          ;[77][17] no nulls so this should be <> 0
  5426. ;[87]    jmp   tl0p22          ;[77][17] And then continue
  5427.     beq   tl0p22          ;[87] And then continue
  5428. tl0pcl: cmp   #lf          ;[77][17] Do we have a <lf>?
  5429.     bne   tl0pnl          ;[77][17] Nope, We must go shut the Dellf flag.
  5430.     lda   dellf          ;[77][17] We have a <lf>, is the flag on?
  5431.     beq   tl0poc          ;[77][50][17] If not, continue normally
  5432.     lda   #off          ;[77][17] Flag is on, <lf> follows <cr>, ignore it
  5433.     sta   dellf          ;[77][17] Start by zeroing flag
  5434. ;[87]    jmp   tl0prc          ;[77][17] Now go to top of loop and try again
  5435.     beq   tl0prc          ;[87] Now go to top of loop and try again
  5436. ;[87]tl0pnl: lda   #off          ;[77][17] Zero Dellf
  5437. ;[87]    sta   dellf          ;[77][17]         ...
  5438. tl0pnl: ldx   #off          ;[87] Zero Dellf
  5439.     stx   dellf          ;[87]    but preserve a
  5440. tl0poc: ;[77][74]tya          ;[12] Get the data into the AC
  5441. ;[87]    lda    ksavea        ;[74] restore a
  5442. tl0p22                ;[77]
  5443. ;[77]    jsr    tl0prt        ;[74] print ch
  5444. ;[74]    jsr   logput          ;[56] We may log this ch
  5445. ;[74]    jsr   curoff          ;[31] Turn the cursor off
  5446. ;[74]    jsr   dspchr          ;[34] Show the character replaces COUT     
  5447. ;[74]    jsr   curon          ;[31] Turn the cursor on
  5448. ;[85]    jsr   logput          ;[77][56] We may log this ch
  5449. ;[87]    jsr   curoff          ;[77][31] Turn the cursor off
  5450. ;[87]    jsr   dspchr          ;[77][34] Show the character replaces COUT     
  5451. ;[87]    jsr   curon          ;[77][31] Turn the cursor on
  5452.     jsr    ktocur        ;[87] keep track of cursor
  5453.     jmp   tl0prc          ;[12] Try for another
  5454.  
  5455. ktocur    cmp   #cr        ;[87] Do we have a <cr>?
  5456.     bne   ktocu3        ;[87] No
  5457.     ldx    #0        ;[87] keep track of hch
  5458.     stx    hch        ;[87]
  5459.     jsr    bphcv        ;[87] & hcv
  5460.     jmp   ktocu7        ;[87] And then continue
  5461. ktocu3:                ;[87] Do we have a <lf>?
  5462.     cmp    #bs        ;[87] more house keeping
  5463.     bne    ktocu5        ;[87]
  5464.     jsr    dchch        ;[87] back up but not too far
  5465.     jmp    ktocu7        ;[87]
  5466. ktocu5    inc    hch        ;[87]
  5467. ktocu7                ;[87]
  5468.     jsr   curoff        ;[87] Turn the cursor off
  5469.     jsr   dspchr        ;[87] Show the character replaces COUT     
  5470.     jmp   curon        ;[87] Turn the cursor on
  5471.  
  5472. ;[77]tl0prt    jsr   logput          ;[74] We may log this ch
  5473. ;[77]    jsr   curoff          ;[74] Turn the cursor off
  5474. ;[77]    jsr   dspchr          ;[74] Show the character replaces COUT     
  5475. ;[77]    jsr   curon          ;[74] Turn the cursor on
  5476. ;[77]    rts            ;[74] thats all
  5477.  
  5478.     .ifeq <ftcom-ftappl>
  5479. telcnc: lda   kbd          ;[12] Check the keyboard for a character
  5480.         bpl   telcrs          ;[12] If none, return skip
  5481.     ldx    kpfl        ;[86] do we have a keypad
  5482.     beq    telcn0        ;[86] no, //c+ doesnt like us looking @ c025
  5483.     ldx    $c025        ;[80] just in case its gs keypad
  5484.     stx    kwrk01        ;[80]
  5485. telcn0                ;[86]
  5486.     bit   kbdstr          ;[12] Reset the keyboard strobe
  5487.     and   #$7f          ;[12] Make sure H.O. bit is off
  5488. ;[80]    jsr    swapbs        ;[73] swap bs & del
  5489.     cmp   escp          ;[12] Is it the connect-escape character?
  5490.     bne   telcn1          ;[35]
  5491.     jmp   intchr          ;[35] If so, go handle the interupt character
  5492. telcn1:
  5493.     ldx   xonfg          ;[57] have we stopped the flow ?
  5494.     beq   telcn3          ;[57] no
  5495.     ldx   #0          ;[57] tatle
  5496.     stx   xonfg          ;[57]
  5497.     pha          ;[57] save the current ch
  5498.     lda   #hxon          ;[57] and tell remote
  5499.     jsr   tl0cmd          ;[57] to start up again
  5500.     pla          ;[57] now print the current ch
  5501. telcn3:
  5502.     .ifeq    funkey        ;[73]
  5503.     ldy    kpfl        ;[80] do we have a keypad
  5504.     beq    telcn4        ;[80] no
  5505.     ldy    kpafl        ;[80] is the keypad in application mode
  5506.     beq    telcn4        ;[80] no
  5507.     asl    kwrk01        ;[80] yes look for keypad pushed
  5508.     asl    kwrk01        ;[80] yes look for keypad pushed
  5509.     asl    kwrk01        ;[80] yes look for keypad pushed
  5510. ;[81]    bmi    telcn4        ;[80] this was a keypad key
  5511.     bmi    telcn5        ;[81] this was a keypad key
  5512. telcn4                ;[80]
  5513.     ldy    usfkey        ;[73] is game plug in?
  5514.     beq    telcn7        ;[73] no dont try
  5515.     ldy    $c061        ;[73] how about open apple
  5516.     bmi    telcn5        ;[73] yes
  5517.     ldy    $c062        ;[73] how about closed apple
  5518.     bpl    telcn7        ;[73] no
  5519. telcn5    jsr    cffk        ;[73] check for a function keypress - & + entries
  5520.     jmp    rskp        ;[73] we have a function key so just return
  5521. ;[80]telcn7                ;[73]
  5522. telcn9                ;[80]
  5523.     .endc            ;[73]
  5524.     jsr    swapbs        ;[80] swap bs & del
  5525.     jsr   chrcon          ;[35] Go deal with loosing 2/2+ keyboard.
  5526.     pha            ;[86] save a for local echo
  5527.     jsr   telppc          ;[12] Output the port character
  5528.     pla            ;[86] just in case
  5529.     ldx   lecho          ;[57][12] Is local-echo turned on?
  5530.     beq   telcrs          ;[57][12] If not, we are done, return skip
  5531.     sta    ksavea        ;[87]
  5532.     jsr    rstrcr        ;[87] restore cursor
  5533. ;[87]    jsr   curoff          ;[31] Turn off cursor.
  5534. ;[87]    jsr   dspchr          ;[34] Show the char. replaces COUT.
  5535. ;[87]    jsr   curon          ;[31] Turn the cursor back on.
  5536.     jsr    ktocur        ;[87] keep track of cursor
  5537. telcrs: jmp   rskp          ;[12] Skip return
  5538. telcn7    ldy    ckfl        ;[80] how about cursor keys
  5539.     bne    telcn5        ;[80] yes, look for functions via a + entry
  5540.     beq    telcn9        ;[80]
  5541. u2icc    ldx    #erms1j\        ;[62] tell about initialization fail
  5542.     ldy    #erms1j^        ;[62]
  5543. ;[79]    jsr    prstr        ;[62]
  5544. ;[79]    jsr    prcrlf        ;[62]
  5545.     jmp    prstrl        ;[79] & let it rts
  5546. ;[79]    rts            ;[62]
  5547. u2s8b    ldx    #erms1k\        ;[72] tell about initialization fail
  5548.     ldy    #erms1k^        ;[72]
  5549. ;[79]    jsr    prstr        ;[72]
  5550. ;[79]    jsr    prcrlf        ;[72]
  5551. prwait                ;[87]
  5552.     jsr    prstrl        ;[79]
  5553.     jsr    bell        ;[72] attention
  5554. ;[87]    jsr    dfsv        ;[72] wait a bit so i can read this
  5555. ;[87]    rts            ;[72]
  5556.     jmp    dfsv        ;[72] wait a bit so i can read this
  5557. rstrcr                ;[86]
  5558.     lda    itsefl        ;[86] do we need to restore cursor?
  5559.     ror    a        ;[86]
  5560.     bcs    tl0prd        ;[86] no
  5561.     jsr    rstclc        ;[86]
  5562.     stx    itse80+1    ;[86]
  5563. tl0prd    lda    ksavea        ;[86] restore acc
  5564.     rts            ;[86]
  5565. rstclc    inc    itsefl        ;[86] tatle abt inverted
  5566. rstcl3                ;[87]
  5567.     lda    hch        ;[86] where are we?
  5568.     cmp    wndwth        ;[86] did we do that 80th col stuff
  5569.     bne    .+5        ;[86] no
  5570.     sec            ;[86]
  5571.     sbc    #1        ;[86] we only go 0 to 79
  5572.     lsr    a        ;[86]
  5573.     tay            ;[86] div by 2
  5574. ;    sei            ;[86] lockout interupts
  5575. ;[87]    lda    $c055        ;[86] assume page 2
  5576. ;[87]    bcc    .+5        ;[86] yes
  5577. ;[87]    lda    $c054        ;[86] page 1
  5578.     bcs    .+5        ;[87] page 1 is normal
  5579.     lda    $c055        ;[87] page 2
  5580.     lda    (basl),y    ;[86] flip inverse
  5581.     eor    #$80        ;[86]
  5582.     sta    (basl),y    ;[86]
  5583.     lda    $c054        ;[86] back to page 1 if necessary
  5584. ;    cli            ;[86] ok n now u can interupt
  5585.     ldx    #1        ;[86]
  5586.     stx    itse80        ;[86]
  5587.     dex            ;[86] now for a 0
  5588.     rts            ;[86]
  5589.     .endc          ;[12] Apple computer conditional
  5590.  
  5591. ;
  5592. ;     Telspa - This routine sets the parity according to the
  5593. ;     current value of the PARITY parameter.
  5594. ;
  5595.  
  5596. telspa: sta   kertpc          ;[21] Hold character here
  5597.     lda   #telpjt\      ;[21] Get the L.O. byte of parity jump table
  5598.     sta   jtaddr          ;[21] Put the L.O. byte here until needed
  5599.     lda   #telpjt^      ;[21] Get the H.O. byte
  5600.     sta   jtaddr+1      ;[21] Store that
  5601.     lda   parity          ;[21] Get the offset in AC
  5602.     clc          ;[21] Clear the carry
  5603.     adc   parity          ;[21] Make it an offset for a jump table
  5604.     adc   parity          ;[21]         ...
  5605.     clc          ;[21] Make sure carry is clear again
  5606.     adc   jtaddr          ;[21] Add the L.O. byte of address
  5607.     sta    jtaddr    ;[57]
  5608.     lda   jtaddr+1      ;[21] Get the H.O. byte of address
  5609.     adc   #$00          ;[21] Add in carry if there is any
  5610.     sta    jtaddr+1    ;[57]
  5611.     lda   kertpc          ;[21] Get the character
  5612.     jmp    (jtaddr)    ;[57] indexed jump
  5613. telpjt: jmp   tlpnon          ;[21] No parity
  5614.     jmp   tlpspc          ;[21] Space parity
  5615.     jmp   tlpmrk          ;[21] Mark parity
  5616.     jmp   tlpodd          ;[21] Odd parity
  5617.     jmp   tlpevn          ;[21] Even parity
  5618.  
  5619. tlpnon: rts          ;[21] No parity, so return intact
  5620.  
  5621. tlpspc: and   #$7f          ;[21] Turn off the parity bit
  5622.     rts          ;[21] Go back
  5623.  
  5624. tlpmrk: ora   #$80          ;[21] Set the parity bit
  5625.     rts          ;[21]     and go back
  5626.  
  5627. tlpevn: lda   #$00          ;[21] Start with 0 (for even parity)
  5628.     jmp   tlpeo          ;[21] Continue with even parity
  5629. tlpodd: lda   #$01          ;[21] Set bit for odd parity
  5630. tlpeo:    ldx   #$07          ;[21] Repeat count for parity toggle
  5631. tlplp0: bit   kertpc          ;[21] Test H.O. bit
  5632.     bpl   tlplp1          ;[21] Don't do the EOR if bit 7 not set
  5633.     eor   #$01          ;[21] Toggle parity
  5634. tlplp1: rol   kertpc          ;[21] Get next bit in position
  5635.     dex          ;[21] Decrement the count
  5636.     bpl   tlplp0          ;[21] Not done, do next bit
  5637.     rol   kertpc          ;[21] Now we have original byte again
  5638.     ror   a          ;[21] Get the parity bit to bit 7
  5639.     ror   a          ;[21]         ...
  5640.     ora   kertpc          ;[21] Merge the two
  5641.     rts          ;[21]     and return
  5642.  
  5643.     .ifeq    funkey        ;[73]
  5644. ;[80]cffk    ldy    vtmod        ;[76]
  5645. cffk    bpl    cffkc        ;[80] is this cursor keys vt100, yes
  5646.     ldy    vtmod        ;[76]
  5647.     cpy    #2        ;[76] vt 100?
  5648.     beq    gafk0        ;[76] yes
  5649.     ldy    #efkls-sfkls    ;[73] length of fun key list
  5650. cffklp    cmp    sfkls-1,y    ;[73] is it in list
  5651.     beq    gafk        ;[73] yes
  5652.     dey            ;[73]    
  5653.     bne    cffklp        ;[73] at end of list? no
  5654.     jmp    rskp        ;[73] yes, thats all return to normal process
  5655. cffkc    ldy    #efkckk-sfklsk    ;[80] only search for the cursor keypress
  5656.     bne    gafk01        ;[80] always branch
  5657. ;[80]gafk0    ldy    #efklsc-sfklsc    ;[76] length of fun key list
  5658. gafk0    ldy    kpfl        ;[80] do we have a keypad?
  5659.     beq    gafk03        ;[80] no
  5660.     ldy    #efklsk-sfklsk    ;[80] len of table
  5661. gafk01    cmp    sfklsk-1,y    ;[80]
  5662.     beq    gafk3        ;[80] got one use common code
  5663.     dey            ;[80] no try next
  5664.     bne    gafk01        ;[80]
  5665. gafk02                ;[81]
  5666.     jmp    rskp        ;[80] no more
  5667. gafk03                ;[80]
  5668.     ldy    #efklsc-sfklsc    ;[76] length of fun key list
  5669. gafk1    cmp    sfklsc-1,y    ;[76] is it in list
  5670. ;[81]    beq    gafk3        ;[76] yes
  5671.     beq    gafk2        ;[81] yes
  5672.     dey            ;[76]    
  5673.     bne    gafk1        ;[76] at end of list? no
  5674.     jmp    rskp        ;[76] yes, thats all return to normal process
  5675. gafk2    ldx    ckfl        ;[81] how about vt100 keys
  5676.     beq    gafk3        ;[81] no
  5677.     cpy    #efkckk-sfklsk+1    ;[81]
  5678.     bcc    gafk02    ;[81]  yes forget cursor keys
  5679. gafk3    tya            ;[76]
  5680.     asl    a        ;[76]
  5681.     tay            ;[76] double it
  5682.     lda    efklsc-2,y    ;[76] get address of fk equivalents
  5683. ;[86]    sta    saddr        ;[76]
  5684.     sta    cffk3+1        ;[86]
  5685.     lda    efklsc-1,y    ;[76] all of it
  5686. ;[86]    sta    saddr+1        ;[76]
  5687.     sta    cffk3+2        ;[86]
  5688.     jmp    gafk7        ;[76]
  5689. gafk    tya            ;[76] now 
  5690.     asl    a        ;[76] double
  5691.     tay            ;[76] it
  5692.     lda    efkls-2,y    ;[73] get address of fk equivalents
  5693. ;[86]    sta    saddr        ;[73]
  5694.     sta    cffk3+1        ;[86]
  5695.     lda    efkls-1,y    ;[73] all of it
  5696. ;[86]    sta    saddr+1        ;[73]
  5697.     sta    cffk3+2        ;[86]
  5698. gafk7                ;[76]
  5699.     ldy    #0        ;[73] start at the begining
  5700.     sty    kwrk01        ;[73] routines use a,x & y
  5701. cffkl    ldy    kwrk01        ;[73]
  5702. ;[86]    lda    (saddr),y    ;[73] get next ch of function key
  5703. cffk3    lda    cffk3,y        ;[86] page 0 may be used?
  5704.     beq    cffke        ;[73] 0 is end of list
  5705.     inc    kwrk01        ;[73] ready for next
  5706.     jsr    telppc        ;[73] send it down the line
  5707.     jmp    cffkl        ;[73]
  5708. cffke    rts            ;[73] thats all folks
  5709.     .endc            ;[73]
  5710. swapbs    ldx    swapf        ;[73] are we swapping bs & del keypress
  5711.     beq    swaprt        ;[73] no
  5712.     cmp    #bs        ;[73] yes check for the swap
  5713.     bne    swap3        ;[73] not bs
  5714.     lda    #del        ;[73] yes make it a del
  5715. ;[80]    bne    swaprt        ;[73] and return
  5716.     rts            ;[80]
  5717. swap3    cmp    #del        ;[73] how about a del?
  5718.     bne    swaprt        ;[73] no so return
  5719.     lda    #bs        ;[73] swap del for bs
  5720. swaprt    rts            ;[73] thats all folks
  5721.  
  5722. ;
  5723. ;    since rdkey wont leave wndtop & wndbtm alone
  5724. ;    we have our own
  5725. nrdkey    lda    kbd        ;[87] have we got a ch?
  5726.     bpl    nrdkey        ;[87] no tight loop
  5727.     bit    kbdstr        ;[87] ready for next
  5728.     rts            ;[87]
  5729.     
  5730. ;
  5731. ;     Intchr - processes the character which follows the interupt
  5732. ;     character and performs functions based on what that character
  5733. ;     is.
  5734. ;
  5735.  
  5736. ;[87]intchr: jsr   rdkey          ;[12] Get the next character
  5737. intchr:    jsr    savscr        ;[87] save screen
  5738.     jsr   nrdkey        ;[87] Get the next character
  5739. intsvk    sta   kerchr          ;[12] Save a copy of it
  5740.     and   #$5f          ;[12] Capitalize it
  5741.     cmp   #'D          ;[48] is this drop
  5742.     bne   intch9          ;[48] no
  5743.     lda   #0          ;[54] command the card to
  5744. ;[85]    sta   logfg          ;[56] turn off logging
  5745.     jsr   tl0cmd          ;[54] tell card to hang up
  5746. ;[85]    bne    intcha        ;[75] yes, weve hung up
  5747.     bne    intchf        ;[85] yes, weve hung up
  5748. ;[75]    beq   intch8          ;[54] card says he is unable
  5749. ;[75]    rts          ;[48] and stay here
  5750. ;[75]intch8: ldx   #erms1b\      ;[48] tell the user its not supported
  5751.     ldx   #erms1b\      ;[48] tell the user its not supported
  5752.     ldy   #erms1b^      ;[48]
  5753. ;[79]    jsr   prstr          ;[48]
  5754. ;[79]    jsr   prcrlf          ;[48]
  5755. ;[87]    jsr    prstrl        ;[79]
  5756.     jsr    prwait        ;[87] print & wait for op to read
  5757.     jsr    rstscr        ;[87] now restore screen
  5758.     jmp   rskp          ;[48] go back with a skip
  5759. intch9:              ;[48]
  5760.     cmp   #'C          ;[12] Does user want the connection closed?
  5761.     bne   intch0          ;[12] If not, try next option
  5762. intchf                ;[85]
  5763.     lda   logfg          ;[56] are we logging ?
  5764.     bpl   intcha          ;[56] no
  5765.     lda   #$00          ;[56][3] Make CLOSEF see there are no errors
  5766.     sta   logfg          ;[56] turn off logging
  5767.     jsr   closef          ;[56] We are done with this file, so close it
  5768. ;[75]intcha: rts          ;[56] Otherwise, do non-skip return and end it
  5769. intcha:            ;[75]
  5770.     lda    #0        ;[75]
  5771.     sta    flowfg        ;[76] turn off flow control when local
  5772.     jmp    sutljp        ;[85] set up screen distributor& rts
  5773. ;[76]    sta    confg        ;[75] talk to local again
  5774. ;[85]    rts          ;[75] Otherwise, do non-skip return and end it
  5775. intch0: cmp   #'S          ;[12] Does the user want status?
  5776.     bne   intch1          ;[12] Nope
  5777.     jmp   stat01          ;[12] Give it to him
  5778. intch1: cmp   #'B          ;[41] Does user want to send a Break?
  5779.     bne   intch2          ;[41] No, continue
  5780.     jsr   brkcmd          ;[41] Send the Break signal
  5781.     jmp   rskp          ;[41] Do a skip return
  5782. intch2:
  5783.     cmp   #'P          ;[55] is this print toggle
  5784.     bne   intch6          ;[55] no 
  5785.     jsr   prntgl          ;[55] yes toggle printer 
  5786.     jmp   rskp          ;[55] skip rtn
  5787. intch6:
  5788.     cmp    #'W        ;[76] allow swap of bs & del keys
  5789.     bne    intch7        ;[76] no
  5790.     lda    swapf        ;[76] yes
  5791.     eor    #1        ;[76] swap it
  5792.     sta    swapf        ;[76]
  5793.     jmp    rskp        ;[76]
  5794. intch7                ;[76]
  5795.     cmp    #'R        ;[80] how about print screen
  5796.     bne    intchb        ;[80] no
  5797. ;    lda    wndtop        ;[87] see if this fixes delaneys prob
  5798. ;    pha            ;[87]
  5799. ;    lda    wndbtm        ;[87]
  5800. ;    pha            ;[87]
  5801.     lda    cswl        ;[80] save the current display
  5802.     pha            ;[80]
  5803.     lda    cswh        ;[80]
  5804.     pha            ;[80]
  5805.     lda    prnfg        ;[80] the printer flag
  5806.     pha            ;[80] save it
  5807.     bne    intchd        ;[80] if its already on no need to turn on
  5808.     jsr    prntgl        ;[80] turn printer on
  5809. intchd    jsr    prscr        ;[80] now print the screen
  5810.     pla            ;[80] restore printer
  5811.     sta    prnfg        ;[80] restore printer flag
  5812. ;    bne    intcdd        ;[87] is printer on? yes
  5813. ;    lda    dsp2        ;[87] reset the screen?
  5814. ;    jsr    setio2+2    ;[87] hope so
  5815. ;    jsr    rstscr        ;[87] see if this gets arnd edt
  5816. ;intcdd                ;[87]    
  5817.     pla            ;[80] restore current display
  5818.     sta    cswh        ;[80]
  5819.     pla            ;[80]
  5820.     sta    cswl        ;[80]
  5821. ;    pla            ;[87]
  5822. ;    sta    wndbtm        ;[87] restore the window
  5823. ;    pla            ;[87]
  5824. ;    sta    wndtop        ;[87]
  5825.     jsr    sutljp        ;[80] dont forget to reset terminal type
  5826. intchc    jmp    rskp        ;[80] thats all
  5827. intchb                ;[80]
  5828.     cmp    #'K        ;[81] allow swap of keypad application mode
  5829.     bne    intch8        ;[81] no
  5830.     lda    kpafl        ;[81] yes
  5831.     eor    #1        ;[81] swap it
  5832.     sta    kpafl        ;[81]
  5833.     jmp    rskp        ;[81]
  5834. intch8                ;[81]
  5835.     cmp    #'E        ;[83]
  5836.     bne    intche        ;[83] not restore screen
  5837.     jsr    sucout        ;[83]
  5838. ;    lda    #si+$80        ;[87] turn off mouse text?
  5839. ;    jsr    cout        ;[87] hope so :-)
  5840.     lda    #0        ;[87] turn off special vt100 graphics
  5841.     sta    vtcso        ;[87]
  5842.     jmp    rskp        ;[83]
  5843. intche                ;[83]
  5844.     cmp    #'M        ;[86] ok ralpho lets see
  5845.     bne    intchg        ;[86] if this is useful
  5846.     jsr    intchf        ;[86] clean up things
  5847.     jmp    modem        ;[86]
  5848. intchg                ;[86]
  5849.     cmp    #'Q        ;[86] how about an exit, ralpho
  5850.     bne    intchh        ;[86]
  5851.     jsr    intchf        ;[86] clean up things
  5852.     jmp    exit1        ;[86]
  5853. intchh                ;[86]
  5854.     cmp    #'V        ;[87] is this toggle cursor-keys-vt100
  5855.     bne    intchi        ;[87] no
  5856.     lda    ckfl        ;[87]
  5857.     eor    #1        ;[87]
  5858.     sta    ckfl        ;[87]
  5859.     jmp    rskp        ;[87]
  5860. intchi                ;[87]    
  5861.     lda   kerchr          ;[12] now for the special chs
  5862.     and   #$7f          ;[12] dont worry about case
  5863.     cmp   #'?          ;[12] Does user need help?
  5864.     bne   intch3          ;[41][12] If not, continue
  5865.     jsr    home        ;[87] clear the screen
  5866.     ldx   #inthlp\      ;[12] Get the address of the proper help string
  5867.     ldy   #inthlp^      ;[12]         ...
  5868.     jsr   prstr          ;[12] Print the help stuff
  5869.     jsr    nrdkey        ;[87] see what he wants
  5870.     pha            ;[87] save key
  5871.     jsr    rstscr        ;[87] restore screen
  5872.     pla            ;[87] key he pushed
  5873. ;[87]    jmp   intchr          ;[12] Get another option character
  5874.     jmp   intsvk        ;[87] Get another option character
  5875. intch3: cmp   escp          ;[41][12] Is it another connect-escape?
  5876.     bne   intch4          ;[41][12] No, try next thing
  5877.     jsr   telppc          ;[12] Stuff the character at the port
  5878.     jmp   rskp          ;[12] Give skip return
  5879. intch4: cmp   #'0          ;[41] Wants to send a null?
  5880.     bne   intch5          ;[41] Nope,this is definitely an error
  5881.     lda   #nul          ;[41] Fetch a null
  5882.     jsr   telppc          ;[41]     and stuff it at the port
  5883.     jmp   rskp          ;[41] Return with a skip
  5884. intch5:
  5885.     jsr   bell          ;[41][12] Sound bell at the user
  5886.     jmp   rskp          ;[12] Go back (skip)
  5887. savscr    lda    itse80        ;[87] are we saving screen?
  5888.     ora    itse80+1    ;[87] slight hole wid blinking cursor
  5889.     beq    savrts        ;[87] no
  5890.     inc    itsefl        ;[87] if we turned it off leave it off
  5891.     jsr    rstrcr        ;[87] may have to reset cursor
  5892.     inc    itsefl        ;[87] hope hope
  5893.     lda    tl0end+1    ;[87] set up save address
  5894.     sta    intsvc+2    ;[87]
  5895.     sta    fscsv        ;[87] tattle that its saved
  5896.     lda    tl0end        ;[87]
  5897.     sta    intsvc+1    ;[87]
  5898.     lda    hcv        ;[87] save pos on screen
  5899.     sta    scv        ;[87]
  5900.     lda    hch        ;[87]
  5901.     sta    sch        ;[87]
  5902.     ldx    #intgts^    ;[87] set up put
  5903.     ldy    #intgts\    ;[87]
  5904.     jsr    scrsvr        ;[87]
  5905.     ldx    #cffke^        ;[87] what to do at end of line
  5906.     ldy    #cffke\        ;[87]
  5907.     jsr    ssceln        ;[87]
  5908.     ldx    #0        ;[87] and the range +1
  5909.     ldy    #24        ;[87]
  5910.     jsr    ssclns        ;[87]
  5911.     jmp    scrrtn        ;[87] do the screen & rts
  5912. intgts    lda    (a1l,x)        ;[87] get ch from screen
  5913.     sta    $c054        ;[87] always get bank back
  5914. intsvc    sta    $c000        ;[87] place to save screen
  5915.     inc    intsvc+1    ;[87] next
  5916.     bne    .+5        ;[87]
  5917.     inc    intsvc+2    ;[87]
  5918. savrts    rts            ;[87]
  5919.  
  5920. ;
  5921. ;     Print toggle command - turn printer on/off unless printer 
  5922. ;     slot is not defined
  5923. ;
  5924. prntgl: lda   prnfg          ;[55]
  5925.     bne   prnon          ;[55] is printer on ? yes
  5926. prnoff    lda   prnsl          ;[55] no, how about the slot
  5927.     beq   prnfal          ;[55] no slot sigh!
  5928.     ldx   #3          ;[55] turn printer on
  5929.     stx   prnfg          ;[55]
  5930.     jsr   setio2+2      ;[55] nice pr#n rtn
  5931.     ldx    vtmod        ;[87]
  5932.     cpx    #2        ;[87] vt100?
  5933.     beq    savrts        ;[87] yes may have vt102 printer stuff
  5934.     jmp    sutljp        ;[76] set up tel term jp and rtn
  5935. ;[76]    rts          ;[55]
  5936. prnfal:
  5937.     ldx   #ermese\      ;[55] Tell user about the range error
  5938.     ldy   #ermese^      ;[55]         ...
  5939. ;[79]    jsr   prstr          ;[55] Print the error text
  5940. ;[79]    jsr   prcrlf          ;[55] Print a crelf
  5941.     jmp    prstrl        ;[79] let it do a rts
  5942. ;[79]    rts          ;[55] Go to top
  5943. prnon:    lda   #0          ;[55] turn printer off
  5944.     sta   prnfg          ;[55]
  5945. ;[78]    ldx   dsptyp          ;[55] is this 80 col video ?
  5946. ;[78]    bpl   prn40          ;[55] no
  5947. ;[78]    lda   dsp2          ;[55] get 80 col slot
  5948. ;[78]prn40:    jsr   setio2+2      ;[55] and set proper display
  5949.     jsr    sutljp        ;[76]
  5950. ;[76]    jsr    test2e        ;[58] just in case its //e 80 col
  5951. ;[78]    jmp    test2e        ;[76] just in case its //e 80 col
  5952.     jmp    sucout        ;[78] do it all & rts
  5953. ;[76]    rts          ;[55] thats all
  5954. sutljp    lda    prnfg        ;[76] set up tel term type jump
  5955.     bne    sutlj2        ;[76] if printer is on forget about type
  5956.     lda    vtmod        ;[76] now let see what terminal we are
  5957.     beq    sutlj4        ;[76] just monitor the line
  5958.     cmp    #1        ;[76]
  5959.     beq    sutlj2        ;[76] none
  5960.     cmp    #2        ;[76]
  5961.     beq    sutlj6        ;[76] vt 100
  5962.     ldx    #vt52\        ;[76] vt52 i hope
  5963.     ldy    #vt52^        ;[76]
  5964. ;[85]sutljc    stx    tl0jmp+1    ;[76]
  5965. sutljc                ;[85]
  5966.     lda    #$48        ;[85] its a pha
  5967.     bit    dsptyp        ;[85] are we 80 col?
  5968.     bpl    .+4        ;[85] no
  5969.     lda    #$60        ;[85] ist a rts
  5970.     sta    curon        ;[85] speed it up (hope hope hope)
  5971.     sta    curoff        ;[85] "
  5972.     lda    #$c9        ;[85] its a cmp #
  5973.     bit    flowfg        ;[85] flow control?
  5974.     bmi    .+4        ;[85] yes
  5975.     lda    #$60        ;[85] its a rts
  5976.     sta    ckflow        ;[85] speed things up (i hope)
  5977.     lda    #$ae        ;[85] its a ldx abs
  5978.     bit    flowfg        ;[85] flow control?
  5979.     bmi    .+4        ;[85] yes
  5980.     lda    #$60        ;[85] its a rts
  5981.     sta    fflow        ;[85] speed things up (i hope)
  5982.     lda    logfg        ;[85] are we logging?
  5983.     bne    sutlj0        ;[85] yes
  5984.     inx            ;[85]
  5985.     inx            ;[85]
  5986.     inx            ;[85]
  5987.     cpx    #3        ;[85] did we carry?
  5988.     bge    sutlj0        ;[85] no
  5989.     iny            ;[85] yes make it right
  5990. sutlj0                ;[85]
  5991.     stx    tl0jmp+1    ;[85]
  5992.     sty    tl0jmp+2    ;[76]
  5993.     rts            ;[76] bye
  5994. sutlj2    ldx    #tl0pr4\    ;[76] forget the term emulation stuff
  5995.     ldy    #tl0pr4^    ;[76]
  5996.     jmp    sutljc        ;[76] common return
  5997. sutlj4    ldx    #prchrl\    ;[76] monitor the input to the screen
  5998.     ldy    #prchrl^    ;[76]
  5999.     jmp    sutljc        ;[76]
  6000. sutlj6    ldx    #vt100\        ;[76]
  6001.     ldy    #vt100^        ;[76]
  6002.     jmp    sutljc        ;[76]
  6003. ;[87]prscr    ldx    #0        ;[80] must be 0 for rest of rtn to work
  6004. ;[87]    stx    kwrk01        ;[80] this is entry in prstab
  6005. ;[87]prsadd    lda    kwrk01        ;[80] table is 2 bytes each
  6006. ;[87]    pha            ;[80] save the current line number
  6007. ;[87]    lsr    a        ;[80]
  6008. ;[87]    and    #3        ;[80]
  6009. ;[87]    ora    #4        ;[80]
  6010. ;[87]    sta    a1h        ;[80] high order byte of address
  6011. ;[87]    pla            ;[80] now get the original line #
  6012. ;[87]    and    #$18        ;[80]
  6013. ;[87]    bcc    .+4        ;[80] hate to do this
  6014. ;[87]    adc    #$7f        ;[80]
  6015. ;[87]    sta    a1l        ;[80] part of the lsb
  6016. ;[87]    asl    a        ;[80]
  6017. ;[87]    asl    a        ;[80]
  6018. ;[87]    ora    a1l        ;[80]
  6019. ;[87]    sta    a1l        ;[80] finally    
  6020. ;[87]    jsr    calca1        ;[87] calc a1 depending on line #
  6021. ;[87]    ldy    #0        ;[80] start at col 0
  6022. ;[87]    sty    kwrk02        ;[80]
  6023. ;[87]prsnx    ldy    dsptyp        ;[80] is this 80 col?
  6024. ;[87]    bpl    prs40c        ;[80] no
  6025. ;[87]    sta    $c055        ;[80] get evens
  6026. ;[87]    lda    (a1l,x)        ;[80] this is why x must be 0
  6027. ;[87]    sta    $c054        ;[80] now for the odds, arggggggggggggggggg
  6028. ;[87]    jsr    prsguc        ;[80] correct for upper case inverse
  6029. ;[87]    jsr    cout        ;[80] and send it to printer
  6030. ;[87]prs40c    lda    (a1l,x)        ;[80] this is why x must be 0
  6031. ;[87]    jsr    prsguc        ;[80] correct for upper case inverse
  6032. ;[87]    jsr    cout        ;[80] and send it to printer
  6033. ;[87]    inc    a1l        ;[80] next ch
  6034. ;[87]    bne    prs01        ;[80] hate to do this
  6035. ;[87]    inc    a1h        ;[80]
  6036. ;[87]prs01    inc    kwrk02        ;[80] bump ch cnt
  6037. ;[87]    lda    #40        ;[80]
  6038. ;[87]    cmp    kwrk02        ;[80] have we got the whole line?
  6039. ;[87]    bne    prsnx        ;[80] no
  6040. ;[87]    lda    #hcr        ;[80] yes, terminate line ready for next line
  6041. ;[87]    jsr    cout        ;[80]
  6042. ;[87]    inc    kwrk01        ;[80]
  6043. ;[87]    lda    #24        ;[80] have we finished the screen?
  6044. ;[87]    cmp    kwrk01        ;[80]
  6045. ;[87]    bne    prsadd        ;[80] no
  6046. ;[87]    rts            ;[80] yes thats all folks
  6047. prscr    ldx    #prsgts^    ;[87] set up get from scren
  6048.     ldy    #prsgts\    ;[87]
  6049.     jsr    scrsvr        ;[87]
  6050.     ldx    #prseol^    ;[87] set up end of line work
  6051.     ldy    #prseol\    ;[87]
  6052.     jsr    ssceln        ;[87]
  6053.     ldx    #0        ;[87] now for the range +1
  6054.     ldy    #24        ;[87]
  6055.     jsr    ssclns        ;[87]
  6056.     jmp    scrrtn        ;[87] now do the sceen & rts
  6057. prseol    lda    #hcr        ;[87]
  6058.     jmp    cout        ;[87] print and rts
  6059. prsgts    lda    (a1l,x)        ;[87] get ch from screen
  6060.     sta    $c054        ;[87] back to bank
  6061.     and    #$7f        ;[87] turn off neq ascii
  6062.     cmp    #$20        ;[87] a control ch?
  6063.     bpl    .+4        ;[87] no
  6064.     ora    #$40        ;[87] yes make it upper case
  6065.     jmp    cout        ;[87] print & rts
  6066. ;[87]prsguc    and    #$7f        ;[80] turn off neq ascii
  6067. ;[87]    cmp    #$20        ;[80] a control ch?
  6068. ;[87]    bpl    .+4        ;[80] no
  6069. ;[87]    ora    #$40        ;[80] yes make it upper case
  6070. ;[87]    rts            ;[80]
  6071.  
  6072. scrrtn    ldx    #0        ;[87] must be 0 for rest of rtn to work
  6073. scrstl    ldy    #99        ;[87] starting line    
  6074.     sty    kwrk01        ;[87] this is entry in prstab
  6075. scrcln    lda    kwrk01        ;[87] table is 2 bytes each
  6076.     pha            ;[87] save the current line number
  6077.     lsr    a        ;[87]
  6078.     and    #3        ;[87]
  6079.     ora    #4        ;[87]
  6080.     sta    a1h        ;[87] high order byte of address
  6081.     pla            ;[87] now get the original line #
  6082.     and    #$18        ;[87]
  6083.     bcc    .+4        ;[87] hate to do this
  6084.     adc    #$7f        ;[87]
  6085.     sta    a1l        ;[87] part of the lsb
  6086.     asl    a        ;[87]
  6087.     asl    a        ;[87]
  6088.     ora    a1l        ;[87]
  6089.     sta    a1l        ;[87] finally    
  6090.     ldy    #0        ;[87] start at col 0
  6091.     sty    kwrk02        ;[87]
  6092. scrnx    bit    dsptyp        ;[87] is this 80 col?
  6093.     bpl    scrga1        ;[87] no
  6094.     sta    $c055        ;[87] get evens
  6095. scrg1    jsr    $c000        ;[87] user exit for evens-user better $c054
  6096. scrga1    jsr    $c000        ;[87] & now odds
  6097.     inc    a1l        ;[87] next ch
  6098.     bne    .+4        ;[87] hate to do this
  6099.     inc    a1h        ;[87]
  6100.     inc    kwrk02        ;[87] bump ch cnt
  6101.     lda    #40        ;[87]
  6102.     cmp    kwrk02        ;[87] have we got the whole line?
  6103.     bne    scrnx        ;[87] no
  6104. screol    jsr    $c000        ;[87] yes, terminate line ready for next line
  6105.     inc    kwrk01        ;[87]
  6106. scrlln    lda    #99        ;[87] have we finished the screen?
  6107.     cmp    kwrk01        ;[87]
  6108.     bne    scrcln        ;[87] no
  6109.     rts            ;[87] yes thats all folks
  6110. scrsvr    stx    scrg1+2        ;[87] set up users
  6111.     sty    scrg1+1        ;[87]
  6112.     stx    scrga1+2    ;[87]
  6113.     sty    scrga1+1    ;[87]
  6114.     rts            ;[87]
  6115. ssclns    stx    scrstl+1    ;[87] starting row
  6116.     sty    scrlln+1    ;[87] ending row +1
  6117.     rts            ;[87]
  6118. ssceln    stx    screol+2    ;[87] users end of line
  6119.     sty    screol+1    ;[87]
  6120.     rts            ;[87]
  6121. ;
  6122. ;     Brkcmd - This routine checks which communication device is
  6123. ;     being used and takes the appropriate action to send a Break
  6124. ;     signal (Space condition on line for 233 ms.).
  6125. ;
  6126.  
  6127. brkcmd:
  6128.  
  6129.     lda   #$c          ;[54] command for break
  6130.     jmp   tl0cmd          ;[54] let com do rts for us
  6131.  
  6132. ;
  6133. ;     Wait - This routine will wait for some number of milliseconds.
  6134. ;
  6135. ;         Input:     A - number of milliseconds to delay
  6136. ;
  6137. ;         Output:     Nothing
  6138. ;
  6139. ;         Regs Destroyed: A,X      ;[47] Y is not changed
  6140. ;
  6141.  
  6142. ;[78]wait:    ldx   #202          ;[41] Count for a 1 millisecond loop
  6143. ;[78]    .ifeq <.\-$ff>
  6144. ;[78]    nop          ;[41] Push to beginning of next page
  6145. ;[78]    .endc          ;[41]
  6146. ;[78]    .ifeq <.\-$fe>
  6147. ;[78]    nop          ;[41] Push to beginning of next page
  6148. ;[78]    nop          ;[41]         ...
  6149. ;[78]    .endc          ;[41]
  6150. ;  does crossing a page boundary change the timing that much ?????
  6151.  
  6152. ;[78]wait1m: dex          ;[41] Count down
  6153. ;[78]    bne   wait1m          ;[41] If not done, continue
  6154. ;[78]    sec          ;[41] Finished a millisecond
  6155. ;[78]    sbc   #$01          ;[41] Decr # ms done
  6156. ;[78]    bne   wait          ;[41] More to do?, then go to top
  6157. ;[78]    rts          ;[41] Done, return to caller
  6158.  
  6159. logput                ;[56]
  6160.     ldx   logfg          ;[56]
  6161.     bpl   logpt1          ;[56]
  6162.     pha          ;[56] save ch
  6163.     jsr   fputc          ;[56] write ch 
  6164.     jmp   logpt2          ;[56] error exit
  6165.     pla          ;[56] restore ch
  6166. logpt1: rts          ;[56] 
  6167. logpt2: pla          ;[56] just to keep stack straight
  6168.     jsr   bfeerr          ;[56] tell about error
  6169.     sta   logfg          ;[56] since bfeerr returns a 0, turn off logging
  6170.     rts          ;[56]
  6171.  
  6172.     .ifeq <ftcom-ftappl>
  6173. ;[34] Process the character before display, so that caps and odd chars appear
  6174. ;[34] as inverse.
  6175. ;[46] Evade this processing if the display is something better than
  6176. ;     2/2+ 40 col.
  6177.  
  6178. dspchr: ora   #$80          ;[34] Make sure h.o. bit is set.
  6179. ;[74]    pha          ;[46] Save the character
  6180. ;[74]    lda   dsptyp          ;[46] Is the display
  6181. ;[74]    cmp   #ds40up          ;[46] the 2/2+ one?
  6182.     ldx   dsptyp          ;[74][46] Is the display
  6183. ;[76]    cpx   #ds40up          ;[74][46] the 2/2+ one?
  6184.     bne   dspch2          ;[46] If not, we can skip this processing.
  6185. ;[74]    pla          ;[46] Else, we have to munge the character.
  6186.     cmp   #$c1          ;[34]
  6187.     bmi   dspnrm          ;[34] Digit, or normal punctuation char.
  6188.     cmp   #$db          ;[34]
  6189.     bmi   dspinv          ;[34] Capital letter.
  6190.     cmp   #$e0          ;[34]
  6191.     bmi   dspnrm          ;[34] More normal punctuation.
  6192.     bne   dspch1          ;[46][34] Branch if lowercase.
  6193.     lda   #''          ;[34] Accent grave. load a '
  6194.     bne   dspinv          ;[34] And show it inverted.
  6195. dspch1: and   #$df          ;[46][34] Shift high (lowercase) char to caps.
  6196.     cmp   #$db          ;[34]
  6197.     bmi   dspnrm          ;[34] Lowercase letter.
  6198. ;[74]dspinv: pha          ;[34] Save the char.
  6199. ;[74]    lda   #invdsp          ;[34] Show as inverse.
  6200. ;[74]    sta   invflg          ;[34]
  6201. ;[74]dspch2: pla          ;[46][34] Restore the char.
  6202. dspinv:           ;;[74][34] Save the char.
  6203.     ldx   #invdsp          ;[74][34] Show as inverse.
  6204.     stx   invflg          ;[74][34]
  6205. dspch2:           ;;[74][46][34] Restore the char.
  6206. dspnrm:
  6207. ;[85]    ldx    #hcr+1        ;[57] this is one of the search limits
  6208.     jsr    ckflow        ;[57] see if flow control is on
  6209.     jsr   cout          ;[34] Show the character.
  6210.     lda   #nrmdsp          ;[34] Switch back to normal display.
  6211.     sta   invflg          ;[34]
  6212.     rts          ;[34]
  6213.  
  6214. ;
  6215. ;    check for flow control
  6216. ;    x must be set for the upper limit of the ch search
  6217. ;      the lower limit of the search is line feed
  6218. ;
  6219. ckflow                ;[57]
  6220. ;[81]    stx    dspch5+1    ;[57] set the search limit
  6221. ;[85]    stx    dspch3+1    ;[81] set the search limit
  6222. ;[85]    ldx   flowfg          ;[57] do we have flow control
  6223. ;[81]    bpl   dspch4          ;[57] no
  6224. ;[85]    bpl   dspch5          ;[81] no
  6225. ;[76]    ldx    confg        ;[75] are we connected to remote?
  6226. ;[76]    beq    dspch4        ;[75] no
  6227. ;[81]    ldx   xonfg          ;[57] have we already stoped the flow ?
  6228. ;[81]    beq   dspch5          ;[57] no
  6229. ;[81]    pha          ;[57] save ch
  6230. ;[81]    ldx   #0          ;[57] tattle
  6231. ;[81]    stx   xonfg          ;[57]
  6232. ;[81]    lda   #hxon          ;[57] tell remote to
  6233. ;[81]    jsr   tl0cmd          ;[57] start up again
  6234. ;[81]    pla          ;[57] restore ch
  6235. ;[81]dspch5:              ;[57]
  6236. ;[85]dspch3            ;[81]
  6237.     cmp   #hcr+1          ;[57] are we about to start the printer?
  6238. ;[81]    bpl   dspch4          ;[57] no
  6239.     bcs   dspch4          ;[81] no
  6240.     cmp    #hlf        ;[57] all chs between lf & cr
  6241. ;[81]    bmi    dspch4        ;[57] no
  6242.     bcc    dspch4        ;[81] no
  6243. fflow                ;[85] force flow ctnl
  6244.     ldx    xonfg        ;[81]
  6245.     bne    dspch5        ;[81] are we already stopped? yes
  6246.     pha          ;[57] save current ch
  6247.     lda   #hxoff          ;[57] tell remote to
  6248.     sta   xonfg          ;[57] stop and tattle
  6249.     jsr   tl0cmd          ;[57]
  6250.     lda    flowdl        ;[57] get the flow delay
  6251.     beq    dspch8        ;[74] none so carry on
  6252.     sta    kwrk01        ;[57] place to dec
  6253. dspch7:    jsr    telcp        ;[57] check the port and save the input
  6254. ;[74]    lda    kwrk01        ;[57] thru waiting ?
  6255. ;[74]    beq    dspch8        ;[57] yes
  6256. ;[78]    lda    #2        ;[57] 2 ms wait
  6257. ;[82]    lda    #25        ;[78] 2 ms wait
  6258. ;[85]    lda    #17        ;[82] 1 ms wait
  6259.     lda    timect        ;[85] 1 ms wait
  6260.     jsr    wait        ;[57] and wait for it to stop
  6261.     dec    kwrk01        ;[57] thru ?
  6262. ;[74]    jmp    dspch7        ;[57]
  6263.     bne    dspch7        ;[74]
  6264. dspch8:
  6265.     pla          ;[57] restore current ch
  6266.     rts        ;[81]
  6267. dspch4:
  6268.     ldx   xonfg          ;[81] have we already stoped the flow ?
  6269.     beq   dspch5          ;[81] no
  6270.     pha          ;[81] save ch
  6271.     ldx   #0          ;[81] tattle
  6272.     stx   xonfg          ;[81]
  6273.     lda   #hxon          ;[81] tell remote to
  6274.     jsr   tl0cmd          ;[81] start up again
  6275.     pla          ;[81] restore ch
  6276. dspch5:              ;[81]
  6277.     rts        ;[57] thats all
  6278.  
  6279. ;[35] Convert the character as required for the Apple loosing keyboard.
  6280.  
  6281.  
  6282. chrcon: tax          ;[35] Save a copy of the char in X
  6283.     lda   kbdtyp          ;[35] If 2e, just send it.
  6284. ;[72]    cmp   #kbap2e          ;[35]
  6285. ;[72]    beq   chclrs
  6286.     bne   chclrs        ;[72]
  6287.     lda   kbmode          ;[35] Ditto if in literal mode
  6288.     cmp   #kmlit          ;[35]
  6289.     beq   chclrs          ;[35]
  6290.     cpx   #lftarw          ;[35] If left arrow, send a delete
  6291.     bne   chrco1          ;[35]
  6292.     ldx   #$7f          ;[35]
  6293.     bne   chclrs          ;[35]
  6294. chrco1: cpx   #'A          ;[35] Is this a letter?
  6295.     bmi   chnoaz          ;[35] branch if too low.
  6296.     cpx   #'[          ;[36] Left square brace, follows Z.
  6297.     bpl   chnoaz          ;[35] Branch if too high for letter.
  6298.     lda   kbcase          ;[35] Decide if it needs lowercase.
  6299.     eor   kbmode          ;[35] Weird, but it works
  6300.     beq     chclrs          ;[35] Send uppercase, no modification.
  6301.     txa          ;[35]
  6302.     ora   #$20          ;[35] Lowercase it.
  6303.     tax          ;[35]
  6304.     bne   chclrs          ;[35]
  6305. chnoaz: lda   #kmpref          ;[35] Is this char prefixed?
  6306.     cmp   kbmode          ;[35]
  6307.     beq   chspec          ;[35] Branch if so.
  6308.     cpx   #rhtarw          ;[35] Was this a right-arrow?
  6309.     bne   chclrs          ;[35] No. just send char.
  6310.     sta   kbmode          ;[35] Else set prefix mode
  6311.     bpl   chpopr          ;[35] And dont send char.
  6312.  
  6313. ; Is it one of the special, prefixed characters?
  6314.  
  6315. chspec: ldy   #$00          ;[35] Set up index to step thru table
  6316.     txa          ;[35]
  6317. chslop: pha          ;[35] Top of loop
  6318.     lda   chrtab,y      ;[35] Get 1st half of 2-byte pair
  6319.     bmi   chesc          ;[35] $FF is end of table.
  6320.     pla          ;[35] Get our character.
  6321.     cmp   chrtab,y      ;[35] Compare it with the table entry.
  6322.     beq   chrrep          ;[35] Match. Go replace it.
  6323.     iny          ;[35] No match. Step onto next
  6324.     iny          ;[35] Byte pair.
  6325.     bne   chslop          ;[35] And test it.
  6326. chrrep: iny          ;[35] Second half of pair is the replacment.
  6327.     lda   chrtab,y
  6328.     tax          ;[35] So put it in X.
  6329.     bpl   chclrs          ;[35] And send it.
  6330.  
  6331. ;Are we trying to enter literal mode? Prefix-Escape does this.
  6332. chesc:    pla          ;[35] Get the char from where chspec put it.
  6333.     cmp   #esc          ;[35] Is it escape?
  6334.     bne   chtogg          ;[35] No. check for case toggle.
  6335.     lda   #kmlit          ;[35] Yes. set mode to literal.
  6336.     sta   kbmode          ;[35] And store it.
  6337.     bpl   chpopr          ;[35] Return without sending char.
  6338.  
  6339. chtogg: cpx   #rhtarw          ;[35] Was it another right-arrow?
  6340.     bne   chclrs          ;[35] No. just send it & clear mode.
  6341.     lda   kbcase          ;[35] Get the current default case
  6342.     eor   #$01          ;[35] Flip it.
  6343.     sta   kbcase          ;[35] Store it.
  6344.     lda   #kmnorm          ;[35] Set mode to normal.
  6345.     sta   kbmode          ;[35]     ...
  6346.     bpl   chpopr          ;[35] Return without printing the char.
  6347.  
  6348.  
  6349. ;Clear mode and send the character.
  6350. chclrs: lda   #kmnorm          ;[35] Clear the mode.
  6351.     sta   kbmode          ;[35]
  6352.     txa          ;[35] Get the char into A.
  6353. chclrt    rts          ;[35] Return normally.
  6354.  
  6355. ;Return via skip return, without sending the char. This pops the latest return
  6356. ;address off the stack, revealing the next one down. It then does a retskp,
  6357. ;matching the telppc routine.
  6358.  
  6359. chpopr: pla          ;[35] Pop off the latest return address
  6360.     pla          ;[35]
  6361.     jmp   rskp          ;[35] And return skip.
  6362.     .endc
  6363.  
  6364. ;
  6365. ;     Vt52 - will carry out the equivalent of most of the vt52 functions
  6366. ;     available.
  6367. ;
  6368.  
  6369. vt52:
  6370.     jsr    logput        ;[76]
  6371.     ldx   escflg          ;[58] Was previous character an escape?
  6372.     bne   vt527          ;[58] yes
  6373. ;[81]    cmp   #del          ;[58] Was it a delete?
  6374. ;[81]    beq   chclrt          ;[58] If so, return
  6375.     cmp    #si        ;[73] is this vms sending this rediculus ch
  6376.     beq    chclrt        ;[73] yes just forget it
  6377.     cmp   #esc          ;[58] Was it an 'escape'?
  6378.     bne   vt523          ;[58] If not, just output the character
  6379.     lda   #on          ;[58] Set the escape flag on
  6380.     sta   escflg          ;[58]         ...
  6381. vt522    jmp   tl0prc          ;[58] Go try for another character
  6382. vt523    jsr    curoff        ;[58] turn cur off
  6383.     cmp    #tab        ;[58] lets cover horizontal tabs
  6384.     beq    vt524        ;[58] not this one
  6385.     jmp    vtig1        ;[58] just output the ch
  6386. vt524    lda    hch        ;[58] get the horiz position
  6387.     and    #7        ;[58] now for the remainder of div by 8
  6388.     eor    #7        ;[58] now complement it
  6389.     tax            ;[58] into x
  6390. vtloop    jsr    advanc        ;[58] move cursor right one
  6391.     dex            ;[58] all thru spacing ?
  6392.     bpl    vtloop        ;[58] no
  6393.     jmp    tl0prc        ;[58] next
  6394. vt527                ;[58]
  6395.     jsr   curoff          ;[31] turn off the cursor
  6396.     lda   #off          ; First, turn off the escape flag
  6397.     sta   escflg          ;         ...
  6398. ;[74]    tya          ; Get the character to check
  6399.     lda    ksavea        ;[74] restore input ch
  6400.     cmp   #'A          ; It is, is it an 'A'?
  6401.     bne   vt52a          ; No, try next character
  6402. vt52a0    jsr    dchcv        ;[78] check for the top
  6403.     bcc    vt52b2        ;[78] yes
  6404.     lda    #$1f        ;[78] this is up one line
  6405.     jmp    cout        ;[78] doit and rtn
  6406. ;[78]    jsr   upline          ; Go up one line
  6407. ;[78]    jmp   vt52rt          ;[31] Turn on cursor and return
  6408. vt52a:    cmp   #'B          ; Is it a 'B'?
  6409.     bne   vt52b          ; Next char
  6410. vt52a2    jsr    bphcv        ;[78] check for the bottom
  6411.     bcs    vt52b2        ;[78] yes dont move down
  6412.     lda    #$a        ;[78] line feed
  6413.     jmp    cout        ;[78] doit and let cout rtn
  6414. ;[78]    jsr   lfeed          ; Yes, do a line feed
  6415. ;[78]    jmp   vt52rt          ;[31] Turn on cursor and return
  6416. vt52b:    cmp   #'C          ; 'C'?
  6417.     bne   vt52c          ; Nope
  6418. vt52b1    lda    #79        ;[78]
  6419.     cmp    hch        ;[78] have we gone too far?
  6420.     beq    vt52b2        ;[78] yes, forget about the movement
  6421.     jsr   advanc          ; Yes, go forward one space
  6422. vt52b2                ;[78]
  6423.     jmp   vt52rt          ;[31] Turn on cursor and return
  6424. vt52c:    cmp   #'D          ; 'D'?
  6425.     bne   vt52d          ; No
  6426. ;[76]    dec    hch        ;[58] back up one,do this for 80 col
  6427. ;[76]    bpl    vbsp2        ;[58] too far ? no
  6428. ;[76]    inc    hch        ;[58] yes stay at left side
  6429. ;[76]vbsp2    jsr    bsp        ;[58] now do the movement
  6430. ;[78]    jsr    bsp        ;[76] let backspace keep track of ch
  6431. vt52c2    jsr    dchch        ;[78]
  6432.     bcs    vt52b2        ;[78] too far ignore it
  6433.     lda    #bs        ;[78] now do a back space
  6434.     jsr    cout        ;[78]
  6435.     jmp   vt52rt          ;[31] Turn on cursor and return
  6436. vt52d:    cmp    #'G        ;[73] is this exit graphics?
  6437. ;[76]    beq    vt52rt        ;[73] yes currently just ignor it
  6438.     beq    vt52gg        ;[76] yes tell
  6439.     cmp    #'F        ;[76] how about special graphics?
  6440.     beq    vt52ff        ;[76] yes set it up
  6441.     cmp   #'H          ; 'H'?
  6442.     bne   vt52e          ; No, try next character
  6443.     lda   #$00          ; Zero out
  6444.     sta   ch          ;     cursor horizontal
  6445.     sta   cv          ;     and cursor vertical
  6446.     jsr   vtab          ; And then set the line base address
  6447.     jmp   vt52rt          ;[31] Turn on cursor and return
  6448. vt52e:    cmp   #'I          ; 'I'?
  6449.     bne   vt52f          ; Nope
  6450. ;[76]    lda   cv          ; Get the vertical cursor position
  6451. ;[76]    beq   vt52e1          ; Do reverse scrolling
  6452. vt52ri    lda    hcv        ;[76]
  6453.     cmp    wndtop        ;[76] are we at the top?
  6454.     beq    vt52e1        ;[76] yes do reverse scrool
  6455. ;[86]    jsr   upline          ; Otherwise, just go up one line
  6456.     ldx    hcv        ;[86] apple rom wont move above region
  6457.     beq    vt52rj        ;[86] dont go above 0
  6458.     dex            ;[86]
  6459.     stx    cv        ;[86] tell it where to go
  6460.     lda    hch        ;[86]
  6461.     sta    ch        ;[86]
  6462.     jsr    pos80c        ;[86] move up this way
  6463. vt52rj                ;[86]    
  6464.     jmp   vt52rt          ;[31] Turn on cursor and return
  6465. ;[76]vt52e1:    lda    #hlf        ;[58] this may take some time
  6466. ;[76]    ldx    #hcr        ;[58]
  6467. ;[76]    jsr    ckflow        ;[58] is case we must wait
  6468. vt52e1    jsr    fflow        ; force the flow stop
  6469.     jsr   vrscrl          ; Do the reverse scroll
  6470.     jmp   vt52rt          ;[31] Turn on cursor and return
  6471. vt52f:    cmp   #'J          ; 'J'?
  6472.     bne   vt52g          ; No
  6473.     jsr   clreop          ; Clear from where we are to end-of-page
  6474.     jmp   vt52rt          ;[31] Turn on cursor and return
  6475. vt52g:    cmp   #'K          ; 'K'?
  6476.     bne   vt52h          ; Try last option
  6477.     jsr   clreol          ; Clear to end-of-line
  6478.     jmp   vt52rt          ;[31] Turn on cursor and return
  6479. vt52h:    cmp   #'Y          ; 'Y'
  6480. ;[75]    bne   vtig          ; Must be an unimplemented function, do vtig
  6481.     bne   vt52eq          ;[75] try next
  6482.     jsr   vtdca          ; Do direct cursor addressing
  6483.     jmp   vt52rt          ;[31] Turn on cursor and return
  6484. vt52ff    inc    vtcso        ;[76] use vt100 sp graphics for now
  6485.     rts            ;[76]
  6486. vt52gg    lda    #0        ;[76] turn off spec graphics
  6487.     sta    vtcso        ;[76]
  6488.     rts            ;[76]
  6489. vt52ac    lda    #2        ;[80] switch to vt100
  6490.     sta    vtmod        ;[80]
  6491.     jsr    sutljp        ;[80] set it up
  6492.     rts            ;[80]
  6493. vt52ao    lda    #0        ;[80]
  6494. vt52ap    sta    kpafl        ;[80] turn on/off application mode
  6495.     jmp    vt52rt        ;[80]
  6496. vt52eq    cmp    #'=        ;[75] how about alt keypad
  6497. ;[80]    beq    vt52rt        ;[75] yes, currently just ignore
  6498.     beq    vt52ap        ;[80] set application mode
  6499.     cmp    #'>        ;[80] how about keypad
  6500.     beq    vt52ao        ;[80] set numeric mode
  6501.     cmp    #'<        ;[80] how about switching to vt100
  6502.     beq    vt52ac        ;[80] yup
  6503.     cmp    #'w        ;[85] wrap on
  6504.     beq    h19wn        ;[85]
  6505.     cmp    #'v        ;[85] wrap off
  6506.     beq    h19wf        ;[85]
  6507.     cmp    #'x        ;[85] h19 set modes
  6508.     beq    h19mds        ;[85]
  6509.     cmp    #'y        ;[85] h19 reset modes
  6510.     beq    h19mds        ;[85]
  6511.     cmp    #'Z        ;[76] is this identify terminal
  6512.     bne    vtig        ;[76] no
  6513.     lda    #esc        ;[76]
  6514.     jsr    telppc        ;[76]
  6515.     lda    #'/        ;[76]
  6516.     jsr    telppc        ;[76]
  6517.     lda    #'K        ;[76]
  6518.     jsr    telppc        ;[76]
  6519.     jmp    vt52rt        ;[76]
  6520. h19wn    inc    wrapar        ;[85] h19 wrap on
  6521.     rts            ;[85]
  6522. h19wf    lda    #0        ;[85] h19 wrap off
  6523.     sta    wrapar        ;[85]
  6524.     rts            ;[85]
  6525. h19mds    jsr    telcp        ;[85] ignore next ch
  6526.     beq    h19mds        ;[85]
  6527.     jsr    telgpc        ;[85]
  6528.     jsr    logput        ;[85] in case were loging
  6529.     rts            ;[85]
  6530.  
  6531. vtig:    ora   #$80          ; Set the H.O. bit for output
  6532.     pha          ; Save a copy
  6533.     lda   #hesc          ; Get an escape
  6534.     jsr   vprchr          ; Print the special character
  6535.     pla          ; Fetch the other character back
  6536.     cmp   #esc          ; Is it a second escape?
  6537.     bne   vtig1          ; Nope, print it
  6538.     lda   #on          ; Set escflg on again for next time around
  6539.     sta   escflg          ;         ...
  6540.     jmp   vt52rt          ;[31] Turn on cursor and return
  6541. ;[76]vtig1:    jsr   vprchr          ; Print the character
  6542. ;[78]vtig1:    jsr   vt1003        ;[76] check for sp graphics & pr ch
  6543. vtig1:    jsr   vt1002        ;[78] check for sp graphics & pr ch
  6544. ;[78]vt52rt: jsr   curon          ;[31] Turn on cursor
  6545. vt52rt: jmp   curon          ;[78][31] Turn on cursor & rts
  6546. vt5rts    rts          ; Return
  6547.  
  6548. ;[85]vprchr    cmp    #cr        ;[58] is this cr ?
  6549. vprchr    cmp    #del        ;[85] decs bs
  6550.     beq    vt52rt        ;[85] yes forget it
  6551.     cmp    #'        ;[85] a control ch?
  6552.     bge    vprch7        ;[85] no speed this up
  6553.     cmp    #cr        ;[85] is this cr ?
  6554.     bne    vprch0        ;[58] no
  6555. vpracr                ;[76]
  6556.     lda    #0        ;[58] position to start of line
  6557.     sta    ch        ;[58]
  6558.     sta    hch        ;[58] just in case were counting
  6559.     ldx    dsptyp        ;[62] is this 40 col
  6560. ;[76]    bpl    vt5rts        ;[58] yes
  6561.     bpl    vt52rt        ;[76][58] yes
  6562. vprch3                ;[84] so we can position not line feed
  6563.     lda    hcv        ;[76]
  6564.     sta    cv        ;[76] keep track
  6565.     jmp    pos80c        ;[58] yes position to start of line
  6566. vprch0    cmp    #lf        ;[58] is this a line feed ?
  6567.     bne    vprchw        ;[58] no
  6568. ;[76]    ldx    dellf        ;[58] should we ignore this one ?
  6569. ;[76]    beq    vprchb        ;[58] no let card handle cv
  6570. ;[76]    bne    vprch2        ;[76] no let lfeed handle cv
  6571. vprchl                ;[86] lf,ff & vt
  6572.     lda    vtmod        ;[76]
  6573.     cmp    #2        ;[76] is this vt100 mode
  6574.     beq    vprchm        ;[76] yes
  6575.     jmp    lfeed        ;[76] no just do the lf
  6576. ;[84]vprchm    lda    #$e        ;[76] make it normal video
  6577. ;[86]vprchm    lda    hch        ;[84] in case the region is above us
  6578. vprchm                ;[86]
  6579.     lda    vtcnlm        ;[86] how about new line mode
  6580.     beq    vprchn        ;[86] reset
  6581.     jsr    vpracr        ;[86] set, position to start of line
  6582. vprchn                ;[86]
  6583.     lda    hch        ;[84] in case the region is above us
  6584.     sta    ch        ;[84]
  6585.     jsr    bphcv        ;[84] incrememt hcv
  6586.     cpy    wndbtm        ;[85] y=hcv
  6587.     bne    vprch3        ;[84] were not about to scroll
  6588.     lda    #$e        ;[76] make it normal video
  6589.     jsr    cout        ;[76] in case this causes a scrool
  6590.     jsr    lfeed        ;[76] now do the lf
  6591.     lda    vtcsgr        ;[76] and restore the video
  6592.     jmp    cout        ;[76] & let cout do the rtn
  6593. ;[76]    ldx    #off        ;[58] only once
  6594. ;[76]    stx    dellf        ;[58]
  6595. ;[76]    beq    vt5rts        ;[58] yes ignore this, always jump
  6596. ;[76]    beq    vt52rt        ;[76][58] yes ignore this, always jump
  6597. vprchw    cmp    #bs        ;[58] how about a back space
  6598. ;[81]    bne    vprchd        ;[58] no
  6599. ;[85]    bne    vprchy        ;[81] no
  6600.     bne    vprchd        ;[85] no
  6601.     jmp    vt52c2        ;[78] do the backup thing
  6602. ;[85]vprchy    cmp    #del        ;[81] how about a del(decs back space)
  6603. ;[85]    bne    vprchd        ;[81] no
  6604. ;[85]    jmp    vt52rt        ;[81] ignore it
  6605. ;[78]    dec    hch        ;[58] yes back up
  6606. ;[78]    bmi    vprcha        ;[58] too far ? yes
  6607. ;[78]    bpl    vprchb        ;[58] no, now do the back up
  6608. ;[76]vprchx    ldx    #hcr        ;[58] at the right edge, cursor causes scroll
  6609. vprchx                ;[76]
  6610. ;[78]    pha            ;[58] save the current ch
  6611. ;[76]    lda    #hlf        ;[58] make it think we should stop
  6612. ;[76]    jsr    ckflow        ;[58] so we got to check for flow
  6613. ;    jsr    fflow        ;[76] force the flow check
  6614. ;[76]    sta    dellf        ;[58] turn on flag
  6615. ;[78]    lda    wrapar        ;[76] are we wrapping arround?
  6616.     ldx    wrapar        ;[78] are we wrapping arround?
  6617. ;[78]    beq    vprchy        ;[76] no
  6618.     beq    vt5rts        ;[78] no, do nothing
  6619.     pha            ;[78]
  6620.     jsr    vpracr        ;[76] yes first a cr
  6621.     jsr    lfeed        ;[76]
  6622. ;[78]vprchy                ;[76]
  6623.     pla            ;[58] restore current ch
  6624.     bne    vprch7        ;[85] keep track of pos
  6625. ;[76]    ldx    #0        ;[58] 
  6626. ;[76]    stx    hch        ;[58] let us know its the start of the line
  6627. ;[76]    jsr    bphcv        ;[76] bump hcv if not at window bottom
  6628. ;[78]    ora    #$80        ;[58] so it will print
  6629. ;[78]    jmp    cout        ;[58] do it
  6630. vprchd                ;[58]
  6631.     cmp    #ffd        ;[86] form feed is like a lf
  6632.     beq    vprchl        ;[86]
  6633.     cmp    #ctrlk        ;[86] vertical tab is like a lf
  6634.     beq    vprchl        ;[86]
  6635. ;[76]    ldx    #off        ;[58] turn off lf delete
  6636. ;[76]    stx    dellf        ;[58]
  6637. ;[76]    ldx    #80        ;[58]
  6638. ;[76]    ldy    dsptyp        ;[62] is this 80 col display?
  6639. ;[76]    bmi    .+4        ;[62] hate to do this
  6640. ;[76]    ldx    #40        ;[62] no
  6641. ;[76]    cpx    hch        ;[58] too far ?
  6642. ;[76]    beq    vprchx        ;[58] just right this should cause scroll
  6643.     cmp    #bel        ;[82]
  6644. ;[85]    bne    vprche        ;[82]
  6645.     bne    vprchb        ;[85]
  6646. ;[85] fflow prsevers a reg    pha            ;[82] save it
  6647.     jsr    fflow        ;[82] stop this while ring ring
  6648. ;[85]    pla            ;[82] now ring those bells
  6649. ;[86]    bne    vprchb        ;[82]
  6650.     jmp    vprchb        ;[86] dono how it got past the bne
  6651. ;[85]vprche                ;[82]
  6652. ;[85]    cmp    #'         ;[78] is this control ch?
  6653. ;[85]    bcc    vprchb        ;[78] yes, forget about keeping track
  6654. vprch7                ;[85]
  6655.     ldx    hch        ;[76]
  6656.     cpx    wndwth        ;[76] this is 40 or 80
  6657.     bcs    vprchx        ;[76] too much,yes
  6658. ;[85]    inc    hch        ;[58] move one right
  6659.     inx            ;[85] is quicker this way
  6660. ;[76]    bpl    vprchb        ;[58] no
  6661. ;[76]    bne    vprchb        ;[76] no
  6662. ;[78]    bcc    vprchb        ;[76] always jump
  6663. ;[78]vprcha    ldx    #0        ;[58] start at left edge of screen
  6664. ;[78]    stx    hch        ;[58]
  6665. ;[85]    ldx    $fbb3        ;[78]
  6666. ;[85]    cpx    #6        ;[78] is this a //e or above ?
  6667. ;[85]    bne    vprchb        ;[78] no forget about 24 x 80 position
  6668. ;[85]    ldx    hch        ;[78]
  6669.     stx    hch        ;[85] speed?
  6670. ;[84]    cpx    #80        ;[78] cludge to not write
  6671.     cpx    wndwth        ;[84] cludge to not write
  6672.     bne    vprchb        ;[78] in last position 
  6673. ;[86]    ldx    hcv        ;[78] of screen **** stupid ****
  6674. ;[83]    cpx    #23        ;[78]
  6675. ;[86]    inx            ;[83]
  6676. ;[86]    cpx    wndbtm        ;[83] use end of scrooling region
  6677. ;[84]    bne    vprchb        ;[78]
  6678. ;[86]    blt    vprchb        ;[84]
  6679. ;[86]    ldx    $fbb3        ;[85]
  6680. ;[86]    cpx    #6        ;[85] is this a //e or above ?
  6681. ;[86]    bne    vprchb        ;[85] no forget about 24 x 80 position
  6682. ;[87]    ldx    itse80        ;[86] //e or better?
  6683.     ldy    itse80        ;[87] //e or better?
  6684.     beq    vprchb        ;[86] no forget about 24 x 80 position
  6685.     ldy    #39        ;[78] depend upon cursor
  6686.     sta    (basl),y    ;[78] being in correct position & overwrite
  6687.     dex            ;[87] hope this moves cursor but not scrool
  6688.     stx    ch        ;[87]
  6689.     lda    hcv        ;[87]
  6690.     sta    cv        ;[87]
  6691.     jsr    pos80c        ;[87] let rom know where we are
  6692.     inc    hch        ;[87] now back
  6693.     rts            ;[78] cant write it or it will scrool
  6694. vprchb    ora    #$80        ;[58] make it printable
  6695. ;[85]    ldx    #hcr        ;[57] range of test is cr-1 thru lf
  6696.     jsr    ckflow        ;[57] now check for flow control
  6697.     jmp    cout        ;[58] and print ch
  6698. ;[62]vprch1    jmp    prchr        ;[58] print ch
  6699.  
  6700. vrscrl:    lda    dsptyp        ;[58] we may have an 80 col
  6701.     bpl    vrscr0        ;[58] that will do this! sigh! no
  6702.     lda    #$16        ;[58] a syn does reverse scroll ?
  6703.     jmp    cout        ;[58] maybe else were no better than we were
  6704. vrscr0                ;[58] do it the hard way
  6705.     lda   wndbtm          ; Start at bottom of window
  6706.     pha          ; Save ac
  6707.     jsr   vtabz          ; Generate base address
  6708. vrsc1:    lda   basl          ; Move basl,h to bas2l,h
  6709.     sta   bas2l          ;         ...
  6710.     lda   bash          ;         ...
  6711.     sta   bas2h          ;         ...
  6712. ;[76]    ldy    #0        ;[58] got to start at first ch
  6713.     ldy    wndwth        ;[76] doesnt mater which order you move
  6714.     dey            ;[76] but count must be -1
  6715.     pla          ; Get window bottom
  6716.     sec          ; Decrement by one
  6717.     sbc   #$01          ;         ...
  6718.     cmp   wndtop          ; Are we done?
  6719. ;[76]    bcs   vrsc3          ; Yup
  6720.     bmi   vrsc3          ;[76] Yup
  6721.     pha          ; Save new line number
  6722.     jsr   vtabz          ; Generate this line's base address
  6723. vrsc2:    lda   (basl),y      ; Move a character down a line
  6724.     sta   (bas2l),y      ;         ...
  6725. ;[76]vrsc2b    cpy    wndwth        ;[58] are we at the edge of the window ?
  6726. ;[76]    beq    vrsc2c        ;[58] not yet
  6727. ;[76]    bpl    vrsc1        ;[58] yes get next line up
  6728. ;[76]vrsc2c    iny            ;[58] ready for next ch
  6729. ;[76]    jmp    vrsc2        ;[58]
  6730.     dey            ;[76] next
  6731.     bpl    vrsc2        ;[76] theres more
  6732.     bmi    vrsc1        ;[76] next line
  6733. ;[76]vrsc3:    ldy    #0        ;[58] set for top line
  6734. vrsc3:    ldy    wndtop        ;[76][58] set for top line
  6735.     sty    cv        ;[58]
  6736.     jsr   scrl3          ; Clear the entire top line
  6737.     rts          ; Return
  6738.  
  6739. vtdca:    jsr   telcp          ; Check for a character from the port
  6740.     beq   vtdca          ; Try again
  6741.     jsr   telgpc          ; Get the character waiting at the port
  6742.     jsr    logput        ;[56] may be loging
  6743.     and   #$7f          ; Make sure H.O. bit is off
  6744.     sec          ; Subtract hex 20 (make it num from 0 to 23)
  6745.     sbc   #$20          ;         ...
  6746.     bpl   vtdca1          ; No, continue
  6747. vtdca9    clc          ; Clear carry
  6748.     adc   #$20          ; Add this back in
  6749.     jmp   vtig          ; Now ignore it as a control paramenter
  6750. vtdca1: cmp   #24          ; Is it too large?
  6751.     bpl    vtdca9        ;[58] yes
  6752. vtdca2: sta   hcv          ; Store it as the vertical cursor position
  6753. vtdca3: jsr   telcp          ; Check port for character
  6754.     beq   vtdca3          ;     go back and try again
  6755.     jsr   telgpc          ; Get the character waiting at the port
  6756.     jsr    logput        ;[56] may be loging
  6757.     and   #$7f          ; Make sure H.O. bit is off
  6758.     sec          ; Subtract hex 20 (make it num from 0 to 23)
  6759.     sbc   #$20          ;         ...
  6760.     bmi    vtdca9        ;[58] too small
  6761. vtdca4: cmp   #80          ; Is it too large?
  6762.     bpl    vtdca9        ;[58] yes
  6763. vtdca5: sta   ch          ; Store it as the horizontal cursor position
  6764.     sta    hch        ;[58] save this for our count
  6765.     lda   hcv          ; Move this to the real position now
  6766.     sta   cv          ;         ...
  6767.     jsr   vtab          ; Now place the cursor there
  6768.     rts          ;     and return
  6769.  
  6770. dchch    pha            ;[76] dec hch
  6771.     clc            ;[78] clear carry for ok
  6772.     dec    hch        ;[76]
  6773.     bpl    dchchr        ;[76] too far?,no
  6774.     inc    hch        ;[76] yes
  6775.     sec            ;[78] set carry for too far
  6776. dchchr    pla            ;[76]
  6777.     rts            ;[76]
  6778. dchcv    pha            ;[76] dec hcv
  6779.     dec    hcv        ;[76] up one line
  6780.     lda    hcv        ;[76]
  6781.     cmp    wndtop        ;[76] but not too far
  6782.     bcs    dchcvr        ;[76] ok? yes
  6783.     inc    hcv        ;[76] no
  6784. dchcvr    pla            ;[76]
  6785.     rts            ;[76]
  6786. ;[84]bphcv    pha            ;[76] bump hcv
  6787. ;[84]    inc    hcv        ;[76]
  6788. ;[84]    lda    hcv        ;[76]
  6789. ;[84]    cmp    wndbtm        ;[76] too far? rem wndbtm is +1
  6790. ;[84]    bcc    bphcvr        ;[76] no
  6791. ;[84]    dec    hcv        ;[76]
  6792. ;[84]    lda    #0        ;[84] make the status beq
  6793. ;[84]bphcvr    pla            ;[76]
  6794. ;[84]    rts            ;[76]
  6795. bphcv    ldy    hcv        ;[84] bump hcv unless scrolling
  6796.     iny            ;[84]
  6797.     cpy    wndbtm        ;[84] at window bottom?
  6798.     beq    bphcvr        ;[84] yes no change we should scroll
  6799.     cpy    #24        ;[85] dont go off the screen
  6800.     bge    bphcvr        ;[85]
  6801.     sty    hcv        ;[84] bump hcv
  6802. bphcvr    rts            ;[84]
  6803. vtc2i                ;[87] VT102 PRINTER ON/OFF CODE
  6804.     lda    vtcpar        ;[87]
  6805.     cmp    #4        ;[87] is this printer off?
  6806.     bne    vtc2i3        ;[87] no
  6807.     jsr    prnon        ;[87] yes turn printer off
  6808.     jmp    vtccom        ;[87] bye
  6809. vtc2i3    cmp    #5        ;[87] how about printer on?
  6810.     bne    vtc2i7        ;[87] no,just ignore it maybe it will go away
  6811.     jsr    prnoff        ;[87] yes try and turn it on
  6812. vtc2i7    jmp    vtccom        ;[87] bye
  6813. vtclb    jsr    telcp        ;[79] LINE SIZE ETC
  6814.     beq    vtclb        ;[79]
  6815.     jsr    telgpc        ;[79] now get the next ch
  6816.     jsr    logput        ;[79] fputc adds the $80
  6817.     jmp    vtccom        ;[79] bye
  6818. vtcglp                ;[76] G0 CHARACTER SET
  6819. ;[78]    jsr    telcp        ;[76] gpet the next ch we need it
  6820. ;[78]    beq    vtcglp        ;[76]
  6821. ;[78]    jsr    telgpc        ;[76] now get the next ch
  6822. ;[78]    and    #$7f        ;[76] make it ascii
  6823. ;[78]    jsr    logput        ;[76] just in case were loging
  6824. ;[78]    jmp    vtcgr2        ;[76] spill it
  6825.     lda    #1        ;[78] this is mask for bit 0
  6826.     jmp    vtcgr0        ;[78] together again
  6827.  
  6828. vtcgrp                ;[76] G1 CHARACTER SET
  6829.     lda    #2        ;[78] mask for bit 1
  6830. vtcgr0    sta    kwrk01        ;[78] save the mask
  6831. vtcgr7                ;[78]
  6832.     jsr    telcp        ;[76] get the next ch we need it
  6833. ;[78]    beq    vtcgrp        ;[76]
  6834.     beq    vtcgr7        ;[76] wait for next ch
  6835.     jsr    telgpc        ;[76] now get the next ch
  6836.     and    #$7f        ;[76] make it ascii
  6837.     jsr    logput        ;[76] just in case were loging
  6838.     cmp    #'B        ;[76]
  6839.     beq    vtcgr4        ;[76]
  6840.     cmp    #'A        ;[78] uk set will be the same
  6841.     beq    vtcgr4        ;[78]
  6842.     cmp    #'1        ;[78] alt rom will be the same
  6843.     beq    vtcgr4        ;[78]
  6844.     cmp    #'2        ;[78] alt rom special graphics is the same
  6845.     beq    vtcgr1        ;[78]
  6846.     cmp    #'0        ;[76] are we drawing lines etc?
  6847. ;[78]    bne    vtcgr2        ;[76] no
  6848.     beq    vtcgr1        ;[78] yes
  6849. ;[78]vtcgr2    jsr    svnisc        ;[76] save this one for spill
  6850.     jsr    svnisc        ;[78] save this one for spill
  6851.     jmp    vtcspl        ;[76] tattle
  6852. ;[78]vtcgr1    inc    vtcscs        ;[76] now tell we need g1 ch set
  6853. vtcgr1    lda    kwrk01        ;[78] get the mask
  6854.     ora    vtcscs        ;[78]
  6855.     sta    vtcscs        ;[78]
  6856.     jmp    vtccom        ;[76]
  6857. ;[78]vtcgr2    jsr    svnisc        ;[76] save this one for spill
  6858. ;[78]    jmp    vtcspl        ;[76] tattle
  6859. ;[78]vtcgr4    lda    #0        ;[76] turn off the special graphics
  6860. vtcgr4    lda    kwrk01        ;[78]
  6861.     eor    #$ff        ;[78] complement it
  6862.     and    vtcscs        ;[78] this clears the bit
  6863.     sta    vtcscs        ;[76]
  6864.     jmp    vtccom        ;[76]
  6865. vtc7    lda    hcv        ;[76] SAVE CURSOR
  6866.     sta    ohcv        ;[76] first hcv
  6867.     lda    hch        ;[76]
  6868.     sta    ohch        ;[76] and now hch
  6869.     lda    vtcscs        ;[76] save the ch set
  6870.     sta    ovtcsc        ;[76]
  6871.     lda    vtcso    ;[78] save the graphics in action flags
  6872.     sta    ovtcso    ;[78]
  6873.     lda    vtcsgr        ;[76] save the graphics rendition
  6874.     sta    ovtcsg        ;[76]
  6875.     jmp    vtccom        ;[76] thats all
  6876. vtc8    lda    ohcv        ;[76] RESTORE CURSOR
  6877.     sta    cv        ;[76] pos80c will set hcv & hch
  6878.     lda    ohch        ;[76]
  6879.     sta    ch        ;[76]
  6880.     jsr    pos80c        ;[76] now reposition
  6881.     lda    ovtcsc        ;[76] restore the ch set
  6882.     sta    vtcscs        ;[76]
  6883.     lda    ovtcso    ;[78] restore the graphics in action flags
  6884.     sta    vtcso    ;[78]
  6885.     lda    ovtcsg        ;[76] restore the graphics rendition
  6886.     sta    vtcsgr        ;[76]
  6887.     jsr    cout        ;[76]
  6888.     jmp    vtccom        ;[76] bye
  6889. ;[85]vtcqmk    inc    vtcqmf        ;[76] tell that we have a ?
  6890. vtcqmk                ;[85] not used
  6891.     rts            ;[76]
  6892. vtca    lda    #0        ;[80]    KEYPAD NUMERIC MODE
  6893. vtc9    sta    kpafl        ;[80]    KEYPAD APPLICATION MODE
  6894.     jmp    vtccom        ;[80] application better not be first in table
  6895. vtc2ll                        ;[76]  RESET MODES
  6896. ;    lda    vtcqmf        ;[76] was there a ?
  6897. ;    beq    vtcll0        ;[76]
  6898.     lda    vtcpar        ;[76]
  6899.     cmp    #1        ;[76] was the param a 1?
  6900.     beq    vtcll2        ;[76] yes, cursor key mode
  6901.     cmp    #6        ;[76]
  6902.     beq    vtcll8        ;[76] origin mode - absolute
  6903.     cmp    #5        ;[78]
  6904. ;[80]    beq    vtcll6        ;[78] screen mode normal-we cant do anything
  6905.     beq    vtclla        ;[80] screen mode normal
  6906.     cmp    #2        ;[80] switch to vt52?
  6907.     beq    vtcllc        ;[80] yes
  6908.     cmp    #3        ;[76]
  6909.     beq    vtcll6        ;[76] 80 col mode
  6910.     cmp    #4        ;[76]
  6911.     beq    vtcll6        ;[76] scroll mode - jump
  6912.     cmp    #8        ;[76]
  6913.     beq    vtcll6        ;[76] auto repeat - off
  6914.     cmp    #7        ;[76]
  6915.     beq    vtcll5        ;[76] wraparound off
  6916.     cmp    #20        ;[76]
  6917. ;[86]    beq    vtcll6        ;[76] its line feed
  6918.     beq    vtclld        ;[86] its line feed
  6919. vtcll0    jmp    vtcspl        ;[76] no dont understand this one, tattle
  6920. vtcll2    lda    #off        ;[76] clear the vt100 mode flag
  6921. vtcll3                ;[82]
  6922.     sta    vtcmod        ;[76]
  6923.     jsr    scurst        ;[82]
  6924.     jmp    vtccom        ;[76]
  6925. vtcll5    lda    #off        ;[76] maybe we should check for the ?
  6926.     sta    wrapar        ;[76] no wrap arround
  6927. vtcll6    jmp    vtccom        ;[76]
  6928. vtcll8    lda    #0        ;[78] set abs mode
  6929.     sta    vtcorm        ;[78]
  6930.     jmp    vtccom        ;[78]
  6931. vtclla                ;[80]
  6932.     lda    #$e        ;[80] normal video
  6933. vtcllb    sta    vtcsgr        ;[80] save special graphics rendition
  6934.     jsr    cout        ;[80]
  6935.     jmp    vtccom        ;[80]
  6936. vtcllc    lda    #3        ;[80] switch to vt52
  6937.     sta    vtmod        ;[80]
  6938.     jsr    sutljp        ;[80] setup term
  6939.     jmp    vtccom        ;[80]
  6940. scurst    lda    #'O        ;[82] assume set
  6941.     ldy    vtcmod        ;[82]
  6942.     bne    scurs3        ;[82]
  6943.     lda    #'[        ;[82] its reset
  6944. scurs3    sta    cufksc+1    ;[82] now set vt100 cursor keys 
  6945.     sta    bsfksc+1    ;[82] appropiately
  6946.     sta    ckfksc+1    ;[82]
  6947.     sta    cjfksc+1    ;[82]
  6948.     rts            ;[82]
  6949. vtclld    lda    #0        ;[86] reset line feed
  6950. vtclht    sta    vtcnlm        ;[86] new line mode
  6951.     jmp    vtccom        ;[86]
  6952. vtc2lh                        ;[76] SET MODES
  6953. ;    lda    vtcqmf        ;[76] was there a ?
  6954. ;    beq    vtcll0        ;[76] no dont know what this is
  6955.     lda    vtcpar        ;[76]
  6956.     cmp    #1        ;[76]
  6957.     beq    vtclh2        ;[76] cursor keys
  6958.     cmp    #7        ;[76] how about wrap arround?
  6959.     beq    vtclh4        ;[76] yes
  6960.     cmp    #5        ;[78] how about reverse screen?
  6961. ;[80]    beq    vtcll6        ;[78] yes - we cant do anything
  6962.     beq    vtclh8        ;[80] yes
  6963.     cmp    #6        ;[78] how about relative origin?
  6964.     beq    vtclh6        ;[78] yes
  6965.     cmp    #8        ;[76]
  6966.     beq    vtcll6        ;[76] auto repeat - on
  6967.     cmp    #20        ;[86] new line
  6968.     beq    vtclht        ;[86] yup set it
  6969.     jmp    vtcspl        ;[76] tattle, we dont know this one
  6970. ;[82]vtclh2    inc    vtcmod        ;[76] tell were using "O"
  6971. ;[82]    jmp    vtccom        ;[76]
  6972. vtclh2    lda    #on        ;[82] for set
  6973.     jmp    vtcll3        ;[82]
  6974. vtclh4    lda    #on        ;[76]
  6975.     sta    wrapar        ;[76] yes we will wrap arround
  6976.     jmp    vtccom        ;[76] thats all
  6977. vtclh6    inc    vtcorm        ;[78] set relative origin for the region
  6978.     jmp    vtccom        ;[78]
  6979. vtclh8    lda    #$f        ;[80] inverse video
  6980.     jmp    vtcllb        ;[80] common code
  6981. vtlesc    lda    #esc        ;[76] 2 esc in a row
  6982.     dec    nisc        ;[76]
  6983.     jmp    prchr        ;[76] print a ^$ and let it rts
  6984. vtc2bp    inc    vtcpnm        ;[76] next param
  6985.     rts            ;[76]
  6986. vtcpsq    inc    vtcesc        ;[76] its a [ so look for parms
  6987.     rts            ;[76]
  6988. ;[78]vtc2b    jsr    lfeed        ;[76] its a LINE FEED
  6989. vtc2b    jsr    vt52a2        ;[78] its a LINE FEED
  6990.     dec    vtcpar        ;[76] 1st param
  6991.     beq    vtc2b2        ;[76]
  6992.     bpl    vtc2b        ;[76] another line feed
  6993. vtc2b2    jmp    vtccom        ;[76] common 
  6994. ;[78]vtc2d    jsr    bsp        ;[76] its a BACKSPACE
  6995. vtc2d    jsr    vt52c2        ;[78] use this so we keep track of where we are
  6996.     dec    vtcpar        ;[76] 1st param
  6997.     beq    vtc2d2        ;[76] thats all
  6998.     bpl    vtc2d        ;[76] another 
  6999. vtc2d2    jmp    vtccom        ;[76]
  7000. ;[78]vtc2c    jsr    advanc        ;[76] FORWARD SPACE
  7001. vtc2c    jsr    vt52b1        ;[78] FORWARD SPACE
  7002.     dec    vtcpar        ;[76] 1st parm
  7003.     beq    vtc2c2        ;[76] more? no
  7004.     bpl    vtc2c        ;[76] yes
  7005. vtc2c2    jmp    vtccom        ;[76]
  7006. vtc2h    lda    vtcpar        ;[76] 1st param POSITION
  7007.     beq    vtc2h2        ;[76]
  7008.     sec            ;[76]
  7009.     sbc    #1        ;[76]
  7010. vtc2h2    sta    cv        ;[76]
  7011.     ldx    vtcorm        ;[78] is this relative origin?
  7012.     beq    vtc2h3        ;[78] no its absolute
  7013.     clc            ;[78] yes add the top
  7014.     adc    wndtop        ;[78]
  7015.     sta    cv        ;[78] now set the new origin
  7016. vtc2h3                ;[78]
  7017.     cmp    #25        ;[87] are we off the screen?
  7018.     blt    vtc2h7        ;[87]
  7019.     ldx    #24        ;[87] yes, too big
  7020.     dex            ;[87] force bottom
  7021.     stx    cv        ;[87]
  7022. vtc2h7                ;[87]    
  7023.     lda    vtcpar+1    ;[76] 2nd param
  7024.     beq    vtc2h4        ;[76]
  7025.     cmp    wndwth        ;[87] are we beyond the edge?
  7026.     blt    vtc2h9        ;[87]
  7027.     lda    wndwth        ;[87] yes bring it back
  7028. vtc2h9                ;[87]    
  7029.     sec            ;[76]
  7030.     sbc    #1        ;[76]
  7031. vtc2h4    sta    ch        ;[76]
  7032.     jsr    pos80c        ;[76] position to it
  7033.     jmp     vtccom        ;[76]
  7034. ;[78]vtc2a    jsr    upline        ;[76] UP ONE
  7035. vtc2a    jsr    vt52a0        ;[78] UP ONE
  7036.     dec    vtcpar        ;[76] 1st param
  7037.     beq    vtc2a2        ;[76] default
  7038.     bpl    vtc2a        ;[76] another? yes
  7039. vtc2a2    jmp    vtccom        ;[76] thats all
  7040. vtc2j                ;[76]         - ERASING SCREEN
  7041.     lda    #$e        ;[76] make it normal
  7042.     jsr    cout        ;[76] while we erase
  7043.     lda    vtcpar        ;[76] 1st param
  7044. ;[82]    beq    jcleop        ;[76] any params? no
  7045.     beq    jclpg3        ;[82] any params? no
  7046.     cmp    #2        ;[76] page?
  7047.     beq    jclpg        ;[76] yes
  7048. jcl2cu    lda    hcv        ;[76] save current
  7049.     sta    kwrk01        ;[76]
  7050.     lda    hch        ;[76]
  7051.     sta    kwrk02        ;[76]
  7052.     lda    #0        ;[76] now home it
  7053.     sta    cv        ;[76]
  7054. jcl2cw    sta    ch        ;[76]
  7055.     jsr    pos80c        ;[76]
  7056. vtc2j1                ;[76]
  7057.     ldx    hcv        ;[76]
  7058.     cpx    kwrk01        ;[76] are we down to current line
  7059. ;[85]    bcs    vtc2j2        ;[76]
  7060.     bge    vtc2j2        ;[85]
  7061.     jsr    clreol        ;[76] no clear this line
  7062.     inc    cv        ;[76]
  7063.     lda    #0        ;[76] position to next line
  7064.     jmp    jcl2cw        ;[76]
  7065. ;    lda    wrapar        ;[76] in order for this to work 
  7066. ;    pha            ;[76] we must wrap arround, save current
  7067. ;    lda    #hspace        ;[76] print a space
  7068. ;    sta    wrapar        ;[76] set wrap arround on (non 0)
  7069. vtc2j2    lda    #hspace        ;[76] blank start of this line
  7070. ;[85]vtc2j3    jsr    vprchd        ;[76] vt52 rtn to keep track of hvh & hcv
  7071. vtc2j3    jsr    vprch7        ;[85] vt52 rtn to keep track of hvh & hcv
  7072.     ldx    hch        ;[76]
  7073.     cpx    kwrk02        ;[76]
  7074. ;[85]    bcc    vtc2j3        ;[76]
  7075.     blt    vtc2j3        ;[85]
  7076. ;    pla            ;[76] restore the wrap arround
  7077. ;    sta    wrapar        ;[76]
  7078. ;    lda    kwrk01        ;[76] now restore cursor to orig place
  7079. ;    sta    cv        ;[76]
  7080. ;    lda    kwrk02        ;[76]
  7081. ;    sta    ch        ;[76]
  7082. ;    jsr    pos80c        ;[76]
  7083. ;[85]    jmp    jclep2        ;[76]
  7084.     bge    jclep2        ;[76]
  7085. jcleop    jsr    clreop        ;[76] clear to end of page
  7086. jclep2    lda    vtcsgr        ;[76] restore current special graphics
  7087.     jsr    cout        ;[76]
  7088.     jmp    vtccom        ;[76]
  7089. jclpg                ;[76] clear page and home
  7090.     lda    #0        ;[76]
  7091.     sta    cv        ;[76]
  7092.     sta    ch        ;[76]
  7093.     jsr    pos80c        ;[76]
  7094. jclpg3                ;[82]
  7095.     lda    wndbtm        ;[78]
  7096.     pha            ;[78] save current bottom
  7097.     lda    #24        ;[78] and set max 
  7098.     sta    wndbtm        ;[78] to clear all of screen
  7099. ;[78]    jmp    jcleop        ;[76] common code
  7100.     jsr    jcleop        ;[78] common code
  7101.     pla            ;[78] restore current bottom of screen
  7102.     sta    wndbtm        ;[78]
  7103.     rts            ;[78] bye
  7104. vtc2k    lda    vtcpar        ;[76] 1st param - LINE ERASING
  7105.     beq    vtc2k4        ;[76] default is 0
  7106.     ldx    hcv        ;[76]
  7107.     stx    kwrk01        ;[76]
  7108.     stx    cv        ;[85]
  7109.     cmp    #2        ;[76]
  7110.     beq    vtc2k2        ;[76]clear line
  7111.     lda    hch        ;[76] clear from sart of line to current pos
  7112.     sta    kwrk02        ;[76]
  7113. ;[85]    lda    hcv        ;[76]
  7114. ;[85]    sta    cv        ;[76]
  7115. ;[85]    sta    kwrk01        ;[76]
  7116.     lda    #0        ;[76] start of line
  7117.     jmp    jcl2cw        ;[76]
  7118. vtc2k2    lda    #0        ;[76]
  7119.     sta    ch        ;[76]
  7120. ;[85]    lda    hcv        ;[76]
  7121. ;[85]    sta    cv        ;[76]
  7122.     jsr    pos80c        ;[76]
  7123. vtc2k4    lda    #$e        ;[76] clear must also reset inverse video
  7124.     jsr    cout        ;[76] so reset it
  7125.     jsr    clreol        ;[76] clear this line
  7126. ;[83]    jmp    vtccom        ;[76]
  7127.     jmp    jclep2        ;[83] just in case its special video
  7128. vtlh    ldx    nita        ;[76] # in tab array - SET TABS
  7129.     beq    vtlh4        ;[76] 0? yes
  7130. vtlh2    lda    tabary-1,x    ;[76] 
  7131.     cmp    hch        ;[76]
  7132.     bcc    vtlh4        ;[76] add it
  7133.     beq    vtlh6        ;[76] already there
  7134.     sta    tabary,x    ;[76]
  7135.     dex            ;[76]
  7136.     bne    vtlh2        ;[76] all of array? no
  7137. vtlh4    lda    hch        ;[76] add current position
  7138.     sta    tabary,x    ;[76]
  7139.     inc    nita        ;[76] and tell how many
  7140. vtlh6    jmp     vtccom        ;[76]
  7141. vtld    jsr    lfeed        ;[76] DOWN ONE
  7142.     jmp    vtccom        ;[76]
  7143. vtle    jsr    prcrlf        ;[76] start of next line
  7144.     lda    #0        ;[76]
  7145.     sta    hch        ;[76]
  7146.     jsr    bphcv        ;[76] bump hcv
  7147.     jmp    vtccom        ;[76]
  7148. ;[85]vtlm    jsr    vt52ri        ;[76] REVERSE LINE FEED
  7149. vtlm    lda    #$e        ;[85] do this in rormal 
  7150.     jsr    cout        ;[85]
  7151.     jsr    vt52ri        ;[85] REVERSE LINE FEED
  7152.     lda    vtcsgr        ;[85] now restore graphics
  7153.     jsr    cout        ;[85]
  7154.     jmp    vtccom        ;[76]
  7155. vtc2g    lda    vtcpar        ;[76] 1st param- CLEAR TABS
  7156.     beq    vtc2g2        ;[76]
  7157.     cmp    #3        ;[76]
  7158.     bne    vtc2g7        ;[76]
  7159.     lda    #0        ;[76]
  7160.     sta    nita        ;[76] empty tab array
  7161. vtc2g1    jmp    vtccom        ;[76]
  7162. vtc2g7    jmp    vtcspl        ;[76] unknown spill it
  7163. vtc2g2    ldy    #0        ;[76]
  7164.     ldx    nita        ;[76] number in tab array
  7165.     beq    vtc2g1        ;[76] none
  7166.     lda    hch        ;[76] current pos
  7167. vtc2g4    cmp    tabary,y    ;[76]
  7168.     beq    vtc2g6        ;[76]
  7169.     bcc    vtc2g1        ;[76] thats all
  7170.     iny            ;[76]
  7171.     dex            ;[76]
  7172.     bne    vtc2g4        ;[76] thru? no
  7173.     beq    vtc2g1        ;[76] yes
  7174. vtc2g6    iny            ;[76]
  7175.     lda    tabary,y    ;[76]
  7176.     sta    tabary-1,y    ;[76]
  7177.     cpy    nita        ;[76]
  7178.     bne    vtc2g6        ;[76] all of tabs? no
  7179.     dec    nita        ;[76]
  7180.     jmp    vtccom        ;[76]
  7181. vtc2m    ldx    #0        ;[76] search in fifo order     SET 
  7182. vtc2m2    lda    vtcpar,x    ;[76]
  7183.     beq    vtc2m6        ;[76]
  7184.     cmp    #7        ;[76]
  7185.     beq    vtc2m8        ;[76] reverse video
  7186.     cmp    #4        ;[76] is it underline?
  7187.     beq    vtc2m8        ;[76] reverse video is the best we have
  7188.     cmp    #5        ;[80] is it blink?
  7189.     beq    vtc2m8        ;[80] reverse video is the best we have
  7190.     cmp    #1        ;[80] is it bold?
  7191.     beq    vtc2m8        ;[80] reverse video is the best we have
  7192. vtc2m4    inx            ;[76] next
  7193.     cpx    vtcpnm        ;[76]
  7194.     beq    vtc2m2        ;[76]
  7195.     bmi    vtc2m2        ;[76]
  7196.     jmp    vtccom        ;[76] no more
  7197. vtc2m6    lda    #$e        ;[76] normal video
  7198. vtc2m7    sta    vtcsgr        ;[76] save special graphics rendition
  7199.     jsr    cout        ;[76]
  7200.     jmp    vtc2m4        ;[76]
  7201. vtc2m8    lda    #$f        ;[76] inverse video
  7202.     bne    vtc2m7        ;[76] always branch
  7203. ;talso    lda    #$e        ;[76] the default case of 0
  7204. ;    jsr    cout        ;[76]
  7205. ;    jmp    vtccom        ;[76]    
  7206. vtc2lr    lda    vtcpar        ;[76] 1st param - DEFINE SCROOL REGION
  7207.     cmp    vtcpar+1    ;[76] 2nd param
  7208.     bcc    vtclr2        ;[76]
  7209.     ora    vtcpar+1    ;[76] is this the default?
  7210.     beq    vtclr6        ;[76] yes
  7211.     jmp    vtcspl        ;[76] bad window
  7212. vtclr2                ;[76]
  7213.     sta    wndtop        ;[76] top line of window
  7214.     dec    wndtop        ;[76] they start at 1
  7215.     bpl    vtclr4        ;[76] is this default of 0?
  7216.     inc    wndtop        ;[76] yes set it back to 0
  7217. vtclr4    lda    vtcpar+1    ;[76] 2nd param
  7218. vtclr5    sta    wndbtm        ;[76] bottom line of window, we need +1
  7219.     lda    #0        ;[76]
  7220.     sta    ch        ;[76]
  7221. ;apple 80 col must home to 0 sigh! jove fails insert chs then cr
  7222. ;    lda    wndtop        ;[84] home to top of region
  7223.     sta    cv        ;[76] expects to home also
  7224.     jsr    pos80c        ;[76]
  7225.     jmp    vtccom        ;[76]
  7226. vtclr6    lda    #0        ;[76] reset the region
  7227.     sta    wndtop        ;[76]
  7228.     lda    #24        ;[76]
  7229.     jmp    vtclr5        ;[76]
  7230. vtc2lc    ldy    #0        ;[76] need a byte to keep track
  7231.     sty    kwrk01        ;[76]
  7232. vtclc2    ldy    kwrk01        ;[76]
  7233.     lda    vtcid,y        ;[76]
  7234.     beq    vtc2lm        ;[76] end of string
  7235.     jsr    telppc        ;[76] send it down the line
  7236.     inc    kwrk01        ;[76] next
  7237.     jmp    vtclc2        ;[76]
  7238. vtc2lm    jmp    vtccom        ;[76] thats all
  7239. vtlc                ;[76] - RESET
  7240. vtlc2    lda    #0        ;[76] reset window
  7241.     sta    wndtop        ;[76]
  7242.     sta    wrapar        ;[76] wrap arround start off
  7243.     lda    #24        ;[76] end+1 on the bottom
  7244.     sta    wndbtm        ;[76]
  7245.     jsr    home        ;[76] start at top
  7246.     jmp    vtccom        ;[76]
  7247. vtc2r    lda    vtcpar        ;[76] 1st param - TELL WHERE 
  7248.     cmp    #5        ;[76]
  7249.     bne    vtc2r9        ;[76]
  7250.     lda    #0        ;[76]
  7251.     jsr    vtcpos        ;[76]
  7252.     jmp    vtc2r7        ;[76]
  7253. vtc2r9    cmp    #6        ;[76]
  7254.     beq    vtc2r1        ;[76]
  7255.     jmp    vtcspl        ;[76] its an unknown
  7256. vtc2r1    lda    hcv        ;[76]
  7257.     jsr    vtcpos        ;[76]
  7258.     lda    #';        ;[76]
  7259.     jsr    telppc        ;[76]
  7260.     lda    hch        ;[76]
  7261.     jsr    vtcpud        ;[76] put out number
  7262. vtc2r7    lda    #'R        ;[76]
  7263.     jsr    telppc        ;[76]
  7264.     rts            ;[76]
  7265. vtcpud    cmp    #10        ;[76]
  7266.     bcc    vtc2r3        ;[76]
  7267.     pha            ;[76] save count
  7268.     cmp    #20        ;[76]
  7269.     bcs    vtc2r2        ;[76]
  7270.     lda    #'1        ;[76]
  7271.     jsr    telppc    ;[76]
  7272.     pla            ;[76] get original bin number
  7273.     clc            ;[76]
  7274.     sbc    #10        ;[76]
  7275.     jmp    vtc2r3        ;[76]
  7276. vtc2r2    lda    #'2        ;[76]
  7277.     jsr    telppc        ;[76]
  7278.     pla            ;[76] get bin number again
  7279.     clc            ;[76]
  7280.     sbc    #20        ;[76]
  7281. vtc2r3    clc            ;[76]
  7282.     adc    #'0        ;[76]
  7283.     jsr    telppc        ;[76]
  7284.     rts            ;[76]
  7285. vtcpos    pha            ;[76]
  7286.     lda    #esc        ;[76] tell where we are
  7287.     jsr    telppc        ;[76]
  7288.     lda    #'[        ;[76]
  7289.     jsr    telppc        ;[76]
  7290.     pla            ;[76]
  7291.     jsr    vtcpud        ;[76] put out the number
  7292.     rts            ;[76]
  7293. svnisc    ldy    nisc        ;[76] # saved chs
  7294.     sta    chssvd,y    ;[76] save this one
  7295.     inc    nisc        ;[76]
  7296.     rts            ;[76]
  7297. vt100    jsr    logput        ;[76]
  7298.     ldx    vtcesc        ;[76]have we seen an esc
  7299.     bne    vtc2        ;[76] yes
  7300.     cmp    #esc        ;[76] is this an esc?
  7301.     beq    vtc1        ;[76] yes
  7302.     ldx    prnfg        ;[87] are we printing?
  7303.     beq    .+5        ;[87] no
  7304.     jmp    tl0pr4+3    ;[87] yes give non esc seq direct to pr
  7305.     bge    vt1002        ;[85] speed things up a bit
  7306.     cmp    #tab        ;[76] how about a tab
  7307.     beq    vtctab        ;[76] yes
  7308. ;[78]vt1002    cmp    #so        ;[76]
  7309.     cmp    #so        ;[78]
  7310.     beq    vt100a        ;[76] turn on g1 special
  7311.     cmp    #si        ;[76]
  7312. ;[78]    beq    vt100c        ;[76]turn off g1 special
  7313.     beq    vt100c        ;[76] turn on g0 special
  7314. ;[78]    ldx    vtcscs        ;[76] have we got special ch set
  7315. vt1002    ldx    vtcso        ;[78] have we got special ch set
  7316. ;[78]    bne    vt1002        ;[76] yes
  7317.     bne    vt1003        ;[78] yes
  7318. vt1004    jmp    vprchr        ;[76] just print it & let cout rts
  7319. ;[78]vt1003    ldx    vtcso        ;[76]
  7320. ;[78]    beq    vt1004        ;[76] is g1 special on, no
  7321. vt1003                ;[78]
  7322.     cmp    #'_        ;[76]
  7323.     bcc    vt1004        ;[76] is it in the range?,no
  7324.     sec            ;[76]
  7325.     sbc    #'_        ;[76] make it a short table
  7326.     tax            ;[76] set the index into special chs
  7327.     lda    vtcg1,x        ;[76] get new ch
  7328. ;[85]    jmp    vprchd        ;[76] now print new ch-we know its printable
  7329.     jmp    vprch7        ;[85] now print new ch-we know its printable
  7330. ;[78]vt100a    inc    vtcso        ;[76] make it non 0
  7331. vt100a    lda    #2        ;[78] bit 1 for g1 (turned on by so)
  7332. vt100b    and    vtcscs        ;[78] is the graphics bit on?
  7333.     sta    vtcso        ;[78] non 0 if it is
  7334.     rts            ;[76]
  7335. ;[78]vt100c    lda    #0        ;[76] turn off vtcso
  7336. vt100c    lda    #1        ;[78] bit 0 for g0 (turned on by si)
  7337. ;[87]    jmp    vt100b        ;[78] common code
  7338.     bne    vt100b        ;[87] common code
  7339. ;[78]    sta    vtcso        ;[78][76]
  7340. ;[78]    rts            ;[76]
  7341. vtctab    ldy    nita        ;[76] we have a tab so move
  7342.     bne    .+5        ;[76] 
  7343.     jmp    vt524        ;[76] no tabs so use vt52s
  7344.     ldx    #0        ;[76] entry in tab table
  7345. ;[78]    lda    ch        ;[76] where we currently are
  7346.     lda    hch        ;[78] where we currently are
  7347. vtctb1    cmp    tabary,x    ;[76]
  7348. ;[84]    beq    vtctb3        ;[76]
  7349. ;[78]    bcs    vtctb2        ;[76]
  7350.     bcc    vtctb2        ;[76]
  7351.     inx            ;[76] next entry
  7352.     dey            ;[76] are we thru
  7353.     bne    vtctb1        ;[76] no
  7354.     beq    vtctb3        ;[78] what to do its not in array, sigh!
  7355. vtctb2    lda    tabary,x    ;[78]
  7356. ;[78]vtch01    sta    ch        ;[76] got on set loc
  7357.     sta    ch        ;[78] got on set loc
  7358.     jmp    pos80c        ;[76] position and let it rts
  7359. ;[78]vtctb2    dex            ;[76]
  7360. ;[78]    lda    tabary,x    ;[76]
  7361. ;[78]    jmp    vtch01        ;[76]
  7362. vtctb3    rts            ;[76]
  7363. vtc1    inc    vtcesc        ;[76] tattle
  7364.     rts            ;[76] next
  7365. vtc2    jsr    svnisc        ;[76] save current ch
  7366.     cpx    #1        ;[76] what type esc
  7367.     bne    vtclfp        ;[76] [ so look for parms
  7368.     ldx    #vtcoca-vtcoct    ;[76] logic only good for 256 byte table
  7369. vtcjp2    cmp    vtcoct-1,x    ;[76] now search the table
  7370.     bne    vtcjp1        ;[76] not this one
  7371.     txa            ;[76]
  7372.     asl    a        ;[76] double it
  7373.     tax            ;[76]
  7374.     ldy    vtcoca-2,x    ;[76] yup got one
  7375.     sty    vtcjp+1        ;[76] set up the jump
  7376.     ldy    vtcoca-1,x    ;[76]
  7377.     sty    vtcjp+2        ;[76]
  7378. vtcjp    jmp    $ffff        ;[76]
  7379. vtcjp1    dex            ;[76]
  7380.     bne    vtcjp2        ;[76] more? yes
  7381. vtcspl                ;[84] no more 
  7382. ;[84]vtcspl    lda    #esc        ;[76] no dont understand this one so print it
  7383. ;[84]    jsr    prchr        ;[76] make it look like ^$
  7384. ;[84]    ldy    nisc        ;[76] # of chs saved
  7385. ;[84]    ldx    #0        ;[76]
  7386. ;[84]vtcsp1    lda    chssvd,x    ;[76] get next ch saved
  7387. ;[84]    ora    #$80        ;[76] 
  7388. ;[84]    jsr    cout        ;[76] printit
  7389. ;[84]    inx            ;[76]
  7390. ;[84]    dey            ;[76]
  7391. ;[84]    bne    vtcsp1        ;[76] all the saved ones? no
  7392. vtccom    lda    #0        ;[76] commonexit clear all kinds of things
  7393.     ldy    #tabary-nisc    ;[76]
  7394. vtcc01    sta    nisc-1,y        ;[76]
  7395.     dey            ;[76]
  7396.     bne    vtcc01        ;[76] thru? no
  7397.     rts            ;[76] yes
  7398. vtclfp    cmp    #'9+1        ;[76] check for param a number
  7399.     bcs    vtclf3        ;[76] not a number
  7400.     cmp    #'0        ;[76]
  7401.     bcc    vtclf3        ;[76] not a number
  7402.     ldx    vtcpnm        ;[76] get current param
  7403.     sec            ;[76]
  7404.     sbc    #'0        ;[76] make it binary
  7405.     clc            ;[76]
  7406.     ldy    #10        ;[76] mult previous by 10
  7407. vtclf1    adc    vtcpar,x    ;[76]
  7408.     dey            ;[76] done? 
  7409.     bne    vtclf1        ;[76] no
  7410.     sta    vtcpar,x    ;[76] set current param
  7411.     rts            ;[76] thats all
  7412. vtclf3    ldx    #vtctca-vtctct    ;[76] look thru the param posibilities
  7413. vtclf4    cmp    vtctct-1,x    ;[76]
  7414.     bne    vtclf6        ;[76] not in this one
  7415.     txa            ;
  7416.     asl    a        ; double it
  7417.     tax            ;
  7418.     ldy    vtctca-2,x    ;[76] got one
  7419.     sty    vtclf5+1    ;[76] set up jump
  7420.     ldy    vtctca-1,x    ;[76]
  7421.     sty    vtclf5+2    ;[76]
  7422. vtclf5    jmp    $ffff        ;[76]
  7423. vtclf6    dex            ;[76]
  7424.     bne    vtclf4        ;[76] thru? no
  7425.     jmp    vtcspl        ;[76] cant find a match so give up
  7426.  
  7427. .SBTTL    Flashing cursor support routines.
  7428. ;[31]
  7429. ;[31] Take the byte on the screen at (basl),ch, stash it and its location in
  7430. ;[31] obasl,obash, oldch, and curchar, convert the character to flashing, and
  7431. ;[31] stuff it back to the screen. This will display a flashing character at
  7432. ;[31] the next location for writing.
  7433. ;[31] No registers or flags are altered.
  7434.  
  7435. curon:                ;[58]
  7436.     pha          ;[31] Save A
  7437.     lda    dsptyp        ;[58] 80 col display ?
  7438.     bmi    curon1        ;[58] yes ignore all this
  7439.     php          ;[31] Save flags.
  7440.     tya          ;[31] and Y
  7441.     pha          ;[31]
  7442.     ldy   ch          ;[31] Make a safe copy of the cursor char
  7443.     sty   oldch          ;[31] location
  7444.     lda   basl          ;[31]
  7445.     sta   obasl          ;[31]
  7446.     lda   bash          ;[31]
  7447.     sta   obash          ;[31]
  7448.     lda   (basl),y      ;[31]
  7449.     sta   curchr          ;[31] and value
  7450.     and   #$7f          ;[31] convert it to flashing.
  7451.     ora   #$40          ;[31]
  7452.     sta   (basl),y      ;[31] store flashing char to screen
  7453.     pla          ;[31] restore regs.
  7454.     tay          ;[31]
  7455.     plp          ;[31]
  7456. curon1    pla          ;[31]
  7457.     rts          ;[31]
  7458.  
  7459. ;[31] Turn the cursor off
  7460. ;[31] Check to see if the location where we last turned on the cursor is still
  7461. ;[31] flashing. If so, restore it to its old (non-flashing) value.
  7462. ;[31] All registers and flags preserved.
  7463.  
  7464. curoff            ;[58] 
  7465.     pha          ;[31] Preserve the regs
  7466.     lda    dsptyp    ;[58] 80 col display ?
  7467.     bmi    curof2    ;[58] yes skip all this
  7468.     php          ;[31]ha          ;[31] Preserve the regs
  7469.     tya          ;[31]
  7470.     pha          ;[31]
  7471.     ldy   oldch          ;[31] Get the current screen char at
  7472.     lda   (obasl),y      ;[31] old cursor location.
  7473.           bmi     curof1          ;[31] Too high to be flashing ; Quit
  7474.     cmp   #$40          ;[31]
  7475.     bcc   curof1          ;[31] Too low to be flashing ; Quit
  7476.     lda   curchr          ;[31] It is flashing ; restore the old
  7477.     sta   (obasl),y      ;[31] character
  7478. curof1: pla          ;[31] Restore the registers.
  7479.     tay          ;[31]
  7480.     plp          ;[31]
  7481. curof2    pla          ;[31]
  7482.     rts          ;[31]
  7483.  
  7484. scrfrm    jsr    home        ;[59]first clear the screen
  7485. ;[79]    lda    #rplocv        ;[59]
  7486. ;[79]    sta    cv        ;[59]
  7487. ;[79]    lda    #0        ;[59]
  7488. ;[79]    sta    errcnt        ;[59] start with 0 errors
  7489. ;[79]    sta    errcnt+1    ;[59]
  7490. ;[79]    sta    ch        ;[59]
  7491. ;[79]    jsr    vtab        ;[59] position recieve line
  7492. ;[79]    ldx    #rcin01\    ;[59]
  7493. ;[79]    ldy    #rcin01^    ;[59]
  7494. ;[79]    jsr    prstr        ;[59]print receive 
  7495.     lda    #splocv        ;[59]
  7496.     sta    cv        ;[59]
  7497.     lda    #0        ;[59]
  7498.     sta    ch        ;[59]
  7499.     jsr    vtab        ;[59] position send line
  7500.     ldx    #snin01\    ;[59]
  7501.     ldy    #snin01^    ;[59]
  7502.     jsr    prstr        ;[59]print sending
  7503.     lda    #erlocv        ;[59]
  7504.     sta    cv        ;[59]
  7505.     lda    #rploch-7    ;[59] 7 chs in fixed part
  7506.     sta    ch        ;[59]
  7507.     jsr    vtab        ;[59] position error line
  7508.     ldx    #erin01\    ;[59]
  7509.     ldy    #erin01^    ;[59]
  7510.     jsr    prstr        ;[59]print error count
  7511.     lda    #rplocv        ;[79]
  7512.     sta    cv        ;[79]
  7513.     lda    #0        ;[79]
  7514.     sta    errcnt        ;[79] start with 0 errors
  7515.     sta    errcnt+1    ;[79]
  7516.     sta    ch        ;[79]
  7517.     jsr    vtab        ;[79] position recieve line
  7518.     ldx    #rcin01\    ;[79]
  7519.     ldy    #rcin01^    ;[79]
  7520.     jsr    prstrl        ;[79]print receive & move to next line
  7521.     lda    #1        ;[66]
  7522.     sta    fnflag        ;[66] tell open to print file name
  7523.     rts            ;[59] thats all
  7524.  
  7525. .SBTTL    Exit  routine
  7526.  
  7527. ;
  7528. ;     This routine exits properly from kermit-65 and reenters
  7529. ;     Dos.
  7530. ;
  7531. ;         Input:     NONE
  7532. ;
  7533. ;         Output:     NONE
  7534. ;
  7535. ;         Registers destroyed:     A,X
  7536. ;
  7537.  
  7538. ;quit    lda    #0        ;[87] this is quit dont reset serial port
  7539. ;    beq    exit0        ;[87]
  7540. exit:
  7541. ;    lda    #1        ;[87] tatle abt this permanent exit
  7542. ;exit0    sta    exqufl        ;[87]    
  7543. ;[78]    lda   #cmcfm          ;[14] Try to get a confirm
  7544. ;[78]    jsr   comnd          ;[14] Do it
  7545. ;[78]          jmp     kermt3          ;[14] Give '?not confirmed' message
  7546.     jsr    prcfm        ;[78] parse and confirm
  7547. exit1:              ;[14]
  7548.     .ifeq <ftcom-ftappl>
  7549.     jsr    kerin7        ;[78] just in case were reading kermit.ini
  7550. ;[84]    lda    dosflg        ;[80] is this prodos?
  7551. ;[84]    bne    exit4        ;[80] yes
  7552. ;[84]    lda   herrpt          ; Reset the DOS and BASIC error vectors
  7553. ;[84]    sta   errptr          ;         ...
  7554. ;[84]    lda   herrpt+1      ;         ...
  7555. ;[84]    sta   errptr+1      ;         ...
  7556. ;[84]    lda   hbasws          ;         ...
  7557. ;[84]    sta   basws          ;         ...
  7558. ;[84]    lda   hbasws+1      ;         ...
  7559. ;[84]    sta   basws+1          ;         ...
  7560. ;[84]exit4                ;[80]
  7561.     lda    hsoftv        ;[75] restore the soft vector also
  7562.     sta    softvc        ;[75]
  7563.     lda    hsoftv+1    ;[75]
  7564.     sta    softvc+1    ;[75]
  7565.     jsr    warmst        ;[75] and make it right
  7566. ;    lda    exqufl        ;[87] quit?
  7567. ;    beq    .+5        ;[87] yes
  7568.     jsr    tl0exi        ;[80] restore interupt vector also
  7569.     jsr    setio1        ;[58] reset keyboard
  7570.     lda    #0        ;[58] assume pr#0
  7571. ;[80]    sta    herrpt        ;[75] and tell we restored the vectors
  7572. ;[80]    sta    herrpt+1    ;[75]
  7573.     sta    hsoftv+1    ;[80] high byte should be enough
  7574. ;[87]    sta    $800    ;[86] According to Chip Welch we need this,thanks
  7575.     ldx    dsptyp        ;[58] are we 80 col ?
  7576.     bpl    exit3        ;[58] no
  7577.     lda    dsp2        ;[58] yes get pr#n
  7578. exit3    jsr    setio2+2    ;[58] do it
  7579.     lda    dosflg        ;[84] prodos?
  7580.     beq    exit2        ;[84] no
  7581.     jsr    prodos        ;[84] quit
  7582.     .byte    pdquit        ;[84]
  7583.     .word    prdqut        ;[84]
  7584.     jsr    perror        ;[86] if we come back its an error
  7585.     .endc
  7586. exit2:    jmp   dos      ; We got it, now restart DOS
  7587.  
  7588. .SBTTL    Help  routine
  7589.  
  7590. ;
  7591. ;     This routine prints help from the current help text
  7592. ;     area.
  7593. ;
  7594. ;         Input:     Cmhptr     - Pointer to the desired text to be printed
  7595. ;
  7596. ;         Output:     ASCIZ string at Cmhptr is printed on screen
  7597. ;
  7598. ;         Registers destroyed:     A,X,Y
  7599. ;
  7600.  
  7601. ;[78]help:    lda   #cmcfm          ; Try to get a confirm
  7602. ;[78]    jsr   comnd          ; Go get it
  7603. ;[78]          jmp     kermt3          ; Didn't find one? Give 'not confirmed' message
  7604. ;[85]help    jsr    prcfm        ;[78] parse and confirm
  7605. ;[85]help2:    ldx   cmhptr          ; L.O. byte of current help text address
  7606. ;[85]    ldy   cmhptr+1      ; H.O. byte of address
  7607. ;[83]    jsr   prstr          ; Print it
  7608. ;[83]    jmp   kermit          ; Return to main routine
  7609. ;[85]    jmp    kermtx        ;[83] thats all
  7610. help:    lda    #on        ;[85] Set use file-header switch on in case we
  7611.     sta   usehdr          ;[85]     don't parse a filename
  7612.     jsr    kerin7        ;[85] just in case were reading kermit.ini
  7613.     lda    #hlpfne-hlpfn    ;[85] size
  7614.     sta    pdlen        ;[85] of name
  7615.     lda    #hlpfn\        ;[85] and where it is
  7616.     sta    kerbf1        ;[85]
  7617.     lda    #hlpfn^        ;[85]
  7618.     sta    kerbf1+1    ;[85]
  7619.     lda   #kerehr\      ;[85] Point to extra help commands
  7620.     sta   cmehpt          ;[85]         ...
  7621.     lda   #kerehr^      ;[85]         ...
  7622.     sta   cmehpt+1      ;[85]         ...
  7623.     ldx   #mxfnl          ;[85] Longest length a filename may be
  7624.     lda    dosflg        ;[85] prodos?
  7625.     beq    .+4        ;[85] no
  7626.     ldx    #mxppth        ;[85] yes allow for path name
  7627.     ldy   #cmfehf          ;[85] Tell Comnd about extra help
  7628.     lda   #cmifi          ;[85] Load opcode for parsing input files
  7629.     jsr   comnd          ;[85] Call comnd routine
  7630.     jmp    help1          ;[85] Continue, don't turn file-header switch off
  7631.     sta    pdlen        ;[85] length of name parsed
  7632.     stx    kerbf1        ;[85] and where it is
  7633.     sty    kerbf1+1    ;[85]
  7634. help1    jsr    getfil        ;[85] set up fcb1
  7635. helpb    jsr    opentf        ;[85]
  7636. helpa    jsr    home        ;[85] top & clear screen
  7637.     ldx    #morem\        ;[85] instructions
  7638.     ldy    #morem^        ;[85]
  7639.     jsr    prstrl        ;[85] 
  7640.     lda    #0        ;[85]
  7641.     sta    match        ;[85] line count
  7642.     sta    ch        ;[85] position to line 2
  7643.     lda    #1        ;[85]
  7644.     sta    cv        ;[85]
  7645.     jsr    vtab        ;[85]
  7646.     jsr    clreop        ;[85] clear page
  7647. help2    jsr    fgetc        ;[85] get ch from file
  7648.     jmp    help3        ;[85] eof
  7649.     ora    #$80        ;[85] make it printable
  7650.     cmp    #hlf        ;[85] end of line?
  7651.     beq    help21        ;[85]
  7652.     cmp    #hffd        ;[85] top of form?
  7653.     beq    help22        ;[85]
  7654.     cmp    #hcr        ;[85] end of line?
  7655.     bne    help23        ;[85] no just printit
  7656. help21    inc    match        ;[85] yes are we at eop
  7657.     ldx    #22        ;[85]
  7658.     cpx    match        ;[85]
  7659.     bne    help23        ;[85] no
  7660. help22    lda    kbd        ;[85] get users wish
  7661.     bpl    help22        ;[85]
  7662.     bit    kbdstr        ;[85] clear strobe
  7663.     ora    #$20        ;[85] make it lower case
  7664.     cmp    #'q+$80        ;[85] want to quit?
  7665.     beq    help3        ;[85]
  7666.     cmp    #'t+$80        ;[85] want to start over?
  7667.     bne    helpa        ;[85] no, next page
  7668.     jsr    clostf        ;[85]
  7669.     jmp    helpb        ;[85]
  7670. help23    jsr    cout        ;[85] print it
  7671.     jmp    help2        ;[85] till we read it all
  7672. help3    jsr    clostf        ;[85] restore
  7673.     jmp    kermit        ;[85] adios
  7674.  
  7675. .SBTTL    Bye   routine
  7676.  
  7677. ;
  7678. ;     This routine terminates the remote server, logs out and terminates
  7679. ;     the local Kermit.
  7680. ;
  7681.  
  7682. bye:    jsr   prcfm          ;[14] Go parse and print the confirm
  7683. ;[67]    jsr    scrfrm        ;[59] make the screen look nice
  7684.     lda    #'L        ;[67] this is logout
  7685.     sta    logo4+1        ;[67]
  7686.     jsr   logo          ;[14] Tell other Kermit to log out
  7687.           jmp     kermit          ;[14] Don't exit if there was an error
  7688.     lda   #0          ;[54] command to hang up phone
  7689.     jsr   tl0cmd          ;[54] and let card handle it
  7690.     jmp   exit1          ;[14] Leave
  7691.  
  7692. ;
  7693. ;     Logo - This routine does the actual work to send the logout
  7694. ;     packet to the remote server
  7695. ;
  7696.  
  7697. logo:    lda   #$00          ;[14] Zero the number of tries
  7698.     sta   numtry          ;[14]         ...
  7699.     sta   tpak          ;[16]     and the total packet number
  7700.     sta   tpak+1          ;[16]         ...
  7701. ;[81]    sta    kerins        ;[75] make sure we purge com buffers
  7702.     sta    exfg        ;[75] tell it to use classic packets
  7703. ;[83]    lda   #pdbuf\          ;[72] Point kerbf1 at the packet data buffer
  7704. ;[83]    sta   kerbf1          ;[72]         ...
  7705. ;[83]    lda   #pdbuf^          ;[72]         ...
  7706. ;[83]    sta   kerbf1+1      ;[72]         ...
  7707.     jsr    sukrbf        ;[83] setup kerbf1
  7708. ;[81]    jsr   tlinit      ;[72] initialize the serial port
  7709. ;[81]    bne    logoa        ;[72] unable to use the com port
  7710. ;[81]    jsr    u2icc        ;[72] tattle
  7711. ;[81]    jmp    kermit        ;[72]
  7712. ;[81]logoa                ;[72]
  7713.     jsr    comint        ;[81] common com init
  7714.     jsr    scrfrm        ;[59] make the screen look nice
  7715. logo1:    lda   numtry          ;[14] Fetch the number of tries
  7716.     cmp   maxtry          ;[14] Have we exceeded Maxtry?
  7717.     bmi   logo3          ;[14] Not yet, go send the packet
  7718. logo2:    ldx   #ermesc\      ;[14] Yes, give an error message
  7719.     ldy   #ermesc^      ;[14]         ...
  7720. ;[79]    jsr   prstr          ;[14]         ...
  7721. ;[79]    jsr   prcrlf          ;[14]         ...
  7722.     jmp    prstrl        ;[79] & let it rts
  7723. ;[79]    rts          ;[14]     and return
  7724. logo3:    inc   numtry          ;[14] Increment the number of tries for packet
  7725.     lda   #$00          ;[14] Make it packet number 0
  7726.     sta   pnum          ;[14]         ...
  7727.     lda   #$01          ;[14] Data length is only 1
  7728.     sta   pdlen          ;[14]         ...
  7729. logo4    lda   #'L          ;[67][14] The 'Logout' command
  7730.     sta   pdbuf          ;[14] Put that in first character of buffer
  7731.     lda   #'G          ;[14] Generic command packet type
  7732.     sta   ptype          ;[14]         ...
  7733.     jsr   spak          ;[14] Send the packet
  7734.     jsr   rpak          ;[14] Try to fetch an ACK
  7735. ;[53]     cmp     #true          ;[14] Did we receive successfully?
  7736. ;[53]     bne     logo1          ;[14] No, try to send the packet again
  7737. ;[67]    beq   logo1      ;[53]     since false is 0
  7738.     lda   ptype          ;[14] Get the type
  7739.     cmp    #'Y        ;[67] is this a ack?
  7740.     beq    logo7        ;[67] yes
  7741.     ldy    #0        ;[67] ready the error message
  7742. logo5    lda    erms18,y    ;[67]
  7743.     beq    logo6        ;[67] end of message? yes
  7744.     and    #$7f        ;[67] make it ascii
  7745.     sta    pdbuf,y        ;[67] this message is going to remote
  7746.     iny            ;[67]
  7747.     jmp    logo5        ;[67]
  7748. logo6    sty    pdlen        ;[67]
  7749.     lda    #'E        ;[67] this is an error packet
  7750.     sta    ptype        ;[67]
  7751.     jsr    spak        ;[67] send the packet
  7752.     jsr    rpak        ;[67] and get a packet
  7753.     beq    logo1        ;[67] not very sophisticated
  7754.     lda    ptype        ;[67]
  7755.     cmp   #'Y          ;[14] An ACK?
  7756.     bne   logoce          ;[14] No, go check for error
  7757. logo7                ;[67]
  7758.     jmp   rskp          ;[14] Yes, skip return
  7759. logoce:     ;[67]cmp   #'E          ;[14] Error packet?
  7760.     ;[67]bne   logo1          ;[14] Nope, resend packet
  7761.     jsr   prcerp          ;[38][14] Go display the error
  7762.     beq    logo1        ;[67] not an error pkt try again
  7763.     rts          ;[14]     and return
  7764.  
  7765. sukrbf    lda   #pdbuf\          ;[83] Point kerbf1 at the packet data buffer
  7766.     sta   kerbf1          ;[83]         ...
  7767.     lda   #pdbuf^          ;[83]         ...
  7768.     sta   kerbf1+1          ;[83]         ...
  7769.     rts            ;[83]
  7770.  
  7771. .SBTTL    Finish routine
  7772.  
  7773. ;
  7774. ;     This routine terminates the remote server but does not log
  7775. ;     it out. It also keeps the local Kermit running.
  7776. ;
  7777.  
  7778. finish: jsr   prcfm          ;[14] Go parse and print the confirm
  7779.     lda    #'F        ;[67] this is finish command
  7780.     sta    logo4+1        ;[67]
  7781.     jsr    logo        ;[67] and tell remote
  7782.     jmp    finshe        ;[67] error return
  7783. ;[67]    jsr    scrfrm        ;[59] make the screen look nice
  7784. ;[67]    lda   #$00          ;[14] Zero the number of tries
  7785. ;[67]    sta   numtry          ;[14]         ...
  7786. ;[67]    sta   tpak          ;[16]     and the total packet number
  7787. ;[67]    sta   tpak+1          ;[16]         ...
  7788. ;[67]finsh1: lda   numtry          ;[14] Fetch the number of tries
  7789. ;[67]    cmp   maxtry          ;[14] Have we exceeded Maxtry?
  7790. ;[67]    bmi   finsh3          ;[14] Not yet, go send the packet
  7791. ;[67]finsh2: ldx   #ermesd\      ;[14] Yes, give an error message
  7792. ;[67]    ldy   #ermesd^      ;[14]         ...
  7793. ;[67]    jsr   prstr          ;[14]         ...
  7794. ;[67]    jsr   prcrlf          ;[14]         ...
  7795. ;[67];    jmp   kermit          ;[14]     and go back for more commands
  7796. ;[67]    jmp    finshe        ;[61] handle 2e 80 col screen
  7797. ;[67]finsh3: inc   numtry          ;[14] Increment the number of tries for packet
  7798. ;[67]    lda   #$00          ;[14] Make it packet number 0
  7799. ;[67]    sta   pnum          ;[14]         ...
  7800. ;[67]    lda   #$01          ;[14] Data length is only 1
  7801. ;[67]    sta   pdlen          ;[14]         ...
  7802. ;[67]    lda   #'F          ;[14] The 'Finish' command
  7803. ;[67]    sta   pdbuf          ;[14] Put that in first character of buffer
  7804. ;[67]    lda   #'G          ;[14] Generic command packet type
  7805. ;[67]    sta   ptype          ;[14]         ...
  7806. ;[67]    jsr   spak          ;[14] Send the packet
  7807. ;[67]    jsr   rpak          ;[14] Try to fetch an ACK
  7808. ;[67];[53]     cmp     #true          ;[14] Did we receive successfully?
  7809. ;[67];[53]     bne     finsh1          ;[14] No, try to send the packet again
  7810. ;[67]    beq   finsh1      ;[53]     since false is 0
  7811. ;[67]    lda   ptype          ;[14] Get the type
  7812. ;[67]    cmp   #'Y          ;[14] An ACK?
  7813. ;[67]    bne   fince          ;[14] No, go check for error
  7814. ;[67];    jmp   kermit          ;[14] Yes, go back for more commands
  7815. ;[67]    jmp    finshe        ;[61] handle 2e 80 col screen
  7816. ;[67]fince:    cmp   #'E          ;[14] Error packet?
  7817. ;[67]    bne   finsh1          ;[14] Nope, resend packet
  7818. ;[67]    jsr   prcerp          ; ;[38][14] Go display the error
  7819. ;[69]finshe    jsr    test2e        ;[61] what is going on????
  7820. finshe    jsr    dfsv        ;[69] let operator look at screen
  7821.     jsr    test2e        ;[61] what is going on????
  7822.     jmp   kermit          ;[14] Go back for more 
  7823.  
  7824. .SBTTL    Take   routine
  7825.  
  7826. ;
  7827. ;     This routine accepts an unquoted string terminated by 
  7828. ;     <cr> and tries to use the file
  7829. ;     represented by that string for kermit commands.
  7830. ;
  7831.  
  7832. take:    jsr    kerin7        ;[83] just in case were reading kermit.ini
  7833.     lda   #$80          ;[83] Reset all break characters
  7834.     jsr   rstbrk          ;[83]         ...
  7835.     lda   #cr          ;[83]         ...
  7836.     jsr   setbrk          ;[83]         ...
  7837.     ldy   #$00          ;[83]         ...
  7838.     sty    kerrki        ;[83] get commands from file
  7839.     lda   #cmtxt          ;[83] Parse for text
  7840.     jsr   comnd          ;[83] Do it
  7841.     jmp     kermta          ;[83] Found null string
  7842.     sta   kwrk01          ;[83] Store packet size for Kercpy
  7843.     sta    nfcb1        ;[83] just in case of prodos
  7844.     stx   kerfrm          ;[83] Point to the atom buffer from Comnd
  7845.     sty   kerfrm+1      ;[83]     as the source address
  7846.     lda   #fcb1\          ;[83] Set up the address of the target
  7847.     sta   kerto          ;[83]         ...
  7848.     lda   #fcb1^          ;[83]         ...
  7849.     sta   kerto+1          ;[83]         ...
  7850.     jsr   clrfcb          ;[83] Clear the fcb first
  7851.     jsr   kercpy          ;[83] Go move the string
  7852.     jmp    stflo7        ;[83] common parse & print confirm
  7853.  
  7854. preptx    lda   #$80          ;[86] Reset all break characters
  7855.     jsr   rstbrk          ;[86]         
  7856.     lda   #cr          ;[86]    Now set some break chs
  7857.     jsr   setbrk          ;[86]         ...
  7858.     lda   #lf          ;[86]         ...
  7859.     jsr   setbrk          ;[86]         ...
  7860.     lda   #ffd          ;[86]         ...
  7861.     jsr   setbrk          ;[86]         ...
  7862.     lda   #esc          ;[86]         ...
  7863.     jsr   setbrk          ;[86]         ...
  7864.     lda   #',          ;[86]         ...
  7865.     jsr   setbrk          ;[86]         ...
  7866.     ldy   #$00          ;[86]    nothing special
  7867.     lda   #cmtxt          ;[86] Parse for text
  7868.     rts            ;[86]
  7869.  
  7870. .SBTTL    Get   routine
  7871.  
  7872. ;
  7873. ;     This routine accepts an unquoted string terminated by 
  7874. ;     <cr>,<lf>,<ff>, or <esc> and tries to fetch the file
  7875. ;     represented by that string from a remote server Kermit.
  7876. ;
  7877.  
  7878. getfrs: lda   #yes          ;[42] Make KERMIT use file headers
  7879.     sta   usehdr          ;[42]     for file names
  7880.     jsr    kerin7        ;[78] just in case were reading kermit.ini
  7881. ;[59]    lda   #mxfnl+1      ;[14] The buffer size is one more than max
  7882. ;[59]    sta   kwrk01          ;[14]     file name length
  7883. ;[59]    lda   #fcb1\          ;[14] Point to the buffer
  7884. ;[59]    sta   kerto          ;[14]         ...
  7885. ;[59]    lda   #fcb1^          ;[14]         ...
  7886. ;[59]    sta   kerto+1          ;[14]         ...
  7887. ;[59]    jsr   kerflm          ;[14] Clear the buffer
  7888. ;[86]    lda   #$80          ;[14] Reset all break characters
  7889. ;[86]    jsr   rstbrk          ;[14]         ...
  7890. ;[86]    lda   #cr          ;[14]         ...
  7891. ;[86]    jsr   setbrk          ;[14]         ...
  7892. ;[86]    lda   #lf          ;[14]         ...
  7893. ;[86]    jsr   setbrk          ;[14]         ...
  7894. ;[86]    lda   #ffd          ;[14]         ...
  7895. ;[86]    jsr   setbrk          ;[14]         ...
  7896. ;[86]    lda   #esc          ;[14]         ...
  7897. ;[86]    jsr   setbrk          ;[14]         ...
  7898. ;[86]    ldy   #$00          ;[14]         ...
  7899. ;[81]    sty    kerins        ;[75] make sure we empty buffers 
  7900. ;[86]    lda   #cmtxt          ;[14] Parse for text
  7901.     jsr    preptx        ;[86] get string up to comma ...
  7902.     jsr   comnd          ;[14] Do it
  7903.           jmp     kermta          ;[14] Found null string
  7904.     cmp   spsiz          ;[14] Larger than the set packet size?
  7905. ;[75]    bmi   getf1          ;[14] No, continue
  7906.     bcc   getf1          ;;[75][14] No, continue
  7907.     lda   spsiz          ;[14] Yes, it will have to be truncated
  7908. getf1:    sta   kwrk01          ;[14] Store packet size for Kercpy
  7909.     sta   pdlen          ;[14]     and Spak
  7910.     sta    nfcb1        ;[59] just in case of prodos
  7911.     sta    getfln        ;[87] size of get file name
  7912. ;[87]    lda   #pdbuf\          ;[14] Point to the data buffer as destination
  7913.     lda   #dosbuf\          ;[87] place to save filename
  7914.     sta   kerto          ;[14]         ...
  7915. ;[62]    sta   kerbf1          ;[37] Store L.O.B. here for Spak routine
  7916. ;[87]    lda   #pdbuf^          ;[14]         ...
  7917.     lda   #dosbuf^          ;[87] place to save filename
  7918.     sta   kerto+1          ;[14]         ...
  7919. ;[62]    sta   kerbf1+1      ;[37] Store H.O.B. here for Spak routine
  7920.     stx   kerfrm          ;[14] Point to the atom buffer from Comnd
  7921.     sty   kerfrm+1      ;[14]     as the source address
  7922. ;[87]    stx    kerbf1        ;[59] prep getfil
  7923. ;[87]    sty    kerbf1+1    ;[59]
  7924. ;[59]    txa          ;[14] Save the 'from buffer' pointers for later
  7925. ;[59]    pha          ;[14]         ...
  7926. ;[59]    tya          ;[14]         ...
  7927. ;[59]    pha          ;[14]         ...
  7928.     jsr   kercpy          ;[14] Copy the string
  7929. ;[59]    pla          ;[14] Restore these for the next move
  7930. ;[59]    sta   kerfrm+1      ;[14]         ...
  7931. ;[59]    pla          ;[14]         ...
  7932. ;[59]    sta   kerfrm          ;[14]         ...
  7933.     lda   #fcb1\          ;[14] Set up the address of the target
  7934.     sta   kerto          ;[14]         ...
  7935.     lda   #fcb1^          ;[14]         ...
  7936.     sta   kerto+1          ;[14]         ...
  7937.     jsr   clrfcb          ;[14] Clear the fcb first
  7938.     jsr   kercpy          ;[14] Go move the string
  7939.     lda    #cmtxt        ;[86] see if we have to change name
  7940.     jsr    comnd        ;[86]
  7941.     jmp    getf3        ;[86] no, carry on there the same name
  7942.     sta    kwrk01        ;[86] len of new name
  7943.     sta    nfcb1        ;[86] len of new name
  7944.     stx    kerfrm        ;[86] where to get it from
  7945.     sty    kerfrm+1    ;[86]
  7946.     jsr    clrfcb        ;[86]
  7947.     jsr    kercpy        ;[86]
  7948.     lda    #no        ;[86] dont use header
  7949.     sta    usehdr        ;[86]
  7950. getf3                ;[86]    
  7951.     jsr   prcfm          ;[14] Go parse and print the confirm
  7952. ;[81]    jsr   tlinit      ;[47] initialize the serial port
  7953. ;[81]    bne    getf3        ;[62] unable to init com
  7954. ;[81]    jsr    u2icc        ;[62] tell someone
  7955. ;[81]    jmp    kermit        ;[62]
  7956. ;[81]getf3                ;[62]
  7957.     jsr    comint        ;[81] common com init
  7958. ;[87]    lda   #'R          ;[14] Packet type is 'Receive-init'
  7959. ;[87]    sta   ptype          ;[14]         ...
  7960. ;[87]    sta    getfg        ;[75] tell were from get
  7961. ;[87]    lda   #$00          ;[14] Packet number should be zero
  7962. ;[87]    sta   pnum          ;[14]         ...
  7963. ;[87]    sta    exfg        ;[75] start out with clasic packet
  7964. ;[66]    jsr    scrfrm        ;[59] ready the screen for file xfer
  7965. ;[87]    lda    prtcl        ;[83] is this xmodem
  7966. ;[87]    bne    .+5        ;[83] yes hate to do this
  7967. ;[87]    jsr   spak          ;[14] Packet length was set above, 
  7968.     lda    prtcl        ;[87] is this xmodem
  7969.     bne    getf7        ;[87] yes
  7970.     lda    #'I        ;[87] set up lots of things
  7971.     jsr    rswint        ;[87]
  7972. getl1    lda    state        ;[87]
  7973.     cmp    #'I        ;[87] do we have an init?
  7974.     bne    getl2        ;[87] no
  7975.     jsr    sinio        ;[87]
  7976.     jmp    getl1        ;[87]
  7977. getl2    cmp    #'F        ;[87] good init?
  7978.     beq    getl3        ;[87] yes
  7979.     jmp    stat07        ;[87] no error out
  7980. getl3    sta    getfg        ;[87] in case of retry
  7981.     jsr    rini2c        ;[87] send the file name packet
  7982. getf7                ;[87]
  7983.     jsr   rswt          ;[14]     so just call spak and try to receive
  7984.     pha            ;[67] save error return
  7985.     lda    #0        ;[75] turn off get file flag
  7986.     sta    getfg        ;[75]
  7987. ;[68]    jsr    home        ;[67]
  7988.     jsr   bell          ;[56] Sound bell at the user
  7989.     jsr    dfsv        ;[69] let operator look at screen
  7990.     jsr    test2e        ;[61] test for //e 80 col
  7991.     pla            ;[67] get posible error
  7992.     bne    getf2        ;[67] error?,no
  7993.     jmp    stat07        ;[67] yes tell user
  7994. getf2    jmp   kermit          ;[14] Go back for more commands
  7995.  
  7996. ;
  7997. ;     This routine setsup a log file for the remote session
  7998. ;
  7999. ;         Input:     Filename returned from comnd
  8000. ;
  8001. ;         Output:     If file spec is ok file is opened
  8002. ;
  8003. ;         Registers destroyed:     A,X,Y
  8004. ;
  8005.  
  8006. log:              ;[56]
  8007.     jsr    kerin7        ;[78] just in case were reading kermit.ini
  8008.     lda   #kerehr\      ;[56] Point to extra help commands
  8009.     sta   cmehpt          ;[56]         ...
  8010.     lda   #kerehr^      ;[56]         ...
  8011.     sta   cmehpt+1      ;[56]         ...
  8012.     ldx   #mxfnl          ;[56] Longest length a filename may be
  8013.     lda    dosflg        ;[59] is this prodos
  8014.     beq    .+4        ;[59] no
  8015.     ldx    #mxppth        ;[59] yes
  8016.     ldy   #cmfehf          ;[56] Tell Comnd about extra help
  8017.     lda   #cmifi          ;[56] Load opcode for parsing input files
  8018.     jsr   comnd          ;[56] Call comnd routine
  8019.           jmp     kermt6          ;[56] file spec required
  8020.     sta    pdlen        ;[57] length of name parsed
  8021.     stx    kerbf1        ;[57] and where it is
  8022.     sty    kerbf1+1    ;[57]
  8023.     lda    #on        ;[57] force getfil
  8024.     sta    usehdr        ;[57] to convert to neg ascii
  8025.     jsr    getfil        ;[57] set up fcb1
  8026. ;[78]    lda   #cmcfm          ;[56] Get token for confirm
  8027. ;[78]    jsr   comnd          ;[56]     and try to parse that
  8028. ;[78]          jmp     kermt3          ;[56] Failed - give the error
  8029.     jsr    prcfm        ;[78] parse and confirm
  8030.     lda   #fncwrt          ;[56] open for writing
  8031.     jsr   openf          ;[56] use other files defaults
  8032.     lda   #$80          ;[56] turn on flag
  8033.     sta   logfg          ;[56]
  8034. ;[76]    lda    flowfg        ;[57] do we have flow control
  8035.     lda    confg        ;[76] do we have flow control
  8036.     bmi    log0        ;[57] yes
  8037.     ldx    #erms1c\    ;[57] dont think it will work without
  8038.     ldy    #erms1c^    ;[57]
  8039. ;[79]    jsr    prstr        ;[57] tell user
  8040. ;[79]    jsr    prcrlf        ;[57]
  8041.     jsr    prstrl        ;[79]
  8042. log0:
  8043.     jsr    sutljp        ;[85] setup screen distributor
  8044.     jmp   kermit          ;[56] back for more commands
  8045.  
  8046. .SBTTL    Receve routine
  8047.  
  8048. ;
  8049. ;     This routine receives a file from the remote kermit and
  8050. ;     writes it to a disk file.
  8051. ;
  8052. ;         Input:     Filename returned from comnd, if any
  8053. ;
  8054. ;         Output:     If file transfer is good, file is output to disk
  8055. ;
  8056. ;         Registers destroyed:     A,X,Y
  8057. ;
  8058.  
  8059. recev0    lda    prtcl        ;[85] is this xmodem?
  8060.     beq    recev1        ;[85] no
  8061.     jmp    kermta        ;[85] yes a filename is required 
  8062. receve: lda   #on          ; Set use file-header switch on in case we
  8063.     sta   usehdr          ;     don't parse a filename
  8064.     jsr    kerin7        ;[78] just in case were reading kermit.ini
  8065.     lda   #kerehr\      ;[13] Point to extra help commands
  8066.     sta   cmehpt          ;[13]         ...
  8067.     lda   #kerehr^      ;[13]         ...
  8068.     sta   cmehpt+1      ;[13]         ...
  8069.     ldx   #mxfnl          ;[59][13] Longest length a filename may be
  8070.     lda    dosflg        ;[59] prodos?
  8071.     beq    .+4        ;[59] no
  8072.     ldx    #mxppth        ;[59] yes allow for path name
  8073.     ldy   #cmfehf          ;[13] Tell Comnd about extra help
  8074.     lda   #cmifi          ; Load opcode for parsing input files
  8075.     jsr   comnd          ; Call comnd routine
  8076. ;[85]    jmp    recev1        ; Continue, don't turn file-header switch off
  8077.     jmp    recev0        ;[85] Continue, don't turn file-header switch off
  8078.     sta    pdlen        ;[57] length of name parsed
  8079.     stx    kerbf1        ;[57] and where it is
  8080.     sty    kerbf1+1    ;[57]
  8081.     jsr    getfil        ;[57] set up fcb1
  8082.     lda   #off          ; We parsed a filename so we don't need the
  8083.     sta   usehdr          ;     info from the file-header
  8084. ;[78]recev1: lda   #cmcfm          ; Get token for confirm
  8085. ;[78]    jsr   comnd          ;     and try to parse that
  8086. ;[78]          jmp     kermt3          ; Failed - give the error
  8087. recev1    jsr    prcfm        ;[78] parse & confirm
  8088. ;[81]    lda    #0        ;[75] 
  8089. ;[81]    sta    kerins        ;[75] make sure we purge com buffers
  8090. ;[81]    jsr   tlinit      ;[47] initialize the serial port
  8091. ;[81]    bne    recev3        ;[62] unable to use the com port
  8092. ;[81]    jsr    u2icc        ;[62] tattle
  8093. ;[81]    jmp    kermit        ;[62]
  8094. ;[81]recev3                ;[62]
  8095.     jsr    comint        ;[81] common com init
  8096.     jsr   rswt          ; Perform send-switch routine
  8097.     pha            ;[67] save error return
  8098. ;[68]    jsr    home        ;[67]
  8099.     jsr   bell          ;[56] Sound bell at the user
  8100.     jsr    dfsv        ;[69] let operator look at screen
  8101.     jsr    test2e        ;[61] test for //e 80 col
  8102.     pla            ;[67] get posible error
  8103.     bne    recev2        ;[67] error?,no
  8104.     jmp    stat07        ;[67] yes tell user
  8105. recev2    jmp   kermit          ; Go back to main routine
  8106.  
  8107. rswint    sta   state          ;[87] Set that up
  8108.     lda   #$00          ;[87] Zero the packet sequence number
  8109.     sta   n          ;[87]         ...
  8110.     sta   numtry          ;[87]     Number of tries
  8111.     sta   oldtry          ;[87]     Old number of tries
  8112.     sta   eofinp          ;[87]     End of input flag
  8113.     sta   errcod          ;[87]     Error indicator
  8114.     sta   rtot          ;[87]     Total received characters
  8115.     sta   rtot+1          ;[87]         ...
  8116.     sta   rtot+2          ;[87]         ...
  8117.     sta   stot          ;[87]     Total Sent characters
  8118.     sta   stot+1          ;[87]         ...
  8119.     sta   stot+2          ;[87]         ...
  8120.     sta   rchr          ;[87]     Received characters, current file
  8121.     sta   rchr+1          ;[87]         ...
  8122.     sta   rchr+2          ;[87]
  8123.     sta   schr          ;[87]     Sent characters, current file
  8124.     sta   schr+1          ;[87]         ...
  8125.     sta   schr+2          ;[87]
  8126.     sta   tpak          ;[87]     and the total packet number
  8127.     sta   tpak+1          ;[87]
  8128.     sta    exfg        ;[87] start out with classic packet
  8129.     sta    flowfg        ;[87] xmodem may need this
  8130.     jsr    sutljp        ;[87] set up screen distributor
  8131.     jsr    scrfrm        ;[87] format the screen for file xfer
  8132.     rts            ;[87] thats all folks
  8133.  
  8134. rswt:    lda   #'R          ; The state is receive-init
  8135.     jsr    rswint        ;[87] init lots of things
  8136. rswt1:    lda   state          ; Fetch the current system state
  8137.     cmp   #'D          ; Are we trying to receive data?
  8138.     bne   rswt2          ; If not, try the next one
  8139.     jsr   rdat          ; Go try for the data packet
  8140.     jmp   rswt1          ; Go back to the top of the loop
  8141. rswt2:    cmp   #'F          ; Do we need a file header packet?
  8142.     bne   rswt3          ; If not, continue checking
  8143.     jsr   rfil          ; Go get the file-header
  8144.     jmp   rswt1          ; Return to top of loop
  8145. rswt3:    cmp   #'R          ; Do we need the init?
  8146.     bne   rswt4          ; No, try next state
  8147.     jsr   rini          ; Yes, go get it
  8148.     jmp   rswt1          ; Go back to top
  8149. rswt4:    cmp   #'C          ; Have we completed the transfer?
  8150.     bne   rswt5          ; No, we are out of states, fail
  8151.     lda   #true          ; Load AC for true return
  8152.     rts          ; Return
  8153. rswt5:    lda   #false          ; Set up AC for false return
  8154.     rts          ; Return
  8155.  
  8156. ;[83]rini:    lda   #pdbuf\          ; Point kerbf1 at the packet data buffer
  8157. ;[83]    sta   kerbf1          ;         ...
  8158. ;[83]    lda   #pdbuf^          ;         ...
  8159. ;[83]    sta   kerbf1+1      ;         ...
  8160. rini    jsr    sukrbf        ;[83] setup kerbf1
  8161.     lda    prtcl        ;[83]
  8162.     beq    .+5        ;[83] its a long reach
  8163.     jmp    rfilf5        ;[83] xmodem? yes
  8164.     lda   numtry          ; Get current number of tries
  8165.     inc   numtry          ; Increment it for next time
  8166.     cmp   maxtry          ; Have we tried this one enought times
  8167.     bmi    rini2        ;[59] no
  8168. ;[59]    beq   rini1          ; Not yet, go on
  8169. ;[59]    bcs   rini1a          ; Yup, go abort this transfer
  8170. ;[59]rini1:    jmp   rini2          ; Continue
  8171. rini1a: lda   #'A          ; Change state to 'abort'
  8172.     sta   state          ;         ...
  8173.     lda   #errcri          ; Fetch the error index
  8174.     sta   errcod          ;     and store it as the error code
  8175. ;[81]    lda   #false          ; Load AC with false status
  8176.     rts          ;     and return
  8177. rini2:    lda    servef        ;[62] is this server mode?
  8178.     bne    rinici        ;[62] yes
  8179.     jsr   rpak          ; Go try to receive a packet
  8180. ;[53]     sta     rstat          ; Store the return status for later
  8181.     beq   rini2b      ;[53] ok since false is 0
  8182.     lda   ptype          ; Fetch the packet type we got
  8183.     cmp   #'S          ; Was it an 'Init'?
  8184. ;     bne   rini2a           ; No, check the return status
  8185. ;     jmp   rinici           ; Go handle the init case
  8186.     beq   rinici          ; Go handle the init case
  8187. rini2a:               ;[53]lda     rstat          ; Fetch the saved return status
  8188. ;[53]     cmp     #false          ; Is it false?
  8189. ;[53]     beq     rini2b          ; Yes, just return with same state
  8190. ;[53]     lda     #errcri          ;[38] No, fetch the error index
  8191. ;[53]     sta     errcod          ;[38]     and store it as the error code
  8192.     jsr   prcerp          ;[38] Check for error packet and process it
  8193.     bne    rini1a        ;[67] it was an error so quit
  8194.     lda    getfg        ;[75] is this from a get file request
  8195.     beq    rini2b        ;[75] no
  8196. ;[87]    lda    nfcb1        ;[75] we should resend the R packet
  8197. ;[87]    sta    pdlen        ;[75] good thing we saved this
  8198. ;[87]    sta    kwrk01        ;[75] kercpy needs the count here
  8199. ;[87]    lda    #pdbuf\        ;[75] this is 
  8200. ;[87]    sta    kerto        ;[75] where to
  8201. ;[87]    lda    #pdbuf^        ;[75] put the
  8202. ;[87]    sta    kerto+1        ;[75] file name
  8203. ;[87]    jsr    kercpy        ;[75] hope kerfrm is ok
  8204. rini2c                ;[87]
  8205.     lda    #'R        ;[75] now for the 
  8206.     sta    ptype        ;[75] details
  8207.     sta    state        ;[87]
  8208.     lda    #0        ;[75] pnum should be 0
  8209.     sta    pnum        ;[75]
  8210.     jsr    sfsufn        ;[87] now for the file name
  8211.     jsr    spak        ;[75] resend the file name
  8212.     lda    #false        ;[75] and tell about our troubles
  8213.     rts            ;[75]
  8214. ;[53]     lda     #'A          ; Abort this transfer
  8215. ;[53]     sta     state          ; State is now 'abort'
  8216. ;[53]     lda     #false          ; Set return status to 'false'
  8217. ;[53]     rts              ; Return
  8218. rini2b: lda   n          ; Get packet sequence number expected
  8219.     sta   pnum          ; Stuff that parameter at the Nakit routine
  8220.     jsr   nakit          ; Go send the Nak
  8221. ;[81]    lda   #false          ; Set up failure return status
  8222.     rts          ;     and go back
  8223.  
  8224. rinici: lda   pnum          ; Get the packet number we received
  8225.     sta   n          ; Synchronize our packet numbers with this
  8226.     jsr   rpar          ; Load in the init stuff from packet buffer
  8227.     jsr   spar          ; Stuff our init info into the packet buffer
  8228.     lda   #'Y          ; Store the 'Ack' code into the packet type
  8229.     sta   ptype          ;         ...
  8230.     lda   n          ; Get sequence number
  8231.     sta   pnum          ; Stuff that parameter
  8232.     jsr    sparl        ;[72] go set the init par length
  8233. ;[72]    lda   sebq          ; See what we got for an 8-bit quoting
  8234. ;[72]    cmp   #$21          ; First check the character range
  8235. ;[72]    bmi   rinicn          ; Not in range
  8236. ;[72]    cmp   #$3f          ;         ...
  8237. ;[72]    bmi   rinicy          ; Inrange
  8238. ;[72]    cmp   #$60          ;         ...
  8239. ;[72]    bmi   rinicn          ; Not in range
  8240. ;[72]    cmp   #$7f          ;         ...
  8241. ;[72]    bmi   rinicy          ; Inrange
  8242. ;[72]rinicn: lda   #off          ; Punt 8-bit quoting
  8243. ;[72]rinic3    sta   ebqmod          ;         ...
  8244. ;[72]    lda   #$06          ; BTW, the data length is now only 6
  8245. ;[72]    jmp   rinic1          ; Continue
  8246. ;[72]rinicy: lda   #on          ; Make sure everything is on
  8247. ;[72]    sta   ebqmod          ;         ...
  8248. ;[72]rinic4    lda   #$07          ; Data length for ack-init is 7
  8249. ;[72]rinic1: sta   pdlen          ; Store packet data length
  8250.     jsr   spak          ; Send that packet
  8251. ;[87]    lda   numtry          ; Move the number of tries for this packet
  8252. ;[87]    sta   oldtry          ;     to prev packet try count
  8253. ;[87]    lda   #$00          ; Zero
  8254. ;[87]    sta   numtry          ;     the number of tries for current packet
  8255. ;[87]    jsr   incn          ; Increment the packet number once
  8256.     lda   #'F          ; Advance to 'File-header' state
  8257. rfil00    ldx    numtry        ;[87]
  8258.     stx    oldtry        ;[87]
  8259.     jmp    siniy8        ;[87] common code
  8260. ;[87]    sta   state          ;         ...
  8261. ;[81]    lda   #true          ; Set up return code
  8262. ;[87]    rts          ; Return
  8263.  
  8264. rfil0    sta    msgfl        ;[81] set message file
  8265.     lda    pnum        ;[81] do we have the
  8266.     cmp    n        ;[81] the correct packet number
  8267.     beq    .+5        ;[81] yes
  8268.     jmp    rfilf1        ;[81] no abort
  8269.     jsr    scrfrm        ;[81] format the screen for file xfer
  8270. ;[87]    jmp    rfilf9        ;[81] its a long reach
  8271.     jmp    rdatda        ;[87] its a long reach
  8272. rfil:    lda   numtry          ; Get number of tries for this packet
  8273.     inc   numtry          ; Increment it for next time around
  8274.     cmp   maxtry          ; Have we tried too many times?
  8275.     bmi    rfil2        ;[59] no
  8276.     jmp    rfilf1        ;[59] yes
  8277. ;[59]    beq   rfil1          ; Not yet
  8278. ;[59]    bcs   rfil1a          ; Yes, go abort the transfer
  8279. ;[59]rfil1:    jmp   rfil2          ; Continue transfer
  8280. ;[59]rfil1a: lda   #'A          ; Set state of system to 'abort'
  8281. ;[59]sta   state          ;         ...
  8282. ;[59]    lda   #errcrf          ;[53]     fetch the error index
  8283. ;[59]    sta   errcod          ;[53]     and store it as the error code
  8284. ;[59]    lda   #false          ; Return code should be 'false'
  8285. ;[59]    rts          ; Return
  8286. rfil2:    jsr   rpak          ; Try to receive a packet
  8287. ;[53]     sta     rstat          ; Save the return status
  8288.     beq   rfil2e      ;[53] false is 0
  8289.     lda   ptype          ; Get the packet type we found
  8290.     cmp   #'S          ; Was it an 'init' packet?
  8291. ;     bne   rfil2a           ; Nope, try next one
  8292. ;     jmp   rfilci           ; Handle the init case
  8293.     beq   rfilci          ; Handle the init case
  8294. rfil2a: cmp   #'Z          ; Is it an 'eof' packet??
  8295. ;     bne   rfil2b           ; No, try again
  8296. ;     jmp   rfilce           ; Yes, handle that case
  8297.     beq   rfilce          ; Yes, handle that case
  8298.     cmp    #'X        ;[81] is this a message?
  8299.     beq    rfil0        ;[81] yes
  8300. rfil2b: cmp   #'F          ; Is it a 'file-header' packet???
  8301.     bne   rfil2c          ; Nope
  8302.     jmp   rfilcf          ; Handle file-header case
  8303. rfil2c: cmp   #'B          ; Break packet????
  8304.     bne   rfil2d          ; Wrong, go get the return status
  8305.     jmp   rfilcb          ; Handle a break packet
  8306. rfil2d:               ;[53]     lda     rstat          ; Fetch the return status from Rpak
  8307.     cmp    #'D        ;[87] attribute case?
  8308.     bne    rfil2f        ;[87] no
  8309. rfile2h    lda    #fncwrt        ;[87] yes had to wait for attributes
  8310.     jsr    openf        ;[87]
  8311.     lda    #'D        ;[87] advance to d case
  8312.     sta    state        ;[87]
  8313.     jmp    rdatcd        ;[87] let d handle this
  8314. rfil2f    cmp    #'A        ;[87] is this file attribute?
  8315.     bne    rfile2g        ;[87] no
  8316.     lda    pnum        ;[87] right seq?
  8317.     cmp    n        ;[87]
  8318.     bne    rfilf1        ;[87] no abort
  8319.     jsr    rapar        ;[87] handle the attributes
  8320. ;    lda    #0        ;[87] turn off file attr flag
  8321. ;    sta    flatr        ;[87]
  8322.     jmp    rfilf9        ;[87] its a  long reach
  8323. rfile2g                ;[87]    
  8324. ;[53]     cmp     #false          ; Was it a false return?
  8325. ;[53]     beq     rfil2e          ; Yes, Nak it and return
  8326. ;[53]     lda     #errcrf          ;[38] No, fetch the error index
  8327. ;[53]     sta     errcod          ;[38]     and store it as the error code
  8328.     jsr   prcerp          ;[38] Check for error packet and process it
  8329.     bne    rfilf1        ;[67] its an error pkt so quit
  8330. ;[53]     lda     #'A          ; Abort this transfer
  8331. ;[53]     sta     state          ;         ...
  8332. ;[53]     lda     #false          ; Set up failure return code
  8333. ;[53]     rts              ;     and return
  8334. rfil2e: lda   n          ; Move the expected packet number
  8335.     sta   pnum          ;     into the spot for the parameter
  8336.     jsr   nakit          ; Nak the packet
  8337. ;[81]    lda   #false          ; Do a false return but don't change state
  8338.     rts          ; Return
  8339. rfilci: lda   oldtry          ; Get number of tries for prev packet
  8340.     inc   oldtry          ; Increment it
  8341.     cmp   maxtry          ; Have we tried this one too much?
  8342.     bpl    rfilf1        ;[59] yes
  8343. ;[59]    beq   rfili1          ; Not quite yet
  8344. ;[59]    bcs   rfili2          ; Yes, go abort this transfer
  8345. ;[59]rfili1: jmp   rfili3          ; Continue
  8346. ;[59]rfili2:
  8347. ;[59]rfili5: lda   #'A          ; Move abort code
  8348. ;[59]    sta   state          ;     to system state
  8349. ;[59]    lda   #errcrf          ; Fetch the error index
  8350. ;[59]    sta   errcod          ;     and store it as the error code
  8351. ;[59]    lda   #false          ; Prepare failure return
  8352. ;[59]    rts          ;     and go back
  8353. ;[69]rfili3: lda   pnum          ; See if pnum=n-1
  8354. ;[69]    clc          ;         ...
  8355. ;[69]    adc   #$01          ;         ...
  8356. ;[69]    cmp   n          ;         ...
  8357. rfili3: jsr    bpnum          ;[69] See if pnum=n-1
  8358.     bne    rfilf1        ;[59] fail
  8359. ;[59]    beq   rfili4          ; If it does, than we are ok
  8360. ;[59]    jmp   rfili5          ; Otherwise, abort
  8361. rfili4: jsr   spar          ; Set up the init parms in the packet buffer
  8362.     lda   #'Y          ; Set up the code for Ack
  8363.     sta   ptype          ; Stuff that parm
  8364. ;[72]    lda   #$06          ; Packet length for init
  8365. ;[72]    sta   pdlen          ; Stuff that also
  8366.     jsr    sparl        ;[72] set paramater list leng
  8367.     jsr   spak          ; Send the ack
  8368.     lda   #$00          ; Clear out
  8369.     sta   numtry          ;     the number of tries for current packet
  8370. ;[81]    lda   #true          ; This is ok, return true with current state
  8371.     rts          ; Return
  8372. rfilce: lda   oldtry          ; Get number of tries for previous packet
  8373.     inc   oldtry          ; Up it for next time we have to do this
  8374.     cmp   maxtry          ; Too many times for this packet?
  8375.     bpl    rfilf1        ;[59] yes
  8376. ;[59]    beq   rfile1          ; Not yet, continue
  8377. ;[59]    bcs   rfile2          ; Yes, go abort it
  8378. ;[59]rfile1: jmp   rfile3          ;         ...
  8379. ;[59]rfile2:
  8380. ;[59]rfile5: lda   #'A          ; Load abort code
  8381. ;[59]    sta   state          ;     into current system state
  8382. ;[59]    lda   #errcrf          ; Fetch the error index
  8383. ;[59]    sta   errcod          ;     and store it as the error code
  8384. ;[59]    lda   #false          ; Prepare failure return
  8385. ;[59]    rts          ;     and return
  8386. ;[69]rfile3: lda   pnum          ; First, see if pnum=n-1
  8387. ;[69]    clc          ;         ...
  8388. ;[69]    adc   #$01          ;         ...
  8389. ;[69]    cmp   n          ;         ...
  8390. rfile3: jsr    bpnum          ;[69] First, see if pnum=n-1
  8391.     bne    rfilf1        ;[59] no good
  8392. ;[59]    beq   rfile4          ; If so, continue
  8393. ;[59]    jmp   rfile5          ; Else, abort it
  8394. rfile4: lda   #'Y          ; Load 'ack' code
  8395.     sta   ptype          ; Stuff that in the packet type
  8396.     lda   #$00          ; This packet will have a packet data length
  8397.     sta   pdlen          ;     of zero
  8398.     jsr   spak          ; Send the packet out
  8399.     lda   #$00          ; Zero number of tries for current packet
  8400.     sta   numtry          ;         ...
  8401. ;[81]    lda   #true          ; Set up successful return code
  8402.     rts          ;     and return
  8403. rfilcf: lda   pnum          ; Does pnum=n?
  8404.     cmp   n          ;         ...
  8405.     beq    rfilf2        ;[59] yes carry on
  8406. ;[59]    bne   rfilf1          ; If not, abort
  8407. ;[59]    jmp   rfilf2          ; Else, we can continue
  8408. rfilf1: lda   #'A          ; Load the abort code
  8409.     sta   state          ;     and stuff it as current system state
  8410.     lda   #errcrf          ; Fetch the error index
  8411.     sta   errcod          ;     and store it as the error code
  8412. ;[81]    lda   #false          ; Prepare failure return
  8413.     rts          ;     and go back
  8414. rfilf2: jsr   getfil          ; Get the filename we are to use
  8415. rfilf5                ;[83]
  8416.     lda    #0        ;[81] tell were a file
  8417.     sta    msgfl        ;[81]
  8418.     sta    lcurfl        ;[87] start with 0
  8419.     sta    lcurfl+1    ;[87]
  8420.     sta    lcurfl+2    ;[87]
  8421.     sta    rchr        ;[87] start with 0
  8422.     sta    rchr+1    ;[87]
  8423.     sta    rchr+2    ;[87]
  8424.     jsr    scrfrm        ;[79] format the screen for file xfer
  8425. ;[87]    lda    flatr        ;[87] possible file attributes?
  8426. ;[87]    bne    rfilf9        ;[87] wait til we see abt file attributes
  8427. ;[87]    lda   #fncwrt          ; Tell the open routine we want to write
  8428. ;[87]    jsr   openf          ; Open up the file
  8429.     lda    prtcl        ;[83] xmodem?
  8430.     beq    rfilf9        ;[83] no
  8431.     lda    #'N        ;[83] nak it first
  8432.     bne    rfilfa        ;[83]
  8433. rfilf9                ;[81]
  8434.     lda   #'Y          ; Stuff code for 'ack'
  8435. rfilfa                ;[83]
  8436.     sta   ptype          ; Into packet type parm
  8437.     lda   #$00          ; Stuff a zero in as the packet data length
  8438.     sta   pdlen          ;         ...
  8439.     jsr   spak          ; Ack the packet
  8440. ;[87]    lda   numtry          ; Move current tries to previous tries
  8441. ;[87]    sta   oldtry          ;         ...
  8442. ;[87]    lda   #$00          ; Clear the 
  8443. ;[87]    sta   numtry          ; Number of tries for current packet
  8444. ;[87]    jsr   incn          ; Increment the packet sequence number once
  8445.     lda    #'F        ;[87] no change?
  8446. ;[87]    ldx    flatr        ;[87] file attributes?
  8447. ;[87]    bne    .+4        ;[87] yes
  8448. ;[87]    lda   #'D          ; Advance the system state to 'receive-data'
  8449.     jmp    rfil00        ;[87] common code
  8450. ;[87]    sta   state          ;         ...
  8451. ;[81]    lda   #true          ; Set up success return
  8452. rfilrt                ;[87]
  8453.     rts          ;     and go back
  8454. rfilcb: lda   pnum          ; Does pnum=n?
  8455.     cmp   n          ;         ...
  8456.     bne    rfilf1        ;[59] no give it up
  8457. ;[59]    bne   rfilb1          ; If not, abort the transfer process
  8458. ;[59]    jmp   rfilb2          ; Otherwise, we can continue
  8459. ;[59]rfilb1: lda   #'A          ; Code for abort
  8460. ;[59]    sta   state          ; Stuff that into system state
  8461. ;[59]    lda   #errcrf          ; Fetch the error index
  8462. ;[59]    sta   errcod          ;     and store it as the error code
  8463. ;[59]    lda   #false          ; Load failure return status
  8464. ;[59]    rts          ;     and return
  8465. rfilb2: lda   #'Y          ; Set up 'ack' packet type
  8466.     sta   ptype          ;         ...
  8467.     lda   #$00          ; Zero out
  8468.     sta   pdlen          ;     the packet data length
  8469.     jsr   spak          ; Send out this packet
  8470.     lda   #'C          ; Advance state to 'complete'
  8471.     sta   state          ;     since we are now done with the transfer
  8472. ;[81]    lda   #true          ; Return a true
  8473.     rts          ;         ...
  8474.  
  8475. rdat:    lda   numtry          ; Get number of tries for current packet
  8476.     inc   numtry          ; Increment it for next time around
  8477.     cmp   maxtry          ; Have we gone beyond number of tries allowed?
  8478.     bmi    rdat2        ;[59] not yet
  8479.     jmp     rdatf5        ;[59] yes sigh!
  8480. ;[59]    beq   rdat1          ; Not yet, so continue
  8481. ;[59]    bcs   rdat1a          ; Yes, we have, so abort
  8482. ;[59]rdat1:    jmp   rdat2          ;         ...
  8483. ;[59]rdat1a: lda   #'A          ; Code for 'abort' state
  8484. ;[59]    sta   state          ; Stuff that in system state
  8485. ;[59]    lda   #errcrd          ; Fetch the error index
  8486. ;[59]    sta   errcod          ;     and store it as the error code
  8487. ;[59]    lda   #false          ; Set up failure return code
  8488. ;[59]    rts          ;     and go back
  8489. rdat2:    jsr   rpak          ; Go try to receive a packet
  8490.                ;[53] sta     rstat          ; Save the return status for later
  8491.     beq   rdat2d      ;[53] bad packet? yes,since false is 0
  8492.     lda   ptype          ; Get the type of packet we just picked up
  8493.     cmp   #'D          ; Was it a data packet?
  8494. ;[59]    bne   rdat2a          ; If not, try next type
  8495. ;[59]    jmp   rdatcd          ; Handle a data packet
  8496.     beq    rdatcd        ;[59] yes
  8497. rdat2a: cmp   #'F          ; Is it a file-header packet?
  8498. ;[59]    bne   rdat2b          ; Nope, try again
  8499. ;[59]    jmp   rdatcf          ; Go handle a file-header packet
  8500.     beq    rdatcf        ;[59] yes
  8501.     cmp    #'X        ;[81] is it text (a long reply)
  8502.     beq    rdatcf        ;[81] yes, treat it like file-header
  8503. rdat2b: cmp   #'Z          ; Is it an eof packet???
  8504.     bne   rdat2c          ; If not, go check the return status from rpak
  8505.     jmp   rdatce          ; It is, go handle eof processing
  8506. rdat2c:               ;[53]lda     rstat          ; Fetch the return status
  8507. ;[53]     cmp     #false          ; Was it a failure return?
  8508. ;[53]     beq     rdat2d          ; If it was, Nak it
  8509. ;[53]     lda     #errcrd          ;[38] Fetch the error index
  8510. ;[53]     sta     errcod          ;[38]     and store it as the error code
  8511.     jsr   prcerp          ;[38] Check for error packet and process it
  8512.     bne    rdatf5        ;[67] its an error pkt so quit
  8513. ;[53]     lda     #'A          ; Give up the whole transfer
  8514. ;[53]     sta     state          ; Set system state to 'false'
  8515. ;[53]     lda     #false          ; Set up a failure return
  8516. ;[53]     rts              ;     and go back
  8517. rdat2d: lda   n          ; Get the expected packet number
  8518.     sta   pnum          ; Stuff that parameter for Nak routine
  8519.     jsr   nakit          ; Send a Nak packet
  8520. ;[81]    lda   #false          ; Give failure return
  8521.     rts          ; Go back
  8522.  
  8523. rdatcd: lda   pnum          ; Is pnum the right sequence number?
  8524.     cmp   n          ;         ...
  8525.     beq    rdatd7        ;[59] yes
  8526. ;[59]    bne   rdatd1          ; If not, try another approach
  8527. ;[59]    jmp   rdatd7          ; Otherwise, everything is fine
  8528. rdatd1: lda   oldtry          ; Get number of tries for previous packet
  8529.     inc   oldtry          ; Increment it for next time we need it
  8530.     cmp   maxtry          ; Have we exceeded that limit?
  8531.     bpl    rdatf5        ;[59] yes
  8532. ;[59]    beq   rdatd2          ; Not just yet, continue
  8533. ;[59]    bcs   rdatd3          ; Yes, go abort the whole thing
  8534. ;[59]rdatd2: jmp   rdatd4          ; Just continue working on the thing
  8535. ;[59]rdatd3:
  8536. ;[59]rdatd6: lda   #'A          ; Load 'abort' code into the
  8537. ;[59]    sta   state          ;     current system state
  8538. ;[59]    lda   #errcrd          ; Fetch the error index
  8539. ;[59]    sta   errcod          ;     and store it as the error code
  8540. ;[59]    lda   #false          ; Make this a failure return
  8541. ;[59]    rts          ; Return
  8542. ;[69]rdatd4: lda   pnum          ; Is pnum=n-1... Is the received packet
  8543. ;[69]    clc          ;     the one previous to the currently
  8544. ;[69]    adc   #$01          ;     expected packet?
  8545. ;[69]    cmp   n          ;         ...
  8546. rdatd4: jsr    bpnum          ; [69]Is pnum=n-1... Is the received packet
  8547.     bne    rdatf5        ;[59] no give it up
  8548. ;[59]    beq   rdatd5          ; Yes, continue transfer
  8549. ;[59]    jmp   rdatd6          ; Nope, abort the whole thing
  8550. rdatd5: jsr   spar          ; Go set up init data
  8551.     lda   #'Y          ; Make it look like an ack to a send-init
  8552.     sta   ptype          ;         ...
  8553. ;[72]    lda   #$06          ;         ...
  8554. ;[72]    sta   pdlen          ;         ...
  8555.     jsr    sparl        ;[72] set init par list length
  8556.     jsr   spak          ; Go send the ack
  8557.     lda   #$00          ; Clear the
  8558.     sta   numtry          ;     number of tries for current packet
  8559. ;[81]    lda   #true          ;         ...
  8560.     rts          ; Return (successful!)
  8561. ;[81]rdatd7: jsr   bufemp          ; Go empty the packet buffer
  8562. rdatd7: lda    msgfl        ;[81] is this a message?
  8563.     bne    rdatd8        ;[81] yes
  8564.     jsr   bufemp          ;[81] Go empty the packet buffer
  8565.     jmp    rdatd9        ;[81]
  8566. rdatd8    jsr    dbloc        ;[81] position to the debug area
  8567.     jsr    abufmt        ;[81] now put to the screen
  8568. rdatd9                ;[81]
  8569. ;[81]    lda   #'Y          ; Set up an ack packet
  8570. ;[81]    sta   ptype          ;         ...
  8571.     lda n    ;    ...
  8572.     sta pnum    ;    ...
  8573. ;[87]    jmp    rfilf9        ; [81] common code
  8574. rdatda    lda   #'Y          ;[87] Stuff code for 'ack'
  8575.     sta   ptype          ;[87] Into packet type parm
  8576.     lda   #$00          ;[87] Stuff a zero in as the packet data length
  8577.     sta   pdlen          ;[87]         ...
  8578.     jsr   spak          ;[87] Ack the packet
  8579.     lda   #'D          ;[87] Advance the system state to 'receive-data'
  8580.     jmp    rfil00        ;[87] common code
  8581. ;[81]    lda   #$00          ; Don't forget, there is no data
  8582. ;[81]    sta   pdlen          ;         ...
  8583. ;[81]    jsr   spak          ; Send it!
  8584. ;[81]    lda   numtry          ; Move tries for current packet count to
  8585. ;[81]    sta   oldtry          ;     tries for previous packet count
  8586. ;[81]    lda   #$00          ; Zero the
  8587. ;[81]    sta   numtry          ;     number of tries for current packet
  8588. ;[81]    jsr   incn          ; Increment the packet sequence number once
  8589. ;[81]    lda   #'D          ; Advance the system state to 'receive-data'
  8590. ;[81]    sta   state          ;         ...
  8591. ;[81]    lda   #true          ;         ...
  8592. ;[81]    rts          ; Return (successful)
  8593.  
  8594. rdatcf: lda   oldtry          ; Fetch number of tries for previous packet
  8595.     inc   oldtry          ; Increment it for when we need it again
  8596.     cmp   maxtry          ; Have we exceeded maximum tries allowed?
  8597.     bmi    rdatf3        ;[59] no
  8598. ;[59]    beq   rdatf1          ; Not yet, go on
  8599. ;[59]    bcs   rdatf2          ; Yup, we have to abort this thing
  8600. ;[59]rdatf1: jmp   rdatf3          ; Just continue the transfer
  8601. ;[59]rdatf2:
  8602. rdatf5: lda   #'A          ; Move 'abort' code to current system state
  8603.     sta   state          ;         ...
  8604.     lda   #errcrd          ; Fetch the error index
  8605.     sta   errcod          ;     and store it as the error code
  8606. ;[81]    lda    #0        ;[67] tell close no errors
  8607.     lda    msgfl        ;[81] is this a message?
  8608.     bne    .+5        ;[81] yes, nice to have a=0
  8609.     jsr    closef        ;[67] now close the file
  8610. ;[81]    lda   #false          ;         ...
  8611.     rts          ;     and return false
  8612. ;[69]rdatf3: lda   pnum          ; Is this packet the one before the expected
  8613. ;[69]    clc          ;     one?
  8614. ;[69]    adc   #$01          ;         ...
  8615. ;[69]    cmp   n          ;         ...
  8616. rdatf3: jsr    bpnum          ; [69]Is this packet the one before the expected
  8617. ;[69]    beq   rdatf4          ; If so, we can still ack it
  8618. ;[69]    jmp   rdatf5          ; Otherwise, we should abort the transfer
  8619.     bne    rdatf5        ;[69] not even the previous que passo
  8620. ;[81]rdatf4: lda   #'Y          ; Load 'ack' code
  8621. rdatf4: jmp    rfile4        ;[81] common code
  8622. ;[81]    sta   ptype          ; Stuff that parameter
  8623. ;[81]    lda   #$00          ; Use zero as the packet data length
  8624. ;[81]    sta   pdlen          ;         ...
  8625. ;[81]    jsr   spak          ; Send it!
  8626. ;[81]    lda   #$00          ; Zero the number of tries for current packet
  8627. ;[81]    sta   numtry          ;         ...
  8628. ;[81]    lda   #true          ;         ...
  8629. ;[81]    rts          ; Return (successful)
  8630.  
  8631. ;[83]rdatce: lda   pnum          ; Is this the packet we are expecting?
  8632. rdatce: lda    prtcl        ;[83] xmodem?
  8633.     bne    rdate2        ;[83] yes
  8634.     lda   pnum          ;[83] Is this the packet we are expecting?
  8635.     cmp   n          ;         ...
  8636.     bne    rdatf5        ;[59] no fail it
  8637. ;[59]    bne   rdate1          ; No, we should go abort
  8638. ;[59]    jmp   rdate2          ; Yup, go handle it
  8639. ;[59]rdate1: lda   #'A          ; Load 'abort' code into
  8640. ;[59]    sta   state          ;     current system state
  8641. ;[59]    lda   #errcrd          ; Fetch the error index
  8642. ;[59]    sta   errcod          ;     and store it as the error code
  8643. ;[59]    lda   #false          ;         ...
  8644. ;[59]    rts          ; Return (failure)
  8645. rdate2:
  8646. ;    lda   #fcb1\          ;[18] Get the pointer to the fcb
  8647. ;    sta   kerfcb          ;[18]     and store it where the close routine
  8648. ;    lda   #fcb1^          ;[18]     can find it
  8649. ;    sta   kerfcb+1      ;[56] ??????[18]         ...
  8650. ;[81]    lda   #$00          ;[18][3] Make CLOSEF see there are no errors
  8651.     lda    msgfl        ; is this a message
  8652.     bne    .+5        ; yes, nice to have a=0
  8653.     jsr   closef          ;[18] We are done with this file, so close it
  8654.     lda    rchr+2        ;[87] make the % 100
  8655.     sta    lcurfl+2    ;[87]
  8656.     lda    rchr+1        ;[87]
  8657.     sta    lcurfl+1    ;[87]
  8658. ;[87]    jsr   incn          ;[18] Increment the packet number
  8659.     lda   #'Y          ; Get set up for the ack
  8660.     sta   ptype          ; Stuff the packet type
  8661.     lda   n          ;     packet number
  8662.     sta   pnum          ;         ...
  8663.     lda   #$00          ;     and packet data length
  8664.     sta   pdlen          ;     parameters
  8665.     jsr   spak          ; Go send it!
  8666. ;[87]    jsr   incn          ;[87] Increment the packet number
  8667.     lda   #'F          ; Advance system state to 'file-header'
  8668.     ldx    prtcl        ;[83]
  8669.     beq    .+4        ;[83] xmodem? no
  8670.     lda    #'C        ;[83] yes thats all
  8671.     jmp    siniy8        ;[87] common code
  8672. ;[87]    sta   state          ;     incase more files are coming
  8673. ;[81]    lda   #true          ;         ...
  8674. ;[87]    rts          ; Return (successful)
  8675. bpnum    lda    pnum        ;[69] bump pnum mod $3f
  8676.     clc            ;[69]
  8677.     adc    #1        ;[69]
  8678.     ldx    prtcl        ;[83] xmodem?
  8679.     bne    .+4        ;[83] yes no modulo
  8680.     and    #$3f        ;[69]
  8681.     cmp    n        ;[69] kermit recycles @ $3f
  8682.     rts            ;[69]
  8683. dpnum    dec    pnum        ;[69]decrement kermit packet #
  8684.     lda    pnum        ;[69]
  8685.     and    #$3f        ;[69] mod $3f
  8686.     cmp    n        ;[69]
  8687.     rts            ;[69]
  8688.  
  8689. ;[75]sparl    lda    filmod        ;[72] is this text file?
  8690. ;[75]    beq    rinic3        ;[72] yes turn off ebq
  8691. ;[75]    lda    parity        ;[75] is this no parity?
  8692. ;[75]    beq    rinic3        ;[75] yes we dont need ebq
  8693. ;[75]    lda    ebqmod        ;[72] did other kermit agree to ebq?
  8694. ;[75]    bne    rinic4        ;[72] yes
  8695. ;[75]    jsr    u2s8b        ;[72] unable to send/rec 8 bits
  8696. ;[75]    lda    #0        ;[72] tell
  8697. ;[75]rinic3    sta   ebqmod          ;[72]         ...
  8698. ;[75]    lda   #$06          ;[72] BTW, the data length is now only 6
  8699. ;[75]    jmp   rinic1          ;[72] Continue
  8700. ;[75]rinic4    lda   #$07          ;[72] Data length for ack-init is 7
  8701. ;[75]rinic4    lda   #13          ;[75] Data length for ack-init
  8702. ;[75]    ldx    rpsiz        ;[75] should we use extended len
  8703. ;[75]    cpx    #95        ;[75] > 94 means yes
  8704. ;[75]    bcs    rinic1        ;[75] yes
  8705. ;[75]    lda    #7        ;[75] tell him only ebq
  8706. ;[75]rinic1: sta   pdlen          ;[72] Store packet data length
  8707. ;[75]    rts            ;[72]
  8708. sparl    lda    #13        ;[75] tell remote all we can do
  8709.     sta    pdlen        ;[75]
  8710.     rts            ;[75]
  8711.  
  8712. .SBTTL    Send  routine
  8713.  
  8714. ;
  8715. ;     This routine reads a file from disk and sends packets
  8716. ;     of data to the remote kermit.
  8717. ;
  8718. ;         Input:     Filename returned from Comnd routines
  8719. ;
  8720. ;         Output:     File is sent over port
  8721. ;
  8722. ;         Registers destroyed:     A,X,Y
  8723. ;
  8724.  
  8725. send:
  8726.     jsr    kerin7        ;[78] just in case were reading kermit.ini
  8727. ;[86]    ldx   #mxfnl          ;[59][13] Longest length a filename may be
  8728. ;[86]    lda    dosflg        ;[59] prodos?
  8729. ;[86]    beq    .+4        ;[59] no
  8730. ;[86]    ldx    #mxppth        ;[59] max path length
  8731. ;[86]    ldy   #$00          ;[13] No special flags needed
  8732. ;[81]    sty    kerins        ;[75] make sure we purge the com buffers
  8733. ;[86]    lda   #cmifi          ; Load opcode for parsing input files
  8734.     jsr    preptx        ; got to stop on comma
  8735. ;[87]    sty    getfln        ; 0 len
  8736.     jsr   comnd          ; Call comnd routine
  8737.           jmp     kermt6          ; Give the 'missing filespec' error
  8738.     sta   kwrk01          ;[13] Store length of file parsed
  8739.     sta    nfcb1        ;[59] in case of prodos set # chs
  8740.     sta    getfln        ;[87] size of get file name
  8741.     stx   kerfrm          ;[13] Save the from address (addr[atmbuf])
  8742.     sty   kerfrm+1      ;[13]         ...
  8743. ;[81]    lda   #fcb1\          ;[13] Save the to address (Fcb1)
  8744. ;[81]    sta   kerto          ;[13]         ...
  8745. ;[81]    lda   #fcb1^          ;[13]         ...
  8746. ;[81]    sta   kerto+1          ;[13]         ...
  8747.     sta    patl        ;[81] just in case we wildcd
  8748.     ldx    #fcb1\        ;[81]
  8749.     ldy    #fcb1^        ;[81] incase were not
  8750.     lda    wcpres        ;[81] are we wildcd
  8751.     beq    send7        ;[81] no
  8752.     jsr    sfilec        ;[81] set up line of catalog to start on
  8753.     ldx    #patbuf\    ;[81] yes put it in pattern
  8754.     ldy    #patbuf^    ;[81]
  8755. send7    stx    kerto        ;[81]
  8756.     sty    kerto+1        ;[81]
  8757.     jsr   clrfcb          ;[13] Clear the fcb
  8758.     jsr   kercpy          ;[13] Copy the string
  8759. ;[66]    ldy   kwrk01          ;[13] Get filename length
  8760. ;[66]    lda   #nul          ;[13] Fetch a null character
  8761. ;[66]    sta   (kerto),y      ;[13] Stuff a null at end-of-buffer
  8762.     lda    wcpres        ;[86] are we wild card
  8763.     bne    send9        ;[86] yes only one
  8764.     lda   #dosbuf\          ;[87] now save the file name
  8765.     sta   kerto          ;[87]
  8766.     lda   #dosbuf^          ;[87]
  8767.     sta   kerto+1          ;[87]
  8768.     jsr    kercpy        ; need for the file name
  8769.     lda    #cmtxt        ;[86] see if we got to change name
  8770.     jsr    comnd        ;[86]
  8771.     jmp    send9        ;[86] no
  8772.     sta    getfln        ;[86] size
  8773.     sta    kwrk01        ;[86] needed for kercpy
  8774.     stx    kerfrm        ;[86] where it is
  8775.     sty    kerfrm+1    ;[86]
  8776. ;[87]    ldx    #getln\        ;[86] where to put it
  8777. ;[87]    ldy    #getln^        ;[86]
  8778. ;[87]    stx    kerto        ;[86]
  8779. ;[87]    sty    kerto+1        ;[86]
  8780.     jsr    kercpy        ;[86] save new name for later
  8781. send9                ;[86]    
  8782.     jsr   prcfm          ; Parse and print a confirm
  8783. ;[81]    jsr   tlinit      ;[47] initialize the serial port
  8784. ;[81]    bne    send2        ;[62] unable to use the com port
  8785. ;[81]    jsr    u2icc        ;[62] tattle
  8786. ;[81]    jmp    kermit        ;[62]
  8787. ;[81]send2                ;[62]
  8788.     jsr    comint        ;[81] common com init
  8789.     jsr   sswt          ; Perform send-switch routine
  8790.     pha            ;[67] save error 
  8791. ;[68]    jsr    home        ;[67]
  8792.     jsr   bell          ;[56] Sound bell at the user
  8793.     jsr    dfsv        ;[69]
  8794.     jsr    test2e        ;[61] test for //e 80 col
  8795.     pla            ;[67] any error?
  8796.     bne    send1        ;[67] no
  8797.     jmp     stat07        ;[67] yes tattle
  8798. send1    jmp   kermit          ; Go back to main routine
  8799.  
  8800. sswt:    lda   #'S          ; Set up state variable as
  8801.     jsr    rswint        ;[87] set up lots
  8802. ;[87]    sta   state          ;     Send-init
  8803. ;[87]    lda   #$00          ; Clear
  8804. ;[78]    sta   eodind          ;[6]     The End-of-Data indicator
  8805. ;[87]    sta   n          ;     Packet number
  8806. ;[87]    sta   numtry          ;     Number of tries
  8807. ;[87]    sta   oldtry          ;     Old number of tries
  8808. ;[87]    sta   eofinp          ;     End of input flag
  8809. ;[87]    sta   errcod          ;     Error indicator
  8810. ;[87]    sta   rtot          ;     Total received characters
  8811. ;[87]    sta   rtot+1          ;         ...
  8812. ;[87]    sta   stot          ;     Total Sent characters
  8813. ;[87]    sta   stot+1          ;         ...
  8814. ;[87]    sta   rchr          ;     Received characters, current file
  8815. ;[87]    sta   rchr+1          ;         ...
  8816. ;[87]    sta   rchr+2          ;[84]         ...
  8817. ;[87]    sta   schr          ;     Sent characters, current file
  8818. ;[87]    sta   schr+1          ;         ...
  8819. ;[87]    sta   schr+2          ;[84]         ...
  8820. ;[87]    sta   tpak          ;[16]     and the total packet number
  8821. ;[87]    sta   tpak+1          ;[16]         ...
  8822. ;[87]    sta    exfg        ;[75] start out with classic packet
  8823. ;[87]    sta    flowfg        ;[83] xmodem may need this
  8824. ;[87]    jsr    sutljp        ;[85] set up screen distributor
  8825. ;[87]    jsr    scrfrm        ;[59] and format the screen for file xfer
  8826. ;[83]    lda   #pdbuf\          ; Set up the address of the packet buffer
  8827. ;[83]    sta   saddr          ;     so that we can clear it out
  8828. ;[83]    lda   #pdbuf^          ;         ...
  8829. ;[83]    sta   saddr+1          ;         ...
  8830.     lda   #$00          ; Clear AC
  8831.     ldy   #$00          ; Clear Y
  8832. ;[83]clpbuf: sta   (saddr),y      ; Step through buffer, clearing it out
  8833. clpbuf: sta   pdbuf,y      ;[83] Step through buffer, clearing it out
  8834.     iny          ; Up the index
  8835.     cpy   #mxpack-4      ; Done?
  8836.     bmi   clpbuf          ; No, continue
  8837. sswt1:    lda   state          ; Fetch state of the system
  8838.     cmp   #'D          ; Do Send-data?
  8839.     bne   sswt2          ; No, try next one
  8840.     jsr   sdat          ; Yes, send a data packet
  8841.     jmp   sswt1          ; Go to the top of the loop
  8842. sswt2:    cmp   #'F          ; Do we want to send-file-header?
  8843.     bne   sswt3          ; No, continue
  8844.     jsr   sfil          ; Yes, send a file header packet
  8845.     jmp   sswt1          ; Return to top of loop
  8846. sswt3:    cmp   #'Z          ; Are we due for an Eof packet?
  8847.     bne   sswt4          ; Nope, try next state
  8848.     jsr   seof          ; Yes, do it
  8849.     jmp   sswt1          ; Return to top of loop
  8850. sswt4:    cmp   #'S          ; Must we send an init packet
  8851.     bne   sswt5          ; No, continue
  8852.     jsr   sini          ; Yes, go do it
  8853.     jmp   sswt1          ; And continue
  8854. sswt5:    cmp   #'B          ; Time to break the connection?
  8855.     bne   sswt6          ; No, try next state
  8856.     jsr   sbrk          ; Yes, go send a break packet
  8857.     jmp   sswt1          ; Continue from top of loop
  8858. sswt6:    cmp   #'C          ; Is the entire transfer complete?
  8859.     bne   sswt7          ; No, something is wrong, go abort
  8860.     lda   #true          ; Return true
  8861.     rts          ;         ...
  8862. ;[87]sswt7:    lda   #false          ; Return false
  8863. sswt7:    cmp    #'T        ;[87] how abt file attrib?
  8864.     bne    sswt8        ;[87] no
  8865.     jsr    sflatr        ;[87] yes send them
  8866.     jmp    sswt1        ;[87] around we go
  8867. sswt8                ;[87]
  8868.     lda   #false          ; Return false
  8869.     rts          ;         ...
  8870.  
  8871. sdat:    lda   numtry          ; Fetch the number for tries for current packet
  8872.     inc   numtry          ; Add one to it
  8873.     cmp   maxtry          ; Is it more than the maximum allowed?
  8874. ;[67]    bpl    sdat2q        ;[59] yes
  8875.     bmi    sdat1b        ;[67]
  8876.     lda    #1        ;[67] so close wont write
  8877.     jsr    closef        ;[67] now close the file
  8878.     jmp    sdat2q        ;[67] and abort
  8879. ;[59]    beq   sdat1          ; No, not yet
  8880. ;[59]    bcs   sdat1a          ; If it is, go abort
  8881. ;[59]sdat1:    jmp   sdat1b          ; Continue
  8882. ;[59]sdat1a: lda   #'A          ; Load the 'abort' code
  8883. ;[59]    sta   state          ; Stuff that in as current state
  8884. ;[59]    lda   #false          ; Enter false return code
  8885. ;[59]    rts          ;     and return
  8886. sdat1b: lda   #'D          ; Packet type will be 'Send-data'
  8887.     sta   ptype          ;         ...
  8888.     lda   n          ; Get packet sequence number
  8889.     sta   pnum          ; Store that parameter to Spak
  8890.     lda   size          ; This is the size of the data in the packet
  8891.     sta   pdlen          ; Store that where it belongs
  8892.     jsr   spak          ; Go send the packet
  8893. sdat2:    jsr   rpak          ; Try to get an ack
  8894. ;[59]    sta   rstat          ; First, save the return status
  8895.     beq    sdat2c        ;[59] bad get try again
  8896.     lda   ptype          ; Now get the packet type received
  8897.     cmp   #'N          ; Was it a NAK?
  8898. ;[59]    bne   sdat2a          ; No, try for an ACK
  8899. ;[59]    jmp   sdatcn          ; Go handle the nak case
  8900.     beq   sdatcn          ; [59]Go handle the nak case
  8901. sdat2a: cmp   #'Y          ; Did we get an ACK?
  8902. ;[59]    bne   sdat2b          ; No, try checking the return status
  8903. ;[59]    jmp   sdatca          ; Yes, handle the ack
  8904.     beq   sdatca          ; [59]Yes, handle the ack
  8905. ;[59]sdat2b: lda   rstat          ; Fetch the return status
  8906. ;[59]    cmp   #false          ; Failure return?
  8907. ;[59]    beq   sdat2c          ; Yes, just return with current state
  8908. sdat2p    jsr   prcerp          ;[38] Check for error packet and process it
  8909.     beq    sdat2c        ;[68] try again
  8910. sdat2q    lda   #'A          ; Stuff the abort code
  8911.     sta   state          ;     as the current system state
  8912. ;[81]    lda   #false          ; Load failure return code
  8913. sdat2c: rts          ; Go back
  8914. ;[69]sdatcn: dec   pnum          ; Decrement the packet sequence number
  8915. ;[69]    lda   n          ; Get the expected packet sequence number
  8916. ;[69]    cmp   pnum          ; If n=pnum-1 then this is like an ack
  8917. ;[83]sdatcn: jsr    dpnum          ; [69]Decrement the packet sequence number
  8918. sdatcn:             ;[83]
  8919.     lda    prtcl        ;[83] xmodem?
  8920.     bne    sdatn1        ;[83] yes
  8921.     jsr    dpnum          ;[83] Decrement the packet sequence number
  8922. ;[69]    bne   sdatn1          ; No, continue handling the nak
  8923. ;[69]    jmp   sdata2          ; Jump to ack bypassing sequence check
  8924.     beq    sdata2        ;[69] previous sequence so its ok
  8925. sdata1:
  8926. ;[81]sdatn1: lda   #false          ; Failure return
  8927. sdatn1:           ;[81] Failure return
  8928.     jmp    bperrc        ;[83] tally the retries
  8929. ;[83]    rts          ;         ...
  8930. ;[83]sdatca: lda   n          ; First check packet number
  8931. sdatca:             ;[83]
  8932.     lda    prtcl        ;[83] xmodem?
  8933.     bne    sdata2        ;[83] yes
  8934.     lda   n          ;[83] First check packet number
  8935.     cmp   pnum          ; Did he ack the correct packet?
  8936.     bne   sdata1          ; No, go give failure return
  8937. ;[87]sdata2: lda   #$00          ; Zero out number of tries for current packet
  8938. sdata2:                ;[87]
  8939. ;[87]    lda   #$00          ;[87] Zero out number of tries for current packet
  8940. ;[87]    sta   numtry          ;         ...
  8941. ;[87]    jsr   incn          ; Increment the packet sequence number
  8942.     jsr   bufill          ; Go fill the packet buffer with data
  8943.     sta   size          ; Save the data size returned
  8944. ;[72]    lda   eofinp          ; Load end-of-file indicator
  8945. ;[72]    beq     sdatrd        ;[59] not eof
  8946.     cmp    #0        ;[72] 0 is eof,flags may not be set
  8947.     bne    sdatrd        ;[72] works better this way
  8948. ;[59]    cmp   #true          ; Was this set by Bufill?
  8949. ;[59]    beq   sdatrz          ; If so, return state 'Z' ('Send-eof')
  8950. ;[59]    jmp   sdatrd          ; Otherwise, return state 'D' ('Send-data')
  8951. ;[87]sdatrz: lda   #$00          ;[44] Clear
  8952.     sta   eofinp          ;[44]     End of input flag
  8953. ;    lda   #fcb1\          ;[44] Get the pointer to the fcb
  8954. ;    sta   kerfcb          ;[44]     and store it where the close routine
  8955. ;    lda   #fcb1^          ;[44]     can find it
  8956. ;    sta   kerfcb+1      ;[56] ???????????[44]         ...
  8957. ;[59]    lda   #$00          ;[44] Make CLOSEF see there are no errors
  8958.     lda    #1        ;[59] since we are reading,do not attempt write
  8959.     jsr   closef          ;[44] We are done with this file, so close it
  8960.     lda    schr+2        ;[87] make it 100%
  8961.     sta    lcurfl+2    ;[87]
  8962.     lda    schr+1        ;[87]
  8963.     sta    lcurfl+1    ;[87]
  8964.     lda   #'Z          ; Load the Eof code
  8965.     jmp    siniy8        ;[87] common code
  8966. ;[87]    sta   state          ;     and make it the current system state
  8967. ;[81]    lda   #true          ; We did succeed, so give a true return
  8968. ;[87]    rts          ; Go back
  8969. sdatrd: lda   #'D          ; Load the Data code
  8970.     jmp    siniy8        ;[87] common code
  8971. ;[87]    sta   state          ; Set current system state to that
  8972. ;[81]    lda   #true          ; Set up successful return
  8973. ;[87]    rts          ;     and go back
  8974.  
  8975. sfsufn    lda    dosflg        ;[87] save temp
  8976.     pha            ;[87]
  8977.     lda    #true        ;[87]
  8978.     sta    dosflg        ;[87] for bufill to work right
  8979.     sta    fgetgn        ;[87] say were from filename
  8980.     jsr    bufill        ;[87] fill packet
  8981.     sta    pdlen        ;[87] and how many
  8982.     lda    #0        ;[87]
  8983.     sta    schr        ;[87] start over
  8984.     sta    schr+1        ;[87]
  8985.     sta    schr+2        ;[87]
  8986.     sta    fgetgn        ;[87] turn off fgetc filename
  8987.     pla            ;[87] restore dosflg
  8988.     sta    dosflg        ;[87]
  8989.     rts            ;[87]
  8990. sfil:    lda   filmod          ;[6] Fetch the file mode
  8991. ;[83]    beq   sfil0          ;[6] If it is a text file, we don't need length
  8992. ;[83]    lda   #on          ;[6] Otherwise, set flag to get length of file
  8993.     sta   fetfl          ;[6]     from first sector
  8994. sfil0:    lda   numtry          ; Fetch the current number of tries
  8995.     inc   numtry          ; Up it by one
  8996.     cmp   maxtry          ; See if we went up to too many
  8997. ;[87]    bpl    sdat2q        ;[59] yes
  8998.     bmi    sfil1b        ;[87] its a long reach
  8999.     jmp    sdat2q        ;[87] yes
  9000. ;[59]    beq   sfil1          ; Not yet
  9001. ;[59]    bcs   sfil1a          ; Yes, go abort
  9002. ;[59]sfil1:    jmp   sfil1b          ; If we are still ok, take this jump
  9003. ;[59]sfil1a: lda   #'A          ; Load code for abort
  9004. ;[59]    sta   state          ;     and drop that in as the current state
  9005. ;[59]    lda   #false          ; Load false for a return code
  9006. ;[59]    rts          ;     and return
  9007. ;[59]sfil1b: ldy   #$00          ; Clear Y
  9008. ;[83]sfil1b    ldy    nfcb1        ;[59] get # chs
  9009. sfil1b                ;[83]
  9010.     ldy    prtcl        ;[83] xmodem?
  9011.     beq    sfil1a        ;[83] no
  9012.     jsr    rpak        ;[83] wait for a nak
  9013.     beq    sfil1e        ;[83] bad packet
  9014.     lda    ptype        ;[83] what kind of packet?
  9015.     cmp    #'N        ;[83] we need a nak to start
  9016.     beq    sfila2        ;[83] got one now carry on
  9017. sfil1e    rts            ;[83] try again
  9018. sfil1a                ;[83]
  9019. ;[87]    ldy    getfln        ;[86] are we changing names?
  9020. ;[87]    beq    sfil1z        ;[86] no
  9021. ;[87]    sty    pdlen        ;[86]
  9022. ;[87]sfil1w    dey            ;[86]
  9023. ;[87]    bmi    sfil1y        ;[86]
  9024. ;[87]    lda    getln,y        ;[86]
  9025. ;[87]    sta    pdbuf,y        ;[86]
  9026. ;[87]    jmp    sfil1w        ;[86]
  9027. ;[87]sfil1y    ldy    #0        ;[86] only once
  9028. ;[87]    sty    getfln        ;[86]
  9029. ;[87]    beq    sfil1d        ;[86] together again
  9030. ;[87]sfil1z                ;[86]    
  9031. ;[87]    ldy    nfcb1        ;[83] get # chs
  9032. ;[87]    sty   pdlen          ;[59] This is the length of the filename
  9033. ;[87]sfil1c    dey            ;[59]
  9034. ;[87]    bmi    sfil1d        ;[59]
  9035. ;[59]sfil1c:     lda   fcb1,y          ; Get a byte from the filename
  9036. ;[87]    lda    fcb1,y            ;[59]
  9037. ;[59]    cmp   #$00          ; Is it a null?
  9038. ;[59]    beq   sfil1d          ; No, continue
  9039. ;[87]    sta   pdbuf,y          ; Move the byte to this buffer
  9040. ;[59]    iny          ; Up the index once
  9041. ;[87]    jmp   sfil1c          ; Loop and do it again
  9042. sfil1d:
  9043. ;[59]    sty   pdlen          ; This is the length of the filename
  9044.     lda   #'F          ; Load type ('Send-file')
  9045.     sta   ptype          ; Stuff that in as the packet type
  9046.     lda   n          ; Get packet number
  9047.     sta   pnum          ; Store that in its common area
  9048.     jsr    sfsufn        ;[87] put filename in buf controlified
  9049.     jsr   spak          ; Go send the packet
  9050. sfil2:    jsr   rpak          ; Go try to receive an ack
  9051. ;[59]    sta   rstat          ; Save the return status
  9052.     beq    sfil2r        ;[59] bad packet so how can we look further?
  9053.     lda   ptype          ; Get the returned packet type
  9054.     cmp   #'N          ; Is it a NAK?
  9055. ;[59]    bne   sfil2a          ; No, try the next packet type
  9056. ;[59]    jmp   sfilcn          ; Handle the case of a nak
  9057.     beq    sfilcn        ;[59] yes
  9058. sfil2a: cmp   #'Y          ; Is it, perhaps, an ACK?
  9059. ;[59]    bne   sfil2b          ; If not, go to next test
  9060. ;[59]    jmp   sfilca          ; Go and handle the ack case
  9061.     beq    sfilca        ;[59] yes
  9062. ;[59]sfil2b: lda   rstat          ; Get the return status
  9063. ;[59]    beq    sfil2r        ;[59] failure
  9064.     jmp    sdat2p        ;[59] check for error first
  9065. ;[59]    cmp   #false          ; Is it a failure return?
  9066. ;[59]    bne   sfil2c          ; No, just go abort the send
  9067. sfil2r    rts          ; Return failure with current state
  9068. ;[59]sfil2c: jsr   prcerp          ;[38] Check for error packet and process it
  9069. ;[59]    lda   #'A          ; Set state to 'abort'
  9070. ;[59]    sta   state          ; Stuff it in its place
  9071. ;[59]    lda   #false          ; Set up a failure return code
  9072. ;[59]    rts          ;     and go back
  9073. ;[69]sfilcn: dec   pnum          ; Decrement the receive packet number once
  9074. ;[69]    lda   pnum          ; Load it into the AC
  9075. ;[69]    cmp   n          ; Compare that with what we are looking for
  9076. sfilcn: jsr    dpnum          ; [69]Decrement the receive packet number once
  9077.     beq    sfila2        ;[59] 
  9078. ;[59]    bne   sfiln1          ; If n=pnum-1 then this is like an ack, do it
  9079. ;[59]    jmp   sfila2          ; This is like an ack
  9080. sfila1: 
  9081. ;[81]sfiln1: lda   #false          ; Load failure return code
  9082. sfiln1:           ;[81] Load failure return code
  9083. ;[83]    rts          ;     and return
  9084.     jmp    bperrc        ;[83] bump and print retries
  9085. sfilca: lda   n          ; Get the packet number
  9086.     cmp   pnum          ; Is that the one that was acked?
  9087.     bne   sfila1          ; They are not equal
  9088. ;[87]sfila2: lda   #$00          ; Clear AC
  9089. sfila2:                ;[87]
  9090. ;[87]    lda   #$00          ; Clear AC
  9091. ;[87]    sta   numtry          ; Zero the number of tries for current packet
  9092. ;[87]    jsr   incn          ; Up the packet sequence number
  9093. ;    lda   #fcb1\          ; Load the fcb address into the pointer
  9094. ;    sta   kerfcb          ;     for the DOS open routine
  9095. ;    lda   #fcb1^          ;         ...
  9096. ;    sta   kerfcb+1      ;         ...
  9097.     jsr    scrfrm        ;[79] and format the screen for file xfer
  9098.     lda   #fncrea          ; Open for input
  9099.     jsr   openf          ; Open the file
  9100.     lda    dosflg        ;[87] is this prodos?
  9101.     bne    sfila3        ;[87] yes
  9102.     lda    fillen        ;[87] ok this is best 3.3 can give us
  9103.     sta    lcurfl        ;[87] lsb of file length (non text)
  9104.     lda    fillen+1    ;[87] msb
  9105.     sta    lcurfl+1    ;[87]
  9106.     lda    #0        ;[87]
  9107.     sta    lcurfl+2    ;[87] needed for 3.3 file length
  9108.     beq    sfila5        ;[87]
  9109. sfila3    jsr    prodos        ;[87] prodos file size in bytes
  9110.     .byte    geteof        ;[87]
  9111.     .word    pmark        ;[87]
  9112.     bcc    .+5        ;[87] error
  9113.     jsr    perror        ;[87] sigh yes
  9114.     lda    pmark+2        ;[87] size in bytes
  9115.     sta    lcurfl        ;[87] lsb
  9116.     lda    pmark+3        ;[87]
  9117.     sta    lcurfl+1    ;[87]
  9118.     lda    pmark+4        ;[87]
  9119.     sta    lcurfl+2    ;[87] msb
  9120. sfila5                ;[87]    
  9121.     lda    #'T        ;[87] file attributes?
  9122.     ldx    flatr        ;[87]
  9123.     beq    sfila7        ;[87] no
  9124.     jmp    siniy8        ;[87]
  9125. sfila7                ;[87]    
  9126.     jsr   bufill          ; Go get characters from the file
  9127.     sta   size          ; Save the returned buffer size
  9128.     jsr    comint        ;[85] make sure the buffer is empty
  9129.     lda   #'D          ; Set state to 'Send-data'
  9130.     jmp    siniy8        ;[87]
  9131. ;[87]    sta   state          ;         ...
  9132. ;[81]    lda   #true          ; Set up true return code
  9133. ;[87]sfila7                ;[83]
  9134. ;[87]    rts          ;     and return
  9135.  
  9136. seof:    lda   numtry          ; Get the number of attempts for this packet
  9137.     inc   numtry          ; Now up it once for next time around
  9138.     cmp   maxtry          ; Are we over the allowed max?
  9139.     bmi    seof1b        ;[59] no
  9140.     jmp    sini1a        ;[59] yes sigh!
  9141. ;[59]    beq   seof1          ; Not quite yet
  9142. ;[59]    bcs   seof1a          ; Yes, go abort
  9143. ;[59]seof1:    jmp   seof1b          ; Continue sending packet
  9144. ;[59]seof1a: lda   #'A          ; Load 'abort' code
  9145. ;[59]    sta   state          ; Make that the state of the system
  9146. ;[59]    lda   #errmrc          ; Fetch the error index
  9147. ;[59]    sta   errcod          ;     and store it as the error code
  9148. ;[59]    lda   #false          ; Return false
  9149. ;[59]    rts          ;         ...
  9150. seof1b: lda   #'Z          ; Load the packet type 'Z' ('Send-eof')
  9151.     sta   ptype          ; Save that as a parm to Spak
  9152.     lda   n          ; Get the packet sequence number
  9153.     sta   pnum          ; Copy in that parm
  9154.     lda   #$00          ; This is our packet data length (0 for EOF)
  9155.     sta   pdlen          ; Copy it
  9156.     jsr   spak          ; Go send out the Eof
  9157. seof2:    jsr   rpak          ; Try to receive an ack for it
  9158. ;[59]    sta   rstat          ; Save the return status
  9159. ;[83]    beq    seof2c        ;[59] bad get
  9160. ;[87]    beq    sfila7        ;[83] bad get
  9161.     beq    seofa7        ;[87] bad get
  9162.     lda   ptype          ; Get the received packet type
  9163.     cmp   #'N          ; Was it a nak?
  9164. ;[59]    bne   seof2a          ; If not, try the next packet type
  9165. ;[59]    jmp   seofcn          ; Go take care of case nak
  9166.     beq   seofcn          ;[59] Go take care of case nak
  9167. seof2a: cmp   #'Y          ; Was it an ack
  9168. ;[59]    bne   seof2b          ; If it wasn't that, try return status
  9169. ;[59]    jmp   seofca          ; Take care of the ack
  9170.     beq   seofca          ;[59] Take care of the ack
  9171. ;[59]seof2b: lda   rstat          ; Fetch the return status
  9172. ;[59]    cmp   #false          ; Was it a failure?
  9173. ;[59]    beq   seof2c          ; Yes, just fail return with current state
  9174.     jmp    sdat2p        ;[59] 
  9175. ;[59]    jsr   prcerp          ;[38] Check for error packet and process it
  9176. ;[59]    lda   #'A          ; Abort the whole thing
  9177. ;[59]    sta   state          ; Set the state to that
  9178. ;[59]    lda   #false          ; Get false return status
  9179. ;[59]seof2c: rts          ; Return
  9180. ;[69]seofcn: dec   pnum          ; Decrement the received packet sequence number
  9181. ;[69]    lda   n          ; Get the expected sequence number
  9182. ;[69]    cmp   pnum          ; If it's the same as pnum-1, it is like an ack
  9183. ;[83]seofcn: jsr    dpnum          ; [69]Decrement the received packet sequence number
  9184. seofcn:             ;[83]
  9185.     lda    prtcl        ;[83] xmodem?
  9186.     bne    seof2c        ;[83] yes
  9187.     jsr    dpnum          ;[83] Decrement the received packet sequence number
  9188.     beq    seofa2        ;[59]
  9189. ;[59]    bne   seofn1          ; It isn't, continue handling the nak
  9190. ;[59]    jmp   seofa2          ; Switch to an ack but bypass sequence check
  9191. seofa1:
  9192. ;[81]seofn1: lda   #false          ; Load failure return status
  9193. seofn1:           ;[81] Load failure return status
  9194. ;[83]seof2c    rts          ;[59]     and return
  9195. seof2c    jmp    bperrc        ;[83] bump and print retries
  9196. ;[83]seofca: lda   n          ; Check sequence number expected against
  9197. seofca:             ;[83]
  9198.     lda    prtcl        ;[83]xmodem?
  9199.     beq    seofcx        ;[83] no
  9200.     lda    #'C        ;[83] yes thats all
  9201.     sta    state        ;[83]
  9202. seofa7                ;[87] place to hang ur hat
  9203.     rts            ;[83]
  9204. seofcx                ;[83]
  9205.     lda   n          ; Check sequence number expected against
  9206.     cmp   pnum          ;     the number we got.
  9207.     bne   seofa1          ; If not identical, fail and return curr. state
  9208. seofa2: lda   #$00          ; Clear the number of tries for current packet
  9209.     sta   numtry          ;         ...
  9210.     jsr   incn          ; Up the packet sequence number
  9211.     jsr    clrfcb        ;[81] just in case we wildcd
  9212.     jsr   getnfl          ; Call the routine to get the next file
  9213. ;[81]    cmp   #eof          ; If it didn't find any more
  9214.     bne    seofrf        ;[59] no eof
  9215. ;[59]    beq   seofrb          ;     then return state 'B' ('Send-Eot')
  9216. ;[59]    jmp   seofrf          ; Otherwise, return 'F' ('Send-file')
  9217. seofrb: lda   #'B          ; Load Eot state code
  9218.     sta   state          ; Store that as the current state
  9219. ;[81]    lda   #true          ; Give a success on the return
  9220.     rts          ;         ...
  9221. seofrf: lda   #'F          ; Load File-header state code
  9222.     sta   state          ; Make that the current system state
  9223. ;[81]    lda   #true          ; Make success the return status
  9224. sflat3                ;[87]
  9225.     rts          ;     and return
  9226.  
  9227.  
  9228. sflatr                ;[87] send file attributes
  9229.     lda    numtry        ;[87]
  9230.     cmp    maxtry        ;[87] too much?
  9231.     blt    .+5        ;[87] no
  9232.     jmp    sini1a        ;[87] ugh
  9233.     inc    numtry        ;[87]
  9234.     jsr    sapar        ;[87]
  9235.     lda    #'A        ;[87] this is attribute pkt
  9236.     sta    ptype        ;[87] len is set in sapar
  9237.     lda    n        ;[87]
  9238.     sta    pnum        ;[87]
  9239.     jsr    spak        ;[87] send the pkt
  9240.     jsr    rpak        ;[87] and receive pkt
  9241.     beq    sflat3        ;[87] malo
  9242.     lda    ptype        ;[87] see what we got
  9243.     cmp    #'Y        ;[87]
  9244.     beq    .+5        ;[87] its an ack
  9245.     jmp    sinic1        ;[87] now what?
  9246.     lda    n        ;[87]
  9247.     cmp    pnum        ;[87] right pkt?
  9248.     bne    sflat3        ;[87] no
  9249.     jmp    sfila7        ;[87] Set state to 'Send-data'
  9250.  
  9251. ;[81]sini:    lda   #pdbuf\          ; Load the pointer to the
  9252. sini:    lda    #'S        ;[81]
  9253. sinio    sta    sinioo+1    ;[81] set type of init
  9254. ;[83]    lda   #pdbuf\          ; Load the pointer to the
  9255. ;[83]    sta   kerbf1          ;     packet buffer into its
  9256. ;[83]    lda   #pdbuf^          ;     place on page zero
  9257. ;[83]    sta   kerbf1+1      ;         ...
  9258.     jsr    sukrbf        ;[83] setup kerbf1
  9259.     lda    prtcl        ;[83]
  9260.     beq    sinio3        ;[83]
  9261.     jmp    sfil        ;[83] xmodem this way
  9262. sinio3                ;[83]
  9263.     jsr   spar          ; Go fill in the send init parms
  9264.     lda   numtry          ; If numtry > maxtry
  9265.     cmp   maxtry          ;         ...
  9266.     bmi    sini1b        ;[59] ok
  9267. ;[59]    beq   sini1          ;         ...
  9268. ;[59]    bcs   sini1a          ;     then we are in bad shape, go fail
  9269. ;[59]sini1:    jmp   sini1b          ; Otherwise, we just continue
  9270. sini1a: lda   #'A          ; Set state to 'abort'
  9271.     sta   state          ;         ...
  9272.     lda   #errmrc          ; Fetch the error index
  9273.     sta   errcod          ;     and store it as the error code
  9274.     lda   #$00          ; Set return status (AC) to fail
  9275.     rts          ; Return
  9276. sini1b: inc   numtry          ; Increment the number of tries for this packet
  9277. sinioo    lda   #'S          ; Packet type is 'Send-init'
  9278.     sta   ptype          ; Store that
  9279. ;[62]    lda   ebqmod          ; Do we want 8-bit quoting?
  9280. ;[62]    cmp   #on          ;         ...
  9281. ;[62]    beq   sini1c          ; If so, data length is 7
  9282. ;[72]    lda   #$06          ; Else it is 6
  9283. ;[72]    ldx    ebqmod        ;[62] is this 8 bit quoting?
  9284. ;[72]    beq    sini1d        ;[62] no
  9285. ;[62]    jmp   sini1d          ;         ...
  9286. ;[72]sini1c: lda   #$07          ; The length of data in a send-init is always 7
  9287. ;[72]sini1d: sta   pdlen          ; Store that parameter
  9288.     jsr    sparl        ;[72] set par length according to 8 bit q
  9289.     lda   n          ; Get the packet number
  9290.     sta   pnum          ; Store that in its common area
  9291.     jsr   spak          ; Call the routine to ship the packet out
  9292.     jsr   rpak          ; Now go try to receive a packet
  9293. ;[59]    sta   rstat          ; Hold the return status from that last routine
  9294. ;[83]    beq    sinicf        ;[59] bad packet how can we continue?
  9295.     beq    siniy9        ;[83] bad packet how can we continue?
  9296. sinics: lda   ptype          ; Case statement, get the packet type
  9297.     cmp   #'Y          ; Was it an ACK?
  9298. ;[59]    bne   sinic1          ; If not, try next type
  9299. ;[59]    jmp   sinicy          ; Go handle the ack
  9300.     beq    sinicy        ;[59] handle the ack
  9301. sinic1: cmp   #'N          ; Was it a NAK?
  9302. ;[59]    bne   sinic2          ; If not, try next condition
  9303. ;[59]    jmp   sinicn          ; Handle a nak
  9304.     beq    sinicn        ;[59] handle a nak
  9305. ;[59]sinic2: lda   rstat          ; Fetch the return status
  9306. ;[59]    beq    sinicf        ;[59] failure
  9307. ;[59]    cmp   #false          ; Was this, perhaps false?
  9308. ;[59]    bne   sinic3          ; Nope, do the 'otherwise' stuff
  9309. ;[59]    jmp   sinicf          ; Just go and return
  9310. sinic3: jsr   prcerp          ;[38] Check for error packet and process it
  9311.     beq    sinicf        ;[68] no try again
  9312.     lda   #'A          ; Set state to 'abort'
  9313.     sta   state          ;         ...
  9314.     lda    #false        ;[81]
  9315. sinicn:
  9316. ;[83]sinicf: rts          ; Return
  9317. sinicf: jmp    bperrc        ;[83] bump and print retries
  9318.  
  9319. ;[87]sinicy: ldy   #$00          ; Clear Y
  9320. sinicy:                ;[87]
  9321.     lda   n          ; Get packet number
  9322.     cmp   pnum          ; Was the ack for that packet number?
  9323.     beq   siniy1          ; Yes, continue
  9324. ;[83]    lda   #false          ; No, set false return status
  9325.     rts          ;     and go back
  9326. siniy1: jsr   rpar          ; Get parms from the ack packet
  9327. ;[72]    lda   sebq          ; Check if other Kermit agrees to 8-bit quoting
  9328. ;[72]    cmp   #'Y          ;         ...
  9329. ;[75]    lda    filmod        ;[72] is this text file?
  9330. ;[75]    beq    siniy4        ;[72] yes turn off ebq
  9331. ;[75]    lda    ebqmod        ;[72] did other kermit agree to ebq?
  9332. ;[75]    bne    siniy2        ;[72] yes were ok
  9333. ;[75]    jsr    u2s8b        ;[72] problems unable to send 8 bits
  9334. ;[75]siniy4    lda   #off          ; Shut it off
  9335. ;[75]    sta   ebqmod          ;         ...
  9336. ;[75]siniy2:
  9337. ;[81]siniy3: lda   #'F          ; Load code for 'Send-file' into AC
  9338. siniy3: lda    wcpres        ;[81] are we wildcd
  9339.     beq    siniy7        ;[81] no
  9340. ;[87]    lda    tl0end        ;[81] set up stack
  9341. ;[87]    sta    stack        ;[81]
  9342. ;[87]    lda    tl0end+1    ;[81]
  9343. ;[87]    sta    stack+1        ;[81]
  9344.     jmp    seofa2        ;[81]
  9345. siniy7    lda   #'F          ;[81] Load code for 'Send-file' into AC
  9346. siniy8                ;[87] common code
  9347.     sta   state          ; Make that the new state
  9348.     lda   #$00          ; Clear AC
  9349.     sta   numtry          ; Reset numtry to 0 for next send
  9350.     jsr   incn          ; Up the packet sequence number
  9351. ;[83]    lda   #true          ; Return true
  9352.     lda   #true          ;[84] Return true, needed for remote
  9353. siniy9                ;[83]
  9354.     rts
  9355.  
  9356. sbrk:    lda   numtry          ; Get the number of tries for this packet
  9357.     inc   numtry          ; Incrment it for next time
  9358.     cmp   maxtry          ; Have we exceeded the maximum
  9359.     bmi    sbrk1b        ;[59] no
  9360.     jmp    sini1a        ;[59] yes
  9361. ;[59]    beq   sbrk1          ; Not yet
  9362. ;[59]    bcs   sbrk1a          ; Yes, go abort the whole thing
  9363. ;[59]sbrk1:    jmp   sbrk1b          ; Continue send
  9364. ;[59]sbrk1a: lda   #'A          ; Load 'abort' code
  9365. ;[59]    sta   state          ; Make that the system state
  9366. ;[59]    lda   #errmrc          ; Fetch the error index
  9367. ;[59]    sta   errcod          ;     and store it as the error code
  9368. ;[59]    lda   #false          ; Load the failure return status
  9369. ;[59]    rts          ;     and return
  9370. sbrk1b: lda   #'B          ; We are sending an Eot packet
  9371.     sta   ptype          ; Store that as the packet type
  9372.     lda   n          ; Get the current sequence number
  9373.     sta   pnum          ; Copy in that parameter
  9374.     lda   #$00          ; The packet data length will be 0
  9375.     sta   pdlen          ; Copy that in
  9376.     jsr   spak          ; Go send the packet
  9377. sbrk2:    jsr   rpak          ; Try to get an ack
  9378. ;[83]    sta   rstat          ; First, save the return status
  9379.     beq    siniy9        ;[83] bad packet
  9380.     lda   ptype          ; Get the packet type received
  9381.     cmp   #'N          ; Was it a NAK?
  9382. ;[83]    bne   sbrk2a          ; If not, try for the ack
  9383. ;[83]    jmp   sbrkcn          ; Go handle the nak case
  9384.     beq   sbrkcn          ;[83] Go handle the nak case
  9385. sbrk2a: cmp   #'Y          ; An ACK?
  9386.     beq    sbrkca        ;[59] yes
  9387. ;[59]    bne   sbrk2b          ; If not, look at the return status
  9388. ;[59]    jmp   sbrkca          ; Go handle the case of an ack
  9389. sbrk2b: lda   rstat          ; Fetch the return status from Rpak
  9390. ;[59]    cmp   #false          ; Was it a failure?
  9391.     beq   sbrk2c          ; Yes, just return with current state
  9392.     jmp    sdat2p        ;[59] common routine
  9393. ;[59]    jsr   prcerp          ;[38] Check for error packet and process it
  9394. ;[59]    lda   #'A          ; Set up the 'abort' code
  9395. ;[59]    sta   state          ;     as the system state
  9396. ;[59]    lda   #false          ;     load the false return status
  9397. sbrk2c: rts          ;     and return
  9398. ;[69]sbrkcn: dec   pnum          ; Decrement the received packet number once
  9399. ;[69]    lda   n          ; Get the expected sequence number
  9400. ;[69]    cmp   pnum          ; If =pnum-1 then this nak is like an ack
  9401. sbrkcn: jsr    dpnum          ; [69]Decrement the received packet number once
  9402.     beq    sbrka2        ;[59]
  9403. ;[59]    bne   sbrkn1          ; No, this was no the case
  9404. ;[59]    jmp   sbrka2          ; Yes! Go do the ack, but skip sequence check
  9405. sbrka1:
  9406. ;[81]sbrkn1: lda   #false          ; Load failure return code
  9407. sbrkn1:           ;[81] Load failure return code
  9408. ;[83]    rts          ;     and go back
  9409.     jmp    bperrc        ;[83] bump and print retries
  9410. sbrkca: lda   n          ; Get the expected packet sequence number
  9411.     cmp   pnum          ; Did we get what we expected?
  9412.     bne   sbrka1          ; No, return failure with current state
  9413. ;[87]sbrka2: lda   #$00          ; Yes, clear number of tries for this packet
  9414. sbrka2:            ;[87]
  9415. ;[87]    sta   numtry          ;         ...
  9416. ;[87]    jsr   incn          ; Up the packet sequence number
  9417.     lda   #'C          ; The transfer is now complete, reflect this
  9418.     jmp    siniy8        ;[87] common code
  9419. ;[87]    sta   state          ;     in the system state
  9420. ;[87]    lda   #true          ; Return success!
  9421. ;[87]    rts          ;         ...
  9422.  
  9423. .SBTTL    Server mode
  9424.  
  9425. kicmd    lda    cmdctr        ;[81] have we given them
  9426.     cmp    cmdlen        ;[81] all the command?
  9427.     bcs    kicmd3        ;[81] yes
  9428.     ldx    cmdctr        ;[81] no give more of the cmd
  9429.     lda    cmdbuf,x    ;[81]
  9430.     ora    #$80        ;[81] make sure its neg ascii
  9431.     inc    cmdctr        ;[81] ready for next
  9432.     rts            ;[81]
  9433. kicmd3    lda    #hcr        ;[81] terminate it
  9434.     rts            ;[81]
  9435. kicout                ;[81]
  9436.     sty    kwrk01        ;[81] save
  9437.     ldy    pdlen        ;[81] send another ch?
  9438.     bne    kicou3        ;[81] no
  9439.     pha            ;[81]
  9440.     cmp    #hcr        ;[81] have more than the prompt?
  9441.     bne    kicou2        ;[81]
  9442.     inc    kicrct        ;[81] bump the cr count
  9443.     ldy    #2        ;[81]
  9444.     cpy    kicrct        ;[81] have we seen 3 or more?
  9445.     bcs    kicou2        ;[81] no
  9446.     ldy    #'E        ;[81] make it an error packet
  9447.     sty    ptype        ;[81]
  9448. kicou2    and    #$7f        ;[81] make it ascii
  9449.     jsr    ctrlch        ;[81] put it in com buffer
  9450.     bcc    kicou7        ;[81] are we full, no
  9451. kicou5    inc    pdlen        ;[81] tattle, no more
  9452.     bne    kicou9        ;[81]
  9453. kicou7    lda    addlf        ;[81]
  9454.     beq    kicou9        ;[81] do we need to add a lf, no
  9455.     lda    #lf        ;[81] yes
  9456.     jsr    ctrlch        ;[81]
  9457.     bcs    kicou5        ;[81]
  9458.     lda    #0        ;[81] turn off lf flag
  9459.     sta    addlf        ;[81]
  9460. kicou9    pla            ;[81]    
  9461. kicou3    ldy    kwrk01        ;[81] restore
  9462.     rts            ;[81] thats all folks
  9463. servre    ldy    #0        ;[81]
  9464. servr3    lda    erms1h,y    ;[81]
  9465.     beq    servr7        ;[81] all thru? yes
  9466.     and    #$7f        ;[81] make it ascii
  9467.     sta    pdbuf,y        ;[81] return the error to remote
  9468.     iny            ;[81]
  9469.     bne    servr3        ;[81]
  9470. servr7    lda    ptype        ;[81]
  9471.     sta    pdbuf,y        ;[81] finish error
  9472.     iny            ;[81] tell how many
  9473.     sty    pdlen        ;[81]
  9474.     lda    #'E        ;[81] make it an error packet
  9475.     sta    ptype        ;[81]
  9476.     jmp    sercm7        ;[81]
  9477. sercmd    ldy    pdlen        ;[81] get length of this cmd
  9478.     sty    cmdlen        ;[81] and save it
  9479.     beq    sercm3        ;[81] just in case its null
  9480. sercm2    lda    pdbuf-1,y    ;[81] now save the remote cmd
  9481.     sta    cmdbuf-1,y    ;[81]
  9482.     dey            ;[81]
  9483.     bne    sercm2        ;[81] thru? no
  9484. sercm3    sty    cmdctr        ;[81] start with 0
  9485.     sty    pdlen        ;[81]
  9486.     sty    datind        ;[81]
  9487.     sty    kicrct        ;[81]
  9488.     ldx    #kicout\    ;[81] place for cout to come
  9489.     ldy    #kicout^    ;[81]
  9490.     jsr    svcout        ;[81] interupt cout & save current on stack
  9491.     ldx    #kicmd\        ;[81] place for cmd to come for instructions
  9492.     ldy    #kicmd^        ;[81]
  9493.     jsr    svcmd        ;[81]
  9494.     lda    kermit        ;[81] now to interupt kermit return
  9495.     pha            ;[81]
  9496.     lda    #$ea        ;[81] a nop
  9497.     sta    sercm5        ;[81] the first time only
  9498.     lda    #'Y        ;[81] return a ack
  9499.     sta    ptype        ;[81]
  9500.     ldx    #prmt\        ;[81] first instruction of kermit
  9501.     ldy    #prmt^        ;[81]     for Comnd routines
  9502.     lda    #cmini        ;[81] Argument for comnd call
  9503.     jsr    comnd        ;[81] Set up the parser and print the prompt
  9504. sercm5    nop            ;[81]
  9505.     lda    #$60        ;[81] a rts
  9506.     sta    kermit        ;[81] hope this works
  9507.     sta    sercm5        ;[81] turn error rtn into a rts
  9508.     jsr    kermt0        ;[81] go do the command
  9509.     pla            ;[81] should rtn here when thru
  9510.     sta    kermit        ;[81] restore kermit to normal
  9511.     jsr    rscmd        ;[81] restore cmd reader
  9512.     jsr    rscout        ;[81] restore cout
  9513.     lda    datind        ;[81] tell how many
  9514.     sta    pdlen        ;[81]
  9515. sercm7    jsr    spak        ;[81] send it down the line
  9516.     jmp    servel        ;[81] around we go again
  9517.  
  9518. ;[81]server    jsr    tlinit        ;[62] initilize the com card
  9519. ;[81]    bne    serve9        ;[62] unable to use the com port
  9520. ;[81]    jsr    u2icc        ;[62] tattle
  9521. ;[81]    jmp    sallt1        ;[62]
  9522. ;[81]serve9                ;[62]
  9523. server    jsr    comint        ;[81] common com init
  9524.     jsr    kerin7        ;[78] just in case were reading kermit.ini
  9525.     jsr    home        ;[62] make it look nice
  9526.     ldx    #shsm01\    ;[75[ tell whats going on
  9527.     ldy    #shsm01^    ;[75]
  9528.     jsr    prstr        ;[75]
  9529.     lda    #on        ;[62] set server mode flag on
  9530.     sta    servef        ;[62]
  9531.     sta    usehdr        ;[62] use paacket info
  9532. servel    lda   #$00          ;[62] Zero the packet sequence number
  9533.     sta   n          ;[62]         ...
  9534.     sta    exfg        ;[75] use classic packets
  9535.     lda    maxtry        ;[62] back down for test
  9536.     sta   numtry          ;[62]     Number of tries
  9537.     sta    state        ;[62] initilize  so we can get debug info
  9538. sltry    jsr    telck        ;[62] a keyboard ch?
  9539.     beq    sltry2        ;[62] no
  9540.     jsr    rdkey        ;[62] yes get it
  9541.     cmp    #$83        ;[62] is it ^c ?
  9542.     beq    sallt2        ;[62] yes quit
  9543. sltry2    jsr    srini        ;[62] get a packet
  9544.     beq    sltry        ;[62] no good try again
  9545.     lda    ptype        ;[62] what packet did we get
  9546.     cmp    #'K        ;[81] is this a kermit cmd?
  9547.     bne    .+5        ;[81] hate to do this
  9548.     jmp    sercmd        ;[81] yes here comes a command
  9549.     cmp    #'S        ;[62] is this a send?
  9550.     beq    swfaf        ;[62] yes here comes a file
  9551.     cmp    #'R        ;[62] is this a get?
  9552.     beq    sstf        ;[62] yes send the file
  9553.     cmp    #'E        ;[62] an error packet?
  9554.     beq    sepkt        ;[62] tattle
  9555.     cmp    #'G        ;[62] perhaps were thru
  9556.     beq    swmbt        ;[62] maybe
  9557.     cmp    #'B        ;[62] how about a break
  9558.     bne    .+5        ;[62] hate to do this
  9559.     jmp    sallth        ;[62] yes were all thru
  9560.     cmp    #'I        ;[62] how about initilize
  9561.     beq    serint        ;[62] yes
  9562.     cmp    #'Y        ;[81] how about a ack
  9563.     beq    sltry        ;[81] yes just ignore it for now
  9564.     cmp    #'N        ;[81] how about a nak
  9565.     beq    sltry        ;[81] yes just ignore it for now
  9566.     pha            ;[62] save the error character
  9567.     ldx    #erms1h\    ;[62] tell about server command
  9568.     ldy    #erms1h^    ;[62]
  9569.     jsr    prstr        ;[62]
  9570.     pla            ;[62] now print the character
  9571. ;[79]    jsr    prchr        ;[62] handle cntl chs also
  9572. ;[79]    jsr    prcrlf        ;[62] and end the line
  9573.     jsr    prchrr        ;[79] cntl chs & crlf
  9574. ;[81]    lda    ptype        ;[62] what packet did we get
  9575. ;[81]    cmp    #'Y        ;[62] how about a ack
  9576. ;[81]    beq    sltry        ;[62] yes just ignore it for now
  9577. ;[81]    cmp    #'N        ;[62] how about a nak
  9578. ;[81]    beq    sltry        ;[62] yes just ignore it for now
  9579.     jmp    servre        ;[81] return the error
  9580. sallt2    lda    #off        ;[62] turn server mode off
  9581.     sta    servef        ;[62]
  9582.     jsr    bell        ;[62] wake up
  9583.     jsr    home        ;[62] make it look nice
  9584. sallt1                ;[62]
  9585.     .ifeq    termnl        ;[63]
  9586.     lda    confg        ;[78]
  9587.     sta    flowfg        ;[78] restore flow controll
  9588.     jsr    sutljp        ;[85] set up screen distributor
  9589.     jmp    ch0lup        ;[63] and return to where we came from
  9590.     .endc            ;[63]
  9591.     .ifne    termnl        ;[63]
  9592.     jmp    kermit        ;[62] exit server mode
  9593.     .endc            ;[63]
  9594. serint
  9595.     jsr    rinici        ;[62] nice rtn
  9596.     lda    oldtry        ;[62] got to save this
  9597.     sta    numtry        ;[62]
  9598.     jmp    sltry        ;[62] around we go again
  9599. swfaf    jsr    rswt        ;[62] hope this works
  9600.     .ifeq    termnl        ;[63]
  9601.     jmp    sallt2        ;[63] in terminal we are thru
  9602.     .endc            ;[63]
  9603.     .ifne    termnl        ;[63]
  9604.     jmp    servel        ;[62] around we go again
  9605.     .endc            ;[63]
  9606. sstf    jsr    clrfcb        ;[66] clear fcb
  9607.     jsr    sfilec        ;[81] index of lines in catalog
  9608.     ldy    #0        ;[62] move file name to fcb1
  9609.     sty    wcpres        ;[81]
  9610. sstf1    lda    (kerbf1),y    ;[62] get ch of filename
  9611.     sta    fcb1,y        ;[62] and set it up for open
  9612.     cmp    #wcmult        ;[81]
  9613.     beq    sstf7        ;[81] wildcd present
  9614.     cmp    #wcsing        ;[81]
  9615.     bne    sstf8        ;[81] no
  9616. sstf7    sta    wcpres        ;[81] tatle about wildcd present
  9617. sstf8    jsr    convuc        ;[81] convert to upper case
  9618.     sta    patbuf,y    ;[81] just in case
  9619.     iny            ;[62] now for the next
  9620.     cpy    pdlen        ;[62] are we thru?
  9621.     bne    sstf1        ;[62] well soon know
  9622.     sty    nfcb1        ;[62] set count of chs in fcb1
  9623.     sty    patl        ;[81] pattern length also
  9624.     jsr    sswt        ;[62] hope hope
  9625.     .ifeq    termnl        ;[63]
  9626.     jmp    sallt2        ;[63] in terminal we are thru
  9627.     .endc            ;[63]
  9628.     .ifne    termnl        ;[63]
  9629.     jmp    servel        ;[62] around we go again
  9630.     .endc            ;[63]
  9631. sepkt    jsr    prcerp        ;[62] process error packet
  9632.     .ifeq    termnl        ;[63]
  9633.     jmp    sallt2        ;[63] in terminal we are thru
  9634.     .endc            ;[63]
  9635.     .ifne    termnl        ;[63]
  9636.     jmp    servel        ;[62] around we go again
  9637.     .endc            ;[63]
  9638. swmbt    ldy    #0        ;[62] only way to do indirect
  9639.     lda    (kerbf1),y    ;[62] get first data ch
  9640.     cmp    #'L        ;[62] are we thru
  9641.     beq    sallth        ;[62] yes
  9642.     cmp    #'F        ;[62] maybe
  9643.     beq    sallth        ;[62] yes
  9644.     pha            ;[62] save the unknown operand
  9645.     ldx    #erms1i\    ;[62] tell about unknown operand
  9646.     ldy    #erms1i^    ;[62]
  9647.     jsr    prstr        ;[62]
  9648.     pla        ;[62] now for the offending ch
  9649. ;[79]    jsr    prchr    ;[62] handle cntl chs
  9650. ;[79]    jsr    prcrlf        ;[62] end the line
  9651.     jsr    prchrr        ;[79] cntl chs & crlf
  9652.     jmp    kermit        ;[62] and stop server
  9653. sallth    lda    #'Y        ;[62] now to send an ack
  9654.     sta    ptype        ;[62]
  9655.     lda    #0        ;[62] set the len
  9656.     sta    pdlen        ;[62] of the packet
  9657.     jsr    spak        ;[62] send the packet
  9658.     jmp    sallt2        ;[62] thats all
  9659. ;[83]srini    lda   #pdbuf\          ;[62] Point kerbf1 at the packet data buffer
  9660. ;[83]    sta   kerbf1          ;[62]         ...
  9661. ;[83]    lda   #pdbuf^          ;[62]         ...
  9662. ;[83]    sta   kerbf1+1      ;[62]         ...
  9663. srini    jsr    sukrbf        ;[83] setup kerbf1
  9664.     dec   numtry          ;[62] 
  9665.     bne    srini2          ;[62] Have we tried this one enought times
  9666.     lda   #errcri          ;[62] Fetch the error index
  9667.     sta   errcod          ;[62]     and store it as the error code
  9668.     jmp    stat07        ;[62] Tell somebody unable to communicate
  9669. srini2:    jsr   rpak          ;[62] Go try to receive a packet
  9670.     beq   srini3      ;[62] ok since false is 0
  9671.     rts        ;[62]
  9672. srini3: lda   n          ;[62] Get packet sequence number expected
  9673.     sta   pnum          ;[62] Stuff that parameter at the Nakit routine
  9674.     jsr   nakit          ;[62] Go send the Nak
  9675. ;[81]    lda   #false          ;[62] Load AC with false status
  9676.     rts          ;[62]     and go back
  9677.  
  9678. .SBTTL Modem routine        ;
  9679.  
  9680. modem    jsr    kerin7        ;[78] just in case were reading kermit.ini
  9681.     jsr    clrfcb        ;[78] dos needs this
  9682.     ldy    #dialms-dialnm-1 ;[78] now for the size of the file name - null
  9683.     sty    nfcb1        ;[78]
  9684. dial2    lda    dialnm-1,y    ;[78] now move the file name to fcb1
  9685.     sta    fcb1-1,y    ;[78]
  9686.     dey            ;[78]
  9687.     bne    dial2        ;[78] are we thru? no
  9688.     jsr    prcrlf        ;[78]
  9689.     ldx    #dialms\    ;[78] tell what
  9690.     ldy    #dialms^    ;[78] were going to do
  9691.     jsr    prstr        ;[78]
  9692.     ldx    #dialnm\    ;[78] now for the
  9693.     ldy    #dialnm^    ;[78] file name
  9694. ;[79]    jsr    prstr        ;[78]
  9695. ;[79]    jsr    prcrlf        ;[78]
  9696.     jsr    prstrl        ;[79]
  9697.     jsr    opentf        ;[78] save current and open text file
  9698.     ldx    #pdbuf\        ;[78] if we get here its a good open
  9699.     ldy    #pdbuf^        ;[78] hope theres enough room
  9700.     stx    cminf1        ;[78]
  9701.     sty    cminf1+1    ;[78]
  9702. dial3    jsr    home        ;[78] clear screen for choice
  9703.     ldx    #dials\        ;[78] tell options
  9704.     ldy    #dials^        ;[78]
  9705. ;[79]    jsr    prstr        ;[78] at top of screen
  9706. ;[79]    jsr    prcrlf        ;[78]
  9707.     jsr    prstrl        ;[79]
  9708.     ldy    #0        ;[78] start things out 
  9709.     sty    kwrk01        ;[78] at 0
  9710. ;[85]    sty    kwrk02        ;[78]
  9711. ;[85]dial5    lda    kwrk02        ;[78] print the
  9712.     sty    wchpat        ;[85] hope we dont use this one
  9713. dial5    lda    wchpat        ;[85] print the
  9714.     jsr    prhex        ;[78] index
  9715.     lda    #0        ;[78] flag for start of comments
  9716.     sta    chksum        ;[78]
  9717.     lda    #':+$80        ;[78]
  9718.     jsr    cout        ;[78] nicely
  9719. dial7    jsr    fgetc        ;[78] get a ch from file
  9720.     jmp    dialef        ;[78] got a eof
  9721.     ora    #$80        ;[78] make it nasc
  9722.     jsr    cout        ;[78] on the screen
  9723.     cmp    #hcr        ;[78] eol ?
  9724.     beq    dial4        ;[78] that always get entered
  9725.     ldx    chksum        ;[78] have we seen the begining of comments?
  9726.     bne    dial7        ;[78] yes dont enter in table
  9727.     cmp    #hspace        ;[78] no, is this start of comments?
  9728.     bne    dial4        ;[78] no
  9729.     sta    chksum        ;[78] yes turn flag on
  9730.     jmp    dial7        ;[78] and dont enter into table
  9731. dial4    ldy    kwrk01        ;[78] index into buffer
  9732.     sta    (cminf1),y    ;[78]
  9733.     inc    kwrk01        ;[78] ready for next
  9734.     bne    dial8        ;[78] are we > 256? no
  9735.     inc    cminf1+1    ;[78] yes next page
  9736. dial8    cmp    #hcr        ;[78] end of line
  9737.     bne    dial7        ;[78] no
  9738. ;[85]    inc    kwrk02        ;[78] bump line counter
  9739.     inc    wchpat        ;[85] bump line counter
  9740.     lda    #pdbuf+257^    ;[78] limit of 512 bytes or so
  9741.     cmp    cminf1+1    ;[78] some test huh
  9742.     bcc    dialef        ;[78] enough already
  9743.     lda    #10        ;[78] only print 10 at a time
  9744. ;[85]    cmp    kwrk02        ;[78]
  9745.     cmp    wchpat        ;[85]
  9746.     bne    dial5        ;[78] get the next line
  9747. dialef    jsr    bell        ;[78] get someones attention
  9748.     jsr    rdkey        ;[78] get users option
  9749.     and    #$7f        ;[78] make it ascii
  9750.     ora    #$20        ;[78] make it lower case
  9751.     cmp    #'m        ;[78] want more?
  9752.     beq    dial3        ;[78] yes
  9753.     cmp    #'q        ;[78] want to quit?
  9754.     bne    dial27        ;[78] no
  9755.     jmp    dialc        ;[78] yes only way to reach this
  9756. dial27    sec            ;[78] make it binary
  9757.     sbc    #'0        ;[78] try for numbers
  9758. dial9                ;[78]
  9759. ;[85]    cmp    kwrk02        ;[78] is this a legal option?
  9760.     cmp    wchpat        ;[85] is this a legal option?
  9761.     bcs    dialef        ;[78] no
  9762.     sta    kwrk01        ;[78] save the users option
  9763.     jsr    clostf        ;[78] close file and restore filmod
  9764. ;[81]    jsr    tlinit        ;[78] initialize the serial port
  9765. ;[81]    bne    dial17        ;[78] ok
  9766. ;[81]    jsr    u2icc        ;[78] tell we cant
  9767. ;[81]    jmp    kermit        ;[78] thats all
  9768.     jsr    comint        ;[81] common com init
  9769. dial17    ldy    #0        ;[78] now for the search
  9770.     sty    chksum        ;[78] this will be the line counter
  9771.     sty    match        ;[85] 0 esc ch seen flag
  9772.     ldx    #pdbuf\        ;[84]
  9773.     stx    cminf1        ;[84] reset start of array
  9774.     ldx    #pdbuf^        ;[78]
  9775.     stx    cminf1+1    ;[78] reset start of array
  9776.     ldx    kwrk01        ;[78] users choice
  9777. dial11    cpx    chksum        ;[78] current line?
  9778.     beq    dial13        ;[78] yes dial it
  9779. dial12    lda    (cminf1),y    ;[78] search for next line
  9780.     iny            ;[78] ready for next ch
  9781.     bne    dial14        ;[78]
  9782.     inc    cminf1+1    ;[78] next page
  9783. dial14    cmp    #hcr        ;[78] eol ?
  9784.     bne    dial12        ;[78] no
  9785.     inc    chksum        ;[78] yes
  9786.     jmp    dial11        ;[78] try this one
  9787. dial13    sty    chksum        ;[78] this is the start of the line
  9788.     lda    (cminf1),y    ;[78] get ch for modem
  9789.     ldx    match        ;[85] have we seen esc ch?
  9790.     bne    modmeo        ;[85] yes take this ch asis & shut off flg
  9791.     cmp    #'\+$80        ;[85] is this esc ch?
  9792.     bne    modmnp        ;[85] no
  9793.     sta    match        ;[85] yes set flg on
  9794.     beq    dial24        ;[85] and skip this ch
  9795. modmnp                ;[85] carry on
  9796. ;[80]    cmp    #'*+$80        ;[78] is this a delay?
  9797.     cmp    #'&+$80        ;[80] is this a delay?
  9798.     bne    dial23        ;[78] no
  9799.     lda    #8        ;[78] yes wait for 1 sec
  9800.     sta    kwrk01        ;[78] ans to 16 bit problem
  9801. ;[82]dial22    lda    #220        ;[78] just a we bit more than 250
  9802. dial22    lda    #125        ;[82]
  9803.     sta    kwrk02        ;[82]
  9804. dial18    jsr    telcp        ;[82] for non interupt drivers
  9805. ;[85]    lda    #17        ;[82] 1 ms at a time
  9806.     lda    timect        ;[85] 1 ms at a time
  9807. ;[82]    jsr    wait        ;[78] wait for 255 ms, destroys x reg
  9808.     jsr    wait        ;[82]
  9809.     dec    kwrk02        ;[82] are we thru
  9810.     bne    dial18        ;[82] no
  9811.     dec    kwrk01        ;[78]
  9812.     bne    dial22        ;[78] rest of the second
  9813. ;[82]    jmp    dial24        ;[78] now dont tell modem
  9814.     beq    dial24        ;[82] now dont tell modem
  9815. modmeo    ldx    #0        ;[85] turn esc flg off
  9816.     stx    match        ;[85] and process this ch
  9817. ;[82]dial23    jsr    telppc        ;[78] send it down the line
  9818. dial23    and    #$7f        ;[82] make it ascii, telppc need it this way
  9819.     pha            ;[82] save it
  9820.     jsr    telppc        ;[82] send it down the line
  9821.     pla            ;[82] restore it
  9822. ;dial25    jsr    modmsr        ;[78]
  9823. dial24    ;jsr    cout        ;[78] print it
  9824.     ldy    chksum        ;[78] get it again
  9825.     iny            ;[78]
  9826.     bne    dial20        ;[78]
  9827.     inc    cminf1+1    ;[78] next page
  9828. ;[82]dial20    cmp    #hcr        ;[78] end of line?
  9829. dial20    cmp    #cr        ;[82] end of line?
  9830.     bne    dial13        ;[78] no send another
  9831.     lda    #0        ;[78]
  9832. ;[85]    ldx    #4        ;[78]
  9833.     ldx    #lmodmc-1    ;[85]
  9834. modm19    sta    modmwc,x    ;[78] flag for messages
  9835.     dex            ;[78]
  9836.     bpl    modm19        ;[78] 
  9837.     sta    ksavex        ;[78] index into connect message
  9838. dial19    jsr    modmsr        ;[78] now whats the response
  9839.     beq    modm12        ;[78] no more chs
  9840.     jsr    cout        ;[78]
  9841.     jmp    dial19        ;[78] around we go again
  9842. modm12                ;[78]
  9843.     lda    modmwc        ;[78] did we see a connect
  9844.     beq    dialjp        ;[78] no, now go to  loop
  9845. ;[85]    jmp    telne3        ;[78] so do the connect
  9846.     jsr    telcom        ;[85] now we connect
  9847.     jmp    ch0lup        ;[85]
  9848. dialjp    jsr    opentf        ;[78] save current and open text file
  9849.     jmp    dialef        ;[78] and give another chance
  9850. dialc    jsr    clostf        ;[78] close file and restore filmod
  9851.     jmp    kermit        ;[78]
  9852. ;[85]modmsr    ldy    #8        ;[78] timing loop about 1 sec
  9853. modmsr    ldy    #3        ;[85] timing loop about 375 ms
  9854. ;[85]    ldx    #4        ;[78] number of responses -1
  9855.     ldx    #lmodmc-1    ;[85] number of responses -1
  9856.     lda    #0        ;[78] were going to see if we got any
  9857. modm02    ora    modmwc,x    ;[78]
  9858.     dex            ;[78]
  9859.     bpl    modm02        ;[78] look at all 5
  9860.     tax            ;[78] so we can see if its non 0
  9861.     bne    modm4        ;[78] yes so dont wait so long ~ 1 sec
  9862. ;[86]    ldy    #200        ;[78] about 25 sec?
  9863.     ldy    #240        ;[86] about 30 sec?
  9864. modm4    sty    kwrk01        ;[78] 1 or 25 seconds
  9865. modm20    lda    kbd        ;[78] any ch gets us out
  9866.     bpl    modm21        ;[78]
  9867.     bit    kbdstr        ;[78] off with the strobe
  9868.     jsr    telppc        ;[78] wake up the modem
  9869.     lda    #false        ;[78] thats all
  9870.     rts            ;[78]
  9871. modm21    jsr    telcp        ;[78]
  9872.     bne    modm23        ;[78] wait for next
  9873. ;[82]    lda    #220        ;[78] wait 125 ms
  9874.     lda    #125        ;[82] wait 125 ms
  9875. ;[83]    sta    kwrk02        ;[82]
  9876.     sta    kertpc        ;[83]
  9877. ;[85]modm22    lda    #17        ;[82] 1 ms at a time
  9878. modm22    lda    timect        ;[85] 1 ms at a time
  9879.     jsr    wait        ;[78]
  9880.     jsr    telcp        ;[82] for non interupt drivers
  9881.     bne    modm23        ;[82] wait for next?, got one
  9882. ;[83]    dec    kwrk02        ;[82] all 125 ms?
  9883.     dec    kertpc        ;[83] all 125 ms?
  9884.     bne    modm22        ;[82] no
  9885.     dec    kwrk01        ;[78]
  9886.     bne    modm20        ;[78]
  9887.     rts            ;[78] false return
  9888. modm23    jsr    telgpc        ;[78]
  9889.     ora    #$80        ;[78]
  9890.     ldx    ksavex        ;[78]
  9891. modm30    cmp    modmco,x    ;[78]
  9892.     beq    modm33        ;[78] yes we have a hit
  9893.     tay            ;[78] save our ch
  9894.     txa            ;[78] now see if were odd
  9895.     ror    a        ;[78]
  9896.     bcs    modm39        ;[78] yes we best start over from the top
  9897.     tya            ;[78] no lets try next response
  9898.     inx            ;[78]
  9899.     inx            ;[78]
  9900. ;[85]    cpx    #8        ;[78] have we looked at all?
  9901. ;[85]b    bcc    modm30        ;[78] no try next entry
  9902.     cpx    #lmodmc*2    ;[85] have we looked at all?
  9903.     blt    modm30        ;[85] no try next entry
  9904. modm31    ldx    #0        ;[78] ready for next ch
  9905.     stx    ksavex        ;[78]
  9906.     ldx    #true        ;[78] tell we have a ch
  9907.     rts            ;[78]
  9908. modm33    tay            ;[78] save the response ch
  9909.     txa            ;[78] see if were odd
  9910.     clc            ;[78]
  9911.     ror    a        ;[78]
  9912.     bcc    modm37        ;[78] no
  9913.     tax            ;[78] this should be
  9914.     tya            ;[78] index into resonse array
  9915.     sta    modmwc,x    ;[78] response ch should be non 0
  9916.     jmp    modm31        ;[78] and get ready for next
  9917. modm37    inx            ;[78]
  9918.     stx    ksavex        ;[78] ready for next ch in array
  9919.     tya            ;[78] restore response ch
  9920.     rts            ;[78] and return it
  9921. modm39    ldx    #0        ;[78] restart the array search
  9922.     stx    ksavex        ;[78]
  9923.     tya            ;[78] restore the ch
  9924.     jmp    modm30        ;[78]
  9925.  
  9926. .SBTTL Catalog routine        ;[78]
  9927.  
  9928. ;[80]catrtn    ldx    catsz        ;[78]
  9929. catrtn    jsr    prcrlf        ;[80] basic sys fouls up everyother ch
  9930.     ldx    catsz        ;[78]
  9931.     lda    #hcr        ;[78] terminate it
  9932.     sta    getln,x        ;[78]
  9933. catloo    lda    catsz,x        ;[78] move command
  9934.     sta    getln-1,x    ;[78] to get line for basic.system
  9935.     dex            ;[78]
  9936.     bne    catloo        ;[78]
  9937.     jsr    pbasic+3    ;[78] let basic system put out catalog
  9938. ;[81]    jmp    kermit        ;[78]
  9939.     jmp    catext        ;[81] common return so we can jsr to it
  9940. catlog    lda    dosflg        ;[78] is this prodos?
  9941.     bne    catrtn        ;[78] yes dont know how to do this yet
  9942.     lda    #fnccat        ;[78] the catalog command
  9943.     jsr    initfm        ;[78] initialize the dos file manager & do it
  9944. ;[81]    jmp    kermit        ;[78] thats all
  9945. catext    jmp    kermit        ;[81] thats all
  9946.  
  9947. initpo    ldy    #$60        ;[84] init the parameters only
  9948.     sty    initf3        ;[84] a rts
  9949.     bne    initf1        ;[84] common code
  9950. ;[84]initfm    pha            ;[78] save the command
  9951. initfm    ldy    #$ae        ;[84] this will call the file manager
  9952.     sty    initf3        ;[84] a ldx
  9953. initf1    pha            ;[84] save the command
  9954.     jsr    dosfmi        ;[78] initialize dos 3.3
  9955.     sty    cminf1        ;[78] save the parameter table address in page 0
  9956.     sta    cminf1+1    ;[78]
  9957.     ldy    #0        ;[78] index into parameter table
  9958.     pla            ;[78] get the command
  9959.     sta    (cminf1),y    ;[78] put it in byte 0 of parameter table
  9960.     ldy    #2        ;[86] new name slot
  9961.     lda    #getln\        ;[86]
  9962.     sta    (cminf1),y    ;[86]
  9963.     iny            ;[86]
  9964.     lda    #getln^        ;[86]
  9965.     sta    (cminf1),y    ;[86]
  9966.     ldy    #4        ;[78] ofset for vol
  9967.     lda    defvol        ;[78] get default vol
  9968.     sta    (cminf1),y    ;[78]
  9969.     iny            ;[78]
  9970.     lda    defdrv        ;[78] get default drive
  9971.     sta    (cminf1),y    ;[78]
  9972.     iny            ;[78]
  9973.     lda    defslt        ;[78] get default slot
  9974.     sta    (cminf1),y    ;[78]
  9975. ;[84]    ldy    #8        ;[78] now for the file name address
  9976.     iny            ;[84]
  9977.     lda    filmod        ;[84] set up file-type
  9978.     sta    (cminf1),y    ;[84]
  9979.     iny            ;[84]
  9980. ;[84]    lda    #getln+7\    ;[78] we put the file name in getln
  9981.     lda    #fcb1\        ;[84] we put the file name in fcb1
  9982.     sta    (cminf1),y    ;[78]
  9983.     iny            ;[78]
  9984. ;[84]    lda    #getln+7^    ;[78]
  9985.     lda    #fcb1^        ;[84]
  9986.     sta    (cminf1),y    ;[78]
  9987.     ldy    #$c        ;[78] now for a work area
  9988.     lda    #buffer+512\    ;[78] lets use the prodos buffer 45 bytes
  9989.     sta    (cminf1),y    ;[78]
  9990.     iny            ;[78]
  9991.     lda    #buffer+512^    ;[78]
  9992.     sta    (cminf1),y    ;[78]
  9993.     iny            ;[78] work area for track/sector list
  9994.     lda    #buffer\    ;[78] 256 byte part of the prodos buffer
  9995.     sta    (cminf1),y    ;[78]
  9996.     iny            ;[78]
  9997.     lda    #buffer^    ;[78]
  9998.     sta    (cminf1),y    ;[78]
  9999.     iny            ;[84] now for a work area
  10000.     lda    #buffer+256\    ;[84] lets use the prodos buffer 256 bytes
  10001.     sta    (cminf1),y    ;[84]
  10002.     iny            ;[84]
  10003.     lda    #buffer+256^    ;[84]
  10004.     sta    (cminf1),y    ;[84]
  10005. initf3    ldx    doscmi        ;[84] now for the type of open
  10006.     jsr    dosfmg        ;[78] now do the command
  10007.     bcc    initf7        ;[84] error?
  10008.     jmp    nonftl        ;[84] yes
  10009. initf7                ;[84]
  10010.     rts            ;[78]
  10011.  
  10012. .SBTTL    Lock file routine    ;[86]
  10013.  
  10014. lock    lda    #fnclck        ;[86] dos cmd to lock file
  10015.     ldx    #locksz\    ;[86] where name is
  10016.     ldy    #locksz^    ;[86]
  10017.     jmp    cmnfle        ;[86] common code
  10018.     
  10019.  
  10020. .SBTTL    Unlock file routine    ;[86]
  10021.  
  10022. unlock    lda    #fnculk        ;[86] dos cmd to unlock file
  10023.     ldx    #unlksz\    ;[86] where name is
  10024.     ldy    #unlksz^    ;[86]
  10025.     jmp    cmnfle        ;[86] common code
  10026.     
  10027.  
  10028. .SBTTL    Rename file routine    ;[86]
  10029.  
  10030. rename    lda    #fncren        ;[86] dos cmd to rename file
  10031.     ldx    #renmsz\    ;[86] where name is
  10032.     ldy    #renmsz^    ;[86]
  10033.     jmp    cmnfle        ;[86] common code
  10034.     
  10035. .SBTTL    Delete file routine
  10036.  
  10037. delprd    ldx    delsz        ;[78]
  10038. delloo    lda    delsz,x        ;[78] move command
  10039.     sta    getln-1,x    ;[78] to get line for basic.system
  10040.     dex            ;[78]
  10041.     bne    delloo        ;[78]
  10042.     jsr    pbasic+3    ;[78] let basic do it
  10043. delcom    bcc    delrtn        ;[78] its ok
  10044.     ldx    #erms19\    ;[78]
  10045.     ldy    #erms19^    ;[78]
  10046. kermtx    jsr    prstr        ;[78]
  10047. delrtn    jmp    kermit        ;[78] around we go again
  10048.  
  10049. ;[86]deletf    jsr    kerin7    ;[78] just in case were reading kermit.init
  10050. deletf    lda    #fncdel        ;[86] dos cmd to delete file
  10051.     ldx    #delsz\        ;[86] where the name is
  10052.     ldy    #delsz^        ;[86]
  10053. cmnfle    sta    cmncmd+1    ;[86] save the dos cmd
  10054.     stx    delprd+1    ;[86] and where the name is
  10055.     sty    delprd+2    ;[86]
  10056.     stx    delloo+1    ;[86]
  10057.     sty    delloo+2    ;[86]
  10058.     jsr    kerin7        ;[86] just in case were reading kermit.init
  10059.     ldx    #70        ;[78] got to
  10060.     lda    #hcr        ;[78] terminate it with return
  10061.     sta    getln,x        ;[78]
  10062.     lda    #hspace        ;[78] blank out getln for dos & prodos
  10063. delet1    sta    getln-1,x    ;[78]
  10064.     dex            ;[78]
  10065.     bne    delet1        ;[78]    
  10066. ;[86]    ldx   #mxfnl          ;[78] Longest length a filename may be
  10067. ;[86]    lda    dosflg        ;[78] prodos?
  10068. ;[86]    beq    .+4        ;[78] no
  10069. ;[86]    ldx    #mxppth        ;[78] max path length
  10070. ;[86]    ldy   #$00          ;[78] No special flags needed
  10071. ;[86]    lda   #cmifi          ;[78] Load opcode for parsing input files
  10072.     jsr    preptx        ;[86]
  10073.     jsr   comnd          ;[78] Call comnd routine
  10074.     jmp    kermt6          ;[78] Give the 'missing filespec' error
  10075.     sta   kwrk01          ;[78] Store length of file parsed
  10076.     stx   kerfrm          ;[78] Save the from address (addr[atmbuf])
  10077.     sty   kerfrm+1        ;[78]         ...
  10078.     lda   #getln+7\          ;[78] set the to address 
  10079.     ldx    #getln+7^    ;[84]
  10080.     ldy    dosflg        ;[84] prodos?
  10081.     bne    delet3        ;[84] yes
  10082.     jsr    clrfcb        ;[84] dos needs fcb1 cleared
  10083.     lda    #fcb1\        ;[84] dos place for file name
  10084.     ldx    #fcb1^        ;[84]
  10085. delet3                ;[84]
  10086.     sta   kerto          ;[78]         ...
  10087. ;[84]    lda   #getln+7^          ;[78]         ...
  10088. ;[84]    sta   kerto+1          ;[78]         ...
  10089.     stx    kerto+1        ;[84]
  10090.     jsr   kercph          ;[78] Copy the string & make it nasc
  10091. ;[86]    jsr   prcfm          ;[78] Parse and print a confirm
  10092.     lda    #fncren        ;[86] is this rename?
  10093.     cmp    cmncmd+1    ;[86]
  10094.     bne    delet7        ;[86] no
  10095.     lda    dosflg        ;[86] prodos?
  10096.     bne    delet5        ;[86] yes
  10097.     ldx    #getln\        ;[86] we can use this for dos
  10098.     ldy    #getln^        ;[86]
  10099.     jmp    delet6        ;[86]
  10100. delet5    ldy    kwrk01        ;[86] size of previous name
  10101.     lda    #',+$80        ;[86] need a comma
  10102.     sta    (kerto),y    ;[86] between names
  10103.     iny            ;[86]
  10104.     tya            ;[86] now calc getln+7+n
  10105.     ldy    #getln+7^    ;[86] msb
  10106.     clc            ;[86]
  10107.     adc    #getln+7\    ;[86] lsb
  10108.     bcc    .+3        ;[86]
  10109.     iny            ;[86] carry into msb
  10110.     tax            ;[86] lsb
  10111. delet6    stx    kerto        ;[86] new place to move to
  10112.     sty    kerto+1        ;[86]
  10113.     lda    #cmtxt        ;[86] initialize
  10114.     jsr    comnd        ;[86] and get name
  10115.     jmp    kermt6          ;[86] Give the 'missing filespec' error
  10116.     sta   kwrk01          ;[86] Store length of file parsed
  10117.     stx   kerfrm          ;[86] Save the from address (addr[atmbuf])
  10118.     sty   kerfrm+1        ;[86]         ...
  10119.     jsr   kercph          ;[86] Copy the string & make it nasc
  10120.     jsr   prcfm          ;[86] Parse and print a confirm
  10121. delet7                ;[86]
  10122.     jsr    prcrlf        ;[86] basic sys fouls up everyother ch
  10123.     lda    dosflg        ;[78] is this prodos
  10124. ;[86]    bne    delprd        ;[78] yes
  10125.     beq    cmncmd        ;[86]
  10126.     jmp    delprd        ;[86] yes
  10127. cmncmd                ;[86]
  10128.     lda    #fncdel        ;[78] delete command
  10129.     jsr    initfm        ;[78] initialize the file manager & do it
  10130. ;[84]    jmp    delcom        ;[78] check for good delete
  10131.     jmp    kermit        ;[84] thats all initfm checks for error
  10132.  
  10133.  
  10134. .SBTTL    Remote routine
  10135.  
  10136. ;
  10137. ;     This routine sends commands to the remore Kermit.
  10138. ;
  10139. ;         Input:     Parameters from command line
  10140. ;
  10141. ;         Output:     NONE
  10142. ;
  10143. ;         Registers destroyed:     A,X,Y
  10144. ;
  10145.  
  10146. remote: jsr    kerin7        ;[78] just in case were reading kermit.ini
  10147.     lda   #remcmd\      ;[81] Load the address of the keyword table
  10148.     sta   cminf1          ;[81] Save it for the keyword routine
  10149.     lda   #remcmd^      ;[81]         ...
  10150.     sta   cminf1+1      ;[81]         ...
  10151.     ldy   #$00          ;[81] No special flags needed
  10152.     lda   #cmkey          ;[81] Comnd code for parse keyword
  10153.     jsr   comnd          ;[81] Go get it
  10154. remerr    jmp     kermt2          ;[81] Give an error
  10155.     ldy   #remcmb\        ;[81] Get the L.O. byte of jump table
  10156.     lda   #remcmb^        ;[81] Get the H.O. byte
  10157.     jmp    indexj        ;[81]
  10158. remcmb: ;[81] jmp   remker    send remote kermit
  10159. remker: lda   #$80          ;[81] Reset all break characters
  10160.     jsr   rstbrk          ;[81]         ...
  10161.     lda   #cr          ;[81] Now set break characters
  10162.     jsr   setbrk          ;[81]         ...
  10163.     lda   #lf          ;[81]         ...
  10164.     jsr   setbrk          ;[81]         ...
  10165.     lda   #ffd          ;[81]         ...
  10166.     jsr   setbrk          ;[81]         ...
  10167.     lda   #esc          ;[81]         ...
  10168.     jsr   setbrk          ;[81]         ...
  10169.     ldy   #$00          ;[81]         ...
  10170.     sty    n        ;[81]
  10171.     sty    numtry        ;[81]
  10172. ;[81]    sty    kerins        ;[81] make sure we empty buffers 
  10173.     sty    state        ;[81]
  10174.     sty    exfg        ;[81]
  10175.     sty    wcpres        ;[84] just in case
  10176.     lda   #cmtxt          ;[81] Parse for text
  10177.     jsr   comnd          ;[81] Do it
  10178.     jmp     kermta          ;[81] Found null string
  10179.     sta   nfcb1          ;[81] Store packet size for copy
  10180.     stx   remk20+1          ;[81] Point to the atom buffer from Comnd
  10181.     sty   remk20+2        ;[81]     as the source address
  10182.     jsr   prcfm          ;[81] Go parse and print the confirm
  10183.     jsr    comint        ;[81] common com init
  10184.     jsr    scrfrm        ;[81] ready the screen
  10185. remke7    lda    #'I        ;[81] 
  10186.     jsr    sinio        ;[81]
  10187.     bne    remk2r        ;[81] good initialization
  10188.     lda    state        ;[81]
  10189.     cmp    #'A        ;[81] abort?
  10190.     beq    remka2        ;[81] yes
  10191.     bne    remke7        ;[81] try again
  10192.  
  10193.  
  10194. remk2r    lda   numtry          ;[81] Fetch the current number of tries
  10195.     inc   numtry          ;[81] Up it by one
  10196.     cmp   maxtry          ;[81] See if we went up to too many
  10197.     bpl    remerr        ;[81] yes
  10198.     lda   #'K          ;[81] Load type remote kermit
  10199.     sta   ptype          ;[81] Stuff that in as the packet type
  10200.     lda   n          ;[81] Get packet number
  10201.     sta   pnum          ;[81] Store that in its common area
  10202.     ldy    #0        ;[81]
  10203.     sty    datind        ;[81] index into pdbuf
  10204. remk22    sty    kwrk01        ;[81] got to preserve y
  10205. remk20    lda    $ffff,y        ;[81]
  10206.     jsr    ctrlch        ;[81] controlifiy it if necessary
  10207.     bcs    remk23        ;[81] packet is full
  10208.     ldy    kwrk01        ;[81]
  10209.     iny            ;[81]
  10210.     cpy    nfcb1        ;[81]
  10211.     bne    remk22        ;[81]
  10212. remk23    lda    datind        ;[81]
  10213.     sta   pdlen          ;[81]     and Spak
  10214.     jsr   spak          ;[81] Go send the packet
  10215. remk2:    jsr   rpak          ;[81] Go try to receive an ack
  10216.     beq    remk2r        ;[81] bad packet so how can we look further?
  10217.     jsr    dbloc        ;[81] position to debug area of screen
  10218.     lda   ptype          ;[81] Get the returned packet type
  10219.     cmp   #'N          ;[81] Is it a NAK?
  10220.     beq    remkcn        ;[81] yes
  10221. remk2a: cmp   #'Y          ;[81] Is it, perhaps, an ACK?
  10222.     beq    remkca        ;[81] yes
  10223.     cmp    #'E        ;[81] error pkt?
  10224. ;[84]    bne    remk2r        ;[81] try again
  10225.     beq    remka0        ;[84]
  10226.     sta    servef        ;[84] must be long response
  10227.     jsr    rswt        ;[84] hope it starts with s type
  10228.     lda    #0        ;[84] turn server off
  10229.     sta    servef        ;[84]
  10230.     beq    remka2        ;[84] thats all
  10231. remka0                ;[84]
  10232.     jsr    abufmt        ;[81] empty buffer to screen
  10233. ;[85]remka2    jmp    kermit        ;[81] thats all
  10234. remka2    jsr    prcrlf        ;[85]
  10235.     jmp    kermit        ;[85] thats all
  10236. remkcn: jsr    dpnum          ;[81] Decrement the receive packet number once
  10237.     beq    remka2        ;[81] a nak of n-1 is like a ack???????
  10238.     bne    remk2r        ;[81] try again
  10239. remkca: lda   n          ;[81] Get the packet number
  10240.     cmp   pnum          ;[81] Is that the one that was acked?
  10241.     bne   remk2r          ;[81] They are not equal
  10242. ;[84]    beq    remka2        ;[81] good ack
  10243.     beq    remka0        ;[84] good ack
  10244.  
  10245. .SBTTL    Setcom routine
  10246.  
  10247. ;
  10248. ;     This routine sets Kermit-65 parameters.
  10249. ;
  10250. ;         Input:     Parameters from command line
  10251. ;
  10252. ;         Output:     NONE
  10253. ;
  10254. ;         Registers destroyed:     A,X,Y
  10255. ;
  10256.  
  10257. setcom: lda   #setcmd\      ; Load the address of the keyword table
  10258.     sta   cminf1          ; Save it for the keyword routine
  10259.     lda   #setcmd^      ;         ...
  10260.     sta   cminf1+1      ;         ...
  10261.     ldy   #$00          ;[13] No special flags needed
  10262.     lda   #cmkey          ; Comnd code for parse keyword
  10263.     jsr   comnd          ; Go get it
  10264.           jmp     kermt2          ; Give an error
  10265.     jmp    xjmp        ; now do routine
  10266. ;[81]    lda   #setcmb\      ;[9] Get the L.O. byte of jump table
  10267. ;[81]    sta   jtaddr          ;[9] Put the L.O. byte here until needed
  10268. ;[82]    ldy   #setcmb\      ;[81] Get the L.O. byte of jump table
  10269. ;[82]    lda   #setcmb^      ;[9] Get the H.O. byte
  10270. ;[82]    jmp    indexj    ;[57]
  10271. ;[82]setcmb: jmp   stesc          ; Set escape character
  10272. ;[68]    jmp   stibm          ; Set ibm-mode switch
  10273. ;[82]setle    jmp   stle          ; Set local-echo switch
  10274. ;[82]setrc    jmp   strc          ; Set receive parameters
  10275. ;[82]setsn    jmp   stsn          ; Set send parameters
  10276. ;[82]setvt    jmp   stvt          ; Set vt52-emulation switch
  10277. ;[82]setfw    jmp   stfw          ; Set file-warning switch
  10278. ;[72]seteb    jmp   steb          ; Set Eight-bit quoting character
  10279. ;[82]setdb    jmp   stdb          ; Set debugging switch
  10280. ;[82]setmod    jmp   stmod          ; Set file-type mode
  10281. ;[65]    jmp   stfbs          ; Set the file-byte-size for transfer
  10282. ;[82]setcsl    jmp   stslot          ;[12] Set the I/O port index
  10283. ;[82]setcpa    jmp   stpari          ;[21] Set the parity for communication
  10284. ;[82]setckb    jmp   stkbd          ;[35] Set the keyboard type.
  10285. ;[82]setcdd    jmp   stddsk          ;[40] Set the default disk for I/O
  10286. ;[82]setcds    jmp   stdspy          ;[46] Set the display type.
  10287. ;[82]setcba    jmp   stbaud      ;[47] set the baud for super serial card
  10288. ;[82]setcpr    jmp   stprn          ;[55] Set the printer
  10289. ;[82]setcfl    jmp    stflow        ;[57] flow control xon etc
  10290. ;[82]setcpf    jmp    stpre        ;[59] set prefix for prodos
  10291. ;[82]setctm    jmp    sttmr        ;[62] set timer on/off
  10292. ;[82]setcsw    jmp    stswp        ;[73] set swap bs & del on/off
  10293. ;[82]setckp    jmp    stkp        ;[80] set keypad
  10294. ;setcka    jmp    stkpa        ;[80] set keypad application mode
  10295. ;[82]setcka    jmp    stkpa        ;[81] set keypad application mode
  10296. ;[82]setckc    jmp    stcko        ;[80] set cursor keys only in vt100 mode
  10297.  
  10298. stesc:    ldx   #$10          ; Base should be hex
  10299.     ldy   #$00          ;[13] No special flags needed
  10300.     lda   #cmnum          ; Parse for integer
  10301.     jsr   comnd          ; Go!
  10302.           jmp     kermt4          ; Number is bad
  10303.     stx   ksavex          ;[13] Hold the number across the next call
  10304.     sty   ksavey          ;[13]         ...
  10305. ;[78]    lda   #cmcfm          ; Parse for confirm
  10306. ;[78]    jsr   comnd          ; Do it
  10307. ;[78]          jmp     kermt3          ; Not confirmed
  10308.     jsr    prcfm        ;[78] parse & confirm
  10309.     lda   ksavey          ;[13] If this isn't zero
  10310. ;    cmp   #$00          ;     it's not an ASCII character
  10311.     beq   stesc1          ; It is, continue
  10312.     jmp   kermt4          ; Bad number, tell them
  10313. stesc1: lda   ksavex          ;[13] Get L.O. byte
  10314.     cmp   #$7f          ; It shouldn't be bigger than this
  10315.     bmi   stesc2          ; If it's less, it is ok
  10316.     jmp   kermt4          ; Tell the user it is bad
  10317. stesc2: sta   escp          ; Stuff it
  10318.     jmp   kermit
  10319.  
  10320. ;[68]stibm:    jsr   prson          ;[21] Try parsing an 'on' or 'off'
  10321. ;[68]          jmp     kermt2          ;[21] Bad keyword
  10322. ;[68]    stx   ibmmod          ;[21] Store value in the mode switch location
  10323. ;[68]    stx   lecho          ;[21] Also set local echo accordingly
  10324. ;[68]    ldy   #nparit          ;[21] Get ready to set the parity parameter
  10325. ;[68]    cpx   #on          ;[21] Setting ibm mode on?
  10326. ;[68]    bne   stibm1          ;[21] Nope so set no parity
  10327. ;[68]    ldy   #mparit          ;[21] Set mark parity
  10328. ;[68]stibm1: sty   parity          ;[21] Store the value
  10329. ;[68]    lda   #cmcfm          ;[21] Parse for confirm
  10330. ;[68]    jsr   comnd          ;[21] Do it
  10331. ;[68]      jmp     kermt3          ;[21] Not confirmed, tell the user that
  10332. ;[68]    jmp   kermit          ;[21]
  10333.  
  10334. sttmr:    jsr   prson          ;[64] Try parsing an 'on' or 'off'
  10335.           jmp     kermt2          ;[64] Bad keyword
  10336. ;[80]    stx   ksavex          ;[64] Store value in the mode switch location
  10337.     stx    timer        ;[80] set timer on/off - forget about parse error
  10338. ;[78]    lda   #cmcfm          ;[64] Parse for confirm
  10339. ;[78]    jsr   comnd          ;[64] Do it
  10340. ;[78]      jmp     kermt3          ;[64] Not confirmed, tell the user that
  10341. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10342. ;[80]    ldx    ksavex        ;[64] now set timer on/off
  10343. ;[80]    stx    timer        ;[64]
  10344. ;[80]    jmp   kermit          ;[64]
  10345.     jmp    stflo7        ;[80] common parse, comfirm & rtn to kermit
  10346. stswp    jsr    prson        ;[73] pars on/off
  10347.     jmp    kermt2        ;[73] bad keyword
  10348. ;[80]    stx    ksavex        ;[73] save it for after the confirm
  10349.     stx    swapf        ;[80] set swap on/off - forget about parse error
  10350. ;[78]    lda    #cmcfm        ;[73]
  10351. ;[78]    jsr    comnd        ;[73] now for the confirm
  10352. ;[78]    jmp    kermt3        ;[73] no! que passo
  10353. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10354. ;[80]    ldx    ksavex        ;[73]
  10355. ;[80]    stx    swapf        ;[73] now we set it
  10356. ;[80]    jmp    kermit        ;[73] around we go again
  10357.     jmp    stflo7        ;[80] common parse, comfirm & rtn to kermit
  10358. stkp    jsr    prson        ;[80] pars on/off
  10359.     jmp    kermt2        ;[80] bad keyword
  10360.     stx    kpfl        ;[80] now we set it-ignore confirm error
  10361.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10362. ;stkpa    jsr    prson        ;[80] pars on/off
  10363. ;    jmp    kermt2        ;[80] bad keyword
  10364. ;    stx    kpafl        ;[80] now we set it-ignore confirm error
  10365. ;    jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10366. stkpa    jsr    prson        ;[81] pars on/off
  10367.     jmp    kermt2        ;[81] bad keyword
  10368.     stx    kpafl        ;[81] now we set it-ignore confirm error
  10369.     jmp    stflo7        ;[81] common parse, confirm & rtn to kermit
  10370. stcko    jsr    prson        ;[80] pars on/off
  10371.     jmp    kermt2        ;[80] bad keyword
  10372.     stx    ckfl        ;[80] now we set it-ignore confirm error
  10373.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10374.  
  10375. stle:    jsr   prson          ; Try parsing an 'on' or 'off'
  10376.           jmp     kermt2          ; Bad keyword
  10377.     stx   lecho          ; Store value in the mode switch location
  10378. ;[78]    lda   #cmcfm          ; Parse for confirm
  10379. ;[78]    jsr   comnd          ; Do it
  10380. ;[78]          jmp     kermt3          ; Not confirmed, tell the user that
  10381. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10382. ;[80]    jmp   kermit
  10383.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10384.  
  10385. stcs    jsr    prson        ;[87] Try parsing an 'on' or 'off'
  10386.     jmp    kermt2        ;[87] Bad keyword
  10387.     stx    csfg        ;[87] Store value in the mode switch location
  10388.     jmp    stflo7        ;[87] common parse, confirm & rtn to kermit
  10389.  
  10390. strc:    lda   #$00          ; Set srind for receive parms
  10391.     sta   srind          ;         ...
  10392.     lda   #stscmd\      ; Load the address of the keyword table
  10393.     sta   cminf1          ; Save it for the keyword routine
  10394.     lda   #stscmd^      ;         ...
  10395.     sta   cminf1+1      ;         ...
  10396.     ldy   #$00          ;[13] No special flags needed
  10397.     lda   #cmkey          ; Comnd code for parse keyword
  10398.     jsr   comnd          ; Go get it
  10399.           jmp     kermt2          ; Give an error
  10400. ;[81]    lda   #stcct\          ;[9] Get the L.O. byte of jump table
  10401. ;[81]    sta   jtaddr          ;[9] Put the L.O. byte here until needed
  10402.     ldy   #stcct\          ;[81] Get the L.O. byte of jump table
  10403.     lda   #stcct^          ;[9] Get the H.O. byte
  10404.     jmp    indexj    ;[57]
  10405.  
  10406. stsn:    lda   #$01          ; Set srind for send parms
  10407.     sta   srind          ;         ...
  10408.     lda   #stscmd\      ; Load the address of the keyword table
  10409.     sta   cminf1          ; Save it for the keyword routine
  10410.     lda   #stscmd^      ;         ...
  10411.     sta   cminf1+1      ;         ...
  10412.     ldy   #$00          ;[13] No special flags needed
  10413.     lda   #cmkey          ; Comnd code for parse keyword
  10414.     jsr   comnd          ; Go get it
  10415.           jmp     kermt2          ; Give an error
  10416. ;[81]    lda   #stcct\          ;[9] Get the L.O. byte of jump table
  10417. ;[81]    sta   jtaddr          ;[9] Put the L.O. byte here until needed
  10418.     ldy   #stcct\          ;[81] Get the L.O. byte of jump table
  10419.     lda   #stcct^          ;[9] Get the H.O. byte
  10420.     jmp    indexj    ;[57] indexed jump
  10421.  
  10422. stcct:    jmp   stpdc          ; Set send/rec padding character
  10423.     jmp   stpad          ; Set amount of padding on send/rec
  10424.     jmp   stebq          ; Set send/rec eight-bit-quoting character
  10425.     jmp   steol          ; Set send/rec end-of-line
  10426.     jmp   stpl          ; Set send/rec packet length
  10427.     jmp   stqc          ; Set send/rec quote character
  10428.     jmp   sttim          ; Set send/rec timeout
  10429.     jmp    stsop        ;[82] Set send/rec start of packet
  10430.     jmp    stcrlf        ;[84] set cr<->cr,lf xlation
  10431.  
  10432. stcrlf    jsr    prson        ;[84]
  10433.     jmp    kermt2        ;[84] failure
  10434.     txa            ;[84] on/off to acc
  10435.     ldx    srind        ;[84] is this rec/send?
  10436.     sta    xcrlf,x        ;[84] set it
  10437.     jmp    stflo7        ;[84]
  10438.  
  10439. stvt:    ;[76]jsr   prson          ; Try parsing an 'on' or 'off'
  10440.     lda    #terkey\    ;[76]
  10441.     sta    cminf1        ;[76] search for type of terminal
  10442.     lda    #terkey^    ;[76]
  10443.     sta    cminf1+1    ;[76]
  10444.     ldy    #0        ;[76] nothing special
  10445.     lda    #cmkey        ;[76] key word search
  10446.     jsr    comnd        ;[76]
  10447.           jmp     kermt2          ; Bad keyword
  10448.     cpy    #4        ;[78] is this wraparround?
  10449.     beq    stvt1        ;[78] yes
  10450. ;[76]    stx   vtmod          ; Store value in the mode switch location
  10451.     sty   vtmod          ;[76] Store value in the mode switch location
  10452. ;[78]    lda   #cmcfm          ; Parse for confirm
  10453. ;[78]    jsr   comnd          ; Do it
  10454. ;[78]          jmp     kermt3          ; Not confirmed, tell the user that
  10455.     jsr    sutljp        ;[80] setup tel term type jp
  10456. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10457. ;[80]    jsr    sutljp        ;[76] setup tel term type jp
  10458. ;[80]    jmp   kermit
  10459.     jmp    stflo7        '[80] parse, confirm and ignore errors
  10460. stvt1    jsr    prson        ;[78] parse for on/off
  10461.     jmp    kermt2        ;[78] malo
  10462.     stx    wrapar        ;[78] set the wrap arround
  10463. ;[78]    lda   #cmcfm          ;[78] Parse for confirm
  10464. ;[78]    jsr   comnd          ;[78] Do it
  10465. ;[78]    jmp    kermt3        ;[78] Not confirmed, tell the user that
  10466. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10467. ;[80]    jmp   kermit        ;[78]
  10468.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10469.  
  10470. stfw:    jsr   prson          ; Try parsing an 'on' or 'off'
  10471.           jmp     kermt2          ; Bad keyword
  10472.     stx   filwar          ; Store value in the mode switch location
  10473. ;[78]    lda   #cmcfm          ; Parse for confirm
  10474. ;[78]    jsr   comnd          ; Do it
  10475. ;[78]          jmp     kermt3          ; Not confirmed, tell the user that
  10476. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10477. ;[80]    jmp   kermit
  10478.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10479.  
  10480. ;[72]steb:    jsr   prson          ; Try parsing an 'on' or 'off'
  10481. ;[72]          jmp     kermt2          ; Bad keyword
  10482. ;[72]    stx   ebqmod          ; Store value in the mode switch location
  10483. ;[72]    lda   #cmcfm          ; Parse for confirm
  10484. ;[72]    jsr   comnd          ; Do it
  10485. ;[72]          jmp     kermt3          ; Not confirmed, tell the user that
  10486. ;[72]    jmp   kermit
  10487.  
  10488. stdb:    lda   #debkey\      ;[26] Load the address of the keyword table
  10489.     sta   cminf1          ;[26] Save it for the keyword routine
  10490.     lda   #debkey^      ;[26]         ...
  10491.     sta   cminf1+1      ;[26]         ...
  10492.     ldy   #$00          ;[26] No special flags needed
  10493.     lda   #cmkey          ;[26] Comnd code for parse keyword
  10494.     jsr   comnd          ;[26] Go get it
  10495.           jmp     kermt2          ;[26] Give an error
  10496.     stx   debug          ;[26] Stuff returned value into debug switch
  10497. ;[78]    lda   #cmcfm          ;[26] Parse for a confirm
  10498. ;[78]    jsr   comnd          ;[26] Do it
  10499. ;[78]          jmp     kermt3          ;[26] Not confirmed, tell the user that
  10500. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10501. ;[80]    jmp   kermit
  10502.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10503.  
  10504. stcom:    ldx   #$10          ;[82] Base for ASCII value
  10505.     ldy   #$00          ;[82][13] No special flags needed
  10506.     lda   #cmnum          ;[82] Code for integer number
  10507.     jsr   comnd          ;[82] Go do it
  10508.     jmp     stcom4          ;[82] The number was bad
  10509.     tya          ;[82] If this isn't zero
  10510.     beq   stcom1          ;[82] It is, continue
  10511.     jmp   stcom4          ;[82] Bad number, tell them
  10512. stcom1:    txa          ;[82] Get L.O. byte
  10513.     cmp   #$7f          ;[82] It shouldn't be bigger than this
  10514.     bmi   stcom2          ;[82] If it's less, it is ok
  10515.     jmp   stcom4          ;[82] Tell the user it is bad
  10516. stcom2:    ldx   srind          ;[82] Fetch index for receive or send parms
  10517.     rts            ;[82]
  10518. stcom4    pla            ;[82] keep stack straight
  10519.     pla            ;[82]
  10520.     jmp    kermt4        ;[82] now tell user
  10521.  
  10522. ;[82]stebq:    ldx   #$10          ; Base for ASCII value
  10523. stebq:    jsr    stcom        ; first the common code
  10524. ;[82]    ldy   #$00          ;[13] No special flags needed
  10525. ;[82]    lda   #cmnum          ; Code for integer number
  10526. ;[82]    jsr   comnd          ; Go do it
  10527. ;[82]          jmp     kermt4          ; The number was bad
  10528. ;[82]    tya          ;[13] If this isn't zero
  10529. ;    cmp   #$00          ;     it's not an ASCII character
  10530. ;[82]    beq   steb1          ; It is, continue
  10531. ;[82]    jmp   kermt4          ; Bad number, tell them
  10532. ;[82]steb1:    txa          ;[13] Get L.O. byte
  10533. ;[82]    cmp   #$7f          ; It shouldn't be bigger than this
  10534. ;[82]    bmi   steb2          ; If it's less, it is ok
  10535. ;[82]    jmp   kermt4          ; Tell the user it is bad
  10536. steb2:    cmp   #$21          ; First check the character range
  10537.     bmi   steb4          ; Not in range
  10538.     cmp   #$3f          ;         ...
  10539.     bmi   steb3          ; Inrange
  10540.     cmp   #$60          ;         ...
  10541.     bmi   steb4          ; Not in range
  10542. ;[82]steb3:    ldx   srind          ; Get index for receive or send parms
  10543. steb3:                ;[82]
  10544.     sta   ebq,x          ; Stuff it
  10545. ;[78]    lda   #cmcfm          ;[13] Parse for confirm
  10546. ;[78]    jsr   comnd          ;[13] Do it
  10547. ;[78]          jmp     kermt3          ;[13] Not confirmed, tell the user that
  10548. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10549. ;[80]    jmp   kermit
  10550.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10551. steb4:    ldx   #ermes5\      ; Get error message
  10552.     ldy   #ermes5^      ;         ...
  10553.     jsr   prstr          ; Print the error
  10554. ;[80]    jsr   prcfm          ; Go parse and print a confirm
  10555. ;[80]    jmp   kermit          ; Go back
  10556.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10557.  
  10558. ;[82]steol:    ldx   #$10          ; Base for ASCII value
  10559. steol:    jsr    stcom        ;[82 common code
  10560. ;[82]    ldy   #$00          ;[13] No special flags needed
  10561. ;[82]    lda   #cmnum          ; Code for integer number
  10562. ;[82]    jsr   comnd          ; Go do it
  10563. ;[82]          jmp     kermt4          ; The number was bad
  10564. ;[82]    tya          ;[13] If this isn't zero
  10565. ;    cmp   #$00          ;     it's not an ASCII character
  10566. ;[82]    beq   steo1          ; It is, continue
  10567. ;[82]    jmp   kermt4          ; Bad number, tell them
  10568. ;[82]steo1:    txa          ;[13] Get L.O. byte
  10569. ;[82]    cmp   #$7f          ; It shouldn't be bigger than this
  10570. ;[82]    bmi   steo2          ; If it's less, it is ok
  10571. ;[82]    jmp   kermt4          ; Tell the user it is bad
  10572. ;[82]steo2:    ldx   srind          ; Fetch index for receive or send parms
  10573.     sta   eol,x          ; Stuff it
  10574. ;[80]    jsr   prcfm          ; Go parse and print a confirm
  10575. ;[80]    jmp   kermit          ; Go back
  10576.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10577.  
  10578. stsop    jsr    stcom        ;[82] common code
  10579.     sta    sop,x        ;[82] set the rec/send start of packet
  10580.     jmp    stflo7        ;[82] thats all
  10581.  
  10582. ;[82]stpad:    ldx   #$10          ; Base for ASCII value
  10583. stpad:    jsr    stcom        ;[82] common code
  10584. ;[82]    ldy   #$00          ;[13] No special flags needed
  10585. ;[82]    lda   #cmnum          ; Code for integer number
  10586. ;[82]    jsr   comnd          ; Go do it
  10587. ;[82]          jmp     kermt4          ; The number was bad
  10588. ;[82]    tya          ;[13] If this isn't zero
  10589. ;    cmp   #$00          ;     it's not an ASCII character
  10590. ;[82]    beq   stpd1          ; It is, continue
  10591. ;[82]    jmp   kermt4          ; Bad number, tell them
  10592. ;[82]stpd1:    txa          ;[13] Get L.O. byte
  10593. ;[82]    cmp   #$7f          ; It shouldn't be bigger than this
  10594. ;[82]    bmi   stpd2          ; If it's less, it is ok
  10595. ;[82]    jmp   kermt4          ; Tell the user it is bad
  10596. ;[82]stpd2:    ldx   srind          ; Get index (receive or send)
  10597.     sta   pad,x          ; Stuff it
  10598. ;[80]    jsr   prcfm          ; Go parse and print a confirm
  10599. ;[80]    jmp   kermit          ; Go back
  10600.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10601.  
  10602. ;[82]stpdc:    ldx   #$10          ; Base for ASCII value
  10603. stpdc:    jsr    stcom        ;[82] common code
  10604. ;[82]    ldy   #$00          ;[13] No special flags needed
  10605. ;[82]    lda   #cmnum          ; Code for integer number
  10606. ;[82]    jsr   comnd          ; Go do it
  10607. ;[82]          jmp     kermt4          ; The number was bad
  10608. ;[82]    tya          ;[13] If this isn't zero
  10609. ;    cmp   #$00          ;     it's not an ASCII character
  10610. ;[82]    beq   stpc1          ; It is, continue
  10611. ;[82]    jmp   kermt4          ; Bad number, tell them
  10612. ;[82]stpc1:    txa          ;[13] Get L.O. byte
  10613. ;[82]    cmp   #$7f          ; It shouldn't be bigger than this
  10614. ;[82]    bmi   stpc2          ; If it's less, it is ok
  10615. ;[82]    jmp   kermt4          ; Tell the user it is bad
  10616. ;[82]stpc2:    ldx   srind          ; Get index for parms
  10617.     sta   padch,x          ; Stuff it
  10618. ;[80]    jsr   prcfm          ; Go parse and print a confirm
  10619. ;[80]    jmp   kermit          ; Go back
  10620.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10621.  
  10622. stpl:    ldx   #$10          ; Base for ASCII value
  10623.     ldy   #$00          ;[13] No special flags needed
  10624.     lda   #cmnum          ; Code for integer number
  10625.     jsr   comnd          ; Go do it
  10626.           jmp     kermt4          ; The number was bad
  10627.     tya          ;[13] If this isn't zero
  10628. ;    cmp   #$00          ;     it's not an ASCII character
  10629. ;[81]    beq   stpl1          ; It is, continue
  10630. ;[81]    jmp   kermt4          ; Bad number, tell them
  10631. ;[81]stpl1:    txa          ;[13] Get L.O. byte
  10632.     bne    stpl1        ;[81]
  10633.     txa            ;[81]
  10634. ;[75]    cmp   #mxpack          ; It shouldn't be bigger than this
  10635.     cmp   #maxxdl+1          ;[75] It shouldn't be bigger than this
  10636.     bcc   stpl2          ; If it's less, it is ok
  10637. stpl1                ;[81]
  10638.     ldx    #erms1l\        ;[75] tell user 
  10639.     ldy    #erms1l^    ;[75] what the
  10640.     jsr    prstr        ;[75] max is
  10641.     lda    #maxxdl        ;[75]
  10642. ;[79]    jsr    prbyte        ;[75]
  10643. ;[79]    jsr    prcrlf        ;[75]
  10644. ;[87]    jsr    prbytl        ;[79] pr byte in hex & crlf
  10645.     jsr    prbydr        ;[87] pr byte in ascii & cr
  10646.     lda    #maxxdl        ;[81]
  10647. ;[81]    jmp   kermt4          ; Tell the user it is bad
  10648. stpl2:    ldx   srind          ; Get index
  10649.     sta   psiz,x          ; Stuff it
  10650. ;[80]    jsr   prcfm          ; Go parse and print a confirm
  10651. ;[80]    jmp   kermit          ; Go back
  10652.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10653.  
  10654. ;[82]stqc:    ldx   #$10          ; Base for ASCII value
  10655. stqc:    jsr    stcom        ;[82] common code
  10656. ;[82]    ldy   #$00          ;[13] No special flags needed
  10657. ;[82]    lda   #cmnum          ; Code for integer number
  10658. ;[82]    jsr   comnd          ; Go do it
  10659. ;[82]          jmp     kermt4          ; The number was bad
  10660. ;[82]    tya          ;[13] If this isn't zero
  10661. ;    cmp   #$00          ;     it's not an ASCII character
  10662. ;[82]    beq   stqc1          ; It is, continue
  10663. ;[82]    jmp   kermt4          ; Bad number, tell them
  10664. ;[82]stqc1:    txa          ;[13] Get L.O. byte
  10665. ;[82]    cmp   #$7f          ; It shouldn't be bigger than this
  10666. ;[82]    bmi   stqc2          ; If it's less, it is ok
  10667. ;[82]    jmp   kermt4          ; Tell the user it is bad
  10668. ;[82]stqc2:    ldx   srind          ; Fetch index for receive or send parms
  10669.     sta   quote,x          ; Stuff it
  10670. ;[80]    jsr   prcfm          ; Go parse and print a confirm
  10671. ;[80]    jmp   kermit          ; Go back
  10672.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10673.  
  10674. ;[82]sttim:    ldx   #10          ;[64] Base for ASCII value
  10675. sttim:    jsr    stcom        ;[82] common code
  10676. ;[82]    ldy   #$00          ;[13] No special flags needed
  10677. ;[82]    lda   #cmnum          ; Code for integer number
  10678. ;[82]    jsr   comnd          ; Go do it
  10679. ;[82]          jmp     kermt4          ; The number was bad
  10680. ;[82]    tya          ;[13] If this isn't zero
  10681. ;    cmp   #$00          ;     it's not an ASCII character
  10682. ;[82]    beq   sttm1          ; It is, continue
  10683. ;[82]    jmp   kermt4          ; Bad number, tell them
  10684. ;[82]sttm1:    txa          ;[13] Get L.O. byte
  10685. ;[82]    cmp   #$7f          ; It shouldn't be bigger than this
  10686. ;[82]    bmi   sttm2          ; If it's less, it is ok
  10687. ;[82]    jmp   kermt4          ; Tell the user it is bad
  10688. ;[82]sttm2:    ldx   srind          ; Fetch index for receive or send parms
  10689.     sta   time,x          ; Stuff it
  10690.     bne    sttm7        ;[64] did we change rec timeout?,no
  10691. ;[87]    lda    #0        ;[64]
  10692. ;[87]    pha            ;[64]
  10693. ;[87]    pha            ;[87]
  10694. ;[87]    lda    #cv2lp        ;[64] convert sec to loops thru getc
  10695. ;[87]    pha            ;[64]
  10696. ;[87]    lda    #0        ;[64]
  10697. ;[87]    pha            ;[64]
  10698. ;[87]    pha            ;[87]
  10699. ;[87]    lda    rtime        ;[64] rec timeout in seconds
  10700. ;[87]    pha            ;[64]
  10701. ;[87]    jsr    mul16        ;[64] now for the multiply
  10702. ;[87]    pla            ;[64]
  10703. ;[87]    sta    lpcycl        ;[64] answer in here
  10704. ;[87]    pla            ;[64]
  10705. ;[87]    sta    lpcycl+1    ;[64]
  10706. ;[87]    pla            ;[87] msb throw away
  10707.     jsr    cvs2lp        ;[87]
  10708. sttm7                ;[64]
  10709. ;[80]    jsr   prcfm          ; Go parse and print a confirm
  10710. ;[80]    jmp   kermit          ; Go back
  10711.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10712.  
  10713. cvs2lp    lda    #0        ;[87] convert seconds to loops
  10714.     pha            ;[87]
  10715.     pha            ;[87]
  10716.     lda    #cv2lp        ;[87] convert sec to loops thru getc
  10717.     pha            ;[87]
  10718.     lda    #0        ;[87]
  10719.     pha            ;[87]
  10720.     pha            ;[87]
  10721.     lda    rtime        ;[87] rec timeout in seconds
  10722.     pha            ;[87]
  10723.     jsr    mul24        ;[87] now for the multiply
  10724.     pla            ;[87]
  10725.     sta    lpcycl        ;[87] answer in here
  10726.     pla            ;[87]
  10727.     sta    lpcycl+1    ;[87]
  10728.     pla            ;[87] msb throw away
  10729.     rts
  10730.  
  10731. stmod:    lda   #ftcmd\          ; Load the address of the keyword table
  10732.     sta   cminf1          ; Save it for the keyword routine
  10733.     lda   #ftcmd^          ;         ...
  10734.     sta   cminf1+1      ;         ...
  10735.     lda   #ftcdef\      ;[13] Load default address
  10736.     sta   cmdptr          ;[13]         ...
  10737.     lda   #ftcdef^      ;[13]         ...
  10738.     sta   cmdptr+1      ;[13]         ...
  10739.     ldy   #cmfdff          ;[13] Tell Comnd there is a default
  10740.     lda   #cmkey          ; Comnd code for parse keyword
  10741.     jsr   comnd          ; Go get it
  10742.           jmp     kermt2          ; Give an error
  10743.     cpx    #$ff        ;[78] is this other ?
  10744.     bne    stmod1        ;[78] no
  10745. ;    sty    ascii        ;[82] signals type of text
  10746.     ldx    #16        ;[78] other type base 16
  10747.     ldy    #0        ;[78] nothing special
  10748.     lda    #cmnum        ;[78] parse integer
  10749.     jsr    comnd        ;[78]
  10750.     jmp    kermt4        ;[78] no integer, error
  10751. ;    jmp    stmod3        ;[82]
  10752. stmod1                ;[78]
  10753. ;    sty    ascii        ;[82] signals type of text
  10754. ;stmod3                ;[82]
  10755.     stx   filmod          ; Save the file-type mode
  10756.     stx    kersft        ;[78] just in case were initializing
  10757. ;[78]    lda   #cmcfm          ; Parse for a confirm
  10758. ;[78]    jsr   comnd          ; Do it
  10759. ;[78]          jmp     kermt3          ; Not confirmed, tell the user that
  10760. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10761. ;[63]    ldx    #4        ;[59] is this binary ?
  10762. ;[63]    cpx    filmod        ;[59]
  10763. ;[63]    bne    stmod2        ;[59] no we dont need 8 bits
  10764. ;[65]    ldx    filmod        ;[63] is this text mode?
  10765. ;[65]    beq    stmod2        ;[63] yes dont worry about byte size
  10766. ;[65]    ldx    fbsize        ;[59] yes what is the byte size
  10767. ;[65]    beq    stmod2        ;[59] its 8
  10768. ;[65]    ldx    #erms1f\    ;[59] warn about 8 probably required
  10769. ;[65]    ldy    #erms1f^    ;[59]
  10770. ;[65]    jsr    prstr        ;[59]
  10771. ;[65]    jsr    prcrlf        ;[59]
  10772. ;[65]stmod2                ;[59]
  10773. ;[80]    jmp   kermit
  10774.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10775.  
  10776. stprt    lda   #prcmd\          ;[83] Load the address of the keyword table
  10777.     sta   cminf1          ;[83] Save it for the keyword routine
  10778.     lda   #prcmd^          ;[83]         ...
  10779.     sta   cminf1+1      ;[83]         ...
  10780.     lda   #prcdef\      ;[83] Load default address
  10781.     sta   cmdptr          ;[83]         ...
  10782.     lda   #prcdef^      ;[83]         ...
  10783.     sta   cmdptr+1      ;[83]         ...
  10784.     ldy   #cmfdff          ;[83] Tell Comnd there is a default
  10785.     lda   #cmkey          ;[83] Comnd code for parse keyword
  10786.     jsr   comnd          ;[83] Go get it
  10787.           jmp     kermt2          ;[83] Give an error
  10788.     sty   prtcl          ;[83] Save the protocol mode
  10789.     jmp    stflo7        ;[83][80] common parse, confirm & rtn to kermit
  10790.  
  10791. ;[65]stfbs:    lda   #fbskey\      ; Load the address of the keyword table
  10792. ;[65]    sta   cminf1          ; Save it for the keyword routine
  10793. ;[65]    lda   #fbskey^      ;         ...
  10794. ;[65]    sta   cminf1+1      ;         ...
  10795. ;[65]    ldy   #$00          ;[13] No special flags needed
  10796. ;[65]    lda   #cmkey          ; Comnd code for parse keyword
  10797. ;[65]    jsr   comnd          ; Go get it
  10798. ;[65]          jmp     kermt2          ; Give an error
  10799. ;[65]    stx   fbsize          ; Stuff the returned value into file-byte-size
  10800. ;[65]    lda   #cmcfm          ; Parse for a confirm
  10801. ;[65]    jsr   comnd          ; Do it
  10802. ;[65]          jmp     kermt3          ; Not confirmed, tell the user that
  10803. ;[65]    jmp   kermit
  10804.  
  10805. stslot: ldx   #$08          ;[12] Base for ASCII value
  10806.     ldy   #$00          ;[13] No special flags needed
  10807.     lda   #cmnum          ;[12] Code for integer number
  10808.     jsr   comnd          ;[12] Go do it
  10809.           jmp     kermt4          ;[12] The number was bad
  10810.     tya          ;[13][12] If this isn't zero
  10811. ;    cmp   #$00          ;[12]     then the number is too big
  10812.     beq   stslt1          ;[12] It is, continue
  10813.     jmp   kermt4          ;[12] Bad number, tell them
  10814. stslt1: txa          ;[13][12] Get L.O. byte
  10815.     cmp   #$08          ;[12] It shouldn't be bigger than this
  10816.     bmi   stslt2          ;[12] If it's less, it is ok
  10817.     jmp   kermt4          ;[12] Tell the user it is bad
  10818. ;[81]stslt2: sta   kersli          ;[12] Stuff it in the slot index
  10819. ;[81]    asl   kersli          ;[12] Shift it 4 times to make it an index
  10820. ;[81]    asl   kersli          ;[12]     for I/O operations
  10821. ;[81]    asl   kersli          ;[12]         ...
  10822. ;[81]    asl   kersli          ;[12]         ...
  10823. stslt2    asl    a        ;[81] its quicker this way
  10824.     asl    a        ;[81]
  10825.     asl    a        ;[81]
  10826.     asl    a        ;[81]
  10827.     sta    kersli        ;[81]
  10828. ;[81]    lda    #0        ;[75] force com initialize
  10829. ;[81]    sta    kerins        ;[75]
  10830. ;[80]    jsr   prcfm          ;[12] Go parse and print a confirm
  10831. ;[80]    jmp   kermit          ;[12] Go back
  10832.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10833.  
  10834. stpari: lda   #parkey\      ;[21] Load the address of the keyword table
  10835.     sta   cminf1          ;[21] Save it for the keyword routine
  10836.     lda   #parkey^      ;[21]         ...
  10837.     sta   cminf1+1      ;[21]         ...
  10838.     ldy   #$00          ;[21] No special flags needed
  10839.     lda   #cmkey          ;[21] Comnd code for parse keyword
  10840.     jsr   comnd          ;[21] Go get it
  10841.           jmp     kermt2          ;[21] Give an error
  10842.     stx   parity          ;[21] Stuff returned value into parity
  10843. ;[78]    lda   #cmcfm          ;[21] Parse for a confirm
  10844. ;[78]    jsr   comnd          ;[21] Do it
  10845. ;[78]          jmp     kermt3          ;[21] Not confirmed, tell the user that
  10846. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10847. ;[80]    jmp   kermit          ;[21]
  10848.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10849.  
  10850. stkbd:    lda   #kbkey\          ;[35] Load the address of the keyword table
  10851.     sta   cminf1          ;[35] Save it for the keyword routine
  10852.     lda   #kbkey^          ;[35]         ...
  10853.     sta   cminf1+1      ;[35]         ...
  10854.     ldy   #$00          ;[35] No special flags needed
  10855.     lda   #cmkey          ;[35] Comnd code for parse keyword
  10856.     jsr   comnd          ;[35] Go get it
  10857.           jmp     kermt2          ;[35] Give an error
  10858.     stx   kbd1          ;[35] Save the print string index
  10859.     sty   kbdtyp          ;[35]      and the keyboard-type index.
  10860. ;[78]    lda   #cmcfm          ;[35] Parse for a confirm
  10861. ;[78]    jsr   comnd          ;[35] Do it
  10862. ;[78]          jmp     kermt3          ;[35] Not confirmed, tell the user that
  10863. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10864. ;[80]    jmp   kermit          ;[35]
  10865.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10866.  
  10867. stdspy: lda   #dspkey\      ;[46] Load the address of the keyword table
  10868.     sta   cminf1          ;[46] Save it for the keyword routine
  10869.     lda   #dspkey^      ;[46]         ...
  10870.     sta   cminf1+1      ;[46]         ...
  10871.     ldy   #$00          ;[46] No special flags needed
  10872.     lda   #cmkey          ;[46] Comnd code for parse keyword
  10873.     jsr   comnd          ;[46] Go get it
  10874.           jmp     kermt2          ;[46] Give an error
  10875.     stx   dsp1          ;[46] Save the print string index
  10876.     sty   dsptyp          ;[46]      and the display-type index.
  10877. ;[81]    lda   #stdspj\      ;[49] Get the L.O. byte of jump table
  10878.     ldy   #stdspj\      ;[49] Get the L.O. byte of jump table
  10879. ;    sec          ;[49] Turn carry on for subtraction
  10880. ;    sbc   #$01          ;[49] Decrement the address once
  10881. ;[81]    sta   jtaddr          ;[49] Put the L.O. byte here until needed
  10882.     lda   #stdspj^      ;[49] Get the H.O. byte
  10883.     jmp    indexj        ;[57] indexed jump
  10884. ;    sbc   #$00          ;[49] And adjust for carry (borrow) if any
  10885. ;    sta   jtaddr+1      ;[49] Store that
  10886. ;    txa          ;[49] Get the offset in AC
  10887. ;    clc          ;[49] Clear the carry
  10888. ;    adc   jtaddr          ;[49] Add the L.O. byte of address
  10889. ;    tax          ;[49] Hold it here for now
  10890. ;    lda   jtaddr+1      ;[49] Get the H.O. byte of address
  10891. ;    adc   #$00          ;[49] Add in carry if there is any
  10892. ;    pha          ;[49] Push it on the stack
  10893. ;    txa          ;[49] Get modified L.O. byte again
  10894. ;    pha          ;[49] Push that
  10895. ;    rts          ;[49] Jump indexed (The Hard Way)
  10896. stdspj: jmp   stdsp3          ;[49] 2p-40
  10897.     jmp   stdsp3          ;[49] 2e-40
  10898.     ldx   #$10          ;[49] 80 col slot,Base 16
  10899.     ldy   #$00          ;[49] No special parse features
  10900.     lda   #cmnum          ;[49] Parse integer
  10901.     jsr   comnd          ;[49] Do it
  10902.           jmp     kermt4          ;[49] No integer, give error
  10903.     cpy   #$00          ;[49] H.O. byte better be 0
  10904.     bne   stdsp2          ;[49]     else, slot out of range
  10905.     cpx   #maxslt+1      ;[49] > maximum slot available?
  10906.     bpl   stdsp2          ;[49] Out of range
  10907.     cpx   #minslt          ;[49] < minimum slot available?
  10908.     bmi   stdsp2          ;[49] Out of range
  10909. ;[78]    lda    #80        ;[77] just in case card
  10910. ;[78]    sta    wndwth        ;[77] doesnt set this
  10911.     txa          ;[49] now so we can adjust
  10912.     sta   dsp2          ;[49] set 80 col card slot
  10913. ;[77]    lda    #80        ;[76] just in case card
  10914. ;[77]    sta    wndwth        ;[76] doesnt set this
  10915. ;[78]    jsr    setio2+2    ;[57] nice pr#n rtn
  10916. ;[78]    jsr    test2e        ;[58] just in case its //e 80 col
  10917. stdsp1                ;[49]
  10918.     jsr    sucout        ;[78] setup cout
  10919. ;[78]    lda   #cmcfm          ;[46] Parse for a confirm
  10920. ;[78]    jsr   comnd          ;[46] Do it
  10921. ;[78]          jmp     kermt3          ;[46] Not confirmed, tell the user that
  10922. ;[80]    jsr    prcfm        ;[78] parse & confirm
  10923. ;[80]    jmp   kermit          ;[46]
  10924.     jsr    sutljp        ;[85] set up screen distribution
  10925.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  10926. stdsp2: jmp   stddso          ;[49] got to do it this way sigh! relative
  10927. stdsp3:    lda    #ctrlz        ;[57] shut down 80 col I hope
  10928.     jsr    cout        ;[57] wonder how universal this is
  10929.     lda    #'1        ;[57] does ^Z1 really stop all 80 col videos
  10930.     jsr    cout        ;[57]
  10931.     lda    #hxon        ;[68] this is for the //e & company
  10932.     jsr    cout        ;[68] see what this does
  10933.     jmp    stdsp1        ;[57] we shall see
  10934.  
  10935. stprn:    lda   #prnkey\      ;[55] Load the address of the keyword table
  10936.     sta   cminf1          ;[55] Save it for the keyword routine
  10937.     lda   #prnkey^      ;[55]         ...
  10938.     sta   cminf1+1      ;[55]         ...
  10939.     ldy   #$00          ;[55] No special flags needed
  10940.     lda   #cmkey          ;[55] Comnd code for parse keyword
  10941.     jsr   comnd          ;[55] Go get it
  10942.           jmp     kermt2          ;[55] Give an error
  10943.     cpx   #6          ;[55] is this set slot ?
  10944.     beq   stprn0          ;[55] yes dont change on off flag
  10945.     stx   prnfg          ;[55] Set the on off flag
  10946. stprn0:              ;[55]
  10947. ;[81]    lda   #stprnj\      ;[55] Get the L.O. byte of jump table
  10948.     ldy   #stprnj\      ;[55] Get the L.O. byte of jump table
  10949. ;[81]    sta   jtaddr          ;[55] Put the L.O. byte here until needed
  10950.     lda   #stprnj^      ;[55] Get the H.O. byte
  10951. ;[81]indexj:    sta    jtaddr+1    ;[57] save the H O byte
  10952. indexj:    sty    jtaddr        ;[81] L O byte
  10953.     sta    jtaddr+1    ;[81] save the H O byte
  10954.     txa            ;[57] now a has the offset
  10955.     clc            ;[57] ready for the add
  10956.     adc    jtaddr        ;[57] add to L O byte
  10957.     sta    jtaddr        ;[57] and save it
  10958.     lda    #0        ;[57] now for the carry
  10959.     adc    jtaddr+1    ;[57] to the H O byte
  10960.     sta    jtaddr+1    ;[57] now jump is ready
  10961.     jmp    (jtaddr)    ;[57] an indexed jump
  10962. stprnj: jmp   stprn4          ;[55] off
  10963.     jmp   stprn2          ;[55] on
  10964.     ldx   #$10          ;[55] slot,Base 16
  10965.     ldy   #$00          ;[55] No special parse features
  10966.     lda   #cmnum          ;[55] Parse integer
  10967.     jsr   comnd          ;[55] Do it
  10968.           jmp     kermt4          ;[55] No integer, give error
  10969.     cpy   #$00          ;[55] H.O. byte better be 0
  10970.     bne   stdsp2          ;[55]     else, slot out of range
  10971.     cpx   #maxslt+1      ;[55] > maximum slot available?
  10972.     bpl   stdsp2          ;[55] Out of range
  10973.     cpx   #minslt          ;[55] < minimum slot available?
  10974.     bmi   stdsp2          ;[55] Out of range
  10975.     stx   prnsl          ;[55] set printer slot
  10976. ;[78]stprn1: lda   #cmcfm          ;[55] Parse for a confirm
  10977. ;[78]    jsr   comnd          ;[55] Do it
  10978. ;[78]          jmp     kermt3          ;[55] Not confirmed, tell the user that
  10979. ;[80]stprn1    jsr    prcfm        ;[78] parse & confirm
  10980. ;[80]    jsr    sutljp        ;[78] set up the tel term type jump
  10981. ;[80]    jmp   kermit          ;[55]
  10982. stprn1    jsr    sutljp        ;[80] set up the tel term type jump
  10983.     jmp    stflo7        ;[80] common rtn
  10984. stprn2:
  10985. ;[76]    lda    flowfg        ;[57] flow control ?
  10986.     lda    confg        ;[76] flow control ?
  10987.     bmi    stprn7        ;[57] yes should be ok
  10988.     ldx    #erms1c\    ;[57] warn user
  10989.     ldy    #erms1c^    ;[57] that it will not 
  10990. ;[79]    jsr    prstr        ;[57] work
  10991. ;[79]    jsr    prcrlf        ;[57]
  10992.     jsr    prstrl        ;[79]
  10993. stprn7:
  10994. ;[59]    lda   prnsl          ;[55] get printer slot
  10995. ;[59]    beq   stprne          ;[55] Error we need the slot
  10996. ;[59]stprn3: jsr   setio2+2      ;[55] Nice pr#n routine
  10997. ;[59]    jmp   stprn1          ;[55] Now return
  10998.     jsr    prnoff        ;[59] now turn printer on
  10999.     jmp    stprn1        ;[59] and finish up neatly
  11000. stprn4:                ;[55] 
  11001. ;[59]    lda   #0          ;[55] nice pr#0
  11002. ;[59]    bit    dsptyp        ;[55] do we have a video slot?
  11003. ;[59]    bpl    stprn3        ;[55] no do pr#0
  11004. ;[59]    lda    dsp2        ;[55] get video slot
  11005. ;[59]    jmp    stprn3        ;[55] and do pr#n
  11006. ;[59]stprne: sta   prnfg          ;[55] first set off
  11007. ;[59]    jmp     stddso          ;[55] now tell its a nono
  11008.     jsr    prnon        ;[59] turn printer off
  11009.     jmp    stprn1        ;[59] and finish up neatly
  11010.  
  11011. stflow:     lda   #flokey\       ;[57] Load the address of the keyword table
  11012.     sta   cminf1          ;[57] Save it for the keyword routine
  11013.     lda   #flokey^      ;[57]         ...
  11014.     sta   cminf1+1      ;[57]         ...
  11015.     ldy   #$00          ;[57] No special flags needed
  11016.     lda   #cmkey          ;[57] Comnd code for parse keyword
  11017.     jsr   comnd          ;[57] Go get it
  11018.           jmp     kermt2          ;[57] Give an error
  11019. ;[81]    lda   #stfloj\      ;[57] Get the L.O. byte of jump table
  11020. ;[81]    sta   jtaddr          ;[57] Put the L.O. byte here until needed
  11021.     ldy   #stfloj\      ;[81] Get the L.O. byte of jump table
  11022.     lda   #stfloj^      ;[57] Get the H.O. byte
  11023.     jmp    indexj    ;[57] an indexed jump
  11024. stfloj: jmp   stflo4          ;[57] off
  11025.     jmp   stflo2          ;[57] xon
  11026. stflo9:
  11027.     ldx   #10          ;[57] delay,Base 10
  11028.     ldy   #$00          ;[57] No special parse features
  11029.     lda   #cmnum          ;[57] Parse integer
  11030.     jsr   comnd          ;[57] Do it
  11031.           jmp     kermt4          ;[57] No integer, give error
  11032.     cpy   #$00          ;[57] H.O. byte better be 0
  11033.     beq   stflo1          ;[57]     else, delay too large
  11034. stflo8:    ldx    #ermes4\    ;[57] tell
  11035.     ldy    #ermes4^    ;[57] user its too big
  11036. ;[79]    jsr    prstr        ;[57]
  11037. ;[79]    jsr    prcrlf        ;[57]
  11038.     jsr    prstrl        ;[79]
  11039.     jmp    kermit        ;[57] try again
  11040. stflo1: stx    flowdl        ;[57] set the delay time in ms
  11041. ;[78]stflo7:    lda    #cmcfm        ;[57] parse for a comfirm
  11042. ;[78]    jsr    comnd        ;[57] do it
  11043. ;[78]    jmp    kermt3        ;[57] not confirmed tell user
  11044. stflo7    jsr    prcfm        ;[78] parse & confirm
  11045.     jmp    kermit        ;[57] next
  11046. stflo4: lda    #0        ;[57] flow off
  11047. ;[76]stflo3: sta    flowfg        ;[57]
  11048. stflo3: sta    confg        ;[76]
  11049.     jmp    stflo7        ;[57]
  11050. stflo2: lda    #$80        ;[57] xon
  11051.     jmp    stflo3        ;[57]
  11052.  
  11053. sttmct    ldx    #10        ;[85] set timing base 10
  11054.     ldy    #0        ;[85] nothing special
  11055.     lda    #cmnum        ;[85] need an integer
  11056.     jsr    comnd        ;[85] get it
  11057.     jmp    kermt4        ;[85] que passo
  11058.     stx    timect        ;[85] set default timing - forget about parse error
  11059.     jmp    stflo7        ;[85] common parse, confirm & rtn to kermit
  11060.  
  11061. stpre                ;[59] set prodos prefix
  11062.     lda   #$80          ;[59] Reset all break characters
  11063.     jsr   rstbrk          ;[59]         ...
  11064.     lda   #cr          ;[59]         ...
  11065.     jsr   setbrk          ;[59]         ...
  11066.     lda   #lf          ;[59]         ...
  11067.     jsr   setbrk          ;[59]         ...
  11068.     lda   #ffd          ;[59]         ...
  11069.     jsr   setbrk          ;[59]         ...
  11070.     lda   #esc          ;[59]         ...
  11071.     jsr   setbrk          ;[59]         ...
  11072.     lda    #sp        ;[59] we need a space terminator also
  11073.     jsr    setbrk        ;[59]
  11074.     ldy   #$00          ;[59]         ...
  11075.     lda   #cmtxt          ;[59] Parse for text
  11076.     jsr   comnd          ;[59] Do it
  11077.           jmp     kermta          ;[59] Found null string
  11078.     cmp    #64         ;[59] Larger than the set packet size?
  11079.     bmi   stpre1          ;[59] No, continue
  11080.     lda    #64         ;[59] Yes, it will have to be truncated
  11081. stpre1    sta   kwrk01          ;[59] Store packet size for Kercpy
  11082.     sta    prefix        ;[59] start of prefix is # of chs in prefix
  11083.     lda   #prefix+1\      ;[59] Point to the data buffer as destination
  11084.     sta   kerto          ;[59]         ...
  11085.     lda   #prefix+1^      ;[59]         ...
  11086.     sta   kerto+1          ;[59]         ...
  11087.     stx   kerfrm          ;[59] Point to the atom buffer from Comnd
  11088.     sty   kerfrm+1      ;[59]     as the source address
  11089.     jsr   kercph          ;[59] Copy the string with high bit set
  11090.     ldy    kwrk01        ;[59] now for trailing null
  11091.     lda    #0        ;[59]
  11092.     sta    (kerto),y    ;[59]
  11093.     jsr    prodos        ;[59] now see if its a good prefix
  11094.     .byte    setpre        ;[59]
  11095.     .word    predel        ;[59] and the par list
  11096.     bcc    .+5        ;[59] a good prefix
  11097.     jsr    perror        ;[59] tattle
  11098.     jmp    kermit        ;[59]
  11099.  
  11100. stcd    lda    dosflg        ;[87] is this prodos?
  11101.     bne    stpre        ;[87] yes
  11102. stddsk: lda   #ddskey\      ;[40] Set up keyword table pointer
  11103.     sta   cminf1          ;[40]         ...
  11104.     lda   #ddskey^      ;[40]         ...
  11105.     sta   cminf1+1      ;[40]         ...
  11106.     ldy   #$00          ;[40] No special features
  11107.     lda   #cmkey          ;[40] We are looking for a keyword
  11108.     jsr   comnd          ;[40] Do the call to find the keyword
  11109.           jmp     kermt2          ;[40] Nope, we lost
  11110. ;[81]    lda   #stddjt\      ;[40] Fetch the address of the jump table
  11111. ;[81]    sta   jtaddr          ;[40] Stuff it in a hold area for now
  11112.     ldy   #stddjt\      ;[81] Fetch the address of the jump table
  11113.     lda   #stddjt^      ;[40] Do H.O. byte
  11114.     jmp    indexj        ;[57] an indexed jump
  11115.  
  11116. stddjt: jmp   stdddr          ;[40] Set drive
  11117.     jmp    stddsl        ;[60] set slot
  11118.     ldx    #10        ;[60] set vol base 10
  11119.     ldy    #0        ;[60] nothing special
  11120.     lda    #cmnum        ;[60] need an integer
  11121.     jsr    comnd        ;[60] get it
  11122.     jmp    kermt4        ;[60] que passo
  11123. ;[81]    sta    defvol        ;[80] set default vol - forget about parse error
  11124.     stx    defvol        ;[81] set default vol - forget about parse error
  11125. ;[80]    stx    ksavex        ;[60] save while we confirm
  11126. ;[78]    lda    #cmcfm        ;[60] 
  11127. ;[78]    jsr    comnd        ;[60] how about it?
  11128. ;[78]    jmp    kermt3        ;[60] no confirm
  11129. ;[80]    jsr    prcfm        ;[78] parse & confirm
  11130. ;[80]    lda    ksavex        ;[60] finally set the vol
  11131. ;[80]    sta    defvol        ;[60]
  11132. ;[80]    jmp    kermit        ;[60] around we go
  11133.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  11134. stddsl: ldx   #$10          ;[40] Base 16
  11135.     ldy   #$00          ;[40] No special parse features
  11136.     lda   #cmnum          ;[40] Parse integer
  11137.     jsr   comnd          ;[40] Do it
  11138.           jmp     kermt4          ;[40] No integer, give error
  11139.     cpy   #$00          ;[40] H.O. byte better be 0
  11140.     bne   stddso          ;[40]     else, slot out of range
  11141.     cpx   #maxslt+1      ;[40] > maximum slot available?
  11142.     bpl   stddso          ;[40] Out of range
  11143.     cpx   #minslt          ;[40] < minimum slot available?
  11144.     bmi   stddso          ;[40] Out of range
  11145. ;[80]    stx   ksavex          ;[40] Save while we parse the confirm
  11146. ;[81]    sta   defslt          ;[80] set default slot - forget about parse error
  11147.     stx   defslt          ;[81] set default slot - forget about parse error
  11148. ;[78]    lda   #cmcfm          ;[40] Set up token for confirm
  11149. ;[78]    jsr   comnd          ;[40] Parse it
  11150. ;[78]          jmp     kermt3          ;[40] Lost, no confirm
  11151. ;[80]    jsr    prcfm        ;[78] parse & confirm
  11152. ;[80]    lda   ksavex          ;[40] Fetch the saved value
  11153. ;[80]    sta   defslt          ;[40] Place it where it belongs
  11154. ;[80]    jmp   kermit          ;[40] Jump to top again
  11155.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  11156. stdddr: ldx   #$10          ;[40] Base 16
  11157.     ldy   #$00          ;[40] No special features about parse
  11158.     lda   #cmnum          ;[40] Parse an integer
  11159.     jsr   comnd          ;[40] Do it
  11160.           jmp     kermt4          ;[40] Didn't find an integer
  11161.     cpy   #$00          ;[40] H.O. byte should be zero
  11162.     bne   stdddo          ;[40] Otherwise we are way out of range
  11163.     cpx   #maxdrv+1      ;[40] > maximum drive number available?
  11164.     bpl   stdddo          ;[40] Yup, out of range
  11165.     cpx   #mindrv          ;[40] < minimum drive number available?
  11166.     bmi   stdddo          ;[40] Out of range
  11167. ;[80]    stx   ksavex          ;[40] Save while we parse confirm
  11168. ;[81]    sta   defdrv          ;[80] set default drive - forget about parse error
  11169.     stx   defdrv          ;[81] set default drive - forget about parse error
  11170. ;[78]    lda   #cmcfm          ;[40] Set up to parse confirm
  11171. ;[78]    jsr   comnd          ;[40] Do it
  11172. ;[78]          jmp     kermt3          ;[40] Wasn't properly confirmed
  11173. ;[80]    jsr    prcfm        ;[78] parse & confirm
  11174. ;[80]    lda   ksavex          ;[40] Fetch back the data
  11175. ;[80]    sta   defdrv          ;[40] Stuff it where it belongs
  11176. ;[80]    jmp   kermit          ;[40] Jump to top again
  11177.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  11178.  
  11179. stdddo: ldx   #ermesf\      ;[40] Fetch the address of the error
  11180.     ldy   #ermesf^      ;[40]         ...
  11181. ;[79]    jsr   prstr          ;[40] Print the text
  11182. ;[79]    jsr   prcrlf          ;[40] Follow with a crelf
  11183.     jsr    prstrl        ;[79]
  11184.     jmp   kermit          ;[40] Return to top
  11185.  
  11186.  
  11187. stddso: ldx   #ermese\      ;[40] Tell user about the range error
  11188.     ldy   #ermese^      ;[40]         ...
  11189. ;[79]    jsr   prstr          ;[40] Print the error text
  11190. ;[79]    jsr   prcrlf          ;[40] Print a crelf
  11191.     jsr    prstrl        ;[79]
  11192.     jmp   kermit          ;[40] Go to top
  11193.  
  11194. stbaud: lda   #baukey\      ;[47] Set the baud for ssc
  11195.     sta   cminf1      ;[47] ready keyword routine
  11196.     lda   #baukey^      ;[47]
  11197.     sta   cminf1+1      ;[47]
  11198.     ldy   #0      ;[47] 
  11199.     lda   #cmkey      ;[47] tell its keyword search
  11200.     jsr   comnd      ;[47] and do it
  11201.     jmp   kermt2      ;[47] its an error
  11202.     sty   sscdbd      ;[47] save baud index
  11203. ;[78]    lda   #cmcfm      ;[47] now for the confirm
  11204. ;[78]    jsr   comnd      ;[47]
  11205. ;[78]    jmp     kermt3      ;[47]
  11206. ;[80]    jsr    prcfm        ;[78] parse & confirm
  11207.     lda   #$b      ;[54] baud command
  11208.     jsr   tl0cmd      ;[54] tell com card about it
  11209. ;[80]    jmp   kermit      ;[47] arround we go again
  11210.     jmp    stflo7        ;[80] common parse, confirm & rtn to kermit
  11211.  
  11212.  
  11213.  
  11214. .SBTTL    Show  routine
  11215.  
  11216. ;
  11217. ;     This routine shows any of the operational parameters that
  11218. ;     can be altered with the set command.
  11219. ;
  11220. ;         Input:     Parameters from command line
  11221. ;
  11222. ;         Output:     Display parameter values on screen
  11223. ;
  11224. ;         Registers destroyed:     A,X,Y
  11225. ;
  11226.  
  11227. show:    lda   #shocmd\      ; Load address of keyword table
  11228.     sta   cminf1          ; Save it for the keyword routine
  11229.     lda   #shocmd^      ;         ...
  11230.     sta   cminf1+1      ;         ...
  11231.     lda   #shodef\      ;[13] Fetch default address
  11232.     sta   cmdptr          ;[13]         ...
  11233.     lda   #shodef^      ;[13]         ...
  11234.     sta   cmdptr+1      ;[13]         ...
  11235.     ldy   #cmfdff          ;[13] Indicate that there is a default
  11236.     lda   #cmkey          ; Comnd code to parse keyword
  11237.     jsr   comnd          ; Go parse the keyword
  11238.           jmp     kermt2          ; Bad keyword, go give an error
  11239.     cpx    #shrc\        ;[82] exception
  11240.     bne    show3        ;[82] for confirm? no
  11241.     cpy    #shrc^        ;[82] maybe
  11242.     beq    xjsr        ;[82] yes
  11243. show3    cpx    #shsn\        ;[82] how about this one
  11244.     bne    show7        ;[82] no
  11245.     cpy    #shsn^        ;[82] maybe
  11246.     beq    xjsr        ;[82] yes
  11247. show7    stx    xjsr1+1        ;[82] needed later
  11248.     sty    xjsr1+2        ;[82]
  11249.     jsr    prcfm        ;[82] parse for confirm
  11250.     jmp    xjsr1        ;[82]
  11251. xjsr    stx    xjsr1+1        ;[82] now set up the 
  11252.     sty    xjsr1+2        ;[82] for the jsr
  11253. xjsr1    jsr    xjsr1        ;[82]
  11254.     jmp    kermit        ;[82]
  11255. ;[81]    lda   #shocmb\      ;[9] Get the L.O. byte of jump table
  11256. ;[81]    sta   jtaddr          ;[9] Put the L.O. byte here until needed
  11257. ;[82]    ldy   #shocmb\      ;[81] Get the L.O. byte of jump table
  11258. ;[82]    lda   #shocmb^      ;[9] Get the H.O. byte
  11259. ;[82]    jmp    indexj        ;[57] an indexed jump
  11260. ;[82]shocmb: jsr   prcfm          ; Parse for confirm
  11261. ;[82]    jsr   shall          ; Show all setable parameters
  11262. ;[82]    jmp   kermit          ; Go to top of main loop
  11263. ;[82]shoesc    jsr   prcfm          ; Parse for confirm
  11264. ;[82]    jsr   shesc          ; Show escape character
  11265. ;[82]    jmp   kermit          ; Go to top of main loop
  11266. ;[68]    jsr   prcfm          ; Parse for confirm
  11267. ;[68]    jsr   shibm          ; Show ibm-mode switch
  11268. ;[68]    jmp   kermit          ; Go to top of main loop
  11269. ;[82]shole    jsr   prcfm          ; Parse for confirm
  11270. ;[82]    jsr   shle          ; Show local-echo switch
  11271. ;[82]    jmp   kermit          ; Go to top of main loop
  11272. ;[82]shorc    nop          ; We should not parse for confirm
  11273. ;[82]    nop          ;     since this routine parses for
  11274. ;[82]    nop          ;     a keyword next
  11275. ;[82]    jsr   shrc          ; Show receive parameters
  11276. ;[82]    jmp   kermit          ; Go to top of main loop
  11277. ;[82]shosn    nop          ; We should not parse for confirm
  11278. ;[82]    nop          ;     since this routine parses for
  11279. ;[82]    nop          ;     a keyword next
  11280. ;[82]    jsr   shsn          ; Show send parameters
  11281. ;[82]    jmp   kermit          ; Go to top of main loop
  11282. ;[82]shovt    jsr   prcfm          ; Parse for confirm
  11283. ;[82]    jsr   shvt          ; Show vt52-emulation mode switch
  11284. ;[82]    jmp   kermit          ; Go to top of main loop
  11285. ;[82]shofw    jsr   prcfm          ; Parse for confirm
  11286. ;[82]    jsr   shfw          ; Show file-warning switch
  11287. ;[82]    jmp   kermit          ; Go to top of main loop
  11288. ;[72]shoeb    jsr   prcfm          ; Parse for confirm
  11289. ;[72]    jsr   sheb          ; Show eight-bit-quoting switch
  11290. ;[72]    jmp   kermit          ; Go to top of main loop
  11291. ;[82]shodb    jsr   prcfm          ; Parse for confirm
  11292. ;[82]    jsr   shdb          ; Show debugging mode switch
  11293. ;[82]    jmp   kermit          ; Go to top of main loop
  11294. ;[82]shomod    jsr   prcfm          ; Parse for confirm
  11295. ;[82]    jsr   shmod          ; Show File mode
  11296. ;[82]    jmp   kermit          ; Go to top of main loop
  11297. ;[65]    jsr   prcfm          ; Parse for confirm
  11298. ;[65]    jsr   shfbs          ; Show the file-byte-size
  11299. ;[65]    jmp   kermit          ; Go to top of main loop
  11300. ;[82]shocot    jsr   prcfm          ;[12] Parse for confirm
  11301. ;[82]    jsr   shslot          ;[12] Show the I/O index
  11302. ;[82]    jmp   kermit          ;[12] Go to top of main loop
  11303. ;[82]shocdr    jsr   prcfm          ;[12] Parse for confirm
  11304. ;[82]    jsr   shddr          ;[12] Show Device-driver
  11305. ;[82]    jmp   kermit          ;[12] Go to top of main loop
  11306. ;[82]shocri    jsr   prcfm          ;[21] Parse for confirm
  11307. ;[82]    jsr   shpari          ;[21] Show parity
  11308. ;[82]    jmp   kermit          ;[21] Go to top of main loop
  11309. ;[82]shocbd    jsr   prcfm          ;[35] Parse for confirm.
  11310. ;[82]    jsr   shkbd          ;[35] Show keyboard type.
  11311. ;[82]    jmp   kermit          ;[35] Go to top of main loop.
  11312. ;[82]shocsk    jsr   prcfm          ;[40] Parse for confirm.
  11313. ;[82]    jsr   shddsk          ;[40] Show default disk.
  11314. ;[82]    jmp   kermit          ;[40] Go to top of main loop.
  11315. ;[82]shocpy    jsr   prcfm          ;[46] Parse for confirm.
  11316. ;[82]    jsr   shdspy          ;[46] show the display type
  11317. ;[82]    jmp   kermit          ;[46] and return
  11318. ;[82]shocud    jsr   prcfm      ;[47] parse for confirm
  11319. ;[82]    jsr   shbaud      ;[47] show baud rate
  11320. ;[82]    jmp     kermit      ;[47] around the loop again
  11321. ;[82]shocrn    jsr   prcfm      ;[55] parse for confirm
  11322. ;[82]    jsr   shprn      ;[55] show printer
  11323. ;[82]    jmp     kermit      ;[55] around the loop again
  11324. ;[82]shocow    jsr   prcfm      ;[57] parse for confirm
  11325. ;[82]    jsr   shflow       ;[57] show flow control
  11326. ;[82]    jmp     kermit      ;[57] around the loop again
  11327. ;[82]shocog    jsr   prcfm      ;[56] parse for confirm
  11328. ;[82]    jsr   shlog       ;[56] show log
  11329. ;[82]    jmp     kermit      ;[56] around the loop again
  11330. ;[82]shocmr    jsr   prcfm      ;[64] parse for confirm
  11331. ;[82]    jsr   shtmr       ;[64] show timer
  11332. ;[82]    jmp     kermit      ;[64] around the loop again
  11333. ;[82]shoswp    jsr    prcfm        ;[73] confirm parse
  11334. ;[82]    jsr    shswp        ;[73] swap bs & del keypress
  11335. ;[82]    jmp    kermit        ;[73]
  11336. ;[82]shokp    jsr    prcfm        ;[80] confirm parse
  11337. ;[82]    jsr    shkp        ;[80] keypad
  11338. ;[82]    jmp    kermit        ;[80]
  11339. ;shokpa    jsr    prcfm        ;[80] confirm parse
  11340. ;    jsr    shkpa        ;[80] keypad application mode
  11341. ;    jmp    kermit        ;[80]
  11342. ;[82]shokco    jsr    prcfm        ;[80] confirm parse
  11343. ;[82]    jsr    shcko        ;[80] cursor keys only in vt100 mode
  11344. ;[82]    jmp    kermit        ;[80]
  11345.  
  11346. ;[83]shall    jsr   shdb          ; Show debugging mode switch
  11347. shall:                ;[83]
  11348.     ldx    #versio\    ;[83] tell what version kermit
  11349.     ldy    #versio^    ;[83] is also
  11350.     jsr    prstrl        ;[83] prints string & cr
  11351.     jsr   shdb          ;[83] Show debugging mode switch
  11352.     jsr   shvt          ; Show vt52-emulation mode switch
  11353. ;[68]    jsr   shibm          ;[21] Show ibm-mode switch
  11354.     jsr   shle          ; Show local-echo switch
  11355.     jsr   shpari          ;[21] Show parity setting
  11356. ;[72]    jsr   sheb          ; Show eight-bit-quoting switch
  11357.     jsr   shfw          ; Show file-warning switch
  11358.     jsr   shesc          ; Show the current escape character
  11359.     jsr   shmod          ; Show the file-type mode
  11360. ;[65]    jsr   shfbs          ; Show the file-byte-size
  11361.     jsr   shslot          ;[12] Show the I/O index
  11362.     jsr   shddr          ;[12] Show the device-driver begin used
  11363.     jsr   shkbd          ;[35] Show keyboard type.
  11364.     jsr   shdspy          ;[46] Show display type.
  11365.     jsr   shddsk          ;[40] Show default disk.
  11366.     jsr   shbaud      ;[47] yes,show baud rate
  11367.     jsr   shprn          ;[55] show printer info
  11368.     jsr    shlog        ;[56] show log
  11369.     jsr    shflow        ;[57] show flow control 
  11370.     jsr    shtmr        ;[64] show timer
  11371.     jsr    shswp        ;[73] show swap bs & del keypress
  11372.     jsr    shkp        ;[80] show keypad
  11373. ;    jsr    shkpa        ;[80] show keypad application mode
  11374.     jsr    shcko        ;[80] show cursor keys only
  11375.     jsr    shprt        ;[83] show protocol
  11376.     jsr    shcs        ;[87] show clear screen flag
  11377. ;[86]    jsr    shtmct        ;[85] show timing constant
  11378.     jmp    shtmct        ;[86] show timing constant
  11379. ;[86]    jsr   shrcal          ; Show receive parameters
  11380. ;[80]    jsr   shsnal          ; Show send parameters
  11381. ;[86]    jmp   shsnal          ;[80] Show send parameters
  11382. ;[80]    rts          ; Return
  11383.  
  11384. shdb:    ldx   #shin00\      ;[26] Get address of 'debug mode' string
  11385.     ldy   #shin00^      ;[26]         ...
  11386.     lda    shin00        ;[87]
  11387. ;[87]    jsr   prstr          ;[26] Print that
  11388.     jsr   prncfm        ;[87] Print that
  11389.     lda   debug          ;[26] Get the debug mode
  11390.     cmp   #$03          ;[26] Is it >= 3?
  11391.     bmi   shdb1          ;[26] If not just get the string and print it
  11392.     lda   #$00          ;[26] This is index for debug mode we want
  11393. shdb1:    tax          ;[26] Hold this index
  11394.     lda   #kerdms\      ;[26] Get the address of the device strings
  11395.     sta   kermbs          ;[26] And stuff it here for genmad
  11396.     lda   #kerdms^      ;[26]         ...
  11397.     sta   kermbs+1      ;[26]         ...
  11398.     lda   #kerdsz          ;[26] Get the string length
  11399.     pha          ;[26] Push that
  11400.     txa          ;[26] Fetch the index back
  11401.     pha          ;[26] Push that parm then
  11402.     jsr   genmad          ;[26]     call genmad
  11403. ;[79]    jsr   prstr          ;[26] Print the the string at that address
  11404. ;[79]    jsr   prcrlf          ;[26] Print a crelf after it
  11405.     jmp    prstrl        ;[79] let it do the rts
  11406. ;[79]    rts
  11407.  
  11408. shlog:    ldx    #shin28\    ;[56] tell about log
  11409.     ldy    #shin28^    ;[56]
  11410.     lda    shin28        ;[87]
  11411. ;[87]    jsr    prstr        ;[56] first say log
  11412.     jsr    prncfm        ;[87] first say log
  11413.     lda    logfg        ;[56] is log on ?
  11414.     bmi    shlog1        ;[56] yes
  11415.     jmp    pron        ;[56] let routine print off
  11416. shlog1:    ldx    #shon\        ;[56] say on
  11417.     ldy    #shon^        ;[56] with a trailing space
  11418.     jsr    prstr        ;[56]
  11419.     ldx    #shin29\    ;[56] now for file=
  11420.     ldy    #shin29^    ;[56]
  11421.     jsr    prstr        ;[56]
  11422. ;[66]    ldy    nfcb1        ;[59] # chs in name
  11423. ;[66]    lda    fcb1,y        ;[59] null terminate string
  11424. ;[66]    pha            ;[59] save current member
  11425. ;[66]    lda    #0        ;[59]
  11426. ;[66]    sta    fcb1,y        ;[59]
  11427.     lda    nfcb1        ;[66] get length of string
  11428.     ldx    #fcb1\        ;[56] now the file name
  11429.     ldy    #fcb1^        ;[56]
  11430. ;[66]    jsr    prstr        ;[56]
  11431.     jsr    prstrn        ;[66]
  11432.     jmp    prcrlf        ;[56] let this routine do the rts
  11433. ;[66]    jsr    prcrlf        ;[59]
  11434. ;[66]    ldy    nfcb1        ;[59] restore current member
  11435. ;[66]    pla            ;[59]
  11436. ;[66]    sta    fcb1,y        ;[59]
  11437. ;[66]    rts            ;[59]
  11438.  
  11439. shvt:    ldx   #shin01\      ; Get address of message for this item
  11440.     ldy   #shin01^      ;         ...
  11441.     lda    shin01        ;[87]
  11442. ;[87]    jsr   prstr          ; Print that message
  11443.     jsr   prncfm          ;[87] Print that message
  11444. ;[76]    lda   vtmod          ; Get the switch value
  11445.     lda   #terstr\          ;[76] Get the address of the display strings
  11446.     sta   kermbs          ;[76] And stuff it here for genmad
  11447.     lda   #terstr^          ;[76]         ...
  11448.     sta   kermbs+1      ;[76]         ...
  11449.     lda   #terlen          ;[76] Get the string length
  11450.     pha          ;[76] Push that
  11451.     lda   vtmod          ;[76] Get the switch value
  11452.     pha          ;[76] Push that parm then
  11453.     jsr   genmad          ;[76]     call genmad
  11454.     jsr   prstr          ;[76] Print the the string at that address
  11455.     ldx   #shin2d\      ;[78] Get address of message for this item
  11456.     ldy   #shin2d^      ;[78]         ...
  11457.     jsr   prstr          ;[78] Print that message
  11458.     lda    wrapar        ;[78]
  11459.     jmp    pron        ;[78] print wraparound 
  11460. ;[78]    jsr   prcrlf          ;[76] Print a crelf after it
  11461. ;[78]    rts          ;[76]
  11462. ;[76]    jmp   pron          ; Go print the 'on' or 'off' string
  11463.  
  11464. ;shibm:    ldx   #shin02\      ; Get address of message for this item
  11465. ;    ldy   #shin02^      ;         ...
  11466. ;    jsr   prstr          ; Print that message
  11467. ;    lda   ibmmod          ; Get the switch value
  11468. ;    jmp   pron          ; Go print the 'on' or 'off' string
  11469.  
  11470. shtmr:    ldx   #shin2b\      ;[64] Get address of message for this item
  11471.     ldy   #shin2b^      ;[64]         ...
  11472.     lda    shin2b        ;[87]
  11473. ;[87]    jsr   prstr          ;[64] Print that message
  11474.     jsr   prncfm          ;[87] Print that message
  11475.     lda   timer          ;[64] Get the switch value
  11476.     jmp   pron          ;[64] Go print the 'on' or 'off' string
  11477. shswp    ldx    #shin2c\    ;[73] message about
  11478.     ldy    #shin2c^    ;[73] swaping bs & del keypress
  11479.     lda    shin2c        ;[87]
  11480. ;[87]    jsr    prstr        ;[73]
  11481.     jsr    prncfm        ;[87]
  11482.     lda    swapf        ;[73] now for the on/off
  11483.     jmp    pron        ;[73] print it and let it return
  11484. ;[87]shkp    ldx    #shin2e\    ;[80] message about
  11485. ;[87]    ldy    #shin2e^    ;[80] keypad vt100
  11486. ;[87]    jsr    prstr        ;[80]
  11487. ;[87]    lda    kpfl        ;[80] now for the on/off
  11488. ;[81]    jmp    pron        ;[80] print it and let it return
  11489. ;[87]    jsr    pronnr        ;[81] print it
  11490. shkp                ;[87]
  11491.     ldx    #shin2f\    ;[81] message about
  11492.     ldy    #shin2f^    ;[81] keypad application mode vt100
  11493.     lda    shin2f        ;[87]
  11494. ;[87]    jsr    prstr        ;[81]
  11495.     jsr    prncfm        ;[87]
  11496.     lda    kpafl        ;[81] now for the on/off
  11497.     jmp    pron        ;[81] print it and let it return
  11498. ;shkpa    ldx    #shin2f\    ;[80] message about
  11499. ;    ldy    #shin2f^    ;[80] keypad application mode vt100
  11500. ;    jsr    prstr        ;[80]
  11501. ;    lda    kpafl        ;[80] now for the on/off
  11502. ;    jmp    pron        ;[80] print it and let it return
  11503. shcko    ldx    #shin2g\    ;[80] message about
  11504.     ldy    #shin2g^    ;[80] cursor keys only in vt100 mode
  11505.     lda    shin2g        ;[87]
  11506. ;[87]    jsr    prstr        ;[80]
  11507.     jsr    prncfm        ;[87]
  11508.     lda    ckfl        ;[80] now for the on/off
  11509.     jmp    pron        ;[80] print it and let it return
  11510.  
  11511. shle:    ldx   #shin03\      ; Get address of message for this item
  11512.     ldy   #shin03^      ;         ...
  11513.     lda    shin03
  11514. ;[87]    jsr   prstr          ; Print that message
  11515.     jsr   prncfm          ;[87] Print that message
  11516.     lda   lecho          ; Get the switch value
  11517.     jmp   pron          ; Go print the 'on' or 'off' string
  11518.  
  11519. shcs    lda    setcs        ;[87] first the count
  11520.     ldx   #setcs\        ;[87] Get address of message for this item
  11521.     ldy   #setcs^        ;[87]
  11522.     jsr   prncfm        ;[87] Print that message
  11523.     lda   csfg        ;[87] Get the switch value
  11524.     jmp   pron        ;[87] Go print the 'on' or 'off' string
  11525.  
  11526. ;[72]sheb:    ldx   #shin04\      ; Get address of message for this item
  11527. ;[72]    ldy   #shin04^      ;         ...
  11528. ;[72]    jsr   prstr          ; Print that message
  11529. ;[72]    lda   ebqmod          ; Get the switch value
  11530. ;[72]    jmp   pron          ; Go print the 'on' or 'off' string
  11531.  
  11532. shfw:    ldx   #shin05\      ; Get address of message for this item
  11533.     ldy   #shin05^      ;         ...
  11534.     lda   shin05      ;[87]         ...
  11535. ;[87]    jsr   prstr          ; Print that message
  11536.     jsr   prncfm          ;[87] Print that message
  11537.     lda   filwar          ; Get the switch value
  11538.     jmp   pron          ; Go print the 'on' or 'off' string
  11539.  
  11540. shesc:    ldx   #shin06\      ; Get address of message
  11541.     ldy   #shin06^      ;         ...
  11542.     lda   shin06      ;[87]         ...
  11543. ;[87]    jsr   prstr          ; Print message
  11544.     jsr   prncfm          ;[87] Print message
  11545.     lda   escp          ; Get the escape character
  11546. ;[79]    jsr   prchr          ; Print the special character
  11547. ;[79]    jsr   prcrlf          ; Print a crelf
  11548.     jmp    prchrr        ;[79] cntl chs, crlf & let it rts
  11549. ;[79]    rts          ;     and return
  11550.  
  11551. shsn:    lda   #$01          ; Set up index to be used later
  11552.     sta   srind          ;         ...
  11553.     lda   #stscmd\      ; Get the set option table address
  11554.     sta   cminf1          ;     and save it as a parm to cmkey
  11555.     lda   #stscmd^      ;         ...
  11556.     sta   cminf1+1      ;         ...
  11557.     ldy   #$00          ;[13] No special flags needed
  11558.     lda   #cmkey          ; Code for keyword parse
  11559.     jsr   comnd          ; Try to parse it
  11560.           jmp     kermt2          ; Invalid keyword
  11561.     stx   kwrk01          ; Hold offset into jump table
  11562.     jsr   prcfm          ; Parse and print a confirm
  11563. ;[82]    lda   kwrk01          ; Get the value back
  11564.     ldx   kwrk01          ;[82] Get the value back
  11565. ;[82]    clc          ; Clear the carry flag
  11566. ;[82]    adc   kwrk01          ; Now double the value to provide the
  11567.               ;     neccesary index
  11568. ;[82]    tax        ;[57] save the offset in x
  11569. ;[81]    lda   #shcmb\          ;[9] Get the L.O. byte of jump table
  11570. ;[81]    sta   jtaddr          ;[9] Put the L.O. byte here until needed
  11571.     ldy   #shcmb\          ;[81] Get the L.O. byte of jump table
  11572.     lda   #shcmb^          ;[9] Get the H.O. byte
  11573.     jmp    indexj        ;[57] an indexed jump
  11574.  
  11575. shrc:    lda   #$00          ; Set up index to be used later
  11576.     sta   srind          ;         ...
  11577.     lda   #stscmd\      ; Get the set option table address
  11578.     sta   cminf1          ;     and save it as a parm to cmkey
  11579.     lda   #stscmd^      ;         ...
  11580.     sta   cminf1+1      ;         ...
  11581.     ldy   #$00          ;[13] No special flags needed
  11582.     lda   #cmkey          ; Code for keyword parse
  11583.     jsr   comnd          ; Try to parse it
  11584.           jmp     kermt2          ; Invalid keyword
  11585.     stx   kwrk01          ; Hold offset into jump table
  11586.     jsr   prcfm          ; Parse and print a confirm
  11587. ;[82]    lda   kwrk01          ; Get the value back
  11588.     ldx   kwrk01          ;[82] Get the value back
  11589. ;[82]    clc          ; Clear the carry flag
  11590. ;[82]    adc   kwrk01          ; Now double the value to provide the
  11591. ;[82]    tax          ;[57]     neccesary index
  11592. ;[81]    lda   #shcmb\          ;[9] Get the L.O. byte of jump table
  11593. ;[81]    sta   jtaddr          ;[9] Put the L.O. byte here until needed
  11594.     ldy   #shcmb\          ;[81] Get the L.O. byte of jump table
  11595.     lda   #shcmb^          ;[9] Get the H.O. byte
  11596.     jmp    indexj    ;[57] indexed jump
  11597.  
  11598. ;[82]shcmb:    jsr   shpdc          ; Show send/rec padding character
  11599. shcmb:    jmp   shpdc          ;[82] Show send/rec padding character
  11600. ;[82]    jmp   kermit          ; Go back
  11601. ;[82]    jsr   shpad          ; Show amount of padding for send/rec
  11602.     jmp   shpad          ;[82] Show amount of padding for send/rec
  11603. ;[82]    jmp   kermit          ; Go back
  11604. ;[82]    jsr   shebq          ; Show send/rec eight-bit-quoting character
  11605.     jmp   shebq          ;[82] Show send/rec eight-bit-quoting character
  11606. ;[82]    jmp   kermit          ; Go back
  11607. ;[82]    jsr   sheol          ; Show send/rec end-of-line character
  11608.     jmp   sheol          ;[82] Show send/rec end-of-line character
  11609. ;[82]    jmp   kermit          ; Go back
  11610. ;[82]    jsr   shpl          ; Show send/rec packet length
  11611.     jmp   shpl          ; [82]Show send/rec packet length
  11612. ;[82]    jmp   kermit          ; Go back
  11613. ;[82]    jsr   shqc          ; Show send/rec quote character
  11614.     jmp   shqc          ; [82]Show send/rec quote character
  11615. ;[82]    jmp   kermit          ; Go back
  11616. ;[82]    jsr   shtim          ; Show send/rec timeout
  11617.     jmp   shtim          ;[82] Show send/rec timeout
  11618. ;[82]    jmp   kermit          ; Go back
  11619.     jmp   shsop          ;[82] Show send/rec start of packet
  11620. ;[82]    jmp   kermit          ;[82] Go back
  11621. shcrlf    ldx    #shin2j\    ;[84] must follow above ************
  11622.     ldy    #shin2j^    ;[84]
  11623.     jsr    prstr        ;[84] tell option
  11624.     ldx    srind        ;[84] is this rec/send?
  11625.     lda    xcrlf,x        ;[84] on/off
  11626.     jmp    pron        ;[84] print the on/off
  11627.  
  11628. shsop:    ldx   #shin2h\      ;[82] Get address of 'sop char' string
  11629.     ldy   #shin2h^      ;[82]         ...
  11630.     lda   shin2h      ;[87]
  11631. ;[87]    jsr   prstr          ;[82] Print that
  11632.     jsr   prncfm          ;[87] Print that
  11633.     ldx   srind          ;[82] Load index so we print correct parm
  11634.     lda   sop,x          ;[82] If index is 1, this gets spadch
  11635.     jmp    prchrr        ;[82] cntl chs, crlf & let it rts
  11636. shpdc:    ldx   #shin11\      ; Get address of 'pad char' string
  11637.     ldy   #shin11^      ;         ...
  11638.     lda   shin11      ;[87]         ...
  11639. ;[87]    jsr   prstr          ; Print that
  11640.     jsr   prncfm          ;[87] Print that
  11641.     ldx   srind          ; Load index so we print correct parm
  11642.     lda   padch,x          ; If index is 1, this gets spadch
  11643. ;[79]    jsr   prchr          ; Print the special character
  11644. ;[79]    jsr   prcrlf          ; Print a crelf after it
  11645.     jmp    prchrr        ;[79] cntl chs, crlf & let it rts
  11646. ;[79]    rts
  11647. shpad:    ldx   #shin12\      ; Get address of 'padding amount' string
  11648.     ldy   #shin12^      ;         ...
  11649.     lda   shin12      ;[87]         ...
  11650. ;[87]    jsr   prstr          ; Print that
  11651.     jsr   prncfm          ;[87] Print that
  11652.     ldx   srind          ; Load index so we print correct parm
  11653.     lda   pad,x          ; If index is 1, this gets spad
  11654. ;[79]    jsr   prbyte          ; Print the amount of padding
  11655. ;[79]    jsr   prcrlf          ; Print a crelf after it
  11656.     jmp    prbytl        ;[79] pr byte in hex, crlf & let it rts
  11657. ;    jmp    prbydr        ;[87] pr byte in ascii & cr
  11658. ;[79]    rts
  11659. shebq:    ldx   #shin08\      ; Get address of 'eight-bit-quote' string
  11660.     ldy   #shin08^      ;         ...
  11661.     lda   shin08      ;[87]         ...
  11662. ;[87]    jsr   prstr          ; Print that
  11663.     jsr   prncfm          ;[87] Print that
  11664.     ldx   srind          ; Load index so we print correct parm
  11665.     lda   ebq,x          ; If index is 1, this gets sebq
  11666. ;[79]    jsr   prchr          ; Print the special character
  11667. ;[79]    jsr   prcrlf          ; Print a crelf after it
  11668.     jmp    prchrr        ;[79] cntl chs, crlf & let it rts
  11669. ;[79]    rts
  11670. sheol:    ldx   #shin09\      ; Get address of 'end-of-line' string
  11671.     ldy   #shin09^      ;         ...
  11672.     lda   shin09      ;[87]         ...
  11673. ;[87]    jsr   prstr          ; Print that
  11674.     jsr   prncfm          ;[87] Print that
  11675.     ldx   srind          ; Load index so we print correct parm
  11676.     lda   eol,x          ; If index is 1, this gets seol
  11677. ;[79]    jsr   prchr          ; Print the special character
  11678. ;[79]    jsr   prcrlf          ; Print a crelf after it
  11679.     jmp    prchrr        ;[79] cntl c,s, crlf & let it rts
  11680. ;[79]    rts
  11681. shpl:    ldx   #shin10\      ; Get address of 'packet length' string
  11682.     ldy   #shin10^      ;         ...
  11683.     lda   shin10      ;[87]         ...
  11684. ;[87]    jsr   prstr          ; Print that
  11685.     jsr   prncfm          ;[87] Print that
  11686.     ldx   srind          ; Load index so we print correct parm
  11687.     lda   psiz,x          ; If index is 1, this gets spsiz
  11688. ;[79]    jsr   prbyte          ; Print the packet length
  11689. ;[79]    jsr   prcrlf          ; Print a crelf after it
  11690.     jmp    prbytl        ;[79] pr byte in hex, crlf & let it rts
  11691. ;    jmp    prbydr        ;[87] pr byte in ascii & cr
  11692. ;[79]    rts          ;     and return
  11693. shqc:    ldx   #shin13\      ; Get address of 'quote-char' string
  11694.     ldy   #shin13^      ;         ...
  11695.     lda   shin13      ;[87]         ...
  11696. ;[87]    jsr   prstr          ; Print that
  11697.     jsr   prncfm          ;[87] Print that
  11698.     ldx   srind          ; Load index so we print correct parm
  11699.     lda   quote,x          ; If index is 1, this gets squote
  11700. ;[79]    jsr   prchr          ; Print the special character
  11701. ;[79]    jsr   prcrlf          ; Print a crelf after it
  11702.     jmp    prchrr        ;[79] cntl chs, crlf & let it rts
  11703. ;[79]    rts
  11704. shtim:    ldx   #shin14\      ; Get address of 'timeout' string
  11705.     ldy   #shin14^      ;         ...
  11706.     lda   shin14      ;[87]         ...
  11707. ;[87]    jsr   prstr          ; Print that
  11708.     jsr   prncfm          ;[87] Print that
  11709.     ldx   srind          ; Load index so we print correct parm
  11710.     lda   time,x          ; If index is 1, this gets stime
  11711. ;[79]    jsr   prbyte          ; Print the hex value
  11712. ;[79]    jsr   prcrlf          ; Print a crelf after it
  11713.     jmp    prbytl        ;[79] pr byte in hex, crlf & let it rts
  11714. ;    jmp    prbydr        ;[87] pr byte in ascii & cr
  11715. ;[79]    rts
  11716. ;[87]shsnal: lda   #$01          ; Set up index for show parms
  11717. ;[87]    sta   srind          ;     and stuff it here
  11718. ;[87]    ldx   #shin07\      ; Get address of 'send' string
  11719. ;[87]    ldy   #shin07^      ;         ...
  11720. ;[79]    jsr   prstr          ; Print it
  11721. ;[79]    jsr   prcrlf          ; Print a crelf
  11722. ;[87]shsna3                ;[82]
  11723. ;[87]    jsr    prstrl        ;[79]
  11724. ;[87]    jsr   shpdc          ; Show the padding character
  11725. ;[87]    jsr   shpad          ; Show amount of padding
  11726. ;[87]    jsr   shebq          ; Show eight-bit-quote character
  11727. ;[87]    jsr    shsop        ;[82] show start of packet character
  11728. ;[87]    jsr   sheol          ; Show end-of-line character
  11729. ;[87]    jsr   shpl          ; Show packet-length
  11730. ;[87]    jsr   shqc          ; Show quote character
  11731. ;[79]    jsr   shtim          ; Show timeout length
  11732. ;[84]    jmp   shtim          ;[79] Show timeout length & let it rts
  11733. ;[87]    jsr   shtim          ;[84] Show timeout length
  11734. ;[87]    jmp    shcrlf        ;[84] show cr<->cr,lf xlation
  11735. ;[79]    rts
  11736.  
  11737. ;[87]shrcal: lda   #$00          ; Set up index for show parms
  11738. ;[87]    sta   srind          ;     and stuff it here
  11739. ;[87]    ldx   #shin15\      ; Get address of 'receive' string
  11740. ;[87]    ldy   #shin15^      ;         ...
  11741. ;[79]    jsr   prstr          ; Print it
  11742. ;[79]    jsr   prcrlf          ; Print a crelf
  11743. ;[87]    jmp    shsna3        ;[82] common code
  11744. ;[82]    jsr    prstrl        ;[79]
  11745. ;[82]    jsr   shpdc          ; Show the padding character
  11746. ;[82]    jsr   shpad          ; Show amount of padding
  11747. ;[82]    jsr   shebq          ; Show eight-bit-quote character
  11748. ;[82]    jsr    shsop        ;[82] show start of packet character
  11749. ;[82]    jsr   sheol          ; Show end-of-line character
  11750. ;[82]    jsr   shpl          ; Show packet-length
  11751. ;[82]    jsr   shqc          ; Show quote character
  11752. ;[79]    jsr   shtim          ; Show timeout length
  11753. ;[82]    jmp   shtim          ;[79] Show timeout length & let it rts
  11754. ;[79]    rts
  11755.  
  11756. shmod:    ldx   #shin16\      ; Get address of 'file-type' string
  11757.     ldy   #shin16^      ;         ...
  11758.     lda   shin16      ;[87]         ...
  11759. ;[87]    jsr   prstr          ; Print that
  11760.     jsr   prncfm          ;[87] Print that
  11761.     lda   filmod          ; Get the file-type mode
  11762. ;    bne    shmod3        ;[82] is this text, no
  11763. ;    ldx    ascii        ;[82] is this 7bit text?
  11764. ;    beq    shmod3        ;[82] no
  11765. ;    lda    #5        ;[82] this is index to ascii string
  11766. ;    bne    shmod1        ;[82]
  11767. ;shmod3                ;[82]
  11768. ;[78]    cmp   #$04          ; Is it >= 4?
  11769. ;[78]    bmi   shmod1          ; If not just get the string and print it
  11770.     cmp    #5        ;[78] is this type other?
  11771.     bcc    shmod1        ;[78] no, other gets a 3
  11772.     lda   #$03          ; This is the index to the file-type we want
  11773. shmod1: tax          ; Hold this index
  11774.     lda   #kerftp\      ; Get the address if the file type strings
  11775.     sta   kermbs          ; And stuff it here for genmad
  11776.     lda   #kerftp^      ;         ...
  11777.     sta   kermbs+1      ;         ...
  11778.     lda   #kerfts          ; Get the string length
  11779.     pha          ; Push that
  11780.     txa          ; Fetch the index back
  11781.     pha          ; Push that parm then
  11782.     jsr   genmad          ;     call genmad
  11783.     jsr   prstr          ; Print the the string at that address
  11784.     lda    filmod        ;[78] is this type other?
  11785.     cmp    #5        ;[78]
  11786.     bcc    shmod4        ;[78] no
  11787.     jsr    prbyte        ;[78] yes print the byte in hex
  11788. shmod4                ;[78]
  11789. ;[79]    jsr   prcrlf          ; Print a crelf after it
  11790.     jmp   prcrlf          ; Print a crelf after it, let it rts
  11791. ;[79]    rts
  11792.  
  11793. shprt:    ldx   #shin2i\      ; Get address of 'file-type' string
  11794.     ldy   #shin2i^      ;         ...
  11795.     lda   shin2i      ;[87]         ...
  11796. ;[87]    jsr   prstr          ; Print that
  11797.     jsr   prncfm          ;[87] Print that
  11798.     lda   #prcdef\      ; Get the address if the file type strings
  11799.     sta   kermbs          ; And stuff it here for genmad
  11800.     lda   #prcdef^      ;         ...
  11801.     sta   kermbs+1      ;         ...
  11802.     lda   #prclen          ; Get the string length
  11803.     pha          ; Push that
  11804.     lda    prtcl          ; Get the protocol mode
  11805.     pha          ; Push that parm then
  11806.     jsr   genmad          ;     call genmad
  11807.     jsr   prstr          ; Print the the string at that address
  11808.     jmp   prcrlf          ; Print a crelf after it, let it rts
  11809.  
  11810. ;[65]shfbs:    ldx   #shin17\      ; Get address of 'file-byte-size' string
  11811. ;[65]    ldy   #shin17^      ;         ...
  11812. ;[65]    jsr   prstr          ; Print that
  11813. ;[65]    lda   fbsize          ; Get the file-type mode
  11814. ;[65]    beq   shfbse          ; It is in eight-bit mode
  11815. ;[65]    ldx   #shsbit\      ; Get address of 'SEVEN-BIT' string
  11816. ;[65]    ldy   #shsbit^      ;         ...
  11817. ;[65]    jsr   prstr          ; Print that
  11818. ;[65]    jsr   prcrlf          ;     then a crelf
  11819. ;[65]    rts          ;     and return
  11820. ;[65]shfbse: ldx   #shebit\      ; Get the address of 'EIGHT-BIT' string
  11821. ;[65]    ldy   #shebit^      ;         ...
  11822. ;[65]    jsr   prstr          ; Print the the string at that address
  11823. ;[65]    jsr   prcrlf          ; Print a crelf after it
  11824. ;[65]    rts
  11825.  
  11826. shtmct: ldx   #shin2k\        ;[85] Get address of time constant string
  11827.     ldy   #shin2k^        ;[85]         ...
  11828.     lda   shin2k        ;[87][85]         ...
  11829. ;[87]    jsr   prstr        ;[85] Print that
  11830.     jsr   prncfm        ;[87][85] Print that
  11831.     lda    timect        ;[85] now for the current constant
  11832.     jmp    prbytl        ;[85] pr byte in hex, crlf & let it rts
  11833. ;    jmp    prbydr        ;[87] pr byte in ascii & cr
  11834.  
  11835. shvole    rts            ;[87]
  11836. shvols    lda    dosflg        ;[87] is this prodos
  11837.     beq    shvole        ;[87] no only for prodos
  11838.     jsr    prodos        ;[87]
  11839.     .byte    online        ;[87]
  11840.     .word    pvols        ;[87] get all the online vols
  11841.     bcc    .+5        ;[87] ok
  11842.     jmp    perror        ;[87] malo, let it rts
  11843.     ldx    #0        ;[87] and away we go
  11844. shvol1    lda    #'         ;[87] blank out vol name
  11845.     ldy    #15        ;[87]
  11846. shvol2    sta    shin2m+6,y    ;[87]
  11847.     dey            ;[87]
  11848.     bne    shvol2        ;[87]
  11849.     lda    volbuf,x    ;[87] better only be 256 max
  11850.     beq    shvole        ;[87]
  11851.     and    #$0f        ;[87] get the len of name
  11852.     beq    shvol6        ;[87] some kind of error
  11853.     sta    ksavey        ;[87] the counter
  11854.     lda    volbuf,x    ;[87]
  11855.     clc            ;[87]
  11856.     and    #$80        ;[87] now for the drive
  11857.     rol    a        ;[87] into carry
  11858.     rol    a        ;[87] right justified
  11859.     adc    #'1        ;[87] ascii it
  11860.     sta    shin2l+13    ;[87] into msg
  11861.     lda    volbuf,x    ;[87]
  11862.     and    #$70        ;[87] slot
  11863.     clc            ;[87]
  11864.     ror    a        ;[87]
  11865.     ror    a        ;[87]
  11866.     ror    a        ;[87]
  11867.     ror    a        ;[87]
  11868.     adc    #'0        ;[87] ascii it
  11869.     sta    shin2l+5    ;[87]
  11870.     stx    ksavex        ;[87] need this agn
  11871.     ldy    #0        ;[87]
  11872. shvol3    inx            ;[87]
  11873.     lda    volbuf,x    ;[87] ch of vol name
  11874.     sta    shin2m+7,y    ;[87]
  11875.     iny            ;[87]
  11876.     dec    ksavey        ;[87] thru?
  11877.     bne    shvol3        ;[87] no
  11878.     ldx    #shin2l\    ;[87] now print it
  11879.     ldy    #shin2l^    ;[87]
  11880.     jsr    prstrl        ;[87] and crlf
  11881.     ldx    ksavex        ;[87]
  11882. shvol6    txa            ;[87]
  11883.     clc            ;[87]
  11884.     adc    #16        ;[87] nextvol name
  11885.     tax            ;[87]
  11886.     jmp    shvol1        ;[87] around we go
  11887.  
  11888. shslot: ldx   #shin18\      ;[12] Get address of 'slot' string
  11889.     ldy   #shin18^      ;[12]         ...
  11890.     lda   shin18      ;[87][12]         ...
  11891. ;[87]    jsr   prstr          ;[12] Print that
  11892.     jsr   prncfm          ;[87][12] Print that
  11893.     lda   kersli          ;[12] If index is 1, this gets spsiz
  11894. ;[82]    sta   kwrk01          ;[12] Hold it here so we can shift it
  11895. ;[82]    lsr   kwrk01          ;[12] Shift it 4 times
  11896. ;[82]    lsr   kwrk01          ;[12]     to make it a slot number
  11897. ;[82]    lsr   kwrk01          ;[12]         ...
  11898. ;[82]    lsr   kwrk01          ;[12]         ...
  11899. ;[82]    lda   kwrk01          ;[12] Fetch it back
  11900.     lsr    a        ;[82] quicker and shorter
  11901.     lsr    a        ;[82] quicker and shorter
  11902.     lsr    a        ;[82] quicker and shorter
  11903.     lsr    a        ;[82] quicker and shorter
  11904. ;[79]    jsr   prbyte          ;[12] Print the current slot number
  11905. ;[79]    jsr   prcrlf          ;[12] Print a crelf after it
  11906.     jmp    prbytl        ;[79] pr byte in hex, crlf & let it rts
  11907. ;    jmp    prbydr        ;[87] pr byte in ascii, crlf & let it rts
  11908. ;[79]    rts          ;[12]     and return
  11909.  
  11910. shddr:    ldx   #shin19\      ;[12] Get address of 'device-driver' string
  11911.     ldy   #shin19^      ;[12]         ...
  11912.     lda   shin19      ;[87]
  11913. ;[87]    jsr   prstr          ;[12] Print that
  11914.     jsr   prncfm          ;[87] Print that
  11915. ;[83]    lda   ddrnm          ;[54] tell what
  11916. ;[83]    sta   shddr1+1      ;[54] com card
  11917. ;[83]    lda   ddrnm+1          ;[54] we are
  11918. ;[83]    sta   shddr1+2      ;[54] a nice indirect would be slick
  11919. ;[83]    ldy   #0          ;[54] 
  11920. ;[83]shddr1: lda   shddr1,y      ;[54] get ch
  11921. ;[83]    beq   shddr2          ;[54] null terminator?
  11922. ;[83]    jsr   prchr          ;[54] no print the ch - rtn uses x
  11923. ;[83]    iny          ;[54]
  11924. ;[83]    cpy   #27          ;[54] max # chs?
  11925. ;[83]    bne   shddr1          ;[54] not at max get another
  11926. ;[83]shddr2:              ;[54]
  11927. ;[79]    jsr   prcrlf          ;[12] Print a crelf after it
  11928. ;[83]    jmp   prcrlf          ;[79][12] Print a crelf after it,let it rts
  11929. ;[79]    rts
  11930.     ldx    ddrnm        ;[83] its so much easier
  11931.     ldy    ddrnm+1        ;[83] this way
  11932.     jmp    prstrl        ;[83] string & cr
  11933.  
  11934. shpari: ldx   #shin20\      ;[21] Get address of 'parity' string
  11935.     ldy   #shin20^      ;[21]         ...
  11936.     lda    shin20        ;[87]
  11937. ;[87]    jsr   prstr          ;[21] Print that
  11938.     jsr   prncfm          ;[87] Print that
  11939.     lda   parity          ;[21] Get the parity index
  11940.     cmp   #$05          ;[21] Is it >= 5?
  11941.     bmi   shpar1          ;[21] If not just get the string and print it
  11942.     lda   #$00          ;[21] This is the index to the parity we want
  11943. shpar1: tax          ;[21] Hold this index
  11944.     lda   #kerprs\      ;[21] Get address of the parity strings
  11945.     sta   kermbs          ;[21] And stuff it here for genmad
  11946.     lda   #kerprs^      ;[21]         ...
  11947.     sta   kermbs+1      ;[21]         ...
  11948.     lda   #kerpsl          ;[21] Get the string length
  11949.     pha          ;[21] Push that
  11950.     txa          ;[21] Fetch the index back
  11951.     pha          ;[21] Push that parm then
  11952.     jsr   genmad          ;[21]     call genmad
  11953. ;[79]    jsr   prstr          ;[21] Print the the string at that address
  11954. ;[79]    jsr   prcrlf          ;[21] Print a crelf after it
  11955.     jmp    prstrl        ;[79] let it rts
  11956. ;[79]    rts
  11957.  
  11958. shkbd:    ldx   #shin21\      ;[35] Get address of 'keyboard-type' string
  11959.     ldy   #shin21^      ;[35]         ...
  11960.     lda   shin21      ;[87]
  11961. ;[87]    jsr   prstr          ;[35] Print that
  11962.     jsr   prncfm          ;[87] Print that
  11963.     lda   kbd1          ;[35] Get the keyboard-type identification.
  11964.     cmp   #$03          ;[35] Is it >= 3?
  11965.     bmi   shkbd1          ;[35] If not just get the string and print it
  11966.     lda   #$01          ;[35] This is index for keyboard-type we want.
  11967.  
  11968. shkbd1: tax          ;[35] Hold this index
  11969.     lda   #kbds\          ;[35] Get the address of the keyboard strings
  11970.     sta   kermbs          ;[35] And stuff it here for genmad
  11971.     lda   #kbds^          ;[35]         ...
  11972.     sta   kermbs+1      ;[35]         ...
  11973.     lda   #kbdl          ;[35] Get the string length
  11974.     pha          ;[35] Push that
  11975.     txa          ;[35] Fetch the index back
  11976.     pha          ;[35] Push that parm then
  11977.     jsr   genmad          ;[35]     call genmad
  11978. ;[79]    jsr   prstr          ;[35] Print the the string at that address
  11979. ;[79]    jsr   prcrlf          ;[35] Print a crelf after it
  11980.     jmp    prstrl        ;[79] let it rts
  11981. ;[79]    rts          ;[35]
  11982.  
  11983. shdspy: ldx   #shin24\      ;[46] Get address of 'display-type' string
  11984.     ldy   #shin24^      ;[46]         ...
  11985.     lda   shin24      ;[87]
  11986. ;[87]    jsr   prstr          ;[46] Print that
  11987.     jsr   prncfm          ;[87] Print that
  11988.     lda   dsp1          ;[46] Get the display-type identification.
  11989.     cmp   #6          ;[49] 0,3,6 -> 0,1,2
  11990.     bne   .+4          ;[49]
  11991.     lda   #2          ;[49] some way to divide by three
  11992.     cmp   #$03          ;[46] Is it >= 3?
  11993.     bmi   shdsp1          ;[46] If not just get the string and print it
  11994.     lda   #$01          ;[46] This is index for display-type we want.
  11995.  
  11996. shdsp1: tax          ;[46] Hold this index
  11997.     lda   #dsps\          ;[46] Get the address of the display strings
  11998.     sta   kermbs          ;[46] And stuff it here for genmad
  11999.     lda   #dsps^          ;[46]         ...
  12000.     sta   kermbs+1      ;[46]         ...
  12001.     lda   #dspl          ;[46] Get the string length
  12002.     pha          ;[46] Push that
  12003.     txa          ;[46] Fetch the index back
  12004.     pha          ;[46] Push that parm then
  12005.     jsr   genmad          ;[46]     call genmad
  12006.     jsr   prstr          ;[46] Print the the string at that address
  12007.     lda   dsptyp          ;[49] get display type
  12008.     bpl   shdsp2          ;[49] is this 80 col? no
  12009.     lda   #'=+$80      ;[49]
  12010.     jsr   cout          ;[49] print it
  12011.     lda   dsp2          ;[49] get display slot
  12012.     jsr   prbyte          ;[49] and print it
  12013. ;    jsr   prbydc          ;[87] pr in ascii
  12014. shdsp2:              ;[49]
  12015. ;[79]    jsr   prcrlf          ;[46] Print a crelf after it
  12016.     jmp   prcrlf          ;[79][46] Print a crelf after it,let it rts
  12017. ;[79]    rts          ;[46]
  12018.  
  12019. shprn:    ldx   #shin26\      ;[55] Get address of printer string
  12020.     ldy   #shin26^      ;[55]         ...
  12021.     lda   shin26      ;[87]
  12022. ;[87]    jsr   prstr          ;[55] Print that
  12023.     jsr   prncfm          ;[87] Print that
  12024.     lda   prnfg          ;[55] Get the printer info identification.
  12025. ;[81]    cmp   #$03          ;[55] Is it >= 3?
  12026. ;[81]    bmi   shprn1          ;[55] If not just get the string and print it
  12027. ;[81]    lda   #$01          ;[55] This is index for display-type we want.
  12028. ;[81]shprn1: tax          ;[55] Hold this index
  12029. ;[81]    lda   #shoff\          ;[55] Get the address of the display strings
  12030. ;[81]    sta   kermbs          ;[55] And stuff it here for genmad
  12031. ;[81]    lda   #shoff^          ;[55]         ...
  12032. ;[81]    sta   kermbs+1      ;[55]         ...
  12033. ;[81]    lda   #5          ;[55] Get the string length
  12034. ;[81]    pha          ;[55] Push that
  12035. ;[81]    txa          ;[55] Fetch the index back
  12036. ;[81]    pha          ;[55] Push that parm then
  12037. ;[81]    jsr   genmad          ;[55]     call genmad
  12038. ;[81]    jsr   prstr          ;[55] Print the the string at that address
  12039. ;[81]    lda   prnsl          ;[55] get slot number
  12040. ;[81]    beq   shprn2          ;[55] do we have a printer slot? no
  12041.     jsr    pronnr        ;[81] print the on/off
  12042.     ldx   #prnslm\      ;[55]
  12043.     ldy   #prnslm^      ;[55]
  12044.     jsr   prstr          ;[55] print slot
  12045.     lda   #'=          ;[55] separate
  12046.     jsr   dspchr            ;[55] to separate
  12047.     lda   prnsl          ;[55] get printer slot
  12048.     jsr   prbyte          ;[55] and print it
  12049. ;    jsr   prbydc          ;[87] pr in ascii
  12050. shprn2:              ;[55]
  12051. ;[79]    jsr   prcrlf          ;[55] Print a crelf after it
  12052.     jmp   prcrlf          ;[79][55] Print a crelf after it,let it rts
  12053. ;[79]    rts          ;[55]
  12054.  
  12055. shpwd    jsr    prcfm    ;[87] confirm
  12056.     jsr    shddsk    ;[87]
  12057.     jmp    kermit    ;[87]
  12058.     
  12059. shddsk:            ;[59]
  12060.     lda    dosflg    ;[59] is this prodos
  12061.     beq    shdds1    ;[59] no
  12062.     ldx    #shin2a\    ;[59] yes tell about prodos prefix instead
  12063.     ldy    #shin2a^    ;[59]
  12064.     lda    shin2a    ;[87]
  12065. ;[87]    jsr    prstr        ;[59]
  12066.     jsr    prncfm        ;[87]
  12067.     lda    prefix        ;[59] is this a null string?
  12068.     beq    shdds2        ;[59] yes,dont print it
  12069.     ldx    #prefix+1\    ;[59] now for the prefix itself
  12070.     ldy    #prefix+1^    ;[59]
  12071.     jsr    prstr        ;[59]
  12072.     jmp    shdds2        ;[59] and terminate it 
  12073. shdds1                ;[59]
  12074.     ldx   #shin22\      ;[40] Set up to print slot message
  12075.     ldy   #shin22^      ;[40]         ...
  12076.     lda   shin22      ;[87]
  12077. ;[87]    jsr   prstr          ;[40] Print the text
  12078.     jsr   prncfm          ;[87] Print the text
  12079.     lda   defslt          ;[40] Get the number
  12080. ;[79]    jsr   prbyte          ;[40] Put it on the screen
  12081. ;[79]    jsr   prcrlf          ;[40] Print a crelf
  12082.     jsr    prbytl        ;[79] pr byte in hex & crlf
  12083. ;    jsr    prbydr        ;[87] pr byte in ascii & cr
  12084.     ldx   #shin23\      ;[40] Set up for the drive message
  12085.     ldy   #shin23^      ;[40]         ...
  12086.     jsr   prstr          ;[40] Print the text
  12087.     lda   defdrv          ;[40] Get the number
  12088. ;[79]    jsr   prbyte          ;[40] Put drive number on screen
  12089. ;[79]    jsr   prcrlf          ;[40] Print a crelf
  12090.     jsr    prbytl        ;[79] pr byte in hex & crlf
  12091. ;    jsr    prbydr        ;[87] pr byte in ascii & cr
  12092.     ldx   #shi231\      ;[60] Set up to print vol message
  12093.     ldy   #shi231^      ;[60]         ...
  12094.     jsr   prstr          ;[60] Print the text
  12095.     lda   defvol          ;[60] Get the number
  12096. ;[87]    jsr   prbyte          ;[60] Put it on the screen
  12097.     jsr   prbydc          ;[87] pr in ascii
  12098. shdds2                ;[59] place to hang your hat
  12099. ;[79]    jsr   prcrlf          ;[60] Print a crelf
  12100.     jmp   prcrlf          ;[79][60] Print a crelf,let it rts
  12101. ;[79]    rts          ;[40] Return
  12102.  
  12103. shflow: ldx    #shin27\    ;[57] tell about flow control
  12104.     ldy    #shin27^    ;[57]
  12105.     lda    shin27    ;[87]
  12106. ;[87]    jsr    prstr        ;[57]
  12107.     jsr    prncfm        ;[87]
  12108. ;[76]    lda    flowfg        ;[57] now is it off
  12109.     lda    confg        ;[76] now is it off
  12110.     bpl    shflo0        ;[57] yes
  12111.     ldx    #floxon\    ;[57] its xon 
  12112.     ldy    #floxon^    ;[57]
  12113.     jsr    prstr        ;[57]
  12114. shflo1: lda    #hspace        ;[57] separate with a space
  12115.     jsr    dspchr        ;[57]
  12116.     ldx    #flodly\    ;[57] now for the delay
  12117.     ldy    #flodly^    ;[57]
  12118.     jsr    prstr        ;[57]
  12119.     lda    #'=        ;[57] separate
  12120.     jsr    dspchr        ;[57]
  12121.     lda    flowdl        ;[57] now for the value of delay
  12122. ;[87]    jsr    prbyte        ;[57]
  12123.     jsr    prbydc        ;[87] pr in ascii
  12124.     lda    #hspace        ;[57] separate with a space
  12125.     jsr    dspchr        ;[57]
  12126. ;[79]    jsr    prcrlf        ;[57]
  12127.     jmp    prcrlf        ;[79][57] let it rts
  12128. ;[79]    rts            ;[57] thats all folks
  12129. shflo0: ldx    #shoff\        ;[57]
  12130.     ldy    #shoff^        ;[57]
  12131.     jsr    prstr        ;[57]
  12132.     jmp    shflo1        ;[57]
  12133.  
  12134. shbaud:              ;[54]
  12135.     ldx   #shin25\      ;[47] yes,set up show message
  12136.     ldy   #shin25^      ;[47]
  12137.     lda   shin25      ;[87]
  12138. ;[87]    jsr   prstr      ;[47] and print it
  12139.     jsr   prncfm      ;[87] and print it
  12140.     lda   #kerbau\      ;[47] ready the search message
  12141.     sta   kermbs      ;[47]
  12142.     lda   #kerbau^      ;[47]
  12143.     sta   kermbs+1      ;[47]
  12144.     lda   #kerbal      ;[47]
  12145.     pha           ;[47]
  12146.     sec           ;[47] set carry for subtract
  12147.     lda   sscdbd      ;[47] get default baud
  12148.     sbc   #3      ;[47] we ignore the first three
  12149.     pha           ;[47]
  12150.     jsr   genmad      ;[47] get the address
  12151. ;[79]    jsr   prstr      ;[47] and print it
  12152. ;[79]    jsr   prcrlf      ;[47] and the line feed
  12153.     jmp    prstrl        ;[79] let it rts
  12154. ;[79]    rts           ;[47]
  12155.  
  12156. .SBTTL    Status routine
  12157.  
  12158. ;
  12159. ;     This routine shows the status of the most recent transmission
  12160. ;     session.
  12161. ;
  12162. ;         Input:     NONE
  12163. ;
  12164. ;         Output:     Status of last transmission is sent to screen
  12165. ;
  12166. ;         Registers destroyed:     A,X,Y
  12167. ;
  12168.  
  12169. status: jsr   prcfm          ; Parse and print a confirm
  12170.  
  12171. stat01: ldx   #stin00\      ; Get address of first line of text
  12172.     ldy   #stin00^      ;         ...
  12173.     jsr   prstr          ; Print that
  12174. ;[84]    lda   schr          ; Get low order byte of character count
  12175. ;[84]    tax          ; Put that in x
  12176.     lda    schr+2        ;[87] msb
  12177. ;[87]    ldx   schr          ;[84] Get low order byte of character count
  12178. ;[87]    lda   schr+1          ; Get high order byte
  12179.     ldy    schr        ;[87] lsb
  12180.     ldx    schr+1        ;[87]
  12181.     jsr    cv6prr        ;[87] print & cr
  12182. ;[79]    jsr   prntax          ; Print that pair in hex
  12183. ;[79]    jsr   prcrlf          ; Add a crelf at the end
  12184. ;[87]    jsr    prntal        ;[79] pr a,x in hex & crlf
  12185.     ldx   #stin01\      ; Get address of second line
  12186.     ldy   #stin01^      ;         ...
  12187.     jsr   prstr          ; Print it
  12188. ;[84]    lda   rchr          ; Get L.O. byte of char count
  12189. ;[84]    tax          ; Stuff it here for the call
  12190. ;[87]    ldx   rchr          ;[84] Get L.O. byte of char count
  12191. ;[87]    lda   rchr+1          ; Get H.O. byte
  12192. ;[79]    jsr   prntax          ; Print that count
  12193. ;[79]    jsr   prcrlf          ; Add a crelf at the end
  12194. ;[87]    jsr    prntal        ;[79] pr a,x in hex & crlf
  12195.     lda    rchr+2        ;[87] msb
  12196.     ldx    rchr+1        ;[87]
  12197.     ldy    rchr        ;[87]
  12198.     jsr    cv6prr        ;[87]
  12199.     ldx   #stin02\      ; Get L.O. address of message
  12200.     ldy   #stin02^      ; Get H.O. byte
  12201.     jsr   prstr          ; Print message
  12202. ;[87]    lda   stot          ; Get L.O. byte of count
  12203. ;[87]    tax          ; Save it
  12204. ;[87]    lda   stot+1          ; Get H.O. byte
  12205. ;[79]    jsr   prntax          ; Print the count
  12206. ;[79]    jsr   prcrlf          ; Add a crelf at the end
  12207. ;[87]    jsr    prntal        ;[79] pr a,x in hex & crlf
  12208.     lda    stot+2        ;[87] msb
  12209.     ldx    stot+1        ;[87]
  12210.     ldy    stot        ;[87]
  12211.     jsr    cv6prr        ;[87]
  12212.     ldx   #stin03\      ; Get address of next status item message
  12213.     ldy   #stin03^      ;         ...
  12214.     jsr   prstr          ; Print it
  12215. ;[87]    lda   rtot          ; Get the proper count (L.O. byte)
  12216. ;[87]    tax          ; Hold it here for the call
  12217. ;[87]    lda   rtot+1          ; Get H.O. byte
  12218. ;[79]    jsr   prntax          ; Print the 16-bit count
  12219. ;[79]    jsr   prcrlf          ; Add a crelf at the end
  12220. ;[87]    jsr    prntal        ;[79] pr a,x in hex & crlf
  12221. ;[87]    jsr   prcrlf          ; Add a crelf at the end
  12222.     lda    rtot+2        ;[87]
  12223.     ldx    rtot+1        ;[87]
  12224.     ldy    rtot        ;[87]
  12225.     jsr    cv6prr        ;[87]
  12226.     ldx   #stin04\      ; Get address of overhead message
  12227.     ldy   #stin04^      ;         ...
  12228.     jsr   prstr          ; Print that message
  12229.     sec          ; Get ready to calculate overhead amount
  12230.     lda   stot          ; Get total character count and
  12231.     sbc   schr          ;     subtract off data character count
  12232. ;[87]    tax          ; Stuff that here for printing
  12233.     tay          ;[87] Stuff that here for printing
  12234.     lda   stot+1          ;         ...
  12235.     sbc   schr+1          ;         ...
  12236.     tax            ;[87]
  12237.     lda    #0        ;[87]
  12238. ;[79]    jsr   prntax          ; Print it
  12239. ;[79]    jsr   prcrlf          ; Add a crelf at the end
  12240. ;[87]    jsr    prntal        ;[79] pr a,x in hex & crlf
  12241.     jsr    cv6prr        ;[87]
  12242.     ldx   #stin05\      ; Get address of next overhead message
  12243.     ldy   #stin05^      ;         ...
  12244.     jsr   prstr          ; Print that
  12245.     sec          ; Get ready to calculate overhead amount
  12246.     lda   rtot          ; Get total character count and
  12247.     sbc   rchr          ;     subtract off data character count
  12248. ;[87]    tax          ; Stuff that here for printing
  12249.     tay          ;[87] Stuff that here for printing
  12250.     lda   rtot+1          ;         ...
  12251.     sbc   rchr+1          ;         ...
  12252. ;[79]    jsr   prntax          ; Print the count
  12253. ;[79]    jsr   prcrlf          ; Add a crelf at the end
  12254. ;[87]    jsr    prntal        ;[79] pr a,x in hex & crlf
  12255.     tax            ;[87]
  12256.     lda    #0        ;[87]
  12257.     jsr    cv6prr        ;[87]
  12258.     jsr   prcrlf          ; Add a crelf at the end
  12259.     ldx   #stin06\      ; Get message for 'last error'
  12260.     ldy   #stin06^      ;         ...
  12261. ;[79]    jsr   prstr          ; Print the message
  12262. ;[79]    jsr   prcrlf          ; Print a crelf before the error message
  12263.     jsr    prstrl        ;[79]
  12264. stat07                ;[59] entry for error message only
  12265.     bit   errcod          ;[38] Test for 'Error packet received' bit
  12266.     bvs   statpe          ;[38] Go process an error packet
  12267.     lda   #kerems          ; Get the error message size
  12268.     pha          ; Push it
  12269.     lda   errcod          ; Get the error message offset in table
  12270.     bmi   stat02          ; If this is a DOS error, do extra adjusting
  12271.     pha          ; Push that
  12272.     lda   #erms0a\      ; Put the base address in kermbs
  12273.     sta   kermbs          ;         ...
  12274.     lda   #erms0a^      ;         ...
  12275.     sta   kermbs+1      ;         ...
  12276.     jmp   statle          ; Go print the 'last error' encountered
  12277. stat02: and   #$7f          ; Shut off H.O. bit
  12278.     beq   stat03          ; If it is zero, we are done adjusting
  12279.     sec          ; Decrement by one for the unused error code
  12280.     sbc   #$01          ;         ...
  12281. stat03: pha          ; Push that parameter
  12282.     lda   #dskers\      ; Use 'dskers' as the base address
  12283.     sta   kermbs          ;         ...
  12284.     lda   #dskers^      ;         ...
  12285.     sta   kermbs+1      ;         ...
  12286. statle: jsr   genmad          ; Translate code to address of message
  12287. ;[79]    jsr   prstr          ; Print the text of error message
  12288. ;[79]    jsr   prcrlf          ; Add a crelf at the end
  12289.     jsr    prstrl        ;[79]
  12290. ;[59]    jsr   prcrlf          ; Add a crelf at the end
  12291.     lda    servef        ;[62] is this server mode?
  12292.     beq    stat06        ;[62] no
  12293.     lda    #1        ;[62] times to try it
  12294.     sta    numtry        ;[62]
  12295. stat04    jsr    statec        ;[62] try and send error packet
  12296.     bne    stat09        ;[62] ok? yes
  12297.     dec    numtry        ;[62]
  12298.     bne    stat04        ;[62] no try again
  12299. stat09                ;[62] thats all
  12300.     .ifeq    termnl        ;[63]
  12301.     jmp    sallt2        ;[63] in terminal we are thru
  12302.     .endc            ;[63]
  12303.     .ifne    termnl        ;[63]
  12304.     jmp    server        ;[62] around we go again
  12305.     .endc            ;[63]
  12306. statpe:
  12307.     ldx    #erin02\    ;[59]
  12308.     ldy    #erin02^    ;[59]
  12309.     jsr    prstr        ;[59] say its from the remote
  12310.     ldx   #errrkm\      ;[38] L.O. byte address of remote kermit error
  12311.     ldy   #errrkm^      ;[38] H.O. byte address...
  12312. ;[79]    jsr   prstr          ;[38] Print the text from the error packet
  12313. ;[79]    jsr   prcrlf          ;[38] Print an extra crelf
  12314.     jsr    prstrl        ;[79]
  12315. stat06            ;[62]
  12316.     jmp   kermit          ;[38] Start at the top again
  12317. statec    lda    #'E        ;[62] yes send error to rmt
  12318.     sta    ptype        ;[62]
  12319.     lda    n        ;[62] set ther correct pck number
  12320.     sta    pnum        ;[62]
  12321.     ldy    #0        ;[62] move msg to packet
  12322. stat05    lda    (saddr),y        ;[62] setup by prstr
  12323.     and    #$7f        ;[62] get rid of high bit
  12324.     sta    (kerbf1),y        ;[62] setup by srini
  12325.     iny            ;[62]
  12326.     cpy    #kerems-1    ;[62] length of message,forget about nulls
  12327.     bne    stat05        ;[62] all thru? no
  12328.     sty    pdlen        ;[62] tell packet how long
  12329.     jsr    spak        ;[62] send packet
  12330.     jsr    rpak        ;[62] try and read a pkt
  12331.     beq    statrt        ;[62] bad packet,what we need is a timer
  12332.     lda    ptype        ;[62] 
  12333.     cmp    #'Y        ;[64] now that we have timer check ack
  12334.     beq    stattt        ;[64] yes give true rtn
  12335.     lda    #false        ;[64] no, now what
  12336. statrt    rts            ;[64]
  12337. stattt    lda    #true        ;[64] were ok
  12338.     rts            ;[64]
  12339.  
  12340. .SBTTL    Packet routines - SPAK - send packet
  12341.  
  12342. ;
  12343. ;     This routine forms and sends out a complete packet in the
  12344. ;     following format:
  12345. ;
  12346. ;     <SOH><char(pdlen)><char(pnum)><ptype><data><char(chksum)><eol>
  12347. ;
  12348. ;         Input:     kerbf1-     Pointer to packet buffer
  12349. ;             pdlen-     Length of data
  12350. ;             pnum-     Packet number
  12351. ;             ptype-     Packet type
  12352. ;
  12353. ;         Output:     A-     True or False return code
  12354. ;
  12355.  
  12356. spak:
  12357. ;[59]    ldx   #snin01\      ; Give the user info on what we are doing
  12358. ;[59]    ldy   #snin01^      ;         ...
  12359. ;[59]    jsr   prstr          ; Print the information
  12360. ;[87]    lda    #splocv        ;[59] position to data
  12361. ;[87]    sta    cv        ;[59] field
  12362. ;[84]    lda    #rploch        ;[59] and print
  12363. ;[87]    lda    #rploch-2    ;[84] and print
  12364. ;[87]    sta    ch        ;[59]
  12365. ;[87]    jsr    vtab        ;[59] hope this works for all kinds
  12366. ;[87]    lda    schr+2        ;[84]
  12367. ;[87]    jsr    prbyte        ;[84]
  12368. ;[87]    lda    schr+1        ;[84]
  12369. ;[87]    ldx    schr        ;[84] bytes sent
  12370. ;[84]    lda   tpak+1          ;[16] Get the total packets count
  12371. ;[59]    jsr   prbyte          ;[16]     and print that
  12372. ;[59]    lda   tpak          ;[16]         ...
  12373. ;[59]    jsr   prbyte          ;[16]         ...
  12374. ;[84]    ldx    tpak        ;[59]
  12375. ;[79]    jsr    prntax        ;[59] just one call does it all
  12376. ;[79]    jsr   prcrlf          ; Output a crelf
  12377. ;[87]    jsr    prntal        ;[79] pr a,x in hex & crlf
  12378.     lda   #$00          ;[25] Clear packet data index
  12379.     sta   pdtind          ;[25]         ...
  12380. spaknd: lda   spadch          ; Get the padding character
  12381.     ldx   #$00          ; Init counter
  12382. spakpd: cpx   spad          ; Are we done padding?
  12383.     bcs   spakst          ;[21] Yes, start sending packet
  12384.     inx          ; No, up the index and count by one
  12385.     jsr   putplc          ; Output a padding character
  12386.     jmp   spakpd          ; Go around again
  12387. ;[82]spakst: lda   #soh          ; Get the start-of-header char into AC
  12388. spakst: lda   sop+1          ;[82] Get the start-of-header char into AC
  12389.     jsr   putplc          ; Send it
  12390. ;[84]    lda    exfg        ;[75] is this extended packet?
  12391. ;[84]    beq    spaks2        ;[75] no
  12392.     lda    pdlen        ;[75] increment the # of chs send
  12393.     ldx    prtcl        ;[85] xmodem?
  12394.     bne    spaks2        ;[85] yes
  12395.     cmp    #dpakln+1    ;[84] do we need to use long pkts?
  12396.     blt    spaks2        ;[84] no
  12397.     jsr    spnocs    ;[75]
  12398.     lda    #6        ;[75] ex len has 6 extra
  12399.     jsr    spnocs        ;[75]
  12400.     lda    #sp        ;[75] maxl = 0
  12401.     sta    chksum        ;[75] start out checksum
  12402.     jsr    putplc        ;[75] adios ch
  12403.     jmp    spaks3        ;[75]
  12404. spaks2                ;[75]
  12405. ;[84]    lda   pdlen          ; Get the data length
  12406.     clc          ; Clear the carry
  12407.     adc   #$03          ; Adjust it
  12408.     ldx    prtcl        ;[83] xmodem?
  12409.     bne    spaks6        ;[83] yes
  12410.     pha          ; Save this to be added into stot
  12411.     clc          ; Clear carry again
  12412.     adc   #sp          ; Make the thing a character 
  12413.     sta   chksum          ; First item,     start off chksum with it
  12414.     jsr   putplc          ;[25] Send the character
  12415.     pla          ; Fetch the pdlen and add it into the 
  12416. spaks6            ;[83]
  12417.     jsr    spnocs        ;[75] bump # of chs sent
  12418. ;[75]    clc          ;     'total characters sent' counter
  12419. ;[75]    adc   stot          ;         ...
  12420. ;[75]    sta   stot          ;         ...
  12421. ;[75]    lda   stot+1          ;         ...
  12422. ;[75]    adc   #$00          ;         ...
  12423. ;[75]    sta   stot+1          ;         ...
  12424. spaks3            ;[75]
  12425.     lda   pnum          ; Get the packet number
  12426.     ldy    prtcl        ;[83] xmodem?
  12427.     beq    spaks8        ;[83]
  12428.     jsr    putplc        ;[83] first the pkt #
  12429.     eor    #$ff        ;[83] a is still intact
  12430.     jsr    putplc        ;[83] now the pkt # complimented
  12431.     jmp    spaks5        ;[83]
  12432. spaks8                ;[83]
  12433.     clc          ;         ...
  12434.     adc   #sp          ; Char it
  12435.     jsr    ccrcpu        ;[75]
  12436. ;[75]    pha          ; Save it in this condition
  12437. ;[75]    clc          ; Clear carry
  12438. ;[75]    adc   chksum          ; Add this to the checksum
  12439. ;[75]    sta   chksum          ;         ...
  12440. ;[75]    pla          ; Restore character
  12441. ;[75]    jsr   putplc          ;[25] Send it
  12442.     lda   ptype          ; Fetch the packet type
  12443.     and   #$7f          ; Make sure H.O. bit is off for chksum
  12444.     jsr    ccrcpu        ;[75]
  12445. ;[75]    pha          ; Save it on stack
  12446. ;[75]    clc          ; Add to chksum
  12447. ;[75]    adc   chksum          ;         ...
  12448. ;[75]    sta   chksum          ;         ...
  12449. ;[75]    pla          ; Get the original character off stack
  12450. ;[75]    jsr   putplc          ;[25] Send packet type
  12451. ;[84]    lda    exfg        ;[75] are we extended packet
  12452. ;[84]    beq    spaks5        ;[75] no
  12453.     ldy    pdlen        ;[84]
  12454.     cpy    #dpakln+1    ;[84] do we need to use long pkts?
  12455.     blt    spaks5        ;[84] no
  12456.     lda    #0        ;[75] msb
  12457.     pha        ;[75]
  12458.     pha        ;[87]
  12459. ;[84]    lda    pdlen        ;[75] lsb
  12460. ;[84]    clc            ;[75] must include the crc also
  12461. ;[84]    adc    #1        ;[75]
  12462.     iny            ;[84]
  12463.     tya            ;[84]
  12464.     bne    spaks4        ;[75] we cant handle 0
  12465.     brk            ;[75] got to do something about this
  12466. spaks4    
  12467.     pha            ;[75]
  12468.     lda    #0        ;[75] msb
  12469.     pha        ;[75]
  12470.     pha        ;[87]
  12471. ;[84]    lda    #95        ;[75] lsb
  12472.     lda    #dpakln+1        ;[84] lsb
  12473.     pha        ;[75]
  12474. ;[87]    jsr    div16        ;[75] get q and rem
  12475.     jsr    div24        ;[87] get q and rem
  12476.     bcc    spaks7        ;[75] always good it says here
  12477.     brk            ;[75] got to do something better
  12478. spaks7    pla        ;[75]
  12479.     clc        ;[75]
  12480.     adc    #'         ;[75] char it
  12481.     jsr ccrcpu        ;[75] and output it
  12482.     pla            ;[75] msb got to be 0
  12483.     pla            ;[87] msb got to be 0
  12484.     pla            ;[75] lsb of rem
  12485.     clc        ;[75]
  12486.     adc    #'         ;[75] char it
  12487.     jsr    ccrcpu        ;[75] and output it
  12488.     jsr    putcrc        ;[75] get hcrc
  12489.     jsr    ccrcpu        ;[75] and put it
  12490.     pla            ;[75] msb of rem
  12491.     pla            ;[87] msb of rem
  12492. spaks5                ;[75]
  12493.     ldy   #$00          ; Initialize data count
  12494.     sty   datind          ; Hold it here
  12495.     lda    prtcl        ;[83] xmodem?
  12496.     beq    spaklp        ;[83] no
  12497.     sty    chksum        ;[83] start check sum at 0
  12498. spaklp: ldy   datind          ; Get the current index into the data
  12499.     cpy   pdlen          ; Check against packet data length, done?
  12500. ;[75]    bmi   spakdc          ; Not yet, process another character
  12501. ;[83]    bcc   spakdc          ; Not yet, process another character
  12502. ;[83]    jmp   spakch          ; Go do chksum calculations
  12503.     bcs   spakch          ;[83] Go do chksum calculations
  12504. spakdc: lda   (kerbf1),y      ; Fetch data from packet buffer
  12505.     jsr    ccrcpu        ;[75]
  12506. ;[75]    clc          ; Add the character into the chksum
  12507. ;[75]    adc   chksum          ;         ...
  12508. ;[75]    sta   chksum          ;         ...
  12509. ;[75]    lda   (kerbf1),y      ; Refetch data from packet buffer
  12510. ;[75]    jsr   putplc          ;[25] Send it
  12511.     inc   datind          ; Up the counter and index
  12512.     jmp   spaklp          ; Loop to do next character
  12513. ;[83]spakch    jsr    putcrc        ;[75] finalize crc
  12514. spakch                ;[83]
  12515.     lda    prtcl        ;[83] xmodem?
  12516.     beq    spakcj        ;[83] no
  12517. spakci    lda    #sfxmd        ;[83] size of xmodem data
  12518.     cmp    pdlen        ;[83] is this a full one?
  12519.     beq    spakck        ;[83] yes
  12520.     lda    #ctrlz        ;[83] no fill with ^z
  12521.     jsr    ccrcpu        ;[83] 
  12522.     inc    pdlen        ;[83] make it full
  12523.     jmp    spakci        ;[83]
  12524. spakck    lda    chksum        ;[83] now finish up
  12525.     jmp    spakcy        ;[83]
  12526. spakcj                ;[83]
  12527.     jsr    putcrc        ;[83] finalize crc
  12528. ;[75]spakch: lda   chksum          ; Now, adjust the chksum to fit in 6 bits
  12529. ;[75]    and   #$c0          ; First, take bits 6 and 7
  12530. ;[75]    lsr   a          ;     and shift them to the extreme right
  12531. ;[75]    lsr   a          ;     side of the AC
  12532. ;[75]    lsr   a          ;         ...
  12533. ;[75]    lsr   a          ;         ...
  12534. ;[75]    lsr   a          ;         ...
  12535. ;[75]    lsr   a          ;         ...
  12536. ;[75]    clc          ; Now add in the original chksum byte
  12537. ;[75]    adc   chksum          ;         ...
  12538. ;[75]    and   #$3f          ; All this should be mod decimal 64
  12539. ;[75]    clc          ;         ...
  12540. ;[75]    adc   #sp          ; Put it in printable range
  12541.     jsr   putplc          ;[25]     and send it
  12542.     lda   seol          ; Fetch the eol character
  12543. spakcy                ;[83]
  12544.     jsr   putplc          ;[25] Send that as the last byte of the packet
  12545.     lda   pdtind          ;[25] Set the end of buffer pointer
  12546.     sta   pdtend          ;[25]         ...
  12547.     lda   #$00          ;[25] Set index to zero
  12548.     sta   pdtind          ;[25]         ...
  12549.     lda   debug          ;[25] Is the debug option turned on?
  12550. ;[59]    cmp   #off          ;[25]         ...
  12551.     beq   spaksp          ;[25] Nope, go stuff packet at other kermit
  12552.     lda   #$00          ;[25] Option 0
  12553.     jsr   debg          ;[25] Do it
  12554. spaksp: lda   #$00          ;[25] Zero the index
  12555.     sta   pdtind          ;[25]         ...
  12556.     ldx    prtcl        ;[83] xmodem?
  12557.     beq    spakdl        ;[83] no
  12558.     lda    ptype        ;[83]
  12559.     cmp    #'Y        ;[83] is this ack?
  12560.     bne    spakd3        ;[83] no
  12561.     lda    #ack        ;[83] just send the single chs for xmodem
  12562. spakd2    jsr    telppc        ;[83] send it down the line
  12563.     jmp    spakcd        ;[83]
  12564. spakd3    cmp    #'N        ;[83] how about nak?
  12565.     bne    spakd7        ;[83] no
  12566.     lda    #nak        ;[83]
  12567.     bne    spakd2        ;[83]
  12568. spakd7    cmp    #'Z        ;[83] end of file
  12569.     bne    spakdl        ;[83]
  12570.     lda    #eot        ;[83]
  12571.     bne    spakd2        ;[83]
  12572. spakdl: ldx   pdtind          ;[25] Are we done?
  12573.     cpx   pdtend          ;[25]         ...
  12574. ;[75]    bpl   spakcd          ;[25] Yes, go call debug again
  12575.     bcs   spakcd          ;[75][25] Yes, go call debug again
  12576.     lda   plnbuf,x      ;[25] Get the byte to send
  12577.     jsr   telppc          ;[25] Ship it out
  12578.     inc   pdtind          ;[25] Increment the index once
  12579.     jmp   spakdl          ;[25] Go to top of data send loop
  12580. ;[87]spakcd: lda   debug          ; Get debug switch
  12581. spakcd:                ;[87]
  12582.     lda    #splocv        ;[87] position to data
  12583.     sta    cv        ;[87] field
  12584.     lda    #0        ;[87]
  12585.     ldx    schr+2        ;[87]
  12586.     ldy    schr+1        ;[87]
  12587.     jsr    prnpct        ;[87] print %
  12588.     lda    #rploch-2    ;[87] and print
  12589.     sta    ch        ;[87]
  12590.     jsr    vtab        ;[87] hope this works for all kinds
  12591.     lda    schr+2        ;[87]
  12592.     ldx    schr+1        ;[87]
  12593.     ldy    schr        ;[87] bytes sent
  12594.     jsr    cv6prr        ;[87] convert to ascii & print
  12595.     lda   debug          ;[87] Get debug switch
  12596. ;[59]    cmp   #off          ;[26] Do we have to do it?
  12597.     beq   spakcr          ;[26] Nope, return
  12598.     lda   #$01          ; Option 1
  12599.     jsr   debg          ; Do the debug stuff
  12600. spakcr: rts          ;     and return
  12601.  
  12602. ;[87]
  12603. ;[87]    convert 24 binary bits to ascii and print them
  12604. ;[87]
  12605. ;[87]    ENTRY:
  12606. ;[87]        a - msb of 24 bits
  12607. ;[87]        x - next 8 bits
  12608. ;[87]        y - lsb of 24 bits
  12609. ;[87]
  12610. cvaprn    pha            ;[87] msb of value
  12611.     txa            ;[87] next 8
  12612.     pha            ;[87]
  12613.     tya            ;[87] lsb of value
  12614.     pha            ;[87]
  12615.     lda    #getln^        ;[87] msb
  12616.     pha            ;[87]
  12617.     lda    #getln\        ;[87] lsb
  12618.     pha            ;[87]
  12619.     jsr    bn2asc        ;[87] this should get interesting
  12620.     sec            ;[87]
  12621.     lda    cvaflw        ;[87] field width
  12622.     sbc    getln        ;[87] leading blanks
  12623.     beq    cvapr2        ;[87] no
  12624.     bpl    cvapr0        ;[87] yes
  12625.     eor    #$ff        ;[87] trouble not wide enough
  12626.     tay            ;[87] so only last cvaflw chs
  12627.     iny            ;[87]
  12628.     jmp    cvapr3        ;[87]
  12629. cvapr0    tay            ;[87] count of leading blanks
  12630.     lda    #'         ;[87]
  12631. cvapr1    jsr    cout        ;[87]
  12632.     dey            ;[87] thru?
  12633.     bne    cvapr1        ;[87]
  12634. cvapr2    ldy    #0        ;[87]
  12635. cvapr3    cpy    getln        ;[87] length of ascii chs
  12636.     beq    cvapr7        ;[87]
  12637.     lda    getln+1,y    ;[87]
  12638.     jsr    cout        ;[87] print it
  12639.     iny            ;[87]
  12640.     bne    cvapr3        ;[87] more
  12641. cvapr7    rts            ;[87]
  12642.     
  12643. cv6prr    pha            ;[87] field 6 wide with cr
  12644.     lda    #6        ;[87]
  12645.     sta    cvaflw        ;[87]
  12646.     pla            ;[87]
  12647.     jsr    cvaprn        ;[87]
  12648.     jmp    prcrlf        ;[87] now add a cr
  12649.     
  12650. ;cv5prr    pha            ;[87] field 5 wide cr
  12651. ;    lda    #5        ;[87]
  12652. ;    sta    cvaflw        ;[87]
  12653. ;    pla            ;[87]
  12654. ;    jsr    cvaprn        ;[87]
  12655. ;    jmp    prcrlf        ;[87] finaly the cr
  12656.  
  12657. cv4prn    pha            ;[87] field 4 wide no cr
  12658.     lda    #4        ;[87]
  12659.     sta    cvaflw        ;[87]
  12660.     pla            ;[87]
  12661.     jmp    cvaprn        ;[87]
  12662.  
  12663. cv3prn    pha            ;[87] field 3 wide no cr
  12664.     lda    #3        ;[87]
  12665.     sta    cvaflw        ;[87]
  12666.     pla            ;[87]
  12667.     jmp    cvaprn        ;[87]
  12668.  
  12669. cv3prr    pha            ;[87] field 3 wide cr
  12670.     lda    #3        ;[87]
  12671.     sta    cvaflw        ;[87]
  12672.     pla            ;[87]
  12673.     jsr    cvaprn        ;[87]
  12674.     jmp    prcrlf        ;[87] finaly the cr
  12675.  
  12676. spnocs    clc          ;     'total characters sent' counter
  12677.     adc   stot          ;         ...
  12678.     sta   stot          ;         ...
  12679. ;[87]    bcc    .+5        ;[75] hate to do this
  12680.     bcc    spakcr        ;[87]
  12681.     inc   stot+1        ;[75]
  12682.     bne    spakcr        ;[87] did this one carry?
  12683.     inc    stot+2        ;[87] yup
  12684.     rts        ;[75] thats all
  12685. fincrc            ;[75]
  12686.     lda   chksum          ; Now, adjust the chksum to fit in 6 bits
  12687.     and   #$c0          ; First, take bits 6 and 7
  12688.     lsr   a          ;     and shift them to the extreme right
  12689.     lsr   a          ;     side of the AC
  12690.     lsr   a          ;         ...
  12691.     lsr   a          ;         ...
  12692.     lsr   a          ;         ...
  12693.     lsr   a          ;         ...
  12694.     clc          ; Now add in the original chksum byte
  12695.     adc   chksum          ;         ...
  12696.     and   #$3f          ; All this should be mod decimal 64
  12697.     rts        ;[75]
  12698. putcrc            ;[75] finalize crc
  12699.     jsr    fincrc    ;[75]
  12700.     clc          ;         ...
  12701.     adc   #sp          ; Put it in printable range
  12702.     rts        ;[75]
  12703. ccrcpu            ;[75]
  12704.     pha          ; Save it in this condition
  12705.     clc          ; Clear carry
  12706.     adc   chksum          ; Add this to the checksum
  12707.     sta   chksum          ;         ...
  12708.     pla          ; Restore character
  12709.     jsr   putplc          ;[25] Send it
  12710.     rts        ;[75]
  12711. rpnocr    lda   pdlen          ;[75] Get the packet data length
  12712.     clc          ;     and add it into the
  12713.     adc   rtot          ;     'total characters received' counter
  12714.     sta   rtot          ;         ...
  12715.     bcc    rpnoc3
  12716.     inc   rtot+1          ;         ...
  12717.     bne    rpnoc3        ;[87] carry more?
  12718.     inc    rtot+2        ;[87] yes
  12719. rpnoc3    rts
  12720.  
  12721. prnpct    pha            ;[87] msb
  12722.     txa        ;[87]
  12723.     pha            ;[87] msb
  12724.     tya        ;[87]
  12725.     pha            ;[87] lsb
  12726.     lda    #0        ;[87] times 100
  12727.     pha            ;[87] msb
  12728.     pha            ;[87]
  12729.     lda    #100        ;[87] lsb
  12730.     pha            ;[87]
  12731.     jsr    mul24        ;[87] 24bit multiply
  12732.     lda    #0        ;[87]
  12733.     pha            ;[87]
  12734.     lda    lcurfl+2    ;[87] msb of current file length
  12735.     pha            ;[87]
  12736.     lda    lcurfl+1    ;[87]
  12737.     pha            ;[87]
  12738.     jsr    div24        ;[87] should be %
  12739.     lda    #pclocv        ;[87]
  12740.     sta    ch        ;[87] cv should still be ok
  12741.     jsr    vtab        ;[87] pos for % number
  12742.     pla            ;[87]
  12743.     tay            ;[87] lsb of q
  12744.     pla            ;[87] msb "
  12745.     tax            ;[87]
  12746.     pla            ;[87] msb of 24 bits
  12747.     jsr    cv3prn        ;[87] this should get interesting
  12748.     pla            ;[87] remainder
  12749.     pla            ;[87] keep the stack straight
  12750.     pla            ;[87]
  12751.     rts        ;[87] bye
  12752.     
  12753. .SBTTL    Packet routines - RPAK - receive a packet
  12754.  
  12755. ;
  12756. ;     This routine receives a standard Kermit packet and then breaks
  12757. ;     it apart returning the individuals components in their respective
  12758. ;     memory locations.
  12759. ;
  12760. ;         Input:
  12761. ;
  12762. ;         Output:     kerbf1-     Pointer to data from packet
  12763. ;             pdlen-     Length of data
  12764. ;             pnum-     Packet number
  12765. ;             ptype-     Packet type
  12766. ;
  12767.  
  12768. ;[87]rpak:    jsr   gobble          ; Gobble a line up from the port
  12769. ;[87]          jmp     rpkfls          ; Must have gotten a keyboard interupt, fail
  12770. rpak                ;[87] hope this speeds it up
  12771. ;[68]    lda   ibmmod          ;[21] Is ibm-mode on?
  12772. ;[62]    cmp   #on          ;[21]         ...
  12773. ;[62]    bne   rpakst          ;[21] If not, start working on the packet
  12774. ;[68]    beq   rpakst          ;[62][21] If not, start working on the packet
  12775. ;[68]rpakc0: jsr   getc          ;[21] Any characters yet?
  12776. ;[68]          jmp     rpakst          ;[21] Got one from the keyboard
  12777. ;[68]    cmp   #xon          ;[21] Is it an XON?
  12778. ;[68]    bne   rpakc0          ;[21] Nope, try again
  12779. ;[87]rpakst:
  12780. ;[59]    jsr   home          ; Clear the screen
  12781. ;[59]    ldx   #rcin01\      ; Give the user info on what we are doing
  12782. ;[59]    ldy   #rcin01^      ;         ...
  12783. ;[59]    jsr   prstr          ; Print the information
  12784.     lda    #rplocv        ;[59] position to data
  12785.     sta    cv        ;[59] field
  12786.     lda    #0        ; msb
  12787.     ldx    rchr+2        ;
  12788.     ldy    rchr+1        ; lsb
  12789.     jsr    prnpct        ; print %
  12790. ;[84]    lda    #rploch        ;[59] and print it
  12791.     lda    #rploch-2        ;[59] and print it
  12792.     sta    ch        ;[59]
  12793.     jsr    vtab        ;[59] hope this works on //e . . .
  12794.     lda    rchr+2        ;[84]
  12795. ;[87]    jsr    prbyte        ;[84]
  12796. ;[87]    lda    rchr+1        ;[84] now for the bytes received
  12797.     ldx    rchr+1        ;[87] now for the bytes received
  12798. ;[87]    ldx    rchr        ;[84]
  12799. ;[87]    lda    rchr        ;[87]
  12800.     ldy    rchr        ;[87]
  12801.     jsr    cv6prr        ;[87] convert and print
  12802. ;[84]    lda   tpak+1          ;[16] Get the total packets count
  12803. ;[59]    jsr   prbyte          ;[16]     and print that
  12804. ;[59]    lda   tpak          ;[16]         ...
  12805. ;[59]    jsr   prbyte          ;[16]         ...
  12806. ;[84]    ldx    tpak        ;[59]
  12807. ;[79]    jsr    prntax        ;[59] one call does it all
  12808. ;[79]    jsr   prcrlf          ; Output a crelf
  12809. ;[87]    jsr    prntal        ;[79] pr a,x in hex & crlf
  12810.     jsr    gobble          ;[87] Gobble a line up from the port
  12811.     jmp    rpkfls          ;[87] Must have gotten a keyboard interupt, fail
  12812.     lda   debug          ; Is debugging on?
  12813. ;[59]    cmp   #off          ;[26]         ...
  12814.     beq   rpaknd          ;[26] Nope, no debugging, continue
  12815.     lda   #$02          ; Option 2 <reflect the fact we are in rpak>
  12816.     jsr   debg          ; Do debug stuff
  12817. rpaknd: lda   #$00          ; Clear the
  12818.     sta   chksum          ;     chksum
  12819.     sta   datind          ;     index into packet buffer
  12820. ;[75]    sta   kerchr          ;     and the current character input
  12821.     sta    rpkexx        ;[75] & extended len index
  12822. rpakfs: jsr   getplc          ; Get a char, find SOH
  12823.           jmp     rpkfls          ; Got a keyboard interupt instead
  12824.     sta   kerchr          ; Save it
  12825.     and   #$7f          ; Shut off H.O. bit
  12826. ;[82]    cmp   #soh          ; Is it an SOH character?
  12827.     ldx    prtcl        ;[83] xmodem?
  12828.     beq    rpakf9        ;[83] no
  12829.     cmp    #'C        ;[83] crc request?
  12830.     beq    rpakf7        ;[83] yes
  12831.     cmp    #eot        ;[83] end of file
  12832.     bne    rpakf3        ;[83] no
  12833.     lda    #'Z        ;[83] use kermit protocol end of file
  12834.     bne    rpakf7        ;[83] common code
  12835. rpakf3    cmp    #ack        ;[83] ok?
  12836.     bne    rpakf5        ;[83]
  12837.     lda    #'Y        ;[83] this is kermits ack
  12838.     bne    rpakf7        ;[83]
  12839. rpakf5    cmp    #nak        ;[83] failure?
  12840.     bne    rpakf9        ;[83]
  12841.     lda    #'N        ;[83] yes kermits nak
  12842. rpakf7    sta    ptype        ;[83]
  12843.     lda    #0        ;[83]
  12844.     sta    pdlen        ;[83] the data len is 0
  12845.     jmp    rpkret        ;[83] good return
  12846. rpakf9                ;[83]
  12847.     cmp   sop          ;[82] Is it a rec SOH character?
  12848.     bne   rpakfs          ; Nope, try again
  12849.     lda    prtcl        ;[83] xmodem?
  12850.     beq    rpakfc        ;[83] no
  12851.     jsr    getplc        ;[83]
  12852.     jmp    rpkfls        ;[83] failure rtn
  12853.     sta    pnum        ;[83] packet #
  12854.     jsr    getplc        ;[83] next ch
  12855. rpakfa    jmp    rpkfls        ;[83] failure rtn
  12856.     eor    #$ff        ;[83] complemented packet #
  12857.     cmp    pnum        ;[83] are they the same?
  12858.     bne    rpakfa        ;[83] no sigh!
  12859.     ldy    #sfxmd        ;[83] set xmodems data size
  12860.     sty    pdlen        ;[83]
  12861.     lda    #'D        ;[83] its data
  12862.     sta    ptype        ;[83]
  12863.     jmp    rpkif7        ;[83]
  12864. rpakfc                ;[83]
  12865.     lda   #$01          ; Set up the switch for receive packet
  12866.     sta   fld          ;         ...
  12867. rpklp1: lda   fld          ; Get switch
  12868.     cmp   #$06          ; Compare for <= 5
  12869.     bmi   rpklp2          ; If it still is, continue
  12870.     jmp   rpkchk          ; Otherwise, do the chksum calcs
  12871. rpklp2: cmp   #$05          ; Check fld
  12872.     bne   rpkif1          ; If it is not 5, go check for SOH
  12873.     lda   datind          ; Fetch the data index
  12874. ;    cmp   #$00          ; If the data index is not null
  12875.     bne   rpkif1          ;     do the same thing
  12876.     jmp   rpkif2          ; Go process the character
  12877. rpkif1: jsr   getplc          ; Get a char, find SOH
  12878.     jmp     rpkfls          ; Got a keyboard interupt instead
  12879.     sta   kerchr          ; Save that here
  12880.     and   #$7f          ; Make sure H.O. bit is off
  12881. ;[82]    cmp   #soh          ; Was it another SOH?
  12882.     cmp   sop          ;[82] Was it another rec SOH?
  12883.     bne   rpkif2          ; If not, we don't have to resynch
  12884. rpkif4                ;[75]
  12885.     lda   #$00          ; Yes, resynch
  12886.     sta   fld          ; Reset the switch
  12887.     sta    rpkexx        ;[75] reset the extended pak index
  12888. rpkif2: lda   fld          ; Get the field switch
  12889.     cmp   #$04          ; Is it <= 3?
  12890.     bpl   rpkswt          ; No, go check the different cases now
  12891.     jsr    rcrccl        ;[75]
  12892. ;[75]    lda   kerchr          ; Yes, it was, get the character
  12893. ;[75]    clc          ;     and add it into the chksum
  12894. ;[75]    adc   chksum          ;         ...
  12895. ;[75]    sta   chksum          ;         ...
  12896. rpkswt: lda   fld          ; Now check the different cases of fld
  12897. ;    cmp   #$00          ; Case 0?
  12898.     bne   rpkc1          ; Nope, try next one
  12899.     lda   #$00          ; Yes, zero the chksum
  12900.     sta   chksum          ;         ...
  12901.     jmp   rpkef          ;     and restart the loop
  12902. rpkc1:    cmp   #$01          ; Is it case 1?
  12903.     bne   rpkc2          ; No, continue checking
  12904.     lda   kerchr          ; Yes, get the length of packet
  12905.     sec          ;         ...
  12906.     sbc   #sp          ; Unchar it
  12907.     bne    rpkc7        ;[75]
  12908.     inc    rpkexx        ;[75] this is extended packet
  12909. rpkc7                ;[75]
  12910.     sec          ;         ...
  12911.     sbc   #$03          ; Adjust it down to data length
  12912. rpke1b                ;[75]
  12913.     sta   pdlen          ; That is the packet data length, put it there
  12914.     jmp   rpkef          ; Continue on to next item
  12915. rpkc2:    cmp   #$02          ; Case 2 (packet number)?
  12916.     bne   rpkc3          ; If not, try case 3
  12917.     lda   kerchr          ; Fetch the character
  12918.     sec          ;         ...
  12919.     sbc   #sp          ; Take it down to what it really is
  12920.     sta   pnum          ; That is the packet number, save it
  12921.     jmp   rpkef          ; On to the next packet item
  12922. rpkc3:    cmp   #$03          ; Is it case 3 (packet type)?
  12923.     bne   rpkc4          ; If not, try next one
  12924.     lda   kerchr          ; Get the character and
  12925.     sta   ptype          ;     stuff it as is into the packet type
  12926.     jmp   rpkef          ; Go on to next item
  12927. rpkc4:    cmp   #$04          ; Is it case 4???
  12928. ;[75]    bne   rpkc5          ; No, try last case
  12929.     beq    .+5        ;[75] hate to do this
  12930.     jmp    rpkc5        ;[75] its a long reach
  12931.     ldy    rpkexx        ;[75] is this extended pkt
  12932.     beq    rpkc9        ;[75] no
  12933.     lda    kerchr        ;[75] get current ch
  12934.     pha            ;[75] save it
  12935.     jsr    rcrccl        ;[75] calc checksum
  12936.     pla            ;[75] retrieve it again
  12937.     sec            ;[75] unchar it
  12938.     sbc    #sp        ;[75]
  12939.     sta    exchs-1,y    ;[75] save it for the hcrc
  12940.     inc    rpkexx        ;[75] ready for the next
  12941.     cpy    #2        ;[75] are we ready for the header crc calc?
  12942.     bne    rpkc6        ;[75] no
  12943.     jsr    fincrc        ;[75] yes get current crc and finalize
  12944.     sta    hcrc        ;[75] save it 
  12945.     jmp    rpklp1        ;[75] next
  12946. rpkc6    cpy    #3        ;[75] have we got all the header?
  12947.     beq    .+5        ;[75] hate to do this
  12948.     jmp    rpklp1        ;[75] no, next
  12949.     lda    exchs+2     ;[75] get hcrc
  12950.     cmp    hcrc        ;[75] is  header crc ok?
  12951.     beq    rpkc8        ;[75] yes
  12952.     lda    hcrc        ;[75] make print ok
  12953.     sta    chksum        ;[75]
  12954.     jmp    rpkpl        ;[75] bad header crc so do no more
  12955. rpkc8    lda    #0        ;[75] msb
  12956.     sta    rpkexx        ;[75] now turn off extended to process data
  12957.     pha            ;[87] msb
  12958.     pha            ;[75]
  12959.     lda    exchs        ;[75] get xl1
  12960.     pha            ;[75] lsb
  12961.     lda    #0        ;[75] msb
  12962.     pha            ;[87]
  12963.     pha            ;[75]
  12964. ;[84]    lda    #95        ;[75] lsb
  12965.     lda    #dpakln+1        ;[84] lsb
  12966.     pha            ;[75]
  12967. ;[87]    jsr    mul16        ;[75] calc the extended len
  12968.     jsr    mul24        ;[87][75] calc the extended len
  12969.     pla            ;[75]  lsb
  12970.     sta    pdlen        ;[75] this should be only data len
  12971.     pla            ;[75] keep stack straight
  12972.     pla            ;[87] "
  12973.     lda    exchs+1        ;[75] get xl2
  12974.     clc            ;[75] now add them together
  12975.     adc    pdlen        ;[75]
  12976.     sta    pdlen        ;[75]
  12977.     dec    pdlen        ;[75] remove the crc byte from the count
  12978.     jmp    rpklp1        ;[75] now process the data
  12979. rpkc9                ;[75]
  12980.     ldy   #$00          ; Set up the data index
  12981.     sty   datind          ;         ...
  12982. rpkchl: ldy   datind          ; Make sure datind is in Y
  12983.     cpy   pdlen          ; Compare to the packet data length, done?
  12984. ;[75]    bmi   rpkif3          ; Not yet, process the character as data
  12985. ;[75]    jmp   rpkef          ; Yes, go on to last field (chksum)
  12986.     bcs   rpkef          ;;[75] Yes, go on to last field (chksum)
  12987. rpkif3: cpy   #$00          ; Is this the first time through the data loop?
  12988.     beq   rpkacc          ; If so, SOH has been checked, skip it
  12989. rpkif7                ;[83]
  12990.     jsr   getplc          ; Get a char, find SOH
  12991.           jmp     rpkfls          ; Got a keyboard interupt instead
  12992.     sta   kerchr          ; Store it here
  12993.     ldx    prtcl        ;[83] xmodem?
  12994.     bne    rpkacc        ;[83] yes
  12995.     and   #$7f          ; Shut H.O. bit
  12996. ;[82]    cmp   #soh          ; Is it an SOH again?
  12997.     cmp   sop          ;[82] Is it a rec SOH again?
  12998.     bne   rpkacc          ; No, go accumulate chksum
  12999.     jmp    rpkif4        ;[75] think this is cleaner
  13000. ;[75]    lda   #$ff          ; Yup, SOH, go resynch packet input once again
  13001. ;[75]    sta   fld          ;         ...
  13002. ;[75]    jmp   rpkef          ;         ...
  13003. rpkacc    jsr    rcrccl        ;[75]
  13004. ;[75]rpkacc: lda   kerchr          ; Get the character
  13005. ;[75]    clc          ;         ...
  13006. ;[75]    adc   chksum          ; Add it to the chksum
  13007. ;[75]    sta   chksum          ;     and save new chksum
  13008.     lda   kerchr          ; Get the character again
  13009.     ldy   datind          ; Get our current data index
  13010.     sta   (kerbf1),y      ; Stuff the current character into the buffer
  13011.     inc   datind          ; Up the index once
  13012.     jmp   rpkchl          ; Go back and check if we have to do this again
  13013. rpkc5:    cmp   #$05          ; Last chance, is it case 5?
  13014.     beq   rpkc51          ; Ok, continue
  13015.     jmp   rpkpe          ; Warn user about program error
  13016. rpkc51    jsr    fincrc        ;[75]
  13017. ;[75]rpkc51: lda   chksum          ; Do chksum calculations
  13018. ;[75]    and   #$c0          ; Grab bits 6 and 7
  13019. ;[75]    lsr   a          ; Shift them to the right (6 times)
  13020. ;[75]    lsr   a          ;         ...
  13021. ;[75]    lsr   a          ;         ...
  13022. ;[75]    lsr   a          ;         ...
  13023. ;[75]    lsr   a          ;         ...
  13024. ;[75]    lsr   a          ;         ...
  13025. ;[75]    clc          ; Clear carry for addition
  13026. ;[75]    adc   chksum          ; Add this into original chksum
  13027. ;[75]    and   #$3f          ; Make all of this mod decimal 64
  13028.     sta   chksum          ;     and resave it
  13029. ;[83]rpkef:    inc   fld          ; Now increment the field switch
  13030. rpkef:                ;[83]
  13031.     lda    prtcl        ;[83] xmodem?
  13032.     beq    rpkef7        ;[83] no
  13033.     jsr    getplc        ;[83] now for the checksum
  13034.     jmp    rpkfls        ;[83] failure rtn
  13035.     sta    kerchr        ;[83] save it for error print
  13036.     cmp    chksum        ;[83] do they agree?
  13037.     bne    rpkpl        ;[83] no
  13038.     beq    rpkret        ;[83] ok
  13039. rpkef7                ;[83]
  13040.     inc   fld          ; Now increment the field switch
  13041.     jmp   rpklp1          ; And go check the next item
  13042. rpkchk: lda   kerchr          ; Get chksum from packet
  13043.     sec          ; Set carry for subtraction
  13044.     sbc   #sp          ; Unchar it
  13045.     cmp   chksum          ; Compare it to the one this Kermit generated
  13046.     beq   rpkret          ; We were successful, tell the caller that
  13047. rpkpl                ;[75]
  13048.     lda   #$06          ; Store the error code
  13049.     sta   errcod          ;         ...
  13050.     lda    #ellocv        ;[75] position to
  13051.     sta    cv        ;[75] error msg line
  13052.     lda    #dbloch        ;[75]
  13053.     sta    ch        ;[75]
  13054.     jsr    vtab        ;[75] so it will print nice
  13055.     ldx   #erms15\      ; Create pointer to error text
  13056.     ldy   #erms15^      ;         ...
  13057.     jsr   prstr          ; Print the chksum error
  13058.     lda   kerchr          ; Print chksum from packet
  13059.     ldx    prtcl        ;[83]
  13060.     bne    rpkpl3        ;[83]
  13061.     sec        ;[75] un char it
  13062.     sbc    #sp    ;[75]
  13063. rpkpl3                ;[83]
  13064.     jsr   prbyte          ;         ...
  13065.     lda   #sp          ; Space things out a bit
  13066.     jsr   cout          ;         ...
  13067.     lda   chksum          ; Now get what we calculated
  13068. ;[79]    jsr   prbyte          ;     and print that
  13069. ;[79]    jsr   prcrlf          ;[53] make it look nice on the screen
  13070.     jsr    prbytl        ;[79] pr byte in hex & crlf
  13071. rpkfls: lda   #$00          ;[26] Zero the index for debug mode
  13072.     sta   pdtind          ;[26]         ...
  13073.     lda   debug          ; Is debug switch on?
  13074. ;[59]    cmp   #off          ;[26]         ...
  13075.     beq   rpkfnd          ;[26] Return doing no debug stuff
  13076.     lda   #$03          ; Option 3 <we are in rpkfls>
  13077.     jsr   debg          ; Output debug information
  13078. rpkfnd    jsr    rpnocr        ;[75] bump number of chs received
  13079. ;[75]rpkfnd: lda   pdlen          ; Get the packet data length
  13080. ;[75]    clc          ;     and add it into the
  13081. ;[75]    adc   rtot          ;     'total characters received' counter
  13082. ;[75]    sta   rtot          ;         ...
  13083. ;[75]    lda   rtot+1          ;         ...
  13084. ;[75]    adc   #$00          ;         ...
  13085. ;[75]    sta   rtot+1          ;         ...
  13086. bperrc                ;[83]
  13087.     lda    #erlocv        ;[59] position to data
  13088.     sta    cv        ;[59] field
  13089.     lda    #rploch        ;[59] and print it
  13090.     sta    ch        ;[59]
  13091.     jsr    vtab        ;[59] hope hope
  13092.     inc    errcnt        ;[59] bump the error count
  13093.     bne    .+5        ;[59] would rather use a label
  13094.     inc    errcnt+1    ;[59]
  13095. ;[87]    ldx    errcnt        ;[59] now to print the count
  13096. ;[87]    lda    errcnt+1    ;[59]
  13097. ;[87]    jsr    prntax        ;[59]
  13098.     lda    #0        ;[87] msb
  13099.     ldx    errcnt+1    ;[87]
  13100.     ldy    errcnt        ;[87] lsb
  13101.     jsr    cv4prn        ;[87] in decimal
  13102.     lda   #false          ; Set up failure return
  13103.     rts          ;     and go back
  13104. rpkret: lda   #$00          ;[26] Zero the index for debug mode
  13105.     sta   pdtind          ;[26]         ...
  13106.     lda   debug          ; Check debug switch
  13107. ;[59]    cmp   #off          ;[26] Is it on?
  13108.     beq   rpkrnd          ;[26] No, return with no debug
  13109.     lda   #$04          ; Yes, use option 4 <we received a packet>
  13110.     jsr   debg          ; Print out the debug info
  13111. rpkrnd    jsr    rpnocr        ;[75] bump number of chs rec
  13112. ;[75]rpkrnd: lda   pdlen          ; Get the packet data length
  13113. ;[75]    clc          ;     and add it into the
  13114. ;[75]    adc   rtot          ;     'total characters received' counter
  13115. ;[75]    sta   rtot          ;         ...
  13116. ;[75]    lda   rtot+1          ;         ...
  13117. ;[75]    adc   #$00          ;         ...
  13118. ;[75]    sta   rtot+1          ;         ...
  13119.     lda   #true          ; Show a successful return
  13120.     rts          ;     and return
  13121. rpkpe:    ldx   #erms16\      ; Set up pointer to error text
  13122.     ldy   #erms16^      ;         ...
  13123.     jsr   prstr          ; Print the error
  13124.     lda   #$07          ; Load error code and store in errcod
  13125.     sta   errcod          ;         ...
  13126.     jmp   rpkfls          ; Go give a false return
  13127. rcrccl                ;[75] calc checksum
  13128.     lda   kerchr          ; Yes, it was, get the character
  13129.     clc          ;     and add it into the chksum
  13130.     adc   chksum          ;         ...
  13131.     sta   chksum          ;         ...
  13132.     rts            ;[75]
  13133. .SBTTL    DEBG  - debugging output routines
  13134.  
  13135. ;
  13136. ;     When the debugging option is turned on, these routines periodically
  13137. ;     display information about what data is being sent or received.
  13138. ;
  13139. ;         Input:     A-     Action type
  13140. ;             Ptype-     Packet type sent or received
  13141. ;             Pnum-     Packet number sent or received
  13142. ;             Pdlen-     Packet data length
  13143. ;
  13144. ;         Output:     Display info on current packet status
  13145. ;
  13146. ;         Registers destroyed:     A,X,Y
  13147. ;
  13148.  
  13149. debg:              ;[64] Hold the action code here
  13150.     sta   debinx          ; Save it here
  13151.     jsr    dbloc        ;[59] position to debug area of screen
  13152.     lda   debug          ;[26] Get the debug switch
  13153.     cmp   #terse          ;[26] Is it terse
  13154.     bne   debgvr          ;[26] Nope, must be Verbose mode
  13155.     jmp   debgtr          ;[26] Yes, to terse debug output
  13156. debgvr: ;[72]lda   state          ;[26] Check the current state
  13157. ;[72];    cmp   #$00          ; If we just started this thing
  13158. ;[72]    beq   debgrf          ;     then we don't need debug output yet
  13159. ;[72]    cmp   #'C          ; If the transmission state is 'complete'
  13160. ;[72]    beq   debgrf          ;     we don't need debug output either
  13161.     lda   #kerrts\      ; Get base address of the routine name and
  13162.     sta   kermbs          ;     action table so that we can calculate
  13163.     lda   #kerrts^      ;     the address of the routine name string
  13164.     sta   kermbs+1      ;     which we need.
  13165.     lda   #kerrns          ; Load the routine name size
  13166.     pha          ; Push that
  13167.     lda    debinx        ;[64] restore action type
  13168. ;[64]    txa          ; Fetch the offset for the one we want
  13169.     pha          ; And push that parameter
  13170.     jsr   genmad          ; Go generate the message address
  13171.     jsr   prstr          ; Now, go print the string
  13172.     lda   ptype          ; Get the current packet type
  13173. ;[83]    sta   debchk          ;[64]     and start the checksum with that
  13174. ;[64]    pha          ; Save this accross the routine calls
  13175.     ora   #$80          ; Make sure H.O. bit is on before printing
  13176. ;[79]    jsr   cout          ; Write that out
  13177. ;[79]    jsr   prcrlf          ; Now write a crelf
  13178.     jsr    coutl        ;[79] print ch & crlf
  13179. ;[64]    pla          ; Get back the packet type
  13180.     lda   debinx          ; Get the debug action index
  13181. ;[64]    bne   debg1          ; If not 'sending', continue
  13182. ;[64]    jsr   debprd          ; Yes, go do some extra output
  13183. ;[64]debg1:    cmp   #$04          ; Have we just received a packet?
  13184. ;[64]    bne   debgrt          ; No, just return
  13185.     beq    debg1        ;[64] are we sending? yes
  13186. ;[83]    cmp    #4        ;[64] just received?
  13187. ;[83]    bne    debgrt        ;[64] no
  13188.     cmp    #3        ;[83]
  13189.     blt    debgrt        ;[83] print both states of receive
  13190. debg1                ;[64]
  13191.     jsr   debprd          ; Print the packet info
  13192. debgrt:
  13193.     jsr    wfakp        ;[75] wait if a ^S keypress for next keypress
  13194.     lda   #true          ; Load true return code into AC
  13195.     rts          ;     and return
  13196. ;[75]debgrf: lda   #false          ; Set up failure return
  13197. ;[75]    rts          ;     and go back
  13198.  
  13199. keyprs    lda    kbd        ;[85] do we have a key press
  13200.     bpl    debg5        ;[85] not yet
  13201.     cmp    #hxoff        ;[85] how about a ^S
  13202.     bne    debg5        ;[85] no must not be a hold screen
  13203.     bit    kbdstr        ;[85] yes, reset keyboard strobe
  13204. debg4    lda    kbd        ;[85] get next keypress
  13205.     bpl    debg4        ;[85] not yet
  13206.     bit    kbdstr        ;[85] no, reset strobe throw away keypress
  13207. debg5    rts            ;[85]
  13208. wfakp                ;[75]
  13209. ;[78]    lda    #4        ;[59] wait 1 sec for viewing
  13210.     lda    #8        ;[78] wait 1 sec for viewing
  13211.     sta    kwrk01        ;[59]
  13212. ;[78]debg3    lda    #255        ;[59] 255 ms wait
  13213. debg3    lda    #220        ;[78] 125 ms wait
  13214.     jsr    wait        ;[59]
  13215. ;[85]    lda    kbd        ;[75] do we have a key press
  13216. ;[85]    bpl    debg5        ;[75] not yet
  13217. ;[85]    cmp    #hxoff        ;[75] how about a ^S
  13218. ;[85]    bne    debg5        ;[75] no must not be a hold screen
  13219. ;[85]    bit    kbdstr        ;[75] yes, reset keyboard strobe
  13220. ;[85]debg4    lda    kbd        ;[75] get next keypress
  13221. ;[85]    bpl    debg4        ;[75] not yet
  13222. ;[85]    bit    kbdstr        ;[75] no, reset strobe throw away keypress
  13223. ;[85]debg5    
  13224.     jsr    keyprs        ;[85] check for a ^s keypress
  13225.     dec    kwrk01        ;[59]
  13226.     bne    debg3        ;[59]
  13227.     rts            ;[75]
  13228. ;
  13229. ;     Debprd - does special information output including packet number,
  13230. ;     packet data length, the entire packet buffer, and the checksum
  13231. ;     of the packet as calculted by this routine.
  13232. ;
  13233.  
  13234. debprd: jsr   prcrlf          ; Start by giving us a new line
  13235.     ldx   #debms1\      ; Get the first info message address
  13236.     ldy   #debms1^      ;         ...
  13237. ;[79]    jsr   prstr          ;     and print it
  13238. ;[79]    jsr   prcrlf          ; New line
  13239.     jsr    prstrl        ;[79]
  13240.     ldx   #debms3\      ;[26] Get address of message text
  13241.     ldy   #debms3^      ;[26]         ...
  13242.     jsr   prstr          ; Print it
  13243.     inc   pdtind          ;[26] Pass the SOH
  13244.     ldx   pdtind          ;[26] Get the index
  13245.     lda   plnbuf,x      ;[26] Get the data length
  13246.     sec          ;[26] Uncharacter this value
  13247.     sbc   #$20          ;[26]         ...
  13248.     sta    kwrk01        ;[75] 0 is extended len packet
  13249.     lda    pdlen        ;[75] this may be extended len packet
  13250. ;[79]    jsr   prbyte          ; Print the hex value
  13251. ;[79]    jsr   prcrlf          ; New line
  13252.     jsr    prbytl        ;[79] pr byte in hex & crlf
  13253.     ldx   #debms2\      ;[26] Get address of next message to print
  13254.     ldy   #debms2^      ;[26]         ...
  13255.     jsr   prstr          ; Print that one
  13256.     inc   pdtind          ;[26] Next character is packet number
  13257.     ldx   pdtind          ;[26]         ...
  13258.     lda   plnbuf,x      ;[26] Load it
  13259.     ldy    prtcl        ;[83] xmodem?
  13260.     beq    debpr1        ;[83]
  13261.     eor    #$ff        ;[83] complemented packet #
  13262.     dec    pdtind        ;[83] keep things straight
  13263.     jmp    debpr3        ;[83]
  13264. debpr1                ;[83]
  13265.     sec          ;[26] Uncharacter this value
  13266.     sbc   #$20          ;[26]         ...
  13267. ;[79]    jsr   prbyte          ; Print the hex value
  13268. ;[79]    jsr   prcrlf          ; New line
  13269. debpr3                ;[83]
  13270.     jsr    prbytl        ;[79] pr byte in hex & crlf
  13271.     inc   pdtind          ;[26] Bypass the packet type
  13272.     ldy   #$ff          ;[26] Start counter at -1
  13273.     sty   kwrk02          ;[26] Store it here
  13274.     ldy    prtcl        ;[83] xmodem?
  13275.     bne    debprc        ;[83] yes
  13276.     ldy    kwrk01        ;[75] is this extended len pkt
  13277.     bne    debprc        ;[75] no
  13278.     inc    pdtind        ;[75] skip xl1
  13279.     inc    pdtind        ;[75] skip xl2
  13280.     inc    pdtind        ;[75] skip hcrc
  13281. debprc: inc   kwrk02          ;[26] Increment the counter
  13282.     ldy   kwrk02          ;[26] Get counter
  13283.     cpy   pdlen          ; Are we done printing the packet data?
  13284. ;[75]    bpl   debdon          ; If so, go finish up
  13285.     bcs   debdon          ;[75] If so, go finish up
  13286.     inc   pdtind          ;[26] Point to next character
  13287.     ldx   pdtind          ;[26] Fetch the index
  13288.     lda   plnbuf,x      ;[26] Get next byte from packet
  13289.     jsr   prchr          ; Go output special character
  13290. ;[75]    lda   #hspace          ;[26] Now print 1 space
  13291. ;[75]    jsr   cout          ;         ...
  13292.     jmp   debprc          ; Go check next character
  13293. debdon: jsr   prcrlf          ; Next line
  13294.     ldx   #debms4\      ; Get the address to the 'checksum' message
  13295.     ldy   #debms4^      ;         ...
  13296.     jsr   prstr          ; Print that message
  13297.     inc   pdtind          ;[26] Get next byte, this is the checksum
  13298.     ldx   pdtind          ;[26]         ...
  13299.     lda   plnbuf,x      ;[26]         ...
  13300.     ldx    prtcl        ;[83] xmodem?
  13301.     bne    debdo3        ;[83] yes
  13302.     sec          ;[26] Uncharacter this value
  13303.     sbc   #$20          ;[26]         ...
  13304. ;[79]    jsr   prbyte          ; Print the hex value of the checksum
  13305. ;[79]    jsr   prcrlf          ; Print two(2) crelfs
  13306. debdo3                ;[83]
  13307.     jsr    prbytl        ;[79] pr byte in hex & crlf
  13308. ;[79]    jsr   prcrlf          ;         ...
  13309.     jmp   prcrlf          ;[79]         ...
  13310. ;[79]    rts          ;     and return
  13311.  
  13312. .SBTTL    Terse debug output
  13313.  
  13314. ;
  13315. ;     This routine does brief debug output. It prints only the contents
  13316. ;     of the packet with no identifying text.
  13317. ;
  13318.  
  13319. debgtr: ;[75]txa          ;[26] Look at Option
  13320.     lda    debinx        ;[75] option has been moved
  13321. ;    cmp   #$00          ;[26] Sending?
  13322.     beq   debgsn          ;[26] Yes, output 'SENDING: '
  13323.     cmp   #$03          ;[26] Failed receive?
  13324.     beq   debgrc          ;[26] Yes, output 'RECEIVED: '
  13325.     cmp   #$04          ;[26] Receive?
  13326.     beq   debgrc          ;[26] Yes, output 'RECEIVED: '
  13327.     rts          ;[26] Neither, just return
  13328. debgsn: ldx   #sstrng\      ;[26] Get ready to print the string
  13329.     ldy   #sstrng^      ;[26]         ...
  13330. ;[79]    jsr   prstr          ;[26] Do it!
  13331. ;[79]    jsr   prcrlf          ;[26] Print a crelf
  13332. ;[83]    jsr    prstrl        ;[79]
  13333. ;[83]    jmp   debgdp          ;[26] Go dump the packet
  13334.     bne    debgr3        ;[83] common code
  13335. debgrc: ldx   #rstrng\      ;[26] Get ready to print the string
  13336.     ldy   #rstrng^      ;[26]         ...
  13337. ;[79]    jsr   prstr          ;[26] Do it!
  13338. ;[79]    jsr   prcrlf          ;[26] Print a crelf
  13339. debgr3                ;[83]
  13340.     jsr    prstrl        ;[79]
  13341. debgdp: ldx   pdtind          ;[26] Get index
  13342.     cpx   pdtend          ;[26] Are we done?
  13343. ;[75]    bpl   debgfn          ;[26] Yes, return
  13344.     bcs   debgfn          ;[75][26] Yes, return
  13345.     lda   plnbuf,x      ;[26] Get the character
  13346.     jsr   prchr          ;[26] Print it
  13347. ;[75]    lda   #hspace          ;[26] Print a space
  13348. ;[75]    jsr   cout          ;[26]         ...
  13349.     inc   pdtind          ;[26] Advance the index
  13350.     jmp   debgdp          ;[26] Do next character
  13351. debgfn: jsr   prcrlf          ;[26] Print a crelf then...
  13352.     jmp    debgrt        ;[75] wait if a ^S keypress for next keypress
  13353. ;[75]    rts          ;[26]     Return
  13354.     
  13355.  
  13356. dbloc            ;[59] position to debug area on screen
  13357.     lda    #dblocv        ;[59] place for debug output on screen
  13358.     sta    cv        ;[59]
  13359.     lda    #dbloch        ;[59]
  13360.     sta    ch        ;[59]
  13361.     jsr    vtab        ;[59] hope hope
  13362. ;[75]    jsr    clreop        ;[59]
  13363.     jmp    clreop        ;[75][59]
  13364. ;[75]    rts            ;[59]
  13365.  
  13366.  
  13367.     .ifeq <ftcom-ftappl>
  13368. .SBTTL    Dos   routines
  13369.  
  13370. ;
  13371. ;     These routines handle files and calls to the DOS
  13372. ;
  13373.  
  13374. ;
  13375. ;     This routine opens a file for either input or output. If it
  13376. ;     opens it for output, and the file exists, and file-warning is
  13377. ;     on, the routine will issue a warning and attempt to modify
  13378. ;     the filename so that it is unique.
  13379. ;
  13380. ;         Input:     A- Fncrea - open for read
  13381. ;                Fncwrt - open for write
  13382. ;
  13383. ;         Output:     File is opened or error is issued
  13384. ;
  13385.  
  13386. openf
  13387.     pha          ; Hold the parameter on the stack
  13388. ;[84]    jsr   movdds          ;[40] Go move in the default slot and disk
  13389.     ldx    dosflg        ;[66]
  13390.     bne    .+5        ;[66] is this prodos? yes
  13391.     jsr    opnupc        ;[66] no force file name to upper case
  13392.     cmp   #fncwrt          ; Are we openning for output?
  13393.     beq   openfw          ; Open for output
  13394.     ldx    dosflg        ;[59] this is input
  13395.     beq    openf2        ;[59]prodos? no
  13396.     jsr    prodos        ;[59] get file info
  13397.     .byte    gfilin        ;[59]
  13398.     .word    gsinfo        ;[59]
  13399.     bcc    .+5        ;[59] any error? no
  13400.     jsr    perror        ;[59] yes
  13401. ;[87]    lda    filmod        ;[59] get file type
  13402. ;[87]    cmp    #5        ;[78] is this type other?
  13403. ;[87]    bcs    pckfty        ;[78] yes, just use it
  13404. ;[87]    cmp    #4        ;[59] make sure its in range
  13405. ;[87]    bmi    openf0        ;[59] ok
  13406. ;[87]    lda    #3        ;[59] make it fit
  13407. ;[87]openf0    sta    kwrk01        ;[59] now * 3
  13408. ;[87]    asl    kwrk01        ;[59] double it
  13409. ;[87]    clc            ;[59] so we can add
  13410. ;[87]    adc    kwrk01        ;[59] finally * 3
  13411. ;[87]    tax            ;[59] indexed jump needs it here
  13412. ;[81]    lda    #pktyp\        ;[59]
  13413. ;[81]    sta    jtaddr        ;[59]
  13414. ;[87]    ldy    #pktyp\        ;[81]
  13415. ;[87]    lda    #pktyp^        ;[59]
  13416. ;[87]    jmp    indexj        ;[59] and indexed jump
  13417. ;[87]pktyp    jmp    itstxt        ;[59] text file
  13418. ;[87]    jmp    itsiba        ;[59] int basic
  13419. ;[87]    jmp    itsaba        ;[59] applesoft basic
  13420. ;[87]    lda    #ptbin        ;[59] binary file
  13421. ;[87]pckfty    cmp    gfilty        ;[59] is this the same kind
  13422. ;[87]    beq    pgdfl        ;[59] yes
  13423. ;[87]    ldx    #erms1d\    ;[59] tell wrong type
  13424. ;[87]    ldy    #erms1d^    ;[59]
  13425. ;[87]    jsr    prstr        ;[59]
  13426. ;[87]    jsr    shmod        ;[59] and show mode
  13427. ;[87]    pla            ;[59] keep the stack straight
  13428. ;[87]    lda    #false        ;[59]
  13429. ;[87]    rts            ;[59] and return
  13430.     lda    gfilty        ;[87]
  13431.     cmp    #ptbin        ;[87] bin file?
  13432.     bne    opfl02        ;[87]
  13433.     lda    #4        ;[87] yes set filmod
  13434.     bne    opfl05        ;[87] and open the file
  13435. opfl02    cmp    #pttxt        ;[87] text file?
  13436.     bne    opfl03        ;[87]
  13437.     lda    #0        ;[87] yes
  13438.     beq    opfl05        ;[87]
  13439. opfl03    cmp    #ptbas        ;[87] applesoft?
  13440.     bne    opfl04        ;[87]
  13441.     lda    #2        ;[87] yes
  13442.     bne    opfl05        ;[87]
  13443. opfl04    cmp    #ptibas        ;[87] integer basic?
  13444.     bne    opfl05        ;[87]
  13445.     lda    #1        ;[87] yes
  13446. opfl05    sta    filmod        ;[87] ok its type other    
  13447. pgdfl    jsr    prodos        ;[59] ok open file
  13448.     .byte    opnfl        ;[59]
  13449.     .word    propen        ;[59]
  13450.     bcc    .+5        ;[59] good open? yes
  13451.     jsr    perror        ;[59] no
  13452.     jmp    prok        ;[59] carry on
  13453. ;[87]itstxt    lda    #pttxt        ;[59] ascii text type
  13454. ;[87]    jmp    pckfty        ;[59]
  13455. ;[87]itsaba    lda    #ptbas        ;[59] prodos applesoft basic
  13456. ;[87]    jmp    pckfty        ;[59]
  13457. ;[87]itsiba    lda    #ptibas        ;[59] wonder what to do with integer
  13458. ;[87]    jmp    pckfty        ;[59]
  13459. openf2                ;[59] hope we have the reach
  13460.     lda   #$01          ; Open for input, doscmi must be non-zero
  13461.     sta   doscmi          ;     so that we do not allocate the file
  13462.     jmp   opnmfs          ; Start moving the filename
  13463. openfw: lda   #on          ; Set the 'first mod' switch
  13464.     sta   dosffm          ;     in case we have to alter the filename
  13465.     lda   filwar          ; Get the file warning switch
  13466. ;[59]    cmp   #on          ;[59] Is it on?
  13467.     beq   opnlu1          ; If not, don't do the lookup
  13468. opnlu:    jsr   lookup          ; Do the lookup
  13469. opnlu1    jmp     opnnlu          ; Lookup succeeded, fcb1 contains the filename
  13470.     lda   dosffm          ; Is this the first time through?
  13471. ;[59]    cmp   #on          ;         ...
  13472.     beq   opnalt          ; [59]If not, continue
  13473.     ldx   #erms1a\      ; Otherwise, print an error message since
  13474.     ldy   #erms1a^      ;     the file already exists
  13475. ;[79]    jsr   prstr          ;         ...
  13476. ;[79]    jsr    prcrlf        ;[59]
  13477.     jsr    prstrl        ;[79]
  13478. opnalt: jsr   alterf          ; No good, go alter the filename
  13479.     jmp   opnlu          ; Try the lookup again
  13480. propn    jsr    prodos        ;[59] try to open the file
  13481.     .byte    opnfl        ;[59]
  13482.     .word    propen        ;[59] open par list
  13483.     bcc    prok        ;[59] we have the file
  13484.     cmp    #nofile        ;[59] do we have to create one?
  13485.     beq    .+5        ;[59] yes
  13486.     jsr    perror        ;[59] sigh we have trouble
  13487.     lda    filmod        ;[59] get file type
  13488.     cmp    #5        ;[78] how about type other?
  13489.     bcs    prostz        ;[78] yes, just use filmod
  13490.     cmp    #4        ;[59] make sure its in range
  13491.     bmi    .+4        ;[59] ok
  13492.     lda    #3        ;[59] make it fit
  13493.     sta    kwrk01        ;[59] now * 3
  13494.     asl    kwrk01        ;[59] double it
  13495.     clc            ;[59] so we can add
  13496.     adc    kwrk01        ;[59] finally * 3
  13497.     tax            ;[59] indexed jump needs it here
  13498. ;[81]    lda    #protyp\        ;[59]
  13499. ;[81]    sta    jtaddr        ;[59]
  13500.     ldy    #protyp\        ;[81]
  13501.     lda    #protyp^        ;[59]
  13502.     jmp    indexj        ;[59] and indexed jump
  13503. protyp    jmp    dost0        ;[59] text file
  13504.     jmp    dost1        ;[59] int basic
  13505.     jmp    dost2        ;[59] applesoft basic
  13506.     lda    #ptbin        ;[59] binary file
  13507. prostz    ldx    #0        ;[78] wish i could do better for aux
  13508.     ldy    #0        ;[78]
  13509. prosty    sta    pfilty        ;[59] set file type
  13510.     stx    pfilta        ;[78] set aux type LSB
  13511.     sty    pfilta+1    ;[78] & MSB
  13512.     jsr    prodos        ;[59] now to create a file
  13513.     .byte    crefil        ;[59]
  13514.     .word    create        ;[59]
  13515.     bcc    propn        ;[59] ok, now open it
  13516.     jsr    perror        ;[59] sigh
  13517. prok    lda    refnu        ;[59] ref # must be set lots of places
  13518.     sta    prdwr+1        ;[59] first the read/write par
  13519.     sta    pmark+1        ;[59] also the mark/eof
  13520.     sta    pclose+1    ;[59] also the close
  13521.     lda    #mxdb-1\    ;[59] size of full buf writes
  13522.     sta    prdwr+4        ;[59]
  13523.     jmp    prook        ;[59] together again
  13524. dost0    lda    #pttxt        ;[59] text file
  13525. ;[78]    jmp    prosty        ;[59]
  13526.     jmp    prostz        ;[78]
  13527. dost2    lda    #ptbas        ;[59] applesoft basic
  13528. dostt    ldy    #8        ;[78] is this always true of basic? MSB
  13529.     ldx    #1        ;[78] LSB
  13530.     jmp    prosty        ;[59]
  13531. dost1    lda    #ptibas        ;[59] treat int basic
  13532. ;[78]    jmp    prosty        ;[59]
  13533.     jmp    dostt        ;[78]
  13534. opnnlu
  13535.     lda    dosflg        ;[59] is this prodos?
  13536.     bne    propn        ;[59] yes
  13537.     lda   #$00          ; Make doscmi zero so it allocates the file
  13538.     sta   doscmi          ;     if it is not found
  13539. ;[84]opnmfs: ldy   #$00          ; Move the filename from the FCB to
  13540. opnmfs:                ;[84]
  13541. ;[84]opnmfn: lda   fcb1,y          ;     the primary filename buffer in DOS
  13542. ;[84]    beq    opnfl2        ;[59] a null ch? yes
  13543. ;[66]    and    #$7f        ;[62] make it ascii
  13544. ;[66]    cmp    #'a        ;[62] is this < a ?
  13545. ;[66]    bmi    opnmf1        ;[62] yes its not in lowercase range
  13546. ;[66]    cmp    #'{        ;[62] how about beyond the range?
  13547. ;[66]    bpl    opnmf1        ;[62] yes
  13548. ;[66]    and    #$df        ;[62] convert lower to upper case
  13549. ;[66]opnmf1                ;[62]    
  13550. ;[84]    ora   #$80          ; Make sure this is negative ascii
  13551. ;[59]    cmp   #$80          ; Was the character a null?
  13552. ;[84]    bne   opnmfc          ; If not, continue
  13553. ;[84]opnfl2    lda   #hspace          ; If so, make it a space
  13554. ;[84]opnfls: sta   primfn,y      ;[28] Stuff the space there
  13555. ;[84]opnfls: sta   getln+7,y      ;[84] Stuff the space there
  13556. ;[84]    iny          ;[28] Up the pointer
  13557. ;[84]    cpy   #mxfnl+1      ;[28] Done
  13558. ;[84]    bpl   opnfil          ;[28] Yup, continue
  13559. ;[84]    jmp   opnfls          ;[28] No, loop again
  13560. ;[84]    bmi   opnfls          ;[84] No, loop again
  13561. ;[84]opnmfc: sta   primfn,y      ;         ...
  13562. ;[84]opnmfc: sta   getln+7,y      ;[84]         ...
  13563. ;[84]    iny          ; Up the buffer index once
  13564. ;[84]    cpy   #mxfnl+1      ; Done?
  13565. ;[84]    bmi    opnmfn    ;[59]
  13566. ;    bpl   opnfil          ; If so, leave
  13567. ;    jmp   opnmfn          ; Nope, continue move
  13568. ;[84]opnfil: lda   filmod          ; Use the file-type mode as the file-type
  13569. ;[84]    jsr   dosopn          ; Open file with type-checking
  13570. opnfil: lda   #fncopn        ;[84] open command
  13571.     jsr    initfm        ;[84] do it
  13572.     lda    ftype        ;[84] see if file type match
  13573.     and    #$7f        ;[84] hi bit on when file locked
  13574. ;[87]    cmp    filmod        ;[84] 
  13575. ;[87]    beq    prook        ;[84] good open
  13576. ;[87]    jsr    clonlb        ;[84] no, close it
  13577. ;[87]    lda    #12        ;[84] entry to error msg
  13578. ;[87]    jmp    nonft0        ;[84] tattle
  13579.     sta    filmod        ;[87] set file type from file
  13580. prook                ;[59]
  13581.     jsr    opnpfn        ;[66]
  13582.     pla          ; Get the parameter back
  13583.     ldx   #mxdb          ;[59] Maximum DOS buffer size
  13584.     cmp   #fncwrt          ; Are we writing?
  13585.     bne   opnsiw          ;[59] If so, set the indices up for writing
  13586.     ldx   #0          ;[59] Maximum DOS buffer size
  13587.     inc    prdwr+4        ;[59] just in case were prodos
  13588. opnsiw                ;[59]
  13589. ;[59]    sta   dsbind          ; Stuff that in the index to initialize it
  13590.     stx   dsbind          ; Stuff that in the index to initialize it
  13591.     lda   #mxdb-1          ;         ...
  13592.     sta   dsbend          ; Initialize end-of-buffer pointer
  13593.     lda    #0        ;[78] make sure the eof is clear
  13594.     sta    eodind        ;[78]
  13595.     lda   #true          ; If it returns here, there were no errors
  13596.     rts
  13597. opnupc:    pha            ;[66]
  13598.     ldy   #$00          ;[66] Move the filename from the FCB to
  13599. opnup1: lda   fcb1,y          ;[66]     the primary filename buffer in DOS
  13600. ;[81]    and    #$7f        ;[66] make it ascii
  13601. ;[81]    cmp    #'a        ;[66] is this < a ?
  13602. ;[81]    bmi    opnuc2        ;[66] yes its not in lowercase range
  13603. ;[81]    cmp    #'{        ;[66] how about beyond the range?
  13604. ;[81]    bpl    opnuc2        ;[66] yes
  13605. ;[81]    and    #$df        ;[66] convert lower to upper case
  13606. ;[81]opnuc2                ;[66]    
  13607.     jsr    convuc        ;[81] convert to upper case
  13608.     ora   #$80          ;[66] Make sure this is negative ascii
  13609.     sta   fcb1,y      ;[66]         ...
  13610.     iny          ;[66] Up the buffer index once
  13611.     cpy   #mxfnl+1      ;[66] Done?
  13612.     bmi    opnup1    ;[66]
  13613.     pla            ;[66] restore acc
  13614.     rts            ;[66]
  13615. opnpfn    lda    fnflag        ;[66] should we print file name?
  13616.     beq    prook3    ;[66] no
  13617.     lda    #erlocv        ;[66] put it at the start or the retries
  13618.     sta    cv        ;[66]
  13619.     lda    #0        ;[66] at the start
  13620.     sta    ch        ;[66]
  13621.     jsr    vtab        ;[66] position for the print
  13622.     ldx    #fcb1\        ;[66] name is here null terminated
  13623.     ldy    #fcb1^        ;[66] convienient right
  13624.     lda    nfcb1        ;[66] get the number of chs to print
  13625.     jsr    prstrn        ;[66]
  13626.     dec    fnflag        ;[66] only once
  13627. prook3    rts            ;[66]
  13628. coutl    jsr    cout        ;[79] print ch followed by crlf
  13629.     jmp    prcrlf        ;[79]
  13630. prbytl    jsr    prbyte        ;[79] pr byte & crlf
  13631.     jmp    prcrlf        ;[79]
  13632. prbydc    tay            ;[87] print byte in a in ascii
  13633.     lda    #0        ;[87] no cr
  13634.     tax            ;[87]
  13635.     jmp    cv3prn        ;[87] let it do the rts
  13636. prbydr    tay            ;[87] print byte in a in ascii
  13637.     lda    #0        ;[87] cr
  13638.     tax            ;[87]
  13639.     jmp    cv3prr        ;[87] let it do the rts
  13640. prntal    jsr    prntax        ;[79] pr a,x & crlf
  13641.     jmp    prcrlf        ;[79]
  13642. ;praxdc    pha            ;[87] cvt ax to ascii print no cr
  13643. ;    txa            ;[87]
  13644. ;    tay            ;[87] lsb
  13645. ;    pla            ;[87]
  13646. ;    tax            ;[87]
  13647. ;    lda    #0        ;[87] msb
  13648. ;    jmp    cv5prn        ;[87] cvt
  13649. ;praxdr    pha            ;[87] cvt ax to ascii print cr
  13650. ;    txa            ;[87]
  13651. ;    tay            ;[87] lsb
  13652. ;    pla            ;[87]
  13653. ;    tax            ;[87]
  13654. ;    lda    #0        ;[87] msb
  13655. ;    jmp    cv5prr        ;[87] cvt
  13656. prchrr    jsr    prchr        ;[79] print ch (special) followed by crlf
  13657.     jmp    prcrlf        ;[79]
  13658. prstrl    jsr    prstr        ;[79] print string terminated with $0
  13659.     jmp    prcrlf        ;[79] and let it do the rts
  13660. prstrn    stx    saddr        ;[66] setup page 0
  13661.     sty    saddr+1        ;[66]
  13662.     tax            ;[66] get the count
  13663.     beq    prook3        ;[66] nothing to do
  13664.     ldy    #0        ;[66]
  13665. prstr1    lda    (saddr),y        ;[66] get a ch
  13666.     ora    #$80        ;[66] make sure we have high bit on
  13667.     jsr    dely        ;[66] so one can see it
  13668.     iny            ;[66]
  13669.     dex            ;[66]
  13670.     bne    prstr1        ;[66] are we thru, no
  13671.     rts            ;[66] yes
  13672. prncfm    sta    kwrk01        ;[87] now for show format
  13673.     inx            ;[87] address is one more
  13674.     bne    .+3        ;[87] carry? no
  13675.     iny            ;[87] yup msb
  13676.     jsr    prstrn        ;[87] first print the count
  13677.     lda    #lensh        ;[87] length of show line
  13678.     sec            ;[87] less whats already there
  13679.     sbc    kwrk01        ;[87]
  13680.     ldx    #shin2o\        ;[87]
  13681.     ldy    #shin2o^        ;[87]
  13682.     jmp    prstrn        ;[87]
  13683.     
  13684. ;[59]opnsiw: lda   #$00          ; Set the index to zero
  13685. ;[59]    sta   dsbind          ;         ...
  13686. ;[59]    lda   #mxdb-1          ;[59] The end of buffer should be set to
  13687. ;[59]    sta   dsbend          ;     half the length of a DOS buffer
  13688. ;[59]    lda   #true          ; Then return true
  13689. ;[59]    rts          ;         ...
  13690.  
  13691. ;
  13692. ;     Lookup - searches for a filename in a directory. It is used to
  13693. ;     support file warning during the opening of a file.
  13694. ;
  13695.  
  13696. lookup:
  13697.     lda    dosflg        ;[59] prodos?
  13698.     beq    looku1        ;[59] no
  13699.     jsr    filenf        ;[86] fix up file name
  13700.     jsr    prodos        ;[59] get file info
  13701.     .byte    gfilin        ;[59]
  13702.     .word    gsinfo        ;[59] get/set par list
  13703.     bcc    looku2        ;[59] we got this file name
  13704.     cmp    #nofile        ;[59] did we get the nofile ans?
  13705.     beq    locfnf        ;[59] yes
  13706.     ldx    fcb1        ;[85] lets check for a leading alpha
  13707.     cpx    #'A        ;[85]
  13708.     blt    looku0        ;[85] no, make it an A
  13709.     cpx    #'Z+1        ;[85]
  13710.     blt    looku7        ;[85] yes, a leading alpha
  13711. ;[87]looku0    ldx    #'A        ;[85]
  13712. looku0    ldx    #'X        ;[87]
  13713.     stx    fcb1        ;[85] make it alpha
  13714.     jmp    lookup        ;[85]
  13715. looku7                ;[85]
  13716.     jsr    perror        ;[59] sigh
  13717. looku1                ;[59]
  13718. ;[84]    jsr   lookop          ;[60] Go move in default slot and drive
  13719.     lda    #fncopn        ;[84] open
  13720. ;    sta    doscmi        ;[84] so init will set x non 0 properly
  13721.     jsr    initpo        ;[84] set the parameters up
  13722. ;[84]    lda   #fcb1\          ; Get the address of the filename buffer
  13723. ;[84]    sta   fnadrl          ;     and stuff it where it will be found
  13724. ;[84]    lda   #fcb1^          ;     by the 'locate' routine
  13725. ;[84]    sta   fnadrh          ;         ...
  13726. ;[84]    jsr   locent          ; Go try to locate that file
  13727.     ldx    #1        ;[84] make it non 0 so no file allocation
  13728.     jsr    dosfmg        ;[84] use the file manager, hope we dont need close
  13729.     bcs   locfnf          ; File not found? We are in good shape
  13730.     lda   #errfae          ; Store the error code
  13731.     sta   errcod          ;         ...
  13732. looku2    jmp   rskp          ; Return with skip, we have to alter filename
  13733. locfnf: rts          ; Return without a skip
  13734. ;[84]lookop    lda    defdrv    ;[60] default drive
  13735. ;[84]    sta    cdisk    ;[60] fmgr parm list
  13736. ;[84]    lda    defslt    ;[60] slot
  13737. ;[84]    sta    cslot    ;[60]
  13738. ;[84]    lda    defvol    ;[60] volume number
  13739. ;[84]    sta    cvol    ;[60]
  13740. ;[84]    ldx    #fncopn    ;[60] open for fmgr
  13741. ;[84]    stx    opcod    ;[60] into param list
  13742. ;[84]    stx    doscmi    ;[60] tell it to ignore file type
  13743. ;[84]    jsr    dosfmn        ;[60] fmgr
  13744. ;[84]    jsr    dosfmg    ;[84] x non 0 is what we want
  13745. ;[84]    rts        ;[60] return
  13746.  
  13747. ;
  13748. ;     Alterf - changes a filename in the filename buffer to make it unique.
  13749. ;     It accomplishes this in the following manner.
  13750. ;
  13751. ;         1) First time through, it finds the last significant character
  13752. ;             in the filename and appends a '.0' to it.
  13753. ;
  13754. ;         2) Each succeeding time, it will increment the trailing integer
  13755. ;             that it inserted the first time through.
  13756. ;
  13757.  
  13758. alterp            ;[59]
  13759.     ldy    nfcb1        ;[59] get # chs in name
  13760.     cpy    #mxpfn-2    ;[59] <=12 chs
  13761.     bmi    altera        ;[59] yes there is room for our 3 chs
  13762. ;[86]    lda    #'/+$80        ;[59] look for start of file name
  13763.     lda    #'/        ;[86] look for start of file name
  13764. alter2    cmp    fcb1-1,y    ;[59] got the start?
  13765.     beq    alter4        ;[59] yes
  13766.     dey            ;[59] no
  13767.     bne    alter2        ;[59] try again
  13768.     jmp    alterc        ;[59] we are at the start
  13769. alter4    sty    kwrk01        ;[59] now find the size of the file name
  13770.     lda    nfcb1        ;[59] first the # chs in path
  13771.     sec            ;[59] necessary for subtract
  13772.     sbc    kwrk01        ;[59] now we have the size of the name
  13773.     cmp    #mxpfn-2    ;[59] room for version?
  13774.     bpl    alterc        ;[59] no 
  13775.     ldy    nfcb1        ;[59]
  13776.     cpy    #mxppth-2    ;[59] room in the path ?
  13777.     bmi    altera        ;[59] yes
  13778.     cmp    #4        ;[59] <=3 chs in filename?
  13779.     bmi    altng        ;[59] yes we cant do it
  13780. alterc    jsr    dbloc        ;[59] position screen for debug area
  13781.     ldx    #erms1e\    ;[59] tell we have to change tail of filename
  13782.     ldy    #erms1e^        ;[59]
  13783. ;[79]    jsr    prstr        ;[59]
  13784. ;[79]    jsr    prcrlf        ;[59]
  13785.     jsr    prstrl        ;[79]
  13786.     ldy    nfcb1        ;[59] # chs in name
  13787.     dey            ;[59] now ready for
  13788.     dey            ;[59] the modification
  13789.     dey            ;[59] 
  13790.     jmp    altigy        ;[59]
  13791. altera                ;[59]
  13792.     tya            ;[59] save this
  13793.     iny            ;[59] tell prodos about more chs
  13794.     iny            ;[59]
  13795.     iny            ;[59]
  13796.     sty    nfcb1        ;[59] now you have +3
  13797.     tay            ;[59] restore original pointer
  13798. alter6            ;[59] null terminate string
  13799.     jmp    altigy        ;[59]
  13800. ;[84]alterf: jsr   movdds          ;[40] Go move in default slot and drive
  13801. alterf                ;[84]
  13802.     lda   dosffm          ; Get the 'first mod' flag
  13803. ;[59]    cmp   #on          ; Is it on?
  13804.     beq   altsm          ; If it is, do an initial modification
  13805. ;[59]    jmp   altsm          ; Otherwise, just increment the version
  13806.     lda   #off          ; Shut the 'first mod' flag off
  13807.     sta   dosffm          ;         ...
  13808.     lda    dosflg        ;[59]prodos?
  13809.     bne    alterp        ;[59] yes
  13810.     ldy   #mxfnl          ; Stuff the maximum filename length in y
  13811. altgnc: lda   fcb1,y          ; Get the character from the buffer
  13812.     cmp   #hspace          ; Is it a space?
  13813.     bne   altco          ; If not, we can continue with the alteration
  13814.     dey          ; Down the index once
  13815.     bpl   altgnc          ; Get the next character
  13816.     ldy   #$00          ; There is no filename, so use 0 as the index
  13817. altco:    sty   dosfni          ; Save the filename index
  13818.     iny          ; Increment it twice
  13819.     iny          ;         ...
  13820.     cpy   #mxfnl          ; Does this exceed the filename length?
  13821.     bpl   altng          ; Cannot do the alterations
  13822. ;[59]    ora   #$80          ; Make it negative ascii
  13823.     ldy   dosfni          ; Get the original index back
  13824.     iny          ; Up it once
  13825. altigy    lda   #'.+$80          ; [59]Get the dot
  13826.     sta   fcb1,y          ; Store the dot
  13827.     lda   #$00          ; Zero the version count
  13828.     sta   dosfvn          ;         ...
  13829.     iny          ; Up the index again
  13830.     sty   dosfni          ; This will be saved for future alterations
  13831.     jsr   altstv          ; Go store the version in the filename
  13832.     iny            ;[66] got to keep count correct
  13833.     sty    nfcb1        ;[66]
  13834.     rts          ;     and return
  13835. altsm:    inc   dosfvn          ;[59] Get the file version number
  13836. ;[59]    inx          ; Increment it
  13837.     ldx   dosfvn          ;[59] Save the new version number
  13838.     beq   altng          ; Cannot alter name
  13839.     txa          ; Get the version number in the AC
  13840.     jsr   altstv          ; Go store the version
  13841.     rts          ; And return
  13842. altng:    lda   #$09          ; Store the error code
  13843.     sta   errcod          ;         ...
  13844.     ldx   kerosp          ; Get the old stack pointer
  13845.     txs          ;     and restore it
  13846.     jmp   kermit          ; Go back to top of loop
  13847.  
  13848. filenf    ldy    #0        ;[86] lets fix the file name
  13849. altfix    lda    fcb1,y        ;[86] with legal characters
  13850.     and    #$7f        ;[86] drop high bits for prodos
  13851.     cmp    #'.        ;[86] one sp ch, the period
  13852.     beq    altok        ;[86] its ok
  13853.     cmp    #'0        ;[86] now for numbers
  13854.     blt    alterr        ;[86] malo fix this one
  13855.     cmp    #'9+1        ;[86]
  13856.     blt    altok        ;[86] its a number
  13857. ;[87]    and    #$df        ;[86] now upper case all the rest must
  13858.     cmp    #'A        ;[86] be alpha
  13859.     blt    alterr        ;[86] malo
  13860.     cmp    #'Z+1        ;[86]
  13861.     blt    altok        ;[86] its alpha
  13862.     cmp    #'a        ;[87] be alpha
  13863.     blt    alterr        ;[87] malo
  13864.     cmp    #'z+1        ;[87]
  13865.     blt    altok        ;[87] its alpha
  13866. ;[87]alterr    lda    #'.        ;[86] replace illegal ch
  13867. alterr    lda    #'X        ;[87] replace illegal ch
  13868. ;[87]altok    sta    fcb1,y        ;[86] now replace this ch in case it changed
  13869.     sta    fcb1,y        ;[87] now replace this ch
  13870. altok                ;[87] keep lower case
  13871.     iny            ;[86] now
  13872.     cpy    nfcb1        ;[86] check the end
  13873.     bne    altfix        ;[86] theres more
  13874.     rts            ;[86]
  13875. ;
  13876. ;     Altstv - stores the version number passed to it into the filename
  13877. ;     buffer at whatever position dosfni is pointing to.
  13878. ;
  13879.  
  13880. altstv: ldy   dosfni          ; Get the filename index
  13881.     pha          ; Save the value
  13882.     lsr   a          ; Shift out the low order nibble
  13883.     lsr   a          ;         ...
  13884.     lsr   a          ;         ...
  13885.     lsr   a          ;         ...
  13886.     jsr   altstf          ; Stuff the character
  13887.     pla          ; Grab back the original value
  13888.     and   #$0f          ; Take the low order nibble
  13889.     iny          ; Increment the filename index
  13890.     jsr   altstf          ; Stuff the next character
  13891.     rts          ;     and return
  13892.  
  13893. altstf: ora   #$b0          ; Make the character printable
  13894.     cmp   #$ba          ; If it is less than '9'
  13895.     bcc   altdep          ;     then go depisit the character
  13896.     adc   #$06          ; Put the character in the proper range
  13897. altdep: sta   fcb1,y          ; Stuff the character
  13898.     rts          ;     and return
  13899.  
  13900. ;
  13901. ;     Closef - closes the file which was open for transfer. If it was
  13902. ;     an output file, it will go write the last buffer if neccessary.
  13903. ;
  13904.  
  13905. closef
  13906.     ldx    dosflg        ;[59] is this prodos?
  13907.     beq    closep        ;[59] no
  13908.     tax            ;[59] were there errors?
  13909.     bne    close3        ;[59] yes
  13910.     jsr    clowlb        ;[59] empty out the buffer
  13911.     jsr    prodos        ;[59] set eof
  13912.     .byte    getmk        ;[59]
  13913.     .word    pmark        ;[59] par list
  13914.     bcc    .+5        ;[59] any good?
  13915.     jsr    perror        ;[59] no sigh
  13916.     jsr    prodos        ;[59] now ste eof
  13917.     .byte    seteof        ;[59] with the mark
  13918.     .word    pmark        ;[59] par list
  13919.     bcc    .+5        ;[59] error?
  13920.     jsr    perror        ;[59] yes sigh
  13921. close3    jsr    prodos        ;[59] finally close it
  13922.     .byte    clofl        ;[59]
  13923.     .word    pclose        ;[59]
  13924.     bcc    .+5        ;[59]
  13925.     jsr    perror        ;[59]
  13926.     lda    #true        ;[59] give a good return
  13927.     rts            ;[59]
  13928. closep                ;[59]
  13929. ;[84]    jsr   movdds          ;[40] Go move in default slot and drive
  13930.     cmp   #$00          ; If there were errors
  13931.     bne   clonlb          ;     don't write the last buffer
  13932.     jsr   clowlb          ; Otherwise, write last buffer if non-empty
  13933. ;[84]clonlb: ldy   #$00          ; Clear index
  13934. ;[84]clomfn: lda   fcb1,y          ; Move the filename to the primary filename
  13935. ;[84]    ora   #$80          ;[19]     buffer in negative ascii format
  13936. ;[84]    cmp   #$80          ;[19] Was the character null?
  13937. ;[84]    bne   cloms          ;[19] If it wasn't, move it in.
  13938. ;[84]    lda   #hspace          ;[19] Otherwise, replace it with a space
  13939. ;[84]cloms:    sta   primfn,y      ;[19]     format
  13940. ;[84]    iny          ; Increment the buffer index once
  13941. ;[84]    cpy   #mxfnl+1      ; Done?
  13942. ;[84]    bpl   clofil          ; If so, go close the file
  13943. ;[84]    jmp   clomfn          ; Continue to move the filename in
  13944. ;[84]clofil: lda   filmod          ; Fetch the file type
  13945. ;[84]    jsr   dosclo          ; Close it
  13946. clonlb    lda    #fncclo        ;[84]
  13947.     sta    doscmi        ;[84] non 0
  13948.     jsr    initfm        ;[84] now init fm and close
  13949.     lda   #true          ; If we return to here, the close worked
  13950.     rts
  13951.  
  13952. clowlb: lda   dsbind          ; Get the index
  13953.     beq   clowlr          ; Nothing in buffer, just return
  13954.     lda    dosflg        ;[59] is this prodos
  13955.     beq    clowl1        ;[59] no
  13956.     lda    dsbind        ;[59] number of bytes in buffer
  13957.     sta    prdwr+4        ;[59] only lsb since size<256
  13958.     jsr    prodos        ;[59] write out the last
  13959.     .byte    wrfil        ;[59]
  13960.     .word    prdwr        ;[59]
  13961.     bcc    .+5        ;[59]
  13962.     jsr    perror        ;[59]
  13963.     rts            ;[59]
  13964. clowl1                ;[59]
  13965.     lda   #fncwrt          ; Get the 'write' function code
  13966.     sta   opcod          ;     and stuff it in the file manager parms
  13967.     lda   #$00          ; Make the range length
  13968.     sta   rnglnh          ;     look like the buffer length less one
  13969. ;[84]    dec   dsbind          ;         ...
  13970. ;[84]    lda   dsbind          ;         ...
  13971. ;[84]    sta   rnglnl          ;         ...
  13972.     ldx    dsbind        ;[84]
  13973.     dex            ;[84]
  13974.     stx    rnglnl        ;[84]
  13975.     lda   #sfntrn          ; Subfunction is 'transfer range' of bytes
  13976.     sta   subcod          ;         ...
  13977.     lda   #dosbuf\      ;[3] Load the address of the DOS buffer
  13978.     sta   fnadrl          ;[3]     into the appropriate location in the
  13979. ;[84]    lda   #dosbuf^      ;[3]     file manager parameter list.
  13980. ;[84]    sta   fnadrh          ;[3]         ...
  13981. ;[84]    jsr   dosfmn          ; Call the file manager
  13982.     ldx   #dosbuf^          ;[84]     file manager parameter list.
  13983.     stx   fnadrh          ;[84] x must be non 0     ...
  13984.     jsr   dosfmg          ;[84] Call the file manager
  13985.     bcc    clowlr        ;[84] no error
  13986. ;[85]    lda   fmrcod          ;[84] Get the return code
  13987. ;[84]    cmp   #dsener          ; No errors?
  13988. ;[84]    beq   clowlr          ; No errors, return
  13989. ;[85]    ora   #$80          ; Set H.O. bit since it is a DOS error
  13990. ;[85]    sta   errcod          ; Store that
  13991.     jmp    nonftl        ;[85]
  13992. clowlr: rts          ; Return
  13993.  
  13994.     
  13995. ;
  13996. ;     Bufill - takes characters from the file, does any neccesary quoting,
  13997. ;     and then puts them in the packet data buffer. It returns the size
  13998. ;     of the data in the AC. If the size is zero and it hit end-of-file,
  13999. ;     it turns on eofinp.
  14000. ;
  14001.  
  14002. bufill: lda   #$00          ; Zero
  14003.     sta    lgfcol        ;[87] needed for fgetc get filename
  14004.     sta   datind          ;     the buffer index
  14005. bufil1: jsr   fgetc          ; Get a character from the file
  14006.           jmp     bffchk          ; Go check for actual end-of-file
  14007.     sta   kerchr          ; Got a character, save it
  14008.     lda    dosflg        ;[59] prodos?
  14009.     bne    bufceb        ;[59] yes, we have a good byte
  14010.     lda   filmod          ;[6] Get the file-type
  14011.     beq   bufcet          ;[6] Text file, go check for end of text
  14012. ;[87]    sec          ;[6] Set the carry for subtraction
  14013. ;[87]    lda   fillen          ;[6] Get the remaining file length
  14014. ;[87]    sbc   #$01          ;[6] Decrement it once
  14015. ;[87]    sta   fillen          ;[6] Put it back
  14016. ;[87]    lda   fillen+1      ;[6] Do the High order byte
  14017. ;[87]    sbc   #$00          ;[6]         ...
  14018. ;[87]    sta   fillen+1      ;[6]         ...
  14019. ;[87]    cmp   #$ff          ;[6] Did this just go below zero?
  14020. ;[59]    beq   bufcfl          ;[6] If so, check the low order byte
  14021. ;[59]    jmp   bufceb          ;[6] Otherwise, continue filling buffer
  14022. ;[87]    bne    bufceb        ;[59] no
  14023. ;[87]bufcfl: lda   fillen          ;[6] Get the low order byte of the file length
  14024. ;[87]    cmp   #$ff          ;[6] If this is also -1 we are at eof
  14025. ;[87]    bne   bufceb          ;[6] No, continue processing
  14026.     dec    fillen        ;[87] see if were thru
  14027.     lda    #$ff        ;[87] did we carry on lsb
  14028.     cmp    fillen        ;[87]
  14029.     bne    bufceb        ;[87] not thru so carry on
  14030.     dec    fillen+1    ;[87] how about msb
  14031.     cmp    fillen+1    ;[87]
  14032.     bne    bufceb        ;[87] not thru so carry on
  14033.     ldx   dsbend          ;[6] Make sure fgetc fails next time through
  14034.     stx   dsbind          ;[6]     and shows eof.
  14035.     lda   #on          ;[6] Set the end-of-data flag on
  14036.     sta   eodind          ;[6]         ...
  14037.     jmp   bffret          ;[6] Go return with the length of the buffer
  14038. bufcet: lda   kerchr          ;[6] Get the character
  14039.     and   #$7f          ;[6] Make sure we are only working with 7-bits
  14040.     bne   bufceb          ;[6] If it's not null, there's still more text
  14041.     ldx   dsbend          ;[6] Otherwise, make sure fgetc fails and
  14042.     stx   dsbind          ;[6]     returns eof next time
  14043.     jmp   bffchk          ;[6] Go return with the buffer length
  14044. ;[81]bufceb: lda   ebqmod          ; Check if 8-bit quoting is on
  14045. bufceb:    jsr    ctrlck        ;[81] controlify if necessary
  14046. ;[59]    cmp   #on          ;         ...
  14047. ;[59]    beq   bufil2          ; If it is, see if we have to use it
  14048. ;[59]    jmp   bffqc          ; Otherwise, check normal quoting only
  14049. ;[81]    beq    bffqc        ;[59] check normal quoting only
  14050. ;[81]bufil2: lda   kerchr          ; Get the character
  14051. ;[72]    and   #$80          ; Mask everything off but H.O. bit
  14052. ;[72]    beq   bffqc          ; H.O. bit was not on, so continue
  14053. ;[81]    bpl    bffqc        ;[72]
  14054. ;[81]    lda   sebq          ; H.O. bit was on, get 8-bit quote
  14055. ;[81]    ldy   datind          ; Set up the data index
  14056. ;[81]    sta   (kerbf1),y      ; Stuff the quote character in buffer
  14057. ;[81]    iny          ; Up the data index
  14058. ;[81]    sty   datind          ; And save it
  14059. ;[81]    lda   kerchr          ; Get the original character saved
  14060. ;[81]    and   #$7f          ; Shut H.O. bit, we don't need it
  14061. ;[81]    sta   kerchr          ;         ...
  14062. ;[81]bffqc:    lda   kerchr          ; Fetch the character
  14063. ;[81]    and   #$7f          ;[2] When checking for quoting, use only 7 bits
  14064. ;     bpl     bffqc0          ;[2] If >0, check against space w/o H.O. bit on
  14065. ;     cmp     #hspace          ;[2] Greater than space (H.O. bit on)
  14066. ;     bpl     bffqc1          ;[2] If so, no quoting needed
  14067. ;     jmp     bffctl          ;[2] Check next possibility
  14068. ;[81]bffqc0: cmp   #sp          ; Is the character less than a space?
  14069. ;[81]    bpl   bffqc1          ; If not, try next possibility
  14070. ;[81]    ldx   filmod          ;[8] Get the file-type
  14071. ;[81]    bne   bffctl          ;[8] If it is not text, ignore <cr> problem
  14072. ;[81]    cmp   #cr          ;[8] Do we have a <cr> here?
  14073. ;[81]    bne   bffctl          ;[8] Nope, continue processing
  14074. ;[81]    ldx   #on          ;[8] Set flag to add a <lf> next time through
  14075. ;[81]    stx   addlf          ;[8]         ...
  14076. ;[81]    jmp   bffctl          ; This has to be controlified
  14077. ;[81]bffqc1: cmp   #del          ; Is the character a del?
  14078. ;[81]    bne   bffqc2          ; If not, try something else
  14079. ;[81]    jmp   bffctl          ; Controlify it
  14080. ;[81]bffqc2: cmp   squote          ; Is it the quote character?
  14081. ;[81]    bne   bffqc3          ; If not, continue trying
  14082. ;[81]    jmp   bffstq          ; It was, go stuff a quote in buffer
  14083. ;[81]bffqc3: lda   ebqmod          ;[11] Is 8-bit quoting turned on?
  14084. ;[72]    cmp   #on          ;[11]         ...
  14085. ;[72]    bne   bffstf          ;[11] If not, skip this junk
  14086. ;[81]    beq    bffstf        ;[72]
  14087. ;[81]    lda   kerchr          ;[11]     otherwise, check for 8-bit quote char.
  14088. ;[81]    cmp   sebq          ; Is it an 8-bit quote?
  14089. ;[81]    bne   bffstf          ; Nope, just stuff the character itself
  14090. ;[81]    jmp   bffstq          ; Go stuff a quote in the buffer
  14091. ;[81]bffctl: lda   kerchr          ;[2] Get original character back
  14092. ;[81]    eor   #$40          ; Ctl(AC)
  14093. ;[81]    sta   kerchr          ; Save the character again
  14094. ;[81]bffstq: lda   squote          ; Get the quote character
  14095. ;[81]    ldy   datind          ;     and the index into the buffer
  14096. ;[81]    sta   (kerbf1),y      ; Store it in the next location
  14097. ;[81]    iny          ; Up the data index once
  14098. ;[81]    sty   datind          ; Save the index again
  14099. ;[81]bffstf: inc   schr          ; Increment the data character count
  14100. ;[81]    bne   bffsdc          ;         ...
  14101. ;[81]    inc   schr+1          ;         ...
  14102. ;[81]bffsdc: lda   kerchr          ; Get the saved character
  14103. ;[81]    ldy   datind          ;     and the data index
  14104. ;[81]    sta   (kerbf1),y      ; This is the actual char we must store
  14105. ;[81]    iny          ; Increment the index
  14106. ;[81]    sty   datind          ; And resave it
  14107. ;[81]    tya          ; Take this index, put it in AC
  14108. ;[81]    clc          ; Clear carry for addition
  14109. ;[81]    adc   #$06          ; Adjust it so we can see if it
  14110. ;[81]    cmp   spsiz          ;     is >= spsiz-6
  14111. ;[75]    bpl   bffret          ; If it is, go return
  14112.     bcs   bffret          ;[75] If it is, go return
  14113.     jmp   bufil1          ; Otherwise, go get more characters
  14114. bffret: lda   datind          ; Get the index, that will be the size
  14115.     rts          ; Return with the buffer size in AC
  14116.  
  14117. ;
  14118. ;    controlify ch if necessary
  14119. ;
  14120. ;    destroys a,y
  14121. ;
  14122.  
  14123. ctrlch    sta    kerchr        ;[81] alternate entry
  14124.     lda    #true        ;[81] this is for text only
  14125.     bne    ctrlci        ;[81]
  14126. ctrlck:    lda    #false        ;[81] check file type
  14127. ctrlci    sta    kwrk02        ;[81]
  14128.     lda    prtcl        ;[83] xmodem
  14129.     beq    ctrlcj        ;[83] no
  14130.     lda    kerchr        ;[83]
  14131.     jmp    ctrqc4        ;[83] yes
  14132. ctrlcj                ;[83]
  14133.     lda   ebqmod          ;[81] Check if 8-bit quoting is on
  14134.     beq    ctrqc        ;[81] check normal quoting only
  14135.     lda   kerchr          ;[81] Get the character
  14136.     bpl    ctrqcb        ;[81]
  14137.     lda   sebq          ;[81] H.O. bit was on, get 8-bit quote
  14138.     ldy   datind          ;[81] Set up the data index
  14139.     sta   (kerbf1),y      ;[81] Stuff the quote character in buffer
  14140.     iny          ;[81] Up the data index
  14141.     sty   datind          ;[81] And save it
  14142.     lda   kerchr          ;[81] Get the original character saved
  14143.     and   #$7f          ;[81] Shut H.O. bit, we don't need it
  14144.     sta   kerchr          ;[81]         ...
  14145. ctrqc:    lda   kerchr          ;[81] Fetch the character
  14146. ctrqcb    and   #$7f          ;[81] When checking for quoting, use only 7 bits
  14147. ctrqc0: cmp   #sp          ;[81] Is the character less than a space?
  14148.     bpl   ctrqc1          ;[81] If not, try next possibility
  14149.     ldy    kwrk02        ;[81]
  14150.     bne    ctrqca        ;[81] is this text only, yes
  14151. ctrqc4                ;[83]
  14152.     ldy   filmod          ;[81] Get the file-type
  14153.     bne   ctrctl          ;[81] If it is not text, ignore <cr> problem
  14154.     ldy    xcrlf+1        ;[84] check for send xlate cr<->cr,lf
  14155.     beq    ctrctl        ;[84] its off
  14156. ctrqca    cmp   #cr          ;[81] Do we have a <cr> here?
  14157.     bne   ctrctl          ;[81] Nope, continue processing
  14158.     sta   addlf          ;[81]         ...
  14159.     beq   ctrctl          ;[81] This has to be controlified
  14160. ;[83]ctrqc1: cmp   #del          ;[81] Is the character a del?
  14161. ctrqc1:             ;[83]
  14162. ;[84]    ldy    prtcl        ;[83] xmodem?
  14163. ;[84]    bne    ctrstf        ;[83] yes
  14164.     cmp   #del          ;[81] Is the character a del?
  14165. ;[83]    bne   ctrqc2          ;[81] If not, try something else
  14166. ;[83]    jmp   ctrctl          ;[81] Controlify it
  14167.     beq   ctrctl          ;[83][81] Controlify it
  14168. ctrqc2: cmp   squote          ;[81] Is it the quote character?
  14169.     bne   ctrqc3          ;[81] If not, continue trying
  14170.     jmp   ctrstq          ;[81] It was, go stuff a quote in buffer
  14171. ctrqc3: lda   ebqmod          ;[81] Is 8-bit quoting turned on?
  14172.     beq    ctrstf        ;[81]
  14173.     lda   kerchr          ;[81]     otherwise, check for 8-bit quote char.
  14174.     cmp   sebq          ;[81] Is it an 8-bit quote?
  14175.     bne   ctrstf          ;[81] Nope, just stuff the character itself
  14176. ;[87]    jmp   ctrstq          ;[81] Go stuff a quote in the buffer
  14177.     beq   ctrstq          ;[87] Go stuff a quote in the buffer
  14178. ;[83]ctrctl: lda   kerchr          ;[81] Get original character back
  14179. ctrctl:             ;[83]
  14180.     lda    prtcl        ;[83] xmodem?
  14181.     bne    ctrstf        ;[83] yes
  14182.     lda   kerchr          ;[83] Get original character back
  14183.     eor   #$40          ;[81] Ctl(AC)
  14184.     sta   kerchr          ;[81] Save the character again
  14185. ctrstq: lda   squote          ;[81] Get the quote character
  14186.     ldy   datind          ;[81]     and the index into the buffer
  14187.     sta   (kerbf1),y      ;[81] Store it in the next location
  14188.     iny          ;[81] Up the data index once
  14189.     sty   datind          ;[81] Save the index again
  14190. ctrstf: inc   schr          ;[81] Increment the data character count
  14191.     bne   ctrsdc          ;[81]         ...
  14192.     inc   schr+1          ;[81]         ...
  14193.     bne    ctrsdc        ;[84] larger size
  14194.     inc    schr+2        ;[84]
  14195. ctrsdc: lda   kerchr          ;[81] Get the saved character
  14196.     ldy   datind          ;[81]     and the data index
  14197.     sta   (kerbf1),y      ;[81] This is the actual char we must store
  14198.     iny          ;[81] Increment the index
  14199.     sty   datind          ;[81] And resave it
  14200.     tya          ;[81] Take this index, put it in AC
  14201.     ldy    prtcl        ;[83] xmmodem?
  14202.     beq    ctrsd3        ;[83] no
  14203.     cmp    #sfxmd        ;[83] all the data?
  14204.     rts            ;[83]
  14205. ctrsd3                ;[83]
  14206.     clc          ;[81] Clear carry for addition
  14207.     adc   #$06          ;[81] Adjust it so we can see if it
  14208.     cmp   spsiz          ;[81]     is >= spsiz-6
  14209.     rts        ;[81]
  14210.  
  14211. bffchk:
  14212.     lda    dosflg        ;[59] prodos?
  14213.     beq    bufil4        ;[59] no
  14214.     lda    eofinp        ;[59] eof?
  14215.     beq    bufil4        ;[59] no
  14216.     sta    eodind        ;[59] yes, set end of data
  14217.     lda    #0        ;[59] and reset eof
  14218.     sta    eofinp        ;[59] so fgetc likes it
  14219. bufil4                ;[59]
  14220.     lda   datind          ; Get the data index
  14221. ;    cmp   #$00          ; Is it zero?
  14222.     bne   bffne          ; Nope, just return
  14223.     ldy    #true        ;[59] yes we have eof
  14224.     sty    eofinp        ;[59]
  14225. ;[59]    tay          ; Yes, this means the entire file has
  14226. ;[59]    lda   #true          ;     been transmitted so turn on
  14227. ;[59]    sta   eofinp          ;     the eofinp flag
  14228. ;[59]    tya          ; Get back the size of zero
  14229. bffne:    rts          ; Return
  14230.  
  14231. ;
  14232. ;     Bufemp - takes a full data buffer, handles all quoting transforms
  14233. ;     and writes the reconstructed data out to the file using calls to
  14234. ;     FPUTC.
  14235. ;
  14236. abufmt    ldy    #true        ;[81]
  14237.     bne    bfet7        ;[81] say this is a text process
  14238. ;[81]bufemp: lda   #$00          ; Zero
  14239. bufemp: ldy    #false        ;[81]
  14240. bfet7    sty    putcut        ;[81] the flag
  14241.     lda   #$00          ; Zero
  14242.     sta   datind          ;     the data index
  14243. bfetol: lda   datind          ; Get the data index
  14244.     cmp   pdlen          ; Is it >= the packet data length?
  14245. ;[75]    bmi   bfemor          ; No, there is more to come
  14246.     bcc   bfemor          ;[75] No, there is more to come
  14247.     rts          ; Yes, we emptied the buffer, return
  14248. bfemor: lda   #false          ; Reset the H.O.-bit-on flag to false
  14249.     sta   chebo          ;         ...
  14250.     ldy   datind          ; Get the current buffer index
  14251.     lda   (kerbf1),y      ; Fetch the character in that position
  14252.     sta   kerchr          ; Save it for the moment
  14253.     ldy    prtcl        ;[83] xmodem
  14254.     bne    bfeout        ;[83] yes
  14255.     cmp   rebq          ; Is it the 8-bit quote?
  14256.     bne   bfeqc          ; No, go check for normal quoting
  14257.     lda   ebqmod          ; Is 8-bit quoting on?
  14258. ;[72]    cmp   #on          ;         ...
  14259. ;[72]    bne   bfeout          ; No quoting at all, place char in file
  14260. ;[72]    lda   #true          ; Set H.O.-bit-on flag to true
  14261.     beq    bfeout        ;[72] quoting? no
  14262.     sta   chebo          ;         ...
  14263.     inc   datind          ; Increment the data index
  14264.     ldy   datind          ; Fetch it into Y
  14265.     lda   (kerbf1),y      ; Get the next character from buffer
  14266.     sta   kerchr          ; Save it
  14267. bfeqc:    cmp   rquote          ; Is it the normal quote character
  14268.     bne   bfeceb          ; No, pass this stuff up
  14269.     inc   datind          ; Increment the data index
  14270.     ldy   datind          ;     and fetch it in the Y-reg
  14271.     lda   (kerbf1),y      ; Get the next character from buffer
  14272.     sta   kerchr          ; Save it
  14273.     and   #$7f          ;[2] Check only 7 bits for quote
  14274.     cmp   rquote          ; Were we quoting a quote?
  14275.     beq   bfeceb          ; Yes, nothing has to be done
  14276.     cmp   rebq          ;[2] Check for eight-bit quote char as well
  14277.     beq   bfeceb          ;[2] Skip the character adjustment
  14278.     lda   kerchr          ;[2] Fetch back the original character
  14279.     eor   #$40          ; No, so controlify this again
  14280.     sta   kerchr          ; Resave it
  14281. bfeceb: lda   chebo          ; Is the H.O.-bit-on flag lit?
  14282. ;[59]    cmp   #true          ;         ...
  14283. ;[59]    bne   bfeout          ; Just output the character to the file
  14284.     beq    bfeout        ;[59]
  14285.     lda   kerchr          ; Fetch the character
  14286.     ora   #$80          ; Light up the H.O. bit
  14287.     sta   kerchr          ; Resave it
  14288. ;[81]bfeout: lda   filmod          ;[8] Check if this is a text file
  14289. bfeout: lda    putcut        ;[81] is this a text process?
  14290.     bne    bfeou7        ;[81] yes
  14291. ;    lda    ascii        ;[82]
  14292. ;    bne    bfeou7        ;[82] is this 7bit text, yes
  14293.     lda   filmod          ;[8] Check if this is a text file
  14294.     bne   bfefpc          ;[8] If not, continue normal processing
  14295.     lda    dosflg        ;[82]
  14296.     beq    bfeou7        ;[82] 
  14297.     lda    kerchr        ;[82] prodos text uses 8 bits
  14298.     jmp    bfeou9        ;[82]
  14299. bfeou7                ;[81]
  14300.     lda   kerchr          ;[8] Get a copy of the character
  14301.     and   #$7f          ;[8] Make sure we test L.O. 7-bits only
  14302. bfeou9                ;[82]
  14303.     ldx    xcrlf        ;[84] should we xlate cr<->cr,lf
  14304.     beq    bfefpc        ;[84] no, its off
  14305.     cmp   #cr          ;[8] Do we have a <cr>?
  14306.     bne   bfeclf          ;[8] No, then check for <lf>
  14307. ;[81]    lda   #on          ;[8] Yes, set the 'Delete <lf>' flag
  14308.     sta   dellf          ;[8]         ...
  14309. ;[81]    jmp   bfefpc          ;[8] And then continue
  14310.     beq   bfefpc          ;[81] And then continue
  14311. bfeclf: cmp   #lf          ;[8] Do we have a <lf>?
  14312.     bne   bfenlf          ;[8] Nope, We must go shut the Dellf flag.
  14313.     lda   dellf          ;[8] We have a <lf>, is the flag on?
  14314. ;[81]    cmp   #on          ;[8]         ...
  14315. ;[81]    bne   bfefpc          ;[8] If not, continue normally
  14316.     beq   bfefpc          ;[81] If not, continue normally
  14317.     lda   #off          ;[8] Flag is on, <lf> follows <cr>, ignore it
  14318.     sta   dellf          ;[8] Start by zeroing flag
  14319. ;[81]    jmp   bfeou1          ;[8] Now go to end of loop
  14320.     beq   bfeou1          ;[81] Now go to end of loop
  14321. bfenlf: lda   #off          ;[8] Zero Dellf
  14322.     sta   dellf          ;[8]         ...
  14323. bfefpc: lda   kerchr          ;[8] Get the character once more
  14324.     ldy    putcut        ;[81] is this a text process?
  14325.     beq    bfefp7        ;[81] no
  14326.     ora    #$80        ;[81] neg ascii
  14327.     jsr    cout        ;[81]
  14328. ;    jsr    keyprs        ;[85] allow them to hold screen
  14329.     jmp    bfeou1        ;[81] next
  14330. bfefp7                ;[81]
  14331.     jsr   fputc          ; Go write it to the file
  14332.           jmp     bfeerr          ; Check out the error
  14333.     inc   rchr          ; Increment the 'data characters receive' count
  14334.     bne   bfeou1          ;         ...
  14335.     inc   rchr+1          ;         ...
  14336.     bne    bfeou1        ;[84] larger size
  14337.     inc    rchr+2        ;[84]
  14338. bfeou1: inc   datind          ; Up the buffer index once
  14339.     jmp   bfetol          ; Return to the top of the loop
  14340.  
  14341. bfeerr: sta   errcod          ; Store the erro code where it belongs
  14342.     and   #$7f          ; Shut off H.O. bit
  14343.     tay          ; Save the error code here
  14344.     lda   #kerdel          ; Get the disk error message length
  14345.     pha          ; Push that parameter
  14346.     dey          ; Decrement the error code twice to make
  14347.     dey          ;     it correct for the disk error table
  14348.     tya          ; Fetch it back
  14349.     pha          ; Push that as an argument to genmad
  14350.     lda   #dskers\      ; Get L.O. byte of base address
  14351.     sta   kermbs          ;     and stuff it where it is expected
  14352.     lda   #dskers^      ; Do the same for the H.O. byte address
  14353.     sta   kermbs+1      ;         ...
  14354.     jsr   genmad          ; Genereate the message address
  14355.     jsr   prstr          ; Go print that error message
  14356.     lda   #false          ; Indicate failure
  14357. getnf7                ;[81]
  14358.     rts          ;     and return
  14359.  
  14360. ;
  14361. ;     Getnfl - returns the next filename to be transferred. Currently
  14362. ;     it always return true/false to indicate there are no other files to
  14363. ;     process.
  14364. ;
  14365.  
  14366. ;[81]getnfl: lda   #eof          ; No more files (return eof)
  14367. getnfl: lda    wcpres        ;[81] is this wildcd search?
  14368.     beq    getnf7        ;[81] no quit
  14369.     lda    #0        ;[81] start from 0
  14370.     sta    gfcol        ;[81] collumn 
  14371.     sta    lgfcol        ;[81] last non blank col in filename
  14372.     sta    match        ;[81] assume no wildcd
  14373.     sta    catlin        ;[81] current line in the catalog
  14374.     sta    stix        ;[81] init stack pointer
  14375.     sta    kersft        ;[81] init real dos 3.3 flag
  14376.     ldx    #gfcout\    ;[81] and give our cout routine
  14377.     ldy    #gfcout^    ;[81]
  14378.     jsr    svcout        ;[81]
  14379.     lda    catext        ;[81] interupt the catalog return
  14380.     pha            ;[81]
  14381.     lda    #$60        ;[81] and make it rtn from jsr
  14382.     sta    catext        ;[81]
  14383.     lda    dosflg        ;[81]
  14384.     bne    getnf3        ;[81] if dos 3.3 
  14385.     lda    dosrdk        ;[81] got to disable
  14386.     cmp    #$20        ;[81] test for jsr
  14387.     beq    getnf2        ;[81] is this 3.3?, yes
  14388.     inc    kersft        ;[81] its not vanila
  14389.     ldx    #erms1m\    ;[81] now tatle
  14390.     ldy    #erms1m^    ;[81]
  14391.     jsr    prstr        ;[81]
  14392.     jsr    prcrlf        ;[81]
  14393.     jmp    getnf3        ;[81] ought to be interesting
  14394. getnf2                ;[81]
  14395.     pha            ;[81] the pause
  14396.     lda    dosrdk+1    ;[81] in catalog
  14397.     pha            ;[81]
  14398.     lda    dosrdk+2    ;[81]
  14399.     pha            ;[81]
  14400.     lda    #$ea        ;[81] this is
  14401.     sta     dosrdk        ;[81] a nop
  14402.     sta    dosrdk+1    ;[81]
  14403.     sta    dosrdk+2    ;[81]
  14404. getnf3                ;[81]
  14405.     lda    #fcb1\        ;[81] setup name for wildcd
  14406.     sta    name        ;[81]
  14407.     lda    #fcb1^        ;[81]
  14408.     sta    name+1        ;[81]
  14409.     lda    #patbuf\    ;[81] setup patern for wildcd
  14410.     sta    pat        ;[81]
  14411.     lda    #patbuf^    ;[81]
  14412.     sta    pat+1        ;[81]
  14413.     jsr    catlog        ;[81] this should activate our cout proc
  14414.     lda    dosflg        ;[81] restore dos read key call?
  14415.     bne    getnf5        ;[81] no
  14416.     lda    kersft        ;[81] really?
  14417.     bne    getnf5        ;[81] no
  14418.     pla            ;[81] restore the wait for keypress
  14419.     sta    dosrdk+2    ;[81]
  14420.     pla            ;[81]
  14421.     sta    dosrdk+1    ;[81]
  14422.     pla            ;[81]
  14423.     sta    dosrdk        ;[81]
  14424. getnf5                ;[81]
  14425.     pla            ;[81] first restore all
  14426.     sta    catext        ;[81] the exits
  14427.     jsr    rscout        ;[81]
  14428.     lda    nfcb1        ;[81]  is this the end of catalog
  14429.     beq    getnf8        ;[81] yes, same as no match
  14430.     lda    match        ;[81] now did we get a match?
  14431. getnf8                ;[81]
  14432.     rts
  14433.  
  14434. svcout    pla            ;[81] get around the return
  14435.     sta    svcour+1    ;[81] and save on the stack
  14436.     pla            ;[81]
  14437.     sta    svcour+2    ;[81]
  14438.     lda    cswl        ;[81] 
  14439.     pha            ;[81] save the current cout entry
  14440.     lda    cswh        ;[81]
  14441.     pha            ;[81]
  14442.     stx    cswl        ;[81]
  14443.     sty    cswh        ;[81]
  14444.     inc    svcour+1    ;[81] now fix up the return
  14445.     bne    svcour        ;[81]
  14446.     inc    svcour+2    ;[81]
  14447. svcour    jmp    $ffff        ;[81]
  14448. rscout    pla            ;[81]
  14449.     sta    rscour+1    ;[81]
  14450.     pla            ;[81] get around the return
  14451.     sta    rscour+2    ;[81]
  14452.     pla            ;[81]
  14453.     sta    cswh        ;[81] restor cout address
  14454.     pla            ;[81]
  14455.     sta    cswl        ;[81]
  14456.     inc    rscour+1    ;[81]
  14457.     bne    rscour        ;[81]
  14458.     inc    rscour+2    ;[81]
  14459. rscour    jmp    $ffff        ;[81]
  14460.  
  14461. gfcout    pha        ;[81] save regs
  14462.     sta    kwrk01    ;[81] we will need this shortly
  14463.     lda    match    ;[81]
  14464.     bne    gfco33    ;[81] have we found one already? yes
  14465.     txa        ;[81]
  14466.     pha        ;[81]
  14467.     tya        ;[81]
  14468.     pha        ;[81] regs saved
  14469.     lda    kwrk01    ;[81] now what did we get?
  14470.     and    #$7f    ;[81] make sure its ascii
  14471.     cmp    #cr    ;[81]
  14472.     beq    gfcou7    ;[81] end of line, now process it
  14473.     inc    gfcol    ;[81] bump col number
  14474.     ldy    gfcol    ;[81]
  14475.     ldx    dosflg    ;[81] which op system
  14476.     bne    gfco10    ;[81] its prodos
  14477.     cpy    #8    ;[81] before the start of the name?
  14478.     bcs    gfcou3    ;[81] no
  14479. gfcou2    ldx    #0    ;[81] setup start of search
  14480.     stx    nfcb1    ;[81]
  14481.     beq    gfco30    ;[81] and exit
  14482. gfcou3    cpy    #38    ;[81] are we past the name?
  14483.     bcs    gfco30    ;[81] yes
  14484. gfcou5    ldy    nfcb1    ;[81]
  14485.     sta    fcb1,y    ;[81] save the filename
  14486.     sta    dosbuf,y    ;[87] need it both places
  14487. ;[87]    inc    nfcb1    ;[81] keep track of the count
  14488.     iny        ;[87]
  14489.     sty    nfcb1    ;[87]
  14490.     sty    getfln    ;[87]
  14491.     cmp    #sp    ;[81] do we have a space
  14492.     beq    gfco30    ;[81] yes, may be trailing spaces
  14493. ;[87]    iny        ;[81] save the current size
  14494.     sty    lgfcol    ;[81] in case its last non blank
  14495. gfco30    pla        ;[81] restore regs
  14496.     tay        ;[81]
  14497.     pla        ;[81]
  14498.     tax        ;[81]
  14499. gfco33    pla        ;[81]
  14500.     rts        ;[81] thats all folks
  14501. gfco10            ;[81] now for prodos
  14502.     cpy    #2    ;[81] how about the start
  14503.     bcc    gfcou2    ;[81] not yet
  14504.     cpy    #17    ;[81] past the filename?
  14505.     bcs    gfco30    ;[81] yes
  14506.     bcc    gfcou5    ;[81] handle this character
  14507. gfcou7    inc    catlin    ;[81] count lines
  14508.     lda    lgfcol    ;[81] first calculate the actual filename length
  14509.     sta    nfcb1    ;[81]
  14510.     sta    getfln    ;[87] need it hr also
  14511.     lda    #0    ;[81]
  14512.     sta    lgfcol    ;[81]
  14513.     sta    gfcol    ;[81]
  14514.     lda    filect    ;[81] are we skipping files
  14515.     cmp    catlin    ;[81]
  14516.     bcs    gfco30    ;[81] yes
  14517.     lda    nfcb1    ;[81]
  14518.     bne    gfcou8    ;[81] end of catalog?
  14519.     lda    dosflg    ;[86] maybe, wish the catalog listing was consistent
  14520.     beq    gfcou6    ;[86] maybe dos is consistant
  14521.     lda    catlin    ;[86]
  14522.     cmp    #7    ;[86] Must be coordinated with sfilec *********
  14523.     beq    gfco30    ;[86] is this blank line before catalog listing, yes
  14524. gfcou6            ;[86]
  14525.     inc    match    ;[81] just so we skip the rest
  14526.     bne    gfco30    ;[81] always branch
  14527. gfcou8    jsr    wildcd    ;[81] ought to be interesting
  14528.     beq    gfco30    ;[81] match? no
  14529.     lda    catlin    ;[81] save this line number
  14530.     sta    filect    ;[81]
  14531.     jmp    gfco30    ;[81]
  14532.  
  14533. ;***************************************************************
  14534. ;
  14535. ; PART 5: CHECKING CATALOG ENTRY FOR WILDCARD MATCH
  14536. ;
  14537. ;        This routine calls itself recursively with varying
  14538. ;        approaches to selecting the version of pattern and
  14539. ;        name to be used in the next recursion.  It saves
  14540. ;        the start addresses and lengths of the current name
  14541. ;        and pattern on a bottomless stack which starts at
  14542. ;        the end of kermit's com routine.
  14543. ;        As far as I know, this is a robust
  14544. ;        routine--literally anything matching the multiple
  14545. ;        and single tokens will generate a match decision.
  14546. ;
  14547. ;***************************************************************
  14548. ;
  14549. .SBTTL Where the action is
  14550. wildcd   lda  fnl        ;[81]Do we still have a fname?
  14551.          bne  wldc04     ;[81]
  14552.          lda  patl       ;[81]NO NAME, do we have pattern?
  14553.          beq  suceed     ;[81]OK! NAME and PATTERN ran out simultaneously
  14554.          ldy  #$00       ;[81]No name but have pattern--OK as long as only
  14555. wldc03   lda  (pat),y    ;[81] chars left in pattern are multi-wild-cards
  14556.          cmp  #wcmult     ;[81]
  14557.          bne  fail       ;[81]There's a non-multi-wild card--fail!
  14558.          iny             ;[81]Still OK -- check next pattern char
  14559.          cpy  patl       ;[81] (if any are left)
  14560.          bmi  wldc03     ;[81]
  14561.          bpl  suceed     ;[81]Only multi wild cards, we're OK
  14562. wldc04   lda  patl       ;[81]HAVE NAME, do we have pattern?
  14563.          beq  fail       ;[81]Pattern ran out before name, failure
  14564.          ldy  #$00       ;[81]HAVE NAME and PATTERN--
  14565.          lda  (pat),y    ;[81] the pattern determines next step
  14566.          cmp  #wcsing     ;[81]Is it a single-char wildcard?
  14567.          beq  wldc05     ;[81]If so, call it a match.
  14568.          cmp  #wcmult     ;[81]Is it a multiple-char wildcard?
  14569.          beq  wldc06     ;[81] If so, check that situation out.
  14570.          cmp  (name),y   ;[81]If not, PATTERN FIXED: does it match name?
  14571.          bne  fail       ;[81]MISMATCH IN FIXED PATTERN: branch has failed
  14572. wldc05   lda  #remnp     ;[81]MATCH IN FIXED PATTERN: try the remainder of
  14573.          jsr  recurs     ;[81] the pattern on the remainder of the name
  14574.          jmp  pasbak     ;[81]No more options--pass success/failure back
  14575. wldc06   lda  #remnp     ;[81]WILDCARD CHAR: try the remainder of the pattern
  14576.          jsr  recurs     ;[81] on the remainder of the name
  14577.          lda  match      ;[81]Did it work?
  14578.          beq  wldc07     ;[81]
  14579.          jmp  pasbak     ;[81]MATCH! somewhere out there it did.
  14580. wldc07   lda  #samef     ;[81]No match--try defining wild card as NO chars:
  14581.          jsr  recurs     ;[81] strip it from PATT and apply to current name
  14582.          lda  match      ;[81]Did this work?
  14583.          beq  wldc08     ;[81]
  14584.          jmp  pasbak     ;[81]MATCH! The no-char wild-card worked.
  14585. wldc08   lda  fnl        ;[81]No match--we will next try expanding the role
  14586.          cmp  #$01       ;[81] of the wildcard by using the same pattern on
  14587.          beq  pasbak     ;[81] the REST of the name, if the REST exists.
  14588.          lda  #samep     ;[81]Keep the initial wildcard
  14589.          jsr  recurs     ;[81] and attack the rest of the name.
  14590.          jmp  pasbak     ;[81]Maybe it worked, maybe not--pass results back
  14591. suceed   lda  #true      ;[81]
  14592.          bne  return     ;[81]
  14593. fail     lda  #false     ;[81]
  14594. return   sta  match      ;[81]If a final result was obtained, set it
  14595. pasbak   rts             ;[81] passing back the results
  14596. ;
  14597. .SBTTL Check whether the pattern any fixed chars left
  14598. chkpat   ldy  #$00       ;[81]We're at the end of the name.  If there are
  14599. chkpt1   lda  (pat),y    ;[81] any fixed chars left in pattern, match fails.
  14600.          cmp  #wcmult     ;[81]
  14601.          bne  chkpt2     ;[81]A non-wildcard! fail!
  14602.          iny             ;[81]Wild, get another
  14603.          cpy  patl       ;[81]
  14604.          bmi  chkpt1     ;[81]
  14605.          lda  #true      ;[81]Only wild cards, OK
  14606.          jmp  return     ;[81]
  14607. chkpt2   lda  #false     ;[81]Failed
  14608.          jmp  return     ;[81]
  14609. ;
  14610. .SBTTL Do the recursion
  14611. recurs   sta  wchpat     ;[81]Note whether full pattern or remainder of patrn
  14612. ;[85]         jsr  setrec     ;[81]Save the current values of parameters
  14613.     lda  fnl        ;[85]File name parms
  14614.     pha        ;[85]        ;
  14615.          lda  name       ;[85]
  14616.     pha        ;[85]
  14617.          lda  name+1     ;[85]
  14618.     pha        ;[85]
  14619.          lda  patl       ;[85]Pattern parms
  14620.     pha        ;[85]
  14621.          lda  pat        ;[85]
  14622.     pha        ;[85]
  14623.          lda  pat+1      ;[85]
  14624.     pha        ;[85]
  14625.          jsr  nxtprm     ;[81]Set the values to be passed in recursion
  14626.          jsr  wildcd     ;[81]Do the recursion
  14627. ;[85]         jsr  clrrec     ;[81]Recover original values
  14628.     pla        ;[85]
  14629.          sta  pat+1      ;[85]
  14630.     pla        ;[85]
  14631.          sta  pat        ;[85]
  14632.     pla        ;[85]
  14633.          sta  patl       ;[85]
  14634.     pla        ;[85]
  14635.          sta  name+1     ;[85]
  14636.     pla        ;[85]
  14637.          sta  name       ;[85]
  14638.     pla        ;[85]
  14639.          sta  fnl        ;[85]
  14640.          rts             ;[81]
  14641. ;
  14642. .SBTTL Prepare the version of name and pattern for next recurs
  14643. nxtprm   lda  wchpat     ;[81]Do we want to change either NAME or PATTERN?
  14644.          bmi  nxtpr1     ;[81]SAMEF says leave fname alone
  14645.          dec  fnl        ;[81]Otherwise, knock one off the start of the name
  14646.          inc  name       ;[81]
  14647.          bne  nxtpr1     ;[81]
  14648.          inc  name+1     ;[81]
  14649. nxtpr1   lda  wchpat     ;[81]Are we going with same or remaining pattern?
  14650.          beq  nxtpr2     ;[81]SAMEP says leave pattern alone
  14651.          dec  patl       ;[81]Otherwise, take CDR
  14652.          inc  pat        ;[81]
  14653.          bne  nxtpr2     ;[81]
  14654.          inc  pat+1      ;[81]
  14655. nxtpr2   rts             ;[81]
  14656. ;
  14657. .SBTTL Prepare for recursion--save current values
  14658. ;[85]setrec   lda  fnl        ;[81]File name parms
  14659. ;[85]         jsr  push       ;[81]
  14660. ;[85]         lda  name       ;[81]
  14661. ;[85]         jsr  push       ;[81]
  14662. ;[85]         lda  name+1     ;[81]
  14663. ;[85]         jsr  push       ;[81]
  14664. ;[85]         lda  patl       ;[81]Pattern parms
  14665. ;[85]         jsr  push       ;[81]
  14666. ;[85]         lda  pat        ;[81]
  14667. ;[85]         jsr  push       ;[81]
  14668. ;[85]         lda  pat+1      ;[81]
  14669. ;[85]         jsr  push       ;[81]
  14670. ;[85]         rts             ;[81] and return there
  14671. ;
  14672. .SBTTL Recover local values of parms after recursion
  14673. ;[85]clrrec   jsr  pull       ;[81]Pattern parms
  14674. ;[85]         sta  pat+1      ;[81]
  14675. ;[85]         jsr  pull       ;[81]
  14676. ;[85]         sta  pat        ;[81]
  14677. ;[85]         jsr  pull       ;[81]
  14678. ;[85]         sta  patl       ;[81]
  14679. ;[85]         jsr  pull       ;[81]Filename parms
  14680. ;[85]         sta  name+1     ;[81]
  14681. ;[85]         jsr  pull       ;[81]
  14682. ;[85]         sta  name       ;[81]
  14683. ;[85]         jsr  pull       ;[81]
  14684. ;[85]         sta  fnl        ;[81]
  14685. ;[85]         rts             ;[81] and return there
  14686. ;
  14687. .SBTTL Simulated stack routines
  14688. ;[85]push     ldy  stix       ;[81]
  14689. ;[85]         sta  (stack),y  ;[81]
  14690. ;[85]         inc  stix       ;[81]
  14691. ;[85]         bne  push1      ;[81]
  14692. ;[85]         inc  stack+1    ;[81]
  14693. ;[85]push1    rts             ;[81]
  14694. ;
  14695. ;[85]pull     dec  stix       ;[81]
  14696. ;[85]    ldy    stix    ;[81] we will work up towards end of memory
  14697. ;[85]    cpy    #$ff    ;[81] did we carry?
  14698. ;[85]         bne  pull1      ;[81]
  14699. ;[85]         dec  stack+1    ;[81]
  14700. ;[85]pull1            ;[81]
  14701. ;[85]         lda  (stack),y  ;[81]
  14702. ;[85]         rts             ;[81]
  14703. ;[86]sfilec    ldy    #7    ;[81]
  14704. sfilec    ldy    #6    ;[86] Must be coordinated with gfcou6 *******
  14705.     lda    dosflg    ;[81] which os
  14706.     bne    .+4    ;[81] prosos
  14707.     ldy    #4    ;[81] dos
  14708.     sty    filect    ;[81] line on catalog to start looking for file names
  14709.     rts        ;[81]
  14710. ;
  14711. ;     Getfil - gets the filename from the receive command if one was
  14712. ;     parsed. Otherwise, it returns the name in the file header packet.
  14713. ;
  14714.  
  14715. getfil: lda   usehdr          ; Get the use-header switch
  14716. ;[59]    cmp   #on          ; Is it on
  14717.     beq   getfl1          ; If not, keep what we have in the fcb
  14718.     sta    fgetgn        ;[87] tell fputc were filename
  14719.     jsr   clrfcb          ;[43] Clear fcb, else things get messed up
  14720.     ldy   #$00          ; Initialize the y reg
  14721.     sty    nfcb1        ;[87] # chs in fcb1
  14722. ;[87]getfl0: lda   (kerbf1),y      ; Get a character from the packet buffer
  14723. ;[87]    ora   #$80          ; Turn on H.O. bit
  14724. ;[87]    sta   fcb1,y          ; Stuff it in the fcb
  14725. ;[87]    iny          ; Up the index once
  14726. ;[87]    cpy   pdlen          ; Are we finished?
  14727. ;[87]    bmi   getfl0          ; Nope, go do next byte
  14728. ;[87]    sty    nfcb1        ;[59] just in case of prodos
  14729.     jsr    bufemp        ;[87]empty the buf and let fputc handle
  14730.     lda    #0        ;[87]
  14731.     sta    fgetgn        ;[87] turn off fputc
  14732. getfl1: rts
  14733.  
  14734. ;
  14735. ;     Fgetc - returns the next character from the file in the AC. It
  14736. ;     handles all of the low level disk I/O. Whenever it successfully
  14737. ;     gets a character, it skips on return. If it does not get a 
  14738. ;     character, it doesn't skip.
  14739. ;
  14740.  
  14741. ;[87]fgetc:    lda   addlf          ;[8] Get the 'add a lf' flag
  14742. fgetc:                ;[87]
  14743.     lda    fgetgn            ;[87] are we getting file name
  14744.     beq    fgetc0        ;[87] no
  14745.     ldy    lgfcol        ;[87] are we thru?
  14746.     inc    lgfcol        ;[87]
  14747.     cpy    getfln        ;[87]
  14748.     bge    getfl1        ;[87] yes
  14749.     lda    dosbuf,y    ;[87] it was put here
  14750.     jmp    rskp        ;[87] and say we got one
  14751. fgetc0                ;[87]    
  14752.     lda   addlf          ;[87] Get the 'add a lf' flag
  14753.     beq    fgetc1        ;[59] not on
  14754. ;[59]    cmp   #on          ;[8] Is it on?
  14755. ;[59]    bne   fgetc1          ;[8] No, continue with normal processing
  14756.     lda   #off          ;[8] Zero the flag first
  14757.     sta   addlf          ;[8]         ...
  14758. ;[82]    lda   #hlf          ;[8] Get a <lf>
  14759.     lda   #lf          ;[82] Get a <lf>
  14760.     jmp   fgtgn1          ;[8]     and return that as the next character
  14761. fgetc1: ldx   dsbind          ;[8] Get the file buffer index
  14762.     cpx   dsbend          ; Are we passed the last character?
  14763.     bpl   fgetc2          ;[6] Yes, go read next sector
  14764.     jmp   fgtgnc          ;[6] No, get next character
  14765. fgetc2: lda   eodind          ;[6] Check for end-of-data first
  14766.     beq    fgtc2a        ;[59] no
  14767. ;[59]    cmp   #on          ;[6] Is it on?
  14768. ;[59]    bne   fgtc2a          ;[6] No, go read next sector
  14769. fgtc20    jmp   fgteof          ;[6] It was on so there is no data to read
  14770. fgtc2a:
  14771.     lda    dosflg        ;[59] prodos?
  14772.     beq    fget22        ;[59] no
  14773.     jsr    prodos        ;[59] yes read from file
  14774.     .byte    prdfil        ;[59]
  14775.     .word    prdwr        ;[59]
  14776.     beq    fget24        ;[59] good read? yes
  14777.     cmp    #peof        ;[59] did we get an eof?
  14778.     beq    fgtc20        ;[59] yes
  14779.     jsr    perror        ;[59] que passo?
  14780. fget24    lda    pnrdwr        ;[59] get # read
  14781.     jmp    fget33        ;[59] and save some code
  14782. fget22                ;[59] do the dos thing
  14783.     lda   #fncrea          ;[6] Load the file manager opcode (read)
  14784.     sta   opcod          ;         ...
  14785.     lda   #$00          ; Make the range length one sector
  14786.     sta   rnglnh          ;         ...
  14787.     lda   #mxdb-1          ;         ...
  14788.     sta   rnglnl          ;         ...
  14789.     lda   #sfntrn          ; Subfunction is transfer 'range of bytes'
  14790.     sta   subcod          ;         ...
  14791.     lda   #dosbuf\      ; Get the dos buffer and stuff that parm into
  14792.     sta   fnadrl          ;     DOS' parm list
  14793. ;[84]    lda   #dosbuf^      ;         ...
  14794. ;[84]    sta   fnadrh          ;         ...
  14795. ;[84]    jsr   dosfmn          ; Do the read
  14796.     ldx   #dosbuf^      ;[84]         ...
  14797.     stx   fnadrh          ;[84]    x must be non 0     ...
  14798.     jsr   dosfmg          ;[84] Do the read
  14799.     lda   fmrcod          ; Get the return code
  14800. ;[84]    cmp   #dsener          ; Do we have an error?
  14801.     beq   fgtset          ; If not, go set up the pointers
  14802.     cmp   #dseeod          ; Did we hit 'End-of-data'?
  14803.     beq   fgetc3          ;[6] Yes, just handle the eof condition
  14804.     cmp    #dsewpr        ;[60]
  14805.     beq    fgetc3        ;[60] we can read a write protected diskette
  14806.     jmp   fgtcan          ;[6] No, this is a serious error, fail
  14807. fgetc3: lda   #mxdb-2          ;[6] If range length returned is 2 less than
  14808.     sec          ;     the DOS buffer size we are using
  14809.     sbc   rnglnl          ;     then there is NO data left and it
  14810.     beq   fgteof          ;     is a real EOF, go set the flag
  14811. fget33                ;[59]
  14812.     sta   dsbend          ; There is some data left to transmit
  14813.     lda   #$00          ; Zero the index
  14814.     sta   dsbind          ;         ...
  14815.     jmp   fgtgnc          ; Go return the next character
  14816. ;[59]    jmp   fgtgnc          ; Skip the normal index and end reset
  14817. fgtset: lda   #$00          ; No errors, zero
  14818.     sta   dsbind          ;     the index
  14819.     lda   #mxdb-1          ; Stuff (max_buflen - 1) into end-of-buffer ptr
  14820.     sta   dsbend          ;         ...
  14821.     lda   fetfl          ;[6] Get the 'fetch file-length' flag
  14822.     beq    fgtgnc        ;[59]
  14823. ;[59]    cmp   #on          ;[6] Is it on?
  14824. ;[59]    bne   fgtgnc          ;[6] If not, continue processing normally
  14825.     ldx   #$00          ;[6] The length should be first
  14826.     lda   filmod          ;[6]    Unless...
  14827.     cmp   #$04          ;[6]     This is a binary file
  14828.     bne   fgtst1          ;[6] If not, continue
  14829.     ldx    #2        ;[59] get len from bytes 2 & 3
  14830. ;[59]    inx          ;[6] Otherwise get length from bytes 2 and 3
  14831. ;[59]    inx          ;[6]     instead of bytes 0 and 1
  14832. fgtst1: lda   dosbuf,x      ;[6] Get the L.O. byte
  14833.     sta   fillen          ;[6] Stuff it in the file length word
  14834. ;[59]    inx          ;[6] Point at H.O. byte
  14835.     lda   dosbuf+1,x     ;[59][6] Fetch it
  14836.     sta   fillen+1      ;[6] Store that in the file length word
  14837.     ldx   #$02          ;[6] We have to adjust the length
  14838.     lda    #4        ;[59] what is the file type
  14839.     cmp    filmod        ;[59]
  14840. ;[59]    lda   filmod          ;[6]     by either 2 or 4 depending on the
  14841. ;[59]    cmp   #$04          ;[6]     file type...
  14842.     bne   fgtst2          ;[6] If it's not binary, 2 will do
  14843.     tax        ;[59] else adj by 4
  14844. ;[59]    inx          ;[6] Otherwise we have to adjust up by 4
  14845. ;[59]    inx          ;[6]
  14846. fgtst2: stx   kwrk01          ;[6] Store it here for now
  14847.     clc          ;[6] Clear carry for addition
  14848.     lda   fillen          ;[6] Fetch L.O. byte of file length
  14849.     adc   kwrk01          ;[6] Add in the adjustment
  14850.     sta   fillen          ;[6]         ...
  14851.     lda   fillen+1      ;[6] Do H.O. byte
  14852.     adc   #$00          ;[6]         ...
  14853.     sta   fillen+1      ;[6]         ...
  14854.     lda   #off          ;[6] Finally, make sure we turn off the flag
  14855.     sta   fetfl          ;[6]         ...
  14856. fgtgnc: ldx   dsbind          ; Fetch the current index
  14857.     lda   dosbuf,x      ; Get the character at that point
  14858.     inc   dsbind          ; Increment the index
  14859. fgtgn1:         
  14860. ;    ldx    ascii        ;[82] is this 7bit text
  14861. ;    bne    fgtgn2        ;[82] yes
  14862.     ldx    dosflg        ;[82]
  14863.     bne    fgtexi        ;[82] prodos text uses all 8 biits
  14864.     ldx    filmod        ;[63] is this text file?
  14865. ;[65]    beq    fgtgn2        ;[63] yes
  14866. ;[65]    ldx   fbsize          ;[8] Get the file-byte-size
  14867. ;[65]    cpx   #fbsbit          ; Is it seven-bit?
  14868.     bne   fgtexi          ; If not, leave with the character intact
  14869. ;[65]fgtgn2                ;[63]
  14870. fgtgn2                ;[82]
  14871.     and   #$7f          ; Shut off the H.O. byte
  14872.     beq    fgteof        ;[86] null is dos text file eof
  14873. fgtexi: jmp   rskp          ; Do a skip return
  14874. fgteof: lda   #true          ; Set the eof indicator on
  14875.     sta   eofinp          ;         ...
  14876.     lda   #$00          ; Return nul for a character
  14877.     rts
  14878. fgtcan: jmp   fatal          ; Just go give an error
  14879.  
  14880. ;
  14881. ;     Fputc - takes a character passed to it in the AC and writes it
  14882. ;     to the file being transferred in.
  14883. ;
  14884.  
  14885. fputc:
  14886.     ldx    fgetgn        ;[87] is this a filename?
  14887.     beq    fputc3        ;[87] no
  14888.     ldx    nfcb1        ;[87] where to put it
  14889.     sta    fcb1,x        ;[87] unchared ... filename
  14890.     inc    nfcb1        ;[87]
  14891.     jmp    rskp        ;[87]
  14892. fputc3                ;[87]    
  14893.     ldx    dosflg        ;[82]
  14894. ;    beq    fputc3        ;[82] its dos
  14895.     bne    fptstc        ;[82] its prodos
  14896. ;    ldx    ascii        ;[82] is this 7bit text
  14897. ;    beq    fptstc        ;[82] no,prodos text uses all 8 bits
  14898. ;    and    #$7f        ;[82] make sure its only 7bits
  14899. ;    jmp    fptstc        ;[82]
  14900. ;fputc3                ;[82]
  14901.     ldx    filmod        ;[63] is this text file?
  14902. ;[65]    beq    fputc1        ;[63]
  14903. ;[65]    ldx   fbsize          ; Get the file-byte-size
  14904. ;[65]    cpx   #fbsbit          ; Is it seven-bit?
  14905.     bne   fptstc          ; If not, just go store the character
  14906. ;[65]fputc1                ;[63]
  14907.     ora   #$80          ; This should be negative ascii
  14908. fptstc: ldx   dsbind          ; Fetch the buffer index
  14909.     sta   dosbuf,x      ; Stuff the character in the buffer
  14910.     inx   ;[59]dsbind          ; Up the index once
  14911.     stx   dsbind          ;[59] Get the current index
  14912.     cpx   #mxdb    ;[59]If that is equal to the DOS buffer length...
  14913.     beq   fptwrt          ; We just filled last position, write buffer
  14914.     lda   #$00          ; Clear AC, no error
  14915.     jmp   rskp          ; Do a skip return
  14916. fptwrt:
  14917.     lda   logfg          ;[56] are we logging this?
  14918.     bpl   fptwr0          ;[56] no
  14919.     lda   flowfg          ;[57] do we have flow control ?
  14920.     bpl   fptwr0          ;[57] no
  14921.     lda   #hxoff          ;[57] yes tell remote to stop
  14922.     jsr   tl0cmd          ;[57]
  14923.     lda    flowdl        ;[57] and wait for it to take effect
  14924.     sta    kwrk01        ;[57] work space
  14925. fptwr3:    jsr    telcp        ;[57] check port for input and save it
  14926.     lda    kwrk01        ;[57] are we thru waiting ?
  14927.     beq    fptwr0        ;[57] yes
  14928. ;[78]    lda    #2        ;[57] 2 ms
  14929. ;[82]    lda    #25        ;[78] 2 ms
  14930. ;[85]    lda    #17        ;[78] 1 ms
  14931.     lda    timect        ;[85] 1 ms
  14932.     jsr    wait        ;[57]
  14933.     dec    kwrk01        ;[57] waited long enough ?
  14934. ;[82]    jmp    fptwr3        ;[57] no
  14935.     bne    fptwr3        ;[82] no
  14936. fptwr0:
  14937.     lda    dosflg        ;[59] is this prodos?
  14938.     beq    fpwr2        ;[59] no
  14939.     jsr    prodos        ;[59]
  14940.     .byte    wrfil        ;[59]
  14941.     .word    prdwr        ;[59]
  14942.     bcc    .+5        ;[59]
  14943.     jsr    perror        ;[59]
  14944.     jmp    fpwr3        ;[59]
  14945. fpwr2                ;[59]
  14946.     lda   #fncwrt          ; Get the 'write' function code
  14947.     sta   opcod          ;     and stuff it in the file manager parms
  14948.     lda   #$00          ; Make the range length
  14949.     sta   rnglnh          ;     look like the buffer length less one
  14950.     lda   #mxdb-1          ;         ...
  14951.     sta   rnglnl          ;         ...
  14952.     lda   #sfntrn          ; Subfunction is 'transfer range' of bytes
  14953.     sta   subcod          ;         ...
  14954.     lda   #dosbuf\      ; Get the dos buffer and stuff that parm into
  14955.     sta   fnadrl          ;     DOS' parm list
  14956. ;[84]    lda   #dosbuf^      ;         ...
  14957. ;[84]    sta   fnadrh          ;         ...
  14958. ;[84]    jsr   dosfmn          ; Call the file manager
  14959.     ldx   #dosbuf^      ;[84]         ...
  14960.     stx   fnadrh          ;[84] x must be non 0         ...
  14961.     jsr   dosfmg          ;[84] Call the file manager
  14962. fpwr3                ;[59]
  14963.     lda   logfg          ;[56] was this from logging ?
  14964.     bpl   fptwr1          ;[56] no
  14965.     lda   flowfg          ;[57] do we have flow control ?
  14966.     bpl   fptwr1          ;[57] no
  14967.     lda   #hxon          ;[57] yes tell remote to resume
  14968.     jsr   tl0cmd          ;[57]
  14969. fptwr1:
  14970.     lda    dosflg        ;[59] is this prodos?
  14971.     bne    fptrst        ;[59] yes
  14972.     lda   fmrcod          ; Fetch the return code from the last call
  14973. ;[84]    cmp   #dsener          ; No errors?
  14974.     beq   fptrst          ; No errors! reset everything
  14975.     jmp   fatal          ; The error was probably bad, handle it
  14976. fptrst: lda   #mxdb-1          ; Set last character to one less than actual
  14977.     sta   dsbend          ;     buffer size
  14978.     lda   #$00          ; Clear
  14979.     sta   dsbind          ;     the buffer index
  14980.     jmp   rskp          ; Do a skip return
  14981.     .endc
  14982.  
  14983. .SBTTL    Utility routines
  14984.  
  14985. ;
  14986. ;     The following routines are short low-level routines which help
  14987. ;     shorten the code and make it more readable
  14988. ;
  14989.  
  14990.  
  14991. ;
  14992. ;     Incn - increment the packet sequence number expected by this
  14993. ;     Kermit. Then take that number Mod $3f.
  14994. ;         Edit 16 adds the function of incrementing the total packet
  14995. ;         count for display during transmission
  14996. ;
  14997.  
  14998. ;[87]incn:    pha          ; Save AC
  14999. incn:                ;[87]
  15000.     lda    prtcl        ;[83] xmodem
  15001.     beq    incn1        ;[83] no
  15002.     inc    n        ;[83] simple for xmodem
  15003.     jmp    incn2        ;[83]
  15004. incn1                ;[83]
  15005.     lda   n          ; Get the packet number
  15006.     clc          ; Clear the carry flag for the add
  15007.     adc   #$01          ; Up the number by one
  15008.     and   #$3f          ; Do this Mod $3f!
  15009.     sta   n          ; Stuff the number where it belongs
  15010. ;[59]    clc          ;[16] Clear carry again
  15011. ;[59]    lda   tpak          ;[16] Increment L.O. byte of
  15012. ;[59]    adc   #$01          ;[16]     total packet count
  15013. ;[59]    sta   tpak          ;[16]         ...
  15014. ;[59]    lda   tpak+1          ;[16] Do H.O. byte
  15015. ;[59]    adc   #$00          ;[16]         ...
  15016. ;[59]    sta   tpak+1          ;[16]         ...
  15017. incn2                ;[83]
  15018.     inc    tpak        ;[59] bump it the easy way
  15019.     bne    incn3        ;[59]
  15020.     inc    tpak+1        ;[59]
  15021. incn3                ;[59]
  15022. ;[87]    pla          ; Restore the AC
  15023.     rts          ;     and return
  15024.  
  15025. ;
  15026. ;     Movdds - This routine moves the default slot and drive for
  15027. ;     file transfers into the appropriate locations for DOS to
  15028. ;     find them.
  15029. ;
  15030.  
  15031. ;[84]movdds: 
  15032. ;[84]    pha          ;[40] Save the AC across this call
  15033. ;[84]    lda    dosflg        ;[59] prodos?
  15034. ;[84]    bne    movdd1        ;[59] yes
  15035. ;[84]    lda   defslt          ;[40] Move the slot
  15036. ;[84]    sta   kdslot          ;[40]     to where it belongs
  15037. ;[84]    lda   defdrv          ;[40] Move the drive
  15038. ;[84]    sta   kddisk          ;[40]     to where it belongs
  15039. ;[84]    lda    defvol        ;[60]
  15040. ;[84]    sta    kdvol        ;[60]
  15041. ;[84]movdd1    pla          ;[40] Restore the AC
  15042. ;[84]    rts          ;[40]     and return
  15043.  
  15044. ;
  15045. ;     Prcerp - Process error packet. Moves the Remote Kermit error
  15046. ;     text into a save area, notes that there was an error received
  15047. ;     from the remote Kermit in Errcod (set H.O. bit), and displays
  15048. ;     the text on the screen.
  15049. ;
  15050.  
  15051. prcerp: lda   ptype          ;[38] Reload the packet type
  15052.     cmp   #'E          ;[38] Is it an error packet?
  15053.     beq   prcer1          ;[38] Yes, continue processing
  15054.     lda    #false        ;[67] tattle its no error pkt
  15055.     rts          ;[38] No, return
  15056. prcer1: lda   #pdbuf\          ;[38] Set up from-address
  15057.     sta   kerfrm          ;[38]         ...
  15058.     lda   #pdbuf^          ;[38]         ...
  15059.     sta   kerfrm+1      ;[38]         ...
  15060.     lda   #errrkm\      ;[38] Set up the to-address
  15061.     sta   kerto          ;[38]         ...
  15062.     lda   #errrkm^      ;[38]         ...
  15063.     sta   kerto+1          ;[38]         ...
  15064.     ldy   pdlen          ;[38] Get packet data length
  15065.     sty   kwrk01          ;[38] Store for the copy routine
  15066.     lda   #$00          ;[38] Start by storing a null at the end
  15067.     sta   (kerto),y      ;[38]         ...
  15068.     jsr   kercpy          ;[38] Copy the error text
  15069.     lda   errcod          ;[38] Set the bit in the error code
  15070.     ora   #eprflg          ;[38]     saying that the remote Kermit sent us
  15071.     sta   errcod          ;[38]     an error packet.
  15072.     ldx    #erin02\    ;[59]
  15073.     ldy    #erin02^    ;[59]
  15074.     jsr    prstr        ;[59] say its from the remote
  15075.     ldx   #errrkm\      ;[38] Finally, display the error packet
  15076.     ldy   #errrkm^      ;[38]         ...
  15077.     jsr   prrstr          ;[38] Print string
  15078.     jsr   prcrlf          ;[38] Make it look neat, add a crlf
  15079.     jsr    bell        ;[59] get someones attention
  15080.     lda    #true        ;[67] tattle its an error pkt
  15081.     rts          ;[38] Return to caller
  15082.  
  15083. ;
  15084. ;     Prrstr - print a string from a remote source (i.e. there may
  15085. ;     be lower case or special characters in it.
  15086. ;
  15087.  
  15088. prrstr: stx   saddr          ;[38] Save Low order byte
  15089.     sty   saddr+1          ;[38] Save High order byte
  15090.     ldy   #$00          ;[38] Clear Y reg
  15091.  
  15092. prrst1: lda   (saddr),y      ;[38] Get the next byte of the string
  15093.     beq   prrsrt          ;[38] If it is null, we are done
  15094.     pha          ;[38] Hold the AC
  15095. ;[85]    lda   #$32          ;[38] Set delay
  15096.     lda    timect        ;[85] Set delay
  15097.     rol    a        ;[85] just double it
  15098. ;[78]    jsr   $fca8          ;[38] Do the delay
  15099.     jsr   wait          ;[78] Do the delay
  15100.     pla          ;[38] Fetch the character back
  15101.     jsr   dspchr          ;[38] Print the character
  15102.     iny          ;[38] Up the index
  15103.     bne   prrst2          ;[38] If zero, the string is <256, continue
  15104.     inc   saddr+1          ;[38] Increment page number
  15105. prrst2: jmp   prrst1          ;[38] Go back to print next byte
  15106. prrsrt: rts          ;[38] Return
  15107.  
  15108. comint    lda    #0        ;[81]
  15109.     sta    kerins        ;[81] force initialization
  15110.     jsr    tlinit        ;[81] initilize the com card
  15111.     bne    prrsrt        ;[81] unable to use the com port
  15112.     jsr    u2icc        ;[81] tattle
  15113.     pla            ;[81] keep stack straight
  15114.     pla            ;[81]
  15115.     jmp    kermit        ;[81] failure
  15116.  
  15117. ;
  15118. ;     Gobble - snarfs a line of characters from the port up to
  15119. ;     the receive end-of-line character. If it sees a keyboard
  15120. ;     interupt, it punts and does not skip.
  15121. ;
  15122.  
  15123. gobble: lda   #$00
  15124.     sta   pdtend          ; Zero the index pointing to end of line buffer
  15125.     lda   kbd          ;[58][21] Try to make sure we don't get an
  15126.     lda   kbdstr          ;[58][21]     unwarranted keyboard interupt
  15127. gobb:    jsr   getc          ;[27] Get a character
  15128.           jmp     gobb2          ;[27] Got a keyboard interupt
  15129. ;[82]    cmp   #soh          ;[27] Is it a start-of-header?
  15130.     ldx    prtcl        ;[83] xmodem?
  15131.     beq    gobba        ;[83] no
  15132.     cmp    #'C        ;[83] crc request?
  15133.     beq    gobbc        ;[83] yes
  15134.     cmp    #eot        ;[83] end of file?
  15135.     beq    gobbc        ;[83] yes
  15136.     cmp    #nak        ;[83] bad pkt
  15137.     beq    gobbc        ;[83] yes
  15138.     cmp    #ack        ;[83] ok?
  15139.     bne    gobba        ;[83] no
  15140. gobbc    ldx    #0        ;[83]
  15141.     inc    pdtend        ;[83] tell how many
  15142.     jmp    gobb33        ;[83]
  15143. gobba                ;[83]
  15144.     cmp   sop          ;[82] Is it a rec start-of-header?
  15145.     bne   gobb          ;[27] No, flush until first SOH
  15146. ;[83]    jmp   gobbst          ;[27] Ok, now we can start
  15147.     beq   gobbst          ;[83] Ok, now we can start
  15148. gobb0:    jsr   getc          ; Get a character
  15149.           jmp     gobb2          ; Got a keyboard interupt
  15150. ;[82]    cmp   #soh          ;[27] If this not an SOH
  15151.     ldx    prtcl        ;[83] xmodem?
  15152.     bne    gobbst        ;[83] yes
  15153.     cmp   sop          ;[82] If this not a rec SOH
  15154.     bne   gobb1          ;[27]     continue here
  15155. ;[75]    tax          ;[27] Hold the character here
  15156. ;[75]    lda   #$00          ;[27] Rezero the index pointing to end of buf
  15157. ;[75]    sta   pdtend          ;[27]         ...
  15158. ;[75]    txa          ;[27] Get the SOH back
  15159.     ldx   #$00          ;[75][27] Rezero the index pointing to end of buf
  15160.     stx   pdtend          ;[75][27]         ...
  15161. ;[83]    jmp   gobbdb          ;[27] Go stuff the character in the buffer
  15162.     beq   gobbdb          ;[83] Go stuff the character in the buffer
  15163. gobb1:    cmp   reol          ; Is it the end-of-line character?
  15164.     beq   gobb3          ; Yes, finish up
  15165. gobbst: ldx   pdtend          ;[27] Get the index we need
  15166. gobbdb: sta   plnbuf,x      ;[27] Stuff the character at the buffer
  15167.     inc   pdtend          ; Increment the index once
  15168. ;[83]    jmp   gobb0          ; Loop for another character
  15169.     lda    prtcl        ;[83] xmodem?
  15170.     beq    gobb0        ;[83] no
  15171.     cpx    #sfxmd+3    ;[83] data plus rest
  15172.     beq    gobb4        ;[83] were thru
  15173.     bne    gobb0        ;[83] next
  15174. gobb2:    rts          ; Just return, no skip
  15175. gobb3:    ldx   pdtend          ;[27] Get end pointer again
  15176. gobb33                ;[83]
  15177.     sta   plnbuf,x      ;[27] Store the End-of-line before we leave
  15178. gobb4                ;[83]
  15179.     lda   #$00          ; Zero the index, leave eob ptr where it is
  15180.     sta   pdtind          ;         ...
  15181.     jmp   rskp          ; Return with a skip!
  15182.  
  15183. ;
  15184. ;     Getplc - gets a character from the port line buffer and
  15185. ;     returns it. If the buffer is empty, it returns without
  15186. ;     skipping.
  15187. ;
  15188.  
  15189. getplc: ldx   pdtind          ; Get the current index
  15190.     cpx   pdtend          ; Less than the end buffer pointer?
  15191. ;[75]    bmi   getpl1          ; If so, go return the next character
  15192.     bcc   getpl1          ;[75] If so, go return the next character
  15193.     rts          ; Return without a skip
  15194. getpl1: lda   plnbuf,x      ; Get the next character from the buffer
  15195.     inc   pdtind          ; Up the index once
  15196.     jmp   rskp          ; Return with a skip!
  15197.  
  15198. ;
  15199. ;     Putplc - puts a character to the port line buffer.
  15200. ;
  15201.  
  15202. putplc: ldx   pdtind          ;[25] Get the current index
  15203. ;[75]    inx          ;[25] Check if we are at end of buffer
  15204. ;[75]    bne   putpl1          ;[25] No, continue
  15205. ;[75]    rts          ;[25] Return without a skip
  15206. ;[75]putpl1: dex          ;[25] Set index back to what it was
  15207.     sta   plnbuf,x      ;[25] Get the next character from the buffer
  15208.     inc   pdtind          ;[25] Up the index once
  15209.     rts          ;[25] Return
  15210.  
  15211.     .ifeq <ftcom-ftappl>
  15212. ;
  15213. ;     Getc - skip returns with a character from the port or does
  15214. ;     a normal return if a key from the keyboard is received first.
  15215. ;     If it skips, the character from the port is returned in the 
  15216. ;     AC.
  15217. ;
  15218.  
  15219. getc:                ;[64]
  15220.     lda    #$ff        ;[64]
  15221.     sta    twrk1        ;[64] setup fuzzy timer for timeout
  15222.     lda    lpcycl        ;[64] get receive timeout lsb
  15223.     sta    twrk1+1        ;[64]
  15224.     lda    lpcycl+1    ;[64] get receive timeout msb
  15225.     sta    twrk1+2        ;[64]
  15226. getc3    lda    timer        ;[64] is timer on?
  15227.     beq    getc9        ;[64] no
  15228.     lda    twrk1        ;[64]
  15229.     bne    getc6        ;[64] is lsb 0?,no
  15230.     lda    twrk1+1        ;[64] how about middle byte
  15231.     bne    getc7        ;[64] no
  15232.     lda    twrk1+2        ;[64]
  15233.     beq    getc5        ;[64] has timer expired? yes
  15234.     dec    twrk1+2        ;[64] now dec msb
  15235. getc7    dec    twrk1+1        ;[64] middle byte
  15236. getc6    dec    twrk1        ;[64]  decrement lsb
  15237. getc9    jsr   telck          ; No character from keyboard?
  15238. ;[59]    cmp   #false          ;         ...
  15239.     beq   getc1          ; If not try port
  15240.     lda   kbd          ; Get the key
  15241.     bit    kbdstr        ;[59] dont leave it hanging
  15242. ;[87]    and   #$7f          ; Shut H.O. bit
  15243. ;[87]    cmp   #'Q        ; Was it an 'abort' interupt?
  15244.     ora    #$20        ;[87] make it lower case, leave upper bit on
  15245.     cmp   #'q+$80        ;[87] Was it an 'abort' interupt?
  15246.     bne   getc0          ; Nope, continue
  15247.     lda    #1        ;[84] so close wont write
  15248.     jsr    closef        ;[84] now close the file
  15249.     lda   #$08          ; Error code for 'file trans abort'
  15250.     sta   errcod          ; Stuff it here
  15251.     ldx   kerosp          ; Get the old stack pointer back
  15252.     txs          ; Restore it
  15253.     jmp   kermit          ; Warmstart kermit
  15254. getc5    lda    #11        ;[64] setup timeout error
  15255.     sta    errcod        ;[64]
  15256. getc0:    ;[59]    bit   kbdstr          ;     and reset the strobe
  15257.     rts          ; Keyboard interupt, return
  15258. getc1:    jsr   telcp          ; Check the port
  15259.     beq   getc3          ;[64]     go back to the top of the loop
  15260.     jsr   telgpc          ; Go get the port character
  15261.     ldx    parity        ;[75] should we keep 8th bit?
  15262.     beq    getc2        ;[75] yes, now dont lie to me!!!!!
  15263.     and    #$7f        ;[65] what if we have parity,turn it off
  15264. getc2                ;[75]
  15265.     jmp   rskp          ;     and return skip!
  15266.  
  15267. ;
  15268. ;     Telck - checks the keyboard for a character. It returns
  15269. ;     false if none is present, otherwise it returns true.
  15270. ;     It does NOT return the character.
  15271. ;
  15272.  
  15273. telck:    bit   kbd          ; Check the keyboard
  15274.     bpl   telckf          ; No character
  15275.     lda   #true          ; There is a character there
  15276.     rts          ; Return true
  15277. telckf: lda   #false          ; No character, failure return
  15278.     rts          ; Go back
  15279.     .endc
  15280.  
  15281. ;
  15282. ;     Prson - parses an 'on' or an 'off' keyword and passes
  15283. ;     the result back to the calling routine in the x-index
  15284. ;     register. If there is an error, it pops the return
  15285. ;     address off the stack and transfers control to kermt2
  15286. ;     to issue the error message.
  15287. ;
  15288.  
  15289. prson:    lda   #oncmd\          ; L.O. byte of command table
  15290.     sta   cminf1          ; Store that
  15291.     lda   #oncmd^          ; Get H.O. byte of command table address
  15292.     sta   cminf1+1      ; Stuff that parameter
  15293.     lda   #shon\          ;[13] Set up default string for parse
  15294.     sta   cmdptr          ;[13]         ...
  15295.     lda   #shon^          ;[13]         ...
  15296.     sta   cmdptr+1      ;[13]         ...
  15297.     ldy   #cmfdff          ;[13] Show there is a default
  15298.     lda   #cmkey          ; Code for keyword
  15299.     jsr   comnd          ; Go do it
  15300.           rts              ; The command was not recognized
  15301.           nop              ;         ...
  15302.           nop              ;         ...
  15303.     jmp   rskp          ; Good, skip return
  15304.  
  15305. ;
  15306. ;     prcfm - parses for a confirm, then transfers control directly
  15307. ;     to the top of the main loop
  15308. ;
  15309.  
  15310. prcfm:    lda   #cmcfm          ; Load token for confirm
  15311.     jsr   comnd          ; Parse a confirm
  15312.           jmp     kermt3          ; No confirm, give an error
  15313. ;[73]    lda   #hcr          ; Print a crlf
  15314. ;[73]    jsr   cout          ;         ...
  15315. ;[79]    jsr    prcrlf        ;[73] might as well use it
  15316.     jmp    prcrlf        ;[79][73] might as well use it & let it rts
  15317. ;[79]    rts          ; Return
  15318.  
  15319. ;
  15320. ;     Pron - checks the value in the AC and prints either 'ON' or
  15321. ;     'OFF'. (on=1, off=0).
  15322. ;
  15323.  
  15324. pron:    ;[59]    cmp   #on          ; Should we print 'on'?
  15325.     beq   pron1          ;[59] No, go print 'off'
  15326.     ldx   #shon\          ; Point to the 'on' string
  15327.     ldy   #shon^          ;         ...
  15328. ;[79]pron0:    jsr   prstr          ; Print it
  15329. ;[79]    jsr   prcrlf          ; Add a crelf at the end
  15330. pron0    jmp    prstrl        ;[79] let it rts
  15331. ;[79]    rts          ; And return
  15332. pron1:    ldx   #shoff\          ; Point to the 'off' string
  15333.     ldy   #shoff^          ;         ...
  15334.     jmp   pron0          ; Go print it
  15335.  
  15336. pronnr:            ;[81] print on /off without the cr
  15337.     beq   pronn1          ;[81] No, go print 'off'
  15338.     ldx   #shon\          ;[81] Point to the 'on' string
  15339.     ldy   #shon^          ;[81]         ...
  15340. pronn0    jmp    prstr        ;[81] let it rts
  15341. pronn1:    ldx   #shoff\          ;[81] Point to the 'off' string
  15342.     ldy   #shoff^          ;[81]         ...
  15343.     jmp   pronn0          ;[81] Go print it
  15344.  
  15345. ;
  15346. ;     Nonftl - handles non-fatal DOS errors. When Kermit does its
  15347. ;     initialization it points the error vector and the basic
  15348. ;     warmstart vector here.
  15349. ;
  15350.  
  15351. nonftl: lda   fmrcod          ; Get the DOS return code
  15352. nonft0                ;[84]
  15353.     ora   #$80          ; Make sure H.O. bit is on (DOS error)
  15354.     sta   errcod          ; Save that here
  15355.     ldx   kerosp          ; Get the old stack pointer back
  15356.     txs          ; Restore it
  15357.     jmp    stat07        ;[62] lets print the error and handle server
  15358. ;[62]    jmp   kermit          ; Warmstart kermit
  15359.  
  15360. ;
  15361. ;     Fatal - closes and deletes a file on which a bad error
  15362. ;     has occured (most likely a 'disk full' error). It then
  15363. ;     restores the old stack pointer and warmstarts Kermit.
  15364. ;
  15365.  
  15366. fatal:    lda   fmrcod          ; Get the DOS return code
  15367.     ora   #$80          ; Set H.O. bit to indicate DOS error
  15368.     sta   errcod          ; Store the error code
  15369.     lda   #$01          ; Make sure 'closef' knows there was an error
  15370.     jsr   closef          ; Close the file
  15371. ;[84]    jsr   dosdel          ; Now, delete the useless file
  15372.     lda    #fncdel        ;[84] the delete command
  15373.     sta    doscmi        ;[84] should be non 0
  15374.     jsr    initfm        ;[84] use the file manager to delete
  15375.     ldx   kerosp          ; Get the old stack pointer
  15376.     txs          ; Restore it
  15377.     jmp    stat07        ;[62] lets print the error and handle server
  15378. ;[62]    jmp   kermit          ; Warmstart kermit
  15379.     
  15380. ;
  15381. ;     Clrfcb - clears the area FCB1 so the filename placed there
  15382. ;     will not be corrupted.
  15383. ;
  15384.  
  15385. clrfcb: ldx   #$1f-1      ;[57] not quite so much[29] Load max filename length
  15386.     lda   #hspace          ;[29] We will be filling with spaces
  15387. clrfc1: sta   fcb1,x          ;[29] Stuff the space
  15388.     dex          ;[29] Decrement our pointer
  15389.     bpl   clrfc1          ;[29] Not done, go back
  15390. kercrt            ;[78]
  15391. kerflr            ;[78]
  15392.     rts          ;[29] Return
  15393.  
  15394. ;
  15395. ;     Kercpy - copies the string pointed to by Kerfrm to the
  15396. ;     block of memory pointed to by Kerto for Kwrk01 characters.
  15397. ;
  15398.  
  15399. kercpy: ldy   kwrk01          ;[13] Get the length of the string
  15400. kerclp: dey          ;[13] One character less
  15401.     bmi   kercrt          ;[13] If this went negative, we're done
  15402.     lda   (kerfrm),y      ;[13] Get the next character
  15403.     sta   (kerto),y      ;[13] And put it where it belongs
  15404.     jmp   kerclp          ;[13] Go back for next char
  15405. ;[78]kercrt: rts          ;[13] Job is done, return
  15406.  
  15407. kercph: ldy   kwrk01          ;[59] Get the length of the string
  15408. kerclh: dey          ;[59] One character less
  15409.     bmi   kercrt          ;[59] If this went negative, we're done
  15410.     lda   (kerfrm),y      ;[59] Get the next character
  15411.     ora    #$80        ;[59] set high bit on
  15412.     sta   (kerto),y      ;[59] And put it where it belongs
  15413.     jmp   kerclh          ;[59] Go back for next char
  15414. ;
  15415. ;     Kerflm - fills the buffer pointed to by Kerto with the
  15416. ;     character in kwrk02 for Kwrk01 characters.
  15417. ;
  15418.  
  15419. kerflm: ldy   kwrk01          ;[13] Get the length of the string
  15420.     lda   kwrk02          ;[13] Get the fill character
  15421. kerflp: dey          ;[13] One character less
  15422.     bmi   kerflr          ;[13] If this went negative, we're done
  15423.     sta   (kerto),y      ;[13] And put it in the next position
  15424.     jmp   kerflp          ;[13] Go back to do next char
  15425. ;[78]kerflr: rts          ;[13] Job is done, return
  15426.  
  15427.  
  15428. ;
  15429. ;     Prchr - takes a character from the AC and prints it. It
  15430. ;     echos control characters as '^<chr>' and escape as '$'.
  15431. ;
  15432.  
  15433. prchrl    jsr    logput        ;[76] log the ch and then print everything
  15434. prchr:    ora   #$80          ; Make sure it's in range
  15435.     cmp   #$a0          ;[26] Less than escape??
  15436.     bpl   prchr1          ; If not, continue
  15437.     tax          ; Hold the character
  15438. ;[75]    lda   #'^          ; Load the up-arrow for cntrl characters
  15439. ;[76]    lda   #'^+$80          ;[75] Load the up-arrow for cntrl characters
  15440. ;[75]    ora   #$80          ; Put it in printable range
  15441.     lda    #si+$80        ;turn on invers video
  15442.     jsr   cout          ; Print the character
  15443.     lda    textfm        ;[76] just in case it 40 col II/II+
  15444.     pha            ;[76] save it
  15445.     lda    #$3f        ;[76] this makes it inverse
  15446.     sta    textfm        ;[76]
  15447.     txa          ; Get the character back
  15448.     clc          ; Clear carry for add
  15449.     adc   #$40          ; Put this in the alphabetic range
  15450.     jsr    cout        ;[76] put out shifted cntl ch
  15451.     pla            ;[76] restore textfm
  15452.     sta    textfm        ;[76]
  15453.     lda    #so+$80        ;[76] turn off the invers video
  15454. prchr1: jmp   cout          ;[70][26] Normal character, just dump it
  15455. ;[70]    rts          ;     and go back
  15456.  
  15457. ;
  15458. ;     Genmad - takes a message base, offset and size and calculates
  15459. ;     the address of the message leaving it in the X and Y registers
  15460. ;     ready for a call to PRSTR. The size and offset are taken from
  15461. ;     the stack and the base address is found in kermbs.
  15462. ;
  15463.  
  15464. genmad: pla          ; Get return address
  15465.     sta   kerrta          ;     and save it till later
  15466.     pla          ;         ...
  15467.     sta   kerrta+1      ;         ...
  15468.     pla          ; Get message offset
  15469.     tax          ; Hold it here for a while
  15470.     pla          ; Get the message length
  15471.     tay          ;     and put it here
  15472.     lda   #$00          ; H.O. byte of message offset for mul16
  15473.     pha          ;[87] msb
  15474.     pha          ;         ...
  15475.     txa          ; L.O. byte of message offset
  15476.     pha          ;         ...
  15477.     lda   #$00          ; H.O. byte of message size for mul16
  15478.     pha          ;[87] msb
  15479.     pha          ;         ...
  15480.     tya          ; L.O. byte of message size
  15481.     pha          ;         ...
  15482. ;[87]    jsr   mul16          ; Calculate the actual offset in table
  15483.     jsr   mul24          ;[87] Calculate the actual offset in table
  15484.     pla          ; Get L.O. byte of result
  15485.     clc          ; Clear the carry for addition
  15486.     adc   kermbs          ; Add the L.O. byte of the base address
  15487.     tax          ; Put it in X for the return
  15488.     pla          ; Get the H.O. byte
  15489.     adc   kermbs+1      ; Add the H.O. byte of the base address w/carry
  15490.     tay          ; Stuff it here for the return
  15491.     pla        ;[87] msb of product
  15492.     lda   kerrta+1      ; Replace the return address on the stack
  15493.     pha          ;         ...
  15494.     lda   kerrta          ;         ...
  15495.     pha          ;         ...
  15496.     rts          ; Return
  15497.  
  15498. .SBTTL    Spar  and Rpar routines
  15499.  
  15500. ;
  15501. ;     Spar - This routine loads the data buffer with the init parameters
  15502. ;     requested for this Kermit.
  15503. ;
  15504. ;         Input:     NONE
  15505. ;
  15506. ;         Output:     @Kerbf1     - Operational parameters
  15507. ;
  15508. ;         Registers destroyed:     A,Y
  15509. ;
  15510.  
  15511. spar:    ldy   #$00          ; Clear Y
  15512.     sty   datind          ; Clear datind
  15513.     lda   rpsiz          ; Fetch receive packet size
  15514.     cmp    #mxpack+1    ;[75] are we in extended len
  15515.     bcc    .+4        ;[75] no, hate to do this
  15516.     lda    #mxpack        ;[75] in case other cant do extended
  15517.     clc          ; Clear the carry flag
  15518.     adc   #$20          ; Characterize it
  15519.     sta   (kerbf1),y      ; Stuff it in the packet buffer
  15520.     iny          ; Increment the buffer index
  15521.     lda   rtime          ; Get the timeout interval
  15522.     clc          ;         ...
  15523.     adc   #$20          ; Make that a printable character
  15524.     sta   (kerbf1),y      ;     and stuff it in the buffer
  15525.     iny          ; Advance the index
  15526.     lda   rpad          ; Get the amount of padding required
  15527.     clc          ;         ...
  15528.     adc   #$20          ; Make that printable
  15529.     sta   (kerbf1),y      ; Put it in the buffer
  15530.     iny          ; Advance index
  15531.     lda   rpadch          ; Get the padding character expected
  15532.     eor   #$40          ; Controlify it
  15533.     sta   (kerbf1),y      ; And stuff it
  15534.     iny          ; Up the packet buffer index
  15535.     lda   reol          ; Get the end-of-line expected
  15536.     clc          ;         ...
  15537.     adc   #$20          ; Characterize it
  15538.     sta   (kerbf1),y      ; Place that next in the buffer
  15539.     iny          ; Advance the index
  15540.     lda   rquote          ; Get the quote character expected
  15541.     sta   (kerbf1),y      ; Store it as-is last in the buffer
  15542.     iny          ; Advance index
  15543.     lda   #'Y          ;[11] Send 'Y' - I will support 8-bit quoting
  15544. ;    ldx    ascii        ;[82]
  15545. ;    bne    spar3        ;[82] ascii is only 7bits
  15546.     ldx    dosflg        ;[82]
  15547.     bne    spar2        ;[82] prodos text uses all 8 bits
  15548.     ldx    filmod        ;[75] do we really need ebq
  15549.     beq    spar3        ;[75] no just send a 'y
  15550. spar2                ;[82]
  15551.     ldx    parity        ;[75] do we have a 8 bit path?
  15552.     beq    spar3        ;[75] yes
  15553.     lda    rebq        ;[72] tell other kermit what ch to use
  15554. spar3    sta   (kerbf1),y      ; Stuff it into the data area
  15555.     iny        ;[75] ready for the crc field
  15556.     lda    #'1    ;[75] only 1 crc byte
  15557.     sta    (kerbf1),y        ;[75]
  15558.     iny        ;[75] now for the repeat
  15559.     lda    #'     ;[75]
  15560.     sta    (kerbf1),y    ;[75]
  15561.     iny        ;[75] now for the capacity
  15562. ;[87]    lda    #'"    ;[75] should be the 2 bit (1 bit if starting from 0)
  15563.     lda    #$2a    ;[87] file attr & extended len
  15564.     ldx    rpsiz    ;[75] do we really want to support extended len
  15565.     cpx    #mxpack+1    ;[75]
  15566.     bcs    .+4        ;[75] got to be a better way
  15567. ;[87]    lda    #sp        ;[75] say no extended len
  15568.     lda    #$28        ;[87] say no extended len
  15569.     sta    (kerbf1),y    ;[75]
  15570.     iny        ;[75] now for the window
  15571.     lda    #'     ;[75]
  15572.     sta    (kerbf1),y    ;[75]
  15573.     iny        ;[75] now for the extended length
  15574.     sty    ksavey        ;[75] need this later
  15575.     lda    #0        ;[75] msb
  15576.     pha        ;[75]
  15577.     pha        ;[87]
  15578.     lda    rpsiz        ;[75] lsb
  15579.     pha            ;[75]
  15580.     lda    #0        ;[75] msb
  15581.     pha        ;[75]
  15582.     pha        ;[87]
  15583. ;[84]    lda    #95        ;[75] lsb
  15584.     lda    #dpakln+1        ;[84] lsb
  15585.     pha        ;[75]
  15586. ;[87]    jsr    div16        ;[75] get q and rem
  15587.     jsr    div24        ;[87] get q and rem
  15588.     bcc    .+3        ;[75] always good it says here
  15589.     brk            ;[75] got to do something better
  15590.     ldy    ksavey        ;[75] restore y
  15591.     pla        ;[75]
  15592.     clc        ;[75]
  15593.     adc    #'         ;[75] char it
  15594.     sta    (kerbf1),y    ;[75] xl1
  15595.     iny            ;[75]
  15596.     pla            ;[75] msb got to be 0
  15597.     pla            ;[87] msb got to be 0
  15598.     pla            ;[75] lsb of rem
  15599.     clc        ;[75]
  15600.     adc    #'         ;[75] char it
  15601. ;    lda    #maxxdl/95+$20    ;[75]
  15602. ;    sta    (kerbf1),y    ;[75] xl1
  15603. ;    iny        ;[75] rest of extended length
  15604. ;    lda    #maxxdl%95+$20    ;[75] should be remainder
  15605.     sta    (kerbf1),y    ;[75] xl2
  15606.     pla            ;[75] msb of rem
  15607.     pla            ;[87] msb of rem
  15608. raparz                ;[87]
  15609.     rts    ;[75]
  15610. ;
  15611. ;     Rapar - This routine sets file attributes from the other kermit
  15612. ;     from the init packet data buffer.
  15613. ;
  15614. ;         Input:     @Kerbf1     - Operational parameters
  15615. ;
  15616. ;         Output:     parameters set
  15617. ;
  15618. ;         Registers destroyed:     A,Y,x
  15619. ;
  15620.  
  15621. rapar:    ldy   #$00          ;[87] Start the data index at 0
  15622. rapar0    lda    (kerbf1),y    ;[87] so what attribute do we have?
  15623.     tax            ;[87] we shall test in x
  15624.     jsr    despa        ;[87] get the len in a
  15625.     sta    ksavea        ;[87] this is the len of this attribute
  15626.     cpx    #'!        ;[87] this is size in k
  15627.     bne    rapar3        ;[87] no
  15628.     jsr    asc2bn        ;[87] need a binary #
  15629.     lda    #0        ;[87] msb
  15630.     pha            ;[87]
  15631.     lda    #1024^        ;[87] its in k remember
  15632.     pha            ;[87]
  15633.     lda    #1024\        ;[87]
  15634.     pha            ;[87]
  15635.     lda    lcurfl+2    ;[87] msb of size
  15636.     pha            ;[87]
  15637.     lda    lcurfl+1    ;[87]
  15638.     pha            ;[87]
  15639.     lda    lcurfl        ;[87] lsb
  15640.     pha            ;[87]
  15641.     jsr    mul24        ;[87]
  15642.     pla            ;[87] now its in bytes
  15643.     sta    lcurfl        ;[87]
  15644.     pla            ;[87]
  15645.     sta    lcurfl+1    ;[87]
  15646.     pla            ;[87]
  15647.     sta    lcurfl+2    ;[87]
  15648.     ldy    ksavey        ;[87]
  15649. rapar2    iny            ;[87]
  15650.     cpy    pdlen        ;[87] out of data?
  15651.     bge    raparz        ;[87] yes
  15652.     blt    rapar0        ;[87] more
  15653. rapar3    cpx    #'"        ;[87] how abt file type
  15654.     bne    rapar7        ;[87] no
  15655.     iny            ;[87]
  15656.     lda    (kerbf1),y    ;[87] next
  15657.     cmp    #'A        ;[87] ascii?
  15658.     bne    rapar6        ;[87] no
  15659.     lda    #0        ;[87] set file mode to text
  15660.     sta    filmod        ;[87] probably will be trouble
  15661.     dec    ksavea        ;[87] more?
  15662.     beq    rapar2        ;[87] no
  15663.     iny            ;[87]
  15664.     lda    (kerbf1),y    ;[87] lets see what the terminator is
  15665.     cmp    #'M        ;[87] cr?
  15666.     beq    rapar5        ;[87] yes
  15667. rapa33    dec    ksavea        ;[87]
  15668. rapar4    tya            ;[87] skip rest of attr data
  15669.     clc            ;[87]
  15670.     adc    ksavea        ;[87]
  15671.     tay            ;[87]
  15672.     jmp    rapar2        ;[87]
  15673. rapar5    dec    ksavea        ;[87]
  15674.     beq    rapar2        ;[87]
  15675.     iny            ;[87]
  15676.     lda    (kerbf1),y    ;[87]
  15677.     cmp    #'J        ;[87] crlf?
  15678.     bne    rapar4        ;[87] que passo?
  15679.     sta    xcrlf        ;[87] this is receive crlf->cr
  15680.     bne    rapa33        ;[87]
  15681. rapar6    cmp    #'B        ;[87] binary?
  15682.     bne    rapa33        ;[87] cant handle others
  15683.     lda    #4        ;[87] make file mode binary
  15684.     sta    filmod        ;[87] someone probably wont like this
  15685.     bne    rapa33        ;[87]
  15686. rapar7    cpx    #'1        ;[87] exact # of bytes?
  15687.     bne    rapar9        ;[87] no, forget this subfield try next
  15688.     jsr    asc2bn        ;[87] yes, put it in lcurfl
  15689.     jmp    rapar4        ;[87]
  15690. rapar9    cpx    #'#        ;[87] how abt date & time
  15691.     bne    rapar4        ;[87] no
  15692.     ldx    #0        ;[87] index into getln
  15693. rapara    iny            ;[87] get a ch
  15694.     lda    (kerbf1),y    ;[87]
  15695.     cmp    #'         ;[87] space is end of date
  15696.     beq    raparc        ;[87] yes
  15697.     dey            ;[87] its smaller this way
  15698.     jsr    tasc2b        ;[87] 2 asc chs to bin
  15699.     jmp    rapara        ;[87] next
  15700. raparc    dec    ksavea        ;[87] account for the space
  15701.     txa            ;[87] any?
  15702.     beq    rapar4        ;[87] no, que passo quit
  15703.     lda    getln-2,x    ;[87] this is mo
  15704.     asl    a        ;[87] shift it 5
  15705.     asl    a        ;[87]
  15706.     asl    a        ;[87]
  15707.     asl    a        ;[87]
  15708.     asl    a        ;[87]
  15709.     ora    getln-1,x    ;[87] this is day
  15710.     sta    pcrdat        ;[87] part of mo & day
  15711.     lda    getln-3,x    ;[87] yr
  15712.     rol    a        ;[87] get carry from mo
  15713.     sta    pcrdat+1    ;[87]
  15714.     jsr    tasc2b        ;[87] now for the time
  15715.     sta    pcrtim+1    ;[87] first the hr
  15716.     iny            ;[87] skip :
  15717.     dec    ksavea        ;[87]
  15718.     jsr    tasc2b        ;[87]
  15719.     sta    pcrtim        ;[87] & min
  15720.     jmp    rapar4        ;[87]
  15721.  
  15722. tasc2b    iny            ;[87] next ch
  15723.     lda    (kerbf1),y    ;[87]
  15724.     dec    ksavea        ;[87] got to keep track
  15725.     sec            ;[87]
  15726.     sbc    #'0        ;[87] make it binary
  15727.     sta    getln,x        ;[87] save it
  15728.     iny            ;[87]
  15729.     lda    (kerbf1),y    ;[87] next
  15730.     dec    ksavea        ;[87]
  15731.     sec            ;[87]
  15732.     sbc    #'0        ;[87] binary
  15733.     pha            ;[87] for later
  15734.     lda    getln,x        ;[87] times 10
  15735.     asl    a        ;[87]
  15736.     asl    a        ;[87]
  15737.     asl    a        ;[87]
  15738.     clc            ;[87]
  15739.     adc    getln,x        ;[87]
  15740.     adc    getln,x        ;[87]
  15741.     sta    getln,x        ;[87]
  15742.     pla            ;[87]
  15743.     adc    getln,x        ;[87] finally
  15744.     sta    getln,x        ;[87]
  15745.     inx            ;[87]
  15746.     rts            ;[87]
  15747.  
  15748. asc2bn    lda    #0        ;[87]
  15749.     sta    lcurfl        ;[87] convert from ascii to bin
  15750.     sta    lcurfl+1    ;[87] & put it in lcurfl
  15751.     sta    lcurfl+2    ;[87]
  15752.     lda    ksavea        ;[87] any in the subfield?
  15753.     beq    asc2br        ;[87] no
  15754. rapar1    sty    ksavey        ;[87] got to save it
  15755.     lda    lcurfl+2    ;[87] msb
  15756.     pha            ;[87]
  15757.     lda    lcurfl+1    ;[87]
  15758.     pha            ;[87]
  15759.     lda    lcurfl        ;[87] lsb
  15760.     pha            ;[87]
  15761.     lda    #0        ;[87] msb
  15762.     pha            ;[87]
  15763.     pha            ;[87]
  15764.     lda    #10        ;[87] lsb, its times 10
  15765.     pha            ;[87]
  15766.     jsr    mul24        ;[87] 24 bit mul
  15767.     pla            ;[87]
  15768.     sta    lcurfl        ;[87]
  15769.     pla            ;[87]
  15770.     sta    lcurfl+1    ;[87]
  15771.     pla
  15772.     sta    lcurfl+2    ;[87]
  15773.     inc    ksavey        ;[87] restore
  15774.     ldy    ksavey        ;[87]
  15775.     lda    (kerbf1),y    ;[87]
  15776.     sec            ;[87]
  15777.     sbc    #'0        ;[87] better be decimal #
  15778.     clc            ;[87] now add it to lcurfl
  15779.     adc    lcurfl        ;[87]
  15780.     sta    lcurfl        ;[87]
  15781.     bcc    asc2b3        ;[87] no carry
  15782.     inc    lcurfl+1    ;[87] yes
  15783.     bcc    asc2b3        ;[87] more?
  15784.     inc    lcurfl+2    ;[87] yes
  15785. asc2b3    dec    ksavea        ;[87] count of chs
  15786.     bne    rapar1        ;[87] more
  15787. asc2br    rts            ;[87]
  15788.  
  15789. ;
  15790. ;    sapar - set up the attribute pak
  15791. ;
  15792.  
  15793. sapar    ldy    #0        ;[87] just the index
  15794.     lda    #'"        ;[87] type
  15795.     sta    (kerbf1),y    ;[87]
  15796.     iny            ;[87]
  15797.     sty    kwrk01        ;[87] place for len
  15798.     iny            ;[87]
  15799.     lda    filmod        ;[87]
  15800.     bne    sapar3        ;[87]
  15801.     lda    #'A        ;[87] its ascii
  15802.     sta    (kerbf1),y    ;[87]
  15803.     iny            ;[87]
  15804.     lda    #'M        ;[87] term by at least a cr
  15805.     sta    (kerbf1),y    ;[87]
  15806.     iny            ;[87]
  15807.     lda    xcrlf+1        ;[87] see what the crlf<->cr says
  15808.     beq    sapar2        ;[87]
  15809.     lda    #'J        ;[87] it crlf
  15810.     sta    (kerbf1),y    ;[87]
  15811.     iny            ;[87]
  15812.     bne    sapar2        ;[87] always
  15813. sapar3    lda    #'B        ;[87] rest are binary
  15814.     sta    (kerbf1),y    ;[87]
  15815.     iny            ;[87]
  15816.     lda    #'8        ;[87] we only know abt 8 bits
  15817.     sta    (kerbf1),y    ;[87]
  15818.     iny            ;[87]
  15819. sapar2    jsr    satfll        ;[87] and the len
  15820. sapar7    lda    #'.        ;[87] who we are
  15821.     sta    (kerbf1),y    ;[87]
  15822.     iny            ;[87]
  15823.     sty    kwrk01        ;[87] new place for len
  15824.     iny            ;[87]
  15825.     lda    #'A        ;[87] were an apple
  15826.     sta    (kerbf1),y    ;[87]
  15827.     iny            ;[87]
  15828.     lda    #'1        ;[87] 2
  15829.     sta    (kerbf1),y    ;[87]
  15830.     iny            ;[87]
  15831.     jsr    satfll        ;[87] agn set the len
  15832.     lda    lcurfl        ;[87] see if 0 len
  15833.     ora    lcurfl+1    ;[87]
  15834.     ora    lcurfl+2    ;[87]
  15835.     beq    sapar9        ;[87] yes
  15836.     lda    #'1        ;[87] len of file
  15837.     sta    (kerbf1),y    ;[87]
  15838.     iny            ;[87]
  15839.     lda    lcurfl+2    ;[87]
  15840.     pha            ;[87]
  15841.     lda    lcurfl+1    ;[87]
  15842.     pha            ;[87]
  15843.     lda    lcurfl        ;[87]
  15844.     pha            ;[87]
  15845.     tya            ;[87]
  15846.     clc            ;[87] now for place to store it
  15847.     adc    kerbf1        ;[87] lsb
  15848.     sta    kwrk01        ;[87]
  15849.     lda    kerbf1+1    ;[87] msb
  15850.     adc    #0        ;[87]
  15851.     pha            ;[87] msb of where to store it
  15852.     lda    kwrk01        ;[87]
  15853.     pha            ;[87] lsb
  15854.     sty    kwrk01        ;[87] place for len
  15855.     jsr    bn2asc        ;[87] convert lcurfl to ascii
  15856.     lda    kwrk01        ;[87] place of bin len from bn2asc
  15857.     tay            ;[87]
  15858.     clc            ;[87]
  15859.     adc    (kerbf1),y    ;[87] len of ascii number
  15860.     tax            ;[87]
  15861.     inx            ;[87] one more for the len
  15862.     clc            ;[87]
  15863.     lda    #32        ;[87] tochar the len
  15864.     adc    (kerbf1),y    ;[87]
  15865.     sta    (kerbf1),y    ;[87]
  15866.     txa            ;[87]
  15867.     tay            ;[87]
  15868. sapar9    sty    pdlen        ;[87]
  15869.     rts            ;[87]
  15870.  
  15871. satfll    sty    kwrk02        ;[87]
  15872.     dey            ;[87] len field not counted
  15873.     tya            ;[87]
  15874.     sec            ;[87]
  15875.     sbc    kwrk01        ;[87]
  15876.     clc            ;[87]
  15877.     adc    #32        ;[87] tochar
  15878.     ldy    kwrk01        ;[87] place to put len
  15879.     sta    (kerbf1),y    ;[87]
  15880.     ldy    kwrk02        ;[87]
  15881.     rts            ;[87]
  15882.     
  15883. ;
  15884. ;     Rpar - This routine sets operational parameters for the other kermit
  15885. ;     from the init packet data buffer.
  15886. ;
  15887. ;         Input:     @Kerbf1     - Operational parameters
  15888. ;
  15889. ;         Output:     Operational parameters set
  15890. ;
  15891. ;         Registers destroyed:     A,Y
  15892. ;
  15893.  
  15894. rpar:    ldy   #$00          ; Start the data index at 0!
  15895.     sty    ebqmod        ;[75] start without 8 bit quoting
  15896.     sty    exfg        ;[75] turn off extended length packet
  15897.     sty    flatr        ;[87] start out wid no file attr
  15898.     lda   (kerbf1),y      ; Start grabbing data from packet buffer
  15899.     sec          ; Uncharacterize it
  15900.     sbc   #$20          ;         ...
  15901.     sta   spsiz          ; That must be the packet size of other Kermit
  15902. ;[75]    iny          ; Increment the buffer index
  15903. ;[75]    lda   (kerbf1),y      ; Get the next item
  15904. ;[75]    sec          ;         ...
  15905. ;[75]    sbc   #$20          ; Uncharacterize that
  15906.     jsr    despa        ;[75] get ch and unchar
  15907.     sta   stime          ; Other Kermit's timeout interval
  15908. ;[75]    iny          ; Up the index once again
  15909. ;[75]    lda   (kerbf1),y      ; Get next char
  15910. ;[75]    sec          ;         ...
  15911. ;[75]    sbc   #$20          ; Restore to original value
  15912.     jsr    despa        ;[75] get ch and unchar
  15913.     sta   spad          ; This is the amount of padding he wants
  15914.     iny          ; Advnace index
  15915.     lda   (kerbf1),y      ; Next item
  15916.     eor   #$40          ; Uncontrolify this one
  15917.     sta   spadch          ; That is padding character for other Kermit
  15918.     iny          ; Advance index
  15919.     lda   (kerbf1),y      ; Get next item of data
  15920. ;    cmp   #$00          ; If it is equal to zero
  15921.     beq   rpar2          ; Use <cr> as a default
  15922.     jmp   rpar3          ;         ...
  15923. rpar2:    lda   #cr          ; Get value of <cr>
  15924.     sta   seol          ; That will be the eol character
  15925.     jmp   rpar4          ; Continue
  15926. rpar3:    sec          ;         ...
  15927.     sbc   #$20          ; unchar the character
  15928.     sta   seol          ; That is the eol character other Kermit wants
  15929. rpar4:    iny          ; Advance the buffer index
  15930.     lda   (kerbf1),y      ; Get quoting character
  15931. ;    cmp   #$00          ; If that is zero
  15932.     beq   rpar5          ; Use # sign as the qoute character
  15933.     jmp   rpar6          ; Otherwise, give him what he wants
  15934. rpar5:    lda   #'#          ; Load # sign
  15935. rpar6:    sta   squote          ; Make that the other Kermit's quote character
  15936.     iny          ; Advance the index
  15937.     lda   pdlen          ;[11] Check the data length to see
  15938. ;[75]    cmp   #$09          ;[11]     if the 8-bit quote is there
  15939.     cmp   #7          ;[75]  if the 8-bit quote is there
  15940. ;[75]    bmi   rpar8          ;[52][11] If not, return
  15941.     bcc   rpar8          ;[75] pdlen may be - [52][11] If not, return
  15942.     lda   (kerbf1),y      ;[11] Fetch the 8-bit quote
  15943.     cmp   #'N          ;[11] Is it 'N'
  15944.     beq   rpar8          ;[15][11] Yes, leave.(he doesn't support 8-bit)
  15945.     cmp   #'Y          ;[11] Does he support 8-bit quoting?
  15946. ;[72]    beq   rpar8          ;[15][11] If so, leave. (we don't need it.)
  15947. ;[75]    beq   rpar72          ;[72][15][11] If so, leave. (we don't need it.)
  15948.     bne    rpard        ;[75]
  15949. ;    lda    ascii        ;[82]
  15950. ;    bne    rpar9        ;[82] this is 7bit text
  15951.     lda    dosflg        ;[82]
  15952.     bne    rpar67        ;[82] prodos text uses all 8 bits
  15953.     lda    filmod        ;[75] is this text file?
  15954.     beq    rpar9        ;[75] yes turn off ebq
  15955. rpar67                ;[82]
  15956.     lda    parity        ;[75] do we really need it?
  15957.     bne    rpar72        ;[75] yes 
  15958.     beq    rpar9        ;[75] no par so 8 bit not req
  15959. rpard                ;[75]
  15960.     cmp   #'!          ;[11] Now, it should be a real character
  15961.     bmi   rpar8          ;[52][11]     Check if it is in range.
  15962.     cmp   #'?          ;[11]     If so, we set the 8-bit quote char
  15963.     bmi   rpar7          ;[11]     and set 8-bit quoting on.
  15964.     cmp   #$60          ;[11]     If not, just leave.
  15965. ;[75]    bmi   rparrt          ;[11]         ...
  15966.     bmi   rpar8        ;[75]
  15967.     cmp   #del          ;[11]         ...
  15968. ;[75]    bpl   rpar8          ;[52][11]         ...
  15969.     beq   rpar8          ;[75]
  15970. rpar7:    sta   sebq          ;[11] Stuff the character here
  15971. rpar72    lda   #on          ;[11] Set 8-bit quoting on
  15972.     sta   ebqmod          ;[11]         ...
  15973. ;[75]    rts          ;[15] Return
  15974.     bne    rpar9        ;[75] next field
  15975. ;[72]rpar8:    sta   sebq          ;[15] Make sure this parm is stored
  15976. rpar8:                ;[75]
  15977. ;    lda    ascii        ;[82]
  15978. ;    bne    rpar9        ;[82] this is 7bit text
  15979.     lda    dosflg        ;[82]
  15980.     bne    rpar87        ;[82] prodos text uses all 8 bits
  15981.     lda    filmod        ;[75] is this text file?
  15982.     beq    rpar9        ;[75] yes dont need 8bq
  15983. rpar87                ;[82]
  15984.     lda    parity        ;[75] do we really need it?
  15985.     beq    rpar9        ;[75] no par so 8 bit not req
  15986.     tya            ;[75] save y
  15987.     pha            ;[75]
  15988.     jsr    u2s8b        ;[75] problems unable to send 8 bits
  15989.     pla            ;[75] restore y
  15990.     tay            ;[75]
  15991. ;[75]    lda   #off          ;[15]     AND that 8-bit quoting is off.
  15992. ;[75]    sta   ebqmod          ;[15]         ...
  15993. rpar9    lda    pdlen        ;[75]
  15994.     cmp    #10        ;[75] is capacity byte there?
  15995.     bcc    rparrt        ;[75] no, pdlen may be -
  15996.     iny        ;[75]
  15997.     iny        ;[75]
  15998.     iny        ;[75] position to cap byte
  15999.     lda    (kerbf1),y        ;[75]
  16000.     pha        ;[87]
  16001.     and    #8    ;[87] file attributes?
  16002.     sta    flatr    ;[87] just non zero
  16003.     pla        ;[87]
  16004.     and    #2    ;[75] is xlength there?
  16005.     beq    rparrt    ;[75] no
  16006.     lda    rpsiz        ;[75] should we use extended len
  16007. ;[84]    cmp    #95        ;[75] > 94 means yes
  16008.     cmp    #dpakln+1    ;[84] > 94 means yes
  16009.     bcc    rparrt        ;[75] no
  16010.     sta    exfg    ;[75] turn on extended length
  16011. rpara    lda    (kerbf1),y        ;[75]
  16012.     iny        ;[75] ready for next byte
  16013.     and    #1    ;[75] is there more cap bytes?
  16014.     bne    rpara    ;[75] yes
  16015.     tya        ;[75] see if xl1 & xl2 are there
  16016.     clc        ;[75]
  16017.     adc    #2    ;[75]
  16018.     cmp    pdlen    ;[75] well?
  16019.     bcs    tobig    ;[75] not there and default of 500 is too big
  16020.     lda    #0    ;[75] ready for the mult
  16021.     pha        ;[75] msb
  16022.     pha        ;[87]
  16023.     jsr    despa    ;[75] get lsb
  16024.     pha        ;[75]
  16025.     lda    #0            ;[75]
  16026.     pha        ;[75]
  16027.     pha        ;[87]
  16028. ;[84]    lda    #95    ;[75] its 95 times
  16029.     lda    #dpakln+1    ;[84] its 95 times
  16030.     pha        ;[75]
  16031. ;[87]    jsr    mul16    ;[75] mult 2 16 bit quantities
  16032.     jsr    mul24    ;[87][75] mult 2 16 bit quantities
  16033.     pla        ;[75] get ans
  16034.     sta    spsiz    ;[75] this is senders packet size
  16035.     pla        ;[75] now for msb
  16036.     beq    rparc    ;[75] it may be small enough
  16037.     pla        ;[87] msb of prod
  16038. tobig    lda    #maxxdl    ;[75] set our max
  16039.     sta    spsiz        ;[75]
  16040.     jmp    rparrt    ;[75] thats all
  16041. ;[87]rparc    jsr    despa        ;[75]
  16042. rparc    pla        ;[87] msb of prod
  16043.     jsr    despa        ;[87]
  16044.     clc        ;[75]
  16045.     adc    spsiz        ;[75]
  16046.     sta    spsiz        ;[75]
  16047.     bcs    tobig        ;[75]
  16048.     lda    #maxxdl        ;[75]
  16049.     cmp    spsiz    ;[75] is it too big?
  16050.     bcs    rparrt    ;[75] no
  16051.     sta    spsiz    ;[75] yes use ours
  16052. rparrt: rts          ;[11] Return
  16053.  
  16054. despa    iny          ;[75] Increment the buffer index
  16055.     lda   (kerbf1),y      ;[75] Get the next item
  16056.     sec          ;[75]         ...
  16057.     sbc   #$20          ;[75] Uncharacterize that
  16058.     rts        ;[75]
  16059. ;
  16060. ;     Nakit - sends a standard NAK packet out to the other Kermit.
  16061. ;
  16062. ;         Input:     NONE
  16063. ;
  16064. ;         Output:     NONE
  16065. ;
  16066.  
  16067. nakit:    lda   #$00          ; Zero the packet data length
  16068.     sta   pdlen          ;         ...
  16069.     lda   #'N          ; Set up a nak packet type
  16070.     sta   ptype          ;         ...
  16071. ;[81]    jsr   spak          ; Now, send it
  16072. ;[81]    rts          ; Return
  16073.     jmp   spak          ;[81] Now, send it & return
  16074.  
  16075.  
  16076.  
  16077. .SBTTL    Message text
  16078.  
  16079.     .ifeq <ftcom-ftappl>
  16080. versio: nasc  <NOSC/SI/CU-APPLE ][ KERMIT-65 VER 3.87> 1  
  16081.     .endc
  16082. .SBTTL    Command tables and help text
  16083.     .nlst
  16084. modmco    nasc    <CONOOKRIER> 0    ;[78] hayes responses 1st 2 chs
  16085. modmwc    .blkb    5        ;[78] 1 for each pair of modmco
  16086. ;[85]lmodmc    =    .-modmco        ;[78] length of above
  16087. lmodmc    =    .-modmwc        ;[85] length of modmwc
  16088. ;[85]    dials    nasc    <PRESS 0-9 MODEM CMD, M  MORE OR Q  QUIT> 1    ;[78]
  16089. dials    .byte    si+$80        ;[85] start hilite
  16090.     nasc    <PRESS 0-9 MODEM CMD, M-MORE OR Q-QUIT> 0    ;[85]
  16091.     .byte    so+$80,0    ;[85] stop hilite & string
  16092. morem    .byte    si+$80        ;[85] start hilite
  16093.     nasc    <M-MORE, Q-QUIT OR T-TOP> 0        ;[85]
  16094.     .byte    so+$80,0    ;[85] stop hilite and string
  16095. ;dialf    nasc    <CONNECTION FAILED, TRY AGAIN> 1        ;[78]
  16096. dialnm    nasc    <KERMIT.MODEM> 1        ;[78]
  16097. dialms    nasc    <READING MODEM FILE > 1        ;[78]
  16098. ;[83]kerinm    nasc    <INITIALIZING BY READING FILE > 1    ;[78]
  16099. kerinm    nasc    <READING COMMANDS> 1    ;[78]
  16100. hlpfn    nasc    <KERMIT.HELP> 0        ;[85]
  16101. hlpfne                    ;[85]
  16102. kerinn    nasc    <KERMIT.INIT> 1    ;[78] kermit initialization file - 1 of 2
  16103. kercmd: .byte 27     ;[87][85][83][81][78][62][56][14]Table len - 2 of 2
  16104.     .byte $03          ;[14] Keyword length
  16105.     .asciz /BYE/          ;[14] Keyword terminated with a null
  16106. ;[82]    .byte $1E,$1E          ;[14] Two bytes of data
  16107.     .word    bye    ;[82]
  16108. catsz    .byte 7            ;[78] add the catalog command
  16109.     .asciz /CATALOG/    ;[78]
  16110. ;[82]    .byte kercat-kermtb,kercat-kermtb    ;[78]
  16111.     .word    catlog    ;[82]
  16112.     .byte    2    ;[87] unix current directory
  16113.     .asciz /CD/    ;[87]
  16114.     .word    stcd    ;[87]
  16115.     .byte $07
  16116.     .asciz /CONNECT/
  16117. ;[82]    .byte $00,$00
  16118.     .word    telnet    ;[82]
  16119. delsz    .byte 6            ;[78] add the file delete command
  16120.     .asciz /DELETE/    ;[78]
  16121. ;[82]    .byte kerdlf-kermtb,kerdlf-kermtb    ;[78]
  16122.     .word    deletf    ;[82]
  16123.     .byte $04
  16124.     .asciz /EXIT/
  16125. ;[82]    .byte $03,$03
  16126.     .word    exit    ;[82]
  16127.     .byte $06          ;[14] New command
  16128.     .asciz /FINISH/      ;[14]
  16129. ;[82]    .byte $21,$21          ;[14]
  16130.     .word    finish    ;[82]
  16131.     .byte $03          ;[14] New commnad
  16132.     .asciz /GET/          ;[14]
  16133. ;[82]    .byte $24,$24          ;[14]
  16134.     .word    getfrs    ;[82]
  16135.     .byte $04
  16136.     .asciz /HELP/
  16137. ;[82]    .byte $06,$06
  16138.     .word    help    ;[82]
  16139. locksz    .byte 4        ;[86] add the lock file-name cmd
  16140.     .asciz    /LOCK/    ;[86]
  16141.     .word    lock    ;[86]
  16142. shin28
  16143.     .byte $03         
  16144.     .asciz /LOG/
  16145. ;[82]    .byte $09,$09
  16146.     .word    log    ;[82]
  16147.     .byte    2    ;[87] how about a unix cmd
  16148.     .asciz /LS/    ;[87]
  16149.     .word    catlog    ;[87]
  16150.     .byte 5            ;[78] add the modem command
  16151.     .asciz /MODEM/    ;[78]
  16152. ;[82]    .byte kerdil-kermtb,kerdil-kermtb    ;[78]
  16153.     .word    modem    ;[82]
  16154. ;    .byte $04    ;[87] read a text file to screen
  16155. ;    .asciz /MORE/    ;[87]
  16156. ;    .word    help    ;[87] use help rtn
  16157. ;    .byte    2        ;[87] add the rename file-name cmd
  16158. ;    .asciz    /MV/    ;[87]
  16159. ;    .word    rename        ;[87]
  16160.     .byte    3    ;[87] unix show prefix
  16161.     .asciz /PWD/    ;[87]
  16162.     .word    shpwd    ;[87]
  16163.     .byte $04
  16164.     .asciz /QUIT/
  16165. ;[82]    .byte $0C,$0C
  16166.     .word    exit    ;[82]
  16167. ;    .word    quit    ;[87]
  16168.     .byte $07
  16169.     .asciz /RECEIVE/
  16170. ;[82]    .byte $0F,$0F
  16171.     .word    receve    ;[82]
  16172.     .byte 6            ;[81] add the remote command
  16173.     .asciz /REMOTE/    ;[81]
  16174. ;[82]    .byte kerrmt-kermtb,kerrmt-kermtb    ;[81]
  16175.     .word    remote    ;[82]
  16176. renmsz    .byte    6        ;[86] add the rename file-name cmd
  16177.     .asciz    /RENAME/    ;[86]
  16178.     .word    rename        ;[86]
  16179.     .byte    2    ;[87] unix
  16180.     .asciz /RM/    ;[87]
  16181.     .word    deletf    ;[87]
  16182.     .byte $04
  16183.     .asciz /SEND/
  16184. ;[82]    .byte $12,$12
  16185.     .word    send    ;[82]
  16186.     .byte    $6        ;[62] server mode
  16187.     .asciz    /SERVER/    ;[62]
  16188. ;[82]    .byte    $27,$27        ;[62]
  16189.     .word    server    ;[82]
  16190.     .byte $03
  16191.     .asciz /SET/
  16192. ;[82]    .byte $15,$15
  16193.     .word    setcom    ;[82]
  16194.     .byte $04
  16195.     .asciz /SHOW/
  16196. ;[82]    .byte $18,$18
  16197.     .word    show    ;[82]
  16198.     .byte $06
  16199.     .asciz /STATUS/
  16200. ;[82]    .byte $1B,$1B
  16201.     .word    status    ;[82]
  16202.     .byte    4    ;[83]
  16203.     .asciz /TAKE/    ;[83]
  16204.     .word    take    ;[83]
  16205.     .byte $04    ;[85] read a text file to screen
  16206.     .asciz /TYPE/    ;[85]
  16207.     .word    help    ;[85] use help rtn
  16208. unlksz    .byte    6        ;[86] add the unlock file-name cmd
  16209.     .asciz    /UNLOCK/    ;[86]
  16210.     .word    unlock        ;[86]
  16211. remcmd: .byte    1    ;[81] remote subcommands
  16212.     .byte    6    ;[81] remote kermit command
  16213.     .asciz /KERMIT/    ;[81]
  16214.     .byte remker-remcmb,remker-remcmb    ;[81] offset into jump table
  16215. setcmd: .byte 24      ;[35] Edit 12, 21, 35, 40 46 ,47,65,68,72,73,83,85,87
  16216. ;                          new commands
  16217. shin2f                ;[87]
  16218.     .byte 16              ;[81] Add the 'SET KEYPAD-APP...' command.
  16219.     .asciz /APPLICATION-MODE/          ;[81]
  16220. ;[82]    .byte setcka-setcmb,setcka-setcmb    ;[81]
  16221.     .word    stkpa    ;[82]
  16222. shin25            ;[87]
  16223.     .byte     4      ;[47] baud rate
  16224.     .asciz /BAUD/      ;[47]
  16225. ;[65]    .byte $30,$30      ;[47] offset into jump table
  16226. ;[82]    .byte setcba-setcmb,setcba-setcmb    ;[65] offset into jump table
  16227.     .word    stbaud    ;[82]
  16228. setcs    .byte    12            ;[87] Add the 'SET CLEAR-SCREEN ...
  16229.     .asciz /CLEAR-SCREEN/        ;[87]
  16230.     .word    stcs            ;[87]
  16231. shin2g                ;[87]
  16232.     .byte    17              ;[80] Add the 'SET CURSOR ...' command.
  16233.     .asciz /CURSOR-KEYS-VT100/          ;[80]
  16234. ;[82]    .byte setckc-setcmb,setckc-setcmb    ;[80]
  16235.     .word    stcko    ;[82]
  16236. shin00                ;[87]
  16237.     .byte $09
  16238.     .asciz /DEBUGGING/
  16239. ;[68]    .byte $18,$18
  16240. ;[82]    .byte setdb-setcmb,setdb-setcmb    ;[68] offset into jump table
  16241.     .word    stdb    ;[82]
  16242. shin22            ;[87]
  16243.     .byte $0C          ;[40] Add the 'SET DEFAULT-DISK' command
  16244.     .asciz /DEFAULT-DISK/      ;[40]         ...
  16245. ;[65]    .byte $2a,$2a          ;[40]         ...
  16246. ;[82]    .byte setcdd-setcmb,setcdd-setcmb    ;[65]         ...
  16247.     .word    stddsk    ;[82]
  16248. shin24            ;[87]
  16249.     .byte $07          ;[46] Add the 'SET DISPLAY' command
  16250.     .asciz /DISPLAY/      ;[46]         ...
  16251. ;[65]    .byte $2d,$2d          ;[46]         ...
  16252. ;[82]    .byte setcds-setcmb,setcds-setcmb    ;[65]         ...
  16253.     .word    stdspy    ;[82]
  16254. ;[72]    .byte $11
  16255. ;[72]    .asciz /EIGHT-BIT-QUOTING/
  16256. ;[68]    .byte $15,$15
  16257. ;[72]    .byte seteb-setcmb,seteb-setcmb    ;[68] offset into jump table
  16258. shin06                ;[87]
  16259.     .byte $06
  16260.     .asciz /ESCAPE/
  16261. ;[82]    .byte $00,$00
  16262.     .word    stesc    ;[82]
  16263. ;[65]    .byte $0e
  16264. ;[65]    .asciz /FILE-BYTE-SIZE/
  16265. ;[65]    .byte $1e,$1e
  16266. shin16                ;[87]
  16267.     .byte $09
  16268.     .asciz /FILE-TYPE/
  16269. ;[68]    .byte $1b,$1b
  16270. ;[82]    .byte setmod-setcmb,setmod-setcmb    ;[68] offset into jump table
  16271.     .word    stmod    ;[82]
  16272. shin05                ;[87]
  16273.     .byte $0C
  16274.     .asciz /FILE-WARNING/
  16275. ;[68]    .byte $12,$12
  16276. ;[82]    .byte setfw-setcmb,setfw-setcmb    ;[68] offset into jump table
  16277.     .word    stfw    ;[82]
  16278. shin27            ;[87]
  16279.     .byte 4                ;[57] flow control 
  16280.     .asciz /FLOW/               ;[57]
  16281. ;[65]    .byte $36,$36              ;[57]
  16282. ;[82]    .byte setcfl-setcmb,setcfl-setcmb    ;[65]
  16283.     .word    stflow    ;[82]
  16284. ;[68]    .byte $03              ;[21] ibm-mode switch
  16285. ;[68]    .asciz /IBM/              ;[21]
  16286. ;[68]    .byte $03,$03              ;[21]
  16287. shin21                ;[87]
  16288.     .byte $08              ;[35] Add the 'SET KEYBOARD' command.
  16289.     .asciz /KEYBOARD/          ;[35]
  16290. ;[65]    .byte $27,$27              ;[35]
  16291. ;[82]    .byte setckb-setcmb,setckb-setcmb    ;[65]
  16292.     .word    stkbd    ;[82]
  16293. ;[87]    .byte 6              ;[80] Add the 'SET KEYPAD' command.
  16294. ;[87]    .asciz /KEYPAD/          ;[80]
  16295. ;[82]    .byte setckp-setcmb,setckp-setcmb    ;[80]
  16296. ;[87]    .word    stkp    ;[82]
  16297. ;    .byte 23              ;[80] Add the 'SET KEYPAD-APP...' command.
  16298. ;    .asciz /KEYPAD-APPLICATION-MODE/          ;[80]
  16299. ;    .byte setcka-setcmb,setcka-setcmb    ;[80]
  16300. shin03                ;[87]
  16301.     .byte $0A
  16302.     .asciz /LOCAL-ECHO/
  16303. ;[68]    .byte $06,$06
  16304. ;[82]    .byte setle-setcmb,setle-setcmb    ;[68] offset into jump table
  16305.     .word    stle    ;[82]
  16306. shin20            ;[87]
  16307.     .byte $06            ;[86] Add the 'SET PARITY' option
  16308.     .asciz /PARITY/              ;[86]
  16309.     .word    stpari            ;[86]
  16310.     .byte $06              ;[59] Add the 'SET prefix' option
  16311.     .asciz /PREFIX/          ;[59]
  16312. ;[65]    .byte $39,$39              ;[59]
  16313. ;[82]    .byte setcpf-setcmb,setcpf-setcmb    ;[65]
  16314.     .word    stpre    ;[82]
  16315. ;[86]    .byte $06              ;[21] Add the 'SET PARITY' option
  16316. ;[86]    .asciz /PARITY/          ;[21]
  16317. ;[86];[65]    .byte $24,$24              ;[21]
  16318. ;[86];[82]    .byte setcpa-setcmb,setcpa-setcmb    ;[65]
  16319. ;[86]    .word    stpari    ;[82]
  16320. shin26            ;[87]
  16321.     .byte $07              ;[55] Add the 'SET PRINTER' option
  16322.     .asciz /PRINTER/          ;[55]
  16323. ;[65]    .byte $33,$33              ;[55]
  16324. ;[82]    .byte setcpr-setcmb,setcpr-setcmb    ;[65]
  16325.     .word    stprn    ;[82]
  16326. shin2i                ;[87]
  16327.     .byte 8             ;[83] Add the 'SET protocol' option
  16328.     .asciz /PROTOCOL/     ;[83]
  16329.     .word    stprt        ;[83]
  16330.     .byte $07         
  16331.     .asciz /RECEIVE/
  16332. ;[68]    .byte $9,$9     
  16333. ;[82]    .byte setrc-setcmb,setrc-setcmb    ;[68] offset into jump table
  16334.     .word    strc    ;[82]
  16335.     .byte $04
  16336.     .asciz /SEND/
  16337. ;[68]    .byte $0C,$0C
  16338. ;[82]    .byte setsn-setcmb,setsn-setcmb    ;[68] offset into jump table
  16339.     .word    stsn    ;[82]
  16340. shin18            ;[87]
  16341.     .byte $04          ;[12] Add the 'SET SLOT' option
  16342.     .asciz /SLOT/          ;[12]         ...
  16343. ;[65]    .byte $21,$21          ;[12]         ...
  16344. ;[82]    .byte setcsl-setcmb,setcsl-setcmb    ;[65]         ...
  16345.     .word    stslot    ;[82]
  16346. shin2c            ;[87]
  16347.     .byte    15        ;[73] swap bs & del keypress
  16348.     .asciz /SWAPKEYS-BS&DEL/    ;[73]
  16349. ;[82]    .byte setcsw-setcmb,setcsw-setcmb    ;[73]
  16350.     .word    stswp    ;[82]
  16351. shin01                ;[87]
  16352.     .byte 8                ;[76] add the 'set terminal' option
  16353.     .asciz /TERMINAL/        ;[76]
  16354. ;[82]    .byte setvt-setcmb,setvt-setcmb    ;[65] offset into set table
  16355.     .word    stvt    ;[82]
  16356. shin2b                ;[87]
  16357.     .byte $05          ;[64] Add the 'SET timer' option
  16358.     .asciz /TIMER/          ;[64]
  16359. ;[65]    .byte $3C,$3C          ;[64] offset into set table
  16360. ;[82]    .byte setctm-setcmb,setctm-setcmb    ;[65] offset into set table
  16361.     .word    sttmr    ;[82]
  16362. shin2k            ;[87]
  16363.     .byte    6        ;[85] Add the 'SET timing' constant option
  16364.     .asciz /TIMING/        ;[85]
  16365.     .word    sttmct        ;[85]
  16366. ;[76]    .byte $0E
  16367. ;[76]    .asciz /VT52-EMULATION/
  16368. ;[76];[68]    .byte $0F,$0F
  16369. ;[76]    .byte setvt-setcmb,setvt-setcmb    ;[65] offset into set table
  16370. shocmd: .byte 28  ;[40][35] Edit 12, 21, 35, 40,46,47,65,68,72,73,83,85,87
  16371. ;                          new commands
  16372.     .byte $03
  16373. shodef: .asciz /ALL/          ;[13] Default option for 'SHOW' command
  16374. ;[82]    .byte $00,$00
  16375.     .word    shall    ;[82]
  16376.     .byte 16        ;[87] Add 'SHOW KEYPAD-APP...' command.
  16377.     .asciz /APPLICATION-MODE/    ;[87]
  16378.     .word    shkp            ;[87]
  16379.     .byte     4      ;[47]
  16380.     .asciz /BAUD/      ;[47]
  16381. ;[65]    .byte $a2,$a2      ;[47] ofset into jmp table
  16382. ;[82]    .byte shocud-shocmb,shocud-shocmb    ;[65] ofset into jmp table
  16383.     .word    shbaud    ;[82]
  16384.     .byte    12            ;[87] Add the 'SHOW CLEAR-SCREEN ...
  16385.     .asciz /CLEAR-SCREEN/        ;[87]
  16386.     .word    shcs            ;[87]
  16387.     .byte    17          ;[80] Add 'SHOW CURSOR-KEY...' command.
  16388.     .asciz /CURSOR-KEYS-VT100/      ;[80]
  16389. ;[82]    .byte shokco-shocmb,shokco-shocmb    ;[80]
  16390.     .word    shcko    ;[82]
  16391.     .byte $09
  16392.     .asciz /DEBUGGING/
  16393. ;[68]    .byte $51,$51
  16394. ;[82]    .byte shodb-shocmb,shodb-shocmb    ;[68] ofset into jmp table
  16395.     .word    shdb    ;[82]
  16396.     .byte $0C          ;[40] Add the 'SHOW DEFAULT-DISK' option
  16397.     .asciz /DEFAULT-DISK/      ;[40]         ...
  16398. ;[65]    .byte $90,$90          ;[40]         ...
  16399. ;[82]    .byte shocsk-shocmb,shocsk-shocmb    [65]         ...
  16400.     .word    shddsk    ;[82]
  16401. shin19            ;[87]
  16402.     .byte $0D          ;[12] Add the 'SHOW DEVICE-DRIVER' option
  16403.     .asciz /DEVICE-DRIVER/      ;[12]         ...
  16404. ;[65]    .byte $75,$75          ;[12]         ...
  16405. ;[82]    .byte shocdr-shocmb,shocdr-shocmb    ;[65]         ...
  16406.     .word    shddr    ;[82]
  16407.     .byte $07          ;[46] Add the 'SHOW DISPLAY' command
  16408.     .asciz /DISPLAY/      ;[46]         ...
  16409. ;[65]    .byte $99,$99          ;[46]         ...
  16410. ;[82]    .byte shocpy-shocmb,shocpy-shocmb    ;[65]         ...
  16411.     .word    shdspy    ;[82]
  16412. ;[72]    .byte $11
  16413. ;[72]    .asciz /EIGHT-BIT-QUOTING/
  16414. ;[68]    .byte $48,$48
  16415. ;[72]    .byte shoeb-shocmb,shoeb-shocmb    ;[68] ofset into jmp table
  16416.     .byte $06
  16417.     .asciz /ESCAPE/
  16418. ;[68]    .byte $09,$09
  16419. ;[82]    .byte shoesc-shocmb,shoesc-shocmb    ;[68] ofset into jmp table
  16420.     .word    shesc    ;[82]
  16421. ;[65]    .byte $0e
  16422. ;[65]    .asciz /FILE-BYTE-SIZE/
  16423. ;[65]    .byte $63,$63
  16424.     .byte $09
  16425.     .asciz /FILE-TYPE/
  16426. ;[68]    .byte $5a,$5a
  16427. ;[82]    .byte shomod-shocmb,shomod-shocmb    ;[68] ofset into jmp table
  16428.     .word    shmod    ;[82]
  16429.     .byte $0C
  16430.     .asciz /FILE-WARNING/
  16431. ;[68]    .byte $3f,$3f
  16432. ;[82]    .byte shofw-shocmb,shofw-shocmb    ;[68] ofset into jmp table
  16433.     .word    shfw    ;[82]
  16434.     .byte 4            ;[57] flow control
  16435.     .asciz /FLOW/           ;[57]
  16436. ;[65]    .byte $b4,$b4          ;[57]
  16437. ;[82]    .byte shocow-shocmb,shocow-shocmb      ;[65]
  16438.     .word    shflow    ;[82]
  16439. ;[68]    .byte $03          ;[21] Add Ibm mode option
  16440. ;[68]    .asciz /IBM/          ;[21]
  16441. ;[68]    .byte $12,$12          ;[21]
  16442.     .byte $08          ;[35] Add 'SHOW KEYBOARD' command.
  16443.     .asciz /KEYBOARD/      ;[35]
  16444. ;[65]    .byte $87,$87          ;[35]
  16445. ;[82]    .byte shocbd-shocmb,shocbd-shocmb    ;[65]
  16446.     .word    shkbd    ;[82]
  16447. ;[87]    .byte 6          ;[80] Add 'SHOW KEYPAD' command.
  16448. ;[87]    .asciz /KEYPAD/      ;[80]
  16449. ;[82]    .byte shokp-shocmb,shokp-shocmb    ;[80]
  16450. ;[87]    .word    shkp    ;[82]
  16451. ;    .byte 23          ;[80] Add 'SHOW KEYPAD-APP...' command.
  16452. ;    .asciz /KEYPAD-APPLICATION-MODE/      ;[80]
  16453. ;    .byte shokpa-shocmb,shokpa-shocmb    ;[80]
  16454.     .byte $0A
  16455.     .asciz /LOCAL-ECHO/
  16456. ;[68]    .byte $1b,$1b
  16457. ;[82]    .byte shole-shocmb,shole-shocmb    ;[68] ofset into jmp table
  16458.     .word    shle    ;[82]
  16459.     .byte $3        ;[56]
  16460.     .asciz /LOG/        ;[56]
  16461. ;[65]    .byte $bd,$bd        ;[56]
  16462. ;[82]    .byte shocog-shocmb,shocog-shocmb    ;[65]
  16463.     .word    shlog    ;[82]
  16464.     .byte $06          ;[21] Add 'SHOW PARITY' command
  16465.     .asciz /PARITY/      ;[21]
  16466. ;[65]    .byte $7e,$7e          ;[21]
  16467. ;[82]    .byte shocri-shocmb,shocri-shocmb    ;[65]
  16468.     .word    shpari    ;[82]
  16469. prefsz    .byte $06          ;[59] Add the 'SHOW DEFAULT-DISK' option
  16470. shin2a    =    prefsz        ;[87]
  16471.     .asciz /PREFIX/          ;[59] prefix same as default-disk
  16472. ;[68]    .byte $90,$90          ;[59]         ...
  16473. ;[82]    .byte shocsk-shocmb,shocsk-shocmb    ;[68] ofset into jmp table
  16474.     .word    shddsk    ;[82]
  16475.     .byte $07              ;[55] Add the 'SHOW PRINTER' option
  16476.     .asciz /PRINTER/          ;[55]
  16477. ;[65]    .byte $ab,$ab              ;[55]
  16478. ;[82]    .byte shocrn-shocmb,shocrn-shocmb    ;[65]
  16479.     .word    shprn    ;[82]
  16480.     .byte 8              ;[83] Add the 'SHOW protocol' option
  16481.     .asciz /PROTOCOL/          ;[83]
  16482.     .word    shprt    ;[83]
  16483.     .byte $07
  16484.     .asciz /RECEIVE/
  16485. ;[68]    .byte $24,$24
  16486. ;[82]    .byte shorc-shocmb,shorc-shocmb    ;[68] ofset into jmp table
  16487.     .word    shrc    ;[82]
  16488.     .byte $04
  16489.     .asciz /SEND/
  16490. ;[68]    .byte $2d,$2d
  16491. ;[82]    .byte shosn-shocmb,shosn-shocmb    ;[68] ofset into jmp table
  16492.     .word    shsn    ;[82]
  16493.     .byte $04          ;[12] Add the 'SHOW SLOT' option
  16494.     .asciz /SLOT/          ;[12]         ...
  16495. ;[64]    .byte $6c,$6c          ;[12]         ...
  16496. ;[82]    .byte shocot-shocmb,shocot-shocmb    ;[65]         ...
  16497.     .word    shslot    ;[82]
  16498.     .byte    15        ;[73]
  16499.     .asciz /SWAPKEYS-BS&DEL/    ;[73]
  16500. ;[82]    .byte shoswp-shocmb,shoswp-shocmb    ;[73]
  16501.     .word    shswp    ;[82]
  16502.     .byte 8                ;[76]
  16503.     .asciz /TERMINAL/        ;[76]
  16504. ;[82]    .byte shovt-shocmb,shovt-shocmb    ;[76] ofset into jmp table
  16505.     .word    shvt    ;[82]
  16506.     .byte $5        ;[64]
  16507.     .asciz /TIMER/        ;[64]
  16508. ;[65]    .byte $c6,$c6        ;[64] offset into shocmb table
  16509. ;[82]    .byte shocmr-shocmb,shocmr-shocmb    ;[65] offset into shocmb table
  16510.     .word    shtmr    ;[82]
  16511.     .byte    6        ;[85]
  16512.     .asciz /TIMING/        ;[85]
  16513.     .word    shtmct        ;[85]
  16514.     .byte    7        ;[87]
  16515.     .asciz /VOLUMES/        ;[87]
  16516.     .word    shvols        ;[87]
  16517. ;[76]    .byte $0E
  16518. ;[76]    .asciz /VT52-EMULATION/
  16519. ;[76];[68]    .byte $36,$36
  16520. ;[76]    .byte shovt-shocmb,shovt-shocmb    ;[68] ofset into jmp table
  16521. ;[82]stscmd: .byte $07
  16522. stscmd: .byte 9            ;[84][82] number in table
  16523.     .byte    10        ;[84]
  16524.     .byte "CR<->CR,LF",0    ;[84]
  16525.     .byte    24,24        ;[84] offset for jump table
  16526. shin08            ;[87]
  16527. ;[87]    .byte $14
  16528. ;[87]    .asciz /EIGHT-BIT-QUOTE-CHAR/
  16529.     .byte 15        ;[87]
  16530.     .asciz /EIGHT-BIT-QUOTE/    ;[87]
  16531.     .byte $06,$06
  16532. shin09            ;[87]
  16533.     .byte $0B
  16534.     .asciz /END-OF-LINE/
  16535.     .byte $09,$09
  16536. shin10            ;[87]
  16537.     .byte $0D
  16538.     .asciz /PACKET-LENGTH/
  16539.     .byte $0C,$0C
  16540. shin11            ;[87]
  16541.     .byte $08
  16542.     .asciz /PAD-CHAR/
  16543.     .byte $00,$00
  16544. shin12                ;[87]
  16545.     .byte $07
  16546.     .asciz /PADDING/
  16547.     .byte $03,$03
  16548. shin13                ;[87]
  16549.     .byte $0A
  16550.     .asciz /QUOTE-CHAR/
  16551.     .byte $0F,$0F
  16552. shin2h                ;[87]
  16553.     .byte    15            ;[82] number of chs
  16554.     .asciz /START-OF-PACKET/    ;[82]
  16555.     .byte 21,21            ;[82] offset for jump table
  16556. shin14                ;[87]
  16557.     .byte $07
  16558.     .asciz /TIMEOUT/
  16559.     .byte $12,$12
  16560. ;[78]ftcmd:    .byte $04
  16561. ftcmd:    .byte $05
  16562. ;ftcmd:    .byte 6            ;[82]
  16563.     .byte $09
  16564.     .asciz /APPLESOFT/
  16565. ;[82]    .byte $02,$02
  16566.     .byte $02,0        ;[82] turn ascii off
  16567. ;    .byte 5            ;[82] define ascii as special text
  16568. ;    .asciz /ASCII/        ;[82]
  16569. ;    .byte 0,1        ;[82]
  16570.     .byte $06
  16571.     .asciz /BINARY/
  16572. ;[82]    .byte $04,$04
  16573.     .byte $04,0        ;[82]
  16574.     .byte $07
  16575.     .asciz /INTEGER/
  16576. ;[82]    .byte $01,$01
  16577.     .byte $01,0        ;[82]
  16578.     .byte 5            ;[78]
  16579.     .asciz /OTHER/        ;[78]
  16580. ;[82]    .byte $ff,$ff        ;[78]
  16581.     .byte $ff,0        ;[82]
  16582.     .byte $04
  16583. ftcdef: .asciz /TEXT/          ;[13] Default for File-type
  16584.     .byte $00,$00
  16585.  
  16586. prcmd:    .byte 2            ;[83]
  16587.     .byte 6            ;[83]
  16588. prcdef    .asciz /KERMIT/        ;[83]
  16589.     .byte 0,0        ;[83]
  16590.     .byte $06        ;[83]
  16591. prclen    =    .-prcdef    ;[83] allow for 1 trailing nul
  16592.     .asciz /XMODEM/        ;[83]
  16593.     .byte 0,1        ;[83]
  16594.  
  16595. baukey: .byte 13      ;[47] entries in this table
  16596.     
  16597.     .byte 3           ;[47] bytes long
  16598.     .asciz /110/      ;[47]
  16599.     .byte 3,3      ;[47] ssc entry for the baud
  16600.     .byte 4           ;[47] bytes long
  16601.     .asciz /1200/      ;[47]
  16602.     .byte 8,8      ;[47] ssc entry for the baud
  16603.     .byte 5           ;[47] bytes long
  16604.     .asciz /134.5/      ;[47]
  16605.     .byte 4,4      ;[47] ssc entry for the baud
  16606.     .byte 3           ;[47] 3 bytes long
  16607.     .asciz /150/      ;[47]
  16608.     .byte 5,5      ;[47] ssc entry for the baud
  16609.     .byte 4           ;[47] bytes long
  16610.     .asciz /1800/      ;[47]
  16611.     .byte 9,9      ;[47] ssc entry for the baud
  16612.     .byte 5           ;[47] bytes long
  16613.     .asciz /19200/      ;[47]
  16614.     .byte 15,15      ;[47] ssc entry for the baud
  16615.     .byte 4           ;[47] bytes long
  16616.     .asciz /2400/      ;[47]
  16617.     .byte 10,10      ;[47] ssc entry for the baud
  16618.     .byte 3           ;[47] bytes long
  16619.     .asciz /300/      ;[47]
  16620.     .byte 6,6      ;[47] ssc entry for the baud
  16621.     .byte 4           ;[47] bytes long
  16622.     .asciz /3600/      ;[47]
  16623.     .byte 11,11      ;[47] ssc entry for the baud
  16624.     .byte 4           ;[47] bytes long
  16625.     .asciz /4800/      ;[47]
  16626.     .byte 12,12      ;[47] ssc entry for the baud
  16627.     .byte 3           ;[47] bytes long
  16628.     .asciz /600/      ;[47]
  16629.     .byte 7,7      ;[47] ssc entry for the baud
  16630.     .byte 4           ;[47] bytes long
  16631.     .asciz /7200/      ;[47]
  16632.     .byte 13,13      ;[47] ssc entry for the baud
  16633.     .byte 4           ;[47] bytes long
  16634.     .asciz /9600/      ;[47]
  16635.     .byte 14,14      ;[47] ssc entry for the baud
  16636. parkey: .byte $05          ;[21] Length of this table is 5
  16637.     .byte $04          ;[21]
  16638.     .asciz /EVEN/          ;[21]
  16639.     .byte $04,$04          ;[21]
  16640.     .byte $04          ;[21]
  16641.     .asciz /MARK/          ;[21]
  16642.     .byte $02,$02          ;[21]
  16643.     .byte $04          ;[21]
  16644.     .asciz /NONE/          ;[21]
  16645.     .byte $00,$00          ;[21]
  16646.     .byte $03          ;[21]
  16647.     .asciz /ODD/          ;[21]
  16648.     .byte $03,$03          ;[21]
  16649.     .byte $05          ;[21]
  16650.     .asciz /SPACE/          ;[21]
  16651.     .byte $01,$01          ;[21]
  16652. debkey: .byte $03          ;[26] Length of this table is 3
  16653.     .byte $03          ;[26]
  16654.     .asciz /OFF/          ;[26]
  16655.     .byte $00,$00          ;[26]
  16656.     .byte $05          ;[26]
  16657.     .asciz /TERSE/          ;[26]
  16658.     .byte $01,$01          ;[26]
  16659.     .byte $07          ;[26]
  16660.     .asciz /VERBOSE/      ;[26]
  16661.     .byte $02,$02          ;[26]
  16662. ;[78]terkey    .byte 4            ;[76] 4 entries
  16663. terkey    .byte 5            ;[78] 4 entries
  16664.     .byte 7            ;[76] length is 7
  16665. terstr    .asciz /MONITOR/        ;[76] make sure all are same len 
  16666.     .byte    0,0        ;[76] no terminal emulation
  16667.     .byte 7            ;[76] length is 7
  16668. terlen    =    .-terstr    ;[76] length of string
  16669.     .asciz /NONE   /        ;[76] 
  16670.     .byte    0,1        ;[76] no terminal emulation
  16671.     .byte 7            ;[76]
  16672.     .asciz /VT100  /        ;[76]
  16673.     .byte    0,2        ;[76] vt100 flag will be 2
  16674.     .byte 7            ;[76]
  16675.     .asciz /VT52   /        ;[76]
  16676.     .byte    0,3        ;[76] vt52 flag will be 3
  16677.     .byte 7            ;[78]
  16678.     .asciz /WRAP   /        ;[78]
  16679.     .byte    0,4        ;[78] wraparound
  16680. kbkey:    .byte $02          ;[35] Entries in keyboard type table.
  16681.     .byte $02          ;[35]
  16682.     .asciz /2E/          ;[35] Apple 2E keyboard
  16683.     .byte $03,kbap2e      ;[35]
  16684.     .byte $02          ;[35]
  16685.     .asciz /2P/          ;[35] Apple 2/2+ keyboard
  16686.     .byte $00,kbap2p      ;[35]
  16687. ; These must be in alpa order      ;[49]
  16688. dspkey: .byte $03          ;[49] [46] display type entries
  16689.     .byte 12          ;[49] [46] 2e/2c full display, 40 columns
  16690.     .asciz /2E-40-COL   /      ;[46]
  16691.     .byte $03,ds40mx      ;[46]
  16692.     .byte 12          ;[49] [46] loosing, 2/2+ 40 columns
  16693.     .asciz /2P-40-COL   /      ;[46]
  16694.     .byte $0,ds40up      ;[46]
  16695.     .byte 12          ;[49] 2e/2c full display, 80 columns
  16696.     .asciz /80-COL-SLOT /      ;[49]
  16697.     .byte $6,ds80mx      ;[49]
  16698. ; These must be in alpa order      ;[55]
  16699. prnkey: .byte $03          ;[55]     printer entries
  16700.     .byte 3          ;[55]
  16701.     .asciz /OFF/      ;[55]
  16702.     .byte $0,0      ;[55]
  16703.     .byte 2          ;[55]
  16704.     .asciz /ON/      ;[55]
  16705.     .byte $03,0      ;[55]
  16706.     .byte 4          ;[55]
  16707. prnslm: .asciz /SLOT/     ;[55]
  16708.     .byte $6,0      ;[55]
  16709. flokey: .byte    3        ;[57]
  16710.     .byte    3        ;[57]
  16711.     .asciz    /OFF/        ;[57]
  16712.     .byte    0,0        ;[57]
  16713.     .byte    8        ;[57]
  16714. floxon: .asciz    /XON&XOFF/    ;[57]
  16715.     .byte    3,1        ;[57]
  16716.     .byte    5        ;[57]
  16717. flodly: .asciz    /DELAY/        ;[57]
  16718.     .byte    6,2        ;[57]
  16719. ;[65]fbskey: .byte $02
  16720. ;[65]    .byte $09
  16721. ;[65]    .asciz /EIGHT-BIT/
  16722. ;[65]    .byte $00,$00
  16723. ;[65]    .byte $09
  16724. ;[65]    .asciz /SEVEN-BIT/
  16725. ;[65]    .byte $01,$01
  16726. oncmd:    .byte $02
  16727.     .byte $02
  16728.     .asciz /ON/
  16729.     .byte $01,$01
  16730.     .byte $03
  16731.     .asciz /OFF/
  16732.     .byte $00,$00
  16733. yescmd: .byte $02
  16734.     .byte $02
  16735.     .asciz /NO/
  16736.     .byte $00,$00
  16737.     .byte $03
  16738.     .asciz /YES/
  16739.     .byte $01,$01
  16740. ddskey: .byte $03              ;[60] [40] Two options for now
  16741.     .byte $05              ;[40] Length
  16742.     .asciz /DRIVE/              ;[40] Keyword
  16743.     .byte $00,$00              ;[40] Data
  16744.     .byte $04              ;[40] Length
  16745.     .asciz /SLOT/              ;[40] Keyword
  16746.     .byte $03,$03              ;[40] Data
  16747.     .byte    3        ;[60]
  16748.     .asciz    /VOL/        ;[60]
  16749.     .byte    6,6        ;[60]
  16750. kerehr: .byte cmcfm          ;[13] Tell them they can also confirm
  16751.     .byte nul          ;[13] End Help command string
  16752.     .ifeq    1        ;[85] help now in file kermit.help
  16753. kerhlp: .byte hcr
  16754.     .ifeq    akhelp        ;[78] use alans help
  16755.     nasc    <    [USE <CNTL-S> 0        ;[78]
  16756.     .byte    '>        ;[78]
  16757.     nasc    < TO PAUSE]> 0    ;[78]
  16758.     .byte    hcr        ;[78]
  16759.     nasc    <?         GIVE OPTIONS AT ANY POINT> 0    ;[78]
  16760.     .byte    hcr        ;[78]
  16761.     .byte    hcr        ;[78]
  16762.  
  16763.     nasc    <SET ?     GIVE 'SET' OPTIONS> 0    ;[78]
  16764.     .byte    hcr        ;[78]
  16765.     .byte    hcr        ;[78]
  16766.  
  16767. ;[81]    nasc    <SHOW ALL  SHOW ALL PRESENTLY 'SET'> 0    ;[78]
  16768.     nasc    <SHOW ALL  SHOWS ALL PRESENTLY 'SET'> 0    ;[81]
  16769.     .byte    hcr        ;[78]
  16770.     .byte    hcr        ;[78]
  16771.  
  16772.     nasc    <<ESC> 0    ;[78]
  16773.     .byte    '>        ;[78]
  16774.     nasc    <     COMPLETES COMMAND> 0    ;[78]
  16775.     .byte    hcr        ;[78]
  16776.     .byte    hcr        ;[78]
  16777.  
  16778.     nasc    <STATUS    LAST FILE TRANSFER INFO> 0    ;[78]
  16779.     .byte    hcr        ;[78]
  16780.     .byte    hcr        ;[78]
  16781.  
  16782.     nasc    <--> 0            ;[78]
  16783.     .byte    '>,' ,'-,'-,'>        ;[78]
  16784.     nasc    <   [II+ ONLY] SHIFT> 0    ;[78]
  16785.     .byte    hcr        ;[78]
  16786.     .byte    hcr        ;[78]
  16787.     .byte    hcr        ;[78]
  16788.  
  16789.  
  16790.     nasc    <---IN/OUT> 0        ;[78]
  16791.     .byte    hcr        ;[78]
  16792.     .byte    hcr        ;[78]
  16793.  
  16794.     nasc    <FROM KERMIT-65> 0    ;[78]
  16795.     .byte    '>            ;[78]
  16796.     .byte    hcr        ;[78]
  16797. ;[81]    nasc    < YOU CANNOT TALK TO DOS> 0    ;[78]
  16798.     nasc    < YOU CAN TALK TO OS & MODEM AS FOLLOWS:> 0    ;[81]
  16799.     .byte    hcr        ;[78]
  16800. ;[81]    nasc    <(TO CATALOG OR> 0    ;[78]
  16801. ;[81]    .byte    hcr        ;[78]
  16802. ;[81]    nasc    <   BSAVE ALTERED.KERMIT,A$1000,L$6900)> 0    ;[78]
  16803. ;[81]    .byte    hcr        ;[78]
  16804. ;[81]    nasc    <AND, YOU CANNOT TALK TO YOUR MODEM> 0    ;[78]
  16805. ;[81]    .byte    hcr        ;[78]
  16806. ;[81]    nasc    <(TO DIAL AND TALK TO MAINFRAME).> 0    ;[78]
  16807. ;[81]    .byte    hcr        ;[78]
  16808.     .byte    hcr        ;[78]
  16809.  
  16810. ;[81]    nasc    <GET BACK & FORTH WITH:> 0    ;[78]
  16811. ;[81]    .byte    hcr        ;[78]
  16812.     .byte    hcr        ;[78]
  16813.  
  16814.     nasc    <EXIT       [TO DOS/PRODOS]> 0        ;[78]
  16815.     .byte    hcr        ;[78]
  16816.     nasc    <CALL4096   [TO KERMIT-65]> 0    ;[78]
  16817.     .byte    hcr        ;[78]
  16818.     nasc    <BRUN KERMIT384 [SOMETIMES-TO KERMIT-65]> 0    ;[81]
  16819.     .byte    hcr        ;[81]
  16820.     .byte    hcr        ;[78]
  16821.  
  16822.     nasc    <CONNECT    [TO MODEM]> 0    ;[78]
  16823.     .byte    hcr        ;[78]
  16824.     nasc    <<CNTL-@> 0            ;[78]
  16825.     .byte    '>            ;[78]
  16826.     nasc    <C  [TO KERMIT-65]> 0    ;[78]
  16827.     .byte    hcr        ;[78]
  16828.     .byte    hcr        ;[78]
  16829.     .byte    hcr        ;[78]
  16830.  
  16831.     nasc    <---UP/DOWN LOAD SEQUENCE> 0    ;[78]
  16832.     .byte    hcr        ;[78]
  16833.     .byte    hcr        ;[78]
  16834.  
  16835.     nasc    <[PROMPT YOU SEE]> 0    ;[78]
  16836.     .byte    hcr        ;[78]
  16837.     nasc    <.  [WHAT YOU TYPE]> 0    ;[78]
  16838.     .byte    hcr        ;[78]
  16839. ;[81]    nasc    <      [COMMENT]> 0    ;[78]
  16840. ;[81]    .byte    hcr        ;[78]
  16841. ;[81]    nasc    <.  .  .> 0        ;[78]
  16842. ;[81]    .byte    hcr        ;[78]
  16843. ;[81]    nasc    <.  .  .> 0        ;[78]
  16844.     .byte    hcr        ;[78]
  16845.     .byte    hcr        ;[78]
  16846.  
  16847.     nasc    <KERMIT-65> 0        ;[78]
  16848.     .byte    '>            ;[78]
  16849.     .byte    hcr        ;[78]
  16850.     nasc    <   CONNECT> 0        ;[78]
  16851.     .byte    hcr        ;[78]
  16852.     .byte    hcr        ;[78]
  16853.  
  16854.     nasc    <NO PROMPT> 0        ;[78]
  16855.     .byte    hcr        ;[78]
  16856.     nasc    <   ATD555-1234> 0    ;[78]
  16857. ;[81]    .byte    hcr        ;[78]
  16858. ;[81]    nasc    <      [HAYES DIAL]> 0    ;[78]
  16859.     nasc    < [HAYES DIAL]> 0    ;[78]
  16860.     .byte    hcr        ;[78]
  16861.     .byte    hcr        ;[78]
  16862.  
  16863.     nasc    <%     [MAINFRAME PROMPT-USE LOWER CASE]> 0    ;[78]
  16864.     .byte    hcr        ;[78]
  16865.     nasc    <   LOGIN> 0        ;[78]
  16866.     .byte    hcr        ;[78]
  16867.     nasc    <   PASSWORD> 0        ;[78]
  16868.     .byte    hcr        ;[78]
  16869. ;[81]    nasc    <   KERMIT R> 0        ;[78]
  16870.     nasc    <   KERMIT R [HOST DEPENDENT]> 0        ;[81]
  16871.     .byte    hcr        ;[78]
  16872.     nasc    <   <CNTL-@> 0        ;[78]
  16873.     .byte    '>,'C            ;[78]
  16874.     .byte    hcr        ;[78]
  16875.     .byte    hcr        ;[78]
  16876.  
  16877.     nasc    <KERMIT-65> 0        ;[78]
  16878.     .byte    '>            ;[78]
  16879.     .byte    hcr        ;[78]
  16880.     nasc    <   SEND FOO> 0        ;[78]
  16881. ;[81]    .byte    hcr        ;[78]
  16882. ;[81]    nasc    <      [UPLOAD FILE NAMED "FOO"]> 0    ;[78]
  16883.     nasc    < [UPLOAD FILE NAMED "FOO"]> 0    ;[78]
  16884.     .byte    hcr        ;[78]
  16885. ;[81]    nasc    <   EXIT> 0        ;[78]
  16886. ;[81]    .byte    hcr        ;[78]
  16887. ;[81]    .byte    hcr        ;[78]
  16888.  
  16889. ;[81]    nasc    <]     [DOS PROMPT]> 0    ;[78]
  16890. ;[81]    .byte    hcr        ;[78]
  16891.     nasc    <KERMIT-65> 0        ;[81]
  16892.     .byte    '>            ;[81]
  16893.     .byte    hcr        ;[81]
  16894.     nasc    <   CATALOG> 0        ;[78]
  16895.     .byte    hcr        ;[78]
  16896. ;[81]    nasc    <   CALL4096> 0        ;[78]
  16897. ;[81]    .byte    hcr        ;[78]
  16898.     .byte    hcr        ;[78]
  16899.  
  16900.     nasc    <KERMIT-65> 0        ;[78]
  16901.     .byte    '>            ;[78]
  16902.     .byte    hcr        ;[78]
  16903.     nasc    <   CONNECT> 0        ;[78]
  16904.     .byte    hcr        ;[78]
  16905.     .byte    hcr        ;[78]
  16906.  
  16907.     nasc    <%> 0            ;[78]
  16908.     .byte    hcr        ;[78]
  16909. ;[81]    nasc    <   KERMIT S FOO> 0    ;[78]
  16910.     nasc    <   KERMIT S FOO [HOST DEPENDENT]> 0    ;[81]
  16911.     .byte    hcr        ;[78]
  16912. ;[81]    nasc    <      [DOWNLOAD]> 0    ;[78]
  16913. ;[81]    .byte    hcr        ;[78]
  16914.     nasc    <   <CNTL-@> 0        ;[78]
  16915.     .byte    '>,'C            ;[78]
  16916.     .byte    hcr        ;[78]
  16917.     .byte    hcr        ;[78]
  16918.  
  16919.     nasc    <KERMIT-65> 0        ;[78]
  16920.     .byte    '>            ;[78]
  16921.     .byte    hcr        ;[78]
  16922.     nasc    <   RECEIVE> 0        ;[78]
  16923.     nasc    < [DOWNLOADS FILE NAMED "FOO"]> 0    ;[81]
  16924.     .byte    hcr        ;[78]
  16925.     nasc    <   CONNECT> 0        ;[78]
  16926.     .byte    hcr        ;[78]
  16927.     .byte    hcr        ;[78]
  16928.  
  16929.     nasc    <%> 0             ;[78]
  16930.     .byte    hcr        ;[78]
  16931.     nasc    <   +++ATH0> 0        ;[78]
  16932. ;[81]    .byte    hcr        ;[78]
  16933. ;[81]    nasc    <      [HAYES HANGUP]> 0    ;[78]
  16934.     nasc    < [HAYES HANGUP]> 0    ;[78]
  16935.     .byte    hcr        ;[78]
  16936.     nasc    <   <CNTL-@> 0        ;[78]
  16937.     .byte    '>,'C            ;[78]
  16938.     .byte    hcr        ;[78]
  16939.     .byte    hcr        ;[78]
  16940.  
  16941.     nasc    <KERMIT-65> 0        ;[78]
  16942.     .byte    '>            ;[78]
  16943.     .byte    hcr        ;[78]
  16944.     .byte    hcr        ;[78]
  16945.  
  16946.     nasc    <---LOG TO DISK> 0    ;[78]
  16947.     .byte    hcr        ;[78]
  16948.     .byte    hcr        ;[78]
  16949.  
  16950.     nasc    <KERMIT-65> 0        ;[78]
  16951.     .byte    '>            ;[78]
  16952.     .byte    hcr        ;[78]
  16953.     nasc    <   LOG FOO> 0        ;[78]
  16954. ;[81]    .byte    hcr        ;[78]
  16955. ;[81]    nasc    <      [OPEN LOG: "FOO"]> 0    ;[78]
  16956.     nasc    < [OPEN LOG: "FOO"]> 0    ;[78]
  16957.     .byte    hcr        ;[78]
  16958.     nasc    <   CONNECT> 0        ;[78]
  16959.     .byte    hcr        ;[78]
  16960.     .byte    hcr        ;[78]
  16961.  
  16962.     nasc    <%> 0            ;[78]
  16963.     .byte    hcr        ;[78]
  16964.     nasc    <   CAT FOO> 0        ;[78]
  16965. ;[81]    .byte    hcr        ;[78]
  16966. ;[81]    nasc    <      [MAINFRAME PRINTS "FOO"]> 0    ;[78]
  16967.     nasc    < [MAINFRAME PRINTS "FOO"]> 0    ;[81]
  16968.     .byte    hcr        ;[78]
  16969.     nasc    <   <CNTL-@> 0        ;[78]
  16970.     .byte    '>,'C            ;[78]
  16971.     .byte    hcr        ;[78]
  16972.     .byte    hcr        ;[78]
  16973.  
  16974.     nasc    <KERMIT-65> 0        ;[78]
  16975.     .byte    '>            ;[78]
  16976. ;[81]    .byte    hcr        ;[78]
  16977. ;[81]    nasc    <      [LOG ENDS]> 0    ;[78]
  16978.     nasc    < [LOG ENDS]> 0    ;[78]
  16979.     .byte    hcr        ;[78]
  16980.     nasc    <   CONNECT> 0        ;[78]
  16981.     .byte    hcr        ;[78]
  16982.     .byte    hcr        ;[78]
  16983.  
  16984. ;[81]    nasc    <%> 0            ;[78]
  16985.     nasc    <% ...> 0            ;[81]
  16986.     .byte    hcr        ;[78]
  16987.     .byte    hcr        ;[78]
  16988.     .byte    hcr        ;[78]
  16989.  
  16990.  
  16991.     .endc            ;[78]
  16992.     .ifne    akhelp        ;[78]
  16993.     nasc  <KERMIT COMMANDS FOR THIS VERSION ARE:> 0
  16994.     .byte hcr
  16995.     .byte hcr
  16996.     nasc  <BYE       SHUT  DOWN  AND  LOG  OUT  A> 0   ;[14] New command
  16997.     .byte hcr                          ;[14]
  16998.     nasc  <          REMOTE  KERMIT SERVER,  THEN> 0   ;[14]
  16999.     .byte hcr                          ;[14]
  17000.     nasc  <          EXIT.> 0                  ;[14]
  17001.     .byte hcr                          ;[14]
  17002.     .byte hcr                          ;[14]
  17003.     nasc  <CONNECT   ALLOW USER TO TALK TO REMOTE> 0
  17004.     .byte hcr
  17005.     nasc  <          KERMIT DIRECTLY.> 0
  17006.     .byte hcr
  17007.     .byte hcr
  17008.     nasc  <EXIT      EXIT  FROM  KERMIT  BACK  TO> 0
  17009.     .byte hcr
  17010.     nasc  <          THE  HOST OPERATING  SYSTEM.> 0
  17011.     .byte hcr
  17012.     .byte hcr
  17013.     nasc  <FINISH    SHUT   DOWN  REMOTE   KERMIT> 0   ;[14] New command
  17014.     .byte hcr                          ;[14]
  17015.     nasc  <          SERVER  BUT  DO NOT  LOG OUT> 0   ;[14]
  17016.     .byte hcr                          ;[14]
  17017.     nasc  <          REMOTE JOB. DO NOT EXIT FROM> 0   ;[14]
  17018.     .byte hcr                          ;[14]
  17019.     nasc  <          LOCAL KERMIT.> 0              ;[14]
  17020.     .byte hcr                          ;[14]
  17021.     .byte hcr                          ;[14]
  17022.     nasc  <GET       FETCH  A FILE FROM A  REMOTE> 0   ;[14] New command
  17023.     .byte hcr                          ;[14]
  17024.     nasc  <          SERVER KERMIT.  THE FILENAME> 0   ;[14]
  17025.     .byte hcr                          ;[14]
  17026.     nasc  <          IS  VALIDATED BY  THE REMOTE> 0   ;[14]
  17027.     .byte hcr                          ;[14]
  17028.     nasc  <          SERVER.> 0                  ;[14]
  17029.     .byte hcr                          ;[14]
  17030.     .byte hcr                          ;[14]
  17031.     nasc  <HELP      PRINT  INSTRUCTIONS   ON> 0
  17032.     .byte hcr
  17033.     nasc  <          VARIOUS  COMMANDS  AVAILABLE> 0
  17034.     .byte hcr
  17035.     nasc  <          IN KERMIT.> 0
  17036.     .byte hcr
  17037.     .byte hcr
  17038.     nasc  <LOG       COPY REMOTE SESSION TO DISK> 0
  17039.     .byte hcr
  17040.     .byte hcr
  17041.     nasc  <QUIT      SAME AS EXIT.> 0
  17042.     .byte hcr
  17043.     .byte hcr
  17044.     nasc  <RECEIVE   RECEIVE A FILE OR FILE GROUP> 0
  17045.     .byte hcr
  17046.     nasc  <          FROM THE REMOTE HOST.> 0
  17047.     .byte hcr
  17048.     .byte hcr
  17049.     nasc  <SEND      SENDS A FILE FROM THE M6502> 0
  17050.     .byte hcr
  17051.     nasc  <          BASED COMPUTER TO THE REMOTE> 0
  17052.     .byte hcr
  17053.     nasc  <          HOST.> 0
  17054.     .byte hcr
  17055.     .byte hcr
  17056.     nasc  <SERVER    USE AS A FILE SERVER ETC.> 0
  17057.     .BYTE hcr
  17058.     .byte hcr
  17059.     nasc  <SET       ESTABLISH VARIOUS PARAMETERS,> 0
  17060.     .byte hcr
  17061.     nasc  <          SUCH AS DEBBUGING MODE,  EOL> 0
  17062.     .byte hcr
  17063.     nasc  <          CHARACTER, AND  TRANSMISSION> 0
  17064.     .byte hcr
  17065.     nasc  <          DELAY.> 0
  17066.     .byte hcr
  17067.     .byte hcr
  17068.     nasc  <SHOW      DISPLAY  VARIOUS  PARAMETERS> 0
  17069.     .byte hcr
  17070.     nasc  <          ESTABLISHED   BY   THE   SET> 0
  17071.     .byte hcr
  17072.     nasc  <          COMMAND.> 0
  17073.     .byte hcr
  17074.     .byte hcr
  17075.     nasc  <STATUS    GIVE  INFORMATION ABOUT  THE> 0
  17076.     .byte hcr
  17077.     nasc  <          LAST FILE TRANSFER.> 0
  17078.     .endc        ;[78]
  17079.     .byte hcr,nul
  17080.     .endc            ;[85]
  17081. inthlp: nasc  <CHOSE ONE OF THE FOLLOWING:> 0
  17082.     .byte hcr
  17083. ;[80]    nasc  <        ? - THIS HELP MESSAGE> 0
  17084. ;[80]    .byte hcr
  17085. ;[85]    nasc  <        0 - NULL CHAR> 0
  17086. ;[87]    nasc  <        0-NULL CHAR> 0    ;[85]
  17087.     nasc  < 0-NULL CHAR> 0    ;[87]
  17088.     .byte hcr
  17089. ;[85]    nasc  <        B - BREAK SIGNAL> 0
  17090. ;[87]    nasc  <        B-BREAK SIGNAL> 0    ;[85]
  17091.     nasc  < B-BREAK SIGNAL> 0    ;[87]
  17092.     .byte hcr
  17093. ;[85]    nasc  <        C - CLOSE CONNECTION> 0
  17094. ;[86]    nasc  <        C-CLOSE CONNECTION> 0    ;[85]
  17095. ;[87]    nasc  <        C-COMMAND MODE> 0    ;[86]
  17096.     nasc  < C-COMMAND MODE> 0    ;[87]
  17097.     .byte hcr      ;[48]
  17098. ;[85]    nasc  <        D - DROP LINE> 0      ;[48]
  17099. ;[87]    nasc  <        D-DROP LINE> 0      ;[48]    ;[85]
  17100.     nasc  < D-DROP LINE> 0      ;[87]
  17101.     .byte hcr      ;[48]
  17102. ;[85]    nasc  <        E - R(E)STORE SCREEN> 0      ;[83]
  17103. ;[86]    nasc  <        E-R(E)STORE SCREEN> 0      ;[83]    ;[85]
  17104. ;[87]    nasc  <        E-ERASE SCREEN> 0      ;[86][85][83]
  17105.     nasc  < E-ERASE SCREEN> 0      ;[87]
  17106.     .byte hcr      ;[83]
  17107. ;[85]    nasc  <        K - KEYPAD APPLICATION TOGGLE> 0    ;[81]
  17108. ;[87]    nasc  <        K-KEYPAD APPLICATION TOGGLE> 0    ;[81]    ;[85]
  17109.     nasc  < K-KEYPAD APPLICATION TOGGLE> 0    ;[87]
  17110.     .byte hcr      ;[81]
  17111. ;[87]    nasc  <        M-MODEM COMMAND> 0      ;[86]
  17112.     nasc  < M-MODEM COMMAND> 0      ;[87]
  17113.     .byte hcr            ;[86]
  17114. ;[81]    nasc  <        P - PRINTER TOGGLE ON/OFF> 0      ;[55]
  17115. ;[85]    nasc  <        P - PRINTER TOGGLE> 0      ;[81]
  17116. ;[87]    nasc  <        P-PRINTER TOGGLE> 0      ;[81]    ;[85]
  17117.     nasc  < P-PRINTER TOGGLE> 0      ;[87]
  17118.     .byte hcr
  17119. ;[87]    nasc  <        Q-QUIT> 0      ;[86]
  17120.     nasc  < Q-QUIT> 0      ;[87]
  17121.     .byte hcr            ;[86]
  17122. ;[85]    nasc  <        R - P(R)INT SCREEN> 0        ;[80]
  17123. ;[87]    nasc  <        R-P(R)INT SCREEN> 0        ;[80]    ;[85]
  17124.     nasc  < R-P(R)INT SCREEN> 0        ;[87]
  17125.     .byte hcr                    ;[80]
  17126. ;[85]    nasc  <        S - STATUS> 0
  17127. ;[87]    nasc  <        S-STATUS> 0    ;[85]
  17128.     nasc  < S-STATUS> 0    ;[87]
  17129.     .byte hcr                    ;[87]
  17130.     nasc  < V-CURSOR-KEYS-(V)T100 TOGGLE> 0    ;[87]
  17131.     .byte hcr
  17132. ;[85]    nasc  <        W - S(W)AP BS & DEL KEYS> 0        ;[76]
  17133. ;[87]    nasc  <        W-S(W)AP BS & DEL KEYS> 0        ;[76]    ;[85]
  17134.     nasc  < W-S(W)AP BS & DEL KEYS> 0        ;[87]
  17135.     .byte hcr                    ;[76]
  17136. ;[87]    nasc  <        ESCAPE-CHAR - TRANSMIT THE ESCAPE CHAR> 0
  17137.     nasc  < ESCAPE-CHAR - TRANSMIT THE ESCAPE CHAR> 0
  17138.     .byte hcr,nul
  17139. .SBTTL    Message text
  17140. ermes1: .byte hcr
  17141.     nasc  <?UNRECOGNIZED COMMAND> 1
  17142. ermes2: .byte hcr
  17143.     nasc  <?ILLEGAL CHARACTER> 1
  17144. ermes3: .byte hcr
  17145.     nasc  <?NOT CONFIRMED> 1
  17146. ermes4: .byte hcr
  17147.     nasc  <?INTEGER OUT OF RANGE> 1
  17148. ermes5: .byte hcr
  17149.     nasc  <?ASCII CHARACTER IS NOT IN PROPER RANGE> 1
  17150. ermes6: .byte hcr
  17151.     nasc  <?EXPECTING KEYWORD> 1
  17152. ermes7: .byte hcr
  17153.     nasc  <?EXPECTING FILE SPEC> 1
  17154. ermes8: .byte hcr
  17155.     nasc  <?EXPECTING INTEGER> 1
  17156. ermes9: .byte hcr
  17157.     nasc  <?EXPECTING SWITCH> 1
  17158. ermesa: .byte hcr
  17159.     nasc  <?DEVICE DRIVER NOT LOADED> 1
  17160. ermesb: .byte hcr                          ;[13]
  17161.     nasc  <?NULL STRING FOUND WHILE LOOKING FOR TEXT> 1      ;[13]
  17162. ermesc: .byte hcr                          ;[14]
  17163.     nasc  <?COULD NOT SEND GENERIC LOGOUT/FINISH PACKET> 1      ;[67][14]
  17164. ;[67]ermesd: .byte hcr                          ;[14]
  17165. ;[67]    nasc  <?COULD NOT SEND GENERIC FINISH PACKET> 1      ;[14]
  17166. ermese: .byte hcr                          ;[40]
  17167.     nasc  <?SLOT NUMBER OUT OF RANGE> 1              ;[40]
  17168. ermesf: .byte hcr                          ;[40]
  17169.     nasc  <?DRIVE NUMBER OUT OF RANGE> 1              ;[40]
  17170. ;[59] these messages must be kept in order ****** begin
  17171. erms0a: nasc  <                        > 1
  17172. erms10: nasc  <CANNOT RECEIVE INIT     > 1
  17173. erms11: nasc  <CANNOT RECEIVE FILE-HEAD> 1
  17174. erms12: nasc  <CANNOT RECEIVE DATA     > 1
  17175. erms14: nasc  <MAX RETRY COUNT EXCEEDED> 1
  17176. erms15: nasc  <BAD CHKSUM:PACK, ACTUAL > 1
  17177. erms16: nasc  <PROGRAM ERROR IN RPAK   > 1
  17178. erms17: nasc  <8-BIT QUOTING REFUSED   > 1
  17179. erms18: nasc  <TRANSFER ABORTED BY USER> 1
  17180. erms19: nasc  <CANNOT ALTER FILENAME   > 1
  17181. erms1a:    nasc  <FILE ALREADY EXISTS     > 1
  17182.     nasc  <FILE TRANSFER TIMEOUT   > 1    ;[64]
  17183. ;[59] last of the error msgs but start of dos msgs
  17184.     .ifeq <ftcom-ftappl>
  17185. dskers: nasc  <                        > 1
  17186.     nasc  <BAD CALL TYPE           > 1
  17187.     nasc  <BAD SUB-CALL TYPE       > 1
  17188.     nasc  <WRITE PROTECTED         > 1
  17189.     nasc  <END OF DATA             > 1
  17190.     nasc  <FILE NOT FOUND          > 1
  17191.     nasc  <VOLUME MISMATCH         > 1
  17192.     nasc  <DISK I/O                > 1
  17193.     nasc  <DISK FULL               > 1
  17194.     nasc  <FILE LOCKED             > 1
  17195.     nasc  <INVALID PATHNAME        > 1
  17196.     nasc  <INCOMPATIBLE FILE FORMAT> 1
  17197.     nasc  <FILE ALREADY OPEN       > 1
  17198. ;[59] these messages must be kept in order ****** end
  17199.     .ifeq    funkey        ;[73]
  17200. sfkls    .byte '0        ;[73]
  17201.     .byte    '1        ;[73]
  17202.     .byte    '2        ;[73]
  17203.     .byte    '3        ;[73]
  17204.     .byte    '4        ;[73]
  17205.     .byte    '5        ;[73]
  17206.     .byte    '6        ;[73]
  17207.     .byte    '7        ;[73]
  17208.     .byte    '8        ;[73]
  17209.     .byte    '9        ;[73]
  17210.     .byte    'y        ;[73]
  17211.     .byte    'u        ;[73]
  17212.     .byte    'i        ;[73]
  17213.     .byte    'o        ;[73]
  17214.     .byte    'h        ;[73]
  17215.     .byte    'j        ;[73]
  17216.     .byte    'k        ;[73]
  17217.     .byte    'l        ;[73]
  17218.     .byte    'n        ;[73]
  17219.     .byte    'm        ;[73]
  17220.     .byte    'Y        ;[73]
  17221.     .byte    'U        ;[73]
  17222.     .byte    'I        ;[73]
  17223.     .byte    'O        ;[73]
  17224.     .byte    'H        ;[73]
  17225.     .byte    'J        ;[73]
  17226.     .byte    'K        ;[73]
  17227.     .byte    'L        ;[73]
  17228.     .byte    'N        ;[73]
  17229.     .byte    'M        ;[73]
  17230.     .byte    ',        ;[73]
  17231.     .byte    '.        ;[73]
  17232.     .byte    sp        ;[73]
  17233.     .byte    '0        ;[73]
  17234.     .byte    '-        ;[73]
  17235.     .byte    ctrlu        ;[76] right arrow
  17236.     .byte    bs        ;[76] left arrow
  17237. ;[80]    .byte    $7f        ;[76] del since swap may be on
  17238.     .byte    ctrlk        ;[76] up arrow
  17239.     .byte    lf        ;[76] down arrow
  17240. efkls                ;[73]
  17241.     .word    zrfks        ;[73]
  17242.     .word    onfks        ;[73]
  17243.     .word    twfks        ;[73]
  17244.     .word    trfks        ;[73]
  17245.     .word    fufks        ;[73]
  17246.     .word    fvfks        ;[73]
  17247.     .word    sxfks        ;[73]
  17248.     .word    svfks        ;[73]
  17249.     .word    egfks        ;[73]
  17250.     .word    nnfks        ;[73]
  17251.     .word    yfks        ;[73]
  17252.     .word    ufks        ;[73]
  17253.     .word    ifks        ;[73]
  17254.     .word    ofks        ;[73]
  17255.     .word    hfks        ;[73]
  17256.     .word    jfks        ;[73]
  17257.     .word    kfks        ;[73]
  17258.     .word    lfks        ;[73]
  17259.     .word    nfks        ;[73]
  17260.     .word    mfks        ;[73]
  17261.     .word    yfks        ;[73]
  17262.     .word    ufks        ;[73]
  17263.     .word    ifks        ;[73]
  17264.     .word    ofks        ;[73]
  17265.     .word    hfks        ;[73]
  17266.     .word    jfks        ;[73]
  17267.     .word    kfks        ;[73]
  17268.     .word    lfks        ;[73]
  17269.     .word    nfks        ;[73]
  17270.     .word    mfks        ;[73]
  17271.     .word    comfks        ;[73]
  17272.     .word    perfks        ;[73]
  17273.     .word    spfks        ;[73]
  17274.     .word    cufks        ;[73]
  17275.     .word    bsfks        ;[73]
  17276.     .word    lfks        ;[76]
  17277.     .word    perfks        ;[76]
  17278. ;[80]    .word    perfks        ;[76]
  17279.     .word    ckfks        ;[76]
  17280.     .word    cjfks        ;[76]
  17281. zrfks    .byte    $1b,'~,0    ;[73]
  17282. onfks    .byte    $1b,'S,0    ;[73]
  17283. twfks    .byte    $1b,'T,0    ;[73]
  17284. trfks    .byte    $1b,'U,0    ;[73]
  17285. fufks    .byte    $1b,'V,0    ;[73]
  17286. fvfks    .byte    $1b,'W,0    ;[73]
  17287. sxfks    .byte    $1b,'P,0    ;[73]
  17288. svfks    .byte    $1b,'Q,0    ;[73]
  17289. egfks    .byte    $1b,'R,0    ;[73]
  17290. nnfks    .byte    $1b,'A,0    ;[73]
  17291. yfks    .byte    $1b,'?,'w,0    ;[73]
  17292. ufks    .byte    $1b,'?,'x,0    ;[73]
  17293. ifks    .byte    $1b,'?,'y,0    ;[73]
  17294. ofks    .byte    $1b,'B,0    ;[73]
  17295. hfks    .byte    $1b,'?,'t,0    ;[73]
  17296. jfks    .byte    $1b,'?,'u,0    ;[73]
  17297. kfks    .byte    $1b,'?,'v,0    ;[73]
  17298. lfks    .byte    $1b,'C,0    ;[73]
  17299. nfks    .byte    $1b,'?,'q,0    ;[73]
  17300. mfks    .byte    $1b,'?,'r,0    ;[73]
  17301. comfks    .byte    $1b,'?,'s,0    ;[73]
  17302. perfks    .byte    $1b,'D,0    ;[73]
  17303. spfks    .byte    $1b,'?,'p,0    ;[73]
  17304. cufks    .byte    $1b,'?,'n,0    ;[73]
  17305. bsfks    .byte    $1b,'?,'M,0    ;[73]
  17306. ckfks    .byte    $1b,'A,0    ;[73]
  17307. cjfks    .byte    $1b,'B,0    ;[73]
  17308. sfklsc                ;[76] one to one correspondence to efklsc
  17309.     .byte    ctrlu        ;[76] right arrow
  17310.     .byte    bs        ;[76] left arrow
  17311.     .byte    ctrlk        ;[76] up arrow
  17312.     .byte    lf        ;[76] down arrow
  17313. ;[80]    .byte    $7f        ;[76] del since swap may be on
  17314.     .byte    '6        ;[76]
  17315.     .byte    '7        ;[76]
  17316.     .byte    '8        ;[76]
  17317.     .byte    '9        ;[76]
  17318.     .byte    'y        ;[76]
  17319.     .byte    'u        ;[76]
  17320.     .byte    'i        ;[76]
  17321.     .byte    'o        ;[76]
  17322.     .byte    'h        ;[76]
  17323.     .byte    'j        ;[76]
  17324.     .byte    'k        ;[76]
  17325.     .byte    'l        ;[76]
  17326.     .byte    'n        ;[76]
  17327.     .byte    'm        ;[76]
  17328.     .byte    ',        ;[76]
  17329.     .byte    '.        ;[76]
  17330.     .byte    sp        ;[76]
  17331.     .byte    '0        ;[76] this is the . sigh!
  17332.     .byte    'Y        ;[76] repeat these for upper case also
  17333.     .byte    'U        ;[76]        "
  17334.     .byte    'I        ;[76]
  17335.     .byte    'O        ;[76]
  17336.     .byte    'H        ;[76]
  17337.     .byte    'J        ;[76]
  17338.     .byte    'K        ;[76]
  17339.     .byte    'L        ;[76]
  17340.     .byte    'N        ;[76]
  17341.     .byte    'M        ;[76]
  17342. ;[80]    .byte    ',        ;[76]
  17343. ;[80]    .byte    '.        ;[76]
  17344. ;[80]    .byte    sp        ;[76]
  17345. ;[80]    .byte    ctrlu        ;[76] right arrow
  17346. ;[80]    .byte    bs        ;[76] left arrow
  17347. ;[80]    .byte    $7f        ;[76] del since swap may be on
  17348. ;[80]    .byte    ctrlk        ;[76] up arrow
  17349. ;[80]    .byte    lf        ;[76] down arrow
  17350. efklsc                ;[76] one to one correspondence to sfklsc
  17351.     .word    cufksc        ;[80]
  17352.     .word    bsfksc        ;[80]
  17353.     .word    ckfksc        ;[80]
  17354.     .word    cjfksc        ;[80]
  17355.     .word    sxfksc        ;[76]
  17356.     .word    svfksc        ;[76]
  17357.     .word    egfksc        ;[76]
  17358.     .word    nnfksc        ;[76]
  17359.     .word    yfksc        ;[76]
  17360.     .word    ufksc        ;[76]
  17361.     .word    ifksc        ;[76]
  17362.     .word    ofksc        ;[76]
  17363.     .word    hfksc        ;[76]
  17364.     .word    jfksc        ;[76]
  17365.     .word    kfksc        ;[76]
  17366.     .word    lfksc        ;[76]
  17367.     .word    nfksc        ;[76]
  17368.     .word    mfksc        ;[76]
  17369.     .word    comfkc        ;[80]
  17370.     .word    perfkc        ;[80]
  17371.     .word    spfksc        ;[80]
  17372.     .word    zrfksc        ;[76] one to one correspondence to sfklsc
  17373.     .word    yfksc        ;[76]
  17374.     .word    ufksc        ;[76]
  17375.     .word    ifksc        ;[76]
  17376.     .word    ofksc        ;[76]
  17377.     .word    hfksc        ;[76]
  17378.     .word    jfksc        ;[76]
  17379.     .word    kfksc        ;[76]
  17380.     .word    lfksc        ;[76]
  17381.     .word    nfksc        ;[76]
  17382.     .word    mfksc        ;[76]
  17383. ;[80]    .word    comfkc        ;[76]
  17384. ;[80]    .word    perfkc        ;[76]
  17385. ;[80]    .word    spfksc        ;[76]
  17386. ;[80]    .word    cufksc        ;[76]
  17387. ;[80]    .word    bsfksc        ;[76]
  17388. ;[80]    .word    bsfksc        ;[76]
  17389. ;[80]    .word    ckfksc        ;[76]
  17390. ;[80]    .word    cjfksc        ;[76]
  17391. zrfksc    .byte    $1b,'O,'n,0    ;[76] period key aux keypad code
  17392. sxfksc    .byte    $1b,'O,'P,0    ;[76]
  17393. svfksc    .byte    $1b,'O,'Q,0    ;[76]
  17394. egfksc    .byte    $1b,'O,'R,0    ;[76]
  17395. nnfksc    .byte    $1b,'O,'S,0    ;[76]
  17396. yfksc    .byte    $1b,'O,'w,0    ;[76]
  17397. ufksc    .byte    $1b,'O,'x,0    ;[76]
  17398. ifksc    .byte    $1b,'O,'y,0    ;[76]
  17399. ofksc    .byte    $1b,'O,'m,0    ;[76] should be - key pad
  17400. hfksc    .byte    $1b,'O,'t,0    ;[76]
  17401. jfksc    .byte    $1b,'O,'u,0    ;[76]
  17402. kfksc    .byte    $1b,'O,'v,0    ;[76]
  17403. lfksc    .byte    $1b,'O,'l,0    ;[76]
  17404. nfksc    .byte    $1b,'O,'q,0    ;[76]
  17405. mfksc    .byte    $1b,'O,'r,0    ;[76]
  17406. comfkc    .byte    $1b,'O,'s,0    ;[76]
  17407. perfkc    .byte    $1b,'O,'M,0    ;[76] the enter key
  17408. spfksc    .byte    $1b,'O,'p,0    ;[76]
  17409. ;[84]cufksc    .byte    $1b,'O,'C,0    ;[76]
  17410. ;[84]bsfksc    .byte    $1b,'O,'D,0    ;[76]
  17411. ;[84]cjfksc    .byte    $1b,'O,'B,0    ;[76]
  17412. ;[84]ckfksc    .byte    $1b,'O,'A,0    ;[76]
  17413. cufksc    .byte    $1b,'[,'C,0    ;[84] make the default reset
  17414. bsfksc    .byte    $1b,'[,'D,0    ;[84]
  17415. cjfksc    .byte    $1b,'[,'B,0    ;[84]
  17416. ckfksc    .byte    $1b,'[,'A,0    ;[84]
  17417. sfklsk                ;[80] one to one correspondence to efklsc
  17418.     .byte    ctrlu        ;[80] right arrow
  17419.     .byte    bs        ;[80] left arrow
  17420.     .byte    ctrlk        ;[80] up arrow
  17421.     .byte    lf        ;[80] down arrow
  17422. efkckk                ;[80] end of cursor keys
  17423.     .byte    $18        ;[80] clear is really CAN
  17424.     .byte    '=        ;[80]
  17425.     .byte    '/        ;[80]
  17426.     .byte    '*        ;[80]
  17427.     .byte    '7        ;[80]
  17428.     .byte    '8        ;[80]
  17429.     .byte    '9        ;[80]
  17430.     .byte    '+        ;[80]
  17431.     .byte    '4        ;[80]
  17432.     .byte    '5        ;[80]
  17433.     .byte    '6        ;[80]
  17434.     .byte    '-        ;[80]
  17435.     .byte    '1        ;[80]
  17436.     .byte    '2        ;[80]
  17437.     .byte    '3        ;[80]
  17438.     .byte    13        ;[80] the enter (carrage return)
  17439.     .byte    '0        ;[80]
  17440.     .byte    '.        ;[80] this is the . sigh!
  17441. efklsk                ;[80]
  17442.     .endc            ;[73]
  17443. vtcoct                ;[76] one ch table
  17444.     .byte    '[        ;[76] one to one correspondence to vtcoca
  17445.     .byte    'H        ;[76]
  17446.     .byte    'D        ;[76]
  17447.     .byte    'E        ;[76]
  17448.     .byte    'M        ;[76]
  17449.     .byte    esc        ;[76]
  17450.     .byte    '=        ;[76]
  17451.     .byte    '>        ;[76]
  17452.     .byte    'Z        ;[76] this is vt52 identify request
  17453.     .byte    '7        ;[76]
  17454.     .byte    '8        ;[76]
  17455.     .byte    '<        ;[76]
  17456.     .byte    '\        ;[76]
  17457.     .byte    '(        ;[76]
  17458.     .byte    ')        ;[76]
  17459.     .byte    'c        ;[76]
  17460.     .byte    '#        ;[79]
  17461. vtcoca
  17462.     .word    vtcpsq        ;[76] vt100 param seq
  17463.     .word    vtlh        ;[76]
  17464.     .word    vtld        ;[76]
  17465.     .word    vtle        ;[76]
  17466.     .word    vtlm        ;[76]
  17467.     .word    vtlesc        ;[76] 2 esc in a row
  17468. ;[80]    .word    vtccom        ;[77][76] ignore alt keypad stuf
  17469. ;[80]    .word    vtccom        ;[77][76]     "
  17470.     .word    vtc9        ;[80] keypad application mode
  17471.     .word    vtca        ;[80] keypad numeric mode
  17472.     .word    vtc2lc        ;[76] tell who we are
  17473.     .word    vtc7        ;[76] save cursor etc
  17474.     .word    vtc8        ;[76] restore cursor etc
  17475.     .word    vtccom        ;[77][76] ignore ansi
  17476.     .word    vtccom        ;[77][76] what is this ? exit hold screen mode???
  17477.     .word    vtcglp        ;[76] sigh the graphics stuff    ;[76]
  17478.     .word    vtcgrp        ;[76] sigh the graphics stuff    ;[76]
  17479.     .word    vtlc        ;[76]
  17480.     .word    vtclb        ;[79] sigh ignore line size stuff
  17481. vtctct                ;[76]
  17482.     .byte    ';        ;[76]
  17483.     .byte    'B        ;[76]
  17484.     .byte    'D        ;[76]
  17485.     .byte    'C        ;[76]
  17486.     .byte    'H        ;[76]
  17487.     .byte    'f        ;[76]
  17488.     .byte    'A        ;[76]
  17489.     .byte    'J        ;[76]
  17490.     .byte    'K        ;[76]
  17491.     .byte    'g        ;[76]
  17492.     .byte    'm        ;[76]
  17493.     .byte    '?        ;[76]
  17494.     .byte    'l        ;[76]
  17495.     .byte    'h        ;[76]
  17496.     .byte    'r        ;[76]
  17497.     .byte    'R        ;[76]
  17498.     .byte    'c        ;[76]
  17499.     .byte    'q        ;[77]
  17500.     .byte    'i        ;[87]
  17501. vtctca    .word    vtc2bp        ;[76] bump param #
  17502.     .word    vtc2b        ;[76]
  17503.     .word    vtc2d        ;[76]
  17504.     .word    vtc2c        ;[76]
  17505.     .word    vtc2h        ;[76]
  17506.     .word    vtc2h        ;[76] same as above
  17507.     .word    vtc2a        ;[76]
  17508.     .word    vtc2j        ;[76]
  17509.     .word    vtc2k        ;[76]
  17510.     .word    vtc2g        ;[76]
  17511.     .word    vtc2m        ;[76]
  17512.     .word    vtcqmk        ;[76]
  17513.     .word    vtc2ll        ;[76]
  17514.     .word    vtc2lh        ;[76]
  17515.     .word    vtc2lr        ;[76] lower case r
  17516.     .word    vtc2r        ;[76]
  17517.     .word    vtc2lc        ;[76] lower case c
  17518.     .word    vtccom        ;[77] lower case q, just ignore it
  17519.     .word    vtc2i        ;[87] vt102 printer on/off
  17520. vtcid    .byte esc,'[,'?,'1,';,'0,'c,0    ;[76] term with a 0
  17521. vtcg1                ; G1 character set
  17522.     .byte    ' ,'*,'#,'.,'.,'.,'.,'`,'+,'.,'.,'+,'+,'+,'+,'+    ;[76]
  17523.     .byte    '~,'-,'-,'-,'_,'+,'+,'+,'+,'|,'<,'>,'P,'!,'$,'.,$7f    ;[76]
  17524. erms1b: nasc  <NOT SUPPORTED BY THIS DEVICE DRIVER> 1      ;[48]
  17525. erms1c:    .byte    hcr        ;[57]
  17526.     nasc    <WARNING FLOW CONTROL PROBABLY REQUIRED> 1    ;[57]
  17527. erms1d: nasc  <ERROR > 1      ;[59]
  17528. erms1e: nasc  <TAIL OF FILE NAME CHANGED BECAUSE OF FILE WARNING > 1      ;[59]
  17529. ;[65]erms1f:    .byte    hcr        ;[59]
  17530. ;[65]    nasc    <WARNING FILE-BYTE-SIZE OF EIGHT PROBABLY REQUIRED> 1    ;[59]
  17531. erms1g    nasc    <PRODOS ERROR & CALL ADDRESS:> 1    ;[59]
  17532. lerm1g    =    .-erms1g-1        ;[62] forget about the null
  17533. erms1h    nasc    <SERVER COMMAND UNKNOWN => 1   ;[62]
  17534. erms1i    nasc    <GENERIC KERMIT COMMAND OPERAND UNKNOWN => 1   ;[62]
  17535. erms1j    nasc    <UNABLE TO INITIALIZE COM CARD> 1   ;[62]
  17536. erms1k    nasc    <UNABLE TO SEND/RECEIVE 8 BITS> 1   ;[72]
  17537. erms1l    nasc    < MAX SIZE IS > 1            ;[75]
  17538. erms1m    nasc    <NOT DOS 3.3, WILDCARDS?? KEYPRESS(S)??> 1    ;[81]
  17539. kbds:    nasc  <2P  > 1      ;[35] keyboard type strings
  17540.     nasc  <2E  > 1      ;[35]
  17541. dsps:    nasc  <2P-40-COL   > 1      ;[49] [46] Display type strings
  17542.     nasc  <2E-40-COL   > 1      ;[49] [46]
  17543.     nasc  <80-COL-SLOT > 1      ;[49]
  17544. kerftp: nasc  <TEXT      > 1
  17545.     nasc  <INTEGER   > 1
  17546.     nasc  <APPLESOFT > 1
  17547.     nasc  <OTHER  = $> 1        ;[78]
  17548.     nasc  <BINARY    > 1
  17549. kerprs: nasc  <NONE > 1              ;[21] Parity strings
  17550.     nasc  <SPACE> 1              ;[21]
  17551.     nasc  <MARK > 1              ;[21]
  17552.     nasc  <ODD  > 1              ;[21]
  17553.     nasc  <EVEN > 1              ;[21]
  17554. kerdms: nasc  <OFF     > 1          ;[26] Debug mode strings
  17555.     nasc  <TERSE   > 1          ;[26]
  17556.     nasc  <VERBOSE > 1          ;[26]
  17557.     .endc
  17558. kerrts: nasc  <SPAK:     SENDING           - > 1
  17559. kerrns    =     .-kerrts          ;[64] Routine name and action string length
  17560.     nasc  <SPAKCH:   SEND COMPLETE     - > 1
  17561.     nasc  <RPAK:     TRYING TO RECEIVE - > 1
  17562.     nasc  <RPKFLS:   FAILED TO RECEIVE - > 1
  17563.     nasc  <RPKRET:   RECEIVED          - > 1
  17564. ;[64]kerbal    =     6           ;[47] string length of following table
  17565. kerbau: nasc  <110  > 1      ;[47]
  17566. kerbal    =     .-kerbau           ;[64][47] string length of following table
  17567.     nasc  <134.5> 1      ;[47]
  17568.     nasc  <150  > 1      ;[47]
  17569.     nasc  <300  > 1      ;[47]
  17570.     nasc  <600  > 1      ;[47]
  17571.     nasc  <1200 > 1      ;[47]
  17572.     nasc  <1800 > 1      ;[47]
  17573.     nasc  <2400 > 1      ;[47]
  17574.     nasc  <3600 > 1      ;[47]
  17575.     nasc  <4800 > 1      ;[47]
  17576.     nasc  <7200 > 1      ;[47]
  17577.     nasc  <9600 > 1      ;[47]
  17578.     nasc  <19200> 1      ;[47]
  17579. debms1: nasc  <ADDITIONAL DATA> 1
  17580. ;[87]debms2: nasc  <      SEQ NUMBER           > 1
  17581. debms2: nasc  <SEQ NUMBER     > 1    ;[87]
  17582. ;[87]debms3: nasc  <      NUMBER OF DATA CHARS > 1
  17583. debms3: nasc  <NUMBER OF DATA CHARS > 1    ;[87]
  17584. ;[87]debms4: nasc  <      PACKET CHECKSUM      > 1
  17585. debms4: nasc  <PACKET CHECKSUM> 1    ;[87]
  17586. ;[84]snin01: nasc  <SENDING... PACKET NUMBER > 1
  17587. ;[84]rcin01: nasc  <WAITING... PACKET NUMBER > 1
  17588. ;[87]snin01: nasc  <SENDING   NUMBER OF BYTES> 1
  17589. ;[87]rcin01: nasc  <RECEIVING NUMBER OF BYTES> 1
  17590. snin01: nasc  <SENDING      % NUMBER OF BYTES> 1    ;[87]
  17591. rcin01: nasc  <RECEIVING    % NUMBER OF BYTES> 1    ;[87]
  17592. ;[87]erin01    nasc    <RETRYS 0000> 1        ;[59]
  17593. erin01    nasc    <RETRYS > 1        ;[87]
  17594. erin02    nasc    <REMOTE MESSAGE > 1        ;[59]
  17595. ;[87]shin00: nasc  <DEBUGGING IS             > 1
  17596. ;[87]shin00: nasc  <DEBUGGING IS          > 1    ;[87]
  17597. ;[76]shin01: nasc  <VT52-EMULATION IS        > 1
  17598. ;[87]shin01: nasc  <TERMINAL-EMULATION IS    > 1
  17599. ;[87]shin01: nasc  <TERMINAL-EMULATION IS > 1    ;[87]
  17600. ;[68]shin02: nasc  <IBM-MODE IS              > 1
  17601. ;[87]shin03: nasc  <LOCAL-ECHO IS            > 1
  17602. ;[87]shin03: nasc  <LOCAL-ECHO IS         > 1    ;[87]
  17603. ;[72]shin04: nasc  <EIGHT-BIT-QUOTING IS     > 1
  17604. ;[87]shin05: nasc  <FILE-WARNING IS          > 1
  17605. ;[87]shin05: nasc  <FILE-WARNING IS       > 1    ;[87]
  17606. ;[87]shin06: nasc  <ESCAPE CHARACTER IS      > 1
  17607. ;[87]shin06: nasc  <ESCAPE CHARACTER IS   > 1    ;[87]
  17608. ;[87]shin07: nasc  <SEND> 1
  17609. ;[87]shin08: nasc  <      EIGHT-BIT-QUOTING CHAR IS  > 1
  17610. ;[87]shin08: nasc  <EIGHT-BIT-QUOTING CHAR IS  > 1    ;[87]
  17611. ;[87]shin09: nasc  <      END-OF-LINE CHAR IS        > 1
  17612. ;[87]shin09: nasc  <END-OF-LINE CHAR IS  > 1    ;[87]
  17613. ;[87]shin10: nasc  <      PACKET-LENGTH IS           > 1
  17614. ;[87]shin10: nasc  <PACKET-LENGTH IS     > 1    ;[87]
  17615. ;[87]shin11: nasc  <      PADDING CHAR IS            > 1
  17616. ;[87]shin11: nasc  <PADDING CHAR IS> 1    ;[87]
  17617. ;[87]shin12: nasc  <      AMOUNT OF PADDING IS       > 1
  17618. ;[87]shin12: nasc  <AMOUNT OF PADDING IS > 1    ;[87]
  17619. ;[87]shin13: nasc  <      QUOTE CHAR IS              > 1
  17620. ;[87]shin13: nasc  <QUOTE CHAR IS  > 1    ;[87]
  17621. ;[87]shin14: nasc  <      TIMEOUT IN SECONDS IS      > 1    ;[64]
  17622. ;[87]shin14: nasc  <TIMEOUT IN SECONDS IS> 1    ;[87]
  17623. ;[87]shin2h: nasc  <      START-OF-PACKET CHAR IS    > 1    ;[82]
  17624. ;[87]shin2h: nasc  <START-OF-PACKET CHAR IS    > 1    ;[87]
  17625. ;[87]shin2j: nasc  <      TRANSLATE CR<-> 0            ;[84]
  17626. shin2j: nasc  <TRANSLATE CR<-> 0            ;[87]
  17627.     .byte    $80!'>    ;[84] so we get the >
  17628.     nasc               <CR,LF IS    > 1    ;[84]
  17629. ;[87]shin15: nasc  <RECEIVE> 1
  17630. ;[87]shin16: nasc  <FILE-TYPE MODE IS        > 1
  17631. ;[87]shin16: nasc  <FILE-TYPE MODE IS     > 1    ;[87]
  17632. ;[65]shin17: nasc  <FILE-BYTE-SIZE IS        > 1
  17633. ;[87]shin18: nasc  <SLOT FOR I/O IS          > 1  ;[12] Add for 'SHOW SLOT'
  17634. ;[87]shin18: nasc  <SLOT FOR I/O IS       > 1  ;[87] Add for 'SHOW SLOT'
  17635. ;[87]shin19: nasc  <DEVICE-DRIVER IS         > 1  ;[12] For 'SHOW DEVICE-DRIVER'
  17636. ;[87]shin19: nasc  <DEVICE-DRIVER IS      > 1  ;[87] For 'SHOW DEVICE-DRIVER'
  17637. ;[87]shin20: nasc  <PARITY IS                > 1  ;[21] For 'SHOW PARITY'
  17638. ;[87]shin20: nasc  <PARITY IS             > 1  ;[87] For 'SHOW PARITY'
  17639. ;[87]shin21: nasc  <KEYBOARD TYPE IS         > 1  ;[35] For 'SHOW KEYBOARD'.
  17640. ;[87]shin21: nasc  <KEYBOARD TYPE IS      > 1  ;[87] For 'SHOW KEYBOARD'.
  17641. ;[87]shin2a: nasc  <DEFAULT PREFIX IS        > 1  ;[59] For 'SHOW prefix'.
  17642. ;[87]shin2a: nasc  <DEFAULT PREFIX IS     > 1  ;[87] For 'SHOW prefix'.
  17643. ;[87]shin22: nasc  <DEFAULT DRIVE            SLOT=  > 1  ;[40] Default drive
  17644. ;[87]shin22: nasc  <DEFAULT DRIVE         SLOT=  > 1  ;[87] Default drive
  17645. ;[87]shin23: nasc  <                         DRIVE= > 1  ;[40]     messages
  17646. shin23: nasc  <                      DRIVE= > 1  ;[87]     messages
  17647. ;[87]shi231: nasc  <                      VOL= > 1  ;[60]     messages
  17648. shi231: nasc  <                      VOL= > 1  ;[87]     messages
  17649. ;[87]shin24: nasc  <DISPLAY TYPE IS          > 1  ;[46] For 'SHOW DISPLAY'.
  17650. ;[87]shin24: nasc  <DISPLAY TYPE IS       > 1  ;[87] For 'SHOW DISPLAY'.
  17651. ;[87]shin25: nasc  <BAUD RATE IS             > 1  ;[47] FOR SHOW
  17652. ;[87]shin25: nasc  <BAUD RATE IS          > 1  ;[87] FOR SHOW
  17653. ;[87]shin26: nasc  <PRINTER IS               > 1  ;[55] FOR SHOW
  17654. ;[87]shin26: nasc  <PRINTER IS            > 1  ;[87] FOR SHOW
  17655. ;[87]shin27: nasc  <FLOW IS                  > 1    ;[57] FOR SHOW
  17656. ;[87]shin27: nasc  <FLOW IS               > 1    ;[87] FOR SHOW
  17657. ;[87]shin28:    nasc    <LOG IS                   > 1    ;[56] FOR SHOW log
  17658. ;[87]shin28:    nasc    <LOG IS                > 1    ;[87] FOR SHOW log
  17659. shin29:    nasc    <FILE=> 1    ;[56] for show log
  17660. ;[87]shin2b: nasc  <TIMER IS                 > 1    ;[64]
  17661. ;[87]shin2b: nasc  <TIMER IS              > 1    ;[87]
  17662. ;[87]shin2c    nasc  <SWAP KEYS BS & DEL IS    > 1    ;[73]
  17663. ;[87]shin2c    nasc  <SWAP KEYS BS & DEL IS > 1    ;[87]
  17664. shin2d    nasc    < WRAP-AROUND > 1    ;[78]
  17665. ;[87]shin2e    nasc  <KEYPAD EXISTS? ON=YES    > 1    ;[80]
  17666. ;[87]shin2e    nasc  <KEYPAD EXISTS? ON=YES > 1    ;[87]
  17667. ;shin2f    nasc  <KEYPAD-APPLICATION-MODE  > 1    ;[80]
  17668. ;[87]shin2f    nasc  <APPLICATION-MODE > 1    ;[81]
  17669. ;[87]shin2g    nasc  <CURSOR-KEYS-VT100        > 1    ;[80]
  17670. ;[87]shin2g    nasc  <CURSOR-KEYS-VT100     > 1    ;[87]
  17671. ;[87]shin2i    nasc  <PROTOCOL IS              > 1    ;[83]
  17672. ;[87]shin2i    nasc  <PROTOCOL IS           > 1    ;[87]
  17673. ;[87]shin2k    nasc  <TIMING CONSTANT IS       > 1    ;[85]
  17674. ;[87]shin2k    nasc  <TIMING CONSTANT IS    > 1    ;[87]
  17675. shin2l    nasc    <SLOT X,DRIVE X,> 0    ;[87] 1 of 2
  17676. shin2m    nasc    <VOLUME 123456789abcdef> 1 ;[87] 2 of 2
  17677. shin2o    nasc    < IS                > 1    ;[87]
  17678. shoff:  nasc  <OFF > 1
  17679. shon:  nasc  <ON > 1
  17680. shsm01    nasc <SERVER MODE> 1    ;[75]
  17681. ;[65]shsbit: nasc  <SEVEN-BIT> 1
  17682. ;[65]shebit: nasc  <EIGHT-BIT> 1
  17683. sstrng: nasc  <SENDING: > 1        ;[26] For Terse debug
  17684. rstrng: nasc  <RECEIVED: > 1        ;[26]         ...
  17685. stin00: nasc  <NUMBER OF DATA CHARS SENT IS     > 1
  17686. stin01: nasc  <NUMBER OF DATA CHARS RECV'ED IS  > 1
  17687. stin02: nasc  <TOTAL NUMBER OF CHARS SENT IS    > 1
  17688. stin03: nasc  <TOTAL NUMBER OF CHARS RECV'ED IS > 1
  17689. stin04: nasc  <OVERHEAD FOR SEND PACKETS IS     > 1
  17690. stin05: nasc  <OVERHEAD FOR RECEIVE PACKETS IS  > 1
  17691. stin06: nasc  <LAST ERROR ENCOUNTERED IS  > 1
  17692. ;[86]inf01a: nasc  <[CONNECTING TO HOST: TYPE > 1
  17693. ;[86]inf01b: nasc  <C TO RETURN]> 1    ;[4] Second half of connect message
  17694. inf01a: nasc  <[TERMINAL MODE:TYPE > 1    ;[86]
  17695. inf01b: nasc  <C FOR COMMAND MODE]> 1;[86][4] Second half of connect message
  17696. endker: .byte          ;[54] end of main kermit
  17697.     .list
  17698. .SBTTL    End   of Kermit-65 Source
  17699.