Esempio n. 1
0
        public static void video_frame_update()
        {
            Atime current_time = Timer.global_basetime;

            if (!Mame.paused)
            {
                finish_screen_updates();
            }
            Keyboard.Update();
            Inptport.frame_update_callback();
            UI.ui_update_and_render();
            if (Machine.FORM.cheatform.lockState == ui.cheatForm.LockState.LOCK_FRAME)
            {
                Machine.FORM.cheatform.ApplyCheat();
            }
            GDIDraw();
            if (effective_throttle())
            {
                update_throttle(current_time);
            }
            recompute_speed(current_time);
            if (Mame.paused)
            {
                //Thread.Sleep(5);
            }
            else
            {
                video_eof_callback();
            }
        }
Esempio n. 2
0
 private static void handle_load()
 {
     sHandle2 = GetForegroundWindow().ToString();
     if (sHandle1 == sHandle2)
     {
         is_foreground = true;
     }
     else
     {
         is_foreground = false;
     }
     if (is_foreground)
     {
         Video.sDrawText      = "Select position to load from";
         Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 1000;
         if (Keyboard.IsTriggered(Key.Escape))
         {
             Video.sDrawText      = "Load cancelled";
             Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 2;
             playState            = PlayState.PLAY_RUNNING;
             mame_pause(false);
             UI.ui_handler_callback = UI.handler_ingame;
             return;
         }
         char file;
         foreach (Key key1 in Inptport.lk)
         {
             if (Keyboard.IsTriggered(key1))
             {
                 file = Inptport.getcharbykey(key1);
                 if (!File.Exists("sta\\" + Machine.sName + "\\" + file + ".sta"))
                 {
                     Video.sDrawText      = "Load fail";
                     Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 2;
                     playState            = PlayState.PLAY_RUNNING;
                     Thread.Sleep(500);
                     mame_pause(false);
                     UI.ui_handler_callback = UI.handler_ingame;
                     return;
                 }
                 FileStream   fs1 = new FileStream("sta\\" + Machine.sName + "\\" + file + ".sta", FileMode.Open);
                 BinaryReader br1 = new BinaryReader(fs1);
                 State.loadstate_callback(br1);
                 br1.Close();
                 fs1.Close();
                 postload();
                 Video.sDrawText        = "Load from position " + file;
                 Video.popup_text_end   = Wintime.osd_ticks() + Wintime.ticks_per_second * 2;
                 playState              = PlayState.PLAY_RUNNING;
                 UI.ui_handler_callback = UI.handler_ingame;
                 Thread.Sleep(500);
                 mame_pause(false);
                 return;
             }
         }
     }
 }
Esempio n. 3
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();
 }
Esempio n. 4
0
        public static void init_machine()
        {
            //fileio_init();
            //config_init();
            Inptport.input_init();
            //output_init();

            //render_init();
            //ui_init();

            Generic.generic_machine_init();

            Timer.timer_init();
            soft_reset_timer = Timer.timer_alloc_common(soft_reset, "soft_reset", false);

            //osd_init();

            //time(&mame->base_time);

            Inptport.input_port_init();
            //if (newbase != 0)
            //    mame->base_time = newbase;

            /* intialize UI input */
            //ui_input_init();

            //rom_init();
            //memory_init();
            Cpuexec.cpuexec_init();
            Watchdog.watchdog_init();

            //cps1_gfx_decode();

            //device_list_start();

            Video.video_init();

            Sound.sound_init();

            State.state_init();

            Machine.machine_start();
        }
