[Scummvm-cvs-logs] scummvm master -> 33e323ed056f38067aa20db0dc0b2127675c64ae

wjp wjp at usecode.org
Sat Nov 26 18:23:32 CET 2011


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

Summary:
77cb6d1375 DREAMWEB: Move 'actualsave' and 'actualload' from dreamgen
8c830ce1b9 DREAMWEB: Convert 'actualsave'
18b8d25696 DREAMWEB: Convert 'actualload'
de40ec5e93 DREAMWEB: Move 'loadposition' and 'saveposition' from dreamgen
c22ed1dab0 DREAMWEB: Convert 'saveposition'
eef8e4de22 DREAMWEB: Convert 'loadposition'
33e323ed05 DREAMWEB: Reduce code completion for scummvm save/load gui


Commit: 77cb6d137550bd1a437577ebb1259fe574b2b4a6
    https://github.com/scummvm/scummvm/commit/77cb6d137550bd1a437577ebb1259fe574b2b4a6
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-11-26T09:21:15-08:00

Commit Message:
DREAMWEB: Move 'actualsave' and 'actualload' from dreamgen

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



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 958c9dd..4f05b28 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -289,6 +289,8 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'getbackfromob',
 	'showfirstuse',
 	'showseconduse',
+	'actualload',
+	'actualsave',
 	], skip_output = [
 	# These functions are processed but not output
 	'dreamweb',
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index fa25cda..2b8eb29 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -10914,100 +10914,6 @@ discopsloop:
 		goto discopsloop;
 }
 
-void DreamGenContext::actualsave() {
-	STACK_CHECK;
-	_cmp(data.byte(kCommandtype), 222);
-	if (flags.z())
-		goto alreadyactsave;
-	data.byte(kCommandtype) = 222;
-	al = 44;
-	commandonly();
-alreadyactsave:
-	ax = data.word(kMousebutton);
-	_and(ax, 1);
-	if (flags.z())
-		return /* (noactsave) */;
-	dx = data;
-	ds = dx;
-	si = 8579;
-	al = data.byte(kCurrentslot);
-	ah = 0;
-	cx = 17;
-	_mul(cx);
-	_add(si, ax);
-	_inc(si);
-	_cmp(ds.byte(si), 0);
-	if (flags.z())
-		return /* (noactsave) */;
-	al = data.byte(kLocation);
-	ah = 0;
-	cx = 32;
-	_mul(cx);
-	ds = cs;
-	si = 6187;
-	_add(si, ax);
-	di = 7979;
-	bx = di;
-	es = cs;
-	cx = 16;
-	_movsw(cx, true);
-	al = data.byte(kRoomssample);
-	es.byte(bx+13) = al;
-	al = data.byte(kMapx);
-	es.byte(bx+15) = al;
-	al = data.byte(kMapy);
-	es.byte(bx+16) = al;
-	al = data.byte(kLiftflag);
-	es.byte(bx+20) = al;
-	al = data.byte(kManspath);
-	es.byte(bx+21) = al;
-	al = data.byte(kFacing);
-	es.byte(bx+22) = al;
-	al = 255;
-	es.byte(bx+27) = al;
-	saveposition();
-	getridoftemp();
-	restoreall();
-	data.word(kTextaddressx) = 13;
-	data.word(kTextaddressy) = 182;
-	data.byte(kTextlen) = 240;
-	redrawmainscrn();
-	worktoscreenm();
-	data.byte(kGetback) = 4;
-}
-
-void DreamGenContext::actualload() {
-	STACK_CHECK;
-	_cmp(data.byte(kCommandtype), 221);
-	if (flags.z())
-		goto alreadyactload;
-	data.byte(kCommandtype) = 221;
-	al = 41;
-	commandonly();
-alreadyactload:
-	ax = data.word(kMousebutton);
-	_cmp(ax, data.word(kOldbutton));
-	if (flags.z())
-		return /* (notactload) */;
-	_cmp(ax, 1);
-	if (!flags.z())
-		return /* (notactload) */;
-	dx = data;
-	ds = dx;
-	si = 8579;
-	al = data.byte(kCurrentslot);
-	ah = 0;
-	cx = 17;
-	_mul(cx);
-	_add(si, ax);
-	_inc(si);
-	_cmp(ds.byte(si), 0);
-	if (flags.z())
-		return /* (notactload) */;
-	loadposition();
-	data.byte(kGetback) = 1;
-}
-
 void DreamGenContext::selectslot2() {
 	STACK_CHECK;
 	_cmp(data.word(kMousebutton), 0);
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index abf6fe1..0e86325 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -158,8 +158,6 @@ public:
 	static const uint16 addr_getnamepos = 0xc864;
 	static const uint16 addr_checkinput = 0xc860;
 	static const uint16 addr_selectslot2 = 0xc85c;
-	static const uint16 addr_actualload = 0xc858;
-	static const uint16 addr_actualsave = 0xc854;
 	static const uint16 addr_savegame = 0xc850;
 	static const uint16 addr_discops = 0xc84c;
 	static const uint16 addr_getbacktoops = 0xc848;
@@ -1573,7 +1571,7 @@ public:
 	void folderexit();
 	void dosreturn();
 	void wheelsound();
-	void actualsave();
+	//void actualsave();
 	//void autolook();
 	void playguitar();
 	//void showreelframe();
@@ -1810,7 +1808,7 @@ public:
 	void fadescreenup();
 	//void getnextword();
 	void generalerror();
-	void actualload();
+	//void actualload();
 	void allocateload();
 	void saveposition();
 	void mode640x480();
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index c96dd51..8100a25 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -380,5 +380,99 @@ void DreamGenContext::showdiscops() {
 	showframe(tempGraphics(), kOpsx+176+2, kOpsy+60-4, 5, 0);
 }
 
+void DreamGenContext::actualsave() {
+	STACK_CHECK;
+	_cmp(data.byte(kCommandtype), 222);
+	if (flags.z())
+		goto alreadyactsave;
+	data.byte(kCommandtype) = 222;
+	al = 44;
+	commandonly();
+alreadyactsave:
+	ax = data.word(kMousebutton);
+	_and(ax, 1);
+	if (flags.z())
+		return /* (noactsave) */;
+	dx = data;
+	ds = dx;
+	si = 8579;
+	al = data.byte(kCurrentslot);
+	ah = 0;
+	cx = 17;
+	_mul(cx);
+	_add(si, ax);
+	_inc(si);
+	_cmp(ds.byte(si), 0);
+	if (flags.z())
+		return /* (noactsave) */;
+	al = data.byte(kLocation);
+	ah = 0;
+	cx = 32;
+	_mul(cx);
+	ds = cs;
+	si = 6187;
+	_add(si, ax);
+	di = 7979;
+	bx = di;
+	es = cs;
+	cx = 16;
+	_movsw(cx, true);
+	al = data.byte(kRoomssample);
+	es.byte(bx+13) = al;
+	al = data.byte(kMapx);
+	es.byte(bx+15) = al;
+	al = data.byte(kMapy);
+	es.byte(bx+16) = al;
+	al = data.byte(kLiftflag);
+	es.byte(bx+20) = al;
+	al = data.byte(kManspath);
+	es.byte(bx+21) = al;
+	al = data.byte(kFacing);
+	es.byte(bx+22) = al;
+	al = 255;
+	es.byte(bx+27) = al;
+	saveposition();
+	getridoftemp();
+	restoreall();
+	data.word(kTextaddressx) = 13;
+	data.word(kTextaddressy) = 182;
+	data.byte(kTextlen) = 240;
+	redrawmainscrn();
+	worktoscreenm();
+	data.byte(kGetback) = 4;
+}
+
+void DreamGenContext::actualload() {
+	STACK_CHECK;
+	_cmp(data.byte(kCommandtype), 221);
+	if (flags.z())
+		goto alreadyactload;
+	data.byte(kCommandtype) = 221;
+	al = 41;
+	commandonly();
+alreadyactload:
+	ax = data.word(kMousebutton);
+	_cmp(ax, data.word(kOldbutton));
+	if (flags.z())
+		return /* (notactload) */;
+	_cmp(ax, 1);
+	if (!flags.z())
+		return /* (notactload) */;
+	dx = data;
+	ds = dx;
+	si = 8579;
+	al = data.byte(kCurrentslot);
+	ah = 0;
+	cx = 17;
+	_mul(cx);
+	_add(si, ax);
+	_inc(si);
+	_cmp(ds.byte(si), 0);
+	if (flags.z())
+		return /* (notactload) */;
+	loadposition();
+	data.byte(kGetback) = 1;
+}
+
 } /*namespace dreamgen */
 
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 465a026..0d70844 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -343,4 +343,6 @@
 	void getbackfromob();
 	void showfirstuse();
 	void showseconduse();
