Previous 15994 Revisions Next

r15017 Monday 23rd April, 2012 at 21:47:18 UTC by Curt Coder
[C64] IDE64 WIP. (nw)
[src/mess/machine]c64_ide64.c c64_ide64.h

src/mess/machine/c64_ide64.c
r15016r15017
1111
1212   TODO:
1313
14   - kill port
15   - DS1302
14   - flash write
1615   - FT245
1716
1817*/
r15016r15017
9897   device_t(mconfig, C64_IDE64, "C64 IDE64 cartridge", tag, owner, clock),
9998   device_c64_expansion_card_interface(mconfig, *this),
10099   m_flash_rom(*this, AT29C010A_TAG),
100   m_rtc(*this, DS1302_TAG),
101101   m_ide(*this, "ide")
102102{
103103}
r15016r15017
115115   // state saving
116116   save_item(NAME(m_bank));
117117   save_item(NAME(m_ide_data));
118   save_item(NAME(m_enable));
119   save_item(NAME(m_rtc_ce));
118120}
119121
120122
r15016r15017
127129   m_bank = 0;
128130   m_game = 1;
129131   m_exrom = 1;
132   m_enable = 1;
133   m_rtc_ce = 0;
130134
131135   m_wp = input_port_read(*this, "JP1");
132136}
r15016r15017
138142
139143UINT8 c64_ide64_cartridge_device::c64_cd_r(address_space &space, offs_t offset, int roml, int romh, int io1, int io2)
140144{
145   if (!m_enable) return 0;
146
141147   UINT8 data = 0;
142148   int rom_oe = 1, ram_oe = 1;
143149
r15016r15017
186192         {
187193            data = m_ide_data >> 8;
188194         }
195         else if (io1_offset == 0x32)
196         {
197            /*
198           
199                bit     description
200           
201                0       GAME
202                1       EXROM
203                2       A14
204                3       A15
205                4       A16
206                5       v4.x
207                6       
208                7       
209           
210            */
211
212            data = 0x20 | (m_bank << 2) | (m_exrom << 1) | m_game;
213         }
214         else if ((io1_offset == 0x5f) && m_rtc_ce)
215         {
216            m_rtc->ds1302_clk_w(0, 0);
217
218            m_rtc->ds1302_dat_w(0, BIT(data, 0));
219
220            m_rtc->ds1302_clk_w(0, 1);
221         }
189222         else if (io1_offset >= 0x60)
190223         {
191224            rom_oe = 0;
r15016r15017
213246
214247void c64_ide64_cartridge_device::c64_cd_w(address_space &space, offs_t offset, UINT8 data, int roml, int romh, int io1, int io2)
215248{
249   if (!m_enable) return;
250
216251   if (!m_game && m_exrom)
217252   {
218253      if (offset >= 0x1000 && offset < 0x8000)
r15016r15017
251286         {
252287            m_ide_data = (data << 8) | (m_ide_data & 0xff);
253288         }
254         else if (io1_offset >= 0x32 && io1_offset < 0x36)
289         else if ((io1_offset == 0x5f) && m_rtc_ce)
255290         {
256            m_bank = io1_offset - 0x32;
291            m_rtc->ds1302_clk_w(0, 0);
292
293            data = m_rtc->ds1302_read(0);
294           
295            m_rtc->ds1302_clk_w(0, 1);
257296         }
258297         else if (io1_offset >= 0x60 && io1_offset < 0x68)
259298         {
260299            m_bank = offset & 0x07;
261300         }
301         else if (io1_offset >= 0xfb)
302         {
303            /*
304           
305                bit     description
306           
307                0       disable cartridge
308                1       RTC CE
309                2       
310                3       
311                4       
312                5       
313                6       
314                7       
315           
316            */
317
318            m_enable = !BIT(data, 0);
319            m_rtc_ce = BIT(data, 1);
320
321            m_game = BIT(offset, 0);
322            m_exrom = BIT(offset, 1);
323         }
262324         else if (io1_offset >= 0xfc)
263325         {
264326            m_game = BIT(offset, 0);
src/mess/machine/c64_ide64.h
r15016r15017
5151
5252private:
5353   required_device<atmel_29c010_device> m_flash_rom;
54   required_device<ds1302_device> m_rtc;
5455   required_device<device_t> m_ide;
5556
5657   UINT8 m_bank;
5758   UINT8 m_ide_data;
5859   int m_wp;
60   int m_enable;
61   int m_rtc_ce;
5962};
6063
6164

Previous 15994 Revisions Next


© 1998-2018 The MESS Team