Mercurial > hg > forks > pwpunix
diff nykyaeka/musa.c @ 0:acb5694e93d9
Initial import.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 18 May 2010 04:25:44 +0300 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nykyaeka/musa.c Tue May 18 04:25:44 2010 +0300 @@ -0,0 +1,72 @@ +#define pwplib_volume 64 + /* to pwplib.h -- pwplib.setup[SOUND_VOLUME] */ + +#include "pwpdemo.h" + +#include "musa.h" + +struct +{ + int ord,patt,row; + int tick,tempo; +}player; + +void newnote() +{ + int c=0; + + for(;c<3;c++) + { + int note=pwpmusic[player.patt][c][player.row]; + + if(note==253) + { + if(player.tempo==6)player.tempo=50;else + player.tempo=4; + }else + if(note==254) + pwplib_sound_nv(c,0,0); + else + if(note!=255) + pwplib_sound_nv(c,(note-5)<<8,pwplib_volume); + } + player.row++; + if(player.row==64) + { + player.row=0; + player.ord++; + player.patt=pwpmusic_order[player.ord]; + + if(player.patt>128) + { + if(player.patt==255)player.ord=0;else + { + if(player.patt==254)player.tempo=5; + player.ord++; + } + player.patt=pwpmusic_order[player.ord]; + } + } +} + +void playtick() +{ + if(player.tick==0) + newnote(); + + player.tick++; + if(player.tick==player.tempo) + player.tick=0; +} + +void initplayer() +{ + player.row=player.ord; + player.patt=pwpmusic_order[0]; + player.tick=0; + player.tempo=6; + pwplib_setplayer(playtick); +} + + +/* loopflush(); */