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; thats an explenation (y) thnx yaust a r I ported it: Code: if(fileList[loop].size() > 10) { fileBuffer[loop].clear(); fileBuffer[loop].append( fileList[loop], 0 ...
-
05-28-2007, 10:29 AM #4741Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
thats an explenation (y)
thnx yaustar
I ported it:
Code:if(fileList[loop].size() > 10) { fileBuffer[loop].clear(); fileBuffer[loop].append( fileList[loop], 0 , 10); fileBuffer[loop].append( 2, '.' ); }
-
05-28-2007, 10:43 AM #4742It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Something tells me that's not going to work very well. Maybe it's the clearing and then appending itself with itself (even though it's empty). I dunno.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-28-2007, 10:50 AM #4743Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
dude
fileBuffer[loop].append( fileList[loop], 0 , 10);
they are two differnt variabels
-
05-28-2007, 03:01 PM #4744It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
...oh.
I feel stupid now.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-29-2007, 05:55 PM #4745QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
ok i'm trying to add a multi array to my function yest i'm unsure how i've been trying:
object update(float** object_vertex_array,int max_vertexs,int frame_to){
object update(float **object_vertex_array,int max_vertexs,int frame_to){
object update(float *object_vertex_array[],int max_vertexs,int frame_to){
object update(float *object_vertex_array,int max_vertexs,int frame_to){
yet for the first 3 i always get the following error:
./main.cpp: In function 'int main(int, char**)':
./main.cpp:61: error: cannot convert 'float (*)[3]' to 'float**' for argument '1
' to 'object update(float**, int, int)'
make: *** [main.o] Error 1
and i call it like:
test_object_float[0][1]=0.0f;
test_object_float[0][2]=1.0f;
test_object_float[0][3]=0.0f;
test_object_float[1][1]=1.0f;
test_object_float[1][2]=-1.0f;
test_object_float[1][3]=0.0f;
test_object_float[2][1]=-1.0f;
test_object_float[2][2]=-1.0f;
test_object_float[2][3]=0.0f;
test_object = update(test_object_float, numOfTriangles,1);
test_object = update(test_object_float[3],numOfTriangles,1);
the second way gives me the following error:
./main.cpp: In function 'int main(int, char**)':
./main.cpp:61: error: cannot convert 'float*' to 'float**' for argument '1' to '
object update(float**, int, int)'1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
05-30-2007, 01:33 AM #4746QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
*ick* Now we start running into problems
Note: This is dangerous and possibly undefined behaviour.Code:#include <stdio.h> void aFunction( float * anArray ) { printf( "%f\n", anArray[0] ); // same as [0][0] printf( "%f\n", anArray[3] ); // same as [1][0] } int main(int argc, char* argv[]) { float blah[3][3] = { { 0.0f, 1.0f, 2.0f}, { 3.0f, 4.0f, 5.0f }, { 6.0f, 7.0f, 8.0f }} ; float * apBLah = (float *)(blah); aFunction( apBLah ); return 0; }Geändert von yaustar (05-30-2007 um 01:45 AM Uhr)
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-30-2007, 12:25 PM #4747QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
thxs yaustar but i still get this error:
/main.o
./main.cpp: In function 'int main(int, char**)':
./main.cpp:62: error: cannot convert 'float*' to 'float**' for argument '1' to '
object update(float**, int, int)'
./functions/update_object.txt: In function 'object update(float*, int, int)':
./functions/update_object.txt:8: error: invalid types 'float[int]' for array sub
script
./functions/update_object.txt:9: error: invalid types 'float[int]' for array sub
script
./functions/update_object.txt:10: error: invalid types 'float[int]' for array su
bscript
make: *** [main.o] Error 1
i've been looking around for an answer and none have worked so i'm beginning to think that you can't pass a multi array into a function(which is odd)
edit: i figured it out i changed:
(float *)(blah)
to
(float **)(blah)1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
05-30-2007, 01:01 PM #4748QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
My posted code compiles straight off. If you are using this, then you have applied the concept incorrectly. You can't pass a multi-dimension static sized array due to the way that the memory is laid out. That is why I converted it to a one dimensional array before passing it to a function.
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-30-2007, 01:48 PM #4749QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
nvm i found out what i was doing and no longer need that as i like to declare my functions after my main function so i called the function earlier in the program and forgot to go back and change that now it's working=-)
Geändert von slicer4ever (05-30-2007 um 02:05 PM Uhr)
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
05-31-2007, 03:56 AM #4750
Hi! :)
I'm a noob and I have a noob question for you. :)
I searched the forum but didn't find any answer.
I have a problema with the function sceDisplaySetBrightness.
The first time I try to execute it my program hangs and returns to the dashboard.
Can someone help me, please?
Here's my code:
Many thanks. :)Code:#include <pspkernel.h> #include <pspctrl.h> #include <pspdebug.h> #include <psppower.h> PSP_MODULE_INFO("Brightness Test ", 0x1000, 1, 1); void sceDisplay_driver_9E3C6DC6(int a0,int a1);//a0 0-100,a1 = 0/1 (set to 0) #define sceDisplaySetBrightness sceDisplay_driver_9E3C6DC6 void sceDisplay_driver_31C4BAA8(int *a0,int *a1); #define sceDisplayGetBrightness sceDisplay_driver_31C4BAA8 // TWILIGHT ZONE! <do doo do doo> /* 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; } // END OF TWILIGHT ZONE! <do doo do do> int main() { scePowerSetClockFrequency(222, 222, 111); pspDebugScreenInit(); SetupCallbacks(); int curBrightness = 0; SceCtrlData pad; curBrightness = 100; pspDebugScreenSetTextColor(0xffffff); pspDebugScreenSetBackColor(0x000000); pspDebugScreenInit(); pspDebugScreenSetXY(0, 23); pspDebugScreenPrintf("Press L or R to change brightness"); pspDebugScreenSetXY(0, 24); pspDebugScreenPrintf("Press TRIANGLE to exit"); while(1) { pspDebugScreenSetXY(0, 15); pspDebugScreenPrintf("Current brightness: %i", curBrightness); sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons & PSP_CTRL_LTRIGGER) { if (curBrightness > 0){ curBrightness--; sceDisplaySetBrightness(curBrightness, 0); } }else if(pad.Buttons & PSP_CTRL_RTRIGGER) { if (curBrightness < 100){ curBrightness++; sceDisplaySetBrightness(curBrightness, 0); } }else if(pad.Buttons & PSP_CTRL_TRIANGLE) { break; } sceKernelDelayThread(100000); } sceKernelExitGame(); return(0); }
Ciaooo
Sakya
-
05-31-2007, 05:46 AM #4751QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
since when ?
Zitat von yaustar
Surely,
that works no ? cos my programs let me ?Code:void functionName(int array [][10]) { //Code goes here }
-
05-31-2007, 08:26 AM #4752QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Sorry, I meant to add "via pointer to a pointer".
Zitat von MiG
Code:void function( int ** anArray ) { // This won't work if you pass a statically sized array } void function( int anArray[10][10] ) { // This will work as expected as long as the size of the arrays are correct }[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
05-31-2007, 08:39 AM #4753Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
can you set it to 100? isnt 4 the maximum?
Zitat von sakya
-
05-31-2007, 10:37 AM #4754
Hi! :)
The first parameter is 0-100:
Zitat von hallo007
:)Code:void sceDisplay_driver_9E3C6DC6(int a0,int a1);//a0 0-100,a1 = 0/1 (set to 0)
Ciaooo
Sakya
-
05-31-2007, 12:39 PM #4755Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
sceKernelDelayThread(1000 00);
is in your while loop , you will be able to push a button for 0,00000000000000000000000 0000000000000001 seconds :P
use it like this ;-)
understand? feel free to ask questions;-)Code:if (curBrightness < 100) { curBrightness++; sceDisplaySetBrightness(curBrightness, 0); sceKernelDelayThread(100000); }
-
05-31-2007, 11:29 PM #4756
Hi! :)
Many thanks for your reply. :)
Oooops, many thanks. ;)
Zitat von hallo007
I fixed this by moving the sceKernelDelayThread() after sceDisplaySetBrightness() , but the program keeps hanging when I press L to change brightness.
Ciaooo
Sakya
-
06-01-2007, 08:13 AM #4757
I need some help. How do you play a pmf file? Is there a library with a tutorial to download?
Current releases:
Icon Action Replacer v1.5- latest release
Current projects:
PSP C++ IDE - Currently v1.6
RPG Paradise - Latest version at my website
-
06-01-2007, 09:28 AM #4758QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Seen as sceKernelDelayThread(1000 0); will delay your program for a lonnng time, i think its 10s ? i don't know how the delays work on the PSP, but if its milliseconds, it will delay your app for 10s. Change it to something like 100, its just to stop the user from frantically changing the settings.
Zitat von sakya
MiG
-
06-01-2007, 09:34 AM #4759Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
no
1000000 is 1 second ;-)
-
06-01-2007, 10:30 AM #4760QJ Gamer Silver
- Registriert seit
- Sep 2006
- Ort
- Finland
- Beiträge
- 752
- Points
- 7.385
- Level
- 57
- Downloads
- 0
- Uploads
- 0
Yeah, sceKernelDelayThread takes the time to wait as microseconds.
Zitat von hallo007
BTW, I'm having trouble with building PSPlink & psplinkusb with the new toolchain. If anyone has the PC side binaries for Ubuntu and would like to share them, please PM me :)wheeee =:D
-
06-01-2007, 12:43 PM #4761
Hi! :)
Yes, the program doesen't sleep for 10 seconds or 1 second. :)
Zitat von hallo007
Nobody knows why sceDisplaySetBrightness() makes my program hang?
Or have someone an example usage of this function?
Many thanks.
Ciaooo
Sakya
-
06-01-2007, 01:35 PM #4762Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
check this thread ;)
http://forums.ps2dev.org/viewtopic.p...ysetbrightness
-
06-01-2007, 09:32 PM #4763QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
I gotz a question! (obviously :P) Im porting my game to the Old School Library and as such i found it ridiculesly easy to rotate images, so, I would like to rotate smoothly instead of the simple up,down,left,right directions, problem is, how would i make a bullet System to match that??? My result is much like what CS 2d is, but he uses a C++ class for his bullet system, How would i do this in C?
Thank you!NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
06-01-2007, 09:54 PM #4764words 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
BlackShark - A C++ class can be ported to C via removing the function names class:: pre-fix. As for how he rotated to match the direction vector, one method would be to make a particle engine, and have the bullet be a particle but with a constant, fixed rate of fading and color change for each particle, giving it that solid color look. As for the other method (rotating an actual bullet image to the direction vector) you could grab a point somewhere along your player's direction vector and use atan2f to get what degree it is rotated to your player. Hope that helps (if you need any more help, im free tonight)

