Voir la version compl鋈e : [無ibrary][Aide] Using uLibrary&PALib at the same screen
theNinjaBunny
26/03/2007, 17h22
Hi, is there a posibilty to use uLibrary to load PNG/JPG/GIF as backgrounds and PALib for Sprites?(i think not)
Is there something like "dual sprites" from PALib in uLibrary? I mean, my game is using both screen, i'm using DualSprites (which saves you a lot of time coding a sprite system yo use them in both screen) But i reached the 4Mb limit of ROM size, so my idea is to load external PNG/GIF/JPEGs to act as background but without coding so much (yeah, i'm so lazy):lol:
You can use gif and jpegs in PAlib directly, too ^^
I think when you loading ulib it overrides the sprites, not the backgrounds, but maybe you can select, we'll need brunni ^^
theNinjaBunny
26/03/2007, 21h12
You can use gif and jpegs in PAlib directly, too ^^
No, I can't. I could use PAFS to load "external" GIF, but PAFS means some incompatibilities and ... patch the rom each time i compile and wanna test it!
Using uLib I'm able to load "real external" data and overcome the 4Mb limit (that's THE reason of loading externally)
No, I can't.
You can load "real external" gif/jpg with PALib...
theNinjaBunny
26/03/2007, 21h51
how?
Exactly the same way you would use it with pafs or built-in gfx:
For a background:
1) alloc a memory space for the file
2) load the file
3) use "void PA_LoadGif (u8 screen, void *gif)" (*gif points to the space you alloced before)
4) free the space 1)
For a sprite:
1) alloc a memory space for the file
2) alloc memory for the palette
3) load the file
4) use "use u8 * PA_GifToTiles (void *gif, u16 *temppal)"
5) free the space 1)
then use your sprite as usual with PA_CreateSprite()...
No you can't do anything with the screen affected to 無ibrary, PALib will CRASH directly if it ever tries to access the same screen as 無ibrary :(
I don't know what is the problem, but I've not investigated much for now in fact v_v
PALib includes functions to load from other types of file sources, but sometimes it's not as easy. If you don't find a way to do it simply with PALib, you could do something like this:
UL_IMAGE *loadSomething(const char *fileName, int fileSize) {
VIRTUAL_FILE *f;
void *data;
int source = ulGetLoadUtilitySource();
int success = 0;
//Open the file
f = VirtualFileOpen((void*)fileName, fileSize, source, VF_O_READ);
//Check if the file could be opened
if (f) {
//Load our file entirely to RAM and get a pointer to it
data = ulReadEntireFileToMemory(f, NULL);
//The file is entirely loaded, so we don't need it anymore
VirtualFileClose(f);
//Now the pointer "data" contains a pointer to a RAM memory area containing the loaded file data, you can pass it to some PA function that would normally load from RAM
PA_DoSomething(data);
//Don't forget to free the memory block after you've finished with it!
free(data);
success = 1;
}
return success;
}
However, beware, this will load your file to RAM entirely, needing a lot of temporary RAM space! If RAM is nearly full, necessary space may not be available and this loading routine will fail :(
Usual 無ibrary functions use streaming (no need to load the file entirely, but only the needed parts), and I guess PALib does as well, so use this routine only if you know what you are doing ;)
vBulletin® v.3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd. Tous droits r廥erv廥 - Version fran蓷ise vbulletin-fr.org