C/C++ Programming Help Thread
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; Zitat von Grimfate126 a function that converts degrees to radians just take degrees*(3,1415/180); 2. ALSO, how would i "blit" a ...
-
09-20-2006, 01:45 PM #931Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
just take degrees*(3,1415/180);
Zitat von Grimfate126
can't you just do,2. ALSO, how would i "blit" a 3D model to the screen using x,y,z positionst? (in 3D)
YES, i have read BILLIONS of tutorials, looked at the samples, BUT, all of them use prespective. i want to actually "blit" a model using x,y, and z coordinates, and be able to change them.
{
ScePspFVector3 move = { 0.0f-posx, 0.0f-posy, -8.0f-posz };
sceGumTranslate( &move );
}
sceGumDrawArray( GU_TRIANGLES, GU_COLOR_8888|GU_VERTEX_3 2BITF|GU_TRANSFORM_3D,
3*12, 0, exampleobject);
?
-
09-20-2006, 01:50 PM #932Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von waterbottle
hmm. i have 2 questions about that moving code:
1.what is the 'f' after each number? adn why is the last number 8 instead of 0?Code:ScePspFVector3 move = { 0.0f-posx, 0.0f-posy, -8.0f-posz };
2.what does that mean??Code:sceGumTranslate( &move );
thx for helping!!!
--------------------------------------------------------------------------------------
-
09-20-2006, 01:54 PM #933AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Hmm.. Did you read these tutorials about using the GU?
http://www.psp-programming.com/code/...id=c:tutorials
-
09-20-2006, 01:55 PM #934Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
the f is just there becouse it's a float. I don't think you need it.
Zitat von Grimfate126
it's -8 instead of 0 becouse that positiones the object so you can see it.
sceGumTranslate( &move );
moves the position thingh accoriding to what move is.
I recommend you to do the GU tutorials
http://www.psp-programming.com/code/...id=c:tutorials
-
09-20-2006, 03:00 PM #935Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Check out the SDK sample in gu/cube it teaches you everything you need to know.
Zitat von Grimfate126

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-20-2006, 03:39 PM #936Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
thx! i read the tutorials. they were great!! i never even saw that site.. but i have two more (simple) questions:
Zitat von waterbottle
in the makefile (in the first tut) at the end there is this:
what would i put there if i had like these two files:Code:./main.o: ./main.cpp $(CXX) $(CXXFLAGS) -c ./main.cpp -o ./main.o
Code:main.c bullet.c
and, im using C, so will that make any difference to the code/makefile?--------------------------------------------------------------------------------------
-
09-20-2006, 04:09 PM #937Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Yes and yes. You don't need that code in your makefile - just list the files in the OBJs line.
Zitat von Grimfate126
You'll likely have to modify the code to fit with C.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-20-2006, 06:34 PM #938Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Insomniac197
what do you mean by "list the files in the obj's lines?"
and how much should i have to modify it. i think not having the structures should make it work. other than that, it should work.. shouldnt it??
oh and one more thing:
how would i blit an obj wit your lib. so far it only supports loading.
-= Double Post =-
one more thing: in the GU tuts, they use:
Code:dList = malloc( 1500 );
what does "malloc" do? and what does the argument mean?
thx!Geändert von Grimfate126 (09-20-2006 um 06:34 PM Uhr) Grund: Automerged Doublepost
--------------------------------------------------------------------------------------
-
09-21-2006, 03:05 AM #939Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
You need to put the PSP down and learn some basic C mate first.
Zitat von Grimfate126
In your makefile will be a line that starts with 'OBJS =' that's your OBJS line!
'mylib' is not a lib, it's code to load an obj file, which it does perfectly.
Read some basic C tutorials to learn what malloc is used for.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-21-2006, 04:14 AM #940Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Insomniac197
lol. i misunderstood you. i thought you were talking about the obj loader you gave me, not the actual OBJ line. ;)
and i found out malloc does 2 minutes after posted.
sry for the confusion, and thx!
--------------------------------------------------------------------------------------
-
09-22-2006, 08:10 AM #941I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
I'm trying to compile the custom firmware, proof of concept, but I keep getting an error. And the only thing I changed in it is the directory of the config file, so I know I didn't make an error. Anyone know the problem.
Code:$ make psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk /include -O2 -G0 -Wall -c -o main.o main.c psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk /include -O2 -G0 -Wall -L../libs -L. -L/usr/local/pspdev/psp/sdk/lib -Telf_mips allegrexel_psp_2.x -mno-crt0 -nostartfiles main.o conf.o -lpspvshbridge_2 -lpsp debug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpsplibc -lpspnet -lpspnet_inet - lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o vshmain.el f /usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/bin/ld: cannot find -lpspvsh bridge_2 collect2: ld returned 1 exit status make: *** [vshmain.elf] Error 1

