mu3: coin input added

This commit is contained in:
Dniel97 2023-07-14 00:54:30 +02:00
parent ec072667b3
commit 90a6f1be7c
Signed by untrusted user: Dniel97
GPG Key ID: 6180B3C768FB2E08
7 changed files with 69 additions and 5 deletions

View File

@ -1,11 +1,11 @@
[vfs] [vfs]
; Insert the path to the game AMFS directory here (contains ICF1 and ICF2) ; Insert the path to the game AMFS directory here (contains ICF1 and ICF2)
amfs=amfs amfs=
; Create an empty directory somewhere and insert the path here. ; Create an empty directory somewhere and insert the path here.
; This directory may be shared between multiple SEGA games. ; This directory may be shared between multiple SEGA games.
; NOTE: This has nothing to do with Windows %APPDATA%. ; NOTE: This has nothing to do with Windows %APPDATA%.
appdata=appdata appdata=
option=option option=
[dns] [dns]
; Insert the hostname or IP address of the server you wish to use here. ; Insert the hostname or IP address of the server you wish to use here.
@ -40,8 +40,12 @@ enable=1
; Set "1" to use a xinput gamepad and set "2" to use keyboard. ; Set "1" to use a xinput gamepad and set "2" to use keyboard.
mode=2 mode=2
; Test button virtual-key code. Default is the 1 key.
test=0x31 test=0x31
; Service button virtual-key code. Default is the 2 key.
service=0x32 service=0x32
; Keyboard button to increment coin counter. Default is the 3 key.
coin=0x33
[dinput] [dinput]
LEFT_A=0x53 LEFT_A=0x53

View File

@ -11,6 +11,7 @@
#include "util/dprintf.h" #include "util/dprintf.h"
static HRESULT mu3_io4_poll(void *ctx, struct io4_state *state); static HRESULT mu3_io4_poll(void *ctx, struct io4_state *state);
static uint16_t coins;
static const struct io4_ops mu3_io4_ops = { static const struct io4_ops mu3_io4_ops = {
.poll = mu3_io4_poll, .poll = mu3_io4_poll,
@ -69,6 +70,11 @@ static HRESULT mu3_io4_poll(void *ctx, struct io4_state *state)
state->buttons[0] |= IO4_BUTTON_SERVICE; state->buttons[0] |= IO4_BUTTON_SERVICE;
} }
if (opbtn & MU3_IO_OPBTN_COIN) {
coins++;
}
state->chutes[0] = coins << 8;
if (left & MU3_IO_GAMEBTN_1) { if (left & MU3_IO_GAMEBTN_1) {
state->buttons[0] |= 1 << 0; state->buttons[0] |= 1 << 0;
} }

22
mu3io/config.c Normal file
View File

@ -0,0 +1,22 @@
#include <windows.h>
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include "mu3io/config.h"
void mu3_io_config_load(
struct mu3_io_config *cfg,
const wchar_t *filename)
{
wchar_t key[16];
int i;
assert(cfg != NULL);
assert(filename != NULL);
cfg->vk_test = GetPrivateProfileIntW(L"io4", L"test", '1', filename);
cfg->vk_service = GetPrivateProfileIntW(L"io4", L"service", '2', filename);
cfg->vk_coin = GetPrivateProfileIntW(L"io4", L"coin", '3', filename);
}

16
mu3io/config.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
struct mu3_io_config {
uint8_t vk_test;
uint8_t vk_service;
uint8_t vk_coin;
};
void mu3_io_config_load(
struct mu3_io_config *cfg,
const wchar_t *filename);

View File

@ -10,5 +10,7 @@ mu3io_lib = static_library(
sources : [ sources : [
'mu3io.c', 'mu3io.c',
'mu3io.h', 'mu3io.h',
'config.c',
'config.h',
], ],
) )

View File

@ -5,12 +5,15 @@
#include <stdint.h> #include <stdint.h>
#include "mu3io/mu3io.h" #include "mu3io/mu3io.h"
#include "mu3io/config.h"
static uint8_t mu3_opbtn; static uint8_t mu3_opbtn;
static uint8_t mu3_left_btn; static uint8_t mu3_left_btn;
static uint8_t mu3_right_btn; static uint8_t mu3_right_btn;
static int16_t mu3_lever_pos; static int16_t mu3_lever_pos;
static int16_t mu3_lever_xpos; static int16_t mu3_lever_xpos;
static struct mu3_io_config mu3_io_cfg;
static bool mu3_io_coin;
uint16_t mu3_io_get_api_version(void) uint16_t mu3_io_get_api_version(void)
{ {
@ -19,6 +22,7 @@ uint16_t mu3_io_get_api_version(void)
HRESULT mu3_io_init(void) HRESULT mu3_io_init(void)
{ {
mu3_io_config_load(&mu3_io_cfg, L".\\segatools.ini");
return S_OK; return S_OK;
} }
@ -33,14 +37,23 @@ HRESULT mu3_io_poll(void)
mu3_left_btn = 0; mu3_left_btn = 0;
mu3_right_btn = 0; mu3_right_btn = 0;
if (GetAsyncKeyState('1') & 0x8000) { if (GetAsyncKeyState(mu3_io_cfg.vk_test) & 0x8000) {
mu3_opbtn |= MU3_IO_OPBTN_TEST; mu3_opbtn |= MU3_IO_OPBTN_TEST;
} }
if (GetAsyncKeyState('2') & 0x8000) { if (GetAsyncKeyState(mu3_io_cfg.vk_service) & 0x8000) {
mu3_opbtn |= MU3_IO_OPBTN_SERVICE; mu3_opbtn |= MU3_IO_OPBTN_SERVICE;
} }
if (GetAsyncKeyState(mu3_io_cfg.vk_coin) & 0x8000) {
if (!mu3_io_coin) {
mu3_io_coin = true;
mu3_opbtn |= MU3_IO_OPBTN_COIN;
}
} else {
mu3_io_coin = false;
}
memset(&xi, 0, sizeof(xi)); memset(&xi, 0, sizeof(xi));
XInputGetState(0, &xi); XInputGetState(0, &xi);
xb = xi.Gamepad.wButtons; xb = xi.Gamepad.wButtons;

View File

@ -7,6 +7,7 @@
enum { enum {
MU3_IO_OPBTN_TEST = 0x01, MU3_IO_OPBTN_TEST = 0x01,
MU3_IO_OPBTN_SERVICE = 0x02, MU3_IO_OPBTN_SERVICE = 0x02,
MU3_IO_OPBTN_COIN = 0x04,
}; };
enum { enum {