|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 3959 (0xf77) Types: TextFile Names: »gdevegab.c«
└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89 └─⟦ff23ba0e6⟧ »./ghostscript-1.3.tar.Z« └─⟦a24a58cd3⟧ └─⟦this⟧ »gdevegab.c«
/* Copyright (C) 1989 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 copies. */ /* gdevegab(ios).c */ /* EGA driver for GhostScript using BIOS dot-writing routine */ #include "gdevega.h" /* Registers and macros for dot writing */ private registers dot_in_regs, dot_out_regs; #define dot_x dot_in_regs.x.cx #define dot_y dot_in_regs.x.dx #define dot_color dot_in_regs.h.al /* Define the dot writing routines */ #define dot_write() int86(0x10, &dot_in_regs, &dot_out_regs) /* Initialize the EGA for graphics mode */ int ega_open() { if ( ega_save_mode < 0 ) ega_save_mode = ega_get_mode(); ega_set_mode(0x10); dot_in_regs.h.ah = 0xc; /* function */ dot_in_regs.h.bh = 0; /* page */ return 0; } /* Write a dot using the EGA color codes. */ int ega_write_dot(gx_device *dev, int x, int y, gx_color_index color) { validate_dot(); dot_color = color; dot_x = x; dot_y = y; dot_write(); return 0; } /* Copy a monochrome bitmap. The colors are given explicitly. */ /* Color = gx_no_color_index means transparent (no effect on the image). */ int ega_copy_mono(gx_device *dev, byte *base, int sourcex, int raster, int x, int y, int w, int h, gx_color_index zero, gx_color_index one) { byte *line = base + (sourcex >> 3); int ibit; validate_rect(); ibit = 0x80 >> (sourcex & 7); dot_y = y; while ( --h >= 0 ) { byte *bptr = line; int count = w; int bit = ibit; dot_x = x; while ( --count >= 0 ) { gx_color_index color = (*bptr & bit ? one : zero); if ( color != gx_no_color_index ) { dot_color = color; dot_write(); } dot_x++; if ( !(bit >>= 1) ) bit = 0x80, bptr++; } dot_y++; line += raster; } return 0; } /* Copy a color pixelmap. This is just like a bitmap, */ /* except that each pixel takes 4 bits instead of 1. */ int ega_copy_color(gx_device *dev, byte *base, int sourcex, int raster, int x, int y, int w, int h) { byte *line = base + (sourcex >> 1); int ibit; validate_rect(); ibit = (sourcex & 1 ? 0 : -1); dot_y = y; while ( --h >= 0 ) { byte *bptr = line; int bit = ibit; int count = w; dot_x = x; while ( --count >= 0 ) { dot_color = ((bit = ~bit) ? *bptr++ & 0xf : *bptr >> 4); dot_write(); dot_x++; } line += raster; dot_y++; } return 0; } /* Fill a rectangle. */ int ega_fill_rectangle(gx_device *dev, int x, int y, int w, int h, gx_color_index color) { validate_rect(); dot_y = y; dot_color = color; while ( --h >= 0 ) { dot_x = x; { int c = w; while ( c-- ) (dot_write()), dot_x++; } dot_y++; } return 0; } /* Tile a rectangle. */ int ega_tile_rectangle(gx_device *dev, gx_bitmap *tile, int x, int y, int w, int h, gx_color_index zero, gx_color_index one) { while ( h > 0 ) { int yr = y % tile->height; byte *data = tile->data + yr * tile->raster; int ny = tile->height - yr; int dx = x, dw = w; if ( ny > h ) ny = h; while ( dw > 0 ) { int xr = dx % tile->width; int nx = tile->width - xr; if ( nx > dw ) nx = dw; ega_copy_mono(dev, data, xr, tile->raster, dx, y, nx, ny, zero, one); dx += nx, dw -= nx; } y += ny, h -= ny; } return 0; }