Example #1
0
        //-------------------------------------------------
        //  execute_timers - execute timers that are due
        //-------------------------------------------------
        void execute_timers()
        {
            if (machine().video().frame_update_count() % 400 == 0)
            {
                LOG("execute_timers: new={0} head->expire={1}\n", m_basetime.as_string(), m_timer_list.expire().as_string());
            }

            // now process any timers that are overdue
            while (m_timer_list.expire() <= m_basetime)
            {
                // if this is a one-shot timer, disable it now
                emu_timer timer       = m_timer_list;
                bool      was_enabled = timer.enabled();
                if (timer.m_period.is_zero() || timer.m_period.is_never())
                {
                    timer.m_enabled = false;
                }

                // set the global state of which callback we're in
                m_callback_timer_modified    = false;
                m_callback_timer             = timer;
                m_callback_timer_expire_time = timer.expire();

                // call the callback
                if (was_enabled)
                {
                    g_profiler.start(profile_type.PROFILER_TIMER_CALLBACK);

                    if (timer.m_callback != null)
                    {
                        if (timer.m_device != null)
                        {
                            LOG("execute_timers: expired: {0} timer device {1} timer {2}\n", timer.expire().attoseconds(), timer.m_device.tag(), timer.m_id);
                        }
                        else
                        {
                            LOG("execute_timers: expired: {0} timer callback {1}\n", timer.expire().attoseconds(), timer.m_callback.ToString());
                        }

                        timer.m_callback(timer.m_ptr, timer.m_param);
                    }

                    g_profiler.stop();
                }

                // reset or remove the timer, but only if it wasn't modified during the callback
                if (!m_callback_timer_modified)
                {
                    // if the timer is temporary, remove it now
                    if (timer.m_temporary)
                    {
                        m_timer_allocator.reclaim(timer.release());
                    }

                    // otherwise, reschedule it
                    else
                    {
                        timer.schedule_next_period();
                    }
                }
            }

            // clear the callback timer global
            m_callback_timer = null;
        }
Example #2
0
        //void apply_stain(bitmap_ind16 &bitmap, uint16_t *pf, uint16_t *mo, int x, int y);

        // memory access
        //uint16_t &slipram(int offset) { return m_slipram[offset]; }


        // device-level overrides

        //-------------------------------------------------
        //  device_start: Start up the device
        //-------------------------------------------------
        protected override void device_start()
        {
            // call parent
            base.device_start();

            // verify configuration
            gfx_element gfx = m_gfxdecode.op0.gfx(m_atari_motion_objects_config.m_gfxindex);

            if (gfx == null)
            {
                throw new emu_fatalerror("No gfxelement #{0}!", m_atari_motion_objects_config.m_gfxindex);
            }

            // determine the masks
            m_linkmask.set(m_atari_motion_objects_config.m_link_entry);
            m_codemask.set(m_atari_motion_objects_config.m_code_entry);
            m_colormask.set(m_atari_motion_objects_config.m_color_entry);
            m_xposmask.set(m_atari_motion_objects_config.m_xpos_entry);
            m_yposmask.set(m_atari_motion_objects_config.m_ypos_entry);
            m_widthmask.set(m_atari_motion_objects_config.m_width_entry);
            m_heightmask.set(m_atari_motion_objects_config.m_height_entry);
            m_hflipmask.set(m_atari_motion_objects_config.m_hflip_entry);
            m_vflipmask.set(m_atari_motion_objects_config.m_vflip_entry);
            m_prioritymask.set(m_atari_motion_objects_config.m_priority_entry);
            m_neighbormask.set(m_atari_motion_objects_config.m_neighbor_entry);
            m_absolutemask.set(m_atari_motion_objects_config.m_absolute_entry);

            // derive tile information
            m_tilewidth  = gfx.width();
            m_tileheight = gfx.height();
            m_tilexshift = compute_log(m_tilewidth);
            m_tileyshift = compute_log(m_tileheight);

            // derive bitmap information
            m_bitmapwidth  = round_to_powerof2(m_xposmask.mask());
            m_bitmapheight = round_to_powerof2(m_yposmask.mask());
            m_bitmapxmask  = m_bitmapwidth - 1;
            m_bitmapymask  = m_bitmapheight - 1;

            // derive sprite information
            m_entrycount    = round_to_powerof2(m_linkmask.mask());
            m_entrybits     = compute_log(m_entrycount);
            m_spriteramsize = m_atari_motion_objects_config.m_bankcount * m_entrycount;
            m_spriterammask = m_spriteramsize - 1;
            m_slipshift     = (m_atari_motion_objects_config.m_slipheight != 0) ? compute_log(m_atari_motion_objects_config.m_slipheight) : 0;
            m_slipramsize   = m_bitmapheight >> m_slipshift;
            m_sliprammask   = m_slipramsize - 1;
            if (m_atari_motion_objects_config.m_maxperline == 0)
            {
                m_atari_motion_objects_config.m_maxperline = MAX_PER_BANK;
            }

            // Get the slipram from the share if not already explicitly set
            if (m_slipram == null)
            {
                m_slipram = new Pointer <u16>(m_slipramshare.op);
            }

            // allocate and initialize the code lookup
            int codesize = round_to_powerof2((int)m_codemask.mask());

            m_codelookup.resize((size_t)codesize);
            for (int i = 0; i < codesize; i++)
            {
                m_codelookup[i] = (uint32_t)i;
            }

            // allocate and initialize the color lookup
            int colorsize = round_to_powerof2((int)m_colormask.mask());

            m_colorlookup.resize((size_t)colorsize);
            for (int i = 0; i < colorsize; i++)
            {
                m_colorlookup[i] = (uint8_t)i;
            }

            // allocate and the gfx lookup
            int gfxsize = codesize / 256;

            m_gfxlookup.resize((size_t)gfxsize);
            for (int i = 0; i < gfxsize; i++)
            {
                m_gfxlookup[i] = m_atari_motion_objects_config.m_gfxindex;
            }

            // allocate a timer to periodically force update
            m_force_update_timer = timer_alloc(TID_FORCE_UPDATE);
            m_force_update_timer.adjust(m_divideo.screen().time_until_pos(0));

            // register for save states
            save_item(NAME(new { m_bank }));
            save_item(NAME(new { m_xscroll }));
            save_item(NAME(new { m_yscroll }));
        }
