Skip to content

Commit f4b1881

Browse files
committed
nec/pc9801.cpp: fix SDIP bank interface for pc9801us and pc9801fs
1 parent 519cbd9 commit f4b1881

File tree

3 files changed

+41
-25
lines changed

3 files changed

+41
-25
lines changed

src/mame/nec/pc9801.cpp

+23-19
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@
3535
- Export mouse support to an actual PC9871 device;
3636
- Implement IF-SEGA/98 support (Sega Saturn peripheral compatibility for Windows,
3737
cfr. BeOS PnP driver);
38-
- Incomplete SDIP support:
39-
- SDIP never returns a valid state and returns default values even if machine is
40-
soft resetted. By logic should read-back the already existing state, instead
41-
all machines just returns a "set SDIP" warning message at POST no matter what;
42-
- SDIP bank hookup is different across machines, either unmapped or diverging
43-
implementation wise both in port select and behaviour;
44-
- In theory SDIP can be initialized via a BIOS menu, callable by holding down
45-
HELP key at POST. This actually doesn't work for any machine, is it expected to
46-
have key repeat support? Later BIOSes actually have strings for an extended menu
47-
with 3 or 4 pages strings, may be also requiring a jump/bankswitch to unmapped area?
48-
- Expose SDIP to an actual device_nvram_interface;
49-
- Derive defaults off what the model sets up at POST;
5038
- clean-up functions/variables naming by actual documentation nomenclature;
5139
- derive machine configs & romsets by actual default options, examples:
5240
- 3.5 built-in floppy drives vs. default 5.25;
@@ -75,13 +63,10 @@
7563
it's not a 286 CPU;
7664
- Floppy boot fails;
7765
78-
TODO (PC-9801US):
66+
TODO (PC-9801US / PC-9801FS):
7967
- "Invalid Command Byte 13" for bitmap upd7220 at POST (?)
80-
- "SYSTEM SHUTDOWN" after BIOS sets up the SDIP values;
81-
82-
TODO (PC-9801FS):
8368
- RAM check detects more RAM than what's really installed (and saves previous detection in MEMSW);
84-
- Crashes with Japanese error for "HDD failure" when mounted with IDE BIOS,
69+
- pc9801fs at least: Crashes with Japanese error for "HDD failure" when mounted with IDE BIOS,
8570
incompatible with 512 bps or IDE itself?
8671
8772
TODO (PC-9801BX2)
@@ -1252,6 +1237,13 @@ void pc9801us_state::pc9801us_io(address_map &map)
12521237
{
12531238
pc9801rs_io(map);
12541239
map(0x0430, 0x0433).rw(FUNC(pc9801us_state::ide_ctrl_r), FUNC(pc9801us_state::ide_ctrl_w)).umask16(0x00ff);
1240+
map(0x00f6, 0x00f6).lw8(NAME([this] (offs_t offset, u8 data) {
1241+
// despite what undocumented mem claims US and FS actually access this for SDIP banking
1242+
if (data == 0xa0 || data == 0xe0)
1243+
m_sdip->bank_w(BIT(data, 6));
1244+
else
1245+
logerror("SDIP: I/O $00f6 unrecognized write %02x\n", data);
1246+
}));
12551247
map(0x841e, 0x841e).rw(m_sdip, FUNC(pc98_sdip_device::read<0x0>), FUNC(pc98_sdip_device::write<0x0>));
12561248
map(0x851e, 0x851e).rw(m_sdip, FUNC(pc98_sdip_device::read<0x1>), FUNC(pc98_sdip_device::write<0x1>));
12571249
map(0x861e, 0x861e).rw(m_sdip, FUNC(pc98_sdip_device::read<0x2>), FUNC(pc98_sdip_device::write<0x2>));
@@ -1264,7 +1256,7 @@ void pc9801us_state::pc9801us_io(address_map &map)
12641256
map(0x8d1e, 0x8d1e).rw(m_sdip, FUNC(pc98_sdip_device::read<0x9>), FUNC(pc98_sdip_device::write<0x9>));
12651257
map(0x8e1e, 0x8e1e).rw(m_sdip, FUNC(pc98_sdip_device::read<0xa>), FUNC(pc98_sdip_device::write<0xa>));
12661258
map(0x8f1e, 0x8f1e).rw(m_sdip, FUNC(pc98_sdip_device::read<0xb>), FUNC(pc98_sdip_device::write<0xb>));
1267-
map(0x8f1f, 0x8f1f).w(m_sdip, FUNC(pc98_sdip_device::bank_w));
1259+
// map(0x8f1f, 0x8f1f).w(m_sdip, FUNC(pc98_sdip_device::bank_w));
12681260
}
12691261

