From 43d3b0d3b62e306ced4a5020dcaf732cae20f268 Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Sun, 18 Feb 2024 17:46:52 +0100 Subject: Add io port label to curses tui --- tis100-curses.c | 9 +++++++++ tpu.c | 2 ++ tpu.h | 3 +++ 3 files changed, 14 insertions(+) diff --git a/tis100-curses.c b/tis100-curses.c index cc36066..e1925c7 100644 --- a/tis100-curses.c +++ b/tis100-curses.c @@ -5,10 +5,13 @@ #include "asm.h" #include + #include #include #include + #include +#include #include #include #include @@ -301,6 +304,9 @@ tui_draw_tpu(struct tpu *tpu) if (tpu->ports[DIR_UP].attached) { port = &tpu->ports[DIR_UP]; + if (port->dst_port->io) + tui_draw_text(sx + 10, sy - 1, A_BOLD, + "IN.%c", toupper(port->dst_port->io->c)); if (port->writing) tui_draw_lit(sx + 8, sy - 1, A_BOLD, port->out); if (port->type & PORT_OUT) @@ -315,6 +321,9 @@ tui_draw_tpu(struct tpu *tpu) if (tpu->ports[DIR_DOWN].attached) { port = &tpu->ports[DIR_DOWN]; + if (port->dst_port->io) + tui_draw_text(sx + 9, sy + TPU_H, A_BOLD, + "OUT.%c", toupper(port->dst_port->io->c)); if (port->avail) tui_draw_lit(sx + 8, sy + TPU_H, A_BOLD, port->in); if (port->type & PORT_IN) diff --git a/tpu.c b/tpu.c index 3a62e11..4d1c566 100644 --- a/tpu.c +++ b/tpu.c @@ -142,6 +142,7 @@ tpu_port_init(struct tpu_port *port, struct tpu *tpu) port->in = -1; port->writing = false; port->out = -1; + port->io = false; } void @@ -181,6 +182,7 @@ tpu_io_port_init(struct tpu_io_port *io_port, char c, enum tpu_port_dir dir, enum tpu_port_type type, int x, int y) { tpu_port_init(&io_port->port, NULL); + io_port->port.io = io_port; io_port->io_step = 0; io_port->type = type; io_port->file = NULL; diff --git a/tpu.h b/tpu.h index 1805d7c..e18b3ed 100644 --- a/tpu.h +++ b/tpu.h @@ -73,6 +73,9 @@ struct tpu_port { struct tpu *tpu; enum tpu_port_type type; + /* set only if managed by io port */ + struct tpu_io_port *io; + /* NOTE: dont access dst_port during execution, * values are transfered in post execution phase */ struct tpu_port *dst_port; -- cgit v1.2.3-71-gd317