What's new

Where should I begin from?

Tesla-Guy

Moderator
Hey!

I doubt any of you still remember me, since i've left the emulation scene some 5 years ago.
Anyhow! As a new coder studying informatics and telecommunications and having learnt C quite well, i've decided to start on programming my first emulator.
This question is mainly addressed to the admirable coders of the emulation scene:
Where should I start from, considering i'd be developing for linux on C?
Where did you start from?
What libraries should I check out?
Where do I find them?

Thanks in advance!!
 

twiztidgamer

New member
im no programmer but i can easily say that this forum is fully loaded with all the info you need just look around a little and the info will pop right out

but i would recommend you start small. dont try and jump right into the n64 or anything ya know?... i know theres a thread on here thats totally dedicated to gameboy emulation somewhere. but that might even be to big... if i find it ill let ya know
 

nmn

Mupen64Plus Dev.
Do you know how to program with SDL and OpenGL? If not, you may be interested in that. As Linux is your main platform, you should also learn how to do things the POSIX ways (Your applications will port to Windows with a little hassle, but Cygwin can help you with that.)

OpenGL and SDL are basically the 2 most common graphical libraries for going across platforms. On Linux you basically never directly program into X11/GLX (Well, most people these days don't unless they are deving a game engine or a library that abstracts it) so SDL and OpenGL fit well. SDL will handle anything including 2D graphics, but once you wish to get into 3D you can also use SDL to handle your OpenGL context.

If this is making little sense, I recommend you force yourself to traverse Wikipedia - You'll figure it out eventually if you try hard enough (I've been sucessful doing this myself though it was hard...)

Additionally, if you wish to maintain a Windows port, you can cross compile a MinGW toolkit, but this is very annoying for beginners so i just recommend using Visual Studio on a native Windows computer (If you can handle it, It's too freaking hard for me, the error messages make no damn sense sometimes...)
 

Cyberman

Moderator
Moderator
Hmmm well here is the thread he was talking about it's one of the many STICKIES in the forum :D
Look at the stickies for various platforms to emulate. I suggest the simplest ones first. Don't try too much just like everyone had to learn 1 + 1 = 2 before they learned that any finite number divided by infinity was zero.
There is also a list of resources amongst the stickies. (IE programming resources) let me know if any of the links are dead. :)

Cyb
 

Allnatural

New member
Moderator
Could you code me a ps3 emu please? I downloaded lots of roms already but I don't have the emu to play them. I've got dual-core so that should be fast enough for ps3 emu. :bye3:
 

CodeSlinger

New member
Hi mate,

I have recently started learning emulation programming and completely agree with the advice to learn SDL and OpenGL for graphic programming. Pretty much all Linux emulators out there use this, mainly so they can also port them to windows.

Dont worry about sound emulation for now as this imo is the most difficult part of emulation. Plus you can write an emulator without getting the sound working and then just plug that in afterwards.

As you are new to programming do not start with the Gameboy. It has turned out to be much more difficult then I imagined and also is a much bigger project then I thought it would be. Most people of the experienced programmers on this forum took a good 6 months to get it working.

I strongly recommend you start with the chip8 emulator like i did. It only took me about 4 hours to finish as there are only 35 instructions to emulate. Then depending on how confident you felt with it you can either start a gameboy emulator like I did or a Space Invaders emulator which is easier (but still nicely advanced from the chip8)

The sticky thread at the top of this forum contains everything you'll need to get started on the chip8 emulator.

Another plus point about the Chip8 is that you can get it emulating nicely without any graphical programming and just use ascii art inside the terminal. You can use this technique to find all the bugs in the CPU and once the CPU is fully emulated you can take out the ascii art and replace it with OpenGL and SDL.

Good luck mate and enjoy!
 
OP
Tesla-Guy

Tesla-Guy

Moderator
Do you know how to program with SDL and OpenGL? If not, you may be interested in that. As Linux is your main platform, you should also learn how to do things the POSIX ways (Your applications will port to Windows with a little hassle, but Cygwin can help you with that.)
No experience at all i'm afraid.. ofcourse I know what you're talking about, i'm aware of both libraries, have to learn how to use them though because as a 1st year student I haven't programmed anything related to gfx. I guess i'll google / wikipedia for them, and i'll try and get some manpages for their functions if they are not already included in the manpages-dev package.

Additionally, if you wish to maintain a Win...
No. I only code on real OSes for now :p
Seriously, though, my prime concern is to learn how to do it. Porting to spread it around won't be needed as i'd be only giving it to other uni students, 80% of which have linux installed as a primary/secondary OS.
I'll stick to your advice and go study for this stuff, after my exams are over in 1 month.

