Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for two new System/expansion commands #21

Open
neauoire opened this issue Mar 18, 2024 · 1 comment
Open

Support for two new System/expansion commands #21

neauoire opened this issue Mar 18, 2024 · 1 comment

Comments

@neauoire
Copy link
Contributor

Added two new commands, one that's basically just memset, and another that copies a length of memory starting at the end of the data, it helps with people who want to shift memory over itself. The command 0x1 is unchanged.

https://lists.sr.ht/~rabbits/uxn/%3C6a8207b3-9261-4a1a-9850-6ed56a6540c5%40100r.co%3E

ram = u->ram;
		addr = PEEK2(d + 2);
		if(ram[addr] == 0x0) {
			Uint8 value = ram[addr + 7];
			Uint16 i, length = PEEK2(ram + addr + 1);
			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)];
		}
@randrew
Copy link
Owner

randrew commented Mar 24, 2024

OK. I think I can implement this sometime in the next few weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants