/* Demonstrates playing multi-voice music on the PSG using the CPC BIOS functions. Similar to the music example in "Making Arcade Games in C". */ #include #include #include "cpctelera.h" #include "sound_bios.h" //#link "sound_bios.c" #include "music.h" typedef unsigned char byte; typedef unsigned short word; // // MUSIC ROUTINES // void music_start(const byte* music); void music_update(); // Namespace(length=64, upper=49, freq=62500.0, bias=0, maxbits=12) // 430.0 4.526547151857908 49 const int note_table[64] = { 2464,2326,2195,2072,1956,1846,1742,1644,1552,1465,1383,1305,1232,1163,1098,1036,978,923,871,822,776,733,691,653,616,581,549,518,489,461,436,411,388,366,346,326,308,291,274,259,244,231,218,206,194,183,173,163,154,145,137,129,122,115,109,103,97,92,86,82,77,73,69,65,}; 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