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
|
// license:BSD-3-Clause
// copyright-holders:Sandro Ronco
/***************************************************************************
IQ151 Disc2 cartridge emulation
***************************************************************************/
#include "emu.h"
#include "disc2.h"
#include "formats/iq151_dsk.h"
/***************************************************************************
IMPLEMENTATION
***************************************************************************/
FLOPPY_FORMATS_MEMBER( iq151_disc2_device::floppy_formats )
FLOPPY_IQ151_FORMAT
FLOPPY_FORMATS_END
static SLOT_INTERFACE_START( iq151_disc2_floppies )
SLOT_INTERFACE( "8sssd", FLOPPY_8_SSSD )
SLOT_INTERFACE_END
static MACHINE_CONFIG_START( iq151_disc2 )
MCFG_UPD765A_ADD("fdc", false, true)
MCFG_FLOPPY_DRIVE_ADD("fdc:1", iq151_disc2_floppies, "8sssd", iq151_disc2_device::floppy_formats)
MCFG_FLOPPY_DRIVE_ADD("fdc:2", iq151_disc2_floppies, "8sssd", iq151_disc2_device::floppy_formats)
MACHINE_CONFIG_END
ROM_START( iq151_disc2 )
ROM_REGION(0x0800, "disc2", 0)
ROM_LOAD( "iq151_disc2_12_5_1987_v4_0.rom", 0x0000, 0x0800, CRC(b189b170) SHA1(3e2ca80934177e7a32d0905f5a0ad14072f9dabf))
ROM_END
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
DEFINE_DEVICE_TYPE(IQ151_DISC2, iq151_disc2_device, "iq151_disc2", "IQ151 Disc2")
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// iq151_disc2_device - constructor
//-------------------------------------------------
iq151_disc2_device::iq151_disc2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, IQ151_DISC2, tag, owner, clock)
, device_iq151cart_interface(mconfig, *this)
, m_fdc(*this, "fdc"), m_rom(nullptr), m_rom_enabled(false)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void iq151_disc2_device::device_start()
{
m_rom = (uint8_t*)memregion("disc2")->base();
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void iq151_disc2_device::device_reset()
{
m_rom_enabled = false;
}
//-------------------------------------------------
// device_mconfig_additions
//-------------------------------------------------
machine_config_constructor iq151_disc2_device::device_mconfig_additions() const
{
return MACHINE_CONFIG_NAME( iq151_disc2 );
}
//-------------------------------------------------
// rom_region - device-specific ROM region
//-------------------------------------------------
const tiny_rom_entry *iq151_disc2_device::device_rom_region() const
{
return ROM_NAME( iq151_disc2 );
}
//-------------------------------------------------
// read
//-------------------------------------------------
void iq151_disc2_device::read(offs_t offset, uint8_t &data)
{
// interal ROM is mapped at 0xe000-0xe7ff
if (offset >= 0xe000 && offset < 0xe800 && m_rom_enabled)
data = m_rom[offset & 0x7ff];
}
//-------------------------------------------------
// IO read
//-------------------------------------------------
void iq151_disc2_device::io_read(offs_t offset, uint8_t &data)
{
/* This is gross */
address_space *space = nullptr;
if (offset == 0xaa)
data = m_fdc->msr_r(*space, 0, 0xff);
else if (offset == 0xab)
data = m_fdc->fifo_r(*space, 0, 0xff);
}
//-------------------------------------------------
// IO write
//-------------------------------------------------
void iq151_disc2_device::io_write(offs_t offset, uint8_t data)
{
address_space *space = nullptr;
if (offset == 0xab)
m_fdc->fifo_w(*space, 0, data, 0xff);
else if (offset == 0xac)
m_rom_enabled = (data == 0x01);
}
|