Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Android, Wii & 3DS toolchains #915

Merged
merged 7 commits into from Jul 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions builds/android/app/src/main/jni/src/Android.mk
Expand Up @@ -40,11 +40,13 @@ LOCAL_STATIC_LIBRARIES := cpufeatures
LOCAL_LDLIBS := -L$(LOCAL_PATH)/../../obj/local/$(TARGET_ARCH_ABI) \
-L$(EASYRPG_TOOLCHAIN_DIR)/lib -lGLESv1_CM -llog -lz \
-llcf -lSDL2_mixer -lmad -lvorbisfile -lvorbis -logg -lmodplug \
-lmpg123 -lfreetype -lpixman-1 -lpng -licui18n -licuuc -licudata \
-lmpg123 -lfreetype -lpixman-1 -lpng -lspeexdsp -lsndfile \
-licui18n -licuuc -licudata \
-lcpufeatures

LOCAL_CFLAGS := -O2 -Wall -Wextra -fno-rtti -DUSE_SDL \
-DHAVE_SDL_MIXER -DHAVE_MPG123 -DWANT_FMMIDI=2 -DLCF_SUPPORT_ICU
-DHAVE_SDL_MIXER -DHAVE_MPG123 -DWANT_FMMIDI=2 \
-DHAVE_LIBSNDFILE -DHAVE_LIBSPEEXDSP -DHAVE_OGGVORBIS

LOCAL_CPPFLAGS = $(LOCAL_C_FLAGS) -std=c++11

Expand Down
2 changes: 2 additions & 0 deletions builds/wii/Makefile
Expand Up @@ -40,6 +40,7 @@ CFLAGS = -g0 -O2 -Wall -Wextra \
-fomit-frame-pointer -ffast-math \
-flto -fdata-sections -ffunction-sections \
-DUSE_SDL -DNDEBUG -DWANT_FMMIDI=2 -DHAVE_MPG123 \
-DHAVE_LIBSNDFILE -DHAVE_LIBSPEEXDSP -DHAVE_TREMOR \
$(MACHDEP) $(INCLUDE)

CXXFLAGS = $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
Expand All @@ -53,6 +54,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,easyrpg-player-wii.map \

LIBS := -llcf -liconv -lpixman-1 -lpng -lz \
-lSDL_mixer -lSDL -lvorbisidec -lmpg123 \
-lspeexdsp -lsndfile \
-lfat -lwiiuse -lbte -logc -lm -lwiikeyboard
#-licuuc -licui18n -licudata

