400 block VMU on emulator

Place for discussing homebrew games, development, new releases and emulation.
User avatar
Falco Girgis
Developer
Posts: 145

Re: 400 block VMU on emulator

Post by Falco Girgis »

TapamN wrote: Tue Oct 22, 2024 10:25 pm
Falco Girgis wrote: Tue Oct 22, 2024 2:56 pm I'm pretty familiar with the VMU BIOS (we have a community-driven reverse engineered disassembly of it on GH), and the Maple stack logic in its FW responsible responding to a Get_Media_Info request should simply be sourcing its media information from the values stored in its root block directly, which should just be part of its flashrom image...
Huh, that's not at all what I would expect. I would have thought that Get_Media_Info would return fixed values so the card could be properly reformatted in case it gets corrupted. If you wanted the information from the root block, you could just read it with a flash read request.

I decided to look at a disassembly of the American VMU BIOS (Dmitry's 1.005 dump) to see what GMI does.

I found the code responsible responding to a request, a switch table on the maple command code located at 0xE6F, which eventually jumps to the Get_Media_Info handler (0x9BB).

It looks like it checks if the first 16 bytes of the root block contain 0x55 (the loop that does this is at 0x9E3), and if they are, it returns the data in flash. The first eight bytes returned are hard coded, from 0xB59 (right after the license strings), then two bytes from flash 0x1FE46, then a hardcoded 0x00 and 0xFF, then sixteen bytes from flash address 0x1FE48.

If the first 16 bytes of the root block aren't 0x55, it jumps to 0xA38, which returns 28 bytes of fixed values from ROM (from 0xB59).

For your page with VMU variables, I figured out some more.

0x20 contains is the maple address of the VMU, and 0x21 is the maple address of the DC? Maybe I have them backwards?
0x22 also has to do with a maple address
0x23 related to p7, masked by 0xc
0x24 is current command.
0x27 is some kind of error bitmask?
0x29 stores what subdevice the current command is for (0x02 for VMU, 0x04 for LCD, 0x08 for clock)
Well holy shit, you went deeper than I've gone... :shock:

Will update my VMU docs with this information. Thank you!!!! :mrgreen:

User avatar
Falco Girgis
Developer
Posts: 145

Re: 400 block VMU on emulator

Post by Falco Girgis »

MoeFoh wrote: Wed Oct 23, 2024 11:06 am Do we know for certainty what the heck those 40 extra block were intended for by Sega? I've always wondered about that.
Yes, we do. They are supposed to be "spare" blocks for when main flash blocks slowly start to go out due to usage...

HOWEVER. Were these blocks actually ever used in such a manner? I have no idea tbh. I've never actually encountered a VMU in the wild with a FAT block marked as "BAD" (forgot exact value, it's in my docs), and a smaller SAVE/EXTRA/RESERVED area for those block(s). I dunno if it ever actually got implemented like that in the Sega libs, but it was the intention for Maple to work in such a manner.

User avatar
Falco Girgis
Developer
Posts: 145

Re: 400 block VMU on emulator

Post by Falco Girgis »

megavolt85 wrote: Wed Oct 23, 2024 5:30 am
TapamN wrote: Tue Oct 22, 2024 10:25 pm If the first 16 bytes of the root block aren't 0x55, it jumps to 0xA38, which returns 28 bytes of fixed values from ROM (from 0xB59).
cool, I did the same in the SMPK2DC project, I didn't even know that the original works on the same principle :)
Very cool, btw, wasn't sure exactly what you were doing... Sounds like you're being good and compliant. :lol:

  • Similar Topics
    Replies
    Views
    Last post