Página 1 de 2

[PSPSDK] Problema con codigo de plugin

Publicado: 18 May 2011, 01:51
por asmb
codigo del main.c
Spoiler:

Código: Seleccionar todo

#include <stdio.h>

#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>

#include <pspsdk.h>
#include <pspreg.h>
#include <kubridge.h>
#include <pspctrl.h>
#include <pspthreadman_kernel.h>
#include <psprtc.h>
#include <systemctrl_se.h>

PSP_MODULE_INFO("SampleGUI", PSP_MODULE_KERNEL, 0, 0 );

#define deactivate 0
#define activate 1
#define MAX_NUMBER_OF_THREADS 64
#define PAGE_SIZE 31         //
#define MAX_ENTRIES 1000      //

int scePower_0442D852(int unknown);
void ThreadsStatChange( bool stat, SceUID thlist[], int thnum );
int stop_flag;
SceUID st_thlist_first[MAX_NUMBER_OF_THREADS];
int st_thnum_first;
SceUID thlist[MAX_NUMBER_OF_THREADS];
int thnum;

// Variables que usaremos para leer las puslaciones y activar/desactivar el USB
SceCtrlData pad, lastpad;
int USB = deactivate, lastUSB = deactivate;

///******************* HILO PRINCIPAL *******************///
int main_thread(SceSize argc, void* argp)
{
    while(1) // Ciclo del plugin
   {
   sceKernelGetThreadmanIdList( SCE_KERNEL_TMID_Thread, thlist, MAX_NUMBER_OF_THREADS, &thnum );
    //   PULSACIONES
       sceCtrlReadBufferPositive(&pad, 1); // Leemos las pulsaciones
       if(pad.Buttons != lastpad.Buttons)
       {
         lastpad = pad;
         if(pad.Buttons & PSP_CTRL_LTRIGGER) // GATILLO L se desactiva el USB
         {
            pspDebugScreenSetBackColor(0xFF00F3F3);
            pspDebugScreenSetTextColor(0xFF000000);
            pspDebugScreenInit();
            pspDebugScreenSetXY(10,10);
            pspDebugScreenKprintf("Status: %d", USB);
            pspDebugScreenSetXY(10,12);
            pspDebugScreenKprintf("Desea salir ?");            
            pspDebugScreenSetXY(10,14);
            pspDebugScreenKprintf("YES = O,    No = X");
            sceKernelSuspendAllUserThreads();            
            if(pad.Buttons & PSP_CTRL_CIRCLE)
            {
            pspDebugScreenSetXY(10,16);
            pspDebugScreenKprintf("YES = O");
            ThreadsStatChange( true, thlist, thnum );   
            }
            else if(pad.Buttons & PSP_CTRL_CROSS)
            {
            pspDebugScreenSetXY(10,16);
            pspDebugScreenKprintf("No = X");            
            }   
         }
      }
       sceKernelDelayThread(50000);
   }
    return 0;
}

///******************* DEFINICIÓN DEL HILO *******************///
int module_start(SceSize args, void *argp)
{
   int thid = sceKernelCreateThread("SampleGUI", main_thread, 0x30, 0x1000, 0, NULL);
   if(thid >= 0) sceKernelStartThread(thid, args, argp);
   
   return 0;
}
void ThreadsStatChange( bool stat, SceUID thlist[], int thnum )
{
  int ( *request_stat_func )( SceUID ) = NULL;
  int i, j;
  SceUID selfid = sceKernelGetThreadId();

  if( stat ){
    request_stat_func = sceKernelResumeThread;
  } else{
    request_stat_func = sceKernelSuspendThread;
  }

  SceKernelThreadInfo status;

  for( i = 0; i < thnum; i++ ){
    bool no_target = false;
    for( j = 0; j < st_thnum_first; j++ ){
      if( thlist[i] == st_thlist_first[j] || selfid == thlist[i] ){
        no_target = true;
        break;
      }
    }

    sceKernelReferThreadStatus(thlist[i], &status);
    if( ! no_target ) ( *request_stat_func )( thlist[i] );
  }
}

codigo del Makefile
Spoiler:
TARGET = SampleGUI
OBJS = main.o

PSP_FW_VERSION = 500

BUILD_PRX = 1
USE_KERNEL_LIB = 1

CLASSG_LIBS = libs

INCDIR = $(CLASSG_LIBS)
CFLAGS = -Os -G0 -Wall -fno-strict-aliasing -fno-builtin-printf
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBS = -lpspreg -lpsprtc

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak


el problema esque después de que se activa con gatiilo L y
lo desactivo con gatillo L + Circulo no puedo entrar a video ni musica ni nada se paran todos los threads y no se que sea por favor ayuda ya no se que hacer :tiro: :tiro:

Re: [PSPSDK] Problema con codigo de plugin

Publicado: 18 May 2011, 08:16
por m0skit0
Pon ese código formateado porque así desde luego que no voy a leerlo.

Saludos.

Re: [PSPSDK] Problema con codigo de plugin

Publicado: 18 May 2011, 22:48
por asmb
como con la etiqueta code o como.
Espero me disculpen esque es la primera vez que escribo aquí :lol: :lol:

Re: [PSPSDK] Problema con codigo de plugin

Publicado: 19 May 2011, 04:54
por ~Rdavid~
asmb escribió:como con la etiqueta code o como.
Espero me disculpen esque es la primera vez que escribo aquí :lol: :lol:

Si, con esa.

Re: [PSPSDK] Problema con codigo de plugin

Publicado: 19 May 2011, 16:41
por largeroliker
Un código formateado es un código ordenado, siguiendo convenciones de estilo.

Re: [PSPSDK] Problema con codigo de plugin

Publicado: 19 May 2011, 17:00
por m0skit0
A lo que me refiero es que le pongas tabulaciones donde deben ir, y además usar la etiqueta [code] para que no pierda el formato. Y eso es aquí y en Marte ;)

Saludos y suerte :)

PD: tal y como lo has hecho :oki:

El bucle while que tienes no es válido para PSP. Debes insertar código que permita a otros hilos ejecutarse (como por ejemplo el sceKernelDelayThread que tienes fuera del while). La PSP no tiene multitarea/multihilo real, por tanto cada tarea/hilo debe ceder tiempo de ejecución para otros, especialmente el kernel, ya que si pasa X tiempo sin que se ejecute ningún hilo kernel el chip Syscon apagará la consola.

Re: [PSPSDK] Problema con codigo de plugin

Publicado: 19 May 2011, 17:11
por AzagraMac
m0skit0, como fueron tus inicios en la Scene de PSP???
Cabe la posibilidad de ejecutar plugins mediante alguna aplicación extra, aunque solo sea de manera temporal?

Un saludo.

Re: [PSPSDK] Problema con codigo de plugin

Publicado: 19 May 2011, 22:41
por asmb
gracias m0skit0 cuando tenga tiempo edito el codigo :D

-- Doble Post --

hola de nuevo este es mi nuevo codigo no se si estara bien.
puesto que funciona pero no responde a los controles

Spoiler:

Código: Seleccionar todo

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>

#include <pspsdk.h>
#include <pspreg.h>
#include <kubridge.h>
#include <pspctrl.h>
#include <pspumd.h>
#include <pspthreadman_kernel.h>
#include <psprtc.h>

PSP_MODULE_INFO("SampleGUI", PSP_MODULE_KERNEL, 0, 0 );

#define deactivate 0
#define activate 1
#define MAX_NUMBER_OF_THREADS 64
#define PAGE_SIZE 31         //
#define MAX_ENTRIES 1000      //

#define CHEACK_KEY (PSP_CTRL_SELECT | PSP_CTRL_START | PSP_CTRL_UP | PSP_CTRL_RIGHT | \
    PSP_CTRL_DOWN | PSP_CTRL_LEFT | PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER | PSP_CTRL_TRIANGLE | \
    PSP_CTRL_CIRCLE | PSP_CTRL_CROSS | PSP_CTRL_SQUARE | PSP_CTRL_NOTE | PSP_CTRL_HOME)

int scePower_0442D852(int unknown);
void sceKernelExitVSHVSH();
void get_button(SceCtrlData  *data);
void wait_button_up(void);
void ThreadsStatChange( bool stat, SceUID thlist[], int thnum );
int stop_flag;
SceUID st_thlist_first[MAX_NUMBER_OF_THREADS];
int st_thnum_first;
SceUID thlist[MAX_NUMBER_OF_THREADS];
int thnum;

void main_menu(void);

// Variables que usaremos para leer las puslaciones y activar/desactivar el USB
SceCtrlData data;

