From 0d897d07e65826352fba147ce644a901b2cce7bc Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 1 Apr 2021 21:01:36 +0200 Subject: namcos2/c355 sprites: color 0xfe is for a palette offset instead of shadow [dink, hap] --- src/mame/drivers/namconb1.cpp | 8 +- src/mame/drivers/namcos2.cpp | 10 +- src/mame/drivers/tceptor.cpp | 2 +- src/mame/includes/namcos2.h | 2 +- src/mame/includes/tceptor.h | 2 +- src/mame/video/c45.cpp | 267 -------------------------------------- src/mame/video/c45.h | 69 ---------- src/mame/video/namco_c116.h | 5 +- src/mame/video/namco_c123tmap.h | 2 +- src/mame/video/namco_c169roz.h | 2 +- src/mame/video/namco_c355spr.cpp | 15 +-- src/mame/video/namco_c355spr.h | 2 +- src/mame/video/namco_c45road.cpp | 267 ++++++++++++++++++++++++++++++++++++++ src/mame/video/namco_c45road.h | 69 ++++++++++ src/mame/video/namcos2_sprite.cpp | 5 +- 15 files changed, 359 insertions(+), 368 deletions(-) delete mode 100644 src/mame/video/c45.cpp delete mode 100644 src/mame/video/c45.h create mode 100644 src/mame/video/namco_c45road.cpp create mode 100644 src/mame/video/namco_c45road.h (limited to 'src') diff --git a/src/mame/drivers/namconb1.cpp b/src/mame/drivers/namconb1.cpp index ad505fbc38f..9c068d4985a 100644 --- a/src/mame/drivers/namconb1.cpp +++ b/src/mame/drivers/namconb1.cpp @@ -986,7 +986,7 @@ void namconb1_state::namconb1(machine_config &config) m_screen->screen_vblank().set(FUNC(namconb1_state::screen_vblank)); m_screen->set_palette(m_c116); - NAMCO_C355SPR(config, m_c355spr, 0); + NAMCO_C355SPR(config, m_c355spr); m_c355spr->set_screen(m_screen); m_c355spr->set_palette(m_c116); m_c355spr->set_scroll_offsets(0x26, 0x19); @@ -995,12 +995,12 @@ void namconb1_state::namconb1(machine_config &config) m_c355spr->set_buffer(2); // triple buffered m_c355spr->set_color_base(0); - NAMCO_C123TMAP(config, m_c123tmap, 0); + NAMCO_C123TMAP(config, m_c123tmap); m_c123tmap->set_palette(m_c116); m_c123tmap->set_tile_callback(namco_c123tmap_device::c123_tilemap_delegate(&namconb1_state::NB1TilemapCB, this)); m_c123tmap->set_color_base(0x1000); - NAMCO_C116(config, m_c116, 0); + NAMCO_C116(config, m_c116); m_c116->enable_shadows(); SPEAKER(config, "lspeaker").front_left(); @@ -1021,7 +1021,7 @@ void namconb1_state::namconb2(machine_config &config) m_screen->set_screen_update(FUNC(namconb1_state::screen_update_namconb2)); - NAMCO_C169ROZ(config, m_c169roz, 0); + NAMCO_C169ROZ(config, m_c169roz); m_c169roz->set_palette(m_c116); m_c169roz->set_is_namcofl(false); m_c169roz->set_ram_words(0x20000 / 2); diff --git a/src/mame/drivers/namcos2.cpp b/src/mame/drivers/namcos2.cpp index d528c9baf9b..7b1f209f322 100644 --- a/src/mame/drivers/namcos2.cpp +++ b/src/mame/drivers/namcos2.cpp @@ -1641,7 +1641,7 @@ via software as INT1 void namcos2_state::configure_c116_standard(machine_config &config) { - NAMCO_C116(config, m_c116, 0); + NAMCO_C116(config, m_c116); m_c116->enable_shadows(); } @@ -1761,7 +1761,7 @@ TIMER_DEVICE_CALLBACK_MEMBER(namcos2_state::screen_scanline) void namcos2_state::configure_c123tmap_standard(machine_config &config) { - NAMCO_C123TMAP(config, m_c123tmap, 0); + NAMCO_C123TMAP(config, m_c123tmap); m_c123tmap->set_palette(m_c116); m_c123tmap->set_tile_callback(namco_c123tmap_device::c123_tilemap_delegate(&namcos2_state::TilemapCB, this)); m_c123tmap->set_color_base(16*256); @@ -1769,7 +1769,7 @@ void namcos2_state::configure_c123tmap_standard(machine_config &config) void namcos2_state::configure_c169roz_standard(machine_config &config) { - NAMCO_C169ROZ(config, m_c169roz, 0); + NAMCO_C169ROZ(config, m_c169roz); m_c169roz->set_palette(m_c116); m_c169roz->set_is_namcofl(false); m_c169roz->set_ram_words(0x10000/2); @@ -1778,7 +1778,7 @@ void namcos2_state::configure_c169roz_standard(machine_config &config) void namcos2_state::configure_c355spr_standard(machine_config &config) { - NAMCO_C355SPR(config, m_c355spr, 0); + NAMCO_C355SPR(config, m_c355spr); m_c355spr->set_screen(m_screen); m_c355spr->set_palette(m_c116); m_c355spr->set_scroll_offsets(0x26, 0x19); @@ -1789,7 +1789,7 @@ void namcos2_state::configure_c355spr_standard(machine_config &config) void namcos2_state::configure_c45road_standard(machine_config &config) { - NAMCO_C45_ROAD(config, m_c45_road, 0); + NAMCO_C45_ROAD(config, m_c45_road); m_c45_road->set_palette(m_c116); } diff --git a/src/mame/drivers/tceptor.cpp b/src/mame/drivers/tceptor.cpp index 5a99944a50b..9d403a3a8b7 100644 --- a/src/mame/drivers/tceptor.cpp +++ b/src/mame/drivers/tceptor.cpp @@ -343,7 +343,7 @@ void tceptor_state::tceptor(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_tceptor); PALETTE(config, m_palette, FUNC(tceptor_state::tceptor_palette), 4096, 1024); - NAMCO_C45_ROAD(config, m_c45_road, 0); + NAMCO_C45_ROAD(config, m_c45_road); m_c45_road->set_palette(m_palette); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); diff --git a/src/mame/includes/namcos2.h b/src/mame/includes/namcos2.h index 383eab59c38..14cad5bc2cc 100644 --- a/src/mame/includes/namcos2.h +++ b/src/mame/includes/namcos2.h @@ -16,7 +16,7 @@ #include "machine/namco_c148.h" #include "machine/timer.h" #include "sound/c140.h" -#include "video/c45.h" +#include "video/namco_c45road.h" #include "video/namco_c116.h" #include "machine/namco65.h" #include "machine/namco68.h" diff --git a/src/mame/includes/tceptor.h b/src/mame/includes/tceptor.h index c018da7d105..782ca290bef 100644 --- a/src/mame/includes/tceptor.h +++ b/src/mame/includes/tceptor.h @@ -7,7 +7,7 @@ #include "cpu/m6502/m65c02.h" #include "sound/namco.h" -#include "video/c45.h" +#include "video/namco_c45road.h" #include "emupal.h" #include "screen.h" #include "tilemap.h" diff --git a/src/mame/video/c45.cpp b/src/mame/video/c45.cpp deleted file mode 100644 index 35f6659f10e..00000000000 --- a/src/mame/video/c45.cpp +++ /dev/null @@ -1,267 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Phil Stroffolino, Aaron Giles, Alex W. Jackson -/**************************************************************************************************************/ -/* - Land Line Buffer - Land Generator - 0xf,0x7,0xe,0x6,0xd,0x5,0xc,0x4, - 0xb,0x3,0xa,0x2,0x9,0x1,0x8,0x0 - -*/ - -/* Preliminary! The road circuitry is identical for all the driving games. - * - * There are several chunks of RAM - * - * Road Tilemap: - * 0x00000..0x0ffff 64x512 tilemap - * - * Road Tiles: - * 0x10000..0x1f9ff 16x16x2bpp tiles - * - * - * Line Attributes: - * - * 0x1fa00..0x1fbdf xxx- ---- ---- ---- priority - * ---- xxxx xxxx xxxx xscroll - * - * 0x1fbfe horizontal adjust? - * 0x0017 - * 0x0018 (Final Lap3) - * - * 0x1fc00..0x1fddf selects line in source bitmap - * 0x1fdfe yscroll - * - * 0x1fe00..0x1ffdf ---- --xx xxxx xxxx zoomx - * 0x1fffd always 0xffff 0xffff? - */ - -#include "emu.h" -#include "video/c45.h" - - -//**************************************************************************** -// CONSTANTS -//**************************************************************************** - -// device type definition -DEFINE_DEVICE_TYPE(NAMCO_C45_ROAD, namco_c45_road_device, "namco_c45_road", "Namco C45 Road") - - -const gfx_layout namco_c45_road_device::tilelayout = -{ - ROAD_TILE_SIZE, ROAD_TILE_SIZE, - RGN_FRAC(1,1), - 2, - { 0, 8 }, - { STEP8(0, 1), STEP8(16, 1) }, - { STEP16(0, 32) }, - 0x200 // offset to next tile -}; - - -GFXDECODE_MEMBER( namco_c45_road_device::gfxinfo ) - GFXDECODE_DEVICE_RAM( "tileram", 0, tilelayout, 0xf00, 64 ) -GFXDECODE_END - - -void namco_c45_road_device::map(address_map &map) -{ - map(0x00000, 0x0ffff).ram().w(FUNC(namco_c45_road_device::tilemap_w)).share("tmapram"); - map(0x10000, 0x1f9ff).ram().w(FUNC(namco_c45_road_device::tileram_w)).share("tileram"); - map(0x1fa00, 0x1ffff).ram().share("lineram"); -} - - -//------------------------------------------------- -// namco_c45_road_device -- constructor -//------------------------------------------------- - -namco_c45_road_device::namco_c45_road_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - device_t(mconfig, NAMCO_C45_ROAD, tag, owner, clock), - device_gfx_interface(mconfig, *this, gfxinfo), - device_memory_interface(mconfig, *this), - m_space_config("c45", ENDIANNESS_BIG, 16, 17, 0, address_map_constructor(FUNC(namco_c45_road_device::map), this)), - m_tmapram(*this, "tmapram"), - m_tileram(*this, "tileram"), - m_lineram(*this, "lineram"), - m_clut(*this, "clut"), - m_transparent_color(~0) -{ -} - - - -// We need these trampolines for now because uplift_submaps() -// can't deal with address maps that contain RAM. -// We need to explicitly use device_memory_interface::space() -// because read/write handlers have a parameter called 'space' - -//------------------------------------------------- -// read -- CPU read from our address space -//------------------------------------------------- - -uint16_t namco_c45_road_device::read(offs_t offset) -{ - return device_memory_interface::space().read_word(offset*2); -} - - -//------------------------------------------------- -// write -- CPU write to our address space -//------------------------------------------------- - -void namco_c45_road_device::write(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - device_memory_interface::space().write_word(offset*2, data, mem_mask); -} - - -//------------------------------------------------- -// tilemap_w -- write to tilemap RAM -//------------------------------------------------- - -void namco_c45_road_device::tilemap_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_tmapram[offset]); - m_tilemap->mark_tile_dirty(offset); -} - - -//------------------------------------------------- -// tileram_w -- write to tile RAM -//------------------------------------------------- - -void namco_c45_road_device::tileram_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_tileram[offset]); - gfx(0)->mark_dirty(offset / WORDS_PER_ROAD_TILE); -} - - -//------------------------------------------------- -// draw -- render to the target bitmap -//------------------------------------------------- - -void namco_c45_road_device::draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri) -{ - bitmap_ind16 &source_bitmap = m_tilemap->pixmap(); - unsigned yscroll = m_lineram[0x3fe/2]; - - // loop over scanlines - for (int y = cliprect.min_y; y <= cliprect.max_y; y++) - { - // skip if we are not the right priority - int screenx = m_lineram[y + 15]; - if (pri != ((screenx & 0xf000) >> 12)) - continue; - - // skip if we don't have a valid zoom factor - unsigned zoomx = m_lineram[0x400/2 + y + 15] & 0x3ff; - if (zoomx == 0) - continue; - - // skip if we don't have a valid source increment - unsigned sourcey = m_lineram[0x200/2 + y + 15] + yscroll; - const uint16_t *source_gfx = &source_bitmap.pix(sourcey & (ROAD_TILEMAP_HEIGHT - 1)); - unsigned dsourcex = (ROAD_TILEMAP_WIDTH << 16) / zoomx; - if (dsourcex == 0) - continue; - - // mask off priority bits and sign-extend - screenx &= 0x0fff; - if (screenx & 0x0800) - screenx |= ~0x7ff; - - // adjust the horizontal placement - screenx -= 64; // needs adjustment to left - - int numpixels = (44 * ROAD_TILE_SIZE << 16) / dsourcex; - unsigned sourcex = 0; - - // crop left - int clip_pixels = cliprect.min_x - screenx; - if (clip_pixels > 0) - { - numpixels -= clip_pixels; - sourcex += dsourcex*clip_pixels; - screenx = cliprect.min_x; - } - - // crop right - clip_pixels = (screenx + numpixels) - (cliprect.max_x + 1); - if (clip_pixels > 0) - numpixels -= clip_pixels; - - // TBA: work out palette mapping for Final Lap, Suzuka - - // BUT: support transparent color for Thunder Ceptor - uint16_t *dest = &bitmap.pix(y); - if (m_transparent_color != ~0) - { - while (numpixels-- > 0) - { - int pen = source_gfx[sourcex >> 16]; - if (palette().pen_indirect(pen) != m_transparent_color) - { - if (m_clut != nullptr) - pen = (pen & ~0xff) | m_clut[pen & 0xff]; - dest[screenx] = pen; - } - screenx++; - sourcex += dsourcex; - } - } - else - { - while (numpixels-- > 0) - { - int pen = source_gfx[sourcex >> 16]; - if (m_clut != nullptr) - pen = (pen & ~0xff) | m_clut[pen & 0xff]; - dest[screenx++] = pen; - sourcex += dsourcex; - } - } - } -} - - -//------------------------------------------------- -// device_start -- device startup -//------------------------------------------------- - -void namco_c45_road_device::device_start() -{ - // create a tilemap for the road - m_tilemap = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(namco_c45_road_device::get_road_info)), - TILEMAP_SCAN_ROWS, ROAD_TILE_SIZE, ROAD_TILE_SIZE, ROAD_COLS, ROAD_ROWS); -} - - -//------------------------------------------------- -// memory_space_config - return a description of -// any address spaces owned by this device -//------------------------------------------------- - -device_memory_interface::space_config_vector namco_c45_road_device::memory_space_config() const -{ - return space_config_vector { - std::make_pair(0, &m_space_config) - }; -} - - -//------------------------------------------------- -// get_road_info -- tilemap callback -//------------------------------------------------- - -TILE_GET_INFO_MEMBER( namco_c45_road_device::get_road_info ) -{ - // ------xx xxxxxxxx tile number - // xxxxxx-- -------- palette select - uint16_t data = m_tmapram[tile_index]; - int tile = data & 0x3ff; - int color = data >> 10; - tileinfo.set(0, tile, color, 0); -} diff --git a/src/mame/video/c45.h b/src/mame/video/c45.h deleted file mode 100644 index 68efbfe22c7..00000000000 --- a/src/mame/video/c45.h +++ /dev/null @@ -1,69 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Phil Stroffolino, Aaron Giles, Alex W. Jackson -#ifndef MAME_VIDEO_C45_H -#define MAME_VIDEO_C45_H - -#pragma once - -#include "tilemap.h" - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - - -// ======================> namco_c45_road_device - -class namco_c45_road_device : public device_t, public device_gfx_interface, public device_memory_interface -{ -public: - // construction/destruction - namco_c45_road_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - - void map(address_map &map); - - // read/write handlers - uint16_t read(offs_t offset); - void write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - - // C45 Land (Road) Emulation - void set_transparent_color(pen_t pen) { m_transparent_color = pen; } - void draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri); - -protected: - // device-level overrides - virtual void device_start() override; - virtual space_config_vector memory_space_config() const override; - -private: - // constants - static constexpr int ROAD_COLS = 64; - static constexpr int ROAD_ROWS = 512; - static constexpr int ROAD_TILE_SIZE = 16; - static constexpr int ROAD_TILEMAP_WIDTH = ROAD_TILE_SIZE * ROAD_COLS; - static constexpr int ROAD_TILEMAP_HEIGHT = ROAD_TILE_SIZE * ROAD_ROWS; - static constexpr int WORDS_PER_ROAD_TILE = 0x40/2; - static const gfx_layout tilelayout; - - // internal helpers - DECLARE_GFXDECODE_MEMBER(gfxinfo); - void tilemap_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void tileram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - TILE_GET_INFO_MEMBER( get_road_info ); - - // internal state - address_space_config m_space_config; - required_shared_ptr m_tmapram; - required_shared_ptr m_tileram; - required_shared_ptr m_lineram; - optional_region_ptr m_clut; - tilemap_t * m_tilemap; - pen_t m_transparent_color; -}; - - -// device type definition -DECLARE_DEVICE_TYPE(NAMCO_C45_ROAD, namco_c45_road_device) - -#endif // MAME_VIDEO_C45_H diff --git a/src/mame/video/namco_c116.h b/src/mame/video/namco_c116.h index 96a0b774697..c9688479d2f 100644 --- a/src/mame/video/namco_c116.h +++ b/src/mame/video/namco_c116.h @@ -6,7 +6,6 @@ #pragma once - //*************************************************************************** // TYPE DEFINITIONS //*************************************************************************** @@ -18,7 +17,7 @@ class namco_c116_device : { public: //construction/destruction - namco_c116_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + namco_c116_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); // configuration void enable_shadows() { m_enable_shadows = true; } @@ -44,7 +43,7 @@ private: std::vector m_ram_g; std::vector m_ram_b; uint16_t m_regs[8]; - bool m_enable_shadows; // are shadows enabled? + bool m_enable_shadows; // are shadows enabled? }; DECLARE_DEVICE_TYPE(NAMCO_C116, namco_c116_device) diff --git a/src/mame/video/namco_c123tmap.h b/src/mame/video/namco_c123tmap.h index d02296cfcc8..3ae46b869b0 100644 --- a/src/mame/video/namco_c123tmap.h +++ b/src/mame/video/namco_c123tmap.h @@ -13,7 +13,7 @@ class namco_c123tmap_device : public device_t, public device_gfx_interface { public: // construction/destruction - namco_c123tmap_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + namco_c123tmap_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); void set_color_base(int color) { m_color_base = color; } void set_offset(int xoffs, int yoffs) diff --git a/src/mame/video/namco_c169roz.h b/src/mame/video/namco_c169roz.h index d6329a6a8d0..626dba73d79 100644 --- a/src/mame/video/namco_c169roz.h +++ b/src/mame/video/namco_c169roz.h @@ -13,7 +13,7 @@ class namco_c169roz_device : public device_t, public device_gfx_interface { public: // construction/destruction - namco_c169roz_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + namco_c169roz_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); void set_is_namcofl(bool state) { m_is_namcofl = state; } void set_ram_words(uint32_t size) { m_ramsize = size; } diff --git a/src/mame/video/namco_c355spr.cpp b/src/mame/video/namco_c355spr.cpp index 570c6a92e7d..8ea17dc18d1 100644 --- a/src/mame/video/namco_c355spr.cpp +++ b/src/mame/video/namco_c355spr.cpp @@ -133,9 +133,6 @@ void namco_c355spr_device::zdrawgfxzoom( void namco_c355spr_device::copybitmap(bitmap_ind16 &dest_bmp, const rectangle &clip, u8 pri) { - device_palette_interface &palette = gfx(0)->palette(); - const int shadow_offset = (palette.shadows_enabled()) ? palette.entries() : 0; - const pen_t black = palette.black_pen(); if (m_palxor) { for (int y = clip.min_y; y <= clip.max_y; y++) @@ -186,10 +183,9 @@ void namco_c355spr_device::copybitmap(bitmap_ind16 &dest_bmp, const rectangle &c { if ((c & 0xff) != 0xff) { - if (c == 0xffe && shadow_offset) + if (c == 0xffe) { - if (dest[x] != black) - dest[x] |= shadow_offset; + dest[x] |= 0x800; } else { @@ -206,8 +202,6 @@ void namco_c355spr_device::copybitmap(bitmap_ind16 &dest_bmp, const rectangle &c void namco_c355spr_device::copybitmap(bitmap_rgb32 &dest_bmp, const rectangle &clip, u8 pri) { device_palette_interface &palette = gfx(0)->palette(); - const int shadow_offset = (palette.shadows_enabled()) ? palette.entries() : 0; - const pen_t black = palette.black_pen(); const pen_t *pal = &palette.pen(gfx(0)->colorbase()); if (m_palxor) { @@ -264,10 +258,9 @@ void namco_c355spr_device::copybitmap(bitmap_rgb32 &dest_bmp, const rectangle &c { if ((c & 0xff) != 0xff) { - if (c == 0xffe && shadow_offset) + if (c == 0xffe) { - if (srcrender[x] != black) - srcrender[x] |= shadow_offset; + srcrender[x] |= 0x800; } else { diff --git a/src/mame/video/namco_c355spr.h b/src/mame/video/namco_c355spr.h index 70d53ec0fc5..3e55eacd3b7 100644 --- a/src/mame/video/namco_c355spr.h +++ b/src/mame/video/namco_c355spr.h @@ -12,7 +12,7 @@ class namco_c355spr_device : public device_t, public device_gfx_interface, publi { public: // construction/destruction - namco_c355spr_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + namco_c355spr_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); void set_color_base(u16 base) { m_colbase = base; } void set_scroll_offsets(int x, int y) { m_scrolloffs[0] = x; m_scrolloffs[1] = y; } diff --git a/src/mame/video/namco_c45road.cpp b/src/mame/video/namco_c45road.cpp new file mode 100644 index 00000000000..403ad010276 --- /dev/null +++ b/src/mame/video/namco_c45road.cpp @@ -0,0 +1,267 @@ +// license:BSD-3-Clause +// copyright-holders:Phil Stroffolino, Aaron Giles, Alex W. Jackson +/**************************************************************************************************************/ +/* + Land Line Buffer + Land Generator + 0xf,0x7,0xe,0x6,0xd,0x5,0xc,0x4, + 0xb,0x3,0xa,0x2,0x9,0x1,0x8,0x0 + +*/ + +/* Preliminary! The road circuitry is identical for all the driving games. + * + * There are several chunks of RAM + * + * Road Tilemap: + * 0x00000..0x0ffff 64x512 tilemap + * + * Road Tiles: + * 0x10000..0x1f9ff 16x16x2bpp tiles + * + * + * Line Attributes: + * + * 0x1fa00..0x1fbdf xxx- ---- ---- ---- priority + * ---- xxxx xxxx xxxx xscroll + * + * 0x1fbfe horizontal adjust? + * 0x0017 + * 0x0018 (Final Lap3) + * + * 0x1fc00..0x1fddf selects line in source bitmap + * 0x1fdfe yscroll + * + * 0x1fe00..0x1ffdf ---- --xx xxxx xxxx zoomx + * 0x1fffd always 0xffff 0xffff? + */ + +#include "emu.h" +#include "video/namco_c45road.h" + + +//**************************************************************************** +// CONSTANTS +//**************************************************************************** + +// device type definition +DEFINE_DEVICE_TYPE(NAMCO_C45_ROAD, namco_c45_road_device, "namco_c45_road", "Namco C45 Road") + + +const gfx_layout namco_c45_road_device::tilelayout = +{ + ROAD_TILE_SIZE, ROAD_TILE_SIZE, + RGN_FRAC(1,1), + 2, + { 0, 8 }, + { STEP8(0, 1), STEP8(16, 1) }, + { STEP16(0, 32) }, + 0x200 // offset to next tile +}; + + +GFXDECODE_MEMBER( namco_c45_road_device::gfxinfo ) + GFXDECODE_DEVICE_RAM( "tileram", 0, tilelayout, 0xf00, 64 ) +GFXDECODE_END + + +void namco_c45_road_device::map(address_map &map) +{ + map(0x00000, 0x0ffff).ram().w(FUNC(namco_c45_road_device::tilemap_w)).share("tmapram"); + map(0x10000, 0x1f9ff).ram().w(FUNC(namco_c45_road_device::tileram_w)).share("tileram"); + map(0x1fa00, 0x1ffff).ram().share("lineram"); +} + + +//------------------------------------------------- +// namco_c45_road_device -- constructor +//------------------------------------------------- + +namco_c45_road_device::namco_c45_road_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, NAMCO_C45_ROAD, tag, owner, clock), + device_gfx_interface(mconfig, *this, gfxinfo), + device_memory_interface(mconfig, *this), + m_space_config("c45", ENDIANNESS_BIG, 16, 17, 0, address_map_constructor(FUNC(namco_c45_road_device::map), this)), + m_tmapram(*this, "tmapram"), + m_tileram(*this, "tileram"), + m_lineram(*this, "lineram"), + m_clut(*this, "clut"), + m_transparent_color(~0) +{ +} + + + +// We need these trampolines for now because uplift_submaps() +// can't deal with address maps that contain RAM. +// We need to explicitly use device_memory_interface::space() +// because read/write handlers have a parameter called 'space' + +//------------------------------------------------- +// read -- CPU read from our address space +//------------------------------------------------- + +uint16_t namco_c45_road_device::read(offs_t offset) +{ + return device_memory_interface::space().read_word(offset*2); +} + + +//------------------------------------------------- +// write -- CPU write to our address space +//------------------------------------------------- + +void namco_c45_road_device::write(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + device_memory_interface::space().write_word(offset*2, data, mem_mask); +} + + +//------------------------------------------------- +// tilemap_w -- write to tilemap RAM +//------------------------------------------------- + +void namco_c45_road_device::tilemap_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_tmapram[offset]); + m_tilemap->mark_tile_dirty(offset); +} + + +//------------------------------------------------- +// tileram_w -- write to tile RAM +//------------------------------------------------- + +void namco_c45_road_device::tileram_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_tileram[offset]); + gfx(0)->mark_dirty(offset / WORDS_PER_ROAD_TILE); +} + + +//------------------------------------------------- +// draw -- render to the target bitmap +//------------------------------------------------- + +void namco_c45_road_device::draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri) +{ + bitmap_ind16 &source_bitmap = m_tilemap->pixmap(); + unsigned yscroll = m_lineram[0x3fe/2]; + + // loop over scanlines + for (int y = cliprect.min_y; y <= cliprect.max_y; y++) + { + // skip if we are not the right priority + int screenx = m_lineram[y + 15]; + if (pri != ((screenx & 0xf000) >> 12)) + continue; + + // skip if we don't have a valid zoom factor + unsigned zoomx = m_lineram[0x400/2 + y + 15] & 0x3ff; + if (zoomx == 0) + continue; + + // skip if we don't have a valid source increment + unsigned sourcey = m_lineram[0x200/2 + y + 15] + yscroll; + const uint16_t *source_gfx = &source_bitmap.pix(sourcey & (ROAD_TILEMAP_HEIGHT - 1)); + unsigned dsourcex = (ROAD_TILEMAP_WIDTH << 16) / zoomx; + if (dsourcex == 0) + continue; + + // mask off priority bits and sign-extend + screenx &= 0x0fff; + if (screenx & 0x0800) + screenx |= ~0x7ff; + + // adjust the horizontal placement + screenx -= 64; // needs adjustment to left + + int numpixels = (44 * ROAD_TILE_SIZE << 16) / dsourcex; + unsigned sourcex = 0; + + // crop left + int clip_pixels = cliprect.min_x - screenx; + if (clip_pixels > 0) + { + numpixels -= clip_pixels; + sourcex += dsourcex*clip_pixels; + screenx = cliprect.min_x; + } + + // crop right + clip_pixels = (screenx + numpixels) - (cliprect.max_x + 1); + if (clip_pixels > 0) + numpixels -= clip_pixels; + + // TBA: work out palette mapping for Final Lap, Suzuka + + // BUT: support transparent color for Thunder Ceptor + uint16_t *dest = &bitmap.pix(y); + if (m_transparent_color != ~0) + { + while (numpixels-- > 0) + { + int pen = source_gfx[sourcex >> 16]; + if (palette().pen_indirect(pen) != m_transparent_color) + { + if (m_clut != nullptr) + pen = (pen & ~0xff) | m_clut[pen & 0xff]; + dest[screenx] = pen; + } + screenx++; + sourcex += dsourcex; + } + } + else + { + while (numpixels-- > 0) + { + int pen = source_gfx[sourcex >> 16]; + if (m_clut != nullptr) + pen = (pen & ~0xff) | m_clut[pen & 0xff]; + dest[screenx++] = pen; + sourcex += dsourcex; + } + } + } +} + + +//------------------------------------------------- +// device_start -- device startup +//------------------------------------------------- + +void namco_c45_road_device::device_start() +{ + // create a tilemap for the road + m_tilemap = &machine().tilemap().create(*this, tilemap_get_info_delegate(*this, FUNC(namco_c45_road_device::get_road_info)), + TILEMAP_SCAN_ROWS, ROAD_TILE_SIZE, ROAD_TILE_SIZE, ROAD_COLS, ROAD_ROWS); +} + + +//------------------------------------------------- +// memory_space_config - return a description of +// any address spaces owned by this device +//------------------------------------------------- + +device_memory_interface::space_config_vector namco_c45_road_device::memory_space_config() const +{ + return space_config_vector { + std::make_pair(0, &m_space_config) + }; +} + + +//------------------------------------------------- +// get_road_info -- tilemap callback +//------------------------------------------------- + +TILE_GET_INFO_MEMBER( namco_c45_road_device::get_road_info ) +{ + // ------xx xxxxxxxx tile number + // xxxxxx-- -------- palette select + uint16_t data = m_tmapram[tile_index]; + int tile = data & 0x3ff; + int color = data >> 10; + tileinfo.set(0, tile, color, 0); +} diff --git a/src/mame/video/namco_c45road.h b/src/mame/video/namco_c45road.h new file mode 100644 index 00000000000..ba0814ccb51 --- /dev/null +++ b/src/mame/video/namco_c45road.h @@ -0,0 +1,69 @@ +// license:BSD-3-Clause +// copyright-holders:Phil Stroffolino, Aaron Giles, Alex W. Jackson +#ifndef MAME_VIDEO_C45_H +#define MAME_VIDEO_C45_H + +#pragma once + +#include "tilemap.h" + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + + +// ======================> namco_c45_road_device + +class namco_c45_road_device : public device_t, public device_gfx_interface, public device_memory_interface +{ +public: + // construction/destruction + namco_c45_road_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + + void map(address_map &map); + + // read/write handlers + uint16_t read(offs_t offset); + void write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + + // C45 Land (Road) Emulation + void set_transparent_color(pen_t pen) { m_transparent_color = pen; } + void draw(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri); + +protected: + // device-level overrides + virtual void device_start() override; + virtual space_config_vector memory_space_config() const override; + +private: + // constants + static constexpr int ROAD_COLS = 64; + static constexpr int ROAD_ROWS = 512; + static constexpr int ROAD_TILE_SIZE = 16; + static constexpr int ROAD_TILEMAP_WIDTH = ROAD_TILE_SIZE * ROAD_COLS; + static constexpr int ROAD_TILEMAP_HEIGHT = ROAD_TILE_SIZE * ROAD_ROWS; + static constexpr int WORDS_PER_ROAD_TILE = 0x40/2; + static const gfx_layout tilelayout; + + // internal helpers + DECLARE_GFXDECODE_MEMBER(gfxinfo); + void tilemap_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void tileram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + TILE_GET_INFO_MEMBER( get_road_info ); + + // internal state + address_space_config m_space_config; + required_shared_ptr m_tmapram; + required_shared_ptr m_tileram; + required_shared_ptr m_lineram; + optional_region_ptr m_clut; + tilemap_t * m_tilemap; + pen_t m_transparent_color; +}; + + +// device type definition +DECLARE_DEVICE_TYPE(NAMCO_C45_ROAD, namco_c45_road_device) + +#endif // MAME_VIDEO_C45_H diff --git a/src/mame/video/namcos2_sprite.cpp b/src/mame/video/namcos2_sprite.cpp index 2e6f48abf91..a6047f05add 100644 --- a/src/mame/video/namcos2_sprite.cpp +++ b/src/mame/video/namcos2_sprite.cpp @@ -50,7 +50,6 @@ void namcos2_sprite_device::zdrawgfxzoom( if (gfx) { device_palette_interface &palette = gfx->palette(); - const int shadow_offset = (palette.shadows_enabled()) ? palette.entries() : 0; const pen_t *pal = &palette.pen(gfx->colorbase() + gfx->granularity() * (color % gfx->colors())); const u8 *source_base = gfx->get_data(code % gfx->elements()); const int sprite_screen_height = (scaley * gfx->height() + 0x8000) >> 16; @@ -160,9 +159,9 @@ void namcos2_sprite_device::zdrawgfxzoom( { if (pri[x] <= zpos) { - if (color == 0xf && c==0xfe && shadow_offset) + if (color == 0xf && c == 0xfe) { - dest[x] |= shadow_offset; + dest[x] |= 0x800; } else { -- cgit v1.2.3