Skip to content

Commit ed697c3

Browse files
committed
apple/apple2.cpp, apple2e.cpp, apple2gs.cpp: Don't disable reading $C0nx from debug memory view; add the appropriate check to bus devices instead
* bus/a2bus: Add support for reading from open bus
1 parent 8f75d92 commit ed697c3

19 files changed

Lines changed: 169 additions & 95 deletions

src/devices/bus/a2bus/a2applicard.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ uint8_t a2bus_applicard_device::read_c0nx(uint8_t offset)
178178
switch (offset & 0xf)
179179
{
180180
case 0:
181-
m_6502stat = false;
181+
if (!machine().side_effects_disabled())
182+
m_6502stat = false;
182183
return m_to6502;
183184

184185
case 1:
@@ -189,31 +190,37 @@ uint8_t a2bus_applicard_device::read_c0nx(uint8_t offset)
189190
{
190191
return 0x80;
191192
}
192-
return false;
193+
return 0;
193194

194195
case 3:
195196
if (m_6502stat)
196197
{
197198
return 0x80;
198199
}
199-
return false;
200+
return 0;
200201

201202
case 5:
202-
m_z80rom.select(0);
203-
m_toz80 = false;
204-
m_to6502 = false;
205-
m_z80->reset();
203+
if (!machine().side_effects_disabled())
204+
{
205+
m_z80rom.select(0);
206+
m_toz80 = false;
207+
m_to6502 = false;
208+
m_z80->reset();
209+
}
206210
break;
207211

208212
case 6: // IRQ on Z80 via CTC channel 3 (CP/M doesn't use the CTC or IRQs)
209-
fatalerror("Applicard: Z80 IRQ not supported yet\n");
213+
if (!machine().side_effects_disabled())
214+
fatalerror("Applicard: Z80 IRQ not supported yet\n");
215+
break;
210216

211217
case 7: // NMI on Z80 (direct)
212-
m_z80->pulse_input_line(INPUT_LINE_NMI, attotime::zero);
218+
if (!machine().side_effects_disabled())
219+
m_z80->pulse_input_line(INPUT_LINE_NMI, attotime::zero);
213220
break;
214221

215222
}
216-
return 0xff;
223+
return get_open_bus();
217224
}
218225

219226
void a2bus_applicard_device::write_c0nx(uint8_t offset, uint8_t data)

src/devices/bus/a2bus/a2bus.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ a2bus_device::a2bus_device(const machine_config &mconfig, device_type type, cons
168168
, m_out_nmi_cb(*this)
169169
, m_out_inh_cb(*this)
170170
, m_out_dma_cb(*this)
171+
, m_in_open_bus_cb(*this, 0xff)
171172
, m_slot_irq_mask(0), m_slot_nmi_mask(0)
172173
{
173174
}
@@ -346,3 +347,49 @@ void device_a2bus_card_interface::interface_pre_start()
346347
m_a2bus->add_a2bus_card(m_slot, this);
347348
}
348349
}
350+
351+
352+
uint8_t device_a2bus_card_interface::read_c0nx(uint8_t offset)
353+
{
354+
if (!device().machine().side_effects_disabled())
355+
device().logerror("a2bus: unhandled read at C0n%x\n", offset);
356+
return get_open_bus();
357+
}
358+
359+
void device_a2bus_card_interface::write_c0nx(uint8_t offset, uint8_t data)
360+
{
361+
device().logerror("a2bus: unhandled write %02x to C0n%x\n", data, offset);
362+
}
363+
364+
uint8_t device_a2bus_card_interface::read_cnxx(uint8_t offset)
365+
{
366+
return get_open_bus();
367+
}
368+
369+
void device_a2bus_card_interface::write_cnxx(uint8_t offset, uint8_t data)
370+
{
371+
device().logerror("a2bus: unhandled write %02x to Cn%02x\n", data, offset);
372+
}
373+
374+
uint8_t device_a2bus_card_interface::read_c800(uint16_t offset)
375+
{
376+
if (!device().machine().side_effects_disabled())
377+
device().logerror("a2bus: unhandled read at %04x\n", offset + 0xc800);
378+
return get_open_bus();
379+
}
380+
381+
void device_a2bus_card_interface::write_c800(uint16_t offset, uint8_t data)
382+
{
383+
device().logerror("a2bus: unhandled write %02x to %04x\n", data, offset + 0xc800);
384+
}
385+
386+
uint8_t device_a2bus_card_interface::read_inh_rom(uint16_t offset)
387+
{
388+
if (!device().machine().side_effects_disabled())
389+
device().logerror("a2bus: unhandled read at C0n%x\n", offset);
390+
return get_open_bus();
391+
}
392+
393+
void device_a2bus_card_interface::write_inh_rom(uint16_t offset, uint8_t data)
394+
{
395+
}

