Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove va_start warning from rp6502 xregn #295

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions mos-platform/rp6502/rp6502.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct __RP6502 {

/* C API for the operating system. */

int xregn(char device, char channel, unsigned char address, unsigned char count,
int xregn(char device, char channel, unsigned char address, unsigned count,
...);
int phi2(void);
int codepage(void);
Expand Down Expand Up @@ -95,13 +95,6 @@ long lseek(int fd, long offset, int whence);
unsigned char _sysremove(const char *name);
unsigned char _sysrename(const char *oldpath, const char *newpath);

/* XREG location helpers */

#define xreg_ria_keyboard(...) xreg(0, 0, 0, __VA_ARGS__)
#define xreg_ria_mouse(...) xreg(0, 0, 1, __VA_ARGS__)
#define xreg_vga_canvas(...) xreg(1, 0, 0, __VA_ARGS__)
#define xreg_vga_mode(...) xreg(1, 0, 1, __VA_ARGS__)

/* XRAM structure helpers */

#define xram0_struct_set(addr, type, member, val) \
Expand Down
9 changes: 6 additions & 3 deletions mos-platform/rp6502/xregn.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#include "rp6502.h"
#include <stdarg.h>

int xregn(char device, char channel, unsigned char address, unsigned char count,
int 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;
for (unsigned char i = 0; i < count; i++)
RIA.xstack = (char)va_arg(args, unsigned);
for (unsigned i = 0; i < count; i++) {
unsigned v = va_arg(args, unsigned);
RIA.xstack = v >> 8;
RIA.xstack = v;
}
va_end(args);
RIA.op = RIA_OP_XREG;
while (RIA.busy & RIA_BUSY_BIT)
Expand Down