src/mess/machine/x68k_hdc.c
| r2805 | r2806 | |
| 17 | 17 | |
| 18 | 18 | #include "x68k_hdc.h" |
| 19 | 19 | #include "devices/harddriv.h" |
| 20 | #include "device.h" |
| 20 | 21 | #include "image.h" |
| 21 | 22 | |
| 22 | 23 | struct hd_state hd; |
| r2805 | r2806 | |
| 55 | 56 | hd.current_block = 0; |
| 56 | 57 | } |
| 57 | 58 | |
| 59 | DEVICE_IMAGE_CREATE( sasihd ) |
| 60 | { |
| 61 | // create 20MB HD |
| 62 | int x; |
| 63 | int ret; |
| 64 | unsigned char sectordata[256]; // empty block data |
| 65 | |
| 66 | memset(sectordata,0,256); |
| 67 | for(x=0;x<0x013c98;x++) // 0x13c98 = number of blocks on a 20MB HD |
| 68 | { |
| 69 | ret = image_fwrite(image,sectordata,256); |
| 70 | if(ret < 256) |
| 71 | return INIT_FAIL; |
| 72 | } |
| 73 | |
| 74 | return INIT_PASS; |
| 75 | } |
| 76 | |
| 58 | 77 | WRITE16_DEVICE_HANDLER( x68k_hdc_w ) |
| 59 | 78 | { |
| 60 | 79 | sasi_ctrl_t* sasi = device->token; |
| 61 | 80 | unsigned int lba = 0; |
| 81 | char* blk; |
| 62 | 82 | |
| 63 | 83 | switch(offset) |
| 64 | 84 | { |
| r2805 | r2806 | |
| 236 | 256 | sasi->status_port |= 0x04; // C/D remains the same |
| 237 | 257 | sasi->cd = 1; |
| 238 | 258 | sasi->status_port |= 0x08; |
| 259 | logerror("SASI: SEEK (LBA 0x%06x)\n",lba); |
| 260 | break; |
| 261 | case SASI_CMD_FORMAT_UNIT: |
| 262 | case SASI_CMD_FORMAT_UNIT_06: |
| 263 | /* |
| 264 | Format Unit command format (differs from SASI spec?) |
| 265 | 0 | 0x06 |
| 266 | 1 | Unit number (0-7) | LBA MSB (high 5 bits) |
| 267 | 2 | LBA |
| 268 | 3 | LBA LSB |
| 269 | 4 | ?? (usually 0x01) |
| 270 | 5 | ?? |
| 271 | */ |
| 272 | sasi->phase = SASI_PHASE_STATUS; |
| 273 | sasi->io = 1; // Output |
| 274 | sasi->status_port |= 0x04; // C/D remains the same |
| 275 | sasi->cd = 1; |
| 276 | sasi->status_port |= 0x08; |
| 239 | 277 | lba = sasi->command[3]; |
| 240 | 278 | lba |= sasi->command[2] << 8; |
| 241 | 279 | lba |= (sasi->command[1] & 0x1f) << 16; |
| 242 | 280 | image_fseek(device,lba * 256,SEEK_SET); |
| 243 | | logerror("SASI: SEEK (LBA 0x%06x)\n",lba); |
| 281 | blk = malloc(256*33); |
| 282 | memset(blk,0,256*33); |
| 283 | // formats 33 256-byte blocks |
| 284 | image_fwrite(device,blk,256*33); |
| 285 | free(blk); |
| 286 | logerror("SASI: FORMAT UNIT (LBA 0x%06x)\n",lba); |
| 244 | 287 | break; |
| 245 | 288 | default: |
| 246 | 289 | sasi->phase = SASI_PHASE_STATUS; |
| r2805 | r2806 | |
| 414 | 457 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 415 | 458 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(sasi_ctrl_t); break; |
| 416 | 459 | case DEVINFO_INT_IMAGE_TYPE: info->i = IO_HARDDISK; break; |
| 460 | case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break; |
| 461 | case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break; |
| 462 | case DEVINFO_INT_IMAGE_CREATABLE: info->i = 1; break; |
| 417 | 463 | |
| 418 | 464 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 419 | 465 | case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(x68k_hdc); break; |
| 420 | 466 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(x68k_hdc); break; |
| 421 | 467 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 422 | 468 | case DEVINFO_FCT_RESET: /*info->reset = DEVICE_RESET_NAME(x68k_hdc);*/ break; |
| 423 | | case DEVINFO_INT_IMAGE_READABLE: info->i = 1; break; |
| 424 | | case DEVINFO_INT_IMAGE_WRITEABLE: info->i = 1; break; |
| 425 | | case DEVINFO_INT_IMAGE_CREATABLE: info->i = 0; break; |
| 469 | case DEVINFO_FCT_IMAGE_CREATE: info->f = (genf *)DEVICE_IMAGE_CREATE_NAME(sasihd); break; |
| 426 | 470 | |
| 427 | 471 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 428 | 472 | case DEVINFO_STR_NAME: info->s = "SASI Hard Disk"; break; |