Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | #include "cutscene.h" |
2 | #include "drmem.h" |
||
3 | #include "errors.h" |
||
4 | #include "flicplay.h" |
||
5 | #include "globvars.h" |
||
6 | #include "globvrpb.h" |
||
7 | #include "graphics.h" |
||
8 | #include "harness/config.h" |
||
9 | #include "harness/hooks.h" |
||
10 | #include "harness/os.h" |
||
11 | #include "harness/trace.h" |
||
12 | #include "input.h" |
||
13 | #include "loading.h" |
||
14 | #include "pd/sys.h" |
||
15 | #include "smackw32/smackw32.h" |
||
16 | #include "sound.h" |
||
17 | #include "utility.h" |
||
18 | #include <stdlib.h> |
||
19 | #include <time.h> |
||
20 | |||
21 | tS32 gLast_demo_end_anim = -90000; |
||
22 | |||
23 | // IDA: void __usercall ShowCutScene(int pIndex@<EAX>, int pWait_end@<EDX>, int pSound_ID@<EBX>, br_scalar pDelay) |
||
24 | void ShowCutScene(int pIndex, int pWait_end, int pSound_ID, br_scalar pDelay) { |
||
25 | LOG_TRACE("(%d, %d, %d, %f)", pIndex, pWait_end, pSound_ID, pDelay); |
||
26 | |||
27 | gProgram_state.cut_scene = 1; |
||
28 | if (pSound_ID >= 0) { |
||
29 | DRS3LoadSound(pSound_ID); |
||
30 | SetFlicSound(pSound_ID, PDGetTotalTime() + 1000.f * pDelay); |
||
31 | } |
||
32 | SetNonFatalAllocationErrors(); |
||
33 | RunFlic(pIndex); |
||
34 | ResetNonFatalAllocationErrors(); |
||
35 | if (pWait_end) { |
||
36 | WaitForAKey(); |
||
37 | } else { |
||
38 | WaitForNoKeys(); |
||
39 | } |
||
40 | FadePaletteDown(); |
||
41 | ClearEntireScreen(); |
||
42 | if (pSound_ID >= 0) { |
||
43 | DRS3ReleaseSound(pSound_ID); |
||
44 | SetFlicSound(0, 0); |
||
45 | } |
||
46 | gProgram_state.cut_scene = 0; |
||
47 | } |
||
48 | |||
49 | // IDA: void __cdecl DoSCILogo() |
||
50 | void DoSCILogo(void) { |
||
51 | } |
||
52 | |||
53 | // IDA: void __cdecl DoStainlessLogo() |
||
54 | void DoStainlessLogo(void) { |
||
55 | LOG_TRACE("()"); |
||
56 | } |
||
57 | |||
58 | // IDA: void __usercall PlaySmackerFile(char *pSmack_name@<EAX>) |
||
59 | void PlaySmackerFile(char* pSmack_name) { |
||
60 | tPath_name the_path; |
||
61 | br_colour* br_colours_ptr; |
||
62 | tU8* smack_colours_ptr; |
||
63 | Smack* smk; |
||
64 | unsigned long i; // Pierre-Marie Baty -- fixed type |
||
65 | int j; |
||
66 | //int len; // Pierre-Marie Baty -- unused variable |
||
67 | int fuck_off; |
||
68 | LOG_TRACE("(\"%s\")", pSmack_name); |
||
69 | |||
70 | if (!gSound_override && !gCut_scene_override) { |
||
71 | StopMusic(); |
||
72 | FadePaletteDown(); |
||
73 | ClearEntireScreen(); |
||
74 | SmackSoundUseDirectSound(NULL); |
||
75 | br_colours_ptr = gCurrent_palette->pixels; |
||
76 | PathCat(the_path, gApplication_path, "CUTSCENE"); |
||
77 | PathCat(the_path, the_path, pSmack_name); |
||
78 | dr_dprintf("Trying to open smack file '%s'", the_path); |
||
79 | smk = SmackOpen(the_path, SMACKTRACKS, SMACKAUTOEXTRA); |
||
80 | if (smk == NULL) { |
||
81 | dr_dprintf("Unable to open smack file - attempt to load smack from CD..."); |
||
82 | if (GetCDPathFromPathsTxtFile(the_path)) { |
||
83 | strcat(the_path, gDir_separator); |
||
84 | strcat(the_path, "DATA"); |
||
85 | PathCat(the_path, the_path, "CUTSCENE"); |
||
86 | PathCat(the_path, the_path, pSmack_name); |
||
87 | if (PDCheckDriveExists(the_path)) { |
||
88 | smk = SmackOpen(the_path, SMACKTRACKS, SMACKAUTOEXTRA); |
||
89 | } |
||
90 | } else { |
||
91 | dr_dprintf("Can't get CD directory name"); |
||
92 | } |
||
93 | } |
||
94 | if (smk != NULL) { |
||
95 | dr_dprintf("Smack file opened OK"); |
||
96 | for (i = 1; i <= smk->Frames; i++) { |
||
97 | SmackToBuffer(smk, 0, 0, gBack_screen->row_bytes, gBack_screen->height, gBack_screen->pixels, 0); |
||
98 | |||
99 | if (smk->NewPalette) { |
||
100 | smack_colours_ptr = smk->Palette; |
||
101 | for (j = 0; j < 256; j++) { |
||
102 | br_colours_ptr[j] = (smack_colours_ptr[j * 3] << 16) | smack_colours_ptr[j * 3 + 2] | (smack_colours_ptr[j * 3 + 1] << 8); |
||
103 | } |
||
104 | |||
105 | // TOOD: remove the commented-out line below when smk->NewPalette is set correctly per-frame |
||
106 | // memset(gBack_screen->pixels, 0, gBack_screen->row_bytes * gBack_screen->height); |
||
107 | DRSetPalette(gCurrent_palette); |
||
108 | PDScreenBufferSwap(0); |
||
109 | EnsurePaletteUp(); |
||
110 | } |
||
111 | |||
112 | SmackDoFrame(smk); |
||
113 | if (i != smk->Frames) { |
||
114 | SmackNextFrame(smk); |
||
115 | } |
||
116 | PDScreenBufferSwap(0); |
||
117 | |||
118 | do { |
||
119 | fuck_off = AnyKeyDown() || EitherMouseButtonDown(); |
||
120 | } while (!fuck_off && SmackWait(smk)); |
||
121 | if (fuck_off) { |
||
122 | break; |
||
123 | } |
||
124 | } |
||
125 | FadePaletteDown(); |
||
126 | ClearEntireScreen(); |
||
127 | SmackClose(smk); |
||
128 | } else { |
||
129 | dr_dprintf("Smack file '%s' failed to open", pSmack_name); |
||
130 | } |
||
131 | StartMusic(); |
||
132 | } |
||
133 | } |
||
134 | |||
135 | // IDA: void __cdecl DoOpeningAnimation() |
||
136 | void DoOpeningAnimation(void) { |
||
137 | LOG_TRACE("()"); |
||
138 | |||
139 | PlaySmackerFile("LOGO.SMK"); |
||
140 | PlaySmackerFile(harness_game_info.defines.INTRO_SMK_FILE); |
||
141 | WaitForNoKeys(); |
||
142 | } |
||
143 | |||
144 | // IDA: void __cdecl DoNewGameAnimation() |
||
145 | void DoNewGameAnimation(void) { |
||
146 | LOG_TRACE("()"); |
||
147 | } |
||
148 | |||
149 | // IDA: void __cdecl DoGoToRaceAnimation() |
||
150 | void DoGoToRaceAnimation(void) { |
||
151 | LOG_TRACE("()"); |
||
152 | |||
15 | pmbaty | 153 | if (!gNet_mode) { |
1 | pmbaty | 154 | if (PercentageChance(50)) { |
155 | PlaySmackerFile("GARAGE2.SMK"); |
||
156 | } else { |
||
157 | PlaySmackerFile("GARAGE1.SMK"); |
||
158 | } |
||
159 | } |
||
160 | } |
||
161 | |||
162 | // IDA: void __cdecl DoEndRaceAnimation() |
||
163 | void DoEndRaceAnimation(void) { |
||
164 | int made_a_profit; |
||
165 | int went_up_a_rank; |
||
166 | LOG_TRACE("()"); |
||
167 | |||
168 | made_a_profit = gProgram_state.credits_earned >= gProgram_state.credits_lost; |
||
169 | went_up_a_rank = gProgram_state.credits_earned >= gProgram_state.credits_per_rank; |
||
170 | |||
171 | FadePaletteDown(); |
||
172 | |||
173 | if (gAusterity_mode || gNet_mode != eNet_mode_none) { |
||
174 | return; |
||
175 | } |
||
176 | if (gProgram_state.credits + gProgram_state.credits_earned - gProgram_state.credits_lost >= 0) { |
||
177 | if (made_a_profit && went_up_a_rank) { |
||
178 | PlaySmackerFile("SUCCESS.SMK"); |
||
179 | } else if (made_a_profit || went_up_a_rank) { |
||
180 | PlaySmackerFile("MUNDANE.SMK"); |
||
181 | } else { |
||
182 | PlaySmackerFile("UNSUCSES.SMK"); |
||
183 | } |
||
184 | } |
||
185 | } |
||
186 | |||
187 | // IDA: void __cdecl DoGameOverAnimation() |
||
188 | void DoGameOverAnimation(void) { |
||
189 | LOG_TRACE("()"); |
||
190 | |||
191 | StopMusic(); |
||
192 | PlaySmackerFile("CRASH.SMK"); |
||
193 | StartMusic(); |
||
194 | } |
||
195 | |||
196 | // IDA: void __cdecl DoGameCompletedAnimation() |
||
197 | void DoGameCompletedAnimation(void) { |
||
198 | LOG_TRACE("()"); |
||
199 | |||
200 | StopMusic(); |
||
201 | PlaySmackerFile("TOPRANK.SMK"); |
||
202 | StartMusic(); |
||
203 | } |
||
204 | |||
205 | void DoFeatureUnavailableInDemo(void) { |
||
206 | LOG_TRACE("()"); |
||
207 | |||
208 | PrintMemoryDump(0, "BEFORE DEMO-ONLY SCREEN"); |
||
209 | |||
210 | SuspendPendingFlic(); |
||
211 | FadePaletteDown(); |
||
212 | ShowCutScene(7, 1, 8502, gCut_delay_3); |
||
213 | FadePaletteDown(); |
||
214 | |||
215 | PrintMemoryDump(0, "AFTER DEMO-ONLY SCREEN"); |
||
216 | } |
||
217 | |||
218 | void DoFullVersionPowerpoint(void) { |
||
219 | LOG_TRACE("()"); |
||
220 | |||
221 | FadePaletteDown(); |
||
222 | DRSetPalette(gRender_palette); |
||
223 | if (harness_game_info.mode == eGame_splatpack_demo) { |
||
224 | PlaySmackerFile("DEMOEND.SMK"); |
||
225 | } else { |
||
226 | ShowCutScene(9, 0, 8503, gCut_delay_4); |
||
227 | } |
||
228 | FadePaletteDown(); |
||
229 | |||
230 | gLast_demo_end_anim = PDGetTotalTime(); |
||
231 | } |
||
232 | |||
233 | void DoDemoGoodbye(void) { |
||
234 | if (PDGetTotalTime() - gLast_demo_end_anim > 90000) { |
||
235 | DoFullVersionPowerpoint(); |
||
236 | } |
||
237 | } |
||
238 | |||
239 | // IDA: void __cdecl StartLoadingScreen() |
||
240 | void StartLoadingScreen(void) { |
||
241 | LOG_TRACE("()"); |
||
242 | |||
243 | PossibleService(); |
||
244 | if (gProgram_state.sausage_eater_mode) { |
||
245 | SplashScreenWith(harness_game_info.defines.GERMAN_LOADSCRN); |
||
246 | } else { |
||
247 | SplashScreenWith("LOADSCRN.PIX"); |
||
248 | } |
||
249 | } |