commit 43d3b0d3b62e306ced4a5020dcaf732cae20f268
parent 11d75bf41c7d22b6a6a76fa2dd4843d23a75fffb
Author: Louis Burda <quent.burda@gmail.com>
Date: Sun, 18 Feb 2024 17:46:52 +0100
Add io port label to curses tui
Diffstat:
3 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/tis100-curses.c b/tis100-curses.c
@@ -5,10 +5,13 @@
#include "asm.h"
#include <curses.h>
+
#include <sys/inotify.h>
#include <unistd.h>
#include <locale.h>
+
#include <errno.h>
+#include <ctype.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
@@ -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
@@ -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
@@ -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;