-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo_title_screen.patch
279 lines (265 loc) · 8.65 KB
/
demo_title_screen.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
diff --git a/Makefile b/Makefile
index 9b15874..b44def8 100644
--- a/Makefile
+++ b/Makefile
@@ -64,7 +64,7 @@ DISCORDRPC ?= 0
# Enable rumble functions (Originally in Shindou)
RUMBLE_FEEDBACK ?= 0
# Enable Goddard (Mario Face)
-GODDARD_MFACE ?= 1
+GODDARD_MFACE ?= 0
# Enable Command Line Options
COMMAND_LINE_OPTIONS ?= 1
# Kaze MOP Objects Port, disabled by default
diff --git a/include/level_commands.h b/include/level_commands.h
index c5940bf..c9769f7 100644
--- a/include/level_commands.h
+++ b/include/level_commands.h
@@ -22,6 +22,7 @@
#define VAR_CURR_ACT_NUM 2
#define VAR_CURR_LEVEL_NUM 3
#define VAR_CURR_AREA_INDEX 4
+#define VAR_CURR_DEMO_START_BUTTON 5
#define WARP_CHECKPOINT 0x80
#define WARP_NO_CHECKPOINT 0x00
@@ -102,6 +103,7 @@ enum LevelCommandsIDList
#ifdef BETTERCAMERA
LVL_SCRIPT_CMD_PUPPYVOLUME,
#endif
+ LVL_SCRIPT_DEMO_SCREEN,
};
#ifdef NO_SEGMENTED_MEMORY
diff --git a/levels/intro/script.c b/levels/intro/script.c
index 18f2eb0..6f752a6 100644
--- a/levels/intro/script.c
+++ b/levels/intro/script.c
@@ -9,6 +9,7 @@
#include "game/area.h"
#include "game/level_update.h"
#include "menu/title_screen.h"
+#include "extras/demo_screen.h"
#include "levels/scripts.h"
#include "levels/menu/header.h"
@@ -117,18 +118,27 @@ const LevelScript level_intro_mario_head_dizzy[] = {
#else
const LevelScript level_intro_mario_head_regular[] = {
INIT_LEVEL(),
- CALL_LOOP(/*arg*/ LVL_INTRO_REGULAR, /*func*/ lvl_intro_update),
- JUMP_IF(/*op*/ OP_EQ, /*arg*/ 100, script_intro_L1),
- JUMP_IF(/*op*/ OP_EQ, /*arg*/ 101, script_intro_L2),
- EXIT_AND_EXECUTE(/*seg*/ 0x14, _menuSegmentRomStart, _menuSegmentRomEnd, level_main_menu_entry_1),
+ BLACKOUT(/*active*/ TRUE),
+ LOAD_RAW(/*seg*/ 0x13, _behaviorSegmentRomStart, _behaviorSegmentRomEnd),
+ LOAD_MIO0_TEXTURE(/*seg*/ 0x0A, _title_screen_bg_mio0SegmentRomStart, _title_screen_bg_mio0SegmentRomEnd),
+ ALLOC_LEVEL_POOL(),
+ FREE_LEVEL_POOL(),
+ SLEEP(/*frames*/ 2),
+ BLACKOUT(/*active*/ FALSE),
+
+ DEMO_SCRIPT(LVL_DEMO_CLEAR), // we need to do this or else file select will be tainted with inputs
+ GET_OR_SET(/*op*/ OP_GET, /*var*/ VAR_CURR_DEMO_START_BUTTON),
+ JUMP_IF(/*op*/ OP_EQ, /*arg*/ 1, script_intro_L1), // was start pressed when demo ended last time?
+
+ SET_MENU_MUSIC(/*seq*/ SEQ_MENU_TITLE_SCREEN),
+ TRANSITION(/*transType*/ WARP_TRANSITION_FADE_FROM_STAR, /*time*/ 20, /*color*/ 0x00, 0x00, 0x00),
+ SLEEP(/*frames*/ 20),
+ DEMO_SCRIPT(LVL_DEMO_SET_ADVANCE), // advance the demo ID manually with a new command which sets the level as script register
+ JUMP(script_intro_L4), // go to ingame
};
const LevelScript level_intro_mario_head_dizzy[] = {
- INIT_LEVEL(),
- CALL_LOOP(/*arg*/ LVL_INTRO_GAME_OVER, /*func*/ lvl_intro_update),
- JUMP_IF(/*op*/ OP_EQ, /*arg*/ 100, script_intro_L1),
- JUMP_IF(/*op*/ OP_EQ, /*arg*/ 101, script_intro_L2),
- EXIT_AND_EXECUTE(/*seg*/ 0x14, _introSegmentRomStart, _introSegmentRomEnd, level_intro_splash_screen),
+ EXIT_AND_EXECUTE(/*seg*/ 0x14, _introSegmentRomStart, _introSegmentRomEnd, level_intro_mario_head_regular),
};
#endif
@@ -144,6 +154,7 @@ const LevelScript level_intro_entry_4[] = {
AREA(/*index*/ 1, intro_geo_000414),
END_AREA(),
+ DEMO_SCRIPT(LVL_DEMO_CLEAR), // we need to do this or else file select will be tainted with inputs
FREE_LEVEL_POOL(),
LOAD_AREA(/*area*/ 1),
diff --git a/src/engine/level_script.c b/src/engine/level_script.c
index 1d3f7dc..64418d3 100644
--- a/src/engine/level_script.c
+++ b/src/engine/level_script.c
@@ -32,6 +32,8 @@
#include "extras/bettercamera.h"
#endif
+#include "extras/demo_screen.h"
+
#define CMD_GET(type, offset) (*(type *) (CMD_PROCESS_OFFSET(offset) + (u8 *) sCurrentCmd))
// These are equal
@@ -767,6 +769,9 @@ static void level_cmd_get_or_set_var(void) {
case 4:
gCurrAreaIndex = sRegister;
break;
+ case 5:
+ gDemoPressedStart = sRegister;
+ break;
}
} else {
switch (CMD_GET(u8, 3)) {
@@ -785,6 +790,9 @@ static void level_cmd_get_or_set_var(void) {
case 4:
sRegister = gCurrAreaIndex;
break;
+ case 5:
+ sRegister = gDemoPressedStart;
+ break;
}
}
@@ -825,6 +833,37 @@ static void level_cmd_puppyvolume(void) {
}
#endif
+void level_cmd_demo(void) {
+ s16 screenDemoLvls[] = {
+ LEVEL_BOWSER_1,
+ LEVEL_WF,
+ LEVEL_CCM,
+ LEVEL_BBH,
+ LEVEL_JRB,
+ LEVEL_HMC,
+ LEVEL_PSS
+ };
+
+ s16 count = ARRAY_COUNT(screenDemoLvls) - 1;
+
+ switch (CMD_GET(s16, 2)) {
+ case LVL_DEMO_SET_ADVANCE:
+ start_demo_intro(0);
+ if (gScreenDemoLevelID == count) {
+ sRegister = screenDemoLvls[count];
+ gScreenDemoLevelID = 0;
+ } else {
+ sRegister = screenDemoLvls[gScreenDemoLevelID++];
+ }
+ break;
+ case LVL_DEMO_CLEAR:
+ gCurrDemoInput = NULL;
+ break;
+ }
+
+ sCurrentCmd = CMD_NEXT;
+}
+
static void (*LevelScriptJumpTable[])(void) = {
/*00*/ level_cmd_load_and_execute,
/*01*/ level_cmd_exit_and_execute,
@@ -890,6 +929,7 @@ static void (*LevelScriptJumpTable[])(void) = {
#ifdef BETTERCAMERA
/*3D*/ level_cmd_puppyvolume,
#endif
+ level_cmd_demo,
};
#ifdef TOUCH_CONTROLS
diff --git a/src/extras/demo_screen.c b/src/extras/demo_screen.c
new file mode 100644
index 0000000..2545f89
--- /dev/null
+++ b/src/extras/demo_screen.c
@@ -0,0 +1,46 @@
+#include <ultra64.h>
+#include "sm64.h"
+
+#include "demo_screen.h"
+#include "game/area.h"
+#include "game/game_init.h"
+#include "game/memory.h"
+#include "game/print.h"
+#include "level_table.h"
+
+s16 gDemoPressedStart = FALSE;
+s16 gScreenDemoLevelID = 0;
+
+u16 gDemoInputListIDForIntro = 0;
+
+void print_intro_text_demo(void) {
+ if (gControllerBits == 0) {
+ print_text_centered(160, 20, "NO CONTROLLER");
+ } else {
+ print_text_centered(160, 164, "SUPER MARIO 64");
+ print_text_centered(160, 128, "MADE BY");
+ print_text_centered(160, 110, "NINTENDO");
+ print_text_centered(160, 38, "PRESS START");
+ print_text_centered(160, 20, "COPYRIGHT 1996");
+ }
+}
+
+s32 start_demo_intro(s16 timer) {
+ gCurrDemoInput = NULL;
+ gDemoPressedStart = FALSE;
+ // start the mario demo animation for the demo list.
+ load_patchable_table(&gDemoInputsBuf, gDemoInputListIDForIntro);
+
+ // if the next demo sequence ID is the count limit, reset it back to
+ // the first sequence.
+
+ if((++gDemoInputListIDForIntro) == gDemoInputsBuf.dmaTable->count)
+ gDemoInputListIDForIntro = 0;
+
+ // add 1 (+4) to the pointer to skip the demoID.
+ gCurrDemoInput = ((struct DemoInput *) gDemoInputsBuf.bufTarget) + 1;
+ timer = (s8)((struct DemoInput *) gDemoInputsBuf.bufTarget)->timer;
+ gCurrSaveFileNum = 1;
+ gCurrActNum = 6;
+ return timer;
+}
diff --git a/src/extras/demo_screen.h b/src/extras/demo_screen.h
new file mode 100644
index 0000000..8f0efc6
--- /dev/null
+++ b/src/extras/demo_screen.h
@@ -0,0 +1,24 @@
+#ifndef DEMO_SCREEN_H
+#define DEMO_SCREEN_H
+
+#include "level_commands.h"
+
+extern s16 gDemoPressedStart;
+extern s16 gScreenDemoLevelID;
+
+extern u16 gDemoInputListIDForIntro;
+
+enum LevelScriptDemoArgs {
+ LVL_DEMO_SET_ADVANCE,
+ LVL_DEMO_CLEAR
+};
+
+extern void print_intro_text_demo(void);
+extern s32 start_demo_intro(s16 timer);
+
+extern void level_cmd_demo(void);
+
+#define DEMO_SCRIPT(arg) \
+ CMD_BBH(LVL_SCRIPT_DEMO_SCREEN, 0x04, arg)
+
+#endif // OPTIONS_MENU_H
diff --git a/src/game/level_update.c b/src/game/level_update.c
index 8f28b73..50ce145 100644
--- a/src/game/level_update.c
+++ b/src/game/level_update.c
@@ -47,6 +47,8 @@
#include "extras/bettercamera.h"
#endif
+#include "extras/demo_screen.h"
+
#define PLAY_MODE_NORMAL 0
#define PLAY_MODE_PAUSED 2
#define PLAY_MODE_CHANGE_AREA 3
@@ -1010,12 +1012,13 @@ void basic_update(UNUSED s16 *arg) {
s32 play_mode_normal(void) {
if (gCurrDemoInput != NULL) {
- print_intro_text();
+ print_intro_text_demo();
if (gPlayer1Controller->buttonPressed & END_DEMO) {
level_trigger_warp(gMarioState,
gCurrLevelNum == LEVEL_PSS ? WARP_OP_DEMO_END : WARP_OP_DEMO_NEXT);
} else if (!gWarpTransition.isActive && sDelayedWarpOp == WARP_OP_NONE
&& (gPlayer1Controller->buttonPressed & START_BUTTON)) {
+ gDemoPressedStart = TRUE;
level_trigger_warp(gMarioState, WARP_OP_DEMO_NEXT);
}
}