From 4d3153e10e185323ca0d89c4d17b43bdffa803ca Mon Sep 17 00:00:00 2001 From: rumbledethumps <16963588+rumbledethumps@users.noreply.github.com> Date: Sat, 17 Feb 2024 16:02:57 -0800 Subject: [PATCH] add rp6502 xregn --- include/rp6502.h | 2 ++ libsrc/rp6502/xregn.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 libsrc/rp6502/xregn.c diff --git a/include/rp6502.h b/include/rp6502.h index 53028c35a..7deeebc4c 100644 --- a/include/rp6502.h +++ b/include/rp6502.h @@ -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/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); +}