diff options
Diffstat (limited to 'src/uxn.h')
-rw-r--r-- | src/uxn.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/uxn.h b/src/uxn.h new file mode 100644 index 0000000..e904e24 --- /dev/null +++ b/src/uxn.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | Copyright (c) 2021 Devine Lu Linvega | ||
3 | |||
4 | Permission to use, copy, modify, and distribute this software for any | ||
5 | purpose with or without fee is hereby granted, provided that the above | ||
6 | copyright notice and this permission notice appear in all copies. | ||
7 | |||
8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
9 | WITH REGARD TO THIS SOFTWARE. | ||
10 | */ | ||
11 | |||
12 | typedef unsigned char Uint8; | ||
13 | typedef signed char Sint8; | ||
14 | typedef unsigned short Uint16; | ||
15 | typedef signed short Sint16; | ||
16 | |||
17 | #define PAGE_PROGRAM 0x0100 | ||
18 | |||
19 | typedef struct { | ||
20 | Uint8 ptr, kptr, error; | ||
21 | Uint8 dat[256]; | ||
22 | } Stack; | ||
23 | |||
24 | typedef struct { | ||
25 | Uint16 ptr; | ||
26 | Uint8 dat[65536]; | ||
27 | } Memory; | ||
28 | |||
29 | typedef struct Device { | ||
30 | struct Uxn *u; | ||
31 | Uint8 addr, dat[16], *mem; | ||
32 | void (*talk)(struct Device *d, Uint8, Uint8); | ||
33 | } Device; | ||
34 | |||
35 | typedef struct Uxn { | ||
36 | Stack wst, rst, *src, *dst; | ||
37 | Memory ram; | ||
38 | Device dev[16]; | ||
39 | } Uxn; | ||
40 | |||
41 | struct Uxn; | ||
42 | |||
43 | void mempoke16(Uint8 *m, Uint16 a, Uint16 b); | ||
44 | Uint16 mempeek16(Uint8 *m, Uint16 a); | ||
45 | |||
46 | int uxn_boot(Uxn *c); | ||
47 | int uxn_eval(Uxn *u, Uint16 vec); | ||
48 | int uxn_halt(Uxn *u, Uint8 error, char *name, int id); | ||
49 | Device *uxn_port(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *, Uint8, Uint8)); | ||