ProDOS-Utils icon indicating copy to clipboard operation
ProDOS-Utils copied to clipboard

Feature Request: cmd line

Open polluks opened this issue 5 years ago • 2 comments

How about officially supporting ProDOS 2.5 command line parameters in cc65?

polluks avatar Jun 03 '20 10:06 polluks

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 avatar Jun 03 '20 13:06 bobbimanners

@bobbimanners Thanks, I think we have to wait for the release of 2.5.

polluks avatar Jun 03 '20 15:06 polluks