improved Wiimote support for mouse emulation

VDP code cleanup
This commit is contained in:
ekeeke31 2010-03-07 17:58:33 +00:00
parent 0f4da285f8
commit 9092121e60
2 changed files with 24 additions and 34 deletions

View File

@ -455,9 +455,6 @@ static void wpad_config(u8 chan, u8 exp, u8 max_keys)
VIDEO_Flush();
}
static float old_x = 0.0;
static float old_y = 0.0;
static void wpad_update(s8 chan, u8 i, u32 exp)
{
/* WPAD data */
@ -513,7 +510,7 @@ static void wpad_update(s8 chan, u8 i, u32 exp)
/* Emulated device specific */
switch (input.dev[i])
{
case DEVICE_LIGHTGUN:
case DEVICE_LIGHTGUN:
{
/* Lightgun cursor position (x,y) */
if (x || y)
@ -551,10 +548,13 @@ static void wpad_update(s8 chan, u8 i, u32 exp)
case DEVICE_MOUSE:
{
/* Mouse relative movement (-255,255) */
/* Mouse relative movement (9 bits signed value) */
input.analog[2][0] = 0;
input.analog[2][1] = 0;
/* Nunchuk/Classic controller analog stick */
if (x || y)
{
/* analog stick relative positions */
input.analog[2][0] = (x * 2) / ANALOG_SENSITIVITY;
input.analog[2][1] = -(y * 2) / ANALOG_SENSITIVITY;
}
@ -564,19 +564,10 @@ static void wpad_update(s8 chan, u8 i, u32 exp)
{
struct ir_t ir;
WPAD_IR(chan, &ir);
if (ir.valid)
if(ir.smooth_valid)
{
/* calculate mouse values (FIXME) */
input.analog[2][0] = (ir.x - old_x);
input.analog[2][1] = (ir.y - old_y);
old_x = ir.x;
old_y = ir.y;
if (input.analog[2][0] > 255)
input.analog[2][0] = 255;
else if (input.analog[2][0] < -255)
input.analog[2][0] = -255;
if (input.analog[2][1] > 255) input.analog[2][1] = 255;
else if (input.analog[2][1] < -255) input.analog[2][1] = -255;
input.analog[2][0] = (int)((ir.sx - 512) / 2 / ANALOG_SENSITIVITY);
input.analog[2][1] = (int)((ir.sy - 384) * 2 / 3 / ANALOG_SENSITIVITY);
/* use default trigger button */
if (p & WPAD_BUTTON_B)
@ -585,7 +576,7 @@ static void wpad_update(s8 chan, u8 i, u32 exp)
}
#ifdef USB_MOUSE
/* USB mouse support (NOT WORKING) */
/* USB mouse support (FIXME) */
if (MOUSE_IsConnected())
{
mouse_event event;

View File

@ -438,7 +438,7 @@ unsigned int vdp_ctrl_r(void)
if (!(reg[1] & 0x40))
temp |= 0x08;
/* HBLANK flag (Sonic 3 and Sonic 2 "VS Modes", Lemmings 2, Mega Turrican, Gouketsuji Ichizoku) */
/* HBLANK flag (Sonic 3 and Sonic 2 "VS Modes", Lemmings 2, Mega Turrican, V.R Troopers, Gouketsuji Ichizoku, ...) */
if ((mcycles_68k % MCYCLES_PER_LINE) < 588)
temp |= 0x04;
@ -456,10 +456,13 @@ unsigned int vdp_ctrl_r(void)
unsigned int vdp_hvc_r(void)
{
uint8 hc = (hc_latch & 0x100) ? (hc_latch & 0xFF) : hctab[mcycles_68k%MCYCLES_PER_LINE];
/* Horizontal Counter (Striker, Mickey Mania, Skitchin, Road Rash I,II,III, ...) */
uint8 hc = (hc_latch & 0x100) ? (hc_latch & 0xFF) : hctab[mcycles_68k%MCYCLES_PER_LINE];
/* Vertical Counter */
uint8 vc = vctab[v_counter];
/* interlace mode 2 */
/* interlace mode 2 (Sonic the Hedgehog 2, Combat Cars) */
if (im2_flag)
vc = (vc << 1) | ((vc >> 7) & 1);
@ -813,13 +816,13 @@ static inline void reg_w(unsigned int r, unsigned int d)
}
}
/* Display status modified during Horizontal Blanking (Legend of Galahad, Lemmings 2, */
/* Nigel Mansell's World Championship Racing, Deadly Moves, Power Athlete, ...) */
/* */
/* Note that this is not entirely correct since we are cheating with the HBLANK period limits */
/* and still redrawing the whole line. This is done because some game (PAL version of Nigel */
/* Mansell's World Championship Racing actually) appear to disable display outside HBLANK. On */
/* real hardware, the raster line would appear partially blanked. */
/* Display status modified during HBLANK (Legend of Galahad, Lemmings 2, Formula 1 Championship, */
/* Nigel Mansell's World Championship Racing, ...) */
/* */
/* Note that this is not entirely correct since we are cheating with the HBLANK period limits and */
/* still redrawing the whole line. This is done because some games (forexample, the PAL version */
/* of Nigel Mansell's World Championship Racing) appear to disable display outside HBLANK. */
/* On real hardware, the raster line would appear partially blanked. */
if ((r & 0x40) && !(status & 8))
{
if (mcycles_68k <= (hint_68k + 860))
@ -863,11 +866,7 @@ static inline void reg_w(unsigned int r, unsigned int d)
case 5: /* SATB */
reg[5] = d;
if (reg[12] & 1)
satb = (d << 9) & 0xFC00;
else
satb = (d << 9) & 0xFE00;
satb = (d << 9) & sat_base_mask;
break;
case 7: