home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d09xx
/
d0931.lha
/
Modules
/
PrinterDevice
/
PrinterDevice.mod
/
PrinterDevice.mod
Wrap
Text File
|
1993-12-20
|
3KB
|
164 lines
IMPLEMENTATION MODULE PrinterDevice;
(* Die Anleitungen und ErlΣuterungen befinden sich im Definitionsfile *)
(* Compiler M2Amiga V4.097d ⌐ 1991 by Andre Wiethoff *)
(*$ StackChk:=FALSE *)
(*$ RangeChk:=FALSE *)
(*$ OverflowChk:=FALSE *)
(*$ NilChk:=FALSE *)
(*$ CaseChk:=FALSE *)
(*$ ReturnChk:=FALSE *)
(*$ Volatile:=FALSE *)
(*$ LargeVars:=FALSE *)
FROM SYSTEM IMPORT LONGSET,ADR;
FROM GraphicsD IMPORT RastPortPtr,ViewPortPtr,ColorMapPtr,ViewModeSet;
FROM ExecD IMPORT IOStdReqPtr,MsgPort,TaskPtr,write;
FROM ExecL IMPORT OpenDevice,CloseDevice,FindTask,AddPort,RemPort,DoIO;
FROM Printer IMPORT IOPrtCmdReqPtr,IODRPReq,SpecialSet,rawWrite,
prtCommand,dumpRPort,Error,nel,query;
FROM String IMPORT Length;
VAR
task : TaskPtr;
msg : MsgPort;
ioPrtCmd : IOPrtCmdReqPtr;
ioNorm : IOStdReqPtr;
all : IODRPReq;
opened : BOOLEAN;
PROCEDURE OpenPrinter():BOOLEAN;
BEGIN
IF NOT opened THEN
opened:=TRUE;
all.device:=NIL;
task:=FindTask(0);
msg.sigTask:=task;
AddPort(ADR(msg));
all.message.replyPort:=ADR(msg);
OpenDevice(ADR("printer.device"),0,ADR(all),LONGSET{});
IF all.device=NIL THEN
opened:=FALSE;
RemPort(ADR(msg));
ELSE
ioPrtCmd:=ADR(all);
ioNorm:=ADR(all);
END;
END;
RETURN opened;
END OpenPrinter;
PROCEDURE SendCommand(befehl : CARDINAL;
p0,p1,p2,p3 : SHORTCARD) : Error;
BEGIN
IF opened THEN
ioPrtCmd^.command:=prtCommand;
ioPrtCmd^.prtCommand:=befehl; ioPrtCmd^.parm0:=p0; ioPrtCmd^.parm1:=p1;
ioPrtCmd^.parm2:=p2; ioPrtCmd^.parm3:=p3;
DoIO(ioPrtCmd);
END;
RETURN all.error;
END SendCommand;
PROCEDURE PrintText(text : ARRAY OF CHAR) : Error;
BEGIN
IF opened THEN
ioNorm^.command:=write;
ioNorm^.data:=ADR(text); ioNorm^.length:=Length(text); ioNorm^.actual:=0;
ioNorm^.offset:=0;
DoIO(ioNorm);
END;
RETURN all.error;
END PrintText;
PROCEDURE PrintRawText(text : ARRAY OF CHAR) : Error;
BEGIN
IF opened THEN
ioNorm^.command:=rawWrite;
ioNorm^.data:=ADR(text); ioNorm^.length:=Length(text); ioNorm^.actual:=0;
ioNorm^.offset:=0;
DoIO(ioNorm);
END;
RETURN all.error;
END PrintRawText;
PROCEDURE PrintLn() : Error;
BEGIN
RETURN SendCommand(nel,0,0,0,0);
END PrintLn;
PROCEDURE PrintDump(rp : RastPortPtr;
vp : ViewPortPtr;
x,y : CARDINAL;
w,h : CARDINAL;
VAR cols,rows : LONGINT;
spezial : SpecialSet) : Error;
BEGIN
IF opened THEN
all.rastPort:=rp; all.colorMap:=vp^.colorMap; all.modes:=vp^.modes;
all.command:=dumpRPort; all.srcX:=x; all.srcY:=y; all.srcWidth:=w;
all.modesHi:=0; all.srcHeight:=h; all.destCols:=cols; all.destRows:=rows;
all.special:=spezial;
DoIO(ADR(all));
cols:=all.destCols; rows:=all.destRows;
END;
RETURN all.error;
END PrintDump;
PROCEDURE GetPrinterStatus(VAR status : Status) : Error;
VAR c : SerStatusSet;
BEGIN
IF opened THEN
ioNorm^.command:=query;
ioNorm^.data:=ADR(c); ioNorm^.length:=2; ioNorm^.offset:=0;
DoIO(ioNorm);
status.serStatus:=c;
IF ioNorm^.actual=1 THEN
status.port:=parallel;
ELSE
status.port:=serial;
END;
END;
RETURN all.error;
END GetPrinterStatus;
PROCEDURE ClosePrinter;
BEGIN
IF opened THEN
RemPort(ADR(msg));
CloseDevice(ADR(all));
opened:=FALSE;
END;
END ClosePrinter;
BEGIN
opened:=FALSE;
CLOSE
ClosePrinter;
END PrinterDevice.