diff --git a/core/cheats.cpp b/core/cheats.cpp index 77bdd50e6..aa6b7b343 100644 --- a/core/cheats.cpp +++ b/core/cheats.cpp @@ -430,39 +430,26 @@ void CheatManager::reset(const std::string& gameId) if (!cheatFile.empty()) loadCheatFile(cheatFile); #endif + size_t cheatCount = cheats.size(); if (gameId == "Fixed BOOT strapper") // Extreme Hunting 2 { - setActive(true); - cheats.emplace_back(Cheat::Type::runNextIfEq, "skip netbd check ifeq", true, 32, 0x00067b04, 0); - cheats.back().builtIn = true; - 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; + cheats.emplace_back(Cheat::Type::runNextIfEq, "skip netbd check ifeq", true, 32, 0x00067b04, 0, true); + cheats.emplace_back(Cheat::Type::setValue, "skip netbd check", true, 32, 0x00067b04, 1, true); // 1 skips initNetwork() + cheats.emplace_back(Cheat::Type::setValue, "skip netbd check 2", true, 16, 0x0009acc8, 0x0009, true); // not acceptable by main board // 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.back().builtIn = true; - cheats.emplace_back(Cheat::Type::setValue, "fix boot", true, 32, 0x00010000, 0x9302d202); - cheats.back().builtIn = true; + cheats.emplace_back(Cheat::Type::runNextIfEq, "fix boot ifeq", true, 32, 0x00010000, 0x8c9378c0, true); + cheats.emplace_back(Cheat::Type::setValue, "fix boot", true, 32, 0x00010000, 0x9302d202, true); } - else if (gameId == "THE KING OF ROUTE66") - { - setActive(true); - cheats.emplace_back(Cheat::Type::setValue, "ignore drive error", true, 32, 0x00023ee0, 0x0009000B); // rts, nop - cheats.back().builtIn = true; + else if (gameId == "THE KING OF ROUTE66") { + cheats.emplace_back(Cheat::Type::setValue, "ignore drive error", true, 32, 0x00023ee0, 0x0009000B, true); // rts, nop } else if (gameId.substr(0, 8) == "MKG TKOB") { const auto& setMushikingCheats = [this](u32 addr) { - setActive(true); - cheats.emplace_back(Cheat::Type::setValue, "ignore rfid1 error", true, 32, addr, 0); // rfid[0].error = 0 - cheats.back().builtIn = true; - cheats.emplace_back(Cheat::Type::setValue, "ignore rfid2 error", true, 32, addr + 0x48, 0); // rfid[1].error = 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; + 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 rfid2 error", true, 32, addr + 0x48, 0, true); // rfid[1].error = 0 + 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 status", true, 32, addr + 0x50, 0, true); // rfid[1].data18 = 0 }; if (gameId == "MKG TKOB 2 EXP VER1.001-") // mushi2eo setMushikingCheats(0x6fe1bc); @@ -481,36 +468,23 @@ void CheatManager::reset(const std::string& gameId) else if (gameId == "MKG TKOB 2 KOR VER1.000-") // mushik2k setMushikingCheats(0x706084); } - else if (gameId == "T-8120N") // Dave Mirra BMX (US) - { - 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 == "T-8120N") { // Dave Mirra BMX (US) + cheats.emplace_back(Cheat::Type::setValue, "fix main loop time", true, 32, 0x0030b8cc, 0x42040000, true); // 33.0 ms } - else if (gameId == "T8120D 50") // Dave Mirra BMX (EU) - { - 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 == "T8120D 50") { // Dave Mirra BMX (EU) + cheats.emplace_back(Cheat::Type::setValue, "fix main loop time", true, 32, 0x003011cc, 0x42200000, true); // 40.0 ms } - else if (gameId == "MK-0100") // F355 US - { - setActive(true); - cheats.emplace_back(Cheat::Type::setValue, "increase datapump timeout", true, 16, 0x00131668, 1000); - cheats.back().builtIn = true; + else if (gameId == "MK-0100") { // F355 US + cheats.emplace_back(Cheat::Type::setValue, "increase datapump timeout", true, 16, 0x00131668, 1000, true); } - else if (gameId == "T8118D 50") // F355 EU - { - setActive(true); - cheats.emplace_back(Cheat::Type::setValue, "increase datapump timeout", true, 16, 0x00135588, 1000); - cheats.back().builtIn = true; + else if (gameId == "T8118D 50") { // F355 EU + cheats.emplace_back(Cheat::Type::setValue, "increase datapump timeout", true, 16, 0x00135588, 1000, true); } - else if (gameId == "SAMURAI SPIRITS 6" || gameId == "T0002M") - { - 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; + 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) } + if (cheats.size() > cheatCount) + setActive(true); } if (config::WidescreenGameHacks) { diff --git a/core/cheats.h b/core/cheats.h index cd68b8d41..709939d76 100644 --- a/core/cheats.h +++ b/core/cheats.h @@ -51,19 +51,17 @@ struct Cheat u32 size; u32 address; u32 value; - u8 valueMask; - u32 repeatCount; - u32 repeatValueIncrement; - u32 repeatAddressIncrement; - u32 destAddress; + u8 valueMask = 0; + u32 repeatCount = 1; + u32 repeatValueIncrement = 0; + u32 repeatAddressIncrement = 0; + u32 destAddress = 0; bool builtIn; - Cheat(Type type = Type::disabled, const std::string& description = "", bool enabled = false, u32 size = 0, u32 address = 0, - u32 value = 0, u8 valueMask = 0, u32 repeatCount = 1, u32 repeatValueIncrement = 0, - u32 repeatAddressIncrement = 0, u32 destAddress = 0, bool builtIn = false) - : type(type), description(description), enabled(enabled), size(size), address(address), value(value), valueMask(valueMask), - repeatCount(repeatCount), repeatValueIncrement(repeatValueIncrement), repeatAddressIncrement(repeatAddressIncrement), - destAddress(destAddress), builtIn(builtIn) + Cheat(Type type = Type::disabled, const std::string& description = "", bool enabled = false, + u32 size = 0, u32 address = 0, u32 value = 0, bool builtIn = false) + : type(type), description(description), enabled(enabled), + size(size), address(address), value(value), builtIn(builtIn) { } }; diff --git a/core/sdl/sdl.cpp b/core/sdl/sdl.cpp index 8fcaf7f2a..da9164107 100644 --- a/core/sdl/sdl.cpp +++ b/core/sdl/sdl.cpp @@ -843,14 +843,11 @@ static KeyboardLayout detectKeyboardLayout() { // PT or BR key = SDL_GetKeyFromScancode(SDL_SCANCODE_RIGHTBRACKET); - if (key == SDLK_LEFTBRACKET) { + if (key == SDLK_LEFTBRACKET) INFO_LOG(INPUT, "Portuguese (BR) keyboard detected"); - return KeyboardLayout::PT; - } - else { + else INFO_LOG(INPUT, "Portuguese keyboard detected"); - return KeyboardLayout::PT; - } + return KeyboardLayout::PT; } key = SDL_GetKeyFromScancode(SDL_SCANCODE_MINUS); if (key == SDLK_PLUS) { @@ -904,6 +901,10 @@ static KeyboardLayout detectKeyboardLayout() 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 const std::unordered_map keymapDefault { diff --git a/core/wsi/egl.cpp b/core/wsi/egl.cpp index 81a7042b9..d55993381 100644 --- a/core/wsi/egl.cpp +++ b/core/wsi/egl.cpp @@ -39,7 +39,12 @@ bool EGLGraphicsContext::makeCurrent() 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 display = eglGetDisplay((EGLNativeDisplayType)display); diff --git a/core/wsi/sdl.cpp b/core/wsi/sdl.cpp index cbcb9390c..e187a8e6a 100644 --- a/core/wsi/sdl.cpp +++ b/core/wsi/sdl.cpp @@ -99,7 +99,11 @@ bool SDLGLGraphicsContext::init() SDL_GL_SetSwapInterval(swapOnVSync ? swapInterval : 0); #ifdef GLES - gladLoadGLES2((GLADloadfunc) SDL_GL_GetProcAddress); + if (gladLoadGLES2((GLADloadfunc)SDL_GL_GetProcAddress) == 0) + { + ERROR_LOG(RENDERER, "gladLoadGLES2 failed"); + return false; + } #else if (!gladLoadGL((GLADloadfunc) SDL_GL_GetProcAddress) || !GLAD_GL_VERSION_3_0) {