1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "common/endian.h"
#include "gob/gob.h"
#include "gob/demos/demoplayer.h"
#include "gob/global.h"
#include "gob/util.h"
#include "gob/draw.h"
#include "gob/inter.h"
#include "gob/videoplayer.h"
namespace Gob {
DemoPlayer::DemoPlayer(GobEngine *vm) : _vm(vm) {
_doubleMode = false;
}
DemoPlayer::~DemoPlayer() {
}
bool DemoPlayer::lineStartsWith(const Common::String &line, const char *start) {
return (strstr(line.c_str(), start) == line.c_str());
}
void DemoPlayer::init() {
// The video player needs some fake variables
_vm->_inter->allocateVars(32);
// Init the screen
_vm->_draw->initScreen();
_vm->_draw->_cursorIndex = -1;
_vm->_util->longDelay(200); // Letting everything settle
}
void DemoPlayer::clearScreen() {
debugC(1, kDebugDemo, "Clearing the screen");
_vm->_video->clearScreen();
}
void DemoPlayer::playVideo(const char *fileName) {
uint32 waitTime = 0;
char *file, *filePtr;
file = filePtr = strdupcpy(fileName);
// Trimming spaces front
while (*file == ' ')
file++;
char *spaceBack = strchr(file, ' ');
if (spaceBack) {
char *nextSpace = strchr(spaceBack, ' ');
if (nextSpace)
*nextSpace = '\0';
*spaceBack++ = '\0';
waitTime = atoi(spaceBack) * 100;
}
// WORKAROUND: The Inca2 demo wants to play cons2.imd, but that file doesn't exist.
// cons.imd does, however.
if ((_vm->getGameType() == kGameTypeInca2) && (!scumm_stricmp(file, "cons2.imd")))
strcpy(file, "cons.imd");
debugC(1, kDebugDemo, "Playing video \"%s\"", file);
if (_vm->_vidPlayer->primaryOpen(file)) {
bool videoSupportsDouble =
((_vm->_vidPlayer->getFeatures() & CoktelVideo::kFeaturesSupportsDouble) != 0);
if (_doubleMode) {
if (videoSupportsDouble) {
_vm->_vidPlayer->slotSetDoubleMode(-1, true);
playVideoNormal();
} else
playVideoDoubled();
} else
playVideoNormal();
_vm->_vidPlayer->primaryClose();
if (waitTime > 0)
_vm->_util->longDelay(waitTime);
}
delete[] filePtr;
}
void DemoPlayer::playVideoNormal() {
_vm->_vidPlayer->primaryPlay();
}
void DemoPlayer::playVideoDoubled() {
const char *fileNameOpened = _vm->_vidPlayer->getFileName();
char *fileName = strdupcpy(fileNameOpened);
_vm->_vidPlayer->primaryClose();
if (_vm->_vidPlayer->primaryOpen(fileName, 0, -1, VideoPlayer::kFlagOtherSurface)) {
for (int i = 0; i < _vm->_vidPlayer->getFramesCount(); i++) {
if (_vm->_vidPlayer->primaryPlay(i, i))
break;
CoktelVideo::State state = _vm->_vidPlayer->getState();
int16 w = state.right - state.left + 1;
int16 h = state.bottom - state.top + 1;
int16 wD = (state.left * 2) + (w * 2);
int16 hD = (state.top * 2) + (h * 2);
_vm->_video->drawSpriteDouble(_vm->_draw->_spritesArray[0], _vm->_draw->_frontSurface,
state.left, state.top, state.right, state.bottom, state.left, state.top, 0);
_vm->_draw->dirtiedRect(_vm->_draw->_frontSurface,
state.left * 2, state.top * 2, wD, hD);
_vm->_video->retrace();
}
}
delete[] fileName;
}
void DemoPlayer::evaluateVideoMode(const char *mode) {
debugC(2, kDebugDemo, "Video mode \"%s\"", mode);
if (!scumm_strnicmp(mode, "VESA", 4))
_doubleMode = false;
else if (!scumm_strnicmp(mode, "VGA", 3) && _vm->is640())
_doubleMode = true;
}
} // End of namespace Gob
|