Page 1 of 1

Can anyone figure this out?

PostPosted: Thu Oct 12, 2006 4:31 pm
by Mailas
  Code:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspiofilemgr.h>
#include <pspgu.h>
#include <png.h>
#include <stdlib.h>
#include <string.h>
#include <pspaudio.h>
#include <pspaudiolib.h>
#include <psppower.h>
#include <psprtc.h>
extern "C"
{
#include "graphics.h"
}
#define RGB(r, g, b) ((r)|((g)<<8)|((b)<<16))

PSP_MODULE_INFO("MailasProduct", 0, 1, 1);

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
          sceKernelExitGame();
          return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
          int cbid;

          cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
          sceKernelRegisterExitCallback(cbid);

          sceKernelSleepThreadCB();

          return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
          int thid = 0;

          thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
          if(thid >= 0) {
                    sceKernelStartThread(thid, 0, 0);
          }

          return thid;
}

//GLOBAL VARIABLES
int main(void) {
    SetupCallbacks();
    initGraphics();

    SceCtrlData pad, lastpad;

    sceCtrlReadBufferPositive(&lastpad, 1);
   
    int MegaX = 27;
    int MegaY = 136;
   
    int ProtoX = 427;
    int ProtoY = 136;
   
    Image* MegaImage;
MegaImage = loadImage("./Images/M_Plat.png");

    Image* ProtoImage;
ProtoImage = loadImage("./Images/P_Plat.png");

    Image* PelletImage;
PelletImage = loadImage("./Images/pellet.png");

Image * Background;
Background = loadImage("./Images/Back.png");

       while(1) {
      sceCtrlReadBufferPositive(&pad, 1);

      if(pad.Buttons != lastpad.Buttons) { // 1
      lastpad = pad;
     

      if(pad.Buttons & PSP_CTRL_UP)
      {
       MegaY-=3;                     
      }
     
      if(pad.Buttons & PSP_CTRL_DOWN)
      {
       MegaY+=3;                     
      }
      } // 2
     
      blitAlphaImageToScreen(0, 0, 480, 272, Background, 0, 0);
      blitAlphaImageToScreen(0, 0, 33, 26, MegaImage, MegaX, MegaY);
      blitAlphaImageToScreen(0, 0, 24, 25, ProtoImage, ProtoX, ProtoY);
     
       sceDisplayWaitVblankStart();
flipScreen();
      }
      }


Its all down and my cygwin batch file is able to compile it and everything but it just doesnt want to show on my PSP screen, just shows it as black. Anyone know how to fix?

PostPosted: Thu Oct 12, 2006 6:13 pm
by .Vault
looks like u are missing a psp boot up file...

and i really have no idea how to fix it..

PostPosted: Fri Oct 13, 2006 4:45 pm
by Mailas
I have no idea what you're talking about but I was able to compile it.

EDIT:

Ah got it I just had to press in return 0;, but now it just freezes, anyone here know what to do?

PostPosted: Fri Oct 13, 2006 8:00 pm
by crait
i think the "sceDisplayWaitVblankStart();" may be in the wrong spot
hmm... also check out your make file...
you may want to put this lil peice of code in too
"pspDebugScreenClear();"

oh, and im going to copy some of that code because i couldn't figure out how to make an image become a variable... lol

PostPosted: Fri Oct 13, 2006 8:03 pm
by Mailas
Well to make it become a variable you save its X and Y position and let them blit to the screen.
And no the screDisplayWaitVBlankStart is in the right spot.

PostPosted: Fri Oct 13, 2006 8:50 pm
by crait
all i needed was an example to go by
i was talking about this though
Image* MegaImage;
MegaImage = loadImage("./Images/M_Plat.png");

silly head

also, did you check the makefile
maybe you didnt include all the #include thingermajigers in the make file?
and try adding this at the end of your code
  Code:
pspDebugScreenClear();

PostPosted: Fri Oct 13, 2006 9:16 pm
by Mailas
Umm no the game runs fine I fixed it myself with the return0;
You don't need that if you're usng call backs.

And no theres nothing wrong with the makefile.

PostPosted: Fri Oct 13, 2006 9:42 pm
by crait
ok
lol, its always good to dowble check