//------------------------------------------------- // find_memshare - find memory share //------------------------------------------------- public override ListBytesPointer find_memshare(u8 width, out UInt32 bytes, bool required) { bytes = 0; // look up the share and return NULL if not found memory_share share = base_().memshare(tag()); if (share == null) { return(null); } // check the width and warn if not correct if (width != 0 && share.bitwidth() != width) { if (required) { osd_printf_warning("Shared ptr '{0}' found but is width {1}, not {2} as requested\n", tag(), share.bitwidth(), width); } return(null); } // return results bytes = (UInt32)share.bytes(); return(share.ptr()); }
public void set(memory_share share, int bpe) { set(share.ptr(), (UInt32)share.bytes(), share.bitwidth(), share.endianness(), bpe); }
//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); } }