Skip to content

Commit

Permalink
added support for firmware 3.x.x (thanks to Toscanelli for the addres…
Browse files Browse the repository at this point in the history
…ses and FIX94 for testing)
  • Loading branch information
dimok789 committed Apr 28, 2016
1 parent d179849 commit 9174e3c
Show file tree
Hide file tree
Showing 10 changed files with 1,237 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ MAKEFLAGS += --no-print-directory
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lgcc -lgd -lpng -lz -lfreetype -lvorbisidec
LIBS := -lgcc -lgd -lpng -lz -lfreetype -lmad -lvorbisidec

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
Expand Down
2 changes: 1 addition & 1 deletion installer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sd_loader_elf := ../sd_loader/sd_loader.elf
CFLAGS += -DUSE_SD_LOADER
ASFLAGS += -DUSE_SD_LOADER

all: clean setup main532 main550 main500 main410 main400
all: clean setup main532 main550 main500 main410 main400 main310 main300

sd_loader.h: $(sd_loader_elf)
xxd -i $< | sed "s/unsigned/static const unsigned/g;s/loader/loader/g;s/build_//g" > $@
Expand Down
28 changes: 27 additions & 1 deletion installer/kernel_patches.S
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,32 @@

#define BAT_SET_NOP_ADDR_8 0xFFEE0F50
#define BAT_SET_NOP_ADDR_9 0xFFEE0F54
#elif (VER == 310)
#define BAT_SETUP_HOOK_ADDR 0xFFF19EC4

#define BAT_SET_NOP_ADDR_1 0xFFF06590
#define BAT_SET_NOP_ADDR_2 0xFFF0661C
#define BAT_SET_NOP_ADDR_3 0xFFF003C8
#define BAT_SET_NOP_ADDR_4 0xFFF003CC
#define BAT_SET_NOP_ADDR_5 0xFFF19FAC
#define BAT_SET_NOP_ADDR_6 0xFFF19FC8
// #define BAT_SET_NOP_ADDR_7 not present in 3.1.0

#define BAT_SET_NOP_ADDR_8 0xFFEE0FB0
#define BAT_SET_NOP_ADDR_9 0xFFEE0FB4
#elif (VER == 300)
#define BAT_SETUP_HOOK_ADDR 0xFFF19E2C

#define BAT_SET_NOP_ADDR_1 0xFFF06590
#define BAT_SET_NOP_ADDR_2 0xFFF0661C
#define BAT_SET_NOP_ADDR_3 0xFFF003C8
#define BAT_SET_NOP_ADDR_4 0xFFF003CC
#define BAT_SET_NOP_ADDR_5 0xFFF19F14
#define BAT_SET_NOP_ADDR_6 0xFFF19F30
// #define BAT_SET_NOP_ADDR_7 not present in 3.0.x

#define BAT_SET_NOP_ADDR_8 0xFFEE0DB8
#define BAT_SET_NOP_ADDR_9 0xFFEE0DBC
#else
#error Please define valid values for kernel setup.
#endif
Expand All @@ -81,7 +107,7 @@
#define BAT4U_VAL 0x008000FF
#if VER >= 410
#define BAT4L_VAL 0x30800012
#elif VER == 400
#elif VER <= 400
#define BAT4L_VAL 0x4E800012
#else
#error Please define valid value for firmware setup.
Expand Down
11 changes: 10 additions & 1 deletion installer/launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@
#define KERN_SYSCALL_TBL_3 0xFFE85C90
#define KERN_SYSCALL_TBL_4 0xFFE85490
#define KERN_SYSCALL_TBL_5 0xFFE85890 // works with browser
#elif ( (VER == 300) || (VER == 310) )
#define ADDRESS_OSTitle_main_entry_ptr 0x1005BBC0
#define ADDRESS_main_entry_hook 0x0101894C // used OSDynLoad_Acquire 0x01022CBC from libwiiu to calculate

#define KERN_SYSCALL_TBL_1 0xFFE84D50
#define KERN_SYSCALL_TBL_2 0xFFE85150
#define KERN_SYSCALL_TBL_3 0xFFE85D50 // comes after KERN_SYSCALL_TBL_5
#define KERN_SYSCALL_TBL_4 0xFFE85550
#define KERN_SYSCALL_TBL_5 0xFFE85950
#else
#error Please define valid values for firmware.
#endif // VER
Expand All @@ -68,7 +77,7 @@
#if (VER >= 410)
#define ROOTRPX_DBAT0L_VAL 0x30000012
#define COREINIT_DBAT0L_VAL 0x32000012
#elif (VER == 400)
#elif (VER <= 400)
#define ROOTRPX_DBAT0L_VAL 0x4E000012
#define COREINIT_DBAT0L_VAL 0x4D000012
#else
Expand Down
32 changes: 24 additions & 8 deletions src/dynamic_libs/ax_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#include "common/common.h"
#include "os_functions.h"
#include "ax_functions.h"

EXPORT_DECL(void, AXInitWithParams, u32 * params);
EXPORT_DECL(void, AXInit, void);
EXPORT_DECL(void, AXQuit, void);
EXPORT_DECL(u32, AXGetInputSamplesPerSec, void);
EXPORT_DECL(u32, AXGetInputSamplesPerFrame, void);
Expand All @@ -47,13 +49,27 @@ EXPORT_DECL(void, AXSetVoiceLoopOffset, void *v, u32 offset);

