Gameboy on 32X

Announce (tech) demos or games releases

Moderator: Mask of Destiny

mic_
Very interested
Posts: 265
Joined: Tue Aug 12, 2008 12:26 pm
Location: Sweden
Contact:

Gameboy on 32X

Post by mic_ »

Here's something I've been tinkering with a bit lately:

ImageImage

It's dog slow right now, because the code is all plain C that hasn't been optimized or tweaked for the 32X. There's also some weird bug that seems to corrupt the ROM if I add a .gb file larger than 128kB (this doesn't happen with the PC version).
ob1
Very interested
Posts: 468
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 »

Hey ! Looks interesting.
;)
Any way to look into your sources ?
mic_
Very interested
Posts: 265
Joined: Tue Aug 12, 2008 12:26 pm
Location: Sweden
Contact:

Post by mic_ »

Perhaps after I've cleaned it up a bit and fixed some bugs. Right now it's quite useless.
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) »

wow, this is awesome Ö
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
AamirM
Very interested
Posts: 472
Joined: Mon Feb 18, 2008 8:23 am
Contact:

Post by AamirM »

Dude, that is just so cool and awesome!!
Jorge Nuno
Very interested
Posts: 374
Joined: Mon Jun 11, 2007 3:09 am
Location: Azeitão, PT

Post by Jorge Nuno »

W00t! :o

Doesn't the gameboy have the Z80 as a CPU? maybe it could be ran "almost" natively on the megadrive.
Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru »

Jorge Nuno wrote:Doesn't the gameboy have the Z80 as a CPU?
Not, it has it's own unique CPU, something between 8080 and Z80, partially compatible.
Jorge Nuno
Very interested
Posts: 374
Joined: Mon Jun 11, 2007 3:09 am
Location: Azeitão, PT

Post by Jorge Nuno »

Well what if the 68k supervises the code for z80 unknown instructions and handle them, while it feeds the z80 with pure code. I don't know if it is possible to do that fast enough, doing the address translation at the same time.
mic_
Very interested
Posts: 265
Joined: Tue Aug 12, 2008 12:26 pm
Location: Sweden
Contact:

Post by mic_ »

I've looked at the SH2 assembly that gcc generates (I'm compiling with -O2) for my emulator, and it's a real piece of crap compared to what even an SH novice like me could accomplish. To achieve any kind of decent speed - especially for the CPU emulation - it'd probably be necessary to write the whole thing from scratch in assembly.
mic_
Very interested
Posts: 265
Joined: Tue Aug 12, 2008 12:26 pm
Location: Sweden
Contact:

Post by mic_ »

Just as an example; a function that contains only "return 0;" gets compiled into:

Code: Select all

	mov.l	r14,@-r15
	mov	#0,r0
	mov	r15,r14
	mov	r14,r15
	rts     
	mov.l	@r15+,r14
Plain awesomeness.. :roll: That could be reduced by 67%. And it just goes on like that.
TMorita
Interested
Posts: 17
Joined: Thu May 29, 2008 8:07 am

Post by TMorita »

mic_ wrote:Just as an example; a function that contains only "return 0;" gets compiled into:

Code: Select all

	mov.l	r14,@-r15
	mov	#0,r0
	mov	r15,r14
	mov	r14,r15
	rts     
	mov.l	@r15+,r14
Plain awesomeness.. :roll: That could be reduced by 67%. And it just goes on like that.
GCC is creating a stack frame. You need to use -fomit-frame-pointer to disable this.

Toshi
mic_
Very interested
Posts: 265
Joined: Tue Aug 12, 2008 12:26 pm
Location: Sweden
Contact:

Post by mic_ »

GCC is creating a stack frame.
Yes, I know, it's the same on most processors. That was just an example of the overall (lack of) quality of the code.
Chilly Willy
Very interested
Posts: 2993
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy »

mic_ wrote:
GCC is creating a stack frame.
Yes, I know, it's the same on most processors. That was just an example of the overall (lack of) quality of the code.
Except that IS quality code... for code with a stack frame. It's not gcc's fault you made no use of the stack frame when you told it to make one. I'm not saying a compiler can beat hand-done assembly, but the code produced is much better than you're saying.
tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous »

Awesome project :D Let's hope you can get GBC cpu core running full speed as well.
mic_
Very interested
Posts: 265
Joined: Tue Aug 12, 2008 12:26 pm
Location: Sweden
Contact:

Post by mic_ »

Code: Select all

Let's hope you can get GBC cpu core running full speed as well.
The CPU is the same, it just runs at twice the clock frequency. I don't see a system with an 8MHz gb-z80 being emulated at full speed on the 32X. Even at normal frequency it's very far from full speed.
Post Reply