Skip to content

Commit

Permalink
funtech/supracan.cpp: move lockout chip to umc6650_device
Browse files Browse the repository at this point in the history
  • Loading branch information
angelosa committed Sep 3, 2024
1 parent 409cd32 commit 1fcf4a9
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 39 deletions.
2 changes: 1 addition & 1 deletion hash/supracan.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Black screen at security BIOS time, cfr. PC=f8061a
<year>1996</year>
<publisher>Funtech</publisher>
<notes><![CDATA[
Too fast in gameplay
Too fast in gameplay, [irq 3] related
]]></notes>
<info name="serial" value="F009" />
<info name="alt_title" value="賭霸 (Du Ba)" />
Expand Down
2 changes: 1 addition & 1 deletion src/mame/funtech/acan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "emu.h"
#include "acan.h"

#define VERBOSE (1)
#define VERBOSE (0)
#include "logmacro.h"

// device type definition
Expand Down
49 changes: 12 additions & 37 deletions src/mame/funtech/supracan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
// copyright-holders:Angelo Salese,Ryan Holtz
/***************************************************************************
Funtech Super A'Can
-------------------
Preliminary driver by Angelo Salese
Improvements by Ryan Holtz
Super A'Can (c) 1995 Funtech
References:
- https://gist.github.com/evadot/66cfdb8891544b41b4c9
Expand Down Expand Up @@ -89,6 +84,7 @@ DEBUG TRICKS:
#include "softlist_dev.h"
#include "speaker.h"
#include "tilemap.h"
#include "umc6650.h"

#define LOG_UNKNOWNS (1U << 1)
#define LOG_DMA (1U << 2)
Expand All @@ -108,7 +104,7 @@ DEBUG TRICKS:
#define LOG_ALL (LOG_UNKNOWNS | LOG_HFUNKNOWNS | LOG_DMA | LOG_VIDEO | LOG_HFVIDEO | LOG_IRQS | LOG_SOUND | LOG_68K_SOUND | LOG_CONTROLS)
#define LOG_DEFAULT (LOG_ALL & ~(LOG_HFVIDEO | LOG_HFUNKNOWNS))

#define VERBOSE (LOG_UNKNOWNS | LOG_SOUND | LOG_DMA)
#define VERBOSE (LOG_UNKNOWNS | LOG_DMA)
#include "logmacro.h"


Expand All @@ -129,10 +125,10 @@ class supracan_state : public driver_device
, m_maincpu(*this, "maincpu")
, m_soundcpu(*this, "soundcpu")
, m_cart(*this, "cartslot")
, m_lockout(*this, "lockout")
, m_internal68(*this, "internal68")
, m_internal68_view(*this, "internal68")
, m_internal68_view_hi(*this, "internal68_hi")
, m_umc6650key(*this, "umc6650key")
, m_vram(*this, "vram")
, m_soundram(*this, "soundram")
, m_sound(*this, "acansnd")
Expand Down Expand Up @@ -168,10 +164,6 @@ class supracan_state : public driver_device
void video_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void vram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);

void umc6650_addr_w(uint8_t data);
uint8_t umc6650_data_r();
void umc6650_data_w(uint8_t data);

uint8_t sound_ram_read(offs_t offset);

struct dma_regs_t
Expand All @@ -195,10 +187,10 @@ class supracan_state : public driver_device
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_soundcpu;
required_device<generic_slot_device> m_cart;
required_device<umc6650_device> m_lockout;
required_region_ptr<uint16_t> m_internal68;
memory_view m_internal68_view;
memory_view m_internal68_view_hi;
required_region_ptr<uint8_t> m_umc6650key;

required_shared_ptr<uint16_t> m_vram;
required_shared_ptr<uint8_t> m_soundram;
Expand Down Expand Up @@ -1335,23 +1327,6 @@ void supracan_state::vram_w(offs_t offset, uint16_t data, uint16_t mem_mask)
m_gfxdecode->gfx(4)->mark_dirty((offset * 2) / 8);
}

void supracan_state::umc6650_addr_w(uint8_t data)
{
m_umc6650_addr = data & 0x7f;
}

uint8_t supracan_state::umc6650_data_r()
{
if (m_umc6650_addr >= 0x20 && m_umc6650_addr < 0x2f)
return m_umc6650key[m_umc6650_addr & 0xf];
return m_umc6650_data[m_umc6650_addr];
}

void supracan_state::umc6650_data_w(uint8_t data)
{
m_umc6650_data[m_umc6650_addr] = data;
}

void supracan_state::supracan_mem(address_map &map)
{
// 0x000000..0x3fffff is mapped by the cartslot
Expand All @@ -1360,8 +1335,9 @@ void supracan_state::supracan_mem(address_map &map)
map(0xe90020, 0xe9002f).w(FUNC(supracan_state::dma_channel0_w));
map(0xe90030, 0xe9003f).w(FUNC(supracan_state::dma_channel1_w));

map(0xeb0d00, 0xeb0d01).rw(FUNC(supracan_state::umc6650_data_r), FUNC(supracan_state::umc6650_data_w)).umask16(0x00ff);
map(0xeb0d02, 0xeb0d03).w(FUNC(supracan_state::umc6650_addr_w)).umask16(0x00ff);
map(0xe90b3c, 0xe90b3d).noprw(); // noisy during lockout checks

map(0xeb0d00, 0xeb0d03).rw(m_lockout, FUNC(umc6650_device::read), FUNC(umc6650_device::write)).umask16(0x00ff);

map(0xf00000, 0xf001ff).rw(FUNC(supracan_state::video_r), FUNC(supracan_state::video_w));
map(0xf00200, 0xf003ff).ram().w("palette", FUNC(palette_device::write16)).share("palette");
Expand Down Expand Up @@ -2177,11 +2153,14 @@ void supracan_state::supracan(machine_config &config)
M68000(config, m_maincpu, XTAL(10'738'635)); /* Correct frequency unknown */
m_maincpu->set_addrmap(AS_PROGRAM, &supracan_state::supracan_mem);

