Page 1 of 2
Recommended emulator source to read for educational purpose
Posted: Fri Oct 16, 2009 1:09 am
by Banshaku
I always like to read (when I can find the time) different ways of programming since it helps you think differently when approaching new problems for normal programming task.
Since programming an emulator is not what I would call "traditional business programming", there must be some concept or approach used that could be interesting to read or to learn from it.
There as been a surge of aspiring emulator authors these days and it got me in the mood to read some code related to this but with no intention to built an emulator myself (no time for that). Any specific emulator code that would make and interesting read? I want to see approach done procedurally or in OO, if that's can be applied for this (but cannot see how yet, one of the many reason I want to read some code).
Posted: Fri Oct 16, 2009 7:54 am
by Zepper
- Well, mine would be the best choice for a single reason: it's easy to read, more human readable. It's compact and not cryptic like many others around. Anyway, be clear: that's my opinion. Perhaps it's quite different.
Posted: Fri Oct 16, 2009 7:25 pm
by Banshaku
If you provide your code under some kind of
NDA (since it's not open source), I will be more than happy to read it

Posted: Fri Oct 16, 2009 7:59 pm
by Dwedit
When I read the code to Loopynes, I saw that it looked very similar to PocketNES.
Posted: Sat Oct 17, 2009 4:24 pm
by Zepper
Dwedit wrote:When I read the code to Loopynes, I saw that it looked very similar to PocketNES.
- Loopy & Flubba work together. ^_^;;
Posted: Sun Oct 18, 2009 8:03 pm
by Banshaku
I guess I will take as an answer that none of the existing code is really worth to read. Oh well. Will browse some of them when I can find some time.
Posted: Mon Oct 19, 2009 2:46 am
by qeed
You can try nestopia for a full blown OOP based design. Everything is in a namespaces and in classes or so. In fact, so much it's basically a fortress in trying to figure out what some stuff do

Posted: Mon Oct 19, 2009 7:22 am
by Zepper
Banshaku wrote:I guess I will take as an answer that none of the existing code is really worth to read. Oh well. Will browse some of them when I can find some time.
- PM me with an e-mail and I'll send it.
Posted: Mon Oct 19, 2009 7:49 am
by Dwedit
Whenever I've needed to know what PPU events happen at which PPU cycle, I look at Nintendulator's source code first. Its PPU source code is arranged so that you can very clearly tell which cycle the scroll increments at, which cycles have memory accesses, etc.
Posted: Mon Oct 19, 2009 8:19 am
by kyuusaku
I would look at Sega Li/FCEU/Nintendulator/LoopyNES (/there's another I forget written entirely in assembly for Win32!) which are all light emulators and mostly straight forward. I worked on an emulator that would have been great for this because it was <1000 lines of C, but I delete things out of perfectionism :)
Posted: Mon Oct 19, 2009 10:31 am
by Nessie
I find Nestopias source extremely well written, but its architecture may occasionally be rather complex. Certain parts make use of advanced C++ features, making it difficult to comprehend at first, at least for someone with my humble C++ experience.
Nintendulator, virtuanes and fceu are all pretty straight forward and should be easy to read.
kyuusaku wrote:there's another I forget written entirely in assembly for Win32
That sounds like mine:
http://nessie.emubase.de
It uses special asm syntax, people around here seem to be more familiar with C++
But if you prefer something other than C++, how about javascript?
http://benfirshman.com/projects/jsnes/
Posted: Mon Oct 19, 2009 2:42 pm
by kyuusaku
Nessie wrote:That sounds like mine:
http://nessie.emubase.de
It uses special asm syntax, people around here seem to be more familiar with C++
Exactly! :D
Posted: Mon Oct 19, 2009 3:13 pm
by thefox
Nessie wrote:That sounds like mine:
http://nessie.emubase.de
It uses special asm syntax, people around here seem to be more familiar with C++
Little bit off-topic here: I tried your emu and it eats 100% CPU when running (50% on dual core of course). You probably want to look in to that.

Posted: Mon Oct 19, 2009 3:32 pm
by tepples
thefox wrote:Little bit off-topic here: I tried your emu and it eats 100% CPU when running
Some game programming libraries spin-wait for vertical blank instead of releasing the CPU.
Posted: Mon Oct 19, 2009 4:40 pm
by Banshaku
Nessie wrote:I find Nestopias source extremely well written, but its architecture may occasionally be rather complex. /
For Nestopia, I did a quick peek in the code and it's quite overwhelming at first. I don't really know C++ but know some other language that use OOP and the sheer amount of files inside makes it hard to check were to start.
The code is well write for the form but there seems to be no comment at all inside the code, just in the header files. But the no comments part seems very common to many source I saw.
@kyuusaku:
I will give them a look once I can find some time.