+	void actualsave();
+	void actualload();
 


Commit: 8c830ce1b98a5cd9ab011d2c6599e5f3d9659c80
    https://github.com/scummvm/scummvm/commit/8c830ce1b98a5cd9ab011d2c6599e5f3d9659c80
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-11-26T09:21:15-08:00

Commit Message:
DREAMWEB: Convert 'actualsave'

Changed paths:
    engines/dreamweb/saveload.cpp



diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index 8100a25..ba338cb 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -246,32 +246,19 @@ void DreamGenContext::savegame() {
 		}
 
 		// TODO: The below is copied from actualsave
-		al = data.byte(kLocation);
-		ah = 0;
-		cx = 32;
-		_mul(cx);
-		ds = cs;
-		si = kRoomdata;
-		_add(si, ax);
-		di = kMadeuproomdat;
-		bx = di;
+		const Room *currentRoom = (const Room *)cs.ptr(kRoomdata + sizeof(Room)*data.byte(kLocation), sizeof(Room));
+		Room *madeUpRoom = (Room *)cs.ptr(kMadeuproomdat, sizeof(Room));
+
+		*madeUpRoom = *currentRoom;
+		bx = kMadeuproomdat;
 		es = cs;
-		cx = 16;
-		_movsw(cx, true);
-		al = data.byte(kRoomssample);
-		es.byte(bx+13) = al;
-		al = data.byte(kMapx);
-		es.byte(bx+15) = al;
-		al = data.byte(kMapy);
-		es.byte(bx+16) = al;
-		al = data.byte(kLiftflag);
-		es.byte(bx+20) = al;
-		al = data.byte(kManspath);
-		es.byte(bx+21) = al;
-		al = data.byte(kFacing);
-		es.byte(bx+22) = al;
-		al = 255;
-		es.byte(bx+27) = al;
+		madeUpRoom->roomsSample = data.byte(kRoomssample);
+		madeUpRoom->mapX = data.byte(kMapx);
+		madeUpRoom->mapY = data.byte(kMapy);
+		madeUpRoom->liftFlag = data.byte(kLiftflag);
+		madeUpRoom->b21 = data.byte(kManspath);
+		madeUpRoom->facing = data.byte(kFacing);
+		madeUpRoom->b27 = 255;
 
 		// TODO: The below is copied from saveposition
 		makeheader();
@@ -381,59 +368,38 @@ void DreamGenContext::showdiscops() {
 }
 
 void DreamGenContext::actualsave() {
-	STACK_CHECK;
-	_cmp(data.byte(kCommandtype), 222);
-	if (flags.z())
-		goto alreadyactsave;
-	data.byte(kCommandtype) = 222;
-	al = 44;
-	commandonly();
-alreadyactsave:
-	ax = data.word(kMousebutton);
-	_and(ax, 1);
-	if (flags.z())
-		return /* (noactsave) */;
-	dx = data;
-	ds = dx;
-	si = 8579;
-	al = data.byte(kCurrentslot);
-	ah = 0;
-	cx = 17;
-	_mul(cx);
-	_add(si, ax);
-	_inc(si);
-	_cmp(ds.byte(si), 0);
-	if (flags.z())
-		return /* (noactsave) */;
-	al = data.byte(kLocation);
-	ah = 0;
-	cx = 32;
-	_mul(cx);
-	ds = cs;
-	si = 6187;
-	_add(si, ax);
-	di = 7979;
-	bx = di;
+	if (data.byte(kCommandtype) != 222) {
+		data.byte(kCommandtype) = 222;
+		commandonly(44);
+	}
+
+	if (!(data.word(kMousebutton) & 1))
+		return;
+
+	unsigned int slot = data.byte(kCurrentslot);
+
+	const char *desc = (const char *)data.ptr(kSavenames + 17*slot + 1, 16);
+	if (desc[0] == 0)
+		return;
+
+	const Room *currentRoom = (const Room *)cs.ptr(kRoomdata + sizeof(Room)*data.byte(kLocation), sizeof(Room));
+	Room *madeUpRoom = (Room *)cs.ptr(kMadeuproomdat, sizeof(Room));
+
+	*madeUpRoom = *currentRoom;
+	bx = kMadeuproomdat;
 	es = cs;
-	cx = 16;
-	_movsw(cx, true);
-	al = data.byte(kRoomssample);
-	es.byte(bx+13) = al;
-	al = data.byte(kMapx);
-	es.byte(bx+15) = al;
-	al = data.byte(kMapy);
-	es.byte(bx+16) = al;
-	al = data.byte(kLiftflag);
-	es.byte(bx+20) = al;
-	al = data.byte(kManspath);
-	es.byte(bx+21) = al;
-	al = data.byte(kFacing);
-	es.byte(bx+22) = al;
-	al = 255;
-	es.byte(bx+27) = al;
+	madeUpRoom->roomsSample = data.byte(kRoomssample);
+	madeUpRoom->mapX = data.byte(kMapx);
+	madeUpRoom->mapY = data.byte(kMapy);
+	madeUpRoom->liftFlag = data.byte(kLiftflag);
+	madeUpRoom->b21 = data.byte(kManspath);
+	madeUpRoom->facing = data.byte(kFacing);
+	madeUpRoom->b27 = 255;
+
 	saveposition();
+
 	getridoftemp();
-	restoreall();
+	restoreall(); // reels
 	data.word(kTextaddressx) = 13;
 	data.word(kTextaddressy) = 182;
 	data.byte(kTextlen) = 240;


Commit: 18b8d25696ccfa64fc9336e0b96482a8567fbf15
    https://github.com/scummvm/scummvm/commit/18b8d25696ccfa64fc9336e0b96482a8567fbf15
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-11-26T09:21:15-08:00

Commit Message:
DREAMWEB: Convert 'actualload'

Changed paths:
    engines/dreamweb/saveload.cpp



diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index ba338cb..76ae503 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -409,33 +409,20 @@ void DreamGenContext::actualsave() {
 }
 
 void DreamGenContext::actualload() {
-	STACK_CHECK;
-	_cmp(data.byte(kCommandtype), 221);
-	if (flags.z())
-		goto alreadyactload;
-	data.byte(kCommandtype) = 221;
-	al = 41;
-	commandonly();
-alreadyactload:
-	ax = data.word(kMousebutton);
-	_cmp(ax, data.word(kOldbutton));
-	if (flags.z())
-		return /* (notactload) */;
-	_cmp(ax, 1);
-	if (!flags.z())
-		return /* (notactload) */;
-	dx = data;
-	ds = dx;
-	si = 8579;
-	al = data.byte(kCurrentslot);
-	ah = 0;
-	cx = 17;
-	_mul(cx);
-	_add(si, ax);
-	_inc(si);
-	_cmp(ds.byte(si), 0);
-	if (flags.z())
-		return /* (notactload) */;
+	if (data.byte(kCommandtype) != 221) {
+		data.byte(kCommandtype) = 221;
+		commandonly(41);
+	}
+
+	if (data.word(kMousebutton) == data.word(kOldbutton) || data.word(kMousebutton) != 1)
+		return;
+
+	unsigned int slot = data.byte(kCurrentslot);
+
+	const char *desc = (const char *)data.ptr(kSavenames + 17*slot + 1, 16);
+	if (desc[0] == 0)
+		return;
+
 	loadposition();
 	data.byte(kGetback) = 1;
 }


Commit: de40ec5e9323fa8c6b601915d708a6ee2a83bbc9
    https://github.com/scummvm/scummvm/commit/de40ec5e9323fa8c6b601915d708a6ee2a83bbc9
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-11-26T09:21:15-08:00

Commit Message:
DREAMWEB: Move 'loadposition' and 'saveposition' from dreamgen

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



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 4f05b28..cfb3fe4 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -291,6 +291,8 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'showseconduse',
 	'actualload',
 	'actualsave',
+	'loadposition',
+	'saveposition',
 	], skip_output = [
 	# These functions are processed but not output
 	'dreamweb',
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 2b8eb29..7e2637b 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -11199,104 +11199,6 @@ afterprintname:
 		goto shownameloop;
 }
 
