From eee1be766d35a3ab76b10fc0aeaf1bbe7a88bfbc Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 21 Feb 2018 16:43:38 -0500 Subject: rejoice! tasks suck no more --- src/main.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index c70d24b..0245801 100644 --- a/src/main.c +++ b/src/main.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -100,6 +101,32 @@ int script_ppos(interpreter *it) return 0; } +int script_color(interpreter *it) +{ + uint16_t c = dsp_color(igetarg_integer(it, 0), igetarg_integer(it, 1), + igetarg_integer(it, 2)); + variable v; + v.valtype = INTEGER; + v.value = c; + v.svalue = 0; + isetstr(&v); + iret(it, &v); + return 0; +} + +int script_rand(interpreter *it) +{ + static uint32_t next = 1; + next = (next * 182 + 1829) % igetarg_integer(it, 0); + variable v; + v.valtype = INTEGER; + v.value = next; + v.svalue = 0; + isetstr(&v); + iret(it, &v); + return 0; +} + void task_interpreter(void) { interpreter it; @@ -110,6 +137,8 @@ void task_interpreter(void) inew_cfunc(&it, "rect", script_rect); inew_cfunc(&it, "ppos", script_ppos); inew_cfunc(&it, "line", script_line); + inew_cfunc(&it, "color", script_color); + inew_cfunc(&it, "rand", script_rand); /*int ret = 0; char *linebuf = malloc(100), c[2] = {0, 0}; @@ -134,8 +163,10 @@ void task_interpreter(void) }*/ char *s = initrd_getfile("init"); - if (s == 0) + if (s == 0) { + dsp_puts("init not found"); goto end; + } char *linebuf = (char *)malloc(120); uint32_t i = 0, prev = 0, lc; @@ -150,7 +181,9 @@ void task_interpreter(void) } strncpy(linebuf, s + prev, lc + 1); linebuf[lc] = '\0'; + //task_hold(1); ret = idoline(&it, linebuf); + //task_hold(0); if (ret < 0) break; prev = ++i; @@ -171,7 +204,6 @@ end: void kmain(void) { asm("cpsie i"); - dsp_init(); dsp_rect(0, 0, LCD_WIDTH, LCD_HEIGHT, dsp_color(0, 0, 0)); dsp_cursoron(); -- cgit v1.2.3