fix cart detection for 512K ROMs

add new event & hotkey for selecting previous multicart ROM
This commit is contained in:
thrust26 2020-05-25 13:58:53 +02:00
parent f284b91f28
commit 70ab70ab46
8 changed files with 39 additions and 12 deletions

View File

@ -1749,9 +1749,15 @@
<td>Control + 1</td>
</tr>
<tr>
<td>Load <i>previous</i> game in ROM (multicart ROM, TIA mode)</td>
<td>Shift-Control + r</td>
<td>Shift-Control + r</td>
</tr>
<tr>
<td>Reload current ROM (singlecart ROM, TIA mode)<br>
Load next game in ROM (multicart ROM, TIA mode)</td>
Load <i>next</i> game in ROM (multicart ROM, TIA mode)</td>
<td>Control + r</td>
<td>Control + r</td>
</tr>

View File

@ -459,6 +459,7 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo
{Event::Quit, KBDK_Q, KBDM_CTRL},
#endif
{Event::ReloadConsole, KBDK_R, KBDM_CTRL},
{Event::PreviousMultiCartRom, KBDK_R, KBDM_SHIFT | KBDM_CTRL},
{Event::VidmodeDecrease, KBDK_MINUS, MOD3},
{Event::VidmodeIncrease, KBDK_EQUALS, MOD3},

View File

@ -218,6 +218,14 @@ CartDetector::createFromMultiCart(const ByteBuffer& image, size_t& size,
{
// 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;
else
i = (i - 1) % numroms;
settings.setValue("romloadcount", i);
size /= numroms;
ByteBuffer slice = make_unique<uInt8[]>(size);
std::copy_n(image.get()+i*size, size, slice.get());
@ -228,9 +236,6 @@ CartDetector::createFromMultiCart(const ByteBuffer& image, size_t& size,
buf << " [G" << (i+1) << "]";
id = buf.str();
// Move to the next game the next time this ROM is loaded
settings.setValue("romloadcount", (i+1)%numroms);
if(size <= 2_KB) type = Bankswitch::Type::_2K;
else if(size == 4_KB) type = Bankswitch::Type::_4K;
else if(size == 8_KB) type = Bankswitch::Type::_F8;
@ -529,7 +534,13 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
}
else if(size == 512_KB)
{
if(isProbablyTVBoy(image, size))
if(isProbably3EX(image, size))
type = Bankswitch::Type::_3EX;
else if(isProbably3E(image, size))
type = Bankswitch::Type::_3E;
else if(isProbably3F(image, size))
type = Bankswitch::Type::_3F;
else if(isProbablyTVBoy(image, size))
type = Bankswitch::Type::_TVBOY;
}
else // what else can we do?

View File

@ -123,7 +123,7 @@ class Event
ToggleFrameStats, ToggleSAPortOrder, ExitGame,
// add new events from here to avoid that user remapped events get overwritten
SettingDecrease, SettingIncrease, PreviousSetting, NextSetting,
ToggleAdaptRefresh,
ToggleAdaptRefresh, PreviousMultiCartRom,
LastType
};

View File

@ -544,7 +544,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
return;
case Event::ReloadConsole:
if(pressed && !repeated) myOSystem.reloadConsole();
if(pressed && !repeated) myOSystem.reloadConsole(true);
return;
case Event::PreviousMultiCartRom:
if(pressed && !repeated) myOSystem.reloadConsole(false);
return;
case Event::VolumeDecrease:
@ -2172,6 +2176,7 @@ void EventHandler::exitEmulation(bool checkLauncher)
EventHandler::EmulActionList EventHandler::ourEmulActionList = { {
{ Event::Quit, "Quit", "" },
{ Event::ReloadConsole, "Reload current ROM/load next game", "" },
{ Event::PreviousMultiCartRom, "Load previous multicart game", "" },
{ Event::ExitMode, "Exit current Stella menu/mode", "" },
{ Event::OptionsMenuMode, "Enter Options menu UI", "" },
{ Event::CmdMenuMode, "Toggle Commands menu UI", "" },
@ -2409,7 +2414,7 @@ const Event::EventSet EventHandler::MiscEvents = {
// Event::MouseAxisXMove, Event::MouseAxisYMove,
// Event::MouseButtonLeftValue, Event::MouseButtonRightValue,
Event::HandleMouseControl, Event::ToggleGrabMouse,
Event::ToggleSAPortOrder,
Event::ToggleSAPortOrder, Event::PreviousMultiCartRom
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -525,7 +525,7 @@ class EventHandler
#else
REFRESH_SIZE = 0,
#endif
EMUL_ACTIONLIST_SIZE = 156 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE,
EMUL_ACTIONLIST_SIZE = 157 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE,
MENU_ACTIONLIST_SIZE = 18
;

View File

@ -399,7 +399,7 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
// Each time a new console is loaded, we simulate a cart removal
// Some carts need knowledge of this, as they behave differently
// based on how many power-cycles they've been through since plugged in
mySettings->setValue("romloadcount", 0);
mySettings->setValue("romloadcount", -1); // we move to the next game initially
}
// Create an instance of the 2600 game console
@ -474,8 +474,10 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool OSystem::reloadConsole()
bool OSystem::reloadConsole(bool nextrom)
{
mySettings->setValue("romloadprev", !nextrom);
return createConsole(myRomFile, myRomMD5, false) == EmptyString;
}

View File

@ -345,9 +345,11 @@ class OSystem
Reloads the current console (essentially deletes and re-creates it).
This can be thought of as a real console off/on toggle.
@param nextrom If true select next multicart ROM, else previous one
@return True on successful creation, otherwise false
*/
bool reloadConsole();
bool reloadConsole(bool nextrom = true);
/**
Creates a new ROM launcher, to select a new ROM to emulate.