-void DreamGenContext::saveposition() {
-	STACK_CHECK;
-	makeheader();
-	al = data.byte(kCurrentslot);
-	ah = 0;
-	push(ax);
-	cx = 13;
-	_mul(cx);
-	dx = data;
-	ds = dx;
-	dx = 8698;
-	_add(dx, ax);
-	openforsave();
-	dx = data;
-	ds = dx;
-	dx = 6091;
-	cx = (6187-6091);
-	savefilewrite();
-	dx = data;
-	es = dx;
-	di = 6141;
-	ax = pop();
-	cx = 17;
-	_mul(cx);
-	dx = data;
-	ds = dx;
-	dx = 8579;
-	_add(dx, ax);
-	saveseg();
-	dx = data;
-	ds = dx;
-	dx = 0;
-	saveseg();
-	ds = data.word(kExtras);
-	dx = (0);
-	saveseg();
-	ds = data.word(kBuffers);
-	dx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80));
-	saveseg();
-	dx = data;
-	ds = dx;
-	dx = 7979;
-	saveseg();
-	dx = data;
-	ds = dx;
-	dx = 534;
-	saveseg();
-	closefile();
-}
-
-void DreamGenContext::loadposition() {
-	STACK_CHECK;
-	data.word(kTimecount) = 0;
-	clearchanges();
-	al = data.byte(kCurrentslot);
-	ah = 0;
-	push(ax);
-	cx = 13;
-	_mul(cx);
-	dx = data;
-	ds = dx;
-	dx = 8698;
-	_add(dx, ax);
-	openfilefromc();
-	ds = cs;
-	dx = 6091;
-	cx = (6187-6091);
-	savefileread();
-	es = cs;
-	di = 6141;
-	ax = pop();
-	cx = 17;
-	_mul(cx);
-	dx = data;
-	ds = dx;
-	dx = 8579;
-	_add(dx, ax);
-	loadseg();
-	dx = data;
-	ds = dx;
-	dx = 0;
-	loadseg();
-	ds = data.word(kExtras);
-	dx = (0);
-	loadseg();
-	ds = data.word(kBuffers);
-	dx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80));
-	loadseg();
-	dx = data;
-	ds = dx;
-	dx = 7979;
-	loadseg();
-	ds = cs;
-	dx = 534;
-	loadseg();
-	closefile();
-}
-
 void DreamGenContext::makeheader() {
 	STACK_CHECK;
 	dx = data;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 0e86325..ee34fb3 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -142,8 +142,6 @@ public:
 	static const uint16 addr_storeit = 0xc8a8;
 	static const uint16 addr_makeheader = 0xc8a4;
 	static const uint16 addr_loadseg = 0xc8a0;
-	static const uint16 addr_loadposition = 0xc89c;
-	static const uint16 addr_saveposition = 0xc898;
 	static const uint16 addr_savefileread = 0xc894;
 	static const uint16 addr_savefilewrite = 0xc890;
 	static const uint16 addr_error = 0xc884;
@@ -1394,7 +1392,7 @@ public:
 	//void dumpwatch();
 	//void saveload();
 	void monitorlogo();
-	void loadposition();
+	//void loadposition();
 	//void wornerror();
 	void entersymbol();
 	//void showword();
@@ -1810,7 +1808,7 @@ public:
 	void generalerror();
 	//void actualload();
 	void allocateload();
-	void saveposition();
+	//void saveposition();
 	void mode640x480();
 	void openeden();
 	void execcommand();
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index 76ae503..5f5a847 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -427,5 +427,103 @@ void DreamGenContext::actualload() {
 	data.byte(kGetback) = 1;
 }
 
+void DreamGenContext::saveposition() {
+	STACK_CHECK;
+	makeheader();
+	al = data.byte(kCurrentslot);
+	ah = 0;
+	push(ax);
+	cx = 13;
+	_mul(cx);
+	dx = data;
+	ds = dx;
+	dx = 8698;
+	_add(dx, ax);
+	openforsave();
+	dx = data;
+	ds = dx;
+	dx = 6091;
+	cx = (6187-6091);
+	savefilewrite();
+	dx = data;
+	es = dx;
+	di = 6141;
+	ax = pop();
+	cx = 17;
+	_mul(cx);
+	dx = data;
+	ds = dx;
+	dx = 8579;
+	_add(dx, ax);
+	saveseg();
+	dx = data;
+	ds = dx;
+	dx = 0;
+	saveseg();
+	ds = data.word(kExtras);
+	dx = (0);
+	saveseg();
+	ds = data.word(kBuffers);
+	dx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80));
+	saveseg();
+	dx = data;
+	ds = dx;
+	dx = 7979;
+	saveseg();
+	dx = data;
+	ds = dx;
+	dx = 534;
+	saveseg();
+	closefile();
+}
+
+void DreamGenContext::loadposition() {
+	STACK_CHECK;
+	data.word(kTimecount) = 0;
+	clearchanges();
+	al = data.byte(kCurrentslot);
+	ah = 0;
+	push(ax);
+	cx = 13;
+	_mul(cx);
+	dx = data;
+	ds = dx;
+	dx = 8698;
+	_add(dx, ax);
+	openfilefromc();
+	ds = cs;
+	dx = 6091;
+	cx = (6187-6091);
+	savefileread();
+	es = cs;
+	di = 6141;
+	ax = pop();
+	cx = 17;
+	_mul(cx);
+	dx = data;
+	ds = dx;
+	dx = 8579;
+	_add(dx, ax);
+	loadseg();
+	dx = data;
+	ds = dx;
+	dx = 0;
+	loadseg();
+	ds = data.word(kExtras);
+	dx = (0);
+	loadseg();
+	ds = data.word(kBuffers);
+	dx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80));
+	loadseg();
+	dx = data;
+	ds = dx;
+	dx = 7979;
+	loadseg();
+	ds = cs;
+	dx = 534;
+	loadseg();
+	closefile();
+}
+
 } /*namespace dreamgen */
 
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 0d70844..c0542af 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -345,4 +345,6 @@
 	void showseconduse();
 	void actualsave();
 	void actualload();
+	void loadposition();
+	void saveposition();
 


Commit: c22ed1dab03134aa2645e92afc2e1e0d73771c58
    https://github.com/scummvm/scummvm/commit/c22ed1dab03134aa2645e92afc2e1e0d73771c58
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-11-26T09:22:45-08:00

Commit Message:
DREAMWEB: Convert 'saveposition'

Also inline and remove 'saveseg', 'savefilewrite', 'makeheader'.

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



diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index cfb3fe4..5b6faed 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -293,6 +293,10 @@ generator = cpp(context, "DreamGen", blacklist = [
 	'actualsave',
 	'loadposition',
 	'saveposition',
+	'saveseg',
+	'openforsave',
+	'makeheader',
+	'savefilewrite',
 	], skip_output = [
 	# These functions are processed but not output
 	'dreamweb',
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 7e2637b..82db260 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -11199,25 +11199,6 @@ afterprintname:
 		goto shownameloop;
 }
 
-void DreamGenContext::makeheader() {
-	STACK_CHECK;
-	dx = data;
-	es = dx;
-	di = 6141;
-	ax = 17;
-	storeit();
-	ax = (68-0);
-	storeit();
-	ax = (0+2080+30000+(16*114)+((114+2)*2)+18000);
-	storeit();
-	ax = (250)*4;
-	storeit();
-	ax = 48;
-	storeit();
-	ax = (991-534);
-	storeit();
-}
-
 void DreamGenContext::storeit() {
 	STACK_CHECK;
 	_cmp(ax, 0);
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index ee34fb3..b507a89 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -43,7 +43,6 @@ public:
 	static const uint16 addr_setkeyboardint = 0xcbac;
 	static const uint16 addr_readfromfile = 0xcba8;
 	static const uint16 addr_closefile = 0xcba4;
-	static const uint16 addr_openforsave = 0xcba0;
 	static const uint16 addr_openfilenocheck = 0xcb9c;
 	static const uint16 addr_openfilefromc = 0xcb94;
 	static const uint16 addr_openfile = 0xcb90;
@@ -138,12 +137,9 @@ public:
 	static const uint16 addr_showdecisions = 0xc8bc;
 	static const uint16 addr_decide = 0xc8b8;
 	static const uint16 addr_scanfornames = 0xc8b4;
-	static const uint16 addr_saveseg = 0xc8ac;
 	static const uint16 addr_storeit = 0xc8a8;
-	static const uint16 addr_makeheader = 0xc8a4;
 	static const uint16 addr_loadseg = 0xc8a0;
 	static const uint16 addr_savefileread = 0xc894;
-	static const uint16 addr_savefilewrite = 0xc890;
 	static const uint16 addr_error = 0xc884;
 	static const uint16 addr_generalerror = 0xcbbc;
 	static const uint16 addr_dosreturn = 0xc880;
@@ -1265,7 +1261,7 @@ public:
 	void slabdoorf();
 	//void loadintotemp();
 	void loadintroroom();
-	void saveseg();
+	//void saveseg();
 	//void showblink();
 	void mousecall();
 	void train();
@@ -1377,7 +1373,7 @@ public:
 	void getridoftempcharset();
 	void heavy();
 	//void endpaltostart();
-	void showkeys();
+	//void makeheader();
 	void usekey();
 	void locklighton();
 	void useladderb();
@@ -1398,7 +1394,7 @@ public:
 	//void showword();
 	void dirfile();
 	//void bresenhams();
-	//void walktotext();
+	//void savefilewrite();
 	void pickupconts();
 	void locklightoff();
 	void wearwatch();
@@ -1546,12 +1542,12 @@ public:
 	void getundercentre();
 	void checkforexit();
 	void loadseg();
-	void makeheader();
+	void showkeys();
 	void setkeyboardint();
 	void priest();
 	//void readmouse();
 	//void addtopeoplelist();
-	void savefilewrite();
+	//void walktotext();
 	void printmessage2();
 	//void showallfree();
 	void loadnews();
@@ -1794,7 +1790,7 @@ public:
 	void keeper();
 	void afternewroom();
 	void getexad();
-	void openforsave();
+	//void openforsave();
 	void closefile();
 	//void delcurs();
 	//void randomaccess();
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index 5f5a847..42f78a1 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -261,22 +261,15 @@ void DreamGenContext::savegame() {
 		madeUpRoom->b27 = 255;
 
 		// TODO: The below is copied from saveposition
-		makeheader();
 
-		//Common::String filename = ConfMan.getActiveDomainName() + Common::String::format(".d%02d", savegameId);
-		Common::String filename = Common::String::format("DREAMWEB.D%02d", savegameId);
-		debug(1, "Saving to filename: %s (%s)", filename.c_str(), game_description.c_str());
 
-		engine->openSaveFileForWriting(filename.c_str());
-
-		dx = data;
-		ds = dx;
-		dx = kFileheader;
-		cx = kHeaderlen;
-		savefilewrite();
-		dx = data;
-		es = dx;
-		di = kFiledata;
+		openforsave(savegameId);
+		// fill length fields in savegame file header
+		uint16 len[6] = { 17, kLengthofvars, kLengthofextra,
+		                  4*kNumchanges, 48, kLenofreelrouts };
+		for (int i = 0; i < 6; ++i)
+			data.word(kFiledata + 2*i) = len[i];
+		engine->writeToSaveFile(data.ptr(kFileheader, kHeaderlen), kHeaderlen);
 
 		// TODO: Check if this 2 is a constant
 		uint8 descbuf[17] = { 2, 0 };
@@ -288,38 +281,14 @@ void DreamGenContext::savegame() {
 		descbuf[++desclen] = 0;
 		while (desclen < 17)
 			descbuf[++desclen] = 1;
-		if (savegameId < 7) {
-			ax = savegameId;
-			cx = 17;
-			_mul(cx);
-			ds = data;
-			dx = kSavenames;
-			_add(dx, ax);
-			memcpy(data.ptr(dx,17), descbuf, 17);
-			saveseg();
-		} else {
-			// savenames only has room for descriptions for 7 slots
-			uint16 len = es.word(di);
-			_add(di, 2);
-			assert(len == 17);
-			engine->writeToSaveFile(descbuf, len);
-		}
-
-		ds = data;
-		dx = kStartvars;
-		saveseg();
-		ds = data.word(kExtras);
-		dx = kExframedata;
-		saveseg();
-		ds = data.word(kBuffers);
-		dx = kListofchanges;
-		saveseg();
-		ds = data;
-		dx = kMadeuproomdat;
-		saveseg();
-		ds = data;
-		dx = kReelroutines;
-		saveseg();
+		if (savegameId < 7)
+			memcpy(data.ptr(kSavenames + 17*savegameId, 17), descbuf, 17);
+		engine->writeToSaveFile(descbuf, len[0]);
+		engine->writeToSaveFile(data.ptr(kStartvars, len[1]), len[1]);
+		engine->writeToSaveFile(segRef(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]);
+		engine->writeToSaveFile(segRef(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]);
+		engine->writeToSaveFile(data.ptr(kMadeuproomdat, len[4]), len[4]);
+		engine->writeToSaveFile(data.ptr(kReelroutines, len[5]), len[5]);
 		closefile();
 
 		getridoftemp();
@@ -428,52 +397,23 @@ void DreamGenContext::actualload() {
 }
 
 void DreamGenContext::saveposition() {
-	STACK_CHECK;
-	makeheader();
-	al = data.byte(kCurrentslot);
-	ah = 0;
-	push(ax);
-	cx = 13;
-	_mul(cx);
-	dx = data;
-	ds = dx;
-	dx = 8698;
-	_add(dx, ax);
-	openforsave();
-	dx = data;
-	ds = dx;
-	dx = 6091;
-	cx = (6187-6091);
-	savefilewrite();
-	dx = data;
-	es = dx;
-	di = 6141;
-	ax = pop();
-	cx = 17;
-	_mul(cx);
-	dx = data;
-	ds = dx;
-	dx = 8579;
-	_add(dx, ax);
-	saveseg();
-	dx = data;
-	ds = dx;
-	dx = 0;
-	saveseg();
-	ds = data.word(kExtras);
-	dx = (0);
-	saveseg();
-	ds = data.word(kBuffers);
-	dx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80));
-	saveseg();
-	dx = data;
-	ds = dx;
-	dx = 7979;
-	saveseg();
-	dx = data;
-	ds = dx;
-	dx = 534;
-	saveseg();
+	unsigned int slot = data.byte(kCurrentslot);
+
+	openforsave(slot);
+
+	// fill length fields in savegame file header
+	uint16 len[6] = { 17, kLengthofvars, kLengthofextra,
+	                  4*kNumchanges, 48, kLenofreelrouts };
+	for (int i = 0; i < 6; ++i)
+		data.word(kFiledata + 2*i) = len[i];
+
+	engine->writeToSaveFile(data.ptr(kFileheader, kHeaderlen), kHeaderlen);
+	engine->writeToSaveFile(data.ptr(kSavenames + 17*slot, len[0]), len[0]);
+	engine->writeToSaveFile(data.ptr(kStartvars, len[1]), len[1]);
+	engine->writeToSaveFile(segRef(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]);
+	engine->writeToSaveFile(segRef(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]);
+	engine->writeToSaveFile(data.ptr(kMadeuproomdat, len[4]), len[4]);
+	engine->writeToSaveFile(data.ptr(kReelroutines, len[5]), len[5]);
 	closefile();
 }
 
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index a518616..a41d5c1 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -406,10 +406,11 @@ void DreamGenContext::closefile() {
 	data.byte(kHandle) = 0;
 }
 
-void DreamGenContext::openforsave() {
-	const char *name = (const char *)ds.ptr(dx, 13);
-	debug(1, "openforsave(%s)", name);
-	engine->openSaveFileForWriting(name);
+void DreamGenContext::openforsave(unsigned int slot) {
+	//Common::String filename = ConfMan.getActiveDomainName() + Common::String::format(".d%02d", savegameId);
+	Common::String filename = Common::String::format("DREAMWEB.D%02d", slot);
+	debug(1, "openforsave(%s)", filename.c_str());
+	engine->openSaveFileForWriting(filename);
 }
 
 void DreamGenContext::openfilenocheck() {
@@ -721,16 +722,6 @@ void DreamGenContext::loadspeech() {
 		data.byte(kSpeechloaded) = 1;
 }
 
-void DreamGenContext::saveseg() {
-	cx = es.word(di);
-	_add(di, 2);
-	savefilewrite();
-}
-
-void DreamGenContext::savefilewrite() {
-	ax = engine->writeToSaveFile(ds.ptr(dx, cx), cx);
-}
-
 void DreamGenContext::savefileread() {
 	ax = engine->readFromSaveFile(ds.ptr(dx, cx), cx);
 }
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index c0542af..f86b0e0 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -347,4 +347,5 @@
 	void actualload();
 	void loadposition();
 	void saveposition();
+	void openforsave(unsigned int slot);
 


Commit: eef8e4de22e799eba2a9011ea15bdb3fc6e3faec
    https://github.com/scummvm/scummvm/commit/eef8e4de22e799eba2a9011ea15bdb3fc6e3faec
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-11-26T09:22:54-08:00

Commit Message:
DREAMWEB: Convert 'loadposition'

Changed paths:
    engines/dreamweb/saveload.cpp
    engines/dreamweb/stubs.cpp
    engines/dreamweb/stubs.h



diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index 42f78a1..60b7236 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -102,53 +102,35 @@ void DreamGenContext::doload() {
 		}
 
 
-		// TODO: proper scheme for filename, in a separate function
-		//Common::String filename = ConfMan.getActiveDomainName() + Common::String::format(".d%02d", savegameId);
-		Common::String filename = Common::String::format("DREAMWEB.D%02d", savegameId);
-		debug(1, "Loading from filename: %s", filename.c_str());
-		engine->openSaveFileForReading(filename);
-
 		// TODO: The below is duplicated from Loadposition
 		data.word(kTimecount) = 0;
 		clearchanges();
 
-		ds = cs;
-		dx = kFileheader;
-		cx = kHeaderlen;
-		savefileread();
-		es = cs;
-		di = kFiledata;
-		ax = savegameId;
+		openforload(savegameId);
+
+		engine->readFromSaveFile(cs.ptr(kFileheader, kHeaderlen), kHeaderlen);
+
+		// read segment lengths from savegame file header
+		int len[6];
+		for (int i = 0; i < 6; ++i)
+			len[i] = cs.word(kFiledata + 2*i);
+		if (len[0] != 17)
+			::error("Error loading save: description buffer isn't 17 bytes");
+
 		if (savegameId < 7) {
-			cx = 17;
-			_mul(cx);
-			ds = data;
-			dx = kSavenames;
-			_add(dx, ax);
-			loadseg();
+			engine->readFromSaveFile(data.ptr(kSavenames + 17*savegameId, len[0]), len[0]);
 		} else {
-			// For potential support of more than 7 savegame slots,
+			// For support of more than 7 savegame slots,
 			// loading into the savenames buffer isn't always possible
-			// Emulate a loadseg call:
 			uint8 namebuf[17];
-			engine->readFromFile(namebuf, 17);
-			_add(di, 2);
+			engine->readFromSaveFile(namebuf, 17);
 		}
-		ds = data; 
-		dx = kStartvars;
-		loadseg();
-		ds = data.word(kExtras);
-		dx = kExframedata;
-		loadseg();
-		ds = data.word(kBuffers);
-		dx = kListofchanges;
-		loadseg();
-		ds = data;
-		dx = kMadeuproomdat;
-		loadseg();
-		ds = cs;
-		dx = kReelroutines;
-		loadseg();
+		engine->readFromSaveFile(data.ptr(kStartvars, len[1]), len[1]);
+		engine->readFromSaveFile(segRef(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]);
+		engine->readFromSaveFile(segRef(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]);
+		engine->readFromSaveFile(data.ptr(kMadeuproomdat, len[4]), len[4]);
+		engine->readFromSaveFile(cs.ptr(kReelroutines, len[5]), len[5]);
+
 		closefile();
 		data.byte(kGetback) = 1;
 	}
@@ -418,50 +400,29 @@ void DreamGenContext::saveposition() {
 }
 
 void DreamGenContext::loadposition() {
-	STACK_CHECK;
 	data.word(kTimecount) = 0;
 	clearchanges();
-	al = data.byte(kCurrentslot);
-	ah = 0;
-	push(ax);
-	cx = 13;
-	_mul(cx);
-	dx = data;
-	ds = dx;
-	dx = 8698;
-	_add(dx, ax);
-	openfilefromc();
-	ds = cs;
-	dx = 6091;
-	cx = (6187-6091);
-	savefileread();
-	es = cs;
-	di = 6141;
-	ax = pop();
-	cx = 17;
-	_mul(cx);
-	dx = data;
-	ds = dx;
-	dx = 8579;
-	_add(dx, ax);
-	loadseg();
-	dx = data;
-	ds = dx;
-	dx = 0;
-	loadseg();
-	ds = data.word(kExtras);
-	dx = (0);
-	loadseg();
-	ds = data.word(kBuffers);
-	dx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5)+(12*5)+(46*40)+(5*80));
-	loadseg();
-	dx = data;
-	ds = dx;
-	dx = 7979;
-	loadseg();
-	ds = cs;
-	dx = 534;
-	loadseg();
+
+	unsigned int slot = data.byte(kCurrentslot);
+
+	openforload(slot);
+
+	engine->readFromSaveFile(cs.ptr(kFileheader, kHeaderlen), kHeaderlen);
+
+	// read segment lengths from savegame file header
+	int len[6];
+	for (int i = 0; i < 6; ++i)
+		len[i] = cs.word(kFiledata + 2*i);
+	if (len[0] != 17)
+		::error("Error loading save: description buffer isn't 17 bytes");
+
+	engine->readFromSaveFile(data.ptr(kSavenames + 17*slot, len[0]), len[0]);
+	engine->readFromSaveFile(data.ptr(kStartvars, len[1]), len[1]);
+	engine->readFromSaveFile(segRef(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]);
+	engine->readFromSaveFile(segRef(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]);
+	engine->readFromSaveFile(data.ptr(kMadeuproomdat, len[4]), len[4]);
+	engine->readFromSaveFile(cs.ptr(kReelroutines, len[5]), len[5]);
+
 	closefile();
 }
 
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index a41d5c1..01a7657 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -413,6 +413,14 @@ void DreamGenContext::openforsave(unsigned int slot) {
 	engine->openSaveFileForWriting(filename);
 }
 
+void DreamGenContext::openforload(unsigned int slot) {
+	//Common::String filename = ConfMan.getActiveDomainName() + Common::String::format(".d%02d", savegameId);
+	Common::String filename = Common::String::format("DREAMWEB.D%02d", slot);
+	debug(1, "openforload(%s)", filename.c_str());
+	engine->openSaveFileForReading(filename);
+}
+
+
 void DreamGenContext::openfilenocheck() {
 	const char *name = (const char *)ds.ptr(dx, 13);
 	debug(1, "checksavefile(%s)", name);
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index f86b0e0..24233b4 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -348,4 +348,5 @@
 	void loadposition();
 	void saveposition();
 	void openforsave(unsigned int slot);
+	void openforload(unsigned int slot);
 


Commit: 33e323ed056f38067aa20db0dc0b2127675c64ae
    https://github.com/scummvm/scummvm/commit/33e323ed056f38067aa20db0dc0b2127675c64ae
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-11-26T09:22:54-08:00

Commit Message:
DREAMWEB: Reduce code completion for scummvm save/load gui

Changed paths:
    engines/dreamweb/saveload.cpp
    engines/dreamweb/stubs.h



diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index 60b7236..00e81ed 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -101,37 +101,8 @@ void DreamGenContext::doload() {
 			return;
 		}
 
+		loadposition(savegameId);
 
-		// TODO: The below is duplicated from Loadposition
-		data.word(kTimecount) = 0;
-		clearchanges();
-
-		openforload(savegameId);
-
-		engine->readFromSaveFile(cs.ptr(kFileheader, kHeaderlen), kHeaderlen);
-
-		// read segment lengths from savegame file header
-		int len[6];
-		for (int i = 0; i < 6; ++i)
-			len[i] = cs.word(kFiledata + 2*i);
-		if (len[0] != 17)
-			::error("Error loading save: description buffer isn't 17 bytes");
-
-		if (savegameId < 7) {
-			engine->readFromSaveFile(data.ptr(kSavenames + 17*savegameId, len[0]), len[0]);
-		} else {
-			// For support of more than 7 savegame slots,
-			// loading into the savenames buffer isn't always possible
-			uint8 namebuf[17];
-			engine->readFromSaveFile(namebuf, 17);
-		}
-		engine->readFromSaveFile(data.ptr(kStartvars, len[1]), len[1]);
-		engine->readFromSaveFile(segRef(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]);
-		engine->readFromSaveFile(segRef(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]);
-		engine->readFromSaveFile(data.ptr(kMadeuproomdat, len[4]), len[4]);
-		engine->readFromSaveFile(cs.ptr(kReelroutines, len[5]), len[5]);
-
-		closefile();
 		data.byte(kGetback) = 1;
 	}
 
@@ -227,32 +198,6 @@ void DreamGenContext::savegame() {
 			return;
 		}
 
-		// TODO: The below is copied from actualsave
-		const Room *currentRoom = (const Room *)cs.ptr(kRoomdata + sizeof(Room)*data.byte(kLocation), sizeof(Room));
-		Room *madeUpRoom = (Room *)cs.ptr(kMadeuproomdat, sizeof(Room));
-
-		*madeUpRoom = *currentRoom;
-		bx = kMadeuproomdat;
-		es = cs;
-		madeUpRoom->roomsSample = data.byte(kRoomssample);
-		madeUpRoom->mapX = data.byte(kMapx);
-		madeUpRoom->mapY = data.byte(kMapy);
-		madeUpRoom->liftFlag = data.byte(kLiftflag);
-		madeUpRoom->b21 = data.byte(kManspath);
-		madeUpRoom->facing = data.byte(kFacing);
-		madeUpRoom->b27 = 255;
-
-		// TODO: The below is copied from saveposition
-
-
-		openforsave(savegameId);
-		// fill length fields in savegame file header
-		uint16 len[6] = { 17, kLengthofvars, kLengthofextra,
-		                  4*kNumchanges, 48, kLenofreelrouts };
-		for (int i = 0; i < 6; ++i)
-			data.word(kFiledata + 2*i) = len[i];
-		engine->writeToSaveFile(data.ptr(kFileheader, kHeaderlen), kHeaderlen);
-
 		// TODO: Check if this 2 is a constant
 		uint8 descbuf[17] = { 2, 0 };
 		strncpy((char*)descbuf+1, game_description.c_str(), 16);
@@ -265,16 +210,12 @@ void DreamGenContext::savegame() {
 			descbuf[++desclen] = 1;
 		if (savegameId < 7)
 			memcpy(data.ptr(kSavenames + 17*savegameId, 17), descbuf, 17);
-		engine->writeToSaveFile(descbuf, len[0]);
-		engine->writeToSaveFile(data.ptr(kStartvars, len[1]), len[1]);
-		engine->writeToSaveFile(segRef(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]);
-		engine->writeToSaveFile(segRef(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]);
-		engine->writeToSaveFile(data.ptr(kMadeuproomdat, len[4]), len[4]);
-		engine->writeToSaveFile(data.ptr(kReelroutines, len[5]), len[5]);
-		closefile();
 
+		saveposition(savegameId, descbuf);
+
+		// TODO: The below is copied from actualsave
 		getridoftemp();
-		restoreall();
+		restoreall(); // reels
 		data.word(kTextaddressx) = 13;
 		data.word(kTextaddressy) = 182;
 		data.byte(kTextlen) = 240;
@@ -329,25 +270,11 @@ void DreamGenContext::actualsave() {
 
 	unsigned int slot = data.byte(kCurrentslot);
 
-	const char *desc = (const char *)data.ptr(kSavenames + 17*slot + 1, 16);
-	if (desc[0] == 0)
+	const uint8 *desc = data.ptr(kSavenames + 17*slot, 16);
+	if (desc[1] == 0) // The actual description string starts at desc[1]
 		return;
 
-	const Room *currentRoom = (const Room *)cs.ptr(kRoomdata + sizeof(Room)*data.byte(kLocation), sizeof(Room));
-	Room *madeUpRoom = (Room *)cs.ptr(kMadeuproomdat, sizeof(Room));
-
-	*madeUpRoom = *currentRoom;
-	bx = kMadeuproomdat;
-	es = cs;
-	madeUpRoom->roomsSample = data.byte(kRoomssample);
-	madeUpRoom->mapX = data.byte(kMapx);
-	madeUpRoom->mapY = data.byte(kMapy);
-	madeUpRoom->liftFlag = data.byte(kLiftflag);
-	madeUpRoom->b21 = data.byte(kManspath);
-	madeUpRoom->facing = data.byte(kFacing);
-	madeUpRoom->b27 = 255;
-
-	saveposition();
+	saveposition(slot, desc);
 
 	getridoftemp();
 	restoreall(); // reels
@@ -370,16 +297,28 @@ void DreamGenContext::actualload() {
 
 	unsigned int slot = data.byte(kCurrentslot);
 
-	const char *desc = (const char *)data.ptr(kSavenames + 17*slot + 1, 16);
-	if (desc[0] == 0)
+	const uint8 *desc = data.ptr(kSavenames + 17*slot, 16);
+	if (desc[1] == 0) // The actual description string starts at desc[1]
 		return;
 
-	loadposition();
+	loadposition(data.byte(kCurrentslot));
 	data.byte(kGetback) = 1;
 }
 
-void DreamGenContext::saveposition() {
-	unsigned int slot = data.byte(kCurrentslot);
+void DreamGenContext::saveposition(unsigned int slot, const uint8 *descbuf) {
+
+	const Room *currentRoom = (const Room *)cs.ptr(kRoomdata + sizeof(Room)*data.byte(kLocation), sizeof(Room));
+	Room *madeUpRoom = (Room *)cs.ptr(kMadeuproomdat, sizeof(Room));
+
+	*madeUpRoom = *currentRoom;
+	madeUpRoom->roomsSample = data.byte(kRoomssample);
+	madeUpRoom->mapX = data.byte(kMapx);
+	madeUpRoom->mapY = data.byte(kMapy);
+	madeUpRoom->liftFlag = data.byte(kLiftflag);
+	madeUpRoom->b21 = data.byte(kManspath);
+	madeUpRoom->facing = data.byte(kFacing);
+	madeUpRoom->b27 = 255;
+
 
 	openforsave(slot);
 
@@ -390,21 +329,21 @@ void DreamGenContext::saveposition() {
 		data.word(kFiledata + 2*i) = len[i];
 
 	engine->writeToSaveFile(data.ptr(kFileheader, kHeaderlen), kHeaderlen);
-	engine->writeToSaveFile(data.ptr(kSavenames + 17*slot, len[0]), len[0]);
+	engine->writeToSaveFile(descbuf, len[0]);
 	engine->writeToSaveFile(data.ptr(kStartvars, len[1]), len[1]);
 	engine->writeToSaveFile(segRef(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]);
 	engine->writeToSaveFile(segRef(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]);
 	engine->writeToSaveFile(data.ptr(kMadeuproomdat, len[4]), len[4]);
 	engine->writeToSaveFile(data.ptr(kReelroutines, len[5]), len[5]);
 	closefile();
+
+
 }
 
-void DreamGenContext::loadposition() {
+void DreamGenContext::loadposition(unsigned int slot) {
 	data.word(kTimecount) = 0;
 	clearchanges();
 
-	unsigned int slot = data.byte(kCurrentslot);
-
 	openforload(slot);
 
 	engine->readFromSaveFile(cs.ptr(kFileheader, kHeaderlen), kHeaderlen);
@@ -416,7 +355,13 @@ void DreamGenContext::loadposition() {
 	if (len[0] != 17)
 		::error("Error loading save: description buffer isn't 17 bytes");
 
-	engine->readFromSaveFile(data.ptr(kSavenames + 17*slot, len[0]), len[0]);
+	if (slot < 7) {
+		engine->readFromSaveFile(data.ptr(kSavenames + 17*slot, len[0]), len[0]);
+	} else {
+		// The savenames buffer only has room for 7 descriptions
+		uint8 namebuf[17];
+		engine->readFromSaveFile(namebuf, 17);
+	}
 	engine->readFromSaveFile(data.ptr(kStartvars, len[1]), len[1]);
 	engine->readFromSaveFile(segRef(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]);
 	engine->readFromSaveFile(segRef(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]);
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 24233b4..c4f126a 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -345,8 +345,8 @@
 	void showseconduse();
 	void actualsave();
 	void actualload();
-	void loadposition();
-	void saveposition();
+	void loadposition(unsigned int slot);
+	void saveposition(unsigned int slot, const uint8 *descbuf);
 	void openforsave(unsigned int slot);
 	void openforload(unsigned int slot);
 






More information about the Scummvm-git-logs mailing list