main: Clean-up code indentation and move source/headers into respective folders

This commit is contained in:
Joel16 2022-05-19 21:37:52 -04:00
parent 0a135b39d0
commit 0c4043b9d5
24 changed files with 1042 additions and 1049 deletions

View File

@ -1,5 +1,6 @@
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
OBJS = source/crt0.o source/main.o source/utils.o source/hardware_utils.o source/system_utils.o \
source/translate.o source/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
@ -12,8 +13,6 @@ 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 Rev6
PSP_EBOOT_ICON = ICON0.PNG

91
crt0.c
View File

@ -1,91 +0,0 @@
#include <pspsdk.h>
#include <pspkernel.h>
#include <string.h>
#include <stdio.h>
#include <vlf.h>
#include <kubridge.h>
#include <psputility_sysparam.h>
#include "main.h"
#include "everest_kernel_prx.h"
#include "kumdman_prx.h"
#include "intraFont_prx.h"
#include "vlf_prx.h"
extern int app_main(int argc, char *argv[]);
int SetupCallbacks(void) {
int CallbackThread(SceSize args, void *argp) {
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int thid = sceKernelCreateThread("PSP_EVEREST_UPDATE_THREAD", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
sceKernelStartThread(thid, 0, 0);
return thid;
}
void LoadStartModuleBuffer(char *path, char *buf, int size, SceSize args, void *argp) {
SceUID mod, out;
sceIoRemove(path);
out = sceIoOpen(path, PSP_O_WRONLY | PSP_O_CREAT, 0777);
sceIoWrite(out, buf, size);
sceIoClose(out);
mod = sceKernelLoadModule(path, 0, NULL);
mod = sceKernelStartModule(mod, args, argp, NULL, NULL);
sceIoRemove(path);
}
int start_thread(SceSize args, void *argp) {
char *path = (char *)argp;
int last_trail = -1;
int i;
for(i = 0; path[i]; i++)
if(path[i] == '/')
last_trail = i;
if(last_trail >= 0)
path[last_trail] = 0;
sceIoChdir(path);
path[last_trail] = '/';
if(psp_model != 4)
LoadStartModuleBuffer("kumdman.prx", (void *)kumdman_prx, size_kumdman_prx, args, argp);
LoadStartModuleBuffer("everest_kernel.prx", (void *)everest_kernel_prx, size_everest_kernel_prx, args, argp);
LoadStartModuleBuffer("intraFont.prx", (void *)intraFont_prx, size_intraFont_prx, args, argp);
strcpy((void *)vlf_prx + 0x6D678, "flash0:/font/ltn0.pgf");//WARNING: Path for font not be more 23 characters!
LoadStartModuleBuffer("vlf.prx", (void *)vlf_prx, size_vlf_prx, args, argp);
vlfGuiInit(-1, app_main);
return sceKernelExitDeleteThread(0);
}
int module_start(SceSize args, void *argp) {
SetupCallbacks();
psp_model = kuKernelGetModel();
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &language);
SceUID thid = sceKernelCreateThread("PSP_EVEREST_START_THREAD", start_thread, 0x10, 0x4000, 0, NULL);
if(thid < 0)
return thid;
sceKernelStartThread(thid, args, argp);
return 0;
}

View File

@ -1,13 +1,11 @@
TARGET = everest_kernel
OBJS = main.o imports.o
INCDIR = ../include ../libs/include ../
INCDIR = ../include ../libs/include
CFLAGS = -O2 -G0 -Wall -fno-pic
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
PSP_FW_VERSION = 271
BUILD_PRX = 1
PRX_EXPORTS = exports.exp

View File

@ -1,127 +0,0 @@
#include <pspsdk.h>
#include <pspkernel.h>
#include <string.h>
#include <stdio.h>
#include "main.h"
#include "utils.h"
#include "everest_kernel.h"
#include "translate.h"
#include "kumdman.h"
char macbuf[256];
int pspGetFirstSymbolOfModel(void) {
switch(psp_model + 1) {
case 1:
case 5:
case 11:
return 1;
case 2:
return 2;
case 3:
case 4:
case 7:
case 9:
return 3;
default:
break;
}
return -1;
}
char *pspGetRegionName(void) {
int region = pspGetRegion();
if (region >= 0 && region < 11)
return trans->hardware.regname[region];
return "-";
}
#define UNKNOWN 0x00000000
typedef struct {
u32 tachyon;
u32 baryon;
u32 pommel;
char *mobo_name;
} Motherboard;
Motherboard detmobo[] = {
/* PSP-100x */
{ 0x00140000, 0x00030600, 0x00000103, "TA-079v1" },
{ 0x00200000, 0x00030600, 0x00000103, "TA-079v2" },
{ 0x00200000, 0x00040600, 0x00000103, "TA-079v3" },
{ 0x00300000, 0x00040600, 0x00000103, "TA-081v1" },
{ 0x00300000, 0x00040600, 0x00000104, "TA-081v2" },
{ 0x00400000, 0x00114000, 0x00000112, "TA-082" },
{ 0x00400000, 0x00121000, 0x00000112, "TA-086" },
/* PSP-200x */
{ 0x00500000, 0x0022B200, 0x00000123, "TA-085v1" },
{ 0x00500000, 0x00234000, 0x00000123, "TA-085v2" },
{ 0x00500000, 0x00243000, 0x00000123, "TA-088v1" },// >----| If initial FW: 4.01, skipped TA-088v1...
{ 0x00500000, 0x00243000, 0x00000123, "TA-088v2" },// <----| ...and detected TA-088v2.
{ 0x00600000, 0x00243000, 0x00000123, "TA-088v3" },
{ 0x00500000, 0x00243000, 0x00000132, "TA-090v1" },
/* PSP-300x */
{ 0x00600000, 0x00263100, 0x00000132, "TA-090v2" },
{ 0x00600000, 0x00263100, 0x00000133, "TA-090v3" },
{ 0x00600000, 0x00285000, 0x00000133, "TA-092" },
{ 0x00810000, 0x002C4000, 0x00000141, "TA-093v1" },
{ 0x00810000, 0x002C4000, 0x00000143, "TA-093v2" },
{ 0x00810000, 0x002E4000, 0x00000154, "TA-095v1" },
{ 0x00820000, 0x002E4000, 0x00000154, "TA-095v2" },
/* PSP-N100x (PSPgo) */
{ 0x00720000, 0x00304000, 0x00000133, "TA-091" },
{ 0x00800000, 0x002A0000, UNKNOWN, "TA-094" },
/* PSP-E100x (PSP Essentials aka PSP Street) */
{ 0x00900000, 0x00403000, 0x00000154, "TA-096" },
/* DTP-T1000A */
{ 0x00100000, UNKNOWN, UNKNOWN, "Devkit" },
};
char *pspGetMoBoName(void) {
char *ret_mobo = "-";
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(pspGetInitialFW(), "4.01", 4))
continue;
else if (i == 10 /* TA-088v2 */ && strncmp(pspGetInitialFW(), "3.95", 4))
ret_mobo = "TA-088v1/v2";
ret_mobo = detmobo[i].mobo_name;
}
return ret_mobo;
}
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 *pspGetMacAddressText(void) {
u8 macaddr[512];
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 *pspGetModelName(void) {
char *models[] = { "PSP Fat", "PSP Slim", "PSP Brite", "PSP Brite", "PSPgo", "-", "PSP Brite", "-", "PSP Brite", "-", "PSP Street" };
return models[psp_model];
}

View File

@ -1,7 +0,0 @@
.set noreorder
#include "pspstub.s"
STUB_START "SystemCtrlForUser",0x40090000,0x00020005
STUB_FUNC 0x1090A2E1,sctrlHENGetVersion
STUB_FUNC 0x5328B431,sctrlHENGetMinorVersion

24
include/kumdman.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef ___KUMDMAN_H___
#define ___KUMDMAN_H___
static char outtxt[0x12];
typedef struct {
unsigned char peripheral_device_type;
unsigned char removable;
unsigned char standard_ver;
unsigned char atapi_response;
unsigned int additional;
char vendor_id[8];
char product_id[16];
char product_rev[4];
char sony_spec[0x14];
} ATAPI_INQURIY;
extern ATAPI_INQURIY ai;
extern u8 buf[0x38];
extern u8 param[4];
void *pspUmdManGetUmdDrive(int driveNum);
int pspUmdExecInquiryCmd(void *drive, u8 *param, u8 *buf);
#endif

77
include/translate.h Normal file
View File

@ -0,0 +1,77 @@
#ifndef __TRANSLATE_H__
#define __TRANSLATE_H__
struct HardwareInformation {
char *model;
char *no_model;
char *mobo;
char *region;
char *gen;
char *eeprom;
char *pandora;
char *initialfw;
char *umdfw;
char *nandsize;
char *regname[11];
};
struct BatteryInformation {
char *ex_power;
char *batt_stat;
char *batt_stat_present;
char *batt_stat_absent;
char *charging;
char *charging_cpl;
char *no_charge_lvl;
char *charge_lvl;
char *charge_stat;
char *charge_stat_low;
char *charge_stat_normal;
char *charge_stat_strong;
char *no_left_time;
char *left_time;
char *no_voltage;
char *voltage;
char *no_temperature;
char *temperature;
char *no_remain_capacity;
char *remain_capacity;
char *no_total_capacity;
char *total_capacity;
char *serial;
char *no_serial;
char *mode;
char *mode_service;
char *mode_autoboot;
char *mode_default;
};
struct SystemInformation {
char *fw;
char *button_assign;
char *username;
char *password;
char *vertxterr;
};
typedef struct _EverestTranslate {
char *yes;
char *no;
char *hardware_title;
struct HardwareInformation hardware;
char *battery_title;
struct BatteryInformation battery;
char *system_title;
struct SystemInformation system;
char *exit;
} EverestTranslate;
extern EverestTranslate *trans;
void SetupTranslate(void);
#endif

View File

@ -1,25 +0,0 @@
#ifndef ___KUMDMAN_H___
#define ___KUMDMAN_H___
static char outtxt[0x12];
typedef struct
{
unsigned char peripheral_device_type;
unsigned char removable;
unsigned char standard_ver;
unsigned char atapi_response;
unsigned int additional;
char vendor_id[8];
char product_id[16];
char product_rev[4];
char sony_spec[0x14];
}ATAPI_INQURIY;
ATAPI_INQURIY ai;
u8 buf[0x38];
u8 param[4] = { 0, 0, 0x38, 0 };
void *pspUmdManGetUmdDrive(int driveNum);
int pspUmdExecInquiryCmd(void *drive, u8 *param, u8 *buf);
#endif

480
main.c
View File

@ -1,480 +0,0 @@
//>>> PSP_EVEREST 2
//Copyright(C) 2011, frostegater
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspidstorage.h>
#include <stdio.h>
#include <string.h>
#include <pspctrl.h>
#include <psppower.h>
#include <stdarg.h>
#include <psputility_sysparam.h>
#include "main.h"
#include "vlf.h"
#include "utils.h"
#include "backgrounds_bmp.h"
#include "everest_kernel.h"
#include "hardware_utils.h"
#include "system_utils.h"
#include "translate.h"
PSP_MODULE_INFO("PSP_EVEREST", 0, 2, 0);
PSP_MAIN_THREAD_ATTR(0);
#define NUM_DEL_ITEMS_MAIN 4
#define NUM_DEL_ITEMS_HARDWARE 18
#define NUM_DEL_ITEMS_BATTERY 12
#define NUM_DEL_ITEMS_SYSTEM 11
#define EVE_ENTER_EN "Enter"
#define EVE_BACK_EN "Back"
VlfText main_menu[NUM_DEL_ITEMS_MAIN], text_hardware[NUM_DEL_ITEMS_HARDWARE], text_battery[NUM_DEL_ITEMS_BATTERY], text_system[NUM_DEL_ITEMS_SYSTEM], title_text;
VlfPicture title_pic, pic_button_assign;
int battery_break = 0, battery_fade_ctrl = 0, focus;
unsigned int button_assign;
char kirk[4], spock[4];
u32 fusecfg, scramble;
u16 bserialdata[2], serialdata[2];
u64 fuseid;
int psp_model, devkit, language;
u32 tachyon, baryon, pommel;
ScePsCode pscode;
int pscodeRet = 0;
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);
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);
void SetBackground(void);
int OnMainMenuScreenUp(void *param);
int OnMainMenuScreenDown(void *param);
char *vertxt;
int OnMainMenu(int enter) {
if (enter) {
vlfGuiRemoveEventHandler(OnMainMenuScreenUp);
vlfGuiRemoveEventHandler(OnMainMenuScreenDown);
for(int i = 0; i < NUM_DEL_ITEMS_MAIN; i++)
vlfGuiRemoveText(main_menu[i]);
switch(focus) {
case 0:
HardwareInfo();
break;
case 1:
battery_break = 0;
BatteryInfo();
break;
case 2:
SystemInfo();
break;
case 3:
sceKernelExitGame();
break;
}
}
return VLF_EV_RET_NOTHING;
}
int ExitInMainMenuHardwareInfo(int enter) {
if (!enter) {
for(int i = 0; i < NUM_DEL_ITEMS_HARDWARE; i++)
vlfGuiRemoveText(text_hardware[i]);
if (!button_assign)
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
vlfGuiCancelBottomDialog();
MainMenu(0);
}
return VLF_EV_RET_NOTHING;
}
int ExitInMainMenuBatteryInfo(int enter) {
if (!enter) {
battery_break = 1;
if (!button_assign)
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
vlfGuiCancelBottomDialog();
MainMenu(1);
}
return VLF_EV_RET_NOTHING;
}
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) {
vlfGuiRemovePicture(pic_button_assign);
pic_button_assign = NULL;
}
if (!button_assign)
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
vlfGuiCancelBottomDialog();
MainMenu(2);
}
return VLF_EV_RET_NOTHING;
}
void HardwareInfo(void) {
SetTitle(trans->hardware_title);
text_hardware[0] = pspEverestPrintf(10, 40, "Tachyon: 0x%08X", tachyon);
text_hardware[1] = pspEverestPrintf(10, 60, "Baryon: 0x%08X", baryon);
text_hardware[2] = pspEverestPrintf(10, 80, "Pommel: 0x%08X", pommel);
text_hardware[3] = pspEverestPrintf(10, 100, "FuseID: 0x%llX", fuseid);
text_hardware[4] = pspEverestPrintf(10, 120, "FuseCFG: 0x%08X", fusecfg);
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, 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, 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", 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) {
int swbt = 1, checkbt = 0;
vlfGuiCancelCentralMenu();
if (button_assign)
vlfGuiBottomDialog(VLF_DI_BACK, -1, 1, 0, 0, NULL);
vlfGuiCancelBottomDialog();
SetTitle(trans->battery_title);
battery_fade_ctrl = 0;
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;
}
vlfGuiDrawFrame();
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;
}
int battery_percent = scePowerGetBatteryLifePercent();
int battery_life_time = scePowerGetBatteryLifeTime();
if (update != 0 && scePowerIsBatteryExist() && swbt && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200))) {
pspReadSerial(bserialdata);
u16 wrbuffer[0x80];
wrbuffer[0] = 0x5053;
if (bserialdata[0] != 0x5058)
wrbuffer[1] = 0x5058;
else
wrbuffer[1] = 0x4456;
pspWriteSerial(wrbuffer);
checkbt = 0;
pspReadSerial(serialdata);
if (serialdata[0] == wrbuffer[0] && serialdata[1] == wrbuffer[1])
{
checkbt = 1;
pspWriteSerial(bserialdata);
}
swbt = 0;
}
if (swbt == 0 && !scePowerIsBatteryExist())
swbt = 1;
text_battery[0] = pspEverestPrintf(15, 70, trans->battery.ex_power, psp_model == 4 ? "-" : scePowerIsPowerOnline() ? trans->yes : trans->no);
text_battery[1] = pspEverestPrintf(15, 90, trans->battery.batt_stat, scePowerIsBatteryExist() ? trans->battery.batt_stat_present : trans->battery.batt_stat_absent);
text_battery[2] = pspEverestPrintf(15, 110, trans->battery.charging, scePowerIsBatteryCharging() ? scePowerIsBatteryExist() ? battery_percent == 100 ? trans->battery.charging_cpl : trans->yes : trans->no : trans->no);
text_battery[3] = pspEverestPrintf(15, 130, battery_percent > 100 || battery_percent < 0 ? trans->battery.no_charge_lvl : trans->battery.charge_lvl, battery_percent);
text_battery[4] = pspEverestPrintf(15, 150, trans->battery.charge_stat, battery_percent >= 0 && battery_percent <= 20 ? trans->battery.charge_stat_low : battery_percent > 20 && battery_percent < 70 ? trans->battery.charge_stat_normal : battery_percent >= 70 && battery_percent <= 100 ? trans->battery.charge_stat_strong : "-");
text_battery[5] = pspEverestPrintf(15, 170, battery_life_time < 0 || battery_life_time / 60 > 100 || (battery_life_time / 60 == 0 && battery_life_time - (battery_life_time / 60 * 60) == 0) ? trans->battery.no_left_time : trans->battery.left_time, battery_life_time / 60, battery_life_time - (battery_life_time / 60 * 60));
text_battery[6] = pspEverestPrintf(240, 70, scePowerGetBatteryVolt() <= 0 ? trans->battery.no_voltage : trans->battery.voltage, (float)scePowerGetBatteryVolt() / 1000.0);
text_battery[7] = pspEverestPrintf(240, 90, scePowerGetBatteryTemp() <= 0 ? trans->battery.no_temperature : trans->battery.temperature, scePowerGetBatteryTemp());
text_battery[8] = pspEverestPrintf(240, 110, scePowerGetBatteryRemainCapacity() <= 0 ? trans->battery.no_remain_capacity : trans->battery.remain_capacity, scePowerGetBatteryRemainCapacity());
text_battery[9] = pspEverestPrintf(240, 130, scePowerGetBatteryFullCapacity() <= 0 ? trans->battery.no_total_capacity : trans->battery.total_capacity, scePowerGetBatteryFullCapacity());
text_battery[10] = pspEverestPrintf(240, 150, scePowerIsBatteryExist() && (psp_model == 0 || (tachyon == 0x00500000 && baryon == 0x0022B200)) && checkbt ? trans->battery.serial : trans->battery.no_serial, bserialdata[0], bserialdata[1]);
text_battery[11] = pspEverestPrintf(240, 170, trans->battery.mode,
checkbt && scePowerIsBatteryExist() && bserialdata[0] == 0xFFFF && bserialdata[1] == 0xFFFF && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200)) ? trans->battery.mode_service :
checkbt && scePowerIsBatteryExist() && bserialdata[0] == 0x0000 && bserialdata[1] == 0x0000 && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200)) ? trans->battery.mode_autoboot :
checkbt && scePowerIsBatteryExist() && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200)) ? trans->battery.mode_default : "-");
}
if (!update) {
SetBottomDialog(0, 1, ExitInMainMenuBatteryInfo, 0);
SetFade();
}
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;
}
break;
}
vlfGuiDrawFrame();
}
}
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, 40, trans->system.fw, pspGetFirmwareName());
text_system[1] = pspEverestPrintf(10, 60, trans->system.button_assign);
text_system[2] = pspEverestPrintf(10, 80, "Company code: 0x%02X", pscode.companyCode);
text_system[3] = pspEverestPrintf(10, 100, "Product sub code: 0x%02X", pscode.productSubCode);
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);
vlfGuiSetPictureXY(pic_button_assign, 131, 63);
char unicode_username[26];
utf82unicode((wchar_t *)unicode_username, (char *)GetRegistryValue("/CONFIG/SYSTEM", "owner_name", &username, sizeof(username), 0));
text_system[4] = pspEverestPrintf(237, 40, trans->system.username);
text_system[5] = vlfGuiAddTextW(language == PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN ? 337 : 327, 40, (u16 *)unicode_username);
text_system[6] = pspEverestPrintf(237, 60, trans->system.password, GetRegistryValue("/CONFIG/SYSTEM/LOCK", "password", &password, sizeof(password), 0));
text_system[7] = pspEverestPrintf(237, 80, "Product code: 0x%02X", pscode.productCode);
text_system[8] = pspEverestPrintf(237, 100, "Factory code: 0x%02X", pscode.factoryCode);
text_system[9] = pspEverestPrintf(10, 130, "version.txt:");
if (vertxt != NULL)
text_system[10] = vlfGuiAddTextF(10, 155, pspGetVersionTxt());
else
text_system[10] = pspEverestPrintf(10, 155, trans->system.vertxterr);
vlfGuiSetTextFontSize(text_system[10], 0.75f);
SetBottomDialog(0, 1, ExitInMainMenuSystemInfo, 1);
SetFade();
}
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();
}
vlfGuiBottomDialog(back ? VLF_DI_BACK : -1, enter ? VLF_DI_ENTER : -1, 1, 0, VLF_DEFAULT, handler);
}
void SetTitle(char *text) {
if (title_text != NULL)
vlfGuiRemoveText(title_text);
if (title_pic != NULL)
vlfGuiRemovePicture(title_pic);
title_text = pspEverestPrintf(30, 1, text);
title_pic = vlfGuiAddPictureResource("ps3scan_plugin.rco", "tex_infobar_icon", 4, -2);
vlfGuiSetTitleBarEx(title_text, title_pic, 1, 0, 18);
}
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) {
case 1:
focus = 0;
vlfGuiRemoveTextFocus(main_menu[1], 1);
vlfGuiSetTextFocus(main_menu[0]);
break;
case 2:
focus = 1;
vlfGuiRemoveTextFocus(main_menu[2], 1);
vlfGuiSetTextFocus(main_menu[1]);
break;
case 3:
focus = 2;
vlfGuiRemoveTextFocus(main_menu[3], 1);
vlfGuiSetTextFocus(main_menu[2]);
break;
default:
focus = 3;
vlfGuiRemoveTextFocus(main_menu[0], 1);
vlfGuiSetTextFocus(main_menu[3]);
break;
}
return VLF_EV_RET_NOTHING;
}
int OnMainMenuScreenDown(void *param) {
switch(focus) {
case 0:
focus = 1;
vlfGuiRemoveTextFocus(main_menu[0], 1);
vlfGuiSetTextFocus(main_menu[1]);
break;
case 1:
focus = 2;
vlfGuiRemoveTextFocus(main_menu[1], 1);
vlfGuiSetTextFocus(main_menu[2]);
break;
case 2:
focus = 3;
vlfGuiRemoveTextFocus(main_menu[2], 1);
vlfGuiSetTextFocus(main_menu[3]);
break;
default:
focus = 0;
vlfGuiRemoveTextFocus(main_menu[3], 1);
vlfGuiSetTextFocus(main_menu[0]);
break;
}
return VLF_EV_RET_NOTHING;
}
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) {
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 {
main_x[0] = 143; main_y[0] = 85;
main_x[1] = 151; main_y[1] = 107;
main_x[2] = 151; main_y[2] = 129;
main_x[3] = 212; main_y[3] = 151;
}
main_menu[0] = pspEverestPrintf(main_x[0], main_y[0], trans->hardware_title);
main_menu[1] = pspEverestPrintf(main_x[1], main_y[1], trans->battery_title);
main_menu[2] = pspEverestPrintf(main_x[2], main_y[2], trans->system_title);
main_menu[3] = pspEverestPrintf(main_x[3], main_y[3], trans->exit);
vlfGuiSetTextFocus(main_menu[select]);
vlfGuiAddEventHandler(PSP_CTRL_UP, 0, OnMainMenuScreenUp, NULL);
vlfGuiAddEventHandler(PSP_CTRL_DOWN, 0, OnMainMenuScreenDown, NULL);
SetFade();
}
void SetBackground(void) {
vlfGuiSetBackgroundFileBuffer(backgrounds_bmp + 111168, 6176, 1);
SetFade();
}
int app_main(int argc, char *argv[]) {
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &language);
SetupTranslate();
if (language == PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN)
vlfGuiSetLanguage(PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN);
else
vlfGuiSetLanguage(PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
*(u32 *)kirk = pspGetKirkVersion();
*(u32 *)spock = pspGetSpockVersion();
tachyon = pspGetTachyonVersion();
fuseid = pspGetFuseId();
fusecfg = pspGetFuseConfig();
scramble = pspNandGetScramble();
pspGetBaryonVersion(&baryon);
pspGetPommelVersion(&pommel);
devkit = sceKernelDevkitVersion();
pscodeRet = pspChkregGetPsCode(&pscode);
GetRegistryValue("/CONFIG/SYSTEM/XMB", "button_assign", &button_assign, 4, 1);
vertxt = pspGetVersionTxt();
vlfGuiSystemSetup(1, 1, 1);
SetBackground();
MainMenu(0);
while(1)
vlfGuiDrawFrame();
return 0;
}

88
source/crt0.c Normal file
View File

@ -0,0 +1,88 @@
#include <pspsdk.h>
#include <pspkernel.h>
#include <string.h>
#include <stdio.h>
#include <vlf.h>
#include <kubridge.h>
#include <psputility_sysparam.h>
#include "main.h"
#include "everest_kernel_prx.h"
#include "kumdman_prx.h"
#include "intraFont_prx.h"
#include "vlf_prx.h"
extern int app_main(int argc, char *argv[]);
int SetupCallbacks(void) {
int CallbackThread(SceSize args, void *argp) {
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int thid = sceKernelCreateThread("PSP_EVEREST_UPDATE_THREAD", CallbackThread, 0x11, 0xFA0, 0, 0);
if (thid >= 0)
sceKernelStartThread(thid, 0, 0);
return thid;
}
void LoadStartModuleBuffer(char *path, char *buf, int size, SceSize args, void *argp) {
SceUID mod, out;
sceIoRemove(path);
out = sceIoOpen(path, PSP_O_WRONLY | PSP_O_CREAT, 0777);
sceIoWrite(out, buf, size);
sceIoClose(out);
mod = sceKernelLoadModule(path, 0, NULL);
mod = sceKernelStartModule(mod, args, argp, NULL, NULL);
sceIoRemove(path);
}
int start_thread(SceSize args, void *argp) {
char *path = (char *)argp;
int last_trail = -1;
for(int i = 0; path[i]; i++) {
if (path[i] == '/')
last_trail = i;
}
if (last_trail >= 0)
path[last_trail] = 0;
sceIoChdir(path);
path[last_trail] = '/';
if (psp_model != 4)
LoadStartModuleBuffer("kumdman.prx", (void *)kumdman_prx, size_kumdman_prx, args, argp);
LoadStartModuleBuffer("everest_kernel.prx", (void *)everest_kernel_prx, size_everest_kernel_prx, args, argp);
LoadStartModuleBuffer("intraFont.prx", (void *)intraFont_prx, size_intraFont_prx, args, argp);
strcpy((void *)vlf_prx + 0x6D678, "flash0:/font/ltn0.pgf");//WARNING: Path for font not be more 23 characters!
LoadStartModuleBuffer("vlf.prx", (void *)vlf_prx, size_vlf_prx, args, argp);
vlfGuiInit(-1, app_main);
return sceKernelExitDeleteThread(0);
}
int module_start(SceSize args, void *argp) {
SetupCallbacks();
psp_model = kuKernelGetModel();
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &language);
SceUID thid = sceKernelCreateThread("PSP_EVEREST_START_THREAD", start_thread, 0x10, 0x4000, 0, NULL);
if (thid < 0)
return thid;
sceKernelStartThread(thid, args, argp);
return 0;
}

