1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-27 00:29:31 +00:00

Enter bytes in a loop in data mode

This commit is contained in:
Stephan Mühlstrasser 2014-11-02 23:22:41 +01:00
parent 57a422d064
commit 29801cd45f

View File

@ -82,6 +82,7 @@ static unsigned long CvtNumber (const char* Arg, const char* Number)
#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
/* 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
@ -90,19 +91,20 @@ static unsigned long CvtNumber (const char* Arg, const char* Number)
static void Transform (unsigned long StartAddress, FILE *In, FILE *Out) static void Transform (unsigned long StartAddress, FILE *In, FILE *Out)
{ {
int c; int c;
unsigned long CurrentAddress;
/* Loop over all input bytes, position to current address, /* Position to the start address */
switch to data mod, output input byte fprintf(Out, "%c%04.4X%c", ADDRESS_MODE_CMD,
*/ StartAddress & 0xFFFF, DATA_MODE_CMD);
for (CurrentAddress = StartAddress, c = getc(In);
c != EOF; /* Loop over all input bytes and enter them one by one */
c = getc(In), CurrentAddress += 1) { for (c = getc(In); c != EOF; c = getc(In)) {
fprintf (Out, "%c%04.4X%c%02.2X", fprintf(Out, "%02.2X\n", (unsigned int) c & 0xFF);
ADDRESS_MODE_CMD, (unsigned int) CurrentAddress & 0xFFFF,
DATA_MODE_CMD, (unsigned int) c & 0xFF);
} }
/* 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);
/* And execute /* And execute
fprintf (Out, "%c%04.4x%c", fprintf (Out, "%c%04.4x%c",
ADDRESS_MODE_CMD, (unsigned int) StartAddress & 0xFFFF, ADDRESS_MODE_CMD, (unsigned int) StartAddress & 0xFFFF,