#include "../libovr/ovr.h"
#include "../libovr/keyboard.h"
#endif
-#include "../libsdl/opengl.h"
+#include "../libopengl/opengl.h"
#include "../libsdl/print.h"
#include "../libcpu/m68k.h"
#include "../libcpu/execute.h"
static int config_ctrl_c = 0;
static int config_amiga_speed = 0; /* fast speed */
-static double config_fps = 16.0;
+static double config_fps = 10.0;
#if !defined(_WIN32)
static const char *config_gamesave_dir = ".mercenary";
#endif
static int config_skip_intro = 0;
static int config_multisampling = 8;
#ifdef HAVE_OVR
-static double config_benson_size = 0.5;
+static double config_benson_size = 0.7;
static double config_fov = FOV_JOLLY;
#else
static double config_benson_size = 1.0;
#endif
static double config_monitor_distance = 41.5; /* inch */
#ifdef HAVE_OVR
-static double config_keyboard_distance = 40.5; /* inch */
+static double config_keyboard_distance = 38.5; /* inch */
static double config_keyboard_height = -26.0; /* inch */
#endif
static int config_debug_transparent = 0;
static uint8_t *info_osd = NULL;
static int help_view = 1;
static int help_views = 0;
-static int32_t osd_timer = 0;
+static int32_t osd_timer = 0, border_timer = 0;
#ifdef HAVE_OVR
#define SCREEN_WIDTH 1344
#define SCREEN_HEIGHT 800
{
window_width = width;
window_height = height;
+ border_timer = ticks_sdl() + 1500;
+ osd_info("", "window resized");
}
#ifdef HAVE_OVR
static int joystick_set_x_last = 0, joystick_set_y_last = 0;
static int keyboard_on = 0;
static enum keycode vr_key_pressed = 0, vr_key = 0;
+static int we_walk = 0, we_rotate = 0;
static void handle_vr_poses(void)
{
vr_key_pressed = vr_key;
set_amiga_key(vr_key_pressed, 1);
}
- } else
- if (mercenary_get_info_walking()) {
- /* change orientation */
- double roll, pitch, yaw;
- mercenary_get_orientation(&roll, &pitch, &yaw);
- mercenary_set_orientation(yaw + hand_right_yaw);
} else {
/* fire button */
set_joystick(-1, -1, -1, -1, 1);
}
} else {
double roll, pitch, yaw;
- double dist, dir, east, north;
+ double tilt, dir, east, north;
int32_t move_east[4], move_north[4];
- /* check if we push the stick */
- dist = sqrt(stick_right_x * stick_right_x + stick_right_y * stick_right_y);
- if (dist > STICK_WALK_THRESHOLD) {
+ tilt = sqrt(stick_right_x * stick_right_x + stick_right_y * stick_right_y);
+
+ /* check if we rotate, walk or rest */
+ if (we_rotate == 0 && we_walk == 0) {
+ /* we rest */
+ if (fabs(stick_right_y) > fabs(stick_right_x) && tilt > STICK_WALK_THRESHOLD)
+ we_walk = 1;
+ if (fabs(stick_right_x) > fabs(stick_right_y) && tilt > STICK_ROTATE_THRESHOLD)
+ we_rotate = 1;
+ } else if (we_walk) {
+ /* we walk */
+ if (tilt < STICK_WALK_THRESHOLD) {
+ we_walk = 0;
+ /* we need to stop right here and not continue until next rendering */
+ set_joystick(-1, -1, 0, 0, -1); /* stop y */
+ reset_joystick(); /* commit stop */
+ }
+ } else {
+ /* we rotate */
+ if (tilt < STICK_ROTATE_THRESHOLD)
+ we_rotate = 0;
+ }
+
+ /* if we walk */
+ if (we_walk) {
/* get stick amplitude (dist) and direction (dir) */
- if (dist > 1.0)
- dist = 1.0;
- dist = (dist - STICK_WALK_THRESHOLD) / (1.0 - STICK_WALK_THRESHOLD) * 40.0;
+ if (tilt > 1.0)
+ tilt = 1.0;
+ tilt = (tilt - STICK_WALK_THRESHOLD) / (1.0 - STICK_WALK_THRESHOLD) * 40.0;
dir = atan2(stick_right_x, stick_right_y);
+#if 0
/* use hand direction to get actual stick direction */
dir = fmod(dir - hand_right_yaw, M_PI * 2.0);
if (dir < -M_PI)
dir += M_PI * 2.0;
if (dir > M_PI)
dir -= M_PI * 2.0;
- /* flip directin, if we walk backwards */
+#endif
+ /* flip direction, if we walk backwards */
if (dir > M_PI / 2.0 || dir < -M_PI / 2.0) {
/* go backwards */
set_joystick(-1, -1, 0, 1, -1);
set_joystick(-1, -1, 1, 0, -1);
joystick_set_y = 1;
}
- joystick_set_y = 1;
mercenary_get_orientation(&roll, &pitch, &yaw);
- east = sin(yaw - dir + M_PI) * dist;
- north = -cos(yaw - dir + M_PI) * dist;
+ east = sin(yaw - dir + M_PI) * tilt;
+ north = -cos(yaw - dir + M_PI) * tilt;
/* calculatate the integer positions of 4 steps */
move_east[0] = (int32_t)((east * 0.25) + 0.5);
move_north[0] = (int32_t)((north * 0.25) + 0.5);
/* the game takes 4 steps to move the player */
mercenary_vr_move(1, move_east, move_north, 256, 256);
}
+
+ /* if we rotate */
+ if (we_rotate == 1) {
+ /* change orientation */
+ mercenary_get_orientation(&roll, &pitch, &yaw);
+ if (stick_right_x > 0)
+ mercenary_set_orientation(yaw - 45.0 / 180.0 * M_PI);
+ else
+ mercenary_set_orientation(yaw + 45.0 / 180.0 * M_PI);
+ /* rotate only once */
+ we_rotate = 2;
+ }
}
if (joystick_set_x_last && !joystick_set_x)
set_joystick(0, 0, -1, -1, -1);
/* for amiga speed: set delay by the number of cycles */
if (config_amiga_speed)
render_delay += (double)cycle_count / CPU_SPEED;
+ /* reset joystick after rendering */
+ reset_joystick();
}
/* STEP 2: transfer legacy image (or just benson) in memory to OpenGL texture */
if (osd_timer - (int32_t)ticks_sdl() < 0)
osd_timer = 0;
}
+#ifndef HAVE_OVR
+ /* draw border around legacy render area */
+ if (border_timer) {
+ opengl_render_color(1.0, 0.0, 0.0, 1.0);
+ opengl_render_line(160, -68, 256, 160, 68, 256, 0.0);
+ opengl_render_line(-160, -68, 256, -160, 68, 256, 0.0);
+ opengl_render_line(-160, 68, 256, 160, 68, 256, 0.0);
+ opengl_render_line(-160, -68, 256, 160, -68, 256, 0.0);
+ if (border_timer - (int32_t)ticks_sdl() < 0)
+ border_timer = 0;
+ }
+#endif
}
/* setup viewport for legacy image and render image, if enabled */
/* also render legacy, if render_improved failed due to not (yet) available items */
}
}
-static int shift = 0, ctrl = 0;
+static int shift = 0, ctrl = 0, alt = 0;
static void keyboard_sdl(int down, enum keycode keycode)
{
config_fov = FOV_JOLLY;
}
osd_info("Benson size", (config_benson_size == 0.5) ? "half" : "normal");
+ border_timer = ticks_sdl() + 1500;
break;
case KEYCODE_i:
if (!intro_skipped)
disp_fov:
{
char text[16];
- sprintf(text, "%.2f", config_fov);
+ if (config_fov < 63.5 || config_fov > 64.5)
+ sprintf(text, "%.2f", config_fov);
+ else
+ sprintf(text, "%.2f (default)", config_fov);
osd_info("FOV", text);
+ border_timer = ticks_sdl() + 1500;
}
#endif
break;
set_amiga_key(keycode, down);
shift = down;
break;
+ case KEYCODE_LALT:
+ set_amiga_key(keycode, down);
+ alt = down;
+ break;
+ case KEYCODE_RALT:
+ set_amiga_key(keycode, down);
+ alt = down;
+ break;
case KEYCODE_LEFT:
if (shift && down) {
set_amiga_key(keycode, down);
break;
}
set_amiga_key(keycode, 0);
- set_joystick(-1, -1, down, -1, -1);
+ if (!alt || down)
+ set_joystick(-1, -1, down, 0, -1);
break;
case KEYCODE_DOWN:
if (shift && down) {
break;
}
set_amiga_key(keycode, 0);
- set_joystick(-1, -1, -1, down, -1);
+ if (!alt || down)
+ set_joystick(-1, -1, 0, down, -1);
break;
case KEYCODE_END:
set_joystick(-1, -1, -1, -1, down);
" Press `CTRL' + `I' to skip intro (approaching to Eris).\n"
" Press `CTRL' + `1' or `2' to insert or `0' to remove mission disk.\n"
#ifdef HAVE_OVR
- " Press `CTRL' + `O' (or both triggers) to reset observer position.\n"
+ " Press `CTRL' + `O' to reset observer position.\n"
#endif
"\n"
"Answer to a Question:\n"
" To have a virtual keyboard, point below benson (control pannel).\n"
" Point to a key on keyboard. The key will highlight.\n"
" Pull `Trigger' on right controller to enter the highlighted key.\n"
- " Press thumb stick on left controller to reset observer position.\n"
+ " Press thumb stick on right controller to reset observer position.\n"
"\n"
"Walking / Driving / Flying using Controller:\n"
" Use thumb stick on right controller, to move player / craft.\n"
- " Point right controller towards the direction to walk to.\n"
+ " Move thumb stick forth and back to walk, left and right to rotate.\n"
" Pull `Trigger' on right controller to change orientation.\n"
" Press `X' button to board, `Y' button to leave.\n"
" Move thumb stick on left controller to drive/fly forward or backward.\n"