[Scummvm-cvs-logs] scummvm master -> 914bf3d5192c3ec3131ade9d22c5d5f5ccd18fc0

wjp wjp at usecode.org
Tue Dec 27 23:06:23 CET 2011


This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
8ed39a2b9e DREAMWEB: Fix uninitialized variable
90cb52b7f6 DREAMWEB: Streamline graphics file access
e54196f37f DREAMWEB: Remove Extras segment
f729742f87 DREAMWEB: Convert exText into TextFile
a7cdc342b3 DREAMWEB: Convert reel segments into GraphicsFiles
d9aed2e00b DREAMWEB: Convert room text into TextFiles
15a1f41e8a DREAMWEB: Remove reels segment
914bf3d519 DREAMWEB: Remove setdat, freedat segments


Commit: 8ed39a2b9e54bb46973a2c9b7f8c5bfb4964bd5c
    https://github.com/scummvm/scummvm/commit/8ed39a2b9e54bb46973a2c9b7f8c5bfb4964bd5c
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T14:01:07-08:00

Commit Message:
DREAMWEB: Fix uninitialized variable

Changed paths:
    engines/dreamweb/dreamweb.cpp



diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index fa9bece..d90cd6a 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -420,6 +420,9 @@ DreamBase::DreamBase(DreamWeb::DreamWebEngine *en) : engine(en) {
 	_quitRequested = false;
 
 	_currentSample = 0xff;
+
+	_oldSubject._type = 0;
+	_oldSubject._index = 0;
 }
 
 } // End of namespace DreamGen


Commit: 90cb52b7f6364a0d4b83cdc91c76c7edf4fcf79d
    https://github.com/scummvm/scummvm/commit/90cb52b7f6364a0d4b83cdc91c76c7edf4fcf79d
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T14:01:58-08:00

Commit Message:
DREAMWEB: Streamline graphics file access

