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 use a trace function that i created myself for debugging really helps here: Code: void trace(char text[100]){ FILE *pfile; ...
-
07-19-2007, 10:49 PM #5581QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
i use a trace function that i created myself for debugging really helps here:
it's really great for debugging however i never got around to placeing in formating and suchCode:void trace(char text[100]){ FILE *pfile; pfile = fopen("trace.txt","a+"); fputs(text,pfile); fclose(pfile); }
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
-
07-20-2007, 01:18 AM #5582Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Has anyone already have succes with loading eboots from the xmb under 3.51 M33 , the se technique seems to fail :s
-
07-20-2007, 02:23 AM #5583QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Why restricting yourself artificially to 100 chars?Code:void trace(char text[100]){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.
-
07-20-2007, 02:39 AM #5584
crap, i missed that typo. but about the null terminator \0 thats stored as 1 byte, 0, or am i missing something?
Zitat von Moca
-
07-20-2007, 02:47 AM #5585QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yes, it is one byte in size. "String" takes 7 bytes of memory. "String\0" also takes 7 bytes of memory. However, strlen doesn't count '\0' as it is a NULL terminator so both strings would be 6 characters in length.
Zitat von brethren
[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]
-
07-20-2007, 02:50 AM #5586QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
exactly..
Zitat von Raphael
void trace(char text[])
would be better.
-
07-20-2007, 10:21 AM #5587QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
because i don't have anything that well go over 100 besides i quickly made that function and didn't overly think about it
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
-
07-20-2007, 01:20 PM #5588Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
ok i have a memory adress (for example 0×88000000) and i want to storage the value 3 there , how do i do that?
-
07-20-2007, 02:00 PM #5589It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Um, use the dereference operation?
Code:int *pointer = new int; *int = 3;
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
07-20-2007, 02:48 PM #5590QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Code:int * pInt = (int*)(0×88000000); *pInt = 3;
[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]
-
07-20-2007, 02:58 PM #5591I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Just 2 quick questions...
1) Using graphics.c is it possible to store an image in the program to blit to screen, or does it have to be a .png file seperate?
2) Can I return an array from a .prx, the array would be 1296 charactors long if this makes any difference.
Thanks.
-Aura
-
07-20-2007, 04:10 PM #5592QJ Gamer Silver
- Registriert seit
- Sep 2006
- Ort
- Finland
- Beiträge
- 752
- Points
- 7.385
- Level
- 57
- Downloads
- 0
- Uploads
- 0
1) IIRC some version of graphics.c does have a function to load an image from buffer. Then you just bin2c the file and add it as an object to your makefile. The buffer will be unsigned char filename_start[]. Then declare the file in your main.c as extern unsigned char filename_start[].
Zitat von Auraomega
2) Return an address, then use it as a pointer.wheeee =:D
-
07-20-2007, 04:37 PM #5593I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Hi, I've taken a look for this, but I can't find it, just wondering if you could post a link or something, as I have to go now and can't search anymore.
Zitat von MaTiAz
Cheers.
-Aura
-
07-20-2007, 05:44 PM #5594QJ Gamer Silver
- Registriert seit
- Sep 2006
- Ort
- Finland
- Beiträge
- 752
- Points
- 7.385
- Level
- 57
- Downloads
- 0
- Uploads
- 0
Yeah, I'll just copypaste my graphics.c/.h and required stuff. They were ripped from some version of LuaPlayer (don't remember which one though).
Zitat von Auraomega
Spoiler for graphics.c:
Spoiler for graphics.h:
Spoiler for framebuffer.c:
Spoiler for framebuffer.h:
You can always remove the freetype/jpeg stuff if you don't need them, as they require extra libraries and make your ELF bigger.wheeee =:D
-
07-20-2007, 11:53 PM #5595Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
perfect , thnx
Zitat von yaustar
-
07-21-2007, 01:07 AM #5596words 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
...
Zitat von MiG
?Code:void trace(const char *text);

