home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / ShellTerm / STv1.09.S < prev   
Text File  |  1993-12-21  |  57KB  |  2,854 lines

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