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