diff --git a/README.md b/README.md index f781bd8..06872e6 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,21 @@ -## chuniio-tasoller +## chuniio-tasoller *with air tower LEDs* chuniio driver for tasoller custom 2.0 firmware +now with working air tower LEDs when using [Dniel97 segatools](https://gitea.tendokyu.moe/Dniel97/segatools) + +thanks to: +**akiroz** for the original code and USB Protocol information +[**Dniel97**](https://gitea.tendokyu.moe/Dniel97) for rewritting my failed attempts at making this work + +the current implementation may not be fully arcade accurate, but should be visually acceptable during gameplay +this should hopefully be addressed in the future Supported titles: - Chunithm - Chunithm NEW +- Chunithn SUN +- Chunithm SUN PLUS -Downloads avaliable in [releases](https://dev.s-ul.net/akiroz/chuniio-tasoller/-/releases) ## Configuration diff --git a/src/main.zig b/src/main.zig index 153c46b..5818ece 100644 --- a/src/main.zig +++ b/src/main.zig @@ -296,3 +296,35 @@ export fn chuni_io_slider_set_leds(rgb: ?[*]u8) void { std.log.warn("[chuniio] WinUsb_WritePipe: {any}", .{GetLastError()}); } } + +export fn chuni_io_led_init() c_int { + return 0; +} + +export fn chuni_io_led_set_colors(board: u8, rgb: ?[*]u8) void { + if(cfg.?.chusan == 1 and builtin.cpu.arch != .i386) 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]; + } + } + + usb_out_op.lock(); + defer usb_out_op.unlock(); + if(WinUsb_WritePipe(tasoller, 0x03, @ptrCast(*u8, &usb_out), usb_out.len, &n, null) == 0) { + std.log.warn("[chuniio] WinUsb_WritePipe: {any}", .{GetLastError()}); + } +} \ No newline at end of file