Esempio n. 5
0
        public static byte N3ReadMemory_quester(ushort address)
        {
            byte result;

            if (address == 0x1400)
            {
                if ((strobe & 0x20) == 0)
                {
                    result = (byte)((uint)(byte0 & 0x90) | (uint)(strobe & 0x40) | (Inptport.input_port_read_direct(Inptport.analog_p0) & 0x0f));
                }
                else
                {
                    result = (byte)((uint)(byte0 & 0x90) | (uint)(strobe & 0x40) | (Inptport.input_port_read_direct(Inptport.analog_p1) & 0x0f));
                }
                strobe ^= 0x40;
            }
            else if (address == 0x1401)
            {
                if ((strobe & 0x20) == 0)
                {
                    result = (byte)((uint)(byte1 & 0x90) | 0x00 | (Inptport.input_port_read_direct(Inptport.analog_p0) >> 4));
                }
                else
                {
                    result = (byte)((uint)(byte1 & 0x90) | 0x20 | (Inptport.input_port_read_direct(Inptport.analog_p1) >> 4));
                }
                if ((strobe & 0x40) == 0)
                {
                    strobe ^= 0x20;
                }
            }
            else
            {
                result = N3ReadMemory(address);
            }
            return(result);
        }
Esempio n. 6
0
 public static void loop_inputports_ns1_quester()
 {
     if (Keyboard.IsPressed(Key.D5))
     {
         byte2 &= unchecked ((byte)~0x10);
     }
     else
     {
         byte2 |= 0x10;
     }
     if (Keyboard.IsPressed(Key.D6))
     {
         byte2 &= unchecked ((byte)~0x08);
     }
     else
     {
         byte2 |= 0x08;
     }
     if (Keyboard.IsPressed(Key.D1))
     {
         byte0 &= unchecked ((byte)~0x80);
     }
     else
     {
         byte0 |= 0x80;
     }
     if (Keyboard.IsPressed(Key.D2))
     {
         byte1 &= unchecked ((byte)~0x80);
     }
     else
     {
         byte1 |= 0x80;
     }
     if (Keyboard.IsPressed(Key.J))
     {
         byte0 &= unchecked ((byte)~0x10);
     }
     else
     {
         byte0 |= 0x10;
     }
     if (Keyboard.IsPressed(Key.K))
     {
         byte0 &= unchecked ((byte)~0x20);
     }
     else
     {
         byte0 |= 0x20;
     }
     if (Keyboard.IsPressed(Key.L))
     {
         byte0 &= unchecked ((byte)~0x40);
     }
     else
     {
         byte0 |= 0x40;
     }
     if (Keyboard.IsPressed(Key.NumPad1))
     {
         byte1 &= unchecked ((byte)~0x10);
     }
     else
     {
         byte1 |= 0x10;
     }
     if (Keyboard.IsPressed(Key.NumPad2))
     {
         byte1 &= unchecked ((byte)~0x20);
     }
     else
     {
         byte1 |= 0x20;
     }
     if (Keyboard.IsPressed(Key.NumPad3))
     {
         byte1 &= unchecked ((byte)~0x40);
     }
     else
     {
         byte1 |= 0x40;
     }
     if (Keyboard.IsPressed(Key.R))
     {
         byte2 &= unchecked ((byte)~0x20);
     }
     else
     {
         byte2 |= 0x20;
     }
     if (Keyboard.IsPressed(Key.T))
     {
         byte2 &= unchecked ((byte)~0x40);
     }
     else
     {
         byte2 |= 0x40;
     }
     Inptport.frame_update_analog_field_quester_p0(Inptport.analog_p0);
     Inptport.frame_update_analog_field_quester_p1(Inptport.analog_p1);
 }
