What's new

A new guy wondering how long it takes

Toasty

Sony battery
Hey, I want to get into writing emulators and am just trying to get a good guess at what kind of time investment it will take before I start seeing any results. Let me start out saying that I've been programming for a few years now and have some experience with C/C++ and a little with x86 assembly, and I understand the basic principles behind emulation (read instructions from a foreign executable and execute the natively typically by means of interpretation, dynamic or static recompilation).

I realize I have to start small, so I think the first logical step is probably something simple (well, less complicated) like the NES. Eventually, though, I'd like to write emulators for (running on) consoles - perhaps even the N64 emulator for PS2 that so many people say is impossible. If there's anyone reading this thread who's written an emulator, I'd be very grateful to hear how much you've done in emulation and how long it took you to get that far. Thanks in advance for your insights!
 

BGNG

New member
The absolute most difficult part of writing any emulator for a videogaming system is to obtain proper documentation on the usage of the processor and the internal workings of the given devices.

The best way to find out how certain interfaces of a device function is to write programs yourself and see how the device handles them.

If you understand the principle of Assembly (which is NOT difficult to understand. I learned it all in one day) and have control over your personal ability to program, writing emulators is anything BUT difficult.
__________

The NES is indeed very low-level and simplistic, but programming for it requires some kinda magic touch that I never quite achieved. It is an utter pain in the neck unless you understand it real well, and I ran away from it crying. Probably the easiest console to program (that I have sufficient documentation for) would be the Game Boy Advance.

I have included all the information you need for emulating NES and GBA. The GBATek file includes ALL aspects of GBA (it came from the help section of the developer version of no$gba) and will suit you nicely. The NES ASM 6502 file includes information on NES Assembly, and the NESTech file (should be read with the DOS Edit program for best display) goes over all the specifics of programming for the NES.

Keep in mind, though... The ARM 32-bit opcodes that are used in the Game Boy Advance are structured to allow maximum flexibility, and that can make decoding them rather tricky if you don't know what you're doing. It's not as simple as "read these exact bits to get the instruction" like most other systems.
__________

Writing a program to implement opcodes, if you set up a good system for doing so, shouldn't take more than 3 weeks max. The GBA has two sets of opcodes; ARM and THUMB, so I say 3 weeks as an overestimation.

Configuring the graphical processing and file access business can take up to a few months for troubleshooting and fine tweaking. You will need a lot of patience when implementing these things.

Sound and input are generally fairly easy, but the GameBoy Advance has a built-in "media player" that I haven't had time to research. That may or may not be easy to emulate.

Altogeather, if you have your documentation and a firm understanding of Assembly, writing an emulator for any of Nintendo's platforms shouldn't take more than maybe a year at most; for polishing it off and adding any features you want to have at your disposal.
__________

But don't let time scare you. The process is a LOT of fun and pretty easy; considering the majority of the game is... well, programmed in the game and not the emulator. If your emulator does what the games tell it to do, it will seem probably too easy for what it's worth.
 

zenogais

New member
Hey there :bouncy: I've been at this emulation thing for a few years now, and I'd say that it takes a considerable amount of willpower and motivation to create an emulator, but you can do it. Now the NES is a very ambitious project, and a little beyond someone who is looking for their first emulation experience. I'd say that its probably a much better choice to start by emulating the Chip8 first. The Chip8 is a very simple emulation project and will set up the basic principles you need to move further. Now anything above Chip8 will never be that simple, but it lays the ground work for any future projects you'd like to attempt. For more information read through the sticky Chip8 thread :bunny:

BGNG: Now you're being a little misleading with your post. The GameBoy Advance is definately not a beginners emulation project. The ARM is a RISC processor, but still has a fairly complex design. If you weren't able to complete a NES emulator, I'd suggest trying something like Chip8 first, its extremely simplistic, well-documented and a quick project to complete. So I'd say thats a good beginners emulator.
 
Last edited:

