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