From 4fea206b3afcebd311d44e3fc743af0167a31d18 Mon Sep 17 00:00:00 2001 From: Zsolt Vasvari Date: Mon, 18 Feb 2008 00:13:06 +0000 Subject: [PATCH] Color table removal --- src/mame/drivers/cave.c | 53 +++++++---------- src/mame/video/cave.c | 124 +++++++++++++++++++++++++--------------- 2 files changed, 100 insertions(+), 77 deletions(-) diff --git a/src/mame/drivers/cave.c b/src/mame/drivers/cave.c index 63179f14fcd..0465d6071f6 100644 --- a/src/mame/drivers/cave.c +++ b/src/mame/drivers/cave.c @@ -518,7 +518,7 @@ static ADDRESS_MAP_START( dfeveron_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x408000, 0x40ffff) AM_WRITE(MWA16_RAM ) // Sprites? AM_RANGE(0x500000, 0x507fff) AM_WRITE(cave_vram_0_w) AM_BASE(&cave_vram_0 ) // Layer 0 AM_RANGE(0x600000, 0x607fff) AM_WRITE(cave_vram_1_w) AM_BASE(&cave_vram_1 ) // Layer 1 - AM_RANGE(0x708000, 0x708fff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0x708000, 0x708fff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0x710c00, 0x710fff) AM_WRITE(MWA16_RAM ) // ? AM_RANGE(0x800000, 0x80007f) AM_WRITE(MWA16_RAM) AM_BASE(&cave_videoregs ) // Video Regs AM_RANGE(0x900000, 0x900005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_0 ) // Layer 0 Control @@ -562,7 +562,7 @@ static ADDRESS_MAP_START( ddonpach_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x900000, 0x900005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_0 ) // Layer 0 Control AM_RANGE(0xa00000, 0xa00005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_1 ) // Layer 1 Control AM_RANGE(0xb00000, 0xb00005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_2 ) // Layer 2 Control - AM_RANGE(0xc00000, 0xc0ffff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0xc00000, 0xc0ffff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0xe00000, 0xe00001) AM_WRITE(cave_eeprom_msb_w ) // EEPROM ADDRESS_MAP_END @@ -627,7 +627,7 @@ static ADDRESS_MAP_START( donpachi_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x700000, 0x700005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_0 ) // Layer 0 Control AM_RANGE(0x800000, 0x800005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_2 ) // Layer 2 Control AM_RANGE(0x900000, 0x90007f) AM_WRITE(MWA16_RAM) AM_BASE(&cave_videoregs ) // Video Regs - AM_RANGE(0xa08000, 0xa08fff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0xa08000, 0xa08fff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0xb00000, 0xb00003) AM_WRITE(OKIM6295_data_0_lsb_w ) // M6295 AM_RANGE(0xb00010, 0xb00013) AM_WRITE(OKIM6295_data_1_lsb_w ) // AM_RANGE(0xb00020, 0xb0002f) AM_WRITE(NMK112_okibank_lsb_w ) // @@ -670,7 +670,7 @@ static ADDRESS_MAP_START( esprade_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x900000, 0x900005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_0 ) // Layer 0 Control AM_RANGE(0xa00000, 0xa00005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_1 ) // Layer 1 Control AM_RANGE(0xb00000, 0xb00005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_2 ) // Layer 2 Control - AM_RANGE(0xc00000, 0xc0ffff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0xc00000, 0xc0ffff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0xe00000, 0xe00001) AM_WRITE(cave_eeprom_msb_w ) // EEPROM ADDRESS_MAP_END @@ -717,7 +717,7 @@ static ADDRESS_MAP_START( gaia_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x900000, 0x900005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_0 ) // Layer 0 Control AM_RANGE(0xa00000, 0xa00005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_1 ) // Layer 1 Control AM_RANGE(0xb00000, 0xb00005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_2 ) // Layer 2 Control - AM_RANGE(0xc00000, 0xc0ffff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0xc00000, 0xc0ffff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0xd00010, 0xd00011) AM_WRITE(gaia_coin_lsb_w ) // Coin counter only AM_RANGE(0xd00014, 0xd00015) AM_WRITE(watchdog_reset16_w ) // Watchdog? ADDRESS_MAP_END @@ -758,7 +758,7 @@ static ADDRESS_MAP_START( guwange_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x900000, 0x900005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_0 ) // Layer 0 Control AM_RANGE(0xa00000, 0xa00005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_1 ) // Layer 1 Control AM_RANGE(0xb00000, 0xb00005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_2 ) // Layer 2 Control - AM_RANGE(0xc00000, 0xc0ffff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0xc00000, 0xc0ffff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0xd00010, 0xd00011) AM_WRITE(cave_eeprom_lsb_w ) // EEPROM // AM_RANGE(0xd00012, 0xd00013) AM_WRITE(MWA16_NOP ) // ? // AM_RANGE(0xd00014, 0xd00015) AM_WRITE(MWA16_NOP ) // ? $800068 in dfeveron ? probably Watchdog @@ -790,7 +790,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( hotdogst_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x0fffff) AM_WRITE(MWA16_ROM ) // ROM AM_RANGE(0x300000, 0x30ffff) AM_WRITE(MWA16_RAM ) // RAM - AM_RANGE(0x408000, 0x408fff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0x408000, 0x408fff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0x880000, 0x887fff) AM_WRITE(cave_vram_0_w) AM_BASE(&cave_vram_0 ) // Layer 0 AM_RANGE(0x900000, 0x907fff) AM_WRITE(cave_vram_1_w) AM_BASE(&cave_vram_1 ) // Layer 1 AM_RANGE(0x980000, 0x987fff) AM_WRITE(cave_vram_2_w) AM_BASE(&cave_vram_2 ) // Layer 2 @@ -897,7 +897,7 @@ static ADDRESS_MAP_START( korokoro_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x140000, 0x140005) AM_WRITE( MWA16_RAM ) AM_BASE( &cave_vctrl_0 ) // Layer 0 Control AM_RANGE(0x180000, 0x187fff) AM_WRITE( MWA16_RAM ) AM_BASE( &spriteram16 ) AM_SIZE(&spriteram_size ) // Sprites AM_RANGE(0x1c0000, 0x1c007f) AM_WRITE( MWA16_RAM ) AM_BASE( &cave_videoregs ) // Video Regs - AM_RANGE(0x200000, 0x207fff) AM_WRITE( paletteram16_xGGGGGRRRRRBBBBB_word_w ) AM_BASE(&paletteram16) // Palette + AM_RANGE(0x200000, 0x207fff) AM_WRITE( MWA16_RAM ) AM_BASE(&paletteram16) // Palette AM_RANGE(0x240000, 0x240003) AM_WRITE( cave_sound_w ) // YMZ280 AM_RANGE(0x280008, 0x280009) AM_WRITE( korokoro_leds_w ) AM_RANGE(0x28000a, 0x28000b) AM_WRITE( korokoro_eeprom_msb_w ) // EEPROM @@ -940,7 +940,7 @@ static ADDRESS_MAP_START( mazinger_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x600000, 0x600005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_1 ) // Layer 1 Control AM_RANGE(0x700000, 0x700005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_0 ) // Layer 0 Control AM_RANGE(0x900000, 0x900001) AM_WRITE(cave_eeprom_msb_w ) // EEPROM - AM_RANGE(0xc08000, 0xc0ffff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0xc08000, 0xc0ffff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0xd00000, 0xd7ffff) AM_WRITE(MWA16_ROM ) // ROM ADDRESS_MAP_END @@ -977,7 +977,7 @@ static ADDRESS_MAP_START( metmqstr_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_WRITE(MWA16_ROM ) // ROM AM_RANGE(0x100000, 0x17ffff) AM_WRITE(MWA16_ROM ) // ROM AM_RANGE(0x200000, 0x27ffff) AM_WRITE(MWA16_ROM ) // ROM - AM_RANGE(0x408000, 0x408fff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0x408000, 0x408fff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0x880000, 0x887fff) AM_WRITE(cave_vram_2_w) AM_BASE(&cave_vram_2 ) // Layer 2 AM_RANGE(0x888000, 0x88ffff) AM_WRITE(MWA16_RAM ) // AM_RANGE(0x900000, 0x907fff) AM_WRITE(cave_vram_1_w) AM_BASE(&cave_vram_1 ) // Layer 1 @@ -1066,7 +1066,7 @@ static ADDRESS_MAP_START( pwrinst2_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0xc00000, 0xc00005) AM_WRITE(pwrinst2_vctrl_1_w) AM_BASE(&cave_vctrl_1 ) // Layer 1 Control AM_RANGE(0xc80000, 0xc80005) AM_WRITE(pwrinst2_vctrl_3_w) AM_BASE(&cave_vctrl_3 ) // Layer 3 Control AM_RANGE(0xe00000, 0xe00001) AM_WRITE(sound_cmd_w ) // To Sound CPU - AM_RANGE(0xf00000, 0xf04fff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0xf00000, 0xf04fff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette ADDRESS_MAP_END @@ -1126,7 +1126,7 @@ static ADDRESS_MAP_START( sailormn_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x110000, 0x110001) AM_WRITE(MWA16_RAM ) // (agallet) AM_RANGE(0x200000, 0x3fffff) AM_WRITE(MWA16_ROM ) // ROM AM_RANGE(0x400000, 0x407fff) AM_WRITE(MWA16_RAM ) // (agallet) - AM_RANGE(0x408000, 0x40bfff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0x408000, 0x40bfff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0x40c000, 0x40ffff) AM_WRITE(MWA16_RAM ) // (agallet) AM_RANGE(0x410000, 0x410001) AM_WRITE(MWA16_RAM ) // (agallet) AM_RANGE(0x500000, 0x507fff) AM_WRITE(MWA16_RAM) AM_BASE(&spriteram16) AM_SIZE(&spriteram_size ) // Sprites @@ -1172,7 +1172,7 @@ static ADDRESS_MAP_START( uopoko_writemem, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x500000, 0x507fff) AM_WRITE(cave_vram_0_w) AM_BASE(&cave_vram_0 ) // Layer 0 AM_RANGE(0x600000, 0x60007f) AM_WRITE(MWA16_RAM) AM_BASE(&cave_videoregs ) // Video Regs AM_RANGE(0x700000, 0x700005) AM_WRITE(MWA16_RAM) AM_BASE(&cave_vctrl_0 ) // Layer 0 Control - AM_RANGE(0x800000, 0x80ffff) AM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE(&paletteram16) // Palette + AM_RANGE(0x800000, 0x80ffff) AM_WRITE(MWA16_RAM) AM_BASE(&paletteram16) // Palette AM_RANGE(0xa00000, 0xa00001) AM_WRITE(cave_eeprom_msb_w ) // EEPROM ADDRESS_MAP_END @@ -2032,8 +2032,7 @@ static MACHINE_DRIVER_START( dfeveron ) MDRV_SCREEN_SIZE(320, 240) MDRV_SCREEN_VISIBLE_AREA(0, 320-1, 0, 240-1) MDRV_GFXDECODE(dfeveron) - MDRV_PALETTE_LENGTH(0x800) - MDRV_COLORTABLE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ + MDRV_PALETTE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ MDRV_PALETTE_INIT(dfeveron) MDRV_VIDEO_START(cave_2_layers) @@ -2072,8 +2071,7 @@ static MACHINE_DRIVER_START( ddonpach ) MDRV_SCREEN_SIZE(320, 240) MDRV_SCREEN_VISIBLE_AREA(0, 320-1, 0, 240-1) MDRV_GFXDECODE(ddonpach) - MDRV_PALETTE_LENGTH(0x8000) - MDRV_COLORTABLE_LENGTH(0x8000 + 0x40*16) // $400 extra entries for layers 1&2 + MDRV_PALETTE_LENGTH(0x8000 + 0x40*16) // $400 extra entries for layers 1&2 MDRV_PALETTE_INIT(ddonpach) MDRV_VIDEO_START(cave_3_layers) @@ -2112,8 +2110,7 @@ static MACHINE_DRIVER_START( donpachi ) MDRV_SCREEN_SIZE(320, 240) MDRV_SCREEN_VISIBLE_AREA(0, 320-1, 0, 240-1) MDRV_GFXDECODE(donpachi) - MDRV_PALETTE_LENGTH(0x800) - MDRV_COLORTABLE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ + MDRV_PALETTE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ MDRV_PALETTE_INIT(dfeveron) MDRV_VIDEO_START(cave_3_layers) @@ -2274,8 +2271,7 @@ static MACHINE_DRIVER_START( hotdogst ) MDRV_SCREEN_SIZE(384, 240) MDRV_SCREEN_VISIBLE_AREA(0, 384-1, 0, 240-1) MDRV_GFXDECODE(hotdogst) - MDRV_PALETTE_LENGTH(0x800) - MDRV_COLORTABLE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ + MDRV_PALETTE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ MDRV_PALETTE_INIT(dfeveron) MDRV_VIDEO_START(cave_3_layers) @@ -2325,8 +2321,7 @@ static MACHINE_DRIVER_START( korokoro ) MDRV_SCREEN_SIZE(320, 240) MDRV_SCREEN_VISIBLE_AREA(0, 320-1-2, 0, 240-1-1) MDRV_GFXDECODE(korokoro) - MDRV_PALETTE_LENGTH(0x4000) - MDRV_COLORTABLE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ + MDRV_PALETTE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ MDRV_PALETTE_INIT(korokoro) MDRV_VIDEO_START(cave_1_layer) @@ -2371,8 +2366,7 @@ static MACHINE_DRIVER_START( mazinger ) MDRV_SCREEN_SIZE(384, 240) MDRV_SCREEN_VISIBLE_AREA(0, 384-1, 0, 240-1) MDRV_GFXDECODE(mazinger) - MDRV_PALETTE_LENGTH(0x4000) - MDRV_COLORTABLE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ + MDRV_PALETTE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ MDRV_PALETTE_INIT(mazinger) MDRV_VIDEO_START(cave_2_layers) @@ -2428,8 +2422,7 @@ static MACHINE_DRIVER_START( metmqstr ) MDRV_SCREEN_SIZE(0x200, 240) MDRV_SCREEN_VISIBLE_AREA(0x7d, 0x7d + 0x180-1, 0, 240-1) MDRV_GFXDECODE(donpachi) - MDRV_PALETTE_LENGTH(0x800) - MDRV_COLORTABLE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ + MDRV_PALETTE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ MDRV_PALETTE_INIT(dfeveron) MDRV_VIDEO_START(cave_3_layers) @@ -2485,8 +2478,7 @@ static MACHINE_DRIVER_START( pwrinst2 ) MDRV_SCREEN_SIZE(0x200, 240) MDRV_SCREEN_VISIBLE_AREA(0x70, 0x70 + 0x140-1, 0, 240-1) MDRV_GFXDECODE(pwrinst2) - MDRV_PALETTE_LENGTH(0x5000/2) - MDRV_COLORTABLE_LENGTH(0x8000+0x2800) + MDRV_PALETTE_LENGTH(0x8000+0x2800) MDRV_PALETTE_INIT(pwrinst2) MDRV_VIDEO_START(cave_4_layers) @@ -2547,8 +2539,7 @@ static MACHINE_DRIVER_START( sailormn ) MDRV_SCREEN_SIZE(320+1, 240) MDRV_SCREEN_VISIBLE_AREA(0+1, 320+1-1, 0, 240-1) MDRV_GFXDECODE(sailormn) - MDRV_PALETTE_LENGTH(0x2000) - MDRV_COLORTABLE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ + MDRV_PALETTE_LENGTH(0x8000) /* $8000 palette entries for consistency with the other games */ MDRV_PALETTE_INIT(sailormn) // 4 bit sprites, 6 bit tiles MDRV_VIDEO_START(sailormn_3_layers) /* Layer 2 has 1 banked ROM */ diff --git a/src/mame/video/cave.c b/src/mame/video/cave.c index a6a0dcbded5..48dffe6ed28 100644 --- a/src/mame/video/cave.c +++ b/src/mame/video/cave.c @@ -62,13 +62,13 @@ UINT16 *cave_vram_3, *cave_vctrl_3; /* Variables only used here: */ static tilemap *tilemap_0; -static int tiledim_0, old_tiledim_0; +static int tiledim_0, old_tiledim_0; static tilemap *tilemap_1; -static int tiledim_1, old_tiledim_1; +static int tiledim_1, old_tiledim_1; static tilemap *tilemap_2; -static int tiledim_2, old_tiledim_2; +static int tiledim_2, old_tiledim_2; static tilemap *tilemap_3; -static int tiledim_3, old_tiledim_3; +static int tiledim_3, old_tiledim_3; @@ -137,83 +137,118 @@ PALETTE_INIT( dfeveron ) { int color, pen; + /* allocate the colortable */ + machine->colortable = colortable_alloc(machine, 0x0800); + /* Fill the 0-3fff range, used by sprites ($40 color codes * $100 pens) Here sprites have 16 pens, but the sprite drawing routine always multiplies the color code by $100 (for consistency). That's why we need this function. */ - for( color = 0; color < 0x40; color++ ) - for( pen = 0; pen < 16; pen++ ) - colortable[color * 256 + pen] = color * 16 + pen; + for (color = 0; color < 0x40; color++) + for (pen = 0; pen < 0x10; pen++) + colortable_entry_set_value(machine->colortable, (color << 8) | pen, (color << 4) | pen); } PALETTE_INIT( ddonpach ) { int color, pen; + /* allocate the colortable */ + machine->colortable = colortable_alloc(machine, 0x8000); + /* Fill the 8000-83ff range ($40 color codes * $10 pens) for layers 0 & 1 which are 4 bits deep rather than 8 bits deep like layer 2, but use the first 16 color of every 256 for any given color code. */ - for( color = 0; color < 0x40; color++ ) - for( pen = 0; pen < 16; pen++ ) - colortable[color * 16 + pen + 0x8000] = 0x4000 + color * 256 + pen; + for (color = 0; color < 0x40; color++) + for (pen = 0; pen < 0x10; pen++) + colortable_entry_set_value(machine->colortable, 0x8000 | (color << 4) | pen, 0x4000 | (color << 8) | pen); } PALETTE_INIT( mazinger ) { int color, pen; - /* Sprites (encrypted) are 4 bit deep */ - for( color = 0; color < 0x40; color++ ) - for( pen = 0; pen < 256; pen++ ) - colortable[color * 256 + pen] = color * 16 + pen; + /* allocate the colortable */ + machine->colortable = colortable_alloc(machine, 0x4000); - /* Layer 0 is 6 bit deep, there are 64 color codes but only $400 + /* sprites (encrypted) are 4 bit deep */ + for (color = 0; color < 0x40; color++) + for (pen = 0; pen < 0x100; pen++) + colortable_entry_set_value(machine->colortable, (color << 8) | pen, (color << 4) + pen); /* yes, PLUS, not OR */ + + /* layer 0 is 6 bit deep, there are 64 color codes but only $400 colors are actually addressable */ - for( color = 0; color < 0x40; color++ ) - for( pen = 0; pen < 64; pen++ ) - colortable[color * 64 + pen + 0x4400] = 0x400 + (color % (64/4)) * 64 + pen; + for (color = 0; color < 0x40; color++) + for (pen = 0; pen < 0x40; pen++) + colortable_entry_set_value(machine->colortable, 0x4400 | (color << 6) | pen, 0x400 | ((color & 0x0f) << 6) | pen); } PALETTE_INIT( sailormn ) { int color, pen; - /* Sprites (encrypted) are 4 bit deep */ - for( color = 0; color < 0x40; color++ ) - for( pen = 0; pen < 256; pen++ ) - colortable[color * 256 + pen] = color * 16 + pen; + /* allocate the colortable */ + machine->colortable = colortable_alloc(machine, 0x2000); - /* Layer 2 is 6 bit deep, there are 64 color codes but only $400 + /* sprites (encrypted) are 4 bit deep */ + for (color = 0; color < 0x40; color++) + for (pen = 0; pen < 0x100; pen++) + colortable_entry_set_value(machine->colortable, (color << 8) | pen, (color << 4) + pen); /* yes, PLUS, not OR */ + + /* layer 2 is 6 bit deep, there are 64 color codes but only $400 colors are actually addressable */ - for( color = 0; color < 0x40; color++ ) - for( pen = 0; pen < 64; pen++ ) - colortable[color * 64 + pen + 0x4c00] = 0xc00 + (color % (64/4)) * 64 + pen; + for (color = 0; color < 0x40; color++) + for (pen = 0; pen < 0x40; pen++) + colortable_entry_set_value(machine->colortable, 0x4c00 | (color << 6) | pen, 0xc00 | ((color & 0x0f) << 6) | pen); } PALETTE_INIT( pwrinst2 ) { int color, pen; - for( color = 0; color < 0x80; color++ ) - for( pen = 0; pen < 16; pen++ ) - colortable[color * 256 + pen] = color * 16 + pen; + /* allocate the colortable */ + machine->colortable = colortable_alloc(machine, 0x2800); - for( color = 0x8000; color < machine->drv->color_table_len; color++ ) - colortable[color] = (color - 0x8000) % machine->drv->total_colors; + for (color = 0; color < 0x80; color++) + for (pen = 0; pen < 0x10; pen++) + colortable_entry_set_value(machine->colortable, (color << 8) | pen, (color << 4) | pen); + + for (pen = 0x8000; pen < 0xa800; pen++) + colortable_entry_set_value(machine->colortable, pen, pen - 0x8000); } PALETTE_INIT( korokoro ) { int color, pen; - for( color = 0; color < 0x40; color++ ) - for( pen = 0; pen < 16; pen++ ) - colortable[color * 256 + pen] = 0x3c00 + color * 16 + pen; + /* allocate the colortable */ + machine->colortable = colortable_alloc(machine, 0x4000); + + for (color = 0; color < 0x40; color++) + for (pen = 0; pen < 0x10; pen++) + colortable_entry_set_value(machine->colortable, (color << 8) | pen, 0x3c00 | (color << 4) | pen); } + +static void set_pens(colortable_t *colortable) +{ + offs_t i; + int palette_size = colortable_palette_get_size(colortable); + + for (i = 0; i < palette_size; i++) + { + UINT16 data = paletteram16[i]; + + rgb_t color = MAKE_RGB(pal5bit(data >> 5), pal5bit(data >> 10), pal5bit(data >> 0)); + + colortable_palette_set_color(colortable, i, color); + } +} + + /*************************************************************************** Tiles Format @@ -409,29 +444,25 @@ static void cave_vh_start(running_machine *machine, int num) switch( num ) { case 4: - tilemap_3 = tilemap_create( get_tile_info_3, tilemap_scan_rows, - 8,8, 512/8,512/8 ); + tilemap_3 = tilemap_create( get_tile_info_3, tilemap_scan_rows, 8,8, 512/8,512/8 ); tilemap_set_transparent_pen(tilemap_3, 0); tilemap_set_scroll_rows(tilemap_3, 1); tilemap_set_scroll_cols(tilemap_3, 1); case 3: - tilemap_2 = tilemap_create( get_tile_info_2, tilemap_scan_rows, - 8,8, 512/8,512/8 ); + tilemap_2 = tilemap_create( get_tile_info_2, tilemap_scan_rows, 8,8, 512/8,512/8 ); tilemap_set_transparent_pen(tilemap_2, 0); tilemap_set_scroll_rows(tilemap_2, 1); tilemap_set_scroll_cols(tilemap_2, 1); case 2: - tilemap_1 = tilemap_create( get_tile_info_1, tilemap_scan_rows, - 8,8, 512/8,512/8 ); + tilemap_1 = tilemap_create( get_tile_info_1, tilemap_scan_rows, 8,8, 512/8,512/8 ); tilemap_set_transparent_pen(tilemap_1, 0); tilemap_set_scroll_rows(tilemap_1, 1); tilemap_set_scroll_cols(tilemap_1, 1); case 1: - tilemap_0 = tilemap_create( get_tile_info_0, tilemap_scan_rows, - 8,8, 512/8,512/8 ); + tilemap_0 = tilemap_create( get_tile_info_0, tilemap_scan_rows, 8,8, 512/8,512/8 ); tilemap_set_transparent_pen(tilemap_0, 0); tilemap_set_scroll_rows(tilemap_0, 1); tilemap_set_scroll_cols(tilemap_0, 1); @@ -447,7 +478,6 @@ static void cave_vh_start(running_machine *machine, int num) cave_row_effect_offs_n = -1; cave_row_effect_offs_f = 1; -// background_color = machine->drv->gfxdecodeinfo[0].color_codes_start; background_color = machine->drv->gfxdecodeinfo[0].color_codes_start + (machine->drv->gfxdecodeinfo[0].total_color_codes-1) * machine->gfx[0]->color_granularity; @@ -521,7 +551,7 @@ static void get_sprite_info_cave(running_machine *machine) { const int region = REGION_GFX1; - const pen_t *base_pal = machine->remapped_colortable + 0; + const pen_t *base_pal = machine->pens + 0; const UINT8 *base_gfx = memory_region(region); int code_max = memory_region_length(region) / (16*16); @@ -642,7 +672,7 @@ static void get_sprite_info_donpachi(running_machine *machine) { const int region = REGION_GFX1; - const pen_t *base_pal = machine->remapped_colortable + 0; + const pen_t *base_pal = machine->pens + 0; const UINT8 *base_gfx = memory_region(region); int code_max = memory_region_length(region) / (16*16); @@ -1406,6 +1436,8 @@ VIDEO_UPDATE( cave ) int pri, pri2; int layers_ctrl = -1; + set_pens(machine->colortable); + blit.baseaddr = bitmap->base; blit.line_offset = bitmap->rowpixels * bitmap->bpp / 8; @@ -1490,7 +1522,7 @@ VIDEO_UPDATE( cave ) cave_sprite_check(machine, cliprect); - fillbitmap(bitmap,machine->remapped_colortable[background_color],cliprect); + fillbitmap(bitmap,machine->pens[background_color],cliprect); /* Tiles and sprites are ordered by priority (0 back, 3 front) with