From 511fbb3644525eca9885a1dcb0eb22468864a1b8 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sat, 6 Aug 2022 09:20:13 +0200 Subject: [PATCH] a few minor changes (finally resolves #913 and #914) --- src/emucore/CartCreator.cxx | 55 ++++++++++++++----------------------- src/emucore/CartCreator.hxx | 4 +-- src/gui/GameInfoDialog.cxx | 2 +- 3 files changed, 24 insertions(+), 37 deletions(-) diff --git a/src/emucore/CartCreator.cxx b/src/emucore/CartCreator.cxx index 8afdc6149..8deab775f 100644 --- a/src/emucore/CartCreator.cxx +++ b/src/emucore/CartCreator.cxx @@ -106,47 +106,47 @@ unique_ptr CartCreator::create(const FSNode& file, // Check for multicart first; if found, get the correct part of the image bool validMultiSize = true; - int numRoms = 0; + int numMultiRoms = 0; switch(type) { case Bankswitch::Type::_2IN1: - numRoms = 2; + numMultiRoms = 2; // Make sure we have a valid sized image validMultiSize = (size == 2 * 2_KB || size == 2 * 4_KB || size == 2 * 8_KB || size == 2 * 16_KB || size == 2 * 32_KB); break; case Bankswitch::Type::_4IN1: - numRoms = 4; + numMultiRoms = 4; // Make sure we have a valid sized image validMultiSize = (size == 4 * 2_KB || size == 4 * 4_KB || size == 4 * 8_KB || size == 4 * 16_KB); break; case Bankswitch::Type::_8IN1: - numRoms = 8; + numMultiRoms = 8; // Make sure we have a valid sized image validMultiSize = (size == 8 * 2_KB || size == 8 * 4_KB || size == 8 * 8_KB); break; case Bankswitch::Type::_16IN1: - numRoms = 16; + numMultiRoms = 16; // Make sure we have a valid sized image validMultiSize = (size == 16 * 2_KB || size == 16 * 4_KB || size == 16 * 8_KB); break; case Bankswitch::Type::_32IN1: - numRoms = 32; + numMultiRoms = 32; // Make sure we have a valid sized image validMultiSize = (size == 32 * 2_KB || size == 32 * 4_KB); break; case Bankswitch::Type::_64IN1: - numRoms = 64; + numMultiRoms = 64; // Make sure we have a valid sized image validMultiSize = (size == 64 * 2_KB || size == 64 * 4_KB); break; case Bankswitch::Type::_128IN1: - numRoms = 128; + numMultiRoms = 128; // Make sure we have a valid sized image validMultiSize = (size == 128 * 2_KB || size == 128 * 4_KB); break; @@ -160,35 +160,22 @@ unique_ptr CartCreator::create(const FSNode& file, break; } - bool isMulti = false; - switch(type) + if(numMultiRoms) { - case Bankswitch::Type::_2IN1: - case Bankswitch::Type::_4IN1: - case Bankswitch::Type::_8IN1: - case Bankswitch::Type::_16IN1: - case Bankswitch::Type::_32IN1: - case Bankswitch::Type::_64IN1: - case Bankswitch::Type::_128IN1: - isMulti = true; - if(validMultiSize) - cartridge = createFromMultiCart(image, size, numRoms, md5, detectedType, id, settings); - else - throw runtime_error("Invalid cart size for type '" + Bankswitch::typeToName(type) + "'"); + if(validMultiSize) + cartridge = createFromMultiCart(image, size, numMultiRoms, md5, detectedType, id, settings); + else + throw runtime_error("Invalid cart size for type '" + Bankswitch::typeToName(type) + "'"); - //type = detectedType; - buf << id; - break; - - default: - break; + //type = detectedType; + buf << id; } if(size < 1_KB) buf << " (" << size << "B"; else buf << " (" << (size/1_KB) << "K"; - if(isMulti && detectedType != Bankswitch::Type::_2K && detectedType != Bankswitch::Type::_4K) + if(numMultiRoms && detectedType != Bankswitch::Type::_2K && detectedType != Bankswitch::Type::_4K) buf << " " << Bankswitch::typeToName(detectedType); buf << ") "; @@ -200,21 +187,21 @@ unique_ptr CartCreator::create(const FSNode& file, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unique_ptr CartCreator::createFromMultiCart(const ByteBuffer& image, size_t& size, - uInt32 numroms, string& md5, Bankswitch::Type& type, string& id, Settings& settings) + uInt32 numRoms, string& md5, Bankswitch::Type& type, string& id, Settings& settings) { // Get a piece of the larger image uInt32 i = settings.getInt("romloadcount"); // Move to the next game if(!settings.getBool("romloadprev")) - i = (i + 1) % numroms; + i = (i + 1) % numRoms; else - i = (i - 1) % numroms; + i = (i - 1) % numRoms; settings.setValue("romloadcount", i); - size /= numroms; + size /= numRoms; ByteBuffer slice = make_unique(size); - std::copy_n(image.get()+i*size, size, slice.get()); + std::copy_n(image.get() + i * size, size, slice.get()); // We need a new md5 and name md5 = MD5::hash(slice, size); diff --git a/src/emucore/CartCreator.hxx b/src/emucore/CartCreator.hxx index f7ce4a956..676b565f4 100644 --- a/src/emucore/CartCreator.hxx +++ b/src/emucore/CartCreator.hxx @@ -56,7 +56,7 @@ class CartCreator @param image A pointer to the complete ROM image @param size The size of the ROM image slice - @param numroms The number of ROMs in the multicart + @param numRoms The number of ROMs in the multicart @param md5 The md5sum for the slice of the ROM image @param type The detected type of the slice of the ROM image @param id The ID for the slice of the ROM image @@ -66,7 +66,7 @@ class CartCreator */ static unique_ptr createFromMultiCart(const ByteBuffer& image, size_t& size, - uInt32 numroms, string& md5, Bankswitch::Type& type, string& id, + uInt32 numRoms, string& md5, Bankswitch::Type& type, string& id, Settings& settings); /** diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index b050f2ff1..d545d56ae 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -772,7 +772,7 @@ void GameInfoDialog::loadEmulationProperties(const Properties& props) VarList::push_back(items, startBank, startBank); } myStartBank->addItems(items); - myStartBank->setSelected(props.get(PropType::Cart_StartBank), "AUTO"); + myStartBank->setSelected(props.get(PropType::Cart_StartBank), "Auto"); myFormat->setSelected(props.get(PropType::Display_Format), "AUTO"); if(instance().hasConsole() && myFormat->getSelectedTag().toString() == "AUTO")