Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Mega SD MD+ patches? #297

Closed
EvilJagaGenius opened this issue Dec 16, 2019 · 33 comments
Closed

Support for Mega SD MD+ patches? #297

EvilJagaGenius opened this issue Dec 16, 2019 · 33 comments

Comments

@EvilJagaGenius
Copy link

(I'm using Genesis Plus GX through BizHawk)

Are there any plans to support Genesis games with enhanced audio patches, specifically the MD+ games that Terraonion's MegaSD cartridge supports? I noticed that the Pier Solar audio CD was supported and was wondering if this would be in the realm of possibility as well.

I did give it a shot with Strider with the download in this thread, but didn't have any luck getting music to play.

@ekeeke
Copy link
Owner

ekeeke commented Dec 16, 2019

Yes, it requires emulation of Mega SD specific mapper to detect and handle CD-DA play commands sent by the (patched) MD+ games.

I actually have already implemented complete mapper (based on Mega SD dev manual available on Terraonion website) in my local repository and verified first MD+ patched games (tested SOR2 and Outrun I think) worked fine but was waiting for an updated dev manual to publish changes as it seems there are additional parameters/commands used in later patches that are still undocumented (for looping track playback it seems).

@BooBerry
Copy link

BooBerry commented Jan 9, 2020

You're in luck, I informed Neodev (the MegaSD developer) about it, and he updated the dev manual for the new parameters/commands. You should be able to get your MD+ implementation complete now, hopefully. He also said the best game to test the "stop with fadeout" is with the Ys III patch when entering a building, the music should fade out nicely instead of a hard stop. He also said the Strider patch has loop point specification in the cue sheet, so another good test for it.

https://downloads.terraonion.com/public/MegaSD_DEV_Manual.pdf

Good luck. :)

P.S. in case any of you guys didn't already know, there's a MD+ hacks database here with all the latest MD+ patches: http://www.zeldix.net/f66-md-hacks-database

@ekeeke
Copy link
Owner

ekeeke commented Jan 9, 2020

That's nice. Thanks to you both, I will give it a shot when I got some time. There seem to be a lot of new stuff, this should keep me busy...

@pepodmc
Copy link

pepodmc commented Mar 24, 2020

That's nice. Thanks to you both, I will give it a shot when I got some time. There seem to be a lot of new stuff, this should keep me busy...

Did you make progress with Mega SD support?

Or at least release the preliminary version you did in january, i know that music tracks will not have loop support, but its OK.

I can do longer wavs for the moment XD

@ekeeke
Copy link
Owner

ekeeke commented Apr 28, 2020

I have quite all commands implemented except the ones that let you open/read files and play WAV files from storage device (no software that use these commands exist yet so maybe this can indeed be left pending for the moment). Still need to test the few commands that are being used with current existing patched games and add a way to enable/disable MegaSD support in the various supported ports (libretro, wii/gamecube and sdl) because it is incompatible with existing MD hacks that have CD-DA support (on real MegaSD you need to patch the header of those existing hacks to make them work, which is a little bit unconvenient).

@QuintanaSonBlade
Copy link

The implementation of MegaSD support on consoles (WII / NGC) would be great!
It is a definitive improvement for the megadrive system. I will be attentive and appreciate these developments.

@pepodmc
Copy link

pepodmc commented Jun 19, 2020

I have quite all commands implemented except the ones that let you open/read files and play WAV files from storage device (no software that use these commands exist yet so maybe this can indeed be left pending for the moment). Still need to test the few commands that are being used with current existing patched games and add a way to enable/disable MegaSD support in the various supported ports (libretro, wii/gamecube and sdl) because it is incompatible with existing MD hacks that have CD-DA support (on real MegaSD you need to patch the header of those existing hacks to make them work, which is a little bit unconvenient).

How many chances are that mega sd support be added before the end of this year?

@Flupper
Copy link

Flupper commented Aug 1, 2020

Krikkz has ported Terraonions MD+ patches to MSU-MD (Mega EverDrive Pro).
https://github.com/krikzz/msu-md/tree/master/ips
Unfortunately audio doesn't play in any of the titles in GenPlusGX.
I tried a few in Fusion (just to see if audio works) with mixed results, Moonwalker is fine but Golden Axe and Strider has issues.

I take it this format (MSU-MD) isn't 100% identical to the Rock 'n Roll Racing CD audio hack, which is working fine in GenPlusGX btw.

@ekeeke
Copy link
Owner

