1
0
mirror of synced 2024-11-27 22:50:47 +01:00

Make config actually work

This commit is contained in:
Bobby Dilley 2022-07-20 19:52:45 +01:00
parent 90884f647e
commit 52b6e2a283
8 changed files with 85 additions and 40 deletions

View File

@ -53,26 +53,4 @@ This is an emulation of the driver that games use to route sound out of the Crea
## Config
### EMULATE_JVS
This turns on the JVS emulation layer, which will use X11s input capabilities to read your mouse/keyboard. When this is turned off the JVS traffic will be passed through to a serial port defined by `JVS_PATH`.
### JVS_PATH
This defines the path of the serial port that is connected to the JVS IO.
### FULLSCREEN
This defines if the game should open in full screen mode.
### EMULATE_RIDEBOARD
This turns on the Rideboard emulation layer used in the games The House Of The Dead 4 Special, and Let's Go Jungle Special!
### EMULATE_DRIVEBOARD
This turns on the Driveboard emulation layer used in the games Outrun 2 SP SDX, SEGA Race TV, Initial D 4 and Initial D 5.
### EMULATE_MOTIONBOARD
This turns on the motionboard emulation layer used in the game Outrun 2 SP SDX in its SDX setting.
A default configuration file is provided in `docs/lindbergh.conf`. It should be placed in the same folder as the game is run from. If no config file is present a default setting will be used.

View File

@ -1,5 +0,0 @@
# Turn off JVS emulation and default to JVS Passthrough
EMULATE_JVS 0
# The path to the real JVS IO you'd like to use
JVS_PATH /dev/ttyUSB0

View File

@ -1,2 +0,0 @@
EMULATE_DRIVEBOARD 1
EMULATE_RIDEBOARD 1

View File

@ -1,2 +0,0 @@
# Emulate the special rideboard
EMULATE_RIDEBOARD 1

View File

@ -1,11 +1,33 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
EmulatorConfig config = {0};
FILE *configFile = NULL;
#define CONFIG_PATH "lindbergh.conf"
#define MAX_LINE_LENGTH 1024
static char *getNextToken(char *buffer, char *seperator, char **saveptr)
{
char *token = strtok_r(buffer, seperator, saveptr);
if (token == NULL)
return NULL;
for (int i = 0; i < (int)strlen(token); i++)
{
if ((token[i] == '\n') || (token[i] == '\r'))
{
token[i] = 0;
}
}
return token;
}
static int detectGame()
{
@ -54,6 +76,48 @@ char *getGameName()
return "Unknown Game";
}
int readConfig(FILE *configFile, EmulatorConfig *config)
{
char buffer[MAX_LINE_LENGTH];
char *saveptr = NULL;
while (fgets(buffer, MAX_LINE_LENGTH, configFile))
{
/* Check for comments */
if (buffer[0] == '#' || buffer[0] == 0 || buffer[0] == ' ' || buffer[0] == '\r' || buffer[0] == '\n')
continue;
char *command = getNextToken(buffer, " ", &saveptr);
if (strcmp(command, "WIDTH") == 0)
config->width = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "HEIGHT") == 0)
config->height = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "EEPROM_PATH") == 0)
strcpy(config->eepromPath, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "SRAM_PATH") == 0)
strcpy(config->eepromPath, getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "EMULATE_RIDEBOARD") == 0)
config->emulateRideboard = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "EMULATE_DRIVEBOARD") == 0)
config->emulateDriveboard = atoi(getNextToken(NULL, " ", &saveptr));
else if (strcmp(command, "EMULATE_MOTIONBOARD") == 0)
config->emulateMotionboard = atoi(getNextToken(NULL, " ", &saveptr));
else
printf("Error: Unknown settings command %s\n", command);
}
return 0;
}
int initConfig()
{
config.emulateRideboard = 0;
@ -67,6 +131,19 @@ int initConfig()
{
printf("Warning: Unsure what game this is, using default configuration values");
}
configFile = fopen(CONFIG_PATH, "r");
if (configFile == NULL)
{
printf("Error: Cannot open %s, using default values\n", CONFIG_PATH);
return 1;
}
readConfig(configFile, &config);
fclose(configFile);
return 0;
}

View File

@ -116,7 +116,6 @@ int XNextEvent(Display *display, XEvent *event_return)
int (*_XNextEvent)(Display * display, XEvent * event_return) = dlsym(RTLD_NEXT, "XNextEvent");
int returnValue = _XNextEvent(display, event_return);
switch (event_return->type)
{
case KeyPress:
@ -124,7 +123,6 @@ int XNextEvent(Display *display, XEvent *event_return)
{
case 28:
securityBoardSetSwitch(BUTTON_TEST, 1);
abort();
break;
case 39:
securityBoardSetSwitch(BUTTON_SERVICE, 1);

View File

@ -94,7 +94,7 @@ static void handleSegfault(int signal, siginfo_t *info, void *ptr)
default:
printf("Warning: Skipping SEGFAULT %X\n", *code);
ctx->uc_mcontext.gregs[REG_EIP]++;
// abort();
//abort();
}
}
@ -317,16 +317,15 @@ int system(const char *command)
if (strcmp(command, "mkdir /tmp/segaboot > /dev/null") == 0)
return system("mkdir tmp/segaboot > /dev/null");
/*
if (strcmp(command, "lspci | grep \"Multimedia audio controller: %Creative\" > /dev/null") == 0)
if (strcmp(command, "lspci | grep \"Multimedia audio controller: %Creative\" > /dev/null") == 0)
return 0;
if (strcmp(command, "lsmod | grep ctaud") == 0)
if (strcmp(command, "lsmod | grep ctaud") == 0)
return 0;
if (strcmp(command, "lspci | grep MPC8272 > /dev/null") == 0)
if (strcmp(command, "lspci | grep MPC8272 > /dev/null") == 0)
return 0;
*/
return _system(command);
}

View File

@ -5,6 +5,7 @@
#include "config.h"
#define SECURITY_BOARD_FRONT_PANEL 0x38
#define SECURITY_BOARD_FRONT_PANEL_NON_ROOT 0x1038
#define SECURITY_BOARD_KEYCHIP 0xFF
#define DIP_SWITCH_ROTATION 3
@ -101,6 +102,7 @@ int securityBoardIn(uint16_t port, uint32_t *data)
{
switch (port)
{
case SECURITY_BOARD_FRONT_PANEL_NON_ROOT:
case SECURITY_BOARD_FRONT_PANEL:
{
uint32_t result = 0xFFFFFFFF;