From 5d837313e56d19cd6ecfa2ad9746edca20afb5f6 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Tue, 14 Jun 2022 10:47:52 -0700 Subject: [PATCH] Added warning for incompatible emulator devices --- src/uxn11.c | 4 ++++ src/uxncli.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/uxn11.c b/src/uxn11.c index 14677fb..0c3ee10 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -33,6 +33,7 @@ static Window window; char *rom_path; +#define SUPPORT 0x1f07 /* devices mask */ #define WIDTH (64 * 8) #define HEIGHT (40 * 8) @@ -79,6 +80,7 @@ static void emu_deo(Uxn *u, Uint8 addr, Uint8 v) { Uint8 p = addr & 0x0f, d = addr & 0xf0; + Uint16 mask = 0x1 << (d >> 4); u->dev[addr] = v; switch(d) { case 0x00: @@ -91,6 +93,8 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 v) case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break; case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break; } + if(p == 0x01 && !(SUPPORT & mask)) + fprintf(stderr, "Warning: Incompatible emulation, device: %02x.\n", d >> 4); } static void diff --git a/src/uxncli.c b/src/uxncli.c index edf0104..b64bb3f 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -17,6 +17,8 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ +#define SUPPORT 0x1c03 /* devices mask */ + static int emu_error(char *msg, const char *err) { @@ -59,6 +61,7 @@ static void emu_deo(Uxn *u, Uint8 addr, Uint8 v) { Uint8 p = addr & 0x0f, d = addr & 0xf0; + Uint16 mask = 0x1 << (d >> 4); u->dev[addr] = v; switch(d) { case 0x00: system_deo(u, &u->dev[d], p); break; @@ -66,6 +69,8 @@ emu_deo(Uxn *u, Uint8 addr, Uint8 v) case 0xa0: file_deo(0, u->ram, &u->dev[d], p); break; case 0xb0: file_deo(1, u->ram, &u->dev[d], p); break; } + if(p == 0x01 && !(SUPPORT & mask)) + fprintf(stderr, "Warning: Incompatible emulation, device: %02x.\n", d >> 4); } int