home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / ShellTerm / ST1.17.S < prev    next >
Text File  |  1993-12-21  |  59KB  |  2,986 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. *************************************************
  85.  
  86.     INCLUDE    "JMPLibs.i"
  87.     INCLUDE    "exec/types.i"
  88.     INCLUDE    "exec/nodes.i"
  89.     INCLUDE    "exec/lists.i"
  90.     INCLUDE    "exec/ports.i"
  91.     INCLUDE    "exec/memory.i"
  92.     INCLUDE    "exec/devices.i"
  93.     INCLUDE    "exec/io.i"
  94.     INCLUDE    "exec/tasks.i"
  95.     INCLUDE    "libraries/dosextens.i"
  96.     INCLUDE    "libraries/dos.i"
  97.     INCLUDE    "devices/serial.i"
  98.  
  99.     INCLUDE    "XREF:2.0.xref"
  100.     INCLUDE    "XREF:exec.xref"
  101.     INCLUDE    "XREF:dos.xref"
  102.  
  103.  
  104. CTRL_B:        EQU    2
  105. CTRL_F:        EQU    6
  106. BS:        EQU    8
  107. TAB:        EQU    9
  108. LF:        EQU    10
  109. CR:        EQU    13
  110. CTRL_N:        EQU    $E
  111. CTRL_O:        EQU    $F
  112. CTRL_P:        EQU    $10
  113. DEL:        EQU    127
  114. CSI:        EQU    $9B
  115. Cursor_Up:    EQU    'A'
  116. Cursor_Down:    EQU    'B'
  117. Cursor_Left:    EQU    'D'
  118. Cursor_Right:    EQU    'C'
  119.  
  120. MENU_KEY:    EQU    CTRL_P
  121. STATS_KEY:    EQU    CTRL_O
  122.  
  123. FALSE:        EQU    0
  124. TRUE:        EQU    1
  125.  
  126. BUFLEN:        EQU    1024
  127. ENTRYLENGTH:    EQU    20
  128.  
  129.         section    ST,CODE
  130.  
  131.         push    d2-d7/a2-a6
  132.         push    d0/a0
  133.  
  134.         openlib    Dos,NoDos        ;Keep at beginning
  135.  
  136. CLIStart:    lib    Dos,Output
  137.         move.l    d0,_stdout
  138.         lib    Dos,Input
  139.         move.l    d0,_stdin
  140.         move.l    d0,d1
  141.         lib    Dos,IsInteractive
  142.         tst.l    d0
  143.         beq    NotInteractive
  144.         pull    d0/a0
  145.  
  146.         lea.l    CLTemplate1,a0
  147.         move.l    a0,d1
  148.         lea.l    CLArray1,a0
  149.         move.l    a0,d2
  150.         clr.l    d3
  151.         lib    Dos,ReadArgs
  152.         move.l    d0,RDArgs1
  153.         beq    NoRDArgs
  154.  
  155.         move.l    CLArray1,a0
  156.         lea.l    FileNameBuf1,a1
  157.         tst.b    (a0)
  158.         beq    Parse2
  159. CLCopyLoop:    move.b    (a0)+,(a1)+
  160.         tst.b    -1(a1)
  161.         bne    CLCopyLoop
  162.  
  163. Parse2:        tst.l    OptPortName
  164.         beq    Parse3            ;No port specified
  165.  
  166.         lib    Exec,CreateMsgPort
  167.         move.l    d0,OptPort
  168.         beq    NoMsgPort
  169.  
  170. ;Add port to public lists
  171.  
  172.         move.l    OptPort,a1
  173.         move.l    OptPortName,a0
  174.         move.l    a0,LN_NAME(a1)
  175.         lib    Exec,AddPort
  176.  
  177. Parse3:
  178.  
  179. ;Create read reply port for serial.device (or modem0.device etc.)
  180.  
  181. MainStart:    openlib    Utility,NoUtility        ;Keep at beginning
  182.         lib    Exec,CreateMsgPort
  183.         move.l    d0,SRRPort
  184.         beq    NoMsgPort
  185.  
  186. ;Add port to public lists
  187.  
  188.         move.l    SRRPort,a1
  189.         lea.l    RPortText1,a0
  190.         move.l    a0,LN_NAME(a1)
  191.         lib    Exec,AddPort
  192.  
  193. ;Create read IOReq for serial.device (or for other device, but size is EXTSER)
  194.  
  195.         move.l    #IOEXTSER_SIZE,d0
  196.         move.l    SRRPort,a0
  197.         lib    Exec,CreateIORequest
  198.         move.l    d0,IORRequest
  199.         beq    NoIOReq
  200.  
  201. ;Create write reply port for serial.device (or modem0.device etc.)
  202.  
  203.         lib    Exec,CreateMsgPort
  204.         move.l    d0,SWRPort
  205.         beq    NoMsgPort
  206.  
  207. ;Add port to public lists
  208.  
  209.         move.l    SWRPort,a1
  210.         lea.l    WPortText1,a0
  211.         move.l    a0,LN_NAME(a1)
  212.         lib    Exec,AddPort
  213.  
  214. ;Create write IOReq for serial.device (or for other device, but size is EXTSER)
  215.  
  216.         move.l    #IOEXTSER_SIZE,d0
  217.         move.l    SWRPort,a0
  218.         lib    Exec,CreateIORequest
  219.         move.l    d0,IOWRequest
  220.         beq    NoIOReq
  221.  
  222.         bsr    LoadPrefsFile
  223.  
  224.         bsr    OpenSerial
  225.         bsr    SetSerParams
  226.  
  227. ;        tst.l    d0
  228. ;        bne    ShutDown
  229.  
  230.         lea.l    StartText1,a0
  231.         bsr    Printer
  232.  
  233. ;Change mode for CLI to RAW:
  234.  
  235.         move.l    _stdin,d1
  236.         move.l    #TRUE,d2
  237.         lib    Dos,SetMode
  238.  
  239. ;Flush extra text
  240.  
  241.         move.l    _stdin,d1
  242.         lib    Dos,Flush
  243.  
  244. Looper:        move.l    _stdin,d1
  245.         move.l    #5000,d2
  246.         lib    Dos,WaitForChar
  247.         tst.l    d0
  248.         beq    Looper1
  249.         move.l    _stdin,d1
  250.         lea.l    Buffer1,a0
  251.         move.l    a0,d2
  252.         move.l    #1,d3
  253.         lib    Dos,Read
  254.         cmp.b    #MENU_KEY,Buffer1
  255.         beq    Menu
  256.         move.b    CPAssign,d0
  257.         cmp.b    Buffer1,d0
  258.         beq    DoCTRL_P2
  259.         bsr    DoCLIInput
  260. Looper1:    move.l    #BUFLEN,d0
  261.         move.l    #1,d1
  262.         bsr    Read
  263.         tst.l    d0
  264.         beq    Looper
  265.  
  266.         lea.l    Buffer3,a0
  267.         clr.b    0(a0,d0.l)    ;null terminated, please!
  268.  
  269.         bsr    DoSerialInput
  270.  
  271.         move.l    _stdout,d1
  272.         lea.l    Buffer4,a1
  273.         bsr    GetLength
  274.         move.l    d0,d3
  275.         lea.l    Buffer4,a0
  276.         move.l    a0,d2
  277.         lib    Dos,Write
  278.  
  279.         bsr    DoCapture
  280.  
  281.         bra    Looper
  282.  
  283. Menu:        bsr    DoANSI
  284.         lea.l    MenuText1,a0
  285.         bsr    Printer
  286. Menu1:        move.l    _stdin,d1
  287.         lib    Dos,FGetC
  288.         cmp.l    #-1,d0
  289.         beq    ShutDown
  290.         cmp.l    #'a',d0
  291.         bcs    Menu2
  292.         cmp.l    #'z',d0
  293.         bhi    Menu2
  294.         sub.l    #32,d0
  295. Menu2:        cmp.l    #'P',d0
  296.         beq    Prefs
  297.         cmp.l    #'S',d0
  298.         beq    DoStats
  299.         cmp.l    #'C',d0
  300.         beq    ClearBoth
  301.         cmp.l    #'D',d0
  302.         beq    Dialer
  303.         cmp.l    #'B',d0
  304.         beq    DoBreak
  305.         cmp.l    #'O',d0
  306.         beq    DoCTRL_P
  307.         cmp.l    #'F',d0
  308.         beq    ResetFont
  309.         cmp.l    #'X',d0
  310.         beq    ClearScreen
  311.         cmp.l    #'R',d0
  312.         beq    DoReset
  313.         cmp.l    #'H',d0
  314.         beq    DoHangUp
  315.         cmp.l    #'L',d0
  316.         beq    DoOpenCapture
  317.         cmp.l    #'K',d0
  318.         beq    DoCloseCapture
  319.         cmp.l    #'+',d0
  320.         beq    DoUpLoad
  321.         cmp.l    #'-',d0
  322.         beq    DoDownLoad
  323.         cmp.l    #'M',d0
  324.         beq    DoExecute
  325.         cmp.l    #'?',d0
  326.         beq    DoInfo
  327.         cmp.l    #'Q',d0
  328.         beq    Quit
  329.         cmp.l    #'E',d0
  330.         beq    Exit1
  331.         bra    Menu1
  332. Exit1:        bclr.b    #0,ModifyMode            ;Clear modify bit
  333.         lea.l    ExitText1,a0
  334.         bsr    Printer
  335.         bra    Looper1
  336.  
  337. ResetFont:    lea.l    ResetFText1,a0
  338.         bsr    Printer
  339.         lea.l    PlainText1,a0
  340.         bsr    Printer
  341.         bra    Menu
  342.  
  343. ClearScreen:    lea.l    ClearSText1,a0
  344.         bsr    Printer
  345.         bra    Exit
  346.  
  347. DoANSI:        tst.b    UseANSI
  348.         beq    DoANSI_OUT
  349.         lea.l    ClearSText1,a0
  350.         bsr    Printer
  351. DoANSI_OUT:    rts
  352.  
  353. DoStats:    lea.l    StatsText2,a0
  354.         bsr    Printer
  355.         bsr    DoANSI
  356.         bsr    GiveStats
  357.         bsr    GetAnyKey
  358.         bra    Menu
  359.  
  360. ClearBoth:    lea.l    ClearText1,a0
  361.         bsr    Printer
  362.         clr.l    Received
  363.         clr.l    Sent
  364.         bra    Menu
  365.  
  366. DoBreak:    bsr    SendBREAK
  367.         lea.l    BreakText2,a0
  368.         bsr    Printer
  369.  
  370.         bra    Exit
  371.  
  372. DoCTRL_P:    move.b    #CTRL_P,Buffer1
  373.         bsr    Writer
  374.         lea.l    CTRL_PText1,a0
  375.         bsr    Printer
  376.         add.l    #1,Sent
  377.         bra    Exit
  378.  
  379. DoCTRL_P2:    move.b    #CTRL_P,Buffer1
  380.         bsr    Writer
  381.         add.l    #1,Sent
  382.         bra    Looper
  383.  
  384. DoReset:    lea.l    ResetText1,a0
  385.         bsr    Printer
  386.         lea.l    ResetText2,a1
  387.         bsr    GetLength
  388.         lea.l    ResetText2,a0
  389.         bsr    Writer2
  390.         bra    Exit
  391.  
  392. DoHangUp:    lea.l    HangUpText1,a0
  393.         bsr    Printer
  394.         move.l    #3*50,d1
  395.         lib    Dos,Delay
  396.         lea.l    HangUpText2,a1
  397.         bsr    GetLength
  398.         lea.l    HangUpText2,a0
  399.         bsr    Writer2
  400.         move.l    #2*55,d1
  401.         lib    Dos,Delay
  402.         lea.l    HangUpText3,a1
  403.         bsr    GetLength
  404.         lea.l    HangUpText3,a0
  405.         bsr    Writer2
  406.         bra    Exit
  407.  
  408. DoOpenCapture:    lea.l    OpenCaptureText1,a0
  409.         bsr    Printer
  410.  
  411.         tst.l    CaptureFile
  412.         bne    DoOpenCapture_ERR2
  413.  
  414.         lea.l    FileNameBuf2,a0
  415.         move.l    #128,d3
  416.         bsr    GetString
  417.  
  418.         tst.b    FileNameBuf2
  419.         beq    DoOpenCapture_OUT
  420.  
  421.         lea.l    FileNameBuf2,a0
  422.         move.l    a0,d1
  423.         move.l    #MODE_READWRITE,d2
  424.         lib    Dos,Open
  425.         move.l    d0,CaptureFile
  426.         beq    DoOpenCapture_ERR1
  427.  
  428. DoOpenCapture_OUT: bra    Menu
  429. DoOpenCapture_ERR1: lea.l    CaptureErrorText1,a0
  430.         bsr    Printer
  431.         bra    Menu
  432. DoOpenCapture_ERR2: lea.l    CaptureErrorText2,a0
  433.         bsr    Printer
  434.         bra    Menu
  435.  
  436. DoCloseCapture:    lea.l    CloseCaptureText1,a0
  437.         bsr    Printer
  438.  
  439.         move.l    CaptureFile,d1
  440.         beq    DoCloseCapture_OUT
  441.         lib    Dos,Close
  442.         clr.l    CaptureFile
  443. DoCloseCapture_OUT: bra    Menu
  444.  
  445. DoUpLoad:    lea.l    ULText2,a0
  446.         bsr    Printer
  447.         lea.l    ULProgram,a0
  448.         tst.b    (a0)
  449.         beq    DoUpLoad9
  450.  
  451.         lea.l    FileNameBuf2,a0
  452.         move.l    #128,d3
  453.         bsr    GetString
  454.  
  455.         bsr    MakeCmdString
  456.  
  457.         tst.b    ULDir
  458.         beq    DoUpLoad1
  459.         lea.l    ULDir,a0
  460.         move.l    a0,d1
  461.         move.l    #ACCESS_READ,d2
  462.         lib    Dos,Lock
  463.         move.l    d0,ULLock
  464.         bne    DoUpLoad2
  465.  
  466. DoUpLoad1:    lea.l    NoULDirText1,a0
  467.         bsr    Printer
  468.         bra    DoUpLoad5
  469.  
  470. DoUpLoad2:    move.l    ULLock,d1
  471.         lib    Dos,CurrentDir
  472.