-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add SGB Audio support from Bizhawk #264
base: master
Are you sure you want to change the base?
Conversation
This is all a mess; the buildscripts seems to assume some franken of ms and gnu tools
About |
It was most likely made by loading the SNES side SGB rom into a SNES emulator and then dumping the SPC ram and registers after the cart program had filled them all up. It most certainly contains samples; games that just ask for the built in SGB sound effects to play and don't load their own sample data do work with this. It's a problem to be sure; it's a firmware but there's not one exact official version of it so it could be quite difficult for users to obtain. The audio emulation needs the right initial values loaded to the SPC hardware, but without LLE of the SNES side, can't produce that right initial state. Practically speaking, if you search for spc rips on the internet, it isn't too hard to come across this file, but I can see the issue. |
I see, it's a bit tricky as I'll need to recreate open source version that doesn't use copyrighted samples and code, while keeping it possible for users to provide the original version (Similar to how I handle the boot ROMs). |
Most SNES games used standard sound code, both on the main CPU and the S-CPU side, provided by Nintendo. The Super Game Boy is no exception, and the behavior I provide in HLE, such as the data packet decoding in So while there's a lot of reverse engineering ahead of you if you want to incorporate this feature, it's probably not all that "complicated"; the original payload that gets uploaded to the SPC is most likely just standard program data plus a list of patches in some standard format. |
4ebe973
to
0989ee2
Compare
This is an early draft, so just ignore the build script changes and some of the other junkus. I'm mostly interested in feedback on whether this is something that upstream might be interested in having.
The key details are:
snes_spc
is used to emulate the audio hardwaresgb-cart-present.spc
is used to provide the initial SPC stateSOU_TRN = 0x09
is emulated by parsing the resulting packets andmemcpy()
ing them into SPC RAM; the transfer process that would normally involve SNES code is not emulated.SOUND = 0x08
is emulated by storing the expected port values and then updating them against the SPC port values at 60hzIt's not much, but it works and games sound fine (once audio output to the frontend is implemented; see below.)
Major missing pieces:
GB_sgb_render
blasting chunks of samples directly to the front end whileGB_apu_run
blasts its own chunks of samples directly to the frontend as well, while the frontend then randomly drops chunks of samples because there are too many of them to match the video framerate. Bizhawk reconciles the timing of the streams together and usesblip_buf
to resample everything, but I'm not sure how you want to proceed with that.