nesdev.comhttp://forums.nesdev.com/ What's the fastest rate of repeated IRQ possible?http://forums.nesdev.com/viewtopic.php?f=2&t=16648 Page 2 of 2

 Author: lidnariq [ Wed Nov 01, 2017 6:58 pm ] Post subject: Re: What's the fastest rate of repeated IRQ possible? Pretty easy to simulate that situation, right?Say we're aiming for 10kHz audio, 180cy per DAC update. OAMDMA would knock out 2 samples every 16ms.A little bit of trivial perl:Code:use Math::Trig;for (\$cy = \$sa = 0; \$cy < 297805; \$cy += 180, \$sa++) {      \$newsample = 63.5*(1+sin(\$sa*pi/5)); # sine wave at exactly sample rate / 10, so 994Hz      if (\$cy*2 % 59561 >= 1028) {            \$oldsample = \$newsample;      }      print chr(\$oldsample);}yields this sound:Attachment: sim.ogg [3.7 KiB] Downloaded 39 times Of course, this is roughly the worst possible situation; a sine wave will make this distortion maximally audible.

 Author: Memblers [ Wed Nov 01, 2017 8:39 pm ] Post subject: Re: What's the fastest rate of repeated IRQ possible? Neat, that does have a familiar ring to it. Thinking about the old samples I had recorded, IIRC, 001.WAV and 002.WAV are the only ones recorded while I purposely turned the OAM DMA off (they are sine waves also). Aliasing seems especially noticeable in 007.mp3 (those detuning glitches were in the music driver, I know it sounds awful).http://membler-industries.com/squeedo/2004_version/samps/007.mp3http://membler-industries.com/squeedo/2004_version/samps/

 Author: tokumaru [ Wed Nov 01, 2017 9:19 pm ] Post subject: Re: What's the fastest rate of repeated IRQ possible? rainwarrior wrote:I thought as long as you set OAMADDR back to 0 before vblank ends things should be fine? (At least, I've used it before and not seen anything wrong...)Is there some additional corruption you're talking about?This whole OAM corruption thing confuses me to no end, but I think you're right. Setting OAMADDR back to 0 before sprite evaluation starts should work just fine.It's just that for years we knew that using \$2003/4 was unreliable somehow, but AFAIK it was only recently that the exact behavior was properly analyzed and documented. I guess I just put OAM manipulation through \$2003/4 in my "list of things to never do" and it remains there to this day.Anyway, I understand that the purpose is to be able to have PCM audio during actual gameplay, but 50% of the CPU time, slow ass OAM updates, vblank time being spent on audio... those are pretty severe restrictions, making the technique still prohibitive for most kinds of games.

 Author: lidnariq [ Wed Nov 01, 2017 9:35 pm ] Post subject: Re: What's the fastest rate of repeated IRQ possible? I know I've had situations where just writing to \$2003 caused corruption, even if we write 0 to \$2003 before rendering starts.The last time this came up, Quietust said that in his tests, it works for some CPU-PPU alignments and not for others.

 Author: tokumaru [ Wed Nov 01, 2017 9:45 pm ] Post subject: Re: What's the fastest rate of repeated IRQ possible? Now that you mentioned it, I think I remember someone saying that the only safe way to use \$2003/4 is to write all 256 bytes and let OAMADDR wrap back to 0 (which's exactly what an OAM DMA does, only faster). That'll eat nearly your entire vblank time, even if you use unrolled code.

 Author: lidnariq [ Wed Nov 01, 2017 10:55 pm ] Post subject: Re: What's the fastest rate of repeated IRQ possible? last timeThat was me.You can also safely write the first 7 bytes by hand, but ... being only able to update sprite 0 and everything but X in sprite 1 isn't very useful.

 Author: tokumaru [ Wed Nov 01, 2017 11:16 pm ] Post subject: Re: What's the fastest rate of repeated IRQ possible? Oh, I completely forgot about that topic! Hahaha Yeah, that was certainly the most recent conversation that contributed to my "only fill the OAM using DMAs" stance.

 Author: rainwarrior [ Thu Nov 02, 2017 1:01 am ] Post subject: Re: What's the fastest rate of repeated IRQ possible? Hunh, well that's new to me. I'm going to have to do some tests laster, ha ha. :S

Author:  za909 [ Sat Nov 04, 2017 4:42 pm ]
Post subject:  Re: What's the fastest rate of repeated IRQ possible?

I've tested the effect of the OAM DMA distortion with my FME-7 test ROM before. This exemplifies the worst possible distortion though where the output is delayed, since the sample is fetched from ROM inside the IRQ handler. But this could be solved as well by manually adjusting the vector after each OAM DMA to get the "missed samples" effect instead.