| 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 <cstring> |
| 20 | |
| 21 | #include "application.h"cxx . . $ `<file>/lib/application.h`/ |
| 22 | #include "args.h"cxx . . $ `<file>/Descent3/args.h`/ |
| 23 | #include "bitmap.h"cxx . . $ `<file>/lib/bitmap.h`/ |
| 24 | #include "d3movie.h"cxx . . $ `<file>/Descent3/d3movie.h`/ |
| 25 | #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/ |
| 26 | #include "ddvid.h"cxx . . $ `<file>/lib/ddvid.h`/ |
| 27 | #include "game.h"cxx . . $ `<file>/Descent3/game.h`/ |
| 28 | #include "gamefont.h"cxx . . $ `<file>/Descent3/gamefont.h`/ |
| 29 | #include "grtext.h"cxx . . $ `<file>/grtext/grtext.h`/ |
| 30 | #include "mem.h"cxx . . $ `<file>/mem/mem.h`/ |
| 31 | #include "mvelib.h"cxx . . $ `<file>/libmve/mvelib.h`/ |
| 32 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 33 | #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/ |
| 34 | |
| 35 | namespacecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/ { |
| 36 | MovieFrameCallback_fpcxx . . $ MovieFrameCallback_fp# Movie_callbackcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_callback. = nullptr; |
| 37 | uint16_tcxx . . $ uint16_t# CurrentPalettecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/CurrentPalette.[256]; |
| 38 | int Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle. = -1; |
| 39 | uint32_tcxx . . $ uint32_t# Movie_current_framenumcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_current_framenum. = 0; |
| 40 | bool Movie_loopingcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_looping. = false; |
| 41 | } // namespace |
| 42 | |
| 43 | static void *CallbackAlloccxx . . $ CallbackAlloc(52408c21a1e21ff7).(uint32_tcxx . . $ uint32_t# size); |
| 44 | static void CallbackFreecxx . . $ CallbackFree(5d22bdacc48458e8).(void *p); |
| 45 | static uint32_tcxx . . $ uint32_t# CallbackFileReadcxx . . $ CallbackFileRead(e448eb38b8391a4e).(void *stream, void *pBuffer, uint32_tcxx . . $ uint32_t# bufferCount); |
| 46 | static void InitializePalettecxx . . $ InitializePalette(49f6e7a06ebc5aa8).(); |
| 47 | static void CallbackSetPalettecxx . . $ CallbackSetPalette(1b559f841397e97b).(const uint8_tcxx . . $ uint8_t# *pBuffer, uint32_tcxx . . $ uint32_t# start, uint32_tcxx . . $ uint32_t# count); |
| 48 | static void CallbackShowFramecxx . . $ CallbackShowFrame(757904e8a083ae7f).(uint8_tcxx . . $ uint8_t# *buf, uint32_tcxx . . $ uint32_t# bufw, uint32_tcxx . . $ uint32_t# bufh, uint32_tcxx . . $ uint32_t# sx, |
| 49 | uint32_tcxx . . $ uint32_t# sy, uint32_tcxx . . $ uint32_t# w, uint32_tcxx . . $ uint32_t# h, uint32_tcxx . . $ uint32_t# dstx, uint32_tcxx . . $ uint32_t# dsty, |
| 50 | uint32_tcxx . . $ uint32_t# hicolor); |
| 51 | |
| 52 | #ifndef NO_MOVIES |
| 53 | static bool mve_InitSoundcxx . . $ mve_InitSound(c9857a73d68e59ba).(); |
| 54 | static void mve_CloseSoundcxx . . $ mve_CloseSound(49f6e7a06ebc5aa8).(); |
| 55 | #endif |
| 56 | |
| 57 | // sets the directory where movies are stored |
| 58 | int mve_Initcxx . . $ mve_Init(5ae29d726ae57f88).(const char *dir, const char *sndcard) { |
| 59 | #ifndef NO_MOVIES |
| 60 | return MVELIB_NOERRORcxx . . $ `Descent3/d3movie.h:28:9`!; |
| 61 | #else |
| 62 | return MVELIB_INIT_ERROR; |
| 63 | #endif |
| 64 | } |
| 65 | |
| 66 | // callback called per frame of playback of movies. |
| 67 | void mve_SetCallbackcxx . . $ mve_SetCallback(d20c6d03e4c9e417).(MovieFrameCallback_fpcxx . . $ MovieFrameCallback_fp# callBack) { |
| 68 | #ifndef NO_MOVIES |
| 69 | Movie_callbackcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_callback. = callBack; |
| 70 | #endif |
| 71 | } |
| 72 | |
| 73 | // used to tell movie library how to render movies. |
| 74 | void mve_SetRenderPropertiescxx . . $ mve_SetRenderProperties(aca4f8ddff7084a4).(int16_t x, int16_t y, int16_t w, int16_t h, renderer_typecxx . . $ renderer_type# type, bool hicolor) {} |
| 75 | |
| 76 | #if defined(POSIXcxx . . $ `<built-in>:480:9`!) |
| 77 | // locates the case-sensitive movie file name |
| 78 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# mve_FindMovieFileRealNamecxx . . $ mve_FindMovieFileRealName(4ac62a867fe4334a).(const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &movie) { |
| 79 | // split into directory and file... |
| 80 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# t_file = movie.filenamecxx . . $ std/filesystem/__cxx11/path#filename(159787a050b29eb0).(); |
| 81 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# t_dir = movie.parent_pathcxx . . $ std/filesystem/__cxx11/path#parent_path(159787a050b29eb0).(); |
| 82 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# t_outcxx . . $ std/filesystem/__cxx11/path#path(ced63f7c635d850d).; |
| 83 | |
| 84 | // found a directory? |
| 85 | if (!t_dir.emptycxx . . $ std/filesystem/__cxx11/path#empty(3482b152b9333168).()) { |
| 86 | // map the bits (or fail) |
| 87 | t_out =cxx . . $ std/filesystem/__cxx11/path#`operator=`(9c9aa2f17f237d0f). cf_FindRealFileNameCaseInsensitivecxx . . $ cf_FindRealFileNameCaseInsensitive(578e0438ad5f0e7e).(t_file, t_dir); |
| 88 | if (t_out.emptycxx . . $ std/filesystem/__cxx11/path#empty(3482b152b9333168).()) |
| 89 | return t_outcxx . . $ std/filesystem/__cxx11/path#path(91601bf9ad65ca31).; |
| 90 | // re-assemble |
| 91 | return (t_dir /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). t_out); |
| 92 | } else { |
| 93 | // just a file, map that |
| 94 | t_out =cxx . . $ std/filesystem/__cxx11/path#`operator=`(9c9aa2f17f237d0f). cf_FindRealFileNameCaseInsensitivecxx . . $ cf_FindRealFileNameCaseInsensitive(578e0438ad5f0e7e).(t_file); |
| 95 | if (t_out.emptycxx . . $ std/filesystem/__cxx11/path#empty(3482b152b9333168).()) |
| 96 | return t_outcxx . . $ std/filesystem/__cxx11/path#path(91601bf9ad65ca31).; |
| 97 | // re-assemble |
| 98 | return t_outcxx . . $ std/filesystem/__cxx11/path#path(91601bf9ad65ca31).; |
| 99 | } |
| 100 | } |
| 101 | #endif |
| 102 | |
| 103 | // plays a movie using the current screen. |
| 104 | int mve_PlayMoviecxx . . $ mve_PlayMovie(1d7e1054ee864747).(const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &pMovieName, oeApplicationcxx . . $ oeApplication# *pApp) { |
| 105 | #ifndef NO_MOVIES |
| 106 | // first, find that movie.. |
| 107 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# real_namecxx . . $ std/filesystem/__cxx11/path#path(ced63f7c635d850d).; |
| 108 | #if defined(POSIXcxx . . $ `<built-in>:480:9`!) |
| 109 | real_name =cxx . . $ std/filesystem/__cxx11/path#`operator=`(9c9aa2f17f237d0f). mve_FindMovieFileRealNamecxx . . $ mve_FindMovieFileRealName(4ac62a867fe4334a).(pMovieName); |
| 110 | if (real_name.emptycxx . . $ std/filesystem/__cxx11/path#empty(3482b152b9333168).()) { |
| 111 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "MOVIE: No such file %s\n", pMovieName.u8string().c_str()); |
| 112 | return MVELIB_FILE_ERRORcxx . . $ `Descent3/d3movie.h:29:9`!; |
| 113 | } |
| 114 | #else |
| 115 | real_name = pMovieName; |
| 116 | #endif |
| 117 | // open movie file. |
| 118 | FILEcxx . . $ FILE# *hFile = fopen(real_name.u8stringcxx . . $ std/filesystem/__cxx11/path#u8string(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), "rb"); |
| 119 | if (hFile == nullptr) { |
| 120 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "MOVIE: Unable to open %s\n", real_name.u8string().c_str()); |
| 121 | return MVELIB_FILE_ERRORcxx . . $ `Descent3/d3movie.h:29:9`!; |
| 122 | } |
| 123 | |
| 124 | // setup |
| 125 | MVE_sfCallbackscxx . . $ MVE_sfCallbacks(d9e6b75645a4c6c8).(CallbackShowFramecxx . . $ CallbackShowFrame(757904e8a083ae7f).); |
| 126 | MVE_memCallbackscxx . . $ MVE_memCallbacks(19c120d411afc1d).(CallbackAlloccxx . . $ CallbackAlloc(52408c21a1e21ff7)., CallbackFreecxx . . $ CallbackFree(5d22bdacc48458e8).); |
| 127 | MVE_ioCallbackscxx . . $ MVE_ioCallbacks(db0132fb63dbf97d).(CallbackFileReadcxx . . $ CallbackFileRead(e448eb38b8391a4e).); |
| 128 | MVE_palCallbackscxx . . $ MVE_palCallbacks(93fa3d6c1e1dd934).(CallbackSetPalettecxx . . $ CallbackSetPalette(1b559f841397e97b).); |
| 129 | InitializePalettecxx . . $ InitializePalette(49f6e7a06ebc5aa8).(); |
| 130 | Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle. = -1; |
| 131 | |
| 132 | if (!mve_InitSoundcxx . . $ mve_InitSound(c9857a73d68e59ba).()) { |
| 133 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Failed to initialize sound\n"); |
| 134 | fclose(hFile); |
| 135 | return MVELIB_INIT_ERRORcxx . . $ `Descent3/d3movie.h:32:9`!; |
| 136 | } |
| 137 | |
| 138 | MVESTREAMcxx . . $ MVESTREAM# *mve = MVE_rmPrepMoviecxx . . $ MVE_rmPrepMovie(2c2ed7ae2903cf25).(hFile, -1, -1, 0); |
| 139 | if (mve == nullptr) { |
| 140 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Failed to prepMovie %s\n", pMovieName.u8string().c_str()); |
| 141 | fclose(hFile); |
| 142 | mve_CloseSoundcxx . . $ mve_CloseSound(49f6e7a06ebc5aa8).(); |
| 143 | return MVELIB_INIT_ERRORcxx . . $ `Descent3/d3movie.h:32:9`!; |
| 144 | } |
| 145 | |
| 146 | bool aborted = false; |
| 147 | Movie_current_framenumcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_current_framenum. = 0; |
| 148 | int result; |
| 149 | while ((result = MVE_rmStepMoviecxx . . $ MVE_rmStepMovie(c6a4a7571c8c3481).(mve)) == 0) { |
| 150 | // let the OS do its thing |
| 151 | pApp->defercxx . . $ oeApplication#defer(db52760e79bf9054).(); |
| 152 | |
| 153 | // check for bail |
| 154 | int key = ddio_KeyInKeycxx . . $ ddio_KeyInKey(b126dc7c1de90089).(); |
| 155 | if (key == KEY_ESCcxx . . $ `ddio/ddio_common.h:267:9`!) { |
| 156 | aborted = true; |
| 157 | break; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | // free our bitmap |
| 162 | if (Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle. != -1) { |
| 163 | bm_FreeBitmapcxx . . $ bm_FreeBitmap(d4f767463ce0a6b3).(Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle.); |
| 164 | Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle. = -1; |
| 165 | } |
| 166 | |
| 167 | // close our file handle |
| 168 | fclose(hFile); |
| 169 | |
| 170 | // determine the return code |
| 171 | int err = MVELIB_NOERRORcxx . . $ `Descent3/d3movie.h:28:9`!; |
| 172 | if (aborted) { |
| 173 | err = MVELIB_PLAYBACK_ABORTEDcxx . . $ `Descent3/d3movie.h:34:9`!; |
| 174 | } else if (result != MVE_ERR_EOFcxx . . $ `libmve/mvelib.h:45:9`!) { |
| 175 | err = MVELIB_PLAYBACK_ERRORcxx . . $ `Descent3/d3movie.h:33:9`!; |
| 176 | } |
| 177 | |
| 178 | // cleanup and shutdown |
| 179 | MVE_rmEndMoviecxx . . $ MVE_rmEndMovie(322520e409d4025).(mve); |
| 180 | |
| 181 | // reset sound |
| 182 | mve_CloseSoundcxx . . $ mve_CloseSound(49f6e7a06ebc5aa8).(); |
| 183 | |
| 184 | // return out |
| 185 | return err; |
| 186 | #else |
| 187 | return MVELIB_INIT_ERROR; |
| 188 | #endif |
| 189 | } |
| 190 | |
| 191 | void *CallbackAlloccxx . . $ CallbackAlloc(52408c21a1e21ff7).(uint32_tcxx . . $ uint32_t# size) { return mem_malloccxx . . $ `mem/mem.h:79:9`!(size); } |
| 192 | |
| 193 | void CallbackFreecxx . . $ CallbackFree(5d22bdacc48458e8).(void *p) { mem_freecxx . . $ `mem/mem.h:80:9`!(p); } |
| 194 | |
| 195 | uint32_tcxx . . $ uint32_t# CallbackFileReadcxx . . $ CallbackFileRead(e448eb38b8391a4e).(void *stream, void *pBuffer, uint32_tcxx . . $ uint32_t# bufferCount) { |
| 196 | uint32_tcxx . . $ uint32_t# numRead = fread(pBuffer, 1, bufferCount, (FILEcxx . . $ FILE# *)stream); |
| 197 | return (numRead == bufferCount) ? 1 : 0; |
| 198 | } |
| 199 | |
| 200 | void InitializePalettecxx . . $ InitializePalette(49f6e7a06ebc5aa8).() { |
| 201 | for (unsigned short & i : CurrentPalettecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/CurrentPalette.) { |
| 202 | i = OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`! | GR_RGB16cxx . . $ GR_RGB16(6461fafb79bad5b9).(0, 0, 0); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | void CallbackSetPalettecxx . . $ CallbackSetPalette(1b559f841397e97b).(const uint8_tcxx . . $ uint8_t# *pBuffer, uint32_tcxx . . $ uint32_t# start, uint32_tcxx . . $ uint32_t# count) { |
| 207 | #ifndef NO_MOVIES |
| 208 | pBuffer += start * 3; |
| 209 | |
| 210 | for (uint32_tcxx . . $ uint32_t# i = 0; i < count; ++i) { |
| 211 | uint32_tcxx . . $ uint32_t# r = pBuffer[0] << 2; |
| 212 | uint32_tcxx . . $ uint32_t# g = pBuffer[1] << 2; |
| 213 | uint32_tcxx . . $ uint32_t# b = pBuffer[2] << 2; |
| 214 | pBuffer += 3; |
| 215 | |
| 216 | CurrentPalettecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/CurrentPalette.[start + i] = OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`! | GR_RGB16cxx . . $ GR_RGB16(6461fafb79bad5b9).(r, g, b); |
| 217 | } |
| 218 | #endif |
| 219 | } |
| 220 | |
| 221 | int NextPow2cxx . . $ NextPow2(7864480464b09eea).(int n) { |
| 222 | n--; |
| 223 | n |= n >> 1; |
| 224 | n |= n >> 2; |
| 225 | n |= n >> 4; |
| 226 | n |= n >> 8; |
| 227 | n |= n >> 16; |
| 228 | n++; |
| 229 | return n; |
| 230 | } |
| 231 | |
| 232 | #ifndef NO_MOVIES |
| 233 | void BlitToMovieBitmapcxx . . $ BlitToMovieBitmap(75a987121187cf9d).(uint8_tcxx . . $ uint8_t# *buf, uint32_tcxx . . $ uint32_t# bufw, uint32_tcxx . . $ uint32_t# bufh, uint32_tcxx . . $ uint32_t# hicolor, |
| 234 | bool usePow2Texture, int &texW, int &texH) { |
| 235 | // get some sizes |
| 236 | int drawWidth = bufw; |
| 237 | int drawHeight = bufh; |
| 238 | |
| 239 | if (usePow2Texture) { |
| 240 | int wPow2 = NextPow2cxx . . $ NextPow2(7864480464b09eea).(drawWidth); |
| 241 | int hPow2 = NextPow2cxx . . $ NextPow2(7864480464b09eea).(drawHeight); |
| 242 | int texSize = (wPow2 > hPow2) ? wPow2 : hPow2; |
| 243 | texW = texSize; |
| 244 | texH = texSize; |
| 245 | } else { |
| 246 | texW = drawWidth; |
| 247 | texH = drawHeight; |
| 248 | } |
| 249 | |
| 250 | if (Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle. == -1) { |
| 251 | // Allocate our bitmap |
| 252 | Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle. = bm_AllocBitmapcxx . . $ bm_AllocBitmap(2326284602b0bb2d).(texW, texH, 0); |
| 253 | } |
| 254 | |
| 255 | uint16_tcxx . . $ uint16_t# *pPixelData = (uint16_tcxx . . $ uint16_t# *)bm_datacxx . . $ bm_data(501e1bc9f482c6bd).(Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle., 0); |
| 256 | GameBitmapscxx . . $ GameBitmaps.[Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle.].flagscxx . . $ bms_bitmap#flags. |= BF_CHANGEDcxx . . $ `lib/bitmap.h:46:9`!; |
| 257 | if (hicolor) { |
| 258 | uint16_tcxx . . $ uint16_t# *wBuf = (uint16_tcxx . . $ uint16_t# *)buf; |
| 259 | for (int y = 0; y < drawHeight; ++y) { |
| 260 | for (int x = 0; x < drawWidth; ++x) { |
| 261 | uint16_tcxx . . $ uint16_t# col16 = *wBuf++; |
| 262 | // Convert to RGB555 |
| 263 | pPixelData[x] = col16 | OPAQUE_FLAGcxx . . $ `lib/grdefs.h:72:9`!; |
| 264 | } |
| 265 | |
| 266 | pPixelData += texW; |
| 267 | } |
| 268 | } else { |
| 269 | for (int y = 0; y < drawHeight; ++y) { |
| 270 | for (int x = 0; x < drawWidth; ++x) { |
| 271 | uint8_tcxx . . $ uint8_t# palIndex = *buf++; |
| 272 | pPixelData[x] = CurrentPalettecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/CurrentPalette.[palIndex]; |
| 273 | } |
| 274 | |
| 275 | pPixelData += texW; |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | void CallbackShowFramecxx . . $ CallbackShowFrame(757904e8a083ae7f).(uint8_tcxx . . $ uint8_t# *buf, uint32_tcxx . . $ uint32_t# bufw, uint32_tcxx . . $ uint32_t# bufh, uint32_tcxx . . $ uint32_t# sx, uint32_tcxx . . $ uint32_t# sy, |
| 281 | uint32_tcxx . . $ uint32_t# w, uint32_tcxx . . $ uint32_t# h, uint32_tcxx . . $ uint32_t# dstx, uint32_tcxx . . $ uint32_t# dsty, uint32_tcxx . . $ uint32_t# hicolor) { |
| 282 | // prepare our bitmap |
| 283 | int texW, texH; |
| 284 | BlitToMovieBitmapcxx . . $ BlitToMovieBitmap(75a987121187cf9d).(buf, bufw, bufh, hicolor, true, texW, texH); |
| 285 | |
| 286 | // calculate UVs from texture |
| 287 | unsigned int drawWidth = bufw; |
| 288 | unsigned int drawHeight = bufh; |
| 289 | float u = float(drawWidth - 1) / float(texW - 1); |
| 290 | float v = float(drawHeight - 1) / float(texH - 1); |
| 291 | |
| 292 | StartFramecxx . . $ StartFrame(3285c9bef785d51c).(0, 0, 640, 480, false); |
| 293 | |
| 294 | rend_ClearScreencxx . . $ rend_ClearScreen(cb2f890c2fdad230).(GR_BLACKcxx . . $ GR_BLACK.); |
| 295 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`!); |
| 296 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255); |
| 297 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 298 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.); |
| 299 | rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!); |
| 300 | rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_CLAMPcxx . . $ WT_CLAMP.); |
| 301 | rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(0); |
| 302 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(0); |
| 303 | rend_DrawScaledBitmapcxx . . $ rend_DrawScaledBitmap(bffd21ce5f93b71b).(dstx, dsty, dstx + drawWidth, dsty + drawHeight, Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle., 0.0f, 0.0f, u, v); |
| 304 | rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(1); |
| 305 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1); |
| 306 | |
| 307 | // call our callback |
| 308 | if (Movie_callbackcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_callback. != nullptr) { |
| 309 | Movie_callbackcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_callback.(dstx, dsty, Movie_current_framenumcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_current_framenum.); |
| 310 | } |
| 311 | ++Movie_current_framenumcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_current_framenum.; |
| 312 | |
| 313 | EndFramecxx . . $ EndFrame(49f6e7a06ebc5aa8).(); |
| 314 | |
| 315 | rend_Flipcxx . . $ rend_Flip(49f6e7a06ebc5aa8).(); |
| 316 | } |
| 317 | |
| 318 | // This callback is same as CallbackShowFrame() but don't flip renderer at end, so there no flickering |
| 319 | void CallbackShowFrameNoFlipcxx . . $ CallbackShowFrameNoFlip(757904e8a083ae7f).(unsigned char *buf, unsigned int bufw, unsigned int bufh, unsigned int sx, unsigned int sy, |
| 320 | unsigned int w, unsigned int h, unsigned int dstx, unsigned int dsty, unsigned int hicolor) { |
| 321 | // prepare our bitmap |
| 322 | int texW, texH; |
| 323 | BlitToMovieBitmapcxx . . $ BlitToMovieBitmap(75a987121187cf9d).(buf, bufw, bufh, hicolor, true, texW, texH); |
| 324 | |
| 325 | // calculate UVs from texture |
| 326 | unsigned int drawWidth = bufw; |
| 327 | unsigned int drawHeight = bufh; |
| 328 | float u = float(drawWidth - 1) / float(texW - 1); |
| 329 | float v = float(drawHeight - 1) / float(texH - 1); |
| 330 | |
| 331 | StartFramecxx . . $ StartFrame(3285c9bef785d51c).(0, 0, 640, 480, false); |
| 332 | |
| 333 | rend_ClearScreencxx . . $ rend_ClearScreen(cb2f890c2fdad230).(GR_BLACKcxx . . $ GR_BLACK.); |
| 334 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`!); |
| 335 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255); |
| 336 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 337 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.); |
| 338 | rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!); |
| 339 | rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_CLAMPcxx . . $ WT_CLAMP.); |
| 340 | rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(0); |
| 341 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(0); |
| 342 | rend_DrawScaledBitmapcxx . . $ rend_DrawScaledBitmap(bffd21ce5f93b71b).(dstx, dsty, dstx + drawWidth, dsty + drawHeight, Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle., 0.0f, 0.0f, u, v); |
| 343 | rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(1); |
| 344 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1); |
| 345 | |
| 346 | // call our callback |
| 347 | if (Movie_callbackcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_callback. != nullptr) { |
| 348 | Movie_callbackcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_callback.(dstx, dsty, Movie_current_framenumcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_current_framenum.); |
| 349 | } |
| 350 | ++Movie_current_framenumcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_current_framenum.; |
| 351 | |
| 352 | EndFramecxx . . $ EndFrame(49f6e7a06ebc5aa8).(); |
| 353 | } |
| 354 | #endif |
| 355 | |
| 356 | intptr_tcxx . . $ intptr_t# mve_SequenceStartcxx . . $ mve_SequenceStart(290e4e6c58f7778e).(const char *mvename, void *fhandle, oeApplicationcxx . . $ oeApplication# *app, bool looping) { |
| 357 | #ifndef NO_MOVIES |
| 358 | // first, find that movie.. |
| 359 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# real_namecxx . . $ std/filesystem/__cxx11/path#path(ced63f7c635d850d).; |
| 360 | #if defined(POSIXcxx . . $ `<built-in>:480:9`!) |
| 361 | real_name =cxx . . $ std/filesystem/__cxx11/path#`operator=`(9c9aa2f17f237d0f). mve_FindMovieFileRealNamecxx . . $ mve_FindMovieFileRealName(4ac62a867fe4334a).(mvenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).); |
| 362 | if (real_name.emptycxx . . $ std/filesystem/__cxx11/path#empty(3482b152b9333168).()) { |
| 363 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "MOVIE: No such file %s\n", mvename); |
| 364 | fhandle = nullptr; |
| 365 | return 0; |
| 366 | } |
| 367 | #else |
| 368 | real_name = mvename; |
| 369 | #endif |
| 370 | fhandle = fopen(real_name.u8stringcxx . . $ std/filesystem/__cxx11/path#u8string(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), "rb"); |
| 371 | |
| 372 | if (fhandle == nullptr) { |
| 373 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(1, "MOVIE: Unable to open %s\n", real_name.u8string().c_str()); |
| 374 | return 0; |
| 375 | } |
| 376 | |
| 377 | // setup |
| 378 | MVE_memCallbackscxx . . $ MVE_memCallbacks(19c120d411afc1d).(CallbackAlloccxx . . $ CallbackAlloc(52408c21a1e21ff7)., CallbackFreecxx . . $ CallbackFree(5d22bdacc48458e8).); |
| 379 | MVE_ioCallbackscxx . . $ MVE_ioCallbacks(db0132fb63dbf97d).(CallbackFileReadcxx . . $ CallbackFileRead(e448eb38b8391a4e).); |
| 380 | MVE_sfCallbackscxx . . $ MVE_sfCallbacks(d9e6b75645a4c6c8).(CallbackShowFrameNoFlipcxx . . $ CallbackShowFrameNoFlip(757904e8a083ae7f).); |
| 381 | MVE_palCallbackscxx . . $ MVE_palCallbacks(93fa3d6c1e1dd934).(CallbackSetPalettecxx . . $ CallbackSetPalette(1b559f841397e97b).); |
| 382 | InitializePalettecxx . . $ InitializePalette(49f6e7a06ebc5aa8).(); |
| 383 | Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle. = -1; |
| 384 | Movie_loopingcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_looping. = looping; |
| 385 | |
| 386 | // let the render know we will be copying bitmaps to framebuffer (or something) |
| 387 | rend_SetFrameBufferCopyStatecxx . . $ rend_SetFrameBufferCopyState(b45ddcbc8423892c).(true); |
| 388 | |
| 389 | MVESTREAMcxx . . $ MVESTREAM# *mve = MVE_rmPrepMoviecxx . . $ MVE_rmPrepMovie(2c2ed7ae2903cf25).(fhandle, -1, -1, 0); |
| 390 | if (mve == nullptr) { |
| 391 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Failed to PrepMovie %s\n", mvename); |
| 392 | fclose((FILEcxx . . $ FILE# *)fhandle); |
| 393 | return MVELIB_INIT_ERRORcxx . . $ `Descent3/d3movie.h:32:9`!; |
| 394 | } |
| 395 | |
| 396 | return (intptr_tcxx . . $ intptr_t#)mve; |
| 397 | #else |
| 398 | return nullptr; |
| 399 | #endif |
| 400 | } |
| 401 | |
| 402 | intptr_tcxx . . $ intptr_t# mve_SequenceFramecxx . . $ mve_SequenceFrame(688560c0d8406393).(intptr_tcxx . . $ intptr_t# handle, void *fhandle, bool sequence, int *bm_handle) { |
| 403 | #ifndef NO_MOVIES |
| 404 | if (bm_handle) { |
| 405 | *bm_handle = -1; |
| 406 | } |
| 407 | |
| 408 | if (handle == -1) { |
| 409 | return -1; |
| 410 | } |
| 411 | |
| 412 | static unsigned sw = 0, sh = 0, hicolor = 0; |
| 413 | int err = 0; |
| 414 | |
| 415 | reread_frame: |
| 416 | |
| 417 | // get the next frame of data |
| 418 | uint8_tcxx . . $ uint8_t# *pBuffer = nullptr; |
| 419 | err = MVE_rmStepMoviecxx . . $ MVE_rmStepMovie(c6a4a7571c8c3481).((MVESTREAMcxx . . $ MVESTREAM# *)handle); |
| 420 | |
| 421 | if (err == 0) { |
| 422 | // blit to bitmap |
| 423 | int texW, texH; |
| 424 | BlitToMovieBitmapcxx . . $ BlitToMovieBitmap(75a987121187cf9d).(pBuffer, sw, sh, hicolor, false, texW, texH); |
| 425 | |
| 426 | if (bm_handle) { |
| 427 | *bm_handle = Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle.; |
| 428 | } |
| 429 | |
| 430 | return handle; |
| 431 | } |
| 432 | |
| 433 | if (Movie_loopingcxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_looping. && err == MVE_ERR_EOFcxx . . $ `libmve/mvelib.h:45:9`!) { |
| 434 | mve_resetcxx . . $ mve_reset(322520e409d4025).((MVESTREAMcxx . . $ MVESTREAM# *)handle); |
| 435 | sequence = true; |
| 436 | goto reread_frame; |
| 437 | } |
| 438 | |
| 439 | return -1; |
| 440 | #else |
| 441 | return -1; |
| 442 | #endif |
| 443 | } |
| 444 | |
| 445 | bool mve_SequenceClosecxx . . $ mve_SequenceClose(b2ca06e953f3967f).(intptr_tcxx . . $ intptr_t# hMovie, void *hFile) { |
| 446 | #ifndef NO_MOVIES |
| 447 | if (hMovie == -1) |
| 448 | return false; |
| 449 | |
| 450 | MVE_rmEndMoviecxx . . $ MVE_rmEndMovie(322520e409d4025).((MVESTREAMcxx . . $ MVESTREAM# *)hMovie); |
| 451 | |
| 452 | // free our bitmap |
| 453 | if (Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle. != -1) { |
| 454 | bm_FreeBitmapcxx . . $ bm_FreeBitmap(d4f767463ce0a6b3).(Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle.); |
| 455 | Movie_bm_handlecxx . . $ `$anonymous_namespace_Descent3/d3movie.cpp`/Movie_bm_handle. = -1; |
| 456 | } |
| 457 | |
| 458 | // We're no longer needing this |
| 459 | rend_SetFrameBufferCopyStatecxx . . $ rend_SetFrameBufferCopyState(b45ddcbc8423892c).(false); |
| 460 | |
| 461 | return true; |
| 462 | #else |
| 463 | return false; |
| 464 | #endif |
| 465 | } |
| 466 | |
| 467 | void mve_Putscxx . . $ mve_Puts(fd7f3a04a1c20bf5).(int16_t x, int16_t y, ddgr_colorcxx . . $ ddgr_color# col, const char *txt) { |
| 468 | grtext_SetFontcxx . . $ grtext_SetFont(d4f767463ce0a6b3).(BRIEFING_FONTcxx . . $ `Descent3/gamefont.h:111:9`!); |
| 469 | grtext_SetColorcxx . . $ grtext_SetColor(cb2f890c2fdad230).(col); |
| 470 | grtext_SetAlphacxx . . $ grtext_SetAlpha(ac50b47256ae7414).(255); |
| 471 | grtext_SetFlagscxx . . $ grtext_SetFlags(d4f767463ce0a6b3).(GRTEXTFLAG_SHADOWcxx . . $ `grtext/grtext.h:120:9`!); |
| 472 | grtext_CenteredPrintfcxx . . $ grtext_CenteredPrintf(9514e36549094170).(0, y, txt); |
| 473 | grtext_Flushcxx . . $ grtext_Flush(49f6e7a06ebc5aa8).(); |
| 474 | } |
| 475 | |
| 476 | void mve_ClearRectcxx . . $ mve_ClearRect(6f3a90be462c391b).(int16_t x1, int16_t y1, int16_t x2, int16_t y2) { |
| 477 | // Note: I can not figure out how to clear, and then write over it with text. It always covers my text! |
| 478 | // rend_FillRect( GR_BLACK, x1, y1, x2, y2 ); |
| 479 | } |
| 480 | |
| 481 | #ifndef NO_MOVIES |
| 482 | bool mve_InitSoundcxx . . $ mve_InitSound(c9857a73d68e59ba).() { |
| 483 | MVE_sndInitcxx . . $ MVE_sndInit(b45ddcbc8423892c).(FindArgcxx . . $ FindArg(5c4306d8553b3696).("-nosound") == 0); |
| 484 | |
| 485 | return true; |
| 486 | } |
| 487 | |
| 488 | void mve_CloseSoundcxx . . $ mve_CloseSound(49f6e7a06ebc5aa8).() { |
| 489 | // TODO: close the driver out |
| 490 | } |
| 491 | |
| 492 | #endif |