Skip to content

Commit

Permalink
k052109: add function for marking tilemap dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
happppp committed Jan 10, 2025
1 parent b35397e commit 04bdcc4
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 126 deletions.
15 changes: 6 additions & 9 deletions src/mame/konami/asterix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ K056832_CB_MEMBER(asterix_state::tile_callback)

uint32_t asterix_state::screen_update_asterix(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
static const int K053251_CI[4] = { k053251_device::CI0, k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 };
int layer[3];

/* Layer offsets are different if horizontally flipped */
// layer offsets are different if horizontally flipped
if (m_k056832->read_register(0x0) & 0x10)
{
m_k056832->set_layer_offs(0, 89 - 176, 0);
Expand Down Expand Up @@ -158,6 +155,9 @@ uint32_t asterix_state::screen_update_asterix(screen_device &screen, bitmap_ind1
tilemaps_dirty = true;
}

static const int K053251_CI[4] = { k053251_device::CI0, k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 };
m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1);

for (int plane = 0; plane < 4; plane++)
{
int prev_colorbase = m_layer_colorbase[plane];
Expand All @@ -170,13 +170,10 @@ uint32_t asterix_state::screen_update_asterix(screen_device &screen, bitmap_ind1
if (tilemaps_dirty)
m_k056832->mark_all_tilemaps_dirty();

m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1);

layer[0] = 0;
// sort layers and draw
int layer[3] = { 0, 1, 3 };
m_layerpri[0] = m_k053251->get_priority(k053251_device::CI0);
layer[1] = 1;
m_layerpri[1] = m_k053251->get_priority(k053251_device::CI2);
layer[2] = 3;
m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4);

konami_sortlayers3(layer, m_layerpri);
Expand Down
6 changes: 6 additions & 0 deletions src/mame/konami/k052109.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,12 @@ void k052109_device::tilemap_draw( screen_device &screen, bitmap_ind16 &bitmap,
m_tilemap[tmap_num]->draw(screen, bitmap, cliprect, flags, priority);
}

void k052109_device::mark_tilemap_dirty( uint8_t tmap_num )
{
assert(tmap_num <= 2);
m_tilemap[tmap_num]->mark_all_dirty();
}


/***************************************************************************
Expand Down
1 change: 1 addition & 0 deletions src/mame/konami/k052109.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class k052109_device : public device_t, public device_gfx_interface, public devi
int get_rmrd_line();
void tilemap_update();
void tilemap_draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int tmap_num, uint32_t flags, uint8_t priority);
void mark_tilemap_dirty(uint8_t tmap_num);

void vblank_callback(screen_device &screen, bool state);

Expand Down
29 changes: 18 additions & 11 deletions src/mame/konami/parodius.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,29 @@ K05324X_CB_MEMBER(parodius_state::sprite_callback)

uint32_t parodius_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
// update color info and refresh tilemaps
static const int K053251_CI[3] = { k053251_device::CI2, k053251_device::CI4, k053251_device::CI3 };
int bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0);
m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1);
m_layer_colorbase[0] = m_k053251->get_palette_index(k053251_device::CI2);
m_layer_colorbase[1] = m_k053251->get_palette_index(k053251_device::CI4);
m_layer_colorbase[2] = m_k053251->get_palette_index(k053251_device::CI3);
m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1);

for (int i = 0; i < 3; i++)
{
int prev_colorbase = m_layer_colorbase[i];
m_layer_colorbase[i] = m_k053251->get_palette_index(K053251_CI[i]);

if (m_layer_colorbase[i] != prev_colorbase)
m_k052109->mark_tilemap_dirty(i);
}

m_k052109->tilemap_update();

// sort layers and draw
int layer[3];

layer[0] = 0;
m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2);
layer[1] = 1;
m_layerpri[1] = m_k053251->get_priority(k053251_device::CI4);
layer[2] = 2;
m_layerpri[2] = m_k053251->get_priority(k053251_device::CI3);
for (int i = 0; i < 3; i++)
{
layer[i] = i;
m_layerpri[i] = m_k053251->get_priority(K053251_CI[i]);
}

konami_sortlayers3(layer, m_layerpri);

Expand Down
34 changes: 21 additions & 13 deletions src/mame/konami/simpsons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,11 @@ class simpsons_state : public driver_device

void simpsons(machine_config &config);

private:
protected:
virtual void machine_start() override ATTR_COLD;
virtual void machine_reset() override ATTR_COLD;

private:
void bank0000_map(address_map &map) ATTR_COLD;
void bank2000_map(address_map &map) ATTR_COLD;
void main_map(address_map &map) ATTR_COLD;
Expand Down Expand Up @@ -280,22 +281,29 @@ void simpsons_state::video_bank_select( int bank )

uint32_t simpsons_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int layer[3], bg_colorbase;

bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0);
// update color info and refresh tilemaps
static const int K053251_CI[3] = { k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 };
int bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0);
m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1);
m_layer_colorbase[0] = m_k053251->get_palette_index(k053251_device::CI2);
m_layer_colorbase[1] = m_k053251->get_palette_index(k053251_device::CI3);
m_layer_colorbase[2] = m_k053251->get_palette_index(k053251_device::CI4);

for (int i = 0; i < 3; i++)
{
int prev_colorbase = m_layer_colorbase[i];
m_layer_colorbase[i] = m_k053251->get_palette_index(K053251_CI[i]);

if (m_layer_colorbase[i] != prev_colorbase)
m_k052109->mark_tilemap_dirty(i);
}

m_k052109->tilemap_update();

layer[0] = 0;
m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2);
layer[1] = 1;
m_layerpri[1] = m_k053251->get_priority(k053251_device::CI3);
layer[2] = 2;
m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4);
// sort layers and draw
int layer[3];
for (int i = 0; i < 3; i++)
{
layer[i] = i;
m_layerpri[i] = m_k053251->get_priority(K053251_CI[i]);
}

konami_sortlayers3(layer, m_layerpri);

Expand Down
27 changes: 17 additions & 10 deletions src/mame/konami/surpratk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,29 @@ K05324X_CB_MEMBER(surpratk_state::sprite_callback)

uint32_t surpratk_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
// update color info and refresh tilemaps
static const int K053251_CI[3] = { k053251_device::CI2, k053251_device::CI4, k053251_device::CI3 };
int bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0);
m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1);
m_layer_colorbase[0] = m_k053251->get_palette_index(k053251_device::CI2);
m_layer_colorbase[1] = m_k053251->get_palette_index(k053251_device::CI4);
m_layer_colorbase[2] = m_k053251->get_palette_index(k053251_device::CI3);

for (int i = 0; i < 3; i++)
{
int prev_colorbase = m_layer_colorbase[i];
m_layer_colorbase[i] = m_k053251->get_palette_index(K053251_CI[i]);

if (m_layer_colorbase[i] != prev_colorbase)
m_k052109->mark_tilemap_dirty(i);
}

m_k052109->tilemap_update();

// sort layers and draw
int layer[3];

layer[0] = 0;
m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2);
layer[1] = 1;
m_layerpri[1] = m_k053251->get_priority(k053251_device::CI4);
layer[2] = 2;
m_layerpri[2] = m_k053251->get_priority(k053251_device::CI3);
for (int i = 0; i < 3; i++)
{
layer[i] = i;
m_layerpri[i] = m_k053251->get_priority(K053251_CI[i]);
}

konami_sortlayers3(layer, m_layerpri);

Expand Down
2 changes: 1 addition & 1 deletion src/mame/konami/tmnt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ K052109_CB_MEMBER(tmnt_state::cuebrick_tile_callback)
if ((m_k052109->get_rmrd_line() == CLEAR_LINE) && (layer == 0))
{
*code |= ((*color & 0x01) << 8);
*color = m_layer_colorbase[layer] + ((*color & 0x0e) >> 1);
*color = m_layer_colorbase[layer] + ((*color & 0x0e) >> 1);
}
else
{
Expand Down
124 changes: 75 additions & 49 deletions src/mame/konami/tmnt2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,19 +1012,27 @@ uint16_t prmrsocr_state::prmrsocr_rom_r(offs_t offset)

uint32_t tmnt2_state::screen_update_punkshot(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
// update color info and refresh tilemaps
static const int K053251_CI[3] = { k053251_device::CI2, k053251_device::CI4, k053251_device::CI3 };
m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1);
m_layer_colorbase[0] = m_k053251->get_palette_index(k053251_device::CI2);
m_layer_colorbase[1] = m_k053251->get_palette_index(k053251_device::CI4);
m_layer_colorbase[2] = m_k053251->get_palette_index(k053251_device::CI3);

for (int i = 0; i < 3; i++)
{
int prev_colorbase = m_layer_colorbase[i];
m_layer_colorbase[i] = m_k053251->get_palette_index(K053251_CI[i]);

if (m_layer_colorbase[i] != prev_colorbase)
m_k052109->mark_tilemap_dirty(i);
}

m_k052109->tilemap_update();

m_sorted_layer[0] = 0;
m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2);
m_sorted_layer[1] = 1;
m_layerpri[1] = m_k053251->get_priority(k053251_device::CI4);
m_sorted_layer[2] = 2;
m_layerpri[2] = m_k053251->get_priority(k053251_device::CI3);
// sort layers and draw
for (int i = 0; i < 3; i++)
{
m_sorted_layer[i] = i;
m_layerpri[i] = m_k053251->get_priority(K053251_CI[i]);
}

konami_sortlayers3(m_sorted_layer, m_layerpri);

Expand All @@ -1040,22 +1048,28 @@ uint32_t tmnt2_state::screen_update_punkshot(screen_device &screen, bitmap_ind16

uint32_t tmnt2_state::screen_update_lgtnfght(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int bg_colorbase;

bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0);
// update color info and refresh tilemaps
static const int K053251_CI[3] = { k053251_device::CI2, k053251_device::CI4, k053251_device::CI3 };
int bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0);
m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1);
m_layer_colorbase[0] = m_k053251->get_palette_index(k053251_device::CI2);
m_layer_colorbase[1] = m_k053251->get_palette_index(k053251_device::CI4);
m_layer_colorbase[2] = m_k053251->get_palette_index(k053251_device::CI3);

for (int i = 0; i < 3; i++)
{
int prev_colorbase = m_layer_colorbase[i];
m_layer_colorbase[i] = m_k053251->get_palette_index(K053251_CI[i]);

if (m_layer_colorbase[i] != prev_colorbase)
m_k052109->mark_tilemap_dirty(i);
}

m_k052109->tilemap_update();

m_sorted_layer[0] = 0;
m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2);
m_sorted_layer[1] = 1;
m_layerpri[1] = m_k053251->get_priority(k053251_device::CI4);
m_sorted_layer[2] = 2;
m_layerpri[2] = m_k053251->get_priority(k053251_device::CI3);
// sort layers and draw
for (int i = 0; i < 3; i++)
{
m_sorted_layer[i] = i;
m_layerpri[i] = m_k053251->get_priority(K053251_CI[i]);
}

konami_sortlayers3(m_sorted_layer, m_layerpri);

Expand All @@ -1073,9 +1087,9 @@ uint32_t tmnt2_state::screen_update_lgtnfght(screen_device &screen, bitmap_ind16
uint16_t glfgreat_state::glfgreat_ball_r()
{
#ifdef MAME_DEBUG
popmessage("%04x", m_glfgreat_pixel);
popmessage("%04x", m_glfgreat_pixel);
#endif
/* if out of the ROZ layer palette range, it's in the water - return 0 */
// if out of the ROZ layer palette range, it's in the water - return 0
if (m_glfgreat_pixel < 0x400 || m_glfgreat_pixel >= 0x500)
return 0;
else
Expand All @@ -1084,27 +1098,33 @@ popmessage("%04x", m_glfgreat_pixel);

uint32_t tmnt2_state::screen_update_glfgreat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int bg_colorbase;

bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0);
// update color info and refresh tilemaps
static const int K053251_CI[3] = { k053251_device::CI2, k053251_device::CI3, k053251_device::CI4 };
int bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0);
m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1);
m_layer_colorbase[0] = m_k053251->get_palette_index(k053251_device::CI2);
m_layer_colorbase[1] = m_k053251->get_palette_index(k053251_device::CI3) + 8; /* weird... */
m_layer_colorbase[2] = m_k053251->get_palette_index(k053251_device::CI4);

