Skip to content

Commit

Permalink
add supduck palette type to emupal.c and use that (nw)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamehaze committed Dec 1, 2014
1 parent ab9039f commit d00d8db
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 28 deletions.
10 changes: 9 additions & 1 deletion src/emu/emupal.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,10 +927,18 @@ rgb_t raw_to_rgb_converter::RRRRGGGGBBBBRGBx_decoder(UINT32 raw)
return rgb_t(r, g, b);
}

rgb_t raw_to_rgb_converter::xRGBRRRRGGGGBBBB_decoder(UINT32 raw)
rgb_t raw_to_rgb_converter::xRGBRRRRGGGGBBBB_bit0_decoder(UINT32 raw)
{
UINT8 r = pal5bit(((raw >> 7) & 0x1e) | ((raw >> 14) & 0x01));
UINT8 g = pal5bit(((raw >> 3) & 0x1e) | ((raw >> 13) & 0x01));
UINT8 b = pal5bit(((raw << 1) & 0x1e) | ((raw >> 12) & 0x01));
return rgb_t(r, g, b);
}

rgb_t raw_to_rgb_converter::xRGBRRRRGGGGBBBB_bit4_decoder(UINT32 raw)
{
UINT8 r = pal5bit(((raw >> 8) & 0x0f) | ((raw >> 10) & 0x10));
UINT8 g = pal5bit(((raw >> 4) & 0x0f) | ((raw >> 9) & 0x10));
UINT8 b = pal5bit(((raw >> 0) & 0x0f) | ((raw >> 8) & 0x10));
return rgb_t(r, g, b);
}
6 changes: 4 additions & 2 deletions src/emu/emupal.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
#define PALETTE_FORMAT_RRRRRGGGGGBBBBBx raw_to_rgb_converter(2, &raw_to_rgb_converter::standard_rgb_decoder<5,5,5, 11,6,1>)
#define PALETTE_FORMAT_GGGGGRRRRRBBBBBx raw_to_rgb_converter(2, &raw_to_rgb_converter::standard_rgb_decoder<5,5,5, 6,11,1>)
#define PALETTE_FORMAT_RRRRGGGGBBBBRGBx raw_to_rgb_converter(2, &raw_to_rgb_converter::RRRRGGGGBBBBRGBx_decoder)
#define PALETTE_FORMAT_xRGBRRRRGGGGBBBB raw_to_rgb_converter(2, &raw_to_rgb_converter::xRGBRRRRGGGGBBBB_decoder)
#define PALETTE_FORMAT_xRGBRRRRGGGGBBBB_bit0 raw_to_rgb_converter(2, &raw_to_rgb_converter::xRGBRRRRGGGGBBBB_bit0_decoder)
#define PALETTE_FORMAT_xRGBRRRRGGGGBBBB_bit4 raw_to_rgb_converter(2, &raw_to_rgb_converter::xRGBRRRRGGGGBBBB_bit4_decoder)

// standard 5-6-5 formats
#define PALETTE_FORMAT_RRRRRGGGGGGBBBBB raw_to_rgb_converter(2, &raw_to_rgb_converter::standard_rgb_decoder<5,6,5, 11,5,0>)
Expand Down Expand Up @@ -307,7 +308,8 @@ class raw_to_rgb_converter
static rgb_t BBGGRRII_decoder(UINT32 raw);
static rgb_t IRRRRRGGGGGBBBBB_decoder(UINT32 raw);
static rgb_t RRRRGGGGBBBBRGBx_decoder(UINT32 raw); // bits 3/2/1 are LSb
static rgb_t xRGBRRRRGGGGBBBB_decoder(UINT32 raw); // bits 14/13/12 are LSb
static rgb_t xRGBRRRRGGGGBBBB_bit0_decoder(UINT32 raw); // bits 14/13/12 are LSb
static rgb_t xRGBRRRRGGGGBBBB_bit4_decoder(UINT32 raw); // bits 14/13/12 are MSb

private:
// internal data
Expand Down
8 changes: 4 additions & 4 deletions src/mame/drivers/alpha68k.c
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ static MACHINE_CONFIG_START( alpha68k_II, alpha68k_state )

MCFG_GFXDECODE_ADD("gfxdecode", "palette", alpha68k_II)
MCFG_PALETTE_ADD("palette", 2048)
MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB)
MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB_bit0)

MCFG_VIDEO_START_OVERRIDE(alpha68k_state,alpha68k)

Expand Down Expand Up @@ -2151,7 +2151,7 @@ static MACHINE_CONFIG_START( alpha68k_II_gm, alpha68k_state )

