Open polluks opened 4 years ago
I have some command line parsing code which works in sortdir.c
. It is conditionally compiled out at the moment because it is only useful for programs which are small enough to load from BASIC.SYSTEM
(ie: fit from 0x2000 to 0x9600 if it is a SYSTEM file). However you can swipe the code if you like, or we can re-do it in ASM if that is better for cc65.
#define MAXNUMARGS 10
int argc;
char *argv[MAXNUMARGS];
void parseargs() {
char *p;
char i = 0, s = 0, prev = ' ';
argc = 1;
for (p = (char*)0x200; p <= (char*)0x27f; ++p) {
*p &= 0x7f;
if ((*p == 0) || (*p == 0x0d)) {
argv[argc - 1] = buf + s;
break;
}
if (*p == ' ') {
if (prev != ' ') {
buf[i++] = '\0';
argv[argc - 1] = buf + s;
s = i;
++argc;
}
} else {
buf[i++] = *p;
}
prev = *p;
}
}
#endif
@bobbimanners Thanks, I think we have to wait for the release of 2.5.
How about officially supporting ProDOS 2.5 command line parameters in cc65?