trunk/src/mess/machine/nubus_image.c
| r19609 | r19610 | |
| 97 | 97 | { |
| 98 | 98 | disk_data *disk = get_safe_disk_token(this); |
| 99 | 99 | |
| 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(); |
| 106 | 102 | if (disk->size > (256*1024*1024)) |
| 107 | 103 | { |
| 108 | 104 | printf("Mac image too large: must be 256MB or less!\n"); |
| r19609 | r19610 | |
| 113 | 109 | disk->data = (UINT8 *)auto_alloc_array_clear(machine(), UINT32, disk->size/sizeof(UINT32)); |
| 114 | 110 | fseek(0, SEEK_SET); |
| 115 | 111 | fread(disk->data, disk->size); |
| 112 | disk->ejected = false; |
| 116 | 113 | |
| 117 | 114 | return IMAGE_INIT_PASS; |
| 118 | 115 | } |
| r19609 | r19610 | |
| 124 | 121 | // TODO: track dirty sectors and only write those |
| 125 | 122 | fseek(0, SEEK_SET); |
| 126 | 123 | fwrite(disk->data, disk->size); |
| 127 | | // disk->size = 0; |
| 128 | | // free(disk->data); |
| 124 | disk->size = 0; |
| 125 | //free(disk->data); |
| 129 | 126 | } |
| 130 | 127 | |
| 131 | 128 | /*------------------------------------------------- |
| r19609 | r19610 | |
| 142 | 139 | |
| 143 | 140 | ROM_START( image ) |
| 144 | 141 | 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) ) |
| 146 | 143 | ROM_END |
| 147 | 144 | |
| 148 | 145 | //************************************************************************** |
| r19609 | r19610 | |
| 212 | 209 | // printf("[image %p] slotspace = %x, super = %x\n", this, slotspace, superslotspace); |
| 213 | 210 | |
| 214 | 211 | 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)); |
| 215 | 213 | 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 | 214 | |
| 217 | 215 | device_t *device0 = subdevice(IMAGE_DISK0_TAG); |
| 218 | 216 | m_image = (disk_data *) downcast<messimg_disk_image_device *>(device0)->token(); |
| 219 | | image_mapping = (UINT32 *)NULL; |
| 220 | 217 | } |
| 221 | 218 | |
| 222 | 219 | //------------------------------------------------- |
| r19609 | r19610 | |
| 225 | 222 | |
| 226 | 223 | void nubus_image_device::device_reset() |
| 227 | 224 | { |
| 228 | | image_length = m_image->size; |
| 229 | | image_mapping = (UINT32 *)m_image->data; |
| 230 | 225 | } |
| 231 | 226 | |
| 227 | WRITE32_MEMBER( nubus_image_device::image_status_w ) |
| 228 | { |
| 229 | m_image->ejected = true; |
| 230 | } |
| 231 | |
| 232 | READ32_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 | |
| 232 | 244 | WRITE32_MEMBER( nubus_image_device::image_w ) |
| 233 | 245 | { |
| 234 | 246 | } |
| 235 | 247 | |
| 236 | 248 | READ32_MEMBER( nubus_image_device::image_r ) |
| 237 | 249 | { |
| 238 | | return image_length; |
| 250 | return m_image->size; |
| 239 | 251 | } |
| 240 | 252 | |
| 241 | 253 | WRITE32_MEMBER( nubus_image_device::image_super_w ) |
| 242 | 254 | { |
| 255 | UINT32 *image = (UINT32*)m_image->data; |
| 243 | 256 | data = ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24); |
| 244 | 257 | mem_mask = ((mem_mask & 0xff) << 24) | ((mem_mask & 0xff00) << 8) | ((mem_mask & 0xff0000) >> 8) | ((mem_mask & 0xff000000) >> 24); |
| 245 | 258 | |
| 246 | | COMBINE_DATA(&image_mapping[offset]); |
| 259 | COMBINE_DATA(&image[offset]); |
| 247 | 260 | } |
| 248 | 261 | |
| 249 | 262 | READ32_MEMBER( nubus_image_device::image_super_r ) |
| 250 | 263 | { |
| 251 | | UINT32 data = image_mapping[offset]; |
| 264 | UINT32 *image = (UINT32*)m_image->data; |
| 265 | UINT32 data = image[offset]; |
| 252 | 266 | return ((data & 0xff) << 24) | ((data & 0xff00) << 8) | ((data & 0xff0000) >> 8) | ((data & 0xff000000) >> 24); |
| 253 | 267 | } |
| 254 | 268 | |