Using RetroZone RetroVision to program GameBoy audio.

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Using RetroZone RetroVision to program GameBoy audio.
by on (#78666)
I originally posted this at ChipMusic.org.

http://chipmusic.org/forums/topic/4281/ ... ibilities/

Basically the idea would be to allow the NES and Game Boy pseudo APUs to sing together.

I'll mirror the quotation here:

B00daW wrote:
Oh, Hi.

Well, it's not news that bunnyboy of RetroUSB fame has created the RetroVision (http://www.retrousb.com/product_info.ph … ucts_id=87) from his "because he can" department... Game Boy on the NES seems to be a neat idea for the NES fans who would just love to play a Game Boy game on the same system after playing a Nintendo game. However, don't we all just love chip music even more?

Let's stop bickering about which console has more sheer power or kick-ass, because we'll never reach an outcome of which sound chip sounds the best or which console has the greatest possibilities. ...Not.

The Nintendo Entertainment System wins again by one simple design choice of the RetroVision.

The RetroVision is basically Game Boy with a I/O (controller) wrapper intercepting from the NES to the GB and PPU (graphics) wrapper intercepting from the GB to the NES inside of an NES cart. The GB audio is also piped through the expansion port of the NES if you have done the expansion sound modification. If not, there is a 1/8" headphones audio jack on the side of the cartridge. The RetroVision wraps the NES I/O register $4016 to the GB controller register $FF00. Both registers are also R/W (or read/write). (The NES controller register can be written via binary strobe. -- http://wiki.nesdev.com/w/index.php/Cont … _registers. GB registers located here. -- http://fms.komkon.org/GameBoy/Tech/Software.html) What does this mean or why does this matter? Effectively the NES can stream data to the Game Boy. Let's use our imagination, shall we? Hrm...

Who would like the NES to control the Game Boy's audio? ...Now wouldn't we need NES code and hardware to store that code to control the GB while the Retrovision is also connected to the Nintendo?

Fortunately, it appears that bunnyboy at RetroUSB is working on a dongle cartridge for the NES. http://www.sealiecomputing.com/images/scoreboard.jpg (This cart in question currently takes score information from a game and uploads it to the Internet. Neat.) This means that a dongle cart can run host code in a specified area of RAM while the client cart connected to it is running its code as well. Remember the Game Genie?

Let's think about what we need for our NES+GB audio set up:

1.) 6502/2a0x host code on a NES dongle cartridge that contains a NES sound engine -- with its 2a0x instrument envelopes, sequencer and sample data -- also its accompanying GB instrument envelopes, sample and sequencer data; and a routine that streams GB sequencer data through the controller port to the GB after X cycles (depending on the code.)

2.) A Game Boy flash cartridge with Z80 code that contains a Game Boy sound engine and a routine that synchronizes with the NES, reads the GB instrument envelopes, sample and sequencer data from the NES controller port and plays the sequencer data after X cycles (depending on the code.)

Sounds complicated, but once it's coded and done, it's done. However there are just a couple minor snags to consider:

1.) Obviously the controller would be useless while GB music is playing, but could also effectively distort the GB sequencer data if you wanted it to for a few frames. The only way around this would be that the controller can only be used after the GB song data has been determined finished. Obviously looped GB audio accompaniment would make effectively using the controller impossible.

