diff options
Diffstat (limited to 'src/emu/emupal.h')
-rw-r--r-- | src/emu/emupal.h | 101 |
1 files changed, 11 insertions, 90 deletions
diff --git a/src/emu/emupal.h b/src/emu/emupal.h index 42b1c1253cc..31f6937fb52 100644 --- a/src/emu/emupal.h +++ b/src/emu/emupal.h @@ -104,9 +104,6 @@ // CONSTANTS //************************************************************************** -#define PALETTE_DEFAULT_SHADOW_FACTOR (0.6) -#define PALETTE_DEFAULT_HIGHLIGHT_FACTOR (1/PALETTE_DEFAULT_SHADOW_FACTOR) - #define PALETTE_INIT_NAME(_Name) palette_init_##_Name #define DECLARE_PALETTE_INIT(_Name) void PALETTE_INIT_NAME(_Name)(palette_device &palette) #define PALETTE_INIT_MEMBER(_Class, _Name) void _Class::PALETTE_INIT_NAME(_Name)(palette_device &palette) @@ -288,10 +285,9 @@ // TYPE DEFINITIONS //************************************************************************** +class palette_device; // forward declaration typedef device_delegate<void (palette_device &)> palette_init_delegate; -typedef u16 indirect_pen_t; - // ======================> raw_to_rgb_converter @@ -360,10 +356,8 @@ private: // device type definition extern const device_type PALETTE; -class palette_device : public device_t +class palette_device : public device_t, public device_palette_interface { - static const int MAX_SHADOW_PRESETS = 4; - public: // construction/destruction palette_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); @@ -378,21 +372,9 @@ public: static void static_enable_shadows(device_t &device); static void static_enable_hilights(device_t &device); - // getters - int entries() const { return m_entries; } - int indirect_entries() const { return m_indirect_entries; } - palette_t *palette() const { return m_palette; } - const pen_t &pen(int index) const { return m_pens[index]; } - const pen_t *pens() const { return m_pens; } - pen_t *shadow_table() const { return m_shadow_table; } - rgb_t pen_color(pen_t pen) { return m_palette->entry_color(pen); } - double pen_contrast(pen_t pen) { return m_palette->entry_contrast(pen); } - pen_t black_pen() const { return m_black_pen; } - pen_t white_pen() const { return m_white_pen; } + // palette RAM accessors memory_array &basemem() { return m_paletteram; } memory_array &extmem() { return m_paletteram_ext; } - bool shadows_enabled() { return m_enable_shadows; } - bool hilights_enabled() { return m_enable_hilights; } // raw entry reading u32 read_entry(pen_t pen) const @@ -403,28 +385,6 @@ public: return data; } - // setters - void set_pen_color(pen_t pen, rgb_t rgb) { m_palette->entry_set_color(pen, rgb); } - void set_pen_red_level(pen_t pen, u8 level) { m_palette->entry_set_red_level(pen, level); } - void set_pen_green_level(pen_t pen, u8 level) { m_palette->entry_set_green_level(pen, level); } - void set_pen_blue_level(pen_t pen, u8 level) { m_palette->entry_set_blue_level(pen, level); } - void set_pen_color(pen_t pen, u8 r, u8 g, u8 b) { m_palette->entry_set_color(pen, rgb_t(r, g, b)); } - void set_pen_colors(pen_t color_base, const rgb_t *colors, int color_count) { while (color_count--) set_pen_color(color_base++, *colors++); } - void set_pen_colors(pen_t color_base, const std::vector<rgb_t> &colors) { for(unsigned int i=0; i != colors.size(); i++) set_pen_color(color_base+i, colors[i]); } - void set_pen_contrast(pen_t pen, double bright) { m_palette->entry_set_contrast(pen, bright); } - - // indirection (aka colortables) - indirect_pen_t pen_indirect(int index) const { return m_indirect_pens[index]; } - rgb_t indirect_color(int index) const { return m_indirect_colors[index]; } - void set_indirect_color(int index, rgb_t rgb); - void set_pen_indirect(pen_t pen, indirect_pen_t index); - u32 transpen_mask(gfx_element &gfx, u32 color, indirect_pen_t transcolor); - - // shadow config - void set_shadow_factor(double factor) { assert(m_shadow_group != 0); m_palette->group_set_contrast(m_shadow_group, factor); } - void set_highlight_factor(double factor) { assert(m_hilight_group != 0); m_palette->group_set_contrast(m_hilight_group, factor); } - void set_shadow_mode(int mode) { assert(mode >= 0 && mode < MAX_SHADOW_PRESETS); m_shadow_table = m_shadow_tables[mode].base; } - // generic read/write handlers DECLARE_READ8_MEMBER(read); DECLARE_WRITE8_MEMBER(write); @@ -455,25 +415,20 @@ public: // helper to update palette when data changed void update() { if (!m_init.isnull()) m_init(*this); } + protected: // device-level overrides - virtual void device_validity_check(validity_checker &valid) const override; virtual void device_start() override; - virtual void device_pre_save() override; - virtual void device_post_load() override; - virtual void device_stop() override; - void allocate_palette(); - void allocate_color_tables(); - void allocate_shadow_tables(); + // device_palette_interface overrides + virtual int palette_entries() const override { return m_entries; } + virtual int palette_indirect_entries() const override { return m_indirect_entries; } + virtual bool palette_shadows_enabled() const override { return m_enable_shadows; } + virtual bool palette_hilights_enabled() const override { return m_enable_hilights; } +private: void update_for_write(offs_t byte_offset, int bytes_modified, bool indirect = false); -public: // needed by konamigx - void set_shadow_dRGB32(int mode, int dr, int dg, int db, bool noclip); -protected: - void configure_rgb_shadows(int mode, float factor); -private: // configuration state int m_entries; // number of entries in the palette int m_indirect_entries; // number of indirect colors in the palette @@ -483,47 +438,13 @@ private: bool m_membits_supplied; // true if membits forced in static config endianness_t m_endianness; // endianness of palette RAM, if different from native bool m_endianness_supplied; // true if endianness forced in static config + palette_init_delegate m_init; // palette RAM raw_to_rgb_converter m_raw_to_rgb; // format of palette RAM memory_array m_paletteram; // base memory memory_array m_paletteram_ext; // extended memory - - // internal state - palette_t * m_palette; // the palette itself - const pen_t * m_pens; // remapped palette pen numbers - bitmap_format m_format; // format assumed for palette data - pen_t * m_shadow_table; // table for looking up a shadowed pen - u32 m_shadow_group; // index of the shadow group, or 0 if none - u32 m_hilight_group; // index of the hilight group, or 0 if none - pen_t m_white_pen; // precomputed white pen value - pen_t m_black_pen; // precomputed black pen value - - // indirection state - std::vector<rgb_t> m_indirect_colors; // actual colors set for indirection - std::vector<indirect_pen_t> m_indirect_pens; // indirection values - - struct shadow_table_data - { - pen_t * base; // pointer to the base of the table - s16 dr; // delta red value - s16 dg; // delta green value - s16 db; // delta blue value - bool noclip; // clip? - }; - shadow_table_data m_shadow_tables[MAX_SHADOW_PRESETS]; // array of shadow table data - - std::vector<pen_t> m_save_pen; // pens for save/restore - std::vector<float> m_save_contrast; // brightness for save/restore - - std::vector<pen_t> m_pen_array; - std::vector<pen_t> m_shadow_array; - std::vector<pen_t> m_hilight_array; - palette_init_delegate m_init; }; -// device type iterator -typedef device_type_iterator<palette_device> palette_device_iterator; - #endif // MAME_EMU_EMUPAL_H |