home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
262.lha
/
IffLibrary_v1.3
/
printer.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-04
|
2KB
|
81 lines
#include <graphics/view.h>
#include <graphics/rastport.h>
#include <exec/memory.h>
#include <exec/io.h>
#include <devices/printer.h>
extern long DoIO(), OpenDevice();
extern void *AllocMem(), FreeMem();
typedef union
{
struct IOStdReq ios;
struct IODRPReq iodrp;
struct IOPrtCmdReq iopc;
} ReqBlock;
#define REGS register
#define MEMFLAGS ((long)(MEMF_PUBLIC|MEMF_CLEAR))
#define ALLOC_SIZE ((long)sizeof(ReqBlock))
/* pointers to IO request blocks */
static ReqBlock *write_prt;
/* convience */
typedef struct MsgPort Port;
/* message port, must be created before opening the device */
static Port *ThisPort;
long open_prtdev()
{
extern void *AllocMem(), FreeMem(), DeletePort();
extern Port *CreatePort();
extern long OpenDevice();
if( !(ThisPort = CreatePort("pport",0L)) )
return(1L);
/* Allocate memory for IO request blocks */
if( !(write_prt = AllocMem(ALLOC_SIZE,MEMFLAGS)) )
return(2L);
if( OpenDevice("printer.device",0L,write_prt,0L) )
{
FreeMem(write_prt,ALLOC_SIZE);
return(3L);
}
write_prt->ios.io_Message.mn_ReplyPort = ThisPort;
return(0L);
}
void close_prtdev()
{
CloseDevice(write_prt);
FreeMem(write_prt,ALLOC_SIZE);
write_prt = 0L;
DeletePort(ThisPort);
}
long DumpRPort(rp,vp,sx,sy,sw,sh,dc,dr,s)
REGS struct RastPort *rp;
REGS struct ViewPort *vp;
REGS UWORD sx,sy,sw,sh;
REGS long dc, dr;
REGS UWORD s;
{
write_prt->iodrp.io_Command = PRD_DUMPRPORT;
write_prt->iodrp.io_RastPort = rp;
write_prt->iodrp.io_ColorMap = vp->ColorMap;
write_prt->iodrp.io_Modes = vp->Modes;
write_prt->iodrp.io_SrcX = sx;
write_prt->iodrp.io_SrcY = sy;
write_prt->iodrp.io_SrcWidth = sw;
write_prt->iodrp.io_SrcHeight = sh;
write_prt->iodrp.io_DestCols = dc;
write_prt->iodrp.io_DestRows = dr;
write_prt->iodrp.io_Special = s;
return(DoIO(write_prt));
}