| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef DOSBOX_DOS_INC_H |
| 22 |
#define DOSBOX_DOS_INC_H |
| 23 |
|
| 24 |
#ifndef DOSBOX_DOS_SYSTEM_H |
| 25 |
#include "dos_system.h" |
| 26 |
#endif |
| 27 |
#ifndef DOSBOX_MEM_H |
| 28 |
#include "mem.h" |
| 29 |
#endif |
| 30 |
|
| 31 |
#include <stddef.h> |
| 32 |
|
| 33 |
#ifdef _MSC_VER |
| 34 |
#pragma pack (1) |
| 35 |
#endif |
| 36 |
struct CommandTail{ |
| 37 |
Bit8u count; |
| 38 |
char buffer[127]; |
| 39 |
} GCC_ATTRIBUTE(packed); |
| 40 |
#ifdef _MSC_VER |
| 41 |
#pragma pack () |
| 42 |
#endif |
| 43 |
|
| 44 |
struct DOS_Date { |
| 45 |
Bit16u year; |
| 46 |
Bit8u month; |
| 47 |
Bit8u day; |
| 48 |
}; |
| 49 |
|
| 50 |
struct DOS_Version { |
| 51 |
Bit8u major,minor,revision; |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
#ifdef _MSC_VER |
| 56 |
#pragma pack (1) |
| 57 |
#endif |
| 58 |
union bootSector { |
| 59 |
struct entries { |
| 60 |
Bit8u jump[3]; |
| 61 |
Bit8u oem_name[8]; |
| 62 |
Bit16u bytesect; |
| 63 |
Bit8u sectclust; |
| 64 |
Bit16u reserve_sect; |
| 65 |
Bit8u misc[496]; |
| 66 |
} bootdata; |
| 67 |
Bit8u rawdata[512]; |
| 68 |
} GCC_ATTRIBUTE(packed); |
| 69 |
#ifdef _MSC_VER |
| 70 |
#pragma pack () |
| 71 |
#endif |
| 72 |
|
| 73 |
|
| 74 |
enum { MCB_FREE=0x0000,MCB_DOS=0x0008 }; |
| 75 |
enum { RETURN_EXIT=0,RETURN_CTRLC=1,RETURN_ABORT=2,RETURN_TSR=3}; |
| 76 |
|
| 77 |
#define DOS_FILES 127 |
| 78 |
#define DOS_DRIVES 26 |
| 79 |
#define DOS_DEVICES 10 |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
#define DOS_INFOBLOCK_SEG 0x80 // sysvars (list of lists) |
| 85 |
#define DOS_CONDRV_SEG 0xa0 |
| 86 |
#define DOS_CONSTRING_SEG 0xa8 |
| 87 |
#define DOS_SDA_SEG 0xb2 // dos swappable area |
| 88 |
#define DOS_SDA_OFS 0 |
| 89 |
#define DOS_CDS_SEG 0x108 |
| 90 |
#define DOS_FIRST_SHELL 0x118 |
| 91 |
#define DOS_MEM_START 0x16f //First Segment that DOS can use |
| 92 |
|
| 93 |
#define DOS_PRIVATE_SEGMENT 0xc800 |
| 94 |
#define DOS_PRIVATE_SEGMENT_END 0xd000 |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
extern DOS_File * Files[DOS_FILES]; |
| 99 |
extern DOS_Drive * Drives[DOS_DRIVES]; |
| 100 |
extern DOS_Device * Devices[DOS_DEVICES]; |
| 101 |
|
| 102 |
extern Bit8u dos_copybuf[0x10000]; |
| 103 |
|
| 104 |
|
| 105 |
void DOS_SetError(Bit16u code); |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
enum { STDIN=0,STDOUT=1,STDERR=2,STDAUX=3,STDPRN=4}; |
| 110 |
enum { HAND_NONE=0,HAND_FILE,HAND_DEVICE}; |
| 111 |
|
| 112 |
|
| 113 |
void DOS_SetupFiles (void); |
| 114 |
bool DOS_ReadFile(Bit16u handle,Bit8u * data,Bit16u * amount); |
| 115 |
bool DOS_WriteFile(Bit16u handle,Bit8u * data,Bit16u * amount); |
| 116 |
bool DOS_SeekFile(Bit16u handle,Bit32u * pos,Bit32u type); |
| 117 |
bool DOS_CloseFile(Bit16u handle); |
| 118 |
bool DOS_FlushFile(Bit16u handle); |
| 119 |
bool DOS_DuplicateEntry(Bit16u entry,Bit16u * newentry); |
| 120 |
bool DOS_ForceDuplicateEntry(Bit16u entry,Bit16u newentry); |
| 121 |
bool DOS_GetFileDate(Bit16u entry, Bit16u* otime, Bit16u* odate); |
| 122 |
|
| 123 |
|
| 124 |
bool DOS_OpenFile(char const * name,Bit8u flags,Bit16u * entry); |
| 125 |
bool DOS_OpenFileExtended(char const * name, Bit16u flags, Bit16u createAttr, Bit16u action, Bit16u *entry, Bit16u* status); |
| 126 |
bool DOS_CreateFile(char const * name,Bit16u attribute,Bit16u * entry); |
| 127 |
bool DOS_UnlinkFile(char const * const name); |
| 128 |
bool DOS_FindFirst(char *search,Bit16u attr,bool fcb_findfirst=false); |
| 129 |
bool DOS_FindNext(void); |
| 130 |
bool DOS_Canonicalize(char const * const name,char * const big); |
| 131 |
bool DOS_CreateTempFile(char * const name,Bit16u * entry); |
| 132 |
bool DOS_FileExists(char const * const name); |
| 133 |
|
| 134 |
|
| 135 |
bool DOS_MakeName(char const * const name,char * const fullname,Bit8u * drive); |
| 136 |
|
| 137 |
Bit8u DOS_GetDefaultDrive(void); |
| 138 |
void DOS_SetDefaultDrive(Bit8u drive); |
| 139 |
bool DOS_SetDrive(Bit8u drive); |
| 140 |
bool DOS_GetCurrentDir(Bit8u drive,char * const buffer); |
| 141 |
bool DOS_ChangeDir(char const * const dir); |
| 142 |
bool DOS_MakeDir(char const * const dir); |
| 143 |
bool DOS_RemoveDir(char const * const dir); |
| 144 |
bool DOS_Rename(char const * const oldname,char const * const newname); |
| 145 |
bool DOS_GetFreeDiskSpace(Bit8u drive,Bit16u * bytes,Bit8u * sectors,Bit16u * clusters,Bit16u * free); |
| 146 |
bool DOS_GetFileAttr(char const * const name,Bit16u * attr); |
| 147 |
bool DOS_SetFileAttr(char const * const name,Bit16u attr); |
| 148 |
|
| 149 |
|
| 150 |
bool DOS_IOCTL(void); |
| 151 |
bool DOS_GetSTDINStatus(); |
| 152 |
Bit8u DOS_FindDevice(char const * name); |
| 153 |
void DOS_SetupDevices(void); |
| 154 |
|
| 155 |
|
| 156 |
bool DOS_NewPSP(Bit16u pspseg,Bit16u size); |
| 157 |
bool DOS_ChildPSP(Bit16u pspseg,Bit16u size); |
| 158 |
bool DOS_Execute(char * name,PhysPt block,Bit8u flags); |
| 159 |
void DOS_Terminate(Bit16u pspseg,bool tsr,Bit8u exitcode); |
| 160 |
|
| 161 |
|
| 162 |
void DOS_SetupMemory(void); |
| 163 |
bool DOS_AllocateMemory(Bit16u * segment,Bit16u * blocks); |
| 164 |
bool DOS_ResizeMemory(Bit16u segment,Bit16u * blocks); |
| 165 |
bool DOS_FreeMemory(Bit16u segment); |
| 166 |
void DOS_FreeProcessMemory(Bit16u pspseg); |
| 167 |
Bit16u DOS_GetMemory(Bit16u pages); |
| 168 |
bool DOS_SetMemAllocStrategy(Bit16u strat); |
| 169 |
Bit16u DOS_GetMemAllocStrategy(void); |
| 170 |
void DOS_BuildUMBChain(bool umb_active,bool ems_active); |
| 171 |
bool DOS_LinkUMBsToMemChain(Bit16u linkstate); |
| 172 |
|
| 173 |
|
| 174 |
bool DOS_FCBOpen(Bit16u seg,Bit16u offset); |
| 175 |
bool DOS_FCBCreate(Bit16u seg,Bit16u offset); |
| 176 |
bool DOS_FCBClose(Bit16u seg,Bit16u offset); |
| 177 |
bool DOS_FCBFindFirst(Bit16u seg,Bit16u offset); |
| 178 |
bool DOS_FCBFindNext(Bit16u seg,Bit16u offset); |
| 179 |
Bit8u DOS_FCBRead(Bit16u seg,Bit16u offset, Bit16u numBlocks); |
| 180 |
Bit8u DOS_FCBWrite(Bit16u seg,Bit16u offset,Bit16u numBlocks); |
| 181 |
Bit8u DOS_FCBRandomRead(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore); |
| 182 |
Bit8u DOS_FCBRandomWrite(Bit16u seg,Bit16u offset,Bit16u numRec,bool restore); |
| 183 |
bool DOS_FCBGetFileSize(Bit16u seg,Bit16u offset); |
| 184 |
bool DOS_FCBDeleteFile(Bit16u seg,Bit16u offset); |
| 185 |
bool DOS_FCBRenameFile(Bit16u seg, Bit16u offset); |
| 186 |
void DOS_FCBSetRandomRecord(Bit16u seg, Bit16u offset); |
| 187 |
Bit8u FCB_Parsename(Bit16u seg,Bit16u offset,Bit8u parser ,char *string, Bit8u *change); |
| 188 |
bool DOS_GetAllocationInfo(Bit8u drive,Bit16u * _bytes_sector,Bit8u * _sectors_cluster,Bit16u * _total_clusters); |
| 189 |
|
| 190 |
|
| 191 |
void DOS_SetupMisc(void); |
| 192 |
|
| 193 |
|
| 194 |
void DOS_SetupTables(void); |
| 195 |
|
| 196 |
|
| 197 |
void DOS_SetupPrograms(void); |
| 198 |
|
| 199 |
|
| 200 |
void DOS_KeyboardLayout_Init(Section* sec); |
| 201 |
|
| 202 |
bool DOS_LayoutKey(Bitu key, Bit8u flags1, Bit8u flags2, Bit8u flags3); |
| 203 |
|
| 204 |
enum { |
| 205 |
KEYB_NOERROR=0, |
| 206 |
KEYB_FILENOTFOUND, |
| 207 |
KEYB_INVALIDFILE, |
| 208 |
KEYB_LAYOUTNOTFOUND, |
| 209 |
KEYB_INVALIDCPFILE |
| 210 |
}; |
| 211 |
|
| 212 |
|
| 213 |
static INLINE Bit16u long2para(Bit32u size) { |
| 214 |
if (size>0xFFFF0) return 0xffff; |
| 215 |
if (size&0xf) return (Bit16u)((size>>4)+1); |
| 216 |
else return (Bit16u)(size>>4); |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
static INLINE Bit16u DOS_PackTime(Bit16u hour,Bit16u min,Bit16u sec) { |
| 221 |
return (hour&0x1f)<<11 | (min&0x3f) << 5 | ((sec/2)&0x1f); |
| 222 |
} |
| 223 |
|
| 224 |
static INLINE Bit16u DOS_PackDate(Bit16u year,Bit16u mon,Bit16u day) { |
| 225 |
return ((year-1980)&0x7f)<<9 | (mon&0x3f) << 5 | (day&0x1f); |
| 226 |
} |
| 227 |
|
| 228 |
|
| 229 |
#define DOSERR_NONE 0 |
| 230 |
#define DOSERR_FUNCTION_NUMBER_INVALID 1 |
| 231 |
#define DOSERR_FILE_NOT_FOUND 2 |
| 232 |
#define DOSERR_PATH_NOT_FOUND 3 |
| 233 |
#define DOSERR_TOO_MANY_OPEN_FILES 4 |
| 234 |
#define DOSERR_ACCESS_DENIED 5 |
| 235 |
#define DOSERR_INVALID_HANDLE 6 |
| 236 |
#define DOSERR_MCB_DESTROYED 7 |
| 237 |
#define DOSERR_INSUFFICIENT_MEMORY 8 |
| 238 |
#define DOSERR_MB_ADDRESS_INVALID 9 |
| 239 |
#define DOSERR_ENVIRONMENT_INVALID 10 |
| 240 |
#define DOSERR_FORMAT_INVALID 11 |
| 241 |
#define DOSERR_ACCESS_CODE_INVALID 12 |
| 242 |
#define DOSERR_DATA_INVALID 13 |
| 243 |
#define DOSERR_RESERVED 14 |
| 244 |
#define DOSERR_FIXUP_OVERFLOW 14 |
| 245 |
#define DOSERR_INVALID_DRIVE 15 |
| 246 |
#define DOSERR_REMOVE_CURRENT_DIRECTORY 16 |
| 247 |
#define DOSERR_NOT_SAME_DEVICE 17 |
| 248 |
#define DOSERR_NO_MORE_FILES 18 |
| 249 |
#define DOSERR_FILE_ALREADY_EXISTS 80 |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
#define sOffset(s,m) ((char*)&(((s*)NULL)->m)-(char*)NULL) |
| 254 |
#define sGet(s,m) GetIt(sizeof(((s *)&pt)->m),(PhysPt)sOffset(s,m)) |
| 255 |
#define sSave(s,m,val) SaveIt(sizeof(((s *)&pt)->m),(PhysPt)sOffset(s,m),val) |
| 256 |
|
| 257 |
class MemStruct { |
| 258 |
public: |
| 259 |
Bitu GetIt(Bitu size,PhysPt addr) { |
| 260 |
switch (size) { |
| 261 |
case 1:return mem_readb(pt+addr); |
| 262 |
case 2:return mem_readw(pt+addr); |
| 263 |
case 4:return mem_readd(pt+addr); |
| 264 |
} |
| 265 |
return 0; |
| 266 |
} |
| 267 |
void SaveIt(Bitu size,PhysPt addr,Bitu val) { |
| 268 |
switch (size) { |
| 269 |
case 1:mem_writeb(pt+addr,(Bit8u)val);break; |
| 270 |
case 2:mem_writew(pt+addr,(Bit16u)val);break; |
| 271 |
case 4:mem_writed(pt+addr,(Bit32u)val);break; |
| 272 |
} |
| 273 |
} |
| 274 |
void SetPt(Bit16u seg) { pt=PhysMake(seg,0);} |
| 275 |
void SetPt(Bit16u seg,Bit16u off) { pt=PhysMake(seg,off);} |
| 276 |
void SetPt(RealPt addr) { pt=Real2Phys(addr);} |
| 277 |
protected: |
| 278 |
PhysPt pt; |
| 279 |
}; |
| 280 |
|
| 281 |
class DOS_PSP :public MemStruct { |
| 282 |
public: |
| 283 |
DOS_PSP (Bit16u segment) { SetPt(segment);seg=segment;}; |
| 284 |
void MakeNew (Bit16u memSize); |
| 285 |
void CopyFileTable (DOS_PSP* srcpsp,bool createchildpsp); |
| 286 |
Bit16u FindFreeFileEntry (void); |
| 287 |
void CloseFiles (void); |
| 288 |
|
| 289 |
void SaveVectors (void); |
| 290 |
void RestoreVectors (void); |
| 291 |
void SetSize (Bit16u size) { sSave(sPSP,next_seg,size); }; |
| 292 |
Bit16u GetSize (void) { return (Bit16u)sGet(sPSP,next_seg); }; |
| 293 |
void SetEnvironment (Bit16u envseg) { sSave(sPSP,environment,envseg); }; |
| 294 |
Bit16u GetEnvironment (void) { return (Bit16u)sGet(sPSP,environment); }; |
| 295 |
Bit16u GetSegment (void) { return seg; }; |
| 296 |
void SetFileHandle (Bit16u index, Bit8u handle); |
| 297 |
Bit8u GetFileHandle (Bit16u index); |
| 298 |
void SetParent (Bit16u parent) { sSave(sPSP,psp_parent,parent); }; |
| 299 |
Bit16u GetParent (void) { return (Bit16u)sGet(sPSP,psp_parent); }; |
| 300 |
void SetStack (RealPt stackpt) { sSave(sPSP,stack,stackpt); }; |
| 301 |
RealPt GetStack (void) { return sGet(sPSP,stack); }; |
| 302 |
void SetInt22 (RealPt int22pt) { sSave(sPSP,int_22,int22pt); }; |
| 303 |
RealPt GetInt22 (void) { return sGet(sPSP,int_22); }; |
| 304 |
void SetFCB1 (RealPt src); |
| 305 |
void SetFCB2 (RealPt src); |
| 306 |
void SetCommandTail (RealPt src); |
| 307 |
bool SetNumFiles (Bit16u fileNum); |
| 308 |
Bit16u FindEntryByHandle (Bit8u handle); |
| 309 |
|
| 310 |
private: |
| 311 |
#ifdef _MSC_VER |
| 312 |
#pragma pack(1) |
| 313 |
#endif |
| 314 |
struct sPSP { |
| 315 |
Bit8u exit[2]; |
| 316 |
Bit16u next_seg; |
| 317 |
Bit8u fill_1; |
| 318 |
Bit8u far_call; |
| 319 |
RealPt cpm_entry; |
| 320 |
RealPt int_22; |
| 321 |
RealPt int_23; |
| 322 |
RealPt int_24; |
| 323 |
Bit16u psp_parent; |
| 324 |
Bit8u files[20]; |
| 325 |
Bit16u environment; |
| 326 |
RealPt stack; |
| 327 |
Bit16u max_files; |
| 328 |
RealPt file_table; |
| 329 |
RealPt prev_psp; |
| 330 |
Bit8u interim_flag; |
| 331 |
Bit8u truename_flag; |
| 332 |
Bit16u nn_flags; |
| 333 |
Bit16u dos_version; |
| 334 |
Bit8u fill_2[14]; |
| 335 |
Bit8u service[3]; |
| 336 |
Bit8u fill_3[9]; |
| 337 |
Bit8u fcb1[16]; |
| 338 |
Bit8u fcb2[16]; |
| 339 |
Bit8u fill_4[4]; |
| 340 |
CommandTail cmdtail; |
| 341 |
} GCC_ATTRIBUTE(packed); |
| 342 |
#ifdef _MSC_VER |
| 343 |
#pragma pack() |
| 344 |
#endif |
| 345 |
Bit16u seg; |
| 346 |
public: |
| 347 |
static Bit16u rootpsp; |
| 348 |
}; |
| 349 |
|
| 350 |
class DOS_ParamBlock:public MemStruct { |
| 351 |
public: |
| 352 |
DOS_ParamBlock(PhysPt addr) {pt=addr;} |
| 353 |
void Clear(void); |
| 354 |
void LoadData(void); |
| 355 |
void SaveData(void); |
| 356 |
#ifdef _MSC_VER |
| 357 |
#pragma pack (1) |
| 358 |
#endif |
| 359 |
struct sOverlay { |
| 360 |
Bit16u loadseg; |
| 361 |
Bit16u relocation; |
| 362 |
} GCC_ATTRIBUTE(packed); |
| 363 |
struct sExec { |
| 364 |
Bit16u envseg; |
| 365 |
RealPt cmdtail; |
| 366 |
RealPt fcb1; |
| 367 |
RealPt fcb2; |
| 368 |
RealPt initsssp; |
| 369 |
RealPt initcsip; |
| 370 |
}GCC_ATTRIBUTE(packed); |
| 371 |
#ifdef _MSC_VER |
| 372 |
#pragma pack() |
| 373 |
#endif |
| 374 |
sExec exec; |
| 375 |
sOverlay overlay; |
| 376 |
}; |
| 377 |
|
| 378 |
class DOS_InfoBlock:public MemStruct { |
| 379 |
public: |
| 380 |
DOS_InfoBlock () {}; |
| 381 |
void SetLocation(Bit16u seg); |
| 382 |
void SetFirstMCB(Bit16u _first_mcb); |
| 383 |
void SetBuffers(Bit16u x,Bit16u y); |
| 384 |
void SetCurDirStruct(Bit32u _curdirstruct); |
| 385 |
void SetFCBTable(Bit32u _fcbtable); |
| 386 |
void SetDeviceChainStart(Bit32u _devchain); |
| 387 |
void SetDiskBufferHeadPt(Bit32u _dbheadpt); |
| 388 |
void SetStartOfUMBChain(Bit16u _umbstartseg); |
| 389 |
void SetUMBChainState(Bit8u _umbchaining); |
| 390 |
Bit16u GetStartOfUMBChain(void); |
| 391 |
Bit8u GetUMBChainState(void); |
| 392 |
RealPt GetPointer(void); |
| 393 |
Bit32u GetDeviceChain(void); |
| 394 |
|
| 395 |
#ifdef _MSC_VER |
| 396 |
#pragma pack(1) |
| 397 |
#endif |
| 398 |
struct sDIB { |
| 399 |
Bit8u unknown1[4]; |
| 400 |
Bit16u magicWord; |
| 401 |
Bit8u unknown2[8]; |
| 402 |
Bit16u regCXfrom5e; |
| 403 |
Bit16u countLRUcache; |
| 404 |
Bit16u countLRUopens; |
| 405 |
Bit8u stuff[6]; |
| 406 |
Bit16u sharingCount; |
| 407 |
Bit16u sharingDelay; |
| 408 |
RealPt diskBufPtr; |
| 409 |
Bit16u ptrCONinput; |
| 410 |
Bit16u firstMCB; |
| 411 |
RealPt firstDPB; |
| 412 |
RealPt firstFileTable; |
| 413 |
RealPt activeClock; |
| 414 |
RealPt activeCon; |
| 415 |
Bit16u maxSectorLength; |
| 416 |
RealPt diskInfoBuffer; |
| 417 |
RealPt curDirStructure; |
| 418 |
RealPt fcbTable; |
| 419 |
Bit16u protFCBs; |
| 420 |
Bit8u blockDevices; |
| 421 |
Bit8u lastdrive; |
| 422 |
Bit32u nulNextDriver; |
| 423 |
Bit16u nulAttributes; |
| 424 |
Bit32u nulStrategy; |
| 425 |
Bit8u nulString[8]; |
| 426 |
Bit8u joindedDrives; |
| 427 |
Bit16u specialCodeSeg; |
| 428 |
RealPt setverPtr; |
| 429 |
Bit16u a20FixOfs; |
| 430 |
Bit16u pspLastIfHMA; |
| 431 |
Bit16u buffers_x; |
| 432 |
Bit16u buffers_y; |
| 433 |
Bit8u bootDrive; |
| 434 |
Bit8u useDwordMov; |
| 435 |
Bit16u extendedSize; |
| 436 |
Bit32u diskBufferHeadPt; |
| 437 |
Bit16u dirtyDiskBuffers; |
| 438 |
Bit32u lookaheadBufPt; |
| 439 |
Bit16u lookaheadBufNumber; |
| 440 |
Bit8u bufferLocation; |
| 441 |
Bit32u workspaceBuffer; |
| 442 |
Bit8u unknown3[11]; |
| 443 |
Bit8u chainingUMB; |
| 444 |
Bit16u minMemForExec; |
| 445 |
Bit16u startOfUMBChain; |
| 446 |
Bit16u memAllocScanStart; |
| 447 |
} GCC_ATTRIBUTE(packed); |
| 448 |
#ifdef _MSC_VER |
| 449 |
#pragma pack () |
| 450 |
#endif |
| 451 |
Bit16u seg; |
| 452 |
}; |
| 453 |
|
| 454 |
class DOS_DTA:public MemStruct{ |
| 455 |
public: |
| 456 |
DOS_DTA(RealPt addr) { SetPt(addr); } |
| 457 |
|
| 458 |
void SetupSearch(Bit8u _sdrive,Bit8u _sattr,char * _pattern); |
| 459 |
void SetResult(const char * _name,Bit32u _size,Bit16u _date,Bit16u _time,Bit8u _attr); |
| 460 |
|
| 461 |
Bit8u GetSearchDrive(void); |
| 462 |
void GetSearchParams(Bit8u & _sattr,char * _spattern); |
| 463 |
void GetResult(char * _name,Bit32u & _size,Bit16u & _date,Bit16u & _time,Bit8u & _attr); |
| 464 |
|
| 465 |
void SetDirID(Bit16u entry) { sSave(sDTA,dirID,entry); }; |
| 466 |
void SetDirIDCluster(Bit16u entry) { sSave(sDTA,dirCluster,entry); }; |
| 467 |
Bit16u GetDirID(void) { return (Bit16u)sGet(sDTA,dirID); }; |
| 468 |
Bit16u GetDirIDCluster(void) { return (Bit16u)sGet(sDTA,dirCluster); }; |
| 469 |
private: |
| 470 |
#ifdef _MSC_VER |
| 471 |
#pragma pack(1) |
| 472 |
#endif |
| 473 |
struct sDTA { |
| 474 |
Bit8u sdrive; |
| 475 |
Bit8u sname[8]; |
| 476 |
Bit8u sext[3]; |
| 477 |
Bit8u sattr; |
| 478 |
Bit16u dirID; |
| 479 |
Bit16u dirCluster; |
| 480 |
Bit8u fill[4]; |
| 481 |
Bit8u attr; |
| 482 |
Bit16u time; |
| 483 |
Bit16u date; |
| 484 |
Bit32u size; |
| 485 |
char name[DOS_NAMELENGTH_ASCII]; |
| 486 |
} GCC_ATTRIBUTE(packed); |
| 487 |
#ifdef _MSC_VER |
| 488 |
#pragma pack() |
| 489 |
#endif |
| 490 |
}; |
| 491 |
|
| 492 |
class DOS_FCB: public MemStruct { |
| 493 |
public: |
| 494 |
DOS_FCB(Bit16u seg,Bit16u off,bool allow_extended=true); |
| 495 |
void Create(bool _extended); |
| 496 |
void SetName(Bit8u _drive,char * _fname,char * _ext); |
| 497 |
void SetSizeDateTime(Bit32u _size,Bit16u _date,Bit16u _time); |
| 498 |
void GetSizeDateTime(Bit32u & _size,Bit16u & _date,Bit16u & _time); |
| 499 |
void GetName(char * fillname); |
| 500 |
void FileOpen(Bit8u _fhandle); |
| 501 |
void FileClose(Bit8u & _fhandle); |
| 502 |
void GetRecord(Bit16u & _cur_block,Bit8u & _cur_rec); |
| 503 |
void SetRecord(Bit16u _cur_block,Bit8u _cur_rec); |
| 504 |
void GetSeqData(Bit8u & _fhandle,Bit16u & _rec_size); |
| 505 |
void GetRandom(Bit32u & _random); |
| 506 |
void SetRandom(Bit32u _random); |
| 507 |
Bit8u GetDrive(void); |
| 508 |
bool Extended(void); |
| 509 |
void GetAttr(Bit8u & attr); |
| 510 |
void SetAttr(Bit8u attr); |
| 511 |
bool Valid(void); |
| 512 |
private: |
| 513 |
bool extended; |
| 514 |
PhysPt real_pt; |
| 515 |
#ifdef _MSC_VER |
| 516 |
#pragma pack (1) |
| 517 |
#endif |
| 518 |
struct sFCB { |
| 519 |
Bit8u drive; |
| 520 |
Bit8u filename[8]; |
| 521 |
Bit8u ext[3]; |
| 522 |
Bit16u cur_block; |
| 523 |
Bit16u rec_size; |
| 524 |
Bit32u filesize; |
| 525 |
Bit16u date; |
| 526 |
Bit16u time; |
| 527 |
|
| 528 |
Bit8u sft_entries; |
| 529 |
Bit8u share_attributes; |
| 530 |
Bit8u extra_info; |
| 531 |
Bit8u file_handle; |
| 532 |
Bit8u reserved[4]; |
| 533 |
|
| 534 |
Bit8u cur_rec; |
| 535 |
Bit32u rndm; |
| 536 |
} GCC_ATTRIBUTE(packed); |
| 537 |
#ifdef _MSC_VER |
| 538 |
#pragma pack () |
| 539 |
#endif |
| 540 |
}; |
| 541 |
|
| 542 |
class DOS_MCB : public MemStruct{ |
| 543 |
public: |
| 544 |
DOS_MCB(Bit16u seg) { SetPt(seg); } |
| 545 |
void SetFileName(char const * const _name) { MEM_BlockWrite(pt+offsetof(sMCB,filename),_name,8); } |
| 546 |
void GetFileName(char * const _name) { MEM_BlockRead(pt+offsetof(sMCB,filename),_name,8);_name[8]=0;} |
| 547 |
void SetType(Bit8u _type) { sSave(sMCB,type,_type);} |
| 548 |
void SetSize(Bit16u _size) { sSave(sMCB,size,_size);} |
| 549 |
void SetPSPSeg(Bit16u _pspseg) { sSave(sMCB,psp_segment,_pspseg);} |
| 550 |
Bit8u GetType(void) { return (Bit8u)sGet(sMCB,type);} |
| 551 |
Bit16u GetSize(void) { return (Bit16u)sGet(sMCB,size);} |
| 552 |
Bit16u GetPSPSeg(void) { return (Bit16u)sGet(sMCB,psp_segment);} |
| 553 |
private: |
| 554 |
#ifdef _MSC_VER |
| 555 |
#pragma pack (1) |
| 556 |
#endif |
| 557 |
struct sMCB { |
| 558 |
Bit8u type; |
| 559 |
Bit16u psp_segment; |
| 560 |
Bit16u size; |
| 561 |
Bit8u unused[3]; |
| 562 |
Bit8u filename[8]; |
| 563 |
} GCC_ATTRIBUTE(packed); |
| 564 |
#ifdef _MSC_VER |
| 565 |
#pragma pack () |
| 566 |
#endif |
| 567 |
}; |
| 568 |
|
| 569 |
class DOS_SDA : public MemStruct { |
| 570 |
public: |
| 571 |
DOS_SDA(Bit16u _seg,Bit16u _offs) { SetPt(_seg,_offs); } |
| 572 |
void Init(); |
| 573 |
void SetDrive(Bit8u _drive) { sSave(sSDA,current_drive, _drive); } |
| 574 |
void SetDTA(Bit32u _dta) { sSave(sSDA,current_dta, _dta); } |
| 575 |
void SetPSP(Bit16u _psp) { sSave(sSDA,current_psp, _psp); } |
| 576 |
Bit8u GetDrive(void) { return (Bit8u)sGet(sSDA,current_drive); } |
| 577 |
Bit16u GetPSP(void) { return (Bit16u)sGet(sSDA,current_psp); } |
| 578 |
Bit32u GetDTA(void) { return (Bit32u)sGet(sSDA,current_dta); } |
| 579 |
|
| 580 |
|
| 581 |
private: |
| 582 |
#ifdef _MSC_VER |
| 583 |
#pragma pack (1) |
| 584 |
#endif |
| 585 |
struct sSDA { |
| 586 |
Bit8u crit_error_flag; |
| 587 |
Bit8u inDOS_flag; |
| 588 |
Bit8u drive_crit_error; |
| 589 |
Bit8u locus_of_last_error; |
| 590 |
Bit16u extended_error_code; |
| 591 |
Bit8u suggested_action; |
| 592 |
Bit8u error_class; |
| 593 |
Bit32u last_error_pointer; |
| 594 |
Bit32u current_dta; |
| 595 |
Bit16u current_psp; |
| 596 |
Bit16u sp_int_23; |
| 597 |
Bit16u return_code; |
| 598 |
Bit8u current_drive; |
| 599 |
Bit8u extended_break_flag; |
| 600 |
Bit8u fill[2]; |
| 601 |
} GCC_ATTRIBUTE(packed); |
| 602 |
#ifdef _MSC_VER |
| 603 |
#pragma pack() |
| 604 |
#endif |
| 605 |
}; |
| 606 |
extern DOS_InfoBlock dos_infoblock; |
| 607 |
|
| 608 |
struct DOS_Block { |
| 609 |
DOS_Date date; |
| 610 |
DOS_Version version; |
| 611 |
Bit16u firstMCB; |
| 612 |
Bit16u errorcode; |
| 613 |
Bit16u psp(){return DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetPSP();}; |
| 614 |
void psp(Bit16u _seg){ DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).SetPSP(_seg);}; |
| 615 |
Bit16u env; |
| 616 |
RealPt cpmentry; |
| 617 |
RealPt dta(){return DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).GetDTA();}; |
| 618 |
void dta(RealPt _dta){DOS_SDA(DOS_SDA_SEG,DOS_SDA_OFS).SetDTA(_dta);}; |
| 619 |
Bit8u return_code,return_mode; |
| 620 |
|
| 621 |
Bit8u current_drive; |
| 622 |
bool verify; |
| 623 |
bool breakcheck; |
| 624 |
bool echo; |
| 625 |
struct { |
| 626 |
RealPt mediaid; |
| 627 |
RealPt tempdta; |
| 628 |
RealPt tempdta_fcbdelete; |
| 629 |
RealPt dbcs; |
| 630 |
RealPt filenamechar; |
| 631 |
RealPt collatingseq; |
| 632 |
RealPt upcase; |
| 633 |
Bit8u* country; |
| 634 |
Bit16u dpb; |
| 635 |
} tables; |
| 636 |
Bit16u loaded_codepage; |
| 637 |
}; |
| 638 |
|
| 639 |
extern DOS_Block dos; |
| 640 |
|
| 641 |
static INLINE Bit8u RealHandle(Bit16u handle) { |
| 642 |
DOS_PSP psp(dos.psp()); |
| 643 |
return psp.GetFileHandle(handle); |
| 644 |
} |
| 645 |
|
| 646 |
#endif |