Exemple #1
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();
        }
Exemple #2
0
        public static void machine_reset_namcos1()
        {
            cus117_offset[0, 0]   = 0x0180 * 0x2000;
            cus117_offset[0, 1]   = 0x0180 * 0x2000;
            cus117_offset[0, 7]   = 0x03ff * 0x2000;
            cus117_offset[1, 0]   = 0x0180 * 0x2000;
            cus117_offset[1, 7]   = 0x03ff * 0x2000;
            user1rom_offset[0, 7] = cus117_offset[0, 7] - 0x400000;
            user1rom_offset[1, 7] = cus117_offset[1, 7] - 0x400000;
            Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_RESET, LineState.ASSERT_LINE);
            Cpuint.cpunum_set_input_line(2, (int)LineState.INPUT_LINE_RESET, LineState.ASSERT_LINE);
            Cpuint.cpunum_set_input_line(3, (int)LineState.INPUT_LINE_RESET, LineState.ASSERT_LINE);
            mcu_patch_data = 0;
            namcos1_reset  = 0;
            namcos1_init_DACs();
            int i, j;

            for (i = 0; i < 8; i++)
            {
                key[i] = 0;
            }
            for (i = 0; i < 2; i++)
            {
                for (j = 0; j < 8; j++)
                {
                    cus117_offset[i, j] = 0;
                }
            }
            wdog = 0;
        }
Exemple #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);
        }
Exemple #4
0
        public static void setvector_callback()
        {
            switch (setvector_param)
            {
            case 0:
                irqvector = 0xff;
                break;

            case 1:
                irqvector &= 0xef;
                break;

            case 2:
                irqvector |= 0x10;
                break;

            case 3:
                irqvector &= 0xdf;
                break;

            case 4:
                irqvector |= 0x20;
                break;
            }
            Cpuint.interrupt_vector[1, 0] = irqvector;
            if (irqvector == 0xff)
            {
                Cpuint.cpunum_set_input_line(1, 0, LineState.CLEAR_LINE);
            }
            else
            {
                Cpuint.cpunum_set_input_line(1, 0, LineState.ASSERT_LINE);
            }
        }
Exemple #5
0
        private static void update_interrupts()
        {
            int level = 0;

            if (vblank_interrupt_pending != 0)
            {
                level = 1;
            }
            if (display_position_interrupt_pending != 0)
            {
                level = 2;
            }
            if (irq3_pending != 0)
            {
                level = 3;
            }
            if (level == 1)
            {
                Cpuint.cpunum_set_input_line(0, 1, LineState.ASSERT_LINE);
            }
            else if (level == 2)
            {
                Cpuint.cpunum_set_input_line(0, 2, LineState.ASSERT_LINE);
            }
            else if (level == 3)
            {
                Cpuint.cpunum_set_input_line(0, 3, LineState.ASSERT_LINE);
            }
            else
            {
                Cpuint.cpunum_set_input_line(0, 7, LineState.CLEAR_LINE);
            }
        }
Exemple #6
0
        public static void SaveStateBinaryC(BinaryWriter writer)
        {
            int i;

            writer.Write(dswa);
            writer.Write(dswb);
            writer.Write(dswc);
            writer.Write(basebanksnd);
            for (i = 0; i < 0x20; i++)
            {
                writer.Write(cps_a_regs[i]);
            }
            for (i = 0; i < 0x20; i++)
            {
                writer.Write(cps_b_regs[i]);
            }
            for (i = 0; i < 0xc00; i++)
            {
                writer.Write(Palette.entry_color[i]);
            }
            writer.Write(Memory.mainram, 0, 0x10000);
            writer.Write(gfxram, 0, 0x30000);
            MC68000.m1.SaveStateBinary(writer);
            writer.Write(Memory.audioram, 0, 0x800);
            Z80A.z1.SaveStateBinary(writer);
            Cpuint.SaveStateBinary(writer);
            writer.Write(Timer.global_basetime.seconds);
            writer.Write(Timer.global_basetime.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);
            writer.Write(Memory.audioram, 0, 0x800);
            YM2151.SaveStateBinary(writer);
            OKI6295.SaveStateBinary(writer);
            for (i = 0; i < 2; i++)
            {
                writer.Write(Sound.latched_value[i]);
            }
            for (i = 0; i < 2; i++)
            {
                writer.Write(Sound.utempdata[i]);
            }
            writer.Write(Sound.ym2151stream.output_sampindex);
            writer.Write(Sound.ym2151stream.output_base_sampindex);
            writer.Write(Sound.okistream.output_sampindex);
            writer.Write(Sound.okistream.output_base_sampindex);
            writer.Write(Sound.mixerstream.output_sampindex);
            writer.Write(Sound.mixerstream.output_base_sampindex);
        }
