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