1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 20:29:34 +00:00

Added text tables

git-svn-id: svn://svn.cc65.org/cc65/trunk@941 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-09-16 18:16:09 +00:00
parent 308785487f
commit 0f4acb37c6
7 changed files with 93 additions and 3 deletions

View File

@ -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 */

View File

@ -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 ();

View File

@ -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;
}

View File

@ -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 */

View File

@ -267,6 +267,10 @@ static void OneOpcode (unsigned RemainingBytes)
RtsTable ();
break;
case atTextTab:
TextTable ();
break;
default:
DataByteLine (1);
++PC;

View File

@ -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);
}

View File

@ -81,6 +81,7 @@ typedef enum token_t {
CFGTOK_DWORDTAB,
CFGTOK_ADDRTAB,
CFGTOK_RTSTAB,
CFGTOK_TEXTTAB,
/* Label section */
CFGTOK_NAME,