Zeige Ergebnis 4.561 bis 4.590 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; Have you done work with pointers and know how they work?...
-
05-19-2007, 04:50 PM #4561QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Have you done work with pointers and know how they work?
[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-19-2007, 04:56 PM #4562QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
This is my first time working with them.
Zitat von yaustar
And I understand how they work, just not compleatly enough to notice bugs...yet.
-
05-19-2007, 04:56 PM #4563
How do you initialize an array SEPARATELY from its declaration? I want all elements to be intialized in one statement, not going through the indices one by one. Is there another way besides using a typedef struct?
GameSnooper - Random drawing of gaming news
The 32 Bit Shell - My development blog (also includes gaming oddities)
-
05-19-2007, 04:58 PM #4564QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
'Found' the bug. That code is outside function scope. Eg
This is illegal syntax. You can create and declare, define and initialise variables outside function scope but you can't do anything more with them outside function scope.Code:Image * img; img->width = 100; //etc int main() { }
-= Double Post =-
No you don't otherwise you would have noticed why it would crash immediately.
Zitat von MrChaos
Geändert von yaustar (05-19-2007 um 04:59 PM Uhr) Grund: Automerged Doublepost
[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-19-2007, 05:01 PM #4565QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
I understand that. I was just throwing it out there.
Zitat von Archaemic
-
05-19-2007, 05:02 PM #4566QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Zitat von JustChris
Code:int anArray1[4] = { 0 }; // All values in the array are 0 int anArray2[4] = { 1, 2, 4, 6 }; // The array has been given the values 1, 2, 4 and 6 int anArray3[4] = { 1, 2 }; // Illegal. You cannot partially initialise an array.[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-19-2007, 05:05 PM #4567QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
I said I didn't understand them "compleatly" :P.
Zitat von yaustar
Ok, I fixed the 'bug'. But I need to fix something else. When I fixed it, then compiled, the compiler spit out 637 errors, saying that the image data is incorrect. I'm back to my first problem now. My logo data is this:
Yeah, that's where it is. What SHOULD be in the logo data, instead of what I have?Code:logo->data = 0x7fff,0x7fff,0x7fff,0x7fff, // and so on...;
-
05-19-2007, 05:07 PM #4568
Yaustar, that works in normal cases, but I guess I need to mention now that the array I'm trying to use is declared as a private member of a class. I can't initialize it in the class declaration. Ideally it needs to be initialized in one method, and other methods called after it would be able to use the array.
GameSnooper - Random drawing of gaming news
The 32 Bit Shell - My development blog (also includes gaming oddities)
-
05-19-2007, 05:08 PM #4569QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- France
- Beiträge
- 753
- Points
- 5.784
- Level
- 49
- Downloads
- 0
- Uploads
- 0
See what yaustar said, but his only works at the declaration moment, later in your code, you can't us eit anymore, you'll have to go to each indices.
Zitat von JustChris
++ B.if I make mistakes in english, feel free to correct me or else i won't progress :D .
-
05-19-2007, 05:08 PM #4570QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
*Goes into a coma from banging had against wall"
bin2c spits a .c file out with the data definition already.
Do,
Code:img->data = variable_from_bin2c;
-
05-19-2007, 05:11 PM #4571QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
LOL! By this point you guys hate me now. Sorry guys, I studied C++, but apperently, haven't learned enough. But, I like to learn from expericence.
Zitat von PSPJunkie_
But...Now my compiler "can't convert short unsigned int [127840]' to Color* in assignment".
I think the compiler hates me too.
-
05-19-2007, 05:14 PM #4572QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
In that case, you can't. You can't initialise arrays in the initialisation list of a construct.
Zitat von JustChris
If you are using C++ then you really should be using vectors instead of arrays otherwise your only other option is to use a for loop.[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-19-2007, 05:15 PM #4573QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Maybe try masking it? I honestly don't know if that will do anything, though.
-
05-19-2007, 05:16 PM #4574QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
An error is only useful if we see the code that refers to the error.
Zitat von MrChaos
[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-19-2007, 05:18 PM #4575QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
It's:
Zitat von yaustar
logo->data = imageData;
But it referrs to the .c img file that bin2c made...
-
05-19-2007, 05:20 PM #4576It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
The first one is the only one with an assignment.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-19-2007, 05:23 PM #4577QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
What is the datatype of logo->data and imageData?
Zitat von MrChaos
What is the datatype of logo?
What is the declaration of the datatype of logo?
What is the declaration of the datatype of imageData?[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-19-2007, 05:26 PM #4578QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Datatype of logo = Not sure what you mean by that...
Zitat von yaustar
Declaration of the datatype of logo = Image* logo
Declaration of the datatype of imageData = unsigned short imageData
-
05-19-2007, 05:28 PM #4579QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
'data' is a u32, and imageData is an unsigned char.
-
05-19-2007, 05:29 PM #4580It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Geez, look at the previous page. Logo is an Image*
E] Make that two pages agopəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-19-2007, 05:29 PM #4581QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Ok. I learn stuff every day. Thanks.
Zitat von PSPJunkie_
-
05-19-2007, 05:34 PM #4582QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
This is going to be problematic. Image->data is a Color * which is a typedef'ed u32 which is an unsigned int (32 bit). imageData however is an array of unsigned shorts which are 16 bit.
If you change the following code, it will compile but won't give you the correct results (ignoring the fact that the program will still crash).
Basically, the data NEEDs to be in 32 bit format for this to work with graphics.h.Code:unsigned short imageData // Change to unsigned int imageData
To make this painless, just load the image from a seperate image file rather then try to compile the data with the code. It isn't worth the hassle.[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-19-2007, 05:34 PM #4583QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Um, try looking at graphics.h or the file that bin2c created.
andCode:typedef u32 Color;
Code:static unsigned char hw[] __attribute__((aligned(16)));
-
05-19-2007, 05:37 PM #4584QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Ok. If I include it in the makefile, will it still show in the folder?
Zitat von yaustar
-
05-19-2007, 05:38 PM #4585QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I don't have either at hand hance I asked for them.
Zitat von PSPJunkie_
A short is 2 bytes.
Zitat von MrChaos
[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-19-2007, 05:39 PM #4586QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
I don't use bin2c (even though I said I did; I use graphicsto16bitc)
Zitat von PSPJunkie_
-
05-19-2007, 05:39 PM #4587QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Saying it is an Image tells me nothing of the datatypes of the members hence I asked for a declaration since it is a non-standard datatype.
Zitat von Archaemic
[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-19-2007, 05:40 PM #4588QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Chaos, save the image as a .raw, then bin2c it.
-
05-19-2007, 05:41 PM #4589It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I never said anything about its members.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-19-2007, 05:43 PM #4590QJ Gamer Blue
- Registriert seit
- Feb 2007
- Ort
- Florida
- Beiträge
- 214
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Can you do me a favor, and send me a link to bin2c? All I find is the one I have right now, and that aint it.
Zitat von PSPJunkie_


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