diff options
Diffstat (limited to 'src/mame/video/jalblend.c')
-rw-r--r-- | src/mame/video/jalblend.c | 193 |
1 files changed, 97 insertions, 96 deletions
diff --git a/src/mame/video/jalblend.c b/src/mame/video/jalblend.c index 3e94ad933bd..6b6e6f8917a 100644 --- a/src/mame/video/jalblend.c +++ b/src/mame/video/jalblend.c @@ -14,33 +14,43 @@ #include "emu.h" #include "jalblend.h" +/***************************************************************************** + DEVICE INTERFACE +*****************************************************************************/ -/* each palette entry contains a fourth 'alpha' value */ -static UINT8 *jal_blend_table; -static void jal_blend_reset(running_machine &machine) +const device_type JALECO_BLEND = &device_creator<jaleco_blend_device>; + +jaleco_blend_device::jaleco_blend_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, JALECO_BLEND, "Jaleco Blending Device", tag, owner, clock, "jaleco_blend", __FILE__), + m_table(NULL) { - memset(jal_blend_table, 0, 0xc00); } -void jal_blend_init(running_machine &machine, int enable) +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void jaleco_blend_device::device_start() { - if (enable) - { - jal_blend_table = auto_alloc_array_clear(machine, UINT8, 0xc00); - machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(jal_blend_reset), &machine)); - machine.save().save_pointer(NAME(jal_blend_table), 0xc00); - } - else - { - jal_blend_table = NULL; - } + m_table = auto_alloc_array_clear(machine(), UINT8, 0xc00); + + save_pointer(NAME(m_table), 0xc00); } -void jal_blend_set(int color, UINT8 val) +//------------------------------------------------- +// device_reset - device-specific startup +//------------------------------------------------- + +void jaleco_blend_device::device_reset() { - if (jal_blend_table) jal_blend_table[color] = val; + memset(m_table, 0, 0xc00); +} + +void jaleco_blend_device::set(int color, UINT8 val) +{ + m_table[color] = val; } /* @@ -56,7 +66,7 @@ void jal_blend_set(int color, UINT8 val) */ /* basically an add/subtract function with clamping */ -rgb_t jal_blend_func(rgb_t dest, rgb_t addMe, UINT8 alpha) +rgb_t jaleco_blend_device::func(rgb_t dest, rgb_t addMe, UINT8 alpha) { int r, g, b; int ir, ig, ib; @@ -86,100 +96,91 @@ rgb_t jal_blend_func(rgb_t dest, rgb_t addMe, UINT8 alpha) } template<class _BitmapClass> -void jal_blend_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 code,UINT32 color,int flipx,int flipy,int offsx,int offsy, int transparent_color) { - if (jal_blend_table == NULL) - { - gfx->transpen(dest_bmp,clip,code,color,flipx,flipy,offsx,offsy,transparent_color); - return; - } - /* Start drawing */ - if (gfx) - { - const pen_t *pal = &palette.pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors())); - const UINT8 *alpha = &jal_blend_table[gfx->granularity() * (color % gfx->colors())]; - const UINT8 *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; - yinc = flipy ? -1 : 1; - - x_index_base = flipx ? gfx->width()-1 : 0; - y_index = flipy ? gfx->height()-1 : 0; - - // start coordinates - sx = offsx; - sy = offsy; - - // end coordinates - ex = sx + gfx->width(); - ey = sy + gfx->height(); - - if (sx < clip.min_x) - { // clip left - int pixels = clip.min_x-sx; - sx += pixels; - x_index_base += xinc*pixels; - } - if (sy < clip.min_y) - { // clip top - int pixels = clip.min_y-sy; - sy += pixels; - y_index += yinc*pixels; - } - // NS 980211 - fixed incorrect clipping - if (ex > clip.max_x+1) - { // clip right - ex = clip.max_x+1; - } - if (ey > clip.max_y+1) - { // clip bottom - ey = clip.max_y+1; - } - - if (ex > sx) - { // skip if inner loop doesn't draw anything - int x, y; + const pen_t *pal = &palette.pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors())); + const UINT8 *alpha = &m_table[gfx->granularity() * (color % gfx->colors())]; + const UINT8 *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; + yinc = flipy ? -1 : 1; + + x_index_base = flipx ? gfx->width()-1 : 0; + y_index = flipy ? gfx->height()-1 : 0; + + // start coordinates + sx = offsx; + sy = offsy; + + // end coordinates + ex = sx + gfx->width(); + ey = sy + gfx->height(); + + if (sx < clip.min_x) + { // clip left + int pixels = clip.min_x-sx; + sx += pixels; + x_index_base += xinc*pixels; + } + if (sy < clip.min_y) + { // clip top + int pixels = clip.min_y-sy; + sy += pixels; + y_index += yinc*pixels; + } + // NS 980211 - fixed incorrect clipping + if (ex > clip.max_x+1) + { // clip right + ex = clip.max_x+1; + } + if (ey > clip.max_y+1) + { // clip bottom + ey = clip.max_y+1; + } - // taken from case 7: TRANSPARENCY_ALPHARANGE - for (y = sy; y < ey; y++) + if (ex > sx) + { // skip if inner loop doesn't draw anything + int x, y; + + // taken from case 7: TRANSPARENCY_ALPHARANGE + for (y = sy; y < ey; y++) + { + const UINT8 *source = source_base + y_index*gfx->rowbytes(); + typename _BitmapClass::pixel_t *dest = &dest_bmp.pix(y); + int x_index = x_index_base; + for (x = sx; x < ex; x++) { - const UINT8 *source = source_base + y_index*gfx->rowbytes(); - typename _BitmapClass::pixel_t *dest = &dest_bmp.pix(y); - int x_index = x_index_base; - for (x = sx; x < ex; x++) + int c = source[x_index]; + if (c != transparent_color) { - int c = source[x_index]; - if (c != transparent_color) + if (alpha[c] & 8) + { + // Comp with clamp + dest[x] = jaleco_blend_device::func(dest[x], pal[c], alpha[c]); + } + else { - if (alpha[c] & 8) - { - // Comp with clamp - dest[x] = jal_blend_func(dest[x], pal[c], alpha[c]); - } - else - { - // Skip the costly alpha step altogether - dest[x] = pal[c]; - } + // Skip the costly alpha step altogether + dest[x] = pal[c]; } - x_index += xinc; } - y_index += yinc; + x_index += xinc; } + y_index += yinc; } } } -void jal_blend_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 code,UINT32 color,int flipx,int flipy,int offsx,int offsy, int transparent_color) -{ jal_blend_drawgfx_common(palette,dest_bmp, clip, gfx, code, color, flipx, flipy, offsx, offsy, transparent_color); } -void jal_blend_drawgfx(palette_device &palette,bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, +{ 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, UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy, int transparent_color) -{ jal_blend_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); } |