From: cuz Date: Sun, 16 Sep 2001 18:16:09 +0000 (+0000) Subject: Added text tables X-Git-Tag: V2.12.0~2643 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0f4acb37c687984ce95f519d5c2509aacf66ff55;p=cc65 Added text tables git-svn-id: svn://svn.cc65.org/cc65/trunk@941 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/da65/attrtab.h b/src/da65/attrtab.h index 94898d62d..50d39b016 100644 --- a/src/da65/attrtab.h +++ b/src/da65/attrtab.h @@ -55,6 +55,7 @@ typedef enum attr_t { atDWordTab = 0x05, atAddrTab = 0x06, atRtsTab = 0x07, + atTextTab = 0x08, /* Label flags */ atNoLabel = 0x00, /* No label for this address */ diff --git a/src/da65/config.c b/src/da65/config.c index 7bbe46340..f6fefab7f 100644 --- a/src/da65/config.c +++ b/src/da65/config.c @@ -153,6 +153,7 @@ static void RangeSection (void) { "DWORDTABLE", CFGTOK_DWORDTAB }, { "ADDRTABLE", CFGTOK_ADDRTAB }, { "RTSTABLE", CFGTOK_RTSTAB }, + { "TEXTTABLE", CFGTOK_TEXTTAB }, }; @@ -213,6 +214,7 @@ static void RangeSection (void) case CFGTOK_DWORDTAB: Type = atDWordTab; break; case CFGTOK_ADDRTAB: Type = atAddrTab; break; case CFGTOK_RTSTAB: Type = atRtsTab; break; + case CFGTOK_TEXTTAB: Type = atTextTab; break; } Needed |= tType; CfgNextTok (); diff --git a/src/da65/data.c b/src/da65/data.c index 8e21fd621..81c628ae8 100644 --- a/src/da65/data.c +++ b/src/da65/data.c @@ -263,3 +263,82 @@ unsigned RtsTable (void) +unsigned TextTable (void) +/* Output a table of text messages */ +{ + /* Count how many bytes may be output. */ + unsigned ByteCount = GetSpan (atTextTab); + + /* Output as many data bytes lines as needed. */ + unsigned BytesLeft = ByteCount; + while (BytesLeft > 0) { + + unsigned I; + + /* Count the number of characters that can be output as such */ + unsigned Count = 0; + while (Count < BytesLeft && Count < BytesPerLine*4-1) { + unsigned char C = GetCodeByte (PC + Count); + if (C >= 0x20 && C <= 0x7E && C != '\"') { + ++Count; + } else { + break; + } + } + + /* If we have text, output it */ + if (Count > 0) { + unsigned CBytes; + Indent (MIndent); + Output (".text"); + Indent (AIndent); + Output ("\""); + for (I = 0; I < Count; ++I) { + Output ("%c", GetCodeByte (PC+I)); + } + Output ("\""); + CBytes = Count; + while (CBytes > 0) { + unsigned Chunk = CBytes; + if (Chunk > BytesPerLine) { + Chunk = BytesPerLine; + } + LineComment (PC, Chunk); + LineFeed (); + CBytes -= Chunk; + PC += Chunk; + } + BytesLeft -= Count; + } + + /* Count the number of bytes that must be output as bytes */ + Count = 0; + while (Count < BytesLeft && Count < BytesPerLine) { + unsigned char C = GetCodeByte (PC + Count); + if (C < 0x20 || C > 0x7E || C == '\"') { + ++Count; + } else { + break; + } + } + + /* If we have raw output bytes, print them */ + if (Count > 0) { + DataByteLine (Count); + PC += Count; + BytesLeft -= Count; + } + + } + + /* If the next line is not a byte table line, add a separator */ + if (CodeLeft() && GetStyleAttr (PC) != atTextTab) { + SeparatorLine (); + } + + /* Return the number of bytes output */ + return ByteCount; +} + + + diff --git a/src/da65/data.h b/src/da65/data.h index 0594f8bbb..997c51283 100644 --- a/src/da65/data.h +++ b/src/da65/data.h @@ -58,7 +58,10 @@ unsigned AddrTable (void); unsigned RtsTable (void); /* Output a table of RTS addresses (address - 1) */ - + +unsigned TextTable (void); +/* Output a table of text messages */ + /* End of data.h */ diff --git a/src/da65/main.c b/src/da65/main.c index 761b11eed..c321074f4 100644 --- a/src/da65/main.c +++ b/src/da65/main.c @@ -267,6 +267,10 @@ static void OneOpcode (unsigned RemainingBytes) RtsTable (); break; + case atTextTab: + TextTable (); + break; + default: DataByteLine (1); ++PC; diff --git a/src/da65/output.c b/src/da65/output.c index df21f03a3..24977cf40 100644 --- a/src/da65/output.c +++ b/src/da65/output.c @@ -138,9 +138,9 @@ void Indent (unsigned N) void LineFeed (void) /* Add a linefeed to the output file */ { - if (Pass == PassCount && PageLength > 0) { + if (Pass == PassCount) { fputc ('\n', F); - if (++Line >= PageLength) { + if (PageLength > 0 && ++Line >= PageLength) { if (FormFeeds) { fputc ('\f', F); } diff --git a/src/da65/scanner.h b/src/da65/scanner.h index 71e4ea23a..ec14e0973 100644 --- a/src/da65/scanner.h +++ b/src/da65/scanner.h @@ -81,6 +81,7 @@ typedef enum token_t { CFGTOK_DWORDTAB, CFGTOK_ADDRTAB, CFGTOK_RTSTAB, + CFGTOK_TEXTTAB, /* Label section */ CFGTOK_NAME,