From 7203f8443e5f71b78a406833bb9a6bebf886ac93 Mon Sep 17 00:00:00 2001 From: cancel Date: Fri, 13 Nov 2020 11:44:25 +0900 Subject: [PATCH] Fix J and Y to not grow when held by H An oversight in the implementation of J and Y meant that the chain would grow each frame, if there were at least two segments and the first segment was locked by something like H. Example: H YY This is not what we want. I've added a guard in the J and Y implementations that checks if the glyph above (or for Y, to the left) is an earlier part of the chain, and if it is, to return. This has the downside of making long chains potentially having to enter the J code repeatedly, only to end up doing nothing. The STUN() in J and Y might no longer be worth it. It was used to prevent further operators in the chain from running, but since we have a guard now, the writes while looping might end up costing more time. We don't have any good benchmark files set up right now, so we'll have to test it in the future. --- sim.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sim.c b/sim.c index 191e681..17c2644 100644 --- a/sim.c +++ b/sim.c @@ -498,9 +498,11 @@ END_OPERATOR BEGIN_OPERATOR(jump) LOWERCASE_REQUIRES_BANG; - PORT(-1, 0, IN); Glyph g = PEEK(-1, 0); - for (Isz i = 1;; ++i) { + if (g == This_oper_char) + return; + PORT(-1, 0, IN); + for (Isz i = 1; i <= 256; ++i) { if (PEEK(i, 0) != This_oper_char) { PORT(i, 0, OUT); POKE(i, 0, g); @@ -706,9 +708,11 @@ END_OPERATOR BEGIN_OPERATOR(yump) LOWERCASE_REQUIRES_BANG; - PORT(0, -1, IN); Glyph g = PEEK(0, -1); - for (Isz i = 1;; ++i) { + if (g == This_oper_char) + return; + PORT(0, -1, IN); + for (Isz i = 1; i <= 256; ++i) { if (PEEK(0, i) != This_oper_char) { PORT(0, i, OUT); POKE(0, i, g);