Console Game Emulation

BlitzMax Forums/BlitzMax Programming/Console Game Emulation

William Drescher(Posted 2009) [#1]
Ok, so it's high time I asked this question.

Does anyone have a good guide to writing game emulators that are for, or easy to port to, BlitzMax. I'm specifically looking for N64 ROM type emulators.

Any help on this would be great. Thanks.


Brucey(Posted 2009) [#2]
Someone did a wonderful tutorial once which created a proper emulator...

Anyone got the link for it? :-)


REDi(Posted 2009) [#3]
http://rveilleux.googlepages.com/blitzmaxarcadeemulatortutorial


William Drescher(Posted 2009) [#4]
Ok, that's seriously awesome right there, thank you very much for that website.

Now here comes the tricky part. Does anyone know of maybe a website that has tutorials on how to load a ROM with all the sound and graphics files self-contained in it? The one for that arcade game used separate sound files which won't work very well for a cartridge game ROM.

My idea I'm trying to bring to life is a Nintendo game emulator (Hopefully it will become an All-In-One, allowing people to use this one emulator to run NES, SNES, N64, GB, and GBA games). I'm doing this because I'm running into dead ends when it comes to finding good N64 emulators for Macs and also this seems like it would be a good way to expand my programming abilities.

Before anyone has the chance to say anything, yes, I googled this, but I would like some feedback, like preferred websites or tutorials, on the subject.

Any information would be helpful, thanks in advance.


daaan(Posted 2009) [#5]
Start with a Chip-8 emulator. Then go onto GB, then NES, and so forth.


Who was John Galt?(Posted 2009) [#6]
An N64 emultator is quite a tall order. As dan said, start small. I'm assuming the NES is based around a Z80 or 6502 variant. Read a book on assembly language for the target processor and write something to emulate it. That will put you well on the road to creating an emulator for the complete machine.


Nate the Great(Posted 2009) [#7]
or maybe it would be fun to write your own cpu emulator... no specific cpu in mind. Make an assymbly language for it and write a compiler for basic for it :) fun stuff.


Corum(Posted 2009) [#8]
This is a big source of information if you're aiming to NES emulation, mainly to catch the big picture:
http://graphics.stanford.edu/~ianbuck/proj/Nintendo/Nintendo.html
More hardware than software oriented, but includes good documentation references and architectural details.
Happy coding! ;)


Ked(Posted 2009) [#9]
That is an awesome link! I feel like attempting to create a SNES emulator now. Please note that "attempting" is bold.


Dabhand(Posted 2009) [#10]
I recall someone wrote a speccy emulator in good auld BlitzBasic and released the source... I was well impressed! :)

Dabz


Ked(Posted 2009) [#11]
Actually, this tutorial really doesn't work with console emulation. Unless I'm not getting something... :) I've tried GBA, SNES, and NES emulation to no avail.

GBA has a 32-bit processor, so wouldn't I use ints instead of bytes? I can't find instruction sets for SNES nor NES processors, so I'm done with those. :)


Jesse(Posted 2009) [#12]
snes instruction set:
http://www.emulatronia.com/doctec/consolas/snes/spc.htm


Ked(Posted 2009) [#13]
@Jesse: The SNES CPU is a custom 16-bit 65c816 Ricoh 5A22. The SPC is a co-processor. I need the instruction set for the Ricoh, don't I?


Russell(Posted 2009) [#14]
Programming a hardware emulator is a LOT of work! Make sure you know what you are getting into before you get into it...and become overwhelmed by the complexity. If you are still interested, here's a good place to start:
http://en.wikibooks.org/wiki/Super_NES_Programming

Good luck!
Russell


xlsior(Posted 2009) [#15]
Ked: You'll need the instruction sets for ALL processors / coprocessors / custom chips... Not for the faint of heart, to put it mildly.

also, for any emulator to be functional, you'll also going to need things like ROM images of the (copyrighted) on-board ROM chips, which would be illegal to distribute with your program which would severely limit its usefulness to most people.


Ked(Posted 2009) [#16]
Thanks, Russell, I used that for the registers.

What I really need to know though is if I should read a byte at a time from the ROM image or a short at a time? I have yet to come across some information that tells me which one I should use. If I use the byte, then I keep getting the BRK instruction which is only used in NES emulation mode, so that's wrong.


Jesse(Posted 2009) [#17]
you know, some emulators include the source code. you can look at them and extract what you need from them.
zsnes
http://www.zsnes.com/index.php?page=files
snes9x
http://www.geocities.co.jp/SiliconValley-PaloAlto/2560/snes9x.html

this should be alot easier than reading through hundreds of technical documents.


theHand(Posted 2009) [#18]
There are plenty of emulators. Blitzmax is not what you want to go with, either. The reason being, if you run into a scenario like needing to do something currently beyond the capabilities of Blitzmax (definitely possible), you will become really frustrated. Learn C and do it properly (and have full control over everything); the Allegro library will allow you to do everything you want and still have it be cross platform, and has a "giftware" license just like Blitzmax (Allegro is also multi thread-safe). And PCC is a mostly working compiler, but since you'll have a lot of trouble getting support (but only because it is not yet mature), learn with g++. By the time you learn C++, PCC will probably be mature. I'm depending on it being mature by the time I learn Blitzmax, and subsequently work on and finish my project in Blitzmax, actually.


Nate the Great(Posted 2009) [#19]
I dont see how this is beyond the capabilities of blitz max. Firstly, why do you need threads for emulation. And also what do you need that is not already with blitz max. If worst comes to worst, program it in c and use extern import or something like that, I havent used it in a while.


theHand(Posted 2009) [#20]
The only thing that might be beyond Blitzmax would be some kind of esoteric low level routine, or something. Other than that, it is entirely feasible.