diff --git a/src/devices/video/k051316.cpp b/src/devices/video/k051316.cpp index 5f59e3f8b83..c2426de7afa 100644 --- a/src/devices/video/k051316.cpp +++ b/src/devices/video/k051316.cpp @@ -30,8 +30,9 @@ control registers 00e bit 0 = enable ROM reading (active low). This only makes the chip output the requested address: the ROM is actually read externally, not through the chip's data bus. - bit 1 = unknown - bit 2 = unknown + bit 1 = enable tile X flip when tile color attribute bit 6 is set + bit 2 = enable tile Y flip when tile color attribute bit 7 is set + bits 3-7 = internal tests, shouldn't be used 00f unused */ @@ -39,6 +40,7 @@ control registers #include "emu.h" #include "k051316.h" +#include #define VERBOSE 0 #include "logmacro.h" @@ -104,7 +106,7 @@ GFXDECODE_MEMBER( k051316_device::gfxinfo4_ram ) GFXDECODE_END -k051316_device::k051316_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) +k051316_device::k051316_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, K051316, tag, owner, clock) , device_gfx_interface(mconfig, *this, gfxinfo) , m_zoom_rom(*this, DEVICE_SELF) @@ -114,6 +116,9 @@ k051316_device::k051316_device(const machine_config &mconfig, const char *tag, d , m_pixels_per_byte(2) // 4bpp layout is default , m_layermask(0) , m_k051316_cb(*this) + , m_readout_enabled(true) + , m_flipx_enabled(false) + , m_flipy_enabled(false) { } @@ -172,11 +177,16 @@ void k051316_device::device_start() m_tmap->map_pens_to_layer(0, m_layermask, m_layermask, TILEMAP_PIXEL_LAYER0); } else + { m_tmap->set_transparent_pen(0); + } save_item(NAME(m_ram)); save_item(NAME(m_ctrlram)); save_item(NAME(m_wrap)); + save_item(NAME(m_readout_enabled)); + save_item(NAME(m_flipx_enabled)); + save_item(NAME(m_flipy_enabled)); } @@ -186,7 +196,7 @@ void k051316_device::device_start() void k051316_device::device_reset() { - memset(m_ctrlram, 0, 0x10); + std::fill(std::begin(m_ctrlram), std::end(m_ctrlram), 0); } /***************************************************************************** @@ -207,9 +217,9 @@ void k051316_device::write(offs_t offset, u8 data) u8 k051316_device::rom_r(offs_t offset) { - assert (m_zoom_rom.found()); + assert(m_zoom_rom.found()); - if ((m_ctrlram[0x0e] & 0x01) == 0) + if (m_readout_enabled) { int addr = offset + (m_ctrlram[0x0c] << 11) + (m_ctrlram[0x0d] << 19); addr /= m_pixels_per_byte; @@ -228,12 +238,22 @@ u8 k051316_device::rom_r(offs_t offset) void k051316_device::ctrl_w(offs_t offset, u8 data) { - m_ctrlram[offset] = data; + if (offset == 0x0e) + { + m_readout_enabled = !BIT(data, 0); + if ((m_flipx_enabled != BIT(data, 1)) || (m_flipy_enabled != BIT(data, 2))) + m_tmap->mark_all_dirty(); + m_flipx_enabled = BIT(data, 1); + m_flipy_enabled = BIT(data, 2); + } + else if (offset < 0x0e) + m_ctrlram[offset] = data; + //if (offset >= 0x0c) logerror("%s: write %02x to 051316 reg %x\n", machine().describe_context(), data, offset); } // some games (ajax, rollerg, ultraman, etc.) have external logic that can enable or disable wraparound dynamically -void k051316_device::wraparound_enable( int status ) +void k051316_device::wraparound_enable(int status) { m_wrap = status; } @@ -248,9 +268,15 @@ TILE_GET_INFO_MEMBER(k051316_device::get_tile_info) { int code = m_ram[tile_index]; int color = m_ram[tile_index + 0x400]; - int flags = 0; + u8 flags = 0; - m_k051316_cb(&code, &color, &flags); + if (m_flipx_enabled && (color & 0x40)) + flags |= TILE_FLIPX; + + if (m_flipy_enabled && (color & 0x80)) + flags |= TILE_FLIPY; + + m_k051316_cb(&code, &color); tileinfo.set(0, code, @@ -259,9 +285,9 @@ TILE_GET_INFO_MEMBER(k051316_device::get_tile_info) } -void k051316_device::zoom_draw( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flags, uint32_t priority ) +void k051316_device::zoom_draw( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flags, u32 priority ) { - uint32_t startx, starty; + u32 startx, starty; int incxx, incxy, incyx, incyy; startx = 256 * ((int16_t)(256 * m_ctrlram[0x00] + m_ctrlram[0x01])); @@ -283,7 +309,7 @@ void k051316_device::zoom_draw( screen_device &screen, bitmap_ind16 &bitmap, con flags, priority); #if 0 - popmessage("%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x", + popmessage("%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x", m_ctrlram[0x00], m_ctrlram[0x01], m_ctrlram[0x02], @@ -297,8 +323,6 @@ void k051316_device::zoom_draw( screen_device &screen, bitmap_ind16 &bitmap, con m_ctrlram[0x0a], m_ctrlram[0x0b], m_ctrlram[0x0c], /* bank for ROM testing */ - m_ctrlram[0x0d], - m_ctrlram[0x0e], /* 0 = test ROMs */ - m_ctrlram[0x0f]); + m_ctrlram[0x0d]); #endif } diff --git a/src/devices/video/k051316.h b/src/devices/video/k051316.h index db3df893986..c397beb8772 100644 --- a/src/devices/video/k051316.h +++ b/src/devices/video/k051316.h @@ -8,15 +8,15 @@ #include "tilemap.h" -#define K051316_CB_MEMBER(_name) void _name(int *code, int *color, int *flags) +#define K051316_CB_MEMBER(_name) void _name(int *code, int *color) class k051316_device : public device_t, public device_gfx_interface { public: - using zoom_delegate = device_delegate; + using zoom_delegate = device_delegate; - k051316_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + k051316_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); static const gfx_layout charlayout4; static const gfx_layout charlayout7; @@ -45,7 +45,6 @@ public: The callback must put: - in code the resulting tile number - in color the resulting color index - - if necessary, put flags for the TileMap code in the tile_info structure (e.g. TILE_FLIPX) */ @@ -53,7 +52,7 @@ public: void write(offs_t offset, u8 data); u8 rom_r(offs_t offset); void ctrl_w(offs_t offset, u8 data); - void zoom_draw(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,int flags,uint32_t priority); + void zoom_draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int flags, u32 priority); void wraparound_enable(int status); void mark_gfx_dirty(offs_t byteoffset) { gfx(0)->mark_dirty(byteoffset * m_pixels_per_byte / (16 * 16)); } @@ -67,8 +66,8 @@ protected: private: // internal state std::vector m_ram; - uint8_t m_ctrlram[16]; - tilemap_t *m_tmap = nullptr; + uint8_t m_ctrlram[14]; + tilemap_t *m_tmap; optional_region_ptr m_zoom_rom; @@ -77,6 +76,9 @@ private: int m_pixels_per_byte; int m_layermask; zoom_delegate m_k051316_cb; + bool m_readout_enabled; + bool m_flipx_enabled; + bool m_flipy_enabled; TILE_GET_INFO_MEMBER(get_tile_info); }; diff --git a/src/mame/konami/88games_v.cpp b/src/mame/konami/88games_v.cpp index 1c555fffe33..2f47bc7fe53 100644 --- a/src/mame/konami/88games_v.cpp +++ b/src/mame/konami/88games_v.cpp @@ -46,7 +46,6 @@ K051316_CB_MEMBER(_88games_state::zoom_callback) { enum { zoom_colorbase = 768 / 16 }; - *flags = (*color & 0x40) ? TILE_FLIPX : 0; *code |= ((*color & 0x07) << 8); *color = zoom_colorbase + ((*color & 0x38) >> 3) + ((*color & 0x80) >> 4); } diff --git a/src/mame/konami/bottom9.cpp b/src/mame/konami/bottom9.cpp index f392c673633..6d81e147629 100644 --- a/src/mame/konami/bottom9.cpp +++ b/src/mame/konami/bottom9.cpp @@ -143,7 +143,6 @@ K051316_CB_MEMBER(bottom9_state::zoom_callback) { enum { zoom_colorbase = 768 / 16 }; - *flags = (*color & 0x40) ? TILE_FLIPX : 0; *code |= ((*color & 0x03) << 8); *color = zoom_colorbase + ((*color & 0x3c) >> 2); } diff --git a/src/mame/konami/chqflag_v.cpp b/src/mame/konami/chqflag_v.cpp index 8fc9a35f8b9..a4e6c0e561b 100644 --- a/src/mame/konami/chqflag_v.cpp +++ b/src/mame/konami/chqflag_v.cpp @@ -45,7 +45,6 @@ K051316_CB_MEMBER(chqflag_state::zoom_callback_2) { enum { zoom_colorbase_2 = 512 / 256 }; - *flags = TILE_FLIPYX((*color & 0xc0) >> 6); *code |= ((*color & 0x0f) << 8); *color = zoom_colorbase_2 + ((*color & 0x10) >> 4); } diff --git a/src/mame/konami/overdriv.cpp b/src/mame/konami/overdriv.cpp index 04ffb61c8e4..9db471482f6 100644 --- a/src/mame/konami/overdriv.cpp +++ b/src/mame/konami/overdriv.cpp @@ -264,14 +264,12 @@ K053246_CB_MEMBER(overdriv_state::sprite_callback) K051316_CB_MEMBER(overdriv_state::zoom_callback_1) { - *flags = (*color & 0x40) ? TILE_FLIPX : 0; *code |= ((*color & 0x03) << 8); *color = m_zoom_colorbase[0] + ((*color & 0x3c) >> 2); } K051316_CB_MEMBER(overdriv_state::zoom_callback_2) { - *flags = (*color & 0x40) ? TILE_FLIPX : 0; *code |= ((*color & 0x03) << 8); *color = m_zoom_colorbase[1] + ((*color & 0x3c) >> 2); } diff --git a/src/mame/konami/rollerg.cpp b/src/mame/konami/rollerg.cpp index 2931afcf10f..c083846b297 100644 --- a/src/mame/konami/rollerg.cpp +++ b/src/mame/konami/rollerg.cpp @@ -119,7 +119,6 @@ K05324X_CB_MEMBER(rollerg_state::sprite_callback) K051316_CB_MEMBER(rollerg_state::zoom_callback) { - *flags = TILE_FLIPYX((*color & 0xc0) >> 6); *code |= ((*color & 0x0f) << 8); *color = ((*color & 0x30) >> 4); }