Example #1
0
        private void resetSample(byte chipID)
        {
            chipID &= 1;
            GigatronState g = gig[chipID];

            g.soundTable = new byte[256];
            int r = (int)DateTime.Now.Ticks;

            for (int i = 0; i < 64; i++)
            {
                //noise
                r += r * 56465321 + 456156321;
                g.soundTable[i * 4 + 0] = (byte)(r & 63);
                //Triangle
                g.soundTable[i * 4 + 1] = (byte)(i < 32 ? 2 * i : (127 - 2 * i));
                //Pulse
                g.soundTable[i * 4 + 2] = (byte)(i < 32 ? 0 : 63);
                //Sawtooth
                g.soundTable[i * 4 + 3] = (byte)i;
            }
        }
Example #2
0
        public override int Write(byte chipID, int port, int adr, int data)
        {
            chipID &= 1;
            GigatronState g   = gig[chipID];
            ushort        ad  = (ushort)adr;
            byte          dat = (byte)data;

            if (ad == 0x21)
            {
                g.channelMask = (byte)(dat & 0x7);
                return(0);
            }

            int hi = ad & 0xff00;
            int lo = ad & 0xff;

            if (hi == 0x0700)
            {
                g.soundTable[lo] = dat;
                return(0);
            }

            if (lo < 250)
            {
                return(0);
            }
            if (hi < 0x100)
            {
                return(0);
            }
            if (hi > 0x400)
            {
                return(0);
            }

            Channel c = g.ch[(hi >> 8) - 1];

            switch (lo)
            {
            case 250:
                c.wavA = dat;
                break;

            case 251:
                c.wavX = dat;
                break;

            case 252:
                c.key = (short)((c.key & 0xff80) | (dat & 0x7f));
                break;

            case 253:
                c.key = (short)((c.key & 0x007f) | (dat << 7));
                break;

            case 254:
                c.osc = (short)((c.osc & 0xff80) | (dat & 0x7f));
                break;

            case 255:
                c.osc = (short)((c.osc & 0x007f) | (dat << 7));
                break;
            }

            return(0);
        }