Skip to content

Commit

Permalink
Add PS Vita support
Browse files Browse the repository at this point in the history
  • Loading branch information
usineur committed Nov 4, 2019
1 parent e52751b commit fe9fa8b
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 2 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ cmake_minimum_required(VERSION 3.0)
include(FindPkgConfig)

set(CMAKE_CXX_FLAGS "-g -Wall -pedantic -MMD ${CMAKE_CXX_FLAGS}")
if(VITA)
set(ENV{PKG_CONFIG_PATH} "$ENV{VITASDK}/arm-vita-eabi/lib/pkgconfig")
endif(VITA)

pkg_check_modules(SDL2 sdl2 REQUIRED)

Expand Down Expand Up @@ -48,7 +51,7 @@ add_executable(${CMAKE_PROJECT_NAME}
)

target_link_libraries(${CMAKE_PROJECT_NAME}
${SDL2_LIBRARIES}
${SDL2_STATIC_LIBRARIES}
)

if(SWITCH_LIBNX)
Expand All @@ -66,3 +69,16 @@ if(SWITCH_LIBNX)
DEPENDS ${CMAKE_PROJECT_NAME}.nro
)
endif(SWITCH_LIBNX)

if(VITA)
include("${VITASDK}/share/vita.cmake" REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -fpermissive")
vita_create_self(eboot.bin ${CMAKE_PROJECT_NAME} UNSAFE)
vita_create_vpk(${CMAKE_PROJECT_NAME}.vpk "HODEVITA1" eboot.bin
NAME ${CMAKE_PROJECT_NAME}
FILE res/icon0.png sce_sys/icon0.png
FILE res/bg.png sce_sys/livearea/contents/bg.png
FILE res/startup.png sce_sys/livearea/contents/startup.png
FILE res/template.xml sce_sys/livearea/contents/template.xml
)
endif(VITA)
4 changes: 4 additions & 0 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#include "video.h"

// menu settings and player progress
#ifdef __vita__
static const char *_setupCfg = "ux0:data/hode/setup.cfg";
#else
static const char *_setupCfg = "setup.cfg";
#endif

// starting level cutscene number
static const uint8_t _cutscenes[] = { 0, 2, 4, 5, 6, 8, 10, 14, 19 };
Expand Down
2 changes: 1 addition & 1 deletion intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <stdlib.h>
#include <assert.h>

#if defined(_WIN32) || defined(__SWITCH__)
#if defined(_WIN32) || defined(__SWITCH__) || defined(__vita__)
#define le16toh(x) x
#define le32toh(x) x
#define htole16(x) x
Expand Down
10 changes: 10 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@

static const char *_title = "Heart of Darkness";

#ifdef __vita__
static const char *_configIni = "ux0:data/hode/hode.ini";
#else
static const char *_configIni = "hode.ini";
#endif

static const char *_usage =
"hode - Heart of Darkness Interpreter\n"
Expand Down Expand Up @@ -128,7 +132,11 @@ int main(int argc, char *argv[]) {
socketInitializeDefault();
nxlinkStdio();
#endif
#ifdef __vita__
const char *dataPath = "ux0:data/hode";
#else
char *dataPath = 0;
#endif
int level = 0;
int checkpoint = 0;
bool resume = true;
Expand Down Expand Up @@ -220,7 +228,9 @@ int main(int argc, char *argv[]) {
_system->stopAudio();
g->_mix.fini();
delete g;
#ifndef __vita__
free(dataPath);
#endif
#ifdef __SWITCH__
socketExit();
#endif
Expand Down
5 changes: 5 additions & 0 deletions monsters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2662,8 +2662,13 @@ int Game::mstUpdateTaskMonsterObject1(Task *t) {
if ((m->monsterInfos[946] & 2) == 0) {
MstWalkNode *walkPath = m->walkNode;
int vf = READ_LE_UINT32(m->monsterInfos + 904);
#ifdef __vita__
int vb = MAX<int32_t>(m->unk88, walkPath->coords[1][1] + vf);
int va = MIN<int32_t>(m->unk84, walkPath->coords[0][1] - vf);
#else
int vb = MAX(m->unk88, walkPath->coords[1][1] + vf);
int va = MIN(m->unk84, walkPath->coords[0][1] - vf);
#endif
const uint32_t indexUnk36 = walkPath->movingBoundsIndex2;
assert(indexUnk36 != kNone);
const uint32_t indexUnk49 = _res->_mstMovingBoundsIndexData[indexUnk36].indexUnk49;
Expand Down
Binary file added res/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/icon0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/startup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions res/template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>

<livearea style="a1" format-ver="01.00" content-rev="1">
<livearea-background>
<image>bg.png</image>
</livearea-background>
<gate>
<startup-image>startup.png</startup-image>
</gate>
</livearea>
16 changes: 16 additions & 0 deletions sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,11 @@ SssObject *Game::startSoundObject(int bankIndex, int sampleIndex, uint32_t flags

if (sample->framesCount != 0) {
SssFilter *filter = &_res->_sssFilters[bank->sssFilter];
#ifdef __vita__
const int priority = CLIP(filter->priorityCurrent + sample->initPriority, 0l, 7l);
#else
const int priority = CLIP(filter->priorityCurrent + sample->initPriority, 0, 7);
#endif
uint32_t flags1 = flags & 0xFFF0F000;
flags1 |= ((sampleIndex & 0xF) << 16) | (bankIndex & 0xFFF);
SssPcm *pcm = &_res->_sssPcmTable[sample->pcm];
Expand Down Expand Up @@ -1093,13 +1097,21 @@ void Game::setSoundObjectPanning(SssObject *so) {
int volume = ((so->filter->volumeCurrent >> 16) * so->volume) >> 7;
int panning = 0;
if (so->panningPtr) {
#ifdef __vita__
int priority = CLIP(so->priority + so->filter->priorityCurrent, 0l, 7l);
#else
int priority = CLIP(so->priority + so->filter->priorityCurrent, 0, 7);
#endif
if (so->panning == -2) {
volume = 0;
panning = kDefaultSoundPanning;
priority = 0;
} else {
#ifdef __vita__
panning = CLIP(so->panning, 0l, 128l);
#else
panning = CLIP(so->panning, 0, 128);
#endif
volume >>= 2;
priority /= 2;
}
Expand All @@ -1110,7 +1122,11 @@ void Game::setSoundObjectPanning(SssObject *so) {
}
}
} else {
#ifdef __vita__
panning = CLIP(so->panning + (so->filter->panningCurrent >> 16), 0l, 128l);
#else
panning = CLIP(so->panning + (so->filter->panningCurrent >> 16), 0, 128);
#endif
}
if (so->pcm == 0) {
return;
Expand Down

0 comments on commit fe9fa8b

Please sign in to comment.