fixed input system rested when loading a new rom, fixed sega mouse buttons being inverted, SRAM are not compressed anymore, fixed B button on wiimote when emulating lightguns

This commit is contained in:
ekeeke31 2008-08-26 16:00:43 +00:00
parent 2fc0a8efca
commit f2fdbc4e4d
7 changed files with 35 additions and 27 deletions

View File

@ -113,8 +113,7 @@ T_CART_ENTRY rom_database[CART_CNT] =
/* current cart hardware */
T_CART_HW cart_hw;
uint8 j_cart;
static int old_system[2] = {-1,-1};
int old_system[2] = {-1,-1};
/************************************************************
Cart Hardware initialization
@ -207,12 +206,13 @@ void cart_hw_init()
m68k_writemap_16[7] = SVP_CELL;
}
/**********************************************
SEGA MENACER
***********************************************/
/* default GUN settings */
input.x_offset = 0x00;
input.y_offset = 0x00;
/**********************************************
SEGA MENACER
***********************************************/
if (strstr(rominfo.international,"MENACER") != NULL)
{
/* save current setting */

View File

@ -210,8 +210,8 @@ unsigned int mouse_read()
break;
case 5: /* Buttons state */
if (input.pad[mouse.Port] & INPUT_B) temp |= 0x01;
if (input.pad[mouse.Port] & INPUT_A) temp |= 0x02;
if (input.pad[mouse.Port] & INPUT_A) temp |= 0x01;
if (input.pad[mouse.Port] & INPUT_B) temp |= 0x02;
if (input.pad[mouse.Port] & INPUT_C) temp |= 0x04;
if (input.pad[mouse.Port] & INPUT_START) temp |= 0x08;
break;

View File

@ -308,8 +308,8 @@ unsigned int m68k_read_memory_8(unsigned int address)
case 0x03: /* IO register */
{
uint8 retval = 0xff;
if (input.pad[0] & INPUT_B) retval &= ~0x80;
if (input.pad[0] & INPUT_A) retval &= ~0x10;
if (input.pad[0] & INPUT_B) retval &= ~0x10;
if (input.pad[0] & INPUT_A) retval &= ~0x80;
if (input.pad[0] & INPUT_UP) retval &= ~0x01;
if (input.pad[0] & INPUT_DOWN) retval &= ~0x02;
if (input.pad[0] & INPUT_LEFT) retval &= ~0x04;
@ -526,8 +526,8 @@ unsigned int m68k_read_memory_16 (unsigned int address)
case 0x02: /* IO register */
{
uint8 retval = 0xff;
if (input.pad[0] & INPUT_B) retval &= ~0x80;
if (input.pad[0] & INPUT_A) retval &= ~0x10;
if (input.pad[0] & INPUT_B) retval &= ~0x10;
if (input.pad[0] & INPUT_A) retval &= ~0x80;
if (input.pad[0] & INPUT_UP) retval &= ~0x01;
if (input.pad[0] & INPUT_DOWN) retval &= ~0x02;
if (input.pad[0] & INPUT_LEFT) retval &= ~0x04;

View File

@ -428,6 +428,7 @@ void dispmenu ()
/****************************************************************************
* ConfigureJoypads
****************************************************************************/
extern int old_system[2];
void ConfigureJoypads ()
{
int ret, max_players;
@ -562,6 +563,8 @@ void ConfigureJoypads ()
input.system[1] = SYSTEM_GAMEPAD;
}
io_reset();
old_system[0] = input.system[0];
old_system[1] = input.system[1];
break;
case 1:
@ -579,6 +582,8 @@ void ConfigureJoypads ()
input.system[0] = SYSTEM_GAMEPAD;
}
io_reset();
old_system[0] = input.system[0];
old_system[1] = input.system[1];
break;
case 2:
@ -702,6 +707,8 @@ void ConfigureJoypads ()
break;
case 7:
/* special case: wiimote controls lightgun */
ogc_input__config(config.input[player].port, config.input[player].device, input.padtype[player]);
break;

View File

@ -84,7 +84,6 @@ static int SD_ManageFile(char *filename, int direction, int filetype)
char pathname[MAXPATHLEN];
int done = 0;
int filesize;
unsigned long inbytes,outbytes;
/* first check if directory exist */
DIR_ITER *dir = diropen("/genplus/saves");
@ -109,12 +108,9 @@ static int SD_ManageFile(char *filename, int direction, int filetype)
if (filetype) /* SRAM */
{
inbytes = 0x10000;
outbytes = 0x24000;
compress2 ((Bytef *)(savebuffer + 4), &outbytes, (Bytef *)(sram.sram), inbytes, 9);
memcpy(savebuffer, &outbytes, 4);
filesize = outbytes + 4;
memcpy(savebuffer, sram.sram, 0x10000);
sram.crc = crc32 (0, sram.sram, 0x10000);
filesize = 0x10000;
}
else filesize = state_save(savebuffer); /* STATE */
@ -151,9 +147,7 @@ static int SD_ManageFile(char *filename, int direction, int filetype)
if (filetype) /* SRAM */
{
memcpy(&inbytes, savebuffer, 4);
outbytes = 0x10000;
uncompress ((Bytef *)(sram.sram), &outbytes, (Bytef *)(savebuffer + 4), inbytes);
memcpy(sram.sram, savebuffer, filesize);
sram.crc = crc32 (0, sram.sram, 0x10000);
system_reset ();
}

View File

@ -451,6 +451,7 @@ static void wpad_update(s8 num, u8 i, u32 exp)
{
input.analog[i-4][0] = (ir.x * bitmap.viewport.w) / 640;
input.analog[i-4][1] = (ir.y * bitmap.viewport.h) / 480;
if (p & WPAD_BUTTON_B) input.pad[i] |= INPUT_B;
}
}
}
@ -478,6 +479,7 @@ static void wpad_update(s8 num, u8 i, u32 exp)
{
input.analog[0][0] = 0x3c + (ir.x * (0x17c - 0x3c + 1)) / 640;
input.analog[0][1] = 0x1fc + (ir.y * (0x3f3 - 0x1fc + 1)) / 480;
if (p & WPAD_BUTTON_B) input.pad[i] |= INPUT_B;
}
}
}
@ -527,6 +529,8 @@ static void wpad_update(s8 num, u8 i, u32 exp)
{
old_y = ir.y;
}
if (p & WPAD_BUTTON_B) input.pad[i] |= INPUT_B;
}
else
{

View File

@ -314,7 +314,7 @@ int audio_init (int rate)
/* Calculate the sound buffer size (for one frame) */
snd.buffer_size = (rate / vdp_rate);
#ifndef NGC
#ifdef DOS
/* output buffers */
snd.buffer[0] = (int16 *) malloc(SND_SIZE);
snd.buffer[1] = (int16 *) malloc(SND_SIZE);
@ -373,7 +373,7 @@ void audio_update (void)
int boost = config.boost;
int filter = config.filter;
#ifdef NGC
#ifndef DOS
int16 *sb = (int16 *) soundbuffer[mixbuffer];
#endif
@ -410,16 +410,19 @@ void audio_update (void)
else if (r < -32768) r = -32768;
/* update sound buffer */
#ifdef NGC
*sb++ = r; // RIGHT channel comes first
*sb++ = l;
#else
#ifdef DOS
snd.buffer[0][i] = l;
snd.buffer[1][i] = r;
#elif LSB_FIRST
*sb++ = l;
*sb++ = r;
#else
*sb++ = r;
*sb++ = l;
#endif
}
#ifdef NGC
#ifndef DOS
mixbuffer++;
mixbuffer &= 0xf;
#endif