From 1589c86ebedef4a9bd6784a52a7d41fa2d5acdf9 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Wed, 5 Jan 2011 19:48:18 +0000 Subject: [PATCH] Some FCB read/write refinements. Stop exiting on weird int 21 0x33 calls. (ripsaw) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3666 --- include/dos_inc.h | 4 ++-- src/dos/dos.cpp | 18 +++++++++++++----- src/dos/dos_files.cpp | 26 +++++++++++++------------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/include/dos_inc.h b/include/dos_inc.h index 290d76b3..5199e506 100644 --- a/include/dos_inc.h +++ b/include/dos_inc.h @@ -176,8 +176,8 @@ bool DOS_FCBFindFirst(Bit16u seg,Bit16u offset); bool DOS_FCBFindNext(Bit16u seg,Bit16u offset); Bit8u DOS_FCBRead(Bit16u seg,Bit16u offset, Bit16u numBlocks); Bit8u DOS_FCBWrite(Bit16u seg,Bit16u offset,Bit16u numBlocks); -Bit8u DOS_FCBRandomRead(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore); -Bit8u DOS_FCBRandomWrite(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore); +Bit8u DOS_FCBRandomRead(Bit16u seg,Bit16u offset,Bit16u * numRec,bool restore); +Bit8u DOS_FCBRandomWrite(Bit16u seg,Bit16u offset,Bit16u * numRec,bool restore); bool DOS_FCBGetFileSize(Bit16u seg,Bit16u offset); bool DOS_FCBDeleteFile(Bit16u seg,Bit16u offset); bool DOS_FCBRenameFile(Bit16u seg, Bit16u offset); diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index fb490c27..318095b2 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -319,11 +319,17 @@ static Bitu DOS_21Handler(void) { if (!DOS_GetAllocationInfo(reg_dl,®_cx,®_al,®_dx)) reg_al=0xff; break; case 0x21: /* Read random record from FCB */ - reg_al = DOS_FCBRandomRead(SegValue(ds),reg_dx,1,true); + { + Bit16u toread=1; + reg_al = DOS_FCBRandomRead(SegValue(ds),reg_dx,&toread,true); + } LOG(LOG_FCB,LOG_NORMAL)("DOS:0x21 FCB-Random read used, result:al=%d",reg_al); break; case 0x22: /* Write random record to FCB */ - reg_al=DOS_FCBRandomWrite(SegValue(ds),reg_dx,1,true); + { + Bit16u towrite=1; + reg_al=DOS_FCBRandomWrite(SegValue(ds),reg_dx,&towrite,true); + } LOG(LOG_FCB,LOG_NORMAL)("DOS:0x22 FCB-Random write used, result:al=%d",reg_al); break; case 0x23: /* Get file size for FCB */ @@ -334,11 +340,11 @@ static Bitu DOS_21Handler(void) { DOS_FCBSetRandomRecord(SegValue(ds),reg_dx); break; case 0x27: /* Random block read from FCB */ - reg_al = DOS_FCBRandomRead(SegValue(ds),reg_dx,reg_cx,false); + reg_al = DOS_FCBRandomRead(SegValue(ds),reg_dx,®_cx,false); LOG(LOG_FCB,LOG_NORMAL)("DOS:0x27 FCB-Random(block) read used, result:al=%d",reg_al); break; case 0x28: /* Random Block write to FCB */ - reg_al=DOS_FCBRandomWrite(SegValue(ds),reg_dx,reg_cx,false); + reg_al=DOS_FCBRandomWrite(SegValue(ds),reg_dx,®_cx,false); LOG(LOG_FCB,LOG_NORMAL)("DOS:0x28 FCB-Random(block) write used, result:al=%d",reg_al); break; case 0x29: /* Parse filename into FCB */ @@ -462,7 +468,9 @@ static Bitu DOS_21Handler(void) { reg_dh=0x10; /* Dos in HMA */ break; default: - E_Exit("DOS:Illegal 0x33 Call %2X",reg_al); + LOG(LOG_DOSMISC,LOG_ERROR)("Weird 0x33 call %2X",reg_al); + reg_al =0xff; + break; } break; case 0x34: /* Get INDos Flag */ diff --git a/src/dos/dos_files.cpp b/src/dos/dos_files.cpp index 9fe36bcb..a9c7e12b 100644 --- a/src/dos/dos_files.cpp +++ b/src/dos/dos_files.cpp @@ -1067,32 +1067,30 @@ Bit8u DOS_FCBIncreaseSize(Bit16u seg,Bit16u offset) { return FCB_SUCCESS; } -Bit8u DOS_FCBRandomRead(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore) { +Bit8u DOS_FCBRandomRead(Bit16u seg,Bit16u offset,Bit16u * numRec,bool restore) { /* if restore is true :random read else random blok read. * random read updates old block and old record to reflect the random data * before the read!!!!!!!!! and the random data is not updated! (user must do this) * Random block read updates these fields to reflect the state after the read! */ - -/* BUG: numRec should return the amount of records read! - * Not implemented yet as I'm unsure how to count on error states (partial/failed) - */ - DOS_FCB fcb(seg,offset); Bit32u random; Bit16u old_block=0; Bit8u old_rec=0; Bit8u error=0; + Bit16u count; /* Set the correct record from the random data */ fcb.GetRandom(random); fcb.SetRecord((Bit16u)(random / 128),(Bit8u)(random & 127)); if (restore) fcb.GetRecord(old_block,old_rec);//store this for after the read. // Read records - for (int i=0; i0) { /* Write records */ - for (int i=0; i