src/devices/bus/a2bus/a2bus.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class a2bus_device : public device_t
7575
auto nmi_w() { return m_out_nmi_cb.bind(); }
7676
auto inh_w() { return m_out_inh_cb.bind(); }
7777
auto dma_w() { return m_out_dma_cb.bind(); }
78+
auto open_bus_r() { return m_in_open_bus_cb.bind(); }
7879

7980
void add_a2bus_card(int slot, device_a2bus_card_interface *card);
8081
device_a2bus_card_interface *get_a2bus_card(int slot);
@@ -88,6 +89,7 @@ class a2bus_device : public device_t
8889
uint8_t dma_r(uint16_t offset);
8990
void dma_w(uint16_t offset, uint8_t data);
9091
void reset_bus();
92+
uint8_t get_open_bus() { return m_in_open_bus_cb(); }
9193

9294
void irq_w(int state);
9395
void nmi_w(int state);
@@ -106,6 +108,7 @@ class a2bus_device : public device_t
106108
devcb_write_line m_out_nmi_cb;
107109
devcb_write8 m_out_inh_cb;
108110
devcb_write_line m_out_dma_cb;
111+
devcb_read8 m_in_open_bus_cb;
109112

110113
device_a2bus_card_interface *m_device_list[8];
111114

@@ -127,15 +130,15 @@ class device_a2bus_card_interface : public device_interface
127130
// construction/destruction
128131
virtual ~device_a2bus_card_interface();
129132

130-
virtual uint8_t read_c0nx(uint8_t offset) { device().logerror("a2bus: unhandled read at C0n%x\n", offset); return 0; } // C0nX - /DEVSEL
131-
virtual void write_c0nx(uint8_t offset, uint8_t data) { device().logerror("a2bus: unhandled write %02x to C0n%x\n", data, offset); }
132-
virtual uint8_t read_cnxx(uint8_t offset) { return 0; } // CnXX - /IOSEL
133-
virtual void write_cnxx(uint8_t offset, uint8_t data) { device().logerror("a2bus: unhandled write %02x to Cn%02x\n", data, offset); }
134-
virtual uint8_t read_c800(uint16_t offset) { return 0; } // C800 - /IOSTB
135-
virtual void write_c800(uint16_t offset, uint8_t data) {device().logerror("a2bus: unhandled write %02x to %04x\n", data, offset + 0xc800); }
136-
virtual bool take_c800() const { return false; } // override and return true if your card can take over the /IOSTB space
137-
virtual uint8_t read_inh_rom(uint16_t offset) { return 0; }
138-
virtual void write_inh_rom(uint16_t offset, uint8_t data) { }
133+
virtual uint8_t read_c0nx(uint8_t offset); // C0nX - /DEVSEL
134+
virtual void write_c0nx(uint8_t offset, uint8_t data);
135+
virtual uint8_t read_cnxx(uint8_t offset); // CnXX - /IOSEL
136+
virtual void write_cnxx(uint8_t offset, uint8_t data);
137+
virtual uint8_t read_c800(uint16_t offset); // C800 - /IOSTB
138+
virtual void write_c800(uint16_t offset, uint8_t data);
139+
virtual bool take_c800() const { return false; } // override and return true if your card can take over the /IOSTB space
140+
virtual uint8_t read_inh_rom(uint16_t offset);
141+
virtual void write_inh_rom(uint16_t offset, uint8_t data);
139142
virtual uint16_t inh_start() { return INH_START_INVALID; }
140143
virtual uint16_t inh_end() { return INH_END_INVALID; }
141144
virtual bool inh_check(uint16_t offset, bool bIsWrite) { return false; }
@@ -162,6 +165,7 @@ class device_a2bus_card_interface : public device_interface
162165
void recalc_slot_inh() { m_a2bus->recalc_inh(m_slot); }
163166
void raise_slot_dma() { m_a2bus->set_dma_line(ASSERT_LINE); }
164167
void lower_slot_dma() { m_a2bus->set_dma_line(CLEAR_LINE); }
168+
uint8_t get_open_bus() { return m_a2bus->get_open_bus(); }
165169

166170
device_a2bus_card_interface(const machine_config &mconfig, device_t &device);
167171

src/devices/bus/a2bus/a2cffa.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,18 @@ uint8_t a2bus_cffa2000_device::read_c0nx(uint8_t offset)
194194
return m_lastreaddata >> 8;
195195

196196
case 3:
197-
m_writeprotect = false;
197+
if (!machine().side_effects_disabled())
198+
m_writeprotect = false;
198199
break;
199200

200201
case 4:
201-
m_writeprotect = true;
202+
if (!machine().side_effects_disabled())
203+
m_writeprotect = true;
202204
break;
203205

