Ejemplo n.º 1
0
 public static void N1WriteWord(int address, ushort value)
 {
     address &= 0xfffff;
     if (address >= 0x9ff00 && address + 1 <= 0x9ffff)
     {
     }
     else if (address >= 0xa0000 && address + 1 <= 0xa3fff)
     {
         int offset = address - 0xa0000;
         Memory.audioram[offset]     = (byte)value;
         Memory.audioram[offset + 1] = (byte)(value >> 8);
     }
     else if (address >= 0xa8000 && address + 1 <= 0xa803f)
     {
         int offset = (address - 0xa8000) / 2;
         Iremga20.irem_ga20_w(offset, value);
     }
     else if (address >= 0xa8040 && address + 1 <= 0xa8041)
     {
         YM2151.ym2151_register_port_0_w((byte)value);
     }
     else if (address >= 0xa8042 && address + 1 <= 0xa8043)
     {
         YM2151.ym2151_data_port_0_w((byte)value);
     }
     else if (address >= 0xa8044 && address + 1 <= 0xa8045)
     {
         m92_sound_irq_ack_w();
     }
     else if (address >= 0xa8046 && address + 1 <= 0xa8047)
     {
         m92_sound_status_w(value);
     }
 }
Ejemplo n.º 2
0
        public static ushort N1ReadWord(int address)
        {
            address &= 0xfffff;
            ushort result = 0;

            if (address >= 0 && address + 1 <= 0x1ffff)
            {
                result = (ushort)(Memory.audiorom[address] + Memory.audiorom[address + 1] * 0x100);
            }
            else if (address >= 0xa0000 && address + 1 <= 0xa3fff)
            {
                int offset = address - 0xa0000;
                result = (ushort)(Memory.audioram[offset] + Memory.audioram[offset + 1] * 0x100);
            }
            else if (address >= 0xa8000 && address + 1 <= 0xa803f)
            {
                int offset = (address - 0xa8000) / 2;
                result = Iremga20.irem_ga20_r(offset);
            }
            else if (address >= 0xa8042 && address + 1 <= 0xa8043)
            {
                result = YM2151.ym2151_status_port_0_r();
            }
            else if (address >= 0xa8044 && address + 1 <= 0xa8045)
            {
                result = m92_soundlatch_r();
            }
            else if (address >= 0xffff0 && address + 1 <= 0xfffff)
            {
                int offset = address - 0xe0000;
                result = (ushort)(Memory.mainrom[offset] + Memory.mainrom[offset + 1] * 0x100);
            }
            return(result);
        }
Ejemplo n.º 3
0
        public static byte N1ReadByte(int address)
        {
            address &= 0xfffff;
            byte result = 0;

            if (address >= 0 && address <= 0x1ffff)
            {
                result = Memory.audiorom[address];
            }
            else if (address >= 0xa0000 && address <= 0xa3fff)
            {
                int offset = address - 0xa0000;
                result = Memory.audioram[offset];
            }
            else if (address >= 0xa8000 && address <= 0xa803f)
            {
                int offset = (address - 0xa8000) / 2;
                result = (byte)Iremga20.irem_ga20_r(offset);
            }
            else if (address >= 0xa8042 && address <= 0xa8043)
            {
                result = YM2151.ym2151_status_port_0_r();
            }
            else if (address >= 0xa8044 && address <= 0xa8045)
            {
                result = (byte)m92_soundlatch_r();
            }
            else if (address >= 0xffff0 && address <= 0xfffff)
            {
                int offset = address - 0xe0000;
                result = Memory.mainrom[offset];
            }
            return(result);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public static void LoadStateBinary(BinaryReader reader)
        {
            int i, j;

            dsw                     = reader.ReadUInt16();
            irqvector               = reader.ReadByte();
            sound_status            = reader.ReadUInt16();
            bankaddress             = reader.ReadInt32();
            m92_irq_vectorbase      = reader.ReadByte();
            m92_raster_irq_position = reader.ReadInt32();
            m92_scanline_param      = reader.ReadInt32();
            setvector_param         = reader.ReadInt32();
            m92_sprite_buffer_busy  = reader.ReadByte();
            for (i = 0; i < 4; i++)
            {
                pf_master_control[i] = reader.ReadUInt16();
            }
            m92_sprite_list   = reader.ReadInt32();
            m92_vram_data     = reader.ReadBytes(0x10000);
            m92_spritecontrol = reader.ReadBytes(0x10);
            m92_game_kludge   = reader.ReadInt32();
            m92_palette_bank  = reader.ReadInt32();
            for (i = 0; i < 3; i++)
            {
                pf_layer[i].vram_base = reader.ReadUInt16();
            }
            for (i = 0; i < 3; i++)
            {
                for (j = 0; j < 4; j++)
                {
                    pf_layer[i].control[j] = reader.ReadUInt16();
                }
            }
            for (i = 0; i < 0x800; i++)
            {
                Generic.paletteram16[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 0x400; i++)
            {
                Generic.spriteram16[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 0x400; i++)
            {
                Generic.buffered_spriteram16[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 0x801; i++)
            {
                Palette.entry_color[i] = reader.ReadUInt32();
            }
            Memory.mainram = reader.ReadBytes(0x10000);
            Nec.nn1[0].LoadStateBinary(reader);
            Memory.audioram = reader.ReadBytes(0x4000);
            Nec.nn1[1].LoadStateBinary(reader);
            Cpuint.LoadStateBinary(reader);
            Timer.global_basetime.seconds     = reader.ReadInt32();
            Timer.global_basetime.attoseconds = reader.ReadInt64();
            Video.LoadStateBinary(reader);
            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);
            YM2151.LoadStateBinary(reader);
            Iremga20.LoadStateBinary(reader);
            Sound.latched_value[0] = reader.ReadUInt16();
            Sound.utempdata[0]     = reader.ReadUInt16();
            Sound.ym2151stream.output_sampindex        = reader.ReadInt32();
            Sound.ym2151stream.output_base_sampindex   = reader.ReadInt32();
            Sound.iremga20stream.output_sampindex      = reader.ReadInt32();
            Sound.iremga20stream.output_base_sampindex = reader.ReadInt32();
            Sound.mixerstream.output_sampindex         = reader.ReadInt32();
            Sound.mixerstream.output_base_sampindex    = reader.ReadInt32();
        }
Ejemplo n.º 6
0
        public static void SaveStateBinary(BinaryWriter writer)
        {
            int i, j;

            writer.Write(dsw);
            writer.Write(irqvector);
            writer.Write(sound_status);
            writer.Write(bankaddress);
            writer.Write(m92_irq_vectorbase);
            writer.Write(m92_raster_irq_position);
            writer.Write(m92_scanline_param);
            writer.Write(setvector_param);
            writer.Write(m92_sprite_buffer_busy);
            for (i = 0; i < 4; i++)
            {
                writer.Write(pf_master_control[i]);
            }
            writer.Write(m92_sprite_list);
            writer.Write(m92_vram_data, 0, 0x10000);
            writer.Write(m92_spritecontrol, 0, 0x10);
            writer.Write(m92_game_kludge);
            writer.Write(m92_palette_bank);
            for (i = 0; i < 3; i++)
            {
                writer.Write(pf_layer[i].vram_base);
            }
            for (i = 0; i < 3; i++)
            {
                for (j = 0; j < 4; j++)
                {
                    writer.Write(pf_layer[i].control[j]);
                }
            }
            for (i = 0; i < 0x800; i++)
            {
                writer.Write(Generic.paletteram16[i]);
            }
            for (i = 0; i < 0x400; i++)
            {
                writer.Write(Generic.spriteram16[i]);
            }
            for (i = 0; i < 0x400; i++)
            {
                writer.Write(Generic.buffered_spriteram16[i]);
            }
            for (i = 0; i < 0x801; i++)
            {
                writer.Write(Palette.entry_color[i]);
            }
            writer.Write(Memory.mainram, 0, 0x10000);
            Nec.nn1[0].SaveStateBinary(writer);
            writer.Write(Memory.audioram, 0, 0x4000);
            Nec.nn1[1].SaveStateBinary(writer);
            Cpuint.SaveStateBinary(writer);
            writer.Write(Timer.global_basetime.seconds);
            writer.Write(Timer.global_basetime.attoseconds);
            Video.SaveStateBinary(writer);
            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);
            YM2151.SaveStateBinary(writer);
            Iremga20.SaveStateBinary(writer);
            writer.Write(Sound.latched_value[0]);
            writer.Write(Sound.utempdata[0]);
            writer.Write(Sound.ym2151stream.output_sampindex);
            writer.Write(Sound.ym2151stream.output_base_sampindex);
            writer.Write(Sound.iremga20stream.output_sampindex);
            writer.Write(Sound.iremga20stream.output_base_sampindex);
            writer.Write(Sound.mixerstream.output_sampindex);
            writer.Write(Sound.mixerstream.output_base_sampindex);
        }