Skip to content

Commit f44886d

Browse files
authored
xTRC: Progress (#676)
* xTRC: Get xTRCReset to equivalent match * zVar: Correctly export bad_card_available S32 var * xTRC: Near equiv match on xTRC * Use -sym on for xTRC * xTRC: the wisdom of Seil
1 parent f9522c9 commit f44886d

File tree

4 files changed

+83
-5
lines changed

4 files changed

+83
-5
lines changed

configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ def MatchingFor(*versions):
464464
Object(NonMatching, "SB/Core/x/xString.cpp"),
465465
Object(Matching, "SB/Core/x/xSurface.cpp"),
466466
Object(Matching, "SB/Core/x/xTimer.cpp"),
467-
Object(NonMatching, "SB/Core/x/xTRC.cpp"),
467+
Object(NonMatching, "SB/Core/x/xTRC.cpp", extra_cflags=["-sym on"]),
468468
Object(Matching, "SB/Core/x/xutil.cpp"),
469469
Object(Matching, "SB/Core/x/xVec3.cpp"),
470470
Object(NonMatching, "SB/Game/zActionLine.cpp"),

src/SB/Core/x/xTRC.cpp

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,32 @@
33

44
#include "zGame.h"
55
#include "zGlobals.h"
6+
#include "xMath2.h"
7+
#include "xFont.h"
8+
#include "zVar.h"
69

710
#include <string.h>
811
#include <types.h>
912

1013
_tagTRCPadInfo gTrcPad[4];
1114
_tagTRCState gTrcDisk[2];
1215

13-
const char* message_text;
16+
static const char* __deadstripped_xTRC()
17+
{
18+
return "The Controller in Controller Socket 1 has been removed. Reconnect the Controller to continue with the game.\0"
19+
"The Controller in Controller Socket 1 is an unknown type. Connect a standard Controller to continue with the game.\0"
20+
"Please wait... Checking for the 'SpongeBob SquarePants: Battle for Bikini Bottom' Game Disc.\0"
21+
"The Disc Cover is open. If you want to continue the game, please close the Disc Cover.\0"
22+
"Please insert the 'SpongeBob SquarePants: Battle for Bikini Bottom' Game Disc.\0"
23+
"This is not the 'SpongeBob SquarePants: Battle for Bikini Bottom' Game Disc. Please insert the 'SpongeBob SquarePants: Battle for Bikini Bottom' Game Disc.\0"
24+
"The Game Disc could not be read. Please read the Nintendo GameCube\x99 Instruction Booklet for more information.\0"
25+
"An error has occurred. Turn the power off and refer to the Nintendo GameCube\x99 Instruction Booklet for further instructions.";
26+
}
27+
28+
static const char* message_text;
29+
30+
static const basic_rect<F32> screen_bounds = { 0.0f, 0.0f, 1.0f, 1.0f };
31+
static S32 yellow = 0xFFE600FF;
1432

1533
void xTRCInit()
1634
{
@@ -22,7 +40,23 @@ void xTRCInit()
2240
memset(gTrcDisk, 0, 8);
2341
}
2442

25-
void render_message(const char*);
43+
static void render_message(const char* s)
44+
{
45+
static xtextbox tb = xtextbox::create(xfont::create(1, NSCREENX(19.0f), NSCREENY(22.0f), 0.0f,
46+
*(iColor_tag*)&yellow, screen_bounds),
47+
screen_bounds, 0x2, 0.0f, 0.0f, 0.0f, 0.0f);
48+
49+
tb.set_text(s);
50+
tb.bounds = screen_bounds;
51+
tb.bounds.contract(0.1f);
52+
53+
tb.bounds.h = tb.yextent(true);
54+
tb.bounds.y = -(0.5f * tb.bounds.h + 0.5f);
55+
56+
render_fill_rect(tb.font.clip, xColorFromRGBA(0, 0, 0, 0xC8));
57+
58+
tb.render(true);
59+
}
2660

2761
void xTRCRender()
2862
{
@@ -43,9 +77,12 @@ void xTRCReset()
4377
if (isStall)
4478
{
4579
zGameModeSwitch(eGameMode_Game);
80+
xSndResume();
4681
}
82+
}
4783

48-
xSndResume();
84+
void xTRCPad(S32, _tagTRCState)
85+
{
4986
}
5087

5188
// SDA relocation shenanigans
@@ -62,6 +99,45 @@ void xTRCDisk(_tagTRCState state)
6299
}
63100
}
64101

65-
void xTRCPad(S32, _tagTRCState)
102+
void render_mem_card_no_space(S32 needed, S32 available, S32 neededFiles, bool enabled)
103+
{
104+
if (available < 0 && neededFiles != -1 && needed != -1)
105+
{
106+
available = 0;
107+
}
108+
109+
bad_card_needed = needed;
110+
bad_card_available = available;
111+
112+
char* error_text = "{i:text_mem_card_no_space}";
113+
if (neededFiles == 0 && needed > available)
114+
{
115+
error_text = "{i:text_mem_card_no_space_overwrite}";
116+
}
117+
else if ((neededFiles > 0 && needed > available) || neededFiles == -1 || needed > available)
118+
{
119+
error_text = "{i:text_mem_card_no_space_no_save}";
120+
}
121+
122+
RenderText(error_text, enabled);
123+
}
124+
125+
void RenderText(const char* text, bool enabled)
66126
{
127+
static xtextbox tb =
128+
xtextbox::create(xfont::create(1, NSCREENX(19.0f), NSCREENY(22.0f), 0.0f,
129+
xColorFromRGBA(0xFF, 0xE6, 0x00, 0xFF), screen_bounds),
130+
screen_bounds, 0x2, 0.0f, 0.0f, 0.0f, 0.0f);
131+
132+
tb.set_text(enabled ? text : "");
133+
tb.bounds = screen_bounds;
134+
tb.bounds.contract(0.1f);
135+
tb.bounds.h = tb.yextent(true);
136+
tb.bounds.y = -(0.5f * tb.bounds.h - 0.5f);
137+
tb.render(true);
138+
139+
if (!enabled)
140+
{
141+
render_fill_rect(tb.font.clip, xColorFromRGBA(0, 0, 0, 0xC8));
142+
}
67143
}

src/SB/Core/x/xTRC.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ void xTRCRender();
3636
void xTRCReset();
3737
void xTRCDisk(_tagTRCState state);
3838
void render_mem_card_no_space(S32 needed, S32 available, S32 neededFiles, bool enabled);
39+
void RenderText(const char* text, bool enabled);
3940

4041
#endif

src/SB/Game/zVar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct var_type
4747
};
4848

4949
extern S32 bad_card_needed;
50+
extern S32 bad_card_available;
5051

5152
void var_init();
5253
void zVarNewGame();

0 commit comments

Comments
 (0)