Ticket #8650: diff.2

File diff.2, 4.9 KB (added by SF/robinwatts, 17 years ago)

Corrected patch to allow DXA to double if required

Line 
1Index: engines/sword1/animation.cpp
2===================================================================
3--- engines/sword1/animation.cpp (revision 26742)
4+++ engines/sword1/animation.cpp (working copy)
5@@ -405,7 +405,7 @@
6
7 char filename[20];
8 snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]);
9- if (loadFile(filename)) {
10+ if (loadFile(filename, 640, 480)) {
11 // The Broken Sword games always use external audio tracks.
12 if (_fd.readUint32BE() != MKID_BE('NULL'))
13 return false;
14Index: engines/sword2/animation.cpp
15===================================================================
16--- engines/sword2/animation.cpp (revision 26742)
17+++ engines/sword2/animation.cpp (working copy)
18@@ -510,7 +510,9 @@
19
20 snprintf(filename, sizeof(filename), "%s.dxa", _name);
21
22- if (loadFile(filename)) {
23+ if (loadFile(filename,
24+ _vm->_screen->getScreenWide(),
25+ _vm->_screen->getScreenDeep())) {
26 // The Broken Sword games always use external audio tracks.
27 if (_fd.readUint32BE() != MKID_BE('NULL'))
28 return false;
29Index: engines/agos/animation.cpp
30===================================================================
31--- engines/agos/animation.cpp (revision 26742)
32+++ engines/agos/animation.cpp (working copy)
33@@ -62,19 +62,21 @@
34 // Change file extension to dxa
35 sprintf(videoName, "%s.dxa", baseName);
36
37- if (!loadFile(videoName)) {
38+ if (!loadFile(videoName,
39+ _vm->_screenWidth,
40+ _vm->_screenHeight)) {
41 // Check short filename to work around
42 // bug in a German Windows 2CD version.
43 if (baseLen >= 8) {
44 char shortName[20];
45 memset(shortName, 0, sizeof(shortName));
46 memcpy(shortName, filename, 6);
47-
48+
49 sprintf(shortName, "%s~1.dxa", shortName);
50
51 if (!loadFile(shortName))
52 error("Failed to load video file %s or %s", videoName, shortName);
53-
54+
55 memset(baseName, 0, sizeof(baseName));
56 memcpy(baseName, shortName, 8);
57 debug(0, "Playing video %s", shortName);
58Index: graphics/dxa_player.cpp
59===================================================================
60--- graphics/dxa_player.cpp (revision 26742)
61+++ graphics/dxa_player.cpp (working copy)
62@@ -29,6 +29,24 @@
63 #include <zlib.h>
64 #endif
65
66+static void scaleUpBy2(byte *dst, byte *src, uint16 width, uint16 h) {
67+ uint16 x;
68+
69+ while (h > 0)
70+ {
71+ for (x=width; x>0; x--)
72+ {
73+ register byte v;
74+ v = *src++;
75+ *dst++ = v;
76+ *dst++ = v;
77+ }
78+ memcpy(dst, dst-width*2, width*2);
79+ dst += width*2;
80+ h--;
81+ }
82+}
83+
84 namespace Graphics {
85
86 DXAPlayer::DXAPlayer() {
87@@ -36,6 +54,7 @@
88 _frameBuffer2 = 0;
89 _scaledBuffer = 0;
90 _drawBuffer = 0;
91+ _scaledBuffer2 = 0;
92
93 _width = 0;
94 _height = 0;
95@@ -48,6 +67,8 @@
96 _frameTicks = 0;
97
98 _scaleMode = S_NONE;
99+
100+ _scaling = 1;
101 }
102
103 DXAPlayer::~DXAPlayer() {
104@@ -56,13 +77,13 @@
105 int DXAPlayer::getWidth() {
106 if (!_fd.isOpen())
107 return 0;
108- return _width;
109+ return _width*_scaling;
110 }
111
112 int DXAPlayer::getHeight() {
113 if (!_fd.isOpen())
114 return 0;
115- return _height;
116+ return _height*_scaling;
117 }
118
119 int DXAPlayer::getCurFrame() {
120@@ -77,6 +98,26 @@
121 return _framesCount;
122 }
123
124+bool DXAPlayer::loadFile(const char *filename, uint16 maxWidth, uint16 maxHeight) {
125+ bool result = loadFile(filename);
126+
127+ if (result)
128+ {
129+ _scaling = MIN(maxWidth/_width, maxHeight/_height);
130+ if (_scaling < 1)
131+ _scaling = 1;
132+ if (_scaling > 2)
133+ _scaling = 2;
134+ if (_scaling >= 2)
135+ {
136+ _scaledBuffer2 = (uint8 *)malloc(_width*_height*_scaling*_scaling);
137+ if (!_scaledBuffer2) {
138+ _scaling = 1;
139+ }
140+ }
141+ }
142+ return result;
143+}
144 bool DXAPlayer::loadFile(const char *filename) {
145 uint32 tag;
146 int32 frameRate;
147@@ -147,6 +188,7 @@
148 free(_frameBuffer1);
149 free(_frameBuffer2);
150 free(_scaledBuffer);
151+ free(_scaledBuffer2);
152 }
153
154 void DXAPlayer::copyFrameToBuffer(byte *dst, uint x, uint y, uint pitch) {
155@@ -535,6 +577,12 @@
156 _drawBuffer = _frameBuffer1;
157 break;
158 }
159+
160+ if (_scaling == 2) {
161+ /* Scale up here */
162+ scaleUpBy2(_scaledBuffer2, _drawBuffer, _width, _height);
163+ _drawBuffer = _scaledBuffer2;
164+ }
165 }
166
167 } // End of namespace Graphics
168Index: graphics/dxa_player.h
169===================================================================
170--- graphics/dxa_player.h (revision 26742)
171+++ graphics/dxa_player.h (working copy)
172@@ -46,6 +46,7 @@
173 byte *_frameBuffer2;
174 byte *_scaledBuffer;
175 byte *_drawBuffer;
176+ byte *_scaledBuffer2;
177 uint16 _width;
178 uint16 _height, _curHeight;
179 uint16 _framesCount;
180@@ -55,6 +56,7 @@
181 uint16 _frameSkipped;
182 uint32 _frameTicks;
183 ScaleMode _scaleMode;
184+ uint32 _scaling;
185
186 public:
187 DXAPlayer();
188@@ -91,6 +93,14 @@
189 bool loadFile(const char *filename);
190
191 /**
192+ * Load a DXA encoded video file and setup scaling if required
193+ * @param filename the filename to load
194+ * @param maxWidth the maximum width available to the film
195+ * @param maxHeight the maximum height available to the film
196+ */
197+ bool loadFile(const char *filename, uint16 maxWidth, uint16 maxHeight);
198+
199+ /**
200 * Close a DXA encoded video file
201 */
202 void closeFile();