[vita] Initial port

This commit is contained in:
Ivan Epifanov 2020-12-13 00:16:34 +03:00 committed by Anders Jenbo
commit 1e53f32049
15 changed files with 198 additions and 5 deletions

View file

@ -17,6 +17,16 @@
#include "StormLib.h"
#include "StormCommon.h"
#include "FileStream.h"
#ifdef __vita__
#include <psp2/rtc.h>
#define mmap(ptr, size, c, d, e, f) malloc(size)
#define munmap(ptr, size) free(ptr)
#define PROT_READ 0
#define MAP_PRIVATE 0
#endif
#ifdef _MSC_VER
#pragma comment(lib, "wininet.lib") // Internet functions for HTTP stream

View file

@ -203,7 +203,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifndef __vita__
#include <sys/mman.h>
#endif
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
@ -297,7 +299,7 @@
#endif // !PLATFORM_WINDOWS
// 64-bit calls are supplied by "normal" calls on Mac
#if defined(PLATFORM_MAC) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR)
#if defined(PLATFORM_MAC) || defined(PLATFORM_HAIKU) || defined(PLATFORM_AMIGA) || defined(PLATFORM_SWITCH) || defined(PLATFORM_CTR) || defined(__vita__)
#define stat64 stat
#define fstat64 fstat
#define lseek64 lseek

5
CMake/vita_defs.cmake Normal file
View file