Changed paths:
    devtools/tasmrecover/tasm-recover
    engines/dreamweb/backdrop.cpp
    engines/dreamweb/dreambase.h
    engines/dreamweb/dreamgen.cpp
    engines/dreamweb/dreamgen.h
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/dreamweb.h
    engines/dreamweb/keypad.cpp
    engines/dreamweb/monitor.cpp
    engines/dreamweb/newplace.cpp
    engines/dreamweb/object.cpp
    engines/dreamweb/print.cpp
    engines/dreamweb/saveload.cpp
    engines/dreamweb/sprite.cpp
    engines/dreamweb/structs.h
    engines/dreamweb/stubs.cpp
    engines/dreamweb/titles.cpp
    engines/dreamweb/use.cpp
    engines/dreamweb/vgagrafx.cpp



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 9dc5034..bf0a2c0 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -250,6 +250,11 @@ p = parser(skip_binary_data = [
 	'puzzletext',
 	'commandtext',
 	'traveltext',
+	'tempgraphics',
+	'tempgraphics2',
+	'tempgraphics3',
+	'tempsprites',
+	'charset1',
 	# vars.asm - constants
 	'openinvlist',
 	'ryaninvlist',
diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp
index 553390f..0dface9 100644
--- a/engines/dreamweb/backdrop.cpp
+++ b/engines/dreamweb/backdrop.cpp
@@ -99,15 +99,14 @@ uint8 DreamBase::getMapAd(const uint8 *setData, uint16 *x, uint16 *y) {
 	return 1;
 }
 
-void DreamBase::calcFrFrame(const Frame *frameBase, uint16 frameNum, uint8 *width, uint8 *height, uint16 x, uint16 y, ObjPos *objPos) {
-	const Frame *frame = frameBase + frameNum;
-	*width = frame->width;
-	*height = frame->height;
-
-	objPos->xMin = (x + frame->x) & 0xff;
-	objPos->yMin = (y + frame->y) & 0xff;
-	objPos->xMax = objPos->xMin + frame->width;
-	objPos->yMax = objPos->yMin + frame->height;
+void DreamBase::calcFrFrame(const Frame &frame, uint8 *width, uint8 *height, uint16 x, uint16 y, ObjPos *objPos) {
+	*width = frame.width;
+	*height = frame.height;
+
+	objPos->xMin = (x + frame.x) & 0xff;
+	objPos->yMin = (y + frame.y) & 0xff;
+	objPos->xMax = objPos->xMin + frame.width;
+	objPos->yMax = objPos->yMin + frame.height;
 }
 
 void DreamBase::makeBackOb(SetObject *objData, uint16 x, uint16 y) {
@@ -115,7 +114,7 @@ void DreamBase::makeBackOb(SetObject *objData, uint16 x, uint16 y) {
 		return;
 	uint8 priority = objData->priority;
 	uint8 type = objData->type;
-	Sprite *sprite = makeSprite(x, y, addr_backobject, data.word(kSetframes), 0);
+	Sprite *sprite = makeSprite(x, y, addr_backobject, &_setFrames, 0);
 
 	uint16 objDataOffset = (uint8 *)objData - getSegment(data.word(kSetdat)).ptr(0, 0);
 	assert(objDataOffset % sizeof(SetObject) == 0);
@@ -135,7 +134,7 @@ void DreamBase::showAllObs() {
 
 	_setList.clear();
 
-	const Frame *frameBase = (const Frame *)getSegment(data.word(kSetframes)).ptr(0, 0);
+	const GraphicsFile &frameBase = _setFrames;
 	SetObject *setEntries = (SetObject *)getSegment(data.word(kSetdat)).ptr(0, count * sizeof(SetObject));
 	for (size_t i = 0; i < count; ++i) {
 		SetObject *setEntry = setEntries + i;
@@ -147,7 +146,7 @@ void DreamBase::showAllObs() {
 			continue;
 		uint8 width, height;
 		ObjPos objPos;
-		calcFrFrame(frameBase, currentFrame, &width, &height, x, y, &objPos);
+		calcFrFrame(frameBase._frames[currentFrame], &width, &height, x, y, &objPos);
 		setEntry->index = setEntry->frames[0];
 		if ((setEntry->type == 0) && (setEntry->priority != 5) && (setEntry->priority != 6)) {
 			x += data.word(kMapadx);
@@ -218,7 +217,7 @@ void DreamBase::showAllFree() {
 	_freeList.clear();
 
 	const DynObject *freeObjects = (const DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0);
-	const Frame *frameBase = (const Frame *)getSegment(data.word(kFreeframes)).ptr(0, 0);
+	const GraphicsFile &frameBase = _freeFrames;
 	for (size_t i = 0; i < count; ++i) {
 		uint16 x, y;
 		uint8 mapAd = getMapAd(freeObjects[i].mapad, &x, &y);
@@ -226,7 +225,7 @@ void DreamBase::showAllFree() {
 			uint8 width, height;
 			ObjPos objPos;
 			uint16 currentFrame = 3 * i;
-			calcFrFrame(frameBase, currentFrame, &width, &height, x, y, &objPos);
+			calcFrFrame(frameBase._frames[currentFrame], &width, &height, x, y, &objPos);
 			if ((width != 0) || (height != 0)) {
 				x += data.word(kMapadx);
 				y += data.word(kMapady);
@@ -274,7 +273,7 @@ void DreamBase::showAllEx() {
 		uint8 width, height;
 		ObjPos objPos;
 		uint16 currentFrame = 3 * i;
-		calcFrFrame(frameBase, currentFrame, &width, &height, x, y, &objPos);
+		calcFrFrame(frameBase[currentFrame], &width, &height, x, y, &objPos);
 		if ((width != 0) || (height != 0)) {
 			assert(currentFrame < 256);
 			showFrame(frameBase, x + data.word(kMapadx), y + data.word(kMapady), currentFrame, 0);
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 4727fc4..8dd8083 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -131,6 +131,21 @@ protected:
 	TextFile _puzzleText;
 	TextFile _commandText;
 
+	// graphics files
+	GraphicsFile _tempGraphics;
+	GraphicsFile _tempGraphics2;
+	GraphicsFile _tempGraphics3;
+	GraphicsFile _icons1;
+	GraphicsFile _icons2;
+	GraphicsFile _tempCharset;
+	GraphicsFile _charset1;
+	GraphicsFile _mainSprites;
+	const GraphicsFile *_currentCharset;
+
+	// room graphics files
+	GraphicsFile _setFrames;
+	GraphicsFile _freeFrames;
+
 public:
 	DreamBase(DreamWeb::DreamWebEngine *en);
 
@@ -146,7 +161,7 @@ public:
 	uint8 getXAd(const uint8 *setData, uint8 *result);
 	uint8 getYAd(const uint8 *setData, uint8 *result);
 	uint8 getMapAd(const uint8 *setData, uint16 *x, uint16 *y);
-	void calcFrFrame(const Frame *frameBase, uint16 frameNum, uint8* width, uint8* height, uint16 x, uint16 y, ObjPos *objPos);
+	void calcFrFrame(const Frame &frame, uint8* width, uint8* height, uint16 x, uint16 y, ObjPos *objPos);
 	void makeBackOb(SetObject *objData, uint16 x, uint16 y);
 	void showAllObs();
 	void getDimension(uint8 *mapXstart, uint8 *mapYstart, uint8 *mapXsize, uint8 *mapYsize);
@@ -348,13 +363,13 @@ public:
 	void poolGuard(ReelRoutine &routine);
 
 	// from print.cpp
-	uint8 getNextWord(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount);
-	void printChar(const Frame* charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height);
-	void printChar(const Frame* charSet, uint16 x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height);
-	void printBoth(const Frame* charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar);
+	uint8 getNextWord(const GraphicsFile &charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount);
+	void printChar(const GraphicsFile &charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height);
+	void printChar(const GraphicsFile &charSet, uint16 x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height);
+	void printBoth(const GraphicsFile &charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar);
 	uint8 printDirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered);
 	uint8 printDirect(const uint8* string, uint16 x, uint16 y, uint8 maxWidth, bool centered);
-	uint8 getNumber(const Frame *charSet, const uint8 *string, uint16 maxWidth, bool centered, uint16 *offset);
+	uint8 getNumber(const GraphicsFile &charSet, const uint8 *string, uint16 maxWidth, bool centered, uint16 *offset);
 	uint8 kernChars(uint8 firstChar, uint8 secondChar, uint8 width);
 	uint8 printSlow(const uint8 *string, uint16 x, uint16 y, uint8 maxWidth, bool centered);
 	uint16 waitFrames();
@@ -403,7 +418,7 @@ public:
 	void printSprites();
 	void printASprite(const Sprite *sprite);
 	void clearSprites();
-	Sprite *makeSprite(uint8 x, uint8 y, uint16 updateCallback, uint16 frameData, uint16 somethingInDi);
+	Sprite *makeSprite(uint8 x, uint8 y, uint16 updateCallback, const GraphicsFile *frameData, uint16 somethingInDi);
 	void initMan();
 	void walking(Sprite *sprite);
 	void aboutTurn(Sprite *sprite);
@@ -462,9 +477,6 @@ public:
 	void showRyanPage();
 	void switchRyanOn();
 	void switchRyanOff();
-	Frame *tempGraphics();
-	Frame *tempGraphics2();
-	Frame *tempGraphics3();
 	void middlePanel();
 	void showDiary();
 	void readMouse();
@@ -492,6 +504,7 @@ public:
 	void deallocateMem(uint16 segment);
 	uint16 allocateAndLoad(unsigned int size);
 	void loadTextFile(TextFile &file, const char *fileName);
+	void loadGraphicsFile(GraphicsFile &file, const char *fileName);
 	uint16 standardLoad(const char *fileName, uint16 *outSizeInBytes = NULL); // Returns a segment handle which needs to be freed with deallocatemem for symmetry
 	void *standardLoadCPP(const char *fileName, uint16 *outSizeInBytes = NULL); // And this one should be 'free'd
 	void loadIntoTemp(const char *fileName);
@@ -550,7 +563,6 @@ public:
 	void getRidOfTemp2();
 	void getRidOfTemp3();
 	void getRidOfTempCharset();
-	void getRidOfTempsP();
 	void getRidOfAll();
 	void placeSetObject(uint8 index);
 	void removeSetObject(uint8 index);
@@ -832,6 +844,9 @@ public:
 	void vSync();
 	void setMode();
 	void showPCX(const Common::String &name);
+	void showFrameInternal(const uint8 *pSrc, uint16 x, uint16 y, uint8 effectsFlag, uint8 width, uint8 height);
+	void showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height);
+	void showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag);
 	void showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height);
 	void showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag);
 	bool pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index b0de4df..4378841 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -65,13 +65,13 @@ void DreamGenContext::__start() {
 		//0x0100: .... .... .... ....
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0110: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
 		//0x0120: .... .... .... ....
-		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 
 		//0x0130: .... .... .... ....
-		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0140: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
+		0x00, 0xff, };
 	ds.assign(src, src + sizeof(src));
 	dreamweb(); 
 }
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index a35b405..41b3010 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -251,45 +251,40 @@ static const uint16 kBufferin = 276;
 static const uint16 kBufferout = 278;
 static const uint16 kExtras = 280;
 static const uint16 kWorkspace = 282;
-static const uint16 kCharset1 = 284;
-static const uint16 kMainsprites = 286;
-static const uint16 kBackdrop = 288;
-static const uint16 kRecordspace = 290;
-static const uint16 kFreedat = 292;
-static const uint16 kSetdat = 294;
-static const uint16 kReel1 = 296;
-static const uint16 kReel2 = 298;
-static const uint16 kReel3 = 300;
-static const uint16 kRoomdesc = 302;
-static const uint16 kFreedesc = 304;
-static const uint16 kSetdesc = 306;
-static const uint16 kBlockdesc = 308;
-static const uint16 kSetframes = 310;
-static const uint16 kFreeframes = 312;
-static const uint16 kPeople = 314;
-static const uint16 kReels = 316;
-static const uint16 kTempgraphics = 318;
-static const uint16 kTempgraphics2 = 320;
-static const uint16 kTempgraphics3 = 322;
-static const uint16 kTempsprites = 324;
-static const uint16 kBlinkframe = 326;
-static const uint16 kBlinkcount = 327;
-static const uint16 kReasseschanges = 328;
-static const uint16 kPointerspath = 329;
-static const uint16 kManspath = 330;
-static const uint16 kPointerfirstpath = 331;
-static const uint16 kFinaldest = 332;
-static const uint16 kDestination = 333;
-static const uint16 kLinestartx = 334;
-static const uint16 kLinestarty = 336;
-static const uint16 kLineendx = 338;
-static const uint16 kLineendy = 340;
-static const uint16 kLinepointer = 342;
-static const uint16 kLinedirection = 343;
-static const uint16 kLinelength = 344;
-static const uint16 kCh0playing = 345;
-static const uint16 kCh0repeat = 346;
-static const uint16 kCh1playing = 347;
+static const uint16 kMainsprites = 284;
+static const uint16 kBackdrop = 286;
+static const uint16 kRecordspace = 288;
+static const uint16 kFreedat = 290;
+static const uint16 kSetdat = 292;
+static const uint16 kReel1 = 294;
+static const uint16 kReel2 = 296;
+static const uint16 kReel3 = 298;
+static const uint16 kRoomdesc = 300;
+static const uint16 kFreedesc = 302;
+static const uint16 kSetdesc = 304;
+static const uint16 kBlockdesc = 306;
+static const uint16 kSetframes = 308;
+static const uint16 kFreeframes = 310;
+static const uint16 kPeople = 312;
+static const uint16 kReels = 314;
+static const uint16 kBlinkframe = 316;
+static const uint16 kBlinkcount = 317;
+static const uint16 kReasseschanges = 318;
+static const uint16 kPointerspath = 319;
+static const uint16 kManspath = 320;
+static const uint16 kPointerfirstpath = 321;
+static const uint16 kFinaldest = 322;
+static const uint16 kDestination = 323;
+static const uint16 kLinestartx = 324;
+static const uint16 kLinestarty = 326;
+static const uint16 kLineendx = 328;
+static const uint16 kLineendy = 330;
+static const uint16 kLinepointer = 332;
+static const uint16 kLinedirection = 333;
+static const uint16 kLinelength = 334;
+static const uint16 kCh0playing = 335;
+static const uint16 kCh0repeat = 336;
+static const uint16 kCh1playing = 337;
 static const uint16 kBlocktextdat = (0);
 static const uint16 kPersonframes = (0);
 static const uint16 kDebuglevel1 = (0);
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index d90cd6a..b31a851 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -58,18 +58,10 @@ DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gam
 	_channel0 = 0;
 	_channel1 = 0;
 
-	_icons1 = NULL;
-	_icons2 = NULL;
-	_tempCharset = NULL;
-
 	_language = gameDesc->desc.language;
 }
 
 DreamWebEngine::~DreamWebEngine() {
-	assert(_icons1 == NULL);
-	assert(_icons2 == NULL);
-	assert(_tempCharset == NULL);
-
 	DebugMan.clearAllDebugChannels();
 	delete _console;
 }
@@ -421,6 +413,8 @@ DreamBase::DreamBase(DreamWeb::DreamWebEngine *en) : engine(en) {
 
 	_currentSample = 0xff;
 
+	_backdropBlocks = 0;
+
 	_oldSubject._type = 0;
 	_oldSubject._index = 0;
 }
diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h
index 4d7bf5f..58354a9 100644
--- a/engines/dreamweb/dreamweb.h
+++ b/engines/dreamweb/dreamweb.h
@@ -125,20 +125,6 @@ public:
 
 	void stopSound(uint8 channel);
 
-	DreamGen::Frame *icons1() const { return (DreamGen::Frame *)_icons1; }
-	DreamGen::Frame *icons2() const { return (DreamGen::Frame *)_icons2; }
-	void setIcons1(void *frames) { assert(_icons1 == NULL); _icons1 = frames; }
-	void setIcons2(void *frames) { assert(_icons2 == NULL); _icons2 = frames; }
-	void freeIcons1() { free(_icons1); _icons1 = NULL; }
-	void freeIcons2() { free(_icons2); _icons2 = NULL; }
-
-	DreamGen::Frame *tempCharset() const { return (DreamGen::Frame *)_tempCharset; }
-	void setTempCharset(void *frames) { assert(_tempCharset == NULL); _tempCharset = frames; }
-	void freeTempCharset() { free(_tempCharset); _tempCharset = NULL; }
-
-	DreamGen::Frame *currentCharset() const { return _currentCharset; }
-	void setCurrentCharset(DreamGen::Frame *charset) { _currentCharset = charset; }
-
 private:
 	void keyPressed(uint16 ascii);
 	void setSpeed(uint speed);
@@ -173,11 +159,6 @@ private:
 	Audio::SoundHandle _channelHandle[2];
 	uint8 _channel0, _channel1;
 
-	void *_icons1;
-	void *_icons2;
-	void *_tempCharset;
-	DreamGen::Frame *_currentCharset;
-
 	DreamGen::DreamGenContext _context;
 	DreamGen::DreamBase &_base;
 };
diff --git a/engines/dreamweb/keypad.cpp b/engines/dreamweb/keypad.cpp
index c3db72f..5f83ddb 100644
--- a/engines/dreamweb/keypad.cpp
+++ b/engines/dreamweb/keypad.cpp
@@ -39,7 +39,7 @@ void DreamBase::singleKey(uint8 key, uint16 x, uint16 y) {
 			key -= 11;
 	}
 	key -= 20;
-	showFrame(tempGraphics(), x, y, key, 0);
+	showFrame(_tempGraphics, x, y, key, 0);
 }
 
 void DreamBase::loadKeypad() {
@@ -71,7 +71,7 @@ void DreamBase::showKeypad() {
 		}
 		if ((data.byte(kLightcount) >= 60) && (data.byte(kLightcount) < 100))
 			--frameIndex;
-		showFrame(tempGraphics(), kKeypadx+60, y, frameIndex, 0);
+		showFrame(_tempGraphics, kKeypadx+60, y, frameIndex, 0);
 	}
 }
 
@@ -224,8 +224,8 @@ void DreamBase::buttonPress(uint8 buttonId) {
 }
 
 void DreamBase::showOuterPad() {
-	showFrame(tempGraphics(), kKeypadx-3, kKeypady-4, 1, 0);
-	showFrame(tempGraphics(), kKeypadx+74, kKeypady+76, 37, 0);
+	showFrame(_tempGraphics, kKeypadx-3, kKeypady-4, 1, 0);
+	showFrame(_tempGraphics, kKeypadx+74, kKeypady+76, 37, 0);
 }
 
 void DreamBase::dumpKeypad() {
diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp
index 23c26f6..471d5ec 100644
--- a/engines/dreamweb/monitor.cpp
+++ b/engines/dreamweb/monitor.cpp
@@ -188,14 +188,14 @@ void DreamBase::monitorLogo() {
 }
 
 void DreamBase::printLogo() {
-	showFrame(tempGraphics(), 56, 32, 0, 0);
+	showFrame(_tempGraphics, 56, 32, 0, 0);
 	showCurrentFile();
 }
 
 void DreamBase::input() {
 	memset(_inputLine, 0, 64);
 	data.word(kCurpos) = 0;
-	printChar(engine->tempCharset(), data.word(kMonadx), data.word(kMonady), '>', 0, NULL, NULL);
+	printChar(_tempCharset, data.word(kMonadx), data.word(kMonady), '>', 0, NULL, NULL);
 	multiDump(data.word(kMonadx), data.word(kMonady), 6, 8);
 	data.word(kMonadx) += 6;
 	data.word(kCurslocx) = data.word(kMonadx);
@@ -227,7 +227,7 @@ void DreamBase::input() {
 			continue;
 		multiGet(_mapStore + data.word(kCurpos) * 256, data.word(kMonadx), data.word(kMonady), 8, 8);
 		uint8 charWidth;
-		printChar(engine->tempCharset(), data.word(kMonadx), data.word(kMonady), currentKey, 0, &charWidth, NULL);
+		printChar(_tempCharset, data.word(kMonadx), data.word(kMonady), currentKey, 0, &charWidth, NULL);
 		_inputLine[data.word(kCurpos) * 2 + 1] = charWidth;
 		data.word(kMonadx) += charWidth;
 		++data.word(kCurpos);
@@ -266,7 +266,7 @@ void DreamBase::printCurs() {
 	multiGet(_textUnder, x, y, 6, height);
 	++data.word(kMaintimer);
 	if ((data.word(kMaintimer) & 16) == 0)
-		showFrame(engine->tempCharset(), x, y, '/' - 32, 0);
+		showFrame(_tempCharset, x, y, '/' - 32, 0);
 	multiDump(x - 6, y, 12, height);
 }
 
@@ -297,17 +297,17 @@ void DreamBase::showCurrentFile() {
 	while (*currentFile) {
 		char c = *currentFile++;
 		c = engine->modifyChar(c);
-		printChar(engine->tempCharset(), &x, 37, c, 0, NULL, NULL);
+		printChar(_tempCharset, &x, 37, c, 0, NULL, NULL);
 	}
 }
 
 void DreamBase::accessLightOn() {
-	showFrame(tempGraphics(), 74, 182, 8, 0);
+	showFrame(_tempGraphics, 74, 182, 8, 0);
 	multiDump(74, 182, 12, 8);
 }
 
 void DreamBase::accessLightOff() {
-	showFrame(tempGraphics(), 74, 182, 7, 0);
+	showFrame(_tempGraphics, 74, 182, 7, 0);
 	multiDump(74, 182, 12, 8);
 }
 
@@ -340,22 +340,22 @@ void DreamBase::netError() {
 }
 
 void DreamBase::powerLightOn() {
-	showFrame(tempGraphics(), 257+4, 182, 6, 0);
+	showFrame(_tempGraphics, 257+4, 182, 6, 0);
 	multiDump(257+4, 182, 12, 8);
 }
 
 void DreamBase::powerLightOff() {
-	showFrame(tempGraphics(), 257+4, 182, 5, 0);
+	showFrame(_tempGraphics, 257+4, 182, 5, 0);
 	multiDump(257+4, 182, 12, 8);
 }
 
 void DreamBase::lockLightOn() {
-	showFrame(tempGraphics(), 56, 182, 10, 0);
+	showFrame(_tempGraphics, 56, 182, 10, 0);
 	multiDump(58, 182, 12, 8);
 }
 
 void DreamBase::lockLightOff() {
-	showFrame(tempGraphics(), 56, 182, 9, 0);
+	showFrame(_tempGraphics, 56, 182, 9, 0);
 	multiDump(58, 182, 12, 8);
 }
 
@@ -370,10 +370,10 @@ void DreamBase::turnOnPower() {
 }
 
 void DreamBase::printOuterMon() {
-	showFrame(tempGraphics(), 40, 32, 1, 0);
-	showFrame(tempGraphics(), 264, 32, 2, 0);
-	showFrame(tempGraphics(), 40, 12, 3, 0);
-	showFrame(tempGraphics(), 40, 164, 4, 0);
+	showFrame(_tempGraphics, 40, 32, 1, 0);
+	showFrame(_tempGraphics, 264, 32, 2, 0);
+	showFrame(_tempGraphics, 40, 12, 3, 0);
+	showFrame(_tempGraphics, 40, 164, 4, 0);
 }
 
 void DreamBase::loadPersonal() {
diff --git a/engines/dreamweb/newplace.cpp b/engines/dreamweb/newplace.cpp
index 21975ee..43b334c 100644
--- a/engines/dreamweb/newplace.cpp
+++ b/engines/dreamweb/newplace.cpp
@@ -98,8 +98,8 @@ void DreamBase::selectLocation() {
 
 void DreamBase::showCity() {
 	clearWork();
-	showFrame(tempGraphics(), 57, 32, 0, 0);
-	showFrame(tempGraphics(), 120+57, 32, 1, 0);
+	showFrame(_tempGraphics, 57, 32, 0, 0);
+	showFrame(_tempGraphics, 120+57, 32, 1, 0);
 }
 
 void DreamBase::lookAtPlace() {
@@ -116,10 +116,10 @@ void DreamBase::lookAtPlace() {
 	delPointer();
 	delTextLine();
 	getUnderCentre();
-	showFrame(tempGraphics3(), 60, 72, 0, 0);
-	showFrame(tempGraphics3(), 60, 72 + 55, 4, 0);
+	showFrame(_tempGraphics3, 60, 72, 0, 0);
+	showFrame(_tempGraphics3, 60, 72 + 55, 4, 0);
 	if (_foreignRelease)
-		showFrame(tempGraphics3(), 60, 72+55+21, 4, 0);
+		showFrame(_tempGraphics3, 60, 72+55+21, 4, 0);
 
 	const uint8 *string = (const uint8 *)_travelText.getString(data.byte(kDestpos));
 	findNextColon(&string);
@@ -146,21 +146,21 @@ void DreamBase::locationPic() {
 	byte picture = roomPics[data.byte(kDestpos)];
 
 	if (picture >= 6)
-		showFrame(tempGraphics2(), 104, 138 + 14, picture - 6, 0);	// Second slot
+		showFrame(_tempGraphics2, 104, 138 + 14, picture - 6, 0);	// Second slot
 	else
-		showFrame(tempGraphics(),  104, 138 + 14, picture + 4, 0);
+		showFrame(_tempGraphics,  104, 138 + 14, picture + 4, 0);
 
 	if (data.byte(kDestpos) == data.byte(kReallocation))
-		showFrame(tempGraphics(), 104, 140 + 14, 3, 0);	// Currently in this location
+		showFrame(_tempGraphics, 104, 140 + 14, 3, 0);	// Currently in this location
 
 	const uint8 *string = (const uint8 *)_travelText.getString(data.byte(kDestpos));
 	DreamBase::printDirect(string, 50, 20, 241, 241 & 1);
 }
 
 void DreamBase::showArrows() {
-	showFrame(tempGraphics(), 116 - 12, 16, 0, 0);
-	showFrame(tempGraphics(), 226 + 12, 16, 1, 0);
-	showFrame(tempGraphics(), 280, 14, 2, 0);
+	showFrame(_tempGraphics, 116 - 12, 16, 0, 0);
+	showFrame(_tempGraphics, 226 + 12, 16, 1, 0);
+	showFrame(_tempGraphics, 280, 14, 2, 0);
 }
 
 void DreamBase::nextDest() {
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index cb105c7..4f9d091 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -25,8 +25,8 @@
 namespace DreamGen {
 
 void DreamBase::showRyanPage() {
-	showFrame(engine->icons1(), kInventx + 167, kInventy - 12, 12, 0);
-	showFrame(engine->icons1(), kInventx + 167 + 18 * data.byte(kRyanpage), kInventy - 12, 13 + data.byte(kRyanpage), 0);
+	showFrame(_icons1, kInventx + 167, kInventy - 12, 12, 0);
+	showFrame(_icons1, kInventx + 167 + 18 * data.byte(kRyanpage), kInventy - 12, 13 + data.byte(kRyanpage), 0);
 }
 
 void DreamBase::findAllRyan() {
@@ -79,30 +79,32 @@ void DreamBase::makeWorn(DynObject *object) {
 }
 
 void DreamBase::obToInv(uint8 index, uint8 flag, uint16 x, uint16 y) {
-	showFrame(engine->icons1(), x - 2, y - 1, 10, 0);
+	showFrame(_icons1, x - 2, y - 1, 10, 0);
 	if (index == 0xff)
 		return;
 
-	Frame *extras = (Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
-	Frame *frees = (Frame *)getSegment(data.word(kFreeframes)).ptr(0, 0);
-	Frame *frames = (flag == 4) ? extras : frees;
-	showFrame(frames, x + 18, y + 19, 3 * index + 1, 128);
+	if (flag == kExObjectType) {
+		Frame *extras = (Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
+		showFrame(extras, x + 18, y + 19, 3 * index + 1, 128);
+	} else {
+		showFrame(_freeFrames, x + 18, y + 19, 3 * index + 1, 128);
+	}
 	const DynObject *object = (const DynObject *)getAnyAdDir(index, flag);
 	bool worn = isItWorn(object);
 	if (worn)
-		showFrame(engine->icons1(), x - 3, y - 2, 7, 0);
+		showFrame(_icons1, x - 3, y - 2, 7, 0);
 }
 
 void DreamBase::obPicture() {
 	if (data.byte(kObjecttype) == kSetObjectType1)
 		return;
-	Frame *frames;
-	if (data.byte(kObjecttype) == kExObjectType)
-		frames = (Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
-	else
-		frames = (Frame *)getSegment(data.word(kFreeframes)).ptr(0, 0);
 	uint8 frame = 3 * data.byte(kCommand) + 1;
-	showFrame(frames, 160, 68, frame, 0x80);
+	if (data.byte(kObjecttype) == kExObjectType) {
+		const Frame *frames = (const Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
+		showFrame(frames, 160, 68, frame, 0x80);
+	} else {
+		showFrame(_freeFrames, 160, 68, frame, 0x80);
+	}
 }
 
 void DreamBase::obIcons() {
@@ -110,10 +112,10 @@ void DreamBase::obIcons() {
 	getAnyAd(&value1, &value2);
 	if (value1 != 0xff) {
 		// can open it
-		showFrame(engine->icons2(), 210, 1, 4, 0);
+		showFrame(_icons2, 210, 1, 4, 0);
 	}
 
-	showFrame(engine->icons2(), 260, 1, 1, 0);
+	showFrame(_icons2, 260, 1, 1, 0);
 }
 
 void DreamBase::examineOb(bool examineAgain) {
diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp
index f5f0dda..b20726d 100644
--- a/engines/dreamweb/print.cpp
+++ b/engines/dreamweb/print.cpp
@@ -24,7 +24,7 @@
 
 namespace DreamGen {
 
-void DreamBase::printBoth(const Frame *charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar) {
+void DreamBase::printBoth(const GraphicsFile &charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar) {
 	uint16 newX = *x;
 	uint8 width, height;
 	printChar(charSet, &newX, y, c, nextChar, &width, &height);
@@ -32,7 +32,7 @@ void DreamBase::printBoth(const Frame *charSet, uint16 *x, uint16 y, uint8 c, ui
 	*x = newX;
 }
 
-uint8 DreamBase::getNextWord(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount) {
+uint8 DreamBase::getNextWord(const GraphicsFile &charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount) {
 	*totalWidth = 0;
 	*charCount = 0;
 	while (true) {
@@ -50,14 +50,14 @@ uint8 DreamBase::getNextWord(const Frame *charSet, const uint8 *string, uint8 *t
 		firstChar = engine->modifyChar(firstChar);
 		if (firstChar != 255) {
 			uint8 secondChar = *string;
-			uint8 width = charSet[firstChar - 32 + data.word(kCharshift)].width;
+			uint8 width = charSet._frames[firstChar - 32 + data.word(kCharshift)].width;
 			width = kernChars(firstChar, secondChar, width);
 			*totalWidth += width;
 		}
 	}
 }
 
-void DreamBase::printChar(const Frame *charSet, uint16* x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) {
+void DreamBase::printChar(const GraphicsFile &charSet, uint16* x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) {
 	if (c == 255)
 		return;
 
@@ -75,23 +75,22 @@ void DreamBase::printChar(const Frame *charSet, uint16* x, uint16 y, uint8 c, ui
 	(*x) += *width;
 }
 
-void DreamBase::printChar(const Frame *charSet, uint16 x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) {
+void DreamBase::printChar(const GraphicsFile &charSet, uint16 x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) {
 	printChar(charSet, &x, y, c, nextChar, width, height);
 }
 
 uint8 DreamBase::printSlow(const uint8 *string, uint16 x, uint16 y, uint8 maxWidth, bool centered) {
 	data.byte(kPointerframe) = 1;
 	data.byte(kPointermode) = 3;
-	const Frame* charSet = (const Frame *)getSegment(data.word(kCharset1)).ptr(0, 0);
 	do {
 		uint16 offset = x;
-		uint16 charCount = getNumber(charSet, string, maxWidth, centered, &offset);
+		uint16 charCount = getNumber(_charset1, string, maxWidth, centered, &offset);
 		do {
 			uint8 c0 = string[0];
 			uint8 c1 = string[1];
 			uint8 c2 = string[2];
 			c0 = engine->modifyChar(c0);
-			printBoth(charSet, &offset, y, c0, c1);
+			printBoth(_charset1, &offset, y, c0, c1);
 			if ((c1 == 0) || (c1 == ':')) {
 				return 0;
 			}
@@ -99,7 +98,7 @@ uint8 DreamBase::printSlow(const uint8 *string, uint16 x, uint16 y, uint8 maxWid
 				c1 = engine->modifyChar(c1);
 				data.word(kCharshift) = 91;
 				uint16 offset2 = offset;
-				printBoth(charSet, &offset2, y, c1, c2);
+				printBoth(_charset1, &offset2, y, c1, c2);
 				data.word(kCharshift) = 0;
 				for (int i=0; i<2; ++i) {
 					uint16 mouseState = waitFrames();
@@ -126,7 +125,7 @@ uint8 DreamBase::printDirect(const uint8* string, uint16 x, uint16 y, uint8 maxW
 
 uint8 DreamBase::printDirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered) {
 	data.word(kLastxpos) = x;
-	const Frame *charSet = engine->currentCharset();
+	const GraphicsFile &charSet = *_currentCharset;
 	while (true) {
 		uint16 offset = x;
 		uint8 charCount = getNumber(charSet, *string, maxWidth, centered, &offset);
@@ -148,7 +147,7 @@ uint8 DreamBase::printDirect(const uint8** string, uint16 x, uint16 *y, uint8 ma
 	}
 }
 
-uint8 DreamBase::getNumber(const Frame *charSet, const uint8 *string, uint16 maxWidth, bool centered, uint16* offset) {
+uint8 DreamBase::getNumber(const GraphicsFile &charSet, const uint8 *string, uint16 maxWidth, bool centered, uint16* offset) {
 	uint8 totalWidth = 0;
 	uint8 charCount = 0;
 	while (true) {
@@ -207,12 +206,11 @@ uint16 DreamBase::waitFrames() {
 const char *DreamBase::monPrint(const char *string) {
 	data.byte(kKerning) = 1;
 	uint16 x = data.word(kMonadx);
-	Frame *charset = engine->tempCharset();
 	const char *iterator = string;
 	bool done = false;
 	while (!done) {
 
-		uint16 count = getNumber(charset, (const uint8 *)iterator, 166, false, &x);
+		uint16 count = getNumber(_tempCharset, (const uint8 *)iterator, 166, false, &x);
 		do {	
 			char c = *iterator++;
 			if (c == ':')
@@ -228,7 +226,7 @@ const char *DreamBase::monPrint(const char *string) {
 				break;
 			}
 			c = engine->modifyChar(c);
-			printChar(charset, &x, data.word(kMonady), c, 0, NULL, NULL);
+			printChar(_tempCharset, &x, data.word(kMonady), c, 0, NULL, NULL);
 			data.word(kCurslocx) = x;
 			data.word(kCurslocy) = data.word(kMonady);
 			data.word(kMaintimer) = 1;
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index 159f886..843bee7 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -118,9 +118,7 @@ void DreamBase::doLoad(int savegameId) {
 	// If we reach this point, loadPosition() has just been called.
 	// Among other things, it will have filled g_MadeUpRoomDat.
 
-	// kTempgraphics might not have been allocated if we bypassed all menus
-	if (data.word(kTempgraphics) != 0xFFFF)
-		getRidOfTemp();
+	getRidOfTemp();
 
 	startLoading(g_madeUpRoomDat);
 	loadRoomsSample();
@@ -338,16 +336,16 @@ void DreamBase::getBackToOps() {
 }
 
 void DreamBase::showMainOps() {
-	showFrame(tempGraphics(), kOpsx+10, kOpsy+10, 8, 0);
-	showFrame(tempGraphics(), kOpsx+59, kOpsy+30, 7, 0);
-	showFrame(tempGraphics(), kOpsx+128+4, kOpsy+12, 1, 0);
+	showFrame(_tempGraphics, kOpsx+10, kOpsy+10, 8, 0);
+	showFrame(_tempGraphics, kOpsx+59, kOpsy+30, 7, 0);
+	showFrame(_tempGraphics, kOpsx+128+4, kOpsy+12, 1, 0);
 }
 
 void DreamBase::showDiscOps() {
-	showFrame(tempGraphics(), kOpsx+128+4, kOpsy+12, 1, 0);
-	showFrame(tempGraphics(), kOpsx+10, kOpsy+10, 9, 0);
-	showFrame(tempGraphics(), kOpsx+59, kOpsy+30, 10, 0);
-	showFrame(tempGraphics(), kOpsx+176+2, kOpsy+60-4, 5, 0);
+	showFrame(_tempGraphics, kOpsx+128+4, kOpsy+12, 1, 0);
+	showFrame(_tempGraphics, kOpsx+10, kOpsy+10, 9, 0);
+	showFrame(_tempGraphics, kOpsx+59, kOpsy+30, 10, 0);
+	showFrame(_tempGraphics, kOpsx+176+2, kOpsy+60-4, 5, 0);
 }
 
 void DreamBase::discOps() {
@@ -648,7 +646,7 @@ void DreamBase::loadOld() {
 void DreamBase::showDecisions() {
 	createPanel2();
 	showOpBox();
-	showFrame(tempGraphics(), kOpsx + 17, kOpsy + 13, 6, 0);
+	showFrame(_tempGraphics, kOpsx + 17, kOpsy + 13, 6, 0);
 	underTextLine();
 }
 
@@ -750,35 +748,35 @@ void DreamBase::selectSlot() {
 }
 
 void DreamBase::showSlots() {
-	showFrame(tempGraphics(), kOpsx + 7, kOpsy + 8, 2, 0);
+	showFrame(_tempGraphics, kOpsx + 7, kOpsy + 8, 2, 0);
 
 	uint16 y = kOpsy + 11;
 
 	for (int slot = 0; slot < 7; slot++) {
 		if (slot == data.byte(kCurrentslot))
-			showFrame(tempGraphics(), kOpsx + 10, y, 3, 0);
+			showFrame(_tempGraphics, kOpsx + 10, y, 3, 0);
 
 		y += 10;
 	}
 }
 
 void DreamBase::showOpBox() {
-	showFrame(tempGraphics(), kOpsx, kOpsy, 0, 0);
+	showFrame(_tempGraphics, kOpsx, kOpsy, 0, 0);
 
 	// CHECKME: There seem to be versions of dreamweb in which this call
 	// should be removed. It displays a red dot on the ops dialogs if left in.
-	showFrame(tempGraphics(), kOpsx, kOpsy + 55, 4, 0);
+	showFrame(_tempGraphics, kOpsx, kOpsy + 55, 4, 0);
 }
 
 void DreamBase::showLoadOps() {
-	showFrame(tempGraphics(), kOpsx + 128 + 4, kOpsy + 12, 1, 0);
-	showFrame(tempGraphics(), kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0);
+	showFrame(_tempGraphics, kOpsx + 128 + 4, kOpsy + 12, 1, 0);
+	showFrame(_tempGraphics, kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0);
 	printMessage(kOpsx + 104, kOpsy + 14, 55, 101, (101 & 1));
 }
 
 void DreamBase::showSaveOps() {
-	showFrame(tempGraphics(), kOpsx + 128 + 4, kOpsy + 12, 1, 0);
-	showFrame(tempGraphics(), kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0);
+	showFrame(_tempGraphics, kOpsx + 128 + 4, kOpsy + 12, 1, 0);
+	showFrame(_tempGraphics, kOpsx + 176 + 2, kOpsy + 60 - 4, 5, 0);
 	printMessage(kOpsx + 104, kOpsy + 14, 54, 101, (101 & 1));
 }
 
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index cd79d38..31f7408 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -58,14 +58,14 @@ void DreamBase::printASprite(const Sprite *sprite) {
 		c = 8;
 	else
 		c = 0;
-	showFrame((const Frame *)getSegment(sprite->_frameData).ptr(0, 0), x, y, sprite->frameNumber, c);
+	showFrame(*sprite->_frameData, x, y, sprite->frameNumber, c);
 }
 
 void DreamBase::clearSprites() {
 	_spriteTable.clear();
 }
 
-Sprite *DreamBase::makeSprite(uint8 x, uint8 y, uint16 updateCallback, uint16 frameData, uint16 somethingInDi) {
+Sprite *DreamBase::makeSprite(uint8 x, uint8 y, uint16 updateCallback, const GraphicsFile *frameData, uint16 somethingInDi) {
 	// Note: the original didn't append sprites here, but filled up the
 	// first unused entry. This can change the order of entries, but since they
 	// are drawn based on the priority field, this shouldn't matter.
@@ -109,7 +109,7 @@ void DreamBase::spriteUpdate() {
 }
 
 void DreamBase::initMan() {
-	Sprite *sprite = makeSprite(data.byte(kRyanx), data.byte(kRyany), addr_mainman, data.word(kMainsprites), 0);
+	Sprite *sprite = makeSprite(data.byte(kRyanx), data.byte(kRyany), addr_mainman, &_mainSprites, 0);
 	sprite->priority = 4;
 	sprite->speed = 0;
 	sprite->walkFrame = 0;
@@ -477,8 +477,7 @@ void DreamBase::showRain() {
 	if (_rainList.empty())
 		return;
 
-	const Frame *frame = (const Frame *)getSegment(data.word(kMainsprites)).ptr(58 * sizeof(Frame), sizeof(Frame));
-	const uint8 *frameData = getSegment(data.word(kMainsprites)).ptr(kFrframes + frame->ptr(), 512);
+	const uint8 *frameData = _mainSprites.getFrameData(58);
 
 	for (i = _rainList.begin(); i != _rainList.end(); ++i) {
 		Rain &rain = *i;
@@ -1102,13 +1101,14 @@ void DreamBase::clearBeforeLoad() {
 	//clearRest
 	memset(_mapData, 0, kMaplen);
 	delete[] _backdropBlocks;
-	deallocateMem(data.word(kSetframes));
+	_backdropBlocks = 0;
+	_setFrames.clear();
 	deallocateMem(data.word(kReels));
 	deallocateMem(data.word(kPeople));
 	deallocateMem(data.word(kSetdesc));
 	deallocateMem(data.word(kBlockdesc));
 	deallocateMem(data.word(kRoomdesc));
-	deallocateMem(data.word(kFreeframes));
+	_freeFrames.clear();
 	deallocateMem(data.word(kFreedesc));
 
 	data.byte(kRoomloaded) = 0;
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index ce675fc..cf3e2ce 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -28,11 +28,13 @@
 
 namespace DreamGen {
 
+struct GraphicsFile;
+
 struct Sprite {
 	uint16 _updateCallback;
 	uint16 w2;
 	uint16 w4;
-	uint16 _frameData;
+	const GraphicsFile *_frameData;
 	uint16 w8;
 	uint8  x;
 	uint8  y;
@@ -308,6 +310,24 @@ struct TextFile {
 	}
 };
 
+struct GraphicsFile {
+	GraphicsFile() : _data(0) { }
+
+	Frame _frames[347];
+	uint8 *_data;
+
+	const uint8 *getFrameData(unsigned int i) const {
+		// There is 2080 bytes of Frame data, but that is between 346 and 347
+		// frames
+		assert(i < 346);
+		return _data + _frames[i].ptr();
+	}
+	void clear() {
+		delete[] _data;
+		_data = 0;
+	}
+};
+
 
 } // End of namespace DreamWeb
 
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 1868c19..9ef7dda 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -640,8 +640,22 @@ done: // The engine will need some cleaner finalization, let's put it here for n
 	// FIXME: This triggers "Deallocating non existent segment" errors when
 	// quitting from a menu.
 	getRidOfAll();
-	engine->freeIcons1();
-	engine->freeIcons2();
+
+	_icons1.clear();
+	_icons2.clear();
+	_charset1.clear();
+	_tempGraphics.clear();
+	_tempGraphics2.clear();
+	_tempGraphics3.clear();
+	_tempCharset.clear();
+	_mainSprites.clear();
+
+	_textFile1.clear();
+	_textFile2.clear();
+	_textFile3.clear();
+	_travelText.clear();
+	_puzzleText.clear();
+	_commandText.clear();
 }
 
 void DreamBase::loadTextFile(TextFile &file, const char *fileName)
@@ -775,20 +789,36 @@ void *DreamBase::standardLoadCPP(const char *fileName, uint16 *outSizeInBytes) {
 	return buffer;
 }
 
+void DreamBase::loadGraphicsFile(GraphicsFile &file, const char *fileName) {
+	FileHeader header;
+
+	Common::File f;
+	f.open(fileName);
+	f.read((uint8 *)&header, sizeof(FileHeader));
+	uint16 sizeInBytes = header.len(0);
+
+	assert(sizeInBytes >= 2080);
+	delete[] file._data;
+	file._data = new uint8[sizeInBytes - 2080];
+
+	f.read((uint8 *)file._frames, 2080);
+	f.read(file._data, sizeInBytes - 2080);
+}
+
 void DreamBase::loadIntoTemp(const char *fileName) {
-	data.word(kTempgraphics) = standardLoad(fileName);
+	loadGraphicsFile(_tempGraphics, fileName);
 }
 
 void DreamBase::loadIntoTemp2(const char *fileName) {
-	data.word(kTempgraphics2) = standardLoad(fileName);
+	loadGraphicsFile(_tempGraphics2, fileName);
 }
 
 void DreamBase::loadIntoTemp3(const char *fileName) {
-	data.word(kTempgraphics3) = standardLoad(fileName);
+	loadGraphicsFile(_tempGraphics3, fileName);
 }
 
 void DreamBase::loadTempCharset(const char *fileName) {
-	engine->setTempCharset(standardLoadCPP(fileName));
+	loadGraphicsFile(_tempCharset, fileName);
 }
 
 void DreamBase::hangOnCurs(uint16 frameCount) {
@@ -955,17 +985,6 @@ uint16 DreamBase::allocateMem(uint16 paragraphs) {
 void DreamBase::deallocateMem(uint16 segment) {
 	debug(1, "deallocating segment %04x", segment);
 	deallocateSegment(segment);
-
-	// CHECKME: Do we really need this? From brief testing it appears
-	// the sprite table is cleared entirely shortly after this happens
-	// anyway.
-	Common::List<Sprite>::iterator i;
-	for (i = _spriteTable.begin(); i != _spriteTable.end(); ) {
-		if (i->_frameData == segment)
-			i = _spriteTable.erase(i);
-		else
-			++i;
-	}
 }
 
 void DreamBase::DOSReturn() {
@@ -1131,7 +1150,7 @@ void DreamBase::crosshair() {
 	} else {
 		frame = 29;
 	}
-	showFrame(engine->icons1(), kZoomx + 24, kZoomy + 19, frame, 0);
+	showFrame(_icons1, kZoomx + 24, kZoomy + 19, frame, 0);
 }
 
 void DreamBase::delTextLine() {
@@ -1505,7 +1524,7 @@ void DreamBase::showBlink() {
 		blinkFrame = 6;
 	static const uint8 blinkTab[] = { 16,18,18,17,16,16,16 };
 	uint8 width, height;
-	showFrame(engine->icons1(), 44, 32, blinkTab[blinkFrame], 0, &width, &height);
+	showFrame(_icons1, 44, 32, blinkTab[blinkFrame], 0, &width, &height);
 }
 
 void DreamBase::dumpBlink() {
@@ -1546,12 +1565,13 @@ void DreamBase::showPointer() {
 	uint16 y = data.word(kMousey);
 	data.word(kOldpointery) = data.word(kMousey);
 	if (data.byte(kPickup) == 1) {
-		const Frame *frames;
-		if (data.byte(kObjecttype) != kExObjectType)
-			frames = (const Frame *)getSegment(data.word(kFreeframes)).ptr(0, 0);
-		else
-			frames = (const Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
-		const Frame *frame = frames + (3 * data.byte(kItemframe) + 1);
+		const Frame *frame;
+		if (data.byte(kObjecttype) != kExObjectType) {
+			frame = &_freeFrames._frames[(3 * data.byte(kItemframe) + 1)];
+		} else {
+			const Frame *frames = (const Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
+			frame = frames + (3 * data.byte(kItemframe) + 1);
+		}
 		uint8 width = frame->width;
 		uint8 height = frame->height;
 		if (width < 12)
@@ -1565,10 +1585,15 @@ void DreamBase::showPointer() {
 		data.word(kOldpointerx) = xMin;
 		data.word(kOldpointery) = yMin;
 		multiGet(_pointerBack, xMin, yMin, width, height);
-		showFrame(frames, x, y, 3 * data.byte(kItemframe) + 1, 128);
-		showFrame(engine->icons1(), x, y, 3, 128);
+		if (data.byte(kObjecttype) != kExObjectType) {
+			showFrame(_freeFrames, x, y, 3 * data.byte(kItemframe) + 1, 128);
+		} else {
+			const Frame *frames = (const Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
+			showFrame(frames, x, y, 3 * data.byte(kItemframe) + 1, 128);
+		}
+		showFrame(_icons1, x, y, 3, 128);
 	} else {
-		const Frame *frame = engine->icons1() + (data.byte(kPointerframe) + 20);
+		const Frame *frame = &_icons1._frames[data.byte(kPointerframe) + 20];
 		uint8 width = frame->width;
 		uint8 height = frame->height;
 		if (width < 12)
@@ -1578,7 +1603,7 @@ void DreamBase::showPointer() {
 		data.byte(kPointerxs) = width;
 		data.byte(kPointerys) = height;
 		multiGet(_pointerBack, x, y, width, height);
-		showFrame(engine->icons1(), x, y, data.byte(kPointerframe) + 20, 0);
+		showFrame(_icons1, x, y, data.byte(kPointerframe) + 20, 0);
 	}
 }
 
@@ -1712,6 +1737,9 @@ void DreamBase::showIcon() {
 		panelIcons1();
 		zoomIcon();
 	} else {
+		error("Unimplemented tempsprites code called");
+		// the tempsprites segment is never initialized, but used here.
+/*
 		Frame *tempSprites = (Frame *)getSegment(data.word(kTempsprites)).ptr(0, 0);
 		showFrame(tempSprites, 72, 2, 45, 0);
 		showFrame(tempSprites, 72+47, 2, 46, 0);
@@ -1719,7 +1747,13 @@ void DreamBase::showIcon() {
 		showFrame(tempSprites, 160+88, 2, 45, 4 & 0xfe);
 		showFrame(tempSprites, 160+43, 2, 46, 4 & 0xfe);
 		showFrame(tempSprites, 160+101, 21, 49, 4 & 0xfe);
-		middlePanel();
+
+		// middle panel
+		showFrame(tempSprites, 72 + 47 + 20, 0, 48, 0);
+		showFrame(tempSprites, 72 + 19, 21, 47, 0);
+		showFrame(tempSprites, 160 + 23, 0, 48, 4);
+		showFrame(tempSprites, 160 + 71, 21, 47, 4);
+*/
 	}
 }
 
@@ -1932,7 +1966,7 @@ void DreamBase::mainScreen() {
 
 void DreamBase::showWatch() {
 	if (data.byte(kWatchon)) {
-		showFrame(engine->icons1(), 250, 1, 6, 0);
+		showFrame(_icons1, 250, 1, 6, 0);
 		showTime();
 	}
 }
@@ -1947,22 +1981,21 @@ void DreamBase::dumpWatch() {
 void DreamBase::showTime() {
 	if (data.byte(kWatchon) == 0)
 		return;
-	Frame *charset = (Frame *)getSegment(data.word(kCharset1)).ptr(0, 0);
 
 	int seconds = data.byte(kSecondcount);
 	int minutes = data.byte(kMinutecount);
 	int hours = data.byte(kHourcount);
 
-	showFrame(charset, 282+5, 21, 91*3+10 + seconds / 10, 0);
-	showFrame(charset, 282+9, 21, 91*3+10 + seconds % 10, 0);
+	showFrame(_charset1, 282+5, 21, 91*3+10 + seconds / 10, 0);
+	showFrame(_charset1, 282+9, 21, 91*3+10 + seconds % 10, 0);
 
-	showFrame(charset, 270+5, 21, 91*3 + minutes / 10, 0);
-	showFrame(charset, 270+11, 21, 91*3 + minutes % 10, 0);
+	showFrame(_charset1, 270+5, 21, 91*3 + minutes / 10, 0);
+	showFrame(_charset1, 270+11, 21, 91*3 + minutes % 10, 0);
 
-	showFrame(charset, 256+5, 21, 91*3 + hours / 10, 0);
-	showFrame(charset, 256+11, 21, 91*3 + hours % 10, 0);
+	showFrame(_charset1, 256+5, 21, 91*3 + hours / 10, 0);
+	showFrame(_charset1, 256+11, 21, 91*3 + hours % 10, 0);
 
-	showFrame(charset, 267+5, 21, 91*3+20, 0);
+	showFrame(_charset1, 267+5, 21, 91*3+20, 0);
 }
 
 void DreamBase::watchCount() {
@@ -1970,7 +2003,7 @@ void DreamBase::watchCount() {
 		return;
 	++data.byte(kTimercount);
 	if (data.byte(kTimercount) == 9) {
-		showFrame((Frame *)getSegment(data.word(kCharset1)).ptr(0, 0), 268+4, 21, 91*3+21, 0);
+		showFrame(_charset1, 268+4, 21, 91*3+21, 0);
 		data.byte(kWatchdump) = 1;
 	} else if (data.byte(kTimercount) == 18) {
 		data.byte(kTimercount) = 0;
@@ -2007,7 +2040,7 @@ void DreamBase::roomName() {
 void DreamBase::zoomIcon() {
 	if (data.byte(kZoomon) == 0)
 		return;
-	showFrame(engine->icons1(), kZoomx, kZoomy-1, 8, 0);
+	showFrame(_icons1, kZoomx, kZoomy-1, 8, 0);
 }
 
 void DreamBase::loadRoom() {
@@ -2032,14 +2065,10 @@ void DreamBase::loadRoom() {
 }
 
 void DreamBase::readSetData() {
-	data.word(kCharset1) = standardLoad("DREAMWEB.C00");
-
-	void *icons1Buffer = standardLoadCPP("DREAMWEB.G00");
-	engine->setIcons1(icons1Buffer);
-	void *icons2Buffer = standardLoadCPP("DREAMWEB.G01");
-	engine->setIcons2(icons2Buffer);
-
-	data.word(kMainsprites) = standardLoad("DREAMWEB.S00");
+	loadGraphicsFile(_charset1, "DREAMWEB.C00");
+	loadGraphicsFile(_icons1, "DREAMWEB.G00");
+	loadGraphicsFile(_icons2, "DREAMWEB.G01");
+	loadGraphicsFile(_mainSprites, "DREAMWEB.S00");
 	loadTextFile(_puzzleText, "DREAMWEB.T80");
 	loadTextFile(_commandText, "DREAMWEB.T84");
 	useCharset1();
@@ -2051,18 +2080,6 @@ void DreamBase::readSetData() {
 	//engine->closeFile();
 }
 
-Frame * DreamBase::tempGraphics() {
-	return (Frame *)getSegment(data.word(kTempgraphics)).ptr(0, 0);
-}
-
-Frame * DreamBase::tempGraphics2() {
-	return (Frame *)getSegment(data.word(kTempgraphics2)).ptr(0, 0);
-}
-
-Frame * DreamBase::tempGraphics3() {
-	return (Frame *)getSegment(data.word(kTempgraphics3)).ptr(0, 0);
-}
-
 void DreamBase::findRoomInLoc() {
 	uint8 x = data.byte(kMapx) / 11;
 	uint8 y = data.byte(kMapy) / 10;
@@ -2123,15 +2140,15 @@ void DreamBase::doLook() {
 }
 
 void DreamBase::useCharset1() {
-	engine->setCurrentCharset((Frame *)getSegment(data.word(kCharset1)).ptr(0, 0));
+	_currentCharset = &_charset1;
 }
 
 void DreamBase::useTempCharset() {
-	engine->setCurrentCharset(engine->tempCharset());
+	_currentCharset = &_tempCharset;
 }
 
 void DreamBase::getRidOfTemp() {
-	deallocateMem(data.word(kTempgraphics));
+	_tempGraphics.clear();
 }
 
 void DreamBase::getRidOfTempText() {
@@ -2139,24 +2156,22 @@ void DreamBase::getRidOfTempText() {
 }
 
 void DreamBase::getRidOfTemp2() {
-	deallocateMem(data.word(kTempgraphics2));
+	_tempGraphics2.clear();
 }
 
 void DreamBase::getRidOfTemp3() {
-	deallocateMem(data.word(kTempgraphics3));
+	_tempGraphics3.clear();
 }
 
 void DreamBase::getRidOfTempCharset() {
-	engine->freeTempCharset();
-}
-
-void DreamBase::getRidOfTempsP() {
-	deallocateMem(data.word(kTempsprites));
+	_tempCharset.clear();
 }
 
 void DreamBase::getRidOfAll() {
 	delete[] _backdropBlocks;
-	deallocateMem(data.word(kSetframes));
+	_backdropBlocks = 0;
+
+	_setFrames.clear();
 	deallocateMem(data.word(kReel1));
 	deallocateMem(data.word(kReel2));
 	deallocateMem(data.word(kReel3));
@@ -2165,7 +2180,7 @@ void DreamBase::getRidOfAll() {
 	deallocateMem(data.word(kSetdesc));
 	deallocateMem(data.word(kBlockdesc));
 	deallocateMem(data.word(kRoomdesc));
-	deallocateMem(data.word(kFreeframes));
+	_freeFrames.clear();
 	deallocateMem(data.word(kFreedesc));
 }
 
@@ -2188,7 +2203,14 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 
 	clearAndLoad(workspace(), 0, len[1], 132*66); // 132*66 = maplen
 	sortOutMap();
-	data.word(kSetframes) = allocateAndLoad(len[2]);
+
+	// TODO: Create function for loading a GraphicsFile from a file segment
+	_setFrames.clear();
+	assert(len[2] >= 2080);
+	engine->readFromFile((uint8 *)_setFrames._frames, 2080);
+	_setFrames._data = new uint8[len[2] - 2080];
+	engine->readFromFile(_setFrames._data, len[2] - 2080);
+
 	if (!skipDat)
 		clearAndLoad(data.word(kSetdat), 255, len[3], kSetdatlen);
 	else
@@ -2196,6 +2218,7 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 	// NB: The skipDat version of this function as called by restoreall
 	// had a 'call bloc' instead of 'call loadseg' for reel1,
 	// but 'bloc' was not defined.
+	// TODO: kReel1/2/3 are also GraphicsFiles?
 	data.word(kReel1) = allocateAndLoad(len[4]);
 	data.word(kReel2) = allocateAndLoad(len[5]);
 	data.word(kReel3) = allocateAndLoad(len[6]);
@@ -2204,7 +2227,14 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 	data.word(kSetdesc) = allocateAndLoad(len[9]);
 	data.word(kBlockdesc) = allocateAndLoad(len[10]);
 	data.word(kRoomdesc) = allocateAndLoad(len[11]);
-	data.word(kFreeframes) = allocateAndLoad(len[12]);
+
+	// TODO: Create function for loading a GraphicsFile from a file segment
+	_freeFrames.clear();
+	assert(len[12] >= 2080);
+	engine->readFromFile((uint8 *)_freeFrames._frames, 2080);
+	_freeFrames._data = new uint8[len[12] - 2080];
+	engine->readFromFile(_freeFrames._data, len[12] - 2080);
+
 	if (!skipDat)
 		clearAndLoad(data.word(kFreedat), 255, len[13], kFreedatlen);
 	else
@@ -2260,10 +2290,10 @@ void DreamBase::showFolder() {
 	if (data.byte(kFolderpage)) {
 		useTempCharset();
 		createPanel2();
-		showFrame(tempGraphics(), 0, 0, 0, 0);
-		showFrame(tempGraphics(), 143, 0, 1, 0);
-		showFrame(tempGraphics(), 0, 92, 2, 0);
-		showFrame(tempGraphics(), 143, 92, 3, 0);
+		showFrame(_tempGraphics, 0, 0, 0, 0);
+		showFrame(_tempGraphics, 143, 0, 1, 0);
+		showFrame(_tempGraphics, 0, 92, 2, 0);
+		showFrame(_tempGraphics, 143, 92, 3, 0);
 		folderExit();
 		if (data.byte(kFolderpage) != 1)
 			showLeftPage();
@@ -2273,21 +2303,21 @@ void DreamBase::showFolder() {
 		underTextLine();
 	} else {
 		createPanel2();
-		showFrame(tempGraphics3(), 143-28, 0, 0, 0);
-		showFrame(tempGraphics3(), 143-28, 92, 1, 0);
+		showFrame(_tempGraphics3, 143-28, 0, 0, 0);
+		showFrame(_tempGraphics3, 143-28, 92, 1, 0);
 		folderExit();
 		underTextLine();
 	}
 }
 
 void DreamBase::showLeftPage() {
-	showFrame(tempGraphics2(), 0, 12, 3, 0);
+	showFrame(_tempGraphics2, 0, 12, 3, 0);
 	uint16 y = 12+5;
 	for (size_t i = 0; i < 9; ++i) {
-		showFrame(tempGraphics2(), 0, y, 4, 0);
+		showFrame(_tempGraphics2, 0, y, 4, 0);
 		y += 16;
 	}
-	showFrame(tempGraphics2(), 0, y, 5, 0);
+	showFrame(_tempGraphics2, 0, y, 5, 0);
 	data.word(kLinespacing) = 8;
 	data.word(kCharshift) = 91;
 	data.byte(kKerning) = 1;
@@ -2314,14 +2344,14 @@ void DreamBase::showLeftPage() {
 }
 
 void DreamBase::showRightPage() {
-	showFrame(tempGraphics2(), 143, 12, 0, 0);
+	showFrame(_tempGraphics2, 143, 12, 0, 0);
 	uint16 y = 12+37;
 	for (size_t i = 0; i < 7; ++i) {
-		showFrame(tempGraphics2(), 143, y, 1, 0);
+		showFrame(_tempGraphics2, 143, y, 1, 0);
 		y += 16;
 	}
 
-	showFrame(tempGraphics2(), 143, y, 2, 0);
+	showFrame(_tempGraphics2, 143, y, 2, 0);
 	data.word(kLinespacing) = 8;
 	data.byte(kKerning) = 1;
 	uint8 pageIndex = data.byte(kFolderpage) - 1;
@@ -2339,14 +2369,14 @@ void DreamBase::showRightPage() {
 }
 
 void DreamBase::showExit() {
-	showFrame(engine->icons1(), 274, 154, 11, 0);
+	showFrame(_icons1, 274, 154, 11, 0);
 }
 
 void DreamBase::showMan() {
-	showFrame(engine->icons1(), 0, 0, 0, 0);
-	showFrame(engine->icons1(), 0, 114, 1, 0);
+	showFrame(_icons1, 0, 0, 0, 0);
+	showFrame(_icons1, 0, 114, 1, 0);
 	if (data.byte(kShadeson))
-		showFrame(engine->icons1(), 28, 25, 2, 0);
+		showFrame(_icons1, 28, 25, 2, 0);
 }
 
 void DreamBase::panelIcons1() {
@@ -2355,14 +2385,14 @@ void DreamBase::panelIcons1() {
 		x = 48;
 	else
 		x = 0;
-	showFrame(engine->icons2(), 204 + x, 4, 2, 0);
+	showFrame(_icons2, 204 + x, 4, 2, 0);
 	if (data.byte(kZoomon) != 1)
-		showFrame(engine->icons1(), 228 + x, 8, 5, 0);
+		showFrame(_icons1, 228 + x, 8, 5, 0);
 	showWatch();
 }
 
 void DreamBase::examIcon() {
-	showFrame(engine->icons2(), 254, 5, 3, 0);
+	showFrame(_icons2, 254, 5, 3, 0);
 }
 
 const uint8 *DreamBase::getTextInFile1(uint16 index) {
@@ -2443,7 +2473,7 @@ void DreamBase::folderHints() {
 }
 
 void DreamBase::folderExit() {
-	showFrame(tempGraphics2(), 296, 178, 6, 0);
+	showFrame(_tempGraphics2, 296, 178, 6, 0);
 }
 
 void DreamBase::loadTravelText() {
@@ -2491,7 +2521,7 @@ void DreamBase::showMenu() {
 	++data.byte(kMenucount);
 	if (data.byte(kMenucount) == 37*2)
 		data.byte(kMenucount) = 0;
-	showFrame(tempGraphics(), kMenux, kMenuy, data.byte(kMenucount) / 2, 0);
+	showFrame(_tempGraphics, kMenux, kMenuy, data.byte(kMenucount) / 2, 0);
 }
 
 void DreamBase::dumpMenu() {
@@ -2507,9 +2537,9 @@ void DreamBase::useMenu() {
 	data.byte(kNewobs) = 0;
 	drawFloor();
 	printSprites();
-	showFrame(tempGraphics2(), kMenux-48, kMenuy-4, 4, 0);
+	showFrame(_tempGraphics2, kMenux-48, kMenuy-4, 4, 0);
 	getUnderMenu();
-	showFrame(tempGraphics2(), kMenux+54, kMenuy+72, 5, 0);
+	showFrame(_tempGraphics2, kMenux+54, kMenuy+72, 5, 0);
 	workToScreenM();
 	data.byte(kGetback) = 0;
 	do {
@@ -2609,19 +2639,19 @@ uint8 DreamBase::nextSymbol(uint8 symbol) {
 }
 
 void DreamBase::showSymbol() {
-	showFrame(tempGraphics(), kSymbolx, kSymboly, 12, 0);
+	showFrame(_tempGraphics, kSymbolx, kSymboly, 12, 0);
 
-	showFrame(tempGraphics(), data.byte(kSymboltopx) + kSymbolx-44, kSymboly+20, data.byte(kSymboltopnum), 32);
+	showFrame(_tempGraphics, data.byte(kSymboltopx) + kSymbolx-44, kSymboly+20, data.byte(kSymboltopnum), 32);
 	uint8 nextTopSymbol = nextSymbol(data.byte(kSymboltopnum));
-	showFrame(tempGraphics(), data.byte(kSymboltopx) + kSymbolx+5, kSymboly+20, nextTopSymbol, 32);
+	showFrame(_tempGraphics, data.byte(kSymboltopx) + kSymbolx+5, kSymboly+20, nextTopSymbol, 32);
 	uint8 nextNextTopSymbol = nextSymbol(nextTopSymbol);
-	showFrame(tempGraphics(), data.byte(kSymboltopx) + kSymbolx+54, kSymboly+20, nextNextTopSymbol, 32);
+	showFrame(_tempGraphics, data.byte(kSymboltopx) + kSymbolx+54, kSymboly+20, nextNextTopSymbol, 32);
 
-	showFrame(tempGraphics(), data.byte(kSymbolbotx) + kSymbolx-44, kSymboly+49, 6 + data.byte(kSymbolbotnum), 32);
+	showFrame(_tempGraphics, data.byte(kSymbolbotx) + kSymbolx-44, kSymboly+49, 6 + data.byte(kSymbolbotnum), 32);
 	uint8 nextBotSymbol = nextSymbol(data.byte(kSymbolbotnum));
-	showFrame(tempGraphics(), data.byte(kSymbolbotx) + kSymbolx+5, kSymboly+49, 6 + nextBotSymbol, 32);
+	showFrame(_tempGraphics, data.byte(kSymbolbotx) + kSymbolx+5, kSymboly+49, 6 + nextBotSymbol, 32);
 	uint8 nextNextBotSymbol = nextSymbol(nextBotSymbol);
-	showFrame(tempGraphics(), data.byte(kSymbolbotx) + kSymbolx+54, kSymboly+49, 6 + nextNextBotSymbol, 32);
+	showFrame(_tempGraphics, data.byte(kSymbolbotx) + kSymbolx+54, kSymboly+49, 6 + nextNextBotSymbol, 32);
 }
 
 void DreamBase::readKey() {
@@ -2961,16 +2991,11 @@ void DreamBase::examineInventory() {
 }
 
 void DreamBase::middlePanel() {
-	Frame *tempSprites = (Frame *)getSegment(data.word(kTempsprites)).ptr(0, 0);
-	showFrame(tempSprites, 72 + 47 + 20, 0, 48, 0);
-	showFrame(tempSprites, 72 + 19, 21, 47, 0);
-	showFrame(tempSprites, 160 + 23, 0, 48, 4);
-	showFrame(tempSprites, 160 + 71, 21, 47, 4);
 }
 
 void DreamBase::showDiary() {
-	showFrame(tempGraphics(), kDiaryx, kDiaryy + 37, 1, 0);
-	showFrame(tempGraphics(), kDiaryx + 176, kDiaryy + 108, 2, 0);
+	showFrame(_tempGraphics, kDiaryx, kDiaryy + 37, 1, 0);
+	showFrame(_tempGraphics, kDiaryx + 176, kDiaryy + 108, 2, 0);
 }
 
 void DreamBase::underTextLine() {
@@ -3166,8 +3191,8 @@ void DreamBase::showGun() {
 	data.byte(kVolume) = 0;
 	loadIntoTemp("DREAMWEB.G13");
 	createPanel2();
-	showFrame(tempGraphics(), 100, 4, 0, 0);
-	showFrame(tempGraphics(), 158, 106, 1, 0);
+	showFrame(_tempGraphics, 100, 4, 0, 0);
+	showFrame(_tempGraphics, 158, 106, 1, 0);
 	workToScreen();
 	getRidOfTemp();
 	fadeScreenUp();
@@ -3511,7 +3536,7 @@ void DreamBase::updateSymbolBot() {
 }
 
 void DreamBase::showDiaryPage() {
-	showFrame(tempGraphics(), kDiaryx, kDiaryy, 0, 0);
+	showFrame(_tempGraphics, kDiaryx, kDiaryy, 0, 0);
 	data.byte(kKerning) = 1;
 	useTempCharset();
 	data.word(kCharshift) = 91+91;
@@ -3558,7 +3583,7 @@ void DreamBase::lookAtCard() {
 	getRidOfReels();
 	loadKeypad();
 	createPanel2();
-	showFrame(tempGraphics(), 160, 80, 42, 128);
+	showFrame(_tempGraphics, 160, 80, 42, 128);
 	const uint8 *obText = getObTextStart();
 	findNextColon(&obText);
 	findNextColon(&obText);
@@ -3568,7 +3593,7 @@ void DreamBase::lookAtCard() {
 	workToScreenM();
 	hangOnW(280);
 	createPanel2();
-	showFrame(tempGraphics(), 160, 80, 42, 128);
+	showFrame(_tempGraphics, 160, 80, 42, 128);
 	printDirect(obText, 36, 130, 241, 241 & 1);
 	workToScreenM();
 	hangOnW(200);
@@ -3614,10 +3639,10 @@ void DreamBase::showDiaryKeys() {
 
 	if (data.byte(kPressed) == 'N') {
 		byte frame = (data.byte(kPresscount) == 1) ? 3 : 4;
-		showFrame(tempGraphics(), kDiaryx + 94, kDiaryy + 97, frame, 0);
+		showFrame(_tempGraphics, kDiaryx + 94, kDiaryy + 97, frame, 0);
 	} else {
 		byte frame = (data.byte(kPresscount) == 1) ? 5 : 6;
-		showFrame(tempGraphics(), kDiaryx + 151, kDiaryy + 71, frame, 0);
+		showFrame(_tempGraphics, kDiaryx + 151, kDiaryy + 71, frame, 0);
 	}
 
 	if (data.byte(kPresscount) == 1)
diff --git a/engines/dreamweb/titles.cpp b/engines/dreamweb/titles.cpp
index ed54c4b..8576fd4 100644
--- a/engines/dreamweb/titles.cpp
+++ b/engines/dreamweb/titles.cpp
@@ -42,7 +42,7 @@ void DreamBase::monkSpeaking() {
 	loadRoomsSample();
 	loadIntoTemp("DREAMWEB.G15");
 	clearWork();
-	showFrame(tempGraphics(), 160, 72, 0, 128);	// show monk
+	showFrame(_tempGraphics, 160, 72, 0, 128);	// show monk
 	workToScreen();
 	data.byte(kVolume) = 7;
 	data.byte(kVolumedirection) = (byte)-1;
diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp
index 1b91cc8..f2dce4d 100644
--- a/engines/dreamweb/use.cpp
+++ b/engines/dreamweb/use.cpp
@@ -1576,7 +1576,7 @@ void DreamBase::useCashCard() {
 	showExit();
 	showMan();
 	uint16 y = (!_foreignRelease) ? 120 : 120 - 3;
-	showFrame(tempGraphics(), 114, y, 39, 0);
+	showFrame(_tempGraphics, 114, y, 39, 0);
 	const uint8 *obText = getObTextStart();
 	findNextColon(&obText);
 	findNextColon(&obText);
diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp
index f611a79..19abc2b 100644
--- a/engines/dreamweb/vgagrafx.cpp
+++ b/engines/dreamweb/vgagrafx.cpp
@@ -273,29 +273,17 @@ void DreamBase::showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 fra
 	showFrame(frameData, x, y, frameNumber, effectsFlag, &width, &height);
 }
 
-void DreamBase::showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) {
-	const Frame *frame = frameData + frameNumber;
-	if ((frame->width == 0) && (frame->height == 0)) {
-		*width = 0;
-		*height = 0;
-		return;
-	}
 
-	// "notBlankShow"
-	if ((effectsFlag & 128) == 0) {
-		x += frame->x;
-		y += frame->y;
-	}
-
-	// "skipOffsets"
-	*width = frame->width;
-	*height = frame->height;
-	const uint8 *pSrc = ((const uint8 *)frameData) + frame->ptr() + 2080;
+void DreamBase::showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag) {
+	uint8 width, height;
+	showFrame(frameData, x, y, frameNumber, effectsFlag, &width, &height);
+}
 
+void DreamBase::showFrameInternal(const uint8 *pSrc, uint16 x, uint16 y, uint8 effectsFlag, uint8 width, uint8 height) {
 	if (effectsFlag) {
 		if (effectsFlag & 128) { //centred
-			x -= *width / 2;
-			y -= *height / 2;
+			x -= width / 2;
+			y -= height / 2;
 		}
 		if (effectsFlag & 64) { // diffDest
 			error("Unsupported DreamBase::showFrame effectsFlag %d", effectsFlag);
@@ -308,21 +296,64 @@ void DreamBase::showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 fra
 			//addToPrintList(x - data.word(kMapadx), y - data.word(kMapady)); // NB: Commented in the original asm
 		}
 		if (effectsFlag & 4) { // flippedX
-			frameOutFx(workspace(), pSrc, 320, *width, *height, x, y);
+			frameOutFx(workspace(), pSrc, 320, width, height, x, y);
 			return;
 		}
 		if (effectsFlag & 2) { // noMask
-			frameOutNm(workspace(), pSrc, 320, *width, *height, x, y);
+			frameOutNm(workspace(), pSrc, 320, width, height, x, y);
 			return;
 		}
 		if (effectsFlag & 32) {
-			frameOutBh(workspace(), pSrc, 320, *width, *height, x, y);
+			frameOutBh(workspace(), pSrc, 320, width, height, x, y);
 			return;
 		}
 	}
 	// "noEffects"
-	frameOutV(workspace(), pSrc, 320, *width, *height, x, y);
-	return;
+	frameOutV(workspace(), pSrc, 320, width, height, x, y);
+}
+
+void DreamBase::showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) {
+	const Frame *frame = frameData + frameNumber;
+	if ((frame->width == 0) && (frame->height == 0)) {
+		*width = 0;
+		*height = 0;
+		return;
+	}
+
+	// "notBlankShow"
+	if ((effectsFlag & 128) == 0) {
+		x += frame->x;
+		y += frame->y;
+	}
+
+	// "skipOffsets"
+	*width = frame->width;
+	*height = frame->height;
+	const uint8 *pSrc = ((const uint8 *)frameData) + frame->ptr() + 2080;
+
+	showFrameInternal(pSrc, x, y, effectsFlag, *width, *height);
+}
+
+void DreamBase::showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) {
+	const Frame *frame = &frameData._frames[frameNumber];
+	if ((frame->width == 0) && (frame->height == 0)) {
+		*width = 0;
+		*height = 0;
+		return;
+	}
+
+	// "notBlankShow"
+	if ((effectsFlag & 128) == 0) {
+		x += frame->x;
+		y += frame->y;
+	}
+
+	// "skipOffsets"
+	*width = frame->width;
+	*height = frame->height;
+	const uint8 *pSrc = frameData.getFrameData(frameNumber);
+
+	showFrameInternal(pSrc, x, y, effectsFlag, *width, *height);
 }
 
 void DreamBase::clearWork() {
@@ -373,8 +404,8 @@ bool DreamBase::pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y) {
 	x -= pos->xMin;
 	y -= pos->yMin;
 	SetObject *setObject = getSetAd(pos->index);
-	Frame *frame = (Frame *)getSegment(data.word(kSetframes)).ptr(kFramedata, 0) + setObject->index;
-	const uint8 *ptr = getSegment(data.word(kSetframes)).ptr(kFrames, 0) + frame->ptr() + y * frame->width + x;
+	const Frame &frame = _setFrames._frames[setObject->index];
+	const uint8 *ptr = _setFrames.getFrameData(setObject->index) + y * frame.width + x;
 	return *ptr != 0;
 }
 
@@ -403,26 +434,25 @@ void DreamBase::loadPalFromIFF() {
 }
 
 void DreamBase::createPanel() {
-	showFrame(engine->icons2(), 0, 8, 0, 2);
-	showFrame(engine->icons2(), 160, 8, 0, 2);
-	showFrame(engine->icons2(), 0, 104, 0, 2);
-	showFrame(engine->icons2(), 160, 104, 0, 2);
+	showFrame(_icons2, 0, 8, 0, 2);
+	showFrame(_icons2, 160, 8, 0, 2);
+	showFrame(_icons2, 0, 104, 0, 2);
+	showFrame(_icons2, 160, 104, 0, 2);
 }
 
 void DreamBase::createPanel2() {
 	createPanel();
-	showFrame(engine->icons2(), 0, 0, 5, 2);
-	showFrame(engine->icons2(), 160, 0, 5, 2);
+	showFrame(_icons2, 0, 0, 5, 2);
+	showFrame(_icons2, 160, 0, 5, 2);
 }
 
 void DreamBase::showPanel() {
-	showFrame(engine->icons1(), 72, 0, 19, 0);
-	showFrame(engine->icons1(), 192, 0, 19, 0);
+	showFrame(_icons1, 72, 0, 19, 0);
+	showFrame(_icons1, 192, 0, 19, 0);
 }
 
 void DreamBase::transferFrame(uint8 from, uint8 to, uint8 offset) {
-	const Frame *freeFrames = (const Frame *)getSegment(data.word(kFreeframes)).ptr(kFrframedata, 0);
-	const Frame &freeFrame = freeFrames[3*from + offset];
+	const Frame &freeFrame = _freeFrames._frames[3*from + offset];
 
 	Frame *exFrames = (Frame *)getSegment(data.word(kExtras)).ptr(kExframedata, 0);
 	Frame &exFrame = exFrames[3*to + offset];
@@ -433,7 +463,7 @@ void DreamBase::transferFrame(uint8 from, uint8 to, uint8 offset) {
 	exFrame.y = freeFrame.y;
 	uint16 byteCount = freeFrame.width * freeFrame.height;
 
-	const uint8 *src = getSegment(data.word(kFreeframes)).ptr(kFrframes + freeFrame.ptr(), byteCount);
+	const uint8 *src = _freeFrames.getFrameData(3*from + offset);
 	uint8 *dst = getSegment(data.word(kExtras)).ptr(kExframes + data.word(kExframepos), byteCount);
 	memcpy(dst, src, byteCount);
 


Commit: e54196f37fbf918976f834680671c12bfce58d23
    https://github.com/scummvm/scummvm/commit/e54196f37fbf918976f834680671c12bfce58d23
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T14:02:33-08:00

Commit Message:
DREAMWEB: Remove Extras segment

Changed paths:
    devtools/tasmrecover/tasm-recover
    engines/dreamweb/backdrop.cpp
    engines/dreamweb/dreambase.h
    engines/dreamweb/dreamgen.cpp
    engines/dreamweb/dreamgen.h
    engines/dreamweb/object.cpp
    engines/dreamweb/saveload.cpp
    engines/dreamweb/stubs.cpp
    engines/dreamweb/vgagrafx.cpp



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index bf0a2c0..7e636eb 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -255,6 +255,7 @@ p = parser(skip_binary_data = [
 	'tempgraphics3',
 	'tempsprites',
 	'charset1',
+	'extras',
 	# vars.asm - constants
 	'openinvlist',
 	'ryaninvlist',
diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp
index 0dface9..e6f5e9a 100644
--- a/engines/dreamweb/backdrop.cpp
+++ b/engines/dreamweb/backdrop.cpp
@@ -259,8 +259,8 @@ void DreamBase::showAllEx() {
 
 	_exList.clear();
 
-	DynObject *objects = (DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, sizeof(DynObject));
-	const Frame *frameBase = (const Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
+	DynObject *objects = _exData;
+	const GraphicsFile &frameBase = _exFrames;
 	for (size_t i = 0; i < count; ++i) {
 		DynObject *object = objects + i;
 		if (object->mapad[0] == 0xff)
@@ -273,7 +273,7 @@ void DreamBase::showAllEx() {
 		uint8 width, height;
 		ObjPos objPos;
 		uint16 currentFrame = 3 * i;
-		calcFrFrame(frameBase[currentFrame], &width, &height, x, y, &objPos);
+		calcFrFrame(frameBase._frames[currentFrame], &width, &height, x, y, &objPos);
 		if ((width != 0) || (height != 0)) {
 			assert(currentFrame < 256);
 			showFrame(frameBase, x + data.word(kMapadx), y + data.word(kMapady), currentFrame, 0);
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 8dd8083..d07e74d 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -51,6 +51,7 @@ const unsigned int kLenOfMapStore = 22*8*20*8;
 const unsigned int kMapWidth = 66;
 const unsigned int kMapHeight = 60;
 const unsigned int kLengthOfMap = kMapWidth * kMapHeight;
+const unsigned int kNumExObjects = 114;
 
 /**
  * This class is one of the parent classes of DreamGenContext. Its sole purpose
@@ -146,6 +147,12 @@ protected:
 	GraphicsFile _setFrames;
 	GraphicsFile _freeFrames;
 
+	// Extras segment (NB: this is saved)
+	GraphicsFile _exFrames;
+	DynObject _exData[kNumExObjects];
+	uint16 _exTextdatLE[kNumExObjects+2]; // TODO: Convert into TextFile
+	char _exText[18000];
+
 public:
 	DreamBase(DreamWeb::DreamWebEngine *en);
 
@@ -845,10 +852,10 @@ public:
 	void setMode();
 	void showPCX(const Common::String &name);
 	void showFrameInternal(const uint8 *pSrc, uint16 x, uint16 y, uint8 effectsFlag, uint8 width, uint8 height);
-	void showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height);
-	void showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag);
 	void showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height);
 	void showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag);
+	void showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height);
+	void showFrame(const GraphicsFile &frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag);
 	bool pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y);
 	void loadPalFromIFF();
 	void createPanel();
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 4378841..401140e 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -65,13 +65,13 @@ void DreamGenContext::__start() {
 		//0x0100: .... .... .... ....
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0110: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
+		0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
 		//0x0120: .... .... .... ....
-		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 
+		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0130: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 
 		//0x0140: .... .... .... ....
-		0x00, 0xff, };
+		};
 	ds.assign(src, src + sizeof(src));
 	dreamweb(); 
 }
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 41b3010..6738007 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -249,42 +249,41 @@ static const uint16 kWongame = 274;
 static const uint16 kLasthardkey = 275;
 static const uint16 kBufferin = 276;
 static const uint16 kBufferout = 278;
-static const uint16 kExtras = 280;
-static const uint16 kWorkspace = 282;
-static const uint16 kMainsprites = 284;
-static const uint16 kBackdrop = 286;
-static const uint16 kRecordspace = 288;
-static const uint16 kFreedat = 290;
-static const uint16 kSetdat = 292;
-static const uint16 kReel1 = 294;
-static const uint16 kReel2 = 296;
-static const uint16 kReel3 = 298;
-static const uint16 kRoomdesc = 300;
-static const uint16 kFreedesc = 302;
-static const uint16 kSetdesc = 304;
-static const uint16 kBlockdesc = 306;
-static const uint16 kSetframes = 308;
-static const uint16 kFreeframes = 310;
-static const uint16 kPeople = 312;
-static const uint16 kReels = 314;
-static const uint16 kBlinkframe = 316;
-static const uint16 kBlinkcount = 317;
-static const uint16 kReasseschanges = 318;
-static const uint16 kPointerspath = 319;
-static const uint16 kManspath = 320;
-static const uint16 kPointerfirstpath = 321;
-static const uint16 kFinaldest = 322;
-static const uint16 kDestination = 323;
-static const uint16 kLinestartx = 324;
-static const uint16 kLinestarty = 326;
-static const uint16 kLineendx = 328;
-static const uint16 kLineendy = 330;
-static const uint16 kLinepointer = 332;
-static const uint16 kLinedirection = 333;
-static const uint16 kLinelength = 334;
-static const uint16 kCh0playing = 335;
-static const uint16 kCh0repeat = 336;
-static const uint16 kCh1playing = 337;
+static const uint16 kWorkspace = 280;
+static const uint16 kMainsprites = 282;
+static const uint16 kBackdrop = 284;
+static const uint16 kRecordspace = 286;
+static const uint16 kFreedat = 288;
+static const uint16 kSetdat = 290;
+static const uint16 kReel1 = 292;
+static const uint16 kReel2 = 294;
+static const uint16 kReel3 = 296;
+static const uint16 kRoomdesc = 298;
+static const uint16 kFreedesc = 300;
+static const uint16 kSetdesc = 302;
+static const uint16 kBlockdesc = 304;
+static const uint16 kSetframes = 306;
+static const uint16 kFreeframes = 308;
+static const uint16 kPeople = 310;
+static const uint16 kReels = 312;
+static const uint16 kBlinkframe = 314;
+static const uint16 kBlinkcount = 315;
+static const uint16 kReasseschanges = 316;
+static const uint16 kPointerspath = 317;
+static const uint16 kManspath = 318;
+static const uint16 kPointerfirstpath = 319;
+static const uint16 kFinaldest = 320;
+static const uint16 kDestination = 321;
+static const uint16 kLinestartx = 322;
+static const uint16 kLinestarty = 324;
+static const uint16 kLineendx = 326;
+static const uint16 kLineendy = 328;
+static const uint16 kLinepointer = 330;
+static const uint16 kLinedirection = 331;
+static const uint16 kLinelength = 332;
+static const uint16 kCh0playing = 333;
+static const uint16 kCh0repeat = 334;
+static const uint16 kCh1playing = 335;
 static const uint16 kBlocktextdat = (0);
 static const uint16 kPersonframes = (0);
 static const uint16 kDebuglevel1 = (0);
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index 4f9d091..3054a61 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -83,12 +83,11 @@ void DreamBase::obToInv(uint8 index, uint8 flag, uint16 x, uint16 y) {
 	if (index == 0xff)
 		return;
 
-	if (flag == kExObjectType) {
-		Frame *extras = (Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
-		showFrame(extras, x + 18, y + 19, 3 * index + 1, 128);
-	} else {
+	if (flag == kExObjectType)
+		showFrame(_exFrames, x + 18, y + 19, 3 * index + 1, 128);
+	else
 		showFrame(_freeFrames, x + 18, y + 19, 3 * index + 1, 128);
-	}
+
 	const DynObject *object = (const DynObject *)getAnyAdDir(index, flag);
 	bool worn = isItWorn(object);
 	if (worn)
@@ -99,12 +98,10 @@ void DreamBase::obPicture() {
 	if (data.byte(kObjecttype) == kSetObjectType1)
 		return;
 	uint8 frame = 3 * data.byte(kCommand) + 1;
-	if (data.byte(kObjecttype) == kExObjectType) {
-		const Frame *frames = (const Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
-		showFrame(frames, 160, 68, frame, 0x80);
-	} else {
+	if (data.byte(kObjecttype) == kExObjectType)
+		showFrame(_exFrames, 160, 68, frame, 0x80);
+	else
 		showFrame(_freeFrames, 160, 68, frame, 0x80);
-	}
 }
 
 void DreamBase::obIcons() {
@@ -254,12 +251,12 @@ void DreamBase::inventory() {
 }
 
 void DreamBase::transferText(uint8 from, uint8 to) {
-	getSegment(data.word(kExtras)).word(kExtextdat + 2*to) = data.word(kExtextpos);
+	WRITE_LE_UINT16(&_exTextdatLE[to], data.word(kExtextpos));
 	uint16 freeTextOffset = 2*from;
 	uint16 srcOffset = getSegment(data.word(kFreedesc)).word(kFreetextdat + freeTextOffset);
 
 	const char *src = (const char *)getSegment(data.word(kFreedesc)).ptr(kFreetext + srcOffset, 0);
-	char *dst = (char *)getSegment(data.word(kExtras)).ptr(kExtext + data.word(kExtextpos), 0);
+	char *dst = _exText + data.word(kExtextpos);
 
 	size_t len = strlen(src);
 	memcpy(dst, src, len + 1);
@@ -429,47 +426,47 @@ void DreamBase::setPickup() {
 }
 
 void DreamBase::deleteExFrame(uint8 frameNum) {
-	Frame *frame = (Frame *)getSegment(data.word(kExtras)).ptr(kExframedata + sizeof(Frame)*frameNum, sizeof(Frame));
+	Frame *frame = &_exFrames._frames[frameNum];
 
 	uint16 frameSize = frame->width * frame->height;
 	// Note: the original asm didn't subtract frameSize from remainder
 	uint16 remainder = kExframeslen - frame->ptr() - frameSize;
-	uint16 startOff = kExframes + frame->ptr();
+	uint16 startOff = frame->ptr();
 	uint16 endOff = startOff + frameSize;
 
 	// Shift frame data after this one down
-	memmove(getSegment(data.word(kExtras)).ptr(startOff, remainder), getSegment(data.word(kExtras)).ptr(endOff, remainder), remainder);
+	memmove(&_exFrames._data[startOff], &_exFrames._data[endOff], remainder);
 
 	// Combined frame data is now frameSize smaller
 	data.word(kExframepos) -= frameSize;
 
 	// Adjust all frame pointers pointing into the shifted data
 	for (unsigned int i = 0; i < 3*kNumexobjects; ++i) {
-		frame = (Frame *)getSegment(data.word(kExtras)).ptr(kExframedata + sizeof(Frame)*i, sizeof(Frame));
+		frame = &_exFrames._frames[i];
 		if (frame->ptr() >= startOff)
 			frame->setPtr(frame->ptr() - frameSize);
 	}
 }
 
 void DreamBase::deleteExText(uint8 textNum) {
-	uint16 offset = getSegment(data.word(kExtras)).word(kExtextdat + 2*textNum);
+	uint16 offset = READ_LE_UINT16(&_exTextdatLE[textNum]);
 
-	uint16 startOff = kExtext + offset;
-	uint16 textSize = strlen((char *)getSegment(data.word(kExtras)).ptr(startOff, 0)) + 1;
+	uint16 startOff = offset;
+	uint16 textSize = strlen(&_exText[startOff]) + 1;
 	uint16 endOff = startOff + textSize;
 	uint16 remainder = kExtextlen - offset - textSize;
 
 	// Shift text data after this one down
-	memmove(getSegment(data.word(kExtras)).ptr(startOff, remainder), getSegment(data.word(kExtras)).ptr(endOff, remainder), remainder);
+	memmove(&_exText[startOff], &_exText[endOff], remainder);
 
 	// Combined text data is now frameSize smaller
 	data.word(kExtextpos) -= textSize;
 
 	// Adjust all text pointers pointing into the shifted data
 	for (unsigned int i = 0; i < kNumexobjects; ++i) {
-		uint16 t = getSegment(data.word(kExtras)).word(kExtextdat + 2*i);
+		uint16 t = READ_LE_UINT16(&_exTextdatLE[i]);
 		if (t >= offset + textSize)
-			getSegment(data.word(kExtras)).word(kExtextdat + 2*i) = t - textSize;
+			WRITE_LE_UINT16(&_exTextdatLE[i], t - textSize);
 	}
 }
 
@@ -591,22 +588,26 @@ void DreamBase::purgeALocation(uint8 index) {
 }
 
 const uint8 *DreamBase::getObTextStart() {
-	uint16 textSeg, textDatOff, textOff;
+	const uint8 *textBase;
+	const uint8 *text;
+	uint16 textOff;
 	if (data.byte(kObjecttype) == kFreeObjectType) {
-		textSeg = data.word(kFreedesc);
-		textDatOff = kFreetextdat;
+		uint16 textSeg = data.word(kFreedesc);
+		uint16 textDatOff = kFreetextdat;
 		textOff = kFreetext;
+		textBase = getSegment(textSeg).ptr(textOff, 0);
+		text = textBase + getSegment(textSeg).word(textDatOff + 2*data.byte(kCommand));
 	} else if (data.byte(kObjecttype) == kSetObjectType1) {
-		textSeg = data.word(kSetdesc);
-		textDatOff = kSettextdat;
+		uint16 textSeg = data.word(kSetdesc);
+		uint16 textDatOff = kSettextdat;
 		textOff = kSettext;
+		textBase = getSegment(textSeg).ptr(textOff, 0);
+		text = textBase + getSegment(textSeg).word(textDatOff + 2*data.byte(kCommand));
 	} else {
-		textSeg = data.word(kExtras);
-		textDatOff = kExtextdat;
+		textBase = (const uint8 *)_exText;
 		textOff = kExtext;
+		text = textBase + READ_LE_UINT16(&_exTextdatLE[data.byte(kCommand)]);
 	}
-	const uint8 *textBase = getSegment(textSeg).ptr(textOff, 0);
-	const uint8 *text = textBase + getSegment(textSeg).word(textDatOff + 2*data.byte(kCommand));
 
 	if (data.byte(kObjecttype) != kSetObjectType1)
 		return text;
@@ -635,6 +636,7 @@ const uint8 *DreamBase::getObTextStart() {
 				text++;
 
 				// arbitrary give-up counter
+				// FIXME: Make this more precise to avoid reading out of bounds
 				if (text - (textBase - textOff) >= 8000) {
 					warning("Object description for %d/%d not found", data.byte(kObjecttype), data.byte(kCommand));
 					return obname;
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index 843bee7..2c659c4 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -476,7 +476,14 @@ void DreamBase::savePosition(unsigned int slot, const char *descbuf) {
 	outSaveFile->write((const uint8 *)&header, sizeof(FileHeader));
 	outSaveFile->write(descbuf, len[0]);
 	outSaveFile->write(data.ptr(kStartvars, len[1]), len[1]);
-	outSaveFile->write(getSegment(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]);
+
+	// the Extras segment:
+	outSaveFile->write((const uint8 *)_exFrames._frames, 2080);
+	outSaveFile->write((const uint8 *)_exFrames._data, kExframeslen);
+	outSaveFile->write((const uint8 *)_exData, sizeof(DynObject)*kNumexobjects);
+	outSaveFile->write((const uint8 *)_exTextdatLE, 2*(kNumExObjects+2));
+	outSaveFile->write((const uint8 *)_exText, kExtextlen);
+
 	outSaveFile->write(_listOfChanges, len[3]);
 
 	// len[4] == 48, which is sizeof(Room) plus 16 for 'Roomscango'
@@ -542,7 +549,14 @@ void DreamBase::loadPosition(unsigned int slot) {
 		inSaveFile->read(namebuf, 17);
 	}
 	inSaveFile->read(data.ptr(kStartvars, len[1]), len[1]);
-	inSaveFile->read(getSegment(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]);
+
+	// the Extras segment:
+	inSaveFile->read((uint8 *)_exFrames._frames, 2080);
+	inSaveFile->read((uint8 *)_exFrames._data, kExframeslen);
+	inSaveFile->read((uint8 *)_exData, sizeof(DynObject)*kNumexobjects);
+	inSaveFile->read((uint8 *)_exTextdatLE, 2*(kNumExObjects+2));
+	inSaveFile->read((uint8 *)_exText, kExtextlen);
+
 	inSaveFile->read(_listOfChanges, len[3]);
 
 	// len[4] == 48, which is sizeof(Room) plus 16 for 'Roomscango'
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 9ef7dda..084aa76 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -650,6 +650,10 @@ done: // The engine will need some cleaner finalization, let's put it here for n
 	_tempCharset.clear();
 	_mainSprites.clear();
 
+	_exFrames.clear();
+	_setFrames.clear();
+	_freeFrames.clear();
+
 	_textFile1.clear();
 	_textFile2.clear();
 	_textFile3.clear();
@@ -1226,8 +1230,8 @@ const uint8 *DreamBase::findObName(uint8 type, uint8 index) {
 		uint16 offset = getSegment(data.word(kPeople)).word(kPersontxtdat + i) + kPersontext;
 		return getSegment(data.word(kPeople)).ptr(offset, 0);
 	} else if (type == 4) {
-		uint16 offset = getSegment(data.word(kExtras)).word(kExtextdat + index * 2) + kExtext;
-		return getSegment(data.word(kExtras)).ptr(offset, 0);
+		uint16 offset = READ_LE_UINT16(&_exTextdatLE[index]);
+		return (const uint8 *)_exText + offset;
 	} else if (type == 2) {
 		uint16 offset = getSegment(data.word(kFreedesc)).word(kFreetextdat + index * 2) + kFreetext;
 		return getSegment(data.word(kFreedesc)).ptr(offset, 0);
@@ -1313,7 +1317,7 @@ DynObject *DreamBase::getFreeAd(uint8 index) {
 }
 
 DynObject *DreamBase::getExAd(uint8 index) {
-	return (DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, 0) + index;
+	return &_exData[index];
 }
 
 DynObject *DreamBase::getEitherAdCPP() {
@@ -1374,7 +1378,7 @@ void DreamBase::doChange(uint8 index, uint8 value, uint8 type) {
 }
 
 void DreamBase::deleteTaken() {
-	const DynObject *extraObjects = (const DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, 0);
+	const DynObject *extraObjects = _exData;
 	DynObject *freeObjects = (DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0);
 	for (size_t i = 0; i < kNumexobjects; ++i) {
 		uint8 location = extraObjects[i].initialLocation;
@@ -1386,7 +1390,7 @@ void DreamBase::deleteTaken() {
 }
 
 uint8 DreamBase::getExPos() {
-	DynObject *objects = (DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, sizeof(DynObject));
+	DynObject *objects = _exData;
 	for (size_t i = 0; i < kNumexobjects; ++i) {
 		if (objects[i].mapad[0] == 0xff)
 			return i;
@@ -1565,13 +1569,13 @@ void DreamBase::showPointer() {
 	uint16 y = data.word(kMousey);
 	data.word(kOldpointery) = data.word(kMousey);
 	if (data.byte(kPickup) == 1) {
-		const Frame *frame;
-		if (data.byte(kObjecttype) != kExObjectType) {
-			frame = &_freeFrames._frames[(3 * data.byte(kItemframe) + 1)];
-		} else {
-			const Frame *frames = (const Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
-			frame = frames + (3 * data.byte(kItemframe) + 1);
-		}
+		const GraphicsFile *frames;
+		if (data.byte(kObjecttype) != kExObjectType)
+			frames = &_freeFrames;
+		else
+			frames = &_exFrames;
+		const Frame *frame = &frames->_frames[(3 * data.byte(kItemframe) + 1)];
+
 		uint8 width = frame->width;
 		uint8 height = frame->height;
 		if (width < 12)
@@ -1585,12 +1589,7 @@ void DreamBase::showPointer() {
 		data.word(kOldpointerx) = xMin;
 		data.word(kOldpointery) = yMin;
 		multiGet(_pointerBack, xMin, yMin, width, height);
-		if (data.byte(kObjecttype) != kExObjectType) {
-			showFrame(_freeFrames, x, y, 3 * data.byte(kItemframe) + 1, 128);
-		} else {
-			const Frame *frames = (const Frame *)getSegment(data.word(kExtras)).ptr(0, 0);
-			showFrame(frames, x, y, 3 * data.byte(kItemframe) + 1, 128);
-		}
+		showFrame(*frames, x, y, 3 * data.byte(kItemframe) + 1, 128);
 		showFrame(_icons1, x, y, 3, 128);
 	} else {
 		const Frame *frame = &_icons1._frames[data.byte(kPointerframe) + 20];
@@ -2498,7 +2497,8 @@ void DreamBase::drawFloor() {
 }
 
 void DreamBase::allocateBuffers() {
-	data.word(kExtras) = allocateMem(kLengthofextra/16);
+	_exFrames.clear();
+	_exFrames._data = new uint8[kExframeslen];
 	data.word(kFreedat) = allocateMem(kFreedatlen/16);
 	data.word(kSetdat) = allocateMem(kSetdatlen/16);
 }
@@ -3604,8 +3604,6 @@ void DreamBase::lookAtCard() {
 }
 
 void DreamBase::clearBuffers() {
-	memset(getSegment(data.word(kExtras)).ptr(0, kLengthofextra), 0xFF, kLengthofextra);
-
 	memcpy(_initialVars, data.ptr(kStartvars, kLengthofvars), kLengthofvars);
 
 	clearChanges();
@@ -3621,7 +3619,11 @@ void DreamBase::clearChanges() {
 	data.word(kExframepos) = 0;
 	data.word(kExtextpos) = 0;
 
-	memset(getSegment(data.word(kExtras)).ptr(0, kLengthofextra), 0xFF, kLengthofextra);
+	memset(_exFrames._frames, 0xFF, 2080);
+	memset(_exFrames._data, 0xFF, kExframeslen);
+	memset(_exData, 0xFF, sizeof(DynObject) * kNumexobjects);
+	memset(_exTextdatLE, 0xFF, 2*(kNumexobjects+2));
+	memset(_exText, 0xFF, kExtextlen);
 
 	const uint8 initialRoomsCanGo[] = { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 
@@ -3710,7 +3712,7 @@ void DreamBase::emergencyPurge() {
 }
 
 void DreamBase::purgeAnItem() {
-	const DynObject *extraObjects = (const DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, 0);
+	const DynObject *extraObjects = _exData;
 
 	for (size_t i = 0; i < kNumexobjects; ++i) {
 		if (extraObjects[i].mapad[0] && extraObjects[i].id[0] == 255 &&
diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp
index 19abc2b..417ccce 100644
--- a/engines/dreamweb/vgagrafx.cpp
+++ b/engines/dreamweb/vgagrafx.cpp
@@ -453,9 +453,7 @@ void DreamBase::showPanel() {
 
 void DreamBase::transferFrame(uint8 from, uint8 to, uint8 offset) {
 	const Frame &freeFrame = _freeFrames._frames[3*from + offset];
-
-	Frame *exFrames = (Frame *)getSegment(data.word(kExtras)).ptr(kExframedata, 0);
-	Frame &exFrame = exFrames[3*to + offset];
+	Frame &exFrame = _exFrames._frames[3*to + offset];
 
 	exFrame.width = freeFrame.width;
 	exFrame.height = freeFrame.height;
@@ -464,7 +462,7 @@ void DreamBase::transferFrame(uint8 from, uint8 to, uint8 offset) {
 	uint16 byteCount = freeFrame.width * freeFrame.height;
 
 	const uint8 *src = _freeFrames.getFrameData(3*from + offset);
-	uint8 *dst = getSegment(data.word(kExtras)).ptr(kExframes + data.word(kExframepos), byteCount);
+	uint8 *dst = _exFrames._data + data.word(kExframepos);
 	memcpy(dst, src, byteCount);
 
 	exFrame.setPtr(data.word(kExframepos));


Commit: f729742f87648d6a5ebc1468e26e90ac1de1c2e0
    https://github.com/scummvm/scummvm/commit/f729742f87648d6a5ebc1468e26e90ac1de1c2e0
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T14:02:33-08:00

Commit Message:
DREAMWEB: Convert exText into TextFile

Changed paths:
    engines/dreamweb/dreambase.h
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/object.cpp
    engines/dreamweb/saveload.cpp
    engines/dreamweb/structs.h
    engines/dreamweb/stubs.cpp



diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index d07e74d..88dc96e 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -150,8 +150,7 @@ protected:
 	// Extras segment (NB: this is saved)
 	GraphicsFile _exFrames;
 	DynObject _exData[kNumExObjects];
-	uint16 _exTextdatLE[kNumExObjects+2]; // TODO: Convert into TextFile
-	char _exText[18000];
+	TextFile _exText;
 
 public:
 	DreamBase(DreamWeb::DreamWebEngine *en);
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index b31a851..1019aba 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -407,7 +407,7 @@ uint8 DreamWebEngine::modifyChar(uint8 c) const {
 namespace DreamGen {
 
 // FIXME/TODO: Move this to a better place.
-DreamBase::DreamBase(DreamWeb::DreamWebEngine *en) : engine(en) {
+DreamBase::DreamBase(DreamWeb::DreamWebEngine *en) : engine(en), _exText(kNumExObjects+2) {
 	_openChangeSize = kInventx+(4*kItempicsize);
 	_quitRequested = false;
 
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index 3054a61..c78ec71 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -251,12 +251,12 @@ void DreamBase::inventory() {
 }
 
 void DreamBase::transferText(uint8 from, uint8 to) {
-	WRITE_LE_UINT16(&_exTextdatLE[to], data.word(kExtextpos));
+	_exText.setOffset(to, data.word(kExtextpos));
 	uint16 freeTextOffset = 2*from;
 	uint16 srcOffset = getSegment(data.word(kFreedesc)).word(kFreetextdat + freeTextOffset);
 
 	const char *src = (const char *)getSegment(data.word(kFreedesc)).ptr(kFreetext + srcOffset, 0);
-	char *dst = _exText + data.word(kExtextpos);
+	char *dst = _exText._text + data.word(kExtextpos);
 
 	size_t len = strlen(src);
 	memcpy(dst, src, len + 1);
@@ -449,24 +449,24 @@ void DreamBase::deleteExFrame(uint8 frameNum) {
 }
 
 void DreamBase::deleteExText(uint8 textNum) {
-	uint16 offset = READ_LE_UINT16(&_exTextdatLE[textNum]);
+	uint16 offset = _exText.getOffset(textNum);
 
 	uint16 startOff = offset;
-	uint16 textSize = strlen(&_exText[startOff]) + 1;
+	uint16 textSize = strlen(_exText.getString(textNum)) + 1;
 	uint16 endOff = startOff + textSize;
 	uint16 remainder = kExtextlen - offset - textSize;
 
 	// Shift text data after this one down
-	memmove(&_exText[startOff], &_exText[endOff], remainder);
+	memmove(&_exText._text[startOff], &_exText._text[endOff], remainder);
 
 	// Combined text data is now frameSize smaller
 	data.word(kExtextpos) -= textSize;
 
 	// Adjust all text pointers pointing into the shifted data
 	for (unsigned int i = 0; i < kNumexobjects; ++i) {
-		uint16 t = READ_LE_UINT16(&_exTextdatLE[i]);
+		uint16 t = _exText.getOffset(i);
 		if (t >= offset + textSize)
-			WRITE_LE_UINT16(&_exTextdatLE[i], t - textSize);
+			_exText.setOffset(i, t - textSize);
 	}
 }
 
@@ -604,9 +604,9 @@ const uint8 *DreamBase::getObTextStart() {
 		textBase = getSegment(textSeg).ptr(textOff, 0);
 		text = textBase + getSegment(textSeg).word(textDatOff + 2*data.byte(kCommand));
 	} else {
-		textBase = (const uint8 *)_exText;
+		textBase = (const uint8 *)_exText._text;
 		textOff = kExtext;
-		text = textBase + READ_LE_UINT16(&_exTextdatLE[data.byte(kCommand)]);
+		text = (const uint8 *)_exText.getString(data.byte(kCommand));
 	}
 
 	if (data.byte(kObjecttype) != kSetObjectType1)
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index 2c659c4..e2af04d 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -481,8 +481,8 @@ void DreamBase::savePosition(unsigned int slot, const char *descbuf) {
 	outSaveFile->write((const uint8 *)_exFrames._frames, 2080);
 	outSaveFile->write((const uint8 *)_exFrames._data, kExframeslen);
 	outSaveFile->write((const uint8 *)_exData, sizeof(DynObject)*kNumexobjects);
-	outSaveFile->write((const uint8 *)_exTextdatLE, 2*(kNumExObjects+2));
-	outSaveFile->write((const uint8 *)_exText, kExtextlen);
+	outSaveFile->write((const uint8 *)_exText._offsetsLE, 2*(kNumExObjects+2));
+	outSaveFile->write((const uint8 *)_exText._text, kExtextlen);
 
 	outSaveFile->write(_listOfChanges, len[3]);
 
@@ -554,8 +554,8 @@ void DreamBase::loadPosition(unsigned int slot) {
 	inSaveFile->read((uint8 *)_exFrames._frames, 2080);
 	inSaveFile->read((uint8 *)_exFrames._data, kExframeslen);
 	inSaveFile->read((uint8 *)_exData, sizeof(DynObject)*kNumexobjects);
-	inSaveFile->read((uint8 *)_exTextdatLE, 2*(kNumExObjects+2));
-	inSaveFile->read((uint8 *)_exText, kExtextlen);
+	inSaveFile->read((uint8 *)_exText._offsetsLE, 2*(kNumExObjects+2));
+	inSaveFile->read((uint8 *)_exText._text, kExtextlen);
 
 	inSaveFile->read(_listOfChanges, len[3]);
 
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index cf3e2ce..0b7a81b 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -295,14 +295,28 @@ struct MapFlag {
 };
 
 struct TextFile {
-	TextFile() : _text(0) { }
+	TextFile(unsigned int size = 66) : _size(size), _text(0) { _offsetsLE = new uint16[_size]; }
 
-	uint16 _offsetsLE[66];
+	~TextFile() {
+		delete[] _offsetsLE;
+		_offsetsLE = 0;
+		_size = 0;
+		clear();
+	}
+
+	uint16 *_offsetsLE;
+	unsigned int _size;
 	char *_text;
 
 	const char *getString(unsigned int i) const {
-		assert(i < 66);
-		return _text + READ_LE_UINT16(&_offsetsLE[i]);
+		assert(i < _size);
+		return _text + getOffset(i);
+	}
+	void setOffset(unsigned int i, uint16 offset) {
+		WRITE_LE_UINT16(&_offsetsLE[i], offset);
+	}
+	uint16 getOffset(unsigned int i) const {
+		return READ_LE_UINT16(&_offsetsLE[i]);
 	}
 	void clear() {
 		delete[] _text;
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 084aa76..818e1a5 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1230,8 +1230,7 @@ const uint8 *DreamBase::findObName(uint8 type, uint8 index) {
 		uint16 offset = getSegment(data.word(kPeople)).word(kPersontxtdat + i) + kPersontext;
 		return getSegment(data.word(kPeople)).ptr(offset, 0);
 	} else if (type == 4) {
-		uint16 offset = READ_LE_UINT16(&_exTextdatLE[index]);
-		return (const uint8 *)_exText + offset;
+		return (const uint8 *)_exText.getString(index);
 	} else if (type == 2) {
 		uint16 offset = getSegment(data.word(kFreedesc)).word(kFreetextdat + index * 2) + kFreetext;
 		return getSegment(data.word(kFreedesc)).ptr(offset, 0);
@@ -2223,6 +2222,7 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 	data.word(kReel3) = allocateAndLoad(len[6]);
 	data.word(kReels) = allocateAndLoad(len[7]);
 	data.word(kPeople) = allocateAndLoad(len[8]);
+	// TODO: kSetdesc, kBlockdesc, kRoomdesc are also TextFiles?
 	data.word(kSetdesc) = allocateAndLoad(len[9]);
 	data.word(kBlockdesc) = allocateAndLoad(len[10]);
 	data.word(kRoomdesc) = allocateAndLoad(len[11]);
@@ -2238,6 +2238,7 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 		clearAndLoad(data.word(kFreedat), 255, len[13], kFreedatlen);
 	else
 		engine->skipBytes(len[13]);
+	// TODO: kFreedesc is also a TextFile?
 	data.word(kFreedesc) = allocateAndLoad(len[14]);
 
 	engine->closeFile();
@@ -2499,6 +2500,9 @@ void DreamBase::drawFloor() {
 void DreamBase::allocateBuffers() {
 	_exFrames.clear();
 	_exFrames._data = new uint8[kExframeslen];
+	_exText.clear();
+	_exText._text = new char[kExtextlen];
+
 	data.word(kFreedat) = allocateMem(kFreedatlen/16);
 	data.word(kSetdat) = allocateMem(kSetdatlen/16);
 }
@@ -3622,8 +3626,8 @@ void DreamBase::clearChanges() {
 	memset(_exFrames._frames, 0xFF, 2080);
 	memset(_exFrames._data, 0xFF, kExframeslen);
 	memset(_exData, 0xFF, sizeof(DynObject) * kNumexobjects);
-	memset(_exTextdatLE, 0xFF, 2*(kNumexobjects+2));
-	memset(_exText, 0xFF, kExtextlen);
+	memset(_exText._offsetsLE, 0xFF, 2*(kNumexobjects+2));
+	memset(_exText._text, 0xFF, kExtextlen);
 
 	const uint8 initialRoomsCanGo[] = { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 


Commit: a7cdc342b36bce68e5cdabf6a682e38ea1b21e7b
    https://github.com/scummvm/scummvm/commit/a7cdc342b36bce68e5cdabf6a682e38ea1b21e7b
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T14:03:05-08:00

Commit Message:
DREAMWEB: Convert reel segments into GraphicsFiles

Changed paths:
    devtools/tasmrecover/tasm-recover
    engines/dreamweb/dreambase.h
    engines/dreamweb/dreamgen.cpp
    engines/dreamweb/dreamgen.h
    engines/dreamweb/sprite.cpp
    engines/dreamweb/stubs.cpp
    engines/dreamweb/talk.cpp



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 7e636eb..f87caf4 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -256,6 +256,11 @@ p = parser(skip_binary_data = [
 	'tempsprites',
 	'charset1',
 	'extras',
+	'freeframes',
+	'setframes',
+	'reel1',
+	'reel2',
+	'reel3',
 	# vars.asm - constants
 	'openinvlist',
 	'ryaninvlist',
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 88dc96e..1b48e07 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -146,6 +146,9 @@ protected:
 	// room graphics files
 	GraphicsFile _setFrames;
 	GraphicsFile _freeFrames;
+	GraphicsFile _reel1;
+	GraphicsFile _reel2;
+	GraphicsFile _reel3;
 
 	// Extras segment (NB: this is saved)
 	GraphicsFile _exFrames;
@@ -439,7 +442,7 @@ public:
 	void liftSprite(Sprite *sprite, SetObject *objData);
 
 	Reel *getReelStart(uint16 reelPointer);
-	const Frame *findSource(uint16 &frame);
+	const GraphicsFile *findSource(uint16 &frame);
 	void showReelFrame(Reel *reel);
 	void showGameReel(ReelRoutine *routine);
 	const Frame *getReelFrameAX(uint16 frame);
@@ -511,6 +514,8 @@ public:
 	uint16 allocateAndLoad(unsigned int size);
 	void loadTextFile(TextFile &file, const char *fileName);
 	void loadGraphicsFile(GraphicsFile &file, const char *fileName);
+	void loadGraphicsSegment(GraphicsFile &file, unsigned int len);
+	void loadTextSegment(TextFile &file, unsigned int len);
 	uint16 standardLoad(const char *fileName, uint16 *outSizeInBytes = NULL); // Returns a segment handle which needs to be freed with deallocatemem for symmetry
 	void *standardLoadCPP(const char *fileName, uint16 *outSizeInBytes = NULL); // And this one should be 'free'd
 	void loadIntoTemp(const char *fileName);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 401140e..4f2524a 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -67,11 +67,9 @@ void DreamGenContext::__start() {
 		//0x0110: .... .... .... ....
 		0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
 		//0x0120: .... .... .... ....
-		0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 
+		0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0130: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 
-		//0x0140: .... .... .... ....
-		};
+		0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
 	ds.assign(src, src + sizeof(src));
 	dreamweb(); 
 }
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 6738007..75fef09 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -255,35 +255,30 @@ static const uint16 kBackdrop = 284;
 static const uint16 kRecordspace = 286;
 static const uint16 kFreedat = 288;
 static const uint16 kSetdat = 290;
-static const uint16 kReel1 = 292;
-static const uint16 kReel2 = 294;
-static const uint16 kReel3 = 296;
-static const uint16 kRoomdesc = 298;
-static const uint16 kFreedesc = 300;
-static const uint16 kSetdesc = 302;
-static const uint16 kBlockdesc = 304;
-static const uint16 kSetframes = 306;
-static const uint16 kFreeframes = 308;
-static const uint16 kPeople = 310;
-static const uint16 kReels = 312;
-static const uint16 kBlinkframe = 314;
-static const uint16 kBlinkcount = 315;
-static const uint16 kReasseschanges = 316;
-static const uint16 kPointerspath = 317;
-static const uint16 kManspath = 318;
-static const uint16 kPointerfirstpath = 319;
-static const uint16 kFinaldest = 320;
-static const uint16 kDestination = 321;
-static const uint16 kLinestartx = 322;
-static const uint16 kLinestarty = 324;
-static const uint16 kLineendx = 326;
-static const uint16 kLineendy = 328;
-static const uint16 kLinepointer = 330;
-static const uint16 kLinedirection = 331;
-static const uint16 kLinelength = 332;
-static const uint16 kCh0playing = 333;
-static const uint16 kCh0repeat = 334;
-static const uint16 kCh1playing = 335;
+static const uint16 kRoomdesc = 292;
+static const uint16 kFreedesc = 294;
+static const uint16 kSetdesc = 296;
+static const uint16 kBlockdesc = 298;
+static const uint16 kPeople = 300;
+static const uint16 kReels = 302;
+static const uint16 kBlinkframe = 304;
+static const uint16 kBlinkcount = 305;
+static const uint16 kReasseschanges = 306;
+static const uint16 kPointerspath = 307;
+static const uint16 kManspath = 308;
+static const uint16 kPointerfirstpath = 309;
+static const uint16 kFinaldest = 310;
+static const uint16 kDestination = 311;
+static const uint16 kLinestartx = 312;
+static const uint16 kLinestarty = 314;
+static const uint16 kLineendx = 316;
+static const uint16 kLineendy = 318;
+static const uint16 kLinepointer = 320;
+static const uint16 kLinedirection = 321;
+static const uint16 kLinelength = 322;
+static const uint16 kCh0playing = 323;
+static const uint16 kCh0repeat = 324;
+static const uint16 kCh1playing = 325;
 static const uint16 kBlocktextdat = (0);
 static const uint16 kPersonframes = (0);
 static const uint16 kDebuglevel1 = (0);
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index 31f7408..4071c56 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -435,26 +435,24 @@ Reel *DreamBase::getReelStart(uint16 reelPointer) {
 
 // Locate the reel segment (reel1, reel2, reel3) this frame is stored in,
 // and adjust the frame number relative to this segment.
-const Frame *DreamBase::findSource(uint16 &frame) {
-	uint16 base;
+const GraphicsFile *DreamBase::findSource(uint16 &frame) {
 	if (frame < 160) {
-		base = data.word(kReel1);
+		return &_reel1;
 	} else if (frame < 320) {
 		frame -= 160;
-		base = data.word(kReel2);
+		return &_reel2;
 	} else {
 		frame -= 320;
-		base = data.word(kReel3);
+		return &_reel3;
 	}
-	return (const Frame *)getSegment(base).ptr(0, (frame+1)*sizeof(Frame));
 }
 
 void DreamBase::showReelFrame(Reel *reel) {
 	uint16 x = reel->x + data.word(kMapadx);
 	uint16 y = reel->y + data.word(kMapady);
 	uint16 frame = reel->frame();
-	const Frame *base = findSource(frame);
-	showFrame(base, x, y, frame, 8);
+	const GraphicsFile *base = findSource(frame);
+	showFrame(*base, x, y, frame, 8);
 }
 
 void DreamBase::showGameReel(ReelRoutine *routine) {
@@ -466,8 +464,8 @@ void DreamBase::showGameReel(ReelRoutine *routine) {
 }
 
 const Frame *DreamBase::getReelFrameAX(uint16 frame) {
-	const Frame *base = findSource(frame);
-	return base + frame;
+	const GraphicsFile *base = findSource(frame);
+	return &base->_frames[frame];
 }
 
 void DreamBase::showRain() {
@@ -1115,18 +1113,14 @@ void DreamBase::clearBeforeLoad() {
 }
 
 void DreamBase::clearReels() {
-	deallocateMem(data.word(kReel1));
-	deallocateMem(data.word(kReel2));
-	deallocateMem(data.word(kReel3));
+	_reel1.clear();
+	_reel2.clear();
+	_reel3.clear();
 }
 
 void DreamBase::getRidOfReels() {
-	if (data.byte(kRoomloaded) == 0)
-		return /* (dontgetrid) */;
-
-	deallocateMem(data.word(kReel1));
-	deallocateMem(data.word(kReel2));
-	deallocateMem(data.word(kReel3));
+	if (data.byte(kRoomloaded))
+		clearReels();
 }
 
 void DreamBase::liftNoise(uint8 index) {
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 818e1a5..e9f1ea4 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -651,8 +651,13 @@ done: // The engine will need some cleaner finalization, let's put it here for n
 	_mainSprites.clear();
 
 	_exFrames.clear();
+	_exText.clear();
+
 	_setFrames.clear();
 	_freeFrames.clear();
+	_reel1.clear();
+	_reel2.clear();
+	_reel3.clear();
 
 	_textFile1.clear();
 	_textFile2.clear();
@@ -809,6 +814,23 @@ void DreamBase::loadGraphicsFile(GraphicsFile &file, const char *fileName) {
 	f.read(file._data, sizeInBytes - 2080);
 }
 
+void DreamBase::loadGraphicsSegment(GraphicsFile &file, unsigned int len) {
+	assert(len >= 2080);
+	delete[] file._data;
+	file._data = new uint8[len - 2080];
+	engine->readFromFile((uint8 *)file._frames, 2080);
+	engine->readFromFile(file._data, len - 2080);
+}
+
+void DreamBase::loadTextSegment(TextFile &file, unsigned int len) {
+	unsigned int headerSize = 2 * file._size;
+	assert(len >= headerSize);
+	delete[] file._text;
+	file._text = new char[len - headerSize];
+	engine->readFromFile((uint8 *)file._offsetsLE, headerSize);
+	engine->readFromFile((uint8 *)file._text, len - headerSize);
+}
+
 void DreamBase::loadIntoTemp(const char *fileName) {
 	loadGraphicsFile(_tempGraphics, fileName);
 }
@@ -2170,9 +2192,9 @@ void DreamBase::getRidOfAll() {
 	_backdropBlocks = 0;
 
 	_setFrames.clear();
-	deallocateMem(data.word(kReel1));
-	deallocateMem(data.word(kReel2));
-	deallocateMem(data.word(kReel3));
+	_reel1.clear();
+	_reel2.clear();
+	_reel3.clear();
 	deallocateMem(data.word(kReels));
 	deallocateMem(data.word(kPeople));
 	deallocateMem(data.word(kSetdesc));
@@ -2202,13 +2224,7 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 	clearAndLoad(workspace(), 0, len[1], 132*66); // 132*66 = maplen
 	sortOutMap();
 
-	// TODO: Create function for loading a GraphicsFile from a file segment
-	_setFrames.clear();
-	assert(len[2] >= 2080);
-	engine->readFromFile((uint8 *)_setFrames._frames, 2080);
-	_setFrames._data = new uint8[len[2] - 2080];
-	engine->readFromFile(_setFrames._data, len[2] - 2080);
-
+	loadGraphicsSegment(_setFrames, len[2]);
 	if (!skipDat)
 		clearAndLoad(data.word(kSetdat), 255, len[3], kSetdatlen);
 	else
@@ -2216,24 +2232,16 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 	// NB: The skipDat version of this function as called by restoreall
 	// had a 'call bloc' instead of 'call loadseg' for reel1,
 	// but 'bloc' was not defined.
-	// TODO: kReel1/2/3 are also GraphicsFiles?
-	data.word(kReel1) = allocateAndLoad(len[4]);
-	data.word(kReel2) = allocateAndLoad(len[5]);
-	data.word(kReel3) = allocateAndLoad(len[6]);
+	loadGraphicsSegment(_reel1, len[4]);
+	loadGraphicsSegment(_reel2, len[5]);
+	loadGraphicsSegment(_reel3, len[6]);
 	data.word(kReels) = allocateAndLoad(len[7]);
 	data.word(kPeople) = allocateAndLoad(len[8]);
 	// TODO: kSetdesc, kBlockdesc, kRoomdesc are also TextFiles?
 	data.word(kSetdesc) = allocateAndLoad(len[9]);
 	data.word(kBlockdesc) = allocateAndLoad(len[10]);
 	data.word(kRoomdesc) = allocateAndLoad(len[11]);
-
-	// TODO: Create function for loading a GraphicsFile from a file segment
-	_freeFrames.clear();
-	assert(len[12] >= 2080);
-	engine->readFromFile((uint8 *)_freeFrames._frames, 2080);
-	_freeFrames._data = new uint8[len[12] - 2080];
-	engine->readFromFile(_freeFrames._data, len[12] - 2080);
-
+	loadGraphicsSegment(_freeFrames, len[12]);
 	if (!skipDat)
 		clearAndLoad(data.word(kFreedat), 255, len[13], kFreedatlen);
 	else
@@ -2270,9 +2278,9 @@ void DreamBase::restoreReels() {
 	engine->skipBytes(len[1]);
 	engine->skipBytes(len[2]);
 	engine->skipBytes(len[3]);
-	data.word(kReel1) = allocateAndLoad(len[4]);
-	data.word(kReel2) = allocateAndLoad(len[5]);
-	data.word(kReel3) = allocateAndLoad(len[6]);
+	loadGraphicsSegment(_reel1, len[4]);
+	loadGraphicsSegment(_reel2, len[5]);
+	loadGraphicsSegment(_reel3, len[6]);
 
 	engine->closeFile();
 }
diff --git a/engines/dreamweb/talk.cpp b/engines/dreamweb/talk.cpp
index 74357f3..172a61f 100644
--- a/engines/dreamweb/talk.cpp
+++ b/engines/dreamweb/talk.cpp
@@ -76,8 +76,8 @@ void DreamBase::talk() {
 void DreamBase::convIcons() {
 	uint8 index = data.byte(kCharacter) & 127;
 	uint16 frame = getPersFrame(index);
-	const Frame *base = findSource(frame);
-	showFrame(base, 234, 2, frame, 0);
+	const GraphicsFile *base = findSource(frame);
+	showFrame(*base, 234, 2, frame, 0);
 }
 
 uint16 DreamBase::getPersFrame(uint8 index) {


Commit: d9aed2e00bbb2dc54eb741affc1d978068175c04
    https://github.com/scummvm/scummvm/commit/d9aed2e00bbb2dc54eb741affc1d978068175c04
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T14:03:40-08:00

Commit Message:
DREAMWEB: Convert room text into TextFiles

Changed paths:
    devtools/tasmrecover/tasm-recover
    engines/dreamweb/dreambase.h
    engines/dreamweb/dreamgen.cpp
    engines/dreamweb/dreamgen.h
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/object.cpp
    engines/dreamweb/sprite.cpp
    engines/dreamweb/stubs.cpp
    engines/dreamweb/talk.cpp



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index f87caf4..2b6ff61 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -261,6 +261,11 @@ p = parser(skip_binary_data = [
 	'reel1',
 	'reel2',
 	'reel3',
+	'setdesc',
+	'blockdesc',
+	'roomdesc',
+	'freedesc',
+	'people',
 	# vars.asm - constants
 	'openinvlist',
 	'ryaninvlist',
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 1b48e07..c62d202 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -143,12 +143,18 @@ protected:
 	GraphicsFile _mainSprites;
 	const GraphicsFile *_currentCharset;
 
-	// room graphics files
+	// room files
 	GraphicsFile _setFrames;
 	GraphicsFile _freeFrames;
 	GraphicsFile _reel1;
 	GraphicsFile _reel2;
 	GraphicsFile _reel3;
+	TextFile _setDesc;
+	TextFile _blockDesc;
+	TextFile _roomDesc;
+	TextFile _freeDesc;
+	TextFile _personText;
+	uint16 _personFramesLE[12];
 
 	// Extras segment (NB: this is saved)
 	GraphicsFile _exFrames;
@@ -516,8 +522,6 @@ public:
 	void loadGraphicsFile(GraphicsFile &file, const char *fileName);
 	void loadGraphicsSegment(GraphicsFile &file, unsigned int len);
 	void loadTextSegment(TextFile &file, unsigned int len);
-	uint16 standardLoad(const char *fileName, uint16 *outSizeInBytes = NULL); // Returns a segment handle which needs to be freed with deallocatemem for symmetry
-	void *standardLoadCPP(const char *fileName, uint16 *outSizeInBytes = NULL); // And this one should be 'free'd
 	void loadIntoTemp(const char *fileName);
 	void loadIntoTemp2(const char *fileName);
 	void loadIntoTemp3(const char *fileName);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 4f2524a..de85b4c 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -65,11 +65,9 @@ void DreamGenContext::__start() {
 		//0x0100: .... .... .... ....
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0110: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 
+		0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0120: .... .... .... ....
-		0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-		//0x0130: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
 	ds.assign(src, src + sizeof(src));
 	dreamweb(); 
 }
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 75fef09..bbedcbc 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -255,30 +255,25 @@ static const uint16 kBackdrop = 284;
 static const uint16 kRecordspace = 286;
 static const uint16 kFreedat = 288;
 static const uint16 kSetdat = 290;
-static const uint16 kRoomdesc = 292;
-static const uint16 kFreedesc = 294;
-static const uint16 kSetdesc = 296;
-static const uint16 kBlockdesc = 298;
-static const uint16 kPeople = 300;
-static const uint16 kReels = 302;
-static const uint16 kBlinkframe = 304;
-static const uint16 kBlinkcount = 305;
-static const uint16 kReasseschanges = 306;
-static const uint16 kPointerspath = 307;
-static const uint16 kManspath = 308;
-static const uint16 kPointerfirstpath = 309;
-static const uint16 kFinaldest = 310;
-static const uint16 kDestination = 311;
-static const uint16 kLinestartx = 312;
-static const uint16 kLinestarty = 314;
-static const uint16 kLineendx = 316;
-static const uint16 kLineendy = 318;
-static const uint16 kLinepointer = 320;
-static const uint16 kLinedirection = 321;
-static const uint16 kLinelength = 322;
-static const uint16 kCh0playing = 323;
-static const uint16 kCh0repeat = 324;
-static const uint16 kCh1playing = 325;
+static const uint16 kReels = 292;
+static const uint16 kBlinkframe = 294;
+static const uint16 kBlinkcount = 295;
+static const uint16 kReasseschanges = 296;
+static const uint16 kPointerspath = 297;
+static const uint16 kManspath = 298;
+static const uint16 kPointerfirstpath = 299;
+static const uint16 kFinaldest = 300;
+static const uint16 kDestination = 301;
+static const uint16 kLinestartx = 302;
+static const uint16 kLinestarty = 304;
+static const uint16 kLineendx = 306;
+static const uint16 kLineendy = 308;
+static const uint16 kLinepointer = 310;
+static const uint16 kLinedirection = 311;
+static const uint16 kLinelength = 312;
+static const uint16 kCh0playing = 313;
+static const uint16 kCh0repeat = 314;
+static const uint16 kCh1playing = 315;
 static const uint16 kBlocktextdat = (0);
 static const uint16 kPersonframes = (0);
 static const uint16 kDebuglevel1 = (0);
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 1019aba..539433d 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -407,7 +407,10 @@ uint8 DreamWebEngine::modifyChar(uint8 c) const {
 namespace DreamGen {
 
 // FIXME/TODO: Move this to a better place.
-DreamBase::DreamBase(DreamWeb::DreamWebEngine *en) : engine(en), _exText(kNumExObjects+2) {
+DreamBase::DreamBase(DreamWeb::DreamWebEngine *en) :
+		engine(en), _exText(kNumExObjects+2),
+		_setDesc(130), _blockDesc(98), _roomDesc(38), _freeDesc(82), _personText(1026) {
+
 	_openChangeSize = kInventx+(4*kItempicsize);
 	_quitRequested = false;
 
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index c78ec71..6e5ae8a 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -252,10 +252,7 @@ void DreamBase::inventory() {
 
 void DreamBase::transferText(uint8 from, uint8 to) {
 	_exText.setOffset(to, data.word(kExtextpos));
-	uint16 freeTextOffset = 2*from;
-	uint16 srcOffset = getSegment(data.word(kFreedesc)).word(kFreetextdat + freeTextOffset);
-
-	const char *src = (const char *)getSegment(data.word(kFreedesc)).ptr(kFreetext + srcOffset, 0);
+	const char *src = _freeDesc.getString(from);
 	char *dst = _exText._text + data.word(kExtextpos);
 
 	size_t len = strlen(src);
@@ -592,17 +589,13 @@ const uint8 *DreamBase::getObTextStart() {
 	const uint8 *text;
 	uint16 textOff;
 	if (data.byte(kObjecttype) == kFreeObjectType) {
-		uint16 textSeg = data.word(kFreedesc);
-		uint16 textDatOff = kFreetextdat;
+		textBase = (const uint8 *)_freeDesc._text;
 		textOff = kFreetext;
-		textBase = getSegment(textSeg).ptr(textOff, 0);
-		text = textBase + getSegment(textSeg).word(textDatOff + 2*data.byte(kCommand));
+		text = (const uint8 *)_freeDesc.getString(data.byte(kCommand));
 	} else if (data.byte(kObjecttype) == kSetObjectType1) {
-		uint16 textSeg = data.word(kSetdesc);
-		uint16 textDatOff = kSettextdat;
+		textBase = (const uint8 *)_setDesc._text;
 		textOff = kSettext;
-		textBase = getSegment(textSeg).ptr(textOff, 0);
-		text = textBase + getSegment(textSeg).word(textDatOff + 2*data.byte(kCommand));
+		text = (const uint8 *)_setDesc.getString(data.byte(kCommand));
 	} else {
 		textBase = (const uint8 *)_exText._text;
 		textOff = kExtext;
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index 4071c56..424d8d5 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -1102,12 +1102,12 @@ void DreamBase::clearBeforeLoad() {
 	_backdropBlocks = 0;
 	_setFrames.clear();
 	deallocateMem(data.word(kReels));
-	deallocateMem(data.word(kPeople));
-	deallocateMem(data.word(kSetdesc));
-	deallocateMem(data.word(kBlockdesc));
-	deallocateMem(data.word(kRoomdesc));
+	_personText.clear();
+	_setDesc.clear();
+	_blockDesc.clear();
+	_roomDesc.clear();
 	_freeFrames.clear();
-	deallocateMem(data.word(kFreedesc));
+	_freeDesc.clear();
 
 	data.byte(kRoomloaded) = 0;
 }
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index e9f1ea4..994111d 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -658,6 +658,11 @@ done: // The engine will need some cleaner finalization, let's put it here for n
 	_reel1.clear();
 	_reel2.clear();
 	_reel3.clear();
+	_setDesc.clear();
+	_blockDesc.clear();
+	_roomDesc.clear();
+	_freeDesc.clear();
+	_personText.clear();
 
 	_textFile1.clear();
 	_textFile2.clear();
@@ -773,31 +778,6 @@ void DreamBase::switchRyanOff() {
 	data.byte(kRyanon) = 1;
 }
 
-uint16 DreamBase::standardLoad(const char *fileName, uint16 *outSizeInBytes) {
-	FileHeader header;
-
-	Common::File file;
-	file.open(fileName);
-	file.read((uint8 *)&header, sizeof(FileHeader));
-	uint16 sizeInBytes = header.len(0);
-	if (outSizeInBytes)
-		*outSizeInBytes = sizeInBytes;
-	uint16 result = allocateMem((sizeInBytes + 15) / 16);
-	file.read(getSegment(result).ptr(0, 0), sizeInBytes);
-	return result;
-}
-
-void *DreamBase::standardLoadCPP(const char *fileName, uint16 *outSizeInBytes) {
-	uint16 sizeInBytes;
-	uint16 seg = standardLoad(fileName, &sizeInBytes);
-	void *buffer = malloc(sizeInBytes);
-	memcpy(buffer, getSegment(seg).ptr(0, 0), sizeInBytes);
-	deallocateMem(seg);
-	if (outSizeInBytes)
-		*outSizeInBytes = sizeInBytes;
-	return buffer;
-}
-
 void DreamBase::loadGraphicsFile(GraphicsFile &file, const char *fileName) {
 	FileHeader header;
 
@@ -1248,20 +1228,16 @@ bool DreamBase::checkIfEx(uint8 x, uint8 y) {
 
 const uint8 *DreamBase::findObName(uint8 type, uint8 index) {
 	if (type == 5) {
-		uint16 i = 64 * 2 * (index & 127);
-		uint16 offset = getSegment(data.word(kPeople)).word(kPersontxtdat + i) + kPersontext;
-		return getSegment(data.word(kPeople)).ptr(offset, 0);
+		uint16 i = 64 * (index & 127);
+		return (const uint8 *)_personText.getString(i);
 	} else if (type == 4) {
 		return (const uint8 *)_exText.getString(index);
 	} else if (type == 2) {
-		uint16 offset = getSegment(data.word(kFreedesc)).word(kFreetextdat + index * 2) + kFreetext;
-		return getSegment(data.word(kFreedesc)).ptr(offset, 0);
+		return (const uint8 *)_freeDesc.getString(index);
 	} else if (type == 1) {
-		uint16 offset = getSegment(data.word(kSetdesc)).word(kSettextdat + index * 2) + kSettext;
-		return getSegment(data.word(kSetdesc)).ptr(offset, 0);
+		return (const uint8 *)_setDesc.getString(index);
 	} else {
-		uint16 offset = getSegment(data.word(kBlockdesc)).word(kBlocktextdat + index * 2) + kBlocktext;
-		return getSegment(data.word(kBlockdesc)).ptr(offset, 0);
+		return (const uint8 *)_blockDesc.getString(index);
 	}
 }
 
@@ -1736,9 +1712,8 @@ bool DreamBase::isRyanHolding(const char *id) {
 }
 
 bool DreamBase::isItDescribed(const ObjPos *pos) {
-	uint16 offset = getSegment(data.word(kSetdesc)).word(kSettextdat + pos->index * 2);
-	uint8 result = getSegment(data.word(kSetdesc)).byte(kSettext + offset);
-	return result != 0;
+	const char *string = _setDesc.getString(pos->index);
+	return string[0] != 0;
 }
 
 bool DreamBase::isCD() {
@@ -2050,8 +2025,7 @@ void DreamBase::roomName() {
 		textIndex -= 32;
 	data.word(kLinespacing) = 7;
 	uint8 maxWidth = (data.byte(kWatchon) == 1) ? 120 : 160;
-	uint16 descOffset = getSegment(data.word(kRoomdesc)).word(kIntextdat + textIndex * 2);
-	const uint8 *string = getSegment(data.word(kRoomdesc)).ptr(kIntext + descOffset, 0);
+	const uint8 *string = (const uint8 *)_roomDesc.getString(textIndex);
 	printDirect(string, 88, 25, maxWidth, false);
 	data.word(kLinespacing) = 10;
 	useCharset1();
@@ -2142,8 +2116,7 @@ void DreamBase::doLook() {
 	data.byte(kCommandtype) = 255;
 	dumpTextLine();
 	uint8 index = data.byte(kRoomnum) & 31;
-	uint16 offset = getSegment(data.word(kRoomdesc)).word(kIntextdat + index * 2);
-	const uint8 *string = getSegment(data.word(kRoomdesc)).ptr(kIntext, 0) + offset;
+	const uint8 *string = (const uint8 *)_roomDesc.getString(index);
 	findNextColon(&string);
 	uint16 x;
 	if (data.byte(kReallocation) < 50)
@@ -2196,12 +2169,12 @@ void DreamBase::getRidOfAll() {
 	_reel2.clear();
 	_reel3.clear();
 	deallocateMem(data.word(kReels));
-	deallocateMem(data.word(kPeople));
-	deallocateMem(data.word(kSetdesc));
-	deallocateMem(data.word(kBlockdesc));
-	deallocateMem(data.word(kRoomdesc));
+	_personText.clear();
+	_setDesc.clear();
+	_blockDesc.clear();
+	_roomDesc.clear();
 	_freeFrames.clear();
-	deallocateMem(data.word(kFreedesc));
+	_freeDesc.clear();
 }
 
 // if skipDat, skip clearing and loading Setdat and Freedat
@@ -2236,18 +2209,20 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 	loadGraphicsSegment(_reel2, len[5]);
 	loadGraphicsSegment(_reel3, len[6]);
 	data.word(kReels) = allocateAndLoad(len[7]);
-	data.word(kPeople) = allocateAndLoad(len[8]);
-	// TODO: kSetdesc, kBlockdesc, kRoomdesc are also TextFiles?
-	data.word(kSetdesc) = allocateAndLoad(len[9]);
-	data.word(kBlockdesc) = allocateAndLoad(len[10]);
-	data.word(kRoomdesc) = allocateAndLoad(len[11]);
+
+	// segment 8 consists of 12 personFrames followed by a TextFile
+	engine->readFromFile((uint8 *)_personFramesLE, 24);
+	loadTextSegment(_personText, len[8] - 24);
+
+	loadTextSegment(_setDesc, len[9]);
+	loadTextSegment(_blockDesc, len[10]);
+	loadTextSegment(_roomDesc, len[11]);
 	loadGraphicsSegment(_freeFrames, len[12]);
 	if (!skipDat)
 		clearAndLoad(data.word(kFreedat), 255, len[13], kFreedatlen);
 	else
 		engine->skipBytes(len[13]);
-	// TODO: kFreedesc is also a TextFile?
-	data.word(kFreedesc) = allocateAndLoad(len[14]);
+	loadTextSegment(_freeDesc, len[14]);
 
 	engine->closeFile();
 }
diff --git a/engines/dreamweb/talk.cpp b/engines/dreamweb/talk.cpp
index 172a61f..d27d920 100644
--- a/engines/dreamweb/talk.cpp
+++ b/engines/dreamweb/talk.cpp
@@ -81,7 +81,7 @@ void DreamBase::convIcons() {
 }
 
 uint16 DreamBase::getPersFrame(uint8 index) {
-	return getSegment(data.word(kPeople)).word(kPersonframes + index * 2);
+	return READ_LE_UINT16(&_personFramesLE[index]);
 }
 
 void DreamBase::startTalk() {
@@ -108,8 +108,7 @@ void DreamBase::startTalk() {
 }
 
 const uint8 *DreamBase::getPersonText(uint8 index, uint8 talkPos) {
-	uint16 offset = kPersontext + getSegment(data.word(kPeople)).word(((index * 64 + talkPos) * 2) + kPersontxtdat);
-	return getSegment(data.word(kPeople)).ptr(offset, 0);
+	return (const uint8 *)_personText.getString(index*64 + talkPos);
 }
 
 void DreamBase::moreTalk() {


Commit: 15a1f41e8a9ff22ba4ebb83c1a56d437ec518c2e
    https://github.com/scummvm/scummvm/commit/15a1f41e8a9ff22ba4ebb83c1a56d437ec518c2e
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T14:04:58-08:00

Commit Message:
DREAMWEB: Remove reels segment

Changed paths:
    devtools/tasmrecover/tasm-recover
    engines/dreamweb/dreambase.h
    engines/dreamweb/dreamgen.cpp
    engines/dreamweb/dreamgen.h
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/pathfind.cpp
    engines/dreamweb/sprite.cpp
    engines/dreamweb/stubs.cpp



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 2b6ff61..2d5be1d 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -266,6 +266,7 @@ p = parser(skip_binary_data = [
 	'roomdesc',
 	'freedesc',
 	'people',
+	'reels',
 	# vars.asm - constants
 	'openinvlist',
 	'ryaninvlist',
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index c62d202..a9b0f57 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -155,6 +155,8 @@ protected:
 	TextFile _freeDesc;
 	TextFile _personText;
 	uint16 _personFramesLE[12];
+	RoomPaths _pathData[36];
+	Reel *_reelList;
 
 	// Extras segment (NB: this is saved)
 	GraphicsFile _exFrames;
@@ -517,7 +519,6 @@ public:
 	void allocateBuffers();
 	uint16 allocateMem(uint16 paragraphs);
 	void deallocateMem(uint16 segment);
-	uint16 allocateAndLoad(unsigned int size);
 	void loadTextFile(TextFile &file, const char *fileName);
 	void loadGraphicsFile(GraphicsFile &file, const char *fileName);
 	void loadGraphicsSegment(GraphicsFile &file, unsigned int len);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index de85b4c..4dc099a 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -65,9 +65,9 @@ void DreamGenContext::__start() {
 		//0x0100: .... .... .... ....
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0110: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0120: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
 	ds.assign(src, src + sizeof(src));
 	dreamweb(); 
 }
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index bbedcbc..1ea4972 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -255,25 +255,24 @@ static const uint16 kBackdrop = 284;
 static const uint16 kRecordspace = 286;
 static const uint16 kFreedat = 288;
 static const uint16 kSetdat = 290;
-static const uint16 kReels = 292;
-static const uint16 kBlinkframe = 294;
-static const uint16 kBlinkcount = 295;
-static const uint16 kReasseschanges = 296;
-static const uint16 kPointerspath = 297;
-static const uint16 kManspath = 298;
-static const uint16 kPointerfirstpath = 299;
-static const uint16 kFinaldest = 300;
-static const uint16 kDestination = 301;
-static const uint16 kLinestartx = 302;
-static const uint16 kLinestarty = 304;
-static const uint16 kLineendx = 306;
-static const uint16 kLineendy = 308;
-static const uint16 kLinepointer = 310;
-static const uint16 kLinedirection = 311;
-static const uint16 kLinelength = 312;
-static const uint16 kCh0playing = 313;
-static const uint16 kCh0repeat = 314;
-static const uint16 kCh1playing = 315;
+static const uint16 kBlinkframe = 292;
+static const uint16 kBlinkcount = 293;
+static const uint16 kReasseschanges = 294;
+static const uint16 kPointerspath = 295;
+static const uint16 kManspath = 296;
+static const uint16 kPointerfirstpath = 297;
+static const uint16 kFinaldest = 298;
+static const uint16 kDestination = 299;
+static const uint16 kLinestartx = 300;
+static const uint16 kLinestarty = 302;
+static const uint16 kLineendx = 304;
+static const uint16 kLineendy = 306;
+static const uint16 kLinepointer = 308;
+static const uint16 kLinedirection = 309;
+static const uint16 kLinelength = 310;
+static const uint16 kCh0playing = 311;
+static const uint16 kCh0repeat = 312;
+static const uint16 kCh1playing = 313;
 static const uint16 kBlocktextdat = (0);
 static const uint16 kPersonframes = (0);
 static const uint16 kDebuglevel1 = (0);
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 539433d..468999e 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -417,6 +417,7 @@ DreamBase::DreamBase(DreamWeb::DreamWebEngine *en) :
 	_currentSample = 0xff;
 
 	_backdropBlocks = 0;
+	_reelList = 0;
 
 	_oldSubject._type = 0;
 	_oldSubject._index = 0;
diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp
index 4f887db..8a05961 100644
--- a/engines/dreamweb/pathfind.cpp
+++ b/engines/dreamweb/pathfind.cpp
@@ -42,19 +42,16 @@ void DreamBase::turnPathOff(uint8 param) {
 
 void DreamBase::turnAnyPathOn(uint8 param, uint8 room) {
 	findOrMake(param, 0xff, room + 100);
-	PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * room, 0);
-	paths[param].on = 0xff;
+	_pathData[room].nodes[param].on = 0xff;
 }
 
 void DreamBase::turnAnyPathOff(uint8 param, uint8 room) {
 	findOrMake(param, 0x00, room + 100);
-	PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * room, 0);
-	paths[param].on = 0x00;
+	_pathData[room].nodes[param].on = 0x00;
 }
 
 RoomPaths *DreamBase::getRoomsPaths() {
-	void *result = getSegment(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144);
-	return (RoomPaths *)result;
+	return &_pathData[data.byte(kRoomnum)];
 }
 
 void DreamBase::faceRightWay() {
@@ -310,7 +307,7 @@ void DreamBase::workoutFrames() {
 }
 
 byte DreamBase::findFirstPath(byte x, byte y) {
-	PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * data.byte(kRoomnum), 0);
+	PathNode *paths = _pathData[data.byte(kRoomnum)].nodes;
 
 	for (uint8 index = 0; index < 12; index++) {
 		if (paths[index].x1 == 0xff && paths[index].y1 == 0xff)
@@ -329,7 +326,7 @@ byte DreamBase::findFirstPath(byte x, byte y) {
 }
 
 byte DreamBase::findPathOfPoint(byte x, byte y) {
-	PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * data.byte(kRoomnum), 0);
+	PathNode *paths = _pathData[data.byte(kRoomnum)].nodes;
 
 	for (uint8 index = 0; index < 12; index++) {
 		if (paths[index].on != 0xff)
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index 424d8d5..cc48ca1 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -429,7 +429,7 @@ void DreamBase::liftSprite(Sprite *sprite, SetObject *objData) {
 }
 
 Reel *DreamBase::getReelStart(uint16 reelPointer) {
-	Reel *reel = (Reel *)getSegment(data.word(kReels)).ptr(kReellist + reelPointer * sizeof(Reel) * 8, sizeof(Reel));
+	Reel *reel = &_reelList[reelPointer * 8];
 	return reel;
 }
 
@@ -1101,7 +1101,8 @@ void DreamBase::clearBeforeLoad() {
 	delete[] _backdropBlocks;
 	_backdropBlocks = 0;
 	_setFrames.clear();
-	deallocateMem(data.word(kReels));
+	delete[] _reelList;
+	_reelList = 0;
 	_personText.clear();
 	_setDesc.clear();
 	_blockDesc.clear();
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 994111d..0137fd2 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1049,13 +1049,6 @@ void DreamBase::lockMon() {
 	}
 }
 
-uint16 DreamBase::allocateAndLoad(unsigned int size) {
-	// allocatemem adds 32 bytes, so it doesn't matter that size/16 rounds down
-	uint16 result = allocateMem(size / 16);
-	engine->readFromFile(getSegment(result).ptr(0, size), size);
-	return result;
-}
-
 void DreamBase::clearAndLoad(uint8 *buf, uint8 c,
                                    unsigned int size, unsigned int maxSize) {
 	assert(size <= maxSize);
@@ -1368,9 +1361,7 @@ void DreamBase::doChange(uint8 index, uint8 value, uint8 type) {
 		if (freeObject->mapad[0] == 0xff)
 			freeObject->mapad[0] = value;
 	} else { //path
-//		getSegment(data.word(kReels)).byte(kPathdata + (type - 100) * 144 + index * 8 + 6) = value;
-		PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * (type - 100), 0);
-		paths[index].on = value;
+		_pathData[type - 100].nodes[index].on = value;
 	}
 }
 
@@ -2168,7 +2159,8 @@ void DreamBase::getRidOfAll() {
 	_reel1.clear();
 	_reel2.clear();
 	_reel3.clear();
-	deallocateMem(data.word(kReels));
+	delete[] _reelList;
+	_reelList = 0;
 	_personText.clear();
 	_setDesc.clear();
 	_blockDesc.clear();
@@ -2208,7 +2200,14 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 	loadGraphicsSegment(_reel1, len[4]);
 	loadGraphicsSegment(_reel2, len[5]);
 	loadGraphicsSegment(_reel3, len[6]);
-	data.word(kReels) = allocateAndLoad(len[7]);
+
+	// segment 7 consists of 36*38 pathNodes followed by 'reelList'
+	engine->readFromFile((uint8 *)_pathData, 36*sizeof(RoomPaths));
+	unsigned int reelLen = len[7] - 36*sizeof(RoomPaths);
+	unsigned int reelCount = (reelLen + sizeof(Reel) - 1) / sizeof(Reel);
+	delete[] _reelList;
+	_reelList = new Reel[reelCount];
+	engine->readFromFile((uint8 *)_reelList, reelLen);
 
 	// segment 8 consists of 12 personFrames followed by a TextFile
 	engine->readFromFile((uint8 *)_personFramesLE, 24);


Commit: 914bf3d5192c3ec3131ade9d22c5d5f5ccd18fc0
    https://github.com/scummvm/scummvm/commit/914bf3d5192c3ec3131ade9d22c5d5f5ccd18fc0
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T14:05:27-08:00

Commit Message:
DREAMWEB: Remove setdat, freedat segments

Changed paths:
    devtools/tasmrecover/tasm-recover
    engines/dreamweb/backdrop.cpp
    engines/dreamweb/dreambase.h
    engines/dreamweb/dreamgen.cpp
    engines/dreamweb/dreamgen.h
    engines/dreamweb/sprite.cpp
    engines/dreamweb/structs.h
    engines/dreamweb/stubs.cpp



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 2d5be1d..5c9ec51 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -267,6 +267,8 @@ p = parser(skip_binary_data = [
 	'freedesc',
 	'people',
 	'reels',
+	'setdat',
+	'freedat',
 	# vars.asm - constants
 	'openinvlist',
 	'ryaninvlist',
diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp
index e6f5e9a..295be47 100644
--- a/engines/dreamweb/backdrop.cpp
+++ b/engines/dreamweb/backdrop.cpp
@@ -116,10 +116,7 @@ void DreamBase::makeBackOb(SetObject *objData, uint16 x, uint16 y) {
 	uint8 type = objData->type;
 	Sprite *sprite = makeSprite(x, y, addr_backobject, &_setFrames, 0);
 
-	uint16 objDataOffset = (uint8 *)objData - getSegment(data.word(kSetdat)).ptr(0, 0);
-	assert(objDataOffset % sizeof(SetObject) == 0);
-	assert(objDataOffset < 128 * sizeof(SetObject));
-	sprite->_objData = objDataOffset;
+	sprite->_objData = objData;
 	if (priority == 255)
 		priority = 0;
 	sprite->priority = priority;
@@ -135,9 +132,8 @@ void DreamBase::showAllObs() {
 	_setList.clear();
 
 	const GraphicsFile &frameBase = _setFrames;
-	SetObject *setEntries = (SetObject *)getSegment(data.word(kSetdat)).ptr(0, count * sizeof(SetObject));
 	for (size_t i = 0; i < count; ++i) {
-		SetObject *setEntry = setEntries + i;
+		SetObject *setEntry = &_setDat[i];
 		uint16 x, y;
 		if (getMapAd(setEntry->mapad, &x, &y) == 0)
 			continue;
@@ -216,7 +212,7 @@ void DreamBase::showAllFree() {
 
 	_freeList.clear();
 
-	const DynObject *freeObjects = (const DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0);
+	const DynObject *freeObjects = _freeDat;
 	const GraphicsFile &frameBase = _freeFrames;
 	for (size_t i = 0; i < count; ++i) {
 		uint16 x, y;
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index a9b0f57..77a32bb 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -157,6 +157,8 @@ protected:
 	uint16 _personFramesLE[12];
 	RoomPaths _pathData[36];
 	Reel *_reelList;
+	SetObject _setDat[128];
+	DynObject _freeDat[80];
 
 	// Extras segment (NB: this is saved)
 	GraphicsFile _exFrames;
@@ -530,7 +532,6 @@ public:
 	void loadTravelText();
 	void loadTempText(const char *fileName);
 	void clearAndLoad(uint8 *buf, uint8 c, unsigned int size, unsigned int maxSize);
-	void clearAndLoad(uint16 seg, uint8 c, unsigned int size, unsigned int maxSize);
 	void sortOutMap();
 	void loadRoomData(const Room &room, bool skipDat);
 	void useTempCharset();
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 4dc099a..8b69c84 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -65,9 +65,9 @@ void DreamGenContext::__start() {
 		//0x0100: .... .... .... ....
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0110: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+		0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
 		//0x0120: .... .... .... ....
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
+		0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
 	ds.assign(src, src + sizeof(src));
 	dreamweb(); 
 }
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 1ea4972..d283cd1 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -253,26 +253,24 @@ static const uint16 kWorkspace = 280;
 static const uint16 kMainsprites = 282;
 static const uint16 kBackdrop = 284;
 static const uint16 kRecordspace = 286;
-static const uint16 kFreedat = 288;
-static const uint16 kSetdat = 290;
-static const uint16 kBlinkframe = 292;
-static const uint16 kBlinkcount = 293;
-static const uint16 kReasseschanges = 294;
-static const uint16 kPointerspath = 295;
-static const uint16 kManspath = 296;
-static const uint16 kPointerfirstpath = 297;
-static const uint16 kFinaldest = 298;
-static const uint16 kDestination = 299;
-static const uint16 kLinestartx = 300;
-static const uint16 kLinestarty = 302;
-static const uint16 kLineendx = 304;
-static const uint16 kLineendy = 306;
-static const uint16 kLinepointer = 308;
-static const uint16 kLinedirection = 309;
-static const uint16 kLinelength = 310;
-static const uint16 kCh0playing = 311;
-static const uint16 kCh0repeat = 312;
-static const uint16 kCh1playing = 313;
+static const uint16 kBlinkframe = 288;
+static const uint16 kBlinkcount = 289;
+static const uint16 kReasseschanges = 290;
+static const uint16 kPointerspath = 291;
+static const uint16 kManspath = 292;
+static const uint16 kPointerfirstpath = 293;
+static const uint16 kFinaldest = 294;
+static const uint16 kDestination = 295;
+static const uint16 kLinestartx = 296;
+static const uint16 kLinestarty = 298;
+static const uint16 kLineendx = 300;
+static const uint16 kLineendy = 302;
+static const uint16 kLinepointer = 304;
+static const uint16 kLinedirection = 305;
+static const uint16 kLinelength = 306;
+static const uint16 kCh0playing = 307;
+static const uint16 kCh0repeat = 308;
+static const uint16 kCh1playing = 309;
 static const uint16 kBlocktextdat = (0);
 static const uint16 kPersonframes = (0);
 static const uint16 kDebuglevel1 = (0);
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index cc48ca1..d1b7934 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -82,6 +82,7 @@ Sprite *DreamBase::makeSprite(uint8 x, uint8 y, uint16 updateCallback, const Gra
 	sprite->w2 = 0xffff;
 	sprite->frameNumber = 0;
 	sprite->delay = 0;
+	sprite->_objData = 0;
 	return sprite;
 }
 
@@ -225,7 +226,7 @@ void DreamBase::aboutTurn(Sprite *sprite) {
 }
 
 void DreamBase::backObject(Sprite *sprite) {
-	SetObject *objData = (SetObject *)getSegment(data.word(kSetdat)).ptr(sprite->_objData, 0);
+	SetObject *objData = sprite->_objData;
 
 	if (sprite->delay != 0) {
 		--sprite->delay;
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index 0b7a81b..db1e51f 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -29,6 +29,7 @@
 namespace DreamGen {
 
 struct GraphicsFile;
+struct SetObject;
 
 struct Sprite {
 	uint16 _updateCallback;
@@ -45,7 +46,7 @@ struct Sprite {
 	uint8  b17;
 	uint8  delay;
 	uint8  animFrame; // index into SetObject::frames
-	uint16 _objData;
+	SetObject *_objData;
 	uint8  speed;
 	uint8  priority;
 	uint16 w24;
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 0137fd2..f62e651 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1016,7 +1016,7 @@ void DreamBase::eraseOldObs() {
 	Common::List<Sprite>::iterator i;
 	for (i = _spriteTable.begin(); i != _spriteTable.end(); ) {
 		Sprite &sprite = *i;
-		if (sprite._objData != 0xffff)
+		if (sprite._objData)
 			i = _spriteTable.erase(i);
 		else
 			++i;
@@ -1056,13 +1056,6 @@ void DreamBase::clearAndLoad(uint8 *buf, uint8 c,
 	engine->readFromFile(buf, size);
 }
 
-void DreamBase::clearAndLoad(uint16 seg, uint8 c,
-                                   unsigned int size, unsigned int maxSize) {
-	assert(size <= maxSize);
-	uint8 *buf = getSegment(seg).ptr(0, maxSize);
-	clearAndLoad(buf, c, size, maxSize);
-}
-
 void DreamBase::startLoading(const Room &room) {
 	data.byte(kCombatcount) = 0;
 	_roomsSample = room.roomsSample;
@@ -1303,7 +1296,7 @@ void DreamBase::setAllChanges() {
 }
 
 DynObject *DreamBase::getFreeAd(uint8 index) {
-	return (DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0) + index;
+	return &_freeDat[index];
 }
 
 DynObject *DreamBase::getExAd(uint8 index) {
@@ -1350,7 +1343,7 @@ void *DreamBase::getAnyAdDir(uint8 index, uint8 flag) {
 }
 
 SetObject *DreamBase::getSetAd(uint8 index) {
-	return (SetObject *)getSegment(data.word(kSetdat)).ptr(0, 0) + index;
+	return &_setDat[index];
 }
 
 void DreamBase::doChange(uint8 index, uint8 value, uint8 type) {
@@ -1366,13 +1359,11 @@ void DreamBase::doChange(uint8 index, uint8 value, uint8 type) {
 }
 
 void DreamBase::deleteTaken() {
-	const DynObject *extraObjects = _exData;
-	DynObject *freeObjects = (DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0);
 	for (size_t i = 0; i < kNumexobjects; ++i) {
-		uint8 location = extraObjects[i].initialLocation;
+		uint8 location = _exData[i].initialLocation;
 		if (location == data.byte(kReallocation)) {
-			uint8 index = extraObjects[i].index;
-			freeObjects[index].mapad[0] = 0xfe;
+			uint8 index = _exData[i].index;
+			_freeDat[index].mapad[0] = 0xfe;
 		}
 	}
 }
@@ -2191,7 +2182,7 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 
 	loadGraphicsSegment(_setFrames, len[2]);
 	if (!skipDat)
-		clearAndLoad(data.word(kSetdat), 255, len[3], kSetdatlen);
+		clearAndLoad((uint8 *)_setDat, 255, len[3], kSetdatlen);
 	else
 		engine->skipBytes(len[3]);
 	// NB: The skipDat version of this function as called by restoreall
@@ -2218,7 +2209,7 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
 	loadTextSegment(_roomDesc, len[11]);
 	loadGraphicsSegment(_freeFrames, len[12]);
 	if (!skipDat)
-		clearAndLoad(data.word(kFreedat), 255, len[13], kFreedatlen);
+		clearAndLoad((uint8 *)_freeDat, 255, len[13], kFreedatlen);
 	else
 		engine->skipBytes(len[13]);
 	loadTextSegment(_freeDesc, len[14]);
@@ -2484,9 +2475,6 @@ void DreamBase::allocateBuffers() {
 	_exFrames._data = new uint8[kExframeslen];
 	_exText.clear();
 	_exText._text = new char[kExtextlen];
-
-	data.word(kFreedat) = allocateMem(kFreedatlen/16);
-	data.word(kSetdat) = allocateMem(kSetdatlen/16);
 }
 
 void DreamBase::workToScreenM() {






More information about the Scummvm-git-logs mailing list