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 PSP-Maniac does anyone now a good tut for making games on a windows PC someone?? Why did you ...
-
09-23-2006, 03:50 PM #961AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Why did you post this in a PSP C/C++ thread? If I were you I'd go to a C/C++ game programming forum and ask there.
Zitat von PSP-Maniac
-
09-23-2006, 04:31 PM #962Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
i need help. i tried a new lib, and it screwed up my makefile. now im trying to revert back to my original lib. and im there except for one thing. when i complie, it gives this error:
this is weird cause its referring to the ACTUAL library. and ive been using it for all this time with no errors. heres my makefile:Code:/tmp/pspdev/pspsdk/src/gum/pspgum.c:463: undefined reference to 'cosf' /tmp/pspdev/pspsdk/src/gum/pspgum.c:463: undefined reference to 'sinf'
Code:TARGET = aso OBJS = main.o CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) PSPBIN = $(PSPSDK)/../bin LIBS += -lm -lc -lpsputility -lpspdebug -lpspgu -lpspgum -lmad -lpspaudiolib -lpspaudio -lpspdisplay -lpspctrl -lpspsdk -lpspvfpu -lpsplibc -lpspuser -lpspkernel -lpsprtc -lpsppower -lstdc++ EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE =Test PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak
HELP!--------------------------------------------------------------------------------------
-
09-23-2006, 04:32 PM #963AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Did you include <math.h>?
-
09-23-2006, 04:39 PM #964QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Looks more of a linker problem with the libs.
Shouldn't "LIBS +=" in the makefile be "LIBS =" ?
-
09-23-2006, 05:09 PM #965Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von homer
i did.--------------------------------------------------------------------------------------
-
09-23-2006, 05:12 PM #966words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
head_54us - I think you can do LIBS+= if you already have LIBS declared (stated or w/e) with LIBS =, than again, I know nothing of makefiles compared to others.
And ya, you might wnat to check your ordering, its improtant. Try putting -lm in the middle, if that doesnt work, try the end, etc.
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
09-23-2006, 05:15 PM #967Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von SG57
taht worked! i put it after pspgum, and it worked! thx!!--------------------------------------------------------------------------------------
-
09-23-2006, 05:15 PM #968QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
So you can: http://www.netbsd.org/Documentation/.../makefile.html
Zitat von SG57
Whoops.
-
09-23-2006, 05:15 PM #969AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
I always keep -lm and -lc at the end.
Zitat von SG57
-
09-24-2006, 02:32 AM #970QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Germany
- Beiträge
- 216
- Points
- 4.511
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Transparent Text and Images
Transparent Text and Images
Hi,
is there a way to specify an alpha-value for displaying text and/or images?
Thanks in advance
Luke
-
09-24-2006, 02:36 AM #971Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
i am porting my calculator to psp and started with the menu
Code:#include <math.h> #include <pspkernel.h> #include <pspdebug.h> #include <pspdisplay.h> #include <pspctrl.h> #include <math.h> PSP_MODULE_INFO("Hello World", 250, 1, 1); #define printf pspDebugScreenPrintf /* 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; } double sqrt (double x); void vermenigvuldigen (); void optellen (); void aftrekken () ; void delen (); void kwadrateren (); void vierkantswortel (); void credits (); void sluiten(); int main (void) { pspDebugScreenInit(); SetupCallbacks(); printf( " ______ _______ _ ______ \n"); printf( "| ____| | ___ | | | | ____| \n"); printf( "| | | | | | | | | | \n"); printf( "| |____ | --- | | |____ | |____ \n"); printf( "|______| |__| |__| |______| |______| v0.04 Beta \n"); int input; printf("1. Vermenigvuldig\n"); printf("2. delen\n"); printf("3. optellen\n"); printf("4. aftrekken\n"); printf("5. kwadrateren\n"); printf("6. Vierkantswortel\n"); printf("7. Credits , historie en To-Do\n"); printf("8. sluiten\n"); printf("selecteer:", input); switch (input) { case 1: system("cls"); case 2 : system("cls"); case 3 : system("cls"); case 4 : system("cls"); case 5 : system("cls"); case 6 : system("cls"); case 7 : system("cls"); case 8 : system("cls"); break; default: system("cls"); printf("error , slechte selectie , probeer opnieuw\n"); main(); sceKernelSleepThread(); return 0; } }
and i get this errorCode:$ make psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o mai n.c main.c: In function 'main': main.c:77: warning: too many arguments for format main.c:81: warning: implicit declaration of function 'system' main.c:77: warning: 'input' is used uninitialized in this function main.c:116: warning: control reaches end of non-void function psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/ pspdev/psp/sdk/lib main.o -lpspgu -lpng -lz -lm -lpspdebug -lpspdisplay -lpspg e -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o cpu psp-fixup-imports cpu psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/ pspdev/psp/sdk/lib main.o -lpspgu -lpng -lz -lm -lpspdebug -lpspdisplay -lpspg e -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o tester.elf psp-fixup-imports tester.elf mksfo 'Image Example' PARAM.SFO psp-strip cpu tester.elf -o cpu tester_strip.elf Usage: psp-strip <option(s)> in-file(s) Removes symbols and sections from files The options are: -I --input-target=<bfdname> Assume input file is in format <bfdname> -O --output-target=<bfdname> Create an output file in format <bfdname> -F --target=<bfdname> Set both input and output format to <bfdname> -p --preserve-dates Copy modified/access timestamps to the output -R --remove-section=<name> Remove section <name> from the output -s --strip-all Remove all symbol and relocation information -g -S -d --strip-debug Remove all debugging symbols & sections --strip-unneeded Remove all symbols not needed by relocations --only-keep-debug Strip everything but the debug information -N --strip-symbol=<name> Do not copy symbol <name> -K --keep-symbol=<name> Only copy symbol <name> -w --wildcard Permit wildcard in symbol comparison -x --discard-all Remove all non-global symbols -X --discard-locals Remove any compiler-generated symbols -v --verbose List all object files modified -V --version Display this program's version number -h --help Display this output --info List object formats & architectures supported -o <file> Place stripped output into <file> psp-strip: supported targets: elf32-littlemips elf32-bigmips elf64-bigmips elf64 -littlemips elf64-little elf64-big elf32-little elf32-big srec symbolsrec tekhex binary ihex make: *** [EBOOT.PBP] Error 1Geändert von hallo007 (09-24-2006 um 03:07 AM Uhr)
-
09-24-2006, 03:36 AM #972QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Not related to your problem but using "cls" command in the system function is pretty much DOS specific and should not be used at all.
-
09-24-2006, 03:57 AM #973QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Germany
- Beiträge
- 216
- Points
- 4.511
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Sorry for the doublepost, but I think that old post won't be found by anyone
Transparent Text and Images
Hi,
is there a way to specify an alpha-value for displaying text and/or images?
Thanks in advance
Luke
-
09-24-2006, 05:12 AM #974AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Well, I use this to set the alpha value of images:
Code:void SetAlphaImage(Image * image, unsigned int alpha) { int size; Color *databuf; if(!image->data) return; if(alpha>255) alpha = 255; if(alpha<0) alpha = 0; size = image->textureWidth * image->textureHeight; databuf = image->data; for(i = 0; i <= size; i++) { *databuf = (*databuf & 0x00ffffff) | ((A(*databuf)-(A(*databuf)-alpha))<<24); databuf++; } }
-
09-24-2006, 06:07 AM #975Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Code:#include <math.h> #include <pspkernel.h> #include <pspdebug.h> #include <pspdisplay.h> #include <pspctrl.h> #include <math.h> PSP_MODULE_INFO("Hello World", 250, 1, 1); #define printf pspDebugScreenPrintf /* 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; } double sqrt (double x); void vermenigvuldigen (); void optellen (); void aftrekken () ; void delen (); void kwadrateren (); void vierkantswortel (); void credits (); void sluiten(); int main (void) { pspDebugScreenInit(); SetupCallbacks(); printf( " ______ _______ _ ______ \n"); printf( "| ____| | ___ | | | | ____| \n"); printf( "| | | | | | | | | | \n"); printf( "| |____ | --- | | |____ | |____ \n"); printf( "|______| |__| |__| |______| |______| v0.04 Beta \n"); int input; printf("1. Vermenigvuldig\n"); printf("2. delen\n"); printf("3. optellen\n"); printf("4. aftrekken\n"); printf("5. kwadrateren\n"); printf("6. Vierkantswortel\n"); printf("7. Credits , historie en To-Do\n"); printf("8. sluiten\n"); printf("selecteer:", input); switch (input) { case 1: printf("test"); case 2 : printf("test"); case 3 : printf("test"); case 4 : printf("test"); case 5 : printf("test"); case 6 : printf("test"); case 7 : printf("test"); case 8 : printf("test"); break; default: printf("test\n"); printf("error , slechte selectie , probeer opnieuw\n"); main(); sceKernelSleepThread(); return 0; } }
no errors , but when i start it on psp it's shows the text for 1/10 sec and then i get black screen
when i want to go back to xmb my psp crashes, why?
-= Double Post =-
and where can i found a sample keyboard in c/c++ , i only found them in LUAGeändert von hallo007 (09-24-2006 um 06:07 AM Uhr) Grund: Automerged Doublepost
-
09-24-2006, 08:13 AM #976Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
I have this code:
and get these warnings,Code:int *CarPointerPos = (int*) 0x08b5e114; short *CurCarCol; char *CurCarType; *CurCarCol = (short*) CarPointerPos+0x1f0; *CurCarType = (char*) CarPointerPos+0x58; if(*CurCarCol == 0x746F && *CurCarType == 133) { //some code }
main.c:126: warning: assignment makes integer from pointer without a cast
main.c:127: warning: assignment makes integer from pointer without a cast
main.c:128: warning: comparison is always false due to limited range of data type
main.c:126: warning: 'CurCarCol' is used uninitialized in this function
main.c:127: warning: 'CurCarType' is used uninitialized in this function
what am I doing wrong? :/
-
09-24-2006, 08:23 AM #977Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
int curcartype;
int curcarcol;
i think
-= Double Post =-
but normal warnings arent problems , you can make the eboot perfectly
but mayby when in game it will give some bugsGeändert von hallo007 (09-24-2006 um 08:23 AM Uhr) Grund: Automerged Doublepost
-
09-24-2006, 08:33 AM #978Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
if I remove the * it won't be a pointer any more
Zitat von hallo007
And they are supposed to be a short and a char, that's what they are in memory.
and the warning 'main.c:128: warning: comparison is always false due to limited range of data type' I think means that the if statement never returns true so the code inside it will never be ran..
and it's a prx btw.
-
09-24-2006, 09:13 AM #979Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
o prx , i know nothing about that;)
-= Double Post =-
where can i find a exemple for a keyboard?
-= Double Post =-
but did you try it like this
int *CarPointerPos = (int*) 0x08b5e114;
short *CurCarCol;
char *CurCarType;
int *CurCarCol = (short*) CarPointerPos+0x1f0;
int *CurCarType = (char*) CarPointerPos+0x58;
if(*CurCarCol == 0x746F && *CurCarType == 133) {
//some code
}
then are it still pointersGeändert von hallo007 (09-24-2006 um 09:13 AM Uhr) Grund: Automerged Doublepost
-
09-24-2006, 12:30 PM #980QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I suggest going back and read up on pointers since from that code, you don't fully understand the use of *.
I can't even tell what you are trying to do. Are you trying to point to a specific memory address? Or are you trying to pass actual values? Are the hex values (0xXXXXX) represent values or memory addresses?
-
09-24-2006, 12:34 PM #981QJ Gamer Green
- Registriert seit
- Apr 2006
- Beiträge
- 0
- Points
- 13.013
- Level
- 74
- Downloads
- 0
- Uploads
- 0
Ok, so im a complete n00b to c++ programming, and I just installed visual c++ express edition. I made a new source file, which is a simple hello world program. I was trying to add the iostream header file to the header folder, and when I compile it, it tells me that there is no such thing as this header file.
-
09-24-2006, 12:39 PM #982Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
I'll try and explain what I'm trying to do.
Zitat von head_54us
first I want to get the value of the memory address 0x08b5e114
so I do
int *CarPointerPos = (int*) 0x08b5e114;
then 0x08b5e114 is a pointer (so the value it contains is another memory address).
and I want edit 2 memory addresses according to what 0x08b5e114 is.
so if forexample 0x08b5e114 stores the value 0x08e41210 then I would want to read the value of 0x08e41200 and 0x08e41268.
Hope that's understandable (I'm not very good at explaining :/ ).
Any help would be appriciated.
-
09-24-2006, 01:11 PM #983QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
skfhaklsfhaklsfhsafashfls afCode:// If 0x08b5e114 is a memory address then this is all you need to do. int *CarPointerPos = 0x08b5e114; // Always NULL pointers if they are not given a value on creation // This saves ALOT of trouble during debugging short *CurCarCol = NULL; char *CurCarType = NULL; // I have no clue what the hell you are trying to do from this point on. /* What is 0x1F0? What is 0x58? A value? A memory address? Are you trying to jump memory addresses? Why are you trying to jump memory addresses? What is so special about the value/memory address of 0x1f0 or 0x58? How many bits/bytes do you want to jump? Do you understand pointer arithmetic? */ *CurCarCol = (short*) CarPointerPos+0x1f0; *CurCarType = (char*) CarPointerPos+0x58; if(*CurCarCol == 0x746F && *CurCarType == 133) { //some code }
-= Double Post =-
Did you install the compiler? http://msdn.microsoft.com/vstudio/ex...alc/usingpsdk/
Zitat von Frenchb0yenius
If you just want to get an easy to use IDE and compiler, I recommend DevCppGeändert von yaustar (09-24-2006 um 01:14 PM Uhr) Grund: Automerged Doublepost
-
09-24-2006, 01:16 PM #984Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
ok, I'm trying to create a simple custom mission for gta.
Zitat von head_54us
the value that CarPointerPos gets points to the start of the memory for the car you are in.
and I want to read some info about the car which is located in memory at CarPointerPos+0x1f0 and CarPointerPos+0x58. so 0x58 and 0x1f0 are how far into the car memory the info is located. so I want to read from the memory address the value of CarPointerPos is +0x58.
-
09-24-2006, 01:36 PM #985words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
FrenchOyenious - iostream is the standard in/out library for windows, meaning the psptoolchain shouldnt have it in there unless it was ported (?)
hallo007 - Making a PRX has nothing to do with whether or not his pointer's are being un-initalized, or anything on that matter...
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
09-24-2006, 02:45 PM #986Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
I'll try and make my question simlper. (disregard the code I posted)
I first make CarPointerPos point to 0x08b5e114 so I can read it's value.
int *CarPointerPos = (int*) 0x08b5e114;
Now the int that is stored in 0x08b5e114 is a memory address. How could I get a pointer to point to the memory address that value of 0x08b5e114 is?
here's an example picture of what the memory might look like.

there you can see that 0x08b5e114 = 0x0998B580 (reversed order of the hex).
so then I want the second pointer to point to the memory address 0x0998B580. How would I do that?
I don't think I'll be able to explain it any better than this. hoping for an answer.
-
09-24-2006, 08:02 PM #987Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
i need help. how can i save a image in C?? (like screen:save in lua) i know the function, but it wont work since im using the GU/GUM. any other way?
--------------------------------------------------------------------------------------
-
09-24-2006, 08:10 PM #988QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
int *CarPointer = (int*)((int)*CarPointerPo s);
Zitat von waterbottle
should work (inner cast probably is unneccesary).
Also, regarding something like
*CurCarCol = (short*) CarPointerPos+0x1f0;
*CurCarType = (char*) CarPointerPos+0x58;
Read up on pointer arithmetic unless you already know, since (short*)x + 1 != (char*)x + 1.Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
09-24-2006, 08:14 PM #989QJ Gamer Blue
- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 70
- Points
- 4.073
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Grimfate I used the saveImage(); function in graphics.h it works great for my pong game. Im not sure how it will turn out when you are using GU.
-
09-24-2006, 08:19 PM #990Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Twin891
tahts why it wont work. :)--------------------------------------------------------------------------------------


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