FC18: Moved sand worms to own interface and split steno writer

This commit is contained in:
Willem Cazander 2025-09-08 16:53:12 +02:00
parent ab80c81c97
commit b289a8c9bf
4 changed files with 146 additions and 79 deletions

View file

@ -0,0 +1,46 @@
/*
* 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.util.List;
import org.x4o.fc18.octal8.PrimordialOctal;
/// Handles the hyper reality four corner cake strobes.
///
/// NOTE: needs a "nether db" where a sand walk gets a spice harvester to deal with the spice value
///
/// @author Willem Cazander
/// @version 1.0 Sep 8, 2025
public interface FourCornerZion7BaseVoid extends FourCornerZion7AlphaOmega {
/// Embed sand spice using a sand walk to call the identified great sand worm which leaves the spice in the sand.
void strobeSandWorm(List<PrimordialOctal> sandWalk, List<PrimordialOctal> sandSpice);
interface Adapter extends FourCornerZion7BaseVoid, FourCornerZion7AlphaOmega.Adapter {
@Override
default void strobeSandWorm(List<PrimordialOctal> sandWalk, List<PrimordialOctal> sandSpice) {
}
}
}

View file

@ -25,7 +25,6 @@ package org.x4o.fc18.zion7;
import java.math.BigInteger;
import java.util.List;
import org.x4o.fc18.octal8.PrimordialOctal;
import org.x4o.fc18.zion7.flame4.FCFlameFremanChocoBase8;
import org.x4o.fc18.zion7.flame4.FCFlameFremanLegoBase2;
import org.x4o.fc18.zion7.flame4.FCFlameFremanLegoBase8;
@ -38,7 +37,7 @@ import org.x4o.fc18.zion7.flame4.FCFlameWordDish;
///
/// @author Willem Cazander
/// @version 1.0 Jan 09, 2025
public interface FourCornerZion7Bereshit extends FourCornerZion7AlphaOmega {
public interface FourCornerZion7Bereshit extends FourCornerZion7BaseVoid {
/// Single word cake point.
void strobeTheWord(FCFlameWordDish course, int cakePoint);
@ -61,13 +60,10 @@ public interface FourCornerZion7Bereshit extends FourCornerZion7AlphaOmega {
/// Embed base8 computer chocolate number.
void strobeNumberBASE8Choco(FCFlameFremanChocoBase8 type, FCFlameNumberTaste taste, BigInteger value);
/// Embed sand spice using a sand walk to call the identified great sand worm which leaves the spice in the sand.
void strobeSandWorm(List<PrimordialOctal> sandWalk, List<PrimordialOctal> sandSpice);
/// The external supported salah sequence strobes.
void strobeSalahSequence(FCFlameSalahSequence type, List<List<Integer>> arguments);
interface Adapter extends FourCornerZion7Bereshit, FourCornerZion7AlphaOmega.Adapter {
interface Adapter extends FourCornerZion7Bereshit, FourCornerZion7BaseVoid.Adapter {
@Override
default void strobeTheWord(FCFlameWordDish course, int cakePoint) {
@ -93,10 +89,6 @@ public interface FourCornerZion7Bereshit extends FourCornerZion7AlphaOmega {
default void strobeNumberBASE8Choco(FCFlameFremanChocoBase8 type, FCFlameNumberTaste taste, BigInteger value) {
}
@Override
default void strobeSandWorm(List<PrimordialOctal> sandWalk, List<PrimordialOctal> sandSpice) {
}
@Override
default void strobeSalahSequence(FCFlameSalahSequence type, List<List<Integer>> arguments) {
}

View file

@ -58,15 +58,15 @@ import org.x4o.fc18.zion7.flame4.FCFlameNumberGram;
public class FourCornerZionStenoGrapher {
static public FourCornerZion7Bereshit writerX06(List<Integer> out) {
return new FourCornerWriter(v -> out.add(v), () -> {}, FCFlameStenoTongue.FC6_PLUS);
return new FourCornerWriterBereshit(v -> out.add(v), () -> {}, FCFlameStenoTongue.FC6_PLUS);
}
static public FourCornerZion7Candlelier writerX18(List<Integer> out) {
return new FourCornerWriter(v -> out.add(v), () -> {}, FCFlameStenoTongue.FC18);
return new FourCornerWriterCandlelier(v -> out.add(v), () -> {}, FCFlameStenoTongue.FC18);
}
static public FourCornerZion7TempleScrolls writerXDBX18(List<Integer> out) {
return new FourCornerWriter(v -> out.add(v), () -> {}, FCFlameStenoTongue.FC18);
return new FourCornerWriterTempleScrolls(v -> out.add(v), () -> {}, FCFlameStenoTongue.FC18);
}
/*
static public FourCornerZion7Bereshit writerFC6(List<Integer> out) {
@ -85,11 +85,15 @@ public class FourCornerZionStenoGrapher {
return new FourCornerWriter(v -> out.add(v), () -> {}, false);
}
static public FourCornerZion7TempleScrolls writerXDBX18(List<Integer> out) {
static public FourCornerZion7BaseVoid writerFC18Worms(List<Integer> out) {
return new FourCornerWriter(v -> out.add(v), () -> {}, false);
}
static public FourCornerZion7TempleScrolls writerXDBX18Adult(List<Integer> out) {
static public FourCornerZion7TempleScrolls writerTongue(FCFlameStenoTongue outTongue, List<Integer> out) {
return new FourCornerWriter(v -> out.add(v), () -> {}, false);
}
static public FourCornerZion7TempleScrolls writerTongue(FCFlameStenoTongue outTongue,List<Integer> out) {
return new FourCornerWriter(v -> out.add(v), () -> {}, false);
}s
*/
@ -123,27 +127,27 @@ public class FourCornerZionStenoGrapher {
}
*/
static public final class FourCornerWriter implements FourCornerZionStenoPetroglyphs, FourCornerZion7Candlelier, FourCornerZion7TempleScrolls {
private final IntConsumer out;
private final Runnable outFlush;
private final FCFlameStenoTongue outTongue;
static abstract private class FourCornerWriterBaseVoid implements FourCornerZionStenoPetroglyphs, FourCornerZion7BaseVoid {
public FourCornerWriter(IntConsumer out, Runnable outFlush, FCFlameStenoTongue outTongue) {
protected final IntConsumer out;
private final Runnable outFlush;
protected final FCFlameStenoTongue outTongue;
public FourCornerWriterBaseVoid(IntConsumer out, Runnable outFlush, FCFlameStenoTongue outTongue) {
this.out = Objects.requireNonNull(out);
this.outFlush = Objects.requireNonNull(outFlush);
this.outTongue = Objects.requireNonNull(outTongue);
}
private void outFlush() {
protected void outFlush() {
outFlush.run();
}
private void outAdd(int value) {
protected void outAdd(int value) {
out.accept(value);
}
private void outAddAll(List<Integer> values) {
protected void outAddAll(List<Integer> values) {
int listSize = values.size();
for (int i = NCR_ZERO; i < listSize; i++) {
outAdd(values.get(i));
@ -188,7 +192,7 @@ public class FourCornerZionStenoGrapher {
outAdd(FCDotCDC1604DashP6.NS04_RAKA1_INTERROBANG.baklavaPointDotIndex());
}
private void outAddFremanCake8(FCFlameFremanSuit suit, int bankStart, BigInteger value, Function<Integer, Integer> overrideMsb) {
protected void outAddFremanCake8(FCFlameFremanSuit suit, int bankStart, BigInteger value, Function<Integer, Integer> overrideMsb) {
if (outTongue.isSixBit()) {
outAddBankCakeFC6(NCR_BANK8_BITS, BIG_BITS_8, suit, bankStart, value, overrideMsb);
} else {
@ -197,7 +201,7 @@ public class FourCornerZionStenoGrapher {
outFlush();
}
private void outAddFremanCake9(FCFlameFremanSuit suit, int bankStart, BigInteger value, Function<Integer, Integer> overrideMsb) {
protected void outAddFremanCake9(FCFlameFremanSuit suit, int bankStart, BigInteger value, Function<Integer, Integer> overrideMsb) {
if (outTongue.isSixBit()) {
outAddBankCakeFC6(NCR_BANK9_BITS, BIG_BITS_9, suit, bankStart, value, overrideMsb);
} else {
@ -206,39 +210,39 @@ public class FourCornerZionStenoGrapher {
outFlush();
}
private void outAddBankCake12(int cakeSel0, int cakeBank, int bankStart, BigInteger value, Function<Integer, Integer> overrideMsb) {
protected void outAddBankCake12(int cakeSel0, int cakeBank, int bankStart, BigInteger value, Function<Integer, Integer> overrideMsb) {
outAddBankCake(NCR_BANK12_BITS, BIG_BITS_12, cakeSel0, cakeBank, bankStart, value, out, overrideMsb);
outFlush();
}
private BigInteger requireBigPositive(BigInteger value) {
protected BigInteger requireBigPositive(BigInteger value) {
if (value.signum() == NCR_SIGNUM_NEGATIVE) {
throw new IllegalArgumentException("Value can't be negative: " + value);
}
return value;
}
private BigInteger requireBigMax(BigInteger value, BigInteger valueMax) {
protected BigInteger requireBigMax(BigInteger value, BigInteger valueMax) {
if (value.compareTo(valueMax) > 0) {
throw new IllegalArgumentException("Value is larger than max: " + valueMax);
}
return value;
}
private BigInteger requireBigNoneZero(BigInteger value) {
protected BigInteger requireBigNoneZero(BigInteger value) {
if (BigInteger.ZERO.equals(value)) {
throw new IllegalArgumentException("Value can't be zero: " + value);
}
return value;
}
private void requireTongueFC18() {
protected void requireTongueFC18() {
if (outTongue.isSixBit()) {
throw new IllegalArgumentException("Value can't be written in six bit mode.");
}
}
// --------------------------------------- BEGIN FC6
// --------------------------------------- BEGIN BASE VOID
@Override
public void strobeDocumentAlpha() {
@ -249,6 +253,57 @@ public class FourCornerZionStenoGrapher {
outFlush();
}
@Override
public void strobeSandWorm(List<PrimordialOctal> sandWalk, List<PrimordialOctal> sandSpice) {
Objects.requireNonNull(sandWalk);
Objects.requireNonNull(sandSpice);
if (!SAND_WORM_SIGNS.contains(sandWalk.size())) {
throw new IllegalArgumentException("Sand walk rhythm is not 72 bit aligned: " + sandWalk.size());
}
if (0 != (sandSpice.size() % 5)) {
throw new IllegalArgumentException("Sand spice is not 15 bit aligned: " + sandSpice.size());
}
Iterator<PrimordialOctal> walkItr = sandWalk.iterator();
Iterator<PrimordialOctal> spiceItr = sandSpice.iterator();
if (outTongue.isSixBit()) {
outAdd(FCDotDEC2701DashPX0.ESC6_SAND_WORM.cakePointDotIndex());
while (walkItr.hasNext()) {
outAdd(FCDotCDC1604DashP6.NX01_A.cakePointDotIndex() + walkItr.next().ordinal());
}
outAdd(FCDotCDC1604DashP6.NS05_RAKA1_UPQUESTION.cakePointDotIndex());
while (spiceItr.hasNext()) {
outAdd(FCDotCDC1604DashP6.NX01_A.cakePointDotIndex() + spiceItr.next().ordinal());
}
outAdd(FCDotCDC1604DashP6.NS04_RAKA1_INTERROBANG.cakePointDotIndex());
} else {
while (walkItr.hasNext()) {
int bitValue12 = 0;
bitValue12 += (walkItr.next().ordinal() << 9);
bitValue12 += (walkItr.next().ordinal() << 6);
bitValue12 += (walkItr.next().ordinal() << 3);
bitValue12 += (walkItr.next().ordinal() << 0);
outAdd(FourCornerDotCake.FC_SANDWALK_12.getStart() + bitValue12);
}
while (spiceItr.hasNext()) {
int bitValue15 = 0;
bitValue15 += (spiceItr.next().ordinal() << 12);
bitValue15 += (spiceItr.next().ordinal() << 9);
bitValue15 += (spiceItr.next().ordinal() << 6);
bitValue15 += (spiceItr.next().ordinal() << 3);
bitValue15 += (spiceItr.next().ordinal() << 0);
outAdd(FourCornerDotCake.FC_SANDWORM_15.getStart() + bitValue15);
}
}
outFlush();
}
}
static private class FourCornerWriterBereshit extends FourCornerWriterBaseVoid implements FourCornerZion7Bereshit {
public FourCornerWriterBereshit(IntConsumer out, Runnable outFlush, FCFlameStenoTongue outTongue) {
super(out, outFlush, outTongue);
}
@Override
public void strobeTheWord(FCFlameWordDish course, int cakePoint) {
if (cakePoint < outTongue.cakePointMin()) {
@ -317,50 +372,6 @@ public class FourCornerZionStenoGrapher {
outAddFremanCake9(type, type.octals()/3 - 1, value, v -> v = (v & 0x1F) + (taste.ordinal() << 5));
}
@Override
public void strobeSandWorm(List<PrimordialOctal> sandWalk, List<PrimordialOctal> sandSpice) {
Objects.requireNonNull(sandWalk);
Objects.requireNonNull(sandSpice);
if (!SAND_WORM_SIGNS.contains(sandWalk.size())) {
throw new IllegalArgumentException("Sand walk rhythm is not 72 bit aligned: " + sandWalk.size());
}
if (0 != (sandSpice.size() % 5)) {
throw new IllegalArgumentException("Sand spice is not 15 bit aligned: " + sandSpice.size());
}
Iterator<PrimordialOctal> walkItr = sandWalk.iterator();
Iterator<PrimordialOctal> spiceItr = sandSpice.iterator();
if (outTongue.isSixBit()) {
outAdd(FCDotDEC2701DashPX0.ESC6_SAND_WORM.cakePointDotIndex());
while (walkItr.hasNext()) {
outAdd(FCDotCDC1604DashP6.NX01_A.cakePointDotIndex() + walkItr.next().ordinal());
}
outAdd(FCDotCDC1604DashP6.NS05_RAKA1_UPQUESTION.cakePointDotIndex());
while (spiceItr.hasNext()) {
outAdd(FCDotCDC1604DashP6.NX01_A.cakePointDotIndex() + spiceItr.next().ordinal());
}
outAdd(FCDotCDC1604DashP6.NS04_RAKA1_INTERROBANG.cakePointDotIndex());
} else {
while (walkItr.hasNext()) {
int bitValue12 = 0;
bitValue12 += (walkItr.next().ordinal() << 9);
bitValue12 += (walkItr.next().ordinal() << 6);
bitValue12 += (walkItr.next().ordinal() << 3);
bitValue12 += (walkItr.next().ordinal() << 0);
outAdd(FourCornerDotCake.FC_SANDWALK_12.getStart() + bitValue12);
}
while (spiceItr.hasNext()) {
int bitValue15 = 0;
bitValue15 += (spiceItr.next().ordinal() << 12);
bitValue15 += (spiceItr.next().ordinal() << 9);
bitValue15 += (spiceItr.next().ordinal() << 6);
bitValue15 += (spiceItr.next().ordinal() << 3);
bitValue15 += (spiceItr.next().ordinal() << 0);
outAdd(FourCornerDotCake.FC_SANDWORM_15.getStart() + bitValue15);
}
}
outFlush();
}
@Override
public void strobeSalahSequence(FCFlameSalahSequence type, List<List<Integer>> arguments) {
Objects.requireNonNull(type);
@ -402,8 +413,13 @@ public class FourCornerZionStenoGrapher {
outAdd(FCDotCDC1604DashP6.NS04_RAKA1_INTERROBANG.baklavaPointDotIndex());
outFlush();
}
}
static private class FourCornerWriterCandlelier extends FourCornerWriterBereshit implements FourCornerZion7Candlelier {
// ----------------------------- END FC6
public FourCornerWriterCandlelier(IntConsumer out, Runnable outFlush, FCFlameStenoTongue outTongue) {
super(out, outFlush, outTongue);
}
@Override
public void strobeNumberGrams(FCFlameNumberGram gram, List<Integer> values) {
@ -492,5 +508,12 @@ public class FourCornerZionStenoGrapher {
});
}
}
static private class FourCornerWriterTempleScrolls extends FourCornerWriterCandlelier implements FourCornerZion7TempleScrolls {
public FourCornerWriterTempleScrolls(IntConsumer out, Runnable outFlush, FCFlameStenoTongue outTongue) {
super(out, outFlush, outTongue);
}
}
}

View file

@ -30,10 +30,16 @@ import org.x4o.fc18.cake2.FourCornerDotCake;
/// @version 1.0 Sep 6, 2025
public enum FCFlameStenoTongue {
/// Pure six bit baklave point word candy.
FC6 (FourCornerDotCake.FC_CDC1604_P6.getStart(), FourCornerDotCake.FC_CDC1604_P6.getStop()),
FC6_PLUS (FourCornerDotCake.FC_CDC1604_P6.getStart(), FourCornerDotCake.FC_PIE9D_27.getStop()), // 63 > auto esc to fc6
/// Big computer have extra ROM space for extra candy letters.
FC6_PLUS (FourCornerDotCake.FC_CDC1604_P6.getStart(), FourCornerDotCake.FC_PIE9D_27.getStop()),
/// Full range with all features
FC18 (FourCornerDotCake.FC_CDC1604_P6.getStart(), FourCornerDotCake.FC_CDC1604_P6.getStop()),
FC18_ADULT (FourCornerDotCake.FC_CLK1K_Z.getStop() + 1, FourCornerDotCake.FC_CDC1604_P6.getStop()), // no candy for adults
/// No candy for adults.
FC18_ADULT (FourCornerDotCake.FC_CLK1K_Z.getStop() + 1, FourCornerDotCake.FC_CDC1604_P6.getStop()),
/// Only adult worms are allowed in the desert of the real.
FC18_WORMS (FourCornerDotCake.FC_SANDWALK_12.getStart(), FourCornerDotCake.FC_SANDWORM_15.getStop()),
;
private static final FCFlameStenoTongue[] VALUES = values();