@ -0,0 +1,5 @@
set(ASAN OFF)
set(UBSAN OFF)
set(NONET ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEFAULT_WIDTH=960 -DDEFAULT_HEIGHT=544")

View file

@ -1,5 +1,14 @@
cmake_minimum_required(VERSION 3.10) # CMP0083 NEW
if(VITA)
if(DEFINED ENV{DOLCESDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{DOLCESDK}/share/dolce.toolchain.cmake" CACHE PATH "toolchain file")
else()
message(FATAL_ERROR "Please define DOLCESDK to point to your SDK path!")
endif()
include("$ENV{DOLCESDK}/share/dolce.cmake" REQUIRED)
endif()
include(CMake/out_of_tree.cmake)
include(CMake/genex.cmake)
@ -35,6 +44,9 @@ endif()
if(NOT VERSION_NUM)
include(CMake/git.cmake)
get_git_tag(VERSION_NUM)
if (NOT "${VERSION_NUM}" STREQUAL "")
string(REGEX MATCH "([0-9]+\.[0-9]+\.[0-9]+)" VERSION_NUM ${VERSION_NUM} )
endif()
get_git_commit_hash(GIT_COMMIT_HASH)
if(NOT VERSION_SUFFIX)
set(VERSION_SUFFIX "$<$<NOT:$<CONFIG:Release>>:-${GIT_COMMIT_HASH}>")
@ -79,6 +91,10 @@ if(SWITCH)
find_package(LIBNX REQUIRED)
include(switch_defs)
endif()
if(VITA)
include(vita_defs)
endif()
set(TARGET_PLATFORM host CACHE STRING "Target platform")
set_property(CACHE TARGET_PLATFORM PROPERTY STRINGS host retrofw rg350 gkd350h cpigamesh)
@ -518,6 +534,7 @@ foreach(target devilution ${BIN_TARGET} SourceS)
target_compile_definitions(${target} PRIVATE USE_SDL1)
else()
target_link_libraries(${target} PRIVATE
SDL2::SDL2
SDL2::SDL2main
SDL2::SDL2_ttf
SDL2::SDL2_mixer)
@ -537,6 +554,44 @@ foreach(target devilution ${BIN_TARGET} SourceS)
endif()
endif()
if (VITA)
target_link_libraries(${target} PRIVATE
pib
SceDisplay_stub
SceCtrl_stub
SceAppMgr_stub
SceAudio_stub
SceSysmodule_stub
SceSharedFb_stub
SceDisplay_stub
SceDisplayUser_stub
SceCtrl_stub
SceAppMgr_stub
SceAppMgrUser_stub
SceAudio_stub
SceIofilemgr_stub
SceSysmodule_stub
SceGxm_stub
SceGxmInternalForVsh_stub
SceCommonDialog_stub
SceTouch_stub
SceHid_stub
SceMotion_stub
ScePower_stub
freetype
png
m
z
FLAC
vorbisfile
vorbis
ogg
mikmod
mpg123
)
target_compile_definitions(${target} PRIVATE VITA)
endif()
if(N3DS)
target_link_libraries(${target} PRIVATE ${TREMOR_LIBRARIES})
target_include_directories(${target} PRIVATE ${TREMOR_INCLUDE_DIRS})
@ -547,7 +602,7 @@ foreach(target devilution ${BIN_TARGET} SourceS)
target_compile_definitions(${target} PRIVATE ${def_list})
endforeach(target)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT HAIKU)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT HAIKU AND NOT VITA)
target_link_libraries(${BIN_TARGET} PUBLIC "$<$<NOT:$<CONFIG:Debug>>:-static-libgcc;-static-libstdc++>")
endif()
@ -644,6 +699,26 @@ if(SWITCH)
build_switch_binaries(${BIN_TARGET})
endif()
if(VITA)
set(VITA_APP_NAME "devilutionX")
set(VITA_TITLEID "DVLX00001")
set(VITA_VERSION "01.00")
set(DOLCE_MKSFOEX_FLAGS "${DOLCE_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1")
set(DOLCE_MKSFOEX_FLAGS "${DOLCE_MKSFOEX_FLAGS} -d ATTRIBUTE2=12")
dolce_create_self(devilutionx.self devilutionx UNSAFE)
dolce_create_vpk(devilutionx.vpk ${VITA_TITLEID} devilutionx.self
VERSION ${VITA_VERSION}
NAME ${VITA_APP_NAME}
FILE Packaging/vita/sce_sys/icon0.png sce_sys/icon0.png
FILE Packaging/vita/sce_sys/pic0.png sce_sys/pic0.png
FILE Packaging/vita/sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png
FILE Packaging/vita/sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
FILE Packaging/vita/sce_sys/livearea/contents/logo0.png sce_sys/livearea/contents/logo0.png
FILE Packaging/vita/sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml
FILE Packaging/resources/CharisSILB.ttf CharisSILB.ttf
)
endif()
if(N3DS)
set(APP_TITLE "DevilutionX")
set(APP_DESCRIPTION "DevilutionX port for 3DS")

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<livearea style="psmobile" format-ver="01.00" content-rev="1">
 
<livearea-background>
    <image>bg.png</image>
</livearea-background>
<gate>
<startup-image>startup.png</startup-image>
</gate>
<frame id="frame1">
<liveitem>
<image>logo0.png</image>
</liveitem>
</frame>
<frame id="frame2">
<liveitem>
<text valign="bottom" align="left" text-align="left" text-valign="bottom" line-space="3" ellipsis="on">
<str color="#ffffff" size="30" bold="on" shadow="on">devilutionX</str>
</text>
</liveitem>
</frame>
</livearea>

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

View file

@ -216,13 +216,21 @@ cd build
cmake .. -DNIGHTLY_BUILD=ON -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/3ds.cmake
make -j$(nproc)
```
*Note:* Add `-DHELLFIRE=ON` to build the Hellfire binaries.
The output-files will be generated in the build folder.
[Nintendo 3DS manual](docs/manual/platforms/n3ds.md)
</details>
<details><summary>PS Vita</summary>
### Compiling
```
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DVITA=1 ..
make
```
</details>
<details><summary>Haiku</summary>
### Installing dependencies on 32 bit Haiku

View file

@ -12,6 +12,12 @@
#include <SDL.h>
#include <config.h>
#ifdef __vita__
// increase default allowed heap size on Vita
int _newlib_heap_size_user = 100 * 1024 * 1024;
#endif
DEVILUTION_BEGIN_NAMESPACE
_SNETVERSIONDATA fileinfo;
@ -48,7 +54,7 @@ HANDLE init_test_access(const char *mpq_name, const char *reg_loc, int dwPriorit
const std::string *paths[2] = { &GetBasePath(), &GetPrefPath() };
std::string mpq_abspath;
DWORD mpq_flags = 0;
#if !defined(__SWITCH__) && !defined(__AMIGA__)
#if !defined(__SWITCH__) && !defined(__AMIGA__) && !defined(__vita__)
mpq_flags |= MPQ_FLAG_READ_ONLY;
#endif
for (int i = 0; i < 2; i++) {

View file

@ -39,7 +39,11 @@ std::string *FromSDL(char *s) {
const std::string &GetBasePath()
{
#ifdef __vita__
if (basePath == NULL) basePath = new std::string(GetPrefPath());
#else
if (basePath == NULL) basePath = FromSDL(SDL_GetBasePath());
#endif
return *basePath;
}

View file

@ -264,7 +264,10 @@ WPARAM keystate_for_mouse(WPARAM ret)
bool false_avail(const char *name, int value)
{
#ifndef __vita__
// Logging on Vita is slow due slow IO, so disable spamming unhandled events to log
SDL_Log("Unhandled SDL event: %s %d", name, value);
#endif
return true;
}

View file

@ -0,0 +1,54 @@
# devilutionX PS Vita port
## How To Play:
- Install VPK
- Copy diabdat.mpq from your CD or GoG installation (or [extract it from the GoG installer](https://github.com/diasurgical/devilutionX/wiki/Extracting-the-DIABDAT.MPQ-from-the-GoG-installer)) to the `ux0:/data/diasurgical/devilution/`; make sure it is all lowercase.
# Building from Source
```
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DVITA=1 ..
make
```
# Multiplayer
- Not supported yet
# Controls
## Default
- Left analog or D-Pad: move hero
- ○: attack nearby enemies, talk to townspeople and merchants, pickup/place items in the inventory, OK while in main menu
- ×: select spell, back while in menus
- △: pickup items, open nearby chests and doors, use item in the inventory
- □: cast spell, delete character while in main menu
- L1: use health item from belt
- R1: use mana potion from belt
- Left back touch panel: character sheet (alt: Start + ←)
- Right back touch panel: inventory (alt: Start + →)
- Start + ↓: toggle automap
- Start + Select: game menu (alt: Start + ↑)
- Select + ×/○/□/△: Spell hotkeys
- Right analog: move automap or simulate mouse
- Select + L1: left mouse click
- Select + R1: right mouse click
- Start + □: quest log
- Start + △: spell book
## Options
There's special vita section in diablo.ini file, that allows you to adjust controls:
```
[vita]
dpad_hotkeys=0
switch_potions_and_clicks=0
back_touch=0
gamepad_mapping=y:b0,b:b1,a:b2,x:b3,leftshoulder:b4,rightshoulder:b5,dpdown:b6,dpleft:b7,dpup:b8,dpright:b9,back:b10,start:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,
```
- **dpad_hotkeys:** dpad works as hotkeys without holding Start button
- **switch_potions_and_clicks:** L1/R1 works as left/right mouse clicks by debault, and as health/mana potion while holding Select
- **gamepad_mapping:** allows you to remap controls. It uses https://github.com/gabomdq/SDL_GameControllerDB syntax (but without controller GUID/Name)
- **back_touch:** enable/disable back touch mapping to L2/R2