ekeeke commented Aug 1, 2020

See #329.

They work fine providing you have all 3 region CD BIOS properly named and the cue file as the same basename as the ROM file you load.

@Flupper
Copy link

Flupper commented Aug 1, 2020

I do have all bios images and correct cue sheets and filenames.
Perhaps the libretro core isn't up-to-date ?
The one I have is newest available for Windows x86_64, Genesis Plus GX (v1.7.4 7fa34f2).

If you don't have anything to do with libretro core, then I do apologize.

@Flupper
Copy link

Flupper commented Aug 1, 2020

Ah, sorry, nevermind.
I grabbed a snapshot of latest source from this repo and compiled a 64-bit dll and it's working now.

I guess the official Retroarch buildbot hasn't caught up yet.

Sorry for the false alarm and thanks again.

@ekeeke
Copy link
Owner

ekeeke commented Aug 9, 2020

Yes, after looking a bit into it, the libretro repository is missing the following commit that improved CDD interrupt emulation accuracy: e66b7bc

It does not work without these changes because Krikzz's Mega CD Mode 1 driver (which is embedded in those 'MSU-MD' patches) does not use the BIOS commands but directly accesses CD registers to initialize CD hardware, play tracks, etc and does it a bit differently from official BIOS software. Unfortunately, the emulator has a few optimizations (i.e deliberate inacccuracies or simplified hardware behavior) based on the assumption that CD registers are always accessed like official BIOS are doing, which can break unofficial code (like MSU-MD driver) doing unexpected stuff.

NB: this is also the reason why, even with latest changes, the first track starts playing automatically in Genesis Plus GX when those patched games are starting. I will commit a fix for this when I got some time.

@Relikk
Copy link

Relikk commented Oct 8, 2020

Has there been any progress regarding the MD+ standard?

@ekeeke
Copy link
Owner

ekeeke commented Oct 9, 2020

Not much I am afraid. As usual, I need to find some time (and motivation) to work on it, which is kinda limited for me these days.

@ArcadeTV
Copy link

I just found your fork of the msu-md driver and played around with it. Thank you very much for your effort! I loaded my own msu-md hacks, as well as your updated sample in the latest genesisPlusGX core and though the looping offset was exact, the looping itself was not 100% seemless.
Is this something you may continue to support? I'd love that and promise to make good use of it in return.
Thank you again and take care.

@ekeeke
Copy link
Owner

ekeeke commented Jan 19, 2021

Hi. The reason it's not 100% seemless in emulator is likely because seek time emulation is always enabled by default so you will get some delay with silence before audio playback starts again from loop offset. The same would occur with real CD hardware or Mega SD / Mega ED pro flashcarts with seek time emulation enabled (not sure if it can be disabled on the latter) and there is nothing I can do in MSU-MD driver code to fix it. Therefore I am not sure what kind of support you are thinking about: the addition of loop command suport in Krikzz's driver what just a quick exercise I did to show it was possible with Mode 1 and I have no plan to work more on it as I consider it to be done.

All I could possibly do is to add a configurable setting for seek time emulation in Genesis Plus GX (like it exists in Mega SD implementation) but it's kinda painful to do (this is also the main reason I still haven't commited my changes with Mega SD extra hardware support for MD+ games as it requires to be enabled manually in emulator settings to be able to distinguish MD+ games that need emulation of Mega SD extra hardware from normal games using Mode 1 that only need emulation of Mega CD hardware).

@ArcadeTV
Copy link

Thank you very much for the insight! As a beginner context like that helps understanding it a lot better.
To be honest, I personally have no problem with using audio that fades out, this was a common thing back in the cd-games-era. On the other hand seamless loops would be a very neat addition and thanks to your commit to the msu-drv very easy to implement.
I have no idea how painful it would be to implement seek time emulation in Genesis Plus GX. I tried to find out how MegaEDpro handles this but no luck finding any info on this.
Anyways, if you ever decide to go for it, I'd happily adjust my patches and soundPacks for both - loops and fading.
Thanks again and I wish I could return something for your efforts..

@ArcadeTV
Copy link

I did a MSU-MD romhack for Sonic 2 using the modified driver https://github.com/ArcadeTV/msu-md-sonic2

Krikzz made a comment that seek time emulation may be optionally turned of on MegaEDpro with a future fw update.
As far as I know all romhacks with MD+ or MSU-MD use the string "MEGA SD" instead of "SEGA GENESIS" in the header at 0x100, so this could be a potentional trigger for ste-disabling.

