1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2025-02-17 11:18:31 +01:00

chore: Apply code formatting

This commit is contained in:
icex2 2024-01-28 21:44:30 +01:00 committed by icex2
parent 0a29e031ff
commit e2a6410461
6 changed files with 136 additions and 142 deletions

View File

@ -511,7 +511,7 @@ static void ac_io_emu_icca_cipher_set_key(
resp.cmd.raw[0] = (reader_key >> 24) & 0xFF; resp.cmd.raw[0] = (reader_key >> 24) & 0xFF;
resp.cmd.raw[1] = (reader_key >> 16) & 0xFF; resp.cmd.raw[1] = (reader_key >> 16) & 0xFF;
resp.cmd.raw[2] = (reader_key >> 8) & 0xFF; resp.cmd.raw[2] = (reader_key >> 8) & 0xFF;
resp.cmd.raw[3] = (reader_key) &0xFF; resp.cmd.raw[3] = (reader_key) & 0xFF;
// so I looked these constants up, this isn't actually a secure key // so I looked these constants up, this isn't actually a secure key
// generator it's actually Marsaglia's "KISS" algorithm with different // generator it's actually Marsaglia's "KISS" algorithm with different

View File

@ -29,81 +29,79 @@ bool aciotest_bi2a_iidx_handler_update(
return false; return false;
} }
printf( printf(
"|---------------------------------------|\n" "|---------------------------------------|\n"
"| R Y G B Neons B G Y R |\n" "| R Y G B Neons B G Y R |\n"
"| %d %d %d %d %d %d %d %d %d |\n" "| %d %d %d %d %d %d %d %d %d |\n"
"|---------------------------------------|\n" "|---------------------------------------|\n"
"| NOW PLAYING: %c%c%c%c%c%c%c%c%c |\n" "| NOW PLAYING: %c%c%c%c%c%c%c%c%c |\n"
"|---------------------------------------|\n" "|---------------------------------------|\n"
"| Effect %d S1 S2 S3 S4 S5 Test %d|\n" "| Effect %d S1 S2 S3 S4 S5 Test %d|\n"
"|StartP1 %d %02d %02d %02d %02d %02d StartP2 %d|\n" "|StartP1 %d %02d %02d %02d %02d %02d StartP2 %d|\n"
"| VEFX %d Service %d|\n" "| VEFX %d Service %d|\n"
"_________________________________________\n" "_________________________________________\n"
"| __ __ |\n" "| __ __ |\n"
"| / \\ _ / \\ |\n" "| / \\ _ / \\ |\n"
"| | %03d| %d %d %d |%d| %d %d %d | %03d| |\n" "| | %03d| %d %d %d |%d| %d %d %d | %03d| |\n"
"| \\___/ %d %d %d %d |_| %d %d %d %d \\___/ |\n" "| \\___/ %d %d %d %d |_| %d %d %d %d \\___/ |\n"
"| |\n" "| |\n"
"|---------------------------------------|\n" "|---------------------------------------|\n"
"|---------------------------------------|\n", "|---------------------------------------|\n",
pout.SPOTLIGHT2[0].l_state, pout.SPOTLIGHT2[0].l_state,
pout.SPOTLIGHT2[1].l_state, pout.SPOTLIGHT2[1].l_state,
pout.SPOTLIGHT2[2].l_state, pout.SPOTLIGHT2[2].l_state,
pout.SPOTLIGHT2[3].l_state, pout.SPOTLIGHT2[3].l_state,
pout.NEONLAMP.l_state, pout.NEONLAMP.l_state,
pout.SPOTLIGHT1[0].l_state, pout.SPOTLIGHT1[0].l_state,
pout.SPOTLIGHT1[1].l_state, pout.SPOTLIGHT1[1].l_state,
pout.SPOTLIGHT1[2].l_state, pout.SPOTLIGHT1[2].l_state,
pout.SPOTLIGHT1[3].l_state, pout.SPOTLIGHT1[3].l_state,
pout.SEG16[0], pout.SEG16[0],
pout.SEG16[1], pout.SEG16[1],
pout.SEG16[2], pout.SEG16[2],
pout.SEG16[3], pout.SEG16[3],
pout.SEG16[4], pout.SEG16[4],
pout.SEG16[5], pout.SEG16[5],
pout.SEG16[6], pout.SEG16[6],
pout.SEG16[7], pout.SEG16[7],
pout.SEG16[8], pout.SEG16[8],
pin.PANEL.y_effect, pin.PANEL.y_effect,
pin.SYSTEM.v_test, pin.SYSTEM.v_test,
pin.PANEL.y_start1, pin.PANEL.y_start1,
pin.SLIDER1.s_val, pin.SLIDER1.s_val,
pin.SLIDER2.s_val, pin.SLIDER2.s_val,
pin.SLIDER3.s_val, pin.SLIDER3.s_val,
pin.SLIDER4.s_val, pin.SLIDER4.s_val,
pin.SLIDER5.s_val, pin.SLIDER5.s_val,
pin.PANEL.y_start2, pin.PANEL.y_start2,
pin.PANEL.y_vefx, pin.PANEL.y_vefx,
pin.SYSTEM.v_service, pin.SYSTEM.v_service,
pin.TURNTABLE1, pin.TURNTABLE1,
pin.P1SW2.b_val, pin.P1SW2.b_val,
pin.P1SW4.b_val, pin.P1SW4.b_val,
pin.P1SW6.b_val, pin.P1SW6.b_val,
pin.SYSTEM.v_coin, pin.SYSTEM.v_coin,
pin.P2SW2.b_val, pin.P2SW2.b_val,
pin.P2SW4.b_val, pin.P2SW4.b_val,
pin.P2SW6.b_val, pin.P2SW6.b_val,
pin.TURNTABLE2, pin.TURNTABLE2,
pin.P1SW1.b_val, pin.P1SW1.b_val,
pin.P1SW3.b_val, pin.P1SW3.b_val,
pin.P1SW5.b_val, pin.P1SW5.b_val,
pin.P1SW7.b_val, pin.P1SW7.b_val,
pin.P2SW1.b_val, pin.P2SW1.b_val,
pin.P2SW3.b_val, pin.P2SW3.b_val,
pin.P2SW5.b_val, pin.P2SW5.b_val,
pin.P2SW7.b_val pin.P2SW7.b_val
); );
return true; return true;
} }

