chqflag.cpp: k051937 actually sets up a register when background should be dimmed, fixes start/end pouring event colors [Angelo Salese]

This commit is contained in:
angelosa 2017-11-17 02:14:21 +01:00
parent 149def928f
commit 1fb897055a
4 changed files with 45 additions and 13 deletions

View File

@ -57,14 +57,6 @@ WRITE8_MEMBER(chqflag_state::chqflag_bankswitch_w)
/* other bits unknown/unused */ /* other bits unknown/unused */
} }
inline void chqflag_state::update_background_shadows(uint8_t data)
{
double brt = (data & 0x80) ? PALETTE_DEFAULT_SHADOW_FACTOR : 1.0;
for (int i = 512; i < 1024; i++)
m_palette->set_pen_contrast(i, brt);
}
WRITE8_MEMBER(chqflag_state::chqflag_vreg_w) WRITE8_MEMBER(chqflag_state::chqflag_vreg_w)
{ {
/* bits 0 & 1 = coin counters */ /* bits 0 & 1 = coin counters */
@ -86,12 +78,13 @@ WRITE8_MEMBER(chqflag_state::chqflag_vreg_w)
* 0x88 is for when night shows up (max amount of highlight) * 0x88 is for when night shows up (max amount of highlight)
* 0x08 is used at dawn after 0x88 state * 0x08 is used at dawn after 0x88 state
* The shadow part looks ugly when rain starts/ends pouring (-> black colored with a setting of 0x00), * The shadow part looks ugly when rain starts/ends pouring (-> black colored with a setting of 0x00),
* apparently the reference shows dimmed background when car pits in which maybe translates in a * the reference shows dimmed background when this event occurs (which is handled via reg 1 bit 0 of k051960 device),
* global zoomed sprite that gets clipped in emulation? * might be actually disabling the shadow here (-> setting 1.0f instead), but can't say for sure from the available reference.
*/ */
const float shadow_factors[4] = {PALETTE_DEFAULT_SHADOW_FACTOR, 1.33f, 1.66f, 2.0f }; const float shadow_factors[4] = {PALETTE_DEFAULT_SHADOW_FACTOR, 1.33f, 1.66f, 2.0f };
m_palette->set_shadow_factor(shadow_factors[((data & 0x80) >> 6) | ((data & 0x08) >> 3)]); m_palette->set_shadow_factor(shadow_factors[((data & 0x80) >> 6) | ((data & 0x08) >> 3)]);
#if 0
if ((data & 0x80) != m_last_vreg) if ((data & 0x80) != m_last_vreg)
{ {
m_last_vreg = data & 0x80; m_last_vreg = data & 0x80;
@ -99,6 +92,7 @@ WRITE8_MEMBER(chqflag_state::chqflag_vreg_w)
/* only affect the background */ /* only affect the background */
update_background_shadows(data); update_background_shadows(data);
} }
#endif
//if ((data & 0xf8) && (data & 0xf8) != 0x88) //if ((data & 0xf8) && (data & 0xf8) != 0x88)
// popmessage("chqflag_vreg_w %02x",data); // popmessage("chqflag_vreg_w %02x",data);
@ -301,6 +295,26 @@ void chqflag_state::machine_reset()
update_background_shadows(0); update_background_shadows(0);
} }
inline void chqflag_state::update_background_shadows(uint8_t data)
{
double brt = (data & 1) ? PALETTE_DEFAULT_SHADOW_FACTOR : 1.0;
for (int i = 512; i < 1024; i++)
m_palette->set_pen_contrast(i, brt);
}
WRITE_LINE_MEMBER(chqflag_state::background_brt_w)
{
// popmessage("%d",state);
if (state != m_last_vreg)
{
m_last_vreg = state;
update_background_shadows(state);
}
}
static MACHINE_CONFIG_START( chqflag ) static MACHINE_CONFIG_START( chqflag )
/* basic machine hardware */ /* basic machine hardware */
@ -339,6 +353,7 @@ static MACHINE_CONFIG_START( chqflag )
MCFG_K051960_CB(chqflag_state, sprite_callback) MCFG_K051960_CB(chqflag_state, sprite_callback)
MCFG_K051960_IRQ_HANDLER(INPUTLINE("maincpu", KONAMI_IRQ_LINE)) MCFG_K051960_IRQ_HANDLER(INPUTLINE("maincpu", KONAMI_IRQ_LINE))
MCFG_K051960_NMI_HANDLER(INPUTLINE("maincpu", INPUT_LINE_NMI)) MCFG_K051960_NMI_HANDLER(INPUTLINE("maincpu", INPUT_LINE_NMI))
MCFG_K051960_VREG_CONTRAST_HANDLER(WRITELINE(chqflag_state,background_brt_w))
MCFG_DEVICE_ADD("k051316_1", K051316, 0) MCFG_DEVICE_ADD("k051316_1", K051316, 0)
MCFG_GFX_PALETTE("palette") MCFG_GFX_PALETTE("palette")

View File

