mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-12-26 07:34:52 +01:00
Merge pull request #36 from DrItanium/abstraction-layer
Abstraction layer
This commit is contained in:
commit
fd52a044d4
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -81,7 +81,9 @@ Sources/SeriousSkaStudio/Parser.cpp
|
|||
Sources/SeriousSkaStudio/Parser.h
|
||||
Sources/SeriousSkaStudio/Scanner.cpp
|
||||
|
||||
|
||||
# vim swap files
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -13,14 +13,17 @@ You should have received a copy of the GNU General Public License along
|
|||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
|
||||
|
||||
|
||||
#ifndef SE_INCL_ENGINE_BASE_BASE_H
|
||||
#define SE_INCL_ENGINE_BASE_BASE_H
|
||||
/*
|
||||
* rcg10042001 In case these don't get defined in the project file, try to
|
||||
* catch them here...
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
// be a little more discerning, using these macros will ensure that if someone
|
||||
// wants to use MINGW then they can
|
||||
#if (defined _WIN32) || (defined _WIN64)
|
||||
#ifndef PLATFORM_WIN32
|
||||
#define PLATFORM_WIN32
|
||||
#define PLATFORM_WIN32 1
|
||||
#endif
|
||||
|
||||
#ifndef PRAGMA_ONCE
|
||||
|
@ -51,10 +54,34 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#endif // defined _MSC_VER
|
||||
#elif (defined __linux__)
|
||||
#if (defined __ANDROID__) || (defined __android__)
|
||||
#error "Android current isn't supported"
|
||||
#else
|
||||
#define PLATFORM_LINUX 1
|
||||
#endif
|
||||
#elif (defined __APPLE__)
|
||||
#include "TargetConditionals.h"
|
||||
#if TARGET_OS_MAC
|
||||
#define PLATFORM_MACOSX 1
|
||||
#else
|
||||
#error "Unsupported apple platform"
|
||||
#endif
|
||||
#else
|
||||
#warning "UNKNOWN PLATFORM IDENTIFIED!!!!"
|
||||
#define PLATFORM_UNKNOWN 1
|
||||
#warning "USING PORTABLE C!!!"
|
||||
#define USE_PORTABLE_C
|
||||
#endif
|
||||
|
||||
#if PLATFORM_LINUX || PLATFORM_MACOSX
|
||||
#ifndef PLATFORM_UNIX
|
||||
#define PLATFORM_UNIX 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_UNIX /* rcg10042001 */
|
||||
#define ENGINE_API
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
45
Sources/Engine/Base/SystemSpecificInclude.h
Normal file
45
Sources/Engine/Base/SystemSpecificInclude.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* Copyright (c) 2002-2012 Croteam Ltd.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of version 2 of the GNU General Public License as published by
|
||||
the Free Software Foundation
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
|
||||
|
||||
#ifndef SE_INCL_ENGINE_BASE_SYSTEM_SPECIFIC_INCLUDE_H
|
||||
#define SE_INCL_ENGINE_BASE_SYSTEM_SPECIFIC_INCLUDE_H
|
||||
|
||||
#ifdef PRAGMA_ONCE
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <Engine/Base/Base.h> //blerg potential cyclic dependency :(
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <search.h> // for qsort
|
||||
#include <float.h> // for FPU control
|
||||
|
||||
/* rcg10042001 !!! FIXME: Move these somewhere. */
|
||||
#if (defined PLATFORM_WIN32)
|
||||
#include <malloc.h>
|
||||
#include <conio.h>
|
||||
#include <crtdbg.h>
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h> // for timers
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include <Engine/Base/Priority.inl>
|
||||
|
||||
// !!! FIXME: use SDL timer code instead and rdtsc never?
|
||||
#if (USE_PORTABLE_C)
|
||||
#if (USE_PORTABLE_C)
|
||||
#define USE_GETTIMEOFDAY 1
|
||||
#endif
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include <Engine/Graphics/gl_types.h>
|
||||
|
||||
// !!! FIXME: use stdint.h for this (and other things like INDEX, too)?
|
||||
#ifdef PLATFORM_WIN32
|
||||
typedef signed int SLONG;
|
||||
typedef signed short int SWORD;
|
||||
typedef signed char SBYTE;
|
||||
|
@ -36,6 +37,20 @@ typedef unsigned int ULONG;
|
|||
typedef unsigned short int UWORD;
|
||||
typedef unsigned char UBYTE;
|
||||
typedef unsigned int UINT;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
// use the defined typesizes from MSDN to create an equivalent translation on
|
||||
// non windows platforms
|
||||
typedef int32_t SLONG;
|
||||
typedef int16_t SWORD;
|
||||
typedef int8_t SBYTE;
|
||||
typedef int32_t SINT;
|
||||
|
||||
typedef uint32_t ULONG;
|
||||
typedef uint16_t UWORD;
|
||||
typedef uint8_t UBYTE;
|
||||
typedef uint32_t UINT;
|
||||
#endif
|
||||
|
||||
// Flip this to 1 to turn off these messages everywhere.
|
||||
// !!! FIXME: I have it forced off for Windows because fprintf.
|
||||
|
@ -53,7 +68,8 @@ typedef unsigned int UINT;
|
|||
} while (0)
|
||||
#endif
|
||||
|
||||
#if __POWERPC__ /* rcg03232004 */
|
||||
// TODO: add more architecture detection routines
|
||||
#if __POWERPC__ || (defined __ppc64__) || (defined __alpha__) || (defined __sparc__) /* rcg03232004 */
|
||||
#define PLATFORM_BIGENDIAN 1
|
||||
#define PLATFORM_LITTLEENDIAN 0
|
||||
#else
|
||||
|
@ -121,6 +137,9 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*));
|
|||
#include <limits.h> // for PAGESIZE...
|
||||
#include <math.h>
|
||||
|
||||
// TODO: move the compiler detect routines to a separate file to declutter
|
||||
// things
|
||||
|
||||
// check for legacy defines...
|
||||
#if (defined __ICC)
|
||||
#if (!defined __INTEL_COMPILER)
|
||||
|
@ -248,22 +267,22 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*));
|
|||
#endif
|
||||
}
|
||||
|
||||
typedef unsigned long long __uint64;
|
||||
typedef uint64_t __uint64;
|
||||
#if (!defined __INTEL_COMPILER)
|
||||
typedef long long __int64;
|
||||
typedef int64_t __int64;
|
||||
#endif
|
||||
|
||||
typedef char CHAR;
|
||||
typedef UBYTE BYTE;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned int DWORD;
|
||||
typedef signed int LONG;
|
||||
typedef uint16_t WORD;
|
||||
typedef uint32_t DWORD;
|
||||
typedef int32_t LONG;
|
||||
typedef void *LPVOID;
|
||||
typedef char *LPSTR;
|
||||
typedef signed long int WPARAM;
|
||||
typedef signed long int LPARAM;
|
||||
typedef signed short int SHORT;
|
||||
typedef unsigned short int USHORT;
|
||||
typedef uint32_t WPARAM;
|
||||
typedef int32_t LPARAM;
|
||||
typedef int16_t SHORT;
|
||||
typedef uint16_t USHORT;
|
||||
|
||||
typedef void *HWND; /* !!! FIXME this sucks. */
|
||||
typedef void *HINSTANCE; /* !!! FIXME this sucks. */
|
||||
|
@ -318,9 +337,15 @@ MY_STATIC_ASSERT(size_tSize, sizeof(size_t) == sizeof(void*));
|
|||
#define MAX_UWORD ((UWORD)0xFFFF)
|
||||
#define MAX_UBYTE ((UBYTE)0xFF)
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
typedef int BOOL; // this is for TRUE/FALSE
|
||||
typedef int RESULT; // for error codes
|
||||
typedef int INDEX; // for indexed values and quantities
|
||||
#else
|
||||
typedef int32_t BOOL; // this is for TRUE/FALSE
|
||||
typedef int32_t RESULT; // for error codes
|
||||
typedef int32_t INDEX; // for indexed values and quantities
|
||||
#endif
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
|
|
@ -320,12 +320,176 @@ static void SanityCheckTypes(void)
|
|||
ASSERT(num == 0x01);
|
||||
#endif
|
||||
}
|
||||
|
||||
// startup engine
|
||||
ENGINE_API void SE_InitEngine(const char *argv0, CTString strGameID)
|
||||
// don't want to export this function
|
||||
static void PlatformIdentification(void)
|
||||
{
|
||||
SanityCheckTypes();
|
||||
// !!! FIXME: Abstract this somehow.
|
||||
#if (defined PLATFORM_WIN32)
|
||||
OSVERSIONINFO osv;
|
||||
memset(&osv, 0, sizeof(osv));
|
||||
osv.dwOSVersionInfoSize = sizeof(osv);
|
||||
if (GetVersionEx(&osv)) {
|
||||
switch (osv.dwPlatformId) {
|
||||
case VER_PLATFORM_WIN32s: sys_strOS = "Win32s"; break;
|
||||
case VER_PLATFORM_WIN32_WINDOWS: sys_strOS = "Win9x"; break;
|
||||
case VER_PLATFORM_WIN32_NT: sys_strOS = "WinNT"; break;
|
||||
default: sys_strOS = "Unknown\n"; break;
|
||||
}
|
||||
|
||||
sys_iOSMajor = osv.dwMajorVersion;
|
||||
sys_iOSMinor = osv.dwMinorVersion;
|
||||
sys_iOSBuild = osv.dwBuildNumber & 0xFFFF;
|
||||
sys_strOSMisc = osv.szCSDVersion;
|
||||
|
||||
CPrintF(TRANSV(" Type: %s\n"), (const char*)sys_strOS);
|
||||
CPrintF(TRANSV(" Version: %d.%d, build %d\n"),
|
||||
osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber & 0xFFFF);
|
||||
CPrintF(TRANSV(" Misc: %s\n"), osv.szCSDVersion);
|
||||
} else {
|
||||
CPrintF(TRANSV("Error getting OS info: %s\n"), GetWindowsError(GetLastError()) );
|
||||
}
|
||||
|
||||
#elif (defined PLATFORM_MACOSX)
|
||||
STUBBED("Use some Gestalt replacement, or whatever");
|
||||
#if 0
|
||||
long osver = 0x0000;
|
||||
OSErr err = Gestalt(gestaltSystemVersion, &osver);
|
||||
if (err != noErr)
|
||||
osver = 0x0000;
|
||||
|
||||
sys_iOSMajor = ((osver & 0x0F00) >> 8) + (((osver & 0xF000) >> 12) * 10);
|
||||
sys_iOSMinor = ((osver & 0x00F0) >> 4);
|
||||
sys_iOSBuild = ((osver & 0x000F) >> 0);
|
||||
#else
|
||||
sys_iOSMajor = 10; // !!! FIXME: just flatly false.
|
||||
sys_iOSMinor = 6;
|
||||
sys_iOSBuild = 0;
|
||||
#endif
|
||||
|
||||
sys_strOS = "Mac OS X";
|
||||
sys_strOSMisc = "Mac OS";
|
||||
CPrintF(TRANSV(" Type: %s\n"), (const char*)sys_strOS);
|
||||
CPrintF(TRANSV(" Version: %d.%d.%d\n"),
|
||||
(int)sys_iOSMajor, (int)sys_iOSMinor, (int)sys_iOSBuild);
|
||||
|
||||
#elif (defined PLATFORM_UNIX) // !!! FIXME: rcg10082001 what to do with this?
|
||||
// FIXME: probably want to use uname function on Linux but it isn't totally applicable...hmm...
|
||||
sys_iOSMajor = 1;
|
||||
sys_iOSMinor = 0;
|
||||
sys_iOSBuild = 0;
|
||||
sys_strOS = "Unix";
|
||||
sys_strOSMisc = "Unix";
|
||||
CPrintF(TRANSV(" Type: %s\n"), (const char*)sys_strOS);
|
||||
|
||||
#else
|
||||
#error Do something with this for your platform.
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SetupMemoryManager(void)
|
||||
{
|
||||
|
||||
#if (defined PLATFORM_WIN32) // !!! FIXME: Abstract this somehow.
|
||||
MEMORYSTATUS ms;
|
||||
GlobalMemoryStatus(&ms);
|
||||
|
||||
#define MB (1024*1024)
|
||||
sys_iRAMPhys = ms.dwTotalPhys /MB;
|
||||
sys_iRAMSwap = ms.dwTotalPageFile/MB;
|
||||
|
||||
#elif (defined PLATFORM_UNIX)
|
||||
sys_iRAMPhys = 1; // !!! FIXME: This is bad. Bad. BAD.
|
||||
sys_iRAMSwap = 1;
|
||||
|
||||
#else
|
||||
#error Do something with this for your platform.
|
||||
#endif
|
||||
}
|
||||
|
||||
static void SetupSecondaryStorage(void)
|
||||
{
|
||||
#if (defined PLATFORM_WIN32) // !!! FIXME: Abstract this somehow.
|
||||
// get info on the first disk in system
|
||||
DWORD dwSerial;
|
||||
DWORD dwFreeClusters;
|
||||
DWORD dwClusters;
|
||||
DWORD dwSectors;
|
||||
DWORD dwBytes;
|
||||
|
||||
char strDrive[] = "C:\\";
|
||||
strDrive[0] = strExePath[0];
|
||||
|
||||
GetVolumeInformationA(strDrive, NULL, 0, &dwSerial, NULL, NULL, NULL, 0);
|
||||
GetDiskFreeSpaceA(strDrive, &dwSectors, &dwBytes, &dwFreeClusters, &dwClusters);
|
||||
sys_iHDDSize = ((__int64)dwSectors)*dwBytes*dwClusters/MB;
|
||||
sys_iHDDFree = ((__int64)dwSectors)*dwBytes*dwFreeClusters/MB;
|
||||
sys_iHDDMisc = dwSerial;
|
||||
|
||||
#elif (defined PLATFORM_UNIX) // !!! FIXME: Uhh...?
|
||||
sys_iHDDSize = 1;
|
||||
sys_iHDDFree = 1;
|
||||
sys_iHDDMisc = 0xDEADBEEF;
|
||||
|
||||
#else
|
||||
#error Do something with this for your platform.
|
||||
#endif
|
||||
}
|
||||
|
||||
static void InitIFeel(void)
|
||||
{
|
||||
// !!! FIXME : rcg12072001 Move this somewhere else.
|
||||
#ifdef PLATFORM_WIN32
|
||||
// init IFeel
|
||||
HWND hwnd = NULL;//GetDesktopWindow();
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
if(IFeel_InitDevice(hInstance,hwnd))
|
||||
{
|
||||
CTString strDefaultProject = "Data\\Default.ifr";
|
||||
// get project file name for this device
|
||||
CTString strIFeel = IFeel_GetProjectFileName();
|
||||
// if no file name is returned use default file
|
||||
if(strIFeel.Length()==0) strIFeel = strDefaultProject;
|
||||
if(!IFeel_LoadFile(strIFeel))
|
||||
{
|
||||
if(strIFeel!=strDefaultProject)
|
||||
{
|
||||
IFeel_LoadFile(strDefaultProject);
|
||||
}
|
||||
}
|
||||
CPrintF("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void InitSystemGammaSettings(void)
|
||||
{
|
||||
// !!! FIXME: Move this into GfxLibrary...
|
||||
#ifdef PLATFORM_WIN32
|
||||
// readout system gamma table
|
||||
HDC hdc = GetDC(NULL);
|
||||
BOOL bOK = GetDeviceGammaRamp( hdc, &auwSystemGamma[0]);
|
||||
_pGfx->gl_ulFlags |= GLF_ADJUSTABLEGAMMA;
|
||||
if( !bOK) {
|
||||
_pGfx->gl_ulFlags &= ~GLF_ADJUSTABLEGAMMA;
|
||||
CPrintF( TRANS("\nWARNING: Gamma, brightness and contrast are not adjustable!\n\n"));
|
||||
} // done
|
||||
ReleaseDC( NULL, hdc);
|
||||
#else
|
||||
// !!! FIXME : rcg01072002 This CAN be done with SDL, actually. Move this somewhere.
|
||||
#ifdef PLATFORM_PANDORA
|
||||
// hacked gamma support
|
||||
_pGfx->gl_ulFlags |= GLF_ADJUSTABLEGAMMA;
|
||||
#else
|
||||
CPrintF( TRANS("\nWARNING: Gamma, brightness and contrast are not adjustable!\n\n"));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// System specific platform init functions
|
||||
static void PlatformSpecificInit(void)
|
||||
{
|
||||
#if PLATFORM_UNIX
|
||||
extern SDL_EventType WM_SYSKEYDOWN;
|
||||
extern SDL_EventType WM_LBUTTONDOWN;
|
||||
|
@ -340,6 +504,14 @@ ENGINE_API void SE_InitEngine(const char *argv0, CTString strGameID)
|
|||
WM_RBUTTONUP = (SDL_EventType) SDL_RegisterEvents(1);
|
||||
WM_PAINT = (SDL_EventType) SDL_RegisterEvents(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
// startup engine
|
||||
ENGINE_API void SE_InitEngine(const char *argv0, CTString strGameID)
|
||||
{
|
||||
SanityCheckTypes();
|
||||
|
||||
PlatformSpecificInit();
|
||||
|
||||
const char *gamename = "UnknownGame";
|
||||
if (strGameID != "")
|
||||
|
@ -412,67 +584,8 @@ ENGINE_API void SE_InitEngine(const char *argv0, CTString strGameID)
|
|||
|
||||
// report os info
|
||||
CPrintF(TRANSV("Examining underlying OS...\n"));
|
||||
|
||||
// !!! FIXME: Abstract this somehow.
|
||||
#if (defined PLATFORM_WIN32)
|
||||
OSVERSIONINFO osv;
|
||||
memset(&osv, 0, sizeof(osv));
|
||||
osv.dwOSVersionInfoSize = sizeof(osv);
|
||||
if (GetVersionEx(&osv)) {
|
||||
switch (osv.dwPlatformId) {
|
||||
case VER_PLATFORM_WIN32s: sys_strOS = "Win32s"; break;
|
||||
case VER_PLATFORM_WIN32_WINDOWS: sys_strOS = "Win9x"; break;
|
||||
case VER_PLATFORM_WIN32_NT: sys_strOS = "WinNT"; break;
|
||||
default: sys_strOS = "Unknown\n"; break;
|
||||
}
|
||||
|
||||
sys_iOSMajor = osv.dwMajorVersion;
|
||||
sys_iOSMinor = osv.dwMinorVersion;
|
||||
sys_iOSBuild = osv.dwBuildNumber & 0xFFFF;
|
||||
sys_strOSMisc = osv.szCSDVersion;
|
||||
|
||||
CPrintF(TRANSV(" Type: %s\n"), (const char*)sys_strOS);
|
||||
CPrintF(TRANSV(" Version: %d.%d, build %d\n"),
|
||||
osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber & 0xFFFF);
|
||||
CPrintF(TRANSV(" Misc: %s\n"), osv.szCSDVersion);
|
||||
} else {
|
||||
CPrintF(TRANSV("Error getting OS info: %s\n"), GetWindowsError(GetLastError()) );
|
||||
}
|
||||
|
||||
#elif (defined PLATFORM_MACOSX)
|
||||
STUBBED("Use some Gestalt replacement, or whatever");
|
||||
#if 0
|
||||
long osver = 0x0000;
|
||||
OSErr err = Gestalt(gestaltSystemVersion, &osver);
|
||||
if (err != noErr)
|
||||
osver = 0x0000;
|
||||
|
||||
sys_iOSMajor = ((osver & 0x0F00) >> 8) + (((osver & 0xF000) >> 12) * 10);
|
||||
sys_iOSMinor = ((osver & 0x00F0) >> 4);
|
||||
sys_iOSBuild = ((osver & 0x000F) >> 0);
|
||||
#else
|
||||
sys_iOSMajor = 10; // !!! FIXME: just flatly false.
|
||||
sys_iOSMinor = 6;
|
||||
sys_iOSBuild = 0;
|
||||
#endif
|
||||
|
||||
sys_strOS = "Mac OS X";
|
||||
sys_strOSMisc = "Mac OS";
|
||||
CPrintF(TRANSV(" Type: %s\n"), (const char*)sys_strOS);
|
||||
CPrintF(TRANSV(" Version: %d.%d.%d\n"),
|
||||
(int)sys_iOSMajor, (int)sys_iOSMinor, (int)sys_iOSBuild);
|
||||
|
||||
#elif (defined PLATFORM_UNIX) // !!! FIXME: rcg10082001 what to do with this?
|
||||
sys_iOSMajor = 1;
|
||||
sys_iOSMinor = 0;
|
||||
sys_iOSBuild = 0;
|
||||
sys_strOS = "Unix";
|
||||
sys_strOSMisc = "Unix";
|
||||
CPrintF(TRANSV(" Type: %s\n"), (const char*)sys_strOS);
|
||||
|
||||
#else
|
||||
#error Do something with this for your platform.
|
||||
#endif
|
||||
|
||||
PlatformIdentification();
|
||||
|
||||
CPrintF("\n");
|
||||
|
||||
|
@ -487,53 +600,14 @@ ENGINE_API void SE_InitEngine(const char *argv0, CTString strGameID)
|
|||
extern void ReportGlobalMemoryStatus(void);
|
||||
ReportGlobalMemoryStatus();
|
||||
|
||||
#if (defined PLATFORM_WIN32) // !!! FIXME: Abstract this somehow.
|
||||
MEMORYSTATUS ms;
|
||||
GlobalMemoryStatus(&ms);
|
||||
|
||||
#define MB (1024*1024)
|
||||
sys_iRAMPhys = ms.dwTotalPhys /MB;
|
||||
sys_iRAMSwap = ms.dwTotalPageFile/MB;
|
||||
|
||||
#elif (defined PLATFORM_UNIX)
|
||||
sys_iRAMPhys = 1; // !!! FIXME: This is bad. Bad. BAD.
|
||||
sys_iRAMSwap = 1;
|
||||
|
||||
#else
|
||||
#error Do something with this for your platform.
|
||||
#endif
|
||||
|
||||
SetupMemoryManager();
|
||||
// initialize zip semaphore
|
||||
zip_csLock.cs_iIndex = -1; // not checked for locking order
|
||||
|
||||
|
||||
// rcg10082001 Honestly, all of this is meaningless in a multitasking OS.
|
||||
// That includes Windows, too.
|
||||
#if (defined PLATFORM_WIN32) // !!! FIXME: Abstract this somehow.
|
||||
// get info on the first disk in system
|
||||
DWORD dwSerial;
|
||||
DWORD dwFreeClusters;
|
||||
DWORD dwClusters;
|
||||
DWORD dwSectors;
|
||||
DWORD dwBytes;
|
||||
|
||||
char strDrive[] = "C:\\";
|
||||
strDrive[0] = strExePath[0];
|
||||
|
||||
GetVolumeInformationA(strDrive, NULL, 0, &dwSerial, NULL, NULL, NULL, 0);
|
||||
GetDiskFreeSpaceA(strDrive, &dwSectors, &dwBytes, &dwFreeClusters, &dwClusters);
|
||||
sys_iHDDSize = ((__int64)dwSectors)*dwBytes*dwClusters/MB;
|
||||
sys_iHDDFree = ((__int64)dwSectors)*dwBytes*dwFreeClusters/MB;
|
||||
sys_iHDDMisc = dwSerial;
|
||||
|
||||
#elif (defined PLATFORM_UNIX) // !!! FIXME: Uhh...?
|
||||
sys_iHDDSize = 1;
|
||||
sys_iHDDFree = 1;
|
||||
sys_iHDDMisc = 0xDEADBEEF;
|
||||
|
||||
#else
|
||||
#error Do something with this for your platform.
|
||||
#endif
|
||||
SetupSecondaryStorage(); /// FIXME: does that name make sense
|
||||
|
||||
// add console variables
|
||||
extern INDEX con_bNoWarnings;
|
||||
|
@ -635,54 +709,13 @@ ENGINE_API void SE_InitEngine(const char *argv0, CTString strGameID)
|
|||
_pfdDisplayFont = NULL;
|
||||
_pfdConsoleFont = NULL;
|
||||
|
||||
// !!! FIXME: Move this into GfxLibrary...
|
||||
#ifdef PLATFORM_WIN32
|
||||
// readout system gamma table
|
||||
HDC hdc = GetDC(NULL);
|
||||
BOOL bOK = GetDeviceGammaRamp( hdc, &auwSystemGamma[0]);
|
||||
_pGfx->gl_ulFlags |= GLF_ADJUSTABLEGAMMA;
|
||||
if( !bOK) {
|
||||
_pGfx->gl_ulFlags &= ~GLF_ADJUSTABLEGAMMA;
|
||||
CPrintF( TRANS("\nWARNING: Gamma, brightness and contrast are not adjustable!\n\n"));
|
||||
} // done
|
||||
ReleaseDC( NULL, hdc);
|
||||
#else
|
||||
// !!! FIXME : rcg01072002 This CAN be done with SDL, actually. Move this somewhere.
|
||||
#ifdef PLATFORM_PANDORA
|
||||
// hacked gamma support
|
||||
_pGfx->gl_ulFlags |= GLF_ADJUSTABLEGAMMA;
|
||||
#else
|
||||
CPrintF( TRANS("\nWARNING: Gamma, brightness and contrast are not adjustable!\n\n"));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// !!! FIXME : rcg12072001 Move this somewhere else.
|
||||
#ifdef PLATFORM_WIN32
|
||||
// init IFeel
|
||||
HWND hwnd = NULL;//GetDesktopWindow();
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
if(IFeel_InitDevice(hInstance,hwnd))
|
||||
{
|
||||
CTString strDefaultProject = "Data\\Default.ifr";
|
||||
// get project file name for this device
|
||||
CTString strIFeel = IFeel_GetProjectFileName();
|
||||
// if no file name is returned use default file
|
||||
if(strIFeel.Length()==0) strIFeel = strDefaultProject;
|
||||
if(!IFeel_LoadFile(strIFeel))
|
||||
{
|
||||
if(strIFeel!=strDefaultProject)
|
||||
{
|
||||
IFeel_LoadFile(strDefaultProject);
|
||||
}
|
||||
}
|
||||
CPrintF("\n");
|
||||
}
|
||||
#endif
|
||||
InitSystemGammaSettings();
|
||||
InitIFeel(); // on non win32 platforms this will be optimized out if we play our cards right
|
||||
}
|
||||
|
||||
|
||||
// shutdown entire engine
|
||||
ENGINE_API void SE_EndEngine(void)
|
||||
|
||||
static void PlatformSpecificDeinit(void)
|
||||
{
|
||||
// !!! FIXME: Move this into GfxLibrary...
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
@ -697,6 +730,12 @@ ENGINE_API void SE_EndEngine(void)
|
|||
// restore default gamma
|
||||
system("sudo /usr/pandora/scripts/op_gamma.sh 0");
|
||||
#endif
|
||||
}
|
||||
|
||||
// shutdown entire engine
|
||||
ENGINE_API void SE_EndEngine(void)
|
||||
{
|
||||
PlatformSpecificDeinit();
|
||||
|
||||
// free stocks
|
||||
delete _pEntityClassStock; _pEntityClassStock = NULL;
|
||||
|
|
|
@ -19,36 +19,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef PLATFORM_WIN32
|
||||
#define PLATFORM_WIN32 1
|
||||
#endif
|
||||
#endif
|
||||
#include <Engine/Base/Base.h>
|
||||
|
||||
// set this to 1 to enable checks whether somethig is deleted while iterating some array/container
|
||||
#define CHECKARRAYLOCKING 0
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <search.h> // for qsort
|
||||
#include <float.h> // for FPU control
|
||||
|
||||
/* rcg10042001 !!! FIXME: Move these somewhere. */
|
||||
#if (defined PLATFORM_WIN32)
|
||||
#include <malloc.h>
|
||||
#include <conio.h>
|
||||
#include <crtdbg.h>
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h> // for timers
|
||||
#endif
|
||||
|
||||
#include <Engine/Base/Base.h>
|
||||
#include <Engine/Base/SystemSpecificInclude.h>
|
||||
|
||||
#include <Engine/Base/Types.h>
|
||||
|
||||
#include <Engine/Base/Input.h>
|
||||
|
|
Loading…
Reference in New Issue
Block a user