home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 10 / Fresh_Fish_10_2352.bin / new / comm / net / pronet / source / utilities / pronet-talk.s < prev   
Encoding:
Text File  |  1995-06-22  |  7.5 KB  |  385 lines

  1. ;: Talk.s
  2. ;:
  3. ;: 03-06-1995    UNIT support. v34.1
  4.  
  5. CSI        equ    27+128
  6. USEPRONET    equ    1    ;zum Testen..
  7.  
  8.         include    "A:OSmacros.i"
  9.         include    "exec/exec.i"
  10.         include    "intuition/intuition.i"
  11.         include    "A:ProNET/include/devices/pronet.i"
  12.         include    "exec_lib.i"
  13.         include    "intuition_lib.i"
  14.  
  15. j        cmp.w    #2,d0        * UNIT as Argument?
  16.         bls.s    .cont
  17.         bsr    dec2long
  18.         move.l    d1,unit
  19.  
  20. .cont        lea    wintitle2mod(pc),a0
  21.         move.l    unit(pc),d0
  22.         bsr    long2dec
  23.         clr.b    (a0)+
  24.  
  25.         move.l    4.w,a6
  26.         lea    intname(pc),a1
  27.         LIBCALL    OldOpenLibrary
  28.         move.l    d0,intbase
  29.  
  30.         bsr    initconsole
  31.         tst.w    d0
  32.         bne    noconsole
  33.  
  34.         IFNE    USEPRONET
  35.         bsr    startpronet
  36.         tst.w    d0
  37.         bne    nopronet
  38.         ENDC    
  39.         move.l    intbase(pc),a6
  40.         move.l    window(pc),a0
  41.         lea    wintitle2(pc),a1
  42.         move.l    a1,a2
  43.         LIBCALL    SetWindowTitles
  44.  
  45.         bsr    Wait4Message
  46.  
  47.         IFNE    USEPRONET
  48.         bsr    stoppronet
  49.         ENDC
  50.  
  51. nopronet    bsr    closeconsole
  52.  
  53. noconsole    move.l    intbase(pc),a1
  54.         move.l    4.w,a6
  55.         LIBCALL    CloseLibrary
  56.         moveq    #0,d0
  57.         rts
  58.  
  59.         dc.b    "$VER: pronet-talk 34.1 (03-06-95)",13,10,0
  60.         even
  61.  
  62. initconsole    move.l    intbase(pc),a6        ;Window öffnen
  63.         cmp.w    #36,LIB_VERSION(a6)
  64.         bcs.s    .nokick2
  65.         lea    wbname(pc),a0
  66.         LIBCALL    LockPubScreen
  67.         move.l    d0,wbscreen
  68.         beq    icnoscr
  69.         move.l    d0,a0
  70.         moveq    #0,d1
  71.         move.b    sc_WBorTop(a0),d1
  72.         add.b    sc_WBorBottom(a0),d1
  73.         add.w    sc_RastPort+rp_TxHeight(a0),d1
  74.         add.w    #2+100,d1
  75.         move.w    d1,newwindow+6
  76. .nokick2    lea    newwindow(pc),a0
  77.         LIBCALL    OpenWindow
  78.         move.l    d0,window
  79.         beq    icnowin
  80.  
  81.         moveq    #48,d0            ;Console-Device öffnen
  82.         bsr    GetIORequest
  83.         move.l    d0,conreadio
  84.         beq    nodevblock1
  85.         moveq    #48,d0
  86.         bsr    GetIORequest
  87.         move.l    d0,conwriteio
  88.         beq    nodevblock2
  89.         move.l    conreadio(pc),a1
  90.         move.l    window(pc),IO_DATA(a1)
  91.         lea    consolename(pc),a0
  92.         moveq    #0,d0
  93.         moveq    #0,d1
  94.         move.l    4.w,a6
  95.         LIBCALL    OpenDevice
  96.         tst.l    d0
  97.         bne    nocondev
  98.         move.l    conreadio(pc),a0
  99.         move.l    conwriteio(pc),a1
  100.         move.l    20(a0),20(a1)
  101.         move.l    24(a0),24(a1)
  102.  
  103.         move.l    window(pc),a0
  104.         move.l    wd_UserPort(a0),a0
  105.         move.b    MP_SIGBIT(a0),Signal.window
  106.         move.l    conreadio(pc),a0
  107.         move.l    MN_REPLYPORT(a0),a0
  108.         move.b    MP_SIGBIT(a0),Signal.console
  109.  
  110.         bsr    sendconreadcmd
  111.         moveq    #0,d0
  112.         rts
  113.  
  114. sendconreadcmd    move.l    4.w,a6
  115.         moveq    #0,d0
  116.         moveq    #0,d1
  117.         move.l    conreadio(pc),a0
  118.         move.l    MN_REPLYPORT(a0),a0
  119.         move.b    MP_SIGBIT(a0),d2
  120.         bset    d2,d1
  121.         LIBCALL    SetSignal
  122.         move.l    conreadio(pc),a1
  123.         clr.b    IO_FLAGS(a1)
  124.         move.l    #256,IO_LENGTH(a1)
  125.         move.l    #conbuf,IO_DATA(a1)
  126.         move.w    #CMD_READ,IO_COMMAND(a1)
  127.         LIBCALL    SendIO
  128.         rts
  129.  
  130. closeconsole    move.l    4.w,a6
  131.         move.l    conreadio(pc),a1
  132.         LIBCALL    CloseDevice
  133. nocondev    move.l    conwriteio(pc),a0
  134.         bsr    FreeIORequest
  135. nodevblock2    move.l    conreadio(pc),a0
  136.         bsr    FreeIORequest
  137. nodevblock1    move.l    intbase(pc),a6
  138.         move.l    window(pc),a0
  139.         LIBCALL    CloseWindow
  140. icnowin        cmp.w    #36,LIB_VERSION(a6)
  141.         bcs.s    icnoscr
  142.         sub.l    a0,a0
  143.         move.l    wbscreen(pc),a1
  144.         LIBCALL    UnlockPubScreen
  145. icnoscr        moveq    #-1,d0
  146.         rts
  147.  
  148. startpronet    moveq    #pnr_Size,d0
  149.         bsr    GetIORequest
  150.         move.l    d0,pronetio
  151.         beq    spnoioreq
  152.         bsr    CreatePort
  153.         move.l    d0,msgport
  154.         beq    spnomsgport
  155.         lea    pronetname,a0
  156.         move.l    unit(pc),d0
  157.         moveq    #0,d1
  158.         move.l    pronetio(pc),a1
  159.         move.w    #PNP_NAME,pnr_NetSourcePort(a1)
  160.         move.l    msgport(pc),pnr_MsgPort(a1)
  161.         move.l    #talkstr,pnr_Data1(a1)
  162.         move.l    4.w,a6
  163.         LIBCALL    OpenDevice
  164.         tst.l    d0
  165.         bne    spnodev
  166.  
  167.         move.l    pronetio(pc),a1
  168.         move.w    pnr_NetSourcePort(a1),pnr_NetDestPort(a1)
  169.         clr.l    pnr_Data2(a1)
  170.         clr.l    pnr_Length2(a1)
  171.  
  172.         move.l    msgport(pc),a0
  173.         move.b    MP_SIGBIT(a0),Signal.pronet
  174.         moveq    #0,d0
  175.         rts
  176.  
  177. stoppronet    move.l    4.w,a6
  178.         move.l    pronetio(pc),a1
  179.         LIBCALL    CloseDevice
  180. spnodev        move.l    msgport(pc),a0
  181.         bsr    DeletePort
  182. spnomsgport    move.l    pronetio(pc),a0
  183.         bsr    FreeIORequest
  184. spnoioreq    moveq    #-1,d0
  185.         rts
  186.  
  187. dec2long    ; konvertiert Dezimalstring ab (a0) zu Longword in D1 !!
  188.         moveq    #0,d1
  189. .loop        moveq    #0,d0
  190.         move.b    (a0)+,d0
  191.         sub.b    #"0",d0
  192.         cmp.b    #9,d0
  193.         bhi.s    .oki
  194.         move.l    d1,d2
  195.         lsl.l    #3,d1
  196.         add.l    d2,d1
  197.         add.l    d2,d1
  198.         add.l    d0,d1
  199.         bra.s    .loop
  200. .oki        rts
  201.  
  202. long2dec    ;Converts Long in d0 to Dec-String in (a0)+
  203.         tst.l    d0
  204.         bne.s    .0
  205.         move.b    #"0",(a0)+
  206.         rts
  207. .0        lea    long2asciitab(pc),a1
  208.         moveq    #9,d1
  209.         moveq    #0,d6
  210. .1        move.l    (a1)+,d2
  211.         move.l    d0,d3
  212.         moveq    #-1,d4
  213. .2        move.l    d3,d5
  214.         sub.l    d2,d3
  215.         cmp.l    d5,d3
  216.         dbhi    d4,.2
  217.         add.l    d2,d3
  218.         move.l    d3,d0
  219.         not.w    d4
  220.         bne.s    .3
  221.         tst.w    d6
  222.         beq.s    .4
  223. .3        st    d6
  224.         add.b    #"0",d4
  225.         move.b    d4,(a0)+
  226. .4        dbra    d1,.1
  227.         rts
  228. long2asciitab    dc.l    1000000000,100000000,10000000,1000000,100000
  229.         dc.l    10000,1000,100,10,1
  230.  
  231. w4mquitflag    dc.w    0
  232. Wait4Message    tst.w    w4mquitflag
  233.         bne    .quit
  234.         clr.w    w4mquitflag
  235.  
  236.         lea    Signals(pc),a3    * auf die Messages
  237.         moveq    #0,d0        * an allen möglichen
  238.         moveq    #numports-1,d1    * Ports warten
  239. .loop1        move.b    (a3),d2
  240.         bmi.s    .0
  241.         bset    d2,d0
  242. .0        addq.w    #6,a3
  243.         dbra    d1,.loop1
  244.         move.l    4.w,a6
  245.         LIBCALL    Wait
  246.                     * entsprechende Routinen
  247.         moveq    #31,d7        * aufrufen
  248. .00        rol.l    d0
  249.         bcc.s    .notthisbit
  250.         lea    Signals(pc),a3
  251.         moveq    #numports-1,d4
  252. .01        cmp.b    (a3),d7
  253.         bne.s    .notthisport
  254.         movem.l    d0/d4/d7/a3,-(sp)
  255.         move.l    2(a3),a3
  256.         jsr    (a3)
  257.         movem.l    (sp)+,d0/d4/d7/a3
  258. .notthisport    addq.w    #6,a3
  259.         dbra    d4,.01
  260. .notthisbit    dbra    d7,.00    
  261.  
  262.         bra    Wait4Message
  263. .quit        rts
  264. Signals:
  265. Signal.window    dc.b    -1,0            ;Signalbit
  266.         dc.l    EvalWindowMessage    ;Entsprechende Routine
  267. Signal.pronet    dc.b    -1,0
  268.         dc.l    ReadFromProNET
  269. Signal.console    dc.b    -1,0
  270.         dc.l    ReadFromConsole
  271. numports    equ    3
  272.  
  273. EvalWindowMessage    ; IDCMP-Flags des Window wurden aufgerufen
  274.         move.l    4.w,a6
  275.         move.l    window(pc),a0
  276.         move.l    wd_UserPort(a0),a0
  277.         LIBCALL    GetMsg
  278.         move.l    d0,a1
  279.         tst.l    d0
  280.         beq.s    .ende
  281.         move.l    $14(a1),d4    ;Class
  282.         move.w    $18(a1),d5    ;Code
  283.         move.w    $1a(a1),d6    ;Qualifier
  284.         move.l    $1c(a1),a4    ;IAddress
  285.         cmp.l    #IDCMP_CLOSEWINDOW,d4
  286.         bne.s    .0
  287.         st    w4mquitflag
  288. .0        LIBCALL    ReplyMsg
  289.         bra.s    EvalWindowMessage
  290. .ende        rts
  291.  
  292. ReadFromProNET        ; Message vom anderen Rechner
  293.         move.l    4.w,a6
  294.         move.l    msgport(pc),a0
  295.         LIBCALL    GetMsg
  296.         tst.l    d0
  297.         beq.s    .ende
  298.         move.l    d0,a3
  299.         move.l    conwriteio(pc),a1
  300.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  301.         move.l    a3,d0
  302.         add.l    #MN_SIZE+6,d0
  303.         move.l    d0,IO_DATA(a1)
  304.         move.l    MN_SIZE+2(a3),d0
  305.         move.l    d0,IO_LENGTH(a1)
  306.         clr.b    IO_FLAGS(a1)
  307.         LIBCALL    DoIO        ;und auf der Console ausgeben
  308.         move.l    a3,a1
  309.         LIBCALL    ReplyMsg
  310.         bra.s    ReadFromProNET
  311. .ende        rts
  312.  
  313.  
  314. ReadFromConsole        ; Es wurde auf der Console etwas getippt
  315.         move.l    conreadio(pc),a0
  316.         move.l    IO_ACTUAL(a0),d6    ;Anzahl der Bytes
  317.  
  318.         bsr    processconbuf
  319.  
  320.         move.l    conwriteio(pc),a1
  321.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  322.         move.l    #conbuf,IO_DATA(a1)
  323.         move.l    d6,IO_LENGTH(a1)
  324.         clr.b    IO_FLAGS(a1)
  325.         LIBCALL    DoIO            ;auf der Console ausgeben
  326.  
  327.         IFNE    USEPRONET
  328.         move.l    pronetio(pc),a1
  329.         move.w    #CMD_WRITE,IO_COMMAND(a1)
  330.         lea    conbuf-4,a0
  331.         move.l    a0,pnr_Data1(a1)
  332.         move.l    d6,(a0)
  333.         addq.l    #1,d6
  334.         bclr    #0,d6    ;aufrunden
  335.         addq.l    #4,d6    ;Längenwort !
  336.         move.l    d6,pnr_Length1(a1)
  337.         LIBCALL DoIO            ;und auf dem anderen Amiga
  338.         ENDC
  339.  
  340.         bsr    sendconreadcmd        ;neue Sachen lesen
  341.         rts
  342.  
  343. processconbuf    ; Ein paar Tasten umdefinieren (Cursor, Del etc.)
  344.         ; alte Länge der Daten in D6.l
  345.         ; muß neue Länge in D6.l zurückgeben
  346.         rts
  347.  
  348. ; - Data ------------------------------------------------------------------
  349.  
  350. pronetname    dc.b    "pronet.device",0
  351. consolename    dc.b    "console.device",0
  352. intname        dc.b    "intuition.library",0
  353. wbname        dc.b    "Workbench",0
  354.         even
  355.  
  356. newwindow    dc.w    50,50
  357.         dc.w    400,114
  358.         dc.b    -1,-1
  359.         dc.l    IDCMP_CLOSEWINDOW,$1100e,0,0,wintitle,0,0
  360.         dc.w    -1,-1,-1,-1,$1
  361.  
  362. wintitle    dc.b    "ProNET-Talk! - Starting ProNET..",0
  363. wintitle2    dc.b    "ProNET-Talk! Unit "
  364. wintitle2mod    dc.b    "XXXXXXXX",0
  365.  
  366. talkstr        dc.b    "pronet-talk:",0
  367.         even
  368.  
  369. unit        dc.l    0
  370.  
  371. pronetio    dc.l    0
  372. msgport        dc.l    0
  373. intbase        dc.l    0
  374. window        dc.l    0
  375. wbscreen    dc.l    0
  376. conreadio    dc.l    0
  377. conwriteio    dc.l    0
  378.  
  379.         include    "A:ProNET/source/devio.s"
  380.  
  381.         section    b,bss
  382.  
  383.         ds.b    4
  384. conbuf        ds.b    256
  385.