Exemple #7
0
        public static void LoadStateBinaryC(BinaryReader reader)
        {
            int i, i1, n1, n2;

            dswa        = reader.ReadByte();
            dswb        = reader.ReadByte();
            dswc        = reader.ReadByte();
            basebanksnd = reader.ReadInt32();
            for (i = 0; i < 0x20; i++)
            {
                cps_a_regs[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 0x20; i++)
            {
                cps_b_regs[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 0xc00; i++)
            {
                Palette.entry_color[i] = reader.ReadUInt32();
            }
            Memory.mainram = reader.ReadBytes(0x10000);
            gfxram         = reader.ReadBytes(0x30000);
            MC68000.m1.LoadStateBinary(reader);
            Memory.audioram = reader.ReadBytes(0x800);
            Z80A.z1.LoadStateBinary(reader);
            Cpuint.LoadStateBinary(reader);
            Timer.global_basetime.seconds     = reader.ReadInt32();
            Timer.global_basetime.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);
            Memory.audioram = reader.ReadBytes(0x800);
            YM2151.LoadStateBinary(reader);
            OKI6295.LoadStateBinary(reader);
            for (i = 0; i < 2; i++)
            {
                Sound.latched_value[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 2; i++)
            {
                Sound.utempdata[i] = reader.ReadUInt16();
            }
            Sound.ym2151stream.output_sampindex      = reader.ReadInt32();
            Sound.ym2151stream.output_base_sampindex = reader.ReadInt32();
            Sound.okistream.output_sampindex         = reader.ReadInt32();
            Sound.okistream.output_base_sampindex    = reader.ReadInt32();
            Sound.mixerstream.output_sampindex       = reader.ReadInt32();
            Sound.mixerstream.output_base_sampindex  = reader.ReadInt32();
        }
Exemple #8
0
        public static void LoadStateBinaryQ(BinaryReader reader)
        {
            int i;

            dswa        = reader.ReadByte();
            dswb        = reader.ReadByte();
            dswc        = reader.ReadByte();
            basebanksnd = reader.ReadInt32();
            for (i = 0; i < 0x20; i++)
            {
                cps_a_regs[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 0x20; i++)
            {
                cps_b_regs[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 0xc00; i++)
            {
                Palette.entry_color[i] = reader.ReadUInt32();
            }
            Memory.mainram = reader.ReadBytes(0x10000);
            gfxram         = reader.ReadBytes(0x30000);
            MC68000.m1.LoadStateBinary(reader);
            Memory.audioram = reader.ReadBytes(0x800);
            Z80A.z1.LoadStateBinary(reader);
            Cpuint.LoadStateBinary(reader);
            Timer.global_basetime.seconds     = reader.ReadInt32();
            Timer.global_basetime.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);
            qsound_sharedram1 = reader.ReadBytes(0x1000);
            qsound_sharedram2 = reader.ReadBytes(0x1000);
            //QSound.LoadStateBinary(reader);
            //Sound.qsoundstream.output_sampindex = reader.ReadInt32();
            //Sound.qsoundstream.output_base_sampindex = reader.ReadInt32();
            //Sound.mixerstream.output_sampindex = reader.ReadInt32();
            //Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
            Eeprom.eeprom_data      = reader.ReadBytes(0x80);
            Eeprom.serial_buffer    = reader.ReadBytes(40);
            Eeprom.clock_line       = (LineState)reader.ReadInt32();
            Eeprom.reset_line       = (LineState)reader.ReadInt32();
            Eeprom.locked           = reader.ReadInt32();
            Eeprom.serial_count     = reader.ReadInt32();
            Eeprom.latch            = reader.ReadInt32();
            Eeprom.sending          = reader.ReadInt32();
            Eeprom.eeprom_data_bits = reader.ReadInt32();
        }
Exemple #9
0
        public static void SaveStateBinaryQ(BinaryWriter writer)
        {
            int i;

            writer.Write(dswa);
            writer.Write(dswb);
            writer.Write(dswc);
            writer.Write(basebanksnd);
            for (i = 0; i < 0x20; i++)
            {
                writer.Write(cps_a_regs[i]);
            }
            for (i = 0; i < 0x20; i++)
            {
                writer.Write(cps_b_regs[i]);
            }
            for (i = 0; i < 0xc00; i++)
            {
                writer.Write(Palette.entry_color[i]);
            }
            writer.Write(Memory.mainram, 0, 0x10000);
            writer.Write(gfxram, 0, 0x30000);
            MC68000.m1.SaveStateBinary(writer);
            writer.Write(Memory.audioram, 0, 0x800);
            Z80A.z1.SaveStateBinary(writer);
            Cpuint.SaveStateBinary(writer);
            writer.Write(Timer.global_basetime.seconds);
            writer.Write(Timer.global_basetime.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);
            writer.Write(qsound_sharedram1);
            writer.Write(qsound_sharedram2);
            //QSound.SaveStateBinary(writer);
            //writer.Write(Sound.qsoundstream.output_sampindex);
            //writer.Write(Sound.qsoundstream.output_base_sampindex);
            //writer.Write(Sound.mixerstream.output_sampindex);
            //writer.Write(Sound.mixerstream.output_base_sampindex);
            writer.Write(Eeprom.eeprom_data);
            writer.Write(Eeprom.serial_buffer);
            writer.Write((int)Eeprom.clock_line);
            writer.Write((int)Eeprom.reset_line);
            writer.Write(Eeprom.locked);
            writer.Write(Eeprom.serial_count);
            writer.Write(Eeprom.latch);
            writer.Write(Eeprom.sending);
            writer.Write(Eeprom.eeprom_data_bits);
        }
Exemple #10
0
 public static void cps2_eeprom_port_bl(int data)
 {
     Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_RESET, ((data & 0x0008) != 0) ? LineState.CLEAR_LINE : LineState.ASSERT_LINE);
     Generic.coin_counter_w(0, data & 0x0001);
     Generic.coin_counter_w(1, data & 0x0002);
     Generic.coin_lockout_w(0, ~data & 0x0010);
     Generic.coin_lockout_w(1, ~data & 0x0020);
     Generic.coin_lockout_w(2, ~data & 0x0040);
     Generic.coin_lockout_w(3, ~data & 0x0080);
 }
Exemple #11
0
 public static void lhb2_interrupt()
 {
     if (Cpuexec.iloops == 0)
     {
         Cpuint.cpunum_set_input_line(0, 6, LineState.HOLD_LINE);
     }
     else
     {
         Cpuint.cpunum_set_input_line(0, 5, LineState.HOLD_LINE);
     }
 }
Exemple #12
0
 public static void namcos1_cpu_control_w(byte data)
 {
     if (((data & 1) ^ namcos1_reset) != 0)
     {
         mcu_patch_data = 0;
         namcos1_reset  = data & 1;
     }
     Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_RESET, ((data & 1) != 0) ? LineState.CLEAR_LINE : LineState.ASSERT_LINE);
     Cpuint.cpunum_set_input_line(2, (int)LineState.INPUT_LINE_RESET, ((data & 1) != 0) ? LineState.CLEAR_LINE : LineState.ASSERT_LINE);
     Cpuint.cpunum_set_input_line(3, (int)LineState.INPUT_LINE_RESET, ((data & 1) != 0) ? LineState.CLEAR_LINE : LineState.ASSERT_LINE);
 }
Exemple #13
0
 public static void soft_reset()
 {
     Memory.memory_reset();
     Cpuint.cpuint_reset();
     Machine.machine_reset_callback();
     Cpuexec.cpuexec_reset();
     Watchdog.watchdog_internal_reset();
     //Sound.sound_reset();
     playState = PlayState.PLAY_RUNNING;
     Timer.timer_set_global_time(Timer.get_current_time());
 }
Exemple #14
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);
     }
 }
Exemple #15
0
 public static void init_machine()
 {
     //Inptport.input_init();
     Generic.generic_machine_init();
     Timer.timer_init();
     soft_reset_timer = Timer.timer_alloc_common(soft_reset, "soft_reset", false);
     //Inptport.input_port_init();
     Cpuexec.cpuexec_init();
     Watchdog.watchdog_init();
     Cpuint.cpuint_init();
     Video.video_init();
     //Sound.sound_init();
     State.state_init();
     Machine.machine_start();
 }
Exemple #16
0
 public static void lhb_interrupt()
 {
     if (lhb_irq_enable == 0)
     {
         return;
     }
     if (Cpuexec.iloops == 0)
     {
         Cpuint.cpunum_set_input_line(0, 6, LineState.HOLD_LINE);
     }
     else
     {
         Cpuint.cpunum_set_input_line(0, 5, LineState.HOLD_LINE);
     }
 }
Exemple #17
0
        public static void cps2_interrupt()
        {
            /* 2 is vblank, 4 is some sort of scanline interrupt, 6 is both at the same time. */
            if (scancount >= 261)
            {
                scancount      = -1;
                cps1_scancalls = 0;
            }
            scancount++;
            if ((cps_b_regs[0x10 / 2] & 0x8000) != 0)
            {
                cps_b_regs[0x10 / 2] = (ushort)(cps_b_regs[0x10 / 2] & 0x1ff);
            }
            if ((cps_b_regs[0x12 / 2] & 0x8000) != 0)
            {
                cps_b_regs[0x12 / 2] = (ushort)(cps_b_regs[0x12 / 2] & 0x1ff);
            }

            /*if(cps1_scanline1 == scancount || (cps1_scanline1 < scancount && (cps1_scancalls!=0)))
             * {
             *  CPS1.cps1_cps_b_regs[0x10 / 2] = 0;
             *
             *  cpunum_set_input_line(machine, 0, 4, HOLD_LINE);
             *  cps2_set_sprite_priorities();
             *  video_screen_update_partial(machine->primary_screen, 16 - 10 + scancount);
             *  cps1_scancalls++;
             * }
             * if(cps1_scanline2 == scancount || (cps1_scanline2 < scancount && !cps1_scancalls))
             * {
             *  cps1_cps_b_regs[0x12/2] = 0;
             *  cpunum_set_input_line(machine, 0, 4, HOLD_LINE);
             *  cps2_set_sprite_priorities();
             *  video_screen_update_partial(machine->primary_screen, 16 - 10 + scancount);
             *  cps1_scancalls++;
             * }*/
            if (scancount == 256)  /* VBlank */
            {
                cps_b_regs[0x10 / 2] = (ushort)cps1_scanline1;
                cps_b_regs[0x12 / 2] = (ushort)cps1_scanline2;
                Cpuint.cpunum_set_input_line(0, 2, LineState.HOLD_LINE);
                if (cps1_scancalls != 0)
                {
                    cps2_set_sprite_priorities();
                    //video_screen_update_partial(machine->primary_screen, 256);
                }
                cps2_objram_latch();
            }
        }
Exemple #18
0
        public static void cps2_eeprom_port_w(int data)
        {
            //high 8 bits
            {
                /* bit 0 - Unused */
                /* bit 1 - Unused */
                /* bit 2 - Unused */
                /* bit 3 - Unused? */
                /* bit 4 - Eeprom data  */
                /* bit 5 - Eeprom clock */
                /* bit 6 - */
                /* bit 7 - */

                /* EEPROM */
                Eeprom.eeprom_write_bit(data & 0x1000);
                Eeprom.eeprom_set_clock_line(((data & 0x2000) != 0) ? LineState.ASSERT_LINE : LineState.CLEAR_LINE);
                Eeprom.eeprom_set_cs_line(((data & 0x4000) != 0) ? LineState.CLEAR_LINE : LineState.ASSERT_LINE);
            }
            //low 8 bits
            {
                /* bit 0 - coin counter 1 */
                /* bit 0 - coin counter 2 */
                /* bit 2 - Unused */
                /* bit 3 - Allows access to Z80 address space (Z80 reset) */
                /* bit 4 - lock 1  */
                /* bit 5 - lock 2  */
                /* bit 6 - */
                /* bit 7 - */

                /* Z80 Reset */
                Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_RESET, ((data & 0x0008) != 0) ? LineState.CLEAR_LINE : LineState.ASSERT_LINE);

                Generic.coin_counter_w(0, data & 0x0001);
                Generic.coin_counter_w(1, data & 0x0002);

                Generic.coin_lockout_w(0, ~data & 0x0010);
                Generic.coin_lockout_w(1, ~data & 0x0020);
                Generic.coin_lockout_w(2, ~data & 0x0040);
                Generic.coin_lockout_w(3, ~data & 0x0080);

                /*
                 * set_led_status(0,data & 0x01);
                 * set_led_status(1,data & 0x10);
                 * set_led_status(2,data & 0x20);
                 */
            }
        }
Exemple #19
0
        public static void setvector_callback()
        {
            /*StreamWriter sw1 = new StreamWriter("1.txt", false);
             * sw1.WriteLine(Video.screenstate.frame_number.ToString() + "\t" + setvector_param.ToString());
             * sw1.Close();*/
            switch (setvector_param)
            {
            case 0:
                irqvector = 0;
                break;

            case 1:
                irqvector |= 0x2;
                break;

            case 2:
                irqvector &= 0xfd;
                break;

            case 3:
                irqvector |= 0x1;
                break;

            case 4:
                irqvector &= 0xfe;
                break;
            }

            if ((irqvector & 0x2) != 0)
            {
                Cpuint.interrupt_vector[1, 0] = 0x18;
            }
            else if ((irqvector & 0x1) != 0)
            {
                Cpuint.interrupt_vector[1, 0] = 0x19;
            }
            if (irqvector == 0)
            {
                Cpuint.cpunum_set_input_line(1, 0, LineState.CLEAR_LINE);
            }
            else
            {
                Cpuint.cpunum_set_input_line(1, 0, LineState.ASSERT_LINE);
            }
        }
Exemple #20
0
 public static void m72_port02_w(ushort data)
 {
     //if (ACCESSING_BITS_0_7)
     {
         //coin_counter_w(0,data & 0x01);
         //coin_counter_w(1,data & 0x02);
         //flip_screen_set(((data & 0x04) >> 2) ^ ((~input_port_read(machine, "DSW") >> 8) & 1));
         video_off = data & 0x08;
         if ((data & 0x10) != 0)
         {
             Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_RESET, LineState.CLEAR_LINE);
         }
         else
         {
             Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_RESET, LineState.ASSERT_LINE);
         }
     }
 }
Exemple #21
0
 public static void m68k_l1_w(byte data)
 {
     //if(ACCESSING_BITS_0_7)
     Sound.soundlatch_w(data);
     Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_NMI, LineState.PULSE_LINE);
 }
Exemple #22
0
 public static void machine_reset_pgm()
 {
     Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_HALT, LineState.ASSERT_LINE);
     device_reset();
 }
Exemple #23
0
 public static void firq_ack_w(int cpunum)
 {
     Cpuint.cpunum_set_input_line(cpunum, 1, LineState.CLEAR_LINE);
 }
