extern char McdDisable[2];
/* PCSX ReARMed core calls and stuff */
-int in_type1, in_type2;
-int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 };
-int in_a3[2] = { 127, 127 }, in_a4[2] = { 127, 127 };
-int in_keystate;
+int in_type[8] = { PSE_PAD_TYPE_STANDARD, PSE_PAD_TYPE_STANDARD,
+ PSE_PAD_TYPE_STANDARD, PSE_PAD_TYPE_STANDARD,
+ PSE_PAD_TYPE_STANDARD, PSE_PAD_TYPE_STANDARD,
+ PSE_PAD_TYPE_STANDARD, PSE_PAD_TYPE_STANDARD };
+int in_analog_left[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }};
+int in_analog_right[8][2] = {{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 },{ 127, 127 }};
+unsigned short in_keystate[8];
+int multitap1 = 0;
+int multitap2 = 0;
int in_enable_vibration = 1;
/* PSX max resolution is 640x512, but with enhancement it's 1024x512 */
#endif
static void *pl_mmap(unsigned int size)
-{
+{
return psxMap(0, size, 0, MAP_TAG_VRAM);
}
{ "pcsx_rearmed_region", "Region; Auto|NTSC|PAL" },
{ "pcsx_rearmed_pad1type", "Pad 1 Type; standard|analog|negcon" },
{ "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog|negcon" },
+ { "pcsx_rearmed_pad3type", "Pad 3 Type; standard|analog|negcon" },
+ { "pcsx_rearmed_pad4type", "Pad 4 Type; standard|analog|negcon" },
+ { "pcsx_rearmed_pad5type", "Pad 5 Type; standard|analog|negcon" },
+ { "pcsx_rearmed_pad6type", "Pad 6 Type; standard|analog|negcon" },
+ { "pcsx_rearmed_pad7type", "Pad 7 Type; standard|analog|negcon" },
+ { "pcsx_rearmed_pad8type", "Pad 8 Type; standard|analog|negcon" },
+ { "pcsx_rearmed_multitap1", "Multitap 1; disabled|enabled" },
+ { "pcsx_rearmed_multitap2", "Multitap 2; disabled|enabled" },
#ifndef DRC_DISABLE
{ "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" },
#endif
void retro_set_controller_port_device(unsigned port, unsigned device)
{
+ SysPrintf("port %u device %u",port,device);
}
void retro_get_system_info(struct retro_system_info *info)
}
/* savestates */
-size_t retro_serialize_size(void)
-{
+size_t retro_serialize_size(void)
+{
// it's currently 4380651-4397047 bytes,
// but have some reserved for future
return 0x440000;
}
bool retro_serialize(void *data, size_t size)
-{
+{
int ret = SaveState(data);
return ret == 0 ? true : false;
}
{ 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" },
{ 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" },
{ 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
- { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
+ { 5, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
{ 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" },
{ 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" },
{ 5, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" },
{ 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" },
{ 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" },
{ 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
- { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
+ { 6, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
{ 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" },
{ 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" },
{ 6, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" },
{ 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R2, "R2" },
{ 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R3, "R3" },
{ 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT, "Select" },
- { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
+ { 7, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START, "Start" },
{ 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X, "Left Analog X" },
{ 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y, "Left Analog Y" },
{ 7, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X" },
return false;
}
-void retro_unload_game(void)
+void retro_unload_game(void)
{
}
static void update_variables(bool in_flight)
{
struct retro_variable var;
-
+
var.value = NULL;
var.key = "pcsx_rearmed_frameskip";
-
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
pl_rearmed_cbs.frameskip = atoi(var.value);
var.value = NULL;
var.key = "pcsx_rearmed_region";
-
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
{
Config.PsxAuto = 0;
var.value = NULL;
var.key = "pcsx_rearmed_pad1type";
-
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
{
- in_type1 = PSE_PAD_TYPE_STANDARD;
+ in_type[0] = PSE_PAD_TYPE_STANDARD;
if (strcmp(var.value, "analog") == 0)
- in_type1 = PSE_PAD_TYPE_ANALOGPAD;
- if (strcmp(var.value, "negcon") == 0)
- in_type1 = PSE_PAD_TYPE_NEGCON;
+ in_type[0] = PSE_PAD_TYPE_ANALOGPAD;
+ else if (strcmp(var.value, "negcon") == 0)
+ in_type[0] = PSE_PAD_TYPE_NEGCON;
}
var.value = NULL;
var.key = "pcsx_rearmed_pad2type";
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+ {
+ in_type[1] = PSE_PAD_TYPE_STANDARD;
+ if (strcmp(var.value, "analog") == 0)
+ in_type[1] = PSE_PAD_TYPE_ANALOGPAD;
+ else if (strcmp(var.value, "negcon") == 0)
+ in_type[1] = PSE_PAD_TYPE_NEGCON;
+ }
+ var.value = NULL;
+ var.key = "pcsx_rearmed_pad3type";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
{
- in_type2 = PSE_PAD_TYPE_STANDARD;
+ in_type[2] = PSE_PAD_TYPE_STANDARD;
if (strcmp(var.value, "analog") == 0)
- in_type2 = PSE_PAD_TYPE_ANALOGPAD;
- if (strcmp(var.value, "negcon") == 0)
- in_type2 = PSE_PAD_TYPE_NEGCON;
+ in_type[2] = PSE_PAD_TYPE_ANALOGPAD;
+ else if (strcmp(var.value, "negcon") == 0)
+ in_type[2] = PSE_PAD_TYPE_NEGCON;
+ }
+ var.value = NULL;
+ var.key = "pcsx_rearmed_pad4type";
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+ {
+ in_type[3] = PSE_PAD_TYPE_STANDARD;
+ if (strcmp(var.value, "analog") == 0)
+ in_type[3] = PSE_PAD_TYPE_ANALOGPAD;
+ else if (strcmp(var.value, "negcon") == 0)
+ in_type[3] = PSE_PAD_TYPE_NEGCON;
+ }
+
+ var.value = NULL;
+ var.key = "pcsx_rearmed_pad5type";
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+ {
+ in_type[4] = PSE_PAD_TYPE_STANDARD;
+ if (strcmp(var.value, "analog") == 0)
+ in_type[4] = PSE_PAD_TYPE_ANALOGPAD;
+ else if (strcmp(var.value, "negcon") == 0)
+ in_type[4] = PSE_PAD_TYPE_NEGCON;
+ }
+
+ var.value = NULL;
+ var.key = "pcsx_rearmed_pad6type";
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+ {
+ in_type[5] = PSE_PAD_TYPE_STANDARD;
+ if (strcmp(var.value, "analog") == 0)
+ in_type[5] = PSE_PAD_TYPE_ANALOGPAD;
+ else if (strcmp(var.value, "negcon") == 0)
+ in_type[5] = PSE_PAD_TYPE_NEGCON;
+ }
+
+ var.value = NULL;
+ var.key = "pcsx_rearmed_pad7type";
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+ {
+ in_type[6] = PSE_PAD_TYPE_STANDARD;
+ if (strcmp(var.value, "analog") == 0)
+ in_type[6] = PSE_PAD_TYPE_ANALOGPAD;
+ else if (strcmp(var.value, "negcon") == 0)
+ in_type[6] = PSE_PAD_TYPE_NEGCON;
+ }
+
+ var.value = NULL;
+ var.key = "pcsx_rearmed_pad8type";
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+ {
+ in_type[7] = PSE_PAD_TYPE_STANDARD;
+ if (strcmp(var.value, "analog") == 0)
+ in_type[7] = PSE_PAD_TYPE_ANALOGPAD;
+ else if (strcmp(var.value, "negcon") == 0)
+ in_type[7] = PSE_PAD_TYPE_NEGCON;
+ }
+
+ var.value = NULL;
+ var.key = "pcsx_rearmed_multitap1";
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+ {
+ if (strcmp(var.value, "enabled") == 0)
+ multitap1 = 1;
+ else multitap1 = 0;
+ }
+
+ var.value = NULL;
+ var.key = "pcsx_rearmed_multitap2";
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+ {
+ if (strcmp(var.value, "enabled") == 0)
+ multitap2 = 1;
+ else multitap2 = 0;
}
#ifdef __ARM_NEON__
else if (strcmp(var.value, "enabled") == 0)
Config.RCntFix = 1;
}
-
+
var.value = "NULL";
var.key = "pcsx_rearmed_inuyasha_fix";
}
}
-void retro_run(void)
+void retro_run(void)
{
- int i, val;
+ int i;
input_poll_cb();
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
update_variables(true);
- in_keystate = 0;
- for (i = 0; i < RETRO_PSX_MAP_LEN; i++)
- if (input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, i))
- in_keystate |= retro_psx_map[i];
- in_keystate <<= 16;
- for (i = 0; i < RETRO_PSX_MAP_LEN; i++)
- if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i))
- in_keystate |= retro_psx_map[i];
-
+ // reset all keystate, query libretro for keystate
+ int j;
+ for(i = 0; i < 8; i++) {
+ in_keystate[i] = 0;
+ // query libretro for keystate
+ for (j = 0; j < RETRO_PSX_MAP_LEN; j++)
+ if (input_state_cb(i, RETRO_DEVICE_JOYPAD, 0, j))
+ in_keystate[i] |= retro_psx_map[j];
- if (in_type1 == PSE_PAD_TYPE_ANALOGPAD)
- {
- in_a1[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
- in_a1[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
- in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
- in_a2[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
- }
-
- if (in_type2 == PSE_PAD_TYPE_ANALOGPAD)
- {
- in_a3[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
- in_a3[1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
- in_a4[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
- in_a4[1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
+ if (in_type[i] == PSE_PAD_TYPE_ANALOGPAD)
+ {
+ in_analog_left[i][0] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
+ in_analog_left[i][1] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
+ in_analog_right[i][0] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
+ in_analog_right[i][1] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
+ }
}
-
- if (in_type1 == PSE_PAD_TYPE_NEGCON)
- {
- /* left brake */
- if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 12))
- in_a1[1] = 255;
- else
- in_a1[1] = 0;
-
- /* steer */
- in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
-
- /* thrust and fire */
- val = ((input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 127));
- if(val < -2) {
- in_a1[0] = 256 - val;
- }
- if (val > 2) {
- in_a2[1] = val;
- }
- if(val >= -2 && val <= 2)
- {
- in_a2[1] = 0;
- in_a1[0] = 0;
- }
- }
-
- if (in_type2 == PSE_PAD_TYPE_NEGCON)
- {
- /* left brake */
- if(input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, 12))
- in_a3[1] = 255;
- else
- in_a3[1] = 0;
-
- /* steer */
- in_a4[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
-
- /* thrust and fire */
- val = ((input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 127));
- if(val < -2) {
- in_a3[0] = 256 - val;
- }
- if (val > 2) {
- in_a4[1] = val;
- }
- if(val >= -2 && val <= 2)
- {
- in_a4[1] = 0;
- in_a3[0] = 0;
- }
- }
-
-
stop = 0;
psxCpu->Execute();
else
{
SysPrintf("no BIOS files found.\n");
- struct retro_message msg =
+ struct retro_message msg =
{
"no BIOS found, expect bugs!",
180
void *hPAD1Driver = NULL;\r
void *hPAD2Driver = NULL;\r
\r
-static unsigned char buf[256];\r
+static int multitap1 = -1;\r
+static int multitap2 = -1;\r
+\r
+static unsigned char buf[512];\r
unsigned char stdpar[10] = { 0x00, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\r
unsigned char mousepar[8] = { 0x00, 0x12, 0x5a, 0xff, 0xff, 0xff, 0xff };\r
unsigned char analogpar[9] = { 0x00, 0xff, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\r
+unsigned char multitappar[35] = { 0x00, 0x80, 0x5a, 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+ 0x41, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\r
\r
static int bufcount, bufc;\r
\r
-PadDataS padd1, padd2;\r
+//PadDataS padd1, padd2;\r
+unsigned char _PADstartPollMultitap(PadDataS padd[4]) {\r
+ int i = 0;\r
+ int offset = 2;\r
+ bufc = 0;\r
+ PadDataS pad;\r
+ for(i = 0; i < 4; i++) {\r
+ offset = 2 + (i * 8);\r
+ pad = padd[i];\r
+ switch (pad.controllerType) {\r
+ case PSE_PAD_TYPE_MOUSE:\r
+ multitappar[offset + 1] = 0x12;\r
+ multitappar[offset + 2] = 0x5a;\r
+ multitappar[offset + 3] = pad.buttonStatus & 0xff;\r
+ multitappar[offset + 4] = pad.buttonStatus >> 8;\r
+ multitappar[offset + 5] = pad.moveX;\r
+ multitappar[offset + 6] = pad.moveY;\r
+\r
+ break;\r
+ case PSE_PAD_TYPE_NEGCON: // npc101/npc104(slph00001/slph00069)\r
+ multitappar[offset + 1] = 0x23;\r
+ multitappar[offset + 2] = 0x5a;\r
+ multitappar[offset + 3] = pad.buttonStatus & 0xff;\r
+ multitappar[offset + 4] = pad.buttonStatus >> 8;\r
+ multitappar[offset + 5] = pad.rightJoyX;\r
+ multitappar[offset + 6] = pad.rightJoyY;\r
+ multitappar[offset + 7] = pad.leftJoyX;\r
+ multitappar[offset + 8] = pad.leftJoyY;\r
+\r
+ break;\r
+ case PSE_PAD_TYPE_ANALOGPAD: // scph1150\r
+ multitappar[offset + 1] = 0x73;\r
+ multitappar[offset + 2] = 0x5a;\r
+ multitappar[offset + 3] = pad.buttonStatus & 0xff;\r
+ multitappar[offset + 4] = pad.buttonStatus >> 8;\r
+ multitappar[offset + 5] = pad.rightJoyX;\r
+ multitappar[offset + 6] = pad.rightJoyY;\r
+ multitappar[offset + 7] = pad.leftJoyX;\r
+ multitappar[offset + 8] = pad.leftJoyY;\r
+\r
+ break;\r
+ case PSE_PAD_TYPE_ANALOGJOY: // scph1110\r
+ multitappar[offset + 1] = 0x53;\r
+ multitappar[offset + 2] = 0x5a;\r
+ multitappar[offset + 3] = pad.buttonStatus & 0xff;\r
+ multitappar[offset + 4] = pad.buttonStatus >> 8;\r
+ multitappar[offset + 5] = pad.rightJoyX;\r
+ multitappar[offset + 6] = pad.rightJoyY;\r
+ multitappar[offset + 7] = pad.leftJoyX;\r
+ multitappar[offset + 8] = pad.leftJoyY;\r
+\r
+ break;\r
+ case PSE_PAD_TYPE_STANDARD:\r
+ default:\r
+ multitappar[offset + 1] = 0x41;\r
+ multitappar[offset + 2] = 0x5a;\r
+ multitappar[offset + 3] = pad.buttonStatus & 0xff;\r
+ multitappar[offset + 4] = pad.buttonStatus >> 8;\r
+ }\r
+ }\r
+\r
+ memcpy(buf, multitappar, 35);\r
+ bufcount = 34;\r
+\r
+ return buf[bufc++];\r
+}\r
\r
unsigned char _PADstartPoll(PadDataS *pad) {\r
+\r
bufc = 0;\r
\r
switch (pad->controllerType) {\r
default:\r
stdpar[3] = pad->buttonStatus & 0xff;\r
stdpar[4] = pad->buttonStatus >> 8;\r
-\r
- memcpy(buf, stdpar, 5);\r
- bufcount = 4;\r
+ memcpy(buf, stdpar, 5);\r
+ bufcount = 4;\r
}\r
\r
return buf[bufc++];\r
}\r
\r
unsigned char _PADpoll(unsigned char value) {\r
- if (bufc > bufcount) return 0;\r
+ if (bufc > bufcount) return 0;\r
return buf[bufc++];\r
}\r
\r
+// refresh the button state on port 1.\r
+// int pad is not needed.\r
unsigned char CALLBACK PAD1__startPoll(int pad) {\r
- PadDataS padd;\r
-\r
- PAD1_readPort1(&padd);\r
-\r
- return _PADstartPoll(&padd);\r
+ // first call the pad provide if a multitap is connected between the psx and himself\r
+ if(multitap1 == -1)\r
+ {\r
+ PadDataS padd;\r
+ PAD1_readPort1(&padd, 0);\r
+ multitap1 = padd.portMultitap;\r
+ }\r
+ // just one pad is on port 1 : NO MULTITAP\r
+ if (multitap1 == 0)\r
+ {\r
+ PadDataS padd;\r
+ PAD1_readPort1(&padd, 0);\r
+ return _PADstartPoll(&padd);\r
+ } else {\r
+ // a multitap is plugged : refresh all pad.\r
+ int i=0;\r
+ PadDataS padd[4];\r
+ for(i = 0; i < 4; i++) {\r
+ PAD1_readPort1(&padd[i], i);\r
+ }\r
+ return _PADstartPollMultitap(padd);\r
+ }\r
}\r
\r
unsigned char CALLBACK PAD1__poll(unsigned char value) {\r
- return _PADpoll(value);\r
+ if (multitap1 == 0)\r
+ {\r
+ return _PADpoll(value);\r
+ } else {\r
+ if(value == 42) {\r
+ unsigned char bufmultitap[256];\r
+ memcpy(bufmultitap, multitappar, 3);\r
+ bufcount = 2;\r
+ return bufmultitap[bufc++];\r
+ } else {\r
+ return _PADpoll(value);\r
+ }\r
+ }\r
}\r
\r
long CALLBACK PAD1__configure(void) { return 0; }\r
}\r
\r
unsigned char CALLBACK PAD2__startPoll(int pad) {\r
- PadDataS padd;\r
+ int pad_index = 0;\r
+ if(multitap1 == 1){\r
+ pad_index+=4;\r
+ }else{\r
+ pad_index=1;\r
+ }\r
+ //first call the pad provide if a multitap is connected between the psx and himself\r
+ if(multitap2 == -1){\r
+ PadDataS padd;\r
+ PAD2_readPort2(&padd,pad_index);\r
+ multitap2 = padd.portMultitap;\r
+ }\r
\r
- PAD2_readPort2(&padd);\r
- \r
- return _PADstartPoll(&padd);\r
+ // just one pad is on port 2 : NO MULTITAP\r
+ if (multitap2 == 0){\r
+ PadDataS padd;\r
+ PAD2_readPort2(&padd,pad_index);\r
+ return _PADstartPoll(&padd);\r
+ }else{\r
+ //a multitap is plugged : refresh all pad.\r
+ int i=0;\r
+ PadDataS padd[4];\r
+ for(i=0;i<4;i++){\r
+ PAD2_readPort2(&padd[i],i+pad_index);\r
+ }\r
+ return _PADstartPollMultitap(padd);\r
+ }\r
}\r
\r
unsigned char CALLBACK PAD2__poll(unsigned char value) {\r
- return _PADpoll(value);\r
+// if(value !=0){\r
+// int i;\r
+// printf("%2x %c\n", value, value);\r
+// for (i = 0; i < 35; i++) {\r
+// printf("%2x", buf[i]);\r
+// }\r
+// printf("\n");\r
+// }\r
+ if(multitap2==0){\r
+ return _PADpoll(value);\r
+ }else {\r
+ if(value==42){\r
+ unsigned char bufmultitap[256];\r
+ memcpy(bufmultitap, multitappar, 3);\r
+ bufcount = 2;\r
+ return bufmultitap[bufc++];\r
+ }else{\r
+ return _PADpoll(value);\r
+ }\r
+ }\r
}\r
\r
long CALLBACK PAD2__configure(void) { return 0; }\r