Пример #1
0
        //-------------------------------------------------
        //  postload - after loading a save state
        //-------------------------------------------------
        void postload()
        {
            // remove all timers and make a private list of permanent ones
            simple_list <emu_timer> private_list = new simple_list <emu_timer>();

            while (m_timer_list != null)
            {
                emu_timer timer = m_timer_list;

                // temporary timers go away entirely (except our special never-expiring one)
                if (timer.m_temporary && !timer.expire().is_never())
                {
                    m_timer_allocator.reclaim(timer.release());
                }

                // permanent ones get added to our private list
                else
                {
                    private_list.append(timer_list_remove(timer));
                }
            }

            {
                // now re-insert them; this effectively re-sorts them by time
                emu_timer timer;
                while ((timer = private_list.detach_head()) != null)
                {
                    timer_list_insert(timer);
                }
            }

            m_suspend_changes_pending = true;
            rebuild_execute_list();

            // report the timer state after a log
            LOG("After resetting/reordering timers:\n");
#if VERBOSE
            dump_timers();
#endif
        }
Пример #2
0
        //-------------------------------------------------
        //  first_dirty_rect -- return the first dirty
        //  rectangle in the list
        //-------------------------------------------------
        public sparse_dirty_rect first_dirty_rect(rectangle cliprect)
        {
            // if what we have is valid, just return it again
            if (m_rect_list_bounds == cliprect)
            {
                return(m_rect_list.empty() ? null : m_rect_list.first());
            }

            // reclaim the dirty list and start over
            m_rect_allocator.reclaim_all(m_rect_list);

            // compute dirty space rectangle coordinates
            int sx       = cliprect.min_x >> m_granularity;
            int ex       = cliprect.max_x >> m_granularity;
            int sy       = cliprect.min_y >> m_granularity;
            int ey       = cliprect.max_y >> m_granularity;
            int tilesize = 1 << m_granularity;

            // loop over all grid rows that intersect our cliprect
            for (int y = sy; y <= ey; y++)
            {
                PointerU8         dirtybase = m_bitmap.pix(y); //uint8_t *dirtybase = &m_bitmap.pix(y);
                sparse_dirty_rect currect   = null;

                // loop over all grid columns that intersect our cliprect
                for (int x = sx; x <= ex; x++)
                {
                    // if this tile is not dirty, end our current run and continue
                    if (dirtybase[x] == 0)
                    {
                        if (currect != null)
                        {
                            currect.m_rect &= cliprect;  //*currect &= cliprect;
                        }
                        currect = null;
                        continue;
                    }

                    // if we can't add to an existing rect, create a new one
                    if (currect == null)
                    {
                        // allocate a new rect and add it to the list
                        currect = m_rect_list.append(m_rect_allocator.alloc());

                        // make a rect describing this grid square
                        currect.m_rect.min_x = x << m_granularity;
                        currect.m_rect.max_x = currect.m_rect.min_x + tilesize - 1;
                        currect.m_rect.min_y = y << m_granularity;
                        currect.m_rect.max_y = currect.m_rect.min_y + tilesize - 1;
                    }

                    // if we can add to the previous rect, just expand its width
                    else
                    {
                        currect.m_rect.max_x += tilesize;
                    }
                }

                // clip the last rect to the cliprect
                if (currect != null)
                {
                    currect.m_rect &= cliprect;
                }
            }

            // mark the list as valid
            m_rect_list_bounds = cliprect;
            return(m_rect_list.empty() ? null : m_rect_list.first());
        }