134
source/hardware_utils.c Normal file
View File

@ -0,0 +1,134 @@
#include <pspsdk.h>
#include <pspkernel.h>
#include <string.h>
#include <stdio.h>
#include "main.h"
#include "utils.h"
#include "everest_kernel.h"
#include "translate.h"
#include "kumdman.h"
static char macbuf[256];
ATAPI_INQURIY ai;
u8 buf[0x38];
u8 param[4] = { 0, 0, 0x38, 0 };
int pspGetFirstSymbolOfModel(void) {
switch(psp_model + 1) {
case 1:
case 5:
case 11:
return 1;
case 2:
return 2;
case 3:
case 4:
case 7:
case 9:
return 3;
default:
break;
}
return -1;
}
char *pspGetRegionName(void) {
int region = pspGetRegion();
if (region >= 0 && region < 11)
return trans->hardware.regname[region];
return "-";
}
#define UNKNOWN 0x00000000
typedef struct {
u32 tachyon;
u32 baryon;
u32 pommel;
char *mobo_name;
} Motherboard;
Motherboard detmobo[] = {
/* PSP-100x */
{ 0x00140000, 0x00030600, 0x00000103, "TA-079v1" },
{ 0x00200000, 0x00030600, 0x00000103, "TA-079v2" },
{ 0x00200000, 0x00040600, 0x00000103, "TA-079v3" },
{ 0x00300000, 0x00040600, 0x00000103, "TA-081v1" },
{ 0x00300000, 0x00040600, 0x00000104, "TA-081v2" },
{ 0x00400000, 0x00114000, 0x00000112, "TA-082" },
{ 0x00400000, 0x00121000, 0x00000112, "TA-086" },
/* PSP-200x */
{ 0x00500000, 0x0022B200, 0x00000123, "TA-085v1" },
{ 0x00500000, 0x00234000, 0x00000123, "TA-085v2" },
{ 0x00500000, 0x00243000, 0x00000123, "TA-088v1" },// >----| If initial FW: 4.01, skipped TA-088v1...
{ 0x00500000, 0x00243000, 0x00000123, "TA-088v2" },// <----| ...and detected TA-088v2.
{ 0x00600000, 0x00243000, 0x00000123, "TA-088v3" },
{ 0x00500000, 0x00243000, 0x00000132, "TA-090v1" },
/* PSP-300x */
{ 0x00600000, 0x00263100, 0x00000132, "TA-090v2" },
{ 0x00600000, 0x00263100, 0x00000133, "TA-090v3" },
{ 0x00600000, 0x00285000, 0x00000133, "TA-092" },
{ 0x00810000, 0x002C4000, 0x00000141, "TA-093v1" },
{ 0x00810000, 0x002C4000, 0x00000143, "TA-093v2" },
{ 0x00810000, 0x002E4000, 0x00000154, "TA-095v1" },
{ 0x00820000, 0x002E4000, 0x00000154, "TA-095v2" },
/* PSP-N100x (PSPgo) */
{ 0x00720000, 0x00304000, 0x00000133, "TA-091" },
{ 0x00800000, 0x002A0000, UNKNOWN, "TA-094" },
/* PSP-E100x (PSP Essentials aka PSP Street) */
{ 0x00900000, 0x00403000, 0x00000154, "TA-096" },
/* DTP-T1000A */
{ 0x00100000, UNKNOWN, UNKNOWN, "Devkit" },
};
char *pspGetMoBoName(void) {
char initial_fw[8];
char *ret_mobo = "-";
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(pspGetInitialFW(initial_fw), "4.01", 4))
continue;
else if (i == 10 /* TA-088v2 */ && strncmp(pspGetInitialFW(initial_fw), "3.95", 4))
ret_mobo = "TA-088v1/v2";
ret_mobo = detmobo[i].mobo_name;
}
}
return ret_mobo;
}
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 *pspGetMacAddressText(void) {
u8 macaddr[512];
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 *pspGetModelName(void) {
char *models[] = { "PSP Fat", "PSP Slim", "PSP Brite", "PSP Brite", "PSPgo", "-", "PSP Brite", "-", "PSP Brite", "-", "PSP Street" };
return models[psp_model];
}

7
source/imports.S Normal file
View File

@ -0,0 +1,7 @@
.set noreorder
#include "pspstub.s"
STUB_START "SystemCtrlForUser",0x40090000,0x00020005
STUB_FUNC 0x1090A2E1,sctrlHENGetVersion
STUB_FUNC 0x5328B431,sctrlHENGetMinorVersion

475
source/main.c Normal file
View File

@ -0,0 +1,475 @@
//>>> PSP_EVEREST 2
//Copyright(C) 2011, frostegater
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspidstorage.h>
#include <stdio.h>
#include <string.h>
#include <pspctrl.h>
#include <psppower.h>
#include <stdarg.h>
#include <psputility_sysparam.h>
#include "main.h"
#include "vlf.h"
#include "utils.h"
#include "backgrounds_bmp.h"
#include "everest_kernel.h"
#include "hardware_utils.h"
#include "system_utils.h"
#include "translate.h"
PSP_MODULE_INFO("PSP_EVEREST", 0, 2, 0);
PSP_MAIN_THREAD_ATTR(0);
#define NUM_DEL_ITEMS_MAIN 4
#define NUM_DEL_ITEMS_HARDWARE 18
#define NUM_DEL_ITEMS_BATTERY 12
#define NUM_DEL_ITEMS_SYSTEM 11
#define EVE_ENTER_EN "Enter"
#define EVE_BACK_EN "Back"
VlfText main_menu[NUM_DEL_ITEMS_MAIN], text_hardware[NUM_DEL_ITEMS_HARDWARE], text_battery[NUM_DEL_ITEMS_BATTERY], text_system[NUM_DEL_ITEMS_SYSTEM], title_text;
VlfPicture title_pic, pic_button_assign;
static int battery_break = 0, battery_fade_ctrl = 0, focus = 0;
static unsigned int button_assign = 0;
static char initial_fw[8], kirk[4], spock[4];
static u32 fusecfg = 0, scramble = 0;
static u16 bserialdata[2], serialdata[2];
static u64 fuseid = 0;
static ScePsCode pscode = { 0 };
static char *vertxt = NULL;
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);
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);
void SetBackground(void);
int OnMainMenuScreenUp(void *param);
int OnMainMenuScreenDown(void *param);
int OnMainMenu(int enter) {
if (enter) {
vlfGuiRemoveEventHandler(OnMainMenuScreenUp);
vlfGuiRemoveEventHandler(OnMainMenuScreenDown);
for(int i = 0; i < NUM_DEL_ITEMS_MAIN; i++)
vlfGuiRemoveText(main_menu[i]);
switch(focus) {
case 0:
HardwareInfo();
break;
case 1:
battery_break = 0;
BatteryInfo();
break;
case 2:
SystemInfo();
break;
case 3:
sceKernelExitGame();
break;
}
}
return VLF_EV_RET_NOTHING;
}
int ExitInMainMenuHardwareInfo(int enter) {
if (!enter) {
for(int i = 0; i < NUM_DEL_ITEMS_HARDWARE; i++)
vlfGuiRemoveText(text_hardware[i]);
if (!button_assign)
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
vlfGuiCancelBottomDialog();
MainMenu(0);
}
return VLF_EV_RET_NOTHING;
}
int ExitInMainMenuBatteryInfo(int enter) {
if (!enter) {
battery_break = 1;
if (!button_assign)
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
vlfGuiCancelBottomDialog();
MainMenu(1);
}
return VLF_EV_RET_NOTHING;
}
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) {
vlfGuiRemovePicture(pic_button_assign);
pic_button_assign = NULL;
}
if (!button_assign)
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
vlfGuiCancelBottomDialog();
MainMenu(2);
}
return VLF_EV_RET_NOTHING;
}
void HardwareInfo(void) {
SetTitle(trans->hardware_title);
text_hardware[0] = pspEverestPrintf(10, 40, "Tachyon: 0x%08X", tachyon);
text_hardware[1] = pspEverestPrintf(10, 60, "Baryon: 0x%08X", baryon);
text_hardware[2] = pspEverestPrintf(10, 80, "Pommel: 0x%08X", pommel);
text_hardware[3] = pspEverestPrintf(10, 100, "FuseID: 0x%llX", fuseid);
text_hardware[4] = pspEverestPrintf(10, 120, "FuseCFG: 0x%08X", fusecfg);
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, 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, 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", pspGetMacAddressText());
text_hardware[15] = pspEverestPrintf(250, 160, trans->hardware.initialfw, initial_fw);
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) {
int swbt = 1, checkbt = 0;
vlfGuiCancelCentralMenu();
if (button_assign)
vlfGuiBottomDialog(VLF_DI_BACK, -1, 1, 0, 0, NULL);
vlfGuiCancelBottomDialog();
SetTitle(trans->battery_title);
battery_fade_ctrl = 0;
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;
}
vlfGuiDrawFrame();
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;
}
}
int battery_percent = scePowerGetBatteryLifePercent();
int battery_life_time = scePowerGetBatteryLifeTime();
if (update != 0 && scePowerIsBatteryExist() && swbt && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200))) {
pspReadSerial(bserialdata);
u16 wrbuffer[0x80];
wrbuffer[0] = 0x5053;
if (bserialdata[0] != 0x5058)
wrbuffer[1] = 0x5058;
else
wrbuffer[1] = 0x4456;
pspWriteSerial(wrbuffer);
checkbt = 0;
pspReadSerial(serialdata);
if (serialdata[0] == wrbuffer[0] && serialdata[1] == wrbuffer[1]) {
checkbt = 1;
pspWriteSerial(bserialdata);
}
swbt = 0;
}
if (swbt == 0 && !scePowerIsBatteryExist())
swbt = 1;
text_battery[0] = pspEverestPrintf(15, 70, trans->battery.ex_power, psp_model == 4 ? "-" : scePowerIsPowerOnline() ? trans->yes : trans->no);
text_battery[1] = pspEverestPrintf(15, 90, trans->battery.batt_stat, scePowerIsBatteryExist() ? trans->battery.batt_stat_present : trans->battery.batt_stat_absent);
text_battery[2] = pspEverestPrintf(15, 110, trans->battery.charging, scePowerIsBatteryCharging() ? scePowerIsBatteryExist() ? battery_percent == 100 ? trans->battery.charging_cpl : trans->yes : trans->no : trans->no);
text_battery[3] = pspEverestPrintf(15, 130, battery_percent > 100 || battery_percent < 0 ? trans->battery.no_charge_lvl : trans->battery.charge_lvl, battery_percent);
text_battery[4] = pspEverestPrintf(15, 150, trans->battery.charge_stat, battery_percent >= 0 && battery_percent <= 20 ? trans->battery.charge_stat_low : battery_percent > 20 && battery_percent < 70 ? trans->battery.charge_stat_normal : battery_percent >= 70 && battery_percent <= 100 ? trans->battery.charge_stat_strong : "-");
text_battery[5] = pspEverestPrintf(15, 170, battery_life_time < 0 || battery_life_time / 60 > 100 || (battery_life_time / 60 == 0 && battery_life_time - (battery_life_time / 60 * 60) == 0) ? trans->battery.no_left_time : trans->battery.left_time, battery_life_time / 60, battery_life_time - (battery_life_time / 60 * 60));
text_battery[6] = pspEverestPrintf(240, 70, scePowerGetBatteryVolt() <= 0 ? trans->battery.no_voltage : trans->battery.voltage, (float)scePowerGetBatteryVolt() / 1000.0);
text_battery[7] = pspEverestPrintf(240, 90, scePowerGetBatteryTemp() <= 0 ? trans->battery.no_temperature : trans->battery.temperature, scePowerGetBatteryTemp());
text_battery[8] = pspEverestPrintf(240, 110, scePowerGetBatteryRemainCapacity() <= 0 ? trans->battery.no_remain_capacity : trans->battery.remain_capacity, scePowerGetBatteryRemainCapacity());
text_battery[9] = pspEverestPrintf(240, 130, scePowerGetBatteryFullCapacity() <= 0 ? trans->battery.no_total_capacity : trans->battery.total_capacity, scePowerGetBatteryFullCapacity());
text_battery[10] = pspEverestPrintf(240, 150, scePowerIsBatteryExist() && (psp_model == 0 || (tachyon == 0x00500000 && baryon == 0x0022B200)) && checkbt ? trans->battery.serial : trans->battery.no_serial, bserialdata[0], bserialdata[1]);
text_battery[11] = pspEverestPrintf(240, 170, trans->battery.mode,
checkbt && scePowerIsBatteryExist() && bserialdata[0] == 0xFFFF && bserialdata[1] == 0xFFFF && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200)) ? trans->battery.mode_service :
checkbt && scePowerIsBatteryExist() && bserialdata[0] == 0x0000 && bserialdata[1] == 0x0000 && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200)) ? trans->battery.mode_autoboot :
checkbt && scePowerIsBatteryExist() && (psp_model == 0 || (tachyon <= 0x00500000 && baryon == 0x0022B200)) ? trans->battery.mode_default : "-");
}
if (!update) {
SetBottomDialog(0, 1, ExitInMainMenuBatteryInfo, 0);
SetFade();
}
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;
}
}
break;
}
vlfGuiDrawFrame();
}
}
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, 40, trans->system.fw, pspGetFirmwareName());
text_system[1] = pspEverestPrintf(10, 60, trans->system.button_assign);
text_system[2] = pspEverestPrintf(10, 80, "Company code: 0x%02X", pscode.companyCode);
text_system[3] = pspEverestPrintf(10, 100, "Product sub code: 0x%02X", pscode.productSubCode);
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);
vlfGuiSetPictureXY(pic_button_assign, 131, 63);
char unicode_username[26];
utf82unicode((wchar_t *)unicode_username, (char *)GetRegistryValue("/CONFIG/SYSTEM", "owner_name", &username, sizeof(username), 0));
text_system[4] = pspEverestPrintf(237, 40, trans->system.username);
text_system[5] = vlfGuiAddTextW(language == PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN ? 337 : 327, 40, (u16 *)unicode_username);
text_system[6] = pspEverestPrintf(237, 60, trans->system.password, GetRegistryValue("/CONFIG/SYSTEM/LOCK", "password", &password, sizeof(password), 0));
text_system[7] = pspEverestPrintf(237, 80, "Product code: 0x%02X", pscode.productCode);
text_system[8] = pspEverestPrintf(237, 100, "Factory code: %d", pscode.factoryCode);
text_system[9] = pspEverestPrintf(10, 130, "version.txt:");
if (vertxt != NULL)
text_system[10] = vlfGuiAddTextF(10, 155, pspGetVersionTxt());
else
text_system[10] = pspEverestPrintf(10, 155, trans->system.vertxterr);
vlfGuiSetTextFontSize(text_system[10], 0.75f);
SetBottomDialog(0, 1, ExitInMainMenuSystemInfo, 1);
SetFade();
}
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();
}
vlfGuiBottomDialog(back ? VLF_DI_BACK : -1, enter ? VLF_DI_ENTER : -1, 1, 0, VLF_DEFAULT, handler);
}
void SetTitle(char *text) {
if (title_text != NULL)
vlfGuiRemoveText(title_text);
if (title_pic != NULL)
vlfGuiRemovePicture(title_pic);
title_text = pspEverestPrintf(30, 1, text);
title_pic = vlfGuiAddPictureResource("ps3scan_plugin.rco", "tex_infobar_icon", 4, -2);
vlfGuiSetTitleBarEx(title_text, title_pic, 1, 0, 18);
}
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) {
case 1:
focus = 0;
vlfGuiRemoveTextFocus(main_menu[1], 1);
vlfGuiSetTextFocus(main_menu[0]);
break;
case 2:
focus = 1;
vlfGuiRemoveTextFocus(main_menu[2], 1);
vlfGuiSetTextFocus(main_menu[1]);
break;
case 3:
focus = 2;
vlfGuiRemoveTextFocus(main_menu[3], 1);
vlfGuiSetTextFocus(main_menu[2]);
break;
default:
focus = 3;
vlfGuiRemoveTextFocus(main_menu[0], 1);
vlfGuiSetTextFocus(main_menu[3]);
break;
}
return VLF_EV_RET_NOTHING;
}
int OnMainMenuScreenDown(void *param) {
switch(focus) {
case 0:
focus = 1;
vlfGuiRemoveTextFocus(main_menu[0], 1);
vlfGuiSetTextFocus(main_menu[1]);
break;
case 1:
focus = 2;
vlfGuiRemoveTextFocus(main_menu[1], 1);
vlfGuiSetTextFocus(main_menu[2]);
break;
case 2:
focus = 3;
vlfGuiRemoveTextFocus(main_menu[2], 1);
vlfGuiSetTextFocus(main_menu[3]);
break;
default:
focus = 0;
vlfGuiRemoveTextFocus(main_menu[3], 1);
vlfGuiSetTextFocus(main_menu[0]);
break;
}
return VLF_EV_RET_NOTHING;
}
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) {
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 {
main_x[0] = 143; main_y[0] = 85;
main_x[1] = 151; main_y[1] = 107;
main_x[2] = 151; main_y[2] = 129;
main_x[3] = 212; main_y[3] = 151;
}
main_menu[0] = pspEverestPrintf(main_x[0], main_y[0], trans->hardware_title);
main_menu[1] = pspEverestPrintf(main_x[1], main_y[1], trans->battery_title);
main_menu[2] = pspEverestPrintf(main_x[2], main_y[2], trans->system_title);
main_menu[3] = pspEverestPrintf(main_x[3], main_y[3], trans->exit);
vlfGuiSetTextFocus(main_menu[select]);
vlfGuiAddEventHandler(PSP_CTRL_UP, 0, OnMainMenuScreenUp, NULL);
vlfGuiAddEventHandler(PSP_CTRL_DOWN, 0, OnMainMenuScreenDown, NULL);
SetFade();
}
void SetBackground(void) {
vlfGuiSetBackgroundFileBuffer(backgrounds_bmp + 111168, 6176, 1);
SetFade();
}
int app_main(int argc, char *argv[]) {
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &language);
SetupTranslate();
if (language == PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN)
vlfGuiSetLanguage(PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN);
else
vlfGuiSetLanguage(PSP_SYSTEMPARAM_LANGUAGE_ENGLISH);
*(u32 *)kirk = pspGetKirkVersion();
*(u32 *)spock = pspGetSpockVersion();
tachyon = pspGetTachyonVersion();
fuseid = pspGetFuseId();
fusecfg = pspGetFuseConfig();
scramble = pspNandGetScramble();
pspGetBaryonVersion(&baryon);
pspGetPommelVersion(&pommel);
devkit = sceKernelDevkitVersion();
pspGetInitialFW(initial_fw);
pspChkregGetPsCode(&pscode);
GetRegistryValue("/CONFIG/SYSTEM/XMB", "button_assign", &button_assign, 4, 1);
vertxt = pspGetVersionTxt();
vlfGuiSystemSetup(1, 1, 1);
SetBackground();
MainMenu(0);
while(1)
vlfGuiDrawFrame();
return 0;
}

