| 1 | /* |
| 2 | * Copyright (C) 2002-2024 D2X Project |
| 3 | * |
| 4 | * This program is free software: you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation, either version 3 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #define AUDIOcxx . . $ `libmve/mveplay.cpp:18:9`! |
| 19 | |
| 20 | #include <chrono> |
| 21 | #include <cstring> |
| 22 | #include <deque> |
| 23 | #include <memory> |
| 24 | #include <thread> |
| 25 | |
| 26 | #include "byteswap.h"cxx . . $ `<file>/lib/byteswap.h`/ |
| 27 | #include "chrono_timer.h"cxx . . $ `<file>/ddio/chrono_timer.h`/ |
| 28 | #include "decoders.h"cxx . . $ `<file>/libmve/decoders.h`/ |
| 29 | #include "mvelib.h"cxx . . $ `<file>/libmve/mvelib.h`/ |
| 30 | #include "mve_audio.h"cxx . . $ `<file>/libmve/mve_audio.h`/ |
| 31 | |
| 32 | #ifdef AUDIOcxx . . $ `libmve/mveplay.cpp:18:9`! |
| 33 | #include "movie_sound.h"cxx . . $ `<file>/libmve/movie_sound.h`/ |
| 34 | #endif |
| 35 | |
| 36 | #define MVE_OPCODE_ENDOFSTREAMcxx . . $ `libmve/mveplay.cpp:36:9`! 0x00 // mcmd_end |
| 37 | #define MVE_OPCODE_ENDOFCHUNKcxx . . $ `libmve/mveplay.cpp:37:9`! 0x01 // mcmd_next |
| 38 | #define MVE_OPCODE_CREATETIMERcxx . . $ `libmve/mveplay.cpp:38:9`! 0x02 // mcmd_syncInit |
| 39 | #define MVE_OPCODE_INITAUDIOBUFFERScxx . . $ `libmve/mveplay.cpp:39:9`! 0x03 // mcmd_sndConfigure |
| 40 | #define MVE_OPCODE_STARTSTOPAUDIOcxx . . $ `libmve/mveplay.cpp:40:9`! 0x04 // mcmd_sndSync |
| 41 | #define MVE_OPCODE_INITVIDEOBUFFERScxx . . $ `libmve/mveplay.cpp:41:9`! 0x05 // mcmd_nfConfig |
| 42 | #define MVE_OPCODE_UNKNOWN_06cxx . . $ `libmve/mveplay.cpp:42:9`! 0x06 // mcmd_nfDecomp |
| 43 | #define MVE_OPCODE_DISPLAYVIDEOcxx . . $ `libmve/mveplay.cpp:43:9`! 0x07 // mcmd_sfShowFrame |
| 44 | #define MVE_OPCODE_AUDIOFRAMEDATAcxx . . $ `libmve/mveplay.cpp:44:9`! 0x08 // mcmd_sndAdd |
| 45 | #define MVE_OPCODE_AUDIOFRAMESILENCEcxx . . $ `libmve/mveplay.cpp:45:9`! 0x09 // mcmd_sndSilence |
| 46 | #define MVE_OPCODE_INITVIDEOMODEcxx . . $ `libmve/mveplay.cpp:46:9`! 0x0A // mcmd_gfxMode |
| 47 | #define MVE_OPCODE_UNKNOWN_0Bcxx . . $ `libmve/mveplay.cpp:47:9`! 0x0B // mcmd_palMakeSynthPalette |
| 48 | #define MVE_OPCODE_SETPALETTEcxx . . $ `libmve/mveplay.cpp:48:9`! 0x0C // mcmd_palLoadPalette |
| 49 | #define MVE_OPCODE_SETPALETTECOMPRESSEDcxx . . $ `libmve/mveplay.cpp:49:9`! 0x0D // mcmd_palLoadCompPalette |
| 50 | #define MVE_OPCODE_UNKNOWN_0Ecxx . . $ `libmve/mveplay.cpp:50:9`! 0x0E // mcmd_nfChanges |
| 51 | #define MVE_OPCODE_SETDECODINGMAPcxx . . $ `libmve/mveplay.cpp:51:9`! 0x0F // mcmd_nfParms |
| 52 | #define MVE_OPCODE_UNKNOWN_10cxx . . $ `libmve/mveplay.cpp:52:9`! 0x10 // mcmd_nfDecompChg |
| 53 | #define MVE_OPCODE_VIDEODATAcxx . . $ `libmve/mveplay.cpp:53:9`! 0x11 // mcmd_nfPkDecomp |
| 54 | |
| 55 | #define MVE_AUDIO_FLAGS_STEREOcxx . . $ `libmve/mveplay.cpp:55:9`! 1 |
| 56 | #define MVE_AUDIO_FLAGS_16BITcxx . . $ `libmve/mveplay.cpp:56:9`! 2 |
| 57 | #define MVE_AUDIO_FLAGS_COMPRESSEDcxx . . $ `libmve/mveplay.cpp:57:9`! 4 |
| 58 | |
| 59 | int g_spdFactorNumcxx . . $ g_spdFactorNum. = 0; |
| 60 | static int g_spdFactorDenomcxx . . $ g_spdFactorDenom. = 10; |
| 61 | static int g_frameUpdatedcxx . . $ g_frameUpdated. = 0; |
| 62 | |
| 63 | static short get_shortcxx . . $ get_short(76686030ffb3fc3).(const unsigned char *data) { |
| 64 | return D3cxx . . $ D3/::convert_lecxx . . $ D3/convert_le(ada6a8422704cf8a).<int16_tcxx . . $ int16_t#>(data[0] | (data[1] << 8)); |
| 65 | } |
| 66 | |
| 67 | static unsigned short get_ushortcxx . . $ get_ushort(469dcb4e54b221a8).(const unsigned char *data) { |
| 68 | return D3cxx . . $ D3/::convert_lecxx . . $ D3/convert_le(ada6a8422704cf8a).<uint16_tcxx . . $ uint16_t#>(data[0] | (data[1] << 8)); |
| 69 | } |
| 70 | |
| 71 | static int get_intcxx . . $ get_int(b84ccf4e0bb14b06).(const unsigned char *data) { |
| 72 | return D3cxx . . $ D3/::convert_lecxx . . $ D3/convert_le(ada6a8422704cf8a).<int32_tcxx . . $ int32_t#>(data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24)); |
| 73 | } |
| 74 | |
| 75 | static unsigned int unhandled_chunkscxx . . $ unhandled_chunks.[32 * 256]; |
| 76 | |
| 77 | static int default_seg_handlercxx . . $ default_seg_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) { |
| 78 | unhandled_chunkscxx . . $ unhandled_chunks.[major << 8 | minor]++; |
| 79 | return 1; |
| 80 | } |
| 81 | |
| 82 | /************************* |
| 83 | * general handlers |
| 84 | *************************/ |
| 85 | static int end_movie_handlercxx . . $ end_movie_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) { |
| 86 | return 0; |
| 87 | } |
| 88 | |
| 89 | /************************* |
| 90 | * timer handlers |
| 91 | *************************/ |
| 92 | |
| 93 | /* |
| 94 | * timer variables |
| 95 | */ |
| 96 | static int timer_createdcxx . . $ timer_created. = 0; |
| 97 | static int micro_frame_delaycxx . . $ micro_frame_delay. = 0; |
| 98 | static int timer_startedcxx . . $ timer_started. = 0; |
| 99 | static unsigned long int timer_expirecxx . . $ timer_expire. = 0; |
| 100 | |
| 101 | unsigned long int timer_getmicrosecondscxx . . $ timer_getmicroseconds(f708dce9a8856c70).() { |
| 102 | return D3cxx . . $ D3/::ChronoTimercxx . . $ D3/ChronoTimer#::GetTimeUScxx . . $ D3/ChronoTimer#GetTimeUS(da6335ded91d79c2).(); |
| 103 | } |
| 104 | |
| 105 | void timer_sleepmicrosecondscxx . . $ timer_sleepmicroseconds(2c44cd906ae4e829).(unsigned long int usec) { |
| 106 | std::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(stdcxx . . $ std/chrono/duration#duration(edcd8b2679e9bd1a).::chronocxx . . $ std/chrono/::microsecondscxx . . $ std/chrono/microseconds#(usec)); |
| 107 | } |
| 108 | |
| 109 | static int create_timer_handlercxx . . $ create_timer_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) { |
| 110 | long temp; |
| 111 | |
| 112 | if (timer_createdcxx . . $ timer_created.) |
| 113 | return 1; |
| 114 | else |
| 115 | timer_createdcxx . . $ timer_created. = 1; |
| 116 | |
| 117 | micro_frame_delaycxx . . $ micro_frame_delay. = get_intcxx . . $ get_int(b84ccf4e0bb14b06).(data) * (int)get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 4); |
| 118 | if (g_spdFactorNumcxx . . $ g_spdFactorNum. != 0) { |
| 119 | temp = micro_frame_delaycxx . . $ micro_frame_delay.; |
| 120 | temp *= g_spdFactorNumcxx . . $ g_spdFactorNum.; |
| 121 | temp /= g_spdFactorDenomcxx . . $ g_spdFactorDenom.; |
| 122 | micro_frame_delaycxx . . $ micro_frame_delay. = (int)temp; |
| 123 | } |
| 124 | |
| 125 | return 1; |
| 126 | } |
| 127 | |
| 128 | static void timer_stopcxx . . $ timer_stop(49f6e7a06ebc5aa8).() { |
| 129 | timer_expirecxx . . $ timer_expire. = 0; |
| 130 | timer_startedcxx . . $ timer_started. = 0; |
| 131 | } |
| 132 | |
| 133 | static void timer_startcxx . . $ timer_start(49f6e7a06ebc5aa8).() { |
| 134 | timer_expirecxx . . $ timer_expire. = timer_getmicrosecondscxx . . $ timer_getmicroseconds(f708dce9a8856c70).(); |
| 135 | timer_expirecxx . . $ timer_expire. += micro_frame_delaycxx . . $ micro_frame_delay.; |
| 136 | timer_startedcxx . . $ timer_started. = 1; |
| 137 | } |
| 138 | |
| 139 | #ifdef AUDIOcxx . . $ `libmve/mveplay.cpp:18:9`! |
| 140 | static std::unique_ptrcxx . . $ std/unique_ptr#<D3cxx . . $ D3/::MovieSoundDevicecxx . . $ D3/MovieSoundDevice#> snd_dscxx . . $ snd_ds.; |
| 141 | static int mve_audio_enabledcxx . . $ mve_audio_enabled. = 1; |
| 142 | #else |
| 143 | static int mve_audio_enabled = 0; |
| 144 | #endif |
| 145 | |
| 146 | static void do_timer_waitcxx . . $ do_timer_wait(49f6e7a06ebc5aa8).() { |
| 147 | uint64_tcxx . . $ uint64_t# ts; |
| 148 | uint64_tcxx . . $ uint64_t# tv; |
| 149 | |
| 150 | if (!timer_startedcxx . . $ timer_started.) |
| 151 | return; |
| 152 | |
| 153 | tv = timer_getmicrosecondscxx . . $ timer_getmicroseconds(f708dce9a8856c70).(); |
| 154 | if (tv > timer_expirecxx . . $ timer_expire.) |
| 155 | goto end; |
| 156 | |
| 157 | ts = timer_expirecxx . . $ timer_expire. - tv; |
| 158 | |
| 159 | timer_sleepmicrosecondscxx . . $ timer_sleepmicroseconds(2c44cd906ae4e829).(ts); |
| 160 | |
| 161 | end: |
| 162 | timer_expirecxx . . $ timer_expire. += micro_frame_delaycxx . . $ micro_frame_delay.; |
| 163 | } |
| 164 | |
| 165 | /************************* |
| 166 | * audio handlers |
| 167 | *************************/ |
| 168 | |
| 169 | static int create_audiobuf_handlercxx . . $ create_audiobuf_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, |
| 170 | void *context) { |
| 171 | #ifdef AUDIOcxx . . $ `libmve/mveplay.cpp:18:9`! |
| 172 | if (!mve_audio_enabledcxx . . $ mve_audio_enabled.) |
| 173 | return 1; |
| 174 | |
| 175 | int flags = get_ushortcxx . . $ get_ushort(469dcb4e54b221a8).(data + 2); |
| 176 | int sample_rate = get_ushortcxx . . $ get_ushort(469dcb4e54b221a8).(data + 4); |
| 177 | int desired_buffer = get_intcxx . . $ get_int(b84ccf4e0bb14b06).(data + 6); |
| 178 | |
| 179 | int channels = (flags & MVE_AUDIO_FLAGS_STEREOcxx . . $ `libmve/mveplay.cpp:55:9`!) ? 2 : 1; |
| 180 | int sample_size = (flags & MVE_AUDIO_FLAGS_16BITcxx . . $ `libmve/mveplay.cpp:56:9`!) ? 2 : 1; |
| 181 | |
| 182 | bool is_compressed = false; |
| 183 | if (minor > 0 && (flags & MVE_AUDIO_FLAGS_COMPRESSEDcxx . . $ `libmve/mveplay.cpp:57:9`!)) { |
| 184 | is_compressed = true; |
| 185 | } |
| 186 | |
| 187 | snd_dscxx . . $ snd_ds. =cxx . . $ std/unique_ptr#`operator=`(1b63e42eaa758a73). std::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<D3cxx . . $ D3/::MovieSoundDevicecxx . . $ D3/MovieSoundDevice#>(sample_rate, sample_size, channels, 4096, is_compressed); |
| 188 | #endif |
| 189 | |
| 190 | return 1; |
| 191 | } |
| 192 | |
| 193 | static int play_audio_handlercxx . . $ play_audio_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) { |
| 194 | #ifdef AUDIOcxx . . $ `libmve/mveplay.cpp:18:9`! |
| 195 | if (snd_dscxx . . $ snd_ds. && snd_dscxx . . $ snd_ds.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).IsInitializedcxx . . $ D3/MovieSoundDevice#IsInitialized(50ce9a9e25b4a850).()) { |
| 196 | snd_dscxx . . $ snd_ds.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).Playcxx . . $ D3/MovieSoundDevice#Play(49f6e7a06ebc5aa8).(); |
| 197 | } |
| 198 | #endif |
| 199 | return 1; |
| 200 | } |
| 201 | |
| 202 | static int audio_data_handlercxx . . $ audio_data_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) { |
| 203 | #ifdef AUDIOcxx . . $ `libmve/mveplay.cpp:18:9`! |
| 204 | static const int selected_chan = 1; |
| 205 | if (snd_dscxx . . $ snd_ds. && snd_dscxx . . $ snd_ds.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).IsInitializedcxx . . $ D3/MovieSoundDevice#IsInitialized(50ce9a9e25b4a850).()) { |
| 206 | int chan = get_ushortcxx . . $ get_ushort(469dcb4e54b221a8).(data + 2); |
| 207 | int size = get_ushortcxx . . $ get_ushort(469dcb4e54b221a8).(data + 4); |
| 208 | if (chan & selected_chan) { |
| 209 | void *buf = malloccxx . . $ malloc(9f008b2a9698428b).(size); |
| 210 | if (major == MVE_OPCODE_AUDIOFRAMEDATAcxx . . $ `libmve/mveplay.cpp:44:9`!) { |
| 211 | mveaudio_processcxx . . $ mveaudio_process(237702cc52226b1f).((char *)buf, data, snd_dscxx . . $ snd_ds.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).GetSampleSizecxx . . $ D3/MovieSoundDevice#GetSampleSize(72085aa11f4b6e09).(), snd_dscxx . . $ snd_ds.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).IsCompressedcxx . . $ D3/ISoundDevice#IsCompressed(50ce9a9e25b4a850).()); |
| 212 | } else { |
| 213 | // SILENCE, MORTALS! |
| 214 | memset(data, 0, size); |
| 215 | } |
| 216 | snd_dscxx . . $ snd_ds.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).FillBuffercxx . . $ D3/MovieSoundDevice#FillBuffer(4c1d9d34c3551872).((char *)buf, size); |
| 217 | freecxx . . $ free(bd21765a0afc8e3c).(buf); |
| 218 | } |
| 219 | } |
| 220 | #endif |
| 221 | |
| 222 | return 1; |
| 223 | } |
| 224 | |
| 225 | /************************* |
| 226 | * video handlers |
| 227 | *************************/ |
| 228 | |
| 229 | static int videobuf_createdcxx . . $ videobuf_created. = 0; |
| 230 | static int video_initializedcxx . . $ video_initialized. = 0; |
| 231 | int g_widthcxx . . $ g_width., g_heightcxx . . $ g_height.; |
| 232 | void *g_vBufferscxx . . $ g_vBuffers. = nullptr, *g_vBackBuf1cxx . . $ g_vBackBuf1., *g_vBackBuf2cxx . . $ g_vBackBuf2.; |
| 233 | |
| 234 | static int g_destXcxx . . $ g_destX., g_destYcxx . . $ g_destY.; |
| 235 | static int g_screenWidthcxx . . $ g_screenWidth., g_screenHeightcxx . . $ g_screenHeight.; |
| 236 | static unsigned char *g_pCurMapcxx . . $ g_pCurMap. = nullptr; |
| 237 | static int g_nMapLengthcxx . . $ g_nMapLength. = 0; |
| 238 | static int g_truecolorcxx . . $ g_truecolor.; |
| 239 | |
| 240 | static int create_videobuf_handlercxx . . $ create_videobuf_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, |
| 241 | void *context) { |
| 242 | short w, h; |
| 243 | short count, truecolor; |
| 244 | |
| 245 | if (videobuf_createdcxx . . $ videobuf_created.) |
| 246 | return 1; |
| 247 | else |
| 248 | videobuf_createdcxx . . $ videobuf_created. = 1; |
| 249 | |
| 250 | w = get_shortcxx . . $ get_short(76686030ffb3fc3).(data); |
| 251 | h = get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 2); |
| 252 | |
| 253 | if (minor > 0) { |
| 254 | count = get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 4); |
| 255 | } else { |
| 256 | count = 1; |
| 257 | } |
| 258 | |
| 259 | if (minor > 1) { |
| 260 | truecolor = get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 6); |
| 261 | } else { |
| 262 | truecolor = 0; |
| 263 | } |
| 264 | |
| 265 | g_widthcxx . . $ g_width. = w << 3; |
| 266 | g_heightcxx . . $ g_height. = h << 3; |
| 267 | |
| 268 | /* TODO: * 4 causes crashes on some files */ |
| 269 | /* only malloc once */ |
| 270 | if (g_vBufferscxx . . $ g_vBuffers. == nullptr) |
| 271 | g_vBackBuf1cxx . . $ g_vBackBuf1. = g_vBufferscxx . . $ g_vBuffers. = mve_alloccxx . . $ mve_alloc.(g_widthcxx . . $ g_width. * g_heightcxx . . $ g_height. * 8); |
| 272 | if (truecolor) { |
| 273 | g_vBackBuf2cxx . . $ g_vBackBuf2. = (unsigned short *)g_vBackBuf1cxx . . $ g_vBackBuf1. + (g_widthcxx . . $ g_width. * g_heightcxx . . $ g_height.); |
| 274 | } else { |
| 275 | g_vBackBuf2cxx . . $ g_vBackBuf2. = (unsigned char *)g_vBackBuf1cxx . . $ g_vBackBuf1. + (g_widthcxx . . $ g_width. * g_heightcxx . . $ g_height.); |
| 276 | } |
| 277 | |
| 278 | memset(g_vBackBuf1cxx . . $ g_vBackBuf1., 0, g_widthcxx . . $ g_width. * g_heightcxx . . $ g_height. * 4); |
| 279 | |
| 280 | g_truecolorcxx . . $ g_truecolor. = truecolor; |
| 281 | |
| 282 | return 1; |
| 283 | } |
| 284 | |
| 285 | static int display_video_handlercxx . . $ display_video_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, |
| 286 | void *context) { |
| 287 | if (g_destXcxx . . $ g_destX. == -1) // center it |
| 288 | g_destXcxx . . $ g_destX. = (g_screenWidthcxx . . $ g_screenWidth. - g_widthcxx . . $ g_width.) >> 1; |
| 289 | if (g_destYcxx . . $ g_destY. == -1) // center it |
| 290 | g_destYcxx . . $ g_destY. = (g_screenHeightcxx . . $ g_screenHeight. - g_heightcxx . . $ g_height.) >> 1; |
| 291 | |
| 292 | mve_showframecxx . . $ mve_showframe.((unsigned char *)g_vBackBuf1cxx . . $ g_vBackBuf1., g_widthcxx . . $ g_width., g_heightcxx . . $ g_height., 0, 0, g_widthcxx . . $ g_width., g_heightcxx . . $ g_height., g_destXcxx . . $ g_destX., g_destYcxx . . $ g_destY., |
| 293 | g_truecolorcxx . . $ g_truecolor.); |
| 294 | |
| 295 | g_frameUpdatedcxx . . $ g_frameUpdated. = 1; |
| 296 | |
| 297 | return 1; |
| 298 | } |
| 299 | |
| 300 | static int init_video_handlercxx . . $ init_video_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) { |
| 301 | short width, height; |
| 302 | |
| 303 | if (video_initializedcxx . . $ video_initialized.) |
| 304 | return 1; /* maybe we actually need to change width/height here? */ |
| 305 | else |
| 306 | video_initializedcxx . . $ video_initialized. = 1; |
| 307 | |
| 308 | width = get_shortcxx . . $ get_short(76686030ffb3fc3).(data); |
| 309 | height = get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 2); |
| 310 | g_screenWidthcxx . . $ g_screenWidth. = width; |
| 311 | g_screenHeightcxx . . $ g_screenHeight. = height; |
| 312 | |
| 313 | return 1; |
| 314 | } |
| 315 | |
| 316 | static int video_palette_handlercxx . . $ video_palette_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, |
| 317 | void *context) { |
| 318 | short start, count; |
| 319 | unsigned char *p; |
| 320 | |
| 321 | start = get_shortcxx . . $ get_short(76686030ffb3fc3).(data); |
| 322 | count = get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 2); |
| 323 | |
| 324 | p = data + 4; |
| 325 | |
| 326 | mve_setpalettecxx . . $ mve_setpalette.(p - 3 * start, start, count); |
| 327 | |
| 328 | return 1; |
| 329 | } |
| 330 | |
| 331 | static int video_codemap_handlercxx . . $ video_codemap_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, |
| 332 | void *context) { |
| 333 | g_pCurMapcxx . . $ g_pCurMap. = data; |
| 334 | g_nMapLengthcxx . . $ g_nMapLength. = len; |
| 335 | return 1; |
| 336 | } |
| 337 | |
| 338 | static int video_data_handlercxx . . $ video_data_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) { |
| 339 | unsigned char *temp; |
| 340 | |
| 341 | short nFrameHot = get_shortcxx . . $ get_short(76686030ffb3fc3).(data); |
| 342 | short nFrameCold = get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 2); |
| 343 | short nXoffset = get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 4); |
| 344 | short nYoffset = get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 6); |
| 345 | short nXsize = get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 8); |
| 346 | short nYsize = get_shortcxx . . $ get_short(76686030ffb3fc3).(data + 10); |
| 347 | unsigned short nFlags = get_ushortcxx . . $ get_ushort(469dcb4e54b221a8).(data + 12); |
| 348 | |
| 349 | if (nFlags & 1) { |
| 350 | temp = (unsigned char *)g_vBackBuf1cxx . . $ g_vBackBuf1.; |
| 351 | g_vBackBuf1cxx . . $ g_vBackBuf1. = g_vBackBuf2cxx . . $ g_vBackBuf2.; |
| 352 | g_vBackBuf2cxx . . $ g_vBackBuf2. = temp; |
| 353 | } |
| 354 | |
| 355 | /* convert the frame */ |
| 356 | if (g_truecolorcxx . . $ g_truecolor.) { |
| 357 | decodeFrame16cxx . . $ decodeFrame16(70072384e3929096).((unsigned char *)g_vBackBuf1cxx . . $ g_vBackBuf1., g_pCurMapcxx . . $ g_pCurMap., g_nMapLengthcxx . . $ g_nMapLength., data + 14, len - 14); |
| 358 | } else { |
| 359 | decodeFrame8cxx . . $ decodeFrame8(70072384e3929096).((unsigned char *)g_vBackBuf1cxx . . $ g_vBackBuf1., g_pCurMapcxx . . $ g_pCurMap., g_nMapLengthcxx . . $ g_nMapLength., data + 14, len - 14); |
| 360 | } |
| 361 | |
| 362 | return 1; |
| 363 | } |
| 364 | |
| 365 | static int end_chunk_handlercxx . . $ end_chunk_handler(d43bc7282d60f454).(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context) { |
| 366 | g_pCurMapcxx . . $ g_pCurMap. = nullptr; |
| 367 | return 1; |
| 368 | } |
| 369 | |
| 370 | void MVE_ioCallbackscxx . . $ MVE_ioCallbacks(db0132fb63dbf97d).(mve_cb_Readcxx . . $ mve_cb_Read# io_read) { mve_readcxx . . $ mve_read. = io_read; } |
| 371 | |
| 372 | void MVE_memCallbackscxx . . $ MVE_memCallbacks(19c120d411afc1d).(mve_cb_Alloccxx . . $ mve_cb_Alloc# mem_alloc, mve_cb_Freecxx . . $ mve_cb_Free# mem_free) { |
| 373 | mve_alloccxx . . $ mve_alloc. = mem_alloc; |
| 374 | mve_freecxx . . $ mve_free. = mem_free; |
| 375 | } |
| 376 | |
| 377 | void MVE_sfCallbackscxx . . $ MVE_sfCallbacks(d9e6b75645a4c6c8).(mve_cb_ShowFramecxx . . $ mve_cb_ShowFrame# showframe) { mve_showframecxx . . $ mve_showframe. = showframe; } |
| 378 | |
| 379 | void MVE_palCallbackscxx . . $ MVE_palCallbacks(93fa3d6c1e1dd934).(mve_cb_SetPalettecxx . . $ mve_cb_SetPalette# setpalette) { mve_setpalettecxx . . $ mve_setpalette. = setpalette; } |
| 380 | |
| 381 | MVESTREAMcxx . . $ MVESTREAM#* MVE_rmPrepMoviecxx . . $ MVE_rmPrepMovie(2c2ed7ae2903cf25).(void *src, int x, int y, int track) { |
| 382 | MVESTREAMcxx . . $ MVESTREAM# *mve; |
| 383 | mve = mve_opencxx . . $ mve_open(773157b047541329).(src); |
| 384 | |
| 385 | if (!mve) |
| 386 | return nullptr; |
| 387 | |
| 388 | g_destXcxx . . $ g_destX. = x; |
| 389 | g_destYcxx . . $ g_destY. = y; |
| 390 | |
| 391 | for (int i = 0; i < 32; i++) |
| 392 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, i, default_seg_handlercxx . . $ default_seg_handler(d43bc7282d60f454).); |
| 393 | |
| 394 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_ENDOFSTREAMcxx . . $ `libmve/mveplay.cpp:36:9`!, end_movie_handlercxx . . $ end_movie_handler(d43bc7282d60f454).); |
| 395 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_ENDOFCHUNKcxx . . $ `libmve/mveplay.cpp:37:9`!, end_chunk_handlercxx . . $ end_chunk_handler(d43bc7282d60f454).); |
| 396 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_CREATETIMERcxx . . $ `libmve/mveplay.cpp:38:9`!, create_timer_handlercxx . . $ create_timer_handler(d43bc7282d60f454).); |
| 397 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_INITAUDIOBUFFERScxx . . $ `libmve/mveplay.cpp:39:9`!, create_audiobuf_handlercxx . . $ create_audiobuf_handler(d43bc7282d60f454).); |
| 398 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_STARTSTOPAUDIOcxx . . $ `libmve/mveplay.cpp:40:9`!, play_audio_handlercxx . . $ play_audio_handler(d43bc7282d60f454).); |
| 399 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_INITVIDEOBUFFERScxx . . $ `libmve/mveplay.cpp:41:9`!, create_videobuf_handlercxx . . $ create_videobuf_handler(d43bc7282d60f454).); |
| 400 | |
| 401 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_DISPLAYVIDEOcxx . . $ `libmve/mveplay.cpp:43:9`!, display_video_handlercxx . . $ display_video_handler(d43bc7282d60f454).); |
| 402 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_AUDIOFRAMEDATAcxx . . $ `libmve/mveplay.cpp:44:9`!, audio_data_handlercxx . . $ audio_data_handler(d43bc7282d60f454).); |
| 403 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_AUDIOFRAMESILENCEcxx . . $ `libmve/mveplay.cpp:45:9`!, audio_data_handlercxx . . $ audio_data_handler(d43bc7282d60f454).); |
| 404 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_INITVIDEOMODEcxx . . $ `libmve/mveplay.cpp:46:9`!, init_video_handlercxx . . $ init_video_handler(d43bc7282d60f454).); |
| 405 | |
| 406 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_SETPALETTEcxx . . $ `libmve/mveplay.cpp:48:9`!, video_palette_handlercxx . . $ video_palette_handler(d43bc7282d60f454).); |
| 407 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_SETPALETTECOMPRESSEDcxx . . $ `libmve/mveplay.cpp:49:9`!, default_seg_handlercxx . . $ default_seg_handler(d43bc7282d60f454).); |
| 408 | |
| 409 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_SETDECODINGMAPcxx . . $ `libmve/mveplay.cpp:51:9`!, video_codemap_handlercxx . . $ video_codemap_handler(d43bc7282d60f454).); |
| 410 | |
| 411 | mve_set_handlercxx . . $ mve_set_handler(208c9697527ebac9).(mve, MVE_OPCODE_VIDEODATAcxx . . $ `libmve/mveplay.cpp:53:9`!, video_data_handlercxx . . $ video_data_handler(d43bc7282d60f454).); |
| 412 | |
| 413 | mve_play_next_chunkcxx . . $ mve_play_next_chunk(c6a4a7571c8c3481).(mve); /* video initialization chunk */ |
| 414 | if (mve_audio_enabledcxx . . $ mve_audio_enabled.) |
| 415 | mve_play_next_chunkcxx . . $ mve_play_next_chunk(c6a4a7571c8c3481).(mve); /* audio initialization chunk */ |
| 416 | |
| 417 | return mve; |
| 418 | } |
| 419 | |
| 420 | void MVE_getVideoSpeccxx . . $ MVE_getVideoSpec(2a90f1c080e52241).(MVE_videoSpeccxx . . $ MVE_videoSpec# *vSpec) { |
| 421 | vSpec->screenWidthcxx . . $ $anonymous_type_e461a2138b30f544_0#screenWidth. = g_screenWidthcxx . . $ g_screenWidth.; |
| 422 | vSpec->screenHeightcxx . . $ $anonymous_type_e461a2138b30f544_0#screenHeight. = g_screenHeightcxx . . $ g_screenHeight.; |
| 423 | vSpec->widthcxx . . $ $anonymous_type_e461a2138b30f544_0#width. = g_widthcxx . . $ g_width.; |
| 424 | vSpec->heightcxx . . $ $anonymous_type_e461a2138b30f544_0#height. = g_heightcxx . . $ g_height.; |
| 425 | vSpec->truecolorcxx . . $ $anonymous_type_e461a2138b30f544_0#truecolor. = g_truecolorcxx . . $ g_truecolor.; |
| 426 | } |
| 427 | |
| 428 | int MVE_rmStepMoviecxx . . $ MVE_rmStepMovie(c6a4a7571c8c3481).(MVESTREAMcxx . . $ MVESTREAM# *mve) { |
| 429 | static int init_timer = 0; |
| 430 | int cont = 1; |
| 431 | |
| 432 | if (!timer_startedcxx . . $ timer_started.) |
| 433 | timer_startcxx . . $ timer_start(49f6e7a06ebc5aa8).(); |
| 434 | |
| 435 | while (cont && !g_frameUpdatedcxx . . $ g_frameUpdated.) // make a "step" be a frame, not a chunk... |
| 436 | cont = mve_play_next_chunkcxx . . $ mve_play_next_chunk(c6a4a7571c8c3481).(mve); |
| 437 | g_frameUpdatedcxx . . $ g_frameUpdated. = 0; |
| 438 | |
| 439 | if (!cont) |
| 440 | return MVE_ERR_EOFcxx . . $ `libmve/mvelib.h:45:9`!; |
| 441 | |
| 442 | if (micro_frame_delaycxx . . $ micro_frame_delay. && !init_timer) { |
| 443 | timer_startcxx . . $ timer_start(49f6e7a06ebc5aa8).(); |
| 444 | init_timer = 1; |
| 445 | } |
| 446 | |
| 447 | do_timer_waitcxx . . $ do_timer_wait(49f6e7a06ebc5aa8).(); |
| 448 | |
| 449 | return 0; |
| 450 | } |
| 451 | |
| 452 | void MVE_rmEndMoviecxx . . $ MVE_rmEndMovie(322520e409d4025).(MVESTREAMcxx . . $ MVESTREAM# *mve) { |
| 453 | timer_stopcxx . . $ timer_stop(49f6e7a06ebc5aa8).(); |
| 454 | timer_createdcxx . . $ timer_created. = 0; |
| 455 | |
| 456 | #ifdef AUDIOcxx . . $ `libmve/mveplay.cpp:18:9`! |
| 457 | snd_dscxx . . $ snd_ds..resetcxx . . $ std/unique_ptr#reset(c8c3025d73122d7d).(); |
| 458 | #endif |
| 459 | |
| 460 | mve_freecxx . . $ mve_free.(g_vBufferscxx . . $ g_vBuffers.); |
| 461 | g_vBufferscxx . . $ g_vBuffers. = nullptr; |
| 462 | g_pCurMapcxx . . $ g_pCurMap. = nullptr; |
| 463 | g_nMapLengthcxx . . $ g_nMapLength. = 0; |
| 464 | videobuf_createdcxx . . $ videobuf_created. = 0; |
| 465 | video_initializedcxx . . $ video_initialized. = 0; |
| 466 | |
| 467 | mve_closecxx . . $ mve_close(322520e409d4025).(mve); |
| 468 | mve = nullptr; |
| 469 | } |
| 470 | |
| 471 | void MVE_rmHoldMoviecxx . . $ MVE_rmHoldMovie(49f6e7a06ebc5aa8).() { timer_startedcxx . . $ timer_started. = 0; } |
| 472 | |
| 473 | void MVE_sndInitcxx . . $ MVE_sndInit(b45ddcbc8423892c).(const bool enable) { |
| 474 | #ifdef AUDIOcxx . . $ `libmve/mveplay.cpp:18:9`! |
| 475 | if (enable) { |
| 476 | mve_audio_enabledcxx . . $ mve_audio_enabled. = 1; |
| 477 | } else { |
| 478 | mve_audio_enabledcxx . . $ mve_audio_enabled. = 0; |
| 479 | } |
| 480 | #endif |
| 481 | } |