diff --git a/src/platform/psv/CMakeLists.txt b/src/platform/psv/CMakeLists.txt index 733d842..863aac8 100644 --- a/src/platform/psv/CMakeLists.txt +++ b/src/platform/psv/CMakeLists.txt @@ -17,8 +17,8 @@ set(VITA_APP_NAME "OpenLara") set(VITA_TITLEID "OPENLARA1") set(VITA_VERSION "01.00") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++11") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O3 -Wall") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O3 -std=c++11") set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1") include_directories( @@ -44,6 +44,7 @@ target_link_libraries(OpenLara SceCtrl_stub SceAudio_stub SceTouch_stub + SceAppUtil_stub ) diff --git a/src/platform/psv/deploy.sh b/src/platform/psv/deploy.sh new file mode 100644 index 0000000..8ac45f4 --- /dev/null +++ b/src/platform/psv/deploy.sh @@ -0,0 +1,3 @@ +make +curl --ftp-method nocwd -T OpenLara.self ftp://192.168.1.59:1337/ux0:/app/OPENLARA1/eboot.bin +echo launch OPENLARA1 | ./nc.exe 192.168.1.59 1338 diff --git a/src/platform/psv/main.cpp b/src/platform/psv/main.cpp index 94a1c40..60328e0 100644 --- a/src/platform/psv/main.cpp +++ b/src/platform/psv/main.cpp @@ -11,27 +11,39 @@ #include #include #include +#include +#include #include #include "game.h" // multi-threading -void* osMutexInit() { - SceUID *mutex = new SceUID(); - *mutex = sceKernelCreateMutex(NULL, 0, 0, NULL); +void* osMutexInit() +{ + SceUID mutex = sceKernelCreateMutex(NULL, SCE_KERNEL_MUTEX_ATTR_RECURSIVE, 0, NULL); + if (mutex < 0) + { + return NULL; + } + SceUID* obj = new SceUID(); + *obj = mutex; + return obj; } -void osMutexFree(void *obj) { +void osMutexFree(void *obj) +{ sceKernelDeleteMutex(*(SceUID*)obj); delete (SceUID*)obj; } -void osMutexLock(void *obj) { +void osMutexLock(void *obj) +{ sceKernelLockMutex(*(SceUID*)obj, 1, NULL); } -void osMutexUnlock(void *obj) { +void osMutexUnlock(void *obj) +{ sceKernelUnlockMutex(*(SceUID*)obj, 1); } @@ -39,28 +51,33 @@ void osMutexUnlock(void *obj) { int osStartTime = 0; int osTimerFreq; -int osGetTimeMS() { +int osGetTimeMS() +{ SceRtcTick current; sceRtcGetCurrentTick(¤t); return int(current.tick * 1000 / osTimerFreq - osStartTime); } // input -bool osJoyReady(int index) { +bool osJoyReady(int index) +{ return index == 0; } -void osJoyVibrate(int index, float L, float R) { +void osJoyVibrate(int index, float L, float R) +{ // } -void inputInit() { +void inputInit() +{ sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG); sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START); sceTouchEnableTouchForce(SCE_TOUCH_PORT_FRONT); } -void inputUpdate() { +void inputUpdate() +{ // gamepad SceCtrlData pad; sceCtrlReadBufferPositive(0, &pad, 1); @@ -91,9 +108,12 @@ void inputUpdate() { bool touchState[COUNT(Input::touch)]; for (int i = 0; i < COUNT(Input::touch); i++) + { touchState[i] = Input::down[ikTouchA + i]; + } - for (int i = 0; i < touch.reportNum; i++) { + for (int i = 0; i < touch.reportNum; i++) + { SceTouchReport &t = touch.report[i]; InputKey key = Input::getTouch(t.id); @@ -106,8 +126,12 @@ void inputUpdate() { } for (int i = 0; i < COUNT(Input::touch); i++) + { if (touchState[i]) + { Input::setDown(InputKey(ikTouchA + i), false); + } + } } bool sndTerm; @@ -119,8 +143,10 @@ Sound::Frame *sndBuffer; #define SND_FRAMES 2048 -int sndPrepThread(SceSize args, void *argp) { - while (!sndTerm) { +int sndPrepThread(SceSize args, void *argp) +{ + while (!sndTerm) + { sceKernelWaitSema(sndSema, 1, NULL); sndPartIndex ^= 1; Sound::Frame *part = sndBuffer + SND_FRAMES * sndPartIndex; @@ -129,8 +155,10 @@ int sndPrepThread(SceSize args, void *argp) { return 0; } -int sndOutThread(SceSize args, void *argp) { - while (!sndTerm) { +int sndOutThread(SceSize args, void *argp) +{ + while (!sndTerm) + { Sound::Frame *part = sndBuffer + SND_FRAMES * sndPartIndex; sceKernelSignalSema(sndSema, 1); sceAudioOutOutput(sndPort, part); @@ -138,7 +166,8 @@ int sndOutThread(SceSize args, void *argp) { return 0; } -void sndInit() { +void sndInit() +{ sndTerm = false; sndPartIndex = 0; @@ -158,7 +187,8 @@ void sndInit() { sceKernelStartThread(sndOutTID, 0, NULL); } -void sndFree() { +void sndFree() +{ sndTerm = true; sceKernelSignalSema(sndSema, 1); @@ -173,8 +203,35 @@ void sndFree() { free(sndBuffer); } +int checkLanguage() +{ + int id; + sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_LANG, &id); + + int str = STR_LANG_EN; + switch (id) + { + case SCE_SYSTEM_PARAM_LANG_ENGLISH_US : + case SCE_SYSTEM_PARAM_LANG_ENGLISH_GB : str = STR_LANG_EN; break; + case SCE_SYSTEM_PARAM_LANG_FRENCH : str = STR_LANG_FR; break; + case SCE_SYSTEM_PARAM_LANG_GERMAN : str = STR_LANG_DE; break; + case SCE_SYSTEM_PARAM_LANG_SPANISH : str = STR_LANG_ES; break; + case SCE_SYSTEM_PARAM_LANG_ITALIAN : str = STR_LANG_IT; break; + case SCE_SYSTEM_PARAM_LANG_POLISH : str = STR_LANG_PL; break; + case SCE_SYSTEM_PARAM_LANG_PORTUGUESE_PT : + case SCE_SYSTEM_PARAM_LANG_PORTUGUESE_BR : str = STR_LANG_PT; break; + case SCE_SYSTEM_PARAM_LANG_RUSSIAN : str = STR_LANG_RU; break; + case SCE_SYSTEM_PARAM_LANG_JAPANESE : str = STR_LANG_JA; break; + case SCE_SYSTEM_PARAM_LANG_FINNISH : str = STR_LANG_FI; break; + case SCE_SYSTEM_PARAM_LANG_CHINESE_T : + case SCE_SYSTEM_PARAM_LANG_CHINESE_S : str = STR_LANG_CN; break; + case SCE_SYSTEM_PARAM_LANG_SWEDISH : str = STR_LANG_SV; break; + } + return str - STR_LANG_EN; +} -int main() { +int main() +{ psvDebugScreenInit(); scePowerSetArmClockFrequency(444); @@ -182,25 +239,34 @@ int main() { scePowerSetGpuClockFrequency(222); scePowerSetGpuXbarClockFrequency(166); + { + SceAppUtilInitParam initParam = {}; + SceAppUtilBootParam bootParam = {}; + sceAppUtilInit(&initParam, &bootParam); + } + cacheDir[0] = saveDir[0] = contentDir[0] = 0; strcpy(cacheDir, "ux0:data/OpenLara/"); strcpy(saveDir, "ux0:data/OpenLara/"); strcpy(contentDir, "ux0:data/OpenLara/"); + Core::defLang = checkLanguage(); + sndInit(); inputInit(); osTimerFreq = sceRtcGetTickResolution(); - osStartTime = Core::getTime(); + osStartTime = osGetTimeMS(); - Game::init();//"PSXDATA/LEVEL2.PSX"); -// sceRazorGpuCaptureSetTrigger(100, "ux0:data/OpenLara/capture.sgx"); + Game::init(); while (!Core::isQuit) { inputUpdate(); if (Input::joy[0].down[jkStart]) + { Core::quit(); + } Game::update(); Game::render(); diff --git a/src/platform/psv/sce_sys/icon0.png b/src/platform/psv/sce_sys/icon0.png index bb54cf5..94c68fa 100644 Binary files a/src/platform/psv/sce_sys/icon0.png and b/src/platform/psv/sce_sys/icon0.png differ diff --git a/src/platform/psv/sce_sys/livearea/contents/bg.png b/src/platform/psv/sce_sys/livearea/contents/bg.png index 23a9f3b..259af4a 100644 Binary files a/src/platform/psv/sce_sys/livearea/contents/bg.png and b/src/platform/psv/sce_sys/livearea/contents/bg.png differ diff --git a/src/platform/psv/sce_sys/livearea/contents/startup.png b/src/platform/psv/sce_sys/livearea/contents/startup.png index 9f2bf25..ce0ec88 100644 Binary files a/src/platform/psv/sce_sys/livearea/contents/startup.png and b/src/platform/psv/sce_sys/livearea/contents/startup.png differ diff --git a/src/platform/psv/sce_sys/livearea/contents/template.xml b/src/platform/psv/sce_sys/livearea/contents/template.xml index a4d43f0..b934a29 100644 --- a/src/platform/psv/sce_sys/livearea/contents/template.xml +++ b/src/platform/psv/sce_sys/livearea/contents/template.xml @@ -1,6 +1,6 @@ - + bg.png