Added warning for incompatible emulator devices

This commit is contained in:
Devine Lu Linvega 2022-06-14 10:47:52 -07:00
parent 2a1a506524
commit 5d837313e5
2 changed files with 9 additions and 0 deletions

View File

@ -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

View File

@ -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