add support for uuid-based extensions
This commit is contained in:
parent
ae1e6367a3
commit
73e965c105
|
@ -101,6 +101,46 @@ system_init(Uxn *u, Uint8 *ram, char *rom)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
system_expansion_copy(Uxn *u, Uint8 *ram, Uint16 addr)
|
||||
{
|
||||
Uint16 i, length = PEEK2(ram + addr + 1);
|
||||
Uint16 a_page = PEEK2(ram + addr + 1 + 2), a_addr = PEEK2(ram + addr + 1 + 4);
|
||||
Uint16 b_page = PEEK2(ram + addr + 1 + 6), b_addr = PEEK2(ram + addr + 1 + 8);
|
||||
int src = (a_page % RAM_PAGES) * 0x10000, dst = (b_page % RAM_PAGES) * 0x10000;
|
||||
for(i = 0; i < length; i++)
|
||||
ram[dst + (Uint16)(b_addr + i)] = ram[src + (Uint16)(a_addr + i)];
|
||||
}
|
||||
|
||||
static int
|
||||
uuid_eq(Uint8 *m, Uint8 uuid[16])
|
||||
{
|
||||
for(int i = 0; i < 16; i++)
|
||||
if (m[i] != uuid[i])
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* console device: 01231250-d878-4462-bc41-d0927645a2fa */
|
||||
static Uint8 console_uuid[16] = {
|
||||
0x01, 0x23, 0x12, 0x50, 0xd8, 0x78, 0x44, 0x62,
|
||||
0xbc, 0x41, 0xd0, 0x92, 0x76, 0x45, 0xa2, 0xfa
|
||||
};
|
||||
|
||||
static void
|
||||
system_expansion_uxn38_device(Uxn *u, Uint8 *ram, Uint16 addr)
|
||||
{
|
||||
Uint8 dev_id = ram[addr + 1];
|
||||
Uint8 *uuid = &ram[addr + 2];
|
||||
if(dev_id == 0x10 && uuid_eq(uuid, console_uuid) != 0) {
|
||||
ram[addr + 18] = 0x00;
|
||||
ram[addr + 19] = 0xff;
|
||||
} else {
|
||||
ram[addr + 18] = 0x00;
|
||||
ram[addr + 19] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
/* IO */
|
||||
|
||||
Uint8
|
||||
|
@ -122,14 +162,10 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port)
|
|||
case 0x3:
|
||||
ram = u->ram;
|
||||
addr = PEEK2(d + 2);
|
||||
if(ram[addr] == 0x1) {
|
||||
Uint16 i, length = PEEK2(ram + addr + 1);
|
||||
Uint16 a_page = PEEK2(ram + addr + 1 + 2), a_addr = PEEK2(ram + addr + 1 + 4);
|
||||
Uint16 b_page = PEEK2(ram + addr + 1 + 6), b_addr = PEEK2(ram + addr + 1 + 8);
|
||||
int src = (a_page % RAM_PAGES) * 0x10000, dst = (b_page % RAM_PAGES) * 0x10000;
|
||||
for(i = 0; i < length; i++)
|
||||
ram[dst + (Uint16)(b_addr + i)] = ram[src + (Uint16)(a_addr + i)];
|
||||
}
|
||||
if(ram[addr] == 0x1)
|
||||
system_expansion_copy(u, ram, addr);
|
||||
else if(ram[addr] == 0x3)
|
||||
system_expansion_uxn38_device(u, ram, addr);
|
||||
break;
|
||||
case 0x4:
|
||||
u->wst.ptr = d[4];
|
||||
|
|
Loading…
Reference in New Issue