diff --git a/inc/data.h b/inc/data.h index ce66b07..d51fac6 100644 --- a/inc/data.h +++ b/inc/data.h @@ -109,6 +109,8 @@ namespace data //Stores current data we're using so I don't have to type so much. extern titledata curData; extern user curUser; + + extern bool isSpcd; } #endif // DATA_H diff --git a/inc/gfx.h b/inc/gfx.h index 6e72525..27d727e 100644 --- a/inc/gfx.h +++ b/inc/gfx.h @@ -109,6 +109,9 @@ tex *texLoadJPEGFile(const char *path); //Loads jpeg from memory tex *texLoadJPEGMem(const uint8_t *jpegData, size_t jpegSize); +//Loads image from RGBA - Not meant for large images +tex *texLoadRGBA(const char *path); + //Frees memory used by t void texDestroy(tex *t); diff --git a/romfs/img/icn/icnDefault.png b/romfs/img/icn/icnDefault.png index 6a5929c..ee52d93 100644 Binary files a/romfs/img/icn/icnDefault.png and b/romfs/img/icn/icnDefault.png differ diff --git a/src/data.cpp b/src/data.cpp index bc253ad..7dba047 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -4,7 +4,9 @@ #include #include #include +#include #include +#include #include "data.h" #include "file.h" @@ -67,9 +69,17 @@ namespace data std::vector icons; std::vector users; bool forceMount = true; + bool isSpcd = false; void loadDataInfo() { + //Check date + time_t raw; + time(&raw); + tm *locTime = localtime(&raw); + if(locTime->tm_mon == 3 && locTime->tm_mday == 1) + isSpcd = true; + //Clear titles + users just in case for(unsigned i = 0; i < users.size(); i++) users[i].titles.clear(); @@ -92,7 +102,7 @@ namespace data user sys, bcat, dev; sys.initNoChk(util::u128ToAccountUID(1), "System"); bcat.initNoChk(util::u128ToAccountUID(2), "BCAT"); - dev.initNoChk(util::u128ToAccountUID(3), "Dev. Sv"); + dev.initNoChk(util::u128ToAccountUID(3), "Device"); users.push_back(sys); users.push_back(bcat); @@ -280,15 +290,31 @@ namespace data if(username.empty()) username = "Unknown"; userSafe = util::safeString(username); + if(!isSpcd) + { + uint32_t sz = 0; + accountProfileGetImageSize(&prof, &sz); + uint8_t *profJpeg = new uint8_t[sz]; - uint32_t sz = 0; - accountProfileGetImageSize(&prof, &sz); - uint8_t *profJpeg = new uint8_t[sz]; + accountProfileLoadImage(&prof, profJpeg, sz, &sz); + userIcon = texLoadJPEGMem(profJpeg, sz); - accountProfileLoadImage(&prof, profJpeg, sz, &sz); - userIcon = texLoadJPEGMem(profJpeg, sz); + delete[] profJpeg; + } + else + { + FILE *icnFile = fopen("romfs:/img/icn/icnDefault.png", "rb"); + fseek(icnFile, 0, SEEK_END); + size_t fileSize = ftell(icnFile); + fseek(icnFile, 0xB50, SEEK_SET); - delete[] profJpeg; + size_t icnSize = fileSize - 0xB50; + unsigned char *tmpBuff = new unsigned char[icnSize]; + fread(tmpBuff, 1, icnSize, icnFile); + fclose(icnFile); + userIcon = texLoadJPEGMem(tmpBuff, icnSize); + delete[] tmpBuff; + } accountProfileClose(&prof); diff --git a/src/gfx.c b/src/gfx.c index 9babe99..58a3db2 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -1,9 +1,11 @@ #include #include +#include #include #include #include #include +#include #include "gfx.h" @@ -14,6 +16,13 @@ static NWindow *window; static Framebuffer fb; static bool framestarted = false; +typedef struct +{ + uint16_t w; + uint16_t h; + uint32_t sz; +} rgbaHead; + static inline uint32_t blend(const clr px, const clr fb) { if(px.a == 0x00) @@ -515,6 +524,35 @@ tex *texLoadJPEGMem(const uint8_t *jpegData, size_t jpegSize) return ret; } +tex *texLoadRGBA(const char *path) +{ + tex *ret = malloc(sizeof(tex)); + FILE *rgb = fopen(path, "rb"); + + fseek(rgb, 0, SEEK_END); + size_t dataSize = ftell(rgb) - sizeof(rgbaHead); + fseek(rgb, 0, SEEK_SET); + + rgbaHead head; + fread(&head, sizeof(rgbaHead), 1, rgb); + ret->width = head.w; + ret->height = head.h; + ret->size = head.w * head.h; + ret->data = (uint32_t *)malloc((ret->width * ret->height) * sizeof(uint32_t)); + + unsigned char *inBuff = malloc(dataSize); + fread(inBuff, 1, dataSize, rgb); + uLongf destSz = ret->size * 4; + uncompress((unsigned char *)ret->data, &destSz, inBuff, dataSize); + + FILE *deb = fopen("sdmc:/JKSV/deb.bin", "wb"); + fwrite(ret->data, sizeof(uint32_t), ret->size, deb); + fclose(deb); + + free(inBuff); + return ret; +} + void texDestroy(tex *t) { if(t->data != NULL) diff --git a/src/ui/clsui.cpp b/src/ui/clsui.cpp index 8adbcd8..51872eb 100644 --- a/src/ui/clsui.cpp +++ b/src/ui/clsui.cpp @@ -326,7 +326,7 @@ namespace ui std::fstream nandOut("sdmc:/JKSV/nand.bin", std::ios::out | std::ios::binary); - size_t nandBuffSize = 1024 * 1024 * 4; + s64 nandBuffSize = 1024 * 1024 * 4; uint8_t *nandBuff = new uint8_t[nandBuffSize]; progBar nandProg(nandSize); @@ -373,7 +373,7 @@ namespace ui std::fstream nandOut("sdmc:/JKSV/nand.bin.00", std::ios::out | std::ios::binary); - size_t nandBuffSize = 1024 * 1024 * 3; + s64 nandBuffSize = 1024 * 1024 * 3; uint8_t *nandBuff = new uint8_t[nandBuffSize]; progBar nandProg(nandSize); diff --git a/src/ui/usrsel.cpp b/src/ui/usrsel.cpp index 46d0e86..025c117 100644 --- a/src/ui/usrsel.cpp +++ b/src/ui/usrsel.cpp @@ -151,7 +151,7 @@ namespace ui } else if(down & KEY_Y || usrNav[1].getEvent() == BUTTON_RELEASED) { - for(unsigned i = 0; i < data::users.size(); i++) + for(unsigned i = 0; i < data::users.size() - 3; i++) fs::dumpAllUserSaves(data::users[i]); } else if(down & KEY_X || usrNav[2].getEvent() == BUTTON_RELEASED)