Removed GETVEC macro
This commit is contained in:
parent
5917f409c5
commit
416f37c71a
4
build.sh
4
build.sh
|
@ -2,8 +2,8 @@
|
|||
|
||||
RELEASE_FLAGS="-Os -DNDEBUG -g0 -s"
|
||||
DEBUG_FLAGS="-std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined"
|
||||
EMU_INC="src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11"
|
||||
CLI_INC="src/uxn.c src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli"
|
||||
EMU_INC="src/uxn.c src/devices/system.c src/devices/console.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11"
|
||||
CLI_INC="src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli"
|
||||
|
||||
# find X11 libs on various systems
|
||||
if [ -e /usr/X11R6 ]; then
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../uxn.h"
|
||||
#include "console.h"
|
||||
|
||||
/*
|
||||
Copyright (c) 2022-2023 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
int
|
||||
console_input(Uxn *u, char c)
|
||||
{
|
||||
Uint8 *d = &u->dev[0x10];
|
||||
d[0x02] = c;
|
||||
return uxn_eval(u, PEEK2(d));
|
||||
}
|
||||
|
||||
void
|
||||
console_deo(Uint8 *d, Uint8 port)
|
||||
{
|
||||
FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr :
|
||||
0;
|
||||
if(fd) {
|
||||
fputc(d[port], fd);
|
||||
fflush(fd);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
Copyright (c) 2021 Devine Lu Linvega, Andrew Alderwick
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
int console_input(Uxn *u, char c);
|
||||
void console_deo(Uint8 *d, Uint8 port);
|
|
@ -17,7 +17,7 @@ controller_down(Uxn *u, Uint8 *d, Uint8 mask)
|
|||
{
|
||||
if(mask) {
|
||||
d[2] |= mask;
|
||||
uxn_eval(u, GETVEC(d));
|
||||
uxn_eval(u, PEEK2(d));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ controller_up(Uxn *u, Uint8 *d, Uint8 mask)
|
|||
{
|
||||
if(mask) {
|
||||
d[2] &= (~mask);
|
||||
uxn_eval(u, GETVEC(d));
|
||||
uxn_eval(u, PEEK2(d));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ controller_key(Uxn *u, Uint8 *d, Uint8 key)
|
|||
{
|
||||
if(key) {
|
||||
d[3] = key;
|
||||
uxn_eval(u, GETVEC(d));
|
||||
uxn_eval(u, PEEK2(d));
|
||||
d[3] = 0x00;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,14 +16,14 @@ void
|
|||
mouse_down(Uxn *u, Uint8 *d, Uint8 mask)
|
||||
{
|
||||
d[6] |= mask;
|
||||
uxn_eval(u, GETVEC(d));
|
||||
uxn_eval(u, PEEK2(d));
|
||||
}
|
||||
|
||||
void
|
||||
mouse_up(Uxn *u, Uint8 *d, Uint8 mask)
|
||||
{
|
||||
d[6] &= (~mask);
|
||||
uxn_eval(u, GETVEC(d));
|
||||
uxn_eval(u, PEEK2(d));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -31,7 +31,7 @@ mouse_pos(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
|
|||
{
|
||||
POKDEV(0x2, x);
|
||||
POKDEV(0x4, y);
|
||||
uxn_eval(u, GETVEC(d));
|
||||
uxn_eval(u, PEEK2(d));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -39,7 +39,7 @@ mouse_scroll(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
|
|||
{
|
||||
POKDEV(0xa, x);
|
||||
POKDEV(0xc, -y);
|
||||
uxn_eval(u, GETVEC(d));
|
||||
uxn_eval(u, PEEK2(d));
|
||||
POKDEV(0xa, 0);
|
||||
POKDEV(0xc, 0);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ int
|
|||
uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr)
|
||||
{
|
||||
Uint8 *d = &u->dev[0x00];
|
||||
Uint16 handler = GETVEC(d);
|
||||
Uint16 handler = PEEK2(d);
|
||||
if(handler) {
|
||||
u->wst->ptr = 4;
|
||||
u->wst->dat[0] = addr >> 0x8;
|
||||
|
|
|
@ -19,7 +19,9 @@ typedef unsigned int Uint32;
|
|||
|
||||
/* clang-format off */
|
||||
|
||||
#define GETVEC(d) ((d)[0] << 8 | (d)[1])
|
||||
#define POKE2(d, v) { (d)[0] = (v) >> 8; (d)[1] = (v); }
|
||||
#define PEEK2(d) ((d)[0] << 8 | (d)[1])
|
||||
|
||||
#define POKDEV(x, y) { d[(x)] = (y) >> 8; d[(x) + 1] = (y); }
|
||||
#define PEKDEV(o, x) { (o) = (d[(x)] << 8) + d[(x) + 1]; }
|
||||
|
||||
|
|
24
src/uxn11.c
24
src/uxn11.c
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "uxn.h"
|
||||
#include "devices/system.h"
|
||||
#include "devices/console.h"
|
||||
#include "devices/screen.h"
|
||||
#include "devices/controller.h"
|
||||
#include "devices/mouse.h"
|
||||
|
@ -46,25 +47,6 @@ emu_error(char *msg, const char *err)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
console_input(Uxn *u, char c)
|
||||
{
|
||||
Uint8 *d = &u->dev[0x10];
|
||||
d[0x02] = c;
|
||||
return uxn_eval(u, GETVEC(d));
|
||||
}
|
||||
|
||||
static void
|
||||
console_deo(Uint8 *d, Uint8 port)
|
||||
{
|
||||
FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr :
|
||||
0;
|
||||
if(fd) {
|
||||
fputc(d[port], fd);
|
||||
fflush(fd);
|
||||
}
|
||||
}
|
||||
|
||||
static Uint8
|
||||
emu_dei(Uxn *u, Uint8 addr)
|
||||
{
|
||||
|
@ -260,8 +242,8 @@ main(int argc, char **argv)
|
|||
while(XPending(display))
|
||||
emu_event(&u);
|
||||
if(poll(&fds[1], 1, 0)) {
|
||||
read(fds[1].fd, expirations, 8); /* Indicate we handled the timer */
|
||||
uxn_eval(&u, GETVEC(&u.dev[0x20])); /* Call the vector once, even if the timer fired multiple times */
|
||||
read(fds[1].fd, expirations, 8); /* Indicate we handled the timer */
|
||||
uxn_eval(&u, PEEK2(&u.dev[0x20])); /* Call the vector once, even if the timer fired multiple times */
|
||||
}
|
||||
if((fds[2].revents & POLLIN) != 0) {
|
||||
n = read(fds[2].fd, coninp, CONINBUFSIZE - 1);
|
||||
|
|
|
@ -31,7 +31,7 @@ console_input(Uxn *u, char c)
|
|||
{
|
||||
Uint8 *d = &u->dev[0x10];
|
||||
d[0x02] = c;
|
||||
return uxn_eval(u, GETVEC(d));
|
||||
return uxn_eval(u, PEEK2(d));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue