Skip to content

Commit 3ad1d0d

Browse files
committed
Support MSX Sunrise SCC Flash cart type used in Manbow 2
1 parent 7f264f4 commit 3ad1d0d

File tree

6 files changed

+147
-6
lines changed

6 files changed

+147
-6
lines changed

hash/msx2_cart.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3707,26 +3707,24 @@ LZ93A13 (32 pin) - 8KB banks
37073707
</part>
37083708
</software>
37093709

3710-
<software name="manbow2" supported="no">
3710+
<software name="manbow2">
37113711
<description>Manbow 2</description>
37123712
<year>2007</year>
37133713
<publisher>Sunrise</publisher>
3714-
<notes>Flash writing is not supported. Game play does not start.</notes>
37153714
<part name="cart" interface="msx_cart">
3716-
<feature name="slot" value="konami_scc"/>
3715+
<feature name="slot" value="sunrise_scc"/>
37173716
<dataarea name="rom" size="0x80000">
37183717
<rom name="manbow 2 - sunrise.rom" size="0x80000" crc="64d8454a" sha1="e3b9241291b5f19ab239726360258a31e02565a3"/>
37193718
</dataarea>
37203719
</part>
37213720
</software>
37223721

3723-
<software name="manbow2a" cloneof="manbow2" supported="no">
3722+
<software name="manbow2a" cloneof="manbow2">
37243723
<description>Manbow 2 (alt)</description>
37253724
<year>2007</year>
37263725
<publisher>Sunrise</publisher>
3727-
<notes>Flash writing is not supported. Game play does not start.</notes>
37283726
<part name="cart" interface="msx_cart">
3729-
<feature name="slot" value="konami_scc"/>
3727+
<feature name="slot" value="sunrise_scc"/>
37303728
<dataarea name="rom" size="0x80000">
37313729
<rom name="manbow 2 - sunrise (alt).rom" size="0x80000" crc="492b06b8" sha1="c2a2663302c845468dddfe7f4eee8823b7d4bdd6"/>
37323730
</dataarea>

src/devices/bus/msx/cart/cartridge.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ void msx_cart(device_slot_interface &device, bool is_in_subslot)
8888
device.option_add_internal(slotoptions::RTYPE, MSX_CART_RTYPE);
8989
device.option_add_internal(slotoptions::SOUND_SNATCHER, MSX_CART_SOUND_SNATCHER);
9090
device.option_add_internal(slotoptions::SOUND_SDSNATCH, MSX_CART_SOUND_SDSNATCHER);
91+
device.option_add_internal(slotoptions::SUNRISE_SCC, MSX_CART_SUNRISE_SCC);
9192
device.option_add_internal(slotoptions::SUPER_SWANGI, MSX_CART_SUPER_SWANGI);
9293
device.option_add_internal(slotoptions::SUPERLODERUNNER, MSX_CART_SUPERLODERUNNER);
9394
device.option_add_internal(slotoptions::SYNTHESIZER, MSX_CART_SYNTHESIZER);

src/devices/bus/msx/cart/konami.cpp

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "emu.h"
44
#include "konami.h"
55

6+
#include "machine/intelfsh.h"
7+
68
#include "sound/k051649.h"
79
#include "sound/vlm5030.h"
810
#include "sound/dac.h"
@@ -199,6 +201,142 @@ void msx_cart_konami_scc_device::bank_w(u8 data)
199201

200202

201203

