Added untested worm bit size check and added missing octal shifts

This commit is contained in:
Willem Cazander 2025-01-23 15:33:46 +01:00
parent 2179614b2a
commit 4dcba6b3d2

View file

@ -304,14 +304,16 @@ public class FourCornerZionStenoLexer {
if (lexer.sandwormSign) { if (lexer.sandwormSign) {
lexer.smokeSignals.burnSandWormSignUnused(lexer.sandwormSignLine, lexer.sandwormSignColumn); lexer.smokeSignals.burnSandWormSignUnused(lexer.sandwormSignLine, lexer.sandwormSignColumn);
} }
int bitSize = 0;
int bitIdxLast = 0; int bitIdxLast = 0;
int[] sandWalking = new int[576]; int[] sandWalking = new int[576];
for (int i = idxFirst; i <= idxLast; i++) { for (int i = idxFirst; i <= idxLast; i++) {
int bitIdx = lexer.input.get(i); int bitIdx = lexer.input.get(i);
if (bitIdx < bitIdxLast) { if (bitIdx != 0 && bitIdx < bitIdxLast) {
lexer.smokeSignals.burnSandWormSignOutOfOrder(lexer.currLine, lexer.currCol); lexer.smokeSignals.burnSandWormSignOutOfOrder(lexer.currLine, lexer.currCol);
return; return;
} }
bitSize++;
bitIdxLast = bitIdx; bitIdxLast = bitIdx;
int bitOff = bitIdx - FourCornerDotCake.FC_SAND_OLGOI.getStart(); int bitOff = bitIdx - FourCornerDotCake.FC_SAND_OLGOI.getStart();
sandWalking[bitOff] = 1; sandWalking[bitOff] = 1;
@ -320,7 +322,12 @@ public class FourCornerZionStenoLexer {
PrimitiveIterator.OfInt i = Arrays.stream(sandWalking).iterator(); PrimitiveIterator.OfInt i = Arrays.stream(sandWalking).iterator();
int octalIdx = 2; int octalIdx = 2;
int octalValue = 0; int octalValue = 0;
int bitSizeCounter = 0;
while (i.hasNext()) { while (i.hasNext()) {
if (bitSizeCounter > bitSize) {
break; // the sand walk bit pulses are always full size
}
bitSizeCounter++;
int bitValue = i.nextInt(); int bitValue = i.nextInt();
octalValue += bitValue << octalIdx; octalValue += bitValue << octalIdx;
if (octalIdx > 0) { if (octalIdx > 0) {
@ -366,21 +373,21 @@ public class FourCornerZionStenoLexer {
int octal2 = 0; int octal2 = 0;
int octal1 = 0; int octal1 = 0;
int octal0 = 0; int octal0 = 0;
octal4 += (bitValue15 >> 14) & 0b1; octal4 += ((bitValue15 >> 14) & 0b1) << 2;
octal4 += (bitValue15 >> 13) & 0b1; octal4 += ((bitValue15 >> 13) & 0b1) << 1;
octal4 += (bitValue15 >> 12) & 0b1; octal4 += ((bitValue15 >> 12) & 0b1) << 0;
octal3 += (bitValue15 >> 11) & 0b1; octal3 += ((bitValue15 >> 11) & 0b1) << 2;
octal3 += (bitValue15 >> 10) & 0b1; octal3 += ((bitValue15 >> 10) & 0b1) << 1;
octal3 += (bitValue15 >> 9) & 0b1; octal3 += ((bitValue15 >> 9) & 0b1) << 0;
octal2 += (bitValue15 >> 8) & 0b1; octal2 += ((bitValue15 >> 8) & 0b1) << 2;
octal2 += (bitValue15 >> 7) & 0b1; octal2 += ((bitValue15 >> 7) & 0b1) << 1;
octal2 += (bitValue15 >> 6) & 0b1; octal2 += ((bitValue15 >> 6) & 0b1) << 0;
octal1 += (bitValue15 >> 5) & 0b1; octal1 += ((bitValue15 >> 5) & 0b1) << 2;
octal1 += (bitValue15 >> 4) & 0b1; octal1 += ((bitValue15 >> 4) & 0b1) << 1;
octal1 += (bitValue15 >> 3) & 0b1; octal1 += ((bitValue15 >> 3) & 0b1) << 0;
octal0 += (bitValue15 >> 2) & 0b1; octal0 += ((bitValue15 >> 2) & 0b1) << 2;
octal0 += (bitValue15 >> 1) & 0b1; octal0 += ((bitValue15 >> 1) & 0b1) << 1;
octal0 += (bitValue15 >> 0) & 0b1; octal0 += ((bitValue15 >> 0) & 0b1) << 0;
wormBody.add(octal4); wormBody.add(octal4);
wormBody.add(octal3); wormBody.add(octal3);
wormBody.add(octal2); wormBody.add(octal2);