mirror of
https://github.com/holub/mame
synced 2025-04-20 15:32:45 +03:00
machine/k056230: preliminary Konami Viper LANC superset
* Applies portions of PR #12546 * fixes gameplay hangs/crashes in gticlub2, xtrial, code1d, wcombat
This commit is contained in:
parent
bc23190458
commit
93060d50e3
@ -1,6 +1,6 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Fabio Priuli
|
||||
/***************************************************************************
|
||||
/**************************************************************************************************
|
||||
|
||||
Konami IC 056230 (LANC)
|
||||
|
||||
@ -12,9 +12,11 @@ Device Notes:
|
||||
-PAL(056787A) for zr107.cpp, gticlub.cpp and thunderh's I/O board
|
||||
-HYC2485S RS485 transceiver
|
||||
|
||||
TODO: nearly everything
|
||||
TODO:
|
||||
- nearly everything, currently a wrapper to make games happy and don't fail POSTs
|
||||
- LANC part name for konami/viper.cpp
|
||||
|
||||
***************************************************************************/
|
||||
**************************************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
|
||||
@ -31,42 +33,51 @@ TODO: nearly everything
|
||||
#include "logmacro.h"
|
||||
|
||||
DEFINE_DEVICE_TYPE(K056230, k056230_device, "k056230", "K056230 LANC")
|
||||
DEFINE_DEVICE_TYPE(K056230_VIPER, k056230_viper_device, "k056230_viper", "Konami Viper LANC")
|
||||
|
||||
|
||||
k056230_device::k056230_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
|
||||
: device_t(mconfig, K056230, tag, owner, clock)
|
||||
k056230_device::k056230_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
|
||||
: device_t(mconfig, type, tag, owner, clock)
|
||||
, m_ram(*this, "lanc_ram", 0x800U * 4, ENDIANNESS_BIG)
|
||||
, m_irq_cb(*this)
|
||||
{
|
||||
}
|
||||
|
||||
k056230_device::k056230_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
|
||||
: k056230_device(mconfig, K056230, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
void k056230_device::device_start()
|
||||
{
|
||||
m_irq_state = CLEAR_LINE;
|
||||
|
||||
save_item(NAME(m_irq_state));
|
||||
save_item(NAME(m_status));
|
||||
}
|
||||
|
||||
void k056230_device::device_reset()
|
||||
{
|
||||
m_irq_state = CLEAR_LINE;
|
||||
m_status = 0x08;
|
||||
}
|
||||
|
||||
void k056230_device::regs_map(address_map &map)
|
||||
{
|
||||
map(0x00, 0x00).lrw8(
|
||||
NAME([this] (offs_t offset) {
|
||||
const u8 res = 0x08;
|
||||
LOGMASKED(LOG_REG_READS, "%s: regs_r: Status Register: %02x\n", machine().describe_context(), res);
|
||||
return res;
|
||||
LOGMASKED(LOG_REG_READS, "%s: Status Register read %02x\n", machine().describe_context(), m_status);
|
||||
return m_status;
|
||||
}),
|
||||
NAME([this] (offs_t offset, u8 data) {
|
||||
LOGMASKED(LOG_REG_WRITES, "%s: regs_w: Mode Register = %02x\n", machine().describe_context(), data);
|
||||
LOGMASKED(LOG_REG_WRITES, "%s: Mode Register read %02x\n", machine().describe_context(), data);
|
||||
})
|
||||
),
|
||||
map(0x01, 0x01).lrw8(
|
||||
NAME([this] (offs_t offset) {
|
||||
const u8 res = 0x00;
|
||||
LOGMASKED(LOG_REG_READS, "%s: regs_r: CRC Error Register: %02x\n", machine().describe_context(), res);
|
||||
LOGMASKED(LOG_REG_READS, "%s: CRC Error Register read %02x\n", machine().describe_context(), res);
|
||||
return res;
|
||||
}),
|
||||
NAME([this] (offs_t offset, u8 data) {
|
||||
LOGMASKED(LOG_REG_WRITES, "%s: regs_w: Control Register = %02x\n", machine().describe_context(), data);
|
||||
LOGMASKED(LOG_REG_WRITES, "%s: Control Register write %02x\n", machine().describe_context(), data);
|
||||
// TODO: This is a literal translation of the previous device behaviour, and is incorrect.
|
||||
// Namely it can't possibly ping irq state on the fly, needs some transaction from the receiver.
|
||||
const int old_state = m_irq_state;
|
||||
@ -107,3 +118,80 @@ void k056230_device::ram_w(offs_t offset, u32 data, u32 mem_mask)
|
||||
LOGMASKED(LOG_RAM_WRITES, "%s: Network RAM write [%04x (%03x)] = %08x & %08x\n", machine().describe_context(), offset << 2, (offset & 0x7ff) << 2, data, mem_mask);
|
||||
COMBINE_DATA(&lanc_ram[offset & 0x7ff]);
|
||||
}
|
||||
|
||||
/****************************************
|
||||
*
|
||||
* konami/viper.cpp superset overrides
|
||||
*
|
||||
***************************************/
|
||||
|
||||
k056230_viper_device::k056230_viper_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
|
||||
: k056230_device(mconfig, K056230_VIPER, tag, owner, clock)
|
||||
{
|
||||
}
|
||||
|
||||
void k056230_viper_device::device_reset()
|
||||
{
|
||||
k056230_device::device_reset();
|
||||
m_control = 0;
|
||||
m_irq_enable = false;
|
||||
m_unk[0] = m_unk[1] = 0;
|
||||
}
|
||||
|
||||
void k056230_viper_device::regs_map(address_map &map)
|
||||
{
|
||||
map(0x00, 0x00).lw8(
|
||||
NAME([this] (offs_t offset, u8 data) {
|
||||
LOGMASKED(LOG_REG_WRITES, "%s: network_id_w = %02x\n", machine().describe_context(), data);
|
||||
})
|
||||
);
|
||||
map(0x01, 0x01).lw8(
|
||||
NAME([this] (offs_t offset, u8 data) {
|
||||
// HACK: more irq bad juju
|
||||
if (!BIT(data, 0))
|
||||
{
|
||||
m_status = 0;
|
||||
m_irq_state = CLEAR_LINE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_irq_enable)
|
||||
m_irq_state = ASSERT_LINE;
|
||||
}
|
||||
|
||||
if (BIT(data, 3))
|
||||
m_status = 0x10;
|
||||
|
||||
m_irq_cb(m_irq_state);
|
||||
|
||||
// TODO: is this readback-able?
|
||||
m_control = data;
|
||||
LOGMASKED(LOG_REG_WRITES, "%s: control_w: %02x\n", machine().describe_context(), m_control);
|
||||
})
|
||||
);
|
||||
map(0x02, 0x02).lr8(
|
||||
NAME([this] (offs_t offset) {
|
||||
LOGMASKED(LOG_REG_READS, "%s: status_r: %02x\n", machine().describe_context(), m_status);
|
||||
return m_status;
|
||||
})
|
||||
);
|
||||
// TODO: unknown regs
|
||||
map(0x03, 0x04).lrw8(
|
||||
NAME([this] (offs_t offset) {
|
||||
LOGMASKED(LOG_REG_READS, "%s: unk%d_r\n", machine().describe_context(), offset + 3, m_unk[offset]);
|
||||
return m_unk[offset];
|
||||
}),
|
||||
NAME([this] (offs_t offset, u8 data) {
|
||||
LOGMASKED(LOG_REG_WRITES, "%s: unk%d_w %02x\n", machine().describe_context(), offset + 3, m_unk[offset], data);
|
||||
m_unk[offset] = data;
|
||||
})
|
||||
);
|
||||
map(0x05, 0x05).lw8(
|
||||
NAME([this] (offs_t offset, u8 data) {
|
||||
// TODO: should sync if an irq is already there
|
||||
m_irq_enable = bool(BIT(data, 0));
|
||||
LOGMASKED(LOG_REG_WRITES, "%s: irq enable: %02x\n", machine().describe_context(), data);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -22,21 +22,42 @@ public:
|
||||
u32 ram_r(offs_t offset, u32 mem_mask = ~0);
|
||||
void ram_w(offs_t offset, u32 data, u32 mem_mask = ~0);
|
||||
|
||||
void regs_map(address_map &map);
|
||||
virtual void regs_map(address_map &map);
|
||||
|
||||
protected:
|
||||
k056230_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// device-level overrides
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
|
||||
memory_share_creator<u32> m_ram;
|
||||
|
||||
devcb_write_line m_irq_cb;
|
||||
int m_irq_state;
|
||||
u8 m_ctrl_reg;
|
||||
int m_irq_state = 0;
|
||||
u8 m_ctrl_reg = 0;
|
||||
u8 m_status = 0;
|
||||
};
|
||||
|
||||
class k056230_viper_device : public k056230_device
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
k056230_viper_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);
|
||||
|
||||
virtual void regs_map(address_map &map) override;
|
||||
|
||||
protected:
|
||||
virtual void device_reset() override;
|
||||
|
||||
private:
|
||||
u8 m_control = 0;
|
||||
bool m_irq_enable = false;
|
||||
u8 m_unk[2]{};
|
||||
};
|
||||
|
||||
// device type definition
|
||||
DECLARE_DEVICE_TYPE(K056230, k056230_device)
|
||||
DECLARE_DEVICE_TYPE(K056230_VIPER, k056230_viper_device)
|
||||
|
||||
#endif // MAME_MACHINE_K056230_H
|
||||
|
@ -431,6 +431,7 @@ The golf club acts like a LED gun. PCB power input is 12V.
|
||||
#include "bus/ata/hdd.h"
|
||||
#include "machine/ds2430a.h"
|
||||
#include "machine/ins8250.h"
|
||||
#include "machine/k056230.h"
|
||||
#include "machine/lpci.h"
|
||||
#include "machine/timekpr.h"
|
||||
#include "machine/timer.h"
|
||||
@ -471,6 +472,7 @@ public:
|
||||
m_maincpu(*this, "maincpu"),
|
||||
m_screen(*this, "screen"),
|
||||
m_duart_com(*this, "duart_com"),
|
||||
m_lanc(*this, "lanc"),
|
||||
m_ata(*this, "ata"),
|
||||
m_lpci(*this, "pcibus"),
|
||||
m_ds2430(*this, "ds2430"),
|
||||
@ -537,6 +539,7 @@ private:
|
||||
|
||||
uint16_t ppp_sensor_r(offs_t offset);
|
||||
|
||||
void lanc_int(int state);
|
||||
void uart_int(int state);
|
||||
|
||||
void voodoo_vblank(int state);
|
||||
@ -657,6 +660,7 @@ private:
|
||||
required_device<ppc_device> m_maincpu;
|
||||
required_device<screen_device> m_screen;
|
||||
required_device<pc16552_device> m_duart_com;
|
||||
required_device<k056230_device> m_lanc;
|
||||
required_device<ata_interface_device> m_ata;
|
||||
required_device<pci_bus_legacy_device> m_lpci;
|
||||
required_device<ds2430a_device> m_ds2430;
|
||||
@ -1863,8 +1867,8 @@ void viper_state::viper_map(address_map &map)
|
||||
map(0xffe78000, 0xffe78000).rw(FUNC(viper_state::ds2430_ext_r), FUNC(viper_state::ds2430_ext_w));
|
||||
map(0xffe80000, 0xffe80007).w(FUNC(viper_state::unk1a_w));
|
||||
map(0xffe88000, 0xffe88007).w(FUNC(viper_state::unk1b_w));
|
||||
map(0xffe98000, 0xffe98007).noprw(); // network?
|
||||
map(0xffe9a000, 0xffe9bfff).ram(); // wcombat uses this
|
||||
map(0xffe98000, 0xffe98007).m(m_lanc, FUNC(k056230_viper_device::regs_map));
|
||||
map(0xffe9a000, 0xffe9bfff).rw(m_lanc, FUNC(k056230_viper_device::ram_r), FUNC(k056230_viper_device::ram_w));
|
||||
map(0xffea0000, 0xffea0007).lr8(
|
||||
NAME([this] (offs_t offset) {
|
||||
const u8 res = m_gun_input[offset >> 1]->read() >> ((offset & 1) ? 0 : 8);
|
||||
@ -2444,6 +2448,12 @@ INPUT_PORTS_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void viper_state::lanc_int(int state)
|
||||
{
|
||||
if (state)
|
||||
mpc8240_interrupt(MPC8240_IRQ1);
|
||||
}
|
||||
|
||||
void viper_state::uart_int(int state)
|
||||
{
|
||||
if (state)
|
||||
@ -2589,6 +2599,9 @@ void viper_state::viper(machine_config &config)
|
||||
NS16550(config, "duart_com:chan0", XTAL(19'660'800));
|
||||
NS16550(config, "duart_com:chan1", XTAL(19'660'800)).out_int_callback().set(FUNC(viper_state::uart_int));
|
||||
|
||||
K056230_VIPER(config, m_lanc);
|
||||
m_lanc->irq_cb().set(FUNC(viper_state::lanc_int));
|
||||
|
||||
VOODOO_3(config, m_voodoo, voodoo_3_device::NOMINAL_CLOCK);
|
||||
m_voodoo->set_fbmem(8); // TODO: should be 16, implement VMI_DATA_5 strapping pin in Voodoo 3 core instead
|
||||
m_voodoo->set_screen("screen");
|
||||
|
Loading…
Reference in New Issue
Block a user