home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / checkprinter.lha / CheckPrinter.s < prev    next >
Encoding:
Text File  |  1994-01-03  |  1.8 KB  |  93 lines

  1. *    CheckForPrinter
  2. * written in 1991 by Stephan Fuhrmann
  3. * Contact : Stephan Fuhrmann / Erikstr.30 / 2380 Schleswig / Germany
  4. * DevPac-Source
  5.  
  6.     incdir    dh0:include/
  7.     include    exec/exec_lib.i
  8.     include    exec/io.i
  9.     include    exec/ports.i
  10.     include    devices/parallel.i
  11.     include    libraries/dos_lib.i
  12.     include    libraries/dos.i
  13.  
  14.     section    CheckPrinter,code
  15.     sub.l    a1,a1
  16.     CALLEXEC    FindTask
  17.     lea    _Reply(pc),a1
  18.     move.l    d0,MP_SIGTASK(a1)
  19.     lea    _ParIO(pc),a0
  20.     move.l    a1,MN_REPLYPORT(a0)
  21.     CALLEXEC    AddPort 
  22.  
  23.     lea    _ParName(pc),a0
  24.     lea    _ParIO(pc),a1
  25.     moveq    #0,d0
  26.     moveq    #0,d1
  27.     CALLEXEC    OpenDevice
  28.     tst.l    d0
  29.     bne.s    RMSG
  30.     lea    _ParIO(pc),a1
  31.     move.w    #PDCMD_QUERY,IO_COMMAND(a1)
  32.     CALLEXEC    DoIO
  33.         ;IO-Struktur mit Parallel-Port-STATUS füllen
  34.  
  35. CDEV:
  36.     lea    _ParIO(pc),a1
  37.     CALLEXEC    CloseDevice
  38. RMSG:
  39.     lea    _Reply(pc),a1
  40.     CALLEXEC    RemPort
  41.  
  42.     lea    _ParIO(pc),a1
  43.     move.b    IO_PARSTATUS(a1),d0
  44.  
  45. ; D0 enthält jetzt das Status-Byte des Parallel-Ports .
  46. ; Siehe devices/parallel.i für weitere Informationen :
  47. ; Bit 0 : 1-OffLine
  48. ;    : 0-OnLine
  49. ; Bit 1 : 1-OK
  50. ;    : 0-PAPER_OUT
  51. ; Bit 2 : 1-PRINTER_READY
  52. ;    : 0-PRINTER_BUSY
  53. ; Bit 3 : 1-Direction WRITE
  54. ;    : 0-Direction READ
  55.  
  56.     move.b    d0,d7        ;für später retten
  57.  
  58.     lea    _DosName(pc),a1
  59.     moveq    #0,d0
  60.     CALLEXEC    OpenLibrary
  61.     lea    _DOSBase(pc),a0
  62.     move.l    d0,(a0)
  63.     beq.s    Error
  64.     CALLDOS    Output
  65.     move.l    d0,d1
  66.     btst    #0,d7
  67.     beq.s    ONLINE
  68.     move.l    #_OfflineTXT,d2
  69.     move.l    #_OffLineLng,d3
  70. PrintIt:
  71.     CALLDOS    Write
  72. Error:    moveq    #0,d0
  73.     rts
  74. ONLINE:
  75.     move.l    #_OnlineTXT,d2
  76.     move.l    #_OnLineLng,d3
  77.     bra.s    PrintIt
  78.  
  79. ; Daten für die eigentliche Routine (PAR-Status)
  80.  
  81. _ParName:    PARALLELNAME
  82. _ParIO:        ds.l    20
  83. _Reply:        ds.l    8
  84.  
  85. ; Daten für Textausgabe
  86.  
  87. _DOSBase:    ds.l    1
  88. _OnlineTXT:    dc.b    "Printer is ONLINE",$a
  89. _OnLineLng    =*-_OnlineTXT
  90. _OfflineTXT    dc.b    "Printer is OFFLINE/Not connected",$a
  91. _OffLineLng    =*-_OfflineTXT
  92. _DosName:    DOSNAME
  93.