More NES expansion audio biz

Discuss hardware-related topics, such as development cartridges, CopyNES, PowerPak, EPROMs, or whatever.

Moderator: Moderators

Post Reply
User avatar
mikejmoffitt
Posts: 1353
Joined: Sun May 27, 2012 8:43 pm

More NES expansion audio biz

Post by mikejmoffitt »

I have an idea to save a cycle in reading from a cartridge-based expansion (as in many mappers). While I can read from some magic location, I'd like to read from a zero-page location.

During reset, I'd write #$FF to a location (let's say $80, but it's arbitrary as long as it is unused elsewhere). An open collector buffer sits between my peripheral and the data bus, and my device responds to the same address $80. This way, when $80 is read by the CPU, the peripheral can pull data bits low, or leave them at the #$FF that the RAM is already outputting.

This is a bus conflict, but as I do not expect it to sink very much current from the NMOS SRAM chip, it should not damage anything.

As the 2A03 and RAM are NMOS devices, as well as the RAM in the NES, which pull lines low but do not drive them high, would it be safe to do something like that?
Last edited by mikejmoffitt on Wed Feb 08, 2017 12:42 pm, edited 1 time in total.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Forcing a peripheral into zero page safety

Post by tepples »

Later revisions of the NES Control Deck may have a CMOS RAM, as may clones.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Forcing a peripheral into zero page safety

Post by lidnariq »

I don't know if any revision of the NES or Famicom used NMOS SRAM. The MB8416A, LH5116, and HM6116LFP are all CMOS.

Can't find any documentation about the TMM2115BP.
User avatar
mikejmoffitt
Posts: 1353
Joined: Sun May 27, 2012 8:43 pm

Re: Forcing a peripheral into zero page safety

Post by mikejmoffitt »

I see, that's a bummer. Out with that idea, then.

What I wanted to do is create a simple wavetable synth, with a 7-bit output. It is responsible for synthesis, and the 2A03's job is just to take samples and push them to $4011 when there is free time.

I would just insert

Code: Select all

lda SAMPLE
sta $4011
whenever it's convenient in the middle of code, and certainly while I wait for the next frame. Since synthesis is done off of the 2A03 the pitch won't shift, just the rate and subsequent aliasing artifacts will. During game logic and OAM DMA, there would be a small gap (and a bit of a 60Hz buzz), but I'd like to try it and see how noisy it is. It may be suitable for low-frequencies or drums, and if it's not too bad it would be a fun way of having expansion audio on a stock NES. I could forego OAM DMA in favor of a slower but less noisy implementation, if the game is simple enough to allow such a luxury.

I wanted to use zero-page to speed up this access, but this will require a normal two-byte address read. Even still, experimentation might be worth doing.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Forcing a peripheral into zero page safety

Post by lidnariq »

mikejmoffitt wrote:Since synthesis is done off of the 2A03
I kinda have this suspicion that the best seamless way to get expansion audio on an unmodified frontloader is to have the synth coprocessor encode its output as DPCM. Then the 2A03 just sets up the DPCM streamer to endlessly loop a single byte (e.g. $FFC0) and the only thing the 2A03 has to do is tell the synth what to generate.

If it were primarily used with sine, triangle, and trapezoid waves, it should even mostly be able to avoid the slew rate distortion that comes from DPCM encoding.

More similar to your actual idea, we've previously played around with the idea of mapping a read port overlaying the $4011 DAC, and then the game "just" has to LSR $4011 occasionally. Somewhere I think we have some simulations of the resulting audio quality? It's ok.
User avatar
mikejmoffitt
Posts: 1353
Joined: Sun May 27, 2012 8:43 pm

Re: Forcing a peripheral into zero page safety

Post by mikejmoffitt »

lidnariq wrote:
mikejmoffitt wrote:Since synthesis is done off of the 2A03
I kinda have this suspicion that the best seamless way to get expansion audio on an unmodified frontloader is to have the synth coprocessor encode its output as DPCM. Then the 2A03 just sets up the DPCM streamer to endlessly loop a single byte (e.g. $FFC0) and the only thing the 2A03 has to do is tell the synth what to generate.

If it were primarily used with sine, triangle, and trapezoid waves, it should even mostly be able to avoid the slew rate distortion that comes from DPCM encoding.

More similar to your actual idea, we've previously played around with the idea of mapping a read port overlaying the $4011 DAC, and then the game "just" has to LSR $4011 occasionally. Somewhere I think we have some simulations of the resulting audio quality? It's ok.
That too could work as a mode. Unfortunately, DPCM is quite noisy for quiet waves, but there certainly are use cases otherwise. That is certainly worth playing with. Maybe I will try to throw together a simple test "cartridge" with a magic ROM location for this like $FFC0.

If it works well, it would be nice to create proper documentation for it, and hook it up as an extension of some common mapper so that it might actually be supported in a testing environment. This would not be difficult to implement as a PowerPak or Everdrive N8 mapper, either.
Post Reply