From 776b355ee300c7469d63a3988b07ea7a22056b1e Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 30 Jun 2024 21:13:18 -0800 Subject: [PATCH] Do not pass memory in controller device --- src/devices/controller.c | 20 ++++++++++---------- src/devices/controller.h | 6 +++--- src/uxn11.c | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/devices/controller.c b/src/devices/controller.c index 9602cc7..a9e9ad3 100644 --- a/src/devices/controller.c +++ b/src/devices/controller.c @@ -13,29 +13,29 @@ WITH REGARD TO THIS SOFTWARE. */ void -controller_down(Uint8 *d, Uint8 mask) +controller_down(Uint8 mask) { if(mask) { - d[2] |= mask; - uxn_eval(PEEK2(d)); + uxn.dev[0x82] |= mask; + uxn_eval(PEEK2(&uxn.dev[0x80])); } } void -controller_up(Uint8 *d, Uint8 mask) +controller_up(Uint8 mask) { if(mask) { - d[2] &= (~mask); - uxn_eval(PEEK2(d)); + uxn.dev[0x82] &= (~mask); + uxn_eval(PEEK2(&uxn.dev[0x80])); } } void -controller_key(Uint8 *d, Uint8 key) +controller_key(Uint8 key) { if(key) { - d[3] = key; - uxn_eval(PEEK2(d)); - d[3] = 0x00; + uxn.dev[0x83] = key; + uxn_eval(PEEK2(&uxn.dev[0x80])); + uxn.dev[0x83] = 0; } } diff --git a/src/devices/controller.h b/src/devices/controller.h index 8b408fc..2d4fa7f 100644 --- a/src/devices/controller.h +++ b/src/devices/controller.h @@ -11,6 +11,6 @@ WITH REGARD TO THIS SOFTWARE. #define CONTROL_VERSION 1 -void controller_down(Uint8 *d, Uint8 mask); -void controller_up(Uint8 *d, Uint8 mask); -void controller_key(Uint8 *d, Uint8 key); +void controller_down(Uint8 mask); +void controller_up(Uint8 mask); +void controller_key(Uint8 key); diff --git a/src/uxn11.c b/src/uxn11.c index e7f66e6..1ad9a89 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -158,14 +158,14 @@ emu_event(void) case XK_F4: emu_restart(boot_rom, 0); break; case XK_F5: emu_restart(boot_rom, 1); break; } - controller_down(&uxn.dev[0x80], get_button(sym)); - controller_key(&uxn.dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]); + controller_down(get_button(sym)); + controller_key(sym < 0x80 ? sym : (Uint8)buf[0]); } break; case KeyRelease: { KeySym sym; char buf[7]; XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0); - controller_up(&uxn.dev[0x80], get_button(sym)); + controller_up(get_button(sym)); } break; case ButtonPress: { XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;