Color table removal

This commit is contained in:
Zsolt Vasvari 2008-02-13 02:45:16 +00:00
parent 72fa930e78
commit 42ddf4508b
7 changed files with 83 additions and 79 deletions

View File

@ -413,8 +413,7 @@ static MACHINE_DRIVER_START( ironhors )
MDRV_SCREEN_SIZE(32*8, 32*8)
MDRV_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 2*8, 30*8-1)
MDRV_GFXDECODE(ironhors)
MDRV_PALETTE_LENGTH(256)
MDRV_COLORTABLE_LENGTH(16*8*16+16*8*16)
MDRV_PALETTE_LENGTH(16*8*16+16*8*16)
MDRV_PALETTE_INIT(ironhors)
MDRV_VIDEO_START(ironhors)

View File

@ -9,7 +9,7 @@ Notes:
that the two 4bpp tilemaps from the two chips are merged to form a single
8bpp tilemap.
- topgunbl is derived from a completely different version, which supports gun
turret rotation. The copyright year is also deiffrent, but this doesn't
turret rotation. The copyright year is also different, but this doesn't
necessarily mean anything.
TODO:
@ -85,7 +85,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( slave_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x2000, 0x2000) AM_WRITE(YM2151_register_port_0_w)
AM_RANGE(0x2001, 0x2001) AM_READWRITE(YM2151_status_port_0_r, YM2151_data_port_0_w)
AM_RANGE(0x4000, 0x43ff) AM_RAM AM_WRITE(paletteram_xBBBBBGGGGGRRRRR_le_w) AM_BASE(&paletteram) // COLOR RAM (Self test only check 0x4000-0x423f)
AM_RANGE(0x4000, 0x43ff) AM_RAM AM_WRITE(MWA8_RAM) AM_BASE(&paletteram) // self test only checks 0x4000-0x423f)
AM_RANGE(0x6000, 0x605f) AM_RAM // SOUND RAM (Self test check 0x6000-605f, 0x7c00-0x7fff)
AM_RANGE(0x6060, 0x7fff) AM_RAM AM_SHARE(1)
AM_RANGE(0x8000, 0xffff) AM_ROM
@ -276,8 +276,7 @@ static MACHINE_DRIVER_START( jackal )
MDRV_SCREEN_SIZE(32*8, 32*8)
MDRV_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 2*8, 30*8-1)
MDRV_GFXDECODE(jackal)
MDRV_PALETTE_LENGTH(512)
MDRV_COLORTABLE_LENGTH(256*16+16*16+16*16)
MDRV_PALETTE_LENGTH(256*16+16*16+16*16)
MDRV_PALETTE_INIT(jackal)
MDRV_VIDEO_START(jackal)

View File

@ -462,7 +462,6 @@ static MACHINE_DRIVER_START( kchampvs )
MDRV_SCREEN_VISIBLE_AREA(0, 32*8-1, 2*8, 30*8-1)
MDRV_GFXDECODE(kchamp)
MDRV_PALETTE_LENGTH(256)
MDRV_COLORTABLE_LENGTH(256)
MDRV_PALETTE_INIT(kchamp)
MDRV_VIDEO_START(kchamp)
@ -511,7 +510,6 @@ static MACHINE_DRIVER_START( kchamp )
MDRV_SCREEN_VISIBLE_AREA(0, 32*8-1, 2*8, 30*8-1)
MDRV_GFXDECODE(kchamp)
MDRV_PALETTE_LENGTH(256)
MDRV_COLORTABLE_LENGTH(256)
MDRV_PALETTE_INIT(kchamp)
MDRV_VIDEO_START(kchamp)

View File

