It is currently Tue Feb 20, 2018 12:53 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sun Jan 21, 2018 12:47 am 
Offline

Joined: Mon Jan 15, 2018 12:52 am
Posts: 3
So there's this little project I've been working on for the past few weeks, which I think is at a good stage to start showing off. Its still very much a work-in-progress, but the most critical components are now working.

What I'm building is a contraption that can play NES game music using an authentic RP2A03 CPU/APU to do the audio synthesis. Beyond the RP2A03 itself, however, I'm attempting to do this with entirely modern components.

My system is basically composed of two halves:

The NES half contains the RP2A03, an SRAM chip, and EEPROM chip, an audio amplifier, and an I2C interface.

The "modern microcontroller" half currently contains an Espressif ESP32-WROOM and a microSD card interface. Eventually, I intend for it to have a display and some buttons for control. (I'm also seriously considering wrapping up a version of this project into an alarm clock, which uses the ESP32's Wi-Fi for network time sync.)

The system currently works by reading the music from VGM files, and generating a command stream to tell the 2A03 what to poke at its APU registers.

Here's a video of my first end-to-end test:
https://www.youtube.com/watch?v=97jic_WRrwY

And a follow-up playing a different track:
https://www.youtube.com/watch?v=eafaFr9Q_rU

And here's the work-in-progress schematic of the NES half of the system:
Image

At the outset of this project, the VGM format seemed like an ideal thing to start with. Lots of rips already available, and the format was literally "poke this value into that register, sleep for X samples, poke this value into that register, etc." In very little time, I was actually able to write a quick-and-dirty C program that could convert VGM into a dump of 6502 assembly (or data easy to iterate over in 6502 assembly). Of course it filled my memory to play only a few seconds of Super Mario Bros this way, but that was enough to give me a huge grin.

As I got deeper into it, I also learned about NSF. It seems like NSF has an even larger catalogue of rips and is more populate in the chiptune community. Unfortunately, NSF seems to only be viable on emulators (or if you have just the right combination of "architecturally correct NES /w whichever bank switching chip a particular game felt like using"). So when/if I decide to consider dealing with NSF files, I think I'm going to have to basically convert it to VGM first. (Either by hacking an emulator on my PC, or by running a stripped down emulator on the ESP32 that captures APU writes and sends them across.)

Anyway, enough rambling for now, and I'll save any involved back-stories and inspirations for a future blog post. I just felt like I had to get some sort of forum post about this project out there. :-)


Top
 Profile  
 
PostPosted: Sun Jan 21, 2018 1:29 am 
Online

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6786
Location: Seattle
NSF always uses the same bankswitching hardware, or none at all. The problem for your current design is that the no-bankswitching-at-all model expects something resembling a 32K ROM in the upper half of the address space.

As far as VGM consuming too much memory, I'd think you should be able to build a message-passing loop between the 2A03 and the ESP32 ...

For whatever it's worth, a bare 2A03 doesn't have to worry about where it maps things: the bus conflict that would happen on reads from $4016 and $4017 won't happen (because that's external, between the 74'368 on the mainboard and whatever other hardware is present) OR on any conflict that would happen on reads from $4015 (because the NES hardware special cases that address and ignores the data bus on reads from that address).

(When the 2A03's TST pin 30 is high, reads from the entire range from $4000 through $401F ignore the external data bus entirely)


Top
 Profile  
 
PostPosted: Mon Jan 22, 2018 9:22 pm 
Offline

Joined: Mon Jan 15, 2018 12:52 am
Posts: 3
lidnariq wrote:
As far as VGM consuming too much memory, I'd think you should be able to build a message-passing loop between the 2A03 and the ESP32 ...


I know its probably lost in the middle of my attempt at writing a "brief" post, but this is actually exactly what I did. I only tried cramming data into the EEPROM in my early "let's see if I can make sound" tests. My later tests (which are in those video links) use the ESP32 to read in the VGM file and generate a sequence of I2C commands that tell the 2A03 what to do. This works quite well, doesn't require much 6502 code, and is how I plan to make this all work.


Top
 Profile  
 
PostPosted: Mon Jan 22, 2018 9:46 pm 
Online

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6786
Location: Seattle
Glad to see that was the obvious thing to have done :)

I'd think you'd also be able to emulate the 6502 and NSF bankswitching hardware on the ESP32, and relay the audio writes to the physical 2A03... basically dynamically generating the VGM at play time. That's probably also what you meant ...

Something I'd think would be fun from a musical point of view, although not particularly useful from the point of view of replaying existing soundtracks, is using some kind of reconfigurable clock generator to choose what frequency the 2A03 runs at. Could be nice to get an extra octave off the bottom, or more precise tuning with higher notes, or different DPCM tuning. (Then again, most of the VGMs of Master System games I've listened to are dramatically improved by transposing everything down an octave. The 2A03 has a much less limited musical range, but I can't say that won't be true here too.)


Top
 Profile  
 
PostPosted: Tue Jan 23, 2018 10:20 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19643
Location: NE Indiana, USA (NTSC)
lidnariq wrote:
Then again, most of the VGMs of Master System games I've listened to are dramatically improved by transposing everything down an octave.

Is it because their developers weren't aware of the alternate mode for pulse 3 that's 4 octaves down? That's two octaves below even the 2A03 triangle.


Top
 Profile  
 
PostPosted: Thu Jan 25, 2018 6:42 pm 
Offline

Joined: Mon Jan 15, 2018 12:52 am
Posts: 3
lidnariq wrote:
Something I'd think would be fun from a musical point of view, although not particularly useful from the point of view of replaying existing soundtracks, is using some kind of reconfigurable clock generator to choose what frequency the 2A03 runs at.


This is an idea that has never occurred to me, but actually something worth considering as part of a follow-on project (in addition to exploring add-on audio chips only used on the Famicom). Programmable oscillators are now a thing (a Sega Genesis VGM player project used them in lieu of weird crystal frequencies) so its definitely do-able.

Thankfully I actually was able to still get a new crystal at the weird frequency used by the 2A03, otherwise I'd have already built in this capability.


Top
 Profile  
 
PostPosted: Thu Jan 25, 2018 9:21 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19643
Location: NE Indiana, USA (NTSC)
So 6 * NTSC is "weird" now?

Is 4 * NTSC still gettable, and is PLL multiplication by 3/2 practical?


Top
 Profile  
 
PostPosted: Thu Jan 25, 2018 9:36 pm 
Online

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6786
Location: Seattle
6√óNTSC crystals have been verging on "special order" territory for years now.

Not that special order is that much of a problem.

No PLL is needed; extracting the 3rd harmonic of a square wave using an adjustable LC tank is an easy thing.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group