diff --git a/Frameworks/GME/vgmplay/chips/fm.c b/Frameworks/GME/vgmplay/chips/fm.c index dc680909d..7b3131f0e 100644 --- a/Frameworks/GME/vgmplay/chips/fm.c +++ b/Frameworks/GME/vgmplay/chips/fm.c @@ -2480,6 +2480,111 @@ typedef YM2610 YM2608; /* Algorithm and tables verified on real YM2608 and YM2610 */ + +#ifdef __clang__ +#define Init_ADPCMATable() +static const int jedi_table[49 * 16] = +{ + 2, 6, 10, 14, 18, 22, 26, 30, + -2, -6, -10, -14, -18, -22, -26, -30, + 2, 6, 10, 14, 19, 23, 27, 31, + -2, -6, -10, -14, -19, -23, -27, -31, + 2, 7, 11, 16, 21, 26, 30, 35, + -2, -7, -11, -16, -21, -26, -30, -35, + 2, 7, 13, 18, 23, 28, 34, 39, + -2, -7, -13, -18, -23, -28, -34, -39, + 2, 8, 14, 20, 25, 31, 37, 43, + -2, -8, -14, -20, -25, -31, -37, -43, + 3, 9, 15, 21, 28, 34, 40, 46, + -3, -9, -15, -21, -28, -34, -40, -46, + 3, 10, 17, 24, 31, 38, 45, 52, + -3, -10, -17, -24, -31, -38, -45, -52, + 3, 11, 19, 27, 34, 42, 50, 58, + -3, -11, -19, -27, -34, -42, -50, -58, + 4, 12, 21, 29, 38, 46, 55, 63, + -4, -12, -21, -29, -38, -46, -55, -63, + 4, 13, 23, 32, 41, 50, 60, 69, + -4, -13, -23, -32, -41, -50, -60, -69, + 5, 15, 25, 35, 46, 56, 66, 76, + -5, -15, -25, -35, -46, -56, -66, -76, + 5, 16, 28, 39, 50, 61, 73, 84, + -5, -16, -28, -39, -50, -61, -73, -84, + 6, 18, 31, 43, 56, 68, 81, 93, + -6, -18, -31, -43, -56, -68, -81, -93, + 6, 20, 34, 48, 61, 75, 89, 103, + -6, -20, -34, -48, -61, -75, -89, -103, + 7, 22, 37, 52, 67, 82, 97, 112, + -7, -22, -37, -52, -67, -82, -97, -112, + 8, 24, 41, 57, 74, 90, 107, 123, + -8, -24, -41, -57, -74, -90, -107, -123, + 9, 27, 45, 63, 82, 100, 118, 136, + -9, -27, -45, -63, -82, -100, -118, -136, + 10, 30, 50, 70, 90, 110, 130, 150, + -10, -30, -50, -70, -90, -110, -130, -150, + 11, 33, 55, 77, 99, 121, 143, 165, + -11, -33, -55, -77, -99, -121, -143, -165, + 12, 36, 60, 84, 109, 133, 157, 181, + -12, -36, -60, -84, -109, -133, -157, -181, + 13, 40, 66, 93, 120, 147, 173, 200, + -13, -40, -66, -93, -120, -147, -173, -200, + 14, 44, 73, 103, 132, 162, 191, 221, + -14, -44, -73, -103, -132, -162, -191, -221, + 16, 48, 81, 113, 146, 178, 211, 243, + -16, -48, -81, -113, -146, -178, -211, -243, + 17, 53, 89, 125, 160, 196, 232, 268, + -17, -53, -89, -125, -160, -196, -232, -268, + 19, 58, 98, 137, 176, 215, 255, 294, + -19, -58, -98, -137, -176, -215, -255, -294, + 21, 64, 108, 151, 194, 237, 281, 324, + -21, -64, -108, -151, -194, -237, -281, -324, + 23, 71, 118, 166, 213, 261, 308, 356, + -23, -71, -118, -166, -213, -261, -308, -356, + 26, 78, 130, 182, 235, 287, 339, 391, + -26, -78, -130, -182, -235, -287, -339, -391, + 28, 86, 143, 201, 258, 316, 373, 431, + -28, -86, -143, -201, -258, -316, -373, -431, + 31, 94, 158, 221, 284, 347, 411, 474, + -31, -94, -158, -221, -284, -347, -411, -474, + 34, 104, 174, 244, 313, 383, 453, 523, + -34, -104, -174, -244, -313, -383, -453, -523, + 38, 115, 191, 268, 345, 422, 498, 575, + -38, -115, -191, -268, -345, -422, -498, -575, + 42, 126, 210, 294, 379, 463, 547, 631, + -42, -126, -210, -294, -379, -463, -547, -631, + 46, 139, 231, 324, 417, 510, 602, 695, + -46, -139, -231, -324, -417, -510, -602, -695, + 51, 153, 255, 357, 459, 561, 663, 765, + -51, -153, -255, -357, -459, -561, -663, -765, + 56, 168, 280, 392, 505, 617, 729, 841, + -56, -168, -280, -392, -505, -617, -729, -841, + 61, 185, 308, 432, 555, 679, 802, 926, + -61, -185, -308, -432, -555, -679, -802, -926, + 68, 204, 340, 476, 612, 748, 884, 1020, + -68, -204, -340, -476, -612, -748, -884, -1020, + 74, 224, 373, 523, 672, 822, 971, 1121, + -74, -224, -373, -523, -672, -822, -971, -1121, + 82, 246, 411, 575, 740, 904, 1069, 1233, + -82, -246, -411, -575, -740, -904, -1069, -1233, + 90, 271, 452, 633, 814, 995, 1176, 1357, + -90, -271, -452, -633, -814, -995, -1176, -1357, + 99, 298, 497, 696, 895, 1094, 1293, 1492, + -99, -298, -497, -696, -895, -1094, -1293, -1492, + 109, 328, 547, 766, 985, 1204, 1423, 1642, + -109, -328, -547, -766, -985, -1204, -1423, -1642, + 120, 361, 601, 842, 1083, 1324, 1564, 1805, + -120, -361, -601, -842, -1083, -1324, -1564, -1805, + 132, 397, 662, 927, 1192, 1457, 1722, 1987, + -132, -397, -662, -927, -1192, -1457, -1722, -1987, + 145, 437, 728, 1020, 1311, 1603, 1894, 2186, + -145, -437, -728, -1020, -1311, -1603, -1894, -2186, + 160, 480, 801, 1121, 1442, 1762, 2083, 2403, + -160, -480, -801, -1121, -1442, -1762, -2083, -2403, + 176, 529, 881, 1234, 1587, 1940, 2292, 2645, + -176, -529, -881, -1234, -1587, -1940, -2292, -2645, + 194, 582, 970, 1358, 1746, 2134, 2522, 2910, + -194, -582, -970, -1358, -1746, -2134, -2522, -2910, +}; +#else /* usual ADPCM table (16 * 1.1^N) */ static const int steps[49] = { @@ -2492,27 +2597,29 @@ static const int steps[49] = 876, 963, 1060, 1166, 1282, 1411, 1552 }; -/* different from the usual ADPCM table */ -static const int step_inc[8] = { -1*16, -1*16, -1*16, -1*16, 2*16, 5*16, 7*16, 9*16 }; - /* speedup purposes only */ static int jedi_table[ 49*16 ]; - +/* clang with Xcode 7.2.1 mis-optimizes the !(nib&0x08) steps to zero when compiled with -Os */ static void Init_ADPCMATable(void) { - int step, nib; - - for (step = 0; step < 49; step++) - { - /* loop over all nibbles and compute the difference */ - for (nib = 0; nib < 16; nib++) - { - int value = (2*(nib & 0x07) + 1) * steps[step] / 8; - jedi_table[step*16 + nib] = (nib&0x08) ? -value : value; - } - } + int step, nib; + + for (step = 0; step < 49; step++) + { + /* loop over all nibbles and compute the difference */ + for (nib = 0; nib < 16; nib++) + { + int value = (2*(nib & 0x07) + 1) * steps[step] / 8; + jedi_table[step*16 + nib] = (nib&0x08) ? -value : value; + } + } } +#endif + +/* different from the usual ADPCM table */ +static const int step_inc[8] = { -1*16, -1*16, -1*16, -1*16, 2*16, 5*16, 7*16, 9*16 }; + /* ADPCM A (Non control type) : calculate one channel output */ INLINE void ADPCMA_calc_chan( YM2610 *F2610, ADPCM_CH *ch )