View File

@ -1,14 +1,14 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <windows.h> #include <windows.h>
#include "aciodrv/device.h" #include "aciodrv/device.h"
#include "aciotest/bi2a-sdvx.h"
#include "aciotest/bi2a-iidx.h" #include "aciotest/bi2a-iidx.h"
#include "aciotest/bi2a-sdvx.h"
#include "aciotest/handler.h" #include "aciotest/handler.h"
#include "aciotest/icca.h" #include "aciotest/icca.h"
#include "aciotest/kfca.h" #include "aciotest/kfca.h"
@ -58,25 +58,23 @@ static bool aciotest_assign_handler(
if (bi2a_mode == 255) { if (bi2a_mode == 255) {
printf( printf(
"Unknown BI2A mode specified, please check your command.\n" "Unknown BI2A mode specified, please check your command.\n"
"Using bi2a-sdvx mode as default, press ENTER to continue\n" "Using bi2a-sdvx mode as default, press ENTER to continue\n");
);
bi2a_mode = 0; bi2a_mode = 0;
getchar(); getchar();
} }
switch (bi2a_mode) switch (bi2a_mode) {
{ case 0:
case 0: handler->init = aciotest_bi2a_sdvx_handler_init;
handler->init = aciotest_bi2a_sdvx_handler_init; handler->update = aciotest_bi2a_sdvx_handler_update;
handler->update = aciotest_bi2a_sdvx_handler_update; break;
break; case 1:
case 1: handler->init = aciotest_bi2a_iidx_handler_init;
handler->init = aciotest_bi2a_iidx_handler_init; handler->update = aciotest_bi2a_iidx_handler_update;
handler->update = aciotest_bi2a_iidx_handler_update; break;
break;
default: default:
break; break;
} }
return true; return true;
} }
@ -107,9 +105,9 @@ int main(int argc, char **argv)
} }
if (argc == 4) { if (argc == 4) {
if(!strcmp(argv[3],"bi2a-iidx")) { if (!strcmp(argv[3], "bi2a-iidx")) {
bi2a_mode = 1; bi2a_mode = 1;
} else if(!strcmp(argv[3],"bi2a-sdvx")) { } else if (!strcmp(argv[3], "bi2a-sdvx")) {
bi2a_mode = 0; bi2a_mode = 0;
} }
} }

