diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index e9cd34550..3dcf395f1 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: EventHandler.cxx,v 1.149 2006-01-25 01:42:46 stephena Exp $ +// $Id: EventHandler.cxx,v 1.150 2006-01-30 01:01:44 stephena Exp $ //============================================================================ #include @@ -349,6 +349,9 @@ void EventHandler::poll(uInt32 time) // while(myEventStreamer->pollEvent(type, value)) // myEvent->set((Event::Type)type, value); + // Synthesize events for platform-specific hardware + myOSystem->pollEvent(); + // Check for an event SDL_Event event; while(SDL_PollEvent(&event)) diff --git a/stella/src/emucore/OSystem.cxx b/stella/src/emucore/OSystem.cxx index 6551a32f0..b164a0aac 100644 --- a/stella/src/emucore/OSystem.cxx +++ b/stella/src/emucore/OSystem.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OSystem.cxx,v 1.58 2006-01-19 00:45:12 stephena Exp $ +// $Id: OSystem.cxx,v 1.59 2006-01-30 01:01:44 stephena Exp $ //============================================================================ #include @@ -487,6 +487,11 @@ void OSystem::setDefaultJoyHatMap() { } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void OSystem::pollEvent() +{ +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OSystem::OSystem(const OSystem& osystem) { diff --git a/stella/src/emucore/OSystem.hxx b/stella/src/emucore/OSystem.hxx index 613581af5..7e2f35a33 100644 --- a/stella/src/emucore/OSystem.hxx +++ b/stella/src/emucore/OSystem.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OSystem.hxx,v 1.36 2006-01-09 16:50:01 stephena Exp $ +// $Id: OSystem.hxx,v 1.37 2006-01-30 01:01:44 stephena Exp $ //============================================================================ #ifndef OSYSTEM_HXX @@ -44,7 +44,7 @@ class CheatManager; other objects belong. @author Stephen Anthony - @version $Id: OSystem.hxx,v 1.36 2006-01-09 16:50:01 stephena Exp $ + @version $Id: OSystem.hxx,v 1.37 2006-01-30 01:01:44 stephena Exp $ */ class OSystem { @@ -345,6 +345,11 @@ class OSystem */ virtual void setDefaultJoyHatMap(); + /** + This method creates events from platform-specific hardware. + */ + virtual void pollEvent(); + protected: /** Set the base directory for all Stella files diff --git a/stella/src/gp2x/OSystemGP2X.cxx b/stella/src/gp2x/OSystemGP2X.cxx index 71d88961d..a5931999e 100644 --- a/stella/src/gp2x/OSystemGP2X.cxx +++ b/stella/src/gp2x/OSystemGP2X.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OSystemGP2X.cxx,v 1.1 2006-01-08 02:28:03 stephena Exp $ +// $Id: OSystemGP2X.cxx,v 1.2 2006-01-30 01:01:44 stephena Exp $ // Modified on 2006/01/06 by Alex Zaballa for use on GP2X //============================================================================ @@ -76,8 +76,6 @@ OSystemGP2X::OSystemGP2X() string cacheFile = basedir + "/stella.cache"; setCacheFile(cacheFile); - - // No drivers are specified for Unix } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -92,69 +90,32 @@ void OSystemGP2X::mainLoop() // and are needed to calculate the overall frames per second. uInt32 frameTime = 0, numberOfFrames = 0; - if(mySettings->getBool("accurate")) // normal, CPU-intensive timing + // Set up less accurate timing stuff + uInt32 startTime, virtualTime, currentTime; + + // Set the base for the timers + virtualTime = getTicks(); + frameTime = 0; + + // Main game loop + for(;;) { - // Set up accurate timing stuff - uInt32 startTime, delta; + // Exit if the user wants to quit + if(myEventHandler->doQuit()) + break; - // Set the base for the timers - frameTime = 0; + startTime = getTicks(); + myEventHandler->poll(startTime); + myFrameBuffer->update(); - // Main game loop - for(;;) - { - // Exit if the user wants to quit - if(myEventHandler->doQuit()) - break; + currentTime = getTicks(); + virtualTime += myTimePerFrame; + if(currentTime < virtualTime) + SDL_Delay((virtualTime - currentTime)/1000); - startTime = getTicks(); - myEventHandler->poll(startTime); - myFrameBuffer->update(); - - // Now, waste time if we need to so that we are at the desired frame rate - for(;;) - { - delta = getTicks() - startTime; - - if(delta >= myTimePerFrame) - break; - } - - frameTime += getTicks() - startTime; - ++numberOfFrames; - } - } - else // less accurate, less CPU-intensive timing - { - // Set up less accurate timing stuff - uInt32 startTime, virtualTime, currentTime; - - // Set the base for the timers - virtualTime = getTicks(); - frameTime = 0; - - // Main game loop - for(;;) - { - // Exit if the user wants to quit - if(myEventHandler->doQuit()) - break; - - startTime = getTicks(); - myEventHandler->poll(startTime); - myFrameBuffer->update(); - - currentTime = getTicks(); - virtualTime += myTimePerFrame; - if(currentTime < virtualTime) - { - SDL_Delay((virtualTime - currentTime)/1000); - } - - currentTime = getTicks() - startTime; - frameTime += currentTime; - ++numberOfFrames; - } + currentTime = getTicks() - startTime; + frameTime += currentTime; + ++numberOfFrames; } // Only print console information if a console was actually created @@ -218,3 +179,10 @@ void OSystemGP2X::setDefaultJoymap() void OSystemGP2X::setDefaultJoyAxisMap() { } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void OSystemGP2X::pollEvent() +{ + // TODO - add code to translate joystick directions into proper SDL HAT + // events, so that the core code will 'just work' +} diff --git a/stella/src/gp2x/OSystemGP2X.hxx b/stella/src/gp2x/OSystemGP2X.hxx index fcf223509..dc5464858 100644 --- a/stella/src/gp2x/OSystemGP2X.hxx +++ b/stella/src/gp2x/OSystemGP2X.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OSystemGP2X.hxx,v 1.1 2006-01-08 02:28:03 stephena Exp $ +// $Id: OSystemGP2X.hxx,v 1.2 2006-01-30 01:01:44 stephena Exp $ // Modified by Alex Zaballa on 2006/01/04 for use on GP2X //============================================================================ @@ -45,19 +45,19 @@ class OSystemGP2X : public OSystem may use different timing methods and/or algorithms, this method has been abstracted to each platform. */ - virtual void mainLoop(); + void mainLoop(); /** This method returns number of ticks in microseconds. @return Current time in microseconds. */ - virtual uInt32 getTicks(); + uInt32 getTicks(); /** This method queries the dimensions of the screen for this hardware. */ - virtual void getScreenDimensions(int& width, int& height); + void getScreenDimensions(int& width, int& height); /** This method determines the default mapping of joystick buttons to @@ -70,6 +70,11 @@ class OSystemGP2X : public OSystem Stella events for for the PSP device. */ void setDefaultJoyAxisMap(); + + /** + This method creates events from platform-specific hardware. + */ + void pollEvent(); }; #endif diff --git a/stella/src/gp2x/SettingsGP2X.cxx b/stella/src/gp2x/SettingsGP2X.cxx index 55aec43a8..bb8bdba36 100644 --- a/stella/src/gp2x/SettingsGP2X.cxx +++ b/stella/src/gp2x/SettingsGP2X.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: SettingsGP2X.cxx,v 1.3 2006-01-25 01:42:47 stephena Exp $ +// $Id: SettingsGP2X.cxx,v 1.4 2006-01-30 01:01:44 stephena Exp $ // Modified on 2006/01/04 by Alex Zaballa for use on GP2X //============================================================================ @@ -28,7 +28,6 @@ SettingsGP2X::SettingsGP2X(OSystem* osystem) { // Some of these settings might be redundant, but are crucial for GP2X set("center", "true"); - set("accurate", "false"); set("volume", "50"); set("sound", "true"); set("zoom", "1");