Skip to content

Commit a4f7c42

Browse files
author
Niko
committed
progress
1 parent ed7d9ba commit a4f7c42

5 files changed

Lines changed: 97 additions & 27 deletions

File tree

psx-modding-toolchain/games/CrashTeamRacing/mods/Standalones/Screensaver/buildList.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55

66
// Hooks
77
common, exe, BOTS_SetRotation, -0x8, src/hookUpdate.s
8+
common, exe, DotLights_AudioAndVideo, -0x8, src/hookTrafficLight.s
89

910
common, exe, rdata_free, 0x0, src/main.c

psx-modding-toolchain/games/CrashTeamRacing/mods/Standalones/Screensaver/src/hookInit.s

Lines changed: 0 additions & 2 deletions
This file was deleted.

psx-modding-toolchain/games/CrashTeamRacing/mods/Standalones/Screensaver/src/hookStartLoading.s

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.set noreorder
2+
j RunTrafficLightHook

psx-modding-toolchain/games/CrashTeamRacing/mods/Standalones/Screensaver/src/main.c

Lines changed: 94 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ void DecalFont_DrawLine(char*, int, int, int, int);
44
void DrawTextBackground(RECT* r, int flag, void* ot);
55
void EndOfRace_DrawAllComments();
66
void MM_JumpTo_Scrapbook();
7+
void Level_RequestNewLEV(int level);
78

89
RECT window1 = {0, 0, 400, 130};
910
char options[14] = "\0";
@@ -66,14 +67,49 @@ char* linePlayer[4] =
6667
#error HookCups needs a macro for addresses
6768
#endif
6869

70+
// first frame after spawning is complete
71+
void RunTrafficLightHook()
72+
{
73+
// BORDER
74+
if(data.characterIDs[5] == 1)
75+
sdata.gGT->gameMode1 |= 0x20;
76+
}
77+
6978
void RunUpdateHook()
7079
{
71-
int i;
72-
7380
struct GamepadBuffer* gpb;
7481
short* cIDs;
7582
int tap;
7683

84+
int i = 0;
85+
86+
87+
88+
// === Initial Essentials ===
89+
90+
91+
92+
// if 1P or 2P arcade,
93+
// characterIDs for AIs are overwritten
94+
// after we start the loading anyway
95+
#define PLAYER1 cIDs[0]
96+
#define PLAYER2 cIDs[1]
97+
#define PLAYER3 cIDs[2]
98+
#define PLAYER4 cIDs[3]
99+
#define TRACK cIDs[4]
100+
#define BORDER cIDs[5]
101+
#define PLAYERS cIDs[6]
102+
#define ROW cIDs[7]
103+
104+
// saves instructions by sharing pointer
105+
cIDs = &data.characterIDs[0];
106+
107+
// arcade mode (ignored in 3P/4P)
108+
sdata.gGT->gameMode1 |= 0x400000;
109+
110+
// prevent error message for controllers
111+
sdata.gGT->numScreens = 1;
112+
77113
// lock, dont decrease,
78114
// prevents main menu from leaving,
79115
// prevents demo mode from leaving
@@ -86,29 +122,27 @@ void RunUpdateHook()
86122
// NOP function
87123
*(int*)((int)EndOfRace_DrawAllComments + 0) = 0x3E00008;
88124
*(int*)((int)EndOfRace_DrawAllComments + 4) = 0;
125+
126+
// remove battle mode
127+
sdata.gGT->gameMode1 &= 0xFFFFFFDF;
89128
}
90129

91130
tap = sdata.PtrGamepadSystem->controller[0].buttonsTapped;
92131

93-
// saves instructions by sharing pointer
94-
cIDs = &data.characterIDs[0];
132+
// shut any menu
133+
sdata.ptrActiveMenuBox = 0;
134+
95135

96-
// if 1P or 2P arcade,
97-
// characterIDs for AIs are overwritten
98-
// after we start the loading anyway
99-
#define PLAYER1 cIDs[0]
100-
#define PLAYER2 cIDs[1]
101-
#define PLAYER3 cIDs[2]
102-
#define PLAYER4 cIDs[3]
103-
#define TRACK cIDs[4]
104-
#define BORDER cIDs[5]
105-
#define PLAYERS cIDs[6]
106136

137+
// ==== Menu Logic and Input ====
138+
139+
140+
107141
// from custom cups
108142
#define SIN_TRACK() *(char*)(SIN_ADDR + SIN_SIZE*TRACK + 0)
109143

110144
// defaults
111-
if(cIDs[7] == 7)
145+
if(ROW == 7)
112146
{
113147
PLAYER1 = 0;
114148
PLAYER2 = 1;
@@ -117,14 +151,43 @@ void RunUpdateHook()
117151
TRACK = 0;
118152
BORDER = 0;
119153
PLAYERS = 4;
120-
121-
cIDs[7] = 0;
154+
ROW = 0;
155+
}
156+
157+
if(tap == BTN_RIGHT)
158+
{
159+
if(ROW == 0) TRACK++;
160+
if(ROW == 1) BORDER++;
161+
if(ROW == 2) PLAYERS++;
162+
163+
for(i < 0; i < 4; i++)
164+
{
165+
if(ROW == 3+i) cIDs[i]++;
166+
}
122167
}
123168

169+
if(tap == BTN_LEFT)
170+
{
171+
if(ROW == 0) TRACK--;
172+
if(ROW == 1) BORDER--;
173+
if(ROW == 2) PLAYERS--;
174+
175+
for(i < 0; i < 4; i++)
176+
{
177+
if(ROW == 3+i) cIDs[i]--;
178+
}
179+
}
180+
181+
if(tap == BTN_UP) ROW--;
182+
if(tap == BTN_DOWN) ROW++;
183+
184+
if(ROW < 0) ROW = 0;
185+
if(ROW > 2+PLAYERS) ROW = 2+PLAYERS;
186+
124187
for(i < 0; i < 4; i++)
125188
{
126189
if(cIDs[i] < 0) cIDs[i] = 0;
127-
if(cIDs[i] > 8) cIDs[i] = 8;
190+
if(cIDs[i] > 0xF) cIDs[i] = 0xF;
128191
}
129192

130193
if(TRACK < 0) TRACK = 0;
@@ -133,14 +196,17 @@ void RunUpdateHook()
133196
if(BORDER < 0) BORDER = 0;
134197
if(BORDER > 1) BORDER = 1;
135198

136-
if(PLAYERS < 0) PLAYERS = 0;
199+
if(PLAYERS < 1) PLAYERS = 1;
137200
if(PLAYERS > 4) PLAYERS = 4;
201+
202+
203+
204+
// ==== Draw Menu ====
205+
138206

139-
// shut any menu
140-
sdata.ptrActiveMenuBox = 0;
141207

142-
// draw custom menu
143-
DecalFont_DrawLine(arrowText, 20, 10, 2, 0);
208+
if(ROW <= 2) DecalFont_DrawLine(arrowText, 20, 10 + ROW * 10, 2, 0);
209+
else DecalFont_DrawLine(arrowText, 20, 20 + ROW * 10, 2, 0);
144210

145211
// TRACK
146212
DecalFont_DrawLine(line0, 40, 10, 2, 14);
@@ -178,6 +244,11 @@ void RunUpdateHook()
178244
// These background boxes are the same used in Battle/VS End-Of-Race comments
179245
DrawTextBackground(&window1,1,sdata.gGT->backBuffer->otMem.startPlusFour);
180246

247+
248+
249+
// === Starting Demo Mode ===
250+
251+
181252
// input
182253
if((tap & BTN_START) != 0)
183254
{

0 commit comments

Comments
 (0)