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

  1. ***********************************************
  2. *                                             *
  3. *              (C)opyright 1991               *
  4. *                                             *
  5. *             by  Tomi Blinnikka              *
  6. *                                             *
  7. *      Don´t try to understand the code       *
  8. *                                             *
  9. ***********************************************
  10.     
  11. ;Yeah, sure we'll see! If Mr. Tomi Blinnikka can write something that
  12. ;actually works... especially a BBS-software. LET ME LAUGH!
  13.  
  14.     INCLUDE    "JMPLibs.i"
  15.     INCLUDE    "exec/types.i"
  16.     INCLUDE    "exec/io.i"
  17.     INCLUDE    "libraries/dos.i"
  18.     INCLUDE    "devices/serial.i"
  19.     INCLUDE    "intuition/intuition.i"
  20.  
  21.     INCLUDE    "XREF:dos.xref"
  22.     INCLUDE    "XREF:gfx.xref"
  23.     INCLUDE    "XREF:intuition.xref"
  24.     INCLUDE    "XREF:exec.xref"
  25.  
  26.     XREF    _CreatePort
  27.     XREF    _DeletePort
  28.     XREF    _CreateExtIO
  29.     XREF    _DeleteExtIO
  30.     XREF    _printf
  31.  
  32.     XDEF    _DOSBase
  33.     XDEF    _SysBase
  34.     XDEF    _stdout
  35.  
  36. ;USFPV  - Unnecessary Setups For Pre-release Versions
  37.  
  38. USFPV:        move.b    #$00,SerFlags
  39.         bset.b    #SERF_XDISABLED,SerFlags
  40. ;        bset.b    #SERF_RAD_BOOGIE,SerFlags    ;not used
  41.         move.l    #2400,SerBaud
  42.  
  43. Start:        move.l    a0,ConfigAddress    ;Get Config filename
  44.         clr.b    -1(a0,d0.l)        ;add null to end of filename
  45.         openlib    Dos,ShutDown
  46.         move.l    _DosBase(pc),_DOSBase
  47.         move.l    $4,_SysBase
  48.  
  49.         lib    Dos,Output
  50.         move.l    d0,_stdout
  51.  
  52.         move.l    ConfigAddress(pc),a0
  53.         tst.b    (a0)
  54.         bne    GotFileName
  55.  
  56. GotFileName:    move.l    ConfigAddress(pc),d1
  57.         move.l    #MODE_OLDFILE,d2
  58.         lib    Dos,Open
  59.         move.l    d0,ConfigFile
  60.         beq    ConfigNotOpen
  61.  
  62. ;Close config file, we've got what we want
  63.  
  64.         move.l    ConfigFile(pc),d1
  65.         lib    Dos,Close
  66.         move.l    #$00,ConfigFile
  67.  
  68. ;Create reply port for serial.device (or modem0.device etc.)
  69.  
  70.         move.l    #0,-(sp)
  71. ;        move.l    #0,-(sp)
  72.         pea    SRPortName        ;S(erial)R(eply)PortName
  73.         jsr    _CreatePort
  74.         add.l    #8,sp
  75.         move.l    d0,SRPort
  76.         beq    ShutDown
  77.  
  78. ;Create IOReq for serial.device (or for other device, but size is EXTSER)
  79.  
  80.         move.l    #IOEXTSER_SIZE,-(sp)
  81.         move.l    d0,-(sp)
  82.         jsr    _CreateExtIO
  83.          add.l    #8,sp
  84.         move.l    d0,SerDevIO
  85.         bne    OpenSer
  86.         print    <"Couldn't get SerialIOReq!",13,10>,_stdout
  87.         jmp    ShutDown
  88.  
  89. ;open serial.device
  90.  
  91. OpenSer:    move.w    #$00,SerOpen
  92.         lea.l    SerName(pc),a0
  93.         move.l    SerUnit(pc),d0
  94.         move.l    SerDevIO(pc),a1
  95.         move.b    #SERF_SHARED,IO_SERFLAGS(a1)    ;for debugging!
  96.         move.l    #$00,d1                ;no flags
  97.         lib    Exec,OpenDevice
  98.         tst.l    d0
  99.         beq    OpenSer1
  100.         print    <"Couldn't open requested device!",13,10>,_stdout
  101.         jmp    ShutDown
  102.  
  103. OpenSer1:    move.w    #$1,SerOpen        ;just to tell if open
  104.         move.l    SRPort(pc),a1
  105.         move.l    #00,d1
  106.         move.b    MP_SIGBIT(a1),d1
  107.         bset.l    d1,WaitMask
  108.  
  109.         jsr    SetUpSer
  110.         tst.l    d1
  111.         beq    ResetModem
  112.         print    <"***BREAK",13,10,"I couldn't set baud rate etc!",13,10>,_stdout
  113.         jmp    ShutDown
  114.  
  115. ResetModem:    move.l    SerDevIO(pc),a1
  116.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  117.         move.l    #-1,IO_LENGTH(a1)
  118.         lea.l    TestCMD2(pc),a0
  119.         move.l    a0,IO_DATA(a1)
  120.         lib    Exec,SendIO
  121.  
  122.         move.l    WaitMask(pc),d0
  123.         lib    Exec,Wait
  124.  
  125.         move.l    SerDevIO(pc),a1
  126.         lib    Exec,CheckIO
  127.         tst.l    d0
  128.         bne    ResetModem2
  129.         move.l    SerDevIO(pc),a1
  130.         lib    Exec,AbortIO
  131. ResetModem2:    move.l    SerDevIO(pc),a1
  132.         lib    Exec,WaitIO
  133.  
  134. CloseSer:
  135.         move.l    SerDevIO(pc),a1
  136.         lib    Exec,CloseDevice
  137.         move.w    #$00,SerOpen
  138.  
  139.         move.l    #IOEXTSER_SIZE,-(sp)
  140.         move.l    SerDevIO(pc),-(sp)
  141.         jsr    _DeleteExtIO
  142.         add.l    #8,sp
  143.         move.l    #$00,SerDevIO
  144.  
  145.         move.l    SRPort(pc),-(sp)
  146.         jsr    _DeletePort
  147.         add.l    #4,sp
  148.         move.l    #$00,SRPort
  149.         jmp    ShutDown8800
  150.  
  151. SetUpSer:    move.l    SerDevIO(pc),a1
  152.         move.w    #SDCMD_SETPARAMS,IO_COMMAND(a1)
  153.         move.b    SerFlags(pc),IO_SERFLAGS(a1)
  154.         move.l    SerBaud(pc),IO_BAUD(a1)
  155.         lib    Exec,SendIO
  156.  
  157.         move.l    WaitMask(pc),d0
  158.         lib    Exec,Wait
  159.         move.l    #$00,d1            ;returns wait stat in d1
  160.         cmp.l    #SIGBREAKF_CTRL_C,d0
  161.         bne    SetUpSerOut
  162.         move.l    SerDevIO(pc),a1
  163.         lib    Exec,AbortIO
  164.         move.l    SerDevIO(pc),a1
  165.         lib    Exec,WaitIO
  166.         move.l    #$01,d1
  167. SetUpSerOut:    rts
  168.  
  169. ShutDown:    tst.l    SerOpen
  170.         beq    ShutDown9000
  171.         move.l    SerDevIO(pc),a1
  172.         lib    Exec,CloseDevice
  173.         
  174. ShutDown9000:    move.l    SerDevIO(pc),d0
  175.         tst.l    d0
  176.         beq    ShutDown8900
  177.         move.l    #IOEXTSER_SIZE,-(sp)
  178.         move.l    d0,-(sp)
  179.         jsr    _DeleteExtIO
  180.         add.l    #8,sp
  181.  
  182. ShutDown8900:    move.l    SRPort(pc),d0
  183.         tst.l    d0
  184.         beq    ShutDown8800
  185.         move.l    d0,-(sp)
  186.         jsr    _DeletePort
  187.         add.l    #4,sp
  188.  
  189. ShutDown8800:    move.l    ConfigFile(pc),d1
  190.         beq    ShutDown8700
  191.         lib    Exec,Close
  192.  
  193. ShutDown8700:
  194. ShutDown1000:    closlib    Dos
  195.  
  196. ShutDownOut:    move.l    #RETURN_OK,d0
  197.         rts
  198.  
  199.         INCLUDE    "LWF:NBBS/DosError.i"
  200.  
  201. ;bits
  202.  
  203. WaitMask    dc.l    SIGBREAKF_CTRL_C
  204.  
  205. ;Structures
  206.  
  207. _DOSBase     dc.l    0
  208. _SysBase    dc.l    0
  209.  
  210.         libnames
  211. ;file stuff
  212.  
  213. _stdout        dc.l    0            ;ex. outfile
  214. ConfigAddress    dc.l    0
  215. ConfigFile:    dc.l    0            ;pointer from Exec,Open
  216.  
  217. ;device stuff
  218.  
  219. SerOpen        dc.w    0            ;Equals 1 if open
  220. SerDevIO    dc.l    0
  221.  
  222. ;port stuff
  223.  
  224. SRPortName    dc.b    "NBBS_SerialPort",0
  225.         ds.l    0
  226. SRPort        dc.l    0
  227.  
  228. ;config stuff - a straight copy of the .config file and vice versa
  229.  
  230.         INCLUDE    "LWF:NBBS/Config.i"
  231.  
  232. ;debug stuff
  233.  
  234. fstr        dc.b    "$%lx",10,0
  235.         ds.l    0
  236. TestCMD2:    dc.b    "ATZ",13,0
  237.         ds.l    0
  238.  
  239.         END
  240.