Skip to content

Commit

Permalink
Added -v option to embed a version string into the loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
iratahack authored and Craig Hackney committed Nov 18, 2024
1 parent c769e6b commit d9d0fff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions loader.asm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ start:
jr start1
dw blocks
dw loadBlock
dw version
version:
ds 32
start1:
di
ld sp, stack
Expand Down
22 changes: 21 additions & 1 deletion zxctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ typedef struct __attribute__((packed))
uint16_t destAddr;
} blocks_t;

#define VERSION "v0.5"
#define VERSION "v0.6"
#define MAX_OFFSET_ZX0 32640
#define MAX_OFFSET_ZX7 2176
#define MAX_INPUT 0x10000
Expand Down Expand Up @@ -64,6 +64,7 @@ void usage(void)
fprintf(stderr, "\t must be reserved in bank 2 for the loader\n");
fprintf(stderr, "\t-w,--wav Convert the .tap file to a .wav file\n");
fprintf(stderr, "\t-f,--fast Enable turbo loader, implies -w and -c\n");
fprintf(stderr, "\t-v,--version <ver> Embed version string <ver> into loader\n");
fprintf(stderr, "\n");

exit(1);
Expand Down Expand Up @@ -184,6 +185,7 @@ int main(int argc, char **argv)
int wavOut = 0;
int ROMLoader = 1;
int custom = 0;
char *versionString = NULL;

printf("ZX Spectrum Compressed Tape Loader (ZXCTL)\n");
printf("Version %s, (C) 2023 IrataHack, All Rights Reserved.\n\n", VERSION);
Expand Down Expand Up @@ -301,6 +303,24 @@ int main(int argc, char **argv)
exit(1);
}
}
else if ((strcmp(argv[arg], "--version") == 0) || (strcmp(argv[arg], "-v") == 0))
{
if (++arg < argc)
{
versionString = argv[arg];

if (debug)
printf("Version : %s\n", versionString);

if ((!strlen(versionString)) || (strlen(versionString) > 31))
{
fprintf(stderr, "Invalid version string\n");
exit(1);
}

memcpy(&loader_bin[8], versionString, strlen(versionString));
}
}
else if ((strcmp(argv[arg], "--quick") == 0) || (strcmp(argv[arg], "-q") == 0))
{
quick = 1;
Expand Down

0 comments on commit d9d0fff

Please sign in to comment.