private static void recompute_speed(Atime emutime) { long delta_emutime; if (speed_last_realtime == 0 || Mame.mame_is_paused()) { speed_last_realtime = Wintime.osd_ticks(); speed_last_emutime = emutime; } delta_emutime = Attotime.attotime_to_attoseconds(Attotime.attotime_sub(emutime, speed_last_emutime)); if (delta_emutime > Attotime.ATTOSECONDS_PER_SECOND / 4) { long realtime = Wintime.osd_ticks(); long delta_realtime = realtime - speed_last_realtime; long tps = Wintime.ticks_per_second; speed_percent = (double)delta_emutime * (double)tps / ((double)delta_realtime * (double)Attotime.ATTOSECONDS_PER_SECOND); speed_last_realtime = realtime; speed_last_emutime = emutime; overall_valid_counter++; if (overall_valid_counter >= 4) { overall_real_ticks += delta_realtime; while (overall_real_ticks >= tps) { overall_real_ticks -= tps; overall_real_seconds++; } overall_emutime = Attotime.attotime_add_attoseconds(overall_emutime, delta_emutime); } } }
private static long throttle_until_ticks(long target_ticks) { long minimum_sleep = Wintime.ticks_per_second / 1000; long current_ticks = Wintime.osd_ticks(); long new_ticks; while (current_ticks < target_ticks) { long delta; bool slept = false; delta = (target_ticks - current_ticks) * 1000 / (1000 + average_oversleep); if (delta >= minimum_sleep) { Wintime.osd_sleep(delta); slept = true; } new_ticks = Wintime.osd_ticks(); if (slept) { long actual_ticks = new_ticks - current_ticks; if (actual_ticks > delta) { long oversleep_milliticks = 1000 * (actual_ticks - delta) / delta; average_oversleep = (average_oversleep * 99 + oversleep_milliticks) / 100; } } current_ticks = new_ticks; } return(current_ticks); }
public static void GDIDraw() { try { bitmapData = bitmapGDI.LockBits(new Rectangle(0, 0, Video.fullwidth, Video.fullheight), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); Marshal.Copy(Video.bitmapcolor, 0, bitmapData.Scan0, Video.fullwidth * Video.fullheight); bitmapGDI.UnlockBits(bitmapData); if (Wintime.osd_ticks() < popup_text_end) { Machine.FORM.tsslStatus.Text = sDrawText; } else { popup_text_end = 0; if (Mame.paused) { Machine.FORM.tsslStatus.Text = "pause"; } else { switch (Mame.playState) { case Mame.PlayState.PLAY_RECORDRUNNING: Machine.FORM.tsslStatus.Text = "record"; break; case Mame.PlayState.PLAY_REPLAYRUNNING: Machine.FORM.tsslStatus.Text = "replay"; break; default: Machine.FORM.tsslStatus.Text = "run"; break; } } } bbmp[iMode] = (Bitmap)bitmapGDI.Clone(new Rectangle(offsetx, offsety, width, height), PixelFormat.Format32bppArgb); switch (Machine.sDirection) { case "": break; case "90": bbmp[iMode].RotateFlip(RotateFlipType.Rotate90FlipNone); break; case "180": bbmp[iMode].RotateFlip(RotateFlipType.Rotate180FlipNone); break; case "270": bbmp[iMode].RotateFlip(RotateFlipType.Rotate270FlipNone); break; } Machine.FORM.pictureBox1.Image = bbmp[iMode]; } catch { } }
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; * }*/ // } } }
private static void handle_save() { sHandle2 = GetForegroundWindow().ToString(); if (sHandle1 == sHandle2) { is_foreground = true; } else { is_foreground = false; } if (is_foreground) { Video.sDrawText = "Select position to save to"; Video.popup_text_end = Wintime.osd_ticks() + Wintime.ticks_per_second * 1000; /*if (Keyboard.IsTriggered(Key.Escape)) * { * Video.sDrawText = "Save 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("sta\\" + Machine.sName)) * { * Directory.CreateDirectory("sta\\" + Machine.sName); * } * FileStream fs1 = new FileStream("sta\\" + Machine.sName + "\\" + file + ".sta", FileMode.Create); * BinaryWriter bw1 = new BinaryWriter(fs1); * State.savestate_callback(bw1); * bw1.Close(); * fs1.Close(); * Video.sDrawText = "Save to 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; * } * }*/ } }
private static void update_throttle(Atime emutime) { long real_delta_attoseconds; long emu_delta_attoseconds; long real_is_ahead_attoseconds; long attoseconds_per_tick; long ticks_per_second; long target_ticks; long diff_ticks; ticks_per_second = Wintime.ticks_per_second; attoseconds_per_tick = Attotime.ATTOSECONDS_PER_SECOND / ticks_per_second; if (Mame.mame_is_paused()) { throttle_emutime = Attotime.attotime_sub_attoseconds(emutime, Attotime.ATTOSECONDS_PER_SECOND / PAUSED_REFRESH_RATE); throttle_realtime = throttle_emutime; } emu_delta_attoseconds = Attotime.attotime_to_attoseconds(Attotime.attotime_sub(emutime, throttle_emutime)); if (emu_delta_attoseconds < 0 || emu_delta_attoseconds > Attotime.ATTOSECONDS_PER_SECOND / 10) { goto resync; } diff_ticks = Wintime.osd_ticks() - throttle_last_ticks; throttle_last_ticks += diff_ticks; if (diff_ticks >= ticks_per_second) { goto resync; } real_delta_attoseconds = diff_ticks * attoseconds_per_tick; throttle_emutime = emutime; throttle_realtime = Attotime.attotime_add_attoseconds(throttle_realtime, real_delta_attoseconds); throttle_history = (throttle_history << 1) | Convert.ToUInt32(emu_delta_attoseconds > real_delta_attoseconds); real_is_ahead_attoseconds = Attotime.attotime_to_attoseconds(Attotime.attotime_sub(throttle_emutime, throttle_realtime)); if ((real_is_ahead_attoseconds < -Attotime.ATTOSECONDS_PER_SECOND / 10) || (real_is_ahead_attoseconds < 0 && popcount[throttle_history & 0xff] < 6)) { goto resync; } if (real_is_ahead_attoseconds < 0) { return; } target_ticks = throttle_last_ticks + real_is_ahead_attoseconds / attoseconds_per_tick; diff_ticks = throttle_until_ticks(target_ticks) - throttle_last_ticks; throttle_last_ticks += diff_ticks; throttle_realtime = Attotime.attotime_add_attoseconds(throttle_realtime, diff_ticks * attoseconds_per_tick); return; resync: throttle_realtime = throttle_emutime = emutime; }
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; } }
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; } } }
private static int NEOGEO_VBLANK_RELOAD_HPOS = 0x11f; //287 public static void video_init() { Wintime.wintime_init(); global_throttle = true; //UI.ui_handler_callback = UI.handler_ingame; sDrawText = ""; popup_text_end = 0; popcount = new int[256] { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 }; switch (Machine.sBoard) { case "CPS-1": //case "CPS-1(QSound)": screenstate.width = 0x200; screenstate.height = 0x100; //screenstate.visarea.min_x = 0; //screenstate.visarea.max_x = 0x1ff; //screenstate.visarea.min_y = 0; //screenstate.visarea.max_y = 0x1ff; fullwidth = 0x200; fullheight = 0x200; frame_update_time = new Atime(0, (long)(1e18 / 59.61));//59.61Hz screenstate.vblank_period = 0; // bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); // UI.ui_update_callback = UI.ui_updateC; bitmapbase = new ushort[2][]; bitmapbase[0] = new ushort[0x200 * 0x200]; bitmapbase[1] = new ushort[0x200 * 0x200]; // bbmp = new Bitmap[3]; // bbmp[0] = new Bitmap(512, 512); // bbmp[1] = new Bitmap(512, 256); // bbmp[2] = new Bitmap(384, 224); video_update_callback = CPS.video_update_cps1; video_eof_callback = CPS.video_eof_cps1; break; /*case "CPS2": * screenstate.width = 0x200; * screenstate.height = 0x100; * screenstate.visarea.min_x = 0; * screenstate.visarea.max_x = 0x1ff; * screenstate.visarea.min_y = 0; * screenstate.visarea.max_y = 0x1ff; * fullwidth = 0x200; * fullheight = 0x200; * frame_update_time = new Atime(0, (long)(1e18 / 8000000) * 512 * 262);//59.637404580152669Hz * screenstate.vblank_period = 0; * bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); * UI.ui_update_callback = UI.ui_updateC; * bitmapbase = new ushort[2][]; * bitmapbase[0] = new ushort[0x200 * 0x200]; * bitmapbase[1] = new ushort[0x200 * 0x200]; * bbmp = new Bitmap[3]; * bbmp[0] = new Bitmap(512, 512); * bbmp[1] = new Bitmap(512, 256); * bbmp[2] = new Bitmap(384, 224); * video_update_callback = CPS.video_update_cps1; * video_eof_callback = CPS.video_eof_cps1; * break; * case "Neo Geo": * screenstate.width = 384; * screenstate.height = 264; * screenstate.visarea.min_x = NEOGEO_HBEND;//30 * screenstate.visarea.max_x = NEOGEO_HBSTART - 1;//349 * screenstate.visarea.min_y = NEOGEO_VBEND;//16 * screenstate.visarea.max_y = NEOGEO_VBSTART - 1;//239 * fullwidth = 384; * fullheight = 264; * frame_update_time = new Atime(0, (long)(1e18 / 6000000) * screenstate.width * screenstate.height);//59.1856060608428Hz * screenstate.vblank_period = (long)(1e18 / 6000000) * 384 * (264 - 224); * UI.ui_update_callback = UI.ui_updateN; * bitmapbaseN = new int[2][]; * bitmapbaseN[0] = new int[384 * 264]; * bitmapbaseN[1] = new int[384 * 264]; * bbmp = new Bitmap[1]; * bbmp[0] = new Bitmap(320, 224); * video_update_callback = Neogeo.video_update_neogeo; * video_eof_callback = Neogeo.video_eof_neogeo; * break; * case "Namco System 1": * screenstate.width = 0x200; * screenstate.height = 0x200; * screenstate.visarea.min_x = 0; * screenstate.visarea.max_x = 0x1ff; * screenstate.visarea.min_y = 0; * screenstate.visarea.max_y = 0x1ff; * fullwidth = 0x200; * fullheight = 0x200; * frame_update_time = new Atime(0, (long)(1e18 / 60.606060)); * screenstate.vblank_period = 0; * UI.ui_update_callback = UI.ui_updateNa; * bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); * bitmapbase = new ushort[2][]; * bitmapbase[0] = new ushort[0x200 * 0x200]; * bitmapbase[1] = new ushort[0x200 * 0x200]; * bbmp = new Bitmap[2]; * bbmp[0] = new Bitmap(512, 512); * bbmp[1] = new Bitmap(288, 224); * video_update_callback = Namcos1.video_update_namcos1; * video_eof_callback = Namcos1.video_eof_namcos1; * break; * case "IGS011": * screenstate.width = 0x200; * screenstate.height = 0x100; * screenstate.visarea.min_x = 0; * screenstate.visarea.max_x = 0x1ff; * screenstate.visarea.min_y = 0; * screenstate.visarea.max_y = 0xff; * fullwidth = 0x200; * fullheight = 0x200; * frame_update_time = new Atime(0, (long)(1e18 / 60)); * screenstate.vblank_period = 0; * UI.ui_update_callback = UI.ui_updateIGS011; * bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); * bitmapbase = new ushort[2][]; * bitmapbase[0] = new ushort[0x200 * 0x200]; * bitmapbase[1] = new ushort[0x200 * 0x200]; * bbmp = new Bitmap[1]; * bbmp[0] = new Bitmap(512, 240); * video_update_callback = IGS011.video_update_igs011; * video_eof_callback = IGS011.video_eof_igs011; * break; * case "PGM": * screenstate.width = 0x200; * screenstate.height = 0x200; * screenstate.visarea.min_x = 0; * screenstate.visarea.max_x = 0x1bf; * screenstate.visarea.min_y = 0; * screenstate.visarea.max_y = 0xdf; * fullwidth = 0x200; * fullheight = 0x200; * frame_update_time = new Atime(0, (long)(1e18 / 60)); * screenstate.vblank_period = 0; * UI.ui_update_callback = UI.ui_updatePGM; * bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); * bitmapbase = new ushort[2][]; * bitmapbase[0] = new ushort[0x200 * 0x200]; * bitmapbase[1] = new ushort[0x200 * 0x200]; * bbmp = new Bitmap[1]; * bbmp[0] = new Bitmap(448, 224); * video_update_callback = PGM.video_update_pgm; * video_eof_callback = PGM.video_eof_pgm; * break; * case "M72": * screenstate.width = 0x200; * screenstate.height = 0x11c; * screenstate.visarea.min_x = 0x40; * screenstate.visarea.max_x = 0x1bf; * screenstate.visarea.min_y = 0; * screenstate.visarea.max_y = 0xff; * fullwidth = 0x200; * fullheight = 0x200; * frame_update_time = new Atime(0, (long)(1e18 / 8000000) * screenstate.width * screenstate.height); * screenstate.vblank_period = (long)(1e18 / 8000000) * 512 * (284 - 256); * UI.ui_update_callback = UI.ui_updatePGM; * bitmapbase = new ushort[2][]; * bitmapbase[0] = new ushort[0x200 * 0x200];//0x11c * bitmapbase[1] = new ushort[0x200 * 0x200];//0x11c * bbmp = new Bitmap[1]; * bbmp[0] = new Bitmap(512, 284); * video_update_callback = M72.video_update_m72; * video_eof_callback = M72.video_eof_m72; * break; * case "M92": * screenstate.width = 0x200; * screenstate.height = 0x100; * screenstate.visarea.min_x = 0x50; * screenstate.visarea.max_x = 0x18f; * screenstate.visarea.min_y = 0x8; * screenstate.visarea.max_y = 0xf7; * fullwidth = 0x200; * fullheight = 0x200; * frame_update_time = new Atime(0, (long)(1e18 / 60)); * screenstate.vblank_period = 0; * UI.ui_update_callback = UI.ui_updatePGM; * bitmapbase = new ushort[2][]; * bitmapbase[0] = new ushort[0x200 * 0x200]; * bitmapbase[1] = new ushort[0x200 * 0x200]; * bbmp = new Bitmap[1]; * bbmp[0] = new Bitmap(0x200, 0x100); * video_update_callback = M92.video_update_m92; * video_eof_callback = M92.video_eof_m92; * break;*/ } screenstate.frame_period = frame_update_time.attoseconds; screenstate.scantime = screenstate.frame_period / screenstate.height; screenstate.pixeltime = screenstate.frame_period / (screenstate.height * screenstate.width); screenstate.frame_number = 0; // bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); bitmapcolor = new int[Video.fullwidth * Video.fullheight]; vblank_begin_timer = Timer.timer_alloc_common(vblank_begin_callback, "vblank_begin_callback", false); Timer.timer_adjust_periodic(vblank_begin_timer, frame_update_time, Attotime.ATTOTIME_NEVER); scanline0_timer = Timer.timer_alloc_common(scanline0_callback, "scanline0_callback", false); Timer.timer_adjust_periodic(scanline0_timer, video_screen_get_time_until_pos(0, 0), Attotime.ATTOTIME_NEVER); switch (Machine.sBoard) { case "CPS-1": case "CPS-1(QSound)": case "Namco System 1": break; case "CPS2": Cpuexec.cpu[0].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 262); Cpuexec.cpu[0].partial_frame_timer = Timer.timer_alloc_common(Cpuexec.trigger_partial_frame_interrupt, "trigger_partial_frame_interrupt", false); break; case "Neo Geo": break; case "IGS011": Cpuexec.cpu[0].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 5); Cpuexec.cpu[0].partial_frame_timer = Timer.timer_alloc_common(Cpuexec.trigger_partial_frame_interrupt, "trigger_partial_frame_interrupt", false); break; case "M72": Cpuexec.cpu[1].partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 128); Cpuexec.cpu[1].partial_frame_timer = Timer.timer_alloc_common(Cpuexec.trigger_partial_frame_interrupt, "trigger_partial_frame_interrupt", false); break; } screenstate.vblank_start_time = Attotime.ATTOTIME_ZERO; }
private static int NEOGEO_VBLANK_RELOAD_HPOS = 0x11f; //287 public static void video_init() { Wintime.wintime_init(); global_throttle = true; UI.ui_handler_callback = UI.handler_ingame; sDrawText = ""; popup_text_end = 0; popcount = new int[256] { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 }; switch (Machine.sBoard) { case "CPS-1": case "CPS-1(QSound)": screenstate.visarea.min_x = 0; screenstate.visarea.max_x = 0x1ff; screenstate.visarea.min_y = 0; screenstate.visarea.max_y = 0x1ff; fullwidth = 0x200; fullheight = 0x200; frame_update_time = new Atime(0, (long)(1e18 / 59.61));//59.61Hz bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); UI.ui_update_callback = UI.ui_updateC; bitmapbaseC = new ushort[2][]; bitmapbaseC[0] = new ushort[0x200 * 0x200]; bitmapbaseC[1] = new ushort[0x200 * 0x200]; bbmp = new Bitmap[3]; bbmp[0] = new Bitmap(512, 512); bbmp[1] = new Bitmap(512, 256); bbmp[2] = new Bitmap(384, 224); video_update_callback = CPS.video_update_cps1; video_eof_callback = CPS.video_eof_cps1; break; case "CPS2": fullwidth = 0x200; fullheight = 0x200; frame_update_time = new Atime(0, (long)(1e18 / 8000000) * 512 * 262);//59.637404580152669Hz bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); UI.ui_update_callback = UI.ui_updateC; bitmapbaseC = new ushort[2][]; bitmapbaseC[0] = new ushort[0x200 * 0x200]; bitmapbaseC[1] = new ushort[0x200 * 0x200]; bbmp = new Bitmap[3]; bbmp[0] = new Bitmap(512, 512); bbmp[1] = new Bitmap(512, 256); bbmp[2] = new Bitmap(384, 224); video_update_callback = CPS.video_update_cps1; video_eof_callback = CPS.video_eof_cps1; break; case "Neo Geo": screenstate.width = 384; screenstate.height = 264; screenstate.visarea.min_x = NEOGEO_HBEND; //30 screenstate.visarea.max_x = NEOGEO_HBSTART - 1; //349 screenstate.visarea.min_y = NEOGEO_VBEND; //16 screenstate.visarea.max_y = NEOGEO_VBSTART - 1; //239 fullwidth = 384; fullheight = 264; screenstate.frame_period = (long)(1e18 / 6000000) * screenstate.width * screenstate.height; screenstate.scantime = (long)(1e18 / 6000000) * screenstate.width; screenstate.pixeltime = (long)(1e18 / 6000000); frame_update_time = new Atime(0, (long)(1e18 / 6000000) * 384 * 264);//59.1856060608428Hz UI.ui_update_callback = UI.ui_updateN; bitmapbaseN = new int[2][]; bitmapbaseN[0] = new int[384 * 264]; bitmapbaseN[1] = new int[384 * 264]; bbmp = new Bitmap[1]; bbmp[0] = new Bitmap(320, 224); video_update_callback = Neogeo.video_update_neogeo; video_eof_callback = Neogeo.video_eof_neogeo; break; case "Namco System 1": screenstate.visarea.min_x = 0; screenstate.visarea.max_x = 0x1ff; screenstate.visarea.min_y = 0; screenstate.visarea.max_y = 0x1ff; fullwidth = 0x200; fullheight = 0x200; frame_update_time = new Atime(0, (long)(1e18 / 60.606060)); UI.ui_update_callback = UI.ui_updateNa; bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); bitmapbaseNa = new ushort[2][]; bitmapbaseNa[0] = new ushort[0x200 * 0x200]; bitmapbaseNa[1] = new ushort[0x200 * 0x200]; bbmp = new Bitmap[2]; bbmp[0] = new Bitmap(512, 512); bbmp[1] = new Bitmap(288, 224); video_update_callback = Namcos1.video_update_namcos1; video_eof_callback = Namcos1.video_eof_namcos1; break; case "IGS011": screenstate.visarea.min_x = 0; screenstate.visarea.max_x = 0x1ff; screenstate.visarea.min_y = 0; screenstate.visarea.max_y = 0xff; fullwidth = 0x200; fullheight = 0x200; frame_update_time = new Atime(0, (long)(1e18 / 60)); UI.ui_update_callback = UI.ui_updateIGS011; bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); bitmapbaseIGS011 = new ushort[2][]; bitmapbaseIGS011[0] = new ushort[0x200 * 0x200]; bitmapbaseIGS011[1] = new ushort[0x200 * 0x200]; bbmp = new Bitmap[1]; bbmp[0] = new Bitmap(512, 240); video_update_callback = IGS011.video_update_igs011; video_eof_callback = IGS011.video_eof_igs011; break; case "PGM": fullwidth = 0x200; fullheight = 0x200; frame_update_time = new Atime(0, (long)(1e18 / 60)); UI.ui_update_callback = UI.ui_updatePGM; bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); bitmapbasePGM = new ushort[2][]; bitmapbasePGM[0] = new ushort[0x200 * 0x200]; bitmapbasePGM[1] = new ushort[0x200 * 0x200]; bbmp = new Bitmap[1]; bbmp[0] = new Bitmap(448, 224); video_update_callback = PGM.video_update_pgm; video_eof_callback = PGM.video_eof_pgm; break; } screenstate.frame_number = 0; bitmapGDI = new Bitmap(Video.fullwidth, Video.fullheight); bitmapcolor = new int[Video.fullwidth * Video.fullheight]; vblank_begin_timer = Timer.timer_alloc_common(vblank_begin_callback, "vblank_begin_callback", false); Timer.timer_adjust_periodic(vblank_begin_timer, frame_update_time, Attotime.ATTOTIME_NEVER); switch (Machine.sBoard) { case "CPS-1": case "CPS-1(QSound)": case "Namco System 1": break; case "CPS2": partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 262); Cpuexec.partial_frame_timer = Timer.timer_alloc_common(Cpuexec.trigger_partial_frame_interrupt, "trigger_partial_frame_interrupt", false); break; case "Neo Geo": Timer.timer_adjust_periodic(vblank_begin_timer, video_screen_get_time_until_pos(screenstate.visarea.max_y + 1, 0), Attotime.ATTOTIME_NEVER); break; case "IGS011": partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 5); Cpuexec.partial_frame_timer = Timer.timer_alloc_common(Cpuexec.trigger_partial_frame_interrupt, "trigger_partial_frame_interrupt", false); break; case "PGM": partial_frame_period = Attotime.attotime_div(Video.frame_update_time, 2); Cpuexec.partial_frame_timer = Timer.timer_alloc_common(Cpuexec.trigger_partial_frame_interrupt, "trigger_partial_frame_interrupt", false); break; } screenstate.vblank_start_time = Attotime.ATTOTIME_ZERO; }