src/mess/devices/flopdrv.c
| r8322 | r8323 | |
| 118 | 118 | /*************************************************************************** |
| 119 | 119 | IMPLEMENTATION |
| 120 | 120 | ***************************************************************************/ |
| 121 | | extern DEVICE_GET_INFO(apple525); |
| 122 | | extern DEVICE_GET_INFO(sonydriv); |
| 121 | DECLARE_LEGACY_IMAGE_DEVICE(FLOPPY_APPLE, apple525); |
| 122 | DECLARE_LEGACY_IMAGE_DEVICE(FLOPPY_SONY, sonydriv); |
| 123 | 123 | |
| 124 | 124 | INLINE floppy_drive *get_safe_token(running_device *device) |
| 125 | 125 | { |
| 126 | 126 | assert( device != NULL ); |
| 127 | | // assert( device->type() == FLOPPY || device->type() == FLOPPY_APPLE || device->type() == FLOPPY_SONY); |
| 127 | assert( device->type() == FLOPPY || device->type() == FLOPPY_APPLE || device->type() == FLOPPY_SONY); |
| 128 | 128 | return (floppy_drive *) downcast<legacy_device_base *>(device)->token(); |
| 129 | 129 | } |
| 130 | 130 | |
| r8322 | r8323 | |
| 346 | 346 | void floppy_drive_set_ready_state(running_device *img, int state, int flag) |
| 347 | 347 | { |
| 348 | 348 | floppy_drive *drive = get_safe_token(img); |
| 349 | | device_image_interface *image = (device_image_interface *) img; |
| 349 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 350 | 350 | if (flag) |
| 351 | 351 | { |
| 352 | 352 | /* set ready only if drive is present, disk is in the drive, |
| r8322 | r8323 | |
| 394 | 394 | |
| 395 | 395 | void floppy_drive_seek(running_device *img, signed int signed_tracks) |
| 396 | 396 | { |
| 397 | | device_image_interface *image = (device_image_interface *) img; |
| 397 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 398 | 398 | floppy_drive *pDrive; |
| 399 | 399 | |
| 400 | 400 | pDrive = get_safe_token( img ); |
| r8322 | r8323 | |
| 469 | 469 | void floppy_drive_read_track_data_info_buffer(running_device *img, int side, void *ptr, int *length ) |
| 470 | 470 | { |
| 471 | 471 | floppy_drive *flopimg; |
| 472 | | device_image_interface *image = (device_image_interface *) img; |
| 472 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 473 | 473 | |
| 474 | 474 | if (image->exists()) |
| 475 | 475 | { |
| r8322 | r8323 | |
| 484 | 484 | void floppy_drive_write_track_data_info_buffer(running_device *img, int side, const void *ptr, int *length ) |
| 485 | 485 | { |
| 486 | 486 | floppy_drive *flopimg; |
| 487 | | device_image_interface *image = (device_image_interface *) img; |
| 487 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 488 | 488 | |
| 489 | 489 | if (image->exists()) |
| 490 | 490 | { |
| r8322 | r8323 | |
| 498 | 498 | |
| 499 | 499 | void floppy_drive_format_sector(running_device *img, int side, int sector_index,int c,int h, int r, int n, int filler) |
| 500 | 500 | { |
| 501 | | device_image_interface *image = (device_image_interface *) img; |
| 501 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 502 | 502 | |
| 503 | 503 | if (image->exists()) |
| 504 | 504 | { |
| r8322 | r8323 | |
| 510 | 510 | void floppy_drive_read_sector_data(running_device *img, int side, int index1, void *ptr, int length) |
| 511 | 511 | { |
| 512 | 512 | floppy_drive *flopimg; |
| 513 | | device_image_interface *image = (device_image_interface *) img; |
| 513 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 514 | 514 | |
| 515 | 515 | if (image->exists()) |
| 516 | 516 | { |
| r8322 | r8323 | |
| 529 | 529 | void floppy_drive_write_sector_data(running_device *img, int side, int index1, const void *ptr,int length, int ddam) |
| 530 | 530 | { |
| 531 | 531 | floppy_drive *flopimg; |
| 532 | | device_image_interface *image = (device_image_interface *) img; |
| 532 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 533 | 533 | |
| 534 | 534 | if (image->exists()) |
| 535 | 535 | { |
| r8322 | r8323 | |
| 586 | 586 | { |
| 587 | 587 | floppy_drive *drv = get_safe_token( img ); |
| 588 | 588 | int size = 0; |
| 589 | | device_image_interface *image = (device_image_interface*)img; |
| 589 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 590 | 590 | |
| 591 | 591 | if (image->exists()) |
| 592 | 592 | { |
| r8322 | r8323 | |
| 887 | 887 | WRITE_LINE_DEVICE_HANDLER( floppy_mon_w ) |
| 888 | 888 | { |
| 889 | 889 | floppy_drive *drive = get_safe_token(device); |
| 890 | | device_image_interface *image = (device_image_interface *) device; |
| 890 | device_image_interface *image = dynamic_cast<device_image_interface *>(device); |
| 891 | 891 | /* force off if there is no attached image */ |
| 892 | 892 | if (!image->exists()) |
| 893 | 893 | state = ASSERT_LINE; |
src/mess/devices/sonydriv.c
| r8322 | r8323 | |
| 111 | 111 | floppy *f; |
| 112 | 112 | |
| 113 | 113 | f = &sony_floppy[floppy_select]; |
| 114 | | cur_image = (device_image_interface *)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, floppy_select); |
| 114 | cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, floppy_select)); |
| 115 | 115 | |
| 116 | 116 | track_size = floppy_get_track_size(flopimg_get_image(&cur_image->device()), f->head, floppy_drive_get_current_track(&cur_image->device())); |
| 117 | 117 | new_data = (UINT8*)cur_image->image_realloc(f->loadedtrack_data, track_size); |
| r8322 | r8323 | |
| 130 | 130 | |
| 131 | 131 | static void save_track_data(running_device *device, int floppy_select) |
| 132 | 132 | { |
| 133 | | running_device *cur_image; |
| 133 | device_image_interface *cur_image; |
| 134 | 134 | floppy *f; |
| 135 | 135 | int len; |
| 136 | 136 | |
| 137 | 137 | f = &sony_floppy[floppy_select]; |
| 138 | | cur_image = floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, floppy_select); |
| 138 | cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, floppy_select)); |
| 139 | 139 | |
| 140 | 140 | if (f->loadedtrack_dirty) |
| 141 | 141 | { |
| 142 | 142 | len = f->loadedtrack_size; |
| 143 | | floppy_drive_write_track_data_info_buffer(cur_image, f->head, f->loadedtrack_data, &len); |
| 143 | floppy_drive_write_track_data_info_buffer(&cur_image->device(), f->head, f->loadedtrack_data, &len); |
| 144 | 144 | f->loadedtrack_dirty = 0; |
| 145 | 145 | } |
| 146 | 146 | } |
| r8322 | r8323 | |
| 157 | 157 | return 0xFF; /* right ??? */ |
| 158 | 158 | |
| 159 | 159 | f = &sony_floppy[sony_floppy_select]; |
| 160 | | cur_image = (device_image_interface*)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select); |
| 160 | cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select)); |
| 161 | 161 | if (!cur_image->exists()) |
| 162 | 162 | return 0xFF; |
| 163 | 163 | |
| r8322 | r8323 | |
| 176 | 176 | floppy *f; |
| 177 | 177 | |
| 178 | 178 | f = &sony_floppy[sony_floppy_select]; |
| 179 | | cur_image = (device_image_interface*)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select); |
| 179 | cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select)); |
| 180 | 180 | if (!cur_image->exists()) |
| 181 | 181 | return; |
| 182 | 182 | |
| r8322 | r8323 | |
| 191 | 191 | static int sony_rpm(floppy *f, running_device *cur_image) |
| 192 | 192 | { |
| 193 | 193 | int result = 0; |
| 194 | | device_image_interface *image =(device_image_interface*)cur_image; |
| 194 | device_image_interface *image =dynamic_cast<device_image_interface *>(cur_image); |
| 195 | 195 | /* |
| 196 | 196 | * The Mac floppy controller was interesting in that its speed was adjusted |
| 197 | 197 | * while the thing was running. On the tracks closer to the rim, it was |
| r8322 | r8323 | |
| 259 | 259 | if ((! sony_enable2()) && sony_floppy_enable) |
| 260 | 260 | { |
| 261 | 261 | f = &sony_floppy[sony_floppy_select]; |
| 262 | | cur_image = (device_image_interface*)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select); |
| 262 | cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select)); |
| 263 | 263 | if (!cur_image->exists()) |
| 264 | 264 | cur_image = NULL; |
| 265 | 265 | |
| r8322 | r8323 | |
| 365 | 365 | if (sony_floppy_enable) |
| 366 | 366 | { |
| 367 | 367 | f = &sony_floppy[sony_floppy_select]; |
| 368 | | cur_image = (device_image_interface*)floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select); |
| 368 | cur_image = dynamic_cast<device_image_interface *>(floppy_get_device_by_type(device->machine, FLOPPY_TYPE_SONY, sony_floppy_select)); |
| 369 | 369 | if (!cur_image->exists()) |
| 370 | 370 | cur_image = NULL; |
| 371 | 371 | |
| r8322 | r8323 | |
| 471 | 471 | DEVICE_START_CALL(floppy); |
| 472 | 472 | floppy_set_type(device,FLOPPY_TYPE_SONY); |
| 473 | 473 | } |
| 474 | | // |
| 475 | | //static DEVICE_IMAGE_UNLOAD( sonydriv_floppy ) |
| 476 | | //{ |
| 477 | | // int id; |
| 478 | | // running_device *fdc; |
| 479 | | // |
| 480 | | // /* locate the FDC */ |
| 481 | | // fdc = devtag_get_device(image->machine, "fdc"); |
| 482 | | // |
| 483 | | // id = floppy_get_drive_by_type(image,FLOPPY_TYPE_SONY); |
| 484 | | // save_track_data(fdc, id); |
| 485 | | // memset(&sony_floppy[id], 0, sizeof(sony_floppy[id])); |
| 486 | | // |
| 487 | | // DEVICE_IMAGE_UNLOAD_NAME(floppy)(image); |
| 488 | | //} |
| 489 | | // |
| 474 | |
| 475 | static DEVICE_IMAGE_UNLOAD( sonydriv_floppy ) |
| 476 | { |
| 477 | int id; |
| 478 | running_device *fdc; |
| 479 | |
| 480 | /* locate the FDC */ |
| 481 | fdc = devtag_get_device(image.device().machine, "fdc"); |
| 482 | |
| 483 | id = floppy_get_drive_by_type(&image.device(),FLOPPY_TYPE_SONY); |
| 484 | save_track_data(fdc, id); |
| 485 | memset(&sony_floppy[id], 0, sizeof(sony_floppy[id])); |
| 486 | |
| 487 | DEVICE_IMAGE_UNLOAD_NAME(floppy)(image); |
| 488 | } |
| 489 | |
| 490 | 490 | DEVICE_GET_INFO( sonydriv ) |
| 491 | 491 | { |
| 492 | 492 | switch (state) |
| 493 | 493 | { |
| 494 | 494 | case DEVINFO_STR_NAME: strcpy(info->s, "Floppy Disk [Sony]"); break; |
| 495 | 495 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(sonydriv_floppy); break; |
| 496 | | //case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(sonydriv_floppy); break; |
| 496 | case DEVINFO_FCT_IMAGE_UNLOAD: info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(sonydriv_floppy); break; |
| 497 | 497 | |
| 498 | 498 | default: DEVICE_GET_INFO_CALL(floppy); break; |
| 499 | 499 | } |
src/mess/devices/thomflop.c
| r8322 | r8323 | |
| 719 | 719 | case 8: /* floppy status */ |
| 720 | 720 | { |
| 721 | 721 | UINT8 data = 0; |
| 722 | | device_image_interface* img = (device_image_interface*)to7_qdd_image(space->machine); |
| 722 | device_image_interface* img = dynamic_cast<device_image_interface *>(to7_qdd_image(space->machine)); |
| 723 | 723 | if ( ! img->exists() ) |
| 724 | 724 | data |= 0x40; /* disk present */ |
| 725 | 725 | if ( to7qdd->index_pulse ) |
| r8322 | r8323 | |
| 958 | 958 | if ( image != thmfc_floppy_image(image->machine) ) |
| 959 | 959 | return; |
| 960 | 960 | |
| 961 | | if ( thmfc_floppy_is_qdd((device_image_interface*)image) ) |
| 961 | if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(image))) |
| 962 | 962 | { |
| 963 | 963 | /* pulse each time the whole-disk spiraling track ends */ |
| 964 | 964 | floppy_drive_set_rpm( image, 16.92f /* 423/25 */ ); |
| r8322 | r8323 | |
| 1079 | 1079 | /* rebuild track if needed */ |
| 1080 | 1080 | if ( ! thmfc1->data_raw_size ) |
| 1081 | 1081 | { |
| 1082 | | if ( thmfc_floppy_is_qdd((device_image_interface*)thmfc_floppy_image(machine)) ) |
| 1082 | if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image(machine)))) |
| 1083 | 1083 | /* QDD: track = whole disk */ |
| 1084 | 1084 | thmfc1->data_raw_size = thom_qdd_make_disk ( thmfc_floppy_image(machine), thmfc1->data ); |
| 1085 | 1085 | else |
| r8322 | r8323 | |
| 1268 | 1268 | case 1: /* STAT1 */ |
| 1269 | 1269 | { |
| 1270 | 1270 | UINT8 data = 0; |
| 1271 | | device_image_interface * img = (device_image_interface*)thmfc_floppy_image(space->machine); |
| 1271 | device_image_interface * img = dynamic_cast<device_image_interface *>(thmfc_floppy_image(space->machine)); |
| 1272 | 1272 | int flags = floppy_drive_get_flag_state( &img->device(), -1 ); |
| 1273 | 1273 | if ( thmfc_floppy_is_qdd(img) ) |
| 1274 | 1274 | { |
| r8322 | r8323 | |
| 1331 | 1331 | case 0: /* CMD0 */ |
| 1332 | 1332 | { |
| 1333 | 1333 | int wsync = (data >> 4) & 1; |
| 1334 | | int qdd = thmfc_floppy_is_qdd((device_image_interface*)thmfc_floppy_image(space->machine)); |
| 1334 | int qdd = thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image(space->machine))); |
| 1335 | 1335 | chrn_id id; |
| 1336 | 1336 | thmfc1->formatting = (data >> 2) & 1; |
| 1337 | 1337 | LOG (( "%f $%04x thmfc_floppy_w: CMD0=$%02X dens=%s wsync=%i dsync=%i fmt=%i op=%i\n", |
| r8322 | r8323 | |
| 1438 | 1438 | thmfc1->drive = data & 2; |
| 1439 | 1439 | |
| 1440 | 1440 | img = thmfc_floppy_image(space->machine); |
| 1441 | | if ( thmfc_floppy_is_qdd((device_image_interface*)img) ) |
| 1441 | if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(img))) |
| 1442 | 1442 | { |
| 1443 | 1443 | motor = !(data & 0x40); |
| 1444 | 1444 | /* no side select & no seek for QDD */ |
| r8322 | r8323 | |
| 1476 | 1476 | |
| 1477 | 1477 | case 3: /* WDATA */ |
| 1478 | 1478 | thmfc1->wsync = data; |
| 1479 | | if ( thmfc_floppy_is_qdd((device_image_interface*)thmfc_floppy_image(space->machine)) ) |
| 1479 | if ( thmfc_floppy_is_qdd(dynamic_cast<device_image_interface *>(thmfc_floppy_image(space->machine)))) |
| 1480 | 1480 | thmfc_floppy_qdd_write_byte( space->machine, data ); |
| 1481 | 1481 | else if ( thmfc1->op==THMFC1_OP_WRITE_SECT ) |
| 1482 | 1482 | thmfc_floppy_write_byte( space->machine, data ); |
src/mess/machine/hp48.c
| r8322 | r8323 | |
| 194 | 194 | /* end of send event */ |
| 195 | 195 | static TIMER_CALLBACK( hp48_rs232_byte_sent_cb ) |
| 196 | 196 | { |
| 197 | | device_image_interface *xmodem = (device_image_interface*)devtag_get_device(machine, "rs232_x"); |
| 198 | | device_image_interface *kermit = (device_image_interface*)devtag_get_device(machine, "rs232_k"); |
| 197 | device_image_interface *xmodem = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "rs232_x")); |
| 198 | device_image_interface *kermit = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "rs232_k")); |
| 199 | 199 | |
| 200 | 200 | LOG_SERIAL(( "%f hp48_rs232_byte_sent_cb: end of send, data=%02x\n", |
| 201 | 201 | attotime_to_double(timer_get_time(machine)), param )); |
| r8322 | r8323 | |
| 594 | 594 | { |
| 595 | 595 | /* second nibble of received data */ |
| 596 | 596 | |
| 597 | | device_image_interface *xmodem = (device_image_interface *)devtag_get_device(space->machine, "rs232_x"); |
| 598 | | device_image_interface *kermit = (device_image_interface *)devtag_get_device(space->machine, "rs232_k"); |
| 597 | device_image_interface *xmodem = dynamic_cast<device_image_interface *>(devtag_get_device(space->machine, "rs232_x")); |
| 598 | device_image_interface *kermit = dynamic_cast<device_image_interface *>(devtag_get_device(space->machine, "rs232_k")); |
| 599 | 599 | |
| 600 | 600 | hp48_io[0x11] &= ~1; /* clear byte received */ |
| 601 | 601 | data = hp48_io[offset]; |
src/mess/machine/thomson.c
| r8322 | r8323 | |
| 86 | 86 | static int to7_get_cassette ( running_machine *machine ) |
| 87 | 87 | { |
| 88 | 88 | running_device* img = thom_cassette_img(machine); |
| 89 | | device_image_interface *image = (device_image_interface*)img; |
| 89 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 90 | 90 | if ( image->exists() ) |
| 91 | 91 | { |
| 92 | 92 | cassette_image* cass = cassette_get_image( img ); |
| r8322 | r8323 | |
| 187 | 187 | static int mo5_get_cassette ( running_machine *machine ) |
| 188 | 188 | { |
| 189 | 189 | running_device* img = thom_cassette_img(machine); |
| 190 | | device_image_interface *image = (device_image_interface*)img; |
| 190 | device_image_interface *image = dynamic_cast<device_image_interface *>(img); |
| 191 | 191 | |
| 192 | 192 | if ( image->exists() ) |
| 193 | 193 | { |
| r8322 | r8323 | |
| 771 | 771 | static to7_io_dev to7_io_mode( running_machine *machine ) |
| 772 | 772 | { |
| 773 | 773 | running_device *centronics = devtag_get_device(machine, "centronics"); |
| 774 | | device_image_interface *serial = (device_image_interface*)devtag_get_device(machine, "cc90232"); |
| 774 | device_image_interface *serial = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cc90232")); |
| 775 | 775 | |
| 776 | 776 | if (centronics_pe_r(centronics) == TRUE) |
| 777 | 777 | return TO7_IO_CENTRONICS; |
src/mess/machine/snescart.c
| r8322 | r8323 | |
| 128 | 128 | |
| 129 | 129 | battery_ram = (UINT8*)malloc(state->cart[0].sram_max); |
| 130 | 130 | ptr = battery_ram; |
| 131 | | device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cart"); |
| 131 | device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart")); |
| 132 | 132 | image->battery_load(battery_ram, state->cart[0].sram_max, 0xff); |
| 133 | 133 | |
| 134 | 134 | if (state->cart[0].mode == SNES_MODE_20) |
| r8322 | r8323 | |
| 205 | 205 | ptr += 0x2000; |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | | device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "cart"); |
| 208 | device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "cart")); |
| 209 | 209 | image->battery_save(battery_ram, state->cart[0].sram_max); |
| 210 | 210 | |
| 211 | 211 | free(battery_ram); |
| r8322 | r8323 | |
| 235 | 235 | |
| 236 | 236 | battery_ram = (UINT8*)malloc(0x20000); |
| 237 | 237 | ptr = battery_ram; |
| 238 | | device_image_interface *image = (device_image_interface*)devtag_get_device(machine, cart_tag); |
| 238 | device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, cart_tag)); |
| 239 | 239 | image->battery_load(battery_ram, 0x20000, 0); |
| 240 | 240 | |
| 241 | 241 | if (strcmp(cart_tag, "slot_a") == 0) |
| r8322 | r8323 | |
| 271 | 271 | { |
| 272 | 272 | memmove(ptr + ii * 0x8000, &snes_ram[0x608000 + (ii * 0x010000)], 0x8000); |
| 273 | 273 | } |
| 274 | | device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "slot_a"); |
| 274 | device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "slot_a")); |
| 275 | 275 | image->battery_save(battery_ram, 0x20000); |
| 276 | 276 | } |
| 277 | 277 | |
| r8322 | r8323 | |
| 281 | 281 | { |
| 282 | 282 | memmove(ptr + ii * 0x8000, &snes_ram[0x708000 + (ii * 0x010000)], 0x8000); |
| 283 | 283 | } |
| 284 | | device_image_interface *image = (device_image_interface*)devtag_get_device(machine, "slot_b"); |
| 284 | device_image_interface *image = dynamic_cast<device_image_interface *>(devtag_get_device(machine, "slot_b")); |
| 285 | 285 | image->battery_save(battery_ram, 0x20000); |
| 286 | 286 | } |
| 287 | 287 | |