View File

@ -28,7 +28,8 @@ typedef uint32_t (*ddr_io_read_pad_t)(void);
typedef void (*ddr_io_set_lights_extio_t)(uint32_t extio_lights); typedef void (*ddr_io_set_lights_extio_t)(uint32_t extio_lights);
typedef void (*ddr_io_set_lights_p3io_t)(uint32_t p3io_lights); typedef void (*ddr_io_set_lights_p3io_t)(uint32_t p3io_lights);
typedef void (*ddr_io_set_lights_hdxs_panel_t)(uint32_t hdxs_lights); typedef void (*ddr_io_set_lights_hdxs_panel_t)(uint32_t hdxs_lights);
typedef void (*ddr_io_set_lights_hdxs_rgb_t)(uint8_t idx, uint8_t r, uint8_t g, uint8_t b); typedef void (*ddr_io_set_lights_hdxs_rgb_t)(
uint8_t idx, uint8_t r, uint8_t g, uint8_t b);
typedef void (*ddr_io_fini_t)(void); typedef void (*ddr_io_fini_t)(void);
static HMODULE _child_ddr_io_module; static HMODULE _child_ddr_io_module;
@ -66,10 +67,7 @@ static int _io_thread_proc(void *ctx)
uint32_t local_tmp; uint32_t local_tmp;
atomic_store_explicit( atomic_store_explicit(&_io_thread_proc_running, true, memory_order_seq_cst);
&_io_thread_proc_running,
true,
memory_order_seq_cst);
log_info("IO thread running"); log_info("IO thread running");
@ -85,18 +83,16 @@ static int _io_thread_proc(void *ctx)
local_tmp = _child_ddr_io_read_pad(); local_tmp = _child_ddr_io_read_pad();
atomic_store_explicit( atomic_store_explicit(
&_child_ddr_io_data_pad, &_child_ddr_io_data_pad, local_tmp, memory_order_relaxed);
local_tmp,
memory_order_relaxed);
// Only update outputs when they change gives this loop a major performance boost // Only update outputs when they change gives this loop a major
// The write calls on a p3io for the outputs are very expensive (~12 ms) as they // performance boost The write calls on a p3io for the outputs are very
// are executed over the ACIO protocol compared to only the input read // expensive (~12 ms) as they are executed over the ACIO protocol
// calls (~4 ms) which have a dedicated IOCTL call/endpoint // compared to only the input read calls (~4 ms) which have a dedicated
// IOCTL call/endpoint
local_tmp = atomic_load_explicit( local_tmp = atomic_load_explicit(
&_child_ddr_io_data_extio_lights, &_child_ddr_io_data_extio_lights, memory_order_relaxed);
memory_order_relaxed);
if (local_tmp != prev_child_ddr_io_data_extio_lights) { if (local_tmp != prev_child_ddr_io_data_extio_lights) {
_child_ddr_io_set_lights_extio(local_tmp); _child_ddr_io_set_lights_extio(local_tmp);
@ -104,9 +100,8 @@ static int _io_thread_proc(void *ctx)
} }
local_tmp = atomic_load_explicit( local_tmp = atomic_load_explicit(
&_child_ddr_io_data_p3io_lights, &_child_ddr_io_data_p3io_lights, memory_order_relaxed);
memory_order_relaxed);
if (local_tmp != prev_child_ddr_io_data_p3io_lights) { if (local_tmp != prev_child_ddr_io_data_p3io_lights) {
_child_ddr_io_set_lights_p3io(local_tmp); _child_ddr_io_set_lights_p3io(local_tmp);
prev_child_ddr_io_data_p3io_lights = local_tmp; prev_child_ddr_io_data_p3io_lights = local_tmp;
@ -121,22 +116,23 @@ static int _io_thread_proc(void *ctx)
time_end = time_get_counter(); time_end = time_get_counter();
total_time = time_get_elapsed_us(time_end - time_start); total_time = time_get_elapsed_us(time_end - time_start);
log_info("IO thread performance: total iterations %lld, avg. loop cycle time %f us", log_info(
loop_counter, ((double) total_time) / loop_counter); "IO thread performance: total iterations %lld, avg. loop cycle time %f "
"us",
loop_counter,
((double) total_time) / loop_counter);
atomic_store_explicit( atomic_store_explicit(
&_io_thread_proc_running, &_io_thread_proc_running, false, memory_order_seq_cst);
false,
memory_order_seq_cst);
log_info("IO thread shut down"); log_info("IO thread shut down");
return 0; return 0;
} }
static void* _load_function(HMODULE module, const char* name) static void *_load_function(HMODULE module, const char *name)
{ {
void* ptr; void *ptr;
ptr = GetProcAddress(module, name); ptr = GetProcAddress(module, name);
@ -175,13 +171,19 @@ bool ddr_io_init(
return false; return false;
} }
_child_ddr_io_set_loggers = _load_function(_child_ddr_io_module, "ddr_io_set_loggers"); _child_ddr_io_set_loggers =
_load_function(_child_ddr_io_module, "ddr_io_set_loggers");
_child_ddr_io_init = _load_function(_child_ddr_io_module, "ddr_io_init"); _child_ddr_io_init = _load_function(_child_ddr_io_module, "ddr_io_init");
_child_ddr_io_read_pad = _load_function(_child_ddr_io_module, "ddr_io_read_pad"); _child_ddr_io_read_pad =
_child_ddr_io_set_lights_extio = _load_function(_child_ddr_io_module, "ddr_io_set_lights_extio"); _load_function(_child_ddr_io_module, "ddr_io_read_pad");
_child_ddr_io_set_lights_p3io = _load_function(_child_ddr_io_module, "ddr_io_set_lights_p3io"); _child_ddr_io_set_lights_extio =
_child_ddr_io_set_lights_hdxs_panel = _load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_panel"); _load_function(_child_ddr_io_module, "ddr_io_set_lights_extio");
_child_ddr_io_set_lights_hdxs_rgb = _load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_rgb"); _child_ddr_io_set_lights_p3io =
_load_function(_child_ddr_io_module, "ddr_io_set_lights_p3io");
_child_ddr_io_set_lights_hdxs_panel =
_load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_panel");
_child_ddr_io_set_lights_hdxs_rgb =
_load_function(_child_ddr_io_module, "ddr_io_set_lights_hdxs_rgb");
_child_ddr_io_fini = _load_function(_child_ddr_io_module, "ddr_io_fini"); _child_ddr_io_fini = _load_function(_child_ddr_io_module, "ddr_io_fini");
_child_ddr_io_set_loggers( _child_ddr_io_set_loggers(
@ -199,10 +201,7 @@ bool ddr_io_init(
return false; return false;
} }
atomic_store_explicit( atomic_store_explicit(&_io_thread_proc_loop, true, memory_order_seq_cst);
&_io_thread_proc_loop,
true,
memory_order_seq_cst);
if (!thread_create(_io_thread_proc, NULL, 16384, 0)) { if (!thread_create(_io_thread_proc, NULL, 16384, 0)) {
log_warning("Creating IO thread failed"); log_warning("Creating IO thread failed");
@ -224,17 +223,13 @@ uint32_t ddr_io_read_pad(void)
void ddr_io_set_lights_extio(uint32_t extio_lights) void ddr_io_set_lights_extio(uint32_t extio_lights)
{ {
atomic_store_explicit( atomic_store_explicit(
&_child_ddr_io_data_extio_lights, &_child_ddr_io_data_extio_lights, extio_lights, memory_order_relaxed);
extio_lights,
memory_order_relaxed);
} }
void ddr_io_set_lights_p3io(uint32_t p3io_lights) void ddr_io_set_lights_p3io(uint32_t p3io_lights)
{ {
atomic_store_explicit( atomic_store_explicit(
&_child_ddr_io_data_p3io_lights, &_child_ddr_io_data_p3io_lights, p3io_lights, memory_order_relaxed);
p3io_lights,
memory_order_relaxed);
} }
void ddr_io_set_lights_hdxs_panel(uint32_t lights) void ddr_io_set_lights_hdxs_panel(uint32_t lights)
@ -249,14 +244,12 @@ void ddr_io_set_lights_hdxs_rgb(uint8_t idx, uint8_t r, uint8_t g, uint8_t b)
void ddr_io_fini(void) void ddr_io_fini(void)
{ {
atomic_store_explicit( atomic_store_explicit(&_io_thread_proc_loop, false, memory_order_seq_cst);
&_io_thread_proc_loop,
false,
memory_order_seq_cst);
log_info("Shutting down IO thread and waiting for it to finish..."); log_info("Shutting down IO thread and waiting for it to finish...");
while (atomic_load_explicit(&_io_thread_proc_running, memory_order_seq_cst)) { while (
atomic_load_explicit(&_io_thread_proc_running, memory_order_seq_cst)) {
Sleep(1); Sleep(1);
} }

View File

@ -50,8 +50,9 @@ arrays_fail:
caps_fail: caps_fail:
/** /**
* Still allow the device to be used as input. * Still allow the device to be used as input.
* Useful for devices like the Sony DUALSHOCK 4, where it indicates it can receive outputs * Useful for devices like the Sony DUALSHOCK 4, where it indicates it can
* but it errors out when trying to initialize an output report. * receive outputs but it errors out when trying to initialize an output
* report.
*/ */
return true; return true;
} }
@ -213,7 +214,7 @@ r_init_fail:
meta->nreports = 0; meta->nreports = 0;
free(meta->reports); free(meta->reports);
meta->reports = NULL; meta->reports = NULL;
meta->nlights = 0; meta->nlights = 0;
meta->nbuttons = 0; meta->nbuttons = 0;
// Failed out before allocating memory // Failed out before allocating memory

View File

@ -48,8 +48,8 @@ static void p3io_cmd_get_cab_type_or_dipsw(
static void p3io_cmd_get_video_freq( static void p3io_cmd_get_video_freq(
const struct p3io_req_get_video_freq *req, const struct p3io_req_get_video_freq *req,
struct p3io_resp_get_video_freq *resp); struct p3io_resp_get_video_freq *resp);
static void static void p3io_cmd_unknown_2b(
p3io_cmd_unknown_2b(const struct p3io_req_unknown_2b *req, struct p3io_resp_unknown_2b *resp); const struct p3io_req_unknown_2b *req, struct p3io_resp_unknown_2b *resp);
static void static void
p3io_cmd_init(const struct p3io_req_init *req, struct p3io_resp_init *resp); p3io_cmd_init(const struct p3io_req_init *req, struct p3io_resp_init *resp);
static void p3io_cmd_get_coinstock( static void p3io_cmd_get_coinstock(
@ -57,8 +57,9 @@ static void p3io_cmd_get_coinstock(
static void p3io_cmd_set_coin_counter( static void p3io_cmd_set_coin_counter(
const struct p3io_req_set_coin_counter *req, const struct p3io_req_set_coin_counter *req,
struct p3io_resp_set_coin_counter *resp); struct p3io_resp_set_coin_counter *resp);
static void static void p3io_cmd_unknown(
p3io_cmd_unknown(const struct p3io_req_unknown_generic *req, struct p3io_resp_unknown_generic *resp); const struct p3io_req_unknown_generic *req,
struct p3io_resp_unknown_generic *resp);
void p3io_emu_init(const struct p3io_ops *ops, void *ctx) void p3io_emu_init(const struct p3io_ops *ops, void *ctx)
{ {
@ -518,8 +519,8 @@ static void p3io_cmd_get_video_freq(
} }
} }
static void static void p3io_cmd_unknown_2b(
p3io_cmd_unknown_2b(const struct p3io_req_unknown_2b *req, struct p3io_resp_unknown_2b *resp) const struct p3io_req_unknown_2b *req, struct p3io_resp_unknown_2b *resp)
{ {
log_misc("Unknown 2b"); log_misc("Unknown 2b");
@ -573,10 +574,13 @@ static void p3io_cmd_set_coin_counter(
resp->status = 0; resp->status = 0;
} }
static void static void p3io_cmd_unknown(
p3io_cmd_unknown(const struct p3io_req_unknown_generic *req, struct p3io_resp_unknown_generic *resp) const struct p3io_req_unknown_generic *req,
struct p3io_resp_unknown_generic *resp)
{ {
log_warning("Unsupported P3IO command, sending default response (might not work/crash though): %02x", log_warning(
"Unsupported P3IO command, sending default response (might not "
"work/crash though): %02x",
req->hdr.cmd); req->hdr.cmd);
p3io_resp_hdr_init(&resp->hdr, sizeof(*resp), &req->hdr); p3io_resp_hdr_init(&resp->hdr, sizeof(*resp), &req->hdr);