From cb3f0e96ba0e83c42bc8b31d65cfbc855160a2a3 Mon Sep 17 00:00:00 2001 From: stephena Date: Thu, 9 Jun 2011 20:50:19 +0000 Subject: [PATCH] Zero-byte ROMs are now rejected, instead of being loaded as Supercharger ROMs. Fixed bug in handling analog axes with jitter; they were overriding events from digital, hat and keyboard input. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2251 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- Changes.txt | 20 +++++++++++++++----- docs/index.html | 2 +- src/emucore/EventHandler.cxx | 17 +++++++++++++---- src/emucore/OSystem.cxx | 36 +++++++++++++++++++++--------------- src/gui/LauncherDialog.cxx | 7 ++----- 5 files changed, 52 insertions(+), 30 deletions(-) diff --git a/Changes.txt b/Changes.txt index 47c4fdeb4..0e8bc6f7f 100644 --- a/Changes.txt +++ b/Changes.txt @@ -20,19 +20,29 @@ - it only has meaning while in emulation mode - it is enabled by default - * Fixed bug with emulation of paddles using the mouse in Warlords; - movement was being filtered out if the mouse was moved too fast. + * Fixed bug with emulation of paddles using the mouse most evident in + Warlords; movement was being filtered out if the mouse was moved too + fast. There's still more work required in this area, however. - * Fixed bug whereby switching to the debugger and back again would + * Fixed bug with analog axes on gamepad devices, whereby jittering in + these axes would override input from digital axis, hat or keyboard + input. + + * Fixed bug when switching to the debugger and back again would sometimes cause an extra mouse motion event (which would cause the emulation to think the mouse was moved and move the player accordingly). - * Tweaked bankswitch autodetection code for 4A50 bankswitching. + * Tweaked bankswitch autodetection code for 4A50 bankswitching; several + more test ROMs are automatically detected. * The 'saverom' debugger command now saves ROMs in your home directory by default if you don't specify a valid path. This fixes - a bug whereby ROMs were saved and couldn't later be located. + a bug whereby ROMs were saved in strange locations and couldn't later + be found. + + * Zero-byte ROMs are no longer loaded and mis-detected as Supercharger + images. -Have fun! diff --git a/docs/index.html b/docs/index.html index a57a4add2..9dac7ff0a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2934,7 +2934,7 @@ Ms Pac-Man (Stella extended codes): 2K 64-2048 byte Atari 3E 32K Tigervision 3F 512K Tigervision - 4A50 ¹64K 4A50 + ram + 4A50 64K 4A50 + ram 4K 4K Atari AR Supercharger CV Commavid extra ram diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 5fd27d52c..b3135dd7a 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -818,11 +818,20 @@ void EventHandler::poll(uInt64 time) handleEvent(eventAxisNeg, 1); else { - // Turn off both events, since we don't know exactly which one - // was previously activated. - handleEvent(eventAxisNeg, 0); - handleEvent(eventAxisPos, 0); + // Treat any deadzone value as zero + value = 0; + + // Now filter out consecutive, similar values + // (only pass on the event if the state has changed) + if(myAxisLastValue[stick][axis] != value) + { + // Turn off both events, since we don't know exactly which one + // was previously activated. + handleEvent(eventAxisNeg, 0); + handleEvent(eventAxisPos, 0); + } } + myAxisLastValue[stick][axis] = value; break; } } diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index ae6f97d81..2aab15afd 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -479,7 +479,7 @@ bool OSystem::createConsole(const string& romfile, const string& md5sum) // Do a little error checking; it shouldn't be necessary if(myConsole) deleteConsole(); - bool retval = false, showmessage = false; + bool showmessage = false; // If a blank ROM has been given, we reload the current one (assuming one exists) if(romfile == "") @@ -546,25 +546,24 @@ bool OSystem::createConsole(const string& romfile, const string& md5sum) resetLoopTiming(); myFrameBuffer->setCursorState(); - retval = true; + + // Also check if certain virtual buttons should be held down + // These must be checked each time a new console is being created + if(mySettings->getBool("holdreset")) + myEventHandler->handleEvent(Event::ConsoleReset, 1); + if(mySettings->getBool("holdselect")) + myEventHandler->handleEvent(Event::ConsoleSelect, 1); + if(mySettings->getBool("holdbutton0")) + myEventHandler->handleEvent(Event::JoystickZeroFire1, 1); + + return true; } else { buf << "ERROR: Couldn't create console for " << myRomFile << endl; logMessage(buf.str(), 0); - retval = false; + return false; } - - // Also check if certain virtual buttons should be held down - // These must be checked each time a new console is being created - if(mySettings->getBool("holdreset")) - myEventHandler->handleEvent(Event::ConsoleReset, 1); - if(mySettings->getBool("holdselect")) - myEventHandler->handleEvent(Event::ConsoleSelect, 1); - if(mySettings->getBool("holdbutton0")) - myEventHandler->handleEvent(Event::JoystickZeroFire1, 1); - - return retval; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -813,6 +812,13 @@ uInt8* OSystem::openROM(string file, string& md5, uInt32& size) gzclose(f); } + // Zero-byte files should be automatically discarded + if(size == 0) + { + delete[] image; + return (uInt8*) 0; + } + // If we get to this point, we know we have a valid file to open // Now we make sure that the file has a valid properties entry // To save time, only generate an MD5 if we really need one @@ -868,7 +874,7 @@ void OSystem::validatePath(const string& setting, const string& partialpath, { const string& s = mySettings->getString(setting) != "" ? mySettings->getString(setting) : myBaseDir + partialpath; - FilesystemNode node = FilesystemNode(s); + FilesystemNode node(s); if(!node.isDirectory()) { AbstractFilesystemNode::makeDir(s); diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index b67197646..2ea587037 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -538,14 +538,11 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd, if(LauncherFilterDialog::isValidRomName(rom, extension)) { if(instance().createConsole(rom, md5)) - { - #if !defined(GP2X) // Quick GP2X hack to spare flash-card saves instance().settings().setString("lastrom", myList->getSelectedString()); - #endif - } else instance().frameBuffer().showMessage( - "Error creating console (screen too small)", kMiddleCenter, true); + "Error creating console (check ROM file)", + kMiddleCenter, true); } else instance().frameBuffer().showMessage("Not a valid ROM file",