2.) There is a known hardware glitch on the NES that when DPCM (sample) data is being played that it corrupts reads to certain NES registers; one being the controller registers. (http://wiki.nesdev.com/w/index.php/APU_DMC -- See the bottom.) This is normally worked around for NES/Famicom software by reading the register 2 to 4 times before proceeding to make sure the right information is received. In this case the GB would have to read its controller register a few times before proceeding. My idea for this would be to either have no DPCM sample data on the NES end -- being quite the shame -- or streaming four duplicate nibbles (half bytes or 4 bits) of the GB sequencer information to the controller register from the NES. If the GB receives two equal nibbles, that it would wait the remaining cycles until the next nibble, and so on...

The main stress would be synchronization of the GB to the NES. Without it this wouldn't work. This means cycle timing on the GB end on its main loop timed to the NES code. Shouldn't be all that difficult. The second stress is that the sequencer data should not be played unless the GB instrument envelopes and sample data has already been streamed to the GB and written to RAM. Basically there would only be a short loading period. To summarize, first the GB would synchronize to the NES, the NES would wait X frames before streaming GB instrument envelopes and samples to the GB with a stop sequence at the end, once the GB has written them to RAM the NES waits X additional frames before streaming sequencer data to the GB, to which it begins to listen and stream the sequencer data in real time to its player routine. The goal being the NES is only writing and not checking on the GB to see if it has gotten what it needs. The NES would just make sure to send more than necessary while the GB continues to check that it's getting the right stuff.

So that about sums it up. If I was a better coder than a dreamer I'd do this myself.

Thoughts?


I'm no expert at the moment. I'm more of a dreamer with select knowledge. I talked with a few people in #NESdev to see if this would work and most responded positively or didn't shoot me down.

How many people have a RetroVision and a hacked Game Genie?

I guess the easiest way to start this off would be to program music using PPMCK and XPMCK since the xyntax is almost identical for the MML.

by on (#78682)
I've considered doing this with my NES+PowerPak and a stock Game Boy Color. But you'd first need an 8-bit Game Boy flash cartridge. Those are a lot harder to find than, say, a GBA flash cartridge since Nintendo shut down Bung.

Then you'd need to solder together a cable from controller port 2 to the Game Boy's Game Link port. Game Link is in essence a null modem cable for SPI (clk to clk, MISO to MOSI), and we know the NES controllers use a protocol not entirely unlike SPI. In SPI terms, data out ($4016 write D0) is a combination of chip select and MOSI, and data in ($4017 read D0, D3, or D4) is MISO. Set up Game Boy in "external clock" mode, and it'll see the NES as another Game Boy, and the NES will see the Game Boy as a gamepad.

From pandocs:
I've composed some tracker music for an NES+Game Boy duet in anticipation of a setup like this. It might sound like this (NES on left, GB on right).

by on (#78685)
This might sound blasphemous, but why not just use a PC-Engine tracker if you want to get NES-like and GB-like waveforms together? Or a Virtual Boy? Or a DS with the NES side done in emulation through PCM?

Why must it be a veritable chimera of an idea?

by on (#78686)
The EMS cartridge is one that seems to stay available longer than others. I have an older model Game Boy flash cart that still does the trick for me.

Either way this looks like to be another good idea to pull this off. Would be good to get the software made so that either route could be taken with the same software.

As for Chris:

ccovell wrote:
This might sound blasphemous, but why not just use a PC-Engine tracker if you want to get NES-like and GB-like waveforms together? Or a Virtual Boy? Or a DS with the NES side done in emulation through PCM?

Why must it be a veritable chimera of an idea?


In this case why not just use an modular format like tepples, FL Studio or Renoise? The idea would be to use the real hardware.

by on (#78687)
The EMS USB cartridge sort of reminds me of the EFA-Linker in how it's described. But a lot of people will have to reboot to Linux to get it to work.

ccovell wrote:
why not just use a PC-Engine tracker

Because TurboGrafx-16 was never popular in my market. That's why I currently stick with Modplug Tracker for my fakebit compositions.

by on (#78713)
Quote:
Those are a lot harder to find than, say, a GBA flash cartridge since Nintendo shut down Bung.


I own 3 different GB flash carts, all bought in the last couple of years, and none of them Bung. So they're not that hard to find.

Like B00daW said, the EMS 64M cart is sold at various places. I've found the USB drivers for it a bit iffy, but it can also be programmed over an LPT port using the Gameboy Transferer II. The LPT-only GB Smart 32 card is also still on sale.
Only the Smartboy cart seems to be temporarily unavailable, due to shipping problems.

by on (#80151)
I'd like to be able to use these together. It would streamline my live setup, and I'd only have to bring the NES, as apposed to the NES + GB. And that's one less thing to forget. :)

ccovell wrote:
This might sound blasphemous, but why not just use a PC-Engine tracker if you want to get NES-like and GB-like waveforms together? Or a Virtual Boy? Or a DS with the NES side done in emulation through PCM?

Why must it be a veritable chimera of an idea?


When there is a PC-Engine tracker, let me know!... and Virtual Boy! ;)

by on (#80165)
Quote:
When there is a PC-Engine tracker, let me know!... and Virtual Boy!


It's not a tracker, but my MML compiler kit supports the PC-Engine.

by on (#80398)
I know! Just saw the release. XPMCK is a powerful program. But, man, I really struggle with MML. :oops:

by on (#80408)
mic_ wrote:
It's not a tracker, but my MML compiler kit supports the PC-Engine.
Is source codes available and is there feature for using alternative temperament (such as just intonation for example), or be able to enter some of the assembly language codes for callbacks directly in your .mml file?

by on (#80422)
Quote:
Is source codes available

Yes.

Quote:
and is there feature for using alternative temperament (such as just intonation for example)

I've had no musical education, so that's mumbo-jumbo to me. But this is what I base my frequency tables on:

32.7032, -- C
34.6479, -- C+ / D-
36.7081, -- D
38.8909, -- D+ / E-
41.2035, -- E
43.6536, -- F
46.2493, -- F+ / G-
48.9995, -- G
51.9130, -- G+ / A-
55.0000, -- A
58.2705, -- A+ / B-
61.7354 -- B

That's my Octave 1, and then I double the values for each octave I go up.


Quote:
be able to enter some of the assembly language codes for callbacks directly in your .mml file?

No. At the moment you have to put all callback code in a separate file (like the assembly code file that invokes xpmp_init/xpmp_update).