[Scummvm-cvs-logs] SF.net SVN: scummvm:[44717] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue Oct 6 21:57:55 CEST 2009


Revision: 44717
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44717&view=rev
Author:   thebluegr
Date:     2009-10-06 19:57:55 +0000 (Tue, 06 Oct 2009)

Log Message:
-----------
WIP code for replacing the FreeSCI view decoding code with the new one (no changes to the logic, yet)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
    scummvm/trunk/engines/sci/gfx/gfx_resmgr.h
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/gfx/operations.h
    scummvm/trunk/engines/sci/gui/gui.cpp
    scummvm/trunk/engines/sci/gui/gui.h
    scummvm/trunk/engines/sci/gui/gui_palette.cpp
    scummvm/trunk/engines/sci/gui/gui_palette.h
    scummvm/trunk/engines/sci/gui/gui_screen.cpp
    scummvm/trunk/engines/sci/gui/gui_screen.h
    scummvm/trunk/engines/sci/gui/gui_view.h
    scummvm/trunk/engines/sci/gui32/gui32.cpp
    scummvm/trunk/engines/sci/gui32/gui32.h
    scummvm/trunk/engines/sci/sci.cpp

Modified: scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gfx/gfx_resmgr.cpp	2009-10-06 19:57:55 UTC (rev 44717)
@@ -32,7 +32,9 @@
 #include "sci/sci.h"
 #include "sci/gfx/gfx_resource.h"
 #include "sci/gfx/gfx_tools.h"
+#include "sci/gui/gui_palette.h"
 #include "sci/gui/gui_screen.h"
+#include "sci/gui/gui_view.h"
 #include "sci/gfx/gfx_driver.h"
 #include "sci/gfx/gfx_resmgr.h"
 #include "sci/gfx/gfx_state_internal.h"
@@ -50,8 +52,8 @@
 	GfxDriver *driver;
 };
 
-GfxResManager::GfxResManager(gfx_options_t *options, GfxDriver *driver, ResourceManager *resMan) :
-				_options(options), _driver(driver), _resMan(resMan),
+GfxResManager::GfxResManager(gfx_options_t *options, GfxDriver *driver, ResourceManager *resMan, SciGuiScreen *screen, SciGuiPalette *palette) :
+				_options(options), _driver(driver), _resMan(resMan), _screen(screen), _palette(palette),
 				_lockCounter(0), _tagLockCounter(0), _staticPalette(0) {
 	gfxr_init_static_palette();
 
@@ -495,8 +497,60 @@
 }
 
 gfxr_view_t *GfxResManager::getView(int nr, int *loop, int *cel, int palette) {
+
+	// Wrapper code for the new view decoder - still WIP
+#if 0
+
 	IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_VIEW];
 	gfx_resource_t *res = NULL;
+	gfxr_view_t *result = (gfxr_view_t *)malloc(sizeof(gfxr_view_t));
+
+	result->ID = nr;
+	result->flags = 0;
+
+	SciGuiView *view = new SciGuiView(_resMan, _screen, _palette, nr);
+
+	result->loops_nr = view->getLoopCount();
+	result->palette = NULL;
+	result->loops = (gfxr_loop_t*)malloc(sizeof(gfxr_loop_t) * ((result->loops_nr) ? result->loops_nr : 1)); /* Alloc 1 if no loop */
+
+	if (*loop >= result->loops_nr)
+		*loop = result->loops_nr - 1;
+
+	for (int i = 0; i < result->loops_nr; i++) {
+		result->loops[i].cels_nr = view->getLoopInfo(i)->celCount;
+		result->loops[i].cels = (gfx_pixmap_t**)calloc(result->loops[i].cels_nr, sizeof(gfx_pixmap_t *));
+
+		if (*cel >= result->loops[i].cels_nr)
+			*cel = result->loops[i].cels_nr - 1;
+
+		for (int j = 0; j < result->loops[i].cels_nr; j++) {
+			sciViewCelInfo *celInfo = view->getCelInfo(i, j);
+			result->loops[i].cels[j] = gfx_pixmap_alloc_index_data(gfx_new_pixmap(celInfo->width, celInfo->height, nr, i, j));
+			gfx_pixmap_t *curCel = result->loops[i].cels[j];
+			curCel->alpha_map = 0;	// TODO
+			curCel->color_key = celInfo->clearKey;
+			curCel->index_data = view->getBitmap(i, j);
+			curCel->data = curCel->index_data;
+			curCel->flags = 0;
+			curCel->width = celInfo->width;
+			curCel->height = celInfo->height;
+			curCel->index_width = celInfo->width;
+			curCel->index_height = celInfo->height;
+			curCel->palette = 0;	// TODO
+			curCel->palette_revision = 0;
+			curCel->xoffset = celInfo->displaceX;
+			curCel->yoffset = celInfo->displaceY;
+		}
+	}
+
+	return result;
+
+#else
+
+	// Existing code
+	IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_VIEW];
+	gfx_resource_t *res = NULL;
 	int hash = palette;
 	gfxr_view_t *view = NULL;
 	gfxr_loop_t *loop_data = NULL;
