What's new

Few programming questions.

cloudy

New member
Hi all,

I've read tutorials on emulation programming and I have a fair knowledge of C to begin programming an emulator. There are a few things Im not too sure about though.

First of all, how do you start getting the OpCodes? What i mean is I know you read in the ROM into memory (The RAM i think) but how do you start getting input from the ROM on what to do? I know roughly how the CPU works. You fetch the opcode, determine the opcode and then execute it. The OpCodes are obviously the input into the emulator core but I dont understand how you get the OpCodes from the ROM.

Secondly im only going to code the core of the emulator to start with and not the Input Plugins, Video Plugins and Sound Plugins. I will use someone elses plugin so I know they work. How will the core communicate with the plugins?

Thanks for any help.
 

Slougi

New member
Well, roms are in binary. So say you have a 8 bit cpu, you fetch 8 bits from the rom from whereever you start execution, compute that opcode, and assuming it isn't jmp or similar, fetch the next opcode, etc.
 

KaioShin

New member
Plug-Ins are only available for very complex systems like N64 or PSX. You should definitly NOT start with one of these. You will need to know how your target system works anyway so it is important to understand I/O. The reason why Emu coders use external plug-ins is only because of the huge amount of work and time needed to do both themselves.
But you can just use dummy code for I/O that does nothing. You can then test the core by writing small Assembler roms and look at your Emus emulated registers. Once you have the cpu working you can start "real" I/O :p
 

Doomulation

?????????????????????????
You can easily use functions such as fread to read a byte from the rom and store it in a char or word. Then examine the opcode, fetch more data if necessary, interpret, execute. That easy.
 

euphoria

Emutalk Member
The opcodes are not necessarily actually in the ROM, since some of them are generated by self-modifying code and probably the ROM is packed. You start to read from boot point (differs from system to system and also cartridge of the same system can have different boot points). You start to fetch opcodes from there and when the boot code ends it has DMA'd to to-be-executed code some location in RAM and then it jumps there.

That's it, basically ;)
 

Top