Esempio n. 7
0
 private static void handle_replay()
 {
     sHandle2 = GetForegroundWindow().ToString();
     if (sHandle1 == sHandle2)
     {
         is_foreground = true;
     }
     else
     {
         is_foreground = false;
     }
     if (is_foreground)
     {
         if (playState == PlayState.PLAY_REPLAYSTART)
         {
             Video.sDrawText      = "Select position to replay from";
             Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 1000;
             if (Keyboard.IsTriggered(Key.Escape))
             {
                 Video.sDrawText      = "Replay cancelled";
                 Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 2;
                 playState            = PlayState.PLAY_RUNNING;
                 mame_pause(false);
                 UI.ui_handler_callback = UI.handler_ingame;
                 return;
             }
             char file;
             foreach (Key key1 in Inptport.lk)
             {
                 if (Keyboard.IsTriggered(key1))
                 {
                     file = Inptport.getcharbykey(key1);
                     if (!File.Exists("inp\\" + Machine.sName + "\\" + file + ".sta") || !File.Exists("inp\\" + Machine.sName + "\\" + file + ".inp"))
                     {
                         Video.sDrawText      = "Replay fail";
                         Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 2;
                         playState            = PlayState.PLAY_RUNNING;
                         Thread.Sleep(500);
                         mame_pause(false);
                         UI.ui_handler_callback = UI.handler_ingame;
                         return;
                     }
                     if (bwRecord != null)
                     {
                         bwRecord.Close();
                         bwRecord = null;
                     }
                     if (fsRecord != null)
                     {
                         fsRecord.Close();
                         fsRecord = null;
                     }
                     if (brRecord != null)
                     {
                         brRecord.Close();
                         brRecord = null;
                     }
                     FileStream   fs1 = new FileStream("inp\\" + Machine.sName + "\\" + file + ".sta", FileMode.Open);
                     BinaryReader br1 = new BinaryReader(fs1);
                     State.loadstate_callback(br1);
                     br1.Close();
                     fs1.Close();
                     postload();
                     fsRecord = new FileStream("inp\\" + Machine.sName + "\\" + file + ".inp", FileMode.Open);
                     brRecord = new BinaryReader(fsRecord);
                     Memory.memory_reset();
                     Inptport.bReplayRead = true;
                     Inptport.replay_port_callback();
                     Video.sDrawText        = "Replay from position " + file;
                     Video.popup_text_end   = Wintime.osd_ticks() + Wintime.ticks_per_second * 2;
                     playState              = PlayState.PLAY_REPLAYRUNNING;
                     UI.ui_handler_callback = UI.handler_ingame;
                     Thread.Sleep(500);
                     mame_pause(false);
                     return;
                 }
             }
         }
     }
     if (playState == PlayState.PLAY_REPLAYEND)
     {
         Video.sDrawText      = "Replay end";
         Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 2;
         brRecord.Close();
         brRecord  = null;
         playState = PlayState.PLAY_RUNNING;
     }
 }
Esempio n. 8
0
 private static void handle_record()
 {
     sHandle2 = GetForegroundWindow().ToString();
     if (sHandle1 == sHandle2)
     {
         is_foreground = true;
     }
     else
     {
         is_foreground = false;
     }
     if (is_foreground)
     {
         if (playState == PlayState.PLAY_RECORDSTART)
         {
             Video.sDrawText      = "Select position to record to";
             Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 1000;
             if (Keyboard.IsTriggered(Key.Escape))
             {
                 Video.sDrawText      = "Record cancelled";
                 Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 2;
                 playState            = PlayState.PLAY_RUNNING;
                 mame_pause(false);
                 UI.ui_handler_callback = UI.handler_ingame;
                 return;
             }
             char file;
             foreach (Key key1 in Inptport.lk)
             {
                 if (Keyboard.IsTriggered(key1))
                 {
                     file = Inptport.getcharbykey(key1);
                     if (!Directory.Exists("inp\\" + Machine.sName))
                     {
                         Directory.CreateDirectory("inp\\" + Machine.sName);
                     }
                     FileStream   fs1 = new FileStream("inp\\" + Machine.sName + "\\" + file + ".sta", FileMode.Create);
                     BinaryWriter bw1 = new BinaryWriter(fs1);
                     State.savestate_callback(bw1);
                     bw1.Close();
                     fs1.Close();
                     if (bwRecord != null)
                     {
                         bwRecord.Close();
                         bwRecord = null;
                     }
                     FileStream fs2 = new FileStream("inp\\" + Machine.sName + "\\" + file + ".inp", FileMode.Create);
                     bwRecord = new BinaryWriter(fs2);
                     Memory.memory_reset2();
                     Inptport.record_port_callback();
                     Video.sDrawText        = "Record to position " + file;
                     Video.popup_text_end   = Wintime.osd_ticks() + Wintime.ticks_per_second * 2;
                     playState              = PlayState.PLAY_RECORDRUNNING;
                     UI.ui_handler_callback = UI.handler_ingame;
                     Thread.Sleep(500);
                     mame_pause(false);
                     return;
                 }
             }
         }
         else if (playState == PlayState.PLAY_RECORDEND)
         {
             Video.sDrawText      = "Record end";
             Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 2;
             bwRecord.Close();
             bwRecord  = null;
             playState = PlayState.PLAY_RUNNING;
         }
     }
 }
