Previous 15994 Revisions Next

r14889 Tuesday 10th April, 2012 at 00:35:27 UTC by R. Belmont
Apple II: CFFA2000 now has savable settings EEPROM, plus default settings patched to enable two drives [R. Belmont]
[src/mess/machine]a2cffa.c a2cffa.h

src/mess/machine/a2cffa.c
r14888r14889
8686}
8787
8888a2bus_cffa2_device::a2bus_cffa2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
89    a2bus_cffa2000_device(mconfig, A2BUS_CFFA2, "CFFA2000 Compact Flash (65C02 firmware, www.dreher.net)", tag, owner, clock)
89    a2bus_cffa2000_device(mconfig, A2BUS_CFFA2, "CFFA2000 Compact Flash (65C02 firmware, www.dreher.net)", tag, owner, clock),
90   device_nvram_interface(mconfig, *this)
9091{
9192   m_shortname = "a2cffa2";
9293}
9394
9495a2bus_cffa2_6502_device::a2bus_cffa2_6502_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
95    a2bus_cffa2000_device(mconfig, A2BUS_CFFA2, "CFFA2000 Compact Flash (6502 firmware, www.dreher.net)", tag, owner, clock)
96    a2bus_cffa2000_device(mconfig, A2BUS_CFFA2, "CFFA2000 Compact Flash (6502 firmware, www.dreher.net)", tag, owner, clock),
97   device_nvram_interface(mconfig, *this)
9698{
9799   m_shortname = "a2cffa02";
98100}
r14888r14889
108110
109111   astring tempstring;
110112   m_rom = device().machine().region(this->subtag(tempstring, CFFA2_ROM_REGION))->base();
113
114   // patch default setting so slave device is enabled
115   m_rom[0x801] = 4;
111116}
112117
113118void a2bus_cffa2000_device::device_reset()
114119{
120   m_writeprotect = true;
115121}
116122
117123
r14888r14889
121127
122128UINT8 a2bus_cffa2000_device::read_c0nx(address_space &space, UINT8 offset)
123129{
124   if (offset == 0)
130   switch (offset)
125131   {
126      return m_lastdata>>8;
132      case 0:
133         return m_lastdata>>8;
134
135      case 3:
136         m_writeprotect = false;
137         break;
138
139      case 4:
140         m_writeprotect = true;
141         break;
142
143      case 8:
144         m_lastdata = ide_controller_r(m_ide, 0x1f0+offset-8, 2);
145         return m_lastdata & 0xff;
146
147      case 9:
148      case 0xa:
149      case 0xb:
150      case 0xc:
151      case 0xd:
152      case 0xe:
153      case 0xf:
154         return ide_controller_r(m_ide, 0x1f0+offset-8, 1);
127155   }
128   else if (offset == 8)
129   {
130      m_lastdata = ide_controller_r(m_ide, 0x1f0+offset-8, 2);
131      return m_lastdata & 0xff;
132   }
133   else if (offset > 8)
134   {
135      return ide_controller_r(m_ide, 0x1f0+offset-8, 1);
136   }
137156
138157   return 0xff;
139158}
r14888r14889
145164
146165void a2bus_cffa2000_device::write_c0nx(address_space &space, UINT8 offset, UINT8 data)
147166{
148   if (offset == 0)
167   switch (offset)
149168   {
150      m_lastdata &= 0x00ff;
151      m_lastdata |= data<<8;
169      case 0:
170         m_lastdata &= 0x00ff;
171         m_lastdata |= data<<8;
172         break;
173
174      case 3:
175         m_writeprotect = false;
176         break;
177
178      case 4:
179         m_writeprotect = true;
180         break;
181
182      case 8:
183         m_lastdata &= 0xff00;
184         m_lastdata |= data;
185         ide_controller_w(m_ide, 0x1f0+offset-8, 2, m_lastdata);
186         break;
187
188      case 9:
189      case 0xa:
190      case 0xb:
191      case 0xc:
192      case 0xd:
193      case 0xe:
194      case 0xf:
195         ide_controller_w(m_ide, 0x1f0+offset-8, 1, data);
196         break;
152197   }
153   else if (offset == 8)
154   {
155      m_lastdata &= 0xff00;
156      m_lastdata |= data;
157      ide_controller_w(m_ide, 0x1f0+offset-8, 2, m_lastdata);
158   }
159   else if (offset > 8)
160   {
161      ide_controller_w(m_ide, 0x1f0+offset-8, 1, data);
162   }
163198}
164199
165200/*-------------------------------------------------
r14888r14889
171206    int slotimg = m_slot * 0x100;
172207
173208    // ROM contains a CnXX image for each of slots 1-7
174    return m_rom[offset+slotimg];
209    return m_eeprom[offset+slotimg];
175210}
176211
177212/*-------------------------------------------------
r14888r14889
180215
181216UINT8 a2bus_cffa2000_device::read_c800(address_space &space, UINT16 offset)
182217{
183    return m_rom[offset+0x800];
218    return m_eeprom[offset+0x800];
184219}
185220
221void a2bus_cffa2000_device::write_c800(address_space &space, UINT16 offset, UINT8 data)
222{
223   if (!m_writeprotect)
224   {
225      printf("Write %02x to EEPROM at %x\n", data, offset);
226      m_eeprom[offset + 0x800] = data;
227   }
228}
229
230// NVRAM device virtual overrides to provide saving/loading of settings changes
231void a2bus_cffa2_device::nvram_default()
232{
233   memcpy(m_eeprom, m_rom, 0x1000);
234}
235
236void a2bus_cffa2_device::nvram_read(emu_file &file)
237{
238   file.read(m_eeprom, 0x1000);
239}
240
241void a2bus_cffa2_device::nvram_write(emu_file &file)
242{
243   file.write(m_eeprom, 0x1000);
244}
245
246void a2bus_cffa2_6502_device::nvram_default()
247{
248   memcpy(m_eeprom, m_rom, 0x1000);
249}
250
251void a2bus_cffa2_6502_device::nvram_read(emu_file &file)
252{
253   file.read(m_eeprom, 0x1000);
254}
255
256void a2bus_cffa2_6502_device::nvram_write(emu_file &file)
257{
258   file.write(m_eeprom, 0x1000);
259}
260
src/mess/machine/a2cffa.h
r14888r14889
3838    virtual void write_c0nx(address_space &space, UINT8 offset, UINT8 data);
3939    virtual UINT8 read_cnxx(address_space &space, UINT8 offset);
4040    virtual UINT8 read_c800(address_space &space, UINT16 offset);
41    virtual void write_c800(address_space &space, UINT16 offset, UINT8 data);
4142
4243    required_device<device_t> m_ide;
4344
45    UINT8 *m_rom;
46    UINT8 m_eeprom[0x1000];
47
4448private:
45    UINT8 *m_rom;
4649    UINT16 m_lastdata;
50    bool m_writeprotect;
4751};
4852
49class a2bus_cffa2_device : public a2bus_cffa2000_device
53class a2bus_cffa2_device : public a2bus_cffa2000_device, public device_nvram_interface
5054{
5155public:
5256    a2bus_cffa2_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
57
58protected:
59    // device_config_nvram_interface overrides
60    virtual void nvram_default();
61    virtual void nvram_read(emu_file &file);
62    virtual void nvram_write(emu_file &file);
5363};
5464
55class a2bus_cffa2_6502_device : public a2bus_cffa2000_device
65class a2bus_cffa2_6502_device : public a2bus_cffa2000_device, public device_nvram_interface
5666{
5767public:
5868    a2bus_cffa2_6502_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
5969    virtual const rom_entry *device_rom_region() const;
70
71protected:
72    // device_config_nvram_interface overrides
73    virtual void nvram_default();
74    virtual void nvram_read(emu_file &file);
75    virtual void nvram_write(emu_file &file);
6076};
6177
6278// device type definition

Previous 15994 Revisions Next


© 1998-2018 The MESS Team