@ -7,6 +7,7 @@
***************************************************************************/
#include "driver.h"
#include "video/resnet.h"
UINT8 *ironhors_scroll;
static int palettebank, charbank, spriterambank;
@ -17,75 +18,66 @@ static tilemap *bg_tilemap;
Convert the color PROMs into a more useable format.
Iron Horse has three 256x4 palette PROMs (one per gun) and two 256x4
lookup table PROMs (one for characters, one for sprites).
I don't know for sure how the palette PROMs are connected to the RGB
output, but it's probably the usual:
bit 3 -- 220 ohm resistor -- RED/GREEN/BLUE
-- 470 ohm resistor -- RED/GREEN/BLUE
-- 1 kohm resistor -- RED/GREEN/BLUE
bit 0 -- 2.2kohm resistor -- RED/GREEN/BLUE
***************************************************************************/
PALETTE_INIT( ironhors )
{
static const int resistances[4] = { 2000, 1000, 470, 220 };
double rweights[4], gweights[4], bweights[4];
int i;
#define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity)
#define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
/* compute the color output resistor weights */
compute_resistor_weights(0, 255, -1.0,
4, resistances, rweights, 1000, 0,
4, resistances, gweights, 1000, 0,
4, resistances, bweights, 1000, 0);
for (i = 0;i < machine->drv->total_colors;i++)
/* allocate the colortable */
machine->colortable = colortable_alloc(machine, 0x100);
/* create a lookup table for the palette */
for (i = 0; i < 0x100; i++)
{
int bit0,bit1,bit2,bit3,r,g,b;
int bit0, bit1, bit2, bit3;
int r, g, b;
/* red component */
bit0 = (color_prom[i + 0x000] >> 0) & 0x01;
bit1 = (color_prom[i + 0x000] >> 1) & 0x01;
bit2 = (color_prom[i + 0x000] >> 2) & 0x01;
bit3 = (color_prom[i + 0x000] >> 3) & 0x01;
r = combine_4_weights(rweights, bit0, bit1, bit2, bit3);
bit0 = (color_prom[0] >> 0) & 0x01;
bit1 = (color_prom[0] >> 1) & 0x01;
bit2 = (color_prom[0] >> 2) & 0x01;
bit3 = (color_prom[0] >> 3) & 0x01;
r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
bit0 = (color_prom[machine->drv->total_colors] >> 0) & 0x01;
bit1 = (color_prom[machine->drv->total_colors] >> 1) & 0x01;
bit2 = (color_prom[machine->drv->total_colors] >> 2) & 0x01;
bit3 = (color_prom[machine->drv->total_colors] >> 3) & 0x01;
g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
bit0 = (color_prom[2*machine->drv->total_colors] >> 0) & 0x01;
bit1 = (color_prom[2*machine->drv->total_colors] >> 1) & 0x01;
bit2 = (color_prom[2*machine->drv->total_colors] >> 2) & 0x01;
bit3 = (color_prom[2*machine->drv->total_colors] >> 3) & 0x01;
b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
/* green component */
bit0 = (color_prom[i + 0x100] >> 0) & 0x01;
bit1 = (color_prom[i + 0x100] >> 1) & 0x01;
bit2 = (color_prom[i + 0x100] >> 2) & 0x01;
bit3 = (color_prom[i + 0x100] >> 3) & 0x01;
g = combine_4_weights(gweights, bit0, bit1, bit2, bit3);
palette_set_color(machine,i,MAKE_RGB(r,g,b));
color_prom++;
/* blue component */
bit0 = (color_prom[i + 0x200] >> 0) & 0x01;
bit1 = (color_prom[i + 0x200] >> 1) & 0x01;
bit2 = (color_prom[i + 0x200] >> 2) & 0x01;
bit3 = (color_prom[i + 0x200] >> 3) & 0x01;
b = combine_4_weights(bweights, bit0, bit1, bit2, bit3);
colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
}
color_prom += 2*machine->drv->total_colors;
/* color_prom now points to the beginning of the character lookup table */
/* color_prom now points to the beginning of the lookup table,*/
color_prom += 0x300;
/* there are eight 32 colors palette banks; sprites use colors 0-15 and */
/* characters 16-31 of each bank. */
for (i = 0;i < TOTAL_COLORS(0)/8;i++)
/* characters use colors 0x10-0x1f of each 0x20 color bank,
while sprites use colors 0-0x0f */
for (i = 0; i < 0x200; i++)
{
int j;
for (j = 0;j < 8;j++)
COLOR(0,i + j * TOTAL_COLORS(0)/8) = (*color_prom & 0x0f) + 32 * j + 16;
color_prom++;
}
for (i = 0;i < TOTAL_COLORS(1)/8;i++)
{
int j;
for (j = 0;j < 8;j++)
COLOR(1,i + j * TOTAL_COLORS(1)/8) = (*color_prom & 0x0f) + 32 * j;
color_prom++;
for (j = 0; j < 8; j++)
{
UINT8 ctabentry = (j << 5) | ((~i & 0x100) >> 4) | (color_prom[i] & 0x0f);
colortable_entry_set_value(machine->colortable, ((i & 0x100) << 3) | (j << 8) | (i & 0xff), ctabentry);
}
}
}

