1942.c: colortables, you're doing it wrong (nw)

This commit is contained in:
Alex W. Jackson 2014-02-01 21:06:58 +00:00
parent 6707c2fef5
commit 491f77d5f9
2 changed files with 10 additions and 17 deletions

View File

@ -27,7 +27,6 @@ public:
tilemap_t *m_bg_tilemap; tilemap_t *m_bg_tilemap;
int m_palette_bank; int m_palette_bank;
UINT8 m_scroll[2]; UINT8 m_scroll[2];
rgb_t palette[256];
void create_palette(); void create_palette();
void palette_init_1942p(); void palette_init_1942p();
DECLARE_WRITE8_MEMBER(c1942p_palette_w); DECLARE_WRITE8_MEMBER(c1942p_palette_w);

View File

@ -29,6 +29,8 @@ void _1942_state::create_palette()
const UINT8 *color_prom = memregion("proms")->base(); const UINT8 *color_prom = memregion("proms")->base();
int i; int i;
machine().colortable = colortable_alloc(machine(), 256);
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
{ {
int bit0, bit1, bit2, bit3, r, g, b; int bit0, bit1, bit2, bit3, r, g, b;
@ -52,14 +54,12 @@ void _1942_state::create_palette()
bit3 = (color_prom[i + 2 * 256] >> 3) & 0x01; bit3 = (color_prom[i + 2 * 256] >> 3) & 0x01;
b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
palette[i] = MAKE_RGB(r,g,b); colortable_palette_set_color(machine().colortable,i,MAKE_RGB(r,g,b));
} }
} }
void _1942_state::palette_init() void _1942_state::palette_init()
{ {
machine().colortable = colortable_alloc(machine(), 0x600);
create_palette(); create_palette();
const UINT8 *color_prom = memregion("proms")->base(); const UINT8 *color_prom = memregion("proms")->base();
@ -72,30 +72,24 @@ void _1942_state::palette_init()
colorbase = 0; colorbase = 0;
for (i = 0; i < 64 * 4; i++) for (i = 0; i < 64 * 4; i++)
{ {
colortable_palette_set_color(machine().colortable, colorbase + i, palette[0x80 | *color_prom++]); colortable_entry_set_value(machine().colortable, colorbase + i, 0x80 | *color_prom++);
} }
colorbase += 64 * 4; colorbase += 64 * 4;
/* background tiles use palette entries 0-63 in four banks */ /* background tiles use palette entries 0-63 in four banks */
for (i = 0; i < 32 * 8; i++) for (i = 0; i < 32 * 8; i++)
{ {
colortable_palette_set_color(machine().colortable, colorbase + 0 * 32 * 8 + i, palette[0x00 | *color_prom]); colortable_entry_set_value(machine().colortable, colorbase + 0 * 32 * 8 + i, 0x00 | *color_prom);
colortable_palette_set_color(machine().colortable, colorbase + 1 * 32 * 8 + i, palette[0x10 | *color_prom]); colortable_entry_set_value(machine().colortable, colorbase + 1 * 32 * 8 + i, 0x10 | *color_prom);
colortable_palette_set_color(machine().colortable, colorbase + 2 * 32 * 8 + i, palette[0x20 | *color_prom]); colortable_entry_set_value(machine().colortable, colorbase + 2 * 32 * 8 + i, 0x20 | *color_prom);
colortable_palette_set_color(machine().colortable, colorbase + 3 * 32 * 8 + i, palette[0x30 | *color_prom]); colortable_entry_set_value(machine().colortable, colorbase + 3 * 32 * 8 + i, 0x30 | *color_prom);
color_prom++; color_prom++;
} }
colorbase += 4 * 32 * 8; colorbase += 4 * 32 * 8;
/* sprites use palette entries 64-79 */ /* sprites use palette entries 64-79 */
for (i = 0; i < 16 * 16; i++) for (i = 0; i < 16 * 16; i++)
colortable_palette_set_color(machine().colortable, colorbase + i, palette[0x40 | *color_prom++]); colortable_entry_set_value(machine().colortable, colorbase + i, 0x40 | *color_prom++);
for (i = 0; i < 0x600; i++)
{
colortable_entry_set_value(machine().colortable, i, i);
}
} }
void _1942_state::palette_init_1942p() void _1942_state::palette_init_1942p()
@ -196,7 +190,7 @@ WRITE8_MEMBER(_1942_state::c1942_palette_bank_w)
{ {
if (m_palette_bank != data) if (m_palette_bank != data)
{ {
m_palette_bank = data; m_palette_bank = data & 3;
m_bg_tilemap->mark_all_dirty(); m_bg_tilemap->mark_all_dirty();
} }
} }