answersLogoWhite
Sony Playstation 2
IMAP

How does an emulator work?


Top Answer
User Avatar
Wiki User
Answered 2014-03-21 15:03:05

An emulator is a program that basically reproduces the behaviour of the hardware of an old machine (ex : video cards, CPU, mainboard, RAM). People that program emulators have to first obtain some information about the console they want to emulate; for example : what are the operations performed by the CPU. How is the RAM divided ?

Emulation is a very a complicated process of an application (emulator) acting like (emulating) another platform/processor/computer/etc.

One commonly emulated platform is the video game console, including systems like the Nintendo Game Boy, Nintendo Entertainment System, Sony Playstation, Sega Genesis, NeoGeo Pocket Color to name a few, although, just about anything can be emulated, from computers, to calculators, to video game consoles. Even the computer used in the spacecraft for the Apollo space missions has been emulated.

The basic process of emulation looks something like this:

  1. Fetch the current instruction from memory (RAM).
  2. Interpret that instruction. (Interpreting is taking an instruction that is supposed to run on another platform and executing or doing the equivalent instruction(s) on the machine that is doing the emulating/running the emulator program.)
  3. Increment the emulated PC (program counter; a register that points to the currently executing instruction) the appropriate amount.
  4. (OPTIONAL) Allow the machine running the emulator program to sleep/rest or stop execution of the emulator for a certain amount of time to regulate frame rate (FPS; Frame Per Second) or the emulated platform's processor speed.
  5. (OPTIONAL) Do any other things that need to be done. (Draw an emulated screen, process emulated audio, etc.)
  6. Repeat the process.

Hopefully that makes some sense to the person who asked this question. Emulation is not the sort of thing that can be explained in detail to a non-programmer or non-techie.

If you want to write an emulator yourself, and feel you know enough to get started, then do the following:

  1. Get as much info on the system you're looking to emulate AS POSSIBLE! This is EXTREMELY important, otherwise you'll have no idea what to do in the next steps.
  2. Pick an appropriate programming language to use. Using a scripting language or a language/tool that is interpreted is probably not the best idea if you're looking to emulate a fast platform.
  3. Figure out how you're going to emulate registers, RAM, etc. One of the simplest ways of emulating RAM is creating a large array to put all the emulated RAM's contents in. Registers can be done in multiple ways, but my WIP GB emulator simply uses char variables, since one char is 8 bits (1 byte) in size, which is the size of most of the GB's registers. (The GB's 16-bit registers are emulated using shorts.)
  4. Start coding! Take it easy though. Make sure you're not making too many mistakes. Assuming you're emulating some kind of "complete" platform (a platform with everything need to run and function), emulation of the CPU and RAM is what you should focus on first. (Remember! Focus on accuracy and proper emulation first. You can speed things up later, when your emulator actually does something!)
  5. Debug. This is what's gonna make you want to shoot yourself. Emulators are going to require a ton of debugging.
  6. Repeat steps 4 and 5 many, many, many, many, many times.

As far as info, you should have several resources available to compare with and get info from. I use Google and Wikipedia to get my info. You might have to search for info for quite a while to get what you want. (I took about two days to find and bookmark enough info that I think I will need.)

You probably want to code your emulator in C/C++ or ASM. I know some people even code emulator in Java, although, don't expect an emulator in Java to run as fast as one in C/C++ or ASM.

If you want, you can look at a very basic version of my code for my WIP GameBoy emulator below (use as you please):

//This is all done in C++ using MinGW and Code::Blocks IDE

//Define our RAM, VRAM, registers, etc:

int InterpretInstruction();

char gb_a, gb_f; //Emulated registers A and F. Sometimes paired as one 16-bit register

char gb_b, gb_c; //More registers. Sometimes paired as one 16-bit register

char gb_d, gb_e; //...

char gb_h, gb_l; //...

short gb_pc; //Emulated Program Counter register (16-bit)

short gb_sp; //Emulated Stack Pointer register

char* gb_ram_main; //Emulated RAM

char* gb_ram_video; //Emulated Video RAM

char* gb_cart_rom; //Emulated contents of the ROM