Exemple #24
0
        public static void LoadStateBinaryC(BinaryReader reader)
        {
            int i;

            dswa        = reader.ReadByte();
            dswb        = reader.ReadByte();
            dswc        = reader.ReadByte();
            basebanksnd = reader.ReadInt32();
            for (i = 0; i < 0x20; i++)
            {
                cps_a_regs[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 0x20; i++)
            {
                cps_b_regs[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 0xc00; i++)
            {
                Palette.entry_color[i] = reader.ReadUInt32();
            }
            Memory.mainram = reader.ReadBytes(0x10000);
            gfxram         = reader.ReadBytes(0x30000);
            MC68000.m1.LoadStateBinary(reader);
            Memory.audioram = reader.ReadBytes(0x800);
            Z80A.z1.LoadStateBinary(reader);
            Cpuint.LoadStateBinary(reader);
            Timer.global_basetime.seconds     = reader.ReadInt32();
            Timer.global_basetime.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);
            //YM2151.LoadStateBinary(reader);
            //OKI6295.LoadStateBinary(reader);
            for (i = 0; i < 2; i++)
            {
                //Sound.latched_value[i] = reader.ReadUInt16();
            }
            for (i = 0; i < 2; i++)
            {
                //Sound.utempdata[i] = reader.ReadUInt16();
            }
            //Sound.ym2151stream.output_sampindex = reader.ReadInt32();
            //Sound.ym2151stream.output_base_sampindex = reader.ReadInt32();
            //Sound.okistream.output_sampindex = reader.ReadInt32();
            //Sound.okistream.output_base_sampindex = reader.ReadInt32();
            //Sound.mixerstream.output_sampindex = reader.ReadInt32();
            //Sound.mixerstream.output_base_sampindex = reader.ReadInt32();
            switch (RomInfo.Rom.Name)
            {
            case "forgottn":
            case "forgottna":
            case "forgottnu":
            case "forgottnue":
            case "forgottnuc":
            case "forgottnua":
            case "forgottnuaa":
            case "lostwrld":
            case "lostwrldo":
                //Inptport.portdata.last_delta_nsec = reader.ReadInt64();
                break;
            }
        }
Exemple #25
0
        public static void SaveStateBinaryC(BinaryWriter writer)
        {
            int i;

            writer.Write(dswa);
            writer.Write(dswb);
            writer.Write(dswc);
            writer.Write(basebanksnd);
            for (i = 0; i < 0x20; i++)
            {
                writer.Write(cps_a_regs[i]);
            }
            for (i = 0; i < 0x20; i++)
            {
                writer.Write(cps_b_regs[i]);
            }
            for (i = 0; i < 0xc00; i++)
            {
                writer.Write(Palette.entry_color[i]);
            }
            writer.Write(Memory.mainram, 0, 0x10000);
            writer.Write(gfxram, 0, 0x30000);
            MC68000.m1.SaveStateBinary(writer);
            writer.Write(Memory.audioram, 0, 0x800);
            Z80A.z1.SaveStateBinary(writer);
            Cpuint.SaveStateBinary(writer);
            writer.Write(Timer.global_basetime.seconds);
            writer.Write(Timer.global_basetime.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);
            //YM2151.SaveStateBinary(writer);
            //OKI6295.SaveStateBinary(writer);
            for (i = 0; i < 2; i++)
            {
                //writer.Write(Sound.latched_value[i]);
            }
            for (i = 0; i < 2; i++)
            {
                //writer.Write(Sound.utempdata[i]);
            }
            //writer.Write(Sound.ym2151stream.output_sampindex);
            //writer.Write(Sound.ym2151stream.output_base_sampindex);
            //writer.Write(Sound.okistream.output_sampindex);
            //writer.Write(Sound.okistream.output_base_sampindex);
            //writer.Write(Sound.mixerstream.output_sampindex);
            //writer.Write(Sound.mixerstream.output_base_sampindex);
            switch (RomInfo.Rom.Name)
            {
            case "forgottn":
            case "forgottna":
            case "forgottnu":
            case "forgottnue":
            case "forgottnuc":
            case "forgottnua":
            case "forgottnuaa":
            case "lostwrld":
            case "lostwrldo":
                //writer.Write(Inptport.portdata.last_delta_nsec);
                break;
            }
        }
Exemple #26
0
 public static void audio_cpu_check_nmi()
 {
     Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_NMI, (audio_cpu_nmi_enabled && audio_cpu_nmi_pending) ? LineState.ASSERT_LINE : LineState.CLEAR_LINE);
 }
Exemple #27
0
        public static void LoadStateBinary(BinaryReader reader)
        {
            int i, j;

            dipsw = reader.ReadByte();
            for (i = 0; i < 0x2000; i++)
            {
                Palette.entry_color[i] = reader.ReadUInt32();
            }
            bank_ram20                = reader.ReadBytes(0x2000);
            bank_ram30                = reader.ReadBytes(0x80);
            namcos1_videoram          = reader.ReadBytes(0x8000);
            namcos1_cus116            = reader.ReadBytes(0x10);
            namcos1_spriteram         = reader.ReadBytes(0x1000);
            namcos1_playfield_control = reader.ReadBytes(0x20);
            copy_sprites              = reader.ReadInt32();
            s1ram              = reader.ReadBytes(0x8000);
            namcos1_triram     = reader.ReadBytes(0x800);
            namcos1_paletteram = reader.ReadBytes(0x8000);
            key = reader.ReadBytes(8);
            audiocpurom_offset = reader.ReadInt32();
            mcu_patch_data     = reader.ReadInt32();
            mcurom_offset      = reader.ReadInt32();
            namcos1_reset      = reader.ReadInt32();
            wdog                  = reader.ReadInt32();
            dac0_value            = reader.ReadInt32();
            dac1_value            = reader.ReadInt32();
            dac0_gain             = reader.ReadInt32();
            dac1_gain             = reader.ReadInt32();
            Generic.generic_nvram = reader.ReadBytes(0x800);
            for (i = 0; i < 2; i++)
            {
                for (j = 0; j < 8; j++)
                {
                    cus117_offset[i, j] = reader.ReadInt32();
                }
            }
            for (i = 0; i < 2; i++)
            {
                for (j = 0; j < 8; j++)
                {
                    user1rom_offset[i, j] = reader.ReadInt32();
                }
            }
            for (i = 0; i < 3; i++)
            {
                M6809.mm1[i].PC.LowWord   = reader.ReadUInt16();
                M6809.mm1[i].PPC.LowWord  = reader.ReadUInt16();
                M6809.mm1[i].D.LowWord    = reader.ReadUInt16();
                M6809.mm1[i].DP.LowWord   = reader.ReadUInt16();
                M6809.mm1[i].U.LowWord    = reader.ReadUInt16();
                M6809.mm1[i].S.LowWord    = reader.ReadUInt16();
                M6809.mm1[i].X.LowWord    = reader.ReadUInt16();
                M6809.mm1[i].Y.LowWord    = reader.ReadUInt16();
                M6809.mm1[i].CC           = reader.ReadByte();
                M6809.mm1[i].irq_state[0] = (LineState)reader.ReadByte();
                M6809.mm1[i].irq_state[1] = (LineState)reader.ReadByte();
                M6809.mm1[i].int_state    = reader.ReadByte();
                M6809.mm1[i].nmi_state    = (LineState)reader.ReadByte();
            }
            M6800.m1.PPC.LowWord      = reader.ReadUInt16();
            M6800.m1.PC.LowWord       = reader.ReadUInt16();
            M6800.m1.S.LowWord        = reader.ReadUInt16();
            M6800.m1.X.LowWord        = reader.ReadUInt16();
            M6800.m1.D.LowWord        = reader.ReadUInt16();
            M6800.m1.cc               = reader.ReadByte();
            M6800.m1.wai_state        = reader.ReadByte();
            M6800.m1.nmi_state        = (LineState)reader.ReadByte();
            M6800.m1.irq_state[0]     = (LineState)reader.ReadByte();
            M6800.m1.irq_state[1]     = (LineState)reader.ReadByte();
            M6800.m1.ic_eddge         = reader.ReadByte();
            M6800.m1.port1_ddr        = reader.ReadByte();
            M6800.m1.port2_ddr        = reader.ReadByte();
            M6800.m1.port3_ddr        = reader.ReadByte();
            M6800.m1.port4_ddr        = reader.ReadByte();
            M6800.m1.port1_data       = reader.ReadByte();
            M6800.m1.port2_data       = reader.ReadByte();
            M6800.m1.port3_data       = reader.ReadByte();
            M6800.m1.port4_data       = reader.ReadByte();
            M6800.m1.tcsr             = reader.ReadByte();
            M6800.m1.pending_tcsr     = reader.ReadByte();
            M6800.m1.irq2             = reader.ReadByte();
            M6800.m1.ram_ctrl         = reader.ReadByte();
            M6800.m1.counter.d        = reader.ReadUInt32();
            M6800.m1.output_compare.d = reader.ReadUInt32();
            M6800.m1.input_capture    = reader.ReadUInt16();
            M6800.m1.timer_over.d     = reader.ReadUInt32();
            M6800.m1.clock            = reader.ReadInt32();
            M6800.m1.trcsr            = reader.ReadByte();
            M6800.m1.rmcr             = reader.ReadByte();
            M6800.m1.rdr              = reader.ReadByte();
            M6800.m1.tdr              = reader.ReadByte();
            M6800.m1.rsr              = reader.ReadByte();
            M6800.m1.tsr              = reader.ReadByte();
            M6800.m1.rxbits           = reader.ReadInt32();
            M6800.m1.txbits           = reader.ReadInt32();
            M6800.m1.txstate          = (M6800.M6800_TX_STATE)reader.ReadInt32();
            M6800.m1.trcsr_read       = reader.ReadInt32();
            M6800.m1.tx               = reader.ReadInt32();
            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 < 4; 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();
                Cpuexec.cpu[i].TotalExecutedCycles   = reader.ReadUInt64();
                Cpuexec.cpu[i].PendingCycles         = reader.ReadInt32();
            }
            Timer.LoadStateBinary(reader);
            YM2151.LoadStateBinary(reader);
            Namco.nam1.num_voices   = reader.ReadInt32();
            Namco.nam1.sound_enable = reader.ReadInt32();
            for (i = 0; i < 16; i++)
            {
                for (j = 0; j < 32 * 16; j++)
                {
                    Namco.nam1.waveform[i][j] = reader.ReadInt16();
                }
            }
            for (i = 0; i < 8; i++)
            {
                Namco.nam1.channel_list[i].frequency       = reader.ReadInt32();
                Namco.nam1.channel_list[i].counter         = reader.ReadInt32();
                Namco.nam1.channel_list[i].volume[0]       = reader.ReadInt32();
                Namco.nam1.channel_list[i].volume[1]       = reader.ReadInt32();
                Namco.nam1.channel_list[i].noise_sw        = reader.ReadInt32();
                Namco.nam1.channel_list[i].noise_state     = reader.ReadInt32();
                Namco.nam1.channel_list[i].noise_seed      = reader.ReadInt32();
                Namco.nam1.channel_list[i].noise_hold      = reader.ReadInt32();
                Namco.nam1.channel_list[i].noise_counter   = reader.ReadInt32();
                Namco.nam1.channel_list[i].waveform_select = reader.ReadInt32();
            }
            Namco.namco_wavedata = reader.ReadBytes(0x400);
            DAC.dac1.output      = reader.ReadInt16();
            Sound.ym2151stream.output_sampindex      = reader.ReadInt32();
            Sound.ym2151stream.output_base_sampindex = reader.ReadInt32();
            Sound.namcostream.output_sampindex       = reader.ReadInt32();
            Sound.namcostream.output_base_sampindex  = reader.ReadInt32();
            Sound.dacstream.output_sampindex         = reader.ReadInt32();
            Sound.dacstream.output_base_sampindex    = reader.ReadInt32();
            Sound.mixerstream.output_sampindex       = reader.ReadInt32();
            Sound.mixerstream.output_base_sampindex  = reader.ReadInt32();
        }
Exemple #28
0
 public static void m68k_l1_w(ushort data)
 {
     Sound.soundlatch_w(data);
     Cpuint.cpunum_set_input_line(1, (int)LineState.INPUT_LINE_NMI, LineState.PULSE_LINE);
 }
Exemple #29
0
 public static void sound_irq(int level)
 {
     Cpuint.cpunum_set_input_line(1, 0, (LineState)level);
 }
Exemple #30
0
 public static void namcos1_sub_firq_w()
 {
     Cpuint.cpunum_set_input_line(1, 1, LineState.ASSERT_LINE);
 }