Building an Emulator

Status
Not open for further replies.

CrysisFX

New member
ok so ive read how emulators basically work. now i wanto make one. ill be taking a java class this year in school so i can learn a good programming language but i got to thinking that is it possible for an emulator to take a video game and rewrite its excutables to lets say .exe or c++/c#. if all an emulator does is tranlate memory address functions so a newpeice of hardware can understand them then isnt it possible to have the emulator translate those same function and save the translated functions to an .exe?

if it was all just loaded into ram then takes the functions for the video/sound/input and translated to something standard such as opengl/directx calls, directsound/openal calls, or directinput calls couldnt it run natively?

besides dont most consoles use variations of opengl/al or directx?

so basically my idea is to make a program to first emulate the games excutable files and translate all its proccesses to standard x86 processes and make a .exe out of those processes. i understand some processes such as hardware checking may need to be removed but is this even remotely possible?
 

ulaoulao

Controller Man
Staff member
ill be taking a java class this year in school so i can learn a good programming language
- First of Java is not a "good" language, its a rather clumsy and buggy one. How many times are you asked to update your java runtime? Yeah...

i got to thinking that is it possible for an emulator to take a video game and rewrite its excutables to lets say .exe or c++/c#
- If you truly think that's even possible you have a lot of learning to do. Roms are the binary result of a compiled program ( normally c++ ). The only way to get it to exe would be to reverse engineer it then recompile it.

exe or c++/c#
- huh?? thats not even the same ball park.. c++ is a language not a binary file? exe is a binary compilation based on c++ or other source.

if all an emulator does is tranlate memory address functions so a newpeice of hardware can understand them then isnt it possible to have the emulator translate those same function and save the translated functions to an .exe?
- Whoa.. now we are talking gibberish... Going with the first post .. No..


if it was all just loaded into ram then takes the functions for the video/sound/input and translated to something standard such as opengl/directx calls, directsound/openal calls, or directinput calls couldnt it run natively?
- Not sure I follow your explanation here. A plugin is a way to communicate the core lingo of the rom and translate it to DX calls. That's basically what plugins do.. So what are you asking?

so basically my idea is to make a program to first emulate the games excutable files and translate all its proccesses to standard x86 processes and make a .exe out of those processes. i understand some processes such as hardware checking may need to be removed but is this even remotely possible?
- If it were that easy do you think these extremely talented engineering mind would not think of that?

I'm not trying to burst you dreams here, but you're not making sense. A rom is based off that same architecture. It is all derived from the 8086 paradigm AFAIK. Getting a rom to work on a PC is just a matter of re assembling the calls and figuring out how to interface with windows and DX. Once this is happening YEAH the rom is in memory, but not the emulated game? All of those DX calls and what not is FIFO do think for a second that the entire working of the emulation magic is in memory, because its not.. Just the rom.
 
Last edited:

onewecallgod

New member
- First of Java is not a "good" language, its a rather clumsy and buggy one. How many times are you asked to update your java runtime?
Java isn't a bad language; if it was, then why are so many companies using it? The main reason why it's sometimes undesireable is the reason why it's praised: the runtime allows flexability in where it's used. Rather than recompile the program, recompile the runtime instead.

That aside, to the OP: learn assembly.
 

ulaoulao

Controller Man
Staff member
Java isn't a bad language; if it was, then why are so many companies using it?

1) because its platfor independent.

2) its a c++ design.

3) it has a very good web based SDK.


The reason you dont see many java based emulators is its clunky and slow. I mainly write in c++ and have for 20 plus years. I learned java mainly to see what all the fuss was about. Yeah it has its good points but quick, fluent, and powerful are not some of them. If you're going to design a web based application, or have a need for a cross platform independent app, then its a good choice. Emulation....na, not a good choice.


That aside, to the OP: learn assembly.
- Granted he should learn assembly if he is going to do a thing with emulation, but it wont help for what he wants to do. For that he will need nothing short of magic. All the languages in the world wont help you create an emulator ( only an interface ) . AS onewecallgod simply put you're going to need to know how an assembler works, what HEX and binary really is and how the it's number system works, a good understanding of how the machine interferes calls and how it works with registers, and most importantly a sh7t-ton of patience. Then you can write your core interpreter that will go though and analyze and decipher these roms..
 
Last edited:

Lovecraft

New member
I am surprised (though not shocked) at the misdirection given to the poster that asked about the possibility of being able to emulate a game rom from some system into an exe file for that specific rom.

The TRUE answer to his (I am assuming the poster is male) question is yes, it is absolutly possible and again yes for the very reasons you have mentioned within your question.

If the answer were false, then software such as DosBox, Mame, QEmu and all the other emulators could not work since, in principle, this is exactly what true EMULATORS (not simulators) do.

For instance, mame and mess emulate the hardware that a rom is a stored program for (or in the case of pc's on mess the "rom" it loads is the system BIOS and then it the software emulates being an intel 8086 processor with various hardware peices attached -- software then loaded for that system -- such as it's operating system communicates with the bios program to interface with the simulated hardware (the various hardware is simulated in mame and mess - the processors are emulated -- there is a fine line in the distinction and some mame/mess developers would disagree with me on this point)

Probably the easiest way to do what the original poster asked would be to merely compile the program AS an emulator with the rom included as a resource within the executable. Or a tool could be made to generate executables like this from a rom.

The source code to mame could even be used like this with alot of changes made to it to handle one specific machine rather than hundreds.

As far as generating c or even java code from the rom itself, this too is possible for any given game using disassembly techniques. The code generated would still require some form of stub or mudules that simulate the hardware they are expecting.

But yes this *IS* possible to do, and it does not require reverse engineering if the code in the rom is known to be native code for a specific processor for which one already knows the method to emulate.

Why someone would say it's impossible is beyond me, that's like pretending MAME doesn't work or is just some kind of magic.
 

Lovecraft

New member
pffft I've seen z80 simulators written in BASIC

it's not rocket science, it's more "Instruction in/new instruction out" one DOES have to know the registers and addressing of the original system but an indepth knowledge of assembly is not required. One could do this with a reference manual of the processor in an edit window.

Assembly instructions do not need to be processed as an assembly instruction-- it's silly to think they do and not the way things are done in all emulators/simulators for some, however, it DOES work out easier to do that way == especially 8086 emulators running on modern intel or amd processors -- there is no reason they MUST behave that way, however.
 
Status
Not open for further replies.
Top