2021-02-08 20:17:50 +00: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 20:16:39 +00:00
|
|
|
typedef unsigned char Uint8;
|
2021-02-13 00:18:52 +00:00
|
|
|
typedef signed char Sint8;
|
2021-02-08 20:16:39 +00:00
|
|
|
typedef unsigned short Uint16;
|
2021-02-13 00:18:52 +00:00
|
|
|
typedef signed short Sint16;
|
2021-02-08 20:16:39 +00:00
|
|
|
|
2021-04-20 21:30:26 +00:00
|
|
|
#define PAGE_PROGRAM 0x0100
|
|
|
|
|
2021-02-08 20:16:39 +00:00
|
|
|
typedef struct {
|
2021-05-12 19:36:18 +00:00
|
|
|
Uint8 ptr, kptr, error;
|
2021-02-08 20:16:39 +00:00
|
|
|
Uint8 dat[256];
|
2021-02-15 18:12:44 +00:00
|
|
|
} Stack;
|
2021-02-08 20:16:39 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Uint16 ptr;
|
|
|
|
Uint8 dat[65536];
|
|
|
|
} Memory;
|
|
|
|
|
2021-02-09 18:58:06 +00:00
|
|
|
typedef struct Device {
|
2021-04-27 20:10:58 +00:00
|
|
|
struct Uxn *u;
|
2021-04-21 03:38:15 +00:00
|
|
|
Uint8 addr, dat[16], *mem;
|
2021-09-22 19:16:16 +00:00
|
|
|
Uint16 vector;
|
2021-09-07 21:11:52 +00:00
|
|
|
int (*talk)(struct Device *d, Uint8, Uint8);
|
2021-02-09 05:59:46 +00:00
|
|
|
} Device;
|
|
|
|
|
2021-03-22 21:22:06 +00:00
|
|
|
typedef struct Uxn {
|
2021-03-16 04:29:44 +00:00
|
|
|
Stack wst, rst, *src, *dst;
|
2021-02-08 20:16:39 +00:00
|
|
|
Memory ram;
|
2021-02-28 19:41:28 +00:00
|
|
|
Device dev[16];
|
2021-02-08 22:18:01 +00:00
|
|
|
} Uxn;
|
2021-02-08 20:16:39 +00:00
|
|
|
|
2021-05-13 01:28:45 +00:00
|
|
|
struct Uxn;
|
|
|
|
|
2021-08-29 21:41:05 +00:00
|
|
|
void poke16(Uint8 *m, Uint16 a, Uint16 b);
|
|
|
|
Uint16 peek16(Uint8 *m, Uint16 a);
|
2021-04-09 17:01:53 +00:00
|
|
|
|
2021-08-01 21:46:43 +00:00
|
|
|
int uxn_boot(Uxn *c);
|
|
|
|
int uxn_eval(Uxn *u, Uint16 vec);
|
|
|
|
int uxn_halt(Uxn *u, Uint8 error, char *name, int id);
|
2021-09-07 21:11:52 +00:00
|
|
|
Device *uxn_port(Uxn *u, Uint8 id, int (*talkfn)(Device *, Uint8, Uint8));
|