@auraomega: that shouldn't make a difference. it works the same way
@psp_jono: I did tell him that "extern Global global;" needs to be in there. He has it in but didn't put that part.
Printable View
@auraomega: that shouldn't make a difference. it works the same way
@psp_jono: I did tell him that "extern Global global;" needs to be in there. He has it in but didn't put that part.
Yeah, that post wasn't actually meant for you, I was telling Auraomega because I thought he had removed it.Zitat:
Zitat von pspballer07
:oZitat:
Zitat von psp_jono
I wouldn't be to sure, mate.
Gives me:Code:#include <stdio.h>
typedef struct ThisWontWork
{
int myVar;
int myOtherVar;
};
int main(int argc, char* argv[])
{
ThisWontWork myStruct;
myStruct.myVar = 1;
myStruct.myOtherVar = 1;
return 0;
}
Zitat:
[email protected]:~/.temp/jono_struct$ gcc main.c -o typedef_struct
main.c:7: warning: useless storage class specifier in empty declaration
main.c: In function ‘main’:
main.c:11: error: ‘ThisWontWork’ undeclared (first use in this function)
main.c:11: error: (Each undeclared identifier is reported only once
main.c:11: error: for each function it appears in.)
main.c:11: error: expected ‘;’ before ‘myStruct’
main.c:12: error: ‘myStruct’ undeclared (first use in this function)
BUT, this compiles and runs fine.
Code:#include <stdio.h>
typedef struct ThisWontWork
{
int myVar;
int myOtherVar;
} ThisWontWork;
int main(int argc, char* argv[])
{
ThisWontWork myStruct;
myStruct.myVar = 1;
myStruct.myOtherVar = 1;
return 0;
}
Strange, I jut tested it on a small gcc compiler on my pc and it compiled and ran without a problem.
Here is the code, like I said it compiles and runs fine.
I guess it must be a difference in the standards used by the pc compiler I'm using and the psp-gcc compiler.Code:#include "stdio.h"
typedef struct
{
int a;
} Example1;
typedef struct Example2
{
int a;
};
Example1 global1;
Example2 global2;
int main()
{
global1.a = 1;
global2.a = 2;
printf( "Global: %d\nGlobal2: %d", global1.a, global2.a);
return 0;
}
Thanks, always handy to find these things out.
I should've tested on the psp first :)
Hm, I compiled the above example in my post with GCC 4.1.2 Ubuntu Linux. Now, I just tried to compile the same example for the psp, and I get:
Zitat:
[email protected]:~/.temp/jono_struct$ make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -G0 -Wall -D_PSP_FW_VERSION=150 -c -o main.o main.c
main.c:10: warning: useless storage class specifier in empty declaration
main.c: In function ‘main’:
main.c:14: error: ‘ThisWontWork’ undeclared (first use in this function)
main.c:14: error: (Each undeclared identifier is reported only once
main.c:14: error: for each function it appears in.)
main.c:14: error: expected ‘;’ before ‘myStruct’
main.c:15: error: ‘myStruct’ undeclared (first use in this function)
make: *** [main.o] Error 1
Hm, I'm interested to know which version of GCC you tried compiling withZitat:
-= Double Post =-
Ahah! It looks like it is only valid in C++. :P
Hmm, I guess it must just be the standard that the compilers adheres to, some standards must be a bit more relaxed.
I use the above basically all the time. It must be the most acceptable to the different standards because I've never had a problem with it.Code:typedef struct
{
// member vars
} Structure;
The only exception is if I have a self-referential structure, in which case I just typedef the struct name later.
ie.
EDIT: Ahh. I jut saw your footnote and yep you are correct, I'm using a c++ compiler. I didn't even realise :).Code:struct example
{
struct example* a;
};
typedef struct example Example;
Its a small program called jens file editor, it came with a built in gcc compiler.
Well, you could do:
I believe that would work.Code:typedef struct _myStruct
{
_myStruct* s;
} myStruct;
struct tagnameforcompiler {
int variable1;
int variable2;
char variable3;} declarestructvariable1, declarestructvariable2;
declarestructvariable1.va riable1 = 10;
declarestructvariable2.va riable3 = 'C';
I've never seen a self-referential structure defined like that, much better than seperating the typdef from the structure definition. Thanks :)Zitat:
Zitat von _dysfunctional
what is the function to erase the entire nand. no i am not making a bricker (pointless becasue of pandoras battery) my brother cracked his lcd screen and the whole right side doesnt work. Instead of buying a new psp he is waiting for the psp slim. so i just want to try the pandora battery method myself by bricking his psp then recovering it. I also want to see if the psp can recover from a 100% corrupt or missing flash. if you feel its not a good idea to post the function on the forum, please pm me it
Zitat:
Zitat von vodkkaa
???Code:sceNandEraseAllBlock();
pspnand_driver.h as a header... Youd need to make it a kernel app etc...
lol i just found it in pspnand_driver.h. thanks though
vodkkaa: my mate formated flash0 and then recovered, so it should work
vodkkaa is erasing the whole flash, it'll destroy idstorage, flash0/1/2/3 etc.Zitat:
Zitat von myschoo
and pandora WONT recover it , so pointless to test , hold the psp for tests with idstorage , much more needed
so where is stored idstorage? if u format flash0 and then still recover
on the nand , idstorage.prx is a librarie
:facepalm: idstorage.prx is a library in flash0 that manipulates the idstorage. It isn't the idstorage itself.
If thats so, where is idstorage actually stored, I'm guessing its not hardcoded into the hardware, else it wouldn't be damagable, right? And what are the exact ill effects of removing it?Zitat:
Zitat von Archaemic
I've never really understood that much about idstorage, I guess now is the time to learn :)
-Aura
Thats just the same I said:rolleyes:Zitat:
Zitat von Archaemic
he said format flash0 => doesnt do anything to flash0
so i said it's on the nand , idstorage.prx (I guess that is the thing why he thought it was on flash0) is a library....
NAND is a kind of flash memory, by the way, and at that, the kind that the PSP uses. Saying it's on the NAND and on the flash memory mean the same thing. It's just not one of the flashx folders.
flash0 is a partation on the nand (or how you say it in englisch)
Partition. And yes, that's exactly what flash0 is.
So, where exactly is idstorage? I'm assuming by what was said that its in a partition of the nand, but we know its not going to be in flash0-3... I'm confused...
And another question, how do I check the content of a directory, and display everything in it, sort of like iRShell or PSP Filer... I've taken a look at various peices of source code, but just got overwhelmed (I'm not good at reading big peices of source code from other people). I've noticed that there appears to be nothing in the pspiomanager.h file that can help.
-Aura
Um, sceIoDopen, sceIoDread and sceIoDclose.
Thats it? *Smashes head on table*Zitat:
Zitat von Archaemic
Do you have as simple an answer to the idstorage question? :p
-Aura
Umm, hold on. I have a sample some where...
-= Double Post =-
This is from something I was making, called dsxPlugin.
I didn't finish it because I didn't think anyone would use it, but still, it shows how it works. Or, at least, how I would do it.Code:typedef struct
{
char filename[256];
int id;
} dsxFile;
typedef struct
{
int numFiles;
dsxFile* files;
} dsxFilebrowser;
dsxFilebrowser _dsxFilebrowser;
char _dsxPluginBrowserPath[256] = "ms0:";
int dsxPluginBrowserSet(const char* path)
{
strncpy(_dsxPluginBrowserPath, path, 256);
printf("New browser path:\n\t%s\n", _dsxPluginBrowserPath);
return 1;
}
int dsxPluginBrowserBuild()
{
/**
* Define our dirent.
* dirent holds the current
* file info. As we need our
* dirent to act as a point,
* memset it before use.
*/
SceIoDirent dirent;
memset(&dirent, 0, sizeof(SceIoDirent));
SceUID dirId = sceIoDopen(_dsxPluginBrowserPath);
if(dirId < 0)
{
//* Error check
printf("Error: Unable to open directory \"%s\". SONY ERROR CODE: %X\n", _dsxPluginBrowserPath, dirId);
dsxPluginBrowserSet("ms0:");
dsxPluginBrowserBuild();
}
/**
* Get file count.
* sceIoDread return > 0 when
* there are still files to
* be read in the said directory.
*/
int fileCount = 0;
while(sceIoDread(dirId, &dirent) > 0)
{
fileCount++;
}
/**
* Close and reopen the file.
* There is no rewind function
* in the sceIo* lib, so we
* do it the manual way.
*/
sceIoDclose(dirId);
dirId = sceIoDopen(_dsxPluginBrowserPath);
if(dirId < 0)
{
//* Error check
printf("Error: Unable to open directory \"%s\". SONY ERROR CODE: %X\n", _dsxPluginBrowserPath, dirId);
dsxPluginBrowserSet("ms0:");
dsxPluginBrowserBuild();
}
/**
* Free any files that
* are left.
*/
if(_dsxFilebrowser.files)
{
free(_dsxFilebrowser.files);
_dsxFilebrowser.files = NULL;
}
/**
* Malloc enough data to
* hold enough files for the
* current directory.
*/
_dsxFilebrowser.files = (dsxFile*) malloc(sizeof(dsxFile) * fileCount);
int i, err;
for(i = 0; i < fileCount; i++)
{
err = sceIoDread(dirId, &dirent);
if(err < 0)
{
printf("Unable to read file.\n");
return 0;
}
/**
* Get filename and file id.
*/
strncpy(_dsxFilebrowser.files[i].filename, dirent.d_name, 256);
_dsxFilebrowser.files[i].id = i;
}
_dsxFilebrowser.numFiles = fileCount;
sceIoDclose(dirId);
return 1;
}
int dsxPluginBrowserDump(const char* path)
{
FILE* pFile = fopen(path, "a");
if(!pFile)
{
printf("Error: Unable to open file, \"%s\"\n", path);
return 0;
}
int i;
for(i = 0; i < _dsxFilebrowser.numFiles; i++)
{
fprintf(pFile, "File ID: %d\n\t%s\n\n", _dsxFilebrowser.files[i].id, _dsxFilebrowser.files[i].filename);
}
fclose(pFile);
return 1;
}
Thanks, that should come in handy.
-Aura
Ok, I've got it all working well, except how to go down the directories, as in going from ms0:/PSP/GAME to ms0:/PSP, when using the .. option. Is there some sort of easy way of doing this, or do I have to do this manually?
Also, whats the . signify? I always thought that ./ was the same directory?
. is the root
and just write some function to let the user press 0 to go a folder up
hallo is wrong again. . is the same folder. It's just there because it's part of various standards.
"." and "./" mean the same thing, unless there's a subtle difference that I'm unaware of.
Really quick question here.
When would you use int main(int argc, char* argv[]) instead of just int main() ?
If you want to accept command line arguments. On the PSP, that really only happens if it's an iR Shell plugin.
Please, stop answering questions. :/Zitat:
Zitat von hallo007
. and ./ mean the same thing. The difference is that . is a directory, so you can't append a file to it.
Would represent a folder named '.someotherfolder'.Zitat:
.someotherfolder/
Would represent a folder named 'someotherfolder' in the current directory.Zitat:
./someotherfolder/
I've never felt the need for it, nor was I ever interested in using it, but can't you useZitat:
Zitat von Archaemic
I remember I saw it a while back but never got around to using it.Code:pspSdkLoadStartModuleWithArgs(const char *filename, int mpid, int argc, char * const argv[]);
Yes, and the argc and argv are passed to the main function, telling the plugin what to do.
How do I go down a directory? I've tried making a manual way, but I keep crashing or ending up in the root oddly.
Also, how do I check file extentions? So as to load a .PBP when its selected.
Thanks
-Aura
strrchr will be your friend in both cases.
Well, there's a few approaches to doing that. You could:Zitat:
Zitat von Auraomega
Thats one way to do it. Also, you would need to create a menu to select the items. Shouldn't take much space for the entire code.Code:void load_file(char* file)
{
int x = 0;
char temp[5];
int namelen = strlen(file);
file += (namelen-4);
if(strcmp(file,".pbp")==0)
{
file -= (namelen-4);
/*Load eboot*/;
}
}
Why modify file?
Code:void load_file(const char *file)
{
int namelen = strlen(file)
if(strcasecmp(file+namelen-4,".pbp")==0)
{
/*Load eboot*/;
}
}