From 305ab38ac800be541f6bf6bbe4e86ecc9658abab Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Tue, 24 Nov 2020 20:50:50 +0100 Subject: [PATCH] naomi: search parent rom path for gdrom --- core/hw/naomi/gdcartridge.cpp | 11 +++++++++-- core/hw/naomi/gdcartridge.h | 15 ++++++--------- core/hw/naomi/naomi_cart.cpp | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core/hw/naomi/gdcartridge.cpp b/core/hw/naomi/gdcartridge.cpp index b440223a1..cc27dc622 100644 --- a/core/hw/naomi/gdcartridge.cpp +++ b/core/hw/naomi/gdcartridge.cpp @@ -495,9 +495,16 @@ void GDCartridge::device_start() u8 buffer[2048]; std::string gdrom_path = get_game_basename() + "/" + gdrom_name; Disc *gdrom = OpenDisc((gdrom_path + ".chd").c_str()); - if (gdrom == NULL) + if (gdrom == nullptr) gdrom = OpenDisc((gdrom_path + ".gdi").c_str()); - if (gdrom == NULL) + if (gdrom_parent_name != nullptr && gdrom == nullptr) + { + std::string gdrom_parent_path = get_game_basename() + "/" + gdrom_parent_name; + gdrom = OpenDisc((gdrom_parent_path + ".chd").c_str()); + if (gdrom == nullptr) + gdrom = OpenDisc((gdrom_parent_path + ".gdi").c_str()); + } + if (gdrom == nullptr) throw NaomiCartException("Naomi GDROM: Cannot open " + gdrom_path + ".chd or " + gdrom_path + ".gdi"); // primary volume descriptor diff --git a/core/hw/naomi/gdcartridge.h b/core/hw/naomi/gdcartridge.h index 66f63b1d7..fc6d623b5 100644 --- a/core/hw/naomi/gdcartridge.h +++ b/core/hw/naomi/gdcartridge.h @@ -20,10 +20,6 @@ class GDCartridge: public NaomiCartridge { public: GDCartridge(u32 size) : NaomiCartridge(size) { - gdrom_name = NULL; - dimm_data = NULL; - dimm_data_size = 0; - dimm_cur_address = 0; } ~GDCartridge() { @@ -39,17 +35,18 @@ public: virtual bool Read(u32 offset, u32 size, void* dst) override; virtual std::string GetGameId() override; - void SetGDRomName(const char *name) { this->gdrom_name = name; } + void SetGDRomName(const char *name, const char *parentName) { this->gdrom_name = name; this->gdrom_parent_name = parentName; } private: enum { FILENAME_LENGTH=24 }; - const char *gdrom_name; + const char *gdrom_name = nullptr; + const char *gdrom_parent_name = nullptr; - u32 dimm_cur_address; + u32 dimm_cur_address = 0; - u8 *dimm_data; - u32 dimm_data_size; + u8 *dimm_data = nullptr; + u32 dimm_data_size = 0; static const u32 DES_LEFTSWAP[]; static const u32 DES_RIGHTSWAP[]; diff --git a/core/hw/naomi/naomi_cart.cpp b/core/hw/naomi/naomi_cart.cpp index 5e27bf70f..dd25105ef 100644 --- a/core/hw/naomi/naomi_cart.cpp +++ b/core/hw/naomi/naomi_cart.cpp @@ -258,7 +258,7 @@ static void naomi_cart_LoadZip(const char *filename) case GD: { GDCartridge *gdcart = new GDCartridge(game->size); - gdcart->SetGDRomName(game->gdrom_name); + gdcart->SetGDRomName(game->gdrom_name, game->parent_name); CurrentCartridge = gdcart; } break;