Expand Down
26 changes: 6 additions & 20 deletions src/audio_sdl.cpp
Expand Up @@ -108,9 +108,9 @@ namespace {
case AudioDecoder::Format::S8:
return AUDIO_S8;
case AudioDecoder::Format::U16:
return AUDIO_U16;
return AUDIO_U16SYS;
case AudioDecoder::Format::S16:
return AUDIO_S16;
return AUDIO_S16SYS;
#if SDL_MIXER_MAJOR_VERSION>1
case AudioDecoder::Format::S32:
return AUDIO_S32;
Expand All @@ -130,9 +130,9 @@ namespace {
return AudioDecoder::Format::U8;
case AUDIO_S8:
return AudioDecoder::Format::S8;
case AUDIO_U16:
case AUDIO_U16SYS:
return AudioDecoder::Format::U16;
case AUDIO_S16:
case AUDIO_S16SYS:
return AudioDecoder::Format::S16;
#if SDL_MIXER_MAJOR_VERSION>1
case AUDIO_S32:
Expand Down Expand Up @@ -348,18 +348,6 @@ void SdlAudio::SetupAudioDecoder(FILE* handle, const std::string& file, int volu
return;
}

// Detect bad AudioCVT implementations (SDL Wii)
static bool broken_test = false;
static bool audiocvt_broken = false;
if (!broken_test) {
broken_test = true;
SDL_BuildAudioCVT(&cvt, AUDIO_S16, 2, 44100, AUDIO_S16, 2, 44100 / 2);
if (!cvt.needed || cvt.rate_incr == 0.0) {
Output::Debug("SDL_AudioCVT implementation is broken. Resampling will not work.");
audiocvt_broken = true;
}
}

// Can't use BGM_Stop here because it destroys the audio_decoder
#if SDL_MAJOR_VERSION>1
// SDL2_mixer bug, see above
Expand All @@ -385,7 +373,7 @@ void SdlAudio::SetupAudioDecoder(FILE* handle, const std::string& file, int volu
AudioDecoder::Format audio_format = sdl_format_to_format(sdl_format);

int target_rate = audio_rate;
if (!audiocvt_broken && audio_decoder->GetType() == "midi") {
if (audio_decoder->GetType() == "midi") {
// FM Midi is very CPU heavy and the difference between 44100 and 22050
// is not hearable for MIDI
target_rate /= 2;
Expand All @@ -399,9 +387,7 @@ void SdlAudio::SetupAudioDecoder(FILE* handle, const std::string& file, int volu

// Don't care if successful, always build cvt
SDL_BuildAudioCVT(&cvt, format_to_sdl_format(device_format), (int)device_channels, device_rate, sdl_format, audio_channels, audio_rate);
if (audiocvt_broken) {
cvt.needed = false;
}
cvt.needed = false;

audio_decoder->SetFade(0, volume, fadein);
audio_decoder->SetPitch(pitch);
Expand Down
8 changes: 6 additions & 2 deletions src/decoder_libsndfile.cpp
Expand Up @@ -143,10 +143,14 @@ int LibsndfileDecoder::FillBuffer(uint8_t* buffer, int length) {
break;
case Format::S32:
{
decoded=sf_read_int(soundfile,(int32_t*)buffer,length/sizeof(int32_t));
// Uses int instead of int32_t because the 3ds toolchain typedefs
// to long int which is an incompatible pointer type
decoded=sf_read_int(soundfile,(int*)buffer,length/sizeof(int));

if(!decoded)
finished=true;
decoded*=sizeof(int32_t);

decoded *= sizeof(int);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChristianBreitwieser
Does this look okay for you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ghabry
Yeah it does, but why not drop int32_t altogether (no ifdef) and use int instead for all architectures.
The interface of libsndfile uses int anyway. sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items);

I just used int32_t for clarification (and to stay uniform with the int16_t above.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, was just unsure about the code :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using int_least32_t?

break;
default:
Expand Down
15 changes: 7 additions & 8 deletions src/input_buttons_gekko.cpp
Expand Up @@ -26,8 +26,7 @@ void Input::InitButtons() {

// Remote
buttons[TOGGLE_FPS].push_back(Keys::JOY_0); // A
//buttons[N1].push_back(Keys::JOY_0); // A
buttons[N2].push_back(Keys::JOY_1); // B
buttons[SHIFT].push_back(Keys::JOY_1); // B
buttons[CANCEL].push_back(Keys::JOY_2); // 1
buttons[DECISION].push_back(Keys::JOY_3); // 2
buttons[MINUS].push_back(Keys::JOY_4); // -
Expand All @@ -41,12 +40,12 @@ void Input::InitButtons() {
// Classic Controller
buttons[DECISION].push_back(Keys::JOY_9); // A
buttons[CANCEL].push_back(Keys::JOY_10); // B
buttons[N1].push_back(Keys::JOY_11); // X
buttons[N2].push_back(Keys::JOY_12); // Y
buttons[SHIFT].push_back(Keys::JOY_13); // L
buttons[DEBUG_THROUGH].push_back(Keys::JOY_14); // R
buttons[MULTIPLY].push_back(Keys::JOY_15); // Zl
buttons[DIVIDE].push_back(Keys::JOY_16); // Zr
buttons[SHIFT].push_back(Keys::JOY_11); // X
buttons[N1].push_back(Keys::JOY_12); // Y
buttons[N3].push_back(Keys::JOY_13); // L
buttons[N5].push_back(Keys::JOY_14); // R
buttons[N9].push_back(Keys::JOY_15); // Zl
buttons[TOGGLE_FPS].push_back(Keys::JOY_16); // Zr
buttons[MINUS].push_back(Keys::JOY_17); // -
buttons[PLUS].push_back(Keys::JOY_18); // +
buttons[CANCEL].push_back(Keys::JOY_19); // Home
Expand Down
9 changes: 3 additions & 6 deletions src/main_data.cpp
Expand Up @@ -92,7 +92,6 @@ void Main_Data::Init() {

if (!Player::is_3dsx) {
// Create savepath for CIA - unique for any ID
aptOpenSession();

// Generating save_path
u64 titleID;
Expand All @@ -101,15 +100,13 @@ void Main_Data::Init() {
sprintf(mainDir,"sdmc:/easyrpg-player/%016llX",titleID);

// Creating dirs if they don't exist
FS_Archive archive = (FS_Archive){ARCHIVE_SDMC, (FS_Path){PATH_EMPTY, 1, (u8*)""}};
FSUSER_OpenArchive(&archive);
FS_Archive archive;
FSUSER_OpenArchive(&archive, ARCHIVE_SDMC, {PATH_EMPTY, 1, (u8*)""});
FS_Path filePath=fsMakePath(PATH_ASCII, "/easyrpg-player");
FSUSER_CreateDirectory(archive,filePath, FS_ATTRIBUTE_DIRECTORY);
FS_Path filePath2=fsMakePath(PATH_ASCII, &mainDir[5]);
FSUSER_CreateDirectory(archive,filePath2, FS_ATTRIBUTE_DIRECTORY);
FSUSER_CloseArchive(&archive);

aptCloseSession();
FSUSER_CloseArchive(archive);

save_path = mainDir;
}
Expand Down
5 changes: 2 additions & 3 deletions src/player.cpp
Expand Up @@ -145,9 +145,8 @@ void Player::Init(int argc, char *argv[]) {
gfxInitDefault();
consoleInit(GFX_BOTTOM, NULL);

aptOpenSession();
APT_SetAppCpuTimeLimit(30);
aptCloseSession();

if (osGetKernelVersion() < SYSTEM_VERSION(2, 48, 3)) khaxInit(); // Executing libkhax just to be sure...
consoleClear();

Expand Down Expand Up @@ -183,7 +182,7 @@ void Player::Init(int argc, char *argv[]) {
hidInit();

// Enable 804 Mhz mode if on N3DS
u8 isN3DS;
bool isN3DS;
APT_CheckNew3DS(&isN3DS);
if (isN3DS) {
osSetSpeedupEnable(true);
Expand Down