From 594954789c39ad8c5d7b2a554606c65ddbedab47 Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 1 Jul 2009 16:04:28 +0000 Subject: [PATCH] Surprise, surprise, Microsoft doesn't support the C99 standard, and doesn't know what intxx_t datatypes are. So we need yet another check for Win32-specific stuff in BSPF. Folded getTicks() from UNIX and OSX back into OSystem directly. The default is now to use OSystem::getTicks() unless it's overrided by a platform-specific OSystemXXX class. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1824 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/emucore/OSystem.cxx | 18 +++++++++++ src/emucore/OSystem.hxx | 2 +- src/emucore/m6502/src/bspf/src/bspf.hxx | 43 ++++++++++++++++--------- src/macosx/OSystemMACOSX.cxx | 20 ++---------- src/macosx/OSystemMACOSX.hxx | 7 ---- src/unix/OSystemUNIX.cxx | 21 ------------ src/unix/OSystemUNIX.hxx | 7 ---- 7 files changed, 49 insertions(+), 69 deletions(-) diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 90d1e440f..51a3eebed 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -21,6 +21,11 @@ #include #include +#ifdef HAVE_GETTIMEOFDAY + #include + #include +#endif + #include "bspf.hxx" #include "MediaFactory.hxx" @@ -862,6 +867,19 @@ void OSystem::stateChanged(EventHandler::State state) { } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +uInt64 OSystem::getTicks() const +{ +#ifdef HAVE_GETTIMEOFDAY + timeval now; + gettimeofday(&now, 0); + + return uInt64(now.tv_sec) * 1000000 + now.tv_usec; +#else + return uInt64(SDL_GetTicks()) * 1000; +#endif +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void OSystem::mainLoop() { diff --git a/src/emucore/OSystem.hxx b/src/emucore/OSystem.hxx index aa5a830d8..6faddd7b9 100644 --- a/src/emucore/OSystem.hxx +++ b/src/emucore/OSystem.hxx @@ -368,7 +368,7 @@ class OSystem @return Current time in microseconds. */ - virtual uInt64 getTicks() const = 0; + virtual uInt64 getTicks() const; ////////////////////////////////////////////////////////////////////// // The following methods are system-specific and can be overrided in diff --git a/src/emucore/m6502/src/bspf/src/bspf.hxx b/src/emucore/m6502/src/bspf/src/bspf.hxx index 0b963b35f..e3eb0a828 100644 --- a/src/emucore/m6502/src/bspf/src/bspf.hxx +++ b/src/emucore/m6502/src/bspf/src/bspf.hxx @@ -29,23 +29,36 @@ #ifdef HAVE_INTTYPES #include + + // Types for 8-bit signed and unsigned integers + typedef int8_t Int8; + typedef uint8_t uInt8; + // Types for 16-bit signed and unsigned integers + typedef int16_t Int16; + typedef uint16_t uInt16; + // Types for 32-bit signed and unsigned integers + typedef int32_t Int32; + typedef uint32_t uInt32; + // Types for 64-bit signed and unsigned integers + typedef int64_t Int64; + typedef uint64_t uInt64; +#elif defined BSPF_WIN32 + // Types for 8-bit signed and unsigned integers + typedef signed char Int8; + typedef unsigned char uInt8; + // Types for 16-bit signed and unsigned integers + typedef signed short Int16; + typedef unsigned short uInt16; + // Types for 32-bit signed and unsigned integers + typedef signed int Int32; + typedef unsigned int uInt32; + // Types for 64-bit signed and unsigned integers + typedef __int64 Int64; + typedef unsigned __int64 uInt64; +#else + #error Update BSPF.hxx for datatypes #endif -// Types for 8-bit signed and unsigned integers -typedef int8_t Int8; -typedef uint8_t uInt8; - -// Types for 16-bit signed and unsigned integers -typedef int16_t Int16; -typedef uint16_t uInt16; - -// Types for 32-bit signed and unsigned integers -typedef int32_t Int32; -typedef uint32_t uInt32; - -// Types for 64-bit signed and unsigned integers -typedef int64_t Int64; -typedef uint64_t uInt64; // The following code should provide access to the standard C++ objects and // types: cout, cerr, string, ostream, istream, etc. diff --git a/src/macosx/OSystemMACOSX.cxx b/src/macosx/OSystemMACOSX.cxx index 2a4ca5894..9369fd42b 100644 --- a/src/macosx/OSystemMACOSX.cxx +++ b/src/macosx/OSystemMACOSX.cxx @@ -31,11 +31,6 @@ #include "OSystemMACOSX.hxx" #include "MenusEvents.h" -#ifdef HAVE_GETTIMEOFDAY - #include - #include -#endif - extern "C" { void macOpenConsole(char *romname); uInt16 macOSXDisplayWidth(void); @@ -93,6 +88,8 @@ OSystemMACOSX::OSystemMACOSX() : OSystem() { setBaseDir("~/.stella"); + + // This will be overridden, as OSX uses plist files for settings setConfigFile("~/.stella/stellarc"); } @@ -101,19 +98,6 @@ OSystemMACOSX::~OSystemMACOSX() { } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt64 OSystemMACOSX::getTicks() const -{ -#ifdef HAVE_GETTIMEOFDAY - timeval now; - gettimeofday(&now, 0); - - return uInt64(now.tv_sec) * 1000000 + now.tv_usec; -#else - return uInt64(SDL_GetTicks()) * 1000; -#endif -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void OSystemMACOSX::getScreenDimensions(int& width, int& height) { diff --git a/src/macosx/OSystemMACOSX.hxx b/src/macosx/OSystemMACOSX.hxx index 5b943d5b2..6fd49bf96 100644 --- a/src/macosx/OSystemMACOSX.hxx +++ b/src/macosx/OSystemMACOSX.hxx @@ -42,13 +42,6 @@ class OSystemMACOSX : public OSystem virtual ~OSystemMACOSX(); public: - /** - This method returns number of ticks in microseconds. - - @return Current time in microseconds. - */ - virtual uInt64 getTicks() const; - /** This method queries the dimensions of the screen for this hardware. */ diff --git a/src/unix/OSystemUNIX.cxx b/src/unix/OSystemUNIX.cxx index affc861b2..04b223a9c 100644 --- a/src/unix/OSystemUNIX.cxx +++ b/src/unix/OSystemUNIX.cxx @@ -16,18 +16,10 @@ // $Id$ //============================================================================ -#include -#include - #include "bspf.hxx" #include "OSystem.hxx" #include "OSystemUNIX.hxx" -#ifdef HAVE_GETTIMEOFDAY - #include - #include -#endif - /** Each derived class is responsible for calling the following methods in its constructor: @@ -50,16 +42,3 @@ OSystemUNIX::OSystemUNIX() OSystemUNIX::~OSystemUNIX() { } - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt64 OSystemUNIX::getTicks() const -{ -#ifdef HAVE_GETTIMEOFDAY - timeval now; - gettimeofday(&now, 0); - - return uInt64(now.tv_sec) * 1000000 + now.tv_usec; -#else - return uInt64(SDL_GetTicks()) * 1000; -#endif -} diff --git a/src/unix/OSystemUNIX.hxx b/src/unix/OSystemUNIX.hxx index 390ad753a..71acf1358 100644 --- a/src/unix/OSystemUNIX.hxx +++ b/src/unix/OSystemUNIX.hxx @@ -39,13 +39,6 @@ class OSystemUNIX : public OSystem Destructor */ virtual ~OSystemUNIX(); - - /** - This method returns number of ticks in microseconds. - - @return Current time in microseconds. - */ - uInt64 getTicks() const; }; #endif