| 639 | } |
| 640 | |
| 641 | static void check_changes (int unitnum) |
| 642 | { |
| 643 | struct blkdevstate *st = &state[unitnum]; |
| 644 | bool changed = false; |
| 645 | bool gotsem = false; |
| 646 | |
| 647 | if (st->device_func == NULL) |
| 648 | return; |
| 649 | |
| 650 | if (st->showstatusline) { |
| 651 | cd_statusline_label(unitnum); |
| 652 | st->showstatusline = 0; |
| 653 | } |
| 654 | |
| 655 | if (st->delayed) { |
| 656 | st->delayed--; |
| 657 | if (st->delayed == 0) |
| 658 | write_log (_T("CD: startup delayed insert '%s'\n"), currprefs.cdslots[unitnum].name[0] ? currprefs.cdslots[unitnum].name : _T("<EMPTY>")); |
| 659 | return; |
| 660 | } |
| 661 | |
| 662 | if (_tcscmp (changed_prefs.cdslots[unitnum].name, currprefs.cdslots[unitnum].name) != 0) |
| 663 | changed = true; |
| 664 | if (!changed && changed_prefs.cdslots[unitnum].name[0] == 0 && changed_prefs.cdslots[unitnum].inuse != currprefs.cdslots[unitnum].inuse) |
| 665 | changed = true; |
| 666 | |
| 667 | if (changed) { |
| 668 | bool wasimage = currprefs.cdslots[unitnum].name[0] != 0; |
| 669 | if (st->sema) |
| 670 | gotsem = getsem (unitnum, true); |
| 671 | st->cdimagefileinuse = changed_prefs.cdslots[unitnum].inuse; |
| 672 | _tcscpy (st->newimagefile, changed_prefs.cdslots[unitnum].name); |
| 673 | changed_prefs.cdslots[unitnum].name[0] = currprefs.cdslots[unitnum].name[0] = 0; |
| 674 | currprefs.cdslots[unitnum].inuse = changed_prefs.cdslots[unitnum].inuse; |
| 675 | int pollmode = 0; |
| 676 | st->imagechangetime = 3 * 50; |
| 677 | struct device_info di; |
| 678 | st->device_func->info (unitnum, &di, 0, -1); |
| 679 | if (st->wasopen >= 0) |
| 680 | st->wasopen = di.open ? 1 : 0; |
| 681 | if (st->wasopen) { |
| 682 | st->device_func->closedev (unitnum); |
| 683 | st->wasopen = -1; |
| 684 | if (currprefs.scsi) { |
| 685 | scsi_do_disk_change (unitnum, 0, &pollmode); |
| 686 | if (pollmode) |
| 687 | st->imagechangetime = 8 * 50; |
| 688 | if (filesys_do_disk_change (unitnum, 0)) { |
| 689 | st->imagechangetime = st->newimagefile[0] ? 3 * 50 : 0; |
| 690 | pollmode = 0; |
| 691 | } |
| 692 | } |
| 693 | } |
| 694 | write_log (_T("CD: eject (%s) open=%d\n"), pollmode ? _T("slow") : _T("fast"), st->wasopen ? 1 : 0); |
| 695 | if (wasimage) |
| 696 | statusline_add_message(STATUSTYPE_CD, _T("CD%d: -"), unitnum); |
| 697 | |
| 698 | #ifdef RETROPLATFORM |
no test coverage detected