...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
-
06-01-2007, 10:02 PM #4765QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
Well, I am not that experienced so I would not even know were to begin in making a particle engine :S
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
06-01-2007, 10:52 PM #4766words 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
Well, then go with the second option. It may be even faster as it doesnt require as many trig calculations per cycle.
For the second option, here's what i would when the bullet is fired (AKA when the X or R trigger button is pressed)
Note: The bullet image would need to have 0 degrees as straight up.
Then you'd say if currentBullet onScreen is true, draw it and move the X values via adding xspeed and Y values via adding yspeed. I might make an example just for fun, but my PSP is currently non useable (it works, its just the LCD is not plugged in)Code:if(osl_key->pressed.cross && numBulletsOnScreen < MAX_BULLETS) { bullet[currentBullet].image->angle = atan2f((crosshair.y+crosshair.image->height*0.5) - (player.y+player.image->height*0.5), (crosshair.x+crosshair.image->width*0.5) - (player.x+player.image->width*0.5)); // the *0.5 is faster then /2, which is centering where to shoot the bullet from, you could even mod these to shoot from the end of hte barrel for better accuracy bullet[currentBullet].xspeed = oslCos(bullet[currentBullet].angle,1); bullet[currentBullet].yspeed = oslSin(bullet[currentBullet].angle,1); bullet[currentBullet].onScreen = true; if(currentBullet >= MAX_BULLETS) currentBullet = 0; else currentBullet += 1; }Geändert von SG57 (06-01-2007 um 11:30 PM Uhr)

