1.- No se como cargar olas diferentes a las de default, necesito un ejemplo.
2.- Tengo una aplicación hecha (a medias) pero el sub-menú creado no me funciona abajo os dejo el código:
Spoiler:
Código: Seleccionar todo
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <psppower.h>
#include <vlf.h>
PSP_MODULE_INFO("TodoInfoPSP", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
// Callbacks
int ExitCallback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp)
{
int callback_id;
callback_id = sceKernelCreateCallback("Exit Callback", ExitCallback, NULL);
sceKernelRegisterExitCallback(callback_id);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallback(void)
{
int thread_id = 0;
thread_id = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
if (thread_id >= 0) {
sceKernelStartThread(thread_id, 0, 0);
}
return thread_id;
}
void MainMenu(int sel);
void Extras(int sel);
int text;
int option = 0; // Para recordar la opcion seleccionada
int optionn = 0;
// Menu
int BackToMainMenu()
{
vlfGuiRemoveText(text);
vlfGuiCancelBottomDialog();
MainMenu(option);
return VLF_EV_RET_NOTHING;
}
int BackToMainMenuExtras()
{
vlfGuiRemoveText(text);
vlfGuiCancelBottomDialog();
Extras(option);
return VLF_EV_RET_NOTHING;
}
void ExampleSelectionExtra(int optt)
{
if (optt == 0) {
text = vlfGuiAddText(80, 100, "USB");
optionn = optt;
}
if (optt == 1) {
text = vlfGuiAddText(80, 100, "DUMP");
optionn = optt;
}
vlfGuiBottomDialog(VLF_DI_BACK, -1, 1, 0, VLF_DEFAULT, BackToMainMenuExtras);
}
int ExtrasSelect(int sel)
{
switch(sel)
{
case 0:
vlfGuiCancelBottomDialog();
ExampleSelectionExtra(0);
break;
case 1:
vlfGuiCancelBottomDialog();
ExampleSelectionExtra(1);
break;
}
return VLF_EV_RET_REMOVE_OBJECTS | VLF_EV_RET_REMOVE_HANDLERS;
}
void Extras(int sel)
{
//Opciones del menu (texto)
char *items[] =
{
"USB",
"Dumpear IPL",
"Dumpear NAND",
"Dumpear Flash0",
"Dumpear Flash1",
"Dumpear Flash2",
"Dumpear Flash3",
"Dumpear IdStorage",
"Dumpear Info de la PSP",
};
vlfGuiCentralMenu(9, items, sel, ExtrasSelect, 0, 0); // Establece el menu
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
}
void ExampleSelection(int opt)
{
if (opt == 0) {
text = vlfGuiAddText(80, 100, "Has escogido la primera opción.");
option = opt;
}
if (opt == 1) {
text = vlfGuiAddTextF(80, 100, "Has escogido la segunda opción.");
option = opt;
}
if (opt == 2) {
text = vlfGuiAddText(80, 100, "Has escogido la tercera opción." );
option = opt;
}
if (opt == 3) {
vlfGuiCancelCentralMenu();
Extras(option);
option = opt;
}
if (opt == 4) {
text = vlfGuiAddText(20, 50, "Creditos:\n\nAgradecimientos:\nEspecialmente a Germax y a Dark_Mizar\n\nProgramación y Diseño:\nDark_Dragon-Black y Germax\n\nPaginas del autor:\nPSP.Station.org y PSP.SceneBeta.Com");
option = opt;
}
if (opt == 5) {
text = vlfGuiAddText(80, 100, "Has escogido la cuarta opción.");
option = opt;
}
vlfGuiBottomDialog(VLF_DI_BACK, -1, 1, 0, VLF_DEFAULT, BackToMainMenu);
}
int OnMainMenuSelect(int sel)
{
switch(sel)
{
case 0:
vlfGuiCancelBottomDialog();
ExampleSelection(0);
break;
case 1:
vlfGuiCancelBottomDialog();
ExampleSelection(1);
break;
case 2:
vlfGuiCancelBottomDialog();
ExampleSelection(2);
break;
case 3:
vlfGuiCancelBottomDialog();
ExampleSelection(3);
break;
case 4:
vlfGuiCancelBottomDialog();
ExampleSelection(4);
break;
case 5:
sceKernelExitGame();
break;
}
return VLF_EV_RET_REMOVE_OBJECTS | VLF_EV_RET_REMOVE_HANDLERS;
}
void MainMenu(int sel)
{
char *items[] =
{
"Información PSP",
"Información Memory Stick",
"Información de la Bateria",
"Extras",
"Creditos",
"Salir",
}; // Opciones del menu
vlfGuiCentralMenu(6, items, sel, OnMainMenuSelect, 0, 0); // Establece el menu
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
}
// Aplicacion
int app_main()
{
void *battery_icon;
SetupCallback();
vlfGuiSetBackgroundSystem(1);
vlfGuiSetModelSystem(0, 0, 1);
// Variables
int icono;
int titulo;
titulo = vlfGuiAddText(0,0,"TodoInfoPSP C v1"); // Titulo barra superior
icono = vlfGuiAddPictureResource("sysconf_plugin", "tex_bar_init_icon", 4, -2);
vlfGuiSetTitleBar(titulo, icono, 1, 1);
// Añade el efecto de las ondas
vlfGuiAddClock(); // Añade el reloj en la esquina superior derecha
vlfGuiAddBatteryIconSystem(&battery_icon, 10*1000*1000); // Añade el icono de la bateria
// Cargamos Icono barra superior
// Mostramos menu anteriormente creado
MainMenu(0);
// Bucle principal
while(1)
{
vlfGuiDrawFrame(); // Mostramos todo por pantalla
}
sceKernelSleepThread();
return 0;
}
3.- He intentado hacer que la apllicación muestre el porcentage de la bateria pero me da error cuando creo que lo he hecho bien.
Spoiler:
Código: Seleccionar todo
#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <psppower.h>
#include <vlf.h>
PSP_MODULE_INFO("TodoInfoPSP", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
// Callbacks
int ExitCallback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp)
{
int callback_id;
callback_id = sceKernelCreateCallback("Exit Callback", ExitCallback, NULL);
sceKernelRegisterExitCallback(callback_id);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallback(void)
{
int thread_id = 0;
thread_id = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, THREAD_ATTR_USER, 0);
if (thread_id >= 0) {
sceKernelStartThread(thread_id, 0, 0);
}
return thread_id;
}
void MainMenu(int sel);
void Extras(int sel);
int text;
int option = 0; // Para recordar la opcion seleccionada
int optionn = 0;
// Menu
int BackToMainMenu()
{
vlfGuiRemoveText(text);
vlfGuiCancelBottomDialog();
MainMenu(option);
return VLF_EV_RET_NOTHING;
}
int BackToMainMenuExtras()
{
vlfGuiRemoveText(text);
vlfGuiCancelBottomDialog();
Extras(option);
return VLF_EV_RET_NOTHING;
}
void ExampleSelectionExtra(int optt)
{
if (optt == 0) {
text = vlfGuiAddText(80, 100, "USB");
optionn = optt;
}
if (optt == 1) {
text = vlfGuiAddText(80, 100, "DUMP");
optionn = optt;
}
vlfGuiBottomDialog(VLF_DI_BACK, -1, 1, 0, VLF_DEFAULT, BackToMainMenuExtras);
}
int ExtrasSelect(int sel)
{
switch(sel)
{
case 0:
vlfGuiCancelBottomDialog();
ExampleSelectionExtra(0);
break;
case 1:
vlfGuiCancelBottomDialog();
ExampleSelectionExtra(1);
break;
}
return VLF_EV_RET_REMOVE_OBJECTS | VLF_EV_RET_REMOVE_HANDLERS;
}
void Extras(int sel)
{
//Opciones del menu (texto)
char *items[] =
{
"USB",
"Dumpear IPL",
"Dumpear NAND",
"Dumpear Flash0",
"Dumpear Flash1",
"Dumpear Flash2",
"Dumpear Flash3",
"Dumpear IdStorage",
"Dumpear Info de la PSP",
};
vlfGuiCentralMenu(9, items, sel, ExtrasSelect, 0, 0); // Establece el menu
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
}
void ExampleSelection(int opt)
{
if (opt == 0) {
text = vlfGuiAddText(80, 100, "Has escogido la primera opción.");
option = opt;
}
if (opt == 2) {
text = vlfGuiAddTextF(80, 100, "Has escogido la segunda opción %d%%\n", scePowerGetBatteryLifePercent());
option = opt;
}
if (opt == 2) {
text = vlfGuiAddText(80, 100, "Has escogido la segunda opción." );
option = opt;
}
if (opt == 3) {
vlfGuiCancelCentralMenu();
Extras(option);
option = opt;
}
if (opt == 4) {
text = vlfGuiAddText(20, 50, "Creditos:\n\nAgradecimientos:\nEspecialmente a Germax y a Dark_Mizar\n\nProgramación y Diseño:\nDark_Dragon-Black y Germax\n\nPaginas del autor:\nPSP.Station.org y PSP.SceneBeta.Com");
option = opt;
}
if (opt == 5) {
text = vlfGuiAddText(80, 100, "Has escogido la segunda opción.");
option = opt;
}
vlfGuiBottomDialog(VLF_DI_BACK, -1, 1, 0, VLF_DEFAULT, BackToMainMenu);
}
int OnMainMenuSelect(int sel)
{
switch(sel)
{
case 0:
vlfGuiCancelBottomDialog();
ExampleSelection(0);
break;
case 1:
vlfGuiCancelBottomDialog();
ExampleSelection(1);
break;
case 2:
vlfGuiCancelBottomDialog();
ExampleSelection(2);
break;
case 3:
vlfGuiCancelBottomDialog();
ExampleSelection(3);
break;
case 4:
vlfGuiCancelBottomDialog();
ExampleSelection(4);
break;
case 5:
sceKernelExitGame();
break;
}
return VLF_EV_RET_REMOVE_OBJECTS | VLF_EV_RET_REMOVE_HANDLERS;
}
void MainMenu(int sel)
{
char *items[] =
{
"Información PSP",
"Información Memory Stick",
"Información de la Bateria",
"Extras",
"Creditos",
"Salir",
}; // Opciones del menu
vlfGuiCentralMenu(6, items, sel, OnMainMenuSelect, 0, 0); // Establece el menu
vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
}
// Aplicacion
int app_main()
{
void *battery_icon;
SetupCallback();
vlfGuiSetBackgroundSystem(1);
vlfGuiSetModelSystem(0, 0, 1);
// Variables
int icono;
int titulo;
titulo = vlfGuiAddText(0,0,"TodoInfoPSP C v1"); // Titulo barra superior
icono = vlfGuiAddPictureResource("sysconf_plugin", "tex_bar_init_icon", 4, -2);
vlfGuiSetTitleBar(titulo, icono, 1, 1);
// Añade el efecto de las ondas
vlfGuiAddClock(); // Añade el reloj en la esquina superior derecha
vlfGuiAddBatteryIconSystem(&battery_icon, 10*1000*1000); // Añade el icono de la bateria
// Cargamos Icono barra superior
// Mostramos menu anteriormente creado
MainMenu(0);
// Bucle principal
while(1)
{
vlfGuiDrawFrame(); // Mostramos todo por pantalla
}
sceKernelSleepThread();
return 0;
}