Segment OVERLAY renamed to REPLACE. Bugfix for read-only segments. Formatting.

This commit is contained in:
Laubzega
2018-09-04 00:34:28 -07:00
parent 1b0e2cf783
commit cd9efd53fe
4 changed files with 15 additions and 17 deletions

View File

@@ -194,8 +194,8 @@ static void BinWriteMem (BinDesc* D, MemoryArea* M)
} }
if (DoWrite || (M->Flags & MF_FILL) != 0) { if (DoWrite || (M->Flags & MF_FILL) != 0) {
/* Seek in "overlay" segments */ /* Seek in "overlay" segments */
if (S->Flags & SF_OVERLAY) { if (S->Flags & SF_REPLACE) {
fseek(D->F, NewAddr - M->Start, SEEK_SET); fseek (D->F, NewAddr - M->Start, SEEK_SET);
} else { } else {
WriteMult (D->F, M->FillVal, NewAddr-Addr); WriteMult (D->F, M->FillVal, NewAddr-Addr);
PrintNumVal ("SF_OFFSET", NewAddr - Addr); PrintNumVal ("SF_OFFSET", NewAddr - Addr);

View File

@@ -653,7 +653,7 @@ static void ParseSegments (void)
{ "RW", CFGTOK_RW }, { "RW", CFGTOK_RW },
{ "BSS", CFGTOK_BSS }, { "BSS", CFGTOK_BSS },
{ "ZP", CFGTOK_ZP }, { "ZP", CFGTOK_ZP },
{ "OVERLAY", CFGTOK_OVERLAY }, { "REPLACE", CFGTOK_REPLACE },
}; };
unsigned Count; unsigned Count;
@@ -758,7 +758,7 @@ static void ParseSegments (void)
case CFGTOK_RW: /* Default */ break; case CFGTOK_RW: /* Default */ break;
case CFGTOK_BSS: S->Flags |= SF_BSS; break; case CFGTOK_BSS: S->Flags |= SF_BSS; break;
case CFGTOK_ZP: S->Flags |= (SF_BSS | SF_ZP); break; case CFGTOK_ZP: S->Flags |= (SF_BSS | SF_ZP); break;
case CFGTOK_OVERLAY: S->Flags |= SF_OVERLAY; break; case CFGTOK_REPLACE: S->Flags |= (SF_REPLACE | SF_RO); break;
default: Internal ("Unexpected token: %d", CfgTok); default: Internal ("Unexpected token: %d", CfgTok);
} }
CfgNextTok (); CfgNextTok ();
@@ -1854,17 +1854,15 @@ unsigned CfgProcess (void)
/* Take note of overlayed segments and make sure there are no other /* Take note of overlayed segments and make sure there are no other
** segment types following them in current memory region. ** segment types following them in current memory region.
*/ */
if (S->Flags & SF_OVERLAY) { if (S->Flags & SF_REPLACE) {
{
if (S->Flags & (SF_OFFSET | SF_START)) { if (S->Flags & (SF_OFFSET | SF_START)) {
++Overlays; ++Overlays;
} else { } else {
CfgError (GetSourcePos (M->LI), CfgError (GetSourcePos (M->LI),
"Segment `%s' of type `overlay' requires either" "Segment `%s' of type `overlay' requires either"
" `Start' or `Offset' argument to be specified.", " `Start' or `Offset' attribute to be specified",
GetString (S->Name)); GetString (S->Name));
} }
}
} else { } else {
if (Overlays > 0) { if (Overlays > 0) {
CfgError (GetSourcePos (M->LI), CfgError (GetSourcePos (M->LI),
@@ -1923,10 +1921,10 @@ unsigned CfgProcess (void)
NewAddr += M->Start; NewAddr += M->Start;
} }
if (S->Flags & SF_OVERLAY) { if (S->Flags & SF_REPLACE) {
if (NewAddr < M->Start) { if (NewAddr < M->Start) {
CfgError (GetSourcePos (S->LI), CfgError (GetSourcePos (S->LI),
"Segment `%s' begins before memory area `%s'.", "Segment `%s' begins before memory area `%s'",
GetString (S->Name), GetString (M->Name)); GetString (S->Name), GetString (M->Name));
} else { } else {
Addr = NewAddr; Addr = NewAddr;

View File

@@ -96,7 +96,7 @@ struct SegDesc {
#define SF_RUN_DEF 0x0200 /* RUN symbols already defined */ #define SF_RUN_DEF 0x0200 /* RUN symbols already defined */
#define SF_LOAD_DEF 0x0400 /* LOAD symbols already defined */ #define SF_LOAD_DEF 0x0400 /* LOAD symbols already defined */
#define SF_FILLVAL 0x0800 /* Segment has separate fill value */ #define SF_FILLVAL 0x0800 /* Segment has separate fill value */
#define SF_OVERLAY 0x1000 /* Segment can be overlayed on another one */ #define SF_REPLACE 0x1000 /* Segment can replace (part of) another one */

View File

@@ -105,7 +105,7 @@ typedef enum {
CFGTOK_RW, CFGTOK_RW,
CFGTOK_BSS, CFGTOK_BSS,
CFGTOK_ZP, CFGTOK_ZP,
CFGTOK_OVERLAY, CFGTOK_REPLACE,
CFGTOK_O65, CFGTOK_O65,
CFGTOK_BIN, CFGTOK_BIN,