fix out of bounds array access during astrowar boot

This commit is contained in:
Michaël Banaan Ananas 2012-03-27 00:38:12 +00:00
parent 6e34740603
commit fd66104ca6

View File

@ -60,35 +60,51 @@ PALETTE_INIT( astrowar )
palette_set_color_rgb(machine, BULLET_PEN, pal1bit(1), pal1bit(1), pal1bit(0)); palette_set_color_rgb(machine, BULLET_PEN, pal1bit(1), pal1bit(1), pal1bit(0));
} }
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_galaxia_bg_tile_info )
{
galaxia_state *state = machine.driver_data<galaxia_state>();
UINT8 code = state->m_video_ram[tile_index] & 0x7f; // d7 unused
UINT8 color = state->m_color_ram[tile_index] & 3; // highest bits unused
SET_TILE_INFO(0, code, color, 0);
}
static TILE_GET_INFO( get_astrowar_bg_tile_info )
{ {
galaxia_state *state = machine.driver_data<galaxia_state>(); galaxia_state *state = machine.driver_data<galaxia_state>();
UINT8 code = state->m_video_ram[tile_index]; UINT8 code = state->m_video_ram[tile_index];
UINT8 color = state->m_color_ram[tile_index]; // highest bits unused UINT8 color = state->m_color_ram[tile_index] & 7; // highest bits unused
SET_TILE_INFO(0, code, color, 0); SET_TILE_INFO(0, code, color, 0);
} }
static void init_common( running_machine &machine )
{
assert((STAR_PEN & 7) == 0);
cvs_init_stars(machine);
}
VIDEO_START( galaxia ) VIDEO_START( galaxia )
{ {
galaxia_state *state = machine.driver_data<galaxia_state>(); galaxia_state *state = machine.driver_data<galaxia_state>();
init_common(machine);
assert((STAR_PEN & 7) == 0); state->m_bg_tilemap = tilemap_create(machine, get_galaxia_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->m_bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->m_bg_tilemap->set_transparent_pen(0); state->m_bg_tilemap->set_transparent_pen(0);
state->m_bg_tilemap->set_scroll_cols(8); state->m_bg_tilemap->set_scroll_cols(8);
cvs_init_stars(machine);
} }
VIDEO_START( astrowar ) VIDEO_START( astrowar )
{ {
VIDEO_START_CALL(galaxia);
galaxia_state *state = machine.driver_data<galaxia_state>(); galaxia_state *state = machine.driver_data<galaxia_state>();
init_common(machine);
state->m_bg_tilemap = tilemap_create(machine, get_astrowar_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->m_bg_tilemap->set_transparent_pen(0);
state->m_bg_tilemap->set_scroll_cols(8);
state->m_bg_tilemap->set_scrolldx(8, 8); state->m_bg_tilemap->set_scrolldx(8, 8);
machine.primary_screen->register_screen_bitmap(state->m_temp_bitmap); machine.primary_screen->register_screen_bitmap(state->m_temp_bitmap);
} }