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.
]]>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.
]]>Sorry but i had to upload to rapidshare, everything into one BIG file... 42kb
http://rapidshare.com/files/30205730/flash.zip.html
There is no write support in the cflash emulation code in the CVS (hence your no save).
]]>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>