Support PAL mode lightguns

This commit is contained in:
David Walters 2017-12-07 00:10:31 +00:00
parent eee7bc3152
commit 57f844705d
3 changed files with 24 additions and 7 deletions

View File

@ -22,6 +22,9 @@ static int astick_deadzone = 0;
static int trigger_deadzone = 0;
static float mouse_sensitivity = 1.0f;
static unsigned geometry_width = 0;
static unsigned geometry_height = 0;
typedef union
{
uint8_t u8[ 32 ];
@ -440,6 +443,14 @@ void input_init()
}
}
void input_set_geometry( unsigned width, unsigned height )
{
log_cb( RETRO_LOG_INFO, "input_set_geometry: %dx%d\n", width, height );
geometry_width = width;
geometry_height = height;
}
void input_set_deadzone_stick( int percent )
{
if ( percent >= 0 && percent <= 100 )
@ -881,7 +892,9 @@ void input_update( retro_input_state_t input_state_cb )
forced_reload = input_state_cb( iplayer, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD );
// off-screen?
if ( input_state_cb( iplayer, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN ) || forced_reload )
if ( input_state_cb( iplayer, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN ) ||
forced_reload ||
geometry_height == 0 )
{
shot_type = 0x4; // off-screen shot
@ -897,15 +910,15 @@ void input_update( retro_input_state_t input_state_cb )
gun_y_raw = input_state_cb( iplayer, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y );
// .. scale into screen space:
// NOTE: the scaling here is semi-guesswork, need to re-write.
// TODO: Test with PAL games.
// NOTE: the scaling here is empirical-guesswork.
// Tested at 352x240 (ntsc) and 352x256 (pal)
const int scale_x = 21472;
const int offset_x = 60;
const int scale_y = 240;
const int scale_y = geometry_height;
const int offset_y = geometry_height - 240;
gun_x = ( ( gun_x_raw + offset_x + 0x7fff ) * scale_x ) / (0x7fff << 1);
gun_y = ( ( gun_y_raw + 0x7fff ) * scale_y ) / (0x7fff << 1);
gun_x = ( ( gun_x_raw + 0x7fff ) * scale_x ) / (0x7fff << 1);
gun_y = ( ( gun_y_raw + 0x7fff ) * scale_y ) / (0x7fff << 1) + offset_y;
}
// position

View File

@ -11,6 +11,8 @@ extern void input_init_env( retro_environment_t environ_cb );
extern void input_init();
extern void input_set_geometry( unsigned width, unsigned height );
extern void input_set_env( retro_environment_t environ_cb );
extern void input_set_deadzone_stick( int percent );

View File

@ -2257,6 +2257,8 @@ void retro_run(void)
game_width = width;
game_height = height;
input_set_geometry( width, height );
}
pix += surf->pitchinpix * (linevisfirst << PrevInterlaced) + overscan_mask;