From ee4c9c4c244d3a2580628d08a4bfbf54c1fd0273 Mon Sep 17 00:00:00 2001 From: Zsolt Vasvari Date: Tue, 5 Feb 2008 13:06:32 +0000 Subject: [PATCH] Changed the use of machine->remapped_colortable to machine->pens where the drivers weren't using color tables --- src/mame/drivers/exerion.c | 3 +- src/mame/drivers/gamecstl.c | 17 ++---- src/mame/drivers/gticlub.c | 2 +- src/mame/drivers/mediagx.c | 14 ++--- src/mame/drivers/namcoic.c | 2 +- src/mame/drivers/nwk-tr.c | 2 +- src/mame/drivers/taitowlf.c | 14 ++--- src/mame/drivers/ultrsprt.c | 4 +- src/mame/drivers/zr107.c | 4 +- src/mame/video/atari.c | 16 +++--- src/mame/video/bbusters.c | 2 +- src/mame/video/circus.c | 15 +---- src/mame/video/deco16ic.c | 2 +- src/mame/video/deco32.c | 8 +-- src/mame/video/deco_mlc.c | 4 +- src/mame/video/djmain.c | 2 +- src/mame/video/exerion.c | 109 +++++++++++++++++++++--------------- src/mame/video/gtia.c | 6 +- src/mame/video/gticlub.c | 2 +- src/mame/video/jalblend.c | 2 +- src/mame/video/kaneko16.c | 2 +- src/mame/video/m52.c | 2 +- src/mame/video/namcona1.c | 6 +- src/mame/video/namcos22.c | 2 +- src/mame/video/namcos86.c | 2 +- src/mame/video/psikyosh.c | 4 +- src/mame/video/seibuspi.c | 8 +-- src/mame/video/stvvdp2.c | 2 +- src/mame/video/suprloco.c | 2 +- src/mame/video/system1.c | 2 +- src/mame/video/system16.c | 4 +- src/mame/video/taito_f2.c | 2 +- src/mame/video/taito_f3.c | 6 +- src/mame/video/tatsumi.c | 2 +- src/mame/video/toaplan1.c | 2 +- src/mame/video/wecleman.c | 8 +-- 36 files changed, 139 insertions(+), 147 deletions(-) diff --git a/src/mame/drivers/exerion.c b/src/mame/drivers/exerion.c index 3ff708338b3..7ba91038f76 100644 --- a/src/mame/drivers/exerion.c +++ b/src/mame/drivers/exerion.c @@ -291,8 +291,7 @@ static MACHINE_DRIVER_START( exerion ) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) MDRV_SCREEN_RAW_PARAMS(EXERION_PIXEL_CLOCK, EXERION_HTOTAL, EXERION_HBEND, EXERION_HBSTART, EXERION_VTOTAL, EXERION_VBEND, EXERION_VBSTART) MDRV_GFXDECODE(exerion) - MDRV_PALETTE_LENGTH(32) - MDRV_COLORTABLE_LENGTH(256*3) + MDRV_PALETTE_LENGTH(256*3) MDRV_PALETTE_INIT(exerion) MDRV_VIDEO_START(exerion) diff --git a/src/mame/drivers/gamecstl.c b/src/mame/drivers/gamecstl.c index 1b16acf14c8..690d73684db 100644 --- a/src/mame/drivers/gamecstl.c +++ b/src/mame/drivers/gamecstl.c @@ -67,12 +67,10 @@ static VIDEO_START(gamecstl) { int i; for (i=0; i < 16; i++) - { palette_set_color(machine, i, cga_palette[i]); - } } -static void draw_char(mame_bitmap *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y) +static void draw_char(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y) { int i,j; UINT8 *dp; @@ -82,17 +80,14 @@ static void draw_char(mame_bitmap *bitmap, const rectangle *cliprect, const gfx_ for (j=y; j < y+8; j++) { UINT16 *p = BITMAP_ADDR16(bitmap, j, 0); + for (i=x; i < x+8; i++) { UINT8 pen = dp[index++]; if (pen) - { - p[i] = Machine->remapped_colortable[gfx->color_base + (att & 0xf)]; - } + p[i] = machine->pens[gfx->color_base + (att & 0xf)]; else - { - p[i] = Machine->remapped_colortable[gfx->color_base + ((att >> 4) & 0x7)]; - } + p[i] = machine->pens[gfx->color_base + ((att >> 4) & 0x7)]; } } } @@ -115,8 +110,8 @@ static VIDEO_UPDATE(gamecstl) int att1 = (cga[index] >> 24) & 0xff; int ch1 = (cga[index] >> 16) & 0xff; - draw_char(bitmap, cliprect, gfx, ch0, att0, i*8, j*8); - draw_char(bitmap, cliprect, gfx, ch1, att1, (i*8)+8, j*8); + draw_char(machine, bitmap, cliprect, gfx, ch0, att0, i*8, j*8); + draw_char(machine, bitmap, cliprect, gfx, ch1, att1, (i*8)+8, j*8); index++; } } diff --git a/src/mame/drivers/gticlub.c b/src/mame/drivers/gticlub.c index 1e94642b0ef..0b0907ca390 100644 --- a/src/mame/drivers/gticlub.c +++ b/src/mame/drivers/gticlub.c @@ -102,7 +102,7 @@ static VIDEO_START( hangplt ) static VIDEO_UPDATE( hangplt ) { - fillbitmap(bitmap, machine->remapped_colortable[0], cliprect); + fillbitmap(bitmap, machine->pens[0], cliprect); K001604_tile_update(screen); // K001604_draw_back_layer(bitmap, cliprect); diff --git a/src/mame/drivers/mediagx.c b/src/mame/drivers/mediagx.c index a6ff3509edd..cd94b5226f5 100644 --- a/src/mame/drivers/mediagx.c +++ b/src/mame/drivers/mediagx.c @@ -169,7 +169,7 @@ static VIDEO_START(mediagx) } } -static void draw_char(mame_bitmap *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y) +static void draw_char(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y) { int i,j; UINT8 *dp; @@ -183,15 +183,11 @@ static void draw_char(mame_bitmap *bitmap, const rectangle *cliprect, const gfx_ { UINT8 pen = dp[index++]; if (pen) - { - p[i] = Machine->remapped_colortable[gfx->color_base + (att & 0xf)]; - } + p[i] = machine->pens[gfx->color_base + (att & 0xf)]; else { if (((att >> 4) & 7) > 0) - { - p[i] = Machine->remapped_colortable[gfx->color_base + ((att >> 4) & 0x7)]; - } + p[i] = machine->pens[gfx->color_base + ((att >> 4) & 0x7)]; } } } @@ -304,8 +300,8 @@ static void draw_cga(running_machine *machine, mame_bitmap *bitmap, const rectan int att1 = (cga[index] >> 24) & 0xff; int ch1 = (cga[index] >> 16) & 0xff; - draw_char(bitmap, cliprect, gfx, ch0, att0, i*8, j*8); - draw_char(bitmap, cliprect, gfx, ch1, att1, (i*8)+8, j*8); + draw_char(machine, bitmap, cliprect, gfx, ch0, att0, i*8, j*8); + draw_char(machine, bitmap, cliprect, gfx, ch1, att1, (i*8)+8, j*8); index++; } } diff --git a/src/mame/drivers/namcoic.c b/src/mame/drivers/namcoic.c index f74acf00888..2e8dd397adf 100644 --- a/src/mame/drivers/namcoic.c +++ b/src/mame/drivers/namcoic.c @@ -277,7 +277,7 @@ static void zdrawgfxzoom(running_machine *machine, if( gfx ) { int shadow_offset = (machine->drv->video_attributes&VIDEO_HAS_SHADOWS)?machine->drv->total_colors:0; - 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; int sprite_screen_width = (scalex*gfx->width+0x8000)>>16; diff --git a/src/mame/drivers/nwk-tr.c b/src/mame/drivers/nwk-tr.c index 71ba6c54466..6431418391c 100644 --- a/src/mame/drivers/nwk-tr.c +++ b/src/mame/drivers/nwk-tr.c @@ -545,7 +545,7 @@ static VIDEO_START( nwktr ) static VIDEO_UPDATE( nwktr ) { - fillbitmap(bitmap, machine->remapped_colortable[0], cliprect); + fillbitmap(bitmap, machine->pens[0], cliprect); voodoo_update(0, bitmap, cliprect); diff --git a/src/mame/drivers/taitowlf.c b/src/mame/drivers/taitowlf.c index 1a931490664..ca410d6058b 100644 --- a/src/mame/drivers/taitowlf.c +++ b/src/mame/drivers/taitowlf.c @@ -37,7 +37,7 @@ static VIDEO_START(taitowlf) } } -static void draw_char(mame_bitmap *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y) +static void draw_char(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, const gfx_element *gfx, int ch, int att, int x, int y) { int i,j; UINT8 *dp; @@ -51,13 +51,9 @@ static void draw_char(mame_bitmap *bitmap, const rectangle *cliprect, const gfx_ { UINT8 pen = dp[index++]; if (pen) - { - p[i] = Machine->remapped_colortable[gfx->color_base + (att & 0xf)]; - } + p[i] = machine->pens[gfx->color_base + (att & 0xf)]; else - { - p[i] = Machine->remapped_colortable[gfx->color_base + ((att >> 4) & 0x7)]; - } + p[i] = machine->pens[gfx->color_base + ((att >> 4) & 0x7)]; } } } @@ -80,8 +76,8 @@ static VIDEO_UPDATE(taitowlf) int att1 = (cga[index] >> 24) & 0xff; int ch1 = (cga[index] >> 16) & 0xff; - draw_char(bitmap, cliprect, gfx, ch0, att0, i*8, j*8); - draw_char(bitmap, cliprect, gfx, ch1, att1, (i*8)+8, j*8); + draw_char(machine, bitmap, cliprect, gfx, ch0, att0, i*8, j*8); + draw_char(machine, bitmap, cliprect, gfx, ch1, att1, (i*8)+8, j*8); index++; } } diff --git a/src/mame/drivers/ultrsprt.c b/src/mame/drivers/ultrsprt.c index 0a81dae3717..4efc5b8dd32 100644 --- a/src/mame/drivers/ultrsprt.c +++ b/src/mame/drivers/ultrsprt.c @@ -36,11 +36,11 @@ static VIDEO_UPDATE( ultrsprt ) if (p1 == 0) { UINT8 p2 = ram[BYTE4_XOR_BE(fb_index + i)]; - bmp[i] = machine->remapped_colortable[0x000 + p2]; + bmp[i] = machine->pens[0x000 + p2]; } else { - bmp[i] = machine->remapped_colortable[0x100 + p1]; + bmp[i] = machine->pens[0x100 + p1]; } } } diff --git a/src/mame/drivers/zr107.c b/src/mame/drivers/zr107.c index 22178e0cce0..f7c413750fb 100644 --- a/src/mame/drivers/zr107.c +++ b/src/mame/drivers/zr107.c @@ -91,7 +91,7 @@ static VIDEO_START( jetwave ) static VIDEO_UPDATE( jetwave ) { - fillbitmap(bitmap, machine->remapped_colortable[0], cliprect); + fillbitmap(bitmap, machine->pens[0], cliprect); K001604_tile_update(machine, 0); K001005_draw(bitmap, cliprect); @@ -138,7 +138,7 @@ static VIDEO_START( zr107 ) static VIDEO_UPDATE( zr107 ) { - fillbitmap(bitmap, machine->remapped_colortable[0], cliprect); + fillbitmap(bitmap, machine->pens[0], cliprect); K056832_set_LayerOffset(0, -29, -27); K056832_set_LayerOffset(1, -29, -27); diff --git a/src/mame/video/atari.c b/src/mame/video/atari.c index 844eaff35ba..f67abd77d9f 100644 --- a/src/mame/video/atari.c +++ b/src/mame/video/atari.c @@ -804,10 +804,10 @@ static void artifacts_gfx(UINT8 *src, UINT8 *dst, int width) UINT8 n, bits = 0; UINT8 b = gtia.w.colbk & 0xf0; UINT8 c = gtia.w.colpf1 & 0x0f; - UINT8 atari_A = Machine->remapped_colortable[((b+0x30)&0xf0)+c]; - UINT8 atari_B = Machine->remapped_colortable[((b+0x70)&0xf0)+c]; - UINT8 atari_C = Machine->remapped_colortable[b+c]; - UINT8 atari_D = Machine->remapped_colortable[gtia.w.colbk]; + UINT8 atari_A = Machine->pens[((b+0x30)&0xf0)+c]; + UINT8 atari_B = Machine->pens[((b+0x70)&0xf0)+c]; + UINT8 atari_C = Machine->pens[b+c]; + UINT8 atari_D = Machine->pens[gtia.w.colbk]; for( x = 0; x < width * 4; x++ ) { @@ -878,10 +878,10 @@ static void artifacts_txt(UINT8 * src, UINT8 * dst, int width) UINT8 n, bits = 0; UINT8 b = gtia.w.colpf2 & 0xf0; UINT8 c = gtia.w.colpf1 & 0x0f; - UINT8 atari_A = Machine->remapped_colortable[((b+0x30)&0xf0)+c]; - UINT8 atari_B = Machine->remapped_colortable[((b+0x70)&0xf0)+c]; - UINT8 atari_C = Machine->remapped_colortable[b+c]; - UINT8 atari_D = Machine->remapped_colortable[gtia.w.colpf2]; + UINT8 atari_A = Machine->pens[((b+0x30)&0xf0)+c]; + UINT8 atari_B = Machine->pens[((b+0x70)&0xf0)+c]; + UINT8 atari_C = Machine->pens[b+c]; + UINT8 atari_D = Machine->pens[gtia.w.colpf2]; for( x = 0; x < width * 4; x++ ) { diff --git a/src/mame/video/bbusters.c b/src/mame/video/bbusters.c index a418f524881..8c28d836c93 100644 --- a/src/mame/video/bbusters.c +++ b/src/mame/video/bbusters.c @@ -148,7 +148,7 @@ INLINE const UINT8 *get_source_ptr(running_machine *machine, UINT32 sprite, int static void bbusters_draw_block(running_machine *machine, mame_bitmap *dest,int x,int y,int size,int flipx,int flipy,UINT32 sprite,int color,int bank,int block) { - const pen_t *pal = &machine->remapped_colortable[machine->gfx[bank]->color_base + machine->gfx[bank]->color_granularity * (color % machine->gfx[bank]->total_colors)]; + const pen_t *pal = &machine->pens[machine->gfx[bank]->color_base + machine->gfx[bank]->color_granularity * (color % machine->gfx[bank]->total_colors)]; UINT32 xinc=(scale_line_count * 0x10000 ) / size; UINT8 pixel; int x_index; diff --git a/src/mame/video/circus.c b/src/mame/video/circus.c index d5aa8115206..957b9dcc141 100644 --- a/src/mame/video/circus.c +++ b/src/mame/video/circus.c @@ -65,19 +65,11 @@ static void draw_line(running_machine *machine, mame_bitmap *bitmap, const recta skip = 1; if (x1 == x2) - { for (count = y2; count >= y1; count -= skip) - { *BITMAP_ADDR16(bitmap, count, x1) = machine->pens[1]; - } - } else - { for (count = x2; count >= x1; count -= skip) - { *BITMAP_ADDR16(bitmap, y1, count) = machine->pens[1]; - } - } } static void draw_robot_box (running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int x, int y) @@ -202,10 +194,9 @@ VIDEO_UPDATE( crash ) static void ripcord_draw_skydiver(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect) { const gfx_element *gfx; - const pen_t *pal_ptr; UINT8 *src_lineptr, *src_pixptr; UINT16 *dst_lineptr, *dst_lineend; - UINT32 code, color; + UINT32 code; int sx, sy; int src_pitch, dst_width, dst_height, dst_pitch, dst_pixoffs, dst_pixend; int collision, eax, edx; @@ -213,7 +204,6 @@ static void ripcord_draw_skydiver(running_machine *machine, mame_bitmap *bitmap, gfx = machine->gfx[0]; code = clown_z; - color = 0; sx = clown_y; sy = clown_x - 1; @@ -222,7 +212,6 @@ static void ripcord_draw_skydiver(running_machine *machine, mame_bitmap *bitmap, edx = 1; gfx = machine->gfx[1]; - pal_ptr = &machine->remapped_colortable[gfx->color_base + color * gfx->color_granularity]; src_lineptr = gfx->gfxdata + code * gfx->char_modulo; src_pitch = gfx->line_modulo; dst_pitch = bitmap->rowpixels; @@ -244,7 +233,7 @@ static void ripcord_draw_skydiver(running_machine *machine, mame_bitmap *bitmap, src_pixptr ++; if (eax) { - eax = pal_ptr[eax]; + eax = machine->pens[eax]; collision |= dst_lineptr[dst_pixoffs]; dst_lineptr[dst_pixoffs] = eax; } diff --git a/src/mame/video/deco16ic.c b/src/mame/video/deco16ic.c index bd1e43da65d..6ad76a9ab85 100644 --- a/src/mame/video/deco16ic.c +++ b/src/mame/video/deco16ic.c @@ -838,7 +838,7 @@ void deco16_pdrawgfx(mame_bitmap *dest,const gfx_element *gfx, int ox,oy,cx,cy; int x_index,y_index,x,y; - 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)]; int source_base = (code % gfx->total_elements) * gfx->height; /* check bounds */ diff --git a/src/mame/video/deco32.c b/src/mame/video/deco32.c index 96eed7dbf8d..18f3d667765 100644 --- a/src/mame/video/deco32.c +++ b/src/mame/video/deco32.c @@ -490,7 +490,7 @@ INLINE void dragngun_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)]; int source_base = (code % gfx->total_elements) * gfx->height; if (sprite_screen_width && sprite_screen_height) @@ -1414,9 +1414,9 @@ VIDEO_UPDATE( fghthist ) */ static void mixDualAlphaSprites(running_machine* machine, mame_bitmap *bitmap, const rectangle *cliprect, const gfx_element *gfx0, const gfx_element *gfx1, int mixAlphaTilemap) { - const pen_t *pal0 = &machine->remapped_colortable[gfx0->color_base]; - const pen_t *pal1 = &machine->remapped_colortable[gfx1->color_base]; - const pen_t *pal2 = &machine->remapped_colortable[(deco32_pri&1) ? machine->gfx[1]->color_base : machine->gfx[2]->color_base]; + const pen_t *pal0 = &machine->pens[gfx0->color_base]; + const pen_t *pal1 = &machine->pens[gfx1->color_base]; + const pen_t *pal2 = &machine->pens[(deco32_pri&1) ? machine->gfx[1]->color_base : machine->gfx[2]->color_base]; int x,y; /* Mix sprites into main bitmap, based on priority & alpha */ diff --git a/src/mame/video/deco_mlc.c b/src/mame/video/deco_mlc.c index 41e6593372a..c9f9edde922 100644 --- a/src/mame/video/deco_mlc.c +++ b/src/mame/video/deco_mlc.c @@ -63,7 +63,7 @@ static void blitRaster(mame_bitmap *bitmap, int rasterMode) } #endif -static void mlc_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx, +static void mlc_drawgfxzoom(mame_bitmap *dest_bmp,const gfx_element *gfx, UINT32 code1,UINT32 code2, UINT32 color,int flipx,int flipy,int sx,int sy, const rectangle *clip,int transparency,int transparent_color,int use8bpp, int scalex, int scaley) @@ -98,7 +98,7 @@ static void mlc_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)]; int source_base1 = (code1 % gfx->total_elements) * gfx->height; int source_base2 = (code2 % gfx->total_elements) * gfx->height; diff --git a/src/mame/video/djmain.c b/src/mame/video/djmain.c index 90e681289b9..6fbb150fbf7 100644 --- a/src/mame/video/djmain.c +++ b/src/mame/video/djmain.c @@ -173,7 +173,7 @@ VIDEO_UPDATE( djmain ) order[j] = temp; } - fillbitmap(bitmap, machine->remapped_colortable[0], cliprect); + fillbitmap(bitmap, machine->pens[0], cliprect); for (i = 0; i < NUM_LAYERS + 1; i++) { diff --git a/src/mame/video/exerion.c b/src/mame/video/exerion.c index a0eadedd750..b35211b9993 100644 --- a/src/mame/video/exerion.c +++ b/src/mame/video/exerion.c @@ -5,6 +5,7 @@ ***************************************************************************/ #include "driver.h" +#include "video/resnet.h" #include "exerion.h" @@ -46,51 +47,64 @@ static UINT8 *background_mixer; PALETTE_INIT( exerion ) { + static const int resistances_rg[3] = { 1000, 470, 220 }; + static const int resistances_b [2] = { 470, 220 }; + double rweights[3], gweights[3], bweights[2]; int i; - for (i = 0; i < machine->drv->total_colors; i++) + /* compute the color output resistor weights */ + compute_resistor_weights(0, 255, -1.0, + 3, &resistances_rg[0], rweights, 0, 0, + 3, &resistances_rg[0], gweights, 0, 0, + 2, &resistances_b[0], bweights, 0, 0); + + /* allocate the colortable */ + machine->colortable = colortable_alloc(machine, 0x20); + + /* create a lookup table for the palette */ + for (i = 0; i < 0x20; i++) { - int bit0, bit1, bit2, r, g, b; + int bit0, bit1, bit2; + int r, g, b; /* red component */ - bit0 = (*color_prom >> 0) & 0x01; - bit1 = (*color_prom >> 1) & 0x01; - bit2 = (*color_prom >> 2) & 0x01; - r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - /* green component */ - bit0 = (*color_prom >> 3) & 0x01; - bit1 = (*color_prom >> 4) & 0x01; - bit2 = (*color_prom >> 5) & 0x01; - g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - /* blue component */ - bit0 = 0; - bit1 = (*color_prom >> 6) & 0x01; - bit2 = (*color_prom >> 7) & 0x01; - b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; + bit0 = (color_prom[i] >> 0) & 0x01; + bit1 = (color_prom[i] >> 1) & 0x01; + bit2 = (color_prom[i] >> 2) & 0x01; + r = combine_3_weights(rweights, bit0, bit1, bit2); - palette_set_color(machine,i,MAKE_RGB(r,g,b)); - color_prom++; + /* green component */ + bit0 = (color_prom[i] >> 3) & 0x01; + bit1 = (color_prom[i] >> 4) & 0x01; + bit2 = (color_prom[i] >> 5) & 0x01; + g = combine_3_weights(gweights, bit0, bit1, bit2); + + /* blue component */ + bit0 = (color_prom[i] >> 6) & 0x01; + bit1 = (color_prom[i] >> 7) & 0x01; + b = combine_2_weights(bweights, bit0, bit1); + + colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b)); } - /* color_prom now points to the beginning of the char lookup table */ + /* color_prom now points to the beginning of the lookup table */ + color_prom += 0x20; - /* fg chars */ - for (i = 0; i < 256; i++) - colortable[i + 0x000] = 16 + (color_prom[(i & 0xc0) | ((i & 3) << 4) | ((i >> 2) & 15)] & 15); - color_prom += 256; - - /* color_prom now points to the beginning of the sprite lookup table */ - - /* sprites */ - for (i = 0; i < 256; i++) - colortable[i + 0x100] = 16 + (color_prom[(i & 0xc0) | ((i & 3) << 4) | ((i >> 2) & 15)] & 15); - color_prom += 256; + /* fg chars and sprites */ + for (i = 0; i < 0x200; i++) + { + UINT8 ctabentry = 0x10 | (color_prom[(i & 0xc0) | ((i & 3) << 4) | ((i >> 2) & 0x0f)] & 0x0f); + colortable_entry_set_value(machine->colortable, i, ctabentry); + } /* bg chars (this is not the full story... there are four layers mixed */ /* using another PROM */ - for (i = 0; i < 256; i++) - colortable[i + 0x200] = *color_prom++ & 15; -} + for (i = 0x200; i < 0x300; i++) + { + UINT8 ctabentry = color_prom[i] & 0x0f; + colortable_entry_set_value(machine->colortable, i, ctabentry); + } + } @@ -102,9 +116,7 @@ PALETTE_INIT( exerion ) VIDEO_START( exerion ) { - UINT16 *dst; - UINT8 *src; - int i, x, y; + int i; /* get pointers to the mixing and lookup PROMs */ background_mixer = memory_region(REGION_PROMS) + 0x320; @@ -132,12 +144,16 @@ VIDEO_START( exerion ) */ for (i = 0; i < 4; i++) { - src = memory_region(REGION_GFX3) + i * 0x2000; - dst = background_gfx[i]; + int y; - for (y = 0; y < 256; y++) + UINT8 *src = memory_region(REGION_GFX3) + i * 0x2000; + UINT16 *dst = background_gfx[i]; + + for (y = 0; y < 0x100; y++) { - for (x = 0; x < 128; x += 4) + int x; + + for (x = 0; x < 0x80; x += 4) { UINT8 data = *src++; UINT16 val; @@ -158,7 +174,8 @@ VIDEO_START( exerion ) if (val) val |= 0x100 >> i; *dst++ = val << (2 * i); } - for (x = 0; x < 128; x++) + + for (; x < 0x100; x++) *dst++ = 0; } } @@ -207,9 +224,7 @@ READ8_HANDLER( exerion_video_timing_r ) UINT8 snmi = 1; if (((hcounter & 0x180) == 0x180) && !video_screen_get_vblank(0)) - { snmi = !((hcounter >> 6) & 0x01); - } return (video_screen_get_vblank(0) << 1) | snmi; } @@ -325,7 +340,7 @@ static void draw_background(running_machine *machine, mame_bitmap *bitmap, const } /* draw the scanline */ - pens = &machine->remapped_colortable[0x200 + (background_latches[12] >> 4) * 16]; + pens = &machine->pens[0x200 + ((background_latches[12] >> 4) << 4)]; draw_scanline8(bitmap, cliprect->min_x, y, cliprect->max_x - cliprect->min_x + 1, &scanline[cliprect->min_x], pens, -1); } } @@ -378,11 +393,13 @@ VIDEO_UPDATE( exerion ) code &= ~0x10, code2 |= 0x10; drawgfx(bitmap, gfx, code2, color, xflip, yflip, x, y + gfx->height, - cliprect, TRANSPARENCY_COLOR, 16); + cliprect, TRANSPARENCY_PENS, + colortable_get_transpen_mask(machine->colortable, gfx, color, 0x10)); } drawgfx(bitmap, gfx, code, color, xflip, yflip, x, y, - cliprect, TRANSPARENCY_COLOR, 16); + cliprect, TRANSPARENCY_PENS, + colortable_get_transpen_mask(machine->colortable, gfx, color, 0x10)); if (doubled) i += 4; } diff --git a/src/mame/video/gtia.c b/src/mame/video/gtia.c index b8206d44620..ad4da6d131f 100644 --- a/src/mame/video/gtia.c +++ b/src/mame/video/gtia.c @@ -42,19 +42,19 @@ static void gtia_state_postload(void); * set both color clocks equal for one color **********************************************/ #define SETCOL_B(o,d) \ - antic.color_lookup[o] = (Machine->remapped_colortable[d] << 8) | Machine->remapped_colortable[d] + antic.color_lookup[o] = (Machine->pens[d] << 8) | Machine->pens[d] /********************************************** * set left color clock for one color **********************************************/ #define SETCOL_L(o,d) \ - *((UINT8*)&antic.color_lookup[o] + 0) = Machine->remapped_colortable[d] + *((UINT8*)&antic.color_lookup[o] + 0) = Machine->pens[d] /********************************************** * set right color clock for one color **********************************************/ #define SETCOL_R(o,d) \ - *((UINT8*)&antic.color_lookup[o] + 1) = Machine->remapped_colortable[d] + *((UINT8*)&antic.color_lookup[o] + 1) = Machine->pens[d] diff --git a/src/mame/video/gticlub.c b/src/mame/video/gticlub.c index 6bd2ca03c49..a22d47722e4 100644 --- a/src/mame/video/gticlub.c +++ b/src/mame/video/gticlub.c @@ -938,7 +938,7 @@ void K001005_swap_buffers(void) //if (K001005_status == 2) { - fillbitmap(K001005_bitmap[K001005_bitmap_page], Machine->remapped_colortable[0], &K001005_cliprect); + fillbitmap(K001005_bitmap[K001005_bitmap_page], Machine->pens[0], &K001005_cliprect); fillbitmap(K001005_zbuffer, 0xffffffff, &K001005_cliprect); } } diff --git a/src/mame/video/jalblend.c b/src/mame/video/jalblend.c index d5afd148e92..2b351cf8371 100644 --- a/src/mame/video/jalblend.c +++ b/src/mame/video/jalblend.c @@ -91,7 +91,7 @@ static void jal_blend_drawgfx( mame_bitmap *dest_bmp,const gfx_element *gfx, { for (xtile = xstart; xtile != xend; xtile += xinc ) { - 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)]; const UINT8 *alpha = &jal_blend_table[gfx->color_granularity * (color % gfx->total_colors)]; int source_base = ((code + code_offset++) % gfx->total_elements) * gfx->height; diff --git a/src/mame/video/kaneko16.c b/src/mame/video/kaneko16.c index 6fddacd210a..f2eec121764 100644 --- a/src/mame/video/kaneko16.c +++ b/src/mame/video/kaneko16.c @@ -395,7 +395,7 @@ static void kaneko16_draw_sprites_custom(running_machine *machine, mame_bitmap * UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, const rectangle *clip,int priority) { - 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 = ((1<<16)*gfx->height+0x8000)>>16; diff --git a/src/mame/video/m52.c b/src/mame/video/m52.c index 216f33151e3..5120e7df681 100644 --- a/src/mame/video/m52.c +++ b/src/mame/video/m52.c @@ -332,7 +332,7 @@ static void draw_background(running_machine *machine, mame_bitmap *bitmap, const rect.max_y = ypos + 2 * BGHEIGHT - 1; } - fillbitmap(bitmap, machine->remapped_colortable[machine->gfx[image]->color_base + 3], &rect); + fillbitmap(bitmap, machine->pens[machine->gfx[image]->color_base + 3], &rect); } diff --git a/src/mame/video/namcona1.c b/src/mame/video/namcona1.c index 353a7fb274b..41fbd75726f 100644 --- a/src/mame/video/namcona1.c +++ b/src/mame/video/namcona1.c @@ -278,7 +278,7 @@ static void pdraw_masked_tile(running_machine *machine, mask = machine->gfx[1]; code %= gfx->total_elements; color %= gfx->total_colors; - paldata = &machine->remapped_colortable[gfx->color_base + gfx->color_granularity * color]; + paldata = &machine->pens[gfx->color_base + gfx->color_granularity * color]; gfx_addr = gfx->gfxdata + code * gfx->char_modulo; gfx_pitch = gfx->line_modulo; mask_addr = mask->gfxdata + code * mask->char_modulo; @@ -413,7 +413,7 @@ static void pdraw_opaque_tile(running_machine *machine, gfx = machine->gfx[0]; code %= gfx->total_elements; color %= gfx->total_colors; - paldata = &machine->remapped_colortable[gfx->color_base + gfx->color_granularity * color]; + paldata = &machine->pens[gfx->color_base + gfx->color_granularity * color]; gfx_addr = gfx->gfxdata + code * gfx->char_modulo; gfx_pitch = gfx->line_modulo; @@ -575,7 +575,7 @@ static void draw_background(running_machine *machine, mame_bitmap *bitmap, const gfx_element *pGfx; pGfx = machine->gfx[0]; - paldata = &machine->remapped_colortable[pGfx->color_base + pGfx->color_granularity * tilemap_palette_bank[which]]; + paldata = &machine->pens[pGfx->color_base + pGfx->color_granularity * tilemap_palette_bank[which]]; /* draw one scanline at a time */ clip.min_x = cliprect->min_x; diff --git a/src/mame/video/namcos22.c b/src/mame/video/namcos22.c index e72a750cec7..b010796a7b9 100644 --- a/src/mame/video/namcos22.c +++ b/src/mame/video/namcos22.c @@ -490,7 +490,7 @@ static void renderscanline_sprite(void *destbase, INT32 scanline, const poly_ext int dx = extent->param[0].dpdx * 65536.0f; const poly_extra_data *extra = extradata; mame_bitmap *destmap = destbase; - const pen_t *pal = &Machine->remapped_colortable[extra->color]; + const pen_t *pal = &Machine->pens[extra->color]; int prioverchar = extra->prioverchar; int z = extra->z; int alpha = extra->alpha; diff --git a/src/mame/video/namcos86.c b/src/mame/video/namcos86.c index de056793b76..c7d2996e627 100644 --- a/src/mame/video/namcos86.c +++ b/src/mame/video/namcos86.c @@ -360,7 +360,7 @@ VIDEO_UPDATE( namcos86 ) fillbitmap(priority_bitmap, 0, cliprect); - fillbitmap(bitmap,machine->remapped_colortable[machine->gfx[0]->color_base + 8*backcolor+7],cliprect); + fillbitmap(bitmap,machine->pens[machine->gfx[0]->color_base + 8*backcolor+7],cliprect); for (layer = 0;layer < 8;layer++) { diff --git a/src/mame/video/psikyosh.c b/src/mame/video/psikyosh.c index 64e58848ee5..7d731ae4c1b 100644 --- a/src/mame/video/psikyosh.c +++ b/src/mame/video/psikyosh.c @@ -443,7 +443,7 @@ static void psikyosh_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx, { for (xtile = xstart; xtile != xend; xtile += xinc ) { - 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)]; int source_base = ((code + code_offset++) % gfx->total_elements) * gfx->height; int x_index_base, y_index, sx, sy, ex, ey; @@ -707,7 +707,7 @@ static void psikyosh_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx, /* Start drawing */ 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)]; int sprite_screen_height = ((high*gfx->height*(0x400*0x400))/zoomy + 0x200)>>10; /* Round up to nearest pixel */ int sprite_screen_width = ((wide*gfx->width*(0x400*0x400))/zoomx + 0x200)>>10; diff --git a/src/mame/video/seibuspi.c b/src/mame/video/seibuspi.c index 2311b2e36fd..dceff525b1b 100644 --- a/src/mame/video/seibuspi.c +++ b/src/mame/video/seibuspi.c @@ -332,11 +332,11 @@ static void draw_blend_gfx(mame_bitmap *bitmap, const rectangle *cliprect, const UINT8 alpha = alpha_table[global_pen]; if (alpha) { - p[i] = alpha_blend16(p[i], Machine->remapped_colortable[gfx->color_base + global_pen]); + p[i] = alpha_blend16(p[i], Machine->pens[gfx->color_base + global_pen]); } else { - p[i] = Machine->remapped_colortable[gfx->color_base + global_pen]; + p[i] = Machine->pens[gfx->color_base + global_pen]; } } dp_i += xd; @@ -598,11 +598,11 @@ static void combine_tilemap(running_machine *machine, mame_bitmap *bitmap, const UINT8 alpha = alpha_table[pen]; if (alpha) { - *d = alpha_blend16(*d, machine->remapped_colortable[pen]); + *d = alpha_blend16(*d, machine->pens[pen]); } else { - *d = machine->remapped_colortable[pen]; + *d = machine->pens[pen]; } } ++d; diff --git a/src/mame/video/stvvdp2.c b/src/mame/video/stvvdp2.c index 18230fb7767..98685044261 100644 --- a/src/mame/video/stvvdp2.c +++ b/src/mame/video/stvvdp2.c @@ -2413,7 +2413,7 @@ static void stv_vdp2_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; diff --git a/src/mame/video/suprloco.c b/src/mame/video/suprloco.c index 3387decdc92..97e1fc96acb 100644 --- a/src/mame/video/suprloco.c +++ b/src/mame/video/suprloco.c @@ -190,7 +190,7 @@ static void draw_sprite(running_machine *machine, mame_bitmap *bitmap,const rect skip = spr_reg[SPR_SKIP_LO] + (spr_reg[SPR_SKIP_HI] << 8); height = spr_reg[SPR_Y_BOTTOM] - spr_reg[SPR_Y_TOP]; - spr_palette = machine->remapped_colortable + 0x100 + 0x10 * (spr_reg[SPR_COL]&0x03) + ((control & 0x20)?0x100:0); + spr_palette = machine->pens + 0x100 + 0x10 * (spr_reg[SPR_COL]&0x03) + ((control & 0x20)?0x100:0); sx = spr_reg[SPR_X]; sy = spr_reg[SPR_Y_TOP] + 1; diff --git a/src/mame/video/system1.c b/src/mame/video/system1.c index c8e77a13e8b..c76e24d6916 100644 --- a/src/mame/video/system1.c +++ b/src/mame/video/system1.c @@ -269,7 +269,7 @@ static void draw_sprite(mame_bitmap *bitmap,int spr_number) skip = sprite_base[SPR_SKIP_LO] + (sprite_base[SPR_SKIP_HI] << 8); height = sprite_base[SPR_Y_BOTTOM] - sprite_base[SPR_Y_TOP]; - sprite_palette = Machine->remapped_colortable + 0x10 * spr_number; + sprite_palette = Machine->pens + 0x10 * spr_number; sy = sprite_base[SPR_Y_TOP] + 1; diff --git a/src/mame/video/system16.c b/src/mame/video/system16.c index 2eb1e950846..9e0a3a72bdc 100644 --- a/src/mame/video/system16.c +++ b/src/mame/video/system16.c @@ -209,7 +209,7 @@ static void draw_sprite(running_machine *machine, int shadow, int shadow_pen, int eos ) { - const pen_t *shadow_base = machine->remapped_colortable + machine->gfx[0]->color_base + (machine->drv->total_colors/2); + const pen_t *shadow_base = machine->pens + machine->gfx[0]->color_base + (machine->drv->total_colors/2); const UINT8 *source; int full_shadow=shadow&SYS16_SPR_SHADOW; int partial_shadow=shadow&SYS16_SPR_PARTIAL_SHADOW; @@ -340,7 +340,7 @@ static void draw_sprite(running_machine *machine, static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int b3d ) //* { - const pen_t *base_pal = machine->remapped_colortable + machine->gfx[0]->color_base; + const pen_t *base_pal = machine->pens + machine->gfx[0]->color_base; const UINT8 *base_gfx = memory_region(REGION_GFX2); const int gfx_rom_size = memory_region_length(REGION_GFX2); const UINT16 *source = sys16_spriteram; diff --git a/src/mame/video/taito_f2.c b/src/mame/video/taito_f2.c index 9040e7aea7f..12a2ea29ba2 100644 --- a/src/mame/video/taito_f2.c +++ b/src/mame/video/taito_f2.c @@ -374,7 +374,7 @@ static void taito_f2_tc360_spritemixdraw( mame_bitmap *dest_bmp,const gfx_elemen UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, const rectangle *clip,int scalex, int scaley) { - 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; diff --git a/src/mame/video/taito_f3.c b/src/mame/video/taito_f3.c index 72ef9a7ce49..d764c7a4943 100644 --- a/src/mame/video/taito_f3.c +++ b/src/mame/video/taito_f3.c @@ -1364,7 +1364,7 @@ INLINE void draw_scanlines(running_machine *machine, UINT32 orient, int skip_layer_num) { - const pen_t *clut = &machine->remapped_colortable[0]; + const pen_t *clut = &machine->pens[0]; UINT32 bgcolor=clut[0]; int length; @@ -2668,7 +2668,7 @@ INLINE void f3_drawgfx( 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)]; int source_base = (code % gfx->total_elements) * 16; { @@ -2832,7 +2832,7 @@ INLINE void f3_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)]; int source_base = (code % gfx->total_elements) * 16; { diff --git a/src/mame/video/tatsumi.c b/src/mame/video/tatsumi.c index 70fe4ec6189..02b7ecc783b 100644 --- a/src/mame/video/tatsumi.c +++ b/src/mame/video/tatsumi.c @@ -271,7 +271,7 @@ INLINE void roundupt_drawgfxzoomrotate( mame_bitmap *dest_bmp,const gfx_element { 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)]; const UINT8 *shadow_pens = shadow_pen_array + (gfx->color_granularity * (color % gfx->total_colors)); int source_base = (code % gfx->total_elements) * gfx->height; diff --git a/src/mame/video/toaplan1.c b/src/mame/video/toaplan1.c index 046067b762e..68022b80cc8 100644 --- a/src/mame/video/toaplan1.c +++ b/src/mame/video/toaplan1.c @@ -946,7 +946,7 @@ static void toaplan1_draw_sprite_custom(mame_bitmap *dest_bmp,const gfx_element UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy, const rectangle *clip,int priority) { - 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 = ((1<<16)*gfx->height+0x8000)>>16; diff --git a/src/mame/video/wecleman.c b/src/mame/video/wecleman.c index 4171ee80d7d..d9d8ef94e2d 100644 --- a/src/mame/video/wecleman.c +++ b/src/mame/video/wecleman.c @@ -106,7 +106,7 @@ static struct sprite *sprite_list_create(int num_sprites) static void get_sprite_info(running_machine *machine) { - const pen_t *base_pal = machine->remapped_colortable; + const pen_t *base_pal = machine->pens; UINT8 *base_gfx = memory_region(REGION_GFX1); int gfx_max = memory_region_length(REGION_GFX1); @@ -566,7 +566,7 @@ static void wecleman_draw_road(running_machine *machine, mame_bitmap *bitmap, co int scrollx, sy, sx; int mdy, tdy, i; - rgb_ptr = machine->remapped_colortable; + rgb_ptr = machine->pens; if (priority == 0x02) { @@ -683,7 +683,7 @@ static void draw_cloud(running_machine *machine, mame_bitmap *bitmap, dst_pitch = bitmap->rowpixels; dst_base = (UINT16 *)bitmap->base + (y0+dy)*dst_pitch + (x0+dx); - pal_base = machine->remapped_colortable + pal_offset * gfx->color_granularity; + pal_base = machine->pens + pal_offset * gfx->color_granularity; alpha <<= 6; @@ -1022,7 +1022,7 @@ VIDEO_UPDATE ( wecleman ) int cloud_sx, cloud_sy; int i, j, k; - mrct = machine->remapped_colortable; + mrct = machine->pens; video_on = wecleman_irqctrl & 0x40;