gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > NDS MegaDrive/Genesis emulator first pass

#69241 - bananaboy - Sun Jan 29, 2006 3:44 pm

Hi folks,

I've ported Charles MacDonald's Genesis Plus emulator to the DS! It currently runs very slowly (about 1 frame per second) and doesn't make use of any specialised DS hardware apart from the palette and the hardware scaling.

It's available here:
http://www.humbug.net/gpnds.zip

It renders the MD screen to a 512x256 extended rotation bitmap in mode 3 and uses hardware scaling to scale it to fit the DS screen.

Source is included (in fact, there is only source, no binary). It uses devkitpro. I also created a VS.NET 2003 project file (which just runs make). gpnds can be compiled to use a statically linked in GBFS filesystem, or a single statically linked in rom image (converted using bin2s). No roms are included in this archive! Sound is untested/unimplemented (and #ifdefed out by default).

This is just a sort of first pass release. I'm not sure if I've got the energy to port this to use the actual DS hardware (which would result in huge speed increases) so I'm putting it out there in case anyone is interested in toying with it. As it stands, it's really not playable, so this is really just a demonstration, I guess.

Here is a quick how-to from the readme.txt:

1. Copy a smd or bin file to the root directory of gpnds.

2. If it's an smd file, run:
grom\grom -bin filename.smd
to convert it to a raw image.

3. Run:
swap filename.bin rom.bin
to swap the byte order of the bin file (there was code in the original
genesis plus to do this at load time, however, I wanted to remove as
many static arrays as possible).

4. Run:
bin2s rom.bin > gp/rom.s
to create the data file.

5. Run:
make

5. Make sure the entire thing isn't over 4Mb! :) Copy the .ds.gba file to
your flash card (or use whatever method you are familiar with for running
homebrew).

Keys are:

NDS d-pad maps to megadrive d-pad
NDS x, b, a map to megadrive a, b, c
NDS start maps to megadrive start
NDS select resets the emulator

--------------

Any questions, don't hesitate to post!

cheers
sam

#69258 - Sicon - Sun Jan 29, 2006 5:40 pm

Very nice, it works though slowly. Keep up the good work it would be cool to see it running full speed with sound. :)
_________________
http://www.fullsail.edu/

#69265 - Barnard - Sun Jan 29, 2006 6:36 pm

I'm stuck on step four, I don't understand what the Bin2s means and the bat file can't find the make.exe.

#69277 - Sicon - Sun Jan 29, 2006 7:22 pm

if you have devkitpro installed you should be able to find bin2s in the devkitpro\devkitarm\bin folder. the syntax to use the program is..
Code:
bin2s yourrom.bin > rom.s


then replace the rom.s file in the gp folder and compile.
_________________
http://www.fullsail.edu/

#69440 - Wraggster - Mon Jan 30, 2006 8:08 pm

anyone else getting a corrupt zipfile ?

it still opens but with errors ?
_________________
Webmaster of Nintendo DS Emulation News

http://nintendo-ds.dcemu.co.uk

#69477 - Normmatt - Tue Jan 31, 2006 12:34 am

yeah that happened the first few times but after a few trys it downloaded and worked good

#69508 - bananaboy - Tue Jan 31, 2006 4:31 am

Hm strange, I don't know why it would be corrupt.. Just downloaded it at work and it was fine.

#69510 - Darkflame - Tue Jan 31, 2006 4:41 am

Its fantastic to see someone finaly working on this :)

Nes emulators are perfect.
And playing Sonic on the SMS emulator is pretty nice.

But nothing would compare to having a MegaDrive emulator :D

Of course, I understand its very early days. I am just glade someone has at least got this far!

#69547 - TheChuckster - Tue Jan 31, 2006 1:00 pm

It wouldn't be possible to rewrite the bits of graphics code that say draw sprites or tiles or manipulate the palette, and then convert them to directly use NDSlib? This gave StellaDS a huge speed up.

The hard part will be doing anything much more than that without knowing ARM ASM really well. I mean it's one thing to rewrite the whole CPU emulator in Assembly but if you don't know all of the idiosyncracies of the RISC instruction set, your code is going to be no where near optimized. Which means it will be just as fast as the C code.

#69552 - bananaboy - Tue Jan 31, 2006 1:40 pm

Well that's the idea: to map the Genesis hardware to the DS hardware. So any sprite code, instead of being emulated, would be redirected to poke bytes into the DS sprite hardware. However, this looks to be a bit of a challenge :).

I don't think re-writing the emulator in 100% seriously optimised ARM assembly language would make it playable. It might improve the speed by 10 or 20 percent but I think the real improvement would come from mapping the hardware.

Is that what StellaDS does?

#69573 - souLLy - Tue Jan 31, 2006 4:13 pm

Great stuff, I'd love to see what this could become with more development time, good job

#69628 - FluBBa - Tue Jan 31, 2006 9:30 pm

bananboy: Have you checked Cyclone 68000?
_________________
I probably suck, my not is a programmer.

#69633 - nmain - Tue Jan 31, 2006 9:44 pm

bananaboy wrote:
Well that's the idea: to map the Genesis hardware to the DS hardware. So any sprite code, instead of being emulated, would be redirected to poke bytes into the DS sprite hardware. However, this looks to be a bit of a challenge :).

I don't think re-writing the emulator in 100% seriously optimised ARM assembly language would make it playable. It might improve the speed by 10 or 20 percent but I think the real improvement would come from mapping the hardware.

Is that what StellaDS does?


