Sign in to follow this  

writing an emulator?

This topic is 4477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'd like to try and write an emulator just for the learning experience. Something simple like an atari 2600 and maybe if I get it done try my hand at writing one for the snes. What are good sites to learn about the process of writing an emulator? It appears there's not much information on this (or at least I can't find anything on the subject).

Share this post


Link to post
Share on other sites
to do something like that you have to be i imaging amazing with how computers and programming languages work, i mean if youve just read beginners c++i n 20 mins then you may as well go an dig urself an early grave, hoever if you just read assembler for the pros and hacked nasa last night then it will be a doddle i can imagine

all u have to ask urself is can i program a console blackjack game with classes in c++, if the answer is no . . or even maybe, then no, i doubt u have enough knoe how to create an emulator

Share this post


Link to post
Share on other sites
alright thanks,

@zero: Is only for the learning experience I don't care if I get it finished or not, just as long as I get it half working at least. I have some experience in programming c++ around 5+ years and have experience in some other languages as well, nothing special really :/

Again thank you, I appreciate the input.

Share this post


Link to post
Share on other sites
You really should learn a RISC assembly language before trying something like this. An emulator is essentially a software emulation of a set of chip and it's low-level programs like BIOS. There's no way you'll be able to build one until you can at least use one.

Share this post


Link to post
Share on other sites
its ok man, i was just saying i dont want you going down a road which is virtually impossible unless u are one of those crazy coder types, i dont think in 20 years id be good enough to do anything like that, im barely any good at dx after 6 months solid learning

Share this post


Link to post
Share on other sites
Seeing as how I'm probably the only one here making an emulator, I'll give you some advice:

You don't need to know how to make games in assembler. However you should be able to read and understand it as you will have to deal with. You'll need to know the assembler for the system you choose and x86 since lots of examples use inline asm. Also being able to make your own programs for the system is a huge bonus. Oh and if you don't know what an opcode is, well you're screwed.

As for what system to emulate, trust me that the early consoles are not "easy". For example the NES(and SNES and Atari, etc..) cartridges can contain extra processors and have specal memory mappers added on to an already retarded 8/16bit memory system.

I'd suggest going with a hand-held system like the Gameboy or GBA. Their memory model is flat for the most part(no silly "banking") and there's no co-processors to deal with.

Be sure you can find plenty of resources on the system you choose. And download the source to some open-source emulators, it can help a lot when starting out. Just be sure to get one written by someone sane(not ZSNES [lol])

Edit: and if someone tells you to use Python/VB/Java because C/C++/ASM is too hard, tell them to go to hell. You need every cycle you can get.

Share this post


Link to post
Share on other sites
Actually, you may benefit more by creating a Virtual Machine of your own design first. Less worrying about why this program doesn't work well, but this one runs too fast, and that one is all wonky. (Because in emulators, you do have to count cycles for each opcode, or at least guess moderately well.) At least, if you design the system, you have less to worry about, and you can focus more on the task at hand. Pulling out an opcode, getting the operands, executing, increasing the PC, whatever.

A great book on the subject is Virtual Machine Design and Implementation, by Bill Blunden. It covers way more than you'll need for an emulator (including creating an assembler for a virtual machine), but I strongly believe it will help in the long run.

Share this post


Link to post
Share on other sites
The hardest problem in writing an emulator, in my opinion, is to emulate the hardware. Most important thing is to know how the hardware works, so you'd best choose a device for which there are plenty of documentation.
First actual programming task should be to write (or acquire by other means) a processor emulator. It can be a bit tedious to write and you need to write small test programs in assembly to test for bugs. It's important that you understand the semantics of all of the instructions well. In other words, you need to be able to program in assembly for the target device.
Once you've got a processor emulator, you can start working on the other hardware.

Share this post


Link to post
Share on other sites
Quote:
Original post by stylin
Quote:
Original post by Nychold
... Pulling out an opcode, getting the operands, executing, increasing the PC, whatever.

I'm a little confused about this. Do you mean IP?


IP (Instruction Pointer) is the same as PC (Program Counter).

Share this post


Link to post
Share on other sites
Quote:
Original post by FlowingOoze
Quote:
Original post by stylin
Quote:
Original post by Nychold
... Pulling out an opcode, getting the operands, executing, increasing the PC, whatever.

I'm a little confused about this. Do you mean IP?


IP (Instruction Pointer) is the same as PC (Program Counter).

Thanks for the clarification. I figured as much, but I wasn't sure.

Share this post


Link to post
Share on other sites
Ok for all these people who said you need to be a pro asm programmer or W/E, dont listen to em, I wrote a CPU core for the nes, without any knowledge of asm when I started, and I wrote it in VB. It helped me learn ASM, or at least alot of the fundamental concepts, like addressing modes. Writing an emulator isnt as hard as everyone makes it out to be, its just hard to make a good fast one.

Share this post


Link to post
Share on other sites
Alright so then the 2600 isn't simple to emulate eh, I don't know what gave me the idea it was :). Ok then I'll try to write a gameboy emulator instead hopefully when I get some free time. The Virtual Machine idea sounds interesting as well. Does anybody know of some open source gameboy emulators I can look at?
And I wouldn't like to start off trying to emulate the snes I want to keep my sanity for now. [lol]

Share this post


Link to post
Share on other sites
I've written an x86 emulator that handled bios images and such and a few devices. The biggest problems are documentation on the cpu's, documentation on the hardware, and timing issues. I'd say timing issues are the biggest, even later Zsnes versions had timing issues. If you can get a nice scheduler and such going then you'll be fine.

Share this post


Link to post
Share on other sites
The nesdev forum has a support section for emulator authors. You may want to check out some of the topics even if you don't intend to write a NES emulator since they cover lots of common emulation issues in detail.

Keep in mind that different systems require widely different levels of synchronization and timing, largely depending on how much hacking you had to get anything decent out of the graphics chip. So a GameBoy which has little need for palette hacking and has split-screen support built-in isn't too touchy about timing, while almost every single NES game requires fairly accurate cycle counting, and the C64 is nothing short of a nightmare.

Share this post


Link to post
Share on other sites

This topic is 4477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this