From 2138f3c902f2bcbe538a62fae5e7e36c36ea2c2a Mon Sep 17 00:00:00 2001 From: rumbledethumps <16963588+rumbledethumps@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:24:55 -0800 Subject: [PATCH] add clock() to RP6502 --- include/rp6502.h | 1 + include/time.h | 2 ++ libsrc/rp6502/clock.c | 7 +++++++ 3 files changed, 10 insertions(+) create mode 100644 libsrc/rp6502/clock.c diff --git a/include/rp6502.h b/include/rp6502.h index 2b40cfc71..61664c78f 100644 --- a/include/rp6502.h +++ b/include/rp6502.h @@ -101,6 +101,7 @@ long __fastcall__ ria_call_long_errno (unsigned char op); #define RIA_OP_CODEPAGE 0x03 #define RIA_OP_LRAND 0x04 #define RIA_OP_STDIN_OPT 0x05 +#define RIA_OP_CLOCK 0x0F #define RIA_OP_CLOCK_GETRES 0x10 #define RIA_OP_CLOCK_GETTIME 0x11 #define RIA_OP_CLOCK_SETTIME 0x12 diff --git a/include/time.h b/include/time.h index f8977ab0c..5eb6f144a 100644 --- a/include/time.h +++ b/include/time.h @@ -86,6 +86,8 @@ struct tm { # define CLOCKS_PER_SEC 135 /* FIXME */ #elif defined(__GEOS__) # define CLOCKS_PER_SEC 1 +#elif defined (__RP6502__) +# define CLOCKS_PER_SEC 100 #elif defined(__TELESTRAT__) # define CLOCKS_PER_SEC 10 #elif defined(__ATARI__) || defined (__LYNX__) diff --git a/libsrc/rp6502/clock.c b/libsrc/rp6502/clock.c new file mode 100644 index 000000000..f8756f553 --- /dev/null +++ b/libsrc/rp6502/clock.c @@ -0,0 +1,7 @@ +#include +#include + +clock_t __fastcall__ clock (void) +{ + return ria_call_long (RIA_OP_CLOCK); +}