1
0
Fork 0

Prevent problems related to I/O buffering with disk images.

Return a fake success result for INT 13/05. Helps older games (Sierra On-Line booters, Mickey's Space Adventure, Zyll, et al.) that insist on low-level formatting a floppy disk to be used for saving games.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3980
This commit is contained in:
ripsaw8080 2016-04-18 13:07:18 +00:00
parent 4555aa279d
commit 2b32f2bfa9
2 changed files with 17 additions and 3 deletions

View file

@ -65,7 +65,9 @@ public:
Bit32u sector_size;
Bit32u heads,cylinders,sectors;
private:
Bit32u current_fpos;
enum { NONE,READ,WRITE } last_action;
};
void updateDPT(void);

View file

@ -163,9 +163,10 @@ Bit8u imageDisk::Read_AbsoluteSector(Bit32u sectnum, void * data) {
bytenum = sectnum * sector_size;
if (bytenum!=current_fpos) fseek(diskimg,bytenum,SEEK_SET);
if (last_action==WRITE || bytenum!=current_fpos) fseek(diskimg,bytenum,SEEK_SET);
size_t ret=fread(data, 1, sector_size, diskimg);
current_fpos=bytenum+ret;
last_action=READ;
return 0x00;
}
@ -186,9 +187,10 @@ Bit8u imageDisk::Write_AbsoluteSector(Bit32u sectnum, void *data) {
//LOG_MSG("Writing sectors to %ld at bytenum %d", sectnum, bytenum);
if (bytenum!=current_fpos) fseek(diskimg,bytenum,SEEK_SET);
size_t ret=fwrite(data, sector_size, 1, diskimg);
if (last_action==READ || bytenum!=current_fpos) fseek(diskimg,bytenum,SEEK_SET);
size_t ret=fwrite(data, 1, sector_size, diskimg);
current_fpos=bytenum+ret;
last_action=WRITE;
return ((ret>0)?0x00:0x05);
@ -200,6 +202,7 @@ imageDisk::imageDisk(FILE *imgFile, Bit8u *imgName, Bit32u imgSizeK, bool isHard
sectors = 0;
sector_size = 512;
current_fpos = 0;
last_action = NONE;
diskimg = imgFile;
fseek(diskimg,0,SEEK_SET);
@ -450,6 +453,15 @@ static Bitu INT13_DiskHandler(void) {
//reg_al = 0x00; /* CRC verify succeeded */
CALLBACK_SCF(false);
break;
case 0x05: /* Format track */
if (driveInactive(drivenum)) {
reg_ah = 0xff;
CALLBACK_SCF(true);
return CBRET_NONE;
}
reg_ah = 0x00;
CALLBACK_SCF(false);
break;
case 0x08: /* Get drive parameters */
if(driveInactive(drivenum)) {