Zeige Ergebnis 8.431 bis 8.460 von 10174
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; i'm not doing this with the psp, at least not at first anyways...
-
04-19-2008, 09:39 AM #8431QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
i'm not doing this with the psp, at least not at first anyways
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
-
04-20-2008, 05:54 AM #8432
I donot exactly understand the purpose of empty semicolon ended while loopCode:while (something) { /*nothing here*/ }; someother statement;
-
04-20-2008, 09:00 AM #8433QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
quick question on drawing an circle...which i think i may have realized a faster way as i write this.....anyways
currently the way i'm drawing a circle is:
^^now than for one or two circles not bad however a multitude of circles and u see a huge slowdownCode:#include <oslib/oslib.h> #include <math.h> #define PI (first several digits go here) void DrawPixel(float x, float y, osl_color color){ oslDrawFillRect(x, y , x+1, y+1, color); } void DrawCircle(int x, int y, int radius, osl_color){ for(int i=0;i<360;i++){ float tx = x + sinf(i*(PI/180))*radius); float ty = y - cosf(i*(PI/180))*radius); DrawPixel(tx, ty, color) } }
i've changed the function
toCode:void DrawCircle(int x, int y, int radius, osl_color){ for(int i=0;i<360;i++){ float tx = x + sinf(i*(PI/180))*radius); float ty = y - cosf(i*(PI/180))*radius); DrawPixel(tx, ty, color) } }
so that does show a major increase in speed but not the bestCode:void DrawCircle(int x, int y, int radius, osl_color){ for(int i=0;i<360;i+=30){ float tx = x + sinf(i*(PI/180))*radius); float ty = y - cosf(i*(PI/180))*radius); DrawPixel(tx, ty, color) } }
would it be faster and this is the idea i just thought of to:
draw the circle to an empty image than just displaying the image?
thanks every11. 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
-
04-20-2008, 11:25 AM #8434It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
They're doing it wrong.
Zitat von Mr305
Perfectly valid, even if kinda hard to read at times.Code:while (something_that_affects_state);
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
04-20-2008, 08:37 PM #8435
OK this is not for PSP, I am learning C++ still but have hit a problem with random numbers. I am using Dev C++, with begining ++ Game Programming (this uses Dev C++). The program is meant to be like a dice when rolled, a random number is produced and then modulised by 6 to make it a dice number. However when I run this I only get 6 everytime I run the program. Here is the code.
Code:#include <cstdlib> #include <iostream> #include <ctime> using namespace std; int randomnumber = rand(); //generates a random number int die = (randomnumber % 6) + 1; //get a number between 1 and 6 int main() { srand(time(0)); //seed a random number based on current time cout << "You got a " << die << endl; cin.get(); return 0; }
-
04-20-2008, 09:00 PM #8436words 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
slicer - Please format your code, your how old now? (in all seriousness)
Anyways, ya something like hwat you said might be better considering your slow down is due to those 2 calculations * 360 times * number of circles to draw. This will only run those 2 calculations once then just scale the image to the radius specified.
Example:
Haven't tested it however it should work. If it doesn't tell me the outcome, i have a few other filtering techniques to color it to the desired color....Code:OSL_IMAGE *pEllipse = NULL; // internally used, don't directly use this anywhere // run this function anywhere just once before drawing hte circle (usually the loading resources part of a game) void Initialize() { if (pEllipse != NULL) oslDeleteImage(pEllipse); // create image pEllipse = oslCreateImage (512, 512, OSL_IN_VRAM, OSL_PF_8888) oslAssert(pEllipse); // clear to alpha oslClearImage(pEllipse, RGBA(0, 0, 0, 255)); // set the draw buffer to the new image oslSetDrawBuffer(pEllipse); // draw the circle on it, radius = 1/2 dimensions for (int i = 0; i < 360; i++) { int tmpX = oslCosi(i, 256) + 256; // why you don't use OSlib's math functions i dont know... int tmpY = oslSini(i, 256) + 256; // these use the VFPU, takes the angle as a degree and multiplies it by the magnitude and returns an integer // does all the stuff you were doing but faster and more readable ;) oslDrawFillRect(tmpX, tmpY, tmpX + 1, tmpY + 1, RGB(255,255,255)); // draw it white } // set the draw buffer back to the default oslSetDrawBuffer(OSL_DEFAULT_BUFFER); } void DrawCircle(int x, int y, int radiusX, int radiusY, OSL_COLOR color) { pEllipse->x = x - radiusX; // set the position of the image pEllipse->y = y - radiusY; // " pEllipse->stretchX = radiusX * 2; // set the width of the ellipsoid pEllipse->stretchY = radiusY * 2; // set the height " // store the current params OSL_ALPHA_PARAMS *currentParameters = NULL; oslGetAlphaEx(currentParameters); // now we set a filter to convert the white part of the ellipsoid image // (the circle part) to the color passed oslSetAlpha(OSL_FX_ALPHA | OSL_FX_COLOR, color); oslDrawImage(pEllipse); // draw it // back to normal oslSetAlphaEx(currentParameters); }
Also, take a look here:
http://www.psp-hacks.com/forums/viewtopic.php?id=140324
leejames - It should always return 6 (well any value at that, just the same each time). Your initializing 'randomnumber' to a random number before setting a random seed. Try something like this (btw format your code or i'll have your head ;))
That'll work. However I recommend you avoid global variables where possible, not initialize variables to desired values, assign them later to desired values (that was your main problem here) and format your code (a lot of people don't like having to take the time and format your code then look for a problem so format before hand).Code:#include <cstdlib> #include <iostream> #include <ctime> using namespace std; int randomnumber = 0; int die = 0; int main() { srand(time(0)); randomnumber = rand(); die = (randomnumber % 6) + 1; cout << "You got a " << die << endl; cin.get(); return 0; }Geändert von SG57 (04-20-2008 um 09:43 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
-
04-20-2008, 09:20 PM #8437QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Phoenix
- Beiträge
- 208
- Points
- 13.529
- Level
- 75
- Downloads
- 0
- Uploads
- 0
Try this:
Zitat von leejames04
Try not to use globals unless absolutely neccessary, and seed before you randomize.Code:#include <cstdlib> #include <iostream> #include <ctime> using namespace std; int main() { srand((unsigned)time(0)); //seed a random number based on current time int randomnumber = rand(); //generates a random number int die = (randomnumber % 6) + 1; //get a number between 1 and 6 cout << "You got a " << die << endl; cin.get(); return 0; }
-
04-21-2008, 06:27 AM #8438OMFG

