aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/biosvar.h5
-rw-r--r--src/boot.c2
-rw-r--r--src/cdrom.c22
-rw-r--r--src/disk.c2
4 files changed, 15 insertions, 16 deletions
diff --git a/src/biosvar.h b/src/biosvar.h
index 9469c9aa..b200645f 100644
--- a/src/biosvar.h
+++ b/src/biosvar.h
@@ -175,9 +175,8 @@ struct dpte_s {
struct cdemu_s {
u8 active;
u8 media;
- u8 emulated_drive;
- u8 controller_index;
- u16 device_spec;
+ u8 emulated_extdrive;
+ u8 emulated_driveid;
u32 ilba;
u16 buffer_segment;
u16 load_segment;
diff --git a/src/boot.c b/src/boot.c
index b4067bbf..bfd7f066 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -370,7 +370,7 @@ boot_cdrom(struct ipl_entry_s *ie)
}
u16 ebda_seg = get_ebda_seg();
- u8 bootdrv = GET_EBDA2(ebda_seg, cdemu.emulated_drive);
+ u8 bootdrv = GET_EBDA2(ebda_seg, cdemu.emulated_extdrive);
u16 bootseg = GET_EBDA2(ebda_seg, cdemu.load_segment);
/* Canonicalize bootseg:bootip */
u16 bootip = (bootseg & 0x0fff) << 4;
diff --git a/src/cdrom.c b/src/cdrom.c
index 5f03b8db..8823f9b7 100644
--- a/src/cdrom.c
+++ b/src/cdrom.c
@@ -225,8 +225,7 @@ cdemu_13(struct bregs *regs)
//debug_stub(regs);
u16 ebda_seg = get_ebda_seg();
- u8 driveid = GET_EBDA2(ebda_seg, cdemu.controller_index) * 2;
- driveid += GET_EBDA2(ebda_seg, cdemu.device_spec);
+ u8 driveid = GET_EBDA2(ebda_seg, cdemu.emulated_driveid);
switch (regs->ah) {
case 0x02: cdemu_1302(regs, driveid); break;
@@ -279,11 +278,13 @@ cdemu_134b(struct bregs *regs)
u16 ebda_seg = get_ebda_seg();
SET_INT13ET(regs, size, 0x13);
SET_INT13ET(regs, media, GET_EBDA2(ebda_seg, cdemu.media));
- SET_INT13ET(regs, emulated_drive, GET_EBDA2(ebda_seg, cdemu.emulated_drive));
- SET_INT13ET(regs, controller_index
- , GET_EBDA2(ebda_seg, cdemu.controller_index));
+ SET_INT13ET(regs, emulated_drive
+ , GET_EBDA2(ebda_seg, cdemu.emulated_extdrive));
+ u8 driveid = GET_EBDA2(ebda_seg, cdemu.emulated_driveid);
+ u8 cntl_id = GET_GLOBAL(Drives.drives[driveid].cntl_id);
+ SET_INT13ET(regs, controller_index, cntl_id / 2);
+ SET_INT13ET(regs, device_spec, cntl_id % 2);
SET_INT13ET(regs, ilba, GET_EBDA2(ebda_seg, cdemu.ilba));
- SET_INT13ET(regs, device_spec, GET_EBDA2(ebda_seg, cdemu.device_spec));
SET_INT13ET(regs, buffer_segment, GET_EBDA2(ebda_seg, cdemu.buffer_segment));
SET_INT13ET(regs, load_segment, GET_EBDA2(ebda_seg, cdemu.load_segment));
SET_INT13ET(regs, sector_count, GET_EBDA2(ebda_seg, cdemu.sector_count));
@@ -454,8 +455,7 @@ cdrom_boot(int cdid)
u8 media = buffer[0x21];
SET_EBDA2(ebda_seg, cdemu.media, media);
- SET_EBDA2(ebda_seg, cdemu.controller_index, driveid/2);
- SET_EBDA2(ebda_seg, cdemu.device_spec, driveid%2);
+ SET_EBDA2(ebda_seg, cdemu.emulated_driveid, driveid);
u16 boot_segment = *(u16*)&buffer[0x22];
if (!boot_segment)
@@ -479,7 +479,7 @@ cdrom_boot(int cdid)
if (media == 0) {
// No emulation requested - return success.
- SET_EBDA2(ebda_seg, cdemu.emulated_drive, 0xE0 + cdid);
+ SET_EBDA2(ebda_seg, cdemu.emulated_extdrive, 0xE0 + cdid);
return 0;
}
@@ -491,7 +491,7 @@ cdrom_boot(int cdid)
// number of devices
if (media < 4) {
// Floppy emulation
- SET_EBDA2(ebda_seg, cdemu.emulated_drive, 0x00);
+ SET_EBDA2(ebda_seg, cdemu.emulated_extdrive, 0x00);
SETBITS_BDA(equipment_list_flags, 0x41);
switch (media) {
@@ -513,7 +513,7 @@ cdrom_boot(int cdid)
}
} else {
// Harddrive emulation
- SET_EBDA2(ebda_seg, cdemu.emulated_drive, 0x80);
+ SET_EBDA2(ebda_seg, cdemu.emulated_extdrive, 0x80);
SET_BDA(hdcount, GET_BDA(hdcount) + 1);
// Peak at partition table to get chs.
diff --git a/src/disk.c b/src/disk.c
index 32962246..0cd2aca4 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -750,7 +750,7 @@ handle_13(struct bregs *regs)
}
u16 ebda_seg = get_ebda_seg();
if (GET_EBDA2(ebda_seg, cdemu.active)) {
- u8 emudrive = GET_EBDA2(ebda_seg, cdemu.emulated_drive);
+ u8 emudrive = GET_EBDA2(ebda_seg, cdemu.emulated_extdrive);
if (extdrive == emudrive) {
cdemu_13(regs);
return;