- Scooter Shooter -- color table removal

- Unified transparency handling in these games running on very similar hardware
This commit is contained in:
Zsolt Vasvari 2008-02-06 11:37:51 +00:00
parent 897ea4b0b5
commit e18344a0e7
4 changed files with 33 additions and 98 deletions

View File

@ -242,8 +242,7 @@ static MACHINE_DRIVER_START( scotrsht )
MDRV_SCREEN_SIZE(32*8, 32*8)
MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
MDRV_GFXDECODE(scotrsht)
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(scotrsht)
MDRV_VIDEO_START(scotrsht)

View File

@ -10,61 +10,33 @@ static int scotrsht_palette_bank = 0;
PALETTE_INIT( scotrsht )
{
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])
/* allocate the colortable */
machine->colortable = colortable_alloc(machine, 0x100);
for (i = 0;i < machine->drv->total_colors;i++)
/* create a lookup table for the palette */
for (i = 0; i < 0x100; i++)
{
int bit0,bit1,bit2,bit3,r,g,b;
int r = pal4bit(color_prom[i + 0x000]);
int g = pal4bit(color_prom[i + 0x100]);
int b = pal4bit(color_prom[i + 0x200]);
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;
palette_set_color(machine,i,MAKE_RGB(r,g,b));
color_prom++;
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 16 colors palette banks; sprites use colors 0x00-0x7f and */
/* characters 0x80-0xff. */
for (i = 0;i < TOTAL_COLORS(0)/8;i++)
/* characters use colors 0x80-0xff, sprites use colors 0-0x7f */
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) + 16 * j + 0x80;
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) + 16 * j;
color_prom++;
for (j = 0; j < 8; j++)
{
UINT8 ctabentry = ((~i & 0x100) >> 1) | (j << 4) | (color_prom[i] & 0x0f);
colortable_entry_set_value(machine->colortable, ((i & 0x100) << 3) | (j << 8) | (i & 0xff), ctabentry);
}
}
}
@ -145,7 +117,8 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const re
}
drawgfx(bitmap, machine->gfx[1], code, color, flipx, flipy,
sx, sy, cliprect, TRANSPARENCY_COLOR, scotrsht_palette_bank * 16);
sx, sy, cliprect, TRANSPARENCY_PENS,
colortable_get_transpen_mask(machine->colortable, machine->gfx[1], color, scotrsht_palette_bank * 16));
}
}

View File

@ -74,37 +74,19 @@ PALETTE_INIT( shaolins )
colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
}
/* color_prom now points to the beginning of the lookup table */
/* color_prom now points to the beginning of the lookup table,*/
color_prom += 0x300;
/* characters use colors 0x10-0x1f of each 0x20 color bank */
for (i = 0; i < 0x100; 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++)
{
UINT8 ctabentry = (j << 5) | 0x10 | (color_prom[i] & 0x0f);
colortable_entry_set_value(machine->colortable, (j << 8) | i, ctabentry);
}
}
/* characters use colors 0-0x0f of each 0x20 color bank */
for (i = 0x100; i < 0x200; i++)
{
int j;
for (j = 0; j < 8; j++)
{
UINT8 ctabentry;
if ((color_prom[i] & 0x0f))
ctabentry = (j << 5) | (color_prom[i] & 0x0f);
else
/* preserve transparency */
ctabentry = 0;
colortable_entry_set_value(machine->colortable, 0x800 | (j << 8) | (i & 0xff), ctabentry);
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);
}
}
}
@ -176,7 +158,7 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const re
if (spriteram[offs] && spriteram[offs + 6]) /* stop rogue sprites on high score screen */
{
int code = spriteram[offs + 8];
int color = (spriteram[offs + 9] & 0x0f) + 16 * palettebank;
int color = (spriteram[offs + 9] & 0x0f) | (palettebank << 4);
int flipx = !(spriteram[offs + 9] & 0x40);
int flipy = spriteram[offs + 9] & 0x80;
int sx = 240 - spriteram[offs + 6];
@ -195,7 +177,7 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const re
flipx, flipy,
sx, sy,
cliprect,TRANSPARENCY_PENS,
colortable_get_transpen_mask(machine->colortable, machine->gfx[1], color, 0));
colortable_get_transpen_mask(machine->colortable, machine->gfx[1], color, palettebank << 5));
}
}
}

View File

@ -98,34 +98,15 @@ PALETTE_INIT( tp84 )
/* color_prom now points to the beginning of the lookup table */
color_prom += 0x300;
/* characters use colors 0x80-0xff */
for (i = 0; i < 0x100; i++)
/* characters use colors 0x80-0xff, sprites use colors 0-0x7f */
for (i = 0; i < 0x200; i++)
{
int j;
for (j = 0; j < 8; j++)
{
UINT8 ctabentry = 0x80 | (j << 4) | (color_prom[i] & 0x0f);
colortable_entry_set_value(machine->colortable, (j << 8) | i, ctabentry);
}
}
/* sprites use colors 0-0x7f */
for (i = 0x100; i < 0x200; i++)
{
int j;
for (j = 0; j < 8; j++)
{
UINT8 ctabentry;
if ((color_prom[i] & 0x0f))
ctabentry = (j << 4) | (color_prom[i] & 0x0f);
else
/* preserve transparency */
ctabentry = 0;
colortable_entry_set_value(machine->colortable, 0x800 | (j << 8) | (i & 0xff), ctabentry);
UINT8 ctabentry = ((~i & 0x100) >> 1) | (j << 4) | (color_prom[i] & 0x0f);
colortable_entry_set_value(machine->colortable, ((i & 0x100) << 3) | (j << 8) | (i & 0xff), ctabentry);
}
}
}
@ -263,7 +244,7 @@ static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const re
flipx,flipy,
sx,sy,
&clip,TRANSPARENCY_PENS,
colortable_get_transpen_mask(machine->colortable, gfx, color, 0));
colortable_get_transpen_mask(machine->colortable, gfx, color, coloffset));
}
}
}