taito/lkage.cpp: Add variant of The Legend of Kage with MSM5232. (#11424)

Also combined source files and cleaned up code.

New working systems
-------------------
The Legend of Kage (MSM5232 ver) [Takahiro Nogi]
This commit is contained in:
Ivan Vangelista 2023-08-07 19:59:34 +02:00 committed by GitHub
parent e97630981c
commit a4421fa962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 586 additions and 474 deletions

View File

@ -42630,6 +42630,7 @@ lgpalt // (c) 1983 Taito
@source:taito/lkage.cpp
bygone // A53 (c) 1985 Taito Corporation - prototype ?
lkage // A54 (c) 1984 Taito Corporation
lkage5232 //
lkageb // bootleg
lkageb2 // bootleg
lkageb3 // bootleg

File diff suppressed because it is too large Load Diff

View File

@ -1,95 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Phil Stroffolino
#ifndef MAME_TAITO_LKAGE_H
#define MAME_TAITO_LKAGE_H
#pragma once
#include "taito68705.h"
#include "machine/gen_latch.h"
#include "machine/input_merger.h"
#include "emupal.h"
#include "tilemap.h"
class lkage_state : public driver_device
{
public:
lkage_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_vreg(*this, "vreg"),
m_scroll(*this, "scroll"),
m_spriteram(*this, "spriteram"),
m_videoram(*this, "videoram"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_bmcu(*this, "bmcu"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_soundlatch(*this, "soundlatch"),
m_soundnmi(*this, "soundnmi")
{ }
void lkageb(machine_config &config);
void lkage(machine_config &config);
void init_bygone();
void init_lkage();
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
private:
required_shared_ptr<uint8_t> m_vreg;
required_shared_ptr<uint8_t> m_scroll;
required_shared_ptr<uint8_t> m_spriteram;
required_shared_ptr<uint8_t> m_videoram;
/* video-related */
tilemap_t *m_bg_tilemap = nullptr;
tilemap_t *m_fg_tilemap = nullptr;
tilemap_t *m_tx_tilemap = nullptr;
uint8_t m_bg_tile_bank = 0U;
uint8_t m_fg_tile_bank = 0U;
uint8_t m_tx_tile_bank = 0U;
int m_sprite_dx = 0;
/* lkageb fake mcu */
uint8_t m_mcu_val = 0U;
int m_mcu_ready = 0; /* cpu data/mcu ready status */
/* devices */
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
optional_device<taito68705_mcu_device> m_bmcu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_device<generic_latch_8_device> m_soundlatch;
required_device<input_merger_device> m_soundnmi;
void lkage_sh_nmi_disable_w(uint8_t data);
void lkage_sh_nmi_enable_w(uint8_t data);
uint8_t sound_status_r();
uint8_t port_fetch_r(offs_t offset);
uint8_t mcu_status_r();
uint8_t fake_mcu_r();
void fake_mcu_w(uint8_t data);
uint8_t fake_status_r();
void lkage_videoram_w(offs_t offset, uint8_t data);
TILE_GET_INFO_MEMBER(get_bg_tile_info);
TILE_GET_INFO_MEMBER(get_fg_tile_info);
TILE_GET_INFO_MEMBER(get_tx_tile_info);
uint32_t screen_update_lkage(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
void lkage_io_map(address_map &map);
void lkage_map(address_map &map);
void lkage_map_boot(address_map &map);
void lkage_map_mcu(address_map &map);
void lkage_sound_map(address_map &map);
};
#endif // MAME_TAITO_LKAGE_H

View File

@ -1,225 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Phil Stroffolino
/***************************************************************************
video/lkage.c
lkage_scroll[0x00]: text layer horizontal scroll
lkage_scroll[0x01]: text layer vertical scroll
lkage_scroll[0x02]: foreground layer horizontal scroll
lkage_scroll[0x03]: foreground layer vertical scroll
lkage_scroll[0x04]: background layer horizontal scroll
lkage_scroll[0x05]: background layer vertical scroll
lkage_vreg[0]: 0x00,0x04
0x02: tx tile bank select (bygone only?)
0x04: fg tile bank select
0x08: ?
lkage_vreg[1]: 0x7d
0xf0: background/foreground palette select
0x08: bg tile bank select
0x07: priority config?
lkage_vreg[2]: 0xf3
0x03: flip screen x/y
0xf0: normally 1111, but 1001 and 0001 inbetween stages (while the
backgrounds are are being redrawn). These bits are probably used to enable
individual layers, but we have no way of knowing the mapping.
lkage_vreg:
04 7d f3 : title screen 101
0c 7d f3 : high score 101
04 06 f3 : attract#1 110
04 1e f3 : attract#2 110
04 1e f3 : attract#3 110
00 4e f3 : attract#4 110
***************************************************************************/
#include "emu.h"
#include "lkage.h"
#include "screen.h"
void lkage_state::lkage_videoram_w(offs_t offset, uint8_t data)
{
m_videoram[offset] = data;
switch (offset / 0x400)
{
case 0:
m_tx_tilemap->mark_tile_dirty(offset & 0x3ff);
break;
case 1:
m_fg_tilemap->mark_tile_dirty(offset & 0x3ff);
break;
case 2:
m_bg_tilemap->mark_tile_dirty(offset & 0x3ff);
break;
default:
break;
}
}
TILE_GET_INFO_MEMBER(lkage_state::get_bg_tile_info)
{
int code = m_videoram[tile_index + 0x800] + 256 * (m_bg_tile_bank ? 5 : 1);
tileinfo.set(0/*gfx*/, code, 0/*color*/, 0/*flags*/ );
}
TILE_GET_INFO_MEMBER(lkage_state::get_fg_tile_info)
{
int code = m_videoram[tile_index + 0x400] + 256 * (m_fg_tile_bank ? 1 : 0);
tileinfo.set(0/*gfx*/, code, 0/*color*/, 0/*flags*/);
}
TILE_GET_INFO_MEMBER(lkage_state::get_tx_tile_info)
{
int code = m_videoram[tile_index] + 256 * (m_tx_tile_bank ? 4 : 0);
tileinfo.set(0/*gfx*/, code, 0/*color*/, 0/*flags*/);
}
void lkage_state::video_start()
{
m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(lkage_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
m_fg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(lkage_state::get_fg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
m_tx_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(lkage_state::get_tx_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
m_fg_tilemap->set_transparent_pen(0);
m_tx_tilemap->set_transparent_pen(0);
m_bg_tilemap->set_scrolldx(-5, -5 + 24);
m_fg_tilemap->set_scrolldx(-3, -3 + 24);
m_tx_tilemap->set_scrolldx(-1, -1 + 24);
}
void lkage_state::draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
{
const uint8_t *source = m_spriteram;
const uint8_t *finish = source + 0x60;
while (source < finish)
{
int attributes = source[2];
/* 0x01: horizontal flip
* 0x02: vertical flip
* 0x04: bank select
* 0x08: sprite size
* 0x70: color
* 0x80: priority
*/
int priority_mask = 0;
int color = (attributes >> 4) & 7;
int flipx = attributes & 0x01;
int flipy = attributes & 0x02;
int height = (attributes & 0x08) ? 2 : 1;
int sx = source[0] - 15 + m_sprite_dx;
int sy = 256 - 16 * height - source[1];
int sprite_number = source[3] + ((attributes & 0x04) << 6);
int y;
if (attributes & 0x80)
{
priority_mask = (0xf0 | 0xcc);
}
else
{
priority_mask = 0xf0;
}
if (flip_screen_x())
{
sx = 239 - sx - 24;
flipx = !flipx;
}
if (flip_screen_y())
{
sy = 254 - 16 * height - sy;
flipy = !flipy;
}
if (height == 2 && !flipy)
{
sprite_number ^= 1;
}
for (y = 0; y < height; y++)
{
m_gfxdecode->gfx(1)->prio_transpen(
bitmap,
cliprect,
sprite_number ^ y,
color,
flipx,flipy,
sx&0xff,
sy + 16*y,
screen.priority(),
priority_mask,0 );
}
source += 4;
}
}
uint32_t lkage_state::screen_update_lkage(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int bank;
flip_screen_x_set(~m_vreg[2] & 0x01);
flip_screen_y_set(~m_vreg[2] & 0x02);
bank = m_vreg[1] & 0x08;
if (m_bg_tile_bank != bank)
{
m_bg_tile_bank = bank;
m_bg_tilemap->mark_all_dirty();
}
bank = m_vreg[0]&0x04;
if (m_fg_tile_bank != bank)
{
m_fg_tile_bank = bank;
m_fg_tilemap->mark_all_dirty();
}
bank = m_vreg[0]&0x02;
if (m_tx_tile_bank != bank)
{
m_tx_tile_bank = bank;
m_tx_tilemap->mark_all_dirty();
}
m_bg_tilemap->set_palette_offset(0x300 + (m_vreg[1] & 0xf0));
m_fg_tilemap->set_palette_offset(0x200 + (m_vreg[1] & 0xf0));
m_tx_tilemap->set_palette_offset(0x110);
m_tx_tilemap->set_scrollx(0, m_scroll[0]);
m_tx_tilemap->set_scrolly(0, m_scroll[1]);
m_fg_tilemap->set_scrollx(0, m_scroll[2]);
m_fg_tilemap->set_scrolly(0, m_scroll[3]);
m_bg_tilemap->set_scrollx(0, m_scroll[4]);
m_bg_tilemap->set_scrolly(0, m_scroll[5]);
screen.priority().fill(0, cliprect);
if ((m_vreg[2] & 0xf0) == 0xf0)
{
m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 1);
m_fg_tilemap->draw(screen, bitmap, cliprect, 0, (m_vreg[1] & 2) ? 2 : 4);
m_tx_tilemap->draw(screen, bitmap, cliprect, 0, 4);
draw_sprites(screen, bitmap, cliprect);
}
else
{
m_tx_tilemap->draw(screen, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
}
return 0;
}