![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Add -lpspumd to your LIBS....
![]() |
|
|
LinkBack | Thread Tools |
|
|
#122 |
![]() ![]() Developer
|
Ok, thanks alot!
But when you fix a problem there is always a new one... Now the program launches the UMD even if I don't push 'X'... So exactly when I execute the program it starts the UMD. Why doesn't the 'wait-for-me pressing-the-button' work?? Code:
while(1) {
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS) {
break;
}
i = sceUmdCheckMedium(0);
if (i == 0) { printf("- Insert UMD\n"); }
while (i == 0) {
i = sceUmdCheckMedium(0);
}
i = sceUmdActivate(1, "disc0:");
printf("- Mounted UMD\n");
i = sceUmdWaitDriveStat(UMD_WAITFORINIT);
fd = sceIoOpen("disc0:/UMD_DATA.BIN", PSP_O_RDONLY, 0777);
if(fd >= 0)
{
char game_id[11];
sceIoRead(fd, game_id, 10);
sceIoClose(fd);
game_id[10] = 0;
printf("- Found game %s\n", game_id);
}
sceKernelLoadExec("disc0:/PSP_GAME/SYSDIR/BOOT.BIN",0);
|
|
|
|
|
|
#123 | |
![]() |
Quote:
Code:
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS)
{
break;
}
}
Code:
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS)
break;
}
|
|
|
|
|
|
|
#124 |
![]() ![]() Developer
|
I tryed tto make a simple meny but it wont work...
Code:
while (1) {
sceCtrlReadBufferPositive(&pad, 1);
if (menu == 1) {
printTextScreen(10, 10, "something <--", RGB(0, 0, 0));
printTextScreen(10, 20, "something", RGB(0, 0, 0));
printTextScreen(10, 30, "something", RGB(0, 0, 0));
printTextScreen(10, 40, "something", RGB(0, 0, 0));
flipScreen();
}
if (menu == 2) {
printTextScreen(10, 10, "something", RGB(0, 0, 0));
printTextScreen(10, 20, "something <--", RGB(0, 0, 0));
printTextScreen(10, 30, "something", RGB(0, 0, 0));
printTextScreen(10, 40, "something", RGB(0, 0, 0));
flipScreen();
}
if (menu == 3) {
printTextScreen(10, 10, "something", RGB(0, 0, 0));
printTextScreen(10, 20, "something", RGB(0, 0, 0));
printTextScreen(10, 30, "something <--", RGB(0, 0, 0));
printTextScreen(10, 40, "something", RGB(0, 0, 0));
flipScreen();
}
if (menu == 4) {
printTextScreen(10, 10, "something", RGB(0, 0, 0));
printTextScreen(10, 20, "something", RGB(0, 0, 0));
printTextScreen(10, 30, "something", RGB(0, 0, 0));
printTextScreen(10, 40, "something <--", RGB(0, 0, 0));
flipScreen();
}
if (pad.Buttons & PSP_CTRL_UP) {
if (menu > 1) {
menu--;
for(i=0; i<10; i++) {
sceDisplayWaitVblankStart();
}
}
}
if (pad.Buttons & PSP_CTRL_DOWN) {
if (menu < 9) {
menu++;
for(i=0; i<10; i++) {
sceDisplayWaitVblankStart();
}
}
}
Last edited by SodR; 03-12-2006 at 07:09 AM.. |
|
|
|
|
|
#125 |
![]() ![]() ...in a dream...
|
What are you getting when complying? Also, might want to remove all the flipScreen()'s, you only need one, and when doing just text printing with printTextScreen, just put it at the end of the while loop / main infinite loop. O and dont make the colors
RGB(0, 0, 0); That makes them black aka, wont see them lol
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#126 | |
![]() ![]() Developer
|
Quote:
|
|
|
|
|
|
|
#127 | |
![]() |
Quote:
|
|
|
|
|
|
|
#128 |
![]() ![]() ...in a dream...
|
Here is something i just threw together:
Code:
void GameMenu() // ------------------------------Menu Function
{
char bufferStart[200];
char bufferOption[200];
char bufferCredit[200];
char bufferExit[200];
char bufferBG[200]; // { Complete Backround Loading
Image* bg;
sprintf(bufferBG, "bg.png");
bg = loadImage(bufferBG); // } Complete Backround loading
sprintf(bufferStart," S T A R T");
sprintf(bufferOption, "O P T I O N S");
sprintf(bufferCredit, "C R E D I T S");
sprintf(bufferExit, " E X I T");
int startx = 200, starty = 136;
int optionx = 200, optiony = 156;
int creditx = 200, credity = 176;
int exitx = 200, exity = 196;
int menucount = 0;
int i;
Color highlighted = RGB(255, 255, 255); // When selected
Color dimmed = RGB(55, 55, 55); // NOT selected
Color shadow = RGB(55, 55, 55); // When/Not selected
SceCtrlData pad;
while(1) {
blitAlphaImageToScreen(0, 0, 480, 272, bg, 0, 0);
// --- Seperator for Cleaner code...
printTextScreen(startx, starty, bufferStart, shadow); // {print the shadow of option
printTextScreen(optionx, optiony, bufferOption, shadow);
printTextScreen(creditx, credity, bufferCredit, shadow);
printTextScreen(exitx, exity, bufferExit, shadow); // } print the shadow of option
// --- Seperator for Cleaner code...
printTextScreen(startx, starty, bufferStart, dimmed); // [ print the dimmed version of option
printTextScreen(optionx, optiony, bufferOption, dimmed);
printTextScreen(creditx, credity, bufferCredit, dimmed);
printTextScreen(exitx, exity, bufferExit, dimmed); // ] print the dimmed version of option
sceCtrlReadBufferPositive(&pad, 1); // initialize 'pad' to work with controller
if(UPPressed) {
menucount--; // '--' Because menu is going downwards
for(i=0; i<10; i++) {
sceDisplayWaitVblankStart(); // Wait 1 second until initiation
}
}
if(DOWNPressed) {
menucount++;
for(i=0; i<10;i++) {
sceDisplayWaitVblankStart();
}
}
if(menucount < 0) menucount = 0;
if(menucount > 3) menucount = 3;
if(menucount == 0) {
printTextScreen(startx, starty, bufferStart, highlighted);
if(XPressed) {
GameMode = true;
}
}
if(menucount == 1) {
printTextScreen(optionx, optiony, bufferOption, highlighted);
}
if(menucount == 2) {
printTextScreen(creditx, credity, bufferCredit, highlighted);
}
if(menucount == 3) {
printTextScreen(exitx, exity, bufferExit, highlighted);
if(XPressed) {
pspDebugScreenClear();
clearScreen(RGB(100, 100, 100));
printTextScreen(100, 133, "H a v e A N i c e D a y ! ! !", highlighted);
sceKernelDelayThread(1000000*2); // wait 2 seconds before quiting
sceKernelExitGame();
}
} else if(GameMode==true) {
Game();
}
flipScreen();
} //while
} // --------------------------------------------END GAMEMENU
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#129 |
![]() ![]() Developer
|
Thanks alot SG57 but this line gives me some problem when I try to comply:
Code:
GameMode = true; btw. I changed Xpressed to pad.Buttons & PSP_CTRL_CROSS in the code. Because I assume that you have defined them that way, right? |
|
|
|
|
|
#130 |
![]() |
Alright, I hate to do this, because the problem seems so trivial, and knowing my luck I'm gonna find the answer to it myself as soon as I post this. However, I've been banging my head against this for awhile, and it's confounding me.
I have a class written called Paddle. I know this class is functional, as I've used it before and it executed perfectly. However, it's come to pass somehow that my other files in the project will no longer recognize the Paddle class. Everytime I try to create an instance of it, it thinks I'm trying to declare a variable with no type. Classes that used instances of this class that were working perfectly find beforehand are now no longer functional due to this. More specifically, I keep getting this error: ISO C++ forbids declaration of 'Paddle' with no type This occurs every time I try to create a new Paddle object. Here's the declaration of my Paddle class (contained in a seperate file named Paddle.h): Code:
class Paddle
{
private:
int nX,
nY,
nXSize,
nYSize;
bool bImageLoaded;
Image* imgPaddle;
public:
Paddle(void);
Paddle(int, int, int, int, char*);
bool LoadImage(char*, int, int);
bool ImageSuccess(void);
int GetX(void);
int GetY(void);
int GetXSize(void);
int GetYSize(void);
void Display(void);
void LoadXY(int, int);
void MoveX(int);
};
Here's one of the classes that's trying to use it: Code:
class Puck
{
private:
int nX,
nY,
nXSize,
nYSize,
nXVelocity,
nYVelocity,
nStartingX,
nStartingY,
nStartingXVelocity,
nStartingYVelocity,
nNumBlocks;
bool bImageLoaded;
Image* imgPuck;
Paddle* pPaddle;
Block* bBlocks;
public:
Puck(void);
Puck(int, int, int, int, int, int, int, Paddle*, Block*, char*);
bool LoadImage(char*, int, int);
bool ImageSuccess(void);
void SetVelocity(int, int);
void Reset(void);
int Refresh(void);
};
Code:
#include "psptools.h" #include "Block.h" #include "Paddle.h" Code:
TARGET = Breakout OBJS = main.o graphics.o framebuffer.o psptools.o Block.o Puck.o pause.o level.o Paddle.o CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) LIBDIR = LIBS = -lpspgu -lpsppower -lpng -lz -lm -lstdc++ LDFLAGS = EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = Breakout PSP PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak Last edited by Andorien; 03-12-2006 at 02:52 PM.. |
|
|
|
|
|
#131 | |
![]() ![]() ...in a dream...
|
Quote:
2. GameMode is just a flag I used to determine if my game was in the menu or in the game or credits or exiting, etc. 3. I defined true and false: #define true 1 #define false 0 So I could use them with teh GameMode flag and for better senseof whats is going on, not just a bunch of numbers and bools. Plus, Im not complaining or nothing, but debugging is a very useful 'skill' as someone had posted above. The complying errors you posted were very easy and understandable so maybe you could have looked at the code and realized "Wait a minute, I dont knoiw what 'true' means, and its not defined, theres the problem, along with GameMode". But I was once that way so I can not complain or else ill be a hipicrit :icon_smil
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) Last edited by SG57; 03-12-2006 at 03:38 PM.. |
|
|
|
|
|
|
#132 | |
![]() |
Quote:
|
|
|
|
|
|
|
#133 |
![]() ![]() Developer
|
I managed to fix the menu problem above, so nevermind about that one.
I want my program to execute MPH's Game Loader when I press X and I'm using this code: Code:
sceKernelLoadExec("ms0:/PSP/GAME/MPHGAMELOADER/EBOOT.BIN", 0);
I tryed with sceKernelLoadExec("ms0:/PSP/GAME/MPHGAMELOADER%/EBOOT.BIN", 0); but that didn't work either... ----------------------------------------------------- I know how to dump a single file with this code but what should I do if I want to dump the entire kd folder or the whole flash0? Code:
void DumpAta.prx(void)
{
int i;
int fd;
fd = sceIoOpen("flash0:/kd/ata.prx", PSP_O_RDONLY, 0777);
if(fd >= 0)
{
char path[256];
build_path(path, "ms0:/", kd, 0);
sceIoMkdir(path, 0777);
write_file("flash0:/kd/", path, "ata.prx");
}
}
Last edited by SodR; 03-13-2006 at 03:48 PM.. |
|
|
|
|
|
#134 |
|
11th Squad Captain
|
what do i do with loadvsh.sh?
I Wanna load my PRX File in the PSP's OS, and i got told that loadvsh.sh will do that for me. But at the moment i dont know how to load it? Should i open it up with a text editor and add the code from loadvsh.sh to my main.c file?
__________________
FAVORITE GAME! - BEER & ANIME! - SO EXICTING! ![]() 開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋 Currently Working On: - Flashmod V2.50 - Flashmod V2.60 Currently Drinking: Coffee! - 私はコーヒーを飲む Chao Garden: DEMO v0.6 Chao Garden V0.5b Review! |
|
|
|
|
|
#135 | |
![]() ![]() ...in a dream...
|
Quote:
Just kinda guessing
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
|
#136 | |
![]() ![]() Developer
|
Quote:
Because when I'm in user mode I can't start eboot.pbp from the ms but i can start UMD's with sceKernelLoadExec("disc0:/PSP_GAME/SYSDIR/BOOT.BIN",0); . But when I go into kernel mode with this line Code:
PSP_MODULE_INFO("MyApp", 0x1000, 1, 1); // 0x1000 = Kernel mode
PSP_MAIN_THREAD_ATTR(0); // Kernel Mode
I have no idea why I can't launch UMD's in kernel mode =S |
|
|
|
|
|
|
#137 |
![]() ![]() ...in a dream...
|
Well, think about the GTA exploit for a sec.... if UMD = USER MODE ONLY and GTA does not use kernel, only user mode, that may just be because it is in user mode, so that kinda verifys that user mode = UMD, unless fanjita or someone has a bigger brain ;-)
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#139 |
![]() ![]() ...in a dream...
|
Yes there is, do some multithreading. OSS like PSIX and such play UMD Games and run eboots.
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#141 |
|
Anybody know how I could launch EBOOT.PBP -files from my program? I'm trying to do a program where I could launch all my emulators by pressing the buttons on PSP, lets say that X launches NES-emulator, O launches SNES emulator and so on. I know everything else of how to do that except the loading of EBOOT.PBP's. I've tried to load them like this:
Code:
// Sets The Program To Kernel Mode
PSP_MODULE_INFO("EMULATOR_LAUNCHER", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
.
.
.
and in main I'm trying to launch the eboot like this:
sceKernelLoadExec("ms0:/EMULATORS/SNES.PBP",0);
So, does somebody know what's wrong and how I could succesfully load those .PBP -files? |
|
|
|
|
|
|
#142 |
![]() ![]() ...in a dream...
|
Look at the FileAssistant Source, tahts what they released it for ?-S
__________________
...you'll never know what it's like... spending your whole life in a dream...
Launch a Kitten out of a Cannon and win real cash! Checkout my newly updated site for all my projects (Kitten Cannon, BOXHEAD, Light Cycle 3D) |
|
|
|
|
|
#143 |
![]() |
is there a routine in C that will allow me to copy a substring from a given string.
for instance, say I want to extract the word 'World' from 'Hello World'? At the moment I'm using loops, which are a pain.. ![]() Thanks PS: I scanned the sdk docs, but nothing gave me any ideas, I'm sure there used to be a function though... EDIT: I've been using this..... Code:
char source[20];
char dest[20];
int f;
strcpy(source, "Hello World");
printf("source = %s\n", source);
for (f=0; f<=4; f++)
{
dest[f] = source[f+6];
}
printf("dest = %s\n", dest);
Last edited by polomint; 03-17-2006 at 02:48 AM.. |
|
|
|
|
|
#144 | |
|
Quote:
PSP-OSS and some other programs use Bootloader 1.0 to boot EBOOT.PBP's, but I haven't find anything of it.
|
||
|
|
|
|
|
#145 | |
![]() |
Quote:
I havn't worked with classes much, but I know I had a similar problem with structs. normally you can declare a struct like.. struct mystruct { stuff }; then declare it like... mystruct* mystructarray[10]; but for some reason you have to declare structs as... struct mystruc* mystructarray[10]; so maybe when you declare something of paddle class try class paddle* mypaddles; Only thing that I can think of
__________________
PSN: Shatterdome |
|
|
|
|
|
|
#146 | |
![]() |
Quote:
Last edited by Andorien; 03-17-2006 at 09:38 PM.. |
|
|
|
|
|
|
#147 |
![]() ![]() Developer
|
Yes, that bootloader would fix everything, too bad I can't find the sources.
btw. Miikkiz, have you made sure there is actually an eboot that is at ms0:/EMULATORS/SNES.PBP?? Shouldn't it be like this: ms0:/PSP/GAME/"theemulatorsfoldernamehe re"/EBOOT.PBP, since the excutable is always called eboot.pbp it's kinda weird to link to snes.pbp... |
|
|
|
|
|
#148 |
![]() |
This is kinda like the source code to one(.PBP^booter), but as it says... it doesn't work on 1.0
http://forums.ps2dev.org/viewtopic.p...00576e0177cb77 |
|
|
|
|
|
#149 | |
|
Quote:
Devun_06, thanks for posting that, I'll look for more in to it tomorrow, still it seems pretty confusing to me, a guy who just started to learn coding Im just wondering what do I need to edit in that code, where do I put the path to my EBOOT? I'll try something and post my results then.
Last edited by MiiKKiZ; 03-21-2006 at 12:51 PM.. |
||
|
|
|
|
|
#150 | |
|
Quote:
![]() EDIT: I actually found the source of Bootloader from FileAssistant forums, it can be downloaded here: http://www.easy-monkey.co.uk/Downloads/BootLoader.rar "Check out CFrameWork::RunExecutable and CFrameWork::RunUMD functions in FA++ source code to see how to use the loaders." But, as I'm a dumb idiot, I don't know how to use this, either. So, if somebody could post an example of this, how to load ms0:/Emulators/NES/EBOOT.PBP after the program starts, I would be so happy :icon_wink Last edited by MiiKKiZ; 03-26-2006 at 07:48 AM.. |
||
|
|
|
![]() |
| Tags |
| c or c , c++ , c/c++ , code , coding , c_language , programming , psp , psp programming , thread |
| Thread Tools | |
|
|