diff --git a/etc/mmu.tal b/etc/mmu.tal new file mode 100644 index 0000000..7d2a85e --- /dev/null +++ b/etc/mmu.tal @@ -0,0 +1,56 @@ +|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1 +|100 + +@on-reset ( -> ) + ;buf + #2018 DEO + ;buf + #0a18 DEO + ( | copy left ) + ;buf #0006 ADD2 ;mmu-cpyl/a STA2 + ;buf #0003 ADD2 ;mmu-cpyl/b STA2 + ;mmu-cpyl .System/expansion DEO2 + ;buf + #2018 DEO + ;res1 + #0a18 DEO + ( | copy right ) + ;buf #0003 ADD2 ;mmu-cpyr/a STA2 + ;buf #0009 ADD2 ;mmu-cpyr/b STA2 + ;mmu-cpyr .System/expansion DEO2 + ;buf + #2018 DEO + ;res2 + #0a18 DEO + ( | copy left ) + ;buf #0009 ADD2 ;mmu-cpyl/a STA2 + ;buf #0006 ADD2 ;mmu-cpyl/b STA2 + ;mmu-cpyl .System/expansion DEO2 + ;buf + #2018 DEO + ;res3 + #0a18 DEO + ( | memset ) + ;buf #0003 ADD2 ;mmu-fill/a STA2 + ;mmu-fill .System/expansion DEO2 + ;buf + #2018 DEO + ;res4 + #0a18 DEO + BRK + +@ ( str* -- ) + LDAk #18 DEO + INC2 LDAk ? + POP2 JMP2r + +@buf [ "......[hello]..... $1 ] +@res1 [ "...[hello]o]...... $1 ] +@res2 [ "...[hello[hello].. $1 ] +@res3 [ "...[he[hello]lo].. $1 ] +@res4 [ "...-------------.. $1 ] + +@mmu-fill [ 00 000d 0000 &a $2 2d ] +@mmu-cpyl [ 01 0007 0000 &a $2 0000 &b $2 ] +@mmu-cpyr [ 02 0007 0000 &a $2 0000 &b $2 ] + diff --git a/src/devices/system.c b/src/devices/system.c index 0f96fdb..5987eb5 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -116,14 +116,29 @@ system_deo(Uxn *u, Uint8 *d, Uint8 port) case 0x3: ram = u->ram; addr = PEEK2(d + 2); - if(ram[addr] == 0x1) { + if(ram[addr] == 0x0) { + Uint8 value = ram[addr + 7]; 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); + Uint16 dst_page = PEEK2(ram + addr + 3), dst_addr = PEEK2(ram + addr + 5); + int dst = (dst_page % RAM_PAGES) * 0x10000; + for(i = 0; i < length; i++) + ram[dst + (Uint16)(dst_addr + i)] = value; + } else if(ram[addr] == 0x1) { + Uint16 i, length = PEEK2(ram + addr + 1); + Uint16 a_page = PEEK2(ram + addr + 3), a_addr = PEEK2(ram + addr + 5); + Uint16 b_page = PEEK2(ram + addr + 7), b_addr = PEEK2(ram + addr + 9); 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)]; - } + } else if(ram[addr] == 0x2) { + Uint16 i, length = PEEK2(ram + addr + 1); + Uint16 a_page = PEEK2(ram + addr + 3), a_addr = PEEK2(ram + addr + 5); + Uint16 b_page = PEEK2(ram + addr + 7), b_addr = PEEK2(ram + addr + 9); + int src = (a_page % RAM_PAGES) * 0x10000, dst = (b_page % RAM_PAGES) * 0x10000; + for(i = length - 1; i != 0xffff; i--) + ram[dst + (Uint16)(b_addr + i)] = ram[src + (Uint16)(a_addr + i)]; + } else + fprintf(stderr, "Unknown Expansion Command 0x%02x\n", ram[addr]); break; case 0x4: u->wst.ptr = d[4]; diff --git a/src/uxn11.c b/src/uxn11.c index 779b8ff..c795ca0 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -271,7 +271,7 @@ main(int argc, char **argv) int i = 1; char *rom; if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') { - fprintf(stdout, "Uxn11 - Varvara Emulator, 7 Mar 2023.\n"); + fprintf(stdout, "Uxn11 - Varvara Emulator, 18 Mar 2024.\n"); i++; } rom = i == argc ? "boot.rom" : argv[i++]; diff --git a/src/uxncli.c b/src/uxncli.c index 76e625b..f7f9fc2 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -71,7 +71,7 @@ main(int argc, char **argv) return system_error("usage", "uxncli [-v] file.rom [args..]"); /* Read flags */ if(argv[i][0] == '-' && argv[i][1] == 'v') - return system_version("Uxncli - Console Varvara Emulator", "4 Mar 2024"); + return system_version("Uxncli - Console Varvara Emulator", "18 Mar 2024"); if(!system_boot(&u, (Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++])) return system_error("Init", "Failed to initialize uxn."); /* Game Loop */