aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2011-12-07 10:23:21 -0800
committerWillem Jan Palenstijn2011-12-07 10:23:21 -0800
commit9e617d0dfddf91e5802c783fae5be679afe22b05 (patch)
tree5e9eb811689cb5e21b7ec41b0b14674d422da092 /engines
parentc1b7d25bb7cd8f718d79b47c6b4a12caed904dde (diff)
parent28ba2071e44b15ecb4c20ee682a9e2bbafe67ab9 (diff)
downloadscummvm-rg350-9e617d0dfddf91e5802c783fae5be679afe22b05.tar.gz
scummvm-rg350-9e617d0dfddf91e5802c783fae5be679afe22b05.tar.bz2
scummvm-rg350-9e617d0dfddf91e5802c783fae5be679afe22b05.zip
Merge pull request #127 from fingolfin/dreamweb-cleanup
Dreamweb: Remove more dead stuff, advance DreamBase <-> DreamGenContext split
Diffstat (limited to 'engines')
-rw-r--r--engines/dreamweb/dreambase.h47
-rw-r--r--engines/dreamweb/dreamgen.cpp21
-rw-r--r--engines/dreamweb/dreamgen.h4
-rw-r--r--engines/dreamweb/dreamweb.cpp71
-rw-r--r--engines/dreamweb/dreamweb.h6
-rw-r--r--engines/dreamweb/monitor.cpp12
-rw-r--r--engines/dreamweb/object.cpp2
-rw-r--r--engines/dreamweb/pathfind.cpp25
-rw-r--r--engines/dreamweb/people.cpp6
-rw-r--r--engines/dreamweb/runtime.h26
-rw-r--r--engines/dreamweb/saveload.cpp6
-rw-r--r--engines/dreamweb/sprite.cpp4
-rw-r--r--engines/dreamweb/stubs.cpp90
-rw-r--r--engines/dreamweb/stubs.h42
-rw-r--r--engines/dreamweb/vgagrafx.cpp45
15 files changed, 200 insertions, 207 deletions
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 4173499203..99cb8476e1 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -34,26 +34,58 @@ namespace DreamWeb {
namespace DreamGen {
+/**
+ * This class is one of the parent classes of DreamGenContext. Its sole purpose
+ * is to allow us to incrementally move things out of DreamGenContext into this
+ * base class, as soon as they don't modify any context registers (ax, bx, cx, ...)
+ * anymore.
+ * Ultimately, DreamGenContext should be empty, at which point it can be removed
+ * together with class Context. When that happens, we can probably merge
+ * DreamBase into DreamWebEngine.
+ */
class DreamBase {
+protected:
+ DreamWeb::DreamWebEngine *engine;
+
public:
enum { kDefaultDataSegment = 0x1000 };
- DreamWeb::DreamWebEngine *engine;
-
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() : _realData(new Segment()), data(kDefaultDataSegment, _realData) {
+ DreamBase(DreamWeb::DreamWebEngine *en) :
+ engine(en),
+ _realData(new Segment()),
+ data(kDefaultDataSegment, _realData) {
}
-
public:
+ // from pathfind.cpp
+ Common::Point _lineData[200]; // Output of Bresenham
+ void checkDest(const RoomPaths *roomsPaths);
+
// from print.cpp
uint8 getNextWord(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount);
uint8 getNumber(const Frame *charSet, const uint8 *string, uint16 maxWidth, bool centered, uint16 *offset);
uint8 kernChars(uint8 firstChar, uint8 secondChar, uint8 width);
+ // from stubs.cpp
+ void crosshair();
+ void showBlink();
+ void dumpBlink();
+ void dumpPointer();
+ void showRyanPage();
+ void volumeAdjust();
+
// from vgagrafx.cpp
+ uint8 _workspace[(0x1000 + 2) * 16];
+ inline uint8 *workspace() { return _workspace; }
+ void clearWork();
+
+ 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);
+ void workToScreenCPP();
void printUnderMon();
void cls();
void frameOutV(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, int16 x, int16 y);
@@ -62,8 +94,11 @@ public:
void frameOutFx(uint8 *dst, const uint8 *src, uint16 pitch, uint16 width, uint16 height, uint16 x, uint16 y);
void doShake();
void showPCX(const Common::String &name);
-
-// TODO: Move more methods from stubs.h to here.
+ 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 createPanel();
+ void createPanel2();
+ void showPanel();
};
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index d7669c60d4..b5094dfb1a 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -7141,27 +7141,6 @@ tensc:
cs.byte(di+7) = al;
}
-void DreamGenContext::volumeAdjust() {
- STACK_CHECK;
- al = data.byte(kVolumedirection);
- _cmp(al, 0);
- if (flags.z())
- return /* (volok) */;
- al = data.byte(kVolume);
- _cmp(al, data.byte(kVolumeto));
- if (flags.z())
- goto volfinish;
- _add(data.byte(kVolumecount), 64);
- if (!flags.z())
- return /* (volok) */;
- al = data.byte(kVolume);
- _add(al, data.byte(kVolumedirection));
- data.byte(kVolume) = al;
- return;
-volfinish:
- data.byte(kVolumedirection) = 0;
-}
-
void DreamGenContext::entryTexts() {
STACK_CHECK;
_cmp(data.byte(kLocation), 21);
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 98aab6e2c6..572564c6cb 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -538,7 +538,7 @@ static const uint16 kLenofreelrouts = (983-526);
class DreamGenContext : public DreamBase, public Context {
public:
- DreamGenContext() : DreamBase(), Context(_realData) {}
+ DreamGenContext(DreamWeb::DreamWebEngine *en) : DreamBase(en), Context(data) {}
void __start();
#include "stubs.h" // Allow hand-reversed functions to have a signature different than void f()
@@ -560,7 +560,6 @@ public:
void watchReel();
void openFileFromC();
void getTime();
- void fadeDOS();
void findText1();
void isRyanHolding();
void showSlots();
@@ -759,7 +758,6 @@ public:
void alleyBarkSound();
void quitKey();
void processTrigger();
- void volumeAdjust();
void transferConToEx();
void adjustDown();
void withWhat();
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 2220cdb47a..df39c4dfd6 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -42,9 +42,8 @@
namespace DreamWeb {
DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gameDesc) :
- Engine(syst), _gameDescription(gameDesc), _rnd("dreamweb") {
+ Engine(syst), _gameDescription(gameDesc), _rnd("dreamweb"), _context(this), _base(_context) {
- _context.engine = this;
// Setup mixer
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
@@ -101,14 +100,14 @@ void DreamWebEngine::waitForVSync() {
setVSyncInterrupt(false);
}
- _context.doShake();
+ _base.doShake();
_context.doFade();
_system->updateScreen();
}
void DreamWebEngine::quit() {
- _context.data.byte(DreamGen::kQuitrequested) = 1;
- _context.data.byte(DreamGen::kLasthardkey) = 1;
+ _base.data.byte(DreamGen::kQuitrequested) = 1;
+ _base.data.byte(DreamGen::kLasthardkey) = 1;
}
void DreamWebEngine::processEvents() {
@@ -144,8 +143,8 @@ void DreamWebEngine::processEvents() {
break;
case Common::KEYCODE_c: //skip statue puzzle
- _context.data.byte(DreamGen::kSymbolbotnum) = 3;
- _context.data.byte(DreamGen::kSymboltopnum) = 5;
+ _base.data.byte(DreamGen::kSymbolbotnum) = 3;
+ _base.data.byte(DreamGen::kSymboltopnum) = 5;
break;
default:
@@ -175,7 +174,7 @@ void DreamWebEngine::processEvents() {
break;
}
- _context.data.byte(DreamGen::kLasthardkey) = hardKey;
+ _base.data.byte(DreamGen::kLasthardkey) = hardKey;
// The rest of the keys are converted to ASCII. This
// is fairly restrictive, and eventually we may want
@@ -219,7 +218,7 @@ Common::Error DreamWebEngine::run() {
getTimerManager()->installTimerProc(vSyncInterrupt, 1000000 / 70, this, "dreamwebVSync");
_context.__start();
- _context.data.byte(DreamGen::kQuitrequested) = 0;
+ _base.data.byte(DreamGen::kQuitrequested) = 0;
getTimerManager()->removeTimerProc(vSyncInterrupt);
@@ -298,13 +297,13 @@ uint DreamWebEngine::readFromSaveFile(uint8 *data, uint size) {
void DreamWebEngine::keyPressed(uint16 ascii) {
debug(2, "key pressed = %04x", ascii);
- uint16 in = (_context.data.word(DreamGen::kBufferin) + 1) & 0x0f;
- uint16 out = _context.data.word(DreamGen::kBufferout);
+ uint16 in = (_base.data.word(DreamGen::kBufferin) + 1) & 0x0f;
+ uint16 out = _base.data.word(DreamGen::kBufferout);
if (in == out) {
warning("keyboard buffer is full");
return;
}
- _context.data.word(DreamGen::kBufferin) = in;
+ _base.data.word(DreamGen::kBufferin) = in;
DreamGen::g_keyBuffer[in] = ascii;
}
@@ -328,33 +327,6 @@ void DreamWebEngine::mouseCall(uint16 *x, uint16 *y, uint16 *state) {
_oldMouseState = newState;
}
-void DreamWebEngine::fadeDos() {
- _context.ds = _context.es = _context.data.word(DreamGen::kBuffers);
- return; //fixme later
- waitForVSync();
- //processEvents will be called from vsync
- uint8 *dst = _context.es.ptr(DreamGen::kStartpal, 768);
- getPalette(dst, 0, 64);
- for(int fade = 0; fade < 64; ++fade) {
- for(int c = 0; c < 768; ++c) { //original sources decrement 768 values -> 256 colors
- if (dst[c]) {
- --dst[c];
- }
- }
- setPalette(dst, 0, 64);
- waitForVSync();
- }
-}
-
-void DreamWebEngine::setPalette() {
- processEvents();
- unsigned n = (uint16)_context.cx;
- uint8 *src = _context.ds.ptr(_context.si, n * 3);
- setPalette(src, _context.al, n);
- _context.si += n * 3;
- _context.cx = 0;
-}
-
void DreamWebEngine::getPalette(uint8 *data, uint start, uint count) {
_system->getPaletteManager()->grabPalette(data, start, count);
while(count--)
@@ -381,8 +353,7 @@ void DreamWebEngine::blit(const uint8 *src, int pitch, int x, int y, int w, int
}
void DreamWebEngine::printUnderMonitor() {
- uint8 *workspace = _context.workspace();
- uint8 *dst = workspace + DreamGen::kScreenwidth * 43 + 76;
+ uint8 *dst = _base._workspace + DreamGen::kScreenwidth * 43 + 76;
Graphics::Surface *s = _system->lockScreen();
if (!s)
@@ -490,12 +461,10 @@ bool DreamWebEngine::loadSpeech(const Common::String &filename) {
}
void DreamWebEngine::soundHandler() {
- _context.data.byte(DreamGen::kSubtitles) = ConfMan.getBool("subtitles");
- _context.push(_context.ax);
- _context.volumeAdjust();
- _context.ax = _context.pop();
+ _base.data.byte(DreamGen::kSubtitles) = ConfMan.getBool("subtitles");
+ _base.volumeAdjust();
- uint volume = _context.data.byte(DreamGen::kVolume);
+ uint volume = _base.data.byte(DreamGen::kVolume);
//.vol file loaded into soundbuf:0x4000
//volume table at (volume * 0x100 + 0x3f00)
//volume value could be from 1 to 7
@@ -511,13 +480,13 @@ void DreamWebEngine::soundHandler() {
volume = (8 - volume) * Audio::Mixer::kMaxChannelVolume / 8;
_mixer->setChannelVolume(_channelHandle[0], volume);
- uint8 ch0 = _context.data.byte(DreamGen::kCh0playing);
+ uint8 ch0 = _base.data.byte(DreamGen::kCh0playing);
if (ch0 == 255)
ch0 = 0;
- uint8 ch1 = _context.data.byte(DreamGen::kCh1playing);
+ uint8 ch1 = _base.data.byte(DreamGen::kCh1playing);
if (ch1 == 255)
ch1 = 0;
- uint8 ch0loop = _context.data.byte(DreamGen::kCh0repeat);
+ uint8 ch0loop = _base.data.byte(DreamGen::kCh0repeat);
if (_channel0 != ch0) {
_channel0 = ch0;
@@ -532,11 +501,11 @@ void DreamWebEngine::soundHandler() {
}
}
if (!_mixer->isSoundHandleActive(_channelHandle[0])) {
- _context.data.byte(DreamGen::kCh0playing) = 255;
+ _base.data.byte(DreamGen::kCh0playing) = 255;
_channel0 = 0;
}
if (!_mixer->isSoundHandleActive(_channelHandle[1])) {
- _context.data.byte(DreamGen::kCh1playing) = 255;
+ _base.data.byte(DreamGen::kCh1playing) = 255;
_channel1 = 0;
}
diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h
index b8fb315498..1d16a188d2 100644
--- a/engines/dreamweb/dreamweb.h
+++ b/engines/dreamweb/dreamweb.h
@@ -48,9 +48,6 @@ namespace DreamGen {
const uint16 addr_backobject = 0xc170;
const uint16 addr_mainman = 0xc138;
-// Output of Bresenham
-extern Common::Point g_lineData[200];
-
// Keyboard buffer. data.word(kBufferin) and data.word(kBufferout) are indexes
// into this, making it a ring buffer
extern uint8 g_keyBuffer[16];
@@ -101,8 +98,6 @@ public:
void mouseCall(uint16 *x, uint16 *y, uint16 *state); //fill mouse pos and button state
void processEvents();
- void setPalette();
- void fadeDos();
void blit(const uint8 *src, int pitch, int x, int y, int w, int h);
void cls();
@@ -185,6 +180,7 @@ private:
DreamGen::Frame *_currentCharset;
DreamGen::DreamGenContext _context;
+ DreamGen::DreamBase &_base;
};
} // End of namespace DreamWeb
diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp
index c813037ddb..f552b71c00 100644
--- a/engines/dreamweb/monitor.cpp
+++ b/engines/dreamweb/monitor.cpp
@@ -32,10 +32,10 @@ struct MonitorKeyEntry {
void DreamGenContext::useMon() {
data.byte(kLasttrigger) = 0;
- memset(cs.ptr(kCurrentfile+1, 0), ' ', 12);
- memset(cs.ptr(offset_operand1+1, 0), ' ', 12);
+ memset(data.ptr(kCurrentfile+1, 0), ' ', 12);
+ memset(data.ptr(offset_operand1+1, 0), ' ', 12);
- MonitorKeyEntry *monitorKeyEntries = (MonitorKeyEntry *)cs.ptr(offset_keys, 0);
+ MonitorKeyEntry *monitorKeyEntries = (MonitorKeyEntry *)data.ptr(offset_keys, 0);
monitorKeyEntries[0].b0 = 1;
monitorKeyEntries[1].b0 = 0;
monitorKeyEntries[2].b0 = 0;
@@ -103,7 +103,7 @@ void DreamGenContext::printLogo() {
}
void DreamGenContext::input() {
- char *inputLine = (char *)cs.ptr(kInputline, 64);
+ char *inputLine = (char *)data.ptr(kInputline, 64);
memset(inputLine, 0, 64);
data.word(kCurpos) = 0;
printChar(engine->tempCharset(), data.word(kMonadx), data.word(kMonady), '>', 0, NULL, NULL);
@@ -149,7 +149,7 @@ void DreamGenContext::input() {
}
void DreamGenContext::delChar() {
- char *inputLine = (char *)cs.ptr(kInputline, 0);
+ char *inputLine = (char *)data.ptr(kInputline, 0);
--data.word(kCurpos);
inputLine[data.word(kCurpos) * 2] = 0;
uint8 width = inputLine[data.word(kCurpos) * 2 + 1];
@@ -204,7 +204,7 @@ void DreamGenContext::scrollMonitor() {
void DreamGenContext::showCurrentFile() {
uint16 x = 178; // TODO: Looks like this hardcoded constant in the asm doesn't match the frame
- const char *currentFile = (const char *)cs.ptr(kCurrentfile+1, 0);
+ const char *currentFile = (const char *)data.ptr(kCurrentfile+1, 0);
while (*currentFile) {
char c = *currentFile++;
c = engine->modifyChar(c);
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index 02526b583d..44be58c168 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -167,7 +167,7 @@ void DreamGenContext::examineOb(bool examineAgain) {
{ 273,320,157,198,&DreamGenContext::getBackFromOb },
{ 255,294,0,24,&DreamGenContext::dropObject },
{ kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamGenContext::incRyanPage },
- { kInventx, cs.word(offset_openchangesize),kInventy+100,kInventy+100+kItempicsize,&DreamGenContext::useOpened },
+ { kInventx, data.word(offset_openchangesize),kInventy+100,kInventy+100+kItempicsize,&DreamGenContext::useOpened },
{ kInventx,kInventx+(5*kItempicsize), kInventy,kInventy+(2*kItempicsize),&DreamGenContext::inToInv },
{ 0,320,0,200,&DreamGenContext::blank },
{ 0xFFFF,0,0,0,0 }
diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp
index 986cdbeb8f..ff2659c235 100644
--- a/engines/dreamweb/pathfind.cpp
+++ b/engines/dreamweb/pathfind.cpp
@@ -24,10 +24,6 @@
namespace DreamGen {
-// Output of Bresenham
-Common::Point g_lineData[200];
-
-
void DreamGenContext::turnPathOn() {
turnPathOn(al);
}
@@ -105,8 +101,7 @@ void DreamGenContext::setWalk() {
}
void DreamGenContext::autoSetWalk() {
- al = data.byte(kManspath);
- if (data.byte(kFinaldest) == al)
+ if (data.byte(kFinaldest) == data.byte(kManspath))
return;
const RoomPaths *roomsPaths = getRoomsPaths();
checkDest(roomsPaths);
@@ -123,21 +118,19 @@ void DreamGenContext::autoSetWalk() {
data.byte(kLinepointer) = 0;
}
-void DreamGenContext::checkDest(const RoomPaths *roomsPaths) {
+void DreamBase::checkDest(const RoomPaths *roomsPaths) {
const PathSegment *segments = roomsPaths->segments;
- ah = data.byte(kManspath) << 4;
- al = data.byte(kDestination);
+ const uint8 tmp = data.byte(kManspath) << 4;
uint8 destination = data.byte(kDestination);
for (size_t i = 0; i < 24; ++i) {
- dh = segments[i].b0 & 0xf0;
- dl = segments[i].b0 & 0x0f;
- if (ax == dx) {
+ if ((segments[i].b0 & 0xf0) == tmp &&
+ (segments[i].b0 & 0x0f) == data.byte(kDestination)) {
data.byte(kDestination) = segments[i].b1 & 0x0f;
return;
}
- dl = (segments[i].b0 & 0xf0) >> 4;
- dh = (segments[i].b0 & 0x0f) << 4;
- if (ax == dx) {
+
+ if (((segments[i].b0 & 0x0f) << 4) == tmp &&
+ ((segments[i].b0 & 0xf0) >> 4) == data.byte(kDestination)) {
destination = segments[i].b1 & 0x0f;
}
}
@@ -162,7 +155,7 @@ bool DreamGenContext::checkIfPathIsOn(uint8 index) {
void DreamGenContext::bresenhams() {
workoutFrames();
- Common::Point *lineData = &g_lineData[0];
+ Common::Point *lineData = &_lineData[0];
int16 startX = (int16)data.word(kLinestartx);
int16 startY = (int16)data.word(kLinestarty);
int16 endX = (int16)data.word(kLineendx);
diff --git a/engines/dreamweb/people.cpp b/engines/dreamweb/people.cpp
index 6e2128e391..d1814ce8b9 100644
--- a/engines/dreamweb/people.cpp
+++ b/engines/dreamweb/people.cpp
@@ -96,8 +96,8 @@ void DreamGenContext::updatePeople() {
// The original callbacks are called with es:bx pointing to their reelRoutine entry.
// The new callbacks take a mutable ReelRoutine parameter.
- es = cs;
- ReelRoutine *r = (ReelRoutine *)cs.ptr(kReelroutines, 0);
+ es = data;
+ ReelRoutine *r = (ReelRoutine *)data.ptr(kReelroutines, 0);
for (int i = 0; r[i].reallocation != 255; ++i) {
bx = kReelroutines + 8*i;
@@ -196,7 +196,7 @@ void DreamGenContext::addToPeopleList() {
}
void DreamGenContext::addToPeopleList(ReelRoutine *routine) {
- uint16 routinePointer = (const uint8 *)routine - cs.ptr(0, 0);
+ uint16 routinePointer = (const uint8 *)routine - data.ptr(0, 0);
People *people = (People *)getSegment(data.word(kBuffers)).ptr(data.word(kListpos), sizeof(People));
people->setReelPointer(routine->reelPointer());
diff --git a/engines/dreamweb/runtime.h b/engines/dreamweb/runtime.h
index 48f7c88a20..a37fb56967 100644
--- a/engines/dreamweb/runtime.h
+++ b/engines/dreamweb/runtime.h
@@ -151,15 +151,19 @@ public:
: _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 operator uint16() const {
- return _value;
- }
-
inline WordRef word(unsigned index) {
//debug(1, "getting word ref for %04x:%d", _value, index);
assert(_segment != 0);
@@ -194,6 +198,10 @@ public:
: _context(ctx), SegmentRef(value, segment) {
}
+ MutableSegmentRef(Context *ctx, SegmentRef seg)
+ : _context(ctx), SegmentRef(seg) {
+ }
+
inline MutableSegmentRef& operator=(const uint16 id);
};
@@ -255,12 +263,12 @@ public:
MutableSegmentRef es;
Flags flags;
- Context(SegmentPtr realData): al(ax), ah(ax), bl(bx), bh(bx), cl(cx), ch(cx), dl(dx), dh(dx),
- cs(kDefaultDataSegment, realData),
- ds(this, kDefaultDataSegment, realData),
- es(this, kDefaultDataSegment, realData) {
+ 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) {
- _segments[kDefaultDataSegment] = realData;
+ _segments[kDefaultDataSegment] = data.getSegmentPtr();
}
SegmentRef getSegment(uint16 value) {
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp
index 9bc24f2631..45a1c8ef7a 100644
--- a/engines/dreamweb/saveload.cpp
+++ b/engines/dreamweb/saveload.cpp
@@ -219,11 +219,11 @@ void DreamGenContext::saveGame() {
}
void DreamGenContext::namesToOld() {
- memcpy(getSegment(data.word(kBuffers)).ptr(kZoomspace, 0), cs.ptr(kSavenames, 0), 17*4);
+ memcpy(getSegment(data.word(kBuffers)).ptr(kZoomspace, 0), data.ptr(kSavenames, 0), 17*4);
}
void DreamGenContext::oldToNames() {
- memcpy(cs.ptr(kSavenames, 0), getSegment(data.word(kBuffers)).ptr(kZoomspace, 0), 17*4);
+ memcpy(data.ptr(kSavenames, 0), getSegment(data.word(kBuffers)).ptr(kZoomspace, 0), 17*4);
}
void DreamGenContext::saveLoad() {
@@ -377,7 +377,7 @@ void DreamGenContext::loadPosition(unsigned int slot) {
engine->readFromSaveFile((uint8 *)&g_madeUpRoomDat, sizeof(Room));
engine->readFromSaveFile(data.ptr(kRoomscango, 16), 16);
- engine->readFromSaveFile(cs.ptr(kReelroutines, len[5]), len[5]);
+ engine->readFromSaveFile(data.ptr(kReelroutines, len[5]), len[5]);
closeFile();
}
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index 9f3666312a..14794a81a8 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -196,8 +196,8 @@ void DreamGenContext::walking(Sprite *sprite) {
comp = data.byte(kLinelength);
}
if (data.byte(kLinepointer) < comp) {
- sprite->x = (uint8)g_lineData[data.byte(kLinepointer)].x;
- sprite->y = (uint8)g_lineData[data.byte(kLinepointer)].y;
+ sprite->x = (uint8)_lineData[data.byte(kLinepointer)].x;
+ sprite->y = (uint8)_lineData[data.byte(kLinepointer)].y;
return;
}
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 75adc72c44..6d13ed6378 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -735,11 +735,6 @@ void DreamGenContext::switchRyanOff() {
data.byte(kRyanon) = 1;
}
-Common::String DreamGenContext::getFilename(Context &context) {
- const char *name = (const char *)context.cs.ptr(context.dx, 0);
- return Common::String(name);
-}
-
uint8 *DreamGenContext::textUnder() {
return getSegment(data.word(kBuffers)).ptr(kTextunder, 0);
}
@@ -770,7 +765,7 @@ void *DreamGenContext::standardLoadCPP(const char *fileName, uint16 *outSizeInBy
}
void DreamGenContext::loadIntoTemp() {
- loadIntoTemp((const char *)cs.ptr(dx, 0));
+ loadIntoTemp((const char *)data.ptr(dx, 0));
}
void DreamGenContext::loadIntoTemp(const char *fileName) {
@@ -786,7 +781,7 @@ void DreamGenContext::loadIntoTemp3(const char *fileName) {
}
void DreamGenContext::loadTempCharset() {
- loadTempCharset((const char *)cs.ptr(dx, 0));
+ loadTempCharset((const char *)data.ptr(dx, 0));
}
void DreamGenContext::loadTempCharset(const char *fileName) {
@@ -1105,13 +1100,33 @@ void DreamGenContext::set16ColPalette() {
}
void DreamGenContext::showGroup() {
- engine->setPalette();
+ engine->processEvents();
+ unsigned n = (uint16)cx;
+ uint8 *src = ds.ptr(si, n * 3);
+ engine->setPalette(src, al, n);
+ si += n * 3;
+ cx = 0;
}
void DreamGenContext::fadeDOS() {
- engine->fadeDos();
+ ds = es = data.word(kBuffers);
+ return; //fixme later
+ engine->waitForVSync();
+ //processEvents will be called from vsync
+ uint8 *dst = es.ptr(kStartpal, 768);
+ engine->getPalette(dst, 0, 64);
+ for(int fade = 0; fade < 64; ++fade) {
+ for(int c = 0; c < 768; ++c) { //original sources decrement 768 values -> 256 colors
+ if (dst[c]) {
+ --dst[c];
+ }
+ }
+ engine->setPalette(dst, 0, 64);
+ engine->waitForVSync();
+ }
}
+
void DreamGenContext::eraseOldObs() {
if (data.byte(kNewobs) == 0)
return;
@@ -1125,10 +1140,6 @@ void DreamGenContext::eraseOldObs() {
}
}
-void DreamGenContext::modifyChar() {
- al = engine->modifyChar(al);
-}
-
void DreamGenContext::lockMon() {
// Pressing space pauses text output in the monitor. We use the "hard"
// key because calling readkey() drains characters from the input
@@ -1195,14 +1206,20 @@ uint16 DreamGenContext::allocateAndLoad(unsigned int size) {
return result;
}
-void DreamGenContext::clearAndLoad(uint16 seg, uint8 c,
+void DreamGenContext::clearAndLoad(uint8 *buf, uint8 c,
unsigned int size, unsigned int maxSize) {
assert(size <= maxSize);
- uint8 *buf = getSegment(seg).ptr(0, maxSize);
memset(buf, c, maxSize);
engine->readFromFile(buf, size);
}
+void DreamGenContext::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 DreamGenContext::startLoading(const Room &room) {
data.byte(kCombatcount) = 0;
data.byte(kRoomssample) = room.roomsSample;
@@ -1246,10 +1263,6 @@ void DreamGenContext::startLoading(const Room &room) {
findXYFromPath();
}
-void DreamGenContext::fillSpace() {
- memset(ds.ptr(dx, cx), al, cx);
-}
-
void DreamGenContext::dealWithSpecial(uint8 firstParam, uint8 secondParam) {
uint8 type = firstParam - 220;
if (type == 0) {
@@ -1299,7 +1312,7 @@ void DreamGenContext::plotReel() {
es = pop();
}
-void DreamGenContext::crosshair() {
+void DreamBase::crosshair() {
uint8 frame;
if ((data.byte(kCommandtype) != 3) && (data.byte(kCommandtype) < 10)) {
frame = 9;
@@ -1418,7 +1431,7 @@ const uint8 *DreamGenContext::findObName(uint8 type, uint8 index) {
}
void DreamGenContext::copyName() {
- copyName(ah, al, cs.ptr(di, 0));
+ copyName(ah, al, data.ptr(di, 0));
}
void DreamGenContext::copyName(uint8 type, uint8 index, uint8 *dst) {
@@ -1460,11 +1473,6 @@ void DreamGenContext::examineObText() {
commandWithOb(1, data.byte(kCommandtype), data.byte(kCommand));
}
-void DreamGenContext::showPanel() {
- showFrame(engine->icons1(), 72, 0, 19, 0);
- showFrame(engine->icons1(), 192, 0, 19, 0);
-}
-
void DreamGenContext::blockNameText() {
commandWithOb(0, data.byte(kCommandtype), data.byte(kCommand));
}
@@ -1728,7 +1736,7 @@ void DreamGenContext::delPointer() {
multiPut(getSegment(data.word(kBuffers)).ptr(kPointerback, 0), data.word(kDelherex), data.word(kDelherey), data.byte(kPointerxs), data.byte(kPointerys));
}
-void DreamGenContext::showBlink() {
+void DreamBase::showBlink() {
if (data.byte(kManisoffscreen) == 1)
return;
++data.byte(kBlinkcount);
@@ -1749,7 +1757,7 @@ void DreamGenContext::showBlink() {
showFrame(engine->icons1(), 44, 32, blinkTab[blinkFrame], 0, &width, &height);
}
-void DreamGenContext::dumpBlink() {
+void DreamBase::dumpBlink() {
if (data.byte(kShadeson) != 0)
return;
if (data.byte(kBlinkcount) != 0)
@@ -1759,7 +1767,7 @@ void DreamGenContext::dumpBlink() {
multiDump(44, 32, 16, 12);
}
-void DreamGenContext::dumpPointer() {
+void DreamBase::dumpPointer() {
dumpBlink();
multiDump(data.word(kDelherex), data.word(kDelherey), data.byte(kDelxs), data.byte(kDelys));
if ((data.word(kOldpointerx) != data.word(kDelherex)) || (data.word(kOldpointery) != data.word(kDelherey)))
@@ -2040,7 +2048,7 @@ bool DreamGenContext::checkIfSet(uint8 x, uint8 y) {
return false;
}
-void DreamGenContext::showRyanPage() {
+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);
}
@@ -2438,6 +2446,19 @@ Frame * DreamGenContext::tempGraphics3() {
return (Frame *)getSegment(data.word(kTempgraphics3)).ptr(0, 0);
}
+void DreamBase::volumeAdjust() {
+ if (data.byte(kVolumedirection) == 0)
+ return;
+ if (data.byte(kVolume) != data.byte(kVolumeto)) {
+ data.byte(kVolumecount) += 64;
+ // Only modify the volume every 256/64 = 4th time around
+ if (data.byte(kVolumecount) == 0)
+ data.byte(kVolume) += data.byte(kVolumedirection);
+ } else {
+ data.byte(kVolumedirection) = 0;
+ }
+}
+
void DreamGenContext::playChannel0(uint8 index, uint8 repeat) {
if (data.byte(kSoundint) == 255)
return;
@@ -2597,7 +2618,7 @@ void DreamGenContext::getRidOfAll() {
// if skipDat, skip clearing and loading Setdat and Freedat
void DreamGenContext::loadRoomData(const Room &room, bool skipDat) {
engine->openFile(room.name);
- cs.word(kHandle) = 1; //only one handle
+ data.word(kHandle) = 1; //only one handle
flags._c = false;
FileHeader header;
@@ -2609,7 +2630,7 @@ void DreamGenContext::loadRoomData(const Room &room, bool skipDat) {
len[i] = header.len(i);
data.word(kBackdrop) = allocateAndLoad(len[0]);
- clearAndLoad(data.word(kWorkspace), 0, len[1], 132*66); // 132*66 = maplen
+ clearAndLoad(workspace(), 0, len[1], 132*66); // 132*66 = maplen
sortOutMap();
data.word(kSetframes) = allocateAndLoad(len[2]);
if (!skipDat)
@@ -2650,7 +2671,7 @@ void DreamGenContext::restoreReels() {
const Room &room = g_roomData[data.byte(kReallocation)];
engine->openFile(room.name);
- cs.word(kHandle) = 1; //only one handle
+ data.word(kHandle) = 1; //only one handle
flags._c = false;
FileHeader header;
@@ -2894,7 +2915,7 @@ void DreamGenContext::loadTravelText() {
}
void DreamGenContext::loadTempText() {
- loadTempText((const char *)cs.ptr(dx, 0));
+ loadTempText((const char *)data.ptr(dx, 0));
}
void DreamGenContext::loadTempText(const char *fileName) {
@@ -2921,7 +2942,6 @@ void DreamGenContext::allocateBuffers() {
data.word(kFreedat) = allocateMem(kFreedatlen/16);
data.word(kSetdat) = allocateMem(kSetdatlen/16);
data.word(kMapstore) = allocateMem(kLenofmapstore/16);
- allocateWork();
data.word(kSounddata) = allocateMem(2048/16);
data.word(kSounddata2) = allocateMem(2048/16);
}
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 4b22ee0dd1..1b80818b5e 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -31,10 +31,7 @@
uint16 allocateMem(uint16 paragraphs);
void deallocateMem();
void deallocateMem(uint16 segment);
- uint8 *workspace();
uint8 *textUnder();
- void allocateWork();
- void clearWork();
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();
@@ -49,13 +46,20 @@
void delChar();
void hangOnCurs(uint16 frameCount);
void hangOnCurs();
- void multiDump();
- void multiDump(uint16 x, uint16 y, uint8 width, uint8 height);
void workToScreen();
- void workToScreenCPP();
uint8 *mapStore();
void multiGet();
- void multiGet(uint8 *dst, uint16 x, uint16 y, uint8 width, uint8 height);
+ void multiGet(uint8 *dst, uint16 x, uint16 y, uint8 width, uint8 height) {
+ DreamBase::multiGet(dst, x, y, width, height);
+ }
+ void multiPut();
+ void multiPut(const uint8 *src, uint16 x, uint16 y, uint8 width, uint8 height) {
+ DreamBase::multiPut(src, x, y, width, height);
+ }
+ void multiDump();
+ void multiDump(uint16 x, uint16 y, uint8 width, uint8 height) {
+ DreamBase::multiDump(x, y, width, height);
+ }
void printSprites();
void quickQuit();
void readOneBlock();
@@ -82,16 +86,17 @@
void oldToNames();
void namesToOld();
void loadPalFromIFF();
- void fillSpace();
void startLoading(const Room &room);
Sprite *spriteTable();
void showFrame();
- 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 Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *height) {
+ DreamBase::showFrame(frameData, x, y, frameNumber, effectsFlag, width, height);
+ }
+ void showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag) {
+ DreamBase::showFrame(frameData, x, y, frameNumber, effectsFlag);
+ }
void printASprite(const Sprite *sprite);
void width160();
- void multiPut(const uint8 *src, uint16 x, uint16 y, uint8 width, uint8 height);
- void multiPut();
void eraseOldObs();
void clearSprites();
Sprite *makeSprite(uint8 x, uint8 y, uint16 updateCallback, uint16 frameData, uint16 somethingInDi);
@@ -102,7 +107,6 @@
void faceRightWay();
void walking(Sprite *sprite);
void autoSetWalk();
- void checkDest(const RoomPaths *roomsPaths);
void aboutTurn(Sprite *sprite);
void backObject(Sprite *sprite);
void backObject();
@@ -129,7 +133,6 @@
void turnAnyPathOff();
RoomPaths *getRoomsPaths();
void makeBackOb(SetObject *objData);
- void modifyChar();
void lockMon();
void cancelCh0();
void cancelCh1();
@@ -137,7 +140,6 @@
Reel *getReelStart();
void dealWithSpecial(uint8 firstParam, uint8 secondParam);
void zoom();
- void crosshair();
void showRain();
void delTextLine();
void commandOnly();
@@ -154,7 +156,6 @@
void copyName(uint8 type, uint8 index, uint8 *dst);
void commandWithOb();
void commandWithOb(uint8 command, uint8 type, uint8 index);
- void showPanel();
void updatePeople();
void madman(ReelRoutine &routine);
void madmanText();
@@ -206,9 +207,6 @@
void obName();
void obName(uint8 command, uint8 commandType);
void delPointer();
- void showBlink();
- void dumpBlink();
- void dumpPointer();
void showPointer();
void animPointer();
void checkCoords();
@@ -241,7 +239,6 @@
void makeWorn(DynObject *object);
void obToInv();
void obToInv(uint8 index, uint8 flag, uint16 x, uint16 y);
- void showRyanPage();
void findAllRyan();
void findAllRyan(uint8 *inv);
void fillRyan();
@@ -330,8 +327,6 @@
void playChannel1(uint8 index);
void showMainOps();
void showDiscOps();
- void createPanel();
- void createPanel2();
void findRoomInLoc();
void reelsOnScreen();
void reconstruct();
@@ -357,6 +352,7 @@
void openForSave(unsigned int slot);
bool openForLoad(unsigned int slot);
uint16 allocateAndLoad(unsigned int size);
+ 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 loadRoomData(const Room &room, bool skipDat);
void restoreAll();
@@ -493,7 +489,6 @@
void bibleQuote();
void realCredits();
void intro();
- Common::String getFilename(Context &context);
void fadeScreenUp();
void fadeScreenUps();
void fadeScreenUpHalf();
@@ -567,5 +562,6 @@
void dumpSymbol();
void dumpSymBox();
void dumpZoom();
+ void fadeDOS();
#endif
diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp
index 20eb840628..4c3ba57e6c 100644
--- a/engines/dreamweb/vgagrafx.cpp
+++ b/engines/dreamweb/vgagrafx.cpp
@@ -27,15 +27,6 @@
namespace DreamGen {
-uint8 *DreamGenContext::workspace() {
- uint8 *result = getSegment(data.word(kWorkspace)).ptr(0, 0);
- return result;
-}
-
-void DreamGenContext::allocateWork() {
- data.word(kWorkspace) = allocateMem(0x1000);
-}
-
void DreamGenContext::multiGet() {
multiGet(ds.ptr(si, 0), di, bx, cl, ch);
si += cl * ch;
@@ -43,7 +34,7 @@ void DreamGenContext::multiGet() {
cx = 0;
}
-void DreamGenContext::multiGet(uint8 *dst, uint16 x, uint16 y, uint8 w, uint8 h) {
+void DreamBase::multiGet(uint8 *dst, uint16 x, uint16 y, uint8 w, uint8 h) {
assert(x < 320);
assert(y < 200);
const uint8 *src = workspace() + x + y * kScreenwidth;
@@ -66,7 +57,7 @@ void DreamGenContext::multiPut() {
cx = 0;
}
-void DreamGenContext::multiPut(const uint8 *src, uint16 x, uint16 y, uint8 w, uint8 h) {
+void DreamBase::multiPut(const uint8 *src, uint16 x, uint16 y, uint8 w, uint8 h) {
assert(x < 320);
assert(y < 200);
uint8 *dst = workspace() + x + y * kScreenwidth;
@@ -82,12 +73,6 @@ void DreamGenContext::multiPut(const uint8 *src, uint16 x, uint16 y, uint8 w, ui
}
}
-void DreamGenContext::multiDump(uint16 x, uint16 y, uint8 width, uint8 height) {
- unsigned offset = x + y * kScreenwidth;
- //debug(1, "multiDump %ux%u(segment: %04x) -> %d,%d(address: %d)", w, h, (uint16)ds, x, y, offset);
- engine->blit(workspace() + offset, kScreenwidth, x, y, width, height);
-}
-
void DreamGenContext::multiDump() {
multiDump(di, bx, cl, ch);
unsigned offset = di + bx * kScreenwidth;
@@ -95,7 +80,13 @@ void DreamGenContext::multiDump() {
cx = 0;
}
-void DreamGenContext::workToScreenCPP() {
+void DreamBase::multiDump(uint16 x, uint16 y, uint8 width, uint8 height) {
+ unsigned offset = x + y * kScreenwidth;
+ //debug(1, "multiDump %ux%u(segment: %04x) -> %d,%d(address: %d)", w, h, (uint16)ds, x, y, offset);
+ engine->blit(workspace() + offset, kScreenwidth, x, y, width, height);
+}
+
+void DreamBase::workToScreenCPP() {
engine->blit(workspace(), 320, 0, 0, 320, 200);
}
@@ -322,12 +313,12 @@ void DreamBase::frameOutV(uint8 *dst, const uint8 *src, uint16 pitch, uint16 wid
}
}
-void DreamGenContext::showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag) {
+void DreamBase::showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag) {
uint8 width, height;
showFrame(frameData, x, y, frameNumber, effectsFlag, &width, &height);
}
-void DreamGenContext::showFrame(const Frame *frameData, uint16 x, uint16 y, uint16 frameNumber, uint8 effectsFlag, uint8 *width, uint8 *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;
@@ -352,8 +343,11 @@ void DreamGenContext::showFrame(const Frame *frameData, uint16 x, uint16 y, uint
y -= *height / 2;
}
if (effectsFlag & 64) { //diffDest
+ error("Unsupported DreamBase::showFrame effectsFlag %d", effectsFlag);
+ /*
frameOutFx(es.ptr(0, dx * *height), pSrc, dx, *width, *height, x, y);
return;
+ */
}
if (effectsFlag & 8) { //printList
/*
@@ -389,7 +383,7 @@ void DreamGenContext::showFrame() {
ch = height;
}
-void DreamGenContext::clearWork() {
+void DreamBase::clearWork() {
memset(workspace(), 0, 320*200);
}
@@ -479,17 +473,22 @@ void DreamGenContext::loadPalFromIFF() {
}
}
-void DreamGenContext::createPanel() {
+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);
}
-void DreamGenContext::createPanel2() {
+void DreamBase::createPanel2() {
createPanel();
showFrame(engine->icons2(), 0, 0, 5, 2);
showFrame(engine->icons2(), 160, 0, 5, 2);
}
+void DreamBase::showPanel() {
+ showFrame(engine->icons1(), 72, 0, 19, 0);
+ showFrame(engine->icons1(), 192, 0, 19, 0);
+}
+
} // End of namespace DreamGen