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

feat(iidx/ezusb): Make iidx ezusb emu io board type configurable

Second part to fixing the 10th style SQ-INIT error. This has
cross-impact on the kind of security data the game expects.
Therefore, we need to expose the IO board type and make it
configurable like the security data for the different game
versions.

More details explained in a dev journal entry to following
in one of the next commits.
This commit is contained in:
icex2 2023-04-03 01:09:44 +02:00 committed by icex2
parent eab80455b2
commit aaab9bfbfc
2 changed files with 40 additions and 6 deletions

View File

@ -65,6 +65,7 @@ static const struct ezusb_iidx_emu_node *ezusb_iidx_emu_msg_v2_nodes[256] = {
[EZUSB_IIDX_MSG_NODE_WDT] = &ezusb_iidx_emu_node_wdt,
};
static enum ezusb_iidx_emu_msg_io_board_type ezusb_iidx_emu_msg_io_board_type;
static const struct ezusb_iidx_emu_node **ezusb_iidx_emu_node_handler;
static uint8_t ezusb_iidx_emu_msg_status = 0;
static uint8_t ezusb_iidx_emu_msg_seq_no = 0;
@ -72,8 +73,16 @@ static uint8_t ezusb_iidx_emu_msg_read_cur_node = 0;
/* ------------------------------------------------------------------------ */
struct ezusb_emu_msg_hook *ezusb_iidx_emu_msg_init(void)
struct ezusb_emu_msg_hook *ezusb_iidx_emu_msg_init(
enum ezusb_iidx_emu_msg_io_board_type io_board_type)
{
if (io_board_type < 0 ||
io_board_type >= EZUSB_IIDX_EMU_MSG_IO_BOARD_TYPE_COUNT) {
log_fatal("Invalid io board type %d specified", io_board_type);
}
ezusb_iidx_emu_msg_io_board_type = io_board_type;
/* Init all nodes */
for (uint32_t i = 0; i < 256; i++) {
/* "Constructor" optional */
@ -85,6 +94,9 @@ struct ezusb_emu_msg_hook *ezusb_iidx_emu_msg_init(void)
ezusb_iidx_emu_node_handler = ezusb_iidx_emu_msg_nodes;
log_info("Initialized, io board type: %d",
ezusb_iidx_emu_msg_io_board_type);
return &ezusb_iidx_emu_msg_hook;
}
@ -163,9 +175,21 @@ static HRESULT ezusb_iidx_emu_msg_interrupt_read(struct iobuf *read)
otherwise the game's fpga check will fail */
msg_resp->fpga2_check_flag_unkn = 2;
#ifdef EZUSB_IIDX_EMU_D01_BOARD
msg_resp->inverted_pad &= ~(1 << 4);
#endif
switch (ezusb_iidx_emu_msg_io_board_type) {
case EZUSB_IIDX_EMU_MSG_IO_BOARD_TYPE_C02:
// noop
break;
case EZUSB_IIDX_EMU_MSG_IO_BOARD_TYPE_D01:
msg_resp->inverted_pad &= ~(1 << 4);
break;
case EZUSB_IIDX_EMU_MSG_IO_BOARD_TYPE_COUNT:
default:
log_fatal("Illegal state, unhandled board type: %d",
ezusb_iidx_emu_msg_io_board_type);
break;
}
read->pos = sizeof(*msg_resp);

View File

@ -8,16 +8,26 @@
#include "ezusb-emu/msg.h"
enum ezusb_iidx_emu_msg_io_board_type {
EZUSB_IIDX_EMU_MSG_IO_BOARD_TYPE_C02 = 0,
EZUSB_IIDX_EMU_MSG_IO_BOARD_TYPE_D01 = 1,
EZUSB_IIDX_EMU_MSG_IO_BOARD_TYPE_COUNT = 2,
};
/**
* Init the fully emulated IIDX msg backend for a EZUSB (C02) board. This
* Init the fully emulated IIDX msg backend for a EZUSB board. This
* activates the "old" V1 node handling backend which was used on iidx 09 to 13.
* On iidx14, the firmware was updated and removed nodes that were not used
* anymore, e.g. serial card reader handling.
*
* @param io_board_type Type of IO board to emulate. Note that this impacts the
* security data which is different on some game versions, e.g. 10th
* style.
* @return ezusb_emu_msg_hook structure with hook calls for ezusb msg
* dispatching
*/
struct ezusb_emu_msg_hook *ezusb_iidx_emu_msg_init(void);
struct ezusb_emu_msg_hook *ezusb_iidx_emu_msg_init(
enum ezusb_iidx_emu_msg_io_board_type io_board_type);
/**
* Init the fully emulated IIDX msg backend for a EZUSB (C02) board. This