115
source/system_utils.c Normal file
View File

@ -0,0 +1,115 @@
#include <pspsdk.h>
#include <pspkernel.h>
#include <systemctrl.h>
#include <string.h>
#include <stdio.h>
#include "main.h"
#include "utils.h"
#include "translate.h"
int sctrlHENGetMinorVersion();
static char get_firmware_buf[256], version_txt_buf[256];
char *pspGetFirmwareName(void) {
char *cfwname = "";
int henid = sctrlHENGetVersion();
if (devkit == 0x05000010)
cfwname = "m33";
else if (devkit == 0x05000210)
cfwname = "GEN";
else if (devkit == 0x05000310) {
if (henid != 0x8002013A)
cfwname = "GEN/MHU";
else
cfwname = "GEN/MHU";
}
else if (devkit == 0x05050010)
cfwname = "GEN";
else if (devkit == 0x06020010) {
if (sctrlHENGetMinorVersion() != 0x8002013A) {
if (henid == 0x00001001)
cfwname = "PRO";
else if (henid == 0x00001002)
cfwname = "PRO-B";
else if (henid == 0x00001003)
cfwname = "PRO-C";
}
else if (henid == 0x00001000)
cfwname = "TN-A";
else if (henid == 0x00001001)
cfwname = "TN-B";
else if (henid == 0x00001002)
cfwname = "TN-C";
else if (henid == 0x00001003)
cfwname = "TN-D";
else if (henid == 0x00001004)
cfwname = "TN-E";
}
else if (devkit == 0x06030110)
cfwname = "PRO HEN";
else if (devkit == 0x06030510) {
if (sctrlHENGetMinorVersion() != 0x8002013A) {
if (henid == 0x00001001)
cfwname = "PRO";
else if (henid == 0x00001002)
cfwname = "PRO-B";
else if (henid == 0x00001003)
cfwname = "PRO-C";
}
else if (henid == 0x00001000)
cfwname = "Custom";
}
else if (devkit == 0x06030610)
cfwname = "PRO HEN";
else if (devkit == 0x06030710 && henid == 0x00001000)
cfwname = "ME";
else if (devkit == 0x06030810 && henid == 0x00001000)
cfwname = "ME";
else if (devkit == 0x06030910) {
if (sctrlHENGetMinorVersion() != 0x8002013A) {
if (henid == 0x00001001)
cfwname = "PRO";
else if (henid == 0x00001002)
cfwname = "PRO-B";
else if (henid == 0x00001003)
cfwname = "PRO-C";
}
else if (henid == 0x00001000)
cfwname = "ME";
else if (henid == 0x00002000)
cfwname = "TN-A";
}
else if (devkit == 0x06060010) {
if (sctrlHENGetMinorVersion() != 0x8002013A) {
if (henid == 0x00001001)
cfwname = "PRO";
else if (henid == 0x00001002)
cfwname = "PRO-B";
else if (henid == 0x00001003)
cfwname = "PRO-C";
}
else if (henid == 0x00001000)
cfwname = "ME";
}
char *devkit_chr = (char *)&devkit;
sprintf(get_firmware_buf, "%i.%i%i %s", devkit_chr[3], devkit_chr[2], devkit_chr[1], cfwname);
return get_firmware_buf;
}
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)
sceIoRead(fd, version_txt_buf, 255);
else {
sceIoClose(fd);
return NULL;
}
sceIoClose(fd);
return version_txt_buf;
}

