FC18: Fixed NCR encoding and added full range for six bit computers
This commit is contained in:
parent
d0cf13fe26
commit
e7e26b569b
10 changed files with 312 additions and 160 deletions
|
|
@ -140,47 +140,169 @@ final public class FourCornerRecipe {
|
|||
|
||||
static public List<Integer> embedSandWormX18(List<Integer> out, List<PrimordialOctal> spice) {
|
||||
Objects.requireNonNull(spice);
|
||||
return embedSandWormX06(out, spice); // TODO: write 18 bit version
|
||||
}
|
||||
|
||||
static public List<Integer> embedNCR1632Denominator(BigInteger value) {
|
||||
return embedNCR1632Value(new ArrayList<>(), value, FourCornerDotCake.FC_NCR1632_DEN.getStart());
|
||||
}
|
||||
|
||||
static public List<Integer> embedNCR1632Numerator(BigInteger value) {
|
||||
return embedNCR1632Value(new ArrayList<>(), value, FourCornerDotCake.FC_NCR1632_NUM.getStart());
|
||||
}
|
||||
|
||||
static public void embedNCR1632Denominator(List<Integer> out, BigInteger value) {
|
||||
embedNCR1632Value(out, value, FourCornerDotCake.FC_NCR1632_DEN.getStart());
|
||||
}
|
||||
|
||||
static public void embedNCR1632Numerator(List<Integer> out, BigInteger value) {
|
||||
embedNCR1632Value(out, value, FourCornerDotCake.FC_NCR1632_NUM.getStart());
|
||||
}
|
||||
|
||||
static private List<Integer> embedNCR1632Value(List<Integer> out, BigInteger value, int bankStart) {
|
||||
if (value.equals(BigInteger.ZERO)) {
|
||||
throw new IllegalArgumentException("The value ZERO is not allowed.");
|
||||
Iterator<PrimordialOctal> 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);
|
||||
}
|
||||
//if (value.signum() == -1) {
|
||||
return out;
|
||||
}
|
||||
|
||||
static public List<Integer> embedNCR1632FractionX06(BigInteger denominator, BigInteger numerator) {
|
||||
return embedNCR1632FractionX18(new ArrayList<>(), denominator, numerator);
|
||||
}
|
||||
|
||||
static public List<Integer> embedNCR1632FractionX06(List<Integer> 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 (value.compareTo(NCR1632_VALUE_MAX) > 0) {
|
||||
throw new IllegalArgumentException("Value is larger than 576 bit: " + value);
|
||||
if (denominator.compareTo(NCR1632_VALUE_MAX) > 0) { // fixme: this is still one off...
|
||||
throw new IllegalArgumentException("Value denominator is larger than 576 bit: " + denominator);
|
||||
}
|
||||
BigInteger valueZero = value.subtract(BigInteger.ONE);
|
||||
if (valueZero.equals(BigInteger.ZERO)) {
|
||||
out.add(bankStart);
|
||||
return out;
|
||||
if (numerator.compareTo(NCR1632_VALUE_MAX) > 0) { // fixme: this is still one off...
|
||||
throw new IllegalArgumentException("Value numerator is larger than 576 bit: " + numerator);
|
||||
}
|
||||
for (int i = 63; i >= 0; i--) {
|
||||
int bankValue = valueZero.shiftRight(i * 9).and(NCR1632_MASK_PAGE).intValue();
|
||||
if (bankValue == 0) {
|
||||
continue;
|
||||
|
||||
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<Integer> embedNCR1632FractionX18(BigInteger denominator, BigInteger numerator) {
|
||||
return embedNCR1632FractionX18(new ArrayList<>(), denominator, numerator);
|
||||
}
|
||||
|
||||
static public List<Integer> embedNCR1632FractionX18(List<Integer> 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);
|
||||
}
|
||||
int cakePoint = bankStart + bankValue + (i * 512);
|
||||
out.add(cakePoint);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -308,13 +308,7 @@ public enum FourCornerDotCake {
|
|||
FC_CLK1K_Y(131072 + (1024*24), 1024, FCDotCLK1KDashY.values()),
|
||||
FC_CLK1K_Z(131072 + (1024*25), 1024, FCDotCLK1KDashZ.values()),
|
||||
|
||||
// =========== Allow structures,sandworms and legacy unicode an pieve of the cake
|
||||
|
||||
//FC_F4SID0512_XE(0x026800, 512, FCDotF4SID0512DashXE.values(), "Flag4 StringID XML4 Elements"),
|
||||
//FC_F4SID0512_XA(0x026A00, 512, FCDotF4SID0512DashXA.values(), "Flag4 StringID XML4 Attributes"),
|
||||
//FC_F4SID0064_XN(0x026C00, 64, FCDotF4SID0064DashXN.values(), "Flag4 StringID XML4 Namespaces"),
|
||||
|
||||
//FC_F4XMLXDBX_V4()
|
||||
// =========== Define document structures and sandworms
|
||||
|
||||
/// Reserved Flag4 Structures
|
||||
__RESERVED_F4(0x026800, 0x026DBE - 0x026800, "Reserved for F4 structures"),
|
||||
|
|
|
|||
|
|
@ -114,9 +114,11 @@ public enum FCDotDEC2701DashPX0 implements FourCornerX06BaklavaPointSequence, Fo
|
|||
ESC68_INC0801_P8,
|
||||
|
||||
/// _ESC6_X2 _ESC6_X3 _ESC6_X2 = 17
|
||||
/// Select packed pie terminator number for 6 and 8 bit systems.
|
||||
/// First NXX P6 is terminator select, than next NXX P6 are values, until out of range.
|
||||
/// TODO: Double range to 54 with the negative AT (= symbols) for -1=AT=28 -2=BAR_V_RIGHT=29
|
||||
/// Select packed new counting rods fraction for 6 and 8 bit systems.
|
||||
/// NX01-NX08 are octal values
|
||||
/// 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,
|
||||
|
||||
/// _ESC6_X2 _ESC6_X3 _ESC6_X3 = 18
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import java.util.Objects;
|
|||
|
||||
import org.x4o.fc18.FourCornerRecipe;
|
||||
import org.x4o.fc18.octal8.PrimordialOctal;
|
||||
import org.x4o.fc18.octal8.PrimordialOctalOrangeJuice;
|
||||
|
||||
/// Write steno for zion.
|
||||
///
|
||||
|
|
@ -63,8 +64,12 @@ public class FourCornerZionStenoGrapher {
|
|||
|
||||
@Override
|
||||
public void strobeWord(int cakePoint) {
|
||||
//if (isSixBit) {
|
||||
//}
|
||||
if (isSixBit && cakePoint > 63) {
|
||||
throw new IllegalArgumentException("Cake point is larger than baklave point limit: 0x" + Integer.toHexString(cakePoint));
|
||||
}
|
||||
if (cakePoint > PrimordialOctalOrangeJuice.MAX_VALUE) {
|
||||
throw new IllegalArgumentException("Cake point is larger than max value limit: 0x" + Integer.toHexString(cakePoint));
|
||||
}
|
||||
out.add(cakePoint);
|
||||
}
|
||||
|
||||
|
|
@ -78,8 +83,11 @@ public class FourCornerZionStenoGrapher {
|
|||
|
||||
@Override
|
||||
public void strobeNCR1632(BigInteger denominator, BigInteger numerator) {
|
||||
FourCornerRecipe.embedNCR1632Denominator(out, denominator);
|
||||
FourCornerRecipe.embedNCR1632Numerator(out, numerator);
|
||||
if (isSixBit) {
|
||||
FourCornerRecipe.embedNCR1632FractionX06(out, denominator, numerator);
|
||||
} else {
|
||||
FourCornerRecipe.embedNCR1632FractionX18(out, denominator, numerator);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,12 +24,10 @@ package org.x4o.fc18.zion7;
|
|||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.PrimitiveIterator;
|
||||
|
||||
import org.x4o.fc18.FourCornerRecipe;
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
|
|
@ -67,9 +65,13 @@ public class FourCornerZionStenoLexer {
|
|||
private FCDotDEC2701DashPX0 cdcDECMode = null;
|
||||
private FCDotINC0801DashP8 cdcDECModeInc = null;
|
||||
private FCDotDEC0801DashE10 cdcDECModeE10 = null;
|
||||
private Integer cdcDECModeNcr = null;
|
||||
private int cdcDECModePie = 0;
|
||||
private Boolean cdcDECModePieAlt = null;
|
||||
private int cdcDECModeNCR68Select = 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;
|
||||
|
||||
|
|
@ -149,7 +151,6 @@ public class FourCornerZionStenoLexer {
|
|||
currLine = 0;
|
||||
currCol = 0; // allow reuse of lexer
|
||||
decModeReset();
|
||||
ncrBankResetSilent();
|
||||
handlerDocument.strobeDocumentAlpha();
|
||||
do {
|
||||
ScanResult run = readTokens();
|
||||
|
|
@ -195,12 +196,7 @@ public class FourCornerZionStenoLexer {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void ncrBankReset(boolean magic) {
|
||||
fireSignals.fireStateNCR1632BankReset(magic);
|
||||
ncrBankResetSilent();
|
||||
}
|
||||
|
||||
private void ncrBankResetSilent() {
|
||||
private void ncrBankReset() {
|
||||
for (int i = 0; i < denominatorBank.length; i++) {
|
||||
denominatorBank[i] = 0;
|
||||
numeratorBank[i] = 0;
|
||||
|
|
@ -224,9 +220,13 @@ public class FourCornerZionStenoLexer {
|
|||
cdcDECMode = null;
|
||||
cdcDECModeInc = null;
|
||||
cdcDECModeE10 = null;
|
||||
cdcDECModeNcr = null;
|
||||
cdcDECModePie = 0;
|
||||
cdcDECModePieAlt = null;
|
||||
cdcDECModeNCR68Select = 0;
|
||||
cdcDECModeNCR68DenPage = 0;
|
||||
cdcDECModeNCR68DenValue = 0;
|
||||
cdcDECModeNCR68NumPage = 0;
|
||||
cdcDECModeNCR68NumValue = 0;
|
||||
}
|
||||
|
||||
abstract static private class StenoScanner {
|
||||
|
|
@ -302,10 +302,11 @@ public class FourCornerZionStenoLexer {
|
|||
|
||||
@Override
|
||||
public void process(FourCornerZionStenoLexer lexer, int idxFirst, int idxLast) {
|
||||
List<Integer> wormBody15 = new ArrayList<>();
|
||||
for (int i = idxFirst; i <= idxLast; i++) {
|
||||
wormBody15.add(lexer.input.get(i));
|
||||
}
|
||||
//List<Integer> wormBody15 = new ArrayList<>();
|
||||
//for (int i = idxFirst; i <= idxLast; i++) {
|
||||
// wormBody15.add(lexer.input.get(i));
|
||||
//}
|
||||
List<Integer> wormBody15 = lexer.input.subList(idxFirst, idxLast + 1);
|
||||
List<PrimordialOctal> wormSpice = new ArrayList<>();
|
||||
Iterator<Integer> i15 = wormBody15.iterator();
|
||||
while (i15.hasNext()) {
|
||||
|
|
@ -350,9 +351,8 @@ public class FourCornerZionStenoLexer {
|
|||
|
||||
@Override
|
||||
public void process(FourCornerZionStenoLexer lexer, int idxFirst, int idxLast) {
|
||||
lexer.ncrBankReset(false);
|
||||
lexer.ncrBankReset();
|
||||
boolean magicSparkler = true;
|
||||
boolean requestBankReset = false;
|
||||
for (int i = idxFirst; i <= idxLast; i++) {
|
||||
int cakePoint = lexer.input.get(i);
|
||||
if (cakePoint >= FourCornerDotCake.FC_NCR1632_DEN.getStart() && cakePoint <= FourCornerDotCake.FC_NCR1632_DEN.getStop()) {
|
||||
|
|
@ -363,27 +363,18 @@ public class FourCornerZionStenoLexer {
|
|||
}
|
||||
int numeratorX = cakePoint - FourCornerDotCake.FC_NCR1632_NUM.getStart();
|
||||
lexer.numeratorBank[numeratorX / 512] = numeratorX % 512;
|
||||
// 1st select + enable request, if second than reset bank
|
||||
if (cakePoint == FourCornerDotCake.FC_NCR1632_NUM.getStop()) {
|
||||
if (requestBankReset) {
|
||||
requestBankReset = false;
|
||||
lexer.ncrBankReset(true);
|
||||
magicSparkler = false; // if block ends with bank reset, don't leak a sparkler
|
||||
continue;
|
||||
}
|
||||
requestBankReset = true;
|
||||
} else {
|
||||
requestBankReset = false;
|
||||
}
|
||||
|
||||
if (cakePoint > CAKEPOINT_BANK0_END) {
|
||||
magicSparkler = true;
|
||||
continue; // Only fire fraction on lowest value select
|
||||
}
|
||||
lexer.ncrBankFire(false);
|
||||
lexer.ncrBankReset();
|
||||
magicSparkler = false;
|
||||
}
|
||||
if (magicSparkler) {
|
||||
lexer.ncrBankFire(true);
|
||||
lexer.ncrBankReset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -517,7 +508,7 @@ public class FourCornerZionStenoLexer {
|
|||
return handleCMD(lexer);
|
||||
}
|
||||
if (FCDotDEC2701DashPX0.ESC68_NCR.equals(cdcDECMode)) {
|
||||
return handleNCR(lexer); // TODO: add small bank switching ?
|
||||
return handleNCR(lexer);
|
||||
}
|
||||
if (FCDotDEC2701DashPX0.ESC_DEC0801_E10.equals(cdcDECMode)) {
|
||||
return handleE10(lexer);
|
||||
|
|
@ -665,31 +656,77 @@ 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 (lexer.cdcDECModeNcr == null) {
|
||||
lexer.cdcDECModeNcr = cdcPoint;
|
||||
if (lexer.cdcDECModeNcr < FCDotCDC1604DashP6.NX01_A.ordinal()) {
|
||||
lexer.decModeReset();
|
||||
return false; // print char
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
if (cdcPoint == FCDotCDC1604DashP6._SALAH_EXCLAMATION.ordinal() || cdcPoint == FCDotCDC1604DashP6._RAKA_QUESTION.ordinal()) {
|
||||
lexer.decModeReset();
|
||||
return true; // eat salah and end mode
|
||||
}
|
||||
if (lexer.cdcDECModeNcr != null) {
|
||||
if (cdcPoint < FCDotCDC1604DashP6.NX01_A.ordinal()) {
|
||||
lexer.decModeReset();
|
||||
return false;
|
||||
}
|
||||
if (cdcPoint > lexer.cdcDECModeNcr) {
|
||||
lexer.decModeReset();
|
||||
return false;
|
||||
}
|
||||
if (cdcPoint >= FCDotCDC1604DashP6.NY10_CARET.ordinal() && cdcPoint <= FCDotCDC1604DashP6.NY01_AT.ordinal()) {
|
||||
lexer.cdcDECModeNCR68Select = cdcPoint;
|
||||
return true; // swallow select
|
||||
}
|
||||
if (lexer.cdcDECModeNCR68Select == 0) {
|
||||
lexer.decModeReset(); // exit mode did not start with select
|
||||
return false; // print char
|
||||
}
|
||||
int octalValue = -1;
|
||||
if (cdcPoint >= FCDotCDC1604DashP6.NX01_A.ordinal() && cdcPoint <= FCDotCDC1604DashP6.NX08_H.ordinal()) {
|
||||
octalValue = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal(); // goto relative
|
||||
}
|
||||
if (octalValue == -1) {
|
||||
lexer.decModeReset(); // exit mode out of range
|
||||
return false; // print char
|
||||
}
|
||||
if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY01_AT.ordinal()) {
|
||||
lexer.cdcDECModeNCR68DenPage = (octalValue << 3) + (lexer.cdcDECModeNCR68DenPage & 0b111);
|
||||
return true;
|
||||
}
|
||||
if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY02_BAR_V_RIGHT.ordinal()) {
|
||||
lexer.cdcDECModeNCR68DenPage = (lexer.cdcDECModeNCR68DenPage & 0b111000) + octalValue;
|
||||
return true;
|
||||
}
|
||||
if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY03_BAR_V_LEFT.ordinal()) {
|
||||
lexer.cdcDECModeNCR68DenValue = (octalValue << 6) + (lexer.cdcDECModeNCR68DenValue & 0b111111);
|
||||
return true;
|
||||
}
|
||||
if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY04_BAR_UNDER.ordinal()) {
|
||||
lexer.cdcDECModeNCR68DenValue = (octalValue << 3) + (lexer.cdcDECModeNCR68DenValue & 0b111000111);
|
||||
return true;
|
||||
}
|
||||
if (lexer.cdcDECModeNCR68Select == FCDotCDC1604DashP6.NY05_BAR_VERTICAL.ordinal()) {
|
||||
lexer.cdcDECModeNCR68DenValue = (lexer.cdcDECModeNCR68DenValue & 0b111111000) + octalValue;
|
||||
lexer.denominatorBank[lexer.cdcDECModeNCR68DenPage] = lexer.cdcDECModeNCR68DenValue;
|
||||
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(false);
|
||||
lexer.ncrBankReset();
|
||||
}
|
||||
int terminatorOff = lexer.cdcDECModeNcr - FCDotCDC1604DashP6.NX01_A.ordinal() + 1;
|
||||
int numberIdxOff = cdcPoint - FCDotCDC1604DashP6.NX01_A.ordinal() + 1;
|
||||
BigInteger denominator = BigInteger.valueOf(terminatorOff);
|
||||
BigInteger numerator = BigInteger.valueOf(numberIdxOff);
|
||||
lexer.handler.strobeNCR1632(denominator, numerator);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ public interface FourCornerZionStenoLexerFire {
|
|||
|
||||
void fireStateNCR1632BankSparkler(boolean magic);
|
||||
|
||||
void fireStateNCR1632BankReset(boolean magic);
|
||||
|
||||
interface Adapter extends FourCornerZionStenoLexerFire {
|
||||
|
||||
@Override
|
||||
|
|
@ -49,9 +47,5 @@ public interface FourCornerZionStenoLexerFire {
|
|||
@Override
|
||||
default void fireStateNCR1632BankSparkler(boolean magic) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void fireStateNCR1632BankReset(boolean magic) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,29 +53,60 @@ public class FourCornerRecipeTest {
|
|||
Assertions.assertTrue(res.endsWith("PART_1PART_1"), "missing " + res);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRValues() throws Exception {
|
||||
List<Integer> cdcX06 = new ArrayList<>();
|
||||
List<Integer> 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);
|
||||
System.out.println(FourCornerUnicodeDisplay.raw().renderFromInt18(cdcX06));
|
||||
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<Integer> cdc = new ArrayList<>();
|
||||
for (int x = 1; x <= 1024; x++) {
|
||||
List<Integer> cdcX06 = new ArrayList<>();
|
||||
List<Integer> cdcX18 = new ArrayList<>();
|
||||
for (int x = 1; x <= 1025; x++) {
|
||||
BigInteger v = BigInteger.valueOf(x);
|
||||
cdc.addAll(FourCornerRecipe.embedNCR1632Denominator(v));
|
||||
|
||||
//cdc.add(FourCornerDotCake.FC_NCR1632_XN.getStart()); // NXX_1
|
||||
List<Integer> nomList = FourCornerRecipe.embedNCR1632Numerator(BigInteger.ONE);
|
||||
Assertions.assertEquals(1, nomList.size());
|
||||
cdc.addAll(nomList); // NXX_1
|
||||
FourCornerRecipe.embedNCR1632FractionX06(cdcX06, v, BigInteger.ONE);
|
||||
FourCornerRecipe.embedNCR1632FractionX18(cdcX18, v, BigInteger.ONE);
|
||||
}
|
||||
String res = FourCornerUnicodeDisplay.text().renderFromInt18(cdc);
|
||||
Assertions.assertTrue(res.startsWith("¹/₁¹/₂"), "missing " + res);
|
||||
Assertions.assertTrue(res.endsWith("¹/₁₀₂₃¹/₁₀₂₄"), "missing " + res);
|
||||
System.out.println(FourCornerUnicodeDisplay.raw().renderFromInt18(cdcX06));
|
||||
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.embedNCR1632Numerator(maxValue);
|
||||
FourCornerRecipe.embedNCR1632FractionX06(maxValue, maxValue);
|
||||
Assertions.assertThrows(IllegalArgumentException.class, () -> {
|
||||
FourCornerRecipe.embedNCR1632Numerator(maxValue.add(BigInteger.ONE));
|
||||
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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
package org.x4o.fc18;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,16 +22,13 @@
|
|||
*/
|
||||
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.FourCornerRecipe;
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
import org.x4o.fc18.cake2.FourCornerX06BaklavaPointSequence;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
|
||||
import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0;
|
||||
|
||||
|
|
@ -62,7 +59,6 @@ public class LexerNCRTest {
|
|||
lexer.read(cdc);
|
||||
Assertions.assertEquals(2, fireWalker.ncr1632BankSparkler);
|
||||
|
||||
Assertions.assertEquals(0, fireWalker.ncr1632BankReset);
|
||||
cdc.addAll(FCDotDEC2701DashPX0.ESC_STOP.cakePointSequence()); // the print above auto value + next test (normal bank reset)
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() - 1 + 11);
|
||||
cdc.add(FourCornerDotCake.FC_NCR1632_DEN.getStart() + (512*3) + 12);
|
||||
|
|
@ -74,30 +70,8 @@ public class LexerNCRTest {
|
|||
cdc.add(FourCornerDotCake.FC_NCR1632_NUM.getStart() - 1 + 123); // normal NXX_123
|
||||
fireWalker.reset();
|
||||
lexer.read(cdc);
|
||||
Assertions.assertEquals(1, fireWalker.ncr1632BankReset);
|
||||
|
||||
Assertions.assertEquals("¹/₁₃₄₂₁₇₇₂₉¹²³/₁¹³⁷⁴³⁸⁹⁵³⁵⁹⁵/₁⁴⁹³⁴⁷⁴⁵⁶²⁴⁴¹²¹⁷/₁₆₁₀₆₁₂₇₄₇¹²³/₁", FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNCRSimpleX06() throws Exception {
|
||||
List<FourCornerX06BaklavaPointSequence> cdc = new ArrayList<>();
|
||||
cdc.add(FCDotCDC1604DashP6.NX24_X); // = X
|
||||
cdc.add(FCDotCDC1604DashP6.NY09_EQUALS);
|
||||
cdc.add(FCDotCDC1604DashP6._ESC6_X2);
|
||||
cdc.add(FCDotCDC1604DashP6._ESC6_X3);
|
||||
cdc.add(FCDotCDC1604DashP6._ESC6_X2);
|
||||
cdc.add(FCDotCDC1604DashP6.NX15_O); // T015
|
||||
cdc.add(FCDotCDC1604DashP6.NX14_N); // NXX_014
|
||||
cdc.add(FCDotCDC1604DashP6.NX05_E); // NXX_005
|
||||
cdc.add(FCDotCDC1604DashP6.NX07_G); // NXX_007
|
||||
cdc.add(FCDotCDC1604DashP6.NX15_O); // NXX_015
|
||||
cdc.add(FCDotCDC1604DashP6.NX04_D); // NXX_004
|
||||
//cdc.add(FCDotCDC1604DashP6.NY14_SEMICOLON);
|
||||
//cdc.add(FCDotCDC1604DashP6._NEWLINE);
|
||||
|
||||
Assertions.assertEquals("X=¹⁴/₁₅⁵/₁₅⁷/₁₅¹⁵/₁₅⁴/₁₅", FourCornerUnicodeDisplay.text().renderFromX06(cdc));
|
||||
Assertions.assertEquals("X=␇␘␇ONEGOD", FourCornerUnicodeDisplay.raw().renderFromX06(cdc));
|
||||
String res = "¹/₁₃₄₂₁₇₇₂₉¹²³/₁¹³⁷⁴³⁸⁹⁵³⁴⁷³/₁⁴⁹³⁴⁷⁴⁵⁶²⁴⁴¹²¹⁷/₁₆₁₀₆₁₂₇₄₇²⁴⁶⁸⁴⁷³³⁴²⁸²⁷²⁷³⁷⁶⁷⁶⁷⁴¹⁵⁶⁰²⁰³³²⁸⁰⁶⁹¹⁶¹⁷⁰⁹³⁹⁸³¹⁸⁴⁹⁹⁸⁵³⁵⁵³⁹²³⁰⁹⁰¹⁶⁸⁶⁴⁶⁵⁷⁸⁵²¹³⁷⁴⁵⁶⁷²¹¹⁷²⁴⁹³⁷⁶⁸⁴⁰⁴²⁰³⁰⁴⁶⁶⁷³⁵²³⁶³⁴⁷⁴⁰¹²²⁰¹⁵⁶⁷²⁰⁴¹⁹⁴³⁹⁹⁴⁷⁴¹²⁰⁸³⁶⁵¹⁰⁵⁷⁸²⁹¹⁵¹⁷⁷⁰⁹⁷⁸²⁸²³⁰¹⁹⁶⁴⁹⁵⁴⁶⁸⁴⁶³³¹/₁";
|
||||
Assertions.assertEquals(res, FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -113,11 +87,11 @@ public class LexerNCRTest {
|
|||
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
|
||||
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));
|
||||
Assertions.assertEquals("X=¹¹/₁¹/₁¹⁴/₁₅¹²³/₁₀₂₅⁴/₁;", FourCornerUnicodeDisplay.text().renderFromInt18(cdc));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter {
|
|||
int scanBlockStop;
|
||||
int scanMatchPoint;
|
||||
int ncr1632BankSparkler;
|
||||
int ncr1632BankReset;
|
||||
|
||||
public TestFireWalker() {
|
||||
reset();
|
||||
|
|
@ -47,7 +46,6 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter {
|
|||
scanMatchPoint = 0;
|
||||
scanMatchPoint = 0;
|
||||
ncr1632BankSparkler = 0;
|
||||
ncr1632BankReset = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -68,11 +66,4 @@ public class TestFireWalker implements FourCornerZionStenoLexerFire.Adapter {
|
|||
ncr1632BankSparkler++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireStateNCR1632BankReset(boolean magic) {
|
||||
if (magic) {
|
||||
ncr1632BankReset++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue