diff options
Diffstat (limited to 'src/uxn.h')
-rw-r--r-- | src/uxn.h | 57 |
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 | /* | ||
7 | Copyright (c) 2021 Devine Lu Linvega | ||
8 | |||
9 | Permission to use, copy, modify, and distribute this software for any | ||
10 | purpose with or without fee is hereby granted, provided that the above | ||
11 | copyright notice and this permission notice appear in all copies. | ||
12 | |||
13 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
14 | WITH 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 | |||
21 | typedef struct { | ||
22 | u8 ptr, kptr, error; | ||
23 | u8 dat[256]; | ||
24 | } Stack; | ||
25 | |||
26 | typedef struct { | ||
27 | u16 ptr; | ||
28 | u8 *dat; | ||
29 | } Memory; | ||
30 | |||
31 | typedef 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 | |||
38 | typedef struct Uxn { | ||
39 | Stack wst, rst, *src, *dst; | ||
40 | Memory ram; | ||
41 | Device dev[16]; | ||
42 | } Uxn; | ||
43 | |||
44 | struct Uxn; | ||
45 | |||
46 | static inline void mempoke8(u8 *m, u16 a, u8 b) { m[a] = b; } | ||
47 | static inline u8 mempeek8(u8 *m, u16 a) { return m[a]; } | ||
48 | static inline void mempoke16(u8 *m, u16 a, u16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); } | ||
49 | static inline u16 mempeek16(u8 *m, u16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); } | ||
50 | static inline void devpoke8(Device *d, u8 a, u8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); } | ||
51 | static inline u8 devpeek8(Device *d, u8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; } | ||
52 | static inline void devpoke16(Device *d, u8 a, u16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); } | ||
53 | static inline u16 devpeek16(Device *d, u16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); } | ||
54 | |||
55 | int uxn_eval(Uxn *u, u16 vec); | ||
56 | Device *uxn_port(Uxn *u, u8 id, char *name, void (*talkfn)(Device *, u8, u8)); | ||
57 | #endif // UXNGBA_UXN_H | ||