PT
games/alis / src / Alis / Emu8950Vars.php · commit 9c722cf
<?phpnamespace App\Alis;/** File-scope variables and tables of emu8950/emu8950.c (built by Emu8950Vars::init(), C initializeTables()). */final class Emu8950Vars{    /* exp_table[x] = round((exp2((double)x / 256.0) - 1) * 1024) */    public const exp_table = [        0, 3, 6, 8, 11, 14, 17, 20, 22, 25, 28, 31, 34, 37, 40, 42,        45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90,        93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 130, 133, 136, 139,        142, 145, 148, 152, 155, 158, 161, 164, 168, 171, 174, 177, 181, 184, 187, 190,        194, 197, 200, 204, 207, 210, 214, 217, 220, 224, 227, 231, 234, 237, 241, 244,        248, 251, 255, 258, 262, 265, 268, 272, 276, 279, 283, 286, 290, 293, 297, 300,        304, 308, 311, 315, 318, 322, 326, 329, 333, 337, 340, 344, 348, 352, 355, 359,        363, 367, 370, 374, 378, 382, 385, 389, 393, 397, 401, 405, 409, 412, 416, 420,        424, 428, 432, 436, 440, 444, 448, 452, 456, 460, 464, 468, 472, 476, 480, 484,        488, 492, 496, 501, 505, 509, 513, 517, 521, 526, 530, 534, 538, 542, 547, 551,        555, 560, 564, 568, 572, 577, 581, 585, 590, 594, 599, 603, 607, 612, 616, 621,        625, 630, 634, 639, 643, 648, 652, 657, 661, 666, 670, 675, 680, 684, 689, 693,        698, 703, 708, 712, 717, 722, 726, 731, 736, 741, 745, 750, 755, 760, 765, 770,        774, 779, 784, 789, 794, 799, 804, 809, 814, 819, 824, 829, 834, 839, 844, 849,        854, 859, 864, 869, 874, 880, 885, 890, 895, 900, 906, 911, 916, 921, 927, 932,        937, 942, 948, 953, 959, 964, 969, 975, 980, 986, 991, 996, 1002, 1007, 1013, 1018,    ];    /* logsin_table[x] = round(-log2(sin((x + 0.5) * PI / (PG_WIDTH / 4) / 2)) * 256) */    public const logsin_table = [        2137, 1731, 1543, 1419, 1326, 1252, 1190, 1137, 1091, 1050, 1013, 979, 949, 920, 894, 869,        846, 825, 804, 785, 767, 749, 732, 717, 701, 687, 672, 659, 646, 633, 621, 609,        598, 587, 576, 566, 556, 546, 536, 527, 518, 509, 501, 492, 484, 476, 468, 461,        453, 446, 439, 432, 425, 418, 411, 405, 399, 392, 386, 380, 375, 369, 363, 358,        352, 347, 341, 336, 331, 326, 321, 316, 311, 307, 302, 297, 293, 289, 284, 280,        276, 271, 267, 263, 259, 255, 251, 248, 244, 240, 236, 233, 229, 226, 222, 219,        215, 212, 209, 205, 202, 199, 196, 193, 190, 187, 184, 181, 178, 175, 172, 169,        167, 164, 161, 159, 156, 153, 151, 148, 146, 143, 141, 138, 136, 134, 131, 129,        127, 125, 122, 120, 118, 116, 114, 112, 110, 108, 106, 104, 102, 100, 98, 96,        94, 92, 91, 89, 87, 85, 83, 82, 80, 78, 77, 75, 74, 72, 70, 69,        67, 66, 64, 63, 62, 60, 59, 57, 56, 55, 53, 52, 51, 49, 48, 47,        46, 45, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30,        29, 28, 27, 26, 25, 24, 23, 23, 22, 21, 20, 20, 19, 18, 17, 17,        16, 15, 15, 14, 13, 13, 12, 12, 11, 10, 10, 9, 9, 8, 8, 7,        7, 7, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2,        2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,    ];    /* offset to fnum, rough approximation of 14 cents depth. */    public const pm_table = [        [0, 0, 0, 0, 0, 0, 0, 0],    // fnum = 000xxxxx        [0, 0, 1, 0, 0, 0, -1, 0],   // fnum = 001xxxxx        [0, 1, 2, 1, 0, -1, -2, -1], // fnum = 010xxxxx        [0, 1, 3, 1, 0, -1, -3, -1], // fnum = 011xxxxx        [0, 2, 4, 2, 0, -2, -4, -2], // fnum = 100xxxxx        [0, 2, 5, 2, 0, -2, -5, -2], // fnum = 101xxxxx        [0, 3, 6, 3, 0, -3, -6, -3], // fnum = 110xxxxx        [0, 3, 7, 3, 0, -3, -7, -3], // fnum = 111xxxxx    ];    /* amplitude lfo table: each element repeats 64 cycles */    public const am_table = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,        2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,        4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,        6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,        8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,        10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11,        12, 12, 12, 12, 12, 12, 12, 12,        13, 13, 13,        12, 12, 12, 12, 12, 12, 12, 12,        11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10,        9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8,        7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6,        5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,        3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2,        1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0];    /* envelope decay increment step table */    public const eg_step_tables = [        [0, 1, 0, 1, 0, 1, 0, 1],        [0, 1, 0, 1, 1, 1, 0, 1],        [0, 1, 1, 1, 0, 1, 1, 1],        [0, 1, 1, 1, 1, 1, 1, 1],    ];    public const eg_step_tables_fast = [        [1, 1, 1, 1, 1, 1, 1, 1],        [1, 1, 1, 2, 1, 1, 1, 2],        [1, 2, 1, 2, 1, 2, 1, 2],        [1, 2, 2, 2, 1, 2, 2, 2],    ];    public const ml_table = [1, 1 * 2, 2 * 2, 3 * 2, 4 * 2, 5 * 2, 6 * 2, 7 * 2,        8 * 2, 9 * 2, 10 * 2, 10 * 2, 12 * 2, 12 * 2, 15 * 2, 15 * 2];    // dB2(x) = x * 2    public const kl_table = [0.000 * 2, 9.000 * 2, 12.000 * 2, 13.875 * 2, 15.000 * 2, 16.125 * 2,        16.875 * 2, 17.625 * 2, 18.000 * 2, 18.750 * 2, 19.125 * 2, 19.500 * 2,        19.875 * 2, 20.250 * 2, 20.625 * 2, 21.000 * 2];    /** OPL_writeReg's static stbl[32]: register offset -> slot */    public const stbl = [0, 2, 4, 1, 3, 5, -1, -1, 6, 8, 10, 7, 9, 11, -1, -1,        12, 14, 16, 13, 15, 17, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];    /** C static uint16_t wave_table_map[4][PG_WIDTH] */    public static array $wave_table_map = [];    /** C static uint32_t tll_table[8 * 16][1 << TL_BITS][4], flattened: [((blk_fnum >> 6) << 8) | (TL << 2) | KL] */    public static array $tll_table = [];    /** C static int32_t rks_table[2][32][2], flattened: [(notesel << 6) | (blk_fnum98 << 1) | KR] */    public static array $rks_table = [];    public static int $table_initialized = 0;    /**     * PORT (speed): wave tables with the sign bit 0x8000 moved to 0x2000, so that "wave value + attenuation" indexes     * the packed table $lin (lookup_exp_table() of every possible value): see to_linear().     */    public static array $wave_fast = [];    public static array $lin = [];    /** PORT (speed): the noise LFSR advanced by 18 / 14 / 2 steps, per byte of the state: [steps][byte][value] */    public static array $noise_jump = [];}