From 84489e8fae3af65352723d30c01906e084329fae Mon Sep 17 00:00:00 2001 From: Scribbler Date: Tue, 9 Jan 2024 19:36:56 +0000 Subject: [PATCH] Make tower LEDs more arcade accurate Now using all the tower LED data sent by the game instead of just using 1 and repeating it across all LEDs. This will have no effect in game as the game simply sets them all to the same colour anyway :( --- src/main.zig | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/src/main.zig b/src/main.zig index 155bc3a..cab7028 100644 --- a/src/main.zig +++ b/src/main.zig @@ -296,22 +296,42 @@ export fn chuni_io_led_set_colors(board: u8, rgb: ?[*]u8) void { if (cfg.?.chusan == 1 and builtin.cpu.arch != .x86) return; if (rgb == null) return; - var n: u32 = 0; - if (board == 0) { - const out = usb_out[96..168]; - while (n < 24) : (n += 1) { - out[n * 3 + 1] = rgb.?[0x96]; - out[n * 3 + 0] = rgb.?[0x97]; - out[n * 3 + 2] = rgb.?[0x98]; - } - } else if (board == 1) { - const out = usb_out[168..240]; - while (n < 24) : (n += 1) { - out[n * 3 + 1] = rgb.?[0xb4]; - out[n * 3 + 0] = rgb.?[0xb5]; - out[n * 3 + 2] = rgb.?[0xb6]; +var n: u32 = 0; +if (board == 0) { + const out = usb_out[96..168]; + const led_limit: u32 = 3; + const i_limit: u32 = 8; + + var led: u32 = 0; + while (led < led_limit) { + var i: u32 = 0; + while (i < i_limit) { + n = (8 * led) + i; + out[n * 3 + 1] = rgb.?[0x96 + (led * 3)]; + out[n * 3 + 0] = rgb.?[0x97 + (led * 3)]; + out[n * 3 + 2] = rgb.?[0x98 + (led * 3)]; + i += 1; } + led += 1; } +} else if (board == 1) { + const out = usb_out[168..240]; + const led_limit: u32 = 3; + const i_limit: u32 = 8; + + var led: u32 = 0; + while (led < led_limit) { + var i: u32 = 0; + while (i < i_limit) { + n = (8 * led) + i; + out[n * 3 + 1] = rgb.?[0xb4 + (led * 3)]; + out[n * 3 + 0] = rgb.?[0xb5 + (led * 3)]; + out[n * 3 + 2] = rgb.?[0xb6 + (led * 3)]; + i += 1; + } + led += 1; + } +} usb_out_op.lock(); defer usb_out_op.unlock();