Previous 15994 Revisions Next

r14328 Friday 3rd February, 2012 at 11:23:41 UTC by Miodrag Milanović
converted DOCG3 to modern, commented evpc and hsgpl nvram handling for now (nw)
[src/mess/drivers]gizmondo.c
[src/mess/machine]docg3.c docg3.h
[src/mess/machine/ti99]evpc.c evpc.h hsgpl.c hsgpl.h

src/mess/machine/docg3.c
r14327r14328
2424   }
2525}
2626
27/***************************************************************************
28    TYPE DEFINITIONS
29***************************************************************************/
3027
31typedef struct _diskonchip_g3_t diskonchip_g3_t;
32struct _diskonchip_g3_t
33{
34   UINT32 planes;
35   UINT32 blocks;
36   UINT32 pages;
37   UINT32 user_data_size;
38   UINT32 extra_area_size;
39   UINT8 *data[3];
40   UINT32 data_size[3];
41   UINT8 sec_2[0x800];
42   UINT32 data_1036;
43   UINT32 data_1036_count;
44   UINT32 transfer_offset;
45   UINT8 device;
46   UINT32 block;
47   UINT32 page;
48   UINT32 plane;
49   UINT32 transfersize;
50   UINT8 test;
51   UINT32 address_count;
52};
53
5428/***************************************************************************
55    PROTOTYPES
29    IMPLEMENTATION
5630***************************************************************************/
5731
58static DEVICE_NVRAM( diskonchip_g3 );
32// device type definition
33const device_type DISKONCHIP_G3 = &device_creator<diskonchip_g3_device>;
5934
60/***************************************************************************
61    INLINE FUNCTIONS
62***************************************************************************/
35//-------------------------------------------------
36//  diskonchip_g3_device - constructor
37//-------------------------------------------------
6338
64INLINE diskonchip_g3_t *get_token( device_t *device)
39diskonchip_g3_device::diskonchip_g3_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
40    : device_t(mconfig, DISKONCHIP_G3, "DiskOnChip G3", tag, owner, clock),
41     device_nvram_interface(mconfig, *this)
6542{
66   assert(device != NULL);
67   assert(device->type() == DISKONCHIP_G3);
68
69   return (diskonchip_g3_t *)downcast<legacy_device_base *>(device)->token();
7043}
7144
72INLINE const diskonchip_g3_config *get_config( device_t *device)
73{
74   assert(device != NULL);
75   assert(device->type() == DISKONCHIP_G3);
76   assert(downcast<const legacy_device_base *>(device)->inline_config() != NULL);
77   return (const diskonchip_g3_config *)downcast<const legacy_device_base *>(device)->inline_config();
78}
7945
80/***************************************************************************
81    IMPLEMENTATION
82***************************************************************************/
83
84static UINT32 diskonchip_g3_offset_data_1( device_t *device)
46UINT32 diskonchip_g3_device::g3_offset_data_1()
8547{
86   diskonchip_g3_t *doc = get_token( device);
8748//  printf( "block %d pages %d page %d planes %d plane %d user_data_size %d extra_area_size %d\n", doc->block, doc->pages, doc->page, doc->planes, doc->plane, doc->user_data_size, doc->extra_area_size);
88   return ((((doc->block * doc->pages) + doc->page) * doc->planes) + doc->plane) * (doc->user_data_size + doc->extra_area_size);
49   return ((((m_block * m_pages) + m_page) * m_planes) + m_plane) * (m_user_data_size + m_extra_area_size);
8950}
9051
91static UINT32 diskonchip_g3_offset_data_2( device_t *device)
52UINT32 diskonchip_g3_device::g3_offset_data_2()
9253{
93   diskonchip_g3_t *doc = get_token( device);
94   return ((((doc->block * doc->pages) + doc->page) * doc->planes) + doc->plane) * 16;
54   return ((((m_block * m_pages) + m_page) * m_planes) + m_plane) * 16;
9555}
9656
97static UINT32 diskonchip_g3_offset_data_3( device_t *device)
57UINT32 diskonchip_g3_device::g3_offset_data_3()
9858{
99   diskonchip_g3_t *doc = get_token( device);
100   return doc->block * 8;
59   return m_block * 8;
10160}
10261
103static UINT8 diskonchip_g3_read_data( device_t *device)
62UINT8 diskonchip_g3_device::g3_read_data()
10463{
105   diskonchip_g3_t *doc = get_token( device);
10664   UINT8 data = 0;
10765   UINT32 offset;
108   if (doc->test == 0)
66   if (m_test == 0)
10967   {
11068      // read page data (512 + 16)
111      if (doc->transfer_offset >= (doc->user_data_size + doc->extra_area_size))
69      if (m_transfer_offset >= (m_user_data_size + m_extra_area_size))
11270      {
113         doc->transfer_offset = doc->transfer_offset - (doc->user_data_size + doc->extra_area_size);
114         doc->plane++;
71         m_transfer_offset = m_transfer_offset - (m_user_data_size + m_extra_area_size);
72         m_plane++;
11573      }
116      offset = diskonchip_g3_offset_data_1( device) + doc->transfer_offset;
117      data = doc->data[0][offset];
74      offset = g3_offset_data_1() + m_transfer_offset;
75      data = m_data[0][offset];
11876   }
119   else if (doc->test == 1)
77   else if (m_test == 1)
12078   {
12179      // read ??? (0x28 bytes)
122      if (doc->transfer_offset < 0x20)
80      if (m_transfer_offset < 0x20)
12381      {
124         offset = diskonchip_g3_offset_data_1( device) + (doc->user_data_size + doc->extra_area_size) + (doc->user_data_size - 16) + doc->transfer_offset;
125         data = doc->data[0][offset];
82         offset = g3_offset_data_1() + (m_user_data_size + m_extra_area_size) + (m_user_data_size - 16) + m_transfer_offset;
83         data = m_data[0][offset];
12684      }
127      else if (doc->transfer_offset < 0x28)
85      else if (m_transfer_offset < 0x28)
12886      {
129         offset = diskonchip_g3_offset_data_3( device) + doc->transfer_offset - 0x20;
130         data = doc->data[2][offset];
87         offset = g3_offset_data_3() + m_transfer_offset - 0x20;
88         data = m_data[2][offset];
13189      }
13290      else
13391      {
13492         data = 0xFF;
13593      }
13694   }
137   else if (doc->test == 2)
95   else if (m_test == 2)
13896   {
13997      // read erase block status
14098      data = 0x00;
14199   }
142   doc->transfer_offset++;
100   m_transfer_offset++;
143101   return data;
144102}
145103
146READ16_DEVICE_HANDLER( diskonchip_g3_sec_1_r )
104READ16_MEMBER( diskonchip_g3_device::sec_1_r )
147105{
148   diskonchip_g3_t *doc = get_token( device);
149106   UINT16 data;
150   if (doc->sec_2[0x1B] & 0x40)
107   if (m_sec_2[0x1B] & 0x40)
151108   {
152      data = diskonchip_g3_read_data( device);
153      doc->sec_2[0x1B] &= ~0x40;
109      data = g3_read_data();
110      m_sec_2[0x1B] &= ~0x40;
154111   }
155112   else
156113   {
157      data = (diskonchip_g3_read_data( device) << 0) | (diskonchip_g3_read_data( device) << 8);
114      data = (g3_read_data() << 0) | (g3_read_data() << 8);
158115   }
159   verboselog( device->machine(), 9, "(DOC) %08X -> %04X\n", 0x0800 + (offset << 1), data);
116   verboselog( machine(), 9, "(DOC) %08X -> %04X\n", 0x0800 + (offset << 1), data);
160117   return data;
161118}
162119
163static void diskonchip_g3_write_data( device_t *device, UINT8 data)
120void diskonchip_g3_device::g3_write_data(UINT8 data)
164121{
165   diskonchip_g3_t *doc = get_token( device);
166122   UINT32 offset;
167   if (doc->test == 3)
123   if (m_test == 3)
168124   {
169125      // read page data (512 + 16)
170      if (doc->transfer_offset >= (doc->user_data_size + doc->extra_area_size))
126      if (m_transfer_offset >= (m_user_data_size + m_extra_area_size))
171127      {
172         doc->transfer_offset = doc->transfer_offset - (doc->user_data_size + doc->extra_area_size);
173         doc->plane++;
128         m_transfer_offset = m_transfer_offset - (m_user_data_size + m_extra_area_size);
129         m_plane++;
174130      }
175      if (doc->transfer_offset == 0)
131      if (m_transfer_offset == 0)
176132      {
177133         const UINT8 xxx[] = { 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
178         offset = diskonchip_g3_offset_data_2( device);
179         memcpy( doc->data[1] + offset, xxx, 16);
134         offset = g3_offset_data_2();
135         memcpy( m_data[1] + offset, xxx, 16);
180136      }
181      offset = diskonchip_g3_offset_data_1( device) + doc->transfer_offset;
182      doc->data[0][offset] = data;
137      offset = g3_offset_data_1() + m_transfer_offset;
138      m_data[0][offset] = data;
183139   }
184   doc->transfer_offset++;
140   m_transfer_offset++;
185141}
186142
187WRITE16_DEVICE_HANDLER( diskonchip_g3_sec_1_w )
143WRITE16_MEMBER( diskonchip_g3_device::sec_1_w )
188144{
189   diskonchip_g3_t *doc = get_token( device);
190   verboselog( device->machine(), 9, "(DOC) %08X <- %04X\n", 0x0800 + (offset << 1), data);
191   if (doc->sec_2[0x1B] & 0x40)
145   verboselog( machine(), 9, "(DOC) %08X <- %04X\n", 0x0800 + (offset << 1), data);
146   if (m_sec_2[0x1B] & 0x40)
192147   {
193      diskonchip_g3_write_data( device, data);
194      doc->sec_2[0x1B] &= ~0x40;
148      g3_write_data(data);
149      m_sec_2[0x1B] &= ~0x40;
195150   }
196151   else
197152   {
198      diskonchip_g3_write_data( device, (data >> 0) & 0xFF);
199      diskonchip_g3_write_data( device, (data >> 8) & 0xFF);
153      g3_write_data((data >> 0) & 0xFF);
154      g3_write_data((data >> 8) & 0xFF);
200155   }
201156}
202157
r14327r14328
212167// #define DoC_G3_FlashCtrl 0x1038
213168// #define DoC_G3_Nop 0x103e
214169
215static UINT16 diskonchip_sec_2_read_1000( device_t *device)
170UINT16 diskonchip_g3_device::sec_2_read_1000()
216171{
217   diskonchip_g3_t *doc = get_token( device);
218   if (doc->device == 0)
172   if (m_device == 0)
219173   {
220174      return 0x0200;
221175   }
r14327r14328
225179   }
226180}
227181
228static UINT16 diskonchip_sec_2_read_1074( device_t *device)
182UINT16 diskonchip_g3_device::sec_2_read_1074()
229183{
230   diskonchip_g3_t *doc = get_token( device);
231   if (doc->device == 0)
184   if (m_device == 0)
232185   {
233186      return 0xFDFF;
234187   }
r14327r14328
238191   }
239192}
240193
241static UINT8 diskonchip_sec_2_read_1042( device_t *device)
194UINT8 diskonchip_g3_device::sec_2_read_1042()
242195{
243   diskonchip_g3_t *doc = get_token( device);
244196   UINT8 data;
245   if ((doc->block == 0) && (doc->page == 0) && (doc->transfersize == 0x27))
197   if ((m_block == 0) && (m_page == 0) && (m_transfersize == 0x27))
246198   {
247199      data = 0x07;
248200   }
249201   else
250202   {
251      UINT32 offset = diskonchip_g3_offset_data_2( device) + 0x02;
252      data = doc->data[1][offset]; //0x07; //data & ~(1 << 7);
253      if ((doc->sec_2[0x41] & 0x10) == 0)
203      UINT32 offset = g3_offset_data_2() + 0x02;
204      data = m_data[1][offset]; //0x07; //data & ~(1 << 7);
205      if ((m_sec_2[0x41] & 0x10) == 0)
254206      {
255207         data = data & ~0x20;
256208      }
257      if ((doc->sec_2[0x41] & 0x08) == 0)
209      if ((m_sec_2[0x41] & 0x08) == 0)
258210      {
259211         data = data & ~0x80;
260212      }
261      if (doc->test != 0)
213      if (m_test != 0)
262214      {
263215         data = 0x00;
264216      }
r14327r14328
266218   return data;
267219}
268220
269static UINT8 diskonchip_sec_2_read_1046( device_t *device)
221UINT8 diskonchip_g3_device::sec_2_read_1046()
270222{
271   diskonchip_g3_t *doc = get_token( device);
272   if (doc->test == 0)
223   if (m_test == 0)
273224   {
274      UINT32 offset = diskonchip_g3_offset_data_2( device) + 0x06;
275      return doc->data[1][offset];
225      UINT32 offset = g3_offset_data_2() + 0x06;
226      return m_data[1][offset];
276227   }
277228   else
278229   {
r14327r14328
280231   }
281232}
282233
283static UINT8 diskonchip_sec_2_read_1048( device_t *device)
234UINT8 diskonchip_g3_device::sec_2_read_1048()
284235{
285   diskonchip_g3_t *doc = get_token( device);
286   if (doc->test == 0)
236   if (m_test == 0)
287237   {
288      UINT32 offset = diskonchip_g3_offset_data_2( device) + 0x08;
289      return doc->data[1][offset];
238      UINT32 offset = g3_offset_data_2() + 0x08;
239      return m_data[1][offset];
290240   }
291241   else
292242   {
r14327r14328
294244   }
295245}
296246
297static UINT8 diskonchip_sec_2_read_1049( device_t *device)
247UINT8 diskonchip_g3_device::sec_2_read_1049()
298248{
299   diskonchip_g3_t *doc = get_token( device);
300   if (doc->test == 0)
249   if (m_test == 0)
301250   {
302      UINT32 offset = diskonchip_g3_offset_data_2( device) + 0x09;
303      return doc->data[1][offset];
251      UINT32 offset = g3_offset_data_2() + 0x09;
252      return m_data[1][offset];
304253   }
305254   else
306255   {
r14327r14328
308257   }
309258}
310259
311static UINT8 diskonchip_sec_2_read_104A( device_t *device)
260UINT8 diskonchip_g3_device::sec_2_read_104A()
312261{
313   diskonchip_g3_t *doc = get_token( device);
314   if (doc->test == 0)
262   if (m_test == 0)
315263   {
316      UINT32 offset = diskonchip_g3_offset_data_2( device) + 0x0A;
317      return doc->data[1][offset];
264      UINT32 offset = g3_offset_data_2() + 0x0A;
265      return m_data[1][offset];
318266   }
319267   else
320268   {
r14327r14328
322270   }
323271}
324272
325static UINT8 diskonchip_sec_2_read_104B( device_t *device)
273UINT8 diskonchip_g3_device::sec_2_read_104B()
326274{
327   diskonchip_g3_t *doc = get_token( device);
328   if (doc->test == 0)
275   if (m_test == 0)
329276   {
330      UINT32 offset = diskonchip_g3_offset_data_2( device) + 0x0B;
331      return doc->data[1][offset];
277      UINT32 offset = g3_offset_data_2() + 0x0B;
278      return m_data[1][offset];
332279   }
333280   else
334281   {
r14327r14328
336283   }
337284}
338285
339static UINT8 diskonchip_sec_2_read_104C( device_t *device)
286UINT8 diskonchip_g3_device::sec_2_read_104C()
340287{
341   diskonchip_g3_t *doc = get_token( device);
342   if (doc->test == 0)
288   if (m_test == 0)
343289   {
344      UINT32 offset = diskonchip_g3_offset_data_2( device) + 0x0C;
345      return doc->data[1][offset];
290      UINT32 offset = g3_offset_data_2() + 0x0C;
291      return m_data[1][offset];
346292   }
347293   else
348294   {
r14327r14328
350296   }
351297}
352298
353static UINT8 diskonchip_sec_2_read_104D( device_t *device)
299UINT8 diskonchip_g3_device::sec_2_read_104D()
354300{
355   diskonchip_g3_t *doc = get_token( device);
356   if (doc->test == 0)
301   if (m_test == 0)
357302   {
358      UINT32 offset = diskonchip_g3_offset_data_2( device) + 0x0D;
359      return doc->data[1][offset];
303      UINT32 offset = g3_offset_data_2() + 0x0D;
304      return m_data[1][offset];
360305   }
361306   else
362307   {
r14327r14328
364309   }
365310}
366311
367static UINT8 diskonchip_sec_2_read_104E( device_t *device)
312UINT8 diskonchip_g3_device::sec_2_read_104E()
368313{
369   diskonchip_g3_t *doc = get_token( device);
370   if (doc->test == 0)
314   if (m_test == 0)
371315   {
372      UINT32 offset = diskonchip_g3_offset_data_2( device) + 0x0E;
373      return doc->data[1][offset];
316      UINT32 offset = g3_offset_data_2() + 0x0E;
317      return m_data[1][offset];
374318   }
375319   else
376320   {
r14327r14328
378322   }
379323}
380324
381static UINT8 diskonchip_sec_2_read_104F( device_t *device)
325UINT8 diskonchip_g3_device::sec_2_read_104F()
382326{
383   diskonchip_g3_t *doc = get_token( device);
384   if (doc->test == 0)
327   if (m_test == 0)
385328   {
386      UINT32 offset = diskonchip_g3_offset_data_2( device) + 0x0F;
387      return doc->data[1][offset];
329      UINT32 offset = g3_offset_data_2() + 0x0F;
330      return m_data[1][offset];
388331   }
389332   else
390333   {
r14327r14328
392335   }
393336}
394337
395static UINT8 diskonchip_sec_2_read_100E( device_t *device)
338UINT8 diskonchip_g3_device::sec_2_read_100E()
396339{
397340   return 0x81;
398341}
399342
400static UINT8 diskonchip_sec_2_read_1014( device_t *device)
343UINT8 diskonchip_g3_device::sec_2_read_1014()
401344{
402345   return 0x01;
403346}
404347
405static UINT8 diskonchip_sec_2_read_1022( device_t *device)
348UINT8 diskonchip_g3_device::sec_2_read_1022()
406349{
407350   return 0x85;
408351}
409352
410static UINT8 diskonchip_sec_2_read_1038( device_t *device)
353UINT8 diskonchip_g3_device::sec_2_read_1038()
411354{
412355   // bit 0 = ?
413356   // bit 1 = ? error 0x7C
r14327r14328
417360   // bit 5 = ?
418361   // bit 6 = ?
419362   // bit 7 = ?
420   diskonchip_g3_t *doc = get_token( device);
421   if (doc->device == 0)
363   if (m_device == 0)
422364   {
423365      return 0x19;
424366   }
r14327r14328
428370   }
429371}
430372
431static UINT16 diskonchip_sec_2_read16( device_t *device, UINT32 offset)
373UINT16 diskonchip_g3_device::sec_2_read16(UINT32 offset)
432374{
433   diskonchip_g3_t *doc = get_token( device);
434   UINT16 data = (doc->sec_2[offset+0] << 0) + (doc->sec_2[offset+1] << 8);
375   UINT16 data = (m_sec_2[offset+0] << 0) + (m_sec_2[offset+1] << 8);
435376   switch (0x1000 + offset)
436377   {
437378      // ?
438      case 0x1000 : data = diskonchip_sec_2_read_1000( device); break;
379      case 0x1000 : data = sec_2_read_1000(); break;
439380      // ?
440      case 0x100E : data = diskonchip_sec_2_read_100E( device); break;
381      case 0x100E : data = sec_2_read_100E(); break;
441382      // ?
442      case 0x1014 : data = diskonchip_sec_2_read_1014( device); break;
383      case 0x1014 : data = sec_2_read_1014(); break;
443384      // ?
444      case 0x1022 : data = diskonchip_sec_2_read_1022( device); break;
385      case 0x1022 : data = sec_2_read_1022(); break;
445386      // flash control
446      case 0x1038 : data = diskonchip_sec_2_read_1038( device); break;
387      case 0x1038 : data = sec_2_read_1038(); break;
447388      // flash ?
448      case 0x1042 : data = diskonchip_sec_2_read_1042( device); break;
389      case 0x1042 : data = sec_2_read_1042(); break;
449390      // ?
450      case 0x1046 : data = diskonchip_sec_2_read_1046( device); break;
391      case 0x1046 : data = sec_2_read_1046(); break;
451392      // ?
452      case 0x1048 : data = (diskonchip_sec_2_read_1048( device) << 0) + (diskonchip_sec_2_read_1049( device) << 8); break;
453      case 0x104A : data = (diskonchip_sec_2_read_104A( device) << 0) + (diskonchip_sec_2_read_104B( device) << 8); break;
454      case 0x104C : data = (diskonchip_sec_2_read_104C( device) << 0) + (diskonchip_sec_2_read_104D( device) << 8); break;
455      case 0x104E : data = (diskonchip_sec_2_read_104E( device) << 0) + (diskonchip_sec_2_read_104F( device) << 8); break;
393      case 0x1048 : data = (sec_2_read_1048() << 0) + (sec_2_read_1049() << 8); break;
394      case 0x104A : data = (sec_2_read_104A() << 0) + (sec_2_read_104B() << 8); break;
395      case 0x104C : data = (sec_2_read_104C() << 0) + (sec_2_read_104D() << 8); break;
396      case 0x104E : data = (sec_2_read_104E() << 0) + (sec_2_read_104F() << 8); break;
456397      // ?
457      case 0x1074 : data = diskonchip_sec_2_read_1074( device); break;
398      case 0x1074 : data = sec_2_read_1074(); break;
458399   }
459   verboselog( device->machine(), 9, "(DOC) %08X -> %04X\n", 0x1000 + offset, data);
400   verboselog( machine(), 9, "(DOC) %08X -> %04X\n", 0x1000 + offset, data);
460401   return data;
461402}
462403
463static UINT8 diskonchip_sec_2_read8( device_t *device, UINT32 offset)
404UINT8 diskonchip_g3_device::sec_2_read8(UINT32 offset)
464405{
465   diskonchip_g3_t *doc = get_token( device);
466   UINT8 data = doc->sec_2[offset];
406   UINT8 data = m_sec_2[offset];
467407   switch (0x1000 + offset)
468408   {
469409      // ?
470      case 0x100E : data = diskonchip_sec_2_read_100E( device); break;
410      case 0x100E : data = sec_2_read_100E(); break;
471411      // ?
472      case 0x1014 : data = diskonchip_sec_2_read_1014( device); break;
412      case 0x1014 : data = sec_2_read_1014(); break;
473413      // ?
474      case 0x1022 : data = diskonchip_sec_2_read_1022( device); break;
414      case 0x1022 : data = sec_2_read_1022(); break;
475415      // flash control
476      case 0x1038 : data = diskonchip_sec_2_read_1038( device); break;
416      case 0x1038 : data = sec_2_read_1038(); break;
477417      // flash ?
478      case 0x1042 : data = diskonchip_sec_2_read_1042( device); break;
418      case 0x1042 : data = sec_2_read_1042(); break;
479419      // ?
480      case 0x1046 : data = diskonchip_sec_2_read_1046( device); break;
420      case 0x1046 : data = sec_2_read_1046(); break;
481421      // ?
482      case 0x1048 : data = diskonchip_sec_2_read_1048( device); break;
483      case 0x1049 : data = diskonchip_sec_2_read_1049( device); break;
484      case 0x104A : data = diskonchip_sec_2_read_104A( device); break;
485      case 0x104B : data = diskonchip_sec_2_read_104B( device); break;
486      case 0x104C : data = diskonchip_sec_2_read_104C( device); break;
487      case 0x104D : data = diskonchip_sec_2_read_104D( device); break;
488      case 0x104E : data = diskonchip_sec_2_read_104E( device); break;
489      case 0x104F : data = diskonchip_sec_2_read_104F( device); break;
422      case 0x1048 : data = sec_2_read_1048(); break;
423      case 0x1049 : data = sec_2_read_1049(); break;
424      case 0x104A : data = sec_2_read_104A(); break;
425      case 0x104B : data = sec_2_read_104B(); break;
426      case 0x104C : data = sec_2_read_104C(); break;
427      case 0x104D : data = sec_2_read_104D(); break;
428      case 0x104E : data = sec_2_read_104E(); break;
429      case 0x104F : data = sec_2_read_104F(); break;
490430   }
491   verboselog( device->machine(), 9, "(DOC) %08X -> %02X\n", 0x1000 + offset, data);
431   verboselog( machine(), 9, "(DOC) %08X -> %02X\n", 0x1000 + offset, data);
492432   return data;
493433}
494434
495static void diskonchip_sec_2_write_100C( device_t *device, UINT8 data)
435void diskonchip_g3_device::sec_2_write_100C(UINT8 data)
496436{
497   diskonchip_g3_t *doc = get_token( device);
498437   const char *mode_name[] = { "reset", "normal", "deep power down" };
499438   UINT32 mode = data & 3;
500   verboselog( device->machine(), 5, "mode %d (%s)\n", mode, mode_name[mode]);
439   verboselog( machine(), 5, "mode %d (%s)\n", mode, mode_name[mode]);
501440   if (mode == 0)
502441   {
503      doc->sec_2[0x04] = 00;
442      m_sec_2[0x04] = 00;
504443   }
505444}
506445
507static void diskonchip_sec_2_write_1032( device_t *device, UINT8 data)
446void diskonchip_g3_device::sec_2_write_1032(UINT8 data)
508447{
509   diskonchip_g3_t *doc = get_token( device);
510   verboselog( device->machine(), 5, "flash select %02X\n", data);
448   verboselog( machine(), 5, "flash select %02X\n", data);
511449   if ((data == 0x12) || (data == 0x27))
512450   {
513      doc->transfer_offset = 0;
514      doc->plane = 0;
515      doc->block = 0;
516      doc->page = 0;
451      m_transfer_offset = 0;
452      m_plane = 0;
453      m_block = 0;
454      m_page = 0;
517455   }
518456}
519457
520static void diskonchip_g3_erase_block( device_t *device)
458void diskonchip_g3_device::g3_erase_block()
521459{
522   diskonchip_g3_t *doc = get_token( device);
523460   UINT32 offset;
524461   int i, j;
525462   const UINT8 xxx[] = { 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0xCE, 0x00, 0xCF, 0x72, 0xFC, 0x1B, 0xA9, 0xC7, 0xB9, 0x00 };
526   verboselog( device->machine(), 5, "erase block %04X\n", doc->block);
527   for (i=0;i<doc->pages;i++)
463   verboselog( machine(), 5, "erase block %04X\n", m_block);
464   for (i=0;i<m_pages;i++)
528465   {
529      doc->page = i;
466      m_page = i;
530467      for (j=0;j<2;j++)
531468      {
532         doc->plane = j;
533         offset = diskonchip_g3_offset_data_1( device);
534         memset( doc->data[0] + offset, 0xFF, (doc->user_data_size + doc->extra_area_size));
535         offset = diskonchip_g3_offset_data_2( device);
536         memcpy( doc->data[1] + offset, xxx, 16);
469         m_plane = j;
470         offset = g3_offset_data_1();
471         memset( m_data[0] + offset, 0xFF, (m_user_data_size + m_extra_area_size));
472         offset = g3_offset_data_2();
473         memcpy( m_data[1] + offset, xxx, 16);
537474      }
538475   }
539476}
r14327r14328
545482// 'maincpu' (028848E4): diskonchip_sec_2_write_1034: unknown value 11/1D
546483// 'maincpu' (028848E4): diskonchip_sec_2_write_1034: unknown value 10/1D
547484
548static void diskonchip_sec_2_write_1034( device_t *device, UINT8 data)
485void diskonchip_g3_device::sec_2_write_1034(UINT8 data)
549486{
550   diskonchip_g3_t *doc = get_token( device);
551   verboselog( device->machine(), 5, "flash command %02X\n", data);
552   if ((doc->sec_2[0x32] == 0x0E) && (data == 0x00))
487   verboselog( machine(), 5, "flash command %02X\n", data);
488   if ((m_sec_2[0x32] == 0x0E) && (data == 0x00))
553489   {
554      doc->test = 0;
555      doc->address_count = 0;
490      m_test = 0;
491      m_address_count = 0;
556492   }
557   else if ((doc->sec_2[0x32] == 0x10) && (data == 0x50))
493   else if ((m_sec_2[0x32] == 0x10) && (data == 0x50))
558494   {
559      doc->test = 1;
560      doc->address_count = 0;
495      m_test = 1;
496      m_address_count = 0;
561497   }
562   else if ((doc->sec_2[0x32] == 0x03) && (data == 0x3C))
498   else if ((m_sec_2[0x32] == 0x03) && (data == 0x3C))
563499   {
564500      // do nothing
565501   }
566   else if ((doc->sec_2[0x32] == 0x00) && (data == 0xFF))
502   else if ((m_sec_2[0x32] == 0x00) && (data == 0xFF))
567503   {
568      doc->address_count = 0;
504      m_address_count = 0;
569505   }
570   else if (doc->sec_2[0x32] == 0x09)
506   else if (m_sec_2[0x32] == 0x09)
571507   {
572508      if (data == 0x22)
573509      {
r14327r14328
579515      }
580516      else
581517      {
582         verboselog( device->machine(), 0, "diskonchip_sec_2_write_1034: unknown value %02X/%02X\n", data, doc->sec_2[0x32]);
518         verboselog( machine(), 0, "diskonchip_sec_2_write_1034: unknown value %02X/%02X\n", data, m_sec_2[0x32]);
583519      }
584520   }
585   else if (doc->sec_2[0x32] == 0x12)
521   else if (m_sec_2[0x32] == 0x12)
586522   {
587523      if (data == 0x60)
588524      {
589         doc->data_1036 = 0;
590         doc->data_1036_count = 0;
591         doc->address_count++;
525         m_data_1036 = 0;
526         m_data_1036_count = 0;
527         m_address_count++;
592528      }
593529      else if (data == 0x30)
594530      {
r14327r14328
604540      }
605541      else
606542      {
607         verboselog( device->machine(), 0, "diskonchip_sec_2_write_1034: unknown value %02X/%02X\n", data, doc->sec_2[0x32]);
543         verboselog( machine(), 0, "diskonchip_sec_2_write_1034: unknown value %02X/%02X\n", data, m_sec_2[0x32]);
608544      }
609545   }
610   else if (doc->sec_2[0x32] == 0x27)
546   else if (m_sec_2[0x32] == 0x27)
611547   {
612548      if (data == 0x60)
613549      {
614         doc->data_1036 = 0;
615         doc->data_1036_count = 0;
616         doc->address_count++;
550         m_data_1036 = 0;
551         m_data_1036_count = 0;
552         m_address_count++;
617553      }
618554      else if (data == 0xD0)
619555      {
620         diskonchip_g3_erase_block( device);
556         g3_erase_block();
621557      }
622558      else
623559      {
624         verboselog( device->machine(), 0, "diskonchip_sec_2_write_1034: unknown value %02X/%02X\n", data, doc->sec_2[0x32]);
560         verboselog( machine(), 0, "diskonchip_sec_2_write_1034: unknown value %02X/%02X\n", data, m_sec_2[0x32]);
625561      }
626562   }
627   else if ((doc->sec_2[0x32] == 0x31) && (data == 0x71))
563   else if ((m_sec_2[0x32] == 0x31) && (data == 0x71))
628564   {
629565      // erase block status? (after: read one byte from 08xx, bit 0/1/2 is checked)
630      doc->test = 2;
566      m_test = 2;
631567   }
632   else if (doc->sec_2[0x32] == 0x1D)
568   else if (m_sec_2[0x32] == 0x1D)
633569   {
634570      if (data == 0x80)
635571      {
636         doc->data_1036 = 0;
637         doc->data_1036_count = 0;
638         doc->address_count++;
572         m_data_1036 = 0;
573         m_data_1036_count = 0;
574         m_address_count++;
639575      }
640576      else if (data == 0x11)
641577      {
642         doc->test = 3;
578         m_test = 3;
643579      }
644580      else
645581      {
646         verboselog( device->machine(), 0, "diskonchip_sec_2_write_1034: unknown value %02X/%02X\n", data, doc->sec_2[0x32]);
582         verboselog( machine(), 0, "diskonchip_sec_2_write_1034: unknown value %02X/%02X\n", data, m_sec_2[0x32]);
647583      }
648584   }
649585   else
650586   {
651      verboselog( device->machine(), 0, "diskonchip_sec_2_write_1034: unknown value %02X/%02X\n", data, doc->sec_2[0x32]);
587      verboselog( machine(), 0, "diskonchip_sec_2_write_1034: unknown value %02X/%02X\n", data, m_sec_2[0x32]);
652588   }
653589}
654590
655static void diskonchip_sec_2_write_1036( device_t *device, UINT8 data)
591void diskonchip_g3_device::sec_2_write_1036(UINT8 data)
656592{
657   diskonchip_g3_t *doc = get_token( device);
658   if (doc->sec_2[0x34] == 0x60)
593   if (m_sec_2[0x34] == 0x60)
659594   {
660      doc->data_1036 |= data << (8 * doc->data_1036_count++);
661      if (doc->data_1036_count == 3)
595      m_data_1036 |= data << (8 * m_data_1036_count++);
596      if (m_data_1036_count == 3)
662597      {
663598         UINT32 block, page, plane;
664         block = (doc->data_1036 >> 7);
665         if (block >= doc->blocks) fatalerror( "DOCG3: invalid block (%d)", block);
666         plane = (doc->data_1036 >> 6) & 1;
667         page = (doc->data_1036 >> 0) & 0x3F;
668         verboselog( device->machine(), 5, "flash address %d - %06X (plane %d block %04X page %04X)\n", doc->address_count, doc->data_1036, plane, block, page);
669         if (doc->address_count == 1)
599         block = (m_data_1036 >> 7);
600         if (block >= m_blocks) fatalerror( "DOCG3: invalid block (%d)", block);
601         plane = (m_data_1036 >> 6) & 1;
602         page = (m_data_1036 >> 0) & 0x3F;
603         verboselog( machine(), 5, "flash address %d - %06X (plane %d block %04X page %04X)\n", m_address_count, m_data_1036, plane, block, page);
604         if (m_address_count == 1)
670605         {
671            doc->plane = 0;
672            doc->block = block;
673            doc->page = page;
606            m_plane = 0;
607            m_block = block;
608            m_page = page;
674609         }
675610      }
676611   }
677   else if (doc->sec_2[0x34] == 0x80)
612   else if (m_sec_2[0x34] == 0x80)
678613   {
679      doc->data_1036 |= data << (8 * doc->data_1036_count++);
680      if (doc->data_1036_count == 4)
614      m_data_1036 |= data << (8 * m_data_1036_count++);
615      if (m_data_1036_count == 4)
681616      {
682617         UINT32 block, page, plane, unk;
683         block = (doc->data_1036 >> 15);
684         plane = (doc->data_1036 >> 14) & 1;
685         page = (doc->data_1036 >> 8) & 0x3F;
686         unk = (doc->data_1036 >> 0) & 0xFF;
687         verboselog( device->machine(), 5, "flash address %d - %08X (plane %d block %04X page %04X unk %02X)\n", doc->address_count, doc->data_1036, plane, block, page, unk);
688         if (doc->address_count == 1)
618         block = (m_data_1036 >> 15);
619         plane = (m_data_1036 >> 14) & 1;
620         page = (m_data_1036 >> 8) & 0x3F;
621         unk = (m_data_1036 >> 0) & 0xFF;
622         verboselog( machine(), 5, "flash address %d - %08X (plane %d block %04X page %04X unk %02X)\n", m_address_count, m_data_1036, plane, block, page, unk);
623         if (m_address_count == 1)
689624         {
690            doc->plane = 0;
691            doc->block = block;
692            doc->page = page;
693            doc->transfer_offset = 0;
625            m_plane = 0;
626            m_block = block;
627            m_page = page;
628            m_transfer_offset = 0;
694629         }
695630      }
696631   }
697   else if (doc->sec_2[0x34] == 0x05)
632   else if (m_sec_2[0x34] == 0x05)
698633   {
699      doc->transfer_offset = data << 2;
700      verboselog( device->machine(), 5, "flash transfer offset %04X\n", doc->transfer_offset);
634      m_transfer_offset = data << 2;
635      verboselog( machine(), 5, "flash transfer offset %04X\n", m_transfer_offset);
701636   }
702637}
703638
704static void diskonchip_sec_2_write_1040( device_t *device, UINT16 data)
639void diskonchip_g3_device::sec_2_write_1040(UINT16 data)
705640{
706   diskonchip_g3_t *doc = get_token( device);
707   doc->transfersize = (data & 0x3FF);
708   verboselog( device->machine(), 5, "flash transfer size %04X\n", doc->transfersize);
641   m_transfersize = (data & 0x3FF);
642   verboselog( machine(), 5, "flash transfer size %04X\n", m_transfersize);
709643}
710644
711static void diskonchip_sec_2_write_100A( device_t *device, UINT8 data)
645void diskonchip_g3_device::sec_2_write_100A(UINT8 data)
712646{
713   diskonchip_g3_t *doc = get_token( device);
714   doc->device = data & 3;
715   verboselog( device->machine(), 5, "select device %d\n", doc->device);
647   m_device = data & 3;
648   verboselog( machine(), 5, "select device %d\n", m_device);
716649}
717650
718static void diskonchip_sec_2_write16( device_t *device, UINT32 offset, UINT16 data)
651void diskonchip_g3_device::sec_2_write16(UINT32 offset, UINT16 data)
719652{
720   diskonchip_g3_t *doc = get_token( device);
721   doc->sec_2[offset+0] = (data >> 0) & 0xFF;
722   doc->sec_2[offset+1] = (data >> 8) & 0xFF;
723   verboselog( device->machine(), 9, "(DOC) %08X <- %04X\n", 0x1000 + offset, data);
653   m_sec_2[offset+0] = (data >> 0) & 0xFF;
654   m_sec_2[offset+1] = (data >> 8) & 0xFF;
655   verboselog( machine(), 9, "(DOC) %08X <- %04X\n", 0x1000 + offset, data);
724656   switch (0x1000 + offset)
725657   {
726658      // ?
727      case 0x100C : diskonchip_sec_2_write_100C( device, data); break;
659      case 0x100C : sec_2_write_100C(data); break;
728660      // Device ID Select Register
729      case 0x100A : diskonchip_sec_2_write_100A( device, data); break;
661      case 0x100A : sec_2_write_100A(data); break;
730662      // flash select
731      case 0x1032 : diskonchip_sec_2_write_1032( device, data); break;
663      case 0x1032 : sec_2_write_1032(data); break;
732664      // flash command
733      case 0x1034 : diskonchip_sec_2_write_1034( device, data); break;
665      case 0x1034 : sec_2_write_1034(data); break;
734666      // flash address
735      case 0x1036 : diskonchip_sec_2_write_1036( device, data); break;
667      case 0x1036 : sec_2_write_1036(data); break;
736668      // ?
737      case 0x1040 : diskonchip_sec_2_write_1040( device, data); break;
669      case 0x1040 : sec_2_write_1040(data); break;
738670   }
739671}
740672
741static void diskonchip_sec_2_write8( device_t *device, UINT32 offset, UINT8 data)
673void diskonchip_g3_device::sec_2_write8(UINT32 offset, UINT8 data)
742674{
743   diskonchip_g3_t *doc = get_token( device);
744   doc->sec_2[offset] = data;
745   verboselog( device->machine(), 9, "(DOC) %08X <- %02X\n", 0x1000 + offset, data);
675   m_sec_2[offset] = data;
676   verboselog( machine(), 9, "(DOC) %08X <- %02X\n", 0x1000 + offset, data);
746677   switch (0x1000 + offset)
747678   {
748679      // ?
749      case 0x100C : diskonchip_sec_2_write_100C( device, data); break;
680      case 0x100C : sec_2_write_100C(data); break;
750681      // Device ID Select Register
751      case 0x100A : diskonchip_sec_2_write_100A( device, data); break;
682      case 0x100A : sec_2_write_100A(data); break;
752683      // flash select
753      case 0x1032 : diskonchip_sec_2_write_1032( device, data); break;
684      case 0x1032 : sec_2_write_1032(data); break;
754685      // flash command
755      case 0x1034 : diskonchip_sec_2_write_1034( device, data); break;
686      case 0x1034 : sec_2_write_1034(data); break;
756687      // flash address
757      case 0x1036 : diskonchip_sec_2_write_1036( device, data); break;
688      case 0x1036 : sec_2_write_1036(data); break;
758689   }
759690}
760691
761READ16_DEVICE_HANDLER( diskonchip_g3_sec_2_r )
692READ16_MEMBER( diskonchip_g3_device::sec_2_r )
762693{
763694   if (mem_mask == 0xffff)
764695   {
765      return diskonchip_sec_2_read16( device, offset * 2);
696      return sec_2_read16(offset * 2);
766697   }
767698   else if (mem_mask == 0x00ff)
768699   {
769      return diskonchip_sec_2_read8( device, offset * 2 + 0) << 0;
700      return sec_2_read8(offset * 2 + 0) << 0;
770701   }
771702   else if (mem_mask == 0xff00)
772703   {
773      return diskonchip_sec_2_read8( device, offset * 2 + 1) << 8;
704      return sec_2_read8( offset * 2 + 1) << 8;
774705   }
775706   else
776707   {
777      verboselog( device->machine(), 0, "diskonchip_g3_sec_2_r: unknown mem_mask %08X\n", mem_mask);
708      verboselog( machine(), 0, "diskonchip_g3_sec_2_r: unknown mem_mask %08X\n", mem_mask);
778709      return 0;
779710   }
780711}
781712
782WRITE16_DEVICE_HANDLER( diskonchip_g3_sec_2_w )
713WRITE16_MEMBER( diskonchip_g3_device::sec_2_w )
783714{
784715   if (mem_mask == 0xffff)
785716   {
786      diskonchip_sec_2_write16( device, offset * 2, data);
717      sec_2_write16(offset * 2, data);
787718   }
788719   else if (mem_mask == 0x00ff)
789720   {
790      diskonchip_sec_2_write8( device, offset * 2 + 0, (data >> 0) & 0xFF);
721      sec_2_write8(offset * 2 + 0, (data >> 0) & 0xFF);
791722   }
792723   else if (mem_mask == 0xff00)
793724   {
794      diskonchip_sec_2_write8( device, offset * 2 + 1, (data >> 8) & 0xFF);
725      sec_2_write8(offset * 2 + 1, (data >> 8) & 0xFF);
795726   }
796727   else
797728   {
798      verboselog( device->machine(), 0, "diskonchip_g3_sec_2_w: unknown mem_mask %08X\n", mem_mask);
729      verboselog( machine(), 0, "diskonchip_g3_sec_2_w: unknown mem_mask %08X\n", mem_mask);
799730   }
800731}
801732
802READ16_DEVICE_HANDLER( diskonchip_g3_sec_3_r )
733READ16_MEMBER( diskonchip_g3_device::sec_3_r )
803734{
804735   UINT16 data = 0;
805   verboselog( device->machine(), 9, "(DOC) %08X -> %04X\n", 0x1800 + (offset << 1), data);
736   verboselog( machine(), 9, "(DOC) %08X -> %04X\n", 0x1800 + (offset << 1), data);
806737   return data;
807738}
808739
809WRITE16_DEVICE_HANDLER( diskonchip_g3_sec_3_w )
740WRITE16_MEMBER( diskonchip_g3_device::sec_3_w )
810741{
811   verboselog( device->machine(), 9, "(DOC) %08X <- %02X\n", 0x1800 + (offset << 1), data);
742   verboselog( machine(), 9, "(DOC) %08X <- %02X\n", 0x1800 + (offset << 1), data);
812743}
813744
814#if 0
815
816static emu_file *nvram_system_fopen( running_machine &machine, UINT32 openflags, const char *name)
745//-------------------------------------------------
746//  device_start - device-specific startup
747//-------------------------------------------------
748void diskonchip_g3_device::device_start()
817749{
818   astring fname;
819   file_error filerr;
820   emu_file *file;
821   astring_assemble_4(&fname, machine.system().name, PATH_SEPARATOR, name, ".nv");
822   filerr = mame_fopen( SEARCHPATH_NVRAM, fname.cstr(), openflags, &file);
823   return (filerr == FILERR_NONE) ? file : NULL;
824}
750   verboselog( machine(), 9, "(DOC) device start\n");
825751
826static void diskonchip_load( device_t *device, const char *name)
827{
828   emu_file *file;
829   file = nvram_system_fopen( device->machine(), OPEN_FLAG_READ, name);
830   device_nvram_diskonchip_g3( device, file, 0);
831   if (file) mame_fclose( file);
832}
833
834static void diskonchip_save( device_t *device, const char *name)
835{
836   emu_file *file;
837   file = nvram_system_fopen( device->machine(), OPEN_FLAG_CREATE | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE_PATHS, name);
838   device_nvram_diskonchip_g3( device, file, 1);
839   if (file) mame_fclose( file);
840}
841
842#endif
843
844static DEVICE_START( diskonchip_g3 )
845{
846   diskonchip_g3_t *doc = get_token( device);
847   const diskonchip_g3_config *config = get_config( device);
848
849   verboselog( device->machine(), 9, "(DOC) device start\n");
850
851   switch (config->size)
752   switch (m_size)
852753   {
853754      case 64 :
854755      {
855         doc->planes = 2;
856         doc->blocks = 1024;
857         doc->pages = 64;
858         doc->user_data_size = 512;
859         doc->extra_area_size = 16;
756         m_planes = 2;
757         m_blocks = 1024;
758         m_pages = 64;
759         m_user_data_size = 512;
760         m_extra_area_size = 16;
860761      }
861762      break;
862763   }
863764
864   doc->data_size[0] = doc->planes * doc->blocks * doc->pages * (doc->user_data_size + doc->extra_area_size);
865   doc->data_size[1] = doc->planes * doc->blocks * doc->pages * 16;
866   doc->data_size[2] = doc->blocks * 8;
765   m_data_size[0] = m_planes * m_blocks * m_pages * (m_user_data_size + m_extra_area_size);
766   m_data_size[1] = m_planes * m_blocks * m_pages * 16;
767   m_data_size[2] = m_blocks * 8;
867768
868   doc->data[0] = auto_alloc_array( device->machine(), UINT8, doc->data_size[0]);
869   doc->data[1] = auto_alloc_array( device->machine(), UINT8, doc->data_size[1]);
870   doc->data[2] = auto_alloc_array( device->machine(), UINT8, doc->data_size[2]);
769   m_data[0] = auto_alloc_array( machine(), UINT8, m_data_size[0]);
770   m_data[1] = auto_alloc_array( machine(), UINT8, m_data_size[1]);
771   m_data[2] = auto_alloc_array( machine(), UINT8, m_data_size[2]);
871772
872773//  diskonchip_load( device, "diskonchip");
873774
874   device->save_item( NAME(doc->planes));
875   device->save_item( NAME(doc->blocks));
876   device->save_item( NAME(doc->pages));
877   device->save_item( NAME(doc->user_data_size));
878   device->save_item( NAME(doc->extra_area_size));
879   device->save_pointer( NAME(doc->data[0]), doc->data_size[0]);
880   device->save_pointer( NAME(doc->data[1]), doc->data_size[1]);
881   device->save_pointer( NAME(doc->data[2]), doc->data_size[2]);
775   save_item( NAME(m_planes));
776   save_item( NAME(m_blocks));
777   save_item( NAME(m_pages));
778   save_item( NAME(m_user_data_size));
779   save_item( NAME(m_extra_area_size));
780   save_pointer( NAME(m_data[0]), m_data_size[0]);
781   save_pointer( NAME(m_data[1]), m_data_size[1]);
782   save_pointer( NAME(m_data[2]), m_data_size[2]);
882783}
883784
884static DEVICE_STOP( diskonchip_g3 )
785//-------------------------------------------------
786//  device_reset - device-specific reset
787//-------------------------------------------------
788
789void diskonchip_g3_device::device_reset()
885790{
886   verboselog( device->machine(), 9, "(DOC) device stop\n");
887//  diskonchip_save( device, "diskonchip");
791   verboselog( machine(), 9, "(DOC) device reset\n");
888792}
889793
890static DEVICE_RESET( diskonchip_g3 )
794//-------------------------------------------------
795//  nvram_default - called to initialize NVRAM to
796//  its default state
797//-------------------------------------------------
798
799void diskonchip_g3_device::nvram_default()
891800{
892   verboselog( device->machine(), 9, "(DOC) device reset\n");
801   memset(m_data[0], 0xFF, m_data_size[0]);
802   memset(m_data[1], 0x00, m_data_size[1]);
803   memset(m_data[2], 0xFF, m_data_size[2]);
893804}
894805
895static DEVICE_NVRAM( diskonchip_g3 )
806//-------------------------------------------------
807//  nvram_read - called to read NVRAM from the
808//  .nv file
809//-------------------------------------------------
810
811void diskonchip_g3_device::nvram_read(emu_file &file)
896812{
897   diskonchip_g3_t *doc = get_token( device);
898   verboselog( device->machine(), 9, "(DOC) nvram %s\n", read_or_write ? "write" : "read");
899   if (read_or_write)
900   {
901      if (file)
902      {
903         file->write(doc->data[0], doc->data_size[0]);
904         file->write(doc->data[1], doc->data_size[1]);
905         file->write(doc->data[2], doc->data_size[2]);
906      }
907   }
908   else
909   {
910      if (file)
911      {
912         file->read(doc->data[0], doc->data_size[0]);
913         file->read(doc->data[1], doc->data_size[1]);
914         file->read(doc->data[2], doc->data_size[2]);
915      }
916      else
917      {
918         memset( doc->data[0], 0xFF, doc->data_size[0]);
919         memset( doc->data[1], 0x00, doc->data_size[1]);
920         memset( doc->data[2], 0xFF, doc->data_size[2]);
921      }
922   }
813   file.read(m_data[0], m_data_size[0]);
814   file.read(m_data[1], m_data_size[1]);
815   file.read(m_data[2], m_data_size[2]);
923816}
924817
925DEVICE_GET_INFO( diskonchip_g3 )
926{
927   switch (state)
928   {
929      /* --- the following bits of info are returned as 64-bit signed integers --- */
930      case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(diskonchip_g3_t); break;
931      case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(diskonchip_g3_config); break;
932//      case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break;
818//-------------------------------------------------
819//  nvram_write - called to write NVRAM to the
820//  .nv file
821//-------------------------------------------------
933822
934      /* --- the following bits of info are returned as pointers to data or functions --- */
935      case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(diskonchip_g3); break;
936      case DEVINFO_FCT_STOP: info->stop = DEVICE_STOP_NAME(diskonchip_g3); break;
937      case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(diskonchip_g3); break;
938      case DEVINFO_FCT_NVRAM: info->nvram = DEVICE_NVRAM_NAME(diskonchip_g3); break;
939
940      /* --- the following bits of info are returned as NULL-terminated strings --- */
941      case DEVINFO_STR_NAME: strcpy(info->s, "DiskOnChip G3"); break;
942      case DEVINFO_STR_FAMILY: strcpy(info->s, "DiskOnChip"); break;
943      case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break;
944      case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
945      case DEVINFO_STR_CREDITS: strcpy( info->s, "Copyright Tim Schuerewegen and the MESS Team" ); break;
946   }
823void diskonchip_g3_device::nvram_write(emu_file &file)
824{
825   file.write(m_data[0], m_data_size[0]);
826   file.write(m_data[1], m_data_size[1]);
827   file.write(m_data[2], m_data_size[2]);
947828}
948
949DEFINE_LEGACY_NVRAM_DEVICE(DISKONCHIP_G3, diskonchip_g3);
src/mess/machine/docg3.h
r14327r14328
1111
1212#include "devlegcy.h"
1313
14typedef struct _diskonchip_g3_config diskonchip_g3_config;
15struct _diskonchip_g3_config
14#define MCFG_DISKONCHIP_G3_ADD(_tag, _size) \
15   MCFG_DEVICE_ADD(_tag, DISKONCHIP_G3, 0) \
16   static_cast<diskonchip_g3_device *>(device)->set_size(_size);
17
18// ======================> diskonchip_g3_device
19
20class diskonchip_g3_device : public device_t,
21                      public device_nvram_interface
1622{
17   const int size;
18};
23public:
24   // construction/destruction
25   diskonchip_g3_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
26   
27   void set_size(int _size) { m_size = _size; }
28protected:
29    // device-level overrides
30    virtual void device_start();
31   virtual void device_reset();
1932
20DEVICE_GET_INFO( diskonchip_g3 );
33   // device_nvram_interface overrides
34   virtual void nvram_default();
35   virtual void nvram_read(emu_file &file);
36   virtual void nvram_write(emu_file &file);
37public:
38   DECLARE_READ16_MEMBER( sec_1_r );
39   DECLARE_WRITE16_MEMBER( sec_1_w );
40   DECLARE_READ16_MEMBER( sec_2_r );
41   DECLARE_WRITE16_MEMBER( sec_2_w );
42   DECLARE_READ16_MEMBER( sec_3_r );
43   DECLARE_WRITE16_MEMBER( sec_3_w );
44private:
45   UINT32 g3_offset_data_1();
46   UINT32 g3_offset_data_2();
47   UINT32 g3_offset_data_3();
48   UINT8 g3_read_data();
49   void g3_write_data(UINT8 data);
50   UINT16 sec_2_read_1000();
51   UINT16 sec_2_read_1074();
52   UINT8 sec_2_read_1042();
53   UINT8 sec_2_read_1046();
54   UINT8 sec_2_read_1048();
55   UINT8 sec_2_read_1049();
56   UINT8 sec_2_read_104A();
57   UINT8 sec_2_read_104B();
58   UINT8 sec_2_read_104C();
59   UINT8 sec_2_read_104D();
60   UINT8 sec_2_read_104E();
61   UINT8 sec_2_read_104F();
62   UINT8 sec_2_read_100E();
63   UINT8 sec_2_read_1014();
64   UINT8 sec_2_read_1022();
65   UINT8 sec_2_read_1038();
66   UINT16 sec_2_read16(UINT32 offset);
67   UINT8 sec_2_read8(UINT32 offset);
68   void sec_2_write_100C(UINT8 data);
69   void sec_2_write_1032(UINT8 data);
70   void g3_erase_block();
71   void sec_2_write_1034(UINT8 data);
72   void sec_2_write_1036(UINT8 data);
73   void sec_2_write_1040(UINT16 data);
74   void sec_2_write_100A(UINT8 data);
75   void sec_2_write16(UINT32 offset, UINT16 data);
76   void sec_2_write8(UINT32 offset, UINT8 data);
2177
22#define MCFG_DISKONCHIP_G3_ADD(_tag, _size) \
23   MCFG_DEVICE_ADD(_tag, DISKONCHIP_G3, 0) \
24   MCFG_DEVICE_CONFIG_DATA32(diskonchip_g3_config, size, _size)
78   int m_size;
79   
80   UINT32 m_planes;
81   UINT32 m_blocks;
82   UINT32 m_pages;
83   UINT32 m_user_data_size;
84   UINT32 m_extra_area_size;
85   UINT8 *m_data[3];
86   UINT32 m_data_size[3];
87   UINT8  m_sec_2[0x800];
88   UINT32 m_data_1036;
89   UINT32 m_data_1036_count;
90   UINT32 m_transfer_offset;
91   UINT8  m_device;
92   UINT32 m_block;
93   UINT32 m_page;
94   UINT32 m_plane;
95   UINT32 m_transfersize;
96   UINT8  m_test;
97   UINT32 m_address_count;   
98};
2599
26READ16_DEVICE_HANDLER( diskonchip_g3_sec_1_r );
27WRITE16_DEVICE_HANDLER( diskonchip_g3_sec_1_w );
28READ16_DEVICE_HANDLER( diskonchip_g3_sec_2_r );
29WRITE16_DEVICE_HANDLER( diskonchip_g3_sec_2_w );
30READ16_DEVICE_HANDLER( diskonchip_g3_sec_3_r );
31WRITE16_DEVICE_HANDLER( diskonchip_g3_sec_3_w );
100// device type definition
101extern const device_type DISKONCHIP_G3;   
32102
33DECLARE_LEGACY_NVRAM_DEVICE(DISKONCHIP_G3, diskonchip_g3);
34
35103#endif /* __DOCG3_H__ */
src/mess/machine/ti99/hsgpl.c
r14327r14328
629629      }
630630   }
631631}
632
632/*
633633static DEVICE_NVRAM( hsgpl )
634634{
635635   // Called between START and RESET
r14327r14328
693693      }
694694   }
695695}
696
696*/
697697/*
698698    Get the pointer to the memory data from the HSGPL card. Called by the FEEPROM.
699699*/
r14327r14328
713713static const char DEVTEMPLATE_SOURCE[] = __FILE__;
714714
715715#define DEVTEMPLATE_ID(p,s)             p##hsgpl##s
716#define DEVTEMPLATE_FEATURES            DT_HAS_START | DT_HAS_STOP | DT_HAS_RESET | DT_HAS_INLINE_CONFIG | DT_HAS_MACHINE_CONFIG | DT_HAS_NVRAM
716#define DEVTEMPLATE_FEATURES            DT_HAS_START | DT_HAS_STOP | DT_HAS_RESET | DT_HAS_INLINE_CONFIG | DT_HAS_MACHINE_CONFIG
717717#define DEVTEMPLATE_NAME                "SNUG High-Speed GPL card"
718718#define DEVTEMPLATE_FAMILY              "Peripheral expansion"
719719#include "devtempl.h"
720720
721DEFINE_LEGACY_NVRAM_DEVICE( HSGPL, hsgpl );
721DEFINE_LEGACY_DEVICE( HSGPL, hsgpl );
src/mess/machine/ti99/hsgpl.h
r14327r14328
1010#ifndef __HSGPL__
1111#define __HSGPL__
1212
13DECLARE_LEGACY_NVRAM_DEVICE( HSGPL, hsgpl );
13DECLARE_LEGACY_DEVICE( HSGPL, hsgpl );
1414#endif
1515
src/mess/machine/ti99/evpc.c
r14327r14328
367367
368368   card->dsrrom = device->machine().region(region.cstr())->base();
369369}
370
370/*
371371static DEVICE_NVRAM( ti99_evpc )
372372{
373373   // Called between START and RESET
r14327r14328
400400      }
401401   }
402402}
403
403*/
404404MACHINE_CONFIG_FRAGMENT( ti99_evpc )
405405MACHINE_CONFIG_END
406406
r14327r14328
412412static const char DEVTEMPLATE_SOURCE[] = __FILE__;
413413
414414#define DEVTEMPLATE_ID(p,s)             p##ti99_evpc##s
415#define DEVTEMPLATE_FEATURES            DT_HAS_START | DT_HAS_STOP | DT_HAS_RESET | DT_HAS_ROM_REGION | DT_HAS_INLINE_CONFIG | DT_HAS_MACHINE_CONFIG | DT_HAS_NVRAM
415#define DEVTEMPLATE_FEATURES            DT_HAS_START | DT_HAS_STOP | DT_HAS_RESET | DT_HAS_ROM_REGION | DT_HAS_INLINE_CONFIG | DT_HAS_MACHINE_CONFIG
416416#define DEVTEMPLATE_NAME                "SNUG Enhanced Video Processor Card"
417417#define DEVTEMPLATE_SHORTNAME           "snugvdc"
418418#define DEVTEMPLATE_FAMILY              "Peripheral expansion"
419419#include "devtempl.h"
420420
421DEFINE_LEGACY_NVRAM_DEVICE(EVPC, ti99_evpc);
421DEFINE_LEGACY_DEVICE(EVPC, ti99_evpc);
src/mess/machine/ti99/evpc.h
r14327r14328
99#ifndef __EVPC__
1010#define __EVPC__
1111
12DECLARE_LEGACY_NVRAM_DEVICE( EVPC, ti99_evpc );
12DECLARE_LEGACY_DEVICE( EVPC, ti99_evpc );
1313#endif
src/mess/drivers/gizmondo.c
r14327r14328
153153
154154static ADDRESS_MAP_START( gizmondo_map, AS_PROGRAM, 32 )
155155   AM_RANGE(0x00000000, 0x000007ff) AM_ROM
156   AM_RANGE(0x00000800, 0x00000fff) AM_DEVREADWRITE16( "diskonchip", diskonchip_g3_sec_1_r, diskonchip_g3_sec_1_w, 0xffffffff)
157   AM_RANGE(0x00001000, 0x000017ff) AM_DEVREADWRITE16( "diskonchip", diskonchip_g3_sec_2_r, diskonchip_g3_sec_2_w, 0xffffffff)
158   AM_RANGE(0x00001800, 0x00001fff) AM_DEVREADWRITE16( "diskonchip", diskonchip_g3_sec_3_r, diskonchip_g3_sec_3_w, 0xffffffff)
156   AM_RANGE(0x00000800, 0x00000fff) AM_DEVREADWRITE16_MODERN( "diskonchip", diskonchip_g3_device, sec_1_r, sec_1_w, 0xffffffff)
157   AM_RANGE(0x00001000, 0x000017ff) AM_DEVREADWRITE16_MODERN( "diskonchip", diskonchip_g3_device, sec_2_r, sec_2_w, 0xffffffff)
158   AM_RANGE(0x00001800, 0x00001fff) AM_DEVREADWRITE16_MODERN( "diskonchip", diskonchip_g3_device, sec_3_r, sec_3_w, 0xffffffff)
159159   AM_RANGE(0x30000000, 0x33ffffff) AM_RAM
160160   AM_RANGE(0x34000000, 0x3413ffff) AM_READWRITE( gf4500_r, gf4500_w)
161161ADDRESS_MAP_END

Previous 15994 Revisions Next


© 1998-2018 The MESS Team