More cleanup and code size optimizations

This commit is contained in:
Xpl0itU 2022-06-20 19:57:37 +02:00
parent 42179ec7db
commit 144ff1a57e
6 changed files with 10 additions and 70 deletions

View File

@ -15,23 +15,13 @@ typedef union _RGBAColor {
};
} RGBAColor;
//Function declarations for my graphics library
void flipBuffers();
void clearBuffers();
void clearBuffersEx();
void drawTGA(int x, int y, float scale, uint8_t *fileContent);
void drawRGB5A3(int x, int y, float scale, uint8_t *pixels);
void drawBackgroundDRC(uint32_t w, uint32_t h, uint8_t *out);
void drawBackgroundTV(uint32_t w, uint32_t h, uint8_t *out);
auto ttfPrintString(int x, int y, char *string, bool wWrap, bool ceroX) -> int;
auto ttfStringWidth(char *string, int8_t part) -> int;
void draw_bitmap(FT_Bitmap *bitmap, FT_Int x, FT_Int y);

View File

@ -7,5 +7,4 @@
#include "savemng.h"
std::string getSlotDate(uint32_t highID, uint32_t lowID, uint8_t slot);
auto setSlotDate(uint32_t highID, uint32_t lowID, uint8_t slot, std::string date) -> bool;

View File

