From 16c45b6ab046746d37eefc5dc40290283273887b Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Thu, 11 Mar 2021 20:36:37 -0600 Subject: [PATCH] I don't even know what I'm doing anymore. --- warehouse/main.c | 98 +++++++++++---------------------------------- warehouse/tiles.xcf | 3 -- 2 files changed, 23 insertions(+), 78 deletions(-) delete mode 100644 warehouse/tiles.xcf diff --git a/warehouse/main.c b/warehouse/main.c index 6b68446..64bf2d2 100644 --- a/warehouse/main.c +++ b/warehouse/main.c @@ -27,7 +27,6 @@ #include -#define JOEY_MAIN #include "joey.h" #ifdef JOEY_IIGS segment "warehouse"; @@ -197,7 +196,6 @@ 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); jint16 menuHandle(const char *titleShow, const char *menuItems[], jint16 selected); bool menuMain(void); @@ -245,7 +243,6 @@ void avatarCrateHide(byte x1, byte y1, bool pushing) { void avatarCrateShow(void) { - jlImgDisplay(savedScreen1); avatarDraw(AVATAR_X_ON_SCREEN, AVATAR_Y_ON_SCREEN, avatarFacing, 0); } @@ -542,23 +539,23 @@ void gamePlay(void) { byte tile = 0; while (playing && !jlUtilMustExit()) { - if (inputRead(&key)) { + if (jlUtilInputRead(&key)) { avatarXLast = avatarX; avatarYLast = avatarY; switch (key) { - case 27: + case JOEY_INPUT_SECONDARY: playing = menuMain(); break; - case 13: + case JOEY_INPUT_PRIMARY: + //paletteShow(); if (1 == menuHandle("Reset Level?", menuReset, 0)) { puzzleReset(); puzzleForceFullRedraw(); } break; - case 'I': - case 'i': + case JOEY_INPUT_UP: // Can we move up? tile = puzzleNow[avatarX][avatarY - 1]; if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { @@ -573,8 +570,7 @@ void gamePlay(void) { } break; - case 'J': - case 'j': + case JOEY_INPUT_LEFT: // Can we move left? tile = puzzleNow[avatarX - 1][avatarY]; if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { @@ -589,8 +585,7 @@ void gamePlay(void) { } break; - case 'K': - case 'k': + case JOEY_INPUT_RIGHT: // Can we move right? tile = puzzleNow[avatarX + 1][avatarY]; if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { @@ -605,8 +600,7 @@ void gamePlay(void) { } break; - case 'M': - case 'm': + case JOEY_INPUT_DOWN: // Can we move down? tile = puzzleNow[avatarX][avatarY + 1]; if ((tile == TILE_FLOOR) || (tile == TILE_GOAL)) { @@ -668,7 +662,7 @@ void imageShow(jlImgT *image) { jlImgDisplay(image); jlDisplayPresent(); - while (!inputRead(&key) && !jlUtilMustExit()) { + while (!jlUtilInputRead(&key) && !jlUtilMustExit()) { // Do nothing } @@ -677,44 +671,6 @@ void imageShow(jlImgT *image) { } -bool inputRead(byte *key) { - - static bool debounceController = false; - - *key = 0; - - // Keyboard - if (jlKeyPressed()) { - while (jlKeyPressed()) { - *key = jlKeyRead(); - } - return true; - } - - // Joystick - if (jlGameGetAxis(0) < -50) *key = 'J'; - if (jlGameGetAxis(0) > 50) *key = 'K'; - if (jlGameGetAxis(1) < -50) *key = 'I'; - if (jlGameGetAxis(1) > 50) *key = 'M'; - if (jlGameGetButton(0)) *key = 13; - if (jlGameGetButton(1)) *key = 27; - - // Debounce Joystick Input - if (debounceController) { - *key = 0; - return false; - } else { - if (*key != 0) { - 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; @@ -802,19 +758,18 @@ jint16 menuHandle(const char *title, const char *menuItems[], jint16 selected) { lastY = ypos; last = (selected == 0 ? 1 : 0); while (inMenu && !jlUtilMustExit()) { - if (inputRead(&key)) { + if (jlUtilInputRead(&key)) { switch (key) { - case 27: + case JOEY_INPUT_SECONDARY: inMenu = false; break; - case 13: + case JOEY_INPUT_PRIMARY: result = selected; inMenu = false; break; - case 'I': - case 'i': + case JOEY_INPUT_UP: if (selected > 0) { selected--; ypos -= 16; @@ -824,8 +779,7 @@ jint16 menuHandle(const char *title, const char *menuItems[], jint16 selected) { } break; - case 'M': - case 'm': + case JOEY_INPUT_DOWN: if (selected < count - 1) { selected++; ypos += 16; @@ -1139,22 +1093,21 @@ void puzzleSelect(void) { lastY = -1; while (inMenu && !jlUtilMustExit()) { - if (inputRead(&data)) { + if (jlUtilInputRead(&data)) { avatarXLast = avatarX; avatarYLast = avatarY; switch (data) { - case 27: + case JOEY_INPUT_SECONDARY: inMenu = false; break; - case 13: + case JOEY_INPUT_PRIMARY: // Actually loaded and redrawn in play loop. puzzleCurrent = p; inMenu = false; break; - case 'I': - case 'i': + case JOEY_INPUT_UP: // Case when we'll land in the 'dangling' line. if (p <= dangling) { p = puzzleCount - (dangling - p); @@ -1169,8 +1122,7 @@ void puzzleSelect(void) { } break; - case 'J': - case 'j': + case JOEY_INPUT_LEFT: if (p > 1) { p--; } else { @@ -1178,8 +1130,7 @@ void puzzleSelect(void) { } break; - case 'K': - case 'k': + case JOEY_INPUT_RIGHT: if (p < puzzleCount) { p++; } else { @@ -1187,8 +1138,7 @@ void puzzleSelect(void) { } break; - case 'M': - case 'm': + case JOEY_INPUT_DOWN: // Are we moving down from the 'dangling' line? if (p > (cols * (cols - 1))) { p = dangling - (puzzleCount - p); @@ -1308,14 +1258,14 @@ void titleShow(void) { } -int main(void) { +void joeyMain(void) { jint16 i = 0; jint16 j = 0; jint16 x = 0; jint16 y = 0; FILE *in = NULL; - jlUtilStartup("Warehouse"); + jlUtilTitleSet("Warehouse"); // Get something on the screen as quickly as possible. titleShow(); @@ -1410,6 +1360,4 @@ int main(void) { jlStnFree(tilesS); jlImgFree(tilesI); jlImgFree(fontI); - - jlUtilShutdown(); } diff --git a/warehouse/tiles.xcf b/warehouse/tiles.xcf deleted file mode 100644 index 1496896..0000000 --- a/warehouse/tiles.xcf +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9662463b983e4089bd77bacbcbbef4b7bca9e530113176251db27ad40cdfc09a -size 1423