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.h37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/uxn/uxn.h b/src/uxn/uxn.h
index 6c6d53e..a4ab428 100644
--- a/src/uxn/uxn.h
+++ b/src/uxn/uxn.h
@@ -14,27 +14,22 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14WITH REGARD TO THIS SOFTWARE. 14WITH REGARD TO THIS SOFTWARE.
15*/ 15*/
16 16
17typedef unsigned char Uint8;
18typedef signed char Sint8;
19typedef unsigned short Uint16;
20typedef signed short Sint16;
21
22#define PAGE_PROGRAM 0x0100 17#define PAGE_PROGRAM 0x0100
23 18
24typedef struct { 19typedef struct {
25 Uint8 ptr, kptr, error; 20 u8 ptr, kptr, error;
26 Uint8 dat[256]; 21 u8 dat[256];
27} Stack; 22} Stack;
28 23
29typedef struct { 24typedef struct {
30 Uint16 ptr; 25 u16 ptr;
31 Uint8 *dat; 26 u8 *dat;
32} Memory; 27} Memory;
33 28
34typedef struct Device { 29typedef struct Device {
35 struct Uxn *u; 30 struct Uxn *u;
36 Uint8 addr, dat[16], *mem; 31 u8 addr, dat[16], *mem;
37 void (*talk)(struct Device *d, Uint8, Uint8); 32 void (*talk)(struct Device *d, u8, u8);
38} Device; 33} Device;
39 34
40typedef struct Uxn { 35typedef struct Uxn {
@@ -45,17 +40,17 @@ typedef struct Uxn {
45 40
46struct Uxn; 41struct Uxn;
47 42
48static inline void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; } 43static inline void mempoke8(u8 *m, u16 a, u8 b) { m[a] = b; }
49static inline Uint8 mempeek8(Uint8 *m, Uint16 a) { return m[a]; } 44static inline u8 mempeek8(u8 *m, u16 a) { return m[a]; }
50static inline void mempoke16(Uint8 *m, Uint16 a, Uint16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); } 45static inline void mempoke16(u8 *m, u16 a, u16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); }
51static inline Uint16 mempeek16(Uint8 *m, Uint16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); } 46static inline u16 mempeek16(u8 *m, u16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); }
52static inline void devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); } 47static inline void devpoke8(Device *d, u8 a, u8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); }
53static inline Uint8 devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; } 48static inline u8 devpeek8(Device *d, u8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; }
54static inline void devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); } 49static inline void devpoke16(Device *d, u8 a, u16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); }
55static inline Uint16 devpeek16(Device *d, Uint16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); } 50static inline u16 devpeek16(Device *d, u16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); }
56 51
57int loaduxn(Uxn *c, char *filepath); 52int loaduxn(Uxn *c, char *filepath);
58int bootuxn(Uxn *c); 53int bootuxn(Uxn *c);
59int evaluxn(Uxn *u, Uint16 vec); 54int evaluxn(Uxn *u, u16 vec);
60Device *portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *, Uint8, Uint8)); 55Device *portuxn(Uxn *u, u8 id, char *name, void (*talkfn)(Device *, u8, u8));
61#endif // UXNGBA_UXN_H 56#endif // UXNGBA_UXN_H