diff --git a/Package.mk b/Package.mk index 5e597a8..bdbb262 100644 --- a/Package.mk +++ b/Package.mk @@ -279,11 +279,7 @@ $(BUILD_DIR_ZIP)/sekito.zip: $(V)echo ... $@ $(V)mkdir -p $(BUILD_DIR_ZIP)/sekito $(V)mkdir -p $(BUILD_DIR_ZIP)/sekito/DEVICE - $(V)cp $(BUILD_DIR_32)/subprojects/capnhook/inject/inject_x86.exe \ - $(V)cp $(BUILD_DIR_64)/subprojects/capnhook/inject/inject_x64.exe \ - $(BUILD_DIR_GAMES_64)/sekitohook/sekitohook_x64.dll \ - $(BUILD_DIR_GAMES_32)/sekitohook/sekitohook_x86.dll \ - $(DIST_DIR)/sekito/segatools_terminal.ini \ + $(V)cp $(DIST_DIR)/sekito/segatools_terminal.ini \ $(DIST_DIR)/sekito/segatools_satellite.ini \ $(DIST_DIR)/sekito/launch_terminal.bat \ $(DIST_DIR)/sekito/launch_satellite.bat \ @@ -293,6 +289,16 @@ $(BUILD_DIR_ZIP)/sekito.zip: $(V)cp pki/billing.pub \ pki/ca.crt \ $(BUILD_DIR_ZIP)/sekito/DEVICE + $(V)cp $(BUILD_DIR_32)/subprojects/capnhook/inject/inject.exe \ + $(BUILD_DIR_ZIP)/sekito/inject_x86.exe + $(V)cp $(BUILD_DIR_64)/subprojects/capnhook/inject/inject.exe \ + $(BUILD_DIR_ZIP)/sekito/inject_x64.exe + $(V)cp $(BUILD_DIR_32)/subprojects/capnhook/inject/inject.exe \ + $(BUILD_DIR_ZIP)/sekito/inject_x86.exe + $(V)cp $(BUILD_DIR_GAMES_32)/sekitohook/sekitohook.dll \ + $(BUILD_DIR_ZIP)/sekito/sekitohook_x86.dll + $(V)cp $(BUILD_DIR_GAMES_64)/sekitohook/sekitohook.dll \ + $(BUILD_DIR_ZIP)/sekito/sekitohook_x64.dll $(V)strip $(BUILD_DIR_ZIP)/sekito/*.{exe,dll} $(V)cd $(BUILD_DIR_ZIP)/sekito ; zip -r ../sekito.zip * diff --git a/common/hooklib/printer_chc.c b/common/hooklib/printer_chc.c index 001a6c4..53d44ed 100644 --- a/common/hooklib/printer_chc.c +++ b/common/hooklib/printer_chc.c @@ -149,6 +149,7 @@ int WINAPI chcusb_getEEPROM(uint8_t index, uint8_t *rData, uint16_t *rResult); int WINAPI chcusb_setParameter(uint8_t a1, uint32_t a2, uint16_t *rResult); int WINAPI chcusb_getParameter(uint8_t a1, uint8_t *a2, uint16_t *rResult); int WINAPI chcusb_universal_command(int32_t a1, uint8_t a2, int32_t a3, uint8_t *a4, uint16_t *rResult); +int WINAPI chcusb_writeIred(uint8_t* a1, uint8_t* a2, uint16_t* rResult); /* PrintDLL API hooks */ @@ -866,6 +867,336 @@ static const struct hook_symbol C3XXusb_hooks[] = { }, }; +/* CHC320 x86 hook table */ + +static const struct hook_symbol C320usb_hooks[] = { + { + .name = "__imp_chcusb_MakeThread", + .ordinal= 1, + .patch = chcusb_MakeThread, + .link = NULL + }, { + .name = "__imp_chcusb_open", + .ordinal= 2, + .patch = chcusb_open, + .link = NULL + }, { + .name = "__imp_chcusb_close", + .ordinal= 3, + .patch = chcusb_close, + .link = NULL + }, { + .name = "__imp_chcusb_ReleaseThread", + .ordinal= 4, + .patch = chcusb_ReleaseThread, + .link = NULL + }, { + .name = "__imp_chcusb_listupPrinter", + .ordinal= 5, + .patch = chcusb_listupPrinter, + .link = NULL + }, { + .name = "__imp_chcusb_listupPrinterSN", + .ordinal= 6, + .patch = chcusb_listupPrinterSN, + .link = NULL + }, { + .name = "__imp_chcusb_selectPrinter", + .ordinal= 7, + .patch = chcusb_selectPrinter, + .link = NULL + }, { + .name = "__imp_chcusb_selectPrinterSN", + .ordinal= 8, + .patch = chcusb_selectPrinterSN, + .link = NULL + }, { + .name = "__imp_chcusb_getPrinterInfo", + .ordinal= 9, + .patch = chcusb_getPrinterInfo, + .link = NULL + }, { + .name = "__imp_chcusb_imageformat", + .ordinal= 10, + .patch = chcusb_imageformat_330, + .link = NULL + }, { + .name = "__imp_chcusb_setmtf", + .ordinal= 11, + .patch = chcusb_setmtf, + .link = NULL + }, { + .name = "__imp_chcusb_makeGamma", + .ordinal= 12, + .patch = chcusb_makeGamma, + .link = NULL + }, { + .name = "__imp_chcusb_setIcctable", + .ordinal= 13, + .patch = chcusb_setIcctable, + .link = NULL + }, { + .name = "__imp_chcusb_copies", + .ordinal= 14, + .patch = chcusb_copies, + .link = NULL + }, { + .name = "__imp_chcusb_status", + .ordinal= 15, + .patch = chcusb_status, + .link = NULL + }, { + .name = "__imp_chcusb_statusAll", + .ordinal= 16, + .patch = chcusb_statusAll, + .link = NULL + }, { + .name = "__imp_chcusb_startpage", + .ordinal= 17, + .patch = chcusb_startpage, + .link = NULL + }, { + .name = "__imp_chcusb_endpage", + .ordinal= 18, + .patch = chcusb_endpage, + .link = NULL + }, { + .name = "__imp_chcusb_write", + .ordinal= 19, + .patch = chcusb_write, + .link = NULL + }, { + .name = "__imp_chcusb_writeLaminate", + .ordinal= 20, + .patch = chcusb_writeLaminate, + .link = NULL + }, { + .name = "__imp_chcusb_writeHolo", + .ordinal= 21, + .patch = chcusb_writeHolo, + .link = NULL + }, { + .name = "__imp_chcusb_setPrinterInfo", + .ordinal= 22, + .patch = chcusb_setPrinterInfo, + .link = NULL + }, { + .name = "__imp_chcusb_getGamma", + .ordinal= 23, + .patch = chcusb_getGamma, + .link = NULL + }, { + .name = "__imp_chcusb_getMtf", + .ordinal= 24, + .patch = chcusb_getMtf, + .link = NULL + }, { + .name = "__imp_chcusb_cancelCopies", + .ordinal= 25, + .patch = chcusb_cancelCopies, + .link = NULL + }, { + .name = "__imp_chcusb_setPrinterToneCurve", + .ordinal= 26, + .patch = chcusb_setPrinterToneCurve, + .link = NULL + }, { + .name = "__imp_chcusb_getPrinterToneCurve", + .ordinal= 27, + .patch = chcusb_getPrinterToneCurve, + .link = NULL + }, { + .name = "chcusb_blinkLED", + .ordinal= 28, + .patch = chcusb_blinkLED, + .link = NULL + }, { + .name = "chcusb_resetPrinter", + .ordinal= 29, + .patch = chcusb_resetPrinter, + .link = NULL + }, { + .name = "__imp_chcusb_AttachThreadCount", + .ordinal= 30, + .patch = chcusb_AttachThreadCount, + .link = NULL + }, { + .name = "__imp_chcusb_getPrintIDStatus", + .ordinal= 31, + .patch = chcusb_getPrintIDStatus, + .link = NULL + }, { + .name = "__imp_chcusb_setPrintStandby", + .ordinal= 32, + .patch = chcusb_setPrintStandby, + .link = NULL + }, { + .name = "chcusb_testCardFeed", + .ordinal= 33, + .patch = chcusb_testCardFeed, + .link = NULL + }, { + .name = "__imp_chcusb_exitCard", + .ordinal= 34, + .patch = chcusb_exitCard, + .link = NULL + }, { + .name = "__imp_chcusb_getCardRfidTID", + .ordinal= 35, + .patch = chcusb_getCardRfidTID, + .link = NULL + }, { + .name = "__imp_chcusb_commCardRfidReader", + .ordinal= 36, + .patch = chcusb_commCardRfidReader, + .link = NULL + }, { + .name = "__imp_chcusb_updateCardRfidReader", + .ordinal= 37, + .patch = chcusb_updateCardRfidReader, + .link = NULL + }, { + .name = "__imp_chcusb_getErrorLog", + .ordinal= 38, + .patch = chcusb_getErrorLog, + .link = NULL + }, { + .name = "__imp_chcusb_getErrorStatus", + .ordinal= 39, + .patch = chcusb_getErrorStatus, + .link = NULL + }, { + .name = "__imp_chcusb_setCutList", + .ordinal= 40, + .patch = chcusb_setCutList, + .link = NULL + }, { + .name = "__imp_chcusb_setLaminatePattern", + .ordinal= 41, + .patch = chcusb_setLaminatePattern, + .link = NULL + }, { + .name = "__imp_chcusb_color_adjustment", + .ordinal= 42, + .patch = chcusb_color_adjustment, + .link = NULL + }, { + .name = "__imp_chcusb_color_adjustmentEx", + .ordinal= 43, + .patch = chcusb_color_adjustmentEx, + .link = NULL + }, { + .name = "__imp_chcusb_writeIred", + .ordinal= 50, + .patch = chcusb_writeIred, + .link = NULL + }, { + .name = "__imp_chcusb_getEEPROM", + .ordinal= 58, + .patch = chcusb_getEEPROM, + .link = NULL + }, { + .name = "__imp_chcusb_setParameter", + .ordinal= 64, + .patch = chcusb_setParameter, + .link = NULL + }, { + .name = "__imp_chcusb_getParameter", + .ordinal= 65, + .patch = chcusb_getParameter, + .link = NULL + }, { + .name = "__imp_chcusb_universal_command", + .ordinal= 73, + .patch = chcusb_universal_command, + .link = NULL + }, +}; + +static const struct hook_symbol C320FWDLusb_hooks[] = { + { + .name = "__imp_fwdlusb_open", + .ordinal= 1, + .patch = fwdlusb_open, + .link = NULL + }, { + .name = "__imp_fwdlusb_close", + .ordinal= 2, + .patch = fwdlusb_close, + .link = NULL + }, { + .name = "__imp_fwdlusb_listupPrinter", + .ordinal= 3, + .patch = fwdlusb_listupPrinter, + .link = NULL + }, { + .name = "__imp_fwdlusb_listupPrinterSN", + .ordinal= 4, + .patch = fwdlusb_listupPrinterSN, + .link = NULL + }, { + .name = "__imp_fwdlusb_selectPrinter", + .ordinal= 5, + .patch = fwdlusb_selectPrinter, + .link = NULL + }, { + .name = "__imp_fwdlusb_selectPrinterSN", + .ordinal= 6, + .patch = fwdlusb_selectPrinterSN, + .link = NULL + }, { + .name = "__imp_fwdlusb_getPrinterInfo", + .ordinal= 7, + .patch = fwdlusb_getPrinterInfo, + .link = NULL + }, { + .name = "__imp_fwdlusb_status", + .ordinal= 8, + .patch = fwdlusb_status, + .link = NULL + }, { + .name = "__imp_fwdlusb_statusAll", + .ordinal= 9, + .patch = fwdlusb_statusAll, + .link = NULL + }, { + .name = "__imp_fwdlusb_resetPrinter", + .ordinal= 10, + .patch = fwdlusb_resetPrinter, + .link = NULL + }, { + .name = "__imp_fwdlusb_updateFirmware", + .ordinal= 11, + .patch = fwdlusb_updateFirmware, + .link = NULL + }, { + .name = "__imp_fwdlusb_getFirmwareInfo", + .ordinal= 12, + .patch = fwdlusb_getFirmwareInfo, + .link = NULL + }, { + .name = "__imp_fwdlusb_MakeThread", + .ordinal= 13, + .patch = fwdlusb_MakeThread, + .link = NULL + }, { + .name = "__imp_fwdlusb_ReleaseThread", + .ordinal= 14, + .patch = fwdlusb_ReleaseThread, + .link = NULL + }, { + .name = "__imp_fwdlusb_AttachThreadCount", + .ordinal= 15, + .patch = fwdlusb_AttachThreadCount, + .link = NULL + }, { + .name = "__imp_fwdlusb_getErrorLog", + .ordinal= 16, + .patch = fwdlusb_getErrorLog, + .link = NULL + }, +}; + /* PrintDLL hook tbl */ static struct hook_symbol printdll_hooks[] = { @@ -1236,8 +1567,8 @@ void printer_chc_hook_insert_hooks(HMODULE target) { hook_table_apply(target, "C310Busb.dll", C3XXusb_hooks, _countof(C3XXusb_hooks)); hook_table_apply(target, "C310FWDLusb.dll", C3XXFWDLusb_hooks, _countof(C3XXFWDLusb_hooks)); hook_table_apply(target, "C310BFWDLusb.dll", C3XXFWDLusb_hooks, _countof(C3XXFWDLusb_hooks)); - hook_table_apply(target, "C320Ausb.dll", C3XXusb_hooks, _countof(C3XXusb_hooks)); - hook_table_apply(target, "C320AFWDLusb.dll", C3XXFWDLusb_hooks, _countof(C3XXFWDLusb_hooks)); + hook_table_apply(target, "C320Ausb.dll", C320usb_hooks, _countof(C3XXusb_hooks)); + hook_table_apply(target, "C320AFWDLusb.dll", C320FWDLusb_hooks, _countof(C3XXFWDLusb_hooks)); hook_table_apply(target, "C330Ausb.dll", C3XXusb_hooks, _countof(C3XXusb_hooks)); hook_table_apply(target, "C330AFWDLusb.dll", C3XXFWDLusb_hooks, _countof(C3XXFWDLusb_hooks)); @@ -2162,6 +2493,11 @@ int WINAPI chcusb_getPrinterInfo(uint16_t tagNumber, uint8_t *rBuffer, uint32_t if (rBuffer) memset(rBuffer, 0, *rLen); break; + case 2: // unknown + if (*rLen != 0x17) *rLen = 0x17; + if (rBuffer) memset(rBuffer, 0, *rLen); + break; + case 3: // getFirmwareVersion if (*rLen != 0x99) *rLen = 0x99; if (rBuffer) { @@ -3153,3 +3489,12 @@ void printer_set_dimensions(int width, int height){ WIDTH = width; HEIGHT = height; } + + +int WINAPI chcusb_writeIred(uint8_t* a1, uint8_t* a2, uint16_t* rResult) { + dprintf("Printer: C3XXusb: %s, %p, %p\n", __func__, a1, a2); + dump(a1, 16); + dump(a2, 16); + *rResult = 0; + return 1; +} \ No newline at end of file diff --git a/common/platform/amvideo.c b/common/platform/amvideo.c index 001a52a..e0c51ab 100644 --- a/common/platform/amvideo.c +++ b/common/platform/amvideo.c @@ -18,6 +18,7 @@ static HRESULT amvideo_reg_read_name(void *bytes, uint32_t *nbytes); static HRESULT amvideo_reg_read_port_X(void *bytes, uint32_t *nbytes); static HRESULT amvideo_reg_read_resolution_1(void *bytes, uint32_t *nbytes); +static HRESULT amvideo_reg_read_resolution_2(void *bytes, uint32_t *nbytes); static HRESULT amvideo_reg_read_setting(void *bytes, uint32_t *nbytes); static HRESULT amvideo_reg_read_use_segatiming(void *bytes, uint32_t *nbytes); @@ -81,6 +82,10 @@ static const struct reg_hook_val amvideo_reg_mode_vals[] = { .name = L"resolution_1", .read = amvideo_reg_read_resolution_1, .type = REG_SZ, + }, { + .name = L"resolution_2", + .read = amvideo_reg_read_resolution_2, + .type = REG_SZ, }, { .name = L"use_segatiming", .read = amvideo_reg_read_use_segatiming, @@ -171,6 +176,11 @@ static HRESULT amvideo_reg_read_resolution_1(void *bytes, uint32_t *nbytes) return reg_hook_read_wstr(bytes, nbytes, L"1920x1080"); } +static HRESULT amvideo_reg_read_resolution_2(void *bytes, uint32_t *nbytes) +{ + return reg_hook_read_wstr(bytes, nbytes, L"1920x1080"); +} + static HRESULT amvideo_reg_read_setting(void *bytes, uint32_t *nbytes) { return reg_hook_read_wstr(bytes, nbytes, L"0"); diff --git a/dist/ekt/card_player.html b/dist/ekt/card_player.html index 98e4e08..a92696d 100644 --- a/dist/ekt/card_player.html +++ b/dist/ekt/card_player.html @@ -53,7 +53,7 @@ } function connect(){ - socket = new WebSocket("ws://127.0.0.1:3497/y3io"); + socket = new WebSocket("ws://127.0.0.1:3594/y3io"); socket.onopen = function(e) { document.getElementById("status").innerText = "Connected. Loading information..."; diff --git a/dist/sekito/card_player.html b/dist/sekito/card_player.html index 98e4e08..a92696d 100644 --- a/dist/sekito/card_player.html +++ b/dist/sekito/card_player.html @@ -53,7 +53,7 @@ } function connect(){ - socket = new WebSocket("ws://127.0.0.1:3497/y3io"); + socket = new WebSocket("ws://127.0.0.1:3594/y3io"); socket.onopen = function(e) { document.getElementById("status").innerText = "Connected. Loading information..."; diff --git a/dist/sekito/segatools_satellite.ini b/dist/sekito/segatools_satellite.ini index 19d3451..1f96a01 100644 --- a/dist/sekito/segatools_satellite.ini +++ b/dist/sekito/segatools_satellite.ini @@ -76,6 +76,28 @@ dipsw1=0 ; Misc. hooks settings ; ----------------------------------------------------------------------------- +[printer] +; Sinfonia CHC-C320 printer emulation setting. +enable=1 +; Change the printer serial number here. +serial_no="5A-A123" +; Insert the path to the image output directory here. +printerOutPath="DEVICE\print" +; Rotate all printed images by 180 degrees. +rotate180=1 + +[gfx] +; Enables the graphics hook. +enable=1 +; Force the game to run windowed. +windowed=1 +; Add a frame to the game window if running windowed. +framed=0 +; Select the monitor to run the game on. (Fullscreen only, 0 =primary screen) +monitor=0 +; Enable DPI awareness for the game process, preventing Windows from stretching the game window if a DPI scaling higher than 100% is used +dpiAware=1 + [flatPanelReader] ; Enable the Y3 board emulation. enable=1 diff --git a/dist/sekito/segatools_terminal.ini b/dist/sekito/segatools_terminal.ini index 7f68cb3..7004632 100644 --- a/dist/sekito/segatools_terminal.ini +++ b/dist/sekito/segatools_terminal.ini @@ -72,6 +72,22 @@ enable=1 ; this to 0 on exactly one machine and set this to 1 on all others. dipsw1=0 +; ----------------------------------------------------------------------------- +; Misc. hooks settings +; ----------------------------------------------------------------------------- + +[gfx] +; Enables the graphics hook. +enable=1 +; Force the game to run windowed. +windowed=1 +; Add a frame to the game window if running windowed. +framed=0 +; Select the monitor to run the game on. (Fullscreen only, 0 =primary screen) +monitor=0 +; Enable DPI awareness for the game process, preventing Windows from stretching the game window if a DPI scaling higher than 100% is used +dpiAware=1 + ; ----------------------------------------------------------------------------- ; LED settings ; ----------------------------------------------------------------------------- diff --git a/games/sekitohook/config.c b/games/sekitohook/config.c index a98ace9..84831ef 100644 --- a/games/sekitohook/config.c +++ b/games/sekitohook/config.c @@ -1,7 +1,10 @@ +#include "amex/config.h" + #include #include #include "board/config.h" +#include "gfxhook/config.h" #include "sekitohook/config.h" #include "sekitohook/sekito-dll.h" @@ -102,6 +105,8 @@ void sekito_hook_config_load( led15093_config_load(&cfg->led15093, filename); y3_config_load(&cfg->y3, filename); printer_chc_config_load(&cfg->printer, filename); - unity_config_load(&cfg->unity, filename); sekito_dll_config_load(&cfg->dll, filename); + gfx_config_load(&cfg->gfx, filename); + amex_config_load(&cfg->amex, filename); + amvideo_config_load(&cfg->amvideo, filename); } diff --git a/games/sekitohook/config.h b/games/sekitohook/config.h index 54ebd36..13c7207 100644 --- a/games/sekitohook/config.h +++ b/games/sekitohook/config.h @@ -2,9 +2,11 @@ #include +#include "amex/amex.h" #include "board/sg-reader.h" #include "board/config.h" #include "board/led15093.h" +#include "gfxhook/gfx.h" #include "sekitohook/sekito-dll.h" @@ -14,7 +16,6 @@ #include "platform/config.h" -#include "unityhook/config.h" struct sekito_hook_config { struct platform_config platform; @@ -24,8 +25,10 @@ struct sekito_hook_config { struct led15093_config led15093; struct y3_config y3; struct sekito_dll_config dll; - struct unity_config unity; struct printer_chc_config printer; + struct gfx_config gfx; + struct amex_config amex; + struct amvideo_config amvideo; }; void sekito_dll_config_load( diff --git a/games/sekitohook/dllmain.c b/games/sekitohook/dllmain.c index 5269556..2c13566 100644 --- a/games/sekitohook/dllmain.c +++ b/games/sekitohook/dllmain.c @@ -3,19 +3,20 @@ Devices - USB: 837-15257-01 "Type 4" I/O Board - COM12: 837-15396 "Gen 3" Aime Reader + USB: 837-14572 "Type 3" I/O Board + COM12: Aime [Satellite] USB: Printer COM1: 837-15093-06 LED Controller Board + COM10: 601-13160-01 "Flat Panel Reader" Y3CR BD SIE F720MM Board COM11: Printer Camera [Terminal] - COM1: 837-15396 "Gen 3" Aime Reader - COM3: 837-15093-06 LED Controller Board + COM1: Aime + COM11: 837-15093-06 LED Controller Board */ #include @@ -23,36 +24,31 @@ #include #include "sekito-dll.h" +#include "amex/amex.h" #include "board/sg-reader.h" #include "board/led15093.h" +#include "gfxhook/gfx.h" #include "hook/process.h" #include "hook/iohook.h" +#include "hooklib/dll.h" #include "hooklib/serial.h" #include "hooklib/spike.h" #include "sekitohook/config.h" -#include "sekitohook/io4.h" -#include "hooklib/printer_cx.h" +#include "sekitohook/jvs.h" #include "platform/platform.h" -#include "unityhook/hook.h" - #include "util/dprintf.h" #include "util/env.h" -#include "hooklib/y3-dll.h" #include "hooklib/y3.h" static HMODULE sekito_hook_mod; static process_entry_t sekito_startup; static struct sekito_hook_config sekito_hook_cfg; -static void unity_hook_callback(HMODULE hmodule, const wchar_t* p) { - netenv_hook_apply_hooks(hmodule); -} - static DWORD CALLBACK sekito_pre_startup(void) { HRESULT hr; @@ -67,7 +63,9 @@ static DWORD CALLBACK sekito_pre_startup(void) /* Hook Win32 APIs */ dvd_hook_init(&sekito_hook_cfg.dvd, sekito_hook_mod); + gfx_hook_init(&sekito_hook_cfg.gfx); serial_hook_init(); + sekito_io_init(); /* Hook external DLL APIs */ @@ -78,6 +76,10 @@ static DWORD CALLBACK sekito_pre_startup(void) } printer_chc_hook_init(&sekito_hook_cfg.printer, 0, sekito_hook_mod); + if (sekito_hook_cfg.printer.enable) { + dll_hook_push(sekito_hook_mod, L"C320Ausb.dll"); + dll_hook_push(sekito_hook_mod, L"C320AFWDLusb.dll"); + } /* Initialize emulation hooks */ @@ -104,17 +106,11 @@ static DWORD CALLBACK sekito_pre_startup(void) goto fail; } - // LED: terminal uses COM 3 and satellite use COM 2 - unsigned int led_port_no[2] = {is_terminal ? 3 : 2, 0}; + // LED: terminal uses COM 11 and satellite use COM 2 + unsigned int led_port_no[2] = {is_terminal ? 11 : 1, 0}; hr = sekito_dll_init(&sekito_hook_cfg.dll, sekito_hook_mod); - if (FAILED(hr)) { - goto fail; - } - - hr = sekito_io4_hook_init(&sekito_hook_cfg.io4, is_terminal); - if (FAILED(hr)) { goto fail; } @@ -144,6 +140,18 @@ static DWORD CALLBACK sekito_pre_startup(void) } + sekito_jvs_set_terminal(is_terminal); + hr = amex_hook_init(&sekito_hook_cfg.amex, sekito_jvs_init); + + if (FAILED(hr)) { + goto fail; + } + hr = amvideo_hook_init(&sekito_hook_cfg.amvideo, sekito_hook_mod); + + if (FAILED(hr)) { + goto fail; + } + /* Initialize debug helpers */ spike_hook_init(get_config_path()); diff --git a/games/sekitohook/io4.c b/games/sekitohook/io4.c deleted file mode 100644 index 4103ef1..0000000 --- a/games/sekitohook/io4.c +++ /dev/null @@ -1,212 +0,0 @@ -#include "io4.h" - -#include - -#include -#include -#include - -#include "board/io4.h" - -#include "sekitohook/sekito-dll.h" - -#include "util/dprintf.h" - -static HRESULT sekito_io4_poll(void *ctx, struct io4_state *state); -static uint16_t coins; - -static const struct io4_ops sekito_io4_ops = { - .poll = sekito_io4_poll, -}; - -static bool io_is_terminal; - -HRESULT sekito_io4_hook_init(const struct io4_config *cfg, bool is_terminal) -{ - HRESULT hr; - - assert(sekito_dll.init != NULL); - - hr = io4_hook_init(cfg, &sekito_io4_ops, NULL); - - io_is_terminal = is_terminal; - - if (FAILED(hr)) { - return hr; - } - - return sekito_dll.init(); -} - -static HRESULT sekito_io4_poll(void *ctx, struct io4_state *state) -{ - uint8_t opbtn; - uint16_t x, y; - uint32_t gamebtn; - HRESULT hr; - - assert(sekito_dll.poll != NULL); - assert(sekito_dll.get_opbtns != NULL); - assert(sekito_dll.get_gamebtns != NULL); - assert(sekito_dll.get_trackball_position != NULL); - - memset(state, 0, sizeof(*state)); - - hr = sekito_dll.poll(); - - if (FAILED(hr)) { - return hr; - } - - opbtn = 0; - gamebtn = 0; - x = 0; - y = 0; - - sekito_dll.get_opbtns(&opbtn); - sekito_dll.get_gamebtns(&gamebtn); - sekito_dll.get_trackball_position(&x, &y); - - if (opbtn & SEKITO_IO_OPBTN_TEST) { - state->buttons[0] |= IO4_BUTTON_TEST; - } - - if (opbtn & SEKITO_IO_OPBTN_SERVICE) { - state->buttons[0] |= IO4_BUTTON_SERVICE; - } - - if (opbtn & SEKITO_IO_OPBTN_SW1) { - state->buttons[0] |= 1 << 10; - } - - if (opbtn & SEKITO_IO_OPBTN_SW2) { - state->buttons[0] |= 1 << 11; - } - - if (opbtn & SEKITO_IO_OPBTN_COIN) { - coins++; - } - state->chutes[0] = coins << 8; - - if (!io_is_terminal) { - if (gamebtn & SEKITO_IO_GAMEBTN_HOUGU) { - state->buttons[1] |= 1 << 6; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_MENU) { - state->buttons[1] |= 1 << 4; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_START) { - state->buttons[0] |= 1 << 15; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_STRATAGEM) { - state->buttons[1] |= 1 << 7; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_STRATAGEM_LOCK) { - state->buttons[1] |= 1 << 5; - } - - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_0) { - state->buttons[0] |= SEKITO_NUMPAD_C2; - state->buttons[0] |= SEKITO_NUMPAD_R4; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_1) { - state->buttons[0] |= SEKITO_NUMPAD_C1; - state->buttons[0] |= SEKITO_NUMPAD_R1; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_2) { - state->buttons[0] |= SEKITO_NUMPAD_C2; - state->buttons[0] |= SEKITO_NUMPAD_R1; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_3) { - state->buttons[0] |= SEKITO_NUMPAD_C3; - state->buttons[0] |= SEKITO_NUMPAD_R1; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_4) { - state->buttons[0] |= SEKITO_NUMPAD_C1; - state->buttons[0] |= SEKITO_NUMPAD_R2; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_5) { - state->buttons[0] |= SEKITO_NUMPAD_C2; - state->buttons[0] |= SEKITO_NUMPAD_R2; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_6) { - state->buttons[0] |= SEKITO_NUMPAD_C3; - state->buttons[0] |= SEKITO_NUMPAD_R2; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_7) { - state->buttons[0] |= SEKITO_NUMPAD_C1; - state->buttons[0] |= SEKITO_NUMPAD_R3; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_8) { - state->buttons[0] |= SEKITO_NUMPAD_C2; - state->buttons[0] |= SEKITO_NUMPAD_R3; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_9) { - state->buttons[0] |= SEKITO_NUMPAD_C3; - state->buttons[0] |= SEKITO_NUMPAD_R3; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_CLEAR) { - state->buttons[0] |= SEKITO_NUMPAD_C1; - state->buttons[0] |= SEKITO_NUMPAD_R4; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_ENTER) { - state->buttons[0] |= SEKITO_NUMPAD_C3; - state->buttons[0] |= SEKITO_NUMPAD_R4; - } - - if (io_is_terminal) { - if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_CANCEL) { - state->buttons[1] |= 1 << 0; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_DECIDE) { - state->buttons[1] |= 1 << 1; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_LEFT) { - state->buttons[0] |= 1 << 3; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_UP) { - state->buttons[0] |= 1 << 5; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_RIGHT) { - state->buttons[0] |= 1 << 2; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_DOWN) { - state->buttons[0] |= 1 << 4; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_LEFT_2) { - state->buttons[1] |= 1 << 3; - } - - if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_RIGHT_2) { - state->buttons[1] |= 1 << 2; - } - } - - state->spinners[2] = x; - state->spinners[3] = y; - - return S_OK; -} diff --git a/games/sekitohook/jvs.c b/games/sekitohook/jvs.c new file mode 100644 index 0000000..42c4293 --- /dev/null +++ b/games/sekitohook/jvs.c @@ -0,0 +1,252 @@ +#include "jvs.h" + +#include + +#include +#include +#include +#include + +#include "amex/jvs.h" + +#include "board/io3.h" + +#include "sekitohook/config.h" + +#include "jvs/jvs-bus.h" + +#include "util/dprintf.h" + +static void sekito_jvs_read_switches(void* ctx, struct io3_switch_state* out); + +static void sekito_jvs_read_coin_counter( + void* ctx, + uint8_t slot_no, + uint16_t* out); + +static void sekito_jvs_read_rotary( + void* ctx, + uint16_t* rotary, + uint8_t nrotary); + +static const struct io3_ops sekito_jvs_io3_ops = { + .read_switches = sekito_jvs_read_switches, + .read_rotarys = sekito_jvs_read_rotary, + .read_coin_counter = sekito_jvs_read_coin_counter, +}; + +static struct io3 sekito_jvs_io3; + +static bool io_is_terminal; + +HRESULT sekito_jvs_init(struct jvs_node** out) { + assert(out != NULL); + + dprintf("JVS I/O: Starting JVS\n"); + + io3_init(&sekito_jvs_io3, NULL, &sekito_jvs_io3_ops, NULL); + *out = io3_to_jvs_node(&sekito_jvs_io3); + + return S_OK; +} + +void sekito_jvs_set_terminal(bool is_terminal) { + io_is_terminal = is_terminal; +} + +static void sekito_jvs_read_switches(void* ctx, struct io3_switch_state* out) { + assert(out != NULL); + + uint8_t opbtn; + uint32_t gamebtn; + + assert(sekito_dll.poll != NULL); + assert(sekito_dll.get_opbtns != NULL); + assert(sekito_dll.get_gamebtns != NULL); + + memset(out, 0, sizeof(*out)); + + sekito_dll.poll(); + + opbtn = 0; + gamebtn = 0; + + sekito_dll.get_opbtns(&opbtn); + sekito_dll.get_gamebtns(&gamebtn); + + if (opbtn & SEKITO_IO_OPBTN_TEST) { + out->system = 0x80; + } else { + out->system = 0; + } + + if (opbtn & SEKITO_IO_OPBTN_SERVICE) { + out->p1 |= 1 << 1; + } + + if (opbtn & SEKITO_IO_OPBTN_SW1) { + out->p1 |= 1 << 10; + } + + if (opbtn & SEKITO_IO_OPBTN_SW2) { + out->p1 |= 1 << 11; + } + + if (opbtn & SEKITO_IO_OPBTN_COIN) { + out->p1 |= 1 << 14; + } + + + if (!io_is_terminal) { + if (gamebtn & SEKITO_IO_GAMEBTN_HOUGU) { + out->p2 |= 1 << 6; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_MENU) { + out->p2 |= 1 << 4; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_START) { + out->p1 |= 1 << 15; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_STRATAGEM) { + out->p2 |= 1 << 7; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_STRATAGEM_LOCK) { + out->p2 |= 1 << 5; + } + + out->p1 |= 0 << 2; // card_sensor + out->p2 |= 1 << 2; // open_sensor + out->p2 |= 1 << 3; // lock + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_0) { + out->p1 |= SEKITO_NUMPAD_C2; + out->p1 |= SEKITO_NUMPAD_R4; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_1) { + out->p1 |= SEKITO_NUMPAD_C1; + out->p1 |= SEKITO_NUMPAD_R1; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_2) { + out->p1 |= SEKITO_NUMPAD_C2; + out->p1 |= SEKITO_NUMPAD_R1; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_3) { + out->p1 |= SEKITO_NUMPAD_C3; + out->p1 |= SEKITO_NUMPAD_R1; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_4) { + out->p1 |= SEKITO_NUMPAD_C1; + out->p1 |= SEKITO_NUMPAD_R2; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_5) { + out->p1 |= SEKITO_NUMPAD_C2; + out->p1 |= SEKITO_NUMPAD_R2; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_6) { + out->p1 |= SEKITO_NUMPAD_C3; + out->p1 |= SEKITO_NUMPAD_R2; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_7) { + out->p1 |= SEKITO_NUMPAD_C1; + out->p1 |= SEKITO_NUMPAD_R3; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_8) { + out->p1 |= SEKITO_NUMPAD_C2; + out->p1 |= SEKITO_NUMPAD_R3; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_9) { + out->p1 |= SEKITO_NUMPAD_C3; + out->p1 |= SEKITO_NUMPAD_R3; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_CLEAR) { + out->p1 |= SEKITO_NUMPAD_C1; + out->p1 |= SEKITO_NUMPAD_R4; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_NUMPAD_ENTER) { + out->p1 |= SEKITO_NUMPAD_C3; + out->p1 |= SEKITO_NUMPAD_R4; + } + + if (io_is_terminal) { + if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_CANCEL) { + out->p2 |= 1 << 0; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_DECIDE) { + out->p2 |= 1 << 1; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_LEFT) { + out->p1 |= 1 << 3; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_UP) { + out->p1 |= 1 << 5; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_RIGHT) { + out->p1 |= 1 << 2; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_DOWN) { + out->p1 |= 1 << 4; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_LEFT_2) { + out->p2 |= 1 << 3; + } + + if (gamebtn & SEKITO_IO_GAMEBTN_TERMINAL_RIGHT_2) { + out->p2 |= 1 << 2; + } + } + +} + +static void sekito_jvs_read_rotary( + void* ctx, + uint16_t* rotary, + uint8_t nrotary) { + assert(rotary != NULL); + assert(sekito_dll.get_trackball_position != NULL); + + uint16_t x, y; + + x = 0; + y = 0; + + sekito_dll.get_trackball_position(&x, &y); + + if (nrotary >= 4) { + rotary[2] = x; + rotary[3] = y; + } +} + +static void sekito_jvs_read_coin_counter( + void* ctx, + uint8_t slot_no, + uint16_t* out) { + if (slot_no > 0) { + return; + } + + // unused(!) + *out = 0; +} diff --git a/games/sekitohook/io4.h b/games/sekitohook/jvs.h similarity index 68% rename from games/sekitohook/io4.h rename to games/sekitohook/jvs.h index 78fa910..fa0584e 100644 --- a/games/sekitohook/io4.h +++ b/games/sekitohook/jvs.h @@ -2,7 +2,7 @@ #include -#include "board/io4.h" +#include "jvs/jvs-bus.h" enum { SEKITO_NUMPAD_R1 = 1 << 9, @@ -14,4 +14,5 @@ enum { SEKITO_NUMPAD_C3 = 1 << 3 }; -HRESULT sekito_io4_hook_init(const struct io4_config *cfg, bool is_terminal); +HRESULT sekito_jvs_init(struct jvs_node **root); +void sekito_jvs_set_terminal(bool is_terminal); diff --git a/games/sekitohook/meson.build b/games/sekitohook/meson.build index 96a9403..c8c647d 100644 --- a/games/sekitohook/meson.build +++ b/games/sekitohook/meson.build @@ -10,12 +10,13 @@ shared_library( ], link_with : [ aimeio_lib, + amex_lib, board_lib, - sekitoio_lib, hooklib_lib, + gfxhook_lib, jvs_lib, platform_lib, - unityhook_lib, + sekitoio_lib, util_lib, y3io_lib, ], @@ -23,8 +24,8 @@ shared_library( 'config.c', 'config.h', 'dllmain.c', - 'io4.c', - 'io4.h', + 'jvs.c', + 'jvs.h', 'sekito-dll.c', 'sekito-dll.h', ], diff --git a/games/sekitohook/sekitohook.def b/games/sekitohook/sekitohook.def index 71ac5ca..de4a252 100644 --- a/games/sekitohook/sekitohook.def +++ b/games/sekitohook/sekitohook.def @@ -19,6 +19,10 @@ EXPORTS y3_io_init y3_io_close y3_io_get_cards + amDllVideoClose + amDllVideoGetVBiosVersion + amDllVideoOpen + amDllVideoSetResolution API_DLLVersion @1 API_GetLastError @2 API_GetErrorMessage @3