Skip to content

Commit

Permalink
fix savestates with tile usage + minor reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
y-ack committed Apr 26, 2024
1 parent ed3c3f7 commit 5473bf3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/mame/taito/taito_f3.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class taito_f3_state : public driver_device
int m_sprite_lag = 0;
u8 m_textram_row_usage[64]{};
u8 m_sprite_pri_row_usage[256]{};
u8 m_tilemap_row_usage[8][32]{};
u8 m_tilemap_row_usage[32][8]{};
bitmap_ind8 m_pri_alp_bitmap;
bitmap_ind16 m_sprite_framebuffer{};
u16 m_width_mask = 0;
Expand Down
67 changes: 43 additions & 24 deletions src/mame/taito/taito_f3_v.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,27 @@ const taito_f3_state::F3config taito_f3_state::f3_config_table[] = {

void taito_f3_state::device_post_load()
{
/* force a reread of the dynamic tiles in the pixel layer */
// force a reread of the dynamic tiles in the pixel layer
m_gfxdecode->gfx(0)->mark_all_dirty();
m_gfxdecode->gfx(1)->mark_all_dirty();

// refresh tile usage indexes
std::fill_n(*m_tilemap_row_usage, 32 * 8, 0);
std::fill_n(m_textram_row_usage, 64, 0);
// playfield blank tiles
for (int offset = 1; offset < 0x4000; offset += 2) {
const int row = m_extend ? BIT(offset, 7, 5) : BIT(offset, 6, 5);
const int tmap = m_extend ? offset >> 12 : offset >> 11;
if (m_pf_ram[offset] != 0)
m_tilemap_row_usage[row][tmap] += 1;
}
// textram blank tiles
for (int offset = 0; offset < 0x1000; offset++) {
const u8 tile = BIT(m_textram[offset], 0, 8);
const int row = BIT(offset, 6, 6);
if (tile != 0)
m_textram_row_usage[row] += 1;
}
}

/******************************************************************************/
Expand Down Expand Up @@ -471,8 +489,8 @@ void taito_f3_state::create_tilemaps(bool extend)
for (int i = 0; i < 8; i++) {
if (m_tilemap[i])
m_tilemap[i]->set_transparent_pen(0);
std::fill_n(m_tilemap_row_usage[i], 32, 0);
}
std::fill_n(*m_tilemap_row_usage, 32 * 8, 0);

if (m_extend) {
m_width_mask = 0x3ff; // 10 bits
Expand Down Expand Up @@ -543,26 +561,25 @@ void taito_f3_state::pf_ram_w(offs_t offset, u16 data, u16 mem_mask)
{
// [.ttt yyyy yxxx xxa|h] non-extend
// [.tty yyyy xxxx xxa|h] extend
if (offset & 1 && offset < 0x4000) {
const int row = m_extend ? BIT(offset, 7, 5) : BIT(offset, 6, 5);
const u16 prev_tile = m_pf_ram[offset];
const int tmap = m_extend ? offset >> 12 : offset >> 11;

if (prev_tile == 0 && data != 0)
m_tilemap_row_usage[tmap][row] += 1;
else if (prev_tile != 0 && data == 0)
m_tilemap_row_usage[tmap][row] -= 1;
}
const u16 prev_tile = m_pf_ram[offset];

COMBINE_DATA(&m_pf_ram[offset]);

if (m_game_config->extend) {
if (offset < 0x4000) {
m_tilemap[offset >> 12]->mark_tile_dirty((offset & 0xfff) >> 1);
if (offset < 0x4000) {
if (offset & 1) {
const int row = m_extend ? BIT(offset, 7, 5) : BIT(offset, 6, 5);
const int tmap = m_extend ? offset >> 12 : offset >> 11;
if ((prev_tile == 0) && (m_pf_ram[offset] != 0))
m_tilemap_row_usage[row][tmap] += 1;
else if ((prev_tile != 0) && (m_pf_ram[offset] == 0))
m_tilemap_row_usage[row][tmap] -= 1;
}
} else {
if (offset < 0x4000)

if (m_game_config->extend) {
m_tilemap[offset >> 12]->mark_tile_dirty((offset & 0xfff) >> 1);
} else {
m_tilemap[offset >> 11]->mark_tile_dirty((offset & 0x7ff) >> 1);
}
}
}

Expand Down Expand Up @@ -593,15 +610,17 @@ u16 taito_f3_state::textram_r(offs_t offset)

void taito_f3_state::textram_w(offs_t offset, u16 data, u16 mem_mask)
{
const int row = BIT(offset, 6, 6);
const u16 prev_tile = m_textram[offset];
if (prev_tile == 0 && data != 0)
m_textram_row_usage[row] += 1;
else if (prev_tile != 0 && data == 0)
m_textram_row_usage[row] -= 1;
const u8 prev_tile = BIT(m_textram[offset], 0, 8);

COMBINE_DATA(&m_textram[offset]);

const int row = BIT(offset, 6, 6);
const u8 tile = BIT(m_textram[offset], 0, 8);
if (prev_tile == 0 && tile != 0)
m_textram_row_usage[row] += 1;
else if (prev_tile != 0 && tile == 0)
m_textram_row_usage[row] -= 1;

m_vram_layer->mark_tile_dirty(offset);

// dirty the pixel layer too, since it uses palette etc. from text layer
Expand Down Expand Up @@ -1108,7 +1127,7 @@ inline bool taito_f3_state::used(const sprite_inf &layer, int y) const
inline bool taito_f3_state::used(const playfield_inf &layer, int y) const
{
const int y_adj = m_flipscreen ? 0x1ff - layer.y_index(y) : layer.y_index(y);
return m_tilemap_row_usage[layer.index + (2 * layer.alt_tilemap)][y_adj >> 4] > 0;
return m_tilemap_row_usage[y_adj >> 4][layer.index + (2 * layer.alt_tilemap)] > 0;
}

void taito_f3_state::scanline_draw(bitmap_rgb32 &bitmap, const rectangle &cliprect)
Expand Down

0 comments on commit 5473bf3

Please sign in to comment.