Esempio n. 9
0
 public static void loop_inputports_neogeo_irrmaze()
 {
     if (Keyboard.IsPressed(Key.D5))
     {
         short3 &= ~0x0001;
     }
     else
     {
         short3 |= 0x0001;
     }
     if (Keyboard.IsPressed(Key.D6))
     {
         short3 &= ~0x0002;
     }
     else
     {
         short3 |= 0x0002;
     }
     if (Keyboard.IsPressed(Key.D1))
     {
         short2 &= ~0x0100;
     }
     else
     {
         short2 |= 0x0100;
     }
     if (Keyboard.IsPressed(Key.D2))
     {
         short2 &= ~0x0400;
     }
     else
     {
         short2 |= 0x0400;
     }
     if (Keyboard.IsPressed(Key.J))
     {
         short1 &= ~0x1000;
     }
     else
     {
         short1 |= 0x1000;
     }
     if (Keyboard.IsPressed(Key.K))
     {
         short1 &= ~0x2000;
     }
     else
     {
         short1 |= 0x2000;
     }
     if (Keyboard.IsPressed(Key.NumPad1))
     {
         short1 &= ~0x4000;
     }
     else
     {
         short1 |= 0x4000;
     }
     if (Keyboard.IsPressed(Key.NumPad2))
     {
         short1 &= unchecked ((short)~0x8000);
     }
     else
     {
         short1 |= unchecked ((short)0x8000);
     }
     Inptport.frame_update_analog_field_irrmaze_p0(Inptport.analog_p0);
     Inptport.frame_update_analog_field_irrmaze_p1(Inptport.analog_p1);
 }
Esempio n. 10
0
 public static void loop_inputports_cps2_ecofghtr()
 {
     if (Keyboard.IsPressed(Key.D5))
     {
         short2 &= ~0x1000;
     }
     else
     {
         short2 |= 0x1000;
     }
     if (Keyboard.IsPressed(Key.D6))
     {
         short2 &= ~0x2000;
     }
     else
     {
         short2 |= 0x2000;
     }
     if (Keyboard.IsPressed(Key.D1))
     {
         short2 &= ~0x0100;
     }
     else
     {
         short2 |= 0x0100;
     }
     if (Keyboard.IsPressed(Key.D2))
     {
         short2 &= ~0x0200;
     }
     else
     {
         short2 |= 0x0200;
     }
     if (Keyboard.IsPressed(Key.D))
     {
         short0 &= ~0x0001;
     }
     else
     {
         short0 |= 0x0001;
     }
     if (Keyboard.IsPressed(Key.A))
     {
         short0 &= ~0x0002;
     }
     else
     {
         short0 |= 0x0002;
     }
     if (Keyboard.IsPressed(Key.S))
     {
         short0 &= ~0x0004;
     }
     else
     {
         short0 |= 0x0004;
     }
     if (Keyboard.IsPressed(Key.W))
     {
         short0 &= ~0x0008;
     }
     else
     {
         short0 |= 0x0008;
     }
     if (Keyboard.IsPressed(Key.J))
     {
         short0 &= ~0x0010;
     }
     else
     {
         short0 |= 0x0010;
     }
     if (Keyboard.IsPressed(Key.K))
     {
         short0 &= ~0x0020;
     }
     else
     {
         short0 |= 0x0020;
     }
     if (Keyboard.IsPressed(Key.L))
     {
         short0 &= ~0x0040;
     }
     else
     {
         short0 |= 0x0040;
     }
     if (Keyboard.IsPressed(Key.Right))
     {
         short0 &= ~0x0100;
     }
     else
     {
         short0 |= 0x0100;
     }
     if (Keyboard.IsPressed(Key.Left))
     {
         short0 &= ~0x0200;
     }
     else
     {
         short0 |= 0x0200;
     }
     if (Keyboard.IsPressed(Key.Down))
     {
         short0 &= ~0x0400;
     }
     else
     {
         short0 |= 0x0400;
     }
     if (Keyboard.IsPressed(Key.Up))
     {
         short0 &= ~0x0800;
     }
     else
     {
         short0 |= 0x0800;
     }
     if (Keyboard.IsPressed(Key.NumPad1))
     {
         short0 &= ~0x1000;
     }
     else
     {
         short0 |= 0x1000;
     }
     if (Keyboard.IsPressed(Key.NumPad2))
     {
         short0 &= ~0x2000;
     }
     else
     {
         short0 |= 0x2000;
     }
     if (Keyboard.IsPressed(Key.NumPad3))
     {
         short0 &= ~0x4000;
     }
     else
     {
         short0 |= 0x4000;
     }
     if (Keyboard.IsPressed(Key.R))
     {
         short2 &= ~0x0004;
     }
     else
     {
         short2 |= 0x0004;
     }
     if (Keyboard.IsPressed(Key.T))
     {
         short2 &= ~0x0002;
     }
     else
     {
         short2 |= 0x0002;
     }
     Inptport.frame_update_analog_field_ecofghtr_p0(Inptport.analog_p0);
     Inptport.frame_update_analog_field_ecofghtr_p1(Inptport.analog_p1);
 }
