mirror of https://github.com/stella-emu/stella.git
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
This commit is contained in:
parent
8a8d04031a
commit
594954789c
|
@ -21,6 +21,11 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
#include "MediaFactory.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()
|
void OSystem::mainLoop()
|
||||||
{
|
{
|
||||||
|
|
|
@ -368,7 +368,7 @@ class OSystem
|
||||||
|
|
||||||
@return Current time in microseconds.
|
@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
|
// The following methods are system-specific and can be overrided in
|
||||||
|
|
|
@ -29,23 +29,36 @@
|
||||||
|
|
||||||
#ifdef HAVE_INTTYPES
|
#ifdef HAVE_INTTYPES
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
// 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
|
#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
|
// The following code should provide access to the standard C++ objects and
|
||||||
// types: cout, cerr, string, ostream, istream, etc.
|
// types: cout, cerr, string, ostream, istream, etc.
|
||||||
|
|
|
@ -31,11 +31,6 @@
|
||||||
#include "OSystemMACOSX.hxx"
|
#include "OSystemMACOSX.hxx"
|
||||||
#include "MenusEvents.h"
|
#include "MenusEvents.h"
|
||||||
|
|
||||||
#ifdef HAVE_GETTIMEOFDAY
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void macOpenConsole(char *romname);
|
void macOpenConsole(char *romname);
|
||||||
uInt16 macOSXDisplayWidth(void);
|
uInt16 macOSXDisplayWidth(void);
|
||||||
|
@ -93,6 +88,8 @@ OSystemMACOSX::OSystemMACOSX()
|
||||||
: OSystem()
|
: OSystem()
|
||||||
{
|
{
|
||||||
setBaseDir("~/.stella");
|
setBaseDir("~/.stella");
|
||||||
|
|
||||||
|
// This will be overridden, as OSX uses plist files for settings
|
||||||
setConfigFile("~/.stella/stellarc");
|
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)
|
void OSystemMACOSX::getScreenDimensions(int& width, int& height)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,13 +42,6 @@ class OSystemMACOSX : public OSystem
|
||||||
virtual ~OSystemMACOSX();
|
virtual ~OSystemMACOSX();
|
||||||
|
|
||||||
public:
|
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.
|
This method queries the dimensions of the screen for this hardware.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,18 +16,10 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
#include "OSystemUNIX.hxx"
|
#include "OSystemUNIX.hxx"
|
||||||
|
|
||||||
#ifdef HAVE_GETTIMEOFDAY
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Each derived class is responsible for calling the following methods
|
Each derived class is responsible for calling the following methods
|
||||||
in its constructor:
|
in its constructor:
|
||||||
|
@ -50,16 +42,3 @@ OSystemUNIX::OSystemUNIX()
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
|
@ -39,13 +39,6 @@ class OSystemUNIX : public OSystem
|
||||||
Destructor
|
Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~OSystemUNIX();
|
virtual ~OSystemUNIX();
|
||||||
|
|
||||||
/**
|
|
||||||
This method returns number of ticks in microseconds.
|
|
||||||
|
|
||||||
@return Current time in microseconds.
|
|
||||||
*/
|
|
||||||
uInt64 getTicks() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue