home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / ShellTerm / ST1.21.S < prev    next >
Text File  |  1993-12-21  |  63KB  |  3,197 lines

  1. *************************************************
  2. *                        *
  3. *           (C)opyright 1992-93        *
  4. *                        *
  5. *        by Tomi Blinnikka        *
  6. *                        *
  7. *    Don't try to understand the code    *
  8. *                        *
  9. * Version 0.01    28/05/1992            *
  10. *     -0.99ö                    *
  11. *                        *
  12. * Version 1.00    04/08/1992            *
  13. *                        *
  14. * BUGS: Lots! No phonebook.            *
  15. *                        *
  16. * Version 1.01    05/08/1992            *
  17. *                        *
  18. * BUGS: Some. Dialer problems.            *
  19. *                        *
  20. * Version 1.02    06/08/1992            *
  21. *                        *
  22. * BUGS: Less. Still dialer problems.        *
  23. *                        *
  24. * Version 1.03    08/08/1992            *
  25. *                        *
  26. * BUGS:                     *
  27. *                        *
  28. * Version 1.04    11/08/1992            *
  29. *                        *
  30. * Released                    *
  31. *                        *
  32. * BUGS: Send CTRL-P didn't work            *
  33. *                        *
  34. * Version 1.05    15/08/1992            *
  35. *                        *
  36. * Version 1.06    28/08/1992            *
  37. *                        *
  38. * Added prefs file and swap BS & DEL        *
  39. * See docs for more info            *
  40. *                        *
  41. * Version 1.07    30/08/1992            *
  42. *                        *
  43. * Version 1.08    04/09/1992            *
  44. *                        *
  45. * Added cursor remap                *
  46. *                        *
  47. * Version 1.09    06/09/1992            *
  48. *                        *
  49. * Version 1.10    20/10/1992            *
  50. *                        *
  51. * Hopefully fixed bug in FindWord        *
  52. * Added: PublicPorts                *
  53. *                        *
  54. * Version 1.11    13/11/1992 <-Friday the 13th    *
  55. *                        *
  56. * Version for Mika Henttinen            *
  57. *                        *
  58. * Version 1.12    30/12/1992            *
  59. *                        *
  60. * Changed parser to Commodore's own ReadArgs    *
  61. *                        *
  62. * Version 1.13    02/01/1993            *
  63. *                        *
  64. * Added 'Execute Command'            *
  65. *                        *
  66. * Version 1.14    06/02/1993            *
  67. *                        *
  68. * Fixed bug at start clearing CLI pointer's    *
  69. * last byte                    *
  70. *                        *
  71. * Version 1.15    10/02/1993            *
  72. *                        *
  73. * Made sure that the Modify Mode in the dialer    *
  74. * is turned off when the dialer is quit        *
  75. *                        *
  76. * Version 1.16    24/03/1993            *
  77. *                        *
  78. * Fixed bug with opening device!        *
  79. *                        *
  80. * Version 1.17    25/03/1993            *
  81. *                        *
  82. * Added optional port                *
  83. *                        *
  84. * Version 1.18    22/05/1993            *
  85. *                        *
  86. * Added scripts to archive            *
  87. *                         *
  88. * Fixed bug with opening device and setting    *
  89. * parameters.                    *
  90. *                        *
  91. * Added XON/XOFF                *
  92. *                        *
  93. * Version 1.19    26/05/1993            *
  94. *                        *
  95. * Added version to prefs file            *
  96. *                        *
  97. * Version 1.20    23/06/1993            *
  98. *                        *
  99. * Fixed "Can't open device '"... string.    *
  100. *                        *
  101. * Version 1.21    02/07/1993            *
  102. *                        *
  103. * Fixed 'Load prefs' bug.            *
  104. *                        *
  105. *************************************************
  106.  
  107.     INCLUDE    "JMPLibs.i"
  108.     INCLUDE    "exec/types.i"
  109.     INCLUDE    "exec/nodes.i"
  110.     INCLUDE    "exec/lists.i"
  111.     INCLUDE    "exec/ports.i"
  112.     INCLUDE    "exec/memory.i"
  113.     INCLUDE    "exec/devices.i"
  114.     INCLUDE    "exec/io.i"
  115.     INCLUDE    "exec/tasks.i"
  116.     INCLUDE    "libraries/dosextens.i"
  117.     INCLUDE    "libraries/dos.i"
  118.     INCLUDE    "devices/serial.i"
  119.  
  120.     INCLUDE    "XREF:2.0.xref"
  121.     INCLUDE    "XREF:exec.xref"
  122.     INCLUDE    "XREF:dos.xref"
  123.  
  124.  
  125. PROGVERSION:    macro
  126.         dc.b    "1.21 (02.07.93)"
  127.         endm
  128.  
  129. STFileVersion:    EQU    'ST01'
  130.  
  131. CTRL_B:        EQU    2
  132. CTRL_F:        EQU    6
  133. BS:        EQU    8
  134. TAB:        EQU    9
  135. LF:        EQU    10
  136. CR:        EQU    13
  137. CTRL_N:        EQU    $E
  138. CTRL_O:        EQU    $F
  139. CTRL_P:        EQU    $10
  140. DEL:        EQU    127
  141. CSI:        EQU    $9B
  142. Cursor_Up:    EQU    'A'
  143. Cursor_Down:    EQU    'B'
  144. Cursor_Left:    EQU    'D'
  145. Cursor_Right:    EQU    'C'
  146.  
  147. MENU_KEY:    EQU    CTRL_P
  148. STATS_KEY:    EQU    CTRL_O
  149.  
  150. FALSE:        EQU    0
  151. TRUE:        EQU    1
  152.  
  153. BUFLEN:        EQU    1024
  154. ENTRYLENGTH:    EQU    20
  155.  
  156.         section    ST,CODE
  157.  
  158.         push    d2-d7/a2-a6
  159.         push    d0/a0
  160.  
  161.         openlib    Dos,NoDos        ;Keep at beginning
  162.  
  163. CLIStart:    lib    Dos,Output
  164.         move.l    d0,_stdout
  165.         lib    Dos,Input
  166.         move.l    d0,_stdin
  167.         move.l    d0,d1
  168.         lib    Dos,IsInteractive
  169.         tst.l    d0
  170.         beq    NotInteractive
  171.         pull    d0/a0
  172.  
  173.         lea.l    CLTemplate1,a0
  174.         move.l    a0,d1
  175.         lea.l    CLArray1,a0
  176.         move.l    a0,d2
  177.         clr.l    d3
  178.         lib    Dos,ReadArgs
  179.         move.l    d0,RDArgs1
  180.         beq    NoRDArgs
  181.  
  182.         move.l    CLArray1,a0
  183.         lea.l    FileNameBuf1,a1
  184.         tst.b    (a0)
  185.         beq    Parse2
  186. CLCopyLoop:    move.b    (a0)+,(a1)+
  187.         tst.b    -1(a1)
  188.         bne    CLCopyLoop
  189.  
  190. Parse2:        tst.l    OptPortName
  191.         beq    Parse3            ;No port specified
  192.  
  193.         lib    Exec,CreateMsgPort
  194.         move.l    d0,OptPort
  195.         beq    NoMsgPort
  196.  
  197. ;Add port to public lists
  198.  
  199.         move.l    OptPort,a1
  200.         move.l    OptPortName,a0
  201.         move.l    a0,LN_NAME(a1)
  202.         lib    Exec,AddPort
  203.  
  204. Parse3:
  205.  
  206. MainStart:    openlib    Utility,NoUtility        ;Keep at beginning
  207.  
  208.         bsr    LoadPrefsFile
  209.  
  210.         bsr    OpenSerial
  211.  
  212.         bsr    SetSerParams
  213.         tst.l    d0
  214.         beq    MainStart1
  215.         bsr    ParamsNotSet
  216.  
  217. MainStart1:    lea.l    StartText1,a0
  218.         bsr    Printer
  219.  
  220. ;Change mode for CLI to RAW:
  221.  
  222.         move.l    _stdin,d1
  223.         move.l    #TRUE,d2
  224.         lib    Dos,SetMode
  225.  
  226. ;Flush extra text
  227.  
  228.         move.l    _stdin,d1
  229.         lib    Dos,Flush
  230.  
  231. Looper:        move.l    _stdin,d1
  232.         move.l    #5000,d2
  233.         lib    Dos,WaitForChar
  234.         tst.l    d0
  235.         beq    Looper1
  236.         move.l    _stdin,d1
  237.         lea.l    Buffer1,a0
  238.         move.l    a0,d2
  239.         move.l    #1,d3
  240.         lib    Dos,Read
  241.         cmp.b    #MENU_KEY,Buffer1
  242.         beq    Menu
  243.         move.b    CPAssign,d0
  244.         cmp.b    Buffer1,d0
  245.         beq    DoCTRL_P2
  246.         bsr    DoCLIInput
  247. Looper1:    move.l    #BUFLEN,d0
  248.         move.l    #1,d1
  249.         bsr    Read
  250.         tst.l    d0
  251.         beq    Looper
  252.  
  253.         lea.l    Buffer3,a0
  254.         clr.b    0(a0,d0.l)    ;null terminated, please!
  255.  
  256.         bsr    DoSerialInput
  257.  
  258.         move.l    _stdout,d1
  259.         lea.l    Buffer4,a1
  260.         bsr    GetLength
  261.         move.l    d0,d3
  262.         lea.l    Buffer4,a0
  263.         move.l    a0,d2
  264.         lib    Dos,Write
  265.  
  266.         bsr    DoCapture
  267.  
  268.         bra    Looper
  269.  
  270. Menu:        bsr    DoANSI
  271.         lea.l    MenuText1,a0
  272.         bsr    Printer
  273. Menu1:        move.l    _stdin,d1
  274.         lib    Dos,FGetC
  275.         cmp.l    #-1,d0
  276.         beq    ShutDown
  277.         cmp.l    #'a',d0
  278.         bcs    Menu2
  279.         cmp.l    #'z',d0
  280.         bhi    Menu2
  281.         sub.l    #32,d0
  282. Menu2:        cmp.l    #'P',d0
  283.         beq    Prefs
  284.         cmp.l    #'S',d0
  285.         beq    DoStats
  286.         cmp.l    #'C',d0
  287.         beq    ClearBoth
  288.         cmp.l    #'D',d0
  289.         beq    Dialer
  290.         cmp.l    #'B',d0
  291.         beq    DoBreak
  292.         cmp.l    #'O',d0
  293.         beq    DoCTRL_P
  294.         cmp.l    #'F',d0
  295.         beq    ResetFont
  296.         cmp.l    #'X',d0
  297.         beq    ClearScreen
  298.         cmp.l    #'R',d0
  299.         beq    DoReset
  300.         cmp.l    #'H',d0
  301.         beq    DoHangUp
  302.         cmp.l    #'L',d0
  303.         beq    DoOpenCapture
  304.         cmp.l    #'K',d0
  305.         beq    DoCloseCapture
  306.         cmp.l    #'+',d0
  307.         beq    DoUpLoad
  308.         cmp.l    #'-',d0
  309.         beq    DoDownLoad
  310.         cmp.l    #'M',d0
  311.         beq    DoExecute
  312.         cmp.l    #'?',d0
  313.         beq    DoInfo
  314.         cmp.l    #'Q',d0
  315.         beq    Quit
  316.         cmp.l    #'E',d0
  317.         beq    Exit1
  318.         bra    Menu1
  319. Exit1:        lea.l    ExitText1,a0
  320.         bsr    Printer
  321.  
  322. Exit:        bsr    DoANSI
  323.         lea.l    TerminalText1,a0
  324.         bsr    Printer
  325.         bclr.b    #0,ModifyMode            ;Clear modify bit
  326.  
  327.         tst.w    SerOpen
  328.         bne    Exit_OUT
  329.         bsr    NoSerial
  330. Exit_OUT:    bra    Looper1
  331.  
  332. ResetFont:    lea.l    ResetFText1,a0
  333.         bsr    Printer
  334.         lea.l    PlainText1,a0
  335.         bsr    Printer
  336.         bra    Menu
  337.  
  338. ClearScreen:    lea.l    ClearSText1,a0
  339.         bsr    Printer
  340.         bra    Exit
  341.  
  342. DoANSI:        tst.b    UseANSI
  343.         beq    DoANSI_OUT
  344.         lea.l    ClearSText1,a0
  345.         bsr    Printer
  346. DoANSI_OUT:    rts
  347.  
  348. DoStats:    lea.l    StatsText2,a0
  349.         bsr    Printer
  350.         bsr    DoANSI
  351.         bsr    GiveStats
  352.         bsr    GetAnyKey
  353.         bra    Menu
  354.  
  355. ClearBoth:    lea.l    ClearText1,a0
  356.         bsr    Printer
  357.         clr.l    Received
  358.         clr.l    Sent
  359.         bra    Menu
  360.  
  361. DoBreak:    bsr    SendBREAK
  362.         lea.l    BreakText2,a0
  363.         bsr    Printer
  364.  
  365.         bra    Exit
  366.  
  367. DoCTRL_P:    move.b    #CTRL_P,Buffer1
  368.         bsr    Writer
  369.         lea.l    CTRL_PText1,a0
  370.         bsr    Printer
  371.         add.l    #1,Sent
  372.         bra    Exit
  373.  
  374. DoCTRL_P2:    move.b    #CTRL_P,Buffer1
  375.         bsr    Writer
  376.         add.l    #1,Sent
  377.         bra    Looper
  378.  
  379. DoReset:    lea.l    ResetText1,a0
  380.         bsr    Printer
  381.         lea.l    ResetText2,a1
  382.         bsr    GetLength
  383.         lea.l    ResetText2,a0
  384.         bsr    Writer2
  385.         bra    Exit
  386.  
  387. DoHangUp:    lea.l    HangUpText1,a0
  388.         bsr    Printer
  389.         move.l    #3*50,d1
  390.         lib    Dos,Delay
  391.         lea.l    HangUpText2,a1
  392.         bsr    GetLength
  393.         lea.l    HangUpText2,a0
  394.         bsr    Writer2
  395.         move.l    #2*55,d1
  396.         lib    Dos,Delay
  397.         lea.l    HangUpText3,a1
  398.         bsr    GetLength
  399.         lea.l    HangUpText3,a0
  400.         bsr    Writer2
  401.         bra    Exit
  402.  
  403. DoOpenCapture:    lea.l    OpenCaptureText1,a0
  404.         bsr    Printer
  405.  
  406.         tst.l    CaptureFile
  407.         bne    DoOpenCapture_ERR2
  408.  
  409.         lea.l    FileNameBuf2,a0
  410.         move.l    #128,d3
  411.         bsr    GetString
  412.  
  413.         tst.b    FileNameBuf2
  414.         beq    DoOpenCapture_OUT
  415.  
  416.         lea.l    FileNameBuf2,a0
  417.         move.l    a0,d1
  418.         move.l    #MODE_READWRITE,d2
  419.         lib    Dos,Open
  420.         move.l    d0,CaptureFile
  421.         beq    DoOpenCapture_ERR1
  422.  
  423. DoOpenCapture_OUT: bra    Menu
  424. DoOpenCapture_ERR1: lea.l    CaptureErrorText1,a0
  425.         bsr    Printer
  426.         bra    Menu
  427. DoOpenCapture_ERR2: lea.l    CaptureErrorText2,a0
  428.         bsr    Printer
  429.         bra    Menu
  430.  
  431. DoCloseCapture:    lea.l    CloseCaptureText1,a0
  432.         bsr    Printer
  433.  
  434.         move.l    CaptureFile,d1
  435.         beq    DoCloseCapture_OUT
  436.         lib    Dos,Close
  437.         clr.l    CaptureFile
  438. DoCloseCapture_OUT: bra    Menu
  439.  
  440. DoUpLoad:    lea.l    ULText2,a0
  441.         bsr    Printer
  442.         lea.l    ULProgram,a0
  443.         tst.b    (a0)
  444.         beq    DoUpLoad9
  445.  
  446.         lea.l    FileNameBuf2,a0
  447.         move.l    #128,d3
  448.         bsr    GetString
  449.  
  450.         bsr    MakeCmdString
  451.  
  452.         tst.b    ULDir
  453.         beq    DoUpLoad1
  454.         lea.l    ULDir,a0
  455.         move.l    a0,d1
  456.         move.l    #ACCESS_READ,d2
  457.         lib    Dos,Lock
  458.         move.l    d0,ULLock
  459.         bne    DoUpLoad2
  460.  
  461. DoUpLoad1:    lea.l    NoULDirText1,a0
  462.         bsr    Printer
  463.         bra    DoUpLoad5
  464.  
  465. DoUpLoad2:    move.l    ULLock,d1
  466.         lib    Dos,CurrentDir
  467.         move.l    d0,OldLock
  468.  
  469. DoUpLoad5:    lea.l    ULText3,a0
  470.         bsr    Printer
  471.  
  472.         lea.l    FileNameBuf3,a0
  473.         move.l    a0,d1
  474.         clr.l    d2
  475.         clr.l    d3
  476.         lib    Dos,Execute
  477.  
  478. ;change back to dir where we started from
  479.  
  480.         move.l    OldLock,d1
  481.         beq