Added support for C64 .PRG output format (#194)

This commit is contained in:
ggn 2022-12-20 23:48:39 +02:00 committed by Shamus Hammons
parent 0172b60145
commit 45c9dc2361
1 changed files with 29 additions and 0 deletions

29
6502.c
View File

@ -569,3 +569,32 @@ void m6502obj(int ofd)
}
}
//
// Generate a C64 .PRG output file
//
void m6502c64(int ofd)
{
uint8_t header[2];
CHUNK * ch = sect[M6502].scode;
// If no 6502 code was generated, bail out
if ((ch == NULL) || (ch->challoc == 0))
return;
if (currentorg != &orgmap[1][0])
{
// More than one 6502 section created, this is not allowed
error("when generating C64 .PRG files only one org section is allowed - aborting");
return;
}
SETLE16(header, 0, orgmap[0][0]);
register uint8_t * p = ch->chptr;
// Write header
uint32_t unused = write(ofd, header, 2);
// Write the data
unused = write(ofd, p + orgmap[0][0], orgmap[0][1] - orgmap[0][0]);
}