i need help on writing a nes emu.

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
jonathonrh
Posts: 1
Joined: Sat Nov 28, 2009 8:39 pm

i need help on writing a nes emu.

Post by jonathonrh » Sat Nov 28, 2009 9:02 pm

i've tried finding stuff on the internet but i can't seem to find anything. I may have overlooked something, but if anyone would point me to a simple tutorial or help me personally i would appreciate it.

(i've done very simple programming in c and c++, but nothing deep)

i know alot about a computer but not much about programming.

thanks, guys.
Last edited by jonathonrh on Mon Nov 30, 2009 8:40 pm, edited 1 time in total.

tepples
Posts: 22278
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Sat Nov 28, 2009 9:39 pm

Have you programmed a video game before?

User avatar
Dwedit
Posts: 4408
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit » Sat Nov 28, 2009 10:18 pm

If you're making an emulator, you will learn the assembly language of the processor you're emulating. Then you will simulate that processor.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

User avatar
MottZilla
Posts: 2835
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Sat Nov 28, 2009 11:20 pm

You also need to be capable of basic functions on your platform like drawing images to the screen, getting input, and Vsync type functions. Making a simple game like pong would be something to do before attempting an emulator although I would say if you have never made a game before then making an emulator is biting off more than you can chew. While it doesn't have to be making a game, it most easily sums up alot of the skills you would need in making an emulator.

MatthewCallis
Posts: 82
Joined: Sat Sep 22, 2007 8:32 am
Location: Seattle, WA
Contact:

Post by MatthewCallis » Sun Nov 29, 2009 9:37 am

I Googled 'writing a NES emulator', the first result is more than enough to get you started:

http://www.cecs.csulb.edu/~hill/cecs497 ... howto.html

aphex
Posts: 25
Joined: Thu Apr 22, 2010 1:35 pm
Location: England

Post by aphex » Thu Apr 22, 2010 2:34 pm

For all people new to emulation, this is a great blog. I wouldnt advise that you start of with a Nes emulator, it's gonna be a very tough challenge, maybe start with a Chip8 emu.

Here's the blog
http://www.codeslinger.co.uk/pages/projects/chip8.html

User avatar
Zepper
Formerly Fx3
Posts: 3223
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Thu Apr 22, 2010 2:40 pm

- The first thing is about the emulator style: will it be scanline-based? Cycle-by-cycle based? That's your first question.

- Next, about the CPU, how often will you run it? Per instruction? Per given number of cycles (to be used in scanline-based PPUs)?

- Next, the doc about the CPU opcodes/instructions step-by-step. Try to create an abstract layer, like a .h file within all the opcodes and operations, flags and labels. Provide PRG access, perhaps hooking functions inside a big CPU context structure.

- The finale is your PPU emulator; otherwise, you rely on CPU logs. It's interesting here to compare your CPU emulation output with another accurate emulator that provides such thing.

User avatar
MottZilla
Posts: 2835
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Thu Apr 22, 2010 6:51 pm

I disagree aphex. My first emulator was for NES. I could have done Chip 8 or Gameboy or some arcade game I suppose, but the NES was the system I liked and had all my favorite games.

While emulating the NES reasonably accurately to support most games is alot to ask for a beginner, you have to remember it doesn't take much accuracy to get alot of games to run so a beginner shouldn't be discouraged from starting with NES. Infact I think the NES is an excellent platform to start with.

aphex
Posts: 25
Joined: Thu Apr 22, 2010 1:35 pm
Location: England

Post by aphex » Thu Apr 22, 2010 9:42 pm

MottZilla wrote:I disagree aphex. My first emulator was for NES. I could have done Chip 8 or Gameboy or some arcade game I suppose, but the NES was the system I liked and had all my favorite games.

While emulating the NES reasonably accurately to support most games is alot to ask for a beginner, you have to remember it doesn't take much accuracy to get alot of games to run so a beginner shouldn't be discouraged from starting with NES. Infact I think the NES is an excellent platform to start with.
Well I guess it's more of a personal thing, depending on how much you know about emulation thoery in general. I personaly find emulation most challenging because of the amount of work it takes to get any sort of working output (for me anyway), so starting basic helped me build confidence in that sense :)

For simplicities sake, I think that people should start where they feel comfortable, for me, that was the Chip8 and I have heard others with the same ideology, so I think it might be a good path to take.

qeed
Posts: 61
Joined: Tue Jun 17, 2008 11:51 am

Post by qeed » Fri Apr 23, 2010 4:10 am

Yeah I would recommend chip8, very little work to do, I think I wrote a chip8 emu in around 2 hours with the opcode and graphics. Chip8 is good for learning how the emulation loop goes and how to draw.

tepples
Posts: 22278
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Fri Apr 23, 2010 4:12 am

Did CHIP-8 ever get a widely recognized set of mnemonics, or even timings, for its opcodes?

qeed
Posts: 61
Joined: Tue Jun 17, 2008 11:51 am

Post by qeed » Fri Apr 23, 2010 4:22 am

I couldn't find timing info on it, but its opcode is pretty standard, stuff like LD or JMP. There are 2 timers on the machine that can count down from 60 HZ, so rather than doing any timing I just delay the frames to 60 fps per second. It doesn't do IRQ i dont think or i didn't implement it, so timing is rarely needed, and you can write to the graphics whenever you want I think. Yes, it seems like chip8 is poorly documented, but if you just want to see the game screens and manipulate it a little, chip8 is recommended for implementaton because of ease. :D

aphex
Posts: 25
Joined: Thu Apr 22, 2010 1:35 pm
Location: England

Post by aphex » Sun Apr 25, 2010 8:11 am

The Chip8 has basically no documentation on timing and the Chip8 actually has an instruction for drawing the graphics to the screen, believe it or not, so timing isn't that important.

http://en.wikipedia.org/wiki/CHIP-8

I'm surprised you wrote one in 2 hours though qeed, it took me much longer. Although, I have heard the same from others, that it takes very little time to write a Chip8 emulator... I guess I'm just a little slower than the average emulator author :oops:

One thing I always found odd about the Chip8 though, is that it uses 16 bit opcodes, for such a basic system (interpretter actually), that's odd.

qeed
Posts: 61
Joined: Tue Jun 17, 2008 11:51 am

Post by qeed » Sun Apr 25, 2010 8:15 am

lol, that was only possible because i spent near to a year trying to write a nes emu. I guess hard work pays off at some point lol.

aphex
Posts: 25
Joined: Thu Apr 22, 2010 1:35 pm
Location: England

Post by aphex » Sun Apr 25, 2010 10:32 am

It's only now that I'm starting to feel confident with writing emulators, and actually making good progress. Emulation is tough, but that's why I love it, it's a challenge.

Anyway, sorry to hijack the thread jonathonrh, but I'm sure you will find your way with emulation, just keep at it :)

Post Reply