uxn11/src/uxn.h

44 lines
1.1 KiB
C
Raw Normal View History

2022-03-26 20:23:52 -04: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.
*/
typedef unsigned char Uint8;
typedef signed char Sint8;
typedef unsigned short Uint16;
typedef signed short Sint16;
typedef unsigned int Uint32;
#define PAGE_PROGRAM 0x0100
2022-03-26 21:32:46 -04:00
/* clang-format off */
2023-04-10 13:08:40 -04:00
#define POKE2(d, v) { (d)[0] = (v) >> 8; (d)[1] = (v); }
#define PEEK2(d) ((d)[0] << 8 | (d)[1])
2022-03-26 21:32:46 -04:00
/* clang-format on */
2022-03-26 20:23:52 -04:00
typedef struct {
2023-02-02 12:34:14 -05:00
Uint8 dat[255], ptr;
2022-03-26 21:32:46 -04:00
} Stack;
2022-03-26 20:23:52 -04:00
typedef struct Uxn {
2022-04-05 14:42:50 -04:00
Uint8 *ram, *dev;
2022-03-30 13:37:47 -04:00
Stack *wst, *rst;
2022-04-07 12:33:52 -04:00
Uint8 (*dei)(struct Uxn *u, Uint8 addr);
void (*deo)(struct Uxn *u, Uint8 addr, Uint8 value);
2022-03-26 20:23:52 -04:00
} Uxn;
2022-06-13 15:06:16 -04:00
typedef Uint8 Dei(Uxn *u, Uint8 addr);
typedef void Deo(Uxn *u, Uint8 addr, Uint8 value);
int uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);
2022-06-13 15:06:16 -04:00
int uxn_boot(Uxn *u, Uint8 *ram, Dei *dei, Deo *deo);
2022-03-26 21:32:46 -04:00
int uxn_eval(Uxn *u, Uint16 pc);