119
source/utils.c Normal file
View File

@ -0,0 +1,119 @@
#include <pspsdk.h>
#include <pspkernel.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <pspreg.h>
#include <psprtc.h>
#include "main.h"
int GetRegistryValue(const char *dir, const char *name, void *buf, int bufsize, int inttype) {
int ret = 0;
struct RegParam reg;
REGHANDLE h;
memset(&reg, 0, sizeof(reg));
reg.regtype = 1;
reg.namelen = strlen("/system");
reg.unk2 = 1;
reg.unk3 = 1;
strcpy(reg.name, "/system");
if (sceRegOpenRegistry(&reg, 2, &h) == 0) {
REGHANDLE 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)) {
ret = inttype ? 1 : (int)buf;
sceRegFlushCategory(hd);
}
}
sceRegCloseCategory(hd);
}
sceRegFlushRegistry(h);
sceRegCloseRegistry(h);
}
return ret;
}
int Random(int min, int max) {
u64 tick;
SceKernelUtilsMt19937Context ctx;
sceRtcGetCurrentTick(&tick);
sceKernelUtilsMt19937Init(&ctx, (u32)tick);
return min + (sceKernelUtilsMt19937UInt(&ctx) % max);
}
int utf82unicode(wchar_t *dest, char *src) {
int i, x;
unsigned char *usrc = (unsigned char *)src;
for(i = 0, x = 0; usrc[i];) {
wchar_t ch;
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) {
ch = ((usrc[i] & 0x1F) << 6) | (usrc[i+1] & 0x3F);
i += 2;
}
else {
ch = usrc[i];
i += 1;
}
dest[x++] = ch;
}
dest[x++] = '\0';
return x;
}
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) {
*unicode++ = 0x22;
*unicode++ = 0x21;
}
else if ((unsigned char)*ascii == 0xB8) {
*unicode++ = 0x51;
*unicode++ = 0x04;
}
else if ((unsigned char)*ascii == 0xA8) {
*unicode++ = 0x01;
*unicode++ = 0x04;
}
else {
*unicode++ = *ascii;
*unicode++ = '\0';
}
ascii++;
}
*unicode++ = '\0';
*unicode++ = '\0';
}
VlfText pspEverestPrintf(int x, int y, const char *text, ...) {
char ascii[256], unicode[256];
va_list list;
va_start(list, text);
vsprintf(ascii, text, list);
va_end(list);
ascii2unicode(unicode, ascii);
return vlfGuiAddTextW(x, y, (u16 *)unicode);
}