Could you code me a ps3 emu please? I downloaded lots of roms already but I don't have the emu to play them. I've got dual-core so that should be fast enough for ps3 emu. :bye3:
Me have it ready plays gta IV FULL SPEED!! ! !1 ! 1! want? :D

Hi mate,

I have recently started learning emulation programming and completely agree with the advice to learn SDL and OpenGL for graphic programming. Pretty much all Linux emulators out there use this, mainly so they can also port them to windows.

Dont worry about sound emulation for now as this imo is the most difficult part of emulation. Plus you can write an emulator without getting the sound working and then just plug that in afterwards.

As you are new to programming do not start with the Gameboy. It has turned out to be much more difficult then I imagined and also is a much bigger project then I thought it would be. Most people of the experienced programmers on this forum took a good 6 months to get it working.

I strongly recommend you start with the chip8 emulator like i did. It only took me about 4 hours to finish as there are only 35 instructions to emulate. Then depending on how confident you felt with it you can either start a gameboy emulator like I did or a Space Invaders emulator which is easier (but still nicely advanced from the chip8)

The sticky thread at the top of this forum contains everything you'll need to get started on the chip8 emulator.

Another plus point about the Chip8 is that you can get it emulating nicely without any graphical programming and just use ascii art inside the terminal. You can use this technique to find all the bugs in the CPU and once the CPU is fully emulated you can take out the ascii art and replace it with OpenGL and SDL.

Good luck mate and enjoy!
Your post has been enlighting. I was thinking gb, as twiztidgamer said in the previous post, it would be more self-satisfactory, but i'll indeed begin with the Chip8 then.
Took you only 4 hours ? How many lines?
About the ascii art, you mean curses, right? I wouldn't imagine having to give system calls to refresh the screen :)

@Cyberman: I bookmarked your links, thanks! I'll keep that in mind after I finish this chip8 thing.

Thank you all for your posts!! I really appreciate it, i'll update this thread with my progress and furthermore questions! In the mean time i'll be checking the thread, so feel free to post any further advice and suggestions! Thank you all for your time

PS: DAMN i hate this nickname, what the heck nicknames did i come up with when i was 12 ..
 
Last edited:

CodeSlinger

New member
Yeah it took 4 hours. Not including the time it took me to read up on the system and understand exactly what I was going to do before I started any programming. I couldnt tell you how many lines the emu was as the source code is on my pc with a blown power supply :-(

And yes i meant ascii art and did have to call clear screen lol. I used it for all of 10 minutes to confirm that the CPU was working. As soon as i saw the blocks in WIPEOFF appear I replaced it with my graphics library. As i'm a game programmer I already had a working set of graphic libraries which is another reason it only took 4 hours :)

The chip8 is really a very simple system. There are only 35 instructions to implement and 90% of them are easy and only take 2 mins to emulate.

To code a chip8 emu you will need the following programming knowldege:

1. File Input so you can load a rom into memory.
2. Bit manipulation. Logical AND, OR, XOR and shifting.
3. Register emulation (it's just an array of bytes)
4. How to read keypresses to check for player input
5. Playing a beep noise for sound emulation (really simple on chip8).
6. Reading bytes from memory to form the next instruction to call.
7. A bit of hexadecimal understanding is useful.
8. How to mask of parts of the next opcode to get the data needed.

Good luck mate. When you get round to starting it just post in the chip8 sticky forum and I'll try and lend a hand.
 
OP
Tesla-Guy

Tesla-Guy

Moderator
check! all except 8, can't figure out what you mean, perhaps i'll understand when I begin.
Studying in greece is awesome, i was coding a crossword solving program (~1k lines) (takes a dictionary an empty crossword and fills it) when a friend 1st year too in the UK was learning what loops were. and i'm not joking. :p ..well except everything is in greek and I can't understand a phew terms, like point 8.
 
Last edited:

CodeSlinger

New member
Opcode 1NNN means jump to address NNN. So if the instruction was 1675 you need to mask off the 1 to get 675.

I recommend you use wikipedia for the Chip8 Documentation. It contains everything you need. I found its opcode explanations the most accurate.
 
OP
Tesla-Guy

Tesla-Guy

Moderator
Opcode 1NNN means jump to address NNN. So if the instruction was 1675 you need to mask off the 1 to get 675.

I recommend you use wikipedia for the Chip8 Documentation. It contains everything you need. I found its opcode explanations the most accurate.

OK, it's easy. Thanks again! :)
 

AamirM

New member
Hi,

I'd suggest to learn and do sound emulation side by side instead of leaving it for later.

stay safe,

AamirM
 

Top