Best Genesis/Mega Drive emulator for DC?

This forum is for discussion pertaining to homebrew and indie software for the Dreamcast, such as homebrew games, emulators/interpreters, and other homebrew software/applications. Porting requests and developmental ideas are not to be made here; you can make those here. If you need any help burning discs for homebrew software, this is the place to ask as well.
Post Reply
User avatar
Christuserloeser
Moderator
Moderator
Posts: 5936
Joined: Thu Aug 28, 2003 12:16 am
Location: DCEvolution.net
Has liked: 0
Been liked: 0
Contact:

Post by Christuserloeser » Sat Jan 20, 2007 4:31 pm

Quzar released an update of GPDC today, thought I should post about it here too:
Quzar wrote:Here are the changes, straight from the new part of the readme:
alpha4 (01/18/07):
*after more of eke-eke's changes, the sound stuff now works properly.

alpha3 (01/17/06):
*Slightly newer fame
*put in the code for eke-eke's changes to the sound driver to fix FM sound in some games. Doesn't work properly so it is defined out.

alpha2 (10/26/06):
*Uses DMA for texture transfer, but only partially. Should speed up texture transfer by ~2x
*Uses SQs in more places that affect speed more.

alpha1 (10/22/06):
*Faster assembly twiddling function
*Uses store queues when possible for speedups
*New FAME core from fox68k
*Multilingual Menu - automatically set by the DC's BIOS settings
*Re-Added FPS showing option
*Modified the romlist system, so that it can now read files with spaces in their names (use an | to seperate filename from real name)
*Small speedups in many places

TODO:

*Add switch for mameZ80 and Cz80
*use DMA for sound
*Make menu able to list roms without romlist
For reference, this was built off the july release of gpdc by BlackAura, and includes all files except roms that you need to use it (and more!).

The download is HERE. It includes all files needed, including the source code.

A note to those looking at the source: every change I made is marked somehow (usually by a comment including my name or a similar define).

If you repost this news elsewhere, please do NOT use your own download link. I'd much rather have all downloads go through this original file (I want to be able to track the number of downloads).

Enjoy folks!

I've tested it with the following games:
Streets of Rage 2 - seems to be broken with FAME, runs flawless with C68K tho.
Ultimate MK3, Street Fighter II CE - controls do not respond when using FAME, but work with C68K.
Castle of Illusion, Quackshot - FM music is way too fast with either FAME or C68K.
Technosoft games (ThunderForce, Herzog, Devil Crash, etc) - those have music now, but twice as fast.

All other games I tested ran great.
Insane homebrew collector.
User avatar
Christuserloeser
Moderator
Moderator
Posts: 5936
Joined: Thu Aug 28, 2003 12:16 am
Location: DCEvolution.net
Has liked: 0
Been liked: 0
Contact:

Post by Christuserloeser » Sun Jan 21, 2007 10:15 am

More games I've tested with Quzar's build:

- Chiki Chiki Boys: sound's way too fast
- Castle of Illusion: sound's way too fast
- Alisia Dragoon: sound's way too fast
- Columns: sound's way too fast
- Contra: no sound at all!
- Rocket Knight Adventures: no sound at all
- Sagaia & Darius II: no sound at all
- Deadly Moves: no sound in game
- Double Dragon: sound too fast
- Gaiares: no sound at all
- World Heroes: sound's way too fast

Seems most games I've tested yesterday are those that actually work, while many many other games have the issues described above. I would guess it's because of what eke-eke wrote. You couldn't use his sound fixes with 12khz, as it would only work with 22 and up.
eke-eke wrote:I think this is due to the sample rate used in the DC port (12000 ?), which is also used to init the genesis audio and the sound buffers. The Timer increment (64us at each scanline) only works for high sample rate (22500 and higher), I think.

As these timers are used by the Z80 program to synchronise his FM data writing, fast tempo means Z80 running too fast because of FM timers decrement to quickly.


