1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "engines/util.h"
24 #include "sci/engine/kernel.h"
25 #include "sci/engine/state.h"
26 #include "sci/graphics/helpers.h"
27 #include "sci/graphics/cursor.h"
28 #include "sci/graphics/palette.h"
29 #include "sci/graphics/screen.h"
30 #include "sci/util.h"
31 #include "common/events.h"
32 #include "common/keyboard.h"
33 #include "common/span.h"
34 #include "common/str.h"
35 #include "common/system.h"
36 #include "common/textconsole.h"
37 #include "graphics/palette.h"
38 #include "graphics/pixelformat.h"
39 #include "graphics/surface.h"
40 #include "video/video_decoder.h"
41 #include "video/avi_decoder.h"
42 #include "video/qt_decoder.h"
43 #include "sci/video/seq_decoder.h"
44 #ifdef ENABLE_SCI32
45 #include "sci/engine/guest_additions.h"
46 #include "sci/graphics/frameout.h"
47 #include "sci/graphics/video32.h"
48 #include "sci/video/robot_decoder.h"
49 #endif
50
51 namespace Sci {
52
playVideo(Video::VideoDecoder & videoDecoder)53 void playVideo(Video::VideoDecoder &videoDecoder) {
54 videoDecoder.start();
55
56 Common::SpanOwner<SciSpan<byte> > scaleBuffer;
57 byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel;
58 uint16 width = videoDecoder.getWidth();
59 uint16 height = videoDecoder.getHeight();
60 uint16 pitch = videoDecoder.getWidth() * bytesPerPixel;
61 uint16 screenWidth = g_sci->_gfxScreen->getDisplayWidth();
62 uint16 screenHeight = g_sci->_gfxScreen->getDisplayHeight();
63 uint32 numPixels;
64
65 if (screenWidth == 640 && width <= 320 && height <= 240) {
66 width *= 2;
67 height *= 2;
68 pitch *= 2;
69 numPixels = width * height * bytesPerPixel;
70 scaleBuffer->allocate(numPixels, "video scale buffer");
71 }
72
73 uint16 x = (screenWidth - width) / 2;
74 uint16 y = (screenHeight - height) / 2;
75
76 bool skipVideo = false;
77
78 if (videoDecoder.hasDirtyPalette()) {
79 const byte *palette = videoDecoder.getPalette();
80 g_sci->_gfxScreen->setPalette(palette, 0, 255);
81 }
82
83 while (!g_engine->shouldQuit() && !videoDecoder.endOfVideo() && !skipVideo) {
84 if (videoDecoder.needsUpdate()) {
85 const Graphics::Surface *frame = videoDecoder.decodeNextFrame();
86
87 if (frame) {
88 Common::Rect rect(x, y, x+width, y+height);
89 if (scaleBuffer) {
90 const SciSpan<const byte> input((const byte *)frame->getPixels(), frame->w * frame->h * bytesPerPixel);
91 // TODO: Probably should do aspect ratio correction in KQ6
92 g_sci->_gfxScreen->scale2x(input, *scaleBuffer, videoDecoder.getWidth(), videoDecoder.getHeight(), bytesPerPixel);
93 g_sci->_gfxScreen->copyVideoFrameToScreen(scaleBuffer->getUnsafeDataAt(0, pitch * height), pitch, rect, bytesPerPixel == 1);
94 } else {
95 g_sci->_gfxScreen->copyVideoFrameToScreen((const byte *)frame->getPixels(), frame->pitch, rect, bytesPerPixel == 1);
96 }
97
98 if (videoDecoder.hasDirtyPalette()) {
99 const byte *palette = videoDecoder.getPalette();
100 g_sci->_gfxScreen->setPalette(palette, 0, 255);
101 }
102
103 g_system->updateScreen();
104 }
105 }
106
107 Common::Event event;
108 while (g_system->getEventManager()->pollEvent(event)) {
109 if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP)
110 skipVideo = true;
111 }
112 if (g_sci->getEngineState()->_delayedRestoreGameId != -1)
113 skipVideo = true;
114
115 g_system->delayMillis(10);
116 }
117 }
118
kShowMovie(EngineState * s,int argc,reg_t * argv)119 reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) {
120 // Hide the cursor if it's showing and then show it again if it was
121 // previously visible.
122 bool reshowCursor = g_sci->_gfxCursor->isVisible();
123 if (reshowCursor)
124 g_sci->_gfxCursor->kernelHide();
125
126 uint16 screenWidth = g_system->getWidth();
127 uint16 screenHeight = g_system->getHeight();
128
129 Common::ScopedPtr<Video::VideoDecoder> videoDecoder;
130
131 bool switchedGraphicsMode = false;
132
133 if (argv[0].isPointer()) {
134 Common::String filename = s->_segMan->getString(argv[0]);
135
136 if (g_sci->getPlatform() == Common::kPlatformMacintosh) {
137 // Mac QuickTime
138 // The only argument is the string for the video
139
140 // HACK: Switch to 16bpp graphics for Cinepak.
141 if (g_system->getScreenFormat().bytesPerPixel == 1) {
142 initGraphics(screenWidth, screenHeight, nullptr);
143 switchedGraphicsMode = true;
144 }
145
146 if (g_system->getScreenFormat().bytesPerPixel == 1) {
147 warning("This video requires >8bpp color to be displayed, but could not switch to RGB color mode");
148 return NULL_REG;
149 }
150
151 videoDecoder.reset(new Video::QuickTimeDecoder());
152 if (!videoDecoder->loadFile(filename))
153 error("Could not open '%s'", filename.c_str());
154 } else {
155 // DOS SEQ
156 // SEQ's are called with no subops, just the string and delay
157 // Time is specified as ticks
158 videoDecoder.reset(new SEQDecoder(argv[1].toUint16()));
159
160 if (!videoDecoder->loadFile(filename)) {
161 warning("Failed to open movie file %s", filename.c_str());
162 videoDecoder.reset();
163 }
164 }
165 } else {
166 // Windows AVI
167 // TODO: This appears to be some sort of subop. case 0 contains the string
168 // for the video, so we'll just play it from there for now.
169
170 switch (argv[0].toUint16()) {
171 case 0: {
172 Common::String filename = s->_segMan->getString(argv[1]);
173 videoDecoder.reset(new Video::AVIDecoder());
174 if (!videoDecoder->loadFile(filename.c_str())) {
175 warning("Failed to open movie file %s", filename.c_str());
176 videoDecoder.reset();
177 }
178 break;
179 }
180 default:
181 warning("Unhandled SCI kShowMovie subop %d", argv[0].toUint16());
182 }
183 }
184
185 if (videoDecoder) {
186 bool is8bit = videoDecoder->getPixelFormat().bytesPerPixel == 1;
187
188 playVideo(*videoDecoder);
189
190 // HACK: Switch back to 8bpp if we played a true color video.
191 // We also won't be copying the screen to the SCI screen...
192 if (switchedGraphicsMode)
193 initGraphics(screenWidth, screenHeight);
194 else if (is8bit) {
195 g_sci->_gfxScreen->kernelSyncWithFramebuffer();
196 g_sci->_gfxPalette16->kernelSyncScreenPalette();
197 }
198 }
199
200 if (reshowCursor)
201 g_sci->_gfxCursor->kernelShow();
202
203 return s->r_acc;
204 }
205
206 #ifdef ENABLE_SCI32
kShowMovie32(EngineState * s,int argc,reg_t * argv)207 reg_t kShowMovie32(EngineState *s, int argc, reg_t *argv) {
208 Common::String fileName = s->_segMan->getString(argv[0]);
209 const int16 numTicks = argv[1].toSint16();
210 const int16 x = argc > 3 ? argv[2].toSint16() : 0;
211 const int16 y = argc > 3 ? argv[3].toSint16() : 0;
212
213 if (g_sci->getPlatform() == Common::kPlatformMacintosh) {
214 g_sci->_video32->getQuickTimePlayer().play(fileName);
215 } else {
216 g_sci->_video32->getSEQPlayer().play(fileName, numTicks, x, y);
217 }
218
219 return s->r_acc;
220 }
221
kRobot(EngineState * s,int argc,reg_t * argv)222 reg_t kRobot(EngineState *s, int argc, reg_t *argv) {
223 if (!s)
224 return make_reg(0, getSciVersion());
225 error("not supposed to call this");
226 }
227
kRobotOpen(EngineState * s,int argc,reg_t * argv)228 reg_t kRobotOpen(EngineState *s, int argc, reg_t *argv) {
229 const GuiResourceId robotId = argv[0].toUint16();
230 const reg_t plane = argv[1];
231 const int16 priority = argv[2].toSint16();
232 const int16 x = argv[3].toSint16();
233 const int16 y = argv[4].toSint16();
234 const int16 scale = argc > 5 ? argv[5].toSint16() : 128;
235 g_sci->_video32->getRobotPlayer().open(robotId, plane, priority, x, y, scale);
236 return make_reg(0, 0);
237 }
kRobotShowFrame(EngineState * s,int argc,reg_t * argv)238 reg_t kRobotShowFrame(EngineState *s, int argc, reg_t *argv) {
239 const uint16 frameNo = argv[0].toUint16();
240 const uint16 newX = argc > 1 ? argv[1].toUint16() : (uint16)RobotDecoder::kUnspecified;
241 const uint16 newY = argc > 1 ? argv[2].toUint16() : (uint16)RobotDecoder::kUnspecified;
242 g_sci->_video32->getRobotPlayer().showFrame(frameNo, newX, newY, RobotDecoder::kUnspecified);
243 return s->r_acc;
244 }
245
kRobotGetFrameSize(EngineState * s,int argc,reg_t * argv)246 reg_t kRobotGetFrameSize(EngineState *s, int argc, reg_t *argv) {
247 Common::Rect frameRect;
248 const uint16 numFramesTotal = g_sci->_video32->getRobotPlayer().getFrameSize(frameRect);
249
250 SciArray *outRect = s->_segMan->lookupArray(argv[0]);
251 reg_t values[4] = {
252 make_reg(0, frameRect.left),
253 make_reg(0, frameRect.top),
254 make_reg(0, frameRect.right - 1),
255 make_reg(0, frameRect.bottom - 1) };
256 outRect->setElements(0, 4, values);
257
258 return make_reg(0, numFramesTotal);
259 }
260
kRobotPlay(EngineState * s,int argc,reg_t * argv)261 reg_t kRobotPlay(EngineState *s, int argc, reg_t *argv) {
262 g_sci->_video32->getRobotPlayer().resume();
263 return s->r_acc;
264 }
265
kRobotGetIsFinished(EngineState * s,int argc,reg_t * argv)266 reg_t kRobotGetIsFinished(EngineState *s, int argc, reg_t *argv) {
267 return make_reg(0, g_sci->_video32->getRobotPlayer().getStatus() == RobotDecoder::kRobotStatusEnd);
268 }
269
kRobotGetIsInitialized(EngineState * s,int argc,reg_t * argv)270 reg_t kRobotGetIsInitialized(EngineState *s, int argc, reg_t *argv) {
271 return make_reg(0, g_sci->_video32->getRobotPlayer().getStatus() != RobotDecoder::kRobotStatusUninitialized);
272 }
273
kRobotClose(EngineState * s,int argc,reg_t * argv)274 reg_t kRobotClose(EngineState *s, int argc, reg_t *argv) {
275 g_sci->_video32->getRobotPlayer().close();
276 return s->r_acc;
277 }
278
kRobotGetCue(EngineState * s,int argc,reg_t * argv)279 reg_t kRobotGetCue(EngineState *s, int argc, reg_t *argv) {
280 writeSelectorValue(s->_segMan, argv[0], SELECTOR(signal), g_sci->_video32->getRobotPlayer().getCue());
281 return s->r_acc;
282 }
283
kRobotPause(EngineState * s,int argc,reg_t * argv)284 reg_t kRobotPause(EngineState *s, int argc, reg_t *argv) {
285 g_sci->_video32->getRobotPlayer().pause();
286 return s->r_acc;
287 }
288
kRobotGetFrameNo(EngineState * s,int argc,reg_t * argv)289 reg_t kRobotGetFrameNo(EngineState *s, int argc, reg_t *argv) {
290 return make_reg(0, g_sci->_video32->getRobotPlayer().getFrameNo());
291 }
292
kRobotSetPriority(EngineState * s,int argc,reg_t * argv)293 reg_t kRobotSetPriority(EngineState *s, int argc, reg_t *argv) {
294 g_sci->_video32->getRobotPlayer().setPriority(argv[0].toSint16());
295 return s->r_acc;
296 }
297
kShowMovieWin(EngineState * s,int argc,reg_t * argv)298 reg_t kShowMovieWin(EngineState *s, int argc, reg_t *argv) {
299 if (!s)
300 return make_reg(0, getSciVersion());
301 error("not supposed to call this");
302 }
303
kShowMovieWinOpen(EngineState * s,int argc,reg_t * argv)304 reg_t kShowMovieWinOpen(EngineState *s, int argc, reg_t *argv) {
305 // SCI2.1 adds a movie ID to the call, but the movie ID is broken,
306 // so just ignore it
307 if (getSciVersion() > SCI_VERSION_2) {
308 ++argv;
309 --argc;
310 }
311
312 const Common::String fileName = s->_segMan->getString(argv[0]);
313 return make_reg(0, g_sci->_video32->getAVIPlayer().open(fileName));
314 }
315
kShowMovieWinInit(EngineState * s,int argc,reg_t * argv)316 reg_t kShowMovieWinInit(EngineState *s, int argc, reg_t *argv) {
317 // SCI2.1 adds a movie ID to the call, but the movie ID is broken,
318 // so just ignore it
319 if (getSciVersion() > SCI_VERSION_2) {
320 ++argv;
321 --argc;
322 }
323
324 // argv[0] is a broken x-coordinate
325 // argv[1] is a broken y-coordinate
326 // argv[2] is an optional broken width
327 // argv[3] is an optional broken height
328 const bool pixelDouble = argc > 3 && argv[2].toSint16() && argv[3].toSint16();
329 return make_reg(0, g_sci->_video32->getAVIPlayer().init(pixelDouble));
330 }
331
kShowMovieWinPlay(EngineState * s,int argc,reg_t * argv)332 reg_t kShowMovieWinPlay(EngineState *s, int argc, reg_t *argv) {
333 if (getSciVersion() == SCI_VERSION_2) {
334 AVIPlayer::EventFlags flags = (AVIPlayer::EventFlags)argv[0].toUint16();
335 return make_reg(0, g_sci->_video32->getAVIPlayer().playUntilEvent(flags));
336 } else {
337 // argv[0] is a broken movie ID
338 const int16 from = argc > 2 ? argv[1].toSint16() : 0;
339 const int16 to = argc > 2 ? argv[2].toSint16() : 0;
340 const int16 showStyle = argc > 3 ? argv[3].toSint16() : 0;
341 const bool cue = argc > 4 ? (bool)argv[4].toSint16() : false;
342 return make_reg(0, g_sci->_video32->getAVIPlayer().play(from, to, showStyle, cue));
343 }
344 }
345
kShowMovieWinClose(EngineState * s,int argc,reg_t * argv)346 reg_t kShowMovieWinClose(EngineState *s, int argc, reg_t *argv) {
347 return make_reg(0, g_sci->_video32->getAVIPlayer().close());
348 }
349
kShowMovieWinGetDuration(EngineState * s,int argc,reg_t * argv)350 reg_t kShowMovieWinGetDuration(EngineState *s, int argc, reg_t *argv) {
351 return make_reg(0, g_sci->_video32->getAVIPlayer().getDuration());
352 }
353
kShowMovieWinCue(EngineState * s,int argc,reg_t * argv)354 reg_t kShowMovieWinCue(EngineState *s, int argc, reg_t *argv) {
355 // SCI2.1 adds a movie ID to the call, but the movie ID is broken,
356 // so just ignore it
357 if (getSciVersion() > SCI_VERSION_2) {
358 ++argv;
359 --argc;
360 }
361
362 const uint16 frameNo = argv[0].toUint16();
363 return make_reg(0, g_sci->_video32->getAVIPlayer().cue(frameNo));
364 }
365
kShowMovieWinPlayUntilEvent(EngineState * s,int argc,reg_t * argv)366 reg_t kShowMovieWinPlayUntilEvent(EngineState *s, int argc, reg_t *argv) {
367 const int defaultFlags =
368 AVIPlayer::kEventFlagEnd |
369 AVIPlayer::kEventFlagEscapeKey;
370
371 // argv[0] is the movie number, which is not used by this method
372 const AVIPlayer::EventFlags flags = (AVIPlayer::EventFlags)(argc > 1 ? argv[1].toUint16() : defaultFlags);
373
374 return make_reg(0, g_sci->_video32->getAVIPlayer().playUntilEvent(flags));
375 }
376
kShowMovieWinInitDouble(EngineState * s,int argc,reg_t * argv)377 reg_t kShowMovieWinInitDouble(EngineState *s, int argc, reg_t *argv) {
378 // argv[0] is a broken movie ID
379 // argv[1] is a broken x-coordinate
380 // argv[2] is a broken y-coordinate
381 return make_reg(0, g_sci->_video32->getAVIPlayer().init(true));
382 }
383
kPlayVMD(EngineState * s,int argc,reg_t * argv)384 reg_t kPlayVMD(EngineState *s, int argc, reg_t *argv) {
385 if (!s)
386 return make_reg(0, getSciVersion());
387 error("not supposed to call this");
388 }
389
kPlayVMDOpen(EngineState * s,int argc,reg_t * argv)390 reg_t kPlayVMDOpen(EngineState *s, int argc, reg_t *argv) {
391 const Common::String fileName = s->_segMan->getString(argv[0]);
392 // argv[1] is an optional cache size argument which we do not use
393 // const uint16 cacheSize = argc > 1 ? CLIP<int16>(argv[1].toSint16(), 16, 1024) : 0;
394 const VMDPlayer::OpenFlags flags = argc > 2 ? (VMDPlayer::OpenFlags)argv[2].toUint16() : VMDPlayer::kOpenFlagNone;
395
396 return make_reg(0, g_sci->_video32->getVMDPlayer().open(fileName, flags));
397 }
398
kPlayVMDInit(EngineState * s,int argc,reg_t * argv)399 reg_t kPlayVMDInit(EngineState *s, int argc, reg_t *argv) {
400 const int16 x = argv[0].toSint16();
401 const int16 y = argv[1].toSint16();
402 const VMDPlayer::PlayFlags flags = argc > 2 ? (VMDPlayer::PlayFlags)argv[2].toUint16() : VMDPlayer::kPlayFlagNone;
403 int16 boostPercent;
404 int16 boostStartColor;
405 int16 boostEndColor;
406 if (argc > 5 && (flags & VMDPlayer::kPlayFlagBoost)) {
407 boostPercent = argv[3].toSint16();
408 boostStartColor = argv[4].toSint16();
409 boostEndColor = argv[5].toSint16();
410 } else {
411 boostPercent = 0;
412 boostStartColor = -1;
413 boostEndColor = -1;
414 }
415
416 g_sci->_video32->getVMDPlayer().init(x, y, flags, boostPercent, boostStartColor, boostEndColor);
417
418 return make_reg(0, 0);
419 }
420
kPlayVMDClose(EngineState * s,int argc,reg_t * argv)421 reg_t kPlayVMDClose(EngineState *s, int argc, reg_t *argv) {
422 return make_reg(0, g_sci->_video32->getVMDPlayer().close());
423 }
424
kPlayVMDIgnorePalettes(EngineState * s,int argc,reg_t * argv)425 reg_t kPlayVMDIgnorePalettes(EngineState *s, int argc, reg_t *argv) {
426 g_sci->_video32->getVMDPlayer().ignorePalettes();
427 return s->r_acc;
428 }
429
kPlayVMDGetStatus(EngineState * s,int argc,reg_t * argv)430 reg_t kPlayVMDGetStatus(EngineState *s, int argc, reg_t *argv) {
431 return make_reg(0, g_sci->_video32->getVMDPlayer().getStatus());
432 }
433
kPlayVMDPlayUntilEvent(EngineState * s,int argc,reg_t * argv)434 reg_t kPlayVMDPlayUntilEvent(EngineState *s, int argc, reg_t *argv) {
435 if (g_sci->_guestAdditions->kPlayDuckPlayVMDHook()) {
436 return make_reg(0, VMDPlayer::kEventFlagEnd);
437 }
438
439 const VMDPlayer::EventFlags flags = (VMDPlayer::EventFlags)argv[0].toUint16();
440 const int16 lastFrameNo = argc > 1 ? argv[1].toSint16() : -1;
441 const int16 yieldInterval = argc > 2 ? argv[2].toSint16() : -1;
442 return make_reg(0, g_sci->_video32->getVMDPlayer().kernelPlayUntilEvent(flags, lastFrameNo, yieldInterval));
443 }
444
kPlayVMDShowCursor(EngineState * s,int argc,reg_t * argv)445 reg_t kPlayVMDShowCursor(EngineState *s, int argc, reg_t *argv) {
446 g_sci->_video32->getVMDPlayer().setShowCursor((bool)argv[0].toUint16());
447 return s->r_acc;
448 }
449
kPlayVMDStartBlob(EngineState * s,int argc,reg_t * argv)450 reg_t kPlayVMDStartBlob(EngineState *s, int argc, reg_t *argv) {
451 g_sci->_video32->getVMDPlayer().deleteBlobs();
452 return NULL_REG;
453 }
454
kPlayVMDStopBlobs(EngineState * s,int argc,reg_t * argv)455 reg_t kPlayVMDStopBlobs(EngineState *s, int argc, reg_t *argv) {
456 g_sci->_video32->getVMDPlayer().deleteBlobs();
457 return NULL_REG;
458 }
459
kPlayVMDAddBlob(EngineState * s,int argc,reg_t * argv)460 reg_t kPlayVMDAddBlob(EngineState *s, int argc, reg_t *argv) {
461 int16 squareSize = argv[0].toSint16();
462 int16 top = argv[1].toSint16();
463 int16 left = argv[2].toSint16();
464 int16 bottom = argv[3].toSint16();
465 int16 right = argv[4].toSint16();
466 int16 blobNumber = g_sci->_video32->getVMDPlayer().addBlob(squareSize, top, left, bottom, right);
467 return make_reg(0, blobNumber);
468 }
469
kPlayVMDDeleteBlob(EngineState * s,int argc,reg_t * argv)470 reg_t kPlayVMDDeleteBlob(EngineState *s, int argc, reg_t *argv) {
471 int16 blobNumber = argv[0].toSint16();
472 g_sci->_video32->getVMDPlayer().deleteBlob(blobNumber);
473 return SIGNAL_REG;
474 }
475
kPlayVMDSetBlackoutArea(EngineState * s,int argc,reg_t * argv)476 reg_t kPlayVMDSetBlackoutArea(EngineState *s, int argc, reg_t *argv) {
477 const int16 scriptWidth = g_sci->_gfxFrameout->getScriptWidth();
478 const int16 scriptHeight = g_sci->_gfxFrameout->getScriptHeight();
479
480 Common::Rect blackoutArea;
481 blackoutArea.left = MAX<int16>(0, argv[0].toSint16());
482 blackoutArea.top = MAX<int16>(0, argv[1].toSint16());
483 blackoutArea.right = MIN<int16>(scriptWidth, argv[2].toSint16() + 1);
484 blackoutArea.bottom = MIN<int16>(scriptHeight, argv[3].toSint16() + 1);
485 g_sci->_video32->getVMDPlayer().setBlackoutArea(blackoutArea);
486 return s->r_acc;
487 }
488
kPlayVMDRestrictPalette(EngineState * s,int argc,reg_t * argv)489 reg_t kPlayVMDRestrictPalette(EngineState *s, int argc, reg_t *argv) {
490 g_sci->_video32->getVMDPlayer().restrictPalette(argv[0].toUint16(), argv[1].toUint16());
491 return s->r_acc;
492 }
493
kPlayVMDSetPlane(EngineState * s,int argc,reg_t * argv)494 reg_t kPlayVMDSetPlane(EngineState *s, int argc, reg_t *argv) {
495 g_sci->_video32->getVMDPlayer().setPlane(argv[0].toSint16(), argc > 1 ? argv[1] : NULL_REG);
496 return s->r_acc;
497 }
498
kPlayDuck(EngineState * s,int argc,reg_t * argv)499 reg_t kPlayDuck(EngineState *s, int argc, reg_t *argv) {
500 if (!s)
501 return make_reg(0, getSciVersion());
502 error("not supposed to call this");
503 }
504
kPlayDuckPlay(EngineState * s,int argc,reg_t * argv)505 reg_t kPlayDuckPlay(EngineState *s, int argc, reg_t *argv) {
506 if (g_sci->_guestAdditions->kPlayDuckPlayVMDHook()) {
507 return NULL_REG;
508 }
509 kPlayDuckOpen(s, argc, argv);
510 g_sci->_video32->getDuckPlayer().play(-1);
511 g_sci->_video32->getDuckPlayer().close();
512 return NULL_REG;
513 }
514
kPlayDuckSetFrameOut(EngineState * s,int argc,reg_t * argv)515 reg_t kPlayDuckSetFrameOut(EngineState *s, int argc, reg_t *argv) {
516 g_sci->_video32->getDuckPlayer().setDoFrameOut((bool)argv[0].toUint16());
517 return NULL_REG;
518 }
519
kPlayDuckOpen(EngineState * s,int argc,reg_t * argv)520 reg_t kPlayDuckOpen(EngineState *s, int argc, reg_t *argv) {
521 const GuiResourceId resourceId = argv[0].toUint16();
522 const int displayMode = argv[1].toSint16();
523 const int16 x = argv[2].toSint16();
524 const int16 y = argv[3].toSint16();
525 // argv[4] is a cache size argument that we do not use
526 g_sci->_video32->getDuckPlayer().open(resourceId, displayMode, x, y);
527 return NULL_REG;
528 }
529
kPlayDuckClose(EngineState * s,int argc,reg_t * argv)530 reg_t kPlayDuckClose(EngineState *s, int argc, reg_t *argv) {
531 g_sci->_video32->getDuckPlayer().close();
532 return NULL_REG;
533 }
534
kPlayDuckSetVolume(EngineState * s,int argc,reg_t * argv)535 reg_t kPlayDuckSetVolume(EngineState *s, int argc, reg_t *argv) {
536 g_sci->_video32->getDuckPlayer().setVolume(argv[0].toUint16());
537 return NULL_REG;
538 }
539
540 #endif
541
542 } // End of namespace Sci
543