The real fix is that oper[].kc_i got initialised to 0 where as it should have been initialised to 768 since that is the min value for kc_i.

I've also found that they we're using right shift as a divide op on signed numbers which won't work ofcourse.

This is fixed in CVS now, Lawrence Please merge this upstream, also see the note in the diff about me wondering if the new divide code is correct.

Regards,

Hans


F.J. McCloud wrote:
This is core MAME code but no one on mametesters is doing
64-bit work yet.  I hope someone here can shed some light on
this first.

There are a number of games that work fine in 32-bit X86 xmame,
but crash on 64-bit amd64 xmame regardless of gcc version or
setting.  This also has nothing to do with ASM or DRC.

I started looking at stunrun and have documented my efforts so
far here:
http://www.anthrofox.org/code/mame/64bitclean/index.html

stunrun will segfault during attract mode on X86-64 right when
the car hits the yellow plate.

The dirty ugly disgusting hack patch I have on the URL above
actually gets around this segfault.  The problem is
src/sound/ym2151.c.  And the behavior is interesting.
1.  This line:
INT32 mod_ind = PSG->lfp;               /* -128..+127 (8bits
signed) */
often goes below -200!
2.  Is UINT32 supposed to clamp mod_ind to zero?  Because for
whatever reason it does not work on X86-64!
UINT32 kc_channel =     op->kc_i + mod_ind;
Here, kc_channel becomes negative and causes an out-of-bounds
access later on.

Details are on the link above.  Can someone else help with this
before I beg mametesters to look at 64-bit updates again?  I'd
like to know the right thing to do in this code before giving
them a dirty patch.

Thanks!



__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail


_______________________________________________
Xmame mailing list
[EMAIL PROTECTED]
http://toybox.twisted.org.uk/mailman/listinfo/xmame


-- EuropeSwPatentFree http://EuropeSwPatentFree.hispalinux.es
Index: src/sound/ym2151.c
===================================================================
RCS file: /home/cvs/mess/src/sound/ym2151.c,v
retrieving revision 1.9
diff -u -r1.9 ym2151.c
--- src/sound/ym2151.c  28 Jan 2004 03:15:07 -0000      1.9
+++ src/sound/ym2151.c  31 Oct 2004 08:21:55 -0000
@@ -1576,6 +1576,7 @@
        {
                memset(&chip->oper[i],'\0',sizeof(YM2151Operator));
                chip->oper[i].volume = MAX_ATT_INDEX;
+               chip->oper[i].kc_i = 768; /* min kc_i value */
        }
 
        chip->eg_timer = 0;
@@ -2174,10 +2175,39 @@
                if (op->pms)    /* only when phase modulation from LFO is enabled for 
this channel */
                {
                        INT32 mod_ind = PSG->lfp;               /* -128..+127 (8bits 
signed) */
+#if 0 /* right shift as divide doesn't work on signed values! */
                        if (op->pms < 6)
                                mod_ind >>= (6 - op->pms);
                        else
                                mod_ind <<= (op->pms - 5);
+#else
+                        /* Is this right? Shouldn't there be case where
+                           mod_ind is not modified at all? */
+                        switch (op->pms) /* 1 - 7 */
+                        {
+                                case 1:
+                                        mod_ind /= 32;
+                                        break;
+                                case 2:
+                                        mod_ind /= 16;
+                                        break;
+                                case 3:
+                                        mod_ind /= 8;
+                                        break;
+                                case 4:
+                                        mod_ind /= 4;
+                                        break;
+                                case 5:
+                                        mod_ind /= 2;
+                                        break;
+                                case 6:
+                                        mod_ind *= 2;
+                                        break;
+                                case 7:
+                                        mod_ind *= 4;
+                                        break;
+                        }
+#endif
 
                        if (mod_ind)
                        {

Reply via email to