From 44e7e65ab5ec609fe5993f8f32a06c23f31be868 Mon Sep 17 00:00:00 2001 From: Ulf Wohlers Date: Fri, 14 Feb 2003 22:16:19 +0000 Subject: [PATCH] Added Int 21/67: Set file handle count Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@665 --- include/dos_inc.h | 3 ++- src/dos/dos.cpp | 11 +++++++---- src/dos/dos_classes.cpp | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/dos_inc.h b/include/dos_inc.h index 575bb79c..af5abcf7 100644 --- a/include/dos_inc.h +++ b/include/dos_inc.h @@ -259,7 +259,8 @@ public: void SetFCB1 (RealPt src); void SetFCB2 (RealPt src); void SetCommandTail (RealPt src); - + bool SetNumFiles (Bit16u fileNum); + private: #pragma pack(1) struct sPSP { diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index 15cc5b5a..83f14cf6 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -784,11 +784,14 @@ static Bitu DOS_21Handler(void) { } LOG_ERROR("DOS:Setting code page table is not supported"); break; - case 0x67: /* Set handle countr */ + case 0x67: /* Set handle count */ /* Weird call to increase amount of file handles needs to allocate memory if >20 */ - LOG_DEBUG("DOS:67:Set Handle Count not working"); - CALLBACK_SCF(false); - break; + { + DOS_PSP psp(dos.psp); + psp.SetNumFiles(reg_bx); + CALLBACK_SCF(false); + break; + }; case 0x69: /* Get/Set disk serial number */ { switch(reg_al) { diff --git a/src/dos/dos_classes.cpp b/src/dos/dos_classes.cpp index 386688ff..f03bf19c 100644 --- a/src/dos/dos_classes.cpp +++ b/src/dos/dos_classes.cpp @@ -197,6 +197,20 @@ void DOS_PSP::SetFCB2(RealPt src) if (src) MEM_BlockCopy(PhysMake(seg,offsetof(sPSP,fcb2)),Real2Phys(src),16); }; +bool DOS_PSP::SetNumFiles(Bit16u fileNum) +{ + // Allocate needed paragraphs + Bit16u para = (fileNum/16)+((fileNum%16)>0); + RealPt data = RealMake(DOS_GetMemory(para),0); + sSave(sPSP,file_table,data); + sSave(sPSP,max_files,fileNum); + if (fileNum>20) { + for (Bit16u i=0; i<20; i++) SetFileHandle(i,sGet(sPSP,files[i])); + for (i=20; i