///******************* HILO PRINCIPAL *******************///
int main_thread(SceSize argc, void* argp)
{
   while(stop_flag == 0){
    sceKernelDelayThread( 50000 );
    get_button(&data);
    if((data.Buttons) == PSP_CTRL_LTRIGGER)
    {
      main_menu();   
    }       
    }
   return 0;
}
void main_menu(void)
{
            sceKernelGetThreadmanIdList( SCE_KERNEL_TMID_Thread, thlist, MAX_NUMBER_OF_THREADS, &thnum );
            sceKernelSuspendAllUserThreads();
            pspDebugScreenSetBackColor(0xFF00F3F3);
            pspDebugScreenSetTextColor(0xFF000000);
            pspDebugScreenInit();
            pspDebugScreenSetXY(10,10);
            pspDebugScreenKprintf("Status: %d", USB);
            pspDebugScreenSetXY(10,12);
            pspDebugScreenKprintf("Desea salir ?");            
            pspDebugScreenSetXY(10,14);
            pspDebugScreenKprintf("YES = O,    No = X");         
            wait_button_up();
            while(1)
            {
            get_button(&data);
                if((data.Buttons) == PSP_CTRL_CIRCLE)
            {
            pspDebugScreenSetXY(10,16);
            pspDebugScreenKprintf("YES = O");
            ThreadsStatChange( true, thlist, thnum );   
            }
            else if((data.Buttons) == PSP_CTRL_CROSS)
            {
            pspDebugScreenSetXY(10,16);
            pspDebugScreenKprintf("No = X");            
            }              
            else if((data.Buttons) == PSP_CTRL_RTRIGGER)
            {
            sceKernelExitVSHVSH(0);
            }                          
            }
    sceKernelDelayThreadCB(16000);
}
///******************* DEFINICIÓN DEL HILO *******************///
int module_start(SceSize args, void *argp)
{
   SceUID thid;
    stop_flag = 0;
   thid = sceKernelCreateThread("SampleGUI", main_thread, 30, 0x9000, PSP_THREAD_ATTR_NO_FILLSTACK, 0 );
   if( thid ) sceKernelStartThread( thid, args, argp );
   
   return 0;
}

int module_stop( void )
{
  stop_flag = 1;
  return 0;
}

void get_button(SceCtrlData *data)
{
  sceCtrlPeekBufferPositive( data, 1 );
  data->Buttons &= CHEACK_KEY;
}

void wait_button_up(void)
{
  while((data.Buttons & CHEACK_KEY) != 0)
  {
    sceCtrlPeekBufferPositive( &data, 1 );
  }
}

void ThreadsStatChange( bool stat, SceUID thlist[], int thnum )
{
  int ( *request_stat_func )( SceUID ) = NULL;
  int i, j;
  SceUID selfid = sceKernelGetThreadId();

  if( stat ){
    request_stat_func = sceKernelResumeThread;
  } else{
    request_stat_func = sceKernelSuspendThread;
  }

  SceKernelThreadInfo status;

  for( i = 0; i < thnum; i++ ){
    bool no_target = false;
    for( j = 0; j < st_thnum_first; j++ ){
      if( thlist[i] == st_thlist_first[j] || selfid == thlist[i] ){
        no_target = true;
        break;
      }
    }

    sceKernelReferThreadStatus(thlist[i], &status);
    if( ! no_target ) ( *request_stat_func )( thlist[i] );
  }
}

Re: [PSPSDK] Problema con codigo de plugin

Publicado: 20 May 2011, 14:39
por m0skit0

Código: Seleccionar todo

if((data.Buttons) == PSP_CTRL_LTRIGGER)

Esto no es así. Consulta la documentación o mira cómo lo hacen los demás.

AzagraMac escribió:m0skit0, como fueron tus inicios en la Scene de PSP???

Muy iniciales :lol:

AzagraMac escribió:Cabe la posibilidad de ejecutar plugins mediante alguna aplicación extra, aunque solo sea de manera temporal?

¿Te refieres en el HBL? Si es así, no, los plugins corren en modo kernel.

Re: [PSPSDK] Problema con codigo de plugin

Publicado: 20 May 2011, 19:33
por AzagraMac
No me referia exactamente al HBL, pero.. bueno.

Todos los plugins corren en modo Kernel? ninguno en modo User?

Que consejo podrias darme, tengo mucho interesas en la scene, auqnue tengo conocimientos de programacion en C, me falta algo. De hay que te preguntaba como fueron tus inicios, por donde empezaste, jeje.

un saludo compi ;-)