1
0
Fork 0

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
This commit is contained in:
Peter Veenstra 2011-01-05 19:48:18 +00:00
parent c3a904c56e
commit 1589c86ebe
3 changed files with 28 additions and 20 deletions

View file

@ -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);

View file

@ -319,11 +319,17 @@ static Bitu DOS_21Handler(void) {
if (!DOS_GetAllocationInfo(reg_dl,&reg_cx,&reg_al,&reg_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,&reg_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,&reg_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 */

View file

@ -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; i<numRec; i++) {
error = DOS_FCBRead(seg,offset,(Bit16u)i);
if (error!=0x00) break;
for (count=0; count<*numRec; count++) {
error = DOS_FCBRead(seg,offset,count);
if (error!=FCB_SUCCESS) break;
}
if (error==FCB_READ_PARTIAL) count++; //partial read counts
*numRec=count;
Bit16u new_block;Bit8u new_rec;
fcb.GetRecord(new_block,new_rec);
if (restore) fcb.SetRecord(old_block,old_rec);
@ -1101,13 +1099,14 @@ Bit8u DOS_FCBRandomRead(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore) {
return error;
}
Bit8u DOS_FCBRandomWrite(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore) {
Bit8u DOS_FCBRandomWrite(Bit16u seg,Bit16u offset,Bit16u * numRec,bool restore) {
/* see FCB_RandomRead */
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);
@ -1115,10 +1114,11 @@ Bit8u DOS_FCBRandomWrite(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore) {
if (restore) fcb.GetRecord(old_block,old_rec);
if (numRec>0) {
/* Write records */
for (int i=0; i<numRec; i++) {
error = DOS_FCBWrite(seg,offset,(Bit16u)i);// dos_fcbwrite return 0 false when true...
if (error!=0x00) break;
for (count=0; count<*numRec; count++) {
error = DOS_FCBWrite(seg,offset,count);// dos_fcbwrite return 0 false when true...
if (error!=FCB_SUCCESS) break;
}
*numRec=count;
} else {
DOS_FCBIncreaseSize(seg,offset);
}