From cd9efd53fe1b4588e5473452304960f3072ed529 Mon Sep 17 00:00:00 2001 From: Laubzega Date: Tue, 4 Sep 2018 00:34:28 -0700 Subject: [PATCH] Segment OVERLAY renamed to REPLACE. Bugfix for read-only segments. Formatting. --- src/ld65/bin.c | 4 ++-- src/ld65/config.c | 24 +++++++++++------------- src/ld65/config.h | 2 +- src/ld65/scanner.h | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/ld65/bin.c b/src/ld65/bin.c index f4d241add..c94ac9319 100644 --- a/src/ld65/bin.c +++ b/src/ld65/bin.c @@ -194,8 +194,8 @@ static void BinWriteMem (BinDesc* D, MemoryArea* M) } if (DoWrite || (M->Flags & MF_FILL) != 0) { /* Seek in "overlay" segments */ - if (S->Flags & SF_OVERLAY) { - fseek(D->F, NewAddr - M->Start, SEEK_SET); + if (S->Flags & SF_REPLACE) { + fseek (D->F, NewAddr - M->Start, SEEK_SET); } else { WriteMult (D->F, M->FillVal, NewAddr-Addr); PrintNumVal ("SF_OFFSET", NewAddr - Addr); diff --git a/src/ld65/config.c b/src/ld65/config.c index f6603d628..5c61bdd3f 100644 --- a/src/ld65/config.c +++ b/src/ld65/config.c @@ -653,7 +653,7 @@ static void ParseSegments (void) { "RW", CFGTOK_RW }, { "BSS", CFGTOK_BSS }, { "ZP", CFGTOK_ZP }, - { "OVERLAY", CFGTOK_OVERLAY }, + { "REPLACE", CFGTOK_REPLACE }, }; unsigned Count; @@ -754,12 +754,12 @@ static void ParseSegments (void) FlagAttr (&S->Attr, SA_TYPE, "TYPE"); CfgSpecialToken (Types, ENTRY_COUNT (Types), "Type"); switch (CfgTok) { - case CFGTOK_RO: S->Flags |= SF_RO; break; - case CFGTOK_RW: /* Default */ break; - case CFGTOK_BSS: S->Flags |= SF_BSS; break; - case CFGTOK_ZP: S->Flags |= (SF_BSS | SF_ZP); break; - case CFGTOK_OVERLAY: S->Flags |= SF_OVERLAY; break; - default: Internal ("Unexpected token: %d", CfgTok); + case CFGTOK_RO: S->Flags |= SF_RO; break; + case CFGTOK_RW: /* Default */ break; + case CFGTOK_BSS: S->Flags |= SF_BSS; break; + case CFGTOK_ZP: S->Flags |= (SF_BSS | SF_ZP); break; + case CFGTOK_REPLACE: S->Flags |= (SF_REPLACE | SF_RO); break; + default: Internal ("Unexpected token: %d", CfgTok); } CfgNextTok (); break; @@ -1854,17 +1854,15 @@ unsigned CfgProcess (void) /* Take note of overlayed segments and make sure there are no other ** 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)) { ++Overlays; } else { CfgError (GetSourcePos (M->LI), "Segment `%s' of type `overlay' requires either" - " `Start' or `Offset' argument to be specified.", + " `Start' or `Offset' attribute to be specified", GetString (S->Name)); } - } } else { if (Overlays > 0) { CfgError (GetSourcePos (M->LI), @@ -1923,10 +1921,10 @@ unsigned CfgProcess (void) NewAddr += M->Start; } - if (S->Flags & SF_OVERLAY) { + if (S->Flags & SF_REPLACE) { if (NewAddr < M->Start) { CfgError (GetSourcePos (S->LI), - "Segment `%s' begins before memory area `%s'.", + "Segment `%s' begins before memory area `%s'", GetString (S->Name), GetString (M->Name)); } else { Addr = NewAddr; diff --git a/src/ld65/config.h b/src/ld65/config.h index a60580da3..d172560bd 100644 --- a/src/ld65/config.h +++ b/src/ld65/config.h @@ -96,7 +96,7 @@ struct SegDesc { #define SF_RUN_DEF 0x0200 /* RUN symbols already defined */ #define SF_LOAD_DEF 0x0400 /* LOAD symbols already defined */ #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 */ diff --git a/src/ld65/scanner.h b/src/ld65/scanner.h index e994c0547..2c60da975 100644 --- a/src/ld65/scanner.h +++ b/src/ld65/scanner.h @@ -105,7 +105,7 @@ typedef enum { CFGTOK_RW, CFGTOK_BSS, CFGTOK_ZP, - CFGTOK_OVERLAY, + CFGTOK_REPLACE, CFGTOK_O65, CFGTOK_BIN, -- 2.39.5