Skip to content

Commit 3ccde21

Browse files
committed
Merge remote-tracking branch 'upstream/master' into stable
2 parents 518d8c5 + b29f171 commit 3ccde21

3 files changed

Lines changed: 38 additions & 14 deletions

File tree

ide.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,11 @@ void ide_get_regs(ide_config *ide)
160160

161161
void ide_set_regs(ide_config *ide)
162162
{
163-
if (!(ide->regs.status & (ATA_STATUS_BSY | ATA_STATUS_ERR))) ide->regs.status |= ATA_STATUS_DSC;
164-
165-
// For ATAPI (packet) devices, status bit 4 is the SERVICE bit, not DSC. We never run
166-
// overlapped commands, so SERVICE must read 0. Force it low for CD drives, matching 86Box
167-
// ide_status() which masks DSC out of every ATAPI status read (hdc_ide.c). Win9x ESDI_506
168-
// otherwise reads the permanent bit-4 as "overlapped-command SERVICE pending", rejects the
169-
// channel, and the device fails to start (Device Manager Code 10).
170-
if (ide->drive[ide->regs.drv].cd) ide->regs.status &= ~ATA_STATUS_DSC;
163+
// Auto-assert DSC for non-CD drives only; let each ATAPI command set its own status.
164+
if (!ide->drive[ide->regs.drv].cd && !(ide->regs.status & (ATA_STATUS_BSY | ATA_STATUS_ERR)))
165+
{
166+
ide->regs.status |= ATA_STATUS_DSC;
167+
}
171168

172169
uint8_t data[12] =
173170
{
@@ -1016,7 +1013,8 @@ void ide_io(int num, int req)
10161013
else if (ide->state == IDE_STATE_WAIT_PKT_RD)
10171014
{
10181015
if (ide->regs.pkt_cnt) cdrom_read(ide);
1019-
else cdrom_reply(ide, 0);
1016+
// A successful data-phase completion must report GOOD, not UNIT ATTENTION.
1017+
else cdrom_reply(ide, 0, 0, 0, false);
10201018
}
10211019
else if (ide->state == IDE_STATE_WAIT_PKT_MODE)
10221020
{
@@ -1049,7 +1047,8 @@ void ide_io(int num, int req)
10491047

10501048
ide_get_regs(ide);
10511049
ide->regs.head = 0;
1052-
ide->regs.error = 0;
1050+
// ATAPI posts diagnostic code 01h after a bus reset; an ATA HDD posts 0.
1051+
ide->regs.error = ide->drive[ide->regs.drv].cd ? 1 : 0;
10531052
ide->regs.sector = 1;
10541053
ide->regs.sector_count = 1;
10551054
ide->regs.cylinder = (!ide->drive[ide->regs.drv].present) ? 0xFFFF : ide->drive[ide->regs.drv].cd ? 0xEB14 : 0x0000;

ide_cdrom.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,11 +1579,14 @@ int cdrom_handle_cmd(ide_config *ide)
15791579
ide->regs.sector_count = 1;
15801580
ide->regs.cylinder = 0xEB14;
15811581
ide->regs.head = 0;
1582+
// ATAPI diagnostic code 01h after DEVICE RESET.
1583+
ide->regs.error = 1;
15821584
ide->regs.io_size = 0;
1583-
ide->regs.status = ATA_STATUS_RDY | ATA_STATUS_DSC;
1585+
// Present status 0x00 (no DRDY/DSC), matching real ATAPI HW; routes OAKCDROM to signature detect.
1586+
ide->regs.status = 0;
15841587
ide_set_regs(ide);
15851588
break;
1586-
1589+
15871590
case 0xEF: // set features
15881591
switch(ide->regs.features)
15891592
{

support/3do/3do.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,28 @@ void p3do_poll()
5252
}
5353
}
5454

55-
static char buf[1024];
55+
static char buf[2048];
56+
57+
static void p3do_get_save_without_disk(char *path)
58+
{
59+
char *p1, *p2;
60+
61+
if ((p1 = strstr(path, "disc")) != 0 || (p1 = strstr(path, "Disc")) != 0 || (p1 = strstr(path, "DISC")) != 0 ||
62+
(p1 = strstr(path, "disk")) != 0 || (p1 = strstr(path, "Disk")) != 0 || (p1 = strstr(path, "DISK")) != 0)
63+
{
64+
p2 = p1 + 4;
65+
66+
if (p1 > path && *(--p1) == '(') p1--;
67+
if (p1 > path && *(--p1) == ' ') p1--;
68+
if (*p2 == ' ') p2++;
69+
if ((*p2 >= '0' && *p2 <= '9') || (*p2 >= 'a' && *p2 <= 'f') || (*p2 >= 'A' && *p2 <= 'F')) {
70+
p2++;
71+
if (*p2 == ')') p2++;
72+
p1++;
73+
strcpy(p1, p2);
74+
}
75+
}
76+
}
5677

5778
static void p3do_mount_save(const char *filename)
5879
{
@@ -61,6 +82,7 @@ static void p3do_mount_save(const char *filename)
6182
if (strlen(filename))
6283
{
6384
FileGenerateSavePath(filename, buf);
85+
p3do_get_save_without_disk(buf);
6486
#ifdef P3DO_DEBUG
6587
printf("Saturn save filename = %s\n", buf);
6688
#endif // P3DO_DEBUG
@@ -96,7 +118,7 @@ void p3do_set_image(int num, const char *filename)
96118
p3docdd.Unload();
97119
p3docdd.Reset();
98120

99-
int same_game = *filename && *last_dir && !strncmp(last_dir, filename, strlen(last_dir));
121+
int same_game = 0;//*filename && *last_dir && !strncmp(last_dir, filename, strlen(last_dir));
100122
strcpy(last_dir, filename);
101123
char *p = strrchr(last_dir, '/');
102124
if (p) *p = 0;

0 commit comments

Comments
 (0)