|vga_accel(ACCEL_FILLBOX, int x, int y, int w, int h)|
|Simple solid fill of a box at pixels x, y with width w and height h in the current foreground color|
|vga_accel(ACCEL_SCREENCOPY, int x1, int y1, int x2, int y2, int w, int h)|
|Simple screen-to-screen blit. It copies a box of width w and height h pixels from position x1, y1 to position x2, y2. You may assume that the copy is non corrupting in case of overlapping source and destination areas.|
|vga_accel(ACCEL_SCREENCOPYMONO, int x1, int y1, int x2, int y2, int w, int h)|
Monochrome screen-to-screen blit. It copies a box of width
w and height h pixels from position
x1, y1 to position
x2, y2. |
However, each pixel will all bits set to 0 is drawn in the background color, each pixel with all bits set to 1 is drawn in the foreground color. To allow many different architectures supporting this routine, behaviour is undefined for other values. Bitmap transparency might be supported as well.
You should not expect ACCEL_SCREENCOPYBITMAP handling overlapping screen areas gracefully.
|vga_accel(ACCEL_PUTIMAGE, int x, int y, int w, int h, void *p)|
|Straight image transfer. It fills the given box with the data in memory area p. The memory buffer must contain the pixels in the same representation as used in the vga memory, starting at the top left corner, from left to right, and then, line by line, from up to down, without any gaps and interline spaces.|
|vga_accel(ACCEL_DRAWLINE, int x1, int y1, int x2, int y2))|
|General line draw. Draws a line from x1, y1 to position x2, y2 in the foreground color. You should not expect the reverse line from x2, y2 to position x1, y1 to use the exact same pixels on the screen. Several, esp. hardware, algorithms tend to yield to surprising results.|
|vga_accel(ACCEL_SETFGCOLOR, int color)|
Sets foreground color. It is used by most other draw commands.
|vga_accel(ACCEL_SETBGCOLOR, int color)|
Set background color. It is used by draw commands which might also
|vga_accel(ACCEL_SETTRANSPARENCY, int mode, ...)|
Set transparency mode, see the table below for an explanation parameters.
|vga_accel(ACCEL_SETRASTEROP, int mode)|
Set raster-operation, see the table below for an explanation of parameters.
|vga_accel(ACCEL_PUTBITMAP, int x, int y, int w, int h, void *p)|
Color-expand bitmap. This works similar to
ACCEL_PUTIMAGE but the bitmap
*p is a one bit bitmap.
Each pixel related to a set bit in
*p is drawn in the foreground color, the other pixels are drawn in the background color.
Each byte at *p contains 8 pixels. The lowest order bit of each byte is leftmost on the screen (contrary to the VGA tradition), irrespective of the bitmap bit order flag. Each scanline is aligned to a multiple of 32-bits.
If the transparency mode is enabled (irrespective of the transparency color), then bits that are zero in the bitmap are not written (the background color is not used).
|vga_accel(ACCEL_SCREENCOPYBITMAP, int x1, int y1, int x2, int y2, int w, int h)|
Color-expand from screen. This works similar to
ACCEL_PUTBITMAP but the bitmap
lies at position
x1, y1 and the destination box at
x2, y2. |
Alas, the sizes of the pixels in both bitmap are different. The bitmap *p must have the format corresponding to ACCEL_PUTBITMAP but will start at the screen memory location where the pixel (x1, y1) would be (probably in off screen memory).
In modes where pixel will not start at byte boundaries (typically those with less then 256 colors), the pixel (x1, y1) must start at a byte boundary (for example in a 16 color mode (4bpp rather than 8bpp for 256 colors) this means that x1 should be an even number).
The easiest way to achieve this is probably to choose x1 == 0 in these situations.
You should not expect ACCEL_SCREENCOPYBITMAP handling overlapping screen areas gracefully.
|vga_accel(ACCEL_DRAWHLINELIST, int y, int n, int *x1, int *x2)|
|Draw horizontal spans. Each of the *x1 and *x2 arrays contains n x-coordinate pairs. Starting with a horizontal line from *x1,y to *x2,y consecutive horizontal lines (with increasing y values) are drawn using the start and end points in *x1 and *x2. This is usually a very quick operation and useful to draw arbitrary polygons (when the accelerator cannot do an arbitrary polygon fill itself).|
|vga_accel(ACCEL_POLYLINE, int flag, int n, unsigned short *coords)|
draws a contiguous line through the
n points listed in
n pairs of shorts, the first is the x coordinate, the second is the y coordinate.
Normally flag should have the value ACCEL_START | ACCEL_END. However, if the evaluation of the points is costly, you can mix calculations and drawings. Your first call to vga_accel(ACCEL_POLYLINE, ...) must have ACCEL_START set. This will initialize the accelerator. If you do not specify ACCEL_END, you can (actually you have to) follow your call with another vga_accel(ACCEL_POLYLINE, ...) call which will give additional points to connect.
It is important that no other operations (even no color settings) take place between a call with ACCEL_START and the one with the corresponding ACCEL_END. Because of this, it is also important that you lock the console with vga_lockvc(3) and vga_unlockvc(3), s.t. you cannot be interrupted by a console switch.
It is allowed not to set ACCEL_END for your last call to vga_accel(ACCEL_POLYLINE, ...).Thiswillnotdrawthelastpixelofthelast line which is important for some raster operations when drawing closed polygons. The accelerator will automatically deinitialize when called with another operation in this situation.
It is undefined what happens when you specify other values for flag and when your polyline contains only a single point. The line segments must also not be of length zero.
For implementors: In conjunction with raster operations (ROP_XOR, ROP_INV) it is important that endpoints of inner line section are only drawn once. If you cannot achieve that, you must signal that this function cannot be used in conjunction with raster operations. In this case it is valid to always draw all points of the line segments including the endpoints regardless of the existence of a ACCEL_END parameter.
|vga_accel(ACCEL_POLYHLINE, int flag, int y, int n, unsigned short *xcoords)|
This function combines the features of
ACCEL_DRAWHLINELIST. Starting in row
y horizontal lines are drawn from top to bottom. For each horizontal scanline the
*coords array will contain a number
m followed by
m x coordinates in left to right order. Horizontal lines are drawn between the first and the
second, the third and the fourth x coordinates, and so on. If the
m coordinates are exhausted,
y is increased, a new number
m is read from the
*coords array and operation continues.
This procedure is done for n scan lines.
In addition there is a flag parameter which works similar to ACCEL_POLYLINE. Your first call to ACCEL_DRAWHLINELIST must have the ACCEL_START bit set for proper initialization. The y parameter is ignored when ACCEL_START is not given.
On contrary to ACCEL_POLYLINE it is required that the last call has the ACCEL_END bit set.
The function is intended for drawing complex filled polygons using horizontal scanlines. By issuing small and fast calls for few scanlines only it is possible to intermix drawing and calculations.
The operation of ACCEL_POLYHLINE is undefined if the x coordinates are not sorted from left to right or there are zero length segments in any scan line or if n or one of the m counters are zero, or one of the ms is not even.
Switches polygon fill mode on
(onoffnon-zero) or off.
When in polygon fill mode, ACCEL_DRAWLINE and ACCEL_POLYLINE will only draw a single point on each scanline of each line segment. ACCEL_SCREENCOPYMONO will horizontally scan its source area and start drawing in the foreground color when it encounters a set pixel. When the next pixel is encountered, it will start using the background color and so on.
This can be used for hardware filled polygons:
The rasteroperations and transparency which are signalled to be supported for
are actually meant to apply to the last
Because this polygon drawing uses more screen read/write operations it is probably slower than using ACCEL_DRAWHLINELIST or ACCEL_POLYHLINE for drawing a polygon scanline by scanline. However, it is easier to use and it will work mostly without intervention of the CPU which can do other calculations then. See BUGS below.
It is unspecified if the left or right end points of the scanlines are drawn, and most probably some cards (like Mach32) will omit them on one end, at least. Because of that you should always draw the boundary line in the fill color (or another color) after filling the polygon.
|Set blit strategy. There are two choices for mode, namely BLITS_SYNC and BLITS_IN_BACKGROUND. The first ensures that a vga_accel() call only returns when the accelerator has finished its operation. The second allows for an immediate return and thus allows parallel operation of the CPU and the accelerator. Consecutive accelerator operations will wait for each other to complete (and block if necessary). However, direct screen memory access (also when done implicitly by some call to an svgalib function) may find any intermediate state in vga memory or even corrupt the running accelerator operation.|
|Wait for accelerator to finish when in vga_accel(BLITS_IN_BACKGROUND) mode.|
|vga_accel(ACCEL_SETOFFSET, int address)|
set a screen offset as
vga_setdisplaystart(3) does. The same restrictions for this function as reported by
vga_getmodeinfo(3) apply to
Whenever the video screen offset is modified, the accelerators offset will follow. However you can modify it later with this function.
|The following mode values are defined for vga_accel(ACCEL_SETTRANSPARENCY, int mode, ...)|
|vga_accel(ACCEL_SETTRANSPARENCY, ENABLE_TRANSPARENCY_COLOR, int color)|
|Whenever one of the vga_accel() operations would draw a pixel in color color, no operation is performed and the destination pixel is left unchanged. In fact that color is defined to be transparent.|
|disables the previous functionality.|
|in the bitmap expanding operations ACCEL_PUTBITMAP and ACCEL_SCREENCOPYBITMAP whenever a non set bit is encountered, to not perform any draw operation. The 0 bits do not draw in the background color. Instead they are defined to be transparent.|
disables the previous functionality.
|The following mode values are defined for vga_accel(ACCEL_SETRASTEROP, int mode)|
|Straight copy. Pixels drawn by vga_accel() replace the destination.|
|Logical or. Pixels drawn by vga_accel() are logical (bitwise) ored to the destination.|
|Logical and. Pixels drawn by vga_accel() are logical (bitwise) anded to the destination.|
|Logical exclusive or. Pixels drawn by vga_accel() are logical (bitwise) exclusive ored to the destination (bits set in the drawn pixels flip those pits in the destination).|
Inversion. Pixels drawn by
vga_accel() are inverted. Which color is drawn is actually ignored. Any pixel which would be
overwritten is simply inverted (bitwise) instead.
Instead of calling vga_accel() for each operation to find out if it is supported, you can call:
int vga_ext_set(VGA_EXT_AVAILABLE, VGA_AVAIL_ACCEL)
When the logical bitwise and of the return value with one of the following predefined (one bit set only) integer constants is non zero, the corresponding operation is available: ACCELFLAG_FILLBOX, ACCELFLAG_SCREENCOPY, ACCELFLAG_PUTIMAGE, ACCELFLAG_DRAWLINE, ACCELFLAG_SETFGCOLOR, ACCELFLAG_SETBGCOLOR, ACCELFLAG_SETTRANSPARENCY, ACCELFLAG_SETRASTEROP, ACCELFLAG_PUTBITMAP, ACCELFLAG_SCREENCOPYBITMAP, ACCELFLAG_DRAWHLINELIST, ACCELFLAG_SETMODE and ACCELFLAG_SYNC.
In addition, calling
int vga_ext_set(VGA_EXT_AVAILABLE, VGA_AVAIL_TRANSPARENCY)
int vga_ext_set(VGA_EXT_AVAILABLE, VGA_AVAIL_ROP)
does not list the supported values for raster operations and transparency but instead returns the ACCELFLAG_ values for the accelerator operations which respond the raster operation resp. transparency settings.
The availability of the operations will usually depend on the current video mode selected. You should not try to use them or check for availability prior to selecting the mode you want to use with set_mode(3).
I found the Mach32 buggy in that it occasionally omits drawing last pixels of lines when in polygon fill modes (that means, a single point for the last scanline touched by a line). Obviously this confuses the polygon fill hardware. However, screen corruption will always be restricted to a small area as ACCEL_SCREENCOPYMONO will work only on a limited area. It is not clear if this is a driver error, but it seems to be a hardware bug, and I dont know a clutch to avoid it yet. In case you experience problems with certain applications, try blit nopolyfillmode in the configuration file or the SVGALIB_CONFIG environment variable.
You must ensure that the given screen coordinates lie in screen memory. Actually you may not really be sure how offscreen areas are handled, you can only really trust that coordinates which are visible are supported. For example, the Mach32 restricts the allowable x and y coordinates to the range -512 .. 1535. However, even on a 1MB VGA memory card, the offscreen point (0, 1599) would identify a valid screen memory location (if you could use it).
Where supported, the vga_accel(ACCEL_SETOFFSET, ...) directive might help to ease things a bit in such situations.
Svgalibs accelerator support is a mess. Right now, only the Ark, the Cirrus, the Chips&Technologies, and the Mach32 svga drivers really support this function. The Mach32 still also supports the old style accelerator functions vga_bitblt(3), vga_blitwait(3), vga_fillblt(3), vga_hlinelistblt(3) and vga_imageblt(3) which were first designed for the Cirrus cards and thus the Mach32 has its problems emulating them. The gl_ functions use the accelerator to some extend. Currently the use both the new and the old style accelerator. You should avoid mixing calls of the new and the old style kinds.
These functions are not well tested. You should expect weird bugs. In any case, the accelerator is of not much use in many typical svgalib applications. Best if you are not using them.
BEWARE! You should not use the graphics accelerator together with the background feature of vga_runinbackground(3). However, you can try using vga_lockvc(3) to lock the vc prior to using the accelerator.
The Mach32 driver does this on its own, and even keeps the console locked while background accelerator functions are in progress. Other drivers might not be as graceful.
svgalib(7), vgagl(7), libvga.config(5), accel(6), vga_bitblt(3), vga_blitwait(3), vga_ext_set(3), vga_fillblt(3), vga_getmodeinfo(3), vga_hlinelistblt(3), vga_imageblt(3), vga_runinbackground(3), vga_runinbackground_version(3)
This manual page was edited by Michael Weller <email@example.com>. The exact source of the referenced function as well as of the original documentation is unknown.
It is very likely that both are at least to some extent are due to Harm Hanemaayer <H.Hanemaayer@inter.nl.net>.
Occasionally this might be wrong. I hereby asked to be excused by the original author and will happily accept any additions or corrections to this first version of the svgalib manual.
|Svgalib (>= 1.2.11)||VGA_ACCEL (3)||27 July 1997|