load sprites from filesystem
load sprites from filesystem
Hi,
i managed to load some informations from the filesystem. Now i'm trying to load some sprites from it.
Is there a tutorial or something like this?
Thanks, vralfy
i managed to load some informations from the filesystem. Now i'm trying to load some sprites from it.
Is there a tutorial or something like this?
Thanks, vralfy
Re: load sprites from filesystem
I got the same problem... some one pls help us...
Re: load sprites from filesystem
There's a set of functions being written for this exact issue, if you check the IRC channel one of the guys in there will be able to help you out.
There are a few improvements coming in the next release, but if you need some bleeding edge updates you should check the IRC channel.
There are a few improvements coming in the next release, but if you need some bleeding edge updates you should check the IRC channel.
Re: load sprites from filesystem
I haven't use IRC for years.. btw, what is the channel number?
Re: load sprites from filesystem
It's 4 am here, I'm a bit sleepy. After overnight work, this is my function to load binary file from nitrofs, like tiles, map, and palette... Feel free to use it...
here is the full example -> http://www.mediafire.com/?rn2tdni3k1u
time to sleep...
Code: Select all
void loadBinary(u16* memAddress,char *filename)
{
FILE *pFile=fopen (filename,"rb");
if (pFile!=NULL)
{
//file size
fseek (pFile, 0 , SEEK_END);
long lSize = ftell (pFile);
u8 *buffer= (u8*) malloc (sizeof(u8)*lSize);
rewind (pFile);
if (fread (buffer,1,lSize,pFile) != lSize)
printf("error reading file\n");
//copy from buffer
dmaCopy(buffer, memAddress, lSize);
//close file and clean buffer
fclose (pFile);
free (buffer);
}
else
printf("file not exist");
}
time to sleep...
Re: load sprites from filesystem
The channel is irc://irc.blitzed.org/dsdev
and the functions for reading grt files (generated by GRIT) have been posted:
<TheLazy1> Here we go: http://www.mediafire.com/file/4kxhnjyck ... le.tar.bz2 -- flame away
and the functions for reading grt files (generated by GRIT) have been posted:
<TheLazy1> Here we go: http://www.mediafire.com/file/4kxhnjyck ... le.tar.bz2 -- flame away
Re: load sprites from filesystem
Thanks for posting these pieces of code.
I've read that the speeds of microSD varies. I'm guessing writing directly to vram might not always work depending on how much data you are moving and the speed of the card. I wonder if its possible to steam sound this way on some cards.
I've read that the speeds of microSD varies. I'm guessing writing directly to vram might not always work depending on how much data you are moving and the speed of the card. I wonder if its possible to steam sound this way on some cards.
Re: load sprites from filesystem
There is some example code on gbadev.org forums for streaming music, IIRC it's by ekid...coreyh2 wrote:Thanks for posting these pieces of code.
I've read that the speeds of microSD varies. I'm guessing writing directly to vram might not always work depending on how much data you are moving and the speed of the card. I wonder if its possible to steam sound this way on some cards.
Re: load sprites from filesystem
My function above isn't working in my real DS , it works perfectly on emulator. I use sandisk microSD + EDGE cards, and the sprite/background not fully loaded.. some one pls help me...
Or should I give delay to read each file?
EDIT:
I already solved this problem, my function above is a bit wrong, memcpy is the solution, don't use DMA... thx 4 the link above, I realized this after read GRF_LoadVRAM function...
Or should I give delay to read each file?
EDIT:
I already solved this problem, my function above is a bit wrong, memcpy is the solution, don't use DMA... thx 4 the link above, I realized this after read GRF_LoadVRAM function...
Re: load sprites from filesystem
http://www.coranac.com/2010/03/dma-vs-arm9-round-2/
This is a useful link about dma. Talks about using it correctly.
If you look at the code for oamUpdate or oamInit in libnds you'll see how its done with vram. It just involves using DC_FlushRange on main or stack memory that has been changed. There is a lot more too it when using dma to move to main memory. Tests show assembly versions of memcpy working better in those situations too. Asynchronous dma can still be useful maybe. DMA is the fastest way to to move to vram with assembly being a close second.
I've done a bit of research but I haven't done any tests myself. If you go through Cearn's blog you'll find much more detailed information.
This is a useful link about dma. Talks about using it correctly.
If you look at the code for oamUpdate or oamInit in libnds you'll see how its done with vram. It just involves using DC_FlushRange on main or stack memory that has been changed. There is a lot more too it when using dma to move to main memory. Tests show assembly versions of memcpy working better in those situations too. Asynchronous dma can still be useful maybe. DMA is the fastest way to to move to vram with assembly being a close second.
I've done a bit of research but I haven't done any tests myself. If you go through Cearn's blog you'll find much more detailed information.
Who is online
Users browsing this forum: No registered users and 1 guest