OVR: Smoothly pitch craft if flying over planet, also change stick responses
authorAndreas Eversberg <jolly@eversberg.eu>
Fri, 27 Apr 2018 14:53:29 +0000 (16:53 +0200)
committerAndreas Eversberg <jolly@eversberg.eu>
Fri, 27 Apr 2018 19:21:17 +0000 (21:21 +0200)
src/mercenary/main.c
src/mercenary/mercenary.h
src/mercenary/mercenary2.c
src/mercenary/mercenary3.c

index 2f7d314..b6aba1f 100644 (file)
@@ -49,9 +49,9 @@
 #define FOV_JOLLY      80.0
 #define FOV_MAX                170.0
 
-#define STICK_WALK_THRESHOLD 0.2 /* move the stick until the player moves */
-#define STICK_ROTATE_THRESHOLD 0.2 /* move the stick until the player rotates */
-#define STICK_THRUST_THRESHOLD 0.2 /* move the stick until the craft moves */
+#define STICK_WALK_THRESHOLD 0.3 /* move the stick until the player moves */
+#define STICK_ROTATE_THRESHOLD 0.3 /* move the stick until the player rotates */
+#define STICK_THRUST_THRESHOLD 0.3 /* move the stick until the craft moves */
 
 static int config_ctrl_c = 0;
 static int config_amiga_speed = 0; /* fast speed */
@@ -480,10 +480,12 @@ static void handle_vr_poses(void)
                move_east[1] -= move_east[0];
                move_north[1] -= move_north[0];
                /* the game takes 4 steps to move the player */
-               mercenary_vr_move(1, move_east, move_north);
+               mercenary_vr_move(1, move_east, move_north,
+                       256,
+                       (int)(256.0 * fabs(stick_right_y) - STICK_WALK_THRESHOLD / (1.0 - STICK_WALK_THRESHOLD) + 0.5));
        } else {
                /* don't change what the game actually does when moving joystick in y-direction */
-               mercenary_vr_move(0, NULL, NULL);
+               mercenary_vr_move(0, NULL, NULL, 256, 256);
        }
 }
 #endif
index bcabc3f..78674d4 100644 (file)
@@ -70,6 +70,7 @@ struct vr_move {
        int index;
        int32_t east[4];
        int32_t north[4];
+       int yaw, pitch;
 };
 
 extern const struct cpu_stop mercenary_stop_at[];
@@ -94,7 +95,7 @@ uint16_t mercenary_poly_tags_color(void);
 int mercenary_background_index(void);
 uint32_t mercenary_planet_scale_index(void);
 uint32_t mercenary_star_table(void);
-void mercenary_vr_move(int override, int32_t *east, int32_t *north);
+void mercenary_vr_move(int override, int32_t *east, int32_t *north, int yaw, int pitch);
 extern const char *mercenary_name;
 extern const char *mercenary_gamesavesuffix;
 
index 74d9c29..e1246d1 100644 (file)
@@ -112,7 +112,9 @@ const struct cpu_stop mercenary_stop_at[] = {
        { 0x528C4,      STOP_AT_PATCH_RENDER },                 /* patch away planet check (behind observer) */
        { 0x45806,      STOP_AT_PATCH_RENDER },                 /* patch away planet rendering (would crash without check above) */
        { 0x53276,      STOP_AT_PATCH_RENDER },                 /* patch away beacon check (not visible on screen) */
-       { 0x58EA8,      STOP_AT_PATCH_VR },                     /* step that moves player */
+       { 0x58EA8,      STOP_AT_PATCH_VR },                     /* step that moves player on surface */
+       { 0x58060,      STOP_AT_PATCH_VR },                     /* soft pitch over planet */
+       { 0x58918,      STOP_AT_PATCH_VR },                     /* soft pitch in space */
        { 0x0,          STOP_AT_END },                          /* end */
 };
 
@@ -201,6 +203,11 @@ void mercenary_patch_vr(void)
                        vr_move.index++;
                }
                break;
+       case 0x58060: /* soft pitch over surface */
+               if (vr_move.override) {
+                       REG_D[1] = ((int16_t)REG_D[1] * vr_move.pitch / 256) & 0xfff;
+               }
+               break;
        }
 }
 
@@ -324,15 +331,18 @@ uint32_t mercenary_star_table(void)
        return 0x005D8C0;
 }
 
-void mercenary_vr_move(int override, int32_t *east, int32_t *north)
+void mercenary_vr_move(int override, int32_t *east, int32_t *north, int yaw, int pitch)
 {
        vr_move.override = override;
        if (east)
                memcpy(vr_move.east, east, sizeof(vr_move.east));
        if (north)
                memcpy(vr_move.north, north, sizeof(vr_move.north));
+       vr_move.yaw = yaw;
+       vr_move.pitch = pitch;
        vr_move.index = 0;
 }
+
 const char *mercenary_name = "Mercenary II - Damocles";
 const char *mercenary_gamesavesuffix = ".m2save";
 
index 9afd60b..9532597 100644 (file)
@@ -118,7 +118,9 @@ const struct cpu_stop mercenary_stop_at[] = {
        { 0x537B0,      STOP_AT_PATCH_RENDER },                 /* patch away planet check (behind observer) */
        { 0x45806,      STOP_AT_PATCH_RENDER },                 /* patch away planet rendering (would crash without check above) */
        { 0x5406E,      STOP_AT_PATCH_RENDER },                 /* patch away beacon check (not visible on screen) */
-       { 0x59A00,      STOP_AT_PATCH_VR },                     /* step that moves player */
+       { 0x59A00,      STOP_AT_PATCH_VR },                     /* step that moves player on surface */
+       { 0x58F44,      STOP_AT_PATCH_VR },                     /* soft pitch over planet */
+       { 0x5946E,      STOP_AT_PATCH_VR },                     /* soft pitch in space */
        { 0x0,          STOP_AT_END },                          /* end */
 };
 
@@ -237,6 +239,19 @@ void mercenary_patch_vr(void)
                        vr_move.index++;
                }
                break;
+       case 0x58F44: /* soft pitch over surface */
+               if (vr_move.override) {
+                       REG_D[1] = ((int16_t)REG_D[1] * vr_move.pitch / 256) & 0xfff;
+               }
+               break;
+#if 0
+       case 0x5946E: /* pitch in space doesn't work! */
+               if (vr_move.override) {
+                       REG_D[1] = ((int32_t)REG_D[1] * vr_move.pitch / 256) & 0xffffff00;
+                       printf("unten factor %d reg_d1 = %d\n", vr_move.pitch, (int32_t)REG_D[1]);
+               }
+               break;
+#endif
        }
 }
 
@@ -363,13 +378,15 @@ uint32_t mercenary_star_table(void)
        return DS_84+0x6A;
 }
 
-void mercenary_vr_move(int override, int32_t *east, int32_t *north)
+void mercenary_vr_move(int override, int32_t *east, int32_t *north, int yaw, int pitch)
 {
        vr_move.override = override;
        if (east)
                memcpy(vr_move.east, east, sizeof(vr_move.east));
        if (north)
                memcpy(vr_move.north, north, sizeof(vr_move.north));
+       vr_move.yaw = yaw;
+       vr_move.pitch = pitch;
        vr_move.index = 0;
 }