diff options
| author | Filippos Karapetis | 2009-10-07 11:31:30 +0000 | 
|---|---|---|
| committer | Filippos Karapetis | 2009-10-07 11:31:30 +0000 | 
| commit | a17d01bd21b8377b132b59ec48589495d3852fb0 (patch) | |
| tree | c97498447f0093d0a0f4cd8004a739f8b94f1654 | |
| parent | f72c4d21c7d158345546dd9db95c2ae9a1924f79 (diff) | |
| download | scummvm-rg350-a17d01bd21b8377b132b59ec48589495d3852fb0.tar.gz scummvm-rg350-a17d01bd21b8377b132b59ec48589495d3852fb0.tar.bz2 scummvm-rg350-a17d01bd21b8377b132b59ec48589495d3852fb0.zip | |
More work on the view code wrapper. Now all SCI0-SCI11 views should be displayed correctly, apart from the late SCI0 ones (e.g. in Codename Iceman), where the palette is incorrect
svn-id: r44724
| -rw-r--r-- | engines/sci/gfx/gfx_resmgr.cpp | 53 | ||||
| -rw-r--r-- | engines/sci/gui/gui_view.h | 3 | 
2 files changed, 22 insertions, 34 deletions
| diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 87e232c052..276f8402c3 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -519,13 +519,21 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {  		// Translate view palette  		view->palette = NULL; -		if (guiView->getPalette()) { -			GuiPalette viewPalette = guiView->getPalette()->_sysPalette; -			int colorCount = (viewType == kViewVga) ? 256 : 16; -			view->palette = new Palette(colorCount); +		if (viewType == kViewVga || viewType == kViewVga11) { +			GuiPalette *viewPalette = guiView->getPalette(); +			if (viewPalette) { +				view->palette = new Palette(256); +				for (int c = 0; c < 256; c++) +					view->palette->setColor(c, viewPalette->colors[c].r, viewPalette->colors[c].g, viewPalette->colors[c].b); +			} +		} else { +			view->palette = _staticPalette->getref(); -			for (int c = 0; c < colorCount; c++) -				view->palette->setColor(c, viewPalette.colors[c].r, viewPalette.colors[c].g, viewPalette.colors[c].b); +			const byte *paldata = guiView->getEgaMapping(); +			for (int p = 0; p < GFX_SCI0_IMAGE_COLORS_NR; p++) +				view->translation[p] = *(paldata++); + +			view->flags |= GFX_PIXMAP_FLAG_PALETTIZED;  		}  		view->loops_nr = guiView->getLoopCount(); @@ -546,15 +554,16 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {  				curCel->height = celInfo->height;  				curCel->index_width = celInfo->width;  				curCel->index_height = celInfo->height; -				curCel->palette_revision = 0; -				curCel->xoffset = celInfo->displaceX; -				curCel->yoffset = celInfo->displaceY; +				curCel->palette_revision = -1; +				curCel->xoffset = -celInfo->displaceX; +				curCel->yoffset = -celInfo->displaceY;  				curCel->alpha_map = 0;	// will be allocated by gfx_xlate_pixmap()  				curCel->data = 0;		// will be allocated by gfx_xlate_pixmap() -				curCel->palette = view->palette->getref(); +				curCel->palette = NULL;	// will be assigned to the view palette below  			}  		} +		if (viewType == kViewVga || viewType == kViewVga11) {  #else  		// Existing code @@ -570,6 +579,7 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {  			view = getEGAView(resid, viewRes->data, viewRes->size, pal);  		} else {  			view = getVGAView(resid, viewRes->data, viewRes->size, viewType); +#endif  			if (view->palette) {  				// Palettize view @@ -585,8 +595,6 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {  			}  		} -#endif -  		if (!res) {  			res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t));  			res->scaled_data.view = NULL; @@ -607,30 +615,9 @@ gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {  	}  	*loop = CLIP<int>(*loop, 0, view->loops_nr - 1); - -	if (*loop < 0) { -		warning("[GFX] View %d has no loops", nr); -		return NULL; -	} -  	loop_data = view->loops + (*loop); -	if (loop_data == NULL) { -		warning("[GFX] Trying to load invalid loop %d of view %d", *loop, nr); -		return NULL; -	} -  	*cel = CLIP<int>(*cel, 0, loop_data->cels_nr - 1); - -	if (*cel < 0) { -		warning("[GFX] View %d loop %d has no cels", nr, *loop); -		return NULL; -	} -  	cel_data = loop_data->cels[*cel]; -	if (loop_data == NULL) { -		warning("[GFX] Trying to load invalid view/loop/cel %d/%d/%d", nr, *loop, *cel); -		return NULL; -	}  	if (!cel_data->data) {  		if (!cel_data->palette) diff --git a/engines/sci/gui/gui_view.h b/engines/sci/gui/gui_view.h index b52cf585d7..8ed7bb058b 100644 --- a/engines/sci/gui/gui_view.h +++ b/engines/sci/gui/gui_view.h @@ -59,7 +59,8 @@ public:  	byte *getBitmap(GuiViewLoopNo loopNo, GuiViewCelNo celNo);  	void draw(Common::Rect rect, Common::Rect clipRect, Common::Rect clipRectTranslated, GuiViewLoopNo loopNo, GuiViewCelNo celNo, byte priority, uint16 paletteNo);  	uint16 getLoopCount() const { return _loopCount; } -	SciGuiPalette *getPalette() const { return _palette; } +	GuiPalette *getPalette() { return &_viewPalette; } +	const byte *getEgaMapping() const { return _EGAMapping; }  private:  	void initData(GuiResourceId resourceId); | 
