Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions include/bios_disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "dos_inc.h"
#include "logging.h"
#include "../src/dos/cdrom.h"
#include "memfile.h"

/* The Section handling Bios Disk Access */
#define BIOS_MAX_DISK 10
Expand Down Expand Up @@ -99,8 +100,10 @@ class imageDisk {
imageDisk(class DOS_Drive *useDrive, unsigned int letter, uint32_t freeMB, int timeout);
imageDisk(FILE *imgFile, const char *imgName, uint32_t imgSizeK, bool isHardDisk);
imageDisk(FILE* diskimg, const char* diskName, uint32_t cylinders, uint32_t heads, uint32_t sectors, uint32_t sector_size, bool hardDrive);

imageDisk() = default;
virtual ~imageDisk();
void Set_GeometryForHardDisk();
virtual void Set_GeometryForHardDisk();
struct fatFromDOSDrive* ffdd = NULL;
unsigned int drvnum = DOS_DRIVES;

Expand All @@ -113,21 +116,21 @@ class imageDisk {
uint32_t sectors = 0;
bool hardDrive = false;
uint64_t diskSizeK = 0;
FILE* diskimg = NULL;
bool diskChangeFlag = false;

/* this is intended only for when the disk can change out from under us while mounted */
virtual bool detectDiskChange(void) { const bool r = diskChangeFlag; diskChangeFlag = false; return r; }

protected:
FILE* diskimg = NULL;
imageDisk(IMAGE_TYPE class_id);
uint8_t floppytype = 0;

uint32_t reserved_cylinders = 0;
uint64_t image_base = 0;
uint64_t image_length = 0;

private:
protected:
volatile int refcount = 0;
std::vector<bool> partition_in_use; /* used by FAT driver to prevent mounting a partition twice */
uint64_t current_fpos = 0;
Expand Down Expand Up @@ -165,6 +168,15 @@ class imageDisk {
}
};

class imageDisk_Mem : public imageDisk {
public:
uint8_t Read_AbsoluteSector(uint32_t sectnum, void * data) override;
uint8_t Write_AbsoluteSector(uint32_t sectnum, const void * data) override;
imageDisk_Mem(jaffarCommon::file::MemoryFile* memfile, const char *imgName, uint32_t imgSizeK, bool isHardDisk) ;
void Set_GeometryForHardDisk() override;
jaffarCommon::file::MemoryFile* _memfile;
};

class imageDiskEmptyDrive : public imageDisk {
public:
uint8_t Read_Sector(uint32_t head,uint32_t cylinder,uint32_t sector,void * data,unsigned int req_sector_size=0) override;
Expand Down Expand Up @@ -299,7 +311,7 @@ class imageDiskMemory : public imageDisk {
imageDiskMemory(imageDisk* underlyingImage);
virtual ~imageDiskMemory();

private:
protected:
void init(diskGeo diskParams, bool isHardDrive, imageDisk* underlyingImage);
bool CalculateFAT(uint32_t partitionStartingSector, uint32_t partitionLength, bool isHardDrive, uint32_t rootEntries, uint32_t* rootSectors, uint32_t* sectorsPerCluster, bool* isFat16, uint32_t* fatSectors, uint32_t* reservedSectors);

Expand Down Expand Up @@ -399,7 +411,7 @@ class imageDiskVHD : public imageDisk {
static void mk_uuid(uint8_t* buf);
virtual ~imageDiskVHD();

private:
protected:
struct ParentLocatorEntry {
uint32_t platformCode;
uint32_t platformDataSpace;
Expand Down Expand Up @@ -627,4 +639,6 @@ class imageDiskINT13Drive : public imageDisk {
bool busy = false;
};



#endif
5 changes: 5 additions & 0 deletions include/memfile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include <jaffarCommon/file.hpp>

extern jaffarCommon::file::MemoryFileDirectory _memFileDirectory;
27 changes: 27 additions & 0 deletions include/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,31 @@ void PCSPEAKER_SetCounter(Bitu cntr,Bitu mode);
void PCSPEAKER_SetType(bool pit_clock_gate_enabled, bool pit_output_enabled);
void PCSPEAKER_SetPITControl(Bitu mode);

struct mixedFraction {
unsigned int w;
unsigned int fn,fd;
};

struct mixer_t {
int32_t work[MIXER_BUFSIZE][2];
Bitu work_in,work_out,work_wrap;
Bitu pos,done;
float mastervol[2];
float recordvol[2];
MixerChannel* channels;
uint32_t freq;
uint32_t blocksize;
struct mixedFraction samples_per_ms;
struct mixedFraction samples_this_ms;
struct mixedFraction samples_rendered_ms;
bool nosound;
bool swapstereo;
bool sampleaccurate;
bool prebuffer_wait;
Bitu prebuffer_samples;
bool mute;
};

extern mixer_t mixer;

#endif
26 changes: 22 additions & 4 deletions src/dos/dos_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,11 +800,14 @@ bool DOS_FlushFile(uint16_t entry) {


bool DOS_CreateFile(char const * name,uint16_t attributes,uint16_t * entry,bool fcb) {
printf("Trying to create file: %s\n", name);

// Creation of a device is the same as opening it
// Tc201 installer
if (DOS_FindDevice(name) != DOS_DEVICES)
return DOS_OpenFile(name, OPEN_READ, entry, fcb);

printf("DOS_CreateFile 1\n");
LOG(LOG_FILES,LOG_NORMAL)("file create attributes %X file %s",attributes,name);
char fullname[DOS_PATHLENGTH];uint8_t drive;
DOS_PSP psp(dos.psp());
Expand All @@ -815,6 +818,8 @@ bool DOS_CreateFile(char const * name,uint16_t attributes,uint16_t * entry,bool
return Network_CreateFile(name,attributes,entry);
#endif

printf("DOS_CreateFile 2\n");

/* Check for a free file handle */
uint8_t handle=(uint8_t)DOS_FILES;uint8_t i;
for (i=0;i<DOS_FILES;i++) {
Expand All @@ -823,22 +828,33 @@ bool DOS_CreateFile(char const * name,uint16_t attributes,uint16_t * entry,bool
break;
}
}

printf("DOS_CreateFile 3\n");

if (handle==DOS_FILES) {
DOS_SetError(DOSERR_TOO_MANY_OPEN_FILES);
return false;
}

printf("DOS_CreateFile 4\n");

/* We have a position in the main table now find one in the psp table */
*entry = fcb?handle:psp.FindFreeFileEntry();
if (*entry==0xff) {
DOS_SetError(DOSERR_TOO_MANY_OPEN_FILES);
return false;
}

printf("DOS_CreateFile 5\n");
/* Don't allow directories to be created */
if (attributes&DOS_ATTR_DIRECTORY) {
DOS_SetError(DOSERR_ACCESS_DENIED);
return false;
}

printf("DOS_CreateFile 6\n");
bool foundit=Drives[drive]->FileCreate(&Files[handle],fullname,attributes);
printf("foundit: %d\n", foundit);
if (foundit) {
if (Files[handle]) {
Files[handle]->SetDrive(drive);
Expand All @@ -847,11 +863,13 @@ bool DOS_CreateFile(char const * name,uint16_t attributes,uint16_t * entry,bool
}
if (!fcb) psp.SetFileHandle(*entry,handle);
if (Files[handle]) Drives[drive]->EmptyCache();
printf("DOS_CreateFile 7\n");
return true;
} else {
if(dos.errorcode==DOSERR_ACCESS_DENIED||dos.errorcode==DOSERR_WRITE_PROTECTED) return false;
if(!PathExists(name)) DOS_SetError(DOSERR_PATH_NOT_FOUND);
else DOS_SetError(DOSERR_FILE_NOT_FOUND);
printf("DOS_CreateFile 8\n");
return false;
}
}
Expand Down Expand Up @@ -2655,10 +2673,10 @@ void POD_Load_DOS_Files( std::istream& stream )
} else if (!opts.mounttype && *diskname) {
std::vector<std::string> options;
fatDrive* newDrive = new fatDrive(diskname, opts.bytesector, opts.cylsector, opts.headscyl, opts.cylinders, options);
if (newDrive->created_successfully) {
imageDisk* image = newDrive->loadedDisk;
AttachToBiosAndIdeByLetter(image, 'A'+d, (unsigned char)ide_index, ide_slave);
} else
// if (newDrive->created_successfully) {
// imageDisk* image = newDrive->loadedDisk;
// AttachToBiosAndIdeByLetter(image, 'A'+d, (unsigned char)ide_index, ide_slave);
// } else
LOG_MSG("Warning: Cannot restore drive number from image file %s\n", diskname);
if (newDrive) delete newDrive;
}
Expand Down
Loading