diff --git a/source/gfx/gfx.c b/source/gfx/gfx.c index 60c167e..0a4af6e 100644 --- a/source/gfx/gfx.c +++ b/source/gfx/gfx.c @@ -595,6 +595,10 @@ void gfx_set_pixel(u32 x, u32 y, u32 color) gfx_ctxt.fb[x + y * gfx_ctxt.stride] = color; } +void gfx_set_pixel_horz(int x, int y, u32 color) { + *(gfx_ctxt.fb + (YLEFT - x) * gfx_ctxt.stride + y) = color; +} + void gfx_line(int x0, int y0, int x1, int y1, u32 color) { int dx = abs(x1 - x0), sx = x0 < x1 ? 1 : -1; diff --git a/source/gfx/gfx.h b/source/gfx/gfx.h index 56f4e42..b85efa0 100644 --- a/source/gfx/gfx.h +++ b/source/gfx/gfx.h @@ -71,6 +71,7 @@ void gfx_puts_limit(const char *s, u32 limit); void gfx_puts_small(const char *s); void gfx_set_pixel(u32 x, u32 y, u32 color); +void gfx_set_pixel_horz(int x, int y, u32 color); void gfx_line(int x0, int y0, int x1, int y1, u32 color); void gfx_put_small_sep(); void gfx_put_big_sep(); diff --git a/source/script/functions.c b/source/script/functions.c index 8eacfe6..ec977d0 100644 --- a/source/script/functions.c +++ b/source/script/functions.c @@ -70,6 +70,13 @@ scriptFunction(funcMakeByteArray){ return newVar(ByteArrayType, 1, .vectorType = v); } +scriptFunction(funcSetPixel){ + u32 color = 0xFF000000 | ((vars[2].integerType & 0xFF) << 16) | ((vars[3].integerType & 0xFF) << 8) | (vars[4].integerType & 0xFF); + gfx_set_pixel_horz(vars[0].integerType, vars[1].integerType, color); + return NullVar; +} + +u8 fiveInts[] = {IntType, IntType, IntType, IntType, IntType}; u8 singleIntArray[] = { IntArrayType }; u8 singleInt[] = { IntType }; u8 singleAny[] = { varArgs }; @@ -82,6 +89,7 @@ functionStruct_t scriptFunctions[] = { {"else", funcElse, 0, NULL}, {"len", funcLen, 1, singleAny}, {"byte", funcMakeByteArray, 1, singleIntArray}, + {"setPixel", funcSetPixel, 5, fiveInts}, }; Variable_t executeFunction(scriptCtx_t* ctx, char* func_name, lexarToken_t *start, u32 len) {