- Registriert seit
- Jul 2005
- Ort
- Toronto
- Beiträge
- 2.814
- Points
- 19.453
- Level
- 88
- Downloads
- 0
- Uploads
- 0
Re-post.
Zitat von Slasher
Anyone successfully get this working? How can I get it working?
EDIT: nvm I figured it out
Code:#ifdef __cplusplus extern "C" { #endif int pspDveMgrCheckVideoOut(); int pspDveMgrSetVideoOut(int u, int mode, int width, int height, int x, int y, int z); #ifdef __cplusplus } #endifGeändert von Slasher (04-21-2008 um 07:06 AM Uhr)
-
04-21-2008, 01:32 PM #8439QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
sry sg57 i'm so used to hitting tab to increase by a few spaces that when trying to type formated code here....well anyways, thanks that'll defiantly give me speed up i think i'm ganna re-write pixel attack anyways since my coding style has changed so much since the time that i wrote it anyways thanks a million this well rly help me=-)
plus i wanna try a few physic's tricks that i've learned to make it look far better
also i didn't use the oslcos and sin commands because they've given back undesired results before so i find going with sinf and cosf to give me the results i'm looking forGeändert von slicer4ever (04-21-2008 um 01:49 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
-
04-21-2008, 05:22 PM #8440words 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
What do you mean undesired results lol
They take an angle in degrees and the radius size/magnitude. Returns the integer value of the sin/cos of that angle * the radius size/magnitude. It uses the vfpu for the calculations as well so a lot of calls to it should make a significant difference between math.h sinf/cosf and oslib's oslCos and oslSin...
...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
-
04-21-2008, 05:56 PM #8441QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
yes i fully understand what the function does, however i have experianced problems with the two commands which were remedied when i replaced them with cos and sin, also at this point such a small increase in speed isn't really necessary, especially with such a speed up that the command above gives me
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
-
04-21-2008, 06:03 PM #8442words 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
Post your old usage of oslCos/Sin and I can almost guarantee a flaw in your usage of it, And hey if it's possible to optimize readability-wise and performance wise, why not? ;)

...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
-
04-21-2008, 06:06 PM #8443QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
your just an optimization whore=-) not a bad thing of course
i'll see if i can find the project but idk if i still have it on my computer, if i remeber correctly it was in my celestial cunning projects however they've gone through so many updates that idk if i have the original problem any longer but i'll look to see if i can find it1. 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
-
04-22-2008, 11:36 PM #8444
i need some help, this is my first post (yay) and i dont know how to get the time off the psp's internal clock, a n00b problem i know. i try to use time.h but cygwin doesnt like it... yay first post.
hmm... since its so late over ther (im in aus) i'll log back in tomorrow after school and see if anything has happenedGeändert von Sangheili (04-22-2008 um 11:53 PM Uhr)
-
04-23-2008, 08:51 AM #8445I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I'm having a problem using a function to load a pbp file as a module. I've been given the stub for the function and got everything work up to the point where I actually try and load the file, at which point I get 0x800200D9, which after searching on Google, I've found to be an error with the file I'm loading.
The functions I'm using are in an exported file which is loading fine by the looks of things, but seeing as the application I'm trying to load (BookR) is working fine normally, I'm more than a tad confused about what is causing the error to pop up?
Any assistance what so ever is welcome, this really has me stumped.
-Aura
-
04-23-2008, 10:07 AM #8446OMFG

- Registriert seit
- Jul 2005
- Ort
- Toronto
- Beiträge
- 2.814
- Points
- 19.453
- Level
- 88
- Downloads
- 0
- Uploads
- 0
Hopefully this helps. It loads an elf (the eboot.pbp in the non % folder for kxploited apps).
Zitat von Auraomega
There's alot of unneeded stuff such as the unloading of the prx loader (which is meant to load this prx), and patching the sceKernelExitGame function, and a few other things.
int run_elf(char * elfPath) is what you should be looking at.
http://slasher.team-duck.com/development/loader.zip
I think your problem lies in that you can't load actual eboots as a module, you need to load the elf. (I may be wrong on this, I'm just assuming)
Furthermore, if you're trying to load BookR such as the way irshell does it(Uses BookR to look at txt files, etc), then it's something entirely different. You must pass arguments onto the eboot. I'm not 100% sure this is how irshell does it, but I'm pretty sure.
Ex)
The program that is loaded, 'fileName'; can then recieve the arg that you passed onto it, "ms0:/PSP/GAME/test.txt",Code:int runPBP(char * fileName) { char load_path[256]; sprintf(load_path, "ms0:/PSP/GAME/test.txt"); char args[256]; sprintf(args, "%s", load_path); struct SceKernelLoadExecParam execParam; execParam.size = sizeof(execParam); execParam.argp = args; execParam.args = strlen(args) + 1; execParam.key = NULL; if (sceKernelLoadExec(fileName, &execParam) < 0) return -1; return 1; }
through argv.
Anyways, let me know if this helpsCode:int main(int argc, char** argv) {Geändert von Slasher (04-23-2008 um 10:21 AM Uhr)
-
04-23-2008, 10:22 AM #8447I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Well, 7-Points sent me the stubs for a sceKernelLoadModuleForLoa dExecVSHMs2 which is the function I've been trying to get working.
Stub for the functions:
My kernel module seems to be fine until I attempt to use the above function, which is when it breaks down.Code:.set noreorder #include "pspstub.s" STUB_START "ModuleMgrForKernel",0x40090000,0x00030005 STUB_FUNC 0x6723BBFF,sceKernelLoadModuleForLoadExecVSHMs1 STUB_FUNC 0x49C5B9E1,sceKernelLoadModuleForLoadExecVSHMs2 STUB_FUNC 0xF07E1A2F,sceKernelLoadModuleForLoadExecVSHMs4 STUB_END
-Aura
-
04-23-2008, 10:35 AM #8448It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Might I add that 0x800200D9, an error I know well, means that the PSP ran out of memory? Check the size of your heap and stack to make sure there's enough room for the ELF.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
04-23-2008, 10:48 AM #8449I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Well, I made sure that all memory was free, I reduced my heaps down to the default (32 or 64kb, can't remember) and tried, same error. Plus, according to the link I posted above, it refers to not being able to load due to an error if the file, not just that I'm out of free space?
-Aura
-
04-23-2008, 10:50 AM #8450It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
http://psp.jim.sh/pspsdk-doc/pspkerror_8h.html
So I guess it's not strictly running out of memory, so much as that it can't allocate the memory for one reason or another.SCE_KERNEL_ERROR_MEMBLOCK _ALLOC_FAILED = 0x800200d9pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
04-23-2008, 11:01 AM #8451I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Could it be because I'm loading from a kernel module? I doubt that would be the cause seeing as it won't run in user mode, but best to ask.
-Aura
-
04-23-2008, 02:09 PM #8452
Hey I was wondering if anyone knew how to find all files in a folder? I'm thinking of making an app that will need this and wonder if there are functions already out there like this for the psp..
Thanks in advance.Atheist, because I just won't believe in what doesn't show itself to me.
-
04-23-2008, 02:25 PM #8453QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
research up on dirent.h library that's helped me in the past, their may be a library specific to the psp however i've not needed it if their is, someone correct me please, durka, if your still confused after some research on it hit me with a pm=-)
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
-
04-23-2008, 03:25 PM #8454I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Using dirents, namely sceIoDopen (I think, havn't actually got my code on me to refer to). If you need a bit of help drop me a PM and I'll knock you up some code when I get a chance.
-Aura
-
04-23-2008, 03:39 PM #8455OMFG

