Beispiel #1
0
 static Pokey()
 {
     for (int i = 0; i < Mame.MAXPOKEYS; i++)
         _pokey[i] = new POKEYregisters();
 }
Beispiel #2
0
        public override int start(Mame.MachineSound msound)
        {
            intf = (POKEYinterface)msound.sound_interface;

            poly9 = new byte[0x1ff + 1];
            rand9 = new byte[0x1ff + 1];
            poly17 = new byte[0x1ffff + 1];
            rand17 = new byte[0x1ffff + 1];

            /* initialize the poly counters */
            poly_init(poly4, 4, 3, 1, 0x00004);
            poly_init(poly5, 5, 3, 2, 0x00008);
            poly_init(poly9, 9, 2, 7, 0x00080);
            poly_init(poly17, 17, 7, 10, 0x18000);

            /* initialize the random arrays */
            rand_init(rand9, 9, 2, 7, 0x00080);
            rand_init(rand17, 17, 7, 10, 0x18000);

            for (int chip = 0; chip < intf.num; chip++)
            {
                _pokey[chip] = new POKEYregisters();
                string name = "";

                //memset(p, 0, sizeof(struct POKEYregisters));

                _pokey[chip].samplerate_24_8 = (uint)((Mame.Machine.sample_rate) != 0 ? (intf.baseclock << 8) / Mame.Machine.sample_rate : 1);
                _pokey[chip].divisor[CHAN1] = 4;
                _pokey[chip].divisor[CHAN2] = 4;
                _pokey[chip].divisor[CHAN3] = 4;
                _pokey[chip].divisor[CHAN4] = 4;
                _pokey[chip].clockmult = DIV_64;
                _pokey[chip].KBCODE = 0x09;		 /* Atari 800 'no key' */
                _pokey[chip].SKCTL = SK_RESET;	 /* let the RNG run after reset */
                _pokey[chip].rtimer = Mame.Timer.timer_set(Mame.Timer.TIME_NEVER, chip, null);

                _pokey[chip].pot_r[0] = intf.pot0_r[chip];
                _pokey[chip].pot_r[1] = intf.pot1_r[chip];
                _pokey[chip].pot_r[2] = intf.pot2_r[chip];
                _pokey[chip].pot_r[3] = intf.pot3_r[chip];
                _pokey[chip].pot_r[4] = intf.pot4_r[chip];
                _pokey[chip].pot_r[5] = intf.pot5_r[chip];
                _pokey[chip].pot_r[6] = intf.pot6_r[chip];
                _pokey[chip].pot_r[7] = intf.pot7_r[chip];
                _pokey[chip].allpot_r = intf.allpot_r[chip];
                _pokey[chip].serin_r = intf.serin_r[chip];
                _pokey[chip].serout_w = intf.serout_w[chip];
                _pokey[chip].interrupt_cb = intf.interrupt_cb[chip];

                name = Mame.sprintf(name, "Pokey #%d", chip);
                _pokey[chip].channel = Mame.stream_init(name, intf.mixing_level[chip], Mame.Machine.sample_rate, chip, _update[chip]);

                if (_pokey[chip].channel == -1)
                {
                    Mame.printf("failed to initialize sound channel");
                    return 1;
                }
            }

            return 0;
        }