204206
case 8:
205207
// Apple /// driver uses sta $c080,x when writing, which causes spurious reads of c088
206-
if (!m_inwritecycle)
208+
if (!m_inwritecycle && !machine().side_effects_disabled())
207209
{
208210
m_lastreaddata = m_ata->cs0_r(offset - 8);
209211
}
@@ -219,7 +221,7 @@ uint8_t a2bus_cffa2000_device::read_c0nx(uint8_t offset)
219221
return m_ata->cs0_r(offset - 8, 0xff);
220222
}
221223

222-
return 0xff;
224+
return get_open_bus();
223225
}
224226

225227

src/devices/bus/a2bus/a2mockingboard.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class a2bus_ayboard_device:
4545
virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
4646

4747
// device_a2bus_card_interface implementation
48-
virtual u8 read_c0nx(u8 offset) override { return 0xff; }
48+
virtual u8 read_c0nx(u8 offset) override { return get_open_bus(); }
4949
virtual void write_c0nx(u8 offset, u8 data) override { }
5050
virtual u8 read_cnxx(u8 offset) override;
5151
virtual void write_cnxx(u8 offset, u8 data) override;
@@ -568,9 +568,12 @@ void a2bus_phasor_device::set_clocks()
568568

569569
u8 a2bus_phasor_device::read_c0nx(u8 offset)
570570
{
571-
m_native = BIT(offset, 0);
572-
set_clocks();
573-
return 0xff;
571+
if (!machine().side_effects_disabled())
572+
{
573+
m_native = BIT(offset, 0);
574+
set_clocks();
575+
}
576+
return get_open_bus();
574577
}
575578

576579
void a2bus_phasor_device::write_c0nx(u8 offset, u8 data)

src/devices/bus/a2bus/a2parprn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ u8 a2bus_parprn_device::read_c0nx(u8 offset)
171171
write_c0nx(offset, 0xffU);
172172
}
173173

174-
return 0x00U;
174+
return get_open_bus();
175175
}
176176

177177

src/devices/bus/a2bus/a2pic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ u8 a2bus_pic_device::read_c0nx(u8 offset)
218218
return 0x97U | (m_perror_in << 5) | (m_select_in << 6) | (m_fault_in << 3);
219219

220220
case 4U:
221-
return (m_ack_latch << 7) | (m_ack_in ^ BIT(m_input_sw1->read(), 4));
221+
return (m_ack_latch << 7) | (get_open_bus() & 0x7eU) | (m_ack_in ^ BIT(m_input_sw1->read(), 4));
222222

223223
case 5U:
224224
logerror("500ns negative strobe not implemented\n");
@@ -235,7 +235,7 @@ u8 a2bus_pic_device::read_c0nx(u8 offset)
235235
break;
236236
}
237237

238-
return 0x00U;
238+
return get_open_bus();
239239
}
240240

241241
void a2bus_pic_device::write_c0nx(u8 offset, u8 data)

src/devices/bus/a2bus/a2sic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ u8 a2sic_device::read_cnxx(u8 offset)
117117
u8 a2sic_device::read_c800(u16 offset)
118118
{
119119
if (BIT(offset, 9))
120-
return 0xff; // TODO: select open bus
120+
return get_open_bus(); // TODO: deselect card
121121
else
122122
return m_p8[offset & 0x1ff];
123123
}

src/devices/bus/a2bus/a2videoterm.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ uint8_t a2bus_videx80_device::read_c0nx(uint8_t offset)
388388
return m_crtc->register_r(); // status_r?
389389
}
390390

391-
return 0xff;
391+
return get_open_bus();
392392
}
393393

394394

@@ -450,10 +450,12 @@ uint8_t a2bus_videx80_device::read_c800(uint16_t offset)
450450
// printf("Read VRAM at %x = %02x\n", offset+m_rambank, m_ram[offset + m_rambank]);
451451
return m_rom[offset];
452452
}
453-
else
453+
else if (offset < 0x600)
454454
{
455455
return m_ram[(offset & 0x1ff) + m_rambank];
456456
}
457+
else
458+
return get_open_bus();
457459
}
458460

459461
/*-------------------------------------------------

src/devices/bus/a2bus/grappler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,15 @@ u8 a2bus_grappler_device::read_c0nx(u8 offset)
291291
if (BIT(offset, 0)) // A0 - printer status
292292
{
293293
return
294-
0xf0U | // TODO: actually open bus
294+
(get_open_bus() & 0xf0U) |
295295
(busy_in() << 3) |
296296
(pe_in() << 2) |
297297
(slct_in() << 1) |
298298
m_ack_latch;
299299
}
300300
else
301301
{
302-
return 0xffU; // TODO: actually open bus
302+
return get_open_bus();
303303
}
304304
}
305305

0 commit comments

Comments
 (0)