some useful graphics functions More...
Macros | |
Drawing settings | |
#define | G_SCREEN_BUFFER plotSScreen |
the temp ram where you draw to | |
#define | G_COL_START 0x20 |
#define | G_START_ROW 0x80 |
#define | G_ROW_END 0xBF |
#define | G_MAX_ROW 12 |
#define | G_BLOB_END 768 |
#define | G_CLEAR_BUFFER_CO 48 |
#define | buff ( (char*)G_SCREEN_BUFFER ) |
Use this like a variable for interacting with the screen buffer. | |
#define | _LCD_BUSY_QUICK 0x000B |
function to call from ASM to wait required amount of time between screen calls | |
#define | XMAX 96 |
Width of screen in pixels. | |
#define | YMAX 64 |
Height of screen in pixels. | |
Functions | |
void | clearBuffer () |
clears screen buffer as defined by G_SCREEN_BUFFER If you wish to redefine the screen size you muse set multiple #defines before you include this file. You can find an example of this in examples/2048/main.c | |
void | swap () |
fast enough way to display SCREEN_BUFFER on lcd See the scoreboard in examples/2048/main.c for redefining the location of the screen | |
void | line (char x, char y, char x2, char y2) __naked __z88dk_sdccdecl __z88dk_callee |
Draw a line between any 2 valid points. | |
void | vertical_line (char x, char start, char height, char not_used) __naked |
Quick verticle line drawing routine. | |
void | vertical_dotted_line (char x, char start, char height, char not_used) __naked |
Quick dotted verticle line drawing routine. | |
void | ___GetPixel () __naked |
ASM Routine to get the memory location of a pixel based | |
void | setPix (char x, char y) __naked __z88dk_callee __z88dk_sdccdecl |
Set a pixel on the screen. | |
void | __drawCircleSegment (char xc, char yc, char x, char y) |
Do not call me. | |
void | circle (char xc, char yc, char r) |
Circle drawing routine. | |
some useful graphics functions
void ___GetPixel | ( | ) |
ASM Routine to get the memory location of a pixel based
[A] | The x coord |
[L] | The y coord |
Only call this from assembly Taken from https://taricorp.gitlab.io/83pa28d/lesson/week4/day24/index.html
void circle | ( | char | xc, |
char | yc, | ||
char | r ) |
Circle drawing routine.
[xc] | X coord of center of the circle |
[yc] | Y coord of center of the circle |
[r] | Radius of the circle |
This code is quite slow as it is entirly written in c and uses the already quite slow setPix()
taken from https://www.geeksforgeeks.org/bresenhams-circle-drawing-algorithm/ and modified
void clearBuffer | ( | ) |
clears screen buffer as defined by G_SCREEN_BUFFER If you wish to redefine the screen size you muse set multiple #defines before you include this file. You can find an example of this in examples/2048/main.c
Taken from https://taricorp.gitlab.io/83pa28d/lesson/day10.html
void line | ( | char | x, |
char | y, | ||
char | x2, | ||
char | y2 ) |
Draw a line between any 2 valid points.
[x] | First x coord (between 0-XMAX) |
[x] | First y coord (between 0-YMAX) |
[x2] | Secound x coord (between 0-XMAX) |
[y2] | Secound y coord (between 0-YMAX) |
Draws a line onto G_SCREEN_BUFFER between (x, y) and (x2, y2)
taken from https://wikiti.brandonw.net/index.php?title=Z80_Routines:Graphic:LineDraw and adapted for sdcc, should be quite fast
void setPix | ( | char | x, |
char | y ) |
Set a pixel on the screen.
[x] | the x value to draw at (0-XMAX) |
[y] | the y value to draw at (0-YMAX) |
This is a routine that works, but is overall not the most efficient way to draw on the screen.
void vertical_dotted_line | ( | char | x, |
char | start, | ||
char | height, | ||
char | not_used ) |
Quick dotted verticle line drawing routine.
[x] | the x value to draw at (0-XMAX) |
[start] | the y value to start at (0-YMAX-1) |
[height] | How long the line should be (1-YMAX) |
[not_used] | Can be anything, this value is just discarded. Odd number byte params require more instructions than Even number params |
Quickly draws a dotted verticle line onto G_SCREEN_BUFFER
void vertical_line | ( | char | x, |
char | start, | ||
char | height, | ||
char | not_used ) |
Quick verticle line drawing routine.
[x] | the x value to draw at (0-XMAX) |
[start] | the y value to start at (0-YMAX-1) |
[height] | How long the line should be (1-YMAX) |
[not_used] | Can be anything, this value is just discarded. Odd number byte params require more instructions than Even number params |
Quickly draws a verticle line onto G_SCREEN_BUFFER