//------------------------------------------------- // interface_pre_start - work to be done prior to // actually starting a device //------------------------------------------------- public override void interface_pre_start() { m_scheduler = device().machine().scheduler(); // bind delegates //m_vblank_interrupt.bind_relative_to(*device().owner()); //m_timed_interrupt.bind_relative_to(*device().owner()); //m_driver_irq.bind_relative_to(*device().owner()); // fill in the initial states device_iterator iter = new device_iterator(device().machine().root_device()); int index = iter.indexof(device()); m_suspend = SUSPEND_REASON_RESET; m_profiler = (profile_type)(index + profile_type.PROFILER_DEVICE_FIRST); m_inttrigger = index + TRIGGER_INT; // allocate timers if we need them if (m_timed_interrupt_period != attotime.zero) { m_timedint_timer = m_scheduler.timer_alloc(trigger_periodic_interrupt, this); } }
//------------------------------------------------- // update_text - update the current astring //------------------------------------------------- void update_text(running_machine machine) { // compute the total time for all bits, not including profiler or idle UInt64 computed = 0; profile_type curtype; for (curtype = profile_type.PROFILER_DEVICE_FIRST; curtype < profile_type.PROFILER_PROFILER; curtype++) { computed += m_data[(int)curtype]; } // save that result in normalize, and continue adding the rest UInt64 normalize = computed; for ( ; curtype < profile_type.PROFILER_TOTAL; curtype++) { computed += m_data[(int)curtype]; } // this becomes the total; if we end up with 0 for anything, we were just started, so return empty UInt64 total = computed; if (total == 0 || normalize == 0) { m_text = ""; return; } // loop over all types and generate the string device_iterator iter = new device_iterator(machine.root_device()); string stream = ""; for (curtype = profile_type.PROFILER_DEVICE_FIRST; curtype < profile_type.PROFILER_TOTAL; curtype++) { // determine the accumulated time for this type computed = m_data[(int)curtype]; // if we have non-zero data and we're ready to display, do it if (computed != 0) { // start with the un-normalized percentage stream += string.Format("{0}%% ", (int)((computed * 100 + total / 2) / total)); // followed by the normalized percentage for everything but profiler and idle if (curtype < profile_type.PROFILER_PROFILER) { stream += string.Format("{0}%% ", (int)((computed * 100 + normalize / 2) / normalize)); } // and then the text if (curtype >= profile_type.PROFILER_DEVICE_FIRST && curtype <= profile_type.PROFILER_DEVICE_MAX) { stream += string.Format("'{0}'", iter.byindex(curtype - profile_type.PROFILER_DEVICE_FIRST).tag()); } else { for (int nameindex = 0; nameindex < names.Length; nameindex++) { if (names[nameindex].type == (int)curtype) { stream += names[nameindex].str; break; } } } // followed by a carriage return stream += "\n"; } } // reset data set to 0 memset <osd_ticks_t>(m_data, 0, (UInt32)m_data.Length); m_text = stream.str(); }