aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-08-11 21:04:54 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-08-11 21:04:54 +0100
commit43503cfa510a7f7e650efccaac266d7cc6657a5d (patch)
treef0fc2a9b480f413f8f0bab25bd97170b17a794b8
parentcd2296358a03ab9ca4d6c017262735eaa63b5fdb (diff)
downloadgold-mine-run-43503cfa510a7f7e650efccaac266d7cc6657a5d.tar.gz
gold-mine-run-43503cfa510a7f7e650efccaac266d7cc6657a5d.zip
Better koystick support1.2
-rw-r--r--src/game.c9
-rw-r--r--src/joy.c20
-rw-r--r--src/main.c2
-rw-r--r--src/menu.c12
4 files changed, 32 insertions, 11 deletions
diff --git a/src/game.c b/src/game.c
index c2420ca..67c6ffe 100644
--- a/src/game.c
+++ b/src/game.c
@@ -382,8 +382,15 @@ update_menu:
goto update_menu;
}
- if (keys[KEY_ENTER])
+ if (keys[KEY_ENTER] || (ctl & CTL_FIRE1))
+ {
+ while (keys[KEY_ENTER] || (ctl & CTL_FIRE1))
+ {
+ ctl = control_read();
+ wait_vsync();
+ }
break;
+ }
}
wait_vsync();
diff --git a/src/joy.c b/src/joy.c
index cda2fcf..4910f16 100644
--- a/src/joy.c
+++ b/src/joy.c
@@ -66,6 +66,10 @@ uint8_t joy_detect()
printf("Joystick detected!\n");
+ uint16_t cx, cy;
+ printf("Please center the joystick and press BUTTON 1 (ESC to abort)\n");
+ if (!calibrate(&cy, &cx))
+ return 0;
printf("Please move UP + LEFT and press BUTTON 1 (ESC to abort)\n");
if (!calibrate(&j_up, &j_left))
return 0;
@@ -78,10 +82,10 @@ uint8_t joy_detect()
j_up, j_down, j_left, j_right);
#endif
- j_up += j_up >> 4;
- j_down -= j_down >> 4;
- j_left += j_left >> 4;
- j_right -= j_right >> 4;
+ j_up = cy - ((cy - j_up) / 2);
+ j_down = cy + ((j_down - cy) / 2);
+ j_left = cx - ((cx - j_left) / 2);
+ j_right = cx + ((j_right - cx) / 2);
#ifdef DEBUG
printf(" Adjusted: up=%04d, down=%04d, left=%04d, right=%04d\n",
@@ -108,15 +112,15 @@ uint8_t joy_read()
r |= CTL_FIRE2;
v = read_axis(AXISY);
- if (v <= j_up)
+ if (v < j_up)
r |= CTL_UP;
- if (v >= j_down)
+ if (v > j_down)
r |= CTL_DOWN;
v = read_axis(AXISX);
- if (v <= j_left)
+ if (v < j_left)
r |= CTL_LEFT;
- if (v >= j_right)
+ if (v > j_right)
r |= CTL_RIGHT;
return r;
diff --git a/src/main.c b/src/main.c
index 9e1a678..9140bdf 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,7 +14,7 @@
#include "game.h"
#define GAME_NAME "Gold Mine Run!"
-#define GAME_VERSION "1.1 (2023-08-10)"
+#define GAME_VERSION "1.2 (2023-08-11)"
#define GAME_URL "https://www.usebox.net/jjm/gold-mine-run/"
/* disable paging because our int handlers are written in C */
diff --git a/src/menu.c b/src/menu.c
index 77b9f2b..5a459e8 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include "keyb.h"
+#include "control.h"
#include "vga.h"
#include "sound.h"
#include "text.h"
@@ -77,15 +78,24 @@ uint8_t run_menu()
uint16_t count = 0;
uint8_t cast = 0;
uint8_t wait;
+ uint8_t ctl;
blit_target(TARGET_SCREEN);
while (1)
{
+ ctl = control_read();
+
if (keys[KEY_ESC])
return 0;
- if (keys[KEY_SPACE])
+ if (keys[KEY_SPACE] || (ctl & CTL_FIRE1))
{
+ while (keys[KEY_SPACE] || (ctl & CTL_FIRE1))
+ {
+ ctl = control_read();
+ wait_vsync();
+ }
+
sound_play_efx(EFX_ONEUP);
for (uint8_t i = 0; i < 32; i++)