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:
Zitat von PSP-Maniac
Printable View
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:
Zitat von PSP-Maniac
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!
Did you include <math.h>?
Looks more of a linker problem with the libs.
Shouldn't "LIBS +=" in the makefile be "LIBS =" ?
Zitat:
Zitat von homer
i did.
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.
Zitat:
Zitat von SG57
taht worked! i put it after pspgum, and it worked! thx!!
So you can: http://www.netbsd.org/Documentation/.../makefile.htmlZitat:
Zitat von SG57
Whoops.
I always keep -lm and -lc at the end.Zitat:
Zitat von SG57
Transparent Text and Images
Hi,
is there a way to specify an alpha-value for displaying text and/or images?
Thanks in advance
Luke
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 1
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.
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
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++;
}
}
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 LUA
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? :/
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 bugs
if I remove the * it won't be a pointer any more http://forums.qj.net/user_pics/38805-1158412981.gif And they are supposed to be a short and a char, that's what they are in memory.Zitat:
Zitat von hallo007
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.
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 pointers
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?
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.
I'll try and explain what I'm trying to do.Zitat:
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.
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:
Zitat von Frenchb0yenius
If you just want to get an easy to use IDE and compiler, I recommend DevCpp
ok, I'm trying to create a simple custom mission for gta.Zitat:
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.
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...
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.
http://img.photobucket.com/albums/v1...oryexample.jpg
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.
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?
int *CarPointer = (int*)((int)*CarPointerPo s);Zitat:
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.
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.
Zitat:
Zitat von Twin891
tahts why it wont work. :)
ah ok srry i can't help :(
Zitat:
Zitat von Twin891
its k. ill figure some other way
As Twin891 already mentioned, the saveImage() functions from graphics.c is a good start.
I use this function to save as a PNG.
Code:void IMG_Screenshot(const char* filename)
{
u32* data = (u32*)0x04000000;
png_structp png_ptr;
png_infop info_ptr;
FILE* fp;
int i, x, y;
u8* line;
if ((fp = fopen(filename, "wb")) == NULL) return;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) return;
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
return;
}
png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr, 480, 272, 8,
PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
png_write_info(png_ptr, info_ptr);
line = (u8*) malloc(480 * 3);
for (y = 0; y < 272; y++) {
for (i = 0, x = 0; x < 480; x++) {
u32 color = data[x + y * 512];
u8 r = color & 0xff;
u8 g = (color >> 8) & 0xff;
u8 b = (color >> 16) & 0xff;
line[i++] = r;
line[i++] = g;
line[i++] = b;
}
png_write_row(png_ptr, line);
}
free(line);
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
fclose(fp);
}
Zitat:
Zitat von Insomniac197
well, i tried this:
but when i try to compile it, it gives an error:Code:void Controls() {
//read pad//
if (pad.Buttons & PSP_CTRL_SELECT) {
saveImage("test1.png", getVramDisplayBuffer(), 480, 272, 480, 1);
}
}
how can i solve that?Code:undefined reference to 'getVramDisplayBuffer()'
undefined reference to saveImage(const char*, unsigned int*, int, int, int, int);
If you are using the graphics.c then you will need to #include graphics.h in your code, as well as add graphics.o and framebuffer.o to the OBJS in your makefile.
where can i find a keyboard in c/c++ exemple
because i can find them only in lua:Argh:
Zitat:
Zitat von Insomniac197
i did that, and it still gives the same errors. help
I am trying to execute another eboot from within my eboot. I read about sceKernelLoadExec, but that didn't work. I read somewhere that the eboot needed to be kxploited. When I enter 'make', it gives me a single eboot.pbp. I assume this is not kxploited and is meant for 1.0 (which works fine with custom firmware). 'Make Kxploit' causes it not to show up in the list. If I execute it from irshell, it won't load.
Currently, here is my test source code:
It is meant to execute the hello world app in the hello folder. This app isn't kxploited. When I run it, it gets past the printf statement, and then crashse (sends me back to the xmb).Code:#include <pspkernel.h>
#include <pspdebug.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <psploadexec.h>
//I know I have a lot of #include, but I'm leaving them for later
PSP_MODULE_INFO("Ebooy", 0x1000, 0, 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;
}
int main (void) {
pspDebugScreenInit();
SetupCallbacks();
printf("Loading Eboot...\n");
sceKernelLoadExec("ms0:/PSP/GAME/hello/EBOOT.PBP", NULL);
printf("Eboot loaded\n");
return 0;
}
Please don't tell me to search. I've read every thread in this forum (as well as stuff found on google and ps2dev.org) that has anything to do with it. I think my problem has something to do with the hello world eboot (even though it runs fine by itself).
Thanks in advance.
A kxploited eboot is basically an eboot without the param.sfo. I believe the sceKernelLoadExec file needs to be kxploited, or possibly in elf format I haven't really used it that much, so I'm not 100% sure.
ive had the same prob when i tried to make a mini shell and i asked every person and schearched every thread and i didnt find anything but you could try asking at pspdev.org (:Zitat:
Zitat von Cheater