From f44e6faa1efb901d89072e43b0e2d7e94e02780f Mon Sep 17 00:00:00 2001 From: escape209 Date: Tue, 6 Aug 2024 19:11:29 +0100 Subject: [PATCH] xTRC work (#345) --- src/SB/Core/x/xTRC.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++ src/SB/Core/x/xTRC.h | 4 ++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/SB/Core/x/xTRC.cpp b/src/SB/Core/x/xTRC.cpp index d067f5d3..a53fa711 100644 --- a/src/SB/Core/x/xTRC.cpp +++ b/src/SB/Core/x/xTRC.cpp @@ -1,7 +1,67 @@ #include "xTRC.h" +#include "xSnd.h" +#include "zGame.h" +#include "zGlobals.h" + +#include #include +_tagTRCPadInfo gTrcPad[4]; +_tagTRCState gTrcDisk[2]; + +const char* message_text; + +void xTRCInit() +{ + memset(gTrcPad, 0, sizeof(gTrcPad)); + gTrcPad[0].id = 0; + gTrcPad[1].id = 1; + gTrcPad[2].id = 2; + gTrcPad[3].id = 3; + memset(gTrcDisk, 0, 8); +} + +void render_message(const char*); + +void xTRCRender() +{ + if (message_text != NULL) + { + render_message(message_text); + } +} + +void xTRCReset() +{ + message_text = NULL; + globals.dontShowPadMessageDuringLoadingOrCutScene = false; + + eGameMode mode = gGameMode; + bool isStall = mode == eGameMode_Stall; + + if (isStall) + { + zGameModeSwitch(eGameMode_Game); + } + + xSndResume(); +} + +// SDA relocation shenanigans +void xTRCDisk(_tagTRCState state) +{ + if (state != TRC_DiskNotIdentified) + { + gTrcDisk[0] = state; + gTrcDisk[1] = TRC_DiskIdentified; + } + else + { + gTrcDisk[1] = TRC_DiskNotIdentified; + } +} + void xTRCPad(S32, _tagTRCState) { } diff --git a/src/SB/Core/x/xTRC.h b/src/SB/Core/x/xTRC.h index acba223c..cb255714 100644 --- a/src/SB/Core/x/xTRC.h +++ b/src/SB/Core/x/xTRC.h @@ -27,8 +27,10 @@ struct _tagTRCPadInfo : _tagiTRCPadInfo _tagTRCState state; }; -_tagTRCPadInfo gTrcPad[4]; +_tagTRCPadInfo gTrcPad[]; +_tagTRCState gTrcDisk[]; +void xTRCInit(); void xTRCPad(S32 pad_id, _tagTRCState state); void xTRCRender(); void xTRCReset();