1
0
mirror of synced 2025-02-17 11:08:36 +01:00

Add in serial passthrough

This commit is contained in:
Bobby Dilley 2024-01-31 23:25:56 +00:00
parent 305004d423
commit c8a8c1122f
4 changed files with 29 additions and 30 deletions

View File

@ -2,7 +2,7 @@
# Written by Bobby Dilley
# Set the colour of the lindbergh to change the Segaboot logo
# Possibly colours are: YELLOW and RED
# Possible colours are: YELLOW and RED
LINDBERGH_COLOUR YELLOW
# Choice of resolutions
@ -44,14 +44,11 @@ EMULATE_MOTIONBOARD 0
# Define the path to pass the JVS packets to
JVS_PATH /dev/ttyUSB0
# Define the path to pass the rideboard packets to
RIDEBOARD_PATH /dev/ttyUSB0
# Define the path to pass the first serial port to
SERIAL_1_PATH /dev/ttyUSB0
# Define the path to pass the driveboard packets to
DRIVEBOARD_PATH /dev/ttyUSB0
# Define the path to pass the motionboard packets to
MOTIONBOARD_PATH /dev/ttyUSB0
# Define the path to pass the second serial port to
SERIAL_2_PATH /dev/ttyUSB0
# Define the path to the sram.bin file
SRAM_PATH sram.bin

View File

@ -82,6 +82,8 @@ static int detectGame(uint32_t elf_crc)
config.gameTitle = "The House of the Dead 4 Special";
config.emulateRideboard = 1;
config.gameStatus = WORKING;
config.width = 1024;
config.height = 768;
return 0;
}
break;
@ -363,14 +365,11 @@ int readConfig(FILE *configFile, EmulatorConfig *config)
else if (strcmp(command, "JVS_PATH") == 0)
strcpy(config->jvsPath, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "RIDEBOARD_PATH") == 0)
strcpy(config->rideboardPath, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "SERIAL_1_PATH") == 0)
strcpy(config->serial1Path, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "DRIVEBOARD_PATH") == 0)
strcpy(config->driveboardPath, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "MOTIONBOARD_PATH") == 0)
strcpy(config->motionboardPath, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "SERIAL_2_PATH") == 0)
strcpy(config->serial2Path, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "FREEPLAY") == 0)
config->freeplay = atoi(getNextToken(NULL, " ", &saveptr));
@ -415,10 +414,9 @@ int initConfig()
config.lindberghColour = YELLOW;
strcpy(config.eepromPath, "eeprom.bin");
strcpy(config.sramPath, "sram.bin");
strcpy(config.jvsPath, "none");
strcpy(config.driveboardPath, "none");
strcpy(config.motionboardPath, "none");
strcpy(config.rideboardPath, "none");
strcpy(config.jvsPath, "/dev/ttyUSB0");
strcpy(config.serial1Path, "/dev/ttyS0");
strcpy(config.serial2Path, "/dev/ttyS1");
config.width = 640;
config.height = 480;
config.crc32 = elf_crc;

View File

@ -93,9 +93,8 @@ typedef struct
char eepromPath[MAX_PATH_LENGTH];
char sramPath[MAX_PATH_LENGTH];
char jvsPath[MAX_PATH_LENGTH];
char rideboardPath[MAX_PATH_LENGTH];
char motionboardPath[MAX_PATH_LENGTH];
char driveboardPath[MAX_PATH_LENGTH];
char serial1Path[MAX_PATH_LENGTH];
char serial2Path[MAX_PATH_LENGTH];
int width;
int height;
Colour lindberghColour;

View File

@ -188,7 +188,6 @@ void __attribute__((constructor)) hook_init()
printf(" GAME ID: %s\n", getGameID());
printf(" DVP: %s\n", getDVPName());
printf(" STATUS: %s\n", getConfig()->gameStatus == WORKING ? "WORKING" : "NOT WORKING");
}
int open(const char *pathname, int flags)
@ -211,6 +210,9 @@ int open(const char *pathname, int flags)
if (strcmp(pathname, "/dev/ttyS0") == 0 || strcmp(pathname, "/dev/tts/0") == 0)
{
if (getConfig()->emulateDriveboard == 0 && getConfig()->emulateRideboard == 0)
return _open(getConfig()->serial1Path, flags);
if (hooks[SERIAL0] != -1)
return -1;
@ -221,6 +223,9 @@ int open(const char *pathname, int flags)
if (strcmp(pathname, "/dev/ttyS1") == 0 || strcmp(pathname, "/dev/tts/1") == 0)
{
if (getConfig()->emulateMotionboard == 0)
return _open(getConfig()->serial2Path, flags);
if (hooks[SERIAL1] != -1)
return -1;
@ -301,16 +306,16 @@ FILE *fopen(const char *restrict pathname, const char *restrict mode)
return fileHooks[PCI_CARD_1F0];
}
char* result;
if((result = strstr(pathname, "/home/disk0")) != NULL)
char *result;
if ((result = strstr(pathname, "/home/disk0")) != NULL)
{
memmove(result + 2, result + 11, strlen(result + 11) + 1);
memcpy(result, "..", 2);
return _fopen(result, mode);
}
//printf("Path= %s\n", pathname);
// printf("Path= %s\n", pathname);
return _fopen(pathname, mode);
}
@ -466,8 +471,8 @@ size_t fread(void *buf, size_t size, size_t count, FILE *stream)
if (stream == fileHooks[PCI_CARD_1F0])
{
memcpy(buf, pci_1f0, size*count);
return size*count;
memcpy(buf, pci_1f0, size * count);
return size * count;
}
return _fread(buf, size, count, stream);
}
@ -507,7 +512,7 @@ int ioctl(int fd, unsigned int request, void *data)
if (fd == hooks[EEPROM])
{
if(request == 0xC04064A0)
if (request == 0xC04064A0)
return _ioctl(fd, request, data);
return eepromIoctl(fd, request, data);
}