From c27af361feeca0e7cbfa51f5589b09d0c110e9c9 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 8 Mar 2018 12:17:58 -0500 Subject: [PATCH] graphing perfection --- initrd/init | 2 +- libinterp.a | Bin 65386 -> 67130 bytes src/display_draw.c | 7 ++++++- src/heap.c | 28 +++++++++++++++++++--------- src/script.c | 30 ++++++++++-------------------- src/stdlib.c | 40 +++++++++++++++++++++++++++++++++++++--- src/stm32l4xx_it.c | 14 +++++++++----- 7 files changed, 82 insertions(+), 39 deletions(-) diff --git a/initrd/init b/initrd/init index a250822..4908747 100644 --- a/initrd/init +++ b/initrd/init @@ -58,7 +58,7 @@ do do solve Fx > y set y (0 - y) - if ((y > ymin) & (y < ymax)) + if ((y >= ymin) & (y <= ymax)) pixel (cx + x * xinc) (cy + y * yinc) 511 end set x (x + 1 / xinc) diff --git a/libinterp.a b/libinterp.a index 2d0400d5b353ae437de29b69131a42fadc24320f..11ca083c3e1cf243d002cf66fcb3a122ca5e1f27 100644 GIT binary patch delta 18064 zcmb7L3s_ZEzF%vfbASzphoXSM5#;?)Kv6>xpNMZWb4t+y6a*BJ6qTguP+3~zl(?E~ zCd;O$Ih9RhSvqAiHQCL&+HIz$tZ3eMva;J_EGE0Z-`@Y@>$~@U-#y=V_HX^)|Ml9B zwf6qUY0q<8z1vcQqehGwQ8qd~y(FE#bC2oiWurzq-1PL?NTt+7r940T|Nl$Fl=@%) z!T(EmfvoNhrT)MFN4{0+fBPR zN3^fGx@LXdn&!HtEe(o9>$+7-8`h|$>zZ5In_JfwtuA(&armeaC8I`^T{LR+_V*Kf z!$*{qm6%RoAbSe!-0OP7E@5CH`IeZgL{4A#U8Vy0T`* z_f+-O_BC0hNmZow*N$o4@8s3j^juSXWqw9-TVIndWm%#8Y?EuN6`C~+3bUMbIFY+~w81`b5Y-j4DX1qOKrYyx|mQm`p`%yZ^)vPmfqA~~lmC_1wlI(xMW#o94Q|(-HbJTFX+8l_wD0%^P zmUOY1>}SpQ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7Ra71b-*^ zj{ONe6h9WmX~9@Lyy(C$m@7C~kUOH3HwZ2fTrJ3*Qp)cad|dDa!Pf+jgrxAE;Aeto z1wD8!(or|TG{Js?!vxC(|3h$-;1R)h1&i=RqQ5f1P=yp`5HVsG3%y2gz3{gS{es|c z1rLk-Goil~bfXgbOC#cMfMAjE>m2N+ka2r!7Sot*@UhO@H#B(_DZGiT5$;x@x9R)# zeP&>;Jr*$b=_mH*n6ak46BKK1tm=h*I_DRQnpZ~YxZ{}-7AE~TkFIz#Gh!Va_B3_% z@l4Nls5;+|Z#o`lCiT)!9?$md2lF!h#hU>$x0n774DQdpphq4Em?731@%Ws{SURuO*jAm diff --git a/src/display_draw.c b/src/display_draw.c index 62578e3..f58dda7 100644 --- a/src/display_draw.c +++ b/src/display_draw.c @@ -39,10 +39,15 @@ void dsp_putchar(int c) if (++cury == 12) { UNLOCK; dsp_rect(0, 0, LCD_WIDTH, LCD_HEIGHT, 0); - LOCK; cury = 0; } return; + } else if (c == '\b') { + if (curx > 0) + curx--; + UNLOCK; + dsp_rect(curxo + curx * 12, curyo + cury * 26, 12, 26, 0); + return; } unsigned int start = ((c - ' ') / 16 * 192 * 26 + (c % 16) * 12) * 2; diff --git a/src/heap.c b/src/heap.c index 92978b7..52b5253 100644 --- a/src/heap.c +++ b/src/heap.c @@ -1,7 +1,6 @@ #include -#include -#define HEAP_ALIGN 16 +#define HEAP_ALIGN 4 typedef struct { uint32_t size; @@ -10,7 +9,7 @@ typedef struct { static alloc_t *free_blocks; static void *heap_end; -static uint32_t heap_used; +uint32_t heap_used; void heap_init(void *buf) { @@ -21,17 +20,29 @@ void heap_init(void *buf) void *malloc(uint32_t size) { - //task_hold(1); size = (size + sizeof(alloc_t) + HEAP_ALIGN) & ~(HEAP_ALIGN - 1); alloc_t *node = free_blocks; alloc_t *prev = 0; while (node != 0) { if (node->size >= size) { - if (prev != 0) - prev->next = node->next; - else - free_blocks = node->next; + /*if (node->size > size + sizeof(alloc_t) + HEAP_ALIGN) { + alloc_t *rem = (alloc_t *)((uint8_t *)node + + sizeof(alloc_t) + size); + rem->size = node->size - size - sizeof(alloc_t); + rem->next = node->next; + if (prev != 0) + prev->next = rem; + else + free_blocks = rem; + node->size = size; + } else {*/ + if (prev != 0) + prev->next = node->next; + else + free_blocks = node->next; + //} + node->next = 0; heap_used += node->size; return (void *)((uint8_t *)node + sizeof(alloc_t)); @@ -48,7 +59,6 @@ void *malloc(uint32_t size) heap_end = (void *)((uint8_t *)heap_end + size); heap_used += size; - //task_hold(0); return (void *)((uint8_t *)node + sizeof(alloc_t)); } diff --git a/src/script.c b/src/script.c index 495e409..8fad2f3 100644 --- a/src/script.c +++ b/src/script.c @@ -22,7 +22,6 @@ int script_color(interpreter *it); int script_rand(interpreter *it); int script_getkey(interpreter *it); int script_pixel(interpreter *it); -int script_solve(interpreter *it); void script_loadlib(interpreter *it) { @@ -36,7 +35,6 @@ void script_loadlib(interpreter *it) inew_cfunc(it, "rand", script_rand); inew_cfunc(it, "getkey", script_getkey); inew_cfunc(it, "pixel", script_pixel); - inew_cfunc(it, "solve", script_solve); } int script_puts(interpreter *it) @@ -50,14 +48,21 @@ int script_gets(interpreter *it) { char *s = malloc(64); char c[2] = {0, 0}; - uint16_t index = 0; + int index = 0; do { c[0] = serial_get(); s[index] = c[0]; - if (c[0] != '\r') + if (c[0] == '\b' || c[0] == 127) { + index--; + if (index > -1) { + dsp_puts("\b"); + index--; + } + } else if (c[0] != '\r') { dsp_puts(c); - } while (s[index] != '\r' && index++ < 23); + } + } while (s[index] != '\r' && index++ < 63); s[index] = '\0'; variable *r = make_vars(0, s); @@ -135,18 +140,3 @@ int script_pixel(interpreter *it) return 0; } -int script_solve(interpreter *it) -{ - const char *expr = igetarg_string(it, 0); - int len = strlen(expr); - char *buf = (char *)malloc(len + 2); - strcpy(buf, expr); - buf[len] = ')'; - buf[len + 1] = '\0'; - variable *r = idoexpr(it, buf); - if (r == 0) - r = make_varn(0, 0.0f); - iret(it, r); - free(r); - return 0; -} diff --git a/src/stdlib.c b/src/stdlib.c index ec67ff3..e34d2a0 100644 --- a/src/stdlib.c +++ b/src/stdlib.c @@ -67,15 +67,49 @@ float strtof(const char *s, char **endptr) { (void)s; (void)endptr; - return 0.0f; + + float res = 0.0f; + char neg = 0; + unsigned int i = 0; + + if (s[0] == '-') { + neg = 1; + i++; + } + + for (; isdigit(s[i]); i++) { + res *= 10.0f; + res += (s[i] - '0'); + } + + if (s[i] != '.') + goto end; + + float div = 0.1f; + for (i++; isdigit(s[i]); i++) { + res += div * (s[i] - '0'); + div /= 10.0f; + } + +end: + return (neg == 0) ? res : -res; } int atoi(const char *s) { + unsigned int i = 0; + char neg = 0; int n = 0; - for (unsigned int i = 0; isdigit(s[i]); i++) { + + if (s[0] == '-') { + neg = 1; + i = 1; + } + + for (; isdigit(s[i]); i++) { n *= 10; n += s[i] - '0'; } - return n; + + return (neg == 0) ? n : -n; } diff --git a/src/stm32l4xx_it.c b/src/stm32l4xx_it.c index e54a192..228dc67 100644 --- a/src/stm32l4xx_it.c +++ b/src/stm32l4xx_it.c @@ -12,12 +12,16 @@ void serial_puts(const char *s) void perror(const char *s) { - //extern task_t *current; + extern uint32_t heap_used; serial_puts(s); - //char buf[200]; - //snprintf(buf, 200, "xPSR: %x\r\nPC: %x\r\nLR: %x\r\n", current->sp[0], - // current->sp[1], current->sp[2]); - //serial_puts(buf); + + static char buf[200]; + uint32_t *psp; + asm("mrs %0, psp" : "=r"(psp)); + + snprintf(buf, 200, "\r\nPC: %x\r\nLR: %x\r\nmemused: %db\r\n", + psp[6], psp[5], heap_used); + serial_puts(buf); } __attribute__ ((naked))