@ekeeke
Copy link
Owner

ekeeke commented Jan 23, 2021

Krikzz made a comment that seek time emulation may be optionally turned of on MegaEDpro with a future fw update.

If you are able to build you own version of the emulator, seek time emulation can easily be forced off by commenting the following block (you can also modify the minimal latency initialization above that block from 11 to 1 to reduce it even more but it will break some cd games relying on it):
https://github.com/ekeeke/Genesis-Plus-GX/blob/master/core/cd_hw/cdd.c#L1975

As far as I know all romhacks with MD+ or MSU-MD use the string "MEGA SD" instead of "SEGA GENESIS" in the header at 0x100, so this could be a potentional trigger for ste-disabling

Actually, MD+ patches do not use that "MEGA SD" string, which is only required by Mega SD flashcart to recognize normal Mode 1 games (MSU-MD patched ones or any other existing games that have Mode 1 support) and distinguish them from MD+ patched games (which also means current MSU-MD patches need to be completed with that string to work on Mega SD).

It would have been much more logical to specify the opposite (as MD+ games are the ones requiring specific Mega SD flashcart hardware implementation, not normal Mode 1 games) and would have solved my own issue with being forced to have an user setting to manually enable/disable Mega SD custom registers emulation because it is impossible to safely detect a MD+ game has been loaded and distinguish it from a normal mode 1 game (which needs complete mega cd hardware emulation).

@Relikk
Copy link

Relikk commented Jan 23, 2021

It would have been much more logical to specify the opposite (as MD+ games are the ones requiring specific Mega SD flashcart hardware implementation, not normal Mode 1 games) and would have solved my own issue with being forced to have an user setting to manually enable/disable Mega SD custom registers emulation because it is impossible to safely detect a MD+ game has been loaded and distinguish it from a normal mode 1 game (which needs complete mega cd hardware emulation).

With the next MegaSD firmware release the header edit to detect Mode 1 games will no longer be needed, and MD+ games still work as intended when their headers are edited to "MEGASD". So maybe from this point onward, for the sake of distinguishing between the formats in your emulator, that MD+ games can utilise the "MEGASD" header edit. There are only 7 MD+ games so far, so it wouldn't be a problem editing the existing patches to include the edit, and anything in development now or in the future will have that edit from the start, or if/when you have a build of the emulator to take advantage of it.

@ekeeke
Copy link
Owner

ekeeke commented Jan 23, 2021

So maybe from this point onward, for the sake of distinguishing between the formats in your emulator, that MD+ games can utilise the "MEGASD" header edit.

This would be great indeed, and apart from being more homogeneous to existing "standards" (this ROM header field being generally used to indicate extra 'on-cart' hardware required by the game, like "SEGA 32X" for 32x hardware, "SEGA SSF" for Everdrives extended SSF mapper, "SEGA SSF2" for Mega SD extended SSF mapper or "SEGA EVERDRIVE" for Mega ED PRO custom mappers), this would also greatly simplify my implementation of Mega SD overlay hardware ("MD+") support.

@lan-vuhoang
Copy link

How do I load MD+ and MSU-MD roms? Loading the .md file from MD+ Streets of Rage 2 or MSU-MD Castle of Illusion makes a "no-music" version of the game, while loading the .cue file results in a soundtrack player.

@ArcadeTV
Copy link

ArcadeTV commented Mar 1, 2021

How do I load MD+ and MSU-MD roms?

Checklist:

  1. Do you have the neccessary cd bios files in place?
  2. The .cue and .md must have the same filename
  3. Use the latest version compiled for your OS. Updating the core through RetroArch will not get you the latest version afaik.
  4. Open the cue file in a text editor and verify the filename of the soundPack .bin file is correct

After that load the .md and it should work.

@Sanaki
Copy link
Contributor

Sanaki commented Mar 1, 2021

MSU-MD mode 1 at least should work fine in the libretro core. Not sure beyond that. Though in case anyone else gets the same idea, chd is not yet supported, you have to leave it as bin+cue, wav+cue, or ogg+cue. Hopefully that can be fixed down the road when the raw functionality is less of a concern.

EDIT: Yeah, the core's been updated with necessary commits. Should work fine there for the full range.

@ArcadeTV
Copy link

ArcadeTV commented Mar 1, 2021

All I could possibly do is to add a configurable setting for seek time emulation in Genesis Plus GX (like it exists in Mega SD implementation) but it's kinda painful to do...

krikzz updated the msu-drv so it can set seek time emulation off on MegaEDpro. I don't want to ask for features that are a pain to implement, but it would be awesome to have this option in Genesis Plus GX.

@lan-vuhoang
Copy link

How do I load MD+ and MSU-MD roms?

Checklist:

  1. Do you have the neccessary cd bios files in place?
  2. The .cue and .md must have the same filename
  3. Use the latest version compiled for your OS. Updating the core through RetroArch will not get you the latest version afaik.
  4. Open the cue file in a text editor and verify the filename of the soundPack .bin file is correct

After that load the .md and it should work.

That add 1 more step to the process of updating all installed cores.

@pepodmc3
Copy link

So maybe from this point onward, for the sake of distinguishing between the formats in your emulator, that MD+ games can utilise the "MEGASD" header edit.

This would be great indeed, and apart from being more homogeneous to existing "standards" (this ROM header field being generally used to indicate extra 'on-cart' hardware required by the game, like "SEGA 32X" for 32x hardware, "SEGA SSF" for Everdrives extended SSF mapper, "SEGA SSF2" for Mega SD extended SSF mapper or "SEGA EVERDRIVE" for Mega ED PRO custom mappers), this would also greatly simplify my implementation of Mega SD overlay hardware ("MD+") support.

Do you plan to add md+ support this year?

@Tekkenlord-X
Copy link

All I could possibly do is to add a configurable setting for seek time emulation in Genesis Plus GX (like it exists in Mega SD implementation) but it's kinda painful to do...

krikzz updated the msu-drv so it can set seek time emulation off on MegaEDpro. I don't want to ask for features that are a pain to implement, but it would be awesome to have this option in Genesis Plus GX.

please Arcade TV, make a Battletoads patch for msu-md and convert the gunstar heroes one.

@ArcadeTV
Copy link

ArcadeTV commented May 27, 2021

please Arcade TV, make a Battletoads patch for msu-md and convert the gunstar heroes one.

I think this is not the right place to talk about this. Go here.

@Relikk
Copy link

Relikk commented May 27, 2021

Anyway...

Any updates on MD+ implementation? The list of games that are supported is growing steadily (at least 25) with more on the way.

@Tekkenlord-X
Copy link

Yeeey yes please MD+ implementation please please too...

@Flupper
Copy link

Flupper commented Sep 13, 2021

Brilliant, ekeeke, many thanks for adding support in latest build.

@ekeeke
Copy link
Owner

ekeeke commented Sep 13, 2021

This has been (finally) added by
e87891f
dfe3672
7ca2def

For the record, all CD overlay commands (incl. CUE loop commands) described in MegaSD dev manual (cf. attached file) are supported except the ones that deal with opening/reading files from SD card (starting from command 1Ch) but afaik no MD+ hacks use these commands so far.

As discussed previously, since there is no way to auto-detect a MD+ patched ROM, MegaSD add-on emulation needs to be enabled in core options (through the newly added "CD add-on" option). However, when "CD add-on" option is set to AUTO, if a CUE file with same basename as loaded ROM file is found in same directory AND that CUE file contains MegaSD specific keywords ("REM LOOP xxx", "REM NOLOOP",...), MegaSD CD overlay emulation will be automatically enabled (instead of full Sega/Mega CD hardware emulation).

Additional notes:

  • By setting the "CD add-on" option to "SEGA/MEGA CD", you can force Sega/Mega CD hardware emulation when any MD game (<8MB) is loaded even if there is no CUE file found in loaded game directory (this can be useful for demos or homebrew games that want to use Mega CD extra hardware without necessarily having a loaded CD beforehand)
  • By setting the "CD add-on" option to "NONE", Sega/Mega CD hardware emulation will be forced disabled, even if a CUE file is found in loaded game directory or when the loaded game is known to have Sega/Mega CD support (like Pier Solar, Flux or Wonder Library). This emulates the behavior where there is no Sega/Mega CD unit attached.
  • although no known games are using them, MegaSD extended SSF2 mapper and limited ROM write mapper (automatically enabled when respectively "SEGA SSF2" and "SEGA MEGASD" are found in loaded ROM header) are also emulated, according to the description in MegaSD dev manual . Note that MegaSD overlay will also automatically be enabled when these mappers are detected, no matter of the "CD Add-on" option.

Reference:
MegaSD_DEV_Manual.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests