aboutsummaryrefslogtreecommitdiffstats
path: root/src/uxn.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/uxn.h')
-rw-r--r--src/uxn.h57
1 files changed, 0 insertions, 57 deletions
diff --git a/src/uxn.h b/src/uxn.h
deleted file mode 100644
index 5d68528..0000000
--- a/src/uxn.h
+++ /dev/null
@@ -1,57 +0,0 @@
1#ifndef UXNGBA_UXN_H
2#define UXNGBA_UXN_H
3
4#include <stdio.h>
5
6/*
7Copyright (c) 2021 Devine Lu Linvega
8
9Permission to use, copy, modify, and distribute this software for any
10purpose with or without fee is hereby granted, provided that the above
11copyright notice and this permission notice appear in all copies.
12
13THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14WITH REGARD TO THIS SOFTWARE.
15*/
16
17#define PAGE_PROGRAM 0x0100
18#define DEVPEEK16(o, x) { (o) = (d->dat[(x)] << 8) + d->dat[(x) + 1]; }
19#define DEVPOKE16(x, y) { d->dat[(x)] = (y) >> 8; d->dat[(x) + 1] = (y); }
20
21typedef struct {
22 u8 ptr, kptr, error;
23 u8 dat[256];
24} Stack;
25
26typedef struct {
27 u16 ptr;
28 u8 *dat;
29} Memory;
30
31typedef struct Device {
32 struct Uxn *u;
33 u8 addr, dat[16], *mem;
34 u16 vector;
35 void (*talk)(struct Device *d, u8, u8);
36} Device;
37
38typedef struct Uxn {
39 Stack wst, rst, *src, *dst;
40 Memory ram;
41 Device dev[16];
42} Uxn;
43
44struct Uxn;
45
46static inline void mempoke8(u8 *m, u16 a, u8 b) { m[a] = b; }
47static inline u8 mempeek8(u8 *m, u16 a) { return m[a]; }
48static inline void mempoke16(u8 *m, u16 a, u16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); }
49static inline u16 mempeek16(u8 *m, u16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); }
50static inline void devpoke8(Device *d, u8 a, u8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); }
51static inline u8 devpeek8(Device *d, u8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; }
52static inline void devpoke16(Device *d, u8 a, u16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); }
53static inline u16 devpeek16(Device *d, u16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); }
54
55int uxn_eval(Uxn *u, u16 vec);
56Device *uxn_port(Uxn *u, u8 id, char *name, void (*talkfn)(Device *, u8, u8));
57#endif // UXNGBA_UXN_H