View File

@ -19,30 +19,50 @@ static tilemap *bg_tilemap;
PALETTE_INIT( jackal )
{
int i;
#define TOTAL_COLORS(gfxn) (machine->gfx[gfxn]->total_colors * machine->gfx[gfxn]->color_granularity)
#define COLOR(gfxn,offs) (colortable[machine->drv->gfxdecodeinfo[gfxn].color_codes_start + offs])
for (i = 0;i < TOTAL_COLORS(0);i++)
/* allocate the colortable */
machine->colortable = colortable_alloc(machine, 0x200);
for (i = 0; i < 0x1000; i++)
{
COLOR(0,i) = (i & 0xff) + 256;
UINT16 ctabentry = (i & 0xff) | 0x100;
/* this is surely wrong - is there a PROM missing? */
if (i & 0x0f)
COLOR(0,i) |= i/256;
ctabentry = ctabentry | (i >> 8);
colortable_entry_set_value(machine->colortable, i, ctabentry);
}
for (i = 0;i < TOTAL_COLORS(1);i++)
for (i = 0x1000; i < 0x1100; i++)
{
COLOR(1,i) = (*color_prom & 0x0f);
color_prom++;
UINT8 ctabentry = color_prom[i - 0x1000] & 0x0f;
colortable_entry_set_value(machine->colortable, i, ctabentry);
}
for (i = 0;i < TOTAL_COLORS(3);i++)
for (i = 0x1100; i < 0x1200; i++)
{
COLOR(3,i) = (*color_prom & 0x0f) + 16;
color_prom++;
UINT8 ctabentry = (color_prom[i - 0x1100] & 0x0f) | 0x10;
colortable_entry_set_value(machine->colortable, i, ctabentry);
}
}
static void set_pens(running_machine *machine)
{
int i;
for (i = 0; i < 0x400; i += 2)
{
UINT16 data = paletteram[i] | (paletteram[i | 1] << 8);
rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
colortable_palette_set_color(machine->colortable, i >> 1, color);
}
}
void jackal_mark_tile_dirty(int offset)
{
tilemap_mark_tile_dirty(bg_tilemap, offset);
@ -62,8 +82,7 @@ static TILE_GET_INFO( get_bg_tile_info )
VIDEO_START( jackal )
{
bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows,
8, 8, 32, 32);
bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
}
static void draw_background( mame_bitmap *bitmap, const rectangle *cliprect )
@ -86,9 +105,7 @@ static void draw_background( mame_bitmap *bitmap, const rectangle *cliprect )
tilemap_set_scroll_rows(bg_tilemap, 32);
for (i = 0; i < 32; i++)
{
tilemap_set_scrollx(bg_tilemap, i, jackal_scrollram[i]);
}
}
if (jackal_videoctrl[2] & 0x04)
@ -211,6 +228,7 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const re
VIDEO_UPDATE( jackal )
{
set_pens(machine);
draw_background(bitmap, cliprect);
draw_sprites(machine, bitmap, cliprect);
return 0;

View File

@ -21,8 +21,6 @@ PALETTE_INIT( kchamp )
blue = color_prom[2*machine->drv->total_colors+i];
palette_set_color_rgb(machine,i,pal4bit(red),pal4bit(green),pal4bit(blue));
*(colortable++) = i;
}
}

View File

@ -31,7 +31,7 @@ static tilemap *bg_tilemap;
***************************************************************************/
PALETTE_INIT( shaolins )
{
static const int resistances[4] = { 1000, 470, 220, 100 };
static const int resistances[4] = { 2200, 1000, 470, 220 };
double rweights[4], gweights[4], bweights[4];
int i;