Skip to content

Commit

Permalink
feat: grid markup unknown_08 -> penciled
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Andrew Hyndman committed Nov 30, 2023
1 parent 84d31a4 commit 04d478b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -51,7 +51,7 @@ export const squareMarkupKeys = [
'incorrect',
'previouslyIncorrect',
'revealed',
'unknown_08',
'penciled',
'unknown_04',
'unknown_02',
'unknown_01',
Expand Down
6 changes: 3 additions & 3 deletions src/util/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -303,7 +303,7 @@ export function encodeMarkup({
incorrect,
previouslyIncorrect,
revealed,
unknown_08,
penciled,
unknown_04,
unknown_02,
unknown_01,
Expand All @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/binary/print.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down

0 comments on commit 04d478b

Please sign in to comment.