BGNG

New member
I never tried an NES emulator. I simply stated that I never bothered to learn programming it. GBA, though, I am currently writing an emulator for it with no problems. I can see where I am and where I'm going, and it's all been easy and problem-free up to this point. As I said: the game code takes care of the big stuff. And believe it or not, it is my first emulator project. I was inspired to make it after looking up the assembly, because of the incredible ease it supports. (Yeah. The relative offsets for the B and BL commands baffled me silly. I'm easily amused)

But like you said: Chip8 WOULD be a good start for someone who knows nothing about emulators NOR programming for systems in Assembly. However, because of the way that ARM set up their opcodes (geniuses in my eyes), programming an emulator for that has been a breeze.
__________

In regards to the documentation I posted... I recommend looking at the NES opcodes and writing a disassembler for it, then doing the same with GBA. Once that's done, there's really nothing that can keep you from writing an emulator. That's half the work right there, and it's easy... just time-consuming.
 

aprentice

Moderator
I agree with the chip8 being a great beginners project. The NES is pretty complex, and I don't mean the cpu (which is a breeze to emulate), but the gfx system in the nes is incredibly complex as well as the sensative timing. You want a project to do after the chip8, do a gameboy emulator, its definately more easier, and i speak from experience.
 
OP
Toasty

Toasty

Sony battery
Thank you guys for the info. It sounds like, although it isn't quite the same as writing Tac-Tac-Toe, writing an emulator isn't quite as difficult as I had anticipated. I think I will try out the Chip8, since I really am pretty new to emulation. Now, I've come up with a second question (though you can still feel free to answer the first): How many people do you recommend?

Do most emulator writers just go it alone? If I plan to eventually write emulators for more complex systems, would you recommend finding a partner(s) now, or waiting until I get to that point? Thanks again for your replies - they're very helpful!
 
Last edited:

BGNG

New member
Chip8 sounds like a plan, then. Like zenogais suggested, there's a sticky here in this forum all about it.

Statistically, I believe most emulator authors do work alone. But that doesn't have to be the case. You could have a person do research, a person test programming, a person implementing opcodes, etc... All easy things for one person to do, but quicker and more harmonious with more people.

That ZIP file I attatched to my first post contains ALL the opcodes for both NES and GBA, as well as their functionality as to how to emulate them.

And if aprentice says Game Boy is easy, go with it. Game Boy Advance is easy as it is, so just how hard could Game Boy be? Keep that in mind for when you finish the Chip8 emulator.
 
OP
Toasty

Toasty

Sony battery
OK, sounds good. I'll probably get started on my own and then find someone to work with when I get into more complicated stuff. When that time comes, does anyone know of any good places to find newbies like me who'd want to work on a group project?
 

BGNG

New member
Hmmm... That's a good question. It's not like there's a big ol' box of newbies you can take some out of... Try asking some people you know. I know a guy who may be interested in working with you, so I'll give him a hollar.
 
OP
Toasty

Toasty

Sony battery
Kewl, thanks. After I've polished off a Chip8 emu I think a cooperative project would probably do well for me. I'm pretty busy, and couldn't devote a whole lot of time to the project (it would have to be more of a back-burner hobby project than anything formal). If that works with your friend, then perfect!
 

refraction

PCSX2 Coder
good luck with what you are doing, the chip8 emulator should be pretty easy for you, it baffles quite a few beginners but people with a reasonable amount of knowledge behind them should be able to put it together within a couple of days, plus bug finding can be quite fun as the documentation on the system isnt totally accurate.

When you do get it all working tho, you could try your other methods such as dynamic and static recompilation to get to grips with implementing it into an emulator, even if you are fantastic at it, its always good to put it into practice in anything you are doing, especially with emulation, because it can be quite tricky.

once youve finished that try making a gameboy emulator, it seems to be a popular second step, but the learning curve is more than double that of the chip8 system, but you will at least have the knowledge of the structure behind you :)
 
