From bb9f63337984f8f6427286f7978ba384bda67eec Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Mon, 10 Aug 2020 17:51:29 -0500 Subject: [PATCH] Code rearrangement and cleaning. --- warehouse/main.c | 1044 +++++++++++++++++++++++----------------------- 1 file changed, 521 insertions(+), 523 deletions(-) diff --git a/warehouse/main.c b/warehouse/main.c index d4cfc03..04dc1fb 100644 --- a/warehouse/main.c +++ b/warehouse/main.c @@ -74,10 +74,30 @@ typedef struct CoordS { } CoordT; -static jlImgT *fontI = NULL; -static jlImgT *tilesI = NULL; -static jlImgT *aboutI = NULL; -static jlImgT *helpI = NULL; +const jint16 blockLeftX = ((byte)221 % 40) << 3; // Left-hand block ASCII +const jint16 blockLeftY = ((byte)221 / 40) << 3; +const jint16 blockRightX = ((byte)222 % 40) << 3; // Right-hand block ASCII +const jint16 blockRightY = ((byte)222 / 40) << 3; +const jint16 blockTopX = ((byte)223 % 40) << 3; // Top-half block ASCII +const jint16 blockTopY = ((byte)223 / 40) << 3; +const jint16 blockBottomX = ((byte)220 % 40) << 3; // Bottom-half block ASCII +const jint16 blockBottomY = ((byte)220 / 40) << 3; +const jint16 rightArrowsX = ((byte)175 % 40) << 3; // Right Arrows ASCII +const jint16 rightArrowsY = ((byte)175 / 40) << 3; +const jint16 spaceX = ((byte)32 % 40) << 3; // Space ASCII +const jint16 spaceY = ((byte)32 / 40) << 3; + +const char *menuOptions[] = { "Return to Game", "About", "How to Play", "Select Level", "Reset Level", "Exit", 0 }; +const char *menuYesNo[] = { "What? No!", "Yeah, I've had enough.", 0 }; +const char *menuReset[] = { "No! I didn't mean it!", "Yes, let me try again.", 0 }; + + +static jlImgT *fontI = NULL; +static jlImgT *tilesI = NULL; +static jlImgT *aboutI = NULL; +static jlImgT *helpI = NULL; +static jlImgT *savedScreen1 = NULL; +static jlImgT *savedScreen2 = NULL; static jint16 puzzleCount; static jint16 puzzleCurrent; @@ -104,7 +124,7 @@ static byte crateInitialCount; static byte cratesOnTarget; static byte cratesInitiallyOnTarget; -//static char puzzleChars[] = { "_# .$@+*" }; +static char puzzleChars[] = { "_# .$@+*" }; static CoordT tileLookup[TILE_COUNT] = { { 10 * 8, 0 }, @@ -118,53 +138,30 @@ static CoordT tileLookup[TILE_COUNT] = { }; -void countSolved(void); -void drawAvatar(void); -byte drawMenu(const char *title, const char *menuItems[], byte *height, byte *offsetX, byte *offsetY); -void drawPuzzle(void); -void forceFullRedraw(void); -void levelComplete(void); -void loadPuzzle(void); -bool mainMenu(void); -char menu(const char *title, const char *menuItems[], char selected); -void moveCrate(byte sx, byte sy, byte dx, byte dy); -void play(void); -void printAt(jlImgT *font, jint16 cx, jint16 cy, const char *what, ...); -bool readInput(byte *key); -void redraw(void); -void resetPuzzle(void); -void saveGame(void); -void selectLevel(void); -void showImage(jlImgT *image); -void showPalette(void); -void ticker(void); -void title(void); +void avatarDraw(void); +void crateMove(byte sx, byte sy, byte dx, byte dy); +void fontPrint(jlImgT *font, jint16 cx, jint16 cy, const char *what, ...); +void gamePlay(void); +void gameSave(void); +void imageShow(jlImgT *image); +bool inputRead(byte *key); +byte menuDraw(const char *titleShow, const char *menuItems[], byte *height, byte *offsetX, byte *offsetY); +char menuHandle(const char *titleShow, const char *menuItems[], char selected); +bool menuMain(void); +//void paletteShow(void); +void puzzleComplete(void); +void puzzleDraw(void); +void puzzleForceFullRedraw(void); +void puzzleLoad(void); +void puzzleRedraw(void); +void puzzleReset(void); +void puzzleSelect(void); +void solvedCount(void); +void tickerUpdate(void); +void titleShow(void); -void countSolved(void) { - byte data; - char bit = 0; - jint16 index = -1; - jint16 p; - - puzzleSolved = 0; - - // Count number of solved puzzles. - for (p=0; p 50) { + if (debounceController) return false; + *key = 'K'; + debounceController = true; + return true; + } + if (jlGameGetAxis(1) < -50) { + if (debounceController) return false; + *key = 'I'; + debounceController = true; + return true; + } + if (jlGameGetAxis(1) > 50) { + if (debounceController) return false; + *key = 'M'; + debounceController = true; + return true; + } + if (jlGameGetButton(0)) { + if (debounceController) return false; + *key = 13; + debounceController = true; + return true; + } + if (jlGameGetButton(1)) { + if (debounceController) return false; + *key = 27; + debounceController = true; + return true; + } + + debounceController = false; + */ + + return false; +} + + +byte menuDraw(const char *title, const char *menuItems[], byte *height, byte *offsetX, byte *offsetY) { jint16 count = 0; - jint16 lx = ((byte)221 % 40) << 3; // Left-hand block ASCII - jint16 ly = ((byte)221 / 40) << 3; - jint16 rx = ((byte)222 % 40) << 3; // Right-hand block ASCII - jint16 ry = ((byte)222 / 40) << 3; - jint16 tx = ((byte)223 % 40) << 3; // Top-half block ASCII - jint16 ty = ((byte)223 / 40) << 3; - jint16 bx = ((byte)220 % 40) << 3; // Bottom-half block ASCII - jint16 by = ((byte)220 / 40) << 3; jint16 x1; jint16 y1; jint16 x2; @@ -217,8 +454,8 @@ byte drawMenu(const char *title, const char *menuItems[], byte *height, byte *of x1 = *offsetX * 8; x2 = (*offsetX + width) * 8; for (y1=(*offsetY * 8); y1<(*offsetY + *height) * 8; y1+=8) { - jlDrawBlit8x8(jlImgSurfaceGet(fontI), rx, ry, x1, y1); - jlDrawBlit8x8(jlImgSurfaceGet(fontI), lx, ly, x2, y1); + jlDrawBlit8x8(jlImgSurfaceGet(fontI), blockRightX, blockRightY, x1, y1); + jlDrawBlit8x8(jlImgSurfaceGet(fontI), blockLeftX, blockLeftY, x2, y1); } // Draw horizontal lines. @@ -226,20 +463,20 @@ byte drawMenu(const char *title, const char *menuItems[], byte *height, byte *of y2 = (*offsetY + 4) * 8; y3 = (*offsetY + *height - 1) * 8; for (x1=(*offsetX + 1) * 8; x1<(*offsetX + width) * 8; x1+=8) { - jlDrawBlit8x8(jlImgSurfaceGet(fontI), tx, ty, x1, y1); - jlDrawBlit8x8(jlImgSurfaceGet(fontI), bx, by, x1, y2); - jlDrawBlit8x8(jlImgSurfaceGet(fontI), bx, by, x1, y3); + jlDrawBlit8x8(jlImgSurfaceGet(fontI), blockTopX, blockTopY, x1, y1); + jlDrawBlit8x8(jlImgSurfaceGet(fontI), blockBottomX, blockBottomY, x1, y2); + jlDrawBlit8x8(jlImgSurfaceGet(fontI), blockBottomX, blockBottomY, x1, y3); } x1 = (width / 2 - strlen(title) / 2) + *offsetX; - printAt(fontI, x1, *offsetY + 2, title); + fontPrint(fontI, x1, *offsetY + 2, title); // Draw menu. x1 = *offsetX + 4; y1 = *offsetY + 7; count = 0; while (menuItems[count]) { - printAt(fontI, x1, y1, menuItems[count]); + fontPrint(fontI, x1, y1, menuItems[count]); y1+=2; count++; } @@ -249,7 +486,175 @@ byte drawMenu(const char *title, const char *menuItems[], byte *height, byte *of } -void drawPuzzle(void) { +char menuHandle(const char *title, const char *menuItems[], char selected) { + byte count = 0; + byte inMenuYOffset = 7; + byte offsetX = 0; + byte offsetY = 0; + byte key; + byte height; + byte ox; + byte oy; + char result = -1; + bool inMenu = true; + jint16 xpos; + jint16 ypos; + jint16 last; + jint16 lastY; + + jlImgCreate(savedScreen1); + + ox = offsetX; + oy = offsetY; + + count = menuDraw(title, menuItems, &height, &ox, &oy); + + inMenuYOffset += oy; + xpos = (ox + 2) * 8; + ypos = (inMenuYOffset + (selected * 2)) * 8; + lastY = ypos; + last = (selected == 0 ? 1 : 0); + while (inMenu && !jlUtilMustExit()) { + if (inputRead(&key)) { + switch (key) { + case 27: + inMenu = false; + break; + + case 13: + result = selected; + inMenu = false; + break; + + case 'I': + case 'i': + if (selected > 0) { + selected--; + ypos -= 16; + } else { + selected = count - 1; + ypos = (inMenuYOffset + (count - 1) * 2) * 8; + } + break; + + case 'M': + case 'm': + if (selected < count - 1) { + selected++; + ypos += 16; + } else { + selected = 0; + ypos = inMenuYOffset * 8; + } + break; + } + } + if (selected != last) { + jlDrawBlit8x8(jlImgSurfaceGet(fontI), spaceX, spaceY, xpos, lastY); + jlDrawBlit8x8(jlImgSurfaceGet(fontI), rightArrowsX, rightArrowsY, xpos, ypos); + jlDisplayPresent(); + lastY = ypos; + last = selected; + } + tickerUpdate(); + } + + jlImgDisplay(savedScreen1); + jlDisplayPresent(); + + return result; +} + + +bool menuMain(void) { + bool running = true; + char choice = 0; + + while ((choice >= 0) && running && !jlUtilMustExit()) { + choice = menuHandle("Main Menu", menuOptions, choice); + switch (choice) { + case 0: // Return to Game + choice = -1; + break; + + case 1: // About + imageShow(aboutI); + break; + + case 2: // How to Play + imageShow(helpI); + break; + + case 3: // Select Level + puzzleSelect(); + if (puzzleLast != puzzleCurrent) { + // New puzzle selected, exit menu. + choice = -1; + } + break; + + case 4: // Reset Level + if (1 == menuHandle("Reset Level?", menuReset, 0)) { + puzzleReset(); + puzzleForceFullRedraw(); + choice = -1; + } + break; + + case 5: // Exit + running = (0 == menuHandle("Exit Game?", menuYesNo, 0)); + break; + } + } + + return running; +} + + +/* +void paletteShow(void) { + byte x; + for (x=0; x<16; x++) { + jlDrawColorSet(x); + jlDrawBoxFilled(x * 20, 179, x * 20 + 19, 199); + } +} +*/ + + +void puzzleComplete(void) { + char bit; + jint16 index; + + // Mark it solved. + index = puzzleCurrent - 1; + bit = 7 - (index % 8); + index /= 8; + saveGameData.solved[index] = saveGameData.solved[index] | (1 << bit); + + // Move to next puzzle. + puzzleCurrent++; + if (puzzleCurrent > puzzleCount) { + puzzleCurrent = 1; + } + + gameSave(); + + // Recount solves. + solvedCount(); + + // Is the game complete? + if (puzzleSolved == puzzleCount) { + // They did them all! + //***TODO*** + return; + } + + //***TODO*** +} + + +void puzzleDraw(void) { byte bx = 0; // Board coordinates. byte by = 0; jint16 x = 0; // Screen (tile) coordinates. @@ -274,45 +679,13 @@ void drawPuzzle(void) { } -void forceFullRedraw(void) { +void puzzleForceFullRedraw(void) { // Clear "displayed" board so it has to redraw. memset(&puzzleBefore, TILE_NOTHING, sizeof(byte) * MAX_WIDTH * MAX_HEIGHT); } -void levelComplete(void) { - char bit; - jint16 index; - - // Mark it solved. - index = puzzleCurrent - 1; - bit = 7 - (index % 8); - index /= 8; - saveGameData.solved[index] = saveGameData.solved[index] | (1 << bit); - - // Move to next puzzle. - puzzleCurrent++; - if (puzzleCurrent > puzzleCount) { - puzzleCurrent = 1; - } - - saveGame(); - - // Recount solves. - countSolved(); - - // Is the game complete? - if (puzzleSolved == puzzleCount) { - // They did them all! - //***TODO*** - return; - } - - //***TODO*** -} - - -void loadPuzzle(void) { +void puzzleLoad(void) { FILE *in = NULL; byte x = 0; byte y = 0; @@ -382,374 +755,19 @@ void loadPuzzle(void) { puzzle.offsetX = (10 - puzzle.width / 2) * 2; puzzle.offsetY = (6 - puzzle.height / 2) * 2; - resetPuzzle(); - forceFullRedraw(); + puzzleReset(); + puzzleForceFullRedraw(); } -bool mainMenu(void) { - const char *options[] = { "Return to Game", "About", "How to Play", "Select Level", "Reset Level", "Exit", 0 }; - const char *yesno[] = { "What? No!", "Yeah, I've had enough.", 0 }; - const char *reset[] = { "No! I didn't mean it!", "Yes, let me try again.", 0 }; - bool running = true; - char choice = 0; - - while ((choice >= 0) && running && !jlUtilMustExit()) { - choice = menu("Main Menu", options, choice); - switch (choice) { - case 0: // Return to Game - choice = -1; - break; - - case 1: // About - showImage(aboutI); - break; - - case 2: // How to Play - showImage(helpI); - break; - - case 3: // Select Level - selectLevel(); - if (puzzleLast != puzzleCurrent) { - // New puzzle selected, exit menu. - choice = -1; - } - break; - - case 4: // Reset Level - if (1 == menu("Reset Level?", reset, 0)) { - resetPuzzle(); - forceFullRedraw(); - choice = -1; - } - break; - - case 5: // Exit - running = (0 == menu("Exit Game?", yesno, 0)); - break; - } - } - - return running; -} - - -char menu(const char *title, const char *menuItems[], char selected) { - byte count = 0; - byte inMenuYOffset = 7; - byte key; - byte height; - byte ox; - byte oy; - byte offsetX = 0; - byte offsetY = 0; - char result = -1; - bool inMenu = true; - jint16 rx = ((byte)175 % 40) << 3; // Right Arrows ASCII - jint16 ry = ((byte)175 / 40) << 3; - jint16 sx = ((byte)32 % 40) << 3; // Space ASCII - jint16 sy = ((byte)32 / 40) << 3; - jint16 xpos; - jint16 ypos; - jint16 last; - jint16 lastY; - jlImgT *screen = NULL; - - jlImgCreate(screen); - - ox = offsetX; - oy = offsetY; - - count = drawMenu(title, menuItems, &height, &ox, &oy); - - inMenuYOffset += oy; - xpos = (ox + 2) * 8; - ypos = (inMenuYOffset + (selected * 2)) * 8; - lastY = ypos; - last = (selected == 0 ? 1 : 0); - while (inMenu && !jlUtilMustExit()) { - if (readInput(&key)) { - switch (key) { - case 27: - inMenu = false; - break; - - case 13: - result = selected; - inMenu = false; - break; - - case 'I': - case 'i': - if (selected > 0) { - selected--; - ypos -= 16; - } else { - selected = count - 1; - ypos = (inMenuYOffset + (count - 1) * 2) * 8; - } - break; - - case 'M': - case 'm': - if (selected < count - 1) { - selected++; - ypos += 16; - } else { - selected = 0; - ypos = inMenuYOffset * 8; - } - break; - } - } - if (selected != last) { - jlDrawBlit8x8(jlImgSurfaceGet(fontI), sx, sy, xpos, lastY); - jlDrawBlit8x8(jlImgSurfaceGet(fontI), rx, ry, xpos, ypos); - jlDisplayPresent(); - lastY = ypos; - last = selected; - } - ticker(); - } - - jlImgDisplay(screen); - jlDisplayPresent(); - jlImgFree(screen); - - return result; -} - - -void moveCrate(byte sx, byte sy, byte dx, byte dy) { - - if (puzzleNow[sx][sy] == TILE_CRATE) { - puzzleNow[sx][sy] = TILE_FLOOR; - } else { - puzzleNow[sx][sy] = TILE_GOAL; - cratesOnTarget--; - } - - if (puzzleNow[dx][dy] == TILE_FLOOR) { - puzzleNow[dx][dy] = TILE_CRATE; - } else { - puzzleNow[dx][dy] = TILE_CRATE_ON_GOAL; - cratesOnTarget++; - } - - // Did they win? - if (cratesOnTarget == crateCount) { - levelComplete(); - } -} - - -void play(void) { - byte key = 0; - bool playing = true; - byte tile = 0; - - // Show menu on entry - playing = mainMenu(); - - // Force tile palette - jlImgDisplay(tilesI); - jlDrawClear(); - - while (playing && !jlUtilMustExit()) { - if (readInput(&key)) { - avatarXLast = avatarX; - avatarYLast = avatarY; - switch (key) { - case 27: - playing = mainMenu(); - if (playing) { - redraw(); - } - break; - - case 'I': - case 'i': - // Can we move up? - tile = puzzleNow[avatarX][avatarY - 1]; - if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { - avatarY--; - } - // Can we push up? - if ((tile == TILE_CRATE) || (tile == TILE_CRATE_ON_GOAL)) { - tile = puzzleNow[avatarX][avatarY - 2]; - if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { - avatarY--; - moveCrate(avatarX, avatarY, avatarX, avatarY - 1); - } - } - break; - - case 'J': - case 'j': - // Can we move left? - tile = puzzleNow[avatarX - 1][avatarY]; - if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { - avatarX--; - } - // Can we push left? - if ((tile == TILE_CRATE) || (tile == TILE_CRATE_ON_GOAL)) { - tile = puzzleNow[avatarX - 2][avatarY]; - if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { - avatarX--; - moveCrate(avatarX, avatarY, avatarX - 1, avatarY); - } - } - break; - - case 'K': - case 'k': - // Can we move right? - tile = puzzleNow[avatarX + 1][avatarY]; - if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { - avatarX++; - } - // Can we push right? - if ((tile == TILE_CRATE) || (tile == TILE_CRATE_ON_GOAL)) { - tile = puzzleNow[avatarX + 2][avatarY]; - if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { - avatarX++; - moveCrate(avatarX, avatarY, avatarX + 1, avatarY); - } - } - break; - - case 'M': - case 'm': - // Can we move down? - tile = puzzleNow[avatarX][avatarY + 1]; - if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { - avatarY++; - } - // Can we push down? - if ((tile == TILE_CRATE) || (tile == TILE_CRATE_ON_GOAL)) { - tile = puzzleNow[avatarX][avatarY + 2]; - if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { - avatarY++; - moveCrate(avatarX, avatarY, avatarX, avatarY + 1); - } - } - break; - } - } - // Load new level? - if (puzzleLast != puzzleCurrent) { - puzzleLast = puzzleCurrent; - loadPuzzle(); - avatarXLast = -1; - avatarYLast = -1; - jlDrawClear(); - } - // Redraw? - if ((avatarX != avatarXLast) || (avatarY != avatarYLast)) { - puzzleBefore[avatarXLast][avatarYLast] = TILE_NOTHING; - redraw(); - } - ticker(); - } -} - - -// (Slow) Font Printing -__attribute__((__format__ (__printf__, 4, 0))) -void printAt(jlImgT *font, jint16 cx, jint16 cy, const char *what, ...) { - jint16 x; - jint16 y; - jint16 tx; - jint16 ty; - jint16 counter; - char msg[41]; // Very short messages (screen width). Be careful! - va_list va; - - va_start(va, what); - vsprintf(msg, what, va); - va_end(va); - - tx = cx << 3; - ty = cy << 3; - - for (counter=0; counter<(int)strlen(msg); counter++) { - x = ((byte)msg[counter] % 40) << 3; - y = ((byte)msg[counter] / 40) << 3; - jlDrawBlit8x8(jlImgSurfaceGet(font), x, y, tx, ty); - tx += 8; - } -} - - -bool readInput(byte *key) { - - //static bool debounceController = false; - - *key = 0; - - // Keyboard - if (jlKeyPressed()) { - while (jlKeyPressed()) { - *key = jlKeyRead(); - } - return true; - } - - /* - // Joystick - if (jlGameGetAxis(0) < -50) { - if (debounceController) return false; - *key = 'J'; - debounceController = true; - return true; - } - if (jlGameGetAxis(0) > 50) { - if (debounceController) return false; - *key = 'K'; - debounceController = true; - return true; - } - if (jlGameGetAxis(1) < -50) { - if (debounceController) return false; - *key = 'I'; - debounceController = true; - return true; - } - if (jlGameGetAxis(1) > 50) { - if (debounceController) return false; - *key = 'M'; - debounceController = true; - return true; - } - if (jlGameGetButton(0)) { - if (debounceController) return false; - *key = 13; - debounceController = true; - return true; - } - if (jlGameGetButton(1)) { - if (debounceController) return false; - *key = 27; - debounceController = true; - return true; - } - - debounceController = false; - */ - - return false; -} - - -void redraw(void) { - drawPuzzle(); - drawAvatar(); +void puzzleRedraw(void) { + puzzleDraw(); + avatarDraw(); jlDisplayPresent(); } -void resetPuzzle(void) { +void puzzleReset(void) { // Copy loaded puzzle data into playable data. memcpy(&puzzleNow, puzzle.puzzle, sizeof(byte) * MAX_WIDTH * MAX_HEIGHT); // Reset crate count. @@ -763,24 +781,7 @@ void resetPuzzle(void) { } -void saveGame(void) { - FILE *out = NULL; - - saveGameData.lastPuzzle = puzzleCurrent; - - // Save game. - out = fopen("data/save.dat", "wb"); - if (out) { - fwrite(&puzzleCount, sizeof(jint16), 1, out); - fwrite(&saveGameData.lastPuzzle, sizeof(jint16), 1, out); - fwrite(&saveGameData.solvedSize, sizeof(jint16), 1, out); - fwrite(saveGameData.solved, saveGameData.solvedSize, 1, out); - fclose(out); - } -} - - -void selectLevel(void) { +void puzzleSelect(void) { jint16 x; jint16 y; jint16 lastX; @@ -798,9 +799,8 @@ void selectLevel(void) { byte data; byte oldColor = jlDrawColorGet(); bool inMenu = true; - jlImgT *screen = NULL; - jlImgCreate(screen); + jlImgCreate(savedScreen2); jlPaletteSet( 0, 0, 0, 0); jlPaletteSet( 1, 0, 15, 0); @@ -845,14 +845,14 @@ void selectLevel(void) { } } - printAt(fontI, 0, 24, "Green are Completed. Red are Unsolved."); + fontPrint(fontI, 0, 24, "Green are Completed. Red are Unsolved."); p = puzzleCurrent; lastX = -1; lastY = -1; while (inMenu && !jlUtilMustExit()) { - if (readInput(&data)) { + if (inputRead(&data)) { avatarXLast = avatarX; avatarYLast = avatarY; switch (data) { @@ -928,53 +928,46 @@ void selectLevel(void) { jlDrawBox(x - 1, y - 1, x + 2, y + 2); lastX = x; lastY = y; - printAt(fontI, 6, 0, "Select Your Next Level: %d ", p); + fontPrint(fontI, 6, 0, "Select Your Next Level: %d ", p); jlDisplayPresent(); } } jlDrawColorSet(oldColor); - jlImgDisplay(screen); + jlImgDisplay(savedScreen2); jlDisplayPresent(); - jlImgFree(screen); } -void showImage(jlImgT *image) { - jlImgT *screen = NULL; - byte key; +void solvedCount(void) { + byte data; + char bit = 0; + jint16 index = -1; + jint16 p; - jlImgCreate(screen); + puzzleSolved = 0; - jlImgDisplay(image); - jlDisplayPresent(); - - while (!readInput(&key) && !jlUtilMustExit()) { - // Do nothing - } - - jlImgDisplay(screen); - jlDisplayPresent(); - - jlImgFree(screen); -} - - -void showPalette(void) { - byte x; - for (x=0; x<16; x++) { - jlDrawColorSet(x); - jlDrawBoxFilled(x * 20, 179, x * 20 + 19, 199); + // Count number of solved puzzles. + for (p=0; p