2021-02-08 15:16:39 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2021-02-08 15:17:50 -05:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2021-02-08 15:16:39 -05:00
|
|
|
typedef unsigned char Uint8;
|
2021-02-12 19:18:52 -05:00
|
|
|
typedef signed char Sint8;
|
2021-02-08 15:16:39 -05:00
|
|
|
typedef unsigned short Uint16;
|
2021-02-12 19:18:52 -05:00
|
|
|
typedef signed short Sint16;
|
2021-02-08 15:16:39 -05:00
|
|
|
|
2021-04-20 17:30:26 -04:00
|
|
|
#define PAGE_PROGRAM 0x0100
|
|
|
|
|
2021-02-08 15:16:39 -05:00
|
|
|
typedef struct {
|
2021-05-12 15:36:18 -04:00
|
|
|
Uint8 ptr, kptr, error;
|
2021-02-08 15:16:39 -05:00
|
|
|
Uint8 dat[256];
|
2021-02-15 13:12:44 -05:00
|
|
|
} Stack;
|
2021-02-08 15:16:39 -05:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Uint16 ptr;
|
|
|
|
Uint8 dat[65536];
|
|
|
|
} Memory;
|
|
|
|
|
2021-02-09 13:58:06 -05:00
|
|
|
typedef struct Device {
|
2021-04-27 16:10:58 -04:00
|
|
|
struct Uxn *u;
|
2021-04-20 23:38:15 -04:00
|
|
|
Uint8 addr, dat[16], *mem;
|
2021-04-24 13:15:47 -04:00
|
|
|
void (*talk)(struct Device *d, Uint8, Uint8);
|
2021-02-09 00:59:46 -05:00
|
|
|
} Device;
|
|
|
|
|
2021-03-22 17:22:06 -04:00
|
|
|
typedef struct Uxn {
|
2021-03-16 00:29:44 -04:00
|
|
|
Stack wst, rst, *src, *dst;
|
2021-02-08 15:16:39 -05:00
|
|
|
Memory ram;
|
2021-02-28 14:41:28 -05:00
|
|
|
Device dev[16];
|
2021-02-08 17:18:01 -05:00
|
|
|
} Uxn;
|
2021-02-08 15:16:39 -05:00
|
|
|
|
2021-05-12 21:28:45 -04:00
|
|
|
struct Uxn;
|
|
|
|
|
2021-04-20 23:38:15 -04:00
|
|
|
void mempoke16(Uint8 *m, Uint16 a, Uint16 b);
|
|
|
|
Uint16 mempeek16(Uint8 *m, Uint16 a);
|
2021-04-09 13:01:53 -04:00
|
|
|
|
2021-05-12 21:28:45 -04:00
|
|
|
int loaduxn(Uxn *c, char *filepath);
|
|
|
|
int bootuxn(Uxn *c);
|
|
|
|
int evaluxn(Uxn *u, Uint16 vec);
|
2021-04-30 15:08:24 -04:00
|
|
|
Device *portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *, Uint8, Uint8));
|