Skip to content

Commit 97fbed5

Browse files
Merge pull request #3678 from tbr/fix-3535-and-3347
Fix issues 3535 (dosbox-x hang on zip-mounted drives) and 3347 (minor bug fix and related)
2 parents 0031a6f + a754da6 commit 97fbed5

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

src/dos/dos.cpp

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,30 +1945,24 @@ static Bitu DOS_21Handler(void) {
19451945
}
19461946

19471947
dos.echo=true;
1948-
1949-
if(handle >= DOS_FILES) {
1950-
DOS_SetError(DOSERR_INVALID_HANDLE);
1951-
} else
1952-
if(!Files[handle] || !Files[handle]->IsOpen())
1948+
if(handle >= DOS_FILES || !Files[handle] || !Files[handle]->IsOpen()) {
19531949
DOS_SetError(DOSERR_INVALID_HANDLE);
1954-
else if(Files[handle]->GetInformation() & EXT_DEVICE_BIT)
1955-
{
1950+
}
1951+
else if(Files[handle]->GetInformation() & EXT_DEVICE_BIT) {
19561952
fRead = !(((DOS_ExtDevice*)Files[handle])->CallDeviceFunction(4, 26, SegValue(ds), reg_dx, toread) & 0x8000);
19571953
#if defined(USE_TTF)
1958-
if(fRead && ttf.inUse && reg_bx == WPvga512CHMhandle)
1959-
MEM_BlockRead(SegPhys(ds) + reg_dx, dos_copybuf, toread);
1954+
fRead &= ttf.inUse && reg_bx == WPvga512CHMhandle;
19601955
#endif
19611956
}
1962-
else
1963-
{
1964-
if((fRead = DOS_ReadFile(reg_bx, dos_copybuf, &toread)))
1965-
MEM_BlockWrite(SegPhys(ds) + reg_dx, dos_copybuf, toread);
1957+
else {
1958+
fRead = DOS_ReadFile(reg_bx, dos_copybuf, &toread);
19661959
}
19671960

19681961
if (fRead) {
1962+
MEM_BlockWrite(SegPhys(ds) + reg_dx, dos_copybuf, toread);
19691963
reg_ax=toread;
19701964
#if defined(USE_TTF)
1971-
if (ttf.inUse && reg_bx == WPvga512CHMhandle){
1965+
if (ttf.inUse && reg_bx == WPvga512CHMhandle) {
19721966
if (toread == 26 || toread == 2) {
19731967
if (toread == 2)
19741968
WP5chars = *(uint16_t*)dos_copybuf;
@@ -2037,17 +2031,15 @@ static Bitu DOS_21Handler(void) {
20372031
{
20382032
uint32_t handle = RealHandle(reg_bx);
20392033

2040-
if(handle >= DOS_FILES) {
2034+
if(handle >= DOS_FILES || !Files[handle] || !Files[handle]->IsOpen()) {
20412035
DOS_SetError(DOSERR_INVALID_HANDLE);
20422036
}
2043-
else
2044-
if(!Files[handle] || !Files[handle]->IsOpen())
2045-
DOS_SetError(DOSERR_INVALID_HANDLE);
2046-
else if(Files[handle]->GetInformation() & EXT_DEVICE_BIT)
2047-
{
2048-
fWritten = !(((DOS_ExtDevice*)Files[handle])->CallDeviceFunction(8, 26, SegValue(ds), reg_dx, towrite) & 0x8000);
2049-
}
2050-
else fWritten = DOS_WriteFile(reg_bx, dos_copybuf, &towrite);
2037+
else if(Files[handle]->GetInformation() & EXT_DEVICE_BIT) {
2038+
fWritten = !(((DOS_ExtDevice*)Files[handle])->CallDeviceFunction(8, 26, SegValue(ds), reg_dx, towrite) & 0x8000);
2039+
}
2040+
else {
2041+
fWritten = DOS_WriteFile(reg_bx, dos_copybuf, &towrite);
2042+
}
20512043
}
20522044
if (fWritten) {
20532045
reg_ax=towrite;

src/dos/drive_physfs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ bool physfsDrive::FileOpen(DOS_File * * file,const char * name,uint32_t flags) {
409409
return false;
410410
}
411411

412-
*file=new physfsFile(name,hand,0x202,newname,false);
412+
*file=new physfsFile(name,hand,0x2,newname,false);
413413
(*file)->flags=flags; //for the inheritance flag and maybe check for others.
414414
return true;
415415
}
@@ -449,7 +449,7 @@ bool physfsDrive::FileCreate(DOS_File * * file,const char * name,uint16_t attrib
449449
}
450450

451451
/* Make the 16 bit device information */
452-
*file=new physfsFile(name,hand,0x202,newname,true);
452+
*file=new physfsFile(name,hand,0x2,newname,true);
453453
(*file)->flags=OPEN_READWRITE;
454454
if(!existing_file) {
455455
strcpy(newname,basedir);

0 commit comments

Comments
 (0)