#include "general.h"#include "text.h"#include <stdbool.h>#include <mcp/syscalls.h>#include "a2560k.h"Go to the source code of this file.
Data Structures | |
| struct | Bitmap |
Functions | |
| Bitmap * | Bitmap_New (int16_t width, int16_t height, Font *the_font, bool in_vram) |
| Create a new bitmap object by allocating space for the bitmap struct in regular memory, and for the graphics, in VRAM NOTE: when creating a bitmap to represent something actually in VRAM, pass true to in_vram, and manually assign a known VRAM location afterwards. More... | |
| bool | Bitmap_Resize (Bitmap *the_bitmap, int16_t width, int16_t height) |
| Resize and existing bitmap by setting new width/height and allocating bigger storage if necessary NOTE: if the bitmap is held in VRAM, storage will not be reallocated NOTE: if the new size for the bitmap is smaller than the previous size, storage will not be reallocated - extra bytes will simply not be used. More... | |
| bool | Bitmap_BlitRect (Bitmap *src_bm, Rectangle *src_rect, Bitmap *dst_bm, int16_t dst_x, int16_t dst_y) |
| Blit a rect from source bitmap to distination bitmap This is a wrapper around Bitmap_Blit() The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another. More... | |
| bool | Bitmap_Blit (Bitmap *src_bm, int16_t src_x, int16_t src_y, Bitmap *dst_bm, int16_t dst_x, int16_t dst_y, int16_t width, int16_t height) |
| Blit from source bitmap to distination bitmap. More... | |
| bool | Bitmap_Tile (Bitmap *src_bm, int16_t src_x, int16_t src_y, Bitmap *dst_bm, int16_t width, int16_t height) |
| Tile the source bitmap into the destination bitmap, filling it The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another. More... | |
| bool | Bitmap_TileV1 (Bitmap *src_bm, int16_t src_x, int16_t src_y, Bitmap *dst_bm, int16_t width, int16_t height) |
| Tile the source bitmap into the destination bitmap, filling it The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another. More... | |
| bool | Bitmap_TileV2 (Bitmap *src_bm, int16_t src_x, int16_t src_y, Bitmap *dst_bm, int16_t width, int16_t height) |
| Tile the source bitmap into the destination bitmap, filling it The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another. More... | |
| bool | Bitmap_TileV3 (Bitmap *src_bm, int16_t src_x, int16_t src_y, Bitmap *dst_bm, int16_t width, int16_t height) |
| Tile the source bitmap into the destination bitmap, filling it The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another. More... | |
| bool | Bitmap_FillMemory (Bitmap *the_bitmap, uint8_t the_color) |
| bool | Bitmap_FillBoxRect (Bitmap *the_bitmap, Rectangle *the_coords, uint8_t the_color) |
| Fill pixel values for the passed Rectangle object, using the specified LUT value. More... | |
| bool | Bitmap_FillBox (Bitmap *the_bitmap, int16_t x, int16_t y, int16_t width, int16_t height, uint8_t the_color) |
| Fill pixel values for a specific box area calling function must validate screen id, coords! More... | |
| bool | Bitmap_SetFont (Bitmap *the_bitmap, Font *the_font) |
| Set the font This is the font that will be used for all font drawing in this bitmap. More... | |
| bool | Bitmap_SetColor (Bitmap *the_bitmap, uint8_t the_color) |
| Set the "pen" color This is the color that the next pen-based graphics function will use This only affects functions that use the pen: any graphics function that specifies a color will use that instead. More... | |
| bool | Bitmap_SetXY (Bitmap *the_bitmap, int16_t x, int16_t y) |
| Set the "pen" position This is the location that the next pen-based graphics function will use for a starting location NOTE: you are allowed to set negative values, but not values greater than the height/width of the screen. More... | |
| uint8_t | Bitmap_GetColor (Bitmap *the_bitmap) |
| Get the current color of the pen. More... | |
| int16_t | Bitmap_GetX (Bitmap *the_bitmap) |
| Get the current X position of the pen. More... | |
| int16_t | Bitmap_GetY (Bitmap *the_bitmap) |
| Get the current Y position of the pen. More... | |
| unsigned char * | Bitmap_GetMemLoc (Bitmap *the_bitmap) |
| Calculate the VRAM location of the current coordinate within the bitmap. More... | |
| uint32_t | Bitmap_GetMemLocInt (Bitmap *the_bitmap) |
| Calculate the VRAM location of the current coordinate within the bitmap. More... | |
| Font * | Bitmap_GetFont (Bitmap *the_bitmap) |
| Get the current font of the pen. More... | |
| bool | Bitmap_SetPixelAtXY (Bitmap *the_bitmap, int16_t x, int16_t y, uint8_t the_color) |
| Set a char at a specified x, y coord. More... | |
| uint8_t | Bitmap_GetPixelAtXY (Bitmap *the_bitmap, int16_t x, int16_t y) |
| Get the pixel CLUT index at a specified x, y coord. More... | |
| bool | Bitmap_DrawLine (Bitmap *the_bitmap, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t the_color) |
| Draws a line between 2 passed coordinates. More... | |
| bool | Bitmap_DrawHLine (Bitmap *the_bitmap, int16_t x, int16_t y, int16_t the_line_len, uint8_t the_color) |
| Draws a horizontal line from specified coords, for n pixels, using the specified pixel value. More... | |
| bool | Bitmap_DrawVLine (Bitmap *the_bitmap, int16_t x, int16_t y, int16_t the_line_len, uint8_t the_color) |
| Draws a vertical line from specified coords, for n pixels. More... | |
| bool | Bitmap_DrawBoxRect (Bitmap *the_bitmap, Rectangle *the_coords, uint8_t the_color) |
| Draws a rectangle based on the passed Rectangle object, using the specified LUT value. More... | |
| bool | Bitmap_DrawBoxCoords (Bitmap *the_bitmap, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t the_color) |
| Draws a rectangle based on 2 sets of coords, using the specified LUT value. More... | |
| bool | Bitmap_DrawBox (Bitmap *the_bitmap, int16_t x, int16_t y, int16_t width, int16_t height, uint8_t the_color, bool do_fill) |
| Draws a rectangle based on start coords and width/height, and optionally fills the rectangle. More... | |
| bool | Bitmap_DrawRoundBox (Bitmap *the_bitmap, int16_t x, int16_t y, int16_t width, int16_t height, int16_t radius, uint8_t the_color, bool do_fill) |
| Draws a rounded rectangle with the specified size and radius, and optionally fills the rectangle. More... | |
| bool | Bitmap_DrawCircle (Bitmap *the_bitmap, int16_t x1, int16_t y1, int16_t radius, uint8_t the_color) |
| Draw a circle Based on http://rosettacode.org/wiki/Bitmap/Midpoint_circle_algorithm#C. | |
| bool Bitmap_Blit | ( | Bitmap * | src_bm, |
| int16_t | src_x, | ||
| int16_t | src_y, | ||
| Bitmap * | dst_bm, | ||
| int16_t | dst_x, | ||
| int16_t | dst_y, | ||
| int16_t | width, | ||
| int16_t | height | ||
| ) |
Blit from source bitmap to distination bitmap.
The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another. If the destination location cannot fit the entirety of the copied rectangle, the copy will be truncated, but will not return an error.
| src_bm | – the source bitmap. It must have a valid address within the VRAM memory space. |
| dst_bm | – the destination bitmap. It must have a valid address within the VRAM memory space. It can be the same bitmap as the source. |
| src_x | – the upper left coordinate within the source bitmap, for the rectangle you want to copy. May be negative. |
| src_y | – the upper left coordinate within the source bitmap, for the rectangle you want to copy. May be negative. |
| dst_x | – the location within the destination bitmap to copy pixels to. May be negative. |
| dst_y | – the location within the destination bitmap to copy pixels to. May be negative. |
| width | – the scope of the copy, in pixels. |
| height | – the scope of the copy, in pixels. |
| bool Bitmap_BlitRect | ( | Bitmap * | src_bm, |
| Rectangle * | src_rect, | ||
| Bitmap * | dst_bm, | ||
| int16_t | dst_x, | ||
| int16_t | dst_y | ||
| ) |
Blit a rect from source bitmap to distination bitmap This is a wrapper around Bitmap_Blit() The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another.
If the destination location cannot fit the entirety of the copied rectangle, the copy will be truncated, but will not return an error.
| src_bm | – the source bitmap. It must have a valid address within the VRAM memory space. |
| dst_bm | – the destination bitmap. It must have a valid address within the VRAM memory space. It can be the same bitmap as the source. |
| src_rect | – the rectangle from the source bitmap to be blitted to the target bitmap |
| dst_x | – the location within the destination bitmap to copy pixels to. May be negative. |
| dst_y | – the location within the destination bitmap to copy pixels to. May be negative. |
| bool Bitmap_DrawBox | ( | Bitmap * | the_bitmap, |
| int16_t | x, | ||
| int16_t | y, | ||
| int16_t | width, | ||
| int16_t | height, | ||
| uint8_t | the_color, | ||
| bool | do_fill | ||
| ) |
Draws a rectangle based on start coords and width/height, and optionally fills the rectangle.
| width | – width, in pixels, of the rectangle to be drawn |
| height | – height, in pixels, of the rectangle to be drawn |
| the_color | – a 1-byte index to the current LUT |
| do_fill | – If true, the box will be filled with the provided color. If false, the box will only draw the outline. |
| bool Bitmap_DrawBoxCoords | ( | Bitmap * | the_bitmap, |
| int16_t | x1, | ||
| int16_t | y1, | ||
| int16_t | x2, | ||
| int16_t | y2, | ||
| uint8_t | the_color | ||
| ) |
Draws a rectangle based on 2 sets of coords, using the specified LUT value.
| the_color | – a 1-byte index to the current LUT |
Draws a rectangle based on the passed Rectangle object, using the specified LUT value.
| the_color | – a 1-byte index to the current LUT |
| bool Bitmap_DrawHLine | ( | Bitmap * | the_bitmap, |
| int16_t | x, | ||
| int16_t | y, | ||
| int16_t | the_line_len, | ||
| uint8_t | the_color | ||
| ) |
Draws a horizontal line from specified coords, for n pixels, using the specified pixel value.
| the_color | – a 1-byte index to the current LUT |
| bool Bitmap_DrawLine | ( | Bitmap * | the_bitmap, |
| int16_t | x1, | ||
| int16_t | y1, | ||
| int16_t | x2, | ||
| int16_t | y2, | ||
| uint8_t | the_color | ||
| ) |
Draws a line between 2 passed coordinates.
Use for any line that is not perfectly vertical or perfectly horizontal Based on http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#C. Used in C128 Lich King.
| bool Bitmap_DrawRoundBox | ( | Bitmap * | the_bitmap, |
| int16_t | x, | ||
| int16_t | y, | ||
| int16_t | width, | ||
| int16_t | height, | ||
| int16_t | radius, | ||
| uint8_t | the_color, | ||
| bool | do_fill | ||
| ) |
Draws a rounded rectangle with the specified size and radius, and optionally fills the rectangle.
| width | – width, in pixels, of the rectangle to be drawn |
| height | – height, in pixels, of the rectangle to be drawn |
| radius | – radius, in pixels, of the arc to be applied to the rectangle's corners. Enforces a minimum of 3, maximum of 20. |
| the_color | – a 1-byte index to the current color LUT |
| do_fill | – If true, the box will be filled with the provided color. If false, the box will only draw the outline. |
| bool Bitmap_DrawVLine | ( | Bitmap * | the_bitmap, |
| int16_t | x, | ||
| int16_t | y, | ||
| int16_t | the_line_len, | ||
| uint8_t | the_color | ||
| ) |
Draws a vertical line from specified coords, for n pixels.
| the_color | – a 1-byte index to the current LUT |
| bool Bitmap_FillBox | ( | Bitmap * | the_bitmap, |
| int16_t | x, | ||
| int16_t | y, | ||
| int16_t | width, | ||
| int16_t | height, | ||
| uint8_t | the_color | ||
| ) |
Fill pixel values for a specific box area calling function must validate screen id, coords!
| the_color | – a 1-byte index to the current LUT |
| width | – width, in pixels, of the rectangle to be filled |
| height | – height, in pixels, of the rectangle to be filled |
| the_color | – a 1-byte index to the current LUT |
Fill pixel values for the passed Rectangle object, using the specified LUT value.
| the_color | – a 1-byte index to the current LUT |
| bool Bitmap_FillMemory | ( | Bitmap * | the_bitmap, |
| uint8_t | the_color | ||
| ) |
| the_color | – a 1-byte index to the current LUT |
| uint8_t Bitmap_GetColor | ( | Bitmap * | the_bitmap | ) |
Get the current color of the pen.
| the_bitmap | – reference to a valid Bitmap object. |
Get the current font of the pen.
| the_bitmap | – reference to a valid Bitmap object. |
| unsigned char * Bitmap_GetMemLoc | ( | Bitmap * | the_bitmap | ) |
Calculate the VRAM location of the current coordinate within the bitmap.
| the_bitmap | – reference to a valid Bitmap object. |
| uint32_t Bitmap_GetMemLocInt | ( | Bitmap * | the_bitmap | ) |
Calculate the VRAM location of the current coordinate within the bitmap.
| the_bitmap | – reference to a valid Bitmap object. |
| uint8_t Bitmap_GetPixelAtXY | ( | Bitmap * | the_bitmap, |
| int16_t | x, | ||
| int16_t | y | ||
| ) |
Get the pixel CLUT index at a specified x, y coord.
| int16_t Bitmap_GetX | ( | Bitmap * | the_bitmap | ) |
Get the current X position of the pen.
| the_bitmap | – reference to a valid Bitmap object. |
| int16_t Bitmap_GetY | ( | Bitmap * | the_bitmap | ) |
Get the current Y position of the pen.
| the_bitmap | – reference to a valid Bitmap object. |
Create a new bitmap object by allocating space for the bitmap struct in regular memory, and for the graphics, in VRAM NOTE: when creating a bitmap to represent something actually in VRAM, pass true to in_vram, and manually assign a known VRAM location afterwards.
| width | – width, in pixels, of the bitmap to be created |
| height | – height, in pixels, of the bitmap to be created |
| the_font | – optional font object to associate with the Bitmap. |
| in_vram | – if true, no space will be allocated for the bitmap graphics. If false, width * height area of memory will be allocated in standard memory. |
| bool Bitmap_Resize | ( | Bitmap * | the_bitmap, |
| int16_t | width, | ||
| int16_t | height | ||
| ) |
Resize and existing bitmap by setting new width/height and allocating bigger storage if necessary NOTE: if the bitmap is held in VRAM, storage will not be reallocated NOTE: if the new size for the bitmap is smaller than the previous size, storage will not be reallocated - extra bytes will simply not be used.
| width | – the new width, in pixels, to resize the bitmap to |
| height | – the new height, in pixels, to resize the bitmap to |
| bool Bitmap_SetColor | ( | Bitmap * | the_bitmap, |
| uint8_t | the_color | ||
| ) |
Set the "pen" color This is the color that the next pen-based graphics function will use This only affects functions that use the pen: any graphics function that specifies a color will use that instead.
| the_bitmap | – reference to a valid Bitmap object. |
| the_color | – a 1-byte index to the current LUT |
| bool Bitmap_SetPixelAtXY | ( | Bitmap * | the_bitmap, |
| int16_t | x, | ||
| int16_t | y, | ||
| uint8_t | the_color | ||
| ) |
Set a char at a specified x, y coord.
| the_color | – a 1-byte index to the current LUT |
| bool Bitmap_SetXY | ( | Bitmap * | the_bitmap, |
| int16_t | x, | ||
| int16_t | y | ||
| ) |
Set the "pen" position This is the location that the next pen-based graphics function will use for a starting location NOTE: you are allowed to set negative values, but not values greater than the height/width of the screen.
This is to allow for functions that may have portions visible on the screen, such as a row of text that starts 2 pixels to the left of the bitmap's left edge. This only affects functions that use the pen: any graphics function that specifies an X, Y coordinate will use that instead
| the_bitmap | – reference to a valid Bitmap object. |
| x | – the horizontal position, between 0 and bitmap width - 1 |
| y | – the vertical position, between 0 and bitmap height - 1 |
| bool Bitmap_Tile | ( | Bitmap * | src_bm, |
| int16_t | src_x, | ||
| int16_t | src_y, | ||
| Bitmap * | dst_bm, | ||
| int16_t | width, | ||
| int16_t | height | ||
| ) |
Tile the source bitmap into the destination bitmap, filling it The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another.
If the destination location cannot fit the entirety of the copied rectangle, the copy will be truncated, but will not return an error.
| src_bm | – the source bitmap. It must have a valid address within the VRAM memory space. |
| dst_bm | – the destination bitmap. It must have a valid address within the VRAM memory space. It can be the same bitmap as the source. |
| src_x | – the upper left coordinate within the source bitmap, for the tile you want to copy. Must be non-negative. |
| src_y | – the upper left coordinate within the source bitmap, for the tile you want to copy. Must be non-negative. |
| width | – the size of the tile to be derived from the source bitmap, in pixels. |
| height | – the size of the tile to be derived from the source bitmap, in pixels. |
| bool Bitmap_TileV1 | ( | Bitmap * | src_bm, |
| int16_t | src_x, | ||
| int16_t | src_y, | ||
| Bitmap * | dst_bm, | ||
| int16_t | width, | ||
| int16_t | height | ||
| ) |
Tile the source bitmap into the destination bitmap, filling it The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another.
If the destination location cannot fit the entirety of the copied rectangle, the copy will be truncated, but will not return an error.
| src_bm | – the source bitmap. It must have a valid address within the VRAM memory space. |
| dst_bm | – the destination bitmap. It must have a valid address within the VRAM memory space. It can be the same bitmap as the source. |
| src_x | – the upper left coordinate within the source bitmap, for the tile you want to copy. Must be non-negative. |
| src_y | – the upper left coordinate within the source bitmap, for the tile you want to copy. Must be non-negative. |
| width | – the size of the tile to be derived from the source bitmap, in pixels. |
| height | – the size of the tile to be derived from the source bitmap, in pixels. |
| bool Bitmap_TileV2 | ( | Bitmap * | src_bm, |
| int16_t | src_x, | ||
| int16_t | src_y, | ||
| Bitmap * | dst_bm, | ||
| int16_t | width, | ||
| int16_t | height | ||
| ) |
Tile the source bitmap into the destination bitmap, filling it The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another.
If the destination location cannot fit the entirety of the copied rectangle, the copy will be truncated, but will not return an error.
| src_bm | – the source bitmap. It must have a valid address within the VRAM memory space. |
| dst_bm | – the destination bitmap. It must have a valid address within the VRAM memory space. It can be the same bitmap as the source. |
| src_x | – the upper left coordinate within the source bitmap, for the tile you want to copy. Must be non-negative. |
| src_y | – the upper left coordinate within the source bitmap, for the tile you want to copy. Must be non-negative. |
| width | – the size of the tile to be derived from the source bitmap, in pixels. |
| height | – the size of the tile to be derived from the source bitmap, in pixels. |
| bool Bitmap_TileV3 | ( | Bitmap * | src_bm, |
| int16_t | src_x, | ||
| int16_t | src_y, | ||
| Bitmap * | dst_bm, | ||
| int16_t | width, | ||
| int16_t | height | ||
| ) |
Tile the source bitmap into the destination bitmap, filling it The source and destination bitmaps can be the same: you can use this to copy a chunk of pixels from one part of a screen to another.
If the destination location cannot fit the entirety of the copied rectangle, the copy will be truncated, but will not return an error.
| src_bm | – the source bitmap. It must have a valid address within the VRAM memory space. |
| dst_bm | – the destination bitmap. It must have a valid address within the VRAM memory space. It can be the same bitmap as the source. |
| src_x | – the upper left coordinate within the source bitmap, for the tile you want to copy. Must be non-negative. |
| src_y | – the upper left coordinate within the source bitmap, for the tile you want to copy. Must be non-negative. |
| width | – the size of the tile to be derived from the source bitmap, in pixels. |
| height | – the size of the tile to be derived from the source bitmap, in pixels. |