Zeige Ergebnis 5.311 bis 5.340 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; yep what i wanted thanks...
-
07-03-2007, 05:13 AM #5311QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
yep what i wanted thanks
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-03-2007, 05:17 AM #5312QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
For reference, in C++ it be:
Code:void function( int & aInt ) { aInt = 6; } // use int blah = 4; function(blah);[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-03-2007, 05:30 AM #5313
I have seen some use int& as well as int &aInt --- which one does it refer to?
Zitat von yaustar
Geändert von Mr305 (07-03-2007 um 05:40 AM Uhr)
-
07-03-2007, 05:38 AM #5314QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
The error means you tried to initialize the variable in an impossible way, ie you had the variable global (outside of a function scope). You cannot call functions outside of a function scope.
Zitat von myschoo
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-03-2007, 06:04 AM #5315QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Doesn't matter, they are both the same:
Zitat von Mr305
Code:int& aInt // is the same as int &aInt // and int & aInt
[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-03-2007, 06:45 AM #5316QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
ok i solved it like this:
in the begginning i have:
int bat;
and later in main:
bat = scePowerGetBatteryLfePerc ent();[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
07-03-2007, 07:04 AM #5317
Is it harmful or potentially flawed?Code:void sayHellow0rld(const char varname[])
Becz ever since I changed it to char varname[100], everything is very very stable...
-
07-03-2007, 07:08 AM #5318QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Can be very harmful. Buffer overruns is going to be the biggest problem.
Zitat von Mr305
[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-03-2007, 07:36 AM #5319
The first one or the one I fixed [it isn't going to be >100 for sure] ?
Zitat von yaustar
Suppose, for the first one:
If first a char array of length 3 is passed ... Then char array of length 6 passed.. Would allocation be done?
-
07-03-2007, 07:37 AM #5320QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 499
- Points
- 5.848
- Level
- 49
- Downloads
- 0
- Uploads
- 0
not really flawed. In C++, if you pass a 1D array to a funcion, you don't have to tell it the size of the array you are passing.
Zitat von Mr305
As yaustar mentioned, it can cause overflows if you start trying an array that is bigger than 100 chars. Check if you are trying to change something in the array, as delcaring the array as const means that you only get read access to the array, whereas with char varname[100] you obviously get access, so maybe your trying to change something somewhere.
-
07-03-2007, 09:14 AM #5321QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
how do i use printTextScreen() to print out a variable?
I want to display a score from a variable to a specific area on the screen.
-
07-03-2007, 09:31 AM #5322
I HIGHLY recommend www.cprogramming.com
--
use sprintf.
-
07-03-2007, 09:38 AM #5323QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
sprintf? ok...
yes, i do use that website, but i'm not sure whats different for psp. there is a lot that is changed.
Yeah, i figured out sprintf now.Geändert von Nicko01 (07-03-2007 um 10:31 AM Uhr)
-
07-03-2007, 10:50 AM #5324
i'm writing a prx using dsxlib, its a nice looking vsh extender. I'm trying to bring all the functions of other prxs screenshot, homebrew launching, brightness, cpu speed etc into one package.
my problem is this, i've just noticed the music, video and web browser freeze up when its launched. Would lowering the thread priority have an effect on these freezes. Does anybody know why this is happening
Please guys could someone help me out.
post or just send me a pm
-
07-03-2007, 10:53 AM #5325
-> Keep Arrays/any sizes as small as possible.
Zitat von brethren
-> Put up a small delay at the end of the loop
-> 1 Thread's enough.
That's I cud think of...
-
07-03-2007, 11:52 AM #5326QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
Zitat von Mr305
sorry, im still a n00b at this.
-
07-03-2007, 12:07 PM #5327
google psp sdk documentation. also www.psp-programming.com - great resource
Zitat von Nicko01
-
07-03-2007, 12:16 PM #5328
- Registriert seit
- Nov 2006
- Beiträge
- 11
- Points
- 3.593
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Are there draw commands in C/C++? I want to draw a line from one coordinate to another on my psp, but I have no idea how to do it without using ascii.
In particular, I'm looking for line drawing in particular colors, if there is a fill command, and draw polygon command.
And how do I use the trig commands like arctan?
-
07-03-2007, 12:32 PM #5329QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- c:\Program Files\World of Warcraft\WoW.exe
- Beiträge
- 98
- Points
- 4.031
- Level
- 40
- Downloads
- 0
- Uploads
- 0
i know psp-programming.com....
-
07-03-2007, 12:43 PM #5330
i'm using pspjunkies dsxlib to make a prx, i've solved the last problem i had (further up the page) but i need a bit more help. Sometimes the menu i display in the vsh flickers (usually when a umd is being read or i underclock) is there anyway to stop this flickering.
-
07-03-2007, 01:09 PM #5331
lesson4 graphics.c.
Zitat von zwnage
math.h
-
07-03-2007, 01:17 PM #5332
- Registriert seit
- Nov 2006
- Beiträge
- 11
- Points
- 3.593
- Level
- 37
- Downloads
- 0
- Uploads
- 0
lesson 4? The simple image processing tutorial? But that refers to displaying a picture, I did not see any instance of line drawing commands in the tutorial.
Zitat von Mr305
EDIT: Ooops, my bad. I just looked though graphics.c and found it.
Now how about a draw polygon command? fill command?
-
07-03-2007, 01:35 PM #5333
i dont remmbr, its there too
Zitat von zwnage
-
07-03-2007, 01:42 PM #5334
- Registriert seit
- Nov 2006
- Beiträge
- 11
- Points
- 3.593
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Thanks for the help :) .
Now is there a way to fill the polygon with a color?
-
07-03-2007, 01:46 PM #5335words 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
You need to understand how slow and basic graphics library is. But, you could make a draw polygon command
That should draw a white, closed square with an area of 25 in the center of the screen, not filledCode:typedef struct Point { int x,y; } Point; inline void drawPolygon(int x, int y, const Point *points, const Color color, const bool closed) { for(int i=0; i<sizeof(points); i++) { drawLine(x + points[i].x, y + points[i].y, x + ((closed && i==sizeof(points)-1) ? points[0].x : points[i+1].x), y + ((closed && i==sizeof(points)-1) ? points[0].y : points[i+1].y), color); } // usage: Point square[4] = { {-5,5}, {5,5}, {5,-5}. {-5,-5} } drawPolygon(237,133,square,RGB(255,255,255), true);
I believe drawLine is the function name, and those are it's parameters?
...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-03-2007, 02:39 PM #5336QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Code:typedef struct { float x, y, z; } DSX2DVERTEX; void dsxDrawLine(float x1, float y1, float x2, float y2, Color color) { DSX2DVERTEX* src = (DSX2DVERTEX*) sceGuGetMemory(sizeof(DSX2DVERTEX) * 2); src[0].x = x1; src[0].y = y1; src[0].z = 0.0f; src[1].x = x2; src[1].y = y2; src[1].z = 0.0f; sceGuColor(color); sceGuDisable(GU_TEXTURE_2D); sceGuShadeModel(GU_FLAT); sceGuDrawArray(GU_LINES, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, src); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_TEXTURE_2D); } void dsxDrawRectangleFilled(float x, float y, float w, float h, Color color) { DSX2DVERTEX* src = (DSX2DVERTEX*) sceGuGetMemory(sizeof(DSX2DVERTEX) * 2); src[0].x = x; src[0].y = y; src[0].z = 0.0f; src[1].x = x + w; src[1].y = y + h; src[1].z = 0.0f; sceGuColor(color); sceGuDisable(GU_TEXTURE_2D); sceGuShadeModel(GU_FLAT); sceGuDrawArray(GU_SPRITES, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, src); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_TEXTURE_2D); } void dsxDrawRectangleOutlined(float x, float y, float w, float h, Color color) { DSX2DVERTEX* src = (DSX2DVERTEX*) sceGuGetMemory(sizeof(DSX2DVERTEX) * 3); DSX2DVERTEX* src2 = (DSX2DVERTEX*) sceGuGetMemory(sizeof(DSX2DVERTEX) * 3); src[0].x = x; src[0].y = y; src[0].z = 0.0f; src[1].x = x + w; src[1].y = y; src[1].z = 0.0f; src[2].x = x + w; src[2].y = y + h; src[2].z = 0.0f; src2[0].x = x; src2[0].y = y; src2[0].z = 0.0f; src2[1].x = x; src2[1].y = y + h; src2[1].z = 0.0f; src2[2].x = x + w + 1.0f; src2[2].y = y + h; src2[2].z = 0.0f; sceGuColor(color); sceGuDisable(GU_TEXTURE_2D); sceGuShadeModel(GU_FLAT); sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 3, 0, src2); sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 3, 0, src); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_TEXTURE_2D); } void dsxDrawCircleFilled(float x, float y, float radius, u32 numSteps, Color color) { if(radius <= 0) { return; } if(numSteps < 1) { numSteps = 1; } numSteps = radius * 400; float stepSize = (2 * GU_PI) / (numSteps * 4); DSX2DVERTEX* vertices = (DSX2DVERTEX*) sceGuGetMemory((numSteps * 4 + 2) * sizeof(DSX2DVERTEX)); vertices[0].x = x; vertices[0].y = y; vertices[0].z = 0.0f; int step; u32 numSteps2 = numSteps * 2, numSteps3 = numSteps * 3; float angle = 0; for(step = 1; step < numSteps + 1; step++) { float s = sinf(angle) * radius; float c = cosf(angle) * radius; angle += stepSize; vertices[step].x = x + s; vertices[step].y = y + c; vertices[step].z = 0.0f; vertices[step + numSteps].x = x + c; vertices[step + numSteps].y = y - s; vertices[step + numSteps].z = 0.0f; vertices[step + numSteps2].x = x - s; vertices[step + numSteps2].y = y - c; vertices[step + numSteps2].z = 0.0f; vertices[step + numSteps3].x = x - c; vertices[step + numSteps3].y = y + s; vertices[step + numSteps3].z = 0.0f; } vertices[numSteps * 4 + 1].x = vertices[1].x; vertices[numSteps * 4 + 1].y = vertices[1].y; vertices[numSteps * 4 + 1].z = 0.0f; sceGuColor(color); sceGuDisable(GU_TEXTURE_2D); sceGuShadeModel(GU_FLAT); sceGuDrawArray(GU_TRIANGLE_FAN, GU_VERTEX_32BITF | GU_TRANSFORM_2D, numSteps * 4 + 2, 0, vertices); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_TEXTURE_2D); } void dsxDrawCircleOutlined(float x, float y, float radius, u32 numSteps, Color color) { if (radius <= 0) { return; } if (numSteps < 1) { numSteps = 1; } if(numSteps == 0) { //use preset value numSteps = radius * 400; } float stepSize = (2 * GU_PI) / (numSteps * 4); DSX2DVERTEX* vertices = (DSX2DVERTEX*) sceGuGetMemory((numSteps * 4 + 1) * sizeof(DSX2DVERTEX)); int step; u32 numSteps2 = numSteps * 2, numSteps3 = numSteps * 3; float angle = 0; for(step = 0; step < numSteps; step++) { float s = sinf(angle) * radius; float c = cosf(angle) * radius; angle += stepSize; vertices[step].x = x + s; vertices[step].y = y + c; vertices[step].z = 0.0f; vertices[step + numSteps].x = x + c; vertices[step + numSteps].y = y - s; vertices[step + numSteps].z = 0.0f; vertices[step + numSteps2].x = x - s; vertices[step + numSteps2].y = y - c; vertices[step + numSteps2].z = 0.0f; vertices[step + numSteps3].x = x - c; vertices[step + numSteps3].y = y + s; vertices[step + numSteps3].z = 0.0f; } vertices[numSteps * 4].x = vertices[0].x; vertices[numSteps * 4].y = vertices[0].y; vertices[numSteps * 4].z = 0.0f; sceGuColor(color); sceGuDisable(GU_TEXTURE_2D); sceGuShadeModel(GU_FLAT); sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_2D, numSteps * 4 + 1, 0, vertices); sceGuShadeModel(GU_SMOOTH); sceGuEnable(GU_TEXTURE_2D); }Geändert von PSPJunkie_ (07-04-2007 um 09:58 AM Uhr)
-
07-04-2007, 01:59 AM #5337words 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
May I ask you why there is a large, ~25 line gap between the last } and the bottom of the code block? Forum bug I hope (or do you add a bunch of returns once you finish a source file (eww))

...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-04-2007, 02:12 AM #5338Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
I don't see a gap.
Perhaps it's your browser? (I'm on Firefox).
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
07-04-2007, 07:03 AM #5339I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I've been doing all my testing in iRShell for various reasons (one being I can't get PSPlink to work), and after completing my first quest, I decided to try it properly on the PSP...
Where on iRShell buttons are accepted, when run alone, I can only get buttons in the main thread to be recognised, and not from any other threads... this is obviously proving a problem...
I've had to NULL the buffer after pritty much every button press due to it going mental when you press a button (it does that thing many times before it stops)...
Any help would be greatly welcome as its the only thing stopping me finishing off the rest of my quests :Argh:
Thanks
-Aura
Excuse me while I shoot myself... solved the problem
Just for the record...I'm seeing a massive gap... and I'm on Opera...I don't see a gap.
Perhaps it's your browser? (I'm on Firefox).Geändert von Auraomega (07-04-2007 um 07:41 AM Uhr)
-
07-04-2007, 07:57 AM #5340QJ Gamer Blue
- Registriert seit
- Mar 2006
- Ort
- France
- Beiträge
- 239
- Points
- 7.538
- Level
- 57
- Downloads
- 0
- Uploads
- 0
Hi guys!
Just a lil' question : To get the color of a pixel, I use GetPixelScreen(int x, int y), but can I use this function or an other to get the color of a pixel of a picture that is NOT blitted on screen?


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