コード例 #1
0
        // internal helpers

        //-------------------------------------------------
        //  video_exit - close down the video system
        //-------------------------------------------------
        void exit(running_machine machine_)
        {
            // stop recording any movie
            m_movie_recordings.clear();

            // free the snapshot target
            machine().render().target_free(m_snap_target);
            m_snap_bitmap.reset();

            // print a final result if we have at least 2 seconds' worth of data
            if (!emulator_info.standalone() && m_overall_emutime.seconds() >= 1)
            {
                osd_ticks_t tps             = m_osdcore.osd_ticks_per_second();
                double      final_real_time = (double)m_overall_real_seconds + (double)m_overall_real_ticks / (double)tps;
                double      final_emu_time  = m_overall_emutime.as_double();
                osd_printf_info("Average speed: {0}%% ({1} seconds)\n", 100 * final_emu_time / final_real_time, (m_overall_emutime + new attotime(0, ATTOSECONDS_PER_SECOND / 2)).seconds());  // %.2f%% (%d seconds)\n
            }
        }
コード例 #2
0
        //-------------------------------------------------
        //  recompute_speed - recompute the current
        //  overall speed; we assume this is called only
        //  if we did not skip a frame
        //-------------------------------------------------
        void recompute_speed(attotime emutime)
        {
            // if we don't have a starting time yet, or if we're paused, reset our starting point
            if (m_speed_last_realtime == 0 || machine().paused())
            {
                m_speed_last_realtime = m_osdcore.osd_ticks();
                m_speed_last_emutime  = emutime;
            }

            // if it has been more than the update interval, update the time
            attotime delta_emutime = emutime - m_speed_last_emutime;

            if (delta_emutime > new attotime(0, ATTOSECONDS_PER_SPEED_UPDATE))
            {
                // convert from ticks to attoseconds
                osd_ticks_t realtime       = m_osdcore.osd_ticks();
                osd_ticks_t delta_realtime = realtime - m_speed_last_realtime;
                osd_ticks_t tps            = m_osdcore.osd_ticks_per_second();
                m_speed_percent = delta_emutime.as_double() * (double)tps / (double)delta_realtime;

                // remember the last times
                m_speed_last_realtime = realtime;
                m_speed_last_emutime  = emutime;

                // if we're throttled, this time period counts for overall speed; otherwise, we reset the counter
                if (!m_fastforward)
                {
                    m_overall_valid_counter++;
                }
                else
                {
                    m_overall_valid_counter = 0;
                }

                // if we've had at least 4 consecutive valid periods, accumulate stats
                if (m_overall_valid_counter >= 4)
                {
                    m_overall_real_ticks += delta_realtime;
                    while (m_overall_real_ticks >= tps)
                    {
                        m_overall_real_ticks -= tps;
                        m_overall_real_seconds++;
                    }
                    m_overall_emutime += delta_emutime;
                }
            }

            // if we're past the "time-to-execute" requested, signal an exit
            if (m_seconds_to_run != 0 && emutime.seconds() >= m_seconds_to_run)
            {
                // create a final screenshot
                emu_file            file   = new emu_file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
                std.error_condition filerr = open_next(file, "png");
                if (!filerr)
                {
                    save_snapshot(null, file);
                }

                file.close();

                //printf("Scheduled exit at %f\n", emutime.as_double());

                // schedule our demise
                machine().schedule_exit();
            }
        }