...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
-
06-01-2007, 11:25 PM #4767QJ Gamer Silver
- Registriert seit
- Sep 2006
- Ort
- Finland
- Beiträge
- 752
- Points
- 7.385
- Level
- 57
- Downloads
- 0
- Uploads
- 0
It may be either that you are not in kernel mode (but it shouldn't totally freeze if you're in user mode) or the 1.5 kernel doesn't support that function.
Zitat von sakya
wheeee =:D
-
06-02-2007, 01:02 AM #4768QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
edit: i found my prob i plan to release the source to this later
Geändert von slicer4ever (06-02-2007 um 01:48 AM Uhr)
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
06-02-2007, 07:57 AM #4769QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Blackshark, think about it like this. Say you have a cursor on the screen and when you shoot you want to the bullet to shoot in the direction of the cursor. The concept for what you want to do is just to make the cursor invisible. So, as your character rotates, the bullet is always shooting in the direction the character is facing (In which the cursor would usually be).
-
06-02-2007, 08:49 AM #4770
i want to load ELF using this code
psp resets when loading the elfCode:if (pad.Buttons & PSP_CTRL_RTRIGGER){ struct SceKernelLoadExecParam param; memset(¶m, 0, sizeof(param)); param.size = sizeof(param); param.args = strlen(DEFINED_ELF)+1; param.argp = DEFINED_ELF; param.key = "game"; sceKernelLoadExec(DEFINED_ELF, ¶m); }


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