1
0
mirror of synced 2024-11-27 19:10:48 +01:00

Fix JVS and Tidy Up

This commit is contained in:
Bobby Dilley 2023-12-29 14:02:24 +00:00
parent 788bd1131d
commit d6625d3068
11 changed files with 88 additions and 67 deletions

View File

@ -69,4 +69,4 @@ REGION EX
FREEPLAY 1
# Set if you want to see degug messages in the console
DEBUG_MSGS 0
DEBUG_MSGS 0

View File

@ -60,6 +60,7 @@ uint8_t sharedMemory[1024 * 32] = {0};
int selectReply = -1;
int jvsFileDescriptor = -1;
int jvsPacketSize = -1;
int initBaseboard()
{
@ -192,7 +193,7 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
if (getConfig()->emulateJVS)
{
processPacket();
processPacket(&jvsPacketSize);
}
else if (jvsFileDescriptor >= 0)
{
@ -251,9 +252,9 @@ int baseboardIoctl(int fd, unsigned int request, void *data)
{
if (getConfig()->emulateJVS)
{
memcpy(&sharedMemory[jvsCommand.destAddress], outputBuffer, outputPacket.length + 3);
memcpy(&sharedMemory[jvsCommand.destAddress], outputBuffer, jvsPacketSize);
_data[2] = jvsCommand.destAddress;
_data[3] = outputPacket.length + 3;
_data[3] = jvsPacketSize;
_data[1] = 1; // Set the status to success
}
else if (jvsFileDescriptor >= 0)

View File

@ -47,13 +47,6 @@ static int detectGame(uint32_t elf_crc)
return 0;
}
if (elf_crc == 0x3cc635ee)
{
config.game = SEGABOOT_2_4_SYM;
config.gameStatus = WORKING;
return 0;
}
if (elf_crc == 0xbc0c9ffa)
{
config.game = THE_HOUSE_OF_THE_DEAD_4;
@ -279,7 +272,7 @@ char *getGameName()
case SEGABOOT_2_4:
return "SEGABOOT 2.4";
case SEGABOOT_2_4_SYM:
return "SEGABOOT 2.4 Symbols";
return "SEGABOOT 2.4 with Symbols";
case SEGABOOT_2_6:
return "SEGABOOT 2.6";
case SEGA_RACE_TV:
@ -319,7 +312,7 @@ char *getGameName()
case VIRTUA_TENNIS_3_TEST:
return "Virtua Tennis 3 Test Mode";
case THE_HOUSE_OF_THE_DEAD_4_STRIPPED:
return "The House of the Dead 4";
return "The House of the Dead 4 Rev C";
case INITIALD_4_REVE:
return "Initial D 4 Exp Rev E";
default:
@ -405,7 +398,7 @@ int readConfig(FILE *configFile, EmulatorConfig *config)
}
else if (strcmp(command, "DEBUG_MSGS") == 0)
config->debug_msgs = atoi(getNextToken(NULL, " ", &saveptr));
config->showDebugMessages = atoi(getNextToken(NULL, " ", &saveptr));
else
printf("Error: Unknown settings command %s\n", command);
@ -428,12 +421,12 @@ int initConfig()
strcpy(config.driveboardPath, "none");
strcpy(config.motionboardPath, "none");
strcpy(config.rideboardPath, "none");
config.width = 1024;
config.height = 768;
config.width = 640;
config.height = 480;
config.crc32 = elf_crc;
config.region = -1;
config.freeplay = -1;
config.debug_msgs = 1;
config.showDebugMessages = 0;
if (detectGame(config.crc32) != 0)
{
printf("Warning: Unsure what game with CRC 0x%X is. Please submit this new game to the GitHub repository: https://github.com/bobbydilley/lindbergh-loader/issues/new?title=Please+add+new+game+0x%X&body=I+tried+to+launch+the+following+game:\n", config.crc32, config.crc32);

View File

@ -93,7 +93,7 @@ typedef struct
uint32_t crc32;
GameRegion region;
int freeplay;
int debug_msgs;
int showDebugMessages;
} EmulatorConfig;
int initConfig();

View File

@ -26,7 +26,6 @@ FGAPI int FGAPIENTRY glutEnterGameMode()
{
char gameTitle[256] = {0};
strcat(gameTitle, getGameName());
strcat(gameTitle, " (GLUT)");
glutCreateWindow(gameTitle);
// Outrun doesn't run the glutMainLoop through, so we'll do that here
@ -53,7 +52,7 @@ FGAPI void FGAPIENTRY glutSetCursor(int cursor)
FGAPI void FGAPIENTRY glutGameModeString(const char *string)
{
printf("glutGameModeString: %s\n", string);
// printf("glutGameModeString: %s\n", string);
char gameModeString[1024];
strcpy(gameModeString, string);
@ -100,7 +99,7 @@ Window XCreateWindow(Display *display, Window parent, int x, int y, unsigned int
// attributes->override_redirect = False;
Window window = _XCreateWindow(display, parent, x, y, width, height, border_width, depth, class, visual, valueMask, attributes);
printf("XCreateWindow Resolution %d %d %d %d\n", x, y, width, height);
printf("The resolution is %dx%d \n", width, height);
if (getConfig()->fullscreen)
{
@ -138,7 +137,6 @@ int XStoreName(Display *display, Window w, const char *window_name)
int (*_XStoreName)(Display *display, Window w, const char *window_name) = dlsym(RTLD_NEXT, "XStoreName");
char gameTitle[256] = {0};
strcat(gameTitle, getGameName());
strcat(gameTitle, " (X11)");
return _XStoreName(display, w, gameTitle);
}
@ -147,7 +145,6 @@ int XSetStandardProperties(Display *display, Window window, const char *window_n
int (*_XSetStandardProperties)(Display *display, Window window, const char *window_name, const char *icon_name, Pixmap icon_pixmap, char **argv, int argc, XSizeHints *hints) = dlsym(RTLD_NEXT, "XSetStandardProperties");
char gameTitle[256] = {0};
strcat(gameTitle, getGameName());
strcat(gameTitle, " (X11)");
return _XSetStandardProperties(display, window, gameTitle, icon_name, icon_pixmap, argv, argc, hints);
}

View File

@ -183,14 +183,14 @@ void __attribute__((constructor)) hook_init()
securityBoardSetDipResolution(getConfig()->width, getConfig()->height);
printf("Now emulating %s", getGameName());
printf("Now starting %s", getGameName());
if (getConfig()->gameStatus == WORKING)
{
printf((" - Game is in working state.\n"));
printf((", this game is working.\n"));
}
else
{
printf((" - Game is in NOT WORKING state.\n"));
printf((", this game is NOT working.\n"));
}
}
@ -545,15 +545,14 @@ int system(const char *command)
return 0;
if (strcmp(command, "uname -r | grep mvl") == 0)
{
EmulatorConfig *config = getConfig();
config->game = SEGABOOT_2_4;
return 0;
}
if (strstr(command, "hwclock") != NULL)
return 0;
if (strstr(command, "losetup") != NULL)
return 0;
return _system(command);
}
@ -607,7 +606,10 @@ int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
// Change the IP to connect to to 127.0.0.1
// in_pointer->sin_addr.s_addr = inet_addr("127.0.0.1");
char *some_addr = inet_ntoa(in_pointer->sin_addr);
printf("Connecting to %s\n", some_addr);
if (getConfig()->showDebugMessages)
{
printf("Connecting to %s\n", some_addr);
}
return _connect(sockfd, addr, addrlen);
}
@ -652,7 +654,10 @@ void getCPUID()
eax = 0;
__get_cpuid(0, &eax, &cpu_vendor.ebx, &cpu_vendor.ecx, &cpu_vendor.edx);
sprintf(cpu_vendor.cpuid, "%.4s%.4s%.4s", (const char *)&cpu_vendor.ebx, (const char *)&cpu_vendor.edx, (const char *)&cpu_vendor.ecx);
printf("CPU Vendor: %s\n", cpu_vendor.cpuid);
if (getConfig()->showDebugMessages)
{
printf("Detected CPU Vendor: %s\n", cpu_vendor.cpuid);
}
}
/**

View File

@ -13,11 +13,12 @@
#include <string.h>
#include <stdbool.h>
#include <pthread.h>
#include <math.h>
int initInput()
{
return 0;
return 0;
}
int XNextEvent(Display *display, XEvent *event_return)
@ -87,8 +88,8 @@ int XNextEvent(Display *display, XEvent *event_return)
case MotionNotify:
{
setAnalogue(ANALOGUE_1, ((double)event_return->xmotion.x / (double)getConfig()->width) * 255);
setAnalogue(ANALOGUE_2, ((double)event_return->xmotion.y / (double)getConfig()->height) * 255);
setAnalogue(ANALOGUE_1, ((double)event_return->xmotion.x / (double)getConfig()->width) * pow(2, 10));
setAnalogue(ANALOGUE_2, ((double)event_return->xmotion.y / (double)getConfig()->height) * pow(2, 10));
}
break;

View File

@ -33,7 +33,7 @@ int initJVS()
io.capabilities.switches = 14;
io.capabilities.coins = 2;
io.capabilities.players = 2;
io.capabilities.analogueInBits = 8;
io.capabilities.analogueInBits = 10;
io.capabilities.rightAlignBits = 0;
io.capabilities.analogueInChannels = 8;
io.capabilities.generalPurposeOutputs = 20;
@ -163,7 +163,7 @@ void writeFeatures(JVSPacket *outputPacket, JVSCapabilities *capabilities)
*
* @returns The status of the entire operation
*/
JVSStatus processPacket()
JVSStatus processPacket(int *packetSize)
{
readPacket(&inputPacket);
@ -265,11 +265,11 @@ JVSStatus processPacket()
outputPacket.data[outputPacket.length] = REPORT_SUCCESS;
outputPacket.data[outputPacket.length + 1] = io.state.inputSwitch[0];
outputPacket.length += 2;
for (int i = 0; i < inputPacket.data[index + 1]; i++)
{
for (int j = 0; j < inputPacket.data[index + 2]; j++)
{
{
outputPacket.data[outputPacket.length++] = io.state.inputSwitch[i + 1] >> (8 - (j * 8));
}
}
@ -278,7 +278,7 @@ JVSStatus processPacket()
case CMD_READ_COINS:
{
////printf("CMD_READ_COINS\n");
// printf("CMD_READ_COINS\n");
size = 2;
int numberCoinSlots = inputPacket.data[index + 1];
outputPacket.data[outputPacket.length++] = REPORT_SUCCESS;
@ -294,7 +294,7 @@ JVSStatus processPacket()
case CMD_READ_ANALOGS:
{
// printf("CMD_READ_ANALOGS\n");
// printf("CMD_READ_ANALOGS %d\n", inputPacket.data[index + 1]);
size = 2;
outputPacket.data[outputPacket.length++] = REPORT_SUCCESS;
@ -478,7 +478,7 @@ JVSStatus processPacket()
pthread_mutex_unlock(&jvsMutex);
writePacket(&outputPacket);
writePacket(&outputPacket, packetSize);
return JVS_STATUS_SUCCESS;
}
@ -565,7 +565,7 @@ JVSStatus readPacket(JVSPacket *packet)
*
* @param packet The packet to send
*/
JVSStatus writePacket(JVSPacket *packet)
JVSStatus writePacket(JVSPacket *packet, int *packetSize)
{
/* Get pointer to raw data in packet */
unsigned char *packetPointer = (unsigned char *)packet;
@ -603,6 +603,9 @@ JVSStatus writePacket(JVSPacket *packet)
outputBuffer[outputIndex++] = checksum;
}
// Communicate the output size based on the now escaped bytes
*packetSize = outputIndex;
return JVS_STATUS_SUCCESS;
}

View File

@ -223,10 +223,10 @@ typedef enum
int initJVS();
JVSStatus processPacket();
JVSStatus processPacket(int* packetSize);
JVSStatus readPacket(JVSPacket *packet);
JVSStatus writePacket(JVSPacket *packet);
JVSStatus writePacket(JVSPacket *packet, int* packetSize);
/* The in and out packets used to read and write to and from*/
extern JVSPacket inputPacket, outputPacket;

View File

@ -8,7 +8,7 @@
#define PRELOAD_FILE_NAME "lindbergh.so"
// List of all lindbergh executables known, not including the test executables
char *games[] = {"amiM.elf", "abc", "hod4M.elf", "lgj_final", "vt3", "id4.elf", "id5.elf", "lgjsp_app", "gsevo", "vf5", "apacheM.elf", "END"};
char *games[] = {"segaboot", "amiM.elf", "abc", "hod4M.elf", "lgj_final", "vt3", "id4.elf", "id5.elf", "lgjsp_app", "gsevo", "vf5", "apacheM.elf", "END"};
/**
* Tests if the game uses a seperate elf for test mode

View File

@ -30,19 +30,19 @@ static void setVariable(uint32_t address, uint32_t value)
static void patchMemory(uint32_t address, char *value)
{
size_t size = strlen((void*)value);
size_t size = strlen((void *)value);
printf("Size=%d\n", size);
if(size % 2 != 0)
if (size % 2 != 0)
{
printf("Patch value should be even.\n");
exit(1);
}
char buf[size/2];
char buf[size / 2];
char tmpchr[3];
char *p = value;
for(int i=0; i < size; i++)
for (int i = 0; i < size; i++)
{
memcpy(tmpchr, p, 2);
tmpchr[2] = '\0';
@ -61,7 +61,7 @@ static void patchMemory(uint32_t address, char *value)
return;
}
memcpy((uint32_t *)address, buf, size/2);
memcpy((uint32_t *)address, buf, size / 2);
}
static void detourFunction(uint32_t address, void *function)
@ -263,7 +263,7 @@ int initPatch()
break;
case AFTER_BURNER_CLIMAX_REVA:
{
if (config->debug_msgs == 1)
if (config->showDebugMessages == 1)
{
// Debug Messages
setVariable(0x0a0a37e4, 2); // amBackupDebugLevel
@ -287,12 +287,12 @@ int initPatch()
detourFunction(0x081e48b6, amDipswGetData);
detourFunction(0x081e492e, stubRetZero); // Stub amDipswSetLed
// Does not work
//setVariable(0x08061c31, 0x0000000c); // Force HD resolution
// setVariable(0x08061c31, 0x0000000c); // Force HD resolution
}
break;
case AFTER_BURNER_CLIMAX_REVB:
{
if (config->debug_msgs == 1)
if (config->showDebugMessages == 1)
{
// Debug Messages
setVariable(0x0a0a0d24, 2); // amBackupDebugLevel
@ -319,7 +319,7 @@ int initPatch()
break;
case OUTRUN_2_SP_SDX_REVA:
{
if (config->debug_msgs == 1)
if (config->showDebugMessages == 1)
{
// Debug Messages
setVariable(0x0893a24c, 2); // amBackupDebugLevel
@ -347,7 +347,7 @@ int initPatch()
case THE_HOUSE_OF_THE_DEAD_4:
{
if (config->debug_msgs == 1)
if (config->showDebugMessages == 1)
{
// Debug Messages
setVariable(0x0a737c60, 2); // amBackupDebugLevel
@ -508,7 +508,7 @@ int initPatch()
case LETS_GO_JUNGLE:
{
if (config->debug_msgs == 1)
if (config->showDebugMessages == 1)
{
setVariable(0x08c083a4, 2); // amBackupDebugLevel
setVariable(0x08c083c0, 2); // amCreditDebugLevel
@ -529,7 +529,7 @@ int initPatch()
detourFunction(0x084e50d8, amDongleInit);
detourFunction(0x084e5459, amDongleIsAvailable);
detourFunction(0x084e537d, amDongleUpdate);
patchMemory(0x0807b76a, "9090"); // Patch initializeArcadeBackup
patchMemory(0x0807b76a, "9090"); // Patch initializeArcadeBackup
// Fixes
detourFunction(0x084e500e, amDipswGetData);
detourFunction(0x084e5086, stubRetZero); // Stub amDipswSetLed
@ -547,7 +547,7 @@ int initPatch()
case LETS_GO_JUNGLE_SPECIAL:
{
if (config->debug_msgs == 1)
if (config->showDebugMessages == 1)
{
setVariable(0x08c453e4, 2); // amBackupDebugLevel
setVariable(0x08c45400, 2); // amCreditDebugLevel
@ -581,7 +581,7 @@ int initPatch()
case INITIALD_4:
{
if (config->debug_msgs == 1)
if (config->showDebugMessages == 1)
{
setVariable(0x08d71750, 2); // amBackupDebugLevel
setVariable(0x08d71760, 2); // amCreditDebugLevel
@ -609,10 +609,10 @@ int initPatch()
patchMemory(0x082cb412, "c0270900"); // tickInitStoreNetwork
patchMemory(0x082cb6d9, "e950010000"); // tickWaitDHCP
// Set Resolution
//patchMemory(0x0835664d, "e9f000"); // Force resolution set
//setVariable(0x08356743, 0x00000780); // Set ResX
//setVariable(0x08356748, 0x00000438); // Set ResY
// patchMemory(0x0835664d, "e9f000"); // Force resolution set
// setVariable(0x08356743, 0x00000780); // Set ResX
// setVariable(0x08356748, 0x00000438); // Set ResY
// FrameBuffer Resolution (No effect that I know)
/*
setVariable(0x08248037, 0x00000780); // Set ResX
@ -637,7 +637,7 @@ int initPatch()
break;
case INITIALD_4_REVE:
{
if (config->debug_msgs == 1)
if (config->showDebugMessages == 1)
{
// Debug
detourFunction(0x08090478, _putConsole); // Crashes the game sometimes.
@ -662,6 +662,27 @@ int initPatch()
break;
case SEGABOOT_2_4_SYM:
{
if (config->showDebugMessages == 1)
{
setVariable(0x0808da48, 2); // amAdtecDebugLevel
setVariable(0x0808cf8c, 2); // amAtaDebugLevel
setVariable(0x0808cf90, 2); // amBackupDebugLevel
setVariable(0x0808cf94, 2); // amChunkDataDebugLevel
setVariable(0x0808cfa0, 2); // amCreditDebugLevel
setVariable(0x0808d1f8, 2); // amDipswDebugLevel
setVariable(0x0808d1fc, 2); // amDiskDebugLevel
setVariable(0x0808d200, 2); // amDongleDebugLevel
setVariable(0x0808d204, 2); // amEepromDebugLevel
setVariable(0x0808d208, 2); // amHmDebugLevel
setVariable(0x0808d210, 2); // amJvsDebugLevel
setVariable(0x0808d214, 2); // amLibDebugLevel
setVariable(0x0808d218, 2); // amMiscDebugLevel
setVariable(0x0808d21c, 2); // amSysDataDebugLevel
setVariable(0x0808d220, 2); // bcLibDebugLevel
setVariable(0x0808cf58, 2); // g_DebugLevel
setVariable(0x0808d224, 0x0FFFFFFF); // logmask
}
detourFunction(0x0805e8b0, amDongleInit);
detourFunction(0x0805ebc3, amDongleIsAvailable);
detourFunction(0x0805eb2a, amDongleUpdate);
@ -682,7 +703,7 @@ int initPatch()
break;
case VIRTUA_TENNIS_3_TEST:
{
if (config->debug_msgs == 1)
if (config->showDebugMessages == 1)
{
// Debug
detourFunction(0x08054d14, _putConsole); // Crashes the game sometimes.