400 block VMU on emulator

Place for discussing homebrew games, development, new releases and emulation.

Moderators: pcwzrd13, deluxux, VasiliyRS

TapamN
letterbomb
Posts: 149
Joined: Sun Jan 10, 2021 10:52 pm

Re: 400 block VMU on emulator

Post by TapamN »

Falco Girgis wrote:Oh, apparently TampamN is still active? I had heard somewhere he was no longer active within the scene...
I still do stuff, just stopped doing much on Gens4All, and haven't released anything recently. Mostly slowly working on my game/game engine with most time going to getting the model converter and collision detection. I've also spent time on the beginnings of a AICA library, a video signal setting library, and a VMU display library (it does graphics, text, and menus; I wanted to hook the DC up to an oscilloscope to verify the video signal library and be able to use the VMU to adjust the settings). I did do a small experiment on Gens4All to speed up the sound emulation at the cost of some accuracy (might be worth it for a higher sample rate or better rasters), but it was crashing randomly for some reason that I haven't completely figured out.
Falco Girgis wrote:I was wondering which fields exactly you were setting to which values to get as far as you got?
The settings I used where calculated like this:

There's a single root block which is always at the top of the VMU.

The FAT is right below the root block, and is 2 bytes per unformatted block, or 1 block per 128 KB of unformatted space.

The directory is below the FAT, and should be at least 32 bytes per user accessible block (i.e. divide the user accessible VMU space in blocks by 16 to get the dir size in blocks). If it doesn't divide evenly into the block size, round up. (So on a 200 block VMU, it's 200/16=12.5 -> roundup -> 13 blocks for dir)

The wear level area is between the regular storage area and the directory, and its size is whatever space is left.

I wanted to see if there was anyway to find out the official sizes of the different parts of the VMU file system. After tracing some code in the US version of Sonic Adventure 2, I think I found something. In SA2's 1ST_READ.BIN, at 0xf0338, there appears to be a small array of four longs containing the expected size of the FAT for 128KB, 256KB, 512KB, and 1024KB VMUs and afterwards four more longs containing the expected size of the directory. I don't think there's anything about the size of the wear level area.

The FAT sizes are all the expected values (1, 2, 4, and 8), and the directory size of the 128KB VMU is the known value (13 blocks), but the size for 256KB, 512KB, and 1024KB VMUs are larger than expected, being 30, 60, and 113 blocks large, which suggest there are 480, 960, or 1808 (probably 1800 rounded up) blocks available to the user.

For the 256/512 KB VMUs, I think someone at Sega just miscalculated the directory sizes, and there was never any intention for 480 or 960 block VMUs. If you actually tried to get 480 user accessible blocks on a 256KB flash, you'd run out of space even if you assumed no wear leveling. You have 480 user blocks + 30 dir blocks + 2 FAT blocks + 1 root block = 513 blocks, or 256.5 KB. I think actual space available is be something less, like 400 and 800. The directory is probably just larger than it needs to be and some blocks that could be used for wear leveling get wasted.

It's a bit more plausible that Sega might have intended to create a 1800 block VMU instead of 1600 block, since there's still room for 126 blocks of wear level space after adding everything together.

I really don't think VMU's larger than 128KB are worth it considering how poor they're supported. They can be fun to play around with, but not something to seriously use.

I would guess that the corruption problems with large VMUs could be cause by a buffer overflow. There might be some preallocated buffer to cache the directory area and FAT, and using larger VMUs could overflow this. It seems like there's an attempt to prevent this, since many games reject large VMUs, but maybe some games use the VMU library incorrectly?
SWAT
Developer
Posts: 23
Joined: Sun May 24, 2009 2:48 am

Re: 400 block VMU on emulator

Post by SWAT »

I noticed this post late, maybe it would have helped me. But nevertheless, I implemented support for VMU with 1MB or 1800 blocks (btw, I thought so too) and it works with the same success as yours, but on real hardware with VMU emulation by DreamShell ISO loader:
https://www.youtube.com/watch?v=p9M9Ojz1i-A

After some tests, it seems to me that there is a chance to make some more games work with this, but this is not certain. And I won’t be doing this in nearest next versions. For now it's just an option for being able to virtually touch a device that never existed.
NeoSnk
Outtrigger
Posts: 448
Joined: Wed May 10, 2017 9:09 am
Dreamcast Games you play Online: Phantasy Star Online, Quake 3, Monaco Grand Prix, Planet Ring, Alien front online
Contact:

Re: 400 block VMU on emulator

Post by NeoSnk »

Wow I'd love to test it with Dreamstudio, it would benefits a lot with more space!
For tutorials and homebrews access Titan Game Studios: https://titangamestudioscom.wordpress.com/
For interviews and gameplay support me on YouTube:
https://www.youtube.com/@NaiAdventure/featured
SWAT
Developer
Posts: 23
Joined: Sun May 24, 2009 2:48 am

Re: 400 block VMU on emulator

Post by SWAT »

NeoSnk wrote:Wow I'd love to test it with Dreamstudio, it would benefits a lot with more space!
Good case btw. I'll made test build with this functionality soon. But chance 50/50.
NeoSnk
Outtrigger
Posts: 448
Joined: Wed May 10, 2017 9:09 am
Dreamcast Games you play Online: Phantasy Star Online, Quake 3, Monaco Grand Prix, Planet Ring, Alien front online
Contact:

Re: 400 block VMU on emulator

Post by NeoSnk »

SWAT wrote:
NeoSnk wrote:Wow I'd love to test it with Dreamstudio, it would benefits a lot with more space!
Good case btw. I'll made test build with this functionality soon. But chance 50/50.
I hope it works, we could create bigger games :D
For tutorials and homebrews access Titan Game Studios: https://titangamestudioscom.wordpress.com/
For interviews and gameplay support me on YouTube:
https://www.youtube.com/@NaiAdventure/featured
SWAT
Developer
Posts: 23
Joined: Sun May 24, 2009 2:48 am

Re: 400 block VMU on emulator

Post by SWAT »

NeoSnk wrote:
SWAT wrote:
NeoSnk wrote:Wow I'd love to test it with Dreamstudio, it would benefits a lot with more space!
Good case btw. I'll made test build with this functionality soon. But chance 50/50.
I hope it works, we could create bigger games :D
Try: https://github.com/DC-SWAT/DreamShell/r ... 0.0RC5-T36

Edit: I forgot a few small ISO images in this build, sorry about that, I re-uploaded it.
TapamN
letterbomb
Posts: 149
Joined: Sun Jan 10, 2021 10:52 pm

Re: 400 block VMU on emulator

Post by TapamN »

SWAT wrote:I noticed this post late, maybe it would have helped me. But nevertheless, I implemented support for VMU with 1MB or 1800 blocks (btw, I thought so too) and it works with the same success as yours, but on real hardware with VMU emulation by DreamShell ISO loader:
https://www.youtube.com/watch?v=p9M9Ojz1i-A

After some tests, it seems to me that there is a chance to make some more games work with this, but this is not certain. And I won’t be doing this in nearest next versions. For now it's just an option for being able to virtually touch a device that never existed.
How does this work? Does it find and patch the Maple library code or does it use the breakpoint controller to detect Maple access? For the VGA patches, I've been looking into doing something to automatically create the patches by looking for Sega's video library code, so I wonder if you're doing something similar.

I did some Ghidra on Shenmue a while ago (mainly looking to improve textures, and make some gameplay adjustments, like speeding up the clock to make it easier to see stuff like Christmas and New Years changes), and I found the save/load code. It looked to me like it might be possible to shim the high level save access (on the file level, not flash block level) and redirect the save files to a DCI file on an SD card, to provide an "infinite" single page VMU that still looks like a 200 block VMU to the game code.
Withintoluca
rebel
Posts: 20
Joined: Mon Apr 24, 2023 4:29 am
Dreamcast Games you play Online: I don’t play online.

Re: 400 block VMU on emulator

Post by Withintoluca »

From my understanding the create a player feature is limited by your VMA storage , so in theory if we used emulator with 1gb we should be able to do a complete roster league updated ?
User avatar
megavolt85
Developer
Posts: 1862
Joined: Wed Jan 31, 2018 4:14 pm

Re: 400 block VMU on emulator

Post by megavolt85 »

TapamN wrote:How does this work?
DreamShell intercepts interrupts and rewrites responses from the VMU and controller.
The size of 1800 blocks is the maximum, the data is obtained from the leaked source code of the KATANA SDK, unfortunately very few games support VMUs of this size
SWAT
Developer
Posts: 23
Joined: Sun May 24, 2009 2:48 am

Re: 400 block VMU on emulator

Post by SWAT »

TapamN wrote:
SWAT wrote:I noticed this post late, maybe it would have helped me. But nevertheless, I implemented support for VMU with 1MB or 1800 blocks (btw, I thought so too) and it works with the same success as yours, but on real hardware with VMU emulation by DreamShell ISO loader:
https://www.youtube.com/watch?v=p9M9Ojz1i-A

After some tests, it seems to me that there is a chance to make some more games work with this, but this is not certain. And I won’t be doing this in nearest next versions. For now it's just an option for being able to virtually touch a device that never existed.
How does this work? Does it find and patch the Maple library code or does it use the breakpoint controller to detect Maple access? For the VGA patches, I've been looking into doing something to automatically create the patches by looking for Sega's video library code, so I wonder if you're doing something similar.

I did some Ghidra on Shenmue a while ago (mainly looking to improve textures, and make some gameplay adjustments, like speeding up the clock to make it easier to see stuff like Christmas and New Years changes), and I found the save/load code. It looked to me like it might be possible to shim the high level save access (on the file level, not flash block level) and redirect the save files to a DCI file on an SD card, to provide an "infinite" single page VMU that still looks like a 200 block VMU to the game code.
Maple interrupts are hooked and data coming from the bus is replaced. This is a full-fledged emulation; using the same principle, you can make a real device with the same capabilities.
What you are talking about is, of course, completely different, but yes, in this way it would be possible to store saves in general simply in a directory on SD/IDE, and not in a dump.
But I was interested in checking how games would work with this. And obviously not everyone uses SDK directly or there are different versions, since not all games support this, although there is support in SDK, the code of which appeared on the Internet.
Post Reply