diff --git a/SteamworksExample/Main.cpp b/SteamworksExample/Main.cpp index 21e55f9..72cb68a 100644 --- a/SteamworksExample/Main.cpp +++ b/SteamworksExample/Main.cpp @@ -163,8 +163,6 @@ void RunGameLoop( IGameEngine *pGameEngine, const char *pchServerAddress, const //----------------------------------------------------------------------------- // Purpose: Real main entry point for the program //----------------------------------------------------------------------------- -#ifndef _PS3 - static int RealMain( const char *pchCmdLine, HINSTANCE hInstance, int nCmdShow ) { @@ -283,7 +281,6 @@ static int RealMain( const char *pchCmdLine, HINSTANCE hInstance, int nCmdShow ) // exit return EXIT_SUCCESS; } -#endif //----------------------------------------------------------------------------- // Purpose: Main entry point for the program -- win32 diff --git a/SteamworksExample/RemoteStorage.cpp b/SteamworksExample/RemoteStorage.cpp index 33c5346..8164f08 100644 --- a/SteamworksExample/RemoteStorage.cpp +++ b/SteamworksExample/RemoteStorage.cpp @@ -42,10 +42,6 @@ CRemoteStorage::CRemoteStorage( IGameEngine *pGameEngine ) : m_pGameEngine( pGameEngine ), m_pRemoteStorageSync(NULL) { m_pRemoteStorageScreen = new CRemoteStorageScreen( pGameEngine ); - -#ifdef _PS3 - m_pRemoteStorageSync = new CRemoteStorageSync( pGameEngine ); -#endif } diff --git a/SteamworksExample/SpaceWar.h b/SteamworksExample/SpaceWar.h index e3daafe..9800204 100644 --- a/SteamworksExample/SpaceWar.h +++ b/SteamworksExample/SpaceWar.h @@ -116,8 +116,6 @@ inline T QWordSwap( T dw ) return *((T*)&temp); } -#ifndef _PS3 - #define LittleInt16( val ) ( val ) #define LittleWord( val ) ( val ) #define LittleInt32( val ) ( val ) @@ -125,18 +123,6 @@ inline T QWordSwap( T dw ) #define LittleQWord( val ) ( val ) #define LittleFloat( val ) ( val ) -#else - -#define LittleInt16( val ) WordSwap( val ) -#define LittleWord( val ) WordSwap( val ) -#define LittleInt32( val ) DWordSwap( val ) -#define LittleDWord( val ) DWordSwap( val ) -#define LittleQWord( val ) QWordSwap( val ) -#define LittleFloat( val ) DWordSwap( val ) - -#endif - - // Leaderboard names #define LEADERBOARD_QUICKEST_WIN "Quickest Win" #define LEADERBOARD_FEET_TRAVELED "Feet Traveled" diff --git a/SteamworksExample/SpaceWarClient.cpp b/SteamworksExample/SpaceWarClient.cpp index acaad70..206c8c6 100644 --- a/SteamworksExample/SpaceWarClient.cpp +++ b/SteamworksExample/SpaceWarClient.cpp @@ -61,21 +61,12 @@ CSpaceWarClient::CSpaceWarClient( IGameEngine *pGameEngine ) void CSpaceWarClient::Init( IGameEngine *pGameEngine ) { // On PC/OSX we always know the user has a SteamID and is logged in already, - // as Steam enforces this before game launch. On PS3 however the game must - // initiate the logon and we need to check the state here and block the user - // while Steam connects. + // as Steam enforces this before game launch. if ( SteamUser()->BLoggedOn() ) { m_SteamIDLocalUser = SteamUser()->GetSteamID(); m_eGameState = k_EClientGameMenu; } -#ifdef _PS3 - else - { - m_eGameState = k_EClientConnectingToSteam; - SteamUser()->LogOn( true ); - } -#endif g_pSpaceWarClient = this; m_pGameEngine = pGameEngine; @@ -1436,34 +1427,13 @@ void CSpaceWarClient::RunFrame() m_pGameEngine->SetSteamControllerActionSet( eControllerActionSet_MenuControls ); break; case k_EClientRetrySteamConnection: -#ifdef _PS3 - m_pStarField->Render(); - SteamUser()->LogOn( true ); - m_pConnectingMenu->Reset(); - SetGameState( k_EClientConnectingToSteam ); -#else OutputDebugString( "Invalidate state k_EClientRetrySteamConnection hit on non-PS3 platform" ); -#endif break; case k_EClientLinkSteamAccount: -#ifdef _PS3 - m_pStarField->Render(); - SteamUser()->LogOnAndLinkSteamAccountToPSN( true, "jmccaskeybeta", "test123" ); - m_pConnectingMenu->Reset(); - SetGameState( k_EClientConnectingToSteam ); -#else OutputDebugString( "Invalidate state k_EClientLinkSteamAccount hit on non-PS3 platform" ); -#endif break; case k_EClientAutoCreateAccount: -#ifdef _PS3 - m_pStarField->Render(); - m_pConnectingMenu->Reset(); - SteamUser()->LogOnAndCreateNewSteamAccountIfNeeded( true ); - SetGameState( k_EClientConnectingToSteam ); -#else OutputDebugString( "Invalidate state k_EClientAutoCreateAccount hit on non-PS3 platform" ); -#endif break; case k_EClientGameMenu: m_pStarField->Render(); @@ -1722,7 +1692,7 @@ void CSpaceWarClient::RunFrame() if ( !m_bSentWebOpen ) { m_bSentWebOpen = true; -#ifndef _PS3 + char szCurDir[MAX_PATH]; if ( !_getcwd( szCurDir, sizeof(szCurDir) ) ) { @@ -1733,7 +1703,6 @@ void CSpaceWarClient::RunFrame() // load the test html page, it just has a steam://gamewebcallback link in it SteamFriends()->ActivateGameOverlayToWebPage( szURL ); SetGameState( k_EClientGameMenu ); -#endif } break; @@ -1852,16 +1821,8 @@ void CSpaceWarClient::RunFrame() void CSpaceWarClient::DrawHUDText() { // Padding from the edge of the screen for hud elements -#ifdef _PS3 - // Larger padding on PS3, since many of our test HDTVs truncate - // edges of the screen and can't be calibrated properly. - const int32 nHudPaddingVertical = 20; - const int32 nHudPaddingHorizontal = 35; -#else const int32 nHudPaddingVertical = 15; const int32 nHudPaddingHorizontal = 15; -#endif - const int32 width = m_pGameEngine->GetViewportWidth(); const int32 height = m_pGameEngine->GetViewportHeight(); @@ -2026,11 +1987,8 @@ void CSpaceWarClient::DrawInstructions() rect.right = width; char rgchBuffer[256]; -#ifdef _PS3 - sprintf_safe( rgchBuffer, "Turn Ship Left: 'Left'\nTurn Ship Right: 'Right'\nForward Thrusters: 'R2'\nReverse Thrusters: 'L2'\nFire Photon Beams: 'Cross'" ); -#else sprintf_safe( rgchBuffer, "Turn Ship Left: 'A'\nTurn Ship Right: 'D'\nForward Thrusters: 'W'\nReverse Thrusters: 'S'\nFire Photon Beams: 'Space'" ); -#endif + m_pGameEngine->BDrawString( m_hInstructionsFont, rect, D3DCOLOR_ARGB( 255, 25, 200, 25 ), TEXTPOS_CENTER|TEXTPOS_VCENTER, rgchBuffer ); diff --git a/SteamworksExample/StatsAndAchievements.cpp b/SteamworksExample/StatsAndAchievements.cpp index 6f98c80..fb73590 100644 --- a/SteamworksExample/StatsAndAchievements.cpp +++ b/SteamworksExample/StatsAndAchievements.cpp @@ -44,8 +44,7 @@ CStatsAndAchievements::CStatsAndAchievements( IGameEngine *pGameEngine ) m_GameID( SteamUtils()->GetAppID() ), m_CallbackUserStatsReceived( this, &CStatsAndAchievements::OnUserStatsReceived ), m_CallbackUserStatsStored( this, &CStatsAndAchievements::OnUserStatsStored ), - m_CallbackAchievementStored( this, &CStatsAndAchievements::OnAchievementStored ), - m_CallbackPS3TrophiesInstalled( this, &CStatsAndAchievements::OnPS3TrophiesInstalled ) + m_CallbackAchievementStored( this, &CStatsAndAchievements::OnAchievementStored ) { m_pSteamUser = SteamUser(); m_pSteamUserStats = SteamUserStats(); @@ -67,9 +66,6 @@ CStatsAndAchievements::CStatsAndAchievements( IGameEngine *pGameEngine ) m_hDisplayFont = pGameEngine->HCreateFont( ACHDISP_FONT_HEIGHT, FW_MEDIUM, false, "Arial" ); if ( !m_hDisplayFont ) OutputDebugString( "Stats font was not created properly, text won't draw\n" ); - - m_bInstalledPS3Trophies = false; - m_bStartedPS3TrophyInstall = false; } #pragma warning( pop ) @@ -79,31 +75,8 @@ CStatsAndAchievements::CStatsAndAchievements( IGameEngine *pGameEngine ) //----------------------------------------------------------------------------- void CStatsAndAchievements::RunFrame() { - // On PS3, must first install trophies before using the stats system - if ( !m_bInstalledPS3Trophies ) + if ( !m_bRequestedStats ) { -#ifdef _PS3 - // PS3 trophies should be installed before writing to disk. Check PS3TrophiesInstalled_t to determine - // if trophy installation failed because the machine is out of free HD space. - if ( !m_bStartedPS3TrophyInstall ) - { - if ( !m_pSteamUserStats->InstallPS3Trophies() ) - { - OutputDebugString( "Failed to install PS3 trophies. This is a fatal error\n" ); - exit( 1 ); - } - - m_bStartedPS3TrophyInstall = true; - } - - // wait for PS3TrophiesInstalled_t -#else - m_bInstalledPS3Trophies = true; - m_bStartedPS3TrophyInstall = true; -#endif - } - else if ( !m_bRequestedStats ) - { // Is Steam Loaded? if no, can't get stats, done if ( NULL == m_pSteamUserStats || NULL == m_pSteamUser ) { @@ -111,8 +84,6 @@ void CStatsAndAchievements::RunFrame() return; } - LoadUserStatsOnPS3(); - // If yes, request our stats bool bSuccess = m_pSteamUserStats->RequestCurrentStats(); @@ -322,8 +293,6 @@ void CStatsAndAchievements::OnUserStatsReceived( UserStatsReceived_t *pCallback m_pSteamUserStats->GetStat( "FeetTraveled", &m_flTotalFeetTraveled ); m_pSteamUserStats->GetStat( "MaxFeetTraveled", &m_flMaxFeetTraveled ); m_pSteamUserStats->GetStat( "AverageSpeed", &m_flAverageSpeed ); - - SaveUserStatsOnPS3(); } else { @@ -347,7 +316,6 @@ void CStatsAndAchievements::OnUserStatsStored( UserStatsStored_t *pCallback ) if ( k_EResultOK == pCallback->m_eResult ) { OutputDebugString( "StoreStats - success\n" ); - SaveUserStatsOnPS3(); } else if ( k_EResultInvalidParam == pCallback->m_eResult ) { @@ -397,34 +365,6 @@ void CStatsAndAchievements::OnAchievementStored( UserAchievementStored_t *pCallb } -//----------------------------------------------------------------------------- -// Purpose: An achievement was stored -//----------------------------------------------------------------------------- -void CStatsAndAchievements::OnPS3TrophiesInstalled( PS3TrophiesInstalled_t *pCallback ) -{ - // we may get callbacks for other games' stats arriving, ignore them - if ( m_GameID.ToUint64() == pCallback->m_nGameID ) - { - if ( pCallback->m_eResult != k_EResultOK ) - { - // this is a fatal error. Usually the PS3 would have already displayed a fatal error to the user and forced the game to exit. If the system - // could not display that error, you should display the appropriate message to the user then exit. - char buffer[256]; - if ( pCallback->m_eResult == k_EResultDiskFull ) - sprintf_safe( buffer, "Failed to install PS3 trophies because the HD is full (required space=%llu)\n", pCallback->m_ulRequiredDiskSpace ); - else - sprintf_safe( buffer, "Failed to install PS3 trophies (%d)", pCallback->m_eResult ); - - buffer[ sizeof(buffer) - 1 ] = 0; - OutputDebugString( buffer ); - exit( 1 ); - } - - m_bInstalledPS3Trophies = true; - } -} - - //----------------------------------------------------------------------------- // Purpose: Display the user's stats and achievements //----------------------------------------------------------------------------- @@ -631,70 +571,3 @@ void CStatsAndAchievements::DrawInventory( RECT &rect, SteamItemInstanceID_t ite sprintf_safe( rgchBuffer, "%s", pItem->GetLocalizedName().c_str() ); m_pGameEngine->BDrawString( m_hDisplayFont, rect, D3DCOLOR_ARGB( 255, 25, 200, 25 ), TEXTPOS_LEFT|TEXTPOS_VCENTER, rgchBuffer ); } - -bool CStatsAndAchievements::LoadUserStatsOnPS3() -{ -#ifdef _PS3 - // On PS3, we need to load the user's stats & achievement information from the save container. In this example, we are simply - // reading the data from a known location on disk - FILE *file = fopen( GetUserSaveDataPath(), "rb" ); - if ( !file ) - { - // we need to tell Steam that there is no data - SteamUserStats()->SetUserStatsData( NULL, 0 ); - return true; - } - - fseek( file, 0, SEEK_END ); - long nSize = ftell( file ); - fseek( file, 0, SEEK_SET ); - - byte *buffer = new byte[nSize]; - fread( buffer, 1, nSize, file ); - fclose( file ); - - bool bRet = SteamUserStats()->SetUserStatsData( buffer, nSize ); - delete [] buffer; - - return bRet; -#else - return true; -#endif -} - -bool CStatsAndAchievements::SaveUserStatsOnPS3() -{ -#ifdef _PS3 - // On PS3, we need to save the user's stats & achievement information into the save container. In this example, we are simply - // saving the data to a known location on disk - - // get required buffer size - uint32 unSize = 0; - if ( !SteamUserStats()->GetUserStatsData( NULL, 0, &unSize ) && unSize == 0 ) - return false; - - // get data - byte *buffer = new byte[unSize]; - uint32 unWritten = 0; - bool bRet = SteamUserStats()->GetUserStatsData( buffer, unSize, &unWritten ); - if ( bRet ) - { - FILE *file = fopen( GetUserSaveDataPath(), "wb" ); - if ( file ) - { - bRet = (fwrite( buffer, 1, unWritten, file ) == unWritten); - fclose( file ); - } - else - { - bRet = false; - } - } - - delete [] buffer; - - return bRet; -#else - return true; -#endif -} diff --git a/SteamworksExample/StatsAndAchievements.h b/SteamworksExample/StatsAndAchievements.h index 23b370d..45964cb 100644 --- a/SteamworksExample/StatsAndAchievements.h +++ b/SteamworksExample/StatsAndAchievements.h @@ -59,8 +59,7 @@ public: STEAM_CALLBACK( CStatsAndAchievements, OnUserStatsReceived, UserStatsReceived_t, m_CallbackUserStatsReceived ); STEAM_CALLBACK( CStatsAndAchievements, OnUserStatsStored, UserStatsStored_t, m_CallbackUserStatsStored ); STEAM_CALLBACK( CStatsAndAchievements, OnAchievementStored, UserAchievementStored_t, m_CallbackAchievementStored ); - STEAM_CALLBACK( CStatsAndAchievements, OnPS3TrophiesInstalled, PS3TrophiesInstalled_t, m_CallbackPS3TrophiesInstalled ); - + private: @@ -76,10 +75,6 @@ private: void DrawStatInfo( RECT &rect, const char *pchName, float flValue ); void DrawInventory( RECT &rect, SteamItemInstanceID_t itemid ); - // PS3 specific - bool LoadUserStatsOnPS3(); - bool SaveUserStatsOnPS3(); - // our GameID CGameID m_GameID; @@ -114,10 +109,6 @@ private: float m_flTotalFeetTraveled; float m_flMaxFeetTraveled; float m_flAverageSpeed; - - // PS3 specific - bool m_bStartedPS3TrophyInstall; - bool m_bInstalledPS3Trophies; }; #endif // STATS_AND_ACHIEVEMENTS_H \ No newline at end of file diff --git a/SteamworksExample/stdafx.h b/SteamworksExample/stdafx.h index 8ea8d3e..93582af 100644 --- a/SteamworksExample/stdafx.h +++ b/SteamworksExample/stdafx.h @@ -85,12 +85,8 @@ typedef unsigned __int64 uint64; #include #include - #if defined(_PS3) + #if defined(OSX) - #include "stdafx_ps3.h" - - #elif defined(OSX) - #include #endif diff --git a/public/steam/isteammatchmaking.h b/public/steam/isteammatchmaking.h index 12189c7..e150172 100644 --- a/public/steam/isteammatchmaking.h +++ b/public/steam/isteammatchmaking.h @@ -249,13 +249,6 @@ public: // link two lobbies for the purposes of checking player compatibility // you must be the lobby owner of both lobbies virtual bool SetLinkedLobby( CSteamID steamIDLobby, CSteamID steamIDLobbyDependent ) = 0; - -#ifdef _PS3 - // changes who the lobby owner is - // you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby - // after completion, the local user will no longer be the owner - virtual void CheckForPSNGameBootInvite( unsigned int iGameBootAttributes ) = 0; -#endif }; #define STEAMMATCHMAKING_INTERFACE_VERSION "SteamMatchMaking009" diff --git a/public/steam/isteamps3overlayrenderer.h b/public/steam/isteamps3overlayrenderer.h deleted file mode 100644 index 4e07d4a..0000000 --- a/public/steam/isteamps3overlayrenderer.h +++ /dev/null @@ -1,91 +0,0 @@ -//====== Copyright © 1996-2010, Valve Corporation, All rights reserved. ======= -// -// Purpose: interface the game must provide Steam with on PS3 in order for the -// Steam overlay to render. -// -//============================================================================= - -#ifndef ISTEAMPS3OVERLAYRENDERER_H -#define ISTEAMPS3OVERLAYRENDERER_H -#ifdef _WIN32 -#pragma once -#endif - -#include "cell/pad.h" - -//----------------------------------------------------------------------------- -// Purpose: Enum for supported gradient directions -//----------------------------------------------------------------------------- -enum EOverlayGradientDirection -{ - k_EOverlayGradientHorizontal = 1, - k_EOverlayGradientVertical = 2, - k_EOverlayGradientNone = 3, -}; - -// Helpers for fetching individual color components from ARGB packed DWORD colors Steam PS3 overlay renderer uses. -#define STEAM_COLOR_RED( color ) \ - (int)(((color)>>16)&0xff) - -#define STEAM_COLOR_GREEN( color ) \ - (int)(((color)>>8)&0xff) - -#define STEAM_COLOR_BLUE( color ) \ - (int)((color)&0xff) - -#define STEAM_COLOR_ALPHA( color ) \ - (int)(((color)>>24)&0xff) - - -//----------------------------------------------------------------------------- -// Purpose: Interface the game must expose to Steam for rendering -//----------------------------------------------------------------------------- -class ISteamPS3OverlayRenderHost -{ -public: - - // Interface for game engine to implement which Steam requires to render. - - // Draw a textured rect. This may use only part of the texture and will pass texture coords, it will also possibly request a gradient and will specify colors for vertexes. - virtual void DrawTexturedRect( int x0, int y0, int x1, int y1, float u0, float v0, float u1, float v1, int32 iTextureID, DWORD colorStart, DWORD colorEnd, EOverlayGradientDirection eDirection ) = 0; - - // Load a RGBA texture for Steam, or update a previously loaded one. Updates may be partial. You must not evict or remove this texture once Steam has uploaded it. - virtual void LoadOrUpdateTexture( int32 iTextureID, bool bIsFullTexture, int x0, int y0, uint32 uWidth, uint32 uHeight, int32 iBytes, char *pData ) = 0; - - // Delete a texture Steam previously uploaded - virtual void DeleteTexture( int32 iTextureID ) = 0; - - // Delete all previously uploaded textures - virtual void DeleteAllTextures() = 0; -}; - - -//----------------------------------------------------------------------------- -// Purpose: Interface Steam exposes for the game to tell it when to render, etc. -//----------------------------------------------------------------------------- -class ISteamPS3OverlayRender -{ -public: - - // Call once at startup to initialize the Steam overlay and pass it your host interface ptr - virtual bool BHostInitialize( uint32 unScreenWidth, uint32 unScreenHeight, uint32 unRefreshRate, ISteamPS3OverlayRenderHost *pRenderHost, void *CellFontLib ) = 0; - - // Call this once a frame when you are ready for the Steam overlay to render (ie, right before flipping buffers, after all your rendering) - virtual void Render() = 0; - - // Call this everytime you read input on PS3. - // - // If this returns true, then the overlay is active and has consumed the input, your game - // should then ignore all the input until BHandleCellPadData once again returns false, which - // will mean the overlay is deactivated. - virtual bool BHandleCellPadData( const CellPadData &padData ) = 0; - - // Call this if you detect no controllers connected or that the XMB is intercepting input - // - // This is important to clear input state for the overlay, so keys left down during XMB activation - // are not continued to be processed. - virtual bool BResetInputState() = 0; -}; - - -#endif // ISTEAMPS3OVERLAYRENDERER_H \ No newline at end of file diff --git a/public/steam/isteamuserstats.h b/public/steam/isteamuserstats.h index 8bb0c90..ab39ba8 100644 --- a/public/steam/isteamuserstats.h +++ b/public/steam/isteamuserstats.h @@ -457,19 +457,6 @@ struct LeaderboardUGCSet_t }; -//----------------------------------------------------------------------------- -// Purpose: callback indicating that PS3 trophies have been installed -//----------------------------------------------------------------------------- -struct PS3TrophiesInstalled_t -{ - enum { k_iCallback = k_iSteamUserStatsCallbacks + 12 }; - uint64 m_nGameID; // Game these stats are for - EResult m_eResult; // The result of the operation - uint64 m_ulRequiredDiskSpace; // If m_eResult is k_EResultDiskFull, will contain the amount of space needed to install trophies - -}; - - //----------------------------------------------------------------------------- // Purpose: callback indicating global stats have been received. // Returned as a result of RequestGlobalStats() diff --git a/public/steam/steam_api_internal.h b/public/steam/steam_api_internal.h index fcebd7b..15b02c8 100644 --- a/public/steam/steam_api_internal.h +++ b/public/steam/steam_api_internal.h @@ -230,7 +230,6 @@ class ISteamScreenshots; class ISteamMusic; class ISteamMusicRemote; class ISteamGameServerStats; -class ISteamPS3OverlayRender; class ISteamHTTP; class ISteamController; class ISteamUGC; diff --git a/public/steam/steamps3params.h b/public/steam/steamps3params.h deleted file mode 100644 index c0741b4..0000000 --- a/public/steam/steamps3params.h +++ /dev/null @@ -1,112 +0,0 @@ -//====== Copyright 1996-2008, Valve Corporation, All rights reserved. ======= -// -// Purpose: -// -//============================================================================= - -#ifndef STEAMPS3PARAMS_H -#define STEAMPS3PARAMS_H -#ifdef _WIN32 -#pragma once -#endif - -//----------------------------------------------------------------------------------------------------------------------------------------------------------// -// PlayStation 3 initialization parameters -// -// The following structure must be passed to when loading steam_api_ps3.prx -//----------------------------------------------------------------------------------------------------------------------------------------------------------// -#define STEAM_PS3_PATH_MAX 1055 -#define STEAM_PS3_SERVICE_ID_MAX 32 -#define STEAM_PS3_COMMUNICATION_ID_MAX 10 -#define STEAM_PS3_COMMUNICATION_SIG_MAX 160 -#define STEAM_PS3_LANGUAGE_MAX 64 -#define STEAM_PS3_REGION_CODE_MAX 16 -#define STEAM_PS3_CURRENT_PARAMS_VER 2 -struct SteamPS3Params_t -{ - uint32 m_unVersion; // set to STEAM_PS3_CURRENT_PARAMS_VER - - void *pReserved; - uint32 m_nAppId; // set to your game's appid - - char m_rgchInstallationPath[ STEAM_PS3_PATH_MAX ]; // directory containing latest steam prx's and sdata. Can be read only (BDVD) - char m_rgchSystemCache[ STEAM_PS3_PATH_MAX ]; // temp working cache, not persistent - char m_rgchGameData[ STEAM_PS3_PATH_MAX ]; // persistent game data path for storing user data - char m_rgchNpServiceID[ STEAM_PS3_SERVICE_ID_MAX ]; - char m_rgchNpCommunicationID[ STEAM_PS3_COMMUNICATION_ID_MAX ]; - char m_rgchNpCommunicationSig[ STEAM_PS3_COMMUNICATION_SIG_MAX ]; - - // Language should be one of the following. must be zero terminated - // danish - // dutch - // english - // finnish - // french - // german - // italian - // korean - // norwegian - // polish - // portuguese - // russian - // schinese - // spanish - // swedish - // tchinese - char m_rgchSteamLanguage[ STEAM_PS3_LANGUAGE_MAX ]; - - // region codes are "SCEA", "SCEE", "SCEJ". must be zero terminated - char m_rgchRegionCode[ STEAM_PS3_REGION_CODE_MAX ]; - - // Should be SYS_TTYP3 through SYS_TTYP10, if it's 0 then Steam won't spawn a - // thread to read console input at all. Using this let's you use Steam console commands - // like: profile_on, profile_off, profile_dump, mem_stats, mem_validate. - unsigned int m_cSteamInputTTY; - - struct Ps3netInit_t - { - bool m_bNeedInit; - void *m_pMemory; - int m_nMemorySize; - int m_flags; - } m_sysNetInitInfo; - - struct Ps3jpgInit_t - { - bool m_bNeedInit; - } m_sysJpgInitInfo; - - struct Ps3pngInit_t - { - bool m_bNeedInit; - } m_sysPngInitInfo; - - struct Ps3sysutilUserInfo_t - { - bool m_bNeedInit; - } m_sysSysUtilUserInfo; - - bool m_bIncludeNewsPage; -}; - - -//----------------------------------------------------------------------------------------------------------------------------------------------------------// -// PlayStation 3 memory structure -//----------------------------------------------------------------------------------------------------------------------------------------------------------// -#define STEAMPS3_MALLOC_INUSE 0x53D04A51 -#define STEAMPS3_MALLOC_SYSTEM 0x0D102C48 -#define STEAMPS3_MALLOC_OK 0xFFD04A51 -struct SteamPS3Memory_t -{ - bool m_bSingleAllocation; // If true, Steam will request one 6MB allocation and use the returned memory for all future allocations - // If false, Steam will make call malloc for each allocation - - // required function pointers - void* (*m_pfMalloc)(size_t); - void* (*m_pfRealloc)(void *, size_t); - void (*m_pfFree)(void *); - size_t (*m_pUsable_size)(void*); -}; - - -#endif // STEAMPS3PARAMS_H diff --git a/public/steam/steamtypes.h b/public/steam/steamtypes.h index 7b60434..456b833 100644 --- a/public/steam/steamtypes.h +++ b/public/steam/steamtypes.h @@ -29,10 +29,6 @@ typedef unsigned char uint8; #endif #if !defined(VALVE_BIG_ENDIAN) -#if defined(_PS3) -// Make sure VALVE_BIG_ENDIAN gets set on PS3, may already be set previously in Valve internal code. -#define VALVE_BIG_ENDIAN 1 -#endif #if defined( __GNUC__ ) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define VALVE_BIG_ENDIAN 1 #endif diff --git a/steamworksexample/gameengineps3.cpp b/steamworksexample/gameengineps3.cpp deleted file mode 100644 index c30fffc..0000000 --- a/steamworksexample/gameengineps3.cpp +++ /dev/null @@ -1,1840 +0,0 @@ -//========= Copyright © 1996-2008, Valve LLC, All rights reserved. ============ -// -// Purpose: Main class for the game engine -- win32 implementation -// -// $NoKeywords: $ -//============================================================================= - -#include "stdafx.h" -#include "steam/isteamps3overlayrenderer.h" -#include "GameEnginePS3.h" -#include "steam/steamps3params_internal.h" -#include -#include -#include -#include -#include - - -#define DebuggerBreak() { __asm volatile ("tw 31,1,1"); } - -// Allocate static member -std::map CGameEnginePS3::m_MapEngineInstances; - -// How big is the vertex buffer for batching lines in total? -#define LINE_BUFFER_TOTAL_SIZE 1000 - -// How big is the vertex buffer for batching points in total? -#define POINT_BUFFER_TOTAL_SIZE 1800 - -// How big is the vertex buffer for batching quads in total? -#define QUAD_BUFFER_TOTAL_SIZE 1000 - -// Only a single global console can be setup for output, track that here -CellDbgFontConsoleId g_DbgFontConsoleID = -1; - -// Global for PS3 params -SteamPS3Params_t g_SteamPS3Params; - -void RunGameLoop( IGameEngine *pGameEngine, const char *pchServerAddress, const char *pchLobbyID ); -extern "C" void __cdecl SteamAPIDebugTextHook( int nSeverity, const char *pchDebugText ); - -void OutputDebugString( const char *pchMsg ) -{ -#ifndef _CERT - fprintf( stderr, "%s", pchMsg ); - cellDbgFontConsolePrintf( g_DbgFontConsoleID, "%s", pchMsg ); -#endif -} - -// taken from sample -static const char s_npCommunicationSignature[STEAM_PS3_COMMUNICATION_SIG_MAX] = { - 0xb9,0xdd,0xe1,0x3b,0x01,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x1d,0x3c,0x55,0x0f, - 0x35,0xb5,0x54,0xfe,0x4e,0x97,0x1a,0x01, - 0x23,0x38,0xaa,0xd6,0x3d,0xda,0x6a,0xac, - 0x3e,0x95,0xff,0x09,0x49,0xd7,0xb3,0xda, - 0x11,0xae,0xf0,0xde,0xd6,0x2b,0x70,0x96, - 0x40,0x09,0x0e,0xed,0x8c,0x38,0x1d,0xa4, - 0xc3,0x0e,0xc9,0x30,0xc1,0xcc,0x66,0x92, - 0xd1,0xb0,0x6e,0x01,0xc0,0x44,0xb2,0xa2, - 0xd0,0x62,0x88,0xa8,0x26,0x7f,0x91,0xb5, - 0x7b,0x40,0x0c,0x6a,0xc9,0x3b,0x5c,0x89, - 0x43,0x22,0x16,0x4e,0x27,0x56,0x46,0x4a, - 0x63,0xc4,0x55,0xce,0xb3,0xce,0xf7,0x92, - 0x07,0x71,0x13,0x60,0x6e,0xcb,0xad,0xd5, - 0xf0,0x60,0xd6,0x71,0x3a,0x45,0xaa,0x25, - 0x38,0x60,0x11,0x1a,0xa5,0x0e,0xcf,0xa4, - 0x21,0xc8,0x94,0x6d,0xf2,0x0d,0xac,0xcf, - 0x67,0x8d,0x4a,0x14,0x14,0x4e,0xed,0x45, - 0x67,0x40,0x60,0x93,0x2b,0x00,0xeb,0xb7, - 0xf3,0x2f,0x09,0x36,0xb6,0x59,0x84,0x0e - }; - -//----------------------------------------------------------------------------- -// Purpose: Loads the Steam PS3 module -//----------------------------------------------------------------------------- -sys_prx_id_t g_sys_prx_id_steam = -1; -static bool LoadSteamPS3Module() -{ - g_sys_prx_id_steam = sys_prx_load_module( SYS_APP_HOME "/steam_api_ps3.sprx", 0, NULL ); - if ( g_sys_prx_id_steam < CELL_OK ) - { - OutputDebugString( "LoadSteamModule() - failed to load steam_api_ps3\n" ); - return false; - } - - int modres; - int res = sys_prx_start_module( g_sys_prx_id_steam, 0, NULL, &modres, 0, NULL); - if ( res < CELL_OK ) - { - OutputDebugString( "LoadSteamModule() - failed to start steam_api_ps3\n" ); - return false; - } - return true; -} - -//----------------------------------------------------------------------------- -// Purpose: Unloads the Steam PS3 module -//----------------------------------------------------------------------------- -static bool UnloadSteamPS3Module() -{ - // check if loaded - if ( g_sys_prx_id_steam < CELL_OK ) - return false; - - int modres; - int res = sys_prx_stop_module( g_sys_prx_id_steam, 0, NULL, &modres, 0, NULL); - if ( res < CELL_OK ) - { - OutputDebugString( "LoadSteamModule() - failed to stop steam_api_ps3\n" ); - return false; - } - - res = sys_prx_unload_module( g_sys_prx_id_steam, 0, NULL ); - if ( res < CELL_OK ) - { - OutputDebugString( "LoadSteamModule() - failed to unload steam_api_ps3\n" ); - return false; - } - - g_sys_prx_id_steam = -1; - return true; -} - - -//----------------------------------------------------------------------------- -// Purpose: Initializes Steam PS3 params for our application -// This is very similar to CPs3ContentPathInfo::Init -//----------------------------------------------------------------------------- -SteamPS3ParamsInternal_t g_steamPS3ParamsInternal = { STEAM_PS3_PARAMS_INTERNAL_VERSION, k_EUniverseBeta, "", true }; -bool SetSteamPS3Params( SteamPS3Params_t *pParams ) -{ - char bootdir[CELL_GAME_DIRNAME_SIZE] = { 0 }; - char gameHDDataPath[CELL_GAME_DIRNAME_SIZE]; - char gameTitle[CELL_GAME_SYSP_TITLE_SIZE]; - char gameTitleID[CELL_GAME_SYSP_TITLEID_SIZE]; // CELL_GAME_PARAMID_TITLE_ID - char gameAppVer[CELL_GAME_SYSP_VERSION_SIZE]; // CELL_GAME_PARAMID_APP_VER - char gameContentPath[CELL_GAME_PATH_MAX]; // as returned by contentPermit but usually meaningless (?) - char gameBasePath[CELL_GAME_PATH_MAX]; - - unsigned int nBootType = 0; /// either CELL_GAME_GAMETYPE_DISC or CELL_GAME_GAMETYPE_HDD - unsigned int nBootAttribs = 0; /// some combination of attribute masks -- see .cpp for details - - CellSysCacheParam sysCacheParams; - memset( &sysCacheParams, 0, sizeof( CellSysCacheParam ) ); - - CellGameContentSize size; - memset(&size, 0, sizeof(CellGameContentSize)); - - - ///////////////////////////////////////////////////////////////////////// - // - // load sysutil GAME - // - ////////////////////////////////////////////////////////////////////////// - - // we'll need to haul libsysutil into memory ( CELL_SYSMODULE_SYSUTIL_GAME ) - bool bSysModuleIsLoaded = cellSysmoduleIsLoaded( CELL_SYSMODULE_SYSUTIL_GAME ) == CELL_SYSMODULE_LOADED ; - // if this assert trips, then: - // 1) look at where the sysutil_game module is loaded to make sure it still needs to be loaded at this point (maybe you can dump it to save memory) - // 2) if it's being taken care of somewhere else, we don't need to load the module here. - if ( !bSysModuleIsLoaded ) - { - // SYSUTIL_GAME module not loaded yet - if ( CELL_OK != cellSysmoduleLoadModule( CELL_SYSMODULE_SYSUTIL_GAME ) ) - return false; - } - - // get the base to the content directory. - bool bSuccess = CELL_GAME_RET_OK == cellGameBootCheck( &nBootType, &nBootAttribs, &size, bootdir ); - - if ( bSuccess ) - { - - bSuccess &= CELL_GAME_RET_OK == cellGameGetParamString( CELL_GAME_PARAMID_TITLE, gameTitle, sizeof( gameTitle ) ); - bSuccess &= CELL_GAME_RET_OK == cellGameGetParamString( CELL_GAME_PARAMID_TITLE_ID, gameTitleID, sizeof( gameTitleID ) ); - bSuccess &= CELL_GAME_RET_OK == cellGameGetParamString( CELL_GAME_PARAMID_APP_VER, gameAppVer, sizeof( gameAppVer ) ); - } - - if ( bSuccess ) - { - bSuccess = CELL_GAME_RET_OK == cellGameContentPermit( gameContentPath, gameBasePath ) ; - } - - if ( bSuccess ) - { - // Get the game data directory on the hard disk. - memset(&size, 0, sizeof(CellGameContentSize)); - const int ret = cellGameDataCheck( CELL_GAME_GAMETYPE_GAMEDATA, gameTitleID, &size ); - if ( ret == CELL_GAME_RET_NONE ) - { - // create game directory for the first time - CellGameSetInitParams init; memset( &init, 0, sizeof( init ) ); - memcpy( init.title, gameTitle, sizeof( gameTitle ) ); - memcpy( init.titleId, gameTitleID, sizeof( gameTitleID ) ); - memcpy( init.version, gameAppVer, sizeof( gameAppVer ) ); - - char tmp_contentInfoPath[CELL_GAME_PATH_MAX] = {0}; - char tmp_usrdirPath[CELL_GAME_PATH_MAX] = {0}; - - bSuccess = CELL_GAME_RET_OK == cellGameCreateGameData( &init, tmp_contentInfoPath, tmp_usrdirPath ); - } - else if ( ret != CELL_GAME_RET_OK ) - { - // failure - bSuccess = false; - } - } - - if ( bSuccess ) - { - char contentInfoPath[256]; - bSuccess = CELL_GAME_RET_OK == cellGameContentPermit( contentInfoPath, gameHDDataPath ); - } - - if ( bSuccess ) - { - // Steam needs the system cache path. Passing an empty string so it is always cleared for testing - // memcpy( sysCacheParams.cacheId, gameTitleID, sizeof( gameTitleID ) ); - sysCacheParams.cacheId[0] = '\0'; - - const int ret = cellSysCacheMount( &sysCacheParams ); - bSuccess = ( ret == CELL_SYSCACHE_RET_OK_CLEARED ) || ( ret == CELL_SYSCACHE_RET_OK_RELAYED ); - } - - if ( !bSysModuleIsLoaded ) - { - // actually this means it wasn't loaded when we got into the function. unload again - cellSysmoduleUnloadModule( CELL_SYSMODULE_SYSUTIL_GAME ); - } - - if ( bSuccess ) - { - // Internal params, not used by public games. - pParams->pReserved = &g_steamPS3ParamsInternal; - - // configure the Steamworks PS3 parameters. All params need to be set. - pParams->m_nAppId = 480; - - pParams->m_cSteamInputTTY = SYS_TTYP3; - - strncpy( pParams->m_rgchNpServiceID, "UD0031-NPXX00848_00", STEAM_PS3_SERVICE_ID_MAX ); - strncpy( pParams->m_rgchNpCommunicationID, "NPXS00022", STEAM_PS3_COMMUNICATION_ID_MAX ); - memcpy( pParams->m_rgchNpCommunicationSig, s_npCommunicationSignature, STEAM_PS3_COMMUNICATION_SIG_MAX ); - strncpy( pParams->m_rgchInstallationPath, SYS_APP_HOME, STEAM_PS3_PATH_MAX ); - strncpy( pParams->m_rgchSystemCache, sysCacheParams.getCachePath, STEAM_PS3_PATH_MAX ); - strncpy( pParams->m_rgchGameData, gameHDDataPath, STEAM_PS3_PATH_MAX ); - strncpy( pParams->m_rgchSteamLanguage, "english", STEAM_PS3_LANGUAGE_MAX ); - strncpy( pParams->m_rgchRegionCode, "SCEA", STEAM_PS3_REGION_CODE_MAX ); - - pParams->m_sysNetInitInfo.m_bNeedInit = true; // default network initialization - pParams->m_sysJpgInitInfo.m_bNeedInit = true; - pParams->m_sysSysUtilUserInfo.m_bNeedInit = true; - pParams->m_sysPngInitInfo.m_bNeedInit = true; - } - - return bSuccess; -} - - -//----------------------------------------------------------------------------- -// Purpose: Path to save user data -//----------------------------------------------------------------------------- -static char g_rgchUserDataPath[CELL_GAME_PATH_MAX] = {0}; -bool SetUserSaveDataPath() -{ - // On PS3, we need to save the user's stats & achievement information into the save container. In this example, we are simply - // saving the data to a known location on disk. - - // To get a unique path per user, include the local user id in the file name - - // need the user info module - if ( cellSysmoduleLoadModule( CELL_SYSMODULE_SYSUTIL_USERINFO ) != CELL_OK ) - return false; - - // get local id - CellSysutilUserId unLocalUserID; - if ( cellUserInfoGetList( NULL, NULL, &unLocalUserID ) != CELL_USERINFO_RET_OK ) - return false; - - // can now unload the module - cellSysmoduleUnloadModule( CELL_SYSMODULE_SYSUTIL_USERINFO ); - - // save to the game directory - if ( snprintf( g_rgchUserDataPath, sizeof( g_rgchUserDataPath ), "%s/%u_stats.bin", g_SteamPS3Params.m_rgchGameData, unLocalUserID ) > sizeof( g_rgchUserDataPath ) - 1 ) - return false; - - return true; -} - -const char *GetUserSaveDataPath() -{ - return g_rgchUserDataPath; -} - - -//----------------------------------------------------------------------------- -// Purpose: Main entry point for the program -- ps3 -//----------------------------------------------------------------------------- -int main( int argc, char *argv[] ) -{ -#ifdef PS3_MTT_DEBUG - mttLogInit( "/app_home/libmtt_log.txt" ); -#endif - OutputDebugString( "PS3 main\n" ); - - // Initialize 6 SPUs but reserve 1 SPU as a raw SPU for PSGL - sys_spu_initialize(6, 1); - - // Load Steam - if ( !LoadSteamPS3Module() ) - return EXIT_FAILURE; - - // Construct a new instance of the game engine - // bugbug jmccaskey - make screen resolution dynamic, maybe take it on command line? - CGameEnginePS3 *pGameEngine = new CGameEnginePS3(); - - // No restart app if necessary, or CEG initialization on PS3 - - // Initialize SteamAPI, if this fails we bail out since we depend on Steam for lots of stuff. - // You don't necessarily have to though if you write your code to check whether all the Steam - // interfaces are NULL before using them and provide alternate paths when they are unavailable. - - if ( !SetSteamPS3Params( &g_SteamPS3Params ) ) - { - OutputDebugString( "SetSteamPS3Params() failed\n" ); - return EXIT_FAILURE; - } - - // do before SteamAPI_Init(), so we can load and unload the userinfo module (we will tell Steam it isn't loaded) - if ( !SetUserSaveDataPath() ) - { - OutputDebugString( "SetUserSaveDataPath() failed\n" ); - return EXIT_FAILURE; - } - - if ( !SteamAPI_Init( &g_SteamPS3Params ) ) - { - OutputDebugString( "SteamAPI_Init() failed\n" ); - return EXIT_FAILURE; - } - - // set our debug handler - SteamClient()->SetWarningMessageHook( &SteamAPIDebugTextHook ); - - // set text for Steam to use for PSN game invites - SteamUtils()->SetPSNGameBootInviteStrings( "Spacewar Invite", "You've been invited to join a Spacewar lobby!" ); - - // Setup overlay render interface for PS3 Steam overlay - SteamPS3OverlayRender()->BHostInitialize( pGameEngine->GetViewportWidth(), pGameEngine->GetViewportHeight(), 60, pGameEngine, NULL ); - - // No +connect support on PS3 since Steam isn't launching us, but we check for PSN boot invites, and this may postback a lobby join - // requested callback to us. - - // bugbug jmccaskey - MUST call cellGameBootCheck() to get attributes param to pass here! - SteamMatchmaking()->CheckForPSNGameBootInvite( 0 ); - - // This call will block and run until the game exits - RunGameLoop( pGameEngine, NULL, NULL ); - -#ifdef PS3_MTT_DEBUG - mttLogShutdown(); -#endif - - // Shutdown the SteamAPI - SteamAPI_Shutdown(); - - // Unload Steam - UnloadSteamPS3Module(); - - // exit - return 0; -} - -//----------------------------------------------------------------------------- -// Purpose: PS3 callback handler -//----------------------------------------------------------------------------- -static void PS3SysutilCallback( uint64_t status, uint64_t param, void* userdata ) -{ - (void) param; - - CGameEnginePS3 *pGameEngine = CGameEnginePS3::FindEngineInstanceForPtr( userdata ); - - switch( status ) - { - case CELL_SYSUTIL_REQUEST_EXITGAME: - pGameEngine->Shutdown(); - break; - case CELL_SYSUTIL_DRAWING_BEGIN: - case CELL_SYSUTIL_DRAWING_END: - break; - case CELL_SYSUTIL_SYSTEM_MENU_OPEN: - OutputDebugString( "System menu opened!\n" ); - break; - case CELL_SYSUTIL_SYSTEM_MENU_CLOSE: - OutputDebugString( "System menu closed!\n" ); - break; - default: - // Ok that we don't know them all, Steam handles some that we don't know. - //OutputDebugString( "PS3SysutilCallback: Unknown status received\n" ); - break; - } - - // Must call this to pass along to Steam which may need async status provided by these - // callbacks as well. - SteamUtils()->PostPS3SysutilCallback( status, param, userdata ); -} - -struct PacketQueue_t -{ - uint32 unSize; - void *pData; - uint32 unWritten; - PacketQueue_t *pNext; -}; - -class CVoiceContext -{ -public: - CVoiceContext() - { - m_PortIdInput = 0; - m_PortIdOutput = 0; - m_pQueue = NULL; - } - virtual ~CVoiceContext() - { - // - } - - uint32_t m_PortIdInput; - uint32_t m_PortIdOutput; - PacketQueue_t *m_pQueue; - -}; - - -//----------------------------------------------------------------------------- -// Purpose: Constructor for game engine instance -//----------------------------------------------------------------------------- -CGameEnginePS3::CGameEnginePS3() -{ - m_bEngineReadyForUse = false; - m_bShuttingDown = false; - m_nWindowWidth = 0; - m_nWindowHeight = 0; - m_ulPreviousGameTickCount = 0; - m_ulGameTickCount = 0; - m_hTextureWhite = 0; - m_pPSGLContext = NULL; - m_pPSGLDevice = NULL; - m_DbgFontConsoleID = -1; - m_nNextFontHandle = 1; - m_nNextTextureHandle = 1; - m_hLastTexture = 0; - - m_rgflPointsData = new GLfloat[ 3*POINT_BUFFER_TOTAL_SIZE ]; - m_rgflPointsColorData = new GLubyte[ 4*POINT_BUFFER_TOTAL_SIZE ]; - m_dwPointsToFlush = 0; - - m_rgflLinesData = new GLfloat[ 6*LINE_BUFFER_TOTAL_SIZE ]; - m_rgflLinesColorData = new GLubyte[ 8*LINE_BUFFER_TOTAL_SIZE ]; - m_dwLinesToFlush = 0; - - m_rgflQuadsData = new GLfloat [ 12*QUAD_BUFFER_TOTAL_SIZE ]; - m_rgflQuadsColorData = new GLubyte[ 16*QUAD_BUFFER_TOTAL_SIZE ]; - m_rgflQuadsTextureData = new GLfloat[ 8*QUAD_BUFFER_TOTAL_SIZE ]; - m_dwQuadsToFlush = 0; - m_unVoiceChannelCount = 0; - - - CGameEnginePS3::AddInstanceToPtrMap( this ); - - // Setup timing data - m_ulGameTickCount = cell::fios::FIOSAbstimeToMilliseconds( cell::fios::FIOSGetCurrentTime() ); - - // Register sysutil exit callback - int ret = cellSysutilRegisterCallback( 0, PS3SysutilCallback, this ); - if( ret != CELL_OK ) - { - OutputDebugString( "!! Registering sysutil callback failed...\n" ); - return; - } - - if( !BInitializePSGL() ) - { - OutputDebugString( "!! Initializing PSGL failed\n" ); - return; - } - - if( !BInitializeCellDbgFont() ) - { - OutputDebugString( "!! Initializing CellDbgFont failed\n" ); - return; - } - - if ( !BInitializeLibPad() ) - { - OutputDebugString( "!! Initializing libpad failed\n" ); - return; - } - - if ( !BInitializeAudio() ) - { - OutputDebugString( "!! Initializing audio failed\n" ); - return; - } - - m_bEngineReadyForUse = true; -} - - -//----------------------------------------------------------------------------- -// Purpose: Shutdown the game engine -//----------------------------------------------------------------------------- -void CGameEnginePS3::Shutdown() -{ - // Flag that we are shutting down so the frame loop will stop running - m_bShuttingDown = true; - - // Shutdown dbg font library - if ( m_DbgFontConsoleID >= 0 ) - { - cellDbgFontConsoleClose( m_DbgFontConsoleID ); - cellDbgFontExit(); - } - - // Should be safe to call even if we didn't actually init. - cellPadEnd(); - - // PS3 docs say it's best not to call this and allow the os/vshell to handle it instead to avoid brief noise - // in the video display - - if ( m_rgflPointsData ) - { - delete[] m_rgflPointsData; - m_rgflPointsData = NULL; - } - - if ( m_rgflPointsColorData ) - { - delete[] m_rgflPointsColorData; - m_rgflPointsColorData = NULL; - } - - if ( m_rgflLinesData ) - { - delete[] m_rgflLinesData; - m_rgflLinesData = NULL; - } - - if ( m_rgflLinesColorData ) - { - delete[] m_rgflLinesColorData; - m_rgflLinesColorData = NULL; - } - - if ( m_rgflQuadsData ) - { - delete[] m_rgflQuadsData; - m_rgflQuadsData = NULL; - } - - if ( m_rgflQuadsColorData ) - { - delete[] m_rgflQuadsColorData; - m_rgflQuadsColorData = NULL; - } - - if ( m_rgflQuadsTextureData ) - { - delete[] m_rgflQuadsTextureData; - m_rgflQuadsTextureData = NULL; - } - - m_dwLinesToFlush = 0; - m_dwPointsToFlush = 0; - m_dwQuadsToFlush = 0; - - /* - - // PS3 docs say it's best not to call this and allow the os/vshell to handle it instead to avoid brief noise - // in the video display. Should we not do this then? - // - // bugbug jmccaskey - don't do this? - if ( m_pPSGLDevice ) - { - psglMakeCurrent( NULL, m_pPSGLDevice ); - if ( m_pPSGLContext ) - { - psglDestroyContext( m_pPSGLContext ); - m_pPSGLContext = NULL; - } - - psglDestroyDevice( m_pPSGLDevice ); - m_pPSGLDevice = NULL; - } - - psglExit(); - - */ -} - - -//----------------------------------------------------------------------------- -// Purpose: Initialize voice/audio interfaces -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BInitializeAudio() -{ - int ret = cellSysmoduleLoadModule(CELL_SYSMODULE_VOICE); - if ( ret < 0 ) - return false; - - CellVoiceInitParam Params; - memset(&Params, 0, sizeof(CellVoiceInitParam)); - Params.appType = CELLVOICE_APPTYPE_GAME_1MB; - Params.version = CELLVOICE_VERSION_100; - - ret = cellVoiceInitEx( &Params ); - - if (ret != CELL_OK ) - return false; - - sys_ipc_key_t voiceEventKey; - sys_event_queue_t voiceQueue; - int err = cellVoiceCreateNotifyEventQueue(&voiceQueue, &voiceEventKey); - if (err != CELL_OK) - return false; - - uint64_t source = 12345; - - err = cellVoiceSetNotifyEventQueue(voiceEventKey, source); - - if (err != CELL_OK) - return false; - - return true; -} - -//----------------------------------------------------------------------------- -// Purpose: Initialize libpad for controller input -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BInitializeLibPad() -{ - int ret = cellPadInit( CELL_PAD_MAX_PORT_NUM ); - if ( ret != CELL_OK ) - return false; - - // We don't use pressure sensitivity or sixaxis - for ( int i=0; i orange - g_DbgFontConsoleID = m_DbgFontConsoleID = cellDbgFontConsoleOpen( &ccfg0 ); - if ( g_DbgFontConsoleID < 0 ) - { - OutputDebugString( "Failed creating CellDbgFontConsole\n" ); - } - - return true; -} - -//----------------------------------------------------------------------------- -// Purpose: Updates current tick count for the game engine -//----------------------------------------------------------------------------- -void CGameEnginePS3::UpdateGameTickCount() -{ - m_ulPreviousGameTickCount = m_ulGameTickCount; - m_ulGameTickCount = cell::fios::FIOSAbstimeToMilliseconds( cell::fios::FIOSGetCurrentTime() ); -} - - -//----------------------------------------------------------------------------- -// Purpose: Tell the game engine to sleep for a bit if needed to limit frame rate. You must keep -// calling this repeatedly until it returns false. If it returns true it's slept a little, but more -// time may be needed. -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BSleepForFrameRateLimit( uint32 ulMaxFrameRate ) -{ - // Frame rate limiting - float flDesiredFrameMilliseconds = 1000.0f/ulMaxFrameRate; - - uint64 ulGameTickCount = cell::fios::FIOSAbstimeToMilliseconds( cell::fios::FIOSGetCurrentTime() ); - - float flMillisecondsElapsed = (float)(ulGameTickCount - m_ulGameTickCount); - if ( flMillisecondsElapsed < flDesiredFrameMilliseconds ) - { - // If enough time is left sleep, otherwise just keep spinning so we don't go over the limit... - if ( flDesiredFrameMilliseconds - flMillisecondsElapsed > 3.0f ) - { - sys_timer_usleep( 2000 ); - } - else - { - // Just return right away so we busy loop, don't want to sleep too long and go over - } - - return true; - } - else - { - return false; - } -} - - -//----------------------------------------------------------------------------- -// Purpose: Set the background color to clear to -//----------------------------------------------------------------------------- -void CGameEnginePS3::SetBackgroundColor( short a, short r, short g, short b ) -{ - glClearColor( (float)r/255.0f, (float)g/255.0f, (float)b/255.0f, (float)a/255.0f ); -} - -//----------------------------------------------------------------------------- -// Purpose: Start a new frame -//----------------------------------------------------------------------------- -bool CGameEnginePS3::StartFrame() -{ -#ifdef PS3_MTT_DEBUG - mttLogNewFrame(); -#endif - // Pump PS3 system callbacks - MessagePump(); - - // We may now be shutting down, check and don't start a frame then - if ( BShuttingDown() ) - return false; - - // Clear the screen for the new frame - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); - - return true; -} - - -//----------------------------------------------------------------------------- -// Purpose: End the current frame -//----------------------------------------------------------------------------- -void CGameEnginePS3::EndFrame() -{ - if ( BShuttingDown() ) - return; - - if ( !m_pPSGLDevice ) - return; - - if ( !m_pPSGLContext ) - return; - - // Flush point buffer - BFlushPointBuffer(); - - // Flush line buffer - BFlushLineBuffer(); - - // Flush quad buffer - BFlushQuadBuffer(); - - // Flush dbg font data - cellDbgFontDraw(); - - // Tell the Steam overlay to draw now - SteamPS3OverlayRender()->Render(); - - // Draw a few lines, for 10% and 15% safe boundaries - DWORD dwColor = D3DCOLOR_ARGB( 50, 255, 0, 0 ); - - float flXSafe = GetViewportWidth()*0.05f; - float flYSafe = GetViewportHeight()*0.05f; - BDrawLine( flXSafe, flYSafe, dwColor, flXSafe, GetViewportHeight()-flYSafe, dwColor ); - BDrawLine( flXSafe, flYSafe, dwColor, GetViewportWidth()-flXSafe, flYSafe, dwColor ); - BDrawLine( GetViewportWidth()-flXSafe, flYSafe, dwColor, GetViewportWidth()-flXSafe, GetViewportHeight()-flYSafe, dwColor ); - BDrawLine( flXSafe, GetViewportHeight()-flYSafe, dwColor, GetViewportWidth()-flXSafe, GetViewportHeight()-flYSafe, dwColor ); - - dwColor = D3DCOLOR_ARGB( 50, 255, 255, 0 ); - flXSafe = GetViewportWidth()*0.075f; - flYSafe = GetViewportHeight()*0.075f; - BDrawLine( flXSafe, flYSafe, dwColor, flXSafe, GetViewportHeight()-flYSafe, dwColor ); - BDrawLine( flXSafe, flYSafe, dwColor, GetViewportWidth()-flXSafe, flYSafe, dwColor ); - BDrawLine( GetViewportWidth()-flXSafe, flYSafe, dwColor, GetViewportWidth()-flXSafe, GetViewportHeight()-flYSafe, dwColor ); - BDrawLine( flXSafe, GetViewportHeight()-flYSafe, dwColor, GetViewportWidth()-flXSafe, GetViewportHeight()-flYSafe, dwColor ); - - // Flush quads a second time, as Steam may have queued more batches. - BFlushQuadBuffer(); - - // Flush lines again - BFlushLineBuffer(); - - // Swap buffers now that everything is flushed - psglSwap(); - - RunAudio(); -} - - -//----------------------------------------------------------------------------- -// Purpose: Draw a line, the engine internally manages a vertex buffer for batching these -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BDrawLine( float xPos0, float yPos0, DWORD dwColor0, float xPos1, float yPos1, DWORD dwColor1 ) -{ - if ( !m_pPSGLContext || !m_pPSGLDevice || m_bShuttingDown ) - return false; - - - // Check if we are out of room and need to flush the buffer - if ( m_dwLinesToFlush == LINE_BUFFER_TOTAL_SIZE ) - { - BFlushLineBuffer(); - } - - DWORD dwOffset = m_dwLinesToFlush*6; - m_rgflLinesData[dwOffset] = xPos0; - m_rgflLinesData[dwOffset+1] = yPos0; - m_rgflLinesData[dwOffset+2] = 1.0; - m_rgflLinesData[dwOffset+3] = xPos1; - m_rgflLinesData[dwOffset+4] = yPos1; - m_rgflLinesData[dwOffset+5] = 1.0; - - dwOffset = m_dwLinesToFlush*8; - m_rgflLinesColorData[dwOffset] = COLOR_RED( dwColor0 ); - m_rgflLinesColorData[dwOffset+1] = COLOR_GREEN( dwColor0 ); - m_rgflLinesColorData[dwOffset+2] = COLOR_BLUE( dwColor0 ); - m_rgflLinesColorData[dwOffset+3] = COLOR_ALPHA( dwColor0 ); - m_rgflLinesColorData[dwOffset+4] = COLOR_RED( dwColor1 ); - m_rgflLinesColorData[dwOffset+5] = COLOR_GREEN( dwColor1 ); - m_rgflLinesColorData[dwOffset+6] = COLOR_BLUE( dwColor1 ); - m_rgflLinesColorData[dwOffset+7] = COLOR_ALPHA( dwColor1 ); - - ++m_dwLinesToFlush; - - return true; -} - - -//----------------------------------------------------------------------------- -// Purpose: Flush batched lines to the screen -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BFlushLineBuffer() -{ - if ( !m_pPSGLContext || !m_pPSGLDevice || !m_rgflLinesColorData || !m_rgflLinesData || m_bShuttingDown ) - return false; - - if ( m_dwLinesToFlush ) - { - glColorPointer( 4, GL_UNSIGNED_BYTE, 0, m_rgflLinesColorData ); - glVertexPointer( 3, GL_FLOAT, 0, m_rgflLinesData ); - glDrawArrays( GL_LINES, 0, m_dwLinesToFlush*2 ); - - m_dwLinesToFlush = 0; - } - - return true; -} - - -//----------------------------------------------------------------------------- -// Purpose: Draw a point, the engine internally manages a vertex buffer for batching these -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BDrawPoint( float xPos, float yPos, DWORD dwColor ) -{ - - if ( !m_pPSGLContext || !m_pPSGLDevice || m_bShuttingDown ) - return false; - - - // Check if we are out of room and need to flush the buffer - if ( m_dwPointsToFlush == POINT_BUFFER_TOTAL_SIZE ) - { - BFlushPointBuffer(); - } - - DWORD dwOffset = m_dwPointsToFlush*3; - m_rgflPointsData[dwOffset] = xPos; - m_rgflPointsData[dwOffset+1] = yPos; - m_rgflPointsData[dwOffset+2] = 1.0; - - dwOffset = m_dwPointsToFlush*4; - m_rgflPointsColorData[dwOffset] = COLOR_RED( dwColor ); - m_rgflPointsColorData[dwOffset+1] = COLOR_GREEN( dwColor ); - m_rgflPointsColorData[dwOffset+2] = COLOR_BLUE( dwColor ); - m_rgflPointsColorData[dwOffset+3] = COLOR_ALPHA( dwColor ); - - ++m_dwPointsToFlush; - - return true; -} - - -//----------------------------------------------------------------------------- -// Purpose: Flush batched points to the screen -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BFlushPointBuffer() -{ - if ( !m_pPSGLContext || !m_pPSGLDevice || !m_rgflPointsColorData || !m_rgflPointsData || m_bShuttingDown ) - return false; - - if ( m_dwPointsToFlush ) - { - glColorPointer( 4, GL_UNSIGNED_BYTE, 0, m_rgflPointsColorData ); - glVertexPointer( 3, GL_FLOAT, 0, m_rgflPointsData ); - glDrawArrays( GL_POINTS, 0, m_dwPointsToFlush ); - - m_dwPointsToFlush = 0; - } - - return true; -} - - -//----------------------------------------------------------------------------- -// Purpose: Draw a filled quad -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BDrawFilledQuad( float xPos0, float yPos0, float xPos1, float yPos1, DWORD dwColor ) -{ - if ( !m_hTextureWhite ) - { - byte *pRGBAData = new byte[ 1 * 1 * 4 ]; - memset( pRGBAData, 255, 1*1*4 ); - m_hTextureWhite = HCreateTexture( pRGBAData, 1, 1 ); - delete[] pRGBAData; - } - - return BDrawTexturedQuad( xPos0, yPos0, xPos1, yPos1, 0.0f, 0.0f, 1.0f, 1.0f, dwColor, m_hTextureWhite ); -} - - -//----------------------------------------------------------------------------- -// Purpose: Draw a textured quad -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BDrawTexturedQuad( float xPos0, float yPos0, float xPos1, float yPos1, float u0, float v0, float u1, float v1, DWORD dwColor, HGAMETEXTURE hTexture ) -{ - return BDrawTexturedGradientQuad( xPos0, yPos0, xPos1, yPos1, u0, v0, u1, v1, dwColor, dwColor, dwColor, dwColor, hTexture ); -} - -//----------------------------------------------------------------------------- -// Purpose: Draw a textured quad, with different colors at each vertex -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BDrawTexturedGradientQuad( float xPos0, float yPos0, float xPos1, float yPos1, - float u0, float v0, float u1, float v1, - DWORD dwColorTopLeft, DWORD dwColorTopRight, DWORD dwColorBottomLeft, DWORD dwColorBottomRight, HGAMETEXTURE hTexture ) -{ - if ( m_bShuttingDown || !m_pPSGLDevice || !m_pPSGLContext ) - return false; - - // Find the texture - std::map::iterator iter; - iter = m_MapTextures.find( hTexture ); - if ( iter == m_MapTextures.end() ) - { - OutputDebugString( "BDrawTexturedQuad called with invalid hTexture value\n" ); - return false; - } - - // Check if we are out of room and need to flush the buffer, or if our texture is changing - // then we also need to flush the buffer. - if ( m_dwQuadsToFlush == QUAD_BUFFER_TOTAL_SIZE || m_hLastTexture != hTexture ) - { - BFlushQuadBuffer(); - } - - // Bind the new texture - glBindTexture( GL_TEXTURE_2D, iter->second.m_uTextureID ); - - DWORD dwOffset = m_dwQuadsToFlush*12; - m_rgflQuadsData[dwOffset] = xPos0; - m_rgflQuadsData[dwOffset+1] = yPos0; - m_rgflQuadsData[dwOffset+2] = 1.0f; - m_rgflQuadsData[dwOffset+3] = xPos1; - m_rgflQuadsData[dwOffset+4] = yPos0; - m_rgflQuadsData[dwOffset+5] = 1.0f; - m_rgflQuadsData[dwOffset+6] = xPos1; - m_rgflQuadsData[dwOffset+7] = yPos1; - m_rgflQuadsData[dwOffset+8] = 1.0f; - m_rgflQuadsData[dwOffset+9] = xPos0; - m_rgflQuadsData[dwOffset+10] = yPos1; - m_rgflQuadsData[dwOffset+11] = 1.0f; - - dwOffset = m_dwQuadsToFlush*16; - m_rgflQuadsColorData[dwOffset] = COLOR_RED( dwColorTopLeft ); - m_rgflQuadsColorData[dwOffset+1] = COLOR_GREEN( dwColorTopLeft ); - m_rgflQuadsColorData[dwOffset+2] = COLOR_BLUE( dwColorTopLeft ); - m_rgflQuadsColorData[dwOffset+3] = COLOR_ALPHA( dwColorTopLeft ); - m_rgflQuadsColorData[dwOffset+4] = COLOR_RED( dwColorTopRight ); - m_rgflQuadsColorData[dwOffset+5] = COLOR_GREEN( dwColorTopRight ); - m_rgflQuadsColorData[dwOffset+6] = COLOR_BLUE( dwColorTopRight ); - m_rgflQuadsColorData[dwOffset+7] = COLOR_ALPHA( dwColorTopRight ); - m_rgflQuadsColorData[dwOffset+8] = COLOR_RED( dwColorBottomLeft ); - m_rgflQuadsColorData[dwOffset+9] = COLOR_GREEN( dwColorBottomLeft ); - m_rgflQuadsColorData[dwOffset+10] = COLOR_BLUE( dwColorBottomLeft ); - m_rgflQuadsColorData[dwOffset+11] = COLOR_ALPHA( dwColorBottomLeft ); - m_rgflQuadsColorData[dwOffset+12] = COLOR_RED( dwColorBottomRight ); - m_rgflQuadsColorData[dwOffset+13] = COLOR_GREEN( dwColorBottomRight ); - m_rgflQuadsColorData[dwOffset+14] = COLOR_BLUE( dwColorBottomRight ); - m_rgflQuadsColorData[dwOffset+15] = COLOR_ALPHA( dwColorBottomRight ); - - dwOffset = m_dwQuadsToFlush*8; - m_rgflQuadsTextureData[dwOffset] = u0; - m_rgflQuadsTextureData[dwOffset+1] = v0; - m_rgflQuadsTextureData[dwOffset+2] = u1; - m_rgflQuadsTextureData[dwOffset+3] = v0; - m_rgflQuadsTextureData[dwOffset+4] = u1; - m_rgflQuadsTextureData[dwOffset+5] = v1; - m_rgflQuadsTextureData[dwOffset+6] = u0; - m_rgflQuadsTextureData[dwOffset+7] = v1; - - - ++m_dwQuadsToFlush; - - return true; -} - - -//----------------------------------------------------------------------------- -// Purpose: Flush buffered quads -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BFlushQuadBuffer() -{ - if ( !m_pPSGLContext || !m_pPSGLDevice || !m_rgflPointsColorData || !m_rgflPointsData || m_bShuttingDown ) - return false; - - if ( m_dwQuadsToFlush ) - { - glEnable( GL_TEXTURE_2D ); - glEnableClientState( GL_TEXTURE_COORD_ARRAY ); - - glColorPointer( 4, GL_UNSIGNED_BYTE, 0, m_rgflQuadsColorData ); - glVertexPointer( 3, GL_FLOAT, 0, m_rgflQuadsData ); - glTexCoordPointer( 2, GL_FLOAT, 0, m_rgflQuadsTextureData ); - glDrawArrays( GL_QUADS, 0, m_dwQuadsToFlush*4 ); - - glDisable( GL_TEXTURE_2D ); - glDisableClientState( GL_TEXTURE_COORD_ARRAY ); - - m_dwQuadsToFlush = 0; - } - - return true; -} - - -//----------------------------------------------------------------------------- -// Purpose: Creates a new texture -//----------------------------------------------------------------------------- -HGAMETEXTURE CGameEnginePS3::HCreateTexture( byte *pRGBAData, uint32 uWidth, uint32 uHeight ) -{ - if ( m_bShuttingDown || !m_pPSGLDevice || !m_pPSGLContext ) - return 0; - - BFlushQuadBuffer(); - - TextureData_t TexData; - TexData.m_uWidth = uWidth; - TexData.m_uHeight = uHeight; - TexData.m_uTextureID = 0; - - glEnable( GL_TEXTURE_2D ); - glGenTextures( 1, &TexData.m_uTextureID ); - glBindTexture( GL_TEXTURE_2D, TexData.m_uTextureID ); - - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0 ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0 ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - - // build our texture mipmaps - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, uWidth, uHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, (void *)pRGBAData ); - glDisable( GL_TEXTURE_2D ); - - int nHandle = m_nNextTextureHandle; - ++m_nNextTextureHandle; - m_MapTextures[nHandle] = TexData; - - return nHandle; -} - - -//----------------------------------------------------------------------------- -// Purpose: Creates a new font -//----------------------------------------------------------------------------- -HGAMEFONT CGameEnginePS3::HCreateFont( int nHeight, int nFontWeight, bool bItalic, const char * pchFont ) -{ - HGAMEFONT hFont = m_nNextFontHandle; - ++m_nNextFontHandle; - - // weight + italic are not supported in our dbg font output on ps3. Neither is specifying font. - // We also have to compute a "scale" relative to screen size, so it may not match pc exactly. - - // 1.0f for scale means 80 characters fit the screen width, 32 lines fit the height. - // We'll call that 1.0 scale font roughly equivalent to 28pt font height on pc/d3d. - - PS3DbgFont_t font; - font.m_nScale = (float)nHeight/28.0f; - m_MapGameFonts[ hFont ] = font; - - return hFont; -} - - -//----------------------------------------------------------------------------- -// Purpose: Draws text to the screen inside the given rectangular region, using the given font -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BDrawString( HGAMEFONT hFont, RECT rect, DWORD dwColor, DWORD dwFormat, const char *pchText ) -{ - if ( !hFont ) - { - OutputDebugString( "Someone is calling BDrawString with a null font handle\n" ); - return false; - } - - float fCharWidth = m_nWindowWidth/80.0f; - float fCharHeight = m_nWindowHeight/32.0f; - - // Find the font object for the passed handle - std::map::iterator iter; - iter = m_MapGameFonts.find( hFont ); - if ( iter == m_MapGameFonts.end() ) - { - OutputDebugString( "Invalid font handle passed to BDrawString()\n" ); - return false; - } - - fCharWidth *= iter->second.m_nScale; - fCharHeight *= iter->second.m_nScale; - - // Compute width/height in chars/lines - int nLinesInText = 1; - int nCharsWideMax = 0; - int nCharsLine = 0; - for( int i=0; i < strlen(pchText); ++i ) - { - if ( pchText[i] == '\n' ) - { - ++nLinesInText; - nCharsWideMax = MAX( nCharsLine, nCharsWideMax ); - nCharsLine = 0; - } - else - { - // We assume all non linebreak chars are printable, don't pass others! - ++nCharsLine; - } - } - nCharsWideMax = MAX( nCharsLine, nCharsWideMax ); - - // Assume top left positioning - float x = (float)rect.left; - float y = (float)rect.top; - - if ( TEXTPOS_CENTER & dwFormat ) - { - float fTextWidth = nCharsWideMax * fCharWidth; - x = (float)rect.left + ((float)( rect.right-rect.left) - fTextWidth)/2.0f; - } - else if ( TEXTPOS_RIGHT &dwFormat ) - { - float fTextWidth = nCharsWideMax * fCharWidth; - x = (float)rect.right - fTextWidth; - } - - if ( TEXTPOS_VCENTER & dwFormat ) - { - float fTextHeight = nLinesInText * fCharHeight; - y = (float)rect.top + ((float)( rect.bottom-rect.top) - fTextHeight)/2.0f; - } - else if ( TEXTPOS_RIGHT &dwFormat ) - { - float fTextHeight = nLinesInText * fCharHeight; - y = (float)rect.bottom - fTextHeight; - } - - // Convert x/y to 0.0->1.0 range vs screen size - x = x/(float)m_nWindowWidth; - y = y/(float)m_nWindowHeight; - - // we have the font, try to draw with it - if( cellDbgFontPuts( x, y, iter->second.m_nScale, DWARGB_TO_DWABGR(dwColor), pchText ) < 0 ) - { - OutputDebugString( "cellDbgFontPuts call failed\n" ); - return false; - } - - return true; -} - - -//----------------------------------------------------------------------------- -// Purpose: Message pump for OS messages -//----------------------------------------------------------------------------- -void CGameEnginePS3::MessagePump() -{ - cellSysutilCheckCallback(); - - // Running callbacks may have triggered shutdown, if not run input - if ( !m_bShuttingDown ) - { - CellPadInfo2 padInfo; - int ret = cellPadGetInfo2( &padInfo ); - if ( ret == CELL_OK ) - { - if ( padInfo.system_info & CELL_PAD_INFO_INTERCEPTED ) - { - // System has taken control of controller info, we can't currently access it. - } - - bool bControllerFound = false; - m_iCurrentPadIndex = -1; - for( int i=0; i < CELL_PAD_MAX_PORT_NUM; ++i ) - { - if ( padInfo.port_status[i] & CELL_PAD_STATUS_ASSIGN_CHANGES ) - { - if ( (padInfo.port_status[i] & CELL_PAD_STATUS_CONNECTED) == 0 ) - { - char rgchBuffer[512]; - sprintf_safe( rgchBuffer, "Gamepad %d removed\n", i ); - OutputDebugString( rgchBuffer ); - } - else if ( (padInfo.port_status[i] & CELL_PAD_STATUS_CONNECTED) > 0 ) - { - char rgchBuffer[512]; - sprintf_safe( rgchBuffer, "Gamepad %d connected\n", i ); - OutputDebugString( rgchBuffer ); - } - } - - if ( (padInfo.port_status[i] & CELL_PAD_STATUS_CONNECTED ) > 0 && padInfo.device_type[i] == CELL_PAD_DEV_TYPE_STANDARD ) - { - bControllerFound = true; - m_iCurrentPadIndex = i; - break; - } - } - - if ( padInfo.system_info & CELL_PAD_INFO_INTERCEPTED ) - { - // Pass zeroed pad data to overlay to clear it's button state too - SteamPS3OverlayRender()->BResetInputState(); - - // Clear all keys - m_SetKeysDown.clear(); - } - - if ( !bControllerFound ) - { - // Definitely no appropriate controller plugged in, can't do input - static DWORD dwLastSpewTime = 0; - if ( GetGameTickCount() - dwLastSpewTime > 3000 || dwLastSpewTime == 0 || dwLastSpewTime > GetGameTickCount() ) - { - dwLastSpewTime = GetGameTickCount(); - OutputDebugString( "No supported controllers are active, activate one.\n" ); - } - - // Pass zeroed pad data to overlay to clear it's button state too - SteamPS3OverlayRender()->BResetInputState(); - - // Clear all keys - m_SetKeysDown.clear(); - } - else - { - // Get status of the first found controller now - CellPadData padData; - int ret = cellPadGetData( m_iCurrentPadIndex, &padData ); - - // If we got data ok, and if the data is new (len != 0) then process it - if ( ret == CELL_OK && padData.len ) - { - if ( !SteamPS3OverlayRender()->BHandleCellPadData( padData ) ) - { - if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R2 ) - { - m_SetKeysDown.insert( 0x57 ); // W key, thrusters, mapped to R2 on PS3 - } - else - { - m_SetKeysDown.erase( 0x57 ); - } - - if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2 ) - { - m_SetKeysDown.insert( 0x53 ); // S key, reverse thrusters, mapped to L2 on PS3 - } - else - { - m_SetKeysDown.erase( 0x53 ); - } - - if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS ) - { - // Mapped to both enter in menus, and fire in game - m_SetKeysDown.insert( VK_RETURN ); - m_SetKeysDown.insert( VK_SPACE ); - } - else - { - m_SetKeysDown.erase( VK_RETURN ); - m_SetKeysDown.erase( VK_SPACE ); - } - - if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE ) - { - m_SetKeysDown.insert( VK_ESCAPE ); - } - else - { - m_SetKeysDown.erase( VK_ESCAPE ); - } - - if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_UP || padData.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] == 0x00 ) - { - m_SetKeysDown.insert( VK_UP ); - } - else - { - m_SetKeysDown.erase( VK_UP ); - } - - if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_DOWN || padData.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] == 0xFF ) - { - m_SetKeysDown.insert( VK_DOWN ); - } - else - { - m_SetKeysDown.erase( VK_DOWN ); - } - - if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_LEFT || padData.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] == 0x00 ) - { - m_SetKeysDown.insert( 0x41 ); // A Key, mapped to left on PS3 - } - else - { - m_SetKeysDown.erase( 0x41 ); - } - - if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_RIGHT || padData.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] == 0xFF ) - { - m_SetKeysDown.insert( 0x44 ); // D key, mapped to right on PS3 - } - else - { - m_SetKeysDown.erase( 0x44 ); - } - } - } - } - } - } -} - - -//----------------------------------------------------------------------------- -// Purpose: Find out if a key is currently down -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BIsKeyDown( DWORD dwVK ) -{ - std::set::iterator iter; - iter = m_SetKeysDown.find( dwVK ); - if ( iter != m_SetKeysDown.end() ) - return true; - - return false; -} - -//----------------------------------------------------------------------------- -// Purpose: Get a down key value -//----------------------------------------------------------------------------- -bool CGameEnginePS3::BGetFirstKeyDown( DWORD *pdwVK ) -{ - std::set::iterator iter; - iter = m_SetKeysDown.begin(); - if ( iter != m_SetKeysDown.end() ) - { - *pdwVK = *iter; - m_SetKeysDown.erase( iter ); - return true; - } - else - { - return false; - } -} - - -//----------------------------------------------------------------------------- -// Purpose: Find the engine instance tied to a given ptr -//----------------------------------------------------------------------------- -CGameEnginePS3 * CGameEnginePS3::FindEngineInstanceForPtr( void *ptr ) -{ - std::map::iterator iter; - iter = m_MapEngineInstances.find( ptr ); - if ( iter == m_MapEngineInstances.end() ) - return NULL; - else - return iter->second; -} - - -//----------------------------------------------------------------------------- -// Purpose: Add the engine instance tied to a given ptr to our static map -//----------------------------------------------------------------------------- -void CGameEnginePS3::AddInstanceToPtrMap( CGameEnginePS3 *pInstance ) -{ - m_MapEngineInstances[(void*)pInstance] = pInstance; -} - - -//----------------------------------------------------------------------------- -// Purpose: Removes the instance associated with a given ptr from the map -//----------------------------------------------------------------------------- -void CGameEnginePS3::RemoveInstanceFromPtrMap( void *ptr ) -{ - std::map::iterator iter; - iter = m_MapEngineInstances.find( ptr ); - if ( iter != m_MapEngineInstances.end() ) - m_MapEngineInstances.erase( iter ); -} - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -HGAMEVOICECHANNEL CGameEnginePS3::HCreateVoiceChannel() -{ - m_unVoiceChannelCount++; - CVoiceContext* pVoiceContext = new CVoiceContext; - - CellVoicePortParam PortArgs; - memset( &PortArgs, 0, sizeof(PortArgs) ); - - PortArgs.portType = CELLVOICE_PORTTYPE_IN_PCMAUDIO; - PortArgs.bMute = false; - PortArgs.threshold = 100; - PortArgs.volume = 1.0f; - PortArgs.pcmaudio.format.sampleRate= CELLVOICE_SAMPLINGRATE_16000; - PortArgs.pcmaudio.format.dataType = CELLVOICE_PCM_SHORT; - PortArgs.pcmaudio.bufSize = 11000; - - int ret= cellVoiceCreatePort( &pVoiceContext->m_PortIdInput, &PortArgs ); - - PortArgs.portType = CELLVOICE_PORTTYPE_OUT_SECONDARY; - PortArgs.bMute = false; - PortArgs.threshold = 100; - PortArgs.volume = 1.0f; - PortArgs.device.playerId = 0; - - ret = cellVoiceCreatePort( &pVoiceContext->m_PortIdOutput, &PortArgs ); - - ret = cellVoiceConnectIPortToOPort( pVoiceContext->m_PortIdInput, pVoiceContext->m_PortIdOutput ); - - if( ret != CELL_OK ) - { - delete pVoiceContext; - return 0; // failed - } - - if ( m_unVoiceChannelCount == 1 ) - { - CellVoiceStartParam startParams; - startParams.container = SYS_MEMORY_CONTAINER_ID_INVALID; - ret = sys_memory_container_create(&startParams.container,1024*1024); - ret = cellVoiceStartEx(&startParams); - } - - m_MapVoiceChannel[m_unVoiceChannelCount] = pVoiceContext; - - return m_unVoiceChannelCount; -} - -void CGameEnginePS3::RunAudio() -{ - std::map::iterator iter; - - for( iter = m_MapVoiceChannel.begin(); iter!=m_MapVoiceChannel.end(); ++iter) - { - CVoiceContext* pVoiceContext = iter->second; - - PacketQueue_t *pVoicePacket = pVoiceContext->m_pQueue; - - if ( pVoicePacket ) - { - CellVoiceBasePortInfo PortInfo; - memset(&PortInfo, 0, sizeof(PortInfo)); - int Result = cellVoiceGetPortInfo( pVoiceContext->m_PortIdInput, &PortInfo ); - if (Result != CELL_OK && Result != CELL_VOICE_ERROR_SERVICE_DETACHED ) - { - printf("cellVoiceGetPortInfo PCMInputPort failed %x\n",Result); - } - - if ( PortInfo.numByte > pVoicePacket->unSize ) - { - uint32_t bytes = pVoicePacket->unSize; - Result = cellVoiceWriteToIPort( pVoiceContext->m_PortIdInput, pVoicePacket->pData, &bytes ); - pVoicePacket->unWritten += bytes; - - if ( pVoicePacket->unWritten >= pVoicePacket->unSize ) - { - pVoiceContext->m_pQueue = pVoicePacket->pNext; - free( pVoicePacket->pData ); - delete pVoicePacket; - } - } - } - } -} - - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -void CGameEnginePS3::DestroyVoiceChannel( HGAMEVOICECHANNEL hChannel ) -{ - std::map::iterator iter; - iter = m_MapVoiceChannel.find( hChannel ); - if ( iter != m_MapVoiceChannel.end() ) - { - CVoiceContext* pVoiceContext = iter->second; - - // free outstanding voice packets - - PacketQueue_t *pVoicePacket = pVoiceContext->m_pQueue; - - while( pVoicePacket ) - { - PacketQueue_t *pNextPacket = pVoicePacket->pNext; - - free( pVoicePacket->pData ); - delete pVoicePacket; - - pVoicePacket = pNextPacket; - } - - // stop voice - - cellVoiceDisconnectIPortFromOPort( pVoiceContext->m_PortIdInput, pVoiceContext->m_PortIdOutput ); - cellVoiceDeletePort( pVoiceContext->m_PortIdInput ); - cellVoiceDeletePort( pVoiceContext->m_PortIdOutput ); - - delete pVoiceContext; - - m_MapVoiceChannel.erase( iter ); - } -} - - -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -bool CGameEnginePS3::AddVoiceData( HGAMEVOICECHANNEL hChannel, const uint8 *pVoiceData, uint32 uLength ) -{ - std::map::iterator iter; - iter = m_MapVoiceChannel.find( hChannel ); - if ( iter == m_MapVoiceChannel.end() ) - return false; // channel not found - - CVoiceContext* pVoiceContext = iter->second; - - PacketQueue_t *pVoicePacket = new PacketQueue_t; - - pVoicePacket->pData = malloc ( uLength ); - memcpy( pVoicePacket->pData, pVoiceData, uLength ); - pVoicePacket->unSize = uLength; - pVoicePacket->pNext = NULL; - pVoicePacket->unWritten = 0; - - if ( pVoiceContext->m_pQueue == NULL ) - { - // start queue - pVoiceContext->m_pQueue = pVoicePacket; - } - else - { - PacketQueue_t *pLastPacket = pVoiceContext->m_pQueue; - - // find tail - while ( pLastPacket->pNext ) - pLastPacket = pLastPacket->pNext; - - // append to tail - pLastPacket->pNext = pVoicePacket; - } - - return true; -} - - -//----------------------------------------------------------------------------- -// Purpose: Part of the render host interface for Steam overlay to draw through -//----------------------------------------------------------------------------- -void CGameEnginePS3::DrawTexturedRect( int x0, int y0, int x1, int y1, float u0, float v0, float u1, float v1, int32 iTextureID, DWORD colorStart, DWORD colorEnd, EOverlayGradientDirection eDirection ) -{ - std::map::iterator iter; - iter = m_MapSteamTextures.find( iTextureID ); - if ( iter != m_MapSteamTextures.end() ) - { - if ( eDirection == k_EOverlayGradientHorizontal ) - BDrawTexturedGradientQuad( x0, y0, x1, y1, u0, v0, u1, v1, colorStart, colorEnd, colorEnd, colorStart, iter->second ); - else if ( eDirection == k_EOverlayGradientVertical ) - BDrawTexturedGradientQuad( x0, y0, x1, y1, u0, v0, u1, v1, colorStart, colorStart, colorEnd, colorEnd, iter->second ); - else - BDrawTexturedGradientQuad( x0, y0, x1, y1, u0, v0, u1, v1, colorStart, colorStart, colorStart, colorStart, iter->second ); - - } - else - { - char rgchBuf[512]; - sprintf_safe( rgchBuf, "Steam trying to draw for invalid textureid: %d\n", iTextureID ); - OutputDebugString( rgchBuf ); - - } -} - - -//----------------------------------------------------------------------------- -// Purpose: Part of the render host interface for Steam overlay to draw through -//----------------------------------------------------------------------------- -void CGameEnginePS3::LoadOrUpdateTexture( int32 iTextureID, bool bIsFullTexture, int x0, int y0, uint32 uWidth, uint32 uHeight, int32 iBytes, char *pData ) -{ - BFlushQuadBuffer(); - m_hLastTexture = 0; - - if ( !bIsFullTexture ) - { - bool bUpdated = false; - std::map::iterator iter_steam; - iter_steam = m_MapSteamTextures.find( iTextureID ); - if ( iter_steam != m_MapSteamTextures.end() ) - { - std::map::iterator iter_game; - iter_game = m_MapTextures.find( iter_steam->second ); - if ( iter_game != m_MapTextures.end() ) - { - TextureData_t &TexData = iter_game->second; - - glEnable( GL_TEXTURE_2D ); - glBindTexture( GL_TEXTURE_2D, TexData.m_uTextureID ); - glTexSubImage2D( GL_TEXTURE_2D, 0, x0, y0, uWidth, uHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, pData ); - glDisable( GL_TEXTURE_2D ); - - bUpdated = true; - } - else - { - char rgchBuf[512]; - sprintf_safe( rgchBuf, "Couldn't find texture: %d\n", iTextureID ); - OutputDebugString( rgchBuf ); - } - } - else - { - char rgchBuf[512]; - sprintf_safe( rgchBuf, "Couldn't find Steam mapping for texture: %d\n", iTextureID ); - OutputDebugString( rgchBuf ); - } - - if ( !bUpdated ) - { - char rgchBuf[512]; - sprintf_safe( rgchBuf, "Failed updating texture: %d\n", iTextureID ); - OutputDebugString( rgchBuf ); - } - } - else - { - HGAMETEXTURE hGameTexture = HCreateTexture( (byte*)pData, uWidth, uHeight ); - m_MapSteamTextures[iTextureID] = hGameTexture; - } -} - - -//----------------------------------------------------------------------------- -// Purpose: Part of the render host interface for Steam overlay to draw through -//----------------------------------------------------------------------------- -void CGameEnginePS3::DeleteTexture( int32 iTextureID ) -{ - std::map::iterator iter; - iter = m_MapSteamTextures.find( iTextureID ); - if ( iter != m_MapSteamTextures.end() ) - { - // Our game engine doesn't know how to free textures, lol. - m_MapSteamTextures.erase( iter ); - } - else - { - char rgchBuf[512]; - sprintf_safe( rgchBuf, "Got DeleteTexture from Steam for texture we don't have mapped: %d\n", iTextureID ); - OutputDebugString( rgchBuf ); - } -} - - -//----------------------------------------------------------------------------- -// Purpose: Part of the render host interface for Steam overlay to draw through -//----------------------------------------------------------------------------- -void CGameEnginePS3::DeleteAllTextures() -{ - m_MapSteamTextures.clear(); - - // Don't really know how to delete textures in the engine, lol. -} diff --git a/steamworksexample/gameengineps3.h b/steamworksexample/gameengineps3.h deleted file mode 100644 index 8674a0d..0000000 --- a/steamworksexample/gameengineps3.h +++ /dev/null @@ -1,235 +0,0 @@ -//========= Copyright © 1996-2008, Valve LLC, All rights reserved. ============ -// -// Purpose: Main class for the game engine -- ps3 implementation -// -// $NoKeywords: $ -//============================================================================= - -#ifndef GAMEENGINEPS3_H -#define GAMEENGINEPS3_H - -#include "GameEngine.h" -#include -#include - - -// Font info for PS3 dbg font output -struct PS3DbgFont_t -{ - float m_nScale; -}; - -class CVoiceContext; - -class CGameEnginePS3 : public IGameEngine, public ISteamPS3OverlayRenderHost -{ -public: - - // Static methods for tracing mapping of game engine class instances to hwnds - static CGameEnginePS3 * FindEngineInstanceForPtr( void *ptr ); - static void AddInstanceToPtrMap( CGameEnginePS3* pInstance ); - static void RemoveInstanceFromPtrMap( void *ptr ); - - // Constructor - CGameEnginePS3(); - - // Destructor - ~CGameEnginePS3() { Shutdown(); } - - // Check if the game engine is initialized ok and ready for use - bool BReadyForUse() { return m_bEngineReadyForUse; } - - // Check if the engine is shutting down - bool BShuttingDown() { return m_bShuttingDown; } - - // Set the background color - void SetBackgroundColor( short a, short r, short g, short b ); - - // Start a frame, clear(), beginscene(), etc - bool StartFrame(); - - // Finish a frame, endscene(), present(), etc. - void EndFrame(); - - // Shutdown the game engine - void Shutdown(); - - // Pump messages from the OS - void MessagePump(); - - // Accessors for game screen size - int32 GetViewportWidth() { return m_nWindowWidth; } - int32 GetViewportHeight() { return m_nWindowHeight; } - - // Function for drawing text to the screen, dwFormat is a combination of flags like DT_LEFT, TEXTPOS_VCENTER etc... - bool BDrawString( HGAMEFONT hFont, RECT rect, DWORD dwColor, DWORD dwFormat, const char *pchText ); - - // Create a new font returning our internal handle value for it (0 means failure) - HGAMEFONT HCreateFont( int nHeight, int nFontWeight, bool bItalic, const char * pchFont ); - - // Create a new texture returning our internal handle value for it (0 means failure) - HGAMETEXTURE HCreateTexture( byte *pRGBAData, uint32 uWidth, uint32 uHeight ); - - // Draw a line, the engine itself will manage batching these (although you can explicitly flush if you need to) - bool BDrawLine( float xPos0, float yPos0, DWORD dwColor0, float xPos1, float yPos1, DWORD dwColor1 ); - - // Flush the line buffer - bool BFlushLineBuffer(); - - // Draw a point, the engine itself will manage batching these (although you can explicitly flush if you need to) - bool BDrawPoint( float xPos, float yPos, DWORD dwColor ); - - // Flush the point buffer - bool BFlushPointBuffer(); - - // Draw a filled quad - bool BDrawFilledQuad( float xPos0, float yPos0, float xPos1, float yPos1, DWORD dwColor ); - - // Draw a textured rectangle - bool BDrawTexturedQuad( float xPos0, float yPos0, float xPos1, float yPos1, - float u0, float v0, float u1, float v1, DWORD dwColor, HGAMETEXTURE hTexture ); - - // Flush any still cached quad buffers - bool BFlushQuadBuffer(); - - // Get the current state of a key - bool BIsKeyDown( DWORD dwVK ); - - // Get the first (in some arbitrary order) key down, if any - bool BGetFirstKeyDown( DWORD *pdwVK ); - - // Get current tick count for the game engine - uint64 GetGameTickCount() { return m_ulGameTickCount; } - - // Get the tick count elapsed since the previous frame - // bugbug - We use this time to compute things like thrust and acceleration in the game, - // so it's important in doesn't jump ahead by large increments... Need a better - // way to handle that. - uint64 GetGameTicksFrameDelta() { return m_ulGameTickCount - m_ulPreviousGameTickCount; } - - // Tell the game engine to update current tick count - void UpdateGameTickCount(); - - // Tell the game engine to sleep for a bit if needed to limit frame rate - bool BSleepForFrameRateLimit( uint32 ulMaxFrameRate ); - - // Check if the game engine hwnd currently has focus (and a working d3d device) - bool BGameEngineHasFocus() { return true; } - - // Voice chat functions - virtual HGAMEVOICECHANNEL HCreateVoiceChannel(); - virtual void DestroyVoiceChannel( HGAMEVOICECHANNEL hChannel ); - virtual bool AddVoiceData( HGAMEVOICECHANNEL hChannel, const uint8 *pVoiceData, uint32 uLength ); - - // ISteamPS3OverlayRenderHost implementation - virtual void DrawTexturedRect( int x0, int y0, int x1, int y1, float u0, float v0, float u1, float v1, int32 iTextureID, DWORD colorStart, DWORD colorEnd, EOverlayGradientDirection eDirection ); - virtual void LoadOrUpdateTexture( int32 iTextureID, bool bIsFullTexture, int x0, int y0, uint32 uWidth, uint32 uHeight, int32 iBytes, char *pData ); - virtual void DeleteTexture( int32 iTextureID ); - virtual void DeleteAllTextures(); - -private: - - // Draw a textured rectangle - bool BDrawTexturedGradientQuad( float xPos0, float yPos0, float xPos1, float yPos1, - float u0, float v0, float u1, float v1, - DWORD dwColorTopLeft, DWORD dwColorTopRight, DWORD dwColorBottomLeft, DWORD dwColorBottomRight, HGAMETEXTURE hTexture ); - - - // Initialize the PSGL rendering interfaces and default state - bool BInitializePSGL(); - - // Initialize the debug font library - bool BInitializeCellDbgFont(); - - // Initialize libpad for controller input - bool BInitializeLibPad(); - - bool BInitializeAudio(); - - void RunAudio(); - - -private: - // Tracks whether the engine is ready for use - bool m_bEngineReadyForUse; - - // Tracks if we are shutting down - bool m_bShuttingDown; - - // Size of the window to display the game in - int32 m_nWindowWidth; - int32 m_nWindowHeight; - - // Current game time in milliseconds - uint64 m_ulGameTickCount; - - // Game time at the start of the previous frame - uint64 m_ulPreviousGameTickCount; - - // White texture used when drawing filled quads - HGAMETEXTURE m_hTextureWhite; - - // PSGL and CellDbgFont objects - PSGLcontext * m_pPSGLContext; - PSGLdevice * m_pPSGLDevice; - CellDbgFontConsoleId m_DbgFontConsoleID; - - // Pointer to actual data for points - GLfloat *m_rgflPointsData; - GLubyte *m_rgflPointsColorData; - - // How many points are outstanding needing flush - DWORD m_dwPointsToFlush; - - // Pointer to actual data for lines - GLfloat *m_rgflLinesData; - GLubyte *m_rgflLinesColorData; - - - // How many lines are outstanding needing flush - DWORD m_dwLinesToFlush; - - // Pointer to actual data for quads - GLfloat *m_rgflQuadsData; - GLubyte *m_rgflQuadsColorData; - GLfloat *m_rgflQuadsTextureData; - - // How many lines are outstanding needing flush - DWORD m_dwQuadsToFlush; - - // Currently active PS3 pad index to use for input - int m_iCurrentPadIndex; - - // Map of engine instances by ptr, used in ps3 sys callbacks to find engine instance to handle callback - static std::map m_MapEngineInstances; - - // Map of font handles we have given out - HGAMEFONT m_nNextFontHandle; - std::map< HGAMEFONT, PS3DbgFont_t > m_MapGameFonts; - - // Map of handles to texture objects - struct TextureData_t - { - uint32 m_uWidth; - uint32 m_uHeight; - GLuint m_uTextureID; - }; - std::map m_MapTextures; - HGAMETEXTURE m_nNextTextureHandle; - - // Last bound texture, used to know when we must flush - HGAMETEXTURE m_hLastTexture; - - // Map of button state, translated to VK for win32. - std::set< DWORD > m_SetKeysDown; - - // Map of voice handles - std::map m_MapVoiceChannel; - uint32 m_unVoiceChannelCount; - - // Map of Steam texture ids to our engine texture handles - std::map< int, HGAMETEXTURE> m_MapSteamTextures; - -}; - -#endif // GAMEENGINEPS3_H diff --git a/steamworksexample/remotestoragesync.cpp b/steamworksexample/remotestoragesync.cpp deleted file mode 100644 index 1eaf1b4..0000000 --- a/steamworksexample/remotestoragesync.cpp +++ /dev/null @@ -1,228 +0,0 @@ -//========= Copyright © 1996-2008, Valve LLC, All rights reserved. ============ -// -// Purpose: Class for tracking stats and achievements -// -// $NoKeywords: $ -//============================================================================= - -#include "stdafx.h" -#include "remotestoragesync.h" -#include "BaseMenu.h" - -//----------------------------------------------------------------------------- -// NOTE -// -// The following code is for synchronizing files while the game is running -// This is only necessary when on the Playstation 3, as the Steam client handles -// these operations when on PC/Mac. -// -//----------------------------------------------------------------------------- - -#ifdef _PS3 -//----------------------------------------------------------------------------- -// Purpose: Constructor -//----------------------------------------------------------------------------- -CRemoteStorageSyncMenu::CRemoteStorageSyncMenu( IGameEngine *pGameEngine ) : CBaseMenu( pGameEngine ) -{ -} - -//----------------------------------------------------------------------------- -// Purpose: Shows the synchronization progress menu -//----------------------------------------------------------------------------- -void CRemoteStorageSyncMenu::ShowSyncProgress( ESyncOperation eSyncOperation, double dPercentComplete ) -{ - if ( eSyncOperation == k_ESyncOperationIdle ) - return; - - PushSelectedItem(); - ClearMenuItems(); - - // Create progress text - char buffer[260]; - const char *pchFormat = (eSyncOperation == k_ESyncOperationToClient ) ? "Syncing to client (%d%%)" : "Syncing to server(%d%%)"; - sprintf( buffer, pchFormat, (int)dPercentComplete ); - AddMenuItem( CRemoteStorageSyncMenu::MenuItem_t( buffer, k_EMenuCommandProgress ) ); - - PopSelectedItem(); -} - - -//----------------------------------------------------------------------------- -// Purpose: Shows the synchronization progress menu -//----------------------------------------------------------------------------- -void CRemoteStorageSyncMenu::ShowSyncComplete( ESyncOperation eSyncOperation, bool bSuccess ) -{ - if ( eSyncOperation == k_ESyncOperationIdle ) - return; - - PushSelectedItem(); - ClearMenuItems(); - - // Create progress text - char buffer[260]; - const char *pchResult = bSuccess ? "complete" : "failed"; - const char *pchFormat = (eSyncOperation == k_ESyncOperationToClient ) ? "Sync to client %s.. press X" : "Sync to server %s.. press X"; - sprintf( buffer, pchFormat, pchResult ); - AddMenuItem( CRemoteStorageSyncMenu::MenuItem_t( buffer, k_EMenuCommandSyncComplete ) ); - - PopSelectedItem(); -} - - -//----------------------------------------------------------------------------- -// Purpose: Shows the conflict menu -//----------------------------------------------------------------------------- -void CRemoteStorageSyncMenu::ShowConflict() -{ - PushSelectedItem(); - ClearMenuItems(); - - // Description - AddMenuItem( CRemoteStorageSyncMenu::MenuItem_t( "There is a conflict between the local & server versions of your files:", k_EMenuCommandNone ) ); - - PopSelectedItem(); -} - - -//----------------------------------------------------------------------------- -// Purpose: Constructor -//----------------------------------------------------------------------------- -CRemoteStorageSync::CRemoteStorageSync( IGameEngine *pGameEngine ) : - m_eSyncOperation( k_ESyncOperationIdle ), - m_menu( pGameEngine ), - m_callbackAppSyncClientComplete( this, &CRemoteStorageSync::OnAppSyncClientComplete ), - m_callbackAppSyncServerComplete( this, &CRemoteStorageSync::OnAppSyncServerComplete ), - m_callbackAppSyncProgress( this, &CRemoteStorageSync::OnAppSyncProgress ) -{ -} - - -//----------------------------------------------------------------------------- -// Purpose: Start synchronizing files to the client -//----------------------------------------------------------------------------- -void CRemoteStorageSync::SynchronizeToClient() -{ - if ( m_eSyncOperation != k_ESyncOperationIdle ) - return; - - if ( !SteamRemoteStorage()->SynchronizeToClient() ) - return; - - m_eSyncOperation = k_ESyncOperationToClient; - m_menu.ShowSyncProgress( m_eSyncOperation, 0.0 ); -} - - -//----------------------------------------------------------------------------- -// Purpose: Start synchronizing files to the server -//----------------------------------------------------------------------------- -void CRemoteStorageSync::SynchronizeToServer() -{ - if ( m_eSyncOperation != k_ESyncOperationIdle ) - return; - - if ( !SteamRemoteStorage()->SynchronizeToServer() ) - return; - - m_eSyncOperation = k_ESyncOperationToServer; - m_menu.ShowSyncProgress( m_eSyncOperation, 0.0 ); -} - - -//----------------------------------------------------------------------------- -// Purpose: Called each frame. Draw's menu -//----------------------------------------------------------------------------- -void CRemoteStorageSync::Render() -{ - m_menu.RunFrame(); -} - - -//----------------------------------------------------------------------------- -// Purpose: Returns true if we are done synchronizing -//----------------------------------------------------------------------------- -bool CRemoteStorageSync::BFinished() -{ - return m_eSyncOperation == k_ESyncOperationIdle; -} - - -//----------------------------------------------------------------------------- -// Purpose: Called periodically by Steam when a synchronization is in progress -//----------------------------------------------------------------------------- -void CRemoteStorageSync::OnAppSyncProgress( RemoteStorageAppSyncProgress_t *pParam ) -{ - // make sure the update is for us - if ( pParam->m_nAppID != SteamUtils()->GetAppID() ) - return; - - // make sure the update is in the direction we expect - if ( m_eSyncOperation == k_ESyncOperationIdle || (pParam->m_bUploading && m_eSyncOperation != k_ESyncOperationToServer) ) - return; - - m_menu.ShowSyncProgress( m_eSyncOperation, pParam->m_dAppPercentComplete ); -} - - -//----------------------------------------------------------------------------- -// Purpose: Called by Steam when a synchronization to the client is complete -//----------------------------------------------------------------------------- -void CRemoteStorageSync::OnAppSyncClientComplete( RemoteStorageAppSyncedClient_t *pParam ) -{ - // make sure the update is for us - if ( pParam->m_nAppID != SteamUtils()->GetAppID() ) - return; - - // make sure the update is in the direction we expect - if ( m_eSyncOperation != k_ESyncOperationToClient ) - return; - - // check for errors - if ( pParam->m_eResult == k_EResultRemoteFileConflict ) - { - m_menu.ShowConflict(); - return; - } - - m_menu.ShowSyncComplete( m_eSyncOperation, pParam->m_eResult == k_EResultOK ); -} - - -//----------------------------------------------------------------------------- -// Purpose: Called by Steam when a synchronization to the server is complete -//----------------------------------------------------------------------------- -void CRemoteStorageSync::OnAppSyncServerComplete( RemoteStorageAppSyncedServer_t *pParam ) -{ - // make sure the update is for us - if ( pParam->m_nAppID != SteamUtils()->GetAppID() ) - return; - - // make sure the update is in the direction we expect - if ( m_eSyncOperation != k_ESyncOperationToServer ) - return; - - // check for errors - if ( pParam->m_eResult == k_EResultRemoteFileConflict ) - { - m_menu.ShowConflict(); - return; - } - - m_menu.ShowSyncComplete( m_eSyncOperation, pParam->m_eResult == k_EResultOK ); -} - - -//----------------------------------------------------------------------------- -// Purpose: A sync menu item has been selected -//----------------------------------------------------------------------------- -void CRemoteStorageSync::OnMenuSelection( ERemoteStorageSyncMenuCommand selection ) -{ - switch( selection ) - { - case k_EMenuCommandSyncComplete: - m_eSyncOperation = k_ESyncOperationIdle; - break; - } -} - -#endif \ No newline at end of file diff --git a/steamworksexample/remotestoragesync.h b/steamworksexample/remotestoragesync.h index 838de6a..38e32ce 100644 --- a/steamworksexample/remotestoragesync.h +++ b/steamworksexample/remotestoragesync.h @@ -36,54 +36,4 @@ public: virtual void OnMenuSelection( ERemoteStorageSyncMenuCommand selection ) = 0; }; -#ifdef _PS3 -enum ESyncOperation -{ - k_ESyncOperationIdle, - k_ESyncOperationToClient, - k_ESyncOperationToServer -}; - -//----------------------------------------------------------------------------- -// Purpose: Menu shown for synchronization progress and prompting user to resolve a conflict -//----------------------------------------------------------------------------- -class CRemoteStorageSyncMenu : public CBaseMenu< ERemoteStorageSyncMenuCommand > -{ -public: - CRemoteStorageSyncMenu( IGameEngine *pGameEngine ); - void ShowSyncProgress( ESyncOperation eSyncOperation, double dPercentComplete ); - void ShowSyncComplete( ESyncOperation eSyncOperation, bool bSuccess ); - void ShowConflict(); -}; - - -//----------------------------------------------------------------------------- -// Purpose: Synchronizes files with Steam -//----------------------------------------------------------------------------- -class CRemoteStorageSync : public IRemoteStorageSync -{ -public: - - // Constructor - CRemoteStorageSync( IGameEngine *pGameEngine ); - - // IRemoteStorageSync implementations - virtual void SynchronizeToClient(); - virtual void SynchronizeToServer(); - virtual void Render(); - virtual bool BFinished(); - virtual void OnMenuSelection( ERemoteStorageSyncMenuCommand selection ); - -private: - // synchronization updates - STEAM_CALLBACK( CRemoteStorageSync, OnAppSyncClientComplete, RemoteStorageAppSyncedClient_t, m_callbackAppSyncClientComplete ); - STEAM_CALLBACK( CRemoteStorageSync, OnAppSyncServerComplete, RemoteStorageAppSyncedServer_t, m_callbackAppSyncServerComplete ); - STEAM_CALLBACK( CRemoteStorageSync, OnAppSyncProgress, RemoteStorageAppSyncProgress_t, m_callbackAppSyncProgress ); - STEAM_CALLBACK( CRemoteStorageSync, OnConflictResolution, RemoteStorageConflictResolution_t, m_callbackConflictResolution ); - - CRemoteStorageSyncMenu m_menu; - ESyncOperation m_eSyncOperation; -}; -#endif // !_PS3 - #endif diff --git a/steamworksexample/stdafx_ps3.h b/steamworksexample/stdafx_ps3.h deleted file mode 100644 index 9cf0173..0000000 --- a/steamworksexample/stdafx_ps3.h +++ /dev/null @@ -1,38 +0,0 @@ -//========= Copyright Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - - -// stdafx_ps3.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently on the PS3 platform -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#define PS3_MTT_DEBUG - -#ifdef PS3_MTT_DEBUG -#include "../external/libmtt/libmtt/libmtt_log.h" -#endif - -extern CellDbgFontConsoleId g_DbgFontConsoleID; \ No newline at end of file