From 1964fa766f261f2a867953d8a5e5a0ad603269d3 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Thu, 10 Feb 2022 12:17:10 -0500 Subject: [PATCH] Added d3d11 hook, better touch naming --- Dockerfile | 1 + dist/mercury/segatools.ini | 2 ++ dist/mercury/start.bat | 13 +++++++++---- gfxhook/dxgi.c | 2 +- gfxhook/util.c | 2 +- mercuryhook/config.c | 2 ++ mercuryhook/config.h | 2 ++ mercuryhook/dllmain.c | 6 ++++++ mercuryhook/meson.build | 1 + mercuryhook/touch.c | 16 ++++++++-------- mercuryhook/touch.h | 2 +- 11 files changed, 34 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6aa360d..279c6b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,7 @@ COPY mu3hook mu3hook COPY mu3io mu3io COPY pki pki COPY platform platform +COPY gfxhook gfxhook COPY reg reg COPY spike spike COPY subprojects subprojects diff --git a/dist/mercury/segatools.ini b/dist/mercury/segatools.ini index 009ce65..f71bfae 100644 --- a/dist/mercury/segatools.ini +++ b/dist/mercury/segatools.ini @@ -32,6 +32,8 @@ enable=1 ; that subnet must start with 192.168. subnet=192.168.250.0 +[gfx] +enable=1 [io4] ; Input API selection for JVS input emulator. diff --git a/dist/mercury/start.bat b/dist/mercury/start.bat index 887274f..c00f2ea 100644 --- a/dist/mercury/start.bat +++ b/dist/mercury/start.bat @@ -1,10 +1,15 @@ @echo off pushd %~dp0 + taskkill /f /im amdaemon.exe > nul 2>&1 -:LOOP + +REM USA +REM start inject -d -k mercuryhook.dll amdaemon.exe -f -c config.json config_lan_install_client.json config_lan_install_server.json config_video_clone.json config_video_dual.json config_video_clone_flip.json config_video_dual_flip.json config_region_exp.json config_region_chn.json config_region_usa.json + +REM JP start inject -d -k mercuryhook.dll amdaemon.exe -f -c config.json config_lan_install_client.json config_lan_install_server.json config_video_clone.json config_video_dual.json config_video_clone_flip.json config_video_dual_flip.json config_region_exp.json config_region_chn.json config_region_jpn.json inject -d -k mercuryhook.dll ../WindowsNoEditor/Mercury/Binaries/Win64/Mercury-Win64-Shipping.exe + taskkill /f /im amdaemon.exe > nul 2>&1 -echo. -echo Game processes have terminated -pause \ No newline at end of file + +echo Game processes have terminated \ No newline at end of file diff --git a/gfxhook/dxgi.c b/gfxhook/dxgi.c index e27e68d..14d3e5f 100644 --- a/gfxhook/dxgi.c +++ b/gfxhook/dxgi.c @@ -312,7 +312,7 @@ static HRESULT STDMETHODCALLTYPE my_IDXGIFactory_CreateSwapChain( ShowWindow(hwnd, SW_RESTORE); if (!gfx_config.framed && width > 0 && height > 0) { - dprintf("DXGI: Resizing window to %ldx%ld\n", width, height); + dprintf("DXGI: Resizing window to %ux%u\n", width, height); SetWindowLongPtrW(hwnd, GWL_STYLE, WS_POPUP); SetWindowLongPtrW(hwnd, GWL_EXSTYLE, WS_EX_TOPMOST); diff --git a/gfxhook/util.c b/gfxhook/util.c index 4da45b3..1ee552d 100644 --- a/gfxhook/util.c +++ b/gfxhook/util.c @@ -19,7 +19,7 @@ void gfx_util_borderless_fullscreen_windowed(HWND hwnd, UINT width, UINT height) BOOL ok; HRESULT hr; - dprintf("Gfx: Resizing window to %ldx%ld\n", width, height); + dprintf("Gfx: Resizing window to %ux%u\n", width, height); SetWindowLongPtrW(hwnd, GWL_STYLE, WS_POPUP); SetWindowLongPtrW(hwnd, GWL_EXSTYLE, WS_EX_TOPMOST); diff --git a/mercuryhook/config.c b/mercuryhook/config.c index a66efa0..f0dbb08 100644 --- a/mercuryhook/config.c +++ b/mercuryhook/config.c @@ -5,6 +5,7 @@ #include "hooklib/config.h" #include "hooklib/dvd.h" +#include "gfxhook/config.h" #include "mercuryhook/config.h" @@ -51,6 +52,7 @@ void mercury_hook_config_load( aime_config_load(&cfg->aime, filename); dvd_config_load(&cfg->dvd, filename); io4_config_load(&cfg->io4, filename); + gfx_config_load(&cfg->gfx, filename); mercury_dll_config_load(&cfg->dll, filename); touch_config_load(&cfg->touch, filename); } diff --git a/mercuryhook/config.h b/mercuryhook/config.h index bbfc4a4..cfeb490 100644 --- a/mercuryhook/config.h +++ b/mercuryhook/config.h @@ -5,6 +5,7 @@ #include "board/config.h" #include "hooklib/dvd.h" +#include "gfxhook/gfx.h" #include "mercuryhook/mercury-dll.h" #include "mercuryhook/touch.h" @@ -16,6 +17,7 @@ struct mercury_hook_config { struct aime_config aime; struct dvd_config dvd; struct io4_config io4; + struct gfx_config gfx; struct mercury_dll_config dll; struct touch_config touch; }; diff --git a/mercuryhook/dllmain.c b/mercuryhook/dllmain.c index 9da0b25..611122b 100644 --- a/mercuryhook/dllmain.c +++ b/mercuryhook/dllmain.c @@ -9,6 +9,9 @@ #include "hooklib/serial.h" #include "hooklib/spike.h" +#include "gfxhook/gfx.h" +#include "gfxhook/d3d11.h" + #include "mercuryhook/config.h" #include "mercuryhook/io4.h" #include "mercuryhook/mercury-dll.h" @@ -40,6 +43,9 @@ static DWORD CALLBACK mercury_pre_startup(void) dvd_hook_init(&mercury_hook_cfg.dvd, mercury_hook_mod); serial_hook_init(); + gfx_hook_init(&mercury_hook_cfg.gfx); + gfx_d3d11_hook_init(&mercury_hook_cfg.gfx, mercury_hook_mod); + /* Initialize emulation hooks */ hr = platform_hook_init( diff --git a/mercuryhook/meson.build b/mercuryhook/meson.build index ffa0f88..7a676b2 100644 --- a/mercuryhook/meson.build +++ b/mercuryhook/meson.build @@ -11,6 +11,7 @@ shared_library( ], link_with : [ aimeio_lib, + gfxhook_lib, board_lib, hooklib_lib, mercuryio_lib, diff --git a/mercuryhook/touch.c b/mercuryhook/touch.c index 2f86645..d8ada37 100644 --- a/mercuryhook/touch.c +++ b/mercuryhook/touch.c @@ -31,7 +31,7 @@ static HRESULT touch_frame_decode(struct touch_req *dest, struct iobuf *iobuf, i static uint8_t calc_checksum(const void *ptr, size_t nbytes); static HRESULT touch_handle_get_sync_board_ver(const struct touch_req *req); -static HRESULT touch_handle_startup(const struct touch_req *req); +static HRESULT touch_handle_next_read(const struct touch_req *req); static HRESULT touch_handle_get_unit_board_ver(const struct touch_req *req); static HRESULT touch_handle_mystery1(const struct touch_req *req); static HRESULT touch_handle_mystery2(const struct touch_req *req); @@ -204,8 +204,8 @@ static HRESULT touch_req_dispatch(const struct touch_req *req) switch (req->cmd) { case CMD_GET_SYNC_BOARD_VER: return touch_handle_get_sync_board_ver(req); - case CMD_STARTUP: - return touch_handle_startup(req); + case CMD_NEXT_READ: + return touch_handle_next_read(req); case CMD_GET_UNIT_BOARD_VER: return touch_handle_get_unit_board_ver(req); case CMD_MYSTERY1: @@ -252,13 +252,13 @@ static HRESULT touch_handle_get_sync_board_ver(const struct touch_req *req) } /* TODO: Very ugly please make better before upstreaming */ -static HRESULT touch_handle_startup(const struct touch_req *req) +static HRESULT touch_handle_next_read(const struct touch_req *req) { struct touch_resp_startup resp; HRESULT hr; uint8_t *rev; - dprintf("Wacca Touch%d: Startup %2hx\n", req->side, req->data[2]); + dprintf("Wacca Touch%d: Read section %2hx\n", req->side, req->data[2]); switch (req->data[2]) { @@ -290,7 +290,7 @@ static HRESULT touch_handle_startup(const struct touch_req *req) 0x20, 0x20, 0x20, 0x34 }; break; default: - dprintf("Wacca touch: BAD STARTUP REQUEST %2hx\n", req->data[2]); + dprintf("Wacca touch: BAD READ REQUEST %2hx\n", req->data[2]); return 1; } @@ -342,7 +342,7 @@ static HRESULT touch_handle_mystery1(const struct touch_req *req) struct touch_resp_mystery1 resp; HRESULT hr; - dprintf("Wacca Touch%d: mystery command 1\n", req->side); + dprintf("Wacca Touch%d: Command A2\n", req->side); resp.cmd = 0xa2; resp.data = 0x3f; @@ -363,7 +363,7 @@ static HRESULT touch_handle_mystery2(const struct touch_req *req) struct touch_resp_mystery2 resp; HRESULT hr; - dprintf("Wacca Touch%d: mystery command 2\n", req->side); + dprintf("Wacca Touch%d: Command 94\n", req->side); resp.cmd = 0x94; resp.data = 0; diff --git a/mercuryhook/touch.h b/mercuryhook/touch.h index d98fc0b..cc665c8 100644 --- a/mercuryhook/touch.h +++ b/mercuryhook/touch.h @@ -10,7 +10,7 @@ struct touch_config { enum touch_cmd { CMD_GET_SYNC_BOARD_VER = 0xa0, - CMD_STARTUP = 0x72, + CMD_NEXT_READ = 0x72, CMD_GET_UNIT_BOARD_VER = 0xa8, CMD_MYSTERY1 = 0xa2, CMD_MYSTERY2 = 0x94,