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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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
|
|
|
|
2023-04-10 14:32:16 -04:00
|
|
|
typedef unsigned char Uint8;
|
|
|
|
typedef signed char Sint8;
|
|
|
|
typedef unsigned short Uint16;
|
|
|
|
typedef signed short Sint16;
|
|
|
|
typedef unsigned int Uint32;
|
|
|
|
|
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 {
|
2023-04-10 14:32:16 -04:00
|
|
|
Uint8 *ram, dev[256];
|
2023-04-11 12:25:31 -04:00
|
|
|
Stack wst, rst;
|
2022-04-07 12:33:52 -04:00
|
|
|
Uint8 (*dei)(struct Uxn *u, Uint8 addr);
|
2023-04-10 14:32:16 -04:00
|
|
|
void (*deo)(struct Uxn *u, Uint8 addr);
|
2022-03-26 20:23:52 -04:00
|
|
|
} Uxn;
|
|
|
|
|
2023-04-10 14:32:16 -04:00
|
|
|
/* required functions */
|
|
|
|
|
2023-08-01 23:32:42 -04:00
|
|
|
extern Uint8 emu_dei(Uxn *u, Uint8 addr);
|
|
|
|
extern void emu_deo(Uxn *u, Uint8 addr);
|
|
|
|
extern int emu_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);
|
2023-04-10 14:32:16 -04:00
|
|
|
extern Uint16 dei_mask[];
|
|
|
|
extern Uint16 deo_mask[];
|
|
|
|
|
|
|
|
/* built-ins */
|
2022-06-13 15:06:16 -04:00
|
|
|
|
2023-04-10 14:32:16 -04:00
|
|
|
int uxn_boot(Uxn *u, Uint8 *ram);
|
2023-04-30 14:43:33 -04:00
|
|
|
int uxn_eval(Uxn *u, Uint16 pc);
|