1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-28 19:29:53 +00:00

Default is now automatic execution of program after loading

This commit is contained in:
Stephan Mühlstrasser 2014-11-23 20:05:38 +01:00
parent dfbd2912cc
commit 16bdb10bfe

View File

@ -27,6 +27,7 @@ static void Usage (void)
"Short options:\n" "Short options:\n"
" -V\t\t\tPrint the version number\n" " -V\t\t\tPrint the version number\n"
" -h\t\t\tHelp (this text)\n" " -h\t\t\tHelp (this text)\n"
" -n\t\tNo automatic start after loading program\n"
" -o name\t\tName the C1P output file (default: <input>.c1p)\n" " -o name\t\tName the C1P output file (default: <input>.c1p)\n"
" -S addr\t\tLoad address (default 0x300)\n" " -S addr\t\tLoad address (default 0x300)\n"
"\n" "\n"
@ -79,16 +80,17 @@ static unsigned long CvtNumber (const char* Arg, const char* Number)
} }
/* Commands of C1P PROM monitor */ /* Commands of C1P PROM monitor */
#define ADDRESS_MODE_CMD '.' #define ADDRESS_MODE_CMD '.'
#define DATA_MODE_CMD '/' #define DATA_MODE_CMD '/'
#define EXECUTE_CMD 'G' #define EXECUTE_CMD 'G'
#define DATA_MODE_ADDRESS 0x00FB #define DATA_MODE_ADDRESS 0x00FB
/* Transform the cc65 executable binary into a series of /* Transform the cc65 executable binary into a series of
commands that make the C1P PROM monitor load the bytes commands that make the C1P PROM monitor load the bytes
into memory. into memory.
*/ */
static void Transform (unsigned long StartAddress, FILE *In, FILE *Out) static void Transform (unsigned long StartAddress, FILE *In, FILE *Out,
unsigned AutoStart)
{ {
int c; int c;
@ -101,15 +103,17 @@ static void Transform (unsigned long StartAddress, FILE *In, FILE *Out)
fprintf(Out, "%02.2X\n", (unsigned int) c & 0xFF); fprintf(Out, "%02.2X\n", (unsigned int) c & 0xFF);
} }
/* Store 00 to 0x00FB to enable keyboard input at the end */ if (AutoStart) {
fprintf(Out, "%c%04.4X%c%02.2X\n", ADDRESS_MODE_CMD, /* Execute */
0x00FB, DATA_MODE_CMD, 0x00); fprintf (Out, "%c%04.4x%c",
/* And execute
fprintf (Out, "%c%04.4x%c",
ADDRESS_MODE_CMD, (unsigned int) StartAddress & 0xFFFF, ADDRESS_MODE_CMD, (unsigned int) StartAddress & 0xFFFF,
EXECUTE_CMD); EXECUTE_CMD);
*/ }
else {
/* Store 00 to 0x00FB to enable keyboard input at the end */
fprintf(Out, "%c%04.4X%c%02.2X\n", ADDRESS_MODE_CMD,
0x00FB, DATA_MODE_CMD, 0x00);
}
} }
/* Default suffix for C1P object file */ /* Default suffix for C1P object file */
@ -135,6 +139,9 @@ int main (int argc, char *argv[])
/* Initialize with default start address defined in c1p.cfg */ /* Initialize with default start address defined in c1p.cfg */
unsigned long StartAddr = 0x300; unsigned long StartAddr = 0x300;
/* Start program automatically after loading */
unsigned AutoStart = 1;
unsigned int I; unsigned int I;
/* Initialize the cmdline module */ /* Initialize the cmdline module */
@ -155,11 +162,15 @@ int main (int argc, char *argv[])
LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0])); LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
break; break;
case 'o': case 'n':
OutputFile = GetArg (&I, 2); AutoStart = 0;
break; break;
case 'S': case 'o':
OutputFile = GetArg(&I, 2);
break;
case 'S':
StartAddr = CvtNumber (Arg, GetArg (&I, 2)); StartAddr = CvtNumber (Arg, GetArg (&I, 2));
break; break;
@ -206,7 +217,7 @@ int main (int argc, char *argv[])
if (!OutputFileFp) AbEnd ("Unable to open output file"); if (!OutputFileFp) AbEnd ("Unable to open output file");
/* Generate object file */ /* Generate object file */
Transform (StartAddr, InputFileFp, OutputFileFp); Transform (StartAddr, InputFileFp, OutputFileFp, AutoStart);
/* Cleanup */ /* Cleanup */
if (fclose(InputFileFp) == EOF) AbEnd ("Error closing input file"); if (fclose(InputFileFp) == EOF) AbEnd ("Error closing input file");