summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-11-16 00:36:51 +0100
committerXavier Del Campo Romero <xavi92@disroot.org>2025-11-16 00:36:51 +0100
commit788fb20656c8450a3f2da8b3f8b1905242103193 (patch)
treeae6e1a2c9e7da0fe72b070d2db580adf26e410af /plugins
parent8349bf45e9b19d83506e1bb52f2053a7976922e5 (diff)
WIP TCP/SIOsio
Diffstat (limited to 'plugins')
-rw-r--r--plugins/bladesio1/connection.c16
-rw-r--r--plugins/bladesio1/sio1.c23
-rw-r--r--plugins/dfinput/pad.c30
-rw-r--r--plugins/dfinput/pad.h2
-rw-r--r--plugins/dfnet/dfnet.c20
-rw-r--r--plugins/dfnet/dfnet.h32
-rw-r--r--plugins/dfnet/gui.c14
-rw-r--r--plugins/dfxvideo/cfg.c6
-rw-r--r--plugins/dfxvideo/draw.c20
9 files changed, 96 insertions, 67 deletions
diff --git a/plugins/bladesio1/connection.c b/plugins/bladesio1/connection.c
index c922f2f2..bf083e92 100644
--- a/plugins/bladesio1/connection.c
+++ b/plugins/bladesio1/connection.c
@@ -25,6 +25,7 @@
#if defined _WINDOWS
#include <winsock2.h>
#else
+#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@@ -68,14 +69,14 @@ int connectionOpen() {
#endif
return -1;
}
-
+
setsockopt(serversock, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse_addr, sizeof(reuse_addr));
setsockopt(serversock, IPPROTO_TCP, TCP_NODELAY, (const char*)&one, sizeof(one));
memset(&address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
- address.sin_port = settings.port;
+ address.sin_port = htons(settings.port);
if(bind(serversock,(struct sockaddr*)&address,sizeof(address)) == -1) {
#if defined _WINDOWS
@@ -167,9 +168,16 @@ int connectionSend(u8 *pdata, s32 size) {
int connectionRecv(u8 *pdata, s32 size) {
int bytes = 0;
- if(clientsock >= 0)
- if((bytes = (int)recv(clientsock, (char*)pdata, size, 0)) < 0)
+ if(clientsock >= 0) {
+ int flags = fcntl(clientsock, F_GETFL, 0);
+
+ fcntl(clientsock, F_SETFL, flags | O_NONBLOCK);
+ if((bytes = (int)recv(clientsock, (char*)pdata, size, 0)) < 0) {
+ fcntl(clientsock, F_SETFL, flags);
return 0;
+ }
+ fcntl(clientsock, F_SETFL, flags);
+ }
return bytes;
}
diff --git a/plugins/bladesio1/sio1.c b/plugins/bladesio1/sio1.c
index feab1bb6..6c16e964 100644
--- a/plugins/bladesio1/sio1.c
+++ b/plugins/bladesio1/sio1.c
@@ -55,8 +55,6 @@ static const unsigned char build = 1;
static void (CALLBACK *irqCallback)() = 0;
-Settings settings;
-
/* sio status flags.
*/
enum {
@@ -210,6 +208,8 @@ void Exchange(s32 data) {
exc_data_send.len = 1;
exc_data_send.data = data;
+ connectionSend((u8*)&exc_data_send.data, exc_data_send.len);
+
if(ctrlReg & CR_TXIEN) {
if(!(statReg & SR_IRQ)) {
#if defined SIO1_DEBUG
@@ -221,6 +221,7 @@ void Exchange(s32 data) {
}
}
+#if 0
if(settings.player == PLAYER_MASTER) {
connectionSend((u8*)&exc_data_send, sizeof(exc_data_send));
connectionRecv((u8*)&exc_data_recv, sizeof(exc_data_recv));
@@ -229,7 +230,7 @@ void Exchange(s32 data) {
connectionRecv((u8*)&exc_data_recv, sizeof(exc_data_recv));
connectionSend((u8*)&exc_data_send, sizeof(exc_data_send));
}
-
+#endif
if(exc_data_recv.reg & CR_DTR)
statReg |= SR_DSR;
else
@@ -240,6 +241,10 @@ void Exchange(s32 data) {
else
statReg &= ~SR_CTS;
+ if (SR_CTS & SR_CTS) {
+ exc_data_recv.len = connectionRecv((u8*)&exc_data_recv.data, 1);
+ }
+
if(exc_data_recv.len) {
fifoPush(exc_data_recv.data);
@@ -249,7 +254,7 @@ void Exchange(s32 data) {
}
if(ctrlReg & CR_RXIEN) {
- if(fifoEmployment() == fifoIrqVals[(ctrlReg >> 8) & 0x03]) {
+ if(fifoEmployment() >= fifoIrqVals[(ctrlReg >> 8) & 0x03]) {
if(!(statReg & SR_IRQ)) {
#if defined SIO1_DEBUG
printf("irqCallback() : CR_RXIEN\n");
@@ -352,7 +357,7 @@ void CALLBACK SIO1writeCtrl16(u16 ctrl) {
if(ctrlReg & CR_ERRRST) {
ctrlReg &= ~CR_ERRRST;
statReg &= ~(SR_PERROR | SR_OE | SR_FE | SR_IRQ);
-
+
fifoResetErr();
}
@@ -363,15 +368,15 @@ void CALLBACK SIO1writeCtrl16(u16 ctrl) {
ctrlReg = 0;
baudReg = 0;
}
-
+
// FIXME: buffer not cleared and overrun possible, but flag must be cleared.
//if(!(ctrlReg & CR_RXEN))
// statReg &= ~SR_RXRDY;
-
+
// FIXME: ugly hack for C&C: RA and C&C: RAR.
if(((ctrlReg >> 8) & 0x03) != ((ctrlSaved >> 8) & 0x03))
fifoReset();
-
+
// FIXME: move to Exchange.
if(ctrlReg & CR_TXIEN) {
if(!(statReg & SR_IRQ)) {
@@ -382,7 +387,7 @@ void CALLBACK SIO1writeCtrl16(u16 ctrl) {
statReg |= SR_IRQ;
}
}
-
+
Exchange(-1);
}
diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c
index f413d0a4..9755ccbd 100644
--- a/plugins/dfinput/pad.c
+++ b/plugins/dfinput/pad.c
@@ -30,7 +30,7 @@
#if SDL_VERSION_ATLEAST(2,0,0)
int has_haptic;
-SDL_GameControllerButton controllerMap[] = {
+SDL_GameControllerButton controllerMap[DKEY_TOTAL] = {
SDL_CONTROLLER_BUTTON_BACK,
SDL_CONTROLLER_BUTTON_LEFTSTICK,
SDL_CONTROLLER_BUTTON_RIGHTSTICK,
@@ -47,7 +47,7 @@ SDL_GameControllerButton controllerMap[] = {
SDL_CONTROLLER_BUTTON_B,
SDL_CONTROLLER_BUTTON_A,
SDL_CONTROLLER_BUTTON_X,
-
+
SDL_CONTROLLER_BUTTON_GUIDE
};
#endif
@@ -69,7 +69,7 @@ uint32_t PSEgetLibVersion(void) {
static int padDataLenght[] = {0, 2, 3, 1, 1, 3, 3, 3};
void PADsetMode(const int pad, const int mode) {
g.PadState[pad].PadMode = mode;
-
+
if (g.cfg.PadDef[pad].Type == PSE_PAD_TYPE_ANALOGPAD) {
g.PadState[pad].PadID = mode ? 0x73 : 0x41;
}
@@ -77,7 +77,7 @@ void PADsetMode(const int pad, const int mode) {
g.PadState[pad].PadID = (g.cfg.PadDef[pad].Type << 4) |
padDataLenght[g.cfg.PadDef[pad].Type];
}
-
+
g.PadState[pad].Vib0 = 0;
g.PadState[pad].Vib1 = 0;
g.PadState[pad].VibF[0] = 0;
@@ -123,10 +123,10 @@ long PADopen(unsigned long *Disp) {
} else if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) == -1) {
return PSE_PAD_ERR_FAILURE;
}
-
+
#if SDL_VERSION_ATLEAST(2,0,0)
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
-
+
has_haptic = 0;
if (SDL_InitSubSystem(SDL_INIT_HAPTIC) == 0)
has_haptic = 1;
@@ -217,22 +217,22 @@ static uint8_t unk4c[2][8] = {
{0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
};
-static uint8_t unk4d[2][8] = {
+static uint8_t unk4d[2][8] = {
{0xFF, 0x5A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
{0xFF, 0x5A, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
};
-static uint8_t stdcfg[2][8] = {
+static uint8_t stdcfg[2][8] = {
{0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
};
-static uint8_t stdmode[2][8] = {
+static uint8_t stdmode[2][8] = {
{0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
};
-static uint8_t stdmodel[2][8] = {
+static uint8_t stdmodel[2][8] = {
{0xFF,
0x5A,
0x01, // 03 - dualshock2, 01 - dualshock
@@ -241,7 +241,7 @@ static uint8_t stdmodel[2][8] = {
0x02,
0x01,
0x00},
- {0xFF,
+ {0xFF,
0x5A,
0x01, // 03 - dualshock2, 01 - dualshock
0x02, // number of modes
@@ -250,7 +250,7 @@ static uint8_t stdmodel[2][8] = {
0x01,
0x00}
};
-
+
#if !SDL_VERSION_ATLEAST(2,0,0) && defined(__linux__)
/* lifted from SDL; but it's GPL as well */
/* added ffbit, though */
@@ -477,7 +477,7 @@ unsigned char PADpoll(unsigned char value) {
else if(g.PadState[CurPad].PadID == 0x12)
{
CmdLen = 6;
-
+
stdpar[CurPad][4] = g.PadState[0].MouseAxis[0][0];
stdpar[CurPad][5] = g.PadState[0].MouseAxis[0][1];
}
@@ -537,7 +537,7 @@ unsigned char PADpoll(unsigned char value) {
if (!JoyHapticRumble(CurPad, g.PadState[CurPad].VibF[0], g.PadState[CurPad].VibF[1])) {
//gpuVisualVibration(g.PadState[CurPad].VibF[0], g.PadState[CurPad].VibF[1]);
}
-
+
if(gpuVisualVibration != NULL &&
g.cfg.PadDef[CurPad].VisualVibration) {
gpuVisualVibration(g.PadState[CurPad].VibF[0], g.PadState[CurPad].VibF[1]);
@@ -666,7 +666,7 @@ long PADreadPort2(PadDataS *pad) {
long PADkeypressed(void) {
long s;
-
+
static int frame = 0;
if( !frame )
UpdateInput();
diff --git a/plugins/dfinput/pad.h b/plugins/dfinput/pad.h
index 3051e6ad..625d4102 100644
--- a/plugins/dfinput/pad.h
+++ b/plugins/dfinput/pad.h
@@ -151,7 +151,7 @@ typedef struct tagKeyDef {
enum { ANALOG_XP = 0, ANALOG_XM, ANALOG_YP, ANALOG_YM };
#if SDL_VERSION_ATLEAST(2,0,0)
-SDL_GameControllerButton controllerMap[DKEY_TOTAL];
+extern SDL_GameControllerButton controllerMap[DKEY_TOTAL];
#endif
typedef struct tagPadDef {
diff --git a/plugins/dfnet/dfnet.c b/plugins/dfnet/dfnet.c
index fcd438b5..205ae307 100644
--- a/plugins/dfnet/dfnet.c
+++ b/plugins/dfnet/dfnet.c
@@ -16,6 +16,22 @@ extern int errno;
#include "dfnet.h"
+struct timeval tm;
+Config conf;
+int sock;
+char *PadSendData;
+char *PadRecvData;
+char PadSendSize;
+char PadRecvSize;
+char PadSize[2];
+int PadCount;
+int PadCountMax;
+int PadInit;
+int Ping;
+volatile int WaitCancel;
+fd_set rset;
+fd_set wset;
+
const unsigned char version = 2; // NET library v2
const unsigned char revision = 0;
const unsigned char build = 3; // increase that with each version
@@ -125,8 +141,8 @@ long CALLBACK NETopen(unsigned long *gpuDisp) {
if (bind(listen_sock,(struct sockaddr *) &address, sizeof(address)) == -1)
return -1;
- if (listen(listen_sock, 1) != 0)
- return -1;
+ if (listen(listen_sock, 1) != 0)
+ return -1;
sock = -1;
diff --git a/plugins/dfnet/dfnet.h b/plugins/dfnet/dfnet.h
index b824a790..d29e642d 100644
--- a/plugins/dfnet/dfnet.h
+++ b/plugins/dfnet/dfnet.h
@@ -56,8 +56,6 @@ __private_extern char* PLUGLOC(char* toloc);
typedef void* HWND;
-struct timeval tm;
-
#define CALLBACK
long timeGetTime();
@@ -70,25 +68,25 @@ typedef struct {
char ipAddress[32];
} Config;
-Config conf;
+extern struct timeval tm;
+extern Config conf;
+extern int sock;
+extern char *PadSendData;
+extern char *PadRecvData;
+extern char PadSendSize;
+extern char PadRecvSize;
+extern char PadSize[2];
+extern int PadCount;
+extern int PadCountMax;
+extern int PadInit;
+extern int Ping;
+extern volatile int WaitCancel;
+extern fd_set rset;
+extern fd_set wset;
void LoadConf();
void SaveConf();
-int sock;
-char *PadSendData;
-char *PadRecvData;
-char PadSendSize;
-char PadRecvSize;
-char PadSize[2];
-int PadCount;
-int PadCountMax;
-int PadInit;
-int Ping;
-volatile int WaitCancel;
-fd_set rset;
-fd_set wset;
-
long sockInit();
long sockShutdown();
long sockOpen();
diff --git a/plugins/dfnet/gui.c b/plugins/dfnet/gui.c
index 85d0871f..746f34a6 100644
--- a/plugins/dfnet/gui.c
+++ b/plugins/dfnet/gui.c
@@ -15,6 +15,8 @@
#include "cfg.c"
+Config conf;
+
void cfgSysMessage(const char *fmt, ...) {
GtkWidget *MsgDlg;
va_list list;
@@ -220,16 +222,16 @@ int main(int argc, char *argv[]) {
return 0;
}
- if (strcmp(argv[1], "about") != 0 &&
- strcmp(argv[1], "configure") != 0 &&
- strcmp(argv[1], "open") != 0 &&
- strcmp(argv[1], "wait") != 0 &&
- strcmp(argv[1], "pause") != 0 &&
+ if (strcmp(argv[1], "about") != 0 &&
+ strcmp(argv[1], "configure") != 0 &&
+ strcmp(argv[1], "open") != 0 &&
+ strcmp(argv[1], "wait") != 0 &&
+ strcmp(argv[1], "pause") != 0 &&
strcmp(argv[1], "message") != 0) {
printf ("Usage: cfgDFNet {about | configure | open | wait | pause | message}\n");
return 0;
}
-
+
if(argc > 1) {
if (!strcmp(argv[1], "configure")) {
CFGconfigure();
diff --git a/plugins/dfxvideo/cfg.c b/plugins/dfxvideo/cfg.c
index 67f79a8a..e549c96e 100644
--- a/plugins/dfxvideo/cfg.c
+++ b/plugins/dfxvideo/cfg.c
@@ -262,13 +262,13 @@ void WriteConfig(void) {
FILE *out;char t[256];int len, size;
char * pB, * p; char t1[8];
- if(pConfigFile)
+ if(pConfigFile)
strcpy(t,pConfigFile);
- else
+ else
{
strcpy(t,"dfxvideo.cfg");
out = fopen(t,"rb");
- if (!out)
+ if (!out)
{
strcpy(t,"cfg/dfxvideo.cfg");
out = fopen(t,"rb");
diff --git a/plugins/dfxvideo/draw.c b/plugins/dfxvideo/draw.c
index 3cc5e1c2..76007919 100644
--- a/plugins/dfxvideo/draw.c
+++ b/plugins/dfxvideo/draw.c
@@ -82,7 +82,7 @@ void * pSaIBigBuff=NULL;
#define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D))
-static __inline int GetResult1(DWORD A, DWORD B, DWORD C, DWORD D, DWORD E)
+static int GetResult1(DWORD A, DWORD B, DWORD C, DWORD D, DWORD E)
{
int x = 0;
int y = 0;
@@ -94,7 +94,7 @@ static __inline int GetResult1(DWORD A, DWORD B, DWORD C, DWORD D, DWORD E)
return r;
}
-static __inline int GetResult2(DWORD A, DWORD B, DWORD C, DWORD D, DWORD E)
+static int GetResult2(DWORD A, DWORD B, DWORD C, DWORD D, DWORD E)
{
int x = 0;
int y = 0;
@@ -107,7 +107,7 @@ static __inline int GetResult2(DWORD A, DWORD B, DWORD C, DWORD D, DWORD E)
}
/* Convert RGB to YUV */
-__inline uint32_t rgb_to_yuv(uint8_t R, uint8_t G, uint8_t B) {
+static uint32_t rgb_to_yuv(uint8_t R, uint8_t G, uint8_t B) {
uint8_t Y = min(abs(R * 2104 + G * 4130 + B * 802 + 4096 + 131072) >> 13, 235);
uint8_t U = min(abs(R * -1214 + G * -2384 + B * 3598 + 4096 + 1048576) >> 13, 240);
uint8_t V = min(abs(R * 3598 + G * -3013 + B * -585 + 4096 + 1048576) >> 13, 240);
@@ -653,7 +653,7 @@ void SuperEagle_ex8(unsigned char *srcPtr, DWORD srcPitch,
//#include <assert.h>
-static __inline void scale2x_32_def_whole(uint32_t* dst0, uint32_t* dst1, const uint32_t* src0, const uint32_t* src1, const uint32_t* src2, unsigned count)
+static void scale2x_32_def_whole(uint32_t* dst0, uint32_t* dst1, const uint32_t* src0, const uint32_t* src1, const uint32_t* src2, unsigned count)
{
//assert(count >= 2);
@@ -750,7 +750,7 @@ void Scale2x_ex8(unsigned char *srcPtr, DWORD srcPitch,
////////////////////////////////////////////////////////////////////////
-static __inline void scale3x_32_def_whole(uint32_t* dst0, uint32_t* dst1, uint32_t* dst2, const uint32_t* src0, const uint32_t* src1, const uint32_t* src2, unsigned count)
+static void scale3x_32_def_whole(uint32_t* dst0, uint32_t* dst1, uint32_t* dst2, const uint32_t* src0, const uint32_t* src1, const uint32_t* src2, unsigned count)
{
//assert(count >= 2);
@@ -1053,7 +1053,8 @@ void CreateDisplay(void)
#ifdef __BIG_ENDIAN__
if ( fo[j].type == XvYUV && fo[j].bits_per_pixel == 16 && fo[j].format == XvPacked && strncmp("YUYV", fo[j].component_order, 5) == 0 )
#else
- if ( fo[j].type == XvYUV && fo[j].bits_per_pixel == 16 && fo[j].format == XvPacked && strncmp("UYVY", fo[j].component_order, 5) == 0 )
+ /*if ( fo[j].type == XvYUV && fo[j].bits_per_pixel == 16 && fo[j].format == XvPacked && strncmp("UYVY", fo[j].component_order, 5) == 0 )*/
+ if ( fo[j].type == XvYUV && fo[j].bits_per_pixel == 12 && fo[j].format == XvPlanar && strcmp("YVU", fo[j].component_order) == 0 )
#endif
{
yuv_port = p;
@@ -1065,7 +1066,7 @@ void CreateDisplay(void)
rgb_id = fo[j].id;
xv_depth = fo[j].depth;
printf("RGB mode found. id: %x, depth: %d\n", xv_id, xv_depth);
-
+
if (xv_depth != depth) {
printf("Warning: Depth does not match screen depth (%d)\n", depth);
}
@@ -1078,7 +1079,6 @@ void CreateDisplay(void)
}
// Are we searching for a specific mode?
- /*
if ( fo[j].id == uOverrideMode) {
if (fo[j].type == XvYUV) {
xv_id = yuv_id = fo[j].id;
@@ -1095,7 +1095,7 @@ void CreateDisplay(void)
p = p_num_ports;
i = p_num_adaptors;
//break;
- }*/
+ }
}
if (fo)
XFree(fo);
@@ -1594,7 +1594,7 @@ extern time_t tStart;
* The aspect of the psx output mode is preserved.
* Note: dest dx,dy,dw,dh are both input and output variables
*/
-__inline void MaintainAspect(uint32_t * dx, uint32_t * dy, uint32_t * dw, uint32_t * dh)
+void MaintainAspect(uint32_t * dx, uint32_t * dy, uint32_t * dw, uint32_t * dh)
{
double ratio_x = ((double)*dw) / ((double)PSXDisplay.DisplayMode.x) ;