diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-07-26 19:38:36 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-07-26 19:38:36 +0200 |
| commit | 0f06ef7127b669207fd8f09b88ecb660b38eb971 (patch) | |
| tree | d01a688f33f446b3da809f9a154a8748cb5e6506 /tis100-curses.c | |
| parent | 29465804bb9f3bc0eb0f538ec450e9177c0c4767 (diff) | |
| download | tis100-0f06ef7127b669207fd8f09b88ecb660b38eb971.tar.gz tis100-0f06ef7127b669207fd8f09b88ecb660b38eb971.zip | |
Fix more issues caused by negative literals
Diffstat (limited to 'tis100-curses.c')
| -rw-r--r-- | tis100-curses.c | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/tis100-curses.c b/tis100-curses.c index 09cb74c..f7f79c2 100644 --- a/tis100-curses.c +++ b/tis100-curses.c @@ -213,14 +213,12 @@ tui_draw_tpu(struct tpu *tpu) tui_draw_box(x, y, w, h, attr, WACS_D_TTEE, WACS_D_URCORNER, WACS_D_LTEE, WACS_D_RTEE); tui_draw_text(x + 2, y + 1, A_BOLD, "ACC"); - tui_draw_text(x + 1, y + 2, 0, - tpu->acc >= 0 ? " %03i" : "-%03i", tpu->acc); + tui_draw_text(x + 1 + (tpu->acc >= 0), y + 2, 0, "%03i", tpu->acc); tui_draw_box(x, (y += TPU_INFO_H - 1), w, h, attr, WACS_D_LTEE, WACS_D_RTEE, WACS_D_LTEE, WACS_D_RTEE); tui_draw_text(x + 2, y + 1, A_BOLD, "BAK"); - tui_draw_text(x + 1, y + 2, 0, - tpu->bak >= 0 ? " %03i" : "-%03i", tpu->bak); + tui_draw_text(x + 1 + (tpu->bak >= 0), y + 2, 0, "%03i", tpu->bak); tui_draw_box(x, (y += TPU_INFO_H - 1), w, h, attr, WACS_D_LTEE, WACS_D_RTEE, WACS_D_LTEE, WACS_D_RTEE); @@ -255,64 +253,64 @@ tui_draw_tpu(struct tpu *tpu) if (tpu->ports[DIR_LEFT].attached) { port = &tpu->ports[DIR_LEFT]; - if (port->in >= 0) + if (port->in_set) tui_draw_text(sx - 3, sy + 6, A_BOLD, "%03i", port->in); if (port->type & PORT_IN) tui_draw_wch(sx - 1, sy + 7, - port->in >= 0 ? A_BOLD : 0, WACS_RARROW); + port->in_set ? A_BOLD : 0, WACS_RARROW); if (port->type & PORT_OUT) tui_draw_wch(sx - 1, sy + 8, - port->out >= 0 ? A_BOLD : 0, WACS_LARROW); - if (port->out >= 0) + port->out_set ? A_BOLD : 0, WACS_LARROW); + if (port->out_set) tui_draw_text(sx - 3, sy + 10, A_BOLD, "%03i", port->out); } if (tpu->ports[DIR_RIGHT].attached) { port = &tpu->ports[DIR_RIGHT]; - if (port->out >= 0) + if (port->out_set) tui_draw_text(sx + TPU_W + 1, sy + 5, A_BOLD, "%03i", port->out); if (port->type & PORT_OUT) tui_draw_wch(sx + TPU_W + 1, sy + 7, - port->out >= 0 ? A_BOLD : 0, WACS_RARROW); + port->out_set ? A_BOLD : 0, WACS_RARROW); if (port->type & PORT_IN) tui_draw_wch(sx + TPU_W + 1, sy + 8, - port->in >= 0 ? A_BOLD : 0, WACS_LARROW); - if (port->in >= 0) + port->in_set ? A_BOLD : 0, WACS_LARROW); + if (port->in_set) tui_draw_text(sx + TPU_W + 1, sy + 9, A_BOLD, "%03i", port->in); } if (tpu->ports[DIR_UP].attached) { port = &tpu->ports[DIR_UP]; - if (port->out >= 0) + if (port->out_set) tui_draw_text(sx + 9, sy - 1, A_BOLD, "%03i", port->out); if (port->type & PORT_OUT) tui_draw_wch(sx + 13, sy - 1, - port->out >= 0 ? A_BOLD : 0, WACS_UARROW); + port->out_set ? A_BOLD : 0, WACS_UARROW); if (port->type & PORT_IN) tui_draw_wch(sx + 15, sy - 1, - port->in >= 0 ? A_BOLD : 0, WACS_DARROW); - if (port->in >= 0) + port->in_set ? A_BOLD : 0, WACS_DARROW); + if (port->in_set) tui_draw_text(sx + 17, sy - 1, A_BOLD, "%03i", port->in); } if (tpu->ports[DIR_DOWN].attached) { port = &tpu->ports[DIR_DOWN]; - if (port->in >= 0) + if (port->in_set) tui_draw_text(sx + 9, sy + TPU_H, A_BOLD, "%03i", port->in); if (port->type & PORT_IN) tui_draw_wch(sx + 13, sy + TPU_H, - port->in >= 0 ? A_BOLD : 0, WACS_UARROW); + port->in_set ? A_BOLD : 0, WACS_UARROW); if (port->type & PORT_OUT) tui_draw_wch(sx + 15, sy + TPU_H, - port->out >= 0 ? A_BOLD : 0, WACS_DARROW); - if (port->out >= 0) + port->out_set ? A_BOLD : 0, WACS_DARROW); + if (port->out_set) tui_draw_text(sx + 17, sy + TPU_H, A_BOLD, "%03i", port->out); } @@ -388,7 +386,6 @@ static void handlekey(int key) { enum tpu_port_dir dir; - int c; if (input_mode == MAIN) { switch (key) { @@ -408,18 +405,7 @@ handlekey(int key) scrx += 4; break; case 's': - if (tis_stdin && tis.stdin_port.attached - && tis.stdin_port.out < 0) { - c = getc(tis_stdin); - if (c >= 0) tis.stdin_port.out = c; - } - - if (tis.stdout_port.attached && tis.stdout_port.in >= 0) { - if (tis_stdout) - putc(tis.stdout_port.in, tis_stdout); - tis.stdout_port.in = -1; - } - + tis_communicate(&tis, tis_stdin, tis_stdout); tis_step(&tis); break; } |
