/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     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: 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 = new CHardwarePlatformWinTel32();
    }
    return ms_pSingleton;            
}

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

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

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

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

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

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

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

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

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

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

tUINT32 CHardwarePlatformWinTel32::getMemorySize(tUINT32 type)
{
    // 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
}

