PSP Pro GamerZ

For all your PSP Needs
AKA Team Unknown Forum
 
HomeFAQRegisterLog in
---- Welcome to Team Unknown's official Forum, Don't forget to Register on the forum. Be sure to check out all of our projects such as uo DSONPSP and DigiPSP Also Check out our PSP Programming Tutorials Very Happy ----

Share | 
 

 [Tutorial] C/C++ Tutorials Part 2 - Making a Hello world by KaZ [Tutorial]

Go down 
AuthorMessage
KaZ
Admin
avatar

Posts : 131
Points : 204
Join date : 2010-09-20
Location : In The Sky

PostSubject: [Tutorial] C/C++ Tutorials Part 2 - Making a Hello world by KaZ [Tutorial]   Mon Sep 20, 2010 1:22 pm

This tutorial is by kaz. (c) if you modifiy the tutorial or copy edit modify and post please let me know before you do that.

First of all you have to have your enviroment setted up, i reccomend Cygwin or PSPSDK
[Heres a quick tutorial on how to setup pspsdk - [You must be registered and logged in to see this link.] ]

Before you carry on i think you should learn some of this:
FIRST of all a header is something like this
Code:
#include <pspkernel.h>
SECOND of all
Code:
PSP_MODULE_INFO("example", 0, 1, 1);
[<--Usermode Code] we need this to make out eboot.
Code:
PSP_MODULE_INFO("example", 0x1000, 1, 0);
now as you can after the text example the numbers are different. why? this example is now in kernel mode Smile
THIRDLY MOST IMPORTANT IF U WANT TO DISPLAY TEXT after u put ur PSP_MODULE_INFO blah blah on the next line u have to put this
Code:
#define printf pspDebugScreenPrintf
this allows us to print our text to our screen

ok so here are some definitions of some of the C++ lines
printf("text here"); - This is used to display the text
sceKernelDelayThread(100000); - Makes the user wait 1second then u can do whatever e.g display tex after 1sec or exit.
sceKernelExitGame(); - This is used to exit the game to xmb
SetupCallbacks(); - This is used so we can use the HOME Button. if u remove it then u cant press the home button to exit, but u can use sscekernelexitgame func

ok so lets start make a folder and make some files called

Makefile
main.c
[copy these into the folder you made]

these are the files we need to make our eboot.pbp

ok so lets go on ahead and and edit the makefile open it up in notepad and add this

Code:

TARGET = Hello_World

OBJS = main.o 

INCDIR =
CFLAGS = -G4 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR = c:\pspsdk\psp\sdk\lib
LDFLAGS =
STDLIBS= -losl -lpng -lz -lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm
LIBS=$(STDLIBS)$(YOURLIBS)


EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Hello World by KaZ


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

after you've copied that save it and exit it.
now we'll go on ahead to the main.c to edit, again open it up in notepad and copy and paste this code

Code:


#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <pspdisplay.h>


PSP_MODULE_INFO("Hello World with kaz's tut", 0, 1, 2);

#define printf pspDebugScreenPrintf
#define Wait sceKernelDelayThread(3000000);

/* Exit callback */
/* (c) tutorial made by KaZ */
int exit_callback(int arg1, int arg2, void *common) {
          sceKernelExitGame();
          return 0;
}

/* Callback thread */
/* (c) tutorial made by KaZ */
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 */
/* (c) tutorial made by KaZ */
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(int argc, char *argv[])
{
   pspDebugScreenInit();
   SetupCallbacks();
/* This is where the text is displayed (c) tutorial made by KaZ */
   printf("Hello World \n");
   printf("Made with KaZ's Tutorial (c) \n");
   printf("http://pspprogamerz.forummotion.com \n");
   sceKernelSleepThread();
   return 0;
}


edit the words after printf("to say whatever you want it to say");
\n means a new line
E.G printf("this is my first hello world\n");

next copy your folder and the makefile and main.c inside of it to pspdev/pspsdk and paste it in the psp folder
next open up pspdev.cmd/pspsdk.cmd and type cd psp/yourfoldername
then type make and wait for it then it should strip it into param.sfo a main.o and a eboot.pbp then just copy the eboot.pbp and run it on your psp and enjoy. YOU NEED A CFW/HBL PSP TO RUN THE PBP.

Third Tutorial - [You must be registered and logged in to see this link.]
Back to top Go down
 
[Tutorial] C/C++ Tutorials Part 2 - Making a Hello world by KaZ [Tutorial]
Back to top 
Page 1 of 1
 Similar topics
-
» Hot Toys making Indiana Jones figures, hints at Star Wars as well...
» Curl Tutorial!
» Tutorials - How to add multiple ranks Forumotion
» MOTU Classics: The Thread - Part 2
» Tutorials - Notice using css and table Forumotion

Permissions in this forum:You cannot reply to topics in this forum
PSP Pro GamerZ :: PSP :: C++ Tutorials/OSLIB/MIPS/Programming-
Jump to: