diff options
Diffstat (limited to 'src/uxn/uxn.h')
-rw-r--r-- | src/uxn/uxn.h | 37 |
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 | |||
14 | WITH REGARD TO THIS SOFTWARE. | 14 | WITH REGARD TO THIS SOFTWARE. |
15 | */ | 15 | */ |
16 | 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 | 17 | #define PAGE_PROGRAM 0x0100 |
23 | 18 | ||
24 | typedef struct { | 19 | typedef 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 | ||
29 | typedef struct { | 24 | typedef struct { |
30 | Uint16 ptr; | 25 | u16 ptr; |
31 | Uint8 *dat; | 26 | u8 *dat; |
32 | } Memory; | 27 | } Memory; |
33 | 28 | ||
34 | typedef struct Device { | 29 | typedef 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 | ||
40 | typedef struct Uxn { | 35 | typedef struct Uxn { |
@@ -45,17 +40,17 @@ typedef struct Uxn { | |||
45 | 40 | ||
46 | struct Uxn; | 41 | struct Uxn; |
47 | 42 | ||
48 | static inline void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; } | 43 | static inline void mempoke8(u8 *m, u16 a, u8 b) { m[a] = b; } |
49 | static inline Uint8 mempeek8(Uint8 *m, Uint16 a) { return m[a]; } | 44 | static inline u8 mempeek8(u8 *m, u16 a) { return m[a]; } |
50 | static inline void mempoke16(Uint8 *m, Uint16 a, Uint16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); } | 45 | static inline void mempoke16(u8 *m, u16 a, u16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); } |
51 | static inline Uint16 mempeek16(Uint8 *m, Uint16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); } | 46 | static inline u16 mempeek16(u8 *m, u16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); } |
52 | static inline void devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); } | 47 | static inline void devpoke8(Device *d, u8 a, u8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); } |
53 | static inline Uint8 devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; } | 48 | static inline u8 devpeek8(Device *d, u8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; } |
54 | static inline void devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); } | 49 | static inline void devpoke16(Device *d, u8 a, u16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); } |
55 | static inline Uint16 devpeek16(Device *d, Uint16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); } | 50 | static inline u16 devpeek16(Device *d, u16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); } |
56 | 51 | ||
57 | int loaduxn(Uxn *c, char *filepath); | 52 | int loaduxn(Uxn *c, char *filepath); |
58 | int bootuxn(Uxn *c); | 53 | int bootuxn(Uxn *c); |
59 | int evaluxn(Uxn *u, Uint16 vec); | 54 | int evaluxn(Uxn *u, u16 vec); |
60 | Device *portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *, Uint8, Uint8)); | 55 | Device *portuxn(Uxn *u, u8 id, char *name, void (*talkfn)(Device *, u8, u8)); |
61 | #endif // UXNGBA_UXN_H | 56 | #endif // UXNGBA_UXN_H |