summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/k037122.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/video/k037122.cpp')
-rw-r--r--src/mame/video/k037122.cpp153
1 files changed, 85 insertions, 68 deletions
diff --git a/src/mame/video/k037122.cpp b/src/mame/video/k037122.cpp
index c8086c59f41..61a84b20cf7 100644
--- a/src/mame/video/k037122.cpp
+++ b/src/mame/video/k037122.cpp
@@ -14,8 +14,8 @@ Konami 037122
---------------- -----xxxxx------ Red
---------------- ----------xxxxxx Green
- Tilemap is can be rotated, zoomed, similar as K053936 "simple mode"
- Tilemap size is 256x64 (2048x512 pixels) or 128x64 (1024x512 pixels), Each tile is 8bpp 8x8.
+ Tilemap is can be rotated, zoomed, similar as K053936 "simple mode"
+ Tilemap can be configured either as 256x64 tiles (2048x512 pixels) or 128x128 tiles (1024x1024 pixels), Each tile is 8bpp 8x8.
Tile format (4 byte (1x32bit word) per each tile)
Bits Description
@@ -44,12 +44,17 @@ Konami 037122
---------------- xxxxxxxxxxxxxxxx Vertical back porch - 2
20 sxxxxxxxxxxxxxxx ---------------- X counter starting value (12.4 fixed point)
---------------- sxxxxxxxxxxxxxxx Y counter starting value (12.4 fixed point)
- 24 ---------------- sxxxxxxxxxxxxxxx amount to add to the Y counter after each line (4.12 fixed point)
+ 24 sxxxxxxxxxxxxxxx ---------------- amount to add to the X counter after each line (4.12 fixed point)
+ ---------------- sxxxxxxxxxxxxxxx amount to add to the Y counter after each line (4.12 fixed point)
28 sxxxxxxxxxxxxxxx ---------------- amount to add to the X counter after each horizontal pixel (4.12 fixed point)
- 30 ---------------x ---------------- VRAM mapping mode
- ---------------0 ---------------- CLUT at 0x00000-0x08000, Display tilemap area at 0x08000-0x18000 (256x64)
- ---------------1 ---------------- CLUT at 0x18000-0x20000, Display tilemap area at 0x00000-0x08000 (128x64)
+ ---------------- sxxxxxxxxxxxxxxx amount to add to the Y counter after each horizontal pixel (4.12 fixed point)
+ 30 ---------------x ---------------- Tilemap size
+ ---------------0 ---------------- 128x128
+ ---------------1 ---------------- 256x64
---------------- -------------xxx Character RAM bank
+ 34 ---------------- -------------x-- CLUT location
+ ---------------- -------------0-- CLUT at 0x00000-0x08000
+ ---------------- -------------1-- CLUT at 0x18000-0x20000
Other bits/registers unknown, some registers are used
@@ -106,18 +111,19 @@ void k037122_device::device_start()
m_tile_ram = make_unique_clear<uint32_t[]>(0x20000 / 4);
m_reg = make_unique_clear<uint32_t[]>(0x400 / 4);
- m_layer[0] = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(k037122_device::tile_info_layer0)), TILEMAP_SCAN_ROWS, 8, 8, 256, 64);
- m_layer[1] = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(k037122_device::tile_info_layer1)), TILEMAP_SCAN_ROWS, 8, 8, 128, 64);
+ m_tilemap_128 = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(k037122_device::tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 128, 128);
+ m_tilemap_256 = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(k037122_device::tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 256, 64);
- m_layer[0]->set_transparent_pen(0);
- m_layer[1]->set_transparent_pen(0);
+ m_tilemap_128->set_transparent_pen(0);
+ m_tilemap_256->set_transparent_pen(0);
set_gfx(m_gfx_index,std::make_unique<gfx_element>(&palette(), k037122_char_layout, (uint8_t*)m_char_ram.get(), 0, palette().entries() / 16, 0));
save_pointer(NAME(m_reg), 0x400 / 4);
save_pointer(NAME(m_char_ram), 0x200000 / 4);
save_pointer(NAME(m_tile_ram), 0x20000 / 4);
-
+ save_item(NAME(m_tilemap_base));
+ save_item(NAME(m_palette_base));
}
//-------------------------------------------------
@@ -129,30 +135,18 @@ void k037122_device::device_reset()
memset(m_char_ram.get(), 0, 0x200000);
memset(m_tile_ram.get(), 0, 0x20000);
memset(m_reg.get(), 0, 0x400);
+
+ m_tilemap_base = 0;
+ m_palette_base = 0;
}
/*****************************************************************************
DEVICE HANDLERS
*****************************************************************************/
-TILE_GET_INFO_MEMBER(k037122_device::tile_info_layer0)
-{
- uint32_t val = m_tile_ram[tile_index + (0x8000/4)];
- int color = (val >> 17) & 0x1f;
- int tile = val & 0x3fff;
- int flags = 0;
-
- if (val & 0x400000)
- flags |= TILE_FLIPX;
- if (val & 0x800000)
- flags |= TILE_FLIPY;
-
- tileinfo.set(m_gfx_index, tile, color, flags);
-}
-
-TILE_GET_INFO_MEMBER(k037122_device::tile_info_layer1)
-{
- uint32_t val = m_tile_ram[tile_index];
+TILE_GET_INFO_MEMBER(k037122_device::tile_info)
+{
+ uint32_t val = m_tile_ram[tile_index + (m_tilemap_base / 4)];
int color = (val >> 17) & 0x1f;
int tile = val & 0x3fff;
int flags = 0;
@@ -170,25 +164,38 @@ void k037122_device::tile_draw( screen_device &screen, bitmap_rgb32 &bitmap, con
{
const rectangle &visarea = screen.visible_area();
+ int16_t scrollx = m_reg[0x8] >> 16;
+ int16_t scrolly = m_reg[0x8] & 0xffff;
+
+ int16_t incxx = m_reg[0xa] >> 16;
+ int16_t incxy = m_reg[0xa] & 0xffff;
+ int16_t incyx = m_reg[0x9] >> 16;
+ int16_t incyy = m_reg[0x9] & 0xffff;
+
+ // on 256x64 tilemap y-scroll seems to be 8.4 fixed point instead
+ int16_t scrolly_256 = scrolly;
+ if (scrolly_256 & 0x800)
+ scrolly_256 |= 0xf000;
+
if (m_reg[0xc] & 0x10000)
{
- m_layer[1]->set_scrolldx(visarea.min_x, visarea.min_x);
- m_layer[1]->set_scrolldy(visarea.min_y, visarea.min_y);
- m_layer[1]->draw(screen, bitmap, cliprect, 0, 0);
+ m_tilemap_128->set_scrolldx(visarea.min_x, visarea.min_x);
+ m_tilemap_128->set_scrolldy(visarea.min_y, visarea.min_y);
+
+ m_tilemap_128->draw_roz(screen, bitmap, cliprect, (int32_t)(scrollx) << 12, (int32_t)(scrolly) << 12,
+ (int32_t)(incxx) << 4, (int32_t)(incxy) << 4, (int32_t)(incyx), (int32_t)(incyy) << 4,
+ false, 0, 0);
}
else
{
- m_layer[0]->set_scrolldx(visarea.min_x, visarea.min_x);
- m_layer[0]->set_scrolldy(visarea.min_y, visarea.min_y);
- m_layer[0]->draw(screen, bitmap, cliprect, 0, 0);
- }
-}
-
-void k037122_device::update_palette_color( uint32_t palette_base, int color )
-{
- uint32_t data = m_tile_ram[(palette_base / 4) + color];
+ m_tilemap_256->set_scrolldx(visarea.min_x, visarea.min_x);
+ m_tilemap_256->set_scrolldy(visarea.min_y, visarea.min_y);
- palette().set_pen_color(color, pal5bit(data >> 6), pal6bit(data >> 0), pal5bit(data >> 11));
+ m_tilemap_256->draw_roz(screen, bitmap, cliprect, (int32_t)(scrollx) << 12, (int32_t)(scrolly_256) << 12,
+ (int32_t)(incxx) << 4, (int32_t)(incxy) << 4, (int32_t)(incyx) << 4, (int32_t)(incyy) << 4,
+ false, 0, 0);
+ }
+
}
uint32_t k037122_device::sram_r(offs_t offset)
@@ -200,35 +207,18 @@ void k037122_device::sram_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
COMBINE_DATA(m_tile_ram.get() + offset);
- if (m_reg[0xc] & 0x10000)
+ uint32_t address = offset * 4;
+
+ if (address >= m_palette_base && address < m_palette_base + 0x8000)
{
- if (offset < 0x8000 / 4)
- {
- m_layer[1]->mark_tile_dirty(offset);
- }
- else if (offset >= 0x8000 / 4 && offset < 0x18000 / 4)
- {
- m_layer[0]->mark_tile_dirty(offset - (0x8000 / 4));
- }
- else if (offset >= 0x18000 / 4)
- {
- update_palette_color(0x18000, offset - (0x18000 / 4));
- }
+ int color = (address - m_palette_base) / 4;
+ palette().set_pen_color(color, pal5bit(data >> 6), pal6bit(data >> 0), pal5bit(data >> 11));
}
- else
+
+ if (address >= m_tilemap_base && address < m_tilemap_base + 0x10000)
{
- if (offset < 0x8000 / 4)
- {
- update_palette_color(0, offset);
- }
- else if (offset >= 0x8000 / 4 && offset < 0x18000 / 4)
- {
- m_layer[0]->mark_tile_dirty(offset - (0x8000 / 4));
- }
- else if (offset >= 0x18000 / 4)
- {
- m_layer[1]->mark_tile_dirty(offset - (0x18000 / 4));
- }
+ m_tilemap_128->mark_tile_dirty((address - m_tilemap_base) / 4);
+ m_tilemap_256->mark_tile_dirty((address - m_tilemap_base) / 4);
}
}
@@ -263,5 +253,32 @@ uint32_t k037122_device::reg_r(offs_t offset)
void k037122_device::reg_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
+ if (offset == 0x34/4 && ACCESSING_BITS_0_15)
+ {
+ uint32_t palette_base = (data & 0x4) ? 0x18000 : 0x00000;
+
+ // tilemap is at 0x00000 unless CLUT is there
+ uint32_t tilemap_base = (data & 0x4) ? 0x00000 : 0x08000;
+
+ if (palette_base != m_palette_base)
+ {
+ m_palette_base = palette_base;
+
+ // update all colors since palette moved
+ for (auto p = 0; p < 8192; p++)
+ {
+ uint32_t color = m_tile_ram[(m_palette_base / 4) + p];
+ palette().set_pen_color(p, pal5bit(color >> 6), pal6bit(color >> 0), pal5bit(color >> 11));
+ }
+ }
+
+ if (tilemap_base != m_tilemap_base)
+ {
+ m_tilemap_128->mark_all_dirty();
+ m_tilemap_256->mark_all_dirty();
+ m_tilemap_base = tilemap_base;
+ }
+ }
+
COMBINE_DATA(m_reg.get() + offset);
}