Thanks to AxelStone at DCEmu UK for pointing it out. I didn't notice it because at least 90% of all games I've tested yesterday did work. >_<
Insane homebrew collector.
TechnoWolf
Insane DCEmu
Insane DCEmu
Posts: 126
Joined: Wed Jan 10, 2007 11:56 am
Has liked: 0
Been liked: 0

GPWT New build

Post by TechnoWolf » Tue Jan 23, 2007 7:01 pm

Excellent! Hats off on the continuing work!
eke-eke
DC Developer
DC Developer
Posts: 16
Joined: Mon May 01, 2006 4:15 am
Has liked: 0
Been liked: 0

Post by eke-eke » Sat Jan 27, 2007 3:31 pm

eke-eke wrote:By the way, i finally discover why some games (Castle of Illusion, Quackshot ) didn't have in-game FM music. This occurs in each Genesis Plus port apparently (i was working on the Gamecube's port made by Softdev, see http://www.tehskeen.com/ ).


The problem was in the sound.c code, where it seems that Charles Mc Donald made a mistake in handling FM Timers A & B and inverted the status of the 2 timers, which are used in the "fm_status" returned when the program read the FM registers.

So the Z80 program (which was in charge of producing music) was kept in a loop, reading the bad timer and didn't send data to produce music. The correction I made solved this problem :wink:


For Genesis Plus ports devellopers, here are the (minor) changes I made in sound.c:

- in function fm_update_timers:
/* Set overflow flag (if flag setting is enabled) */
if(timer.enable)
{
fm_status |= (1 << i);
}


becomes

/* Set overflow flag (if flag setting is enabled) */
if(timer.enable)
{
fm_status |= (1 << (1-i));
}


- in function fm_write:

/* RESET */
if(data & 0x10) fm_status &= ~1;
if(data & 0x20) fm_status &= ~2;


becomes

/* RESET */
if(data & 0x10) fm_status &= ~2;
if(data & 0x20) fm_status &= ~1;



I found the correct timer handling thanks to the YM2612 Programmer Guide which can be found here: http://www.smspower.org/maxim/docs/ym2612/index.html

Hope this will help to improve your awesome Dreamcast port :wink:



Please note that I was wrong doing this (as I explained later, there was a mistake in the documentation, the correct fm_status assignment is the original one)

I checked your source and saw that you have kept these modifications, That way, timer A & B are inverted, which should make some games not having sound anymore

By the way, even without this, I also have the problem of fast tempo with a lot of games (which had no problem before), even with 48kHz samplerate (on gamecube version)... So I think the problem is elsewhere in the sound.c sourcecode, I have to investigate a little more...
User avatar
Christuserloeser
Moderator
Moderator
Posts: 5936
Joined: Thu Aug 28, 2003 12:16 am
Location: DCEvolution.net
Has liked: 0
Been liked: 0
Contact:

Post by Christuserloeser » Sat Jan 27, 2007 4:16 pm

eke-eke wrote:Please note that I was wrong doing this (as I explained later, there was a mistake in the documentation, the correct fm_status assignment is the original one)

I checked your source and saw that you have kept these modifications, That way, timer A & B are inverted, which should make some games not having sound anymore

By the way, even without this, I also have the problem of fast tempo with a lot of games (which had no problem before), even with 48kHz samplerate (on gamecube version)... So I think the problem is elsewhere in the sound.c sourcecode, I have to investigate a little more...

Thanks a lot eke-eke, your work is greatly appreciated :)


Warmtoe recently replied to my PM:
Warmtoe wrote:You could try handing these on to BA and eke-eke - I've got no time to work on this at the moment, but I had a go at implementing eke-eke's code changes in the current level of the source I have, snippets (with a little context):-

sound.c

Code: Select all

/*
    sound.c
    YM2612 and SN76489 emulation
*/

extern int v_counter;
extern int sound_inc[262];

#include "shared.h"

