Author Topic: FAT drivers for multi card + MK2/3 SD/MMC access  (Read 30572 times)

0 Members and 2 Guests are viewing this topic.

Offline genfish

  • Newbie
  • *
  • Posts: 15
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #15 on: February 27, 2006, 03:31:16 AM »
so can this be used from within my code to load textures into memory? if so, how do you create the file system on the flash cart?

Offline 68HC11

  • Newbie
  • *
  • Posts: 8
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #16 on: February 27, 2006, 03:50:47 AM »
so can this be used from within my code to load textures into memory? if so, how do you create the file system on the flash cart?

I don't know about creating the FS on the Flashcart yet (on the To-Do list), but yeah, if you have a filesystem whether it be on a Flashcart or an SD card, it can be used to load textures into memory.  The next question will be what format would you like to support?  PCX is notoriously easy to implement but not an incredible compression format, nor does it natively have alpha support.  (Though you could decide to rig something.)  PNG is a great patent-free format with multiple bit depths and alpha support but has a lot more overhead to support it properly.

Offline genfish

  • Newbie
  • *
  • Posts: 15
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #17 on: February 28, 2006, 12:53:06 AM »
i tend to use TGA files, and in 16bit mode the extra bit could be used as an alpha channel :)

Offline cory1492

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1443
    • Cory1492's NDS + PSP corner
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #18 on: February 28, 2006, 05:32:09 AM »
Chishms FAT 'driver' works alot like the file io commands in stdio, where you can use files as streams based on their name and path on the media. No real need to pack things into a file system on a disk which already uses a FAT file system. Similar functionality to fopen, fclose, fread, fwrite along with some read ahead buffering that I have not looked into yet for the MK2/3's.

For a very complex example of how to use the FAT driver in different methods look to moonshell's source (http://mdxonline.dyndns.org/archives/nds/).
Those who have come here to hate should leave now, for in their hatred they only betray themselves.
translated from The Book of Life (Src: Sword of Truth - Phantom by Terry Goodkind)

Offline 68HC11

  • Newbie
  • *
  • Posts: 8
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #19 on: February 28, 2006, 10:18:45 PM »
No real need to pack things into a file system on a disk which already uses a FAT file system.

Well, there's no real absolute requirement for compression per se, but it still doesn't have infinite space.  Of course, it all depends on the size of your project.  A pong game probably doesn't care if it uses all RAW graphics files.

Offline cory1492

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1443
    • Cory1492's NDS + PSP corner
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #20 on: March 01, 2006, 10:49:23 PM »
Too true ;)

I can say that zlib does compile on the DS (an example can be found in my etool source) and can handle streams, so gz or zip or some self made format could be adapted. Probably would speed things up if the files were zipped on an MM card (it likely takes longer to read the file than to read a small file and unzip it) provided it is done with a stream wrather than allocating chunks of memory like I did with Etools.
Those who have come here to hate should leave now, for in their hatred they only betray themselves.
translated from The Book of Life (Src: Sword of Truth - Phantom by Terry Goodkind)

Offline TheMikaus

  • Newbie
  • *
  • Posts: 26
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #21 on: May 13, 2006, 03:21:13 PM »
I was wondering if you could help me.

I have FAT_InitFiles() called (which returns true)

but when I call FAT_fopen("/MARIOLUI.gba","w")
the FAT_fopen function returns NULL.

Any ideas?

Offline d-loader

  • Sr. Member
  • ****
  • Posts: 359
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #22 on: May 13, 2006, 07:47:11 PM »
itsn't it suppost to be:

FAT_fopen("/MARIOLUI.gba","r") ?.. deppends on what you want to do  ::sm-11.gif::

Offline TheMikaus

  • Newbie
  • *
  • Posts: 26
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #23 on: May 13, 2006, 10:12:27 PM »
I'm opening it for write.

Offline d-loader

  • Sr. Member
  • ****
  • Posts: 359
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #24 on: May 14, 2006, 01:00:43 AM »
oh, sorry

anyway, which version of the FAT_libs are you using? .. SATA's ?.. cause Ive had problems with those  ::sm-04::

Offline TheMikaus

  • Newbie
  • *
  • Posts: 26
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #25 on: May 14, 2006, 12:15:17 PM »
I used the one on Chism's site.  It says it supports mk3

Offline cory1492

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1443
    • Cory1492's NDS + PSP corner
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #26 on: May 17, 2006, 12:32:56 PM »
Are you booting it through the MK menu or some other way? I have had problems using the FAT lib on some revisions of the MK3 menu.
Those who have come here to hate should leave now, for in their hatred they only betray themselves.
translated from The Book of Life (Src: Sword of Truth - Phantom by Terry Goodkind)

Offline TheMikaus

  • Newbie
  • *
  • Posts: 26
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #27 on: May 17, 2006, 12:42:33 PM »
mk3 menu.

Offline cory1492

  • Neo MOD
  • Hero Member
  • *
  • Posts: 1443
    • Cory1492's NDS + PSP corner
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #28 on: May 17, 2006, 02:00:11 PM »
Which revision?

First, do pwd (change it to the root dir)
then FAT_fopen("MARIOLUI.gba","r");
Not sure how well fopen supports paths (/)
Those who have come here to hate should leave now, for in their hatred they only betray themselves.
translated from The Book of Life (Src: Sword of Truth - Phantom by Terry Goodkind)

Offline TheMikaus

  • Newbie
  • *
  • Posts: 26
Re: FAT drivers for multi card + MK2/3 SD/MMC access
« Reply #29 on: May 19, 2006, 01:26:14 PM »
I got it to work.  I did the chdir and removed the / from the .gba thing.  It didn't seem to help actually.

I was modifying the WAIT_CR flag after I called the init call to the card and for some reason that seemed to mess it up in my case (might have actually been other things though)

Anyway.  Attached is the program I was working on and it's source.  You'll need the fat library to compile and an mk3 (maybe an mk2, not sure) to use it.

Basically it copies the cartridge in the gba slot to a file on the sdcard.  No checking is really done.  Press A to display the last read character, press b to end the loop.

A couple of problems I have is an unknown end condition.  I couldn't find specs that stated the size of the cart so basically I just count the number of zeros that I've read in at the beginning of each 512 block and if I read 1000 straight zeros then I stop processing.  (so it is possible that it'll stop dumping a game before it's done if the game happens to have a zero at every 512th byte)