1 // license:BSD-3-Clause
2 // copyright-holders:AJR
3 /***************************************************************************
4 
5     Atari 810 Disk Drive
6 
7     The 810 is the original 5¼" floppy disk interface for the Atari 400/800
8     computer, supporting only a 709-sector single density format.
9 
10     The built-in drive mechanism uses a four-phase stepper motor which is
11     controlled by outputs to a PIA port rather than by the WD1771-01 FDC.
12     The PIA also generates a synthetic index pulse for the FDC. (The format
13     defines the undersized 19th sector of each track as the index area.)
14 
15 ***************************************************************************/
16 
17 #include "emu.h"
18 #include "atari810.h"
19 
20 #include "cpu/m6502/m6507.h"
21 
22 
23 // device type definition
24 DEFINE_DEVICE_TYPE(ATARI810, atari810_device, "atari810", "Atari 810 Disk Drive")
25 
atari810_device(const machine_config & mconfig,const char * tag,device_t * owner,u32 clock)26 atari810_device::atari810_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
27 	: device_t(mconfig, ATARI810, tag, owner, clock)
28 	, device_a8sio_card_interface(mconfig, *this)
29 	, m_pia(*this, "pia")
30 	, m_fdc(*this, "fdc")
31 {
32 }
33 
device_start()34 void atari810_device::device_start()
35 {
36 }
37 
step_w(u8 data)38 void atari810_device::step_w(u8 data)
39 {
40 	m_a8sio->data_in_w(BIT(data, 0));
41 }
42 
mem_map(address_map & map)43 void atari810_device::mem_map(address_map &map)
44 {
45 	map(0x0000, 0x0003).mirror(0x167c).rw(m_fdc, FUNC(fd1771_device::read), FUNC(fd1771_device::write));
46 	map(0x0080, 0x00ff).mirror(0x1400).ram(); // MCM6810
47 	map(0x0100, 0x017f).mirror(0x1480).m(m_pia, FUNC(mos6532_new_device::ram_map));
48 	map(0x0300, 0x031f).mirror(0x14e0).m(m_pia, FUNC(mos6532_new_device::io_map));
49 	map(0x0800, 0x0fff).mirror(0x1000).rom().region("rom", 0);
50 }
51 
52 
WRITE_LINE_MEMBER(atari810_device::data_out_w)53 WRITE_LINE_MEMBER(atari810_device::data_out_w)
54 {
55 	m_pia->pb7_w(state);
56 }
57 
WRITE_LINE_MEMBER(atari810_device::command_w)58 WRITE_LINE_MEMBER(atari810_device::command_w)
59 {
60 	m_pia->pb6_w(state);
61 }
62 
WRITE_LINE_MEMBER(atari810_device::ready_w)63 WRITE_LINE_MEMBER(atari810_device::ready_w)
64 {
65 	m_pia->pb1_w(state);
66 }
67 
68 
69 static INPUT_PORTS_START(atari810)
70 	PORT_START("SELECT") // values not verified
71 	PORT_DIPNAME(0x05, 0x00, "Drive Code") PORT_DIPLOCATION("S101:1,2")
72 	PORT_DIPSETTING(0x00, "No. 1")
73 	PORT_DIPSETTING(0x01, "No. 2")
74 	PORT_DIPSETTING(0x04, "No. 3")
75 	PORT_DIPSETTING(0x05, "No. 4")
76 	PORT_BIT(0xfa, IP_ACTIVE_LOW, IPT_UNUSED)
77 INPUT_PORTS_END
78 
device_input_ports() const79 ioport_constructor atari810_device::device_input_ports() const
80 {
81 	return INPUT_PORTS_NAME(atari810);
82 }
83 
device_add_mconfig(machine_config & config)84 void atari810_device::device_add_mconfig(machine_config &config)
85 {
86 	m6507_device &fdcpu(M6507(config, "fdcpu", 1_MHz_XTAL / 2));
87 	fdcpu.set_addrmap(AS_PROGRAM, &atari810_device::mem_map);
88 
89 	MOS6532_NEW(config, m_pia, 1_MHz_XTAL / 2);
90 	m_pia->pa_rd_callback().set_ioport("SELECT");
91 	m_pia->pb_wr_callback().set(FUNC(atari810_device::step_w));
92 	//m_pia->irq_wr_callback().set(m_fdc, FUNC(fd1771_device::ip_w));
93 
94 	FD1771(config, m_fdc, 1_MHz_XTAL);
95 	m_fdc->drq_wr_callback().set(m_pia, FUNC(mos6532_new_device::pa7_w));
96 	m_fdc->intrq_wr_callback().set(m_pia, FUNC(mos6532_new_device::pa6_w));
97 }
98 
99 
100 ROM_START(atari810)
101 	ROM_REGION(0x0800, "rom", 0)
102 	ROM_SYSTEM_BIOS(0, "c", "Rev. C (9:1 skew)")
103 	ROMX_LOAD("8229_c68168_c011299c-03.bin", 0x0000, 0x0800, CRC(0896f03d) SHA1(b676b2a46ac3903a6729b92650c5faf0111ba8b6), ROM_BIOS(0))
104 	ROM_SYSTEM_BIOS(1, "b", "Rev. B (12:1 skew)")
105 	ROMX_LOAD("810rom_b.bin", 0x0000, 0x0800, CRC(19227d33) SHA1(075b1948a5736599d5501f0125c745b1b9fcced4), ROM_BIOS(1))
106 ROM_END
107 
device_rom_region() const108 const tiny_rom_entry *atari810_device::device_rom_region() const
109 {
110 	return ROM_NAME(atari810);
111 }
112