Hi gameblabla!!
Thanks for posting here at dcemulation.org, and also sorry to answer this topic so late (I was quite busy these days! U_U).
Well, I've just test your port on REAL HARDWARE and hey, looks nice!! I like it, good job!

Now, let me state some points to work on it
* First of all, you use the serial port to read/write into the SD. That's nice, but unfortunately, this also makes emulators stop from getting your game working

. Yep, they're still primitive in that aspect, go blame on them ^^.
* To load/save into VMU with KOS is quite easy, and you can even use ZLIB compression to do it!!
Let me put here some code and explain it:
Code: Select all
#include <kos.h>
#include <zlib/zlib.h> //vmu compression!
#include "dreamcast_icon.h"
int DC_LoadVMU(void) {
unsigned long unzipsize;
uint8* unzipdata;
vmu_pkg_t pkg;
// Name of the file to open
file_t fd;
if ((fd = fs_open("/vmu/a1/fallingtime", O_RDONLY)) == -1)
{
printf("error opening VMU A1, not found.\n");
return -1;
}
// Remove VMU header
vmu_pkg_parse(fs_mmap(fd), &pkg);
// Allocate memory for the uncompressed data
unzipdata = (uint8 *)malloc(524288); //512KB
unzipsize = 524288;
uncompress(unzipdata, &unzipsize, (uint8 *)pkg.data, pkg.data_len);
// Save buffer into a RAM file
fs_close(fd);
file_t fd2;
if ((fd2 = fs_open(/ram/yourfile.dat, O_WRONLY)) == -1)
{
printf("Can't create RAM file from VMU.\n");
return -1;
}
fs_write(fd2, unzipdata, unzipsize);
fs_close(fd2);
// Free unused memory
free(unzipdata);
return 0;
}
int DC_SaveVMU(void) {
vmu_pkg_t pkg;
uint8 *pkg_out;
int pkg_size;
file_t ft;
// Temporal for reading the file
file_t file;
int data_size;
unsigned long zipsize = 0;
uint8 *datasave;
uint8 *zipdata;
// Open file and copy to buffer
file = fs_open(/ram/yourfile.dat, O_RDONLY);
data_size = fs_total(file);
datasave = (uint8 *)malloc(data_size+1);
fs_read(file, datasave, data_size);
fs_close(file);
// Allocate some memory for compression
zipsize = data_size * 2;
zipdata = (uint8*)malloc(zipsize);
// The compressed save
compress(zipdata, &zipsize, datasave, data_size);
// Make the package to the VMU.
strcpy(pkg.desc_short, "fallingtime");
strcpy(pkg.desc_long, "Falling Time");
strcpy(pkg.app_id, "fallingtime");
pkg.icon_cnt = 1;
memcpy((void *)&pkg.icon_pal[0],(void *)&vmu_savestate_pal,32);
pkg.icon_data = (const uint8*)&vmu_savestate_data;
pkg.icon_anim_speed = 0;
pkg.eyecatch_type = VMUPKG_EC_NONE;
pkg.data_len = zipsize;
pkg.data = zipdata;
vmu_pkg_build(&pkg, &pkg_out, &pkg_size);
// Write at A1 port
fs_unlink("/vmu/a1/fallingtime");
ft = fs_open("/vmu/a1/fallingtime", O_WRONLY);
if (!ft) {
return -1;
}
fs_write(ft, pkg_out, pkg_size);
fs_close(ft);
// Free unused memory
free(pkg_out);
free(datasave);
free(zipdata);
return 0;
}
- DC_LoadVMU(void) will try to read from the VMU (port A1), the file "fallingtime". If success, then it will uncompress into Dreamcast RAM (/ram/yourfile.dat) using zlib.
- DC_SaveVMU(void) does the other way: read from "/ram/yourfile.dat", compress with zlib, and generates the VMU file to store (/vmu/a1/fallingtime).
- Don't worry, this works perfectly with all the emus!! Remember, a full VMU has 200 blocks, or 128kb of storage. Oh, and you have to link with -lz
- vmu_savestate_pal and vmu_savestate_data are variables where they contain the info for the VMU icon in the Dreamcast menu. If you want to follow the quick way, I have a conversor from PNG to C. Limitations are that image must be of 32x32, PNG and 16 colors.
http://vmu.sega-dc.de/vmu/vmuimage.php
The image will add 1 extra block space into your save.
* Next, I saw that there is a WAV file that is not recognized as a RIFF file by KOS, so it sounds very badly on Dreamcast!!! Please, could you detect it and replace it?
* My max score is about 80.... is that a bit lame?
Anyway, excellent work! When you change the SD option for VMU, and fix the WAV issue, then I'll publish on Dreamcast.es
I've done lots of homebrew ports into Dreamcast for a long time (ie. SQRXZ ones for Dreamcast), so I'll be glad to help you in any aspect you want! Contact me via MP for more assistance
PD: I have a Sopwith port ready but.... I want to add network features into it! That one can be erased from your TODO list xD