diff options
author | kcgen <kcgen@users.noreply.github.com> | 2022-07-10 23:42:13 +0300 |
---|---|---|
committer | kcgen <kcgen@users.noreply.github.com> | 2022-07-11 02:31:40 +0300 |
commit | 067be333c1ab497d3a6ca319fe2216ccd31cb81e (patch) | |
tree | 4b17588fe326d841e7a0cf12305652018d4f3335 | |
parent | f8450ec203860afc879415bc67aa9502b07cab26 (diff) |
Replace MCB block type hex literals with named valuekc/mem-testing-1
-rw-r--r-- | src/dos/dos_memory.cpp | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/src/dos/dos_memory.cpp b/src/dos/dos_memory.cpp index 1fb87102e..ef43e36ac 100644 --- a/src/dos/dos_memory.cpp +++ b/src/dos/dos_memory.cpp @@ -96,7 +96,7 @@ static void DOS_CompressMemory() uint16_t faults = {0u}; - while (mcb.GetType() != 0x5a && faults < max_allowed_faults) { + while (mcb.GetType() != mcb_type_Z && faults < max_allowed_faults) { mcb_next.SetPt((uint16_t)(mcb_segment + mcb.GetSize() + 1)); if ((mcb.GetPSPSeg() == MCB_FREE) && (mcb_next.GetPSPSeg() == MCB_FREE)) { @@ -119,9 +119,10 @@ void DOS_FreeProcessMemory(uint16_t pspseg) { if (mcb.GetPSPSeg() == pspseg) { mcb.SetPSPSeg(MCB_FREE); } - if (mcb.GetType()==0x5a) break; - faults += triage_block(mcb, 0x4d); - mcb_segment+=mcb.GetSize()+1; + if (mcb.GetType() == mcb_type_Z) + break; + faults += triage_block(mcb, mcb_type_M); + mcb_segment += mcb.GetSize() + 1; mcb.SetPt(mcb_segment); } @@ -134,9 +135,9 @@ void DOS_FreeProcessMemory(uint16_t pspseg) { if (umb_mcb.GetPSPSeg() == pspseg) { umb_mcb.SetPSPSeg(MCB_FREE); } - if (mcb.GetType() == 0x5a) + if (mcb.GetType() == mcb_type_Z) break; - faults += triage_block(mcb, 0x4d); + faults += triage_block(mcb, mcb_type_M); umb_start += umb_mcb.GetSize() + 1; umb_mcb.SetPt(umb_start); } @@ -200,7 +201,7 @@ bool DOS_AllocateMemory(uint16_t * segment,uint16_t * blocks) { mcb_next.SetType(mcb.GetType()); mcb_next.SetSize(block_size-*blocks-1); mcb.SetSize(*blocks); - mcb.SetType(0x4d); + mcb.SetType(mcb_type_M); mcb.SetPSPSeg(dos.psp()); mcb.SetFileName(psp_name); //TODO Filename @@ -222,7 +223,7 @@ bool DOS_AllocateMemory(uint16_t * segment,uint16_t * blocks) { } } /* Onward to the next MCB if there is one */ - if (mcb.GetType()==0x5a) { + if (mcb.GetType() == mcb_type_Z) { if ((mem_strat&0x80) && (umb_start==UMB_START_SEG)) { /* bit 7 set: try high memory first, then low */ mcb_segment=dos.firstMCB; @@ -241,7 +242,7 @@ bool DOS_AllocateMemory(uint16_t * segment,uint16_t * blocks) { mcb_next.SetSize(found_seg_size-*blocks-1); mcb.SetSize(*blocks); - mcb.SetType(0x4d); + mcb.SetType(mcb_type_M); mcb.SetPSPSeg(dos.psp()); mcb.SetFileName(psp_name); //TODO Filename @@ -266,7 +267,7 @@ bool DOS_AllocateMemory(uint16_t * segment,uint16_t * blocks) { // Old Block mcb.SetSize(found_seg_size-*blocks-1); mcb.SetPSPSeg(MCB_FREE); - mcb.SetType(0x4D); + mcb.SetType(mcb_type_M); } return true; } @@ -275,7 +276,8 @@ bool DOS_AllocateMemory(uint16_t * segment,uint16_t * blocks) { DOS_SetError(DOSERR_INSUFFICIENT_MEMORY); return false; } - } else mcb_segment+=mcb.GetSize()+1; + } else + mcb_segment += mcb.GetSize() + 1; } return false; } @@ -287,7 +289,7 @@ bool DOS_ResizeMemory(uint16_t segment,uint16_t * blocks) { } DOS_MCB mcb(segment-1); - if ((mcb.GetType()!=0x4d) && (mcb.GetType()!=0x5a)) { + if ((mcb.GetType() != mcb_type_M) && (mcb.GetType() != mcb_type_Z)) { DOS_SetError(DOSERR_MCB_DESTROYED); return false; } @@ -304,9 +306,9 @@ bool DOS_ResizeMemory(uint16_t segment,uint16_t * blocks) { DOS_MCB mcb_new_next(segment+(*blocks)); mcb.SetSize(*blocks); mcb_new_next.SetType(mcb.GetType()); - if (mcb.GetType()==0x5a) { + if (mcb.GetType() == mcb_type_Z) { /* Further blocks follow */ - mcb.SetType(0x4d); + mcb.SetType(mcb_type_M); } mcb_new_next.SetSize(total-*blocks-1); @@ -316,13 +318,13 @@ bool DOS_ResizeMemory(uint16_t segment,uint16_t * blocks) { return true; } /* MCB will grow, try to join with following MCB */ - if (mcb.GetType()!=0x5a) { + if (mcb.GetType() != mcb_type_Z) { if (mcb_next.GetPSPSeg()==MCB_FREE) { total+=mcb_next.GetSize()+1; } } if (*blocks<total) { - if (mcb.GetType()!=0x5a) { + if (mcb.GetType() != mcb_type_Z) { /* save type of following MCB */ mcb.SetType(mcb_next.GetType()); } @@ -331,7 +333,7 @@ bool DOS_ResizeMemory(uint16_t segment,uint16_t * blocks) { mcb_next.SetSize(total-*blocks-1); mcb_next.SetType(mcb.GetType()); mcb_next.SetPSPSeg(MCB_FREE); - mcb.SetType(0x4d); + mcb.SetType(mcb_type_M); mcb.SetPSPSeg(dos.psp()); DOS_CompressMemory(); return true; @@ -340,7 +342,7 @@ bool DOS_ResizeMemory(uint16_t segment,uint16_t * blocks) { /* at this point: *blocks==total (fits) or *blocks>total, in the second case resize block to maximum */ - if ((mcb_next.GetPSPSeg()==MCB_FREE) && (mcb.GetType()!=0x5a)) { + if ((mcb_next.GetPSPSeg() == MCB_FREE) && (mcb.GetType() != mcb_type_Z)) { /* adjust type of joined MCB */ mcb.SetType(mcb_next.GetType()); } @@ -363,7 +365,7 @@ bool DOS_FreeMemory(uint16_t segment) { } DOS_MCB mcb(segment-1); - if ((mcb.GetType()!=0x4d) && (mcb.GetType()!=0x5a)) { + if ((mcb.GetType() != mcb_type_M) && (mcb.GetType() != mcb_type_Z)) { DOS_SetError(DOSERR_MB_ADDRESS_INVALID); return false; } @@ -385,12 +387,12 @@ void DOS_BuildUMBChain(bool umb_active,bool ems_active) { DOS_MCB umb_mcb(first_umb_seg); umb_mcb.SetPSPSeg(0); // currently free umb_mcb.SetSize(first_umb_size-1); - umb_mcb.SetType(0x5a); + umb_mcb.SetType(mcb_type_Z); /* Scan MCB-chain for last block */ uint16_t mcb_segment=dos.firstMCB; DOS_MCB mcb(mcb_segment); - while (mcb.GetType()!=0x5a) { + while (mcb.GetType() != mcb_type_Z) { mcb_segment+=mcb.GetSize()+1; mcb.SetPt(mcb_segment); } @@ -399,7 +401,7 @@ void DOS_BuildUMBChain(bool umb_active,bool ems_active) { regular MCB-chain and the UMBs */ uint16_t cover_mcb=(uint16_t)(mcb_segment+mcb.GetSize()+1); mcb.SetPt(cover_mcb); - mcb.SetType(0x4d); + mcb.SetType(mcb_type_M); mcb.SetPSPSeg(0x0008); mcb.SetSize(first_umb_seg-cover_mcb-1); mcb.SetFileName("SC "); @@ -424,7 +426,7 @@ bool DOS_LinkUMBsToMemChain(uint16_t linkstate) { uint16_t mcb_segment=dos.firstMCB; uint16_t prev_mcb_segment=dos.firstMCB; DOS_MCB mcb(mcb_segment); - while ((mcb_segment!=umb_start) && (mcb.GetType()!=0x5a)) { + while ((mcb_segment != umb_start) && (mcb.GetType() != mcb_type_Z)) { prev_mcb_segment=mcb_segment; mcb_segment+=mcb.GetSize()+1; mcb.SetPt(mcb_segment); @@ -433,17 +435,18 @@ bool DOS_LinkUMBsToMemChain(uint16_t linkstate) { switch (linkstate) { case 0x0000: // unlink - if ((prev_mcb.GetType()==0x4d) && (mcb_segment==umb_start)) { - prev_mcb.SetType(0x5a); - } - dos_infoblock.SetUMBChainState(0); + if ((prev_mcb.GetType() == mcb_type_M) && + (mcb_segment == umb_start)) { + prev_mcb.SetType(mcb_type_Z); + } + dos_infoblock.SetUMBChainState(0); break; case 0x0001: // link - if (mcb.GetType()==0x5a) { - mcb.SetType(0x4d); - dos_infoblock.SetUMBChainState(1); - } - break; + if (mcb.GetType() == mcb_type_Z) { + mcb.SetType(mcb_type_M); + dos_infoblock.SetUMBChainState(1); + } + break; default: LOG_MSG("Invalid link state %x when reconfiguring MCB chain",linkstate); return false; @@ -470,8 +473,8 @@ void DOS_SetupMemory(void) { DOS_MCB mcb_devicedummy((uint16_t)DOS_MEM_START); mcb_devicedummy.SetPSPSeg(MCB_DOS); // Devices mcb_devicedummy.SetSize(1); - mcb_devicedummy.SetType(0x4d); // More blocks will follow -// mcb_devicedummy.SetFileName("SD "); + mcb_devicedummy.SetType(mcb_type_M); // More blocks will follow + // mcb_devicedummy.SetFileName("SD "); uint16_t mcb_sizes=2; // Create a small empty MCB (result from a growing environment block) @@ -479,18 +482,18 @@ void DOS_SetupMemory(void) { tempmcb.SetPSPSeg(MCB_FREE); tempmcb.SetSize(4); mcb_sizes+=5; - tempmcb.SetType(0x4d); + tempmcb.SetType(mcb_type_M); // Lock the previous empty MCB DOS_MCB tempmcb2((uint16_t)DOS_MEM_START+mcb_sizes); tempmcb2.SetPSPSeg(0x40); // can be removed by loadfix tempmcb2.SetSize(16); mcb_sizes+=17; - tempmcb2.SetType(0x4d); + tempmcb2.SetType(mcb_type_M); DOS_MCB mcb((uint16_t)DOS_MEM_START+mcb_sizes); mcb.SetPSPSeg(MCB_FREE); //Free - mcb.SetType(0x5a); //Last Block + mcb.SetType(mcb_type_Z); // Last Block if (machine==MCH_TANDY) { /* memory up to 608k available, the rest (to 640k) is used by the tandy graphics system's variable mapping of 0xb800 */ @@ -500,17 +503,17 @@ void DOS_SetupMemory(void) { mcb_devicedummy.SetPt((uint16_t)0x2000); mcb_devicedummy.SetPSPSeg(MCB_FREE); mcb_devicedummy.SetSize(0x9FFF - 0x2000); - mcb_devicedummy.SetType(0x5a); + mcb_devicedummy.SetType(mcb_type_Z); /* exclude PCJr graphics region */ mcb_devicedummy.SetPt((uint16_t)0x17ff); mcb_devicedummy.SetPSPSeg(MCB_DOS); mcb_devicedummy.SetSize(0x800); - mcb_devicedummy.SetType(0x4d); + mcb_devicedummy.SetType(mcb_type_M); /* memory below 96k */ mcb.SetSize(0x1800 - DOS_MEM_START - (2+mcb_sizes)); - mcb.SetType(0x4d); + mcb.SetType(mcb_type_M); } else { /* complete memory up to 640k available */ /* last paragraph used to add UMB chain to low-memory MCB chain */ |