QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Help with code

This is a discussion on Help with code within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I am new to C and compiling for the psp here is my code. I get a few errors so ...

Reply
 
LinkBack Thread Tools
Old 10-04-2006, 07:17 PM   #1
 
cloudpjff7's Avatar
 
Join Date: Sep 2006
Location: Homebrewland, CA
Posts: 191
Trader Feedback: 0
Smile Help with code

I am new to C and compiling for the psp here is my code. I get a few errors so can anyone help with my problems.
Thx!
Code:
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudio.h>
#include <pspaudiolib.h>
#include <psppower.h>
#include <pspdisplay.h>
#include <png.h>
#include <graphics.h>
#include <stdio.h>
#include <pspgu.h>


#define printf pspDebugScreenPrintf
#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
#include "mp3player.h"
PSP_MODULE_INFO("Mp3 Player Example", 0, 1, 1);
#define printf pspDebugScreenPrintf
// TWILIGHT ZONE! <do doo do doo>
/* 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;
}
int main()
 {
          char buffer[200];
          Image* interface;
pspDebugScreenInit();
          SetupCallbacks();
          initGraphics();

 sprintf(buffer, "interface.png");
          interface = loadImage(buffer);
 
if (!interface) {
                    //Image load failed
                    printf("Sorry the image loading has failed try agian\n");
          } else { 

int x = 0;
                    int y = 0;
                    sceDisplayWaitVblankStart(); 

while (x < 480) {
while (y < 272) {
          blitAlphaImageToScreen(0 ,0 ,480 , 272, interface, x, y);
                                        y += 480;
                              } 

     x += 272;
                              y = 0;
                    }
          

}
// END OF TWILIGHT ZONE! <do doo do do>
int main() {
          scePowerSetClockFrequency(333, 333, 166);

          pspDebugScreenInit();
          SetupCallbacks();

          pspAudioInit();
          SceCtrlData pad;
          int i; 
  MP3_Init(1);
          MP3_Load("test.mp3");
          MP3_Play(); 
 while(1) {
                    sceCtrlReadBufferPositive(&pad, 1);
                    if(pad.Buttons & PSP_CTRL_CROSS) {
                              break;
                    } else if(pad.Buttons & PSP_CTRL_CIRCLE) {
                              MP3_Pause();
                              for(i=0; i<10; i++) {
                                        sceDisplayWaitVblankStart();
                              }
                    }

                    if (MP3_EndOfStream() == 1) {
                              MP3_Stop();
                    }
          } 
   MP3_Stop();
          MP3_FreeTune();

          sceKernelSleepThread();
             }
       flipScreen();
          } 
          sceKernelSleepThread();

          return 0;
}
cloudpjff7 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 07:28 PM   #2

Developer
 
Join Date: Mar 2006
Posts: 1,026
Trader Feedback: 0
Default

There's a C/C++ thread for this.

You haven't listed what errors you're having.

Learn what the parts of each tutorial do exactly before you copy/paste two of them together.
__________________

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197

Quote:
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
Insert_Witty_Name is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 07:35 PM   #3
 
cloudpjff7's Avatar
 
Join Date: Sep 2006
Location: Homebrewland, CA
Posts: 191
Trader Feedback: 0
Default

Quote:
Originally Posted by Insomniac197
There's a C/C++ thread for this.

You haven't listed what errors you're having.

Learn what the parts of each tutorial do exactly before you copy/paste two of them together.
Yah probably should huh, guess I'll read it again.
I know some C++ but not really any C

Next time i'll post in the C/C++ Help thread
cloudpjff7 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 07:45 PM   #4

 
Zettablade's Avatar
 
Join Date: May 2006
Location: Programming or Farming Mudkips
Posts: 657
Trader Feedback: 0
Default

Why teh hell do you have two main functions?
__________________
Current Project: Citrus
Zettablade is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-04-2006, 08:02 PM   #5

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

He copy and pasted, just as he admitted.

Also, you should really just use 1 blitAlphaImageToScreen rather than the loops that Yeldarb used to tile the image....
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-05-2006, 05:25 AM   #6
 
pspcoder05's Avatar
 
Join Date: Sep 2006
Posts: 167
Trader Feedback: 0
Default

He used loops cuz he wanted to display the same small image
allover the screen.
pspcoder05 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
code

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 11:57 PM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us