/* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises. All rights reserved.
Distributed by Free Software Foundation, Inc.
This file is part of Ghostscript.
Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer
to the Ghostscript General Public License for full details.
Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License. A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
/* gdevpe.c Private Eye display driver for Ghostscript
Hacked by Fran Taylor, Reflection Technology Inc. */
char *getenv(char *name
);
typedef struct gx_device_pe_s
{
#define pedev ((gx_device_pe *)dev)
#define DEFAULT_ADDRESS ((byte *) 0xb8000000)
#define DEFAULT_REGISTERS 0x3d0
dev_proc_open_device(pe_open
);
dev_proc_close_device(pe_close
);
dev_proc_fill_rectangle(pe_fill_rectangle
);
dev_proc_copy_mono(pe_copy_mono
);
static gx_device_procs pe_procs
=
gx_default_get_initial_matrix
,
gx_default_map_rgb_color
,
gx_default_map_color_rgb
,
gx_default_tile_rectangle
,
gx_device_pe gs_pe_device
=
DEFAULT_ADDRESS
, DEFAULT_REGISTERS
static regval peinit
[] = {{0x04, 0x1e}, {0x05, 0x00},
{0x04, 0x0c}, {0x05, 0x21},
{0x04, 0x0d}, {0x05, 0x98},
{0x08, 0x00}, {0x08, 0x1e},
{0x04, 0x1e}, {0x05, 0x01}};
static regval pedone
[] = {{0x04, 0x1e}, {0x05, 0x10},
{0x04, 0x0a}, {0x05, 0x00},
{0x04, 0x0b}, {0x05, 0x07},
{0x04, 0x0c}, {0x05, 0x00},
{0x04, 0x0d}, {0x05, 0x00},
{0x04, 0x0e}, {0x05, 0x00},
{0x04, 0x0f}, {0x05, 0x00},
{0x08, 0x00}, {0x08, 0x29}};
int pe_open(gx_device
*dev
)
if ((str
= getenv("PEFBADDR")) != 0)
if (!sscanf(str
, "%lx", &(pedev
->fbaddr
)))
eprintf("Private Eye: PEFBADDR environment string format error\n");
if ((str
= getenv("PEREGS")) != 0)
if (!sscanf(str
, "%x", &(pedev
->regs
)))
eprintf("Private Eye: PEREGS environment string format error\n");
outportb(pedev
->regs
+ peinit
[i
].reg
, peinit
[i
].val
);
int pe_close(gx_device
*dev
)
outportb(pedev
->regs
+ pedone
[i
].reg
, pedone
[i
].val
);
/* clear the frame buffer */
memset(pedev
->fbaddr
, 0, 4000);
int pe_fill_rectangle(gx_device
*dev
, int x1
, int y1
, int w
, int h
,
if ((w
<= 0) || (h
<= 0) || (x1
> XSIZE
) || (y1
> YSIZE
))
if ((x2
< 0) || (y2
< 0))
if (x2
> XSIZE
-1) x2
= XSIZE
-1;
if (y2
> YSIZE
-1) y2
= YSIZE
-1;
xlen
= (x2
>> 3) - (x1
>> 3) - 1;
red
= 0xff << (7 - (x2
& 7));
ptr
= pedev
->fbaddr
+ (y1
* BPL
) + (x1
>> 3);
/* special for rectangles that fit in a byte */
for(; h
>= 0; h
--, ptr
+= BPL
)
for(; h
>= 0; h
--, ptr
+= BPL
)
while ( x
-- ) *p
++ = 0xff;
/* here to clear pixels */
/* special for rectangles that fit in a byte */
for(; h
>= 0; h
--, ptr
+= BPL
)
for(; h
>= 0; h
--, ptr
+= BPL
)
while ( x
-- ) *p
++ = 0x00;
int pe_copy_mono(gx_device
*dev
,
byte
*base
, int sourcex
, int raster
, gx_bitmap_id id
,
int x
, int y
, int w
, int h
,
gx_color_index zero
, gx_color_index one
)
int invert
, zmask
, omask
;
if ( ione
== izero
) /* vacuous case */
return pe_fill_rectangle(dev
, x
, y
, w
, h
, zero
);
if ((x
> XSIZE
) || (y
> YSIZE
) || ((x
+ w
) < 0) || ((y
+ h
) < 0))
dest
= pedev
->fbaddr
+ (y
* BPL
) + offset
;
line
= base
+ (sourcex
>> 3);
sleft
= 8 - (sourcex
& 7);
mask
= 0xff >> (8 - dleft
);
rmask
= 0xff00 >> ((w
- dleft
) & 7);
/* Macros for writing partial bytes. */
/* bits has already been inverted by xor'ing with invert. */
#define write_byte_masked(ptr, bits, mask)\
*ptr = ((bits | ~mask | zmask) & *ptr | (bits & mask & omask))
#define write_byte(ptr, bits)\
*ptr = ((bits | zmask) & *ptr | (bits & omask))
if ( izero != (int)gx_no_color_index ) zero ^= 1;
if ( ione != (int)gx_no_color_index ) one ^= 1;
invert
= (izero
== 1 || ione
== 0 ? -1 : 0);
zmask
= (izero
== 0 || ione
== 0 ? 0 : -1);
omask
= (izero
== 1 || ione
== 1 ? -1 : 0);
if (sleft
== dleft
) /* optimize the aligned case */
register byte
*bptr
= line
;
register byte
*optr
= dest
;
register int bits
= *bptr
^ invert
; /* first partial byte */
write_byte_masked(optr
, bits
, mask
);
while ((count
-= 8) >= 0)
write_byte_masked(optr
, bits
, rmask
);
int skew
= (sleft
- dleft
) & 7;
/* Do the first partial byte */
else /* ( sleft < dleft ) */
write_byte_masked(optr
, bits
, mask
);
write_byte_masked(optr
, bits
, rmask
);