summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2023-12-25 04:13:41 +0100
committerLouis Burda <quent.burda@gmail.com>2023-12-25 04:13:41 +0100
commit8ec5b039472f9fbe24f2eb1c5d8e66a7551a33fd (patch)
tree55f8af2371e6f9bd75f48f991984a818de9dbb1b
parentee7820e1cfde69c16130a43c8b7e7df1724afb9e (diff)
downloadtis100-8ec5b039472f9fbe24f2eb1c5d8e66a7551a33fd.tar.gz
tis100-8ec5b039472f9fbe24f2eb1c5d8e66a7551a33fd.zip
Fixup more behaviour - add dim idle indicator
-rw-r--r--tis100-curses.c7
-rw-r--r--tis100.c8
-rw-r--r--tpu.c21
3 files changed, 14 insertions, 22 deletions
diff --git a/tis100-curses.c b/tis100-curses.c
index ec1eb2d..313aa44 100644
--- a/tis100-curses.c
+++ b/tis100-curses.c
@@ -157,8 +157,7 @@ tui_draw_lit(int x, int y, attr_t attr, int lit)
{
char buf[6];
- snprintf(buf, 5, "%03i", lit);
- if (buf[0] != '-') x += 1;
+ snprintf(buf, 5, "% 04i", lit);
tui_draw_text(x, y, attr, "%.*s", 4, buf);
}
@@ -213,8 +212,8 @@ tui_draw_tpu(struct tpu *tpu)
}
asm_print_inst(linebuf, sizeof(linebuf), &tpu->insts[inst]);
tui_draw_text(sx + 2, sy + 1 + off,
- inst == tpu->pc ? A_STANDOUT : 0, "%-*.*s",
- TPU_INPUT_COLS, TPU_INPUT_COLS, linebuf);
+ inst == tpu->pc ? A_STANDOUT | (tpu->idle ? A_DIM : 0) : 0,
+ "%-*.*s", TPU_INPUT_COLS, TPU_INPUT_COLS, linebuf);
inst++; off++;
}
}
diff --git a/tis100.c b/tis100.c
index 633ac59..02904b2 100644
--- a/tis100.c
+++ b/tis100.c
@@ -37,7 +37,6 @@ main(int argc, const char **argv)
{
struct tis_stats stats;
bool idle, prev_idle;
- int i;
if (argc < 2) {
fprintf(stderr, "Usage: tis100 FILE [IO..]\n");
@@ -54,13 +53,6 @@ main(int argc, const char **argv)
idle = !tis_step(&tis);
}
- for (i = 0; i < TIS_MAX_IO_PORTS; i++) {
- if (tis.out_ports[i] && tis.out_ports[i]->io_step > 0) {
- }
- }
-
- tis.steps -= 1; /* remove last idle step */
-
if (tis.show_stats) {
stats = tis_gen_stats(&tis);
printf("=== stats ===\n");
diff --git a/tpu.c b/tpu.c
index 13db28d..9fb87c3 100644
--- a/tpu.c
+++ b/tpu.c
@@ -205,7 +205,7 @@ tpu_init(struct tpu *tpu)
tpu->disabled = false;
tpu->mode = MODE_IDLE;
- tpu->idle = true;
+ tpu->idle = false;
tpu->x = 0;
tpu->y = 0;
@@ -565,6 +565,7 @@ tpu_step(struct tpu *tpu)
if (tpu->pc >= tpu->inst_cnt) tpu->pc = 0;
} else {
tpu->mode = MODE_IDLE;
+ tpu->idle = true;
}
}
@@ -672,20 +673,27 @@ tis_step(struct tis *tis)
bool running;
size_t i;
- tis_communicate(tis);
-
for (i = 0; i < TPU_MAP_BUCKETS; i++) {
link = tis->tpu_map.buckets[i];
for (; link; link = link->next)
tpu_step(link->tpu);
}
+ tis_communicate(tis);
+
for (i = 0; i < TPU_MAP_BUCKETS; i++) {
link = tis->tpu_map.buckets[i];
for (; link; link = link->next)
tpu_update(link->tpu);
}
+ for (i = 0; i < TIS_MAX_IO_PORTS; i++) {
+ if (tis->in_ports[i])
+ tpu_port_update(&tis->in_ports[i]->port);
+ if (tis->out_ports[i])
+ tpu_port_update(&tis->out_ports[i]->port);
+ }
+
running = false;
for (i = 0; i < TPU_MAP_BUCKETS; i++) {
link = tis->tpu_map.buckets[i];
@@ -699,13 +707,6 @@ tis_step(struct tis *tis)
}
}
- for (i = 0; i < TIS_MAX_IO_PORTS; i++) {
- if (tis->in_ports[i])
- tpu_port_update(&tis->in_ports[i]->port);
- if (tis->out_ports[i])
- tpu_port_update(&tis->out_ports[i]->port);
- }
-
tis->steps += 1;
return running;