forked from Hay1tsme/segatools
mercury: fix coin counter (thanks Raki!)
This commit is contained in:
parent
929ea862ca
commit
5f51699c78
@ -89,6 +89,16 @@ static LSTATUS WINAPI hook_RegSetValueExW(
|
||||
const void *bytes,
|
||||
uint32_t nbytes);
|
||||
|
||||
static LSTATUS WINAPI hook_RegGetValueW(
|
||||
HKEY hkey,
|
||||
LPCWSTR lpSubKey,
|
||||
LPCWSTR lpValue,
|
||||
uint32_t flags,
|
||||
uint32_t *type,
|
||||
void *pData,
|
||||
uint32_t *numData
|
||||
);
|
||||
|
||||
/* Link pointers */
|
||||
|
||||
static LSTATUS (WINAPI *next_RegOpenKeyExW)(
|
||||
@ -135,6 +145,16 @@ static LSTATUS (WINAPI *next_RegSetValueExW)(
|
||||
const void *bytes,
|
||||
uint32_t nbytes);
|
||||
|
||||
static LSTATUS (WINAPI *next_RegGetValueW)(
|
||||
HKEY hkey,
|
||||
LPCWSTR lpSubKey,
|
||||
LPCWSTR lpValue,
|
||||
uint32_t flags,
|
||||
uint32_t *type,
|
||||
void *pData,
|
||||
uint32_t *numData
|
||||
);
|
||||
|
||||
static const struct hook_symbol reg_hook_syms[] = {
|
||||
{
|
||||
.name = "RegOpenKeyExW",
|
||||
@ -160,6 +180,10 @@ static const struct hook_symbol reg_hook_syms[] = {
|
||||
.name = "RegSetValueExW",
|
||||
.patch = hook_RegSetValueExW,
|
||||
.link = (void **) &next_RegSetValueExW,
|
||||
}, {
|
||||
.name = "RegGetValueW",
|
||||
.patch = hook_RegGetValueW,
|
||||
.link = (void **) &next_RegGetValueW,
|
||||
}
|
||||
};
|
||||
|
||||
@ -184,6 +208,12 @@ HRESULT reg_hook_push_key(
|
||||
|
||||
reg_hook_init();
|
||||
|
||||
/*dprintf("Pushing reg key %ls:\n", name);
|
||||
|
||||
for (int i = 0; i < nvals; i++) {
|
||||
dprintf("\t%ls\n", vals[i].name);
|
||||
} */
|
||||
|
||||
EnterCriticalSection(®_hook_lock);
|
||||
|
||||
new_mem = realloc(
|
||||
@ -222,6 +252,7 @@ static void reg_hook_init(void)
|
||||
|
||||
reg_hook_initted = true;
|
||||
InitializeCriticalSection(®_hook_lock);
|
||||
dprintf("Reg hook init\n");
|
||||
|
||||
hook_table_apply(
|
||||
NULL,
|
||||
@ -727,6 +758,69 @@ static LSTATUS WINAPI hook_RegSetValueExW(
|
||||
return err;
|
||||
}
|
||||
|
||||
static LSTATUS WINAPI hook_RegGetValueW(
|
||||
HKEY handle,
|
||||
LPCWSTR subkey,
|
||||
LPCWSTR name,
|
||||
uint32_t flags,
|
||||
uint32_t *type,
|
||||
void *pData,
|
||||
uint32_t *numData)
|
||||
{
|
||||
struct reg_hook_key *key;
|
||||
HKEY tmp = NULL;
|
||||
const struct reg_hook_val *val;
|
||||
LSTATUS err;
|
||||
|
||||
EnterCriticalSection(®_hook_lock);
|
||||
//dprintf("Registry: RegGetValueW lookup for %ls\\%ls\n", subkey, name);
|
||||
|
||||
if (subkey == NULL) {
|
||||
key = reg_hook_match_key_locked(handle);
|
||||
} else {
|
||||
err = hook_RegOpenKeyExW(handle, subkey, flags, 1, &tmp);
|
||||
key = reg_hook_match_key_locked(tmp);
|
||||
}
|
||||
|
||||
//dprintf("Registry: RegGetValueW key is %ls", key->name);
|
||||
|
||||
if (key == NULL) {
|
||||
LeaveCriticalSection(®_hook_lock);
|
||||
dprintf("Registry: RegGetValueW Failed to find %ls\\%ls, passing on\n", subkey, name);
|
||||
|
||||
return next_RegGetValueW(
|
||||
handle,
|
||||
subkey,
|
||||
name,
|
||||
flags,
|
||||
type,
|
||||
pData,
|
||||
numData);
|
||||
}
|
||||
|
||||
val = reg_hook_match_val_locked(key, name);
|
||||
|
||||
if (val != NULL) {
|
||||
//dprintf("Registry: RegGetValueW found %ls\\%ls!\n", subkey, name);
|
||||
|
||||
if (val->read != NULL) {
|
||||
val->read(pData, numData);
|
||||
|
||||
if (tmp != NULL) {
|
||||
hook_RegCloseKey(tmp);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(®_hook_lock);
|
||||
err = ERROR_SUCCESS;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
LeaveCriticalSection(®_hook_lock);
|
||||
err = ERROR_NOT_FOUND;
|
||||
return err;
|
||||
}
|
||||
|
||||
HRESULT reg_hook_read_bin(
|
||||
void *bytes,
|
||||
uint32_t *nbytes,
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "board/io4.h"
|
||||
|
||||
@ -10,6 +11,9 @@
|
||||
|
||||
#include "util/dprintf.h"
|
||||
|
||||
bool mercury_io_coin = false;
|
||||
uint16_t mercury_io_coins = 0;
|
||||
|
||||
static HRESULT mercury_io4_poll(void *ctx, struct io4_state *state);
|
||||
|
||||
static const struct io4_ops mercury_io4_ops = {
|
||||
@ -64,8 +68,16 @@ static HRESULT mercury_io4_poll(void *ctx, struct io4_state *state)
|
||||
}
|
||||
|
||||
if (opbtn & MERCURY_IO_OPBTN_COIN) {
|
||||
state->chutes[0] += 1 << 8; // FIXME: Inserts 1 credit on press, then 15 on release...
|
||||
if (!mercury_io_coin) {
|
||||
mercury_io_coin = true;
|
||||
mercury_io_coins++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mercury_io_coin = false;
|
||||
}
|
||||
|
||||
state->chutes[0] = 128 + 256 * mercury_io_coins;
|
||||
|
||||
if (gamebtn & MERCURY_IO_GAMEBTN_VOL_UP) {
|
||||
state->buttons[0] |= 1 << 1;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "mercuryhook/elisabeth.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user