12701262
void pc9801bx_state::pc9801bx2_map(address_map &map)
@@ -1320,8 +1312,17 @@ void pc9801bx_state::gdc_31kHz_w(offs_t offset, u8 data)
13201312
void pc9801bx_state::pc9801bx2_io(address_map &map)
13211313
{
13221314
pc9801us_io(map);
1315+
// NOP legacy SDIP bank access
1316+
map(0x00f6, 0x00f6).lw8(NAME([] (offs_t offset, u8 data) {}));
13231317
map(0x0534, 0x0534).r(FUNC(pc9801bx_state::i486_cpu_mode_r));
13241318
map(0x09a8, 0x09a8).rw(FUNC(pc9801bx_state::gdc_31kHz_r), FUNC(pc9801bx_state::gdc_31kHz_w));
1319+
map(0x8f1f, 0x8f1f).lw8(NAME([this] (offs_t offset, u8 data) {
1320+
// BA2 onward and every PC-9821 uses this method for SDIP bank
1321+
if (data == 0x80 || data == 0xc0)
1322+
m_sdip->bank_w(BIT(data, 6));
1323+
else
1324+
logerror("SDIP: I/O $8f1f unrecognized write %02x\n", data);
1325+
}));
13251326
}
13261327

13271328
/*uint8_t pc9801_state::winram_r(offs_t offset)
@@ -2598,13 +2599,16 @@ void pc9801vm_state::pc9801vx(machine_config &config)
25982599
void pc9801us_state::pc9801us(machine_config &config)
25992600
{
26002601
pc9801rs(config);
2601-
I386SX(config.replace(), m_maincpu, MAIN_CLOCK_X1*8); // unknown clock
2602+
const XTAL xtal = BASE_CLOCK / 2; // ~16 MHz
2603+
I386SX(config.replace(), m_maincpu, xtal);
26022604
m_maincpu->set_addrmap(AS_PROGRAM, &pc9801us_state::pc9801rs_map);
26032605
m_maincpu->set_addrmap(AS_IO, &pc9801us_state::pc9801us_io);
26042606
m_maincpu->set_irq_acknowledge_callback("pic8259_master", FUNC(pic8259_device::inta_cb));
26052607

26062608
config_floppy_35hd(config);
26072609

2610+
pit_clock_config(config, xtal / 4);
2611+
26082612
PC98_SDIP(config, "sdip", 0);
26092613
}
26102614

src/mame/nec/pc98_sdip.cpp

+17-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,22 @@
44
55
PC-9801 S[oftware]DIP interface
66
7+
References:
8+
- https://bitchinbits.foolproofdesigns.com/pc-9821/pc-9821-cheat-sheet/
9+
710
TODO:
8-
- Discards saved settings;
11+
- Discards saved settings in PC-9821 and later;
12+
13+
===================================================================================================
14+
15+
To enter setup mode:
16+
- Target loopy check for i8251 keyboard status bit 1, pull high;
17+
- help key should pop up in keyboard data as 0x3f
18+
\- pc9821 and later just do individual scanning of the key repeat
19+
i.e. for pc9821ap2 bp f8a32,1,{esi=0x40;g}
20+
\- pc9801fs is a bit more involved given it scans from a fixed table instead.
21+
bp f88ea,1,{eax|=2;g}
22+
bp f88fc,1,{eax=3f;g}
923
1024
**************************************************************************************************/
1125

@@ -65,11 +79,9 @@ template<unsigned port> void pc98_sdip_device::write(offs_t offset, u8 data)
6579
m_sdip_ram[sdip_offset] = data;
6680
}
6781

68-
void pc98_sdip_device::bank_w(offs_t offset, u8 data)
82+
void pc98_sdip_device::bank_w(int state)
6983
{
70-
// TODO: depending on model type this is hooked up differently
71-
// (or be not hooked up at all like in 9801US case)
72-
m_bank = !!(BIT(data, 6));
84+
m_bank = !!(state);
7385
}
7486

7587
template u8 pc98_sdip_device::read<0>(offs_t offset);

src/mame/nec/pc98_sdip.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class pc98_sdip_device : public device_t,
1717

1818
template <unsigned port> u8 read(offs_t offset);
1919
template <unsigned port> void write(offs_t offset, u8 data);
20-
void bank_w(offs_t offset, u8 data);
20+
void bank_w(int state);
2121

2222
protected:
2323
virtual void device_start() override ATTR_COLD;

0 commit comments

Comments
 (0)