Example #1
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;
             }
         }
     }
 }
Example #2
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;
     }
 }
Example #3
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;
         }
     }
 }
Example #4
0
        public static void handler_ingame()
        {
            Mame.sHandle2 = GetForegroundWindow().ToString();
            if (Mame.sHandle1 == Mame.sHandle2)
            {
                Mame.is_foreground = true;
            }
            else
            {
                Mame.is_foreground = false;
            }
            bool is_paused = Mame.mame_is_paused();

            if (single_step)
            {
                Mame.mame_pause(true);
                single_step = false;
            }
            if (Mame.is_foreground)
            {
                if (Keyboard.IsPressed(Key.F3))
                {
                    cpurun();
                    Mame.playState = Mame.PlayState.PLAY_RESET;
                }
                if (Keyboard.IsTriggered(Key.F7))
                {
                    cpurun();
                    if (Keyboard.IsPressed(Key.LeftShift) || Keyboard.IsPressed(Key.RightShift))
                    {
                        Mame.playState = Mame.PlayState.PLAY_SAVE;
                    }
                    else
                    {
                        Mame.playState = Mame.PlayState.PLAY_LOAD;
                    }
                    return;
                }
                if (Keyboard.IsTriggered(Key.F8))
                {
                    cpurun();
                    if (Keyboard.IsPressed(Key.LeftShift) || Keyboard.IsPressed(Key.RightShift))
                    {
                        if (Mame.playState == Mame.PlayState.PLAY_RECORDRUNNING)
                        {
                            Mame.playState = Mame.PlayState.PLAY_RECORDEND;
                        }
                        else
                        {
                            Mame.playState = Mame.PlayState.PLAY_RECORDSTART;
                        }
                    }
                    else
                    {
                        Mame.playState = Mame.PlayState.PLAY_REPLAYSTART;
                    }
                    return;
                }
                if (Keyboard.IsTriggered(Key.P))
                {
                    if (is_paused && (Keyboard.IsPressed(Key.LeftShift) || Keyboard.IsPressed(Key.RightShift)))
                    {
                        single_step = true;
                        Mame.mame_pause(false);
                    }
                    else
                    {
                        Mame.mame_pause(!Mame.mame_is_paused());
                        Thread t1 = new Thread(mainform.HandleMouse);
                        t1.Start();
                    }
                }
                if (Keyboard.IsTriggered(Key.F10))
                {
                    Keyboard.bF10 = true;
                    bool b1 = Video.global_throttle;
                    Video.global_throttle = !b1;
                }
            }
        }