home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / trs80model4.zip / m4add.asm next >
Assembly Source File  |  1986-10-22  |  18KB  |  583 lines

  1. ;    m4add/asm
  2. ;
  3. ;    Input a line from a take file
  4. ;
  5. DOTAKE    EQU    $
  6.     LD    HL,CMDBUF    ;WHERE TO PUT THE TEXT
  7.     LD    B,0        ;CHARACTER COUNTER
  8.     CALL    CONIN
  9.     IFA    128,TAKERR    ;Jump if break was pressed
  10. TAKLOP    LD    DE,TFCB        ;FCB FOR TAKE FILE
  11.     CALL    XGET        ;Call @GET svc
  12.     JR    NZ,TAKERR    ;QUIT ON AN ERROR
  13.     LD    (HL),A        ;SAVE THE CHARACTER
  14.     INC    HL        ;POINT TO THE NEXT
  15.     INC    B        ;ADD TO CHARACTER COUNT
  16.     IFA    CR,TAK020    ;Go if at the end of string
  17.     LD    C,A
  18.     LD    A,(TAKLOG)    ;IS DISPLAY OF TAKE FILES ON?
  19.     OR    A
  20.     LD    A,C
  21.     CALL    NZ,CONOUT
  22.     JR    TAKLOP
  23. TAK020    RET            ;RETURN WITH THE STRING
  24. TAKERR    LD    DE,TFCB        ;GET READY TO CLOSE THE FILE
  25.     CALL    XCLOSE        ;Close the file
  26.     XOR    A        ;TURN THE TAKE FLAG OFF
  27.     LD    (TAKFLG),A    ;RESET IT
  28.     LD    A,29
  29.     CALL    CONOUT
  30.     SCF            ;SET CARRY FOR A PARSE ERROR
  31.     RET
  32. ;
  33. ;    This routine is used by the command parser routines to input a
  34. ;    string from the keyboard.  It recognizes the TAKFLG which tells
  35. ;    it to input a string from the active take file.
  36. ;    Input to the routine is HL which points to the string buffer,
  37. ;    and B which has an initial count of the number of characters
  38. ;    already in the buffer.
  39. ;
  40. GETSTR    LD    A,(TAKFLG)    ;Is there a TAKE file active
  41.     OR    A
  42.     JP    NZ,DOTAKE    ;If so than go fill buffer from file.
  43.     LD    IY,(FLAGS)    ;Get the flags address.
  44.     BIT    5,(IY+18)    ;Check if JCL active.
  45.     JR    Z,SKIP_JCL    ;Jump if JCL not active.
  46.     LD    HL,CMDBUF    ;Get the input buffer.
  47.     LD    BC,5000H    ;Set B to max count, and C to zero.
  48.     JP    XKEYIN        ;Get a line from JCL and return.
  49. ;
  50. SKIP_JCL    PUSH    HL    ;Save the registers
  51.     PUSH    DE    
  52.     LD    A,B        ;Save the number of character already in
  53.     LD    (TEMP4),A    ;the buffer for later
  54. GET010    CALL    XKEY        ;Get a character from the keyboard
  55.     JP    NZ,GETEXT    ;Humm, what do we do on an error
  56.     IFANOT    8,GET030    ;Go if not backspace
  57.     LD    E,A        ;Save the KEY we got
  58.     LD    A,B        ;Get the number of characters
  59.     IFZ    GET010        ;Go if no place to backspace over
  60.     DEC    B        ;At least one space left
  61.     DEC    HL        ;Back up the buffer pointer
  62.     LD    A,E        ;Get the character
  63.     CALL    CONOUT        ;Display it
  64.     JR    GET010        ;Go get a new key
  65. GET030    IFA    CR,GET040    ;Go if enter pressed
  66.     IFANOT    24,GET036    ;Jump if not SHIFT <-
  67. GET035    LD    A,B        ;NUMBER LEFT
  68.     IFZ    GET010        ;Go if all were erased
  69.     LD    A,8        ;BACKSPACE
  70.     CALL    CONOUT        ;PRINT IT
  71.     DEC    B        ;ONE MORE LEFT
  72.     DEC    HL        ;BACKUP IN THE BUFFER
  73.     JR    GET035        ;KEEP LOOPING
  74. GET036    IFA    ESC,GET040    ;Go if it was escape
  75.     IFANOT    129,GET038    ;Go if not F1 (Also escape)
  76.     LD    A,ESC        ;GET AN ESCAPE
  77.     JR    GET040        ;JOIN THE CODE FOR EXIT
  78. GET038    IFA    128,GET040    ;Go it it was a break
  79.     IFALT    20H,GET010    ;Ignore other control keys
  80. GET040    INC    B        ;ONE LESS CHARACTER LEFT
  81.     LD    (HL),A        ;PUT THE CHARACTER IN THE BUFFER
  82.     JR    NZ,GET050    ;WHEN nZ IS SET, NO MORE CHARS LEFT
  83.     DEC    B        ;SAY WE STILL HAVE ONE
  84.     JR    GET060        ;MIGHT BE '?' WHICH IS IGNORED AS LAST
  85. GET050    IFA    CR,GETEXT    ;Finish up if CR pressed
  86.     IFA    ESC,GETEXT    ;Same for escape
  87.     IFA    128,GETEXT    ;Same for break
  88.     INC    HL        ;ONE MORE IN THE BUFFER
  89.     CALL    CONOUT        ;PRINT WHAT WAS TYPED
  90. GET060    CP    '?'        ;WAS IT A '?' ?
  91.     JP    NZ,GET010    ;GET A NEW KEY IF NOT
  92.     LD    A,8        ;GET A BACKSPACE
  93.     CALL    CONOUT        ;PRINT IT TO REMOVE THE '?'
  94.     DEC    HL        ;POINT AT THE '?'
  95.     PUSH    HL        ;HL -> IY
  96.     POP    IY
  97.     LD    A,' '        ;LOOK FOR A PREVIOUS SPACE
  98.     IFA    (IY-1),GETEXT    ;Look for a previous space
  99.     LD    A,B        ;ARE WE AT THE START OF THE LINE
  100.     DEC    A
  101. ;IF Z IS SET THAN THE CURSOR IS AT HOME ON THE LINE.    NO SPACE WILL
  102. ;BE ADDED IN THIS CASE.
  103.     LD    A,' '        ;PUT A SPACE ON THE DISPLAY
  104.     CALL    NZ,CONOUT    ;PRINT IT
  105. GETEXT    LD    A,B        ;GET NUMBER ON THE LINE
  106.     DEC    A
  107.     JR    NZ,GET110    ;AT LEAST ONE CHAR ON THE LINE
  108.     PUSH    AF        ;PUT AF INTO BC
  109.     POP    BC
  110.     LD    A,(HL)        ;WAS '?' THE TERMINATOR?
  111.     CP    '?'
  112.     LD    A,B        ;GET THE LENGTH IN A
  113.     JR    NZ,GET120
  114. GET110    INC    A        ;COUNT THE TERMINATOR IF IT IS '?'
  115. GET120    LD    B,A        ;SAVE THE LENGTH
  116.     LD    A,(HL)        ;GET THE TERMINATOR
  117.     IFA    ESC,GET130    ;Skip normal return if escape
  118.     SLA    A        ;CHECK FOR BREAK (128 IS NEGATIVE)
  119.     JR    C,GET130    ;ALSO GIVES C STATUS LIKE @KEYIN
  120.     SRL    A        ;FIX IT BACK
  121.     OR    10H        ;MAKE CR, CHR$(29), '?' IS UNDISTURBED
  122.     CALL    CONOUT        ;PRINT THE CHARACTER
  123. GET130    POP    DE        ;RESTORE THE REGS
  124.     POP    HL
  125.     RET            ;RETURN TO THE CALLER
  126. ;
  127. STDOUT    LD    A,16        ;REVERSE VIDEO ON
  128.     JP    CONOUT        ;USE THE RETURN ON THE STACK
  129. STDEND    LD    A,17        ;REVERSE VIDEO OFF
  130.     JP    CONOUT        ;USE THE RETURN ON THE STACK
  131. ;
  132. ;ENTRY POINT FOR INTERUPT DRIVEN RECEIVE CHARACTER ROUTINE.
  133. ;
  134. GETINT    JR    NZ,GTIN10    ;NO CHARACTER AVAILABLE
  135.     LD    HL,(CURCHR)    ;CURRENT POS IN BUFFER
  136.     LD    (HL),C        ;CHARACTER IS IN C, STORE IT
  137.     INC    L        ;POINT TO NEXT WRITE POSITION
  138.     LD    A,(NXTCHR)    ;CHECK FOR OVERFLOW
  139.     IFA    L,GTIN10
  140.     LD    (CURCHR),HL    ;SAVE ADDRESS OF NEXT STORE
  141.     LD    A,(MAXCNT)
  142.     LD    E,A
  143.     LD    HL,INCNT    ;Get the address of the count
  144.     INC    (HL)        ;Add one to the count
  145.     LD    A,(HL)        ;Get the count
  146.     IFALT    E,GTIN10    ;Jump if below count
  147.     LD    A,(FLOFLG)    ;ARE WE DOING FLOW CONTROL?
  148.     IFZ    GTIN10        ;Go if not doing flow control
  149.     LD    A,C        ;GET THE CHARACTER JUST RECEIVED
  150.     IFA    XOFF,GTIN06    ;Jump if XOFF received
  151.     IFANOT    XON,GTIN07    ;Jump if not time for XON
  152.     XOR    A
  153. GTIN06    LD    (XOFREC),A    ;Store the new flag value
  154. GTIN07    LD    A,(XFFLG)    ;SEE IF WE ALREADY SENT IT
  155.     IFNZ    GTIN10        ;Go if XOFF already sent
  156.     INC    A        ;MAKE IT NON-ZERO
  157.     LD    (XFFLG),A    ;SET IT
  158.     LD    E,XOFF        ;Get an XOFF character
  159.     CALL    OUTCHR        ;SENT IT OUT
  160. GTIN10    RET
  161. ;
  162. ;LOG THE CHARACTER IN THE LOG FILE
  163. ;
  164. LOGIT    PUSH    AF        ;Save the character to log
  165.     LD    A,(LOGFLG)    ;Check if logging active
  166.     IFANOT    2,LOGITO    ;Go if logging not on, or file not open
  167.     POP    AF        ;Get the character back
  168.     PUSH    AF        ;Put the character back
  169.     IFANOT    LF,LOGT0    ;Is it LINE FEED? Jump if not
  170.     LD    A,(PREVLCHR)    ;Check if previous character was <CR>
  171.     IFA    CR,LOGITO    ;Throw out <LF> if previous was <CR>
  172.     LD    A,LF        ;Get a line feed character back
  173. LOGT0    PUSH    DE        ;Save the registers
  174.     LD    (PREVLCHR),A    ;Save the previous character
  175.     LD    DE,LFCB        ;Get the FCB address
  176. LOGT1    CALL    XPUT        ;@PUT the character to the file
  177.     JR    Z,LOGEXT    ;Exit if no errors on output
  178. LOGT2    CALL    XERROR0        ;Print the system message given in A
  179.     LD    DE,LFCB        ;Get the FCB back
  180.     CALL    XCLOSE        ;Make sure that the file is closed
  181.     STROUT    ERMS20        ;Say that the file was closed
  182.     XOR    A        ;Reset the logging flag
  183.     LD    (LOGFLG),A    ;Store the new value
  184. LOGEXT    POP    DE        ;Restore DE
  185. LOGITO    POP    AF        ;Restore the character
  186.     RET            ;Back to caller
  187. ;
  188. ;    These are the TRSDOS 6.x SVC definitions
  189. ;
  190. XPARAM    DOSVC    17        ;@PARAM SVC (Parse ()'d argument list).
  191. XFSPEC    DOSVC    78        ;@FSPEC SVC (Convert filename to TRSDOS)
  192. XINIT    DOSVC    58        ;@INIT SVC (Create a file on disk device)
  193. XOPEN    DOSVC    59        ;@OPEN SVC (Open a file)
  194. XREAD    DOSVC    67        ;@READ SVC (Read a record)
  195. XSKIP    DOSVC    72        ;@SKIP SVC (Skip a logical record)
  196. XCLOSE    DOSVC    60        ;@CLOSE SVC (Close a file)
  197. XVER    DOSVC    73        ;@VER SVC (Write with verification)
  198. XCTL    DOSVC    5        ;@CTL SVC, perform control operation
  199. XPRT    PUSH    BC        ;Send character to printer
  200.     PUSH    AF
  201.     LD    C,A
  202.     LD    A,6
  203.     JR    SVCSAV
  204. XVDCTL    DOSVC    15        ;@VDCTL SVC (Perform video operations)
  205. XGET    DOSVC    3        ;@GET SVC (Get a character from a file)
  206. ;
  207. ;    SVC'S that require the character passed in A to be in C should
  208. ;    look like this.
  209. ;
  210. XPUT    PUSH    BC        ;SAVE BC
  211.     PUSH    AF        ;SAVE AF
  212.     LD    C,A
  213.     LD    A,4        ;@PUT SVC
  214. SVCSAV    RST    28H        ;CALL AN SVC
  215.     POP    BC        ;POPPING BC DOES NOT AFFECT THE FLAGS
  216.     LD    (XERRNO),A    ;Store last error number
  217.     LD    A,B        ;B HAS OLD A SO RESTORE
  218.     POP    BC        ;GET OLD BC
  219.     RET            ;RETURN TO THE CALLER
  220. XKEYIN    DOSVC    9        ;Get a string from *DO (@KEYIN SVC)
  221. XHIGH    DOSVC    100        ;@HIGH$ SVC
  222. XLOAD    DOSVC    76        ;@LOAD SVC (Load an executable)
  223. XCHKDRV    DOSVC    33        ;@CHKDRV SVC (Check if drive is ready)
  224. XTIME    DOSVC    19        ;@TIME SVC (Get current system time)
  225. XADTSK    DOSVC    29        ;@ADTSK SVC (Add a task to the table)
  226. XCKTSK    DOSVC    28        ;@CKTSK SVC (Check if task slot available)
  227. XRMTSK    DOSVC    30        ;@RMTSK SVC (Remove task from table)
  228. XKLTSK    DOSVC    32        ;@KLTSK SVC (Kill current exec task)
  229. XPAUSE    DOSVC    16        ;@PAUSE SVC (Delay for count in BC)
  230. XFLAGS    DOSVC    101        ;@FLAGS SVC (Get system flags address)
  231. XREMOVE    DOSVC    57        ;@REMOV SVC (Remove opened file)
  232. XKILL    EQU    XREMOVE
  233. XDECHEX    DOSVC    96        ;@DECHEX SVC (Convert ASCII to binary)
  234. XHEXDEC    DOSVC    97        ;@HEXDEC SVC (Convert binary to ASCII)
  235. XKBD    DOSVC    8        ;@KBD SVC (Get a keyboard char, no wait)
  236. XKEY    DOSVC    1        ;@KEY SVC (Get a keyboard char, wait)
  237. XCMNDR    DOSVC    25        ;@CMNDR SVC (Execute system command)
  238. XMUL16    DOSVC    91        ;@MUL16 SVC (Multiply 8 bit by 16 bi&t)
  239. XDSP    PUSH    BC        ;SAVE BC
  240.     PUSH    AF        ;SAVE AF
  241.     LD    C,A
  242.     LD    A,2        ;@DSP SVC
  243.     JP    SVCSAV
  244. XGTDCB    DOSVC    82        ;@GTDCB SVC (Get the DCB for given device)
  245. XEXIT    LD    L,A        ;A HAS OUR RETURN CODE
  246.     LD    H,0        ;MAKE HL THE RETURN CODE
  247.     DOSVC    22        ;Do @EXIT SVC
  248. XERROR0    LD    A,0        ;Get the last error number
  249. XERRNO    EQU    $-1
  250. XERROR    PUSH    BC        ;SAVE BC AND AF
  251.     PUSH    AF
  252.     LD    IY,(FLAGS)    ;GET @FLAGS ADDRESS
  253.     RES    6,(IY+2)    ;RESET ALL SPECIAL BITS
  254.     RES    7,(IY+2)
  255.     RES    6,(IY+18)
  256.     OR    0C0H        ;MAKE SIMPLE MESSAGES
  257.     LD    C,A        ;C NEEDS THE ERROR NUMBER
  258.     CALL    NEWLIN        ;Get a new line for the messages
  259.     LD    A,26        ;@ERROR SVC    (ISSUE A SYSTEM MESSAGE)
  260.     JP    SVCSAV        ;GO CALL IT
  261. ;
  262. ;    Set up interrupt and device information
  263. ;
  264. SETINT    EQU    $
  265. ;
  266. ;    This code sets up the interrupt driven receiver.  It calls @CTL
  267. ;    to pass the address of the "GETINT" routine, which is called
  268. ;    each time a character is received by the UART
  269. ;
  270.     LD    IY,GETINT        ;Where to transfer control to
  271.     LD    DE,(CLDCB)        ;Which device to get
  272.     LD    C,4            ;Ctl function 4
  273.     CALL    XCTL            ;Do @CTL
  274. ;
  275. ;    Install *FO and *FI devices
  276. ;
  277.     LD    DE,0        ;Find a new DCB for this device
  278.     CALL    XGTDCB
  279.     JR    NZ,NODCB    ;Abort if an error occured
  280.     LD    (FOTDCB),HL    ;Save the pointer to the DCB
  281.     PUSH    HL        ;Move it to IX to do indexing
  282.     POP    IX
  283.     LD    (IX+6),'F'    ;Store the name in the DCB
  284.     LD    (IX+7),'O'
  285.     LD    A,2        ;Select @PUT capabilities only
  286.     LD    (IX),A
  287.     LD    HL,FILOUT    ;Get the entry point
  288.     LD    (IX+1),L    ;Store it
  289.     LD    (IX+2),H
  290.     LD    DE,0        ;Get a new DCB for the input device
  291.     CALL    XGTDCB
  292.     JR    NZ,NODCB    ;Abort if an error occurs
  293.     LD    (FINDCB),HL    ;Save the address of the DCB
  294.     PUSH    HL        ;Put the address in IX for indexing
  295.     POP    IX
  296.     LD    (IX+6),'F'    ;Store the device name in the DCB
  297.     LD    (IX+7),'I'
  298.     LD    A,1        ;Select @GET capabilites only
  299.     LD    (IX),A
  300.     LD    HL,FILIN    ;Get the entry point
  301.     LD    (IX+1),L    ;Store the address
  302.     LD    (IX+2),H
  303.     RET            ;Done!
  304. ;
  305. ;    Print no DCB's available message
  306. ;
  307. NODCB    STROUT    NONDCB        ;Print NO NEW DCB's message
  308.     JP    EXIT1        ;Exit from KERMIT
  309. ;
  310. ;    Get a new line to print on
  311. ;
  312. NEWLIN    PUSH    AF        ;Save the acumulator
  313.     LD    A,CR        ;Get a <CR><LF> equivilent
  314.     CALL    CONOUT        ;Output it to the screen
  315.     POP    AF        ;Restore A
  316.     RET            ;Return to caller
  317. ;
  318. ;    Set the default disk drive command
  319. ;
  320. SETDSK    EQU    $
  321.     LD    A,CMNUM        ;PARSE A NUMBER
  322.     CALL    COMND
  323.     JP    KERMT3
  324.     OR    A        ;If no number than say bad command
  325.     JP    Z,KERMT2
  326.     LD    A,D        ;Check for number above 255
  327.     IFNZ    SETDRV_2    ;Jump if number bigger than 255
  328.     LD    C,E        ;Get the lower order byte
  329.     CALL    XCHKDRV        ;Check the disk drive
  330.     JR    NZ,SETDRV_2    ;Jump if TRSDOS doesn't like it
  331.     PUSH    BC        ;Save the binary number
  332.     JR    NC,SETDRV_1    ;If carry set the drive is write protected
  333.     STROUT    WRTPROT        ;Say drive is write protected
  334. SETDRV_1    STROUT    DSKOK    ;Say default drive changed
  335.     POP    BC        ;Get the drive number back
  336.     LD    A,C        ;Get the binary value into a
  337.     ADD    A,48        ;Make it and ASCII digit
  338.     LD    (DEFDSK),A    ;Save it as the new default
  339.     JP    KERMIT        ;Get a new command
  340. ;
  341. ;    Print bad drive message
  342. ;
  343. SETDRV_2    LD    A,32    ;Get the illegal drive message number
  344.     CALL    XERROR        ;Have TRSDOS print the message
  345.     JP    KERMIT        ;Go get a new command
  346. ;
  347. ;    Clear any buffered characters from input buffer
  348. ;
  349. CLRPRT    PUSH    AF
  350.     LD    A,(NXTCHR)    ;Set the next, and current positions
  351.     LD    (CURCHR),A    ;within the buffer to be the same
  352.     XOR    A        ;Set buffered character count to zero
  353.     LD    (INCNT),A
  354.     LD    (XOFREC),A    ;Reset XOFF'd state
  355.     LD    (XFFLG),A    ;Haven't sent XOFF either
  356.     POP    AF
  357.     RET
  358. ;
  359. ;    Display the directory
  360. ;
  361. ;This code makes an educated guess as to whether it is running on a
  362. ;6.1 or a 6.2 TRSDOS machine.    This is to determine if we should
  363. ;issue the DIR command for 6.1 or the CAT command for 6.2
  364. ;
  365. DIR    EQU    $
  366.     LD    A,CMTXT        ;Get text for DIR/CAT command
  367.     LD    DE,DIRBUF
  368.     CALL    COMND
  369.     JP    KERMT3
  370.     IFNZ    DIR1C        ;Jump if some text given
  371. DIR1B    LD    A,(DEFDSK)    ;Otherwise, use default drive
  372.     LD    (DIRBUF),A    ;Put in the text
  373.     LD    A,CR        ;Put in the terminator
  374.     LD    (DIRBUF+1),A
  375. DIR1C    CALL    NEWLIN        ;Get new lines
  376.     CALL    NEWLIN
  377.     LD    IY,(FLAGS)    ;Check if using 6.1, or 6.2 TRSDOS
  378.     LD    A,(IY+27)    ;Get the version number
  379.     AND    0FH        ;KEEP JUST THE X OF 6.X
  380.     LD    HL,DO62DR    ;Get 6.2 command (CAT)
  381.     IFA    2,DIR1E        ;Jump if 6.2
  382.     LD    HL,DO61DR    ;Get 6.1 command (DIR)
  383. DIR1E    LD    DE,DIRCMD    ;Where to put the text
  384.     LD    BC,4        ;How much to move
  385.     PUSH    DE        ;Save the start
  386.     LDIR            ;Move the command
  387.     POP    HL        ;Restore the start
  388.     CALL    XCMNDR        ;Let TRSDOS do it for us
  389. DIR1D    JP    KERMIT        ;Get a new command
  390. ;
  391. ;    Erase a file from the system
  392. ;
  393. ERA    EQU    $
  394.     LD    A,CMTXT        ;Get some text
  395.     LD    DE,MFNBUF
  396.     PUSH    DE        ;Save the buffer address
  397.     CALL    COMND
  398.     JP    KERMT3
  399.     IFZ    ERA3        ;Jump if no text given
  400.     CALL    NEWLIN        ;Get a newline
  401.     POP    HL        ;Get the address back
  402.     LD    (MFNPTR),HL
  403.     XOR    A
  404.     LD    (LOGNAMES),A    ;Reset the log names flag
  405.     CALL    BUILDF        ;Do wild carding
  406.     LD    A,(FILECNT)    ;Check if anything found
  407.     IFZ    ERA3
  408.     LD    (MFNPTR),HL    ;Save the start of the list
  409. ERA2    CALL    MFNAME        ;Get one filename from the buffer
  410.     JR    C,ERA3        ;Jump if no more
  411.     LD    DE,MFREQ    ;Get the name
  412.     LD    B,0        ;Select 256 LRL
  413.     LD    HL,DATA        ;Get the address of a temp buffer
  414.     CALL    XOPEN        ;Try to open it
  415.     JR    Z,ERA1        ;Jump if opened
  416.     CP    42        ;Was it an LRL error message?
  417.     JR    Z,ERA1        ;Jump if it was
  418. ERA0    CALL    XERROR0        ;Issue the message indicated in A
  419.     JR    ERA3        ;Get a new command
  420. ;
  421. ;    Print the removing message, then remove it
  422. ;
  423. ERA1    LD    HL,FCB        ;Convert ETX to EOS in FCB
  424.     LD    BC,32        ;Max distance
  425.     LD    A,3        ;What to find
  426.     CPIR            ;Look
  427.     DEC    HL        ;Ignore errors
  428.     LD    (HL),EOS    ;Change it
  429.     STROUT    REMOVSTR    ;Output 'Removing: ' message
  430.     STROUT    FCB        ;Output the filename
  431.     CALL    NEWLIN        ;Get a newline
  432.     LD    DE,MFREQ    ;Get the FCB
  433.     CALL    XKILL        ;Remove the file
  434.     JR    Z,ERA2        ;Abort if error occurs
  435.     JR    ERA0        ;Get the next one
  436. ;
  437. ERA3    JP    KERMIT        ;Get a new command
  438. ;
  439. ;    This routine sets up KERMIT/INI as initialization.  The trick
  440. ;    is to just make it look like the user typed 'TAKE KERMIT/INI'.
  441. ;
  442. CHKTAK    CALL    XFLAGS        ;Get the flags area into IY
  443.     LD    A,(IY+10)    ;Get the KFLAG$
  444.     AND    0F8H        ;Reset the <ENTER>, <BREAK> and
  445.     LD    (IY+10),A    ;the <PAUSE> bits, and store it
  446.     LD    B,46        ;Pause for a good deal of time
  447.     CALL    XPAUSE
  448.     LD    A,(IY+10)    ;Get the KFLAG$ mask back
  449.     AND    7        ;Any of the keys pressed?
  450.     RET    NZ        ;Stop if BREAK, ENTER, or PAUSE
  451.     LD    DE,TFCB        ;LOAD THE FCB ADDRESS
  452.     LD    HL,TKNAME    ;NAME OF THE FILE
  453.     LD    BC,TKLEN    ;LENGTH OF THE STRING
  454.     LDIR
  455.     LD    DE,TFCB        ;GET IT AGAIN
  456.     LD    HL,TBUF        ;GET THE INPUT BUFFER
  457.     LD    B,0        ;256 BYTE LRL
  458.     CALL    XOPEN        ;OPEN THE FILE
  459.     JR    Z,CHKT_1    ;Jump if everything OK
  460.     CP    42
  461.     RET    NZ        ;Return if NOT LRL error
  462. CHKT_1    LD    A,1        ;SET THE TAKE COMMAND ACTIVE FLAG
  463.     LD    (TAKFLG),A
  464.     RET            ;GO DO IT.
  465. ;
  466. ;    Print ESCAPE character sequence as CONTROL-?
  467. ;
  468. ESCPR    LD    A,(ESCCHR)    ;GET THE ESCAPE CHAR.
  469. ESCPR1    IFAGE    ' ',ESCPR2    ;IS IT A CONTROL CHAR?
  470.     PUSH    AF
  471.     STROUT    INMS10        ;Output CONTROL-
  472.     POP    AF        ;GET THE CHAR BACK
  473.     OR    100O        ;DE-CONTROLIFY.
  474. ESCPR2    CALL    CONOUT
  475.     RET    
  476. ;
  477. ;    Swap screens between connect mode, and KERMIT command modes
  478. ;
  479. SWAPIN    LD    A,15        ;cursor off
  480.     CALL    CONOUT        ;Tell *DO to turn it off
  481.     LD    HL,2600H    ;Get the destination
  482.     LD    B,6
  483.     CALL    XVDCTL        ;Move screen image to temp space
  484.     LD    HL,SWTBUF    ;Move the buffer to the screen
  485.     LD    B,5
  486.     CALL    XVDCTL        ;Move it
  487.     LD    HL,2600H    ;Now move temp buffer to swap buffer
  488.     LD    DE,SWTBUF
  489.     LD    BC,1920
  490.     LDIR            ;Move it
  491.     LD    A,14        ;cursor back on
  492.     CALL    CONOUT
  493.     RET            ;Return to the caller
  494. ;
  495. ;    Put connect command screen in view
  496. ;
  497. SCRCON    EQU    $
  498.     CALL    SWAPIN        ;Swap screens
  499.     LD    B,4        ;Select get cursor position option
  500.     CALL    XVDCTL        ;SVC @VDCTL to get position
  501.     LD    (CMDCRS),HL    ;Save the cursor
  502.     LD    HL,(CONCRS)    ;Get the connect cursor postion
  503.     LD    B,3        ;Select SET cursor position
  504.     CALL    XVDCTL        ;SVC @VDCTL to set it
  505.     LD    A,14        ;Make sure that the cursor is ON
  506.     CALL    CONOUT
  507.     RET            ;Return to caller
  508. ;
  509. ;    Swap in Kermit command screen
  510. ;
  511. SCRCMD    EQU    $
  512.     CALL    SWAPIN        ;Swap screens
  513.     LD    B,4        ;Get the current cursor position
  514.     CALL    XVDCTL        ;SVC @VDCTL to get it
  515.     LD    (CONCRS),HL    ;Save it
  516.     LD    HL,(CMDCRS)    ;Get the Kermit command cursor position
  517.     LD    B,3        ;Set the current cursor position
  518.     CALL    XVDCTL        ;SVC @VDCTL to set it
  519.     LD    A,14        ;Make sure the cursor is on
  520.     CALL    CONOUT
  521.     RET            ;Return
  522. ;
  523. ;    *FI Device driver is here
  524. ;
  525. ;    Valid memory module headers are used here, but are not necessary
  526. ;    since the drivers are not in the High or Low memory chain of
  527. ;    modules.
  528. ;
  529. FILIN    JR    INPFIL        ;Jump to code
  530.     DW    ENDIN        ;End of module
  531.     DB    4        ;Module name length
  532.     DB    'INP$'
  533. FINDCB    DW    0        ;Pointer to our DCB
  534.     DW    0
  535. PRECHR    DB    0        ;Previous character received
  536. INPFIL    CALL    INPORT        ;Get an input character
  537.     JR    Z,INP04        ;Jump if successful
  538.     CALL    CONIN        ;Failed, read the keyboard
  539.     IFZ    INPFIL        ;Jump if no key pressed
  540.     IFANOT    128,INP03    ;Jump if not break
  541.     LD    A,28        ;Return at EOF indicator
  542.     OR    A        ;Set NZ status
  543.     RET            ;return to caller
  544. INP03    LD    E,A        ;Get the keyboard character
  545.     CALL    OUTCHR        ;Output it to the port
  546.     JR    INPFIL        ;Read the port again
  547. INP04    LD    C,A        ;Get the input character
  548.     LD    A,(FLOFLG)    ;Are we doing flow control?
  549.     IFNZ    INP05        ;Jump if not doing flow control
  550.     LD    A,C        ;Get the character back
  551.     IFA    XON,INPFIL    ;Ignore XON if sent
  552.     IFA    XOFF,INPFIL    ;Ignore that also
  553. INP05    LD    A,(PRECHR)    ;Get the previous character
  554.     CP    CR        ;Was it CR?
  555.     LD    A,C        ;Get the current character
  556.     JR    NZ,INP09    ;Jump if not CR
  557.     LD    A,(FILTYPE)    ;Check if should convert
  558.     OR    A        ;Is it binary mode?
  559.     LD    A,C
  560.     JR    NZ,INP09    ;It is, so do not translate
  561.     CP    LF        ;Is the current character LF?
  562.     LD    (PRECHR),A    ;Store new previous
  563.     JR    Z,INPFIL    ;Ignore LF after CR
  564. INP09    CP    A        ;Set Z status
  565.     RET            ;Return byte to caller in A
  566. ENDIN    EQU    $
  567. ;
  568. ;    *FO Device driver is here
  569. ;
  570. FILOUT    JR    FIOUT        ;Jump to code
  571.     DW    OUTEND-1    ;Normal header
  572.     DB    4
  573.     DB    'OUT$'
  574. FOTDCB    DW    0
  575.     DW    0
  576. FIOUT    LD    E,C        ;Get the character to send
  577. FIOUT1    CALL    OUTCHR        ;Output it.  We will hang till output
  578.     LD    A,C        ;Get the character sent
  579.     CP    A        ;Set the Z flag
  580.     RET            ;Return the byte sent out, and Z status
  581. OUTEND    EQU    $
  582. ; end of file
  583.