how to load binary files from USB?
how to load binary files from USB?
I'm running my elf from a USB mass storage connected to the PS2, and I would like to load binary files from this same USB drive.
But:
FILE * f=fopen("someFile","r");
doesn't seem to work.
What would be the correct method?
Thank you
But:
FILE * f=fopen("someFile","r");
doesn't seem to work.
What would be the correct method?
Thank you
If you didn't reset the IOP (and the program you launched yours with didn't and the drivers the launcher used are standard ioman/iomanx compatible - you probably won't get it working with SM mass drivers) then just open the "mass:somefile" or "mass0:somefile".
If you did reset IOP, then load iomanx (not really mandatory), usbd and usbhdfsd, then access your files.
If you did reset IOP, then load iomanx (not really mandatory), usbd and usbhdfsd, then access your files.
I've been able to load a file with
FILE * f=fopen("mass:someFile","r");
with the texture example from ps2sdk,
but when change the graphic system from the example into the SDL graphic sytem, then the fopen function doesn't seem to work anymore...
Could SDL lib or gsKit lib conflict with the fopen function??
FILE * f=fopen("mass:someFile","r");
with the texture example from ps2sdk,
but when change the graphic system from the example into the SDL graphic sytem, then the fopen function doesn't seem to work anymore...
Could SDL lib or gsKit lib conflict with the fopen function??
I can't believe this simple code doesn't work, this is so frustrating!
The PS2 crashes when the file is read well is guess so because the small SDL square drawn after the file read is not displayed.
any suggestions ?
The PS2 crashes when the file is read well is guess so because the small SDL square drawn after the file read is not displayed.
Code: Select all
#include <tamtypes.h>
#include <dma.h>
#include <draw.h>
#include <stdio.h>
#include <graph.h>
#include <malloc.h>
#include <math3d.h>
#include <packet.h>
#include <string.h>
#include <sdl.h>
SDL_Surface *screen;
int main(int argc, char **argv) {
Uint32 videoflags;
/* Initialize SDL */
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
videoflags = SDL_SWSURFACE;
while( argc > 1 ) {
--argc;
if ( argv[argc] && !strcmp(argv[argc], "-fullscreen") ) {
videoflags |= SDL_FULLSCREEN;
} else {
fprintf(stderr, "Usage: %s [-fullscreen]\n", argv[0]);
exit(1);
}
}
screen = SDL_SetVideoMode(640, 480, 0, videoflags);//0
SDL_Rect temp;
temp.x = 0;
temp.y = 0;
temp.h = 480;
temp.w = 640;
SDL_FillRect(screen,&temp,31);
SDL_Flip( screen );
FILE *infile;
int b=0;
infile = fopen("mass:polly.jpg", "rb");
fread(&b,sizeof(unsigned char),1,infile);
fclose(infile);
//draw a small square
temp.x = 20;
temp.y = 20;
temp.h = 40;
temp.w = 40;
SDL_FillRect(screen,&temp,31*32);
SDL_Flip( screen );
// The main loop...
for (;;) {
}
// End program.
return 0;
}
From all the tests I've done, I've concluded that as soon as I use gskit or SDL I can't load anymore external files :(
The texture example from the sdk which load "mass:texture.raw" works well,
but the bigtext from the gskit examples just doesn't work.
And I can't find a way to display a simple white pixel on the screen without using one of those libs.
Don't know what to try next...
The texture example from the sdk which load "mass:texture.raw" works well,
but the bigtext from the gskit examples just doesn't work.
And I can't find a way to display a simple white pixel on the screen without using one of those libs.
Don't know what to try next...
softwares for artists on video game systems - http://www.pikilipita.com
I didn't compile your example (weekend time ran out too much quicly) but
from your code :
why are you trying to load 1 byte to the memory address of the b integer?
why don't you allocate a buffer and load into it the proper way?
If you comment the code above, does it still crashes?
Try to load to a allocated buffer and try again.
from your code :
Code: Select all
FILE *infile;
int b=0;
infile = fopen("mass:polly.jpg", "rb");
fread(&b,sizeof(unsigned char),1,infile);
fclose(infile);
why don't you allocate a buffer and load into it the proper way?
If you comment the code above, does it still crashes?
Try to load to a allocated buffer and try again.
The 1 byte things was just here to test is the file does exist.
My research so far:
I've been able to load a file when using gsKit with
fopen() and using relative paths :
"polly.jpg" and not "mass:polly.jpg"
But loading a file with gsKit functions like:
gsKit_texture_png(gsGlobal, &Tex1, "test.png");
doesn't work for me.
fopen() also doesn't work when used with the SDL lib, or I can't make it to work...
My research so far:
I've been able to load a file when using gsKit with
fopen() and using relative paths :
"polly.jpg" and not "mass:polly.jpg"
But loading a file with gsKit functions like:
gsKit_texture_png(gsGlobal, &Tex1, "test.png");
doesn't work for me.
fopen() also doesn't work when used with the SDL lib, or I can't make it to work...
softwares for artists on video game systems - http://www.pikilipita.com
I would suggest to use a newer loader, which loads newer modules. Some old modules have problems. A better way is to reset the IOP and load the correct modules.
Earlier I detected, that it it is sometimes not possible to load fonts into gsKit, because the size reported by fread() was too small. I removed the check in gsKit and then it was working.
Earlier I detected, that it it is sometimes not possible to load fonts into gsKit, because the size reported by fread() was too small. I removed the check in gsKit and then it was working.