home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / dev / asm / 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:    clr.b    (a2)
  469. DialList4:    lea.l    EntrySelected4,a2
  470.         tst.b    (a2)
  471.         beq    DialList5
  472.         lea.l    Entry4,a0
  473.         tst.b    (a0)
  474.         beq    DialList4.1
  475.         bsr    DialEntry
  476.         tst.l    d0
  477.         beq    Exit
  478.         cmp.l    #2,d0        ;cancel
  479.         beq    Dialer0.1
  480.         cmp.l    #3,d0        ;remove
  481.         bne    DialList5
  482. DialList4.1:    clr.b    (a2)
  483. DialList5:    lea.l    EntrySelected5,a2
  484.         tst.b    (a2)
  485.         beq    DialList6
  486.         lea.l    Entry5,a0
  487.         tst.b    (a0)
  488.         beq    DialList5.1
  489.         bsr    DialEntry
  490.         tst.l    d0
  491.         beq    Exit
  492.         cmp.l    #2,d0        ;cancel
  493.         beq    Dialer0.1
  494.         cmp.l    #3,d0        ;remove
  495.         bne    DialList6
  496. DialList5.1:    clr.b    (a2)
  497. DialList6:    lea.l    EntrySelected6,a2
  498.         tst.b    (a2)
  499.         beq    DialList7
  500.         lea.l    Entry6,a0
  501.         tst.b    (a0)
  502.         beq    DialList6.1
  503.         bsr    DialEntry
  504.         tst.l    d0
  505.         beq    Exit
  506.         cmp.l    #2,d0        ;cancel
  507.         beq    Dialer0.1
  508.         cmp.l    #3,d0        ;remove
  509.         bne    DialList7
  510. DialList6.1:    clr.b    (a2)
  511. DialList7:    lea.l    EntrySelected7,a2
  512.         tst.b    (a2)
  513.         beq    DialList8
  514.         lea.l    Entry7,a0
  515.         tst.b    (a0)
  516.         beq    DialList7.1
  517.         bsr    DialEntry
  518.         tst.l    d0
  519.         beq    Exit
  520.         cmp.l    #2,d0        ;cancel
  521.         beq    Dialer0.1
  522.         cmp.l    #3,d0        ;remove
  523.         bne    DialList8
  524. DialList7.1:    clr.b    (a2)
  525. DialList8:    lea.l    EntrySelected8,a2
  526.         tst.b    (a2)
  527.         beq    DialList9
  528.         lea.l    Entry8,a0
  529.         tst.b    (a0)
  530.         beq    DialList8.1
  531.         bsr    DialEntry
  532.         tst.l    d0
  533.         beq    Exit
  534.         cmp.l    #2,d0        ;cancel
  535.         beq    Dialer0.1
  536.         cmp.l    #3,d0        ;remove
  537.         bne    DialList9
  538. DialList8.1:    clr.b    (a2)
  539. DialList9:    lea.l    EntrySelected9,a2
  540.         tst.b    (a2)
  541.         beq    DialList10
  542.         lea.l    Entry9,a0
  543.         tst.b    (a0)
  544.         beq    DialList9.1
  545.         bsr    DialEntry
  546.         tst.l    d0
  547.         beq    Exit
  548.         cmp.l    #2,d0        ;cancel
  549.         beq    Dialer0.1
  550.         cmp.l    #3,d0        ;remove
  551.         bne    DialList10
  552. DialList9.1:    clr.b    (a2)
  553. DialList10:    lea.l    EntrySelected0,a2
  554.         tst.b    (a2)
  555.         beq    DialList11
  556.         lea.l    Entry10,a0
  557.         tst.b    (a0)
  558.         beq    DialList10.1
  559.         bsr    DialEntry
  560.         tst.l    d0
  561.         beq    Exit
  562.         cmp.l    #2,d0        ;cancel
  563.         beq    Dialer0.1
  564.         cmp.l    #3,d0        ;remove
  565.         bne    DialList11
  566. DialList10.1:    clr.b    (a2)
  567. DialList11:    tst.l    EntrySelected1
  568.         bne    DialList1
  569.         tst.l    EntrySelected5
  570.         bne    DialList1
  571.         tst.w    EntrySelected9
  572.         bne    DialList1
  573.         lea.l    EmptyText1,a0
  574.         bsr    Printer
  575.         bra    Dialer0.1
  576.  
  577. Relist:        lea.l    RelistText1,a0
  578.         bsr    Printer
  579.         bra    Dialer0.2
  580.  
  581. SingleDial:    lea.l    SingleText1,a0
  582.         bsr    Printer
  583.  
  584.         lea.l    SingleText2,a0
  585.         bsr    Printer
  586.  
  587.         move.l    _stdin,d1
  588.         move.l    #FALSE,d2
  589.         lib    Dos,SetMode
  590.  
  591.         move.l    _stdin,d1
  592.         lea.l    DialBuffer1,a0
  593.         move.l    a0,d2
  594.         move.l    #16,d3
  595.         lib    Dos,FGets
  596.         tst.l    d0
  597.         beq    Dialer0.1
  598.  
  599.         lea.l    DialBuffer1,a0
  600.         bsr    GetLLength
  601.         clr.b    -1(a0,d1.l)    ;remove LF
  602.  
  603.         move.l    _stdin,d1
  604.         move.l    #TRUE,d2
  605.         lib    Dos,SetMode
  606.  
  607.         lea.l    DialBuffer1,a1
  608.         bsr    GetLength
  609.         tst.l    d0
  610.         beq    Dialer0.1
  611.  
  612.         lea.l    DialText2,a0
  613.         bsr    Printer
  614.  
  615. SingleDial1:    lea.l    DialBuffer1,a0
  616.         bsr    DialEntry
  617.         tst.l    d0
  618.         beq    Exit
  619.         cmp.l    #1,d0
  620.         beq    SingleDial1
  621.         cmp.l    #2,d0
  622.         beq    Dialer0.1
  623.         cmp.l    #3,d0
  624.         beq    Dialer0.1
  625.         bra    Dialer0.1
  626.  
  627. Prefs:        lea.l    PrefsText1,a0
  628.         bsr    Printer
  629. Prefs1:        lea.l    PrefsText2,a0
  630.         bsr    Printer
  631. Prefs2:        move.l    _stdin,d1
  632.         lib    Dos,FGetC
  633.         cmp.l    #-1,d0
  634.         beq    Menu
  635.         cmp.l    #'S',d0
  636.         beq    SetSpeed
  637.         cmp.l    #'s',d0
  638.         beq    SetSpeed
  639.         cmp.l    #'L',d0
  640.         beq    SetLocalEcho
  641.         cmp.l    #'l',d0
  642.         beq    SetLocalEcho
  643.         cmp.l    #'C',d0
  644.         beq    ClearSettings
  645.         cmp.l    #'c',d0
  646.         beq    ClearSettings
  647.         cmp.l    #'E',d0
  648.         beq    Exit1
  649.         cmp.l    #'e',d0
  650.         beq    Exit1
  651.         cmp.l    #'V',d0
  652.         beq    DoView
  653.         cmp.l    #'v',d0
  654.         beq    DoView
  655.         cmp.l    #'M',d0
  656.         beq    MainMenu
  657.         cmp.l    #'m',d0
  658.         beq    MainMenu
  659.         cmp.l    #'-',d0
  660.         beq    MainMenu
  661.         cmp.l    #'1',d0
  662.         beq    SetCRTrans
  663.         cmp.l    #'2',d0
  664.         beq    SetLFTrans
  665.         cmp.l    #'3',d0
  666.         beq    SetCRTransIn
  667.         cmp.l    #'4',d0
  668.         beq    SetLFTransIn
  669.         cmp.l    #'5',d0
  670.         beq    SetDataBits
  671.         cmp.l    #'6',d0
  672.         beq    SetStopBits
  673.         bra    Prefs2
  674.  
  675. DoView:        lea.l    ViewText1,a0
  676.         bsr    Printer
  677.         bsr    GiveSettings
  678.         bsr    GetAnyKey
  679.         bra    Prefs1
  680.  
  681. ClearSettings:    lea.l    ClearText1,a0
  682.         bsr    Printer
  683.         move.l    #9600,Speed
  684.         move.b    #8,DataBits
  685.         move.b    #1,StopBits
  686.         clr.l    CRTranslate
  687.         bsr    SetSerParams
  688.         tst.l    d0
  689.         beq    Prefs1
  690.         lea.l    SerSetText1,a0
  691.         bsr    Printer
  692.         bra    Prefs1
  693.  
  694. SetCRTrans:    lea.l    CRTransText1,a0
  695.         bsr    Printer
  696.         lea.l    CRTransText2,a0
  697.         bsr    Printer
  698.         bsr    GetNSA
  699.         cmp.l    #-1,d0
  700.         beq    Prefs1
  701.         move.b    d0,CRTranslate
  702.         bra    Prefs1
  703.  
  704. SetLFTrans:    lea.l    LFTransText1,a0
  705.         bsr    Printer
  706.         lea.l    LFTransText2,a0
  707.         bsr    Printer
  708.         bsr    GetNSA
  709.         cmp.l    #-1,d0
  710.         beq    Prefs1
  711.         move.b    d0,LFTranslate
  712.         bra    Prefs1
  713.  
  714. SetCRTransIn:    lea.l    CRTransText3,a0
  715.         bsr    Printer
  716.         lea.l    CRTransText2,a0
  717.         bsr    Printer
  718.         bsr    GetNSA
  719.         cmp.l    #-1,d0
  720.         beq    Prefs1
  721.         move.b    d0,CRTranslateIn
  722.         bra    Prefs1
  723.  
  724. SetLFTransIn:    lea.l    LFTransText3,a0
  725.         bsr    Printer
  726.         lea.l    LFTransText2,a0
  727.         bsr    Printer
  728.         bsr    GetNSA
  729.         cmp.l    #-1,d0
  730.         beq    Prefs1
  731.         move.b    d0,LFTranslateIn
  732.         bra    Prefs1
  733.  
  734. SetLocalEcho:    lea.l    EchoText1,a0
  735.         bsr    Printer
  736.         bchg.b    #0,LocalEcho
  737.         beq    SetLocalEcho1
  738.         lea.l    EchoText3,a0
  739.         bsr    Printer
  740.         bra    Prefs1
  741. SetLocalEcho1:    lea.l    EchoText2,a0
  742.         bsr    Printer
  743.         bra    Prefs1
  744.  
  745. SetDataBits:    lea.l    DBitsText1,a0
  746.         bsr    Printer
  747.         cmp.b    #7,DataBits
  748.         beq    SetDataBits1
  749.         move.b    #7,DataBits
  750.         lea.l    DBitsText2,a0
  751.         bsr    Printer
  752.         bra    SetDataBits2
  753. SetDataBits1:    move.b    #8,DataBits
  754.         lea.l    DBitsText3,a0
  755.         bsr    Printer
  756.         bra    Prefs1
  757. SetDataBits2:    bsr    SetSerParams
  758.         tst.l    d0
  759.         beq    Prefs1
  760.         lea.l    DBitsText4,a0
  761.         bsr    Printer
  762.         bra    Prefs1
  763.  
  764. SetStopBits:    lea.l    SBitsText1,a0
  765.         bsr    Printer
  766.         cmp.b    #1,StopBits
  767.         beq    SetStopBits1
  768.         move.b    #1,StopBits
  769.         lea.l    SBitsText2,a0
  770.         bsr    Printer
  771.         bra    SetStopBits2
  772. SetStopBits1:    move.b    #2,StopBits
  773.         lea.l    SBitsText3,a0
  774.         bsr    Printer
  775.         bra    Prefs1
  776. SetStopBits2:    bsr    SetSerParams
  777.         tst.l    d0
  778.         beq    Prefs1
  779.         lea.l    SBitsText4,a0
  780.         bsr    Printer
  781.         bra    Prefs1
  782.  
  783. SetSpeed:    lea.l    SpeedText11,a0
  784.         bsr    Printer
  785. SetSpeed1:    lea.l    SpeedText1,a0
  786.         bsr    Printer
  787. SetSpeed2:    move.l    _stdin,d1
  788.         lib    Dos,FGetC
  789.         cmp.l    #-1,d0
  790.         beq    Menu
  791.         cmp.l    #'0',d0
  792.         beq    DoSpeed0
  793.         cmp.l    #'1',d0
  794.         beq    DoSpeed1
  795.         cmp.l    #'2',d0
  796.         beq    DoSpeed2
  797.         cmp.l    #'3',d0
  798.         beq    DoSpeed3
  799.         cmp.l    #'4',d0
  800.         beq    DoSpeed4
  801.         cmp.l    #'5',d0
  802.         beq    DoSpeed5
  803.         cmp.l    #'6',d0
  804.         beq    DoSpeed6
  805.         cmp.l    #'7',d0
  806.         beq    DoSpeed7
  807.         cmp.l    #'8',d0
  808.         beq    DoSpeed8
  809.         cmp.l    #'9',d0
  810.         beq    DoSpeed9
  811.         cmp.l    #'E',d0
  812.         beq    Exit1
  813.         cmp.l    #'e',d0
  814.         beq    Exit1
  815.         cmp.l    #'M',d0
  816.         beq    MainMenu
  817.         cmp.l    #'m',d0
  818.         beq    MainMenu
  819.         cmp.l    #'-',d0
  820.         beq    Prefs
  821.         bra    SetSpeed2
  822.  
  823. DoSpeed1:    move.l    #110,Speed
  824.         bra    DoSpeed_OUT
  825. DoSpeed2:    move.l    #300,Speed
  826.         bra    DoSpeed_OUT
  827. DoSpeed3:    move.l    #1200,Speed
  828.         bra    DoSpeed_OUT
  829. DoSpeed4:    move.l    #2400,Speed
  830.         bra    DoSpeed_OUT
  831. DoSpeed5:    move.l    #4800,Speed
  832.         bra    DoSpeed_OUT
  833. DoSpeed6:    move.l    #9600,Speed
  834.         bra    DoSpeed_OUT
  835. DoSpeed7:    move.l    #19200,Speed
  836.         bra    DoSpeed_OUT
  837. DoSpeed8:    move.l    #38400,Speed
  838.         bra    DoSpeed_OUT
  839. DoSpeed9:    move.l    #57600,Speed
  840.         bra    DoSpeed_OUT
  841. DoSpeed0:    move.l    #115200,Speed
  842. DoSpeed_OUT:    lea.l    SpeedText11,a0
  843.         bsr    Printer
  844.  
  845.         bsr    SetSerParams
  846.         tst.l    d0
  847.         beq    DoSpeed_OUT1
  848.  
  849.         move.l    IOWRequest,a1
  850.         move.b    IO_ERROR(a1),d0
  851.         move.b    d0,Buffer3
  852.         clr.b    Buffer3+1
  853.         lea.l    Buffer3,a0
  854.         bsr    Printer
  855.         lea.l    SpeedText12,a0
  856.         bsr    Printer
  857. DoSpeed_OUT1:    move.l    #BUFLEN,d0
  858.         bsr    Read
  859.         bsr    WriteDefaults
  860.         bra    Prefs1
  861.  
  862. ;Dials one number. Fails for three reasons, because the user decided
  863. ;to skip this entry, to cancel dialing or to remove this entry.
  864. ;If a busy is found, a value of 1 will be returned.
  865. ;
  866. ;Inputs a0 = pointer to phonenumber (ASCII text)
  867. ;
  868. ;Result d0 = Success (0=Connect, 1=Skipped, 2=Cancelled, 3=Remove this entry)
  869. ;
  870.  
  871. DialEntry:    push    d2-d7/a2-a6
  872.         move.l    a0,a4
  873.  
  874. DialEntry1:    lea.l    DialPrefix,a1
  875.         bsr    GetLength
  876.         lea.l    DialPrefix,a0
  877.         bsr    Writer2
  878.         move.l    a4,a1
  879.         bsr    GetLength
  880.         move.l    a4,a0
  881.         bsr    Writer2
  882.         lea.l    CRLFText1,a1
  883.         bsr    GetLength
  884.         lea.l    CRLFText1,a0
  885.         bsr    Writer2
  886.         lea.l    DialingText1,a0
  887.         bsr    Printer
  888.         move.l    a4,a0
  889.         bsr    Printer
  890.         lea.l    CRLFText1,a0
  891.         bsr    Printer
  892. DialEntry2:    move.l    #BUFLEN,d0
  893.         bsr    Read
  894.         tst.l    d0
  895.         beq    DialEntry3
  896.         cmp.l    #'CONN',Buffer3
  897.         beq    DialEntry_OUT1
  898.         cmp.l    #'BUSY',Buffer3
  899.         beq    DialEntry4
  900. DialEntry3:    move.l    _stdin,d1
  901.         move.l    #5000,d2
  902.         lib    Dos,WaitForChar
  903.         tst.l    d0
  904.         beq    DialEntry2
  905.         move.l    _stdin,d1
  906.         lea.l    Buffer2,a0
  907.         move.l    a0,d2
  908.         move.l    #1,d3
  909.         lib    Dos,Read
  910.         cmp.l    #1,d0
  911.         bne    DialEntry2
  912.         cmp.b    #' ',Buffer2    ;Space
  913.         beq    DialEntry_OUT2
  914.         cmp.b    #27,Buffer2    ;ESC
  915.         beq    DialEntry_OUT3
  916.         cmp.b    #8,Buffer2    ;BS
  917.         beq    DialEntry_OUT4
  918.         bra    DialEntry2
  919. DialEntry4:    lea.l    BusyText1,a0
  920.         bsr    Printer
  921.         move.l    #55,d1
  922.         lib    Dos,Delay
  923.         pull    d2-d7/a2-a6
  924.         move.l    #1,d0
  925.         rts
  926. DialEntry_OUT1:    move.l    #BUFLEN,d0
  927.         bsr    Read
  928.         lea.l    ConnectText1,a0
  929.         bsr    Printer
  930.         pull    d2-d7/a2-a6
  931.         clr.l    d0
  932.         rts
  933. DialEntry_OUT2:    lea.l    CRLFText1,a1
  934.         bsr    GetLength
  935.         lea.l    CRLFText1,a0
  936.         bsr    Writer2
  937.         lea.l    SkippedText1,a0
  938.         bsr    Printer
  939.         move.l    #55,d1
  940.         lib    Dos,Delay
  941.         pull    d2-d7/a2-a6
  942.         move.l    #1,d0
  943.         rts
  944. DialEntry_OUT3:    lea.l    CRLFText1,a1
  945.         bsr    GetLength
  946.         lea.l    CRLFText1,a0
  947.         bsr    Writer2
  948.         move.l    #55,d1
  949.         lib    Dos,Delay
  950.         lea.l    CRLFText1,a1
  951.         bsr    GetLength
  952.         lea.l    CRLFText1,a0
  953.         bsr    Writer2
  954.         lea.l    CancelledText1,a0
  955.         bsr    Printer
  956.         pull    d2-d7/a2-a6
  957.         move.l    #2,d0
  958.         rts
  959. DialEntry_OUT4:    lea.l    CRLFText1,a1
  960.         bsr    GetLength
  961.         lea.l    CRLFText1,a0
  962.         bsr    Writer2
  963.         move.l    #55,d1
  964.         lib    Dos,Delay
  965.         lea.l    CRLFText1,a1
  966.         bsr    GetLength
  967.         lea.l    CRLFText1,a0
  968.         bsr    Writer2
  969.         lea.l    RemoveText1,a0
  970.         bsr    Printer
  971.         pull    d2-d7/a2-a6
  972.         move.l    #3,d0
  973.         rts
  974.  
  975. Break:        lea.l    BreakText1,a0
  976.         bsr    Printer
  977.         clr.l    d0
  978.         rts
  979.  
  980. FlushSer:    lea.l    IOWRequest,a1
  981.         move.w    #CMD_FLUSH,IO_COMMAND(a1)
  982.         lib    Exec,DoIO        ;May freeze, too bad
  983.         bsr    WriteDefaults
  984.         rts
  985.  
  986. ClearSer:    move.l    IORRequest,a1
  987.         lib    Exec,CheckIO
  988.         tst.l    d0
  989.         beq    ClearSer1
  990.         move.l    IORRequest,a1
  991.         lib    Exec,WaitIO
  992.         clr.w    Requested
  993.         rts
  994.  
  995. ClearSer1:    move.l    IORRequest,a1
  996.         ABORTIO
  997.         move.l    IORRequest,a1
  998.         lib    Exec,WaitIO
  999.         clr.w    Requested
  1000.         rts
  1001.  
  1002. ;Flush a read request from device
  1003. ;
  1004.  
  1005. Flush:        push    d2-d7/a2-a6
  1006.  
  1007.         bsr    ClearSer
  1008.  
  1009.         tst.w    Requested
  1010.         beq    Flush_OUT1
  1011.  
  1012.         move.l    SRRPort,a0
  1013.         lib    Exec,GetMsg
  1014.         tst.l    d0
  1015.         beq    Flush_OUT1
  1016.  
  1017. Flush1:        move.l    IORRequest,a1
  1018.         tst.b    IO_ERROR(a1)
  1019.         beq    Flush_OUT1
  1020.         clr.w    Requested
  1021.         bra    Flush_OUT1
  1022.         
  1023. Flush_OUT1:    clr.l    d0
  1024.         pull    d2-d7/a2-a6
  1025.         rts
  1026.  
  1027. ;Buffered read from a device
  1028. ;
  1029. ;Inputs d0 = Buffer length (maximum amount to read)
  1030. ;
  1031. ;Result d0 = Amount actually read
  1032. ;
  1033.  
  1034. Read:        push    d2-d7/a2-a6
  1035.         move.l    d0,d4
  1036.  
  1037.         tst.w    Requested
  1038.         beq    Read3
  1039.  
  1040.         move.l    SRRPort,a0
  1041.         lib    Exec,GetMsg
  1042.         tst.l    d0
  1043.         beq    Read_OUT1
  1044.  
  1045.         move.l    IORRequest,a1
  1046.         tst.b    IO_ERROR(a1)
  1047.         beq    Read1
  1048.         clr.w    Requested
  1049.         bra    Read_OUT1
  1050.         
  1051. Read1:        add.l    #1,Received
  1052.         move.b    Buffer2,Buffer3
  1053.         move.l    #1,BufCount
  1054.         bra    Read3
  1055.  
  1056. Read2:        clr.l    BufCount
  1057.  
  1058. Read3:        move.l    IORRequest,a1
  1059.         clr.b    IO_ERROR(a1)
  1060.         or.b    #IOF_QUICK,IO_FLAGS(a1)
  1061.         move.w    #1,Requested
  1062.  
  1063. ReadLoop:    cmp.l    BufCount,d4
  1064.         beq    Read_OUT2
  1065.  
  1066.         move.l    IORRequest,a1
  1067.         BEGINIO
  1068.  
  1069.         move.l    IORRequest,a1
  1070.         tst.b    IO_ERROR(a1)
  1071.         beq    ReadLoop1
  1072.  
  1073.         move.l    SRRPort,a0
  1074.         lib    Exec,GetMsg
  1075.         clr.w    Requested
  1076.         bra    Read_OUT2
  1077.         
  1078. ReadLoop1:    move.l    IORRequest,a1
  1079.         move.b    IO_FLAGS(a1),d0
  1080.         and.b    #IOF_QUICK,d0
  1081.         beq    Read_OUT2
  1082.  
  1083.         add.l    #1,Received
  1084.         lea.l    Buffer3,a0
  1085.         add.l    BufCount,a0
  1086.         move.b    Buffer2,(a0)
  1087.         add.l    #1,BufCount
  1088.  
  1089.         cmp.b    #LF,Buffer2
  1090.         bne    ReadLoop
  1091.         move.l    IORRequest,a1
  1092.         move.b    IO_FLAGS(a1),d0
  1093.         and.b    #~IOF_QUICK,d0
  1094.         move.b    d0,IO_FLAGS(a1)
  1095.         BEGINIO
  1096.         move.l    IORRequest,a1
  1097.         tst.b    IO_ERROR(a1)
  1098.         beq    Read_OUT2
  1099.         move.l    SRRPort,a0
  1100.         lib    Exec,GetMsg
  1101.         clr.w    Requested
  1102.         bra    Read_OUT2
  1103. Read_OUT1:    clr.l    d0
  1104.         pull    d2-d7/a2-a6
  1105.         rts
  1106. Read_OUT2:    move.l    BufCount,d0
  1107.         pull    d2-d7/a2-a6
  1108.         rts
  1109.  
  1110. Writer:        add.l    #1,Sent
  1111.         move.l    IOWRequest,a1
  1112.         lib    Exec,DoIO        ;May freeze, too bad
  1113.         rts
  1114.  
  1115. ;Writes string to serial port
  1116. ;
  1117. ;D0 = Length
  1118. ;A0 = String
  1119.  
  1120. Writer2:    add.l    d0,Sent
  1121.         move.l    IOWRequest,a1
  1122.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  1123.         move.l    d0,IO_LENGTH(a1)
  1124.         move.l    a0,IO_DATA(a1)
  1125.         lib    Exec,DoIO        ;May freeze, too bad
  1126.         bsr    WriteDefaults
  1127.         rts
  1128.  
  1129. ;Reset back to default...
  1130.  
  1131. WriteDefaults:    move.l    IOWRequest,a1
  1132.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  1133.         move.l    #1,IO_LENGTH(a1)        ;writes in one byte "chunks"
  1134.         lea.l    Buffer1,a0
  1135.         move.l    a0,IO_DATA(a1)
  1136.         rts
  1137.  
  1138. SetSerParams:    bsr    Flush
  1139.         move.l    IOWRequest,a1
  1140.         clr.l    IO_LENGTH(a1)
  1141.         clr.l    IO_DATA(a1)
  1142.         move.w    #SDCMD_SETPARAMS,IO_COMMAND(a1)
  1143.         move.l    Speed,IO_BAUD(a1)
  1144.         move.b    DataBits,IO_READLEN(a1)
  1145.         move.b    DataBits,IO_WRITELEN(a1)
  1146.         move.b    StopBits,IO_STOPBITS(a1)
  1147.         lib    Exec,DoIO
  1148.         rts
  1149.  
  1150. DoCLIInput:    lea.l    Buffer1,a0
  1151.         cmp.b    #CR,Buffer1
  1152.         beq    DoCLIInput3
  1153.         cmp.b    #LF,Buffer1
  1154.         beq    DoCLIInput4
  1155. DoCLIInput1:    bsr    Writer
  1156.         btst.b    #0,LocalEcho
  1157.         beq    DoCLIInput2
  1158.         lea.l    Buffer1,a0
  1159.         bsr    Printer
  1160. DoCLIInput2:    rts
  1161. DoCLIInput3:    tst.b    CRTranslate
  1162.         beq    DoCLIInput1
  1163.         cmp.b    #1,CRTranslate
  1164.         beq    DoCLIInput2
  1165.         cmp.b    #2,CRTranslate
  1166.         bne    DoCLIInput2
  1167.         bsr    DoCLIInput1
  1168.         move.b    #LF,Buffer1
  1169.         bra    DoCLIInput1
  1170. DoCLIInput4:    tst.b    LFTranslate
  1171.         beq    DoCLIInput1
  1172.         cmp.b    #1,LFTranslate
  1173.         beq    DoCLIInput2
  1174.         cmp.b    #2,LFTranslate
  1175.         bne    DoCLIInput2
  1176.         move.b    #CR,Buffer1
  1177.         bsr    DoCLIInput1
  1178.         move.b    #LF,Buffer1
  1179.         bra    DoCLIInput1
  1180.  
  1181. DoSerialInput:    push    d0-d7/a2-a6
  1182.         lea.l    Buffer3,a0
  1183.         lea.l    Buffer4,a1
  1184. DoSerialInput1:    tst.b    (a0)
  1185.         beq    DoSerialInput3.1
  1186.         cmp.b    #CR,(a0)
  1187.         beq    DoSerialInput4
  1188.         cmp.b    #LF,(a0)
  1189.         beq    DoSerialInput6
  1190. DoSerialInput2:    move.b    (a0)+,(a1)+
  1191.         bra    DoSerialInput1
  1192. DoSerialInput3:    pull    d0-d7/a2-a6
  1193.         rts
  1194. DoSerialInput3.1: clr.b    (a1)
  1195.         pull    d0-d7/a2-a6
  1196.         rts
  1197. DoSerialInput4:    tst.b    CRTranslateIn
  1198.         beq    DoSerialInput2
  1199.         cmp.b    #1,CRTranslateIn
  1200.         bne    DoSerialInput5
  1201.         add.l    #1,a0
  1202.         bra    DoSerialInput1
  1203. DoSerialInput5:    cmp.b    #2,CRTranslateIn
  1204.         bne    DoSerialInput2
  1205.         move.b    #CR,(a1)+
  1206.         move.b    #LF,(a1)+
  1207.         add.l    #1,a0
  1208.         bra    DoSerialInput1
  1209. DoSerialInput6:    tst.b    LFTranslateIn
  1210.         beq    DoSerialInput2
  1211.         cmp.b    #1,LFTranslateIn
  1212.         bne    DoSerialInput7
  1213.         add.l    #1,a0
  1214.         bra    DoSerialInput1
  1215. DoSerialInput7:    cmp.b    #2,LFTranslateIn
  1216.         bne    DoSerialInput2
  1217.         move.b    #CR,(a1)+
  1218.         move.b    #LF,(a1)+
  1219.         add.l    #1,a0
  1220.         bra    DoSerialInput1
  1221.  
  1222. ;gets anykey from user
  1223. ;
  1224. ;Results d0 = -1 for error, otherwise d0 = key pressed
  1225.  
  1226. GetAnyKey:    lea.l    AnyKeyText1,a0
  1227.         bsr    Printer
  1228.         move.l    _stdin,d1
  1229.         lib    Dos,Flush
  1230.         move.l    _stdin,d1
  1231.         lib    Dos,FGetC
  1232.         lea.l    CRLFText1,a0
  1233.         bsr    Printer
  1234.         rts
  1235.  
  1236. ;gets input from user
  1237. ;
  1238. ;Results d0 = 0 for N, 1 for S, 2 for A, -1 for error
  1239.  
  1240. GetNSA:        move.l    _stdin,d1
  1241.         lib    Dos,FGetC
  1242.         cmp.l    #-1,d0
  1243.         beq    GetNSA_ERR1
  1244.         cmp.l    #'n',d0
  1245.         beq    GetNSA1
  1246.         cmp.l    #'N',d0
  1247.         beq    GetNSA1
  1248.         cmp.l    #'s',d0
  1249.         beq    GetNSA2
  1250.         cmp.l    #'S',d0
  1251.         beq    GetNSA2
  1252.         cmp.l    #'a',d0
  1253.         beq    GetNSA3
  1254.         cmp.l    #'A',d0
  1255.         beq    GetNSA3
  1256.         cmp.l    #CR,d0
  1257.         beq    GetNSA_ERR1
  1258.         cmp.l    #LF,d0
  1259.         beq    GetNSA_ERR1
  1260.         bra    GetNSA
  1261. GetNSA1:    lea.l    NoneText1,a0
  1262.         bsr    Printer
  1263.         move.l    #0,d0
  1264.         rts
  1265. GetNSA2:    lea.l    StripText1,a0
  1266.         bsr    Printer
  1267.         move.l    #1,d0
  1268.         rts
  1269. GetNSA3:    lea.l    AddText1,a0
  1270.         bsr    Printer
  1271.         move.l    #2,d0
  1272.         rts
  1273. GetNSA_ERR1:    move.l    #-1,d0
  1274.         rts
  1275.  
  1276. ;Give NSA
  1277. ;
  1278. ;Inputs d0 = NSA qualifier(?)
  1279. ;
  1280.  
  1281. GiveNSA:    tst.b    d0
  1282.         beq    GiveNSA1
  1283.         cmp.b    #1,d0
  1284.         beq    GiveNSA2
  1285.         cmp.b    #2,d0
  1286.         beq    GiveNSA3
  1287.         lea.l    NAText1,a0
  1288.         bsr    Printer
  1289.         rts
  1290. GiveNSA1:    lea.l    NText1,a0
  1291.         bsr    Printer
  1292.         rts
  1293. GiveNSA2:    lea.l    SText1,a0
  1294.         bsr    Printer
  1295.         rts
  1296. GiveNSA3:    lea.l    AText1,a0
  1297.         bsr    Printer
  1298.         rts
  1299.  
  1300. Nope:        lea.l    SpaceText1,a0
  1301.         bsr    Printer
  1302.         rts
  1303. Yep:        lea.l    StarText1,a0
  1304.         bsr    Printer
  1305.         rts
  1306.  
  1307. GiveSettings:    lea.l    fstrl3,a0        ;HEX->ASCII
  1308.         lea.l    Speed,a1        ;Number2Print
  1309.         lea.l    PutChProc,a2
  1310.         lea.l    SpeedText90,a3        ;Destination
  1311.         lib    Exec,RawDoFmt
  1312.  
  1313.         lea.l    CurrentText1,a0
  1314.         bsr    Printer
  1315.  
  1316.         tst.l    Speed
  1317.         beq    GiveSettings0.1
  1318.         lea.l    SpeedText90,a0
  1319.         bsr    Printer
  1320.         bra    GiveSettings0.2
  1321.  
  1322. GiveSettings0.1: lea.l    DefText1,a0
  1323.         bsr    Printer
  1324.  
  1325. GiveSettings0.2: lea.l    CurrentText2,a0
  1326.         bsr    Printer
  1327.  
  1328.         tst.w    LocalEcho
  1329.         bne    GiveSettings1
  1330.         bsr    Nope
  1331.         bra    GiveSettings2
  1332. GiveSettings1:    bsr    Yep
  1333.  
  1334. GiveSettings2:    lea.l    CurrentText7,a0
  1335.         bsr    Printer
  1336.  
  1337.         lea.l    CurrentText3,a0
  1338.         bsr    Printer
  1339.  
  1340.         move.b    CRTranslate,d0
  1341.         bsr    GiveNSA
  1342.  
  1343.         lea.l    CurrentText4,a0
  1344.         bsr    Printer
  1345.  
  1346.         move.b    LFTranslate,d0
  1347.         bsr    GiveNSA
  1348.  
  1349.         lea.l    CurrentText7,a0
  1350.         bsr    Printer
  1351.  
  1352.         lea.l    CurrentText5,a0
  1353.         bsr    Printer
  1354.  
  1355.         move.b    CRTranslateIn,d0
  1356.         bsr    GiveNSA
  1357.  
  1358.         lea.l    CurrentText6,a0
  1359.         bsr    Printer
  1360.  
  1361.         move.b    LFTranslateIn,d0
  1362.         bsr    GiveNSA
  1363.  
  1364.         lea.l    CurrentText7,a0
  1365.         bsr    Printer
  1366.  
  1367.         lea.l    CurrentText8,a0
  1368.         bsr    Printer
  1369.  
  1370.         cmp.b    #7,DataBits
  1371.         bne    GiveSettings3
  1372.         lea.l    SevenText1,a0
  1373.         bsr    Printer
  1374.         bra    GiveSettings4
  1375. GiveSettings3:    cmp.b    #8,DataBits
  1376.         bne    GiveSettings3.1
  1377.         lea.l    EightText1,a0
  1378.         bsr    Printer
  1379.         bra    GiveSettings4
  1380. GiveSettings3.1: lea.l    DefText1,a0
  1381.         bsr    Printer
  1382.  
  1383. GiveSettings4:    lea.l    CurrentText9,a0
  1384.         bsr    Printer
  1385.  
  1386.         cmp.b    #1,StopBits
  1387.         bne    GiveSettings5
  1388.         lea.l    OneText1,a0
  1389.         bsr    Printer
  1390.         bra    GiveSettings6
  1391. GiveSettings5:    cmp.b    #2,StopBits
  1392.         bne    GiveSettings5.1
  1393.         lea.l    TwoText1,a0
  1394.         bsr    Printer
  1395.         bra    GiveSettings6
  1396. GiveSettings5.1: lea.l    DefText1,a0
  1397.         bsr    Printer
  1398.  
  1399. GiveSettings6:    lea.l    CurrentText7,a0
  1400.         bsr    Printer
  1401.  
  1402.         rts
  1403.  
  1404. GiveStats:    lea.l    fstrl1,a0        ;HEX->ASCII
  1405.         lea.l    Received,a1        ;Number2Print
  1406.         lea.l    PutChProc,a2
  1407.         lea.l    ReceivedText1,a3    ;Destination
  1408.         lib    Exec,RawDoFmt
  1409.  
  1410.         lea.l    fstrl2,a0        ;HEX->ASCII
  1411.         lea.l    Sent,a1            ;Number2Print
  1412.         lea.l    PutChProc,a2
  1413.         lea.l    SentText1,a3        ;Destination
  1414.         lib    Exec,RawDoFmt
  1415.  
  1416.         lea.l    StatsText1,a0
  1417.         bsr    Printer
  1418.         lea.l    ReceivedText1,a0
  1419.         bsr    Printer
  1420.         lea.l    SentText1,a0
  1421.         bsr    Printer
  1422.         lea.l    CRLFText1,a0
  1423.         bsr    Printer
  1424.         rts
  1425.  
  1426. PrintEntries:    tst.b    DialPrefix
  1427.         beq    PrintEntries1
  1428.         lea.l    PrefixText1,a0
  1429.         bsr    Printer
  1430.         lea.l    DialPrefix,a0
  1431.         bsr    Printer
  1432.         lea.l    CRLFText1,a0
  1433.         bsr    Printer
  1434. PrintEntries1:    tst.b    Entry1
  1435.         beq    PrintEntries2
  1436.         lea.l    EntryText1,a0
  1437.         bsr    Printer
  1438.         lea.l    Entry1,a0
  1439.         bsr    Printer
  1440.         lea.l    CRLFText1,a0
  1441.         bsr    Printer
  1442. PrintEntries2:    tst.b    Entry2
  1443.         beq    PrintEntries3
  1444.         lea.l    EntryText2,a0
  1445.         bsr    Printer
  1446.         lea.l    Entry2,a0
  1447.         bsr    Printer
  1448.         lea.l    CRLFText1,a0
  1449.         bsr    Printer
  1450. PrintEntries3:    tst.b    Entry3
  1451.         beq    PrintEntries4
  1452.         lea.l    EntryText3,a0
  1453.         bsr    Printer
  1454.         lea.l    Entry3,a0
  1455.         bsr    Printer
  1456.         lea.l    CRLFText1,a0
  1457.         bsr    Printer
  1458. PrintEntries4:    tst.b    Entry4
  1459.         beq    PrintEntries5
  1460.         lea.l    EntryText4,a0
  1461.         bsr    Printer
  1462.         lea.l    Entry4,a0
  1463.         bsr    Printer
  1464.         lea.l    CRLFText1,a0
  1465.         bsr    Printer
  1466. PrintEntries5:    tst.b    Entry5
  1467.         beq    PrintEntries6
  1468.         lea.l    EntryText5,a0
  1469.         bsr    Printer
  1470.         lea.l    Entry5,a0
  1471.         bsr    Printer
  1472.         lea.l    CRLFText1,a0
  1473.         bsr    Printer
  1474. PrintEntries6:    tst.b    Entry6
  1475.         beq    PrintEntries7
  1476.         lea.l    EntryText6,a0
  1477.         bsr    Printer
  1478.         lea.l    Entry6,a0
  1479.         bsr    Printer
  1480.         lea.l    CRLFText1,a0
  1481.         bsr    Printer
  1482. PrintEntries7:    tst.b    Entry7
  1483.         beq    PrintEntries8
  1484.         lea.l    EntryText7,a0
  1485.         bsr    Printer
  1486.         lea.l    Entry7,a0
  1487.         bsr    Printer
  1488.         lea.l    CRLFText1,a0
  1489.         bsr    Printer
  1490. PrintEntries8:    tst.b    Entry8
  1491.         beq    PrintEntries9
  1492.         lea.l    EntryText8,a0
  1493.         bsr    Printer
  1494.         lea.l    Entry8,a0
  1495.         bsr    Printer
  1496.         lea.l    CRLFText1,a0
  1497.         bsr    Printer
  1498. PrintEntries9:    tst.b    Entry9
  1499.         beq    PrintEntries10
  1500.         lea.l    EntryText9,a0
  1501.         bsr    Printer
  1502.         lea.l    Entry9,a0
  1503.         bsr    Printer
  1504.         lea.l    CRLFText1,a0
  1505.         bsr    Printer
  1506. PrintEntries10:    tst.b    Entry10
  1507.         beq    PrintEntries11
  1508.         lea.l    EntryText10,a0
  1509.         bsr    Printer
  1510.         lea.l    Entry10,a0
  1511.         bsr    Printer
  1512.         lea.l    CRLFText1,a0
  1513.         bsr    Printer
  1514. PrintEntries11:    rts
  1515.  
  1516. PrintSelect:    lea.l    SelectedText1,a0
  1517.         bsr    Printer
  1518.         lea.l    SelectText1,a0
  1519.         bsr    Printer
  1520.         tst.b    EntrySelected1
  1521.         beq    PrintSelect1
  1522.         lea.l    SelectText11,a0
  1523.         bsr    Printer
  1524.         bra    PrintSelect2
  1525. PrintSelect1:    lea.l    SelectText12,a0
  1526.         bsr    Printer
  1527. PrintSelect2:    lea.l    SelectText2,a0
  1528.         bsr    Printer
  1529.         tst.b    EntrySelected2
  1530.         beq    PrintSelect3
  1531.         lea.l    SelectText11,a0
  1532.         bsr    Printer
  1533.         bra    PrintSelect4
  1534. PrintSelect3:    lea.l    SelectText12,a0
  1535.         bsr    Printer
  1536. PrintSelect4:    lea.l    SelectText3,a0
  1537.         bsr    Printer
  1538.         tst.b    EntrySelected3
  1539.         beq    PrintSelect5
  1540.         lea.l    SelectText11,a0
  1541.         bsr    Printer
  1542.         bra    PrintSelect6
  1543. PrintSelect5:    lea.l    SelectText12,a0
  1544.         bsr    Printer
  1545. PrintSelect6:    lea.l    SelectText4,a0
  1546.         bsr    Printer
  1547.         tst.b    EntrySelected4
  1548.         beq    PrintSelect7
  1549.         lea.l    SelectText11,a0
  1550.         bsr    Printer
  1551.         bra    PrintSelect8
  1552. PrintSelect7:    lea.l    SelectText12,a0
  1553.         bsr    Printer
  1554. PrintSelect8:    lea.l    SelectText5,a0
  1555.         bsr    Printer
  1556.         tst.b    EntrySelected5
  1557.         beq    PrintSelect9
  1558.         lea.l    SelectText11,a0
  1559.         bsr    Printer
  1560.         bra    PrintSelect10
  1561. PrintSelect9:    lea.l    SelectText12,a0
  1562.         bsr    Printer
  1563. PrintSelect10:    lea.l    SelectText6,a0
  1564.         bsr    Printer
  1565.         tst.b    EntrySelected6
  1566.         beq    PrintSelect11
  1567.         lea.l    SelectText11,a0
  1568.         bsr    Printer
  1569.         bra    PrintSelect12
  1570. PrintSelect11:    lea.l    SelectText12,a0
  1571.         bsr    Printer
  1572. PrintSelect12:    lea.l    SelectText7,a0
  1573.         bsr    Printer
  1574.         tst.b    EntrySelected7
  1575.         beq    PrintSelect13
  1576.         lea.l    SelectText11,a0
  1577.         bsr    Printer
  1578.         bra    PrintSelect14
  1579. PrintSelect13:    lea.l    SelectText12,a0
  1580.         bsr    Printer
  1581. PrintSelect14:    lea.l    SelectText8,a0
  1582.         bsr    Printer
  1583.         tst.b    EntrySelected8
  1584.         beq    PrintSelect15
  1585.         lea.l    SelectText11,a0
  1586.         bsr    Printer
  1587.         bra    PrintSelect16
  1588. PrintSelect15:    lea.l    SelectText12,a0
  1589.         bsr    Printer
  1590. PrintSelect16:    lea.l    SelectText9,a0
  1591.         bsr    Printer
  1592.         tst.b    EntrySelected9
  1593.         beq    PrintSelect17
  1594.         lea.l    SelectText11,a0
  1595.         bsr    Printer
  1596.         bra    PrintSelect18
  1597. PrintSelect17:    lea.l    SelectText12,a0
  1598.         bsr    Printer
  1599. PrintSelect18:    lea.l    SelectText0,a0
  1600.         bsr    Printer
  1601.         tst.b    EntrySelected0
  1602.         beq    PrintSelect19
  1603.         lea.l    SelectText13,a0
  1604.         bsr    Printer
  1605.         bra    PrintSelect20
  1606. PrintSelect19:    lea.l    SelectText14,a0
  1607.         bsr    Printer
  1608. PrintSelect20:    lea.l    CRLFText1,a0
  1609.         bsr    Printer
  1610.         rts
  1611.  
  1612. DoPhoneBook:    lea.l    PhoneBookName,a0
  1613.         move.l    a0,d1
  1614.         move.l    #MODE_OLDFILE,d2
  1615.         lib    Dos,Open
  1616.         move.l    d0,PhoneFile
  1617.         bne    DoPhoneBook1
  1618.  
  1619.         lea.l    FileErrorText1,a0
  1620.         bsr    Printer
  1621.         bra    DoPBook_ERR1
  1622.  
  1623. DoPhoneBook1:    move.l    PhoneFile,d1
  1624.         lea.l    LoadBuffer1,a0
  1625.         move.l    a0,d2
  1626.         move.l    #4,d3
  1627.         lib    Dos,Read
  1628.         cmp.l    #4,d0
  1629.         beq    DoPhoneBook2
  1630.  
  1631.         lea.l    FileErrorText2,a0
  1632.         bsr    Printer
  1633.         bra    DoPBook_ERR1
  1634.  
  1635. DoPhoneBook2:    cmp.l    #'#ST#',LoadBuffer1
  1636.         beq    DoPhoneBook3
  1637.  
  1638.         lea.l    FileErrorText3,a0
  1639.         bsr    Printer
  1640.         bra    DoPBook_ERR1
  1641.  
  1642. DoPhoneBook3:    move.l    PhoneFile,d1
  1643.         bsr    GetFileLength
  1644.         move.l    d0,PhoneLength
  1645.         beq    DoPBook_OUT
  1646.  
  1647.         move.l    PhoneLength,d0
  1648.         move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1    ;Type of memory wanted
  1649.         lib    Exec,AllocMem
  1650.         move.l    d0,PhoneMem
  1651.         bne    DoPhoneBook4
  1652.  
  1653.         lea.l    MemErrorText1,a0
  1654.         bsr    Printer
  1655.         bra    DoPBook_ERR2
  1656.  
  1657. DoPhoneBook4:    move.l    PhoneFile,d1
  1658.         move.l    PhoneMem,d2
  1659.         move.l    PhoneLength,d3
  1660.         lib    Dos,Read
  1661.         cmp.l    PhoneLength,d0
  1662.         beq    DoPhoneBook5
  1663.  
  1664.         lea.l    FileErrorText2,a0
  1665.         bsr    Printer
  1666.         bra    DoPBook_ERR2
  1667.  
  1668. DoPhoneBook5:    move.l    PhoneMem,a0
  1669.         bsr    GetLLength
  1670.         add.l    d1,a0        ;skip identifier (#ST#)
  1671.         lea.l    DialPrefix,a1
  1672.         bsr    Parse
  1673.         lea.l    Entry1,a1
  1674.         bsr    Parse
  1675.         lea.l    Entry2,a1
  1676.         bsr    Parse
  1677.         lea.l    Entry3,a1
  1678.         bsr    Parse
  1679.         lea.l    Entry4,a1
  1680.         bsr    Parse
  1681.         lea.l    Entry5,a1
  1682.         bsr    Parse
  1683.         lea.l    Entry6,a1
  1684.         bsr    Parse
  1685.         lea.l    Entry7,a1
  1686.         bsr    Parse
  1687.         lea.l    Entry8,a1
  1688.         bsr    Parse
  1689.         lea.l    Entry9,a1
  1690.         bsr    Parse
  1691.         lea.l    Entry10,a1
  1692.         bsr    Parse
  1693.  
  1694. DoPBook_OUT:    bsr    KillPFile
  1695.         bsr    KillPMem
  1696.         move.l    #-1,d0
  1697.         rts
  1698. DoPBook_ERR1:    clr.l    d0
  1699.         rts
  1700. DoPBook_ERR2:    bsr    KillPFile
  1701.         bsr    KillPMem
  1702.         clr.l    d0
  1703.         rts
  1704.  
  1705. KillPFile:    move.l    PhoneFile,d1
  1706.         beq    KillPFile1
  1707.         lib    Dos,Close
  1708.         clr.l    PhoneFile
  1709. KillPFile1:    rts
  1710.  
  1711. KillPMem:    tst.l    PhoneMem
  1712.         beq    KillPMem1
  1713.         move.l    PhoneMem,a1
  1714.         move.l    PhoneLength,d0
  1715.         lib    Exec,FreeMem
  1716.         clr.l    PhoneMem
  1717.         clr.l    PhoneLength
  1718. KillPMem1:    rts
  1719.  
  1720. ShutDown:    tst.w    SerOpen
  1721.         beq    ShutDown9000
  1722.         bsr    ClearSer
  1723.         move.l    IORRequest,a1
  1724.         lib    Exec,CloseDevice
  1725.  
  1726. ShutDown9000:    move.l    IORRequest,a0
  1727.         lib    Exec,DeleteIORequest
  1728.  
  1729.         move.l    SRRPort,a0
  1730.         lib    Exec,DeleteMsgPort
  1731.  
  1732.         move.l    IOWRequest,a0
  1733.         lib    Exec,DeleteIORequest
  1734.  
  1735.         move.l    SWRPort,a0
  1736.         lib    Exec,DeleteMsgPort
  1737.  
  1738.         move.l    _stdin,d1
  1739.         beq    ShutDown8000
  1740.         move.l    #FALSE,d2
  1741.         lib    Dos,SetMode
  1742.  
  1743. ShutDown8000:    bsr    KillPFile
  1744.         bsr    KillPMem
  1745. ShutDown7000:
  1746. ShutDown1000:    closlib    Dos
  1747.         pull    d2-d7/a2-a6
  1748.         clr.l    d0
  1749.         rts
  1750.  
  1751. ;CheckEvent waits for messages from serial.device
  1752.  
  1753. CheckEvent:    clr.l    d0
  1754.         clr.l    d1
  1755.         move.l    SRRPort,a1        ;serial.device
  1756.         move.l    a1,a2
  1757.         move.b    MP_SIGBIT(a1),d1
  1758.         bset.l    d1,d0
  1759.         lib    Exec,Wait
  1760.  
  1761. C2GetMsg2:    move.l    #-1,d0
  1762.         rts
  1763.  
  1764. ;Get length of text in given address
  1765. ;
  1766. ;Input a1 = Address of null terminated text string
  1767. ;
  1768. ;Result d0 = Length
  1769.  
  1770. GetLength:    clr.l    d0
  1771.         cmp.l    #$00,a1        ;fixes enforcer hit
  1772.         beq    GetLength_OUT
  1773. GetLength2:    add.l    #1,d0
  1774.         tst.b    (a1)+
  1775.         bne    GetLength2
  1776.         sub.l    #1,d0        ;don't include NULL
  1777. GetLength_OUT:    rts
  1778.  
  1779.  
  1780. ;Get line length of text in given address, including LF
  1781. ;
  1782. ;Input a0 = Address of LF terminated text string
  1783. ;
  1784. ;Result d1 = Length
  1785.  
  1786. GetLLength:    push    a0
  1787.         clr.l    d1
  1788.         cmp.l    #$00,a0        ;fixes enforcer hit
  1789.         beq    GetLLength_OUT
  1790. GetLLength2:    add.l    #1,d1
  1791.         cmp.b    #10,(a0)+
  1792.         bne    GetLLength2
  1793. GetLLength_OUT:    pull    a0
  1794.         rts
  1795.  
  1796. ;Gets the length of the file given
  1797. ;
  1798. ;Input d1 = File
  1799. ;
  1800. ;Result d0 = Length of file in bytes
  1801. ;
  1802.  
  1803. GetFileLength:    push    d5-d6
  1804.         move.l    d1,d6
  1805.         move.l    #00,d2
  1806.         move.l    #01,d3
  1807.         lib    Dos,Seek
  1808.         move.l    d6,d1
  1809.         lib    Dos,Seek
  1810.  
  1811.         move.l    d0,d5
  1812.         move.l    d6,d1
  1813.         move.l    #0,d2
  1814.         move.l    #-1,d3
  1815.         lib    Dos,Seek
  1816.  
  1817.         move.l    d5,d0
  1818.         pull    d5-d6
  1819.         rts
  1820.  
  1821. ;Parses string to given address. Removes spaces, tabs, CRs and comments.
  1822. ;Quits on LF or NULL.
  1823. ;
  1824. ;Inputs a0 = pointer to string to parse (source)
  1825. ;       a1 = buffer to store parsed data (destination)
  1826. ;       d0 = maximum length of output
  1827. ;
  1828. ;Results a0 = pointer with start of next data to parse
  1829. ;             i.e. pointer to data after LF or NULL
  1830. ;
  1831.  
  1832. Parse:        tst.b    (a0)        
  1833.         beq    Parse_OUT1
  1834.         cmp.b    #' ',(a0)    ;Space
  1835.         beq    ParseSkipC
  1836.         cmp.b    #9,(a0)        ;TAB
  1837.         beq    ParseSkipC
  1838.         cmp.b    #';',(a0)    ;Comment
  1839.         beq    ParseSkipL
  1840.         cmp.b    #CR,(a0)    ;CR
  1841.         beq    ParseSkipC
  1842.         cmp.b    #LF,(a0)    ;LF
  1843.         beq    Parse_OUT1
  1844.         move.b    (a0)+,(a1)+    ;copy char
  1845.         sub.l    #1,d0
  1846.         beq    Parse_OUT
  1847.         bra    Parse
  1848. ParseSkipC:    add.l    #1,a0
  1849.         bra    Parse
  1850. ParseSkipL:    bsr    GetLLength
  1851.         add.l    d1,a0
  1852. Parse_OUT:    rts
  1853. Parse_OUT1:    add.l    #1,a0
  1854.         rts
  1855.  
  1856. SkipCRLF:    cmp.b    #CR,(a0)
  1857.         bne    SkipCRLF1
  1858.         add.l    #1,a0
  1859. SkipCRLF1:    cmp.b    #LF,(a0)
  1860.         bne    SkipCRLF2
  1861.         add.l    #1,a0
  1862. SkipCRLF2:    rts
  1863.  
  1864. ConvASCII:    clr.l    d0
  1865.         clr.l    d1
  1866.         cmp.b    #' ',(a0)
  1867.         bne    ConvASCII2
  1868.         add.l    #1,a0
  1869. ConvASCII2:    move.b    (a0),d1
  1870.         cmp.b    #'0',d1
  1871.         bcs    ConvASCII_OUT
  1872.         cmp.b    #'9',d1
  1873.         bhi    ConvASCII_OUT
  1874.         sub.b    #'0',d1
  1875.         mulu.w    #10,d0
  1876.         add.l    d1,d0
  1877.         add.l    #1,a0
  1878.         bra    ConvASCII2
  1879. ConvASCII_OUT:    rts
  1880.  
  1881. ;Error etc. messages
  1882.  
  1883. Usage:        lea.l    UsageText1,a0
  1884.         bsr    Printer
  1885.         bra    ShutDown
  1886.  
  1887. NoDos:        add.l    #8,sp
  1888.         pull    d2-d7/a2-a6
  1889.         move.l    #RETURN_FAIL,d0
  1890.         rts
  1891.  
  1892. NotInteractive:    add.l    #8,sp
  1893.         lea.l    NotIntText1,a0
  1894.         bsr    Printer
  1895.         bra    ShutDown
  1896.  
  1897. NoMsgPort:    lea.l    NoMsgPortText1,a0
  1898.         bsr    Printer
  1899.         bra    ShutDown
  1900.  
  1901. NoIOReq:    lea.l    NoIOReqText1,a0
  1902.         bsr    Printer
  1903.         bra    ShutDown
  1904.  
  1905. NoSerial:    lea.l    NoSerialText1,a0
  1906.         bsr    Printer
  1907.         move.l    SerName,a0
  1908.         bsr    Printer
  1909.         lea.l    NoSerialText2,a0
  1910.         bsr    Printer
  1911.         bra    ShutDown
  1912.  
  1913. Printer:    printa    a0,_stdout
  1914.         rts
  1915.  
  1916. PutChProc:    tst.b    d0
  1917.         beq    PutChProc_OUT
  1918.         move.b    d0,(a3)+
  1919. PutChProc_OUT:    rts
  1920.  
  1921. ;Structures
  1922.  
  1923. ;lib stuff
  1924.  
  1925.         libnames
  1926.  
  1927. ;Other stuff, part I
  1928.  
  1929. OurTask:    dc.l    0
  1930. SRRPort:    dc.l    0
  1931. IORRequest:    dc.l    0
  1932. SWRPort:    dc.l    0
  1933. IOWRequest:    dc.l    0
  1934. _stdout:    dc.l    0
  1935. _stdin:        dc.l    0
  1936. BufCount:    dc.l    0
  1937. Requested:    dc.w    0
  1938. Sent:        dc.l    0            ;Count sent chars
  1939. Received:    dc.l    0            ;Count reveived chars
  1940. PhoneFile:    dc.l    0
  1941. PhoneLength:    dc.l    0
  1942. PhoneMem:    dc.l    0
  1943.  
  1944. ;Other stuff part II
  1945.  
  1946. EntrySelected1:    dc.b    0
  1947. EntrySelected2:    dc.b    0
  1948. EntrySelected3:    dc.b    0
  1949. EntrySelected4:    dc.b    0
  1950. EntrySelected5:    dc.b    0
  1951. EntrySelected6:    dc.b    0
  1952. EntrySelected7:    dc.b    0
  1953. EntrySelected8:    dc.b    0
  1954. EntrySelected9:    dc.b    0
  1955. EntrySelected0:    dc.b    0
  1956. Speed:        dc.l    0
  1957. LocalEcho:    dc.w    0        ;bit 0 (0=no echo, 1=echo)
  1958. CRTranslate:    dc.b    0        ;0=none, 1=strip, 2=add LF
  1959. LFTranslate:    dc.b    0        ;0=none, 1=strip, 2=add CR
  1960. CRTranslateIn:    dc.b    0        ;0=none, 1=strip, 2=add LF
  1961. LFTranslateIn:    dc.b    0        ;0=none, 1=strip, 2=add CR
  1962. DataBits:    dc.b    0
  1963. StopBits:    dc.b    0
  1964.  
  1965. ;Serial device stuff
  1966.  
  1967. SerName:    dc.l    SerName2        ;A pointer!
  1968. SerUnit:    dc.l    0
  1969. SerOpen:    dc.w    0
  1970.  
  1971. ;Strings, error
  1972.  
  1973. BreakText1:    dc.b    "***Break",10,0
  1974. NotIntText1:    dc.b    "ERROR: Please don't redirect input!",10,0
  1975. NoMsgPortText1:    dc.b    "ERROR: Couldn't get message port!",10,0
  1976. NoIOReqText1:    dc.b    "ERROR: Couldn't get SerialIOReq!",10,0
  1977. NoSerialText1:    dc.b    "ERROR: Couldn't open ",0
  1978. SerName2:    dc.b    "serial.device",0
  1979. NoSerialText2:    dc.b    10,0
  1980. FileErrorText1:    dc.b    "ERROR: Couldn't open S:ShellTerm.phone",13,10,0
  1981. FileErrorText2:    dc.b    "ERROR: Couldn't read file!",13,10,0
  1982. FileErrorText3:    dc.b    "ERROR: Incorrect filetype!",13,10,0
  1983. MemErrorText1:    dc.b    "ERROR: Out of memory!",13,10,0
  1984.  
  1985. ;Strings, Main menu
  1986.  
  1987. MenuText1:    dc.b    13,10,"ShellTerm menu. Please choose item:",13,10
  1988.         dc.b    13,10,"S) Statistics"
  1989.         dc.b    13,10,"C) Clear statistics"
  1990.         dc.b    13,10,"D) Dialer"
  1991.         dc.b    13,10,"O) Send CTRL-P (ASCII: DLE #16 $10 &020)"
  1992.         dc.b    13,10,"R) Reset modem (Using Hayes-commands)"
  1993.         dc.b    13,10,"H) Hangup line (Using Hayes-commands)"
  1994.         dc.b    13,10,"P) Preferences"
  1995.         dc.b    13,10,"?) Program and author information"
  1996.         dc.b    13,10,"Q) Quit ShellTerm"
  1997.         dc.b    13,10,"E) Exit menus",13,10
  1998.         dc.b    13,10,"Selection: ",0
  1999. InfoText1:    dc.b    "Information",13,10,0
  2000. CTRL_PText1:    dc.b    "CTRL-P sent",13,10,0
  2001. ExitText1:    dc.b    "Exit",13,10
  2002. TerminalText1:    dc.b    13,10,"Terminal mode active:",13,10,0
  2003. StartText1:    dc.b    "Welcome to ShellTerm. Use CTRL-P to get menu.",13,10,0
  2004. QuitText1:    dc.b    "Quit",13,10,0
  2005. StatsText1:    dc.b    "Statistics:",13,10,0
  2006. StatsText2:    dc.b    "Statistics",13,10,0
  2007. DialerText1:    dc.b    "Dialer",13,10,0
  2008. PrefsText1:    dc.b    "Preferences",13,10,0
  2009. ReceivedText1:    dc.b    "                            ",00,00,0    ;max of 4294967295
  2010. ;            "   4294967295 bytes received",CR,LF
  2011. SentText1:    dc.b    "                        ",00,00,0    ;max of 4294967295
  2012. ;            "   4294967295 bytes sent",CR,LF
  2013. fstrl1:        dc.b    "   %10.ld bytes received",13,10,0
  2014. fstrl2:        dc.b    "   %10.ld bytes sent",0
  2015. ClearText1:    dc.b    "Cleared",13,10,0
  2016. CRLFText1:    dc.b    CR,LF,0
  2017. ResetText1:    dc.b    "Reset",13,10,0
  2018. ResetText2:    dc.b    "ATZ",13,10,0
  2019. HangUpText1:    dc.b    "Hangup",13,10,0
  2020. HangUpText2:    dc.b    "+++",0
  2021. HangUpText3:    dc.b    "ATH",13,10,0
  2022.  
  2023. ;Preferences
  2024.  
  2025. PrefsText2:    dc.b    13,10,"ShellTerm preferences:",13,10
  2026. PrefText3:    dc.b    13,10,"Options:   (S)elect speeds      (L)ocal echo"
  2027.         dc.b    13,10,"      OUT: (1) CR translate     (2) LF translate"
  2028.         dc.b    13,10,"       IN: (3) CR translate     (4) LF translate"
  2029.         dc.b    13,10,"           (5) Set databits     (6) Set stopbits"
  2030.         dc.b    13,10,"           (C)lear settings     (V)iew settings"
  2031.         dc.b    13,10,"           (M)ain menu          (E)xit menus",13,10
  2032.         dc.b    13,10,"Selection: ",0
  2033. ViewText1:    dc.b    "View settings",13,10,0
  2034. SpeedText11:    dc.b    "Speed",13,10,0
  2035. EchoText1:    dc.b    "Toggle echo",13,10,0
  2036. CRTransText1:    dc.b    "CR translate (OUT)",13,10,0
  2037. LFTransText1:    dc.b    "LF translate (OUT)",13,10,0
  2038. CRTransText3:    dc.b    "CR translate (IN)",13,10,0
  2039. LFTransText3:    dc.b    "LF translate (IN)",13,10,0
  2040. EchoText2:    dc.b    13,10,"Local echo is now enabled",13,10,0
  2041. EchoText3:    dc.b    13,10,"Local echo is now disabled",13,10,0
  2042. DBitsText1:    dc.b    "Toggle databits",13,10,0
  2043. DBitsText2:    dc.b    13,10,"Using 7 databits",13,10,0
  2044. DBitsText3:    dc.b    13,10,"Using 8 databits",13,10,0
  2045. DBitsText4:    dc.b    13,10,"ERROR: Couldn't set databits!",13,10,0
  2046. SBitsText1:    dc.b    "Toggle stopbits",13,10,0
  2047. SBitsText2:    dc.b    13,10,"Using 1 stopbit",13,10,0
  2048. SBitsText3:    dc.b    13,10,"Using 2 stopbits",13,10,0
  2049. SBitsText4:    dc.b    13,10,"ERROR: Couldn't set stopbits!",13,10,0
  2050. CRTransText2:    dc.b    13,10,"(N)one, (S)trip, (A)dd LF: ",0
  2051. LFTransText2:    dc.b    13,10,"(N)one, (S)trip, (A)dd CR: ",0
  2052. AnyKeyText1:    dc.b    13,10,"Please press any key: ",0
  2053. NoneText1:    dc.b    "None",13,10,0
  2054. StripText1:    dc.b    "Strip",13,10,0
  2055. AddText1:    dc.b    "Add",13,10,0
  2056.  
  2057. CurrentText1:    dc.b    13,10,"Current settings: Speed (",0
  2058. CurrentText2:    dc.b    "), Local echo (",0
  2059. CurrentText3:    dc.b    "                  CR xlate out (",0
  2060. CurrentText4:    dc.b    "), LF xlate out (",0
  2061. CurrentText5:    dc.b    "                  CR xlate in (",0
  2062. CurrentText6:    dc.b    "), LR xlate in (",0
  2063. CurrentText7:    dc.b    ")",13,10,0
  2064. CurrentText8:    dc.b    "                  Databits (",0
  2065. CurrentText9:    dc.b    ") Stopbits (",0
  2066. NAText1:    dc.b    "N/A",0
  2067. DefText1:    dc.b    "Default",0
  2068. StarText1:    dc.b    "*",0
  2069. SpaceText1:    dc.b    " ",0
  2070. NText1:        dc.b    "N",0
  2071. SText1:        dc.b    "S",0
  2072. AText1:        dc.b    "A",0
  2073. OneText1:    dc.b    "1",0
  2074. TwoText1:    dc.b    "2",0
  2075. SevenText1:    dc.b    "7",0
  2076. EightText1:    dc.b    "8",0
  2077.  
  2078. ;Speed prefs
  2079.  
  2080. SpeedText1:    dc.b    13,10,"1) 110 bps",13,10
  2081. SpeedText2:    dc.b    "2) 300 bps",13,10
  2082. SpeedText3:    dc.b    "3) 1200 bps",13,10
  2083. SpeedText4:    dc.b    "4) 2400 bps",13,10
  2084. SpeedText5:    dc.b    "5) 4800 bps",13,10
  2085. SpeedText6:    dc.b    "6) 9600 bps",13,10
  2086. SpeedText7:    dc.b    "7) 19 200 bps",13,10
  2087. SpeedText8:    dc.b    "8) 38 400 bps",13,10
  2088. SpeedText9:    dc.b    "9) 57 600 bps",13,10
  2089. SpeedText10:    dc.b    "0) 115 200 bps",13,10
  2090.         dc.b    13,10,"Options: (0-9) Select speed     (-) Previous menu"
  2091.         dc.b    13,10,"           (M)ain menu          (E)xit menus",13,10
  2092.         dc.b    13,10,"Selection: ",0
  2093. SpeedText12:    dc.b    13,10,"ERROR: Couldn't set that speed. Please reselect!",13,10,0
  2094. SerSetText1:    dc.b    13,10,"ERROR: Couldn't set serial parameters!",13,10,0
  2095. fstrl3:        dc.b    "%ld",0
  2096. SpeedText90:    dc.b    0,0,0,0,0,0,0,0
  2097.  
  2098. ;Dialer stuff
  2099.  
  2100. DialerText2:    dc.b    13,10,"ShellTerm auto-dialer (phonebook)",13,10
  2101.         dc.b    13,10,"Entries:",13,10,13,10,0
  2102. PrefixText1:    dc.b    "Prefix: ",0
  2103. EntryText1:    dc.b    "1) ",0
  2104. EntryText2:    dc.b    "2) ",0
  2105. EntryText3:    dc.b    "3) ",0
  2106. EntryText4:    dc.b    "4) ",0
  2107. EntryText5:    dc.b    "5) ",0
  2108. EntryText6:    dc.b    "6) ",0
  2109. EntryText7:    dc.b    "7) ",0
  2110. EntryText8:    dc.b    "8) ",0
  2111. EntryText9:    dc.b    "9) ",0
  2112. EntryText10:    dc.b    "0) ",0
  2113. DialerText3:    dc.b    13,10,"Options: (0-9) Un/select entry  (R)elist numbers"
  2114.         dc.b    13,10,"           (S)ingle dial        (D)ial list"
  2115.         dc.b    13,10,"           (C)lear list         (A)ll"
  2116.         dc.b    13,10,"           (M)ain menu          (E)xit menus",13,10
  2117. SelectionText1:    dc.b    13,10,"Selection: ",0
  2118. DialText1:    dc.b    "Dial list",13,10,0
  2119. MainMenuText1:    dc.b    "Main menu",13,10,0
  2120. SingleText1:    dc.b    "Dial number",13,10,0
  2121. SingleText2:    dc.b    "Number to dial: ",0
  2122. RelistText1:    dc.b    "Relist",13,10,13,10,0
  2123. EntryTextXIV:    dc.b    "Entry",13,10,0
  2124. ClearText2:    dc.b    "Clear",13,10,0
  2125. AllText1:    dc.b    "All",13,10,0
  2126. HelpText1:    dc.b    "Help",13,10,0
  2127. DialingText1:    dc.b    13,10,"Dialing: ",0
  2128. DialText2:    dc.b    13,10,"Space to skip, Backspace to remove this entry, Escape to quit",13,10,0
  2129. ConnectText1:    dc.b    "Connection established",13,10,0
  2130. BusyText1:    dc.b    "Busy",13,10,0
  2131. SkippedText1:    dc.b    13,10,"Skipping entry",13,10,0
  2132. CancelledText1:    dc.b    13,10,"Quitting",13,10,0
  2133. RemoveText1:    dc.b    13,10,"Removing this entry",13,10,0
  2134. EmptyText1:    dc.b    13,10,"List is empty",13,10,0
  2135. SelectedText1:    dc.b    13,10,"Entries selected:",13,10,0
  2136. SelectText1:    dc.b    "1 (",0
  2137. SelectText2:    dc.b    "2 (",0
  2138. SelectText3:    dc.b    "3 (",0
  2139. SelectText4:    dc.b    "4 (",0
  2140. SelectText5:    dc.b    "5 (",0
  2141. SelectText6:    dc.b    "6 (",0
  2142. SelectText7:    dc.b    "7 (",0
  2143. SelectText8:    dc.b    "8 (",0
  2144. SelectText9:    dc.b    "9 (",0
  2145. SelectText0:    dc.b    "0 (",0
  2146. SelectText11:    dc.b    "*) ",0
  2147. SelectText12:    dc.b    " ) ",0
  2148. SelectText13:    dc.b    "*)",0
  2149. SelectText14:    dc.b    " )",0
  2150. PhoneBookName:    dc.b    "S:ShellTerm.phone",0
  2151.  
  2152. ;Strings, names
  2153.  
  2154. STVersion:    dc.b    "$VER: "
  2155. UsageText1:    dc.b    "ShellTerm 1.02 (6.8.92) (C)opyright Tomi Blinnikka 1992",13,10,13,10
  2156.         dc.b    10,"           !!! BETA TESTER VERSION !!!",13,10,13,10,13,10
  2157.         dc.b    "USAGE: ShellTerm [Unit] [Device]",13,10,13,10
  2158.         dc.b    "       Where: [Unit] is the unit number",13,10
  2159.         dc.b    "              [Device] is the device name",13,10,13,10
  2160.         dc.b    "       Default [Device] is serial.device",13,10,13,10
  2161.         dc.b    "Use current shell as a terminal program.",13,10
  2162.         dc.b    "See docs for more information.",13,10,0
  2163. AuthorText1:    dc.b    13,10,"Name    : ShellTerm",13,10
  2164.         dc.b    "Version : 1.02 (6.8.92)",13,10
  2165.         dc.b    "Author  : Tomi Blinnikka",13,10,13,10
  2166.         dc.b    "(C)opyright Tomi Blinnikka 1992",13,10,0
  2167.         ds.l    0
  2168.  
  2169. ;Buffers
  2170.  
  2171. Buffer1:    dcb.b    2,0        ;For writes to serial (read from CLI)
  2172. Buffer2:    dcb.b    2,0        ;For reads
  2173. Buffer3:    dcb.b    BUFLEN,0    ;For reads from serial
  2174. Buffer4:    dcb.b    BUFLEN*2,0    ;For writes to CLI
  2175.  
  2176. LoadBuffer1:    dcb.b    4,0        ;for header
  2177. DialPrefix:    dc.b    "ATDT"        ;dial prefix
  2178.         dcb.b    18-4,0
  2179. Entry1:        dcb.b    18,0        ;Entry 1
  2180. Entry2:        dcb.b    18,0        ;Entry 2
  2181. Entry3:        dcb.b    18,0        ;Entry 3
  2182. Entry4:        dcb.b    18,0        ;Entry 4
  2183. Entry5:        dcb.b    18,0        ;Entry 5
  2184. Entry6:        dcb.b    18,0        ;Entry 6
  2185. Entry7:        dcb.b    18,0        ;Entry 7
  2186. Entry8:        dcb.b    18,0        ;Entry 8
  2187. Entry9:        dcb.b    18,0        ;Entry 9
  2188. Entry10:    dcb.b    18,0        ;Entry 10
  2189. DialBuffer1:    dcb.b    18,0        ;for single dial
  2190.  
  2191.         end
  2192.  
  2193.