...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
-
07-21-2007, 02:16 AM #5597
can anyone teach me how to code in lua because i dont know how and i want to lean
by the way im fatboys bro
-
07-21-2007, 02:17 AM #5598QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Wrong thread go to the Lua Help Thread... and post Lua things there
-
07-21-2007, 02:37 AM #5599QJ Gamer Green
- Registriert seit
- Apr 2006
- Ort
- England ~¦¦¦|+|¦¦¦~
- Beiträge
- 1.112
- Points
- 9.165
- Level
- 64
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I'm confused by different 'bits' of data. Where you have variables like 'u32', 'u16', 'u8'?
im guessing they are something like this:
Examples:
u32: 0xFFFFFFFF
u16: 0xFFFF
u8: 0xFF
But where and WHY would i use these values in a program? What are they used for? And why would i choose a u16 over a u32 for example?...Just Returned To The Scene...
-
07-21-2007, 03:31 AM #5600QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
These are usually typedef datatypes. A U32 usually means an unsigned integer that is 32 bits, S32 would be a signed int that is 32 bit etc. U8 would a be an unsigned integer that is 8 bit therefore it can only hold a value of 0-255.
Zitat von JaSo PsP
In some programs, you need to maximise the amount of space that you are using, for example say you are storing 4 values that you know will never be more then 255 and less then 0. If you did it like this:
That would take up 4 * 32bits which is 128bits.Code:int a, b, c, d;
If you declared them like this:
The compiler *MAY* pack this into 32 bits (4 * 8). I really stress MAY here, the compiler might equally pad each variable with 24 bits so they are 4 byte (32 bits) aligned in memory and therefore use the same number of bits as 4 ints.Code:U8 a, b, c, d;
At this stage, this isn't something you should worry about or spread information. It only really matters if you are REALLY having memory issues. As a rule of thumb in context of memory usage, ALWAYS use int or unsigned int.
The other use of these datatypes is for pointer arithmetic especially when dealing with registers and hardware memory addresses.
e.g.
Also, the pointer type represents how many bits at the memory address you modify when giving it a value.Code:int * pInt = (int*)(0x80); pInt++; // pInt now points to 0x00A0; U8 * pU8 = (U8*)(0x80); pU8++; // pU8 now points to 0x0088;
All of this is pretty low level and rarely gets used at all on gameplay logic level.[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]
-
07-21-2007, 04:38 AM #5601QJ Gamer Green
- Registriert seit
- Apr 2006
- Ort
- England ~¦¦¦|+|¦¦¦~
- Beiträge
- 1.112
- Points
- 9.165
- Level
- 64
- My Mood
-
- Downloads
- 0
- Uploads
- 0
thanks, i dont think i'll ever find a need to use these anyway. :P
...Just Returned To The Scene...
-
07-21-2007, 10:10 AM #5602QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
const, yesh that would be better, didn't notice he was only reading the array..
Zitat von AdjutantReflex
an array of chars works good as pointer to the start of a char array.
Myself, I think its a load of toss and the C++ & the String library should be used, much better.
-
07-21-2007, 02:24 PM #5603QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Guys,
I'm useing LTE 2.2, right? So, I'm coding a shell for myself, I'm trying to add a button, and when I use the code I need to add the button:
" gui->addImage(menuicon, core:
osition2d<s32>(0,0), 0, 101, 0); "
I get this error:
" main.cpp:202: error: expected primary-expression before "->" token. "
Line 202 is the code I posted above.
--------
Here's the class refrence, if you need it:
virtual IGUIImage * addImage (video::ITexture *image, core:
osition2d< s32 > pos, bool useAlphaChannel=true, IGUIElement *parent=0, s32 id=-1, const wchar_t *text=0)=0
Adds an image element.
So what is my problem?
---------
-
07-21-2007, 04:12 PM #5604QJ Gamer Green
- Registriert seit
- Apr 2006
- Ort
- England ~¦¦¦|+|¦¦¦~
- Beiträge
- 1.112
- Points
- 9.165
- Level
- 64
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Im not sure about your exact problem, but i looked that this in teh Hello World example:
maybe it should look something like that? I dunno, i have been looking at this LTE package for about 10 mins.Code:gui::IGUIStaticText* statusText = guienv->addStaticText(L"Hello World!", rect<int>(10,10,260,22), true);
I also looked at IGUIImage.h:
Code:namespace engine { namespace gui { //! GUI element displaying an image. class IGUIImage : public IGUIElement { public: //! constructor IGUIImage(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle) : IGUIElement(EGUIET_IMAGE, environment, parent, id, rectangle) {} //! destructor ~IGUIImage() {}; //! sets an image virtual void setImage(video::ITexture* image) = 0; //! sets if the image should use its alpha channel to draw itself virtual void setUseAlphaChannel(bool use) = 0; }; } // end namespace gui } // end namespace engine...Just Returned To The Scene...
-
07-21-2007, 04:14 PM #5605QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
EDIT: Nvm, Fixed it.
Geändert von MrChaos (07-21-2007 um 07:15 PM Uhr) Grund: Automerged Doublepost
-
07-22-2007, 05:23 AM #5606I'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, in my game every time I access the menu my game crashes, according to PSPLink, I have an FPU exception.
I was just wondering if the FPU exception is due to a lack of memory? Or something else? The thread works fine when its loaded on its own, and only throws up this error when its loaded after the rest of the program, also if I remove the blitting process it works fine, but I can't understand why, as the images have already been loaded in memory by that time.
Thanks or any help.
-Aura
-
07-22-2007, 05:29 AM #5607It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
And FPU exception means that something bad happened inside of the floating point unit. Generally, this is something like 1.0f/0.0f (division by zero error), which is of course impossible, but it can be other things, too.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
07-22-2007, 05:33 AM #5608
Speed Issue...
Total 12 conditions:
---
Which one is faster?
If or else if
or
Switch
Edit: I do see it's faster for X86 platform but for Mips?
-
07-22-2007, 05:39 AM #5609QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- Cape Town, South Africa
- Beiträge
- 714
- Points
- 5.795
- Level
- 49
- Downloads
- 0
- Uploads
- 0
So do you have:
with 12 "somethingElse"s? In that case, switch is faster, I'd imagine.Code:if (something == somethingElse) { ... } else if (something == somethingElse2) { .. } else if (something == somethingElse3) {... } ...
-
07-22-2007, 05:44 AM #5610
can some1 up umd.h. i dont want to download the new toolchain just to get on header so can someone hook me up


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