char* gb_cart_ram; //Emulated RAM in some cartridges

int main ()

{

load_rom_data_bin();

gb_pc = 0x0100;

gb_pc_ = 0x0099;

gb_sp = 0x0000;

gb_ram_main = new char[ 8192 ];

gb_ram_video = new char[ 8192 ];

load_rom_into_ram();

while( true )

{

if( InterpretInstruction() == 0 ) //My interpreting function returns 0 on OK

{

//Nothing. PC incrementing is handled in InterpretInstruction()

}

else

{

exit(1); //Abort if there's an error.

}

}

return 0;

}

int InterpretInstruction()

{

/*

It is said that switch statements are inefficient for a matter like this, but it seems to depend. According to some sources, this only holds true for switches with a small number of cases, which will compile into a chain of if() ... else if() ... statements - whereas with larger numbers of conditions [100-200+] a switch will compile into a jump table, and thus be more efficient than avoiding switch statements.

*/

switch( gb_ram_main[ gb_pc ] )

{

case 0x00: //NOP instruction

{

gb_pc++;

return 0; //Everything went OK

break;

}

case 0xc3: //JMP instruction Jump to the 16-bit address following this instruction

{

gb_pc = Form_16_Bit_Address_Using_Two_Bytes_Ahead_Of_This_Instruction();

return 0;

break;

}

default: //ERROR!

{

return 1;

break;

}

}

}

001
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0
User Avatar

Your Answer

Related Questions


If the file is in GCM format instead then the emulator will still work properly.


There is currently no functional PlayStation 3 emulator in existence.


it depends what emulator u r using


There are no PS3 emulators and the bios file for the PS3 would not work in a PS2 emulator


u put ur button on your pants and stick it one the emulator chicken thing


Yes. For Final Fantasy I, II and III you need an NES emulator and the rom. You will need an SNES emulator for IV, V and VI and a PSX emulator for VII, VIII and IX. PS2 will work for XII, XIII.


What do you mean an emulator that works to trade pkm there's no such thing! an emulator has no wifi connection! the reason they don't have wifi is because they are not a legit copy of the game!


No a PS2 emulator is much more complex and PS2 games can not be run in PS1 emulation



yes, it called dolphin, it is also a gamecube emulator download a wii ISO with torrent or rapidshare (etc...) then search dolphin wii emulator in Google and download it if your PC have a config that is strong enough, it will work perfect after you loaded the ISO into the emulator


Do you use Visualboy Advance? Make sure this emulator is up-to-date.


That might have something to do with your emu configurations. If you use epsxe, you should be fine. If your emulator has problems, you can go get the PC version of FFVII, that should work.


PS games will not work in a PC that does not have a PS emulator program


Yes but you need pokesav and converter



You can not unless you learn how to set up and run an emulator and then if that game will work on the emulator you might learn how to set up the PC and emulator to play that game and eventually play the game.


No, because Pokemon red's emulator is for Nintendo products only not Xbox whixh is owned by Microsoft. It just would not work. you can play Pokemon red on xbox using xbox emulator, just send emulator and the ROM to your xbox and start it.......


First you'll need to download an emulator, then you have to get a rom that'll work on that emulator. You can find all this stuff at emuparadise.me


With an emulator see related links


First go to the site called Emuparadice(this is easier to remember than previous answer) and download any emulator that might work. then go search the game, download that and learn to work that emulator.


No. There isn't one now. No. There isn't one now. Well there are two that u cn download on emulator-zone.com but they dont work.


a game emulator software converter can be used to convert older games for PC use. I have tried a couple of game emulators and it did not work unless the game came with the emulator installed. a game emulator software converter can be used to convert older games for PC use. I have tried a couple of game emulators and it did not work unless the game came with the emulator installed.


There are no working PS3 emulators. The PS2 system has some poorly working emulators that can barely manage to complete some PS2 titles with a lot of work and very poor results on over half the titles. The much more complex PS3 system does not have a working emulator, but it could still be illegal to download Sony Software if it was included in the emulator even if the emulator does not work


After Enter The How do you get a game pad Make A Restart it may work


There is no emulator for the Xbox.



Copyright ยฉ 2021 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.