zBoy - A GameBoy emulator

User projects written in or related to FreeBASIC.
Fox
Posts: 353
Joined: Aug 08, 2006 13:39
Location: Lille, France
Contact:

zBoy - A GameBoy emulator

Postby Fox » Sep 02, 2010 17:38

Hi there!

Just a quick note to say that I started a GameBoy emulator written in FreeBASIC! :)

The emulator is not in any useable state yet, it partially emulates the Zilog Z80 CPU, some I/O routines, and some basic GameBoy stuff.

Here's a quick description of my emulator project:
http://www.viste-family.net/mateusz/software/zboy/
Last edited by Fox on Sep 03, 2010 17:48, edited 1 time in total.
angros47
Posts: 1382
Joined: Jun 21, 2005 19:04

Postby angros47 » Sep 02, 2010 19:24

Great!

And a Z80 emulator could also be used for other models (like ZX Spectrum)!

For now, the only emulator written in FB was Commodore 64: would be great to expand the family.
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Postby Ryan » Sep 03, 2010 1:44

Excellent. : ) I still have a Gameboy w/ Flipull sitting by my bed (among other games... it's actually a GB Color, so I have the Dragon Warrior 3 remake which rocks).
Fox
Posts: 353
Joined: Aug 08, 2006 13:39
Location: Lille, France
Contact:

Postby Fox » Sep 03, 2010 17:48

angros47 wrote:And a Z80 emulator could also be used for other models (like ZX Spectrum)!


Well, in fact, the GameBoy doesn't come with a real Z80, it's a specific Z80-alike CPU, therefore the emulation CPU core won't be usefull in any other Z80-based project, as this is technically not a Z80 :)

I uploaded the Linux build right now on my website, as well as source code. Enjoy! ;-)
Fox
Posts: 353
Joined: Aug 08, 2006 13:39
Location: Lille, France
Contact:

Postby Fox » Sep 10, 2010 13:50

Hi!

I must admit that I am somewhat stuck right now with my GameBoy emulation project :-/
In fact, I'm pretty sure that my Zilog (CPU) emulation is buggy, because some games that should work, doesn't.

Debugging the CPU step by step is a real pain in the **s, as there are several thousands of instructions executed per seconds, and there's simply no chance for me to analyze step-by-step all the execution of a game...

I even wrote a little program which compiles GameBoy roms with various random instructions, and then I execute such random-generated ROM, and see if instructions are executed properly - but again, it's humanly impossible to check everything such way.

Does anybody have any idea about "how to debug a CPU emulator" ? I though deeply about that, but can't find out any efficient way of testing my emulator, to discover all bugs in it... And without knowing where the bug is, it's very difficult to fix it :-P
Merick
Posts: 1038
Joined: May 28, 2007 1:52

Postby Merick » Sep 10, 2010 22:59

My suggestion would be to go to an emulation specific board (like for vba or zsnes) and ask them how they did the debugging on their emulators
kiyotewolf
Posts: 1009
Joined: Oct 11, 2008 7:42
Location: ABQ, NM
Contact:

Postby kiyotewolf » Sep 11, 2010 23:27

Do you mean to say you're using random numbers (which translate to valid CPU opcodes) to test your virtual CPU?

<.< I helped fix the C=64 emulator.. I can give a shot at debugging yours too, although it's going to be a bit more trouble for me, as I'm not nearly as familiar with Z80 opcodes..

Please go into detail, on how you're testing, whether you're asking the CPU to do a simple thing like add some numbers, or are you trying to make it do something like the silly walk, like in Monty Python's Flying Circus?

~~~

If you're asking the CPU to do very random things, telling what it's doing is going to be tough as hell.

Do you yourself know how to program in Z80 ASM?

~~~

IMHO, get a homebrew rom, for the gameboy, one of those tiny simple tech demos, and use that as your base code to test with.

Using a full blown ROM, from a licenced game, will not be easy, using a tiny little blurt of a program will let you test it and have some ease of finding glitches, cause the length of the bytes will be MUCH shorter, when debugging line by line.



~Kiyote!
Fox
Posts: 353
Joined: Aug 08, 2006 13:39
Location: Lille, France
Contact:

Postby Fox » Sep 14, 2010 16:58

kiyotewolf wrote:Do you mean to say you're using random numbers (which translate to valid CPU opcodes) to test your virtual CPU?