-
09-22-2006, 08:38 AM #942QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yes, it says the error in the message that you shown:
You are missing the pspvshbridge_2.a library.Code:/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/bin/ld: cannot find -lpspvsh bridge_2
-
09-22-2006, 11:02 AM #943I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Yeah, I seen that file, but how do I install it?
Zitat von head_54us
-= Double Post =-
Anyone?Geändert von ARza (09-22-2006 um 11:02 AM Uhr) Grund: Automerged Doublepost

-
09-22-2006, 11:30 AM #944
post your make file please.
-
09-22-2006, 12:05 PM #945I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
EDIT: I found the problem.
-= Double Post =-
Now I have a new problem. I'm trying to make a PRX that loads an EBOOT automatically at startup. I used this tutorial to learn how to load EBOOTs, but when I try to compile, it doesn't work. Here's my code.
Code:
Makefile:Code:#include <pspkernel.h> #include <pspdebug.h> #include <string.h> #include <psploadexec.h> PSP_MODULE_INFO("EBOOTLOADER", 0x1000, 1, 1); PSP_MAIN_THREAD_ATTR (0); pspDebugInstallKprintfHandler (NULL); pspDebugInstallErrorHandler (NULL); void loadeboot() { //char *pbpath; const u32 pbplen = strlen("flash0:/vsh/etc/EBOOT.PBP")+1; struct SceKernelLoadExecParam eloader; eloader.args = pbplen; eloader.argp = "flash0:/vsh/etc/EBOOT.PBP"; eloader.key = NULL; eloader.size = sizeof(eloader) + pbplen; } int main() { pspDebugScreenInit(); pspDebugScreenPrintf("Loading EBOOT..\n"); loadeboot(); }
Error:Code:TARGET = EBOOT Loader OBJS = main.o BUILD_PRX=1 PRX_EXPORTS=exports.exp USE_PSPSDK_LIBC = 1 INCDIR = CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) LIBDIR = PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak
Code:$ make psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk /include -O2 -G0 -Wall -c -o main.o main.c main.c:8: error: syntax error before '(' token main.c:9: error: syntax error before '(' token make: *** [main.o] Error 1Geändert von ARza (09-22-2006 um 12:21 PM Uhr) Grund: Automerged Doublepost

