PSVITA port and fix for audio decoder on 3DS port. #973

Merged
merged 24 commits into from Aug 8, 2016

Projects

None yet

3 participants

@Rinnegatamante
Member

As the title says.
PSVITA port lacks only of OGG support (both sounds and musics).
Everything else is fully working.

@Ghabry
Member
Ghabry commented Aug 4, 2016

For the pics I propose: Any other suggestions?

pics.zip
image1 crushed
pngout

@Ghabry
Member
Ghabry commented Aug 5, 2016

Great. Some BGM features are missing. Though to implement them you need a reference to the AudioDecoder.

The missing fade is noticable in the Ib video, the music should fade out when the light begins to flicker iirc.

Here are the important lines, copied from sdl_audio:

BGM_Play
// You can use GetVolume in the BGM thread to get the current volume, it takes care of fades
audio_decoder->SetFade(0, volume, fadein);
audio_decoder->SetPitch(pitch); // pitch is commented out in the argument list
bgm_starttick = DisplayUi->GetTicks();

BGM_GetTicks
return audio_decoder->GetTicks();

BGM_PlayedOnce
return audio_decoder->GetLoopCount() > 0;

BGM_Volume
// Only a convenience function, you have to still set it for the hardware using something like
// sceAudioOutSetVolume(audio_decoder->GetVolume(), ....)
audio_decoder->SetVolume(volume);

BGM_SetPitch
audio_decoder->SetPitch(pitch);

BGM_Fade
audio_decoder->SetFade(audio_decoder->GetVolume(), 0, fade);
bgm_starttick = DisplayUi->GetTicks();

SE_Play
Also has pitch and volume

Update
// The Fade needs a time delta to work:
if (audio_decoder && bgm_starttick > 0) {
    int t = DisplayUi->GetTicks();
    audio_decoder->Update(t - bgm_starttick);
    bgm_starttick = t;
}
@Rinnegatamante
Member

PlayedOnce is already implemented. Working on the other things.

@Ghabry
Member
Ghabry commented Aug 5, 2016

People who play Yume Nikki will need the buttons N1, N3, N5 and N9 btw. (SHIFT is already mapped) Are there some keys on the controller available to map them? Maybe abuse one of the analog sticks.

There are also much more buttons, but because everybody plays Yume Nikki these are enough ;)

@Rinnegatamante
Member

Mhhh maybe we can map the retrotouch or the touchscreen. OR the right analog. Cause there aren't other buttons available.

@Rinnegatamante
Member

Little note: retrotouch and touchscreen = PSVITA TV not compatible.

@Ghabry
Member
Ghabry commented Aug 5, 2016

The right analog offers at least 4 directions, so this sounds like a plan.

@Ghabry
Member
Ghabry commented Aug 5, 2016

Oh and you have to set the paths where the Runtime Package is searched.

This is in this function:
https://github.com/EasyRPG/Player/blob/master/src/filefinder.cpp#L388

Default is

add_rtp_path("/data/rtp/" + version_str + "/");

If you think this path is fine just keep it and don't modify the function :)

This is also not altered for the 3DS version, though not sure if that's a big deal.

@carstene1ns carstene1ns and 1 other commented on an outdated diff Aug 5, 2016
src/psp2_ui.cpp
@@ -134,6 +138,18 @@ void Psp2Ui::ProcessEvents() {
trigger_state = (input.buttons & SCE_CTRL_RTRIGGER);
if ((trigger_state != old_state) && trigger_state) zoom_state = ((zoom_state + 1) % 3);
+ // Left analog support
+ if (input.ly > 170) keys[Input::Keys::UP] = true;
+ else if (input.ly < 50) keys[Input::Keys::DOWN] = true;
+ else if (input.lx > 170) keys[Input::Keys::RIGHT] = true;
+ else if (input.lx < 50) keys[Input::Keys::LEFT] = true;
+
@carstene1ns
carstene1ns Aug 5, 2016 Member

As this is technically a analog stick, you should define for VITA

#  define SUPPORT_JOYSTICK
#  define SUPPORT_JOYSTICK_AXIS

in system.h and use something like that:

    keys[Input::Keys::JOY_AXIS_X_LEFT] = (input.lx < 50);
    keys[Input::Keys::JOY_AXIS_X_RIGHT] = (input.lx > 170);
    keys[Input::Keys::JOY_AXIS_Y_DOWN] = (input.ly < 50);
    keys[Input::Keys::JOY_AXIS_Y_UP] = (input.ly > 170);
@Rinnegatamante
Rinnegatamante Aug 5, 2016 Member

The same apply to 3DS port then with Circle Stick i suppose

@Rinnegatamante
Member

Talking back to this i previously said:
"Little note: retrotouch and touchscreen = PSVITA TV not compatible."

I discovered it's wrong since even on PSVITA TV there's a setting to emulate touchpad and touchscreen with analogs (basically pressing analogs + moving = emulating touch).
Looks still pretty uncomfortable to use but can be used if we need two extra buttons (just touchscreen tap and retrotouch tap).

@Ghabry Ghabry commented on an outdated diff Aug 6, 2016
builds/psvita/Makefile
+ -lSceKernel_stub -lSceDisplay_stub -lSceGxm_stub \
+ -lSceSysmodule_stub -lSceCtrl_stub -lm \
+ -lScePgf_stub -ljpeg -lfreetype -lc \
+ -lScePower_stub -lSceCommonDialog_stub -lpng16 -lz \
+ -lmpg123 -lSceAudio_stub
+
+
+PREFIX = arm-vita-eabi
+CC = $(PREFIX)-gcc
+CXX = $(PREFIX)-g++
+CFLAGS = -Wl,-q -O3 -DPSP2 -DHAVE_LIBSPEEXDSP \
+ -DSUPPORT_AUDIO -DHAVE_LIBSNDFILE \
+ -DHAVE_OGGVORBIS -DHAVE_MPG123 -DWANT_FMMIDI=1 \
+ -I$(VITASDK)/arm-vita-eabi/include/liblcf \
+ -I$(VITASDK)/arm-vita-eabi/include/pixman-1
+CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11
@Ghabry
Ghabry Aug 6, 2016 Member

For better cooperation with our PR builder I ask you to add some lines here (they won't interfere with yours so is fine ;))

Before PREFIX:

ifeq ($(strip $(LIBLCF_DIR)),)
LIBLCF_DIR := $(TOOLCHAIN_DIR)
endif

To CFLAGS add:
        -I$(TOOLCHAIN_DIR)/include \
        -I$(LIBLCF_DIR)/include/liblcf \
        -I$(TOOLCHAIN_DIR)/include/pixman-1 \
        -L$(TOOLCHAIN_DIR)/lib \
        -L$(LIBLCF_DIR)/lib

To CXXFLAGS add (should make the file a bit smaller, we don't need RTTI):
        -fno-rtti

@Ghabry
Member
Ghabry commented Aug 7, 2016

After adding the mentioned makefile lines, fixing the whitespacing in psp2_ui.cpp (some lines use spaces instead of tabs) and doing a rebase on master to get rid of the merge commits I think this one here is okay in it's current state.

(make a backup of your before if you are afraid)

git rebase upstream/master
git push -f origin

As a long term solution I think we should add another audio system that mixes BGM+SE together in software so the porter only has to play that buffer, also works around the channel limits some hardware has. Will make the life much easier for all non-SDL ports ๐Ÿ‘

Rinnegatamante added some commits Aug 4, 2016
@Rinnegatamante Rinnegatamante PSVITA: First commit.
PSVITA: First commit.
37f254e
@Rinnegatamante Rinnegatamante PSVITA: Deadlock and conditions order fix.
PSVITA: Deadlock and conditions order fix.
8f19ed9
@Rinnegatamante Rinnegatamante Removed unused code.
Removed unused code.
4a8b991
@Rinnegatamante Rinnegatamante PSVITA: First attempt for sounds support.
PSVITA: First attempt for sounds support.
1be52e6
@Rinnegatamante Rinnegatamante PSVITA: Now sounds are correctly working.
PSVITA: Now sounds are correctly working.
7b21f12
@Rinnegatamante Rinnegatamante PSVITA: Centered image for zoomed res.
PSVITA: Centered image for zoomed res.
4f740ed
@Rinnegatamante Rinnegatamante PSVITA: Properly closing sfx threads.
PSVITA: Properly closing sfx threads.
0139ba1
@Rinnegatamante Rinnegatamante Fix for BGM crashes when audio decoder called twice.
Fix for BGM crashes when audio decoder called twice.
9c3a6b2
@Rinnegatamante Rinnegatamante Bugfixes for sounds. Added pitch and fade support.
Bugfixes for sounds. Added pitch and fade support.
218a168
@Rinnegatamante Rinnegatamante Increased heap size to 192 MB.
Increased heap size to 192 MB.
57dafc5
@Rinnegatamante Rinnegatamante PSVITA: Added RTP support.
PSVITA: Added RTP support.
6840f1d
@Rinnegatamante Rinnegatamante Reduced stuttering when sounds are spammed.
Reduced stuttering when sounds are spammed.
9c39510
@Rinnegatamante Rinnegatamante Added analogs support and 444 Mhz mode usage.
Added analogs support and 444 Mhz mode usage.
8a2312d
@Rinnegatamante Rinnegatamante Makefile flags fix and a bit of libraries cleanup.
Makefile flags fix and a bit of libraries cleanup.
edbbc5e
@Rinnegatamante Rinnegatamante PSVITA: Added OGG support.
PSVITA: Added OGG support.
f8acff9
@Rinnegatamante Rinnegatamante Bugfix for Y axis inversion on left analog.
Bugfix for Y axis inversion on left analog.
297703e
@Rinnegatamante Rinnegatamante Fix for Windows build.
Fix for Windows build.
4ec7266
@Rinnegatamante Rinnegatamante Added vpk template and assets.
Added vpk template and assets.
cb3533c
@Rinnegatamante Rinnegatamante Cleanup and adjustments.
Cleanup and adjustments.
b602c69
@Rinnegatamante Rinnegatamante Ident fix.
Ident fix.
c2748cd
@Ghabry Ghabry commented on an outdated diff Aug 7, 2016
builds/psvita/Makefile
@@ -32,10 +32,10 @@ CFLAGS = -Wl,-q -O3 -DPSP2 -DHAVE_LIBSPEEXDSP \
-I$(VITASDK)/arm-vita-eabi/include/liblcf \
-I$(VITASDK)/arm-vita-eabi/include/pixman-1
@Ghabry
Ghabry Aug 7, 2016 Member

This line needs a "" at the end.
When Github Desktop support "ammend commit" you can tick that checkbox to integrate it into this commit.

@Rinnegatamante Rinnegatamante Compilation fixes.
Compilation fixes.
919332c
@Ghabry
Member
Ghabry commented Aug 7, 2016

Jenkins: Test this please

@carstene1ns carstene1ns commented on an outdated diff Aug 7, 2016
src/filefinder.cpp
@@ -36,10 +36,16 @@
# include "dirent_win.h"
# endif
#else
-# include <dirent.h>
+# ifdef PSP2
+# include <psp2/io/dirent.h>
+# include <psp2/io/stat.h>
+# define S_ISDIR SCE_S_ISDIR
+# else
+# include <dirent.h>
+# include <sys/stat.h>
@carstene1ns
carstene1ns Aug 7, 2016 Member

Found a stray <Tab> here.

@carstene1ns carstene1ns commented on an outdated diff Aug 7, 2016
src/filefinder.cpp
@@ -675,29 +687,52 @@ FileFinder::Directory FileFinder::GetDirectoryMembers(const std::string& path, F
# define readdir _wreaddir
#elif _3DS
std::string wpath = path + "/";
+#elif PSP2
+# define opendir sceIoDopen
+# define closedir sceIoDclose
+# define wpath path
+# define dirent SceIoDirent
+# define readdir sceIoDread
#else
@carstene1ns
carstene1ns Aug 7, 2016 Member

Question: Why the need to define these and then later use the redefinitions?
Would make more sense to use them directly to me.

@carstene1ns carstene1ns commented on an outdated diff Aug 7, 2016
src/main_data.cpp
@@ -107,6 +109,7 @@ void Main_Data::Init() {
FS_Path filePath2=fsMakePath(PATH_ASCII, &mainDir[5]);
FSUSER_CreateDirectory(archive,filePath2, FS_ATTRIBUTE_DIRECTORY);
FSUSER_CloseArchive(archive);
+
@carstene1ns
carstene1ns Aug 7, 2016 Member

Stray empty line.

@carstene1ns carstene1ns commented on an outdated diff Aug 7, 2016
src/psp2_decoder.h
+ * EasyRPG Player is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * EasyRPG Player is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _EASYRPG_3DS_DECODER_H_
+#define _EASYRPG_3DS_DECODER_H_
@carstene1ns
carstene1ns Aug 7, 2016 Member

This is likely wrong from copying it over. ;-)

@carstene1ns carstene1ns commented on an outdated diff Aug 7, 2016
src/psp2_ui.h
+ * EasyRPG Player is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * EasyRPG Player is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _EASYRPG_3DSUI_H_
+#define _EASYRPG_3DSUI_H_
@carstene1ns
carstene1ns Aug 7, 2016 Member

Same applies here.

@Ghabry Ghabry commented on an outdated diff Aug 7, 2016
builds/psvita/Makefile
+ -I$(TOOLCHAIN_DIR)/include/pixman-1 \
+ -L$(TOOLCHAIN_DIR)/lib \
+ -L$(LIBLCF_DIR)/lib
+
+CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++11 -fno-rtti
+ASFLAGS = $(CFLAGS)
+
+all: $(TARGET).vpk
+
+$(TARGET).vpk: $(TARGET).velf
+ vita-make-fself $< .\release\eboot.bin
+ vita-mksfoex -s TITLE_ID=$(APP_ID) "$(APP_TITLE)" param.sfo
+ cp -f param.sfo ./release/sce_sys/param.sfo
+
+ #------------ Comment this if you don't have 7zip ------------------
+ 7za a -tzip ./$(TARGET).vpk -r .\release\sce_sys\* .\release\eboot.bin
@Ghabry
Ghabry Aug 7, 2016 Member

Please convert the \ to /, will also work on Windows

@carstene1ns
Member

This is my working Makefile rule:

$(TARGET).vpk: $(TARGET).velf
    vita-make-fself $< release/eboot.bin
    vita-mksfoex -s TITLE_ID=$(APP_ID) "$(APP_TITLE)" release/sce_sys/param.sfo
    7za a -tzip $(TARGET).vpk ./release/sce_sys ./release/eboot.bin
@Ghabry Ghabry commented on an outdated diff Aug 8, 2016
src/psp2_ui.cpp
+ //Resolution changing support
+ bool old_state = trigger_state;
+ trigger_state = (input.buttons & SCE_CTRL_RTRIGGER);
+ if ((trigger_state != old_state) && trigger_state) zoom_state = ((zoom_state + 1) % 3);
+
+ // Left analog support
+ keys[Input::Keys::JOY_AXIS_X_LEFT] = (input.lx < 50);
+ keys[Input::Keys::JOY_AXIS_X_RIGHT] = (input.lx > 170);
+ keys[Input::Keys::JOY_AXIS_Y_DOWN] = (input.ly > 170);
+ keys[Input::Keys::JOY_AXIS_Y_UP] = (input.ly < 50);
+
+ // Right analog support for extra buttons
+ if (input.ry > 170) keys[Input::Keys::N1] = true;
+ else if (input.ry < 50) keys[Input::Keys::N3] = true;
+ else if (input.rx > 170) keys[Input::Keys::N5] = true;
+ else if (input.rx < 50) keys[Input::Keys::N9] = true;
@Ghabry
Ghabry Aug 8, 2016 Member

A spanish user on twitter reported that the keys of the right joystick get stuck in "on" state when used.
Looks like he is rรฌght :)

@Rinnegatamante Rinnegatamante Fix for right analog buttons state.
Fix for right analog buttons state.
d38bd5b
@Ghabry
Member
Ghabry commented Aug 8, 2016
HAVE_ZIP := $(shell command -v zip 2> /dev/null)

all: $(TARGET).vpk

$(TARGET).vpk: $(TARGET).velf
        vita-make-fself $< release/eboot.bin
        vita-mksfoex -s TITLE_ID=$(APP_ID) "$(APP_TITLE)" release/sce_sys/param.sfo
ifdef HAVE_ZIP
        cd release; zip ../$(TARGET).vpk -r ./sce_sys ./eboot.bin
else
        7z a -tzip ./$(TARGET).vpk -r ./release/sce_sys/* ./release/eboot.bin
endif

Another solution that could make both happy (Replace space with tabs!). The 7z line is wrong, use your Windows one there with the ""

@Rinnegatamante
Member

On my side it apparently works fine so i suppose it's ready for a push

@Rinnegatamante Rinnegatamante Fixxed compilation under Linux.
Fixxed compilation under Linux.
a726c1e
@Ghabry
Member
Ghabry commented Aug 8, 2016

Jenkins: Test this please

@Ghabry Ghabry merged commit 2aeb4bf into EasyRPG:master Aug 8, 2016

6 checks passed

Android (armeabi-v7a) Build finished.
Details
GNU/Linux Build finished.
Details
OSX Build finished.
Details
Windows (x64) Build finished.
Details
Windows (x86) Build finished.
Details
web Build finished.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment