From 30089ec31504c862d4ad4317075af600d38a79a8 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 17 Dec 2011 22:20:32 +0100 Subject: [PATCH] DREAMWEB: Convert clearBuffers, clearChanges --- devtools/tasmrecover/tasm-recover | 2 + engines/dreamweb/dreambase.h | 2 + engines/dreamweb/dreamgen.cpp | 67 ------------------------------- engines/dreamweb/dreamgen.h | 2 - engines/dreamweb/stubs.cpp | 35 ++++++++++++++++ 5 files changed, 39 insertions(+), 69 deletions(-) diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover index cbc0001b43d..30a6ea30363 100755 --- a/devtools/tasmrecover/tasm-recover +++ b/devtools/tasmrecover/tasm-recover @@ -305,6 +305,8 @@ generator = cpp(context, "DreamGen", blacklist = [ 'checkspeed', 'chewy', 'clearbeforeload', + 'clearbuffers', + 'clearchanges', 'clearendpal', 'clearpalette', 'clearreels', diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h index 7c86696568d..06936ca72da 100644 --- a/engines/dreamweb/dreambase.h +++ b/engines/dreamweb/dreambase.h @@ -390,6 +390,8 @@ public: void getTime(); void doChange(uint8 index, uint8 value, uint8 type); bool isRyanHolding(const char *id); + void clearBuffers(); + void clearChanges(); // from use.cpp void placeFreeObject(uint8 index); diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index ea4d8e5b059..3c3abe9ca4c 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -2593,73 +2593,6 @@ gotkeyp: showDiaryPage(); } -void DreamGenContext::clearBuffers() { - STACK_CHECK; - es = data.word(kBuffers); - cx = (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)+(250*4)+(256*30)+(6*64)+898-441+68-0)/2; - ax = 0; - di = 0; - _stosw(cx, true); - es = data.word(kExtras); - cx = (0+2080+30000+(16*114)+((114+2)*2)+18000)/2; - ax = 0x0ffff; - di = 0; - _stosw(cx, true); - es = data.word(kBuffers); - di = (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)+(250*4)+(256*30)+(6*64)); - ds = cs; - si = 441; - cx = (898-441); - _movsb(cx, true); - es = data.word(kBuffers); - di = (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)+(250*4)+(256*30)+(6*64)+898-441); - ds = cs; - si = 0; - cx = (68-0); - _movsb(cx, true); - clearChanges(); -} - -void DreamGenContext::clearChanges() { - STACK_CHECK; - es = data.word(kBuffers); - cx = (250)*2; - ax = 0x0ffff; - di = (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)); - _stosw(cx, true); - ds = data.word(kBuffers); - si = (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)+(250*4)+(256*30)+(6*64)); - es = cs; - di = 441; - cx = (898-441); - _movsb(cx, true); - ds = data.word(kBuffers); - si = (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)+(250*4)+(256*30)+(6*64)+898-441); - es = cs; - di = 0; - cx = (68-0); - _movsb(cx, true); - data.byte(kExpos) = 0; - data.word(kExframepos) = 0; - data.word(kExtextpos) = 0; - es = data.word(kExtras); - cx = (0+2080+30000+(16*114)+((114+2)*2)+18000)/2; - ax = 0x0ffff; - di = 0; - _stosw(cx, true); - es = cs; - di = 1120; - al = 1; - _stosb(2); - al = 0; - _stosb(); - al = 1; - _stosb(); - ax = 0; - cx = 6; - _stosw(cx, true); -} - void DreamGenContext::findPathOfPoint() { STACK_CHECK; push(ax); diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index f6100557c13..98bab1bd0e9 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -471,7 +471,6 @@ public: void fadeDownMon(); void getPersonText(); - void clearBuffers(); void getObTextStart(); void checkObjectSize(); void fillOpen(); @@ -522,7 +521,6 @@ public: void searchForString(); void selectOpenOb(); void incRyanPage(); - void clearChanges(); void searchForFiles(); void getExAd(); void initialMonCols(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 1ba88405bcd..eea38eb1960 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -4593,4 +4593,39 @@ void DreamGenContext::showSlots() { } } +void DreamBase::clearBuffers() { + memset(getSegment(data.word(kBuffers)).ptr(0, kLengthofbuffer), 0, kLengthofbuffer); + + memset(getSegment(data.word(kExtras)).ptr(0, kLengthofextra), 0xFF, kLengthofextra); + + // TODO: Remove this line + // (once the ReelRoutines are no longer in the data segment) + memcpy(getSegment(data.word(kBuffers)).ptr(kInitialreelrouts, kLenofreelrouts), data.ptr(kReelroutines, kLenofreelrouts), kLenofreelrouts); + + memcpy(getSegment(data.word(kBuffers)).ptr(kInitialvars, kLengthofvars), data.ptr(kStartvars, kLengthofvars), kLengthofvars); + + clearChanges(); +} + +void DreamBase::clearChanges() { + memset(getSegment(data.word(kBuffers)).ptr(kListofchanges, 4*kNumchanges), 0xFF, 4*kNumchanges); + + // TODO: Call setupInitialReelRoutines instead + // (once the ReelRoutines are no longer in the data segment) + memcpy(data.ptr(kReelroutines, kLenofreelrouts), getSegment(data.word(kBuffers)).ptr(kInitialreelrouts, kLenofreelrouts), kLenofreelrouts); + + memcpy(data.ptr(kStartvars, kLengthofvars), getSegment(data.word(kBuffers)).ptr(kInitialvars, kLengthofvars), kLengthofvars); + + data.byte(kExpos) = 0; + data.word(kExframepos) = 0; + data.word(kExtextpos) = 0; + + memset(getSegment(data.word(kExtras)).ptr(0, kLengthofextra), 0xFF, kLengthofextra); + + const uint8 initialRoomsCanGo[] = { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + memcpy(data.ptr(kRoomscango, 16), initialRoomsCanGo, 16); +} + + } // End of namespace DreamGen