204+
class msx_cart_sunrise_scc_device : public device_t, public msx_cart_interface
205+
{
206+
public:
207+
msx_cart_sunrise_scc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
208+
: device_t(mconfig, MSX_CART_SUNRISE_SCC, tag, owner, clock)
209+
, msx_cart_interface(mconfig, *this)
210+
, m_k051649(*this, "k051649")
211+
, m_flash(*this, "flash")
212+
, m_scc_view(*this, "scc_view")
213+
{ }
214+
215+
virtual std::error_condition initialize_cartridge(std::string &message) override;
216+
217+
protected:
218+
// device_t implementation
219+
virtual void device_start() override { save_item(NAME(m_selected_bank)); }
220+
virtual void device_reset() override;
221+
222+
virtual const tiny_rom_entry *device_rom_region() const override;
223+
virtual void device_add_mconfig(machine_config &config) override;
224+
225+
private:
226+
template <int Bank> u8 flash_r(offs_t offset);
227+
template <int Bank> void flash_w(offs_t offset, u8 data);
228+
template <int Bank> void bank_w(offs_t offset, u8 data);
229+
230+
required_device<k051649_device> m_k051649;
231+
required_device<intelfsh8_device> m_flash;
232+
memory_view m_scc_view;
233+
234+
u8 m_selected_bank[4];
235+
};
236+
237+
ROM_START(msx_cart_sunrise_scc)
238+
ROM_REGION(0x80000, "flash", ROMREGION_ERASEFF)
239+
ROM_END
240+
241+
const tiny_rom_entry *msx_cart_sunrise_scc_device::device_rom_region() const
242+
{
243+
return ROM_NAME(msx_cart_sunrise_scc);
244+
}
245+
246+
void msx_cart_sunrise_scc_device::device_add_mconfig(machine_config &config)
247+
{
248+
K051649(config, m_k051649, DERIVED_CLOCK(1, 1));
249+
if (parent_slot())
250+
m_k051649->add_route(ALL_OUTPUTS, soundin(), 0.4);
251+
252+
AMD_29F040(config, m_flash);
253+
}
254+
255+
void msx_cart_sunrise_scc_device::device_reset()
256+
{
257+
m_scc_view.select(0);
258+
for (int i = 0; i < 4; i++)
259+
m_selected_bank[i] = i;
260+
}
261+
262+
std::error_condition msx_cart_sunrise_scc_device::initialize_cartridge(std::string &message)
263+
{
264+
if (!cart_rom_region())
265+
{
266+
message = "msx_cart_sunrise_scc_device: Required region 'rom' was not found.";
267+
return image_error::INTERNAL;
268+
}
269+
270+
const u32 size = cart_rom_region()->bytes();
271+
if (size != 0x80000)
272+
{
273+
message = "msx_cart_sunrise_scc_device: Region 'rom' has unsupported size.";
274+
return image_error::INVALIDLENGTH;
275+
}
276+
277+
u8 *flash = memregion("flash")->base();
278+
memcpy(flash, cart_rom_region()->base(), size);
279+
280+
page(0)->install_read_handler(0x0000, 0x1fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<2>)));
281+
page(0)->install_write_handler(0x0000, 0x1fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_w<2>)));
282+
page(0)->install_read_handler(0x2000, 0x3fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<3>)));
283+
page(0)->install_write_handler(0x2000, 0x3fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_w<3>)));
284+
page(1)->install_read_handler(0x4000, 0x5fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<0>)));
285+
page(1)->install_write_handler(0x4000, 0x5fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::bank_w<0>)));
286+
page(1)->install_read_handler(0x6000, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<1>)));
287+
page(1)->install_write_handler(0x6000, 0x7fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::bank_w<1>)));
288+
page(2)->install_view(0x8000, 0x9fff, m_scc_view);
289+
m_scc_view[0].install_read_handler(0x8000, 0x9fff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<2>)));
290+
m_scc_view[0].install_write_handler(0x8000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::bank_w<2>)));
291+
m_scc_view[1].install_read_handler(0x8000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<2>)));
292+
m_scc_view[1].install_write_handler(0x8000, 0x97ff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::bank_w<2>)));
293+
m_scc_view[1].install_read_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_waveform_r)));
294+
m_scc_view[1].install_write_handler(0x9800, 0x987f, 0, 0x0700, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_waveform_w)));
295+
m_scc_view[1].install_write_handler(0x9880, 0x9889, 0, 0x0710, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_frequency_w)));
296+
m_scc_view[1].install_write_handler(0x988a, 0x988e, 0, 0x0710, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_volume_w)));
297+
m_scc_view[1].install_write_handler(0x988f, 0x988f, 0, 0x0710, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_keyonoff_w)));
298+
m_scc_view[1].install_read_handler(0x98e0, 0x98e0, 0, 0x071f, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_test_r)));
299+
m_scc_view[1].install_write_handler(0x98e0, 0x98e0, 0, 0x071f, 0, emu::rw_delegate(m_k051649, FUNC(k051649_device::k051649_test_w)));
300+
page(2)->install_read_handler(0xa000, 0xbfff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<3>)));
301+
page(2)->install_write_handler(0xa000, 0xbfff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::bank_w<3>)));
302+
page(3)->install_read_handler(0xc000, 0xdfff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<0>)));
303+
page(3)->install_write_handler(0xc000, 0xdfff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_w<0>)));
304+
page(3)->install_read_handler(0xe000, 0xffff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_r<1>)));
305+
page(3)->install_write_handler(0xe000, 0xffff, emu::rw_delegate(*this, FUNC(msx_cart_sunrise_scc_device::flash_w<1>)));
306+
307+
return std::error_condition();
308+
}
309+
310+
template <int Bank>
311+
u8 msx_cart_sunrise_scc_device::flash_r(offs_t offset)
312+
{
313+
return m_flash->read(m_selected_bank[Bank] * 0x2000 + offset);
314+
}
315+
316+
template <int Bank>
317+
void msx_cart_sunrise_scc_device::flash_w(offs_t offset, u8 data)
318+
{
319+
m_flash->write(m_selected_bank[Bank] * 0x2000 + offset, data);
320+
}
321+
322+
template <int Bank>
323+
void msx_cart_sunrise_scc_device::bank_w(offs_t offset, u8 data)
324+
{
325+
if ((offset & 0x1800) == 0x1000)
326+
{
327+
m_selected_bank[Bank] = data & 0x3f;
328+
if (Bank == 2)
329+
m_scc_view.select(((data & 0x3f) == 0x3f) ? 1 : 0);
330+
}
331+
else
332+
m_flash->write(m_selected_bank[Bank] * 0x2000 + offset, data);
333+
}
334+
335+
336+
337+
338+
339+
202340
class msx_cart_gamemaster2_device : public device_t, public msx_cart_interface
203341
{
204342
public:
@@ -817,6 +955,7 @@ void msx_cart_ec701_device::bank_w(u8 data)
817955

818956
DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_KONAMI, msx_cart_interface, msx_cart_konami_device, "msx_cart_konami", "MSX Cartridge - KONAMI")
819957
DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_KONAMI_SCC, msx_cart_interface, msx_cart_konami_scc_device, "msx_cart_konami_scc", "MSX Cartridge - KONAMI+SCC")
958+
DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_SUNRISE_SCC, msx_cart_interface, msx_cart_sunrise_scc_device, "msx_cart_sunrise_scc", "MSX Cartridge - Sunrise+SCC")
820959
DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_GAMEMASTER2, msx_cart_interface, msx_cart_gamemaster2_device, "msx_cart_gamemaster2", "MSX Cartridge - GAMEMASTER2")
821960
DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_SYNTHESIZER, msx_cart_interface, msx_cart_synthesizer_device, "msx_cart_synthesizer", "MSX Cartridge - Synthesizer")
822961
DEFINE_DEVICE_TYPE_PRIVATE(MSX_CART_SOUND_SNATCHER, msx_cart_interface, msx_cart_konami_sound_snatcher_device, "msx_cart_sound_snatcher", "MSX Cartridge - Sound Snatcher")

