Example #1
0
        // generic read/write handlers
        //DECLARE_READ8_MEMBER(read8);
        //DECLARE_READ8_MEMBER(read8_ext);
        //DECLARE_WRITE8_MEMBER(write8);
        //DECLARE_WRITE8_MEMBER(write8_ext);
        //DECLARE_WRITE8_MEMBER(write_indirect);
        //DECLARE_WRITE8_MEMBER(write_indirect_ext);
        //DECLARE_READ16_MEMBER(read16);
        //DECLARE_READ16_MEMBER(read16_ext);
        //DECLARE_WRITE16_MEMBER(write16);
        //DECLARE_WRITE16_MEMBER(write16_ext);
        //DECLARE_READ32_MEMBER(read32);
        //DECLARE_WRITE32_MEMBER(write32);


        // helper to update palette when data changed
        //void update() { if (!m_init.isnull()) m_init(*this); }


        // device-level overrides

        //-------------------------------------------------
        //  device_start - start up the device
        //-------------------------------------------------
        protected override void device_start()
        {
            // bind the init function
            //m_init.bind_relative_to(*owner());

            // find the memory, if present
            memory_share share = memshare(tag());

            if (share != null)
            {
                // find the extended (split) memory, if present
                string       tag_ext   = tag() + "_ext";
                memory_share share_ext = memshare(tag_ext);

                // make sure we have specified a format
                //assert_always(m_raw_to_rgb.bytes_per_entry() > 0, "Palette has memory share but no format specified");

                // determine bytes per entry and configure
                int bytes_per_entry = m_raw_to_rgb.bytes_per_entry();
                if (share_ext == null)
                {
                    m_paletteram.set(share, bytes_per_entry);
                }
                else
                {
                    m_paletteram.set(share, bytes_per_entry / 2);
                    m_paletteram_ext.set(share_ext, bytes_per_entry / 2);
                }

                // override membits if provided
                if (m_membits_supplied)
                {
                    // forcing width only makes sense when narrower than the native bus width
                    //assert_always(m_membits < share->bitwidth(), "Improper use of MCFG_PALETTE_MEMBITS");
                    m_paletteram.set_membits(m_membits);
                    if (share_ext != null)
                    {
                        m_paletteram_ext.set_membits(m_membits);
                    }
                }

                // override endianness if provided
                if (m_endianness_supplied)
                {
                    // forcing endianness only makes sense when the RAM is narrower than the palette format and not split
                    //assert_always((share_ext == NULL && m_paletteram.membits() / 8 < bytes_per_entry), "Improper use of MCFG_PALETTE_ENDIANNESS");
                    m_paletteram.set_endianness(m_endianness);
                }
            }

            // call the initialization helper if present
            if (m_init != null)
            {
                m_init(this);
            }
        }
Example #2
0
        //void write16_ext(offs_t offset, u16 data, u16 mem_mask = u16(~0));
        //u32 read32(offs_t offset);
        //void write32(offs_t offset, u32 data, u32 mem_mask = u32(~0));


        // helper to update palette when data changed
        //void update() { if (!m_init.isnull()) m_init(*this); }


        // device-level overrides

        //-------------------------------------------------
        //  device_start - start up the device
        //-------------------------------------------------
        protected override void device_start()
        {
            // bind the init function
            //m_init.resolve();

            // find the memory, if present
            memory_share share = memshare(tag());

            if (share != null)
            {
                // find the extended (split) memory, if present
                string       tag_ext   = tag() + "_ext";
                memory_share share_ext = memshare(tag_ext);

                // make sure we have specified a format
                if (m_raw_to_rgb.bytes_per_entry() <= 0)
                {
                    throw new emu_fatalerror("palette_device({0}): Palette has memory share but no format specified", tag());
                }

                // determine bytes per entry and configure
                int bytes_per_entry = m_raw_to_rgb.bytes_per_entry();
                if (share_ext == null)
                {
                    m_paletteram.set(share, bytes_per_entry);
                }
                else
                {
                    m_paletteram.set(share, bytes_per_entry / 2);
                    m_paletteram_ext.set(share_ext, bytes_per_entry / 2);
                }

                // override membits if provided
                if (m_membits_supplied)
                {
                    // forcing width only makes sense when narrower than the native bus width
                    if (m_membits >= share.bitwidth())
                    {
                        throw new emu_fatalerror("palette_device({0}): Improper use of MCFG_PALETTE_MEMBITS", tag());
                    }

                    m_paletteram.set_membits(m_membits);
                    if (share_ext != null)
                    {
                        m_paletteram_ext.set_membits(m_membits);
                    }
                }

                // override endianness if provided
                if (m_endianness_supplied)
                {
                    // forcing endianness only makes sense when the RAM is narrower than the palette format and not split
                    if (share_ext != null || (m_paletteram.membits() / 8) >= bytes_per_entry)
                    {
                        throw new emu_fatalerror("palette_device({0}): Improper use of MCFG_PALETTE_ENDIANNESS", tag());
                    }

                    m_paletteram.set_endianness(m_endianness);
                }
            }

            // call the initialization helper if present
            if (m_init != null)
            {
                m_init(this);
            }
        }