Fix key handling and make the background switching less annoying

This commit is contained in:
Lucas Scharenbroich 2022-07-27 07:46:16 -05:00
parent 843203059c
commit 05d3f42abc

View File

@ -15,6 +15,8 @@ typedef struct PString {
char text[32];
} PString;
#define SPRITE_START_TILE 2
PString toolPath = {9, "1/Tool160" };
void LoadGTEToolSet(Word userId) {
@ -40,7 +42,7 @@ int main (void) {
Word dpWord;
Word x = 0, y = 0;
Word px = 0, py = 0;
Word sec, lastSec = 0;
Word sec;
TLStartUp();
TOOLFAIL("Unable to start tool locator");
@ -77,7 +79,7 @@ int main (void) {
GTESetPalette(0, (Pointer)palette);
GTEFillTileStore(1);
GTECreateSpriteStamp(GTE_SPRITE_8X8|2, SPRITE_VBUFF);
GTECreateSpriteStamp(GTE_SPRITE_8X8 | SPRITE_START_TILE, SPRITE_VBUFF);
GTEAddSprite(SPRITE_SLOT, 0, SPRITE_VBUFF, px, py);
do {
@ -85,46 +87,35 @@ int main (void) {
keyPress = controlMask & 0x007F;
switch (keyPress) {
case 'a': if (x > 0) {
x--;
case ' ': // Toggle background
sec = GTEGetSeconds();
GTEFillTileStore(1 + (sec & 1));
break;
}
case 'd': if (x < 1000) {
x++;
case 'a': if (x > 0) { x--; }
break;
}
case 'w': if (y > 0) {
y--;
case 'd': if (x < 1000) { x++; }
break;
}
case 's': if (y < 1000) {
y++;
case 'w': if (y > 0) { y--; }
break;
case 's': if (y < 1000) { y++; }
break;
}
case 'j': if (px > 0) {
px--;
case 'j': if (px > 0) { px--; }
break;
}
case 'l': if (px < 154) {
px++;
break;
}
case 'i': if (py > 0) {
py--;
break;
}
case 'k': if (py < 192) {
py++;
break;
}
}
sec = GTEGetSeconds();
if (sec != lastSec) {
lastSec = sec;
GTEFillTileStore(1 + (lastSec & 1));
case 'l': if (px < 154) { px++; }
break;
case 'i': if (py > 0) { py--; }
break;
case 'k': if (py < 192) { py++; }
break;
}
GTESetBG0Origin(x, y);