uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 9f4e85b1b3857d07fc3dd77fdc8dd012ad9959d1
parent 36a70ed60572496a6c1672de11562a34a3e75380
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Thu,  2 Feb 2023 10:40:47 -0800

Named arguments in system_cmd

Diffstat:
Msrc/devices/system.c | 14++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/devices/system.c b/src/devices/system.c @@ -36,14 +36,12 @@ static void system_cmd(Uint8 *ram, Uint16 addr) { if(ram[addr] == 0x01) { - int src, dst; - Uint16 i, args[5]; /* length, a_page, a_addr, b_page, b_addr */ - for(i = 0; i < 5; i++) - args[i] = PEEK16(ram + addr + 1 + i * 2); - src = (args[1] % RAM_PAGES) * 0x10000; - dst = (args[3] % RAM_PAGES) * 0x10000; - for(i = 0; i < args[0]; i++) - ram[dst + (Uint16)(args[4] + i)] = ram[src + (Uint16)(args[2] + i)]; + Uint16 i, length = PEEK16(ram + addr + 1); + Uint16 a_page = PEEK16(ram + addr + 1 + 2), a_addr = PEEK16(ram + addr + 1 + 4); + Uint16 b_page = PEEK16(ram + addr + 1 + 6), b_addr = PEEK16(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)]; } }