/* Demonstrates playing multi-voice music on the SN76489A PSG using the CVLib functions. Similar to the music example in "Making Arcade Games in C". */ #include #include #include #include typedef unsigned char byte; typedef unsigned short word; // // MUSIC ROUTINES // void music_start(const byte* music); void music_update(); // Namespace(bias=0, freq=1789772.5, length=64, maxbits=15.0, upper=49) // 437.0 459.515928524 49 const int note_table[64] = { 17356, 32764, 30926, 29190, 27551, 26005, 24546, 23168, 21868, 20640, 19482, 18388, 17356, 32765, 30926, 29190, 27552, 26005, 24546, 23168, 21868, 20640, 19482, 18389, 17357, 16382, 15463, 14595, 13776, 13003, 12273, 11584, 10934, 10320, 9741, 9194, 8678, 8191, 7731, 7298, 6888, 6501, 6136, 5792, 5467, 5160, 4871, 4597, 4339, 4096, 3866, 3649, 3444, 3251, 3068, 2896, 2733, 2580, 2435, 2299, 2170, 2048, 1933, 1824, }; struct { byte volume; } voice[3]; byte music_index = 0; byte cur_duration = 0; byte num_voices = 3; static const byte* music_ptr = NULL; inline byte next_music_byte() { return *music_ptr++; } void music_update() { byte ch; byte freech = 0; for (ch=0; ch