void InitAXFunctionPointers(void)
{
unsigned int sound_handle = 0;
unsigned int *funcPointer = 0;
unsigned int sound_handle;
OSDynLoad_Acquire("sndcore2.rpl", &sound_handle);

OS_FIND_EXPORT(sound_handle, AXInitWithParams);
if(OS_FIRMWARE >= 400)
{
AXInit = 0;

OSDynLoad_Acquire("sndcore2.rpl", &sound_handle);
OS_FIND_EXPORT(sound_handle, AXInitWithParams);
OS_FIND_EXPORT(sound_handle, AXGetInputSamplesPerSec);
}
else
{
AXInitWithParams = 0;
AXGetInputSamplesPerSec = 0;

OSDynLoad_Acquire("snd_core.rpl", &sound_handle);
OS_FIND_EXPORT(sound_handle, AXInit);
}

OS_FIND_EXPORT(sound_handle, AXQuit);
OS_FIND_EXPORT(sound_handle, AXGetInputSamplesPerSec);
OS_FIND_EXPORT(sound_handle, AXVoiceBegin);
OS_FIND_EXPORT(sound_handle, AXVoiceEnd);
OS_FIND_EXPORT(sound_handle, AXSetVoiceType);
Expand All @@ -77,18 +93,18 @@ void ProperlyEndTransitionAudio(void)
bool (* check_os_audio_transition_flag_old)(void);
void (* AXInit_old)(void);
void (* AXQuit_old)(void);

unsigned int *funcPointer = 0;
unsigned int sound_handle;
OSDynLoad_Acquire("snd_core.rpl", &sound_handle);

OS_FIND_EXPORT_EX(sound_handle, check_os_audio_transition_flag, check_os_audio_transition_flag_old);
OS_FIND_EXPORT_EX(sound_handle, AXInit, AXInit_old);
OS_FIND_EXPORT_EX(sound_handle, AXQuit, AXQuit_old);

if (check_os_audio_transition_flag_old())
{
AXInit_old();
AXQuit_old();
}
}
}
1 change: 1 addition & 0 deletions src/dynamic_libs/ax_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void InitAXFunctionPointers(void);
void ProperlyEndTransitionAudio(void);

extern void (* AXInitWithParams)(u32 * params);
extern void (* AXInit)(void);
extern void (* AXQuit)(void);
extern u32 (* AXGetInputSamplesPerSec)(void);
extern s32 (* AXVoiceBegin)(void *v);
Expand Down
17 changes: 10 additions & 7 deletions src/sounds/SoundHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ SoundDecoder * SoundHandler::GetSoundDecoder(const char * filepath)
}
else if(magic == 0x52494646) // 'RIFF'
{
//return new WavDecoder(filepath);
return new WavDecoder(filepath);
}
else if(CheckMP3Signature((u8 *) &magic) == true)
{
//return new Mp3Decoder(filepath);
return new Mp3Decoder(filepath);
}

return new SoundDecoder(filepath);
Expand Down Expand Up @@ -204,11 +204,11 @@ SoundDecoder * SoundHandler::GetSoundDecoder(const u8 * sound, int length)
}
else if(magic[0] == 0x52494646) // 'RIFF'
{
//return new WavDecoder(sound, length);
return new WavDecoder(sound, length);
}
else if(CheckMP3Signature(check) == true)
{
//return new Mp3Decoder(sound, length);
return new Mp3Decoder(sound, length);
}

return new SoundDecoder(sound, length);
Expand All @@ -217,15 +217,18 @@ SoundDecoder * SoundHandler::GetSoundDecoder(const u8 * sound, int length)
void SoundHandler::executeThread()
{
// v2 sound lib can not properly end transition audio on old firmwares
if (OS_FIRMWARE <= 410)
if (OS_FIRMWARE >= 400 && OS_FIRMWARE <= 410)
{
ProperlyEndTransitionAudio();
}

//! initialize 48 kHz renderer
u32 params[3] = { 1, 0, 0 };
AXInitWithParams(params);

if(AXInitWithParams != 0)
AXInitWithParams(params);
else
AXInit();

// The problem with last voice on 500 was caused by it having priority 0
// We would need to change this priority distribution if for some reason
Expand Down
4 changes: 3 additions & 1 deletion src/sounds/Voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ class Voice
voiceBuffer.loop_offset = ((nextBuffer - buffer) >> 1);
nextBufferSize = nextBufSize;

ratioBits[0] = (u32)(0x00010000 * ((f32)sampleRate / (f32)AXGetInputSamplesPerSec()));
u32 samplesPerSec = (AXGetInputSamplesPerSec != 0) ? AXGetInputSamplesPerSec() : 32000;

ratioBits[0] = (u32)(0x00010000 * ((f32)sampleRate / (f32)samplesPerSec));
ratioBits[1] = 0;
ratioBits[2] = 0;
ratioBits[3] = 0;
Expand Down
Loading

0 comments on commit 9174e3c

Please sign in to comment.