From 28ae6d44134c46ce13b2fb335b9a581f2c6f8a46 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 9 Feb 2020 23:50:37 -0500 Subject: [PATCH] octoshock: fix up some mess in port wiring. should fix #1787 but I'm not completely sure. also BEWARE: note the change to UpdateInput(). This was a brain-dead mistake as far as I can tell (just look at it, it seems obvious), and it came from a commit where I said "I tested it for 20 seconds" so it was probably rushed. However, fixing this to something sensible MAY affect sync. If it's important, we could roll it back. However I think UpdateInput is more like a "latch user input" than a "tick internal counters" so it may be safe --- psx/octoshock/psx/psx.cpp | 40 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/psx/octoshock/psx/psx.cpp b/psx/octoshock/psx/psx.cpp index ba54c1f17b..3a5207b153 100644 --- a/psx/octoshock/psx/psx.cpp +++ b/psx/octoshock/psx/psx.cpp @@ -36,7 +36,7 @@ #include "input/memcard.h" #include "input/multitap.h" - +#include #include #include @@ -1058,11 +1058,18 @@ struct ShockState struct ShockPeripheral { - ePeripheralType type; + ePeripheralType type = ePeripheralType_None; u8 buffer[32]; //must be larger than 16+3+1 or thereabouts because the dualshock writes some rumble data into it. bleck, ill fix it later //TODO: test for multitap. does it need to be as large as 4 of whatever the single largest port would be? //well, it must manage its own stuff.. its not like we feed in external data, right? - InputDevice* device; + InputDevice* device = nullptr; + + ~ShockPeripheral() + { + //do not do this! FIO takes care of finishing this off + //I know, it's all a mess + //delete device; + } }; static int addressToPortNum(int address) @@ -1087,15 +1094,13 @@ struct { //"This is kind of redundant with the frontIO code, and should be merged with it eventually, when the configurability gets more advanced" //I dunno. - ShockPeripheral ports[10]; + std::array ports; void Initialize() { + reconstruct(&ports); for(int i=0;i<10;i++) - { - ports[i].type = ePeripheralType_None; memset(ports[i].buffer,0,sizeof(ports[i].buffer)); - } reconstruct(FIO); } @@ -1133,6 +1138,7 @@ struct { return SHOCK_ERROR; } ports[portnum].type = (ePeripheralType)type; + if(ports[portnum].device) delete ports[portnum].device; ports[portnum].device = next; memset(ports[portnum].buffer,0,sizeof(ports[portnum].buffer)); @@ -1303,13 +1309,10 @@ struct { void UpdateInput() { - for(int i=0;i<10;i++) + for(int i=0;iUpdateInput(ports[i].buffer); - } + if(ports[i].device) + ports[i].device->UpdateInput(ports[i].buffer); } } @@ -2494,14 +2497,9 @@ EW_EXPORT s32 shock_AnalyzeDisc(ShockDiscRef* disc, ShockDiscInfo* info) } } } - catch(const char* str) - { - //puts(e.what()); - int zzz=9; - } - catch(...) - { - int zzz=9; + catch(const char* str) + { + //puts(e.what()); } //uhmm couldnt find system.cnf. try another way