Ticket #8042: savepalmanipulate.2.diff

File savepalmanipulate.2.diff, 9.0 KB (added by SF/jamieson630, 22 years ago)
Line 
1--- scummvm\scumm\scumm.h Fri Sep 13 14:20:44 2002
2+++ scummvm\scumm\scumm.new.h Fri Sep 13 14:29:48 2002
3@@ -851,7 +851,10 @@
4
5 int _drawObjectQueNr;
6 byte _drawObjectQue[200];
7- int16 _palManipStart, _palManipEnd, _palManipCounter;
8+ byte _palManipStart, _palManipEnd;
9+ uint16 _palManipCounter;
10+ byte *_palManipPalette;
11+ byte *_palManipIntermediatePal;
12 uint32 gfxUsageBits[200];
13 byte *_shadowPalette;
14 int _shadowPaletteSize;
15--- scummvm\scumm\resource_v2.cpp Fri Sep 13 14:20:44 2002
16+++ scummvm\scumm\resource_v2.new.cpp Fri Sep 13 13:52:08 2002
17@@ -61,6 +61,12 @@
18
19 _shadowPaletteSize = 256;
20 _shadowPalette = (byte *) calloc(_shadowPaletteSize, 1); // FIXME - needs to be removed later
21+
22+ // Jamieson630: palManipulate variable initialization
23+ _palManipCounter = 0;
24+ _palManipPalette = 0; // Will allocate when needed
25+ _palManipIntermediatePal = 0; // Will allocate when needed
26+
27 _numFlObject = 50;
28 allocateArrays();
29
30--- scummvm\scumm\resource_v3.cpp Fri Sep 13 14:20:44 2002
31+++ scummvm\scumm\resource_v3.new.cpp Fri Sep 13 13:52:40 2002
32@@ -84,6 +84,12 @@
33
34 _shadowPaletteSize = 256;
35 _shadowPalette = (byte *) calloc(_shadowPaletteSize, 1); // stupid for now. Need to be removed later
36+
37+ // Jamieson630: palManipulate variable initialization
38+ _palManipCounter = 0;
39+ _palManipPalette = 0; // Will allocate when needed
40+ _palManipIntermediatePal = 0; // Will allocate when needed
41+
42 _numFlObject = 50;
43 allocateArrays();
44
45--- scummvm\scumm\saveload.cpp Fri Sep 13 14:20:44 2002
46+++ scummvm\scumm\saveload.new.cpp Fri Sep 13 13:57:34 2002
47@@ -400,6 +400,11 @@
48 MKLINE(Scumm, _switchRoomEffect2, sleByte),
49 MKLINE(Scumm, _BgNeedsRedraw, sleByte),
50
51+ // Jamieson630: variables for palManipulate
52+ MKLINE(Scumm, _palManipStart, sleByte),
53+ MKLINE(Scumm, _palManipEnd, sleByte),
54+ MKLINE(Scumm, _palManipCounter, sleUint16),
55+
56 MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 200),
57 MKLINE(Scumm, gdi._transparency, sleByte),
58 MKARRAY(Scumm, _currentPalette[0], sleByte, 768),
59@@ -505,6 +510,11 @@
60 MKLINE(Scumm, _switchRoomEffect2, sleByte),
61 MKLINE(Scumm, _BgNeedsRedraw, sleByte),
62
63+ // Jamieson630: variables for palManipulate
64+ MKLINE(Scumm, _palManipStart, sleByte),
65+ MKLINE(Scumm, _palManipEnd, sleByte),
66+ MKLINE(Scumm, _palManipCounter, sleUint16),
67+
68 MKARRAY(Scumm, gfxUsageBits[0], sleUint32, 200),
69 MKLINE(Scumm, gdi._transparency, sleByte),
70 MKARRAY(Scumm, _currentPalette[0], sleByte, 768),
71@@ -634,6 +644,14 @@
72
73 if (_shadowPaletteSize)
74 s->saveLoadArrayOf(_shadowPalette, _shadowPaletteSize, 1, sleByte);
75+ if (_palManipCounter) {
76+ if (!_palManipPalette)
77+ _palManipPalette = (byte *)calloc(0x300, 1);
78+ if (!_palManipIntermediatePal)
79+ _palManipPalette = (byte *)calloc(0x300, 1);
80+ s->saveLoadArrayOf(_palManipPalette, 0x300, 1, sleByte);
81+ s->saveLoadArrayOf(_palManipIntermediatePal, 0x600, 1, sleByte);
82+ }
83
84 s->saveLoadArrayOf(_classData, _numGlobalObjects, sizeof(_classData[0]), sleUint32);
85
86--- scummvm\scumm\gfx.cpp Fri Sep 13 06:55:00 2002
87+++ scummvm\scumm\gfx.new.cpp Fri Sep 13 14:24:22 2002
88@@ -554,17 +554,14 @@
89 byte *startptr2, *endptr2;
90 int num;
91 byte tmp[6];
92- byte tmp2[6];
93
94 if (!_palManipCounter)
95 return;
96
97- startptr = getResourceAddress(rtTemp, 4) + start * 6;
98- endptr = getResourceAddress(rtTemp, 4) + end * 6;
99-
100- startptr2 = getResourceAddress(rtTemp, 5) + start * 6;
101- endptr2 = getResourceAddress(rtTemp, 5) + end * 6;
102-
103+ startptr = _palManipPalette + start * 3;
104+ endptr = _palManipPalette + end * 3;
105+ startptr2 = _palManipIntermediatePal + start * 6;
106+ endptr2 = _palManipIntermediatePal + end * 6;
107 num = end - start;
108
109 if (!endptr) {
110@@ -573,19 +570,19 @@
111 }
112
113 if (!direction) {
114- memmove(tmp, endptr, 6);
115- memmove(startptr + 6, startptr, num * 6);
116- memmove(startptr, tmp, 6);
117- memmove(tmp2, endptr2, 6);
118+ memmove(tmp, endptr, 3);
119+ memmove(startptr + 3, startptr, num * 3);
120+ memmove(startptr, tmp, 3);
121+ memmove(tmp, endptr2, 6);
122 memmove(startptr2 + 6, startptr2, num * 6);
123- memmove(startptr2, tmp2, 6);
124+ memmove(startptr2, tmp, 6);
125 } else {
126- memmove(tmp, startptr, 6);
127- memmove(startptr, startptr + 6, num * 6);
128- memmove(endptr, tmp, 6);
129- memmove(tmp2, startptr2, 6);
130+ memmove(tmp, startptr, 3);
131+ memmove(startptr, startptr + 3, num * 3);
132+ memmove(endptr, tmp, 3);
133+ memmove(tmp, startptr2, 6);
134 memmove(startptr2, startptr2 + 6, num * 6);
135- memmove(endptr2, tmp2, 6);
136+ memmove(endptr2, tmp, 6);
137 }
138 }
139
140@@ -2459,56 +2456,44 @@
141 }
142 }
143
144void Scumm::palManipulateInit(int start, int end, int string_id, int time)
145 {
146+ byte *pal, *target, *between;
147+ byte *string1, *string2, *string3;
148+ int i;
149+
150 _palManipStart = start;
151 _palManipEnd = end;
152 _palManipCounter = 0;
153-
154- byte *startptr = getResourceAddress(rtTemp, 4);
155- if (startptr)
156- nukeResource(rtTemp, 4);
157- startptr = createResource(rtTemp, 4, 256 * 6);
158- if (!startptr) {
159- warning("palManipulateInit(%d,%d,%d,%d): Cannot create rtTemp resource index 4\n", start, end, string_id, time);
160- return;
161- }
162- startptr += _palManipStart * 6;
163-
164- byte *endptr = getResourceAddress(rtTemp, 5);
165- if (endptr)
166- nukeResource(rtTemp, 5);
167- endptr = createResource(rtTemp, 5, 256 * 6);
168- if (!endptr) {
169- warning("palManipulateInit(%d,%d,%d,%d): Cannot create rtTemp resource index 5\n", start, end, string_id, time);
170- return;
171- }
172- endptr += _palManipStart * 6;
173-
174- byte *curptr = _currentPalette + _palManipStart * 3;
175- byte *string1ptr = getStringAddress(string_id) + _palManipStart;
176- byte *string2ptr = getStringAddress(string_id + 1) + _palManipStart;
177- byte *string3ptr = getStringAddress(string_id + 2) + _palManipStart;
178- if (!string1ptr || !string2ptr || !string3ptr) {
179+
180+ if (!_palManipPalette)
181+ _palManipPalette = (byte *)calloc(0x300, 1);
182+ if (!_palManipIntermediatePal)
183+ _palManipIntermediatePal = (byte *)calloc(0x600, 1);
184+
185+ pal = _currentPalette + start * 3;
186+ target = _palManipPalette + start * 3;
187+ between = _palManipIntermediatePal + start * 6;
188+
189+ string1 = getStringAddress(string_id) + start;
190+ string2 = getStringAddress(string_id + 1) + start;
191+ string3 = getStringAddress(string_id + 2) + start;
192+ if (!string1 || !string2 || !string3) {
193 warning("palManipulateInit(%d,%d,%d,%d): Cannot obtain string resources %d, %d and %d\n",
194 start, end, string_id, time, string_id, string_id + 1, string_id + 2);
195 return;
196 }
197
198- int i;
199- for (i = _palManipStart; i <= _palManipEnd; ++i) {
200- *((uint16 *)startptr) = ((uint16) *curptr++) << 8;
201- *((uint16 *)endptr) = ((uint16) *string1ptr++) << 8;
202- startptr += 2;
203- endptr += 2;
204- *((uint16 *)startptr) = ((uint16) *curptr++) << 8;
205- *((uint16 *)endptr) = ((uint16) *string2ptr++) << 8;
206- startptr += 2;
207- endptr += 2;
208- *((uint16 *)startptr) = ((uint16) *curptr++) << 8;
209- *((uint16 *)endptr) = ((uint16) *string3ptr++) << 8;
210- startptr += 2;
211- endptr += 2;
212+ for (i = start; i < end; ++i) {
213+ *target++ = *string1++;
214+ *target++ = *string2++;
215+ *target++ = *string3++;
216+ *(uint16*)between = ((uint16) *pal++) << 8;
217+ between += 2;
218+ *(uint16*)between = ((uint16) *pal++) << 8;
219+ between += 2;
220+ *(uint16*)between = ((uint16) *pal++) << 8;
221+ between += 2;
222 }
223
224 _palManipCounter = time;
225@@ -2516,45 +2501,29 @@
226
227 void Scumm::palManipulate()
228 {
229- byte *srcptr, *destptr;
230- byte *pal;
231+ byte *target, *pal, *between;
232 int i, j;
233
234 if (!_palManipCounter)
235 return;
236
237- srcptr = getResourceAddress(rtTemp, 4) + _palManipStart * 6;
238- destptr = getResourceAddress(rtTemp, 5) + _palManipStart * 6;
239- if (!srcptr || !destptr)
240- return;
241-
242+ target = _palManipPalette + _palManipStart * 3;
243 pal = _currentPalette + _palManipStart * 3;
244+ between = _palManipIntermediatePal + _palManipStart * 6;
245
246- i = _palManipStart;
247- while (i < _palManipEnd) {
248- j = (*((uint16 *)srcptr) += (*(uint16 *)destptr - *((uint16 *)srcptr)) / _palManipCounter);
249+ for (i = _palManipStart; i < _palManipEnd; ++i) {
250+ j = (*((uint16 *)between) += ((*target++ << 8) - *((uint16 *)between)) / _palManipCounter);
251 *pal++ = j >> 8;
252- srcptr += 2;
253- destptr += 2;
254-
255- j = (*((uint16 *)srcptr) += (*(uint16 *)destptr - *((uint16 *)srcptr)) / _palManipCounter);
256+ between += 2;
257+ j = (*((uint16 *)between) += ((*target++ << 8) - *((uint16 *)between)) / _palManipCounter);
258 *pal++ = j >> 8;
259- srcptr += 2;
260- destptr += 2;
261-
262- j = (*((uint16 *)srcptr) += (*(uint16 *)destptr - *((uint16 *)srcptr)) / _palManipCounter);
263+ between += 2;
264+ j = (*((uint16 *)between) += ((*target++ << 8) - *((uint16 *)between)) / _palManipCounter);
265 *pal++ = j >> 8;
266- srcptr += 2;
267- destptr += 2;
268-
269- i++;
270+ between += 2;
271 }
272 setDirtyColors(_palManipStart, _palManipEnd);
273 _palManipCounter--;
274- if (!_palManipCounter) {
275- nukeResource(rtTemp, 4);
276- nukeResource(rtTemp, 5);
277- }
278 }
279
280 void Scumm::unkRoomFunc3(int unk1, int unk2, int rfact, int gfact, int bfact)