OP
Toasty

Toasty

Sony battery
Yeah, I implemented about half the opcodes last night and it's proving to be a pretty simple project. I couldn't believe how small those ROMs are (<500 bytes). The dynamic/static recompilation sounds like a good idea after I get the interpreting one working. Thanks for the suggestion.
 

Azimer

Emulator Developer
Moderator
N64 on PS2 is not impossible... just not worthwhile. You would need a complete understanding of PS2 hardware and N64 hardware before doing this. You would be investing very many months.
 
OP
Toasty

Toasty

Sony battery
Azimer said:
You would need a complete understanding of PS2 hardware and N64 hardware before doing this. You would be investing very many months.
I know - I definitely wouldn't embark on the project alone.
 

Cyberman

Moderator
Moderator
Toasty said:
I realize I have to start small, so I think the first logical step is probably something simple (well, less complicated) like the NES. Eventually, though, I'd like to write emulators for (running on) consoles - perhaps even the N64 emulator for PS2 that so many people say is impossible. If there's anyone reading this thread who's written an emulator, I'd be very grateful to hear how much you've done in emulation and how long it took you to get that far. Thanks in advance for your insights!
Well the problem with the PS2 is not what you might think. The PS2 is 'overly complicated and very difficult to program for'. I think in that case you will be investing more a year before you see any fruit to your labors, that does not include making the N64 emulator. :D Making PS2 games has turned out to be a problem and Sony is a bit out of sorts as a results. There is no question the PS2 is powerful, it's just extremely expensive to program for and difficult to work with.

Cyb
 
OP
Toasty

Toasty

Sony battery
With enough knowledgeable people it would be possible though, wouldn't it? The system itself is capable isn't it?
 

refraction

PCSX2 Coder
Toasty said:
With enough knowledgeable people it would be possible though, wouldn't it? The system itself is capable isn't it?


an Athlon 64 3400 struggles to run emulation above half speed, the N64 doesnt even have half the power of that, probably not even a quater.

i think that says how fast it would be ;)

also i dont think the graphics chip on the n64 could handle PS2 graphics
 

zenogais

New member
If you're going to be writing a Nintendo 64 emulator for the Playstation 2 first you would have to find a decent compiler (for free probably) and a decent SDK (for free as well) then you would probably spend most of your time just getting the raw emulation working (interpret/dynarec) as well as abstracting whatever API you were using to make it more usable. Then once you realized that using the API alone wouldn't produce the speed you need, you spend alot of time writing hand coded inline assembly into the source code to speed up alot of operations. My guess is it would take a few years at best.
 

BGNG

New member
refraction: You've got it backwards. This is a discussion about a Nintendo 64 emulator being run on a Playstation 2...

Which is only barely applicable to the topic of this thread.

I have seen all the internal workings of the Nintendo 64; its functionality and CPU memory map. I can assure you that writing an emulator for it on Playstation 2 is neither impossible nor difficult. Interperatation is not necessary for MIPS Assembly opcodes, because their corresponding operations are stored in a fixed set of bits, unlike the ARM opcodes of GBA which vary depending on their functionality.

It is ludicrously easy to write an emulator for one system in Assembly for another system which has less functionality; as is the relationship between Playstation 2 and Nintendo 64. The reason it may seem "impossible" is because most console developers are still child programmers stuck in the realm of C++. Writing for Assembly IN Assembly is easy, as it requires only a simple Jump command and a push to the stack.

After all... I have yet to see a higher-level programming language able to optimize its machine code as well as a human can. And said higher-level languages, with the exception of the concept of the less-effective Procedure Callback, is completely unable to call a section of code with a number and without using interrupts.
__________

Anyways...

Toasy... My buddy, whom I mentioned earlier, does not wish to work with you in your Chip8 project, as he is unconfident in his programming ability dispite the fact he's been at it for a few years. Sorry if that let you down.
 

Top