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:

Post by mic_ » Tue Jan 27, 2009 8:38 am

You could always DMA the switched bank into sdram, but that would probably slow things down more than just accessing rom space unless the game rarely ever switched banks. Maybe you could make that a rom dependent preference.
Another possibility would be to implement a simple caching scheme where 4 or 8 rom banks (GB rom banks) are kept in the SDRAM, and using LRU replacement of cache entries. I'd have to do some profiling first though to see if I'd get enough cache hits for it to be worth implementing, and that's not really my priority atm since I'm still less than half-way done with SH assembly version of the gb-z80 emulator.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Jan 27, 2009 11:10 am

Yeah, get it working right first, THEN check which things make it faster. I noticed the C code for the core isn't correct for some things. For example, in EVA Pong, the ball and paddle won't go all the way to the right, the wrong bricks get removed, and the score doesn't increase correctly. If you had still been working on that code, it would have been something to look into, but you're working on new code so it doesn't matter. :)

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sat Jan 31, 2009 2:23 pm

Okay, I've been using this for testing since I wanted to be sure what I was doing was actually working. So I know this isn't being worked on anymore - it's just my test bed. Now that I've got this the way I like it, I can now move on to something better myself.

So what's new? I altered how you build the project, and did a MAJOR cleanup. The code is now in the rom, initialized data is copied to the sdram, and the bss area in the sdram is cleared on start. I added support for exceptions, hblank, and vblank on the 68000 side, and support for exceptions and irqs on the SH2. The slave SH2 is now initialized and you can run code on it via a slave() function (the master runs main()).

If you WANT a code function in the sdram, you can either copy it yourself, or even easier, use the section function attribute to put the function in the data section. Anything in the data section is copied into sdram at the start.

http://www.mediafire.com/?rmnverjlnxj

That's an archive with all the code for fuboy, along with my changes to the support stuff. I made a makefile to make making the project easy. The ld scripts have been redone as well to work properly (the vma of the data section is now set for the ram for the machine - 0x00f00000 for the 68000, and 0x06000000 for sh2 - while the lma is set to the end of the text section in rom). The bss section also properly follows the data section in ram. I removed c++ support from the MD LD script while debugging this... I may or may not add it back. In the meantime, look this over and see if you spot any problems. I included my build of fuboy with the PD game EVA Pong, along with a few other PD roms in the roms folder. This build has 3 button joypad support, so you can actually play EVA Pong. All my testing was done in Gens with the poor-man's bios.

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

Post by mic_ » Sat Jan 31, 2009 4:23 pm

I'll check that out later. The assembly rewrite is about 90% done at this point.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sat Jan 31, 2009 11:23 pm

Cool. My rewrite of the support was basically to make it easier to do 32X by switching the linking. Instead of the 68K linker adding a 32X binary to a 68000 assembly, it was better (in my opinion) to have the SH2 linker add 68000 binary to the SH2 assembly. That allows you to make a project that is almost the same as a plain SH2 program.

By the way, it's no wonder I couldn't use 128K roms in the emu either... looking at the resultant binary from my rewrite, the bss section for fuboy was almost 135 KB by itself. The program is pretty small at a bit more than 55KB. That left room in the old method for a 64KB or smaller rom.

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

Post by mic_ » Sun Feb 01, 2009 12:43 pm

I plan to have all the SH2 code and data in SDRAM for the assembly version, and perhaps put some of the most frequently executed code (like the main opcode fetching loop) in the 2kB RAM that you can "borrow" from the cache memory. I'll have the GB ROMs in ROM though, and load the banks into SDRAM as needed (except for bank 0 which will be loaded into SDRAM once when the ROM is first loaded).

looking at the resultant binary from my rewrite, the bss section for fuboy was almost 135 KB by itself.
There's a typo in memory.c. The EXRAM array should be 32kB, not 128kB. There are no GB carts that have more than 32kB of RAM afaik.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Mon Feb 02, 2009 12:05 am

mic_ wrote:I plan to have all the SH2 code and data in SDRAM for the assembly version, and perhaps put some of the most frequently executed code (like the main opcode fetching loop) in the 2kB RAM that you can "borrow" from the cache memory. I'll have the GB ROMs in ROM though, and load the banks into SDRAM as needed (except for bank 0 which will be loaded into SDRAM once when the ROM is first loaded).
That would easy enough to do with the way I changed things... just put ".data" at the top of the assembly files for the program instead of ".text". :)
looking at the resultant binary from my rewrite, the bss section for fuboy was almost 135 KB by itself.
There's a typo in memory.c. The EXRAM array should be 32kB, not 128kB. There are no GB carts that have more than 32kB of RAM afaik.
Ah - okay, that's why it was larger than it should be. For such a small app, it used a LOT of memory. :)

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

Post by mic_ » Thu Feb 12, 2009 9:44 am

Image
The first ever output from the SH2 assembly rewrite of my gameboy emulator.. :roll:

Pretty much everything from the C version has been implemented now, except for parts of the PPU. I don't know what the speed is like though, because there are still a lot of bugs, and the few ROMs I've managed to get kinda working so far don't do much in terms of animation.
Once the amount of bugs are reduced to about the same level as in the C version I plan to attempt to move most of the PPU emulation code to the slave SH2.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Feb 12, 2009 11:08 am

Cool. Sounds like it's coming along nicely. :)

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

Post by mic_ » Sat Feb 14, 2009 8:25 am

Some more progress.. Sprites and windows aren't drawn yet, joypad reading isn't handled, and there are still a lot of bugs.

ImageImage

ob1
Very interested
Posts: 463
Joined: Wed Dec 06, 2006 9:01 am
Location: Aix-en-Provence, France

Post by ob1 » Sat Feb 14, 2009 10:06 am

Looks amazing !

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

Post by mic_ » Wed Feb 18, 2009 8:52 pm

Well, at least I managed to find out why it wasn't working on HW or in Fusion.. I've also been moving the GB ROMs to 32X ROM space so that it's not limited to 128 kB or less, as well as adding some sprite rendering (which isn't working 100% yet as you can see in some of these screenshots):

Image Image
Image Image

Snake
Very interested
Posts: 206
Joined: Sat Sep 13, 2008 1:01 am

Post by Snake » Thu Feb 19, 2009 9:13 pm

Good stuff :) What sort of speed are you getting?

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

Post by mic_ » Fri Feb 20, 2009 9:58 am

What sort of speed are you getting?
There's a video here of me playing Super Mario Land on my 32X.
That's with the main SH2 doing all the work, and no cache optimization. So I guess it can still get a bit smoother.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Sat Feb 21, 2009 1:54 pm

This runs as fast as one MS-DOS NES emulator on a 25MHz 486SX2 :D
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

Post Reply