@ -41,6 +41,7 @@ public:
DECLARE_WRITE8_MEMBER(k007232_extvolume_w); DECLARE_WRITE8_MEMBER(k007232_extvolume_w);
DECLARE_WRITE8_MEMBER(volume_callback0); DECLARE_WRITE8_MEMBER(volume_callback0);
DECLARE_WRITE8_MEMBER(volume_callback1); DECLARE_WRITE8_MEMBER(volume_callback1);
DECLARE_WRITE_LINE_MEMBER(background_brt_w);
K051316_CB_MEMBER(zoom_callback_1); K051316_CB_MEMBER(zoom_callback_1);
K051316_CB_MEMBER(zoom_callback_2); K051316_CB_MEMBER(zoom_callback_2);
K051960_CB_MEMBER(sprite_callback); K051960_CB_MEMBER(sprite_callback);

View File

@ -38,6 +38,7 @@ memory map:
001 W Devastators sets bit 1, function unknown. 001 W Devastators sets bit 1, function unknown.
Ultraman sets the register to 0x0f. Ultraman sets the register to 0x0f.
None of the other games I tested seem to set this register to other than 0. None of the other games I tested seem to set this register to other than 0.
Update: Chequered Flag sets bit 0 when background should be dimmed (palette control?)
002-003 W selects the portion of the gfx ROMs to be read. 002-003 W selects the portion of the gfx ROMs to be read.
004 W Aliens uses this to select the ROM bank to be read, but Punk Shot 004 W Aliens uses this to select the ROM bank to be read, but Punk Shot
and TMNT don't, they use another bit of the registers above. Many and TMNT don't, they use another bit of the registers above. Many
@ -136,6 +137,7 @@ k051960_device::k051960_device(const machine_config &mconfig, const char *tag, d
, m_irq_handler(*this) , m_irq_handler(*this)
, m_firq_handler(*this) , m_firq_handler(*this)
, m_nmi_handler(*this) , m_nmi_handler(*this)
, m_vreg_contrast_handler(*this)
, m_romoffset(0) , m_romoffset(0)
, m_spriteflip(0) , m_spriteflip(0)
, m_readroms(0) , m_readroms(0)
@ -207,6 +209,7 @@ void k051960_device::device_start()
m_irq_handler.resolve_safe(); m_irq_handler.resolve_safe();
m_firq_handler.resolve_safe(); m_firq_handler.resolve_safe();
m_nmi_handler.resolve_safe(); m_nmi_handler.resolve_safe();
m_vreg_contrast_handler.resolve_safe();
// register for save states // register for save states
save_item(NAME(m_romoffset)); save_item(NAME(m_romoffset));
@ -330,6 +333,10 @@ WRITE8_MEMBER( k051960_device::k051937_w )
} }
else if (offset == 1) else if (offset == 1)
{ {
//popmessage("%04x: write %02x to 051937 address %x", space.device().safe_pc(), data, offset);
// Chequered Flag uses this bit to enable background palette dimming
// TODO: use a callback here for now, pending further investigation over this bit
m_vreg_contrast_handler(BIT(data,0));
// unknown, Devastators writes 02 here in game // unknown, Devastators writes 02 here in game
if (0) if (0)
logerror("%s: %02x to 051937 address %x\n", machine().describe_context(), data, offset); logerror("%s: %02x to 051937 address %x\n", machine().describe_context(), data, offset);

View File

@ -33,6 +33,9 @@ typedef device_delegate<void (int *code, int *color, int *priority, int *shadow)
#define MCFG_K051960_NMI_HANDLER(_devcb) \ #define MCFG_K051960_NMI_HANDLER(_devcb) \
devcb = &k051960_device::set_nmi_handler(*device, DEVCB_##_devcb); devcb = &k051960_device::set_nmi_handler(*device, DEVCB_##_devcb);
#define MCFG_K051960_VREG_CONTRAST_HANDLER(_devcb) \
devcb = &k051960_device::set_vreg_contrast_handler(*device, DEVCB_##_devcb);
class k051960_device : public device_t, public device_gfx_interface class k051960_device : public device_t, public device_gfx_interface
{ {
@ -52,6 +55,10 @@ public:
template <class Object> static devcb_base &set_nmi_handler(device_t &device, Object &&cb) template <class Object> static devcb_base &set_nmi_handler(device_t &device, Object &&cb)
{ return downcast<k051960_device &>(device).m_nmi_handler.set_callback(std::forward<Object>(cb)); } { return downcast<k051960_device &>(device).m_nmi_handler.set_callback(std::forward<Object>(cb)); }
template <class Object> static devcb_base &set_vreg_contrast_handler(device_t &device, Object &&cb)
{ return downcast<k051960_device &>(device).m_vreg_contrast_handler.set_callback(std::forward<Object>(cb)); }
// static configuration // static configuration
static void set_k051960_callback(device_t &device, k051960_cb_delegate callback) { downcast<k051960_device &>(device).m_k051960_cb = callback; } static void set_k051960_callback(device_t &device, k051960_cb_delegate callback) { downcast<k051960_device &>(device).m_k051960_cb = callback; }
static void set_plane_order(device_t &device, int order); static void set_plane_order(device_t &device, int order);
@ -98,8 +105,10 @@ private:
k051960_cb_delegate m_k051960_cb; k051960_cb_delegate m_k051960_cb;
devcb_write_line m_irq_handler; devcb_write_line m_irq_handler;
// TODO: is this even used by anything?
devcb_write_line m_firq_handler; devcb_write_line m_firq_handler;
devcb_write_line m_nmi_handler; devcb_write_line m_nmi_handler;
devcb_write_line m_vreg_contrast_handler;
uint8_t m_spriterombank[3]; uint8_t m_spriterombank[3];
int m_romoffset; int m_romoffset;