643 karma · joined November 24, 2016
Also using Wayland (on Linux), gfx.webrender.all and a few other options can help quite a lot. For more details, I suggest you check out these two pages:
https://wiki.archlinux.org/index.php/Firefox https://wiki.archlinux.org/index.php/Firefox/Tweaks
I applied most of the recommended (and some of the not recommended) tweaks documented there, and I'm very happy with the results.
I believe there is still a lot of room for improvement in terms of accuracy, clarity and code size. Note that this repository was more than 3 years old. Maybe this will motivate me to improve it even further.
CPU and PPU implementations tend to be in the order of the thousands of lines -- they are around 200 and 300 lines respectively in LaiNES. In fact, most of the code is in the GUI that I could easily strip away if this was a competition. And this wasn't written to be small - it was written to be simple. It also came out small, but that's incidental.
Here's how I counted the lines and how I decided on the description for the repository, which by the way has been catapulted from totally unknown to worldwide attention overnight, and it's now object of unexpected, ruthless scrutiny that I couldn't foresee.
[andrea@manhattan src]$ rm -rf boost nes_apu Sound_Queue.*
[andrea@manhattan src]$ cloc .
24 text files.
24 unique files.
1 file ignored.
github.com/AlDanial/cloc v 1.70 T=0.03 s (780.3 files/s, 63170.2 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C++ 11 210 110 1163
C/C++ Header 12 87 7 285
-------------------------------------------------------------------------------
SUM: 23 297 117 1448
-------------------------------------------------------------------------------I disagree with this statement. It takes a considerable amount of effort and research to reach cycle-accuracy, especially on the PPU side. Understanding how the PPU pipeline works will take you more time than everything else.
If you settle for frame-based emulation you can write the functions to emulate the opcodes without worrying about the order and duration of the internal operations. Once the opcode is emulated, you just add cycles to a global counter based on a table that contains the number of cycles per instruction.
After 29781 cycles (you may end up being a little off each time, if you are not cycle-accurate), you call a function to update the state of the PPU. There you can use familiar iterative constructs to perform the rendering.
Compare this with the state machine approach in my code (ppu.cpp) and how much more careful I have to be composing microinstructions to form opcodes (cpu.cpp). I came up with a (I think) clean design but it wasn't trivial.
Everything you need is on the NESdev wiki or it's linked there. A couple of particularly helpful resources are linked in my README. The PPU diagram and the 6502 reference were especially useful.
I definitely encourage you to do it, it's a great learning experience and very rewarding. When games start running is pure programming ecstasy :)
The reason for the single letters is that those are the actual names of the 6502 registers.
Glad you like it overall. :)
That looks really good, I'll have a look at it!
Lately I've been experimenting with D (https://dlang.org), created by Walter Bright and Andrei Alexandrescu, both well known expert C++ programmers. D feels a lot like C++ should have been had it dropped some C compatibility in exchange for clarity. Its meta-programming capabilities are also far more powerful. I can think of features (like template mixins) that would make this project even more compact.