Esempio n. 11
0
 public static void loop_inputports_cps1_forgottn()
 {
     if (Keyboard.IsPressed(Key.D5))
     {
         sbyte0 &= ~0x01;
     }
     else
     {
         sbyte0 |= 0x01;
     }
     if (Keyboard.IsPressed(Key.D6))
     {
         sbyte0 &= ~0x02;
     }
     else
     {
         sbyte0 |= 0x02;
     }
     if (Keyboard.IsPressed(Key.D1))
     {
         sbyte0 &= ~0x10;
     }
     else
     {
         sbyte0 |= 0x10;
     }
     if (Keyboard.IsPressed(Key.D2))
     {
         sbyte0 &= ~0x20;
     }
     else
     {
         sbyte0 |= 0x20;
     }
     if (Keyboard.IsPressed(Key.D))
     {
         short1 &= ~0x01;
     }
     else
     {
         short1 |= 0x01;
     }
     if (Keyboard.IsPressed(Key.A))
     {
         short1 &= ~0x02;
     }
     else
     {
         short1 |= 0x02;
     }
     if (Keyboard.IsPressed(Key.S))
     {
         short1 &= ~0x04;
     }
     else
     {
         short1 |= 0x04;
     }
     if (Keyboard.IsPressed(Key.W))
     {
         short1 &= ~0x08;
     }
     else
     {
         short1 |= 0x08;
     }
     if (Keyboard.IsPressed(Key.J))
     {
         short1 &= ~0x10;
     }
     else
     {
         short1 |= 0x10;
     }
     if (Keyboard.IsPressed(Key.Right))
     {
         short1 &= ~0x0100;
     }
     else
     {
         short1 |= 0x0100;
     }
     if (Keyboard.IsPressed(Key.Left))
     {
         short1 &= ~0x0200;
     }
     else
     {
         short1 |= 0x0200;
     }
     if (Keyboard.IsPressed(Key.Down))
     {
         short1 &= ~0x0400;
     }
     else
     {
         short1 |= 0x0400;
     }
     if (Keyboard.IsPressed(Key.Up))
     {
         short1 &= ~0x0800;
     }
     else
     {
         short1 |= 0x0800;
     }
     if (Keyboard.IsPressed(Key.NumPad1))
     {
         short1 &= ~0x1000;
     }
     else
     {
         short1 |= 0x1000;
     }
     if (Keyboard.IsPressed(Key.R))
     {
         sbyte0 &= ~0x04;
     }
     else
     {
         sbyte0 |= 0x04;
     }
     if (Keyboard.IsPressed(Key.T))
     {
         sbyte0 &= ~0x40;
     }
     else
     {
         sbyte0 |= 0x40;
     }
     Inptport.frame_update_analog_field_forgottn_p0(Inptport.analog_p0);
     Inptport.frame_update_analog_field_forgottn_p1(Inptport.analog_p1);
 }