home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / ShellTerm / STv1.02.S < prev    next >
Text File  |  1993-12-21  |  43KB  |  2,193 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. *************************************************
  13.  
  14.     INCLUDE    "JMPLibs.i"
  15.     INCLUDE    "exec/types.i"
  16.     INCLUDE    "exec/nodes.i"
  17.     INCLUDE    "exec/lists.i"
  18.     INCLUDE    "exec/ports.i"
  19.     INCLUDE    "exec/memory.i"
  20.     INCLUDE    "exec/devices.i"
  21.     INCLUDE    "exec/io.i"
  22.     INCLUDE    "exec/tasks.i"
  23.     INCLUDE    "libraries/dosextens.i"
  24.     INCLUDE    "libraries/dos.i"
  25.     INCLUDE    "devices/serial.i"
  26.  
  27.     INCLUDE    "XREF:2.0.xref"
  28.     INCLUDE    "XREF:exec.xref"
  29.     INCLUDE    "XREF:dos.xref"
  30.  
  31.  
  32. LF:        EQU    10
  33. CR:        EQU    13
  34. CTRL_O:        EQU    $0F
  35. CTRL_P:        EQU    $10
  36.  
  37. QUIT_KEY:    EQU    CTRL_P
  38. STATS_KEY:    EQU    CTRL_O
  39.  
  40. FALSE:        EQU    0
  41. TRUE:        EQU    1
  42.  
  43. BUFLEN:        EQU    1024
  44.  
  45.         section    ST,CODE
  46.  
  47.         push    d2-d7/a2-a6
  48.         push    d0/a0
  49.  
  50.         sub.l    a1,a1            ;Find our task
  51.         lib    Exec,FindTask
  52.         move.l    d0,OurTask
  53.  
  54.         openlib    Dos,NoDos        ;Keep at beginning
  55.  
  56. CLIStart:    lib    Dos,Output
  57.         move.l    d0,_stdout
  58.         lib    Dos,Input
  59.         move.l    d0,_stdin
  60.         move.l    d0,d1
  61.         lib    Dos,IsInteractive
  62.         tst.l    d0
  63.         beq    NotInteractive
  64.         pull    d0/a0
  65.         clr.b    -1(a0,d0.l)
  66.         cmp.b    #'?',(a0)
  67.         beq    Usage
  68.         cmp.w    #'-?',(a0)
  69.         beq    Usage
  70.         cmp.w    #'-h',(a0)
  71.         beq    Usage
  72.  
  73. Cont0.2:    bsr    ConvASCII
  74.         tst.w    d0
  75.         beq    Cont1
  76.         move.w    d0,SerUnit
  77. Cont1:        cmp.b    #' ',(a0)
  78.         bne    Cont1.1
  79.         add.l    #1,a0
  80. Cont1.1:    tst.b    (a0)
  81.         beq    Cont1.2
  82.         move.l    a0,SerName
  83. Cont1.2:
  84.  
  85. ;Create read reply port for serial.device (or modem0.device etc.)
  86.  
  87. MainStart:    lib    Exec,CreateMsgPort
  88.         move.l    d0,SRRPort
  89.         beq    NoMsgPort
  90.  
  91. ;Create read IOReq for serial.device (or for other device, but size is EXTSER)
  92.  
  93.         move.l    #IOEXTSER_SIZE,d0
  94.         move.l    SRRPort,a0
  95.         lib    Exec,CreateIORequest
  96.         move.l    d0,IORRequest
  97.         beq    NoIOReq
  98.  
  99.         move.l    IORRequest,a1
  100.         move.w    #CMD_READ,IO_COMMAND(a1)
  101.         lea.l    Buffer2,a0
  102.         move.l    a0,IO_DATA(a1)
  103.         move.l    #1,IO_LENGTH(a1)
  104.  
  105. ;Create write reply port for serial.device (or modem0.device etc.)
  106.  
  107.         lib    Exec,CreateMsgPort
  108.         move.l    d0,SWRPort
  109.         beq    NoMsgPort
  110.  
  111. ;Create write IOReq for serial.device (or for other device, but size is EXTSER)
  112.  
  113.         move.l    #IOEXTSER_SIZE,d0
  114.         move.l    SWRPort,a0
  115.         lib    Exec,CreateIORequest
  116.         move.l    d0,IOWRequest
  117.         beq    NoIOReq
  118.  
  119.         bsr    WriteDefaults
  120.  
  121. ;open serial.device
  122.  
  123.         move.l    SerName,a0
  124.         move.l    SerUnit,d0
  125.         move.l    IORRequest,a1
  126.         move.b    #SERF_SHARED,IO_SERFLAGS(a1)
  127.         clr.l    d1                ;no flags
  128.         lib    Exec,OpenDevice
  129.         tst.l    d0
  130.         bne    NoSerial
  131.         move.w    #$1,SerOpen        ;just to tell if open
  132.  
  133. ;Copy info from one req to the other
  134.  
  135.         move.l    IORRequest,a0
  136.         move.l    IOWRequest,a1
  137.         move.l    IO_DEVICE(a0),IO_DEVICE(a1)
  138.         move.l    IO_UNIT(a0),IO_UNIT(a1)
  139.         add.l    #48,a0            ;get start of ioser
  140.         add.l    #48,a1
  141.         move.l    #34,d0
  142.         lib    Exec,CopyMem
  143.         lea.l    StartText1,a0
  144.         bsr    Printer
  145.  
  146.         bsr    DoPhoneBook
  147.  
  148. ;Change mode for CLI to RAW:
  149.  
  150.         move.l    _stdin,d1
  151.         move.l    #TRUE,d2
  152.         lib    Dos,SetMode
  153.  
  154. ;Flush extra text
  155.  
  156.         move.l    _stdin,d1
  157.         lib    Dos,Flush
  158.  
  159. Looper:        move.l    _stdin,d1
  160.         move.l    #5000,d2
  161.         lib    Dos,WaitForChar
  162.         tst.l    d0
  163.         beq    Looper1
  164.         move.l    _stdin,d1
  165.         lea.l    Buffer1,a0
  166.         move.l    a0,d2
  167.         move.l    #1,d3
  168.         lib    Dos,Read
  169.         cmp.b    #QUIT_KEY,Buffer1
  170.         beq    Menu
  171.         bsr    DoCLIInput
  172. Looper1:    move.l    #BUFLEN,d0
  173.         bsr    Read
  174.         tst.l    d0
  175.         beq    Looper
  176.  
  177.         lea.l    Buffer3,a0
  178.         clr.b    0(a0,d0.l)    ;null terminated, please!
  179.  
  180.         bsr    DoSerialInput
  181.  
  182.         move.l    _stdout,d1
  183.         lea.l    Buffer4,a1
  184.         bsr    GetLength
  185.         move.l    d0,d3
  186.         lea.l    Buffer4,a0
  187.         move.l    a0,d2
  188.         lib    Dos,Write
  189.  
  190.         bra    Looper
  191.  
  192. Menu:        lea.l    MenuText1,a0
  193.         bsr    Printer
  194. Menu1:        move.l    _stdin,d1
  195.         lib    Dos,FGetC
  196.         cmp.l    #-1,d0
  197.         beq    ShutDown
  198.         cmp.l    #'p',d0
  199.         beq    Prefs
  200.         cmp.l    #'P',d0
  201.         beq    Prefs
  202.         cmp.l    #'s',d0
  203.         beq    DoStats
  204.         cmp.l    #'S',d0
  205.         beq    DoStats
  206.         cmp.l    #'c',d0
  207.         beq    ClearBoth
  208.         cmp.l    #'C',d0
  209.         beq    ClearBoth
  210.         cmp.l    #'d',d0
  211.         beq    Dialer
  212.         cmp.l    #'D',d0
  213.         beq    Dialer
  214.         cmp.l    #'o',d0
  215.         beq    DoCTRL_P
  216.         cmp.l    #'O',d0
  217.         beq    DoCTRL_P
  218.         cmp.l    #'r',d0
  219.         beq    DoReset
  220.         cmp.l    #'R',d0
  221.         beq    DoReset
  222.         cmp.l    #'h',d0
  223.         beq    DoHangUp
  224.         cmp.l    #'H',d0
  225.         beq    DoHangUp
  226.         cmp.l    #'?',d0
  227.         beq    DoInfo
  228.         cmp.l    #'q',d0
  229.         beq    Quit
  230.         cmp.l    #'Q',d0
  231.         beq    Quit
  232.         cmp.l    #'e',d0
  233.         beq    Exit1
  234.         cmp.l    #'E',d0
  235.         beq    Exit1
  236.         bra    Menu1
  237. Exit1:        lea.l    ExitText1,a0
  238.         bsr    Printer
  239.         bra    Looper1
  240.  
  241. DoStats:    lea.l    StatsText2,a0
  242.         bsr    Printer
  243.         lea.l    CRLFText1,a0
  244.         bsr    Printer
  245.         bsr    GiveStats
  246.         bsr    GetAnyKey
  247.         bra    Menu
  248.  
  249. ClearBoth:    lea.l    ClearText1,a0
  250.         bsr    Printer
  251.         clr.l    Received
  252.         clr.l    Sent
  253.         bra    Menu
  254.  
  255. DoCTRL_P:    move.b    CTRL_P,Buffer1
  256.         bsr    Writer
  257.         lea.l    CTRL_PText1,a0
  258.         bsr    Printer
  259.         add.l    #1,Sent
  260.         bra    Exit
  261.  
  262. DoReset:    lea.l    ResetText1,a0
  263.         bsr    Printer
  264.         lea.l    ResetText2,a1
  265.         bsr    GetLength
  266.         lea.l    ResetText2,a0
  267.         bsr    Writer2
  268.         bra    Exit
  269.  
  270. DoHangUp:    lea.l    HangUpText1,a0
  271.         bsr    Printer
  272.         move.l    #55,d1
  273.         lib    Dos,Delay
  274.         lea.l    HangUpText2,a1
  275.         bsr    GetLength
  276.         lea.l    HangUpText2,a0
  277.         bsr    Writer2
  278.         move.l    #55,d1
  279.         lib    Dos,Delay
  280.         lea.l    HangUpText3,a1
  281.         bsr    GetLength
  282.         lea.l    HangUpText3,a0
  283.         bsr    Writer2
  284.         bra    Exit
  285.  
  286. DoInfo:        lea.l    InfoText1,a0
  287.         bsr    Printer
  288.         lea.l    AuthorText1,a0
  289.         bsr    Printer
  290.         bsr    GetAnyKey
  291.         bra    Menu
  292.  
  293. Quit:        lea.l    QuitText1,a0
  294.         bsr    Printer
  295.         lea.l    CRLFText1,a0
  296.         bsr    Printer
  297.         bsr    GiveStats
  298.         bra    ShutDown
  299.  
  300. Exit:        lea.l    TerminalText1,a0
  301.         bsr    Printer
  302.         bra    Looper1
  303.  
  304. Dialer:        lea.l    DialerText1,a0
  305.         bsr    Printer
  306. Dialer0.1:    lea.l    DialerText2,a0
  307.         bsr    Printer
  308. Dialer0.2:    bsr    PrintEntries
  309. Dialer0.3:    bsr    PrintSelect
  310. Dialer0.4:    lea.l    DialerText3,a0
  311.         bsr    Printer
  312. Dialer1:    move.l    _stdin,d1
  313.         lib    Dos,FGetC
  314.         cmp.l    #-1,d0
  315.         beq    Menu
  316.         cmp.l    #'0',d0
  317.         beq    DoEntry0
  318.         cmp.l    #'1',d0
  319.         beq    DoEntry1
  320.         cmp.l    #'2',d0
  321.         beq    DoEntry2
  322.         cmp.l    #'3',d0
  323.         beq    DoEntry3
  324.         cmp.l    #'4',d0
  325.         beq    DoEntry4
  326.         cmp.l    #'5',d0
  327.         beq    DoEntry5
  328.         cmp.l    #'6',d0
  329.         beq    DoEntry6
  330.         cmp.l    #'7',d0
  331.         beq    DoEntry7
  332.         cmp.l    #'8',d0
  333.         beq    DoEntry8
  334.         cmp.l    #'9',d0
  335.         beq    DoEntry9
  336.         cmp.l    #'D',d0
  337.         beq    DialList
  338.         cmp.l    #'d',d0
  339.         beq    DialList
  340.         cmp.l    #'E',d0
  341.         beq    Exit1
  342.         cmp.l    #'e',d0
  343.         beq    Exit1
  344.         cmp.l    #'M',d0
  345.         beq    MainMenu
  346.         cmp.l    #'m',d0
  347.         beq    MainMenu
  348.         cmp.l    #'-',d0
  349.         beq    MainMenu
  350.         cmp.l    #'S',d0
  351.         beq    SingleDial
  352.         cmp.l    #'s',d0
  353.         beq    SingleDial
  354.         cmp.l    #'R',d0
  355.         beq    Relist
  356.         cmp.l    #'r',d0
  357.         beq    Relist
  358.         cmp.l    #'C',d0
  359.         beq    ClearList
  360.         cmp.l    #'c',d0
  361.         beq    ClearList
  362.         cmp.l    #'A',d0
  363.         beq    SelectAll
  364.         cmp.l    #'a',d0
  365.         beq    SelectAll
  366.         cmp.l    #'h',d0
  367.         beq    DialerHelp
  368.         cmp.l    #'H',d0
  369.         beq    DialerHelp
  370.         cmp.l    #'?',d0
  371.         beq    DialerHelp
  372.         bra    Dialer1
  373.  
  374. DialerHelp:    lea.l    HelpText1,a0
  375.         bsr    Printer
  376.         bra    Dialer0.4
  377.  
  378. ClearList:    lea.l    ClearText2,a0
  379.         bsr    Printer
  380.         clr.l    EntrySelected1
  381.         clr.l    EntrySelected5
  382.         clr.w    EntrySelected9
  383.         bra    DoEntry_OUT1
  384.  
  385. SelectAll:    lea.l    AllText1,a0
  386.         bsr    Printer
  387.         move.l    #$01010101,EntrySelected1
  388.         move.l    #$01010101,EntrySelected5
  389.         move.w    #$0101,EntrySelected9
  390.         bra    DoEntry_OUT1
  391.  
  392. DoEntry1:    bchg.b    #0,EntrySelected1
  393.         bra    DoEntry_OUT
  394. DoEntry2:    bchg.b    #0,EntrySelected2
  395.         bra    DoEntry_OUT
  396. DoEntry3:    bchg.b    #0,EntrySelected3
  397.         bra    DoEntry_OUT
  398. DoEntry4:    bchg.b    #0,EntrySelected4
  399.         bra    DoEntry_OUT
  400. DoEntry5:    bchg.b    #0,EntrySelected5
  401.         bra    DoEntry_OUT
  402. DoEntry6:    bchg.b    #0,EntrySelected6
  403.         bra    DoEntry_OUT
  404. DoEntry7:    bchg.b    #0,EntrySelected7
  405.         bra    DoEntry_OUT
  406. DoEntry8:    bchg.b    #0,EntrySelected8
  407.         bra    DoEntry_OUT
  408. DoEntry9:    bchg.b    #0,EntrySelected9
  409.         bra    DoEntry_OUT
  410. DoEntry0:    bchg.b    #0,EntrySelected0
  411. DoEntry_OUT:    lea.l    EntryTextXIV,a0
  412.         bsr    Printer
  413. DoEntry_OUT1:    bsr    PrintSelect
  414.         lea.l    SelectionText1,a0
  415.         bsr    Printer
  416.         bra    Dialer1
  417.  
  418. MainMenu:    lea.l    MainMenuText1,a0
  419.         bsr    Printer
  420.         bra    Menu
  421.  
  422. DialList:    lea.l    DialText1,a0
  423.         bsr    Printer
  424.         lea.l    DialText2,a0
  425.         bsr    Printer
  426.  
  427. DialList1:    lea.l    EntrySelected1,a2
  428.         tst.b    (a2)
  429.         beq    DialList2
  430.         lea.l    Entry1,a0
  431.         tst.b    (a0)
  432.         beq    DialList1.1
  433.         bsr    DialEntry
  434.         tst.l    d0
  435.         beq    Exit
  436.         cmp.l    #2,d0        ;cancel
  437.         beq    Dialer0.1
  438.         cmp.l    #3,d0        ;remove
  439.         bne    DialList2
  440. DialList1.1:    clr.b    (a2)
  441. DialList2:    lea.l    EntrySelected2,a2
  442.         tst.b    (a2)
  443.         beq    DialList3
  444.         lea.l    Entry2,a0
  445.         tst.b    (a0)
  446.         beq    DialList2.1
  447.         bsr    DialEntry
  448.         tst.l    d0
  449.         beq    Exit
  450.         cmp.l    #2,d0        ;cancel
  451.         beq    Dialer0.1
  452.         cmp.l    #3,d0        ;remove
  453.         bne    DialList3
  454. DialList2.1:    clr.b    (a2)
  455. DialList3:    lea.l    EntrySelected3,a2
  456.         tst.b    (a2)
  457.         beq    DialList4
  458.         lea.l    Entry3,a0
  459.         tst.b    (a0)
  460.         beq    DialList3.1
  461.         bsr    DialEntry
  462.         tst.l    d0
  463.         beq    Exit
  464.         cmp.l    #2,d0        ;cancel
  465.         beq    Dialer0.1
  466.         cmp.l    #3,d0        ;remove
  467.         bne    DialList4
  468. DialList3.1