nes emulator

Started by
17 comments, last by ed209 16 years, 2 months ago
My goal is to make an nes emulator in VB. So far I know I need to know 6502 assembly. What other documentation or information will I need?
Advertisement
depends. what's your current ability level: what languages do you already know and to what extent? what's your knowledge of things like binary file formats (reading/writing/parsing)? how much do you know about virtual machines?

-me
Depends on how you're approaching the emulator. But for sure you'll also need to know the memory map of the NES, how the GPU and Sound chip work and are given instructions, and how all the various mapper chips inside the cartridges work.

You'll need to know about either Virtual Machines (standard emulation) or the newer, generally faster, Just-In-Time (JIT) or binary translation methods. For VB.NET, JIT/binary translation would be an interesting approach since .NET has all the reflection and code generation stuff built-in. The idea of JIT/binary translation is that, rather than emulating the 6502 with code, you write a translation engine which transforms 6502 assembly into the assembly of the host machine (in this case, .net assembler, or MSIL). Binary translation generally means doing it all up-front, while JIT generally means doing the translation on each function as its called, and caching the most recent blocks.

VB, Whether 6 or .net, may be a pain however, since neither (AFAIK) supports any kind of pointers. I've seen it done before, so its possible, but pointers are generally handy for the kinds of low-level manipulation that an emulator usually entails.

Good luck.

throw table_exception("(? ???)? ? ???");

NES maybe difficult to emulate completely because there are several different memory maps that games could use, and many times they had custom ones (like Mega Man 1 for example. It has a custom memory map). If you want to a game to run in your emulator you have to account for the memory map it uses. Aside from knowledge of the memory maps you'll need to know about the hardware in general like how the CPU worked. you'll also need to know about the format roms are stored in so you can load the games. Zophar's domain still has alot of technical docs even though the site is no longer updated. The is also NESDev.
Patrick
Quote:Original post by prh99
NES maybe difficult to emulate completely because there are several different memory maps that games could use, and many times they had custom ones (like Mega Man 1 for example. It has a custom memory map). If you want to a game to run in your emulator you have to account for the memory map it uses. Aside from knowledge of the memory maps you'll need to know about the hardware in general like how the CPU worked. you'll also need to know about the format roms are stored in so you can load the games. Zophar's domain still has alot of technical docs even though the site is no longer updated. The is also NESDev.


Thanks for the advice. I learned 6502asm and am studying the hardware but it looks like this project is over my head. To read the rom, don't I just read it like a text file and then convert the characters to hexidecimal and then figure out the different opcodes?

Well if NES isn't a good choice to emulate, what do you suggest I emulate first?
I would recommend that you don't start on an emulator if this is your first project. Otherwise, I think that there is no easy system to emulate. My first thought was the Atari2600 but I have heard that there are some tricky things in that system.

All in all (wow, I rambled) I would not recommend any other system if you cannot make a NES emulator. At least you realized that you may not be able to do it before you got far into the project.
------------George Gough
Quote:Original post by ed209
Well if NES isn't a good choice to emulate, what do you suggest I emulate first?


I would suggest going with the x86 (+BIOS)

A basic x86 emulator is relativly trivial (compared to some other platforms), especially if you limit yourself to an older instructionset (like the 80286 for example), information is easy to come by and there is plenty of free software to test with)

[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
For a first emulator project, I'd definitely go for CHIP-8. It has a very small instruction set and simple hardware, but covers most of the basic requirements of an emulator. It's the sort of thing that could be easily squeezed in a hundred of lines of code.

VB is more than sufficient for the job. [smile]

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Okay. I'll emulate the CHIP-8. So where do I start as far as coding goes? I still don't get how emulators are written.
Okay. I'll emulate the CHIP-8. So where do I start as far as coding goes? I still don't get how emulators are written.

First step is to find some hardware specifications. These should help:

http://devernay.free.fr/hacks/chip8/C8TECH10.HTM#0.1

http://www.pdc.kth.se/~lfo/chip8/CHIP8.htm

for your emulator, you will need to allocate the memory that chip-8 programs use (I think it's about 4 kilobytes). Then you will need to loop through the rom's instructions. For every chip8 instruction, you should have a function that accomplishes the same thing. Use a switch statement to call the appropriate function for each instruction, then add to to the program counter register.

Of course, there are a few other things you need to do, such as decreasing the delay and sound timers at a rate of 60HZ, and making sure your emulator doesn't run very much faster than the chip-8's of the late seventies/early eighties (otherwise, games would be unplayable), but I'm not sure how to do that (I'm still working on my first chip8 emulator, too).

Also, you may find this page useful:
http://fms.komkon.org/EMUL8/HOWTO.html#LABH
Placeholder for better sig.

This topic is closed to new replies.

Advertisement