-
09-22-2006, 12:23 PM #946AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Ehm, you can't call functions outside of a function.
You'd have to do like
Code:#include <pspkernel.h> #include <pspdebug.h> #include <string.h> #include <psploadexec.h> PSP_MODULE_INFO("EBOOTLOADER", 0x1000, 1, 1); PSP_MAIN_THREAD_ATTR (0); void loadeboot() { //char *pbpath; const u32 pbplen = strlen("flash0:/vsh/etc/EBOOT.PBP")+1; struct SceKernelLoadExecParam eloader; eloader.args = pbplen; eloader.argp = "flash0:/vsh/etc/EBOOT.PBP"; eloader.key = NULL; eloader.size = sizeof(eloader) + pbplen; if(sceKernelLoadExec("flash0:/vsh/etc/EBOOT.PBP",&eloader)<0) {pspDebugScreenPrintf("Load Failed\n");} } int main() { pspDebugInstallKprintfHandler (NULL); pspDebugInstallErrorHandler (NULL); pspDebugScreenInit(); pspDebugScreenPrintf("Loading EBOOT..\n"); loadeboot(); }
-
09-22-2006, 12:39 PM #947I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Oh, I see. The thing is, I got that code from Nathan over at PSP-programming.com. He posted in some thread, and said the code worked perfectly. Anyway, thanks.
Zitat von homer
-= Double Post =-
Sigh. I still get this error.
Code:$ make psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk /include -O2 -G0 -Wall -c -o main.o main.c main.c: In function 'main': main.c:33: warning: control reaches end of non-void function psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk /include -O2 -G0 -Wall -L. -L/usr/local/pspdev/psp/sdk/lib -specs=/usr/local/ps pdev/psp/sdk/lib/prxspecs -Wl,-q,-T/usr/local/pspdev/psp/sdk/lib/linkfile.prx main.o exports.o -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpsplibc - lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -l pspkernel -o EBOOT exports.o:(.rodata.sceResident+0x4): undefined reference to `getModuleInfo' collect2: ld returned 1 exit status make: *** [EBOOT] Error 1
Geändert von ARza (09-22-2006 um 12:39 PM Uhr) Grund: Automerged Doublepost

-
09-22-2006, 12:48 PM #948AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
You need to add this to main.c
Code:/* Exported function returns the address of module_info */ void* getModuleInfo(void) { return (void *) &module_info; }
-
09-22-2006, 01:41 PM #949Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Am I the only person that thinks the compiler gives really good error messaging?
You also need to add 'return 0;' before the end of your main function.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
09-22-2006, 04:58 PM #950I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Not everyone knows how to interpret the error messages though.
Zitat von Insomniac197
Now, I just have a simple question. I want something to happen if I press X and 3 variables are at a certain amount. For example, in Lua it would be
if pad:cross() and p1 = 1 and p2 = 1 and p3 = 1 then
But I can't figure out how to do it in C. I've tried this:
if(pad.Buttons & PSP_CTRL_CROSS) and (p1 = 1) and (p2 =1) and (p3 = 1) {
But that doesn't work either. How do I do it?Geändert von ARza (09-22-2006 um 04:58 PM Uhr) Grund: Automerged Doublepost

-
09-22-2006, 05:00 PM #951AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
You need a double = in if statements. But it won't work anyway.
Try this:
Code:if((pad.Buttons & PSP_CTRL_CROSS) && (p1 == 1) && (p2 == 1) && (p3 == 1)) { do something }
-
09-22-2006, 07:31 PM #952Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
homer already answered, but I would recommend reading through these tutorials (at least the first few) and taking the quizzes. It hardly takes any time at all, and you can save your questions for deciphering those crazy compiler errors. The syntax errors are easy (you should've known how to fix those, Lua errors aren't much different), but you spoke the truth, it's not always clear to us noobs how to fix some of the other ones, even when we know where there error is. :)Now, I just have a simple question. I want something to happen if I press X and 3 variables are at a certain amount.
-
09-23-2006, 05:02 AM #953Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
help
how do you change the image of your programma on PC
(not to load an image but give the (example) calculator.exe , an image)
-
09-23-2006, 09:36 AM #954QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Germany
- Beiträge
- 216
- Points
- 4.511
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Writing a simple XBM
Writing a simple XMB
Hi,
I'm trying to write a simple XMB but I'm already stuck at moving the menu left/right. If you hold the left (or right) button, I want it to move one element, wait for a sec. and then rush throught the rest (just like the PSP's original XMB. Here's what I tried:
What it does is move from one end to the other once you press (not hold) a key.Code:while(1) { sceCtrlReadBufferPositive(&pad, 1); if (pad.Buttons & PSP_CTRL_LEFT) { if(keyPressCounter == 0) { // Pressed for the first time if(selComponent > 0) { // needed lest to stop at the most left menuitem selComponent--; xmbMoveTo += xmbDistance; //move it } keyPressCounter++; // make it jump to the next part } else { if(keyPressCounter<=10) { // wait 10 frames (little pause between press and hold) sceDisplayWaitVblankStart(); keyPressCounter++; } else { if(selComponent > 0) { // move while holding selComponent--; xmbMoveTo += xmbDistance; } } } } else { keyPressCounter = 0; } // same with PSP_CTRL_RIGHT if(xmbOffsetX < xmbMoveTo) { xmbOffsetX += 10; } else if (xmbOffsetX > xmbMoveTo) { xmbOffsetX -= 10; } // draw the menu according to xmbOffsetX }
-= Double Post =-
I changed the waitingtime ( if(keyPressCounter<=10) ) to 100 and it seems he doesn't even go there!
-= Double Post =-
I added some debug-messages everywhere "xmbMoveTo" is being altered and I got proof: He never gets to the hold-thebutton-part
-= Double Post =-
Can anyone please tell me that this should work? Or maybe have an idea (i don't even need complete code) how to do this otherwise?Geändert von Lukeson (09-23-2006 um 09:36 AM Uhr) Grund: Automerged Doublepost
-
09-23-2006, 09:50 AM #955
if this is the whole code i can tell you that you forgot a
int main() {
youre code here
}
-= Double Post =-
now to my question does anyone now a good tut's for making games on a windows PCGeändert von PSP-Maniac (09-23-2006 um 09:50 AM Uhr) Grund: Automerged Doublepost
-
09-23-2006, 09:52 AM #956QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Germany
- Beiträge
- 216
- Points
- 4.511
- Level
- 42
- Downloads
- 0
- Uploads
- 0
>if this is the whole code
(of course) it isn't
-
09-23-2006, 09:54 AM #957
well i just tried to help you hmf:Cry:
Zitat von Lukeson
-
09-23-2006, 10:03 AM #958QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Germany
- Beiträge
- 216
- Points
- 4.511
- Level
- 42
- Downloads
- 0
- Uploads
- 0
^^ ok, thank you
Zitat von PSP-Maniac
I just found the cause of the problem.Geändert von Lukeson (09-23-2006 um 10:18 AM Uhr)
-
09-23-2006, 12:42 PM #959
does anyone now a good tut for making games on a windows PC
someone??Geändert von PSP-Maniac (09-23-2006 um 01:37 PM Uhr)
-
09-23-2006, 03:46 PM #960QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
That is a REALLY broad question.
Zitat von PSP-Maniac
For C/C++: http://parabellumgames.no-ip.org/articles/ (Many links inside the article)
However, Python is one of the easiest langauges to grasp and allows you to learn the concepts easily. Used with Pygame (SDL bindings) and you can easily make games out of it.
Another alternative is C# (a great OO language) with the ever improving XNA SDK. However this limits you to the PC and Xbox360 for development.
If you can be more specific in your question then it will be much easier to give you a direction.
In general, this will be a good start: http://gpwiki.org/


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum