[libretro] fixed broken gun cursor displaying

This commit is contained in:
EkeEke 2015-04-26 18:28:24 +02:00
parent 935a1f68dc
commit ea1924d747
2 changed files with 28 additions and 7 deletions

Binary file not shown.

View File

@ -283,13 +283,6 @@ 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))
@ -432,6 +425,13 @@ void osd_input_update(void)
}
}
static void draw_cursor(int16_t x, int16_t y, uint16_t color)
{
uint16_t *ptr = (uint16_t *)bitmap.data + ((bitmap.viewport.y + y) * bitmap.width) + x + 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] = color;
ptr[-2*bitmap.width] = ptr[2*bitmap.width] = ptr[-2] = ptr[2] = ptr[0] = 0xffff;
}
static void init_bitmap(void)
{
memset(&bitmap, 0, sizeof(bitmap));
@ -1880,6 +1880,27 @@ void retro_run(void)
}
}
if (config.gun_cursor)
{
if (input.system[0] == SYSTEM_LIGHTPHASER)
{
draw_cursor(input.analog[0][0], input.analog[0][1], 0x001f);
}
else if (input.dev[4] == DEVICE_LIGHTGUN)
{
draw_cursor(input.analog[4][0], input.analog[4][1], 0x001f);
}
if (input.system[1] == SYSTEM_LIGHTPHASER)
{
draw_cursor(input.analog[4][0], input.analog[4][1], 0xf800);
}
else if (input.dev[5] == DEVICE_LIGHTGUN)
{
draw_cursor(input.analog[5][0], input.analog[5][1], 0xf800);
}
}
video_cb(bitmap.data, vwidth, vheight, 720 * 2);
audio_cb(soundbuffer, audio_update(soundbuffer));