the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 1577 lines 61 kB view raw
1// Minecraft.cpp : Defines the entry point for the application. 2// 3 4#include "stdafx.h" 5 6#ifdef __PS3__ 7 8#include <sys/process.h> 9SYS_PROCESS_PARAM(1001, 0x10000); // thread priority, and stack size 10 11#include <sysutil/sysutil_sysparam.h> 12#include <cell/sysmodule.h> 13#include <sys/spu_initialize.h> 14#include <fcntl.h> 15#include <unistd.h> 16#include <cell/audio.h> 17#include <sysutil/sysutil_gamecontent.h> 18//#include <sysutil/sysutil_screenshot.h> 19 20#include "Leaderboards\PS3LeaderboardManager.h" 21#include "PS3\PS3Extras\PS3Strings.h" 22#include "PS3\PS3Extras\ShutdownManager.h" 23#include <sysutil/sysutil_bgmplayback.h> 24#include <sysutil/sysutil_msgdialog.h> 25 26#include "PS3/Network/SonyRemoteStorage_PS3.h" 27 28// define to use spurs (otherwise SPU threads or raw will be used) 29#define USE_SPURS 30#define SPU_SELF_PATH "PS3/SPU_Tasks/" 31 32#ifdef USE_SPURS 33#include <cell/spurs.h> 34#else 35#include <sys/spu_image.h> 36#endif 37 38/* Encrypted ID for protected data file (*) You must edit these binaries!! */ 39char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] = 40{ 41 0xEE, 0xA9, 0x37, 0xCC, 42 0x5B, 0xD4, 0xD9, 0x0D, 43 0x55, 0xED, 0x25, 0x31, 44 0xFA, 0x33, 0xBD, 0xC4 45}; 46 47#define MILES_SPEAKERS 8 // default to 7.1 (can be 2, 6, 7, or 8) 48 49//#define DISABLE_MILES_SOUND 50 51 52//#define HEAPINSPECTOR_PS3 1 53// when defining HEAPINSPECTOR_PS3, add this line to the linker settings 54// --wrap malloc --wrap free --wrap memalign --wrap calloc --wrap realloc --wrap reallocalign --wrap _malloc_init 55 56#if HEAPINSPECTOR_PS3 57#include "HeapInspector\Server\HeapInspectorServer.h" 58#include "HeapInspector\Server\PS3\HeapHooks.hpp" 59#endif 60 61#include "PS3_App.h" 62#include "GameConfig\Minecraft.spa.h" 63#include "..\MinecraftServer.h" 64#include "..\LocalPlayer.h" 65#include "..\..\Minecraft.World\ItemInstance.h" 66#include "..\..\Minecraft.World\MapItem.h" 67#include "..\..\Minecraft.World\Recipes.h" 68#include "..\..\Minecraft.World\Recipy.h" 69#include "..\..\Minecraft.World\Language.h" 70#include "..\..\Minecraft.World\StringHelpers.h" 71#include "..\..\Minecraft.World\AABB.h" 72#include "..\..\Minecraft.World\Vec3.h" 73#include "..\..\Minecraft.World\Level.h" 74#include "..\..\Minecraft.World\net.minecraft.world.level.tile.h" 75 76#include "..\ClientConnection.h" 77#include "..\User.h" 78#include "..\..\Minecraft.World\Socket.h" 79#include "..\..\Minecraft.World\ThreadName.h" 80#include "..\..\Minecraft.Client\StatsCounter.h" 81#include "..\ConnectScreen.h" 82//#include "Social\SocialManager.h" 83//#include "Leaderboards\LeaderboardManager.h" 84//#include "XUI\XUI_Scene_Container.h" 85//#include "NetworkManager.h" 86#include "..\..\Minecraft.Client\Tesselator.h" 87#include "..\Common\Console_Awards_enum.h" 88#include "..\..\Minecraft.Client\Options.h" 89#include "Sentient\SentientManager.h" 90#include "..\..\Minecraft.World\IntCache.h" 91#include "..\Textures.h" 92#include "Resource.h" 93#include "..\..\Minecraft.World\compression.h" 94#include "..\..\Minecraft.World\OldChunkStorage.h" 95#include "PS3\PS3Extras\EdgeZLib.h" 96#include "C4JThread_SPU.h" 97#include "Common\Network\Sony\SQRNetworkManager.h" 98#include "Common\UI\IUIScene_PauseMenu.h" 99 100#include <cell/sysmodule.h> 101 102#define THEME_NAME "584111F70AAAAAAA" 103#define THEME_FILESIZE 2797568 104 105 106#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device) 107 108//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU 109#define NUM_PROFILE_VALUES 5 110#define NUM_PROFILE_SETTINGS 4 111DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= 112{ 113#ifdef _XBOX 114 XPROFILE_OPTION_CONTROLLER_VIBRATION, 115 XPROFILE_GAMER_YAXIS_INVERSION, 116 XPROFILE_GAMER_CONTROL_SENSITIVITY, 117 XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, 118 XPROFILE_TITLE_SPECIFIC1, 119#else 120 0,0,0,0,0 121#endif 122}; 123 124// functions for storing and converting rich presence strings from wchar to utf8 125uint8_t * AddRichPresenceString(int iID); 126void FreeRichPresenceStrings(); 127 128#if HEAPINSPECTOR_PS3 129 130std::vector<HeapInspectorServer::HeapInfo> GetHeapInfo() 131{ 132 std::vector<HeapInspectorServer::HeapInfo> result = HeapInspectorServer::GetDefaultHeapInfo(); 133 HeapInspectorServer::HeapInfo localHeapInfo; 134 localHeapInfo.m_Description = "VRAM"; 135 localHeapInfo.m_Range.m_Min = 0xc0000000; 136 localHeapInfo.m_Range.m_Max = localHeapInfo.m_Range.m_Min + (249*1024*1024); 137 result.push_back(localHeapInfo); 138 return result; 139} 140 141extern "C" void* __real__malloc_init(size_t a_Boundary, size_t a_Size); 142extern "C" void* __wrap__malloc_init(size_t a_Boundary, size_t a_Size) 143{ 144 void* result = __real__malloc_init(a_Boundary, a_Size); 145 HeapInspectorServer::Initialise(GetHeapInfo(), 3000, HeapInspectorServer::WaitForConnection_Enabled); 146 return result; 147} 148 149#endif // HEAPINSPECTOR_PS3 150 151//------------------------------------------------------------------------------------- 152// Time Since fAppTime is a float, we need to keep the quadword app time 153// as a LARGE_INTEGER so that we don't lose precision after running 154// for a long time. 155//------------------------------------------------------------------------------------- 156 157BOOL g_bWidescreen = TRUE; 158//int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, this is setup from init_audio_hardware 159 160void DefineActions(void) 161{ 162 // The app needs to define the actions required, and the possible mappings for these 163 164 // Split into Menu actions, and in-game actions 165 if(InputManager.IsCircleCrossSwapped()) 166 { 167 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _360_JOY_BUTTON_B); 168 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _360_JOY_BUTTON_B); 169 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _360_JOY_BUTTON_A); 170 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _360_JOY_BUTTON_A); 171 } 172 else 173 { 174 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _360_JOY_BUTTON_A); 175 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _360_JOY_BUTTON_A); 176 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _360_JOY_BUTTON_B); 177 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B); 178 } 179 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_X, _360_JOY_BUTTON_X); 180 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_Y, _360_JOY_BUTTON_Y); 181 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); 182 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); 183 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); 184 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); 185 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LT); 186 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); 187 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); 188 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); 189 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START); 190 191 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); 192 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); 193 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); 194 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); 195 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); 196 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); 197 198 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_A); 199 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); 200 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); 201 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); 202 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); 203 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); 204 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); 205 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); 206 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); 207 208 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_LT); 209 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_RT); 210 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_RB); 211 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_LB); 212 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); 213 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); 214 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); 215 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_RTHUMB); 216 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); 217 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB); 218 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); 219 220 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); 221 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); 222 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); 223 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); 224 225 if(InputManager.IsCircleCrossSwapped()) 226 { 227 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_B); 228 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _360_JOY_BUTTON_B); 229 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_A); 230 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _360_JOY_BUTTON_A); 231 } 232 else 233 { 234 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_A); 235 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _360_JOY_BUTTON_A); 236 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_B); 237 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B); 238 } 239 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_X, _360_JOY_BUTTON_X); 240 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_Y, _360_JOY_BUTTON_Y); 241 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); 242 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); 243 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); 244 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); 245 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LB); 246 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); 247 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); 248 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); 249 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START); 250 251 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); 252 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); 253 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); 254 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); 255 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); 256 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); 257 258 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_RT); 259 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); 260 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); 261 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); 262 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); 263 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); 264 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); 265 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); 266 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); 267 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_RB); 268 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_LB); 269 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_DPAD_RIGHT); 270 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_DPAD_LEFT); 271 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); 272 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); 273 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); 274 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_LTHUMB); 275 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); 276 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_RTHUMB); 277 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); 278 279 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); 280 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); 281 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); 282 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); 283 284 if(InputManager.IsCircleCrossSwapped()) 285 { 286 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_A, _360_JOY_BUTTON_B); 287 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OK, _360_JOY_BUTTON_B); 288 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_B, _360_JOY_BUTTON_A); 289 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_CANCEL, _360_JOY_BUTTON_A); 290 } 291 else 292 { 293 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_A, _360_JOY_BUTTON_A); 294 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OK, _360_JOY_BUTTON_A); 295 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_B, _360_JOY_BUTTON_B); 296 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B); 297 } 298 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_X, _360_JOY_BUTTON_X); 299 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_Y, _360_JOY_BUTTON_Y); 300 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); 301 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); 302 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); 303 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); 304 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LB); 305 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); 306 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); 307 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); 308 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START); 309 310 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); 311 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); 312 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); 313 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); 314 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); 315 InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); 316 317 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_LB); 318 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); 319 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); 320 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); 321 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); 322 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); 323 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); 324 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); 325 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); 326 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_RB); 327 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_A); 328 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_DPAD_RIGHT); 329 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_DPAD_LEFT); 330 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); 331 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); 332 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); 333 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_LT); 334 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); 335 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB); 336 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); 337 338 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); 339 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); 340 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); 341 InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); 342} 343 344 345//#define MEMORY_TRACKING 346 347#ifdef MEMORY_TRACKING 348void ResetMem(); 349void DumpMem(); 350void MemPixStuff(); 351#else 352void MemSect(int sect) 353{ 354} 355#endif 356 357 358ID3D11Device* g_pd3dDevice = NULL; 359ID3D11DeviceContext* g_pImmediateContext = NULL; 360IDXGISwapChain* g_pSwapChain = NULL; 361bool g_bBootedFromInvite = false; 362 363//-------------------------------------------------------------------------------------- 364// Create Direct3D device and swap chain 365//-------------------------------------------------------------------------------------- 366HRESULT InitDevice() 367{ 368 369 370 return S_OK; 371} 372 373//-------------------------------------------------------------------------------------- 374// Render the frame 375//-------------------------------------------------------------------------------------- 376void Render() 377{ 378 379} 380 381//-------------------------------------------------------------------------------------- 382// Clean up the objects we've created 383//-------------------------------------------------------------------------------------- 384void CleanupDevice() 385{ 386 387} 388 389// simple function to load a file completely into memory 390static void * load_file( char const * name ) 391{ 392 void * ret; 393 int f; 394 unsigned int size; 395 396 f = open( name, O_RDONLY ); 397 if ( f == -1 ) return 0; 398 399 size = lseek( f, 0, SEEK_END ); 400 401 ret = malloc( size + 127 ); 402 if ( ret == 0 ) 403 { 404 close( f ); 405 return 0; 406 } 407 408 ret = (void*) ( ( ( (unsigned int) ret ) + 127 ) & ~127 ); 409 410 lseek( f, 0, SEEK_SET ); 411 read( f, ret, size ); 412 close( f ); 413 414 return ret; 415} 416 417 418 419void debugSaveGameDirect() 420{ 421 422 C4JThread* thread = new C4JThread(&IUIScene_PauseMenu::SaveWorldThreadProc, NULL, "debugSaveGameDirect"); 423 thread->Run(); 424 thread->WaitForCompletion(1000); 425} 426 427void LoadSysModule(uint16_t module, const char* moduleName) 428{ 429 int ret = cellSysmoduleLoadModule(module); 430 if(ret != CELL_OK) 431 { 432#ifndef _CONTENT_PACKAGE 433 printf("Error cellSysmoduleLoadModule %s failed (%d) \n", moduleName, ret ); 434#endif 435 assert(0); 436 } 437} 438 439#define LOAD_PS3_MODULE(m) LoadSysModule(m, #m) 440 441int simpleMessageBoxCallback( UINT uiTitle, UINT uiText, 442 UINT *uiOptionA, UINT uiOptionC, DWORD dwPad, 443 int(*Func) (LPVOID,int,const C4JStorage::EMessageResult), 444 LPVOID lpParam ) 445{ 446 ui.RequestMessageBox( uiTitle, uiText, 447 uiOptionA, uiOptionC, dwPad, 448 Func, lpParam, app.GetStringTable(), 449 NULL, 0 450 ); 451 452 return 0; 453} 454 455void RegisterAwardsWithProfileManager() 456{ 457 // register the awards 458 ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, eAwardType_Achievement); 459 ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, eAwardType_Achievement); 460 ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, eAwardType_Achievement); 461 ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, eAwardType_Achievement); 462 ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, eAwardType_Achievement); 463 ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, eAwardType_Achievement); 464 ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, eAwardType_Achievement); 465 ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, eAwardType_Achievement); 466 ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, eAwardType_Achievement); 467 ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, eAwardType_Achievement); 468 ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, eAwardType_Achievement); 469 ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, eAwardType_Achievement); 470 ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, eAwardType_Achievement); 471 ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, eAwardType_Achievement); 472 ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, eAwardType_Achievement); 473 ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, eAwardType_Achievement); 474 ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, eAwardType_Achievement); 475 ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, eAwardType_Achievement); 476 ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, eAwardType_Achievement); 477 ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, eAwardType_Achievement); 478 479 ProfileManager.RegisterAward(eAward_snipeSkeleton, ACHIEVEMENT_21, eAwardType_Achievement); // 'Sniper Duel' 480 ProfileManager.RegisterAward(eAward_diamonds, ACHIEVEMENT_22, eAwardType_Achievement); // 'DIAMONDS!' 481 ProfileManager.RegisterAward(eAward_ghast, ACHIEVEMENT_23, eAwardType_Achievement); // 'Return To Sender' 482 ProfileManager.RegisterAward(eAward_blazeRod, ACHIEVEMENT_24, eAwardType_Achievement); // 'Into Fire' 483 ProfileManager.RegisterAward(eAward_potion, ACHIEVEMENT_25, eAwardType_Achievement); // 'Local Brewery' 484 ProfileManager.RegisterAward(eAward_theEnd, ACHIEVEMENT_26, eAwardType_Achievement); // 'The End?' 485 ProfileManager.RegisterAward(eAward_winGame, ACHIEVEMENT_27, eAwardType_Achievement); // 'The End.' 486 ProfileManager.RegisterAward(eAward_enchantments, ACHIEVEMENT_28, eAwardType_Achievement); // 'Enchanter' 487 488#if 0 489 ProfileManager.RegisterAward(eAward_mine100Blocks, GAMER_PICTURE_GAMERPIC1, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC1,IDS_CONFIRM_OK); 490 ProfileManager.RegisterAward(eAward_kill10Creepers, GAMER_PICTURE_GAMERPIC2, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC2,IDS_CONFIRM_OK); 491 492 ProfileManager.RegisterAward(eAward_eatPorkChop, AVATARASSETAWARD_PORKCHOP_TSHIRT, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR1,IDS_CONFIRM_OK); 493 ProfileManager.RegisterAward(eAward_play100Days, AVATARASSETAWARD_WATCH, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR2,IDS_CONFIRM_OK); 494 ProfileManager.RegisterAward(eAward_arrowKillCreeper, AVATARASSETAWARD_CAP, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR3,IDS_CONFIRM_OK); 495 496 ProfileManager.RegisterAward(eAward_socialPost, 0, eAwardType_Theme,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_THEME,IDS_CONFIRM_OK,THEME_NAME,THEME_FILESIZE); 497#endif 498 // Rich Presence init - number of presences, number of contexts 499 //printf("Rich presence strings are hard coded on PS3 for now, must change this!\n"); 500 ProfileManager.RichPresenceInit(-1,-1); // 4J-JEV - Presence and Context count not used. 501 ProfileManager.SetRichPresenceSettingFn(SQRNetworkManager_PS3::SetRichPresence); 502 char *pchRichPresenceString; 503 504 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE); 505 ProfileManager.RichPresenceRegisterContext(CONTEXT_GAME_STATE, pchRichPresenceString); 506 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_IDLE); 507 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_IDLE, pchRichPresenceString); 508 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MENUS); 509 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MENUS, pchRichPresenceString); 510 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER); 511 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER, pchRichPresenceString); 512 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYEROFFLINE); 513 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, pchRichPresenceString); 514 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1P); 515 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1P, pchRichPresenceString); 516 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1POFFLINE); 517 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, pchRichPresenceString); 518 519 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BLANK); 520 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BLANK, pchRichPresenceString); 521 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_PIG); 522 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_PIG, pchRichPresenceString); 523 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_MINECART); 524 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_MINECART, pchRichPresenceString); 525 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BOATING); 526 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BOATING, pchRichPresenceString); 527 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FISHING); 528 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FISHING, pchRichPresenceString); 529 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CRAFTING); 530 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CRAFTING, pchRichPresenceString); 531 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FORGING); 532 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FORGING, pchRichPresenceString); 533 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_NETHER); 534 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_NETHER, pchRichPresenceString); 535 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CD); 536 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CD, pchRichPresenceString); 537 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_MAP); 538 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_MAP, pchRichPresenceString); 539 540 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ENCHANTING); 541 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ENCHANTING, pchRichPresenceString); 542 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BREWING); 543 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BREWING, pchRichPresenceString); 544 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ANVIL); 545 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ANVIL, pchRichPresenceString); 546 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_TRADING); 547 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_TRADING, pchRichPresenceString); 548 549} 550 551int LoadSysModules() 552{ 553 cellSysmoduleInitialize(); 554 555 LOAD_PS3_MODULE(CELL_SYSMODULE_FS ); 556 // 4J Stu - For Iggy 557 LOAD_PS3_MODULE(CELL_SYSMODULE_RTC); 558 // string conversions 559 LOAD_PS3_MODULE(CELL_SYSMODULE_L10N ); 560 // on-screen keyboard 561 LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_OSK_EXT ); 562 // Networking 563 //First load the Network module PRX 564 LOAD_PS3_MODULE(CELL_SYSMODULE_NET); 565 //Load the libnetctl network connection information module PRX 566 LOAD_PS3_MODULE(CELL_SYSMODULE_NETCTL); 567 LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_NP2 ); 568 LOAD_PS3_MODULE(CELL_SYSMODULE_RUDP ); 569 LOAD_PS3_MODULE(CELL_SYSMODULE_HTTP); 570 LOAD_PS3_MODULE(CELL_SYSMODULE_HTTPS); 571 LOAD_PS3_MODULE(CELL_SYSMODULE_HTTP_UTIL); 572 LOAD_PS3_MODULE(CELL_SYSMODULE_SSL); 573 LOAD_PS3_MODULE(CELL_SYSMODULE_JPGDEC); 574 LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_AVCHAT2); 575 576 // 4J-PB - Get launch parameters 577 LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_GAME); 578 LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_NP_COMMERCE2); 579 580 LOAD_PS3_MODULE(CELL_SYSMODULE_AVCONF_EXT); 581 582 LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_SAVEDATA); 583 584 unsigned int uiType ; 585 unsigned int uiAttributes ; 586 CellGameContentSize size,sizeBD; 587 char *dirName=getDirName(); 588 char *contentInfoPath = getConsoleHomePath(); 589 char *usrdirPath= getUsrDirPath(); 590 char *contentInfoPathBDPatch = getConsoleHomePathBDPatch(); 591 char *usrdirPathBDPatch= getUsrDirPathBDPatch(); 592 int ret; 593 bool bBootedFromBDPatch=false; 594 595 memset(&size, 0x00, sizeof(CellGameContentSize)); 596 597 ret = cellGameBootCheck( &uiType, &uiAttributes, &size, dirName ) ; 598 if(ret < 0) 599 { 600 DEBUG_PRINTF("cellGameBootCheck() Error: 0x%x\n", ret); 601 } 602 else 603 { 604 DEBUG_PRINTF("cellGameBootCheck() OK\n"); 605 DEBUG_PRINTF(" get_type = [%d] get_attributes = [0x%08x] dirName = [%s]\n", uiType, uiAttributes, dirName); 606 DEBUG_PRINTF(" hddFreeSizeKB = [%d] sizeKB = [%d] sysSizeKB = [%d]\n", size.hddFreeSizeKB, size.sizeKB, size.sysSizeKB); 607 } 608 609 if (uiAttributes & CELL_GAME_ATTRIBUTE_INVITE_MESSAGE) 610 { 611 g_bBootedFromInvite = true; 612 DEBUG_PRINTF("Booted from invite\n"); 613 } 614 if (uiAttributes & CELL_GAME_ATTRIBUTE_CUSTOM_DATA_MESSAGE) 615 { 616 DEBUG_PRINTF("Booted from custom data\n"); 617 //bootedFromCustomData = true; 618 } 619 if(uiAttributes&CELL_GAME_ATTRIBUTE_PATCH) 620 { 621 // Booted from a patch (only for a disc boot game) 622 // To access patch game data, obtain its path by separately using cellGamePatchCheck(). 623 bBootedFromBDPatch=true; 624 app.SetBootedFromDiscPatch(); 625 } 626 // true if booting from disc, false if booting from HDD 627 StorageManager.SetBootTypeDisc(uiType == CELL_GAME_GAMETYPE_DISC); 628 629 StorageManager.SetMessageBoxCallback(&simpleMessageBoxCallback); 630 631 cellGameContentPermit(contentInfoPath,usrdirPath); 632 DEBUG_PRINTF("contentInfoPath - %s\n",contentInfoPath); 633 DEBUG_PRINTF("usrdirPath - %s\n",usrdirPath); 634 635 ret=cellGamePatchCheck(&sizeBD,NULL); 636 if(ret < 0) 637 { 638 DEBUG_PRINTF("cellGamePatchCheck() Error: 0x%x\n", ret); 639 } 640 else 641 { 642 DEBUG_PRINTF("cellGamePatchCheck() OK - we were booted from a disc patch!\n"); 643 644 cellGameContentPermit(contentInfoPathBDPatch,usrdirPathBDPatch); 645 DEBUG_PRINTF("contentInfoPath - %s\n",contentInfoPathBDPatch); 646 DEBUG_PRINTF("usrdirPath - %s\n",usrdirPathBDPatch); 647 648 app.SetDiscPatchUsrDir(usrdirPathBDPatch); 649 } 650 651 if(uiAttributes&CELL_GAME_ATTRIBUTE_DEBUG) 652 { 653 DEBUG_PRINTF("Booted from debugger\n"); 654#ifndef _RELEASE_FOR_ART 655 strcat(contentInfoPath,"/Minecraft.Client"); 656 strcpy(usrdirPath,contentInfoPath); 657#endif 658 } 659 else 660 { 661 //strcat(contentInfoPath,"/"); 662 //strcat(usrdirPath,"/"); 663 } 664 665 return size.hddFreeSizeKB; 666} 667 668 669 670 671int main() 672{ 673 ShutdownManager::Initialise(); 674 675 sys_memory_info_t mem_info; 676 sys_memory_get_user_memory_size(&mem_info); 677 678#ifndef _CONTENT_PACKAGE 679 printf("------------------------------------------------------\n"); 680 printf("------------------------------------------------------\n"); 681 printf("total_user_memory : %.02f\n", mem_info.total_user_memory / (1024.0f*1024.0f)); 682 printf("available_user_memory : %.02f", mem_info.available_user_memory / (1024.0f*1024.0f)); 683 printf("------------------------------------------------------\n"); 684 printf("------------------------------------------------------\n"); 685#endif 686 687 // 688 // initialize the ps3 689 // 690 691 int ihddFreeSizeKB=LoadSysModules(); 692 ProfileManager.SetHDDFreeKB(ihddFreeSizeKB); 693 // Sony request that we have enough space for a save game, so people don't get hit with this when they first save. Going to make the space 20MB 694 ProfileManager.SetMinSaveKB(20000); 695 696 cellSysutilEnableBgmPlayback(); 697 698 C4JThread_SPU::initSPURS(); 699 700#ifndef DISABLE_MILES_SOUND 701 702#ifdef USE_SPURS 703 void * spurs_info[ 2 ]; 704 spurs_info[ 0 ] = C4JThread_SPU::getSpurs2(); 705 extern const CellSpursTaskBinInfo _binary_task_mssspurs_elf_taskbininfo; 706 spurs_info[1] = (void*)_binary_task_mssspurs_elf_taskbininfo.eaElf; 707 708 // 709 // load it on an SPU 710 // 711 712 if ( !MilesStartAsyncThread( 0, spurs_info ) ) 713 { 714#ifndef _CONTENT_PACKAGE 715 printf( "Error loading SPU image.\n" ); 716#endif 717 return( 5 ); 718 } 719 720#else 721 722 // 723 // Start an SPU thread on SPU threads or RAW 724 // 725 726 { 727 sys_spu_image_t spu_image; 728 char selfPath[256]; 729 sprintf(selfPath,"%s%s%s", getUsrDirPath(), SPU_SELF_PATH, "mssraw.elf" ); 730 731 if ( sys_spu_image_open( &spu_image, selfPath ) != CELL_OK ) 732 { 733 printf( "Error loading SPU image.\n" ); 734 return( 4 ); 735 } 736 737 if ( !MilesStartAsyncThread( 0, &spu_image ) ) 738 { 739 printf( "Error loading SPU image.\n" ); 740 return( 5); 741 } 742 743 // 744 // now close the image, since the system caches it for us 745 // 746 747 sys_spu_image_close( &spu_image ); 748 } 749 750#endif 751 752 753 // 754 // now initialize libAudio 755 // 756 757 cellAudioInit(); 758 759#endif // DISABLE_MILES_SOUND 760 761 // 4J-JEV: Moved this here in case some archived files are compressed. 762 Compression::CreateNewThreadStorage(); 763 764 EdgeZLib::Init(C4JThread_SPU::getSpurs2()); 765 766 RenderManager.Initialise(); 767 768 // Read the file containing the product codes 769 if(app.ReadProductCodes()==FALSE) 770 { 771 // can't continue 772 app.FatalLoadError(); 773 } 774 775 StorageManager.SetDLCProductCode(app.GetProductCode(),app.GetDiscProductCode()); 776 if(StorageManager.GetBootTypeDisc()) 777 { 778 StorageManager.SetBDPatchUsrDir(app.GetDiscPatchUsrDir()); 779 } 780 StorageManager.SetProductUpgradeKey(app.GetUpgradeKey()); 781 ProfileManager.SetServiceID(app.GetCommerceCategory()); 782 783 switch(app.GetProductSKU()) 784 { 785 case e_sku_SCEE: 786 // 4J-PB - need to be online to do this check, so let's stick with the 7+, and move this 787 788 if(StorageManager.GetBootTypeDisc()) 789 { 790 // set Europe age, then hone down specific countries 791 ProfileManager.SetMinimumAge(7,0); // PEGI 7+ 792 ProfileManager.SetGermanyMinimumAge(6); // USK 6+ 793 ProfileManager.SetAustraliaMinimumAge(8); // PG rating has no age, but for some reason the testers are saying it's 8 794 ProfileManager.SetRussiaMinimumAge(6); 795 } 796 else 797 { 798 // PEGI 7+ 799 ProfileManager.SetMinimumAge(7,0); 800 } 801 break; 802 case e_sku_SCEA: 803 // ESRB EVERYONE 10+ 804 ProfileManager.SetMinimumAge(10,1); 805 break; 806 case e_sku_SCEJ: 807 // CERO A 808 ProfileManager.SetMinimumAge(0,2); 809 break; 810 } 811 812 // Initialise NpBasic - this used to be in the network manager but other things need this so moved out on its own 813 void *np_pool = memalign( 8, SQRNetworkManager::NP_POOL_SIZE ); 814 int ret = sceNp2Init( SQRNetworkManager::NP_POOL_SIZE, np_pool ); 815 if( ret < 0 ) 816 { 817 assert(0); 818 } 819 820 821 app.loadMediaArchive(); 822 823 app.DebugPrintf("+++Main - after app.loadMediaArchive\n"); 824 825 app.loadStringTable(); 826 827 // Set the number of possible joypad layouts that the user can switch between, and the number of actions 828 // Need to init Input before UI so we know what the Circle/Cross state is 829 InputManager.Initialise(1,3,MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); 830 831 // Set the default joypad action mappings for Minecraft 832 DefineActions(); 833 InputManager.SetJoypadMapVal(0,0); 834 InputManager.SetKeyRepeatRate(0.3f,0.2f); 835 836 if(RenderManager.IsWidescreen()) 837 ui.init(1280,720); 838 else 839 ui.init(1280,480); 840 841 app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL 842 // 4J-PB - Kick of the check for trial or full version - requires ui to be initialised 843 app.GetCommerce()->CheckForTrialUpgradeKey(); 844 845 static bool bTrialTimerDisplayed=true; 846 847 848 //////////////// 849 // Initialise // 850 //////////////// 851 852#if 0 853 // 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params 854 // are just copied from a sample app and may need changed for our purposes 855 // Start XAudio2 856 hr = XAudio2Create( &g_pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR ); 857 if( FAILED( hr ) ) 858 { 859 app.DebugPrintf( "Initializing XAudio2 failed (err = 0x%08x)!\n", hr ); 860 app.FatalLoadError(); 861 } 862 863 // Create an XAudio2 mastering voice (utilized by XHV2 when voice data is mixed to main speakers) 864 hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL); 865 if ( FAILED( hr ) ) 866 { 867 app.DebugPrintf( "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr ); 868 app.FatalLoadError(); 869 } 870#endif 871 872 app.InitTime(); 873 874 875 // Initialise the profile manager with the game Title ID, Offer ID, a profile version number, and the number of profile values and settings 876 ProfileManager.Initialise(SQRNetworkManager_PS3::GetSceNpCommsId(), 877 SQRNetworkManager_PS3::GetSceNpCommsSig(), 878 PROFILE_VERSION_10, 879 NUM_PROFILE_VALUES, 880 NUM_PROFILE_SETTINGS, 881 dwProfileSettingsA, 882 app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, 883 &app.uiGameDefinedDataChangedBitmask); 884 885 app.DebugPrintf("+++Main - after ProfileManager.Initialise\n"); 886 887 // register the awards 888 RegisterAwardsWithProfileManager(); 889 890 // register the get string function with the profile lib, so it can be called within the lib 891 892 ProfileManager.SetGetStringFunc(&CConsoleMinecraftApp::GetString); 893 ProfileManager.SetPlayerListTitleID(IDS_PLAYER_LIST_TITLE); 894 ProfileManager.SetSignInQuestionID(IDS_SIGNIN_PSN); 895 896 // initialise the storage manager with a callback for displaying the saving message 897 StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,(LPVOID)&app,""); 898 899#if 0 900 901 // Set up the global title storage path 902 StorageManager.StoreTMSPathName(); 903#endif 904 905 // 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 906 907 //app.FatalLoadError(); 908 909 910 // 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 911 ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app); 912 913#if 0 914 // set a function to be called when the ethernet is disconnected, so we can back out if required 915 ProfileManager.SetNotificationsCallback(&CConsoleMinecraftApp::NotificationsCallback,(LPVOID)&app); 916#endif 917 // Set a callback for the default player options to be set - when there is no profile data for the player 918 919 StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); 920 StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,(LPVOID)&app); 921 922 // Set a callback to deal with old profile versions needing updated to new versions 923#if 0 924 ProfileManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app); 925 926 // Set a callback for when there is a read error on profile data 927 ProfileManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback,(LPVOID)&app); 928 929 // QNet needs to be setup after profile manager, as we do not want its Notify listener to handle 930 // XN_SYS_SIGNINCHANGED notifications. This does mean that we need to have a callback in the 931 // ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet. 932#endif // 0 933 934 SonyRemoteStorage_PS3* pRemote = (SonyRemoteStorage_PS3*)app.getRemoteStorage(); 935 pRemote->SetSecureID(secureFileId); 936 pRemote->SetServiceID(app.GetCommerceCategory()); 937 938 // Before using any save/load on PS3, we need a secure id set 939 StorageManager.InitialiseProfileData(PROFILE_VERSION_10, 940 NUM_PROFILE_VALUES, 941 NUM_PROFILE_SETTINGS, 942 dwProfileSettingsA, 943 app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, 944 &app.uiGameDefinedDataChangedBitmask); 945 946 app.DebugPrintf("+++Main - after InitialiseProfileData\n"); 947 948 949 StorageManager.SetSecureID(secureFileId); 950 // set the name of the folder on the XMB that the saves are grouped in 951 // 4J-PB - TRC that we need to be able to see the BD in a different titled save from the digital game 952 if(StorageManager.GetBootTypeDisc()) 953 { 954 wstring wsTemp = app.GetString(IDS_GAMENAME); 955 WCHAR wchTemp[64]; 956 wsTemp.append(L" ("); 957 mbstowcs(wchTemp,app.GetDiscProductCode(),64); 958 wsTemp.append(wchTemp); 959 wsTemp.append(L")"); 960 StorageManager.SetGameSaveFolderTitle((WCHAR *)(wsTemp.c_str())); 961 } 962 else 963 { 964 StorageManager.SetGameSaveFolderTitle((WCHAR *)app.GetString(IDS_GAMENAME));//"Minecraft: PlayStation�3 Edition");//GAMENAME); 965 } 966 StorageManager.SetSaveCacheFolderTitle((WCHAR *)app.GetString(IDS_SAVECACHEFILE));//"Minecraft: PlayStation�3 Edition");//GAMENAME); 967 StorageManager.SetOptionsFolderTitle((WCHAR *)app.GetString(IDS_OPTIONSFILE));//"Minecraft: PlayStation�3 Edition");//GAMENAME); 968 StorageManager.SetGameSaveFolderPrefix(app.GetSaveFolderPrefix()); 969 StorageManager.SetMaxSaves(99); 970 byteArray baOptionsIcon = app.getArchiveFile(L"DefaultOptionsImage320x176.png"); 971 byteArray baSaveThumbnail = app.getArchiveFile(L"DefaultSaveThumbnail64x64.png"); 972 byteArray baSaveImage = app.getArchiveFile(L"DefaultSaveImage320x176.png"); 973 974 uint8_t *szTemp = mallocAndCreateUTF8ArrayFromString(IDS_NODEVICE_DECLINE); 975 StorageManager.SetContinueWithoutSavingMessage((char *)szTemp); 976 free(szTemp); 977 StorageManager.SetDefaultImages((PBYTE)baOptionsIcon.data, baOptionsIcon.length,(PBYTE)baSaveImage.data, baSaveImage.length,(PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); 978 979 if(baOptionsIcon.data!=NULL) 980 { 981 delete [] baOptionsIcon.data; 982 } 983 984 if(baSaveThumbnail.data!=NULL) 985 { 986 delete [] baSaveThumbnail.data; 987 } 988 989 if(baSaveImage.data!=NULL) 990 { 991 delete [] baSaveImage.data; 992 } 993 994 wstring wsName=L"Graphics\\SaveChest.png"; 995 byteArray baSaveLoadIcon = app.getArchiveFile(wsName); 996 if(baSaveLoadIcon.data!=NULL) 997 { 998 StorageManager.SetSaveLoadIcon((PBYTE)baSaveLoadIcon.data, baSaveLoadIcon.length); 999 delete [] baSaveLoadIcon.data; 1000 } 1001 1002 // defaults 1003 StorageManager.SetSaveTitle(L"Default Save"); 1004 1005 // debug switch to trial version 1006// ProfileManager.SetDebugFullOverride(true); 1007 1008 //ProfileManager.AddDLC(2); 1009 StorageManager.SetDLCPackageRoot("DLCDrive"); 1010 StorageManager.RegisterMarketplaceCountsCallback(&CConsoleMinecraftApp::MarketplaceCountsCallback,(LPVOID)&app); 1011 1012 // Initialise TLS for tesselator, for this main thread 1013 Tesselator::CreateNewThreadStorage(1024*1024); 1014 // Initialise TLS for AABB and Vec3 pools, for this main thread 1015 AABB::CreateNewThreadStorage(); 1016 Vec3::CreateNewThreadStorage(); 1017 IntCache::CreateNewThreadStorage(); 1018 OldChunkStorage::CreateNewThreadStorage(); 1019 Level::enableLightingCache(); 1020 Tile::CreateNewThreadStorage(); 1021 1022 Minecraft::main(); 1023 Minecraft *pMinecraft=Minecraft::GetInstance(); 1024 1025 app.InitGameSettings(); // - allocates the memory for the game settings 1026 // read the options here for controller 0 - this won't actually be actioned until a storagemanager tick later 1027 StorageManager.ReadFromProfile(0); 1028 1029 // set the default profile values 1030 // 4J-PB - InitGameSettings already does this 1031 /*for(int i=0;i<XUSER_MAX_COUNT;i++) 1032 { 1033#ifdef __PS3__ 1034 app.SetDefaultOptions(StorageManager.GetDashboardProfileSettings(i),i); 1035#else 1036 app.SetDefaultOptions(ProfileManager.GetDashboardProfileSettings(i),i); 1037#endif 1038 }*/ 1039 1040 // set the achievement text for a trial achievement, now we have the string table loaded 1041 ProfileManager.SetTrialTextStringTable(NULL, IDS_CONFIRM_OK, IDS_CONFIRM_CANCEL); 1042 ProfileManager.SetTrialAwardText(eAwardType_Achievement,IDS_UNLOCK_TITLE,IDS_UNLOCK_ACHIEVEMENT_TEXT); 1043#ifndef __PS3__ 1044 ProfileManager.SetTrialAwardText(eAwardType_GamerPic,IDS_UNLOCK_TITLE,IDS_UNLOCK_GAMERPIC_TEXT); 1045 ProfileManager.SetTrialAwardText(eAwardType_AvatarItem,IDS_UNLOCK_TITLE,IDS_UNLOCK_AVATAR_TEXT); 1046#endif 1047 ProfileManager.SetTrialAwardText(eAwardType_Theme,IDS_UNLOCK_TITLE,IDS_UNLOCK_THEME_TEXT); 1048 ProfileManager.SetUpsellCallback(&app.UpsellReturnedCallback,&app); 1049 1050 app.InitialiseTips(); 1051 1052 1053 // set the callback for losing input (when a system type ui is up) 1054 1055 InputManager.SetLostInputControlCallback(&UIController::SetSystemUIShowing,&ui); 1056 1057 1058#ifndef _FINAL_BUILD 1059#ifndef _DEBUG 1060 #pragma message(__LOC__"Need to define the _FINAL_BUILD before submission") 1061#endif 1062#endif 1063 1064 1065 1066#if 0 1067 1068 DWORD initData=0; 1069 // Set the default sound levels 1070 pMinecraft->options->set(Options::Option::MUSIC,1.0f); 1071 pMinecraft->options->set(Options::Option::SOUND,1.0f); 1072 1073 app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_Intro,&initData); 1074#endif 1075 1076 1077 1078 LeaderboardManager::Instance()->OpenSession(); 1079 //LeaderboardManager::Instance()->ReadStats_TopRank(DebugReadListener::m_instance, 0, LeaderboardManager::eStatsType_Travelling, 1, 1); 1080 1081 // 4J-PB - we really need to know at this point if we are playing the trial or full game, so sleep until we know 1082 while(app.GetCommerce()->LicenseChecked()==false) 1083 { 1084 cellSysutilCheckCallback(); 1085 Sleep(50); 1086 } 1087 // wait for the trophy init to complete - nonblocking semaphore 1088 while((ProfileManager.tryWaitTrophyInitComplete()<0)&&ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) 1089 { 1090 // keep looping 1091 RenderManager.Tick(); 1092 RenderManager.Present(); 1093 cellSysutilCheckCallback(); 1094 Sleep(50); 1095 } 1096 1097 app.DebugPrintf("+++Main - after tryWaitTrophyInitComplete\n"); 1098 1099 if(ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) 1100 { 1101 g_NetworkManager.Initialise(); 1102 g_NetworkManager.SetLocalGame(true); 1103 } 1104 1105 //ProfileManager.WaitTrophyInitComplete(); 1106 1107 // 4J-PB - get the chat/UGC restriction flag here so we can stop online games, and content rating and restriction 1108 // It's ok to do this for the primary PSN player here - it has this data locally. All other players need to do it on PSN sign in. 1109 1110// bool bChatRestricted=false; 1111// ProfileManager.GetChatAndContentRestrictions(0,&bChatRestricted,NULL,NULL); 1112 1113 // 4J-PB - really want to wait until we've read the options, so we can set the right language if they've chosen one other than the default 1114// bool bOptionsRead=false; 1115// 1116// while((bOptionsRead==false) && ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) 1117// { 1118// switch(app.GetOptionsCallbackStatus(0)) 1119// { 1120// case C4JStorage::eOptions_Callback_Idle: 1121// break; 1122// default: 1123// bOptionsRead=true; 1124// break; 1125// } 1126// StorageManager.Tick(); 1127// } 1128// 1129// if(ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) 1130// { 1131// app.loadStringTable(); 1132// ui.SetupFont(); 1133// //handleReload(); 1134// } 1135 1136 while( ShutdownManager::ShouldRun(ShutdownManager::eMainThread) ) 1137 { 1138#if 0 1139 if(pMinecraft->soundEngine->isStreamingWavebankReady() && 1140 !pMinecraft->soundEngine->isPlayingStreamingGameMusic() && 1141 !pMinecraft->soundEngine->isPlayingStreamingCDMusic() ) 1142 { 1143 // play some music in the menus 1144 pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false); 1145 } 1146#endif 1147 app.UpdateTime(); 1148 PIXBeginNamedEvent(0,"Input manager tick"); 1149 InputManager.Tick(); 1150 PIXEndNamedEvent(); 1151 PIXBeginNamedEvent(0,"Profile manager tick"); 1152 ProfileManager.Tick(); 1153 PIXEndNamedEvent(); 1154 PIXBeginNamedEvent(0,"Storage manager tick"); 1155 StorageManager.Tick(); 1156 PIXEndNamedEvent(); 1157 PIXBeginNamedEvent(0,"Render manager tick"); 1158 RenderManager.Tick(); 1159 PIXEndNamedEvent(); 1160 1161 1162 // Tick the social networking manager. 1163 PIXBeginNamedEvent(0,"Social network manager tick"); 1164// CSocialManager::Instance()->Tick(); 1165 PIXEndNamedEvent(); 1166 1167 // Tick sentient. 1168 PIXBeginNamedEvent(0,"Sentient tick"); 1169 MemSect(37); 1170// SentientManager.Tick(); 1171 MemSect(0); 1172 PIXEndNamedEvent(); 1173 1174 PIXBeginNamedEvent(0,"Network manager do work #1"); 1175 g_NetworkManager.DoWork(); 1176 PIXEndNamedEvent(); 1177 // 4J-PB - these get set every tick causing the write profile flag to be true all the time - 1178// app.SetGameSettingsDebugMask(0,eDebugSetting_LoadSavesFromDisk); 1179// app.SetGameSettingsDebugMask(0,eDebugSetting_WriteSavesToDisk); 1180// app.SetLoadSavesFromFolderEnabled(true); 1181// app.SetWriteSavesToFolderEnabled(true); 1182 1183 LeaderboardManager::Instance()->Tick(); 1184 // Render game graphics. 1185 if(app.GetGameStarted()) 1186 { 1187 1188// if(InputManager.ButtonPressed(0, MINECRAFT_ACTION_SNEAK_TOGGLE)) 1189// { 1190// app.DebugPrintf("saving game...\n"); 1191// debugSaveGameDirect(); 1192// 1193// } 1194 pMinecraft->run_middle(); 1195 app.SetAppPaused( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) ); 1196 } 1197 else 1198 { 1199 MemSect(28); 1200 pMinecraft->soundEngine->tick(NULL, 0.0f); 1201 MemSect(0); 1202 pMinecraft->textures->tick(true,false); 1203 IntCache::Reset(); 1204 if( app.GetReallyChangingSessionType() ) 1205 { 1206 pMinecraft->tickAllConnections(); // Added to stop timing out when we are waiting after converting to an offline game 1207 } 1208 } 1209 1210 pMinecraft->soundEngine->playMusicTick(); 1211 1212#ifdef MEMORY_TRACKING 1213 static bool bResetMemTrack = false; 1214 static bool bDumpMemTrack = false; 1215 1216 MemPixStuff(); 1217 1218 if( bResetMemTrack ) 1219 { 1220 ResetMem(); 1221 MEMORYSTATUS memStat; 1222 GlobalMemoryStatus(&memStat); 1223 printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); 1224 bResetMemTrack = false; 1225 } 1226 1227 if( bDumpMemTrack ) 1228 { 1229 DumpMem(); 1230 bDumpMemTrack = false; 1231 MEMORYSTATUS memStat; 1232 GlobalMemoryStatus(&memStat); 1233 printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); 1234 printf("Renderer used: %d\n",RenderManager.CBuffSize(-1)); 1235 } 1236#endif 1237#if 0 1238 static bool bDumpTextureUsage = false; 1239 if( bDumpTextureUsage ) 1240 { 1241 RenderManager.TextureGetStats(); 1242 bDumpTextureUsage = false; 1243 } 1244#endif 1245 ui.tick(); 1246 ui.render(); 1247 1248 // Present the frame. 1249 PIXBeginNamedEvent(0,"Frame present"); 1250 RenderManager.Present(); 1251 PIXEndNamedEvent(); 1252 1253 RenderManager.Set_matrixDirty(); 1254 1255 ui.CheckMenuDisplayed(); 1256 PIXBeginNamedEvent(0,"Profile load check"); 1257 // has the game defined profile data been changed (by a profile load) 1258 if(app.uiGameDefinedDataChangedBitmask!=0) 1259 { 1260 void *pData; 1261 for(int i=0;i<XUSER_MAX_COUNT;i++) 1262 { 1263 if(app.uiGameDefinedDataChangedBitmask&(1<<i)) 1264 { 1265 // It has - game needs to update its values with the data from the profile 1266 pData=StorageManager.GetGameDefinedProfileData(i); 1267 // reset the changed flag 1268 app.ClearGameSettingsChangedFlag(i); 1269 app.DebugPrintf("*** - APPLYING GAME SETTINGS CHANGE for pad %d\n",i); 1270 app.ApplyGameSettingsChanged(i); 1271 1272#ifdef _DEBUG_MENUS_ENABLED 1273 if(app.DebugSettingsOn()) 1274 { 1275 app.ActionDebugMask(i); 1276 } 1277 else 1278 { 1279 // force debug mask off 1280 app.ActionDebugMask(i,true); 1281 } 1282#endif 1283 // clear the stats first - there could have beena signout and sign back in in the menus 1284 // need to clear the player stats - can't assume it'll be done in setlevel - we may not be in the game 1285 pMinecraft->stats[ i ]->clear(); 1286 pMinecraft->stats[i]->parse(pData); 1287 } 1288 } 1289 1290 // Check to see if we can post to social networks. 1291 // PS3 TO DO - CSocialManager::Instance()->RefreshPostingCapability(); 1292 1293 // clear the flag 1294 app.uiGameDefinedDataChangedBitmask=0; 1295 1296 // Check if any profile write are needed 1297 //app.CheckGameSettingsChanged(); 1298 } 1299 PIXEndNamedEvent(); 1300 1301#if 0 1302 app.TickDLCOffersRetrieved(); 1303 app.TickTMSPPFilesRetrieved(); 1304#endif 1305 1306 PIXBeginNamedEvent(0,"Network manager do work #2"); 1307 g_NetworkManager.DoWork(); 1308 PIXEndNamedEvent(); 1309 1310#if 0 1311 PIXBeginNamedEvent(0,"Misc extra xui"); 1312 // Update XUI Timers 1313 hr = XuiTimersRun(); 1314#endif 1315 // Any threading type things to deal with from the xui side? 1316 app.HandleXuiActions(); 1317 1318#if 0 1319 PIXEndNamedEvent(); 1320#endif 1321 1322 // 4J-PB - Update the trial timer display if we are in the trial version 1323 if(!ProfileManager.IsFullVersion()) 1324 { 1325 // display the trial timer 1326 if(app.GetGameStarted()) 1327 { 1328 // 4J-PB - if the game is paused, add the elapsed time to the trial timer count so it doesn't tick down 1329 if(app.IsAppPaused()) 1330 { 1331 app.UpdateTrialPausedTimer(); 1332 } 1333 ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad()); 1334 } 1335 } 1336 else 1337 { 1338 // need to turn off the trial timer if it was on , and we've unlocked the full version 1339 if(bTrialTimerDisplayed) 1340 { 1341 ui.ShowTrialTimer(false); 1342 bTrialTimerDisplayed=false; 1343 } 1344 } 1345 1346 // PS3 DLC 1347 app.CommerceTick(); 1348 1349 // Fix for #7318 - Title crashes after short soak in the leaderboards menu 1350 // A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset 1351 Vec3::resetPool(); 1352 } 1353 1354 // Free resources, unregister custom classes, and exit. 1355// app.Uninit(); 1356// g_pd3dDevice->Release(); 1357 1358#if HEAPINSPECTOR_PS3 1359 HeapInspectorServer::Shutdown(); 1360#endif // HEAPINSPECTOR_PS3 1361 1362 ShutdownManager::MainThreadHandleShutdown(); 1363} 1364 1365vector<uint8_t *> vRichPresenceStrings; 1366uint8_t * AddRichPresenceString(int iID) 1367{ 1368 uint8_t *strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); 1369 if( strUtf8 != NULL ) 1370 { 1371 vRichPresenceStrings.push_back(strUtf8); 1372 } 1373 return strUtf8; 1374} 1375 1376void FreeRichPresenceStrings() 1377{ 1378 uint8_t *strUtf8; 1379 for(int i=0;i<vRichPresenceStrings.size();i++) 1380 { 1381 strUtf8=vRichPresenceStrings.at(i); 1382 free(strUtf8); 1383 } 1384 vRichPresenceStrings.clear(); 1385} 1386 1387 1388#ifdef MEMORY_TRACKING 1389 1390int totalAllocGen = 0; 1391unordered_map<int,int> allocCounts; 1392bool trackEnable = false; 1393bool trackStarted = false; 1394volatile size_t sizeCheckMin = 1160; 1395volatile size_t sizeCheckMax = 1160; 1396volatile int sectCheck = 48; 1397CRITICAL_SECTION memCS; 1398DWORD tlsIdx; 1399 1400LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) 1401{ 1402 if( !trackStarted ) 1403 { 1404 void *p = XMemAllocDefault(dwSize,dwAllocAttributes); 1405 size_t realSize = XMemSizeDefault(p, dwAllocAttributes); 1406 totalAllocGen += realSize; 1407 return p; 1408 } 1409 1410 EnterCriticalSection(&memCS); 1411 1412 void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes); 1413 size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16; 1414 1415 if( trackEnable ) 1416 { 1417#if 1 1418 int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f; 1419 *(((unsigned char *)p)+realSize) = sect; 1420 1421 if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) ) 1422 { 1423 app.DebugPrintf("Found one\n"); 1424 } 1425#endif 1426 1427 if( p ) 1428 { 1429 totalAllocGen += realSize; 1430 trackEnable = false; 1431 int key = ( sect << 26 ) | realSize; 1432 int oldCount = allocCounts[key]; 1433 allocCounts[key] = oldCount + 1; 1434 1435 trackEnable = true; 1436 } 1437 } 1438 1439 LeaveCriticalSection(&memCS); 1440 1441 return p; 1442} 1443 1444void* operator new (size_t size) 1445{ 1446 return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); 1447} 1448 1449void operator delete (void *p) 1450{ 1451 XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); 1452} 1453 1454void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) 1455{ 1456 bool special = false; 1457 if( dwAllocAttributes == 0 ) 1458 { 1459 dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP); 1460 special = true; 1461 } 1462 if(!trackStarted ) 1463 { 1464 size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); 1465 XMemFreeDefault(pAddress, dwAllocAttributes); 1466 totalAllocGen -= realSize; 1467 return; 1468 } 1469 EnterCriticalSection(&memCS); 1470 if( pAddress ) 1471 { 1472 size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; 1473 1474 if(trackEnable) 1475 { 1476 int sect = *(((unsigned char *)pAddress)+realSize); 1477 totalAllocGen -= realSize; 1478 trackEnable = false; 1479 int key = ( sect << 26 ) | realSize; 1480 int oldCount = allocCounts[key]; 1481 allocCounts[key] = oldCount - 1; 1482 trackEnable = true; 1483 } 1484 XMemFreeDefault(pAddress, dwAllocAttributes); 1485 } 1486 LeaveCriticalSection(&memCS); 1487} 1488 1489SIZE_T WINAPI XMemSize( 1490 PVOID pAddress, 1491 DWORD dwAllocAttributes 1492) 1493{ 1494 if( trackStarted ) 1495 { 1496 return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; 1497 } 1498 else 1499 { 1500 return XMemSizeDefault(pAddress, dwAllocAttributes); 1501 } 1502} 1503 1504void DumpMem() 1505{ 1506 int totalLeak = 0; 1507 for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) 1508 { 1509 if(it->second > 0 ) 1510 { 1511 app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second); 1512 totalLeak += ( it->first & 0x03ffffff ) * it->second; 1513 } 1514 } 1515 app.DebugPrintf("Total %d\n",totalLeak); 1516} 1517 1518void ResetMem() 1519{ 1520 if( !trackStarted ) 1521 { 1522 trackEnable = true; 1523 trackStarted = true; 1524 totalAllocGen = 0; 1525 InitializeCriticalSection(&memCS); 1526 tlsIdx = TlsAlloc(); 1527 } 1528 EnterCriticalSection(&memCS); 1529 trackEnable = false; 1530 allocCounts.clear(); 1531 trackEnable = true; 1532 LeaveCriticalSection(&memCS); 1533} 1534 1535void MemSect(int section) 1536{ 1537 unsigned int value = (unsigned int)TlsGetValue(tlsIdx); 1538 if( section == 0 ) // pop 1539 { 1540 value = (value >> 6) & 0x03ffffff; 1541 } 1542 else 1543 { 1544 value = (value << 6) | section; 1545 } 1546 TlsSetValue(tlsIdx, (LPVOID)value); 1547} 1548 1549void MemPixStuff() 1550{ 1551 const int MAX_SECT = 46; 1552 1553 int totals[MAX_SECT] = {0}; 1554 1555 for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) 1556 { 1557 if(it->second > 0 ) 1558 { 1559 int sect = ( it->first >> 26 ) & 0x3f; 1560 int bytes = it->first & 0x03ffffff; 1561 totals[sect] += bytes * it->second; 1562 } 1563 } 1564 1565 unsigned int allSectsTotal = 0; 1566 for( int i = 0; i < MAX_SECT; i++ ) 1567 { 1568 allSectsTotal += totals[i]; 1569 PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i); 1570 } 1571 1572 PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages"); 1573} 1574 1575#endif 1576 1577#endif // __PS3__