Hardware Emulation


Jon

Still Fresh
Joined
Sep 7, 2010
Messages
11
Location
Scotland
It's not something I think I could take on just now, but it's something I've always wondered about. Obviously you need to read the file dumps for games, process and display them in some way. I have heard that in order to emulate a console you need to reverse engineer the instruction set of the processor it uses, is this true?


What exactly are the components that make up an emulator?
 
It's not something I think I could take on just now, but it's something I've always wondered about. Obviously you need to read the file dumps for games, process and display them in some way. I have heard that in order to emulate a console you need to reverse engineer the instruction set of the processor it uses, is this true?


What exactly are the components that make up an emulator?

It's not all that hard, it's just a lot of hard work. If that makes sense.


You need to emulate the CPU, you can do this by getting a big book on the chip, often called something like Z80 Assembler/68000 Assembler etc. and looking, probably, in the back of it where it will give you a list of the op codes and the chars that represent them (and extension chars which give another command again).


Then you find the entry point in the rom and start doing as each instruction says after decoding what they are.


You could write a little GUI where you could step though the instructions and be able to see the register and stack etc.


Once it looks like it's running you can then start displaying (probably) the video RAM and see if anything interesting happens.


It can be quiet addictive to make an emulator for an early system but it can also involve a LOT of debugging when you don't quite emulate a command right or the code is using some kind of undocumented 'feature'.


I'd recommend maybe starting with the 8080 chip if you want to have a go. You could write the emulator in basic or python I'd think. The chip does not have a great deal of instructions to emulate and most games which use it only have 2 colour video ram.
 
Basically you need some code to do what each chip in the original hardware does.


This could include a CPU, sound processor and/or graphics processor.


The particular chips will depend on the system.


At the simplest level, an emulator will just store the state of the system (memory and register contents etc.) and manipulate it each emulated cycle.


This will involve reading the next instruction, and doing what it says.


Graphics and Sound chips are usually sent commands by the CPU, and do more specific tasks (for example, blit a sprite, or produce a sine wave).


You only need to reverse engineer a system if there is no existing documentation available, or if it's incomplete.


If the system has multiple high compatibility emulators available, there's probably already documentation if you ask the devs.


But for to emulate a system which hasn't been done before, then you'd need to reverse engineer it.


Although if you already know it's a MIPS chip, for example, you already have a good idea about the instruction set and architecture.


I might recommend Chip-8 if you want to try writing an emulator.


It's not technically a real chip, but it's very simple while still having many interesting programs to test.


At the absolute simplest, you could make a Manchester "Baby" emulator.


It was the first stored program computer, and it only has 7 instructions!


(Disclaimer: I have never coded an emulator myself)
 
I've taken an interest in embedded computing! Which I've been reading about. I think writing some kind of emulator will be a good learning project and that's my main reason for posting this. So am going to look into the things mentioned above and I'll see where that takes me.


Thanks for the replies :)
 
I've taken an interest in embedded computing! Which I've been reading about. I think writing some kind of emulator will be a good learning project and that's my main reason for posting this. So am going to look into the things mentioned above and I'll see where that takes me.


Thanks for the replies :)

If you want to try writing a 8080 or Z80 (the Z80 will open up hundreds of systems and games which you can emulate) see this handy op code list with ascii code:


http://www.worldofspectrum.org/ZXBasicManual/zxmanappa.html


That is what I used to write my first emulator many years ago.
 
I've been googling info on the Z80 and found a lot of good resources... Just goes to show if you type the right thing into google...


Cheers!

I'd recommend the first thing you try to emulate is Space Invaders (arcade) it uses an 8080 (think of it as a scaled down z80) and you can get the game doing things with very few instructions working.
 
Back
Top