diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2d1879a --- /dev/null +++ b/.gitignore @@ -0,0 +1,53 @@ +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +# *.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +# *.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb +*.PBP + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf diff --git a/Makefile b/Makefile index 00ef16d..90cfd63 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,23 @@ TARGET = EVEREST OBJS = crt0.o main.o utils.o hardware_utils.o system_utils.o translate.o imports.o everest_kernel/everest_kernel.o kumdman/pspUmdMan_driver.o +INCDIR = libs/include include CFLAGS = -O2 -G0 -Wall -fshort-wchar -fno-pic -mno-check-zero-division CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) -c -LDFLAGS = -mno-crt0 -nostdlib -nodefaultlibs +LDFLAGS = -nostdlib -nodefaultlibs -STDLIBS = -lpsprtc -lvlfgui -lvlfgu -lvlfutils -lvlflibc -lpsppower -lpspkubridge +LIBDIR = libs/lib +STDLIBS = -lpspmodinfo -lpsprtc -lvlfgui -lvlfgu -lvlfutils -lvlflibc -lpsppower -lpspkubridge LIBS = $(STDLIBS) -lpspreg PSP_FW_VERSION = 271 EXTRA_TARGETS = EBOOT.PBP -PSP_EBOOT_TITLE = PSP EVEREST 2 +PSP_EBOOT_TITLE = PSP EVEREST 2 Rev6 PSP_EBOOT_ICON = ICON0.PNG -PSP_EBOOT_PIC1 = PIC1.PNG +PSP_EBOOT_PIC1 = PIC1.png BUILD_PRX = 1 PSP_LARGE_MEMORY = 1 diff --git a/PIC1.png b/PIC1.png index 83760d9..fcb4195 100644 Binary files a/PIC1.png and b/PIC1.png differ diff --git a/compile.bat b/compile.sh old mode 100644 new mode 100755 similarity index 80% rename from compile.bat rename to compile.sh index 9efdbec..17aea4a --- a/compile.bat +++ b/compile.sh @@ -1,13 +1,13 @@ -PATH = c:/pspsdk_old/bin +#!/bin/sh cd everest_kernel -make +make clean && make psp-build-exports -s exports.exp bin2c everest_kernel.prx ../everest_kernel_prx.h everest_kernel_prx rm *.o *.elf *.prx cd ../kumdman -make +make clean && make psp-build-exports -s exports.exp bin2c kumdman.prx ../kumdman_prx.h kumdman_prx rm *.o *.elf *.prx @@ -17,10 +17,8 @@ bin2c intraFont.prx ../intraFont_prx.h intraFont_prx bin2c vlf.prx ../vlf_prx.h vlf_prx cd .. -rm *.pbp +rm *.PBP bin2c backgrounds.bmp backgrounds_bmp.h backgrounds_bmp -make -rm *.o *.prx *.elf *.sfo backgrounds_bmp.h everest_kernel_prx.h kumdman_prx.h intraFont_prx.h vlf_prx.h +make clean && make +rm *.o *.prx *.elf *.SFO backgrounds_bmp.h everest_kernel_prx.h kumdman_prx.h intraFont_prx.h vlf_prx.h rm everest_kernel/everest_kernel.S everest_kernel/everest_kernel.o kumdman/pspUmdMan_driver.S kumdman/pspUmdMan_driver.o - -pause diff --git a/crt0.c b/crt0.c index f143dc1..90f7815 100644 --- a/crt0.c +++ b/crt0.c @@ -13,16 +13,11 @@ #include "vlf_prx.h" extern int app_main(int argc, char *argv[]); -int language; -int SetupCallbacks(void) -{ - int CallbackThread(SceSize args, void *argp) - { - int exit_callback(int arg1, int arg2, void *common) - { +int SetupCallbacks(void) { + int CallbackThread(SceSize args, void *argp) { + int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); - return 0; } @@ -40,8 +35,7 @@ int SetupCallbacks(void) return thid; } -void LoadStartModuleBuffer(char *path, char *buf, int size, SceSize args, void *argp) -{ +void LoadStartModuleBuffer(char *path, char *buf, int size, SceSize args, void *argp) { SceUID mod, out; sceIoRemove(path); @@ -54,8 +48,7 @@ void LoadStartModuleBuffer(char *path, char *buf, int size, SceSize args, void * sceIoRemove(path); } -int start_thread(SceSize args, void *argp) -{ +int start_thread(SceSize args, void *argp) { char *path = (char *)argp; int last_trail = -1; @@ -83,8 +76,7 @@ int start_thread(SceSize args, void *argp) return sceKernelExitDeleteThread(0); } -int module_start(SceSize args, void *argp) -{ +int module_start(SceSize args, void *argp) { SetupCallbacks(); psp_model = kuKernelGetModel(); sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &language); diff --git a/everest_kernel.h b/everest_kernel.h index b1b6708..4541018 100644 --- a/everest_kernel.h +++ b/everest_kernel.h @@ -1,21 +1,21 @@ #ifndef ___KPSPIDENT_H___ #define ___KPSPIDENT_H___ -u32 sceSysconGetBaryonVersion(u32 *baryon);// 0x7EC5A957 -u32 sceSysconGetPommelVersion(u32 *pommel);// 0xE7E87741 -u32 sceSysregGetTachyonVersion(void);// 0xE2A5D1EE -u64 sceSysregGetFuseId(void);// 0x4F46EEDE -u32 sceSysregGetFuseConfig(void);// 0x8F4F4E96 +u32 pspGetBaryonVersion(u32 *baryon); // 0x7EC5A957 +u32 pspGetPommelVersion(u32 *pommel); // 0xE7E87741 +u32 pspGetTachyonVersion(void); // 0xE2A5D1EE +u64 pspGetFuseId(void); // 0x4F46EEDE +u32 pspGetFuseConfig(void); // 0x8F4F4E96 u32 pspGetKirkVersion(void); u32 pspGetSpockVersion(void); u32 pspNandGetScramble(void); -int GetRegion(void); -char *GetInitialFW(void); +int pspGetRegion(void); +char *pspGetInitialFW(void); int pspNandGetPageSize(void); int pspNandGetTotalBlocks(void); int pspNandGetPagesPerBlock(void); -u8 *GetMACAddress(u8 *buf); -int ReadSerial(u16 *pdata); -int WriteSerial(u16* serial); +u8 *pspGetMACAddress(u8 *buf); +int pspReadSerial(u16 *pdata); +int pspWriteSerial(u16* serial); #endif diff --git a/everest_kernel/Makefile b/everest_kernel/Makefile index fb42df7..2df690f 100644 --- a/everest_kernel/Makefile +++ b/everest_kernel/Makefile @@ -11,9 +11,9 @@ PSP_FW_VERSION = 271 BUILD_PRX = 1 PRX_EXPORTS = exports.exp -LDFLAGS = -mno-crt0 -nostartfiles +LDFLAGS = -nostartfiles -LIBS = -lpspkernel -lpspident -lpspnand_driver -lpspwlan +LIBS = -lpspkernel -lpspnand_driver -lpspwlan PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak diff --git a/everest_kernel/exports.exp b/everest_kernel/exports.exp index 1d2fa40..0fa91c3 100644 --- a/everest_kernel/exports.exp +++ b/everest_kernel/exports.exp @@ -6,22 +6,22 @@ PSP_BEGIN_EXPORTS PSP_EXPORT_END PSP_EXPORT_START(everest_kernel, 0, 0x4001) - PSP_EXPORT_FUNC_HASH(sceSysconGetBaryonVersion) - PSP_EXPORT_FUNC_HASH(sceSysconGetPommelVersion) - PSP_EXPORT_FUNC_HASH(sceSysregGetTachyonVersion) - PSP_EXPORT_FUNC_HASH(sceSysregGetFuseId) - PSP_EXPORT_FUNC_HASH(sceSysregGetFuseConfig) + PSP_EXPORT_FUNC_HASH(pspGetBaryonVersion) + PSP_EXPORT_FUNC_HASH(pspGetPommelVersion) + PSP_EXPORT_FUNC_HASH(pspGetTachyonVersion) + PSP_EXPORT_FUNC_HASH(pspGetFuseId) + PSP_EXPORT_FUNC_HASH(pspGetFuseConfig) PSP_EXPORT_FUNC_HASH(pspGetKirkVersion) PSP_EXPORT_FUNC_HASH(pspGetSpockVersion) PSP_EXPORT_FUNC_HASH(pspNandGetScramble) - PSP_EXPORT_FUNC_HASH(GetRegion) - PSP_EXPORT_FUNC_HASH(GetInitialFW) + PSP_EXPORT_FUNC_HASH(pspGetRegion) + PSP_EXPORT_FUNC_HASH(pspGetInitialFW) PSP_EXPORT_FUNC_HASH(pspNandGetPageSize) PSP_EXPORT_FUNC_HASH(pspNandGetPagesPerBlock) PSP_EXPORT_FUNC_HASH(pspNandGetTotalBlocks) - PSP_EXPORT_FUNC_HASH(GetMACAddress) - PSP_EXPORT_FUNC_HASH(WriteSerial) - PSP_EXPORT_FUNC_HASH(ReadSerial) + PSP_EXPORT_FUNC_HASH(pspGetMACAddress) + PSP_EXPORT_FUNC_HASH(pspWriteSerial) + PSP_EXPORT_FUNC_HASH(pspReadSerial) PSP_EXPORT_END PSP_END_EXPORTS diff --git a/everest_kernel/main.c b/everest_kernel/main.c index 814c0dd..ff2c982 100644 --- a/everest_kernel/main.c +++ b/everest_kernel/main.c @@ -11,112 +11,87 @@ PSP_MODULE_INFO("EVEREST_KERNEL", 0x1006, 7, 4); PSP_MAIN_THREAD_ATTR(0); -u32 sceSyscon_driver_7EC5A957(u32 *baryon);// Baryon -u32 sceSyscon_driver_E7E87741(u32 *pommel);// Pommel -u32 sceSysreg_driver_E2A5D1EE(void);// Tachyon -u64 sceSysreg_driver_4F46EEDE(void);// FuseId -u32 sceSysreg_driver_8F4F4E96(void);// FuseCfg -int sceSysregKirkBusClockEnable(void);// Kirk -int sceSysregAtaBusClockEnable(void);// Spock +u32 sceSysconGetBaryonVersion(u32 *baryon); // Baryon +u32 sceSysconGetPommelVersion(u32 *pommel); // Pommel +u64 sceSysreg_driver_4F46EEDE(void); // FuseId +u32 sceSysreg_driver_8F4F4E96(void); // FuseCfg +int sceSysregKirkBusClockEnable(void); // Kirk +int sceSysregAtaBusClockEnable(void); // Spock u32 sceSyscon_readbat371(u8 addr); u32 sceSysconCmdExec(void *param, int unk); -u32 sceSysconGetBaryonVersion(u32 *baryon) -{ +u32 pspGetBaryonVersion(u32 *baryon) { int k1 = pspSdkSetK1(0); - - int err = sceSyscon_driver_7EC5A957(baryon); + int err = sceSysconGetBaryonVersion(baryon); pspSdkSetK1(k1); - return err; } -u32 sceSysconGetPommelVersion(u32 *pommel) -{ +u32 pspGetPommelVersion(u32 *pommel) { int k1 = pspSdkSetK1(0); - - int err = sceSyscon_driver_E7E87741(pommel); + int err = sceSysconGetPommelVersion(pommel); pspSdkSetK1(k1); - return err; } -u32 sceSysregGetTachyonVersion(void) -{ +u32 pspGetTachyonVersion(void) { int k1 = pspSdkSetK1(0); - - int err = sceSysreg_driver_E2A5D1EE(); - + int err = sceSysregGetTachyonVersion(); pspSdkSetK1(k1); - return err; } -u64 sceSysregGetFuseId(void) -{ +u64 pspGetFuseId(void) { int k1 = pspSdkSetK1(0); - u64 err = sceSysreg_driver_4F46EEDE(); - pspSdkSetK1(k1); - return err; } -u32 sceSysregGetFuseConfig(void) -{ +u32 pspGetFuseConfig(void) { int k1 = pspSdkSetK1(0); int err = sceSysreg_driver_8F4F4E96(); pspSdkSetK1(k1); return err; } -u32 pspGetKirkVersion(void) -{ +u32 pspGetKirkVersion(void) { int k1 = pspSdkSetK1(0); - sceSysregKirkBusClockEnable(); sceKernelDelayThread(1000); int err = *(u32 *)0xBDE00004; - pspSdkSetK1(k1); - return err; } -u32 pspGetSpockVersion(void) -{ +u32 pspGetSpockVersion(void) { int k1 = pspSdkSetK1(0); - sceSysregAtaBusClockEnable(); sceKernelDelayThread(1000); int err = *(u32 *)0xBDF00004; pspSdkSetK1(k1); - return err; } -u32 pspNandGetScramble(void) -{ +u32 pspNandGetScramble(void) { int k1 = pspSdkSetK1(0); - - u32 magic; + u32 magic = 0; u32 buf[4]; u32 sha[5]; + buf[0] = *(vu32 *)(0xBC100090); buf[1] = *(vu32 *)(0xBC100094); buf[2] = *(vu32 *)(0xBC100090) << 1; buf[3] = 0xD41D8CD9; + sceKernelUtilsSha1Digest((u8 *)buf, sizeof(buf), (u8 *)sha); magic = (sha[0] ^ sha[3]) + sha[2]; pspSdkSetK1(k1); - return magic; } -void pspIdStorageLookup(u16 key, u32 offset, void *buf, u32 len) -{ +void pspIdStorageLookup(u16 key, u32 offset, void *buf, u32 len) { int k1 = pspSdkSetK1(0); memset(buf, 0, len); @@ -138,95 +113,78 @@ void pspIdStorageLookup(u16 key, u32 offset, void *buf, u32 len) 0x0C - Russia 0x0D - China */ - -int GetRegion(void) -{ +int pspGetRegion(void) { u8 region[1]; pspIdStorageLookup(0x100, 0x3D, region, 1); - if(region[0] == 0x03)//Japan + if (region[0] == 0x03)//Japan return 0; - else if(region[0] == 0x04)//America + else if (region[0] == 0x04)//America return 1; - else if(region[0] == 0x09)//Australia + else if (region[0] == 0x09)//Australia return 2; - else if(region[0] == 0x07)//United Kingdom + else if (region[0] == 0x07)//United Kingdom return 3; - else if(region[0] == 0x05)//Europe + else if (region[0] == 0x05)//Europe return 4; - else if(region[0] == 0x06)//Korea + else if (region[0] == 0x06)//Korea return 5; - else if(region[0] == 0x0A)//Hong-Kong + else if (region[0] == 0x0A)//Hong-Kong return 6; - else if(region[0] == 0x0B)//Taiwan + else if (region[0] == 0x0B)//Taiwan return 7; - else if(region[0] == 0x0C)//Russia + else if (region[0] == 0x0C)//Russia return 8; - else if(region[0] == 0x0D)//China + else if (region[0] == 0x0D)//China return 9; - else if(region[0] == 0x08)//Mexico + else if (region[0] == 0x08)//Mexico return 10; else return -1; } -char *GetInitialFW(char *buf) -{ +char *pspGetInitialFW(char *buf) { pspIdStorageLookup(0x51, 0, buf, 5); - if(buf[0] == 0) + + if (buf[0] == 0) sprintf(buf, "-"); return buf; } -int pspNandGetPageSize(void) -{ +int pspNandGetPageSize(void) { int k1 = pspSdkSetK1(0); - int ret = sceNandGetPageSize(); - pspSdkSetK1(k1); - return ret; } -int pspNandGetPagesPerBlock(void) -{ +int pspNandGetPagesPerBlock(void) { int k1 = pspSdkSetK1(0); - int ret = sceNandGetPagesPerBlock(); - pspSdkSetK1(k1); - return ret; } -int pspNandGetTotalBlocks(void) -{ +int pspNandGetTotalBlocks(void) { int k1 = pspSdkSetK1(0); - int ret = sceNandGetTotalBlocks(); - pspSdkSetK1(k1); - return ret; } -u8 *GetMACAddress(u8 *buf) -{ +u8 *pspGetMACAddress(u8 *buf) { sceWlanGetEtherAddr(buf); - return buf; } -u32 writeBat(u8 addr, u16 data) -{ +u32 pspWriteBat(u8 addr, u16 data) { int k1 = pspSdkSetK1(0); - int res; + int res = 0; u8 param[0x60]; - if(addr > 0x7F) + if (addr > 0x7F) return(0x80000102); param[0x0C] = 0x73; @@ -237,7 +195,7 @@ u32 writeBat(u8 addr, u16 data) res = sceSysconCmdExec(param, 0); - if(res < 0) + if (res < 0) return res; pspSdkSetK1(k1); @@ -245,22 +203,20 @@ u32 writeBat(u8 addr, u16 data) return 0; } -int WriteSerial(u16* serial) -{ +int pspWriteSerial(u16 *serial) { int err = 0; - err = writeBat(0x07, serial[0]); - if(!err) - err = writeBat(0x09, serial[1]); + err = pspWriteBat(0x07, serial[0]); + if (!err) + err = pspWriteBat(0x09, serial[1]); return err; } -u32 ReadEEPROM(u8 addr) -{ +u32 pspReadEEPROM(u8 addr) { u8 param[0x60]; - if(addr > 0x7F) + if (addr > 0x7F) return 0x80000102; param[0x0C] = 0x74; @@ -268,38 +224,35 @@ u32 ReadEEPROM(u8 addr) param[0x0E] = addr; int res = sceSysconCmdExec(param, 0); - if(res < 0) + if (res < 0) return res; return (param[0x21] << 8) | param[0x20]; } -int ReadSerial(u16* pdata) -{ +int pspReadSerial(u16 *pdata) { int err = 0; u32 data; u32 k1 = pspSdkSetK1(0); - int errCheck(u32 chdata) - { - if((chdata & 0x80250000) == 0x80250000) + int pspErrCheck(u32 chdata) { + if ((chdata & 0x80250000) == 0x80250000) return -1; - else if(chdata & 0xFFFF0000) + else if (chdata & 0xFFFF0000) return(chdata & 0xFFFF0000) >> 16; return 0; } - data = ReadEEPROM(0x07); - err = errCheck(data); + data = pspReadEEPROM(0x07); + err = pspErrCheck(data); - if(err >= 0) - { + if (err >= 0) { pdata[0] = (data & 0xFFFF); - data = ReadEEPROM(0x09); - err = errCheck(data); - if(err >= 0) + data = pspReadEEPROM(0x09); + err = pspErrCheck(data); + if (err >= 0) pdata[1] = (data & 0xFFFF); else err = data; @@ -312,12 +265,10 @@ int ReadSerial(u16* pdata) return err; } -int module_start(SceSize args, void *argp) -{ +int module_start(SceSize args __attribute__((unused)), void *argp __attribute__((unused))) { return 0; } -int module_stop(void) -{ +int module_stop(void) { return 0; } diff --git a/hardware_utils.c b/hardware_utils.c index 4d10eff..5c0d100 100644 --- a/hardware_utils.c +++ b/hardware_utils.c @@ -11,10 +11,8 @@ char macbuf[256]; -int GetFirstSymbolOfModel() -{ - switch(psp_model + 1) - { +int pspGetFirstSymbolOfModel(void) { + switch(psp_model + 1) { case 1: case 5: case 11: @@ -36,10 +34,9 @@ int GetFirstSymbolOfModel() return -1; } -char *GetRegionName() -{ - int region = GetRegion(); - if(region >= 0 && region < 11) +char *pspGetRegionName(void) { + int region = pspGetRegion(); + if (region >= 0 && region < 11) return trans->hardware.regname[region]; return "-"; @@ -47,16 +44,14 @@ char *GetRegionName() #define UNKNOWN 0x00000000 -typedef struct -{ +typedef struct { u32 tachyon; u32 baryon; u32 pommel; char *mobo_name; } Motherboard; -Motherboard detmobo[] = -{ +Motherboard detmobo[] = { /* PSP-100x */ { 0x00140000, 0x00030600, 0x00000103, "TA-079v1" }, { 0x00200000, 0x00030600, 0x00000103, "TA-079v2" }, @@ -94,18 +89,15 @@ Motherboard detmobo[] = { 0x00100000, UNKNOWN, UNKNOWN, "Devkit" }, }; -char *GetMoBoName() -{ +char *pspGetMoBoName(void) { char *ret_mobo = "-"; - - int i; - for(i = 0; i < sizeof(detmobo) / sizeof(Motherboard); i++) - if(detmobo[i].tachyon == tachyon && (detmobo[i].baryon == baryon || detmobo[i].baryon == UNKNOWN) && (detmobo[i].pommel == pommel || detmobo[i].pommel == UNKNOWN)) - { + + for(int i = 0; i < sizeof(detmobo) / sizeof(Motherboard); i++) + if (detmobo[i].tachyon == tachyon && (detmobo[i].baryon == baryon || detmobo[i].baryon == UNKNOWN) && (detmobo[i].pommel == pommel || detmobo[i].pommel == UNKNOWN)) { /* TA-088v1(3.95) / TA-088v2 (4.01) */ - if(i == 9 /* TA-088v1 */ && !strncmp(GetInitialFW(), "4.01", 4)) + if (i == 9 /* TA-088v1 */ && !strncmp(pspGetInitialFW(), "4.01", 4)) continue; - else if(i == 10 /* TA-088v2 */ && strncmp(GetInitialFW(), "3.95", 4)) + else if (i == 10 /* TA-088v2 */ && strncmp(pspGetInitialFW(), "3.95", 4)) ret_mobo = "TA-088v1/v2"; ret_mobo = detmobo[i].mobo_name; @@ -114,28 +106,22 @@ char *GetMoBoName() return ret_mobo; } -char *GetUMDFWText() -{ - _sceUmdExecInquiryCmd(_sceUmdManGetUmdDrive(0), param, buf); +char *pspGetUMDFWText(void) { + pspUmdExecInquiryCmd(pspUmdManGetUmdDrive(0), param, buf); memset(outtxt, 0, sizeof(outtxt)); memcpy(&ai, buf, sizeof(ATAPI_INQURIY)); strncpy(outtxt, ai.sony_spec, 5); - return outtxt; } -char *GetMacAddressText() -{ +char *pspGetMacAddressText(void) { u8 macaddr[512]; - GetMACAddress(macaddr); + pspGetMACAddress(macaddr); sprintf(macbuf, "%02X:%02X:%02X:%02X:%02X:%02X", macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]); - return macbuf; } -char *GetModelName() -{ +char *pspGetModelName(void) { char *models[] = { "PSP Fat", "PSP Slim", "PSP Brite", "PSP Brite", "PSPgo", "-", "PSP Brite", "-", "PSP Brite", "-", "PSP Street" }; - return models[psp_model]; } diff --git a/hardware_utils.h b/hardware_utils.h index 5c515b2..f90a63c 100644 --- a/hardware_utils.h +++ b/hardware_utils.h @@ -1,11 +1,11 @@ #ifndef ___HARDWARE_UTILS_H___ #define ___HARDWARE_UTILS_H___ -int GetFirstSymbolOfModel(); -char *GetRegionName(); -char *GetMoBoName(); -char *GetUMDFWText(); -char *GetMacAddressText(); -char *GetModelName(); +int pspGetFirstSymbolOfModel(void); +char *pspGetRegionName(void); +char *pspGetMoBoName(void); +char *pspGetUMDFWText(void); +char *pspGetMacAddressText(void); +char *pspGetModelName(void); #endif diff --git a/kumdman.h b/kumdman.h index dcdb33a..c76aad6 100644 --- a/kumdman.h +++ b/kumdman.h @@ -19,7 +19,7 @@ ATAPI_INQURIY ai; u8 buf[0x38]; u8 param[4] = { 0, 0, 0x38, 0 }; -void *_sceUmdManGetUmdDrive(int driveNum); -int _sceUmdExecInquiryCmd(void *drive, u8 *param, u8 *buf); +void *pspUmdManGetUmdDrive(int driveNum); +int pspUmdExecInquiryCmd(void *drive, u8 *param, u8 *buf); #endif diff --git a/kumdman/exports.exp b/kumdman/exports.exp index 2a972ec..7559c99 100644 --- a/kumdman/exports.exp +++ b/kumdman/exports.exp @@ -6,8 +6,8 @@ PSP_BEGIN_EXPORTS PSP_EXPORT_END PSP_EXPORT_START(pspUmdMan_driver, 0, 0x4001) - PSP_EXPORT_FUNC_HASH(_sceUmdExecInquiryCmd) - PSP_EXPORT_FUNC_HASH(_sceUmdManGetUmdDrive) + PSP_EXPORT_FUNC_HASH(pspUmdExecInquiryCmd) + PSP_EXPORT_FUNC_HASH(pspUmdManGetUmdDrive) PSP_EXPORT_END PSP_END_EXPORTS \ No newline at end of file diff --git a/kumdman/main.c b/kumdman/main.c index 8dedbcf..12173b5 100644 --- a/kumdman/main.c +++ b/kumdman/main.c @@ -7,32 +7,24 @@ PSP_MAIN_THREAD_ATTR(0); int sceUmdManGetUmdDrive(int driveNum); int sceUmdExecInquiryCmd(void *drive, u8 *param, u8 *buf); -void *_sceUmdManGetUmdDrive(int driveNum) -{ +void *pspUmdManGetUmdDrive(int driveNum) { int k1 = pspSdkSetK1(0); void *drive = (void *)sceUmdManGetUmdDrive(driveNum); - pspSdkSetK1(k1); - return drive; } -int _sceUmdExecInquiryCmd(void *drive, u8 *param, u8 *buf) -{ +int pspUmdExecInquiryCmd(void *drive, u8 *param, u8 *buf) { int k1 = pspSdkSetK1(0); int res = sceUmdExecInquiryCmd(drive, param, buf); - pspSdkSetK1(k1); - return(res); } -int module_start(SceSize args, void *argp) -{ +int module_start(SceSize args __attribute__((unused)), void *argp __attribute__((unused))) { return 0; } -int module_stop() -{ +int module_stop(void) { return 0; } diff --git a/libs/include/systemctrl.h b/libs/include/systemctrl.h new file mode 100644 index 0000000..831d087 --- /dev/null +++ b/libs/include/systemctrl.h @@ -0,0 +1,401 @@ +#ifndef __SCTRLLIBRARY_H__ +#define __SCTRLLIBRARY_H__ + +#if defined (__cplusplus) +extern "C" { +#endif + +#include +#include +#include +#include + +enum BootLoadFlags +{ + BOOTLOAD_VSH = 1, + BOOTLOAD_GAME = 2, + BOOTLOAD_UPDATER = 4, + BOOTLOAD_POPS = 8, + BOOTLOAD_UMDEMU = 64, /* for original NP9660 */ +}; + +/** + * Restart the vsh. + * + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL + * + * @returns < 0 on some errors. + * +*/ +int sctrlKernelExitVSH(struct SceKernelLoadExecVSHParam *param); + +/** + * Executes a new executable from a disc. + * It is the function used by the firmware to execute the EBOOT.BIN from a disc. + * + * @param file - The file to execute. + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. + * + * @returns < 0 on some errors. +*/ +int sctrlKernelLoadExecVSHDisc(const char *file, struct SceKernelLoadExecVSHParam *param); + +/** + * Executes a new executable from a disc. + * It is the function used by the firmware to execute an updater from a disc. + * + * @param file - The file to execute. + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. + * + * @returns < 0 on some errors. +*/ +int sctrlKernelLoadExecVSHDiscUpdater(const char *file, struct SceKernelLoadExecVSHParam *param); + +/** + * Executes a new executable from a memory stick. + * It is the function used by the firmware to execute an updater from a memory stick. + * + * @param file - The file to execute. + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. + * + * @returns < 0 on some errors. +*/ +int sctrlKernelLoadExecVSHMs1(const char *file, struct SceKernelLoadExecVSHParam *param); + +/** + * Executes a new executable from a memory stick. + * It is the function used by the firmware to execute games (and homebrew :P) from a memory stick. + * + * @param file - The file to execute. + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. + * + * @returns < 0 on some errors. +*/ +int sctrlKernelLoadExecVSHMs2(const char *file, struct SceKernelLoadExecVSHParam *param); +int sctrlKernelLoadExecVSHEf2(const char *file, struct SceKernelLoadExecVSHParam *param); + +/** + * Executes a new executable from a memory stick. + * It is the function used by the firmware to execute ... ? + * + * @param file - The file to execute. + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. + * + * @returns < 0 on some errors. +*/ +int sctrlKernelLoadExecVSHMs3(const char *file, struct SceKernelLoadExecVSHParam *param); + +/** + * Executes a new executable from a memory stick. + * It is the function used by the firmware to execute psx games + * + * @param file - The file to execute. + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. + * + * @returns < 0 on some errors. +*/ +int sctrlKernelLoadExecVSHMs4(const char *file, struct SceKernelLoadExecVSHParam *param); + + +/** + * Executes a new executable with the specified apitype + * + * @param apitype - The apitype + * @param file - The file to execute. + * @param param - Pointer to a ::SceKernelLoadExecVSHParam structure, or NULL. + * + * @returns < 0 on some errors. +*/ +int sctrlKernelLoadExecVSHWithApitype(int apitype, const char *file, struct SceKernelLoadExecVSHParam *param); + +/** + * Sets the api type + * + * @param apitype - The apitype to set + * @returns the previous apitype + * + * @Note - this will modify also the value of sceKernelBootFrom, since the value of + * bootfrom is calculated from the apitype +*/ +int sctrlKernelSetInitApitype(int apitype); + +/** + * Sets the filename of the launched executable. + * + * @param filename - The filename to set + * @returns 0 on success +*/ +int sctrlKernelSetInitFileName(char *filename); + +/** + * Sets the init key config + * + * @param key - The key code + * @returns the previous key config +*/ +int sctrlKernelSetInitKeyConfig(int key); + +/** + * Sets the user level of the current thread + * + * @param level - The user level + * @return the previous user level on success + */ +int sctrlKernelSetUserLevel(int level); + +/** + * Sets the devkit version + * + * @param version - The devkit version to set + * @return the previous devkit version + * +*/ +int sctrlKernelSetDevkitVersion(int version); + +/** + * Checks if we are in SE. + * + * @returns 1 if we are in SE-C or later, 0 if we are in HEN-D or later, + * and < 0 (a kernel error code) in any other case +*/ +int sctrlHENIsSE(); + +/** + * Checks if we are in Devhook. + * + * @returns 1 if we are in SE-C/HEN-D for devhook or later, 0 if we are in normal SE-C/HEN-D or later, + * and < 0 (a kernel error code) in any other case +*/ +int sctrlHENIsDevhook(); + +/** + * Gets the HEN version + * + * @returns - The HEN version + * + * HEN D / SE-C : 0x00000400 + */ +int sctrlHENGetVersion(); + +/** + * Gets the HEN minor version + * + * @returns - The HEN minor version + */ +int sctrlHENGetMinorVersion(); + +/** + * Finds a driver + * + * @param drvname - The name of the driver (without ":" or numbers) + * + * @returns the driver if found, NULL otherwise + * + */ +PspIoDrv *sctrlHENFindDriver(char *drvname); + +/** + * Finds a function. + * + * @param modname - The module where to search the function + * @param libname - The library name + * @nid - The nid of the function + * + * @returns - The function address or 0 if not found + * +*/ +u32 sctrlHENFindFunction(char *modname, char *libname, u32 nid); + +typedef struct SceModule2 { + struct SceModule2 *next; + unsigned short attribute; + unsigned char version[2]; + char modname[27]; + char terminal; + unsigned int unknown1; + unsigned int unknown2; + SceUID modid; + unsigned int unknown3[2]; + u32 mpid_text; // 0x38 + u32 mpid_data; // 0x3C + void * ent_top; + unsigned int ent_size; + void * stub_top; + unsigned int stub_size; + unsigned int unknown4[5]; + unsigned int entry_addr; + unsigned int gp_value; + unsigned int text_addr; + unsigned int text_size; + unsigned int data_size; + unsigned int bss_size; + unsigned int nsegment; + unsigned int segmentaddr[4]; + unsigned int segmentsize[4]; +} SceModule2; + +typedef int (* STMOD_HANDLER)(SceModule2 *); + +/** + * Sets a function to be called just before module_start of a module is gonna be called (useful for patching purposes) + * + * @param handler - The function, that will receive the module structure before the module is started. + * + * @returns - The previous set function (NULL if none); + * @Note: because only one handler function is handled by HEN, you should + * call the previous function in your code. + * + * @Example: + * + * STMOD_HANDLER previous = NULL; + * + * int OnModuleStart(SceModule2 *mod); + * + * void somepointofmycode() + * { + * previous = sctrlHENSetStartModuleHandler(OnModuleStart); + * } + * + * int OnModuleStart(SceModule2 *mod) + * { + * if (strcmp(mod->modname, "vsh_module") == 0) + * { + * // Do something with vsh module here + * } + * + * if (!previous) + * return 0; + * + * // Call previous handler + * + * return previous(mod); + * } + * + * @Note2: The above example should be compiled with the flag -fno-pic + * in order to avoid problems with gp register that may lead to a crash. + * +*/ +STMOD_HANDLER sctrlHENSetStartModuleHandler(STMOD_HANDLER handler); + +typedef int (* KDEC_HANDLER)(u32 *buf, int size, int *retSize, int m); +typedef int (* MDEC_HANDLER)(u32 *tag, u8 *keys, u32 code, u32 *buf, int size, int *retSize, int m, void *unk0, int unk1, int unk2, int unk3, int unk4); + +/** + * Sets the speed (only for kernel usage) + * + * @param cpu - The cpu speed + * @param bus - The bus speed +*/ +void sctrlHENSetSpeed(int cpu, int bus); + +/** + * Sets the partition 2 and 8 memory for next loadexec. + * + * @param p2 - The size in MB for the user partition. Must be > 0 + * @param p8 - The size in MB for partition 8. Can be 0. + * + * @returns 0 on success, < 0 on error. + * This function is only available in the slim. The function will fail + * if p2+p8 > 52 or p2 == 0 +*/ +int sctrlHENSetMemory(u32 p2, u32 p8); + +void sctrlHENPatchSyscall(void *addr, void *newaddr); + +int sctrlKernelQuerySystemCall(void *func_addr); + +int sctrlKernelBootFrom(void); + +/** + * Patch module by offset + * + * @param modname - module name + * @param inst - instruction + * @param offset - module patch offset + * + * @return < 0 on error + */ +int sctrlPatchModule(char *modname, u32 inst, u32 offset); + +/** + * Get module text address + * + * @param modname - module name + * + * @return text address, or 0 if not found + */ +u32 sctrlModuleTextAddr(char *modname); + +/** + * Get sceInit module text address + * + * @note Only useful before sceInit exits + * + * @return text address, or 0 if not found + */ +u32 sctrlGetInitTextAddr(void); + +/** + * Set custom start module handler + * It can be used to replace a system module + * + * @note: func returns -1 to ignore the module and load the original module. Or new modid if replace is done. + */ +void sctrlSetCustomStartModule(int (*func)(int modid, SceSize argsize, void *argp, int *modstatus, SceKernelSMOption *opt)); + +/** + * Loads a module on next reboot. Only kernel mode. + * + * @param module_after - The path of the module which is loaded after the module to be loaded. + The module passed to this function will be loaded just before that module. + * @param buf - The buffer containing the module - Don't deallocate this one. It has to reside in kernel memory. + * @param size - The size of the module + * @param flags - The modes in which the module should be loaded, one of BootLoadFlags + * + * @Example: + * sctrlHENLoadModuleOnReboot("/kd/usersystemlib.prx", module_buffer, module_size, BOOTLOAD_GAME | BOOTLOAD_POPS | BOOTLOAD_UMDEMU); + * + * This will load the module contained in module_buffer just before /kd/usersystemlib.prx in the next reboot, if the mode of next reboot is game, pops or umdemu + * + * @Remarks: Don't use too early modules in first param like "/kd/init.prx" or "/kd/systemctrl.prx", or your module may not load properly + * Only one module will be loaded on reboot with this function. + * If this function is called many times, only the last one will be considered. + * By making a module to load itself using this function, and calling + * sctrlHENLoadModuleOnReboot on module_start, a prx can cause itself to be resident in the modes choosen by flags. + * If all flags are selected, the module will stay resident until a psp shutdown, or until sctrlHENLoadModuleOnReboot is not called. +*/ + +void sctrlHENLoadModuleOnReboot(char *module_after, void *buf, int size, int flags); + +/** + * Enable/disable NID Resolver on particular library + * + * @param libname the name of the library to be enabled/disabled + * @param enabled 0 - disabled, != 0 - enabled + * + * @Example: + * sctrlKernelSetNidResolver("sceImpose_driver", 0); // disable sceImpose_driver resolving + * + * @return previous value if set, < 0 on error + */ +int sctrlKernelSetNidResolver(char *libname, u32 enabled); + +/** + * Get a random u32 key from PSP Kirk PRNG + */ +u32 sctrlKernelRand(void); + +/** + * Get the real unspoofed Ethernet (MAC) Address of the systems WLAN chip + * + * @param mac Out-Buffer (6B) for real MAC Address + * + * @return 0 on success, < 0 on error + */ +int sctrlGetRealEthernetAddress(uint8_t * mac); + +#if defined (__cplusplus) +} +#endif + +#endif diff --git a/libs/include/vlf.h b/libs/include/vlf.h new file mode 100644 index 0000000..38d8e00 --- /dev/null +++ b/libs/include/vlf.h @@ -0,0 +1,2035 @@ +#ifndef __VLF_H__ +#define __VLF_H__ + +typedef struct _VlfText *VlfText; +typedef struct _VlfPicture *VlfPicture; +typedef struct _VlfShadowedPicture *VlfShadowedPicture; +typedef struct _VlfBatteryIcon *VlfBatteryIcon; +typedef struct _VlfSpin *VlfSpin; +typedef struct _VlfCheckBox *VlfCheckBox; +typedef struct _VlfProgressBar *VlfProgressBar; +typedef struct _VlfScrollBar *VlfScrollBar; +typedef struct _VlfInputBox *VlfInputBox; + + +#define VLF_DEFAULT -1 + +#define VLF_TITLEBAR_HEIGHT 22 + +#define VLF_ERROR_INVALID_INPUT (-1) +#define VLF_ERROR_INVALID_INPUT_DATA (-2) +#define VLF_ERROR_UNSUPPORTED_FORMAT (-3) +#define VLF_ERROR_OBJECT_OVERFLOW (-4) +#define VLF_ERROR_OBJECT_NOT_FOUND (-5) +#define VLF_ERROR_NO_MEMORY (-6) +#define VLF_ERROR_SYSTEM (-7) +#define VLF_ERROR_DUPLICATED (-8) + + +#define VLF_EV_RET_NOTHING 0 +#define VLF_EV_RET_REMOVE_EVENT 1 +#define VLF_EV_RET_REMOVE_OBJECTS 2 +#define VLF_EV_RET_REMOVE_HANDLERS 4 +#define VLF_EV_RET_REFRESH_ON_DELAY 8 +#define VLF_EV_RET_DELAY 0x80000000 /* Delay VLF_EV_RET_DELAY | (X << 16), 0 <= X <= 32767 milisecs */ +#define VLF_EV_RET_DELAY_FRAME (VLF_EV_RET_DELAY | 0x40000000) /* Delay VLF_EV_RET_DELAY_FRAME| (X << 16), 0 <= X <= 4095 */ + +/* Alignment */ + +enum VlfObjects +{ + VLF_TEXT = 0, + VLF_PIC = 1, + VLF_SHADOWED_PIC = 2, + VLF_PROGRESS_BAR = 3 +}; + +enum VlfTextAlignment +{ + VLF_ALIGNMENT_LEFT = 0, + VLF_ALIGNMENT_CENTER = 0x200, + VLF_ALIGNMENT_RIGHT = 0x400 +}; + +enum VlfButtonIcon +{ + VLF_ENTER = 0, + VLF_CANCEL = 1, + VLF_CROSS = 2, + VLF_CIRCLE = 3, + VLF_TRIANGLE = 4, + VLF_SQUARE = 5 +}; +/** Fade modes */ + +enum VlfFadeModesFlags +{ + VLF_FADE_MODE_IN = 1, + VLF_FADE_MODE_OUT = 2, + VLF_FADE_MODE_REPEAT = 4, +}; + +enum VlfFadeSpeed +{ + VLF_FADE_SPEED_STANDARD, + VLF_FADE_SPEED_FAST, + VLF_FADE_SPEED_VERY_FAST, + VLF_FADE_SPEED_SLOW, + VLF_FADE_SPEED_SUPER_FAST +}; + +enum VlfBatteryIconStatus +{ + VLF_BATTERY_ICON_HIGH, + VLF_BATTERY_ICON_MEDIUM, + VLF_BATTERY_ICON_LOW, + VLF_BATTERY_ICON_LOWEST +}; + +enum RCOType +{ + RCO_GRAPHIC, + RCO_OBJECT, + RCO_SOUND, + RCO_LABEL, + RCO_FILEPARAM, + RCO_ANIMPARAM +}; + +enum VLF_MDType +{ + VLF_MD_TYPE_ERROR, + VLF_MD_TYPE_NORMAL, +}; + +enum VLF_MD_Buttons +{ + VLF_MD_BUTTONS_NONE = 0, + VLF_MD_BUTTONS_YESNO = 0x10, +}; + +enum VLF_MD_InitalCursor +{ + VLF_MD_INITIAL_CURSOR_YES = 0, + VLF_MD_INITIAL_CURSOR_NO = 0x100, +}; + +enum VLF_MD_ButtonRes +{ + VLF_MD_NONE, + VLF_MD_YES, + VLF_MD_NO, + VLF_MD_BACK +}; + +enum VLF_DialogItem +{ + VLF_DI_ENTER, + VLF_DI_CANCEL, + VLF_DI_BACK, + VLF_DI_YES, + VLF_DI_NO, + VLF_DI_EDIT, +}; + +enum VLF_SpinState +{ + VLF_SPIN_STATE_NOT_FOCUS, // Spin control has not focus, buttons are not listened + VLF_SPIN_STATE_FOCUS, // Spin control text has focus but arrow is not shown, buttons are not listened + VLF_SPIN_STATE_ACTIVE, // Spin control has focus, and it is active (arrows are shown, up and down buttons are listened) +}; + +enum VLF_InputBoxType +{ + VLF_INPUTBOX_TYPE_NORMAL, + VLF_INPUTBOX_TYPE_PASSWORD +}; + +enum PspCtrlExtension +{ + PSP_CTRL_ENTER = 0x40000000, + PSP_CTRL_CANCEL = 0x80000000 +}; + +/** + * Inits VLF library + * + * @param heap_size - The heap size to be allocated. It can be negative. + * @param app_main - The program main application. +*/ +void vlfGuiInit(int heap_size, int (* app_main)(int argc, char *argv[])); + +/** + * Performs typical application initialization tasks (adding background, system model, and optionally battery icon and clock). + * + * @param battery - Inidicates if a battery icon should be added. + * @param clock - Indicates if a clock should be added. + * @param notuserwp - If user configuration is set to use a custom background and this param is 1, then the custom wallpaper won't be used. + * + * @returns 0 on success + * + * @Notes: If an user wallpaper is used, the background model ("waves") won't be added. + */ +int vlfGuiSystemSetup(int battery, int clock, int notuserwp); + +/** + * Gets language used by vlf application + * + * @returns - The language set to be used by current vlf application + * By default is initialized to user language. +*/ +int vlfGuiGetLanguage(); + +/** + * Sets language to be used by blf application + * + * @param lang - The language to be set. + * This only sets the language to be used by current vlf application, + * it doesn't overwrite user preferences in flash. + */ +void vlfGuiSetLanguage(int lang); + +/** + * Gets the button configuration used by vlf application (0 -> circle is enter, 1 -> cross is enter) + * + * @returns - The button configuration set to be used by current vlf application. + * By default is initialized with user preferences. +*/ +int vlfGuiGetButtonConfig(); + +/** + * Sets the button configuration to be used by current vlf application. + * + * @param config - The button configuration to be set (0 -> circle is enter, 1 -> cross is enter) + * This only sets the button configuration to be used by current vlf application, + * it doesn't overwrite user preferences in flash. +*/ +void vlfGuiSetButtonConfig(int config); + +/** + * Sets the directories where resources are located. + * + * @param dir - The directory that will be used to locate resources (max 256 chars including '\0') + * By default is initialized to flash0:/vsh/resource +*/ +void vlfGuiSetResourceDir(char *dir); + +/** + * Performs the draw of next frame +*/ +void vlfGuiDrawFrame(); + +/** + * Loads resources from a rco file + * + * @param rco - It can be one of following things: + * - path relative to the directory without extension (e.g. "system_plugin_bg") + * - path relative to the directory with extension (e.g. "system_plugin_bg.rco") + * - path to a file (e.g. "flash0:/vsh/resource/system_plugin_bg.rco", "ms0:/myresfile.rco") + * + * RCO param is evaluated in the order given above, so if a rco file exists in current directory with name + * "system_plugin_bg.rco", it would load the one of and not the one of current directory. (in such a case, use "./system_plugin_bg.rco") + * + * @param n - The number of resources to loads + * @param names (IN) - An array with the names of resources + * @param types (IN) - An array with the types of the resources (one of RCOType) + * @param datas (OUT) - A pointer to a variable that will receive an array of pointers to the content of each resource, + * or NULL if a specific resource has not been found. + * Pointers returned are allocated with malloc, and should be deallocated by the application. + * + * @param sizes (OUT) - It will receive the sizes of the resources + * @param pntable (OUT) - A pointer that will receive the string table. Pass NULL if no required. + * Returned pointer is allocated with malloc and should be deallocated by the application. + * + * @returns - the number of resources loaded, or < 0 if there is an error. + * + * @Example: Load battery icon pic and shadow + * + * char *names[2]; + * void *datas[2]; + * int types[2], sizes[2]; + * + * names[0] = "tex_battery"; + * names[1] = "tex_battery_shadow"; + * types[0] = types[1] = RCO_GRAPHIC; + * + * int res = vlfGuiLoadResources("system_plugin_fg", 2, names, types, datas, sizes, NULL); + * if (res != 2) // error or not all resources loaded + * { + * if (res > 0) + * { + * if (datas[0]) + * free(datas[0]); + * if (datas[1]) + * free(datas[1]); + * } + * } + * else + * { + * void *bat; + * vlfGuiAddShadowedPicture(&bat, datas[0], sizes[0], datas[1], sizes[1], 441, 4, 1, 1, 1); + * free(datas[0]); + * free(datas[1]); + * } + * +*/ +int vlfGuiLoadResources(char *rco, int n, char **names, int *types, void **datas, int *sizes, char **pntable); + +/** + * Caches a resource in RAM, so it doesn't have to be loaded from storage device anymore. + * + * @param rco - The resource. Same rules apply to this param + * + * @returns - < 0 on error. +*/ +int vlfGuiCacheResource(char *rco); + +/** + * Uncaches a resource previously cached. + * + * @param rco - The resource to be uncached. + * + * @returns - < 0 on error. +*/ +int vlfGuiUncacheResource(char *rco); + + +//int vlfGuiGetResourceSubParam(void *entry, int insize, char *ntable, char *name, void **data, int *size); + +/** + * Loads an unicode string from a resource. + * + * @param str - Buffer that receives the string + * @param rco - The resource file to load the label from. + * @param name - The name of the resource + * + * @returns - < 0 on error. +*/ +int vlfGuiLoadLabel(u16 *str, char *rco, char *name); + +/** + * Sets the background from 8888 texture data + * + * @param texture - The texture data in 8888 format + * @param width - The width of texture. Must be a power of 2. + * @param height - The height of texture. Must be multiple of 8. + * @param swizzled - Indicates if the texture is already in the psp GE fast texture format + * @param scale_x - The x scale to apply + * @param scale_y - The y scale to apply + * + * @returns 0 on success, or < 0 on error (params invalid) +*/ +int vlfGuiSetBackground(u32 *texture, int width, int height, int swizzled, float scale_x, float scale_y); + +/** + * Sets the background from a file buffer. + * Supported formats are currently: BMP, TIM, GIM and PNG, with a depth of 24 or 32 bits. + * + * @param data - The buffer with the file data + * @param size - The size of the data + * @param scale - Wether to scale the image. If it is 0, the image will be centered and filled by black. + * + * @returns - 0 on success, < 0 on error. +*/ +int vlfGuiSetBackgroundFileBuffer(void *data, int size, int scale); + +/** + * Sets the background from a file + * Supported formats are currently: BMP, TIM, GIM and PNG, with a depth of 24 or 32 bits. + * + * @param file - Path to the file. + * @param scale - Wether to scale the image. If it is 0, the image will be centered and filled by black. + * + * @returns - 0 on success, < 0 on error. +*/ +int vlfGuiSetBackgroundFile(char *file, int scale); + +/** + * Sets one of system backgrounds based on the index. + * + * @param index - The index of the background, valid values are 1-27 + * (note that 13-27 is only available on slim and will return an error on old psp) + * + * @returns 0 on success, < 0 on error +*/ +int vlfGuiSetBackgroundIndex(int index); + +/** + * Sets one of system backgrounds based on the current date + * + * @returns 0 on success, < 0 on error +*/ +int vlfGuiSetBackgroundDate(); + +/** + * Sets a background of a single color + * + * @param color - The color in XXBBGGRR format (XX is ignored). + * + * @returns - this functions always succeeds returning 0 +*/ +int vlfGuiSetBackgroundPlane(u32 color); + +/** + * Sets the background according to the system configuration + * + * @returns - 0 on success, < 0 on error. +*/ +int vlfGuiSetBackgroundSystem(int notuserwp); + +/** + * Sets the system color, used in titlebars or menus + * + * @param index - the index of the color, 1-27 +*/ +void vlfGuiSetSystemColor(int index); + +/** + * Sets the background model from a buffer. + * + * @param data - The buffer with the model in GMO format + * @param size - The size of the model + * + * @returns - 0 on success, < 0 on error. +*/ +int vlfGuiSetModel(void *data, int size); + +/** + * Sets the background model from a file. + * + * @param file - The file with the model in GMO format + * + * @returns - 0 on success, < 0 on error. +*/ +int vlfGuiSetModelFile(char *file); + +/** + * Sets the background model from a resource. + * + * @param rco - The path to the RCO file + * @param name - The name of the resource + * + * @returns - 0 on success, < 0 on error. +*/ +int vlfGuiSetModelResource(char *rco, char *name); + +/** + * Sets the background model of the system, and applies the proper world matrix to it. + * + * @returns 0 on success, < 0 on error. +*/ +int vlfGuiSetModelSystem(); + +/** + * Sets the world matrix for the model. (by default, the world matrix is the identity + * after a model has been loaded, except when calling vlfGuiSetModelSystem). + * + * @param matrix - The matrix to set. + * + * @Example: Load waves (this sample assumes the default scale of 8.5) + * + * int res = vlfGuiSetModelResource("system_plugin_bg", "mdl_bg"); + * if (res < 0) process_error; + * + * ScePspFMatrix4 matrix; + * ScePspFVector3 scale; + * + * scale.x = scale.y = scale.z = 8.5f; + * gumLoadIdentity(&matrix); + * gumScale(&matrix, &scale); + * vlfGuiSetModelWorldMatrix(&matrix); +*/ +void vlfGuiSetModelWorldMatrix(ScePspFMatrix4 *matrix); + +/** + * Gets the world matrix of the model + * + * @returns a pointer to the model world matrix +*/ +ScePspFMatrix4 *vlfGuiGetModelWorldMatrix(); + +/** + * Sets the model speed + * + * @param speed - The speed, default model speed is 1.0f/60.0f +*/ +void vlfGuiSetModelSpeed(float speed); + +/** + * Sets a title bar with the current system color. + * + * @param text - Text of the title bar. Pass NULL if no required. + * @param pic - Picture of the title bar. Pass NULL if no required. + * @param visible - If the tile bar will be visible + * @param hideobj - If 1, it will hide objects that were current added within the area of the title bar. + */ +void vlfGuiSetTitleBar(VlfText text, VlfPicture pic, int visible, int hideobj); + +/** + * Sets a title bar with the desired color. + * + * @param text - Text of the title bar. Pass NULL if no required. + * @param pic - Picture of the title bar. Pass NULL if no required. + * @param visible - If the tile bar will be visible + * @param hideobj - If 1, it will hide objects that were current added within the area of the title bar. + * @param color - The color of the title bar. +*/ +void vlfGuiSetTitleBarEx(VlfText text, VlfPicture pic, int visible, int hideobj, u32 color); + +/** + * Sets the tile bar visibility. +*/ +void vlfGuiSetTitleBarVisibility(int visible); + +/** + * Adds a new text item from an ascii string. + * + * @param x - x position + * @param y - y position + * @param string - ascii string with the desired text + * + * @returns a VlfText item on success, NULL on error. +*/ +VlfText vlfGuiAddText(int x, int y, char *string); + +/** + * Adds a new text item from an unicode string. + * + * @param x - x position + * @param y - y position + * @param string - unicode string with the desired text + * + * @returns a VlfText item on success, NULL on error. +*/ +VlfText vlfGuiAddTextW(int x, int y, u16 *string); + +/** + * Adds a new text item from a string with format + * + * @param x - x position + * @param y - y position + * @param fmt - string with format + * + * @returns a VlfText item on success, NULL on error. +*/ +VlfText vlfGuiAddTextF(int x, int y, char *fmt, ...); + +/** + * Adds a new text item from a resource label + * + * @param rco - The resource file to load the label from. + * @param name - The name of the resource. + * @param x - x position + * @param y - y position + * + * @returns a VlfText item on success, NULL on error. +*/ +VlfText vlfGuiAddTextResource(char *rco, char *name, int x, int y); + +/** + * Removes a text item. + * + * @param text - The text item to remove + * + * @returns - < 0 on error. +*/ +int vlfGuiRemoveText(VlfText text); + +/** + * Sets the text of a VlfText item from an ascii string. + * + * @param text - The text item + * @param string - The ascii string to set. + * + * @returns - < 0 on error. +*/ +int vlfGuiSetText(VlfText text, char *string); + +/** + * Sets the text of a VlfText item from an unicode string. + * + * @param text - The text item + * @param string - The unicode string to set. + * + * @returns - < 0 on error. +*/ +int vlfGuiSetTextW(VlfText text, u16 *string); + +/** + * Sets the text of a VlfText item from a string with format. + * + * @param text - The text item + * @param fmt - The string with format. + * + * @returns - < 0 on error. +*/ +int vlfGuiSetTextF(VlfText text, char *fmt, ...); + +/** + * Sets the text of a VlfText item from a resource label. + * + * @param text - The text item + * @param rco - The resource file to load the label from. + * @param name - The name of the resource. + * + * @returns - < 0 on error. +*/ +int vlfGuiSetTextResource(VlfText text, char *rco, char *name); + +/** + * Sets focus on a VlfText item. + * + * @param text - The text item to set the focus. + * + * @returns - < 0 on error. + * + * @Note: this function should only be used with a text with a single line, and + * with default font size. +*/ +int vlfGuiSetTextFocus(VlfText text); + +/** + * Removes focus on a VlfText item previously focused. + * + * @param text - The text item to remove focus. + * + * @returns - < 0 on error. +*/ +int vlfGuiRemoveTextFocus(VlfText text, int keepres); + +/** + * Sets the visibility of a VlfText item. + * + * @param text - The text item. + * @param visible - boolean for the visibility. + * + * @returns - < 0 on error. +*/ +int vlfGuiSetTextVisibility(VlfText text, int visible); + +/** + * Makes a VlfText item to blink. + * + * @param text - The text item to set blinking. + * @param nshow - The number of frames the item will be shown. + * @param nhide - The number of frames the item wil be hidden. + * + * @returns - < 0 on error + * + * @Notes: To remove blinking, pass both params to 0. +*/ +int vlfGuiSetTextBlinking(VlfText text, u32 nshow, u32 nhide); + +/** + * Makes a VlfText item to fade. + * + * @param text - The text item to fade. + * @param mode - Whatever OR combination of VlfFadeModesFlags + * @param speed - The fade speed, one of VlfFadeSpeed + * @param direction_out - If both, VLF_FADE_MODE_IN and VLF_FADE_MODE_OUT, were specified, this param indicates + * wether to start from direction out or in. Otherwise, it is ignored. + * + * @returns - < 0 on error. +*/ +int vlfGuiSetTextFade(VlfText text, int mode, int speed, int direction_out); + +/** + * Cancels a VlfText item fade. + * + * @param text - The text item to remove fade. + * + * @returns - < 0 on error +*/ +int vlfGuiCancelTextFade(VlfText text); + +/** + * Sets a callback to report the end of a fade. + * + * @param text - The text item fading. + * @param callback - The callback function that will be called at end of fade. + * @param param - param that will be passed to the callback function + * @param delay - The delay between the end of fade and the call to the callback + * + * @returns - < 0 on error +*/ +int vlfGuiSetTextFadeFinishCallback(VlfText text, void (* callback)(void *), void *param, int delay); + +/** + * Sets text item alignment + * + * @param text - The text item to set alignment + * @param alignment - One of VlfTextAlignment values + * + * @returns - < 0 on error +*/ +int vlfGuiSetTextAlignment(VlfText text, int alignment); + +/** + * Sets text position + * + * @param text - The text item to set position + * @param x - The x position + * @param y - The y position + * + * @returns - < 0 on error +*/ +int vlfGuiSetTextXY(VlfText text, int x, int y); + +/** + * Sets the font size of a text item + * + * @param text - The text to set font size + * @param size - The size of the font + * + * @returns - < 0 on error +*/ +int vlfGuiSetTextFontSize(VlfText text, float size); + +/** + * Returns the size of a text item. + * + * @param text - The text item yo get size from + * @param width - pointer to a variable that receives the width + * @param height - pointer to a variable that receivs the height + * + * @returns - < 0 on error +*/ +int vlfGuiGetTextSize(VlfText text, int *width, int *height); + +/** + * Sets a scrollbar in the specified text item. + * + * @param text - The text item + * @param height - The height of the scrollbar + * + * @returns - < 0 on error +*/ +int vlfGuiSetTextScrollBar(VlfText text, int height); + +/** + * Sets a scrollbar in the specified text item (with more options) + * + * @param text - The text item + * @param height - The height of the scrollbar + * @param dispx - displacement between text and scrollbar in X axis + * @param dispy - displacement between text and scrollbar in Y axis + * + * @returns - < 0 on error + */ +int vlfGuiSetTextScrollBarEx(VlfText text, int height, int dispx, int dispy); + +/** + * Removes a scrollbar of a text item + * + * @param text - The text item + * + * @returns - < 0 on error +*/ +int vlfGuiRemoveTextScrollBar(VlfText text); + +/** + * Sets a character that will be replaced by a button icon + * + * @param ch - The character that will be replaced. + * @param button - The button used for the replacement, one of VlfButtonIcon + * + * @returns - < 0 on error +*/ +int vlfGuiChangeCharacterByButton(u16 ch, int button); + +/** + * Adds a new picture item from a buffer. + * Supported formats are GIM, TIM, BMP and PNG. + * + * @param data - The buffer with the picture + * @param size - The size of data buffer + * @param x - x position + * @param y - y position + * + * @returns - a new VlfPivture on success, NULL on error +*/ +VlfPicture vlfGuiAddPicture(void *data, int size, int x, int y); + +/** + * Adds a new picture item from a file. + * Supported formats are GIM, TIM, BMP and PNG. + * + * @param file - The file with the picture + * @param x - x position + * @param y - y position + * + * @returns - a new VlfPivture on success, NULL on error +*/ +VlfPicture vlfGuiAddPictureFile(char *file, int x, int y); + +/** + * Adds a new picture item from a resource. + * Supported formats are GIM, TIM, BMP and PNG. + * + * @param rco - The rco + * @param name - The name of the resource + * @param x - x position + * @param y - y position + * + * @returns - a new VlfPivture on success, NULL on error +*/ +VlfPicture vlfGuiAddPictureResource(char *rco, char *name, int x, int y); + +/** + * Removes a picture + * + * @param pic - The picture to remove + * + * @returns - < 0 on error. +*/ +int vlfGuiRemovePicture(VlfPicture pic); + +/** + * Sets a picture position. + * + * @param pic - The picture + * @param x - x position + * @param y - y position + * + * @returns - < 0 on error +*/ +int vlfGuiSetPictureXY(VlfPicture pic, int x, int y); + +/** + * Gets a picture size. + * + * @param pic - The picture + * @param width - pointer to a variable that receives the width + * @param height - pointer to a variable that receives the height + * + * @returns - < 0 on error +*/ +int vlfGuiGetPictureSize(VlfPicture pic, int *width, int *height); + +/** + * Sets the picture display area + * + * @param pic - The picture + * @param x - x position of the display area, relative to the top left corner of the picture. + * @param y - y position of the display area, relative to the top left corner of the picture. + * @param width - the width of the rectangle display area + * @param height - The height of the rectangle display area + * + * @returns - < 0 on error +*/ +int vlfGuiSetPictureDisplayArea(VlfPicture pic, int x, int y, int width, int height); + +/** + * Sets picture alpha blend operation. + * + * @param pic - the picture + * @param op - Blending operation (see pspgu.h) + * @param src - Blending function for source operand (see pspgu.h) + * @param dst - Blending function for dest operand (see pspgu.h) + * @param srcfix - Fix value for GU_FIX (source operand) + * @param destfix - Fix value for GU_FIX (dest operand) + * + * @returns - < 0 on error +*/ +int vlfGuiSetPictureAlphaBlend(VlfPicture pic, int op, int src, int dst, u32 srcfix, u32 dstfix); + +/** + * Clones (duplicate) a picture + * + * @param pic - The picture to clone + * @param real - If 0, then the picture is not totally copied, but only a reference. Otherwise, a total duplication is performed. + * @param x - The x position for the cloned picture + * @param y - The y position for the cloned picture + * + * @returns - The cloned picture +*/ +VlfPicture vlfGuiClonePicture(VlfPicture pic, int real, int x, int y); + +/** + * Sets picture visibility + * + * @param pic - The picture + * @param visible - boolean indicating visibility + * + * @returns - < 0 on error +*/ +int vlfGuiSetPictureVisibility(VlfPicture pic, int visible); + +/** + * Makes a picture blink + * + * @param pic - The picture to blink + * @param nshow - The number of frames the picture will be shown + * @param nhide - The number of frames the picture will be hidden + * + * @returns - < 0 on error +*/ +int vlfGuiSetPictureBlinking(VlfPicture pic, u32 nshow, u32 nhide); + +/** + * Animates a picture. + * Frames are created from rectangle areas of the picture. + * + * @param pic - The picture to animate + * @param w - The width of each frame, must be a divisor of picture width + * @param h - The height of each frame, must be a divisor of picture height + * @param frames - The number of frames each frame is drawn. + * @param vertical - If 0, animaction is created from rectangles in horizontal direction. Otherwise, from vertical direction. + * + * @returns - < 0 on error +*/ +int vlfGuiAnimatePicture(VlfPicture pic, int w, int h, int frames, int vertical); + +/** + * Makes a VlfPicture item to fade. + * + * @param pic - The picture item to fade. + * @param mode - Whatever OR combination of VlfFadeModesFlags + * @param speed - The fade speed, one of VlfFadeSpeed + * @param direction_out - If both, VLF_FADE_MODE_IN and VLF_FADE_MODE_OUT, were specified, this param indicates + * wether to start from direction out or in. Otherwise, it is ignored. + * + * @returns - < 0 on error. + */ +int vlfGuiSetPictureFade(VlfPicture pic, int mode, int effect, int direction_out); + +/** + * Cancels a VlfPicture item fade. + * + * @param pic - The picture item to remove fade. + * + * @returns - < 0 on error +*/ +int vlfGuiCancelPictureFade(VlfPicture pic); + +/** + * Sets a callback to report the end of a fade. + * + * @param pic - The picture item fading. + * @param callback - The callback function that will be called at end of fade. + * @param param - param that will be passed to the callback function + * @param delay - The delay between the end of fade and the call to the callback + * + * @returns - < 0 on error +*/ +int vlfGuiSetPictureFadeFinishCallback(VlfPicture pic, void (* callback)(void *), void *param, int delay); + +/** + * Adds a new shadowed picture from two buffers. + * + * @param pic - The buffer with the main picture + * @param pic_size - The size of the pic buffer + * @param shpic - The buffer with the shadow picture + * @param shpic_size - The size of the shpic buffer + * @param x - x position + * @param y - y position + * @param sh_offsx - distance between the main picture and the shadow (x) + * @param sh_offsy - distance between the main picture and the shadow (y) + * @param shadow_before - indicates if shadow should be painted before + * + * @returns - a new shadowed picture on success, NULL on error +*/ +VlfShadowedPicture vlfGuiAddShadowedPicture(void *pic, int pic_size, void *shpic, int shpic_size, int x, int y, int sh_offsx, int sh_offsy, int shadow_before); + +/** + * Adds a new shadowed picture from two files + * + * @param pic - The file with the main picture + * @param shpic - The file with the shadow picture + * @param x - x position + * @param y - y position + * @param sh_offsx - distance between the main picture and the shadow (x) + * @param sh_offsy - distance between the main picture and the shadow (y) + * @param shadow_before - indicates if shadow should be painted before + * + * @returns - a new shadowed picture on success, NULL on error +*/ +VlfShadowedPicture vlfGuiAddShadowedPictureFile(char *pic, char *shpic, int x, int y, int sh_offsx, int sh_offsy, int shadow_before); + +/** + * Adds a new shadowed picture from two resources. + * + * @param rco .- The resource file + * @param pic - The name of the resource with the main picture + * @param shpic - The name of the resource with the shadow picture + * @param x - x position + * @param y - y position + * @param sh_offsx - distance between the main picture and the shadow (x) + * @param sh_offsy - distance between the main picture and the shadow (y) + * @param shadow_before - indicates if shadow should be painted before + * + * @returns - a new shadowed picture on success, NULL on error +*/ +VlfShadowedPicture vlfGuiAddShadowedPictureResource(char *rco, char *pic, char *shpic, int x, int y, int sh_offsx, int sh_offsy, int shadow_before); + +/** + * Removes a shadowed picture + * + * @param sp - The shadowed picture to remove + * + * @returns - < 0 on error. +*/ +int vlfGuiRemoveShadowedPicture(VlfShadowedPicture sp); + +/** + * Sets shadowed picture visibility + * + * @param sp - The shadowed picture + * @param visible - boolean indicating visibility + * + * @returns - < 0 on error +*/ +int vlfGuiSetShadowedPictureVisibility(VlfShadowedPicture sp, int visible); + +/** + * Makes a shadowed picture blink + * + * @param sp - The shadowed picture to blink + * @param nshow - The number of frames the picture will be shown + * @param nhide - The number of frames the picture will be hidden + * + * @returns - < 0 on error +*/ +int vlfGuiSetShadowedPictureBlinking(VlfShadowedPicture sp, u32 nshow, u32 nhide); + +/** + * Animates a shadowed picture. + * Frames are created from rectangle areas of the picture. + * + * @param sp - The shadowed picture to animate + * @param w - The width of each frame of main picture, must be a divisor of main picture width + * @param h - The height of each frame of main picure, must be a divisor of main picture height + * @param ws - The width of each frame of shadow picture, must be a divisor of shadow picture width + * @param hs - The height of each frame of shadow picure, must be a divisor of shadow picture height + * @param frames - The number of frames each frame is drawn + * @param vertical - If 0, animaction is created from rectangles in horizontal direction. Otherwise, from vertical direction. + * + * @returns - < 0 on error + * + * @Example: vlfGuiAddWaitIconEx source code. Image is divided in 17x17 rectangles, each frame is drawn for 3 frames. + * + * VlfShadowedPicture vlfGuiAddWaitIconEx(int x, int y) + * { + * VlfShadowedPicture res = vlfGuiAddShadowedPictureResource("system_plugin_fg", "tex_busy", "tex_busy_shadow", x, y, 1, 1, 0); + * + * if (!res) + * return NULL; + * + * if (vlfGuiAnimateShadowedPicture(res, 17, 17, 17, 17, 3, 1) < 0) + * { + * vlfGuiRemoveShadowedPicture(res); + * return NULL; + * } + * + * return res; + * } +*/ +int vlfGuiAnimateShadowedPicture(VlfShadowedPicture sp, int w, int h, int ws, int hs, int frames, int vertical); + +/** + * Makes a VlfShadowedPicture item to fade. + * + * @param sp - The shadowed picture item to fade. + * @param mode - Whatever OR combination of VlfFadeModesFlags + * @param speed - The fade speed, one of VlfFadeSpeed + * @param direction_out - If both, VLF_FADE_MODE_IN and VLF_FADE_MODE_OUT, were specified, this param indicates + * wether to start from direction out or in. Otherwise, it is ignored. + * + * @returns - < 0 on error. + */ +int vlfGuiSetShadowedPictureFade(VlfShadowedPicture sp, int mode, int effect, int direction_out); + +/** + * Cancels a VlfShadowedPicture item fade. + * + * @param sp - The shadowed picture item to remove fade. + * + * @returns - < 0 on error + */ +int vlfGuiCancelShadowedPictureFade(VlfShadowedPicture sp); + +/** + * Sets a callback to report the end of a fade. + * + * @param sp - The shadowed picture item fading. + * @param callback - The callback function that will be called at end of fade. + * @param param - param that will be passed to the callback function + * @param delay - The delay between the end of fade and the call to the callback + * + * @returns - < 0 on error +*/ +int vlfGuiSetShadowedPictureFadeFinishCallback(VlfShadowedPicture sp, void (* callback)(void *), void *param, int delay); + +/** + * Adds a new battery icon at its default position. Icon created by this function must be manually operated by programmer. + * + * @param status - The status, one of VlfBatteryIconStatus + * @param blink - blinking flag + * + * @returns - a new VlfBatteryIcon item +*/ +VlfBatteryIcon vlfGuiAddBatteryIcon(u32 status, int blink); + +/** + * Adds a new battery icon (with more options). Icon created by this function must be manually operated by programmer. + * + * @param x - The x position + * @param y - The y position + * @param status - The status, one of VlfBatteryIconStatus + * @param blink - blinking flag + * + * @returns - a new VlfBatteryIcon item + */ +VlfBatteryIcon vlfGuiAddBatteryIconEx(int x, int y, u32 status, int blink); + +/** + * Adds a new battery icon at its default position. + * Icon created by this function is handled automatically by the library. + * + * @param timer_ms - The miliseconds the timer that checks the battery is executed. + * + * @returns - a new VlfBatteryIcon item +*/ +VlfBatteryIcon vlfGuiAddBatteryIconSystem(int timer_ms); + +/** + * Sets battery icon status. + * + * @param baticon - The battery icon + * @param status - The status, one of VlfBatteryIconStatus + * @param blink - blinking flag + * + * @returns - < 0 on error + * + * @Note: this function shouldn't be used with a battery icon created by vlfGuiAddBatteryIconSystem. +*/ +int vlfGuiSetBatteryIconStatus(VlfBatteryIcon baticon, int status, int blink); + +/** + * Removes a battery icon. + * + * @param baticon - The battery icon to remove + * + * @returns - < 0 on error +*/ +int vlfGuiRemoveBatteryIcon(VlfBatteryIcon baticon); + +/** + * Adds a system clock. Only one clock is allowed currently + * + * @returns - < 0 on error. + * + * @Note: this function will change in future versions. +*/ +int vlfGuiAddClock(); + +/** + * Adds an animated wait icon at its default position in lower-right corner. + * + * @returns - a new wait icon. +*/ +VlfShadowedPicture vlfGuiAddWaitIcon(); + +/** + * Adds an animated wait icon at position choosed by programmer. + * + * @param x - x position + * @param y - y position + * + * @returns - a new wait icon. + */ +VlfShadowedPicture vlfGuiAddWaitIconEx(int x, int y); + +/** + * Adds a cross picture. + * + * @param x - x position + * @param y - y position + * + * @returns - a new cross picture +*/ +VlfShadowedPicture vlfGuiAddCross(int x, int y); + +/** + * Adds a circle picture. + * + * @param x - x position + * @param y - y position + * + * @returns - a new circle picture +*/ +VlfShadowedPicture vlfGuiAddCircle(int x, int y); + +/** + * Adds a triangle picture. + * + * @param x - x position + * @param y - y position + * + * @returns - a new triangle picture +*/ +VlfShadowedPicture vlfGuiAddTriangle(int x, int y); + +/** + * Adds a square picture. + * + * @param x - x position + * @param y - y position + * + * @returns - a new square picture +*/ +VlfShadowedPicture vlfGuiAddSquare(int x, int y); + +/** + * Adds an enter picture (cross or circle) + * + * @param x - x position + * @param y - y position + * + * @returns - a new enter picture +*/ +VlfShadowedPicture vlfGuiAddEnter(int x, int y); + +/** + * Adds a cancel picture (cross or circle) + * + * @param x - x position + * @param y - y position + * + * @returns - a new cancel picture +*/ +VlfShadowedPicture vlfGuiAddCancel(int x, int y); + +/** + * Adds a spinup picture. + * + * @param x - x position + * @param y - y position + * + * @returns - a new spinup picture +*/ +VlfShadowedPicture vlfGuiAddSpinUp(int x, int y); + +/** + * Adds a spindown picture. + * + * @param x - x position + * @param y - y position + * + * @returns - a new spindown picture +*/ +VlfShadowedPicture vlfGuiAddSpinDown(int x, int y); + +/** + * Adds an arrow left picture. + * + * @param x - x position + * @param y - y position + * + * @returns - a new arrow left picture +*/ +VlfShadowedPicture vlfGuiAddArrowLeft(int x, int y); + +/** + * Adds an arrow right picture. + * + * @param x - x position + * @param y - y position + * + * @returns - a new arrow right picture +*/ +VlfShadowedPicture vlfGuiAddArrowRight(int x, int y); + +/** + * Adds a new integer spin + * + * @param x - x position + * @param y - y position + * @param min - minim value of the spin + * @param max - max value of the spin + * @param cur - The initial integer value of the spin + * @param step - The step in which the value is increased/decreased + * @param loop - boolean indicating if the spin loops + * @param speed - The speed of the spin in milisecs + * @param initstate - the initial state of the spin, one of VLF_SpinState + * @param prefix - Prefix string, NULL if not needed + * @param suffix - Suffix string, NULL if not needed + * + * @returns - a new VlfSpin object on success, NULL on error +*/ +VlfSpin vlfGuiAddIntegerSpinControl(int x, int y, int min, int max, int cur, int step, int loop, int speed, int initstate, char *prefix, char *suffix); + +/** + * Removes a spin item + * + * @param spin - the spin to remove + * + * @returns - < 0 on error +*/ +int vlfGuiRemoveSpinControl(VlfSpin spin); + +/** + * Sets spin state + * + * @param spin - the spin + * @param state - the state, one of VLF_SpinState + * + * @returns - < 0 on error +*/ +int vlfGuiSetSpinState(VlfSpin spin, int state); + +/** + * Sets integer minimum and maximum values for an integer spin + * + * @param spin - The integer spin + * @param min - the minimum value + * @param max - the maximum value + * + * @returns - < 0 on error +*/ +int vlfGuiSetIntegerSpinMinMax(VlfSpin spin, int min, int max); + +/** + * Gets the integer value of an integer spin + * + * @param spin - the integer spin + * @param value - pointer to a variable that receives the value + * + * @returns - < 0 on error +*/ +int vlfGuiGetIntegerSpinValue(VlfSpin spin, int *value); + +/** + * Sets the integer value of an integer spin + * + * @param spin - the integer spin + * @param value - the integer value to set + * + * @returns - < 0 on error +*/ +int vlfGuiSetIntegerSpinValue(VlfSpin spin, int value); + +/** + * Adds a new checkbox item + * By default the checkbox is created without focus and without check. + * When a checbox has focus, library handles automatically the press of enter button to change check state + * + * @param x - x position + * @param y - y position + * + * @returns - a new VlfCheckBox item on sucess, NULL on error +*/ +VlfCheckBox vlfGuiAddCheckBox(int x, int y); + +/** + * Removes a checkbox item + * + * @param cb - The checkbox to remove + * + * @returns - < 0 on error +*/ +int vlfGuiRemoveCheckBox(VlfCheckBox cb); + +/** + * Sets checkbox check state + * + * @param cb - The checkbox to check/uncheck + * @param check - boolean indicating check + * + * @returns - < 0 on error +*/ +int vlfGuiSetCheckBoxCheck(VlfCheckBox cb, int check); + +/** + * Sets checkbox focus state + * + * @param cb - The checkbox + * @param focus - boolean indicating focus + * + * @returns - < 0 on error + */ +int vlfGuiSetCheckBoxFocus(VlfCheckBox cb, int focus); + +/** + * Boolean function that checks check state of a checkbox + * + * @param cb - the checkbox + * + * @returns 1 if the checkbox is checked, 0 otherwise +*/ +int vlfGuiIsCheckBoxChecked(VlfCheckBox cb); + +/** + * Boolean function that checks focus state of a checkbox + * + * @param cb - the checkbox + * + * @returns 1 if the checkbox has focus, 0 otherwise +*/ +int vlfGuiIsCheckBoxFocused(VlfCheckBox cb); + +/** + * Adds a new inputbox item with default width. + * By default the newly created inputbox is focused and of normal type. + * When a inputbox item is focused, library automatically handles press of enter button to show OSK. + * + * @param desc - description that will be shown in the OSK dialog. + * @param x - the x position + * @param y - the y position + * + * @returns - a new VlfInputBox on sucess, NULL on error +*/ +VlfInputBox vlfGuiAddInputBox(char *desc, int x, int y); + +/** + * Adds a new inputbox item. + * By default the newly created inputbox is focused and of normal type. + * When a inputbox item is focused, library automatically handles press of enter button to show OSK. + * + * @param desc - description that will be shown in the OSK dialog. + * @param x - the x position + * @param y - the y position + * @param width - width of the box + * + * @returns - a new VlfInputBox on sucess, NULL on error +*/ +VlfInputBox vlfGuiAddInputBoxEx(u16 *desc, int x, int y, int width); + +/** + * Removes an inputbox + * + * @param ib - the inputbox to remove + * + * @returns - < 0 on error +*/ +int vlfGuiRemoveInputBox(VlfInputBox ib); + +/** + * Sets inputbox text from an ascii string + * + * @param ib - the inputbox + * @param text - the ascii string + * + * @returns - < 0 on error +*/ +int vlfGuiSetInputBoxText(VlfInputBox ib, char *text); + +/** + * Sets inputbox text from an unicode string + * + * @param ib - the inputbox + * @param text - the unicode string + * + * @returns - < 0 on error + */ +int vlfGuiSetInputBoxTextW(VlfInputBox ib, u16 *text); + +/** + * Sets inputbox text from a string with format + * + * @param ib - the inputbox + * @param fmt - the string with format + * + * @returns - < 0 on error + */ +int vlfGuiSetInputBoxTextF(VlfInputBox ib, char *fmt, ...); + +/** + * Gets inputbox text. + * + * @param ib - thei inputbox + * @param text - output buffer that receives the strig as unicode + * + * @returns - < 0 on error +*/ +int vlfGuiGetInputBoxText(VlfInputBox ib, u16 *text); + +/** + * Sets inputbox focus state + * + * @param ib - the inputbox + * @param focus - the focus state boolean + * + * @returns - < 0 on error +*/ +int vlfGuiSetInputBoxFocus(VlfInputBox ib, int focus); + +/** + * Boolean function that checks inputbox focus state + * + * @param ib - The inputbox + * + * @returns 1 if the inputbox has focus, 0 otherwise +*/ +int vlfGuiIsInputBoxFocused(VlfInputBox ib); + +/** + * Sets inputbox type (normal or password). + * + * @param ib - the inputbox + * @param type - the type to set, one of VLF_InputBoxType + * + * @returns - < 0 on error +*/ +int vlfGuiSetInputBoxType(VlfInputBox ib, int type); + +/** + * Makes a VlfInputBox item to fade. + * + * @param ib - The inputbox item to fade. + * @param mode - Whatever OR combination of VlfFadeModesFlags + * @param speed - The fade speed, one of VlfFadeSpeed + * @param direction_out - If both, VLF_FADE_MODE_IN and VLF_FADE_MODE_OUT, were specified, this param indicates + * wether to start from direction out or in. Otherwise, it is ignored. + * + * @returns - < 0 on error. +*/ +int vlfGuiSetInputBoxFade(VlfInputBox ib, int mode, int effect, int direction_out); + +/** + * Cancels a VlfInputBox item fade. + * + * @param ib - The inputbox item to remove fade. + * + * @returns - < 0 on error +*/ +int vlfGuiCancelInputBoxFade(VlfInputBox ib); + +/** + * Sets a callback to report the end of a fade. + * + * @param ib- The inputbox item fading. + * @param callback - The callback function that will be called at end of fade. + * @param param - param that will be passed to the callback function + * @param delay - The delay between the end of fade and the call to the callback + * + * @returns - < 0 on error +*/ +int vlfGuiSetInputBoxFadeFinishCallback(VlfInputBox ib, void (* callback)(void *), void *param, int delay); + +/** + * Adds a new progressbar at default x position. + * + * @param y - y position + * + * @return - a new VlfProgressBar item on success, NULL on error +*/ +VlfProgressBar vlfGuiAddProgressBar(int y); + +/** + * Adds a new progressbar + * + * @param x - x position + * @param y - y position + * + * @return - a new VlfProgressBar item on success, NULL on error +*/ +VlfProgressBar vlfGuiAddProgressBarEx(int x, int y); + +/** + * Removes a progress bar + * + * @param pb - the progress bar to remove. + * + * @returns - < 0 on error +*/ +int vlfGuiRemoveProgressBar(VlfProgressBar pb); + +/** + * Sets the progress of a progressbar + * + * @param pb - the progress bar + * @param perc - the percentage progress + * + * @returns - < 0 on error +*/ +int vlfGuiProgressBarSetProgress(VlfProgressBar pb, u32 perc); + +/** + * Makes a VlfProgressBar item to fade. + * + * @param pb - The progressbar item to fade. + * @param mode - Whatever OR combination of VlfFadeModesFlags + * @param speed - The fade speed, one of VlfFadeSpeed + * @param direction_out - If both, VLF_FADE_MODE_IN and VLF_FADE_MODE_OUT, were specified, this param indicates + * wether to start from direction out or in. Otherwise, it is ignored. + * + * @returns - < 0 on error. +*/ +int vlfGuiSetProgressBarFade(VlfProgressBar pb, int mode, int effect, int direction_out); + +/** + * Cancels a VlfProgressBar item fade. + * + * @param pb - The progressbar item to remove fade. + * + * @returns - < 0 on error +*/ +int vlfGuiCancelProgressBarFade(VlfProgressBar pb); + +/** + * Sets a callback to report the end of a fade. + * + * @param pb - The progressbar item fading. + * @param callback - The callback function that will be called at end of fade. + * @param param - param that will be passed to the callback function + * @param delay - The delay between the end of fade and the call to the callback + * + * @returns - < 0 on error +*/ +int vlfGuiSetProgressBarFadeFinishCallback(VlfProgressBar pb, void (* callback)(void *), void *param, int delay); + +/** + * Adds a new scrollbar. (must be controlled by programmer) + * + * @param x - x position + * @param y - y position + * @param height - height of scrollbar + * @param sliderheight - height of slider + * + * @returns a new VlfScrollBar item on success, NULL on error +*/ +VlfScrollBar vlfGuiAddScrollBar(int x, int y, int height, int sliderheight); + +/** + * Removes a scrollbar itemm. + * + * @param sb - the scrollbar to remove + * + * @returns - < 0 on error +*/ +int vlfGuiRemoveScrollBar(VlfScrollBar sb); + +/** + * Moves the slider of a scrollbar + * + * @param y - the new position of the slider + * + * @returns - < 0 on error +*/ +int vlfGuiMoveScrollBarSlider(VlfScrollBar sb, int y); + +/** + * Sets the height of the slider of a scrollbar + * + * @param sb - the scrollbar + * @param height - the new height for the slider + * + * @returns - < 0 on error. +*/ +int vlfGuiSetScrollBarSliderHeight(VlfScrollBar sb, int height); + +/** + * Sets the visibility of the items in a rectangle + * + * @param x - x position of rectangle + * @param y - y position of rectangle + * @param w - width of rectangle + * @param h - height of rectangle + * @param visible . boolean indicating visibility + * + * @returns - < 0 on error +*/ +int vlfGuiSetRectangleVisibility(int x, int y, int w, int h, int visible); + +/** + * Saves the visibility context in a rectangle area + * + * @param x - x position of rectangle + * @param y - y position of rectangle + * @param w - width of rectangle + * @param h - height of rectangle + * + * @returns - the visibility context. Use vlfGuiRestoreVisibilityContext to restore it, and vlfGuiFreeVisibilityContext to deallocate it. +*/ +void *vlfGuiSaveRectangleVisibilityContext(int x, int y, int w, int h); + +/** + * Restores a visibility context. + * + * @param ctx - the visibility context +*/ +void vlfGuiRestoreVisibilityContext(void *ctx); + +/** + * Deallocates memory used by a visibility context + * + * @param ctx - the visibility context +*/ +void vlfGuiFreeVisibilityContext(void *ctx); + +/** + * Makes all items within a rectangle to fade + * + * @param x - x position of rectangle + * @param y - y position of rectangle + * @param w - width of rectangle + * @param h - height of rectangle + * @param mode - Whatever OR combination of VlfFadeModesFlags + * @param speed - The fade speed, one of VlfFadeSpeed + * @param direction_out - If both, VLF_FADE_MODE_IN and VLF_FADE_MODE_OUT, were specified, this param indicates + * wether to start from direction out or in. Otherwise, it is ignored. + * + * @returns - < 0 on error. +*/ +int vlfGuiSetRectangleFade(int x, int y, int w, int h, int mode, int effect, int direction_out, void (* callback)(void *), void *param, int delay); + +/** + * Makes all items within a rectangle to blink + * + * @param x - x position of rectangle + * @param y - y position of rectangle + * @param w - width of rectangle + * @param h - height of rectangle + * @param nshow - the numbers of frames the items will be shown + * @param nhide - the numbers of frames the items will be hidden + * + * @returns - < 0 on error. + * + * @Note: currently not all kind of items can blink. This will be fixed in future. +*/ +int vlfGuiSetRectangleBlinking(int x, int y, int w, int h, u32 nshow, u32 nhide); + +/** + * Synchronizes the blinking of one item with the one of a second one + * + * @param dst - the destiny item + * @param dst_type - the type of the destiny object, one of VlfObjects + * @param src - the source item + * @param src_type - the type of source object, one of VlfObjects + * + * @returns - < 0 on error +*/ +int vlfGuiSetSynchronizedBlinking(void *dst, int dst_type, void *src, int src_type); + +/** + * Shows a message dialog. + * + * @param msg - the message dialog + * @param flags - a combination of VLF_MDType, VLF_MD_Buttons and VLF_MD_InitalCursor + * + * @returns - one of VLF_MD_ButtonRes +*/ +int vlfGuiMessageDialog(char *msg, u32 flags); + +/** + * Shows an error dialog. + * + * @param error - the system error code + * + * @returns - one of VLF_MD_ButtonRes +*/ +int vlfGuiErrorDialog(int error); + +/** + * Shows a net config dialog. + * Network libraries must be loaded before. + * + * @returns 0 if the connection was done. +*/ +int vlfGuiNetConfDialog(); + +/** + * Shows an OSK dialog. + * + * @param intext - the initial text of the OSK, NULL if no required + * @param desc - the description that will be shown in the OSK, NULL if no required + * @param outtext - the output text + * + * @returns 0 if the text was entered. +*/ +int vlfGuiOSKDialog(u16 *intext, u16 *desc, u16 *outtext); + +/** + * Shows one or two buttons with enter/cancel icons at bottom of screen. + * Button presses are handled by the library. + * + * @param button1 - a button code, one of VLF_DialogItem. < 0 if no required + * @param button2 - a button code, one of VLF_DialogItem- < 0 if no required + * @param automatic - if automatic is 0, button1 will be the left button and button2 will be right button. + * Otherwise, the buttons are rearranged automatically acording to current button configuration. + * @param enter_is_left - if automatic is 0, this button indicates which button is assigned enter. + * @param distance - the distance between the buttons, use VLF_DEFAULT for a default distance + * @param handler - the function that will be called when enter/cancel are pressed. The function shall return VLF_REMOVE_HANDLERS if it + * wants to cancel further events, VLF_REMOVE_OBJECTS to remove bottom dialog, or both to fully remove the bottom dialog. + * + * @returns - < 0 on error. +*/ +int vlfGuiBottomDialog(int button1, int button2, int automatic, int enter_is_left, int distance, int (* handler)(int enter)); + +/** + * Shows one or two buttons with enter/cancel icons at bottom of screen. + * Button presses are handled by the library. + * + * @param button1 - button string. NULL if no required + * @param button2 - button string. NULL if no required + * @param automatic - if automatic is 0, button1 will be the left button and button2 will be right button. + * Otherwise, the buttons are rearranged automatically acording to current button configuration. + * @param enter_is_left - if automatic is 0, this button indicates which button is assigned enter. + * @param distance - the distance between the buttons, use VLF_DEFAULT for a default distance + * @param handler - the function that will be called when enter/cancel are pressed, enter param indicates if enter was pressed, otherwise cancel was pressed. + * The function shall return VLF_REMOVE_HANDLERS if it wants to cancel further events, VLF_REMOVE_OBJECTS to remove buttons, + * or both to fully remove the bottom dialog. + * + * @returns - < 0 on error. + */ +int vlfGuiCustomBottomDialog(char *button1, char *button2, int automatic, int enter_is_left, int distance, int (* handler)(int enter)); + +/** + * Cancels (remove) the bottom dialog +*/ +void vlfGuiCancelBottomDialog(); + +/** + * Creates a central menu. + * Button presses of menu are automatically handled by the library + * + * @param noptions - number of options of the menu + * @param items - an array of noptions strings + * @param defaultsel- the index of the item with the initial selection + * @param handler - the function that will be called on enter button is pressed. sel param is the index of the selected item. + * The function shall return VLF_REMOVE_HANDLERS if it wants to cancel further events, VLF_REMOVE_OBJECTS to remove items, + * or both to fully remove the central menu. + * @param dispx - displacement relative to the default centered position (x) + * @param dispy - displacement relative to the default centered position (y) + * + * @returns - < 0 on error +*/ +int vlfGuiCentralMenu(int noptions, char **items, int defaultsel, int (* handler)(int sel), int dispx, int dispy); + +/** + * Cancels (remove) the central menu +*/ +void vlfGuiCancelCentralMenu(); + +/** + * Returns the current selected item of the central menu + * + * @returns - the selected item +*/ +int vlfGuiCentralMenuSelection(); + +/** + * Creates a lateral menu with current system color. + * Button presses of menu are automatically handled by the library + * + * @param noptions - number of options of the menu + * @param items - an array of noptions strings + * @param defaultsel- the index of the item with the initial selection + * @param handler - the function that will be called on enter button is pressed. sel param is the index of the selected item. + * The function shall return VLF_REMOVE_HANDLERS if it wants to cancel further events, VLF_REMOVE_OBJECTS to remove menu, + * or both to fully remove the lateral menu. + * @param y - y position of first item + * + * @returns - < 0 on error +*/ +int vlfGuiLateralMenu(int noptions, char **items, int defaultsel, int (* handler)(int sel), int y); + +/** + * Creates a lateral menu with desired color. + * Button presses of menu are automatically handled by the library + * + * @param noptions - number of options of the menu + * @param items - an array of noptions strings + * @param defaultsel- the index of the item with the initial selection + * @param handler - the function that will be called on enter button is pressed. sel param is the index of the selected item. + * The function shall return VLF_REMOVE_HANDLERS if it wants to cancel further events, VLF_REMOVE_OBJECTS to remove menu, + * or both to fully remove the lateral menu. + * @param y - y position of first item + * @param color - the color of the lateral menu + * + * @returns - < 0 on error +*/ +int vlfGuiLateralMenuEx(int noptions, char **items, int defaultsel, int (* handler)(int sel), int y, u32 color); + +/** + * Cancels (remove) the lateral menu + */ +void vlfGuiCancelLateralMenu(); + +/** + * Returns the current selected item of the lateral menu + * + * @returns - the selected item + */ +int vlfGuiLateralMenuSelection(); + +/** + * Creates a control for previous page handling. + * + * @param handler - the function that will be called when the previous button (left) is pressed. page parameter holds the page number. + * The function shall return VLF_REMOVE_HANDLERS if it wants to cancel further events, VLF_REMOVE_OBJECTS to remove control pics and text, + * or both to fully remove the control. + * + * @returns - < 0 on error +*/ +int vlfGuiPreviousPageControl(int (* handler)(int page)); + +/** + * Creates a control for next page handling. + * + * @param handler - the function that will be called when the next button (right) is pressed. page parameter holds the page number. + * The function shall return VLF_REMOVE_HANDLERS if it wants to cancel further events, VLF_REMOVE_OBJECTS to remove control pics and text, + * or both to fully remove the control. + * + * @returns - < 0 on error + */ +int vlfGuiNextPageControl(int (* handler)(int page)); + +/** + * Cancels (remove) previous page control +*/ +void vlfGuiCancelPreviousPageControl(); + +/** + * Cancels (remove) next page control + */ +void vlfGuiCancelNextPageControl(); + +/** + * Enable or disable page control.(it does not add/remove them). + * + * @param enable - enable or disable +*/ +void vlfGuiSetPageControlEnable(int enable); + +/** + * Adds a handler for an event. + * + * @param buttons - the button event, 0 if no event (will be called every frame) + * @param wait - wait for the handler to be added. Use 0 for no wait, and -1 to make this handler impossible to delay. + * @param func - the function that will be called when the event happens. + * @param param - custom param for the handler function. The function must return one or a combination of following values: + * + * VLF_EV_RET_NOTHING: normal return, it does nothing. + * VLF_EV_RET_REMOVE_EVENT: it removes the event (button press), so other handler doesn't receive it. + * VLF_EV_RET_REMOVE_HANDLERS: it removes this handler so that it won't receive more event notifications. + * VLF_EV_RET_DELAY: the event is delayed for specified number of miliseconds. VLF_EV_RET_DELAY | (X << 16), where 0 <= X <= 32727 + * VLF_EV_RET_DELAY_FRAME: the event is delayed for specified number of frames. VLF_EV_RET_DELAY_FRAME | (X << 16), where 0 <= X <= 4095 + * VLF_EV_RET_REFRESH_ON_DELAY: the event is refreshed after a delay, so that if button/s are kept pressed until after the event, it will receive it as a new event + * + * @returns - < 0 on error +*/ +int vlfGuiAddEventHandler(int buttons, int wait, int (* func)(void *), void *param); + +/** + * Adds a handler for an event. + * Unlike the previous function, this one adds the handler to the head instead of the tail. + * + * @param buttons - the button event, 0 if no event (will be called every frame) + * @param wait - wait for the handler to be added. Use 0 for no wait, and -1 to make this handler impossible to delay. + * @param func - the function that will be called when the event happens. + * @param param - custom param for the handler function. The function must return one or a combination of following values: + * + * VLF_EV_RET_NOTHING: normal return, it does nothing. + * VLF_EV_RET_REMOVE_EVENT: it removes the event (button press), so other handler doesn't receive it. + * VLF_EV_RET_REMOVE_HANDLERS: it removes this handler so that it won't receive more event notifications. + * VLF_EV_RET_DELAY: the event is delayed for specified number of miliseconds. VLF_EV_RET_DELAY | (X << 16), where 0 <= X <= 32727 + * VLF_EV_RET_DELAY_FRAME: the event is delayed for specified number of frames. VLF_EV_RET_DELAY_FRAME | (X << 16), where 0 <= X <= 4095 + * VLF_EV_RET_REFRESH_ON_DELAY: the event is refreshed after a delay, so that if button/s are kept pressed until after the event, it will receive it as a new event + * + * @returns - < 0 on error +*/ +int vlfGuiAddEventHandlerHead(int buttons, int wait, int (* func)(void *), void *param); + +/** + * Adds a handler for a negative event. + * + * @param buttons - the negative button event. For Example if you pass PSP_CTRL_CROSS, it will mean NOT PSP_CTRL_CROSS pressed. + * @param wait - wait for the handler to be added. Use 0 for no wait, and -1 to make this handler impossible to delay. + * @param func - the function that will be called when the event happens. + * @param param - custom param for the handler function. The function must return one or a combination of following values: + * + * VLF_EV_RET_NOTHING: normal return, it does nothing. + * VLF_EV_RET_REMOVE_EVENT: it removes the event (button press), so other handler doesn't receive it. + * VLF_EV_RET_REMOVE_HANDLERS: it removes this handler so that it won't receive more event notifications. + * VLF_EV_RET_DELAY: the event is delayed for specified number of miliseconds. VLF_EV_RET_DELAY | (X << 16), where 0 <= X <= 32727 + * VLF_EV_RET_DELAY_FRAME: the event is delayed for specified number of frames. VLF_EV_RET_DELAY_FRAME | (X << 16), where 0 <= X <= 4095 + * VLF_EV_RET_REFRESH_ON_DELAY: the event is refreshed after a delay, so that if button/s are kept pressed until after the event, it will receive it as a new event + * + * @returns - < 0 on error + */ +int vlfGuiAddNegativeEventHandler(int buttons, int wait, int (* func)(void *), void *param); + +/** + * Adds a handler for a negative event. + * Unlike the previous function, this one adds the handler to the head instead of the tail. + * + * @param buttons - the negative button event. For Example if you pass PSP_CTRL_CROSS, it will mean NOT PSP_CTRL_CROSS pressed. + * @param wait - wait for the handler to be added. Use 0 for no wait, and -1 to make this handler impossible to delay. + * @param func - the function that will be called when the event happens. + * @param param - custom param for the handler function. The function must return one or a combination of following values: + * + * VLF_EV_RET_NOTHING: normal return, it does nothing. + * VLF_EV_RET_REMOVE_EVENT: it removes the event (button press), so other handler doesn't receive it. + * VLF_EV_RET_REMOVE_HANDLERS: it removes this handler so that it won't receive more event notifications. + * VLF_EV_RET_DELAY: the event is delayed for specified number of miliseconds. VLF_EV_RET_DELAY | (X << 16), where 0 <= X <= 32727 + * VLF_EV_RET_DELAY_FRAME: the event is delayed for specified number of frames. VLF_EV_RET_DELAY_FRAME | (X << 16), where 0 <= X <= 4095 + * VLF_EV_RET_REFRESH_ON_DELAY: the event is refreshed after a delay, so that if button/s are kept pressed until after the event, it will receive it as a new event + * + * @returns - < 0 on error + */ +int vlfGuiAddNegativeEventHandlerHead(int buttons, int wait, int (* func)(void *), void *param); + +/** + * Removes an event handler. Use vlfGuiRemoveHandlerEx if you have used the same handler with different params. + * + * @param func - the handler function + * + * @returns - < 0 on error +*/ +int vlfGuiRemoveEventHandler(int (* func)(void *)); + +/** + * Removes an event hnadler + * + * @param func - the handler function + * @param param - the parameter that was passed to one of the vlfGuiAddEventHandler functions. + * + * @returns - < 0 on error +*/ +int vlfGuiRemoveEventHandlerEx(int (* func)(void *), void *param); + +/** + * Boolean function that checks if a handler is registered + * + * @param func - the handler to be checked. + * + * @return - < 0 on error +*/ +int vlfGuiIsEventRegistered(int (* func)(void *)); + +/** + * Delays an event handler. Use vlfGuiSetEventDelayEx if you have used the same handler with different params. + * + * @param func - the handler function + * @param delay - the delay in milisecs + * + * @return - < 0 on error +*/ +int vlfGuiSetEventDelay(int (* func)(void *), u32 delay); + +/** + * Delays an event handler. + * + * @param func - the handler function + * @param param - the parameter that was passed to one of the vlfGuiAddEventHandler functions. + * @param delay - the delay in milisecs + * + * @return - < 0 on error + */ +int vlfGuiSetEventDelayEx(int (* func)(void *), void * param, u32 delay); + +/** + * Delays all events that can be delayed + * + * @param delay - the delay in milisecs + * + * @returns - < 0 on error +*/ +int vlfGuiDelayAllEvents(u32 delay); + + + +#endif + diff --git a/libs/lib/libpspkubridge.a b/libs/lib/libpspkubridge.a new file mode 100644 index 0000000..89d64d0 Binary files /dev/null and b/libs/lib/libpspkubridge.a differ diff --git a/libs/lib/libvlfgu.a b/libs/lib/libvlfgu.a new file mode 100644 index 0000000..aecd297 Binary files /dev/null and b/libs/lib/libvlfgu.a differ diff --git a/libs/lib/libvlfgui.a b/libs/lib/libvlfgui.a new file mode 100644 index 0000000..583e748 Binary files /dev/null and b/libs/lib/libvlfgui.a differ diff --git a/libs/lib/libvlflibc.a b/libs/lib/libvlflibc.a new file mode 100644 index 0000000..0aa9270 Binary files /dev/null and b/libs/lib/libvlflibc.a differ diff --git a/libs/lib/libvlfutils.a b/libs/lib/libvlfutils.a new file mode 100644 index 0000000..67b548e Binary files /dev/null and b/libs/lib/libvlfutils.a differ diff --git a/main.c b/main.c index 9f5510d..04d7c13 100644 --- a/main.c +++ b/main.c @@ -41,38 +41,39 @@ char kirk[4], spock[4]; u32 fusecfg, scramble; u16 bserialdata[2], serialdata[2]; u64 fuseid; +int psp_model, devkit, language; +u32 tachyon, baryon, pommel; + +int scePowerGetBatteryRemainCapacity(void); +int scePowerGetBatteryFullCapacity(void); void MainMenu(int select); int ExitInMainMenuHardwareInfo(int enter); int ExitInMainMenuBatteryInfo(int enter); int ExitInMainMenuSystemInfo(int enter); -void HardwareInfo(); -void BatteryInfo(); -void SystemInfo(); +void HardwareInfo(void); +void BatteryInfo(void); +void SystemInfo(void); void SetBottomDialog(int enter, int back, int (* handler)(int enter), int delete_bd); void SetTitle(char *text); -void SetFade(); -void SetBackground(); +void SetFade(void); +void SetBackground(void); int OnMainMenuScreenUp(void *param); int OnMainMenuScreenDown(void *param); char *vertxt; -int OnMainMenu(int enter) -{ - if(enter) - { +int OnMainMenu(int enter) { + if (enter) { vlfGuiRemoveEventHandler(OnMainMenuScreenUp); vlfGuiRemoveEventHandler(OnMainMenuScreenDown); - int i; - for(i = 0; i < NUM_DEL_ITEMS_MAIN; i++) + for(int i = 0; i < NUM_DEL_ITEMS_MAIN; i++) vlfGuiRemoveText(main_menu[i]); - switch(focus) - { + switch(focus) { case 0: HardwareInfo(); break; @@ -95,15 +96,12 @@ int OnMainMenu(int enter) return VLF_EV_RET_NOTHING; } -int ExitInMainMenuHardwareInfo(int enter) -{ - if(!enter) - { - int i; - for(i = 0; i < NUM_DEL_ITEMS_HARDWARE; i++) +int ExitInMainMenuHardwareInfo(int enter) { + if (!enter) { + for(int i = 0; i < NUM_DEL_ITEMS_HARDWARE; i++) vlfGuiRemoveText(text_hardware[i]); - if(!button_assign) + if (!button_assign) vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL); vlfGuiCancelBottomDialog(); @@ -114,12 +112,10 @@ int ExitInMainMenuHardwareInfo(int enter) return VLF_EV_RET_NOTHING; } -int ExitInMainMenuBatteryInfo(int enter) -{ - if(!enter) - { +int ExitInMainMenuBatteryInfo(int enter) { + if (!enter) { battery_break = 1; - if(!button_assign) + if (!button_assign) vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL); vlfGuiCancelBottomDialog(); @@ -129,25 +125,20 @@ int ExitInMainMenuBatteryInfo(int enter) return VLF_EV_RET_NOTHING; } -int ExitInMainMenuSystemInfo(int enter) -{ - if(!enter) - { - int i; - for(i = 0; i < NUM_DEL_ITEMS_SYSTEM; i++) - if(text_system[i] != NULL) - { +int ExitInMainMenuSystemInfo(int enter) { + if (!enter) { + for(int i = 0; i < NUM_DEL_ITEMS_SYSTEM; i++) + if (text_system[i] != NULL) { vlfGuiRemoveText(text_system[i]); text_system[i] = NULL; } - if(pic_button_assign != NULL) - { + if (pic_button_assign != NULL) { vlfGuiRemovePicture(pic_button_assign); pic_button_assign = NULL; } - if(!button_assign) + if (!button_assign) vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL); vlfGuiCancelBottomDialog(); @@ -157,9 +148,7 @@ int ExitInMainMenuSystemInfo(int enter) return VLF_EV_RET_NOTHING; } -void HardwareInfo() -{ - +void HardwareInfo(void) { SetTitle(trans->hardware_title); text_hardware[0] = pspEverestPrintf(10, 40, "Tachyon: 0x%08X", tachyon); @@ -170,29 +159,28 @@ void HardwareInfo() text_hardware[5] = pspEverestPrintf(10, 140, "IDScramble: 0x%08X", scramble); text_hardware[6] = pspEverestPrintf(10, 160, "Kirk: %c%c%c%c", kirk[3], kirk[2], kirk[1], kirk[0]); text_hardware[7] = pspEverestPrintf(10, 180, psp_model == 4 ? "Spock: -" : "Spock: %c%c%c%c", spock[3], spock[2], spock[1], spock[0]); - text_hardware[8] = pspEverestPrintf(10, 200, GetFirstSymbolOfModel() != -1 ? trans->hardware.model : trans->hardware.no_model, psp_model == 4 ? "N" : psp_model == 10 ? "E" : "", GetFirstSymbolOfModel(), GetRegion() < 10 ? "0" : "", GetRegion(), GetModelName()); + text_hardware[8] = pspEverestPrintf(10, 200, pspGetFirstSymbolOfModel() != -1 ? trans->hardware.model : trans->hardware.no_model, psp_model == 4 ? "N" : psp_model == 10 ? "E" : "", pspGetFirstSymbolOfModel(), pspGetRegion() < 10 ? "0" : "", pspGetRegion(), pspGetModelName()); - text_hardware[9] = pspEverestPrintf(250, 40, trans->hardware.mobo, GetMoBoName()); - text_hardware[10] = pspEverestPrintf(250, 60, trans->hardware.region, GetRegionName()); + text_hardware[9] = pspEverestPrintf(250, 40, trans->hardware.mobo, pspGetMoBoName()); + text_hardware[10] = pspEverestPrintf(250, 60, trans->hardware.region, pspGetRegionName()); text_hardware[11] = pspEverestPrintf(250, 80, trans->hardware.gen, psp_model < 10 ? "0" : "", psp_model + 1); text_hardware[12] = pspEverestPrintf(250, 100, trans->hardware.eeprom, tachyon <= 0x00500000 && tachyon != 0x00100000 && baryon <= 0x0022B200 ? trans->yes : trans->no); text_hardware[13] = pspEverestPrintf(250, 120, trans->hardware.pandora, tachyon <= 0x00500000 ? trans->yes : trans->no); - text_hardware[14] = pspEverestPrintf(250, 140, "MAC: %s", GetMacAddressText()); - text_hardware[15] = pspEverestPrintf(250, 160, trans->hardware.initialfw, GetInitialFW()); - text_hardware[16] = pspEverestPrintf(250, 180, trans->hardware.umdfw, psp_model == 4 ? "-" : GetUMDFWText()); + text_hardware[14] = pspEverestPrintf(250, 140, "MAC: %s", pspGetMacAddressText()); + text_hardware[15] = pspEverestPrintf(250, 160, trans->hardware.initialfw, pspGetInitialFW()); + text_hardware[16] = pspEverestPrintf(250, 180, trans->hardware.umdfw, psp_model == 4 ? "-" : pspGetUMDFWText()); text_hardware[17] = pspEverestPrintf(250, 200, trans->hardware.nandsize, (pspNandGetPageSize() * pspNandGetPagesPerBlock() * pspNandGetTotalBlocks()) / 1024 / 1024); SetBottomDialog(0, 1, ExitInMainMenuHardwareInfo, 1); SetFade(); } -void BatteryInfo() -{ +void BatteryInfo(void) { int swbt = 1, checkbt = 0; vlfGuiCancelCentralMenu(); - if(button_assign) + if (button_assign) vlfGuiBottomDialog(VLF_DI_BACK, -1, 1, 0, 0, NULL); vlfGuiCancelBottomDialog(); @@ -201,11 +189,9 @@ void BatteryInfo() battery_fade_ctrl = 0; - int update, first_cycle = 1; - for(update = 0;; update++) - { - if(update == 25 || battery_fade_ctrl) - { + int first_cycle = 1; + for(int update = 0;; update++) { + if (update == 25 || battery_fade_ctrl) { update = 1; first_cycle = (battery_fade_ctrl ? 1 : 0); battery_fade_ctrl = 0; @@ -213,12 +199,9 @@ void BatteryInfo() vlfGuiDrawFrame(); - if(!first_cycle || update == 0) - { - int i; - for(i = 0; i < NUM_DEL_ITEMS_BATTERY; i++) - if(text_battery[i] != NULL) - { + if (!first_cycle || update == 0) { + for(int i = 0; i < NUM_DEL_ITEMS_BATTERY; i++) + if (text_battery[i] != NULL) { vlfGuiRemoveText(text_battery[i]); text_battery[i] = NULL; } @@ -226,31 +209,30 @@ void BatteryInfo() int battery_percent = scePowerGetBatteryLifePercent(); int battery_life_time = scePowerGetBatteryLifeTime(); - if(update != 0 && scePowerIsBatteryExist() && swbt && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200))) - { - ReadSerial(bserialdata); + if (update != 0 && scePowerIsBatteryExist() && swbt && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200))) { + pspReadSerial(bserialdata); u16 wrbuffer[0x80]; wrbuffer[0] = 0x5053; - if(bserialdata[0] != 0x5058) + if (bserialdata[0] != 0x5058) wrbuffer[1] = 0x5058; else wrbuffer[1] = 0x4456; - WriteSerial(wrbuffer); + pspWriteSerial(wrbuffer); checkbt = 0; - ReadSerial(serialdata); - if(serialdata[0] == wrbuffer[0] && serialdata[1] == wrbuffer[1]) + pspReadSerial(serialdata); + if (serialdata[0] == wrbuffer[0] && serialdata[1] == wrbuffer[1]) { checkbt = 1; - WriteSerial(bserialdata); + pspWriteSerial(bserialdata); } swbt = 0; } - if(swbt == 0 && !scePowerIsBatteryExist()) + if (swbt == 0 && !scePowerIsBatteryExist()) swbt = 1; text_battery[0] = pspEverestPrintf(15, 70, trans->battery.ex_power, psp_model == 4 ? "-" : scePowerIsPowerOnline() ? trans->yes : trans->no); @@ -271,18 +253,14 @@ void BatteryInfo() checkbt && scePowerIsBatteryExist() && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200)) ? trans->battery.mode_default : "-"); } - if(!update) - { + if (!update) { SetBottomDialog(0, 1, ExitInMainMenuBatteryInfo, 0); SetFade(); } - if(battery_break) - { - int i; - for(i = 0; i < NUM_DEL_ITEMS_BATTERY; i++) - if(text_battery[i] != NULL) - { + if (battery_break) { + for(int i = 0; i < NUM_DEL_ITEMS_BATTERY; i++) + if (text_battery[i] != NULL) { vlfGuiRemoveText(text_battery[i]); text_battery[i] = NULL; } @@ -294,18 +272,17 @@ void BatteryInfo() } } -void SystemInfo() -{ +void SystemInfo(void) { char username[32], password[5];; memset(username, 0, sizeof(username)); memset(password, 0, sizeof(password)); SetTitle(trans->system_title); - text_system[0] = pspEverestPrintf(10, 45, trans->system.fw, GetFirmwareName()); + text_system[0] = pspEverestPrintf(10, 45, trans->system.fw, pspGetFirmwareName()); text_system[1] = pspEverestPrintf(10, 65, trans->system.button_assign); - if(button_assign) + if (button_assign) pic_button_assign = vlfGuiAddPictureResource("system_plugin_fg.rco", "tex_cross", 4, -2); else pic_button_assign = vlfGuiAddPictureResource("system_plugin_fg.rco", "tex_circle", 4, -2); @@ -321,8 +298,8 @@ void SystemInfo() text_system[4] = pspEverestPrintf(237, 65, trans->system.password, GetRegistryValue("/CONFIG/SYSTEM/LOCK", "password", &password, sizeof(password), 0)); text_system[5] = pspEverestPrintf(10, 120, "version.txt:"); - if(vertxt != NULL) - text_system[6] = vlfGuiAddTextF(10, 143, GetVersionTxt()); + if (vertxt != NULL) + text_system[6] = vlfGuiAddTextF(10, 143, pspGetVersionTxt()); else text_system[6] = pspEverestPrintf(10, 143, trans->system.vertxterr); @@ -332,11 +309,9 @@ void SystemInfo() SetFade(); } -void SetBottomDialog(int enter, int back, int (* handler)(int enter), int delete_bd) -{ - if(delete_bd) - { - if(button_assign) +void SetBottomDialog(int enter, int back, int (* handler)(int enter), int delete_bd) { + if (delete_bd) { + if (button_assign) vlfGuiBottomDialog(back ? VLF_DI_BACK : -1, enter ? VLF_DI_ENTER : -1, 1, 0, 0, NULL); vlfGuiCancelBottomDialog(); @@ -345,12 +320,11 @@ void SetBottomDialog(int enter, int back, int (* handler)(int enter), int delete vlfGuiBottomDialog(back ? VLF_DI_BACK : -1, enter ? VLF_DI_ENTER : -1, 1, 0, VLF_DEFAULT, handler); } -void SetTitle(char *text) -{ - if(title_text != NULL) +void SetTitle(char *text) { + if (title_text != NULL) vlfGuiRemoveText(title_text); - if(title_pic != NULL) + if (title_pic != NULL) vlfGuiRemovePicture(title_pic); title_text = pspEverestPrintf(30, 1, text); @@ -359,18 +333,15 @@ void SetTitle(char *text) vlfGuiSetTitleBar(title_text, title_pic, 1, 0); } -void SetFade() -{ - if(pic_button_assign != NULL) +void SetFade(void) { + if (pic_button_assign != NULL) vlfGuiSetPictureFade(pic_button_assign, VLF_FADE_MODE_IN, VLF_FADE_SPEED_FAST, 0); vlfGuiSetRectangleFade(0, VLF_TITLEBAR_HEIGHT, 480, 272 - VLF_TITLEBAR_HEIGHT, VLF_FADE_MODE_IN, VLF_FADE_SPEED_FAST, 0, NULL, NULL, 0); } -int OnMainMenuScreenUp(void *param) -{ - switch(focus) - { +int OnMainMenuScreenUp(void *param) { + switch(focus) { case 1: focus = 0; vlfGuiRemoveTextFocus(main_menu[1], 1); @@ -399,10 +370,8 @@ int OnMainMenuScreenUp(void *param) return VLF_EV_RET_NOTHING; } -int OnMainMenuScreenDown(void *param) -{ - switch(focus) - { +int OnMainMenuScreenDown(void *param) { + switch(focus) { case 0: focus = 1; vlfGuiRemoveTextFocus(main_menu[0], 1); @@ -431,23 +400,20 @@ int OnMainMenuScreenDown(void *param) return VLF_EV_RET_NOTHING; } -void MainMenu(int select) -{ +void MainMenu(int select) { SetTitle("PSP EVEREST 2"); SetBottomDialog(1, 0, OnMainMenu, 0); focus = select; int main_x[4], main_y[4]; - if(language == PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN) - { + if (language == PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN) { main_x[0] = 143; main_y[0] = 85; main_x[1] = 141; main_y[1] = 107; main_x[2] = 140; main_y[2] = 129; main_x[3] = 207; main_y[3] = 151; } - else - { + else { main_x[0] = 143; main_y[0] = 85; main_x[1] = 151; main_y[1] = 107; main_x[2] = 151; main_y[2] = 129; @@ -466,45 +432,42 @@ void MainMenu(int select) SetFade(); } -void SetBackground() -{ - if(background_number < 0) +void SetBackground(void) { + if (background_number < 0) background_number = max_background_number; - else if(background_number > max_background_number) + else if (background_number > max_background_number) background_number = 0; vlfGuiSetBackgroundFileBuffer(backgrounds_bmp + background_number * 6176, 6176, 1); SetFade(); } -int app_main(int argc, char *argv[]) -{ +int app_main(int argc, char *argv[]) { sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &language); SetupTranslate(); - if(language == PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN) + if (language == PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN) vlfGuiSetLanguage(PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN); else vlfGuiSetLanguage(PSP_SYSTEMPARAM_LANGUAGE_ENGLISH); *(u32 *)kirk = pspGetKirkVersion(); *(u32 *)spock = pspGetSpockVersion(); - tachyon = sceSysregGetTachyonVersion(); - fuseid = sceSysregGetFuseId(); - fusecfg = sceSysregGetFuseConfig(); + tachyon = pspGetTachyonVersion(); + fuseid = pspGetFuseId(); + fusecfg = pspGetFuseConfig(); scramble = pspNandGetScramble(); - sceSysconGetBaryonVersion(&baryon); - sceSysconGetPommelVersion(&pommel); + pspGetBaryonVersion(&baryon); + pspGetPommelVersion(&pommel); devkit = sceKernelDevkitVersion(); GetRegistryValue("/CONFIG/SYSTEM/XMB", "button_assign", &button_assign, 4, 1); - vertxt = GetVersionTxt(); + vertxt = pspGetVersionTxt(); vlfGuiSystemSetup(1, 1, 1); - int OnBackgroundPlus(void *param) - { + int OnBackgroundPlus(void *param) { background_number++; battery_fade_ctrl = 1; SetBackground(); @@ -512,8 +475,7 @@ int app_main(int argc, char *argv[]) return VLF_EV_RET_NOTHING; } - int OnBackgroundMinus(void *param) - { + int OnBackgroundMinus(void *param) { background_number--; battery_fade_ctrl = 1; SetBackground(); diff --git a/main.h b/main.h index 1660343..8f87379 100644 --- a/main.h +++ b/main.h @@ -3,7 +3,7 @@ #include "vlf.h" -int psp_model, devkit, language; -u32 tachyon, baryon, pommel; +extern int psp_model, devkit, language; +extern u32 tachyon, baryon, pommel; #endif diff --git a/system_utils.c b/system_utils.c index 97ee3d5..fd9046b 100644 --- a/system_utils.c +++ b/system_utils.c @@ -11,96 +11,86 @@ int sctrlHENGetMinorVersion(); char get_firmware_buf[256], version_txt_buf[256]; -char *GetFirmwareName() -{ +char *pspGetFirmwareName(void) { char *cfwname = ""; int henid = sctrlHENGetVersion(); - if(devkit == 0x05000010) + if (devkit == 0x05000010) cfwname = "m33"; - else if(devkit == 0x05000210) + else if (devkit == 0x05000210) cfwname = "GEN"; - else if(devkit == 0x05000310) - { - if(henid != 0x8002013A) + else if (devkit == 0x05000310) { + if (henid != 0x8002013A) cfwname = "GEN/MHU"; else cfwname = "GEN/MHU"; } - else if(devkit == 0x05050010) + else if (devkit == 0x05050010) cfwname = "GEN"; - else if(devkit == 0x06020010) - { - if(sctrlHENGetMinorVersion() != 0x8002013A) - { - if(henid == 0x00001001) + else if (devkit == 0x06020010) { + if (sctrlHENGetMinorVersion() != 0x8002013A) { + if (henid == 0x00001001) cfwname = "PRO"; - else if(henid == 0x00001002) + else if (henid == 0x00001002) cfwname = "PRO-B"; - else if(henid == 0x00001003) + else if (henid == 0x00001003) cfwname = "PRO-C"; } - else if(henid == 0x00001000) + else if (henid == 0x00001000) cfwname = "TN-A"; - else if(henid == 0x00001001) + else if (henid == 0x00001001) cfwname = "TN-B"; - else if(henid == 0x00001002) + else if (henid == 0x00001002) cfwname = "TN-C"; - else if(henid == 0x00001003) + else if (henid == 0x00001003) cfwname = "TN-D"; - else if(henid == 0x00001004) + else if (henid == 0x00001004) cfwname = "TN-E"; } - else if(devkit == 0x06030110) + else if (devkit == 0x06030110) cfwname = "PRO HEN"; - else if(devkit == 0x06030510) - { - if(sctrlHENGetMinorVersion() != 0x8002013A) - { - if(henid == 0x00001001) + else if (devkit == 0x06030510) { + if (sctrlHENGetMinorVersion() != 0x8002013A) { + if (henid == 0x00001001) cfwname = "PRO"; - else if(henid == 0x00001002) + else if (henid == 0x00001002) cfwname = "PRO-B"; - else if(henid == 0x00001003) + else if (henid == 0x00001003) cfwname = "PRO-C"; } - else if(henid == 0x00001000) + else if (henid == 0x00001000) cfwname = "Custom"; } - else if(devkit == 0x06030610) + else if (devkit == 0x06030610) cfwname = "PRO HEN"; - else if(devkit == 0x06030710 && henid == 0x00001000) + else if (devkit == 0x06030710 && henid == 0x00001000) cfwname = "ME"; - else if(devkit == 0x06030810 && henid == 0x00001000) + else if (devkit == 0x06030810 && henid == 0x00001000) cfwname = "ME"; - else if(devkit == 0x06030910) - { - if(sctrlHENGetMinorVersion() != 0x8002013A) - { - if(henid == 0x00001001) + else if (devkit == 0x06030910) { + if (sctrlHENGetMinorVersion() != 0x8002013A) { + if (henid == 0x00001001) cfwname = "PRO"; - else if(henid == 0x00001002) + else if (henid == 0x00001002) cfwname = "PRO-B"; - else if(henid == 0x00001003) + else if (henid == 0x00001003) cfwname = "PRO-C"; } - else if(henid == 0x00001000) + else if (henid == 0x00001000) cfwname = "ME"; - else if(henid == 0x00002000) + else if (henid == 0x00002000) cfwname = "TN-A"; } - else if(devkit == 0x06060010) - { - if(sctrlHENGetMinorVersion() != 0x8002013A) - { - if(henid == 0x00001001) + else if (devkit == 0x06060010) { + if (sctrlHENGetMinorVersion() != 0x8002013A) { + if (henid == 0x00001001) cfwname = "PRO"; - else if(henid == 0x00001002) + else if (henid == 0x00001002) cfwname = "PRO-B"; - else if(henid == 0x00001003) + else if (henid == 0x00001003) cfwname = "PRO-C"; } - else if(henid == 0x00001000) + else if (henid == 0x00001000) cfwname = "ME"; } @@ -110,14 +100,12 @@ char *GetFirmwareName() return get_firmware_buf; } -char *GetVersionTxt() -{ +char *pspGetVersionTxt(void) { memset(version_txt_buf, 0, sizeof(version_txt_buf)); SceUID fd = sceIoOpen("flash0:/vsh/etc/version.txt", PSP_O_RDONLY, 777); - if(fd >= 0) + if (fd >= 0) sceIoRead(fd, version_txt_buf, 255); - else - { + else { sceIoClose(fd); return NULL; } diff --git a/system_utils.h b/system_utils.h index ffc1471..646feb6 100644 --- a/system_utils.h +++ b/system_utils.h @@ -1,7 +1,7 @@ #ifndef ___SYSTEM_UTILS_H___ #define ___SYSTEM_UTILS_H___ -char *GetFirmwareName(); -char *GetVersionTxt(); +char *pspGetFirmwareName(void); +char *pspGetVersionTxt(void); #endif diff --git a/utils.c b/utils.c index f4b514b..5f4448d 100644 --- a/utils.c +++ b/utils.c @@ -7,8 +7,7 @@ #include #include "main.h" -int GetRegistryValue(const char *dir, const char *name, void *buf, int bufsize, int inttype) -{ +int GetRegistryValue(const char *dir, const char *name, void *buf, int bufsize, int inttype) { int ret = 0; struct RegParam reg; REGHANDLE h; @@ -19,17 +18,14 @@ int GetRegistryValue(const char *dir, const char *name, void *buf, int bufsize, reg.unk2 = 1; reg.unk3 = 1; strcpy(reg.name, "/system"); - if(sceRegOpenRegistry(®, 2, &h) == 0) - { + if (sceRegOpenRegistry(®, 2, &h) == 0) { REGHANDLE hd; - if(!sceRegOpenCategory(h, dir, 2, &hd)) - { + if (!sceRegOpenCategory(h, dir, 2, &hd)) { REGHANDLE hk; unsigned int type, size; - if(!sceRegGetKeyInfo(hd, name, &hk, &type, &size)) - if(!sceRegGetKeyValue(hd, hk, buf, bufsize)) - { + if (!sceRegGetKeyInfo(hd, name, &hk, &type, &size)) + if (!sceRegGetKeyValue(hd, hk, buf, bufsize)) { ret = inttype ? 1 : (int)buf; sceRegFlushCategory(hd); } @@ -42,8 +38,7 @@ int GetRegistryValue(const char *dir, const char *name, void *buf, int bufsize, return ret; } -int Random(int min, int max) -{ +int Random(int min, int max) { u64 tick; SceKernelUtilsMt19937Context ctx; sceRtcGetCurrentTick(&tick); @@ -52,27 +47,22 @@ int Random(int min, int max) return min + (sceKernelUtilsMt19937UInt(&ctx) % max); } -int utf82unicode(wchar_t *dest, char *src) -{ +int utf82unicode(wchar_t *dest, char *src) { int i, x; unsigned char *usrc = (unsigned char *)src; - for(i = 0, x = 0; usrc[i];) - { + for(i = 0, x = 0; usrc[i];) { wchar_t ch; - if((usrc[i] & 0xE0) == 0xE0) - { + if ((usrc[i] & 0xE0) == 0xE0) { ch = ((usrc[i] & 0x0F) << 12) | ((usrc[i + 1] & 0x3F) << 6) | (usrc[i + 2] & 0x3F); i += 3; } - else if((usrc[i] & 0xC0) == 0xC0) - { + else if ((usrc[i] & 0xC0) == 0xC0) { ch = ((usrc[i] & 0x1F) << 6) | (usrc[i+1] & 0x3F); i += 2; } - else - { + else { ch = usrc[i]; i += 1; } @@ -85,32 +75,25 @@ int utf82unicode(wchar_t *dest, char *src) return x; } -void ascii2unicode(char *unicode, const char *ascii) -{ - while(*ascii != '\0') - { - if((unsigned char)*ascii >= 0xC0) - { +void ascii2unicode(char *unicode, const char *ascii) { + while(*ascii != '\0') { + if ((unsigned char)*ascii >= 0xC0) { *unicode++ = (unsigned char)*ascii - 0xB0; *unicode++ = 0x04; } - else if((unsigned char)*ascii == 0x99) - { + else if ((unsigned char)*ascii == 0x99) { *unicode++ = 0x22; *unicode++ = 0x21; } - else if((unsigned char)*ascii == 0xB8) - { + else if ((unsigned char)*ascii == 0xB8) { *unicode++ = 0x51; *unicode++ = 0x04; } - else if((unsigned char)*ascii == 0xA8) - { + else if ((unsigned char)*ascii == 0xA8) { *unicode++ = 0x01; *unicode++ = 0x04; } - else - { + else { *unicode++ = *ascii; *unicode++ = '\0'; } @@ -122,8 +105,7 @@ void ascii2unicode(char *unicode, const char *ascii) *unicode++ = '\0'; } -VlfText pspEverestPrintf(int x, int y, const char *text, ...) -{ +VlfText pspEverestPrintf(int x, int y, const char *text, ...) { char ascii[256], unicode[256]; va_list list; va_start(list, text);