| View previous topic :: View next topic |
| Author |
Message |
mic_ Very interested
Joined: 12 Aug 2008 Posts: 250 Location: Sweden
|
Posted: Wed Jan 21, 2009 10:37 am Post subject: Gameboy on 32X |
|
|
Here's something I've been tinkering with a bit lately:

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). |
|
| Back to top |
|
 |
ob1 Very interested
Joined: 06 Dec 2006 Posts: 359 Location: Aix-en-Provence, France
|
Posted: Wed Jan 21, 2009 11:19 am Post subject: |
|
|
Hey ! Looks interesting.
;)
Any way to look into your sources ? |
|
| Back to top |
|
 |
mic_ Very interested
Joined: 12 Aug 2008 Posts: 250 Location: Sweden
|
Posted: Wed Jan 21, 2009 11:47 am Post subject: |
|
|
| Perhaps after I've cleaned it up a bit and fixed some bugs. Right now it's quite useless. |
|
| Back to top |
|
 |
TmEE co.(TM) Very interested

Joined: 05 Dec 2006 Posts: 1945 Location: Estonia, Mahtra village
|
Posted: Wed Jan 21, 2009 2:06 pm Post subject: |
|
|
wow, this is awesome Ö _________________ Mida sa loed ? Nagunii aru ei saa  |
|
| Back to top |
|
 |
AamirM Very interested
Joined: 18 Feb 2008 Posts: 470
|
Posted: Wed Jan 21, 2009 6:57 pm Post subject: |
|
|
| Dude, that is just so cool and awesome!! |
|
| Back to top |
|
 |
Jorge Nuno Very interested

Joined: 11 Jun 2007 Posts: 329 Location: Azeitão, PT
|
Posted: Wed Jan 21, 2009 9:05 pm Post subject: |
|
|
W00t!
Doesn't the gameboy have the Z80 as a CPU? maybe it could be ran "almost" natively on the megadrive. |
|
| Back to top |
|
 |
Shiru Very interested
Joined: 07 Apr 2007 Posts: 786 Location: Russia, Moscow
|
Posted: Wed Jan 21, 2009 9:12 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Jorge Nuno Very interested

Joined: 11 Jun 2007 Posts: 329 Location: Azeitão, PT
|
Posted: Wed Jan 21, 2009 9:16 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
mic_ Very interested
Joined: 12 Aug 2008 Posts: 250 Location: Sweden
|
Posted: Thu Jan 22, 2009 5:17 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
mic_ Very interested
Joined: 12 Aug 2008 Posts: 250 Location: Sweden
|
Posted: Thu Jan 22, 2009 5:22 pm Post subject: |
|
|
Just as an example; a function that contains only "return 0;" gets compiled into:
| Code: | mov.l r14,@-r15
mov #0,r0
mov r15,r14
mov r14,r15
rts
mov.l @r15+,r14 |
Plain awesomeness.. That could be reduced by 67%. And it just goes on like that. |
|
| Back to top |
|
 |
TMorita Interested
Joined: 29 May 2008 Posts: 17
|
Posted: Thu Jan 22, 2009 8:36 pm Post subject: |
|
|
| mic_ wrote: | Just as an example; a function that contains only "return 0;" gets compiled into:
| Code: | mov.l r14,@-r15
mov #0,r0
mov r15,r14
mov r14,r15
rts
mov.l @r15+,r14 |
Plain awesomeness.. 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 |
|
| Back to top |
|
 |
mic_ Very interested
Joined: 12 Aug 2008 Posts: 250 Location: Sweden
|
Posted: Thu Jan 22, 2009 8:43 pm Post subject: |
|
|
| Quote: | | 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. |
|
| Back to top |
|
 |
Chilly Willy Very interested
Joined: 17 Aug 2007 Posts: 1955
|
Posted: Thu Jan 22, 2009 10:15 pm Post subject: |
|
|
| mic_ wrote: | | Quote: | | 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. |
|
| Back to top |
|
 |
tomaitheous Very interested
Joined: 11 Sep 2007 Posts: 236
|
Posted: Fri Jan 23, 2009 7:56 am Post subject: |
|
|
Awesome project Let's hope you can get GBC cpu core running full speed as well. |
|
| Back to top |
|
 |
mic_ Very interested
Joined: 12 Aug 2008 Posts: 250 Location: Sweden
|
Posted: Fri Jan 23, 2009 8:36 am Post subject: |
|
|
| Code: | | 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. |
|
| Back to top |
|
 |
|