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 really need to concentrate me a bit more , i forgottet to add it in the makefile , anyway ...
-
05-24-2007, 12:21 PM #4681Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
i really need to concentrate me a bit more , i forgottet to add it in the makefile , anyway thn;-)
-
05-26-2007, 04:17 AM #4682
The initial is getting rather too bromidic. You should instead make a graphic[al] one :Punk:!
Zitat von Maxi_Jac'
-
05-26-2007, 08:25 AM #4683QJ Gamer Blue
- Registriert seit
- Mar 2007
- Ort
- Holland..
- Beiträge
- 154
- Points
- 4.022
- Level
- 40
- Downloads
- 0
- Uploads
- 0
i've got some question's about filesizes :
how do i check how much space there is left in flash0?
how do i check if a directory is empty?
and how do check the size of the folder(and the files in it)?
-
05-26-2007, 09:16 AM #4684QJ Gamer Green
- Registriert seit
- Dec 2006
- Beiträge
- 94
- Points
- 3.777
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Original post by PSP Junkie
Okay, I was thinking that we should have a discussion on IRC with as many people that want to listen on a specific topic. The goal is for everyone who visits to learn something new and therefore, be on their way to becoming a better programming.
I have yet to decide what we want the the subject to be, so I am taking suggestions. We could do something like general C questions or PSP specific topics. I want this to start up in about an hour. So...
5:00PM - US Eastern Time [Me]
10:00PM - GMT
etc....
I will be there as well as Insert_Witty_Name. If you would like to participate just join "psp-seminar" on irc.freenode.net.
If you have never used an IRC client before, here are a few suggestions.
Windows: mIRC
Macs: Colloquy
Linux: irrsi
If you are a developer and are interested in helping us run this, just PM me.
Well, start some suggestions!
p.s. We hope to try to do this at least twice a week.
----------------------------------------------------
this is a great opportunity to ansswer almost any topics regarding PSP's.. but i think that LUA and flashers arent allowed there.. but just hang around there and you ll learn something, :)
-
05-26-2007, 09:16 AM #4685Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
>no need for other flasher
>build path example in sdk (kernel/fileio)
>build path too , the paths you get do you need to use in this fucntion
Code:int lSize; int fsize(const char *fn) { FILE * pFile; pFile = fopen (fn , "rb"); if (pFile==NULL) { return 0; } fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); fclose(pFile); return lSize; }
-
05-26-2007, 09:19 AM #4686QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
What is the point of making 'lSize' global?
Zitat von hallo007
-
05-26-2007, 09:24 AM #4687Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
nothing
but I use it like this lSize = fsize(...);
thats why I made it global;-)
-
05-26-2007, 09:25 AM #4688QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
No more global, plus reusable, plus buttsecks.Code:int fsize(const char *fn) { int lSize; FILE * pFile; pFile = fopen (fn , "rb"); if (pFile==NULL) { return 0; } fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); fclose(pFile); return lSize; }
-
05-26-2007, 04:00 PM #4689QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
jw what is the max size a file can be using c++ that can be opened (on psp or off) because one of my tests i keep getting an stackdump file and after further testing i find it happens when i attempt to open up a file that is 1.7mb
-= Double Post =-
nvm i think i found the probGeändert von slicer4ever (05-26-2007 um 04:18 PM Uhr) Grund: Automerged Doublepost
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-26-2007, 05:16 PM #4690It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Depends on the OS. On Linux, with most filesystems, it's 4GB. I dunno about Windows or PSP.
pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-27-2007, 02:38 AM #4691QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I think he was trying to store the contents on the stack and blew the stack.
[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-27-2007, 06:35 AM #4692Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
result:Code://DEFINES #define blitImage blitAlphaImageToScreen #define printg printTextScreen #define printf pspDebugScreenPrintf using namespace std; string fileList[222]; void getFileList(string path) { SceUID bufferFile; char nextPath[256]; int z = 0; bufferFile = sceIoDopen(path.c_str()); if(bufferFile > 0) { SceIoDirent dir; memset(&dir, 0, sizeof(SceIoDirent)); while(sceIoDread(bufferFile, &dir) > 0) { strcpy((char *)fileList[z].c_str() , dir.d_name); z++; if(z > 222 ) break; } sceIoDclose(bufferFile); } } int main(SceSize args, void *argp) { string desktopFiles[12][24]; //Storage for floople lloopst loopn desktop dlooprectory int z = 0; int x = 5; int y = 25; char imageBuffer[20]; char *fileListBuffer; Image *getImageToBuffer[12][24]; initGraphics(); pspDebugScreenInit(); pspDebugScreenClear(); LoadStartModule("data/screenshot.prx"); //loopmages load /*for(int loop = 0; loop < sizeof(desktopImages); loop++) { snprintf(imageBuffer ,sizeof(imageBuffer) - 1, "%i.PNG" ,loop); desktopImages[loop] = loadImage(imageBuffer); }*/ desktopBack = loadImage("data/desktop/wallpaper.PNG"); /*if(desktopBack < 0) printf("failed to load image\n"); else printf("Image loaded\n");*/ blitImage(0 , 0 , desktopBack); getFileList("ms0:/"); //printf("file paths stored\n"); for(int loop = 0; loop < 222; loop++ ) { printg(x , y , fileList[loop].c_str() , white); x += 20; if(x > 460) { y += 20; x = 0; } } /*x = 5; y = 5; for(int loop = 0; loop < 12; loop++ ) for(int looptwee = 0; looptwee < 24; looptwee++ ) { getImageToBuffer[loop][looptwee] = getImage(desktopFiles[loop][looptwee].c_str()); blitImage(x , y , getImageToBuffer[loop][looptwee]); x += 20; y += 20; }*/ flipScreen(); sceKernelSleepThread(); return 0; }

the results need to be:
PSP VIDEO PICTURE
and now it says something strange like
||MC , i cant really read it , anyone nows the problem?
-
05-27-2007, 06:48 AM #4693QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I be guessing this. *ick*
Should be:Code:strcpy((char *)fileList[z].c_str() , dir.d_name);
Code:fileList[z] = dir.d_name;
[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-27-2007, 06:56 AM #4694Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
oh , thnx ;-)
-
05-27-2007, 07:15 AM #4695QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
c_str() reference:
http://www.cppreference.com/cppstring/c_str.html
Note that since the returned pointer is of type const, the character data that c_str() returns cannot be modified. Furthermore, you do not need to call free() or delete on this pointer.[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-27-2007, 07:30 AM #4696Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
even better(Y)
-
05-27-2007, 07:58 AM #4697QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
That's all you have to say? What about his ugly use of #defines?
Zitat von yaustar
-
05-27-2007, 08:10 AM #4698QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Point.
Why? Just...why? Type them out fully like everyone else. No one is going to know what the heck printg and blitImage do unless you give them the defines. The whole point of the original function names is because they are descriptive and self documenting. Your defines are not. Don't even get me start on the printf define.Code:#define blitImage blitAlphaImageToScreen #define printg printTextScreen #define printf pspDebugScreenPrintf
Macros are just plain evil, evil, evil, evil. Not to mention buggy as hell.
PSPJunkie: How is that?[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-27-2007, 08:19 AM #4699QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Much better. :)
-
05-27-2007, 08:57 AM #4700It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
*has just returned from converting all of the #define constants to consts*
<.<
>.>
Okay, so those aren't the kind of #defines you were talking about, but I have a good reason for aliasing pspDebugScreenPrintf to printf. This program compiles on both Windows and PSP. When I call the function on the PSP, I want it to display to the screen, and when I call the function on Windows, I'd like it to display to the screen, but I've not yet written code for that, so it just prints to STDOUT like you'd expect it to.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-27-2007, 09:06 AM #4701QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Considering the standard Hello World code:
How would you remove all the header includes, callback functions, the vblank state and sleep threads when you compile for Windows?Code:// Hello World - A simple "Hello World" Application. #include <pspkernel.h> #include <pspdebug.h> PSP_MODULE_INFO("Hello World", 0, 1, 1); // Exit callback int ExitCallback(int Arg1, int Arg2, void *Common) { sceKernelExitGame(); return 0; } // Callback thread int CallbackThread(SceSize Args, void *Argp) { int CallbackId; CallbackId = sceKernelCreateCallback("Exit Callback", ExitCallback, NULL); sceKernelRegisterExitCallback(CallbackId); sceKernelSleepThreadCB(); return 0; } // Sets up the callback thread and returns its thread id int SetupCallbacks(void) { int ThreadId = 0; ThreadId = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if (ThreadId >= 0) { sceKernelStartThread(ThreadId, 0, 0); } return ThreadId; } int main(int argc, char ** argv) { pspDebugScreenInit(); SetupCallbacks(); while(1) { pspDebugScreenPrintf ("Hello World"); sceDisplayWaitVblankStart(); } sceKernelSleepThread(); return 0; }
You would have to either physically remove them or #ifdef them out.
Considering printf on all platforms would print to the console (or TTY on consoles), a programmer should never change the expected functionality of standard libraries.
'Using' printf to print to the screen is not expected behaviour. It will always print to the TTY on a console platform.[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-27-2007, 09:29 AM #4702It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Yes, I'm aware of that. I'm waiting on my partner to make a graphical font so that I can make graphical menu. I'll remove all of the printfs then.
And also, it's an SDL app.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-27-2007, 11:30 AM #4703QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Wait, I am confused. If it is an SDL app which is already cross platform, then why would you need printf? Why not use SDL_ttf until you get a bitmap font?
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-27-2007, 11:57 AM #4704It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I'm trying to keep dependencies to a minimum.
Also, I'm using printf so that I can refer to the output that would generally be on the screen.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-27-2007, 12:21 PM #4705QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
As soon as you get the bitmap then get rid of SDL_ttf. If you are going to have WIP builds, you might as well have it relatively as close as you can to the final builds. The dependencies only really matter in the final release build.
Zitat von Archaemic
Just create an abstraction layer to print text on the screen which the game uses, that way you only have to change one function in one section of code after you rip out SDL_ttf in favour of bitmap fonts.
-= Double Post =-
I just thought of something nasty about:#defines don't obey scope, so this will replace anything that is printf to pspDebugScreenPrintf including standard library headers.*ouch*.Code:#define printf pspDebugScreenPrintf
Geändert von yaustar (05-27-2007 um 12:38 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-27-2007, 05:10 PM #4706QJ Gamer Green
- Registriert seit
- Dec 2006
- Beiträge
- 94
- Points
- 3.777
- Level
- 38
- Downloads
- 0
- Uploads
- 0
yaustar, the no.1 #define hater... :)
anyways, anyone here have kernel memory dumper? i have to get on something :)
-
05-27-2007, 05:37 PM #4707
thats why you #define it after #include'ing it *omg*
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
05-27-2007, 05:51 PM #4708It's good to be free...

- Registriert seit
- Feb 2007
- Beiträge
- 2.440
- Points
- 10.420
- Level
- 67
- Downloads
- 0
- Uploads
- 0
What libraries use printf o_O?
Other than maybe ostream.pəʇuɒɹɓ ɹoɟ ɓuɪɥʇou əʞɒʇ
-
05-27-2007, 05:55 PM #4709
Hey Hallo007, my suggestion would be this
[CODE]//DEFINES
#define blitImage blitAlphaImageToScreen
#define printg printTextScreen
#define printf pspDebugScreenPrintf
using namespace std;
char fileList[222][200]; //********change from string to char[], 200 is the max filename length
void getFileList(string path)
{
SceUID bufferFile;
char nextPath[256];
int z = 0;
bufferFile = sceIoDopen(path.c_str());
if(bufferFile > 0)
{
SceIoDirent dir;
memset(&dir, 0, sizeof(SceIoDirent));
while(sceIoDread(bufferFi le, &dir) > 0)
{
strcpy(fileList[z], dir.d_name); //******changed to fit
z++;
if(z > 222 ) break;
}
sceIoDclose(bufferFile);
}
}
int main(SceSize args, void *argp)
{
string desktopFiles[12][24]; //Storage for floople lloopst loopn desktop dlooprectory
int z = 0;
int x = 5;
int y = 25;
char imageBuffer[20];
char *fileListBuffer;
Image *getImageToBuffer[12][24];
initGraphics();
pspDebugScreenInit();
pspDebugScreenClear();
LoadStartModule("data/screenshot.prx");
//loopmages load
/*for(int loop = 0; loop < sizeof(desktopImages); loop++)
{
snprintf(imageBuffer ,sizeof(imageBuffer) - 1, "%i.PNG" ,loop);
desktopImages[loop] = loadImage(imageBuffer);
}*/
desktopBack = loadImage("data/desktop/wallpaper.PNG");
/*if(desktopBack < 0) printf("failed to load image\n");
else printf("Image loaded\n");*/
blitImage(0 , 0 , desktopBack);
getFileList("ms0:/");
//printf("file paths stored\n");
for(int loop%Geändert von pspballer07 (05-27-2007 um 06:39 PM Uhr)
Current releases:
Icon Action Replacer v1.5- latest release
Current projects:
PSP C++ IDE - Currently v1.6
RPG Paradise - Latest version at my website
-
05-27-2007, 05:57 PM #4710Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
stdio
Zitat von Archaemic

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


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