LogFAQs > #979545178

LurkerFAQs, Active Database ( 12.01.2023-present ), DB1, DB2, DB3, DB4, DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, Clear
Topic List
Page List: 1
TopicWriting an NES emulator ama
Yellow
03/24/24 9:42:22 PM
#10:


Sahuagin posted...
sounds fun. looks like C#, right?
Yeah, that's just a big array declaration with one of the parameters being an array of delegates. I use this coding pattern a lot. C++ is used very often in emulators because people think it's faster, but that's a myth. It uses more memory and will chug if you don't know what you're doing, but with the latest .NET JIT optimizations generally any code you write will be just as fast as a compiled language. C/C++ diehards think I'm over here creating a new object to spam the GC every frame, when even amateur C# users know not to do that. Proof of that is RyuJinx, a switch emulator that (ran) as fast as the C++ Yuzu despite being written in C#.

Sahuagin posted...
that almost sounds not too bad except what about graphics and audio? isn't there some kind of sprite system, etc? how does that work? and how do you play 8-bit audio? maybe there are libraries for this? (I see PPU is the graphics but that doesn't sound easy).
I've only been told the PPU is easy, I haven't actually gotten to it yet. So I'll do my best to explain what I know so far about those things;

The sound is controlled via the APU, which takes parameters and outputs a couple waves accordingly. "two pulse wave generators, a triangle wave, noise, and a delta modulation channel for playing DPCM samples"
https://www.nesdev.org/wiki/APU

How it works is essentially this; the CPU writes values to the a certain area. The APU has some registers mapped to that area, the APU reads these values (just like parameters) and outputs sounds accordingly.

The PPU acts the same way, taking only 8 registers as parameters. I can't say much more about it confidently because I haven't gotten to that part yet, but the CPU can work without it.
https://www.nesdev.org/wiki/PPU

---
https://www.youtube.com/watch?v=5C_Wrt6pNSw
... Copied to Clipboard!
Topic List
Page List: 1