From ef00dcaf54f2922fdbbdc336230c1fed29dce48f Mon Sep 17 00:00:00 2001 From: AJR Date: Thu, 25 Jan 2018 09:43:27 -0500 Subject: cninja.cpp: Fix compile (nw) deco_ace.cpp/h: Fix line endings (nw) --- src/mame/drivers/cninja.cpp | 4 +- src/mame/video/deco_ace.cpp | 764 +++++++++++++++++++++++++++++--------------- src/mame/video/deco_ace.h | 222 ++++++++----- 3 files changed, 659 insertions(+), 331 deletions(-) diff --git a/src/mame/drivers/cninja.cpp b/src/mame/drivers/cninja.cpp index dc90dbd4e24..a4700bc50a3 100644 --- a/src/mame/drivers/cninja.cpp +++ b/src/mame/drivers/cninja.cpp @@ -87,7 +87,7 @@ READ16_MEMBER( cninja_state::cninja_protection_region_0_104_r ) int real_address = 0 + (offset *2); int deco146_addr = bitswap<32>(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 10,9,8, 7,6,5,4, 3,2,1,0) & 0x7fff; uint8_t cs = 0; - uint16_t data = m_deco104->read_data( deco146_addr, mem_mask, cs ); + uint16_t data = m_ioprot->read_data( deco146_addr, mem_mask, cs ); return data; } @@ -96,7 +96,7 @@ WRITE16_MEMBER( cninja_state::cninja_protection_region_0_104_w ) int real_address = 0 + (offset *2); int deco146_addr = bitswap<32>(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 10,9,8, 7,6,5,4, 3,2,1,0) & 0x7fff; uint8_t cs = 0; - m_deco104->write_data( space, deco146_addr, data, mem_mask, cs ); + m_ioprot->write_data( space, deco146_addr, data, mem_mask, cs ); } READ16_MEMBER(cninja_state::cninjabl2_sprite_dma_r) diff --git a/src/mame/video/deco_ace.cpp b/src/mame/video/deco_ace.cpp index 65260b7a864..28dd3f82849 100644 --- a/src/mame/video/deco_ace.cpp +++ b/src/mame/video/deco_ace.cpp @@ -1,264 +1,518 @@ -// 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(device).m_palette.set_tag(tag); -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void deco_ace_device::device_start() -{ - m_paletteram = make_unique_clear(4096); - m_paletteram_buffered = make_unique_clear(4096); - m_ace_ram = make_unique_clear(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; +// 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(device).m_palette.set_tag(tag); + +} + + + +//------------------------------------------------- + +// device_start - device-specific startup + +//------------------------------------------------- + + + +void deco_ace_device::device_start() + +{ + + m_paletteram = make_unique_clear(4096); + + m_paletteram_buffered = make_unique_clear(4096); + + m_ace_ram = make_unique_clear(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]); +} + + + +//------------------------------------------------- + +// 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() +} + + + +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; - } - } + 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) - { + } + +} + + + +/************************************************************************* + + + + 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 ) -{ + } + +} + + + +/************************************************************************* + + + + 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(); -} - -/*****************************************************************************************/ +} + + + +/*****************************************************************************************/ + diff --git a/src/mame/video/deco_ace.h b/src/mame/video/deco_ace.h index 88bf7a237d2..e3ae2633013 100644 --- a/src/mame/video/deco_ace.h +++ b/src/mame/video/deco_ace.h @@ -1,74 +1,148 @@ -// 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 m_palette; - std::unique_ptr m_paletteram; - std::unique_ptr m_paletteram_buffered; - std::unique_ptr 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 +// 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 m_palette; + + std::unique_ptr m_paletteram; + + std::unique_ptr m_paletteram_buffered; + + std::unique_ptr 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 + -- cgit v1.2.3