mirror of
https://github.com/holub/mame
synced 2025-04-26 18:23:08 +03:00
jalblend.cpp : Updates
Move alpha table into palette, Fix spacing, Reduce unnecessary line, Fix some behavior, Use shorter / correct type values
This commit is contained in:
parent
f3f39b00e4
commit
f8866f86c0
@ -344,8 +344,7 @@ void argus_state::change_palette(int color, int lo_offs, int hi_offs)
|
|||||||
{
|
{
|
||||||
uint8_t lo = m_paletteram[lo_offs];
|
uint8_t lo = m_paletteram[lo_offs];
|
||||||
uint8_t hi = m_paletteram[hi_offs];
|
uint8_t hi = m_paletteram[hi_offs];
|
||||||
m_blend->set(color, hi & 0x0f);
|
m_palette->set_pen_color(color, rgb_t(hi & 0x0f, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4)));
|
||||||
m_palette->set_pen_color(color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void argus_state::change_bg_palette(int color, int lo_offs, int hi_offs)
|
void argus_state::change_bg_palette(int color, int lo_offs, int hi_offs)
|
||||||
|
@ -24,9 +24,8 @@
|
|||||||
|
|
||||||
DEFINE_DEVICE_TYPE(JALECO_BLEND, jaleco_blend_device, "jaleco_blend", "Jaleco Blending Device")
|
DEFINE_DEVICE_TYPE(JALECO_BLEND, jaleco_blend_device, "jaleco_blend", "Jaleco Blending Device")
|
||||||
|
|
||||||
jaleco_blend_device::jaleco_blend_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
|
jaleco_blend_device::jaleco_blend_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
|
||||||
: device_t(mconfig, JALECO_BLEND, tag, owner, clock)
|
: device_t(mconfig, JALECO_BLEND, tag, owner, clock)
|
||||||
, m_table(nullptr)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,9 +35,6 @@ jaleco_blend_device::jaleco_blend_device(const machine_config &mconfig, const ch
|
|||||||
|
|
||||||
void jaleco_blend_device::device_start()
|
void jaleco_blend_device::device_start()
|
||||||
{
|
{
|
||||||
m_table = make_unique_clear<uint8_t[]>(0xc00);
|
|
||||||
|
|
||||||
save_pointer(NAME(m_table), 0xc00);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
@ -47,12 +43,6 @@ void jaleco_blend_device::device_start()
|
|||||||
|
|
||||||
void jaleco_blend_device::device_reset()
|
void jaleco_blend_device::device_reset()
|
||||||
{
|
{
|
||||||
memset(m_table.get(), 0, 0xc00);
|
|
||||||
}
|
|
||||||
|
|
||||||
void jaleco_blend_device::set(int color, uint8_t val)
|
|
||||||
{
|
|
||||||
m_table[color] = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -67,19 +57,26 @@ void jaleco_blend_device::set(int color, uint8_t val)
|
|||||||
* -------x | blue add/subtract
|
* -------x | blue add/subtract
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* basically an add/subtract function with clamping */
|
rgb_t jaleco_blend_device::func(rgb_t dest, rgb_t addMe)
|
||||||
rgb_t jaleco_blend_device::func(rgb_t dest, rgb_t addMe, uint8_t alpha)
|
|
||||||
{
|
{
|
||||||
int r, g, b;
|
// Comp with clamp
|
||||||
int ir, ig, ib;
|
if (addMe.a() & 8)
|
||||||
|
return func(dest, addMe, addMe.a());
|
||||||
|
|
||||||
r = (int)dest.r();
|
// Skip the costly alpha step altogether
|
||||||
g = (int)dest.g();
|
return addMe;
|
||||||
b = (int)dest.b();
|
}
|
||||||
|
|
||||||
ir = (int)addMe.r();
|
/* basically an add/subtract function with clamping */
|
||||||
ig = (int)addMe.g();
|
rgb_t jaleco_blend_device::func(rgb_t dest, rgb_t addMe, u8 alpha)
|
||||||
ib = (int)addMe.b();
|
{
|
||||||
|
int r = (int)dest.r();
|
||||||
|
int g = (int)dest.g();
|
||||||
|
int b = (int)dest.b();
|
||||||
|
|
||||||
|
const u8 ir = addMe.r();
|
||||||
|
const u8 ig = addMe.g();
|
||||||
|
const u8 ib = addMe.b();
|
||||||
|
|
||||||
if (alpha & 4)
|
if (alpha & 4)
|
||||||
{ r -= ir; if (r < 0) r = 0; }
|
{ r -= ir; if (r < 0) r = 0; }
|
||||||
@ -99,29 +96,26 @@ rgb_t jaleco_blend_device::func(rgb_t dest, rgb_t addMe, uint8_t alpha)
|
|||||||
|
|
||||||
template<class _BitmapClass>
|
template<class _BitmapClass>
|
||||||
void jaleco_blend_device::drawgfx_common(palette_device &palette,_BitmapClass &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
void jaleco_blend_device::drawgfx_common(palette_device &palette,_BitmapClass &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
||||||
uint32_t code,uint32_t color,int flipx,int flipy,int offsx,int offsy,
|
u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,
|
||||||
int transparent_color)
|
u8 transparent_color)
|
||||||
{
|
{
|
||||||
/* Start drawing */
|
/* Start drawing */
|
||||||
const pen_t *pal = &palette.pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors()));
|
const pen_t *pal = &palette.pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors()));
|
||||||
const uint8_t *alpha = &m_table[gfx->granularity() * (color % gfx->colors())];
|
const u8 *source_base = gfx->get_data(code % gfx->elements());
|
||||||
const uint8_t *source_base = gfx->get_data(code % gfx->elements());
|
|
||||||
int x_index_base, y_index, sx, sy, ex, ey;
|
|
||||||
int xinc, yinc;
|
|
||||||
|
|
||||||
xinc = flipx ? -1 : 1;
|
const int xinc = flipx ? -1 : 1;
|
||||||
yinc = flipy ? -1 : 1;
|
const int yinc = flipy ? -1 : 1;
|
||||||
|
|
||||||
x_index_base = flipx ? gfx->width()-1 : 0;
|
int x_index_base = flipx ? gfx->width() - 1 : 0;
|
||||||
y_index = flipy ? gfx->height()-1 : 0;
|
int y_index = flipy ? gfx->height() - 1 : 0;
|
||||||
|
|
||||||
// start coordinates
|
// start coordinates
|
||||||
sx = offsx;
|
int sx = offsx;
|
||||||
sy = offsy;
|
int sy = offsy;
|
||||||
|
|
||||||
// end coordinates
|
// end coordinates
|
||||||
ex = sx + gfx->width();
|
int ex = sx + gfx->width();
|
||||||
ey = sy + gfx->height();
|
int ey = sy + gfx->height();
|
||||||
|
|
||||||
if (sx < clip.min_x)
|
if (sx < clip.min_x)
|
||||||
{ // clip left
|
{ // clip left
|
||||||
@ -147,29 +141,19 @@ void jaleco_blend_device::drawgfx_common(palette_device &palette,_BitmapClass &d
|
|||||||
|
|
||||||
if (ex > sx)
|
if (ex > sx)
|
||||||
{ // skip if inner loop doesn't draw anything
|
{ // skip if inner loop doesn't draw anything
|
||||||
int x, y;
|
|
||||||
|
|
||||||
// taken from case 7: TRANSPARENCY_ALPHARANGE
|
// taken from case : TRANSPARENCY_ALPHARANGE
|
||||||
for (y = sy; y < ey; y++)
|
for (int y = sy; y < ey; y++)
|
||||||
{
|
{
|
||||||
const uint8_t *source = source_base + y_index*gfx->rowbytes();
|
const u8 *source = source_base + y_index*gfx->rowbytes();
|
||||||
typename _BitmapClass::pixel_t *dest = &dest_bmp.pix(y);
|
typename _BitmapClass::pixel_t *dest = &dest_bmp.pix(y);
|
||||||
int x_index = x_index_base;
|
int x_index = x_index_base;
|
||||||
for (x = sx; x < ex; x++)
|
for (int x = sx; x < ex; x++)
|
||||||
{
|
{
|
||||||
int c = source[x_index];
|
const u8 c = source[x_index];
|
||||||
if (c != transparent_color)
|
if (c != transparent_color)
|
||||||
{
|
{
|
||||||
if (alpha[c] & 8)
|
dest[x] = jaleco_blend_device::func(dest[x], pal[c]);
|
||||||
{
|
|
||||||
// Comp with clamp
|
|
||||||
dest[x] = jaleco_blend_device::func(dest[x], pal[c], alpha[c]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Skip the costly alpha step altogether
|
|
||||||
dest[x] = pal[c];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
x_index += xinc;
|
x_index += xinc;
|
||||||
}
|
}
|
||||||
@ -179,10 +163,10 @@ void jaleco_blend_device::drawgfx_common(palette_device &palette,_BitmapClass &d
|
|||||||
}
|
}
|
||||||
|
|
||||||
void jaleco_blend_device::drawgfx(palette_device &palette,bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
void jaleco_blend_device::drawgfx(palette_device &palette,bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
||||||
uint32_t code,uint32_t color,int flipx,int flipy,int offsx,int offsy,
|
u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,
|
||||||
int transparent_color)
|
u8 transparent_color)
|
||||||
{ jaleco_blend_device::drawgfx_common(palette,dest_bmp, clip, gfx, code, color, flipx, flipy, offsx, offsy, transparent_color); }
|
{ jaleco_blend_device::drawgfx_common(palette,dest_bmp, clip, gfx, code, color, flipx, flipy, offsx, offsy, transparent_color); }
|
||||||
void jaleco_blend_device::drawgfx(palette_device &palette,bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
void jaleco_blend_device::drawgfx(palette_device &palette,bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
||||||
uint32_t code,uint32_t color,int flipx,int flipy,int offsx,int offsy,
|
u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,
|
||||||
int transparent_color)
|
u8 transparent_color)
|
||||||
{ jaleco_blend_device::drawgfx_common(palette,dest_bmp, clip, gfx, code, color, flipx, flipy, offsx, offsy, transparent_color); }
|
{ jaleco_blend_device::drawgfx_common(palette,dest_bmp, clip, gfx, code, color, flipx, flipy, offsx, offsy, transparent_color); }
|
||||||
|
@ -10,17 +10,17 @@
|
|||||||
class jaleco_blend_device : public device_t
|
class jaleco_blend_device : public device_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
jaleco_blend_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
jaleco_blend_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
|
||||||
~jaleco_blend_device() {}
|
~jaleco_blend_device() {}
|
||||||
|
|
||||||
void set(int color, uint8_t val);
|
rgb_t func(rgb_t dest, rgb_t addMe);
|
||||||
rgb_t func(rgb_t dest, rgb_t addMe, uint8_t alpha);
|
rgb_t func(rgb_t dest, rgb_t addMe, u8 alpha);
|
||||||
void drawgfx(palette_device &palette,bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
void drawgfx(palette_device &palette,bitmap_ind16 &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
||||||
uint32_t code,uint32_t color,int flipx,int flipy,int offsx,int offsy,
|
u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,
|
||||||
int transparent_color);
|
u8 transparent_color);
|
||||||
void drawgfx(palette_device &palette,bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
void drawgfx(palette_device &palette,bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
||||||
uint32_t code,uint32_t color,int flipx,int flipy,int offsx,int offsy,
|
u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,
|
||||||
int transparent_color);
|
u8 transparent_color);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// device-level overrides
|
// device-level overrides
|
||||||
@ -28,13 +28,10 @@ protected:
|
|||||||
virtual void device_reset() override;
|
virtual void device_reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* each palette entry contains a fourth 'alpha' value */
|
|
||||||
std::unique_ptr<uint8_t[]> m_table;
|
|
||||||
|
|
||||||
template<class _BitmapClass>
|
template<class _BitmapClass>
|
||||||
void drawgfx_common(palette_device &palette,_BitmapClass &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
void drawgfx_common(palette_device &palette,_BitmapClass &dest_bmp,const rectangle &clip,gfx_element *gfx,
|
||||||
uint32_t code,uint32_t color,int flipx,int flipy,int offsx,int offsy,
|
u32 code,u32 color,bool flipx,bool flipy,int offsx,int offsy,
|
||||||
int transparent_color);
|
u8 transparent_color);
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_DEVICE_TYPE(JALECO_BLEND, jaleco_blend_device)
|
DECLARE_DEVICE_TYPE(JALECO_BLEND, jaleco_blend_device)
|
||||||
|
@ -27,10 +27,7 @@ void psychic5_state::change_palette(int offset, uint8_t* palram, int palbase)
|
|||||||
|
|
||||||
int color = offset >> 1;
|
int color = offset >> 1;
|
||||||
|
|
||||||
if (m_blend)
|
m_palette->set_pen_color(palbase + color, rgb_t(hi & 0x0f, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4)));
|
||||||
m_blend->set(palbase + color, hi & 0x0f);
|
|
||||||
|
|
||||||
m_palette->set_pen_color(palbase + color, pal4bit(lo >> 4), pal4bit(lo), pal4bit(hi >> 4));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void psychic5_state::change_bg_palette(int color, int lo_offs, int hi_offs)
|
void psychic5_state::change_bg_palette(int color, int lo_offs, int hi_offs)
|
||||||
|
Loading…
Reference in New Issue
Block a user