diff --git a/asminc/rp6502.inc b/asminc/rp6502.inc index 7dd1b8fcd..816712abb 100644 --- a/asminc/rp6502.inc +++ b/asminc/rp6502.inc @@ -37,6 +37,7 @@ RIA_OP_PHI2 := $02 RIA_OP_CODEPAGE := $03 RIA_OP_LRAND := $04 RIA_OP_STDIN_OPT := $05 +RIA_OP_CLOCK := $0F RIA_OP_CLOCK_GETRES := $10 RIA_OP_CLOCK_GETTIME := $11 RIA_OP_CLOCK_SETTIME := $12 diff --git a/include/rp6502.h b/include/rp6502.h index 2b40cfc71..7deeebc4c 100644 --- a/include/rp6502.h +++ b/include/rp6502.h @@ -47,8 +47,7 @@ struct __RP6502 unsigned char step1; unsigned int addr1; unsigned char xstack; - unsigned char errno_lo; - unsigned char errno_hi; + unsigned int errno; unsigned char op; unsigned char irq; const unsigned char spin; @@ -101,6 +100,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 @@ -117,6 +117,8 @@ long __fastcall__ ria_call_long_errno (unsigned char op); /* C API for the operating system. */ +int __cdecl__ xregn (char device, char channel, unsigned char address, unsigned count, + ...); int __cdecl__ xreg (char device, char channel, unsigned char address, ...); int phi2 (void); int codepage (void); 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); +} diff --git a/libsrc/rp6502/read.c b/libsrc/rp6502/read.c index eb96f779c..87a9bbf7d 100644 --- a/libsrc/rp6502/read.c +++ b/libsrc/rp6502/read.c @@ -5,7 +5,7 @@ int __fastcall__ read (int fildes, void* buf, unsigned count) { int total = 0; while (count) { - unsigned blockcount = (count > 256) ? 256 : count; + unsigned blockcount = (count > 512) ? 512 : count; int bytes_read = read_xstack (&((char*)buf)[total], blockcount, fildes); if (bytes_read < 0) { return bytes_read; diff --git a/libsrc/rp6502/sysrename.c b/libsrc/rp6502/sysrename.c index 96eca24cf..46bdd8b31 100644 --- a/libsrc/rp6502/sysrename.c +++ b/libsrc/rp6502/sysrename.c @@ -7,7 +7,7 @@ unsigned char __fastcall__ _sysrename (const char* oldpath, const char* newpath) size_t oldpathlen, newpathlen; oldpathlen = strlen (oldpath); newpathlen = strlen (newpath); - if (oldpathlen + newpathlen > 254) { + if (oldpathlen + newpathlen > 510) { return _mappederrno (EINVAL); } while (oldpathlen) { diff --git a/libsrc/rp6502/write.c b/libsrc/rp6502/write.c index 11241dab5..23877b6e8 100644 --- a/libsrc/rp6502/write.c +++ b/libsrc/rp6502/write.c @@ -5,7 +5,7 @@ int __fastcall__ write (int fildes, const void* buf, unsigned count) { int ax, total = 0; while (count) { - int blockcount = (count > 256) ? 256 : count; + int blockcount = (count > 512) ? 512 : count; ax = write_xstack (&((char*)buf)[total], blockcount, fildes); if (ax < 0) { return ax; diff --git a/libsrc/rp6502/write_xstack.c b/libsrc/rp6502/write_xstack.c index b53aa95e7..29285a87e 100644 --- a/libsrc/rp6502/write_xstack.c +++ b/libsrc/rp6502/write_xstack.c @@ -1,8 +1,12 @@ #include +#include int __fastcall__ write_xstack (const void* buf, unsigned count, int fildes) { unsigned i; + if (count > 512) { + return _mappederrno (EINVAL); + } for (i = count; i;) { ria_push_char (((char*)buf)[--i]); } diff --git a/libsrc/rp6502/xregn.c b/libsrc/rp6502/xregn.c new file mode 100644 index 000000000..ec040be20 --- /dev/null +++ b/libsrc/rp6502/xregn.c @@ -0,0 +1,19 @@ +#include +#include + +int __cdecl__ xregn (char device, char channel, unsigned char address, unsigned count, + ...) +{ + va_list args; + va_start (args, count); + RIA.xstack = device; + RIA.xstack = channel; + RIA.xstack = address; + while (count--) { + unsigned v = va_arg (args, unsigned); + RIA.xstack = v >> 8; + RIA.xstack = v; + } + va_end (args); + return ria_call_int_errno (RIA_OP_XREG); +}