|
|
|
|
@ -32,7 +32,7 @@ system_load(Uint8 *ram, char *rom_path)
|
|
|
|
|
FILE *f = fopen(rom_path, "rb"); |
|
|
|
|
if(f) { |
|
|
|
|
int i = 0, l = fread(ram, PAGE_SIZE - PAGE_PROGRAM, 1, f); |
|
|
|
|
while(l && ++i < RAM_PAGES) |
|
|
|
|
while(l && ++i < BANKS) |
|
|
|
|
l = fread(ram + PAGE_SIZE * i - PAGE_PROGRAM, PAGE_SIZE, 1, f); |
|
|
|
|
fclose(f); |
|
|
|
|
} |
|
|
|
|
@ -67,6 +67,31 @@ system_reboot(int soft)
|
|
|
|
|
return system_boot(uxn.ram, boot_path, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
system_expansion(const Uint16 addr) |
|
|
|
|
{ |
|
|
|
|
Uint8 *aptr = uxn.ram + addr; |
|
|
|
|
Uint16 length = PEEK2(aptr + 1); |
|
|
|
|
if(uxn.ram[addr] == 0x0) { |
|
|
|
|
unsigned int a = PEEK2(aptr + 3) * 0x10000 + PEEK2(aptr + 5); |
|
|
|
|
unsigned int b = a + length; |
|
|
|
|
unsigned int value = uxn.ram[addr + 7]; |
|
|
|
|
for(b = b < BANKS_CAP ? b : BANKS_CAP; a < b; uxn.ram[a++] = value); |
|
|
|
|
} else if(uxn.ram[addr] == 0x1) { |
|
|
|
|
unsigned int a = PEEK2(aptr + 3) * 0x10000 + PEEK2(aptr + 5); |
|
|
|
|
unsigned int b = a + length; |
|
|
|
|
unsigned int c = PEEK2(aptr + 7) * 0x10000 + PEEK2(aptr + 9); |
|
|
|
|
for(b = b < BANKS_CAP ? b : BANKS_CAP; a < b; uxn.ram[c++] = uxn.ram[a++]); |
|
|
|
|
} else if(uxn.ram[addr] == 0x2) { |
|
|
|
|
unsigned int a = PEEK2(aptr + 3) * 0x10000 + PEEK2(aptr + 5); |
|
|
|
|
unsigned int b = a + length; |
|
|
|
|
unsigned int c = PEEK2(aptr + 7) * 0x10000 + PEEK2(aptr + 9); |
|
|
|
|
unsigned int d = c + length; |
|
|
|
|
for(; b >= a; uxn.ram[--d] = uxn.ram[--b]); |
|
|
|
|
} else |
|
|
|
|
fprintf(stderr, "Unknown command: %s\n", &uxn.ram[addr]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* IO */ |
|
|
|
|
|
|
|
|
|
Uint8 |
|
|
|
|
@ -84,28 +109,7 @@ system_deo(Uint8 port)
|
|
|
|
|
{ |
|
|
|
|
switch(port) { |
|
|
|
|
case 0x3: { |
|
|
|
|
Uint16 value; |
|
|
|
|
Uint16 addr = PEEK2(uxn.dev + 2); |
|
|
|
|
Uint8 *aptr = uxn.ram + addr; |
|
|
|
|
Uint16 length = PEEK2(aptr + 1); |
|
|
|
|
if(uxn.ram[addr] == 0x0) { |
|
|
|
|
unsigned int a = PEEK2(aptr + 3) * PAGE_SIZE + PEEK2(aptr + 5); |
|
|
|
|
unsigned int b = a + length; |
|
|
|
|
value = uxn.ram[addr + 7]; |
|
|
|
|
for(; a < b; uxn.ram[a++] = value); |
|
|
|
|
} else if(uxn.ram[addr] == 0x1) { |
|
|
|
|
unsigned int a = PEEK2(aptr + 3) * PAGE_SIZE + PEEK2(aptr + 5); |
|
|
|
|
unsigned int b = a + length; |
|
|
|
|
unsigned int c = PEEK2(aptr + 7) * PAGE_SIZE + PEEK2(aptr + 9); |
|
|
|
|
for(; a < b; uxn.ram[c++] = uxn.ram[a++]); |
|
|
|
|
} else if(uxn.ram[addr] == 0x2) { |
|
|
|
|
unsigned int a = PEEK2(aptr + 3) * PAGE_SIZE + PEEK2(aptr + 5); |
|
|
|
|
unsigned int b = a + length; |
|
|
|
|
unsigned int c = PEEK2(aptr + 7) * PAGE_SIZE + PEEK2(aptr + 9); |
|
|
|
|
unsigned int d = c + length; |
|
|
|
|
for(; b >= a; uxn.ram[--d] = uxn.ram[--b]); |
|
|
|
|
} else |
|
|
|
|
fprintf(stderr, "Unknown Expansion Command 0x%02x\n", uxn.ram[addr]); |
|
|
|
|
system_expansion(PEEK2(uxn.dev + 2)); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case 0x4: |
|
|
|
|
|