From c870159b5581ba54b03bb5db6e72efb702a61149 Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 22 Dec 2022 15:44:29 +0100 Subject: equites: merge driver files --- src/mame/alpha/equites.cpp | 566 ++++++++++++++++++++++++++++++++++++++++++- src/mame/alpha/equites.h | 142 ----------- src/mame/alpha/equites_v.cpp | 445 ---------------------------------- src/mame/alpha/shougi.cpp | 8 +- 4 files changed, 572 insertions(+), 589 deletions(-) delete mode 100644 src/mame/alpha/equites.h delete mode 100644 src/mame/alpha/equites_v.cpp diff --git a/src/mame/alpha/equites.cpp b/src/mame/alpha/equites.cpp index ca9691ec76a..1e14a5d9f3e 100644 --- a/src/mame/alpha/equites.cpp +++ b/src/mame/alpha/equites.cpp @@ -369,12 +369,574 @@ D *******************************************************************************/ #include "emu.h" -#include "equites.h" #include "ad_sound.h" +#include "alpha8201.h" + #include "cpu/m68000/m68000.h" +#include "machine/74259.h" #include "machine/nvram.h" #include "machine/watchdog.h" +#include "machine/timer.h" + +#include "emupal.h" +#include "screen.h" +#include "tilemap.h" + +namespace { + +class equites_state : public driver_device +{ +public: + equites_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_bg_videoram(*this, "bg_videoram"), + m_spriteram(*this, "spriteram"), + m_spriteram_2(*this, "spriteram_2"), + m_maincpu(*this, "maincpu"), + m_gfxdecode(*this, "gfxdecode"), + m_palette(*this, "palette"), + m_screen(*this, "screen"), + m_alpha_8201(*this, "alpha_8201"), + m_mainlatch(*this, "mainlatch") + { } + + void equites(machine_config &config); + void bngotime(machine_config &config); + void init_equites(); + +protected: + // memory pointers + required_shared_ptr m_bg_videoram; + std::unique_ptr m_fg_videoram; // 8bits + required_shared_ptr m_spriteram; + optional_shared_ptr m_spriteram_2; + + // devices + required_device m_maincpu; + required_device m_gfxdecode; + required_device m_palette; + required_device m_screen; + required_device m_alpha_8201; + required_device m_mainlatch; + + // video-related + tilemap_t *m_fg_tilemap = nullptr; + tilemap_t *m_bg_tilemap = nullptr; + uint8_t m_bgcolor = 0U; + + uint16_t equites_spriteram_kludge_r(); + uint8_t equites_fg_videoram_r(offs_t offset); + void equites_fg_videoram_w(offs_t offset, uint8_t data); + void equites_bg_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void equites_bgcolor_w(offs_t offset, uint8_t data); + void equites_scrollreg_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + DECLARE_WRITE_LINE_MEMBER(flip_screen_w); + TILE_GET_INFO_MEMBER(equites_fg_info); + TILE_GET_INFO_MEMBER(equites_bg_info); + DECLARE_VIDEO_START(equites); + void equites_palette(palette_device &palette) const; + uint32_t screen_update_equites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + TIMER_DEVICE_CALLBACK_MEMBER(equites_scanline); + void equites_draw_sprites_block(bitmap_ind16 &bitmap, const rectangle &cliprect, int start, int end); + void equites_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); + void unpack_block(const char *region, int offset, int size); + void unpack_region(const char *region); + + virtual void machine_start() override; + void bngotime_map(address_map &map); + void equites_map(address_map &map); + void equites_common_map(address_map &map); +}; + + +class gekisou_state : public equites_state +{ +public: + gekisou_state(const machine_config &mconfig, device_type type, const char *tag) : + equites_state(mconfig, type, tag) + { } + + DECLARE_READ_LINE_MEMBER(gekisou_unknown_bit_r); + void gekisou(machine_config &config); + +protected: + virtual void machine_start() override; + +private: + void gekisou_map(address_map &map); + void gekisou_unknown_bit_w(offs_t offset, uint16_t data); + + int m_gekisou_unknown_bit = 0; +}; + + +class splndrbt_state : public equites_state +{ +public: + splndrbt_state(const machine_config &mconfig, device_type type, const char *tag) : + equites_state(mconfig, type, tag), + m_scale_rom(*this, "scale%u", 1U) + { } + + void init_splndrbt(); + void splndrbt(machine_config &config); + +protected: + virtual void machine_start() override; + +private: + required_region_ptr_array m_scale_rom; + + void splndrbt_map(address_map &map); + DECLARE_WRITE_LINE_MEMBER(splndrbt_selchar_w); + void splndrbt_bg_scrollx_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + void splndrbt_bg_scrolly_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); + TILE_GET_INFO_MEMBER(splndrbt_fg_info); + TILE_GET_INFO_MEMBER(splndrbt_bg_info); + DECLARE_VIDEO_START(splndrbt); + void splndrbt_palette(palette_device &palette) const; + uint32_t screen_update_splndrbt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + TIMER_DEVICE_CALLBACK_MEMBER(splndrbt_scanline); + void splndrbt_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); + void splndrbt_copy_bg(bitmap_ind16 &dst_bitmap, const rectangle &cliprect); + + int m_fg_char_bank = 0; + uint16_t m_splndrbt_bg_scrollx = 0U; + uint16_t m_splndrbt_bg_scrolly = 0U; +}; + + +/************************************* + * + * Palette handling + * + *************************************/ + +void equites_state::equites_palette(palette_device &palette) const +{ + const uint8_t *color_prom = memregion("proms")->base(); + + for (int i = 0; i < 256; i++) + palette.set_indirect_color(i, rgb_t(pal4bit(color_prom[i]), pal4bit(color_prom[i + 0x100]), pal4bit(color_prom[i + 0x200]))); + + // point to the CLUT + color_prom += 0x380; + + for (int i = 0; i < 256; i++) + palette.set_pen_indirect(i, i); + + for (int i = 0; i < 0x80; i++) + palette.set_pen_indirect(i + 0x100, color_prom[i]); +} + +void splndrbt_state::splndrbt_palette(palette_device &palette) const +{ + const uint8_t *color_prom = memregion("proms")->base(); + + for (int i = 0; i < 0x100; i++) + palette.set_indirect_color(i, rgb_t(pal4bit(color_prom[i]), pal4bit(color_prom[i + 0x100]), pal4bit(color_prom[i + 0x200]))); + + for (int i = 0; i < 0x100; i++) + palette.set_pen_indirect(i, i); + + // point to the bg CLUT + color_prom += 0x300; + + for (int i = 0; i < 0x80; i++) + palette.set_pen_indirect(i + 0x100, color_prom[i] + 0x10); + + // point to the sprite CLUT + color_prom += 0x100; + + for (int i = 0; i < 0x100; i++) + palette.set_pen_indirect(i + 0x180, color_prom[i]); +} + + + +/************************************* + * + * Callbacks for the TileMap code + * + *************************************/ + +TILE_GET_INFO_MEMBER(equites_state::equites_fg_info) +{ + int tile = m_fg_videoram[2 * tile_index]; + int color = m_fg_videoram[2 * tile_index + 1] & 0x1f; + + tileinfo.set(0, tile, color, 0); + if (color & 0x10) + tileinfo.flags |= TILE_FORCE_LAYER0; +} + +TILE_GET_INFO_MEMBER(splndrbt_state::splndrbt_fg_info) +{ + int tile = m_fg_videoram[2 * tile_index] + (m_fg_char_bank << 8); + int color = m_fg_videoram[2 * tile_index + 1] & 0x3f; + + tileinfo.set(0, tile, color, 0); + if (color & 0x10) + tileinfo.flags |= TILE_FORCE_LAYER0; +} + +TILE_GET_INFO_MEMBER(equites_state::equites_bg_info) +{ + int data = m_bg_videoram[tile_index]; + int tile = data & 0x1ff; + int color = (data & 0xf000) >> 12; + int fxy = (data & 0x0600) >> 9; + + tileinfo.set(1, tile, color, TILE_FLIPXY(fxy)); +} + +TILE_GET_INFO_MEMBER(splndrbt_state::splndrbt_bg_info) +{ + int data = m_bg_videoram[tile_index]; + int tile = data & 0x1ff; + int color = (data & 0xf800) >> 11; + int fxy = (data & 0x0600) >> 9; + + tileinfo.set(1, tile, color, TILE_FLIPXY(fxy)); + tileinfo.group = color; +} + + + +/************************************* + * + * Video system start + * + *************************************/ + +VIDEO_START_MEMBER(equites_state,equites) +{ + m_fg_videoram = std::make_unique(0x800); + save_pointer(NAME(m_fg_videoram), 0x800); + + m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(equites_state::equites_fg_info)), TILEMAP_SCAN_COLS, 8, 8, 32, 32); + m_fg_tilemap->set_transparent_pen(0); + + m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(equites_state::equites_bg_info)), TILEMAP_SCAN_ROWS, 16, 16, 16, 16); + m_bg_tilemap->set_transparent_pen(0); + m_bg_tilemap->set_scrolldx(0, -10); +} + +VIDEO_START_MEMBER(splndrbt_state,splndrbt) +{ + assert(m_screen->format() == BITMAP_FORMAT_IND16); + + m_fg_videoram = std::make_unique(0x800); + save_pointer(NAME(m_fg_videoram), 0x800); + + m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(splndrbt_state::splndrbt_fg_info)), TILEMAP_SCAN_COLS, 8, 8, 32, 32); + m_fg_tilemap->set_transparent_pen(0); + m_fg_tilemap->set_scrolldx(8, -8); + + m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(splndrbt_state::splndrbt_bg_info)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); + m_bg_tilemap->configure_groups(*m_gfxdecode->gfx(1), 0x10); +} + + + +/************************************* + * + * Memory handlers + * + *************************************/ + +uint8_t equites_state::equites_fg_videoram_r(offs_t offset) +{ + // 8-bit + return m_fg_videoram[offset]; +} + +void equites_state::equites_fg_videoram_w(offs_t offset, uint8_t data) +{ + m_fg_videoram[offset] = data; + m_fg_tilemap->mark_tile_dirty(offset >> 1); +} + +void equites_state::equites_bg_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(m_bg_videoram + offset); + m_bg_tilemap->mark_tile_dirty(offset); +} + +void equites_state::equites_bgcolor_w(offs_t offset, uint8_t data) +{ + m_bgcolor = data; +} + +void equites_state::equites_scrollreg_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + if (ACCESSING_BITS_0_7) + m_bg_tilemap->set_scrolly(0, data & 0xff); + + if (ACCESSING_BITS_8_15) + m_bg_tilemap->set_scrollx(0, data >> 8); +} + +WRITE_LINE_MEMBER(splndrbt_state::splndrbt_selchar_w) +{ + // select active char map + m_fg_char_bank = (state == 0) ? 0 : 1; + m_fg_tilemap->mark_all_dirty(); +} + +WRITE_LINE_MEMBER(equites_state::flip_screen_w) +{ + flip_screen_set(state); +} + +void splndrbt_state::splndrbt_bg_scrollx_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_splndrbt_bg_scrollx); +} + +void splndrbt_state::splndrbt_bg_scrolly_w(offs_t offset, uint16_t data, uint16_t mem_mask) +{ + COMBINE_DATA(&m_splndrbt_bg_scrolly); +} + + + +/************************************* + * + * Video update + * + *************************************/ + +void equites_state::equites_draw_sprites_block(bitmap_ind16 &bitmap, const rectangle &cliprect, int start, int end) +{ + for (int offs = end - 2; offs >= start; offs -= 2) + { + int attr = m_spriteram[offs + 1]; + if (!(attr & 0x800)) // disable or x MSB? + { + int tile = attr & 0x1ff; + int fx = ~attr & 0x400; + int fy = ~attr & 0x200; + int color = (~attr & 0xf000) >> 12; + int sx = (m_spriteram[offs] & 0xff00) >> 8; + int sy = (m_spriteram[offs] & 0x00ff); + int transmask = m_palette->transpen_mask(*m_gfxdecode->gfx(2), color, 0); + + if (flip_screen()) + { + sx = 240 - sx; + sy = 240 - sy; + fx = !fx; + fy = !fy; + } + + // align + sx -= 4; + + // sprites are 16x14 centered in a 16x16 square, so skip the first line + sy += 1; + + m_gfxdecode->gfx(2)->transmask(bitmap,cliprect, + tile, + color, + fx, fy, + sx, sy, transmask); + } + } +} + +void equites_state::equites_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + // note that we draw the sprites in three blocks; in each blocks, sprites at + // a lower address have priority. This gives good priorities in gekisou. + equites_draw_sprites_block(bitmap, cliprect, 0x000/2, 0x060/2); + equites_draw_sprites_block(bitmap, cliprect, 0x0e0/2, 0x100/2); + equites_draw_sprites_block(bitmap, cliprect, 0x1a4/2, 0x200/2); +} + + +/* +This is (probably) the sprite x scaling PROM. +The layout is strange. Clearly every line is for one xscale setting. However, +it seems that bytes 0-3 are handled separately from bytes 4-F. +Also, note that sprites are 30x30, not 32x32. +00020200 00000000 00000000 00000000 +00020200 01000000 00000000 00000002 +00020200 01000000 01000002 00000002 +00020200 01000100 01000002 00020002 +00020200 01000100 01010202 00020002 +02020201 01000100 01010202 00020002 +02020201 01010100 01010202 00020202 +02020201 01010101 01010202 02020202 +02020201 03010101 01010202 02020203 +02020201 03010103 01010202 03020203 +02020201 03010103 01030302 03020203 +02020201 03010303 01030302 03030203 +03020203 03010303 01030302 03030203 +03020203 03030303 01030302 03030303 +03020203 03030303 03030303 03030303 +03020303 03030303 03030303 03030303 +*/ + +void splndrbt_state::splndrbt_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + const uint8_t * const xrom = m_scale_rom[1]; + const uint8_t * const yrom = xrom + 0x100; + gfx_element* gfx = m_gfxdecode->gfx(2); + + // note that sprites are actually 30x30, contained in 32x32 squares. The outer edge is not used. + + for (int offs = 0x3f; offs < 0x6f; offs += 2) // 24 sprites + { + int data = m_spriteram[offs]; + int fx = (data & 0x2000) >> 13; + int fy = (data & 0x1000) >> 12; + int tile = data & 0x007f; + int scaley = (data & 0x0f00) >> 8; + int data2 = m_spriteram[offs + 1]; + int color = (data2 & 0x1f00) >> 8; + int sx = data2 & 0x00ff; + int sy = m_spriteram_2[offs + 0] & 0x00ff; + int scalex = m_spriteram_2[offs + 1] & 0x000f; + int transmask = m_palette->transpen_mask(*gfx, color, 0); + +// const uint8_t * const xromline = xrom + (scalex << 4); + const uint8_t * const yromline = yrom + (scaley << 4) + (15 - scaley); + const uint8_t* const srcgfx = gfx->get_data(tile); + const pen_t *paldata = &m_palette->pen(gfx->colorbase() + gfx->granularity() * color); + int x,yy; + + sy += 16; + + if (flip_screen()) + { + // sx NOT inverted + fx = fx ^ 1; + fy = fy ^ 1; + } + else + { + sy = 256 - sy; + } + + for (yy = 0; yy <= scaley; ++yy) + { + int const line = yromline[yy]; + int yhalf; + + for (yhalf = 0; yhalf < 2; ++yhalf) // top or bottom half + { + int const y = yhalf ? sy + 1 + yy : sy - yy; + + if (y >= cliprect.top() && y <= cliprect.bottom()) + { + for (x = 0; x <= (scalex << 1); ++x) + { + int bx = (sx + x) & 0xff; + + if (bx >= cliprect.left() && bx <= cliprect.right()) + { + int xx = scalex ? (x * 29 + scalex) / (scalex << 1) + 1 : 16; // FIXME This is wrong. Should use the PROM. + int const offset = (fx ? (31 - xx) : xx) + ((fy ^ yhalf) ? (16 + line) : (15 - line)) * gfx->rowbytes(); + + int pen = srcgfx[offset]; + + if ((transmask & (1 << pen)) == 0) + bitmap.pix(y, bx) = paldata[pen]; + } + } + } + } + } + } +} + + +void splndrbt_state::splndrbt_copy_bg(bitmap_ind16 &dst_bitmap, const rectangle &cliprect) +{ + bitmap_ind16 &src_bitmap = m_bg_tilemap->pixmap(); + bitmap_ind8 &flags_bitmap = m_bg_tilemap->flagsmap(); + const uint8_t * const xrom = m_scale_rom[0]; + const uint8_t * const yrom = xrom + 0x2000; + int scroll_x = m_splndrbt_bg_scrollx; + int scroll_y = m_splndrbt_bg_scrolly; + int const dinvert = flip_screen() ? 0xff : 0x00; + int src_y = 0; + int dst_y; + + if (flip_screen()) + { + scroll_x = -scroll_x - 8; + scroll_y = -scroll_y; + } + + for (dst_y = 32; dst_y < 256-32; ++dst_y) + { + if (dst_y >= cliprect.top() && dst_y <= cliprect.bottom()) + { + const uint8_t * const romline = &xrom[(dst_y ^ dinvert) << 5]; + const uint16_t * const src_line = &src_bitmap.pix((src_y + scroll_y) & 0x1ff); + const uint8_t * const flags_line = &flags_bitmap.pix((src_y + scroll_y) & 0x1ff); + uint16_t * const dst_line = &dst_bitmap.pix(dst_y); + int dst_x = 0; + int src_x; + + for (src_x = 0; src_x < 256 && dst_x < 128; ++src_x) + { + if ((romline[31 - (src_x >> 3)] >> (src_x & 7)) & 1) + { + int sx; + + sx = (256+128 + scroll_x + src_x) & 0x1ff; + if (flags_line[sx] & TILEMAP_PIXEL_LAYER0) + dst_line[128 + dst_x] = src_line[sx]; + + sx = (255+128 + scroll_x - src_x) & 0x1ff; + if (flags_line[sx] & TILEMAP_PIXEL_LAYER0) + dst_line[127 - dst_x] = src_line[sx]; + + ++dst_x; + } + } + } + + src_y += 1 + yrom[dst_y ^ dinvert]; + } +} + + + +uint32_t equites_state::screen_update_equites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + bitmap.fill(m_bgcolor, cliprect); + + m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + + equites_draw_sprites(bitmap, cliprect); + + m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + + return 0; +} + +uint32_t splndrbt_state::screen_update_splndrbt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + bitmap.fill(m_bgcolor, cliprect); + + splndrbt_copy_bg(bitmap, cliprect); + + if (m_fg_char_bank) + m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + + splndrbt_draw_sprites(bitmap, cliprect); + + if (!m_fg_char_bank) + m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + + return 0; +} + /******************************************************************************/ @@ -1719,6 +2281,8 @@ void splndrbt_state::init_splndrbt() unpack_region("gfx3"); } +} // anonymous namespace + /******************************************************************************/ diff --git a/src/mame/alpha/equites.h b/src/mame/alpha/equites.h deleted file mode 100644 index 9b03bd67238..00000000000 --- a/src/mame/alpha/equites.h +++ /dev/null @@ -1,142 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Acho A. Tang, Nicola Salmoria -/************************************************************************* - - Equites, Splendor Blast driver - -*************************************************************************/ -#ifndef MAME_INCLUDES_EQUITES_H -#define MAME_INCLUDES_EQUITES_H - -#pragma once - -#include "machine/74259.h" -#include "alpha8201.h" -#include "machine/timer.h" -#include "emupal.h" -#include "screen.h" -#include "tilemap.h" - - -class equites_state : public driver_device -{ -public: - equites_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_bg_videoram(*this, "bg_videoram"), - m_spriteram(*this, "spriteram"), - m_spriteram_2(*this, "spriteram_2"), - m_maincpu(*this, "maincpu"), - m_gfxdecode(*this, "gfxdecode"), - m_palette(*this, "palette"), - m_screen(*this, "screen"), - m_alpha_8201(*this, "alpha_8201"), - m_mainlatch(*this, "mainlatch") - { } - - void equites(machine_config &config); - void bngotime(machine_config &config); - void init_equites(); - -protected: - // memory pointers - required_shared_ptr m_bg_videoram; - std::unique_ptr m_fg_videoram; // 8bits - required_shared_ptr m_spriteram; - optional_shared_ptr m_spriteram_2; - - // devices - required_device m_maincpu; - required_device m_gfxdecode; - required_device m_palette; - required_device m_screen; - required_device m_alpha_8201; - required_device m_mainlatch; - - // video-related - tilemap_t *m_fg_tilemap = nullptr; - tilemap_t *m_bg_tilemap = nullptr; - uint8_t m_bgcolor = 0U; - - uint16_t equites_spriteram_kludge_r(); - uint8_t equites_fg_videoram_r(offs_t offset); - void equites_fg_videoram_w(offs_t offset, uint8_t data); - void equites_bg_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void equites_bgcolor_w(offs_t offset, uint8_t data); - void equites_scrollreg_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - DECLARE_WRITE_LINE_MEMBER(flip_screen_w); - TILE_GET_INFO_MEMBER(equites_fg_info); - TILE_GET_INFO_MEMBER(equites_bg_info); - DECLARE_VIDEO_START(equites); - void equites_palette(palette_device &palette) const; - uint32_t screen_update_equites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - TIMER_DEVICE_CALLBACK_MEMBER(equites_scanline); - void equites_draw_sprites_block(bitmap_ind16 &bitmap, const rectangle &cliprect, int start, int end); - void equites_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); - void unpack_block(const char *region, int offset, int size); - void unpack_region(const char *region); - - virtual void machine_start() override; - void bngotime_map(address_map &map); - void equites_map(address_map &map); - void equites_common_map(address_map &map); -}; - - -class gekisou_state : public equites_state -{ -public: - gekisou_state(const machine_config &mconfig, device_type type, const char *tag) : - equites_state(mconfig, type, tag) - { } - - DECLARE_READ_LINE_MEMBER(gekisou_unknown_bit_r); - void gekisou(machine_config &config); - -protected: - virtual void machine_start() override; - -private: - void gekisou_map(address_map &map); - void gekisou_unknown_bit_w(offs_t offset, uint16_t data); - - int m_gekisou_unknown_bit = 0; -}; - - -class splndrbt_state : public equites_state -{ -public: - splndrbt_state(const machine_config &mconfig, device_type type, const char *tag) : - equites_state(mconfig, type, tag), - m_scale_rom(*this, "scale%u", 1U) - { } - - void init_splndrbt(); - void splndrbt(machine_config &config); - -protected: - virtual void machine_start() override; - -private: - required_region_ptr_array m_scale_rom; - - void splndrbt_map(address_map &map); - DECLARE_WRITE_LINE_MEMBER(splndrbt_selchar_w); - void splndrbt_bg_scrollx_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - void splndrbt_bg_scrolly_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); - TILE_GET_INFO_MEMBER(splndrbt_fg_info); - TILE_GET_INFO_MEMBER(splndrbt_bg_info); - DECLARE_VIDEO_START(splndrbt); - void splndrbt_palette(palette_device &palette) const; - uint32_t screen_update_splndrbt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - TIMER_DEVICE_CALLBACK_MEMBER(splndrbt_scanline); - void splndrbt_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); - void splndrbt_copy_bg(bitmap_ind16 &dst_bitmap, const rectangle &cliprect); - - int m_fg_char_bank = 0; - uint16_t m_splndrbt_bg_scrollx = 0U; - uint16_t m_splndrbt_bg_scrolly = 0U; -}; - -#endif // MAME_INCLUDES_EQUITES_H diff --git a/src/mame/alpha/equites_v.cpp b/src/mame/alpha/equites_v.cpp deleted file mode 100644 index 1ec2c81ff2b..00000000000 --- a/src/mame/alpha/equites_v.cpp +++ /dev/null @@ -1,445 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Acho A. Tang, Nicola Salmoria -/************************************************************************* - - Equites, Splendor Blast driver - - functions to emulate the video hardware - -*************************************************************************/ - -#include "emu.h" -#include "equites.h" - - -/************************************* - * - * Palette handling - * - *************************************/ - -void equites_state::equites_palette(palette_device &palette) const -{ - const uint8_t *color_prom = memregion("proms")->base(); - - for (int i = 0; i < 256; i++) - palette.set_indirect_color(i, rgb_t(pal4bit(color_prom[i]), pal4bit(color_prom[i + 0x100]), pal4bit(color_prom[i + 0x200]))); - - // point to the CLUT - color_prom += 0x380; - - for (int i = 0; i < 256; i++) - palette.set_pen_indirect(i, i); - - for (int i = 0; i < 0x80; i++) - palette.set_pen_indirect(i + 0x100, color_prom[i]); -} - -void splndrbt_state::splndrbt_palette(palette_device &palette) const -{ - const uint8_t *color_prom = memregion("proms")->base(); - - for (int i = 0; i < 0x100; i++) - palette.set_indirect_color(i, rgb_t(pal4bit(color_prom[i]), pal4bit(color_prom[i + 0x100]), pal4bit(color_prom[i + 0x200]))); - - for (int i = 0; i < 0x100; i++) - palette.set_pen_indirect(i, i); - - // point to the bg CLUT - color_prom += 0x300; - - for (int i = 0; i < 0x80; i++) - palette.set_pen_indirect(i + 0x100, color_prom[i] + 0x10); - - // point to the sprite CLUT - color_prom += 0x100; - - for (int i = 0; i < 0x100; i++) - palette.set_pen_indirect(i + 0x180, color_prom[i]); -} - - - -/************************************* - * - * Callbacks for the TileMap code - * - *************************************/ - -TILE_GET_INFO_MEMBER(equites_state::equites_fg_info) -{ - int tile = m_fg_videoram[2 * tile_index]; - int color = m_fg_videoram[2 * tile_index + 1] & 0x1f; - - tileinfo.set(0, tile, color, 0); - if (color & 0x10) - tileinfo.flags |= TILE_FORCE_LAYER0; -} - -TILE_GET_INFO_MEMBER(splndrbt_state::splndrbt_fg_info) -{ - int tile = m_fg_videoram[2 * tile_index] + (m_fg_char_bank << 8); - int color = m_fg_videoram[2 * tile_index + 1] & 0x3f; - - tileinfo.set(0, tile, color, 0); - if (color & 0x10) - tileinfo.flags |= TILE_FORCE_LAYER0; -} - -TILE_GET_INFO_MEMBER(equites_state::equites_bg_info) -{ - int data = m_bg_videoram[tile_index]; - int tile = data & 0x1ff; - int color = (data & 0xf000) >> 12; - int fxy = (data & 0x0600) >> 9; - - tileinfo.set(1, tile, color, TILE_FLIPXY(fxy)); -} - -TILE_GET_INFO_MEMBER(splndrbt_state::splndrbt_bg_info) -{ - int data = m_bg_videoram[tile_index]; - int tile = data & 0x1ff; - int color = (data & 0xf800) >> 11; - int fxy = (data & 0x0600) >> 9; - - tileinfo.set(1, tile, color, TILE_FLIPXY(fxy)); - tileinfo.group = color; -} - - - -/************************************* - * - * Video system start - * - *************************************/ - -VIDEO_START_MEMBER(equites_state,equites) -{ - m_fg_videoram = std::make_unique(0x800); - save_pointer(NAME(m_fg_videoram), 0x800); - - m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(equites_state::equites_fg_info)), TILEMAP_SCAN_COLS, 8, 8, 32, 32); - m_fg_tilemap->set_transparent_pen(0); - - m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(equites_state::equites_bg_info)), TILEMAP_SCAN_ROWS, 16, 16, 16, 16); - m_bg_tilemap->set_transparent_pen(0); - m_bg_tilemap->set_scrolldx(0, -10); -} - -VIDEO_START_MEMBER(splndrbt_state,splndrbt) -{ - assert(m_screen->format() == BITMAP_FORMAT_IND16); - - m_fg_videoram = std::make_unique(0x800); - save_pointer(NAME(m_fg_videoram), 0x800); - - m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(splndrbt_state::splndrbt_fg_info)), TILEMAP_SCAN_COLS, 8, 8, 32, 32); - m_fg_tilemap->set_transparent_pen(0); - m_fg_tilemap->set_scrolldx(8, -8); - - m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(splndrbt_state::splndrbt_bg_info)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32); - m_bg_tilemap->configure_groups(*m_gfxdecode->gfx(1), 0x10); -} - - - -/************************************* - * - * Memory handlers - * - *************************************/ - -uint8_t equites_state::equites_fg_videoram_r(offs_t offset) -{ - // 8-bit - return m_fg_videoram[offset]; -} - -void equites_state::equites_fg_videoram_w(offs_t offset, uint8_t data) -{ - m_fg_videoram[offset] = data; - m_fg_tilemap->mark_tile_dirty(offset >> 1); -} - -void equites_state::equites_bg_videoram_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(m_bg_videoram + offset); - m_bg_tilemap->mark_tile_dirty(offset); -} - -void equites_state::equites_bgcolor_w(offs_t offset, uint8_t data) -{ - // bg color register - if (offset == 0) - m_bgcolor = data; -} - -void equites_state::equites_scrollreg_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - if (ACCESSING_BITS_0_7) - m_bg_tilemap->set_scrolly(0, data & 0xff); - - if (ACCESSING_BITS_8_15) - m_bg_tilemap->set_scrollx(0, data >> 8); -} - -WRITE_LINE_MEMBER(splndrbt_state::splndrbt_selchar_w) -{ - // select active char map - m_fg_char_bank = (state == 0) ? 0 : 1; - m_fg_tilemap->mark_all_dirty(); -} - -WRITE_LINE_MEMBER(equites_state::flip_screen_w) -{ - flip_screen_set(state); -} - -void splndrbt_state::splndrbt_bg_scrollx_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_splndrbt_bg_scrollx); -} - -void splndrbt_state::splndrbt_bg_scrolly_w(offs_t offset, uint16_t data, uint16_t mem_mask) -{ - COMBINE_DATA(&m_splndrbt_bg_scrolly); -} - - - -/************************************* - * - * Video update - * - *************************************/ - -void equites_state::equites_draw_sprites_block(bitmap_ind16 &bitmap, const rectangle &cliprect, int start, int end) -{ - for (int offs = end - 2; offs >= start; offs -= 2) - { - int attr = m_spriteram[offs + 1]; - if (!(attr & 0x800)) // disable or x MSB? - { - int tile = attr & 0x1ff; - int fx = ~attr & 0x400; - int fy = ~attr & 0x200; - int color = (~attr & 0xf000) >> 12; - int sx = (m_spriteram[offs] & 0xff00) >> 8; - int sy = (m_spriteram[offs] & 0x00ff); - int transmask = m_palette->transpen_mask(*m_gfxdecode->gfx(2), color, 0); - - if (flip_screen()) - { - sx = 240 - sx; - sy = 240 - sy; - fx = !fx; - fy = !fy; - } - - // align - sx -= 4; - - // sprites are 16x14 centered in a 16x16 square, so skip the first line - sy += 1; - - m_gfxdecode->gfx(2)->transmask(bitmap,cliprect, - tile, - color, - fx, fy, - sx, sy, transmask); - } - } -} - -void equites_state::equites_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - // note that we draw the sprites in three blocks; in each blocks, sprites at - // a lower address have priority. This gives good priorities in gekisou. - equites_draw_sprites_block(bitmap, cliprect, 0x000/2, 0x060/2); - equites_draw_sprites_block(bitmap, cliprect, 0x0e0/2, 0x100/2); - equites_draw_sprites_block(bitmap, cliprect, 0x1a4/2, 0x200/2); -} - - -/* -This is (probably) the sprite x scaling PROM. -The layout is strange. Clearly every line is for one xscale setting. However, -it seems that bytes 0-3 are handled separately from bytes 4-F. -Also, note that sprites are 30x30, not 32x32. -00020200 00000000 00000000 00000000 -00020200 01000000 00000000 00000002 -00020200 01000000 01000002 00000002 -00020200 01000100 01000002 00020002 -00020200 01000100 01010202 00020002 -02020201 01000100 01010202 00020002 -02020201 01010100 01010202 00020202 -02020201 01010101 01010202 02020202 -02020201 03010101 01010202 02020203 -02020201 03010103 01010202 03020203 -02020201 03010103 01030302 03020203 -02020201 03010303 01030302 03030203 -03020203 03010303 01030302 03030203 -03020203 03030303 01030302 03030303 -03020203 03030303 03030303 03030303 -03020303 03030303 03030303 03030303 -*/ - -void splndrbt_state::splndrbt_draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - const uint8_t * const xrom = m_scale_rom[1]; - const uint8_t * const yrom = xrom + 0x100; - gfx_element* gfx = m_gfxdecode->gfx(2); - - // note that sprites are actually 30x30, contained in 32x32 squares. The outer edge is not used. - - for (int offs = 0x3f; offs < 0x6f; offs += 2) // 24 sprites - { - int data = m_spriteram[offs]; - int fx = (data & 0x2000) >> 13; - int fy = (data & 0x1000) >> 12; - int tile = data & 0x007f; - int scaley = (data & 0x0f00) >> 8; - int data2 = m_spriteram[offs + 1]; - int color = (data2 & 0x1f00) >> 8; - int sx = data2 & 0x00ff; - int sy = m_spriteram_2[offs + 0] & 0x00ff; - int scalex = m_spriteram_2[offs + 1] & 0x000f; - int transmask = m_palette->transpen_mask(*gfx, color, 0); - -// const uint8_t * const xromline = xrom + (scalex << 4); - const uint8_t * const yromline = yrom + (scaley << 4) + (15 - scaley); - const uint8_t* const srcgfx = gfx->get_data(tile); - const pen_t *paldata = &m_palette->pen(gfx->colorbase() + gfx->granularity() * color); - int x,yy; - - sy += 16; - - if (flip_screen()) - { - // sx NOT inverted - fx = fx ^ 1; - fy = fy ^ 1; - } - else - { - sy = 256 - sy; - } - - for (yy = 0; yy <= scaley; ++yy) - { - int const line = yromline[yy]; - int yhalf; - - for (yhalf = 0; yhalf < 2; ++yhalf) // top or bottom half - { - int const y = yhalf ? sy + 1 + yy : sy - yy; - - if (y >= cliprect.top() && y <= cliprect.bottom()) - { - for (x = 0; x <= (scalex << 1); ++x) - { - int bx = (sx + x) & 0xff; - - if (bx >= cliprect.left() && bx <= cliprect.right()) - { - int xx = scalex ? (x * 29 + scalex) / (scalex << 1) + 1 : 16; // FIXME This is wrong. Should use the PROM. - int const offset = (fx ? (31 - xx) : xx) + ((fy ^ yhalf) ? (16 + line) : (15 - line)) * gfx->rowbytes(); - - int pen = srcgfx[offset]; - - if ((transmask & (1 << pen)) == 0) - bitmap.pix(y, bx) = paldata[pen]; - } - } - } - } - } - } -} - - -void splndrbt_state::splndrbt_copy_bg(bitmap_ind16 &dst_bitmap, const rectangle &cliprect) -{ - bitmap_ind16 &src_bitmap = m_bg_tilemap->pixmap(); - bitmap_ind8 &flags_bitmap = m_bg_tilemap->flagsmap(); - const uint8_t * const xrom = m_scale_rom[0]; - const uint8_t * const yrom = xrom + 0x2000; - int scroll_x = m_splndrbt_bg_scrollx; - int scroll_y = m_splndrbt_bg_scrolly; - int const dinvert = flip_screen() ? 0xff : 0x00; - int src_y = 0; - int dst_y; - - if (flip_screen()) - { - scroll_x = -scroll_x - 8; - scroll_y = -scroll_y; - } - - for (dst_y = 32; dst_y < 256-32; ++dst_y) - { - if (dst_y >= cliprect.top() && dst_y <= cliprect.bottom()) - { - const uint8_t * const romline = &xrom[(dst_y ^ dinvert) << 5]; - const uint16_t * const src_line = &src_bitmap.pix((src_y + scroll_y) & 0x1ff); - const uint8_t * const flags_line = &flags_bitmap.pix((src_y + scroll_y) & 0x1ff); - uint16_t * const dst_line = &dst_bitmap.pix(dst_y); - int dst_x = 0; - int src_x; - - for (src_x = 0; src_x < 256 && dst_x < 128; ++src_x) - { - if ((romline[31 - (src_x >> 3)] >> (src_x & 7)) & 1) - { - int sx; - - sx = (256+128 + scroll_x + src_x) & 0x1ff; - if (flags_line[sx] & TILEMAP_PIXEL_LAYER0) - dst_line[128 + dst_x] = src_line[sx]; - - sx = (255+128 + scroll_x - src_x) & 0x1ff; - if (flags_line[sx] & TILEMAP_PIXEL_LAYER0) - dst_line[127 - dst_x] = src_line[sx]; - - ++dst_x; - } - } - } - - src_y += 1 + yrom[dst_y ^ dinvert]; - } -} - - - -uint32_t equites_state::screen_update_equites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - bitmap.fill(m_bgcolor, cliprect); - - m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - - equites_draw_sprites(bitmap, cliprect); - - m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - - return 0; -} - -uint32_t splndrbt_state::screen_update_splndrbt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - bitmap.fill(m_bgcolor, cliprect); - - splndrbt_copy_bg(bitmap, cliprect); - - if (m_fg_char_bank) - m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - - splndrbt_draw_sprites(bitmap, cliprect); - - if (!m_fg_char_bank) - m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - - return 0; -} diff --git a/src/mame/alpha/shougi.cpp b/src/mame/alpha/shougi.cpp index b7fdcf3aab4..4421aa1ab95 100644 --- a/src/mame/alpha/shougi.cpp +++ b/src/mame/alpha/shougi.cpp @@ -78,16 +78,20 @@ PROM : Type MB7051 **************************************************************************/ #include "emu.h" -#include "machine/74259.h" + #include "alpha8201.h" + +#include "machine/74259.h" #include "machine/watchdog.h" #include "cpu/z80/z80.h" #include "sound/ay8910.h" #include "video/resnet.h" + #include "emupal.h" #include "screen.h" #include "speaker.h" +namespace { class shougi_state : public driver_device { @@ -465,6 +469,8 @@ ROM_START( shougi2 ) ROM_LOAD( "pr.2l", 0x0000, 0x0020, CRC(cd3559ff) SHA1(a1291b06a8a337943660b2ef62c94c49d58a6fb5) ) ROM_END +} // anonymous namespace + /* YEAR NAME PARENT MACHINE INPUT STATE INIT MONITOR COMPANY FULLNAME FLAGS */ GAME( 1982, shougi, 0, shougi, shougi, shougi_state, empty_init, ROT0, "Alpha Denshi Co. (Tehkan license)", "Shougi", MACHINE_SUPPORTS_SAVE ) -- cgit v1.2.3