#include /* Copyright (c) 2021 Devine Lu Linvega Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ typedef unsigned char Uint8; typedef signed char Sint8; typedef unsigned short Uint16; typedef signed short Sint16; #define PAGE_PROGRAM 0x0100 #define genpeek16(ptr, i) ((ptr[i] << 8) + ptr[i + 1]) #define genpoke16(ptr, i, v) \ do { \ ptr[i] = v >> 8; \ ptr[i + 1] = v & 0xff; \ } while(0) typedef struct { Uint8 ptr, error; Uint8 dat[256]; } Stack; typedef struct { Uint16 ptr; Uint8 dat[65536]; } Memory; struct Uxn; typedef struct Device { Uint8 addr, dat[16]; Uint8 (*poke)(struct Uxn *u, Uint8 *devmem, Uint8, Uint8); } Device; typedef struct Uxn { Stack wst, rst, *src, *dst; Memory ram; Device dev[16]; } Uxn; int loaduxn(Uxn *c, char *filepath); int bootuxn(Uxn *c); int evaluxn(Uxn *u, Uint16 vec); void mempoke16(Uxn *u, Uint16 a, Uint16 b); Uint16 mempeek16(Uxn *u, Uint16 a); Device *portuxn(Uxn *u, Uint8 id, char *name, Uint8 (*pofn)(Uxn *, Uint8 *, Uint8, Uint8));