diff --git a/.gitignore b/.gitignore index 7e5fd52..ffed149 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ encryptKeyWith *.zip *.bat *.jar -*.rpx \ No newline at end of file +*.rpx +TODO.txt diff --git a/Makefile b/Makefile index 9af5e2b..642a704 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ MAKEFLAGS += --no-print-directory #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lfat -liosuhax -lfreetype -lpng -lz -lm +LIBS := -ldynamiclibs -lfat -liosuhax -lfreetype -lpng -lz -lm #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/src/common/common.h b/src/common/common.h index 538b5ad..790aa1c 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -18,7 +18,6 @@ extern "C" { #define ELF_DATA_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x00)) #define ELF_DATA_SIZE (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x04)) #define MAIN_ENTRY_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x00)) -#define OS_FIRMWARE (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x04)) #define OS_SPECIFICS ((OsSpecifics*)(MEM_BASE + 0x1500)) diff --git a/src/common/fs_defs.h b/src/common/fs_defs.h index 37feb3f..3ada496 100644 --- a/src/common/fs_defs.h +++ b/src/common/fs_defs.h @@ -31,6 +31,13 @@ extern "C" { #define FS_CLIENT_SIZE 0x1700 #define FS_CMD_BLOCK_SIZE 0xA80 +#define FSA_STATUS_OK 0 +#define FSA_STATUS_END_OF_DIRECTORY (-4) +#define FSA_STATUS_END_OF_FILE (-5) +#define FSA_STATUS_ALREADY_EXISTS (-22) +#define FSA_STATUS_NOT_FOUND (-23) +#define FSA_STATUS_NOT_EMPTY (-24) + typedef struct { uint32_t flag; diff --git a/src/controllers.c b/src/controllers.c index 1509e1a..e4f40fd 100644 --- a/src/controllers.c +++ b/src/controllers.c @@ -9,6 +9,10 @@ s32 padErrors[4]; u32 padTypes[4]; KPADData pads[4]; +uint32_t buttons_hold[5]; //Held buttons +uint32_t buttons_pressed[5]; //Pressed buttons +uint32_t buttons_released[5]; //Released buttons + void pingControllers() { for (int i = 0; i < 4; i++) { padErrors[i] = WPADProbe(i, &padTypes[i]); @@ -82,15 +86,15 @@ int checkButton(int button, int state) { switch(state) { case PRESS: - stateArray = &buttons_pressed; + stateArray = buttons_pressed; break; case HOLD: - stateArray = &buttons_hold; + stateArray = buttons_hold; break; case RELEASE: - stateArray = &buttons_released; + stateArray = buttons_released; break; default: diff --git a/src/controllers.h b/src/controllers.h index c343fba..a991b0a 100644 --- a/src/controllers.h +++ b/src/controllers.h @@ -1,8 +1,8 @@ #ifndef CONTROLLERS_H #define CONTROLLERS_H -#include "dynamic_libs/padscore_functions.h" -#include "dynamic_libs/vpad_functions.h" +#include +#include enum buttons { PAD_BUTTON_A, @@ -37,10 +37,6 @@ enum buttonStates { RELEASE }; -uint32_t buttons_hold[5]; //Held buttons -uint32_t buttons_pressed[5]; //Pressed buttons -uint32_t buttons_released[5]; //Released buttons - void pingControllers(); void updateButtons(); bool stickPos(u8 stick, f32 value); diff --git a/src/draw.c b/src/draw.c index 6d68dfd..c12e795 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1,6 +1,6 @@ #include "draw.h" -unsigned char *scrBuffer; +uint8_t *scrBuffer; int scr_buf0_size = 0; int scr_buf1_size = 0; bool cur_buf1; @@ -10,17 +10,26 @@ RGBAColor fcolor = {0xFFFFFFFF}; FT_Library library; FT_Face face; -void initDraw(char* buf, int size0, int size1) { - scrBuffer = buf; - scr_buf0_size = size0; - scr_buf1_size = size1; - +void drawInit() { + OSScreenInit(); + scr_buf0_size = OSScreenGetBufferSizeEx(0); + scr_buf1_size = OSScreenGetBufferSizeEx(1); + scrBuffer = MEM1_alloc(scr_buf0_size + scr_buf1_size, 0x100); + OSScreenSetBufferEx(0, scrBuffer); + OSScreenSetBufferEx(1, (scrBuffer + scr_buf0_size)); + OSScreenEnableEx(0, 1); + OSScreenEnableEx(1, 1); clearBuffers(); - uint32_t *screen2 = scrBuffer + scr_buf0_size; + + u32* screen2 = (u32*)scrBuffer + scr_buf0_size; OSScreenPutPixelEx(1, 0, 0, 0xABCDEFFF); - if (screen2[0] == 0xABCDEFFF) cur_buf1 = false; - else cur_buf1 = true; + cur_buf1 = screen2[0] != 0xABCDEFFF; +} + +void drawFini() { + MEM1_free(scrBuffer); + scrBuffer = NULL; } void flipBuffers() { @@ -34,11 +43,11 @@ void flipBuffers() { } void clearBuffers() { - for(int i = 0; i < 2; i++) { - OSScreenClearBufferEx(0, 0); - OSScreenClearBufferEx(1, 0); - flipBuffers(); - } + for(int i = 0; i < 2; i++) { + OSScreenClearBufferEx(0, 0); + OSScreenClearBufferEx(1, 0); + flipBuffers(); + } } void drawString(int x, int line, char* string) { @@ -62,9 +71,10 @@ void drawPixel(int x, int y, u8 r, u8 g, u8 b, u8 a) { /*uint32_t num = (r << 24) | (g << 16) | (b << 8) | a; OSScreenPutPixelEx(0, x, y, num); OSScreenPutPixelEx(1, x, y, num);*/ + if (x < 0 || y < 0 || x >= 896 || y >= 480) return; int width = 1280; //height = 1024 720? - char *screen = scrBuffer; + uint8_t *screen = scrBuffer; int otherBuff0 = scr_buf0_size / 2; int otherBuff1 = scr_buf1_size / 2; float opacity = a / 255.0; @@ -87,7 +97,7 @@ void drawPixel(int x, int y, u8 r, u8 g, u8 b, u8 a) { screen[v + 3] = a;*/ width = 896; //height = 480; - char *screen2 = scrBuffer + scr_buf0_size; + uint8_t *screen2 = scrBuffer + scr_buf0_size; u32 v = (x + y * width) * 4; if (cur_buf1) v += otherBuff1; screen2[v ] = r * opacity + (1 - opacity) * screen2[v]; @@ -215,7 +225,7 @@ void drawPic(int x, int y, u32 w, u32 h, float scale, u32* pixels) { void drawTGA(int x, int y, float scale, u8* fileContent) { u32 w = tgaGetWidth(fileContent), h = tgaGetHeight(fileContent); u32 nw = w, nh = h; - u32* out = tgaRead(fileContent, TGA_READER_RGBA); + u32* out = (u32*)tgaRead(fileContent, TGA_READER_RGBA); if (scale <= 0) scale = 1; nw = w * scale; nh = h * scale; @@ -230,7 +240,7 @@ void drawTGA(int x, int y, float scale, u8* fileContent) { } void drawRGB5A3(int x, int y, float scale, u8* fileContent) { - u32 w = 192, h = 64, num = 0; + u32 w = 192, h = 64; u32 nw = w, nh = h; if (scale <= 0) scale = 1; @@ -266,25 +276,25 @@ void drawBackgroundDRC(u32 w, u32 h, u8* out) { uint32_t *screen2 = NULL; int otherBuff1 = scr_buf1_size / 2; - if (cur_buf1) screen2 = scrBuffer + scr_buf0_size + otherBuff1; - else screen2 = scrBuffer + scr_buf0_size; + if (cur_buf1) screen2 = (uint32_t*)scrBuffer + scr_buf0_size + otherBuff1; + else screen2 = (uint32_t*)scrBuffer + scr_buf0_size; memcpy(screen2, out, w * h * 4); } void drawBackgroundTV(u32 w, u32 h, u8* out) { - uint32_t *screen1 = scrBuffer; + uint32_t *screen1 = (uint32_t*)scrBuffer; int otherBuff0 = scr_buf0_size / 2; - if (cur_buf1) screen1 = scrBuffer + otherBuff0; + if (cur_buf1) screen1 = (uint32_t*)scrBuffer + otherBuff0; memcpy(screen1, out, w * h * 4); } bool initFont(void* fontBuf, FT_Long fsize) { - FT_Long size = fsize; + FT_Long size = fsize; if (fontBuf) { ttfFont = fontBuf; } else { - OSGetSharedData(2, 0, &ttfFont, &size); + OSGetSharedData(2, 0, ttfFont, (u32*)&size); } FT_Error error; @@ -305,7 +315,7 @@ bool initFont(void* fontBuf, FT_Long fsize) { void freeFont(void* fontBuf) { FT_Done_Face(face); - FT_Done_FreeType(library); + FT_Done_FreeType(library); //if (fontBuf) free(fontBuf); } @@ -315,7 +325,7 @@ void draw_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y) { FT_Int y_max = y + bitmap->rows; switch(bitmap->pixel_mode) { - case FT_PIXEL_MODE_GRAY: + case FT_PIXEL_MODE_GRAY: { x_max = x + bitmap->width; for (i = x, p = 0; i < x_max; i++, p++) { for (j = y, q = 0; j < y_max; j++, q++) { @@ -331,7 +341,8 @@ void draw_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y) { } } break; - case FT_PIXEL_MODE_LCD: + } + case FT_PIXEL_MODE_LCD: { x_max = x + bitmap->width / 3; for (i = x, p = 0; i < x_max; i++, p++) { for (j = y, q = 0; j < y_max; j++, q++) { @@ -345,21 +356,7 @@ void draw_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y) { } } break; - // case FT_PIXEL_MODE_BGRA: - // x_max = x + bitmap->width/2; - // for (i = x, p = 0; i < x_max; i++, p++) { - // for (j = y, q = 0; j < y_max; j++, q++) { - // if (i < 0 || j < 0 || i >= 854 || j >= 480) continue; - // u8 cb = bitmap->buffer[q * bitmap->pitch + p * 4]; - // u8 cg = bitmap->buffer[q * bitmap->pitch + p * 4 + 1]; - // u8 cr = bitmap->buffer[q * bitmap->pitch + p * 4 + 2]; - // u8 ca = bitmap->buffer[q * bitmap->pitch + p * 4 + 3]; - // - // if ((cr | cg | cb) == 0) continue; - // drawPixel(i, j, cr, cg, cb, ca); - // } - // } - // break; + } } } @@ -379,19 +376,23 @@ void ttfFontColor32(u32 color) { } void ttfFontColor(u8 r, u8 g, u8 b, u8 a) { - RGBAColor color = {.r = r, .g = g, .b = b, .a = a}; + RGBAColor color; + color.r = r; + color.g = g; + color.b = b; + color.a = a; ttfFontColor32(color.c); } -int ttfPrintString(int x, int y, char *string, bool wWrap, bool ceroX) { +int ttfPrintString(int x, int y, const char *string, bool wWrap, bool ceroX) { FT_GlyphSlot slot = face->glyph; FT_Error error; int pen_x = x, pen_y = y; - FT_UInt previous_glyph; + FT_UInt previous_glyph = 0; - while(*string) { + while(*string) { uint32_t buf = *string++; - int dy = 0; + //int dy = 0; if ((buf >> 6) == 3) { if ((buf & 0xF0) == 0xC0) { @@ -422,14 +423,14 @@ int ttfPrintString(int x, int y, char *string, bool wWrap, bool ceroX) { //error = FT_Load_Char(face, buf, FT_LOAD_RENDER); - FT_UInt glyph_index; + FT_UInt glyph_index; glyph_index = FT_Get_Char_Index(face, buf); if (FT_HAS_KERNING(face)) { FT_Vector vector; FT_Get_Kerning(face, previous_glyph, glyph_index, FT_KERNING_DEFAULT, &vector); pen_x += (vector.x >> 6); - dy = vector.y >> 6; + //dy = vector.y >> 6; } error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);//FT_LOAD_COLOR);// @@ -458,13 +459,13 @@ int ttfPrintString(int x, int y, char *string, bool wWrap, bool ceroX) { return pen_x; } -int ttfStringWidth(char *string, s8 part) { +int ttfStringWidth(const char *string, s8 part) { FT_GlyphSlot slot = face->glyph; FT_Error error; int pen_x = 0, max_x = 0, spart = 1; - FT_UInt previous_glyph; + FT_UInt previous_glyph = 0; - while(*string) { + while(*string) { uint32_t buf = *string++; if ((buf >> 6) == 3) { if ((buf & 0xF0) == 0xC0) { @@ -488,7 +489,7 @@ int ttfStringWidth(char *string, s8 part) { //error = FT_Load_Char(face, buf, FT_LOAD_RENDER); - FT_UInt glyph_index; + FT_UInt glyph_index; glyph_index = FT_Get_Char_Index(face, buf); if (FT_HAS_KERNING(face)) { diff --git a/src/draw.h b/src/draw.h index 85f92fe..a407833 100644 --- a/src/draw.h +++ b/src/draw.h @@ -1,8 +1,9 @@ #ifndef DRAW_H #define DRAW_H + #include //#include -#include "lib_easy.h" +#include "wiiu.h" #include "tga_reader.h" #include #include FT_FREETYPE_H @@ -22,7 +23,8 @@ typedef union _RGBAColor { #endif //Function declarations for my graphics library -void initDraw(char* buf, int size0, int size1); +void drawInit(); +void drawFini(); void flipBuffers(); void clearBuffers(); void fillScreen(u8 r, u8 g, u8 b, u8 a); @@ -47,7 +49,7 @@ void freeFont(); bool ttfFontSize(u8 w, u8 h); void ttfFontColor32(u32 color); void ttfFontColor(u8 r, u8 g, u8 b, u8 a); -int ttfPrintString(int x, int y, char *string, bool wWrap, bool ceroX); -int ttfStringWidth(char *string, s8 part); +int ttfPrintString(int x, int y, const char *string, bool wWrap, bool ceroX); +int ttfStringWidth(const char *string, s8 part); #endif /* DRAW_H */ diff --git a/src/dynamic_libs/acp_functions.c b/src/dynamic_libs/acp_functions.c deleted file mode 100644 index beed06a..0000000 --- a/src/dynamic_libs/acp_functions.c +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "acp_functions.h" - -u32 acp_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, GetMetaXml, void * _ACPMetaXml); - -void InitAcquireACP(void) -{ - OSDynLoad_Acquire("nn_acp.rpl", &acp_handle); -} - -void InitACPFunctionPointers(void) -{ - InitAcquireACP(); - OSDynLoad_FindExport(acp_handle,0,"GetMetaXml__Q2_2nn3acpFP11_ACPMetaXml",&GetMetaXml); -} diff --git a/src/dynamic_libs/acp_functions.h b/src/dynamic_libs/acp_functions.h deleted file mode 100644 index 328b9c3..0000000 --- a/src/dynamic_libs/acp_functions.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __ACP_FUNCTIONS_H_ -#define __ACP_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern u32 acp_handle; - -void InitACPFunctionPointers(void); -void InitAcquireACP(void); - -#ifdef __cplusplus -} -#endif - -#endif // __VPAD_FUNCTIONS_H_ diff --git a/src/dynamic_libs/aoc_functions.c b/src/dynamic_libs/aoc_functions.c deleted file mode 100644 index e1adc7a..0000000 --- a/src/dynamic_libs/aoc_functions.c +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "aoc_functions.h" - -u32 aoc_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(s32, AOC_Initialize, void); -EXPORT_DECL(s32, AOC_Finalize, void); -EXPORT_DECL(u32, AOC_CalculateWorkBufferSize, u32 num_titles); -EXPORT_DECL(s32, AOC_ListTitle, u32 * num_titles, void * titles, u32 max_titles, void * buffer, u32 buffer_size); -EXPORT_DECL(s32, AOC_OpenTitle, char* aoc_path, void * title, void * buffer, u32 buffer_size); -EXPORT_DECL(s32, AOC_CloseTitle, void * title); -EXPORT_DECL(s32, AOC_DeleteContent, u64 title_id, u16 contentIndexes[], u32 numberOfContent, void* buffer, u32 buffer_size); -EXPORT_DECL(s32, AOC_GetPurchaseInfo, u32 * bResult, u64 title_id, u16 contentIndexes[], u32 numberOfContent, void * buffer, u32 buffer_size); - -void InitAcquireAoc(void) -{ - OSDynLoad_Acquire("nn_aoc.rpl", &aoc_handle); -} - -void InitAocFunctionPointers(void) -{ - InitAcquireAoc(); - if(aoc_handle == 0) - return; - - //! assigning those is not mandatory and it does not always work to load them - OSDynLoad_FindExport(aoc_handle, 0, "AOC_Initialize", &AOC_Initialize); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_Finalize", &AOC_Finalize); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_CalculateWorkBufferSize", &AOC_CalculateWorkBufferSize); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_ListTitle", &AOC_ListTitle); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_OpenTitle", &AOC_OpenTitle); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_CloseTitle", &AOC_CloseTitle); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_DeleteContent", &AOC_DeleteContent); - OSDynLoad_FindExport(aoc_handle, 0, "AOC_GetPurchaseInfo", &AOC_GetPurchaseInfo); -} diff --git a/src/dynamic_libs/aoc_functions.h b/src/dynamic_libs/aoc_functions.h deleted file mode 100644 index f2e8205..0000000 --- a/src/dynamic_libs/aoc_functions.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __AOC_FUNCTIONS_H_ -#define __AOC_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern u32 aoc_handle; - -#define AOC_TITLE_SIZE 104 - -typedef struct { - u64 title_ID; - u32 group_ID; - u16 version; - char path[88]; -} AOC_TitleListType; - - -void InitAocFunctionPointers(void); -void InitAcquireAoc(void); - -extern s32 (* AOC_Initialize)(void); -extern s32 (* AOC_Finalize)(void); -extern u32 (* AOC_CalculateWorkBufferSize)(u32 num_titles); -extern s32 (* AOC_ListTitle)(u32 * num_titles, void * titles, u32 max_titles, void * buffer, u32 buffer_size); -extern s32 (* AOC_OpenTitle)(char* aoc_path, void * title, void * buffer, u32 buffer_size); -extern s32 (* AOC_CloseTitle)(void * title); -extern s32 (* AOC_DeleteContent)(u64 title_id, u16 contentIndexes[], u32 numberOfContent, void * buffer, u32 buffer_size); -extern s32 (* AOC_GetPurchaseInfo)(u32 * bResult, u64 title_id, u16 contentIndexes[], u32 numberOfContent, void * buffer, u32 buffer_size); -#ifdef __cplusplus -} -#endif - -#endif // __AOC_FUNCTIONS_H_ diff --git a/src/dynamic_libs/ax_functions.c b/src/dynamic_libs/ax_functions.c deleted file mode 100644 index dc49494..0000000 --- a/src/dynamic_libs/ax_functions.c +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 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" - -u32 sound_handle __attribute__((section(".data"))) = 0; - -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); -EXPORT_DECL(s32, AXVoiceBegin, void *v); -EXPORT_DECL(s32, AXVoiceEnd, void *v); -EXPORT_DECL(void, AXSetVoiceType, void *v, u16 type); -EXPORT_DECL(void, AXSetVoiceOffsets, void *v, const void *buf); -EXPORT_DECL(void, AXSetVoiceSrcType, void *v, u32 type); -EXPORT_DECL(void, AXSetVoiceVe, void *v, const void *vol); -EXPORT_DECL(s32, AXSetVoiceDeviceMix, void *v, s32 device, u32 id, void *mix); -EXPORT_DECL(void, AXSetVoiceState, void *v, u16 state); -EXPORT_DECL(void, AXSetVoiceSrc, void *v, const void *src); -EXPORT_DECL(s32, AXSetVoiceSrcRatio, void *v,f32 ratio) -EXPORT_DECL(void *, AXAcquireVoice, u32 prio, void * callback, u32 arg); -EXPORT_DECL(void, AXFreeVoice, void *v); -EXPORT_DECL(void, AXRegisterFrameCallback, void * callback); -EXPORT_DECL(u32, AXGetVoiceLoopCount, void *v); -EXPORT_DECL(void, AXSetVoiceEndOffset, void *v, u32 offset); -EXPORT_DECL(void, AXSetVoiceLoopOffset, void *v, u32 offset); - -void InitAcquireAX(void) -{ - u32 *funcPointer = 0; - - 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); - } -} - -void InitAXFunctionPointers(void) -{ - u32 *funcPointer = 0; - - InitAcquireAX(); - - OS_FIND_EXPORT(sound_handle, AXQuit); - OS_FIND_EXPORT(sound_handle, AXVoiceBegin); - OS_FIND_EXPORT(sound_handle, AXVoiceEnd); - OS_FIND_EXPORT(sound_handle, AXSetVoiceType); - OS_FIND_EXPORT(sound_handle, AXSetVoiceOffsets); - OS_FIND_EXPORT(sound_handle, AXSetVoiceSrcType); - OS_FIND_EXPORT(sound_handle, AXSetVoiceVe); - OS_FIND_EXPORT(sound_handle, AXSetVoiceDeviceMix); - OS_FIND_EXPORT(sound_handle, AXSetVoiceState); - OS_FIND_EXPORT(sound_handle, AXSetVoiceSrc); - OS_FIND_EXPORT(sound_handle, AXSetVoiceSrcRatio); - OS_FIND_EXPORT(sound_handle, AXAcquireVoice); - OS_FIND_EXPORT(sound_handle, AXFreeVoice); - OS_FIND_EXPORT(sound_handle, AXRegisterFrameCallback); - OS_FIND_EXPORT(sound_handle, AXGetVoiceLoopCount); - OS_FIND_EXPORT(sound_handle, AXSetVoiceEndOffset); - OS_FIND_EXPORT(sound_handle, AXSetVoiceLoopOffset); -} - -void ProperlyEndTransitionAudio(void) -{ - bool (* check_os_audio_transition_flag_old)(void); - void (* AXInit_old)(void); - void (* AXQuit_old)(void); - - u32 *funcPointer = 0; - u32 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(); - } -} diff --git a/src/dynamic_libs/ax_functions.h b/src/dynamic_libs/ax_functions.h deleted file mode 100644 index 206d34f..0000000 --- a/src/dynamic_libs/ax_functions.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __AX_FUNCTIONS_H_ -#define __AX_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern u32 sound_handle; - -void InitAXFunctionPointers(void); -void InitAcquireAX(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); -extern s32 (* AXVoiceEnd)(void *v); -extern void (* AXSetVoiceType)(void *v, u16 type); -extern void (* AXSetVoiceOffsets)(void *v, const void *buf); -extern void (* AXSetVoiceSrcType)(void *v, u32 type); -extern void (* AXSetVoiceVe)(void *v, const void *vol); -extern s32 (* AXSetVoiceDeviceMix)(void *v, s32 device, u32 id, void *mix); -extern void (* AXSetVoiceState)(void *v, u16 state); -extern void (* AXSetVoiceSrc)(void *v, const void *src); -extern s32 (* AXSetVoiceSrcRatio)(void *v, f32 ratio); -extern void * (* AXAcquireVoice)(u32 prio, void * callback, u32 arg); -extern void (* AXFreeVoice)(void *v); -extern void (* AXRegisterFrameCallback)(void * callback); -extern u32 (* AXGetVoiceLoopCount)(void * v); -extern void (* AXSetVoiceEndOffset)(void * v, u32 offset); -extern void (* AXSetVoiceLoopOffset)(void * v, u32 offset); - -#ifdef __cplusplus -} -#endif - -#endif // __VPAD_FUNCTIONS_H_ diff --git a/src/dynamic_libs/curl_functions.c b/src/dynamic_libs/curl_functions.c deleted file mode 100644 index 459524d..0000000 --- a/src/dynamic_libs/curl_functions.c +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "curl_functions.h" - -u32 libcurl_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(CURLcode, n_curl_global_init, long flags); -EXPORT_DECL(CURL *, n_curl_easy_init, void); -EXPORT_DECL(CURLcode, n_curl_easy_setopt, CURL *curl, CURLoption option, ...); -EXPORT_DECL(CURLcode, n_curl_easy_perform, CURL *curl); -EXPORT_DECL(void, n_curl_easy_cleanup, CURL *curl); -EXPORT_DECL(CURLcode, n_curl_easy_getinfo, CURL *curl, CURLINFO info, ...); - -void InitAcquireCurl(void) -{ - OSDynLoad_Acquire("nlibcurl", &libcurl_handle); -} - -void InitCurlFunctionPointers(void) -{ - InitAcquireCurl(); - u32 *funcPointer = 0; - - OS_FIND_EXPORT_EX(libcurl_handle, curl_global_init, n_curl_global_init); - OS_FIND_EXPORT_EX(libcurl_handle, curl_easy_init, n_curl_easy_init); - OS_FIND_EXPORT_EX(libcurl_handle, curl_easy_setopt, n_curl_easy_setopt); - OS_FIND_EXPORT_EX(libcurl_handle, curl_easy_perform, n_curl_easy_perform); - OS_FIND_EXPORT_EX(libcurl_handle, curl_easy_cleanup, n_curl_easy_cleanup); - OS_FIND_EXPORT_EX(libcurl_handle, curl_easy_getinfo, n_curl_easy_getinfo); - - n_curl_global_init(CURL_GLOBAL_ALL); -} diff --git a/src/dynamic_libs/curl_functions.h b/src/dynamic_libs/curl_functions.h deleted file mode 100644 index e40740b..0000000 --- a/src/dynamic_libs/curl_functions.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __CURL_FUNCTIONS_H_ -#define __CURL_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "socket_functions.h" -typedef int socklen_t; -#include -#include - -void InitCurlFunctionPointers(void); -void InitAcquireCurl(void); - -extern CURLcode (* n_curl_global_init)(long flags); -extern CURL * (* n_curl_easy_init)(void); -extern CURLcode (* n_curl_easy_setopt)(CURL *curl, CURLoption option, ...); -extern CURLcode (* n_curl_easy_perform)(CURL *curl); -extern void (* n_curl_easy_cleanup)(CURL *curl); -extern CURLcode (* n_curl_easy_getinfo)(CURL *curl, CURLINFO info, ...); - -#ifdef __cplusplus -} -#endif - -#endif // __CURL_FUNCTIONS_H_ diff --git a/src/dynamic_libs/fs_defs.h b/src/dynamic_libs/fs_defs.h deleted file mode 100644 index bb98595..0000000 --- a/src/dynamic_libs/fs_defs.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef FS_DEFS_H -#define FS_DEFS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* FS defines and types */ -#define FS_MAX_LOCALPATH_SIZE 511 -#define FS_MAX_MOUNTPATH_SIZE 128 -#define FS_MAX_FULLPATH_SIZE (FS_MAX_LOCALPATH_SIZE + FS_MAX_MOUNTPATH_SIZE) -#define FS_MAX_ARGPATH_SIZE FS_MAX_FULLPATH_SIZE - -#define FS_STATUS_OK 0 -#define FS_RET_UNSUPPORTED_CMD 0x0400 -#define FS_RET_NO_ERROR 0x0000 -#define FS_RET_ALL_ERROR (u32)(-1) - -#define FS_STAT_FLAG_IS_DIRECTORY 0x80000000 - -/* max length of file/dir name */ -#define FS_MAX_ENTNAME_SIZE 256 - -#define FS_SOURCETYPE_EXTERNAL 0 -#define FS_SOURCETYPE_HFIO 1 - -#define FS_MOUNT_SOURCE_SIZE 0x300 -#define FS_CLIENT_SIZE 0x1700 -#define FS_CMD_BLOCK_SIZE 0xA80 - -#define FSA_STATUS_OK 0 -#define FSA_STATUS_END_OF_DIRECTORY -4 -#define FSA_STATUS_END_OF_FILE -5 -#define FSA_STATUS_ALREADY_EXISTS -22 -#define FSA_STATUS_NOT_FOUND -23 -#define FSA_STATUS_NOT_EMPTY -24 - -typedef struct -{ - uint32_t flag; - uint32_t permission; - uint32_t owner_id; - uint32_t group_id; - uint32_t size; - uint32_t alloc_size; - uint64_t quota_size; - uint32_t ent_id; - uint64_t ctime; - uint64_t mtime; - uint8_t attributes[48]; -} __attribute__((packed)) FSStat; - -typedef struct -{ - FSStat stat; - char name[FS_MAX_ENTNAME_SIZE]; -} FSDirEntry; - -typedef void (*FSAsyncCallback)(void *pClient, void *pCmd, int result, void *context); -typedef struct -{ - FSAsyncCallback userCallback; - void *userContext; - void *ioMsgQueue; -} FSAsyncParams; - - -#ifdef __cplusplus -} -#endif - -#endif /* FS_DEFS_H */ diff --git a/src/dynamic_libs/fs_functions.c b/src/dynamic_libs/fs_functions.c deleted file mode 100644 index 1da25f3..0000000 --- a/src/dynamic_libs/fs_functions.c +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "fs_functions.h" -#include "os_functions.h" - -EXPORT_DECL(s32, FSInit, void); -EXPORT_DECL(s32, FSShutdown, void); -EXPORT_DECL(s32, FSAddClient, void *pClient, s32 errHandling); -EXPORT_DECL(s32, FSAddClientEx, void *pClient, s32 unk_zero_param, s32 errHandling); -EXPORT_DECL(s32, FSDelClient, void *pClient); -EXPORT_DECL(void, FSInitCmdBlock, void *pCmd); -EXPORT_DECL(void *, FSGetCurrentCmdBlock, void *pClient); -EXPORT_DECL(s32, FSGetMountSource, void *pClient, void *pCmd, s32 type, void *source, s32 errHandling); - -EXPORT_DECL(s32, FSMount, void *pClient, void *pCmd, void *source, char *target, u32 bytes, s32 errHandling); -EXPORT_DECL(s32, FSUnmount, void *pClient, void *pCmd, const char *target, s32 errHandling); - -EXPORT_DECL(s32, FSGetStat, void *pClient, void *pCmd, const char *path, FSStat *stats, s32 errHandling); -EXPORT_DECL(s32, FSGetStatAsync, void *pClient, void *pCmd, const char *path, void *stats, s32 error, void *asyncParams); -EXPORT_DECL(s32, FSRename, void *pClient, void *pCmd, const char *oldPath, const char *newPath, s32 error); -EXPORT_DECL(s32, FSRenameAsync, void *pClient, void *pCmd, const char *oldPath, const char *newPath, s32 error, void *asyncParams); -EXPORT_DECL(s32, FSRemove, void *pClient, void *pCmd, const char *path, s32 error); -EXPORT_DECL(s32, FSRemoveAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); -EXPORT_DECL(s32, FSFlushQuota, void *pClient, void *pCmd, const char* path, s32 error); -EXPORT_DECL(s32, FSFlushQuotaAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); -EXPORT_DECL(s32, FSGetFreeSpaceSize, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error); -EXPORT_DECL(s32, FSGetFreeSpaceSizeAsync, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error, void *asyncParams); -EXPORT_DECL(s32, FSRollbackQuota, void *pClient, void *pCmd, const char *path, s32 error); -EXPORT_DECL(s32, FSRollbackQuotaAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); - -EXPORT_DECL(s32, FSOpenDir, void *pClient, void *pCmd, const char *path, s32 *dh, s32 errHandling); -EXPORT_DECL(s32, FSOpenDirAsync, void *pClient, void* pCmd, const char *path, s32 *handle, s32 error, void *asyncParams); -EXPORT_DECL(s32, FSReadDir, void *pClient, void *pCmd, s32 dh, FSDirEntry *dir_entry, s32 errHandling); -EXPORT_DECL(s32, FSRewindDir, void *pClient, void *pCmd, s32 dh, s32 errHandling); -EXPORT_DECL(s32, FSCloseDir, void *pClient, void *pCmd, s32 dh, s32 errHandling); -EXPORT_DECL(s32, FSChangeDir, void *pClient, void *pCmd, const char *path, s32 errHandling); -EXPORT_DECL(s32, FSChangeDirAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); -EXPORT_DECL(s32, FSMakeDir, void *pClient, void *pCmd, const char *path, s32 errHandling); -EXPORT_DECL(s32, FSMakeDirAsync, void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); - -EXPORT_DECL(s32, FSOpenFile, void *pClient, void *pCmd, const char *path, const char *mode, s32 *fd, s32 errHandling); -EXPORT_DECL(s32, FSOpenFileAsync, void *pClient, void *pCmd, const char *path, const char *mode, s32 *handle, s32 error, const void *asyncParams); -EXPORT_DECL(s32, FSReadFile, void *pClient, void *pCmd, void *buffer, s32 size, s32 count, s32 fd, s32 flag, s32 errHandling); -EXPORT_DECL(s32, FSCloseFile, void *pClient, void *pCmd, s32 fd, s32 errHandling); - -EXPORT_DECL(s32, FSFlushFile, void *pClient, void *pCmd, s32 fd, s32 error); -EXPORT_DECL(s32, FSTruncateFile, void *pClient, void *pCmd, s32 fd, s32 error); -EXPORT_DECL(s32, FSGetStatFile, void *pClient, void *pCmd, s32 fd, void *buffer, s32 error); -EXPORT_DECL(s32, FSSetPosFile, void *pClient, void *pCmd, s32 fd, s32 pos, s32 error); -EXPORT_DECL(s32, FSWriteFile, void *pClient, void *pCmd, const void *source, s32 block_size, s32 block_count, s32 fd, s32 flag, s32 error); - -EXPORT_DECL(s32, FSBindMount, void *pClient, void *pCmd, char *source, char *target, s32 error); -EXPORT_DECL(s32, FSBindUnmount, void *pClient, void *pCmd, char *target, s32 error); - -EXPORT_DECL(s32, FSMakeQuota, void *pClient, void *pCmd, const char *path,u32 mode, u64 size, s32 errHandling); -EXPORT_DECL(s32, FSMakeQuotaAsync ,void *pClient, void *pCmd, const char *path,u32 mode, u64 size, s32 errHandling,const void *asyncParams); - -void InitFSFunctionPointers(void) -{ - u32 *funcPointer = 0; - - OS_FIND_EXPORT(coreinit_handle, FSInit); - OS_FIND_EXPORT(coreinit_handle, FSShutdown); - OS_FIND_EXPORT(coreinit_handle, FSAddClient); - OS_FIND_EXPORT(coreinit_handle, FSAddClientEx); - OS_FIND_EXPORT(coreinit_handle, FSDelClient); - OS_FIND_EXPORT(coreinit_handle, FSInitCmdBlock); - OS_FIND_EXPORT(coreinit_handle, FSGetCurrentCmdBlock); - OS_FIND_EXPORT(coreinit_handle, FSGetMountSource); - - OS_FIND_EXPORT(coreinit_handle, FSMount); - OS_FIND_EXPORT(coreinit_handle, FSUnmount); - - OS_FIND_EXPORT(coreinit_handle, FSGetStat); - OS_FIND_EXPORT(coreinit_handle, FSGetStatAsync); - OS_FIND_EXPORT(coreinit_handle, FSRename); - OS_FIND_EXPORT(coreinit_handle, FSRenameAsync); - OS_FIND_EXPORT(coreinit_handle, FSRemove); - OS_FIND_EXPORT(coreinit_handle, FSRemoveAsync); - OS_FIND_EXPORT(coreinit_handle, FSFlushQuota); - OS_FIND_EXPORT(coreinit_handle, FSFlushQuotaAsync); - OS_FIND_EXPORT(coreinit_handle, FSGetFreeSpaceSize); - OS_FIND_EXPORT(coreinit_handle, FSGetFreeSpaceSizeAsync); - OS_FIND_EXPORT(coreinit_handle, FSRollbackQuota); - OS_FIND_EXPORT(coreinit_handle, FSRollbackQuotaAsync); - - OS_FIND_EXPORT(coreinit_handle, FSOpenDir); - OS_FIND_EXPORT(coreinit_handle, FSOpenDirAsync); - OS_FIND_EXPORT(coreinit_handle, FSReadDir); - OS_FIND_EXPORT(coreinit_handle, FSRewindDir); - OS_FIND_EXPORT(coreinit_handle, FSCloseDir); - OS_FIND_EXPORT(coreinit_handle, FSChangeDir); - OS_FIND_EXPORT(coreinit_handle, FSChangeDirAsync); - OS_FIND_EXPORT(coreinit_handle, FSMakeDir); - OS_FIND_EXPORT(coreinit_handle, FSMakeDirAsync); - - - OS_FIND_EXPORT(coreinit_handle, FSOpenFile); - OS_FIND_EXPORT(coreinit_handle, FSOpenFileAsync); - OS_FIND_EXPORT(coreinit_handle, FSReadFile); - OS_FIND_EXPORT(coreinit_handle, FSCloseFile); - - OS_FIND_EXPORT(coreinit_handle, FSFlushFile); - OS_FIND_EXPORT(coreinit_handle, FSTruncateFile); - OS_FIND_EXPORT(coreinit_handle, FSGetStatFile); - OS_FIND_EXPORT(coreinit_handle, FSSetPosFile); - OS_FIND_EXPORT(coreinit_handle, FSWriteFile); - - OS_FIND_EXPORT(coreinit_handle, FSBindMount); - OS_FIND_EXPORT(coreinit_handle, FSBindUnmount); - - OS_FIND_EXPORT(coreinit_handle, FSMakeQuota); - OS_FIND_EXPORT(coreinit_handle, FSMakeQuotaAsync); -} diff --git a/src/dynamic_libs/fs_functions.h b/src/dynamic_libs/fs_functions.h deleted file mode 100644 index 24e7403..0000000 --- a/src/dynamic_libs/fs_functions.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __FS_FUNCTIONS_H_ -#define __FS_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "fs_defs.h" - -void InitFSFunctionPointers(void); - -extern s32 (* FSInit)(void); -extern s32 (* FSShutdown)(void); -extern s32 (* FSAddClient)(void *pClient, s32 errHandling); -extern s32 (* FSAddClientEx)(void *pClient, s32 unk_zero_param, s32 errHandling); -extern s32 (* FSDelClient)(void *pClient); -extern void (* FSInitCmdBlock)(void *pCmd); -extern void *(* FSGetCurrentCmdBlock)(void *pClient); -extern s32 (* FSGetMountSource)(void *pClient, void *pCmd, s32 type, void *source, s32 errHandling); - -extern s32 (* FSMount)(void *pClient, void *pCmd, void *source, char *target, u32 bytes, s32 errHandling); -extern s32 (* FSUnmount)(void *pClient, void *pCmd, const char *target, s32 errHandling); -extern s32 (* FSRename)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, s32 error); -extern s32 (* FSRenameAsync)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, s32 error, void *asyncParams); -extern s32 (* FSRemove)(void *pClient, void *pCmd, const char *path, s32 error); -extern s32 (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); - -extern s32 (* FSGetStat)(void *pClient, void *pCmd, const char *path, FSStat *stats, s32 errHandling); -extern s32 (* FSGetStatAsync)(void *pClient, void *pCmd, const char *path, void *stats, s32 error, void *asyncParams); -extern s32 (* FSRename)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, s32 error); -extern s32 (* FSRenameAsync)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, s32 error, void *asyncParams); -extern s32 (* FSRemove)(void *pClient, void *pCmd, const char *path, s32 error); -extern s32 (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); -extern s32 (* FSFlushQuota)(void *pClient, void *pCmd, const char* path, s32 error); -extern s32 (* FSFlushQuotaAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); -extern s32 (* FSGetFreeSpaceSize)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error); -extern s32 (* FSGetFreeSpaceSizeAsync)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, s32 error, void *asyncParams); -extern s32 (* FSRollbackQuota)(void *pClient, void *pCmd, const char *path, s32 error); -extern s32 (* FSRollbackQuotaAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); - -extern s32 (* FSOpenDir)(void *pClient, void *pCmd, const char *path, s32 *dh, s32 errHandling); -extern s32 (* FSOpenDirAsync)(void *pClient, void* pCmd, const char *path, s32 *handle, s32 error, void *asyncParams); -extern s32 (* FSReadDir)(void *pClient, void *pCmd, s32 dh, FSDirEntry *dir_entry, s32 errHandling); -extern s32 (* FSRewindDir)(void *pClient, void *pCmd, s32 dh, s32 errHandling); -extern s32 (* FSCloseDir)(void *pClient, void *pCmd, s32 dh, s32 errHandling); -extern s32 (* FSChangeDir)(void *pClient, void *pCmd, const char *path, s32 errHandling); -extern s32 (* FSChangeDirAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); -extern s32 (* FSMakeDir)(void *pClient, void *pCmd, const char *path, s32 errHandling); -extern s32 (* FSMakeDirAsync)(void *pClient, void *pCmd, const char *path, s32 error, void *asyncParams); - -extern s32 (* FSOpenFile)(void *pClient, void *pCmd, const char *path, const char *mode, s32 *fd, s32 errHandling); -extern s32 (* FSOpenFileAsync)(void *pClient, void *pCmd, const char *path, const char *mode, s32 *handle, s32 error, const void *asyncParams); -extern s32 (* FSReadFile)(void *pClient, void *pCmd, void *buffer, s32 size, s32 count, s32 fd, s32 flag, s32 errHandling); -extern s32 (* FSCloseFile)(void *pClient, void *pCmd, s32 fd, s32 errHandling); - -extern s32 (* FSFlushFile)(void *pClient, void *pCmd, s32 fd, s32 error); -extern s32 (* FSTruncateFile)(void *pClient, void *pCmd, s32 fd, s32 error); -extern s32 (* FSGetStatFile)(void *pClient, void *pCmd, s32 fd, void *buffer, s32 error); -extern s32 (* FSSetPosFile)(void *pClient, void *pCmd, s32 fd, s32 pos, s32 error); -extern s32 (* FSWriteFile)(void *pClient, void *pCmd, const void *source, s32 block_size, s32 block_count, s32 fd, s32 flag, s32 error); - -extern s32 (* FSBindMount)(void *pClient, void *pCmd, char *source, char *target, s32 error); -extern s32 (* FSBindUnmount)(void *pClient, void *pCmd, char *target, s32 error); - -extern s32 (* FSMakeQuota)( void *pClient, void *pCmd, const char *path,u32 mode, u64 size, s32 errHandling); -extern s32 (* FSMakeQuotaAsync)(void *pClient, void *pCmd, const char *path,u32 mode, u64 size, s32 errHandling,const void *asyncParams); - - -#ifdef __cplusplus -} -#endif - -#endif // __FS_FUNCTIONS_H_ diff --git a/src/dynamic_libs/gx2_functions.c b/src/dynamic_libs/gx2_functions.c deleted file mode 100644 index 501c4d7..0000000 --- a/src/dynamic_libs/gx2_functions.c +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "gx2_types.h" - -u32 gx2_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, GX2Init, u32 * init_attribs); -EXPORT_DECL(void, GX2Shutdown, void); -EXPORT_DECL(void, GX2Flush, void); -EXPORT_DECL(s32, GX2GetMainCoreId, void) ; -EXPORT_DECL(s32, GX2DrawDone, void); -EXPORT_DECL(void, GX2ClearColor, GX2ColorBuffer *colorBuffer, f32 r, f32 g, f32 b, f32 a); -EXPORT_DECL(void, GX2SetViewport, f32 x, f32 y, f32 w, f32 h, f32 nearZ, f32 farZ); -EXPORT_DECL(void, GX2SetScissor, u32 x_orig, u32 y_orig, u32 wd, u32 ht); -EXPORT_DECL(void, GX2SetContextState, const GX2ContextState* state); -EXPORT_DECL(void, GX2DrawEx, s32 primitive_type, u32 count, u32 first_vertex, u32 instances_count); -EXPORT_DECL(void, GX2DrawIndexedEx, s32 primitive_type, u32 count, s32 index_format, const void* idx, u32 first_vertex, u32 instances_count); -EXPORT_DECL(void, GX2ClearDepthStencilEx, GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value, s32 clear_mode); -EXPORT_DECL(void, GX2SetClearDepthStencil, GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value); -EXPORT_DECL(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, s32 scan_target); -EXPORT_DECL(void, GX2SwapScanBuffers, void); -EXPORT_DECL(void, GX2SetTVEnable, s32 enable); -EXPORT_DECL(void, GX2SetSwapInterval, u32 swap_interval); -EXPORT_DECL(u32, GX2GetSwapInterval, void); -EXPORT_DECL(void, GX2WaitForVsync, void); -EXPORT_DECL(void, GX2CalcTVSize, s32 tv_render_mode, s32 format, s32 buffering_mode, u32 * size, s32 * scale_needed); -EXPORT_DECL(void, GX2Invalidate, s32 invalidate_type, void * ptr, u32 buffer_size); -EXPORT_DECL(void, GX2SetTVBuffer, void *buffer, u32 buffer_size, s32 tv_render_mode, s32 format, s32 buffering_mode); -EXPORT_DECL(void, GX2CalcSurfaceSizeAndAlignment, GX2Surface *surface); -EXPORT_DECL(void, GX2InitDepthBufferRegs, GX2DepthBuffer *depthBuffer); -EXPORT_DECL(void, GX2InitColorBufferRegs, GX2ColorBuffer *colorBuffer); -EXPORT_DECL(void, GX2CalcColorBufferAuxInfo, GX2ColorBuffer *colorBuffer, u32 *size, u32 *align); -EXPORT_DECL(void, GX2CalcDepthBufferHiZInfo, GX2DepthBuffer *depthBuffer, u32 *size, u32 *align); -EXPORT_DECL(void, GX2InitDepthBufferHiZEnable, GX2DepthBuffer *depthBuffer, s32 hiZ_enable); -EXPORT_DECL(void, GX2SetupContextStateEx, GX2ContextState* state, s32 enable_profiling); -EXPORT_DECL(void, GX2SetColorBuffer, const GX2ColorBuffer *colorBuffer, s32 target); -EXPORT_DECL(void, GX2SetDepthBuffer, const GX2DepthBuffer *depthBuffer); -EXPORT_DECL(void, GX2SetAttribBuffer, u32 attr_index, u32 attr_size, u32 stride, const void* attr); -EXPORT_DECL(void, GX2InitTextureRegs, GX2Texture *texture); -EXPORT_DECL(void, GX2InitSampler, GX2Sampler *sampler, s32 tex_clamp, s32 min_mag_filter); -EXPORT_DECL(u32, GX2CalcFetchShaderSizeEx, u32 num_attrib, s32 fetch_shader_type, s32 tessellation_mode); -EXPORT_DECL(void, GX2InitFetchShaderEx, GX2FetchShader* fs, void* fs_buffer, u32 count, const GX2AttribStream* attribs, s32 fetch_shader_type, s32 tessellation_mode); -EXPORT_DECL(void, GX2SetFetchShader, const GX2FetchShader* fs); -EXPORT_DECL(void, GX2SetVertexUniformReg, u32 offset, u32 count, const void *values); -EXPORT_DECL(void, GX2SetPixelUniformReg, u32 offset, u32 count, const void *values); -EXPORT_DECL(void, GX2SetPixelTexture, const GX2Texture *texture, u32 texture_hw_location); -EXPORT_DECL(void, GX2SetVertexTexture, const GX2Texture *texture, u32 texture_hw_location); -EXPORT_DECL(void, GX2SetPixelSampler, const GX2Sampler *sampler, u32 sampler_hw_location); -EXPORT_DECL(void, GX2SetVertexSampler, const GX2Sampler *sampler, u32 sampler_hw_location); -EXPORT_DECL(void, GX2SetPixelShader, const GX2PixelShader* pixelShader); -EXPORT_DECL(void, GX2SetVertexShader, const GX2VertexShader* vertexShader); -EXPORT_DECL(void, GX2InitSamplerZMFilter, GX2Sampler *sampler, s32 z_filter, s32 mip_filter); -EXPORT_DECL(void, GX2SetColorControl, s32 lop, u8 blend_enable_mask, s32 enable_multi_write, s32 enable_color_buffer); -EXPORT_DECL(void, GX2SetDepthOnlyControl, s32 enable_depth, s32 enable_depth_write, s32 depth_comp_function); -EXPORT_DECL(void, GX2SetBlendControl, s32 target, s32 color_src_blend, s32 color_dst_blend, s32 color_combine, s32 separate_alpha_blend, s32 alpha_src_blend, s32 alpha_dst_blend, s32 alpha_combine); -EXPORT_DECL(void, GX2CalcDRCSize, s32 drc_mode, s32 format, s32 buffering_mode, u32 *size, s32 *scale_needed); -EXPORT_DECL(void, GX2SetDRCBuffer, void *buffer, u32 buffer_size, s32 drc_mode, s32 surface_format, s32 buffering_mode); -EXPORT_DECL(void, GX2SetDRCScale, u32 width, u32 height); -EXPORT_DECL(void, GX2SetDRCEnable, s32 enable); -EXPORT_DECL(void, GX2SetPolygonControl, s32 front_face_mode, s32 cull_front, s32 cull_back, s32 enable_mode, s32 mode_font, s32 mode_back, s32 poly_offset_front, s32 poly_offset_back, s32 point_line_offset); -EXPORT_DECL(void, GX2SetCullOnlyControl, s32 front_face_mode, s32 cull_front, s32 cull_back); -EXPORT_DECL(void, GX2SetDepthStencilControl, s32 enable_depth_test, s32 enable_depth_write, s32 depth_comp_function, s32 stencil_test_enable, s32 back_stencil_enable, - s32 font_stencil_func, s32 front_stencil_z_pass, s32 front_stencil_z_fail, s32 front_stencil_fail, - s32 back_stencil_func, s32 back_stencil_z_pass, s32 back_stencil_z_fail, s32 back_stencil_fail); -EXPORT_DECL(void, GX2SetStencilMask, u8 mask_front, u8 write_mask_front, u8 ref_front, u8 mask_back, u8 write_mask_back, u8 ref_back); -EXPORT_DECL(void, GX2SetLineWidth, f32 width); -EXPORT_DECL(void, GX2SetTVGamma, f32 val); -EXPORT_DECL(void, GX2SetDRCGamma, f32 gam); -EXPORT_DECL(s32, GX2GetSystemTVScanMode, void); -EXPORT_DECL(s32, GX2GetSystemDRCScanMode, void); -EXPORT_DECL(void, GX2RSetAllocator, void * (* allocFunc)(u32, u32, u32), void (* freeFunc)(u32, void*)); -EXPORT_DECL(void, GX2CopySurface, GX2Surface * srcSurface,u32 srcMip,u32 srcSlice,GX2Surface * dstSurface,u32 dstMip,u32 dstSlice ); - -EXPORT_DECL(void, GX2ClearBuffersEx, GX2ColorBuffer * colorBuffer,GX2DepthBuffer * depthBuffer,f32 r, f32 g, f32 b, f32 a,f32 depthValue,u8 stencilValue,s32 clearFlags); - -void InitAcquireGX2(void) -{ - OSDynLoad_Acquire("gx2.rpl", &gx2_handle); -} - -void InitGX2FunctionPointers(void) -{ - u32 *funcPointer = 0; - InitAcquireGX2(); - - OS_FIND_EXPORT(gx2_handle, GX2Init); - OS_FIND_EXPORT(gx2_handle, GX2Shutdown); - OS_FIND_EXPORT(gx2_handle, GX2Flush); - OS_FIND_EXPORT(gx2_handle, GX2GetMainCoreId); - OS_FIND_EXPORT(gx2_handle, GX2DrawDone); - OS_FIND_EXPORT(gx2_handle, GX2ClearColor); - OS_FIND_EXPORT(gx2_handle, GX2SetViewport); - OS_FIND_EXPORT(gx2_handle, GX2SetScissor); - OS_FIND_EXPORT(gx2_handle, GX2SetContextState); - OS_FIND_EXPORT(gx2_handle, GX2DrawEx); - OS_FIND_EXPORT(gx2_handle, GX2DrawIndexedEx); - OS_FIND_EXPORT(gx2_handle, GX2ClearDepthStencilEx); - OS_FIND_EXPORT(gx2_handle, GX2CopyColorBufferToScanBuffer); - OS_FIND_EXPORT(gx2_handle, GX2SwapScanBuffers); - OS_FIND_EXPORT(gx2_handle, GX2SetTVEnable); - OS_FIND_EXPORT(gx2_handle, GX2SetSwapInterval); - OS_FIND_EXPORT(gx2_handle, GX2GetSwapInterval); - OS_FIND_EXPORT(gx2_handle, GX2WaitForVsync); - OS_FIND_EXPORT(gx2_handle, GX2CalcTVSize); - OS_FIND_EXPORT(gx2_handle, GX2Invalidate); - OS_FIND_EXPORT(gx2_handle, GX2SetTVBuffer); - OS_FIND_EXPORT(gx2_handle, GX2CalcSurfaceSizeAndAlignment); - OS_FIND_EXPORT(gx2_handle, GX2InitDepthBufferRegs); - OS_FIND_EXPORT(gx2_handle, GX2InitColorBufferRegs); - OS_FIND_EXPORT(gx2_handle, GX2CalcColorBufferAuxInfo); - OS_FIND_EXPORT(gx2_handle, GX2CalcDepthBufferHiZInfo); - OS_FIND_EXPORT(gx2_handle, GX2InitDepthBufferHiZEnable); - OS_FIND_EXPORT(gx2_handle, GX2SetupContextStateEx); - OS_FIND_EXPORT(gx2_handle, GX2SetColorBuffer); - OS_FIND_EXPORT(gx2_handle, GX2SetDepthBuffer); - OS_FIND_EXPORT(gx2_handle, GX2SetAttribBuffer); - OS_FIND_EXPORT(gx2_handle, GX2InitTextureRegs); - OS_FIND_EXPORT(gx2_handle, GX2InitSampler); - OS_FIND_EXPORT(gx2_handle, GX2CalcFetchShaderSizeEx); - OS_FIND_EXPORT(gx2_handle, GX2InitFetchShaderEx); - OS_FIND_EXPORT(gx2_handle, GX2SetFetchShader); - OS_FIND_EXPORT(gx2_handle, GX2SetVertexUniformReg); - OS_FIND_EXPORT(gx2_handle, GX2SetPixelUniformReg); - OS_FIND_EXPORT(gx2_handle, GX2SetPixelTexture); - OS_FIND_EXPORT(gx2_handle, GX2SetVertexTexture); - OS_FIND_EXPORT(gx2_handle, GX2SetPixelSampler); - OS_FIND_EXPORT(gx2_handle, GX2SetVertexSampler); - OS_FIND_EXPORT(gx2_handle, GX2SetPixelShader); - OS_FIND_EXPORT(gx2_handle, GX2SetVertexShader); - OS_FIND_EXPORT(gx2_handle, GX2InitSamplerZMFilter); - OS_FIND_EXPORT(gx2_handle, GX2SetColorControl); - OS_FIND_EXPORT(gx2_handle, GX2SetDepthOnlyControl); - OS_FIND_EXPORT(gx2_handle, GX2SetBlendControl); - OS_FIND_EXPORT(gx2_handle, GX2CalcDRCSize); - OS_FIND_EXPORT(gx2_handle, GX2SetDRCBuffer); - OS_FIND_EXPORT(gx2_handle, GX2SetDRCScale); - OS_FIND_EXPORT(gx2_handle, GX2SetDRCEnable); - OS_FIND_EXPORT(gx2_handle, GX2SetPolygonControl); - OS_FIND_EXPORT(gx2_handle, GX2SetCullOnlyControl); - OS_FIND_EXPORT(gx2_handle, GX2SetDepthStencilControl); - OS_FIND_EXPORT(gx2_handle, GX2SetStencilMask); - OS_FIND_EXPORT(gx2_handle, GX2SetLineWidth); - OS_FIND_EXPORT(gx2_handle, GX2SetDRCGamma); - OS_FIND_EXPORT(gx2_handle, GX2SetTVGamma); - OS_FIND_EXPORT(gx2_handle, GX2GetSystemTVScanMode); - OS_FIND_EXPORT(gx2_handle, GX2GetSystemDRCScanMode); - OS_FIND_EXPORT(gx2_handle, GX2RSetAllocator); - OS_FIND_EXPORT(gx2_handle, GX2CopySurface); - OS_FIND_EXPORT(gx2_handle, GX2ClearBuffersEx); - OS_FIND_EXPORT(gx2_handle, GX2SetClearDepthStencil); -} diff --git a/src/dynamic_libs/gx2_functions.h b/src/dynamic_libs/gx2_functions.h deleted file mode 100644 index 9133fcc..0000000 --- a/src/dynamic_libs/gx2_functions.h +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __GX2_FUNCTIONS_H_ -#define __GX2_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "gx2_types.h" - -extern u32 gx2_handle; - -void InitGX2FunctionPointers(void); -void InitAcquireGX2(void); - -extern void (* GX2Init)(u32 * init_attribs); -extern void (* GX2Shutdown)(void); -extern void (* GX2Flush)(void); -extern s32 (* GX2GetMainCoreId)(void) ; -extern s32 (* GX2DrawDone)(void); -extern void (* GX2ClearColor)(GX2ColorBuffer *colorBuffer, f32 r, f32 g, f32 b, f32 a); -extern void (* GX2SetViewport)(f32 x, f32 y, f32 w, f32 h, f32 nearZ, f32 farZ); -extern void (* GX2SetScissor)(u32 x_orig, u32 y_orig, u32 wd, u32 ht); -extern void (* GX2SetContextState)(const GX2ContextState* state); -extern void (* GX2DrawEx)(s32 primitive_type, u32 count, u32 first_vertex, u32 instances_count); -extern void (* GX2DrawIndexedEx)(s32 primitive_type, u32 count, s32 index_format, const void* idx, u32 first_vertex, u32 instances_count); -extern void (* GX2ClearDepthStencilEx)(GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value, s32 clear_mode); -extern void (* GX2SetClearDepthStencil)(GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value); -extern void (* GX2CopyColorBufferToScanBuffer)(const GX2ColorBuffer *colorBuffer, s32 scan_target); -extern void (* GX2SwapScanBuffers)(void); -extern void (* GX2SetTVEnable)(s32 enable); -extern void (* GX2SetSwapInterval)(u32 swap_interval); -extern u32 (* GX2GetSwapInterval)(void); -extern void (* GX2WaitForVsync)(void); -extern void (* GX2CalcTVSize)(s32 tv_render_mode, s32 format, s32 buffering_mode, u32 * size, s32 * scale_needed); -extern void (* GX2Invalidate)(s32 invalidate_type, void * ptr, u32 buffer_size); -extern void (* GX2SetTVBuffer)(void *buffer, u32 buffer_size, s32 tv_render_mode, s32 format, s32 buffering_mode); -extern void (* GX2CalcSurfaceSizeAndAlignment)(GX2Surface *surface); -extern void (* GX2InitDepthBufferRegs)(GX2DepthBuffer *depthBuffer); -extern void (* GX2InitColorBufferRegs)(GX2ColorBuffer *colorBuffer); -extern void (* GX2CalcColorBufferAuxInfo)(GX2ColorBuffer *colorBuffer, u32 *size, u32 *align); -extern void (* GX2CalcDepthBufferHiZInfo)(GX2DepthBuffer *depthBuffer, u32 *size, u32 *align); -extern void (* GX2InitDepthBufferHiZEnable)(GX2DepthBuffer *depthBuffer, s32 hiZ_enable); -extern void (* GX2SetupContextStateEx)(GX2ContextState* state, s32 enable_profiling); -extern void (* GX2SetColorBuffer)(const GX2ColorBuffer *colorBuffer, s32 target); -extern void (* GX2SetDepthBuffer)(const GX2DepthBuffer *depthBuffer); -extern void (* GX2SetAttribBuffer)(u32 attr_index, u32 attr_size, u32 stride, const void* attr); -extern void (* GX2InitTextureRegs)(GX2Texture *texture); -extern void (* GX2InitSampler)(GX2Sampler *sampler, s32 tex_clamp, s32 min_mag_filter); -extern u32 (* GX2CalcFetchShaderSizeEx)(u32 num_attrib, s32 fetch_shader_type, s32 tessellation_mode); -extern void (* GX2InitFetchShaderEx)(GX2FetchShader* fs, void* fs_buffer, u32 count, const GX2AttribStream* attribs, s32 fetch_shader_type, s32 tessellation_mode); -extern void (* GX2SetFetchShader)(const GX2FetchShader* fs); -extern void (* GX2SetVertexUniformReg)(u32 offset, u32 count, const void *values); -extern void (* GX2SetPixelUniformReg)(u32 offset, u32 count, const void *values); -extern void (* GX2SetPixelTexture)(const GX2Texture *texture, u32 texture_hw_location); -extern void (* GX2SetVertexTexture)(const GX2Texture *texture, u32 texture_hw_location); -extern void (* GX2SetPixelSampler)(const GX2Sampler *sampler, u32 sampler_hw_location); -extern void (* GX2SetVertexSampler)(const GX2Sampler *sampler, u32 sampler_hw_location); -extern void (* GX2SetPixelShader)(const GX2PixelShader* pixelShader); -extern void (* GX2SetVertexShader)(const GX2VertexShader* vertexShader); -extern void (* GX2InitSamplerZMFilter)(GX2Sampler *sampler, s32 z_filter, s32 mip_filter); -extern void (* GX2SetColorControl)(s32 lop, u8 blend_enable_mask, s32 enable_multi_write, s32 enable_color_buffer); -extern void (* GX2SetDepthOnlyControl)(s32 enable_depth, s32 enable_depth_write, s32 depth_comp_function); -extern void (* GX2SetBlendControl)(s32 target, s32 color_src_blend, s32 color_dst_blend, s32 color_combine, s32 separate_alpha_blend, s32 alpha_src_blend, s32 alpha_dst_blend, s32 alpha_combine); -extern void (* GX2CalcDRCSize)(s32 drc_mode, s32 format, s32 buffering_mode, u32 *size, s32 *scale_needed); -extern void (* GX2SetDRCBuffer)(void *buffer, u32 buffer_size, s32 drc_mode, s32 surface_format, s32 buffering_mode); -extern void (* GX2SetDRCScale)(u32 width, u32 height); -extern void (* GX2SetDRCEnable)(s32 enable); -extern void (* GX2SetPolygonControl)(s32 front_face_mode, s32 cull_front, s32 cull_back, s32 enable_mode, s32 mode_font, s32 mode_back, s32 poly_offset_front, s32 poly_offset_back, s32 point_line_offset); -extern void (* GX2SetCullOnlyControl)(s32 front_face_mode, s32 cull_front, s32 cull_back); -extern void (* GX2SetDepthStencilControl)(s32 enable_depth_test, s32 enable_depth_write, s32 depth_comp_function, s32 stencil_test_enable, s32 back_stencil_enable, - s32 font_stencil_func, s32 front_stencil_z_pass, s32 front_stencil_z_fail, s32 front_stencil_fail, - s32 back_stencil_func, s32 back_stencil_z_pass, s32 back_stencil_z_fail, s32 back_stencil_fail); -extern void (* GX2SetStencilMask)(u8 mask_front, u8 write_mask_front, u8 ref_front, u8 mask_back, u8 write_mask_back, u8 ref_back); -extern void (* GX2SetLineWidth)(f32 width); -extern void (* GX2SetTVGamma)(f32 val); -extern void (* GX2SetDRCGamma)(f32 val); -extern s32 (* GX2GetSystemTVScanMode)(void); -extern s32 (* GX2GetSystemDRCScanMode)(void); -extern void (* GX2RSetAllocator)(void * (*allocFunc)(u32, u32, u32), void (*freeFunc)(u32, void*)); -extern void (* GX2CopySurface)(GX2Surface * srcSurface,u32 srcMip,u32 srcSlice,GX2Surface * dstSurface,u32 dstMip,u32 dstSlice ); -extern void (* GX2ClearBuffersEx)(GX2ColorBuffer * colorBuffer,GX2DepthBuffer * depthBuffer,f32 r, f32 g, f32 b, f32 a,f32 depthValue,u8 stencilValue,s32 clearFlags); - -static inline void GX2InitDepthBuffer(GX2DepthBuffer *depthBuffer, s32 dimension, u32 width, u32 height, u32 depth, s32 format, s32 aa) -{ - depthBuffer->surface.dimension = dimension; - depthBuffer->surface.width = width; - depthBuffer->surface.height = height; - depthBuffer->surface.depth = depth; - depthBuffer->surface.num_mips = 1; - depthBuffer->surface.format = format; - depthBuffer->surface.aa = aa; - depthBuffer->surface.use = ((format==GX2_SURFACE_FORMAT_D_D24_S8_UNORM) || (format==GX2_SURFACE_FORMAT_D_D24_S8_FLOAT)) ? GX2_SURFACE_USE_DEPTH_BUFFER : GX2_SURFACE_USE_DEPTH_BUFFER_TEXTURE; - depthBuffer->surface.tile = GX2_TILE_MODE_DEFAULT; - depthBuffer->surface.swizzle = 0; - depthBuffer->view_mip = 0; - depthBuffer->view_first_slice = 0; - depthBuffer->view_slices_count = depth; - depthBuffer->clear_depth = 1.0f; - depthBuffer->clear_stencil = 0; - depthBuffer->hiZ_data = NULL; - depthBuffer->hiZ_size = 0; - GX2CalcSurfaceSizeAndAlignment(&depthBuffer->surface); - GX2InitDepthBufferRegs(depthBuffer); -} - -static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, s32 dimension, u32 width, u32 height, u32 depth, s32 format, s32 aa) -{ - colorBuffer->surface.dimension = dimension; - colorBuffer->surface.width = width; - colorBuffer->surface.height = height; - colorBuffer->surface.depth = depth; - colorBuffer->surface.num_mips = 1; - colorBuffer->surface.format = format; - colorBuffer->surface.aa = aa; - colorBuffer->surface.use = GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE_FTV; - colorBuffer->surface.image_size = 0; - colorBuffer->surface.image_data = NULL; - colorBuffer->surface.mip_size = 0; - colorBuffer->surface.mip_data = NULL; - colorBuffer->surface.tile = GX2_TILE_MODE_DEFAULT; - colorBuffer->surface.swizzle = 0; - colorBuffer->surface.align = 0; - colorBuffer->surface.pitch = 0; - u32 i; - for(i = 0; i < 13; i++) - colorBuffer->surface.mip_offset[i] = 0; - colorBuffer->view_mip = 0; - colorBuffer->view_first_slice = 0; - colorBuffer->view_slices_count = depth; - colorBuffer->aux_data = NULL; - colorBuffer->aux_size = 0; - for(i = 0; i < 5; i++) - colorBuffer->regs[i] = 0; - - GX2CalcSurfaceSizeAndAlignment(&colorBuffer->surface); - GX2InitColorBufferRegs(colorBuffer); -} - -static inline void GX2InitAttribStream(GX2AttribStream* attr, u32 location, u32 buffer, u32 offset, s32 format) -{ - attr->location = location; - attr->buffer = buffer; - attr->offset = offset; - attr->format = format; - attr->index_type = 0; - attr->divisor = 0; - attr->destination_selector = attribute_dest_comp_selector[format & 0xff]; - attr->endian_swap = GX2_ENDIANSWAP_DEFAULT; -} - -static inline void GX2InitTexture(GX2Texture *tex, u32 width, u32 height, u32 depth, u32 num_mips, s32 format, s32 dimension, s32 tile) -{ - tex->surface.dimension = dimension; - tex->surface.width = width; - tex->surface.height = height; - tex->surface.depth = depth; - tex->surface.num_mips = num_mips; - tex->surface.format = format; - tex->surface.aa = GX2_AA_MODE_1X; - tex->surface.use = GX2_SURFACE_USE_TEXTURE; - tex->surface.image_size = 0; - tex->surface.image_data = NULL; - tex->surface.mip_size = 0; - tex->surface.mip_data = NULL; - tex->surface.tile = tile; - tex->surface.swizzle = 0; - tex->surface.align = 0; - tex->surface.pitch = 0; - u32 i; - for(i = 0; i < 13; i++) - tex->surface.mip_offset[i] = 0; - tex->view_first_mip = 0; - tex->view_mips_count = num_mips; - tex->view_first_slice = 0; - tex->view_slices_count = depth; - tex->component_selector = texture_comp_selector[format & 0x3f]; - for(i = 0; i < 5; i++) - tex->regs[i] = 0; - - GX2CalcSurfaceSizeAndAlignment(&tex->surface); - GX2InitTextureRegs(tex); -} - -#ifdef __cplusplus -} -#endif - -#endif // __GX2_FUNCTIONS_H_ diff --git a/src/dynamic_libs/gx2_types.h b/src/dynamic_libs/gx2_types.h deleted file mode 100644 index e292318..0000000 --- a/src/dynamic_libs/gx2_types.h +++ /dev/null @@ -1,699 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef _GX2_TYPES_H_ -#define _GX2_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -//!----------------------------------------------------------------------------------------------------------------------- -//! Constants -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_COMMAND_BUFFER_SIZE 0x400000 -#define GX2_SCAN_BUFFER_ALIGNMENT 0x1000 -#define GX2_SHADER_ALIGNMENT 0x100 -#define GX2_CONTEXT_STATE_ALIGNMENT 0x100 -#define GX2_DISPLAY_LIST_ALIGNMENT 0x20 -#define GX2_VERTEX_BUFFER_ALIGNMENT 0x40 -#define GX2_INDEX_BUFFER_ALIGNMENT 0x20 - -#define GX2_CONTEXT_STATE_SIZE 0xA100 - -#define GX2_AUX_BUFFER_CLEAR_VALUE 0xCC - -//!----------------------------------------------------------------------------------------------------------------------- -//! Common -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_FALSE 0 -#define GX2_TRUE 1 -#define GX2_DISABLE 0 -#define GX2_ENABLE 1 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2InitAttrib -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_INIT_ATTRIB_NULL 0 -#define GX2_INIT_ATTRIB_CB_BASE 1 -#define GX2_INIT_ATTRIB_CB_SIZE 2 -#define GX2_INIT_ATTRIB_ARGC 7 -#define GX2_INIT_ATTRIB_ARGV 8 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 compare functions -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_COMPARE_NEVER 0 -#define GX2_COMPARE_LESS 1 -#define GX2_COMPARE_EQUAL 2 -#define GX2_COMPARE_LEQUAL 3 -#define GX2_COMPARE_GREATER 4 -#define GX2_COMPARE_NOTEQUAL 5 -#define GX2_COMPARE_GEQUAL 6 -#define GX2_COMPARE_ALWAYS 7 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 stencil functions -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_STENCIL_KEEP 0 -#define GX2_STENCIL_ZERO 1 -#define GX2_STENCIL_REPLACE 2 -#define GX2_STENCIL_INCR 3 -#define GX2_STENCIL_DECR 4 -#define GX2_STENCIL_INVERT 5 -#define GX2_STENCIL_INCR_WRAP 6 -#define GX2_STENCIL_DECR_WRAP 7 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 logic op functions -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_LOGIC_OP_CLEAR 0x00 -#define GX2_LOGIC_OP_NOR 0x11 -#define GX2_LOGIC_OP_INVAND 0x22 -#define GX2_LOGIC_OP_INVCOPY 0x33 -#define GX2_LOGIC_OP_REVAND 0x44 -#define GX2_LOGIC_OP_INV 0x55 -#define GX2_LOGIC_OP_XOR 0x66 -#define GX2_LOGIC_OP_NAND 0x77 -#define GX2_LOGIC_OP_AND 0x88 -#define GX2_LOGIC_OP_EQUIV 0x99 -#define GX2_LOGIC_OP_NOOP 0xAA -#define GX2_LOGIC_OP_INVOR 0xBB -#define GX2_LOGIC_OP_COPY 0xCC -#define GX2_LOGIC_OP_REVOR 0xDD -#define GX2_LOGIC_OP_OR 0xEE -#define GX2_LOGIC_OP_SET 0xFF - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 blend combination functions -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_BLEND_COMBINE_ADD 0x00 -#define GX2_BLEND_COMBINE_SRC_MINUS_DST 0x01 -#define GX2_BLEND_COMBINE_MIN 0x02 -#define GX2_BLEND_COMBINE_MAX 0x03 -#define GX2_BLEND_COMBINE_DST_MINUS_SRC 0x04 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 blend functions -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_BLEND_ZERO 0x00 -#define GX2_BLEND_ONE 0x01 -#define GX2_BLEND_SRC_ALPHA 0x04 -#define GX2_BLEND_ONE_MINUS_SRC_ALPHA 0x05 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 render targets -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_RENDER_TARGET_0 0 -#define GX2_RENDER_TARGET_1 1 -#define GX2_RENDER_TARGET_2 2 -#define GX2_RENDER_TARGET_3 3 -#define GX2_RENDER_TARGET_4 4 -#define GX2_RENDER_TARGET_5 5 -#define GX2_RENDER_TARGET_6 6 -#define GX2_RENDER_TARGET_7 7 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 cull modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_FRONT_FACE_CCW 0 -#define GX2_FRONT_FACE_CW 1 -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 polygon modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_POLYGON_MODE_POINT 0 -#define GX2_POLYGON_MODE_LINE 1 -#define GX2_POLYGON_MODE_TRIANGLE 2 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 special states -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SPECIAL_STATE_CLEAR 0 -#define GX2_SPECIAL_STATE_CLEAR_HIZ 1 -#define GX2_SPECIAL_STATE_COPY 2 -#define GX2_SPECIAL_STATE_EXPAND_COLOR 3 -#define GX2_SPECIAL_STATE_EXPAND_DEPTH 4 -#define GX2_SPECIAL_STATE_CONVERT_DEPTH 5 -#define GX2_SPECIAL_STATE_CONVERT_AADEPTH 6 -#define GX2_SPECIAL_STATE_RESOLVE_COLOR 7 -#define GX2_SPECIAL_STATE_CLEAR_COLOR_AS_DEPTH 8 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 attribute formats -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_ATTRIB_FORMAT_8_UNORM 0x00000000 -#define GX2_ATTRIB_FORMAT_4_4_UNORM 0x00000001 -#define GX2_ATTRIB_FORMAT_16_UNORM 0x00000002 -#define GX2_ATTRIB_FORMAT_8_8_UNORM 0x00000004 -#define GX2_ATTRIB_FORMAT_16_16_UNORM 0x00000007 -#define GX2_ATTRIB_FORMAT_8_8_8_8_UNORM 0x0000000A -#define GX2_ATTRIB_FORMAT_10_10_10_2_UNORM 0x0000000B -#define GX2_ATTRIB_FORMAT_16_16_16_16_UNORM 0x0000000E - -#define GX2_ATTRIB_FORMAT_8_UINT 0x00000100 -#define GX2_ATTRIB_FORMAT_16_UINT 0x00000102 -#define GX2_ATTRIB_FORMAT_8_8_UINT 0x00000104 -#define GX2_ATTRIB_FORMAT_32_UINT 0x00000105 -#define GX2_ATTRIB_FORMAT_16_16_UINT 0x00000107 -#define GX2_ATTRIB_FORMAT_8_8_8_8_UINT 0x0000010A -#define GX2_ATTRIB_FORMAT_10_10_10_2_UINT 0x0000010B -#define GX2_ATTRIB_FORMAT_32_32_UINT 0x0000010C -#define GX2_ATTRIB_FORMAT_16_16_16_16_UINT 0x0000010E -#define GX2_ATTRIB_FORMAT_32_32_32_UINT 0x00000110 -#define GX2_ATTRIB_FORMAT_32_32_32_32_UINT 0x00000112 - -#define GX2_ATTRIB_FORMAT_8_SNORM 0x00000200 -#define GX2_ATTRIB_FORMAT_16_SNORM 0x00000202 -#define GX2_ATTRIB_FORMAT_8_8_SNORM 0x00000204 -#define GX2_ATTRIB_FORMAT_16_16_SNORM 0x00000207 -#define GX2_ATTRIB_FORMAT_8_8_8_8_SNORM 0x0000020A -#define GX2_ATTRIB_FORMAT_10_10_10_2_SNORM 0x0000020B -#define GX2_ATTRIB_FORMAT_16_16_16_16_SNORM 0x0000020E - -#define GX2_ATTRIB_FORMAT_8_SINT 0x00000300 -#define GX2_ATTRIB_FORMAT_16_SINT 0x00000303 -#define GX2_ATTRIB_FORMAT_8_8_SINT 0x00000304 -#define GX2_ATTRIB_FORMAT_32_SINT 0x00000305 -#define GX2_ATTRIB_FORMAT_16_16_SINT 0x00000307 -#define GX2_ATTRIB_FORMAT_8_8_8_8_SINT 0x0000030A -#define GX2_ATTRIB_FORMAT_10_10_10_2_SINT 0x0000030B -#define GX2_ATTRIB_FORMAT_32_32_SINT 0x0000030C -#define GX2_ATTRIB_FORMAT_16_16_16_16_SINT 0x0000030E -#define GX2_ATTRIB_FORMAT_32_32_32_SINT 0x00000310 -#define GX2_ATTRIB_FORMAT_32_32_32_32_SINT 0x00000312 - -#define GX2_ATTRIB_FORMAT_8_UINT_TO_FLOAT 0x00000800 -#define GX2_ATTRIB_FORMAT_16_UINT_TO_FLOAT 0x00000802 -#define GX2_ATTRIB_FORMAT_16_FLOAT 0x00000803 -#define GX2_ATTRIB_FORMAT_8_8_UINT_TO_FLOAT 0x00000804 -#define GX2_ATTRIB_FORMAT_32_FLOAT 0x00000806 -#define GX2_ATTRIB_FORMAT_16_16_UINT_TO_FLOAT 0x00000807 -#define GX2_ATTRIB_FORMAT_16_16_FLOAT 0x00000808 -#define GX2_ATTRIB_FORMAT_10_11_11_FLOAT 0x00000809 -#define GX2_ATTRIB_FORMAT_8_8_8_8_UINT_TO_FLOAT 0x0000080A -#define GX2_ATTRIB_FORMAT_32_32_FLOAT 0x0000080D -#define GX2_ATTRIB_FORMAT_16_16_16_16_UINT_TO_FLOAT 0x0000080E -#define GX2_ATTRIB_FORMAT_16_16_16_16_FLOAT 0x0000080F -#define GX2_ATTRIB_FORMAT_32_32_32_FLOAT 0x00000811 -#define GX2_ATTRIB_FORMAT_32_32_32_32_FLOAT 0x00000813 - -#define GX2_ATTRIB_FORMAT_8_SINT_TO_FLOAT 0x00000A00 -#define GX2_ATTRIB_FORMAT_16_SINT_TO_FLOAT 0x00000A02 -#define GX2_ATTRIB_FORMAT_8_8_SINT_TO_FLOAT 0x00000A04 -#define GX2_ATTRIB_FORMAT_16_16_SINT_TO_FLOAT 0x00000A07 -#define GX2_ATTRIB_FORMAT_8_8_8_8_SINT_TO_FLOAT 0x00000A0A -#define GX2_ATTRIB_FORMAT_16_16_16_16_SINT_TO_FLOAT 0x00000A0E - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 shader modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SHADER_MODE_UNIFORM_REGISTER 0 -#define GX2_SHADER_MODE_UNIFORM_BLOCK 1 -#define GX2_SHADER_MODE_GEOMETRY_SHADER 2 -#define GX2_SHADER_MODE_COMPUTE_SHADER 3 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 shader modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_COMP_SEL_NONE 0x04040405 -#define GX2_COMP_SEL_X001 0x00040405 -#define GX2_COMP_SEL_XY01 0x00010405 -#define GX2_COMP_SEL_XYZ1 0x00010205 -#define GX2_COMP_SEL_XYZW 0x00010203 -#define GX2_COMP_SEL_XXXX 0x00000000 -#define GX2_COMP_SEL_YYYY 0x01010101 -#define GX2_COMP_SEL_ZZZZ 0x02020202 -#define GX2_COMP_SEL_WWWW 0x03030303 -#define GX2_COMP_SEL_WZYX 0x03020100 -#define GX2_COMP_SEL_WXYZ 0x03000102 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 variable types -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_VAR_TYPE_VOID 0 -#define GX2_VAR_TYPE_BOOL 1 -#define GX2_VAR_TYPE_INT 2 -#define GX2_VAR_TYPE_UINT 3 -#define GX2_VAR_TYPE_FLOAT 4 -#define GX2_VAR_TYPE_DOUBLE 5 -#define GX2_VAR_TYPE_VEC2 9 -#define GX2_VAR_TYPE_VEC3 10 -#define GX2_VAR_TYPE_VEC4 11 -#define GX2_VAR_TYPE_MAT2 21 -#define GX2_VAR_TYPE_MAT3 25 -#define GX2_VAR_TYPE_MAT4 29 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 sample types -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SAMPLER_TYPE_2D 1 - - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 index formats -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_INDEX_FORMAT_U16 4 -#define GX2_INDEX_FORMAT_U32 9 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 primitive types -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_PRIMITIVE_POINTS 0x01 -#define GX2_PRIMITIVE_LINES 0x02 -#define GX2_PRIMITIVE_LINE_STRIP 0x03 -#define GX2_PRIMITIVE_TRIANGLES 0x04 -#define GX2_PRIMITIVE_TRIANGLE_FAN 0x05 -#define GX2_PRIMITIVE_TRIANGLE_STRIP 0x06 -#define GX2_PRIMITIVE_RECTS 0x11 -#define GX2_PRIMITIVE_QUADS 0x13 -#define GX2_PRIMITIVE_QUAD_STRIP 0x14 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 clear modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_CLEAR_DEPTH 0x01 -#define GX2_CLEAR_STENCIL 0x02 -#define GX2_CLEAR_BOTH (GX2_CLEAR_DEPTH | GX2_CLEAR_STENCIL) - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 surface formats -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SURFACE_FORMAT_TC_R8_UNORM 0x00000001 -#define GX2_SURFACE_FORMAT_T_R4_G4_UNORM 0x00000002 -#define GX2_SURFACE_FORMAT_TCD_R16_UNORM 0x00000005 -#define GX2_SURFACE_FORMAT_TC_R8_G8_UNORM 0x00000007 -#define GX2_SURFACE_FORMAT_TCS_R5_G6_B5_UNORM 0x00000008 -#define GX2_SURFACE_FORMAT_TC_R5_G5_B5_A1_UNORM 0x0000000a -#define GX2_SURFACE_FORMAT_TC_R4_G4_B4_A4_UNORM 0x0000000b -#define GX2_SURFACE_FORMAT_TC_A1_B5_G5_R5_UNORM 0x0000000c -#define GX2_SURFACE_FORMAT_TC_R16_G16_UNORM 0x0000000f -#define GX2_SURFACE_FORMAT_D_D24_S8_UNORM 0x00000011 -#define GX2_SURFACE_FORMAT_T_R24_UNORM_X8 0x00000011 -#define GX2_SURFACE_FORMAT_TCS_R10_G10_B10_A2_UNORM 0x00000019 -#define GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM 0x0000001a -#define GX2_SURFACE_FORMAT_TCS_A2_B10_G10_R10_UNORM 0x0000001b -#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_UNORM 0x0000001f -#define GX2_SURFACE_FORMAT_T_BC1_UNORM 0x00000031 -#define GX2_SURFACE_FORMAT_T_BC2_UNORM 0x00000032 -#define GX2_SURFACE_FORMAT_T_BC3_UNORM 0x00000033 -#define GX2_SURFACE_FORMAT_T_BC4_UNORM 0x00000034 -#define GX2_SURFACE_FORMAT_T_BC5_UNORM 0x00000035 -#define GX2_SURFACE_FORMAT_T_NV12_UNORM 0x00000081 - -#define GX2_SURFACE_FORMAT_TC_R8_UINT 0x00000101 -#define GX2_SURFACE_FORMAT_TC_R16_UINT 0x00000105 -#define GX2_SURFACE_FORMAT_TC_R8_G8_UINT 0x00000107 -#define GX2_SURFACE_FORMAT_TC_R32_UINT 0x0000010d -#define GX2_SURFACE_FORMAT_TC_R16_G16_UINT 0x0000010f -#define GX2_SURFACE_FORMAT_T_X24_G8_UINT 0x00000111 -#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_UINT 0x00000119 -#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_UINT 0x0000011a -#define GX2_SURFACE_FORMAT_TC_A2_B10_G10_R10_UINT 0x0000011b -#define GX2_SURFACE_FORMAT_T_X32_G8_UINT_X24 0x0000011c -#define GX2_SURFACE_FORMAT_TC_R32_G32_UINT 0x0000011d -#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_UINT 0x0000011f -#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_UINT 0x00000122 - -#define GX2_SURFACE_FORMAT_TC_R8_SNORM 0x00000201 -#define GX2_SURFACE_FORMAT_TC_R16_SNORM 0x00000205 -#define GX2_SURFACE_FORMAT_TC_R8_G8_SNORM 0x00000207 -#define GX2_SURFACE_FORMAT_TC_R16_G16_SNORM 0x0000020f -#define GX2_SURFACE_FORMAT_T_R10_G10_B10_A2_SNORM 0x00000219 -#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_SNORM 0x00000219 -#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SNORM 0x0000021a -#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_SNORM 0x0000021f -#define GX2_SURFACE_FORMAT_T_BC4_SNORM 0x00000234 -#define GX2_SURFACE_FORMAT_T_BC5_SNORM 0x00000235 - -#define GX2_SURFACE_FORMAT_TC_R8_SINT 0x00000301 -#define GX2_SURFACE_FORMAT_TC_R16_SINT 0x00000305 -#define GX2_SURFACE_FORMAT_TC_R8_G8_SINT 0x00000307 -#define GX2_SURFACE_FORMAT_TC_R32_SINT 0x0000030d -#define GX2_SURFACE_FORMAT_TC_R16_G16_SINT 0x0000030f -#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_SINT 0x00000319 -#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SINT 0x0000031a -#define GX2_SURFACE_FORMAT_TC_R32_G32_SINT 0x0000031d -#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_SINT 0x0000031f -#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_SINT 0x00000322 - -#define GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB 0x0000041a -#define GX2_SURFACE_FORMAT_T_BC1_SRGB 0x00000431 -#define GX2_SURFACE_FORMAT_T_BC2_SRGB 0x00000432 -#define GX2_SURFACE_FORMAT_T_BC3_SRGB 0x00000433 - -#define GX2_SURFACE_FORMAT_TC_R16_FLOAT 0x00000806 -#define GX2_SURFACE_FORMAT_TCD_R32_FLOAT 0x0000080e -#define GX2_SURFACE_FORMAT_TC_R16_G16_FLOAT 0x00000810 -#define GX2_SURFACE_FORMAT_D_D24_S8_FLOAT 0x00000811 -#define GX2_SURFACE_FORMAT_TC_R11_G11_B10_FLOAT 0x00000816 -#define GX2_SURFACE_FORMAT_D_D32_FLOAT_S8_UINT_X24 0x0000081c -#define GX2_SURFACE_FORMAT_T_R32_FLOAT_X8_X24 0x0000081c -#define GX2_SURFACE_FORMAT_TC_R32_G32_FLOAT 0x0000081e -#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_FLOAT 0x00000820 -#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_FLOAT 0x00000823 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 tile modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TILE_MODE_DEFAULT 0x00000000 -#define GX2_TILE_MODE_LINEAR_ALIGNED 0x00000001 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 surface use -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SURFACE_USE_TEXTURE 0x00000001 -#define GX2_SURFACE_USE_COLOR_BUFFER 0x00000002 -#define GX2_SURFACE_USE_DEPTH_BUFFER 0x00000004 -#define GX2_SURFACE_USE_SCAN_BUFFER 0x00000008 -#define GX2_SURFACE_USE_FTV 0x80000000 -#define GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_TEXTURE) -#define GX2_SURFACE_USE_DEPTH_BUFFER_TEXTURE (GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE) -#define GX2_SURFACE_USE_COLOR_BUFFER_FTV (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_FTV) -#define GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE_FTV (GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE | GX2_SURFACE_USE_FTV) - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 surface dim -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SURFACE_DIM_1D 0x00000000 -#define GX2_SURFACE_DIM_2D 0x00000001 -#define GX2_SURFACE_DIM_3D 0x00000002 -#define GX2_SURFACE_DIM_CUBE 0x00000003 -#define GX2_SURFACE_DIM_1D_ARRAY 0x00000004 -#define GX2_SURFACE_DIM_2D_ARRAY 0x00000005 -#define GX2_SURFACE_DIM_2D_MSAA 0x00000006 -#define GX2_SURFACE_DIM_2D_MSAA_ARRAY 0x00000007 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 AA modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_AA_MODE_1X 0x00000000 -#define GX2_AA_MODE_2X 0x00000001 -#define GX2_AA_MODE_4X 0x00000002 -#define GX2_AA_MODE_8X 0x00000003 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 texture clamp -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TEX_CLAMP_WRAP 0x00000000 -#define GX2_TEX_CLAMP_MIRROR 0x00000001 -#define GX2_TEX_CLAMP_CLAMP 0x00000002 -#define GX2_TEX_CLAMP_MIRROR_ONCE 0x00000003 -#define GX2_TEX_CLAMP_CLAMP_HALF_BORDER 0x00000004 -#define GX2_TEX_CLAMP_MIRROR_ONCE_HALF_BORDER 0x00000005 -#define GX2_TEX_CLAMP_CLAMP_BORDER 0x00000006 -#define GX2_TEX_CLAMP_MIRROR_ONCE_BORDER 0x00000007 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 texture filter -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TEX_XY_FILTER_POINT 0x00000000 -#define GX2_TEX_XY_FILTER_BILINEAR 0x00000001 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 TV scan modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TV_SCAN_MODE_NONE 0x00000000 -#define GX2_TV_SCAN_MODE_576I 0x00000001 -#define GX2_TV_SCAN_MODE_480I 0x00000002 -#define GX2_TV_SCAN_MODE_480P 0x00000003 -#define GX2_TV_SCAN_MODE_720P 0x00000004 -#define GX2_TV_SCAN_MODE_1080I 0x00000006 -#define GX2_TV_SCAN_MODE_1080P 0x00000007 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 TV render modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TV_RENDER_480_NARROW 0x00000001 -#define GX2_TV_RENDER_480_WIDE 0x00000002 -#define GX2_TV_RENDER_720 0x00000003 -#define GX2_TV_RENDER_1080 0x00000005 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 DRC render modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_DRC_NONE 0x00000000 -#define GX2_DRC_SINGLE 0x00000001 -#define GX2_DRC_DOUBLE 0x00000002 -#define GX2_DRC_SINGLE_30HZ 0x00000004 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 buffering mode -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_BUFFERING_SINGLE 0x00000001 -#define GX2_BUFFERING_DOUBLE 0x00000002 -#define GX2_BUFFERING_TRIPLE 0x00000003 -#define GX2_BUFFERING_QUAD -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 scan targets -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_SCAN_TARGET_TV 0x00000001 -#define GX2_SCAN_TARGET_DRC_FIRST 0x00000004 -#define GX2_SCAN_TARGET_DRC_SECOND 0x00000008 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 invalidate types -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_INVALIDATE_ATTRIB_BUFFER 0x00000001 -#define GX2_INVALIDATE_TEXTURE 0x00000002 -#define GX2_INVALIDATE_UNIFORM_BLOCK 0x00000004 -#define GX2_INVALIDATE_SHADER 0x00000008 -#define GX2_INVALIDATE_COLOR_BUFFER 0x00000010 -#define GX2_INVALIDATE_DEPTH_BUFFER 0x00000020 -#define GX2_INVALIDATE_CPU 0x00000040 -#define GX2_INVALIDATE_CPU_ATTRIB_BUFFER (GX2_INVALIDATE_CPU | GX2_INVALIDATE_ATTRIB_BUFFER) -#define GX2_INVALIDATE_CPU_TEXTURE (GX2_INVALIDATE_CPU | GX2_INVALIDATE_TEXTURE) -#define GX2_INVALIDATE_CPU_UNIFORM_BLOCK (GX2_INVALIDATE_CPU | GX2_INVALIDATE_UNIFORM_BLOCK) -#define GX2_INVALIDATE_CPU_SHADER (GX2_INVALIDATE_CPU | GX2_INVALIDATE_SHADER) - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 swap modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_ENDIANSWAP_DEFAULT 0x00000003 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 tessellation modes -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_TESSELLATION_MODE_DISCRETE 0x00000000 -#define GX2_TESSELLATION_MODE_CONTINUOUS 0x00000001 -#define GX2_TESSELLATION_MODE_ADAPTIVE 0x00000002 - -//!----------------------------------------------------------------------------------------------------------------------- -//! GX2 fetch shader types -//!----------------------------------------------------------------------------------------------------------------------- -#define GX2_FETCH_SHADER_TESSELATION_NONE 0x00000000 -#define GX2_FETCH_SHADER_TESSELATION_LINES 0x00000001 -#define GX2_FETCH_SHADER_TESSELATION_TRIANGLES 0x00000002 -#define GX2_FETCH_SHADER_TESSELATION_QUADS 0x00000003 - - -typedef struct _GX2ContextState { - u8 data[GX2_CONTEXT_STATE_SIZE]; -} GX2ContextState; - -typedef struct _GX2Surface { - s32 dimension; - u32 width; - u32 height; - u32 depth; - u32 num_mips; - s32 format; - s32 aa; - s32 use; - u32 image_size; - void *image_data; - u32 mip_size; - void *mip_data; - s32 tile; - u32 swizzle; - u32 align; - u32 pitch; - u32 mip_offset[13]; -} GX2Surface; - -typedef struct _GX2ColorBuffer { - GX2Surface surface; - u32 view_mip; - u32 view_first_slice; - u32 view_slices_count; - void *aux_data; - u32 aux_size; - u32 regs[5]; -} GX2ColorBuffer; - -typedef struct _GX2DepthBuffer { - GX2Surface surface; - u32 view_mip; - u32 view_first_slice; - u32 view_slices_count; - void *hiZ_data; - u32 hiZ_size; - f32 clear_depth; - u32 clear_stencil; - u32 regs[7]; -} GX2DepthBuffer; - - -typedef struct _GX2Texture { - GX2Surface surface; - u32 view_first_mip; - u32 view_mips_count; - u32 view_first_slice; - u32 view_slices_count; - u32 component_selector; - u32 regs[5]; -} GX2Texture; - - -typedef struct _GX2Sampler { - u32 regs[3]; -} GX2Sampler; - -typedef struct _GX2AttribStream { - u32 location; - u32 buffer; - u32 offset; - s32 format; - s32 index_type; - u32 divisor; - u32 destination_selector; - s32 endian_swap; -} GX2AttribStream; - -typedef struct _GX2FetchShader { - s32 type; - u32 reg; - u32 shader_size; - void *shader_program; - u32 attributes_count; - u32 divisor[3]; -} GX2FetchShader; - -typedef struct _GX2AttribVar -{ - const char *name; - s32 var_type; - u32 array_count; - u32 location; -} GX2AttribVar; - - -typedef struct _GX2UniformBlock { - const char *name; - u32 location; - u32 block_size; -} GX2UniformBlock; - -typedef struct _GX2UniformInitialValue { - f32 value[4]; - u32 offset; -} GX2UniformInitialValue; - -typedef struct _GX2SamplerVar -{ - const char *name; - s32 sampler_type; - u32 location; -} GX2SamplerVar; - -typedef struct _GX2UniformVar -{ - const char *name; - s32 var_type; - u32 array_count; - u32 offset; - u32 block_index; -} GX2UniformVar; - -typedef struct _GX2VertexShader { - u32 regs[52]; - u32 shader_size; - void *shader_data; - s32 shader_mode; - u32 uniform_blocks_count; - GX2UniformBlock *uniform_block; - u32 uniform_vars_count; - GX2UniformVar *uniform_var; - u32 initial_values_count; - GX2UniformInitialValue *initial_value; - u32 loops_count; - void *loops_data; - u32 sampler_vars_count; - GX2SamplerVar *sampler_var; - u32 attribute_vars_count; - GX2AttribVar *attribute_var; - u32 data[6]; - u32 shader_program_buffer[16]; -} GX2VertexShader; - -typedef struct _GX2PixelShader { - u32 regs[41]; - u32 shader_size; - void *shader_data; - s32 shader_mode; - u32 uniform_blocks_count; - GX2UniformBlock *uniform_block; - u32 uniform_vars_count; - GX2UniformVar *uniform_var; - u32 initial_values_count; - GX2UniformInitialValue *initial_value; - u32 loops_count; - void *loops_data; - u32 sampler_vars_count; - GX2SamplerVar *sampler_var; - u32 shader_program_buffer[16]; -} GX2PixelShader; - -static const u32 attribute_dest_comp_selector[20] = { - GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, - GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, - GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, - GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW -}; - -static const u32 texture_comp_selector[54] = { - GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, - GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, - GX2_COMP_SEL_WZYX, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, - GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, - GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_WZYX, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, - GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, - GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_X001, - GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, - GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01 -}; - -typedef struct _GX2Color { - u8 r, g, b, a; -} GX2Color; - -typedef struct _GX2ColorF32 { - f32 r, g, b, a; -} GX2ColorF32; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/dynamic_libs/os_functions.c b/src/dynamic_libs/os_functions.c deleted file mode 100644 index 7999c63..0000000 --- a/src/dynamic_libs/os_functions.c +++ /dev/null @@ -1,404 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "common/common.h" -#include "os_functions.h" - -u32 coreinit_handle __attribute__((section(".data"))) = 0; - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Lib handle functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(s32, OSDynLoad_Acquire, const char* rpl, u32 *handle); -EXPORT_DECL(s32, OSDynLoad_FindExport, u32 handle, s32 isdata, const char *symbol, void *address); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Security functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(s32, OSGetSecurityLevel, void); -EXPORT_DECL(s32, OSForceFullRelaunch, void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Thread functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(s32, OSCreateThread, void *thread, s32 (*callback)(s32, void*), s32 argc, void *args, u32 stack, u32 stack_size, s32 priority, u32 attr); -EXPORT_DECL(s32, OSResumeThread, void *thread); -EXPORT_DECL(s32, OSSuspendThread, void *thread); -EXPORT_DECL(void, OSExitThread, u32 result); -EXPORT_DECL(s32, OSIsThreadTerminated, void *thread); -EXPORT_DECL(s32, OSIsThreadSuspended, void *thread); -EXPORT_DECL(s32, OSSetThreadPriority, void * thread, s32 priority); -EXPORT_DECL(s32, OSJoinThread, void * thread, s32 * ret_val); -EXPORT_DECL(void, OSDetachThread, void * thread); -EXPORT_DECL(void, OSSleepTicks, u64 ticks); -EXPORT_DECL(u64, OSGetTick, void); -EXPORT_DECL(u64, OSGetTime, void); -EXPORT_DECL(void, OSTicksToCalendarTime, u64 time, OSCalendarTime * calendarTime); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Mutex functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(void, OSInitMutex, void* mutex); -EXPORT_DECL(void, OSLockMutex, void* mutex); -EXPORT_DECL(void, OSUnlockMutex, void* mutex); -EXPORT_DECL(s32, OSTryLockMutex, void* mutex); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Shared Data functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(bool, OSGetSharedData, u32 type, u32 unk_r4, u8 *addr, u32 *size); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! System functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(u64, OSGetTitleID, void); -EXPORT_DECL(void, OSGetArgcArgv, s32* argc, char*** argv); -EXPORT_DECL(void, __Exit, void); -EXPORT_DECL(void, OSFatal, const char* msg); -EXPORT_DECL(void, OSSetExceptionCallback, u8 exceptionType, exception_callback newCallback); -EXPORT_DECL(void, DCFlushRange, const void *addr, u32 length); -EXPORT_DECL(void, DCStoreRange, const void *addr, u32 length); -EXPORT_DECL(void, ICInvalidateRange, const void *addr, u32 length); -EXPORT_DECL(void*, OSEffectiveToPhysical, const void*); -EXPORT_DECL(s32, __os_snprintf, char* s, s32 n, const char * format, ...); -EXPORT_DECL(s32 *, __gh_errno_ptr, void); - -EXPORT_DECL(void, OSScreenInit, void); -EXPORT_DECL(u32, OSScreenGetBufferSizeEx, u32 bufferNum); -EXPORT_DECL(s32, OSScreenSetBufferEx, u32 bufferNum, void * addr); -EXPORT_DECL(s32, OSScreenClearBufferEx, u32 bufferNum, u32 temp); -EXPORT_DECL(s32, OSScreenFlipBuffersEx, u32 bufferNum); -EXPORT_DECL(s32, OSScreenPutFontEx, u32 bufferNum, u32 posX, u32 posY, const char * buffer); -EXPORT_DECL(s32, OSScreenEnableEx, u32 bufferNum, s32 enable); -EXPORT_DECL(u32, OSScreenPutPixelEx, u32 bufferNum, u32 posX, u32 posY, u32 color); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Memory functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_VAR(u32 *, pMEMAllocFromDefaultHeapEx); -EXPORT_VAR(u32 *, pMEMAllocFromDefaultHeap); -EXPORT_VAR(u32 *, pMEMFreeToDefaultHeap); - -EXPORT_DECL(s32, MEMGetBaseHeapHandle, s32 mem_arena); -EXPORT_DECL(u32, MEMGetAllocatableSizeForFrmHeapEx, s32 heap, s32 align); -EXPORT_DECL(void *, MEMAllocFromFrmHeapEx, s32 heap, u32 size, s32 align); -EXPORT_DECL(void, MEMFreeToFrmHeap, s32 heap, s32 mode); -EXPORT_DECL(void *, MEMAllocFromExpHeapEx, s32 heap, u32 size, s32 align); -EXPORT_DECL(s32 , MEMCreateExpHeapEx, void* address, u32 size, unsigned short flags); -EXPORT_DECL(void *, MEMDestroyExpHeap, s32 heap); -EXPORT_DECL(void, MEMFreeToExpHeap, s32 heap, void* ptr); -EXPORT_DECL(void *, OSAllocFromSystem, int size, int alignment); -EXPORT_DECL(void, OSFreeToSystem, void *addr); -EXPORT_DECL(int, OSIsAddressValid, void *ptr); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! MCP functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(s32, MCP_Open, void); -EXPORT_DECL(s32, MCP_Close, s32 handle); -EXPORT_DECL(s32, MCP_TitleCount, s32 handle); -EXPORT_DECL(s32, MCP_TitleList, s32 handle, s32 *res, void *data, s32 count); -EXPORT_DECL(s32, MCP_GetOwnTitleInfo, s32 handle, void * data); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Loader functions (not real rpl) -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(s32, LiWaitIopComplete, s32 unknown_syscall_arg_r3, s32 * remaining_bytes); -EXPORT_DECL(s32, LiWaitIopCompleteWithInterrupts, s32 unknown_syscall_arg_r3, s32 * remaining_bytes); -EXPORT_DECL(void, addr_LiWaitOneChunk, void); -EXPORT_DECL(void, addr_sgIsLoadingBuffer, void); -EXPORT_DECL(void, addr_gDynloadInitialized, void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Kernel function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(void, addr_PrepareTitle_hook, void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Other function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -EXPORT_DECL(void, DCInvalidateRange, void *buffer, u32 length); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Energy Saver functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//Burn-in Reduction -EXPORT_DECL(s32, IMEnableDim,void); -EXPORT_DECL(s32, IMDisableDim,void); -EXPORT_DECL(s32, IMIsDimEnabled,s32 * result); -//Auto power down -EXPORT_DECL(s32, IMEnableAPD,void); -EXPORT_DECL(s32, IMDisableAPD,void); -EXPORT_DECL(s32, IMIsAPDEnabled,s32 * result); -EXPORT_DECL(s32, IMIsAPDEnabledBySysSettings,s32 * result); - -EXPORT_DECL(s32, OSSendAppSwitchRequest,s32 param,void* unknown1,void* unknown2); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! IOS functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -EXPORT_DECL(s32, IOS_Ioctl,s32 fd, u32 request, void *input_buffer,u32 input_buffer_len, void *output_buffer, u32 output_buffer_len); -EXPORT_DECL(s32, IOS_IoctlAsync,s32 fd, u32 request, void *input_buffer,u32 input_buffer_len, void *output_buffer, u32 output_buffer_len, void *cb, void *cbarg); -EXPORT_DECL(s32, IOS_Open,char *path, u32 mode); -EXPORT_DECL(s32, IOS_Close,s32 fd); - -void _os_find_export(u32 handle, const char *funcName, void *funcPointer) -{ - OSDynLoad_FindExport(handle, 0, funcName, funcPointer); - - if(!*(u32 *)funcPointer) { - /* - * This is effectively OSFatal("Function %s is NULL", funcName), - * but we can't rely on any library functions like snprintf or - * strcpy at this point. - * - * Buffer bounds are not checked. Beware! - */ - char buf[256], *bufp = buf; - const char a[] = "Function ", b[] = " is NULL", *p; - unsigned int i; - - for (i = 0; i < sizeof(a) - 1; i++) - *bufp++ = a[i]; - - for (p = funcName; *p; p++) - *bufp++ = *p; - - for (i = 0; i < sizeof(b) - 1; i++) - *bufp++ = b[i]; - - *bufp++ = '\0'; - - OSFatal(buf); - } -} - -void InitAcquireOS(void) -{ - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Lib handle functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - EXPORT_FUNC_WRITE(OSDynLoad_Acquire, (s32 (*)(const char*, unsigned *))OS_SPECIFICS->addr_OSDynLoad_Acquire); - EXPORT_FUNC_WRITE(OSDynLoad_FindExport, (s32 (*)(u32, s32, const char *, void *))OS_SPECIFICS->addr_OSDynLoad_FindExport); - - OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle); -} - -void InitOSFunctionPointers(void) -{ - u32 *funcPointer = 0; - - InitAcquireOS(); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Security functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, OSGetSecurityLevel); - OS_FIND_EXPORT(coreinit_handle, OSForceFullRelaunch); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Shared Data functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, OSGetSharedData); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! System functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, OSFatal); - OS_FIND_EXPORT(coreinit_handle, OSGetTitleID); - OS_FIND_EXPORT(coreinit_handle, OSGetArgcArgv); - OS_FIND_EXPORT(coreinit_handle, OSSetExceptionCallback); - OS_FIND_EXPORT(coreinit_handle, DCFlushRange); - OS_FIND_EXPORT(coreinit_handle, DCStoreRange); - OS_FIND_EXPORT(coreinit_handle, ICInvalidateRange); - OS_FIND_EXPORT(coreinit_handle, OSEffectiveToPhysical); - OS_FIND_EXPORT(coreinit_handle, __os_snprintf); - OS_FIND_EXPORT(coreinit_handle, __gh_errno_ptr); - - OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &__Exit); - - OS_FIND_EXPORT(coreinit_handle, OSScreenInit); - OS_FIND_EXPORT(coreinit_handle, OSScreenGetBufferSizeEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenSetBufferEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenClearBufferEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenFlipBuffersEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenPutFontEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenEnableEx); - OS_FIND_EXPORT(coreinit_handle, OSScreenPutPixelEx); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Thread functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, OSCreateThread); - OS_FIND_EXPORT(coreinit_handle, OSResumeThread); - OS_FIND_EXPORT(coreinit_handle, OSSuspendThread); - OS_FIND_EXPORT(coreinit_handle, OSExitThread); - OS_FIND_EXPORT(coreinit_handle, OSIsThreadTerminated); - OS_FIND_EXPORT(coreinit_handle, OSIsThreadSuspended); - OS_FIND_EXPORT(coreinit_handle, OSJoinThread); - OS_FIND_EXPORT(coreinit_handle, OSSetThreadPriority); - OS_FIND_EXPORT(coreinit_handle, OSDetachThread); - OS_FIND_EXPORT(coreinit_handle, OSSleepTicks); - OS_FIND_EXPORT(coreinit_handle, OSGetTick); - OS_FIND_EXPORT(coreinit_handle, OSGetTime); - OS_FIND_EXPORT(coreinit_handle, OSTicksToCalendarTime); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Mutex functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, OSInitMutex); - OS_FIND_EXPORT(coreinit_handle, OSLockMutex); - OS_FIND_EXPORT(coreinit_handle, OSUnlockMutex); - OS_FIND_EXPORT(coreinit_handle, OSTryLockMutex); - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! MCP functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, MCP_Open); - OS_FIND_EXPORT(coreinit_handle, MCP_Close); - OS_FIND_EXPORT(coreinit_handle, MCP_TitleCount); - OS_FIND_EXPORT(coreinit_handle, MCP_TitleList); - OS_FIND_EXPORT(coreinit_handle, MCP_GetOwnTitleInfo); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Memory functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeapEx", &pMEMAllocFromDefaultHeapEx); - OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeap", &pMEMAllocFromDefaultHeap); - OSDynLoad_FindExport(coreinit_handle, 1, "MEMFreeToDefaultHeap", &pMEMFreeToDefaultHeap); - - OS_FIND_EXPORT(coreinit_handle, MEMGetBaseHeapHandle); - OS_FIND_EXPORT(coreinit_handle, MEMGetAllocatableSizeForFrmHeapEx); - OS_FIND_EXPORT(coreinit_handle, MEMAllocFromFrmHeapEx); - OS_FIND_EXPORT(coreinit_handle, MEMFreeToFrmHeap); - OS_FIND_EXPORT(coreinit_handle, MEMAllocFromExpHeapEx); - OS_FIND_EXPORT(coreinit_handle, MEMCreateExpHeapEx); - OS_FIND_EXPORT(coreinit_handle, MEMDestroyExpHeap); - OS_FIND_EXPORT(coreinit_handle, MEMFreeToExpHeap); - OS_FIND_EXPORT(coreinit_handle, OSAllocFromSystem); - OS_FIND_EXPORT(coreinit_handle, OSFreeToSystem); - OS_FIND_EXPORT(coreinit_handle, OSIsAddressValid); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Other function addresses - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, DCInvalidateRange); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Energy Saver functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //Burn-in Reduction - OS_FIND_EXPORT(coreinit_handle, IMEnableDim); - OS_FIND_EXPORT(coreinit_handle, IMDisableDim); - OS_FIND_EXPORT(coreinit_handle, IMIsDimEnabled); - //Auto power down - OS_FIND_EXPORT(coreinit_handle, IMEnableAPD); - OS_FIND_EXPORT(coreinit_handle, IMDisableAPD); - OS_FIND_EXPORT(coreinit_handle, IMIsAPDEnabled); - OS_FIND_EXPORT(coreinit_handle, IMIsAPDEnabledBySysSettings); - - OS_FIND_EXPORT(coreinit_handle, OSSendAppSwitchRequest); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! IOS functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - OS_FIND_EXPORT(coreinit_handle, IOS_Ioctl); - OS_FIND_EXPORT(coreinit_handle, IOS_IoctlAsync); - OS_FIND_EXPORT(coreinit_handle, IOS_Open); - OS_FIND_EXPORT(coreinit_handle, IOS_Close); - - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - //! Special non library functions - //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - if(OS_FIRMWARE == 550) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (s32 (*)(s32, s32 *))0x01010180); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (s32 (*)(s32, s32 *))0x0101006C); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (s32 (*)(s32, s32 *))0x0100080C); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (s32 (*)(s32, s32 *))0xFFF184E4); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (s32 (*)(s32, s32 *))0xEFE19E80); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (s32 (*)(s32, s32 *))0xEFE13DBC); - } - else if(OS_FIRMWARE == 532 || OS_FIRMWARE == 540) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (s32 (*)(s32, s32 *))0x0100FFA4); // loader.elf - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (s32 (*)(s32, s32 *))0x0100FE90); // loader.elf - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (s32 (*)(s32, s32 *))0x010007EC); // loader.elf - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (s32 (*)(s32, s32 *))0xFFF18558); // kernel.elf - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (s32 (*)(s32, s32 *))0xEFE19D00); // loader.elf - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (s32 (*)(s32, s32 *))0xEFE13C3C); // loader.elf - } - else if(OS_FIRMWARE == 500 || OS_FIRMWARE == 510) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (s32 (*)(s32, s32 *))0x0100FBC4); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (s32 (*)(s32, s32 *))0x0100FAB0); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (s32 (*)(s32, s32 *))0x010007EC); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (s32 (*)(s32, s32 *))0xFFF18534); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (s32 (*)(s32, s32 *))0xEFE19D00); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (s32 (*)(s32, s32 *))0xEFE13C3C); - } - else if(OS_FIRMWARE == 410) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (s32 (*)(s32, s32 *))0x0100F78C); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (s32 (*)(s32, s32 *))0x0100F678); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (s32 (*)(s32, s32 *))0x010007F8); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (s32 (*)(s32, s32 *))0xFFF166DC); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (s32 (*)(s32, s32 *))0xEFE19CC0); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (s32 (*)(s32, s32 *))0xEFE13BFC); - } - else if(OS_FIRMWARE == 400) //same for 402 and 403 - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (s32 (*)(s32, s32 *))0x0100F78C); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (s32 (*)(s32, s32 *))0x0100F678); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (s32 (*)(s32, s32 *))0x010007F8); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (s32 (*)(s32, s32 *))0xFFF15E70); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (s32 (*)(s32, s32 *))0xEFE19CC0); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (s32 (*)(s32, s32 *))0xEFE13BFC); - } - else if(OS_FIRMWARE == 310) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (s32 (*)(s32, s32 *))0x0100C4E4); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (s32 (*)(s32, s32 *))0x0100C3D4); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (s32 (*)(s32, s32 *))0x010004D8); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (s32 (*)(s32, s32 *))0xFFF15A0C); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (s32 (*)(s32, s32 *))0xEFE19340); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (s32 (*)(s32, s32 *))0xEFE1329C); - } - else if(OS_FIRMWARE == 300) - { - EXPORT_FUNC_WRITE(LiWaitIopComplete, (s32 (*)(s32, s32 *))0x0100C4E4); - EXPORT_FUNC_WRITE(LiWaitIopCompleteWithInterrupts, (s32 (*)(s32, s32 *))0x0100C3D4); - EXPORT_FUNC_WRITE(addr_LiWaitOneChunk, (s32 (*)(s32, s32 *))0x010004D8); - EXPORT_FUNC_WRITE(addr_PrepareTitle_hook, (s32 (*)(s32, s32 *))0xFFF15974); - - EXPORT_FUNC_WRITE(addr_sgIsLoadingBuffer, (s32 (*)(s32, s32 *))0xEFE19340); - EXPORT_FUNC_WRITE(addr_gDynloadInitialized, (s32 (*)(s32, s32 *))0xEFE1329C); - } - else - { - OSFatal("Missing all OS specific addresses."); - } -} diff --git a/src/dynamic_libs/os_functions.h b/src/dynamic_libs/os_functions.h deleted file mode 100644 index 23ff4a3..0000000 --- a/src/dynamic_libs/os_functions.h +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __OS_FUNCTIONS_H_ -#define __OS_FUNCTIONS_H_ - -#include -#include "common/os_defs.h" -#include "os_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define BUS_SPEED 248625000 -#define SECS_TO_TICKS(sec) (((unsigned long long)(sec)) * (BUS_SPEED/4)) -#define MILLISECS_TO_TICKS(msec) (SECS_TO_TICKS(msec) / 1000) -#define MICROSECS_TO_TICKS(usec) (SECS_TO_TICKS(usec) / 1000000) - -//To avoid conflicts with the unistd.h -#define os_usleep(usecs) OSSleepTicks(MICROSECS_TO_TICKS(usecs)) -#define os_sleep(secs) OSSleepTicks(SECS_TO_TICKS(secs)) - -#define FLUSH_DATA_BLOCK(addr) asm volatile("dcbf 0, %0; sync" : : "r"(((addr) & ~31))) -#define INVAL_DATA_BLOCK(addr) asm volatile("dcbi 0, %0; sync" : : "r"(((addr) & ~31))) - -#define EXPORT_DECL(res, func, ...) res (* func)(__VA_ARGS__) __attribute__((section(".data"))) = 0; -#define EXPORT_VAR(type, var) type var __attribute__((section(".data"))); - - -#define EXPORT_FUNC_WRITE(func, val) *(u32*)(((u32)&func) + 0) = (u32)val - -#define OS_FIND_EXPORT(handle, func) _os_find_export(handle, # func, &funcPointer); \ - EXPORT_FUNC_WRITE(func, funcPointer); - -#define OS_FIND_EXPORT_EX(handle, func, func_p) \ - _os_find_export(handle, # func, &funcPointer); \ - EXPORT_FUNC_WRITE(func_p, funcPointer); - -#define OS_MUTEX_SIZE 44 - -/* Handle for coreinit */ -extern u32 coreinit_handle; -extern void _os_find_export(u32 handle, const char *funcName, void *funcPointer); -extern void InitAcquireOS(void); -extern void InitOSFunctionPointers(void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Lib handle functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern s32 (* OSDynLoad_Acquire)(const char* rpl, u32 *handle); -extern s32 (* OSDynLoad_FindExport)(u32 handle, s32 isdata, const char *symbol, void *address); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Security functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern s32 (* OSGetSecurityLevel)(void); -extern s32 (* OSForceFullRelaunch)(void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Thread functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern s32 (* OSCreateThread)(void *thread, s32 (*callback)(s32, void*), s32 argc, void *args, u32 stack, u32 stack_size, s32 priority, u32 attr); -extern s32 (* OSResumeThread)(void *thread); -extern s32 (* OSSuspendThread)(void *thread); -extern void (*OSExitThread)(u32 result); -extern s32 (* OSIsThreadTerminated)(void *thread); -extern s32 (* OSIsThreadSuspended)(void *thread); -extern s32 (* OSJoinThread)(void * thread, s32 * ret_val); -extern s32 (* OSSetThreadPriority)(void * thread, s32 priority); -extern void (* OSDetachThread)(void * thread); -extern void (* OSSleepTicks)(u64 ticks); -extern u64 (* OSGetTick)(void); -extern u64 (* OSGetTime)(void); -extern void (*OSTicksToCalendarTime)(u64 time, OSCalendarTime *calendarTime); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Mutex functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern void (* OSInitMutex)(void* mutex); -extern void (* OSLockMutex)(void* mutex); -extern void (* OSUnlockMutex)(void* mutex); -extern s32 (* OSTryLockMutex)(void* mutex); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Shared Data functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern bool (* OSGetSharedData)(u32 type, u32 unk_r4, u8 *addr, u32 *size); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! System functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern u64 (* OSGetTitleID)(void); -extern void (* OSGetArgcArgv)(s32* argc, char*** argv); -extern void (* __Exit)(void); -extern void (* OSFatal)(const char* msg); -extern void (* DCFlushRange)(const void *addr, u32 length); -extern void (* DCStoreRange)(const void *addr, u32 length); -extern void (* ICInvalidateRange)(const void *addr, u32 length); -extern void* (* OSEffectiveToPhysical)(const void*); -extern s32 (* __os_snprintf)(char* s, s32 n, const char * format, ...); -extern s32 * (* __gh_errno_ptr)(void); - -extern void (*OSScreenInit)(void); -extern u32 (*OSScreenGetBufferSizeEx)(u32 bufferNum); -extern s32 (*OSScreenSetBufferEx)(u32 bufferNum, void * addr); -extern s32 (*OSScreenClearBufferEx)(u32 bufferNum, u32 temp); -extern s32 (*OSScreenFlipBuffersEx)(u32 bufferNum); -extern s32 (*OSScreenPutFontEx)(u32 bufferNum, u32 posX, u32 posY, const char * buffer); -extern s32 (*OSScreenEnableEx)(u32 bufferNum, s32 enable); -extern u32 (*OSScreenPutPixelEx)(u32 bufferNum, u32 posX, u32 posY, u32 color); - -typedef unsigned char (*exception_callback)(void * interruptedContext); -extern void (* OSSetExceptionCallback)(u8 exceptionType, exception_callback newCallback); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Memory functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern u32 *pMEMAllocFromDefaultHeapEx; -extern u32 *pMEMAllocFromDefaultHeap; -extern u32 *pMEMFreeToDefaultHeap; - -extern s32 (* MEMGetBaseHeapHandle)(s32 mem_arena); -extern u32 (* MEMGetAllocatableSizeForFrmHeapEx)(s32 heap, s32 align); -extern void* (* MEMAllocFromFrmHeapEx)(s32 heap, u32 size, s32 align); -extern void (* MEMFreeToFrmHeap)(s32 heap, s32 mode); -extern void *(* MEMAllocFromExpHeapEx)(s32 heap, u32 size, s32 align); -extern s32 (* MEMCreateExpHeapEx)(void* address, u32 size, unsigned short flags); -extern void *(* MEMDestroyExpHeap)(s32 heap); -extern void (* MEMFreeToExpHeap)(s32 heap, void* ptr); -extern void* (* OSAllocFromSystem)(int size, int alignment); -extern void (* OSFreeToSystem)(void *addr); -extern int (* OSIsAddressValid)(void *ptr); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! MCP functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern s32 (* MCP_Open)(void); -extern s32 (* MCP_Close)(s32 handle); -extern s32 (* MCP_TitleCount)(s32 handle); -extern s32 (* MCP_TitleList)(s32 handle, s32 *res, void *data, s32 count); -extern s32 (* MCP_GetOwnTitleInfo)(s32 handle, void * data); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! LOADER functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern s32 (* LiWaitIopComplete)(s32 unknown_syscall_arg_r3, s32 * remaining_bytes); -extern s32 (* LiWaitIopCompleteWithInterrupts)(s32 unknown_syscall_arg_r3, s32 * remaining_bytes); -extern void (* addr_LiWaitOneChunk)(void); -extern void (* addr_sgIsLoadingBuffer)(void); -extern void (* addr_gDynloadInitialized)(void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Kernel function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern void (* addr_PrepareTitle_hook)(void); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Other function addresses -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -extern void (*DCInvalidateRange)(void *buffer, u32 length); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! Energy Saver functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -////Burn-in Reduction -extern s32 (*IMEnableDim)(void); -extern s32 (*IMDisableDim)(void); -extern s32 (*IMIsDimEnabled)(s32 * result); -//Auto power down -extern s32 (*IMEnableAPD)(void); -extern s32 (*IMDisableAPD)(void); -extern s32 (*IMIsAPDEnabled)(s32 * result); -extern s32 (*IMIsAPDEnabledBySysSettings)(s32 * result); - -extern s32 (*OSSendAppSwitchRequest)(s32 param,void* unknown1,void* unknown2); - -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -//! IOS functions -//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -extern s32 (*IOS_Ioctl)(s32 fd, u32 request, void *input_buffer,u32 input_buffer_len, void *output_buffer, u32 output_buffer_len); -extern s32 (*IOS_IoctlAsync)(s32 fd, u32 request, void *input_buffer,u32 input_buffer_len, void *output_buffer, u32 output_buffer_len, void *cb, void *cbarg); -extern s32 (*IOS_Open)(char *path, u32 mode); -extern s32 (*IOS_Close)(s32 fd); - -#ifdef __cplusplus -} -#endif - -#endif // __OS_FUNCTIONS_H_ diff --git a/src/dynamic_libs/os_types.h b/src/dynamic_libs/os_types.h deleted file mode 100644 index aaa18fe..0000000 --- a/src/dynamic_libs/os_types.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _OS_TYPES_H_ -#define _OS_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef struct _OSCalendarTime { - int sec; - int min; - int hour; - int mday; - int mon; - int year; - int wday; - int yday; - int msec; - int usec; -} OSCalendarTime; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/dynamic_libs/padscore_functions.c b/src/dynamic_libs/padscore_functions.c deleted file mode 100644 index 8f774dc..0000000 --- a/src/dynamic_libs/padscore_functions.c +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "padscore_functions.h" - -u32 padscore_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, KPADInit, void); -EXPORT_DECL(void, WPADInit, void); -EXPORT_DECL(s32, WPADProbe, s32 chan, u32 * pad_type); -EXPORT_DECL(s32, WPADSetDataFormat, s32 chan, s32 format); -EXPORT_DECL(void, WPADEnableURCC, s32 enable); -EXPORT_DECL(void, WPADRead, s32 chan, void * data); -EXPORT_DECL(s32, KPADRead, s32 chan, void * data, u32 size); -EXPORT_DECL(void,WPADSetAutoSleepTime,u8 minute); -EXPORT_DECL(void,WPADDisconnect,s32 chan); - -void InitAcquirePadScore(void) -{ - OSDynLoad_Acquire("padscore.rpl", &padscore_handle); -} - -void InitPadScoreFunctionPointers(void) -{ - u32 *funcPointer = 0; - InitAcquirePadScore(); - - OS_FIND_EXPORT(padscore_handle, WPADInit); - OS_FIND_EXPORT(padscore_handle, KPADInit); - OS_FIND_EXPORT(padscore_handle, WPADProbe); - OS_FIND_EXPORT(padscore_handle, WPADSetDataFormat); - OS_FIND_EXPORT(padscore_handle, WPADEnableURCC); - OS_FIND_EXPORT(padscore_handle, WPADRead); - OS_FIND_EXPORT(padscore_handle, KPADRead); - OS_FIND_EXPORT(padscore_handle, WPADSetAutoSleepTime); - OS_FIND_EXPORT(padscore_handle, WPADDisconnect); - - KPADInit(); - WPADEnableURCC(1); -} diff --git a/src/dynamic_libs/padscore_functions.h b/src/dynamic_libs/padscore_functions.h deleted file mode 100644 index f7f07dc..0000000 --- a/src/dynamic_libs/padscore_functions.h +++ /dev/null @@ -1,200 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __PAD_SCORE_FUNCTIONS_H_ -#define __PAD_SCORE_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "dynamic_libs/vpad_functions.h" - -extern u32 padscore_handle; - -#include - -#define WPAD_EXT_CORE 0 -#define WPAD_EXT_NUNCHUK 1 -#define WPAD_EXT_CLASSIC 2 -#define WPAD_EXT_MPLUS 5 -#define WPAD_EXT_MPLUS_NUNCHUK 6 -#define WPAD_EXT_MPLUS_CLASSIC 7 -#define WPAD_EXT_PRO_CONTROLLER 31 - -#define WPAD_FMT_PRO_CONTROLLER 22 - -#define WPAD_BUTTON_LEFT 0x0001 -#define WPAD_BUTTON_RIGHT 0x0002 -#define WPAD_BUTTON_DOWN 0x0004 -#define WPAD_BUTTON_UP 0x0008 -#define WPAD_BUTTON_PLUS 0x0010 -#define WPAD_BUTTON_2 0x0100 -#define WPAD_BUTTON_1 0x0200 -#define WPAD_BUTTON_B 0x0400 -#define WPAD_BUTTON_A 0x0800 -#define WPAD_BUTTON_MINUS 0x1000 -#define WPAD_BUTTON_Z 0x2000 -#define WPAD_BUTTON_C 0x4000 -#define WPAD_BUTTON_HOME 0x8000 - -#define WPAD_CLASSIC_BUTTON_UP 0x0001 -#define WPAD_CLASSIC_BUTTON_LEFT 0x0002 -#define WPAD_CLASSIC_BUTTON_ZR 0x0004 -#define WPAD_CLASSIC_BUTTON_X 0x0008 -#define WPAD_CLASSIC_BUTTON_A 0x0010 -#define WPAD_CLASSIC_BUTTON_Y 0x0020 -#define WPAD_CLASSIC_BUTTON_B 0x0040 -#define WPAD_CLASSIC_BUTTON_ZL 0x0080 -#define WPAD_CLASSIC_BUTTON_R 0x0200 -#define WPAD_CLASSIC_BUTTON_PLUS 0x0400 -#define WPAD_CLASSIC_BUTTON_HOME 0x0800 -#define WPAD_CLASSIC_BUTTON_MINUS 0x1000 -#define WPAD_CLASSIC_BUTTON_L 0x2000 -#define WPAD_CLASSIC_BUTTON_DOWN 0x4000 -#define WPAD_CLASSIC_BUTTON_RIGHT 0x8000 - -#define WPAD_PRO_BUTTON_UP 0x00000001 -#define WPAD_PRO_BUTTON_LEFT 0x00000002 -#define WPAD_PRO_TRIGGER_ZR 0x00000004 -#define WPAD_PRO_BUTTON_X 0x00000008 -#define WPAD_PRO_BUTTON_A 0x00000010 -#define WPAD_PRO_BUTTON_Y 0x00000020 -#define WPAD_PRO_BUTTON_B 0x00000040 -#define WPAD_PRO_TRIGGER_ZL 0x00000080 -#define WPAD_PRO_RESERVED 0x00000100 -#define WPAD_PRO_TRIGGER_R 0x00000200 -#define WPAD_PRO_BUTTON_PLUS 0x00000400 -#define WPAD_PRO_BUTTON_HOME 0x00000800 -#define WPAD_PRO_BUTTON_MINUS 0x00001000 -#define WPAD_PRO_TRIGGER_L 0x00002000 -#define WPAD_PRO_BUTTON_DOWN 0x00004000 -#define WPAD_PRO_BUTTON_RIGHT 0x00008000 -#define WPAD_PRO_BUTTON_STICK_R 0x00010000 -#define WPAD_PRO_BUTTON_STICK_L 0x00020000 - -#define WPAD_PRO_STICK_L_EMULATION_UP 0x00200000 -#define WPAD_PRO_STICK_L_EMULATION_DOWN 0x00100000 -#define WPAD_PRO_STICK_L_EMULATION_LEFT 0x00040000 -#define WPAD_PRO_STICK_L_EMULATION_RIGHT 0x00080000 - -#define WPAD_PRO_STICK_R_EMULATION_UP 0x02000000 -#define WPAD_PRO_STICK_R_EMULATION_DOWN 0x01000000 -#define WPAD_PRO_STICK_R_EMULATION_LEFT 0x00400000 -#define WPAD_PRO_STICK_R_EMULATION_RIGHT 0x00800000 - -typedef struct _KPADData -{ - u32 btns_h; - u32 btns_d; - u32 btns_r; - u32 unused_1[5]; - f32 pos_x; - f32 pos_y; - u32 unused_2[3]; - f32 angle_x; - f32 angle_y; - u32 unused_3[8]; - u8 device_type; - u8 wpad_error; - u8 pos_valid; - u8 format; - - union - { - struct - { - f32 stick_x; - f32 stick_y; - } nunchuck; - - struct - { - u32 btns_h; - u32 btns_d; - u32 btns_r; - f32 lstick_x; - f32 lstick_y; - f32 rstick_x; - f32 rstick_y; - f32 ltrigger; - f32 rtrigger; - } classic; - - struct - { - u32 btns_h; - u32 btns_d; - u32 btns_r; - f32 lstick_x; - f32 lstick_y; - f32 rstick_x; - f32 rstick_y; - s32 charging; - s32 wired; - } pro; - - u32 unused_6[20]; - }; - u32 unused_7[16]; -} KPADData; - -typedef struct WPADReadData_ { - u8 unknown[40]; - u8 dev; - u8 err; - u8 unknown1[2]; - u32 buttons; - s16 l_stick_x; - s16 l_stick_y; - s16 r_stick_x; - s16 r_stick_y; - u8 unknown2[8]; - u8 fmt; -}WPADReadData; - -typedef WPADReadData KPADUnifiedWpadData; - -void InitPadScoreFunctionPointers(void); -void InitAcquirePadScore(void); - -typedef void (* wpad_sampling_callback_t)(s32 chan); -typedef void (* wpad_extension_callback_t)(s32 chan, s32 status); -typedef void (* wpad_connect_callback_t)(s32 chan, s32 status); - -extern void (* KPADInit)(void); -extern void (* WPADInit)(void); -extern s32 (* WPADProbe)(s32 chan, u32 * pad_type); -extern s32 (* WPADSetDataFormat)(s32 chan, s32 format); -extern void (* WPADEnableURCC)(s32 enable); -extern void (* WPADRead)(s32 chan, void * data); -extern s32 (* KPADRead)(s32 chan, void * data, u32 size); -extern s32 (* KPADReadEx)(s32 chan, KPADData * data, u32 size, s32 *error); -extern void (*WPADSetAutoSleepTime)(u8 time); -extern void (*WPADDisconnect)( s32 chan ); - -#ifdef __cplusplus -} -#endif - -#endif // __PAD_SCORE_FUNCTIONS_H_ diff --git a/src/dynamic_libs/socket_functions.c b/src/dynamic_libs/socket_functions.c deleted file mode 100644 index 06aa769..0000000 --- a/src/dynamic_libs/socket_functions.c +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "socket_functions.h" - -u32 hostIpAddress = 0; - -u32 nsysnet_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, socket_lib_init, void); -EXPORT_DECL(s32, socket, s32 domain, s32 type, s32 protocol); -EXPORT_DECL(s32, socketclose, s32 s); -EXPORT_DECL(s32, connect, s32 s, void *addr, s32 addrlen); -EXPORT_DECL(s32, bind, s32 s,struct sockaddr *name,s32 namelen); -EXPORT_DECL(s32, listen, s32 s,u32 backlog); -EXPORT_DECL(s32, accept, s32 s,struct sockaddr *addr,s32 *addrlen); -EXPORT_DECL(s32, send, s32 s, const void *buffer, s32 size, s32 flags); -EXPORT_DECL(s32, recv, s32 s, void *buffer, s32 size, s32 flags); -EXPORT_DECL(s32, recvfrom,s32 sockfd, void *buf, s32 len, s32 flags,struct sockaddr *src_addr, s32 *addrlen); -EXPORT_DECL(s32, sendto, s32 s, const void *buffer, s32 size, s32 flags, const struct sockaddr *dest, s32 dest_len); -EXPORT_DECL(s32, setsockopt, s32 s, s32 level, s32 optname, void *optval, s32 optlen); -EXPORT_DECL(char *, inet_ntoa, struct in_addr in); -EXPORT_DECL(s32, inet_aton, const char *cp, struct in_addr *inp); - -EXPORT_DECL(s32, NSSLWrite, s32 connection, const void* buf, s32 len,s32 * written); -EXPORT_DECL(s32, NSSLRead, s32 connection, const void* buf, s32 len,s32 * read); -EXPORT_DECL(s32, NSSLCreateConnection, s32 context, const char* host, s32 hotlen,s32 options,s32 sock,s32 block); - -void InitAcquireSocket(void) -{ - OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle); -} - -void InitSocketFunctionPointers(void) -{ - u32 *funcPointer = 0; - - InitAcquireSocket(); - - u32 nn_ac_handle; - s32(*ACInitialize)(); - s32(*ACGetStartupId) (u32 *id); - s32(*ACConnectWithConfigId) (u32 id); - s32(*ACGetAssignedAddress) (u32 * ip); - OSDynLoad_Acquire("nn_ac.rpl", &nn_ac_handle); - OSDynLoad_FindExport(nn_ac_handle, 0, "ACInitialize", &ACInitialize); - OSDynLoad_FindExport(nn_ac_handle, 0, "ACGetStartupId", &ACGetStartupId); - OSDynLoad_FindExport(nn_ac_handle, 0, "ACConnectWithConfigId",&ACConnectWithConfigId); - OSDynLoad_FindExport(nn_ac_handle, 0, "ACGetAssignedAddress",&ACGetAssignedAddress); - - OS_FIND_EXPORT(nsysnet_handle, socket_lib_init); - OS_FIND_EXPORT(nsysnet_handle, socket); - OS_FIND_EXPORT(nsysnet_handle, socketclose); - OS_FIND_EXPORT(nsysnet_handle, connect); - OS_FIND_EXPORT(nsysnet_handle, bind); - OS_FIND_EXPORT(nsysnet_handle, listen); - OS_FIND_EXPORT(nsysnet_handle, accept); - OS_FIND_EXPORT(nsysnet_handle, send); - OS_FIND_EXPORT(nsysnet_handle, recv); - OS_FIND_EXPORT(nsysnet_handle, recvfrom); - OS_FIND_EXPORT(nsysnet_handle, sendto); - OS_FIND_EXPORT(nsysnet_handle, setsockopt); - OS_FIND_EXPORT(nsysnet_handle, inet_ntoa); - OS_FIND_EXPORT(nsysnet_handle, inet_aton); - - OS_FIND_EXPORT(nsysnet_handle, NSSLWrite); - OS_FIND_EXPORT(nsysnet_handle, NSSLRead); - OS_FIND_EXPORT(nsysnet_handle, NSSLCreateConnection); - - u32 nn_startupid; - ACInitialize(); - ACGetStartupId(&nn_startupid); - ACConnectWithConfigId(nn_startupid); - ACGetAssignedAddress(&hostIpAddress); - - socket_lib_init(); -} diff --git a/src/dynamic_libs/socket_functions.h b/src/dynamic_libs/socket_functions.h deleted file mode 100644 index 0ab78f7..0000000 --- a/src/dynamic_libs/socket_functions.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __SOCKET_FUNCTIONS_H_ -#define __SOCKET_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -extern u32 nsysnet_handle; - -#include - -#define INADDR_ANY 0 - -#define AF_INET 2 - -#define SOCK_STREAM 1 -#define SOCK_DGRAM 2 - -#define IPPROTO_IP 0 -#define IPPROTO_TCP 6 -#define IPPROTO_UDP 17 - -#define TCP_NODELAY 0x2004 - -#define SOL_SOCKET -1 -#define SO_REUSEADDR 0x0004 -#define SO_NONBLOCK 0x1016 -#define SO_MYADDR 0x1013 -#define SO_RCVTIMEO 0x1006 - -#define SOL_SOCKET -1 -#define MSG_DONTWAIT 32 - -#define htonl(x) x -#define htons(x) x -#define ntohl(x) x -#define ntohs(x) x - - -struct in_addr { - u32 s_addr; -}; -struct sockaddr_in { - short sin_family; - unsigned short sin_port; - struct in_addr sin_addr; - char sin_zero[8]; -}; - -struct sockaddr -{ - unsigned short sa_family; - char sa_data[14]; -}; - - -void InitSocketFunctionPointers(void); -void InitAcquireSocket(void); - -extern void (*socket_lib_init)(void); -extern s32 (*socket)(s32 domain, s32 type, s32 protocol); -extern s32 (*socketclose)(s32 s); -extern s32 (*connect)(s32 s, void *addr, s32 addrlen); -extern s32 (*bind)(s32 s,struct sockaddr *name,s32 namelen); -extern s32 (*listen)(s32 s,u32 backlog); -extern s32 (*accept)(s32 s,struct sockaddr *addr,s32 *addrlen); -extern s32 (*send)(s32 s, const void *buffer, s32 size, s32 flags); -extern s32 (*recv)(s32 s, void *buffer, s32 size, s32 flags); -extern s32 (*recvfrom)(s32 sockfd, void *buf, s32 len, s32 flags,struct sockaddr *src_addr, s32 *addrlen); - -extern s32 (*sendto)(s32 s, const void *buffer, s32 size, s32 flags, const struct sockaddr *dest, s32 dest_len); -extern s32 (*setsockopt)(s32 s, s32 level, s32 optname, void *optval, s32 optlen); - -extern s32 (* NSSLWrite)(s32 connection, const void* buf, s32 len,s32 * written); -extern s32 (* NSSLRead)(s32 connection, const void* buf, s32 len,s32 * read); -extern s32 (* NSSLCreateConnection)(s32 context, const char* host, s32 hotlen,s32 options,s32 sock,s32 block); - -extern char * (*inet_ntoa)(struct in_addr in); -extern s32 (*inet_aton)(const char *cp, struct in_addr *inp); - -#ifdef __cplusplus -} -#endif - -#endif // __SOCKET_FUNCTIONS_H_ diff --git a/src/dynamic_libs/sys_functions.c b/src/dynamic_libs/sys_functions.c deleted file mode 100644 index 25720c5..0000000 --- a/src/dynamic_libs/sys_functions.c +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" - -u32 sysapp_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(s32, _SYSLaunchTitleByPathFromLauncher, const char* path, s32 len, s32 zero); -EXPORT_DECL(s32, SYSRelaunchTitle, s32 argc, char** argv); -EXPORT_DECL(s32, SYSLaunchMenu, void); -EXPORT_DECL(s32, SYSCheckTitleExists, u64 titleId); -EXPORT_DECL(s32, SYSLaunchTitle, u64 titleId); -EXPORT_DECL(s32, SYSLaunchSettings, s32 unk); - -void InitAcquireSys(void) -{ - OSDynLoad_Acquire("sysapp.rpl", &sysapp_handle); -} - -void InitSysFunctionPointers(void) -{ - u32 *funcPointer = 0; - InitAcquireSys(); - - OS_FIND_EXPORT(sysapp_handle, _SYSLaunchTitleByPathFromLauncher); - OS_FIND_EXPORT(sysapp_handle, SYSRelaunchTitle); - OS_FIND_EXPORT(sysapp_handle, SYSLaunchMenu); - OS_FIND_EXPORT(sysapp_handle, SYSCheckTitleExists); - OS_FIND_EXPORT(sysapp_handle, SYSLaunchTitle); - OS_FIND_EXPORT(sysapp_handle, SYSLaunchSettings); -} diff --git a/src/dynamic_libs/sys_functions.h b/src/dynamic_libs/sys_functions.h deleted file mode 100644 index 8c66e78..0000000 --- a/src/dynamic_libs/sys_functions.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __SYS_FUNCTIONS_H_ -#define __SYS_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern u32 sysapp_handle; - -void InitSysFunctionPointers(void); -void InitAcquireSys(void); - -extern int(*_SYSLaunchTitleByPathFromLauncher)(const char* path, s32 len, s32 zero); -extern int (* SYSRelaunchTitle)(s32 argc, char** argv); -extern int (* SYSLaunchMenu)(void); -extern int (* SYSCheckTitleExists)(u64 titleId); -extern int (* SYSLaunchTitle)(u64 titleId); -extern int (* SYSLaunchSettings)(s32 unk); - - -#ifdef __cplusplus -} -#endif - -#endif // __SYS_FUNCTIONS_H_ diff --git a/src/dynamic_libs/syshid_functions.c b/src/dynamic_libs/syshid_functions.c deleted file mode 100644 index b5dbca4..0000000 --- a/src/dynamic_libs/syshid_functions.c +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "syshid_functions.h" - -u32 syshid_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(s32, HIDSetup,void); -EXPORT_DECL(s32, HIDTeardown,void); - -EXPORT_DECL(s32, HIDAddClient,HIDClient *p_client, HIDAttachCallback attach_callback); -EXPORT_DECL(s32, HIDDelClient,HIDClient *p_client); - -EXPORT_DECL(s32, HIDGetDescriptor,u32 handle,u8 descriptor_type,u8 descriptor_index, u16 language_id, unsigned char *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); -EXPORT_DECL(s32, HIDSetDescriptor,u32 handle,u8 descriptor_type,u8 descriptor_index, u16 language_id, unsigned char *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); - -EXPORT_DECL(s32, HIDSetProtocol,u32 handle,u8 s32erface_index,u8 protocol, HIDCallback hc, void *p_user); -EXPORT_DECL(s32, HIDGetProtocol,u32 handle,u8 s32erface_index,u8 * protocol, HIDCallback hc, void *p_user); - -EXPORT_DECL(s32, HIDGetReport,u32 handle, u8 report_type, u8 report_id, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); -EXPORT_DECL(s32, HIDSetReport,u32 handle, u8 report_type, u8 report_id, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); - -EXPORT_DECL(s32, HIDSetIdle,u32 handle, u8 s32erface_index,u8 duration, HIDCallback hc, void *p_user); - -EXPORT_DECL(s32, HIDRead,u32 handle, unsigned char *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); -EXPORT_DECL(s32, HIDWrite,u32 handle, unsigned char *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); - -void InitAcquireSysHID(void) -{ - OSDynLoad_Acquire("nsyshid.rpl", &syshid_handle); -} - -void InitSysHIDFunctionPointers(void) -{ - InitAcquireSysHID(); - - if(syshid_handle == 0){ - return; - } - - u32 funcPointer = 0; - - //! assigning those is not mandatory and it does not always work to load them - OS_FIND_EXPORT(syshid_handle, HIDSetup); - OS_FIND_EXPORT(syshid_handle, HIDTeardown); - OS_FIND_EXPORT(syshid_handle, HIDAddClient); - OS_FIND_EXPORT(syshid_handle, HIDDelClient); - OS_FIND_EXPORT(syshid_handle, HIDGetDescriptor); - OS_FIND_EXPORT(syshid_handle, HIDSetDescriptor); - OS_FIND_EXPORT(syshid_handle, HIDRead); - OS_FIND_EXPORT(syshid_handle, HIDWrite); - OS_FIND_EXPORT(syshid_handle, HIDSetProtocol); - OS_FIND_EXPORT(syshid_handle, HIDGetProtocol); - OS_FIND_EXPORT(syshid_handle, HIDSetIdle); - OS_FIND_EXPORT(syshid_handle, HIDGetReport); - OS_FIND_EXPORT(syshid_handle, HIDSetReport); -} diff --git a/src/dynamic_libs/syshid_functions.h b/src/dynamic_libs/syshid_functions.h deleted file mode 100644 index 9e29133..0000000 --- a/src/dynamic_libs/syshid_functions.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __SYSHID_FUNCTIONS_H_ -#define __SYSHID_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern u32 syshid_handle; - -typedef struct -{ - u32 handle; - u32 physical_device_inst; - u16 vid; - u16 pid; - u8 interface_index; - u8 sub_class; - u8 protocol; - - u16 max_packet_size_rx; - u16 max_packet_size_tx; - -} HIDDevice; - -typedef struct _HIDClient HIDClient; - -#define HID_DEVICE_DETACH 0 -#define HID_DEVICE_ATTACH 1 - -typedef s32 (*HIDAttachCallback)(HIDClient *p_hc,HIDDevice *p_hd,u32 attach); - -struct _HIDClient -{ - HIDClient *next; - HIDAttachCallback attach_cb; -}; - -typedef void (*HIDCallback)(u32 handle,s32 error,u8 *p_buffer,u32 bytes_transferred,void *p_user); - -void InitSysHIDFunctionPointers(void); -void InitAcquireSysHID(void); - -extern s32(*HIDSetup)(void); -extern s32(*HIDTeardown)(void); - -extern s32(*HIDAddClient)(HIDClient *p_client, HIDAttachCallback attach_callback); -extern s32(*HIDDelClient)(HIDClient *p_client); - -extern s32(*HIDGetDescriptor)(u32 handle,u8 descriptor_type,u8 descriptor_index, u16 language_id, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); -extern s32(*HIDSetDescriptor)(u32 handle,u8 descriptor_type,u8 descriptor_index, u16 language_id, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); - -extern s32(*HIDGetReport)(u32 handle, u8 report_type, u8 report_id, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); -extern s32(*HIDSetReport)(u32 handle, u8 report_type, u8 report_id, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); - -extern s32(*HIDSetIdle)(u32 handle, u8 s32erface_index,u8 duration, HIDCallback hc, void *p_user); - -extern s32(* HIDSetProtocol)(u32 handle,u8 s32erface_index,u8 protocol, HIDCallback hc, void *p_user); -extern s32(* HIDGetProtocol)(u32 handle,u8 s32erface_index,u8 * protocol, HIDCallback hc, void *p_user); - -extern s32(*HIDRead)(u32 handle, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); -extern s32(*HIDWrite)(u32 handle, u8 *p_buffer, u32 buffer_length, HIDCallback hc, void *p_user); - -#ifdef __cplusplus -} -#endif - -#endif // __SYSHID_FUNCTIONS_H_ diff --git a/src/dynamic_libs/vpad_functions.c b/src/dynamic_libs/vpad_functions.c deleted file mode 100644 index 4af3b49..0000000 --- a/src/dynamic_libs/vpad_functions.c +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#include "os_functions.h" -#include "vpad_functions.h" - -u32 vpad_handle __attribute__((section(".data"))) = 0; -u32 vpadbase_handle __attribute__((section(".data"))) = 0; - -EXPORT_DECL(void, VPADInit, void); -EXPORT_DECL(s32, VPADRead, s32 chan, VPADData *buffer, u32 buffer_size, s32 *error); -EXPORT_DECL(s32, VPADGetLcdMode, s32 padnum, s32 *lcdmode); -EXPORT_DECL(s32, VPADSetLcdMode, s32 padnum, s32 lcdmode); -EXPORT_DECL(s32, VPADBASEGetMotorOnRemainingCount, s32 padnum); -EXPORT_DECL(s32, VPADBASESetMotorOnRemainingCount, s32 padnum, s32 counter); - -void InitAcquireVPad(void) -{ - OSDynLoad_Acquire("vpad.rpl", &vpad_handle); - OSDynLoad_Acquire("vpadbase.rpl", &vpadbase_handle); -} - -void InitVPadFunctionPointers(void) -{ - u32 *funcPointer = 0; - - InitAcquireVPad(); - - OS_FIND_EXPORT(vpad_handle, VPADInit); - OS_FIND_EXPORT(vpad_handle, VPADRead); - OS_FIND_EXPORT(vpad_handle, VPADGetLcdMode); - OS_FIND_EXPORT(vpad_handle, VPADSetLcdMode); - OS_FIND_EXPORT(vpadbase_handle, VPADBASEGetMotorOnRemainingCount); - OS_FIND_EXPORT(vpadbase_handle, VPADBASESetMotorOnRemainingCount); -} diff --git a/src/dynamic_libs/vpad_functions.h b/src/dynamic_libs/vpad_functions.h deleted file mode 100644 index 483ccbd..0000000 --- a/src/dynamic_libs/vpad_functions.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 - * by Dimok - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any - * damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any - * purpose, including commercial applications, and to alter it and - * redistribute it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you use - * this software in a product, an acknowledgment in the product - * documentation would be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and - * must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - ***************************************************************************/ -#ifndef __VPAD_FUNCTIONS_H_ -#define __VPAD_FUNCTIONS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -extern u32 vpad_handle; -extern u32 vpadbase_handle; - -#define VPAD_BUTTON_A 0x8000 -#define VPAD_BUTTON_B 0x4000 -#define VPAD_BUTTON_X 0x2000 -#define VPAD_BUTTON_Y 0x1000 -#define VPAD_BUTTON_LEFT 0x0800 -#define VPAD_BUTTON_RIGHT 0x0400 -#define VPAD_BUTTON_UP 0x0200 -#define VPAD_BUTTON_DOWN 0x0100 -#define VPAD_BUTTON_ZL 0x0080 -#define VPAD_BUTTON_ZR 0x0040 -#define VPAD_BUTTON_L 0x0020 -#define VPAD_BUTTON_R 0x0010 -#define VPAD_BUTTON_PLUS 0x0008 -#define VPAD_BUTTON_MINUS 0x0004 -#define VPAD_BUTTON_HOME 0x0002 -#define VPAD_BUTTON_SYNC 0x0001 -#define VPAD_BUTTON_STICK_R 0x00020000 -#define VPAD_BUTTON_STICK_L 0x00040000 -#define VPAD_BUTTON_TV 0x00010000 - -#define VPAD_STICK_R_EMULATION_LEFT 0x04000000 -#define VPAD_STICK_R_EMULATION_RIGHT 0x02000000 -#define VPAD_STICK_R_EMULATION_UP 0x01000000 -#define VPAD_STICK_R_EMULATION_DOWN 0x00800000 - -#define VPAD_STICK_L_EMULATION_LEFT 0x40000000 -#define VPAD_STICK_L_EMULATION_RIGHT 0x20000000 -#define VPAD_STICK_L_EMULATION_UP 0x10000000 -#define VPAD_STICK_L_EMULATION_DOWN 0x08000000 - -//! Own definitions -#define VPAD_BUTTON_TOUCH 0x00080000 -#define VPAD_MASK_EMULATED_STICKS 0x7F800000 -#define VPAD_MASK_BUTTONS ~VPAD_MASK_EMULATED_STICKS - -typedef struct -{ - f32 x,y; -} Vec2D; - -typedef struct -{ - f32 x,y,z; -} Vec3D; - -typedef struct -{ - u16 x, y; /* Touch coordinates */ - u16 touched; /* 1 = Touched, 0 = Not touched */ - u16 invalid; /* 0 = All valid, 1 = X invalid, 2 = Y invalid, 3 = Both invalid? */ -} VPADTPData; - -typedef struct -{ - u32 btns_h; /* Held buttons */ - u32 btns_d; /* Buttons that are pressed at that instant */ - u32 btns_r; /* Released buttons */ - Vec2D lstick, rstick; /* Each contains 4-byte X and Y components */ - char unknown1c[0x38 - 0x1c]; /* Contains accelerometer data somewhere */ - Vec3D gyro; /* Gyro data */ - Vec3D angle; /* Angle data */ - char unknown50[0x52 - 0x50]; /* Two bytes of unknown data */ - VPADTPData tpdata; /* Normal touchscreen data */ - VPADTPData tpdata1; /* Modified touchscreen data 1 */ - VPADTPData tpdata2; /* Modified touchscreen data 2 */ - char unknown6a[0xa0 - 0x6a]; - u8 volume; - u8 battery; /* 0 to 6 */ - u8 unk_volume; /* One less than volume */ - char unknowna4[0xac - 0xa4]; -} VPADData; - -void InitVPadFunctionPointers(void); -void InitAcquireVPad(void); - -extern s32 (* VPADRead)(s32 chan, VPADData *buffer, u32 buffer_size, s32 *error); -extern s32 (* VPADGetLcdMode)(s32 padnum, s32 *lcdmode); -extern s32 (* VPADSetLcdMode)(s32 padnum, s32 lcdmode); -extern void (* VPADInit)(void); -extern s32 (* VPADBASEGetMotorOnRemainingCount)(s32 lcdmode); -extern s32 (* VPADBASESetMotorOnRemainingCount)(s32 lcdmode,s32 counter); - -#ifdef __cplusplus -} -#endif - -#endif // __VPAD_FUNCTIONS_H_ diff --git a/src/entry.c b/src/entry.c index aad6777..ac27879 100644 --- a/src/entry.c +++ b/src/entry.c @@ -1,16 +1,32 @@ -#include -#include "dynamic_libs/os_functions.h" -#include "dynamic_libs/sys_functions.h" -#include "common/common.h" -#include "utils/utils.h" #include "main.h" -#include "lib_easy.h" #include "draw.h" +#include "wiiu.h" int __entry_menu(int argc, char **argv) { - uInit(); //Init all the wii u stuff - int ret=Menu_Main(); //Jump to our application - uDeInit(); + InitOSFunctionPointers(); + InitSocketFunctionPointers(); + InitACPFunctionPointers(); + InitAocFunctionPointers(); + InitAXFunctionPointers(); + InitCurlFunctionPointers(); + InitFSFunctionPointers(); + InitGX2FunctionPointers(); + InitPadScoreFunctionPointers(); + InitSysFunctionPointers(); + InitSysHIDFunctionPointers(); + InitVPadFunctionPointers(); + + memoryInitialize(); + VPADInit(); + KPADInit(); + WPADInit(); + drawInit(); + + int ret = Menu_Main(); + + drawFini(); + memoryRelease(); + return ret; } diff --git a/src/fs/fs_utils.c b/src/fs/fs_utils.c index a748029..613cec6 100644 --- a/src/fs/fs_utils.c +++ b/src/fs/fs_utils.c @@ -173,7 +173,7 @@ int CreateSubfolder(const char * fullpath) if(!result) return 0; - if (mkdir(dirnoslash, 0x777) == -1) + if (mkdir(dirnoslash, 0777) == -1) { return 0; } diff --git a/src/lib_easy.c b/src/lib_easy.c deleted file mode 100644 index 2760672..0000000 --- a/src/lib_easy.c +++ /dev/null @@ -1,97 +0,0 @@ -#include "lib_easy.h" - -// int vpadError = -1; -// VPADData vpad; - -int screen_buf0_size = 0; -int screen_buf1_size = 0; - -void ScreenInit() { - //Init screen and screen buffers - OSScreenInit(); - screen_buf0_size = OSScreenGetBufferSizeEx(0); - screen_buf1_size = OSScreenGetBufferSizeEx(1); - screenBuffer = MEM1_alloc(screen_buf0_size + screen_buf1_size, 0x100); - OSScreenSetBufferEx(0, screenBuffer); - OSScreenSetBufferEx(1, (screenBuffer + screen_buf0_size)); - OSScreenEnableEx(0, 1); - OSScreenEnableEx(1, 1); - clearBuffers(); //Clear screens - initDraw(screenBuffer, screen_buf0_size, screen_buf1_size); -} - -// void updatePressedButtons() { -// VPADRead(0, &vpad, 1, &vpadError); -// buttons_pressed = vpad.btns_d; -// } - -// void updateHeldButtons() { -// VPADRead(0, &vpad, 1, &vpadError); -// buttons_hold = vpad.btns_h; -// } - -// void updateReleasedButtons() { -// VPADRead(0, &vpad, 1, &vpadError); -// buttons_released = vpad.btns_r; -// } - -// bool stickPos(u8 stick, f32 value) { -// switch(stick) { -// case 0 : -// return (value > 0) ? (vpad.lstick.x > value): (vpad.lstick.x < value); -// case 1 : -// return (value > 0) ? (vpad.lstick.y > value): (vpad.lstick.y < value); -// case 2 : -// return (value > 0) ? (vpad.rstick.x > value): (vpad.rstick.x < value); -// case 3 : -// return (value > 0) ? (vpad.rstick.y > value): (vpad.rstick.y < value); -// case 4 : -// return ((vpad.lstick.x > value) || (vpad.lstick.x < -value)) || \ -// ((vpad.lstick.y > value) || (vpad.lstick.y < -value)) || \ -// ((vpad.rstick.x > value) || (vpad.rstick.x < -value)) || \ -// ((vpad.rstick.y > value) || (vpad.rstick.y < -value)); -// -// default : -// return 0; -// } -// } - -// int isPressed(int button) { -// return (buttons_pressed&button); -// } - -// int isHeld(int button) { -// return (buttons_hold&button); -// } - -// int isReleased(int button) { -// return (buttons_released&button); -// } - -void uInit() { - //--Initialize every function pointer-- (byebye FindExport :D) - InitOSFunctionPointers(); - InitSocketFunctionPointers(); - InitACPFunctionPointers(); - InitAocFunctionPointers(); - InitAXFunctionPointers(); - InitCurlFunctionPointers(); - InitFSFunctionPointers(); - InitGX2FunctionPointers(); - InitPadScoreFunctionPointers(); - InitSysFunctionPointers(); - InitSysHIDFunctionPointers(); - InitVPadFunctionPointers(); - - memoryInitialize(); //You probably shouldn't care about this for now :P - VPADInit(); //Init GamePad input library (needed for getting gamepad input) - KPADInit(); //Init controller input library for other wireless inputs - WPADInit(); - ScreenInit(); //Init OSScreen (all the complex stuff is in easyfunctions.h :P ) -} - -void uDeInit() { - MEM1_free(screenBuffer); - screenBuffer = NULL; - memoryRelease(); -} diff --git a/src/lib_easy.h b/src/lib_easy.h deleted file mode 100644 index fdb2eba..0000000 --- a/src/lib_easy.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * lib_easy.h - * - * Provides an easy-to-use library for wii u - * usefull for test and beginners - * - * All the "complex" Wii U stuff is here - * -*/ - -#ifndef LIB_EASY_H -#define LIB_EASY_H - -#include -#include -#include -#include -#include - -#include "dynamic_libs/ax_functions.h" -#include "dynamic_libs/sys_functions.h" -#include "dynamic_libs/socket_functions.h" -#include "dynamic_libs/fs_functions.h" -#include "dynamic_libs/aoc_functions.h" -#include "dynamic_libs/syshid_functions.h" -#include "dynamic_libs/padscore_functions.h" -#include "dynamic_libs/fs_defs.h" -#include "dynamic_libs/vpad_functions.h" -#include "dynamic_libs/gx2_types.h" -#include "dynamic_libs/curl_functions.h" -#include "dynamic_libs/os_functions.h" -#include "dynamic_libs/gx2_functions.h" -#include "dynamic_libs/acp_functions.h" -#include "fs/fs_utils.h" -#include "fs/sd_fat_devoptab.h" -#include "system/memory.h" -#include "utils/logger.h" -#include "utils/utils.h" -#include "common/common.h" - -unsigned char *screenBuffer; -//uint32_t buttons_hold; //Held buttons -//uint32_t buttons_pressed; //Pressed buttons -//uint32_t buttons_released; //Released buttons - -void ScreenInit(); -// void updatePressedButtons(); -// void updateHeldButtons(); -// void updateReleasedButtons(); -// bool stickPos(u8 stick, f32 value); -// int isPressed(int button); -// int isHeld(int button); -// int isReleased(int button); -void uInit(); -void uDeInit(); - -#endif /* LIB_EASY_H */ diff --git a/src/main.c b/src/main.c index b8d3306..9e8b752 100644 --- a/src/main.c +++ b/src/main.c @@ -10,7 +10,6 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_MICRO 0 -#define VERSION_MOD "mod5" #define M_OFF 3 u8 slot = 0; @@ -74,6 +73,8 @@ int titleSort(const void *c1, const void *c2) return 1 * sorta; return strcmp(((Title*)c1)->shortName,((Title*)c2)->shortName) * sorta; + } else { + return 0; } } @@ -113,16 +114,16 @@ Title* loadWiiUTitles(int run, int fsaFd) { } savesl = realloc(savesl, usable * sizeof(Saves)); - int dirUH, dirNH, foundCount = 0, pos = 0, tNoSave = usable; + int dirUH, foundCount = 0, pos = 0, tNoSave = usable; for (int i = 0; i <= 1; i++) { char path[255]; sprintf(path, "/vol/storage_%s01/usr/save/00050000", (i == 0) ? "usb" : "mlc"); if (IOSUHAX_FSA_OpenDir(fsaFd, path, &dirUH) >= 0) { while (1) { directoryEntry_s data; - int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirUH, &data); - if (ret != 0) - break; + int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirUH, &data); + if (ret != 0) + break; sprintf(path, "/vol/storage_%s01/usr/save/00050000/%s/user", (i == 0) ? "usb" : "mlc", data.name); if (checkEntry(path) == 2) { @@ -156,9 +157,9 @@ Title* loadWiiUTitles(int run, int fsaFd) { if (IOSUHAX_FSA_OpenDir(fsaFd, path, &dirUH) >= 0) { while (1) { directoryEntry_s data; - int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirUH, &data); - if (ret != 0) - break; + int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirUH, &data); + if (ret != 0) + break; sprintf(path, "/vol/storage_%s01/usr/save/00050000/%s/meta/meta.xml", (i == 0) ? "usb" : "mlc", data.name); if (checkEntry(path) == 1) { @@ -190,20 +191,20 @@ Title* loadWiiUTitles(int run, int fsaFd) { } for (int i = 0; i < foundCount; i++) { - int srcFd = -1; u32 highID = saves[i].highID, lowID = saves[i].lowID; bool isTitleOnUSB = !saves[i].dev; char path[255]; memset(path, 0, 255); - if (saves[i].found) + if (saves[i].found) { sprintf(path, "/vol/storage_%s01/usr/title/%08x/%08x/meta/meta.xml", isTitleOnUSB ? "usb" : "mlc", highID, lowID); - else + } else { sprintf(path, "/vol/storage_%s01/usr/save/%08x/%08x/meta/meta.xml", isTitleOnUSB ? "usb" : "mlc", highID, lowID); + } titles[titleswiiu].saveInit = !saves[i].found; char* xmlBuf = NULL; - if (loadFile(path, &xmlBuf) > 0) { + if (loadFile(path, (u8**)&xmlBuf) > 0) { char *cptr = strchr(strstr(xmlBuf, "product_code"), '>') + 7; memset(titles[titleswiiu].productCode, 0, sizeof(titles[titleswiiu].productCode)); strncpy(titles[titleswiiu].productCode, cptr, strcspn(cptr, "<")); @@ -223,15 +224,15 @@ Title* loadWiiUTitles(int run, int fsaFd) { free(xmlBuf); } - titles[titleswiiu].isTitleDupe = false; - for (int i = 0; i < titleswiiu; i++) { - if ((titles[i].highID == highID) && (titles[i].lowID == lowID)) { - titles[titleswiiu].isTitleDupe = true; - titles[titleswiiu].dupeID = i; - titles[i].isTitleDupe = true; - titles[i].dupeID = titleswiiu; - } - } + titles[titleswiiu].isTitleDupe = false; + for (int i = 0; i < titleswiiu; i++) { + if ((titles[i].highID == highID) && (titles[i].lowID == lowID)) { + titles[titleswiiu].isTitleDupe = true; + titles[titleswiiu].dupeID = i; + titles[i].isTitleDupe = true; + titles[i].dupeID = titleswiiu; + } + } titles[titleswiiu].highID = highID; titles[titleswiiu].lowID = lowID; @@ -257,12 +258,14 @@ Title* loadWiiUTitles(int run, int fsaFd) { Title* loadWiiTitles(int fsaFd) { int dirH; - char* highIDs[3] = {"00010000", "00010001", "00010004"}; + const char* highIDs[3] = {"00010000", "00010001", "00010004"}; bool found = false; - u32* blacklist[7][2] = {{0x00010000, 0x00555044}, {0x00010000, 0x00555045}, \ - {0x00010000, 0x0055504A}, {0x00010000, 0x524F4E45}, \ - {0x00010000, 0x52543445}, {0x00010001, 0x48424344}, - {0x00010001, 0x554E454F}}; + static const u32 blacklist[7][2] = { + {0x00010000, 0x00555044}, {0x00010000, 0x00555045}, + {0x00010000, 0x0055504A}, {0x00010000, 0x524F4E45}, + {0x00010000, 0x52543445}, {0x00010001, 0x48424344}, + {0x00010001, 0x554E454F} + }; char pathW[256]; for (int k = 0; k < 3; k++) { @@ -270,8 +273,8 @@ Title* loadWiiTitles(int fsaFd) { if (IOSUHAX_FSA_OpenDir(fsaFd, pathW, &dirH) >= 0) { while (1) { directoryEntry_s data; - int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirH, &data); - if (ret != 0) break; + int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirH, &data); + if (ret != 0) break; for (int ii = 0; ii < 7; ii++) { if (blacklist[ii][0] == strtoul(highIDs[k], NULL, 16)) { if (blacklist[ii][1] == strtoul(data.name, NULL, 16)) {found = true; break;} @@ -296,8 +299,8 @@ Title* loadWiiTitles(int fsaFd) { if (IOSUHAX_FSA_OpenDir(fsaFd, pathW, &dirH) >= 0) { while (1) { directoryEntry_s data; - int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirH, &data); - if (ret != 0) break; + int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirH, &data); + if (ret != 0) break; for (int ii = 0; ii < 7; ii++) { if (blacklist[ii][0] == strtoul(highIDs[k], NULL, 16)) { if (blacklist[ii][1] == strtoul(data.name, NULL, 16)) {found = true; break;} @@ -429,8 +432,11 @@ int Menu_Main(void) { if (fsaFd < 0) { promptError("IOSUHAX_FSA_Open failed."); //unmount_sd_fat("sd"); - if (mcp_hook_fd >= 0) MCPHookClose(); - else IOSUHAX_Close(); + if (mcp_hook_fd >= 0) { + MCPHookClose(); + } else { + IOSUHAX_Close(); + } return EXIT_SUCCESS; } setFSAFD(fsaFd); @@ -443,10 +449,12 @@ int Menu_Main(void) { mount_fs("storage_odd", fsaFd, "/dev/odd03", "/vol/storage_odd_content"); u8* fontBuf = NULL; - s32 fsize = loadFile("/vol/storage_sdcard/wiiu/apps/savemii_mod/font.ttf", &fontBuf); + s32 fsize = loadFile("/vol/storage_sdcard/wiiu/apps/savemii/font.ttf", &fontBuf); if (fsize > 0) { initFont(fontBuf, fsize); - } else initFont(NULL, 0); + } else { + initFont(NULL, 0); + } disclaimer(); clearBuffers(); @@ -464,16 +472,16 @@ int Menu_Main(void) { u8* fileContent = NULL; u32 wDRC = 0, hDRC = 0, wTV = 0, hTV = 0; - if (loadFile("/vol/storage_sdcard/wiiu/apps/savemii_mod/backgroundDRC.tga", &fileContent) > 0) { + if (loadFile("/vol/storage_sdcard/wiiu/apps/savemii/backgroundDRC.tga", &fileContent) > 0) { wDRC = tgaGetWidth(fileContent); hDRC = tgaGetHeight(fileContent); - tgaBufDRC = tgaRead(fileContent, TGA_READER_RGBA); + tgaBufDRC = (u8*)tgaRead(fileContent, TGA_READER_RGBA); free(fileContent); fileContent = NULL; } - if (loadFile("/vol/storage_sdcard/wiiu/apps/savemii_mod/backgroundTV.tga", &fileContent) > 0) { + if (loadFile("/vol/storage_sdcard/wiiu/apps/savemii/backgroundTV.tga", &fileContent) > 0) { wTV = tgaGetWidth(fileContent); hTV = tgaGetHeight(fileContent); - tgaBufTV = tgaRead(fileContent, TGA_READER_RGBA); + tgaBufTV = (u8*)tgaRead(fileContent, TGA_READER_RGBA); free(fileContent); fileContent = NULL; } @@ -492,7 +500,7 @@ int Menu_Main(void) { OSScreenClearBufferEx(0, 0x00006F00); } - console_print_pos(0, 0, "SaveMii v%u.%u.%u.%s", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO, VERSION_MOD); + console_print_pos(0, 0, "SaveMii v%u.%u.%u", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO); console_print_pos(0, 1, "----------------------------------------------------------------------------"); Title* titles = mode ? wiititles : wiiutitles; @@ -552,9 +560,9 @@ int Menu_Main(void) { if (mode == 0) { console_print_pos(M_OFF, 8, " Import from loadiine"); console_print_pos(M_OFF, 9, " Export to loadiine"); - if (titles[targ].isTitleDupe) { - console_print_pos(M_OFF, 10, " Copy Savedata to Title in %s", titles[targ].isTitleOnUSB ? "NAND" : "USB"); - } + if (titles[targ].isTitleDupe) { + console_print_pos(M_OFF, 10, " Copy Savedata to Title in %s", titles[targ].isTitleOnUSB ? "NAND" : "USB"); + } if (titles[targ].iconBuf) drawTGA(660, 80, 1, titles[targ].iconBuf); } else if (mode == 1) { if (titles[targ].iconBuf) drawRGB5A3(650, 80, 1, titles[targ].iconBuf); @@ -566,7 +574,7 @@ int Menu_Main(void) { entrycount = 3; console_print_pos(M_OFF, 2, "[%08X-%08X] %s", titles[targ].highID, titles[targ].lowID, titles[targ].shortName); - if (task == 5) { + if (task == 5) { console_print_pos(M_OFF, 4, "Destination:"); console_print_pos(M_OFF, 5, " (%s)", titles[targ].isTitleOnUSB ? "NAND" : "USB"); } else if (task > 2) { @@ -799,8 +807,7 @@ int Menu_Main(void) { tsort = (tsort + 1) % 4; qsort(titles, count, sizeof(Title), titleSort); } else if (menu == 2) { - - targ = ++targ % count; + targ = (targ + 1) % count; } } diff --git a/src/savemng.c b/src/savemng.c index b329132..8469dfd 100644 --- a/src/savemng.c +++ b/src/savemng.c @@ -1,3 +1,4 @@ +#include "common/fs_defs.h" #include "savemng.h" #define BUFFER_SIZE 0x8020 @@ -22,7 +23,7 @@ void replace_str(char *str, char *orig, char *rep, int start, char *out) { strcpy(temp, str + start); if (!(p = strstr(temp, orig))) // Is 'orig' even in 'temp'? - return temp; + return; strncpy(buffer, temp, p-temp); // Copy characters from 'temp' start to 'orig' str buffer[p-temp] = '\0'; @@ -31,27 +32,27 @@ void replace_str(char *str, char *orig, char *rep, int start, char *out) { sprintf(out, "%s", buffer); } -void show_file_operation(char* file_name, char* file_src, char* file_dest) { - char* dev_s[10], dev_d[10]; +void show_file_operation(const char* file_name, const char* file_src, const char* file_dest) { + char dev_s[100], dev_d[100]; if (strncmp(strchr(file_src, '_'), "_usb", 4) == 0) { - sprintf(dev_s, " (USB)"); + strcpy(dev_s, " (USB)"); } else if (strncmp(strchr(file_src, '_'), "_mlc", 4) == 0) { - sprintf(dev_s, " (NAND WiiU)"); + strcpy(dev_s, " (NAND WiiU)"); } else if (strncmp(strchr(file_src, '_'), "_slccmpt", 8) == 0) { - sprintf(dev_s, " (NAND vWii)"); + strcpy(dev_s, " (NAND vWii)"); } else if (strncmp(strchr(file_src, '_'), "_sdcard", 7) == 0) { - sprintf(dev_s, " (SD)"); + strcpy(dev_s, " (SD)"); } if (strncmp(strchr(file_dest, '_'), "_usb", 4) == 0) { - sprintf(dev_d, " (USB)"); + strcpy(dev_d, " (USB)"); } else if (strncmp(strchr(file_dest, '_'), "_mlc", 4) == 0) { - sprintf(dev_d, " (NAND WiiU)"); + strcpy(dev_d, " (NAND WiiU)"); } else if (strncmp(strchr(file_dest, '_'), "_slccmpt", 8) == 0) { - sprintf(dev_d, " (NAND vWii)"); + strcpy(dev_d, " (NAND vWii)"); } else if (strncmp(strchr(file_dest, '_'), "_sdcard", 7) == 0) { - sprintf(dev_d, " (SD)"); + strcpy(dev_d, " (SD)"); } console_print_pos(-2, 0, "Copying file: %s", file_name); @@ -107,10 +108,10 @@ s32 loadFilePart(const char * fPath, u32 start, u32 size, u8 **buf) { } s32 loadTitleIcon(Title* title) { - u32 highID = title->highID, lowID = title->lowID; - bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); - char path[255]; - memset(path, 0, 255); + u32 highID = title->highID, lowID = title->lowID; + bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); + char path[256]; + memset(path, 0, sizeof(path)); if (isWii) { if (title->saveInit) { @@ -153,34 +154,34 @@ int folderEmpty(const char * fPath) { } int createFolder(const char * fPath) { //Adapted from mkdir_p made by JonathonReinhart - const size_t len = strlen(fPath); - char _path[FS_MAX_FULLPATH_SIZE]; - char *p; + const size_t len = strlen(fPath); + char _path[FS_MAX_FULLPATH_SIZE]; + char *p; int ret, found = 0; - if (len > sizeof(_path)-1) { - return -1; - } - strcpy(_path, fPath); + if (len > sizeof(_path)-1) { + return -1; + } + strcpy(_path, fPath); - for (p = _path + 1; *p; p++) { - if (*p == '/') { + for (p = _path + 1; *p; p++) { + if (*p == '/') { found++; if (found > 2) { - *p = '\0'; + *p = '\0'; if (checkEntry(_path) == 0) { if ((ret = FSAR(IOSUHAX_FSA_MakeDir(fsaFd, _path, 0x666))) < 0) return -1; } - *p = '/'; + *p = '/'; } - } - } - - if (checkEntry(_path) == 0) { - if ((ret = FSAR(IOSUHAX_FSA_MakeDir(fsaFd, _path, 0x666))) < 0) return -1; + } } - return 0; + if (checkEntry(_path) == 0) { + if ((ret = FSAR(IOSUHAX_FSA_MakeDir(fsaFd, _path, 0x666))) < 0) return -1; + } + + return 0; } void console_print_pos_aligned(int y, u16 offset, u8 align, const char* format, ...) { @@ -209,8 +210,8 @@ void console_print_pos(int x, int y, const char* format, ...) { // Source: ftpii va_start(va, format); if ((vasprintf(&tmp, format, va) >= 0) && tmp) { ttfPrintString((x + 4) * 12, (y + 1) * 24, tmp, false, true); - //OSScreenPutFontEx(0, x, y, tmp); - //OSScreenPutFontEx(1, x, y, tmp); + //OSScreenPutFontEx(0, x, y, tmp); + //OSScreenPutFontEx(1, x, y, tmp); } va_end(va); if (tmp) free(tmp); @@ -218,13 +219,13 @@ void console_print_pos(int x, int y, const char* format, ...) { // Source: ftpii void console_print_pos_multiline(int x, int y, char cdiv, const char* format, ...) { // Source: ftpiiu char* tmp = NULL; - u32 len = (66 - x); + int len = (66 - x); va_list va; va_start(va, format); if ((vasprintf(&tmp, format, va) >= 0) && tmp) { - if ((ttfStringWidth(tmp, -1) / 12) > len) { + if ((ttfStringWidth(tmp, -1) / 12) > len) { char* p = tmp; if (strrchr(p, '\n') != NULL) p = strrchr(p, '\n') + 1; while((ttfStringWidth(p, -1) / 12) > len) { @@ -242,8 +243,8 @@ void console_print_pos_multiline(int x, int y, char cdiv, const char* format, .. q[l1] = o; l1--; } - char* buf[255]; - memset(buf, 0, 255); + char buf[256]; + memset(buf, 0, sizeof(buf)); strcpy(buf, p); sprintf(p, "\n%s", buf); p++; @@ -251,8 +252,8 @@ void console_print_pos_multiline(int x, int y, char cdiv, const char* format, .. } } ttfPrintString((x + 4) * 12, (y + 1) * 24, tmp, true, true); - //OSScreenPutFontEx(0, x, y, tmp); - //OSScreenPutFontEx(1, x, y, tmp); + //OSScreenPutFontEx(0, x, y, tmp); + //OSScreenPutFontEx(1, x, y, tmp); } va_end(va); if (tmp) free(tmp); @@ -263,14 +264,14 @@ void console_print_pos_va(int x, int y, const char* format, va_list va) { // Sou if ((vasprintf(&tmp, format, va) >= 0) && tmp) { ttfPrintString((x + 4) * 12, (y + 1) * 24, tmp, false, true); - //OSScreenPutFontEx(0, x, y, tmp); - //OSScreenPutFontEx(1, x, y, tmp); + //OSScreenPutFontEx(0, x, y, tmp); + //OSScreenPutFontEx(1, x, y, tmp); } if (tmp) free(tmp); } bool promptConfirm(Style st, const char* question) { - clearBuffers(); + clearBuffers(); const char* msg1 = "\ue000 Yes - \ue001 No"; const char* msg2 = "\ue000 Confirm - \ue001 Cancel"; const char* msg; @@ -281,79 +282,79 @@ bool promptConfirm(Style st, const char* question) { } if (st & ST_WARNING) { OSScreenClearBufferEx(0, 0x7F7F0000); - OSScreenClearBufferEx(1, 0x7F7F0000); + OSScreenClearBufferEx(1, 0x7F7F0000); } else if (st & ST_ERROR) { OSScreenClearBufferEx(0, 0x7F000000); - OSScreenClearBufferEx(1, 0x7F000000); + OSScreenClearBufferEx(1, 0x7F000000); } else { OSScreenClearBufferEx(0, 0x007F0000); - OSScreenClearBufferEx(1, 0x007F0000); + OSScreenClearBufferEx(1, 0x007F0000); } if (st & ST_MULTILINE) { } else { - console_print_pos(31 - (ttfStringWidth(question, 0) / 24), 7, question); - console_print_pos(31 - (ttfStringWidth(msg, -1) / 24), 9, msg); + console_print_pos(31 - (ttfStringWidth(question, 0) / 24), 7, question); + console_print_pos(31 - (ttfStringWidth(msg, -1) / 24), 9, msg); } - flipBuffers(); + flipBuffers(); int ret = 0; while(1) { - updateButtons(); - if (checkButton(PAD_BUTTON_ANY, PRESS)) { - ret = checkButton(PAD_BUTTON_A, PRESS); - break; - } - } - return ret; + updateButtons(); + if (checkButton(PAD_BUTTON_ANY, PRESS)) { + ret = checkButton(PAD_BUTTON_A, PRESS); + break; + } + } + return ret; } void promptError(const char* message, ...) { - clearBuffers(); + clearBuffers(); va_list va; va_start(va, message); - OSScreenClearBufferEx(0, 0x7F000000); - OSScreenClearBufferEx(1, 0x7F000000); + OSScreenClearBufferEx(0, 0x7F000000); + OSScreenClearBufferEx(1, 0x7F000000); char* tmp = NULL; if ((vasprintf(&tmp, message, va) >= 0) && tmp) { //int x = 31 - (strlen(tmp)>>1), y = 9; int x = 31 - (ttfStringWidth(tmp, -2) / 24), y = 8; - x = (x < -4 ? -4 : x); + x = (x < -4 ? -4 : x); ttfPrintString((x + 4) * 12, (y + 1) * 24, tmp, true, false); - //OSScreenPutFontEx(0, x, y, tmp); - //OSScreenPutFontEx(1, x, y, tmp); + //OSScreenPutFontEx(0, x, y, tmp); + //OSScreenPutFontEx(1, x, y, tmp); } if (tmp) free(tmp); - flipBuffers(); + flipBuffers(); va_end(va); while(1) { - updateButtons(); - if (checkButton(PAD_BUTTON_ANY, PRESS)) break; - } + updateButtons(); + if (checkButton(PAD_BUTTON_ANY, PRESS)) break; + } } void getAccountsWiiU() { - /* get persistent ID - thanks to Maschell */ - unsigned int nn_act_handle; - u32 (*GetPersistentIdEx)(unsigned char); + /* get persistent ID - thanks to Maschell */ + unsigned int nn_act_handle; + u32 (*GetPersistentIdEx)(unsigned char); bool (*IsSlotOccupied)(unsigned char); - int (*GetSlotNo)(void); + int (*GetSlotNo)(void); int (*GetNumOfAccounts)(void); int (*GetMiiNameEx)(uint16_t*, unsigned char); - void (*nn_Initialize)(void); - void (*nn_Finalize)(void); - OSDynLoad_Acquire("nn_act.rpl", &nn_act_handle); - OSDynLoad_FindExport(nn_act_handle, 0, "GetPersistentIdEx__Q2_2nn3actFUc", &GetPersistentIdEx); + void (*nn_Initialize)(void); + void (*nn_Finalize)(void); + OSDynLoad_Acquire("nn_act.rpl", &nn_act_handle); + OSDynLoad_FindExport(nn_act_handle, 0, "GetPersistentIdEx__Q2_2nn3actFUc", &GetPersistentIdEx); OSDynLoad_FindExport(nn_act_handle, 0, "IsSlotOccupied__Q2_2nn3actFUc", &IsSlotOccupied); - OSDynLoad_FindExport(nn_act_handle, 0, "GetSlotNo__Q2_2nn3actFv", &GetSlotNo); + OSDynLoad_FindExport(nn_act_handle, 0, "GetSlotNo__Q2_2nn3actFv", &GetSlotNo); OSDynLoad_FindExport(nn_act_handle, 0, "GetNumOfAccounts__Q2_2nn3actFv", &GetNumOfAccounts); OSDynLoad_FindExport(nn_act_handle, 0, "GetMiiNameEx__Q2_2nn3actFPwUc", &GetMiiNameEx); - OSDynLoad_FindExport(nn_act_handle, 0, "Initialize__Q2_2nn3actFv", &nn_Initialize); - OSDynLoad_FindExport(nn_act_handle, 0, "Finalize__Q2_2nn3actFv", &nn_Finalize); + OSDynLoad_FindExport(nn_act_handle, 0, "Initialize__Q2_2nn3actFv", &nn_Initialize); + OSDynLoad_FindExport(nn_act_handle, 0, "Finalize__Q2_2nn3actFv", &nn_Finalize); - nn_Initialize(); // To be sure that it is really Initialized + nn_Initialize(); // To be sure that it is really Initialized int i = 0, accn = 0; wiiuaccn = GetNumOfAccounts(); @@ -387,12 +388,13 @@ void getAccountsWiiU() { } i++; } - nn_Finalize(); //must be called an equal number of times to nn_Initialize + nn_Finalize(); //must be called an equal number of times to nn_Initialize } void getAccountsSD(Title* title, u8 slot) { u32 highID = title->highID, lowID = title->lowID; - bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); + //bool isUSB = title->isTitleOnUSB; + //bool isWii = ((highID & 0xFFFFFFF0) == 0x00010000); int dirH; sdaccn = 0; if (sdacc) free(sdacc); @@ -431,13 +433,13 @@ int DumpFile(char* pPath, const char* oPath) { int srcFd = -1, destFd = -1; int ret = 0; int buf_size = BUFFER_SIZE; - uint8_t * pBuffer; + uint8_t * pBuffer; do{ buf_size -= BUFFER_SIZE_STEPS; if (buf_size < 0) { promptError("Error allocating Buffer."); - return; + return -1; } pBuffer = (uint8_t *)memalign(0x40, buf_size); if (pBuffer) memset(pBuffer, 0x00, buf_size); @@ -451,7 +453,7 @@ int DumpFile(char* pPath, const char* oPath) { int result, sizew = 0, sizef = fStat.size; int fwrite = 0; u32 passedMs = 1; - u64 startTime = OSGetTime(); + u64 startTime = OSGetTime(); while ((result = IOSUHAX_FSA_ReadFile(fsaFd, pBuffer, 0x01, buf_size, srcFd, 0)) > 0) { if ((fwrite = IOSUHAX_FSA_WriteFile(fsaFd, pBuffer, 0x01, result, destFd, 0)) < 0) { @@ -463,11 +465,11 @@ int DumpFile(char* pPath, const char* oPath) { } sizew += fwrite; passedMs = (OSGetTime() - startTime) * 4000ULL / BUS_SPEED; - if(passedMs == 0) - passedMs = 1; + if(passedMs == 0) + passedMs = 1; OSScreenClearBufferEx(0, 0); - OSScreenClearBufferEx(1, 0); + OSScreenClearBufferEx(1, 0); show_file_operation(p1, pPath, oPath); console_print_pos(-2, 15, "Bytes Copied: %d of %d (%i kB/s)", sizew, sizef, (u32)(((u64)sizew * 1000) / ((u64)1024 * passedMs))); flipBuffers(); @@ -491,60 +493,60 @@ int DumpFile(char* pPath, const char* oPath) { } int DumpDir(char* pPath, const char* tPath) { // Source: ft2sd - int dirH; + int dirH; if (IOSUHAX_FSA_OpenDir(fsaFd, pPath, &dirH) < 0) return -1; IOSUHAX_FSA_MakeDir(fsaFd, tPath, 0x666); - while (1) { + while (1) { directoryEntry_s data; int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirH, &data); if (ret != 0) break; - OSScreenClearBufferEx(0, 0); - OSScreenClearBufferEx(1, 0); + OSScreenClearBufferEx(0, 0); + OSScreenClearBufferEx(1, 0); - if (strcmp(data.name, "..") == 0 || strcmp(data.name, ".") == 0) continue; + if (strcmp(data.name, "..") == 0 || strcmp(data.name, ".") == 0) continue; - int len = strlen(pPath); - snprintf(pPath + len, FS_MAX_FULLPATH_SIZE - len, "/%s", data.name); + int len = strlen(pPath); + snprintf(pPath + len, FS_MAX_FULLPATH_SIZE - len, "/%s", data.name); - if (data.stat.flag & DIR_ENTRY_IS_DIRECTORY) { - char* targetPath = (char*)malloc(FS_MAX_FULLPATH_SIZE); - snprintf(targetPath, FS_MAX_FULLPATH_SIZE, "%s/%s", tPath, data.name); + if (data.stat.flag & DIR_ENTRY_IS_DIRECTORY) { + char* targetPath = (char*)malloc(FS_MAX_FULLPATH_SIZE); + snprintf(targetPath, FS_MAX_FULLPATH_SIZE, "%s/%s", tPath, data.name); - IOSUHAX_FSA_MakeDir(fsaFd, targetPath, 0x666); - if (DumpDir(pPath, targetPath) != 0) { - IOSUHAX_FSA_CloseDir(fsaFd, dirH); - return -2; - } + IOSUHAX_FSA_MakeDir(fsaFd, targetPath, 0x666); + if (DumpDir(pPath, targetPath) != 0) { + IOSUHAX_FSA_CloseDir(fsaFd, dirH); + return -2; + } - free(targetPath); - } else { - char* targetPath = (char*)malloc(FS_MAX_FULLPATH_SIZE); - snprintf(targetPath, FS_MAX_FULLPATH_SIZE, "%s/%s", tPath, data.name); + free(targetPath); + } else { + char* targetPath = (char*)malloc(FS_MAX_FULLPATH_SIZE); + snprintf(targetPath, FS_MAX_FULLPATH_SIZE, "%s/%s", tPath, data.name); p1 = data.name; ttfFontSize(0, 20); show_file_operation(data.name, pPath, targetPath); - if (DumpFile(pPath, targetPath) != 0) { + if (DumpFile(pPath, targetPath) != 0) { ttfFontSize(0, 22); - IOSUHAX_FSA_CloseDir(fsaFd, dirH); - return -3; - } + IOSUHAX_FSA_CloseDir(fsaFd, dirH); + return -3; + } ttfFontSize(0, 22); - free(targetPath); - } + free(targetPath); + } - pPath[len] = 0; - } + pPath[len] = 0; + } - IOSUHAX_FSA_CloseDir(fsaFd, dirH); + IOSUHAX_FSA_CloseDir(fsaFd, dirH); - return 0; + return 0; } int DeleteDir(char* pPath) { @@ -558,59 +560,59 @@ int DeleteDir(char* pPath) { if (ret != 0) break; - OSScreenClearBufferEx(0, 0); - OSScreenClearBufferEx(1, 0); + OSScreenClearBufferEx(0, 0); + OSScreenClearBufferEx(1, 0); - if (strcmp(data.name, "..") == 0 || strcmp(data.name, ".") == 0) continue; + if (strcmp(data.name, "..") == 0 || strcmp(data.name, ".") == 0) continue; - int len = strlen(pPath); - snprintf(pPath + len, FS_MAX_FULLPATH_SIZE - len, "/%s", data.name); + int len = strlen(pPath); + snprintf(pPath + len, FS_MAX_FULLPATH_SIZE - len, "/%s", data.name); - if (data.stat.flag & DIR_ENTRY_IS_DIRECTORY) { + if (data.stat.flag & DIR_ENTRY_IS_DIRECTORY) { char origPath[PATH_SIZE]; sprintf(origPath, "%s", pPath); - DeleteDir(pPath); + DeleteDir(pPath); OSScreenClearBufferEx(0, 0); - OSScreenClearBufferEx(1, 0); + OSScreenClearBufferEx(1, 0); console_print_pos(-2, 0, "Deleting folder %s", data.name); console_print_pos_multiline(-2, 2, '/', "From: \n%s", origPath); - if (IOSUHAX_FSA_Remove(fsaFd, origPath) != 0) promptError("Failed to delete folder."); - } else { - console_print_pos(-2, 0, "Deleting file %s", data.name); - console_print_pos_multiline(-2, 2, '/', "From: \n%s", pPath); - if (IOSUHAX_FSA_Remove(fsaFd, pPath) != 0) promptError("Failed to delete file."); - } + if (IOSUHAX_FSA_Remove(fsaFd, origPath) != 0) promptError("Failed to delete folder."); + } else { + console_print_pos(-2, 0, "Deleting file %s", data.name); + console_print_pos_multiline(-2, 2, '/', "From: \n%s", pPath); + if (IOSUHAX_FSA_Remove(fsaFd, pPath) != 0) promptError("Failed to delete file."); + } - flipBuffers(); - pPath[len] = 0; - } + flipBuffers(); + pPath[len] = 0; + } - IOSUHAX_FSA_CloseDir(fsaFd, dirH); - return 0; + IOSUHAX_FSA_CloseDir(fsaFd, dirH); + return 0; } void getUserID(char* out) { // Source: loadiine_gx2 - /* get persistent ID - thanks to Maschell */ - unsigned int nn_act_handle; - unsigned long (*GetPersistentIdEx)(unsigned char); - int (*GetSlotNo)(void); - void (*nn_Initialize)(void); - void (*nn_Finalize)(void); - OSDynLoad_Acquire("nn_act.rpl", &nn_act_handle); - OSDynLoad_FindExport(nn_act_handle, 0, "GetPersistentIdEx__Q2_2nn3actFUc", &GetPersistentIdEx); - OSDynLoad_FindExport(nn_act_handle, 0, "GetSlotNo__Q2_2nn3actFv", &GetSlotNo); - OSDynLoad_FindExport(nn_act_handle, 0, "Initialize__Q2_2nn3actFv", &nn_Initialize); - OSDynLoad_FindExport(nn_act_handle, 0, "Finalize__Q2_2nn3actFv", &nn_Finalize); + /* get persistent ID - thanks to Maschell */ + unsigned int nn_act_handle; + unsigned long (*GetPersistentIdEx)(unsigned char); + int (*GetSlotNo)(void); + void (*nn_Initialize)(void); + void (*nn_Finalize)(void); + OSDynLoad_Acquire("nn_act.rpl", &nn_act_handle); + OSDynLoad_FindExport(nn_act_handle, 0, "GetPersistentIdEx__Q2_2nn3actFUc", &GetPersistentIdEx); + OSDynLoad_FindExport(nn_act_handle, 0, "GetSlotNo__Q2_2nn3actFv", &GetSlotNo); + OSDynLoad_FindExport(nn_act_handle, 0, "Initialize__Q2_2nn3actFv", &nn_Initialize); + OSDynLoad_FindExport(nn_act_handle, 0, "Finalize__Q2_2nn3actFv", &nn_Finalize); - nn_Initialize(); // To be sure that it is really Initialized + nn_Initialize(); // To be sure that it is really Initialized - unsigned char slotno = GetSlotNo(); - unsigned int persistentID = GetPersistentIdEx(slotno); - nn_Finalize(); //must be called an equal number of times to nn_Initialize + unsigned char slotno = GetSlotNo(); + unsigned int persistentID = GetPersistentIdEx(slotno); + nn_Finalize(); //must be called an equal number of times to nn_Initialize - sprintf(out, "%08X", persistentID); + sprintf(out, "%08X", persistentID); } @@ -625,16 +627,16 @@ int getLoadiineGameSaveDir(char* out, const char* productCode) { if (ret != 0) break; - if ((data.stat.flag & DIR_ENTRY_IS_DIRECTORY) && (strstr(data.name, productCode) != NULL)) { - sprintf(out, "/vol/storage_sdcard/wiiu/saves/%s", data.name); - IOSUHAX_FSA_CloseDir(fsaFd, dirH); - return 0; - } - } + if ((data.stat.flag & DIR_ENTRY_IS_DIRECTORY) && (strstr(data.name, productCode) != NULL)) { + sprintf(out, "/vol/storage_sdcard/wiiu/saves/%s", data.name); + IOSUHAX_FSA_CloseDir(fsaFd, dirH); + return 0; + } + } - promptError("Loadiine game folder not found."); - IOSUHAX_FSA_CloseDir(fsaFd, dirH); - return -2; + promptError("Loadiine game folder not found."); + IOSUHAX_FSA_CloseDir(fsaFd, dirH); + return -2; } int getLoadiineSaveVersionList(int* out, const char* gamePath) { @@ -645,91 +647,91 @@ int getLoadiineSaveVersionList(int* out, const char* gamePath) { return -1; } - int i = 0; - while (i < 255) { + int i = 0; + while (i < 255) { directoryEntry_s data; int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirH, &data); if (ret != 0) break; - if ((data.stat.flag & DIR_ENTRY_IS_DIRECTORY) && (strchr(data.name, 'v') != NULL)) { - out[++i] = strtol((data.name)+1, NULL, 10); - } + if ((data.stat.flag & DIR_ENTRY_IS_DIRECTORY) && (strchr(data.name, 'v') != NULL)) { + out[++i] = strtol((data.name)+1, NULL, 10); + } - } + } - IOSUHAX_FSA_CloseDir(fsaFd, dirH); - return 0; + IOSUHAX_FSA_CloseDir(fsaFd, dirH); + return 0; } int getLoadiineUserDir(char* out, const char* fullSavePath, const char* userID) { int dirH; if (IOSUHAX_FSA_OpenDir(fsaFd, fullSavePath, &dirH) < 0) { - promptError("Failed to open Loadiine game save directory."); - return -1; - } + promptError("Failed to open Loadiine game save directory."); + return -1; + } - while (1) { + while (1) { directoryEntry_s data; int ret = IOSUHAX_FSA_ReadDir(fsaFd, dirH, &data); if (ret != 0) break; - if ((data.stat.flag & DIR_ENTRY_IS_DIRECTORY) && (strstr(data.name, userID))) { - sprintf(out, "%s/%s", fullSavePath, data.name); - IOSUHAX_FSA_CloseDir(fsaFd, dirH); - return 0; - } - } + if ((data.stat.flag & DIR_ENTRY_IS_DIRECTORY) && (strstr(data.name, userID))) { + sprintf(out, "%s/%s", fullSavePath, data.name); + IOSUHAX_FSA_CloseDir(fsaFd, dirH); + return 0; + } + } - sprintf(out, "%s/u", fullSavePath); + sprintf(out, "%s/u", fullSavePath); if (checkEntry(out) <= 0) return -1; - IOSUHAX_FSA_CloseDir(fsaFd, dirH); - return 0; + IOSUHAX_FSA_CloseDir(fsaFd, dirH); + return 0; } u64 getSlotDate(u32 highID, u32 lowID, u8 slot) { - char path[PATH_SIZE]; + char path[PATH_SIZE]; if (((highID & 0xFFFFFFF0) == 0x00010000) && (slot == 255)) { sprintf(path, "/vol/storage_sdcard/savegames/%08x%08x", highID, lowID); } else { - sprintf(path, "/vol/storage_sdcard/wiiu/backups/%08x%08x/%u", highID, lowID, slot); + sprintf(path, "/vol/storage_sdcard/wiiu/backups/%08x%08x/%u", highID, lowID, slot); } int ret = checkEntry(path); - if (ret <= 0) return 0; - else { + if (ret <= 0) return 0; + else { fileStat_s fStat; - int ret = FSAR(IOSUHAX_FSA_GetStat(fsaFd, path, &fStat)); + ret = FSAR(IOSUHAX_FSA_GetStat(fsaFd, path, &fStat)); return fStat.ctime; } } bool isSlotEmpty(u32 highID, u32 lowID, u8 slot) { - char path[PATH_SIZE]; + char path[PATH_SIZE]; if (((highID & 0xFFFFFFF0) == 0x00010000) && (slot == 255)) { sprintf(path, "/vol/storage_sdcard/savegames/%08x%08x", highID, lowID); } else { - sprintf(path, "/vol/storage_sdcard/wiiu/backups/%08x%08x/%u", highID, lowID, slot); + sprintf(path, "/vol/storage_sdcard/wiiu/backups/%08x%08x/%u", highID, lowID, slot); } int ret = checkEntry(path); - if (ret <= 0) return 1; - else return 0; + if (ret <= 0) return 1; + else return 0; } int getEmptySlot(u32 highID, u32 lowID) { - for (int i = 0; i < 256; i++) { - if (isSlotEmpty(highID, lowID, i)) return i; - } - return -1; + for (int i = 0; i < 256; i++) { + if (isSlotEmpty(highID, lowID, i)) return i; + } + return -1; } bool hasAccountSave(Title* title, bool inSD, bool iine, u32 user, u8 slot, int version) { u32 highID = title->highID, lowID = title->lowID; - bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); + bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); if (highID == 0 || lowID == 0) return false; - char srcPath[PATH_SIZE]; + char srcPath[PATH_SIZE]; if (!isWii) { if (!inSD) { const char* path = (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save"); @@ -741,7 +743,7 @@ bool hasAccountSave(Title* title, bool inSD, bool iine, u32 user, u8 slot, int v sprintf(srcPath, "%s/%08x/%08x/%s/%08X", path, highID, lowID, "user", user); } else { if (!iine) - sprintf(srcPath, "/vol/storage_sdcard/wiiu/backups/%08x%08x/%u/%08X", highID, lowID, slot, user); + sprintf(srcPath, "/vol/storage_sdcard/wiiu/backups/%08x%08x/%u/%08X", highID, lowID, slot, user); else { if (getLoadiineGameSaveDir(srcPath, title->productCode) != 0) return false; if (version) sprintf(srcPath + strlen(srcPath), "/v%u", version); @@ -770,17 +772,17 @@ bool hasAccountSave(Title* title, bool inSD, bool iine, u32 user, u8 slot, int v } bool hasCommonSave(Title* title, bool inSD, bool iine, u8 slot, int version) { - u32 highID = title->highID, lowID = title->lowID; - bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); + u32 highID = title->highID, lowID = title->lowID; + bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); if (isWii) return false; - char srcPath[PATH_SIZE]; + char srcPath[PATH_SIZE]; if (!inSD) { const char* path = (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save"); - sprintf(srcPath, "%s/%08x/%08x/%s/common", path, highID, lowID, "user"); + sprintf(srcPath, "%s/%08x/%08x/%s/common", path, highID, lowID, "user"); } else { if (!iine) - sprintf(srcPath, "/vol/storage_sdcard/wiiu/backups/%08x%08x/%u/common", highID, lowID, slot); + sprintf(srcPath, "/vol/storage_sdcard/wiiu/backups/%08x%08x/%u/common", highID, lowID, slot); else { if (getLoadiineGameSaveDir(srcPath, title->productCode) != 0) return false; if (version) sprintf(srcPath + strlen(srcPath), "/v%u", version); @@ -795,39 +797,39 @@ bool hasCommonSave(Title* title, bool inSD, bool iine, u8 slot, int version) { void copySavedata(Title* title, Title* titleb, s8 allusers, s8 allusers_d, bool common) { - u32 highID = title->highID, lowID = title->lowID; - bool isUSB = title->isTitleOnUSB; - u32 highIDb = titleb->highID, lowIDb = titleb->lowID; - bool isUSBb = titleb->isTitleOnUSB; + u32 highID = title->highID, lowID = title->lowID; + bool isUSB = title->isTitleOnUSB; + u32 highIDb = titleb->highID, lowIDb = titleb->lowID; + bool isUSBb = titleb->isTitleOnUSB; - if (!promptConfirm(ST_WARNING, "Are you sure?")) return; - int slotb = getEmptySlot(titleb->highID, titleb->lowID); - if ((slotb >= 0) && promptConfirm(ST_YES_NO, "Backup current savedata first to next empty slot?")) { - backupSavedata(titleb, slotb, allusers, common); - promptError("Backup done. Now copying Savedata."); - } + if (!promptConfirm(ST_WARNING, "Are you sure?")) return; + int slotb = getEmptySlot(titleb->highID, titleb->lowID); + if ((slotb >= 0) && promptConfirm(ST_YES_NO, "Backup current savedata first to next empty slot?")) { + backupSavedata(titleb, slotb, allusers, common); + promptError("Backup done. Now copying Savedata."); + } - char srcPath[PATH_SIZE]; - char dstPath[PATH_SIZE]; - const char* path = (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save"); - const char* pathb = (isUSBb ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save"); - sprintf(srcPath, "%s/%08x/%08x/%s", path, highID, lowID, "user"); - sprintf(dstPath, "%s/%08x/%08x/%s", pathb, highIDb, lowIDb, "user"); + char srcPath[PATH_SIZE]; + char dstPath[PATH_SIZE]; + const char* path = (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save"); + const char* pathb = (isUSBb ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save"); + sprintf(srcPath, "%s/%08x/%08x/%s", path, highID, lowID, "user"); + sprintf(dstPath, "%s/%08x/%08x/%s", pathb, highIDb, lowIDb, "user"); createFolder(dstPath); - if (allusers > -1) { - u32 srcOffset = strlen(srcPath); - u32 dstOffset = strlen(dstPath); - if (common) { - strcpy(srcPath + srcOffset, "/common"); - strcpy(dstPath + dstOffset, "/common"); - if (DumpDir(srcPath, dstPath) != 0) promptError("Common save not found."); - } - sprintf(srcPath + srcOffset, "/%s", wiiuacc[allusers].persistentID); - sprintf(dstPath + dstOffset, "/%s", wiiuacc[allusers_d].persistentID); - } + if (allusers > -1) { + u32 srcOffset = strlen(srcPath); + u32 dstOffset = strlen(dstPath); + if (common) { + strcpy(srcPath + srcOffset, "/common"); + strcpy(dstPath + dstOffset, "/common"); + if (DumpDir(srcPath, dstPath) != 0) promptError("Common save not found."); + } + sprintf(srcPath + srcOffset, "/%s", wiiuacc[allusers].persistentID); + sprintf(dstPath + dstOffset, "/%s", wiiuacc[allusers_d].persistentID); + } - if (DumpDir(srcPath, dstPath) != 0) promptError("Copy failed."); + if (DumpDir(srcPath, dstPath) != 0) promptError("Copy failed."); if (strncmp(strchr(dstPath, '_'), "_usb", 4) == 0) { IOSUHAX_FSA_FlushVolume(fsaFd, "/vol/storage_usb01"); @@ -855,31 +857,30 @@ void backupAllSave(Title* titles, int count, OSCalendarTime* date) { char datetime[24]; sprintf(datetime, "%04d-%02d-%02dT%02d%02d%02d", dateTime.year, dateTime.mon, dateTime.mday, dateTime.hour, dateTime.min, dateTime.sec); for (int i = 0; i < count; i++) { - if (titles[i].highID == 0 || titles[i].lowID == 0 || !titles[i].saveInit) continue; + if (titles[i].highID == 0 || titles[i].lowID == 0 || !titles[i].saveInit) continue; - u32 highID = titles[i].highID, lowID = titles[i].lowID; - bool isUSB = titles[i].isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); - char srcPath[PATH_SIZE]; - char dstPath[PATH_SIZE]; - const char* path = (isWii ? "/vol/storage_slccmpt01/title" : (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save")); - sprintf(srcPath, "%s/%08x/%08x/%s", path, highID, lowID, isWii ? "data" : "user"); + u32 highID = titles[i].highID, lowID = titles[i].lowID; + bool isUSB = titles[i].isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); + char srcPath[PATH_SIZE]; + char dstPath[PATH_SIZE]; + const char* path = (isWii ? "/vol/storage_slccmpt01/title" : (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save")); + sprintf(srcPath, "%s/%08x/%08x/%s", path, highID, lowID, isWii ? "data" : "user"); sprintf(dstPath, "/vol/storage_sdcard/wiiu/backups/batch/%s/%08x%08x", datetime, highID, lowID); createFolder(dstPath); - if (DumpDir(srcPath, dstPath) != 0) promptError("Backup failed."); + if (DumpDir(srcPath, dstPath) != 0) promptError("Backup failed."); } - return dateTime; } void backupSavedata(Title* title, u8 slot, s8 allusers, bool common) { - if (!isSlotEmpty(title->highID, title->lowID, slot) && !promptConfirm(ST_WARNING, "Backup found on this slot. Overwrite it?")) return; - u32 highID = title->highID, lowID = title->lowID; - bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); - char srcPath[PATH_SIZE]; - char dstPath[PATH_SIZE]; - const char* path = (isWii ? "/vol/storage_slccmpt01/title" : (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save")); - sprintf(srcPath, "%s/%08x/%08x/%s", path, highID, lowID, isWii ? "data" : "user"); + if (!isSlotEmpty(title->highID, title->lowID, slot) && !promptConfirm(ST_WARNING, "Backup found on this slot. Overwrite it?")) return; + u32 highID = title->highID, lowID = title->lowID; + bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); + char srcPath[PATH_SIZE]; + char dstPath[PATH_SIZE]; + const char* path = (isWii ? "/vol/storage_slccmpt01/title" : (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save")); + sprintf(srcPath, "%s/%08x/%08x/%s", path, highID, lowID, isWii ? "data" : "user"); if (isWii && (slot == 255)) { sprintf(dstPath, "/vol/storage_sdcard/savegames/%08x%08x", highID, lowID); } else { @@ -887,21 +888,21 @@ void backupSavedata(Title* title, u8 slot, s8 allusers, bool common) { } createFolder(dstPath); - if ((allusers > -1) && !isWii) { - u32 srcOffset = strlen(srcPath); - u32 dstOffset = strlen(dstPath); - if (common) { - strcpy(srcPath + srcOffset, "/common"); - strcpy(dstPath + dstOffset, "/common"); - if (DumpDir(srcPath, dstPath) != 0) promptError("Common save not found."); - } - sprintf(srcPath + srcOffset, "/%s", wiiuacc[allusers].persistentID); - sprintf(dstPath + dstOffset, "/%s", wiiuacc[allusers].persistentID); + if ((allusers > -1) && !isWii) { + u32 srcOffset = strlen(srcPath); + u32 dstOffset = strlen(dstPath); + if (common) { + strcpy(srcPath + srcOffset, "/common"); + strcpy(dstPath + dstOffset, "/common"); + if (DumpDir(srcPath, dstPath) != 0) promptError("Common save not found."); + } + sprintf(srcPath + srcOffset, "/%s", wiiuacc[allusers].persistentID); + sprintf(dstPath + dstOffset, "/%s", wiiuacc[allusers].persistentID); if (checkEntry(srcPath) == 0) { promptError("No save found for this user."); return; } - } + } if (DumpDir(srcPath, dstPath) != 0) promptError("Backup failed. DO NOT restore from this slot."); @@ -918,18 +919,18 @@ void backupSavedata(Title* title, u8 slot, s8 allusers, bool common) { void restoreSavedata(Title* title, u8 slot, s8 sdusers, s8 allusers, bool common) { - if (isSlotEmpty(title->highID, title->lowID, slot)) { - promptError("No backup found on selected slot."); - return; - } - if (!promptConfirm(ST_WARNING, "Are you sure?")) return; - int slotb = getEmptySlot(title->highID, title->lowID); - if ((slotb >= 0) && promptConfirm(ST_YES_NO, "Backup current savedata first to next empty slot?")) backupSavedata(title, slotb, allusers, common); - u32 highID = title->highID, lowID = title->lowID; - bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); - char srcPath[PATH_SIZE]; - char dstPath[PATH_SIZE]; - const char* path = (isWii ? "/vol/storage_slccmpt01/title" : (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save")); + if (isSlotEmpty(title->highID, title->lowID, slot)) { + promptError("No backup found on selected slot."); + return; + } + if (!promptConfirm(ST_WARNING, "Are you sure?")) return; + int slotb = getEmptySlot(title->highID, title->lowID); + if ((slotb >= 0) && promptConfirm(ST_YES_NO, "Backup current savedata first to next empty slot?")) backupSavedata(title, slotb, allusers, common); + u32 highID = title->highID, lowID = title->lowID; + bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); + char srcPath[PATH_SIZE]; + char dstPath[PATH_SIZE]; + const char* path = (isWii ? "/vol/storage_slccmpt01/title" : (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save")); if (isWii && (slot == 255)) { sprintf(srcPath, "/vol/storage_sdcard/savegames/%08x%08x", highID, lowID); } else { @@ -938,19 +939,19 @@ void restoreSavedata(Title* title, u8 slot, s8 sdusers, s8 allusers, bool common sprintf(dstPath, "%s/%08x/%08x/%s", path, highID, lowID, isWii ? "data" : "user"); createFolder(dstPath); - if ((sdusers > -1) && !isWii) { - u32 srcOffset = strlen(srcPath); - u32 dstOffset = strlen(dstPath); - if (common) { - strcpy(srcPath + srcOffset, "/common"); - strcpy(dstPath + dstOffset, "/common"); - if (DumpDir(srcPath, dstPath) != 0) promptError("Common save not found."); - } - sprintf(srcPath + srcOffset, "/%s", sdacc[sdusers].persistentID); - sprintf(dstPath + dstOffset, "/%s", wiiuacc[allusers].persistentID); - } + if ((sdusers > -1) && !isWii) { + u32 srcOffset = strlen(srcPath); + u32 dstOffset = strlen(dstPath); + if (common) { + strcpy(srcPath + srcOffset, "/common"); + strcpy(dstPath + dstOffset, "/common"); + if (DumpDir(srcPath, dstPath) != 0) promptError("Common save not found."); + } + sprintf(srcPath + srcOffset, "/%s", sdacc[sdusers].persistentID); + sprintf(dstPath + dstOffset, "/%s", wiiuacc[allusers].persistentID); + } - if (DumpDir(srcPath, dstPath) != 0) promptError("Restore failed."); + if (DumpDir(srcPath, dstPath) != 0) promptError("Restore failed."); if (strncmp(strchr(dstPath, '_'), "_usb", 4) == 0) { IOSUHAX_FSA_FlushVolume(fsaFd, "/vol/storage_usb01"); @@ -965,28 +966,28 @@ void restoreSavedata(Title* title, u8 slot, s8 sdusers, s8 allusers, bool common void wipeSavedata(Title* title, s8 allusers, bool common) { - if (!promptConfirm(ST_WARNING, "Are you sure?") || !promptConfirm(ST_WARNING, "Hm, are you REALLY sure?")) return; - int slotb = getEmptySlot(title->highID, title->lowID); - if ((slotb >= 0) && promptConfirm(ST_YES_NO, "Backup current savedata first?")) backupSavedata(title, slotb, allusers, common); - u32 highID = title->highID, lowID = title->lowID; - bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); - char srcPath[PATH_SIZE]; + if (!promptConfirm(ST_WARNING, "Are you sure?") || !promptConfirm(ST_WARNING, "Hm, are you REALLY sure?")) return; + int slotb = getEmptySlot(title->highID, title->lowID); + if ((slotb >= 0) && promptConfirm(ST_YES_NO, "Backup current savedata first?")) backupSavedata(title, slotb, allusers, common); + u32 highID = title->highID, lowID = title->lowID; + bool isUSB = title->isTitleOnUSB, isWii = ((highID & 0xFFFFFFF0) == 0x00010000); + char srcPath[PATH_SIZE]; char origPath[PATH_SIZE]; - const char* path = (isWii ? "/vol/storage_slccmpt01/title" : (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save")); - sprintf(srcPath, "%s/%08x/%08x/%s", path, highID, lowID, isWii ? "data" : "user"); - if ((allusers > -1) && !isWii) { - u32 offset = strlen(srcPath); - if (common) { - strcpy(srcPath + offset, "/common"); + const char* path = (isWii ? "/vol/storage_slccmpt01/title" : (isUSB ? "/vol/storage_usb01/usr/save" : "/vol/storage_mlc01/usr/save")); + sprintf(srcPath, "%s/%08x/%08x/%s", path, highID, lowID, isWii ? "data" : "user"); + if ((allusers > -1) && !isWii) { + u32 offset = strlen(srcPath); + if (common) { + strcpy(srcPath + offset, "/common"); sprintf(origPath, "%s", srcPath); - if (DeleteDir(srcPath) != 0) promptError("Common save not found."); + if (DeleteDir(srcPath) != 0) promptError("Common save not found."); if (IOSUHAX_FSA_Remove(fsaFd, origPath) != 0) promptError("Failed to delete common folder."); - } - sprintf(srcPath + offset, "/%s", wiiuacc[allusers].persistentID); + } + sprintf(srcPath + offset, "/%s", wiiuacc[allusers].persistentID); sprintf(origPath, "%s", srcPath); - } + } - if (DeleteDir(srcPath)!=0) promptError("Failed to delete savefile."); + if (DeleteDir(srcPath)!=0) promptError("Failed to delete savefile."); if ((allusers > -1) && !isWii) { if (IOSUHAX_FSA_Remove(fsaFd, origPath) != 0) promptError("Failed to delete user folder."); } @@ -1004,60 +1005,60 @@ void wipeSavedata(Title* title, s8 allusers, bool common) { void importFromLoadiine(Title* title, bool common, int version) { - if (!promptConfirm(ST_WARNING, "Are you sure?")) return; - int slotb = getEmptySlot(title->highID, title->lowID); - if (slotb>=0 && promptConfirm(ST_YES_NO, "Backup current savedata first?")) backupSavedata(title, slotb, 0, common); - u32 highID = title->highID, lowID = title->lowID; - bool isUSB = title->isTitleOnUSB; - char srcPath[PATH_SIZE]; - char dstPath[PATH_SIZE]; - if (getLoadiineGameSaveDir(srcPath, title->productCode) !=0 ) return; - if (version) sprintf(srcPath + strlen(srcPath), "/v%i", version); - char usrPath[16]; - getUserID(usrPath); - u32 srcOffset = strlen(srcPath); - getLoadiineUserDir(srcPath, srcPath, usrPath); - sprintf(dstPath, "/vol/storage_%s01/usr/save/%08x/%08x/user", isUSB ? "usb" : "mlc", highID, lowID); + if (!promptConfirm(ST_WARNING, "Are you sure?")) return; + int slotb = getEmptySlot(title->highID, title->lowID); + if (slotb>=0 && promptConfirm(ST_YES_NO, "Backup current savedata first?")) backupSavedata(title, slotb, 0, common); + u32 highID = title->highID, lowID = title->lowID; + bool isUSB = title->isTitleOnUSB; + char srcPath[PATH_SIZE]; + char dstPath[PATH_SIZE]; + if (getLoadiineGameSaveDir(srcPath, title->productCode) !=0 ) return; + if (version) sprintf(srcPath + strlen(srcPath), "/v%i", version); + char usrPath[16]; + getUserID(usrPath); + u32 srcOffset = strlen(srcPath); + getLoadiineUserDir(srcPath, srcPath, usrPath); + sprintf(dstPath, "/vol/storage_%s01/usr/save/%08x/%08x/user", isUSB ? "usb" : "mlc", highID, lowID); createFolder(dstPath); - u32 dstOffset = strlen(dstPath); - sprintf(dstPath + dstOffset, "/%s", usrPath); + u32 dstOffset = strlen(dstPath); + sprintf(dstPath + dstOffset, "/%s", usrPath); promptError(srcPath); promptError(dstPath); - if (DumpDir(srcPath, dstPath) != 0) promptError("Failed to import savedata from loadiine."); + if (DumpDir(srcPath, dstPath) != 0) promptError("Failed to import savedata from loadiine."); if (common) { - strcpy(srcPath + srcOffset, "/c\0"); - strcpy(dstPath + dstOffset, "/common\0"); + strcpy(srcPath + srcOffset, "/c\0"); + strcpy(dstPath + dstOffset, "/common\0"); promptError(srcPath); promptError(dstPath); - if (DumpDir(srcPath, dstPath) != 0) promptError("Common save not found."); + if (DumpDir(srcPath, dstPath) != 0) promptError("Common save not found."); } } void exportToLoadiine(Title* title, bool common, int version) { - if (!promptConfirm(ST_WARNING, "Are you sure?")) return; - u32 highID = title->highID, lowID = title->lowID; - bool isUSB = title->isTitleOnUSB; - char srcPath[PATH_SIZE]; - char dstPath[PATH_SIZE]; - if (getLoadiineGameSaveDir(dstPath, title->productCode)!=0) return; - if (version) sprintf(dstPath + strlen(dstPath), "/v%u", version); - char usrPath[16]; - getUserID(usrPath); - u32 dstOffset = strlen(dstPath); - getLoadiineUserDir(dstPath, dstPath, usrPath); - sprintf(srcPath, "/vol/storage_%s01/usr/save/%08x/%08x/user", isUSB ? "usb" : "mlc", highID, lowID); - u32 srcOffset = strlen(srcPath); - sprintf(srcPath + srcOffset, "/%s", usrPath); + if (!promptConfirm(ST_WARNING, "Are you sure?")) return; + u32 highID = title->highID, lowID = title->lowID; + bool isUSB = title->isTitleOnUSB; + char srcPath[PATH_SIZE]; + char dstPath[PATH_SIZE]; + if (getLoadiineGameSaveDir(dstPath, title->productCode)!=0) return; + if (version) sprintf(dstPath + strlen(dstPath), "/v%u", version); + char usrPath[16]; + getUserID(usrPath); + u32 dstOffset = strlen(dstPath); + getLoadiineUserDir(dstPath, dstPath, usrPath); + sprintf(srcPath, "/vol/storage_%s01/usr/save/%08x/%08x/user", isUSB ? "usb" : "mlc", highID, lowID); + u32 srcOffset = strlen(srcPath); + sprintf(srcPath + srcOffset, "/%s", usrPath); createFolder(dstPath); promptError(srcPath); promptError(dstPath); - if (DumpDir(srcPath, dstPath) != 0) promptError("Failed to export savedata to loadiine."); + if (DumpDir(srcPath, dstPath) != 0) promptError("Failed to export savedata to loadiine."); if (common) { - strcpy(dstPath + dstOffset, "/c\0"); - strcpy(srcPath + srcOffset, "/common\0"); + strcpy(dstPath + dstOffset, "/c\0"); + strcpy(srcPath + srcOffset, "/common\0"); promptError(srcPath); promptError(dstPath); - if (DumpDir(srcPath, dstPath) != 0) promptError("Common save not found."); + if (DumpDir(srcPath, dstPath) != 0) promptError("Common save not found."); } } diff --git a/src/savemng.h b/src/savemng.h index 7b588e2..8147955 100644 --- a/src/savemng.h +++ b/src/savemng.h @@ -8,9 +8,9 @@ #include #include -#include "lib_easy.h" #include "draw.h" #include "controllers.h" +#include "wiiu.h" #define PATH_SIZE 0x400 @@ -63,6 +63,8 @@ bool promptConfirm(Style st, const char* question); void promptError(const char* message, ...); void getUserID(char* out); void getAccountsWiiU(); +void getAccountsSD(Title* title, u8 slot); +bool hasAccountSave(Title* title, bool inSD, bool iine, u32 user, u8 slot, int version); int getLoadiineGameSaveDir(char* out, const char* productCode); int getLoadiineSaveVersionList(int* out, const char* gamePath); @@ -87,8 +89,9 @@ s32 loadFile(const char * fPath, u8 **buf); s32 loadFilePart(const char * fPath, u32 start, u32 size, u8 **buf); s32 loadTitleIcon(Title* title); -void show_file_operation(char* file_name, char* file_src, char* file_dest); +void show_file_operation(const char* file_name, const char* file_src, const char* file_dest); void console_print_pos_multiline(int x, int y, char cdiv,const char* format, ...); +void console_print_pos_aligned(int y, u16 offset, u8 align, const char* format, ...); #ifdef __cplusplus } diff --git a/src/tga_reader.c b/src/tga_reader.c index 4c519fb..e4d8fa3 100644 --- a/src/tga_reader.c +++ b/src/tga_reader.c @@ -155,7 +155,7 @@ static int *createPixelsFromColormap(int width, int height, int depth, const uns int i, j; for(i=0; i= 0) { int index = 3*colormapIndex+18; @@ -174,7 +174,7 @@ static int *createPixelsFromColormap(int width, int height, int depth, const uns int i, j; for(i=0; i= 0) { int index = 3*colormapIndex+18; @@ -195,7 +195,7 @@ static int *createPixelsFromColormap(int width, int height, int depth, const uns int i, j; for(i=0; i= 0) { int index = 3*colormapIndex+18; @@ -214,7 +214,7 @@ static int *createPixelsFromColormap(int width, int height, int depth, const uns int i, j; for(i=0; i= 0) { int index = 3*colormapIndex+18; @@ -238,7 +238,7 @@ static int *createPixelsFromColormap(int width, int height, int depth, const uns int i, j; for(i=0; i= 0) { int index = 4*colormapIndex+18; @@ -257,7 +257,7 @@ static int *createPixelsFromColormap(int width, int height, int depth, const uns int i, j; for(i=0; i= 0) { int index = 4*colormapIndex+18; @@ -278,7 +278,7 @@ static int *createPixelsFromColormap(int width, int height, int depth, const uns int i, j; for(i=0; i= 0) { int index = 4*colormapIndex+18; @@ -297,7 +297,7 @@ static int *createPixelsFromColormap(int width, int height, int depth, const uns int i, j; for(i=0; i= 0) { int index = 4*colormapIndex+18; diff --git a/src/wiiu.h b/src/wiiu.h new file mode 100644 index 0000000..66953da --- /dev/null +++ b/src/wiiu.h @@ -0,0 +1,23 @@ +#ifndef WIIU_H +#define WIIU_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fs/fs_utils.h" +#include "fs/sd_fat_devoptab.h" +#include "system/memory.h" +#include "common/common.h" + +#endif // WIIU_H