Skip to content

Commit 42856ef

Browse files
committed
bus/pc98_cbus/fdd_2dd.cpp: port over from base driver
1 parent 57aa5bb commit 42856ef

File tree

6 files changed

+129
-70
lines changed

6 files changed

+129
-70
lines changed

hash/pc98.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48503,10 +48503,14 @@ Eventually hangs with stuck [PC9801-26] sound note (verify, should be fixed)
4850348503
</part>
4850448504
</software>
4850548505

48506-
<software name="tforce">
48506+
<software name="tforce" supported="no">
4850748507
<description>Thunder Force</description>
4850848508
<year>1984</year>
4850948509
<publisher>テクノソフト (Techno Soft)</publisher>
48510+
<notes><![CDATA[
48511+
"Incorrect layout on track 0 head 1, expected_size=100000, current_size=124448"
48512+
May require [PC80S31] interface?
48513+
]]></notes>
4851048514
<info name="alt_title" value="サンダーフォース" />
4851148515
<part name="flop1" interface="floppy_5_25">
4851248516
<dataarea name="flop" size="351024">

src/devices/bus/pc98_cbus/fdd_2dd.cpp

Lines changed: 95 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,28 @@
44
55
FDD 2DD bridge for 1st gen HW
66
7+
TODO:
8+
- support for TMSK / TTRG (sorcer cares)
9+
710
**************************************************************************************************/
811

912
#include "emu.h"
1013
#include "fdd_2dd.h"
1114

12-
13-
//**************************************************************************
14-
// GLOBAL VARIABLES
15-
//**************************************************************************
15+
#include "formats/img_dsk.h"
16+
#include "formats/pc98_dsk.h"
17+
#include "formats/pc98fdi_dsk.h"
18+
#include "formats/fdd_dsk.h"
19+
#include "formats/dcp_dsk.h"
20+
#include "formats/dip_dsk.h"
21+
#include "formats/nfd_dsk.h"
1622

1723
DEFINE_DEVICE_TYPE(FDD_2DD_BRIDGE, fdd_2dd_bridge_device, "pc98_fdd_2dd", "NEC PC-98 2DD FDD bridge")
1824

1925
fdd_2dd_bridge_device::fdd_2dd_bridge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
2026
: device_t(mconfig, FDD_2DD_BRIDGE, tag, owner, clock)
2127
, device_pc98_cbus_slot_interface(mconfig, *this)
28+
, m_fdc(*this, "fdc")
2229
, m_bios(*this, "bios")
2330
{
2431
}
@@ -35,18 +42,50 @@ const tiny_rom_entry *fdd_2dd_bridge_device::device_rom_region() const
3542
return ROM_NAME( fdd_2dd );
3643
}
3744

45+
static void drives_2dd(device_slot_interface &device)
46+
{
47+
device.option_add("525dd", TEAC_FD_55F);
48+
}
49+
50+
static void floppy_formats(format_registration &fr)
51+
{
52+
fr.add_mfm_containers();
53+
fr.add(FLOPPY_PC98_FORMAT);
54+
fr.add(FLOPPY_PC98FDI_FORMAT);
55+
fr.add(FLOPPY_FDD_FORMAT);
56+
fr.add(FLOPPY_DCP_FORMAT);
57+
fr.add(FLOPPY_DIP_FORMAT);
58+
fr.add(FLOPPY_NFD_FORMAT);
59+
// *nix/FreeBSD may distribute with this
60+
fr.add(FLOPPY_IMG_FORMAT);
61+
}
62+
3863
void fdd_2dd_bridge_device::device_add_mconfig(machine_config &config)
3964
{
40-
// TODO: move from base driver
65+
UPD765A(config, m_fdc, 8'000'000, false, true);
66+
m_fdc->intrq_wr_callback().set([this] (int state) {
67+
//if (BIT(m_ctrl, 2))
68+
m_bus->int_w(7, state);
69+
});
70+
m_fdc->drq_wr_callback().set([this] (int state) { m_bus->drq_w(3, state); });
71+
FLOPPY_CONNECTOR(config, "fdc:0", drives_2dd, "525dd", floppy_formats);
72+
FLOPPY_CONNECTOR(config, "fdc:1", drives_2dd, "525dd", floppy_formats);
4173
}
4274

