Skip to content

Commit

Permalink
Merge 0.2.2 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
usineur committed Nov 17, 2019
2 parents 60bc18c + fe9fa8b commit 8447bc7
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
*.d
*.o
build
hode
hode.ini
setup.cfg
84 changes: 84 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,84 @@
project(hode)

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)

include_directories(
${SDL2_INCLUDE_DIRS}
)

add_executable(${CMAKE_PROJECT_NAME}
andy.cpp
benchmark.cpp
fileio.cpp
fs_posix.cpp
game.cpp
level1_rock.cpp
level2_fort.cpp
level3_pwr1.cpp
level4_isld.cpp
level5_lava.cpp
level6_pwr2.cpp
level7_lar1.cpp
level8_lar2.cpp
level9_dark.cpp
lzw.cpp
main.cpp
menu.cpp
mixer.cpp
monsters.cpp
paf.cpp
random.cpp
resource.cpp
screenshot.cpp
sound.cpp
staticres.cpp
system_sdl2.cpp
util.cpp
video.cpp
scaler_nearest.cpp
scaler_xbr.cpp
3p/inih/ini.c
3p/libxbr-standalone/xbr.c
)

target_link_libraries(${CMAKE_PROJECT_NAME}
${SDL2_STATIC_LIBRARIES}
)

if(SWITCH_LIBNX)
set(CMAKE_C_FLAGS "-O2 -ffunction-sections -fdata-sections -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -ftls-model=local-exec")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
include_directories($ENV{DEVKITPRO}/libnx/include)
add_definitions(-D__SWITCH__)
add_custom_target(${CMAKE_PROJECT_NAME}.nro
DEPENDS ${CMAKE_PROJECT_NAME}
COMMAND nacptool --create "Heart of Darkness" "cyx, usineur" "0.2.0" ${CMAKE_PROJECT_NAME}.nacp
COMMAND elf2nro ${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME}.nro --icon=${CMAKE_SOURCE_DIR}/res/icon.jpg --nacp=${CMAKE_PROJECT_NAME}.nacp
)
add_custom_target(nxlink
COMMAND nxlink -a $(SWITCHIP) ${CMAKE_PROJECT_NAME}.nro -s -p ${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_NAME}.nro
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)
6 changes: 5 additions & 1 deletion game.cpp
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 Expand Up @@ -2737,7 +2741,7 @@ void Game::levelMainLoop() {
}
_rnd.update();
_system->processEvents();
if (_system->inp.keyPressed(SYS_INP_ESC)) { // display exit confirmation screen
if (_system->inp.keyPressed(SYS_INP_ESC) || _system->inp.escape) { // display exit confirmation screen
if (displayHintScreen(-1, 0)) {
_system->inp.quit = true;
return;
Expand Down
2 changes: 1 addition & 1 deletion intern.h
Expand Up @@ -12,7 +12,7 @@
#include <stdlib.h>
#include <assert.h>

#ifdef _WIN32
#if defined(_WIN32) || defined(__SWITCH__) || defined(__vita__)
#define le16toh(x) x
#define le32toh(x) x
#define htole16(x) x
Expand Down
22 changes: 22 additions & 0 deletions main.cpp
Expand Up @@ -18,9 +18,17 @@
#include "system.h"
#include "video.h"

#ifdef __SWITCH__
#include <switch.h>
#endif

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 @@ -126,8 +134,17 @@ static int handleConfigIni(void *userdata, const char *section, const char *name
}

int main(int argc, char *argv[]) {
#ifdef __SWITCH__
socketInitializeDefault();
nxlinkStdio();
#endif
#ifdef __vita__
const char *dataPath = "ux0:data/hode";
const char *savePath = "ux0:data/hode";
#else
char *dataPath = 0;
char *savePath = 0;
#endif
int level = 0;
int checkpoint = 0;
bool resume = true;
Expand Down Expand Up @@ -223,7 +240,12 @@ int main(int argc, char *argv[]) {
_system->stopAudio();
g->_mix.fini();
delete g;
#ifndef __vita__
free(dataPath);
free(savePath);
#endif
#ifdef __SWITCH__
socketExit();
#endif
return 0;
}
5 changes: 5 additions & 0 deletions monsters.cpp
Expand Up @@ -2656,8 +2656,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
2 changes: 1 addition & 1 deletion paf.cpp
Expand Up @@ -487,7 +487,7 @@ void PafPlayer::mainLoop() {
_system->copyRect(0, 0, kVideoWidth, kVideoHeight, _pageBuffers[_currentPageBuffer], kVideoWidth);
_system->updateScreen(false);
_system->processEvents();
if (_system->inp.quit || _system->inp.keyPressed(SYS_INP_ESC)) {
if (_system->inp.quit || _system->inp.keyPressed(SYS_INP_ESC) || _system->inp.escape) {
break;
}

Expand Down
Binary file added res/bg.png
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/icon.jpg
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
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
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
@@ -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
Expand Up @@ -844,7 +844,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);
SssObject *so = addSoundObject(pcm, priority, flags1, flags);
Expand Down Expand Up @@ -1054,13 +1058,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 @@ -1071,7 +1083,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
1 change: 1 addition & 0 deletions system.h
Expand Up @@ -19,6 +19,7 @@

struct PlayerInput {
uint8_t prevMask, mask;
bool escape;
bool quit;
bool screenshot;

Expand Down
2 changes: 1 addition & 1 deletion system_sdl2.cpp
Expand Up @@ -551,7 +551,7 @@ void System_SDL2::processEvents() {
break;
case SDL_CONTROLLER_BUTTON_BACK:
case SDL_CONTROLLER_BUTTON_START:
inp.quit = pressed;
inp.escape = pressed;
break;
case SDL_CONTROLLER_BUTTON_DPAD_UP:
if (pressed) {
Expand Down

0 comments on commit 8447bc7

Please sign in to comment.