uxn/uxn.h

58 lines
1.2 KiB
C
Raw Normal View History

2021-02-08 20:16:39 +00:00
#include <stdio.h>
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;
typedef unsigned short Uint16;
2021-02-08 22:08:58 +00:00
#define FLAG_HALT 0x01
#define FLAG_SHORT 0x02
#define FLAG_SIGN 0x04
#define FLAG_COND 0x08
2021-02-08 20:16:39 +00:00
typedef struct {
Uint8 ptr;
Uint8 dat[256];
} Stack8;
typedef struct {
Uint8 ptr;
Uint16 dat[256];
} Stack16;
typedef struct {
Uint16 ptr;
Uint8 dat[65536];
} Memory;
typedef struct {
2021-02-09 18:06:55 +00:00
Uint16 index;
Uint8 (*rfn)(Uint8);
Uint8 (*wfn)(Uint8);
2021-02-09 05:59:46 +00:00
} Device;
typedef struct {
Uint8 literal, status, devices;
2021-02-08 20:16:39 +00:00
Uint16 counter, vreset, vframe, verror;
Stack8 wst;
Stack16 rst;
Memory ram;
2021-02-09 18:06:55 +00:00
Device dev[256];
2021-02-08 22:18:01 +00:00
} Uxn;
2021-02-08 20:16:39 +00:00
2021-02-08 22:08:58 +00:00
void setflag(Uint8 *status, char flag, int b);
int getflag(Uint8 *status, char flag);
2021-02-08 23:46:52 +00:00
int loaduxn(Uxn *c, char *filepath);
int bootuxn(Uxn *c);
2021-02-09 05:59:46 +00:00
int evaluxn(Uxn *u, Uint16 vec);
2021-02-09 18:06:55 +00:00
int portuxn(Uxn *u, char *name, Uint8 (*onread)(Uint8), Uint8 (*onwrite)(Uint8));