feat: bemanitools 6 initial refactoring drop, alpha 1

**THIS IS A HIGHLY WORK/DEVELOPMENT IN PROGRESS VERSION**

**THINGS ARE BROKEN AND EVERYTHING IS SUBJECT TO CHANGE**

First cut after massive refactoring with most critical and fundamental changes implemented.
We need to start somewhere, and this might be as good as anything else, so we can get started
with testing, bug fixing and iterating for the next releases.

The following list is non-exhaustive, does not guarantee anything does work, yet, and is supposed
to give a high level idea of what all of this is about. Updated documentation will reflect all of
this at some later point in time in more detail.

* A common "core" now abstracts logging, thread, property and configuration infrastructure and
  provides a common interface. This is used by bemanitools internally as well as all tools, hooks
  and APIs provided and don't depend on the game, version of the game or AVS version available
  anymore
* New bemanitools (public) API
  * Versioned API allowing for handling incremental API changes as well as breaking changes by
    providing a new/different version when necessary
  * Unified interfaces for bemanitools core API, i.e. logging, threads, configuration
  * SDK with examples (TBD)
  * Dogfooding approach: Bemanitools uses its own (public) API to implement and provide fundamental
    features like configurable keyboard implementations for IO or hooks for different games and
    versions
* All bemanitools hooks and IO libraries have been or are about to be re-worked to use the new APIs
* New hook API allows for more fine grained runtime control when stages of the hook are to be
  executed, i.e. pre AVS, before main game, iat hooking instead of relying purely on DllMain
  (which is still a compatible option though)
* launcher as a replacement for bootstrap: Bring it significantly closer to the original bootstrap
  by supporting completely vanilla data and bootstrap.xml configurations to run the games. Note
  that bemanitools does not include any code or means to run DRM'd data, only decrypted
* inject is also being reworked to use as much of the same "infrastructure" as launcher to provide
  a more seamless bootstrapping process for games that keeps pre-eapki data as vanilla as possible
Summary:

Test Plan:
Summary:

Test Plan:
Summary:

Test Plan:
Summary:

