From 04d478b9ffb0bf54e1ed11f8e3a0b238df9eecc8 Mon Sep 17 00:00:00 2001 From: Andrew Hyndman Date: Wed, 29 Nov 2023 19:53:26 -0500 Subject: [PATCH] feat: grid markup unknown_08 -> penciled I have been able to identify that AcrossLite uses this flag to record when a cell has been filled in using pencil mode. As such, it makes sense to clarify the intent in our JSON representation. --- src/util/constants.ts | 4 ++-- src/util/misc.ts | 6 +++--- test/__snapshots__/index.test.ts.snap | 18 +++++++++--------- test/binary/print.test.ts | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/util/constants.ts b/src/util/constants.ts index 423436b..aa82b73 100644 --- a/src/util/constants.ts +++ b/src/util/constants.ts @@ -32,7 +32,7 @@ export enum SQUARE_MARKUP_BITMASK { REVEALED = 0x40, INCORRECT = 0x20, PREVIOUSLY_INCORRECT = 0x10, - UNKNOWN_08 = 0x08, + PENCILED = 0x08, UNKNOWN_04 = 0x04, UNKNOWN_02 = 0x02, UNKNOWN_01 = 0x01, @@ -51,7 +51,7 @@ export const squareMarkupKeys = [ 'incorrect', 'previouslyIncorrect', 'revealed', - 'unknown_08', + 'penciled', 'unknown_04', 'unknown_02', 'unknown_01', diff --git a/src/util/misc.ts b/src/util/misc.ts index 36066af..0e69590 100644 --- a/src/util/misc.ts +++ b/src/util/misc.ts @@ -284,7 +284,7 @@ export function decodeMarkup(byte: number): SquareMarkup { if ((byte & SQUARE_MARKUP_BITMASK.PREVIOUSLY_INCORRECT) !== 0) markupObject.previouslyIncorrect = true; if ((byte & SQUARE_MARKUP_BITMASK.REVEALED) !== 0) markupObject.revealed = true; - if ((byte & SQUARE_MARKUP_BITMASK.UNKNOWN_08) !== 0) markupObject.unknown_08 = true; + if ((byte & SQUARE_MARKUP_BITMASK.PENCILED) !== 0) markupObject.penciled = true; if ((byte & SQUARE_MARKUP_BITMASK.UNKNOWN_04) !== 0) markupObject.unknown_04 = true; if ((byte & SQUARE_MARKUP_BITMASK.UNKNOWN_02) !== 0) markupObject.unknown_02 = true; if ((byte & SQUARE_MARKUP_BITMASK.UNKNOWN_01) !== 0) markupObject.unknown_01 = true; @@ -303,7 +303,7 @@ export function encodeMarkup({ incorrect, previouslyIncorrect, revealed, - unknown_08, + penciled, unknown_04, unknown_02, unknown_01, @@ -313,7 +313,7 @@ export function encodeMarkup({ (incorrect ? SQUARE_MARKUP_BITMASK.INCORRECT : 0) + (previouslyIncorrect ? SQUARE_MARKUP_BITMASK.PREVIOUSLY_INCORRECT : 0) + (revealed ? SQUARE_MARKUP_BITMASK.REVEALED : 0) + - (unknown_08 ? SQUARE_MARKUP_BITMASK.UNKNOWN_08 : 0) + + (penciled ? SQUARE_MARKUP_BITMASK.PENCILED : 0) + (unknown_04 ? SQUARE_MARKUP_BITMASK.UNKNOWN_04 : 0) + (unknown_02 ? SQUARE_MARKUP_BITMASK.UNKNOWN_02 : 0) + (unknown_01 ? SQUARE_MARKUP_BITMASK.UNKNOWN_01 : 0) diff --git a/test/__snapshots__/index.test.ts.snap b/test/__snapshots__/index.test.ts.snap index ed4f89b..7e697c3 100644 --- a/test/__snapshots__/index.test.ts.snap +++ b/test/__snapshots__/index.test.ts.snap @@ -6344,35 +6344,35 @@ Object { "isScrambled": false, "markupGrid": Array [ Object { - "unknown_08": true, + "penciled": true, }, Object { - "unknown_08": true, + "penciled": true, }, Object { "incorrect": true, - "unknown_08": true, + "penciled": true, }, Object { - "unknown_08": true, + "penciled": true, }, Object { + "penciled": true, "previouslyIncorrect": true, - "unknown_08": true, }, Object { "incorrect": true, - "unknown_08": true, + "penciled": true, }, Object { - "unknown_08": true, + "penciled": true, }, Object { - "unknown_08": true, + "penciled": true, }, Object { "circled": true, - "unknown_08": true, + "penciled": true, }, ], "misc": Object { diff --git a/test/binary/print.test.ts b/test/binary/print.test.ts index b012597..38b9c9d 100644 --- a/test/binary/print.test.ts +++ b/test/binary/print.test.ts @@ -20,7 +20,7 @@ describe('printBinaryFile', () => { it('prints a puzzle with a sparse markupGrid', () => { const markupGrid: SquareMarkup[] = []; markupGrid.length = MINIMAL_PUZZLE.solution.length; - markupGrid[4] = { unknown_08: true }; + markupGrid[4] = { penciled: true }; expect(() => printBinaryFile({ ...MINIMAL_PUZZLE, markupGrid })).not.toThrow(); });