diff --git a/src/emu/crsshair.c b/src/emu/crsshair.c index c14f06a3076..57497b8aa95 100644 --- a/src/emu/crsshair.c +++ b/src/emu/crsshair.c @@ -170,7 +170,7 @@ static void create_bitmap(int player) /* create a texture to reference the bitmap */ global.texture[player] = render_texture_alloc(render_texture_hq_scale, NULL); - render_texture_set_bitmap(global.texture[player], global.bitmap[player], NULL, 0, TEXFORMAT_ARGB32); + render_texture_set_bitmap(global.texture[player], global.bitmap[player], NULL, TEXFORMAT_ARGB32, NULL); } } diff --git a/src/emu/emupal.h b/src/emu/emupal.h index 30f7d670ef3..9e00c7c8a2f 100644 --- a/src/emu/emupal.h +++ b/src/emu/emupal.h @@ -225,11 +225,11 @@ INLINE rgb_t palette_get_color(running_machine *machine, pen_t pen) /*------------------------------------------------- - palette_set_brightness - set the per-pen - brightness factor + palette_set_pen_contrast - set the per-pen + contrast factor -------------------------------------------------*/ -INLINE void palette_set_brightness(running_machine *machine, pen_t pen, double bright) +INLINE void palette_set_pen_contrast(running_machine *machine, pen_t pen, double bright) { palette_entry_set_contrast(machine->palette, pen, bright); } diff --git a/src/emu/machine/ldcore.c b/src/emu/machine/ldcore.c index c112813968a..e748b7c4709 100644 --- a/src/emu/machine/ldcore.c +++ b/src/emu/machine/ldcore.c @@ -1369,15 +1369,15 @@ VIDEO_UPDATE( laserdisc ) if (overbitmap != NULL) { if (overbitmap->format == BITMAP_FORMAT_INDEXED16) - render_texture_set_bitmap(ldcore->overtex, overbitmap, &ldcore->config.overclip, 0, TEXFORMAT_PALETTEA16); + render_texture_set_bitmap(ldcore->overtex, overbitmap, &ldcore->config.overclip, TEXFORMAT_PALETTEA16, laserdisc->machine->palette); else if (overbitmap->format == BITMAP_FORMAT_RGB32) - render_texture_set_bitmap(ldcore->overtex, overbitmap, &ldcore->config.overclip, 0, TEXFORMAT_ARGB32); + render_texture_set_bitmap(ldcore->overtex, overbitmap, &ldcore->config.overclip, TEXFORMAT_ARGB32, NULL); } /* get the laserdisc video */ laserdisc_get_video(laserdisc, &vidbitmap); if (vidbitmap != NULL) - render_texture_set_bitmap(ldcore->videotex, vidbitmap, NULL, 0, TEXFORMAT_YUY16); + render_texture_set_bitmap(ldcore->videotex, vidbitmap, NULL, TEXFORMAT_YUY16, NULL); /* reset the screen contents */ render_container_empty(render_container_get_screen(screen)); diff --git a/src/emu/render.c b/src/emu/render.c index 9ab319a7344..911ffea4524 100644 --- a/src/emu/render.c +++ b/src/emu/render.c @@ -44,7 +44,6 @@ #include "config.h" #include "output.h" #include "xmlfile.h" -#include "deprecat.h" @@ -55,7 +54,7 @@ #define MAX_TEXTURE_SCALES 8 #define TEXTURE_GROUP_SIZE 256 -#define NUM_PRIMLISTS 2 +#define NUM_PRIMLISTS 3 #define MAX_CLEAR_EXTENTS 1000 @@ -133,12 +132,14 @@ struct _render_texture render_texture * base; /* pointer to base of texture group */ bitmap_t * bitmap; /* pointer to the original bitmap */ rectangle sbounds; /* source bounds within the bitmap */ - UINT32 palettebase; /* palette base within the system palette */ + palette_t * palette; /* palette associated with the texture */ int format; /* format of the texture data */ texture_scaler_func scaler; /* scaling callback */ void * param; /* scaling callback parameter */ UINT32 curseq; /* current sequence number */ scaled_texture scaled[MAX_TEXTURE_SCALES]; /* array of scaled variants of this texture */ + rgb_t * bcglookup; /* dynamically allocated B/C/G lookup table */ + UINT32 bcglookup_entries; /* number of B/C/G lookup entries allocated */ }; @@ -146,6 +147,7 @@ struct _render_texture struct _render_target { render_target * next; /* keep a linked list of targets */ + running_machine * machine; /* pointer to the machine we are connected with */ layout_view * curview; /* current view */ layout_file * filelist; /* list of layout files */ UINT32 flags; /* creation flags */ @@ -213,9 +215,6 @@ struct _render_container static render_target *targetlist; static render_target *ui_target; -/* notifier callbacks */ -static int (*rescale_notify)(running_machine *, int, int); - /* free lists */ static render_primitive *render_primitive_free_list; static container_item *container_item_free_list; @@ -270,10 +269,11 @@ static void add_clear_and_optimize_primitive_list(render_target *target, render_ static void invalidate_all_render_ref(void *refptr); /* render textures */ -static int render_texture_get_scaled(render_texture *texture, UINT32 dwidth, UINT32 dheight, render_texinfo *texinfo, render_ref **reflist); +static int texture_get_scaled(render_texture *texture, UINT32 dwidth, UINT32 dheight, render_texinfo *texinfo, render_ref **reflist); +static const rgb_t *texture_get_adjusted_palette(render_texture *texture, render_container *container); /* render containers */ -static render_container *render_container_alloc(void); +static render_container *render_container_alloc(running_machine *machine); static void render_container_free(render_container *container); static container_item *render_container_item_add_generic(render_container *container, UINT8 type, float x0, float y0, float x1, float y1, rgb_t argb); static void render_container_overlay_scale(bitmap_t *dest, const bitmap_t *source, const rectangle *sbounds, void *param); @@ -557,12 +557,12 @@ void render_init(running_machine *machine) ui_target = NULL; /* create a UI container */ - ui_container = render_container_alloc(); + ui_container = render_container_alloc(machine); /* create a container for each screen and determine its orientation */ for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen)) { - render_container *screen_container = render_container_alloc(); + render_container *screen_container = render_container_alloc(machine); render_container **temp = &screen_container->next; render_container_user_settings settings; @@ -946,18 +946,6 @@ static void render_save(running_machine *machine, int config_type, xml_data_node } -/*------------------------------------------------- - render_set_rescale_notify - set a notifier - that we call before doing long scaling - operations --------------------------------------------------*/ - -void render_set_rescale_notify(running_machine *machine, int (*notifier)(running_machine *, int, int)) -{ - rescale_notify = notifier; -} - - /*------------------------------------------------- render_is_live_screen - return if the screen is 'live' @@ -1078,7 +1066,7 @@ float render_get_ui_aspect(void) target -------------------------------------------------*/ -render_target *render_target_alloc(const char *layoutfile, UINT32 flags) +render_target *render_target_alloc(running_machine *machine, const char *layoutfile, UINT32 flags) { render_target *target; render_target **nextptr; @@ -1093,6 +1081,7 @@ render_target *render_target_alloc(const char *layoutfile, UINT32 flags) *nextptr = target; /* fill in the basics with reasonable defaults */ + target->machine = machine; target->flags = flags; target->width = 640; target->height = 480; @@ -1112,12 +1101,12 @@ render_target *render_target_alloc(const char *layoutfile, UINT32 flags) /* determine the base orientation based on options */ target->orientation = ROT0; if (!options_get_bool(mame_options(), OPTION_ROTATE)) - target->base_orientation = orientation_reverse(Machine->gamedrv->flags & ORIENTATION_MASK); + target->base_orientation = orientation_reverse(machine->gamedrv->flags & ORIENTATION_MASK); /* rotate left/right */ - if (options_get_bool(mame_options(), OPTION_ROR) || (options_get_bool(mame_options(), OPTION_AUTOROR) && (Machine->gamedrv->flags & ORIENTATION_SWAP_XY))) + if (options_get_bool(mame_options(), OPTION_ROR) || (options_get_bool(mame_options(), OPTION_AUTOROR) && (machine->gamedrv->flags & ORIENTATION_SWAP_XY))) target->base_orientation = orientation_add(ROT90, target->base_orientation); - if (options_get_bool(mame_options(), OPTION_ROL) || (options_get_bool(mame_options(), OPTION_AUTOROL) && (Machine->gamedrv->flags & ORIENTATION_SWAP_XY))) + if (options_get_bool(mame_options(), OPTION_ROL) || (options_get_bool(mame_options(), OPTION_AUTOROL) && (machine->gamedrv->flags & ORIENTATION_SWAP_XY))) target->base_orientation = orientation_add(ROT270, target->base_orientation); /* flip X/Y */ @@ -1131,7 +1120,7 @@ render_target *render_target_alloc(const char *layoutfile, UINT32 flags) target->layerconfig = target->base_layerconfig; /* allocate a lock for the primitive list */ - for (listnum = 0; listnum < NUM_PRIMLISTS; listnum++) + for (listnum = 0; listnum < ARRAY_LENGTH(target->primlist); listnum++) target->primlist[listnum].lock = osd_lock_alloc(); /* load the layout files */ @@ -1166,7 +1155,7 @@ void render_target_free(render_target *target) *curr = target->next; /* free any primitives */ - for (listnum = 0; listnum < NUM_PRIMLISTS; listnum++) + for (listnum = 0; listnum < ARRAY_LENGTH(target->primlist); listnum++) { release_render_list(&target->primlist[listnum]); osd_lock_free(target->primlist[listnum].lock); @@ -1478,7 +1467,7 @@ void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT3 for (item = target->curview->itemlist[layer]; item != NULL; item = item->next) if (item->element == NULL) { - const device_config *screen = device_list_find_by_index(Machine->config->devicelist, VIDEO_SCREEN, item->index); + const device_config *screen = device_list_find_by_index(target->machine->config->devicelist, VIDEO_SCREEN, item->index); const screen_config *scrconfig = screen->inline_config; const rectangle vectorvis = { 0, 639, 0, 479 }; const rectangle *visarea = NULL; @@ -1486,7 +1475,7 @@ void render_target_get_minimum_size(render_target *target, INT32 *minwidth, INT3 render_bounds bounds; float xscale, yscale; - /* we may be called very early, before Machine->visible_area is initialized; handle that case */ + /* we may be called very early, before machine->visible_area is initialized; handle that case */ if (scrconfig->type == SCREEN_TYPE_VECTOR) visarea = &vectorvis; else if (screen->token != NULL) @@ -1551,7 +1540,7 @@ const render_primitive_list *render_target_get_primitives(render_target *target) /* switch to the next primitive list */ listnum = target->listindex; - target->listindex = (target->listindex + 1) % NUM_PRIMLISTS; + target->listindex = (target->listindex + 1) % ARRAY_LENGTH(target->primlist); osd_lock_acquire(target->primlist[listnum].lock); /* free any previous primitives */ @@ -1569,7 +1558,7 @@ const render_primitive_list *render_target_get_primitives(render_target *target) root_xform.orientation = target->orientation; /* iterate over layers back-to-front, but only if we're running */ - if (mame_get_phase(Machine) >= MAME_PHASE_RESET) + if (mame_get_phase(target->machine) >= MAME_PHASE_RESET) for (layernum = 0; layernum < ITEM_LAYER_MAX; layernum++) { int blendmode; @@ -1610,9 +1599,9 @@ const render_primitive_list *render_target_get_primitives(render_target *target) state = output_get_value(item->output_name); else if (item->input_tag[0] != 0) { - const input_field_config *field = input_field_by_tag_and_mask(Machine->portconfig, item->input_tag, item->input_mask); + const input_field_config *field = input_field_by_tag_and_mask(target->machine->portconfig, item->input_tag, item->input_mask); if (field != NULL) - state = ((input_port_read_safe(Machine, item->input_tag, 0) ^ field->defvalue) & item->input_mask) ? 1 : 0; + state = ((input_port_read_safe(target->machine, item->input_tag, 0) ^ field->defvalue) & item->input_mask) ? 1 : 0; } add_element_primitives(target, &target->primlist[listnum], &item_xform, item->element, state, blendmode); } @@ -1796,7 +1785,7 @@ static int load_layout_files(render_target *target, const char *layoutfile, int /* if there's an explicit file, load that first */ if (layoutfile != NULL) { - *nextfile = layout_file_load(Machine->basename, layoutfile); + *nextfile = layout_file_load(target->machine->basename, layoutfile); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } @@ -1806,28 +1795,28 @@ static int load_layout_files(render_target *target, const char *layoutfile, int return (nextfile == &target->filelist) ? 1 : 0; /* try to load a file based on the driver name */ - *nextfile = layout_file_load(Machine->basename, Machine->gamedrv->name); + *nextfile = layout_file_load(target->machine->basename, target->machine->gamedrv->name); if (*nextfile == NULL) - *nextfile = layout_file_load(Machine->basename, "default"); + *nextfile = layout_file_load(target->machine->basename, "default"); if (*nextfile != NULL) nextfile = &(*nextfile)->next; /* if a default view has been specified, use that as a fallback */ - if (Machine->gamedrv->default_layout != NULL) + if (target->machine->gamedrv->default_layout != NULL) { - *nextfile = layout_file_load(NULL, Machine->gamedrv->default_layout); + *nextfile = layout_file_load(NULL, target->machine->gamedrv->default_layout); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } - if (Machine->config->default_layout != NULL) + if (target->machine->config->default_layout != NULL) { - *nextfile = layout_file_load(NULL, Machine->config->default_layout); + *nextfile = layout_file_load(NULL, target->machine->config->default_layout); if (*nextfile != NULL) nextfile = &(*nextfile)->next; } /* try to load another file based on the parent driver name */ - cloneof = driver_get_clone(Machine->gamedrv); + cloneof = driver_get_clone(target->machine->gamedrv); if (cloneof != NULL) { *nextfile = layout_file_load(cloneof->name, cloneof->name); @@ -1838,9 +1827,9 @@ static int load_layout_files(render_target *target, const char *layoutfile, int } /* now do the built-in layouts for single-screen games */ - if (video_screen_count(Machine->config) == 1) + if (video_screen_count(target->machine->config) == 1) { - if (Machine->gamedrv->flags & ORIENTATION_SWAP_XY) + if (target->machine->gamedrv->flags & ORIENTATION_SWAP_XY) *nextfile = layout_file_load(NULL, layout_vertical); else *nextfile = layout_file_load(NULL, layout_horizont); @@ -1992,19 +1981,10 @@ static void add_container_primitives(render_target *target, render_primitive_lis height = (finalorient & ORIENTATION_SWAP_XY) ? (prim->bounds.x1 - prim->bounds.x0) : (prim->bounds.y1 - prim->bounds.y0); width = MIN(width, target->maxtexwidth); height = MIN(height, target->maxtexheight); - if (render_texture_get_scaled(item->texture, width, height, &prim->texture, &list->reflist)) + if (texture_get_scaled(item->texture, width, height, &prim->texture, &list->reflist)) { - /* override the palette with our adjusted palette */ - switch (item->texture->format) - { - case TEXFORMAT_PALETTE16: prim->texture.palette = &container->bcglookup[prim->texture.palette - palette_entry_list_adjusted(Machine->palette)]; break; - case TEXFORMAT_PALETTEA16: prim->texture.palette = &container->bcglookup[prim->texture.palette - palette_entry_list_adjusted(Machine->palette)]; break; - case TEXFORMAT_RGB15: prim->texture.palette = &container->bcglookup32[0]; break; - case TEXFORMAT_RGB32: prim->texture.palette = &container->bcglookup256[0]; break; - case TEXFORMAT_ARGB32: prim->texture.palette = &container->bcglookup256[0]; break; - case TEXFORMAT_YUY16: prim->texture.palette = &container->bcglookup256[0]; break; - default: assert(FALSE); - } + /* set the palette */ + prim->texture.palette = texture_get_adjusted_palette(item->texture, container); /* determine UV coordinates and apply clipping */ prim->texcoords = oriented_texcoords[finalorient]; @@ -2055,7 +2035,7 @@ static void add_container_primitives(render_target *target, render_primitive_lis prim->color = container_xform.color; width = render_round_nearest(prim->bounds.x1) - render_round_nearest(prim->bounds.x0); height = render_round_nearest(prim->bounds.y1) - render_round_nearest(prim->bounds.y0); - if (render_texture_get_scaled(container->overlaytexture, + if (texture_get_scaled(container->overlaytexture, (container_xform.orientation & ORIENTATION_SWAP_XY) ? height : width, (container_xform.orientation & ORIENTATION_SWAP_XY) ? width : height, &prim->texture, &list->reflist)) { @@ -2111,7 +2091,7 @@ static void add_element_primitives(render_target *target, render_primitive_list height = MIN(height, target->maxtexheight); /* get the scaled texture and append it */ - if (render_texture_get_scaled(texture, width, height, &prim->texture, &list->reflist)) + if (texture_get_scaled(texture, width, height, &prim->texture, &list->reflist)) { /* compute the clip rect */ cliprect.x0 = render_round_nearest(xform->xoffs); @@ -2419,7 +2399,7 @@ static void invalidate_all_render_ref(void *refptr) /* loop over targets */ for (target = targetlist; target != NULL; target = target->next) - for (listnum = 0; listnum < NUM_PRIMLISTS; listnum++) + for (listnum = 0; listnum < ARRAY_LENGTH(target->primlist); listnum++) { render_primitive_list *list = &target->primlist[listnum]; osd_lock_acquire(list->lock); @@ -2495,6 +2475,14 @@ void render_texture_free(render_texture *texture) if (texture->bitmap != NULL) invalidate_all_render_ref(texture->bitmap); + /* release palette references */ + if (texture->palette != NULL) + palette_deref(texture->palette); + + /* free any B/C/G lookup tables */ + if (texture->bcglookup != NULL) + free(texture->bcglookup); + /* add ourself back to the free list */ base_save = texture->base; memset(texture, 0, sizeof(*texture)); @@ -2509,13 +2497,26 @@ void render_texture_free(render_texture *texture) bitmap -------------------------------------------------*/ -void render_texture_set_bitmap(render_texture *texture, bitmap_t *bitmap, const rectangle *sbounds, UINT32 palettebase, int format) +void render_texture_set_bitmap(render_texture *texture, bitmap_t *bitmap, const rectangle *sbounds, int format, palette_t *palette) { int scalenum; + + /* ensure we have a valid palette for palettized modes */ + if (format == TEXFORMAT_PALETTE16 || format == TEXFORMAT_PALETTEA16) + assert(palette != NULL); /* invalidate references to the old bitmap */ if (bitmap != texture->bitmap && texture->bitmap != NULL) invalidate_all_render_ref(texture->bitmap); + + /* if the palette is different, adjust references */ + if (palette != texture->palette) + { + if (texture->palette != NULL) + palette_deref(texture->palette); + if (palette != NULL) + palette_ref(palette); + } /* set the new bitmap/palette */ texture->bitmap = bitmap; @@ -2523,7 +2524,7 @@ void render_texture_set_bitmap(render_texture *texture, bitmap_t *bitmap, const texture->sbounds.min_y = (sbounds != NULL) ? sbounds->min_y : 0; texture->sbounds.max_x = (sbounds != NULL) ? sbounds->max_x : (bitmap != NULL) ? bitmap->width : 1000; texture->sbounds.max_y = (sbounds != NULL) ? sbounds->max_y : (bitmap != NULL) ? bitmap->height : 1000; - texture->palettebase = palettebase; + texture->palette = palette; texture->format = format; /* invalidate all scaled versions */ @@ -2541,14 +2542,14 @@ void render_texture_set_bitmap(render_texture *texture, bitmap_t *bitmap, const /*------------------------------------------------- - render_texture_get_scaled - get a scaled + texture_get_scaled - get a scaled bitmap (if we can) -------------------------------------------------*/ -static int render_texture_get_scaled(render_texture *texture, UINT32 dwidth, UINT32 dheight, render_texinfo *texinfo, render_ref **reflist) +static int texture_get_scaled(render_texture *texture, UINT32 dwidth, UINT32 dheight, render_texinfo *texinfo, render_ref **reflist) { UINT8 bpp = (texture->format == TEXFORMAT_PALETTE16 || texture->format == TEXFORMAT_PALETTEA16 || texture->format == TEXFORMAT_RGB15 || texture->format == TEXFORMAT_YUY16) ? 16 : 32; - const rgb_t *palbase = (texture->format == TEXFORMAT_PALETTE16 || texture->format == TEXFORMAT_PALETTEA16) ? palette_entry_list_adjusted(Machine->palette) + texture->palettebase : NULL; + const rgb_t *palbase = (texture->format == TEXFORMAT_PALETTE16 || texture->format == TEXFORMAT_PALETTEA16) ? palette_entry_list_adjusted(texture->palette) : NULL; scaled_texture *scaled = NULL; int swidth, sheight; int scalenum; @@ -2590,10 +2591,6 @@ static int render_texture_get_scaled(render_texture *texture, UINT32 dwidth, UIN { int lowest = -1; - /* ask our notifier if we can scale now */ - if (rescale_notify != NULL && !(*rescale_notify)(Machine, dwidth, dheight)) - return FALSE; - /* didn't find one -- take the entry with the lowest seqnum */ for (scalenum = 0; scalenum < ARRAY_LENGTH(texture->scaled); scalenum++) if ((lowest == -1 || texture->scaled[scalenum].seqid < texture->scaled[lowest].seqid) && !has_render_ref(*reflist, texture->scaled[scalenum].bitmap)) @@ -2640,6 +2637,119 @@ void render_texture_hq_scale(bitmap_t *dest, const bitmap_t *source, const recta } +/*------------------------------------------------- + texture_get_adjusted_palette - return the + adjusted palette for a texture +-------------------------------------------------*/ + +static const rgb_t *texture_get_adjusted_palette(render_texture *texture, render_container *container) +{ + const rgb_t *adjusted; + int numentries; + int index; + + /* override the palette with our adjusted palette */ + switch (texture->format) + { + case TEXFORMAT_PALETTE16: + case TEXFORMAT_PALETTEA16: + + /* if no adjustment necessary, return the raw palette */ + assert(texture->palette != NULL); + adjusted = palette_entry_list_adjusted(texture->palette); + if (container->brightness == 1.0f && container->contrast == 1.0f && container->gamma == 1.0f) + return adjusted; + + /* if this is the machine palette, return our precomputed adjusted palette */ + if (container->palclient != NULL && palette_client_get_palette(container->palclient) == texture->palette) + return container->bcglookup; + + /* otherwise, ensure we have memory allocated and compute the adjusted result ourself */ + numentries = palette_get_num_colors(texture->palette) * palette_get_num_groups(texture->palette); + if (texture->bcglookup == NULL || texture->bcglookup_entries < numentries) + { + texture->bcglookup = realloc(texture->bcglookup, numentries * sizeof(*texture->bcglookup)); + texture->bcglookup_entries = numentries; + } + for (index = 0; index < numentries; index++) + { + UINT8 r = apply_brightness_contrast_gamma(RGB_RED(adjusted[index]), container->brightness, container->contrast, container->gamma); + UINT8 g = apply_brightness_contrast_gamma(RGB_GREEN(adjusted[index]), container->brightness, container->contrast, container->gamma); + UINT8 b = apply_brightness_contrast_gamma(RGB_BLUE(adjusted[index]), container->brightness, container->contrast, container->gamma); + texture->bcglookup[index] = MAKE_ARGB(RGB_ALPHA(adjusted[index]), r, g, b); + } + return texture->bcglookup; + + case TEXFORMAT_RGB15: + + /* if no adjustment necessary, return NULL */ + if (container->brightness == 1.0f && container->contrast == 1.0f && container->gamma == 1.0f && texture->palette == NULL) + return NULL; + + /* if no palette, return the standard lookups */ + if (texture->palette == NULL) + return container->bcglookup32; + + /* otherwise, ensure we have memory allocated and compute the adjusted result ourself */ + assert(palette_get_num_colors(texture->palette) == 32); + adjusted = palette_entry_list_adjusted(texture->palette); + if (texture->bcglookup == NULL || texture->bcglookup_entries < 4 * 32) + { + texture->bcglookup = realloc(texture->bcglookup, 4 * 32 * sizeof(*texture->bcglookup)); + texture->bcglookup_entries = 4 * 32; + } + + /* otherwise, return the 32-entry BCG lookups */ + for (index = 0; index < 32; index++) + { + UINT8 val = apply_brightness_contrast_gamma(RGB_GREEN(adjusted[index]), container->brightness, container->contrast, container->gamma); + texture->bcglookup[0x00 + index] = val << 0; + texture->bcglookup[0x20 + index] = val << 8; + texture->bcglookup[0x40 + index] = val << 16; + texture->bcglookup[0x60 + index] = val << 24; + } + return texture->bcglookup; + + case TEXFORMAT_RGB32: + case TEXFORMAT_ARGB32: + case TEXFORMAT_YUY16: + + /* if no adjustment necessary, return NULL */ + if (container->brightness == 1.0f && container->contrast == 1.0f && container->gamma == 1.0f && texture->palette == NULL) + return NULL; + + /* if no palette, return the standard lookups */ + if (texture->palette == NULL) + return container->bcglookup256; + + /* otherwise, ensure we have memory allocated and compute the adjusted result ourself */ + assert(palette_get_num_colors(texture->palette) == 256); + adjusted = palette_entry_list_adjusted(texture->palette); + if (texture->bcglookup == NULL || texture->bcglookup_entries < 4 * 256) + { + texture->bcglookup = realloc(texture->bcglookup, 4 * 256 * sizeof(*texture->bcglookup)); + texture->bcglookup_entries = 4 * 256; + } + + /* otherwise, return the 32-entry BCG lookups */ + for (index = 0; index < 256; index++) + { + UINT8 val = apply_brightness_contrast_gamma(RGB_GREEN(adjusted[index]), container->brightness, container->contrast, container->gamma); + texture->bcglookup[0x000 + index] = val << 0; + texture->bcglookup[0x100 + index] = val << 8; + texture->bcglookup[0x200 + index] = val << 16; + texture->bcglookup[0x300 + index] = val << 24; + } + return texture->bcglookup; + + default: + assert(FALSE); + } + + return NULL; +} + + /*************************************************************************** RENDER CONTAINERS @@ -2650,7 +2760,7 @@ void render_texture_hq_scale(bitmap_t *dest, const bitmap_t *source, const recta container -------------------------------------------------*/ -static render_container *render_container_alloc(void) +static render_container *render_container_alloc(running_machine *machine) { render_container *container; int color; @@ -2674,8 +2784,8 @@ static render_container *render_container_alloc(void) render_container_empty(container); /* allocate a client to the main palette */ - if (Machine->palette != NULL) - container->palclient = palette_client_alloc(Machine->palette); + if (machine->palette != NULL) + container->palclient = palette_client_alloc(machine->palette); render_container_recompute_lookups(container); return container; } @@ -2788,7 +2898,7 @@ void render_container_set_overlay(render_container *container, bitmap_t *bitmap) if (container->overlaybitmap != NULL) { container->overlaytexture = render_texture_alloc(render_container_overlay_scale, NULL); - render_texture_set_bitmap(container->overlaytexture, bitmap, NULL, 0, TEXFORMAT_ARGB32); + render_texture_set_bitmap(container->overlaytexture, bitmap, NULL, TEXFORMAT_ARGB32, NULL); } } diff --git a/src/emu/render.h b/src/emu/render.h index 1fee7b48b28..f8f61531f28 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -88,22 +88,22 @@ enum /* texture formats */ enum { - TEXFORMAT_UNDEFINED = 0, /* require a format to be specified */ - TEXFORMAT_PALETTE16, /* 16bpp palettized, alpha ignored */ - TEXFORMAT_PALETTEA16, /* 16bpp palettized, alpha respected */ - TEXFORMAT_RGB15, /* 16bpp 5-5-5 RGB */ - TEXFORMAT_RGB32, /* 32bpp 8-8-8 RGB */ - TEXFORMAT_ARGB32, /* 32bpp 8-8-8-8 ARGB */ - TEXFORMAT_YUY16 /* 16bpp 8-8 Y/Cb, Y/Cr in sequence */ + TEXFORMAT_UNDEFINED = 0, /* require a format to be specified */ + TEXFORMAT_PALETTE16, /* 16bpp palettized, alpha ignored */ + TEXFORMAT_PALETTEA16, /* 16bpp palettized, alpha respected */ + TEXFORMAT_RGB15, /* 16bpp 5-5-5 RGB */ + TEXFORMAT_RGB32, /* 32bpp 8-8-8 RGB */ + TEXFORMAT_ARGB32, /* 32bpp 8-8-8-8 ARGB */ + TEXFORMAT_YUY16 /* 16bpp 8-8 Y/Cb, Y/Cr in sequence */ }; /* blending modes */ enum { - BLENDMODE_NONE = 0, /* no blending */ - BLENDMODE_ALPHA, /* standard alpha blend */ - BLENDMODE_RGB_MULTIPLY, /* apply source alpha to source pix, then multiply RGB values */ - BLENDMODE_ADD /* apply source alpha to source pix, then add to destination */ + BLENDMODE_NONE = 0, /* no blending */ + BLENDMODE_ALPHA, /* standard alpha blend */ + BLENDMODE_RGB_MULTIPLY, /* apply source alpha to source pix, then multiply RGB values */ + BLENDMODE_ADD /* apply source alpha to source pix, then add to destination */ }; @@ -350,7 +350,7 @@ int render_input_hit_test(render_target *target, INT32 target_x, INT32 target_y, /* ----- render target management ----- */ /* allocate a new render target */ -render_target *render_target_alloc(const char *layout, UINT32 flags); +render_target *render_target_alloc(running_machine *machine, const char *layout, UINT32 flags); /* free memory for a render target */ void render_target_free(render_target *target); @@ -424,7 +424,7 @@ render_texture *render_texture_alloc(texture_scaler_func scaler, void *param); void render_texture_free(render_texture *texture); /* set a new source bitmap */ -void render_texture_set_bitmap(render_texture *texture, bitmap_t *bitmap, const rectangle *sbounds, UINT32 palettebase, int format); +void render_texture_set_bitmap(render_texture *texture, bitmap_t *bitmap, const rectangle *sbounds, int format, palette_t *palette); /* generic high quality resampling scaler */ void render_texture_hq_scale(bitmap_t *dest, const bitmap_t *source, const rectangle *sbounds, void *param); diff --git a/src/emu/rendfont.c b/src/emu/rendfont.c index c013f270395..9f52c9697a2 100644 --- a/src/emu/rendfont.c +++ b/src/emu/rendfont.c @@ -276,7 +276,7 @@ static void render_font_char_expand(render_font *font, render_font_char *ch) /* wrap a texture around the bitmap */ ch->texture = render_texture_alloc(render_texture_hq_scale, NULL); - render_texture_set_bitmap(ch->texture, ch->bitmap, NULL, 0, TEXFORMAT_ARGB32); + render_texture_set_bitmap(ch->texture, ch->bitmap, NULL, TEXFORMAT_ARGB32, NULL); } diff --git a/src/emu/ui.c b/src/emu/ui.c index ba289e82a64..329f2bfe501 100644 --- a/src/emu/ui.c +++ b/src/emu/ui.c @@ -94,9 +94,6 @@ static rgb_t messagebox_backcolor; static slider_state *slider_list; static slider_state *slider_current; -static int display_rescale_message; -static int allow_rescale; - /*************************************************************************** @@ -104,7 +101,6 @@ static int allow_rescale; ***************************************************************************/ static void ui_exit(running_machine *machine); -static int rescale_notifier(running_machine *machine, int width, int height); /* text generators */ static astring *disclaimer_string(running_machine *machine, astring *buffer); @@ -228,11 +224,6 @@ int ui_init(running_machine *machine) /* reset globals */ single_step = FALSE; ui_set_handler(handler_messagebox, 0); - - /* request callbacks when the renderer does resizing */ - render_set_rescale_notify(machine, rescale_notifier); - allow_rescale = 0; - display_rescale_message = FALSE; return 0; } @@ -255,26 +246,6 @@ static void ui_exit(running_machine *machine) } -/*------------------------------------------------- - rescale_notifier - notifier to trigger a - rescale message during long operations --------------------------------------------------*/ - -static int rescale_notifier(running_machine *machine, int width, int height) -{ - /* always allow rescaling for a "small" area and for screenless drivers */ - if (width < 500 || height < 500 || machine->primary_screen == NULL) - return TRUE; - - /* if we've currently disallowed rescaling, turn on a message next frame */ - if (allow_rescale == 0) - display_rescale_message = TRUE; - - /* only allow rescaling once we're sure the message is visible */ - return (allow_rescale == 1); -} - - /*------------------------------------------------- ui_display_startup_screens - display the various startup screens @@ -416,19 +387,6 @@ void ui_update_and_render(running_machine *machine) /* cancel takes us back to the ingame handler */ if (ui_handler_param == UI_HANDLER_CANCEL) ui_set_handler(handler_ingame, 0); - - /* add a message if we are rescaling */ - if (display_rescale_message) - { - display_rescale_message = FALSE; - if (allow_rescale == 0) - allow_rescale = 2; - ui_draw_text_box("Updating Artwork...", JUSTIFY_CENTER, 0.5f, 0.5f, messagebox_backcolor); - } - - /* decrement the frame counter if it is non-zero */ - else if (allow_rescale != 0) - allow_rescale--; } diff --git a/src/emu/uigfx.c b/src/emu/uigfx.c index 05ecc74cc8e..8b2ffeee3cf 100644 --- a/src/emu/uigfx.c +++ b/src/emu/uigfx.c @@ -702,7 +702,7 @@ static void gfxset_update_bitmap(running_machine *machine, ui_gfx_state *state, /* allocate new stuff */ state->bitmap = bitmap_alloc(cellxpix * xcells, cellypix * ycells, BITMAP_FORMAT_ARGB32); state->texture = render_texture_alloc(NULL, NULL); - render_texture_set_bitmap(state->texture, state->bitmap, NULL, 0, TEXFORMAT_ARGB32); + render_texture_set_bitmap(state->texture, state->bitmap, NULL, TEXFORMAT_ARGB32, NULL); /* force a redraw */ state->bitmap_dirty = TRUE; @@ -750,7 +750,7 @@ static void gfxset_update_bitmap(running_machine *machine, ui_gfx_state *state, } /* reset the texture to force an update */ - render_texture_set_bitmap(state->texture, state->bitmap, NULL, 0, TEXFORMAT_ARGB32); + render_texture_set_bitmap(state->texture, state->bitmap, NULL, TEXFORMAT_ARGB32, NULL); state->bitmap_dirty = FALSE; } } @@ -1034,15 +1034,16 @@ static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, i static void tilemap_update_bitmap(running_machine *machine, ui_gfx_state *state, int width, int height) { bitmap_format screen_format = video_screen_get_format(machine->primary_screen); + palette_t *palette = NULL; int screen_texformat; /* convert the screen format to a texture format */ switch (screen_format) { - case BITMAP_FORMAT_INDEXED16: screen_texformat = TEXFORMAT_PALETTE16; break; - case BITMAP_FORMAT_RGB15: screen_texformat = TEXFORMAT_RGB15; break; - case BITMAP_FORMAT_RGB32: screen_texformat = TEXFORMAT_RGB32; break; - default: fatalerror("Invalid bitmap format!"); break; + case BITMAP_FORMAT_INDEXED16: screen_texformat = TEXFORMAT_PALETTE16; palette = machine->palette; break; + case BITMAP_FORMAT_RGB15: screen_texformat = TEXFORMAT_RGB15; palette = NULL; break; + case BITMAP_FORMAT_RGB32: screen_texformat = TEXFORMAT_RGB32; palette = NULL; break; + default: fatalerror("Invalid bitmap format!"); break; } /* swap the coordinates back if they were talking about a rotated surface */ @@ -1061,7 +1062,7 @@ static void tilemap_update_bitmap(running_machine *machine, ui_gfx_state *state, /* allocate new stuff */ state->bitmap = bitmap_alloc(width, height, screen_format); state->texture = render_texture_alloc(NULL, NULL); - render_texture_set_bitmap(state->texture, state->bitmap, NULL, 0, screen_texformat); + render_texture_set_bitmap(state->texture, state->bitmap, NULL, screen_texformat, palette); /* force a redraw */ state->bitmap_dirty = TRUE; @@ -1073,7 +1074,7 @@ static void tilemap_update_bitmap(running_machine *machine, ui_gfx_state *state, tilemap_draw_by_index(state->bitmap, state->tilemap.which, state->tilemap.xoffs, state->tilemap.yoffs); /* reset the texture to force an update */ - render_texture_set_bitmap(state->texture, state->bitmap, NULL, 0, screen_texformat); + render_texture_set_bitmap(state->texture, state->bitmap, NULL, screen_texformat, palette); state->bitmap_dirty = FALSE; } } diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c index b85d4faee82..d1c00cf807a 100644 --- a/src/emu/uimenu.c +++ b/src/emu/uimenu.c @@ -384,7 +384,7 @@ void ui_menu_init(running_machine *machine) *BITMAP_ADDR32(hilight_bitmap, 0, x) = MAKE_ARGB(alpha,0xff,0xff,0xff); } hilight_texture = render_texture_alloc(NULL, NULL); - render_texture_set_bitmap(hilight_texture, hilight_bitmap, NULL, 0, TEXFORMAT_ARGB32); + render_texture_set_bitmap(hilight_texture, hilight_bitmap, NULL, TEXFORMAT_ARGB32, NULL); /* create a texture for arrow icons */ arrow_texture = render_texture_alloc(menu_render_triangle, NULL); diff --git a/src/emu/video.c b/src/emu/video.c index cb89df2c93a..60c8e1db1de 100644 --- a/src/emu/video.c +++ b/src/emu/video.c @@ -356,7 +356,7 @@ void video_init(running_machine *machine) /* the native target is hard-coded to our internal layout and has all options disabled */ if (global.snap_native) { - global.snap_target = render_target_alloc(layout_snap, RENDER_CREATE_SINGLE_FILE | RENDER_CREATE_HIDDEN); + global.snap_target = render_target_alloc(machine, layout_snap, RENDER_CREATE_SINGLE_FILE | RENDER_CREATE_HIDDEN); assert(global.snap_target != NULL); render_target_set_layer_config(global.snap_target, 0); } @@ -364,7 +364,7 @@ void video_init(running_machine *machine) /* other targets select the specified view and turn off effects */ else { - global.snap_target = render_target_alloc(NULL, RENDER_CREATE_HIDDEN); + global.snap_target = render_target_alloc(machine, NULL, RENDER_CREATE_HIDDEN); assert(global.snap_target != NULL); render_target_set_view(global.snap_target, video_get_view_for_target(machine, global.snap_target, viewname, 0, 1)); render_target_set_layer_config(global.snap_target, render_target_get_layer_config(global.snap_target) & ~LAYER_CONFIG_ENABLE_SCREEN_OVERLAY); @@ -722,6 +722,7 @@ static void realloc_screen_bitmaps(const device_config *screen) if (state->width > curwidth || state->height > curheight) { bitmap_format screen_format = config->format; + palette_t *palette; /* free what we have currently */ if (state->texture[0] != NULL) @@ -740,10 +741,10 @@ static void realloc_screen_bitmaps(const device_config *screen) /* choose the texture format - convert the screen format to a texture format */ switch (screen_format) { - case BITMAP_FORMAT_INDEXED16: state->texture_format = TEXFORMAT_PALETTE16; break; - case BITMAP_FORMAT_RGB15: state->texture_format = TEXFORMAT_RGB15; break; - case BITMAP_FORMAT_RGB32: state->texture_format = TEXFORMAT_RGB32; break; - default: fatalerror("Invalid bitmap format!"); break; + case BITMAP_FORMAT_INDEXED16: state->texture_format = TEXFORMAT_PALETTE16; palette = screen->machine->palette; break; + case BITMAP_FORMAT_RGB15: state->texture_format = TEXFORMAT_RGB15; palette = NULL; break; + case BITMAP_FORMAT_RGB32: state->texture_format = TEXFORMAT_RGB32; palette = NULL; break; + default: fatalerror("Invalid bitmap format!"); break; } /* allocate bitmaps */ @@ -754,9 +755,9 @@ static void realloc_screen_bitmaps(const device_config *screen) /* allocate textures */ state->texture[0] = render_texture_alloc(NULL, NULL); - render_texture_set_bitmap(state->texture[0], state->bitmap[0], &state->visarea, 0, state->texture_format); + render_texture_set_bitmap(state->texture[0], state->bitmap[0], &state->visarea, state->texture_format, palette); state->texture[1] = render_texture_alloc(NULL, NULL); - render_texture_set_bitmap(state->texture[1], state->bitmap[1], &state->visarea, 0, state->texture_format); + render_texture_set_bitmap(state->texture[1], state->bitmap[1], &state->visarea, state->texture_format, palette); } } } @@ -1572,9 +1573,11 @@ static int finish_screen_updates(running_machine *machine) { bitmap_t *bitmap = state->bitmap[state->curbitmap]; rectangle fixedvis = *video_screen_get_visible_area(screen); + palette_t *palette = (state->texture_format == TEXFORMAT_PALETTE16) ? machine->palette : NULL; + fixedvis.max_x++; fixedvis.max_y++; - render_texture_set_bitmap(state->texture[state->curbitmap], bitmap, &fixedvis, 0, state->texture_format); + render_texture_set_bitmap(state->texture[state->curbitmap], bitmap, &fixedvis, state->texture_format, palette); state->curtexture = state->curbitmap; state->curbitmap = 1 - state->curbitmap; } diff --git a/src/lib/util/palette.c b/src/lib/util/palette.c index eec488005bb..f68a868e3d8 100644 --- a/src/lib/util/palette.c +++ b/src/lib/util/palette.c @@ -10,6 +10,7 @@ ******************************************************************************/ #include "palette.h" +#include @@ -44,6 +45,11 @@ struct _palette_t UINT32 numcolors; /* number of colors in the palette */ UINT32 numgroups; /* number of groups in the palette */ + float brightness; /* overall brightness value */ + float contrast; /* overall contrast value */ + float gamma; /* overall gamma value */ + UINT8 gamma_map[256]; /* gamma map */ + rgb_t * entry_color; /* array of raw colors */ float * entry_contrast; /* contrast value for each entry */ rgb_t * adjusted_color; /* array of adjusted colors */ @@ -75,11 +81,11 @@ static void update_adjusted_color(palette_t *palette, UINT32 group, UINT32 index entry for brightness -------------------------------------------------*/ -INLINE rgb_t adjust_palette_entry(rgb_t entry, float brightness, float contrast) +INLINE rgb_t adjust_palette_entry(rgb_t entry, float brightness, float contrast, const UINT8 *gamma_map) { - int r = rgb_clamp((float)RGB_RED(entry) * contrast + brightness); - int g = rgb_clamp((float)RGB_GREEN(entry) * contrast + brightness); - int b = rgb_clamp((float)RGB_BLUE(entry) * contrast + brightness); + int r = rgb_clamp((float)gamma_map[RGB_RED(entry)] * contrast + brightness); + int g = rgb_clamp((float)gamma_map[RGB_GREEN(entry)] * contrast + brightness); + int b = rgb_clamp((float)gamma_map[RGB_BLUE(entry)] * contrast + brightness); int a = RGB_ALPHA(entry); return MAKE_ARGB(a,r,g,b); } @@ -105,6 +111,13 @@ palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups) if (palette == NULL) goto error; memset(palette, 0, sizeof(*palette)); + + /* initialize overall controls */ + palette->brightness = 0.0f; + palette->contrast = 1.0f; + palette->gamma = 1.0f; + for (index = 0; index < 256; index++) + palette->gamma_map[index] = index; /* allocate an array of palette entries and individual contrasts for each */ palette->entry_color = malloc(sizeof(*palette->entry_color) * numcolors); @@ -461,6 +474,81 @@ const rgb_t *palette_entry_list_adjusted_rgb15(palette_t *palette) PALETTE ADJUSTMENTS ***************************************************************************/ +/*------------------------------------------------- + palette_set_brightness - set the overall + brightness for the palette +-------------------------------------------------*/ + +void palette_set_brightness(palette_t *palette, float brightness) +{ + int groupnum, index; + + /* convert incoming value to normalized result */ + brightness = (brightness - 1.0f) * 256.0f; + + /* set the global brightness if changed */ + if (palette->brightness == brightness) + return; + palette->brightness = brightness; + + /* update across all indices in all groups */ + for (groupnum = 0; groupnum < palette->numgroups; groupnum++) + for (index = 0; index < palette->numcolors; index++) + update_adjusted_color(palette, groupnum, index); +} + + +/*------------------------------------------------- + palette_set_contrast - set the overall + contrast for the palette +-------------------------------------------------*/ + +void palette_set_contrast(palette_t *palette, float contrast) +{ + int groupnum, index; + + /* set the global contrast if changed */ + if (palette->contrast == contrast) + return; + palette->contrast = contrast; + + /* update across all indices in all groups */ + for (groupnum = 0; groupnum < palette->numgroups; groupnum++) + for (index = 0; index < palette->numcolors; index++) + update_adjusted_color(palette, groupnum, index); +} + + +/*------------------------------------------------- + palette_set_gamma - set the overall + gamma for the palette +-------------------------------------------------*/ + +void palette_set_gamma(palette_t *palette, float gamma) +{ + int groupnum, index; + + /* set the global gamma if changed */ + if (palette->gamma == gamma) + return; + palette->gamma = gamma; + + /* recompute the gamma map */ + gamma = 1.0f / gamma; + for (index = 0; index < 256; index++) + { + float fval = (float)index * (1.0f / 255.0f); + float fresult = pow(fval, gamma); + palette->gamma_map[index] = rgb_clamp(255.0f * fresult); + } + + /* update across all indices in all groups */ + for (groupnum = 0; groupnum < palette->numgroups; groupnum++) + for (index = 0; index < palette->numcolors; index++) + update_adjusted_color(palette, groupnum, index); +} + + /*------------------------------------------------- palette_entry_set_contrast - set the contrast adjustment for a single palette index @@ -502,6 +590,9 @@ float palette_entry_get_contrast(palette_t *palette, UINT32 index) void palette_group_set_brightness(palette_t *palette, UINT32 group, float brightness) { int index; + + /* convert incoming value to normalized result */ + brightness = (brightness - 1.0f) * 256.0f; /* if out of range, or unchanged, ignore */ if (group >= palette->numgroups || palette->group_bright[group] == brightness) @@ -632,7 +723,10 @@ static void update_adjusted_color(palette_t *palette, UINT32 group, UINT32 index rgb_t adjusted; /* compute the adjusted value */ - adjusted = adjust_palette_entry(palette->entry_color[index], palette->group_bright[group], palette->group_contrast[group] * palette->entry_contrast[index]); + adjusted = adjust_palette_entry(palette->entry_color[index], + palette->group_bright[group] * palette->brightness, + palette->group_contrast[group] * palette->entry_contrast[index] * palette->contrast, + palette->gamma_map); /* if not different, ignore */ if (palette->adjusted_color[finalindex] == adjusted) diff --git a/src/lib/util/palette.h b/src/lib/util/palette.h index afd3b4eca1a..6b3e3a546f4 100644 --- a/src/lib/util/palette.h +++ b/src/lib/util/palette.h @@ -129,6 +129,15 @@ const rgb_t *palette_entry_list_adjusted_rgb15(palette_t *palette); /* ----- palette adjustments ----- */ +/* set the overall brightness for the palette */ +void palette_set_brightness(palette_t *palette, float brightness); + +/* set the overall contrast for the palette */ +void palette_set_contrast(palette_t *palette, float contrast); + +/* set the overall gamma for the palette */ +void palette_set_gamma(palette_t *palette, float gamma); + /* set the contrast adjustment for a single palette index */ void palette_entry_set_contrast(palette_t *palette, UINT32 index, float contrast); diff --git a/src/mame/drivers/chqflag.c b/src/mame/drivers/chqflag.c index f0ae2dc6a94..a1a017eb1dc 100644 --- a/src/mame/drivers/chqflag.c +++ b/src/mame/drivers/chqflag.c @@ -105,7 +105,7 @@ static WRITE8_HANDLER( chqflag_vreg_w ) /* only affect the background */ for (i = 512;i < 1024;i++) - palette_set_brightness(machine,i,brt); + palette_set_pen_contrast(machine,i,brt); } //if ((data & 0xf8) && (data & 0xf8) != 0x88) diff --git a/src/mame/drivers/mwarr.c b/src/mame/drivers/mwarr.c index 67bd4cb573c..bd884e5fa88 100644 --- a/src/mame/drivers/mwarr.c +++ b/src/mame/drivers/mwarr.c @@ -123,7 +123,7 @@ static WRITE16_HANDLER( mwarr_brightness_w ) brightness = (double)(data & 0xff); for (i=0;i<0x800;i++) { - palette_set_brightness(machine, i, brightness/255); + palette_set_pen_contrast(machine, i, brightness/255); } } diff --git a/src/mame/drivers/psikyo4.c b/src/mame/drivers/psikyo4.c index ecc6b7dc8ed..ed1fdde564e 100644 --- a/src/mame/drivers/psikyo4.c +++ b/src/mame/drivers/psikyo4.c @@ -299,7 +299,7 @@ static WRITE32_HANDLER( ps4_screen1_brt_w ) int i; for (i = 0; i < 0x800; i++) - palette_set_brightness(machine,i,brt1); + palette_set_pen_contrast(machine,i,brt1); oldbrt1 = brt1; } @@ -326,7 +326,7 @@ static WRITE32_HANDLER( ps4_screen2_brt_w ) int i; for (i = 0x800; i < 0x1000; i++) - palette_set_brightness(machine,i,brt2); + palette_set_pen_contrast(machine,i,brt2); oldbrt2 = brt2; } diff --git a/src/mame/drivers/shadfrce.c b/src/mame/drivers/shadfrce.c index e43ee7ab7a5..c372c336dd5 100644 --- a/src/mame/drivers/shadfrce.c +++ b/src/mame/drivers/shadfrce.c @@ -225,7 +225,7 @@ static WRITE16_HANDLER ( shadfrce_sound_brt_w ) double brt = (data & 0xff) / 255.0; for (i = 0; i < 0x4000; i++) - palette_set_brightness(machine,i,brt); + palette_set_pen_contrast(machine,i,brt); } } diff --git a/src/mame/video/itech32.c b/src/mame/video/itech32.c index 7f0f0423a77..a52d1808b6c 100644 --- a/src/mame/video/itech32.c +++ b/src/mame/video/itech32.c @@ -271,7 +271,7 @@ WRITE16_HANDLER( timekill_intensity_w ) double intensity = (double)(data & 0xff) / (double)0x60; int i; for (i = 0; i < 8192; i++) - palette_set_brightness(machine, i, intensity); + palette_set_pen_contrast(machine, i, intensity); } } diff --git a/src/mame/video/tmnt.c b/src/mame/video/tmnt.c index e734229996d..9c95a00eb6d 100644 --- a/src/mame/video/tmnt.c +++ b/src/mame/video/tmnt.c @@ -756,15 +756,15 @@ VIDEO_UPDATE( tmnt2 ) // dim all colors before it for (i=0; imachine,i,brt); + palette_set_pen_contrast(screen->machine,i,brt); // reset all colors in range for (i=cb; imachine,i,1.0); + palette_set_pen_contrast(screen->machine,i,1.0); // dim all colors after it for (i=ce; i<2048; i++) - palette_set_brightness(screen->machine,i,brt); + palette_set_pen_contrast(screen->machine,i,brt); // toggle shadow/highlight if (~dim_c & 0x10) diff --git a/src/mame/video/toobin.c b/src/mame/video/toobin.c index 04484e3a824..30551dd4392 100644 --- a/src/mame/video/toobin.c +++ b/src/mame/video/toobin.c @@ -129,9 +129,9 @@ WRITE16_HANDLER( toobin_paletteram_w ) palette_set_color(machine, offset & 0x3ff, MAKE_RGB(red, green, blue)); if (!(newword & 0x8000)) - palette_set_brightness(machine, offset & 0x3ff, brightness); + palette_set_pen_contrast(machine, offset & 0x3ff, brightness); else - palette_set_brightness(machine, offset & 0x3ff, 1.0); + palette_set_pen_contrast(machine, offset & 0x3ff, 1.0); } } @@ -146,7 +146,7 @@ WRITE16_HANDLER( toobin_intensity_w ) for (i = 0; i < 0x400; i++) if (!(paletteram16[i] & 0x8000)) - palette_set_brightness(machine, i, brightness); + palette_set_pen_contrast(machine, i, brightness); } } diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c index cc26f812428..ebabe4af906 100644 --- a/src/osd/windows/window.c +++ b/src/osd/windows/window.c @@ -605,7 +605,7 @@ void winwindow_video_window_create(running_machine *machine, int index, win_moni window->render_lock = osd_lock_alloc(); // load the layout - window->target = render_target_alloc(NULL, 0); + window->target = render_target_alloc(machine, NULL, 0); if (window->target == NULL) fatalerror("Error creating render target for window %d", index);