1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
// license:BSD-3-Clause
// copyright-holders:Fabio Priuli
/***********************************************************************************************************
Bandai Sufami Turbo cartridge emulation (for SNES/SFC)
This is basically a standard LoROM cart with two slots for ST minicarts
The content of each slot (with ROM and RAM) is mapped to a separate memory range
Slot 1: ROM [20-3f][8000-ffff], RAM [60-63][8000-ffff]
Slot 2: ROM [40-5f][8000-ffff], RAM [70-73][8000-ffff]
***********************************************************************************************************/
#include "emu.h"
#include "sufami.h"
//-------------------------------------------------
// sns_rom_sufami_device - constructor
//-------------------------------------------------
DEFINE_DEVICE_TYPE(SNS_LOROM_SUFAMI, sns_rom_sufami_device, "sns_rom_sufami", "SNES Sufami Turbo Cart")
DEFINE_DEVICE_TYPE(SNS_STROM, sns_rom_strom_device, "sns_strom", "SNES Sufami Turbo Minicart")
sns_rom_sufami_device::sns_rom_sufami_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: sns_rom_device(mconfig, SNS_LOROM_SUFAMI, tag, owner, clock)
, m_slot1(*this, "st_slot1")
, m_slot2(*this, "st_slot2")
{
}
sns_rom_strom_device::sns_rom_strom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: sns_rom_device(mconfig, SNS_STROM, tag, owner, clock)
{
}
void sns_rom_sufami_device::device_start()
{
}
void sns_rom_strom_device::device_start()
{
}
static void sufamiturbo_cart(device_slot_interface &device)
{
device.option_add_internal("strom", SNS_STROM);
}
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void sns_rom_sufami_device::device_add_mconfig(machine_config &config)
{
SNS_SUFAMI_CART_SLOT(config, m_slot1, sufamiturbo_cart, nullptr);
SNS_SUFAMI_CART_SLOT(config, m_slot2, sufamiturbo_cart, nullptr);
}
/*-------------------------------------------------
mapper specific handlers
-------------------------------------------------*/
uint8_t sns_rom_sufami_device::read_l(offs_t offset)
{
return read_h(offset);
}
uint8_t sns_rom_sufami_device::read_h(offs_t offset)
{
int bank;
if (offset < 0x200000) // SUFAMI TURBO ROM
{
bank = offset / 0x10000;
return m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
}
if (offset >= 0x200000 && offset < 0x400000) // SLOT1 STROM
{
return m_slot1->read_l(offset - 0x200000);
}
if (offset >= 0x400000 && offset < 0x600000) // SLOT2 STROM
{
return m_slot2->read_l(offset - 0x400000);
}
if (offset >= 0x600000 && offset < 0x640000) // SLOT1 RAM
{
if ((offset & 0xffff) >= 0x8000)
{
offset -= 0x600000;
bank = offset / 0x10000;
return m_slot1->read_ram(bank * 0x8000 + (offset & 0x7fff));
}
}
if (offset >= 0x700000 && offset < 0x740000) // SLOT2 RAM
{
if ((offset & 0xffff) >= 0x8000)
{
offset -= 0x700000;
bank = offset / 0x10000;
return m_slot2->read_ram(bank * 0x8000 + (offset & 0x7fff));
}
}
return 0xff;
}
void sns_rom_sufami_device::write_l(offs_t offset, uint8_t data)
{
write_h(offset, data);
}
void sns_rom_sufami_device::write_h(offs_t offset, uint8_t data)
{
int bank;
if (offset >= 0x600000 && offset < 0x640000) // SLOT1 RAM
{
if ((offset & 0xffff) >= 0x8000)
{
offset -= 0x600000;
bank = offset / 0x10000;
m_slot1->write_ram(bank * 0x8000 + (offset & 0x7fff), data);
}
}
if (offset >= 0x700000 && offset < 0x740000) // SLOT2 RAM
{
if ((offset & 0xffff) >= 0x8000)
{
offset -= 0x700000;
bank = offset / 0x10000;
m_slot2->write_ram(bank * 0x8000 + (offset & 0x7fff), data);
}
}
}
/*-------------------------------------------------
Sufami Turbo 'minicart' emulation
-------------------------------------------------*/
uint8_t sns_rom_strom_device::read_l(offs_t offset)
{
if (offset < 0x200000)
{
int bank = offset / 0x10000;
return m_rom[rom_bank_map[bank] * 0x8000 + (offset & 0x7fff)];
}
return 0xff;
}
|