home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / NBBS / Utilities / Digitaline.bak < prev    next >
Text File  |  1993-12-21  |  4KB  |  222 lines

  1. ***********************************************
  2. *                          *
  3. *              (C)opyright 1991               *
  4. *                          *
  5. *             by  Tomi Blinnikka              *
  6. *                          *
  7. *      Don´t try to understand the code       *
  8. *                          *
  9. *                          *
  10. *    This is just a program that turns     *
  11. *    the on/off the special stuff with     *
  12. *    a so called digital phoneline          *
  13. *                          *
  14. ***********************************************
  15.  
  16.     INCLUDE    "JMPLibs.i"
  17.     INCLUDE    "exec/types.i"
  18.     INCLUDE    "exec/io.i"
  19.     INCLUDE    "libraries/dos.i"
  20.     INCLUDE    "devices/serial.i"
  21.  
  22.     INCLUDE    "dos.xref"
  23.     INCLUDE    "gfx.xref"
  24.     INCLUDE    "intuition.xref"
  25.     INCLUDE    "exec.xref"
  26.  
  27.     XREF    _CreatePort
  28.     XREF    _DeletePort
  29.     XREF    _CreateExtIO
  30.     XREF    _DeleteExtIO
  31.     XREF    _printf
  32.  
  33.     XDEF    _DOSBase
  34.     XDEF    _SysBase
  35.     XDEF    _stdout
  36.  
  37. Start:        move.l    a0,OptionAddress    ;Get intputs from user
  38.         clr.b    -1(a0,d0.l)        ;add null to end of text
  39.         openlib    Dos,ShutDown
  40.         move.l    _DosBase(pc),_DOSBase
  41.         move.l    $4,_SysBase
  42.  
  43.         lib    Dos,Output
  44.         move.l    d0,_stdout
  45.  
  46.         move.l    OptionAddress(pc),a0
  47.         tst.b    (a0)
  48.         beq    NoCMD
  49.         cmp.b    #"?",(a0)
  50.         beq    CommandLineHelp
  51.         cmp.w    #"-?",(a0)
  52.         beq    CommandLineHelp
  53.         cmp.w    #"-h",(a0)
  54.         beq    CommandLineHelp
  55.         cmp.w    #"-k",(a0)
  56.         bne    Start1
  57.         move.w    #$00,Status
  58.         jmp    Start_END
  59. Start1:        cmp.w    #"-t",(a0)
  60.         bne    CommandLineHelp
  61.         move.w    #$01,Status
  62.  
  63. Start_END:
  64.  
  65. ;Create reply port for serial.device (or modem0.device etc.)
  66.  
  67.         move.l    #0,-(sp)
  68.         pea    SRPortName        ;S(erial)R(eply)PortName
  69.         jsr    _CreatePort
  70.         add.l    #8,sp
  71.         move.l    d0,SRPort
  72.         beq    ShutDown
  73.  
  74. ;Create IOReq for serial.device (or for other device, but size is EXTSER)
  75.  
  76.         move.l    #IOEXTSER_SIZE,-(sp)
  77.         move.l    d0,-(sp)
  78.         jsr    _CreateExtIO
  79.          add.l    #8,sp
  80.         move.l    d0,SerDevIO
  81.         bne    OpenSer
  82.         print    <"Couldn't get SerialIOReq!",13,10>,_stdout
  83.         jmp    ShutDown
  84.  
  85. ;open serial.device
  86.  
  87. OpenSer:    move.w    #$00,SerOpen
  88.         lea.l    SerName(pc),a0
  89.         move.l    SerUnit(pc),d0
  90.         move.l    SerDevIO(pc),a1
  91.         move.b    #SERF_SHARED,IO_SERFLAGS(a1)
  92.         move.l    #$00,d1                ;no flags
  93.         lib    Exec,OpenDevice
  94.         tst.l    d0
  95.         beq    OpenSer1
  96.         print    <"Couldn't open requested device!",13,10>,_stdout
  97.         jmp    ShutDown
  98.  
  99. OpenSer1:    move.w    #$1,SerOpen        ;just to tell if open
  100.         move.l    SRPort(pc),a1
  101.         move.l    #00,d1
  102.         move.b    MP_SIGBIT(a1),d1
  103.         bset.l    d1,WaitMask
  104.  
  105. SendCom:    move.l    SerDevIO(pc),a1
  106.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  107.         move.l    #-1,IO_LENGTH(a1)
  108.         cmp.w    #$01,Status
  109.         bne    SendCom1
  110.         lea.l    TransferOff(pc),a0
  111.         jmp    SendCom2
  112. SendCom1:    lea.l    KnockOff(pc),a0
  113. SendCom2:    move.l    a0,IO_DATA(a1)
  114.         lib    Exec,SendIO
  115.  
  116.         move.l    WaitMask(pc),d0
  117.         lib    Exec,Wait
  118.  
  119.         move.l    SerDevIO(pc),a1
  120.         lib    Exec,CheckIO
  121.         tst.l    d0
  122.         bne    SendCom3
  123.         move.l    SerDevIO(pc),a1
  124.         lib    Exec,AbortIO
  125. SendCom3:    move.l    SerDevIO(pc),a1
  126.         lib    Exec,WaitIO
  127.  
  128.  
  129. CloseSer:
  130.         move.l    SerDevIO(pc),a1
  131.         lib    Exec,CloseDevice
  132.         move.w    #$00,SerOpen
  133.  
  134.         move.l    #IOEXTSER_SIZE,-(sp)
  135.         move.l    SerDevIO(pc),-(sp)
  136.         jsr    _DeleteExtIO
  137.         add.l    #8,sp
  138.         move.l    #$00,SerDevIO
  139.  
  140.         move.l    SRPort(pc),-(sp)
  141.         jsr    _DeletePort
  142.         add.l    #4,sp
  143.         move.l    #$00,SRPort
  144.         jmp    ShutDown8800
  145.  
  146. ShutDown:    tst.l    SerOpen
  147.         beq    ShutDown9000
  148.         move.l    SerDevIO(pc),a1
  149.         lib    Exec,CloseDevice
  150.         
  151. ShutDown9000:    move.l    SerDevIO(pc),d0
  152.         tst.l    d0
  153.         beq    ShutDown8900
  154.         move.l    #IOEXTSER_SIZE,-(sp)
  155.         move.l    d0,-(sp)
  156.         jsr    _DeleteExtIO
  157.         add.l    #8,sp
  158.  
  159. ShutDown8900:    move.l    SRPort(pc),d0
  160.         tst.l    d0
  161.         beq    ShutDown8800
  162.         move.l    d0,-(sp)
  163.         jsr    _DeletePort
  164.         add.l    #4,sp
  165.  
  166. ShutDown8800:
  167. ShutDown8700:
  168. ShutDown1000:    closlib    Dos
  169.  
  170. ShutDownOut:    move.l    #RETURN_OK,d0
  171.         rts
  172.  
  173.         INCLUDE    "LWF:NBBS/Utilities/DiCommandLineHelp.i"
  174.  
  175. ;bits
  176.  
  177. WaitMask    dc.l    SIGBREAKF_CTRL_C
  178.  
  179. ;Structures
  180.  
  181. _DOSBase     dc.l    0
  182. _SysBase    dc.l    0
  183.  
  184.         libnames
  185. ;file stuff
  186.  
  187. _stdout        dc.l    0            ;ex. outfile
  188. OptionAddress    dc.l    0
  189.  
  190. ;device stuff
  191.  
  192. SerOpen        dc.w    0            ;Equals 1 if open
  193. SerDevIO    dc.l    0
  194. SerUnit        dc.l    0
  195. SerName        dc.b    "modem0.device",0
  196.         ds.l    0
  197.  
  198. ;port stuff
  199.  
  200. SRPortName    dc.b    "Digitaline_SerialPort",0
  201.         ds.l    0
  202. SRPort        dc.l    0
  203.  
  204. ;other stuff XIV
  205.  
  206. Status:        dc.w    0        ;0=Knock, 1=transfer
  207.  
  208. ;debug stuff
  209.  
  210. fstr        dc.b    "$%lx",10,0
  211.         ds.l    0
  212. KnockOff:    dc.b    "ATDT#43#",13,0
  213.         ds.l    0
  214. KnockOn:    dc.b    "ATDT*43#",13,0
  215.         ds.l    0
  216. TransferOn:    dc.b    "ATDT*21*4582088#"
  217.         ds.l    0
  218. TransferOff:    dc.b    "ATDT#21#",13,0
  219.         ds.l    0
  220.  
  221.         END
  222.