the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1// Minecraft.cpp : Defines the entry point for the application.
2//
3
4#include "stdafx.h"
5
6#include "Leaderboards\PSVitaLeaderboardManager.h"
7#include "PSVita\PSVitaExtras\ShutdownManager.h"
8
9//#define HEAPINSPECTOR_PS3 1
10// when defining HEAPINSPECTOR_PS3, add this line to the linker settings
11// --wrap malloc --wrap free --wrap memalign --wrap calloc --wrap realloc --wrap reallocalign --wrap _malloc_init
12
13#if HEAPINSPECTOR_PS3
14#include "HeapInspector\Server\HeapInspectorServer.h"
15#include "HeapInspector\Server\PS3\HeapHooks.hpp"
16#endif
17
18//#define DISABLE_MILES_SOUND
19
20#include "PSVita_App.h"
21#include "PSVitaExtras\PSVitaStrings.h"
22#include "GameConfig\Minecraft.spa.h"
23#include "..\MinecraftServer.h"
24#include "..\LocalPlayer.h"
25#include "..\..\Minecraft.World\ItemInstance.h"
26#include "..\..\Minecraft.World\MapItem.h"
27#include "..\..\Minecraft.World\Recipes.h"
28#include "..\..\Minecraft.World\Recipy.h"
29#include "..\..\Minecraft.World\Language.h"
30#include "..\..\Minecraft.World\StringHelpers.h"
31#include "..\..\Minecraft.World\AABB.h"
32#include "..\..\Minecraft.World\Vec3.h"
33#include "..\..\Minecraft.World\Level.h"
34#include "..\..\Minecraft.World\net.minecraft.world.level.tile.h"
35
36#include "..\ClientConnection.h"
37#include "..\User.h"
38#include "..\..\Minecraft.World\Socket.h"
39#include "..\..\Minecraft.World\ThreadName.h"
40#include "..\..\Minecraft.Client\StatsCounter.h"
41#include "..\ConnectScreen.h"
42//#include "Social\SocialManager.h"
43//#include "Leaderboards\LeaderboardManager.h"
44//#include "XUI\XUI_Scene_Container.h"
45//#include "NetworkManager.h"
46#include "..\..\Minecraft.Client\Tesselator.h"
47#include "..\Common\Console_Awards_enum.h"
48#include "..\..\Minecraft.Client\Options.h"
49#include "Sentient\SentientManager.h"
50#include "..\..\Minecraft.World\IntCache.h"
51#include "..\Textures.h"
52//#include "Resource.h"
53#include "..\..\Minecraft.World\compression.h"
54#include "..\..\Minecraft.World\OldChunkStorage.h"
55//#include "PS3\PS3Extras\EdgeZLib.h"
56#include "..\..\Minecraft.World\C4JThread.h"
57#include "Common\Network\Sony\SQRNetworkManager.h"
58#include "Common\UI\IUIScene_PauseMenu.h"
59#include "Conf.h"
60#include "PSVita/Network/PSVita_NPToolkit.h"
61#include "PSVita\Network\SonyVoiceChat_Vita.h"
62#include "..\..\Minecraft.World\FireworksRecipe.h"
63
64#include <libsysmodule.h>
65#include <libperf.h>
66#include <ult.h>
67#include <apputil.h>
68
69#define THEME_NAME "584111F70AAAAAAA"
70#define THEME_FILESIZE 2797568
71
72/* Encrypted ID for protected data file (*) You must edit these binaries!! */
73/*char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] =
74{
750xEE, 0xA9, 0x37, 0xCC,
760x5B, 0xD4, 0xD9, 0x0D,
770x55, 0xED, 0x25, 0x31,
780xFA, 0x33, 0xBD, 0xC4
79};*/
80
81
82#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device)
83
84//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU
85#define NUM_PROFILE_VALUES 5
86#define NUM_PROFILE_SETTINGS 4
87DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]=
88{
89#ifdef _XBOX
90 XPROFILE_OPTION_CONTROLLER_VIBRATION,
91 XPROFILE_GAMER_YAXIS_INVERSION,
92 XPROFILE_GAMER_CONTROL_SENSITIVITY,
93 XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL,
94 XPROFILE_TITLE_SPECIFIC1,
95#else
96 0,0,0,0,0
97#endif
98};
99
100// functions for storing and converting rich presence strings from wchar to utf8
101uint8_t * AddRichPresenceString(int iID);
102void FreeRichPresenceStrings();
103
104#if HEAPINSPECTOR_PS3
105
106std::vector<HeapInspectorServer::HeapInfo> GetHeapInfo()
107{
108 std::vector<HeapInspectorServer::HeapInfo> result = HeapInspectorServer::GetDefaultHeapInfo();
109 HeapInspectorServer::HeapInfo localHeapInfo;
110 localHeapInfo.m_Description = "VRAM";
111 localHeapInfo.m_Range.m_Min = 0xc0000000;
112 localHeapInfo.m_Range.m_Max = localHeapInfo.m_Range.m_Min + (249*1024*1024);
113 result.push_back(localHeapInfo);
114 return result;
115}
116
117extern "C" void* __real__malloc_init(size_t a_Boundary, size_t a_Size);
118extern "C" void* __wrap__malloc_init(size_t a_Boundary, size_t a_Size)
119{
120 void* result = __real__malloc_init(a_Boundary, a_Size);
121 HeapInspectorServer::Initialise(GetHeapInfo(), 3000, HeapInspectorServer::WaitForConnection_Enabled);
122 return result;
123}
124
125#endif // HEAPINSPECTOR_PS3
126
127//-------------------------------------------------------------------------------------
128// Time Since fAppTime is a float, we need to keep the quadword app time
129// as a LARGE_INTEGER so that we don't lose precision after running
130// for a long time.
131//-------------------------------------------------------------------------------------
132
133BOOL g_bWidescreen = TRUE;
134//int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, this is setup from init_audio_hardware
135
136void DefineActions(void)
137{
138 // The app needs to define the actions required, and the possible mappings for these
139
140 /////////////////////////////////////
141 // VITA
142 /////////////////////////////////////
143
144 // Split into Menu actions, and in-game actions
145 if(InputManager.IsCircleCrossSwapped())
146 {
147 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _PSV_JOY_BUTTON_O);
148 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _PSV_JOY_BUTTON_O);
149 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _PSV_JOY_BUTTON_X);
150 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _PSV_JOY_BUTTON_X);
151 }
152 else
153 {
154 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _PSV_JOY_BUTTON_X);
155 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _PSV_JOY_BUTTON_X);
156 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _PSV_JOY_BUTTON_O);
157 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _PSV_JOY_BUTTON_O);
158 }
159
160 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_X, _PSV_JOY_BUTTON_SQUARE);
161 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_Y, _PSV_JOY_BUTTON_TRIANGLE);
162 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_UP, _PSV_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP);
163 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_DOWN, _PSV_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN);
164 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT, _PSV_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT);
165 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT, _PSV_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT);
166 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LT);
167 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_BACK);
168 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT_SCROLL, _PSV_JOY_BUTTON_R1);
169 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT_SCROLL, _PSV_JOY_BUTTON_L1);
170 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAUSEMENU, _PSV_JOY_BUTTON_START);
171
172 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_STICK_PRESS, _PSV_JOY_BUTTON_DPAD_UP);
173 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB);
174 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP);
175 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN);
176 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT);
177 InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT);
178
179 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_JUMP, _PSV_JOY_BUTTON_X);
180 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP);
181 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN);
182 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT);
183 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT);
184 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT);
185 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT);
186 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP);
187 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN);
188
189 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_USE, _PSV_JOY_BUTTON_L1);
190 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_ACTION, _PSV_JOY_BUTTON_R1);
191 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT_SCROLL, _PSV_JOY_BUTTON_DPAD_RIGHT);
192 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT_SCROLL, _PSV_JOY_BUTTON_DPAD_LEFT);
193 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_INVENTORY, _PSV_JOY_BUTTON_TRIANGLE);
194 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START);
195 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DROP, _PSV_JOY_BUTTON_O);
196 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_SNEAK_TOGGLE, _PSV_JOY_BUTTON_DPAD_DOWN);
197 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_CRAFTING, _PSV_JOY_BUTTON_SQUARE);
198 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PSV_JOY_BUTTON_DPAD_UP);
199 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK);
200
201 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_LEFT, _PSV_JOY_BUTTON_DPAD_LEFT);
202 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_RIGHT, _PSV_JOY_BUTTON_DPAD_RIGHT);
203 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_UP, _PSV_JOY_BUTTON_DPAD_UP);
204 InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_DOWN, _PSV_JOY_BUTTON_DPAD_DOWN);
205 /////////////////////////////////////
206 // VITA TV (Dualshock 3/4 mapping)
207 /////////////////////////////////////
208
209 // Note: this is mapping 0 from the PS3 version
210
211 // Split into Menu actions, and in-game actions
212 if(InputManager.IsCircleCrossSwapped() )
213 {
214 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_B);
215 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _360_JOY_BUTTON_B);
216 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_A);
217 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _360_JOY_BUTTON_A);
218 }
219 else
220 {
221 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_A);
222 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _360_JOY_BUTTON_A);
223 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_B);
224 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B);
225 }
226
227 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_X, _360_JOY_BUTTON_X);
228 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_Y, _360_JOY_BUTTON_Y);
229 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP);
230 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN);
231 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT);
232 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT);
233 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LT);
234 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT);
235 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB);
236 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB);
237 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START);
238
239 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB);
240 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB);
241 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP);
242 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN);
243 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT);
244 InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT);
245
246 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_A);
247 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP);
248 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN);
249 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT);
250 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT);
251 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT);
252 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT);
253 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP);
254 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN);
255
256 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_LT);
257 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_RT);
258 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_RB);
259 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_LB);
260 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y);
261 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START);
262 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B);
263 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_RTHUMB);
264 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X);
265 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB);
266 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK);
267
268 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT);
269 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT);
270 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP);
271 InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN);
272}
273
274
275//#define MEMORY_TRACKING
276
277#ifdef MEMORY_TRACKING
278void ResetMem();
279void DumpMem();
280void MemPixStuff();
281#else
282void MemSect(int sect)
283{
284}
285#endif
286
287
288void debugSaveGameDirect()
289{
290
291 C4JThread* thread = new C4JThread(&IUIScene_PauseMenu::SaveWorldThreadProc, NULL, "debugSaveGameDirect");
292 thread->Run();
293 thread->WaitForCompletion(1000);
294}
295
296int simpleMessageBoxCallback( UINT uiTitle, UINT uiText,
297 UINT *uiOptionA, UINT uiOptionC, DWORD dwPad,
298 int(*Func) (LPVOID,int,const C4JStorage::EMessageResult),
299 LPVOID lpParam )
300{
301 ui.RequestErrorMessage( uiTitle, uiText, uiOptionA, uiOptionC, dwPad, Func, lpParam);
302
303 return 0;
304}
305
306void RegisterAwardsWithProfileManager()
307{
308 // register the awards
309 ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, eAwardType_Achievement);
310 ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, eAwardType_Achievement);
311 ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, eAwardType_Achievement);
312 ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, eAwardType_Achievement);
313 ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, eAwardType_Achievement);
314 ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, eAwardType_Achievement);
315 ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, eAwardType_Achievement);
316 ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, eAwardType_Achievement);
317 ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, eAwardType_Achievement);
318 ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, eAwardType_Achievement);
319 ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, eAwardType_Achievement);
320 ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, eAwardType_Achievement);
321 ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, eAwardType_Achievement);
322 ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, eAwardType_Achievement);
323 ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, eAwardType_Achievement);
324 ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, eAwardType_Achievement);
325 ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, eAwardType_Achievement);
326 ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, eAwardType_Achievement);
327 ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, eAwardType_Achievement);
328 ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, eAwardType_Achievement);
329
330 ProfileManager.RegisterAward(eAward_snipeSkeleton, ACHIEVEMENT_21, eAwardType_Achievement); // 'Sniper Duel'
331 ProfileManager.RegisterAward(eAward_diamonds, ACHIEVEMENT_22, eAwardType_Achievement); // 'DIAMONDS!'
332 ProfileManager.RegisterAward(eAward_ghast, ACHIEVEMENT_23, eAwardType_Achievement); // 'Return To Sender'
333 ProfileManager.RegisterAward(eAward_blazeRod, ACHIEVEMENT_24, eAwardType_Achievement); // 'Into Fire'
334 ProfileManager.RegisterAward(eAward_potion, ACHIEVEMENT_25, eAwardType_Achievement); // 'Local Brewery'
335 ProfileManager.RegisterAward(eAward_theEnd, ACHIEVEMENT_26, eAwardType_Achievement); // 'The End?'
336 ProfileManager.RegisterAward(eAward_winGame, ACHIEVEMENT_27, eAwardType_Achievement); // 'The End.'
337 ProfileManager.RegisterAward(eAward_enchantments, ACHIEVEMENT_28, eAwardType_Achievement); // 'Enchanter'
338
339#ifdef _EXTENDED_ACHIEVEMENTS
340 ProfileManager.RegisterAward(eAward_overkill, ACHIEVEMENT_29, eAwardType_Achievement);
341 ProfileManager.RegisterAward(eAward_bookcase, ACHIEVEMENT_30, eAwardType_Achievement);
342 ProfileManager.RegisterAward(eAward_adventuringTime, ACHIEVEMENT_31, eAwardType_Achievement);
343 ProfileManager.RegisterAward(eAward_repopulation, ACHIEVEMENT_32, eAwardType_Achievement);
344 ProfileManager.RegisterAward(eAward_diamondsToYou, ACHIEVEMENT_33, eAwardType_Achievement);
345 ProfileManager.RegisterAward(eAward_eatPorkChop, ACHIEVEMENT_34, eAwardType_Achievement);
346 ProfileManager.RegisterAward(eAward_play100Days, ACHIEVEMENT_35, eAwardType_Achievement);
347 ProfileManager.RegisterAward(eAward_arrowKillCreeper, ACHIEVEMENT_36, eAwardType_Achievement);
348 ProfileManager.RegisterAward(eAward_theHaggler, ACHIEVEMENT_37, eAwardType_Achievement);
349 ProfileManager.RegisterAward(eAward_potPlanter, ACHIEVEMENT_38, eAwardType_Achievement);
350 ProfileManager.RegisterAward(eAward_itsASign, ACHIEVEMENT_39, eAwardType_Achievement);
351 ProfileManager.RegisterAward(eAward_ironBelly, ACHIEVEMENT_40, eAwardType_Achievement);
352 ProfileManager.RegisterAward(eAward_haveAShearfulDay, ACHIEVEMENT_41, eAwardType_Achievement);
353 ProfileManager.RegisterAward(eAward_rainbowCollection, ACHIEVEMENT_42, eAwardType_Achievement);
354 ProfileManager.RegisterAward(eAward_stayinFrosty, ACHIEVEMENT_43, eAwardType_Achievement);
355 ProfileManager.RegisterAward(eAward_chestfulOfCobblestone, ACHIEVEMENT_44, eAwardType_Achievement);
356 ProfileManager.RegisterAward(eAward_renewableEnergy, ACHIEVEMENT_45, eAwardType_Achievement);
357 ProfileManager.RegisterAward(eAward_musicToMyEars, ACHIEVEMENT_46, eAwardType_Achievement);
358 ProfileManager.RegisterAward(eAward_bodyGuard, ACHIEVEMENT_47, eAwardType_Achievement);
359 ProfileManager.RegisterAward(eAward_ironMan, ACHIEVEMENT_48, eAwardType_Achievement);
360 ProfileManager.RegisterAward(eAward_zombieDoctor, ACHIEVEMENT_49, eAwardType_Achievement);
361 ProfileManager.RegisterAward(eAward_lionTamer, ACHIEVEMENT_50, eAwardType_Achievement);
362#endif
363
364#if 0
365 ProfileManager.RegisterAward(eAward_mine100Blocks, GAMER_PICTURE_GAMERPIC1, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC1,IDS_CONFIRM_OK);
366 ProfileManager.RegisterAward(eAward_kill10Creepers, GAMER_PICTURE_GAMERPIC2, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC2,IDS_CONFIRM_OK);
367
368 ProfileManager.RegisterAward(eAward_eatPorkChop, AVATARASSETAWARD_PORKCHOP_TSHIRT, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR1,IDS_CONFIRM_OK);
369 ProfileManager.RegisterAward(eAward_play100Days, AVATARASSETAWARD_WATCH, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR2,IDS_CONFIRM_OK);
370 ProfileManager.RegisterAward(eAward_arrowKillCreeper, AVATARASSETAWARD_CAP, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR3,IDS_CONFIRM_OK);
371
372 ProfileManager.RegisterAward(eAward_socialPost, 0, eAwardType_Theme,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_THEME,IDS_CONFIRM_OK,THEME_NAME,THEME_FILESIZE);
373#endif
374 // Rich Presence init - number of presences, number of contexts
375 //printf("Rich presence strings are hard coded on PS3 for now, must change this!\n");
376 ProfileManager.RichPresenceInit(4,1);
377
378 //Chris TODO
379 ProfileManager.SetRichPresenceSettingFn(SQRNetworkManager_Vita::SetRichPresence);
380 char *pchRichPresenceString;
381
382 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE);
383 ProfileManager.RichPresenceRegisterContext(CONTEXT_GAME_STATE, pchRichPresenceString);
384 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_IDLE);
385 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_IDLE, pchRichPresenceString);
386 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MENUS);
387 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MENUS, pchRichPresenceString);
388 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER);
389 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER, pchRichPresenceString);
390 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYEROFFLINE);
391 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, pchRichPresenceString);
392 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1P);
393 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1P, pchRichPresenceString);
394 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1POFFLINE);
395 ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, pchRichPresenceString);
396
397 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BLANK);
398 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BLANK, pchRichPresenceString);
399 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_PIG);
400 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_PIG, pchRichPresenceString);
401 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_MINECART);
402 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_MINECART, pchRichPresenceString);
403 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BOATING);
404 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BOATING, pchRichPresenceString);
405 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FISHING);
406 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FISHING, pchRichPresenceString);
407 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CRAFTING);
408 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CRAFTING, pchRichPresenceString);
409 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FORGING);
410 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FORGING, pchRichPresenceString);
411 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_NETHER);
412 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_NETHER, pchRichPresenceString);
413 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CD);
414 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CD, pchRichPresenceString);
415 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_MAP);
416 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_MAP, pchRichPresenceString);
417
418 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ENCHANTING);
419 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ENCHANTING, pchRichPresenceString);
420 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BREWING);
421 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BREWING, pchRichPresenceString);
422 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ANVIL);
423 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ANVIL, pchRichPresenceString);
424 pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_TRADING);
425 ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_TRADING, pchRichPresenceString);
426
427}
428
429
430
431void LoadSysModule(uint16_t module, const char* moduleName)
432{
433 int ret = sceSysmoduleLoadModule(module);
434 if(ret != SCE_OK)
435 {
436#ifndef _CONTENT_PACKAGE
437 printf("Error sceSysmoduleLoadModule %s failed (%d) \n", moduleName, ret );
438 // are you running the debugger and don't have the Debugging/Mapping File set? - $(ProjectDir)\PSVita\configuration.psp2path
439#endif
440 assert(0);
441 }
442}
443
444#define LOAD_PSVITA_MODULE(m) LoadSysModule(m, #m)
445
446
447int LoadSysModules()
448{
449 // LOAD_PSVITA_MODULE(SCE_SYSMODULE_PERF);
450 LOAD_PSVITA_MODULE(SCE_SYSMODULE_ULT);
451 LOAD_PSVITA_MODULE(SCE_SYSMODULE_RUDP);
452 LOAD_PSVITA_MODULE(SCE_SYSMODULE_NP_MATCHING2);
453 LOAD_PSVITA_MODULE(SCE_SYSMODULE_NET);
454 LOAD_PSVITA_MODULE(SCE_SYSMODULE_PSPNET_ADHOC);
455 LOAD_PSVITA_MODULE(SCE_SYSMODULE_NET_ADHOC_MATCHING);
456 LOAD_PSVITA_MODULE(SCE_SYSMODULE_HTTP);
457 LOAD_PSVITA_MODULE(SCE_SYSMODULE_HTTPS);
458 LOAD_PSVITA_MODULE(SCE_SYSMODULE_NP_COMMERCE2);
459 LOAD_PSVITA_MODULE(SCE_SYSMODULE_NP_SCORE_RANKING);
460
461 return 0;
462}
463
464
465int main()
466{
467 //int* a = new int(5);
468
469 PSVitaInit();
470
471 ShutdownManager::Initialise();
472
473 SceKernelFreeMemorySizeInfo mem_info;
474 mem_info.size = sizeof(SceKernelFreeMemorySizeInfo);
475 int Err = sceKernelGetFreeMemorySize(&mem_info);
476
477#ifndef _CONTENT_PACKAGE
478 printf("------------------------------------------------------\n");
479 printf("------------------------------------------------------\n");
480 // printf("total_user_memory : %.02f\n", mem_info.total_user_memory / (1024.0f*1024.0f));
481 printf("available_user_memory : %.02f\n", mem_info.sizeMain / (1024.0f*1024.0f));
482 printf("available_video_memory : %.02f\n", mem_info.sizeCdram / (1024.0f*1024.0f));
483 printf("------------------------------------------------------\n");
484 printf("------------------------------------------------------\n");
485#endif
486
487 //
488 // initialize the Vita
489 //
490
491 int ihddFreeSizeKB=LoadSysModules();
492
493 /* Set the parameters to be passed to initialization function sceAppUtilInit() */
494 SceAppUtilInitParam initParam;
495 SceAppUtilBootParam bootParam;
496 memset(&initParam, 0, sizeof(SceAppUtilInitParam));
497 memset(&bootParam, 0, sizeof(SceAppUtilBootParam));
498
499 /* Initialize the library */
500 SceInt32 ret = sceAppUtilInit( &initParam, &bootParam );
501
502
503
504 static bool bTrialTimerDisplayed=true;
505
506 // 4J-JEV: Moved this here in case some archived files are compressed.
507 // Compression::CreateNewThreadStorage();
508
509 app.loadMediaArchive();
510 RenderManager.Initialise();
511
512 // Read the file containing the product codes
513 if(app.ReadProductCodes()==FALSE)
514 {
515 // can't continue
516 app.FatalLoadError();
517 }
518
519 app.InitTime();
520 PSVitaNPToolkit::init();
521
522 // initialise the storage manager with a default save display name, a Minimum save size, and a callback for displaying the saving message
523 StorageManager.Init( 0, L"savegame.dat", "savePackName", FIFTY_ONE_MB, &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, NULL);
524 StorageManager.SetDLCProductCode(app.GetProductCode());
525 StorageManager.SetProductUpgradeKey(app.GetUpgradeKey());
526 ProfileManager.SetServiceID(app.GetCommerceCategory());
527
528 bool bCircleCrossSwapped = false;
529 switch(app.GetProductSKU())
530 {
531 case e_sku_SCEE:
532 // 4J-PB - need to be online to do this check, so let's stick with the 7+, and move this
533 /*if(StorageManager.GetBootTypeDisc())
534 {*/
535 // set Europe age, then hone down specific countries
536 ProfileManager.SetMinimumAge(7,0); // PEGI 7+
537 ProfileManager.SetGermanyMinimumAge(6); // USK 6+
538 ProfileManager.SetAustraliaMinimumAge(8); // PG rating has no age, but for some reason the testers are saying it's 8
539 ProfileManager.SetRussiaMinimumAge(6);
540 ProfileManager.SetKoreaMinimumAge(0);
541 ProfileManager.SetJapanMinimumAge(0);
542 /*}
543 else
544 {
545 // PEGI 7+
546 ProfileManager.SetMinimumAge(7,0);
547 }*/
548 break;
549 case e_sku_SCEA:
550 // ESRB EVERYONE 10+
551 ProfileManager.SetMinimumAge(10,1);
552 break;
553 case e_sku_SCEJ:
554 // CERO A
555 ProfileManager.SetMinimumAge(0,2);
556 bCircleCrossSwapped = true;
557 break;
558 }
559
560 InputManager.SetCircleCrossSwapped(bCircleCrossSwapped);
561
562 app.loadStringTable();
563
564 // Vita
565 //g_iScreenWidth = 720;
566 //g_iScreenHeight = 408;
567
568 // Vita native
569 //g_iScreenWidth = 960;
570 //g_iScreenHeight = 544;
571 ui.init(720, 408);
572
573 ////////////////
574 // Initialise //
575 ////////////////
576
577 // Set the number of possible joypad layouts that the user can switch between, and the number of actions
578 InputManager.Initialise(1,3,MINECRAFT_ACTION_MAX, ACTION_MAX_MENU);
579
580 // Set the default joypad action mappings for Minecraft
581 DefineActions();
582 InputManager.SetJoypadMapVal(0,0);
583 InputManager.SetKeyRepeatRate(0.3f,0.2f);
584
585 //Minimum age must be set prior to profile init
586
587 ProfileManager.Initialise(
588 s_npCommunicationConfig,
589 app.GetCommerceCategory(),// s_serviceId,
590 PROFILE_VERSION_CURRENT,
591 NUM_PROFILE_VALUES,
592 NUM_PROFILE_SETTINGS,
593 dwProfileSettingsA,
594 app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
595 &app.uiGameDefinedDataChangedBitmask);
596
597
598 // register the awards
599 RegisterAwardsWithProfileManager();
600
601 // register the get string function with the profile lib, so it can be called within the lib
602 ProfileManager.SetGetStringFunc(&CConsoleMinecraftApp::GetString);
603 ProfileManager.SetPlayerListTitleID(IDS_PLAYER_LIST_TITLE);
604
605 // defaults
606 StorageManager.ResetSaveData();
607 StorageManager.SetSaveTitle(L"Default Save");
608 StorageManager.SetGameSaveFolderTitle((WCHAR *)app.GetString(IDS_GAMENAME));
609 StorageManager.SetSaveCacheFolderTitle((WCHAR *)app.GetString(IDS_SAVECACHEFILE));
610 StorageManager.SetOptionsFolderTitle((WCHAR *)app.GetString(IDS_OPTIONSFILE));
611 StorageManager.SetGameSaveFolderPrefix(app.GetSaveFolderPrefix());
612 StorageManager.SetMaxSaves(99);
613
614 byteArray baOptionsIcon = app.getArchiveFile(L"DefaultOptionsImage320x176.png");
615 byteArray baSaveThumbnail = app.getArchiveFile(L"DefaultSaveThumbnail64x64.png");
616 byteArray baSaveImage = app.getArchiveFile(L"DefaultSaveImage320x176.png");
617
618 StorageManager.InitialiseProfileData(PROFILE_VERSION_CURRENT,
619 NUM_PROFILE_VALUES,
620 NUM_PROFILE_SETTINGS,
621 dwProfileSettingsA,
622 app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT,
623 &app.uiGameDefinedDataChangedBitmask);
624
625 StorageManager.SetDefaultImages((PBYTE)baOptionsIcon.data, baOptionsIcon.length,(PBYTE)baSaveImage.data, baSaveImage.length,(PBYTE)baSaveThumbnail.data, baSaveThumbnail.length);
626
627 if(baOptionsIcon.data!=NULL){ delete [] baOptionsIcon.data; }
628 if(baSaveThumbnail.data!=NULL){ delete [] baSaveThumbnail.data; }
629 if(baSaveImage.data!=NULL){ delete [] baSaveImage.data; }
630
631 StorageManager.SetIncompleteSaveCallback(CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app);
632
633#if 0
634 // Set up the global title storage path
635 StorageManager.StoreTMSPathName();
636#endif
637
638 // 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
639 ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app);
640#if 0
641 // set a function to be called when the ethernet is disconnected, so we can back out if required
642 ProfileManager.SetNotificationsCallback(&CConsoleMinecraftApp::NotificationsCallback,(LPVOID)&app);
643#endif
644
645 // Set a callback for the default player options to be set - when there is no profile data for the player
646 StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app);
647 StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,(LPVOID)&app);
648
649 // Set a callback to deal with old profile versions needing updated to new versions
650 StorageManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app);
651
652#if 0
653 // Set a callback for when there is a read error on profile data
654 //StorageManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback,(LPVOID)&app);
655#endif
656
657 StorageManager.SetDLCInfoMap(app.GetSonyDLCMap());
658 app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL
659
660 // 4J-PB - Kick of the check for trial or full version - requires ui to be initialised
661 app.GetCommerce()->CheckForTrialUpgradeKey();
662
663
664
665 // debug switch to trial version
666 //ProfileManager.SetDebugFullOverride(false);
667
668 //ProfileManager.AddDLC(2);
669 StorageManager.SetDLCPackageRoot("DLCDrive");
670#if 0
671 StorageManager.RegisterMarketplaceCountsCallback(&CConsoleMinecraftApp::MarketplaceCountsCallback,(LPVOID)&app);
672 // Kinect !
673
674 if(XNuiGetHardwareStatus()!=0)
675 {
676 // If the Kinect Sensor is not physically connected, this function returns 0.
677 NuiInitialize(NUI_INITIALIZE_FLAG_USES_HIGH_QUALITY_COLOR | NUI_INITIALIZE_FLAG_USES_DEPTH |
678 NUI_INITIALIZE_FLAG_EXTRAPOLATE_FLOOR_PLANE | NUI_INITIALIZE_FLAG_USES_FITNESS | NUI_INITIALIZE_FLAG_NUI_GUIDE_DISABLED | NUI_INITIALIZE_FLAG_SUPPRESS_AUTOMATIC_UI,NUI_INITIALIZE_DEFAULT_HARDWARE_THREAD );
679 }
680
681 // Sentient !
682 hr = SentientManager.Init();
683
684#endif
685 // Initialise TLS for tesselator, for this main thread
686 Tesselator::CreateNewThreadStorage(1024*1024);
687 // Initialise TLS for AABB and Vec3 pools, for this main thread
688 AABB::CreateNewThreadStorage();
689 Vec3::CreateNewThreadStorage();
690 IntCache::CreateNewThreadStorage();
691 Compression::CreateNewThreadStorage();
692 OldChunkStorage::CreateNewThreadStorage();
693 Level::enableLightingCache();
694 Tile::CreateNewThreadStorage();
695 FireworksRecipe::CreateNewThreadStorage();
696
697 Minecraft::main();
698 Minecraft *pMinecraft=Minecraft::GetInstance();
699
700 //#if 0
701 //bool bDisplayPauseMenu=false;
702
703 // set the default gamma level
704 float fVal=50.0f*327.68f;
705 RenderManager.UpdateGamma((unsigned short)fVal);
706
707 // load any skins
708 //app.AddSkinsToMemoryTextureFiles();
709
710 // set the achievement text for a trial achievement, now we have the string table loaded
711 //Chris TODO
712 //ProfileManager.SetTrialTextStringTable(app.GetStringTable(),IDS_CONFIRM_OK, IDS_CONFIRM_CANCEL);
713 ProfileManager.SetTrialAwardText(eAwardType_Achievement,IDS_UNLOCK_TITLE,IDS_UNLOCK_ACHIEVEMENT_TEXT);
714 //ProfileManager.SetTrialAwardText(eAwardType_GamerPic,IDS_UNLOCK_TITLE,IDS_UNLOCK_GAMERPIC_TEXT);
715 //ProfileManager.SetTrialAwardText(eAwardType_AvatarItem,IDS_UNLOCK_TITLE,IDS_UNLOCK_AVATAR_TEXT);
716 ProfileManager.SetTrialAwardText(eAwardType_Theme,IDS_UNLOCK_TITLE,IDS_UNLOCK_THEME_TEXT);
717 ProfileManager.SetUpsellCallback(&app.UpsellReturnedCallback,&app);
718
719 // Set up a debug character press sequence
720#ifndef _FINAL_BUILD
721 app.SetDebugSequence("LRLRYYY");
722#endif
723
724 // Initialise the social networking manager.
725 //Chris TODO
726 //CSocialManager::Instance()->Initialise();
727
728 // Update the base scene quick selects now that the minecraft class exists
729 //CXuiSceneBase::UpdateScreenSettings(0);
730 //#endif
731 app.InitialiseTips();
732#if 0
733
734 DWORD initData=0;
735
736#ifndef _FINAL_BUILD
737#ifndef _DEBUG
738#pragma message(__LOC__"Need to define the _FINAL_BUILD before submission")
739#endif
740#endif
741
742 // Set the default sound levels
743 pMinecraft->options->set(Options::Option::MUSIC,1.0f);
744 pMinecraft->options->set(Options::Option::SOUND,1.0f);
745
746 app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_Intro,&initData);
747#endif
748
749 // wait for the trophy init to complete - nonblocking semaphore
750 while(( !ProfileManager.AreTrophiesInstalled() ) && ShutdownManager::ShouldRun(ShutdownManager::eMainThread))
751 {
752 RenderManager.StartFrame();
753 ProfileManager.Tick();
754 RenderManager.Tick();
755 RenderManager.Present();
756 }
757
758 // QNet needs to be setup after profile manager, as we do not want its Notify listener to handle
759 // XN_SYS_SIGNINCHANGED notifications. This does mean that we need to have a callback in the
760 // ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet.
761 g_NetworkManager.Initialise();
762 g_NetworkManager.SetLocalGame(true);
763
764 // Set the default sound levels
765 pMinecraft->options->set(Options::Option::MUSIC,1.0f);
766 pMinecraft->options->set(Options::Option::SOUND,1.0f);
767
768 app.InitGameSettings();
769 // read the options here for controller 0 - this won't actually be actioned until a storagemanager tick later
770 StorageManager.ReadFromProfile(0);
771
772 //app.TemporaryCreateGameStart();
773
774 //Sleep(10000);
775#if 0
776 // Intro loop ?
777 while(app.IntroRunning())
778 {
779 ProfileManager.Tick();
780 // Tick XUI
781 app.RunFrame();
782
783 // 4J : WESTY : Added to ensure we always have clear background for intro.
784 RenderManager.SetClearColour(D3DCOLOR_RGBA(0,0,0,255));
785 RenderManager.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
786
787 // Render XUI
788 hr = app.Render();
789
790 // Present the frame.
791 RenderManager.Present();
792
793 // Update XUI Timers
794 hr = XuiTimersRun();
795 }
796#endif
797 while( true )
798 {
799 SonyVoiceChat_Vita::tick();
800
801 RenderManager.StartFrame();
802#if 0
803 if(pMinecraft->soundEngine->isStreamingWavebankReady() &&
804 !pMinecraft->soundEngine->isPlayingStreamingGameMusic() &&
805 !pMinecraft->soundEngine->isPlayingStreamingCDMusic() )
806 {
807 // play some music in the menus
808 pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false);
809 }
810#endif
811
812 // static bool bPlay=false;
813 // if(bPlay)
814 // {
815 // bPlay=false;
816 // app.audio.PlaySound();
817 // }
818
819 app.UpdateTime();
820 PIXBeginNamedEvent(0,"Input manager tick");
821 InputManager.Tick();
822 PIXEndNamedEvent();
823 PIXBeginNamedEvent(0,"Profile manager tick");
824 ProfileManager.Tick();
825 PIXEndNamedEvent();
826 PIXBeginNamedEvent(0,"Storage manager tick");
827 StorageManager.Tick();
828 PIXEndNamedEvent();
829 PIXBeginNamedEvent(0,"Render manager tick");
830 RenderManager.Tick();
831 PIXEndNamedEvent();
832
833 // Tick the social networking manager.
834 PIXBeginNamedEvent(0,"Social network manager tick");
835 // CSocialManager::Instance()->Tick();
836 PIXEndNamedEvent();
837
838 // Tick sentient.
839 PIXBeginNamedEvent(0,"Sentient tick");
840 MemSect(37);
841 // SentientManager.Tick();
842 MemSect(0);
843 PIXEndNamedEvent();
844
845 PIXBeginNamedEvent(0,"Network manager do work #1");
846 g_NetworkManager.DoWork();
847 PIXEndNamedEvent();
848
849 LeaderboardManager::Instance()->Tick();
850 // Render game graphics.
851 if(app.GetGameStarted())
852 {
853 pMinecraft->run_middle();
854 app.SetAppPaused( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) );
855 }
856 else
857 {
858 MemSect(28);
859 pMinecraft->soundEngine->tick(NULL, 0.0f);
860 MemSect(0);
861 pMinecraft->textures->tick(true,false);
862 IntCache::Reset();
863 if( app.GetReallyChangingSessionType() )
864 {
865 pMinecraft->tickAllConnections(); // Added to stop timing out when we are waiting after converting to an offline game
866 }
867 }
868
869 pMinecraft->soundEngine->playMusicTick();
870
871#ifdef MEMORY_TRACKING
872 static bool bResetMemTrack = false;
873 static bool bDumpMemTrack = false;
874
875
876 MemPixStuff();
877
878 if( bResetMemTrack )
879 {
880 ResetMem();
881 MEMORYSTATUS memStat;
882 GlobalMemoryStatus(&memStat);
883 printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024));
884 bResetMemTrack = false;
885 }
886
887 if( bDumpMemTrack )
888 {
889 DumpMem();
890 bDumpMemTrack = false;
891 MEMORYSTATUS memStat;
892 GlobalMemoryStatus(&memStat);
893 printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024));
894 printf("Renderer used: %d\n",RenderManager.CBuffSize(-1));
895 }
896#endif
897#if 0
898 static bool bDumpTextureUsage = false;
899 if( bDumpTextureUsage )
900 {
901 RenderManager.TextureGetStats();
902 bDumpTextureUsage = false;
903 }
904#endif
905 ui.tick();
906 ui.render();
907#if 0
908 app.HandleButtonPresses();
909
910 // store the minecraft renderstates, and re-set them after the xui render
911 GetRenderAndSamplerStates(pDevice,RenderStateA,SamplerStateA);
912
913 // Tick XUI
914 PIXBeginNamedEvent(0,"Xui running");
915 app.RunFrame();
916 PIXEndNamedEvent();
917
918 // Render XUI
919
920 PIXBeginNamedEvent(0,"XUI render");
921 MemSect(7);
922 hr = app.Render();
923 MemSect(0);
924 GetRenderAndSamplerStates(pDevice,RenderStateA2,SamplerStateA2);
925 PIXEndNamedEvent();
926
927 for(int i=0;i<8;i++)
928 {
929 if(RenderStateA2[i]!=RenderStateA[i])
930 {
931 //printf("Reseting RenderStateA[%d] after a XUI render\n",i);
932 pDevice->SetRenderState(RenderStateModes[i],RenderStateA[i]);
933 }
934 }
935 for(int i=0;i<5;i++)
936 {
937 if(SamplerStateA2[i]!=SamplerStateA[i])
938 {
939 //printf("Reseting SamplerStateA[%d] after a XUI render\n",i);
940 pDevice->SetSamplerState(0,SamplerStateModes[i],SamplerStateA[i]);
941 }
942 }
943
944 RenderManager.Set_matrixDirty();
945#endif
946 // Present the frame.
947 RenderManager.Present();
948
949 ui.CheckMenuDisplayed();
950
951 PIXBeginNamedEvent(0,"Profile load check");
952 // has the game defined profile data been changed (by a profile load)
953 if(app.uiGameDefinedDataChangedBitmask!=0)
954 {
955 void *pData;
956 for(int i=0;i<XUSER_MAX_COUNT;i++)
957 {
958 if(app.uiGameDefinedDataChangedBitmask&(1<<i))
959 {
960 // It has - game needs to update its values with the data from the profile
961 pData=StorageManager.GetGameDefinedProfileData(i);
962 // reset the changed flag
963 app.ClearGameSettingsChangedFlag(i);
964 app.DebugPrintf("*** - APPLYING GAME SETTINGS CHANGE for pad %d\n",i);
965 app.ApplyGameSettingsChanged(i);
966
967#ifdef _DEBUG_MENUS_ENABLED
968 if(app.DebugSettingsOn())
969 {
970 app.ActionDebugMask(i);
971 }
972 else
973 {
974 // force debug mask off
975 app.ActionDebugMask(i,true);
976 }
977#endif
978 // clear the stats first - there could have beena signout and sign back in in the menus
979 // need to clear the player stats - can't assume it'll be done in setlevel - we may not be in the game
980 pMinecraft->stats[ i ]->clear();
981 pMinecraft->stats[i]->parse(pData);
982 }
983 }
984
985 //Check to see if we can post to social networks.
986 //CD - Removing this until support exists
987 //CSocialManager::Instance()->RefreshPostingCapability();
988
989 // clear the flag
990 app.uiGameDefinedDataChangedBitmask=0;
991
992 // Check if any profile write are needed
993 app.CheckGameSettingsChanged();
994 }
995 PIXEndNamedEvent();
996 app.TickDLCOffersRetrieved();
997 app.TickTMSPPFilesRetrieved();
998
999 PIXBeginNamedEvent(0,"Network manager do work #2");
1000 g_NetworkManager.DoWork();
1001 PIXEndNamedEvent();
1002#if 0
1003 PIXBeginNamedEvent(0,"Misc extra xui");
1004 // Update XUI Timers
1005 hr = XuiTimersRun();
1006
1007#endif // #if 0
1008 // Any threading type things to deal with from the xui side?
1009 app.HandleXuiActions();
1010
1011#if 0
1012 PIXEndNamedEvent();
1013#endif
1014
1015 // 4J-PB - Update the trial timer display if we are in the trial version
1016 if(!ProfileManager.IsFullVersion())
1017 {
1018 // display the trial timer
1019 if(app.GetGameStarted())
1020 {
1021 // 4J-PB - if the game is paused, add the elapsed time to the trial timer count so it doesn't tick down
1022 if(app.IsAppPaused())
1023 {
1024 app.UpdateTrialPausedTimer();
1025 }
1026 ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad());
1027 }
1028 }
1029 else
1030 {
1031 // need to turn off the trial timer if it was on , and we've unlocked the full version
1032 if(bTrialTimerDisplayed)
1033 {
1034 ui.ShowTrialTimer(false);
1035 bTrialTimerDisplayed=false;
1036 }
1037 }
1038
1039 // PS4 DLC
1040 app.CommerceTick();
1041 app.AppEventTick();
1042
1043 app.SaveDataTick();
1044
1045 // Fix for #7318 - Title crashes after short soak in the leaderboards menu
1046 // A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset
1047 Vec3::resetPool();
1048
1049 // sceRazorCpuSync();
1050#if 0 //ndef _CONTENT_PACKAGE
1051 if( InputManager.ButtonDown(0, MINECRAFT_ACTION_DPAD_LEFT) )
1052 {
1053 malloc_managed_size mmsize;
1054 malloc_stats(&mmsize);
1055 app.DebugPrintf("Free mem = %d\n", (mmsize.current_system_size - mmsize.current_inuse_size) / (1024*1024));
1056 }
1057#endif
1058 }
1059
1060 ShutdownManager::MainThreadHandleShutdown();
1061}
1062
1063vector<uint8_t *> vRichPresenceStrings;
1064uint8_t * AddRichPresenceString(int iID)
1065{
1066 uint8_t *strUtf8 = mallocAndCreateUTF8ArrayFromString(iID);
1067 if( strUtf8 != NULL )
1068 {
1069 vRichPresenceStrings.push_back(strUtf8);
1070 }
1071 return strUtf8;
1072}
1073
1074void FreeRichPresenceStrings()
1075{
1076 uint8_t *strUtf8;
1077 for(int i=0;i<vRichPresenceStrings.size();i++)
1078 {
1079 strUtf8=vRichPresenceStrings.at(i);
1080 free(strUtf8);
1081 }
1082 vRichPresenceStrings.clear();
1083}