deco_ace.cpp/h: Really fix line endings (nw)

This commit is contained in:
AJR 2018-01-25 09:45:55 -05:00
parent ef00dcaf54
commit bb5e199335
2 changed files with 0 additions and 328 deletions

View File

@ -1,518 +1,264 @@
// license:BSD-3-Clause
// copyright-holders:Bryan McPhail
/*************************************************************************
deco_ace.cpp
Data East 99 "ACE" Chip Emulation
Original source (from deco32.cpp) by Bryan McPhail, Splited by cam900.
**************************************************************************/
/*Some notes pieced together from Tattoo Assassins info(from deco32.cpp):
Bytes 0 to 0x1f : Alpha Control
Tattoo Assassins :
Bytes 0x00 to 0x16(0x58) - object alpha control?
Bytes 0x17(0x5c) to 0x1f(0x7c) - tilemap alpha control
Boogie Wings:
Bytes 0x00 to 0x0f(0x1f) - object alpha control (if ((pix & 0x100) == 0))
Bytes 0x10(0x20) to 0x13(0x26) - another object alpha control?
Bytes 0x14(0x28) to 0x19(0x32) - fixed value 0x1c 0x18 0x14 0x10 0x0c 0x08. it controls explosion object's alpha?
Bytes 0x1a(0x34) to 0x1f(0x3f) - tilemap alpha control?
0 = opaque, 0x10 = 50% transparent, 0x20 = fully transparent
Byte 0x00: ACEO000P0
P8
1P0
1P8
O010C1
o010C8
??
Hardware fade registers:
Byte 0x20(0x80): fadeptred
Byte 0x21(0x84): fadeptgreen
Byte 0x22(0x88): fadeptblue
Byte 0x23(0x8c): fadestred
Byte 0x24(0x90): fadestgreen
Byte 0x25(0x94): fadestblue
Byte 0x26(0x98): fadetype
Byte 0x27(0x9c): unused/unknown
The 'ST' value lerps between the 'PT' value and the palette entries. So, if PT==0,
then ST ranging from 0 to 255 will cause a fade to black (when ST==255 the palette
becomes zero).
'fadetype' - 1100 for multiplicative fade, 1000 for additive
TODO:
additive fade is correct? verify additive fading from real pcb.
*/
#include "emu.h"
#include "video/deco_ace.h"
DEFINE_DEVICE_TYPE(DECO_ACE, deco_ace_device, "deco_ace", "Data East 99 'ACE' Chip")
deco_ace_device::deco_ace_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, DECO_ACE, tag, owner, clock),
device_video_interface(mconfig, *this),
m_palette_effect_min(0x100),
m_palette_effect_max(0xfff),
m_palette(*this, finder_base::DUMMY_TAG),
m_paletteram(nullptr),
m_paletteram_buffered(nullptr),
m_ace_ram(nullptr)
{
}
//-------------------------------------------------
// static_set_palette_tag: Set the tag of the
// palette device
//-------------------------------------------------
void deco_ace_device::static_set_palette_tag(device_t &device, const char *tag)
{
downcast<deco_ace_device &>(device).m_palette.set_tag(tag);
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void deco_ace_device::device_start()
{
m_paletteram = make_unique_clear<uint32_t[]>(4096);
m_paletteram_buffered = make_unique_clear<uint32_t[]>(4096);
m_ace_ram = make_unique_clear<uint16_t[]>(0x28);
save_pointer(NAME(m_paletteram.get()), 4096);
save_pointer(NAME(m_paletteram_buffered.get()), 4096);
save_pointer(NAME(m_ace_ram.get()), 0x28);
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void deco_ace_device::device_reset()
{
m_palette_effect_min = 0x100; /* Screenshots seem to suggest ACE fades do not affect playfield 1 palette (0-255) */
m_palette_effect_max = 0xfff;
memset(m_ace_ram.get(),0,0x28);
}
//-------------------------------------------------
// device_post_load - device-specific post-load
//-------------------------------------------------
void deco_ace_device::device_post_load()
{
palette_update();
}
/*****************************************************************************
DEVICE HANDLERS
*****************************************************************************/
/* Games have double buffered paletteram - the real palette ram is
only updated on a DMA call */
// nslasher
READ32_MEMBER( deco_ace_device::buffered_palette_r )
{
return m_paletteram[offset];
}
WRITE32_MEMBER( deco_ace_device::buffered_palette_w )
{
COMBINE_DATA(&m_paletteram[offset]);
}
// boogwing has 16 bit cpu data bus(M68000 Based)
READ16_MEMBER( deco_ace_device::buffered_palette16_r )
{
if ((offset & 1) == 0)
return (m_paletteram[offset >> 1] >> 16) & 0xffff;
else
return m_paletteram[offset >> 1] & 0xffff;
}
WRITE16_MEMBER( deco_ace_device::buffered_palette16_w )
{
if ((offset & 1) == 0)
m_paletteram[offset >> 1] = (m_paletteram[offset >> 1] & ~(mem_mask<<16)) | ((data & mem_mask)<<16);
else
m_paletteram[offset >> 1] = (m_paletteram[offset >> 1] & ~mem_mask) | (data & mem_mask);
}
READ16_MEMBER( deco_ace_device::ace_r )
{
return m_ace_ram[offset];
}
WRITE16_MEMBER( deco_ace_device::ace_w )
{
COMBINE_DATA(&m_ace_ram[offset]);
if ((offset >= 0x20) && (offset <= 0x26))
palette_update();
}
void deco_ace_device::palette_update()
{
int r,g,b,i;
uint8_t fadeptr=m_ace_ram[0x20] & 0xff;
uint8_t fadeptg=m_ace_ram[0x21] & 0xff;
uint8_t fadeptb=m_ace_ram[0x22] & 0xff;
uint8_t fadepsr=m_ace_ram[0x23] & 0xff;
uint8_t fadepsg=m_ace_ram[0x24] & 0xff;
uint8_t fadepsb=m_ace_ram[0x25] & 0xff;
uint16_t mode=m_ace_ram[0x26] & 0xffff;
for (i=0; i<2048; i++)
{
/* Lerp palette entry to 'fadept' according to 'fadeps' */
b = (m_paletteram_buffered[i] >>16) & 0xff;
g = (m_paletteram_buffered[i] >> 8) & 0xff;
r = (m_paletteram_buffered[i] >> 0) & 0xff;
if ((i>=m_palette_effect_min) && (i<=m_palette_effect_max))
{
switch (mode)
{
default:
case 0x1100: // multiplicative fade
/* Yeah, this should really be fixed point, I know */
b = (uint8_t)((float)b + (((float)fadeptb - (float)b) * (float)fadepsb/255.0f));
g = (uint8_t)((float)g + (((float)fadeptg - (float)g) * (float)fadepsg/255.0f));
r = (uint8_t)((float)r + (((float)fadeptr - (float)r) * (float)fadepsr/255.0f));
break;
case 0x1000: // additive fade, correct?
b = std::min(b + fadepsb, 0xff);
g = std::min(g + fadepsg, 0xff);
r = std::min(r + fadepsr, 0xff);
break;
}
}
m_palette->set_pen_color(i,rgb_t(r,g,b));
}
}
/*************************************************************************
set_palette_effect_max : Change Palette effect max bound (uses boogwing)
*************************************************************************/
void deco_ace_device::set_palette_effect_max(uint32_t val)
{
if (m_palette_effect_max != val)
{
m_palette_effect_max = val;
palette_update();
}
}
/*************************************************************************
get_alpha : Get alpha value (ACE RAM Area 0x00 - 0x1f)
*************************************************************************/
uint8_t deco_ace_device::get_alpha(uint8_t val)
{
val &= 0x1f;
int alpha = m_ace_ram[val] & 0xff;
if (alpha > 0x20)
{
return 0x80; // TODO
}
else
{
alpha = 255 - (alpha << 3);
if (alpha < 0)
alpha = 0;
return (uint8_t)alpha;
}
}
/*************************************************************************
get_aceram : Get ACE RAM value
*************************************************************************/
uint16_t deco_ace_device::get_aceram(uint8_t val)
{
val &= 0x3f;
return m_ace_ram[val];
}
WRITE16_MEMBER( deco_ace_device::palette_dma_w )
{
memcpy(m_paletteram_buffered.get(), m_paletteram.get(), 4096);
palette_update();
}
/*****************************************************************************************/

View File

@ -1,148 +1,74 @@
// license:BSD-3-Clause
// copyright-holders:Bryan McPhail
/*************************************************************************
deco_ace.h
Data East 99 "ACE" Chip Emulation
Original source (from deco32.cpp) by Bryan McPhail, Splited by cam900.
**************************************************************************/
#ifndef MAME_VIDEO_DECO_ACE_H
#define MAME_VIDEO_DECO_ACE_H
#pragma once
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
class deco_ace_device : public device_t,
public device_video_interface
{
public:
deco_ace_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// static configuration
static void static_set_palette_tag(device_t &device, const char *tag);
DECLARE_READ32_MEMBER( buffered_palette_r );
DECLARE_READ16_MEMBER( buffered_palette16_r );
DECLARE_READ16_MEMBER( ace_r );
DECLARE_WRITE32_MEMBER( buffered_palette_w );
DECLARE_WRITE16_MEMBER( buffered_palette16_w );
DECLARE_WRITE16_MEMBER( ace_w );
void palette_update();
void set_palette_effect_max(uint32_t val);
uint16_t get_aceram(uint8_t val);
uint8_t get_alpha(uint8_t val);
DECLARE_WRITE16_MEMBER( palette_dma_w );
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_post_load() override;
private:
// internal state
uint32_t m_palette_effect_min;
uint32_t m_palette_effect_max;
required_device<palette_device> m_palette;
std::unique_ptr<uint32_t[]> m_paletteram;
std::unique_ptr<uint32_t[]> m_paletteram_buffered;
std::unique_ptr<uint16_t[]> m_ace_ram;
};
DECLARE_DEVICE_TYPE(DECO_ACE, deco_ace_device)
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
#define MCFG_DECO_ACE_ADD(_tag) \
MCFG_DEVICE_ADD(_tag, DECO_ACE, 0)
#define MCFG_DECO_ACE_PALETTE(_palette_tag) \
deco_ace_device::static_set_palette_tag(*device, "^" _palette_tag);
#endif // MAME_VIDEO_DECO_ACE_H