Similar changes as for the C output target: If the attribute "ident" is given,
place the data into a .PROC with this name. Add additional constants named COLORS, WIDTH and HEIGHT within this .PROC. git-svn-id: svn://svn.cc65.org/cc65/trunk@5684 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -56,7 +56,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int ValidAsmLabel (const char* L)
|
static int ValidIdentifier (const char* L)
|
||||||
/* Check an assembler label for validity */
|
/* Check an assembler label for validity */
|
||||||
{
|
{
|
||||||
/* Must begin with underscore or alphabetic character */
|
/* Must begin with underscore or alphabetic character */
|
||||||
@@ -113,28 +113,15 @@ static unsigned GetBase (const Collection* A)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const char* GetLabel (const Collection* A)
|
static const char* GetIdentifier (const Collection* A)
|
||||||
/* Return the assembler label from the attribute collection A */
|
/* Return the label identifier from the attribute collection A */
|
||||||
{
|
{
|
||||||
/* Check for a label attribute */
|
/* Check for a ident attribute */
|
||||||
const char* Label = GetAttrVal (A, "label");
|
const char* Ident = GetAttrVal (A, "ident");
|
||||||
if (Label && !ValidAsmLabel (Label)) {
|
if (Ident && !ValidIdentifier (Ident)) {
|
||||||
Error ("Invalid value for attribute `label'");
|
Error ("Invalid value for attribute `ident'");
|
||||||
}
|
}
|
||||||
return Label;
|
return Ident;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const char* GetSegment (const Collection* A)
|
|
||||||
/* Return the segment name from the attribute collection A */
|
|
||||||
{
|
|
||||||
/* Check for a label attribute */
|
|
||||||
const char* Seg = GetAttrVal (A, "segment");
|
|
||||||
if (Seg && !ValidAsmLabel (Seg)) {
|
|
||||||
Error ("Invalid value for attribute `segment'");
|
|
||||||
}
|
|
||||||
return Seg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -159,11 +146,8 @@ void WriteAsmFile (const StrBuf* Data, const Collection* A, const Bitmap* B)
|
|||||||
/* Get the number base */
|
/* Get the number base */
|
||||||
unsigned Base = GetBase (A);
|
unsigned Base = GetBase (A);
|
||||||
|
|
||||||
/* Get the assembler label */
|
/* Get the identifier */
|
||||||
const char* Label = GetLabel (A);
|
const char* Ident = GetIdentifier (A);
|
||||||
|
|
||||||
/* Get the segment */
|
|
||||||
const char* Segment = GetSegment (A);
|
|
||||||
|
|
||||||
/* Open the output file */
|
/* Open the output file */
|
||||||
F = fopen (Name, "w");
|
F = fopen (Name, "w");
|
||||||
@@ -185,14 +169,17 @@ void WriteAsmFile (const StrBuf* Data, const Collection* A, const Bitmap* B)
|
|||||||
GetBitmapColors (B),
|
GetBitmapColors (B),
|
||||||
BitmapIsIndexed (B)? ", indexed" : "");
|
BitmapIsIndexed (B)? ", indexed" : "");
|
||||||
|
|
||||||
/* If we have a segment defined, output a segment directive */
|
|
||||||
if (Segment) {
|
|
||||||
fprintf (F, ".segment \"%s\"\n\n", Segment);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we have an assembler label, output that */
|
/* If we have an assembler label, output that */
|
||||||
if (Label) {
|
if (Ident) {
|
||||||
fprintf (F, "%s:\n", Label);
|
fprintf (F,
|
||||||
|
".proc %s\n"
|
||||||
|
" COLORS = %u\n"
|
||||||
|
" WIDTH = %u\n"
|
||||||
|
" HEIGHT = %u\n",
|
||||||
|
Ident,
|
||||||
|
GetBitmapColors (B),
|
||||||
|
GetBitmapWidth (B),
|
||||||
|
GetBitmapHeight (B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the data */
|
/* Write the data */
|
||||||
@@ -238,6 +225,11 @@ void WriteAsmFile (const StrBuf* Data, const Collection* A, const Bitmap* B)
|
|||||||
Size -= Chunk;
|
Size -= Chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Terminate the .proc if we had an identifier */
|
||||||
|
if (Ident) {
|
||||||
|
fputs (".endproc\n", F);
|
||||||
|
}
|
||||||
|
|
||||||
/* Add an empty line at the end */
|
/* Add an empty line at the end */
|
||||||
fputc ('\n', F);
|
fputc ('\n', F);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user