trunk/src/mess/machine/nubus_image.c
| r0 | r19421 | |
| 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 | |
| 19 | class messimg_disk_image_device : public device_t, |
| 20 | public device_image_interface |
| 21 | { |
| 22 | public: |
| 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; } |
| 42 | protected: |
| 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 |
| 52 | extern const device_type MESSIMG_DISK; |
| 53 | |
| 54 | const device_type MESSIMG_DISK = &device_creator<messimg_disk_image_device>; |
| 55 | |
| 56 | messimg_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 | |
| 62 | void 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 | |
| 72 | INLINE 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 | |
| 82 | void 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 | |
| 96 | bool 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 | |
| 120 | void 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 | |
| 135 | void messimg_disk_image_device::device_reset() |
| 136 | { |
| 137 | } |
| 138 | |
| 139 | MACHINE_CONFIG_FRAGMENT( image ) |
| 140 | MCFG_DEVICE_ADD(IMAGE_DISK0_TAG, MESSIMG_DISK, 0) |
| 141 | MACHINE_CONFIG_END |
| 142 | |
| 143 | ROM_START( image ) |
| 144 | ROM_REGION(0x2000, IMAGE_ROM_REGION, 0) |
| 145 | ROM_LOAD( "nb_fake.bin", 0x000000, 0x002000, CRC(b6c46215) SHA1(5dc805658c1731d189e2cb289c611539680b87f4) ) |
| 146 | ROM_END |
| 147 | |
| 148 | //************************************************************************** |
| 149 | // GLOBAL VARIABLES |
| 150 | //************************************************************************** |
| 151 | |
| 152 | const device_type NUBUS_IMAGE = &device_creator<nubus_image_device>; |
| 153 | |
| 154 | |
| 155 | //------------------------------------------------- |
| 156 | // machine_config_additions - device-specific |
| 157 | // machine configurations |
| 158 | //------------------------------------------------- |
| 159 | |
| 160 | machine_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 | |
| 169 | const 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 | |
| 182 | nubus_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 | |
| 189 | nubus_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 | |
| 200 | void 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 | |
| 226 | void nubus_image_device::device_reset() |
| 227 | { |
| 228 | image_length = m_image->size; |
| 229 | image_mapping = (UINT32 *)m_image->data; |
| 230 | } |
| 231 | |
| 232 | WRITE32_MEMBER( nubus_image_device::image_w ) |
| 233 | { |
| 234 | } |
| 235 | |
| 236 | READ32_MEMBER( nubus_image_device::image_r ) |
| 237 | { |
| 238 | return image_length; |
| 239 | } |
| 240 | |
| 241 | WRITE32_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 | |
| 249 | READ32_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/drivers/mac.c
| r19420 | r19421 | |
| 68 | 68 | #include "video/nubus_radiustpd.h" |
| 69 | 69 | #include "video/nubus_wsportrait.h" |
| 70 | 70 | #include "machine/nubus_asntmc3b.h" |
| 71 | #include "machine/nubus_image.h" |
| 71 | 72 | #include "video/nubus_m2video.h" |
| 72 | 73 | #include "video/pds30_cb264.h" |
| 73 | 74 | #include "video/pds30_procolor816.h" |
| r19420 | r19421 | |
| 853 | 854 | SLOT_INTERFACE("824gc", NUBUS_824GC) /* Apple 8*24 Graphics Card */ |
| 854 | 855 | SLOT_INTERFACE("cb264", NUBUS_CB264) /* RasterOps ColorBoard 264 */ |
| 855 | 856 | SLOT_INTERFACE("vikbw", NUBUS_VIKBW) /* Moniterm Viking board */ |
| 857 | SLOT_INTERFACE("image", NUBUS_IMAGE) /* Disk Image Pseudo-Card */ |
| 856 | 858 | SLOT_INTERFACE("specpdq", NUBUS_SPECPDQ) /* SuperMac Spectrum PDQ */ |
| 857 | 859 | SLOT_INTERFACE("m2hires", NUBUS_M2HIRES) /* Apple Macintosh II Hi-Resolution Card */ |
| 858 | 860 | SLOT_INTERFACE("spec8s3", NUBUS_SPEC8S3) /* SuperMac Spectrum/8 Series III */ |
| r19420 | r19421 | |
| 871 | 873 | SLOT_INTERFACE("mc30", PDS030_XCEEDMC30) // Micron/XCEED Technology MacroColor 30 |
| 872 | 874 | SLOT_INTERFACE_END |
| 873 | 875 | |
| 876 | static SLOT_INTERFACE_START(mac_lcpds_cards) |
| 877 | SLOT_INTERFACE_END |
| 878 | |
| 874 | 879 | /*************************************************************************** |
| 875 | 880 | MACHINE DRIVERS |
| 876 | 881 | ***************************************************************************/ |
| r19420 | r19421 | |
| 1149 | 1154 | MCFG_NUBUS_SLOT_REMOVE("nbe") |
| 1150 | 1155 | MCFG_NUBUS_BUS_REMOVE("nubus") |
| 1151 | 1156 | |
| 1157 | MCFG_NUBUS_BUS_ADD("pds", "maincpu", nubus_intf) |
| 1158 | MCFG_NUBUS_SLOT_ADD("pds","lcpds", mac_lcpds_cards, NULL, NULL) |
| 1159 | |
| 1152 | 1160 | MCFG_ASC_REPLACE("asc", C15M, ASC_TYPE_V8, mac_asc_irq) |
| 1153 | 1161 | MCFG_SOUND_ROUTE(0, "lspeaker", 1.0) |
| 1154 | 1162 | MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) |