diff options
Diffstat (limited to 'src/uxn/uxn.h')
-rw-r--r-- | src/uxn/uxn.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/uxn/uxn.h b/src/uxn/uxn.h new file mode 100644 index 0000000..b2c90ac --- /dev/null +++ b/src/uxn/uxn.h | |||
@@ -0,0 +1,55 @@ | |||
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 | typedef unsigned char Uint8; | ||
18 | typedef signed char Sint8; | ||
19 | typedef unsigned short Uint16; | ||
20 | typedef signed short Sint16; | ||
21 | |||
22 | #define PAGE_PROGRAM 0x0100 | ||
23 | |||
24 | typedef struct { | ||
25 | Uint8 ptr, kptr, error; | ||
26 | Uint8 dat[256]; | ||
27 | } Stack; | ||
28 | |||
29 | typedef struct { | ||
30 | Uint16 ptr; | ||
31 | Uint8 dat[KB(16)]; | ||
32 | } Memory; | ||
33 | |||
34 | typedef struct Device { | ||
35 | struct Uxn *u; | ||
36 | Uint8 addr, dat[16], *mem; | ||
37 | void (*talk)(struct Device *d, Uint8, Uint8); | ||
38 | } Device; | ||
39 | |||
40 | typedef struct Uxn { | ||
41 | Stack wst, rst, *src, *dst; | ||
42 | Memory ram; | ||
43 | Device dev[16]; | ||
44 | } Uxn; | ||
45 | |||
46 | struct Uxn; | ||
47 | |||
48 | void mempoke16(Uint8 *m, Uint16 a, Uint16 b); | ||
49 | Uint16 mempeek16(Uint8 *m, Uint16 a); | ||
50 | |||
51 | int loaduxn(Uxn *c, char *filepath); | ||
52 | int bootuxn(Uxn *c); | ||
53 | int evaluxn(Uxn *u, Uint16 vec); | ||
54 | Device *portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *, Uint8, Uint8)); | ||
55 | #endif // UXNGBA_UXN_H | ||