Small bug in the ym2612's source code

Issue #171 invalid
Former user created an issue

Original [issue 171](https://code.google.com/p/genplus-gx/issues/detail?id=171) created by le.moulin.studio on 2011-04-29T06:35:39.000Z:

I think that this block:

/\* 14-bit channel output \*/ if (out\_fm[0] > 8191) out\_fm[0] = 8192; else if (out\_fm[0] < -8192) out\_fm[0] = -8192; if (out\_fm[1] > 8191) out\_fm[1] = 8192; else if (out\_fm[1] < -8192) out\_fm[1] = -8192; if (out\_fm[2] > 8191) out\_fm[2] = 8192; else if (out\_fm[2] < -8192) out\_fm[2] = -8192; if (out\_fm[3] > 8191) out\_fm[3] = 8192; else if (out\_fm[3] < -8192) out\_fm[3] = -8192; if (out\_fm[4] > 8191) out\_fm[4] = 8192; else if (out\_fm[4] < -8192) out\_fm[4] = -8192; if (out\_fm[5] > 8191) out\_fm[5] = 8192; else if (out\_fm[5] < -8192) out\_fm[5] = -8192;

should be:

/\* 14-bit channel output \*/ if (out\_fm[0] > 8191) out\_fm[0] = 8191; else if (out\_fm[0] < -8192) out\_fm[0] = -8192; if (out\_fm[1] > 8191) out\_fm[1] = 8191; else if (out\_fm[1] < -8192) out\_fm[1] = -8192; if (out\_fm[2] > 8191) out\_fm[2] = 8191; else if (out\_fm[2] < -8192) out\_fm[2] = -8192; if (out\_fm[3] > 8191) out\_fm[3] = 8191; else if (out\_fm[3] < -8192) out\_fm[3] = -8192; if (out\_fm[4] > 8191) out\_fm[4] = 8191; else if (out\_fm[4] < -8192) out\_fm[4] = -8192; if (out\_fm[5] > 8191) out\_fm[5] = 8191; else if (out\_fm[5] < -8192) out\_fm[5] = -8192;

Am I right?

Comments (3)

  1. Former user Account Deleted

    Comment # 1 originally posted by ekeeke31 on 2011-04-29T07:42:47.000Z:

    No, this is deliberate: range when summing operators is -8192;8192. This comes from these researches: http://gendev.spritesmind.net/forum/viewtopic.php?t=386&postdays=0&postorder=asc&start=540

    I am not emulating this exactly as described since i assume a 14-bit DAC (this can be changed in options) so -256;256 range (9-bit DAC input range) is left unshifted i.e -8192;8192

  2. Former user Account Deleted

    Comment # 2 originally posted by le.moulin.studio on 2011-04-29T09:37:03.000Z:

    Ok, you are right. However, the code would be better written:

    /\* 14-bit channel output \*/ if (out\_fm[0] > 8192) out\_fm[0] = 8192; else if (out\_fm[0] < -8192) out\_fm[0] = -8192; if (out\_fm[1] > 8192) out\_fm[1] = 8192; else if (out\_fm[1] < -8192) out\_fm[1] = -8192; if (out\_fm[2] > 8192) out\_fm[2] = 8192; else if (out\_fm[2] < -8192) out\_fm[2] = -8192; if (out\_fm[3] > 8192) out\_fm[3] = 8192; else if (out\_fm[3] < -8192) out\_fm[3] = -8192; if (out\_fm[4] > 8192) out\_fm[4] = 8192; else if (out\_fm[4] < -8192) out\_fm[4] = -8192; if (out\_fm[5] > 8192) out\_fm[5] = 8192; else if (out\_fm[5] < -8192) out\_fm[5] = -8192;

  3. Former user Account Deleted

    Comment # 3 originally posted by ekeeke31 on 2011-04-29T09:53:53.000Z:

    Yeah, I know. But this was so unimportant (and still correct) that I left if this way...

    I can change it this really hurts your eyes too much ;-)

  4. Log in to comment