gladLoader: check return code and log. cheats: light refactoring

This commit is contained in:
Flyinghead 2024-02-10 12:06:48 +01:00
parent a50f5765da
commit 90b13a40ab
5 changed files with 51 additions and 69 deletions

View File

@ -430,39 +430,26 @@ void CheatManager::reset(const std::string& gameId)
if (!cheatFile.empty()) if (!cheatFile.empty())
loadCheatFile(cheatFile); loadCheatFile(cheatFile);
#endif #endif
size_t cheatCount = cheats.size();
if (gameId == "Fixed BOOT strapper") // Extreme Hunting 2 if (gameId == "Fixed BOOT strapper") // Extreme Hunting 2
{ {
setActive(true); cheats.emplace_back(Cheat::Type::runNextIfEq, "skip netbd check ifeq", true, 32, 0x00067b04, 0, true);
cheats.emplace_back(Cheat::Type::runNextIfEq, "skip netbd check ifeq", true, 32, 0x00067b04, 0); cheats.emplace_back(Cheat::Type::setValue, "skip netbd check", true, 32, 0x00067b04, 1, true); // 1 skips initNetwork()
cheats.back().builtIn = true; cheats.emplace_back(Cheat::Type::setValue, "skip netbd check 2", true, 16, 0x0009acc8, 0x0009, true); // not acceptable by main board
cheats.emplace_back(Cheat::Type::setValue, "skip netbd check", true, 32, 0x00067b04, 1); // 1 skips initNetwork()
cheats.back().builtIn = true;
cheats.emplace_back(Cheat::Type::setValue, "skip netbd check 2", true, 16, 0x0009acc8, 0x0009); // not acceptable by main board
cheats.back().builtIn = true;
// ac010000 should be d202 9302, but is changed to 78c0 8c93 // ac010000 should be d202 9302, but is changed to 78c0 8c93
cheats.emplace_back(Cheat::Type::runNextIfEq, "fix boot ifeq", true, 32, 0x00010000, 0x8c9378c0); cheats.emplace_back(Cheat::Type::runNextIfEq, "fix boot ifeq", true, 32, 0x00010000, 0x8c9378c0, true);
cheats.back().builtIn = true; cheats.emplace_back(Cheat::Type::setValue, "fix boot", true, 32, 0x00010000, 0x9302d202, true);
cheats.emplace_back(Cheat::Type::setValue, "fix boot", true, 32, 0x00010000, 0x9302d202);
cheats.back().builtIn = true;
} }
else if (gameId == "THE KING OF ROUTE66") else if (gameId == "THE KING OF ROUTE66") {
{ cheats.emplace_back(Cheat::Type::setValue, "ignore drive error", true, 32, 0x00023ee0, 0x0009000B, true); // rts, nop
setActive(true);
cheats.emplace_back(Cheat::Type::setValue, "ignore drive error", true, 32, 0x00023ee0, 0x0009000B); // rts, nop
cheats.back().builtIn = true;
} }
else if (gameId.substr(0, 8) == "MKG TKOB") else if (gameId.substr(0, 8) == "MKG TKOB")
{ {
const auto& setMushikingCheats = [this](u32 addr) { const auto& setMushikingCheats = [this](u32 addr) {
setActive(true); cheats.emplace_back(Cheat::Type::setValue, "ignore rfid1 error", true, 32, addr, 0, true); // rfid[0].error = 0
cheats.emplace_back(Cheat::Type::setValue, "ignore rfid1 error", true, 32, addr, 0); // rfid[0].error = 0 cheats.emplace_back(Cheat::Type::setValue, "ignore rfid2 error", true, 32, addr + 0x48, 0, true); // rfid[1].error = 0
cheats.back().builtIn = true; cheats.emplace_back(Cheat::Type::setValue, "ignore rfid1 status", true, 32, addr + 8, 0, true); // rfid[0].data18 = 0
cheats.emplace_back(Cheat::Type::setValue, "ignore rfid2 error", true, 32, addr + 0x48, 0); // rfid[1].error = 0 cheats.emplace_back(Cheat::Type::setValue, "ignore rfid2 status", true, 32, addr + 0x50, 0, true); // rfid[1].data18 = 0
cheats.back().builtIn = true;
cheats.emplace_back(Cheat::Type::setValue, "ignore rfid1 status", true, 32, addr + 8, 0); // rfid[0].data18 = 0
cheats.back().builtIn = true;
cheats.emplace_back(Cheat::Type::setValue, "ignore rfid2 status", true, 32, addr + 0x50, 0); // rfid[1].data18 = 0
cheats.back().builtIn = true;
}; };
if (gameId == "MKG TKOB 2 EXP VER1.001-") // mushi2eo if (gameId == "MKG TKOB 2 EXP VER1.001-") // mushi2eo
setMushikingCheats(0x6fe1bc); setMushikingCheats(0x6fe1bc);
@ -481,36 +468,23 @@ void CheatManager::reset(const std::string& gameId)
else if (gameId == "MKG TKOB 2 KOR VER1.000-") // mushik2k else if (gameId == "MKG TKOB 2 KOR VER1.000-") // mushik2k
setMushikingCheats(0x706084); setMushikingCheats(0x706084);
} }
else if (gameId == "T-8120N") // Dave Mirra BMX (US) else if (gameId == "T-8120N") { // Dave Mirra BMX (US)
{ cheats.emplace_back(Cheat::Type::setValue, "fix main loop time", true, 32, 0x0030b8cc, 0x42040000, true); // 33.0 ms
setActive(true);
cheats.emplace_back(Cheat::Type::setValue, "fix main loop time", true, 32, 0x0030b8cc, 0x42040000); // 33.0 ms
cheats.back().builtIn = true;
} }
else if (gameId == "T8120D 50") // Dave Mirra BMX (EU) else if (gameId == "T8120D 50") { // Dave Mirra BMX (EU)
{ cheats.emplace_back(Cheat::Type::setValue, "fix main loop time", true, 32, 0x003011cc, 0x42200000, true); // 40.0 ms
setActive(true);
cheats.emplace_back(Cheat::Type::setValue, "fix main loop time", true, 32, 0x003011cc, 0x42200000); // 40.0 ms
cheats.back().builtIn = true;
} }
else if (gameId == "MK-0100") // F355 US else if (gameId == "MK-0100") { // F355 US
{ cheats.emplace_back(Cheat::Type::setValue, "increase datapump timeout", true, 16, 0x00131668, 1000, true);
setActive(true);
cheats.emplace_back(Cheat::Type::setValue, "increase datapump timeout", true, 16, 0x00131668, 1000);
cheats.back().builtIn = true;
} }
else if (gameId == "T8118D 50") // F355 EU else if (gameId == "T8118D 50") { // F355 EU
{ cheats.emplace_back(Cheat::Type::setValue, "increase datapump timeout", true, 16, 0x00135588, 1000, true);
setActive(true);
cheats.emplace_back(Cheat::Type::setValue, "increase datapump timeout", true, 16, 0x00135588, 1000);
cheats.back().builtIn = true;
} }
else if (gameId == "SAMURAI SPIRITS 6" || gameId == "T0002M") else if (gameId == "SAMURAI SPIRITS 6" || gameId == "T0002M") {
{ cheats.emplace_back(Cheat::Type::setValue, "fix depth", true, 16, 0x0003e602, 0x0009, true); // nop (shift by 8 bits instead of 10)
setActive(true);
cheats.emplace_back(Cheat::Type::setValue, "fix depth", true, 16, 0x0003e602, 0x0009); // nop (shift by 8 bits instead of 10)
cheats.back().builtIn = true;
} }
if (cheats.size() > cheatCount)
setActive(true);
} }
if (config::WidescreenGameHacks) if (config::WidescreenGameHacks)
{ {

View File

@ -51,19 +51,17 @@ struct Cheat
u32 size; u32 size;
u32 address; u32 address;
u32 value; u32 value;
u8 valueMask; u8 valueMask = 0;
u32 repeatCount; u32 repeatCount = 1;
u32 repeatValueIncrement; u32 repeatValueIncrement = 0;
u32 repeatAddressIncrement; u32 repeatAddressIncrement = 0;
u32 destAddress; u32 destAddress = 0;
bool builtIn; bool builtIn;
Cheat(Type type = Type::disabled, const std::string& description = "", bool enabled = false, u32 size = 0, u32 address = 0, Cheat(Type type = Type::disabled, const std::string& description = "", bool enabled = false,
u32 value = 0, u8 valueMask = 0, u32 repeatCount = 1, u32 repeatValueIncrement = 0, u32 size = 0, u32 address = 0, u32 value = 0, bool builtIn = false)
u32 repeatAddressIncrement = 0, u32 destAddress = 0, bool builtIn = false) : type(type), description(description), enabled(enabled),
: type(type), description(description), enabled(enabled), size(size), address(address), value(value), valueMask(valueMask), size(size), address(address), value(value), builtIn(builtIn)
repeatCount(repeatCount), repeatValueIncrement(repeatValueIncrement), repeatAddressIncrement(repeatAddressIncrement),
destAddress(destAddress), builtIn(builtIn)
{ {
} }
}; };