View File

@ -1,116 +0,0 @@
#include <pspsdk.h>
#include <pspkernel.h>
#include <systemctrl.h>
#include <string.h>
#include <stdio.h>
#include "main.h"
#include "utils.h"
#include "translate.h"
int sctrlHENGetMinorVersion();
char get_firmware_buf[256], version_txt_buf[256];
char *pspGetFirmwareName(void) {
char *cfwname = "";
int henid = sctrlHENGetVersion();
if (devkit == 0x05000010)
cfwname = "m33";
else if (devkit == 0x05000210)
cfwname = "GEN";
else if (devkit == 0x05000310) {
if (henid != 0x8002013A)
cfwname = "GEN/MHU";
else
cfwname = "GEN/MHU";
}
else if (devkit == 0x05050010)
cfwname = "GEN";
else if (devkit == 0x06020010) {
if (sctrlHENGetMinorVersion() != 0x8002013A) {
if (henid == 0x00001001)
cfwname = "PRO";
else if (henid == 0x00001002)
cfwname = "PRO-B";
else if (henid == 0x00001003)
cfwname = "PRO-C";
}
else if (henid == 0x00001000)
cfwname = "TN-A";
else if (henid == 0x00001001)
cfwname = "TN-B";
else if (henid == 0x00001002)
cfwname = "TN-C";
else if (henid == 0x00001003)
cfwname = "TN-D";
else if (henid == 0x00001004)
cfwname = "TN-E";
}
else if (devkit == 0x06030110)
cfwname = "PRO HEN";
else if (devkit == 0x06030510) {
if (sctrlHENGetMinorVersion() != 0x8002013A) {
if (henid == 0x00001001)
cfwname = "PRO";
else if (henid == 0x00001002)
cfwname = "PRO-B";
else if (henid == 0x00001003)
cfwname = "PRO-C";
}
else if (henid == 0x00001000)
cfwname = "Custom";
}
else if (devkit == 0x06030610)
cfwname = "PRO HEN";
else if (devkit == 0x06030710 && henid == 0x00001000)
cfwname = "ME";
else if (devkit == 0x06030810 && henid == 0x00001000)
cfwname = "ME";
else if (devkit == 0x06030910) {
if (sctrlHENGetMinorVersion() != 0x8002013A) {
if (henid == 0x00001001)
cfwname = "PRO";
else if (henid == 0x00001002)
cfwname = "PRO-B";
else if (henid == 0x00001003)
cfwname = "PRO-C";
}
else if (henid == 0x00001000)
cfwname = "ME";
else if (henid == 0x00002000)
cfwname = "TN-A";
}
else if (devkit == 0x06060010) {
if (sctrlHENGetMinorVersion() != 0x8002013A) {
if (henid == 0x00001001)
cfwname = "PRO";
else if (henid == 0x00001002)
cfwname = "PRO-B";
else if (henid == 0x00001003)
cfwname = "PRO-C";
}
else if (henid == 0x00001000)
cfwname = "ME";
}
char *devkit_chr = (char *)&devkit;
sprintf(get_firmware_buf, "%i.%i%i %s", devkit_chr[3], devkit_chr[2], devkit_chr[1], cfwname);
return get_firmware_buf;
}
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)
sceIoRead(fd, version_txt_buf, 255);
else {
sceIoClose(fd);
return NULL;
}
sceIoClose(fd);
return version_txt_buf;
}