4375

4476
void fdd_2dd_bridge_device::device_start()
4577
{
78+
m_bus->set_dma_channel(3, this, true);
79+
80+
m_fdc->set_rate(250000);
81+
// TODO: set_rpm?
82+
83+
save_item(NAME(m_ctrl));
4684
}
4785

4886
void fdd_2dd_bridge_device::device_reset()
4987
{
88+
m_ctrl = 0;
5089
}
5190

5291
void fdd_2dd_bridge_device::remap(int space_id, offs_t start, offs_t end)
@@ -70,6 +109,56 @@ void fdd_2dd_bridge_device::remap(int space_id, offs_t start, offs_t end)
70109

71110
void fdd_2dd_bridge_device::io_map(address_map &map)
72111
{
73-
// TODO: map me
112+
map(0x00c8, 0x00cb).m(m_fdc, FUNC(upd765a_device::map)).umask16(0x00ff);
113+
map(0x00cc, 0x00cc).rw(FUNC(fdd_2dd_bridge_device::ctrl_r), FUNC(fdd_2dd_bridge_device::ctrl_w));
114+
}
115+
116+
u8 fdd_2dd_bridge_device::dack_r(int line)
117+
{
118+
u8 res = m_fdc->dma_r();
119+
return res;
120+
}
121+
122+
void fdd_2dd_bridge_device::dack_w(int line, u8 data)
123+
{
124+
m_fdc->dma_w(data);
125+
}
126+
127+
void fdd_2dd_bridge_device::eop_w(int state)
128+
{
129+
m_fdc->tc_w(state);
74130
}
75131

132+
bool fdd_2dd_bridge_device::fdc_drive_ready_r(upd765a_device *fdc)
133+
{
134+
floppy_image_device *floppy0 = fdc->subdevice<floppy_connector>("0")->get_device();
135+
floppy_image_device *floppy1 = fdc->subdevice<floppy_connector>("1")->get_device();
136+
137+
return (!floppy0->ready_r() || !floppy1->ready_r());
138+
}
139+
140+
u8 fdd_2dd_bridge_device::ctrl_r()
141+
{
142+
u8 ret = 0;
143+
144+
// 2dd BIOS specifically tests if a disk is in any drive
145+
// (does not happen on 2HD standalone)
146+
ret |= fdc_drive_ready_r(m_fdc) << 4;
147+
148+
//popmessage("%d %d %02x", floppy0->ready_r(), floppy1->ready_r(), ret);
149+
150+
// TODO: dips et al.
151+
return ret | 0x40;
152+
}
153+
154+
void fdd_2dd_bridge_device::ctrl_w(u8 data)
155+
{
156+
logerror("%02x ctrl\n",data);
157+
m_fdc->reset_w(BIT(data, 7));
158+
159+
m_ctrl = data;
160+
m_fdc->subdevice<floppy_connector>("0")->get_device()->mon_w(data & 8 ? CLEAR_LINE : ASSERT_LINE);
161+
m_fdc->subdevice<floppy_connector>("1")->get_device()->mon_w(data & 8 ? CLEAR_LINE : ASSERT_LINE);
162+
}
163+
164+

src/devices/bus/pc98_cbus/fdd_2dd.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
#include "slot.h"
1010