View File

@ -843,14 +843,11 @@ static KeyboardLayout detectKeyboardLayout()
{ {
// PT or BR // PT or BR
key = SDL_GetKeyFromScancode(SDL_SCANCODE_RIGHTBRACKET); key = SDL_GetKeyFromScancode(SDL_SCANCODE_RIGHTBRACKET);
if (key == SDLK_LEFTBRACKET) { if (key == SDLK_LEFTBRACKET)
INFO_LOG(INPUT, "Portuguese (BR) keyboard detected"); INFO_LOG(INPUT, "Portuguese (BR) keyboard detected");
return KeyboardLayout::PT; else
}
else {
INFO_LOG(INPUT, "Portuguese keyboard detected"); INFO_LOG(INPUT, "Portuguese keyboard detected");
return KeyboardLayout::PT; return KeyboardLayout::PT;
}
} }
key = SDL_GetKeyFromScancode(SDL_SCANCODE_MINUS); key = SDL_GetKeyFromScancode(SDL_SCANCODE_MINUS);
if (key == SDLK_PLUS) { if (key == SDLK_PLUS) {
@ -904,6 +901,10 @@ static KeyboardLayout detectKeyboardLayout()
return KeyboardLayout::US; return KeyboardLayout::US;
} }
// All known card games use simple Code 39 barcodes.
// The barcode scanner should be configured to use HID-USB (act like a keyboard)
// and use '*' as preamble and terminator, which are the Code 39 start and stop characters.
// So disable the default terminator ('\n') and enable sending the Code 39 start and stop characters.
static bool handleBarcodeScanner(const SDL_Event& event) static bool handleBarcodeScanner(const SDL_Event& event)
{ {
static const std::unordered_map<u16, char> keymapDefault { static const std::unordered_map<u16, char> keymapDefault {

View File

@ -39,7 +39,12 @@ bool EGLGraphicsContext::makeCurrent()
bool EGLGraphicsContext::init() bool EGLGraphicsContext::init()
{ {
gladLoaderLoadEGL(NULL); int version = gladLoaderLoadEGL(EGL_NO_DISPLAY);
if (version == 0) {
ERROR_LOG(RENDERER, "Failed to load libEGL.so");
return false;
}
NOTICE_LOG(RENDERER, "EGL version %d.%d", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
//try to get a display //try to get a display
display = eglGetDisplay((EGLNativeDisplayType)display); display = eglGetDisplay((EGLNativeDisplayType)display);

View File

@ -99,7 +99,11 @@ bool SDLGLGraphicsContext::init()
SDL_GL_SetSwapInterval(swapOnVSync ? swapInterval : 0); SDL_GL_SetSwapInterval(swapOnVSync ? swapInterval : 0);
#ifdef GLES #ifdef GLES
gladLoadGLES2((GLADloadfunc) SDL_GL_GetProcAddress); if (gladLoadGLES2((GLADloadfunc)SDL_GL_GetProcAddress) == 0)
{
ERROR_LOG(RENDERER, "gladLoadGLES2 failed");
return false;
}
#else #else
if (!gladLoadGL((GLADloadfunc) SDL_GL_GetProcAddress) || !GLAD_GL_VERSION_3_0) if (!gladLoadGL((GLADloadfunc) SDL_GL_GetProcAddress) || !GLAD_GL_VERSION_3_0)
{ {