Code: Select all

        case 0x27: /* Timer Control */
          /* LOAD */ 
          if(!timer[0].running && (data & 1)) timer[0].count = 0; 
          timer[0].running = (data & 1); 

          if(!timer[1].running && (data & 2 )) timer[1].count = 0; 
          timer[1].running = (data & 2);

Code: Select all

  /* Process YM2612 timers */
  for(i = 0; i < 2; i += 1)
  {
    /* Is the timer running? */
    if(timer[i].running)
    {
      /* Each scanline takes up the calclated microseconds */
      timer[i].count += sound_inc[v_counter];

      /* Check if the counter overflowed */
      if(timer[i].count > timer[i].base)
      {
system.c (or xsystem.c - whichever he's using)

Code: Select all

static int sound_tbl[262];
static int use_cpu68k_type;
int sound_inc[262];

Code: Select all

  /* Make sound tables */
  #if 0
  /* number of samples */
  for (i = 0; i < 262; i++)
  {
    float p = snd.buffer_size * i;
    p = p / 262;
    sound_tbl[i] = (int)p;
  }

  /* timer increment */
  for(i = 0; i < 262; i++)
  {
    sound_inc[i] = 64; /* roughly 64 per scaline */
  }
  #else
  /* number of samples */
  for (i = 0; i < 262; i++)
  {
    float p = rate * i;
    p = p / 15720;
    sound_tbl[i] = (int)p;
  }

  /* timer increment */
  for(i = 0; i < 262; i++)
  {
    float p;
     
    if (i < 261)
      p = sound_tbl[i+1] - sound_tbl[i];
    else
      p = 1;

    p = (p * 1000000)/rate;

    sound_inc[i] = (int)p;
  }
  #endif
We all know BA is a genius already - but if he can work out where they all fit, he'll prove it. Anway, it compiles OK, just haven't been able to test it, but in theory, it's what eke-eke was saying.

Good luck!
Insane homebrew collector.
eke-eke
DC Developer
DC Developer
Posts: 16
Joined: Mon May 01, 2006 4:15 am
Has liked: 0
Been liked: 0

Post by eke-eke » Sat Jan 27, 2007 6:03 pm

That's it ;)
I didn't create a second table but rather use the sound_tbl one in system.c, that means, in function "system_frame", I replaced the call to "fm_update_timer" by:
if (line == 261) fm_update_timers(((snd.buffer_size-sound_tbl[line]) * 1000000)/snd.sample_rate);
else fm_update_timers(((sound_tbl[line+1]-sound_tbl[line]) * 1000000)/snd.sample_rate);

Finally, I realized that the correct way to initialize the timers counters is not on writing to register 0x27 (start or stop the timers) but when writing a new value in the timers base (register 0x24 & 0x25 for timerA, 0x26 for timer B).

Here are the final change I would make in sound.c:

fm_write
case 0x24: /* Timer A (LSB) */
timer[0].index = ((timer[0].index & 0x0003) | (data << 2)) & 0x03FF;
if (timer[0].base != fm_timera_tab[timer[0].index])
{
timer[0].base = fm_timera_tab[timer[0].index];
timer[0].count = 0;
}
break;

case 0x25: /* Timer A (MSB) */
timer[0].index = ((timer[0].index & 0x03FC) | (data & 3)) & 0x03FF;
if (timer[0].base != fm_timera_tab[timer[0].index])
{
timer[0].base = fm_timera_tab[timer[0].index];
timer[0].count = 0;
}
break;

case 0x26: /* Timer B */
timer[1].index = data;
if (timer[1].base != fm_timerb_tab[timer[1].index])
{
timer[1].base = fm_timerb_tab[timer[1].index];
timer[1].count = 0;
}
break;

case 0x27: /* Timer Control */

/* LOAD */
timer[0].running = (data & 1);
timer[1].running = (data & 2);

/* ENABLE */
timer[0].enable = (data >> 2) & 1;
timer[1].enable = (data >> 3) & 1;

/* RESET */
if(data & 0x10) fm_status &= ~1;
if(data & 0x20) fm_status &= ~2;
break;
and
void fm_update_timers(int inc)
{
int i;

/* Process YM2612 timers */
for(i = 0; i < 2; i += 1)
{
/* Is the timer running? */
if(timer.running)
{
/* microseconds increment */
timer.count += inc;

/* Check if the counter overflowed */
if(timer.count >= timer.base)
{
/* Reload counter */
timer.count -= timer.base;

/* Set overflow flag (if flag setting is enabled) */
if(timer.enable)
{
fm_status |= (1 << i);
}
}
}
}
}
User avatar
Christuserloeser
Moderator
Moderator
Posts: 5936
Joined: Thu Aug 28, 2003 12:16 am
Location: DCEvolution.net
Has liked: 0
Been liked: 0
Contact:

Post by Christuserloeser » Sat Jan 27, 2007 6:45 pm

eke-eke wrote:That's it ;)
I didn't create a second table but rather use the sound_tbl one in system.c

[...] Finally, I realized that the correct way to initialize the timers counters is not on writing to register 0x27 (start or stop the timers) but when writing a new value in the timers base (register 0x24 & 0x25 for timerA, 0x26 for timer B).

Here are the final change I would make in sound.c:
[...]
Woohoo! That's just great! Can't wait to see your changes implemented!

Thanks again eke-eke, you are surely a great help :D
Insane homebrew collector.
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7486
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has liked: 0
Been liked: 3 times
Contact:

Post by Quzar » Sat Jan 27, 2007 8:57 pm

Sound works fine now that those changes have been implemented. Somebody please try testing it before I release (staff, mod, coder, etc):

http://www.dcemu.co.uk/vbulletin/showth ... 767&page=3
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
User avatar
Christuserloeser
Moderator
Moderator
Posts: 5936
Joined: Thu Aug 28, 2003 12:16 am
Location: DCEvolution.net
Has liked: 0
Been liked: 0
Contact:

Post by Christuserloeser » Sat Jan 27, 2007 9:00 pm

Testing it right now.
Insane homebrew collector.
User avatar
Christuserloeser
Moderator
Moderator
Posts: 5936
Joined: Thu Aug 28, 2003 12:16 am
Location: DCEvolution.net
Has liked: 0
Been liked: 0
Contact:

Post by Christuserloeser » Sat Jan 27, 2007 11:21 pm

Okay, tested it and I think most problems are fixed with this new build:

- Chiki Chiki Boys: fixed
- Castle of Illusion: fixed
- Alisia Dragoon: fixed
- Columns: fixed
- Contra: fixed
- Rocket Knight Adventures: fixed
- Sagaia & Darius II: fixed
- Deadly Moves: you can hear sound playing with C68k while the screen stays black, with FAME there's no sound but the graphics are displayed
- Double Dragon: fixed
- Gaiares: fixed
- World Heroes: fixed
- Street Fighter II' CE: sound is too fast (with FAME only!)
- GoldenAxe III: sound is too fast (with FAME only!)

The best news with this build is that all Technosoft games now do have proper sound for the first time: Devil Crash, Thunder Force III + IV, Elemental Master, Herzog Zwei - they all run with sound :)

Overall I had the impression the sound now would be a little bit 'cleaner' than with previous builds. But it could be just me... Anyway, I also noticed that C68k can't keep up with FAME anymore, it just doesn't run at full speed while FAME does. It's the first time that I noticed any frame skipping with C68k at all.
Insane homebrew collector.
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7486
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has liked: 0
Been liked: 3 times
Contact:

Post by Quzar » Sun Jan 28, 2007 12:44 am

Christuserloeser wrote:Anyway, I also noticed that C68k can't keep up with FAME anymore, it just doesn't run at full speed while FAME does. It's the first time that I noticed any frame skipping with C68k at all.
um... check the FPS counter. They run just about the same. Better yet, go into SW mode with both of them.

Anyways the bug with SF II is a known one that fox is working on, the others, well i unno =P.

I just realized though, that with these new sound changes (or possibly before) now sw mode with sound off does not seem to work. Not a huge deal, but still =\.
Last edited by Quzar on Wed Jan 31, 2007 12:13 pm, edited 2 times in total.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
User avatar
Christuserloeser
Moderator
Moderator
Posts: 5936
Joined: Thu Aug 28, 2003 12:16 am
Location: DCEvolution.net
Has liked: 0
Been liked: 0
Contact:

Post by Christuserloeser » Sun Jan 28, 2007 1:23 am

Quzar wrote:They run just about the same. Better yet, go into SW mode with both of them.
I tested it in SW mode with your previous build and the difference is 10fps (!) in Sonic 2.
Anyways the bug with SF II is a known one that fox is working on
Glad to hear that! Go Fox, go! :D
I just realized though, that with these new sound changes (or possibly before) now sw mode with sound off does not seem to work. Not a huge deal, but still =\.
As mentioned it worked with your previous build. It would be nice to see the software renderer working again soon (edit: when sound is disabled). It could be used for many games until a few little flaws of the hardware renderer are removed (most important topic would be vertical shmups).

That said allow me to request frameskip for the SW renderer and to have disabling sound emulation actually affecting the emulation speed itself, just like in GenesisPlusDC v01 (BlackAura's 1st public build from 2003). In all previous builds since v01, the software renderer ran at the same speed, regardless if sound emulation was enabled or disabled.

Edit: Dunno if it helps much, but here's the source code of GP/DC v01:
http://www.dcevlolution.net/dsdevelopme ... 01_src.zip
Insane homebrew collector.
eke-eke
DC Developer
DC Developer
Posts: 16
Joined: Mon May 01, 2006 4:15 am
Has liked: 0
Been liked: 0

Post by eke-eke » Sun Jan 28, 2007 4:58 am

Christuserloeser wrote:Okay, tested it and I think most problems are fixed with this new build:

- Chiki Chiki Boys: fixed
- Castle of Illusion: fixed
- Alisia Dragoon: fixed
- Columns: fixed
- Contra: fixed
- Rocket Knight Adventures: fixed
- Sagaia & Darius II: fixed
- Deadly Moves: you can hear sound playing with C68k while the screen stays black, with FAME there's no sound but the graphics are displayed
- Double Dragon: fixed
- Gaiares: fixed
- World Heroes: fixed
- Street Fighter II' CE: sound is too fast (with FAME only!)
- GoldenAxe III: sound is too fast (with FAME only!)

The best news with this build is that all Technosoft games now do have proper sound for the first time: Devil Crash, Thunder Force III + IV, Elemental Master, Herzog Zwei - they all run with sound :)

Overall I had the impression the sound now would be a little bit 'cleaner' than with previous builds. But it could be just me... Anyway, I also noticed that C68k can't keep up with FAME anymore, it just doesn't run at full speed while FAME does. It's the first time that I noticed any frame skipping with C68k at all.
that's good news :wink:
thanks for testing this, I had no more mini-dvdr to test my gamecube port, too bad :oops:
Warmtoe
DC Developer
DC Developer
Posts: 453
Joined: Thu May 16, 2002 8:29 am
Location: ice88's house
Has liked: 0
Been liked: 0
Contact:

Post by Warmtoe » Mon Jan 29, 2007 2:26 am

Quzar wrote:Sound works fine now that those changes have been implemented. Somebody please try testing it before I release (staff, mod, coder, etc):

http://www.dcemu.co.uk/vbulletin/showth ... 767&page=3
Did you implement eke-eke's changes or mine? The downside with eke-eke's approach (ie not using a table) is that there are calculations now taking place on every frame, rather than just a table lookup (those increments will remain constant on each frame, so making them a lookup will make them quicker).

I only mention this, because there now appears to be a lag with C68K vs FAME, and it could all simply be to do with performing these calculations all the time.

Anyhoo, glad it's working!!
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7486
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has liked: 0
Been liked: 3 times
Contact:

Post by Quzar » Mon Jan 29, 2007 2:56 am

Warmtoe wrote:
Quzar wrote:Sound works fine now that those changes have been implemented. Somebody please try testing it before I release (staff, mod, coder, etc):

http://www.dcemu.co.uk/vbulletin/showth ... 767&page=3
Did you implement eke-eke's changes or mine? The downside with eke-eke's approach (ie not using a table) is that there are calculations now taking place on every frame, rather than just a table lookup (those increments will remain constant on each frame, so making them a lookup will make them quicker).

I only mention this, because there now appears to be a lag with C68K vs FAME, and it could all simply be to do with performing these calculations all the time.

Anyhoo, glad it's working!!
I can read code too ya know ;). Yea, I saw that it would be much faster using your approach and opt'd for it =).

hrm, sorry, it's quite late here. what i meant to say was: "thank you so much!" etc etc. Also, you should have access to the private link that was posted to look at the sources. Maybe at some point you can take a look at my changes (I put //Quzar next to any change I made) and tell me what you think.
Last edited by Quzar on Mon Jan 29, 2007 3:17 am, edited 1 time in total.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
User avatar
fox68k
DC Developer
DC Developer
Posts: 49
Joined: Tue Aug 03, 2004 11:01 am
Has liked: 0
Been liked: 0
Contact:

Post by fox68k » Mon Jan 29, 2007 3:09 am

Christuserloeser wrote:Hm, I got a question regarding FAZE then: Do you think it would be save to implement FAZE from the MAME4ALL source into GenesisPlusDC ?
Not sure, but very likely. FAZE is not as complex as FAME in terms of generation options.
I will take a look into this when i have some free time.

Cheers.
- fox68k -
User avatar
Salamander2
Insane DCEmu
Insane DCEmu
Posts: 150
Joined: Mon Apr 05, 2004 8:38 pm
Location: Rio Grande,RS - Brazil
Has liked: 0
Been liked: 0

Post by Salamander2 » Mon Jan 29, 2007 9:08 am

yes!
finally contra have music(fixed one).

thx
"...they are carrying the last hope: to save planet Gradius...on their wings..."
GRADIUS TRIBUTE for Dreamcast!
alb3530
DCEmu Freak
DCEmu Freak
Posts: 99
Joined: Fri Nov 12, 2004 2:00 pm
Location: RS,Brazil
Has liked: 0
Been liked: 0
Contact:

Post by alb3530 » Mon Jan 29, 2007 9:35 am

Some staff, mod, coder: could you please test these games in the latest build (that's not available for the masses) to see if they work?

-Strider Returns, to see if it's playable (not ghost elements anymore)

-KOF98 and Top Fighter 2000.Do they have musics played?
Http_user_agent:
NokiaN80-1/3.0 (4.0623.0.41) Series60/3.0
Profile/MIDP-2.0
Configuration/CLDC-1.1
User avatar
Christuserloeser
Moderator
Moderator
Posts: 5936
Joined: Thu Aug 28, 2003 12:16 am
Location: DCEvolution.net
Has liked: 0
Been liked: 0
Contact:

Post by Christuserloeser » Mon Jan 29, 2007 12:30 pm

alb3530 wrote:ome staff, mod, coder: could you please test these games in the latest build (that's not available for the masses) to see if they work?

-Strider Returns, to see if it's playable (not ghost elements anymore)
Sorry, I don't have that game on my test disc because I don't like it =P I will include it to my next test disc.
alb3530 wrote:-KOF98 and Top Fighter 2000.Do they have musics played?
Yep. Both have :)
Insane homebrew collector.
RMD
Mental DCEmu
Mental DCEmu
Posts: 459
Joined: Sun Oct 01, 2006 10:24 am
Has liked: 0
Been liked: 0

Post by RMD » Mon Jan 29, 2007 5:44 pm

KOF98 came out for genesis? Since when?
Post Reply