diff options
author | Toomas Soome <tsoome@me.com> | 2020-11-21 21:27:25 +0200 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2020-12-01 23:45:44 +0200 |
commit | 63f9f2ff473e9cb7f455f032fe3d04a95ec4b537 (patch) | |
tree | 417278aa9fbd33379be63a0b00385a57eb84366c /usr/src/common | |
parent | 166994016fed8bc2ed47612b34708b33007a891b (diff) | |
download | illumos-joyent-63f9f2ff473e9cb7f455f032fe3d04a95ec4b537.tar.gz |
13332 loader: iterate consoles to draw loader menu screen
Reviewed by: Andy Fiddaman <andy@omnios.org>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/common')
-rw-r--r-- | usr/src/common/ficl/loader.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/usr/src/common/ficl/loader.c b/usr/src/common/ficl/loader.c index c41c86c7c2..c1f5c5d0eb 100644 --- a/usr/src/common/ficl/loader.c +++ b/usr/src/common/ficl/loader.c @@ -44,6 +44,7 @@ #else #include <stand.h> #include <gfx_fb.h> +#include <sys/tem_impl.h> #include "bootstrap.h" #endif #ifdef _STANDALONE @@ -71,6 +72,54 @@ * .# ( value -- ) */ +#ifdef _STANDALONE +/* Put image using terminal coordinates. ( flags x1 y1 x2 y2 -- flag ) */ +void +ficl_term_putimage(ficlVm *pVM) +{ + char *namep, *name; + ficlUnsigned names; + ficlInteger ret = FICL_FALSE; + uint32_t x1, y1, x2, y2, f; + png_t png; + + FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 7, 1); + + names = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + namep = (char *)ficlStackPopPointer(ficlVmGetDataStack(pVM)); + y2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + x2 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + y1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + x1 = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + f = ficlStackPopUnsigned(ficlVmGetDataStack(pVM)); + + x1 = tems.ts_p_offset.x + x1 * tems.ts_font.vf_width; + y1 = tems.ts_p_offset.y + y1 * tems.ts_font.vf_height; + if (x2 != 0) { + x2 = tems.ts_p_offset.x + + x2 * tems.ts_font.vf_width; + } + if (y2 != 0) { + y2 = tems.ts_p_offset.y + + y2 * tems.ts_font.vf_height; + } + + name = ficlMalloc(names + 1); + if (!name) + ficlVmThrowError(pVM, "Error: out of memory"); + (void) strncpy(name, namep, names); + name[names] = '\0'; + + if (png_open(&png, name) == PNG_NO_ERROR) { + if (gfx_fb_putimage(&png, x1, y1, x2, y2, f) == 0) + ret = FICL_TRUE; /* success */ + (void) png_close(&png); + } + ficlFree(name); + ficlStackPushInteger(ficlVmGetDataStack(pVM), ret); +} +#endif + /* ( flags x1 y1 x2 y2 -- flag ) */ void ficl_fb_putimage(ficlVm *pVM) @@ -1057,6 +1106,8 @@ ficlSystemCompilePlatform(ficlSystem *pSys) (void) ficlDictionarySetPrimitive(dp, "term-drawrect", ficl_term_drawrect, FICL_WORD_DEFAULT); #ifdef _STANDALONE + (void) ficlDictionarySetPrimitive(dp, "term-putimage", + ficl_term_putimage, FICL_WORD_DEFAULT); /* Register words from linker set. */ SET_FOREACH(fnpp, Xficl_compile_set) (*fnpp)(pSys); |