mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2026-04-26 07:48:14 -05:00
Add jbio-magicbox.dll
This commit is contained in:
parent
8c3030354a
commit
e4081c057f
|
|
@ -256,7 +256,7 @@ impdef_$1_$2_$3 ?= src/imports/import_$1_$2_$3.def
|
||||||
|
|
||||||
$$(bindir_$1_$2)/lib$3.a: $$(impdef_$1_$2_$3) | $$(bindir_$1_$2)
|
$$(bindir_$1_$2)/lib$3.a: $$(impdef_$1_$2_$3) | $$(bindir_$1_$2)
|
||||||
$(V)echo ... $$@ [dlltool]
|
$(V)echo ... $$@ [dlltool]
|
||||||
$(V)$$(toolchain_$1)dlltool -l $$@ -d $$<
|
$(V)$$(toolchain_$1)dlltool --kill-at -l $$@ -d $$<
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ include src/main/iidxio-ezusb2/Module.mk
|
||||||
include src/main/iidxiotest/Module.mk
|
include src/main/iidxiotest/Module.mk
|
||||||
include src/main/inject/Module.mk
|
include src/main/inject/Module.mk
|
||||||
include src/main/jbio/Module.mk
|
include src/main/jbio/Module.mk
|
||||||
|
include src/main/jbio-magicbox/Module.mk
|
||||||
include src/main/jbiotest/Module.mk
|
include src/main/jbiotest/Module.mk
|
||||||
include src/main/jbhook/Module.mk
|
include src/main/jbhook/Module.mk
|
||||||
include src/main/jbhook1/Module.mk
|
include src/main/jbhook1/Module.mk
|
||||||
|
|
|
||||||
11
doc/jbhook/jbio-magicbox.md
Normal file
11
doc/jbhook/jbio-magicbox.md
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
This library talks to a MagicBox cab's IO and implements the jbio API of BT5.
|
||||||
|
Thus, it allows you to use a MagicBox cab with *any* version of jubeat that is supported by BT5.
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
* Rename jbio-magicbox.dll to jbio.dll.
|
||||||
|
* Ensure that your gamestart.bat actually injects the appropriate jbhook dll
|
||||||
|
for example:
|
||||||
|
```
|
||||||
|
launcher -K jbhook.dll jubeat.dll ...*
|
||||||
|
```
|
||||||
|
or that the application otherwise uses jbio.dll
|
||||||
12
src/imports/ch341.h
Normal file
12
src/imports/ch341.h
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef IMPORTS_CH341_H
|
||||||
|
#define IMPORTS_CH341_H
|
||||||
|
|
||||||
|
// The bare minimum definitions to implement jbio-magicbox
|
||||||
|
// There is a full .h for this DLL floating around online, if you care
|
||||||
|
|
||||||
|
HANDLE WINAPI CH341OpenDevice(ULONG iIndex);
|
||||||
|
VOID WINAPI CH341CloseDevice(ULONG iIndex);
|
||||||
|
BOOL WINAPI CH341EppReadData(ULONG iIndex, PVOID oBuffer, PULONG ioLength);
|
||||||
|
BOOL WINAPI CH341EppSetAddr(ULONG iIndex, UCHAR iAddr);
|
||||||
|
|
||||||
|
#endif
|
||||||
7
src/imports/import_32_indep_ch341.def
Normal file
7
src/imports/import_32_indep_ch341.def
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
LIBRARY ch341dll
|
||||||
|
|
||||||
|
EXPORTS
|
||||||
|
CH341OpenDevice@4=CH341OpenDevice
|
||||||
|
CH341CloseDevice@4=CH341CloseDevice
|
||||||
|
CH341EppReadData@12=CH341EppReadData
|
||||||
|
CH341EppSetAddr@8=CH341EppSetAddr
|
||||||
11
src/main/jbio-magicbox/Module.mk
Normal file
11
src/main/jbio-magicbox/Module.mk
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
dlls += jbio-magicbox
|
||||||
|
imps += ch341
|
||||||
|
|
||||||
|
deplibs_jbio-magicbox := \
|
||||||
|
ch341 \
|
||||||
|
|
||||||
|
src_jbio-magicbox := \
|
||||||
|
jbio.c \
|
||||||
|
|
||||||
|
libs_jbio-magicbox := \
|
||||||
|
util \
|
||||||
11
src/main/jbio-magicbox/jbio-magicbox.def
Normal file
11
src/main/jbio-magicbox/jbio-magicbox.def
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
LIBRARY jbio
|
||||||
|
|
||||||
|
EXPORTS
|
||||||
|
jb_io_fini
|
||||||
|
jb_io_get_panel_inputs
|
||||||
|
jb_io_get_sys_inputs
|
||||||
|
jb_io_init
|
||||||
|
jb_io_read_inputs
|
||||||
|
jb_io_set_loggers
|
||||||
|
jb_io_set_rgb_led
|
||||||
|
jb_io_write_outputs
|
||||||
139
src/main/jbio-magicbox/jbio.c
Normal file
139
src/main/jbio-magicbox/jbio.c
Normal file
|
|
@ -0,0 +1,139 @@
|
||||||
|
// This implementation is ported from the device.dll source graciously
|
||||||
|
// provided by zyp
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "bemanitools/jbio.h"
|
||||||
|
#include "imports/ch341.h"
|
||||||
|
#include "util/defs.h"
|
||||||
|
|
||||||
|
static uint16_t jb_io_panels;
|
||||||
|
static uint8_t jb_io_sys_buttons;
|
||||||
|
|
||||||
|
static bool is_initialized = false;
|
||||||
|
|
||||||
|
log_formatter_t jb_io_log_misc;
|
||||||
|
log_formatter_t jb_io_log_info;
|
||||||
|
log_formatter_t jb_io_log_warning;
|
||||||
|
log_formatter_t jb_io_log_fatal;
|
||||||
|
|
||||||
|
void jb_io_set_loggers(
|
||||||
|
log_formatter_t misc,
|
||||||
|
log_formatter_t info,
|
||||||
|
log_formatter_t warning,
|
||||||
|
log_formatter_t fatal)
|
||||||
|
{
|
||||||
|
jb_io_log_misc = misc;
|
||||||
|
jb_io_log_info = info;
|
||||||
|
jb_io_log_warning = warning;
|
||||||
|
jb_io_log_fatal = fatal;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool jb_io_init(
|
||||||
|
thread_create_t thread_create,
|
||||||
|
thread_join_t thread_join,
|
||||||
|
thread_destroy_t thread_destroy)
|
||||||
|
{
|
||||||
|
if(CH341OpenDevice(0) < 0) {
|
||||||
|
jb_io_log_warning("jbio", "Can't open CH341 device.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
is_initialized = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void jb_io_fini(void)
|
||||||
|
{
|
||||||
|
CH341CloseDevice(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const uint32_t magic_panel_mappings[] = {
|
||||||
|
(1 << 0x08),
|
||||||
|
(1 << 0x0a),
|
||||||
|
(1 << 0x0c),
|
||||||
|
(1 << 0x0e),
|
||||||
|
(1 << 0x07),
|
||||||
|
(1 << 0x05),
|
||||||
|
(1 << 0x03),
|
||||||
|
(1 << 0x01),
|
||||||
|
(1 << 0x09),
|
||||||
|
(1 << 0x0b),
|
||||||
|
(1 << 0x0d),
|
||||||
|
(1 << 0x0f),
|
||||||
|
(1 << 0x06),
|
||||||
|
(1 << 0x04),
|
||||||
|
(1 << 0x02),
|
||||||
|
(1 << 0x00),
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint32_t magic_sys_mappings[] = {
|
||||||
|
(1 << 0x11), // TEST
|
||||||
|
(1 << 0x10), // SERVICE
|
||||||
|
(1 << 0x13), // COIN
|
||||||
|
};
|
||||||
|
|
||||||
|
bool jb_io_read_inputs(void)
|
||||||
|
{
|
||||||
|
// Read IO board
|
||||||
|
unsigned long n;
|
||||||
|
union {
|
||||||
|
uint32_t dword;
|
||||||
|
uint8_t bytes[4];
|
||||||
|
} input;
|
||||||
|
|
||||||
|
input.dword = -1;
|
||||||
|
jb_io_panels = 0;
|
||||||
|
jb_io_sys_buttons = 0;
|
||||||
|
|
||||||
|
CH341EppSetAddr(0, 255);
|
||||||
|
CH341EppSetAddr(0, 1);
|
||||||
|
CH341EppSetAddr(0, 255);
|
||||||
|
CH341EppSetAddr(0, 0);
|
||||||
|
n = 1;
|
||||||
|
CH341EppReadData(0, &input.bytes[0], &n);
|
||||||
|
CH341EppSetAddr(0, 255);
|
||||||
|
CH341EppSetAddr(0, 0);
|
||||||
|
n = 1;
|
||||||
|
CH341EppReadData(0, &input.bytes[1], &n);
|
||||||
|
CH341EppSetAddr(0, 255);
|
||||||
|
CH341EppSetAddr(0, 0);
|
||||||
|
n = 1;
|
||||||
|
CH341EppReadData(0, &input.bytes[2], &n);
|
||||||
|
CH341EppSetAddr(0, 255);
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < lengthof(magic_panel_mappings); i++) {
|
||||||
|
if((input.dword & magic_panel_mappings[i]) == 0) {
|
||||||
|
jb_io_panels |= 1 << i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0; i < lengthof(magic_sys_mappings); i++) {
|
||||||
|
if((input.dword & magic_sys_mappings[i]) == 0) {
|
||||||
|
jb_io_sys_buttons |= 1 << i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool jb_io_write_outputs(void)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t jb_io_get_sys_inputs(void)
|
||||||
|
{
|
||||||
|
return jb_io_sys_buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t jb_io_get_panel_inputs(void)
|
||||||
|
{
|
||||||
|
return jb_io_panels;
|
||||||
|
}
|
||||||
|
|
||||||
|
void jb_io_set_rgb_led(enum jb_io_rgb_led unit, uint8_t r, uint8_t g, uint8_t b)
|
||||||
|
{
|
||||||
|
// I mean I guess there's reactive LEDs on the sides? I'm not going to the
|
||||||
|
// effort to work out if they're controllable or not
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user