11+
#include "imagedev/floppy.h"
12+
#include "machine/upd765.h"
13+
1114
//**************************************************************************
1215
// TYPE DEFINITIONS
1316
//**************************************************************************
@@ -29,11 +32,22 @@ class fdd_2dd_bridge_device : public device_t
2932
// optional information overrides
3033
virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
3134
virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD;
35+
virtual u8 dack_r(int line) override;
36+
virtual void dack_w(int line, u8 data) override;
37+
virtual void eop_w(int state) override;
3238

3339
virtual void remap(int space_id, offs_t start, offs_t end) override;
3440
private:
35-
void io_map(address_map &map) ATTR_COLD;
41+
required_device<upd765a_device> m_fdc;
3642
required_memory_region m_bios;
43+
44+
void io_map(address_map &map) ATTR_COLD;
45+
46+
bool fdc_drive_ready_r(upd765a_device *fdc);
47+
u8 ctrl_r();
48+
void ctrl_w(u8 data);
49+
50+
u8 m_ctrl;
3751
};
3852

3953

src/devices/bus/pc98_cbus/slot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class pc98_cbus_root_device : public device_t,
120120
address_space_config m_space_mem_config;
121121
address_space_config m_space_io_config;
122122

123-
devcb_write_line::array<7> m_int_cb;
123+
devcb_write_line::array<8> m_int_cb;
124124
devcb_write_line::array<4> m_drq_cb;
125125

126126
device_pc98_cbus_slot_interface *m_dma_device[8];

src/mame/nec/pc9801.cpp

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -137,30 +137,6 @@ bool pc9801_state::fdc_drive_ready_r(upd765a_device *fdc)
137137
return (!floppy0->ready_r() || !floppy1->ready_r());
138138
}
139139

140-
uint8_t pc9801_state::fdc_2dd_ctrl_r()
141-
{
142-
u8 ret = 0;
143-
144-
// 2dd BIOS specifically tests if a disk is in any drive
145-
// (does not happen on 2HD standalone)
146-
ret |= fdc_drive_ready_r(m_fdc_2dd) << 4;
147-
148-
//popmessage("%d %d %02x", floppy0->ready_r(), floppy1->ready_r(), ret);
149-
150-
// TODO: dips et al.
151-
return ret | 0x40;
152-
}
153-
154-
void pc9801_state::fdc_2dd_ctrl_w(uint8_t data)
155-
{
156-
logerror("%02x ctrl\n",data);
157-
m_fdc_2dd->reset_w(BIT(data, 7));
158-
159-
m_fdc_2dd_ctrl = data;
160-
m_fdc_2dd->subdevice<floppy_connector>("0")->get_device()->mon_w(data & 8 ? CLEAR_LINE : ASSERT_LINE);
161-
m_fdc_2dd->subdevice<floppy_connector>("1")->get_device()->mon_w(data & 8 ? CLEAR_LINE : ASSERT_LINE);
162-
}
163-
164140
u8 pc9801vm_state::ide_ctrl_hack_r()
165141
{
166142
if (!machine().side_effects_disabled())
@@ -258,8 +234,8 @@ void pc9801_state::pc9801_io(address_map &map)
258234
map(0x0092, 0x0092).rw(m_fdc_2hd, FUNC(upd765a_device::fifo_r), FUNC(upd765a_device::fifo_w));
259235
map(0x0094, 0x0094).rw(FUNC(pc9801_state::fdc_2hd_ctrl_r), FUNC(pc9801_state::fdc_2hd_ctrl_w));
260236
map(0x00a0, 0x00af).rw(FUNC(pc9801_state::pc9801_a0_r), FUNC(pc9801_state::pc9801_a0_w)); //upd7220 bitmap ports / display registers
261-
map(0x00c8, 0x00cb).m(m_fdc_2dd, FUNC(upd765a_device::map)).umask16(0x00ff);
262-
map(0x00cc, 0x00cc).rw(FUNC(pc9801_state::fdc_2dd_ctrl_r), FUNC(pc9801_state::fdc_2dd_ctrl_w)); //upd765a 2dd / <undefined>
237+
// map(0x00c8, 0x00cb).m(m_fdc_2dd, FUNC(upd765a_device::map)).umask16(0x00ff);
238+
// map(0x00cc, 0x00cc).rw(FUNC(pc9801_state::fdc_2dd_ctrl_r), FUNC(pc9801_state::fdc_2dd_ctrl_w)); //upd765a 2dd / <undefined>
263239
}
264240

