1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2024-11-24 14:50:10 +01:00

bio2emu: refactor BIO2 emulation

This commit is contained in:
Will Xyen 2020-08-02 23:02:13 -07:00 committed by adfe3beeadc615e0fa48b493761cc42aae47d399
parent bbb5157460
commit bfbb7103ef
12 changed files with 122 additions and 100 deletions

View File

@ -79,6 +79,7 @@ include src/main/acioemu/Module.mk
include src/main/aciotest/Module.mk
include src/main/asio/Module.mk
include src/main/bio2emu/Module.mk
include src/main/bio2emu-iidx/Module.mk
include src/main/bsthook/Module.mk
include src/main/bstio/Module.mk
include src/main/camhook/Module.mk

View File

@ -1,6 +1,8 @@
#ifndef AC_IO_KFCA_H
#define AC_IO_KFCA_H
#include <stdint.h>
#define AC_IO_CMD_KFCA_POLL 0x0113
#define AC_IO_CMD_KFCA_WATCHDOG 0x0120
#define AC_IO_CMD_KFCA_AMP_CONTROL 0x0128

View File

@ -1,18 +1,7 @@
#ifndef IIDXHOOK_BI2A_H
#define IIDXHOOK_BI2A_H
#ifndef BIO2_BI2A_IIDX
#define BIO2_BI2A_IIDX
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "bio2emu/emu.h"
enum bio2_iidx_cmd {
// Custom Stuff
BIO2_BI2A_CMD_UNK_0100 = 0x0100,
BIO2_BI2A_CMD_UNK_0120 = 0x0120,
BIO2_BI2A_CMD_POLL = 0x0152,
};
#include "bio2/bio2.h"
#pragma pack(push, 1)
struct bi2a_iidx_slider {
@ -114,8 +103,4 @@ _Static_assert(
"bi2a_iidx_state_out is the wrong size");
#pragma pack(pop)
void bio2_emu_bi2a_init(struct bio2emu_port *in, bool disable_poll_limiter);
void bio2_emu_bi2a_dispatch_request(
struct bio2emu_port *bio2port, const struct ac_io_message *req);
#endif

75
src/main/bio2/bi2a-sdvx.h Normal file
View File

@ -0,0 +1,75 @@
#ifndef BIO2_BI2A_SDVX
#define BIO2_BI2A_SDVX
#include "bio2/bio2.h"
#pragma pack(push, 1)
struct bi2a_sdvx_analog {
uint16_t unk1 : 1;
uint16_t a_coin : 1;
uint16_t a_service : 1;
uint16_t a_test : 1;
uint16_t unk2 : 2;
uint16_t a_val : 10;
};
struct bi2a_sdvx_buttons1 {
uint8_t b_fxl : 1;
uint8_t b_d : 1;
uint8_t b_c : 1;
uint8_t b_b : 1;
uint8_t b_a : 1;
uint8_t b_start : 1;
uint8_t b_recorder : 1;
uint8_t b_headphone : 1;
};
struct bi2a_sdvx_buttons2 {
uint8_t unk : 5;
uint8_t b_ex2 : 1;
uint8_t b_ex1 : 1;
uint8_t b_fxr : 1;
};
struct bio2_bi2a_state {
union {
uint16_t raw[8];
struct {
struct bi2a_sdvx_analog analogs[4];
uint8_t unk_1; // coin mech?
struct bi2a_sdvx_buttons1 buttons_1;
struct bi2a_sdvx_buttons2 buttons_2;
uint8_t unk_2[5];
};
};
};
struct bio2_bi2a_state_out {
uint8_t unk1[2];
uint8_t c_block;
uint8_t woof_r;
uint8_t woof_g;
uint8_t unk2;
uint8_t woof_b;
uint8_t controller[3];
uint8_t unk3;
uint8_t gpio[7]; // START, ABCD, FXL, FXR
uint8_t unk4[3];
uint8_t generator[3];
uint8_t unk5[3];
uint8_t gpio2[3]; // pop, titleL, titleR
uint8_t unk6;
uint8_t wingUpper[3];
uint8_t wingLower[3];
uint8_t unk7[3];
};
_Static_assert(
sizeof(struct bio2_bi2a_state) == 16,
"bio2_bi2a_state_in is the wrong size");
_Static_assert(
sizeof(struct bio2_bi2a_state_out) == 40,
"bio2_bi2a_state_out is the wrong size");
#pragma pack(pop)
#endif

15
src/main/bio2/bio2.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef BIO2_BIO2
#define BIO2_BIO2
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
enum bio2_bi2a_cmd {
// Custom Stuff
BIO2_BI2A_CMD_UNK_0100 = 0x0100,
BIO2_BI2A_CMD_UNK_0120 = 0x0120,
BIO2_BI2A_CMD_POLL = 0x0152, // For IIDX
};
#endif

View File

@ -0,0 +1,7 @@
libs += bio2emu-iidx
libs_bio2emu-iidx := \
bio2emu \
src_bio2emu-iidx := \
bi2a.c \

View File

@ -1,7 +1,6 @@
#define LOG_MODULE "bio2emu-bi2a"
#define LOG_MODULE "bio2emu-iidx"
#include "iidxhook8/bi2a.h"
#include "bio2emu/emu.h"
#include "bio2emu-iidx/bi2a.h"
#include <windows.h> /* for _BitScanForward */

View File

@ -0,0 +1,12 @@
#ifndef BIO2EMU_IIDX_BI2A_H
#define BIO2EMU_IIDX_BI2A_H
#include "bio2/bi2a-iidx.h"
#include "bio2emu/emu.h"
void bio2_emu_bi2a_init(struct bio2emu_port *in, bool disable_poll_limiter);
void bio2_emu_bi2a_dispatch_request(
struct bio2emu_port *bio2port, const struct ac_io_message *req);
#endif

View File

@ -350,8 +350,8 @@ static CONFIGRET my_CM_Get_Device_IDA(
log_info("%s: Injecting custom parent ID for BIO2", __FUNCTION__);
strcpy(Buffer, devpath);
Buffer[devpathsize - 1] =
'\0' + (dnDevInst & CUSTOM_DEVICE_INSTANCE_IDXMASK);
Buffer[devpathsize - 2] =
'0' + (dnDevInst & CUSTOM_DEVICE_INSTANCE_IDXMASK);
log_info("%s: %s", __FUNCTION__, Buffer);
return CR_SUCCESS;
}

View File

@ -15,6 +15,7 @@ libs_iidxhook8 := \
iidxhook-util \
acioemu \
bio2emu \
bio2emu-iidx \
camhook \
iidxio \
hook \
@ -24,6 +25,5 @@ libs_iidxhook8 := \
eamio \
src_iidxhook8 := \
bi2a.c \
config-io.c \
dllmain.c \

View File

@ -24,7 +24,7 @@
#include "iidxhook-util/log-server.h"
#include "bio2emu/emu.h"
#include "iidxhook8/bi2a.h"
#include "bio2emu-iidx/bi2a.h"
#include "camhook/cam.h"
#include "camhook/config-cam.h"

View File

@ -6,82 +6,8 @@
#include <stdint.h>
#include "bio2emu/emu.h"
#include "bio2/bi2a-sdvx.h"
enum bio2_bi2a_cmd {
// Custom Stuff
BIO2_BI2A_CMD_UNK_0100 = 0x0100,
BIO2_BI2A_CMD_UNK_0120 = 0x0120,
BIO2_BI2A_CMD_POLL = 0x0152,
};
#pragma pack(push, 1)
struct bi2a_sdvx_analog {
uint16_t unk1 : 1;
uint16_t a_coin : 1;
uint16_t a_service : 1;
uint16_t a_test : 1;
uint16_t unk2 : 2;
uint16_t a_val : 10;
};
struct bi2a_sdvx_buttons1 {
uint8_t b_fxl : 1;
uint8_t b_d : 1;
uint8_t b_c : 1;
uint8_t b_b : 1;
uint8_t b_a : 1;
uint8_t b_start : 1;
uint8_t b_recorder : 1;
uint8_t b_headphone : 1;
};
struct bi2a_sdvx_buttons2 {
uint8_t unk : 5;
uint8_t b_ex2 : 1;
uint8_t b_ex1 : 1;
uint8_t b_fxr : 1;
};
struct bio2_bi2a_state {
union {
uint16_t raw[8];
struct {
struct bi2a_sdvx_analog analogs[4];
uint8_t unk_1; // coin mech?
struct bi2a_sdvx_buttons1 buttons_1;
struct bi2a_sdvx_buttons2 buttons_2;
uint8_t unk_2[5];
};
};
};
struct bio2_bi2a_state_out {
uint8_t unk1[2];
uint8_t c_block;
uint8_t woof_r;
uint8_t woof_g;
uint8_t unk2;
uint8_t woof_b;
uint8_t controller[3];
uint8_t unk3;
uint8_t gpio[7]; // START, ABCD, FXL, FXR
uint8_t unk4[3];
uint8_t generator[3];
uint8_t unk5[3];
uint8_t gpio2[3]; // pop, titleL, titleR
uint8_t unk6;
uint8_t wingUpper[3];
uint8_t wingLower[3];
uint8_t unk7[3];
};
_Static_assert(
sizeof(struct bio2_bi2a_state) == 16,
"bio2_bi2a_state_in is the wrong size");
_Static_assert(
sizeof(struct bio2_bi2a_state_out) == 40,
"bio2_bi2a_state_out is the wrong size");
#pragma pack(pop)
void bio2_emu_bi2a_init(struct bio2emu_port *in, bool disable_poll_limiter, bool force_headphones);
void bio2_emu_bi2a_dispatch_request(