~rabbits/uxn

abd7ab403e6453b64a4bb799c1b6de081e9f19db — Devine Lu Linvega 12 days ago 486a60b
Removed POKDEV
3 files changed, 12 insertions(+), 14 deletions(-)

M src/devices/file.c
M src/devices/mouse.c
M src/uxn.h
M src/devices/file.c => src/devices/file.c +6 -6
@@ 242,16 242,16 @@ file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port)
		if(len > 0x10000 - addr)
			len = 0x10000 - addr;
		res = file_stat(c, &ram[addr], len);
		POKDEV(0x2, res);
		POKE16(d + 0x2, res);
		break;
	case 0x6:
		res = file_delete(c);
		POKDEV(0x2, res);
		POKE16(d + 0x2, res);
		break;
	case 0x9:
		addr = PEEK16(d + 0x8);
		res = file_init(c, (char *)&ram[addr], 0x10000 - addr, 0);
		POKDEV(0x2, res);
		POKE16(d + 0x2, res);
		break;
	case 0xd:
		addr = PEEK16(d + 0xc);


@@ 259,7 259,7 @@ file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port)
		if(len > 0x10000 - addr)
			len = 0x10000 - addr;
		res = file_read(c, &ram[addr], len);
		POKDEV(0x2, res);
		POKE16(d + 0x2, res);
		break;
	case 0xf:
		addr = PEEK16(d + 0xe);


@@ 267,7 267,7 @@ file_deo(Uint8 id, Uint8 *ram, Uint8 *d, Uint8 port)
		if(len > 0x10000 - addr)
			len = 0x10000 - addr;
		res = file_write(c, &ram[addr], len, d[0x7]);
		POKDEV(0x2, res);
		POKE16(d + 0x2, res);
		break;
	}
}


@@ 281,7 281,7 @@ file_dei(Uint8 id, Uint8 *d, Uint8 port)
	case 0xc:
	case 0xd:
		res = file_read(c, &d[port], 1);
		POKDEV(0x2, res);
		POKE16(d + 0x2, res);
		break;
	}
	return d[port];

M src/devices/mouse.c => src/devices/mouse.c +6 -6
@@ 29,17 29,17 @@ mouse_up(Uxn *u, Uint8 *d, Uint8 mask)
void
mouse_pos(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
{
	POKDEV(0x2, x);
	POKDEV(0x4, y);
	POKE16(d + 0x2, x);
	POKE16(d + 0x4, y);
	uxn_eval(u, PEEK16(d));
}

void
mouse_scroll(Uxn *u, Uint8 *d, Uint16 x, Uint16 y)
{
	POKDEV(0xa, x);
	POKDEV(0xc, -y);
	POKE16(d + 0xa, x);
	POKE16(d + 0xc, -y);
	uxn_eval(u, PEEK16(d));
	POKDEV(0xa, 0);
	POKDEV(0xc, 0);
	POKE16(d + 0xa, 0);
	POKE16(d + 0xc, 0);
}

M src/uxn.h => src/uxn.h +0 -2
@@ 16,8 16,6 @@ WITH REGARD TO THIS SOFTWARE.
#define POKE16(d, v) { (d)[0] = (v) >> 8; (d)[1] = (v); }
#define PEEK16(d) ((d)[0] << 8 | (d)[1])

#define POKDEV(x, y) { d[(x)] = (y) >> 8; d[(x) + 1] = (y); }

/* clang-format on */

typedef unsigned char Uint8;