No :)
I wrote a little program, which knows many opcodes, and makes a valid GameBoy ROM using thousands of randomly chosen opcodes (with appropriate parameters to every opcode).

kiyotewolf wrote:I helped fix the C=64 emulator.. I can give a shot at debugging yours too, although it's going to be a bit more trouble for me, as I'm not nearly as familiar with Z80 opcodes..


Debugging it is a real hell :)
In fact, I'm not asking for anyone to debug it - it's *way* too much to ask for anyone :) I'm just wondering if anybody has an idea about how to test the emulator in a more efficient way than I am doing now...

kiyotewolf wrote:If you're asking the CPU to do very random things, telling what it's doing is going to be tough as hell.


What I am doing now, is that I am executing such randomly-generated ROM on my emulator in one window, and also in the no$cash emulator (which comes with an integrated debugger) in another window, and then I am looking how registers are changing after each operation... But again, I'm starting loosing my eyes doing this :-/

kiyotewolf wrote:Do you yourself know how to program in Z80 ASM?


Not enough to code my own game, but enough to understand all CPU operations :)

kiyotewolf wrote:IMHO, get a homebrew rom, for the gameboy, one of those tiny simple tech demos, and use that as your base code to test with.


This might sound reasonable. Of course, it was my first idea... Unfortunately, even a simple ROM has too much instructions for a human to analyze it step-by-step :-/
This is due mostly to the video system, which allows to write to video memory only during a vblank period, so every ROM is looping through a short procedure checking if we're in vblank or not, and this is performed few thousands times a second...
Pritchard
Posts: 5431
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Postby Pritchard » Sep 14, 2010 18:02

And here I was hoping you could just step over the vblank check procedure automatically.
Eponasoft
Posts: 262
Joined: Jul 26, 2007 2:40

Postby Eponasoft » Sep 14, 2010 19:34

Pritchard wrote:And here I was hoping you could just step over the vblank check procedure automatically.

He can... at least for commercial ROMs. The official GB assembler has a macro for waiting for vblank and, from what I've seen, most companies used it, so the code should be identical across ROMs. It might differ for homebrews though. A simple ROM is definitely going to be the best, but if not, then a simple game like SML would be best to test with. KISS is the best way to start out an emulator... for example: when I made my CHIP-8 emulator, I started out with MAZE, the simplest of all known CHIP-8 programs, and didn't stop until it worked perfectly. :)
relsoft
Posts: 1767
Joined: May 27, 2005 10:34
Location: Philippines
Contact:

Postby relsoft » Sep 14, 2010 22:11

Fox:

You have a debug version of No$?!!!

You're one lucky sod! I'm jealous.
Eponasoft
Posts: 262
Joined: Jul 26, 2007 2:40

Postby Eponasoft » Sep 15, 2010 0:15

He didn't say he BOUGHT it... :)
kiyotewolf
Posts: 1009
Joined: Oct 11, 2008 7:42
Location: ABQ, NM
Contact:

Postby kiyotewolf » Sep 15, 2010 1:36

o.o he borrowed it from his programming Aunt 100010111



~Kiyote!
Fox
Posts: 353
Joined: Aug 08, 2006 13:39
Location: Lille, France
Contact:

Postby Fox » Sep 16, 2010 16:38

relsoft wrote:You have a debug version of No$?!!!

You're one lucky sod! I'm jealous.


No need to be. Read what follows.

Eponasoft wrote:He didn't say he BOUGHT it... :)


Nope, I definitely not bought it...

kiyotewolf wrote:o.o he borrowed it from his programming Aunt 100010111


...nor I borrowed it from any relative of mine.

You all seem to be unaware that NO$GMB is *free*.
Really.

http://nocash.emubase.de/ wrote:The old (monochrome) gameboy emulation, and the Super Gameboy features are freeware, and do not need to be registered (...)


If you are interested, simply download it from there:
http://nocash.emubase.de/gmb.htm

Going back to my emulator: the idea of skipping the vblank procedure check sounds nice! I didn't knew that that such procedure might be common to many games - I will check this out, and compare few ROMs. If it's true, I will probably be able to detect it within my emulator, and use a specific step-by-step-with-skipping-vblank-checks mode to debug it further. :)

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 3 guests