for (int i = 0; i < 3; i++)
{
int prev_colorbase = m_layer_colorbase[i];
m_layer_colorbase[i] = m_k053251->get_palette_index(K053251_CI[i]);
if (i == 1) m_layer_colorbase[i] += 8; // weird

if (m_layer_colorbase[i] != prev_colorbase)
m_k052109->mark_tilemap_dirty(i);
}

m_k052109->tilemap_update();

m_sorted_layer[0] = 0;
m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2);
m_sorted_layer[1] = 1;
m_layerpri[1] = m_k053251->get_priority(k053251_device::CI3);
m_sorted_layer[2] = 2;
m_layerpri[2] = m_k053251->get_priority(k053251_device::CI4);
// sort layers and draw
for (int i = 0; i < 3; i++)
{
m_sorted_layer[i] = i;
m_layerpri[i] = m_k053251->get_priority(K053251_CI[i]);
}

konami_sortlayers3(m_sorted_layer, m_layerpri);

/* not sure about the 053936 priority, but it seems to work */

// not sure about the 053936 priority, but it seems to work
screen.priority().fill(0, cliprect);
bitmap.fill(16 * bg_colorbase, cliprect);
m_k052109->tilemap_draw(screen, bitmap, cliprect, m_sorted_layer[0], 0, 1);
Expand Down Expand Up @@ -1189,22 +1209,28 @@ uint32_t tmnt2_state::screen_update_tmnt2(screen_device &screen, bitmap_ind16 &b

uint32_t tmnt2_state::screen_update_thndrx2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int bg_colorbase;

bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0);
// update color info and refresh tilemaps
static const int K053251_CI[3] = { k053251_device::CI2, k053251_device::CI4, k053251_device::CI3 };
int bg_colorbase = m_k053251->get_palette_index(k053251_device::CI0);
m_sprite_colorbase = m_k053251->get_palette_index(k053251_device::CI1);
m_layer_colorbase[0] = m_k053251->get_palette_index(k053251_device::CI2);
m_layer_colorbase[1] = m_k053251->get_palette_index(k053251_device::CI4);
m_layer_colorbase[2] = m_k053251->get_palette_index(k053251_device::CI3);

for (int i = 0; i < 3; i++)
{
int prev_colorbase = m_layer_colorbase[i];
m_layer_colorbase[i] = m_k053251->get_palette_index(K053251_CI[i]);

if (m_layer_colorbase[i] != prev_colorbase)
m_k052109->mark_tilemap_dirty(i);
}

m_k052109->tilemap_update();

m_sorted_layer[0] = 0;
m_layerpri[0] = m_k053251->get_priority(k053251_device::CI2);
m_sorted_layer[1] = 1;
m_layerpri[1] = m_k053251->get_priority(k053251_device::CI4);
m_sorted_layer[2] = 2;
m_layerpri[2] = m_k053251->get_priority(k053251_device::CI3);
// sort layers and draw
for (int i = 0; i < 3; i++)
{
m_sorted_layer[i] = i;
m_layerpri[i] = m_k053251->get_priority(K053251_CI[i]);
}

konami_sortlayers3(m_sorted_layer, m_layerpri);

Expand Down
Loading

0 comments on commit 04bdcc4

Please sign in to comment.