You are not logged in.

Read the FAQ and Knowledge Base before posting.
We won't make a 3DS/2DS emulator.



#1 2007-05-02 14:43:54

masscat
Member
From: UK
Registered: 2007-03-17
Posts: 73
Website

CFlash and FAT emulation

Over on the gbadev forums people were talking about DLDI/FAT support in emulators. There was mention of just using a disk image. So I thought I would give it a go (still test code and not optimised - reading 2 bytes at a time for example).

As with the current CFlash code it emulates a GBAMP. The disk image is just a normal file (hardcoded to be "/home/ben/desmume_disk.image"). The Desmume code makes no interpretation of the file contents and just reads and writes the data as requested. The code may have some linux only code in but should easily be ported to other platforms.

Here is the replacement cflash.c and a picture of a cow I drew in Phidias (running under Desmume, saved to disk image and then copied from the disk image).

Pros of this approach:
The desmume code is very simple for read and write support
The disk image does not have to be FAT

Cons of this approach:
The hassle of creating the disk image (can this be done easily under Windows?)

What do people think of this approach? Any other pros and cons? And can the disk image be constructed and used under Windows?


A quick howto to make a 128MB FAT disk image under linux:

dd if=/dev/zero of=desmume_disk.image bs=1048576 count=128
mkdosfs -F16 desmume_disk.image
(as root)
mount -o loop desmume_disk.image <mount_point>
(copy stuff to the <mount_point> directory)
umount <mount_point>

If I used FAT32 then the image would appear corrupted when used by Desmume emulated programs. Not sure if this is the way I made the image, the Desmume code for reading/writing the file or libfat not handling something that Linux does to FAT32 file systems.

If you want to be able to copy stuff to the disk image as your normal user use:

mount -o loop -t msdos -o uid=<your_user_id> desmume_disk.image <mount_point>

Offline

#2 2007-05-02 20:41:19

snkmad
Member
Registered: 2007-03-17
Posts: 141
Website

Re: CFlash and FAT emulation

This may seem totally Off-topic, but QuakeDS runs on desmume. Shash thought it wouldnt run due the FAT emulation isnt complete.
EDIT: ive tried DScent also, a Descent clone for the DS. Both games run fine, but they cant save, maybe you can test if it will save with your implementation.
Heres some screens, left one is QuakeDS, the right one is DScent:
t1869_quakeds.JPGt1879_dscent.JPG

Last edited by snkmad (2007-05-03 20:01:15)


Athlon 64 X2 3800+ / 2Gb DDR2 800Mhz
Geforce 8600GT 256MB / Windows XP PRO SP3
http://desmume.org/compatibility-list/

Offline

#3 2007-05-07 23:11:19

masscat
Member
From: UK
Registered: 2007-03-17
Posts: 73
Website

Re: CFlash and FAT emulation

QuakeDS uncovered some bugs in the Linux 3D emulation.
With them fixed, QuakeDS does run and, using the disk-image cflash, you can save (and load smile ).

There is no write support in the cflash emulation code in the CVS (hence your no save).

Offline

#4 2007-05-08 02:31:29

snkmad
Member
Registered: 2007-03-17
Posts: 141
Website

Re: CFlash and FAT emulation

Im glad i could help.
And i remember some util to create disk images on win32. It came with "qemu".
Ill take a look and report later.


Athlon 64 X2 3800+ / 2Gb DDR2 800Mhz
Geforce 8600GT 256MB / Windows XP PRO SP3
http://desmume.org/compatibility-list/

Offline

#5 2007-05-08 17:10:37

snkmad
Member
Registered: 2007-03-17
Posts: 141
Website

Re: CFlash and FAT emulation

Well the qemu disk util cant create FAT images, but the mkdosfs from bochs can.
Heres 3 FAT16 disk images, 128mb, 256mb, 512mb.
I cant test it here, i only run Windows XP.

Sorry but i had to upload to rapidshare, everything into one BIG file... 42kb wink
http://rapidshare.com/files/30205730/flash.zip.html


Athlon 64 X2 3800+ / 2Gb DDR2 800Mhz
Geforce 8600GT 256MB / Windows XP PRO SP3
http://desmume.org/compatibility-list/

Offline

#6 2007-05-08 22:40:03

masscat
Member
From: UK
Registered: 2007-03-17
Posts: 73
Website

Re: CFlash and FAT emulation

I have put together a java application to create and copy files in and out of a FAT disk image. Run it as follows:

java -jar FATimageApp.jar

I have successfully used it to create an image with the quake files and run it under Desmume (with the cflash change).
It only supports short file names and cannot delete files.
If anybody fancies porting the cflash code to Windows and seeing if it works I would be interested in the results.

snkmad:
Your FAT images are perfectly fine FAT images. The mkdosfs is probably the same code base as the linux mkdosfs.

EDIT:
The Windows port should just be replacing:

#include <sys/stat.h>
#include <fcntl.h>

with:

#include <io.h>

And if the compiler moans about open, read, write and lseek then replace those with _open, _read, _write and _lseek respectively.

EDIT: The Windows port was not quite that simple (Windows opens files in text mode by default). There is a working example in the Desmume + GDB stub thread.

Last edited by masscat (2007-05-12 21:20:45)

Offline

#7 2007-05-16 01:04:48

snkmad
Member
Registered: 2007-03-17
Posts: 141
Website

Re: CFlash and FAT emulation

Thx for the win binary.
Gonna try with quakeds and DScent.


Athlon 64 X2 3800+ / 2Gb DDR2 800Mhz
Geforce 8600GT 256MB / Windows XP PRO SP3
http://desmume.org/compatibility-list/

Offline

#8 2008-04-11 16:12:53

nicoco73
Member
Registered: 2008-04-11
Posts: 1

Re: CFlash and FAT emulation

Thank you very much for adding this "--cflash" thing!

I have a problem though : reading works fine but writing not. It seems that fopen fails to create the output file in the following piece of code  :

(...)
  case 1 : 
      fic = fopen("/sortie.h3o","w");
      if(fic != NULL)
      {
        fprintf(fic, "\ntest\n") ;
        fclose(fic) ;
      }
      else
      {
        break ;
      }
  case 2:
      return MENU ;
(...)

fopen returns NULL here. Any idea about this ? I am using DeSmume 0.7.3 under Ubuntu (Gutsy).


Nico.

Last edited by nicoco73 (2008-04-11 16:14:14)

Offline

#9 2008-05-17 18:13:49

ghee
Member
Registered: 2007-08-03
Posts: 17

Re: CFlash and FAT emulation

For those on Fedora, look for /sbin/mkfs.msdos in lieu of mkdosfs.

Offline

#10 2008-05-18 16:21:16

ghee
Member
Registered: 2007-08-03
Posts: 17

Re: CFlash and FAT emulation

Has anyone been able to create FAT disk images under OS X that work with desmume?
The lack of a mkfs suite seems to be a barrier.

Offline

#11 2008-05-18 17:04:24

jeff
Member
Registered: 2008-04-06
Posts: 47

Re: CFlash and FAT emulation

ghee, I haven't tried it personally, but newfs should be able to do it.

Offline

#12 2008-12-31 03:53:34

ghee
Member
Registered: 2007-08-03
Posts: 17

Re: CFlash and FAT emulation

Any anecdotes or otherwise on how far cflash image support has gone in the OSX flavour of desmume? I don't seem to get similar results as on Ubuntu 8.04...

Offline

Board footer

Powered by FluxBB