Pre-process dei/deo masks
This commit is contained in:
parent
b405d8c663
commit
c6bd7f06a7
|
@ -64,15 +64,20 @@ system_inspect(Uxn *u)
|
|||
}
|
||||
|
||||
void
|
||||
system_connect(Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo)
|
||||
system_connect(Uxn *u, Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo)
|
||||
{
|
||||
int i, d = (device << 0x4);
|
||||
for(i = 0; i < 0x10; i++) {
|
||||
u->dei_masks[d + i] = (dei >> i) & 0x1;
|
||||
u->deo_masks[d + i] = (deo >> i) & 0x1;
|
||||
}
|
||||
dev_vers[device] = ver;
|
||||
dei_mask[device] = dei;
|
||||
deo_mask[device] = deo;
|
||||
}
|
||||
|
||||
int
|
||||
system_version(char *name, char *date)
|
||||
system_version(Uxn *u, char *name, char *date)
|
||||
{
|
||||
int i;
|
||||
printf("%s, %s.\n", name, date);
|
||||
|
|
|
@ -17,10 +17,10 @@ WITH REGARD TO THIS SOFTWARE.
|
|||
|
||||
extern char *boot_rom;
|
||||
|
||||
void system_connect(Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo);
|
||||
void system_connect(Uxn *u, Uint8 device, Uint8 ver, Uint16 dei, Uint16 deo);
|
||||
void system_reboot(Uxn *u, char *rom, int soft);
|
||||
void system_inspect(Uxn *u);
|
||||
int system_version(char *emulator, char *date);
|
||||
int system_version(Uxn *u, char *emulator, char *date);
|
||||
int system_error(char *msg, const char *err);
|
||||
int system_init(Uxn *u, Uint8 *ram, char *rom);
|
||||
|
||||
|
|
14
src/uxn.h
14
src/uxn.h
|
@ -11,10 +11,10 @@ WITH REGARD TO THIS SOFTWARE.
|
|||
|
||||
/* clang-format off */
|
||||
|
||||
#define POKE2(d, v) { (d)[0] = (v) >> 8; (d)[1] = (v); }
|
||||
#define PEEK2(d) ((d)[0] << 8 | (d)[1])
|
||||
#define DEO(p, v) { u->dev[p] = v; if((deo_mask[p >> 4] >> (p & 0xf)) & 0x1) emu_deo(u, p); }
|
||||
#define DEI(p) ((dei_mask[(p) >> 4] >> ((p) & 0xf)) & 0x1 ? emu_dei(u, (p)) : u->dev[(p)])
|
||||
#define POKE2(d, v) { *(d) = (v) >> 8; (d)[1] = (v); }
|
||||
#define PEEK2(d) (*(d) << 8 | (d)[1])
|
||||
#define DEI(p) (u->dei_masks[p] ? emu_dei(u, (p)) : u->dev[(p)])
|
||||
#define DEO(p, v) { u->dev[p] = v; if(u->deo_masks[p]) emu_deo(u, p); }
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
|
@ -27,14 +27,12 @@ typedef signed short Sint16;
|
|||
typedef unsigned int Uint32;
|
||||
|
||||
typedef struct {
|
||||
Uint8 dat[255], ptr;
|
||||
Uint8 dat[0x100], ptr;
|
||||
} Stack;
|
||||
|
||||
typedef struct Uxn {
|
||||
Uint8 *ram, dev[256];
|
||||
Uint8 *ram, dev[0x100], dei_masks[0x100], deo_masks[0x100];
|
||||
Stack wst, rst;
|
||||
Uint8 (*dei)(struct Uxn *u, Uint8 addr);
|
||||
void (*deo)(struct Uxn *u, Uint8 addr);
|
||||
} Uxn;
|
||||
|
||||
/* required functions */
|
||||
|
|
18
src/uxn11.c
18
src/uxn11.c
|
@ -258,17 +258,17 @@ main(int argc, char **argv)
|
|||
if(i == argc)
|
||||
return system_error("usage", "uxn11 [-v] file.rom [args...]");
|
||||
/* Connect Varvara */
|
||||
system_connect(0x0, SYSTEM_VERSION, SYSTEM_DEIMASK, SYSTEM_DEOMASK);
|
||||
system_connect(0x1, CONSOLE_VERSION, CONSOLE_DEIMASK, CONSOLE_DEOMASK);
|
||||
system_connect(0x2, SCREEN_VERSION, SCREEN_DEIMASK, SCREEN_DEOMASK);
|
||||
system_connect(0x8, CONTROL_VERSION, CONTROL_DEIMASK, CONTROL_DEOMASK);
|
||||
system_connect(0x9, MOUSE_VERSION, MOUSE_DEIMASK, MOUSE_DEOMASK);
|
||||
system_connect(0xa, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
|
||||
system_connect(0xb, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
|
||||
system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
|
||||
system_connect(&u, 0x0, SYSTEM_VERSION, SYSTEM_DEIMASK, SYSTEM_DEOMASK);
|
||||
system_connect(&u, 0x1, CONSOLE_VERSION, CONSOLE_DEIMASK, CONSOLE_DEOMASK);
|
||||
system_connect(&u, 0x2, SCREEN_VERSION, SCREEN_DEIMASK, SCREEN_DEOMASK);
|
||||
system_connect(&u, 0x8, CONTROL_VERSION, CONTROL_DEIMASK, CONTROL_DEOMASK);
|
||||
system_connect(&u, 0x9, MOUSE_VERSION, MOUSE_DEIMASK, MOUSE_DEOMASK);
|
||||
system_connect(&u, 0xa, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
|
||||
system_connect(&u, 0xb, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
|
||||
system_connect(&u, 0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
|
||||
/* Read flags */
|
||||
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
||||
return system_version("Uxn11 - Graphical Varvara Emulator", "16 Aug 2023");
|
||||
return system_version(&u, "Uxn11 - Graphical Varvara Emulator", "17 Aug 2023");
|
||||
if(!emu_init())
|
||||
return system_error("Init", "Failed to initialize varvara.");
|
||||
if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
|
||||
|
|
12
src/uxncli.c
12
src/uxncli.c
|
@ -66,14 +66,14 @@ main(int argc, char **argv)
|
|||
if(i == argc)
|
||||
return system_error("usage", "uxncli [-v] file.rom [args..]");
|
||||
/* Connect Varvara */
|
||||
system_connect(0x0, SYSTEM_VERSION, SYSTEM_DEIMASK, SYSTEM_DEOMASK);
|
||||
system_connect(0x1, CONSOLE_VERSION, CONSOLE_DEIMASK, CONSOLE_DEOMASK);
|
||||
system_connect(0xa, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
|
||||
system_connect(0xb, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
|
||||
system_connect(0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
|
||||
system_connect(&u, 0x0, SYSTEM_VERSION, SYSTEM_DEIMASK, SYSTEM_DEOMASK);
|
||||
system_connect(&u, 0x1, CONSOLE_VERSION, CONSOLE_DEIMASK, CONSOLE_DEOMASK);
|
||||
system_connect(&u, 0xa, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
|
||||
system_connect(&u, 0xb, FILE_VERSION, FILE_DEIMASK, FILE_DEOMASK);
|
||||
system_connect(&u, 0xc, DATETIME_VERSION, DATETIME_DEIMASK, DATETIME_DEOMASK);
|
||||
/* Read flags */
|
||||
if(argv[i][0] == '-' && argv[i][1] == 'v')
|
||||
return system_version("Uxncli - Console Varvara Emulator", "15 Aug 2023");
|
||||
return system_version(&u, "Uxncli - Console Varvara Emulator", "17 Aug 2023");
|
||||
if(!system_init(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
|
||||
return system_error("Init", "Failed to initialize uxn.");
|
||||
/* Game Loop */
|
||||
|
|
Loading…
Reference in New Issue