/** * Initialize graphics device. * * @see deinit_video() */ int GfxMgr::initVideo() { if (_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2)) initPalette(vgaPalette, 256, 8); else if (_vm->_renderMode == Common::kRenderEGA) initPalette(egaPalette); else if (_vm->_renderMode == Common::kRenderAmiga) { if (!ConfMan.getBool("altamigapalette")) { // Set the correct Amiga palette if (_vm->getVersion() < 0x2936) // TODO: This palette isn't used for Apple IIGS games yet, as // we don't set a separate render mode for them yet initPalette(amigaAgiPaletteV1, 16, 4); else if (_vm->getVersion() == 0x2936) initPalette(amigaAgiPaletteV2, 16, 4); else if (_vm->getVersion() > 0x2936) initPalette(amigaAgiPaletteV3, 16, 4); } else // Set the old common alternative Amiga palette initPalette(altAmigaPalette); } else error("initVideo: Unhandled render mode"); if ((_agiScreen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL) return errNotEnoughMemory; gfxSetPalette(); setCursor(_vm->_renderMode == Common::kRenderAmiga); return errOK; }
//Gets AGIPAL Data void GfxMgr::setAGIPal(int p0) { //If 0 from savefile, do not use if (p0 == 0) return; char filename[15]; sprintf(filename, "pal.%d", p0); Common::File agipal; if (!agipal.open(filename)) { warning("Couldn't open AGIPAL palette file '%s'. Not changing palette", filename); return; // Needed at least by Naturette 3 which uses AGIPAL but provides no palette files } //Chunk0 holds colors 0-7 agipal.read(&_agipalPalette[0], 24); //Chunk1 is the same as the chunk0 //Chunk2 chunk holds colors 8-15 agipal.seek(24, SEEK_CUR); agipal.read(&_agipalPalette[24], 24); //Chunk3 is the same as the chunk2 //Chunks4-7 are duplicates of chunks0-3 if (agipal.eos() || agipal.err()) { warning("Couldn't read AGIPAL palette from '%s'. Not changing palette", filename); return; } // Use only the lowest 6 bits of each color component (Red, Green and Blue) // because VGA used only 6 bits per color component (i.e. VGA had 18-bit colors). // This should now be identical to the original AGIPAL-hack's behavior. bool validVgaPalette = true; for (int i = 0; i < 16 * 3; i++) { if (_agipalPalette[i] >= (1 << 6)) { _agipalPalette[i] &= 0x3F; // Leave only the lowest 6 bits of each color component validVgaPalette = false; } } if (!validVgaPalette) warning("Invalid AGIPAL palette (Over 6 bits per color component) in '%s'. Using only the lowest 6 bits per color component", filename); _agipalFileNum = p0; initPalette(_agipalPalette); gfxSetPalette(); debug(1, "Using AGIPAL palette from '%s'", filename); }
/** * Initialize graphics device. * * @see deinit_video() */ int GfxMgr::initVideo() { if (_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2)) initPalette(vgaPalette, 256, 8); else if (_vm->_renderMode == Common::kRenderEGA) initPalette(egaPalette); else initPalette(newPalette); if ((_agiScreen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL) return errNotEnoughMemory; gfxSetPalette(); setCursor(_vm->_renderMode == Common::kRenderAmiga); return errOK; }