k051316 tile flip configuration bits, replaces flag setting in callbacks (#10401)

* Added shadow config bits

* Removed previous fix (hack)

* bool-ize some ints, use BIT macro

* Fixed k054000, got rid of thndrx2 patch

* Attempt to get chqflag shadow/highlights working properly with no k051960 hack

* k051316 tile flip configuration bits, replaces flag setting in callbacks

* k051316: Removed flags cb parameter, added bool for each configuration bit

* Got rid of duplicated state for flip enable bits

* video/k051316.cpp: Cleanup

* video/k051316.h: Cleanup

Also, don’t split member initialisation between declarations and constructor - it’s a recipe for confusion.

Co-authored-by: Vas Crabb <cuavas@users.noreply.github.com>
This commit is contained in:
Furrtek 2022-10-15 11:19:42 +02:00 committed by GitHub
parent d2cb3388ee
commit 400baf8ce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 29 deletions

View File

@ -30,8 +30,9 @@ control registers
00e bit 0 = enable ROM reading (active low). This only makes the chip output the 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 requested address: the ROM is actually read externally, not through
the chip's data bus. the chip's data bus.
bit 1 = unknown bit 1 = enable tile X flip when tile color attribute bit 6 is set
bit 2 = unknown 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 00f unused
*/ */
@ -39,6 +40,7 @@ control registers
#include "emu.h" #include "emu.h"
#include "k051316.h" #include "k051316.h"
#include <algorithm>
#define VERBOSE 0 #define VERBOSE 0
#include "logmacro.h" #include "logmacro.h"
@ -104,7 +106,7 @@ GFXDECODE_MEMBER( k051316_device::gfxinfo4_ram )
GFXDECODE_END 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_t(mconfig, K051316, tag, owner, clock)
, device_gfx_interface(mconfig, *this, gfxinfo) , device_gfx_interface(mconfig, *this, gfxinfo)
, m_zoom_rom(*this, DEVICE_SELF) , 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_pixels_per_byte(2) // 4bpp layout is default
, m_layermask(0) , m_layermask(0)
, m_k051316_cb(*this) , 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); m_tmap->map_pens_to_layer(0, m_layermask, m_layermask, TILEMAP_PIXEL_LAYER0);
} }
else else
{
m_tmap->set_transparent_pen(0); m_tmap->set_transparent_pen(0);
}
save_item(NAME(m_ram)); save_item(NAME(m_ram));
save_item(NAME(m_ctrlram)); save_item(NAME(m_ctrlram));
save_item(NAME(m_wrap)); 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() 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) 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); int addr = offset + (m_ctrlram[0x0c] << 11) + (m_ctrlram[0x0d] << 19);
addr /= m_pixels_per_byte; 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) 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); //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 // 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; m_wrap = status;
} }
@ -248,9 +268,15 @@ TILE_GET_INFO_MEMBER(k051316_device::get_tile_info)
{ {
int code = m_ram[tile_index]; int code = m_ram[tile_index];
int color = m_ram[tile_index + 0x400]; 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, tileinfo.set(0,
code, 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; int incxx, incxy, incyx, incyy;
startx = 256 * ((int16_t)(256 * m_ctrlram[0x00] + m_ctrlram[0x01])); 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); flags, priority);
#if 0 #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[0x00],
m_ctrlram[0x01], m_ctrlram[0x01],
m_ctrlram[0x02], m_ctrlram[0x02],
@ -297,8 +323,6 @@ void k051316_device::zoom_draw( screen_device &screen, bitmap_ind16 &bitmap, con
m_ctrlram[0x0a], m_ctrlram[0x0a],
m_ctrlram[0x0b], m_ctrlram[0x0b],
m_ctrlram[0x0c], /* bank for ROM testing */ m_ctrlram[0x0c], /* bank for ROM testing */
m_ctrlram[0x0d], m_ctrlram[0x0d]);
m_ctrlram[0x0e], /* 0 = test ROMs */
m_ctrlram[0x0f]);
#endif #endif
} }

View File

