Skip to content

Commit

Permalink
Initial Vita port
Browse files Browse the repository at this point in the history
  • Loading branch information
Northfear committed Sep 9, 2020
1 parent 681e640 commit 85711c1
Show file tree
Hide file tree
Showing 28 changed files with 845 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@

# build directory
build

# vita specific
*.bin
*.elf
*.velf
*.vpk
*.sfo
60 changes: 60 additions & 0 deletions Makefile.vita
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# makefile
# project: Free Heroes2
#
# Options:
# DEBUG: build in debug mode
# RELEASE: build with addons extensions
#
# WITHOUT_ZLIB: build without zlib (disable comressed save files)
# WITHOUT_MIXER: build without SDL_mixer library
# WITHOUT_AUDIOCD: disable audio cd support
# WITHOUT_UNICODE: build without unicode (disable translation and ttf font)
# WITHOUT_IMAGE: build without SDL_image library (disable cache image, icn2png)
# WITHOUT_XML: skip build tinyxml, used for load alt. resources
# WITH_TOOLS: build tools
#
# -DCONFIGURE_FHEROES2_LOCALEDIR: system locale dir
# -DCONFIGURE_FHEROES2_DATA: system fheroes2 game dir
#

TARGET := fheroes2
MAKE := make

PROJECT_TITLE := Free Heroes 2
PROJECT_TITLEID := FHOMM0002
PROJECT := fheroes2

all: package

package: $(PROJECT).vpk

$(PROJECT).vpk: eboot.bin param.sfo
vita-pack-vpk -s param.sfo -b eboot.bin \
--add platforms/vita/sce_sys/icon0.png=sce_sys/icon0.png \
--add platforms/vita/sce_sys/livearea/contents/bg.png=sce_sys/livearea/contents/bg.png \
--add platforms/vita/sce_sys/livearea/contents/startup.png=sce_sys/livearea/contents/startup.png \
--add platforms/vita/sce_sys/livearea/contents/template.xml=sce_sys/livearea/contents/template.xml \
--add files/fonts/bigfonts.ttf=files/fonts/bigfonts.ttf \
--add files/fonts/dejavusans.ttf=files/fonts/dejavusans.ttf \
--add files/fonts/smallfonts.ttf=files/fonts/smallfonts.ttf \
$(PROJECT).vpk

eboot.bin: $(PROJECT).velf
vita-make-fself $(PROJECT).velf eboot.bin

param.sfo:
vita-mksfoex -s TITLE_ID="$(PROJECT_TITLEID)" "$(PROJECT_TITLE)" param.sfo

$(PROJECT).velf: $(PROJECT).elf
arm-vita-eabi-strip -g $<
vita-elf-create $< $@

$(PROJECT).elf:
$(MAKE) -f Makefile -C src VITA=true WITH_SDL2=true RELEASE=true
$(MAKE) -f files/lang/Makefile
@cp src/dist/$(TARGET) ./$(PROJECT).elf

clean:
$(MAKE) -f Makefile -C src clean
$(MAKE) -f files/lang/Makefile clean
@rm -rf $(TARGET).velf $(TARGET).elf $(OBJS) $(TARGET).elf.unstripped.elf $(TARGET).vpk eboot.bin sce_sys/param.sfo ./param.sfo
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
# FHeroes2 port for PS Vita

## Install
Download fheroes2_data.zip and fheroes2.vpk files from https://github.com/Northfear/fheroes2-vita/releases.

Install fheroes2.vpk to your Vita. Extract "fheroes2" folder from fheroes2_data.zip into ux0:data.

FHeroes2 requires data files from the original Heroes of Might and Magic 2.

Copy HEROES2.AGG and HEROES2X.AGG (if you own Price of Loyalty expansion) from the original games "DATA" folder into "ux0:data/fheroes2/data" and everything from "MAPS" folder into "ux0:data/fheroes2/maps".

Data from GoG version of the game is working nicely. Files from the demo version are working too.

Music files in OGG format (from GoG release of the game) should be placed into the ux0:data/fheroes2/files/music/ folder. To enable OGG music set "music = external" option in 'ux0:data/fheroes2/fheroes2.cfg".

