Previous 199869 Revisions Next

r19610 Monday 17th December, 2012 at 03:24:11 UTC by R. Belmont
(MESS) nubus_image: support eject/insert in the Finder (won't work from installer) [Rob Braun]
[src/mess/machine]nubus_image.c nubus_image.h

trunk/src/mess/machine/nubus_image.c
r19609r19610
9797{
9898   disk_data *disk = get_safe_disk_token(this);
9999
100   // we're not ejectable for the time being
101   if (disk->data)
102   {
103      return IMAGE_INIT_FAIL;
104   }
105
100   fseek(0, SEEK_END);
101   disk->size = (UINT32)ftell();
106102   if (disk->size > (256*1024*1024))
107103   {
108104      printf("Mac image too large: must be 256MB or less!\n");
r19609r19610
113109   disk->data = (UINT8 *)auto_alloc_array_clear(machine(), UINT32, disk->size/sizeof(UINT32));
114110   fseek(0, SEEK_SET);
115111   fread(disk->data, disk->size);
112   disk->ejected = false;
116113
117114   return IMAGE_INIT_PASS;
118115}
r19609r19610
124121   // TODO: track dirty sectors and only write those
125122   fseek(0, SEEK_SET);
126123   fwrite(disk->data, disk->size);
127//   disk->size = 0;
128//   free(disk->data);
124   disk->size = 0;
125   //free(disk->data);
129126}
130127
131128/*-------------------------------------------------
r19609r19610
142139
143140ROM_START( image )
144141   ROM_REGION(0x2000, IMAGE_ROM_REGION, 0)
145   ROM_LOAD( "nb_fake.bin",  0x000000, 0x002000, CRC(4d77159e) SHA1(45339a63a79ae9b809e559427d12707795961eae) )
142   ROM_LOAD( "nb_fake.bin",  0x000000, 0x002000, CRC(9264bac5) SHA1(540c2ce3c90382b2da6e1e21182cdf8fc3f0c930) )
146143ROM_END
147144
148145//**************************************************************************
r19609r19610
212209//   printf("[image %p] slotspace = %x, super = %x\n", this, slotspace, superslotspace);
213210
214211   m_nubus->install_device(slotspace, slotspace+3, read32_delegate(FUNC(nubus_image_device::image_r), this), write32_delegate(FUNC(nubus_image_device::image_w), this));
212   m_nubus->install_device(slotspace+4, slotspace+7, read32_delegate(FUNC(nubus_image_device::image_status_r), this), write32_delegate(FUNC(nubus_image_device::image_status_w), this));
215213   m_nubus->install_device(superslotspace, superslotspace+((256*1024*1024)-1), read32_delegate(FUNC(nubus_image_device::image_super_r), this), write32_delegate(FUNC(nubus_image_device::image_super_w), this));
216214
217215   device_t *device0 = subdevice(IMAGE_DISK0_TAG);
218216   m_image = (disk_data *) downcast<messimg_disk_image_device *>(device0)->token();
219   image_mapping = (UINT32 *)NULL;
220217}
221218
222219//-------------------------------------------------
r19609r19610
225222
226223void nubus_image_device::device_reset()
227224{
228   image_length = m_image->size;
229   image_mapping = (UINT32 *)m_image->data;
230225}
231226
227WRITE32_MEMBER( nubus_image_device::image_status_w )
228{
229   m_image->ejected = true;
230}
231
232READ32_MEMBER( nubus_image_device::image_status_r )
233{
234   if(m_image->ejected) {
235      return 0;
236   }
237
238   if(m_image->size) {
239      return 1;
240   }
241   return 0;
242}
243
232244WRITE32_MEMBER( nubus_image_device::image_w )
233245{
234246}
235247
236248READ32_MEMBER( nubus_image_device::image_r )
237249{
238   return image_length;
250   return m_image->size;
239251}
240252
241253WRITE32_MEMBER( nubus_image_device::image_super_w )
242254{
255   UINT32 *image = (UINT32*)m_image->data;
243256   data = ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24);
244257   mem_mask = ((mem_mask & 0xff) << 24) | ((mem_mask & 0xff00) << 8) | ((mem_mask & 0xff0000) >> 8) | ((mem_mask & 0xff000000) >> 24);
245258
246   COMBINE_DATA(&image_mapping[offset]);
259   COMBINE_DATA(&image[offset]);
247260}
248261
249262READ32_MEMBER( nubus_image_device::image_super_r )
250263{
251   UINT32 data = image_mapping[offset];
264   UINT32 *image = (UINT32*)m_image->data;
265   UINT32 data = image[offset];
252266   return ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24);
253267}
254268
trunk/src/mess/machine/nubus_image.h
r19609r19610
1515   device_t *device;
1616   UINT32 size;
1717   UINT8 *data;
18   bool ejected;
1819
1920   device_image_interface *image;
2021};
r19609r19610
3940        virtual void device_start();
4041        virtual void device_reset();
4142
43        DECLARE_READ32_MEMBER(image_status_r);
44        DECLARE_WRITE32_MEMBER(image_status_w);
4245        DECLARE_READ32_MEMBER(image_r);
4346        DECLARE_WRITE32_MEMBER(image_w);
4447        DECLARE_READ32_MEMBER(image_super_r);
4548        DECLARE_WRITE32_MEMBER(image_super_w);
4649
4750public:
48   UINT32 image_length;
49   UINT32 *image_mapping;
5051   disk_data *m_image;
5152};
5253

Previous 199869 Revisions Next


© 1997-2024 The MAME Team