265241
/*************************************
@@ -1223,8 +1199,10 @@ void pc9801_state::tc_w(int state)
12231199
case 2:
12241200
case 3:
12251201
m_fdc_2hd->tc_w(state);
1226-
if(m_fdc_2dd)
1227-
m_fdc_2dd->tc_w(state);
1202+
if (m_dack == 3)
1203+
m_cbus_root->eop_w(3, state);
1204+
//if(m_fdc_2dd)
1205+
// m_fdc_2dd->tc_w(state);
12281206
break;
12291207
}
12301208

@@ -1629,18 +1607,6 @@ static void pc9801_floppies(device_slot_interface &device)
16291607
device.option_add("35hd", FLOPPY_35_HD);
16301608
}
16311609

1632-
void pc9801_state::fdc_2dd_irq(int state)
1633-
{
1634-
logerror("IRQ 2DD %d\n",state);
1635-
1636-
// TODO: does this mask applies to the specific timer irq trigger only?
1637-
// (bit 0 of control)
1638-
if(m_fdc_2dd_ctrl & 8)
1639-
{
1640-
m_pic2->ir2_w(state);
1641-
}
1642-
}
1643-
16441610
void pc9801vm_state::fdc_irq_w(int state)
16451611
{
16461612
if(m_fdc_mode & 1)
@@ -1688,8 +1654,7 @@ MACHINE_START_MEMBER(pc9801_state,pc9801f)
16881654
MACHINE_START_CALL_MEMBER(pc9801_common);
16891655

16901656
m_fdc_2hd->set_rate(500000);
1691-
m_fdc_2dd->set_rate(250000);
1692-
// TODO: set_rpm for m_fdc_2dd?
1657+
16931658
m_sys_type = 0x00 >> 6;
16941659
}
16951660

@@ -1903,10 +1868,12 @@ void pc9801_state::pc9801_cbus(machine_config &config)
19031868
m_cbus_root->int_cb<1>().set("pic8259_master", FUNC(pic8259_device::ir5_w));
19041869
m_cbus_root->int_cb<2>().set("pic8259_master", FUNC(pic8259_device::ir6_w));
19051870
m_cbus_root->int_cb<3>().set("pic8259_slave", FUNC(pic8259_device::ir1_w));
1906-
m_cbus_root->int_cb<4>().set("pic8259_slave", FUNC(pic8259_device::ir3_w));
1871+
m_cbus_root->int_cb<4>().set("pic8259_slave", FUNC(pic8259_device::ir3_w)); // INT42
19071872
m_cbus_root->int_cb<5>().set("pic8259_slave", FUNC(pic8259_device::ir4_w));
19081873
m_cbus_root->int_cb<6>().set("pic8259_slave", FUNC(pic8259_device::ir5_w));
1874+
m_cbus_root->int_cb<7>().set("pic8259_slave", FUNC(pic8259_device::ir2_w)); // INT41
19091875
m_cbus_root->drq_cb<0>().set(m_dmac, FUNC(am9517a_device::dreq0_w)).invert();
1876+
m_cbus_root->drq_cb<3>().set(m_dmac, FUNC(am9517a_device::dreq3_w)).invert();
19101877
}
19111878

19121879
void pc9801vm_state::cdrom_headphones(device_t *device)
@@ -1969,6 +1936,9 @@ void pc9801_state::pc9801_common(machine_config &config)
19691936

19701937
m_dmac->in_ior_callback<2>().set(m_fdc_2hd, FUNC(upd765a_device::dma_r));
19711938
m_dmac->out_iow_callback<2>().set(m_fdc_2hd, FUNC(upd765a_device::dma_w));
1939+
m_dmac->in_ior_callback<3>().set([this] () { return m_cbus_root->dack_r(3); });
1940+
m_dmac->out_iow_callback<3>().set([this] (u8 data) { m_cbus_root->dack_w(3, data); });
1941+
19721942
m_dmac->out_dack_callback<0>().set(FUNC(pc9801_state::dack0_w));
19731943
m_dmac->out_dack_callback<1>().set(FUNC(pc9801_state::dack1_w));
19741944
m_dmac->out_dack_callback<2>().set(FUNC(pc9801_state::dack2_w));
@@ -2061,17 +2031,8 @@ void pc9801_state::pc9801(machine_config &config)
20612031
MCFG_MACHINE_START_OVERRIDE(pc9801_state, pc9801f)
20622032
MCFG_MACHINE_RESET_OVERRIDE(pc9801_state, pc9801f)
20632033

2064-
UPD765A(config, m_fdc_2dd, 8'000'000, false, true);
2065-
m_fdc_2dd->intrq_wr_callback().set(FUNC(pc9801_state::fdc_2dd_irq));
2066-
m_fdc_2dd->drq_wr_callback().set(m_dmac, FUNC(am9517a_device::dreq3_w)).invert();
2067-
FLOPPY_CONNECTOR(config, "fdc_2dd:0", pc9801_floppies, "525dd", pc9801_state::floppy_formats);
2068-
FLOPPY_CONNECTOR(config, "fdc_2dd:1", pc9801_floppies, "525dd", pc9801_state::floppy_formats);
2069-
20702034
UPD1990A(config, m_rtc);
20712035

2072-
m_dmac->in_ior_callback<3>().set(m_fdc_2dd, FUNC(upd765a_device::dma_r));
2073-
m_dmac->out_iow_callback<3>().set(m_fdc_2dd, FUNC(upd765a_device::dma_w));
2074-
20752036
BEEP(config, m_beeper, 2400).add_route(ALL_OUTPUTS, "mono", 0.15);
20762037
PALETTE(config, m_palette, FUNC(pc9801_state::pc9801_palette), 16);
20772038

src/mame/nec/pc9801.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ class pc9801_state : public pc98_base_state
139139
, m_dsw2(*this, "DSW2")
140140
, m_ppi_mouse(*this, "ppi_mouse")
141141
, m_fdc_2hd(*this, "fdc_2hd")
142-
, m_fdc_2dd(*this, "fdc_2dd")
143142
, m_hgdc(*this, "hgdc%d", 1)
144143
, m_video_ram(*this, "video_ram_%d", 1)
145144
, m_cbus_root(*this, "cbus_root")
@@ -167,7 +166,6 @@ class pc9801_state : public pc98_base_state
167166
// TODO: should really be one FDC
168167
// (I/O $90-$93 is a "simplified" version)
169168
required_device<upd765a_device> m_fdc_2hd;
170-
optional_device<upd765a_device> m_fdc_2dd;
171169
required_device_array<upd7220_device, 2> m_hgdc;
172170
required_shared_ptr_array<uint16_t, 2> m_video_ram;
173171
required_device<pc98_cbus_root_device> m_cbus_root;
@@ -232,13 +230,6 @@ class pc9801_state : public pc98_base_state
232230
u8 m_fdc_2hd_ctrl = 0;
233231

234232
bool fdc_drive_ready_r(upd765a_device *fdc);
235-
private:
236-
void fdc_2dd_irq(int state);
237-
238-
uint8_t fdc_2dd_ctrl_r();
239-
void fdc_2dd_ctrl_w(uint8_t data);
240-
241-
u8 m_fdc_2dd_ctrl = 0;
242233

243234
// DMA
244235
protected:

0 commit comments

Comments
 (0)