- Registriert seit
- Jul 2005
- Ort
- Toronto
- Beiträge
- 2.814
- Points
- 19.453
- Level
- 88
- Downloads
- 0
- Uploads
- 0
You can also check out the filebrowser example @ my site, http://slasher.team-duck.com . That might help.
-
04-23-2008, 03:49 PM #8456
Wow man great example, this will help me loads.
Exactly what is needed (what headers) to use this? I don't want to include stuff I don't need.Atheist, because I just won't believe in what doesn't show itself to me.
-
04-23-2008, 03:52 PM #8457It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
dirent.h for the POSIX version, pspiofilemgr.h for the PSP version (it's included by some files, so it might already be included)
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
04-23-2008, 03:56 PM #8458
Alright thanks.
One more question. What size (px by px) is a single character on the standard PSP font? I'm making a simple textbox class that will be able to print according to how many characters wide you want it to be, so I need their sizes.Atheist, because I just won't believe in what doesn't show itself to me.
-
04-23-2008, 04:04 PM #8459QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
see your pm for my response=-)
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
-
04-24-2008, 10:45 AM #8460QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 64
- Points
- 3.415
- Level
- 36
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Load an eboot with a prx without exit the first
Hello everyone,
I want to know how I can do if I load an eboot with a prx to not quit the first eboot loaded before.
It is posible because Irshell can do this ^^
Here the code to load an eboot:
I thanks everyone who help me^^Code:void execEboot(char *target) { u8 vshmain_args[0x400]; struct SceKernelLoadExecVSHParam param; memset(vshmain_args, 0, sizeof(vshmain_args)); vshmain_args[0x40] = 1; vshmain_args[0x280] = 1; vshmain_args[0x284] = 3; vshmain_args[0x286] = 5; memset(¶m, 0, sizeof(param)); param.size = sizeof(param); param.args = strlen(target) + 1; param.argp = target; param.key = "game"; param.vshmain_args_size = sizeof(vshmain_args); param.vshmain_args = vshmain_args; sctrlKernelLoadExecVSHMs2(target, ¶m); }
I apologize for my bad english because I am french^^


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