rePatch reDux0 plugin is required for proper suspend/resume support

https://github.com/dots-tb/rePatch-reDux0

## Building
### Prerequisites
- libSDL2
- libSDL2-mixer (optional)
- libSDL2-image (optional)
- libSDL2-ttf (optional)

To build the game just run
```
make -f Makefile.vita
```

## Controls
- Left analog stick - Pointer movement
- X button - Left mouse button
- O button - Right mouse button
- D-Pad - Map scrolling
- START - Enter

Text input is done with D-Pad.

- Left - Remove character
- Right - Add new character
- Down - Next character (alphabetically)
- Up - Previous character
- R1, L1 - Switch current character between uppercase/lowercase

## Vita specific options

Pointer movement speed can be changed with 'vita_pointer_speed' parameter in ux0:data/fheroes2/fheroes2.cfg.

Use "fullscreen = on" option to scale game area to native Vita resolution or "fullscreen = off" to keep game area at the center of the screen.

"vita_keep_aspect_ratio = 1" keeps aspect ratio of original image when scaling. "vita_keep_aspect_ratio = 0" just scales it to 960x544.

Native resolution is supported (set "videomode = 960x544" option in config file or just click on the left door in main menu and select resolution manually. Game restart is required after resolution change).

fheroes2
======
[![Build status](https://travis-ci.org/ihhub/fheroes2.svg?branch=master)](https://travis-ci.org/ihhub/fheroes2) [![Build status](https://ci.appveyor.com/api/projects/status/ih6cw0yr1yuxf4ll?svg=true)](https://ci.appveyor.com/project/ihhub/fheroes2) [![Github Downloads (monthly)](https://img.shields.io/github/downloads/ihhub/fheroes2/total.svg)](https://github.com/ihhub/fheroes2/releases) [![Discord](https://img.shields.io/discord/733093692860137523.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/xF85vbZ) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/paypalme/fheroes2)
Expand Down
Binary file added platforms/vita/sce_sys/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 platforms/vita/sce_sys/livearea/contents/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 platforms/vita/sce_sys/livearea/contents/startup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions platforms/vita/sce_sys/livearea/contents/template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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>
12 changes: 8 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ ifdef RELEASE
CFLAGS := $(CFLAGS) -DBUILD_RELEASE
endif

CFLAGS := $(SDL_FLAGS) $(CFLAGS)
LIBS := $(SDL_LIBS) $(LIBS)

# platform specific flags
ifndef PLATFORM
ifndef OS
Expand All @@ -98,9 +95,16 @@ LIBS := -liconv
endif
endif

ifdef VITA
PLATFORM := vita
endif

include Makefile.$(PLATFORM)

export CXX AR LINK WINDRES LDFLAGS CFLAGS LIBS PLATFORM
CFLAGS := $(SDL_FLAGS) $(CFLAGS)
LIBS := $(SDL_LIBS) $(LIBS)

export CC CXX AR LINK WINDRES LDFLAGS CFLAGS LIBS PLATFORM

.PHONY: clean

Expand Down
38 changes: 38 additions & 0 deletions src/Makefile.vita
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
AR := $(VITASDK)/arm-vita-eabi/bin/ar
CC := arm-vita-eabi-gcc
CXX := arm-vita-eabi-g++

CFLAGS := $(CFLAGS) -DVITA -I$(VITASDK)/arm-vita-eabi/include -O1 -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard -ftree-vectorize
LDFLAGS := $(LDFLAGS) -L$(VITASDK)/arm-vita-eabi/lib -L$(VITASDK)/lib -Wl,-q

ifdef WITH_SDL2
SDL_LIBS := -L$(VITASDK)/arm-vita-eabi/lib -lSDL2 -lSceAudio_stub -lSceCtrl_stub -lvita2d -lSceGxm_stub -lSceHid_stub -lSceTouch_stub -lSceDisplay_stub -lSceAppMgr_stub -lSceSysmodule_stub -lSceCommonDialog_stub -lScePower_stub -lFLAC -lmikmod -lmpg123
SDL_FLAGS := -I$(VITASDK)/arm-vita-eabi/include/SDL2 -D_REENTRANT
else
SDL_LIBS := -L$(VITASDK)/arm-vita-eabi/lib -lSDL -lvita2d -lSceDisplay_stub -lSceCtrl_stub -lSceAudio_stub -lSceSysmodule_stub -lSceGxm_stub -lSceHid_stub -lSceAppMgr_stub -lSceCommonDialog_stub -lScePower_stub -lmikmod
SDL_FLAGS := -I$(VITASDK)/arm-vita-eabi/include/SDL -D_REENTRANT
endif

ifndef WITHOUT_MIXER
ifdef WITH_SDL2
SDL_LIBS := -lSDL2_mixer -lvorbisfile -lvorbis -logg $(SDL_LIBS)
else
SDL_LIBS := -lSDL_mixer -lvorbisfile -lvorbis -logg $(SDL_LIBS)
endif
endif

ifndef WITHOUT_IMAGE
ifdef WITH_SDL2
SDL_LIBS := $(SDL_LIBS) -lSDL2_image -ljpeg -lpng
else
SDL_LIBS := $(SDL_LIBS) -lSDL_image -ljpeg -lpng
endif
endif

ifndef WITHOUT_UNICODE
ifdef WITH_SDL2
SDL_LIBS := $(SDL_LIBS) -lSDL2_ttf -lfreetype
else
SDL_LIBS := $(SDL_LIBS) -lSDL_ttf -lfreetype
endif
endif
37 changes: 37 additions & 0 deletions src/engine/dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
***************************************************************************/
#if defined( _MSC_VER ) || defined( __MINGW32CE__ ) || defined( __MINGW32__ )
#include <windows.h>
#elif defined( VITA )
#include <psp2/io/dirent.h>
#else
#include <dirent.h>
#endif
Expand All @@ -46,6 +48,41 @@ void ListFiles::ReadDir( const std::string & path, const std::string & filter, b
} while ( FindNextFile( hFind, &data ) != 0 );
FindClose( hFind );
}
#elif defined( VITA )
// open the directory
int uid = sceIoDopen( path.c_str() );
if ( uid <= 0 )
return;

// iterate over the directory for files, print name and size of array (always 256)
// this means you use strlen() to get length of file name
SceIoDirent dir;

while ( sceIoDread( uid, &dir ) > 0 ) {
const std::string fullname = System::ConcatePath( path, dir.d_name );

// if not regular file
if ( !System::IsFile( fullname ) )
continue;

if ( filter.size() ) {
std::string filename( dir.d_name );

if ( sensitive ) {
if ( std::string::npos == filename.find( filter ) )
continue;
}
else {
if ( std::string::npos == StringLower( filename ).find( StringLower( filter ) ) )
continue;
}
}

push_back( fullname );
}

// clean up
sceIoDclose( uid );
#else
std::string correctedPath;
if ( !System::GetCaseInsensitivePath( path, correctedPath ) )
Expand Down
11 changes: 10 additions & 1 deletion src/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ namespace Cdrom
}
#endif

#ifdef VITA
SDL_Joystick * gGameController = NULL;
#endif

bool SDL::Init( const u32 system )
{
if ( System::isRunning() )
Expand All @@ -60,6 +64,9 @@ bool SDL::Init( const u32 system )
#ifdef WITH_NET
Network::Init();
#endif
#ifdef VITA
gGameController = SDL_JoystickOpen( 0 );
#endif

#if SDL_VERSION_ATLEAST( 2, 0, 0 )
#else
Expand Down Expand Up @@ -90,7 +97,9 @@ void SDL::Quit( void )
#endif
if ( SubSystem( SDL_INIT_AUDIO ) )
Mixer::Quit();

#ifdef VITA
SDL_JoystickClose( gGameController );
#endif
SDL_Quit();
}

Expand Down
3 changes: 3 additions & 0 deletions src/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#define INIT_AUDIO SDL_INIT_AUDIO
#define INIT_TIMER SDL_INIT_TIMER
#define INIT_CDROM SDL_INIT_CDROM
#ifdef VITA
#define INIT_JOYSTICK SDL_INIT_JOYSTICK
#endif

namespace SDL
{
Expand Down
Loading

0 comments on commit 85711c1

Please sign in to comment.