diff options
author | Filippos Karapetis | 2011-12-08 00:31:33 -0800 |
---|---|---|
committer | Filippos Karapetis | 2011-12-08 00:31:33 -0800 |
commit | 5b5a684c050d937cb8b7284e3d4f17d7746319d0 (patch) | |
tree | 42300faeedf1d031f49fd2bc9cb5421c7dde3a33 /engines | |
parent | 02fed995a96e697927c6b71ae6ca22e29b02febd (diff) | |
parent | cb0a12033b97064b35c30d5d86406b4b16517532 (diff) | |
download | scummvm-rg350-5b5a684c050d937cb8b7284e3d4f17d7746319d0.tar.gz scummvm-rg350-5b5a684c050d937cb8b7284e3d4f17d7746319d0.tar.bz2 scummvm-rg350-5b5a684c050d937cb8b7284e3d4f17d7746319d0.zip |
Merge pull request #128 from fingolfin/dreamweb-segments
DREAMWEB: Refactor segment management
Diffstat (limited to 'engines')
-rw-r--r-- | engines/dreamweb/dreambase.h | 48 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 24 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 3 | ||||
-rw-r--r-- | engines/dreamweb/dreamweb.cpp | 2 | ||||
-rw-r--r-- | engines/dreamweb/print.cpp | 12 | ||||
-rw-r--r-- | engines/dreamweb/runtime.h | 193 | ||||
-rw-r--r-- | engines/dreamweb/segment.h | 227 | ||||
-rw-r--r-- | engines/dreamweb/stubs.cpp | 4 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 35 | ||||
-rw-r--r-- | engines/dreamweb/vgafades.cpp | 46 | ||||
-rw-r--r-- | engines/dreamweb/vgagrafx.cpp | 36 |
11 files changed, 327 insertions, 303 deletions
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h index 6263adfe60..bad977c2df 100644 --- a/engines/dreamweb/dreambase.h +++ b/engines/dreamweb/dreambase.h @@ -25,7 +25,7 @@ #include "common/scummsys.h" -#include "dreamweb/runtime.h" +#include "dreamweb/segment.h" namespace DreamWeb { class DreamWebEngine; @@ -43,21 +43,12 @@ namespace DreamGen { * together with class Context. When that happens, we can probably merge * DreamBase into DreamWebEngine. */ -class DreamBase { +class DreamBase : public SegmentManager { protected: DreamWeb::DreamWebEngine *engine; public: - enum { kDefaultDataSegment = 0x1000 }; - - SegmentPtr _realData; ///< the primary data segment, points to a huge blob of binary data - SegmentRef data; ///< fake segment register always pointing to data segment - - DreamBase(DreamWeb::DreamWebEngine *en) : - engine(en), - _realData(new Segment()), - data(kDefaultDataSegment, _realData) { - } + DreamBase(DreamWeb::DreamWebEngine *en) : engine(en) { } public: // from pathfind.cpp @@ -66,6 +57,11 @@ public: // 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 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 kernChars(uint8 firstChar, uint8 secondChar, uint8 width); @@ -82,11 +78,36 @@ public: void dumpPointer(); void showRyanPage(); + // from vgafades.cpp + uint8 *mainPalette(); + uint8 *startPalette(); + uint8 *endPalette(); + void clearStartPal(); + void clearEndPal(); + void palToStartPal(); + void endPalToStart(); + void startPalToEnd(); + void palToEndPal(); + void doFade(); + void fadeCalculation(); + void fadeScreenUp(); + void fadeScreenUps(); + void fadeScreenUpHalf(); + void fadeScreenDown(); + void fadeScreenDowns(); + // from vgagrafx.cpp uint8 _workspace[(0x1000 + 2) * 16]; inline uint8 *workspace() { return _workspace; } void clearWork(); + uint8 *mapStore(); + void panelToMap(); + void mapToPanel(); + void dumpMap(); + + void transferInv(); + void multiGet(uint8 *dst, uint16 x, uint16 y, uint8 width, uint8 height); void multiPut(const uint8 *src, uint16 x, uint16 y, uint8 width, uint8 height); void multiDump(uint16 x, uint16 y, uint8 width, uint8 height); @@ -98,9 +119,12 @@ public: void frameOutBh(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y); void frameOutFx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y); void doShake(); + void vSync(); + void setMode(); void showPCX(const Common::String &name); 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 loadPalFromIFF(); void createPanel(); void createPanel2(); void showPanel(); diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index 965306313d..aff617e5ad 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -1116,30 +1116,6 @@ void DreamGenContext::transferMap() { _add(data.word(kExframepos), cx); } -void DreamGenContext::doFade() { - STACK_CHECK; - _cmp(data.byte(kFadedirection), 0); - if (flags.z()) - return /* (finishfade) */; - cl = data.byte(kNumtofade); - ch = 0; - al = data.byte(kColourpos); - ah = 0; - ds = data.word(kBuffers); - si = (0+(228*13)+32+60+(32*32)+(11*10*3)); - _add(si, ax); - _add(si, ax); - _add(si, ax); - showGroup(); - al = data.byte(kNumtofade); - _add(al, data.byte(kColourpos)); - data.byte(kColourpos) = al; - _cmp(al, 0); - if (!flags.z()) - return /* (finishfade) */; - fadeCalculation(); -} - void DreamGenContext::fadeToWhite() { STACK_CHECK; es = data.word(kBuffers); diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h index fe922cd959..a981fd8d78 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -536,7 +536,7 @@ static const uint16 kLenofreelrouts = (983-526); class DreamGenContext : public DreamBase, public Context { public: - DreamGenContext(DreamWeb::DreamWebEngine *en) : DreamBase(en), Context(data) {} + DreamGenContext(DreamWeb::DreamWebEngine *en) : DreamBase(en), Context(this) {} void __start(); #include "stubs.h" // Allow hand-reversed functions to have a signature different than void f() @@ -665,7 +665,6 @@ public: void drawItAll(); void useStereo(); void showOpBox(); - void doFade(); void dumpCurrent(); void showDiaryKeys(); void rollEndCredits2(); diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp index 451d8ff13d..717c0620f4 100644 --- a/engines/dreamweb/dreamweb.cpp +++ b/engines/dreamweb/dreamweb.cpp @@ -98,7 +98,7 @@ void DreamWebEngine::waitForVSync() { } _base.doShake(); - _context.doFade(); + _base.doFade(); _system->updateScreen(); } diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp index 1fc652f4b3..c554053fb7 100644 --- a/engines/dreamweb/print.cpp +++ b/engines/dreamweb/print.cpp @@ -24,7 +24,7 @@ namespace DreamGen { -void DreamGenContext::printBoth(const Frame *charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar) { +void DreamBase::printBoth(const Frame *charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar) { uint16 newX = *x; uint8 width, height; printChar(charSet, &newX, y, c, nextChar, &width, &height); @@ -57,7 +57,7 @@ uint8 DreamBase::getNextWord(const Frame *charSet, const uint8 *string, uint8 *t } } -void DreamGenContext::printChar(const Frame *charSet, uint16* x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) { +void DreamBase::printChar(const Frame *charSet, uint16* x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) { if (c == 255) return; @@ -75,7 +75,7 @@ void DreamGenContext::printChar(const Frame *charSet, uint16* x, uint16 y, uint8 (*x) += *width; } -void DreamGenContext::printChar(const Frame *charSet, uint16 x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) { +void DreamBase::printChar(const Frame *charSet, uint16 x, uint16 y, uint8 c, uint8 nextChar, uint8 *width, uint8 *height) { printChar(charSet, &x, y, c, nextChar, width, height); } @@ -125,16 +125,16 @@ void DreamGenContext::printDirect() { uint16 initialSi = si; const uint8 *initialString = es.ptr(si, 0); const uint8 *string = initialString; - al = printDirect(&string, di, &y, dl, (bool)(dl & 1)); + al = DreamBase::printDirect(&string, di, &y, dl, (bool)(dl & 1)); si = initialSi + (string - initialString); bx = y; } -uint8 DreamGenContext::printDirect(const uint8* string, uint16 x, uint16 y, uint8 maxWidth, bool centered) { +uint8 DreamBase::printDirect(const uint8* string, uint16 x, uint16 y, uint8 maxWidth, bool centered) { return printDirect(&string, x, &y, maxWidth, centered); } -uint8 DreamGenContext::printDirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered) { +uint8 DreamBase::printDirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered) { data.word(kLastxpos) = x; const Frame *charSet = engine->currentCharset(); while (true) { diff --git a/engines/dreamweb/runtime.h b/engines/dreamweb/runtime.h index a37fb56967..1ed7f39ad6 100644 --- a/engines/dreamweb/runtime.h +++ b/engines/dreamweb/runtime.h @@ -20,16 +20,15 @@ * */ -#ifndef DREAMGEN_RUNTIME_H__ -#define DREAMGEN_RUNTIME_H__ +#ifndef DREAMGEN_RUNTIME_H +#define DREAMGEN_RUNTIME_H #include <assert.h> #include "common/scummsys.h" #include "common/array.h" #include "common/debug.h" -#include "common/hashmap.h" -#include "common/list.h" -#include "common/ptr.h" + +#include "dreamweb/segment.h" namespace DreamGen { @@ -78,134 +77,6 @@ struct RegisterPart { typedef RegisterPart<0> HighPartOfRegister; #endif -class WordRef { - uint8 *_data; - unsigned _index; - uint16 _value; - -public: - inline WordRef(Common::Array<uint8> &data, unsigned index) : _data(data.begin() + index), _index(index) { - assert(index + 1 < data.size()); - _value = _data[0] | (_data[1] << 8); - } - - inline WordRef& operator=(const WordRef &ref) { - _value = ref._value; - return *this; - } - - inline WordRef& operator=(uint16 v) { - _value = v; - return *this; - } - - inline operator uint16&() { - return _value; - } - - inline ~WordRef() { - _data[0] = _value & 0xff; - _data[1] = _value >> 8; - _value = _data[0] | (_data[1] << 8); - } -}; - -class Segment { - Common::Array<uint8> data; - -public: - Segment(uint size = 0) { - if (size > 0) - data.resize(size); - } - - inline void assign(const uint8 *b, const uint8 *e) { - data.assign(b, e); - } - - inline uint8 &byte(unsigned index) { - assert(index < data.size()); - return data[index]; - } - - inline WordRef word(unsigned index) { - return WordRef(data, index); - } - - inline uint8 *ptr(unsigned index, unsigned size) { - assert(index + size <= data.size()); - return data.begin() + index; - } -}; - -typedef Common::SharedPtr<Segment> SegmentPtr; - -class Context; - -class SegmentRef { - uint16 _value; - SegmentPtr _segment; - -public: - SegmentRef(uint16 value = 0, SegmentPtr segment = SegmentPtr()) - : _value(value), _segment(segment) { - } - - inline operator uint16() const { - return _value; - } - - SegmentPtr getSegmentPtr() const { - return _segment; - } - - inline uint8 &byte(unsigned index) { - assert(_segment != 0); - return _segment->byte(index); - } - - inline WordRef word(unsigned index) { - //debug(1, "getting word ref for %04x:%d", _value, index); - assert(_segment != 0); - return _segment->word(index); - } - - inline void assign(const uint8 *b, const uint8 *e) { - assert(_segment != 0); - _segment->assign(b, e); - } - - inline uint8 *ptr(unsigned index, unsigned size) { - assert(_segment != 0); - return _segment->ptr(index, size); - } - -protected: - SegmentRef &operator=(const SegmentRef &seg) { - _value = seg._value; - _segment = seg._segment; - return *this; - } - -}; - -class MutableSegmentRef : public SegmentRef { -protected: - Context *_context; - -public: - MutableSegmentRef(Context *ctx, uint16 value = 0, SegmentPtr segment = SegmentPtr()) - : _context(ctx), SegmentRef(value, segment) { - } - - MutableSegmentRef(Context *ctx, SegmentRef seg) - : _context(ctx), SegmentRef(seg) { - } - - inline MutableSegmentRef& operator=(const uint16 id); - -}; - struct Flags { bool _z, _c, _s, _o; inline Flags(): _z(true), _c(false), _s(false), _o(false) {} @@ -239,15 +110,7 @@ struct Flags { }; class Context { - typedef Common::HashMap<uint16, SegmentPtr> SegmentMap; - SegmentMap _segments; - - typedef Common::List<uint16> FreeSegmentList; - FreeSegmentList _freeSegments; - public: - enum { kDefaultDataSegment = 0x1000 }; - Register ax, dx, bx, cx, si, di; LowPartOfRegister al; HighPartOfRegister ah; @@ -263,44 +126,11 @@ public: MutableSegmentRef es; Flags flags; - Context(SegmentRef data): al(ax), ah(ax), bl(bx), bh(bx), cl(cx), ch(cx), dl(dx), dh(dx), - cs(data), - ds(this, data), - es(this, data) { + Context(SegmentManager *segMan): al(ax), ah(ax), bl(bx), bh(bx), cl(cx), ch(cx), dl(dx), dh(dx), + cs(segMan->data), + ds(segMan, segMan->data), + es(segMan, segMan->data) { - _segments[kDefaultDataSegment] = data.getSegmentPtr(); - } - - SegmentRef getSegment(uint16 value) { - SegmentMap::iterator i = _segments.find(value); - if (i != _segments.end()) - return SegmentRef(value, i->_value); - else - return SegmentRef(value); - } - - SegmentRef allocateSegment(uint size) { - unsigned id; - if (_freeSegments.empty()) - id = kDefaultDataSegment + _segments.size(); - else { - id = _freeSegments.front(); - _freeSegments.pop_front(); - } - assert(!_segments.contains(id)); - SegmentPtr seg(new Segment(size)); - _segments[id] = seg; - return SegmentRef(id, seg); - } - - void deallocateSegment(uint16 id) { - SegmentMap::iterator i = _segments.find(id); - if(i != _segments.end()) { - _segments.erase(i); - _freeSegments.push_back(id); - } else { - debug("Deallocating non existent segment! Client code should be fixed."); - } } inline void _cmp(uint8 a, uint8 b) { @@ -574,11 +404,6 @@ public: } }; -inline MutableSegmentRef& MutableSegmentRef::operator=(const uint16 id) { - SegmentRef::operator=(_context->getSegment(id)); - return *this; -} - class StackChecker { const Context &_context; const uint _stackDepth; @@ -594,6 +419,6 @@ public: # define STACK_CHECK do {} while (0) #endif -} // End of namespace DreamWeb +} // End of namespace DreamGen #endif diff --git a/engines/dreamweb/segment.h b/engines/dreamweb/segment.h new file mode 100644 index 0000000000..9464015478 --- /dev/null +++ b/engines/dreamweb/segment.h @@ -0,0 +1,227 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef DREAMGEN_SEGMENT_H +#define DREAMGEN_SEGMENT_H + +#include "common/array.h" +#include "common/ptr.h" +#include "common/hashmap.h" +#include "common/list.h" + +namespace DreamGen { + +class WordRef { + uint8 *_data; + unsigned _index; + uint16 _value; + +public: + inline WordRef(Common::Array<uint8> &data, unsigned index) : _data(data.begin() + index), _index(index) { + assert(index + 1 < data.size()); + _value = _data[0] | (_data[1] << 8); + } + + inline WordRef& operator=(const WordRef &ref) { + _value = ref._value; + return *this; + } + + inline WordRef& operator=(uint16 v) { + _value = v; + return *this; + } + + inline operator uint16&() { + return _value; + } + + inline ~WordRef() { + _data[0] = _value & 0xff; + _data[1] = _value >> 8; + _value = _data[0] | (_data[1] << 8); + } +}; + +class Segment { + Common::Array<uint8> data; + +public: + Segment(uint size = 0) { + if (size > 0) + data.resize(size); + } + + inline void assign(const uint8 *b, const uint8 *e) { + data.assign(b, e); + } + + inline uint8 &byte(unsigned index) { + assert(index < data.size()); + return data[index]; + } + + inline WordRef word(unsigned index) { + return WordRef(data, index); + } + + inline uint8 *ptr(unsigned index, unsigned size) { + assert(index + size <= data.size()); + return data.begin() + index; + } +}; + +typedef Common::SharedPtr<Segment> SegmentPtr; + +class SegmentRef { + uint16 _value; + SegmentPtr _segment; + +public: + SegmentRef(uint16 value = 0, SegmentPtr segment = SegmentPtr()) + : _value(value), _segment(segment) { + } + + inline operator uint16() const { + return _value; + } + + SegmentPtr getSegmentPtr() const { + return _segment; + } + + inline uint8 &byte(unsigned index) { + assert(_segment != 0); + return _segment->byte(index); + } + + inline WordRef word(unsigned index) { + //debug(1, "getting word ref for %04x:%d", _value, index); + assert(_segment != 0); + return _segment->word(index); + } + + inline void assign(const uint8 *b, const uint8 *e) { + assert(_segment != 0); + _segment->assign(b, e); + } + + inline uint8 *ptr(unsigned index, unsigned size) { + assert(_segment != 0); + return _segment->ptr(index, size); + } + +protected: + SegmentRef &operator=(const SegmentRef &seg) { + _value = seg._value; + _segment = seg._segment; + return *this; + } + +}; + +class SegmentManager; + +class MutableSegmentRef : public SegmentRef { +protected: + SegmentManager *_segMan; + +public: + MutableSegmentRef(SegmentManager *segMan, uint16 value = 0, SegmentPtr segment = SegmentPtr()) + : _segMan(segMan), SegmentRef(value, segment) { + } + + MutableSegmentRef(SegmentManager *segMan, SegmentRef seg) + : _segMan(segMan), SegmentRef(seg) { + } + + inline MutableSegmentRef& operator=(const uint16 id); + +}; + + +class SegmentManager { +private: + typedef Common::HashMap<uint16, SegmentPtr> SegmentMap; + SegmentMap _segments; + + typedef Common::List<uint16> FreeSegmentList; + FreeSegmentList _freeSegments; + + enum { kDefaultDataSegment = 0x1000 }; + +public: + + SegmentPtr _realData; ///< the primary data segment, points to a huge blob of binary data + SegmentRef data; ///< fake segment register always pointing to data segment + +public: + SegmentManager() : + _realData(new Segment()), + data(kDefaultDataSegment, _realData) { + + _segments[kDefaultDataSegment] = data.getSegmentPtr(); + } + + SegmentRef getSegment(uint16 value) { + SegmentMap::iterator i = _segments.find(value); + if (i != _segments.end()) + return SegmentRef(value, i->_value); + else + return SegmentRef(value); + } + + SegmentRef allocateSegment(uint size) { + unsigned id; + if (_freeSegments.empty()) + id = kDefaultDataSegment + _segments.size(); + else { + id = _freeSegments.front(); + _freeSegments.pop_front(); + } + assert(!_segments.contains(id)); + SegmentPtr seg(new Segment(size)); + _segments[id] = seg; + return SegmentRef(id, seg); + } + + void deallocateSegment(uint16 id) { + SegmentMap::iterator i = _segments.find(id); + if(i != _segments.end()) { + _segments.erase(i); + _freeSegments.push_back(id); + } else { + debug("Deallocating non existent segment! Client code should be fixed."); + } + } + +}; + + +inline MutableSegmentRef& MutableSegmentRef::operator=(const uint16 id) { + SegmentRef::operator=(_segMan->getSegment(id)); + return *this; +} + +} // End of namespace DreamGen + +#endif diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 834aa850f4..7991742424 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -838,10 +838,6 @@ bool DreamGenContext::openForLoad(unsigned int slot) { return engine->openSaveFileForReading(filename); } -uint8 *DreamGenContext::mapStore() { - return getSegment(data.word(kMapstore)).ptr(0, 0); -} - void DreamGenContext::readMouse() { data.word(kOldbutton) = data.word(kMousebutton); uint16 state = readMouseState(); diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index ea2a74d37f..9e33b029c3 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -46,7 +46,6 @@ void hangOnCurs(uint16 frameCount); void hangOnCurs(); void workToScreen(); - uint8 *mapStore(); void multiGet(); void multiGet(uint8 *dst, uint16 x, uint16 y, uint8 width, uint8 height) { DreamBase::multiGet(dst, x, y, width, height); @@ -67,12 +66,13 @@ void seeCommandTail(); void randomNumber(); void quickQuit2(); - void printBoth(const Frame* charSet, uint16 *x, uint16 y, uint8 c, uint8 nextChar); - 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 printDirect(); - 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 printDirect(const uint8** string, uint16 x, uint16 *y, uint8 maxWidth, bool centered) { + return DreamBase::printDirect(string, x, y, maxWidth, centered); + } + uint8 printDirect(const uint8* string, uint16 x, uint16 y, uint8 maxWidth, bool centered) { + return DreamBase::printDirect(string, x, y, maxWidth, centered); + } void printMessage(uint16 x, uint16 y, uint8 index, uint8 maxWidth, bool centered); void printMessage(); void useTimedText(); @@ -84,7 +84,6 @@ void dumpTextLine(); void oldToNames(); void namesToOld(); - void loadPalFromIFF(); void startLoading(const Room &room); Sprite *spriteTable(); void showFrame(); @@ -215,11 +214,7 @@ void addToPeopleList(); void addToPeopleList(ReelRoutine *routine); void getExPos(); - void panelToMap(); - void mapToPanel(); - void dumpMap(); void obPicture(); - void transferInv(); void obIcons(); void compare(); bool compare(uint8 index, uint8 flag, const char id[4]); @@ -268,16 +263,6 @@ void transferText(); void initRain(); Rain *splitIntoLines(uint8 x, uint8 y, Rain *rain); - uint8 *mainPalette(); - uint8 *startPalette(); - uint8 *endPalette(); - void clearStartPal(); - void clearEndPal(); - void palToStartPal(); - void endPalToStart(); - void startPalToEnd(); - void palToEndPal(); - void fadeCalculation(); void watchCount(); void zoomIcon(); void loadRoom(); @@ -494,20 +479,13 @@ void readKey(); void hangOne(uint16 delay); void hangOne(); - void showPCX(const Common::String &name); void bibleQuote(); void realCredits(); void runIntroSeq(); void intro(); - void fadeScreenUp(); - void fadeScreenUps(); - void fadeScreenUpHalf(); - void fadeScreenDown(); - void fadeScreenDowns(); void clearBeforeLoad(); void clearReels(); void getRidOfReels(); - void setMode(); void liftNoise(uint8 index); void setTopLeft(); void setTopRight(); @@ -574,7 +552,6 @@ void dumpZoom(); void fadeDOS(); void selectLocation(); - void vSync(); void showGroup(); void loadSpeech(); void closeFile(); diff --git a/engines/dreamweb/vgafades.cpp b/engines/dreamweb/vgafades.cpp index a0d92c59c0..bb0bd21ed8 100644 --- a/engines/dreamweb/vgafades.cpp +++ b/engines/dreamweb/vgafades.cpp @@ -24,43 +24,56 @@ namespace DreamGen { -uint8 *DreamGenContext::mainPalette() { +uint8 *DreamBase::mainPalette() { return getSegment(data.word(kBuffers)).ptr(kMaingamepal, 256 * 3); } -uint8 *DreamGenContext::startPalette() { +uint8 *DreamBase::startPalette() { return getSegment(data.word(kBuffers)).ptr(kStartpal, 256 * 3); } -uint8 *DreamGenContext::endPalette() { +uint8 *DreamBase::endPalette() { return getSegment(data.word(kBuffers)).ptr(kEndpal, 256 * 3); } -void DreamGenContext::clearStartPal() { +void DreamBase::clearStartPal() { memset(startPalette(), 0, 256 * 3); } -void DreamGenContext::clearEndPal() { +void DreamBase::clearEndPal() { memset(endPalette(), 0, 256 * 3); } -void DreamGenContext::palToStartPal() { +void DreamBase::palToStartPal() { memcpy(startPalette(), mainPalette(), 256 * 3); } -void DreamGenContext::endPalToStart() { +void DreamBase::endPalToStart() { memcpy(startPalette(), endPalette(), 256 * 3); } -void DreamGenContext::startPalToEnd() { +void DreamBase::startPalToEnd() { memcpy(endPalette(), startPalette(), 256 * 3); } -void DreamGenContext::palToEndPal() { +void DreamBase::palToEndPal() { memcpy(endPalette(), mainPalette(), 256 * 3); } -void DreamGenContext::fadeCalculation() { +void DreamBase::doFade() { + if (data.byte(kFadedirection) == 0) + return + + engine->processEvents(); + uint8 *src = startPalette() + 3 * data.byte(kColourpos); + engine->setPalette(src, data.byte(kColourpos), data.byte(kNumtofade)); + + data.byte(kColourpos) += data.byte(kNumtofade); + if (data.byte(kColourpos) == 0) + fadeCalculation(); +} + +void DreamBase::fadeCalculation() { if (data.byte(kFadecount) == 0) { data.byte(kFadedirection) = 0; return; @@ -68,7 +81,7 @@ void DreamGenContext::fadeCalculation() { uint8 *startPal = startPalette(); const uint8 *endPal = endPalette(); - for (size_t i = 0; i < 256 * 3; ++i, ++si, ++di) { + for (size_t i = 0; i < 256 * 3; ++i) { uint8 s = startPal[i]; uint8 e = endPal[i]; if (s == e) @@ -108,7 +121,7 @@ void DreamGenContext::fadeupMonFirst() { hangOn(64); } -void DreamGenContext::fadeScreenUp() { +void DreamBase::fadeScreenUp() { clearStartPal(); palToEndPal(); data.byte(kFadedirection) = 1; @@ -117,8 +130,7 @@ void DreamGenContext::fadeScreenUp() { data.byte(kNumtofade) = 128; } - -void DreamGenContext::fadeScreenUps() { +void DreamBase::fadeScreenUps() { clearStartPal(); palToEndPal(); data.byte(kFadedirection) = 1; @@ -127,7 +139,7 @@ void DreamGenContext::fadeScreenUps() { data.byte(kNumtofade) = 64; } -void DreamGenContext::fadeScreenUpHalf() { +void DreamBase::fadeScreenUpHalf() { endPalToStart(); palToEndPal(); data.byte(kFadedirection) = 1; @@ -136,7 +148,7 @@ void DreamGenContext::fadeScreenUpHalf() { data.byte(kNumtofade) = 32; } -void DreamGenContext::fadeScreenDown() { +void DreamBase::fadeScreenDown() { palToStartPal(); clearEndPal(); data.byte(kFadedirection) = 1; @@ -145,7 +157,7 @@ void DreamGenContext::fadeScreenDown() { data.byte(kNumtofade) = 128; } -void DreamGenContext::fadeScreenDowns() { +void DreamBase::fadeScreenDowns() { palToStartPal(); clearEndPal(); data.byte(kFadedirection) = 1; diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp index 4c3ba57e6c..8d303d1a04 100644 --- a/engines/dreamweb/vgagrafx.cpp +++ b/engines/dreamweb/vgagrafx.cpp @@ -178,32 +178,16 @@ void DreamBase::doShake() { engine->setShakePos(offset >= 0 ? offset : -offset); } -void DreamGenContext::vSync() { - push(ax); - push(bx); - push(cx); - push(dx); - push(si); - push(di); - push(es); - push(ds); +void DreamBase::vSync() { engine->waitForVSync(); - ds = pop(); - es = pop(); - di = pop(); - si = pop(); - dx = pop(); - cx = pop(); - bx = pop(); - ax = pop(); } -void DreamGenContext::setMode() { +void DreamBase::setMode() { vSync(); initGraphics(320, 200, false); } -void DreamGenContext::showPCX(const Common::String &name) { +void DreamBase::showPCX(const Common::String &name) { Common::File pcxFile; if (!pcxFile.open(name)) { @@ -415,19 +399,23 @@ void DreamGenContext::zoom() { data.byte(kDidzoom) = 1; } -void DreamGenContext::panelToMap() { +uint8 *DreamBase::mapStore() { + return getSegment(data.word(kMapstore)).ptr(0, 0); +} + +void DreamBase::panelToMap() { multiGet(mapStore(), data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize)); } -void DreamGenContext::mapToPanel() { +void DreamBase::mapToPanel() { multiPut(mapStore(), data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize)); } -void DreamGenContext::dumpMap() { +void DreamBase::dumpMap() { multiDump(data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize)); } -void DreamGenContext::transferInv() { +void DreamBase::transferInv() { const Frame *freeFrames = (const Frame *)getSegment(data.word(kFreeframes)).ptr(kFrframedata, 0); const Frame *freeFrame = freeFrames + (3 * data.byte(kItemtotran) + 1); Frame *exFrames = (Frame *)getSegment(data.word(kExtras)).ptr(kExframedata, 0); @@ -453,7 +441,7 @@ bool DreamGenContext::pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y) { return *ptr != 0; } -void DreamGenContext::loadPalFromIFF() { +void DreamBase::loadPalFromIFF() { engine->openFile("DREAMWEB.PAL"); engine->readFromFile(mapStore(), 2000); engine->closeFile(); |