Test Plan:
This commit is contained in:
icex2
2024-08-15 11:34:31 +02:00
parent 106b908f17
commit 57e68f928a
692 changed files with 19534 additions and 8278 deletions
+42
View File
@@ -0,0 +1,42 @@
#ifndef BT_API_ACIO_MGR_H
#define BT_API_ACIO_MGR_H
#include <stdbool.h>
#include <stdint.h>
#define BT_ACIO_MGR_NODE_PRODUCT_CODE_LEN 4
typedef struct ac_io_message bt_acio_message_t;
typedef struct aciodrv_device_ctx bt_acio_drv_device_ctx_t;
typedef struct bt_acio_mgr_port_dispatcher bt_acio_mgr_port_dispatcher_t;
typedef bt_acio_mgr_port_dispatcher_t *(*bt_acio_mgr_port_init_t)(const char *path, uint32_t baud);
typedef void (*bt_acio_mgr_port_fini_t)(bt_acio_mgr_port_dispatcher_t *dispatcher);
typedef uint8_t (*bt_acio_mgr_node_count_get_t)(const bt_acio_mgr_port_dispatcher_t *dispatcher);
typedef bool (*bt_acio_mgr_node_product_ident_get_t)(
const bt_acio_mgr_port_dispatcher_t *dispatcher,
uint8_t node_id,
char product[BT_ACIO_MGR_NODE_PRODUCT_CODE_LEN]);
typedef bool (*bt_acio_mgr_port_packet_submit_t)(
bt_acio_mgr_port_dispatcher_t *dispatcher,
bt_acio_message_t *msg,
uint32_t max_resp_size);
typedef bt_acio_drv_device_ctx_t *(*bt_acio_mgr_port_checkout_t)(bt_acio_mgr_port_dispatcher_t *dispatcher);
typedef void (*bt_acio_mgr_port_checkin_t)(bt_acio_mgr_port_dispatcher_t *dispatcher);
typedef struct bt_acio_mgr_api {
uint16_t version;
struct {
// Required to be implemented
bt_acio_mgr_port_init_t port_init;
bt_acio_mgr_port_fini_t port_fini;
bt_acio_mgr_node_count_get_t node_count_get;
bt_acio_mgr_node_product_ident_get_t node_product_ident_get;
bt_acio_mgr_port_packet_submit_t port_packet_submit;
bt_acio_mgr_port_checkout_t port_checkout;
bt_acio_mgr_port_checkin_t port_checkin;
} v1;
} bt_acio_mgr_api_t;
#endif
+51
View File
@@ -0,0 +1,51 @@
#ifndef BT_API_CORE_CONFIG_H
#define BT_API_CORE_CONFIG_H
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct bt_core_config bt_core_config_t;
typedef enum bt_core_config_result {
BT_CORE_CONFIG_RESULT_SUCCESS = 0,
BT_CORE_CONFIG_RESULT_ERROR_INTERNAL = 1,
BT_CORE_CONFIG_RESULT_VALUE_NOT_FOUND = 2,
BT_CORE_CONFIG_RESULT_TYPE_MISMATCH = 3,
} bt_core_config_result_t;
typedef bt_core_config_result_t (*bt_core_config_s8_get_t)(const bt_core_config_t *config, const char *path, int8_t *value);
typedef bt_core_config_result_t (*bt_core_config_u8_get_t)(const bt_core_config_t *config, const char *path, uint8_t *value);
typedef bt_core_config_result_t (*bt_core_config_s16_get_t)(const bt_core_config_t *config, const char *path, int16_t *value);
typedef bt_core_config_result_t (*bt_core_config_u16_get_t)(const bt_core_config_t *config, const char *path, uint16_t *value);
typedef bt_core_config_result_t (*bt_core_config_s32_get_t)(const bt_core_config_t *config, const char *path, int32_t *value);
typedef bt_core_config_result_t (*bt_core_config_u32_get_t)(const bt_core_config_t *config, const char *path, uint32_t *value);
typedef bt_core_config_result_t (*bt_core_config_s64_get_t)(const bt_core_config_t *config, const char *path, int64_t *value);
typedef bt_core_config_result_t (*bt_core_config_u64_get_t)(const bt_core_config_t *config, const char *path, uint64_t *value);
typedef bt_core_config_result_t (*bt_core_config_float_get_t)(const bt_core_config_t *config, const char *path, float *value);
typedef bt_core_config_result_t (*bt_core_config_double_get_t)(const bt_core_config_t *config, const char *path, double *value);
typedef bt_core_config_result_t (*bt_core_config_bool_get_t)(const bt_core_config_t *config, const char *path, bool *value);
typedef bt_core_config_result_t (*bt_core_config_bin_get_t)(const bt_core_config_t *config, const char *path, void *value, size_t len);
typedef bt_core_config_result_t (*bt_core_config_str_get_t)(const bt_core_config_t *config, const char *path, char *value, size_t len);
typedef struct bt_core_config_api {
uint16_t version;
struct {
bt_core_config_s8_get_t s8_get;
bt_core_config_u8_get_t u8_get;
bt_core_config_s16_get_t s16_get;
bt_core_config_u16_get_t u16_get;
bt_core_config_s32_get_t s32_get;
bt_core_config_u32_get_t u32_get;
bt_core_config_s64_get_t s64_get;
bt_core_config_u64_get_t u64_get;
bt_core_config_float_get_t float_get;
bt_core_config_double_get_t double_get;
bt_core_config_bool_get_t bool_get;
bt_core_config_bin_get_t bin_get;
bt_core_config_str_get_t str_get;
} v1;
} bt_core_config_api_t;
#endif
+19
View File
@@ -0,0 +1,19 @@
#ifndef BT_API_CORE_LOG_H
#define BT_API_CORE_LOG_H
#include <stdint.h>
typedef void (*bt_core_log_message_t)(const char *module, const char *fmt, ...);
typedef struct bt_core_log_api {
uint16_t version;
struct {
bt_core_log_message_t misc;
bt_core_log_message_t info;
bt_core_log_message_t warning;
bt_core_log_message_t fatal;
} v1;
} bt_core_log_api_t;
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef BT_API_CORE_THREAD_H
#define BT_API_CORE_THREAD_H
#include <stdint.h>
typedef enum bt_core_thread_result {
BT_CORE_THREAD_RESULT_SUCCESS = 0,
BT_CORE_THREAD_RESULT_ERROR_INTERNAL = 1,
} bt_core_thread_result_t;
typedef int bt_core_thread_id_t;
typedef bt_core_thread_result_t (*bt_core_thread_create_t)(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority, bt_core_thread_id_t *thread_id);
typedef bt_core_thread_result_t (*bt_core_thread_join_t)(bt_core_thread_id_t thread_id, int *result);
typedef bt_core_thread_result_t (*bt_core_thread_destroy_t)(bt_core_thread_id_t thread_id);
typedef struct bt_core_thread_api {
uint16_t version;
struct {
bt_core_thread_create_t create;
bt_core_thread_join_t join;
bt_core_thread_destroy_t destroy;
} v1;
} bt_core_thread_api_t;
#endif
+41
View File
@@ -0,0 +1,41 @@
#ifndef BT_API_HOOK_H
#define BT_API_HOOK_H
#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "api/core/config.h"
typedef enum bt_io_bst_gpio_sys_bit {
BT_IO_BST_GPIO_SYS_COIN = 2,
BT_IO_BST_GPIO_SYS_TEST = 4,
BT_IO_BST_GPIO_SYS_SERVICE = 5,
} bt_io_bst_gpio_sys_bit_t;
typedef void (*bt_hook_iat_dll_name_get_t)(char *buffer, size_t size);
typedef bool (*bt_hook_pre_avs_init_t)(const bt_core_config_t *config);
// game module reference, either the exe or dll. allow for further targeted hooking/patching
// remark: you can't own the memory of the property_node config. whatever you need form that, make sure to copy the data and not just reference it.
// there is no guarantee the data is not free'd/gone after this call returns
// use the property api to iterate the data and parse it into your own custom configuration struct
// it is advised to also validate all parameters
// if no configuration was provided upon loading, the config_node contains an empty root node
typedef bool (*bt_hook_main_init_t)(HMODULE game_module, const bt_core_config_t *config);
typedef void (*bt_hook_main_fini_t)();
typedef struct bt_hook_api {
uint16_t version;
struct {
// Optional
bt_hook_iat_dll_name_get_t iat_dll_name_get;
bt_hook_pre_avs_init_t pre_avs_init;
bt_hook_main_init_t main_init;
bt_hook_main_fini_t main_fini;
} v1;
} bt_hook_api_t;
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef BT_API_INPUT_H
#define BT_API_INPUT_H
#include <stdbool.h>
#include <stdint.h>
typedef bool (*bt_input_init_t)();
typedef void (*bt_input_fini_t)();
typedef bool (*bt_input_mapper_config_load_t)(const char *game_type);
typedef uint8_t (*bt_input_mapper_analog_read_t)(uint8_t analog);
typedef uint64_t (*bt_input_mapper_update_t)();
typedef void (*bt_input_mapper_light_write_t)(uint8_t light, uint8_t intensity);
typedef struct bt_input_api {
uint16_t version;
struct {
// Required to be implemented
bt_input_init_t init;
bt_input_fini_t fini;
bt_input_mapper_config_load_t mapper_config_load;
bt_input_mapper_analog_read_t mapper_analog_read;
bt_input_mapper_update_t mapper_update;
bt_input_mapper_light_write_t mapper_light_write;
} v1;
} bt_input_api_t;
#endif
+30
View File
@@ -0,0 +1,30 @@
#ifndef BT_API_IO_BST_H
#define BT_API_IO_BST_H
#include <stdbool.h>
#include <stdint.h>
typedef enum bt_io_bst_gpio_sys_bit {
BT_IO_BST_GPIO_SYS_COIN = 2,
BT_IO_BST_GPIO_SYS_TEST = 4,
BT_IO_BST_GPIO_SYS_SERVICE = 5,
} bt_io_bst_gpio_sys_bit_t;
typedef bool (*bt_io_bst_init_t)();
typedef void (*bt_io_bst_fini_t)();
typedef bool (*bt_io_bst_input_read_t)();
typedef uint8_t (*bt_io_bst_input_get_t)();
typedef struct bt_io_bst_api {
uint16_t version;
struct {
// Required to be implemented
bt_io_bst_init_t init;
bt_io_bst_fini_t fini;
bt_io_bst_input_read_t input_read;
bt_io_bst_input_get_t input_get;
} v1;
} bt_io_bst_api_t;
#endif
+106
View File
@@ -0,0 +1,106 @@
#ifndef BT_API_IO_DDR_H
#define BT_API_IO_DDR_H
#include <stdbool.h>
#include <stdint.h>
typedef enum bt_io_ddr_pad_bit {
BT_IO_DDR_TEST = 0x04,
BT_IO_DDR_COIN = 0x05,
BT_IO_DDR_SERVICE = 0x06,
BT_IO_DDR_P2_START = 0x08,
BT_IO_DDR_P2_UP = 0x09,
BT_IO_DDR_P2_DOWN = 0x0A,
BT_IO_DDR_P2_LEFT = 0x0B,
BT_IO_DDR_P2_RIGHT = 0x0C,
BT_IO_DDR_P2_MENU_LEFT = 0x0E,
BT_IO_DDR_P2_MENU_RIGHT = 0x0F,
BT_IO_DDR_P2_MENU_UP = 0x02,
BT_IO_DDR_P2_MENU_DOWN = 0x03,
BT_IO_DDR_P1_START = 0x10,
BT_IO_DDR_P1_UP = 0x11,
BT_IO_DDR_P1_DOWN = 0x12,
BT_IO_DDR_P1_LEFT = 0x13,
BT_IO_DDR_P1_RIGHT = 0x14,
BT_IO_DDR_P1_MENU_LEFT = 0x16,
BT_IO_DDR_P1_MENU_RIGHT = 0x17,
BT_IO_DDR_P1_MENU_UP = 0x00,
BT_IO_DDR_P1_MENU_DOWN = 0x01,
} bt_io_ddr_pad_bit_t;
// see the functions below for more information
typedef enum bt_io_ddr_p3io_light_bit {
BT_IO_DDR_P3IO_LIGHT_P1_MENU = 0x00,
BT_IO_DDR_P3IO_LIGHT_P2_MENU = 0x01,
BT_IO_DDR_P3IO_LIGHT_P2_LOWER_LAMP = 0x04,
BT_IO_DDR_P3IO_LIGHT_P2_UPPER_LAMP = 0x05,
BT_IO_DDR_P3IO_LIGHT_P1_LOWER_LAMP = 0x06,
BT_IO_DDR_P3IO_LIGHT_P1_UPPER_LAMP = 0x07,
} bt_io_ddr_p3io_light_bit_t;
typedef enum bt_io_ddr_hdxs_light_bit {
BT_IO_DDR_HDXS_LIGHT_HD_P1_START = 0x08,
BT_IO_DDR_HDXS_LIGHT_HD_P1_UP_DOWN = 0x09,
BT_IO_DDR_HDXS_LIGHT_HD_P1_LEFT_RIGHT = 0x0A,
BT_IO_DDR_HDXS_LIGHT_HD_P2_START = 0x0B,
BT_IO_DDR_HDXS_LIGHT_HD_P2_UP_DOWN = 0x0C,
BT_IO_DDR_HDXS_LIGHT_HD_P2_LEFT_RIGHT = 0x0D,
} bt_io_ddr_hdxs_light_bit_t;
// the indexing starts from 0x20 if you're looking in geninput
typedef enum bt_io_ddr_hdxs_rgb_light_idx {
BT_IO_DDR_HDXS_LIGHT_HD_P1_SPEAKER_F_R = 0x00,
BT_IO_DDR_HDXS_LIGHT_HD_P1_SPEAKER_F_G = 0x01,
BT_IO_DDR_HDXS_LIGHT_HD_P1_SPEAKER_F_B = 0x02,
BT_IO_DDR_HDXS_LIGHT_HD_P2_SPEAKER_F_R = 0x03,
BT_IO_DDR_HDXS_LIGHT_HD_P2_SPEAKER_F_G = 0x04,
BT_IO_DDR_HDXS_LIGHT_HD_P2_SPEAKER_F_B = 0x05,
BT_IO_DDR_HDXS_LIGHT_HD_P1_SPEAKER_W_R = 0x06,
BT_IO_DDR_HDXS_LIGHT_HD_P1_SPEAKER_W_G = 0x07,
BT_IO_DDR_HDXS_LIGHT_HD_P1_SPEAKER_W_B = 0x08,
BT_IO_DDR_HDXS_LIGHT_HD_P2_SPEAKER_W_R = 0x09,
BT_IO_DDR_HDXS_LIGHT_HD_P2_SPEAKER_W_G = 0x0A,
BT_IO_DDR_HDXS_LIGHT_HD_P2_SPEAKER_W_B = 0x0B,
} bt_io_ddr_hdxs_rgb_light_idx_t;
typedef enum bt_io_ddr_extio_light_bit {
BT_IO_DDR_EXTIO_LIGHT_NEONS = 0x0E,
BT_IO_DDR_EXTIO_LIGHT_P2_RIGHT = 0x13,
BT_IO_DDR_EXTIO_LIGHT_P2_LEFT = 0x14,
BT_IO_DDR_EXTIO_LIGHT_P2_DOWN = 0x15,
BT_IO_DDR_EXTIO_LIGHT_P2_UP = 0x16,
BT_IO_DDR_EXTIO_LIGHT_P1_RIGHT = 0x1B,
BT_IO_DDR_EXTIO_LIGHT_P1_LEFT = 0x1C,
BT_IO_DDR_EXTIO_LIGHT_P1_DOWN = 0x1D,
BT_IO_DDR_EXTIO_LIGHT_P1_UP = 0x1E
} bt_io_ddr_extio_light_bit_t;
typedef bool (*bt_io_ddr_init_t)();
typedef void (*bt_io_ddr_fini_t)();
typedef uint32_t (*bt_io_ddr_pad_read_t)();
typedef void (*bt_io_ddr_extio_lights_set_t)(uint32_t extio_lights);
typedef void (*bt_io_ddr_p3io_lights_set_t)(uint32_t p3io_lights);
typedef void (*bt_io_ddr_hdxs_lights_panel_set_t)(uint32_t hdxs_lights);
typedef void (*bt_io_ddr_hdxs_lights_rgb_set_t)(uint8_t idx, uint8_t r, uint8_t g, uint8_t b);
typedef struct bt_io_ddr_api {
uint16_t version;
struct {
// Required to be implemented
bt_io_ddr_init_t init;
bt_io_ddr_fini_t fini;
bt_io_ddr_pad_read_t pad_read;
bt_io_ddr_extio_lights_set_t extio_lights_set;
bt_io_ddr_p3io_lights_set_t p3io_lights_set;
bt_io_ddr_hdxs_lights_panel_set_t hdxs_lights_panel_set;
bt_io_ddr_hdxs_lights_rgb_set_t hdxs_lights_rgb_set;
} v1;
} bt_io_ddr_api_t;
#endif
+88
View File
@@ -0,0 +1,88 @@
#ifndef BT_API_IO_EAM_H
#define BT_API_IO_EAM_H
/* Card reader emulator API. You may replace the stock EAMIO.DLL supplied by
Bemanitools with your own custom implementation, which should implement the
interface contract defined in this header file. */
#include <stdbool.h>
#include <stdint.h>
/* Scan codes for the so-called "10 key" button panel on each card reader. Each
scan code corresponds to a bit position within the 16-bit bitfield that you
return from eam_io_get_keypad_state(). */
typedef enum bt_io_eam_keypad_scan_code {
BT_IO_EAM_KEYPAD_SCAN_CODE_0 = 0,
BT_IO_EAM_KEYPAD_SCAN_CODE_1 = 1,
BT_IO_EAM_KEYPAD_SCAN_CODE_4 = 2,
BT_IO_EAM_KEYPAD_SCAN_CODE_7 = 3,
BT_IO_EAM_KEYPAD_SCAN_CODE_00 = 4,
BT_IO_EAM_KEYPAD_SCAN_CODE_2 = 5,
BT_IO_EAM_KEYPAD_SCAN_CODE_5 = 6,
BT_IO_EAM_KEYPAD_SCAN_CODE_8 = 7,
BT_IO_EAM_KEYPAD_SCAN_CODE_DECIMAL = 8,
BT_IO_EAM_KEYPAD_SCAN_CODE_3 = 9,
BT_IO_EAM_KEYPAD_SCAN_CODE_6 = 10,
BT_IO_EAM_KEYPAD_SCAN_CODE_9 = 11,
BT_IO_EAM_KEYPAD_COUNT = 12, /* Not an actual scan code */
} bt_io_eam_keypad_scan_code_t;
/* Emulating the sensors of a slotted card reader. The reader has one
sensor at the front that detects if a card is getting inserted or
if the card is not fully removed. When the back sensor is triggered
the card is locked in the slot and its data is read. */
typedef enum bt_io_eam_sensor_state {
BT_IO_EAM_SENSOR_STATE_FRONT = 0,
BT_IO_EAM_SENSOR_STATE_BACK = 1,
} bt_io_eam_sensor_state_t;
/* Different commands for the (slotted) reader. The game triggers one
of these actions and the card slot as to execute it. When non-slotted
readers are emulated, these states are not used/set. */
typedef enum bt_io_eam_card_slot_cmd {
BT_IO_EAM_CARD_SLOT_CMD_CLOSE = 0,
BT_IO_EAM_CARD_SLOT_CMD_OPEN = 1,
BT_IO_EAM_CARD_SLOT_CMD_EJECT = 2,
BT_IO_EAM_CARD_SLOT_CMD_READ = 3,
} bt_io_eam_card_slot_cmd_t;
/* Emulating of the card type for new readers. */
typedef enum bt_io_eam_read_card_result {
BT_IO_EAM_READ_CARD_RESULT_NONE = 0,
BT_IO_EAM_READ_CARD_RESULT_ISO15696 = 1,
BT_IO_EAM_READ_CARD_RESULT_FELICA = 2,
} bt_io_eam_read_card_result_t;
typedef struct bt_io_eam_config_api bt_io_eam_config_api_t;
typedef bool (*bt_io_eam_init_t)();
typedef void (*bt_io_eam_fini_t)();
typedef uint16_t (*bt_io_eam_keypad_state_get_t)(uint8_t unit_no);
typedef uint8_t (*bt_io_eam_sensor_state_get_t)(uint8_t unit_no);
typedef uint8_t (*bt_io_eam_card_read_t)(uint8_t unit_no, uint8_t *card_id, uint8_t nbytes);
typedef bool (*bt_io_eam_card_slot_cmd_send_t)(uint8_t unit_no, uint8_t cmd);
typedef bool (*bt_io_eam_poll_t)(uint8_t unit_no);
typedef const bt_io_eam_config_api_t *(*bt_io_eam_config_api_get_t)();
typedef struct bt_io_eam_api {
uint16_t version;
struct {
// Required to be implemented
bt_io_eam_init_t init;
bt_io_eam_fini_t fini;
bt_io_eam_keypad_state_get_t keypad_state_get;
bt_io_eam_sensor_state_get_t sensor_state_get;
bt_io_eam_card_read_t card_read;
bt_io_eam_card_slot_cmd_send_t card_slot_cmd_send;
bt_io_eam_poll_t poll;
bt_io_eam_config_api_get_t config_api_get;
} v1;
} bt_io_eam_api_t;
#endif
+122
View File
@@ -0,0 +1,122 @@
#ifndef BT_API_IO_IIDX_H
#define BT_API_IO_IIDX_H
/* IO emulation provider for beatmania IIDX. */
#include <stdbool.h>
#include <stdint.h>
/* Bit mapping for the "pad" word */
typedef enum bt_io_iidx_sys_bit {
BT_IO_IIDX_SYS_TEST = 0x00,
BT_IO_IIDX_SYS_SERVICE = 0x01,
BT_IO_IIDX_SYS_COIN = 0x02
} bt_io_iidx_sys_bit_t;
typedef enum bt_io_iidx_panel_bit {
BT_IO_IIDX_PANEL_P1_START = 0x00,
BT_IO_IIDX_PANEL_P2_START = 0x01,
BT_IO_IIDX_PANEL_VEFX = 0x02,
BT_IO_IIDX_PANEL_EFFECT = 0x03
} bt_io_iidx_panel_bit_t;
typedef enum bt_io_iidx_key_bit {
BT_IO_IIDX_KEY_P1_1 = 0x00,
BT_IO_IIDX_KEY_P1_2 = 0x01,
BT_IO_IIDX_KEY_P1_3 = 0x02,
BT_IO_IIDX_KEY_P1_4 = 0x03,
BT_IO_IIDX_KEY_P1_5 = 0x04,
BT_IO_IIDX_KEY_P1_6 = 0x05,
BT_IO_IIDX_KEY_P1_7 = 0x06,
BT_IO_IIDX_KEY_P2_1 = 0x07,
BT_IO_IIDX_KEY_P2_2 = 0x08,
BT_IO_IIDX_KEY_P2_3 = 0x09,
BT_IO_IIDX_KEY_P2_4 = 0x0A,
BT_IO_IIDX_KEY_P2_5 = 0x0B,
BT_IO_IIDX_KEY_P2_6 = 0x0C,
BT_IO_IIDX_KEY_P2_7 = 0x0D
} bt_io_iidx_key_bit_t;
/* Bit mapping for the P1 and P2 deck lights */
typedef enum bt_io_iidx_deck_light {
BT_IO_IIDX_DECK_LIGHT_P1_1 = 0,
BT_IO_IIDX_DECK_LIGHT_P1_2 = 1,
BT_IO_IIDX_DECK_LIGHT_P1_3 = 2,
BT_IO_IIDX_DECK_LIGHT_P1_4 = 3,
BT_IO_IIDX_DECK_LIGHT_P1_5 = 4,
BT_IO_IIDX_DECK_LIGHT_P1_6 = 5,
BT_IO_IIDX_DECK_LIGHT_P1_7 = 6,
BT_IO_IIDX_DECK_LIGHT_P2_1 = 8,
BT_IO_IIDX_DECK_LIGHT_P2_2 = 9,
BT_IO_IIDX_DECK_LIGHT_P2_3 = 10,
BT_IO_IIDX_DECK_LIGHT_P2_4 = 11,
BT_IO_IIDX_DECK_LIGHT_P2_5 = 12,
BT_IO_IIDX_DECK_LIGHT_P2_6 = 13,
BT_IO_IIDX_DECK_LIGHT_P2_7 = 14,
} bt_io_iidx_deck_light_t;
/* Bit mapping for the front panel lights */
typedef enum bt_io_iidx_panel_light {
BT_IO_IIDX_PANEL_LIGHT_P1_START = 0,
BT_IO_IIDX_PANEL_LIGHT_P2_START = 1,
BT_IO_IIDX_PANEL_LIGHT_VEFX = 2,
BT_IO_IIDX_PANEL_LIGHT_EFFECT = 3,
} bt_io_iidx_panel_light_t;
/* Bit mapping for the top lamps from left to right when facing cabinet screen
*/
typedef enum bt_io_iidx_top_lamp {
BT_IO_IIDX_TOP_LAMP_LEFT_BLUE = 0,
BT_IO_IIDX_TOP_LAMP_LEFT_GREEN = 1,
BT_IO_IIDX_TOP_LAMP_LEFT_YELLOW = 2,
BT_IO_IIDX_TOP_LAMP_LEFT_RED = 3,
BT_IO_IIDX_TOP_LAMP_RIGHT_BLUE = 4,
BT_IO_IIDX_TOP_LAMP_RIGHT_GREEN = 5,
BT_IO_IIDX_TOP_LAMP_RIGHT_YELLOW = 6,
BT_IO_IIDX_TOP_LAMP_RIGHT_RED = 7,
} bt_io_iidx_top_lamp_t;
typedef bool (*bt_io_iidx_init_t)();
typedef void (*bt_io_iidx_fini_t)();
typedef void (*bt_io_iidx_ep1_deck_lights_set_t)(uint16_t deck_lights);
typedef void (*bt_io_iidx_ep1_panel_lights_set_t)(uint8_t panel_lights);
typedef void (*bt_io_iidx_ep1_top_lamps_set_t)(uint8_t top_lamps);
typedef void (*bt_io_iidx_ep1_top_neons_set_t)(bool top_neons);
typedef bool (*bt_io_iidx_ep1_send_t)();
typedef bool (*bt_io_iidx_ep2_recv_t)();
typedef uint8_t (*bt_io_iidx_ep2_turntable_get_t)(uint8_t player_no);
typedef uint8_t (*bt_io_iidx_ep2_slider_get_t)(uint8_t slider_no);
typedef uint8_t (*bt_io_iidx_ep2_sys_get_t)();
typedef uint8_t (*bt_io_iidx_ep2_panel_get_t)();
typedef uint16_t (*bt_io_iidx_ep2_keys_get_t)();
typedef bool (*bt_io_iidx_ep3_16seg_send_t)(const char *text);
typedef struct bt_io_iidx_api {
uint16_t version;
struct {
// Required to be implemented
bt_io_iidx_init_t init;
bt_io_iidx_fini_t fini;
bt_io_iidx_ep1_deck_lights_set_t ep1_deck_lights_set;
bt_io_iidx_ep1_panel_lights_set_t ep1_panel_lights_set;
bt_io_iidx_ep1_top_lamps_set_t ep1_top_lamps_set;
bt_io_iidx_ep1_top_neons_set_t ep1_top_neons_set;
bt_io_iidx_ep1_send_t ep1_send;
bt_io_iidx_ep2_recv_t ep2_recv;
bt_io_iidx_ep2_turntable_get_t ep2_turntable_get;
bt_io_iidx_ep2_slider_get_t ep2_slider_get;
bt_io_iidx_ep2_sys_get_t ep2_sys_get;
bt_io_iidx_ep2_panel_get_t ep2_panel_get;
bt_io_iidx_ep2_keys_get_t ep2_keys_get;
bt_io_iidx_ep3_16seg_send_t ep3_16seg_send;
} v1;
} bt_io_iidx_api_t;
#endif
+85
View File
@@ -0,0 +1,85 @@
#ifndef BT_API_IO_JB_H
#define BT_API_IO_JB_H
/* IO emulation provider for jubeat. */
#include <stdbool.h>
#include <stdint.h>
/* input bit mappings. Panels on the controller are
panel 1 top left corner down to panel 16 bottom right corner */
typedef enum bt_io_jb_panel_bit {
BT_IO_JB_PANEL_01 = 0x00,
BT_IO_JB_PANEL_02 = 0x01,
BT_IO_JB_PANEL_03 = 0x02,
BT_IO_JB_PANEL_04 = 0x03,
BT_IO_JB_PANEL_05 = 0x04,
BT_IO_JB_PANEL_06 = 0x05,
BT_IO_JB_PANEL_07 = 0x06,
BT_IO_JB_PANEL_08 = 0x07,
BT_IO_JB_PANEL_09 = 0x08,
BT_IO_JB_PANEL_10 = 0x09,
BT_IO_JB_PANEL_11 = 0x0A,
BT_IO_JB_PANEL_12 = 0x0B,
BT_IO_JB_PANEL_13 = 0x0C,
BT_IO_JB_PANEL_14 = 0x0D,
BT_IO_JB_PANEL_15 = 0x0E,
BT_IO_JB_PANEL_16 = 0x0F,
} bt_io_jb_panel_bit_t;
/* input "single button mode" mappings. Allows you to check each corner of each
button to determine any flaky inputs
*/
typedef enum bt_io_jb_panel_mode {
BT_IO_JB_PANEL_MODE_ALL = 0, // any of the four corners will trigger a panel
BT_IO_JB_PANEL_MODE_TOP_LEFT = 1,
BT_IO_JB_PANEL_MODE_TOP_RIGHT = 2,
BT_IO_JB_PANEL_MODE_BOTTOM_RIGHT = 3,
BT_IO_JB_PANEL_MODE_BOTTOM_LEFT = 4,
} bt_io_jb_panel_mode_t;
/* Bit mappings for "system" inputs */
typedef enum bt_io_jb_sys_bit {
BT_IO_JB_SYS_TEST = 0x00,
BT_IO_JB_SYS_SERVICE = 0x01,
BT_IO_JB_SYS_COIN = 0x02,
} bt_io_jb_sys_bit_t;
/* RGB led units to address */
typedef enum bt_io_jb_rgb_led {
BT_IO_JB_RGB_LED_FRONT = 0,
BT_IO_JB_RGB_LED_TOP = 1,
BT_IO_JB_RGB_LED_LEFT = 2,
BT_IO_JB_RGB_LED_RIGHT = 3,
BT_IO_JB_RGB_LED_TITLE = 4,
BT_IO_JB_RGB_LED_WOOFER = 5
} bt_io_jb_rgb_led_t;
typedef bool (*bt_io_jb_init_t)();
typedef void (*bt_io_jb_fini_t)();
typedef bool (*bt_io_jb_inputs_read_t)();
typedef uint8_t (*bt_io_jb_sys_inputs_get_t)();
typedef uint16_t (*bt_io_jb_panel_inputs_get_t)();
typedef void (*bt_io_jb_rgb_led_set_t)(bt_io_jb_rgb_led_t unit, uint8_t r, uint8_t g, uint8_t b);
typedef bool (*bt_io_jb_lights_write_t)();
typedef bool (*bt_io_jb_panel_mode_set_t)(bt_io_jb_panel_mode_t mode);
typedef bool (*bt_io_jb_coin_blocker_set_t)(bool blocked);
typedef struct bt_io_jb_api {
uint16_t version;
struct {
// Required to be implemented
bt_io_jb_init_t init;
bt_io_jb_fini_t fini;
bt_io_jb_inputs_read_t inputs_read;
bt_io_jb_sys_inputs_get_t sys_inputs_get;
bt_io_jb_panel_inputs_get_t panel_inputs_get;
bt_io_jb_rgb_led_set_t rgb_led_set;
bt_io_jb_lights_write_t lights_write;
bt_io_jb_panel_mode_set_t panel_mode_set;
bt_io_jb_coin_blocker_set_t coin_blocker_set;
} v1;
} bt_io_jb_api_t;
#endif
+80
View File
@@ -0,0 +1,80 @@
#ifndef BT_API_IO_POPN_H
#define BT_API_IO_POPN_H
/* IO emulation provider for pop'n music. */
#include <stdbool.h>
#include <stdint.h>
/* Bit mapping for the "buttons" word */
typedef enum bt_io_popn_sys_bit {
BT_IO_POPN_SYS_SERVICE = 0x06,
BT_IO_POPN_SYS_TEST = 0x07,
} bt_io_popn_sys_bit_t;
typedef enum bt_io_popn_button_bit {
BT_IO_POPN_BUTTON_1 = 0x08,
BT_IO_POPN_BUTTON_2 = 0x09,
BT_IO_POPN_BUTTON_3 = 0x0a,
BT_IO_POPN_BUTTON_4 = 0x0b,
BT_IO_POPN_BUTTON_5 = 0x0c,
BT_IO_POPN_BUTTON_6 = 0x0d,
BT_IO_POPN_BUTTON_7 = 0x0e,
BT_IO_POPN_BUTTON_8 = 0x0f,
BT_IO_POPN_BUTTON_9 = 0x10,
} bt_io_popn_button_bit_t;
typedef enum bt_io_popn_light_top_lamp_bit {
BT_IO_POPN_LIGHT_HI_LAMP1 = 0x00,
BT_IO_POPN_LIGHT_HI_LAMP2 = 0x01,
BT_IO_POPN_LIGHT_HI_LAMP3 = 0x02,
BT_IO_POPN_LIGHT_HI_LAMP4 = 0x03,
BT_IO_POPN_LIGHT_HI_LAMP5 = 0x04,
} bt_io_popn_light_top_lamp_bit_t;
typedef enum bt_io_popn_light_side_lamp_bit {
BT_IO_POPN_LIGHT_LEFT_LAMP1 = 0x00,
BT_IO_POPN_LIGHT_LEFT_LAMP2 = 0x01,
BT_IO_POPN_LIGHT_RIGHT_LAMP1 = 0x02,
BT_IO_POPN_LIGHT_RIGHT_LAMP2 = 0x03,
} bt_io_popn_light_side_lamp_bit_t;
typedef enum bt_io_popn_light_switch_lamp_bit {
BT_IO_POPN_LIGHT_SW_LAMP1 = 0x00, // Is actually 4 bits wide
BT_IO_POPN_LIGHT_SW_LAMP2 = 0x04,
BT_IO_POPN_LIGHT_SW_LAMP3 = 0x05,
BT_IO_POPN_LIGHT_SW_LAMP4 = 0x06,
BT_IO_POPN_LIGHT_SW_LAMP5 = 0x07,
BT_IO_POPN_LIGHT_SW_LAMP6 = 0x08,
BT_IO_POPN_LIGHT_SW_LAMP7 = 0x09,
BT_IO_POPN_LIGHT_SW_LAMP8 = 0x0a,
BT_IO_POPN_LIGHT_SW_LAMP9 = 0x0b,
} bt_io_popn_light_switch_lamp_bit_t;
typedef bool (*bt_io_popn_init_t)();
typedef void (*bt_io_popn_fini_t)();
typedef uint32_t (*bt_io_popn_buttons_get_t)();
typedef void (*bt_io_popn_top_lights_set_t)(uint32_t lights);
typedef void (*bt_io_popn_side_lights_set_t)(uint32_t lights);
typedef void (*bt_io_popn_button_lights_set_t)(uint32_t lights);
typedef void (*bt_io_popn_coin_blocker_light_set_t)(bool enabled);
typedef void (*bt_io_popn_coin_counter_light_set_t)(bool enabled);
typedef struct bt_io_popn_api {
uint16_t version;
struct {
// Required to be implemented
bt_io_popn_init_t init;
bt_io_popn_fini_t fini;
bt_io_popn_buttons_get_t buttons_get;
bt_io_popn_top_lights_set_t top_lights_set;
bt_io_popn_side_lights_set_t side_lights_set;
bt_io_popn_button_lights_set_t button_lights_set;
bt_io_popn_coin_blocker_light_set_t coin_blocker_light_set;
bt_io_popn_coin_counter_light_set_t coin_counter_light_set;
} v1;
} bt_io_popn_api_t;
#endif
+70
View File
@@ -0,0 +1,70 @@
#ifndef BT_API_IO_SDVX_H
#define BT_API_IO_SDVX_H
/* IO emulation provider for SOUND VOLTEX */
#include <stdbool.h>
#include <stdint.h>
typedef enum bt_io_sdvx_in_gpio_sys_bit {
BT_IO_SDVX_IN_GPIO_SYS_COIN = 2,
BT_IO_SDVX_IN_GPIO_SYS_SERVICE = 4,
BT_IO_SDVX_IN_GPIO_SYS_TEST = 5,
} bt_io_sdvx_in_gpio_sys_bit_t;
typedef enum bt_io_sdvx_in_gpio_0_bit {
BT_IO_SDVX_IN_GPIO_0_C = 0,
BT_IO_SDVX_IN_GPIO_0_B = 1,
BT_IO_SDVX_IN_GPIO_0_A = 2,
BT_IO_SDVX_IN_GPIO_0_START = 3,
BT_IO_SDVX_IN_GPIO_0_RECORDER = 4,
BT_IO_SDVX_IN_GPIO_0_HEADPHONE = 5,
} bt_io_sdvx_in_gpio_0_bit_t;
typedef enum bt_io_sdvx_in_gpio_1_bit {
BT_IO_SDVX_IN_GPIO_1_FX_R = 3,
BT_IO_SDVX_IN_GPIO_1_FX_L = 4,
BT_IO_SDVX_IN_GPIO_1_D = 5,
} bt_io_sdvx_in_gpio_1_bit_t;
typedef enum bt_io_sdvx_out_gpio_bit {
BT_IO_SDVX_OUT_GPIO_D = 0,
BT_IO_SDVX_OUT_GPIO_FX_L = 1,
BT_IO_SDVX_OUT_GPIO_FX_R = 2,
BT_IO_SDVX_OUT_GPIO_GENERATOR_B = 3,
BT_IO_SDVX_OUT_GPIO_START = 12,
BT_IO_SDVX_OUT_GPIO_A = 13,
BT_IO_SDVX_OUT_GPIO_B = 14,
BT_IO_SDVX_OUT_GPIO_C = 15,
} bt_io_sdvx_out_gpio_bit_t;
typedef bool (*bt_io_sdvx_init_t)();
typedef void (*bt_io_sdvx_fini_t)();
typedef void (*bt_io_sdvx_gpio_lights_set_t)(uint32_t gpio_lights);
typedef void (*bt_io_sdvx_pwm_light_set_t)(uint8_t light_no, uint8_t intensity);
typedef bool (*bt_io_sdvx_output_write_t)();
typedef bool (*bt_io_sdvx_input_read_t)();
typedef uint8_t (*bt_io_sdvx_input_gpio_sys_get_t)();
typedef uint16_t (*bt_io_sdvx_input_gpio_get_t)(uint8_t gpio_bank);
typedef uint16_t (*bt_io_sdvx_spinner_pos_get_t)(uint8_t spinner_no);
typedef bool (*bt_io_sdvx_amp_volume_set_t)(uint8_t primary, uint8_t headphone, uint8_t subwoofer);
typedef struct bt_io_sdvx_api {
uint16_t version;
struct {
// Required to be implemented
bt_io_sdvx_init_t init;
bt_io_sdvx_fini_t fini;
bt_io_sdvx_gpio_lights_set_t gpio_lights_set;
bt_io_sdvx_pwm_light_set_t pwm_light_set;
bt_io_sdvx_output_write_t output_write;
bt_io_sdvx_input_read_t input_read;
bt_io_sdvx_input_gpio_sys_get_t input_gpio_sys_get;
bt_io_sdvx_input_gpio_get_t input_gpio_get;
bt_io_sdvx_spinner_pos_get_t spinner_pos_get;
bt_io_sdvx_amp_volume_set_t amp_volume_set;
} v1;
} bt_io_sdvx_api_t;
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef BT_API_IO_VEFX_H
#define BT_API_IO_VEFX_H
/* IO emulation provider for beatmania IIDX Effector Panel. */
#include <stdbool.h>
#include <stdint.h>
typedef bool (*bt_io_vefx_init_t)();
typedef void (*bt_io_vefx_fini_t)();
typedef bool (*bt_io_vefx_recv_t)(uint64_t *ppad);
typedef uint8_t (*bt_io_vefx_slider_get_t)(uint8_t slider_no);
typedef bool (*bt_io_vefx_16seg_send_t)(const char *text);
typedef struct bt_io_vefx_api {
uint16_t version;
struct {
// Required to be implemented
bt_io_vefx_init_t init;
bt_io_vefx_fini_t fini;
bt_io_vefx_recv_t recv;
bt_io_vefx_slider_get_t slider_get;
bt_io_vefx_16seg_send_t _16seg_send;
} v1;
} bt_io_vefx_api_t;
#endif
-31
View File
@@ -1,31 +0,0 @@
#ifndef BEMANITOOLS_API_THREAD_H
#define BEMANITOOLS_API_THREAD_H
#include <stdint.h>
#ifdef __GNUC__
/* Bemanitools is compiled with GCC (MinGW, specifically) as of version 5 */
#define LOG_CHECK_FMT __attribute__((format(printf, 2, 3)))
#else
/* Compile it out for MSVC plebs */
#define LOG_CHECK_FMT
#endif
/* An AVS-style logger function. Comes in four flavors: misc, info, warning,
and fatal, with increasing severity. Fatal loggers do not return, they
abort the running process after writing their message to the log.
"module" is an arbitrary short string identifying the source of the log
message. The name of the calling DLL is a good default choice for this
string, although you might want to identify a module within your DLL here
instead.
"fmt" is a printf-style format string. Depending on the context in which
your DLL is running you might end up calling a logger function exported
from libavs, which has its own printf implementation (including a number of
proprietary extensions), so don't use any overly exotic formats. */
typedef void (*btapi_log_formatter_t)(const char *module, const char *fmt, ...)
LOG_CHECK_FMT;
#endif
-20
View File
@@ -1,20 +0,0 @@
#ifndef BEMANITOOLS_API_THREAD_H
#define BEMANITOOLS_API_THREAD_H
#include <stdint.h>
/* An API for spawning threads. This API is defined by libavs, although
Bemanitools itself may supply compatible implementations of these functions
to your DLL, depending on the context in which it runs.
NOTE: You may only use the logging functions from a thread where Bemanitools
calls you, or a thread that you create using this API. Failure to observe
this restriction will cause the process to crash. This is a limitation of
libavs itself, not Bemanitools. */
typedef int (*btapi_thread_create_t)(
int (*proc)(void *), void *ctx, uint32_t stack_sz, unsigned int priority);
typedef void (*btapi_thread_join_t)(int thread_id, int *result);
typedef void (*btapi_thread_destroy_t)(int thread_id);
#endif