#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
static int debug_opengl = 0; /* render both, amiga screen and improved image, if set */
static int intro_skipped = 0; /* indicated if we already have landed */
static int window_width, window_height;
+static int mission_disk = 0;
static const char *home_dir;
{
window_width = width;
window_height = height;
+ border_timer = ticks_sdl() + 1500;
+ osd_info("", "window resized");
}
#ifdef HAVE_OVR
/* 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 */
if (!(track & 1)) {
char filename[256];
int gamesave_num = (track - 2) >> 1;
- int got;
- FILE *fp;
memset(game_save, 0, sizeof(game_save)); /* clear so make the game fail, if we fail */
+
+ if (mission_disk == 0) {
+ int got;
+ FILE *fp;
+
#if defined(_WIN32)
- filename[0] = '\0';
+ filename[0] = '\0';
#else
- sprintf(filename, "%s/%s/", home_dir, config_gamesave_dir);
- mkdir(filename, 0777);
+ sprintf(filename, "%s/%s/", home_dir, config_gamesave_dir);
+ mkdir(filename, 0777);
#endif
- sprintf(filename + strlen(filename), "%d%s", gamesave_num, mercenary_gamesavesuffix);
- fp = fopen(filename, "r");
- if (!fp) {
+ sprintf(filename + strlen(filename), "%d%s", gamesave_num, mercenary_gamesavesuffix);
+ fp = fopen(filename, "r");
+ if (!fp) {
fail:
- print_info("failed to load game from '%s'\n", filename);
- goto copy;
+ print_info("failed to load game from '%s'\n", filename);
+ osd_info("load game", "FAILED!");
+ goto copy;
+ }
+ got = fread(game_save, sizeof(game_save[0]), 2, fp);
+ fclose(fp);
+ if (got != 2)
+ goto fail;
+ sprintf(filename, "#%d", gamesave_num);
+ osd_info("loaded game", filename);
+ } else {
+ const uint8_t *mission_data = get_mission_disk(mission_disk, gamesave_num);
+ sprintf(filename, "disk %d #%d", mission_disk, gamesave_num);
+ if (!mission_data) {
+ print_info("failed to load mission %s\n", filename);
+ osd_info("load mission", "FAILED!");
+ goto copy;
+ }
+ memcpy(game_save, mission_data, 0x1820 << 2);
+ osd_info("loaded mission", filename);
}
- got = fread(game_save, sizeof(game_save[0]), 2, fp);
- fclose(fp);
- if (got != 2)
- goto fail;
}
copy:
/* game writes track with saved game */
static void disk_write(int track, int __attribute__((unused)) side, uint32_t data, uint16_t length)
{
+ /* cannot save on mission disk */
+ if (mission_disk) {
+ osd_info("", "not applicable");
+ return;
+ }
+
/* skip sync info that is provided by game and only relevant for a real disk track */
data += 0x200;
length -= 0x200;
if (!fp) {
fail:
print_error("failed to save game to '%s'\n", filename);
+ osd_info("save game", "FAILED!");
return;
}
print_info("Game state saved to '%s'\n", filename);
+ sprintf(filename, "#%d", gamesave_num);
+ osd_info("saved game", filename);
wrote = fwrite(game_save, sizeof(game_save[0]), 2, fp);
fclose(fp);
if (wrote != 2)
}
}
-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)
else
osd_info("", "not applicable");
break;
+ case KEYCODE_1:
+ if (get_mission_disk(1, 1)) { /* just to check support */
+ mission_disk = 1;
+ osd_info("mission disk", "insert 1");
+ } else
+ osd_info("", "not applicable");
+ break;
+ case KEYCODE_2:
+ if (get_mission_disk(2, 1)) { /* just to check support */
+ mission_disk = 2;
+ osd_info("mission disk", "insert 2");
+ } else
+ osd_info("", "not applicable");
+ break;
+ case KEYCODE_0:
+ if (get_mission_disk(1, 1)) { /* just to check support */
+ mission_disk = 0;
+ osd_info("mission disk", "removed");
+ } else
+ osd_info("", "not applicable");
+ break;
case KEYCODE_c:
if (config_ctrl_c)
quit = 1;
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);
sound_buffer_readp =(sound_buffer_readp + length) % sound_buffer_size;
}
+/* used for geier counter */
void sound_irq(void)
{
/* trigger and execute IRQ 4 = sound */
" Press `CTRL' + `A' to toggle audio filter on / off.\n"
" Press `CTRL' + `+' or `-' to change field-of-view (OpenGL).\n"
" 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"
#endif