Before you jump off a bridge, profile it; figure out what % of cpu time is used for all main cpu emulation, and what % is used for the gpu rendering. No reason not to be sure; maybe the cpu emulation is taking up more time than you think.

#69641 - TheChuckster - Tue Jan 31, 2006 10:20 pm

Yeah, I still have my CPU core as a straight port from Stella for PC. Then again, I have more leeway since I'm only emulating a 1.19 mhz 6502 variant. :)

#69673 - justatest - Wed Feb 01, 2006 2:47 am

Nice one!

So... how are you actually doing this? Just curious.. taking a wild guess (as a complete noob) i'd say that you're actually parsing the Genesis binary and detecting when calls are made to sprite/palette/background memory etc. Then you're translating them calls to DS specific code.

I'm probably awefully wrong though...

#69681 - bananaboy - Wed Feb 01, 2006 4:22 am

justatest: No, it doesn't do anything like that. It emulates the Genesis entirely in software and then draws to a frame buffer (this was mentioned a couple of posts above :)).

flubba: Thanks! I'll check that out! It might just be perfect! In fact, maybe that pico emulator would be a better code base to port than Genesis Plus!

#69699 - FluBBa - Wed Feb 01, 2006 10:08 am

There are some bugs in the 68k core though, Reesy fixed some of them in his DrMD emulator for the GP32/2X, so might want to contact him as well.
_________________
I probably suck, my not is a programmer.

#69709 - thehive - Wed Feb 01, 2006 1:45 pm

I think notaz fixed a wad too.
And I could swear that Reesy mentioned to me that he was porting DrMD to the DS. I could be mistaken though.
Not sure that the DS is very capable of full speed emulation of both 68000 and Z80 cores, but who knows?

#69715 - tepples - Wed Feb 01, 2006 2:41 pm

thehive wrote:
Not sure that the DS is very capable of full speed emulation of both 68000 and Z80 cores, but who knows?

Z80 can probably be handled on the ARM7 if Goomba Color is any indication. This leaves emulation of an 8 MHz MC68000 on a 67 MHz ARM9, and because the MC68000 is microcoded and not pipelined, it takes several cycles to do one instruction.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#70010 - darthtron - Fri Feb 03, 2006 6:55 pm

this came from the PIRACY-DOT-COM boards:

HtheB wrote:
Koji wrote:
HtheB wrote:
Will there be a Genesis emu for the DS or GBA? :oops:

http://liranuna.drunkencoders.com was working on it.. but he failed :(

there are awsome games on the genesis :)


Try rereading it... especialy
Quote:
This had been a long month - i got alot of emails requesting me to give betas
of Egga - my Genesis emulator for the DS. Unfourtunatly - i can't give anyone
anything, as the latest devkit, devkitARM r17, is making Egga to show nothing then
a black screen and output noisy sound.


He hasn't failed anything. He's just having a problem getting it to work with the latest devkit. I really wouldn't expect to much though even if he did release it.


(I know that... that after the update, it didnt work anymore)
But I had a chat with him and he said that he stopped making the emu..... :(


maybe we could get lira Nuna to let bananaboy take a look at his source code to "egga" and see if that would help him imporove "gpnds" by figuring out the the good and the bad from egga such as why caused it not to compile and work (one of the bads), maybe he could use that has his bases or maybe atleast use it as "insporation"

what do you all think

#70025 - LiraNuna - Fri Feb 03, 2006 8:38 pm

Egga doesn't work anymore - devkitPro r17 makes it compile into a blackscrens binary with strage buzz sound.

i did got it working a few days ago - now it shows garbage (atleast something!)

i got higher priorities projects now (like my RPG) so it's on halt.

#70155 - LunarCrisis - Sat Feb 04, 2006 7:47 pm

I played around with this a bit, and timed a couple of things in-game in sonic 1:
9 seconds game time == 57 seconds real time with frameskip off
9 seconds game time == 31 seconds real time with frameskip set to 10
(I had to fix frameskipping first though, since it wasn't doing anything initially)

It seems that rendering is only taking about half the time, so while using the display hardware might up to double the speed, it would still be too slow to run at full speed. =(
_________________
If a tree falls in the forest and no one is there to hear it, why the heck do you care?

#70184 - gladius - Sat Feb 04, 2006 10:01 pm

Don't underestimate the speed boost that can be had by (a) using both processors and (b) handcoded assembly cpu cores. Course the only problem with that is it is a collosal amount of work :).

#70185 - LiraNuna - Sat Feb 04, 2006 10:03 pm

Instead of using evil framebuffer, use the power of HW. like i (did) with egga.

#79396 - HtheB - Thu Apr 13, 2006 12:06 pm

how is the process going? :)

#79409 - tepples - Thu Apr 13, 2006 1:03 pm

LiraNuna wrote:
Instead of using evil framebuffer, use the power of HW. like i (did) with egga.

How? You'd need to do both horizontal scaling and vertical scaling, which looks ugly even if you can address all of VRAM for tiles.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#79443 - HtheB - Thu Apr 13, 2006 6:44 pm

problem is.. will it work? :D

#84479 - Wep_Z - Mon May 22, 2006 8:07 pm

I know that I shouldn't bump old topics, but I wanna know if there are some news to this.
http://www.humbug.net doesn't seem to be the official homepage for this..
Anyone ?

#84563 - HtheB - Tue May 23, 2006 11:30 am

Wep_Z wrote:
I know that I shouldn't bump old topics, but I wanna know if there are some news to this.
http://www.humbug.net doesn't seem to be the official homepage for this..
Anyone ?
actually.. it is yes....