ekeeke / Genesis-Plus-GX

An enhanced port of Genesis Plus - accurate & portable Sega 8/16 bit emulator
Other
673 stars 193 forks source link

Harsh noise at Ys (Japan)'s Sega logo when emulated console is set to Mark III #474

Closed Mint128 closed 1 year ago

Mint128 commented 1 year ago

As the title says, if you set console emulation to Mark III and load the Japanese version of Ys, there's a harsh noise at the Sega logo that's supposed to be silent. You can see it in the video below:

https://user-images.githubusercontent.com/110358354/206943308-bd8f4948-eb39-45de-80a9-d691e91d0d1d.mp4

ekeeke commented 1 year ago

This occurs also if you set hardware to export (PAL or NTSC-U) Master System without boot ROM ("SMS BIOS") emulation. This is caused by the PSG sound chip channels attenuation being changed on startup by the game to output sound before PSG channels are even configured so it seems to be actually a software bug. When console hardware and region are set to AUTO, Japanese Master System hardware is emulated for this game and the game disables PSG output (through a specific register that only exists on Japanese Master System hardware) in this case.

I will need confirmation that this does not actually happen on real Mark III hardware.

Mint128 commented 1 year ago

I don't have a Mark III but I do have a Japanese SMS (the one model with built-in FM unit). It does not happen there. Edit: Oops, I read your post more clearly now. So, it seems like I'd need a Mark III specifically. Well, I can't help in that case then.

ekeeke commented 1 year ago

Found this thread in SMS Power which lists a few games that have similar buggy PSG initialization routine and might have same issue on startup.

https://www.smspower.org/forums/11384-ListOfGamesWithBuggyPSGInitialisationWasPossibleBadDumpsOrBuggyRoms#53729

I can confirm Y's (both versions) exhibit the described issue when export Master System or Mark IIII hardware is emulated: the psg routine accidentally sets to 0 channel 0 attenuation register instead of frequency register, which continuously switches channel 0 output between silence and max level instead of forcing it to silence and produces this static noise until music is started. It is particularely noticeable in this game as it has a long pause on startup before the music starts but there is likely other games in above linked list exposing same behavior as they all share the same buggy PSG routine.

Someone with an export Master System could probably test it and check if this static noise is hearable on real hardware (I have one myself but no flashcart and none of the listed games).

birdybro commented 1 year ago

Video captured from a Mark III by @tianfeng33 that he just graciously provided me:

https://user-images.githubusercontent.com/16388068/207395050-62751683-4cb6-476f-a20b-e8f436815f01.mp4

On the Mark III you don't hear this in the initialization. His Mark III is modded to eliminate the large amount of noise from FM on that model, but other than that this is a representative sample of og hw.

ekeeke commented 1 year ago

Thanks but a record from a non modded system would be preferable as this kind of static noise is definitively something that could get reduced by appropriate filtering of the audio output. If you listen carefuly to this recording with volume maximized, you definitively can hear some static noise during staryup, although much less noticeable than in emulators off course.

EDIT: Hmm, according to this page https://www.smspower.org/Development/AudioControlPort, the FM unit disables the PSG output mixing when connected to Mark III (not sure how it does that) so this would explain why the PSG noise is not hearable in this record (and this behavior should definitively be emulated here). I am still curious how it sounds on a Mark III or export Master System without any FM board connected though.

For what it's worth, I was able to test on analogue Mega SG with Master System FM option disabled and the static noise is very hearable, like in emulators. I don't know how much the implementation (especially PSG output filtering as it likely is what could make the noise barely hearable on real hareware) is faithful to real hardware though.

birdybro commented 1 year ago

Actually Tianfeng just told me that I was mistaken, there is no audio mod on the Mark III. I was confused since he was telling me about his other system that was modded.

birdybro commented 1 year ago

Same Mark III but with no FM this time, you can hear the noise but it's not as loud as gpgx.

https://user-images.githubusercontent.com/16388068/207613993-d28b2ca9-f997-4ff7-989a-c5b840f25f6b.mp4

ekeeke commented 1 year ago

Thanks for the recording. The same noise is definitively there and hearable: loudness might be slightly different but this could just be due to different recording/playback volume, psg balance in emulator, etc... so I would not consider the difference to be that much significant

What needs to be fixed in this emulator though is that PSG output should be silent on Mark III when FM unit is used.

birdybro commented 1 year ago

https://github.com/MiSTer-devel/SMS_MiSTer/pull/108

This maybe is associated?

ekeeke commented 1 year ago

Yes but the proposed logic is only for Japanese Master System (and it is already emulated here), not Mark III + FM unit. See https://www.smspower.org/forums/17760-FMPSGMixTestingTheAudioControlPort for the results for different systems.

ekeeke commented 1 year ago

Fixed by https://github.com/ekeeke/Genesis-Plus-GX/commit/350be7731ccb8767b9abdb5ba567a899bc66e05f