fix Win9x shutdown freeze after changing CD image

This commit is contained in:
Wengier
2021-11-10 19:41:03 -05:00
parent 2564ab0c80
commit f02bf026ba
7 changed files with 50 additions and 9 deletions

View File

@@ -53,6 +53,8 @@
Fixes corrupt graphics in the PC Booter version
of Apple Panic. (Allofich)
- Fixed possible crash with printing. (jamesbond3142)
- Fixed possible freeze when shutting down Windows 9x
after changing a CD image from the menu. (Wengier)
- Fixed config option windowposition=x,y not working
in Linux/macOS SDL1 builds. (Wengier)
- Make memory B0000-B7FFF unmapped for the CGA

View File

@@ -13,6 +13,7 @@ extern void (*ide_inits[MAX_IDE_CONTROLLERS])(Section *);
void IDE_Auto(signed char &index,bool &slave);
void IDE_CDROM_Attach(signed char index,bool slave,unsigned char drive_index);
void IDE_CDROM_Detach(unsigned char drive_index);
void IDE_CDROM_Detach_Ret(signed char &indexret,bool &slaveret,unsigned char drive_index);
void IDE_Hard_Disk_Attach(signed char index,bool slave,unsigned char bios_disk_index);
void IDE_Hard_Disk_Detach(unsigned char bios_disk_index);
void IDE_ResetDiskByBIOS(unsigned char disk);

View File

@@ -509,16 +509,22 @@ void MenuBrowseCDImage(char drive, int num) {
lTheOpenFileName = tinyfd_openFileDialog("Select a CD image file","",14,lFilterPatterns,lFilterDescription,0);
if (lTheOpenFileName) {
uint8_t mediaid = 0xF8;
int error = -1;
qmount = true;
DOS_Drive* newDrive = new isoDrive(drive, lTheOpenFileName, mediaid, error);
qmount = false;
if (error) {
tinyfd_messageBox("Error","Could not mount the selected CD image.","ok","error", 1);
return;
isoDrive *cdrom = dynamic_cast<isoDrive*>(Drives[drive-'A']);
DOS_Drive *newDrive = NULL;
if (cdrom && dos_kernel_disabled) {
cdrom->setFileName(lTheOpenFileName);
} else {
uint8_t mediaid = 0xF8;
int error = -1;
DOS_Drive* newDrive = new isoDrive(drive, lTheOpenFileName, mediaid, error);
if (error) {
tinyfd_messageBox("Error","Could not mount the selected CD image.","ok","error", 1);
chdir( Temp_CurrentDir );
return;
}
cdrom = dynamic_cast<isoDrive*>(newDrive);
}
DriveManager::ChangeDisk(drive-'A', newDrive);
if (cdrom) DriveManager::ChangeDisk(drive-'A', cdrom);
}
chdir( Temp_CurrentDir );
#endif
@@ -557,6 +563,7 @@ void MenuBrowseFDImage(char drive, int num, int type) {
fatDrive *newDrive = new fatDrive(lTheOpenFileName, 0, 0, 0, 0, options);
if (!newDrive->created_successfully) {
tinyfd_messageBox("Error","Could not mount the selected floppy disk image.","ok","error", 1);
chdir( Temp_CurrentDir );
return;
}
DriveManager::ChangeDisk(drive-'A', newDrive);

View File

@@ -192,6 +192,12 @@ isoDrive::isoDrive(char driveLetter, const char* fileName, uint8_t mediaid, int&
isoDrive::~isoDrive() { }
void isoDrive::setFileName(const char* fileName) {
safe_strncpy(this->fileName, fileName, CROSS_LEN);
strcpy(info, "isoDrive ");
strcat(info, fileName);
}
int isoDrive::UpdateMscdex(char driveLetter, const char* path, uint8_t& subUnit) {
if (MSCDEX_HasDrive(driveLetter)) {
subUnit = MSCDEX_GetSubUnit(driveLetter);

View File

@@ -25,6 +25,7 @@
#include "mapper.h"
#include "support.h"
#include "control.h"
#include "ide.h"
bool wild_match(const char *haystack, char *needle) {
size_t max, i;
@@ -279,6 +280,10 @@ void DriveManager::AppendDisk(int drive, DOS_Drive* disk) {
void DriveManager::ChangeDisk(int drive, DOS_Drive* disk) {
DriveInfo& driveInfo = driveInfos[drive];
if (Drives[drive]==NULL||disk==NULL||!driveInfo.disks.size()) return;
isoDrive *cdrom = dynamic_cast<isoDrive*>(Drives[drive]);
bool slave=false;
signed char index=-1;
if (cdrom) IDE_CDROM_Detach_Ret(index,slave,drive);
strcpy(disk->curdir,driveInfo.disks[driveInfo.currentDisk]->curdir);
disk->Activate();
disk->UpdateDPB(currentDrive);
@@ -287,6 +292,7 @@ void DriveManager::ChangeDisk(int drive, DOS_Drive* disk) {
Drives[drive] = disk;
Drives[drive]->EmptyCache();
Drives[drive]->MediaChange();
if (cdrom && index>-1) IDE_CDROM_Attach(index,slave,drive);
fatDrive *fdp = dynamic_cast<fatDrive*>(Drives[drive]);
if (drive<2 && fdp && fdp->loadedDisk) {
if (imageDiskList[drive]) {

View File

@@ -662,6 +662,7 @@ public:
virtual bool isRemovable(void);
virtual Bits UnMount(void);
bool readSector(uint8_t *buffer, uint32_t sector);
void setFileName(const char* fileName);
virtual char const* GetLabel(void) {return discLabel;};
virtual void Activate(void);
private:

View File

@@ -2265,6 +2265,24 @@ void IDE_CDROM_Detach(unsigned char drive_index) {
}
}
void IDE_CDROM_Detach_Ret(signed char &indexret,bool &slaveret,unsigned char drive_index) {
indexret = -1;
for (int index = 0; index < MAX_IDE_CONTROLLERS; index++) {
IDEController *c = idecontroller[index];
if (c)
for (int slave = 0; slave < 2; slave++) {
IDEATAPICDROMDevice *dev;
dev = dynamic_cast<IDEATAPICDROMDevice*>(c->device[slave]);
if (dev && dev->drive_index == drive_index) {
delete dev;
c->device[slave] = NULL;
slaveret = slave;
indexret = index;
}
}
}
}
void IDE_CDROM_DetachAll() {
for (int index = 0; index < MAX_IDE_CONTROLLERS; index++) {
IDEController *c = idecontroller[index];