winvram Device Specification

The Video Ram

The video ram uses 4 Byte (one TETRA) for each pixel: II RR GG BB The high order byte II is ignored, the next byte RR specifies the red value in the range 0 (black) to 255 (full red), then GG the green and finally in the low order byte BB the blue value - again in the range 0 to 255.

The first TETRA belongs to the top left pixel. The second TETRA to the next pixel just to the right of it. Line by line from top to bottom, each TETRA in memory belongs to one pixel. The size of the video ram depends on the configuration. The default gives a frame buffer 640 pixel wide and 480 Pixel high. Other sizes are possible. It is possible to configure the visible size smaller than the size of the frame buffer; this leaves video ram, that is not visible (off screen video ram). It can be used to store bitmaps. These can be transfered to the visible part very fast using the GPU.

The Mouse device

The Mouse device uses 16 Byte that are read-only.

Index | Name | Description
00-01buttons The value indicates which buttons are down when the event happens:
0x01 | = MK_LBUTTON | The left mouse button is down.
0x10 | = MK_MBUTTON | The middle mouse button is down.
0x02 | = MK_RBUTTON | The right mouse button is down.
0x04 | = MK_SHIFT | The SHIFT key is down.
0x08 | = MK_CONTROL | The CTRL key is down.
02-03 | event | The event bits use MK_LBUTTON, MK_MBUTTON, and MK_RBUTTON to indicate the button. Bit 0x04 (MK_SHIFT) is 1 for a down event, and 0 for an up event. If the down event is a double-click, the bit 0x08 (MK_CONTROL) is set in addition. A Mouse Move event is indicated by bit 0x80.
04-05 | x | The x position where the event happens
06-07 | y | The y position where the event happens
08-11 | unused
12-13 | cx | the current x position of the mouse.
14-15 | cy | the current y position of the mouse.

The Graphics Processing Unit GPU

The GPU uses 56 Byte as follows:

Index | Name | Description
0x00 | command/status | see below.
0x01-0x03 | command aux | see below.
0x04-0x05 | x | new x position
0x06-0x07 | y | new y position
0x08-0x09 | w | width
0x0a-0x0b | h | height
0x0c-0x0d | cur_x | current x position
0x0e-0x0f | cur_y | current y position
0x10-0x17 | bba | bit block address
0x18 | - | ignored
0x19 | tbr | text background color red
0x1a | tbg | text background color green
0x1b | tbb | text background color blue
0x1c | - | ignored
0x1d | tfr | text foreground color red
0x1e | tfg | text foreground color green
0x1f | tfb | text foreground color blue
0x20 | - | ignored
0x21 | fr | fill color red
0x22 | fg | fill color green
0x23 | fb | fill color blue
0x24 | - | ignored
0x25 | lr | line color red
0x26 | lg | line color green
0x27 | lb | line color blue
0x28-0x29 | cw | character width
0x2a-0x2b | ch | character height
0x2c-0x2f | - | unused
0x30-0x31 | fw | frame width
0x32-0x33 | fh | frame height
0x34-0x35 | sh | screen width
0x36-0x37 | sh | screen height

The first 4 Byte (0-4) contain the command. Writing any of these bytes will trigger the execution of the command. The command may be split into a command number (byte 0) and some auxiliary information (1-3). The command number (byte 0) also serves as status byte. The most significant bit is an error indicator. Therefore reading a negativ status byte, indicates that an error has occured during the last operation. Reading the status byte will reset the error indicator. So reading the status byte twice will return a nonnegative value the second time (unless a new error has occured between the first and the second read). A zero status byte indicates that the GPU is idle and ready to receive new commands. A positive status byte indicates that the GPU is bussy. The values are device dependent. While the GPU is bussy, the effect of writing to the command byte is unspecified. You can, however, write to (or read from) all the other GPU registers. The values in the other registers will be used only when a GPU command starts executing.

Most commands require a position. The coordinates are either taken from Bytes 4,5 (x) and 6,7 (y) or from Bytes c,d (cur_x) and e,f (cur_y) (the current position). If appropriate, executing a command will update the values cur_x and cur_y to make the current position work like a cursor.

Bit Block transfers from/to non graphic memory need a physical target address. The address goes in the third OCTA, the bit block address (bba).

Some commands require, in addition, color information (Drawing of Text, Lines and Rectangles) this information comes in the fourth and fifth OCTA.

Commands that need new x, y information would primarily use byte 4 to 7. Alternatively the current x,y can be used. Width and height information can be provided in bytes 8, 9 (w) and 0xa, 0xb (w).

