From 4b561acea52ffabb3200cc7696900814647e1af3 Mon Sep 17 00:00:00 2001 From: rumbledethumps <16963588+rumbledethumps@users.noreply.github.com> Date: Thu, 16 Oct 2025 16:20:23 -0700 Subject: [PATCH] all dir commands --- include/rp6502.h | 9 ++++----- libsrc/rp6502/f_getcwd.c | 14 ++++++++++++++ libsrc/rp6502/f_getfree.c | 22 ++++++++++++++++++++++ libsrc/rp6502/f_getlabel.c | 21 +++++++++++++++++++++ libsrc/rp6502/f_setlabel.c | 16 ++++++++++++++++ 5 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 libsrc/rp6502/f_getcwd.c create mode 100644 libsrc/rp6502/f_getfree.c create mode 100644 libsrc/rp6502/f_getlabel.c create mode 100644 libsrc/rp6502/f_setlabel.c diff --git a/include/rp6502.h b/include/rp6502.h index 85916e390..b029789b8 100644 --- a/include/rp6502.h +++ b/include/rp6502.h @@ -166,11 +166,10 @@ int __fastcall__ f_chmod (const char* path, unsigned char attr, unsigned char ma int __fastcall__ f_utime (const char* path, unsigned fdate, unsigned ftime, unsigned crdate, unsigned crtime); int __fastcall__ f_mkdir (const char* name); int __fastcall__ f_chdrive (const char* name); -// int __fastcall__ f_getcwd(char* name, unsigned len); -// int __fastcall__ f_setlabel(const char* name); -// int __fastcall__ f_getlabel(const char* path, char* label); -// int __fastcall__ f_getfree(const char* name); - +int __fastcall__ f_getcwd (char* name, unsigned len); +int __fastcall__ f_setlabel (const char* name); +int __fastcall__ f_getlabel (const char* path, char* label); +int __fastcall__ f_getfree (const char* name, unsigned long* free, unsigned long* total); /* Time zone hack */ diff --git a/libsrc/rp6502/f_getcwd.c b/libsrc/rp6502/f_getcwd.c new file mode 100644 index 000000000..477474cbf --- /dev/null +++ b/libsrc/rp6502/f_getcwd.c @@ -0,0 +1,14 @@ +#include +#include +#include + +int __fastcall__ f_getcwd (char* name, unsigned len) +{ + int i, ax; + ria_set_ax (len); + ax = ria_call_int (RIA_OP_GETCWD); + for (i = 0; i < ax; i++) { + name[i] = ria_pop_char (); + } + return ax; +} diff --git a/libsrc/rp6502/f_getfree.c b/libsrc/rp6502/f_getfree.c new file mode 100644 index 000000000..13240591f --- /dev/null +++ b/libsrc/rp6502/f_getfree.c @@ -0,0 +1,22 @@ +#include +#include +#include + +int __fastcall__ f_getfree (const char* name, unsigned long* free, unsigned long* total) +{ + int ax; + size_t namelen = strlen (name); + if (namelen > 255) { + errno = EINVAL; + return -1; + } + while (namelen) { + ria_push_char (name[--namelen]); + } + ax = ria_call_int (RIA_OP_GETFREE); + if (ax >= 0) { + *free = ria_pop_long (); + *total = ria_pop_long (); + } + return ax; +} diff --git a/libsrc/rp6502/f_getlabel.c b/libsrc/rp6502/f_getlabel.c new file mode 100644 index 000000000..89e72eac9 --- /dev/null +++ b/libsrc/rp6502/f_getlabel.c @@ -0,0 +1,21 @@ +#include +#include +#include + +int __fastcall__ f_getlabel (const char* path, char* label) +{ + int i, ax; + size_t pathlen = strlen (path); + if (pathlen > 255) { + errno = EINVAL; + return -1; + } + while (pathlen) { + ria_push_char (path[--pathlen]); + } + ax = ria_call_int (RIA_OP_GETLABEL); + for (i = 0; i < ax; i++) { + label[i] = ria_pop_char (); + } + return ax; +} diff --git a/libsrc/rp6502/f_setlabel.c b/libsrc/rp6502/f_setlabel.c new file mode 100644 index 000000000..0cf77ea15 --- /dev/null +++ b/libsrc/rp6502/f_setlabel.c @@ -0,0 +1,16 @@ +#include +#include +#include + +int __fastcall__ f_setlabel (const char* name) +{ + size_t namelen = strlen (name); + if (namelen > 255) { + errno = EINVAL; + return -1; + } + while (namelen) { + ria_push_char (name[--namelen]); + } + return ria_call_int (RIA_OP_SETLABEL); +}