/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/src/platform/wintel32/hwplatformwintel32.cpp

*/

#include "sgx/core/core.hpp"
#include "drivers/wintel32/core/core.hpp"
#include "platform/wintel32/hwplatformwintel32.hpp"

CHardwarePlatform *CHardwarePlatformWinTel32::create()
{
    if (ms_pSingleton == NULL) {
		ms_pSingleton = SGX_STATIC_CAST(CHardwarePlatform *, new CHardwarePlatformWinTel32());
 		registerPlatform(ms_pSingleton);
   }
    return ms_pSingleton;            
}

const char *CHardwarePlatformWinTel32::getPlatformName() const 
{
    return "WinTel32 PC"; 
}

const char *CHardwarePlatformWinTel32::getPlatformID() const 
{
    return "wintel32"; 
}

const char *CHardwarePlatformWinTel32::getDocsURL() const 
{
    return "//docs_drive/sdks/pc"; 
}

const char *CHardwarePlatformWinTel32::getDevelopmentURL() const 
{
    return "http://www.microsoft.com"; 
}

tREAL32 CHardwarePlatformWinTel32::getDiscAccessSpeed() const 
{
    return 0.009f; // 9 milliseconds
}

tREAL32 CHardwarePlatformWinTel32::getDiscReadSpeed() const 
{
    // Actual range is affected by too many parameters to make this a usable value
    return 30*SGX_MEGABYTES;
}

CHardwarePlatform::tEndian CHardwarePlatformWinTel32::getEndian() const 
{
    return eLittleEndian;
}

tUINT32 CHardwarePlatformWinTel32::getNumCPUs() const 
{
    SYSTEM_INFO sysinfo;
    GetSystemInfo(&sysinfo);
    return sysinfo.dwNumberOfProcessors;
}

tUINT32 CHardwarePlatformWinTel32::getCPUSpeed(tUINT32 type) const 
{
    return 733; // not a real value! just to make it approximate to the Xbox
}

tUINT32 CHardwarePlatformWinTel32::getNumMemoryBanks() const 
{
    return 1;
}

tUINT32 CHardwarePlatformWinTel32::getMemorySize(tUINT32 type) const 
{
    // We're only concerned with system RAM. If a game
    // intentionally uses the swap we're in trouble!
    sgxAssert(type==0); 
    MEMORYSTATUS meminfo;
    GlobalMemoryStatus(&meminfo);
    return meminfo.dwAvailPhys; // as opposed to dwTotalPhys
}


void	
CHardwarePlatformWinTel32::getVideoResolution(sgxRect2i &rc, const tScreenFormat fmt)  const {
	tScreenFormat screenFormat(fmt);

	if (screenFormat == eDefault) {
		screenFormat = getVideoDefaultFormat();
	}
	rc.top = rc.left = 0;
	rc.right = 640;
	rc.bottom = 480;
}