M6502(config, m_soundcpu, XTAL(3'579'545)); /* TODO: Verify actual clock */
// TODO: Verify actual clock
M6502(config, m_soundcpu, XTAL(3'579'545));
m_soundcpu->set_addrmap(AS_PROGRAM, &supracan_state::supracan_sound_mem);

config.set_perfect_quantum(m_soundcpu);

UMC6650(config, m_lockout, 0);

SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_raw(XTAL(10'738'635)/2, 348, 0, 256, 256, 0, 240); /* No idea if this is correct */
m_screen->set_screen_update(FUNC(supracan_state::screen_update));
Expand Down Expand Up @@ -2215,10 +2194,6 @@ ROM_START( supracan )
// 68k internal ROM (security related)
ROM_LOAD16_WORD_SWAP( "internal_68k.bin", 0x0000, 0x1000, CRC(8d575662) SHA1(a8e75633662978d0a885f16a4ed0f898f278a10a) )

ROM_REGION(0x10, "umc6650key", ROMREGION_ERASEFF)
// 68k internal ROM (security related)
ROM_LOAD( "umc6650.bin", 0x00, 0x10, CRC(0ba78597) SHA1(f94805457976d60b91e8df18f9f49cccec77be78) )

ROM_REGION(0x2000, "internal6502", ROMREGION_ERASEFF)
// 2 additional blocks of ROM(?) can be seen next to the 68k ROM on a die shot from Furrtek
ROM_LOAD( "internal_6502_1.bin", 0x0000, 0x1000, NO_DUMP )
Expand Down
78 changes: 78 additions & 0 deletions src/mame/funtech/umc6650.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// license:BSD-3-Clause
// copyright-holders:Angelo Salese
/*************************************************************************************************
[Super A'Can] UMC 6650 lockout chip
TODO:
- signal to cart B26 & B27 (from register $09?).
- Does the effective lockout resolution input merges with $1c signal from UMC6619 host space?
- /WR for optional cart save RAM
**************************************************************************************************/

#include "emu.h"
#include "umc6650.h"

#define VERBOSE (1)
#include "logmacro.h"

DEFINE_DEVICE_TYPE(UMC6650, umc6650_device, "umc6650", "UMC 6650 lockout chip")

umc6650_device::umc6650_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, UMC6650, tag, owner, clock)
, device_memory_interface(mconfig, *this)
, m_romkey(*this, "romkey")
, m_space_io_config("io", ENDIANNESS_LITTLE, 8, 7, 0, address_map_constructor(FUNC(umc6650_device::internal_map), this))
{
}

ROM_START( umc6650 )
ROM_REGION(0x10, "romkey", ROMREGION_ERASEFF)
// 68k internal ROM (security related)
ROM_LOAD( "umc6650.bin", 0x00, 0x10, CRC(0ba78597) SHA1(f94805457976d60b91e8df18f9f49cccec77be78) )
ROM_END

const tiny_rom_entry *umc6650_device::device_rom_region() const
{
return ROM_NAME( umc6650 );
}

device_memory_interface::space_config_vector umc6650_device::memory_space_config() const
{
return space_config_vector{
std::make_pair(AS_IO, &m_space_io_config)
};
}

void umc6650_device::device_start()
{
m_space_io = &space(AS_IO);
save_item(NAME(m_address));
}

void umc6650_device::device_reset()
{
m_address = 0x7f;
}

u8 umc6650_device::read(offs_t offset)
{
return offset == 1 ? m_address : m_space_io->read_byte(m_address);
}

void umc6650_device::write(offs_t offset, u8 data)
{
if (offset == 1)
m_address = data & 0x7f;
else
m_space_io->write_byte(m_address, data);
}

void umc6650_device::internal_map(address_map &map)
{
// map(0x09, 0x09)
// map(0x0c, 0x0c)
map(0x20, 0x2f).rom().region(m_romkey, 0);
map(0x40, 0x5f).ram();
}
33 changes: 33 additions & 0 deletions src/mame/funtech/umc6650.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// license:BSD-3-Clause
// copyright-holders:Angelo Salese

#ifndef MAME_FUNTECH_UMC6650_H
#define MAME_FUNTECH_UMC6650_H

#pragma once

class umc6650_device : public device_t, public device_memory_interface
{
public:
umc6650_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

u8 read(offs_t offset);
void write(offs_t offset, u8 data);

private:
virtual void device_start() override;
virtual void device_reset() override;
virtual space_config_vector memory_space_config() const override;
virtual const tiny_rom_entry *device_rom_region() const override;

required_memory_region m_romkey;
address_space_config m_space_io_config;

void internal_map(address_map &map);
address_space *m_space_io;
u8 m_address;
};

DECLARE_DEVICE_TYPE(UMC6650, umc6650_device)

#endif // MAME_FUNTECH_UMC6650_H

0 comments on commit 1fcf4a9

Please sign in to comment.