From c9cf7954dc3edbdf4692e972e9c0d9963ce0496b Mon Sep 17 00:00:00 2001 From: EkeEke Date: Sun, 17 Aug 2014 18:37:52 +0200 Subject: [PATCH] [libretro] added core options for inverting MD Mouse Y-axis (needed by Populous II) & showing lightgun crosshair --- libretro/libretro.c | 32 +++++++++++++++++++++++++++++++- libretro/osd.h | 2 ++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/libretro/libretro.c b/libretro/libretro.c index 8668399..6119c46 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -222,7 +222,10 @@ void osd_input_update(void) case DEVICE_MOUSE: { input.analog[i][0] = input_state_cb(player, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X); - input.analog[i][1] = -input_state_cb(player, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y); + if (config.invert_mouse) + input.analog[i][1] = input_state_cb(player, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y); + else + input.analog[i][1] = -input_state_cb(player, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y); if (input.analog[i][0] < -255) input.analog[i][0] = -255; @@ -251,6 +254,13 @@ void osd_input_update(void) input.analog[i][0] = ((input_state_cb(player, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X) + 0x7fff) * bitmap.viewport.w) / 0xfffe; input.analog[i][1] = ((input_state_cb(player, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y) + 0x7fff) * bitmap.viewport.h) / 0xfffe; + if (config.gun_cursor) + { + uint16_t *ptr = (uint16_t *)bitmap.data + ((bitmap.viewport.y + input.analog[i][1]) * bitmap.width) + input.analog[i][0] + bitmap.viewport.x; + ptr[-3*bitmap.width] = ptr[-bitmap.width] = ptr[bitmap.width] = ptr[3*bitmap.width] = ptr[-3] = ptr[-1] = ptr[1] = ptr[3] = (i & 1) ? 0xf800 : 0x001f; + ptr[-2*bitmap.width] = ptr[0] = ptr[2*bitmap.width] = ptr[-2] = ptr[2] = 0xffff; + } + if (input_state_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_TRIGGER)) temp |= INPUT_A; if (input_state_cb(player, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_TURBO)) @@ -875,6 +885,24 @@ static void check_variables(void) update_viewports = true; } + var.key = "gun_cursor"; + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); + { + if (strcmp(var.value, "off") == 0) + config.gun_cursor = 0; + else + config.gun_cursor = 1; + } + + var.key = "invert_mouse"; + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); + { + if (strcmp(var.value, "off") == 0) + config.invert_mouse = 0; + else + config.invert_mouse = 1; + } + if (reinit) { audio_init(44100, snd.frame_rate); @@ -913,6 +941,8 @@ void retro_set_environment(retro_environment_t cb) { "overscan", "Borders; disabled|top/bottom|left/right|full" }, { "gg_extra", "Game Gear extended screen; disabled|enabled" }, { "render", "Interlaced mode 2 output; single field|double field" }, + { "gun_cursor", "Show Lightgun crosshair; no|yes" }, + { "invert_mouse", "Invert Mouse Y-axis; no|yes" }, { NULL, NULL }, }; diff --git a/libretro/osd.h b/libretro/osd.h index acb5f40..e22c446 100644 --- a/libretro/osd.h +++ b/libretro/osd.h @@ -64,6 +64,8 @@ struct uint8 gg_extra; uint8 render; t_input_config input[MAX_INPUTS]; + uint8 invert_mouse; + uint8 gun_cursor; } config; extern char GG_ROM[256];