static void psychic5_change_bg_palette(running_machine *machine, int color, int lo_offs, int hi_offs) { psychic5_state *state = machine->driver_data<psychic5_state>(); UINT8 r,g,b,lo,hi,ir,ig,ib,ix; rgb_t irgb; /* red,green,blue intensities */ ir = pal4bit(state->palette_intensity >> 12); ig = pal4bit(state->palette_intensity >> 8); ib = pal4bit(state->palette_intensity >> 4); ix = state->palette_intensity & 0x0f; irgb = MAKE_RGB(ir,ig,ib); lo = state->ps5_palette_ram[lo_offs]; hi = state->ps5_palette_ram[hi_offs]; /* red,green,blue component */ r = pal4bit(lo >> 4); g = pal4bit(lo); b = pal4bit(hi >> 4); /* Grey background enable */ if (state->bg_status & 2) { UINT8 val = (r + g + b) / 3; /* Grey */ /* Just leave plain grey */ palette_set_color(machine,color,jal_blend_func(MAKE_RGB(val,val,val),irgb,ix)); } else { /* Seems fishy, but the title screen would be black otherwise... */ if (!(state->title_screen & 1)) { /* Leave the world as-is */ palette_set_color(machine,color,jal_blend_func(MAKE_RGB(r,g,b),irgb,ix)); } } }
static void jal_blend_drawgfx( mame_bitmap *dest_bmp,const gfx_element *gfx, unsigned int code,unsigned int color,int flipx,int flipy,int offsx,int offsy, const rectangle *clip,int transparency,int transparent_color) { /* drawgfx(dest_bmp, gfx, code, color, flipx, flipy, offsx, offsy, clip, TRANSPARENCY_PEN, 15); */ int xstart, ystart, xend, yend, xinc, yinc; int xtile, ytile ; int code_offset = 0; int wide = 1 ; int high = 1 ; if (flipx) { xstart = wide-1; xend = -1; xinc = -1; } else { xstart = 0; xend = wide; xinc = +1; } if (flipy) { ystart = high-1; yend = -1; yinc = -1; } else { ystart = 0; yend = high; yinc = +1; } /* Start drawing */ if( gfx && gfx->colortable ) { for (ytile = ystart; ytile != yend; ytile += yinc ) { for (xtile = xstart; xtile != xend; xtile += xinc ) { const pen_t *pal = &gfx->colortable[gfx->color_granularity * (color % gfx->total_colors)]; /* ASG 980209 */ const UINT8 *alpha = &jal_blend_table[gfx->color_granularity * (color % gfx->total_colors)]; /* ASG 980209 */ int source_base = ((code + code_offset++) % gfx->total_elements) * gfx->height; int x_index_base, y_index, sx, sy, ex, ey; if (flipx) { x_index_base = gfx->width-1; } else { x_index_base = 0; } if (flipy) { y_index = gfx->height-1; } else { y_index = 0; } /* start coordinates */ sx = offsx + xtile*gfx->width; sy = offsy + ytile*gfx->height; /* end coordinates */ ex = sx + gfx->width; ey = sy + gfx->height; if( clip ) { 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 */ int pixels = ex-clip->max_x-1; ex -= pixels; } if( ey > clip->max_y+1 ) { /* clip bottom */ int pixels = ey-clip->max_y-1; ey -= pixels; } } if( ex>sx ) { /* skip if inner loop doesn't draw anything */ int y; /* taken from case 7: TRANSPARENCY_ALPHARANGE */ UINT8 *source = gfx->gfxdata + (source_base + y_index)*gfx->line_modulo + x_index_base; UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx; int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx); int dst_modulo = dest_bmp->rowpixels - (ex-sx); for( y=sy; y<ey; y++ ) { int x; for( x=sx; x<ex; x++ ) { int c = *source; if( c != transparent_color ) { if( alpha[c] == 0x00 ) { /* Skip the costly alpha step altogether */ *dest = pal[c]; } else { /* Comp with clamp */ *dest = jal_blend_func(*dest, pal[c], alpha[c]) ; } } dest++; source += xinc; } dest += dst_modulo; source += src_modulo; } } } } } }
void jal_blend_drawgfx(bitmap_t *dest_bmp,const rectangle *clip,const gfx_element *gfx, UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy, int transparent_color) { if (jal_blend_table == NULL) { drawgfx_transpen(dest_bmp,clip,gfx,code,color,flipx,flipy,offsx,offsy,transparent_color); return; } /* Start drawing */ if (gfx) { const pen_t *pal = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)]; const UINT8 *alpha = &jal_blend_table[gfx->color_granularity * (color % gfx->total_colors)]; const UINT8 *source_base = gfx_element_get_data(gfx, code % gfx->total_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 (clip) { 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; /* 32-bit destination bitmap */ if (dest_bmp->bpp == 32) { /* taken from case 7: TRANSPARENCY_ALPHARANGE */ for (y = sy; y < ey; y++) { const UINT8 *source = source_base + y_index*gfx->line_modulo; UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0); int x_index = x_index_base; for (x = sx; x < ex; x++) { int c = source[x_index]; if (c != transparent_color) { 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]; } } x_index += xinc; } y_index += yinc; } } /* 16-bit destination bitmap */ else { /* taken from case 7: TRANSPARENCY_ALPHARANGE */ for (y = sy; y < ey; y++) { const UINT8 *source = source_base + y_index*gfx->line_modulo; UINT16 *dest = BITMAP_ADDR16(dest_bmp, y, 0); int x_index = x_index_base; for (x = sx; x < ex; x++) { int c = source[x_index]; if (c != transparent_color) { 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]; } } x_index += xinc; } y_index += yinc; } } } } }