Added NCR1632 embedded bank reset feature

This commit is contained in:
Willem Cazander 2025-01-16 16:06:38 +01:00
parent 62bdf94435
commit aa6f12f336
4 changed files with 56 additions and 15 deletions

View file

@ -304,6 +304,7 @@ public class FourCornerZionStenoLexer {
private void handlePoints(List<Integer> slicedPoints) { private void handlePoints(List<Integer> slicedPoints) {
bankReset(); bankReset();
boolean magicSparkler = true; boolean magicSparkler = true;
boolean requestBankReset = false;
for (Integer cakePoint : slicedPoints) { for (Integer cakePoint : slicedPoints) {
if (cakePoint >= FourCornerDotCake.FC_NCR1632_XD.getStart() && cakePoint <= FourCornerDotCake.FC_NCR1632_XD.getStop()) { if (cakePoint >= FourCornerDotCake.FC_NCR1632_XD.getStart() && cakePoint <= FourCornerDotCake.FC_NCR1632_XD.getStop()) {
int denominatorX = cakePoint - FourCornerDotCake.FC_NCR1632_XD.getStart(); int denominatorX = cakePoint - FourCornerDotCake.FC_NCR1632_XD.getStart();
@ -314,15 +315,29 @@ public class FourCornerZionStenoLexer {
int numeratorX = cakePoint - FourCornerDotCake.FC_NCR1632_XN.getStart(); int numeratorX = cakePoint - FourCornerDotCake.FC_NCR1632_XN.getStart();
numeratorBank[numeratorX / 512] = numeratorX % 512; numeratorBank[numeratorX / 512] = numeratorX % 512;
// highest number, 1st select + enable request, if second than reset bank
if (cakePoint == FourCornerDotCake.FC_NCR1632_XN.getStop()) {
if (requestBankReset) {
requestBankReset = false;
magicSparkler = false; // if EOF ends with bank reset, ignore
fireSignals.fireStateNCR1632BankReset();
bankReset();
continue;
}
requestBankReset = true;
} else {
requestBankReset = false;
}
if (cakePoint > FourCornerDotCake.FC_NCR1632_XN.getStart() + 512) { if (cakePoint > FourCornerDotCake.FC_NCR1632_XN.getStart() + 512) {
magicSparkler = true; magicSparkler = true;
continue; // Only fire fraction on lowest value select continue; // Only fire fraction on lowest value select
} } else
bankFire(); bankFire();
magicSparkler = false; magicSparkler = false;
} }
if (magicSparkler) { if (magicSparkler) {
fireSignals.fireStateNCR1632Sparkler(); fireSignals.fireStateNCR1632BankSparkler();
bankFire(); bankFire();
} }
} }

View file

@ -34,7 +34,9 @@ public interface FourCornerZionStenoLexerFire {
void fireStateScanner(int blockStart, int blockStop, int cakePoint); void fireStateScanner(int blockStart, int blockStop, int cakePoint);
void fireStateNCR1632Sparkler(); void fireStateNCR1632BankSparkler();
void fireStateNCR1632BankReset();
interface Adapter extends FourCornerZionStenoLexerFire { interface Adapter extends FourCornerZionStenoLexerFire {
@ -51,7 +53,11 @@ public interface FourCornerZionStenoLexerFire {
} }
@Override @Override
default void fireStateNCR1632Sparkler() { default void fireStateNCR1632BankSparkler() {
}
@Override
default void fireStateNCR1632BankReset() {
} }
} }
} }

View file

@ -46,22 +46,35 @@ public class LexerNCRTest {
TestFireWalker fireWalker = new TestFireWalker(); TestFireWalker fireWalker = new TestFireWalker();
FourCornerZionStenoLexer lexer = new FourCornerZionStenoLexer(new FourCornerZion7Candlelier.Adapter() {}, true); FourCornerZionStenoLexer lexer = new FourCornerZionStenoLexer(new FourCornerZion7Candlelier.Adapter() {}, true);
lexer.withFireSignals(fireWalker); lexer.withFireSignals(fireWalker);
List<Integer> cdc = new ArrayList<>(); List<Integer> cdc = new ArrayList<>();
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*3) + 1); /// auto NXX_001 cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*3) + 1); /// auto NXX_001
cdc.addAll(FCDotDEC0127DashPX0.ESC_STOP.toInt18BaklavaPoints()); Assertions.assertEquals(0, fireWalker.ncr1632BankSparkler);
Assertions.assertEquals(0, fireWalker.ncrMagicSparks);
lexer.read(cdc); lexer.read(cdc);
Assertions.assertEquals(1, fireWalker.ncrMagicSparks); Assertions.assertEquals(1, fireWalker.ncr1632BankSparkler);
cdc.addAll(FCDotDEC0127DashPX0.ESC_STOP.toInt18BaklavaPoints()); // the print above auto value + next test
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // normal NXX_123 cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // normal NXX_123
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() + (512*4) + 2); /// auto NXX_123 + this cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() + (512*4) + 2); /// auto NXX_123 + this
fireWalker.reset(); fireWalker.reset();
lexer.read(cdc); lexer.read(cdc);
Assertions.assertEquals(2, fireWalker.ncrMagicSparks); Assertions.assertEquals(2, fireWalker.ncr1632BankSparkler);
Assertions.assertEquals("¹/₁₃₄₂₁₇₇₂₉¹²³/₁¹³⁷⁴³⁸⁹⁵³⁵⁹⁵/₁", FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); Assertions.assertEquals(0, fireWalker.ncr1632BankReset);
cdc.addAll(FCDotDEC0127DashPX0.ESC_STOP.toInt18BaklavaPoints()); // the print above auto value + next test (normal bank reset)
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() - 1 + 11);
cdc.add(FourCornerDotCake.FC_NCR1632_XD.getStart() + (512*3) + 12);
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() + (512*4) + 13);
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() + (512*5) + 14);
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart()); // and one which prints
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStop());
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStop()); // embedded bank reset
cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart() - 1 + 123); // normal NXX_123
fireWalker.reset();
lexer.read(cdc);
Assertions.assertEquals(1, fireWalker.ncr1632BankReset);
Assertions.assertEquals("¹/₁₃₄₂₁₇₇₂₉¹²³/₁¹³⁷⁴³⁸⁹⁵³⁵⁹⁵/₁⁴⁹³⁴⁷⁴⁵⁶²⁴⁴¹²¹⁷/₁₆₁₀₆₁₂₇₄₇¹²³/₁", FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
} }
@Test @Test

View file

@ -35,7 +35,8 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter {
int scanBlockStart; int scanBlockStart;
int scanBlockStop; int scanBlockStop;
int scanCakePoint; int scanCakePoint;
int ncrMagicSparks; int ncr1632BankSparkler;
int ncr1632BankReset;
public TestFireWalker() { public TestFireWalker() {
reset(); reset();
@ -45,7 +46,8 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter {
currentLine = 0; currentLine = 0;
currentColumn = 0; currentColumn = 0;
scanBlockStart = 0; scanBlockStart = 0;
ncrMagicSparks = 0; ncr1632BankSparkler = 0;
ncr1632BankReset = 0;
} }
@Override @Override
@ -66,7 +68,12 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter {
} }
@Override @Override
public void fireStateNCR1632Sparkler() { public void fireStateNCR1632BankSparkler() {
ncrMagicSparks++; ncr1632BankSparkler++;
}
@Override
public void fireStateNCR1632BankReset() {
ncr1632BankReset++;
} }
} }