diff --git a/output/dll/octoshock.dll b/output/dll/octoshock.dll index 0296e9b5ed..0d73e4f8e5 100644 Binary files a/output/dll/octoshock.dll and b/output/dll/octoshock.dll differ diff --git a/psx/octoshock/psx/input/negcon.cpp b/psx/octoshock/psx/input/negcon.cpp index 7a30d5aed5..0ade32ec80 100644 --- a/psx/octoshock/psx/input/negcon.cpp +++ b/psx/octoshock/psx/input/negcon.cpp @@ -31,6 +31,7 @@ class InputDevice_neGcon final : public InputDevice virtual void Power(void) override; virtual void UpdateInput(const void *data) override; + virtual void SyncState(bool isReader, EW::NewState *ns) override; // // @@ -41,6 +42,9 @@ class InputDevice_neGcon final : public InputDevice private: + //non-serialized state + IO_NegCon* io; + bool dtr; uint8 buttons[2]; @@ -91,57 +95,42 @@ void InputDevice_neGcon::Power(void) transmit_pos = 0; transmit_count = 0; } -// -//void InputDevice_neGcon::StateAction(StateMem* sm, const unsigned load, const bool data_only, const char* sname_prefix) -//{ -// SFORMAT StateRegs[] = -// { -// SFVAR(dtr), -// -// SFARRAY(buttons, sizeof(buttons)), -// SFVAR(twist), -// SFARRAY(anabuttons, sizeof(anabuttons)), -// -// SFVAR(command_phase), -// SFVAR(bitpos), -// SFVAR(receive_buffer), -// -// SFVAR(command), -// -// SFARRAY(transmit_buffer, sizeof(transmit_buffer)), -// SFVAR(transmit_pos), -// SFVAR(transmit_count), -// -// SFEND -// }; -// char section_name[32]; -// trio_snprintf(section_name, sizeof(section_name), "%s_neGcon", sname_prefix); -// -// if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, section_name, true) && load) -// Power(); -// else if(load) -// { -// if((transmit_pos + transmit_count) > sizeof(transmit_buffer)) -// { -// transmit_pos = 0; -// transmit_count = 0; -// } -// } -//} +void InputDevice_neGcon::SyncState(bool isReader, EW::NewState *ns) +{ + NSS(dtr); + + NSS(buttons); + NSS(twist); + NSS(anabuttons); + + NSS(command_phase); + NSS(bitpos); + NSS(receive_buffer); + + NSS(command); + + NSS(transmit_buffer); + NSS(transmit_pos); + NSS(transmit_count); +} void InputDevice_neGcon::UpdateInput(const void *data) { - uint8 *d8 = (uint8 *)data; + io = (IO_NegCon*)data; - buttons[0] = d8[0]; - buttons[1] = d8[1]; + buttons[0] = io->buttons[0]; + buttons[1] = io->buttons[1]; - twist = ((32768 + MDFN_de16lsb((const uint8 *)data + 2) - (((int32)MDFN_de16lsb((const uint8 *)data + 4) * 32768 + 16383) / 32767)) * 255 + 32767) / 65535; + twist = io->twist; //((32768 + MDFN_de16lsb((const uint8 *)data + 2) - (((int32)MDFN_de16lsb((const uint8 *)data + 4) * 32768 + 16383) / 32767)) * 255 + 32767) / 65535; - anabuttons[0] = (MDFN_de16lsb((const uint8 *)data + 6) * 255 + 16383) / 32767; - anabuttons[1] = (MDFN_de16lsb((const uint8 *)data + 8) * 255 + 16383) / 32767; - anabuttons[2] = (MDFN_de16lsb((const uint8 *)data + 10) * 255 + 16383) / 32767; + anabuttons[0] = io->anabuttons[0]; + anabuttons[1] = io->anabuttons[1]; + anabuttons[2] = io->anabuttons[2]; + + //anabuttons[0] = (MDFN_de16lsb((const uint8 *)data + 6) * 255 + 16383) / 32767; + //anabuttons[1] = (MDFN_de16lsb((const uint8 *)data + 8) * 255 + 16383) / 32767; + //anabuttons[2] = (MDFN_de16lsb((const uint8 *)data + 10) * 255 + 16383) / 32767; //printf("%02x %02x %02x %02x\n", twist, anabuttons[0], anabuttons[1], anabuttons[2]); } diff --git a/psx/octoshock/psx/input/negcon.h b/psx/octoshock/psx/input/negcon.h index 74129294b2..52425010e4 100644 --- a/psx/octoshock/psx/input/negcon.h +++ b/psx/octoshock/psx/input/negcon.h @@ -4,5 +4,15 @@ namespace MDFN_IEN_PSX { InputDevice *Device_neGcon_Create(void); + + EW_PACKED( + struct IO_NegCon + { + u8 buttons[2]; + u8 twist; + u8 anabuttons[3]; + u8 active; + }); + } #endif diff --git a/psx/octoshock/psx/psx.cpp b/psx/octoshock/psx/psx.cpp index 70689c0142..c150b843e2 100644 --- a/psx/octoshock/psx/psx.cpp +++ b/psx/octoshock/psx/psx.cpp @@ -31,6 +31,7 @@ #include "input/dualshock.h" #include "input/dualanalog.h" +#include "input/negcon.h" #include "input/gamepad.h" #include "input/memcard.h" @@ -1093,6 +1094,7 @@ struct { case ePeripheralType_Pad: name = "gamepad"; break; case ePeripheralType_DualShock: name = "dualshock"; break; case ePeripheralType_DualAnalog: name = "dualanalog"; break; + case ePeripheralType_NegCon: name = "negcon"; break; default: return SHOCK_ERROR; } @@ -1140,6 +1142,14 @@ struct { return ret; break; } + case ePeripheralType_NegCon: + { + IO_NegCon* io_negcon = (IO_NegCon*)buf; + if (io_negcon->active) ret = SHOCK_TRUE; + if (clear) io_negcon->active = 0; + return ret; + break; + } case ePeripheralType_None: return SHOCK_NOCANDO; @@ -1190,6 +1200,17 @@ struct { io_dualanalog->left_y = left_y; return SHOCK_OK; } + case ePeripheralType_NegCon: + { + IO_NegCon* io_negcon = (IO_NegCon*)buf; + io_negcon->buttons[0] = (buttons >> 0) & 0xFF; + io_negcon->buttons[1] = (buttons >> 8) & 0xFF; + io_negcon->twist = left_x; + io_negcon->anabuttons[0] = left_y; + io_negcon->anabuttons[1] = right_x; + io_negcon->anabuttons[2] = right_y; + return SHOCK_OK; + } default: return SHOCK_ERROR; diff --git a/psx/octoshock/psx/psx.h b/psx/octoshock/psx/psx.h index 85267ddf7b..7dd7a38db1 100644 --- a/psx/octoshock/psx/psx.h +++ b/psx/octoshock/psx/psx.h @@ -170,6 +170,7 @@ enum ePeripheralType ePeripheralType_Pad = 1, //SCPH-1080 ePeripheralType_DualShock = 2, //SCPH-1200 ePeripheralType_DualAnalog = 3, //SCPH-1180 + ePeripheralType_NegCon = 4, ePeripheralType_Multitap = 10, };