Ticket #7365: alternative.diff
File alternative.diff, 16.0 KB (added by , 18 years ago) |
---|
-
engines/agos/agos.h
558 558 void setUserItem(Item *item, int n, int m); 559 559 560 560 void paletteFadeOut(byte *palPtr, uint num, uint size); 561 561 562 562 byte *allocateItem(uint size); 563 563 byte *allocateTable(uint size); 564 564 void alignTableMem(); … … 796 796 void drawIconArray_Simon(uint i, Item *item_ptr, int line, int classMask); 797 797 void removeIconArray(uint num); 798 798 799 void loadIconData(); 799 void loadIconData(); 800 800 void loadIconFile(); 801 801 void loadMenuFile(); 802 802 … … 1119 1119 void oe1_printPlayerHit(); 1120 1120 void oe1_printMonsterHit(); 1121 1121 1122 int16 levelOf(Item *item); 1122 int16 levelOf(Item *item); 1123 1123 int16 moreText(Item *i); 1124 1124 void lobjFunc(Item *i, const char *f); 1125 1125 uint confirmQuit(); … … 1278 1278 1279 1279 void drawImages(VC10_state *state); 1280 1280 void drawImages_Simon(VC10_state *state); 1281 void drawImages_SimonAmiga(VC10_state *state); 1281 1282 void drawImages_Feeble(VC10_state *state); 1282 1283 1283 1284 void scaleClip(int16 h, int16 w, int16 y, int16 x, int16 scrollY); -
engines/agos/vga.cpp
541 541 } 542 542 543 543 byte *AGOSEngine::vc10_flip(const byte *src, uint w, uint h) { 544 w *= 8;545 546 544 byte *dstPtr; 547 545 uint i; 548 546 549 dstPtr = _videoBuf1 + w; 550 551 do { 552 byte *dst = dstPtr; 553 for (i = 0; i != w; ++i) { 554 byte b = src[i]; 555 b = (b >> 4) | (b << 4); 556 *--dst = b; 547 if (getFeatures() & GF_32COLOR) { 548 const uint flipw = w * 16; 549 for (uint y = 0; y < h; ++y) { 550 dstPtr = _videoBuf1 + (y + 1) * flipw; 551 for (i = 0; i < flipw; ++i) { 552 *--dstPtr = *src++; 553 } 557 554 } 555 } else { 556 w *= 8; 557 dstPtr = _videoBuf1 + w; 558 558 559 src += w; 560 dstPtr += w; 561 } while (--h); 559 do { 560 byte *dst = dstPtr; 561 for (i = 0; i != w; ++i) { 562 byte b = src[i]; 563 b = (b >> 4) | (b << 4); 564 *--dst = b; 565 } 562 566 567 src += w; 568 dstPtr += w; 569 } while (--h); 570 } 571 563 572 return _videoBuf1; 564 573 } 565 574 … … 634 643 state.flags |= kDFCompressed; 635 644 } 636 645 } 646 if (getPlatform() == Common::kPlatformAmiga && !(flags & 0x80)) { 647 // decoded data in res_ami.cpp is always uncompressed 648 if (state.flags & kDFCompressedFlip) { 649 state.flags &= ~kDFCompressedFlip; 650 state.flags |= kDFFlip; 651 } 652 if (state.flags & kDFCompressed) { 653 state.flags &= ~kDFCompressed; 654 } 655 } 637 656 } 638 657 639 658 state.width = state.draw_width = width; /* cl */ … … 654 673 return; 655 674 } 656 675 676 state.surf2_addr = getFrontBuf(); 677 state.surf2_pitch = _dxSurfacePitch; 678 679 state.surf_addr = getBackBuf(); 680 state.surf_pitch = _dxSurfacePitch; 681 657 682 if (getGameType() != GType_FF && getGameType() != GType_PP) { 658 if (state.flags & kDFCompressed Flip) {683 if (state.flags & kDFCompressed && state.flags & kDFCompressedFlip) { 659 684 state.depack_src = vc10_uncompressFlip(state.depack_src, width, height); 660 } else if (state.flags & kDF Flip) {685 } else if (state.flags & kDFCompressedFlip || state.flags & kDFFlip) { 661 686 state.depack_src = vc10_flip(state.depack_src, width, height); 662 687 } 663 688 } 664 689 665 state.surf2_addr = getFrontBuf();666 state.surf2_pitch = _dxSurfacePitch;667 668 state.surf_addr = getBackBuf();669 state.surf_pitch = _dxSurfacePitch;670 671 690 if (getGameType() == GType_FF || getGameType() == GType_PP) { 672 691 drawImages_Feeble(&state); 692 } else if (getFeatures() & GF_32COLOR) { 693 drawImages_SimonAmiga(&state); 673 694 } else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { 674 695 drawImages_Simon(&state); 675 696 } else { … … 1107 1128 1108 1129 if (num == 3) { 1109 1130 memset(getBackBuf(), 0, _screenWidth * _screenHeight); 1110 } else { 1131 } else { 1111 1132 const uint16 *vlut = &_videoWindows[num * 4]; 1112 1133 byte *dst = getBackBuf() + vlut[0] * 16 + vlut[1] * _dxSurfacePitch; 1113 1134 -
engines/agos/res_ami.cpp
29 29 30 30 namespace AGOS { 31 31 32 byte *buffer; 33 byte *bufptr; 34 byte *bufferout; 35 byte *bufptrout; 36 uint32 bufoutend; 37 byte *clipptr; 38 byte *clipoutptr; 39 int clipnumber; 32 static byte *buffer; 33 static byte *bufptr; 34 static byte *bufferout; 35 static byte *bufptrout; 36 static uint32 bufoutend; 37 static byte *clipptr; 38 static byte *clipoutptr; 40 39 41 40 static void uncompressplane(byte *plane, byte *outptr, uint16 length) { 42 41 debug(10, "uncompressplane: length %d", length); 43 44 char x; 45 byte y, z; 46 while (length) { 47 x = *plane++; 42 while (length != 0) { 43 char x = *plane++; 48 44 if (x >= 0) { 49 x += 1;50 y = *plane++;51 z = *plane++;52 while (x ) {45 x++; 46 byte y = *plane++; 47 byte z = *plane++; 48 while (x != 0) { 53 49 *outptr++ = y; 54 50 *outptr++ = z; 55 length--; 56 if (length == 0) 51 if (--length == 0) 57 52 break; 58 53 x--; 59 54 } 60 55 } else { 61 while (x ) {56 while (x != 0) { 62 57 *outptr++ = *plane++; 63 58 *outptr++ = *plane++; 64 length--; 65 if (length == 0) 59 if (--length == 0) 66 60 break; 67 61 x++; 68 62 } … … 70 64 } 71 65 } 72 66 73 static void convertcompressedclip(uint16 height, uint16 width) { 67 static void decodeBitPlaneData(uint16 *w, bool is32Colors, uint8 *&dst) { 68 for (int j = 0; j < 8; j++) { 69 byte color1 = 0; 70 byte color2 = 0; 71 for (int p = 0; p < 5; ++p) { 72 if (w[p] & 0x8000) { 73 color1 |= 1 << p; 74 } 75 if (w[p] & 0x4000) { 76 color2 |= 1 << p; 77 } 78 w[p] <<= 2; 79 } 80 if (is32Colors) { 81 *dst++ = color1; 82 *dst++ = color2; 83 } else { 84 *dst++ = color1 * 16 + color2; 85 } 86 } 87 } 88 89 static void convertcompressedclip(bool is32Colors, uint16 height, uint16 width) { 74 90 debug(10, "convertcompressedclip: height %d width %d", height, width); 75 91 76 92 byte *plane0; 77 93 byte *plane1; 78 94 byte *plane2; 79 95 byte *plane3; 96 byte *plane4; 80 97 byte *uncbuffer; 81 98 byte *uncptr0; 82 99 byte *uncptr1; 83 100 byte *uncptr2; 84 101 byte *uncptr3; 102 byte *uncptr4; 85 103 byte *uncbfrout; 86 104 byte *uncbfroutptr; 87 uint16 length, i, j, k, word1, word2, word3, word4, cliplength; 88 byte outbyte, outbyte1, x, y; 89 char n; 90 uncbuffer = (byte *)malloc(height * width * 4); 91 uncbfrout = (byte *)malloc(height * width * 4); 92 105 uint32 length, i, j; 106 uint16 w[5]; 107 uncbuffer = (byte *)malloc(height * width * 5); 108 uncbfrout = (byte *)malloc(height * width * 5); 109 93 110 byte *free_uncbuffer = uncbuffer; 94 111 byte *free_uncbfrout = uncbfrout; 95 96 length = width / 16;97 length *= height; 98 plane0 = READ_BE_UINT16(clipptr) + READ_BE_UINT16(clipptr + 2) + clipptr; clipptr += 4; plane0 += 4;99 plane1 = READ_BE_UINT16(clipptr) + READ_BE_UINT16(clipptr + 2) + clipptr; clipptr += 4; plane1 += 4;100 plane2 = READ_BE_UINT16(clipptr) + READ_BE_UINT16(clipptr + 2) + clipptr; clipptr += 4; plane2 += 4;101 plane3 = READ_BE_UINT16(clipptr) + READ_BE_UINT16(clipptr + 2) + clipptr; clipptr += 4; plane3 += 4;102 plane0 -= 4;103 plane1 -= 8;104 plane2 -= 12;105 plane3 -= 16; 112 113 length = (width + 15) / 16 * height; 114 115 plane0 = clipptr + READ_BE_UINT16(clipptr + 0) + READ_BE_UINT16(clipptr + 2); 116 plane1 = clipptr + READ_BE_UINT16(clipptr + 4) + READ_BE_UINT16(clipptr + 6); 117 plane2 = clipptr + READ_BE_UINT16(clipptr + 8) + READ_BE_UINT16(clipptr + 10); 118 plane3 = clipptr + READ_BE_UINT16(clipptr + 12) + READ_BE_UINT16(clipptr + 14); 119 if (is32Colors) { 120 plane4 = clipptr + READ_BE_UINT16(clipptr + 16) + READ_BE_UINT16(clipptr + 18); 121 } 122 106 123 uncptr0 = uncbuffer; 107 124 uncptr1 = uncptr0+(length*2); 108 125 uncptr2 = uncptr1+(length*2); 109 126 uncptr3 = uncptr2+(length*2); 127 if (is32Colors) { 128 uncptr4 = uncptr3+(length*2); 129 } 110 130 uncompressplane(plane0, uncptr0, length); 111 131 uncompressplane(plane1, uncptr1, length); 112 132 uncompressplane(plane2, uncptr2, length); 113 133 uncompressplane(plane3, uncptr3, length); 134 if (is32Colors) { 135 uncompressplane(plane4, uncptr4, length); 136 } 114 137 uncbfroutptr = uncbfrout; 138 115 139 for (i = 0; i < length; i++) { 116 word1=READ_BE_UINT16(uncptr0); uncptr0 += 2; 117 word2=READ_BE_UINT16(uncptr1); uncptr1 += 2; 118 word3=READ_BE_UINT16(uncptr2); uncptr2 += 2; 119 word4=READ_BE_UINT16(uncptr3); uncptr3 += 2; 120 for (j = 0; j < 8; j++) { 121 outbyte = ((word1 / 32768) + ((word2 / 32768) * 2) + ((word3 / 32768) * 4) + ((word4 / 32768) * 8)); 122 word1 <<= 1; 123 word2 <<= 1; 124 word3 <<= 1; 125 word4 <<= 1; 126 outbyte1 = ((word1 / 32768) + ((word2 / 32768) * 2) + ((word3 / 32768) * 4) + ((word4 / 32768) * 8)); 127 word1 <<= 1; 128 word2 <<= 1; 129 word3 <<= 1; 130 word4 <<= 1; 131 *uncbfroutptr++ = (outbyte * 16 + outbyte1); 140 w[0] = READ_BE_UINT16(uncptr0); uncptr0 += 2; 141 w[1] = READ_BE_UINT16(uncptr1); uncptr1 += 2; 142 w[2] = READ_BE_UINT16(uncptr2); uncptr2 += 2; 143 w[3] = READ_BE_UINT16(uncptr3); uncptr3 += 2; 144 if (is32Colors) { 145 w[4] = READ_BE_UINT16(uncptr4); uncptr4 += 2; 146 } else { 147 w[4] = 0; 132 148 } 149 decodeBitPlaneData(w, is32Colors, uncbfroutptr); 133 150 } 134 uncptr0 = uncbuffer; 135 uncptr1 = uncbfrout; 136 uncptr2 = uncbfrout; 137 uncptr3 = uncbfrout; 138 for (i = 0; i < (width / 16); i++) { 139 for (k = 0; k < 8; k++) { 140 for (j = 0; j < height; j++) { 141 *uncptr0++ = *uncptr1; 142 uncptr1 += 8; 151 const uint8 *src = uncbfrout; 152 if (is32Colors) { 153 for (i = 0; i < width / 16; ++i) { 154 for (j = 0; j < height; ++j) { 155 memcpy(clipoutptr + width * j + 16 * i, src, 16); 156 src += 16; 157 bufoutend += 16; 143 158 } 144 uncptr2++;145 uncptr1 = uncptr2;146 159 } 147 uncptr3 += (height * 8); 148 uncptr2 = uncptr3; 149 uncptr1 = uncptr2; 150 } 151 length *= 8; 152 cliplength = 0; 153 while(1) { 154 if (length == 1) { 155 *clipoutptr++ = 0xFF; bufoutend++; 156 *clipoutptr++ = *uncbuffer; bufoutend++; 157 cliplength += 2; 158 break; 159 } 160 x = *uncbuffer++; 161 y = *uncbuffer++; 162 length -= 2; 163 if (x == y) { 164 n = 1; 165 y = *uncbuffer++; 166 if (length == 0) { 167 *clipoutptr++ = n; bufoutend++; 168 *clipoutptr++ = x; bufoutend++; 169 cliplength += 2; 170 break; 160 } else { 161 for (i = 0; i < width / 16; ++i) { 162 for (j = 0; j < height; ++j) { 163 memcpy(clipoutptr + width / 2 * j + 8 * i, src, 8); 164 src += 8; 165 bufoutend += 8; 171 166 } 172 length--;173 while (x == y) {174 n++;175 y = *uncbuffer++;176 if (length == 0)177 break;178 length--;179 if(n == 127)180 break;181 }182 *clipoutptr++ = n; bufoutend++;183 *clipoutptr++ = x; bufoutend++;184 cliplength += 2;185 uncbuffer--;186 if (length == 0)187 break;188 length++;189 } else {190 n =- 1;191 uncptr0 = clipoutptr;192 clipoutptr++;193 bufoutend++;194 *clipoutptr++ = x; bufoutend++;195 cliplength += 2;196 x = y;197 y = *uncbuffer++;198 if (length == 0) {199 *uncptr0 = n;200 break;201 }202 length--;203 while (x != y) {204 if (n == -127)205 break;206 n--;207 *clipoutptr++ = x; bufoutend++;208 cliplength++;209 x = y;210 y = *uncbuffer++;211 if (length == 0)212 break;213 length--;214 }215 *uncptr0 = n;216 if (length == 0)217 break;218 uncbuffer -= 2;219 length += 2;220 167 } 221 168 } 222 if (cliplength > (height * width / 2))223 warning("Negative compression. Clip %d. %d bytes bigger.",clipnumber,(cliplength-(height*width/2)));224 169 free(free_uncbuffer); 225 170 free(free_uncbfrout); 226 171 } 227 172 228 static void convertclip( uint32 offset, uint16 height, uint16 width) {173 static void convertclip(bool is32Colors, uint32 offset, uint16 height, uint16 width) { 229 174 debug(10, "convertclip: height %d width %d", height, width); 230 175 231 uint32 length, i, j; 232 uint16 word1, word2, word3, word4; 233 byte outbyte, outbyte1; 176 uint32 length, i; 234 177 clipptr = offset + buffer; 235 178 clipoutptr = bufoutend + bufferout; 236 179 WRITE_BE_UINT32(bufptrout, bufoutend); bufptrout += 4; 237 WRITE_BE_UINT16(bufptrout, height ); bufptrout += 2;180 WRITE_BE_UINT16(bufptrout, height & ~0x8000); bufptrout += 2; // always flag the bitmap as uncompressed 238 181 WRITE_BE_UINT16(bufptrout, width); bufptrout += 2; 239 if (height > 32000) {240 convertcompressedclip( (uint16)(height - 32768), width);182 if (height & 0x8000) { 183 convertcompressedclip(is32Colors, height & ~0x8000, width); 241 184 } else { 242 width /= 16; 243 length = height * width; 185 length = (width + 15) / 16 * height; 244 186 for (i = 0; i < length; i++) { 245 word1 = READ_BE_UINT16(clipptr); clipptr += 2; 246 word2 = READ_BE_UINT16(clipptr); clipptr += 2; 247 word3 = READ_BE_UINT16(clipptr); clipptr += 2; 248 word4 = READ_BE_UINT16(clipptr); clipptr += 2; 249 for (j = 0; j < 8; j++) { 250 outbyte = ((word1 / 32768) + ((word2 / 32768) * 2) + ((word3 / 32768) * 4) + ((word4 / 32768) * 8)); 251 word1 <<= 1; 252 word2 <<= 1; 253 word3 <<= 1; 254 word4 <<= 1; 255 outbyte1 = ((word1 / 32768) + ((word2 / 32768) * 2) + ((word3 / 32768) * 4) + ((word4 / 32768) * 8)); 256 word1 <<= 1; 257 word2 <<= 1; 258 word3 <<= 1; 259 word4 <<= 1; 260 *clipoutptr++ = (outbyte * 16 + outbyte1); bufoutend++; 187 uint16 w[5]; 188 w[0] = READ_BE_UINT16(clipptr); clipptr += 2; 189 w[1] = READ_BE_UINT16(clipptr); clipptr += 2; 190 w[2] = READ_BE_UINT16(clipptr); clipptr += 2; 191 w[3] = READ_BE_UINT16(clipptr); clipptr += 2; 192 if (is32Colors) { 193 w[4] = READ_BE_UINT16(clipptr); clipptr += 2; 194 } else { 195 w[4] = 0; 261 196 } 197 decodeBitPlaneData(w, is32Colors, clipoutptr); 198 bufoutend += is32Colors ? 16 : 8; 262 199 } 263 200 } 264 201 } … … 272 209 return; 273 210 } 274 211 212 bool is32Colors = (getFeatures() & GF_32COLOR); 213 275 214 uint32 clipoffset, outlength; 276 215 uint16 clipwidth, clipheight; 277 216 byte *clipsend; … … 282 221 memcpy(buffer, srcBuf, fileSize); 283 222 bufptr = buffer; 284 223 285 bufferout = (byte *)malloc((int32)(fileSize * 2));224 bufferout = (byte *)malloc((int32)(fileSize * 4)); 286 225 bufptr = buffer; 287 226 bufptrout = bufferout; 288 clipnumber = 0;289 227 while(1) { 290 228 clipoffset = READ_BE_UINT32(bufptr); bufptr += 4; 291 229 clipheight = READ_BE_UINT16(bufptr); bufptr += 2; … … 294 232 break; 295 233 WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4; 296 234 WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4; 297 clipnumber++;298 235 } 299 236 300 237 clipsend = buffer + clipoffset; 301 238 bufoutend = clipoffset; 302 239 while (bufptr <= clipsend) { 303 240 if (clipoffset != 0) { 304 convertclip( clipoffset, clipheight, clipwidth);241 convertclip(is32Colors, clipoffset, clipheight, clipwidth); 305 242 } else { 306 243 WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4; 307 244 WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4; … … 309 246 clipoffset = READ_BE_UINT32(bufptr); bufptr += 4; 310 247 clipheight = READ_BE_UINT16(bufptr); bufptr += 2; 311 248 clipwidth = READ_BE_UINT16(bufptr); bufptr += 2; 312 clipnumber++;313 249 } 314 250 outlength = bufoutend; 315 debug(10, "convertAmiga: outlength %d",outlength);251 printf("convertAmiga: outlength %d\n",outlength); 316 252 317 253 byte *dstBuf = allocBlock (outlength); 318 254 memcpy(dstBuf, bufferout, outlength); … … 320 256 free(bufferout); 321 257 } 322 258 259 323 260 } // End of namespace AGOS -
engines/agos/gfx.cpp
175 175 176 176 if (getGameType() != GType_FF && getGameType() != GType_PP) { 177 177 state->draw_width = state->width * 2; 178 } 178 } 179 179 180 180 cur = state->x; 181 181 if (cur < 0) { … … 384 384 dst += _screenWidth; 385 385 src += state->width; 386 386 } while (--state->draw_height); 387 } 387 } 388 388 } 389 389 390 390 void AGOSEngine::drawImages_Simon(VC10_state *state) { … … 589 589 } 590 590 } 591 591 592 void AGOSEngine::drawImages_SimonAmiga(VC10_state *state) { 593 uint8 *dst; 594 const byte *src; 595 const uint16 *vlut = &_videoWindows[_windowNum * 4]; 596 597 if (drawImages_clip(state) == 0) 598 return; 599 600 uint xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8; 601 uint yoffs = (vlut[1] - _videoWindows[17] + state->y); 602 603 state->surf2_addr += xoffs + yoffs * state->surf_pitch; 604 state->surf_addr += xoffs + yoffs * state->surf2_pitch; 605 606 if (state->flags & kDFMasked) { 607 warning("Unhandled kDFMasked"); 608 } else { 609 src = state->depack_src + (state->width * state->y_skip * 16) + (state->x_skip * 8); 610 dst = state->surf_addr; 611 612 state->draw_width *= 2; 613 614 uint h = state->draw_height; 615 do { 616 for (uint i = 0; i != state->draw_width; i++) 617 if ((state->flags & kDFNonTrans) || src[i]) 618 dst[i] = src[i]; 619 dst += _screenWidth; 620 src += state->width * 16; 621 } while (--h); 622 } 623 } 624 592 625 void AGOSEngine::drawImages(VC10_state *state) { 593 626 const uint16 *vlut = &_videoWindows[_windowNum * 4]; 594 627