aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdevtools/tasmrecover/tasm-recover4
-rw-r--r--engines/dreamweb/dreamgen.cpp19
-rw-r--r--engines/dreamweb/dreamgen.h16
-rw-r--r--engines/dreamweb/saveload.cpp124
-rw-r--r--engines/dreamweb/stubs.cpp19
-rw-r--r--engines/dreamweb/stubs.h1
6 files changed, 48 insertions, 135 deletions
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index cfb3fe4261..5b6faed5e2 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 7e2637b4af..82db2606c3 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 ee34fb3d65..b507a89068 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 5f5a847416..42f78a1786 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 a5186162e6..a41d5c1dc1 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 c0542af164..f86b0e0f5b 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);