Beispiel #1
0
        public static void sound_reset()
        {
            switch (Machine.sBoard)
            {
            case "CPS-1":
                YM2151.ym2151_reset_chip();
                OKI6295.okim6295_reset();
                break;

            case "CPS-1(QSound)":
            case "CPS2":
                break;

            case "Neo Geo":
                FM.ym2610_reset_chip();
                break;

            case "Namco System 1":
                YM2151.ym2151_reset_chip();
                break;

            case "IGS011":
                OKI6295.okim6295_reset();
                break;

            case "PGM":
                ICS2115.ics2115_reset();
                break;
            }
        }
Beispiel #2
0
        public static void LoadStateBinary(BinaryReader reader)
        {
            int i, j;

            pgm_tx_videoram  = reader.ReadBytes(0x2000);
            pgm_bg_videoram  = reader.ReadBytes(0x4000);
            pgm_rowscrollram = reader.ReadBytes(0x800);
            pgm_videoregs    = reader.ReadBytes(0x10000);
            CalVal           = reader.ReadByte();
            CalMask          = reader.ReadByte();
            CalCom           = reader.ReadByte();
            CalCnt           = reader.ReadByte();
            asic3_reg        = reader.ReadByte();
            asic3_x          = reader.ReadByte();
            for (i = 0; i < 3; i++)
            {
                asic3_latch[i] = reader.ReadByte();
            }
            asic3_hold         = reader.ReadUInt16();
            asic3_hilo         = reader.ReadUInt16();
            Video.paletteram16 = reader.ReadBytes(0x1200);
            for (i = 0; i < 0x901; i++)
            {
                Palette.entry_color[i] = reader.ReadUInt32();
            }
            Memory.mainram = reader.ReadBytes(0x20000);
            MC68000.m1.LoadStateBinary(reader);
            Memory.audioram = reader.ReadBytes(0x10000);
            Z80A.z1.LoadStateBinary(reader);
            Cpuint.LoadStateBinary(reader);
            Timer.global_basetime.seconds                   = reader.ReadInt32();
            Timer.global_basetime.attoseconds               = reader.ReadInt64();
            Video.screenstate.vblank_start_time.seconds     = reader.ReadInt32();
            Video.screenstate.vblank_start_time.attoseconds = reader.ReadInt64();
            Video.screenstate.frame_number                  = reader.ReadInt64();
            Sound.last_update_second = reader.ReadInt32();
            for (i = 0; i < 2; i++)
            {
                Cpuexec.cpu[i].suspend               = reader.ReadByte();
                Cpuexec.cpu[i].nextsuspend           = reader.ReadByte();
                Cpuexec.cpu[i].eatcycles             = reader.ReadByte();
                Cpuexec.cpu[i].nexteatcycles         = reader.ReadByte();
                Cpuexec.cpu[i].localtime.seconds     = reader.ReadInt32();
                Cpuexec.cpu[i].localtime.attoseconds = reader.ReadInt64();
            }
            Timer.LoadStateBinary(reader);
            ICS2115.LoadStateBinary(reader);
            for (i = 0; i < 3; i++)
            {
                Sound.latched_value[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 3; i++)
            {
                Sound.utempdata[i] = reader.ReadUInt16();
            }
            Sound.ics2115stream.output_sampindex      = reader.ReadInt32();
            Sound.ics2115stream.output_base_sampindex = reader.ReadInt32();
            Sound.mixerstream.output_sampindex        = reader.ReadInt32();
            Sound.mixerstream.output_base_sampindex   = reader.ReadInt32();
        }
Beispiel #3
0
        public static void SaveStateBinary(BinaryWriter writer)
        {
            int i, j;

            writer.Write(pgm_tx_videoram, 0, 0x2000);
            writer.Write(pgm_bg_videoram, 0, 0x4000);
            writer.Write(pgm_rowscrollram, 0, 0x800);
            writer.Write(pgm_videoregs, 0, 0x10000);
            writer.Write(CalVal);
            writer.Write(CalMask);
            writer.Write(CalCom);
            writer.Write(CalCnt);
            writer.Write(asic3_reg);
            writer.Write(asic3_x);
            for (i = 0; i < 3; i++)
            {
                writer.Write(asic3_latch[i]);
            }
            writer.Write(asic3_hold);
            writer.Write(asic3_hilo);
            writer.Write(Video.paletteram16, 0, 0x1200);
            for (i = 0; i < 0x901; i++)
            {
                writer.Write(Palette.entry_color[i]);
            }
            writer.Write(Memory.mainram, 0, 0x20000);
            MC68000.m1.SaveStateBinary(writer);
            writer.Write(Memory.audioram, 0, 0x10000);
            Z80A.z1.SaveStateBinary(writer);
            Cpuint.SaveStateBinary(writer);
            writer.Write(Timer.global_basetime.seconds);
            writer.Write(Timer.global_basetime.attoseconds);
            writer.Write(Video.screenstate.vblank_start_time.seconds);
            writer.Write(Video.screenstate.vblank_start_time.attoseconds);
            writer.Write(Video.screenstate.frame_number);
            writer.Write(Sound.last_update_second);
            for (i = 0; i < 2; i++)
            {
                writer.Write(Cpuexec.cpu[i].suspend);
                writer.Write(Cpuexec.cpu[i].nextsuspend);
                writer.Write(Cpuexec.cpu[i].eatcycles);
                writer.Write(Cpuexec.cpu[i].nexteatcycles);
                writer.Write(Cpuexec.cpu[i].localtime.seconds);
                writer.Write(Cpuexec.cpu[i].localtime.attoseconds);
            }
            Timer.SaveStateBinary(writer);
            ICS2115.SaveStateBinary(writer);
            for (i = 0; i < 3; i++)
            {
                writer.Write(Sound.latched_value[i]);
            }
            for (i = 0; i < 3; i++)
            {
                writer.Write(Sound.utempdata[i]);
            }
            writer.Write(Sound.ics2115stream.output_sampindex);
            writer.Write(Sound.ics2115stream.output_base_sampindex);
            writer.Write(Sound.mixerstream.output_sampindex);
            writer.Write(Sound.mixerstream.output_base_sampindex);
        }
Beispiel #4
0
        private static void ics2115_0_word_w1(int offset, byte data)
        {
            switch (offset)
            {
            case 1:
                break;

            case 2:
                ICS2115.ics2115_w(3, data);
                break;
            }
        }
Beispiel #5
0
 public static void z80_reset_w(ushort data)
 {
     if (data == 0x5050)
     {
         ICS2115.ics2115_reset();
         Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_HALT, LineState.CLEAR_LINE);
         Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_RESET, LineState.PULSE_LINE);
     }
     else
     {
         Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_HALT, LineState.ASSERT_LINE);
     }
 }
Beispiel #6
0
        private static void ics2115_0_word_w(int offset, ushort data)
        {
            switch (offset)
            {
            case 1:
                ICS2115.ics2115_w(1, (byte)data);
                break;

            case 2:
                ICS2115.ics2115_w(2, (byte)data);
                ICS2115.ics2115_w(3, (byte)(data >> 8));
                break;
            }
        }
Beispiel #7
0
        private static ushort ics2115_0_word_r(int offset)
        {
            switch (offset)
            {
            case 0:
                return(ICS2115.ics2115_r(0));

            case 1:
                return(ICS2115.ics2115_r(1));

            case 2:
                return((ushort)((ICS2115.ics2115_r(3) << 8) | ICS2115.ics2115_r(2)));
            }
            return(0xff);
        }
Beispiel #8
0
        private static byte ics2115_0_word_r2(int offset)
        {
            switch (offset)
            {
            case 0:
                return(ICS2115.ics2115_r(0));

            case 1:
                return(ICS2115.ics2115_r(1));

            case 2:
                return(ICS2115.ics2115_r(2));
            }
            return(0xff);
        }
Beispiel #9
0
        private static byte ics2115_0_word_r1(int offset)
        {
            switch (offset)
            {
            case 0:
                return(0);

            case 1:
                return(0);

            case 2:
                return(ICS2115.ics2115_r(3));
            }
            return(0);
        }
Beispiel #10
0
 public static void ZWriteHardware(ushort address, byte value)
 {
     if (address >= 0x8000 && address <= 0x8003)
     {
         int offset = address - 0x8000;
         ICS2115.ics2115_w(offset, value);
     }
     else if (address >= 0x8100 && address <= 0x81ff)
     {
         z80_l3_w(value);
     }
     else if (address >= 0x8200 && address <= 0x82ff)
     {
         Sound.soundlatch_w((ushort)value);
     }
     else if (address >= 0x8400 && address <= 0x84ff)
     {
         Sound.soundlatch2_w((ushort)value);
     }
 }
Beispiel #11
0
        public static byte ZReadHardware(ushort address)
        {
            byte result = 0;

            if (address >= 0x8000 && address <= 0x8003)
            {
                int offset = address - 0x8000;
                result = ICS2115.ics2115_r(offset);
            }
            else if (address >= 0x8100 && address <= 0x81ff)
            {
                result = (byte)Sound.soundlatch3_r();
            }
            else if (address >= 0x8200 && address <= 0x82ff)
            {
                result = (byte)Sound.soundlatch_r();
            }
            else if (address >= 0x8400 && address <= 0x84ff)
            {
                result = (byte)Sound.soundlatch2_r();
            }
            return(result);
        }
Beispiel #12
0
        public static void sound_init()
        {
            iRecord = 0;

            leftmix  = new int[0x3c0];
            rightmix = new int[0x3c0];

            finalmixb = new byte[0xf00];

            sound_muted = 0;

            buf2.Play(0, BufferPlayFlags.Looping);

            last_update_second = 0;
            //WavWrite.CreateSoundFile(@"\VS2008\compare1\compare1\bin\Debug\2.wav");
            Atime update_frequency = new Atime(0, Attotime.ATTOSECONDS_PER_SECOND / 50);

            switch (Machine.sBoard)
            {
            case "CPS-1":
                latched_value      = new ushort[2];
                utempdata          = new ushort[2];
                sound_update       = sound_updateC;
                sound_update_timer = Timer.timer_alloc_common(sound_update, "sound_update", false);
                YM2151.ym2151_init(3579545);
                OKI6295.okim6295_start();
                ym2151stream = new sound_stream(55930, 0, 2, YM2151.ym2151_update_one);
                okistream    = new sound_stream(1000000 / 132, 0, 1, OKI6295.okim6295_update);
                mixerstream  = new sound_stream(48000, 3, 0, null);
                break;

            case "CPS-1(QSound)":
            case "CPS2":
                sound_update       = sound_updateQ;
                sound_update_timer = Timer.timer_alloc_common(sound_update, "sound_update", false);
                QSound.qsound_start();
                qsoundstream = new sound_stream(4000000 / 166, 0, 2, QSound.qsound_update);
                mixerstream  = new sound_stream(48000, 2, 0, null);
                break;

            case "Neo Geo":
                latched_value      = new ushort[2];
                utempdata          = new ushort[2];
                sound_update       = sound_updateN;
                sound_update_timer = Timer.timer_alloc_common(sound_update, "sound_update", false);
                YM2610.ym2610_start();
                ay8910stream = new sound_stream(250000, 0, 1, AY8910.ay8910_update);
                ym2610stream = new sound_stream(111111, 0, 2, FM.ym2610_update_one);
                mixerstream  = new sound_stream(48000, 3, 0, null);
                break;

            case "Namco System 1":
                sound_update       = sound_updateNa;
                sound_update_timer = Timer.timer_alloc_common(sound_update, "sound_update", false);
                YM2151.ym2151_init(3579580);
                Namco.namco_start();
                DAC.dac_start();
                ym2151stream = new sound_stream(55930, 0, 2, YM2151.ym2151_update_one);
                namcostream  = new sound_stream(192000, 0, 2, Namco.namco_update_stereo);
                dacstream    = new sound_stream(192000, 0, 1, DAC.DAC_update);
                mixerstream  = new sound_stream(48000, 5, 0, null);
                break;

            case "IGS011":
                sound_update       = sound_updateIGS011;
                sound_update_timer = Timer.timer_alloc_common(sound_update, "sound_update", false);
                OKI6295.okim6295_start();
                YM3812.ym3812_start(3579545);
                okistream    = new sound_stream(1047600 / 132, 0, 1, OKI6295.okim6295_update);
                ym3812stream = new sound_stream(49715, 0, 1, FMOpl.ym3812_update_one);
                mixerstream  = new sound_stream(48000, 2, 0, null);
                break;

            case "PGM":
                latched_value      = new ushort[3];
                utempdata          = new ushort[3];
                sound_update       = sound_updatePGM;
                sound_update_timer = Timer.timer_alloc_common(sound_update, "sound_update", false);
                ICS2115.ics2115_start();
                ics2115stream = new sound_stream(33075, 0, 2, ICS2115.ics2115_update);
                mixerstream   = new sound_stream(48000, 2, 0, null);
                break;

            case "M72":
                latched_value      = new ushort[1];
                utempdata          = new ushort[1];
                sound_update       = sound_updateM72;
                sound_update_timer = Timer.timer_alloc_common(sound_update, "sound_update", false);
                YM2151.ym2151_init(3579545);
                DAC.dac_start();
                ym2151stream = new sound_stream(55930, 0, 2, YM2151.ym2151_update_one);
                dacstream    = new sound_stream(192000, 0, 1, DAC.DAC_update);
                mixerstream  = new sound_stream(48000, 3, 0, null);
                break;

            case "M92":
                latched_value      = new ushort[1];
                utempdata          = new ushort[1];
                sound_update       = sound_updateM92;
                sound_update_timer = Timer.timer_alloc_common(sound_update, "sound_update", false);
                YM2151.ym2151_init(3579545);
                Iremga20.iremga20_start();
                ym2151stream   = new sound_stream(55930, 0, 2, YM2151.ym2151_update_one);
                iremga20stream = new sound_stream(894886, 0, 2, Iremga20.iremga20_update);
                mixerstream    = new sound_stream(48000, 4, 0, null);
                break;
            }
            Timer.timer_adjust_periodic(sound_update_timer, update_frequency, update_frequency);
        }