/* */
/* */
/* */
-/* (C) 2000 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 2000-2003 Ullrich von Bassewitz */
+/* Römerstraße 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#include <string.h>
#include <errno.h>
-#include "../common/segdefs.h"
-#include "../common/version.h"
+/* common */
+#include "check.h"
+#include "fname.h"
+#include "fragdefs.h"
+#include "version.h"
+#include "xmalloc.h"
+/* ca65 */
#include "error.h"
-#include "fname.h"
+#include "filetab.h"
#include "global.h"
-#include "mem.h"
-#include "objcode.h"
#include "listing.h"
+#include "segment.h"
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
/* Page and other formatting */
int PageLength = -1; /* Length of a listing page */
static unsigned PageNumber = 1; /* Current listing page number */
-static unsigned PageLines = 0; /* Current line on page */
+static int PageLines = 0; /* Current line on page */
static unsigned ListBytes = 12; /* Number of bytes to list for one line */
/* Switch the listing on/off */
}
/* Allocate memory */
- L = Xmalloc (sizeof (ListLine) + Len);
+ L = xmalloc (sizeof (ListLine) + Len);
/* Initialize the fields. */
L->Next = 0;
if (Listing) {
if (ListingEnabled == 0) {
/* Cannot switch the listing off once more */
- Error (ERR_COUNTER_UNDERFLOW);
+ Error ("Counter underflow");
} else {
--ListingEnabled;
}
{
if (Listing) {
/* Make the last loaded line the current line */
- LineCur = LineLast;
+ /* ###### This code is a hack! We really need to do it right
+ * as soon as we know, how:-(
+ */
+ if (LineCur && LineCur->Next && LineCur->Next != LineLast) {
+ ListLine* L = LineCur;
+ do {
+ L = L->Next;
+ /* Set the values for this line */
+ CHECK (L != 0);
+ L->PC = GetPC ();
+ L->Reloc = RelocMode;
+ L->Output = (ListingEnabled > 0);
+ L->ListBytes = (unsigned char) ListBytes;
+ } while (L->Next != LineLast);
+ }
+ LineCur = LineLast;
- /* Set the values for this line */
- CHECK (LineCur != 0);
- LineCur->PC = GetPC ();
- LineCur->Reloc = RelocMode;
- LineCur->Output = (ListingEnabled > 0);
+ /* Set the values for this line */
+ CHECK (LineCur != 0);
+ LineCur->PC = GetPC ();
+ LineCur->Reloc = RelocMode;
+ LineCur->Output = (ListingEnabled > 0);
LineCur->ListBytes = (unsigned char) ListBytes;
}
}
*/
{
/* Print the header on the new page */
- fprintf (F,
- "ca65 V%u.%u.%u - (C) Copyright 1998-2000 Ullrich von Bassewitz\n"
+ fprintf (F,
+ "ca65 V%u.%u.%u - %s\n"
"Main file : %s\n"
"Current file: %s\n"
"\n",
VER_MAJOR, VER_MINOR, VER_PATCH,
+ Copyright,
InFile,
GetFileName (L->File));
/* Open the real listing file */
F = fopen (ListFile, "w");
if (F == 0) {
- Fatal (FAT_CANNOT_OPEN_LISTING, strerror (errno));
+ Fatal ("Cannot open listing file: %s", strerror (errno));
}
/* Reset variables, print the header for the first page */
}
/* Allocate memory for the given number of bytes */
- Buf = Xmalloc (Count*2+1);
+ Buf = xmalloc (Count*2+1);
/* Copy an ASCII representation of the bytes into the buffer */
B = Buf;
break;
case FRAG_EXPR:
- case FRAG_SEXPR:
+ case FRAG_SEXPR:
B = AddMult (B, 'r', Frag->Len*2);
break;
}
/* Delete the temporary buffer */
- Xfree (Buf);
+ xfree (Buf);
/* Next line */
L = L->Next;