i really need to concentrate me a bit more , i forgottet to add it in the makefile , anyway thn;-)
Printable View
i really need to concentrate me a bit more , i forgottet to add it in the makefile , anyway thn;-)
The initial is getting rather too bromidic. You should instead make a graphic[al] one :Punk:!Zitat:
Zitat von Maxi_Jac'
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)?
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, :)
>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;
}
What is the point of making 'lSize' global?Zitat:
Zitat von hallo007
nothing
but I use it like this lSize = fsize(...);
thats why I made it global;-)
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;
}
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 prob
Depends on the OS. On Linux, with most filesystems, it's 4GB. I dunno about Windows or PSP.
I think he was trying to store the contents on the stack and blew the stack.
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;
}
http://img183.imageshack.us/img183/5...gent000qu6.png
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?
I be guessing this. *ick*
Should be:Code:strcpy((char *)fileList[z].c_str() , dir.d_name);
Code:fileList[z] = dir.d_name;
oh , thnx ;-)
c_str() reference:
http://www.cppreference.com/cppstring/c_str.html
Zitat:
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.
even better(Y)
That's all you have to say? What about his ugly use of #defines?Zitat:
Zitat von yaustar
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?
Much better. :)
*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.
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.
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.
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:
Zitat von Archaemic
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.
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:
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
yaustar, the no.1 #define hater... :)
anyways, anyone here have kernel memory dumper? i have to get on something :)
thats why you #define it after #include'ing it *omg*
What libraries use printf o_O?
Other than maybe ostream.
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%
stdioZitat:
Zitat von Archaemic
stdio rather defines it, I'd say.
*Smacks head against a wall*Zitat:
Zitat von Archaemic
*helps*Zitat:
Zitat von PSPJunkie_
...I'm missing something.
Did I say something stupid without realizing it again?
Forgive me, I'm rather tired right now.
Anyway, I just meant that stdio defines it, but doesn't use it.
since i added the mouse part , it's just crashing
yes , i know the code is ugly at the moment:pCode:int main(SceSize args, void *argp)
{
string desktopFiles[12][24]; //Storage for floople lloopst loopn desktop dlooprectory
int z = 0; //storage for copying strings
int x = 10; //storage for x coordinate
int y = 10; //storage for y coordinate
int mouseX = 10;
int mouseY = 10;
char imageBuffer[20]; //buffer for image loading
char *fileListBuffer; //buffer for file names
SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
Image *iconExample = loadImage("data/desktop/icon.PNG");//the icon
Image *iconFolder = loadImage("data/desktop/folder.PNG");
Image *mouse = loadImage("data/desktop/mouse.PNG");
string fileBuffer[222]; //for the filelist
//init the garphics
initGraphics();
pspDebugScreenInit();
pspDebugScreenClear();
//Load screenshot module
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");*/
getFileList("ms0:/");
while(1)
{
//printf("file paths stored\n");
//printf("Stored to new variabel\n");
blitImage(0,0,desktopBack);
for(int loop = 0; loop < sizeof(fileList); loop++ )
{
char buffer[10];
if(y!=0) y += 10;
if(sizeof(fileList[loop]) > 10)
{
strncpy(buffer , fileList[loop].c_str() , sizeof(buffer) - 3);
strcat(buffer , "..");
fileBuffer[loop] = buffer;
}
else
{
fileBuffer[loop] = fileList[loop];
}
// if(isFile(fileList[loop]))
//{
blitImage(x , y ,iconExample);
// }
// else
//{
//blitImage(x , y ,iconFolder);
//}
y += 40;
printg(x , y , fileBuffer[loop].c_str() , white);
if(y > 249)
{
x += 108;
y = 10;
}
}
blitImage(mouseX , mouseY , mouse);
flipScreen();
while(1)
{
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Lx < 80) //left
{
mouseX -= 10;
if(mouseX<0) mouseX = 460;
break;
}
if (pad.Lx > 175) //right
{
mouseX += 10;
if(mouseX > 480) mouseX = 0;
break;
}
if (pad.Ly > 175) //down
{
mouseY -= 10;
if(mouseY<0) mouseY = 255;
break;
}
if (pad.Ly < 80) //up
{
mouseY += 10;
if(mouseY > 272) mouseY = 0;
break;
}
if(pad.Buttons & PSP_CTRL_HOME)
{
sceKernelExitGame();
}
}
}//end while
/* 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;
}
Unless you know the exact order of files that the preprocessor goes through, that is a dangerous assumption to make. It be better (but still horrendous) to use printfSomeElse or:Zitat:
Zitat von youresam
That would be better and safer then #defining the name of a stdio function name.Code:#ifdef WINDOWS
#define printfDebugText printf
#else
#define printfDebugText pspDebugScreenPrintf
#endif
int main()
{
//.....
printfDebugText( "Hello World" );
}
-= Double Post =-
That would just be plain stupid. STL Strings are much safer then char strings by a mile. ¬¬Zitat:
Zitat von pspballer07
I believe the reason people define pspDebugScreenPrintf as printf is to make typing easier, so defining it to a word of about the same length is kinda pointless.
How about..
There, all better.Code:#define omgprintf pspDebugScreenPrintf
Spoiler for main.cpp:
Spoiler for io.cpp:
a bit rewritten and i still dindt saw a mistakes , there are no warnings either
aargh dammit , with copy/paste get every space lost:-(
Stdio declares it as a function prototype, by using the #define printf etc, it is possible that the preprocessor has changed the name of the function prototype depending on the order of files that the preprocessor has gone through.Zitat:
Zitat von Archaemic
Eek. That is dangerous. I just changed all of my "printf"s to "say". Not because it's short, but because it makes sense.
However, this is just a temporary solution until my partner creates the bitmap font. SDL_ttf looks a little bit too difficult to work with for what I'm using it for. I'd be doing a lot of metric checking, which could get slow.