diff --git a/.gitignore b/.gitignore index 9a87bea..d3dd896 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ build-*-Debug *.stn *.img *.sym +*.png +*.jpg diff --git a/warehouse/about.xcf b/warehouse/about.xcf index c807415..1606961 100644 --- a/warehouse/about.xcf +++ b/warehouse/about.xcf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:44a1c80f46ffc424f85b1a1791412d5a42d6a61e0953c452a1bf83979aebe1f1 -size 4327 +oid sha256:94203999c22ce47a0e0f29db0151964eec3fe7e5950850bc792cd8bd46399d2e +size 1973 diff --git a/warehouse/backgrnd.xcf b/warehouse/backgrnd.xcf deleted file mode 100644 index d378a60..0000000 --- a/warehouse/backgrnd.xcf +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4d57fc78efe117634e9504b9ebe1b77374c98923256f36ad2c8f11dd025e16f5 -size 130558 diff --git a/warehouse/build-IIgs.sh b/warehouse/build-IIgs.sh index 1dce9de..9805b56 100755 --- a/warehouse/build-IIgs.sh +++ b/warehouse/build-IIgs.sh @@ -1,7 +1,7 @@ #!/bin/bash -e PROJECT=Warehouse -DATA=(font.img kanga.img tiles.img backgrnd.img about.img play.img ../puzzles.dat ../index.dat) +DATA=(font.img kanga.img tiles.img title.img about.img help.img ../puzzles.dat ../index.dat) #SOURCE=(*.c *.h) SOURCE=() diff --git a/warehouse/help.xcf b/warehouse/help.xcf new file mode 100644 index 0000000..c3a69f7 --- /dev/null +++ b/warehouse/help.xcf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e4c29e99e04f948e96f7834f880e4c74270c5b6a84c6de7686029b8542df8631 +size 1646 diff --git a/warehouse/main.c b/warehouse/main.c index 7b6f6c1..3b7c850 100644 --- a/warehouse/main.c +++ b/warehouse/main.c @@ -70,9 +70,12 @@ typedef struct CoordS { static jlImgT *fontI = NULL; static jlImgT *tilesI = NULL; +static jlImgT *aboutI = NULL; +static jlImgT *helpI = NULL; static jint16 puzzleCount; static jint16 puzzleCurrent; +static jint16 puzzleLast; static jint32 *puzzleIndex = NULL; @@ -119,7 +122,7 @@ bool readInput(byte *key); void redraw(void); void resetPuzzle(void); void selectLevel(void); -void showImage(char *name); +void showImage(jlImgT *image); void showPalette(void); void ticker(void); void title(void); @@ -318,6 +321,8 @@ bool mainMenu(void) { bool running = true; char choice = 0; + //***TODO*** Reset disk? + while ((choice >= 0) && running && !jlUtilMustExit()) { choice = menu("Main Menu", options, choice, 0, 0, 0); switch (choice) { @@ -326,15 +331,19 @@ bool mainMenu(void) { break; case 1: // About - showImage("about"); + showImage(aboutI); break; case 2: // How to Play - showImage("play"); + showImage(helpI); break; case 3: // Select Level selectLevel(); + if (puzzleLast != puzzleCurrent) { + // New puzzle selected, exit menu. + choice = -1; + } break; case 4: // Reset Level @@ -372,7 +381,7 @@ char menu(char *title, char *menuItems[], char selected, byte width, byte offset jint16 ypos; jint16 last; jint16 lastY; - jlImgT *screen = NULL; //***TODO*** Maybe re-use tilesI to save RAM? + jlImgT *screen = NULL; jlImgCreate(screen); @@ -457,7 +466,6 @@ void moveCrate(byte sx, byte sy, byte dx, byte dy) { void play(void) { - jint16 last = 0; byte key = 0; bool playing = true; byte tile = 0; @@ -479,22 +487,6 @@ void play(void) { if (playing) redraw(); break; - case 'Q': //***REMOVE*** - case 'q': - puzzleCurrent--; - if (puzzleCurrent < 1) { - puzzleCurrent = puzzleCount; - } - break; - - case 'W'://***REMOVE*** - case 'w': - puzzleCurrent++; - if (puzzleCurrent >= puzzleCount) { - puzzleCurrent = 1; - } - break; - case 'I': case 'i': // Can we move up? @@ -564,9 +556,9 @@ void play(void) { break; } } - // Load new level? ***REMOVE*** - if (last != puzzleCurrent) { - last = puzzleCurrent; + // Load new level? + if (puzzleLast != puzzleCurrent) { + puzzleLast = puzzleCurrent; loadPuzzle(puzzleCurrent); avatarXLast = -1; avatarYLast = -1; @@ -651,21 +643,25 @@ void resetPuzzle(void) { void selectLevel(void) { - jint16 x; - jint16 y; - jint16 lastX; - jint16 lastY; - jint16 p; - jint16 c = 0; - jint16 index = -1;; - jint16 marginX = 16; - jint16 marginY = 16; - jint16 spacingX; - jint16 spacingY; - jint16 cols = (jint16)(sqrt(puzzleCount) + 0.5f); - char bit = 0; - byte data; - bool inMenu = true; + jint16 x; + jint16 y; + jint16 lastX; + jint16 lastY; + jint16 p; + jint16 c = 0; + jint16 index = -1; + jint16 marginX = 16; + jint16 marginY = 16; + jint16 spacingX; + jint16 spacingY; + jint16 cols = (jint16)(sqrt(puzzleCount) + 0.5f); + jint16 dangling = puzzleCount - (cols * (cols - 1)); + char bit = 0; + byte data; + bool inMenu = true; + jlImgT *screen = NULL; + + jlImgCreate(screen); jlPaletteSet( 0, 0, 0, 0); jlPaletteSet( 1, 0, 15, 0); @@ -710,6 +706,8 @@ void selectLevel(void) { } } + printAt(fontI, 0, 24, "Green are Completed. Red are Unsolved."); + p = puzzleCurrent; lastX = -1; lastY = -1; @@ -722,6 +720,62 @@ void selectLevel(void) { case 27: inMenu = false; break; + + case 13: + // Actually loaded and redrawn in play loop. + puzzleCurrent = p; + inMenu = false; + break; + + case 'I': + case 'i': + // Case when we'll land in the 'dangling' line. + if (p <= dangling) { + p = puzzleCount - (dangling - p); + } else { + // Moving from top to bottom but not into the 'dangling' line. + if (p <= cols) { + p = p - (cols + dangling) + 1; + } else { + // General case to move up a line. + p -= cols; + } + } + break; + + case 'J': + case 'j': + if (p > 1) { + p--; + } else { + p = puzzleCount; + } + break; + + case 'K': + case 'k': + if (p < puzzleCount) { + p++; + } else { + p = 1; + } + break; + + case 'M': + case 'm': + // Are we moving down from the 'dangling' line? + if (p > (cols * (cols - 1))) { + p = dangling - (puzzleCount - p); + } else { + // Moving from bottom to top but not from the 'dangling' line. + if (p > puzzleCount - cols) { + p = p + cols + dangling; + } else { + // General case to move down a line. + p += cols; + } + } + break; } } x = ((p - 1) % cols) * spacingX + marginX; @@ -735,25 +789,21 @@ 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); + jlDisplayPresent(); } } - printAt(fontI, 5, 0, "Select Your Next Level: %d ", p); - printAt(fontI, 0, 24, "Green are Completed. Red are Unsolved."); - - jlDisplayPresent(); - jlKeyWaitForAny(); + jlImgDisplay(screen); + jlImgFree(screen); } -void showImage(char *name) { +void showImage(jlImgT *image) { jlImgT *screen = NULL; - jlImgT *image = NULL; byte key; - //***TODO*** Maybe re-use tilesI to save RAM? jlImgCreate(screen); - if (!jlImgLoad(image, name)) jlUtilDie("Unable to open %s!", name); jlImgDisplay(image); jlDisplayPresent(); @@ -765,7 +815,6 @@ void showImage(char *name) { jlImgDisplay(screen); jlDisplayPresent(); - jlImgFree(image); jlImgFree(screen); } @@ -780,15 +829,16 @@ void showPalette(void) { void ticker(void) { - char *spinner = "/-\\|"; - static byte count = 0; - static jint16 last = 0; + char *spinner = "/-\\|"; + static byte count = 0; + static juint16 last = 0; printAt(fontI, 0, 24, "%d puzzles. Showing #%d. %d/%d %c ", - puzzleCount, puzzleCurrent, cratesOnTarget, crateCount, spinner[count++]); + puzzleCount, puzzleCurrent, cratesOnTarget, crateCount, spinner[count]); jlDisplayPresent(); if (jlUtilTimeSpan(last, jlUtilTimer()) > 3) { + count++; if (count > 3) count = 0; last = jlUtilTimer(); } @@ -797,7 +847,7 @@ void ticker(void) { void title(void) { - char *images[] = { "kanga", "backgrnd", 0 }; + char *images[] = { "kanga", "title", 0 }; byte count = 1; // CHANGE jlDrawColorSet(0); @@ -831,7 +881,9 @@ int main(void) { // Load the rest of our data. if (!jlImgLoad(tilesI, "tiles")) jlUtilDie("Unable to load tiles!"); - if (!jlImgLoad(fontI, "font")) jlUtilDie("Unable to load font!"); + if (!jlImgLoad(fontI, "font")) jlUtilDie("Unable to load font!"); + if (!jlImgLoad(aboutI, "about")) jlUtilDie("Unable to load about!"); + if (!jlImgLoad(helpI, "help")) jlUtilDie("Unable to load help!"); // Load the index. in = fopen("data/index.dat", "rb"); @@ -867,6 +919,8 @@ int main(void) { jlFree(saveGame.solved); jlFree(puzzleIndex); + jlImgFree(helpI); + jlImgFree(aboutI); jlImgFree(tilesI); jlImgFree(fontI); diff --git a/warehouse/play.xcf b/warehouse/play.xcf deleted file mode 100644 index 8413184..0000000 --- a/warehouse/play.xcf +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ec2390912c91f1e82b3136b5c26c76772219409fa247cd68d6b99fec7d0142cb -size 3346 diff --git a/warehouse/tiles.xcf b/warehouse/tiles.xcf index a934d1f..1496896 100644 --- a/warehouse/tiles.xcf +++ b/warehouse/tiles.xcf @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3b04e05bd9a07b19270a9c53b1430779f0e749f9a8fb36f979234eb4e5fa50ed -size 2506 +oid sha256:9662463b983e4089bd77bacbcbbef4b7bca9e530113176251db27ad40cdfc09a +size 1423 diff --git a/warehouse/title.xcf b/warehouse/title.xcf new file mode 100644 index 0000000..ab17950 --- /dev/null +++ b/warehouse/title.xcf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c796d6dad0d31983b0723f08d12bb15b2eac95fecda9ae579ff5b51b5a720e8c +size 44536 diff --git a/warehouse/updateImages.sh b/warehouse/updateImages.sh new file mode 100755 index 0000000..2105ac0 --- /dev/null +++ b/warehouse/updateImages.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +for IMAGE in *.xcf; do + echo Converting ${IMAGE}... + $JOEY/joeylib/scripts/xcf2img.sh ${IMAGE} +done