mirror of
https://github.com/holub/mame
synced 2025-04-24 01:11:11 +03:00
snk/k1ge.cpp: Implement device_palette_interface. (#12864)
This commit is contained in:
parent
8e6222bb6d
commit
05c6fc873a
@ -14,26 +14,26 @@
|
||||
#include "screen.h"
|
||||
|
||||
|
||||
void k1ge_device::k1ge_palette(palette_device &palette) const
|
||||
void k1ge_device::palette_init()
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int const j = pal3bit(i);
|
||||
const u8 j = pal3bit(i);
|
||||
|
||||
palette.set_pen_color(7 - i, j, j, j);
|
||||
set_pen_color(7 - i, j, j, j);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void k2ge_device::k2ge_palette(palette_device &palette) const
|
||||
void k2ge_device::palette_init()
|
||||
{
|
||||
for (int b = 0; b < 16; b++ )
|
||||
for (int b = 0; b < 16; b++)
|
||||
{
|
||||
for (int g = 0; g < 16; g++ )
|
||||
for (int g = 0; g < 16; g++)
|
||||
{
|
||||
for (int r = 0; r < 16; r++ )
|
||||
for (int r = 0; r < 16; r++)
|
||||
{
|
||||
palette.set_pen_color((b << 8) | (g << 4) | r, (r << 4) | r, (g << 4) | g, (b << 4) | b);
|
||||
set_pen_color((b << 8) | (g << 4) | r, (r << 4) | r, (g << 4) | g, (b << 4) | b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -802,6 +802,8 @@ void k1ge_device::device_start()
|
||||
save_item(NAME(m_wba_v));
|
||||
save_item(NAME(m_wsi_h));
|
||||
save_item(NAME(m_wsi_v));
|
||||
|
||||
palette_init();
|
||||
}
|
||||
|
||||
|
||||
@ -863,34 +865,16 @@ k1ge_device::k1ge_device(const machine_config &mconfig, const char *tag, device_
|
||||
k1ge_device::k1ge_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
|
||||
: device_t(mconfig, type, tag, owner, clock)
|
||||
, device_video_interface(mconfig, *this)
|
||||
, device_palette_interface(mconfig, *this)
|
||||
, m_vblank_pin_w(*this)
|
||||
, m_hblank_pin_w(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_add_mconfig - add device configuration
|
||||
//-------------------------------------------------
|
||||
|
||||
void k1ge_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
PALETTE(config, "palette", FUNC(k1ge_device::k1ge_palette), 8);
|
||||
}
|
||||
|
||||
|
||||
DEFINE_DEVICE_TYPE(K2GE, k2ge_device, "k2ge", "K2GE Color Graphics + LCD")
|
||||
|
||||
k2ge_device::k2ge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
||||
: k1ge_device(mconfig, K2GE, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_add_mconfig - add device configuration
|
||||
//-------------------------------------------------
|
||||
|
||||
void k2ge_device::device_add_mconfig(machine_config &config)
|
||||
{
|
||||
PALETTE(config, "palette", FUNC(k2ge_device::k2ge_palette), 4096);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "emupal.h"
|
||||
|
||||
class k1ge_device : public device_t, public device_video_interface
|
||||
class k1ge_device : public device_t, public device_video_interface, public device_palette_interface
|
||||
{
|
||||
public:
|
||||
template <typename T>
|
||||
@ -42,7 +42,7 @@ protected:
|
||||
// device-level overrides
|
||||
virtual void device_start() override ATTR_COLD;
|
||||
virtual void device_reset() override ATTR_COLD;
|
||||
virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
|
||||
virtual uint32_t palette_entries() const noexcept override { return PALETTE_SIZE; }
|
||||
|
||||
devcb_write_line m_vblank_pin_w;
|
||||
devcb_write_line m_hblank_pin_w;
|
||||
@ -59,9 +59,10 @@ protected:
|
||||
void draw_sprite_plane( uint16_t *p, uint16_t priority, int line, int scroll_x, int scroll_y );
|
||||
TIMER_CALLBACK_MEMBER( hblank_on_timer_callback );
|
||||
TIMER_CALLBACK_MEMBER( timer_callback );
|
||||
virtual void palette_init();
|
||||
|
||||
private:
|
||||
void k1ge_palette(palette_device &palette) const;
|
||||
static constexpr int PALETTE_SIZE = 8;
|
||||
};
|
||||
|
||||
|
||||
@ -78,7 +79,7 @@ public:
|
||||
k2ge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
protected:
|
||||
virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
|
||||
virtual uint32_t palette_entries() const noexcept override { return PALETTE_SIZE; }
|
||||
|
||||
virtual void draw(int line) override;
|
||||
|
||||
@ -86,9 +87,10 @@ protected:
|
||||
void draw_sprite_plane( uint16_t *p, uint16_t priority, int line, int scroll_x, int scroll_y );
|
||||
void k1ge_draw_scroll_plane( uint16_t *p, uint16_t base, int line, int scroll_x, int scroll_y, uint16_t pal_lut_base, uint16_t k2ge_lut_base );
|
||||
void k1ge_draw_sprite_plane( uint16_t *p, uint16_t priority, int line, int scroll_x, int scroll_y );
|
||||
virtual void palette_init() override;
|
||||
|
||||
private:
|
||||
void k2ge_palette(palette_device &palette) const;
|
||||
static constexpr int PALETTE_SIZE = 4096;
|
||||
};
|
||||
|
||||
DECLARE_DEVICE_TYPE(K1GE, k1ge_device)
|
||||
|
@ -895,7 +895,7 @@ void ngp_state::ngp(machine_config &config)
|
||||
m_k1ge->vblank_callback().set(FUNC(ngp_state::ngp_vblank_pin_w));
|
||||
m_k1ge->hblank_callback().set(FUNC(ngp_state::ngp_hblank_pin_w));
|
||||
|
||||
m_screen->set_palette("k1ge:palette");
|
||||
m_screen->set_palette(m_k1ge);
|
||||
|
||||
generic_cartslot_device &cartslot(GENERIC_CARTSLOT(config, "cartslot", generic_plain_slot, "ngp_cart", "bin,ngp,npc,ngc"));
|
||||
cartslot.set_device_load(FUNC(ngp_state::load_ngp_cart));
|
||||
@ -913,7 +913,7 @@ void ngp_state::ngpc(machine_config &config)
|
||||
m_k1ge->vblank_callback().set(FUNC(ngp_state::ngp_vblank_pin_w));
|
||||
m_k1ge->hblank_callback().set(FUNC(ngp_state::ngp_hblank_pin_w));
|
||||
|
||||
m_screen->set_palette("k1ge:palette");
|
||||
m_screen->set_palette(m_k1ge);
|
||||
|
||||
generic_cartslot_device &cartslot(GENERIC_CARTSLOT(config, "cartslot", generic_plain_slot, "ngp_cart", "bin,ngp,npc,ngc"));
|
||||
cartslot.set_device_load(FUNC(ngp_state::load_ngp_cart));
|
||||
|
Loading…
Reference in New Issue
Block a user