view final_isi/time.c @ 89:ea44e1d9eb7c default tip

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 25 May 2014 05:03:14 +0300
parents 96dd9b4e3fe7
children
line wrap: on
line source

#include "musa.h"

#define NUMCH 3

char cord = 0, cpat = 0, crow = 0, drmt = 0xff, drms = 0;

char auditype;

int plrbeep[2];
int musatempo = 5;

int freku[12] =
{
    0x157, 0x16b, 0x181, 0x198, 0x1b0, 0x1ca,
    0x1e5, 0x202, 0x220, 0x241, 0x263, 0x287
};

char plst = 0;

/*char ison[3]={1,1,1};*/
char hvilk[3] = { 0xfe, 0xfe, 0xfe };

int lizayz = 0;


void playtick()
{
    plst++;

    if (plst == musatempo)
    {
        int l;
        unsigned char mark, mkrl;

        for (l = 0; l < NUMCH; l++)
        {

            mkrl = mark = trax[cpat][l][crow];

            if (mark < 0xf0)
                mkrl = mark += lizayz;

            if (auditype == 2)
                plrbeep[l] = mark;

            if (mark == 0xfa)
            {
                musatempo = 8;
                lizayz = -16;
            }

            if (mark == 0xfb)
                if (auditype == 2)
                {
                    if (crow & 1)
                        mark = 0xfe;
                    else
                        mark = hvilk[l];
                    plrbeep[l] = mark;
                }

            if (mark == 0xfe)
                gbsound(l, 0);

            if (mark == 0xfd)
                musatempo = 16;
            if (mark == 0xfc)
                musatempo = 4;

            if (mark < 0xf0)
            {

                if (mark == mkrl)
                    hvilk[l] = mark;
                if ((mark & 15) >= 12)
                    mark += 4;

                gbsound(l, (mark & 15) + ((mark >> 4) * 12));

            }
        }

        crow++;
        if (crow == 64)
        {
            crow = 0;
            cord++;
            cpat = patord[cord];
            if (cpat == 99)
            {
                cord = 0;
                cpat = patord[cord];
            }
        }
        plst = 0;
    }
}