@@ -585,6 +639,8 @@
 	}
 
 	return view;
+
+#endif
 }
 
 gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) {

Modified: scummvm/trunk/engines/sci/gfx/gfx_resmgr.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_resmgr.h	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gfx/gfx_resmgr.h	2009-10-06 19:57:55 UTC (rev 44717)
@@ -31,6 +31,7 @@
 // or something like that.
 
 #include "sci/gfx/gfx_resource.h"
+#include "sci/gui/gui_palette.h"
 #include "sci/resource.h"
 
 #include "common/hashmap.h"
@@ -90,7 +91,7 @@
 /** Graphics resource manager */
 class GfxResManager {
 public:
-	GfxResManager(gfx_options_t *options, GfxDriver *driver, ResourceManager *resMan);
+	GfxResManager(gfx_options_t *options, GfxDriver *driver, ResourceManager *resMan, SciGuiScreen *screen, SciGuiPalette *palette);
 	~GfxResManager();
 
 	/**
@@ -303,6 +304,8 @@
 
 	IntResMap _resourceMaps[GFX_RESOURCE_TYPES_NR];
 	ResourceManager *_resMan;
+	SciGuiScreen *_screen;
+	SciGuiPalette *_palette;
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-10-06 19:57:55 UTC (rev 44717)
@@ -386,7 +386,7 @@
 
 void gfxop_init(GfxState *state,
 				gfx_options_t *options, ResourceManager *resMan,
-				SciGuiScreen *screen, int scaleFactor) {
+				SciGuiScreen *screen, SciGuiPalette *palette, int scaleFactor) {
 	state->options = options;
 	state->visible_map = GFX_MASK_VISUAL;
 	state->fullscreen_override = NULL; // No magical override
@@ -401,7 +401,7 @@
 
 	state->driver = new GfxDriver(screen, scaleFactor);
 
-	state->gfxResMan = new GfxResManager(state->options, state->driver, resMan);
+	state->gfxResMan = new GfxResManager(state->options, state->driver, resMan, screen, palette);
 
 	gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200));
 	state->pointerZone = Common::Rect(0, 0, 320, 200);

Modified: scummvm/trunk/engines/sci/gfx/operations.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.h	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gfx/operations.h	2009-10-06 19:57:55 UTC (rev 44717)
@@ -143,7 +143,7 @@
  */
 void gfxop_init(GfxState *state, 
 		gfx_options_t *options, ResourceManager *resMan,
-		SciGuiScreen *screen, int scaleFactor = 1);
+		SciGuiScreen *screen, SciGuiPalette *palette, int scaleFactor = 1);
 
 /**
  * Deinitializes a currently active driver.

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-06 19:57:55 UTC (rev 44717)
@@ -41,11 +41,9 @@
 
 namespace Sci {
 
-SciGui::SciGui(OSystem *system, EngineState *state, SciGuiScreen *screen)
-	: _system(system), _s(state), _screen(screen) {
-	_picNotValid = 0;
+SciGui::SciGui(OSystem *system, EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette)
+	: _system(system), _s(state), _screen(screen), _palette(palette) {
 
-	_palette = new SciGuiPalette(_s, this, _screen);
 	_gfx = new SciGuiGfx(_s, _screen, _palette);
 	_windowMgr = new SciGuiWindowMgr(_s, _gfx);
 }
@@ -266,7 +264,7 @@
 	_screen->copyToScreen();
 
 	_gfx->SetPort(oldPort);
-	_picNotValid = true;
+	_screen->_picNotValid = true;
 }
 
 void SciGui::drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo) {
@@ -379,13 +377,13 @@
 }
 
 void SciGui::animate(reg_t listReference, bool cycle, int argc, reg_t *argv) {
-	bool old_picNotValid = _picNotValid;
+	bool old_picNotValid = _screen->_picNotValid;
 
 	if (listReference.isNull()) {
 		_gfx->AnimateDisposeLastCast();
-		if (_picNotValid) {
+		if (_screen->_picNotValid) {
 			//(this->*ShowPic)(_showMap, _showStyle);
-			_picNotValid = 0;
+			_screen->_picNotValid = false;
 		}
 		return;
 	}
@@ -409,9 +407,9 @@
 
 	_gfx->AnimateDrawCels();
 
-	if (_picNotValid) {
+	if (_screen->_picNotValid) {
 		//(this->*ShowPic)(_showMap, _showStyle);
-		_picNotValid = 0;
+		_screen->_picNotValid = false;
 	}
 
 	//_gfx->AnimateUpdateScreen();
@@ -449,7 +447,7 @@
 //	}
 //	animSort(arrObj, arrY, szList);
 
-	_picNotValid = 2;
+	_screen->_picNotValid = 2;	// FIXME: _picNotValid is a boolean!
 
 	delete sortedList;
 }

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-06 19:57:55 UTC (rev 44717)
@@ -37,7 +37,7 @@
 class SciGuiWindowMgr;
 class SciGui {
 public:
-	SciGui(OSystem *system, EngineState *s, SciGuiScreen *screen);
+	SciGui(OSystem *system, EngineState *s, SciGuiScreen *screen, SciGuiPalette *palette);
 	SciGui();
 	virtual ~SciGui();
 
@@ -89,7 +89,7 @@
 	virtual void moveCursor(int16 x, int16 y, int16 scaleFactor = 1);
 	void moveCursor(Common::Point p, int16 scaleFactor = 1) { moveCursor(p.x, p.y, scaleFactor); }
 
-	int _picNotValid; // possible values 0, 1 and 2
+	SciGuiPalette *getPalette() { return _palette; }
 
 private:
 	OSystem *_system;

Modified: scummvm/trunk/engines/sci/gui/gui_palette.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_palette.cpp	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gui/gui_palette.cpp	2009-10-06 19:57:55 UTC (rev 44717)
@@ -34,8 +34,8 @@
 
 namespace Sci {
 
-SciGuiPalette::SciGuiPalette(EngineState *state, SciGui *gui, SciGuiScreen *screen)
-	: _s(state), _gui(gui), _screen(screen) {
+SciGuiPalette::SciGuiPalette(EngineState *state, SciGuiScreen *screen)
+	: _s(state), _screen(screen) {
 	init();
 }
 
@@ -186,7 +186,7 @@
 	if (flag == 2 || sciPal->timestamp != systime) {
 		merge(sciPal, &_sysPalette, flag);
 		sciPal->timestamp = _sysPalette.timestamp;
-		if (_gui->_picNotValid == 0 && systime != _sysPalette.timestamp)
+		if (_screen->_picNotValid == 0 && systime != _sysPalette.timestamp)
 			setOnScreen();
 	}
 }

Modified: scummvm/trunk/engines/sci/gui/gui_palette.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_palette.h	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gui/gui_palette.h	2009-10-06 19:57:55 UTC (rev 44717)
@@ -33,7 +33,7 @@
 class SciGuiScreen;
 class SciGuiPalette {
 public:
-	SciGuiPalette(EngineState *state, SciGui *gui, SciGuiScreen *screen);
+	SciGuiPalette(EngineState *state, SciGuiScreen *screen);
 	~SciGuiPalette();
 
 	void init();
@@ -56,7 +56,6 @@
 
 private:
 	EngineState *_s;
-	SciGui *_gui;
 	SciGuiScreen *_screen;
 
 	uint16 _clrPowers[256];

Modified: scummvm/trunk/engines/sci/gui/gui_screen.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_screen.cpp	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gui/gui_screen.cpp	2009-10-06 19:57:55 UTC (rev 44717)
@@ -55,6 +55,8 @@
 		_baseTable[i] = base; _baseDisplayTable[i] = base;
 		base += _width;
 	}
+
+	_picNotValid = false;
 }
 
 SciGuiScreen::~SciGuiScreen() {

Modified: scummvm/trunk/engines/sci/gui/gui_screen.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_screen.h	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gui/gui_screen.h	2009-10-06 19:57:55 UTC (rev 44717)
@@ -70,6 +70,8 @@
 	uint16 _displayHeight;
 	uint _displayPixels;
 
+	int _picNotValid; // possible values 0, 1 and 2
+
 private:
 	void restoreBitsScreen(Common::Rect rect, byte *&memoryPtr, byte *screen);
 	void saveBitsScreen(Common::Rect rect, byte *screen, byte *&memoryPtr);

Modified: scummvm/trunk/engines/sci/gui/gui_view.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_view.h	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gui/gui_view.h	2009-10-06 19:57:55 UTC (rev 44717)
@@ -58,6 +58,7 @@
 	void getCelRect(GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 x, int16 y, int16 z, Common::Rect *outRect);
 	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; }
 
 private:
 	void initData(GuiResourceId resourceId);

Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-06 19:57:55 UTC (rev 44717)
@@ -64,7 +64,7 @@
 
 namespace Sci {
 
-SciGui32::SciGui32(OSystem *system, EngineState *state, SciGuiScreen *screen)
+SciGui32::SciGui32(OSystem *system, EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette)
 	: _system(system), s(state) {
 }
 

Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-06 19:57:55 UTC (rev 44717)
@@ -32,7 +32,7 @@
 
 class SciGui32 : public SciGui {
 public:
-	SciGui32(OSystem *system, EngineState *s, SciGuiScreen *screen);
+	SciGui32(OSystem *system, EngineState *s, SciGuiScreen *screen, SciGuiPalette *palette);
 	~SciGui32();
 
 	// FIXME: Don't store EngineState

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-10-06 19:57:17 UTC (rev 44716)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-10-06 19:57:55 UTC (rev 44717)
@@ -37,6 +37,7 @@
 
 #include "sci/gfx/gfx_state_internal.h"	// required for GfxContainer, GfxPort, GfxVisual
 #include "sci/gui32/gui32.h"
+#include "sci/gui/gui_palette.h"
 
 #include "sci/gfx/gfx_resource.h"
 #include "sci/gfx/gfx_tools.h"
@@ -156,10 +157,11 @@
 	_gamestate->gfx_state = &gfx_state;
 
 	SciGuiScreen *screen = new SciGuiScreen(_system);
+	SciGuiPalette *palette = new SciGuiPalette(_gamestate, screen);
 
 	// Gui change
-	//_gamestate->gui = new SciGui(_system, _gamestate, screen);    // new
-	_gamestate->gui = new SciGui32(_system, _gamestate, screen);  // old
+	//_gamestate->gui = new SciGui(_system, _gamestate, screen, palette);    // new
+	_gamestate->gui = new SciGui32(_system, _gamestate, screen, palette);  // old
 
 	// Assign default values to the config manager, in case settings are missing
 	ConfMan.registerDefault("dither_mode", "0");
@@ -180,7 +182,7 @@
 	// Default config ends
 #endif
 
-	gfxop_init(&gfx_state, &gfx_options, _resMan, screen, 1);
+	gfxop_init(&gfx_state, &gfx_options, _resMan, screen, palette, 1);
 
 	if (game_init_graphics(_gamestate)) { // Init interpreter graphics
 		warning("Game initialization failed: Error in GFX subsystem. Aborting...");
@@ -202,6 +204,7 @@
 	script_free_engine(_gamestate); // Uninitialize game state
 	script_free_breakpoints(_gamestate);
 
+	delete palette;
 	delete screen;
 	delete _gamestate;
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list