MCFG_GFXDECODE_ADD("gfxdecode", "palette", alpha68k_II)
MCFG_PALETTE_ADD("palette", 2048)
MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB)
MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB_bit0)

MCFG_VIDEO_START_OVERRIDE(alpha68k_state,alpha68k)

Expand Down Expand Up @@ -2197,7 +2197,7 @@ static MACHINE_CONFIG_START( alpha68k_V, alpha68k_state )

MCFG_GFXDECODE_ADD("gfxdecode", "palette", alpha68k_V)
MCFG_PALETTE_ADD("palette", 4096)
MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB)
MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB_bit0)

MCFG_VIDEO_START_OVERRIDE(alpha68k_state,alpha68k)

Expand Down Expand Up @@ -2243,7 +2243,7 @@ static MACHINE_CONFIG_START( alpha68k_V_sb, alpha68k_state )

MCFG_GFXDECODE_ADD("gfxdecode", "palette", alpha68k_V)
MCFG_PALETTE_ADD("palette", 4096)
MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB)
MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB_bit0)

MCFG_VIDEO_START_OVERRIDE(alpha68k_state,alpha68k)

Expand Down
23 changes: 2 additions & 21 deletions src/mame/drivers/supduck.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class supduck_state : public driver_device
m_text_videoram(*this, "textvideoram"),
m_fore_videoram(*this, "forevideoram"),
m_back_videoram(*this, "backvideoram"),
m_paletteram(*this, "paletteram"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette")
{ }
Expand All @@ -50,7 +49,6 @@ class supduck_state : public driver_device
required_shared_ptr<UINT16> m_text_videoram;
required_shared_ptr<UINT16> m_fore_videoram;
required_shared_ptr<UINT16> m_back_videoram;
required_shared_ptr<UINT16> m_paletteram;

required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
Expand All @@ -68,7 +66,6 @@ class supduck_state : public driver_device

DECLARE_WRITE16_MEMBER(supduck_4000_w);
DECLARE_WRITE16_MEMBER(supduck_4002_w);
DECLARE_WRITE16_MEMBER(supduck_paletteram_w);

TILEMAP_MAPPER_MEMBER(supduk_tilemap_scan);

Expand Down Expand Up @@ -245,22 +242,6 @@ WRITE16_MEMBER(supduck_state::supduck_4000_w)
{
}

WRITE16_MEMBER(supduck_state::supduck_paletteram_w)
{
int r, g, b;
data = COMBINE_DATA(&m_paletteram[offset]);

r = ((data >> 8) & 0x0f);
if (data & 0x4000) r |= 0x10;

g = ((data >> 4 ) & 0x0f);
if (data & 0x2000) g |= 0x10;

b = ((data >> 0 ) & 0x0f);
if (data & 0x1000) b |= 0x10;

m_palette->set_pen_color (offset, rgb_t(r<<3, g<<3, b<<3));
}

WRITE16_MEMBER(supduck_state::supduck_4002_w)
{
Expand Down Expand Up @@ -308,7 +289,7 @@ static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, supduck_state )
AM_RANGE(0xfec000, 0xfecfff) AM_RAM_WRITE(text_videoram_w) AM_SHARE("textvideoram")
AM_RANGE(0xff0000, 0xff3fff) AM_RAM_WRITE(back_videoram_w) AM_SHARE("backvideoram")
AM_RANGE(0xff4000, 0xff7fff) AM_RAM_WRITE(fore_videoram_w) AM_SHARE("forevideoram")
AM_RANGE(0xff8000, 0xff87ff) AM_RAM_WRITE(supduck_paletteram_w) AM_SHARE("paletteram") // AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
AM_RANGE(0xff8000, 0xff87ff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette")
AM_RANGE(0xffc000, 0xffffff) AM_RAM /* working RAM */
ADDRESS_MAP_END

Expand Down Expand Up @@ -510,7 +491,7 @@ static MACHINE_CONFIG_START( supduck, supduck_state )
MCFG_GFXDECODE_ADD("gfxdecode", "palette", supduck)

MCFG_PALETTE_ADD("palette", 0x800/2)
// MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB) // can't use this, the RGB bits are the lowest bits with this format, for this game they're the highest bits
MCFG_PALETTE_FORMAT(xRGBRRRRGGGGBBBB_bit4)

/* sound hardware */
MCFG_SPEAKER_STANDARD_MONO("mono")
Expand Down

0 comments on commit d00d8db

Please sign in to comment.