tis100

Reimplementation of Zachtronics TIS-100 as a TUI game
git clone https://git.sinitax.com/sinitax/tis100
Log | Files | Refs | sfeed.txt

commit f2ada47e6be185cc31c475c996c4ccf6735f7bb0
parent 5ff5bb25cc864e7fa06aa8fed0c4ec92e99f103a
Author: Louis Burda <quent.burda@gmail.com>
Date:   Mon, 25 Dec 2023 01:56:01 +0100

fixup! Make mode/state behaviour compatible with game

Diffstat:
Mtest.sh | 1+
Mtis100.c | 4++--
Mtpu.c | 14+++++++++-----
Mtpu.h | 2+-
4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/test.sh b/test.sh @@ -28,3 +28,4 @@ for f in test/*.asm; do [ $bad -ne 0 ] && echo "$f" fi done +: diff --git a/tis100.c b/tis100.c @@ -58,8 +58,8 @@ main(int argc, const char **argv) stats = tis_gen_stats(&tis); printf("=== stats ===\n"); printf(" cycles: %zu\n", stats.steps); - printf(" blocks: %zu\n", stats.blocks); - printf(" insts: %zu\n", stats.blocks); + printf(" nodes: %zu\n", stats.nodes); + printf(" insts: %zu\n", stats.nodes); printf(" idle: %2.1f%%\n", stats.idle * 100); printf("=============\n"); } diff --git a/tpu.c b/tpu.c @@ -386,6 +386,8 @@ tpu_port_write(struct tpu *tpu, enum tpu_port_dir dir, int lit) port->writing = true; port->out = lit; + /* port writing never succeeds right away, only after + * value was read in tpu_update is tpu->idle/mode fixed up */ return true; } @@ -477,10 +479,12 @@ tpu_exec(struct tpu *tpu, struct tpu_inst *inst) return MODE_READ; } } - /* tpu->idle/mode fixed up via tpu->reset_in if value is read */ - if (!tpu_exec_put(tpu, &inst->ops[1], lit)) + if (!tpu_exec_put(tpu, &inst->ops[1], lit)) { tpu->idle = true; - return MODE_WRITE; + return MODE_WRITE; + } + tpu->pc += 1; + return MODE_RUN; case INST_SWP: lit = tpu->acc; tpu->acc = tpu->bak; @@ -751,7 +755,7 @@ tis_gen_stats(struct tis *tis) int i; stats.steps = tis->steps; - stats.blocks = 0; + stats.nodes = 0; stats.insts = 0; stats.idle = 0; @@ -763,7 +767,7 @@ tis_gen_stats(struct tis *tis) stats.insts += link->tpu->inst_cnt; idle_steps += link->tpu->idle_steps; all_steps += link->tpu->steps; - stats.blocks += (link->tpu->inst_cnt > 0); + stats.nodes += (link->tpu->inst_cnt > 0); } } diff --git a/tpu.h b/tpu.h @@ -131,7 +131,7 @@ struct tis { struct tis_stats { size_t steps; - size_t blocks; + size_t nodes; size_t insts; float idle; };