From 38f81fb887c3a3abcb9afe57ffe88851cdcb8673 Mon Sep 17 00:00:00 2001 From: dkeruza Date: Mon, 18 Dec 2023 00:32:09 -0500 Subject: [PATCH] Syntax error and fix for some games that do not support Freeplay. --- src/libkswapapi/libkswapapi.o | Bin 0 -> 2264 bytes src/lindbergh/config.c | 4 +-- src/lindbergh/eeprom.c | 52 +++++++++++++++++++++----------- src/lindbergh/eeprom_settings.c | 13 ++++++++ src/lindbergh/eeprom_settings.h | 1 + src/lindbergh/hook.c | 2 +- src/lindbergh/jvs.c | 6 +--- src/lindbergh/patch.c | 7 +++-- 8 files changed, 58 insertions(+), 27 deletions(-) create mode 100644 src/libkswapapi/libkswapapi.o diff --git a/src/libkswapapi/libkswapapi.o b/src/libkswapapi/libkswapapi.o new file mode 100644 index 0000000000000000000000000000000000000000..0ae0ad7d2db3dbc8d94864cb6594f895ed703966 GIT binary patch literal 2264 zcma)7TWB0r7(O$z8)J5Jueq3N#?mH{X2;DY*4PWpgAwsnx z62a#C!8#ZgxpJx7k%X9p9EQ&Vq5*%^R1Xb5zC)WFq z#E$ftv8)-Jj+?QCQ^{emyn4z-nz3jb$4rW^V@UD*yQHM zV|S)D4}Z0_@x^3vA~v!0<>tn8Dj7?6SrZji9d7fxolOUu<_~=Q`<2#v8;Mu6yLB@U zi@K-#KM`ZY!$-|79Qx6{C&pfE7&?je2!Rl^QM;*{sQEG*wGT|vE}RzH#Y(L$8VX&4 zgRLi%WXlI@Dqq!ys>7+=t^&yr z_wUi8d-R$;dabDSEj)h%_IoH0(V$m|-heLem|IHA$8(BHR%XvT+BV+W%DSFi%-G)I zT7KDb)`dNmnjRWV+0&z=&y392GlN5^5u0V%YrRUyQ&(Y@E1_$6jA|mT)+fvUIR#x0R&XO;9u7weft$I#o+1IoAHLF-E6y1_{zFgK_v=>Uw3W{b+ zg|#AX`oHN1MAiqQ`JLo@JpjfN%D3cuwu3p-YEn7>a&CYmHScYZIjsX=(mUuo<5&+* zA?vaJAux0JETmK!c2-sIFf5G!uQ)jah^ycxAlBo#6{&isV30D4f~XHksl2Eh<_GU_ z0|yv@jrZWMlW{EZELhcsD6W9VDEOp&dFV=}>wB}$jo6MN#jsv%c5NABdc$D-0$CY7|#UaSdVcZ z`l#yt0i*h+GMq8wk9-73YVhAr>5L(L3TEGxdmjYeLy>y7?_gk#iaQP=I9n?28^i?r zvLB8**w`2RE${RtSPN!x3H5FQ`R!sp>oJeAno)>i97>XcPwF20tp(${QQ#L91XOYV E0N$$l%>V!Z literal 0 HcmV?d00001 diff --git a/src/lindbergh/config.c b/src/lindbergh/config.c index 14a161b..3dba27d 100644 --- a/src/lindbergh/config.c +++ b/src/lindbergh/config.c @@ -430,8 +430,8 @@ int initConfig() config.width = 1024; config.height = 768; config.crc32 = elf_crc; - config.region = US; - config.freeplay = 1; + config.region = -1; + config.freeplay = -1; 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); diff --git a/src/lindbergh/eeprom.c b/src/lindbergh/eeprom.c index 072632c..9b6f45a 100644 --- a/src/lindbergh/eeprom.c +++ b/src/lindbergh/eeprom.c @@ -6,7 +6,7 @@ #include "eeprom_settings.h" #include "config.h" -#define I2C_SMBUS_BLOCK_MAX 32 +#define I2C_SMBUS_BLOCK_MAX 32 #define I2C_GET_FUNCTIONS 0x705 #define I2C_SMBUS_TRANSFER 0x720 #define I2C_SET_SLAVE_MODE 0x703 @@ -15,17 +15,19 @@ #define I2C_SEEK 2 #define I2C_WRITE 3 -union i2c_smbus_data { - uint8_t byte; - uint16_t word; - uint8_t block[I2C_SMBUS_BLOCK_MAX + 2]; +union i2c_smbus_data +{ + uint8_t byte; + uint16_t word; + uint8_t block[I2C_SMBUS_BLOCK_MAX + 2]; }; -struct i2c_smbus_ioctl_data { - uint8_t read_write; - uint8_t command; - uint32_t size; - union i2c_smbus_data *data; +struct i2c_smbus_ioctl_data +{ + uint8_t read_write; + uint8_t command; + uint32_t size; + union i2c_smbus_data *data; }; FILE *eeprom = NULL; @@ -47,18 +49,34 @@ int initEeprom() eeprom = fopen(eepromPath, "rb+"); - if(eepromSettingsInit(eeprom) !=0) + if (eepromSettingsInit(eeprom) != 0) { printf("Error initializing eeprom settings."); fclose(eeprom); return 1; } - - if(getRegion() != getConfig()->region) - setRegion(eeprom, getConfig()->region); - - if(getFreeplay() != getConfig()->freeplay) - setFreeplay(eeprom, getConfig()->freeplay); + + if (getConfig()->region != -1) + { + if (getRegion() != getConfig()->region) + setRegion(eeprom, getConfig()->region); + } + + if (getConfig()->freeplay != -1) + { + if (getFreeplay() != getConfig()->freeplay) + setFreeplay(eeprom, getConfig()->freeplay); + } + + if ((getConfig()->game == LETS_GO_JUNGLE_SPECIAL) || (getConfig()->game == THE_HOUSE_OF_THE_DEAD_EX) || (getConfig()->game == THE_HOUSE_OF_THE_DEAD_4_SPECIAL)) + { + if (fixCreditSection(eeprom) != 0) + { + printf("Error initializing eeprom settings."); + fclose(eeprom); + return 1; + } + } fseek(eeprom, 0, SEEK_SET); diff --git a/src/lindbergh/eeprom_settings.c b/src/lindbergh/eeprom_settings.c index faf6001..07aba1d 100644 --- a/src/lindbergh/eeprom_settings.c +++ b/src/lindbergh/eeprom_settings.c @@ -199,6 +199,19 @@ int setFreeplay(FILE *eeprom, int freeplay) return 0; } +int fixCreditSection(FILE *eeprom) +{ + eepromBuffer[eepromOffsetTable[CREDIT].offset + 36] = 0; + eepromBuffer[eepromOffsetTable[CREDIT].offset + 39] = 0; + addCRCtoBuffer(CREDIT); + if (writeSectiontoFile(eeprom, CREDIT) != 0) + { + printf("Error setting Free Play."); + return 1; + } + return 0; +} + int eepromSettingsInit( FILE *eeprom) { build_crc32_table(); diff --git a/src/lindbergh/eeprom_settings.h b/src/lindbergh/eeprom_settings.h index 39f7173..fde2f48 100644 --- a/src/lindbergh/eeprom_settings.h +++ b/src/lindbergh/eeprom_settings.h @@ -3,3 +3,4 @@ int getRegion(); int getFreeplay(); int setRegion(FILE *eeprom, int region); int setFreeplay(FILE *eeprom, int freeplay); +int fixCreditSection(FILE *eeprom); diff --git a/src/lindbergh/hook.c b/src/lindbergh/hook.c index 80eb031..fbe1ef0 100644 --- a/src/lindbergh/hook.c +++ b/src/lindbergh/hook.c @@ -42,7 +42,7 @@ #define OSRELEASE 1 #define PCI_CARD_1F0 2 - int hooks[5] = {-1, -1, -1, -1}; +int hooks[5] = {-1, -1, -1, -1}; FILE *fileHooks[3] = {NULL, NULL, NULL}; int fileRead[3] = {0, 0, 0}; char envpath[100]; diff --git a/src/lindbergh/jvs.c b/src/lindbergh/jvs.c index 655efde..8534b54 100644 --- a/src/lindbergh/jvs.c +++ b/src/lindbergh/jvs.c @@ -35,7 +35,7 @@ int initJVS() io.capabilities.players = 2; io.capabilities.analogueInBits = 8; io.capabilities.rightAlignBits = 0; - io.capabilities.analogueInChannels = 20; + io.capabilities.analogueInChannels = 8; io.capabilities.generalPurposeOutputs = 20; io.capabilities.commandVersion = 19; io.capabilities.jvsVersion = 48; @@ -265,8 +265,6 @@ JVSStatus processPacket() outputPacket.data[outputPacket.length] = REPORT_SUCCESS; outputPacket.data[outputPacket.length + 1] = io.state.inputSwitch[0]; outputPacket.length += 2; - - //printf("SW=%08d\r", io.state.inputSwitch[0]); for (int i = 0; i < inputPacket.data[index + 1]; i++) { @@ -569,8 +567,6 @@ JVSStatus readPacket(JVSPacket *packet) */ JVSStatus writePacket(JVSPacket *packet) { - - /* Get pointer to raw data in packet */ unsigned char *packetPointer = (unsigned char *)packet; diff --git a/src/lindbergh/patch.c b/src/lindbergh/patch.c index 25cae21..870b867 100644 --- a/src/lindbergh/patch.c +++ b/src/lindbergh/patch.c @@ -494,7 +494,7 @@ int initPatch() detourFunction(0x084e537d, amDongleUpdate); setVariable(0x080d1f02, 0x90909090); // Patch acpSystem::checkDongle setVariable(0x080d1f06, 0xE8C3C990); // Patch acpSystem::checkDongle - setVariable(0x0807b76a, 0xc2839090); // Patch initializeArcadeBackup + setVariable(0x0807b76d, 0xc2839090); // Patch initializeArcadeBackup // Fixes detourFunction(0x084e500e, amDipswGetData); detourFunction(0x084e5086, stubRetZero); // Stub amDipswSetLed @@ -532,7 +532,8 @@ int initPatch() detourFunction(0x08510600, amDongleUpdate); setVariable(0x080dad63, 0x90909090); // Patch acpSystem::checkDongle setVariable(0x080dad67, 0xE8C3C990); // Patch acpSystem::checkDongle - setVariable(0x0807e609, 0xc2839090); // Patch initializeArcadeBackup + setVariable(0x0807e609, 0x90909090); // Patch initializeArcadeBackup + setVariable(0x0807e60d, 0xc2839090); // Patch initializeArcadeBackup // Fixes detourFunction(0x08510256, amDipswGetData); detourFunction(0x085102ce, stubRetZero); // Stub amDipswSetLed @@ -648,6 +649,8 @@ int initPatch() break; case VIRTUA_TENNIS_3_TEST: { + // Debug + detourFunction(0x08054d14, _putConsole); // Crashes the game sometimes. // Security detourFunction(0x0815f610, amDongleInit); detourFunction(0x0815f923, amDongleIsAvailable);