@ -8,15 +8,15 @@
#include "tilemap.h" #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 class k051316_device : public device_t, public device_gfx_interface
{ {
public: public:
using zoom_delegate = device_delegate<void (int *code, int *color, int *flags)>; using zoom_delegate = device_delegate<void (int *code, int *color)>;
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 charlayout4;
static const gfx_layout charlayout7; static const gfx_layout charlayout7;
@ -45,7 +45,6 @@ public:
The callback must put: The callback must put:
- in code the resulting tile number - in code the resulting tile number
- in color the resulting color index - in color the resulting color index
- if necessary, put flags for the TileMap code in the tile_info
structure (e.g. TILE_FLIPX) structure (e.g. TILE_FLIPX)
*/ */
@ -53,7 +52,7 @@ public:
void write(offs_t offset, u8 data); void write(offs_t offset, u8 data);
u8 rom_r(offs_t offset); u8 rom_r(offs_t offset);
void ctrl_w(offs_t offset, u8 data); 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 wraparound_enable(int status);
void mark_gfx_dirty(offs_t byteoffset) { gfx(0)->mark_dirty(byteoffset * m_pixels_per_byte / (16 * 16)); } void mark_gfx_dirty(offs_t byteoffset) { gfx(0)->mark_dirty(byteoffset * m_pixels_per_byte / (16 * 16)); }
@ -67,8 +66,8 @@ protected:
private: private:
// internal state // internal state
std::vector<uint8_t> m_ram; std::vector<uint8_t> m_ram;
uint8_t m_ctrlram[16]; uint8_t m_ctrlram[14];
tilemap_t *m_tmap = nullptr; tilemap_t *m_tmap;
optional_region_ptr<uint8_t> m_zoom_rom; optional_region_ptr<uint8_t> m_zoom_rom;
@ -77,6 +76,9 @@ private:
int m_pixels_per_byte; int m_pixels_per_byte;
int m_layermask; int m_layermask;
zoom_delegate m_k051316_cb; zoom_delegate m_k051316_cb;
bool m_readout_enabled;
bool m_flipx_enabled;
bool m_flipy_enabled;
TILE_GET_INFO_MEMBER(get_tile_info); TILE_GET_INFO_MEMBER(get_tile_info);
}; };

View File

@ -46,7 +46,6 @@ K051316_CB_MEMBER(_88games_state::zoom_callback)
{ {
enum { zoom_colorbase = 768 / 16 }; enum { zoom_colorbase = 768 / 16 };
*flags = (*color & 0x40) ? TILE_FLIPX : 0;
*code |= ((*color & 0x07) << 8); *code |= ((*color & 0x07) << 8);
*color = zoom_colorbase + ((*color & 0x38) >> 3) + ((*color & 0x80) >> 4); *color = zoom_colorbase + ((*color & 0x38) >> 3) + ((*color & 0x80) >> 4);
} }

View File

@ -143,7 +143,6 @@ K051316_CB_MEMBER(bottom9_state::zoom_callback)
{ {
enum { zoom_colorbase = 768 / 16 }; enum { zoom_colorbase = 768 / 16 };
*flags = (*color & 0x40) ? TILE_FLIPX : 0;
*code |= ((*color & 0x03) << 8); *code |= ((*color & 0x03) << 8);
*color = zoom_colorbase + ((*color & 0x3c) >> 2); *color = zoom_colorbase + ((*color & 0x3c) >> 2);
} }

View File

@ -45,7 +45,6 @@ K051316_CB_MEMBER(chqflag_state::zoom_callback_2)
{ {
enum { zoom_colorbase_2 = 512 / 256 }; enum { zoom_colorbase_2 = 512 / 256 };
*flags = TILE_FLIPYX((*color & 0xc0) >> 6);
*code |= ((*color & 0x0f) << 8); *code |= ((*color & 0x0f) << 8);
*color = zoom_colorbase_2 + ((*color & 0x10) >> 4); *color = zoom_colorbase_2 + ((*color & 0x10) >> 4);
} }

View File

@ -264,14 +264,12 @@ K053246_CB_MEMBER(overdriv_state::sprite_callback)
K051316_CB_MEMBER(overdriv_state::zoom_callback_1) K051316_CB_MEMBER(overdriv_state::zoom_callback_1)
{ {
*flags = (*color & 0x40) ? TILE_FLIPX : 0;
*code |= ((*color & 0x03) << 8); *code |= ((*color & 0x03) << 8);
*color = m_zoom_colorbase[0] + ((*color & 0x3c) >> 2); *color = m_zoom_colorbase[0] + ((*color & 0x3c) >> 2);
} }
K051316_CB_MEMBER(overdriv_state::zoom_callback_2) K051316_CB_MEMBER(overdriv_state::zoom_callback_2)
{ {
*flags = (*color & 0x40) ? TILE_FLIPX : 0;
*code |= ((*color & 0x03) << 8); *code |= ((*color & 0x03) << 8);
*color = m_zoom_colorbase[1] + ((*color & 0x3c) >> 2); *color = m_zoom_colorbase[1] + ((*color & 0x3c) >> 2);
} }

View File

@ -119,7 +119,6 @@ K05324X_CB_MEMBER(rollerg_state::sprite_callback)
K051316_CB_MEMBER(rollerg_state::zoom_callback) K051316_CB_MEMBER(rollerg_state::zoom_callback)
{ {
*flags = TILE_FLIPYX((*color & 0xc0) >> 6);
*code |= ((*color & 0x0f) << 8); *code |= ((*color & 0x0f) << 8);
*color = ((*color & 0x30) >> 4); *color = ((*color & 0x30) >> 4);
} }