summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-02-19 17:52:21 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-02-19 17:52:21 +0000
commitaad4c81ac46e4f64b7a36b00798b53433873da1a (patch)
treebb0ac4260faea21903dddbd400f6eed1934e8380
parent3d8658108fdccc1c26fca29ebed0990728d0614e (diff)
Pulled remaining vestiges of old-style colortables:
* PALETTE_INIT no longer has a colortable parameter * removed game_colortable and remapped_colortable from machine_config * updated a few stragglers that still referenced these fields * removed tile_draw_colortable from tilemap.c (From Zsolt): Added support for the new colortable object in the palette viewer Changed the input port tokens to use a union instead of casting everything to FPTR. In the future, C99-enabled compilers will be able to achieve type safety with designated initializers.
-rw-r--r--src/emu/drawgfx.c34
-rw-r--r--src/emu/driver.h4
-rw-r--r--src/emu/emupal.c39
-rw-r--r--src/emu/inptport.c94
-rw-r--r--src/emu/inptport.h74
-rw-r--r--src/emu/mame.c2
-rw-r--r--src/emu/mame.h4
-rw-r--r--src/emu/mconfig.h3
-rw-r--r--src/emu/tilemap.c123
-rw-r--r--src/emu/uigfx.c25
-rw-r--r--src/emu/validity.c23
-rw-r--r--src/mame/drivers/hornet.c5
-rw-r--r--src/mame/drivers/nwk-tr.c12
-rw-r--r--src/mame/video/dkong.c4
-rw-r--r--src/mame/video/konamiic.c5
-rw-r--r--src/mame/video/plygonet.c5
-rw-r--r--src/mame/video/popeye.c6
-rw-r--r--src/mame/video/rungun.c5
-rw-r--r--src/mame/video/segaic24.c5
-rw-r--r--src/mame/video/taitojc.c5
20 files changed, 166 insertions, 311 deletions
diff --git a/src/emu/drawgfx.c b/src/emu/drawgfx.c
index 7a63cb291ae..a2181bce960 100644
--- a/src/emu/drawgfx.c
+++ b/src/emu/drawgfx.c
@@ -1391,7 +1391,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
{
if( gfx )
{
- const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
+ UINT32 palbase = gfx->color_base + gfx->color_granularity * (color % gfx->total_colors);
UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
@@ -1477,7 +1477,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
for( x=sx; x<ex; x++ )
{
if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[(source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f];
+ dest[x] = palbase + ((source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f);
pri[x] = 31;
x_index += dx;
}
@@ -1497,7 +1497,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
for( x=sx; x<ex; x++ )
{
if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[source[x_index>>16]];
+ dest[x] = palbase + source[x_index>>16];
x_index += dx;
}
@@ -1517,7 +1517,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
int x, x_index = x_index_base;
for( x=sx; x<ex; x++ )
{
- dest[x] = pal[(source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f];
+ dest[x] = palbase + ((source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f);
x_index += dx;
}
@@ -1534,7 +1534,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
int x, x_index = x_index_base;
for( x=sx; x<ex; x++ )
{
- dest[x] = pal[source[x_index>>16]];
+ dest[x] = palbase + source[x_index>>16];
x_index += dx;
}
@@ -1564,7 +1564,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
if( c != transparent_color )
{
if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[c];
+ dest[x] = palbase + c;
pri[x] = 31;
}
x_index += dx;
@@ -1588,7 +1588,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
if( c != transparent_color )
{
if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[c];
+ dest[x] = palbase + c;
pri[x] = 31;
}
x_index += dx;
@@ -1611,7 +1611,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
for( x=sx; x<ex; x++ )
{
int c = (source[x_index>>17] >> ((x_index & 0x10000) >> 14)) & 0x0f;
- if( c != transparent_color ) dest[x] = pal[c];
+ if( c != transparent_color ) dest[x] = palbase + c;
x_index += dx;
}
@@ -1629,7 +1629,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
for( x=sx; x<ex; x++ )
{
int c = source[x_index>>16];
- if( c != transparent_color ) dest[x] = pal[c];
+ if( c != transparent_color ) dest[x] = palbase + c;
x_index += dx;
}
@@ -1704,7 +1704,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
if (((1 << c) & transparent_color) == 0)
{
if (((1 << pri[x]) & pri_mask) == 0)
- dest[x] = pal[c];
+ dest[x] = palbase + c;
pri[x] = 31;
}
x_index += dx;
@@ -1725,7 +1725,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
{
int c = source[x_index>>16];
if (((1 << c) & transparent_color) == 0)
- dest[x] = pal[c];
+ dest[x] = palbase + c;
x_index += dx;
}
@@ -1758,9 +1758,9 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
if (((1 << (pri[x] & 0x1f)) & pri_mask) == 0)
{
if (pri[x] & 0x80)
- dest[x] = palette_shadow_table[pal[c]];
+ dest[x] = palette_shadow_table[palbase + c];
else
- dest[x] = pal[c];
+ dest[x] = palbase + c;
}
pri[x] = (pri[x] & 0x7f) | 31;
break;
@@ -1793,7 +1793,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
switch(gfx_drawmode_table[c])
{
case DRAWMODE_SOURCE:
- dest[x] = pal[c];
+ dest[x] = palbase + c;
break;
case DRAWMODE_SHADOW:
dest[x] = palette_shadow_table[dest[x]];
@@ -1817,7 +1817,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
{
if( gfx )
{
- const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
+ const pen_t *pal = &Machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
@@ -2351,7 +2351,7 @@ INLINE void common_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
{
if( gfx )
{
- const pen_t *pal = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
+ const pen_t *pal = &Machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
UINT8 *source_base = gfx->gfxdata + (code % gfx->total_elements) * gfx->char_modulo;
int sprite_screen_height = (scaley*gfx->height+0x8000)>>16;
@@ -3796,7 +3796,7 @@ DECLARE(drawgfx_core,(
int dw = ex-sx+1; /* dest width */
int dh = ey-sy+1; /* dest height */
int dm = dest->rowpixels; /* dest modulo */
- const pen_t *paldata = &Machine->remapped_colortable[gfx->color_base + gfx->color_granularity * color];
+ const pen_t *paldata = &Machine->pens[gfx->color_base + gfx->color_granularity * color];
UINT8 *pribuf = (pri_buffer) ? BITMAP_ADDR8(pri_buffer, sy, sx) : NULL;
switch (transparency)
diff --git a/src/emu/driver.h b/src/emu/driver.h
index 1047f4f5cb6..071b49d1977 100644
--- a/src/emu/driver.h
+++ b/src/emu/driver.h
@@ -46,8 +46,8 @@
#define VIDEO_RESET(name) void video_reset_##name(running_machine *machine)
#define VIDEO_RESET_CALL(name) video_reset_##name(machine)
-#define PALETTE_INIT(name) void palette_init_##name(running_machine *machine, UINT16 *colortable, const UINT8 *color_prom)
-#define PALETTE_INIT_CALL(name) palette_init_##name(machine, colortable, color_prom)
+#define PALETTE_INIT(name) void palette_init_##name(running_machine *machine, const UINT8 *color_prom)
+#define PALETTE_INIT_CALL(name) palette_init_##name(machine, color_prom)
#define VIDEO_EOF(name) void video_eof_##name(running_machine *machine)
#define VIDEO_EOF_CALL(name) video_eof_##name(machine)
diff --git a/src/emu/emupal.c b/src/emu/emupal.c
index 76b9ad15b34..c3924d9cba6 100644
--- a/src/emu/emupal.c
+++ b/src/emu/emupal.c
@@ -110,19 +110,14 @@ void palette_init(running_machine *machine)
switch (palette->format)
{
case BITMAP_FORMAT_INDEXED16:
- /* indexed modes are fine for everything */
- break;
-
case BITMAP_FORMAT_RGB15:
case BITMAP_FORMAT_RGB32:
- /* RGB modes can't use color tables */
- assert(machine->config->color_table_len == 0);
+ /* indexed and RGB modes are fine for everything */
break;
case BITMAP_FORMAT_INVALID:
/* invalid format means no palette - or at least it should */
assert(machine->config->total_colors == 0);
- assert(machine->config->color_table_len == 0);
return;
default:
@@ -158,40 +153,11 @@ void palette_init(running_machine *machine)
void palette_config(running_machine *machine)
{
- int total_colors = (machine->palette == NULL) ? 0 : palette_get_num_colors(machine->palette) * palette_get_num_groups(machine->palette);
- pen_t *remapped_colortable = NULL;
- UINT16 *colortable = NULL;
int i;
- /* allocate memory for the colortables, if needed */
- if (machine->config->color_table_len > 0)
- {
- /* first for the raw colortable */
- colortable = auto_malloc(machine->config->color_table_len * sizeof(colortable[0]));
- for (i = 0; i < machine->config->color_table_len; i++)
- colortable[i] = i % total_colors;
-
- /* then for the remapped colortable */
- remapped_colortable = auto_malloc(machine->config->color_table_len * sizeof(remapped_colortable[0]));
- }
-
/* now let the driver modify the initial palette and colortable */
if (machine->config->init_palette)
- (*machine->config->init_palette)(machine, colortable, memory_region(REGION_PROMS));
-
- /* now compute the remapped_colortable */
- for (i = 0; i < machine->config->color_table_len; i++)
- {
- pen_t color = colortable[i];
-
- /* check for invalid colors set by machine->config->init_palette */
- assert(color < total_colors);
- remapped_colortable[i] = machine->pens[color];
- }
-
- /* now we can set the final colortables */
- machine->game_colortable = colortable;
- machine->remapped_colortable = (remapped_colortable != NULL) ? remapped_colortable : machine->pens;
+ (*machine->config->init_palette)(machine, memory_region(REGION_PROMS));
/* set the color table base for each graphics element */
for (i = 0; i < MAX_GFX_ELEMENTS; i++)
@@ -371,6 +337,7 @@ colortable_t *colortable_alloc(running_machine *machine, UINT32 palettesize)
assert(machine != NULL);
assert(machine->config != NULL);
+ assert(palettesize > 0);
/* allocate the colortable */
ctable = auto_malloc(sizeof(*ctable));
diff --git a/src/emu/inptport.c b/src/emu/inptport.c
index 9025fc02a9f..d3a875cebeb 100644
--- a/src/emu/inptport.c
+++ b/src/emu/inptport.c
@@ -183,7 +183,7 @@ struct _changed_callback_info
{
changed_callback_info *next; /* linked list */
UINT32 mask; /* mask we care about */
- void (*callback)(void *, UINT32, UINT32); /* callback */
+ input_port_changed_func callback;/* callback */
void * param; /* parameter */
};
@@ -1906,12 +1906,12 @@ const char *input_port_string_from_token(const input_port_token token)
{
int index;
- if (token == 0)
+ if (token.fptr == 0)
return NULL;
- if ((FPTR)token >= INPUT_STRING_COUNT)
- return (const char *)token;
+ if (token.fptr >= INPUT_STRING_COUNT)
+ return token.stringptr;
for (index = 0; index < ARRAY_LENGTH(input_port_default_strings); index++)
- if (input_port_default_strings[index].id == (FPTR)token)
+ if (input_port_default_strings[index].id == token.fptr)
return input_port_default_strings[index].string;
return "(Unknown Default)";
}
@@ -1938,7 +1938,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
/* the entry is the first of a UINT32 pair */
/* note that we advance IPT assuming that there is no second half */
- entrytype = INPUT_PORT_PAIR_ITEM(ipt++, 0);
+ entrytype = INPUT_PORT_PAIR_UINT32(ipt++, 0);
switch (entrytype)
{
/* end */
@@ -1947,7 +1947,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
/* including */
case INPUT_TOKEN_INCLUDE:
- input_port_detokenize(param, (const input_port_token *)*ipt++);
+ input_port_detokenize(param, (ipt++)->tokenptr);
break;
/* start of a new input port */
@@ -1956,20 +1956,20 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
modify_tag = NULL;
port = input_port_initialize(param, IPT_PORT, NULL, 0, 0);
if (entrytype == INPUT_TOKEN_START_TAG)
- port->start.tag = (const char *)*ipt++;
+ port->start.tag = (ipt++)->stringptr;
break;
/* modify an existing port */
case INPUT_TOKEN_MODIFY:
- modify_tag = (const char *)*ipt++;
+ modify_tag = (ipt++)->stringptr;
break;
/* input bit definition */
case INPUT_TOKEN_BIT:
- type = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ type = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
- mask = INPUT_PORT_PAIR_ITEM(ipt, 0);
- defval = INPUT_PORT_PAIR_ITEM(ipt, 1);
+ mask = INPUT_PORT_PAIR_UINT32(ipt, 0);
+ defval = INPUT_PORT_PAIR_UINT32(ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
port = input_port_initialize(param, type, modify_tag, mask, defval);
@@ -1978,7 +1978,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
/* append a code */
case INPUT_TOKEN_CODE:
- val = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ val = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
if (seq_index[0] > 0)
port->seq.code[seq_index[0]++] = SEQCODE_OR;
@@ -1986,7 +1986,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
break;
case INPUT_TOKEN_CODE_DEC:
- val = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ val = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
if (seq_index[1] > 0)
port->analog.decseq.code[seq_index[1]++] = SEQCODE_OR;
@@ -1994,7 +1994,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
break;
case INPUT_TOKEN_CODE_INC:
- val = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ val = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
if (seq_index[2] > 0)
port->analog.incseq.code[seq_index[2]++] = SEQCODE_OR;
@@ -2039,7 +2039,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
break;
case INPUT_TOKEN_IMPULSE:
- port->impulse = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ port->impulse = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
break;
@@ -2057,42 +2057,42 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
/* analog settings */
case INPUT_TOKEN_MINMAX:
- port->analog.min = INPUT_PORT_PAIR_ITEM(ipt, 0);
- port->analog.max = INPUT_PORT_PAIR_ITEM(ipt, 1);
+ port->analog.min = INPUT_PORT_PAIR_UINT32(ipt, 0);
+ port->analog.max = INPUT_PORT_PAIR_UINT32(ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
break;
case INPUT_TOKEN_SENSITIVITY:
- port->analog.sensitivity = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ port->analog.sensitivity = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
break;
case INPUT_TOKEN_KEYDELTA:
- port->analog.delta = port->analog.centerdelta = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ port->analog.delta = port->analog.centerdelta = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
break;
case INPUT_TOKEN_CENTERDELTA:
- port->analog.centerdelta = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ port->analog.centerdelta = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
break;
case INPUT_TOKEN_CROSSHAIR:
- port->analog.crossaxis = INPUT_PORT_PAIR_ITEM(--ipt, 1) & 0xff;
- port->analog.crossaltaxis = (float)((INT32)INPUT_PORT_PAIR_ITEM(ipt, 1) >> 8) / 65536.0f;
+ port->analog.crossaxis = INPUT_PORT_PAIR_UINT32(--ipt, 1) & 0xff;
+ port->analog.crossaltaxis = (float)((INT32)INPUT_PORT_PAIR_UINT32(ipt, 1) >> 8) / 65536.0f;
ipt += INPUT_PORT_PAIR_TOKENS;
- port->analog.crossscale = (float)(INT32)INPUT_PORT_PAIR_ITEM(ipt, 0) / 65536.0f;
- port->analog.crossoffset = (float)(INT32)INPUT_PORT_PAIR_ITEM(ipt, 1) / 65536.0f;
+ port->analog.crossscale = (float)(INT32)INPUT_PORT_PAIR_UINT32(ipt, 0) / 65536.0f;
+ port->analog.crossoffset = (float)(INT32)INPUT_PORT_PAIR_UINT32(ipt, 1) / 65536.0f;
ipt += INPUT_PORT_PAIR_TOKENS;
break;
case INPUT_TOKEN_FULL_TURN_COUNT:
- port->analog.full_turn_count = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ port->analog.full_turn_count = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
break;
case INPUT_TOKEN_POSITIONS:
- port->analog.max = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ port->analog.max = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
break;
@@ -2101,7 +2101,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
break;
case INPUT_TOKEN_REMAP_TABLE:
- port->analog.remap_table = (UINT32 *)*ipt++;
+ port->analog.remap_table = (ipt++)->remapptr;
break;
case INPUT_TOKEN_INVERT:
@@ -2110,14 +2110,14 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
/* custom callbacks */
case INPUT_TOKEN_CUSTOM:
- port->custom = (UINT32 (*)(void *))*ipt++;
- port->custom_param = (void *)*ipt++;
+ port->custom = (ipt++)->customptr;
+ port->custom_param = (ipt++)->ptr;
break;
/* dip switch definition */
case INPUT_TOKEN_DIPNAME:
- mask = INPUT_PORT_PAIR_ITEM(ipt, 0);
- defval = INPUT_PORT_PAIR_ITEM(ipt, 1);
+ mask = INPUT_PORT_PAIR_UINT32(ipt, 0);
+ defval = INPUT_PORT_PAIR_UINT32(ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
port = input_port_initialize(param, IPT_DIPSWITCH_NAME, modify_tag, mask, defval);
@@ -2126,7 +2126,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
break;
case INPUT_TOKEN_DIPSETTING:
- defval = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ defval = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
port = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, defval);
@@ -2136,22 +2136,22 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
/* physical location */
case INPUT_TOKEN_DIPLOCATION:
- input_port_parse_diplocation(port, (const char *)*ipt++);
+ input_port_parse_diplocation(port, (ipt++)->stringptr);
break;
/* conditionals for dip switch settings */
case INPUT_TOKEN_CONDITION:
- port->condition.condition = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ port->condition.condition = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
- port->condition.mask = INPUT_PORT_PAIR_ITEM(ipt, 0);
- port->condition.value = INPUT_PORT_PAIR_ITEM(ipt, 1);
+ port->condition.mask = INPUT_PORT_PAIR_UINT32(ipt, 0);
+ port->condition.value = INPUT_PORT_PAIR_UINT32(ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
- port->condition.tag = (const char *)*ipt++;
+ port->condition.tag = (ipt++)->stringptr;
break;
/* analog adjuster definition */
case INPUT_TOKEN_ADJUSTER:
- defval = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ defval = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
port = input_port_initialize(param, IPT_ADJUSTER, modify_tag, 0xff, defval | (defval << 8));
@@ -2161,8 +2161,8 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
/* configuration definition */
case INPUT_TOKEN_CONFNAME:
- mask = INPUT_PORT_PAIR_ITEM(ipt, 0);
- defval = INPUT_PORT_PAIR_ITEM(ipt, 1);
+ mask = INPUT_PORT_PAIR_UINT32(ipt, 0);
+ defval = INPUT_PORT_PAIR_UINT32(ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
port = input_port_initialize(param, IPT_CONFIG_NAME, modify_tag, mask, defval);
@@ -2171,7 +2171,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
break;
case INPUT_TOKEN_CONFSETTING:
- defval = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ defval = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
port = input_port_initialize(param, IPT_CONFIG_SETTING, modify_tag, 0, defval);
@@ -2181,7 +2181,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
#ifdef MESS
case INPUT_TOKEN_CHAR:
- val = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ val = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
{
@@ -2194,13 +2194,13 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
/* category definition */
case INPUT_TOKEN_CATEGORY:
- port->category = (UINT16) INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ port->category = (UINT16) INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
break;
case INPUT_TOKEN_CATEGORY_NAME:
- mask = INPUT_PORT_PAIR_ITEM(ipt, 0);
- defval = INPUT_PORT_PAIR_ITEM(ipt, 1);
+ mask = INPUT_PORT_PAIR_UINT32(ipt, 0);
+ defval = INPUT_PORT_PAIR_UINT32(ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
port = input_port_initialize(param, IPT_CATEGORY_NAME, modify_tag, mask, defval);
@@ -2209,7 +2209,7 @@ static void input_port_detokenize(input_port_init_params *param, const input_por
break;
case INPUT_TOKEN_CATEGORY_SETTING:
- defval = INPUT_PORT_PAIR_ITEM(--ipt, 1);
+ defval = INPUT_PORT_PAIR_UINT32(--ipt, 1);
ipt += INPUT_PORT_PAIR_TOKENS;
port = input_port_initialize(param, IPT_CATEGORY_SETTING, modify_tag, 0, defval);
diff --git a/src/emu/inptport.h b/src/emu/inptport.h
index b0de99b0eba..9fd5840969b 100644
--- a/src/emu/inptport.h
+++ b/src/emu/inptport.h
@@ -34,6 +34,9 @@
#define IP_ACTIVE_HIGH 0x00000000
#define IP_ACTIVE_LOW 0xffffffff
+#define INPUT_PORT_PAIR_ENTRIES (sizeof(FPTR) / sizeof(UINT32))
+#define INPUT_PORT_PAIR_TOKENS (2 * sizeof(UINT32) / sizeof(FPTR))
+
/* macro for a custom callback functions (PORT_CUSTOM) */
#define CUSTOM_INPUT(name) UINT32 name(void *param)
@@ -492,8 +495,24 @@ enum
typedef struct _input_port_init_params input_port_init_params;
+/* a custom input port callback function */
+typedef UINT32 (*input_port_custom_func)(void *param);
+typedef void (*input_port_changed_func)(void *param, UINT32 oldval, UINT32 newval);
+
+
/* this type is used to encode input port definitions */
-typedef struct _input_port_token *input_port_token;
+typedef union _input_port_token input_port_token;
+union _input_port_token
+{
+ FPTR fptr; /* default value used for C89 implementations */
+ UINT32 i[INPUT_PORT_PAIR_ENTRIES]; /* one or two UINT32s */
+ float f[INPUT_PORT_PAIR_ENTRIES]; /* one or two floats */
+ void * ptr; /* a generic pointer value */
+ const char *stringptr; /* pointer to a string value */
+ const input_port_token *tokenptr; /* pointer to a another token list */
+ input_port_custom_func customptr; /* pointer to a custom input function */
+ const UINT32 *remapptr; /* pointer to a remap table */
+};
/* In mamecore.h: typedef struct _input_port_default_entry input_port_default_entry; */
@@ -544,7 +563,7 @@ struct _input_port_entry
UINT16 category; /* (MESS-specific) category */
const char *name; /* user-friendly name to display */
input_seq seq; /* input sequence affecting the input bits */
- UINT32 (*custom)(void *);/* custom callback routine */
+ input_port_custom_func custom;/* custom callback routine */
void * custom_param; /* parameter for callback routine */
/* valid if type is between __ipt_analog_start and __ipt_analog_end */
@@ -631,19 +650,22 @@ struct _ext_inp_header
#define IP_NAME_DEFAULT NULL
/* single pointers and UINT32s are just encoded straight */
-#define INPUT_PORT_PTR(x) ((input_port_token)(x))
-#define INPUT_PORT_UINT32(x) ((input_port_token)(FPTR)(UINT32)(FPTR)(x))
+#define INPUT_PORT_PTR(type,x) { (FPTR)(x) }
+#define INPUT_PORT_PAIR_UINT32(vptr,x) (vptr)->i[x]
-#ifdef PTR64
/* on 64-bit platforms, pairs of UINT32s are encoded into a single 64-bit pointer */
-#define INPUT_PORT_UINT32_PAIR(x,y) ((input_port_token)((UINT32)(x) | ((UINT64)(y) << 32)))
-#define INPUT_PORT_PAIR_ITEM(vptr,x) ((UINT32)((FPTR)*(vptr) >> (32 * (x))))
-#define INPUT_PORT_PAIR_TOKENS 1
+#ifdef PTR64
+#ifdef LSB_FIRST
+#define INPUT_PORT_UINT32_PAIR(x,y) { (FPTR)((UINT32)(x) | ((UINT64)(y) << 32)) }
#else
+#define INPUT_PORT_UINT32_PAIR(x,y) { (FPTR)((UINT32)(y) | ((UINT64)(x) << 32)) }
+#endif
+#define INPUT_PORT_UINT32(x) INPUT_PORT_UINT32_PAIR(x,0)
+
/* on 32-bit platforms, pairs of UINT32s are encoded in two consecutive 32-bit pointers */
+#else
+#define INPUT_PORT_UINT32(x) { (FPTR)(UINT32)(x) }
#define INPUT_PORT_UINT32_PAIR(x,y) INPUT_PORT_UINT32(x), INPUT_PORT_UINT32(y)
-#define INPUT_PORT_PAIR_ITEM(vptr,x) ((UINT32)((vptr)[x]))
-#define INPUT_PORT_PAIR_TOKENS 2
#endif
/* start of table */
@@ -660,7 +682,7 @@ struct _ext_inp_header
/* including */
#define PORT_INCLUDE(name) \
- INPUT_PORT_UINT32(INPUT_TOKEN_INCLUDE), INPUT_PORT_PTR(&ipt_##name[0]),
+ INPUT_PORT_UINT32(INPUT_TOKEN_INCLUDE), INPUT_PORT_PTR(tokenptr, &ipt_##name[0]),
/* start of a new input port */
#define PORT_START \
@@ -668,11 +690,11 @@ struct _ext_inp_header
/* start of a new input port (with included tag) */
#define PORT_START_TAG(tag_) \
- INPUT_PORT_UINT32(INPUT_TOKEN_START_TAG), INPUT_PORT_PTR(tag_),
+ INPUT_PORT_UINT32(INPUT_TOKEN_START_TAG), INPUT_PORT_PTR(stringptr, tag_),
/* modify an existing port */
#define PORT_MODIFY(tag_) \
- INPUT_PORT_UINT32(INPUT_TOKEN_MODIFY), INPUT_PORT_PTR(tag_),
+ INPUT_PORT_UINT32(INPUT_TOKEN_MODIFY), INPUT_PORT_PTR(stringptr, tag_),
/* input bit definition */
#define PORT_BIT(mask_,default_,type_) \
@@ -706,7 +728,7 @@ struct _ext_inp_header
/* general flags */
#define PORT_NAME(name_) \
- INPUT_PORT_UINT32(INPUT_TOKEN_NAME), INPUT_PORT_PTR(name_),
+ INPUT_PORT_UINT32(INPUT_TOKEN_NAME), INPUT_PORT_PTR(stringptr, name_),
#define PORT_PLAYER(player_) \
INPUT_PORT_UINT32(INPUT_TOKEN_PLAYER1 + (((player_) - 1) % MAX_PLAYERS)),
@@ -765,7 +787,7 @@ struct _ext_inp_header
/* positional control uses this remap table */
#define PORT_REMAP_TABLE(table_) \
- INPUT_PORT_UINT32(INPUT_TOKEN_REMAP_TABLE), INPUT_PORT_PTR(table_),
+ INPUT_PORT_UINT32(INPUT_TOKEN_REMAP_TABLE), INPUT_PORT_PTR(remapptr, table_),
/* positional control bits are active low */
#define PORT_INVERT \
@@ -773,34 +795,34 @@ struct _ext_inp_header
/* custom callbacks */
#define PORT_CUSTOM(callback_, param_) \
- INPUT_PORT_UINT32(INPUT_TOKEN_CUSTOM), INPUT_PORT_PTR(callback_), INPUT_PORT_PTR(param_),
+ INPUT_PORT_UINT32(INPUT_TOKEN_CUSTOM), INPUT_PORT_PTR(customptr, callback_), INPUT_PORT_PTR(ptr, param_),
/* dip switch definition */
#define PORT_DIPNAME(mask,default,name) \
- INPUT_PORT_UINT32(INPUT_TOKEN_DIPNAME), INPUT_PORT_UINT32_PAIR(mask, default), INPUT_PORT_PTR(name),
+ INPUT_PORT_UINT32(INPUT_TOKEN_DIPNAME), INPUT_PORT_UINT32_PAIR(mask, default), INPUT_PORT_PTR(stringptr, name),
#define PORT_DIPSETTING(default,name) \
- INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_DIPSETTING, default), INPUT_PORT_PTR(name),
+ INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_DIPSETTING, default), INPUT_PORT_PTR(stringptr, name),
/* physical location, of the form: name:[!]sw,[name:][!]sw,... */
/* note that these are specified LSB-first */
#define PORT_DIPLOCATION(location_) \
- INPUT_PORT_UINT32(INPUT_TOKEN_DIPLOCATION), INPUT_PORT_PTR(location_),
+ INPUT_PORT_UINT32(INPUT_TOKEN_DIPLOCATION), INPUT_PORT_PTR(stringptr, location_),
/* conditionals for dip switch settings */
#define PORT_CONDITION(tag_,mask_,condition_,value_) \
- INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_CONDITION, condition_), INPUT_PORT_UINT32_PAIR(mask_, value_), INPUT_PORT_PTR(tag_),
+ INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_CONDITION, condition_), INPUT_PORT_UINT32_PAIR(mask_, value_), INPUT_PORT_PTR(stringptr, tag_),
/* analog adjuster definition */
#define PORT_ADJUSTER(default,name) \
- INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_ADJUSTER, default), INPUT_PORT_PTR(name),
+ INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_ADJUSTER, default), INPUT_PORT_PTR(stringptr, name),
/* config definition */
#define PORT_CONFNAME(mask,default,name) \
- INPUT_PORT_UINT32(INPUT_TOKEN_CONFNAME), INPUT_PORT_UINT32_PAIR(mask, default), INPUT_PORT_PTR(name),
+ INPUT_PORT_UINT32(INPUT_TOKEN_CONFNAME), INPUT_PORT_UINT32_PAIR(mask, default), INPUT_PORT_PTR(stringptr, name),
#define PORT_CONFSETTING(default,name) \
- INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_CONFSETTING, default), INPUT_PORT_PTR(name),
+ INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_CONFSETTING, default), INPUT_PORT_PTR(stringptr, name),
#ifdef MESS
/* keyboard chars */
@@ -812,10 +834,10 @@ struct _ext_inp_header
INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_CATEGORY, category),
#define PORT_CATEGORY_CLASS(mask,default,name) \
- INPUT_PORT_UINT32(INPUT_TOKEN_CATEGORY_NAME), INPUT_PORT_UINT32_PAIR(mask, default), INPUT_PORT_PTR(name),
+ INPUT_PORT_UINT32(INPUT_TOKEN_CATEGORY_NAME), INPUT_PORT_UINT32_PAIR(mask, default), INPUT_PORT_PTR(stringptr, name),
#define PORT_CATEGORY_ITEM(default,name,category) \
- INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_CATEGORY_SETTING, default), INPUT_PORT_PTR(name), INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_CATEGORY, category),
+ INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_CATEGORY_SETTING, default), INPUT_PORT_PTR(stringptr, name), INPUT_PORT_UINT32_PAIR(INPUT_TOKEN_CATEGORY, category),
#endif /* MESS */
@@ -895,7 +917,7 @@ const char *input_port_name(const input_port_entry *in);
const input_seq *input_port_seq(input_port_entry *in, input_seq_type seqtype);
const input_seq *input_port_default_seq(int type, int player, input_seq_type seqtype);
int input_port_condition(const input_port_entry *in);
-void input_port_set_changed_callback(int port, UINT32 mask, void (*callback)(void *, UINT32, UINT32), void *param);
+void input_port_set_changed_callback(int port, UINT32 mask, input_port_changed_func callback, void *param);
const char *port_type_to_token(int type, int player);
int token_to_port_type(const char *string, int *player);
diff --git a/src/emu/mame.c b/src/emu/mame.c
index e0aa8c0566e..6dfd1730007 100644
--- a/src/emu/mame.c
+++ b/src/emu/mame.c
@@ -1453,8 +1453,6 @@ static void reset_machine(running_machine *machine)
/* palette-related information */
machine->pens = NULL;
- machine->game_colortable = NULL;
- machine->remapped_colortable = NULL;
machine->shadow_table = NULL;
/* audio-related information */
diff --git a/src/emu/mame.h b/src/emu/mame.h
index 416a457af5c..37c007875fc 100644
--- a/src/emu/mame.h
+++ b/src/emu/mame.h
@@ -183,12 +183,8 @@ struct _running_machine
palette_t * palette; /* global palette object */
/* palette-related information */
-/* fix me - some games try to modify remapped_colortable directly */
-/* search for "palette hack" to find instances */
const pen_t * pens; /* remapped palette pen numbers */
struct _colortable_t * colortable; /* global colortable for remapping */
- const UINT16 * game_colortable; /* lookup table used to map gfx pen numbers to color numbers */
- const pen_t * remapped_colortable;/* the above, already remapped through machine->pens */
pen_t * shadow_table; /* table for looking up a shadowed pen */
/* audio-related information */
diff --git a/src/emu/mconfig.h b/src/emu/mconfig.h
index 978a3e89884..c56ab1d6911 100644
--- a/src/emu/mconfig.h
+++ b/src/emu/mconfig.h
@@ -80,11 +80,10 @@ struct _machine_config
UINT32 video_attributes; /* flags describing the video system */
const gfx_decode_entry *gfxdecodeinfo; /* pointer to array of graphics decoding information */
UINT32 total_colors; /* total number of colors in the palette */
- UINT32 color_table_len; /* length of the color indirection table */
const char * default_layout; /* default layout for this machine */
screen_config screen[MAX_SCREENS]; /* total number of screens */
- void (*init_palette)(running_machine *machine, UINT16 *colortable, const UINT8 *color_prom); /* one-time palette init callback */
+ void (*init_palette)(running_machine *machine, const UINT8 *color_prom); /* one-time palette init callback */
void (*video_start)(running_machine *machine); /* one-time video start callback */
void (*video_reset)(running_machine *machine); /* video reset callback */
void (*video_eof)(running_machine *machine); /* end-of-frame video callback */
diff --git a/src/emu/tilemap.c b/src/emu/tilemap.c
index 4a24783ab3a..ecbd59b3220 100644
--- a/src/emu/tilemap.c
+++ b/src/emu/tilemap.c
@@ -149,7 +149,6 @@ static void mappings_update(tilemap *tmap);
static void pixmap_update(tilemap *tmap, const rectangle *cliprect);
static void tile_update(tilemap *tmap, tilemap_logical_index logindex, UINT32 cached_col, UINT32 cached_row);
static UINT8 tile_draw(tilemap *tmap, const UINT8 *pendata, UINT32 x0, UINT32 y0, UINT32 palette_base, UINT8 category, UINT8 group, UINT8 flags);
-static UINT8 tile_draw_colortable(tilemap *tmap, const UINT8 *pendata, UINT32 x0, UINT32 y0, UINT32 palette_base, UINT8 category, UINT8 group, UINT8 flags);
static UINT8 tile_apply_bitmask(tilemap *tmap, const UINT8 *maskdata, UINT32 x0, UINT32 y0, UINT8 category, UINT8 flags);
/* drawing helpers */
@@ -1247,10 +1246,7 @@ profiler_mark(PROFILER_TILEMAP_UPDATE);
flags = tmap->tileinfo.flags ^ (tmap->attributes & 0x03);
/* draw the tile, using either direct or transparent */
- if (Machine->game_colortable != NULL)
- tmap->tileflags[logindex] = tile_draw_colortable(tmap, tmap->tileinfo.pen_data, x0, y0, tmap->tileinfo.palette_base, tmap->tileinfo.category, tmap->tileinfo.group, flags);
- else
- tmap->tileflags[logindex] = tile_draw(tmap, tmap->tileinfo.pen_data, x0, y0, tmap->tileinfo.palette_base, tmap->tileinfo.category, tmap->tileinfo.group, flags);
+ tmap->tileflags[logindex] = tile_draw(tmap, tmap->tileinfo.pen_data, x0, y0, tmap->tileinfo.palette_base, tmap->tileinfo.category, tmap->tileinfo.group, flags);
/* if mask data is specified, apply it */
if ((flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2)) == 0 && tmap->tileinfo.mask_data != NULL)
@@ -1358,105 +1354,6 @@ static UINT8 tile_draw(tilemap *tmap, const UINT8 *pendata, UINT32 x0, UINT32 y0
/*-------------------------------------------------
- tile_draw_colortable - draw a single tile to
- the tilemap's internal pixmap, using the pen
- as the pen_to_flags lookup value, and using
- the machine's remapped_colortable
--------------------------------------------------*/
-
-static UINT8 tile_draw_colortable(tilemap *tmap, const UINT8 *pendata, UINT32 x0, UINT32 y0, UINT32 palette_base, UINT8 category, UINT8 group, UINT8 flags)
-{
- const UINT8 *penmap = tmap->pen_to_flags + group * MAX_PEN_TO_FLAGS;
- const pen_t *palette_lookup = Machine->remapped_colortable + palette_base;
- mame_bitmap *flagsmap = tmap->flagsmap;
- mame_bitmap *pixmap = tmap->pixmap;
- int height = tmap->tileheight;
- int width = tmap->tilewidth;
- UINT8 andmask = ~0, ormask = 0;
- int dx0 = 1, dy0 = 1;
- int tx, ty;
-
- /* OR in the force layer flags */
- category |= flags & (TILE_FORCE_LAYER0 | TILE_FORCE_LAYER1 | TILE_FORCE_LAYER2);
-
- /* if we're vertically flipped, point to the bottom row and work backwards */
- if (flags & TILE_FLIPY)
- {
- y0 += height - 1;
- dy0 = -1;
- }
-
- /* if we're horizontally flipped, point to the rightmost column and work backwards */
- if (flags & TILE_FLIPX)
- {
- x0 += width - 1;
- dx0 = -1;
- }
-
- /* in 4bpp mode, we draw in groups of 2 pixels, so halve the width now */
- if (flags & TILE_4BPP)
- {
- assert(width % 2 == 0);
- width /= 2;
- }
-
- /* iterate over rows */
- for (ty = 0; ty < height; ty++)
- {
- UINT16 *pixptr = BITMAP_ADDR16(pixmap, y0, x0);
- UINT8 *flagsptr = BITMAP_ADDR8(flagsmap, y0, x0);
- int xoffs = 0;
-
- /* pre-advance to the next row */
- y0 += dy0;
-
- /* 8bpp data */
- if (!(flags & TILE_4BPP))
- {
- for (tx = 0; tx < width; tx++)
- {
- UINT8 pen = *pendata++;
- UINT8 map = penmap[pen];
- pixptr[xoffs] = palette_lookup[pen];
- flagsptr[xoffs] = map | category;
- andmask &= map;
- ormask |= map;
- xoffs += dx0;
- }
- }
-
- /* 4bpp data */
- else
- {
- for (tx = 0; tx < width; tx++)
- {
- UINT8 data = *pendata++;
- pen_t pen;
- UINT8 map;
-
- pen = data & 0x0f;
- map = penmap[pen];
- pixptr[xoffs] = palette_lookup[pen];
- flagsptr[xoffs] = map | category;
- andmask &= map;
- ormask |= map;
- xoffs += dx0;
-
- pen = data >> 4;
- map = penmap[pen];
- pixptr[xoffs] = palette_lookup[pen];
- flagsptr[xoffs] = map | category;
- andmask &= map;
- ormask |= map;
- xoffs += dx0;
- }
- }
- }
- return andmask ^ ormask;
-}
-
-
-/*-------------------------------------------------
tile_apply_bitmask - apply a bitmask to an
already-rendered tile by modifying the
flagsmap appropriately
@@ -1787,7 +1684,7 @@ do { \
static void tilemap_draw_roz_core(tilemap *tmap, const blit_parameters *blit,
UINT32 startx, UINT32 starty, int incxx, int incxy, int incyx, int incyy, int wraparound)
{
- const pen_t *clut = &Machine->remapped_colortable[blit->tilemap_priority_code >> 16];
+ const pen_t *clut = &Machine->pens[blit->tilemap_priority_code >> 16];
mame_bitmap *destbitmap = blit->bitmap;
mame_bitmap *srcbitmap = tmap->pixmap;
mame_bitmap *flagsmap = tmap->flagsmap;
@@ -2085,7 +1982,7 @@ static void scanline_draw_masked_ind16(void *_dest, const UINT16 *source, const
static void scanline_draw_opaque_rgb16(void *_dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode)
{
- const pen_t *clut = &Machine->remapped_colortable[pcode >> 16];
+ const pen_t *clut = &Machine->pens[pcode >> 16];
UINT16 *dest = _dest;
int i;
@@ -2115,7 +2012,7 @@ static void scanline_draw_opaque_rgb16(void *_dest, const UINT16 *source, int co
static void scanline_draw_masked_rgb16(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode)
{
- const pen_t *clut = &Machine->remapped_colortable[pcode >> 16];
+ const pen_t *clut = &Machine->pens[pcode >> 16];
UINT16 *dest = _dest;
int i;
@@ -2147,7 +2044,7 @@ static void scanline_draw_masked_rgb16(void *_dest, const UINT16 *source, const
static void scanline_draw_opaque_rgb16_alpha(void *_dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode)
{
- const pen_t *clut = &Machine->remapped_colortable[pcode >> 16];
+ const pen_t *clut = &Machine->pens[pcode >> 16];
UINT16 *dest = _dest;
int i;
@@ -2178,7 +2075,7 @@ static void scanline_draw_opaque_rgb16_alpha(void *_dest, const UINT16 *source,
static void scanline_draw_masked_rgb16_alpha(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode)
{
- const pen_t *clut = &Machine->remapped_colortable[pcode >> 16];
+ const pen_t *clut = &Machine->pens[pcode >> 16];
UINT16 *dest = _dest;
int i;
@@ -2210,7 +2107,7 @@ static void scanline_draw_masked_rgb16_alpha(void *_dest, const UINT16 *source,
static void scanline_draw_opaque_rgb32(void *_dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode)
{
- const pen_t *clut = &Machine->remapped_colortable[pcode >> 16];
+ const pen_t *clut = &Machine->pens[pcode >> 16];
UINT32 *dest = _dest;
int i;
@@ -2240,7 +2137,7 @@ static void scanline_draw_opaque_rgb32(void *_dest, const UINT16 *source, int co
static void scanline_draw_masked_rgb32(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode)
{
- const pen_t *clut = &Machine->remapped_colortable[pcode >> 16];
+ const pen_t *clut = &Machine->pens[pcode >> 16];
UINT32 *dest = _dest;
int i;
@@ -2272,7 +2169,7 @@ static void scanline_draw_masked_rgb32(void *_dest, const UINT16 *source, const
static void scanline_draw_opaque_rgb32_alpha(void *_dest, const UINT16 *source, int count, UINT8 *pri, UINT32 pcode)
{
- const pen_t *clut = &Machine->remapped_colortable[pcode >> 16];
+ const pen_t *clut = &Machine->pens[pcode >> 16];
UINT32 *dest = _dest;
int i;
@@ -2303,7 +2200,7 @@ static void scanline_draw_opaque_rgb32_alpha(void *_dest, const UINT16 *source,
static void scanline_draw_masked_rgb32_alpha(void *_dest, const UINT16 *source, const UINT8 *maskptr, int mask, int value, int count, UINT8 *pri, UINT32 pcode)
{
- const pen_t *clut = &Machine->remapped_colortable[pcode >> 16];
+ const pen_t *clut = &Machine->pens[pcode >> 16];
UINT32 *dest = _dest;
int i;
diff --git a/src/emu/uigfx.c b/src/emu/uigfx.c
index 85722dae8e0..21c9a5b3479 100644
--- a/src/emu/uigfx.c
+++ b/src/emu/uigfx.c
@@ -155,7 +155,7 @@ UINT32 ui_gfx_ui_handler(running_machine *machine, UINT32 uistate)
ui_gfx_state *state = &ui_gfx;
/* if we have nothing, implicitly cancel */
- if (Machine->config->total_colors == 0 && Machine->config->color_table_len == 0 && Machine->gfx[0] == NULL && tilemap_count() == 0)
+ if (Machine->config->total_colors == 0 && Machine->colortable == NULL && Machine->gfx[0] == NULL && tilemap_count() == 0)
goto cancel;
/* if we're not paused, mark the bitmap dirty */
@@ -235,8 +235,7 @@ cancel:
static void palette_handler(ui_gfx_state *state)
{
- int total = state->palette.which ? Machine->config->color_table_len : Machine->config->total_colors;
- const UINT16 *pens = state->palette.which ? Machine->game_colortable : NULL;
+ int total = state->palette.which ? colortable_palette_get_size(Machine->colortable) : Machine->config->total_colors;
const char *title = state->palette.which ? "COLORTABLE" : "PALETTE";
const rgb_t *raw_color = palette_entry_list_raw(Machine->palette);
render_font *ui_font = ui_get_font();
@@ -337,10 +336,10 @@ static void palette_handler(ui_gfx_state *state)
int index = state->palette.offset + y * state->palette.count + x;
if (index < total)
{
- pen_t pen = (pens != NULL) ? pens[index] : index;
+ pen_t pen = state->palette.which ? colortable_palette_get_color(Machine->colortable, index) : raw_color[index];
render_ui_add_rect(cellboxbounds.x0 + x * cellwidth, cellboxbounds.y0 + y * cellheight,
cellboxbounds.x0 + (x + 1) * cellwidth, cellboxbounds.y0 + (y + 1) * cellheight,
- 0xff000000 | raw_color[pen], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+ 0xff000000 | pen, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
}
@@ -380,11 +379,11 @@ static void palette_handle_keys(ui_gfx_state *state)
/* clamp within range */
if (state->palette.which < 0)
state->palette.which = 1;
- if (state->palette.which > (Machine->config->color_table_len != 0))
- state->palette.which = (Machine->config->color_table_len != 0);
+ if (state->palette.which > (Machine->colortable != NULL))
+ state->palette.which = (Machine->colortable != NULL);
/* cache some info in locals */
- total = state->palette.which ? Machine->config->color_table_len : Machine->config->total_colors;
+ total = state->palette.which ? colortable_palette_get_size(Machine->colortable) : Machine->config->total_colors;
/* determine number of entries per row and total */
rowcount = state->palette.count;
@@ -771,16 +770,12 @@ static void gfxset_draw_item(const gfx_element *gfx, int index, mame_bitmap *bit
};
int width = (rotate & ORIENTATION_SWAP_XY) ? gfx->height : gfx->width;
int height = (rotate & ORIENTATION_SWAP_XY) ? gfx->width : gfx->height;
- const pen_t *palette = (Machine->config->total_colors != 0) ? palette_entry_list_raw(Machine->palette) : NULL;
+ const rgb_t *palette = (Machine->config->total_colors != 0) ? palette_entry_list_raw(Machine->palette) : NULL;
UINT32 rowpixels = bitmap->rowpixels;
- const UINT16 *colortable = NULL;
UINT32 palette_mask = ~0;
int x, y;
- /* select either the raw palette or the colortable */
- if (Machine->game_colortable != NULL)
- colortable = &Machine->game_colortable[gfx->color_base + color * gfx->color_granularity];
- else if (palette != NULL)
+ if (palette != NULL)
palette += gfx->color_base + color * gfx->color_granularity;
else
{
@@ -827,8 +822,6 @@ static void gfxset_draw_item(const gfx_element *gfx, int index, mame_bitmap *bit
pixel = (s[effx/2] >> ((effx & 1) * 4)) & 0xf;
else
pixel = s[effx];
- if (colortable != NULL)
- pixel = colortable[pixel];
*dest++ = 0xff000000 | palette[pixel & palette_mask];
}
}
diff --git a/src/emu/validity.c b/src/emu/validity.c
index 133a7d88fe9..46d9a61ad47 100644
--- a/src/emu/validity.c
+++ b/src/emu/validity.c
@@ -79,6 +79,15 @@ static quark_table *defstr_table;
+INLINE const char *input_port_string_from_index(UINT32 index)
+{
+ input_port_token token;
+ token.i[0] = index;
+ return input_port_string_from_token(token);
+}
+
+
+
/*************************************
*
* Allocate an array of quark
@@ -198,7 +207,7 @@ static void build_quarks(void)
/* add all the default strings */
for (strnum = 1; strnum < INPUT_STRING_COUNT; strnum++)
{
- const char *string = input_port_string_from_token(INPUT_PORT_UINT32(strnum));
+ const char *string = input_port_string_from_index(strnum);
if (string != NULL)
add_quark(defstr_table, strnum, quark_string_crc(string));
}
@@ -961,7 +970,7 @@ static void display_valid_coin_order(int drivnum, const input_port_entry *memory
/* hash the string and look it up in the string table */
crc = quark_string_crc(inp->name);
for (entry = first_hash_entry(defstr_table, crc); entry; entry = entry->next)
- if (entry->crc == crc && !strcmp(inp->name, input_port_string_from_token(INPUT_PORT_UINT32(entry - defstr_table->entry))))
+ if (entry->crc == crc && !strcmp(inp->name, input_port_string_from_index(entry - defstr_table->entry)))
{
strindex = entry - defstr_table->entry;
break;
@@ -992,7 +1001,7 @@ static void display_valid_coin_order(int drivnum, const input_port_entry *memory
for (j = 0; j < coin_len; j++)
/* if it's on our list, display it */
if (coin_list[j] == i)
- mame_printf_error("%s\n", input_port_string_from_token(INPUT_PORT_UINT32(i)));
+ mame_printf_error("%s\n", input_port_string_from_index(i));
}
@@ -1004,8 +1013,8 @@ static void display_valid_coin_order(int drivnum, const input_port_entry *memory
static int validate_inputs(int drivnum, const machine_config *drv, input_port_entry **memory)
{
- const char *demo_sounds = input_port_string_from_token(INPUT_PORT_UINT32(INPUT_STRING_Demo_Sounds));
- const char *flipscreen = input_port_string_from_token(INPUT_PORT_UINT32(INPUT_STRING_Flip_Screen));
+ const char *demo_sounds = input_port_string_from_index(INPUT_STRING_Demo_Sounds);
+ const char *flipscreen = input_port_string_from_index(INPUT_STRING_Flip_Screen);
const input_port_entry *inp, *last_dipname_entry = NULL;
const game_driver *driver = drivers[drivnum];
int empty_string_found = FALSE;
@@ -1188,14 +1197,14 @@ static int validate_inputs(int drivnum, const machine_config *drv, input_port_en
/* hash the string and look it up in the string table */
crc = quark_string_crc(inp->name);
for (entry = first_hash_entry(defstr_table, crc); entry; entry = entry->next)
- if (entry->crc == crc && !strcmp(inp->name, input_port_string_from_token(INPUT_PORT_UINT32(entry - defstr_table->entry))))
+ if (entry->crc == crc && !strcmp(inp->name, input_port_string_from_index(entry - defstr_table->entry)))
{
strindex = entry - defstr_table->entry;
break;
}
/* check for strings that should be DEF_STR */
- if (strindex != 0 && inp->name != input_port_string_from_token(INPUT_PORT_UINT32(strindex)))
+ if (strindex != 0 && inp->name != input_port_string_from_index(strindex))
{
mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver->source_file, driver->name, inp->name);
error = TRUE;
diff --git a/src/mame/drivers/hornet.c b/src/mame/drivers/hornet.c
index c7e2d2681e7..3c4d6a1b83c 100644
--- a/src/mame/drivers/hornet.c
+++ b/src/mame/drivers/hornet.c
@@ -343,10 +343,7 @@ static int K037122_vh_start(running_machine *machine, int chip)
machine->gfx[K037122_gfx_index[chip]] = allocgfx(&K037122_char_layout);
decodegfx(machine->gfx[K037122_gfx_index[chip]], (UINT8*)K037122_char_ram[chip], 0, machine->gfx[K037122_gfx_index[chip]]->total_elements);
- if (machine->config->color_table_len)
- machine->gfx[K037122_gfx_index[chip]]->total_colors = machine->config->color_table_len / 16;
- else
- machine->gfx[K037122_gfx_index[chip]]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[K037122_gfx_index[chip]]->total_colors = machine->config->total_colors / 16;
return 0;
}
diff --git a/src/mame/drivers/nwk-tr.c b/src/mame/drivers/nwk-tr.c
index 3b3e2e6e3fd..3bd2eb884ac 100644
--- a/src/mame/drivers/nwk-tr.c
+++ b/src/mame/drivers/nwk-tr.c
@@ -279,16 +279,8 @@ int K001604_vh_start(running_machine *machine, int chip)
machine->gfx[K001604_gfx_index[chip][1]] = allocgfx(&K001604_char_layout_layer_16x16);
decodegfx(machine->gfx[K001604_gfx_index[chip][1]], (UINT8*)&K001604_char_ram[chip][0], 0, machine->gfx[K001604_gfx_index[chip][1]]->total_elements);
- if (machine->config->color_table_len)
- {
- machine->gfx[K001604_gfx_index[chip][0]]->total_colors = machine->config->color_table_len / 16;
- machine->gfx[K001604_gfx_index[chip][1]]->total_colors = machine->config->color_table_len / 16;
- }
- else
- {
- machine->gfx[K001604_gfx_index[chip][0]]->total_colors = machine->config->total_colors / 16;
- machine->gfx[K001604_gfx_index[chip][1]]->total_colors = machine->config->total_colors / 16;
- }
+ machine->gfx[K001604_gfx_index[chip][0]]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[K001604_gfx_index[chip][1]]->total_colors = machine->config->total_colors / 16;
return 0;
}
diff --git a/src/mame/video/dkong.c b/src/mame/video/dkong.c
index 2cfa67f9d80..b55aebed730 100644
--- a/src/mame/video/dkong.c
+++ b/src/mame/video/dkong.c
@@ -846,10 +846,10 @@ static void check_palette(running_machine *machine)
switch (newset)
{
case 0x00:
- palette_init_radarscp(machine, (UINT16 *) machine->game_colortable, memory_region(REGION_PROMS));
+ palette_init_radarscp(machine, memory_region(REGION_PROMS));
break;
case 0x01:
- palette_init_dkong2b(machine, (UINT16 *) machine->game_colortable, memory_region(REGION_PROMS));
+ palette_init_dkong2b(machine, memory_region(REGION_PROMS));
break;
}
}
diff --git a/src/mame/video/konamiic.c b/src/mame/video/konamiic.c
index 8f1afd3a0b8..d5952a280b3 100644
--- a/src/mame/video/konamiic.c
+++ b/src/mame/video/konamiic.c
@@ -1216,10 +1216,7 @@ static void decode_gfx(running_machine *machine, int gfx_index, UINT8 *data, UIN
decodegfx(machine->gfx[gfx_index], data, 0, machine->gfx[gfx_index]->total_elements);
/* set the color information */
- if (machine->config->color_table_len)
- machine->gfx[gfx_index]->total_colors = machine->config->color_table_len / (1 << bpp);
- else
- machine->gfx[gfx_index]->total_colors = machine->config->total_colors / (1 << bpp);
+ machine->gfx[gfx_index]->total_colors = machine->config->total_colors / (1 << bpp);
}
diff --git a/src/mame/video/plygonet.c b/src/mame/video/plygonet.c
index fed2e897911..2faab9a9d1d 100644
--- a/src/mame/video/plygonet.c
+++ b/src/mame/video/plygonet.c
@@ -69,10 +69,7 @@ VIDEO_START( polygonet )
machine->gfx[ttl_gfx_index] = allocgfx(&charlayout);
decodegfx(machine->gfx[ttl_gfx_index], memory_region(REGION_GFX1), 0, machine->gfx[ttl_gfx_index]->total_elements);
- if (machine->config->color_table_len)
- machine->gfx[ttl_gfx_index]->total_colors = machine->config->color_table_len / 16;
- else
- machine->gfx[ttl_gfx_index]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[ttl_gfx_index]->total_colors = machine->config->total_colors / 16;
// create the tilemap
ttl_tilemap = tilemap_create(ttl_get_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
diff --git a/src/mame/video/popeye.c b/src/mame/video/popeye.c
index 5f8db3ed9c6..a529261a86d 100644
--- a/src/mame/video/popeye.c
+++ b/src/mame/video/popeye.c
@@ -58,7 +58,7 @@ static tilemap *fg_tilemap;
The bootleg is the same, but the outputs are not inverted.
***************************************************************************/
-static void convert_color_prom(running_machine *machine,UINT16 *colortable,const UINT8 *color_prom)
+static void convert_color_prom(running_machine *machine,const UINT8 *color_prom)
{
int i;
@@ -125,14 +125,14 @@ PALETTE_INIT( popeye )
{
invertmask = 0xff;
- convert_color_prom(machine,colortable,color_prom);
+ convert_color_prom(machine,color_prom);
}
PALETTE_INIT( popeyebl )
{
invertmask = 0x00;
- convert_color_prom(machine,colortable,color_prom);
+ convert_color_prom(machine,color_prom);
}
static void set_background_palette(running_machine *machine,int bank)
diff --git a/src/mame/video/rungun.c b/src/mame/video/rungun.c
index b8b015f9839..981b360b098 100644
--- a/src/mame/video/rungun.c
+++ b/src/mame/video/rungun.c
@@ -100,10 +100,7 @@ VIDEO_START(rng)
machine->gfx[ttl_gfx_index] = allocgfx(&charlayout);
decodegfx(machine->gfx[ttl_gfx_index], memory_region(REGION_GFX3), 0, machine->gfx[ttl_gfx_index]->total_elements);
- if (machine->config->color_table_len)
- machine->gfx[ttl_gfx_index]->total_colors = machine->config->color_table_len / 16;
- else
- machine->gfx[ttl_gfx_index]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[ttl_gfx_index]->total_colors = machine->config->total_colors / 16;
// create the tilemap
ttl_tilemap = tilemap_create(ttl_get_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
diff --git a/src/mame/video/segaic24.c b/src/mame/video/segaic24.c
index 656e4436347..a049ae6c581 100644
--- a/src/mame/video/segaic24.c
+++ b/src/mame/video/segaic24.c
@@ -166,10 +166,7 @@ void sys24_tile_vh_start(running_machine *machine, UINT16 tile_mask)
machine->gfx[sys24_char_gfx_index] = allocgfx(&sys24_char_layout);
- if (machine->config->color_table_len)
- machine->gfx[sys24_char_gfx_index]->total_colors = machine->config->color_table_len / 16;
- else
- machine->gfx[sys24_char_gfx_index]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[sys24_char_gfx_index]->total_colors = machine->config->total_colors / 16;
state_save_register_global_pointer(sys24_tile_ram, 0x10000/2);
state_save_register_global_pointer(sys24_char_ram, 0x80000/2);
diff --git a/src/mame/video/taitojc.c b/src/mame/video/taitojc.c
index 40d2d0a62bf..5d4fdb591fd 100644
--- a/src/mame/video/taitojc.c
+++ b/src/mame/video/taitojc.c
@@ -220,10 +220,7 @@ VIDEO_START( taitojc )
machine->gfx[taitojc_gfx_index] = allocgfx(&taitojc_char_layout);
/* set the color information */
- if (machine->config->color_table_len)
- machine->gfx[taitojc_gfx_index]->total_colors = machine->config->color_table_len / 16;
- else
- machine->gfx[taitojc_gfx_index]->total_colors = machine->config->total_colors / 16;
+ machine->gfx[taitojc_gfx_index]->total_colors = machine->config->total_colors / 16;
taitojc_texture = auto_malloc(0x400000);