forked from Dniel97/segatools
Compare commits
5 Commits
ee414d122b
...
926493290b
Author | SHA1 | Date |
---|---|---|
CrazyRedMachine | 926493290b | |
Dniel97 | f4a3a5f78d | |
Dniel97 | f5f275c8e9 | |
Dniel97 | b38dea23ac | |
Dniel97 | 16bbd87c73 |
|
@ -39,6 +39,19 @@ const struct dll_bind_sym chuni_dll_syms[] = {
|
|||
}
|
||||
};
|
||||
|
||||
/* Helper function to determine upon dll_bind failure whether the required functions were found
|
||||
NOTE: relies on symbols order declared above */
|
||||
static HRESULT has_enough_symbols(uint16_t version, uint8_t count)
|
||||
{
|
||||
if ( version <= 0x0101 && count == 7 )
|
||||
return S_OK;
|
||||
|
||||
if ( version >= 0x0102 && count == 9 )
|
||||
return S_OK;
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
struct chuni_dll chuni_dll;
|
||||
|
||||
// Copypasta DLL binding and diagnostic message boilerplate.
|
||||
|
@ -98,16 +111,24 @@ HRESULT chuni_dll_init(const struct chuni_dll_config *cfg, HINSTANCE self)
|
|||
}
|
||||
|
||||
sym = chuni_dll_syms;
|
||||
const struct dll_bind_sym *init_sym = &sym[0];
|
||||
hr = dll_bind(&chuni_dll, src, &sym, _countof(chuni_dll_syms));
|
||||
|
||||
if (FAILED(hr)) {
|
||||
if (src != self) {
|
||||
dprintf("Chunithm IO: Custom IO DLL does not provide function "
|
||||
"\"%s\". Please contact your IO DLL's developer for "
|
||||
"further assistance.\n",
|
||||
sym->sym);
|
||||
// Might still be ok depending on external dll API version
|
||||
int bind_count = sym - init_sym;
|
||||
if ( has_enough_symbols(chuni_dll.api_version, bind_count) == S_OK )
|
||||
{
|
||||
hr = S_OK;
|
||||
} else {
|
||||
dprintf("Chunithm IO: Custom IO DLL does not provide function "
|
||||
"\"%s\". Please contact your IO DLL's developer for "
|
||||
"further assistance.\n",
|
||||
sym->sym);
|
||||
|
||||
goto end;
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
dprintf("Internal error: could not reflect \"%s\"\n", sym->sym);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ bool shmem_create()
|
|||
|
||||
if (g_hMapFile == NULL)
|
||||
{
|
||||
dprintf("shmem_create : Could not create file mapping object (%d).\n",
|
||||
dprintf("shmem_create : Could not create file mapping object (%ld).\n",
|
||||
GetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ bool shmem_create()
|
|||
|
||||
if (g_pBuf == NULL)
|
||||
{
|
||||
dprintf("shmem_create : Could not map view of file (%d).\n",
|
||||
dprintf("shmem_create : Could not map view of file (%ld).\n",
|
||||
GetLastError());
|
||||
|
||||
CloseHandle(g_hMapFile);
|
||||
|
@ -112,7 +112,7 @@ bool shmem_load()
|
|||
|
||||
if (g_hMapFile == NULL)
|
||||
{
|
||||
dprintf("shmem_load : Could not open file mapping object (%d).\n", GetLastError());
|
||||
dprintf("shmem_load : Could not open file mapping object (%ld).\n", GetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ bool shmem_load()
|
|||
|
||||
if (g_pBuf == NULL)
|
||||
{
|
||||
dprintf("shmem_load : Could not map view of file (%d).\n", GetLastError());
|
||||
dprintf("shmem_load : Could not map view of file (%ld).\n", GetLastError());
|
||||
CloseHandle(g_hMapFile);
|
||||
return 0;
|
||||
}
|
||||
|
@ -148,6 +148,7 @@ static unsigned int __stdcall jvs_poll_thread_proc(void *ctx)
|
|||
while (1) {
|
||||
_chuni_io_jvs_read_coin_counter(&g_shared_data.coin_counter);
|
||||
g_shared_data.opbtn = 0;
|
||||
g_shared_data.beams = 0;
|
||||
_chuni_io_jvs_poll(&g_shared_data.opbtn, &g_shared_data.beams);
|
||||
SHMEM_WRITE(&g_shared_data, sizeof(shared_data_t));
|
||||
Sleep(1);
|
||||
|
@ -156,7 +157,7 @@ static unsigned int __stdcall jvs_poll_thread_proc(void *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint16_t chu2to3_load_dll(wchar_t *dllname)
|
||||
uint16_t chu2to3_load_dll(const wchar_t *dllname)
|
||||
{
|
||||
#if defined(ENV64BIT)
|
||||
/* x64 must just open the shmem and do nothing else */
|
||||
|
@ -175,7 +176,7 @@ uint16_t chu2to3_load_dll(wchar_t *dllname)
|
|||
/* this is the first function called so let's setup the chuniio forwarding */
|
||||
hinstLib = LoadLibraryW(dllname);
|
||||
if (hinstLib == NULL) {
|
||||
dprintf("ERROR: unable to load %S (error %d)\n",dllname, GetLastError());
|
||||
dprintf("ERROR: unable to load %S (error %ld)\n",dllname, GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,4 +23,4 @@ void chu2to3_io_slider_stop(void);
|
|||
void chu2to3_io_slider_set_leds(const uint8_t *rgb);
|
||||
HRESULT chu2to3_io_led_init(void);
|
||||
void chu2to3_io_led_set_colors(uint8_t board, uint8_t *rgb);
|
||||
uint16_t chu2to3_load_dll(wchar_t *dllname);
|
||||
uint16_t chu2to3_load_dll(const wchar_t *dllname);
|
||||
|
|
|
@ -22,7 +22,7 @@ static struct chuni_io_config chuni_io_cfg;
|
|||
|
||||
uint16_t chuni_io_get_api_version(void)
|
||||
{
|
||||
return 0x0101;
|
||||
return 0x0102;
|
||||
}
|
||||
|
||||
HRESULT chuni_io_jvs_init(void)
|
||||
|
@ -91,12 +91,12 @@ void chuni_io_jvs_poll(uint8_t *opbtn, uint8_t *beams)
|
|||
}
|
||||
} else {
|
||||
// Use actual AIR
|
||||
// IR format is beams[5:0] = {b5,b6,b3,b4,b1,b2};
|
||||
for (i = 0 ; i < 3 ; i++) {
|
||||
if (GetAsyncKeyState(chuni_io_cfg.vk_ir[i*2]) & 0x8000)
|
||||
*beams |= (1 << (i*2+1));
|
||||
if (GetAsyncKeyState(chuni_io_cfg.vk_ir[i*2+1]) & 0x8000)
|
||||
*beams |= (1 << (i*2));
|
||||
for (i = 0; i < 6; i++) {
|
||||
if(GetAsyncKeyState(chuni_io_cfg.vk_ir[i]) & 0x8000) {
|
||||
*beams |= (1 << i);
|
||||
} else {
|
||||
*beams &= ~(1 << i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "chuniio/chu2to3.h"
|
||||
#include "chusanhook/chuni-dll.h"
|
||||
|
||||
#include "util/dll-bind.h"
|
||||
|
|
|
@ -17,11 +17,13 @@ add_project_arguments(
|
|||
language: 'c',
|
||||
)
|
||||
|
||||
# Use get_argument_syntax() instead once Meson 0.49.0 releases
|
||||
if meson.get_compiler('c').get_id() != 'msvc'
|
||||
cc = meson.get_compiler('c')
|
||||
|
||||
if cc.get_id() != 'msvc'
|
||||
add_project_arguments(
|
||||
'-ffunction-sections',
|
||||
'-fdata-sections',
|
||||
'-flto', # Enable Link-Time Optimization
|
||||
language: 'c',
|
||||
)
|
||||
|
||||
|
@ -30,11 +32,12 @@ if meson.get_compiler('c').get_id() != 'msvc'
|
|||
'-Wl,--exclude-all-symbols',
|
||||
'-Wl,--gc-sections',
|
||||
'-static-libgcc',
|
||||
'-flto', # Enable Link-Time Optimization
|
||||
'-Wl,-s', # Strip debug symbols
|
||||
language: 'c',
|
||||
)
|
||||
endif
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
shlwapi_lib = cc.find_library('shlwapi')
|
||||
dinput8_lib = cc.find_library('dinput8')
|
||||
dxguid_lib = cc.find_library('dxguid')
|
||||
|
|
Loading…
Reference in New Issue