Emulator in Blitzmax?

BlitzMax Forums/BlitzMax Programming/Emulator in Blitzmax?

remz(Posted 2008) [#1]
Hi everybody,

[EDIT]
The emulator project is now complete! Have fun!
Here's a link to the emulator project site:
http://rveilleux.googlepages.com/blitzmaxarcadeemulatortutorial
[/EDIT]

I'm thinking of doing a tutorial-like approach to create a old arcade machine emulator in Blitzmax.

The ultimate goal is educational, there is nothing as satisfying as seeing a game boot to life, running emulated code thru your own work.

So my question is: would you be interested in seeing and creating your own arcade emulator* in Blitzmax?

*Note: I'm planning on doing one machine in particular, not a 'multiple-arcade' like MAME or MESS which would be exponentially harder.


daaan(Posted 2008) [#2]
I've considered emulating Space Invaders or Pacman.. but never got too excited about writing an 8080 core.

But to answer your question. Yes I would be interested in your tutorial.


amonite(Posted 2008) [#3]
Hello,

That would be very interesting.


kochOn(Posted 2008) [#4]
DO IT! DO IT! ;)


Zeke(Posted 2008) [#5]
VIC-20 emulator or sega-8bit :O


Who was John Galt?(Posted 2008) [#6]
Someone did emulate a spectrum and a couple of Z80 based arcade machines in Blitz (not Max) a while back. The source for some of it was available.


Twitchfactor(Posted 2008) [#7]
I would love my beloved Atari 8-bit emulated.


CS_TBL(Posted 2008) [#8]
Emulating a z80 shouldn't be the hardest part.. emulating videochips and audiochips are usually the tough part.


Russell(Posted 2008) [#9]
Are there any systems, consoles or arcade games that haven't already been emulated by someone? How about a Cray XMP Super Computer emulator?! ;)

Russell


Czar Flavius(Posted 2008) [#10]
Russel, I agree. But what can be done? Liberty will prevail over all oppression.


remz(Posted 2008) [#11]
Awesome people.

The project has started. I am doing like Dan suggested a 'Space Invaders' emulator, mostly because it's probably one of the easiest game to emulate and because there is so much information available on the net.

The project is going well, I'll be posting the first tutorial in a couple of days.

Thanks and see you soon!


ImaginaryHuman(Posted 2008) [#12]
Had thought of how cool it would be to do a hardware-accelerated Amiga emulator, but obviously that's a very complicated task.


remz(Posted 2008) [#13]
If you have tried WinUAE, the amiga emulation is pretty good. I don't know specifically what you would like to be faster by making it hardware-accelerated: if you mean the graphic subsystem, you could maybe have the blitter doing copyrect accelerated but as you said, that would be a very complicated task. A modern PC CPU is able to emulate an entire Amiga at full speed or even faster.

That said, the amiga has several processor (copper, blitter, CPU) running in parallel along with freakingly precise timing syncronisation with the video signal. And there's some DMA running also. Wow. I wonder how much work has gone into WinUAE to make it so perfect.


ImaginaryHuman(Posted 2008) [#14]
Yah I know it's fast already but there's surely room for improvement. Throw in some OpenGL hardware accelerated graphics and maybe using the GPU for general computing simulation.


Sledge(Posted 2008) [#15]
I'm glad you're doing this project and I'll be following along, but Max is an odd choice -- without a pure 2d graphics mode, rendering a video buffer is going to choke your performance. There's a reason why you don't see many raycasters hereabouts :)


remz(Posted 2008) [#16]
Sledge, writing into a pixmap is a sort of video buffer and it's pretty fast.
In fact I do have a working "wolf-3D style" raycaster in BMax and it's ultra fast. I might post it if you would be interested to see.


nawi(Posted 2008) [#17]
If you're going to emulate just one game, it is pretty easy. To emulate a complete game console is 10x harder.


Sledge(Posted 2008) [#18]
In fact I do have a working "wolf-3D style" raycaster in BMax and it's ultra fast. I might post it if you would be interested to see.

Definitely!


remz(Posted 2008) [#19]
Alright, there you have it:
http://rveilleux.googlepages.com/blitzmaxwolf-3dstyleraycaster


GregBUG(Posted 2008) [#20]
hi remz...

tested your 3d app but only a window with black screen here!

tested on win vista (svga geforce 8400m gs 256mb)


Sledge(Posted 2008) [#21]
That's ace, much faster than I would've expected -- are you using PixmapPixelPtr()?


remz(Posted 2008) [#22]
Sledge: yes, PixmapPixelPtr casted in a int ptr: The pixmap is created with PF_RGBA8888: if you use the regular "Byte Ptr" returned by PixmapPixelPtr(), you can access the components one by one (R, G, B, A). But if you cast it in a Int Ptr you can write a whole 32-bit pixel value in one shot.

Gregbug: thank you! I've tried it on a Vista machine and got the same result. I've compiled a version with OpenGL instead of DirectX, works perfectly now. You can find the new version on the same page:
http://rveilleux.googlepages.com/blitzmaxwolf-3dstyleraycaster


GregBUG(Posted 2008) [#23]
wow! works perfectly!!!
and fast!


remz(Posted 2008) [#24]
Alright, the first two little chapters are online and ready to be read and checked!

I would be very interested in hearing feedback from you guys, and I'll be going on with the emulator as fast as I can.

http://rveilleux.googlepages.com/blitzmaxarcadeemulatortutorial


Hotshot2005(Posted 2008) [#25]
Hey Remz,

That was great(and fast too) and I also bring your files size down from 295KB to 89KB :)

IF you want the compress files then let me know and I will send to you.


Brucey(Posted 2008) [#26]
Part 3 please :-)


amonite(Posted 2008) [#27]
Cool :)
please more !
thanks


Nennig(Posted 2008) [#28]
nice thanks


SebHoll(Posted 2008) [#29]
This seems really interested - thanks. I've also wondered how emulators actually work under-the-hood... I shall be keepings tabs on this thread...

Keep up the good work! Looking forward to Part 3 and beyond...


Russell(Posted 2008) [#30]
Are we emulating the actual hardware of the original, or re-creating the games verbatim? (ie: Emulating a Z80 running actual Z80 code, etc).

Should be interesting to see what kind of performance you can manage! (I have a 166Mhz system lying around to test it on...)

Imagine running a PC emulator on an emulated Amiga running on a PC. Could it work? Yes. Would it be slow? Absolutely! :)

Russell


remz(Posted 2008) [#31]
Emulation of course :) The CPU is an Intel 8080. Performance is not the main goal of course, but my typical iBook G4 will be able to run the game at full speed in release mode.

I'm wondering what kind of performance your 166Mhz is going to get, if the program boots at all :) Have you tried any Blitzmax stuff on that antique?


Genexi2(Posted 2008) [#32]
I've had an interest in wanting to code an emulator (of the good ol' NES) for a long while, so I'm quite interested in this, even if it is for a non-relevant system.

The main thing I could never grasp was how to set code up so it emulates hardware, and from there, knowing how to interpret rom information and then applying it to said emulated hardware....

By anychance will you be coding the entire thing in a manner that'll be adaptable to Blitz3D? Keeping my eye on this otherwise.


Jesse(Posted 2008) [#33]
thanks for all 3 parts. Much apreciated. looking forward to the rest of the tutorial.


remz(Posted 2008) [#34]
whew.. Part 4 is online!


Brucey(Posted 2008) [#35]
Please stick the link in your first post, so we don't have to remember (look for) it :-)


Matthew Smith(Posted 2008) [#36]
Remz,

As a user of Mame from the very start (well almost v0.05), this stuff is so interesting! Thanks for the explanation - can't wait to see the end result!

I thing I could suggest, please add a link on your front page to each new chapter??


amonite(Posted 2008) [#37]
Excellent tutorial !

I'm following it with great interest.

Thanks a lot remz.


Koriolis(Posted 2008) [#38]
That's realy entertaining remz. A very pleasant reading. Keep them coming.


ziggy(Posted 2008) [#39]
@remz: Impressive. I completely agree with Koriolis


degac(Posted 2008) [#40]
Yes very interesting!


Jesse(Posted 2008) [#41]
I tried to figure out the next instruction, is it
  Case $31
      setsp(FetchRomShort())

or something similar.
Just wondering.:)
[edit]
if that is correct(long shot) than maybe the next instruction is
   Case $06
	setB(FetchROmByte())


but I am stuck on $CD I am interested in seeing how that one works. I know that is a function call but it must store the current address in a stack and maybe push register/s. I am guessing ofcourse.


AltanilConard(Posted 2008) [#42]
Great tutorials, I'm really learning alot from it allready. I love the look of the website too. I'm eagerly waiting for the next chapter. :)

ps. One small bug (I think), on the main page, whatever chapter I click it will allways bring me to chapter 1.


remz(Posted 2008) [#43]
Hi everyone and thank you very much for your interest. I have hopefully fixed the quirks on the website.

Jesse, you are right, both instructions are perfect.
I hope you enjoy the rest of the tutorial, parts 5 and 6 and online now!

My work here is done.


Jesse(Posted 2008) [#44]
great remz. Thank you for such a great work. I have learned a lot from it.


DavidDC(Posted 2008) [#45]
Brilliant!


Matthew Smith(Posted 2008) [#46]
Remz,

Great stuff mate! very informative!!

so, how about pacman??


CS_TBL(Posted 2008) [#47]
remz: check your tutorial text, at a few points it talks about $1ffff, $3ffff etc. and one certain 'f' in these numbers should go. :P


SebHoll(Posted 2008) [#48]
@Remz: Can I suggest you post a new topic in the BlitzMax Tutorials section as I thought these tutorials were really well-written and certainly very interesting! :D


remz(Posted 2008) [#49]
CS_TBL: oops thanks, just fixed that!

SebHoll: sure, great idea: I posted a new tutorial. I might also post a screenshot of the finished game running, on Blitz gallery.


degac(Posted 2008) [#50]
one of the coolest thing I've read. Thank you!