Amulets & Armor
v1.02
Open Source Game
|
Graphics Drawing System. More...
Data Structures | |
struct | T_compressEntry |
Macros | |
#define | MAX_PAGES 4 |
#define | PIC2 0xA0 |
#define | RETRACE_INTERRUPT_NUMBER 0x71 |
#define | RETRACE_VERTICAL_CLEAR_BIT 0x10 |
#define | RETRACE_VERTICAL_INTERRUPT_BIT 0x02 |
Variables | |
T_word16 | G_workingPage = 0 |
T_byte8 * | G_workingStart = ((T_byte8 *)(0xA0000)) |
T_screen | GRAPHICS_ACTUAL_SCREEN |
T_byte8 | P_shadeIndex [16384] |
Graphics Drawing System.
Routines for drawing 2D graphics.
#define MAX_PAGES 4 |
#define PIC2 0xA0 |
#define RETRACE_INTERRUPT_NUMBER 0x71 |
#define RETRACE_VERTICAL_CLEAR_BIT 0x10 |
#define RETRACE_VERTICAL_INTERRUPT_BIT 0x02 |
T_void DrawAndShadeRaster | ( | T_byte8 * | p_source, |
T_byte8 * | p_destination, | ||
T_word32 | count, | ||
T_byte8 | shade | ||
) |
DrawAndShadeRaster copies a section of memory from one place to another and shades it in the process.
NOTE: Warning! Since this routine returns a handle to a partial screen, you have to check that you do not draw out of bounds.
p_source | – Where to copy from |
p_destination | – Where to copy to |
count | – How many bytes to copy and shade |
shade | – Shading value (0-255, 0=black, 255=normal) |
GrActualScreenPush saves the current screen onto the screen stack.
None of the graphics commands take effect until this command is called. When that happens, the active screen is copied over the actual screen.
NOTE: Make sure the active screen is not the actual screen, or else this routine is made to bomb.
T_void GrDoubleSizeTransfer | ( | T_screen | destination, |
T_word16 | x_left, | ||
T_word16 | y_top, | ||
T_word16 | x_right, | ||
T_word16 | y_bottom, | ||
T_word16 | dest_x, | ||
T_word16 | dest_y | ||
) |
GrDoubleSizeTransfer draws a to the screen at double size.
NOTE: No clipping is done. Therefore, the region being copied must fit entirely on the destination screen. If it doesn't you get a debug error. Also, the destination cannot equal the active source.
destination | – Screen to transfer to |
x_left | – Left of transfer rectangle |
y_top | – Top of transfer rectangle |
x_right | – Right of transfer rectangle |
y_bottom | – Bottom of tranfer rectangle |
dest_x | – Left of destination rectangle |
dest_y | – Top of destination rectangle |
When you need to draw a bitmap, call this routine. It uses the standard (raw) format of bitmaps. It will blip it on the active screen with NO masking. (Sorry, black is black)
NOTE: No matter how much you want it to, this routine does NOT clip the bitmap at the edge on the screen and trying to will cause it to bomb.
p_bitmap | – Pointer to a bitmap picture |
x_left | – Position of the left |
y_top | – Position of the top |
Other bitmaps may wish the background to show through. To accompany this, pictures should use the color 0 (0x00) to denote a clear pixel color (usually black). All other pixels are drawn.
NOTE: None, other than no clipping like GrDrawBitmap
p_bitmap | – Pointer to a bitmap picture |
x_left | – Position of the left |
y_top | – Position of the top |
GrDrawCharacter is the low level routine to draw a single character on the screen in the active font. Just pass to it a character and it will be drawn at the current cursor position. The cursor position will then be updated.
NOTE: None. Just make sure you used GrSetBitFont earlier.
character | – character to draw |
color | – color to draw character in |
GrDrawCompressedBitmapAndClip is just like GrDrawCompressedBitmap, but it clips to any coordinates on the screen.
NOTE: No matter how much you want it to, this routine does NOT clip the bitmap at the edge on the screen and trying to will cause it to bomb.
p_bitmap | – Pointer to a compressed bitmap picture |
x_left | – Position of the left |
y_top | – Position of the top |
T_void GrDrawCompressedBitmapAndClipAndColor | ( | T_bitmap * | p_bitmap, |
T_sword16 | x_left, | ||
T_sword16 | y_top, | ||
E_colorizeTable | colorTable | ||
) |
GrDrawCompressedBitmapAndClipAndColor is just like GrDrawCompressedBitmapAndClip, but it also includes a colorization.
NOTE: No matter how much you want it to, this routine does NOT clip the bitmap at the edge on the screen and trying to will cause it to bomb.
p_bitmap | – Pointer to a compressed bitmap picture |
x_left | – Position of the left |
y_top | – Position of the top |
colorTable | – Color to transform into |
T_void GrDrawCompressedBitmapAndClipAndColorAndCenterAndResize | ( | T_bitmap * | p_bitmap, |
T_sword16 | x_left, | ||
T_sword16 | y_top, | ||
E_colorizeTable | colorTable, | ||
T_word16 | width, | ||
T_word16 | height | ||
) |
GrDrawCompressedBitmapAndClipAndColor is just like GrDrawCompressedBitmapAndClip, but it also includes a colorization.
NOTE: No matter how much you want it to, this routine does NOT clip the bitmap at the edge on the screen and trying to will cause it to bomb.
p_bitmap | – Pointer to a compressed bitmap picture |
x_left | – Position of the left |
y_top | – Position of the top |
colorTable | – Color to transform into |
width | – Width of area to fill if too big, or center if too small. |
height | – Height of area to fill if too big, or center if too small. |
T_void GrDrawCompressedBitmapAndColor | ( | T_bitmap * | p_bitmap, |
T_word16 | x_left, | ||
T_word16 | y_top, | ||
E_colorizeTable | colorTable | ||
) |
GrDrawCompressedBitmapAndColor is just like GrDrawCompressedBitmap except that you can also colorize the compressed bitmap with the given colorization table.
NOTE: No matter how much you want it to, this routine does NOT clip the bitmap at the edge on the screen and trying to will cause it to bomb.
p_bitmap | – Pointer to a compressed bitmap picture |
x_left | – Position of the left |
y_top | – Position of the top |
colorTable | – colorization table to use. |
T_void GrDrawFrame | ( | T_word16 | x_left, |
T_word16 | y_top, | ||
T_word16 | x_right, | ||
T_word16 | y_bottom, | ||
T_color | color | ||
) |
GrDrawFrame will draw an empty frame in a choice color. Just give the upper-left and lower-right corner of the frame.
NOTE: All coordinates must be on the screen and the upper-left coordinate must be located to the left and above the lower-right corner.
x_left | – Left of frame |
y_top | – Top of frame |
x_right | – Right of frame |
y_bottom | – Bottom of frame |
color | – Color of the frame |
Drawing a horizontal line is useful in making boxes or underlines. In fact, some graphics are all done just by using this command. But anyways, just pass the left and right position along with the line to which to draw it on. Oh yeah, tell what color too.
NOTE: None really. Just keep the left on the left and the right on the right.
x_left | – Left position of line |
y | – Line position from the top |
x_right | – Right position of line (can equal the left position) |
color | – Index of color to use |
Draw a vertical line from a given (x, y) to a second (x, y) in your choice color.
x1 | – X first point |
y1 | – Y first point |
x2 | – X second point. |
y2 | – Y second point. |
color | – Color index to draw with |
Perhaps the lowest level graphics command, this draws one dot on the screen of a specified color.
x | – position from left to right |
y | – position from top to bottom (top = 0) |
color | – color index into palette |
T_void GrDrawRectangle | ( | T_word16 | x_left, |
T_word16 | y_top, | ||
T_word16 | x_right, | ||
T_word16 | y_bottom, | ||
T_color | color | ||
) |
To draw a solid rectangle of one color, use the GrDrawRectangle routine. Pass to it the upper-left coordinate and the lower-right coordinate and the color.
NOTE: All coordinates must be on the screen and the upper-left coordinate must be located to the left and above the lower-right corner.
x_left | – Left of rectangle |
y_top | – Top of rectangle |
x_right | – Right of rectangle |
y_bottom | – Bottom of rectangle |
color | – Color of the rectangle |
T_void GrDrawShadedAndMaskedBitmap | ( | T_bitmap * | p_bitmap, |
T_word16 | x_left, | ||
T_word16 | y_top, | ||
T_byte8 | shade | ||
) |
T_void GrDrawShadedFrame | ( | T_word16 | x_left, |
T_word16 | y_top, | ||
T_word16 | x_right, | ||
T_word16 | y_bottom, | ||
T_color | color1, | ||
T_color | color2 | ||
) |
GrDrawShadedFrame will draw a frame that looks shaded. The upper left corner is one color and the lower right corner is a different color.
NOTE: All coordinates must be on the screen and the upper-left coordinate must be located to the left and above the lower-right corner.
x_left | – Left of frame |
y_top | – Top of frame |
x_right | – Right of frame |
y_bottom | – Bottom of frame |
color1 | – Color of the upper left corner |
color2 | – Color of the lower right corner |
GrDrawShadowed text is just like GrDrawText except that it draws a shadowed color of the text first and then places the normal characters on top.
text | – Pointer to string to draw |
color | – Color to draw text in |
shadow | – Color to draw shadow in |
GrDrawText draws a whole group of characters on the screen at once. It does NOT do any character filtering (such as newline characters).
text | – Pointer to string to draw |
color | – Color to draw text in |
Draw a vertical line from a given (x, y) to a second y in, of course, your choice color.
NOTE: The value of y_top MUST be a smaller value than y_bottom.
x | – column to draw line down |
y_top | – Top line to start drawing (inclusive) |
y_bottom | – Bottom line to end drawing (inclusive) |
color | – Color index to draw with |
Sometimes it is useful to know how wide a character is before you draw it (say for centering text). To get this information, pass GrGetCharacterWidth the character you need info on.
NOTE: None. Just make sure a valid font is in memory.
character | – Character to get width of |
GrGetPalette is used to retrieve the color pallette list or a sub- part of it. Works just like GrSetPalette.
NOTE: If the index of the start color plus the number of colors is >255 The program will bomb.
start_color | – Index to start of colors to change |
number_colors | – Number of colors to change |
p_palette | – Pointer to palette list |
Turn off graphics mode, and turn on text mode. We will drop back to standard 80x25 color text.
Turn on the graphics screen and turn off the text screen.
NOTE: None really. Just the usually – hey, no more text! Actually I just thought of one, this routine doesn't check to see if the computer can handle mode 0x13 graphics.
T_void GrInvalidateRect | ( | T_sword16 | x_left, |
T_sword16 | y_top, | ||
T_sword16 | x_right, | ||
T_sword16 | y_bottom | ||
) |
T_void GrInvalidateRectClipped | ( | T_sword16 | x_left, |
T_sword16 | y_top, | ||
T_sword16 | x_right, | ||
T_sword16 | y_bottom | ||
) |
GrInvertFrame will invert an empty frame on the screen. Just give the upper-left and lower-right corner of the frame.
NOTE: All coordinates must be on the screen and the upper-left coordinate must be located to the left and above the lower-right corner.
x_left | – Left of frame |
y_top | – Top of frame |
x_right | – Right of frame |
y_bottom | – Bottom of frame |
Invert a horizontal line from a given (x, y) to a second x.
NOTE: None really. Just keep the left on the left and the right on the right.
x_left | – Left position of line |
y | – Line position from the top |
x_right | – Right position of line (can equal the left position) |
Invert a vertical line from a given (x, y) to a second y.
NOTE: The value of y_top MUST be a smaller value than y_bottom.
x | – column to draw line down |
y_top | – Top line to start drawing (inclusive) |
y_bottom | – Bottom line to end drawing (inclusive) |
This routine is needed to allocate enough space for a screen. Although this current implementation only allocates a 320x200 region, future versions may wish to provide different size screens. To actually use this screen, you need to use GrScreenSet(). It will then make that screen the active screen.
This routine is needed to allocate enough space for a partial screen. To actually use this screen, you need to use GrScreenSet(). It will then make that screen the active screen.
NOTE: Warning! Since this routine returns a handle to a partial screen, you have to check that you do not draw out of bounds.
When you are done with a screen, you can free it from memory. This routine removes the screen from memory.
NOTE: A screen cannot be freed if it is the active screen. You must either declare another screen as the active (or GRAPHICS_ACTUAL_SCREEN).
screen | – Screen to free. |
Use GrScreenGet to get the handle to the active screen.
Once you have a screen in allocated, in order to use it, you must declare it as the active screen. To do so, use GrScreenSet and pass the screen handle.
NOTE: None really. Just need to make sure the screen is legal. Of course, I can't tell if what is passed is actually a screen or just junk.
screen | – Screen to make the active screen |
GrSetBitFont declares the bit font that the graphics module will use for all consecutive drawing of text. Just pass a pointer to a bit font that has already been loaded into memory.
NOTE: Note that if the font is removed from memory while in use, these routines have no way of knowing that the font is gone and will output garbage. Hopefully this will not cause an error.
p_bitfont | – Pointer to loaded bit font |
GrSetCursorPosition moves the cursor to a new location on the screen. All subsequent character drawing will occur at that new location.
NOTE: x_position and y_position must be inside the screen area for this command to work correctly.
x_position | – left side of where character is drawn |
y_position | – top side of where character is drawn |
T_void GrShadeRectangle | ( | T_word16 | x_left, |
T_word16 | y_top, | ||
T_word16 | x_right, | ||
T_word16 | y_bottom, | ||
T_byte8 | shade | ||
) |
GrShadeRectangle darkens a given rectangular area.
NOTE: All coordinates must be on the screen and the upper-left coordinate must be located to the left and above the lower-right corner.
x_left | – Left of rectangle |
y_top | – Top of rectangle |
x_right | – Right of rectangle |
y_bottom | – Bottom of rectangle |
shade | – Amount to shade |
To help with high speed parts of the game, a transfer from memory to video routine has been provided. Technically, this routine is only for one raster, but one raster can extend onto multiple lines. Just pass a pointer to where in memory you want to get an array of bytes, and x & y coordinate of where to put it, and the number of bytes (length) of the raster.
whereFrom | – Pointer to memory to transfer |
x | – Screen x coordinate |
y | – Screen y coordinate |
length | – Number of bytes to transfer |
To help with high speed parts of the game, a transfer from video to memory routine has been provided. Technically, this routine is only for one raster, but one raster can extend onto multiple lines. Just pass a pointer to where in memory you want to put an array of bytes, and x & y coordinate of where to get it, and the number of bytes (length) of the raster.
whereTo | – Pointer to memory |
x | – Screen x coordinate |
y | – Screen y coordinate |
length | – Number of bytes to transfer |
T_void GrTransferRectangle | ( | T_screen | destination, |
T_word16 | x_left, | ||
T_word16 | y_top, | ||
T_word16 | x_right, | ||
T_word16 | y_bottom, | ||
T_word16 | dest_x, | ||
T_word16 | dest_y | ||
) |
GrTransferRectangle is used to transfer only a section of the active screen to some other destination screen. This routine requires the upper-left and lower-right corners of the region you wish copied and what coordinates you wish to copy too. Note that no masking is performed in this transfer.
NOTE: No clipping is done. Therefore, the region being copied must fit entirely on the destination screen. If it doesn't you get a debug error. Also, the destination cannot equal the active source.
destination | – Screen to transfer to |
x_left | – Left of transfer rectangle |
y_top | – Top of transfer rectangle |
x_right | – Right of transfer rectangle |
y_bottom | – Bottom of tranfer rectangle |
dest_x | – Left of destination rectangle |
dest_y | – Top of destination rectangle |
T_void ShadeMemAsm | ( | T_byte8 * | p_source, |
T_byte8 * | p_destination, | ||
T_word32 | count, | ||
T_byte8 * | p_transTable | ||
) |
T_word16 G_workingPage = 0 |
T_screen GRAPHICS_ACTUAL_SCREEN |
T_byte8 P_shadeIndex[16384] |
When you need to draw a shaded bitmap, call this routine. It uses the standard (raw) format of bitmaps. It will blip it on the active screen with NO masking. (Sorry, black is black)
NOTE: No matter how much you want it to, this routine does NOT clip the bitmap at the edge on the screen and trying to will cause it to bomb.
p_bitmap | – Pointer to a bitmap picture |
x_left | – Position of the left |
y_top | – Position of the top |
shade | – Shading value (0-255, 0=black, 255=normal) |