View File

@ -1,80 +0,0 @@
#ifndef __TRANSLATE_H__
#define __TRANSLATE_H__
struct HardwareInformation
{
char *model;
char *no_model;
char *mobo;
char *region;
char *gen;
char *eeprom;
char *pandora;
char *initialfw;
char *umdfw;
char *nandsize;
char *regname[11];
};
struct BatteryInformation
{
char *ex_power;
char *batt_stat;
char *batt_stat_present;
char *batt_stat_absent;
char *charging;
char *charging_cpl;
char *no_charge_lvl;
char *charge_lvl;
char *charge_stat;
char *charge_stat_low;
char *charge_stat_normal;
char *charge_stat_strong;
char *no_left_time;
char *left_time;
char *no_voltage;
char *voltage;
char *no_temperature;
char *temperature;
char *no_remain_capacity;
char *remain_capacity;
char *no_total_capacity;
char *total_capacity;
char *serial;
char *no_serial;
char *mode;
char *mode_service;
char *mode_autoboot;
char *mode_default;
};
struct SystemInformation
{
char *fw;
char *button_assign;
char *username;
char *password;
char *vertxterr;
};
typedef struct _EverestTranslate
{
char *yes;
char *no;
char *hardware_title;
struct HardwareInformation hardware;
char *battery_title;
struct BatteryInformation battery;
char *system_title;
struct SystemInformation system;
char *exit;
} EverestTranslate;
extern EverestTranslate *trans;
void SetupTranslate();
#endif

