Recommended emulator source to read for educational purpose

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
Banshaku
Posts: 2404
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Recommended emulator source to read for educational purpose

Post 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).
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post 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.
User avatar
Banshaku
Posts: 2404
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Post 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 :wink:
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

When I read the code to Loopynes, I saw that it looked very similar to PocketNES.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

Dwedit wrote:When I read the code to Loopynes, I saw that it looked very similar to PocketNES.
- Loopy & Flubba work together. ^_^;;
User avatar
Banshaku
Posts: 2404
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Post 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.
qeed
Posts: 61
Joined: Tue Jun 17, 2008 11:51 am

Post 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 :P
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post 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.
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post 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.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
kyuusaku
Posts: 1665
Joined: Mon Sep 27, 2004 2:13 pm

Post 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 :)
Nessie
Posts: 134
Joined: Mon Sep 20, 2004 11:13 am
Location: Sweden
Contact:

Post 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/
User avatar
kyuusaku
Posts: 1665
Joined: Mon Sep 27, 2004 2:13 pm

Post 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
User avatar
thefox
Posts: 3139
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Post 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. :)
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post 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.
User avatar
Banshaku
Posts: 2404
Joined: Tue Jun 24, 2008 8:38 pm
Location: Japan
Contact:

Post 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.
Post Reply