The sixth and seventh OCTA are read only. They provide information on the size of the system font, the frame size and the visible part of it.

Commands

command == 0 Do Nothing

command == 1 Write Character

Write the character contained in the low byte of command aux (ASCII) to the current position given in cur_x and cur_y using the system font. Update cur_x and cur_y for the next character. Handle newline (0x0A) by moving cur_x, cur_y to the beginning of the next line and carriage return (0x0D) by moving cur_x, cur_y to the beginning of the current line. Scroll up the screen, if a newline happens to be in the last line of the screen.

command == 2 Draw Rectangle

Draw a filled Rectangle using the fill color, using the x, y position as top left and w,h as the size of the rectangle. No update of the position occurs.

command == 3 Draw Line

Draw a line, using the current line color, from the cur_x, cur_y position to the new x, y position. The new x, y will then replace the current position cur_x, cur_y to support drawing joint lines. If command aux is zero, the default line width is used (usually 1 pixel). If command aux is not zero, it will be used as the line width in pixel.

command == 4 Bit Block Transfer

Transfers a rectangular block of pixels from one part of the video ram to another part of the video ram. The new position x,y is the top left coordinate of the source. The current position cur_x, cur_y is the top left coordinate of the destination; the width and height values w, h define the size of the destination rectangle. Clipping (if needed) occurs on the destination rectangle. The command aux value is used for the raster mode used in a windows Bitblt Function. the following values are defined:

Name | Value | Operation
SRCCOPY | 0xCC0020 | dest = source
SRCPAINT | 0xEE0086 | dest = source OR dest
SRCAND | 0x8800C6 | dest = source AND dest
SRCINVERT | 0x660046 | dest = source XOR dest
SRCERASE | 0x440328 | dest = source AND (NOT dest )
NOTSRCCOPY | 0x330008 | dest = (NOT source)
NOTSRCERASE | 0x1100A6 | dest = (NOT src) AND (NOT dest)
MERGECOPY | 0xC000CA | dest = (source AND pattern)
MERGEPAINT | 0xBB0226 | dest = (NOT source) OR dest
PATCOPY | 0xF00021 | dest = pattern
PATPAINT | 0xFB0A09 | dest = DPSnoo
PATINVERT | 0x5A0049 | dest = pattern XOR dest
DSTINVERT | 0x550009 | dest = (NOT dest)
BLACKNESS | 0x000042 | dest = BLACK
WHITENESS | 0xFF0062 | dest = WHITE

command == 5 Incoming Bit Block Transfer

Transfers a rectangular block of pixels from regular memory into the video memory. The bit block address (bba) is the physical address where the source bit pattern is stored as a sequence of TETRA byte. The current position cur_x, cur_y is the top left coordinate of the destination; the width and height values (w, h) define the size of source and destination rectangle. Clipping (if needed) occurs on the destination rectangle. The command aux value should be used for the raster mode as specified above, (however this is currently not implemented). The values are just copied from source to destination.

The GPU will raise an interrupt when the data transfer has completed.

command == 6 Outgoing Bit Block Transfer

Transfers a rectangular block of pixels from the video memory into regular memory. The current position cur_x, cur_y is the top left coordinate of the source. The width and height values (w, h) define the size of the source and destination rectangle. The bit block address (bba) is the physical address of the destination where the bit pattern is stored as a sequence of TETRA byte. The command aux value should be used for the raster mode as specified above, however, this is currently not implemented. The values are just copied from source to destination.

The GPU will raise an interrupt when the data transfer has completed.

WINVRAM Configuration

The win32 vram device has the following configurable parameters:

host | localhost | the host where the bus is located
port | 9002 | the port where the bus is located
address | 0x0002000000000000 | address where the video ram is located
mouseaddress | 0x0001000000000010 | address where the mouse device is located
gpuaddress | 0x0001000000000020 | address where the GPU is located
interrupt | 19 | interrupt send by the mouse
moveinterrupt | false | whether mouse movements produce interrupts
gpuinterrupt | 20 | interrupt send by the GPU
debug | false | to generate debug output
debugmask | 0xFFF0 | set mask to hide debug output
verbose | false | make debugging verbose, sets debug mask to zero
width | 640 | visible width in pixel
height | 480 | visible height in pixel
fwidth | 640 | frame width in pixel
fheight | 480 | frame height in pixel
fontwidth | 10 | desired width of characters in pixel
fontheight | 20 | desired height of characters in pixel
zoom | 1 | initial zoom factor
define | not set | to define a name for conditionals
config | not set | filename for a configuration file
help | false | to print information
These values can be set in the .vmb file.