@ -16,15 +16,9 @@
#define max1(a, b) (((a) > (b)) ? (a) : (b))
#endif
// Initialization functions
auto WHBLogFreetypeInit() -> bool;
void WHBLogFreetypeFree();
void drawPixel(int32_t x, int32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
void ttfFontColor32(uint32_t color);
void ttfFontColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
void WHBLogFreetypeDraw();

View File

@ -66,57 +66,25 @@ extern Account *sdacc;
extern uint8_t wiiuaccn, sdaccn;
void console_print_pos(int x, int y, const char *format, ...);
bool promptConfirm(Style st, std::string question);
void promptError(const char *message, ...);
std::string getUserID();
void getAccountsWiiU();
void getAccountsSD(Title *title, uint8_t slot);
bool hasAccountSave(Title *title, bool inSD, bool iine, uint32_t user, uint8_t slot, int version);
int getLoadiineGameSaveDir(char *out, const char *productCode, const char *longName, const uint32_t highID, const uint32_t lowID);
int getLoadiineSaveVersionList(int *out, const char *gamePath);
int getLoadiineUserDir(char *out, const char *fullSavePath, const char *userID);
bool isSlotEmpty(uint32_t highID, uint32_t lowID, uint8_t slot);
bool hasCommonSave(Title *title, bool inSD, bool iine, uint8_t slot, int version);
void copySavedata(Title *title, Title *titled, int8_t allusers, int8_t allusers_d, bool common);
void backupAllSave(Title *titles, int count, OSCalendarTime *date);
void backupSavedata(Title *title, uint8_t slot, int8_t allusers, bool common);
void restoreSavedata(Title *title, uint8_t slot, int8_t sdusers, int8_t allusers, bool common);
void wipeSavedata(Title *title, int8_t allusers, bool common);
void importFromLoadiine(Title *title, bool common, int version);
void exportToLoadiine(Title *title, bool common, int version);
void setFSAFD(int fd);
int checkEntry(const char *fPath);
int folderEmpty(const char *fPath);
int32_t loadFile(const char *fPath, uint8_t **buf);
int32_t loadFilePart(const char *fPath, uint32_t start, uint32_t size, uint8_t **buf);
int32_t loadTitleIcon(Title *title);
void show_file_operation(std::string file_name, std::string file_src, std::string file_dest);
void console_print_pos_multiline(int x, int y, char cdiv, const char *format, ...);
void console_print_pos_aligned(int y, uint16_t offset, uint8_t align, const char *format, ...);

View File

@ -34,13 +34,9 @@ extern const TGA_ORDER *TGA_READER_ABGR;
extern const TGA_ORDER *TGA_READER_RGBA;
auto tgaMalloc(size_t size) -> void *;
void tgaFree(void *memory);
auto tgaGetWidth(const unsigned char *buffer) -> int;
auto tgaGetHeight(const unsigned char *buffer) -> int;
auto tgaRead(const unsigned char *buffer, const TGA_ORDER *order) -> int *;
#ifdef __cplusplus

View File

@ -38,18 +38,12 @@ void setFSAFD(int fd) {
fsaFd = fd;
}
void show_file_operation(std::string file_name, std::string file_src, std::string file_dest) {
static void show_file_operation(std::string file_name, std::string file_src, std::string file_dest) {
console_print_pos(-2, 0, "Copying file: %s", file_name.c_str());
console_print_pos_multiline(-2, 2, '/', "From: %s", file_src.c_str());
console_print_pos_multiline(-2, 8, '/', "To: %s", file_dest.c_str());
}
auto FSAR(int result) -> int {
if ((result & 0xFFFF0000) == 0xFFFC0000)
return (result & 0xFFFF) | 0xFFFF0000;
return result;
}
int32_t loadFile(const char *fPath, uint8_t **buf) {
int ret = 0;
FILE *file = fopen(fPath, "rb");
@ -70,7 +64,7 @@ int32_t loadFile(const char *fPath, uint8_t **buf) {
return ret;
}
int32_t loadFilePart(const char *fPath, uint32_t start, uint32_t size, uint8_t **buf) {
static int32_t loadFilePart(const char *fPath, uint32_t start, uint32_t size, uint8_t **buf) {
int ret = 0;
FILE *file = fopen(fPath, "rb");
if (file != nullptr) {
@ -131,7 +125,7 @@ auto checkEntry(const char *fPath) -> int {
return 1;
}
auto folderEmpty(const char *fPath) -> int {
static auto folderEmpty(const char *fPath) -> int {
DIR *dir = opendir(fPath);
if (dir == nullptr)
return -1;
@ -146,7 +140,7 @@ auto folderEmpty(const char *fPath) -> int {
return c < 3 ? 1 : 0;
}
auto createFolder(const char *fPath) -> int { //Adapted from mkdir_p made by JonathonReinhart
static auto createFolder(const char *fPath) -> int { //Adapted from mkdir_p made by JonathonReinhart
std::string _path;
char *p;
int found = 0;
@ -407,7 +401,7 @@ void getAccountsSD(Title *title, uint8_t slot) {
}
}
auto DumpFile(std::string pPath, std::string oPath) -> int {
static auto DumpFile(std::string pPath, std::string oPath) -> int {
FILE *source = fopen(pPath.c_str(), "rb");
if (source == nullptr)
return -1;
@ -475,7 +469,7 @@ auto DumpFile(std::string pPath, std::string oPath) -> int {
return 0;
}
auto DumpDir(std::string pPath, std::string tPath) -> int { // Source: ft2sd
static auto DumpDir(std::string pPath, std::string tPath) -> int { // Source: ft2sd
DIR *dir = opendir(pPath.c_str());
if (dir == nullptr) {
return -1;
@ -514,7 +508,7 @@ auto DumpDir(std::string pPath, std::string tPath) -> int { // Source: ft2sd
return 0;
}
auto DeleteDir(char *pPath) -> int {
static auto DeleteDir(char *pPath) -> int {
DIR *dir = opendir(pPath);
if (dir == NULL)
return -1;
@ -554,7 +548,7 @@ auto DeleteDir(char *pPath) -> int {
return 0;
}
std::string getUserID() { // Source: loadiine_gx2
static std::string getUserID() { // Source: loadiine_gx2
/* get persistent ID - thanks to Maschell */
nn::act::Initialize();
@ -603,7 +597,7 @@ auto getLoadiineSaveVersionList(int *out, const char *gamePath) -> int {
return 0;
}
auto getLoadiineUserDir(char *out, const char *fullSavePath, const char *userID) -> int {
static auto getLoadiineUserDir(char *out, const char *fullSavePath, const char *userID) -> int {
DIR *dir = opendir(fullSavePath);
if (dir == nullptr) {
@ -638,7 +632,7 @@ auto isSlotEmpty(uint32_t highID, uint32_t lowID, uint8_t slot) -> bool {
return ret <= 0;
}
auto getEmptySlot(uint32_t highID, uint32_t lowID) -> int {
static auto getEmptySlot(uint32_t highID, uint32_t lowID) -> int {
for (int i = 0; i < 256; i++)
if (isSlotEmpty(highID, lowID, i))
return i;
@ -729,7 +723,6 @@ auto hasCommonSave(Title *title, bool inSD, bool iine, uint8_t slot, int version
}
void copySavedata(Title *title, Title *titleb, int8_t allusers, int8_t allusers_d, bool common) {
uint32_t highID = title->highID;
uint32_t lowID = title->lowID;
bool isUSB = title->isTitleOnUSB;