Esempio n. 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;
             }
         }
     }
 }
Esempio n. 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;
     }
 }
Esempio n. 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;
         }
     }
 }