Ticket #8619: agipal.diff

File agipal.diff, 2.8 KB (added by SF/mthreepwood, 17 years ago)

Patch for AGIPAL

  • graphics.cpp

     
    2222 *
    2323 */
    2424
     25#include "common/file.h"
    2526#include "common/stdafx.h"
    2627
    2728#include "graphics/cursorman.h"
     
    375376        g_system->setPalette(pal, 0, 32);
    376377}
    377378
     379//Gets AGIPAL Data
     380void GfxMgr::setAGIPal(int p0) {
     381        //report("Using AGIPAL hack\n");
     382        Common::File agipal;
     383
     384        char filename[15];
     385        uint32 fileSize;
     386        sprintf(filename, "pal.%d", p0);
     387        agipal.open(filename);
     388        fileSize = agipal.size();
     389        byte *_palData = (byte *)malloc(fileSize);
     390        agipal.read(_palData, fileSize);
     391        agipal.close();
     392
     393        //Chunk0 holds colors 0-7
     394        for (int i = 0; i <= 23; i++)
     395                agipalPalette[i] = _palData[i];
     396       
     397        //Chunk1 is the same as the chunk0
     398        //Chunk2 chunk holds colors 8-15
     399        for (int i = 24; i <= 71; i++)
     400                agipalPalette[i] = _palData[i+24];
     401
     402        //Chunk3 is the same as the chunk2
     403        //Chunks4-7 are duplicates of chunks0-3
     404
     405        useAGIPal = 1;
     406        deinitVideo();
     407        initVideo();
     408        free(_palData);
     409        _palData = 0;
     410        for (int j=0; j<48; j++)
     411                agipalPalette[j]=0;
     412}
     413
    378414/* put a block onto the screen */
    379415void GfxMgr::gfxPutBlock(int x1, int y1, int x2, int y2) {
    380416        if (x1 >= GFX_WIDTH)
     
    407443 * @see deinit_video()
    408444 */
    409445int GfxMgr::initVideo() {
    410         if (_vm->_renderMode == Common::kRenderEGA)
    411                 initPalette(egaPalette);
    412         else
    413                 initPalette(newPalette);
     446        if (useAGIPal) {
     447                initPalette(agipalPalette);
     448                useAGIPal = 0;
     449        } else
     450                if (_vm->_renderMode == Common::kRenderEGA)
     451                        initPalette(egaPalette);
     452                else
     453                        initPalette(newPalette);
    414454
    415455        if ((_agiScreen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL)
    416456                return errNotEnoughMemory;
  • graphics.h

     
    4646
    4747        uint8 *_shakeH, *_shakeV;
    4848
     49        bool useAGIPal;
     50        uint8 agipalPalette[16 * 3];
     51
    4952public:
    5053        GfxMgr(AgiEngine *vm) {
    5154                _vm = vm;
    5255                _shakeH = NULL;
    5356                _shakeV = NULL;
     57                useAGIPal = 0;
    5458        }
    5559
    5660        void gfxPutBlock(int x1, int y1, int x2, int y2);
     
    8084        void saveBlock(int, int, int, int, uint8 *);
    8185        void restoreBlock(int, int, int, int, uint8 *);
    8286        void initPalette(uint8 *);
     87        void setAGIPal(int);
    8388        void drawFrame(int x1, int y1, int x2, int y2, int c1, int c2);
    8489
    8590        void putPixel(int, int, int);
  • op_cmd.cpp

     
    12311231         * set the palette.
    12321232         */
    12331233        if ((g_agi->getFeatures() & GF_AGIPAL) && p0 >= 100 && p0 < 110) {
    1234                 report("not implemented: AGIPAL palettes\n");
    1235                 return;
     1234                g_gfx->setAGIPal(p0);
     1235        return;
    12361236        } else
    12371237                g_gfx->shakeStart();
    12381238