Debian Codegraph @

Descent3/cinematics.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "cinematics.h"cxx . . $ `<file>/Descent3/cinematics.h`/
20 #include "d3movie.h"cxx . . $ `<file>/Descent3/d3movie.h`/
21 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
22 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
23 #include "descent.h"cxx . . $ `<file>/Descent3/descent.h`/
24 #include "gamefont.h"cxx . . $ `<file>/Descent3/gamefont.h`/
25 #include "hlsoundlib.h"cxx . . $ `<file>/sndlib/hlsoundlib.h`/
26 #include "subtitles.h"cxx . . $ `<file>/Descent3/subtitles.h`/
27 #include "dedicated_server.h"cxx . . $ `<file>/lib/dedicated_server.h`/
28 #include "appdatabase.h"cxx . . $ `<file>/lib/appdatabase.h`/
29 #include "bitmap.h"cxx . . $ `<file>/lib/bitmap.h`/
30
31 #include <cstring>
32
33 static bool Cinematic_lib_initcxx . . $ Cinematic_lib_init. = false;
34 static int Cinematic_xcxx . . $ Cinematic_x. = 0, Cinematic_ycxx . . $ Cinematic_y. = 0, Cinematic_wcxx . . $ Cinematic_w. = 0, Cinematic_hcxx . . $ Cinematic_h. = 0;
35
36 static void CinematicCallbackcxx . . $ CinematicCallback(b1146eedae1e1d0b).(int mve_x, int mve_y, int frame_num);
37
38 ///////////////////////////////////////////////////////////////////////////////
39 // functions
40
41 bool InitCinematicscxx . . $ InitCinematics(c9857a73d68e59ba).() {
42 if (Dedicated_servercxx . . $ Dedicated_server.) {
43 Cinematic_lib_initcxx . . $ Cinematic_lib_init. = false;
44 return true;
45 }
46
47 char path[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
48 ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(path, Base_directorycxx . . $ Base_directory., "movies", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
49
50 if (mve_Initcxx . . $ mve_Init(5ae29d726ae57f88).(path, Sound_card_namecxx . . $ Sound_card_name.) != MVELIB_NOERRORcxx . . $ `Descent3/d3movie.h:28:9`!)
51 return false;
52
53 mve_SetCallbackcxx . . $ mve_SetCallback(d20c6d03e4c9e417).(CinematicCallbackcxx . . $ CinematicCallback(b1146eedae1e1d0b).);
54
55 Cinematic_lib_initcxx . . $ Cinematic_lib_init. = true;
56
57 return true;
58 }
59
60 void SetMoviePropertiescxx . . $ SetMovieProperties(fd0dc804468c4dff).(int x, int y, int w, int h, renderer_typecxx . . $ renderer_type# type) {
61 const bool kHiColorEnabled = true;
62 Cinematic_xcxx . . $ Cinematic_x. = x;
63 Cinematic_ycxx . . $ Cinematic_y. = y;
64 Cinematic_wcxx . . $ Cinematic_w. = w;
65 Cinematic_hcxx . . $ Cinematic_h. = h;
66 mve_SetRenderPropertiescxx . . $ mve_SetRenderProperties(aca4f8ddff7084a4).(x, y, w, h, type, kHiColorEnabled);
67 }
68
69 bool PlayMoviecxx . . $ PlayMovie(c53a6ef3278968b1).(const std::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &moviename) {
70 if (!Cinematic_lib_initcxx . . $ Cinematic_lib_init.)
71 return false;
72
73 // get in the right directory
74 std::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# filename = movienamecxx . . $ std/filesystem/__cxx11/path#path(3f42e2c2fac0d5fc).;
75 // check extension
76 std::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# extension = moviename.extensioncxx . . $ std/filesystem/__cxx11/path#extension(159787a050b29eb0).();
77 if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(extension.u8string().c_str(), ".mve") != 0 && stricmpcxx . . $ `linux/linux_fix.h:43:9`!(extension.u8string().c_str(), ".mv8") != 0) {
78 // we need an extension
79 filename.replace_extensioncxx . . $ std/filesystem/__cxx11/path#replace_extension(554473e25f389c7d).(extensioncxx . . $ std/filesystem/__cxx11/path#path(2f6c7066048c5333)..u8stringcxx . . $ std/filesystem/__cxx11/path#u8string(219584694fe2b248).() +cxx . . $ std/operator+(900ec9581c410ad9). ".mve");
80 }
81
82 // Initializes the subtitles for a given movie file
83 SubtInitSubtitlescxx . . $ SubtInitSubtitles(3f42e2c2fac0d5fc).(moviename);
84
85 SetMoviePropertiescxx . . $ SetMovieProperties(fd0dc804468c4dff).(0, 0, Max_window_wcxx . . $ Max_window_w., Max_window_hcxx . . $ Max_window_h., Renderer_typecxx . . $ Renderer_type.);
86
87 int mveerr = mve_PlayMoviecxx . . $ mve_PlayMovie(1d7e1054ee864747).(filename, Descentcxx . . $ Descent.);
88
89 // Shutdown the subtitle system
90 SubtCloseSubtitlescxx . . $ SubtCloseSubtitles(49f6e7a06ebc5aa8).();
91
92 bool retval = true;
93 if (mveerr != MVELIB_NOERRORcxx . . $ `Descent3/d3movie.h:28:9`!) {
94 mprintfcxx . . $ `ddebug/mono.h:82:9`!(1, "Movie error %d.\n", mveerr);
95 retval = false;
96 }
97
98 return retval;
99 }
100
101 tCinematiccxx . . $ tCinematic# *StartMoviecxx . . $ StartMovie(deeedf85fc470a35).(const char *moviename, bool looping) {
102 if (!Cinematic_lib_initcxx . . $ Cinematic_lib_init.)
103 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
104
105 // get in the right directory
106 char filename[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!];
107 strncpy(filename, moviename, sizeof(filename) - 1);
108 filename[sizeof(filename) - 1] = 0;
109
110 // check extension
111 const char *extension = strrchr(filename, '.');
112 if (extension == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! || (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(extension, ".mve") != 0 && stricmpcxx . . $ `linux/linux_fix.h:43:9`!(extension, ".mv8") != 0)) {
113 // we need an extension
114 strncat(filename, ".mve", sizeof(filename) - strlen(filename) - 1);
115 filename[sizeof(filename) - 1] = 0;
116 }
117
118 SetMoviePropertiescxx . . $ SetMovieProperties(fd0dc804468c4dff).(0, 0, Max_window_wcxx . . $ Max_window_w., Max_window_hcxx . . $ Max_window_h., Renderer_typecxx . . $ Renderer_type.);
119
120 FILEcxx . . $ FILE# *filehandle;
121 intptr_tcxx . . $ intptr_t# hMovie = mve_SequenceStartcxx . . $ mve_SequenceStart(290e4e6c58f7778e).(filename, &filehandle, Descentcxx . . $ Descent., looping);
122 if (hMovie == 0)
123 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
124
125 tCinematiccxx . . $ tCinematic# *mve = new tCinematiccxx . . $ tCinematic#;
126 mve->mvehandlecxx . . $ tCinematic#mvehandle. = hMovie;
127 mve->filehandlecxx . . $ tCinematic#filehandle. = filehandle;
128 mve->frame_chunkcxx . . $ tCinematic#frame_chunk..bm_arraycxx . . $ chunked_bitmap#bm_array. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
129 return mve;
130 }
131
132 bool FrameMoviecxx . . $ FrameMovie(3359cecd32520d88).(tCinematiccxx . . $ tCinematic# *mve, int x, int y, bool sequence) {
133 if (!Cinematic_lib_initcxx . . $ Cinematic_lib_init. || mve == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
134 return false;
135
136 int bm_handle;
137 intptr_tcxx . . $ intptr_t# hNewMovie = mve_SequenceFramecxx . . $ mve_SequenceFrame(688560c0d8406393).(mve->mvehandlecxx . . $ tCinematic#mvehandle., mve->filehandlecxx . . $ tCinematic#filehandle., sequence, &bm_handle);
138 if (hNewMovie != -1) {
139 // we must have looped, we have a new handle
140 mve->mvehandlecxx . . $ tCinematic#mvehandle. = hNewMovie;
141 }
142
143 // do chunk conversion and blt if absolutely necessary.
144 if (bm_handle > -1) {
145 if (x == -1) {
146 x = (Cinematic_wcxx . . $ Cinematic_w. - bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, 0)) / 2;
147 }
148
149 if (y == -1) {
150 y = (Cinematic_hcxx . . $ Cinematic_h. - bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, 0)) / 2;
151 }
152
153 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_ALWAYScxx . . $ `lib/renderer.h:399:9`!);
154 rend_CopyBitmapToFramebuffercxx . . $ rend_CopyBitmapToFramebuffer(b1146eedae1e1d0b).(bm_handle, x, y);
155 }
156
157 return (hNewMovie != -1);
158 }
159
160 void EndMoviecxx . . $ EndMovie(3a711f4329c1fcf3).(tCinematiccxx . . $ tCinematic# *mve) {
161 if (mve == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! || !Cinematic_lib_initcxx . . $ Cinematic_lib_init.)
162 return;
163
164 mve_SequenceClosecxx . . $ mve_SequenceClose(b2ca06e953f3967f).(mve->mvehandlecxx . . $ tCinematic#mvehandle., mve->filehandlecxx . . $ tCinematic#filehandle.);
165
166 if (mve->frame_chunkcxx . . $ tCinematic#frame_chunk..bm_arraycxx . . $ chunked_bitmap#bm_array.) {
167 bm_DestroyChunkedBitmapcxx . . $ bm_DestroyChunkedBitmap(1635f60f4d3c1317).(&mve->frame_chunkcxx . . $ tCinematic#frame_chunk.);
168 }
169
170 delete mve;
171 }
172
173 void CinematicCallbackcxx . . $ CinematicCallback(b1146eedae1e1d0b).(int mveX, int mveY, int frameNum) { SubtDrawSubtitlescxx . . $ SubtDrawSubtitles(d4f767463ce0a6b3).(frameNum); }