Página 1 de 2

[Solucionado Punto 3] Problemas con VLF en C

Publicado: 12 May 2010, 22:33
por Dark_Miguel
Tengo los siguientes problemas:

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;
}
 

Re: Problemas con VLF en C

Publicado: 13 May 2010, 05:19
por m0skit0
Dark_Dragon-Black escribió:2.- Tengo una aplicación hecha (a medias) pero el sub-menú creado no me funciona abajo os dejo el código:

Si quieres ayuda, deberías indicar dónde falla o dónde crees que está el fallo.

Dark_Dragon-Black escribió: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.

Por favor, indica en qué parte está el código en cuestión o postea simplemente la parte que te dé problemas ;)

Re: Problemas con VLF en C

Publicado: 13 May 2010, 07:24
por Dark_Miguel
Pues mira, en el primer fallo (sub-menu) cuando estoy dentro de la aplicación pulso extras y no aparecen las opciones.

Y en la tercera me da un error en la función de mostrar el porcentaje, dice esto:

Re: Problemas con VLF en C

Publicado: 13 May 2010, 14:13
por m0skit0
Dark_Dragon-Black escribió:el primer fallo (sub-menu) cuando estoy dentro de la aplicación pulso extras y no aparecen las opciones.

Concrétame dónde está eso implementado en el código, por favor.

Dark_Dragon-Black escribió:Y en la tercera me da un error en la función de mostrar el porcentaje, dice esto:

El enlazador no encuentra la función scePowerGetBatteryLifePercent. Eso significa que no has incluído la librería necesaría para ser enlazada.

Re: Problemas con VLF en C

Publicado: 13 May 2010, 22:34
por Dark_Miguel
Lo primero gracias por tu ayuda, lo segundo es que si que he incluido la librería psppower.h pero da el error yo ya estoy desconcertado... Y lo del submenú, pues... lo he hecho, contretamente he creado otro menú y he echo que si pulsas en la cuarta opción aparezca este...

Re: Problemas con VLF en C

Publicado: 14 May 2010, 16:58
por finfantasy
Pues si has incluido la libreria significa que el nombre lo has puesto mal xD

Re: Problemas con VLF en C

Publicado: 14 May 2010, 17:24
por Dark_Miguel
finfantasy escribió:Pues si has incluido la libreria significa que el nombre lo has puesto mal xD


No, el nombre está bien. He probado a compilar un hombrew pero tampoco funciona.

-- Doble Post --

Hola chicos, ya he solucionado mi problema, debido a mi super inorancia se me olvido poner la libreria en el Mackfile. Muchas gracias a todos!! Ahora necesito ayuda con el sub-Menu.

Re: [Solucionado Punto 3] Problemas con VLF en C

Publicado: 14 May 2010, 21:23
por m0skit0
Efectivamente, me refería a incluír la librería en el enlazador, no el .h

En cuanto al submenu, me refiero a que me especifiques dónde en tu código está la parte que se supone debe manejar eso ;)

Re: [Solucionado Punto 3] Problemas con VLF en C

Publicado: 14 May 2010, 21:31
por Dark_Miguel
Entendido. Aquí está:

Spoiler:

Código: Seleccionar todo

void ExampleSelectionExtra(int optt)
{
    if (optt == 0) {
        text = vlfGuiAddText(80, 100, "USB");
        optionn = optt;
    }
    if (optt == 1) {
        text = vlfGuiAddText(80, 100, "DUMP");
        optionn = optt;
    }
    if (optt == 2) {
        text = vlfGuiAddText(80, 100, "DUMP");
        optionn = optt;
    }
   
      if (optt == 3) {
        text = vlfGuiAddText(80, 100, "DUMP");
        optionn = optt;
    }
     
     if (optt == 4) {
        text = vlfGuiAddText(80, 100, "DUMP");
        optionn = optt;
    }
 
      if (optt == 5) {
        text = vlfGuiAddText(80, 100, "DUMP");
        optionn = optt;
    }

       if (optt == 6) {
        text = vlfGuiAddText(80, 100, "DUMP");
        optionn = optt;
    }
 
      if (optt == 7) {
        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;


      case 2:
            vlfGuiCancelBottomDialog();
         ExampleSelectionExtra(0);
        break;

        case 3:
            vlfGuiCancelBottomDialog();
             ExampleSelectionExtra(1);
        break;

      case 4:
            vlfGuiCancelBottomDialog();
         ExampleSelectionExtra(0);
        break;

        case 5:
            vlfGuiCancelBottomDialog();
             ExampleSelectionExtra(1);
        break;

      case 6:
            vlfGuiCancelBottomDialog();
         ExampleSelectionExtra(0);
        break;

        case 7:
            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",
     
     
   };

   vlfGuiCentralMenu(8, items, sel, ExtrasSelect, 0, 0); // Establece el menu
   vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
}   

Re: [Solucionado Punto 3] Problemas con VLF en C

Publicado: 14 May 2010, 22:22
por m0skit0
Hm pero eso parece sólo el código de la parte "Extras". Me refiero a dónde en el código llamas al submenu "Extras".