117
utils.c
View File

@ -1,117 +0,0 @@
#include <pspsdk.h>
#include <pspkernel.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <pspreg.h>
#include <psprtc.h>
#include "main.h"
int GetRegistryValue(const char *dir, const char *name, void *buf, int bufsize, int inttype) {
int ret = 0;
struct RegParam reg;
REGHANDLE h;
memset(&reg, 0, sizeof(reg));
reg.regtype = 1;
reg.namelen = strlen("/system");
reg.unk2 = 1;
reg.unk3 = 1;
strcpy(reg.name, "/system");
if (sceRegOpenRegistry(&reg, 2, &h) == 0) {
REGHANDLE 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)) {
ret = inttype ? 1 : (int)buf;
sceRegFlushCategory(hd);
}
sceRegCloseCategory(hd);
}
sceRegFlushRegistry(h);
sceRegCloseRegistry(h);
}
return ret;
}
int Random(int min, int max) {
u64 tick;
SceKernelUtilsMt19937Context ctx;
sceRtcGetCurrentTick(&tick);
sceKernelUtilsMt19937Init(&ctx, (u32)tick);
return min + (sceKernelUtilsMt19937UInt(&ctx) % max);
}
int utf82unicode(wchar_t *dest, char *src) {
int i, x;
unsigned char *usrc = (unsigned char *)src;
for(i = 0, x = 0; usrc[i];) {
wchar_t ch;
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) {
ch = ((usrc[i] & 0x1F) << 6) | (usrc[i+1] & 0x3F);
i += 2;
}
else {
ch = usrc[i];
i += 1;
}
dest[x++] = ch;
}
dest[x++] = '\0';
return x;
}
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) {
*unicode++ = 0x22;
*unicode++ = 0x21;
}
else if ((unsigned char)*ascii == 0xB8) {
*unicode++ = 0x51;
*unicode++ = 0x04;
}
else if ((unsigned char)*ascii == 0xA8) {
*unicode++ = 0x01;
*unicode++ = 0x04;
}
else {
*unicode++ = *ascii;
*unicode++ = '\0';
}
ascii++;
}
*unicode++ = '\0';
*unicode++ = '\0';
}
VlfText pspEverestPrintf(int x, int y, const char *text, ...) {
char ascii[256], unicode[256];
va_list list;
va_start(list, text);
vsprintf(ascii, text, list);
va_end(list);
ascii2unicode(unicode, ascii);
return vlfGuiAddTextW(x, y, (u16 *)unicode);
}