diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerRecipe.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerRecipe.java index 2f03b7c..f3ae205 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerRecipe.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerRecipe.java @@ -24,13 +24,22 @@ package org.x4o.fc18; import java.math.BigInteger; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import java.util.Objects; import java.util.PrimitiveIterator; +import org.x4o.fc18.cake2.FourCornerDotCake; +import org.x4o.fc18.cake2.FourCornerX00PetitVide; +import org.x4o.fc18.cake2.FourCornerX06BaklavaPointSequence; +import org.x4o.fc18.cake2.FourCornerX18CakePointSequence; import org.x4o.fc18.cake2.pie9c.FCDotPIE9CDash10; import org.x4o.fc18.cake2.pie9c.FCDotPIE9CDash11; import org.x4o.fc18.cake2.pie9c.FCDotPIE9CDash20; import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6; +import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0; +import org.x4o.fc18.octal8.PrimordialOctal; +import org.x4o.fc18.zion7.FourCornerZion7SalahSequence; /// Holds different lookup and conversion maps towards four corner int18 cake points. /// @@ -38,9 +47,266 @@ import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6; /// @version 1.0 Jan 09, 2025 final public class FourCornerRecipe { + public static final BigInteger NCR1632_MASK_PAGE = BigInteger.valueOf(0x1FF); + public static final BigInteger NCR1632_VALUE_MAX = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16); + public static final List SAND_WORM_SIGN = List.of(24,48,72,96,120,144,168,192); + private FourCornerRecipe() { } + static public List embedSalahSequenceX06(FourCornerZion7SalahSequence type, List> arguments) { + return embedSalahSequence(new ArrayList<>(), type, arguments, true); + } + + static public List embedSalahSequenceX18(FourCornerZion7SalahSequence type, List> arguments) { + return embedSalahSequence(new ArrayList<>(), type, arguments, false); + } + + static public List embedSalahSequenceX06(List out, FourCornerZion7SalahSequence type, List> arguments) { + return embedSalahSequence(out, type, arguments, true); + } + + static public List embedSalahSequenceX18(List out, FourCornerZion7SalahSequence type, List> arguments) { + return embedSalahSequence(out, type, arguments, false); + } + + static private List embedSalahSequence(List out, FourCornerZion7SalahSequence type, List> arguments, boolean isSixBit) { + Objects.requireNonNull(type); + Objects.requireNonNull(arguments); + if (FourCornerZion7SalahSequence.ESC_VT06.equals(type)) { + if (isSixBit) { + out.addAll(FCDotDEC2701DashPX0.ESC_VT06.baklavaPointSequence()); + } else { + out.addAll(FCDotDEC2701DashPX0.ESC_VT06.cakePointSequence()); + } + } else { + if (isSixBit) { + out.addAll(FCDotDEC2701DashPX0.valueOf(type.ordinal()).baklavaPointSequence()); + } else { + out.addAll(FCDotDEC2701DashPX0.valueOf(type.ordinal()).cakePointSequence()); + } + } + Iterator> argu = arguments.iterator(); + while (argu.hasNext()) { + List arguValue = argu.next(); + out.addAll(arguValue); // TODO: add range check + if (argu.hasNext()) { + out.add(FCDotCDC1604DashP6._RAKA_QUESTION.baklavaPointDotIndex()); + } + } + out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.baklavaPointDotIndex()); + return out; + } + + static public List embedSandWalker(List rhythm) { + return embedSandWalker(new ArrayList<>(), rhythm); + } + + static public List embedSandWalker(List out, List rhythm) { + Objects.requireNonNull(rhythm); + if (!FourCornerRecipe.SAND_WORM_SIGN.contains(rhythm.size())) { + throw new IllegalArgumentException("Sand walker rhythm is not 72 bit aligned: " + rhythm.size()); + } + out.add(FCDotDEC2701DashPX0.ESC_SAND_WALKER.cakePointDotIndex()); + for (int i = 192 - 1; i >= 0; i--) { + if (rhythm.size() <= i) { + continue; + } + PrimordialOctal octal = rhythm.get(i); + out.add(FCDotCDC1604DashP6.NX01_A.cakePointDotIndex() + octal.ordinal()); + } + out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.cakePointDotIndex()); + return out; + } + + static public List embedSandWormX06(List spice) { + return embedSandWormX06(new ArrayList<>(), spice); + } + + static public List embedSandWormX06(List out, List spice) { + Objects.requireNonNull(spice); + out.add(FCDotDEC2701DashPX0.ESC68_SAND_WORM.cakePointDotIndex()); + for (int i = spice.size(); i >= 0; i--) { + PrimordialOctal octal = spice.get(i); + out.add(FCDotCDC1604DashP6.NX01_A.cakePointDotIndex() + octal.ordinal()); + } + out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.cakePointDotIndex()); + return out; + } + + static public List embedSandWormX18(List spice) { + return embedSandWormX18(new ArrayList<>(), spice); + } + + static public List embedSandWormX18(List out, List spice) { + Objects.requireNonNull(spice); + Iterator spiceItr = spice.iterator(); + while (spiceItr.hasNext()) { + PrimordialOctal octal4 = spiceItr.next(); + PrimordialOctal octal3 = spiceItr.next(); + PrimordialOctal octal2 = spiceItr.next(); + PrimordialOctal octal1 = spiceItr.next(); + PrimordialOctal octal0 = spiceItr.next(); + int bitValue15 = 0; + bitValue15 += (octal4.ordinal() << 12); + bitValue15 += (octal3.ordinal() << 9); + bitValue15 += (octal2.ordinal() << 6); + bitValue15 += (octal1.ordinal() << 3); + bitValue15 += (octal0.ordinal() << 0); + out.add(FourCornerDotCake.FC_SANDWORM_15.getStart() + bitValue15); + } + return out; + } + + static public List embedNCR1632FractionX06(BigInteger denominator, BigInteger numerator) { + return embedNCR1632FractionX18(new ArrayList<>(), denominator, numerator); + } + + static public List embedNCR1632FractionX06(List out, BigInteger denominator, BigInteger numerator) { + if (denominator.equals(BigInteger.ZERO)) { + throw new IllegalArgumentException("The denominator value ZERO is not allowed."); + } + if (numerator.equals(BigInteger.ZERO)) { + throw new IllegalArgumentException("The numerator value ZERO is not allowed."); + } + //if (denominator.signum() == -1) { + // // TODO: check if we need one octal for pos/neg/qNaN/sNaN/pos_inf/neg_inf/free/free options + //} + if (denominator.compareTo(NCR1632_VALUE_MAX) > 0) { // fixme: this is still one off... + throw new IllegalArgumentException("Value denominator is larger than 576 bit: " + denominator); + } + if (numerator.compareTo(NCR1632_VALUE_MAX) > 0) { // fixme: this is still one off... + throw new IllegalArgumentException("Value numerator is larger than 576 bit: " + numerator); + } + + out.addAll(FCDotDEC2701DashPX0.ESC68_NCR.baklavaPointSequence()); + // NX01-NX08 are octals + // DEN: NY01 = page MSB, NY02 = page LSB, NY03 = value MSB, NY04 = value CSB, NY05 = value LSB + // NUM: NY06 = page MSB, NY07 = page LSB, NY08 = value MSB, NY09 = value CSB, NY10 = value LSB + + BigInteger denominatorZero = denominator.subtract(BigInteger.ONE); + BigInteger numeratorZero = numerator.subtract(BigInteger.ONE); + if (denominatorZero.equals(BigInteger.ZERO)) { + out.add(FCDotCDC1604DashP6.NY05_BAR_VERTICAL.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex()); + } else { + for (int i = 63; i >= 0; i--) { + int bankValue = denominatorZero.shiftRight(i * 9).and(NCR1632_MASK_PAGE).intValue(); + if (bankValue == 0) { + continue; + } + int pageMSB = (i >> 3) & 0b111; + int pageLSB = (i >> 0) & 0b111; + int valueMSB = (bankValue >> 6) & 0b111; + int valueCSB = (bankValue >> 3) & 0b111; + int valueLSB = (bankValue >> 0) & 0b111; + if (pageMSB > 0) { + out.add(FCDotCDC1604DashP6.NY01_AT.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + pageMSB); + } + if (pageLSB > 0) { + out.add(FCDotCDC1604DashP6.NY02_BAR_V_RIGHT.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + pageLSB); + } + if (valueMSB > 0) { + out.add(FCDotCDC1604DashP6.NY03_BAR_V_LEFT.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueMSB); + } + if (valueCSB > 0) { + out.add(FCDotCDC1604DashP6.NY04_BAR_UNDER.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueCSB); + } + out.add(FCDotCDC1604DashP6.NY05_BAR_VERTICAL.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueLSB); + } + } + if (numeratorZero.equals(BigInteger.ZERO)) { + out.add(FCDotCDC1604DashP6.NY10_CARET.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex()); + } else { + for (int i = 63; i >= 0; i--) { + int bankValue = numeratorZero.shiftRight(i * 9).and(NCR1632_MASK_PAGE).intValue(); + if (bankValue == 0) { + continue; + } + int pageMSB = (i >> 3) & 0b111; + int pageLSB = (i >> 0) & 0b111; + int valueMSB = (bankValue >> 6) & 0b111; + int valueCSB = (bankValue >> 3) & 0b111; + int valueLSB = (bankValue >> 0) & 0b111; + if (pageMSB > 0) { + out.add(FCDotCDC1604DashP6.NY06_PERCENT.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + pageMSB); + } + if (pageLSB > 0) { + out.add(FCDotCDC1604DashP6.NY07_DOLLAR.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + pageLSB); + } + if (valueMSB > 0) { + out.add(FCDotCDC1604DashP6.NY08_HASH.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueMSB); + } + if (valueCSB > 0) { + out.add(FCDotCDC1604DashP6.NY09_EQUALS.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueCSB); + } + out.add(FCDotCDC1604DashP6.NY10_CARET.baklavaPointDotIndex()); + out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueLSB); + } + } + out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.cakePointDotIndex()); + return out; + } + + static public List embedNCR1632FractionX18(BigInteger denominator, BigInteger numerator) { + return embedNCR1632FractionX18(new ArrayList<>(), denominator, numerator); + } + + static public List embedNCR1632FractionX18(List out, BigInteger denominator, BigInteger numerator) { + if (denominator.equals(BigInteger.ZERO)) { + throw new IllegalArgumentException("The denominator value ZERO is not allowed."); + } + if (numerator.equals(BigInteger.ZERO)) { + throw new IllegalArgumentException("The numerator value ZERO is not allowed."); + } + //if (denominator.signum() == -1) { + // // TODO: check if we need one octal for pos/neg/qNaN/sNaN/pos_inf/neg_inf/free/free options + //} + if (denominator.compareTo(NCR1632_VALUE_MAX) > 0) { // fixme: this is still one off... + throw new IllegalArgumentException("Value denominator is larger than 576 bit: " + denominator); + } + if (numerator.compareTo(NCR1632_VALUE_MAX) > 0) { // fixme: this is still one off... + throw new IllegalArgumentException("Value numerator is larger than 576 bit: " + numerator); + } + BigInteger denominatorZero = denominator.subtract(BigInteger.ONE); + BigInteger numeratorZero = numerator.subtract(BigInteger.ONE); + if (denominatorZero.equals(BigInteger.ZERO)) { + out.add(FourCornerDotCake.FC_NCR1632_DEN.getStart()); + } else { + for (int i = 63; i >= 0; i--) { + int bankValue = denominatorZero.shiftRight(i * 9).and(NCR1632_MASK_PAGE).intValue(); + if (bankValue == 0) { + continue; + } + int cakePoint = FourCornerDotCake.FC_NCR1632_DEN.getStart() + bankValue + (i * 512); + out.add(cakePoint); + } + } + if (numeratorZero.equals(BigInteger.ZERO)) { + out.add(FourCornerDotCake.FC_NCR1632_NUM.getStart()); + } else { + for (int i = 63; i >= 0; i--) { + int bankValue = numeratorZero.shiftRight(i * 9).and(NCR1632_MASK_PAGE).intValue(); + if (bankValue == 0) { + continue; + } + int cakePoint = FourCornerDotCake.FC_NCR1632_NUM.getStart() + bankValue + (i * 512); + out.add(cakePoint); + } + } + return out; + } + static public List toScriptSuperX06(int value) { return toScript(new ArrayList<>(), Integer.toString(value), 0, true); } @@ -176,10 +442,9 @@ final public class FourCornerRecipe { } } } - // fixme - //if (isSixBit) { - // out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.cakePointDotIndex()); // fixme improve: see FourCornerDotCollePie9.baklavaPointsPIE9C - //} + if (isSixBit) { + out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.cakePointDotIndex()); // fixme improve: see FourCornerDotCollePie9.baklavaPointsPIE9C + } return out; } } diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java index 8d3b25b..23f1d99 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java @@ -135,7 +135,7 @@ public class FourCornerUnicodeDisplay { lexer.withSmokeSignals(printer).read(chars); } - private final class StenoUnicodePrinter implements FourCornerZion7Candlelier.Adapter, FourCornerZionStenoLexerSmoke.AdapterMonoPipe { + private final class StenoUnicodePrinter implements FourCornerZion7Candlelier, FourCornerZionStenoLexerSmoke.AdapterMonoPipe { private final StringBuilder output; private boolean wasExternalWord = false; @@ -237,7 +237,7 @@ public class FourCornerUnicodeDisplay { } @Override - public void strobeNCR1632(BigInteger numerator, BigInteger denominator) { + public void strobeNCR1632(BigInteger denominator, BigInteger numerator) { List math = new ArrayList<>(); FourCornerRecipe.toScriptSuperX18(math, numerator); math.add(FCDotCDC1604DashP6.NY02_BAR_V_RIGHT.ordinal()); diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/zero33/dec1/FCDotDEC2701DashPX0.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/zero33/dec1/FCDotDEC2701DashPX0.java index 5b87e00..c57bae5 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/zero33/dec1/FCDotDEC2701DashPX0.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/zero33/dec1/FCDotDEC2701DashPX0.java @@ -69,16 +69,6 @@ public enum FCDotDEC2701DashPX0 implements FourCornerX06BaklavaPointSequence, Fo __ESC_RESERVED_A8, /// _ESC6_X1 _ESC6_X3 _ESC6_X3 = 9 - /// Content type prolog 8 doctype modes of document - /// * 6 bit pure mainframe mode - /// * 6 bit with vt06+candy - /// * 6 bit with vt06+candy+NCR+grams - /// * 6 bit with vt06+candy+NCR+grams+worms - /// * 18 bit only xdbx strict adult structure - /// * 18 bit only xdbx sweaty candy structure - /// * 18 bit simple adult mode (no xdbx, no worms) - /// * 18 bit full range (default, no limits on cake points used) - //ESC_PROLOG_DOCTYPE __ESC_RESERVED_A9, // =========== Internal escape sequence, to embed symbols,fractions and adult texts. @@ -126,8 +116,8 @@ public enum FCDotDEC2701DashPX0 implements FourCornerX06BaklavaPointSequence, Fo /// _ESC6_X2 _ESC6_X3 _ESC6_X2 = 17 /// Select packed new counting rods fraction for 6 and 8 bit systems. /// NX01-NX08 are octal values - /// NUM: NY01 = page MSB, NY02 = page LSB, NY03 = value MSB, NY04 = value CSB, NY05 = value LSB - /// DEN: NY06 = page MSB, NY07 = page LSB, NY08 = value MSB, NY09 = value CSB, NY10 = value LSB + /// DEN: NY01 = page MSB, NY02 = page LSB, NY03 = value MSB, NY04 = value CSB, NY05 = value LSB + /// NUM: NY06 = page MSB, NY07 = page LSB, NY08 = value MSB, NY09 = value CSB, NY10 = value LSB /// and and and must end with ! ESC68_NCR, diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7AlphaOmega.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7AlphaOmega.java index 1add7a1..3a93c6e 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7AlphaOmega.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7AlphaOmega.java @@ -26,13 +26,13 @@ package org.x4o.fc18.zion7; /// /// @author Willem Cazander /// @version 1.0 Jan 11, 2025 -public interface FourCornerZion7AlphaOmega { +public interface FourCornerZion7AlphaOmega extends FourCornerZion7Candlelier { void strobeDocumentAlpha(); void strobeDocumentOmega(); - interface Adapter extends FourCornerZion7AlphaOmega { + interface Adapter extends FourCornerZion7AlphaOmega, FourCornerZion7Candlelier.Adapter { @Override default void strobeDocumentAlpha() { diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Candlelier.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Candlelier.java index f462624..7d7606e 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Candlelier.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Candlelier.java @@ -31,7 +31,7 @@ import org.x4o.fc18.octal8.PrimordialOctal; /// /// @author Willem Cazander /// @version 1.0 Jan 09, 2025 -public interface FourCornerZion7Candlelier extends FourCornerZion7AlphaOmega { +public interface FourCornerZion7Candlelier { /// Single word cake point. void strobeWord(int cakePoint); @@ -39,12 +39,8 @@ public interface FourCornerZion7Candlelier extends FourCornerZion7AlphaOmega { /// Block of word cake points. void strobeWords(List cakePoints); - //void strobeWordGrams(int gramBase, List values); - //void strobeWordDozimal(BigDecimal value); - //void strobeWordDozeger(BigInteger value); // up to 192 bit integer - /// 1152 bit fractions of two 576 bit numbers. - void strobeNCR1632(BigInteger numerator, BigInteger denominator); + void strobeNCR1632(BigInteger denominator, BigInteger numerator); /// Octal sand walker, with an 72 to 576 bit mime-type rhythm header. void strobeSandWalker(List rhythm); @@ -55,7 +51,7 @@ public interface FourCornerZion7Candlelier extends FourCornerZion7AlphaOmega { /// Handles the lexer salah sequence strobes void strobeSalahSequence(FourCornerZion7SalahSequence type, List> arguments); - interface Adapter extends FourCornerZion7Candlelier, FourCornerZion7AlphaOmega.Adapter { + interface Adapter extends FourCornerZion7Candlelier { @Override default void strobeWord(int cakePoint) { @@ -66,7 +62,7 @@ public interface FourCornerZion7Candlelier extends FourCornerZion7AlphaOmega { } @Override - default void strobeNCR1632(BigInteger numerator, BigInteger denominator) { + default void strobeNCR1632(BigInteger denominator, BigInteger numerator) { } @Override diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Petroglyphs.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Petroglyphs.java deleted file mode 100644 index b6ec672..0000000 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZion7Petroglyphs.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2004-2014, Willem Cazander - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.x4o.fc18.zion7; - -import java.math.BigInteger; -import java.util.List; - -/// Rock carvings of special variables. -/// -/// @author Willem Cazander -/// @version 1.0 Aug 24, 2025 -public final class FourCornerZion7Petroglyphs { - - public static final BigInteger NCR1632_MASK_PAGE = BigInteger.valueOf(0x1FF); - public static final BigInteger NCR1632_VALUE_MAX = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16); - public static final List SAND_WORM_SIGN = List.of(24,48,72,96,120,144,168,192); - - private FourCornerZion7Petroglyphs() { - } -} diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoGrapher.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoGrapher.java index 5863e50..5ac588c 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoGrapher.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoGrapher.java @@ -23,13 +23,10 @@ package org.x4o.fc18.zion7; import java.math.BigInteger; -import java.util.Iterator; import java.util.List; import java.util.Objects; -import org.x4o.fc18.cake2.FourCornerDotCake; -import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6; -import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0; +import org.x4o.fc18.FourCornerRecipe; import org.x4o.fc18.octal8.PrimordialOctal; import org.x4o.fc18.octal8.PrimordialOctalOrangeJuice; @@ -39,15 +36,15 @@ import org.x4o.fc18.octal8.PrimordialOctalOrangeJuice; /// @version 1.0 Jan 11, 2025 public class FourCornerZionStenoGrapher { - static public FourCornerZion7Candlelier writerX06(List out) { + static public FourCornerWriter writerX06(List out) { return new FourCornerWriter(out, true); } - static public FourCornerZion7TempleScrolls writerX18(List out) { + static public FourCornerWriter writerX18(List out) { return new FourCornerWriter(out, false); } - - static public final class FourCornerWriter implements FourCornerZion7Candlelier,FourCornerZion7TempleScrolls { + + static public final class FourCornerWriter implements FourCornerZion7AlphaOmega,FourCornerZion7TempleScrolls { private final List out; private final boolean isSixBit; @@ -78,7 +75,6 @@ public class FourCornerZionStenoGrapher { @Override public void strobeWords(List cakePoints) { - Objects.requireNonNull(cakePoints); int cakeSize = cakePoints.size(); for (int i = 0; i < cakeSize; i++) { strobeWord(cakePoints.get(i)); @@ -86,180 +82,37 @@ public class FourCornerZionStenoGrapher { } @Override - public void strobeNCR1632(BigInteger numerator, BigInteger denominator) { - Objects.requireNonNull(numerator); - Objects.requireNonNull(denominator); - if (denominator.equals(BigInteger.ZERO)) { // 0/1 = zero but 1/0 is NaN - throw new IllegalArgumentException("The denominator value ZERO is not allowed."); - } - //if (denominator.signum() == -1) { - // // TODO: check if we need one octal for pos/neg/qNaN/sNaN/pos_inf/neg_inf/free/free options - //} - if (numerator.compareTo(FourCornerZion7Petroglyphs.NCR1632_VALUE_MAX) > 0) { - throw new IllegalArgumentException("Value numerator is larger than 576 bit: " + numerator); - } - if (denominator.compareTo(FourCornerZion7Petroglyphs.NCR1632_VALUE_MAX) > 0) { - throw new IllegalArgumentException("Value denominator is larger than 576 bit: " + denominator); - } - + public void strobeNCR1632(BigInteger denominator, BigInteger numerator) { if (isSixBit) { - out.addAll(FCDotDEC2701DashPX0.ESC68_NCR.baklavaPointSequence()); - for (int i = 63; i >= 0; i--) { - int bankValue = numerator.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); - if (bankValue == 0 && i > 0) { - continue; - } - int pageMSB = (i >> 3) & 0b111; - int pageLSB = (i >> 0) & 0b111; - int valueMSB = (bankValue >> 6) & 0b111; - int valueCSB = (bankValue >> 3) & 0b111; - int valueLSB = (bankValue >> 0) & 0b111; - if (pageMSB > 0) { - out.add(FCDotCDC1604DashP6.NY01_AT.baklavaPointDotIndex()); - out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + pageMSB); - } - if (pageLSB > 0) { - out.add(FCDotCDC1604DashP6.NY02_BAR_V_RIGHT.baklavaPointDotIndex()); - out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + pageLSB); - } - if (valueMSB > 0) { - out.add(FCDotCDC1604DashP6.NY03_BAR_V_LEFT.baklavaPointDotIndex()); - out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueMSB); - } - if (valueCSB > 0) { - out.add(FCDotCDC1604DashP6.NY04_BAR_UNDER.baklavaPointDotIndex()); - out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueCSB); - } - out.add(FCDotCDC1604DashP6.NY05_BAR_VERTICAL.baklavaPointDotIndex()); - out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueLSB); - } - for (int i = 63; i >= 0; i--) { - int bankValue = denominator.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); - if (bankValue == 0 && i > 0) { - continue; - } - int pageMSB = (i >> 3) & 0b111; - int pageLSB = (i >> 0) & 0b111; - int valueMSB = (bankValue >> 6) & 0b111; - int valueCSB = (bankValue >> 3) & 0b111; - int valueLSB = (bankValue >> 0) & 0b111; - if (pageMSB > 0) { - out.add(FCDotCDC1604DashP6.NY06_PERCENT.baklavaPointDotIndex()); - out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + pageMSB); - } - if (pageLSB > 0) { - out.add(FCDotCDC1604DashP6.NY07_DOLLAR.baklavaPointDotIndex()); - out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + pageLSB); - } - if (valueMSB > 0) { - out.add(FCDotCDC1604DashP6.NY08_HASH.baklavaPointDotIndex()); - out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueMSB); - } - if (valueCSB > 0) { - out.add(FCDotCDC1604DashP6.NY09_EQUALS.baklavaPointDotIndex()); - out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueCSB); - } - out.add(FCDotCDC1604DashP6.NY10_CARET.baklavaPointDotIndex()); - out.add(FCDotCDC1604DashP6.NX01_A.baklavaPointDotIndex() + valueLSB); - } - out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.cakePointDotIndex()); - return; - } - for (int i = 63; i >= 0; i--) { - int bankValue = numerator.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); - if (bankValue == 0 && i > 0) { - continue; - } - int cakePoint = FourCornerDotCake.FC_NCR1632_NUM.getStart() + bankValue + (i * 512); - out.add(cakePoint); - } - for (int i = 63; i >= 0; i--) { - int bankValue = denominator.shiftRight(i * 9).and(FourCornerZion7Petroglyphs.NCR1632_MASK_PAGE).intValue(); - if (bankValue == 0 && i > 0) { - continue; - } - int cakePoint = FourCornerDotCake.FC_NCR1632_DEN.getStart() + bankValue + (i * 512); - out.add(cakePoint); + FourCornerRecipe.embedNCR1632FractionX06(out, denominator, numerator); + } else { + FourCornerRecipe.embedNCR1632FractionX18(out, denominator, numerator); } } @Override public void strobeSandWalker(List rhythm) { - Objects.requireNonNull(rhythm); - //if (isSixBit) { - if (!FourCornerZion7Petroglyphs.SAND_WORM_SIGN.contains(rhythm.size())) { - throw new IllegalArgumentException("Sand walker rhythm is not 72 bit aligned: " + rhythm.size()); - } - out.add(FCDotDEC2701DashPX0.ESC_SAND_WALKER.cakePointDotIndex()); - for (int i = 192 - 1; i >= 0; i--) { - if (rhythm.size() <= i) { - continue; - } - PrimordialOctal octal = rhythm.get(i); - out.add(FCDotCDC1604DashP6.NX01_A.cakePointDotIndex() + octal.ordinal()); - } - out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.cakePointDotIndex()); - return; - //} - // todo bring back native 18 bit sand walking if space allow (for adult rule) + FourCornerRecipe.embedSandWalker(out, rhythm); } @Override public void strobeSandWorm(List spice) { - Objects.requireNonNull(spice); if (isSixBit) { - out.add(FCDotDEC2701DashPX0.ESC68_SAND_WORM.cakePointDotIndex()); - for (int i = spice.size(); i >= 0; i--) { - PrimordialOctal octal = spice.get(i); - out.add(FCDotCDC1604DashP6.NX01_A.cakePointDotIndex() + octal.ordinal()); - } - out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.cakePointDotIndex()); - return; - } - Iterator spiceItr = spice.iterator(); - while (spiceItr.hasNext()) { - PrimordialOctal octal4 = spiceItr.next(); - PrimordialOctal octal3 = spiceItr.next(); - PrimordialOctal octal2 = spiceItr.next(); - PrimordialOctal octal1 = spiceItr.next(); - PrimordialOctal octal0 = spiceItr.next(); - int bitValue15 = 0; - bitValue15 += (octal4.ordinal() << 12); - bitValue15 += (octal3.ordinal() << 9); - bitValue15 += (octal2.ordinal() << 6); - bitValue15 += (octal1.ordinal() << 3); - bitValue15 += (octal0.ordinal() << 0); - out.add(FourCornerDotCake.FC_SANDWORM_15.getStart() + bitValue15); + FourCornerRecipe.embedSandWormX06(out, spice); + } else { + FourCornerRecipe.embedSandWormX18(out, spice); } } @Override public void strobeSalahSequence(FourCornerZion7SalahSequence type, List> arguments) { - Objects.requireNonNull(type); - Objects.requireNonNull(arguments); - if (FourCornerZion7SalahSequence.ESC_VT06.equals(type)) { - if (isSixBit) { - out.addAll(FCDotDEC2701DashPX0.ESC_VT06.baklavaPointSequence()); - } else { - out.addAll(FCDotDEC2701DashPX0.ESC_VT06.cakePointSequence()); - } + if (isSixBit) { + FourCornerRecipe.embedSalahSequenceX06(out, type, arguments); } else { - if (isSixBit) { - out.addAll(FCDotDEC2701DashPX0.valueOf(type.ordinal()).baklavaPointSequence()); - } else { - out.addAll(FCDotDEC2701DashPX0.valueOf(type.ordinal()).cakePointSequence()); - } + FourCornerRecipe.embedSalahSequenceX18(out, type, arguments); } - Iterator> argu = arguments.iterator(); - while (argu.hasNext()) { - List arguValue = argu.next(); - out.addAll(arguValue); // TODO: add range check - if (argu.hasNext()) { - out.add(FCDotCDC1604DashP6._RAKA_QUESTION.baklavaPointDotIndex()); - } - } - out.add(FCDotCDC1604DashP6._SALAH_EXCLAMATION.baklavaPointDotIndex()); } + } } \ No newline at end of file diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java index 02fbac5..e968f99 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/zion7/FourCornerZionStenoLexer.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; +import org.x4o.fc18.FourCornerRecipe; import org.x4o.fc18.cake2.FourCornerDotCake; import org.x4o.fc18.cake2.flag4.FCDotF4TTY0001DashNL; import org.x4o.fc18.cake2.flag4.FCDotF4TXT0001DashSP; @@ -45,14 +46,16 @@ import org.x4o.fc18.octal8.PrimordialOctal; /// @version 1.0 Jan 09, 2025 public class FourCornerZionStenoLexer { + private final static FourCornerZion7AlphaOmega CLEAN_BIBLE = new FourCornerZion7AlphaOmega.Adapter() {}; private final static FourCornerZionStenoLexerFire CLEAN_FIRE = new FourCornerZionStenoLexerFire.Adapter() {}; private final static FourCornerZionStenoLexerSmoke CLEAN_SMOKE = new FourCornerZionStenoLexerSmoke.Adapter() {}; private final static List CAKE_SLICE_EATERS = new ArrayList<>(); private final boolean handlerEscape; private final FourCornerZion7Candlelier handler; + private final FourCornerZion7AlphaOmega handlerDocument; private final FourCornerZion7TempleScrolls handlerTempleScrolls; - private final int numeratorBank[] = new int[64]; // <== is the terminator select are 6 bit of banks with 9 bit of values. - private final int denominatorBank[] = new int[numeratorBank.length]; + private final int denominatorBank[] = new int[64]; // <== is the terminator select are 6 bit of banks with 9 bit of values. + private final int numeratorBank[] = new int[denominatorBank.length]; private List input; private int inputIndex = 0; private int currLine = 0; @@ -65,10 +68,10 @@ public class FourCornerZionStenoLexer { private int cdcDECModePie = 0; private Boolean cdcDECModePieAlt = null; private int cdcDECModeNCR68Select = 0; - private int cdcDECModeNCR68NumPage = 0; - private int cdcDECModeNCR68NumValue = 0; private int cdcDECModeNCR68DenPage = 0; private int cdcDECModeNCR68DenValue = 0; + private int cdcDECModeNCR68NumPage = 0; + private int cdcDECModeNCR68NumValue = 0; private FourCornerZionStenoLexerSmoke smokeSignals = CLEAN_SMOKE; private FourCornerZionStenoLexerFire fireSignals = CLEAN_FIRE; @@ -107,6 +110,11 @@ public class FourCornerZionStenoLexer { public FourCornerZionStenoLexer(FourCornerZion7Candlelier handler, boolean handlerEscape) { this.handler = Objects.requireNonNull(handler); this.handlerEscape = handlerEscape; + if (handler instanceof FourCornerZion7AlphaOmega) { + this.handlerDocument = FourCornerZion7AlphaOmega.class.cast(handler); + } else { + this.handlerDocument = CLEAN_BIBLE; + } if (handler instanceof FourCornerZion7TempleScrolls) { this.handlerTempleScrolls = FourCornerZion7TempleScrolls.class.cast(handler); } else { @@ -143,7 +151,7 @@ public class FourCornerZionStenoLexer { currLine = 0; currCol = 0; // allow reuse of lexer decModeReset(); - handler.strobeDocumentAlpha(); + handlerDocument.strobeDocumentAlpha(); do { ScanResult run = readTokens(); if (run.isEOF()) { @@ -153,7 +161,7 @@ public class FourCornerZionStenoLexer { smokeSignals.burnLexerReservedCakePoint(currLine, currCol, input.get(inputIndex)); } } while (safeNext()); - handler.strobeDocumentOmega(); + handlerDocument.strobeDocumentOmega(); } private ScanResult readTokens() { @@ -189,17 +197,19 @@ public class FourCornerZionStenoLexer { } private void ncrBankFire() { - BigInteger numerator = BigInteger.ZERO; - BigInteger denominator = BigInteger.ZERO; - for (int i = 0; i < numeratorBank.length; i++) { - numerator = numerator.add(BigInteger.valueOf(numeratorBank[i]).shiftLeft(i * 9)); + BigInteger denominator = BigInteger.ONE; + for (int i = 0; i < denominatorBank.length; i++) { denominator = denominator.add(BigInteger.valueOf(denominatorBank[i]).shiftLeft(i * 9)); } - handler.strobeNCR1632(numerator, denominator); - // reset the bank after each fire + BigInteger numerator = BigInteger.ONE; for (int i = 0; i < numeratorBank.length; i++) { - numeratorBank[i] = 0; + numerator = numerator.add(BigInteger.valueOf(numeratorBank[i]).shiftLeft(i * 9)); + } + handler.strobeNCR1632(denominator, numerator); + // reset the bank after each fire + for (int i = 0; i < denominatorBank.length; i++) { denominatorBank[i] = 0; + numeratorBank[i] = 0; } } @@ -210,10 +220,10 @@ public class FourCornerZionStenoLexer { cdcDECModePie = 0; cdcDECModePieAlt = null; cdcDECModeNCR68Select = 0; - cdcDECModeNCR68NumPage = 0; - cdcDECModeNCR68NumValue = 0; cdcDECModeNCR68DenPage = 0; cdcDECModeNCR68DenValue = 0; + cdcDECModeNCR68NumPage = 0; + cdcDECModeNCR68NumValue = 0; } abstract static private class StenoScanner { @@ -330,7 +340,7 @@ public class FourCornerZionStenoLexer { static class StenoScannerNCR18 extends StenoScanner { - static private final int CAKEPOINT_BANK0_END = FourCornerDotCake.FC_NCR1632_DEN.getStart() + 512; + static private final int CAKEPOINT_BANK0_END = FourCornerDotCake.FC_NCR1632_NUM.getStart() + 512; public StenoScannerNCR18() { super(FourCornerDotCake.FC_NCR1632_DEN.getStart(), FourCornerDotCake.FC_NCR1632_NUM.getStop()); @@ -341,14 +351,14 @@ public class FourCornerZionStenoLexer { boolean missingSparkler = true; for (int i = idxFirst; i <= idxLast; i++) { int cakePoint = lexer.input.get(i); - if (cakePoint >= FourCornerDotCake.FC_NCR1632_NUM.getStart() && cakePoint <= FourCornerDotCake.FC_NCR1632_NUM.getStop()) { - int numeratorX = cakePoint - FourCornerDotCake.FC_NCR1632_NUM.getStart(); - lexer.numeratorBank[numeratorX / 512] = numeratorX % 512; + if (cakePoint >= FourCornerDotCake.FC_NCR1632_DEN.getStart() && cakePoint <= FourCornerDotCake.FC_NCR1632_DEN.getStop()) { + int denominatorX = cakePoint - FourCornerDotCake.FC_NCR1632_DEN.getStart(); + lexer.denominatorBank[denominatorX / 512] = denominatorX % 512; missingSparkler = true; continue; } - int denominatorX = cakePoint - FourCornerDotCake.FC_NCR1632_DEN.getStart(); - lexer.denominatorBank[denominatorX / 512] = denominatorX % 512; + int numeratorX = cakePoint - FourCornerDotCake.FC_NCR1632_NUM.getStart(); + lexer.numeratorBank[numeratorX / 512] = numeratorX % 512; if (cakePoint > CAKEPOINT_BANK0_END) { missingSparkler = true; @@ -640,6 +650,10 @@ public class FourCornerZionStenoLexer { private boolean handleNCR(FourCornerZionStenoLexer lexer) { int cdcPoint = lexer.input.get(lexer.cdcDECScanIndex); + // NX01-NX08 are octals + // DEN: NY01 = page MSB, NY02 = page LSB, NY03 = value MSB, NY04 = value CSB, NY05 = value LSB + // NUM: NY06 = page MSB, NY07 = page LSB, NY08 = value MSB, NY09 = value CSB, NY10 = value LSB + if (cdcPoint == FCDotCDC1604DashP6._SALAH_EXCLAMATION.ordinal() || cdcPoint == FCDotCDC1604DashP6._RAKA_QUESTION.ordinal()) { lexer.decModeReset(); return true; // eat salah and end mode @@ -661,52 +675,50 @@ public class FourCornerZionStenoLexer { return false; // print char } if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY01_AT.ordinal()) { - lexer.cdcDECModeNCR68NumPage = (octalValue << 3) + (lexer.cdcDECModeNCR68NumPage & 0b000111); + lexer.cdcDECModeNCR68DenPage = (octalValue << 3) + (lexer.cdcDECModeNCR68DenPage & 0b111); return true; } if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY02_BAR_V_RIGHT.ordinal()) { - lexer.cdcDECModeNCR68NumPage = (octalValue << 0) + (lexer.cdcDECModeNCR68NumPage & 0b111000); + lexer.cdcDECModeNCR68DenPage = (lexer.cdcDECModeNCR68DenPage & 0b111000) + octalValue; return true; } if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY03_BAR_V_LEFT.ordinal()) { - lexer.cdcDECModeNCR68NumValue = (octalValue << 6) + (lexer.cdcDECModeNCR68NumValue & 0b000111111); + lexer.cdcDECModeNCR68DenValue = (octalValue << 6) + (lexer.cdcDECModeNCR68DenValue & 0b111111); return true; } if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY04_BAR_UNDER.ordinal()) { - lexer.cdcDECModeNCR68NumValue = (octalValue << 3) + (lexer.cdcDECModeNCR68NumValue & 0b111000111); - return true; - } - if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY05_BAR_VERTICAL.ordinal()) { - lexer.cdcDECModeNCR68NumValue = (octalValue << 0) + (lexer.cdcDECModeNCR68NumValue & 0b111111000); - lexer.numeratorBank[lexer.cdcDECModeNCR68NumPage] = lexer.cdcDECModeNCR68NumValue; - lexer.cdcDECModeNCR68NumPage = 0; - lexer.cdcDECModeNCR68NumValue = 0; - return true; - } - if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY06_PERCENT.ordinal()) { - lexer.cdcDECModeNCR68DenPage = (octalValue << 3) + (lexer.cdcDECModeNCR68DenPage & 0b000111); - return true; - } - if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY07_DOLLAR.ordinal()) { - lexer.cdcDECModeNCR68DenPage = (octalValue << 0) + (lexer.cdcDECModeNCR68DenPage & 0b111000); - return true; - } - if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY08_HASH.ordinal()) { - lexer.cdcDECModeNCR68DenValue = (octalValue << 6) + (lexer.cdcDECModeNCR68DenValue & 0b000111111); - return true; - } - if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY09_EQUALS.ordinal()) { lexer.cdcDECModeNCR68DenValue = (octalValue << 3) + (lexer.cdcDECModeNCR68DenValue & 0b111000111); return true; } - if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY10_CARET.ordinal()) { - lexer.cdcDECModeNCR68DenValue = (octalValue << 0) + (lexer.cdcDECModeNCR68DenValue & 0b111111000); + if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY05_BAR_VERTICAL.ordinal()) { + lexer.cdcDECModeNCR68DenValue = (lexer.cdcDECModeNCR68DenValue & 0b111111000) + octalValue; lexer.denominatorBank[lexer.cdcDECModeNCR68DenPage] = lexer.cdcDECModeNCR68DenValue; - if (lexer.cdcDECModeNCR68DenPage == 0) { - lexer.ncrBankFire(); - } lexer.cdcDECModeNCR68DenPage = 0; lexer.cdcDECModeNCR68DenValue = 0; + return true; + } + if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY06_PERCENT.ordinal()) { + lexer.cdcDECModeNCR68NumPage = (octalValue << 3) + (lexer.cdcDECModeNCR68NumPage & 0b111); + return true; + } + if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY07_DOLLAR.ordinal()) { + lexer.cdcDECModeNCR68NumPage = (lexer.cdcDECModeNCR68NumPage & 0b111000) + octalValue; + return true; + } + if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY08_HASH.ordinal()) { + lexer.cdcDECModeNCR68NumValue = (octalValue << 6) + (lexer.cdcDECModeNCR68NumValue & 0b111111); + return true; + } + if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY09_EQUALS.ordinal()) { + lexer.cdcDECModeNCR68NumValue = (octalValue << 3) + (lexer.cdcDECModeNCR68NumValue & 0b111000111); + return true; + } + if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY10_CARET.ordinal()) { + lexer.cdcDECModeNCR68NumValue = (lexer.cdcDECModeNCR68NumValue & 0b111111000) + octalValue; + lexer.numeratorBank[lexer.cdcDECModeNCR68NumPage] = lexer.cdcDECModeNCR68NumValue; + lexer.cdcDECModeNCR68NumPage = 0; + lexer.cdcDECModeNCR68NumValue = 0; + lexer.ncrBankFire(); } return true; } @@ -759,7 +771,7 @@ public class FourCornerZionStenoLexer { return true; } if (FCDotCDC1604DashP6._SALAH_EXCLAMATION.ordinal() == cdcPoint) { - if (!FourCornerZion7Petroglyphs.SAND_WORM_SIGN.contains(rhythm.size())) { + if (!FourCornerRecipe.SAND_WORM_SIGN.contains(rhythm.size())) { lexer.smokeSignals.burnSandWalkerStepUnaligned(lexer.currLine, lexer.currCol, cdcPoint); } else { lexer.handler.strobeSandWalker(rhythm); diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/FourCornerRecipeTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/FourCornerRecipeTest.java index ea56238..b656884 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/FourCornerRecipeTest.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/FourCornerRecipeTest.java @@ -22,6 +22,14 @@ */ package org.x4o.fc18; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.x4o.fc18.octal8.PrimordialOctal; + /** * Tests FourCornerRecipe methods. * @@ -30,4 +38,73 @@ package org.x4o.fc18; */ public class FourCornerRecipeTest { + @Test + public void testSandWalker() throws Exception { + List cdc = new ArrayList<>(); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + FourCornerRecipe.embedSandWalker(cdc, List.of(PrimordialOctal.PART_1)); + }); + List octalMine = new ArrayList<>(); + for (int i=0;i<24;i++) { + octalMine.add(PrimordialOctal.PART_1); + } + FourCornerRecipe.embedSandWalker(cdc, octalMine); + String res = FourCornerUnicodeDisplay.text().renderFromInt18(cdc); + Assertions.assertTrue(res.endsWith("PART_1PART_1"), "missing " + res); + } + + @Test + public void testNCRValues() throws Exception { + List cdcX06 = new ArrayList<>(); + List cdcX18 = new ArrayList<>(); + BigInteger v1 = BigInteger.valueOf(123); + FourCornerRecipe.embedNCR1632FractionX06(cdcX06, v1, BigInteger.ONE); + FourCornerRecipe.embedNCR1632FractionX18(cdcX18, v1, BigInteger.ONE); + BigInteger v2 = BigInteger.valueOf(12345); + FourCornerRecipe.embedNCR1632FractionX06(cdcX06, v2, BigInteger.ONE); + FourCornerRecipe.embedNCR1632FractionX18(cdcX18, v2, BigInteger.ONE); + String resX06 = FourCornerUnicodeDisplay.text().renderFromInt18(cdcX06); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(cdcX18); + Assertions.assertEquals(resX18, resX06); + Assertions.assertEquals("¹/₁₂₃¹/₁₂₃₄₅", resX06); + } + + @Test + public void testNCRCount1024() throws Exception { + List cdcX06 = new ArrayList<>(); + List cdcX18 = new ArrayList<>(); + for (int x = 1; x <= 1025; x++) { + BigInteger v = BigInteger.valueOf(x); + FourCornerRecipe.embedNCR1632FractionX06(cdcX06, v, BigInteger.ONE); + FourCornerRecipe.embedNCR1632FractionX18(cdcX18, v, BigInteger.ONE); + } + String resX06 = FourCornerUnicodeDisplay.text().renderFromInt18(cdcX06); + String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(cdcX18); + Assertions.assertEquals(resX18, resX06); + Assertions.assertTrue(resX06.startsWith("¹/₁¹/₂¹/₃"), "missing " + resX06); + Assertions.assertTrue(resX06.contains("¹/₅₁₂¹/₅₁₃¹/₅₁₄"), "missing " + resX06); + Assertions.assertTrue(resX06.endsWith("¹/₁₀₂₃¹/₁₀₂₄¹/₁₀₂₅"), "missing " + resX06); + Assertions.assertTrue(resX18.startsWith("¹/₁¹/₂¹/₃"), "missing " + resX18); + Assertions.assertTrue(resX18.contains("¹/₅₁₂¹/₅₁₃¹/₅₁₄"), "missing " + resX18); + Assertions.assertTrue(resX18.endsWith("¹/₁₀₂₃¹/₁₀₂₄¹/₁₀₂₅"), "missing " + resX18); + } + + @Test + public void testNCRMaxValue() throws Exception { + BigInteger maxValue = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16); + FourCornerRecipe.embedNCR1632FractionX06(maxValue, maxValue); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + FourCornerRecipe.embedNCR1632FractionX06(maxValue.add(BigInteger.ONE), maxValue); + }); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + FourCornerRecipe.embedNCR1632FractionX06(maxValue, maxValue.add(BigInteger.ONE)); + }); + FourCornerRecipe.embedNCR1632FractionX18(maxValue, maxValue); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + FourCornerRecipe.embedNCR1632FractionX18(maxValue.add(BigInteger.ONE), maxValue); + }); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + FourCornerRecipe.embedNCR1632FractionX18(maxValue, maxValue.add(BigInteger.ONE)); + }); + } } diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerInvalidTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/LexerInvalidTest.java similarity index 98% rename from nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerInvalidTest.java rename to nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/LexerInvalidTest.java index 2903d35..ff6b7a7 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerInvalidTest.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/LexerInvalidTest.java @@ -36,7 +36,7 @@ import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6; * @author Willem Cazander * @version 1.0 Aug 4, 2025 */ -public class StenoLexerInvalidTest { +public class LexerInvalidTest { @Test public void testInvalid18Plus() throws Exception { diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerNCRTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/LexerNCRTest.java similarity index 75% rename from nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerNCRTest.java rename to nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/LexerNCRTest.java index 55cd0a8..fdf75f9 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoLexerNCRTest.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/LexerNCRTest.java @@ -38,7 +38,7 @@ import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0; * @author Willem Cazander * @version 1.0 Jan 14, 2025 */ -public class StenoLexerNCRTest { +public class LexerNCRTest { @Test public void testNCRSmokeSignals() throws Exception { @@ -61,15 +61,17 @@ public class StenoLexerNCRTest { Assertions.assertEquals(2, smokeReader.pipeSmokeClouds); cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.cakePointSequence()); // the print above auto value + next test (normal bank reset) - cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + 11); + cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() - 1 + 11); cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + (512*3) + 12); cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() + (512*4) + 13); cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() + (512*5) + 14); cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart()); // and one which prints - cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() + 123); // normal NXX_123 + cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStop()); + cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStop()); // embedded bank reset + cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 123); // normal NXX_123 smokeReader.reset(); lexer.read(cdc); - String res = "[0:1:burnNCR1632MissingBankSparkler][0:8:burnNCR1632MissingBankSparkler]¹³⁷⁴³⁸⁹⁵³⁵⁹⁴/₁₃₄₂₁₇₇₃₉[0:16:burnNCR1632MissingBankSparkler]"; + String res = "[0:1:burnNCR1632MissingBankSparkler]¹²³/₁₃₄₂₁₇₇₂₉[0:8:burnNCR1632MissingBankSparkler]⁴⁹³⁴⁷⁴⁵⁶²⁴⁴¹²¹⁷/₁₆₁₀₆₁₂₇₄₇²⁴⁶⁸⁴⁷³³⁴²⁸²⁷²⁷³⁷⁶⁷⁶⁷⁴¹⁵⁶⁰²⁰³³²⁸⁰⁶⁹¹⁶¹⁷⁰⁹³⁹⁸³¹⁸⁴⁹⁹⁸⁵³⁵⁵³⁹²³⁰⁹⁰¹⁶⁸⁶⁴⁶⁵⁷⁸⁵²¹³⁷⁴⁵⁶⁷²¹¹⁷²⁴⁹³⁷⁶⁸⁴⁰⁴²⁰³⁰⁴⁶⁶⁷³⁵²³⁶³⁴⁷⁴⁰¹²²⁰¹⁵⁶⁷²⁰⁴¹⁹⁴³⁹⁹⁴⁷⁴¹²⁰⁸³⁶⁵¹⁰⁵⁷⁸²⁹¹⁵¹⁷⁷⁰⁹⁷⁸²⁸²³⁰¹⁹⁶⁴⁹⁵⁴⁶⁸⁴⁶³³¹/₁"; Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); } @@ -78,23 +80,17 @@ public class StenoLexerNCRTest { List cdc = new ArrayList<>(); cdc.add(FCDotCDC1604DashP6.NX24_X.ordinal()); // = X cdc.add(FCDotCDC1604DashP6.NY09_EQUALS.ordinal()); - - cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() + 11); - cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + 1); - - cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() + 1); - cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + 1); - - cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() + 14); - cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + 15); - - cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() + 123); - cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + 512 + 2); // 1024 - cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + 1); // +1 = 1025 - - cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() + 4); - cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + 1); + cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 11); // NXX_011 + cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart()); // T001 + cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart()); // NXX_001 + cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() - 1 + 15); // T015 + cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 14); // NXX_014 + cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() - 1 + 1); // one + cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + 512 + 2); // T1024 + one + cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 123); // NXX_123 + cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 4); // NXX_004 (/1 as above 123 resets bank) cdc.add(FCDotCDC1604DashP6.NY14_SEMICOLON.ordinal()); + //cdc.add(FCDotCDC1604DashP6._NEWLINE.ordinal()); Assertions.assertEquals("X=¹¹/₁¹/₁¹⁴/₁₅¹²³/₁₀₂₅⁴/₁;", FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); } @@ -102,14 +98,14 @@ public class StenoLexerNCRTest { @Test public void testNCRLargestF576() throws Exception { List cdc = new ArrayList<>(); - for (int i = FourCornerDotCake.FC_NCR1632_NUM.getStop(); i >= FourCornerDotCake.FC_NCR1632_NUM.getStart(); i = i - 512) { - cdc.add(i); - } for (int i = FourCornerDotCake.FC_NCR1632_DEN.getStop(); i >= FourCornerDotCake.FC_NCR1632_DEN.getStart(); i = i - 512) { cdc.add(i); } - String resSuper = "²⁴⁷³³⁰⁴⁰¹⁴⁷³¹⁰⁴⁵³⁴⁰⁶⁰⁵⁰²⁵²¹⁰¹⁹⁶⁴⁷¹⁹⁰⁰³⁵¹³¹³⁴⁹¹⁰¹²¹¹⁸³⁹⁹¹⁴⁰⁶³⁰⁵⁶⁰⁹²⁸⁹⁷²²⁵¹⁰⁶⁵³¹⁸⁶⁷¹⁷⁰³¹⁶⁴⁰¹⁰⁶¹²⁴³⁰⁴⁴⁹⁸⁹⁵⁹⁷⁶⁷¹⁴²⁶⁰¹⁶¹³⁹³³⁹³⁵¹³⁶⁵⁰³⁴³⁰⁶⁷⁵¹²⁰⁹⁹⁶⁷⁵⁴⁶¹⁵⁵¹⁰¹⁸⁹³¹⁶⁷⁹¹⁶⁶⁰⁶⁷⁷²¹⁴⁸⁶⁹⁹¹³⁵"; - String resSuber = "₂₄₇₃₃₀₄₀₁₄₇₃₁₀₄₅₃₄₀₆₀₅₀₂₅₂₁₀₁₉₆₄₇₁₉₀₀₃₅₁₃₁₃₄₉₁₀₁₂₁₁₈₃₉₉₁₄₀₆₃₀₅₆₀₉₂₈₉₇₂₂₅₁₀₆₅₃₁₈₆₇₁₇₀₃₁₆₄₀₁₀₆₁₂₄₃₀₄₄₉₈₉₅₉₇₆₇₁₄₂₆₀₁₆₁₃₉₃₃₉₃₅₁₃₆₅₀₃₄₃₀₆₇₅₁₂₀₉₉₆₇₅₄₆₁₅₅₁₀₁₈₉₃₁₆₇₉₁₆₆₀₆₇₇₂₁₄₈₆₉₉₁₃₅"; + for (int i = FourCornerDotCake.FC_NCR1632_NUM.getStop(); i >= FourCornerDotCake.FC_NCR1632_NUM.getStart(); i = i - 512) { + cdc.add(i); + } + String resSuper = "²⁴⁷³³⁰⁴⁰¹⁴⁷³¹⁰⁴⁵³⁴⁰⁶⁰⁵⁰²⁵²¹⁰¹⁹⁶⁴⁷¹⁹⁰⁰³⁵¹³¹³⁴⁹¹⁰¹²¹¹⁸³⁹⁹¹⁴⁰⁶³⁰⁵⁶⁰⁹²⁸⁹⁷²²⁵¹⁰⁶⁵³¹⁸⁶⁷¹⁷⁰³¹⁶⁴⁰¹⁰⁶¹²⁴³⁰⁴⁴⁹⁸⁹⁵⁹⁷⁶⁷¹⁴²⁶⁰¹⁶¹³⁹³³⁹³⁵¹³⁶⁵⁰³⁴³⁰⁶⁷⁵¹²⁰⁹⁹⁶⁷⁵⁴⁶¹⁵⁵¹⁰¹⁸⁹³¹⁶⁷⁹¹⁶⁶⁰⁶⁷⁷²¹⁴⁸⁶⁹⁹¹³⁶"; + String resSuber = "₂₄₇₃₃₀₄₀₁₄₇₃₁₀₄₅₃₄₀₆₀₅₀₂₅₂₁₀₁₉₆₄₇₁₉₀₀₃₅₁₃₁₃₄₉₁₀₁₂₁₁₈₃₉₉₁₄₀₆₃₀₅₆₀₉₂₈₉₇₂₂₅₁₀₆₅₃₁₈₆₇₁₇₀₃₁₆₄₀₁₀₆₁₂₄₃₀₄₄₉₈₉₅₉₇₆₇₁₄₂₆₀₁₆₁₃₉₃₃₉₃₅₁₃₆₅₀₃₄₃₀₆₇₅₁₂₀₉₉₆₇₅₄₆₁₅₅₁₀₁₈₉₃₁₆₇₉₁₆₆₀₆₇₇₂₁₄₈₆₉₉₁₃₆"; Assertions.assertEquals(resSuper + "/" + resSuber, FourCornerUnicodeDisplay.text().renderFromInt18(cdc)); } } diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoGrapherTest.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoGrapherTest.java deleted file mode 100644 index f88abd7..0000000 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/zion7/StenoGrapherTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2004-2014, Willem Cazander - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.x4o.fc18.zion7; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.x4o.fc18.FourCornerUnicodeDisplay; -import org.x4o.fc18.octal8.PrimordialOctal; - -/** - * Tests four corner grapher parts. - * - * @author Willem Cazander - * @version 1.0 Aug 24, 2025 - */ -public class StenoGrapherTest { - - @Test - public void testSandWalker() throws Exception { - List out = new ArrayList<>(); - FourCornerZion7Candlelier writerX06 = FourCornerZionStenoGrapher.writerX06(out); - Assertions.assertThrows(IllegalArgumentException.class, () -> { - writerX06.strobeSandWalker(List.of(PrimordialOctal.PART_1)); - }); - List octalMine = new ArrayList<>(); - for (int i=0;i<24;i++) { - octalMine.add(PrimordialOctal.PART_1); - } - writerX06.strobeSandWalker(octalMine); - String res = FourCornerUnicodeDisplay.text().renderFromInt18(out); - Assertions.assertTrue(res.endsWith("PART_1PART_1"), "missing " + res); - } - - @Test - public void testNCRValues() throws Exception { - List outX06 = new ArrayList<>(); - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX06 = FourCornerZionStenoGrapher.writerX06(outX06); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - BigInteger v1 = BigInteger.valueOf(123); - writerX06.strobeNCR1632(BigInteger.ONE, v1); - writerX18.strobeNCR1632(BigInteger.ONE, v1); - BigInteger v2 = BigInteger.valueOf(12345); - writerX06.strobeNCR1632(BigInteger.ONE, v2); - writerX18.strobeNCR1632(BigInteger.ONE, v2); - String resX06 = FourCornerUnicodeDisplay.text().renderFromInt18(outX06); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals(resX18, resX06); - Assertions.assertEquals("¹/₁₂₃¹/₁₂₃₄₅", resX06); - } - - @Test - public void testNCRCount1024() throws Exception { - List outX06 = new ArrayList<>(); - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX06 = FourCornerZionStenoGrapher.writerX06(outX06); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - for (int x = 1; x <= 1025; x++) { - BigInteger v = BigInteger.valueOf(x); - writerX06.strobeNCR1632(BigInteger.ONE, v); - writerX18.strobeNCR1632(BigInteger.ONE, v); - } - String resX06 = FourCornerUnicodeDisplay.text().renderFromInt18(outX06); - String resX18 = FourCornerUnicodeDisplay.text().renderFromInt18(outX18); - Assertions.assertEquals(resX18, resX06); - Assertions.assertTrue(resX06.startsWith("¹/₁¹/₂¹/₃"), "missing " + resX06); - Assertions.assertTrue(resX06.contains("¹/₅₁₂¹/₅₁₃¹/₅₁₄"), "missing " + resX06); - Assertions.assertTrue(resX06.endsWith("¹/₁₀₂₃¹/₁₀₂₄¹/₁₀₂₅"), "missing " + resX06); - Assertions.assertTrue(resX18.startsWith("¹/₁¹/₂¹/₃"), "missing " + resX18); - Assertions.assertTrue(resX18.contains("¹/₅₁₂¹/₅₁₃¹/₅₁₄"), "missing " + resX18); - Assertions.assertTrue(resX18.endsWith("¹/₁₀₂₃¹/₁₀₂₄¹/₁₀₂₅"), "missing " + resX18); - } - - @Test - public void testNCRMaxValue() throws Exception { - List outX06 = new ArrayList<>(); - List outX18 = new ArrayList<>(); - FourCornerZion7Candlelier writerX06 = FourCornerZionStenoGrapher.writerX06(outX06); - FourCornerZion7Candlelier writerX18 = FourCornerZionStenoGrapher.writerX18(outX18); - BigInteger maxValue = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16); - writerX06.strobeNCR1632(maxValue, maxValue); - Assertions.assertThrows(IllegalArgumentException.class, () -> { - writerX06.strobeNCR1632(maxValue, maxValue.add(BigInteger.ONE)); - }); - Assertions.assertThrows(IllegalArgumentException.class, () -> { - writerX06.strobeNCR1632(maxValue.add(BigInteger.ONE), maxValue); - }); - writerX18.strobeNCR1632(maxValue, maxValue); - Assertions.assertThrows(IllegalArgumentException.class, () -> { - writerX18.strobeNCR1632(maxValue, maxValue.add(BigInteger.ONE)); - }); - Assertions.assertThrows(IllegalArgumentException.class, () -> { - writerX18.strobeNCR1632(maxValue.add(BigInteger.ONE), maxValue); - }); - } -}