neogeo.c: removed some more tagmap lookups. (nw)

This commit is contained in:
Wilbert Pol 2013-02-10 15:11:26 +00:00
parent 6852552362
commit 60392e44df
3 changed files with 32 additions and 24 deletions

View File

@ -1309,6 +1309,7 @@ DEVICE_IMAGE_LOAD_MEMBER( neogeo_state, neo_cartridge )
machine().memory().region_free(":fixed");
machine().memory().region_alloc(":fixed",size,1, ENDIANNESS_LITTLE);
memcpy(memregion("fixed")->base(),image.get_software_region("fixed"),size);
m_region_fixed.findit();
if(image.get_software_region("audiocpu") != NULL)
{
@ -1338,6 +1339,8 @@ DEVICE_IMAGE_LOAD_MEMBER( neogeo_state, neo_cartridge )
machine().memory().region_free(":sprites");
machine().memory().region_alloc(":sprites",size,1, ENDIANNESS_LITTLE);
memcpy(machine().root_device().memregion("sprites")->base(),image.get_software_region("sprites"),size);
// Reset the reference to the region
m_region_sprites.findit();
if(image.get_software_region("audiocrypt") != NULL) // encrypted Z80 code
{
size = image.get_software_region_length("audiocrypt");

View File

@ -42,6 +42,9 @@ public:
, m_audiocpu(*this, "audiocpu")
, m_upd4990a(*this, "upd4990a")
, m_region_maincpu(*this, "maincpu")
, m_region_sprites(*this, "sprites")
, m_region_fixed(*this, "fixed")
, m_region_fixedbios(*this, "fixedbios")
, m_bank_vectors(*this, NEOGEO_BANK_VECTORS)
, m_bank_bios(*this, NEOGEO_BANK_BIOS)
, m_bank_cartridge(*this, NEOGEO_BANK_CARTRIDGE)
@ -262,6 +265,9 @@ public:
protected:
required_memory_region m_region_maincpu;
required_memory_region m_region_sprites;
required_memory_region m_region_fixed;
required_memory_region m_region_fixedbios;
required_memory_bank m_bank_vectors;
required_memory_bank m_bank_bios;
optional_memory_bank m_bank_cartridge; // optional because of neocd
@ -283,6 +289,8 @@ protected:
void _set_audio_cpu_rom_source();
void set_audio_cpu_rom_source( UINT8 data );
void _set_main_cpu_vector_table_source();
void optimize_sprite_data();
void draw_fixed_layer( bitmap_rgb32 &bitmap, int scanline );
};

View File

@ -264,31 +264,30 @@ void neogeo_set_fixed_layer_source( running_machine &machine, UINT8 data )
}
static void draw_fixed_layer( running_machine &machine, bitmap_rgb32 &bitmap, int scanline )
void neogeo_state::draw_fixed_layer( bitmap_rgb32 &bitmap, int scanline )
{
neogeo_state *state = machine.driver_data<neogeo_state>();
int x;
UINT8* gfx_base = state->memregion(state->m_fixed_layer_source ? "fixed" : "fixedbios")->base();
UINT32 addr_mask = state->memregion(state->m_fixed_layer_source ? "fixed" : "fixedbios")->bytes() - 1;
UINT16 *video_data = &state->m_videoram[0x7000 | (scanline >> 3)];
UINT8* gfx_base = m_fixed_layer_source ? m_region_fixed->base() : m_region_fixedbios->base();
UINT32 addr_mask = ( m_fixed_layer_source ? m_region_fixed->bytes() : m_region_fixedbios->bytes() ) - 1;
UINT16 *video_data = &m_videoram[0x7000 | (scanline >> 3)];
UINT32 *pixel_addr = &bitmap.pix32(scanline, NEOGEO_HBEND);
int garouoffsets[32];
int banked = state->m_fixed_layer_source && (addr_mask > 0x1ffff);
int banked = m_fixed_layer_source && (addr_mask > 0x1ffff);
/* thanks to Mr K for the garou & kof2000 banking info */
/* Build line banking table for Garou & MS3 before starting render */
if (banked && state->m_fixed_layer_bank_type == 1)
if (banked && m_fixed_layer_bank_type == 1)
{
int garoubank = 0;
int k = 0;
int y = 0;
while (y < 32)
{
if (state->m_videoram[0x7500 + k] == 0x0200 && (state->m_videoram[0x7580 + k] & 0xff00) == 0xff00)
if (m_videoram[0x7500 + k] == 0x0200 && (m_videoram[0x7580 + k] & 0xff00) == 0xff00)
{
garoubank = state->m_videoram[0x7580 + k] & 3;
garoubank = m_videoram[0x7580 + k] & 3;
garouoffsets[y++] = garoubank;
}
garouoffsets[y++] = garoubank;
@ -304,14 +303,14 @@ static void draw_fixed_layer( running_machine &machine, bitmap_rgb32 &bitmap, in
if (banked)
{
int y = scanline >> 3;
switch (state->m_fixed_layer_bank_type)
switch (m_fixed_layer_bank_type)
{
case 1:
/* Garou, MSlug 3 */
code += 0x1000 * (garouoffsets[(y - 2) & 31] ^ 3);
break;
case 2:
code += 0x1000 * (((state->m_videoram[0x7500 + ((y - 1) & 31) + 32 * (x / 6)] >> (5 - (x % 6)) * 2) & 3) ^ 3);
code += 0x1000 * (((m_videoram[0x7500 + ((y - 1) & 31) + 32 * (x / 6)] >> (5 - (x % 6)) * 2) & 3) ^ 3);
break;
}
}
@ -321,7 +320,7 @@ static void draw_fixed_layer( running_machine &machine, bitmap_rgb32 &bitmap, in
int i;
UINT8 *gfx = &gfx_base[((code << 5) | (scanline & 0x07)) & addr_mask];
pen_t *char_pens = &state->m_pens[code_and_palette >> 12 << 4];
pen_t *char_pens = &m_pens[code_and_palette >> 12 << 4];
for (i = 0; i < 4; i++)
{
@ -670,10 +669,8 @@ static void start_sprite_line_timer( running_machine &machine )
}
static void optimize_sprite_data( running_machine &machine )
void neogeo_state::optimize_sprite_data()
{
neogeo_state *state = machine.driver_data<neogeo_state>();
/* convert the sprite graphics data into a format that
allows faster blitting */
int i;
@ -684,22 +681,22 @@ static void optimize_sprite_data( running_machine &machine )
/* get mask based on the length rounded up to the nearest
power of 2 */
state->m_sprite_gfx_address_mask = 0xffffffff;
m_sprite_gfx_address_mask = 0xffffffff;
len = state->memregion("sprites")->bytes();
len = m_region_sprites->bytes();
for (bit = 0x80000000; bit != 0; bit >>= 1)
{
if (((len * 2) - 1) & bit)
break;
state->m_sprite_gfx_address_mask >>= 1;
m_sprite_gfx_address_mask >>= 1;
}
state->m_sprite_gfx = auto_alloc_array_clear(machine, UINT8, state->m_sprite_gfx_address_mask + 1);
m_sprite_gfx = auto_alloc_array_clear(machine(), UINT8, m_sprite_gfx_address_mask + 1);
src = machine.root_device().memregion("sprites")->base();
dest = state->m_sprite_gfx;
src = m_region_sprites->base();
dest = m_sprite_gfx;
for (i = 0; i < len; i += 0x80, src += 0x80)
{
@ -859,7 +856,7 @@ void neogeo_state::video_start()
compute_rgb_weights(machine());
create_sprite_line_timer(machine());
create_auto_animation_timer(machine());
optimize_sprite_data(machine());
optimize_sprite_data();
/* initialize values that are not modified on a reset */
m_videoram_read_buffer = 0;
@ -902,7 +899,7 @@ void neogeo_state::video_reset()
{
start_sprite_line_timer(machine());
start_auto_animation_timer(machine());
optimize_sprite_data(machine());
optimize_sprite_data();
}
@ -920,7 +917,7 @@ UINT32 neogeo_state::screen_update_neogeo(screen_device &screen, bitmap_rgb32 &b
if (m_has_sprite_bus) draw_sprites(machine(), bitmap, cliprect.min_y);
if (m_has_text_bus) draw_fixed_layer(machine(), bitmap, cliprect.min_y);
if (m_has_text_bus) draw_fixed_layer(bitmap, cliprect.min_y);
return 0;
}