refactor: remove X360 specific stuff from non X360 platforms

and abit of PS3 only stuff from PSVita
This commit is contained in:
2026-08-21 21:50:18 -04:00
parent e52fce044a
commit 3f8321240f
6 changed files with 25 additions and 3746 deletions
+2 -393
View File
@@ -3,8 +3,6 @@
#include "stdafx.h"
#ifdef __PS3__
#include <sys/process.h>
SYS_PROCESS_PARAM(1001, 0x10000); // thread priority, and stack size
@@ -79,10 +77,6 @@ char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] =
#include "..\..\Minecraft.World\ThreadName.h"
#include "..\..\Minecraft.Client\StatsCounter.h"
#include "..\ConnectScreen.h"
//#include "Social\SocialManager.h"
//#include "Leaderboards\LeaderboardManager.h"
//#include "XUI\XUI_Scene_Container.h"
//#include "NetworkManager.h"
#include "..\..\Minecraft.Client\Tesselator.h"
#include "..\Common\Console_Awards_enum.h"
#include "..\..\Minecraft.Client\Options.h"
@@ -99,26 +93,13 @@ char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] =
#include <cell/sysmodule.h>
#define THEME_NAME "584111F70AAAAAAA"
#define THEME_FILESIZE 2797568
#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device)
//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU
#define NUM_PROFILE_VALUES 5
#define NUM_PROFILE_SETTINGS 4
DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
{
#ifdef _XBOX
XPROFILE_OPTION_CONTROLLER_VIBRATION,
XPROFILE_GAMER_YAXIS_INVERSION,
XPROFILE_GAMER_CONTROL_SENSITIVITY,
XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL,
XPROFILE_TITLE_SPECIFIC1,
#else
0,0,0,0,0
#endif
};
// functions for storing and converting rich presence strings from wchar to utf8
@@ -341,50 +322,11 @@ void DefineActions(void)
InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN);
}
//#define MEMORY_TRACKING
#ifdef MEMORY_TRACKING
void ResetMem();
void DumpMem();
void MemPixStuff();
#else
void MemSect(int sect)
{
}
#endif
ID3D11Device* g_pd3dDevice = NULL;
ID3D11DeviceContext* g_pImmediateContext = NULL;
IDXGISwapChain* g_pSwapChain = NULL;
bool g_bBootedFromInvite = false;
//--------------------------------------------------------------------------------------
// Create Direct3D device and swap chain
//--------------------------------------------------------------------------------------
HRESULT InitDevice()
{
return S_OK;
}
//--------------------------------------------------------------------------------------
// Render the frame
//--------------------------------------------------------------------------------------
void Render()
{
}
//--------------------------------------------------------------------------------------
// Clean up the objects we've created
//--------------------------------------------------------------------------------------
void CleanupDevice()
{
}
bool g_bBootedFromInvite = false;
// simple function to load a file completely into memory
static void * load_file( char const * name )
@@ -414,8 +356,6 @@ static void * load_file( char const * name )
return ret;
}
void debugSaveGameDirect()
{
@@ -506,16 +446,6 @@ void RegisterAwardsWithProfileManager()
ProfileManager.RegisterAward(eAward_lionTamer, ACHIEVEMENT_50, eAwardType_Achievement);
#endif
#if 0
ProfileManager.RegisterAward(eAward_mine100Blocks, GAMER_PICTURE_GAMERPIC1, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC1,IDS_CONFIRM_OK);
ProfileManager.RegisterAward(eAward_kill10Creepers, GAMER_PICTURE_GAMERPIC2, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC2,IDS_CONFIRM_OK);
ProfileManager.RegisterAward(eAward_eatPorkChop, AVATARASSETAWARD_PORKCHOP_TSHIRT, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR1,IDS_CONFIRM_OK);
ProfileManager.RegisterAward(eAward_play100Days, AVATARASSETAWARD_WATCH, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR2,IDS_CONFIRM_OK);
ProfileManager.RegisterAward(eAward_arrowKillCreeper, AVATARASSETAWARD_CAP, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR3,IDS_CONFIRM_OK);
ProfileManager.RegisterAward(eAward_socialPost, 0, eAwardType_Theme,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_THEME,IDS_CONFIRM_OK,THEME_NAME,THEME_FILESIZE);
#endif
// Rich Presence init - number of presences, number of contexts
//printf("Rich presence strings are hard coded on PS3 for now, must change this!\n");
ProfileManager.RichPresenceInit(-1,-1); // 4J-JEV - Presence and Context count not used.
@@ -864,29 +794,8 @@ int main()
// Initialise //
////////////////
#if 0
// 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params
// are just copied from a sample app and may need changed for our purposes
// Start XAudio2
hr = XAudio2Create( &g_pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR );
if( FAILED( hr ) )
{
app.DebugPrintf( "Initializing XAudio2 failed (err = 0x%08x)!\n", hr );
app.FatalLoadError();
}
// Create an XAudio2 mastering voice (utilized by XHV2 when voice data is mixed to main speakers)
hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL);
if ( FAILED( hr ) )
{
app.DebugPrintf( "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr );
app.FatalLoadError();
}
#endif
app.InitTime();
// Initialise the profile manager with the game Title ID, Offer ID, a profile version number, and the number of profile values and settings
ProfileManager.Initialise(SQRNetworkManager_PS3::GetSceNpCommsId(),
SQRNetworkManager_PS3::GetSceNpCommsSig(),
@@ -911,41 +820,13 @@ int main()
// initialise the storage manager with a callback for displaying the saving message
StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,(LPVOID)&app,"");
#if 0
// Set up the global title storage path
StorageManager.StoreTMSPathName();
#endif
// MGH - I've had to rearrange some of the ordering here, as I was getting conflicts with the sysutils for trophies and the upgrade key
//app.FatalLoadError();
// set a function to be called when there's a sign in change, so we can exit a level if the primary player signs out
ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app);
#if 0
// set a function to be called when the ethernet is disconnected, so we can back out if required
ProfileManager.SetNotificationsCallback(&CConsoleMinecraftApp::NotificationsCallback,(LPVOID)&app);
#endif
// Set a callback for the default player options to be set - when there is no profile data for the player
StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app);
StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,(LPVOID)&app);
// Set a callback to deal with old profile versions needing updated to new versions
#if 0
ProfileManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app);
// Set a callback for when there is a read error on profile data
ProfileManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback,(LPVOID)&app);
// QNet needs to be setup after profile manager, as we do not want its Notify listener to handle
// XN_SYS_SIGNINCHANGED notifications. This does mean that we need to have a callback in the
// ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet.
#endif // 0
SonyRemoteStorage_PS3* pRemote = (SonyRemoteStorage_PS3*)app.getRemoteStorage();
pRemote->SetSecureID(secureFileId);
pRemote->SetServiceID(app.GetCommerceCategory());
@@ -1068,27 +949,6 @@ int main()
InputManager.SetLostInputControlCallback(&UIController::SetSystemUIShowing,&ui);
#ifndef _FINAL_BUILD
#ifndef _DEBUG
#pragma message(__LOC__"Need to define the _FINAL_BUILD before submission")
#endif
#endif
#if 0
DWORD initData=0;
// Set the default sound levels
pMinecraft->options->set(Options::Option::MUSIC,1.0f);
pMinecraft->options->set(Options::Option::SOUND,1.0f);
app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_Intro,&initData);
#endif
//LeaderboardManager::Instance()->OpenSession();
//LeaderboardManager::Instance()->ReadStats_TopRank(DebugReadListener::m_instance, 0, LeaderboardManager::eStatsType_Travelling, 1, 1);
@@ -1152,15 +1012,6 @@ int main()
while( ShutdownManager::ShouldRun(ShutdownManager::eMainThread) )
{
#if 0
if(pMinecraft->soundEngine->isStreamingWavebankReady() &&
!pMinecraft->soundEngine->isPlayingStreamingGameMusic() &&
!pMinecraft->soundEngine->isPlayingStreamingCDMusic() )
{
// play some music in the menus
pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false);
}
#endif
app.UpdateTime();
PIXBeginNamedEvent(0,"Input manager tick");
InputManager.Tick();
@@ -1226,39 +1077,6 @@ int main()
pMinecraft->soundEngine->playMusicTick();
#ifdef MEMORY_TRACKING
static bool bResetMemTrack = false;
static bool bDumpMemTrack = false;
MemPixStuff();
if( bResetMemTrack )
{
ResetMem();
MEMORYSTATUS memStat;
GlobalMemoryStatus(&memStat);
printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024));
bResetMemTrack = false;
}
if( bDumpMemTrack )
{
DumpMem();
bDumpMemTrack = false;
MEMORYSTATUS memStat;
GlobalMemoryStatus(&memStat);
printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024));
printf("Renderer used: %d\n",RenderManager.CBuffSize(-1));
}
#endif
#if 0
static bool bDumpTextureUsage = false;
if( bDumpTextureUsage )
{
RenderManager.TextureGetStats();
bDumpTextureUsage = false;
}
#endif
ui.tick();
ui.render();
@@ -1315,27 +1133,10 @@ int main()
}
PIXEndNamedEvent();
#if 0
app.TickDLCOffersRetrieved();
app.TickTMSPPFilesRetrieved();
#endif
PIXBeginNamedEvent(0,"Network manager do work #2");
g_NetworkManager.DoWork();
PIXEndNamedEvent();
#if 0
PIXBeginNamedEvent(0,"Misc extra xui");
// Update XUI Timers
hr = XuiTimersRun();
#endif
// Any threading type things to deal with from the xui side?
app.HandleXuiActions();
#if 0
PIXEndNamedEvent();
#endif
// 4J-PB - Update the trial timer display if we are in the trial version
if(!ProfileManager.IsFullVersion())
{
@@ -1399,196 +1200,4 @@ void FreeRichPresenceStrings()
free(strUtf8);
}
vRichPresenceStrings.clear();
}
#ifdef MEMORY_TRACKING
int totalAllocGen = 0;
unordered_map<int,int> allocCounts;
bool trackEnable = false;
bool trackStarted = false;
volatile size_t sizeCheckMin = 1160;
volatile size_t sizeCheckMax = 1160;
volatile int sectCheck = 48;
CRITICAL_SECTION memCS;
DWORD tlsIdx;
LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes)
{
if( !trackStarted )
{
void *p = XMemAllocDefault(dwSize,dwAllocAttributes);
size_t realSize = XMemSizeDefault(p, dwAllocAttributes);
totalAllocGen += realSize;
return p;
}
EnterCriticalSection(&memCS);
void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes);
size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16;
if( trackEnable )
{
#if 1
int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f;
*(((unsigned char *)p)+realSize) = sect;
if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) )
{
app.DebugPrintf("Found one\n");
}
#endif
if( p )
{
totalAllocGen += realSize;
trackEnable = false;
int key = ( sect << 26 ) | realSize;
int oldCount = allocCounts[key];
allocCounts[key] = oldCount + 1;
trackEnable = true;
}
}
LeaveCriticalSection(&memCS);
return p;
}
void* operator new (size_t size)
{
return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP));
}
void operator delete (void *p)
{
XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP));
}
void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes)
{
bool special = false;
if( dwAllocAttributes == 0 )
{
dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP);
special = true;
}
if(!trackStarted )
{
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes);
XMemFreeDefault(pAddress, dwAllocAttributes);
totalAllocGen -= realSize;
return;
}
EnterCriticalSection(&memCS);
if( pAddress )
{
size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
if(trackEnable)
{
int sect = *(((unsigned char *)pAddress)+realSize);
totalAllocGen -= realSize;
trackEnable = false;
int key = ( sect << 26 ) | realSize;
int oldCount = allocCounts[key];
allocCounts[key] = oldCount - 1;
trackEnable = true;
}
XMemFreeDefault(pAddress, dwAllocAttributes);
}
LeaveCriticalSection(&memCS);
}
SIZE_T WINAPI XMemSize(
PVOID pAddress,
DWORD dwAllocAttributes
)
{
if( trackStarted )
{
return XMemSizeDefault(pAddress, dwAllocAttributes) - 16;
}
else
{
return XMemSizeDefault(pAddress, dwAllocAttributes);
}
}
void DumpMem()
{
int totalLeak = 0;
for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ )
{
if(it->second > 0 )
{
app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second);
totalLeak += ( it->first & 0x03ffffff ) * it->second;
}
}
app.DebugPrintf("Total %d\n",totalLeak);
}
void ResetMem()
{
if( !trackStarted )
{
trackEnable = true;
trackStarted = true;
totalAllocGen = 0;
InitializeCriticalSection(&memCS);
tlsIdx = TlsAlloc();
}
EnterCriticalSection(&memCS);
trackEnable = false;
allocCounts.clear();
trackEnable = true;
LeaveCriticalSection(&memCS);
}
void MemSect(int section)
{
unsigned int value = (unsigned int)TlsGetValue(tlsIdx);
if( section == 0 ) // pop
{
value = (value >> 6) & 0x03ffffff;
}
else
{
value = (value << 6) | section;
}
TlsSetValue(tlsIdx, (LPVOID)value);
}
void MemPixStuff()
{
const int MAX_SECT = 46;
int totals[MAX_SECT] = {0};
for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ )
{
if(it->second > 0 )
{
int sect = ( it->first >> 26 ) & 0x3f;
int bytes = it->first & 0x03ffffff;
totals[sect] += bytes * it->second;
}
}
unsigned int allSectsTotal = 0;
for( int i = 0; i < MAX_SECT; i++ )
{
allSectsTotal += totals[i];
PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i);
}
PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages");
}
#endif
#endif // __PS3__
}