jubeat: support p3io games

This commit is contained in:
Will Toohey
2021-12-31 20:23:31 +10:00
parent 8ab92872ad
commit 1105a2a130
68 changed files with 1633 additions and 918 deletions
+25
View File
@@ -0,0 +1,25 @@
avsdlls += jbhook3
deplibs_jbhook3 := \
avs \
ldflags_jbhook3 := \
-lws2_32 \
-liphlpapi \
libs_jbhook3 := \
acioemu \
eamio \
jbio \
jbhook-util \
p3ioemu \
p3io \
p4ioemu \
hook \
hooklib \
security \
util \
src_jbhook3 := \
dllmain.c \
options.c
+151
View File
@@ -0,0 +1,151 @@
#include <windows.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "bemanitools/eamio.h"
#include "bemanitools/jbio.h"
#include "hook/iohook.h"
#include "hooklib/adapter.h"
#include "hooklib/app.h"
#include "hooklib/rs232.h"
#include "hooklib/setupapi.h"
#include "imports/avs.h"
#include "jbhook3/options.h"
#include "jbhook-util/acio.h"
#include "jbhook-util/eamuse.h"
#include "jbhook-util/gfx.h"
#include "jbhook-util/p4io.h"
#include "jbhook-util/security.h"
#include "p4ioemu/device.h"
#include "p4ioemu/setupapi.h"
#include "security/id.h"
#include "util/defs.h"
#include "util/log.h"
#include "util/thread.h"
static struct options options;
static bool my_dll_entry_init(char *sidcode, struct property_node *param)
{
bool eam_io_ok;
bool jb_io_ok;
eam_io_ok = false;
jb_io_ok = false;
log_info("--- Begin jbhook dll_entry_init ---");
iohook_push_handler(p4ioemu_dispatch_irp);
iohook_push_handler(jbhook_util_ac_io_port_dispatch_irp);
if (!options.disable_p4ioemu) {
log_info("Starting up jubeat IO backend");
jb_io_set_loggers(
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
jb_io_ok =
jb_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
if (!jb_io_ok) {
goto fail;
}
hook_setupapi_init(&p4ioemu_setupapi_data);
p4ioemu_init(jbhook_p4io_init());
}
if (!options.disable_cardemu) {
log_info("Starting up card reader backend");
eam_io_set_loggers(
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
eam_io_ok =
eam_io_init(avs_thread_create, avs_thread_join, avs_thread_destroy);
if (!eam_io_ok) {
goto fail;
}
rs232_hook_init();
jbhook_util_ac_io_port_init(L"COM2");
jbhook_util_ac_io_set_iccb();
}
log_info("--- End jbhook dll_entry_init ---");
bool ret = app_hook_invoke_init(sidcode, param);
return ret;
fail:
if (eam_io_ok) {
eam_io_fini();
}
if (jb_io_ok) {
jb_io_fini();
}
return false;
}
static bool my_dll_entry_main(void)
{
bool result;
result = app_hook_invoke_main();
log_info("Shutting down card reader backend");
eam_io_fini();
log_info("Shutting down Jubeat IO backend");
jb_io_fini();
if (!options.disable_cardemu) {
jbhook_util_ac_io_port_fini();
}
if (!options.disable_p4ioemu) {
p4ioemu_fini();
}
options_fini(&options);
return result;
}
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
if (reason != DLL_PROCESS_ATTACH) {
return TRUE;
}
log_to_external(
log_body_misc, log_body_info, log_body_warning, log_body_fatal);
options_init_from_cmdline(&options);
app_hook_init(my_dll_entry_init, my_dll_entry_main);
if (!options.disable_adapteremu) {
adapter_hook_init();
}
jbhook_util_gfx_hook_init();
jbhook_util_eamuse_hook_init();
return TRUE;
}
+4
View File
@@ -0,0 +1,4 @@
LIBRARY jbhook3
EXPORTS
DllMain@12 @1 NONAME
+109
View File
@@ -0,0 +1,109 @@
#include "jbhook3/options.h"
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "util/cmdline.h"
#include "util/defs.h"
#include "util/hex.h"
#include "util/log.h"
#include "util/str.h"
void options_init_from_cmdline(struct options *options)
{
int argc;
char **argv;
bool ok;
args_recover(&argc, &argv);
options_init(options);
ok = options_read_cmdline(options, argc, (const char **) argv);
args_free(argc, argv);
if (!ok) {
exit(0);
}
}
void options_init(struct options *options)
{
options->windowed = false;
options->window_framed = false;
options->disable_p4ioemu = false;
options->disable_cardemu = false;
options->disable_adapteremu = false;
}
bool options_read_cmdline(struct options *options, int argc, const char **argv)
{
int i;
for (i = 0; i < argc; i++) {
if (argv[i][0] != '-') {
continue;
}
switch (argv[i][1]) {
case 'h': {
options_print_usage();
return false;
}
case 'w': {
options->windowed = true;
break;
}
case 'f': {
options->window_framed = true;
break;
}
case 'a': {
options->disable_adapteremu = true;
break;
}
case 'c': {
options->disable_cardemu = true;
break;
}
case 'p': {
options->disable_p4ioemu = true;
break;
}
}
}
return true;
}
void options_print_usage(void)
{
OutputDebugStringA("jbhook for jubeat, build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(
GITREV) "\n"
"Usage: launcher.exe -K jbhook3.dll [game exec] <options> \n"
"\n"
" The following options can be specified after the game exec path:\n"
"\n"
" -h Print this usage message\n"
" -w Run the game windowed\n"
" -f Run the game in a framed window (needs -w option)\n"
" -a Disable adapter hook\n"
" -c Disable card emulation (e.g. when running on a "
"real cab)\n"
" -p Disable p4io emulation (e.g. when running on a "
"real cab or on a bare "
"p4io)\n");
}
void options_fini(struct options *options)
{
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef JBHOOK_OPTIONS_H
#define JBHOOK_OPTIONS_H
#include <stdbool.h>
#include <stdint.h>
struct options {
bool windowed;
bool window_framed;
bool disable_p4ioemu;
bool disable_cardemu;
bool disable_adapteremu;
};
void options_init_from_cmdline(struct options *options);
void options_init(struct options *options);
bool options_read_cmdline(struct options *options, int argc, const char **argv);
void options_print_usage(void);
void options_fini(struct options *options);
#endif