home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / decpro300 / promit.mac < prev    next >
Text File  |  2020-01-01  |  30KB  |  1,070 lines

  1.     .TITLE     KERMIT
  2.     .SBTTL    S Hecht/D Stevens/R McQueen
  3.  
  4. ;++
  5. ; Main module for PRO/Kermit command scanning.  This will communicate
  6. ; its desires to the KERFIL.TSK
  7. ;--
  8.  
  9. ; Version number
  10.  
  11.     .IDENT    /1.0.10/
  12.  
  13. ; Directives
  14.  
  15.     .ENABLE    LC            ; Allow lower case ascii strings
  16.     .NLIST    BEX
  17.     .LIBRARY /KERMLB/        ; Kermit macro library
  18.  
  19.     .SBTTL    Revision History
  20.  
  21. ;++
  22. ; Version 1.0.00
  23. ;
  24. ; 1.0.00    Create this module
  25. ;
  26. ; 1.0.01    By: Robert C. McQueen        On: 15-Feb-1984
  27. ;        Clean random routines, delete ones that are not used any more
  28. ;        delete global symbols that don't need to be....
  29. ;
  30. ; 1.0.02    By: Robert C. McQueen        On: 5-March-1984
  31. ;        No need to attach to the terminal, so don't do it.
  32. ;
  33. ; 1.0.03    By: Robert C. McQueen        On: 14-March-1984
  34. ;        Redo the inter-task communications.
  35. ;
  36. ; 1.0.04    By: Robert C. McQueen        On: 19-March-1984
  37. ;        Implement support for additional generic commands.
  38. ;
  39. ; 1.0.05    By: Robert C. McQueen        On: 20-March-1984
  40. ;        Change WAIT to SNDPKT to avoid a global symbol conflict.
  41. ;
  42. ; 1.0.06    By: David Stevens        On: 21-March-1984
  43. ;        Change input routines from IO.RVB to IO.RPR, read after
  44. ;        prompt.  Also remove useless data locations.  Also fix
  45. ;        the check for accepting a null input, and C$GET requires
  46. ;        input.
  47. ;
  48. ; 1.0.07    By: Robert C. McQueen        On: 23-March-1984
  49. ;        Make INPUT2 return the correct information.
  50. ;
  51. ; 1.0.08    By: Robert C. McQueen        On: 27-March-1984
  52. ;        Append the positioning strings to the beginning in INPUT and
  53. ;        INPUT2.
  54. ;
  55. ; 1.0.09    By: Robert C. McQueen        On: 5-April-1984
  56. ;        Fix the RESUME typeout problem (I hope).
  57. ;
  58. ; 1.0.10    By: Robert C. McQueen        On: 16-April-1984
  59. ;        Move some routines to support KERCON being a seperate task.
  60. ;--
  61.  
  62.     .SBTTL    External symbols
  63.  
  64. ; Get the KERMLB definitions
  65.  
  66.     .MCALL    KERDEF
  67.     KERDEF                ; Get the general symbol definitions
  68.     .MCALL    CHRDEF            ; Macro for special character
  69.     CHRDEF                ;  definitions (.CHxxx)
  70.  
  71.     .MCALL    BLSRTN            ; Allow use of BLISS macros from
  72.     .MCALL    BLSCAL            ;   library
  73.     .MCALL    PJMP
  74.     .MCALL    MSG            ; Text definition macro
  75. ;
  76. ; System routines used in Kermit
  77. ;
  78.  
  79.     .MCALL    QIOW$C
  80.     .MCALL    QIOW$S
  81.     .MCALL    DIR$
  82.     .MCALL    ABRT$C            ; Abort task.
  83.     .MCALL    MRKT$S            ; Mark time
  84.     .MCALL    ALUN$C            ; Assign LUN
  85.     .MCALL    WTSE$S            ; Wait for single event flag
  86.     .MCALL    RQST$C            ; Request a task (start it up)
  87.     .MCALL    CLEF$S            ; Clear event flag
  88.  
  89.     .SBTTL    Data area for Kermit
  90.  
  91. ;++
  92. ; The following are the various flags that are found in KERMIT
  93. ;--
  94.  
  95.     .PSECT    $BYTE$, RW, D
  96.  
  97. RESFLG:    .BLKB                ; Byte flag for resuming typeout
  98.  
  99.     .SBTTL    Data for Baud rate conversion to ascii
  100.  
  101.     .PSECT    $PLIT$, RO, D
  102.  
  103. ;
  104. ; Data for Senfil system call
  105. ;
  106.  
  107. WLDCRD:    .asciz    '*.*;*'            ; Wild card specification.
  108.     .even
  109. WCDLEN:    .word    5            ; Number of wildcard parameters.
  110. SDTXT:    .asciz    'Possible files to send:'
  111.     .even                
  112. LSDTXT:    .word    27
  113. PRPT1:    .asciz    'To make selections press SELECT'
  114.     .even
  115. LPRPT1:    .word    37
  116. PRPT2:    .asciz    'Make selection and press DO'
  117.     .even
  118. LPRPT2:    .word    34
  119.  
  120.  
  121.     .sbttl    Table for oldfil system call
  122.  
  123. SENFIL:    .byte    lensfl,0    
  124.     .word    status
  125.     .word    nochos
  126.     .word    files
  127.     .word    fsize
  128.     .word    wldcrd
  129.     .word    wcdlen
  130.     .word    sdtxt
  131.     .word    lsdtxt
  132.     .word    prpt1
  133.     .word    lprpt1
  134.     .word    prpt2
  135.     .word    lprpt2
  136. lensfl=    <.-senfil>/2-1
  137.  
  138.     .sbttl    Messages
  139. ;
  140. ; Error messages
  141. ;
  142. ERRRQS:    .asciz    'Error trying to run KERFIL - make sure it is installed'
  143.                     ; Error message for the request
  144.     .even                ;   task routine
  145.  
  146. ;
  147. ; Messages for Status Display
  148. ;
  149.  
  150.     MSG STAT,<Status of previous transmission>
  151.  
  152. STATMG:    .ASCII    <.CHCSI>'4;50HLast'<.CHCSI>'4;65HTotal'
  153.     .ASCII    <.CHCSI>'5;50H----'<.CHCSI>'5;65H-----'
  154.     .ASCII    <.CHCSI>'7;5HThe number of bytes sent:'
  155.     .ASCII    <.CHCSI>'8;5HThe number of data bytes sent:'
  156.     .ASCII    <.CHCSI>'9;5HThe number of packets for sent:'
  157.     .ASCII    <.CHCSI>'10;5HThe number of NAK packets sent:'
  158.     .ASCII    <.CHCSI>'11;5HThe number of bytes received:'
  159.     .ASCII    <.CHCSI>'12;5HThe number of data bytes received:'
  160.     .ASCII    <.CHCSI>'13;5HThe number of packets for received:'
  161.     .ASCII    <.CHCSI>'14;5HThe number of NAK packets received:'
  162.     .ASCIZ    <.CHCSI>'23;5HPress RESUME key to continue'<.CHCRT>
  163.     .EVEN
  164.  
  165.  
  166.  
  167. ;
  168. ; Prompt for input
  169. ;
  170.  
  171. INPHDR:    .ASCII    <.CHCSI>/4;10H/
  172.     .ASCII    /Press MAIN SCREEN or EXIT to return to the main menu/
  173.     .ASCIZ    <.CHCSI>/8;10H/
  174.  
  175. M$PMT1:    .ASCIZ    <.CHCSI>/12;10H/
  176. M$PMT2:    .ASCIZ    <.CHCSI>/14;10H/
  177.  
  178. GETTXT:    .ASCII    /      Enter the name of the file(s) you wish to get/
  179.     .ASCII    <.CHCSI>/9;10H/
  180.     .ASCIZ    /      from the remote system and press RETURN/
  181.  
  182. FILPMT::.ASCIZ    /Remote File Name: /
  183.  
  184. WRONGK:    .ASCII    <.CHESC>/7/<.CHCSI>/18;10H/
  185.     .ASCIZ    /You pressed the wrong function key.  /<.CHESC>/8/
  186.  
  187. NOINP:    .ASCII    <.CHESC>/7/<.CHCSI>/18;10H/
  188.     .ASCIZ    /Must be specified !                  /<.CHESC>/8/
  189.  
  190. I$HDR:    .ASCIZ    /Files To Be Received/
  191.     HDR$L = .-I$HDR
  192.     .EVEN
  193.  
  194.     .SBTTL    Entry point for KERMIT
  195.  
  196. ;++
  197. ; This is the starting point of Pro/Kermit.  The first thing that is done
  198. ; is the initialization and then to call the command scanner to do the work.
  199. ;--
  200.  
  201.     .PSECT    $CODE$, RO, I
  202.  
  203. FROG:    JSR    PC,INICMD        ; Initialize the command processing
  204.     JSR    PC,INILIB        ; Initialize the library routines
  205.     BLSCAL    TT.INIT            ; Initialize terminal processing
  206.     ALUN$C    XKLUN,XK,0,$CODE$    ; Assign XK LUN
  207.  
  208.     JSR    PC,DEFINI        ; Initialize the default file processing
  209.     DIR$    #ASSIGN,IOERR        ; Do the assign terminal LUN routine
  210.                     ;   located at assign.
  211. ;
  212. ; Initialize the intertask communication
  213. ;
  214.     MOV    #N$KER,R0        ; Claim I'm KERMIT
  215.     MOV    #N$FIL,R1        ; And I talk to KERFIL
  216.     JSR    PC,IT$INI        ; Initialize intertask
  217. ;
  218. ; Now and try to start the task
  219. ;
  220.     JSR    PC,STAFIL        ; Start KERFIL
  221.     BCC    20$            ; Branch if not started
  222. ;
  223. ; Here if the task is already active, determine what to do about it
  224. ;
  225.     JSR    PC,CHKACT        ; Check active task
  226. ;
  227. ; Here to do the command scanning
  228. ;
  229. 20$:    CLR    CONNECT.FLAG        ; Clear the connected to own line flag
  230.     JSR    PC,COMMAN        ; Process commands
  231.     JSR    PC,EXFIL        ; Tell KERFIL to go away
  232.     JMP    EXIT            ; Exit this process
  233.  
  234.     .SBTTL    CHKACT - Check what to do about an active task
  235.  
  236. ;++
  237. ; This routine will determine what to do about an active task.
  238. ;--
  239.  
  240.     .PSECT    $CODE$, RO, I
  241.  
  242.     .GLOBL    CHKACT            ; Global routine
  243.  
  244. CHKACT:    CLRB    RESFLG            ; Clear RESUME flag
  245.     BIT    #TRUE,RUN        ; Is it really running already?
  246.     BEQ    99$            ; No, just return to the caller
  247.     MRKT$S    ,#10,#1            ; Wait for a ten ticks
  248.     BIT    #TRUE,RUN        ; May have been just starting up
  249.     BEQ    99$            ; Continue
  250. ;
  251. ; Here if the task is already running, if that is the case display the menu
  252. ; to the user to determine what to do.
  253. ;
  254.     JSR    PC,CMDRUN        ; Do the command processing for a 
  255.                     ; KERFIL that is running
  256.     TSTB    RESFLG            ; Use resume type out?
  257.     BNE    CHKACT            ; Yes, could have exited before done again
  258.     TST    MAIFLG            ; User want MAIN SCREEN
  259.     BEQ    99$            ; No, don't exit
  260.     JMP    EXIT            ; Get out
  261. ;
  262. ; Now just return to the caller
  263. ;
  264. 99$:    RTS    PC            ; Just return for now
  265.  
  266. ;
  267. ; Here if we want to abort the KERFIL task and then try again.
  268. ;
  269.  
  270. CHKABT::MOV    #$TKABT,R0        ; Force the KERFIL to abort
  271.     JSR    PC,IT$SND        ; Send the data
  272.  
  273.     BIT    #TRUE,RUN        ; Is it really running already?
  274.     BEQ    RET            ; No, just return to the caller
  275.     MRKT$S    ,#2,#2            ; Wait for a two seconds
  276.     BIT    #TRUE,RUN        ; Did it shut down?
  277.     BEQ    RET            ; Continue
  278.     
  279.     ABRT$C    KERFIL,$CODE$        ; Abort the task
  280.     PJMP    STAFIL            ; Start KERFIL
  281.  
  282. RET:    RTS    PC            ; Return to the caller
  283. ;
  284. ; Here if we want to resume the file transfer
  285. ;
  286. CHKRES::INCB    RESFLG            ; Flag we got a resume
  287.     MOV    #$TKPAI,R0        ; Have to paint the screen
  288.     PJMP    SNDPKT            ; Send the pack and wait until the 
  289.                     ;  other end is finished
  290.  
  291.     .SBTTL    STATUS command
  292.  
  293. ;++
  294. ; This routine will output the status information that is kept in the data
  295. ; area of KERMSG.  It will paint the box first than fill in the text and
  296. ; finally print the numbers in the box.
  297. ;
  298. ; Usage:
  299. ;    JSR    PC,STATUS
  300. ;    (Return)
  301. ;
  302. ;--
  303.  
  304. STATE::
  305. ;
  306. ; Attach to the terminal, clear the screen, turn off the cursor, and
  307. ;   print out the status message.
  308. ;
  309.     BLSCAL    PAINT,<#M$STAT,#STAT$L,#20.>,+ ; Paint the border
  310.     BLSCAL    TT.TEXT,#CUROFF,+    ; Turn the cursor off
  311.     BLSCAL    TT.TEXT,#STATMG,-    ; Output the text
  312. ;
  313. ; Reposition the cursor to correspond to the first status message.
  314. ;
  315.     MOV    #6,R4            ; Set line count at 5.
  316.     JSR    PC,STCRMV        ; Jump to status cursor movement.
  317.  
  318. ;
  319. ; Take the absolute value of the number of bytes sent, convert it 
  320. ;   to decimal, and output it.
  321. ;  Reposition the cursor one line down.
  322. ;
  323.     MOV    SMSG.TOTAL.CHARS,R2    ; Get total chars for this pass
  324.     JSR    PC,CHGDEC        ; Call ascii conversion subroutine.
  325.     JSR    PC,STCR65        ; Position again
  326.     MOV    SND.TOTAL.CHARS,R2    ; Get total since startup
  327.     JSR    PC,CHGDEC        ; Print it
  328.     JSR    PC,STCRMV        ; Jump to status cursor movement.
  329. ;
  330. ; Print the number of data characters sent
  331. ;
  332.     MOV    SMSG.DATA.CHARS,R2    ; Move send data count into R2.
  333.     JSR    PC,CHGDEC        ; Call ascii conversion routine.
  334.     JSR    PC,STCR65        ; Move out to totals column
  335.     MOV    SND.DATA.CHARS,R2    ; Total data sent
  336.     JSR    PC,CHGDEC        ; Print the total
  337.     JSR    PC,STCRMV        ; Jump to status cursor movement.
  338. ;
  339. ; Convert the send packet count to decimal and output it.
  340. ;  Reposition the cursor one line down.
  341. ;
  342.     MOV    SMSG.COUNT,R2        ; Move send packet count into R2.
  343.     JSR    PC,CHGDEC        ; Call ascii conversion routine.
  344.     JSR    PC,STCR65        ; Move to total column
  345.     MOV    SND.COUNT,R2        ; Total packet count
  346.     JSR    PC,CHGDEC        ; Print it
  347.     JSR    PC,STCRMV        ; Jump to status cursor movement.
  348. ;
  349. ; Print the number of NAK's sent
  350. ;
  351.     MOV    SMSG.NAKS,R2        ; Move send NAK count into R2.
  352.     JSR    PC,CHGDEC        ; Call ascii conversion routine.
  353.     JSR    PC,STCR65        ; Move out to totals column
  354.     MOV    SND.NAKS,R2        ; Total naks sent
  355.     JSR    PC,CHGDEC        ; Print the total
  356.     JSR    PC,STCRMV        ; Jump to status cursor movement.
  357. ;
  358. ; Take the absolute value of the number of bytes received, convert it 
  359. ;   to decimal, and output it.
  360. ;  Reposition the cursor one line down.
  361. ;
  362.     MOV    RMSG.TOTAL.CHARS,R2    ; Get total chars for this pass
  363.     JSR    PC,CHGDEC        ; Call ascii conversion subroutine.
  364.     JSR    PC,STCR65        ; To column 65
  365.     MOV    RCV.TOTAL.CHARS,R2    ; Get total since startup
  366.     JSR    PC,CHGDEC        ; Print it
  367.     JSR    PC,STCRMV        ; Jump to status cursor movement.
  368. ;
  369. ; Print the number of data characters received
  370. ;
  371.     MOV    RMSG.DATA.CHARS,R2    ; Move received data count into R2.
  372.     JSR    PC,CHGDEC        ; Call ascii conversion routine.
  373.     JSR    PC,STCR65        ; Move out to totals column
  374.     MOV    RCV.DATA.CHARS,R2    ; Total data received
  375.     JSR    PC,CHGDEC        ; Print the total
  376.     JSR    PC,STCRMV        ; Jump to status cursor movement.
  377. ;
  378. ; Convert the receive packet count to decimal and output it.
  379. ;  Reposition the cursor one line down.
  380. ;
  381.     MOV    RMSG.COUNT,R2        ; Move receive packet count into R2.
  382.     JSR    PC,CHGDEC        ; Call ascii conversion subroutine.
  383.     JSR    PC,STCR65        ; Move out to totals column
  384.     MOV    RCV.COUNT,R2        ; Total packets received
  385.     JSR    PC,CHGDEC        ; Print the total
  386.     JSR    PC,STCRMV        ; Jump to status cursor movement.
  387. ;
  388. ; Print the number of NAK's received
  389. ;
  390.     MOV    RMSG.NAKS,R2        ; Move received NAK count into R2.
  391.     JSR    PC,CHGDEC        ; Call ascii conversion routine.
  392.     JSR    PC,STCR65        ; Move out to totals column
  393.     MOV    RCV.NAKS,R2        ; Total naks received
  394.     JSR    PC,CHGDEC        ; Print the total
  395.     JSR    PC,STCRMV        ; Jump to status cursor movement.
  396. ;
  397. ; Print out the last error message received.
  398. ;
  399.     
  400.     MOV    #17.,R5            ; Set for line 17
  401.     MOV    #4,R2            ; Set for column 4
  402.     JSR    PC,CURABS        ; Position the cursor
  403.     BLSCAL    TT.TEXT,#LAST.ERROR    ; Print out the last error message.
  404. ;
  405. ; Position cursor at line 22, column 1;  turn on the cursor and output
  406. ;   everything.  Wait for the resume key to be pressed.
  407. ;
  408.     MOV    #22.,R5            ; Set for line 18.
  409.     MOV    #1,R2            ; Set for column 1.
  410.     JSR    PC,CURABS        ; Position the cursor.
  411.     BLSCAL    TT.TEXT,#CURON        ; Output the text
  412.     BLSCAL    TT.OUTPUT        ; Output any remaining characters
  413.     CALL    WTRES            ; Wait for RESUME key to be pressed
  414.                     ;   before continuing.
  415.     RTS    PC            ; Return to the caller
  416.  
  417. ;++
  418. ;
  419. ; Position cursor for last pass field
  420. ;
  421. ;--
  422.  
  423. STCRMV:    INC    R4            ; Incrament the line counter.
  424.     MOV    R4,R5            ; Put line number into R5
  425.     MOV    #50.,R2            ; Put column number into R5.
  426.     PJMP    CURABS            ; Move the cursor.
  427.  
  428. ; Position for totals field
  429.  
  430. STCR65:    MOV    R4,R5            ; Get correct line
  431.     MOV    #65.,R2            ; And column 65
  432.     PJMP    CURABS            ; Position
  433.  
  434.     .SBTTL    Generic commands -- C$BYE
  435.  
  436. ;++
  437. ; This command will instruct KERFIL to send the LOGOUT generic command,
  438. ; followed by an instruction to KERFIL to exit and will cause KERMIT to exit
  439. ; to P/OS.
  440. ;--
  441.  
  442. C$BYE::    JSR    PC,CHKACT        ; Is the other end running?
  443.     JSR    PC,C$LOGO        ; Send it to KERFIL
  444.     JSR    PC,EXFIL        ; Tell KERFIL to go away
  445.     JMP    EXIT            ; Leave KERMIT
  446.  
  447.     .SBTTL    Generic commands -- C$FINI - Finish command
  448.  
  449. ;++
  450. ; This command will instruct KERFIL to send the generic EXIT command to the
  451. ; remote KERMIT.  This will then return to the upper level.
  452. ;--
  453.  
  454. C$FINI::JSR    PC,CHKACT        ; Is the other end running?
  455.     JSR    PC,CLRGEN        ; Clear the generic arguments
  456.     MOV    #GC.EXIT,GENCMD        ; Store the generic command
  457.     MOV    #$TKGEN,R0        ; Send a generic command to the other
  458.                     ;  task
  459.     PJMP    SNDPKT            ; Send the data and assume it worked
  460.  
  461.     .SBTTL    Generic commands -- C$LOGO - Logout command
  462.  
  463. ;++
  464. ; This command will instruct KERFIL to send the generic LOGOUT command to the
  465. ; remote KERMIT.  This will then wait until the remote finishes processing the
  466. ; command before returning to the upper level.
  467. ;--
  468.  
  469.  
  470. C$LOGO::JSR    PC,CHKACT        ; Is the other end running?
  471.     JSR    PC,CLRGEN        ; Clear the generic arguments
  472.     MOV    #GC.LOGOUT,GENCMD    ; Store the generic command
  473.     MOV    #$TKGEN,R0        ; Get the function to send
  474.     PJMP    SNDPKT            ; Go send command wait until finished
  475.  
  476.     .SBTTL    C$SERV - Enter server mode
  477.  
  478. ;++
  479. ; This routine will insturct the KERFIL task to enter server mode.  It will
  480. ; then wait until the remote is finished.
  481. ;--
  482.  
  483. C$SERV::JSR    PC,CHKACT        ; Is the other end running?
  484.     MOV    #$TKSRV,R0        ; Get the function
  485.     PJMP    SNDPKT            ; Send the function to the remote
  486.  
  487.     .SBTTL    STAFIL - Start KERFIL
  488.  
  489. ;++
  490. ; This routine will start the KERFIL task.  It will return only if it was
  491. ; able to start KERFIL.
  492. ;
  493. ; Usage:
  494. ;    JSR    PC,STAFIL
  495. ;    (Return)
  496. ;
  497. ; On return:
  498. ;    Carry set if active
  499. ;    Carry clear if not active
  500. ;--
  501.  
  502.     .PSECT    $CODE$, RO, I
  503.  
  504. STAFIL:    RQST$C    KERFIL,,,,,$CODE$    ; Request task KERFIL to be started
  505.     CMP    @#$DSW,#IS.SUC        ; If successful then go on
  506.     BEQ    20$            ;
  507.     CMP    @#$DSW,#IE.ACT        ; If already active then go on
  508.     BEQ    10$            ; Branch if the task is not active
  509. ;
  510. ; Here if there was some type of error starting the task up
  511. ;
  512.     MOV    @#$DSW,STATUS        ; Save the status
  513.     CLR    STAT1            ; Clear the extra status word
  514.     JMP    RQSERR            ; Jump to the fatal error routine
  515. ;
  516. ; Here if KERFIL was started ok
  517. ;
  518. 20$:    CLC                ; Clear the carry
  519.     RTS    PC            ; Return to the caller
  520. ;
  521. ; Here if KERFIL was already active
  522. ;
  523. 10$:    SEC                ; Set the carry
  524.     RTS    PC            ; Return to the caller
  525.  
  526.     .SBTTL    EXFIL - Cause KERFIL to exit
  527.  
  528. ;++
  529. ; This routine will cause KERFIL to exit to P/OS.  This routine is called from
  530. ; various levels.
  531. ;--
  532.  
  533.  
  534. EXFIL::    BIT    #TRUE,RUN        ; Is the RUN bit up?
  535.     BEQ    10$            ; Branch if it is idle
  536.     RTS    PC            ; Otherwise just return
  537.  
  538. 10$:    MOV    #$TKXIT,R0        ; Get the exit function
  539.     PJMP    IT$SDA            ; Just send the data and go away
  540.  
  541.     .SBTTL    C$RECV - Send the RECEIVE command to the remote
  542.  
  543. ;++
  544. ; This routine will send the RECEIVE command to the KERFIL task.
  545. ; The routine will wait until KERFIL acks the information sent to it.
  546. ;--
  547.  
  548. C$RECV::JSR    PC,CHKACT        ; Is KERFIL running currently?
  549.     CLR    RCVBUF            ; Flag no file
  550.     MOV    #$TKRCV,R0        ; Get the function
  551.     PJMP    SNDPKT            ; Send the function and wait for reply
  552.  
  553.     .SBTTL    C$SEND - Send file(s) to the remote Kermit
  554.  
  555. ;++
  556. ; Send command processing.  This routine will determine the number of files
  557. ; that we have to send to the remote and then send the data to KERXFR to send
  558. ; the information.  Note the file specifications are read directly into the
  559. ; common.
  560. ;
  561. ; Usage:
  562. ;    JSR    PC,C$SEND
  563. ;    (Return)
  564. ;
  565. ;--
  566.  
  567. C$SEND::JSR    PC,CHKACT        ; Is KERFIL active still?
  568.  
  569. 5$:    MOV    #20.,NOCHOS        ; Reset the number of possible choices.
  570.     MOV    #SENFIL,R5        ; Set up call to Oldfile sys. routine.
  571.     CALL    OLDFIL            ; Call the system routine.
  572.  
  573.     CMP    STATUS,#ST.KEY        ; See if a function key was pressed.
  574.     BNE    10$            ; If not a function key then branch.
  575.  
  576.     CMP    STAT1,#KY.MAI        ; See if it was the Main Screen key.
  577.     BEQ    99$            ; Exit if it was
  578.  
  579.     CMP    STAT1,#KY.EXI        ; See if it was the Exit key.
  580.     BEQ    99$            ; Exit if it was
  581.  
  582.     BLSCAL    TT.CHAR,#.CHBEL        ; Output a bell
  583.     BLSCAL    TT.OUTPUT        ; Output any remaining characters
  584.     BR    5$            ; Jump back and try again
  585.  
  586. 10$:    MOV    #$TKSND,R0        ; Get the function to send to KERFIL
  587.     JSR    PC,SNDPKT        ; Send the information and wait for OK
  588. ;
  589. ; Now to return to the command processing.  We must first reinitialize the
  590. ; frame files that are open.
  591. ;
  592. 99$:    PJMP    INICMD            ; Initialize the command processing
  593.  
  594.     .SBTTL    C$GET - Get a file(s) from the remote Kermit
  595.  
  596. ;++
  597. ; This routine will implement the GET command.  It will input the file
  598. ; specifications from the user and then call KERFIL to do the work.
  599. ;
  600. ; Usage:
  601. ;    JSR    PC,C$GET
  602. ;    (Return)
  603. ;
  604. ; On return:
  605. ;    - Command completed, or
  606. ;    - User requested return to KERMIT
  607. ;--
  608.  
  609.  
  610. C$GET::    JSR    PC,CHKACT        ; Is KERFIL active still?
  611.     BLSCAL    INPUT,<#TRUE,#I$HDR,#HDR$L,#GETTXT,#FILPMT>
  612.     TST    R0            ; Get a file specification?
  613.     BEQ    10$            ; Yes, get the files
  614.     RTS    PC            ; Return to the caller
  615.  
  616. 10$:    MOV    #$TKRCV,R0        ; Get the function
  617.     PJMP    SNDPKT            ; Wait until the other end responds
  618.  
  619.     .SBTTL    INPUT - Input a line of text from the user
  620.  
  621. ;++
  622. ; This routine will paint a box and then prompt the user for a single
  623. ; line of input.  The input is left in RCVBUF and the length is left
  624. ; in ????.
  625. ;
  626. ; Usage:
  627. ;
  628. ;    BLSCAL    INPUT,Flag,Header,Header.lenght,Text,Prompt
  629. ;
  630. ; Flag - True/False to determine if a null field is allowed.
  631. ; Header - Address of the header text.
  632. ; Header.length - Number of bytes in the header
  633. ; Text - A single line of text to output
  634. ; Prompt - Prompt for the user
  635. ;
  636. ;--
  637.  
  638.     .PSECT    $CODE$, RO, I
  639.  
  640. BLSRTN    INPUT,5,<FLAG,HEADER,HDRLEN,TEXT,PROMPT>
  641.     JSR    PC,SETESC        ; Allow escape sequences
  642.     MOV    HEADER+2(SP),R0        ; Get the header address
  643.     MOV    HDRLEN+2(SP),R1        ; And the length
  644.     BLSCAL    PAINT,<R0,R1,#22.>,+    ; Put box around prompt.
  645.  
  646.     BLSCAL    TT.TEXT,#INPHDR,+    ; Output the header
  647.     BLSCAL    TT.TEXT,2+..STKO+TEXT(SP),+ ; Output the other text
  648.     BLSCAL    TT.OUTPUT,,-        ; Output any remaining characters
  649.  
  650.     MOV    #M$PMT1,R0        ; Build the prompt
  651.     MOV    PROMPT+2(SP),R1        ; Put address of prompt into R1.
  652.     JSR    PC,BLDPMT        ; Build it
  653. ;
  654. ; This will now call the routine to read the text from the user's terminal
  655. ;
  656.     MOV    FLAG+2(SP),R0        ; Get the flag
  657.     JSR    PC,DOINP        ; Get the input
  658.     TST    R0            ; Normal return ?
  659.     BNE    99$            ; No, EXIT of MAIN SCREEN pressed.
  660.  
  661.     MOV    IOSTAT+2,GEN.1S        ; Move the length
  662.     CMP    #MAX.MSG,IOSTAT+2    ; Make sure this is small enough
  663.     BGE    10$            ; Too big, skip this
  664.     MOV    #MAX.MSG,GEN.1S        ; Move the size
  665. 10$:    BLSCAL    BL$MOV,<GEN.1S,#RCVBUF,#GEN.1D> ; Move the text
  666.     CLR    R0            ; Return a zero to top level
  667. 99$:    RTS    PC            ; Return to caller.
  668.  
  669.     .SBTTL    INPUT2 - Input two lines of text
  670.  
  671. ;++
  672. ; This routine will input two lines of text from the user.  The text will
  673. ; be stored in the generic command argument blocks along with the length.
  674. ;
  675. ; Usage:
  676. ;
  677. ;    BLSCAL    INPUT,Flag,Header,Header.lenght,Text,Prompt,Prompt2
  678. ;
  679. ; Flag - True/False to determine if a null field is allowed.
  680. ; Header - Address of the header text.
  681. ; Header.length - Number of bytes in the header
  682. ; Text - A single line of text to output
  683. ; Prompt - Prompt for the user
  684. ; Prompt2 - Second prompt for the user
  685. ;
  686. ;--
  687.  
  688.     .PSECT    $CODE$, RO, I
  689.  
  690. BLSRTN    INPUT2,5,<FLAG,HEADER,HDRLEN,TEXT,PROMPT,PRMPT2>
  691.     JSR    PC,SETESC        ; Allow escape sequences
  692.     MOV    HEADER+2(SP),R0        ; Get the header address
  693.     MOV    HDRLEN+2(SP),R1        ; And the length
  694.     BLSCAL    PAINT,<R0,R1,#22.>,+    ; Put box around prompt.
  695.     BLSCAL    TT.TEXT,#INPHDR,+    ; Output the header
  696.     BLSCAL    TT.TEXT,2+..STKO+TEXT(SP),+ ; Output the other text
  697.     BLSCAL    TT.OUTPUT,,-        ; Output any remaining characters
  698.     MOV    #M$PMT1,R0        ; Get the address of the position string
  699.     MOV    PROMPT+2(SP),R1        ; Put address of first prompt in R1
  700.     JSR    PC,BLDPMT        ; Build the prompt
  701.  
  702.     MOV    FLAG+2(SP),R0        ; Get the flag
  703.     JSR    PC,DOINP        ; Get the input
  704.  
  705.     TST    R0            ; Continue with routine ?
  706.     BNE    99$            ; No, return to user.
  707. ;
  708. ; Here if we got something from the user
  709. ;
  710.     MOV    IOSTAT+2,GEN.1S        ; Move the length
  711.     CMP    #MAX.MSG,IOSTAT+2    ; Make sure this is small enough
  712.     BGE    10$            ; Too big, skip this
  713.     MOV    #MAX.MSG,GEN.1S        ; Move the size
  714. 10$:    BLSCAL    BL$MOV,<GEN.1S,#RCVBUF,#GEN.1D>,+ ; Move the text
  715.     BLSCAL    TT.OUTPUT,,-        ; Force it out
  716.  
  717.     MOV    #M$PMT2,R0        ; Get the position string
  718.     MOV    PRMPT2+2(SP),R1        ; Get address of second prompt.
  719.     JSR    PC,BLDPMT        ; Build the prompt string
  720.  
  721.     MOV    FLAG+2(SP),R0        ; Get the flags again
  722.     ASR    R0            ; Shift so we just get the other one
  723.     JSR    PC,DOINP        ; Get the other string
  724.     TST    R0            ; Stay with routine ?
  725.     BNE    99$            ; No, return to user.
  726. ;
  727. ; Here if we got the second argument
  728. ;
  729.     MOV    IOSTAT+2,GEN.2S        ; Move the length
  730.     CMP    #MAX.MSG,IOSTAT+2    ; Make sure this is small enough
  731.     BGE    20$            ; Too big, skip this
  732.     MOV    #MAX.MSG,GEN.2S        ; Move the size
  733. 20$:    BLSCAL    BL$MOV,<GEN.2S,#RCVBUF,#GEN.2D> ; Move the text
  734.     CLR    R0            ; Clear so we do the right thing
  735. 99$:    RTS    PC            ; Return to the caller
  736.  
  737.     .SBTTL    BLDPMT - Build the prompt string
  738.  
  739. ;++
  740. ; This routine will build the prompt string.
  741. ;
  742. ; Usage:
  743. ;    MOV    Pos.text.addr,R0
  744. ;    MOV    Prompt.text.addr,R1
  745. ;    JSR    PC,BLDPMT
  746. ;    (Return)
  747. ;
  748. ; On return:
  749. ;    R1 - Address of the prompt
  750. ;    R2 - Length of the text
  751. ;--
  752.  
  753.     .PSECT    $CODE$, RO, I
  754.  
  755. BLDPMT:    MOV    #BUFF1,R2        ; Address to store it
  756. 10$:    MOVB    (R0)+,(R2)+        ; Store a byte
  757.     BNE    10$            ; Loop until finished
  758. ;
  759. ; Here if the prompt is copied
  760. ;
  761.     TSTB    -(R2)            ; Back up the poniter
  762. 20$:    MOVB    (R1)+,(R2)+        ; Store the next byte
  763.     BNE    20$            ; Loop for all of these too
  764.     SUB    #BUFF1+1,R2        ; Calculate the number of bytes
  765.     MOV    #BUFF1,R1        ; Point to the buffer
  766.     RTS    PC            ; Return to the caller
  767.  
  768.     .SBTTL    DOINP - Read a line of text from the user
  769.  
  770. ;++
  771. ; This routine will read a line of text from the user's terminal.
  772. ;
  773. ; Usage:
  774. ;    MOV    Flag,R0            - Save the flag
  775. ;    MOV    PROMPT.ADDRESS,R1    - Address of prompt into R1
  776. ;    MOV    PROMPT.LENGTH,R2    - Length of prompt into R2
  777. ;    JSR    PC,DOINP
  778. ;    (Return)
  779. ;
  780. ;--
  781.  
  782.     .PSECT    $CODE$, RO, I
  783.  
  784. DOINP::    QIOW$S    #IO.RPR!TF.BIN,#TERLUN,#TTREFN,,#IOSTAT,,<#RCVBUF,#100.,,R1,R2>
  785.     TST    R0            ; Is no input valid ?
  786.     BEQ    20$            ; Yes, branch.
  787.     TST    IOSTAT+2        ; Did we get any characters ?
  788.     BNE    20$            ; Yes, branch.
  789.     BLSCAL    TT.TEXT,#NOINP        ; Queue up the error message.
  790.     BLSCAL    TT.OUTPUT        ; Output it.
  791.     BR    DOINP            ; Try again.
  792. ;
  793. ; Here if we got an input file name.
  794. ;
  795. 20$:    MOV    R0,-(SP)        ; Save the flag value.
  796.     JSR    PC,CHKEXT        ; Check what we got.
  797.     CMP    #1,R0            ; Was it a bad function key ?
  798.     BNE    30$            ; No, continue.
  799.     MOV    (SP)+,R0        ; Resore the flag value.
  800.     BR    DOINP            ; Try again.
  801. ;
  802. ; If here then we got a good input file name.
  803. ;
  804. 30$:    MOV    IOSTA1,R1        ; Get the number of characters input
  805.     CLRB    RCVBUF(R1)        ; Clear the last byte
  806.     TST    (SP)+            ; Remove the item from the stack
  807.     RTS    PC            ; Return to caller.
  808.  
  809.     .SBTTL    Exit Check for Rcvfile
  810.  
  811.  
  812. CHKEXT:    CLR    R0            ; Give a good return
  813.     MOV    IOSTAT+2,R2        ; Get the count of characters
  814.     BEQ    99$            ; Just return if nothing
  815.     MOV    #RCVBUF,R1        ; Put address of input buffer into R1.
  816.  
  817. 10$:    CMPB    #.CHESC,(R1)+        ; Is the character an "ESCAPE" ?
  818.     BEQ    20$            ; Yes, branch.
  819.     SOB    R2,10$            ; Decrement the character count
  820.     RTS    PC            ; Just return if no escape
  821. ;
  822. ; Here if we have an <Escape>
  823. ;
  824. 20$:    DEC    R2            ; Decrement the count of characters
  825.     BLT    99$            ; Branch if no more characters
  826.     CMPB    #'[,(R1)+        ; Was the next character a "[" ?
  827.     BNE    105$            ; No, branch.
  828.     DEC    R2            ; Decrement the count of characters
  829.     BLT    99$            ; Branch if no more characters
  830.     CMPB    #'2,(R1)+        ; Was the next a "2" ?
  831.     BNE    105$            ; No, branch.
  832.     CMPB    #'0,(R1)        ; Was the next a "0" ? ( MAIN SCREEN )
  833.     BEQ    90$            ; Yes, branch.
  834.     DEC    R2            ; Decrement the count of characters
  835.     BLT    99$            ; Branch if no more characters
  836.     CMPB    #'1,(R1)+        ; Or was that one a "1" ? ( EXIT )
  837.     BNE    105$            ; Neither then branch.
  838.  
  839. 90$:    MOV    #2,R0            ; Set up an EXIT return.
  840. 99$:    RTS    PC            ; Return to caller.
  841.  
  842. 105$:    BLSCAL    TT.TEXT,#WRONGKEY    ; Output the text
  843.     BLSCAL    TT.OUTPUT        ; Output any remaining characters
  844.     MOV    #1,R0            ; Set up a WRONG FUNCTION KEY return.
  845.     RTS    PC            ; Return to the caller
  846.  
  847.     .SBTTL    SETESC - Allow escape sequences on this command
  848.  
  849. ;++
  850. ; This will allow escape sequences on the following QIOs.
  851. ;
  852. ; Usage:
  853. ;    JSR    PC,SETESC
  854. ;    (Call back)
  855. ;
  856. ; On return:
  857. ;    This routine is stack to return to, so we can disallow escape
  858. ;    escape sequences.
  859. ;--
  860.  
  861.     .PSECT    $PLIT$, RO, D
  862.  
  863. IOLOC:    .BYTE    TC.ESQ,1        ; Recognize escape sequences
  864.  
  865.     .PSECT    $CODE$, RO, I
  866.  
  867.     .GLOBL    SETESC
  868.  
  869. SETESC::
  870.     QIOW$C    SF.SMC,TERLUN,5,,IOSTAT,,<IOLOC,2.>,$CODE$
  871.     QIOW$C    IO.ATT!TF.ESQ,TERLUN,TTAEFN,,IOSTAT,,,$CODE$
  872.     JSR    PC,@(SP)+        ; Call the caller back
  873.     QIOW$C    IO.DET,TERLUN,TTAEFN,,IOSTAT,,,$CODE$
  874.     RTS    PC            ; Return to the caller
  875.  
  876.     .SBTTL    Convert from ascii to binary
  877.  
  878. ;++
  879. ;    INPUT:    R2    Address of buffer with ascii
  880. ;        R5    Original base of number
  881. ;
  882. ;    OUTPUT:    R1    Contains binary value
  883. ;
  884. ;    REGISTERS used:    R0, R1, R2, R5
  885. ;        R0    Temporary value location (destroyed)
  886. ;        R1    (value returned)
  887. ;        R2    (destroyed)
  888. ;        R5    (preserved)
  889. ;
  890.  
  891. ASCBIN::CLR    R1            ; Clear out result location
  892. 10$:    MOVB    (R2)+,R0        ; Get first digit
  893.     BEQ    99$            ; Check for end
  894.     SUB    #'0,R0            ; Get binary value of digit
  895.     CLC                ; Clear the carry for the mult.
  896.     MUL    R5,R1            ; Shift the rest of the answer over 
  897.                     ;   one place (multiply by base)
  898.     ADD    R0,R1            ; Add in last digit
  899.     BR    10$            ; Loop for all digits
  900.  
  901. 99$:    RTS    PC            ; Return to sender
  902.  
  903. ;
  904. ; This routine checks to see if input values are legal for the base specified
  905. ;
  906. ;    INPUT:    R2    Address of buffer with ascii
  907. ;        R5    Original base of number
  908. ;
  909. ;    OUTPUT:    Carry set if bad character was found.
  910. ;
  911. ;    REGISTERS used:    R0, R2, R5
  912. ;        R0    temporary value holder (destroyed)
  913. ;        R2    (destroyed)
  914. ;        R5    (preserved)
  915. ;
  916.  
  917. BASCHK::
  918.     MOVB    (R2)+,R0        ; Get first digit
  919.     CLC                ; Clear carry
  920.     BEQ    99$            ; Check for end
  921.     SUB    #'0,R0            ; Convert to binary digit
  922.     BMI    90$            ; If less then ascii zero then bad
  923.     SUB    R5,R0            ; Subtract base value
  924.     BPL    90$            ; If greater than or equal to the 
  925.                     ;   ascii of base then bad
  926.     BR    BASCHK            ; Loop for the rest
  927. 90$:    SEC                ; Set carry since bad character found
  928. 99$:    RTS    PC            ; Return to sender
  929.  
  930.     .SBTTL    SNDPKT - Send the function to KERFIL and wait until it finishes
  931.  
  932. ;++
  933. ; This routine will send a function to the KERFIL task and then wait until
  934. ; it completes the operation that we requested.
  935. ;
  936. ; Usage:
  937. ;    R0 - Function to send
  938. ;    JSR    PC,SNDPKT
  939. ;    (Return)
  940. ;
  941. ; On return:
  942. ;    Function completed, KERFIL still active, or KERFIL dead
  943. ;--
  944.  
  945.     .PSECT    $CODE$, RO, I
  946.  
  947.     .GLOBL    SNDPKT
  948.  
  949. SNDPKT:    JSR    PC,IT$SND        ; Send the information to the other end
  950. ;
  951. ; Now wait until we get the response from the other end.
  952. ;
  953.     WTSE$S    #ITCEFN            ; Wait until we are told to go again
  954.     CLEF$S    #ITCEFN            ; Clear the event flag
  955.     JSR    PC,IT$RDA        ; Get the data
  956. ;
  957.     RTS    PC            ; Return to sender
  958.  
  959.     .SBTTL    Error routines
  960.  
  961. ;
  962. ; Error routine for the ReQueSt task directive (starts KERFIL)
  963. ;
  964. ;    INPUT:    None
  965. ;
  966. ;    OUTPUT:    The request task error message is displayed and a fatal error
  967. ;        is given.  Control returns to P/OS Main menu
  968.  
  969. RQSERR:    MOV    #ERRRQS,ADRERR        ; Get the error message to be printed
  970.     MOV    #8.,BASE        ; Set up for octal conversion
  971.     JMP    ERROR            ; call the main error routine
  972.  
  973.     .SBTTL    Generic command processing - CLRGEN - Clear generic arguments
  974.  
  975. ; This routine will clear the generic command arguments so that KERMSG
  976. ;will not think there is something there.
  977. ;
  978. ; Usage:
  979. ;    JSR    PC,CLRGEN
  980. ;    (return here, all registers intact)
  981. ;
  982.  
  983. CLRGEN::CLR    GEN.1SIZE        ; No first argument
  984.     CLRB    GEN.1DATA        ; In case someone thinks its ASCIZ
  985.     CLR    GEN.2SIZE        ; No second argument
  986.     CLRB    GEN.2DATA        ; In case someone thinks its ASCIZ
  987.     CLR    GEN.3SIZE        ; No third argument
  988.     CLRB    GEN.3DATA        ; In case someone thinks its ASCIZ
  989.     RTS    PC
  990.  
  991.     .SBTTL    DEFINI - Initlialize the default file processing
  992.  
  993. ;++
  994. ; This routine will determine if the default file contains the
  995. ; default parameters for the XK port.  It will then read them into the
  996. ; common area if they are in the file.  If they are not it will read
  997. ; the current parameters into the default area.
  998. ;--
  999.  
  1000.     XK.IDX==    "XK            ; Index to XK parameters
  1001.  
  1002.     .PSECT    $CODE$,    RO
  1003.  
  1004. DEFINI:    JSR    PC,DF.INI        ; Initialize the default file
  1005.     MOV    #XK.IDX,R0        ; Get the record to read
  1006.     JSR    PC,DF.RD        ; Read the record
  1007.     TST    R1            ; Did we read anything?
  1008.     BGT    10$            ; Yes, skip this
  1009.  
  1010. ; Here if there were no parameters in the file, so just use what
  1011. ; the port is currently set at as the parameters and some other things
  1012. ; that we must default.
  1013.  
  1014.     JSR    PC,XK.INT        ; Initialize the XK port
  1015.  
  1016.     BLSCAL    BL$MOV,<#CURXKL,#ORGXKP,#CURXKP> ; Move the parameters
  1017. ;
  1018. ; Now make some parameters consistant
  1019. ;
  1020.     MOV    #TC.PAR,R0        ; Get the parity setting
  1021.     MOV    #CURXKP,R1        ; From this block
  1022.     JSR    PC,FNDXKP        ; Find the parameter
  1023.     TST    R0            ; Find it?
  1024.     BEQ    4$            ; No, skip this (should be there)
  1025.     CLRB    @R0            ; Clear to turn off parity
  1026. ;
  1027. ; Here to set the data character size
  1028. ;
  1029. 4$:    MOV    #TC.FSZ,R0        ; Get the data size
  1030.     JSR    PC,FNDXKP        ; Find the parameter
  1031.     TST    R0            ; Did we find it?
  1032.     BEQ    6$            ; Branch if not
  1033.     MOVB    #8.,@R0            ; Set to 8 bit characters
  1034. ;
  1035. ; Now write the defaults
  1036. ;
  1037. 6$:    MOV    #XK.IDX,R0        ; Index for the file
  1038.     MOV    #CURXKP,R1        ; Address of the parameters
  1039.     MOV    #CURXKL,R2        ; Length of the block
  1040.     JSR    PC,DF.WT        ; Write the parameters
  1041. ;
  1042. ; Now to shut down the port, since we don't need it
  1043. ;
  1044.     JSR    PC,XK.SHT        ; Shut down the XK again
  1045.     BR    30$            ; Copy over to the default area
  1046.  
  1047. ; Here if we have parameters in the default file for the XK port.
  1048. ; Just copy the parameters to the correct area, so we can use them
  1049. ; later.
  1050.  
  1051. 10$:    CMP    #CURXKL,R1        ; Have enough area?
  1052.     BEQ    20$            ; Long enough area
  1053.     MOV    #CURXKL,R1        ; No, use this length
  1054.  
  1055. 20$:    BLSCAL    BL$MOV,<R1,R0,#CURXKP>    ; Move the parameters
  1056. ;
  1057. ; Now copy the parameters to the default area
  1058. ;
  1059. 30$:    BLSCAL    BL$MOV,<#CURXKL,#CURXKP,#DEFXKP>
  1060. ;
  1061. ; Close the parameter file now.
  1062. ;
  1063.     JSR    PC,DF.FIN        ; Finished with this for now
  1064.     RTS    PC            ; Return to the caller
  1065.  
  1066.     .SBTTL    End of KERMIT
  1067.  
  1068.  
  1069.     .END    FROG            ; That's all folks! (Ribbit)
  1070.