VMU programming in C language ?
- Orion_
- DCEmu Crazy Poster
- Posts: 31
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Fri Nov 21, 2014 3:31 pm
- Location: France
- Has thanked: 0
- Been thanked: 0
- Contact:
VMU programming in C language ?
Is there a C compiler for VMU ?
I made a small game for the PocketStation (a VMU like for the Playstation), and I would like to port the game (which is in C) to VMU.
I made a small game for the PocketStation (a VMU like for the Playstation), and I would like to port the game (which is in C) to VMU.
Retro Game Programming -> http://onorisoft.free.fr/ <-
Dreamcast, PS1, PCe, MD, Atari, Jaguar, GP32, GBA, ...
Dreamcast, PS1, PCe, MD, Atari, Jaguar, GP32, GBA, ...
- BlueCrab
- The Crabby Overlord
- Posts: 5665
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: VMU programming in C language ?
As far as I'm aware, there is no C compiler for the VMU. There's at least one assembler for it (along with various documentation), but that's all I'm aware of in regard to development stuff that's publicly available for it.
Re: VMU programming in C language ?
VMU is a Sanyo LC8670 (8-bit CPU). To code in C for that target you must find a GCC version for that hardware.
- BlueCrab
- The Crabby Overlord
- Posts: 5665
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: VMU programming in C language ?
I'm reasonably sure that GCC doesn't support that target. You'd be much more likely to be able to port something like like the C compiler that's out there for Z80/6502/etc to it than to see a proper GCC port.
- mankrip
- DCEmu Ex-Mod
- Posts: 3712
- Joined: Sun Nov 04, 2001 5:12 pm
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: VMU programming in C language ?
VMU games runs on a Potato.ParabolaWiki wrote:Sega VMU (Sanyo LC86K87 - custom Sanyo LC8670 "Potato", similar to LC86104C/108C - 8bit)
- Orion_
- DCEmu Crazy Poster
- Posts: 31
- Joined: Fri Nov 21, 2014 3:31 pm
- Location: France
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: VMU programming in C language ?
Well, I guess I'm going to learn another assembler then ...
Is there a way to write your game (.vms file) on the VMU using the Dreamcast / KallistiOS ?
I tried to write the VMS file raw on the VMU, but it's not recognized as a game by the VMU.
Is there a way to write your game (.vms file) on the VMU using the Dreamcast / KallistiOS ?
I tried to write the VMS file raw on the VMU, but it's not recognized as a game by the VMU.
Retro Game Programming -> http://onorisoft.free.fr/ <-
Dreamcast, PS1, PCe, MD, Atari, Jaguar, GP32, GBA, ...
Dreamcast, PS1, PCe, MD, Atari, Jaguar, GP32, GBA, ...
- BlueCrab
- The Crabby Overlord
- Posts: 5665
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: VMU programming in C language ?
To write VMU games to the card, you have to use the lower-level vmufs rather than just writing through the normal VMFS functions. You should only have to mess with one vmufs function to do it, though, specifically you'll need to call the vmufs_write() function, making sure to specify VMUFS_VMUGAME as part of the flags for that function.
- Orion_
- DCEmu Crazy Poster
- Posts: 31
- Joined: Fri Nov 21, 2014 3:31 pm
- Location: France
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: VMU programming in C language ?
I tried this function with the correct flag, but the VMU tells me the game is damaged.
I tried to run DreamExplorer to check the data using the hex editor, and the data seems the same than the original file.
Then I used the "defrag" option, and then the game was playable.
So I guess, the data was fine, but something in header or root/fat was wrong, and DreamExplorer fixed it.
I tried the "tetris.vms" game, loaded it in "data" pointer, and used this call:
maple_device_t *dev = maple_enum_type(0, MAPLE_FUNC_MEMCARD);
if (dev)
vmufs_write(dev, "tetris", data, size, VMUFS_VMUGAME);
I tried to run DreamExplorer to check the data using the hex editor, and the data seems the same than the original file.
Then I used the "defrag" option, and then the game was playable.
So I guess, the data was fine, but something in header or root/fat was wrong, and DreamExplorer fixed it.
I tried the "tetris.vms" game, loaded it in "data" pointer, and used this call:
maple_device_t *dev = maple_enum_type(0, MAPLE_FUNC_MEMCARD);
if (dev)
vmufs_write(dev, "tetris", data, size, VMUFS_VMUGAME);
Retro Game Programming -> http://onorisoft.free.fr/ <-
Dreamcast, PS1, PCe, MD, Atari, Jaguar, GP32, GBA, ...
Dreamcast, PS1, PCe, MD, Atari, Jaguar, GP32, GBA, ...
- BlueCrab
- The Crabby Overlord
- Posts: 5665
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
Re: VMU programming in C language ?
I think VMU games have to be at a specific address on the card, and if something else is already there, then it has be moved around to make the space. That'd make sense then that defragging the card would fix it.
In theory, I should probably make KOS do that as well, if there's not already a function for it (I'm not sure whether there is or not, as I've never looked, to be honest).
In theory, I should probably make KOS do that as well, if there's not already a function for it (I'm not sure whether there is or not, as I've never looked, to be honest).
- Orion_
- DCEmu Crazy Poster
- Posts: 31
- Joined: Fri Nov 21, 2014 3:31 pm
- Location: France
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: VMU programming in C language ?
The problem with KOS is that, it can do a lots of things, but there is not much example on how to use all theses features (ex: vmu games, purupuru)
Retro Game Programming -> http://onorisoft.free.fr/ <-
Dreamcast, PS1, PCe, MD, Atari, Jaguar, GP32, GBA, ...
Dreamcast, PS1, PCe, MD, Atari, Jaguar, GP32, GBA, ...
- Orion_
- DCEmu Crazy Poster
- Posts: 31
- Joined: Fri Nov 21, 2014 3:31 pm
- Location: France
- Has thanked: 0
- Been thanked: 0
- Contact:
Re: VMU programming in C language ?
I read from here: http://mc.pp.se/dc/vms/flashmem.html
I can't find a simple way to do it properly unless rewriting all the VMU file processing, which I don't want to do...
So, a mini game must be written from block 0, and if KOS function doesn't handle this (but handle it as a normal save file), it won't work.Note that mini-game files are allocated starting at block 0 and upwards, while a data file is allocated starting at block 199 selecting the highest available free block. This is probably because a mini-game should be able to run directly from the flash, and thus needs to be placed in a linear memory space starting at a known address (i.e. 0).
I can't find a simple way to do it properly unless rewriting all the VMU file processing, which I don't want to do...
Retro Game Programming -> http://onorisoft.free.fr/ <-
Dreamcast, PS1, PCe, MD, Atari, Jaguar, GP32, GBA, ...
Dreamcast, PS1, PCe, MD, Atari, Jaguar, GP32, GBA, ...
- LightDark
- DCEmu Fast Newbie
- Posts: 18
- Joined: Sat Mar 09, 2013 4:39 pm
- Has thanked: 0
- Been thanked: 1 time
Re: VMU programming in C language ?
After spending many hours googling, pouring over vmufs code and comparing hexdumps of my VMU between the KOS vmufs_write output and the subsequently defragmented working DreamExplorer version I think I have determined the culprit of why vmufs_write causes the "game is damaged" error when trying to play minigames uploaded to the VMU via vmufs_write:
In kos/kernel/arch/dreamcast/fs/vmufs.c:
When nd.hdroff is set to 1 the VMU is able to run the game just fine, when it is set to 0 as it currently is in vmufs.c (line: 750) it appears to read in garbage for the header and cause it to not function properly.
This appears to have solved it:
Hopefully this helps anyone trying to upload VMU games through KOS.
In kos/kernel/arch/dreamcast/fs/vmufs.c:
Code: Select all
int vmufs_write(maple_device_t * dev, const char * fn, void * inbuf, int insize, int flags){
...
/* Fill out a new dirent for this file */
memset(&nd, 0, sizeof(nd));
nd.filetype = (flags & VMUFS_VMUGAME) ? 0xcc : 0x33;
nd.copyprotect = (flags & VMUFS_NOCOPY) ? 0xff : 0x00;
nd.firstblk = 0;
strncpy(nd.filename, fn, 12);
vmufs_dir_fill_time(&nd);
nd.filesize = insize / 512;
nd.hdroff = 0; // <------ this is the cause!
nd.dirty = 1;
...
}
This appears to have solved it:
Code: Select all
nd.hdroff = 1;