Example #3
0
        }                                                                               //template <std::size_t Port> auto write_r() { return m_write_r[Port].bind(); }

        // SI: serial input
        //auto read_si() { return m_read_si.bind(); }

        // SO: serial output
        //auto write_so() { return m_write_so.bind(); }


        //static void set_pla(device_t &device, UINT8 *pla) { downcast<mb88_cpu_device &>(device).m_PLA = pla; }


        //DECLARE_WRITE_LINE_MEMBER( clock_w );


        //void data_4bit(address_map &map);
        //void data_5bit(address_map &map);
        //void data_6bit(address_map &map);
        //void data_7bit(address_map &map);
        //void program_10bit(address_map &map);
        //void program_11bit(address_map &map);
        //void program_9bit(address_map &map);


        // device-level overrides

        /***************************************************************************
        *   INITIALIZATION AND SHUTDOWN
        ***************************************************************************/
        protected override void device_start()
        {
            m_dimemory = GetClassInterface <device_memory_interface_mb88>();
            m_diexec   = GetClassInterface <device_execute_interface_mb88>();
            m_distate  = GetClassInterface <device_state_interface_mb88>();


            m_program = m_dimemory.space(AS_PROGRAM);
            m_cache   = m_program.cache(0, 0, (int)endianness_t.ENDIANNESS_BIG);
            m_data    = m_dimemory.space(AS_DATA);

            m_read_k.resolve_safe(0);
            m_write_o.resolve_safe();
            m_write_p.resolve_safe();
            foreach (var cb in m_read_r)
            {
                cb.resolve_safe(0);
            }
            foreach (var cb in m_write_r)
            {
                cb.resolve_safe();
            }
            m_read_si.resolve_safe(0);
            m_write_so.resolve_safe();

            m_serial = machine().scheduler().timer_alloc(serial_timer);  //timer_expired_delegate(FUNC(mb88_cpu_device::serial_timer), this));

            m_ctr = 0;

            save_item(m_PC, "m_PC");
            save_item(m_PA, "m_PA");
            save_item(m_SP[0], "m_SP[0]");
            save_item(m_SP[1], "m_SP[1]");
            save_item(m_SP[2], "m_SP[2]");
            save_item(m_SP[3], "m_SP[3]");
            save_item(m_SI, "m_SI");
            save_item(m_A, "m_A");
            save_item(m_X, "m_X");
            save_item(m_Y, "m_Y");
            save_item(m_st, "m_st");
            save_item(m_zf, "m_zf");
            save_item(m_cf, "m_cf");
            save_item(m_vf, "m_vf");
            save_item(m_sf, "m_sf");
            save_item(m_nf, "m_nf");
            save_item(m_pio, "m_pio");
            save_item(m_TH, "m_TH");
            save_item(m_TL, "m_TL");
            save_item(m_TP, "m_TP");
            save_item(m_ctr, "m_ctr");
            save_item(m_SB, "m_SB");
            save_item(m_SBcount, "m_SBcount");
            save_item(m_pending_interrupt, "m_pending_interrupt");

            m_distate.state_add(MB88_PC, "PC", m_PC).formatstr("%02X");
            m_distate.state_add(MB88_PA, "PA", m_PA).formatstr("%02X");
            m_distate.state_add(MB88_SI, "SI", m_SI).formatstr("%01X");
            m_distate.state_add(MB88_A, "A", m_A).formatstr("%01X");
            m_distate.state_add(MB88_X, "X", m_X).formatstr("%01X");
            m_distate.state_add(MB88_Y, "Y", m_Y).formatstr("%01X");
            m_distate.state_add(MB88_PIO, "PIO", m_pio).formatstr("%02X");
            m_distate.state_add(MB88_TH, "TH", m_TH).formatstr("%01X");
            m_distate.state_add(MB88_TL, "TL", m_TL).formatstr("%01X");
            m_distate.state_add(MB88_SB, "SB", m_SB).formatstr("%01X");

            m_distate.state_add(STATE_GENPC, "GENPC", m_debugger_pc).callimport().callexport().noshow();
            m_distate.state_add(STATE_GENPCBASE, "CURPC", m_debugger_pc).callimport().callexport().noshow();
            m_distate.state_add(STATE_GENFLAGS, "GENFLAGS", m_debugger_flags).callimport().callexport().formatstr("%6s").noshow();

            set_icountptr(m_icountRef);
        }
Example #4
0
 public static Atime timer_timeleft(emu_timer which)
 {
     return(Attotime.attotime_sub(which.expire, get_current_time()));
 }
Example #5
0
 public static bool timer_enabled(emu_timer which)
 {
     return(which.enabled);
 }
Example #6
0
        public static void timer_set_internal(Action action, string func)
        {
            emu_timer timer = timer_alloc_common(action, func, true);

            timer_adjust_periodic(timer, Attotime.ATTOTIME_ZERO, Attotime.ATTOTIME_NEVER);
        }