src/devices/bus/msx/cart/konami.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
DECLARE_DEVICE_TYPE(MSX_CART_KONAMI, msx_cart_interface)
1212
DECLARE_DEVICE_TYPE(MSX_CART_KONAMI_SCC, msx_cart_interface)
13+
DECLARE_DEVICE_TYPE(MSX_CART_SUNRISE_SCC, msx_cart_interface)
1314
DECLARE_DEVICE_TYPE(MSX_CART_GAMEMASTER2, msx_cart_interface)
1415
DECLARE_DEVICE_TYPE(MSX_CART_SYNTHESIZER, msx_cart_interface)
1516
DECLARE_DEVICE_TYPE(MSX_CART_SOUND_SNATCHER, msx_cart_interface)

src/devices/bus/msx/cart/slotoptions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ char const *const SLOTEXP = "slotexp";
7777
char const *const SOFTCARD = "softcard";
7878
char const *const SOUND_SNATCHER = "sound_snatcher";
7979
char const *const SOUND_SDSNATCH = "sound_sdsnatch";
80+
char const *const SUNRISE_SCC = "sunrise_scc";
8081
char const *const SUPER_SWANGI = "super_swangi";
8182
char const *const SUPERLODERUNNER = "superloderunner";
8283
char const *const SYNTHESIZER = "synthesizer";

src/devices/bus/msx/cart/slotoptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ extern char const *const SLOTEXP;
8080
extern char const *const SOFTCARD;
8181
extern char const *const SOUND_SNATCHER;
8282
extern char const *const SOUND_SDSNATCH;
83+
extern char const *const SUNRISE_SCC;
8384
extern char const *const SUPER_SWANGI;
8485
extern char const *const SUPERLODERUNNER;
8586
extern char const *const SYNTHESIZER;

0 commit comments

Comments
 (0)