Previous 199869 Revisions Next

r19421 Sunday 9th December, 2012 at 03:57:00 UTC by R. Belmont
(MESS) Mac: added "image" card which allows direct read/write access to any vMac/BasiliskII compatible image under 256 MB, including HD floppies.  Not bootable, and do NOT try to swap the disk. [Rob Braun, R. Belmont]
[src/mess]mess.mak
[src/mess/drivers]mac.c
[src/mess/machine]nubus_image.c* nubus_image.h*

trunk/src/mess/machine/nubus_image.c
r0r19421
1/***************************************************************************
2
3  nubus_image.c - synthetic NuBus card to allow reading/writing "raw"
4  HFS images, including floppy images (DD and HD) and vMac/Basilisk HDD
5  volumes up to 256 MB in size.
6
7***************************************************************************/
8
9#include "emu.h"
10#include "machine/nubus_image.h"
11
12#define IMAGE_ROM_REGION   "image_rom"
13#define IMAGE_DISK0_TAG    "nb_disk"
14
15#define MESSIMG_DISK_SECTOR_SIZE (512)
16
17// messimg_disk_image_device
18
19class messimg_disk_image_device :   public device_t,
20                        public device_image_interface
21{
22public:
23   // construction/destruction
24   messimg_disk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
25
26   // image-level overrides
27   virtual iodevice_t image_type() const { return IO_QUICKLOAD; }
28
29   virtual bool is_readable()  const { return 1; }
30   virtual bool is_writeable() const { return 1; }
31   virtual bool is_creatable() const { return 0; }
32   virtual bool must_be_loaded() const { return 0; }
33   virtual bool is_reset_on_load() const { return 0; }
34   virtual const char *image_interface() const { return NULL; }
35   virtual const char *file_extensions() const { return "img"; }
36   virtual const option_guide *create_option_guide() const { return NULL; }
37
38   virtual bool call_load();
39   virtual void call_unload();
40
41   disk_data *token() { return &m_token; }
42protected:
43   // device-level overrides
44    virtual void device_config_complete();
45   virtual void device_start();
46   virtual void device_reset();
47
48   disk_data m_token;
49};
50
51// device type definition
52extern const device_type MESSIMG_DISK;
53
54const device_type MESSIMG_DISK = &device_creator<messimg_disk_image_device>;
55
56messimg_disk_image_device::messimg_disk_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
57    : device_t(mconfig, MESSIMG_DISK, "Mac image", tag, owner, clock),
58     device_image_interface(mconfig, *this)
59{
60}
61
62void messimg_disk_image_device::device_config_complete()
63{
64   update_names(MESSIMG_DISK, "disk", "disk");
65};
66
67
68/***************************************************************************
69 get_safe_disk_token - makes sure that the passed in device is a messimg disk
70 ***************************************************************************/
71
72INLINE disk_data *get_safe_disk_token(device_t *device) {
73   assert(device != NULL);
74   assert(device->type() == MESSIMG_DISK);
75   return (disk_data *) downcast<messimg_disk_image_device *>(device)->token();
76}
77
78/*-------------------------------------------------
79    device start callback
80-------------------------------------------------*/
81
82void messimg_disk_image_device::device_start()
83{
84   disk_data *disk = get_safe_disk_token(this);
85
86   disk->device = this;
87   disk->image = this;
88   disk->data = (UINT8 *)NULL;
89
90   if (exists() && fseek(0, SEEK_END) == 0)
91   {
92      disk->size = (UINT32)ftell();
93   }
94}
95
96bool messimg_disk_image_device::call_load()
97{
98   disk_data *disk = get_safe_disk_token(this);
99
100   // we're not ejectable for the time being
101   if (disk->data)
102   {
103      return IMAGE_INIT_FAIL;
104   }
105
106   if (disk->size > (256*1024*1024))
107   {
108      printf("Mac image too large: must be 256MB or less!\n");
109      disk->size = 0;
110      return IMAGE_INIT_FAIL;
111   }
112
113   disk->data = (UINT8 *)auto_alloc_array_clear(machine(), UINT32, disk->size/sizeof(UINT32));
114   fseek(0, SEEK_SET);
115   fread(disk->data, disk->size);
116
117   return IMAGE_INIT_PASS;
118}
119
120void messimg_disk_image_device::call_unload()
121{
122   disk_data *disk = get_safe_disk_token(this);
123
124   // TODO: track dirty sectors and only write those
125   fseek(0, SEEK_SET);
126   fwrite(disk->data, disk->size);
127//   disk->size = 0;
128//   free(disk->data);
129}
130
131/*-------------------------------------------------
132    device reset callback
133-------------------------------------------------*/
134
135void messimg_disk_image_device::device_reset()
136{
137}
138
139MACHINE_CONFIG_FRAGMENT( image )
140   MCFG_DEVICE_ADD(IMAGE_DISK0_TAG, MESSIMG_DISK, 0)
141MACHINE_CONFIG_END
142
143ROM_START( image )
144   ROM_REGION(0x2000, IMAGE_ROM_REGION, 0)
145   ROM_LOAD( "nb_fake.bin",   0x000000, 0x002000, CRC(b6c46215) SHA1(5dc805658c1731d189e2cb289c611539680b87f4) )
146ROM_END
147
148//**************************************************************************
149//  GLOBAL VARIABLES
150//**************************************************************************
151
152const device_type NUBUS_IMAGE = &device_creator<nubus_image_device>;
153
154
155//-------------------------------------------------
156//  machine_config_additions - device-specific
157//  machine configurations
158//-------------------------------------------------
159
160machine_config_constructor nubus_image_device::device_mconfig_additions() const
161{
162   return MACHINE_CONFIG_NAME( image );
163}
164
165//-------------------------------------------------
166//  rom_region - device-specific ROM region
167//-------------------------------------------------
168
169const rom_entry *nubus_image_device::device_rom_region() const
170{
171   return ROM_NAME( image );
172}
173
174//**************************************************************************
175//  LIVE DEVICE
176//**************************************************************************
177
178//-------------------------------------------------
179//  nubus_image_device - constructor
180//-------------------------------------------------
181
182nubus_image_device::nubus_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
183        device_t(mconfig, NUBUS_IMAGE, "Disk Image Pseudo-Card", tag, owner, clock),
184      device_nubus_card_interface(mconfig, *this)
185{
186   m_shortname = "nb_image";
187}
188
189nubus_image_device::nubus_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) :
190        device_t(mconfig, type, name, tag, owner, clock),
191      device_nubus_card_interface(mconfig, *this)
192{
193   m_shortname = "nb_image";
194}
195
196//-------------------------------------------------
197//  device_start - device-specific startup
198//-------------------------------------------------
199
200void nubus_image_device::device_start()
201{
202   UINT32 slotspace;
203   UINT32 superslotspace;
204
205   // set_nubus_device makes m_slot valid
206   set_nubus_device();
207   install_declaration_rom(this, IMAGE_ROM_REGION);
208
209   slotspace = get_slotspace();
210   superslotspace = get_super_slotspace();
211
212//   printf("[image %p] slotspace = %x, super = %x\n", this, slotspace, superslotspace);
213
214   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));
215   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));
216
217   device_t *device0 = subdevice(IMAGE_DISK0_TAG);
218   m_image = (disk_data *) downcast<messimg_disk_image_device *>(device0)->token();
219   image_mapping = (UINT32 *)NULL;
220}
221
222//-------------------------------------------------
223//  device_reset - device-specific reset
224//-------------------------------------------------
225
226void nubus_image_device::device_reset()
227{
228   image_length = m_image->size;
229   image_mapping = (UINT32 *)m_image->data;
230}
231
232WRITE32_MEMBER( nubus_image_device::image_w )
233{
234}
235
236READ32_MEMBER( nubus_image_device::image_r )
237{
238   return image_length;
239}
240
241WRITE32_MEMBER( nubus_image_device::image_super_w )
242{
243   data = ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24);
244   mem_mask = ((mem_mask & 0xff) << 24) | ((mem_mask & 0xff00) << 8) | ((mem_mask & 0xff0000) >> 8) | ((mem_mask & 0xff000000) >> 24);
245
246   COMBINE_DATA(&image_mapping[offset]);
247}
248
249READ32_MEMBER( nubus_image_device::image_super_r )
250{
251   UINT32 data = image_mapping[offset];
252   return ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24);
253}
254
trunk/src/mess/machine/nubus_image.h
r0r19421
1#pragma once
2
3#ifndef __NUBUS_IMAGE_H__
4#define __NUBUS_IMAGE_H__
5
6#include "emu.h"
7#include "machine/nubus.h"
8
9//**************************************************************************
10//  TYPE DEFINITIONS
11//**************************************************************************
12
13struct disk_data
14{
15   device_t *device;
16   UINT32 size;
17   UINT8 *data;
18
19   device_image_interface *image;
20};
21
22// ======================> nubus_image_device
23
24class nubus_image_device :
25      public device_t,
26      public device_nubus_card_interface
27{
28public:
29        // construction/destruction
30        nubus_image_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
31      nubus_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
32
33      // optional information overrides
34      virtual machine_config_constructor device_mconfig_additions() const;
35      virtual const rom_entry *device_rom_region() const;
36
37protected:
38        // device-level overrides
39        virtual void device_start();
40        virtual void device_reset();
41
42        DECLARE_READ32_MEMBER(image_r);
43        DECLARE_WRITE32_MEMBER(image_w);
44        DECLARE_READ32_MEMBER(image_super_r);
45        DECLARE_WRITE32_MEMBER(image_super_w);
46
47public:
48   UINT32 image_length;
49   UINT32 *image_mapping;
50   disk_data *m_image;
51};
52
53
54// device type definition
55extern const device_type NUBUS_IMAGE;
56
57#endif  /* __NUBUS_IMAGE_H__ */
58
trunk/src/mess/drivers/mac.c
r19420r19421
6868#include "video/nubus_radiustpd.h"
6969#include "video/nubus_wsportrait.h"
7070#include "machine/nubus_asntmc3b.h"
71#include "machine/nubus_image.h"
7172#include "video/nubus_m2video.h"
7273#include "video/pds30_cb264.h"
7374#include "video/pds30_procolor816.h"
r19420r19421
853854   SLOT_INTERFACE("824gc", NUBUS_824GC)   /* Apple 8*24 Graphics Card */
854855   SLOT_INTERFACE("cb264", NUBUS_CB264)   /* RasterOps ColorBoard 264 */
855856   SLOT_INTERFACE("vikbw", NUBUS_VIKBW)   /* Moniterm Viking board */
857   SLOT_INTERFACE("image", NUBUS_IMAGE)   /* Disk Image Pseudo-Card */
856858   SLOT_INTERFACE("specpdq", NUBUS_SPECPDQ)   /* SuperMac Spectrum PDQ */
857859   SLOT_INTERFACE("m2hires", NUBUS_M2HIRES)   /* Apple Macintosh II Hi-Resolution Card */
858860   SLOT_INTERFACE("spec8s3", NUBUS_SPEC8S3)   /* SuperMac Spectrum/8 Series III */
r19420r19421
871873    SLOT_INTERFACE("mc30",  PDS030_XCEEDMC30)   // Micron/XCEED Technology MacroColor 30
872874SLOT_INTERFACE_END
873875
876static SLOT_INTERFACE_START(mac_lcpds_cards)
877SLOT_INTERFACE_END
878
874879/***************************************************************************
875880    MACHINE DRIVERS
876881***************************************************************************/
r19420r19421
11491154   MCFG_NUBUS_SLOT_REMOVE("nbe")
11501155   MCFG_NUBUS_BUS_REMOVE("nubus")
11511156
1157   MCFG_NUBUS_BUS_ADD("pds", "maincpu", nubus_intf)
1158   MCFG_NUBUS_SLOT_ADD("pds","lcpds", mac_lcpds_cards, NULL, NULL)
1159
11521160   MCFG_ASC_REPLACE("asc", C15M, ASC_TYPE_V8, mac_asc_irq)
11531161   MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
11541162   MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
trunk/src/mess/mess.mak
r19420r19421
715715   $(MESS_VIDEO)/nubus_radiustpd.o \
716716    $(MESS_VIDEO)/nubus_m2video.o \
717717   $(MESS_MACHINE)/nubus_asntmc3b.o \
718   $(MESS_MACHINE)/nubus_image.o \
718719   $(MESS_VIDEO)/nubus_wsportrait.o \
719720    $(MESS_VIDEO)/pds30_cb264.o \
720721    $(MESS_VIDEO)/pds30_procolor816.o \

Previous 199869 Revisions Next


© 1997-2024 The MAME Team