Previous 15994 Revisions Next

r15015 Monday 23rd April, 2012 at 18:45:49 UTC by Curt Coder
[C64] IDE64 WIP, flash erase works. (nw)
[src/mess/machine]c64_ide64.c c64_ide64.h

src/mess/machine/c64_ide64.c
r15014r15015
77
88**********************************************************************/
99
10/*
11
12   TODO:
13
14   - kill port
15   - DS1302
16   - FT245
17
18*/
19
1020#include "c64_ide64.h"
1121
1222
r15014r15015
1525//  MACROS/CONSTANTS
1626//**************************************************************************
1727
18#define AT29C010_TAG      "u3"
28#define AT29C010A_TAG      "u3"
1929#define DS1302_TAG         "u4"
30#define FT245R_TAG         "u21"
2031
2132
2233
r15014r15015
3243//-------------------------------------------------
3344
3445static MACHINE_CONFIG_FRAGMENT( c64_ide64 )
35   MCFG_ATMEL_29C010_ADD(AT29C010_TAG)
46   MCFG_ATMEL_29C010_ADD(AT29C010A_TAG)
3647   MCFG_DS1302_ADD(DS1302_TAG)
48   // TODO FT245R
3749   // TODO CompactFlash
3850   
3951   MCFG_IDE_CONTROLLER_ADD("ide", NULL, ide_image_devices, "hdd", "hdd")
r15014r15015
5163}
5264
5365
66//-------------------------------------------------
67//  INPUT_PORTS( c64_ide64 )
68//-------------------------------------------------
5469
70static INPUT_PORTS_START( c64_ide64 )
71   PORT_START("JP1")
72   PORT_DIPNAME( 0x01, 0x01, "Flash ROM Write Protect" )
73   PORT_DIPSETTING(    0x00, "Disabled" )
74   PORT_DIPSETTING(    0x01, "Enabled" )
75INPUT_PORTS_END
76
77
78//-------------------------------------------------
79//  input_ports - device-specific input ports
80//-------------------------------------------------
81
82ioport_constructor c64_ide64_cartridge_device::device_input_ports() const
83{
84   return INPUT_PORTS_NAME( c64_ide64 );
85}
86
87
88
5589//**************************************************************************
5690//  LIVE DEVICE
5791//**************************************************************************
r15014r15015
6296
6397c64_ide64_cartridge_device::c64_ide64_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
6498   device_t(mconfig, C64_IDE64, "C64 IDE64 cartridge", tag, owner, clock),
65   device_c64_expansion_card_interface(mconfig, *this)
99   device_c64_expansion_card_interface(mconfig, *this),
100   m_flash_rom(*this, AT29C010A_TAG),
101   m_ide(*this, "ide")
66102{
67103}
68104
r15014r15015
75111{
76112   // allocate memory
77113   c64_ram_pointer(machine(), 0x8000);
114
115   // state saving
116   save_item(NAME(m_bank));
117   save_item(NAME(m_ide_data));
78118}
79119
80120
r15014r15015
84124
85125void c64_ide64_cartridge_device::device_reset()
86126{
127   m_bank = 0;
128   m_game = 1;
129   m_exrom = 1;
130
131   m_wp = input_port_read(*this, "JP1");
87132}
88133
89134
r15014r15015
94139UINT8 c64_ide64_cartridge_device::c64_cd_r(address_space &space, offs_t offset, int roml, int romh, int io1, int io2)
95140{
96141   UINT8 data = 0;
142   int rom_oe = 1, ram_oe = 1;
97143
98   // TODO
144   if (!m_game && m_exrom)
145   {
146      if (offset >= 0x1000 && offset < 0x8000)
147      {
148         ram_oe = 0;
149      }
150      else if (offset >= 0xa000 && offset < 0xc000)
151      {
152         rom_oe = 0;
153      }
154      else if (offset >= 0xc000 && offset < 0xd000)
155      {
156         ram_oe = 0;
157      }
158      else if (!romh)
159      {
160         rom_oe = 0;
161      }
162   }
163   else
164   {
165      if (!roml || !romh)
166      {
167         rom_oe = 0;
168      }
169      else if (!io1)
170      {
171         // 0x20-0x2f   IDE
172         // 0x30-0x37   I/O
173         // 0x5d-0x5e   FT245
174         // 0x5f-0x5f   DS1302
175         // 0x60-0xff   ROM
99176
177         UINT8 io1_offset = offset & 0xff;
178
179         if (io1_offset >= 0x20 && io1_offset < 0x30)
180         {
181            m_ide_data = ide_bus_r(m_ide, BIT(offset, 3), offset & 0x07);
182
183            data = m_ide_data & 0xff;
184         }
185         else if (io1_offset == 0x31)
186         {
187            data = m_ide_data >> 8;
188         }
189         else if (io1_offset >= 0x60)
190         {
191            rom_oe = 0;
192         }
193      }
194   }
195
196   if (!rom_oe)
197   {
198      offs_t addr = (m_bank << 14) | (offset & 0x3fff);
199      data = m_flash_rom->read(addr);
200   }
201   else if (!ram_oe)
202   {
203      data = m_ram[offset & 0x7fff];
204   }
205
100206   return data;
101207}
102208
r15014r15015
107213
108214void c64_ide64_cartridge_device::c64_cd_w(address_space &space, offs_t offset, UINT8 data, int roml, int romh, int io1, int io2)
109215{
110   // TODO
216   if (!m_game && m_exrom)
217   {
218      if (offset >= 0x1000 && offset < 0x8000)
219      {
220         m_ram[offset & 0x7fff] = data;
221      }
222      else if (offset >= 0xc000 && offset < 0xd000)
223      {
224         m_ram[offset & 0x7fff] = data;
225      }
226   }
227   else
228   {
229      if ((offset >= 0x8000 && offset < 0xc000) && !m_wp)
230      {
231         offs_t addr = (m_bank << 14) | (offset & 0x3fff);
232         m_flash_rom->write(addr, data);
233      }
234      else if (!io1)
235      {
236         // 0x20-0x2f   IDE
237         // 0x30-0x37   I/O
238         // 0x5d-0x5e   FT245
239         // 0x5f-0x5f   DS1302
240         // 0x60-0xff   ROM
241
242         UINT8 io1_offset = offset & 0xff;
243
244         if (io1_offset >= 0x20 && io1_offset < 0x30)
245         {
246            m_ide_data = (m_ide_data & 0xff00) | data;
247
248            ide_bus_w(m_ide, BIT(offset, 3), offset & 0x07, m_ide_data);
249         }
250         else if (io1_offset == 0x31)
251         {
252            m_ide_data = (data << 8) | (m_ide_data & 0xff);
253         }
254         else if (io1_offset >= 0x32 && io1_offset < 0x36)
255         {
256            m_bank = io1_offset - 0x32;
257         }
258         else if (io1_offset >= 0x60 && io1_offset < 0x68)
259         {
260            m_bank = offset & 0x07;
261         }
262         else if (io1_offset >= 0xfc)
263         {
264            m_game = BIT(offset, 0);
265            m_exrom = BIT(offset, 1);
266         }
267      }
268   }
111269}
src/mess/machine/c64_ide64.h
r15014r15015
3737
3838   // optional information overrides
3939   virtual machine_config_constructor device_mconfig_additions() const;
40   virtual ioport_constructor device_input_ports() const;
4041
4142protected:
4243   // device-level overrides
r15014r15015
4748   // device_c64_expansion_card_interface overrides
4849   virtual UINT8 c64_cd_r(address_space &space, offs_t offset, int roml, int romh, int io1, int io2);
4950   virtual void c64_cd_w(address_space &space, offs_t offset, UINT8 data, int roml, int romh, int io1, int io2);
51
52private:
53   required_device<atmel_29c010_device> m_flash_rom;
54   required_device<device_t> m_ide;
55
56   UINT8 m_bank;
57   UINT8 m_ide_data;
58   int m_wp;
5059};
5160
5261

Previous 15994 Revisions Next


© 1998-2018 The MESS Team