Update to spice2x-25-04-25 (pre-apply)

> broken commit
This commit is contained in:
[ ]
2025-05-07 00:25:31 +09:00
parent 04dee88276
commit c94de456b5
543 changed files with 78491 additions and 91698 deletions
+44 -10
View File
@@ -1,18 +1,22 @@
#include "pcm.h"
#include "acio/icca/icca.h"
#include "io.h"
#include "misc/wintouchemu.h"
#include "util/detour.h"
#include "util/utils.h"
#include "util/libutils.h"
#include "util/time.h"
namespace games::pcm {
uint32_t *(__cdecl *GsIo_GetState_orig)(uint32_t *state);
static double BILL_IN_TIME = 0;
static double BILL_DELAY = 2.0;
static int BillKind = 0;
static int bill_kind = 0;
static int __cdecl BillVali_GetEscrowBillKind() {
return BillKind;
return bill_kind;
}
static int __cdecl BillVali_GetCurrentStep() {
@@ -28,25 +32,25 @@ namespace games::pcm {
if (GameAPI::Buttons::getState(RI_MGR, buttons[games::pcm::Buttons::Insert1000YenBill])) {
log_misc("pcm", "1000 yen bill inserted");
BillKind = 1;
bill_kind = 1;
return true;
}
if (GameAPI::Buttons::getState(RI_MGR, buttons[games::pcm::Buttons::Insert2000YenBill])) {
log_misc("pcm", "2000 yen bill inserted");
BillKind = 2;
bill_kind = 2;
return true;
}
if (GameAPI::Buttons::getState(RI_MGR, buttons[games::pcm::Buttons::Insert5000YenBill])) {
log_misc("pcm", "5000 yen bill inserted");
BillKind = 3;
bill_kind = 3;
return true;
}
if (GameAPI::Buttons::getState(RI_MGR, buttons[games::pcm::Buttons::Insert10000YenBill])) {
log_misc("pcm", "10000 yen bill inserted");
BillKind = 4;
bill_kind = 4;
return true;
}
@@ -62,19 +66,42 @@ namespace games::pcm {
}
static bool __cdecl BillVali_IsWaiting() {
return true;
return BILL_IN_TIME == 0;
}
static int __cdecl BillVali_GetReceivedBill() {
static int bills_received = 0;
return ++bills_received;
if (BILL_IN_TIME == 0 && BillVali_IsEscrowNow()) {
BILL_IN_TIME = get_performance_seconds();
} else if ((BILL_IN_TIME != 0) && ((BILL_IN_TIME + BILL_DELAY) <= get_performance_seconds())) {
BILL_IN_TIME = 0;
switch (bill_kind) {
case 1:
return 1;
case 2:
return 2;
case 3:
return 5;
case 4:
return 10;
default:
return 0;
}
}
return 0;
}
static bool __cdecl BillVali_ReceiveBill(int) {
return true;
}
static bool __cdecl BillVali_ReceiveCancel() {
return true;
}
static bool __cdecl BillVali_SetAcceptBill(int) {
return true;
}
static uint32_t* __cdecl GsIo_GetState_hook(uint32_t *state) {
GsIo_GetState_orig(state);
@@ -92,6 +119,9 @@ namespace games::pcm {
// system.dll doesn't get loaded until later so load it now for hooking.
HMODULE system = libutils::try_library("system.dll");
// fix ICCA
acio::ICCA_COMPAT_ACTIVE = true;
// apply hooks
detour::trampoline("system.dll", "?GetState@GsIo@@SA?BVSTATE@1@XZ",
GsIo_GetState_hook, &GsIo_GetState_orig);
@@ -112,7 +142,11 @@ namespace games::pcm {
system, "?IsReady@GsBillVali@@SA_NXZ"));
detour::inline_hook(BillVali_ReceiveBill, libutils::try_proc(
system, "?ReceiveBill@GsBillVali@@SA_NH@Z"));
detour::inline_hook(BillVali_ReceiveCancel, libutils::try_proc(
system, "?ReceiveCancel@GsBillVali@@SAHXZ"));
detour::inline_hook(BillVali_GetEscrowBillKind, libutils::try_proc(
system, "?GetEscrowBillKind@GsBillVali@@SAHXZ"));
detour::inline_hook(BillVali_SetAcceptBill, libutils::try_proc(
system, "?SetAcceptBill@GsBillVali@@SA_NH@Z"));
}
}