Ticket #7365: wip-2.diff

File wip-2.diff, 21.6 KB (added by cyxx, 17 years ago)

Convert images when drawing

  • agos/agos.h

     
    479479        uint8 _currentPalette[1024];
    480480        uint8 _displayPalette[1024];
    481481
    482         byte _videoBuf1[32000];
     482        byte _videoBuf1[64000];
    483483        uint16 _videoWindows[128];
    484484
    485485        VgaTimerEntry _vgaTimerList[205];
     
    558558        void setUserItem(Item *item, int n, int m);
    559559
    560560        void paletteFadeOut(byte *palPtr, uint num, uint size);
    561        
     561
    562562        byte *allocateItem(uint size);
    563563        byte *allocateTable(uint size);
    564564        void alignTableMem();
     
    796796        void drawIconArray_Simon(uint i, Item *item_ptr, int line, int classMask);
    797797        void removeIconArray(uint num);
    798798
    799         void loadIconData();   
     799        void loadIconData();
    800800        void loadIconFile();
    801801        void loadMenuFile();
    802802
     
    11191119        void oe1_printPlayerHit();
    11201120        void oe1_printMonsterHit();
    11211121
    1122         int16 levelOf(Item *item); 
     1122        int16 levelOf(Item *item);
    11231123        int16 moreText(Item *i);
    11241124        void lobjFunc(Item *i, const char *f);
    11251125        uint confirmQuit();
     
    12781278
    12791279        void drawImages(VC10_state *state);
    12801280        void drawImages_Simon(VC10_state *state);
     1281        void drawImages_Amiga(VC10_state *state);
    12811282        void drawImages_Feeble(VC10_state *state);
    12821283
    12831284        void scaleClip(int16 h, int16 w, int16 y, int16 x, int16 scrollY);
     
    13351336        byte *getBackGround();
    13361337        byte *getScaleBuf();
    13371338
    1338         void convertAmiga(byte *srcBuf, int32 fileSize);
     1339        byte *convertclip(const byte *src, bool is32Colors, uint height, uint width, byte flags);
     1340
    13391341        bool decrunchFile(byte *src, byte *dst, uint32 size);
    13401342        void loadVGABeardFile(uint id);
    13411343        void loadVGAVideoFile(uint id, uint type);
  • agos/intern.h

     
    210210        GF_CRUNCHED_GAMEPC = 1 << 3,
    211211        GF_ZLIBCOMP        = 1 << 4,
    212212        GF_32COLOR         = 1 << 5,
    213         GF_DEMO            = 1 << 6
     213        GF_PLANAR          = 1 << 6,
     214        GF_DEMO            = 1 << 7
    214215};
    215216
    216217enum GameFileTypes {
  • agos/vga.cpp

     
    541541}
    542542
    543543byte *AGOSEngine::vc10_flip(const byte *src, uint w, uint h) {
    544         w *= 8;
    545 
    546544        byte *dstPtr;
    547545        uint i;
    548546
    549         dstPtr = _videoBuf1 + w;
     547        if (getFeatures() & GF_32COLOR) {
     548                w *= 16;
     549                dstPtr = _videoBuf1 + w;
    550550
    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;
    557                 }
     551                do {
     552                        byte *dst = dstPtr;
     553                        for (i = 0; i != w; ++i) {
     554                                *--dst = src[i];
     555                        }
    558556
    559                 src += w;
    560                 dstPtr += w;
    561         } while (--h);
     557                        src += w;
     558                        dstPtr += w;
     559                } while (--h);
     560        } else {
     561                w *= 8;
     562                dstPtr = _videoBuf1 + w;
    562563
     564                do {
     565                        byte *dst = dstPtr;
     566                        for (i = 0; i != w; ++i) {
     567                                byte b = src[i];
     568                                b = (b >> 4) | (b << 4);
     569                                *--dst = b;
     570                        }
     571
     572                        src += w;
     573                        dstPtr += w;
     574                } while (--h);
     575        }
     576
    563577        return _videoBuf1;
    564578}
    565579
     
    620634        if (_dumpImages)
    621635                dumpSingleBitmap(_vgaCurZoneNum, state.image, state.depack_src, width, height,
    622636                                                                                         state.palette);
     637        if (getFeatures() & GF_PLANAR) {
     638                bool is32Colors = (getFeatures() & GF_32COLOR);
     639                if ((((_lockWord & 0x20) && !state.palette) || state.palette == 0xC0) &&
     640                getGameType() == GType_SIMON1) {
     641                        is32Colors = true;
     642                }
     643
     644                state.depack_src = convertclip(state.depack_src, is32Colors, height, width * 16, flags);
     645                // decoded data in res_ami.cpp is always uncompressed
     646                flags &= ~0x80;
     647                if (state.flags & kDFCompressedFlip) {
     648                        state.flags &= ~kDFCompressedFlip;
     649                        state.flags |= kDFFlip;
     650                }
     651                if (state.flags & kDFCompressed) {
     652                        state.flags &= ~kDFCompressed;
     653                }
     654        }
     655
    623656        // Check if image is compressed
    624657        if (getGameType() == GType_FF || getGameType() == GType_PP) {
    625658                if (flags & 0x80) {
     
    654687                return;
    655688        }
    656689
     690        state.surf2_addr = getFrontBuf();
     691        state.surf2_pitch = _dxSurfacePitch;
     692
     693        state.surf_addr = getBackBuf();
     694        state.surf_pitch = _dxSurfacePitch;
     695
    657696        if (getGameType() != GType_FF && getGameType() != GType_PP) {
    658697                if (state.flags & kDFCompressedFlip) {
    659698                        state.depack_src = vc10_uncompressFlip(state.depack_src, width, height);
     
    662701                }
    663702        }
    664703
    665         state.surf2_addr = getFrontBuf();
    666         state.surf2_pitch = _dxSurfacePitch;
    667 
    668         state.surf_addr = getBackBuf();
    669         state.surf_pitch = _dxSurfacePitch;
    670 
    671704        if (getGameType() == GType_FF || getGameType() == GType_PP) {
    672705                drawImages_Feeble(&state);
     706        } else if (getFeatures() & GF_32COLOR) {
     707                drawImages_Amiga(&state);
    673708        } else if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) {
    674                 drawImages_Simon(&state);
     709                if ((((_lockWord & 0x20) && state.palette == 0) || state.palette == 0xC0)) {
     710                        drawImages_Amiga(&state);
     711                } else {
     712                        drawImages_Simon(&state);
     713                }
    675714        } else {
    676715                drawImages(&state);
    677716        }
     
    11071146
    11081147        if (num == 3) {
    11091148                memset(getBackBuf(), 0, _screenWidth * _screenHeight);
    1110         } else { 
     1149        } else {
    11111150                const uint16 *vlut = &_videoWindows[num * 4];
    11121151                byte *dst = getBackBuf() + vlut[0] * 16 + vlut[1] * _dxSurfacePitch;
    11131152
  • agos/res.cpp

     
    718718                                error("loadVGAVideoFile: Read failed");
    719719
    720720                        dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4);
    721                         if (type == 2) {
    722                                 dst = (byte *)malloc(dstSize);
    723                                 decrunchFile(srcBuffer, dst, srcSize);
    724                                 convertAmiga(dst, dstSize);
    725                                 free(dst);
    726                         } else {
    727                                 dst = allocBlock (dstSize + extraBuffer);
    728                                 decrunchFile(srcBuffer, dst, srcSize);
    729                         }
     721                        dst = allocBlock (dstSize + extraBuffer);
     722                        decrunchFile(srcBuffer, dst, srcSize);
    730723                        free(srcBuffer);
    731724                } else {
    732                         if (getGameId() == GID_SIMON1CD32 && type == 2) {
    733                                 dst = (byte *)malloc(dstSize);
    734                                 if (in.read(dst, dstSize) != dstSize)
    735                                         error("loadVGAVideoFile: Read failed");
    736                                 convertAmiga(dst, dstSize);
    737                                 free(dst);
    738                         } else {
    739                                 dst = allocBlock(dstSize + extraBuffer);
    740                                 if (in.read(dst, dstSize) != dstSize)
    741                                         error("loadVGAVideoFile: Read failed");
    742                         }
     725                        dst = allocBlock(dstSize + extraBuffer);
     726                        if (in.read(dst, dstSize) != dstSize)
     727                                error("loadVGAVideoFile: Read failed");
    743728                }
    744729                in.close();
    745730        } else {
  • agos/res_ami.cpp

     
    2929
    3030namespace AGOS {
    3131
    32 byte *buffer;
    33 byte *bufptr;
    34 byte *bufferout;
    35 byte *bufptrout;
    36 uint32 bufoutend;
    37 byte *clipptr;
    38 byte *clipoutptr;
    39 int clipnumber;
     32enum {
     33        kMaxColorDepth = 5
     34};
    4035
    41 static void uncompressplane(byte *plane, byte *outptr, uint16 length) {
    42         debug(10, "uncompressplane: length %d", length);
    43 
    44         char x;
    45         byte y, z;
    46         while (length) {
    47                 x = *plane++;
     36static void uncompressplane(const byte *plane, byte *outptr, uint16 length) {
     37        debug(0, "uncompressplane: length %d", length);
     38        while (length != 0) {
     39                char x = *plane++;
    4840                if (x >= 0) {
    49                         x += 1;
    50                         y = *plane++;
    51                         z = *plane++;
    52                         while (x) {
     41                        x++;
     42                        byte y = *plane++;
     43                        byte z = *plane++;
     44                        while (x != 0) {
    5345                                *outptr++ = y;
    5446                                *outptr++ = z;
    55                                 length--;
    56                                 if (length == 0)
     47                                if (--length == 0)
    5748                                        break;
    5849                                x--;
    5950                        }
    6051                } else {
    61                         while (x) {
     52                        while (x != 0) {
    6253                                *outptr++ = *plane++;
    6354                                *outptr++ = *plane++;
    64                                 length--;
    65                                 if (length == 0)
     55                                if (--length == 0)
    6656                                        break;
    6757                                x++;
    6858                        }
     
    7060        }
    7161}
    7262
    73 static void convertcompressedclip(uint16 height, uint16 width) {
    74         debug(10, "convertcompressedclip: height %d width %d", height, width);
    75 
    76         byte *plane0;
    77         byte *plane1;
    78         byte *plane2;
    79         byte *plane3;
    80         byte *uncbuffer;
    81         byte *uncptr0;
    82         byte *uncptr1;
    83         byte *uncptr2;
    84         byte *uncptr3;
    85         byte *uncbfrout;
    86         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        
    93         byte *free_uncbuffer = uncbuffer;
    94         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;
    106         uncptr0 = uncbuffer;
    107         uncptr1 = uncptr0+(length*2);
    108         uncptr2 = uncptr1+(length*2);
    109         uncptr3 = uncptr2+(length*2);
    110         uncompressplane(plane0, uncptr0, length);
    111         uncompressplane(plane1, uncptr1, length);
    112         uncompressplane(plane2, uncptr2, length);
    113         uncompressplane(plane3, uncptr3, length);
    114         uncbfroutptr = uncbfrout;
    115         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);
    132                 }
    133         }
    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;
     63static void bitplanetochunky(uint16 *w, uint8 colorDepth, uint8 *&dst) {
     64        for (int j = 0; j < 8; j++) {
     65                byte color1 = 0;
     66                byte color2 = 0;
     67                for (int p = 0; p < 5; ++p) {
     68                        if (w[p] & 0x8000) {
     69                                color1 |= 1 << p;
    14370                        }
    144                         uncptr2++;
    145                         uncptr1 = uncptr2;
    146                 }
    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;
     71                        if (w[p] & 0x4000) {
     72                                color2 |= 1 << p;
    17173                        }
    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++;
     74                        w[p] <<= 2;
     75                }
     76                if (colorDepth > 4) {
     77                        *dst++ = color1;
     78                        *dst++ = color2;
    18979                } 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;
     80                        *dst++ = (color1 << 4) | color2;
    22081                }
    22182        }
    222         if (cliplength > (height * width / 2))
    223                 warning("Negative compression. Clip %d. %d bytes bigger.",clipnumber,(cliplength-(height*width/2)));
    224         free(free_uncbuffer);
    225         free(free_uncbfrout);
    22683}
    22784
    228 static void convertclip(uint32 offset, uint16 height, uint16 width) {
    229         debug(10, "convertclip: height %d width %d", height, width);
     85static void convertcompressedclip(const byte *src, byte *dst, uint8 colorDepth, uint16 height, uint16 width) {
     86        debug(0, "convertcompressedclip: height %d width %d", height, width);
    23087
     88        const byte *plane[kMaxColorDepth];
     89        byte *uncptr[kMaxColorDepth];
    23190        uint32 length, i, j;
    232         uint16 word1, word2, word3, word4;
    233         byte outbyte, outbyte1;
    234         clipptr = offset + buffer;
    235         clipoutptr = bufoutend + bufferout;
    236         WRITE_BE_UINT32(bufptrout, bufoutend); bufptrout += 4;
    237         WRITE_BE_UINT16(bufptrout, height); bufptrout += 2;
    238         WRITE_BE_UINT16(bufptrout, width); bufptrout += 2;
    239         if (height > 32000) {
    240                 convertcompressedclip((uint16)(height - 32768), width);
    241         } else {
    242                 width /= 16;
    243                 length = height * width;
    244                 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++;
    261                         }
     91        uint16 w[kMaxColorDepth];
     92
     93        byte *uncbfrout = (byte *)malloc(width * height);
     94
     95        length = (width + 15) / 16 * height;
     96
     97        for (i = 0; i < colorDepth; ++i) {
     98                plane[i] = src + READ_BE_UINT16(src + i * 4) + READ_BE_UINT16(src + i * 4 + 2);
     99                uncptr[i] = (uint8 *)malloc(length * 2);
     100                uncompressplane(plane[i], uncptr[i], length);
     101                plane[i] = uncptr[i];
     102        }
     103
     104        byte *uncbfroutptr = uncbfrout;
     105        for (i = 0; i < length; ++i) {
     106                for (j = 0; j < colorDepth; ++j) {
     107                        w[j] = READ_BE_UINT16(plane[j]); plane[j] += 2;
    262108                }
     109                bitplanetochunky(w, colorDepth, uncbfroutptr);
    263110        }
    264 }
    265111
    266 void AGOSEngine::convertAmiga(byte *srcBuf, int32 fileSize) {
    267         // TODO Better detection of full screen images
    268         if ((getGameType() == GType_WW && fileSize == 178624) ||
    269                 fileSize == 64800) {
    270                 byte *dstBuf = allocBlock (fileSize);
    271                 memcpy(dstBuf, srcBuf, fileSize);
    272                 return;
     112        uncbfroutptr = uncbfrout;
     113        const int chunkSize = colorDepth > 4 ? 16 : 8;
     114        for (i = 0; i < width / 16; ++i) {
     115                for (j = 0; j < height; ++j) {
     116                        memcpy(dst + width * chunkSize / 16 * j + chunkSize * i, uncbfroutptr, chunkSize);
     117                        uncbfroutptr += chunkSize;
     118                }
    273119        }
    274120
    275         uint32 clipoffset, outlength;
    276         uint16 clipwidth, clipheight;
    277         byte *clipsend;
     121        free(uncbfrout);
     122        for (i = 0; i < colorDepth; ++i) {
     123                free(uncptr[i]);
     124        }
     125}
    278126
    279         debug(10, "convertAmiga: fizeSize %d", fileSize);
     127byte *AGOSEngine::convertclip(const byte *src, bool is32Colors, uint height, uint width, byte flags) {
     128        debug(0, "convertclip: is32Colors %d height %d width %d", is32Colors, height, width);
    280129
    281         buffer = (byte *)malloc((int32)fileSize);
    282         memcpy(buffer, srcBuf, fileSize);
    283         bufptr = buffer;
     130        static byte *_planarBuf = 0;
     131        static uint32 _planarBufSize = 0; // FIXME move these variables to AGOSEngine
    284132
    285         bufferout = (byte *)malloc((int32)(fileSize * 2));
    286         bufptr = buffer;
    287         bufptrout = bufferout;
    288         clipnumber = 0;
    289         while(1) {
    290                 clipoffset = READ_BE_UINT32(bufptr); bufptr += 4;
    291                 clipheight = READ_BE_UINT16(bufptr); bufptr += 2;
    292                 clipwidth = READ_BE_UINT16(bufptr); bufptr += 2;
    293                 if (clipoffset != 0)
    294                         break;
    295                 WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4;
    296                 WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4;
    297                 clipnumber++;
     133        uint8 colorDepth = is32Colors ? 5 : 4;
     134
     135        uint32 length, i, j;
     136
     137        if (_planarBufSize < width * height) {
     138                free(_planarBuf);
     139                _planarBufSize = width * height;
     140                _planarBuf = (byte *)malloc(_planarBufSize);
    298141        }
    299142
    300         clipsend = buffer + clipoffset;
    301         bufoutend = clipoffset;
    302         while (bufptr <= clipsend) {
    303                 if (clipoffset != 0) {
    304                         convertclip(clipoffset, clipheight, clipwidth);
    305                 } else {
    306                         WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4;
    307                         WRITE_BE_UINT32(bufptrout, 0); bufptrout += 4;
     143        byte *dst = _planarBuf; // can't re-use _videoBuf1 here as it's already used in vc10_flip
     144        if (flags & 0x80) {
     145                convertcompressedclip(src, dst, colorDepth, height, width);
     146        } else {
     147                length = (width + 15) / 16 * height;
     148                for (i = 0; i < length; i++) {
     149                        uint16 w[kMaxColorDepth];
     150                        for (j = 0; j < colorDepth; ++j) {
     151                                w[j] = READ_BE_UINT16(src); src += 2;
     152                        }
     153                        bitplanetochunky(w, colorDepth, dst);
    308154                }
    309                 clipoffset = READ_BE_UINT32(bufptr); bufptr += 4;
    310                 clipheight = READ_BE_UINT16(bufptr); bufptr += 2;
    311                 clipwidth = READ_BE_UINT16(bufptr); bufptr += 2;
    312                 clipnumber++;
    313155        }
    314         outlength = bufoutend;
    315         debug(10, "convertAmiga: outlength %d",outlength);
    316156
    317         byte *dstBuf = allocBlock (outlength);
    318         memcpy(dstBuf, bufferout, outlength);
    319         free(buffer);
    320         free(bufferout);
     157//      printf("Decode complete\n");
     158        return _planarBuf;
    321159}
    322160
    323161} // End of namespace AGOS
  • agos/agosgame.cpp

     
    1616
    1717                GType_ELVIRA1,
    1818                GID_ELVIRA1,
    19                 GF_OLD_BUNDLE | GF_CRUNCHED
     19                GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
    2020        },
    2121
    2222        // Elvira 1 - English Amiga Demo
     
    3737
    3838                GType_ELVIRA1,
    3939                GID_ELVIRA1,
    40                 GF_OLD_BUNDLE | GF_CRUNCHED | GF_DEMO
     40                GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR | GF_DEMO
    4141        },
    4242
    4343        // Elvira 1 - English Atari ST Floppy
     
    5959
    6060                GType_ELVIRA1,
    6161                GID_ELVIRA1,
    62                 GF_OLD_BUNDLE | GF_CRUNCHED
     62                GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
    6363        },
    6464
    6565        // Elvira 1 - French Atari ST Floppy
     
    8181
    8282                GType_ELVIRA1,
    8383                GID_ELVIRA1,
    84                 GF_OLD_BUNDLE | GF_CRUNCHED
     84                GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
    8585        },
    8686
    8787        // Elvira 1 - English DOS Floppy
     
    171171
    172172                GType_ELVIRA2,
    173173                GID_ELVIRA2,
    174                 GF_OLD_BUNDLE | GF_CRUNCHED
     174                GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
    175175        },
    176176
    177177        // Elvira 2 - English Atari ST Floppy
     
    195195
    196196                GType_ELVIRA2,
    197197                GID_ELVIRA2,
    198                 GF_OLD_BUNDLE | GF_CRUNCHED
     198                GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
    199199        },
    200200
    201201        // Elvira 2 - French Atari ST Floppy
     
    219219
    220220                GType_ELVIRA2,
    221221                GID_ELVIRA2,
    222                 GF_OLD_BUNDLE | GF_CRUNCHED
     222                GF_OLD_BUNDLE | GF_CRUNCHED | GF_PLANAR
    223223        },
    224224
    225225
     
    365365
    366366                GType_WW,
    367367                GID_WAXWORKS,
    368                 GF_OLD_BUNDLE | GF_CRUNCHED | GF_CRUNCHED_GAMEPC
     368                GF_OLD_BUNDLE | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_PLANAR
    369369        },
    370370
    371371        // Waxworks - English DOS Floppy
     
    459459
    460460                GType_SIMON1,
    461461                GID_SIMON1AMIGA,
    462                 GF_32COLOR | GF_CRUNCHED | GF_OLD_BUNDLE
     462                GF_32COLOR | GF_CRUNCHED | GF_OLD_BUNDLE | GF_PLANAR
    463463        },
    464464
    465465        // Simon the Sorcerer 1 - English Amiga ECS Demo
     
    481481
    482482                GType_SIMON1,
    483483                GID_SIMON1AMIGA,
    484                 GF_32COLOR | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_OLD_BUNDLE | GF_DEMO
     484                GF_32COLOR | GF_CRUNCHED | GF_CRUNCHED_GAMEPC | GF_OLD_BUNDLE | GF_PLANAR | GF_DEMO
    485485        },
    486486
    487487        // Simon the Sorcerer 1 - English Amiga AGA Floppy
     
    503503
    504504                GType_SIMON1,
    505505                GID_SIMON1AMIGA,
    506                 GF_CRUNCHED | GF_OLD_BUNDLE
     506                GF_CRUNCHED | GF_OLD_BUNDLE | GF_PLANAR
    507507        },
    508508
    509509        // Simon the Sorcerer 1 - French Amiga AGA Floppy
     
    525525
    526526                GType_SIMON1,
    527527                GID_SIMON1AMIGA,
    528                 GF_CRUNCHED | GF_OLD_BUNDLE
     528                GF_CRUNCHED | GF_OLD_BUNDLE | GF_PLANAR
    529529        },
    530530
    531531        // Simon the Sorcerer 1 - German Amiga AGA Floppy
     
    547547
    548548                GType_SIMON1,
    549549                GID_SIMON1AMIGA,
    550                 GF_CRUNCHED | GF_OLD_BUNDLE
     550                GF_CRUNCHED | GF_OLD_BUNDLE | GF_PLANAR
    551551        },
    552552
    553553        // Simon the Sorcerer 1 - English Amiga CD32
     
    569569
    570570                GType_SIMON1,
    571571                GID_SIMON1CD32,
    572                 GF_TALKIE | GF_OLD_BUNDLE
     572                GF_TALKIE | GF_OLD_BUNDLE | GF_PLANAR
    573573        },
    574574
    575575        // Simon the Sorcerer 1 - English Amiga CD32 alternative?
     
    591591
    592592                GType_SIMON1,
    593593                GID_SIMON1CD32,
    594                 GF_TALKIE | GF_OLD_BUNDLE
     594                GF_TALKIE | GF_OLD_BUNDLE | GF_PLANAR
    595595        },
    596596
    597597        // Simon the Sorcerer 1 - English DOS Floppy Demo
  • agos/gfx.cpp

     
    175175
    176176        if (getGameType() != GType_FF && getGameType() != GType_PP) {
    177177                state->draw_width = state->width * 2;
    178         } 
     178        }
    179179
    180180        cur = state->x;
    181181        if (cur < 0) {
     
    384384                        dst += _screenWidth;
    385385                        src += state->width;
    386386                } while (--state->draw_height);
    387         } 
     387        }
    388388}
    389389
    390390void AGOSEngine::drawImages_Simon(VC10_state *state) {
     
    408408        state->surf_addr += xoffs + yoffs * state->surf2_pitch;
    409409
    410410        if (state->flags & kDFMasked) {
     411                return;
     412
    411413                byte *mask, *src, *dst;
    412414                byte h;
    413415                uint w;
     
    529531                }
    530532
    531533                if (state->flags & kDFCompressed) {
     534
     535                        return;
     536
    532537                        uint w, h;
    533538                        byte *src, *dst, *dstPtr;
    534539
     
    589594        }
    590595}
    591596
     597void AGOSEngine::drawImages_Amiga(VC10_state *state) {
     598        uint8 *dst;
     599        const byte *src;
     600        const uint16 *vlut = &_videoWindows[_windowNum * 4];
     601
     602        if (drawImages_clip(state) == 0)
     603                return;
     604
     605        uint xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8;
     606        uint yoffs = (vlut[1] - _videoWindows[17] + state->y);
     607
     608        state->surf2_addr += xoffs + yoffs * state->surf_pitch;
     609        state->surf_addr += xoffs + yoffs * state->surf2_pitch;
     610
     611        if (state->flags & kDFMasked) {
     612                warning("Unhandled kDFMasked");
     613        } else {
     614                src = state->depack_src + (state->width * state->y_skip * 16) + (state->x_skip * 8);
     615                dst = state->surf_addr;
     616
     617                state->draw_width *= 2;
     618
     619                uint h = state->draw_height;
     620                do {
     621                        for (uint i = 0; i != state->draw_width; i++)
     622                                if ((state->flags & kDFNonTrans) || src[i])
     623                                        dst[i] = src[i] | state->palette;
     624                        dst += _screenWidth;
     625                        src += state->width * 16;
     626                } while (--h);
     627        }
     628}
     629
    592630void AGOSEngine::drawImages(VC10_state *state) {
    593631        const uint16 *vlut = &_videoWindows[_windowNum * 4];
    594632