aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2011-12-27 22:00:27 +0100
committerWillem Jan Palenstijn2011-12-27 23:03:05 +0100
commita7cdc342b36bce68e5cdabf6a682e38ea1b21e7b (patch)
tree9cf2a70ccadb619697ade53d4b8ffc3eb96417be /engines
parentf729742f87648d6a5ebc1468e26e90ac1de1c2e0 (diff)
downloadscummvm-rg350-a7cdc342b36bce68e5cdabf6a682e38ea1b21e7b.tar.gz
scummvm-rg350-a7cdc342b36bce68e5cdabf6a682e38ea1b21e7b.tar.bz2
scummvm-rg350-a7cdc342b36bce68e5cdabf6a682e38ea1b21e7b.zip
DREAMWEB: Convert reel segments into GraphicsFiles
Diffstat (limited to 'engines')
-rw-r--r--engines/dreamweb/dreambase.h7
-rw-r--r--engines/dreamweb/dreamgen.cpp6
-rw-r--r--engines/dreamweb/dreamgen.h53
-rw-r--r--engines/dreamweb/sprite.cpp32
-rw-r--r--engines/dreamweb/stubs.cpp58
-rw-r--r--engines/dreamweb/talk.cpp4
6 files changed, 80 insertions, 80 deletions
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 88dc96ece2..1b48e07fb4 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -146,6 +146,9 @@ protected:
// room graphics files
GraphicsFile _setFrames;
GraphicsFile _freeFrames;
+ GraphicsFile _reel1;
+ GraphicsFile _reel2;
+ GraphicsFile _reel3;
// Extras segment (NB: this is saved)
GraphicsFile _exFrames;
@@ -439,7 +442,7 @@ public:
void liftSprite(Sprite *sprite, SetObject *objData);
Reel *getReelStart(uint16 reelPointer);
- const Frame *findSource(uint16 &frame);
+ const GraphicsFile *findSource(uint16 &frame);
void showReelFrame(Reel *reel);
void showGameReel(ReelRoutine *routine);
const Frame *getReelFrameAX(uint16 frame);
@@ -511,6 +514,8 @@ public:
uint16 allocateAndLoad(unsigned int size);
void loadTextFile(TextFile &file, const char *fileName);
void loadGraphicsFile(GraphicsFile &file, const char *fileName);
+ void loadGraphicsSegment(GraphicsFile &file, unsigned int len);
+ void loadTextSegment(TextFile &file, unsigned int len);
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(const char *fileName);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 401140e4f3..4f2524ace6 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -67,11 +67,9 @@ void DreamGenContext::__start() {
//0x0110: .... .... .... ....
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
//0x0120: .... .... .... ....
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//0x0130: .... .... .... ....
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
- //0x0140: .... .... .... ....
- };
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
ds.assign(src, src + sizeof(src));
dreamweb();
}
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 673800774a..75fef09741 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -255,35 +255,30 @@ static const uint16 kBackdrop = 284;
static const uint16 kRecordspace = 286;
static const uint16 kFreedat = 288;
static const uint16 kSetdat = 290;
-static const uint16 kReel1 = 292;
-static const uint16 kReel2 = 294;
-static const uint16 kReel3 = 296;
-static const uint16 kRoomdesc = 298;
-static const uint16 kFreedesc = 300;
-static const uint16 kSetdesc = 302;
-static const uint16 kBlockdesc = 304;
-static const uint16 kSetframes = 306;
-static const uint16 kFreeframes = 308;
-static const uint16 kPeople = 310;
-static const uint16 kReels = 312;
-static const uint16 kBlinkframe = 314;
-static const uint16 kBlinkcount = 315;
-static const uint16 kReasseschanges = 316;
-static const uint16 kPointerspath = 317;
-static const uint16 kManspath = 318;
-static const uint16 kPointerfirstpath = 319;
-static const uint16 kFinaldest = 320;
-static const uint16 kDestination = 321;
-static const uint16 kLinestartx = 322;
-static const uint16 kLinestarty = 324;
-static const uint16 kLineendx = 326;
-static const uint16 kLineendy = 328;
-static const uint16 kLinepointer = 330;
-static const uint16 kLinedirection = 331;
-static const uint16 kLinelength = 332;
-static const uint16 kCh0playing = 333;
-static const uint16 kCh0repeat = 334;
-static const uint16 kCh1playing = 335;
+static const uint16 kRoomdesc = 292;
+static const uint16 kFreedesc = 294;
+static const uint16 kSetdesc = 296;
+static const uint16 kBlockdesc = 298;
+static const uint16 kPeople = 300;
+static const uint16 kReels = 302;
+static const uint16 kBlinkframe = 304;
+static const uint16 kBlinkcount = 305;
+static const uint16 kReasseschanges = 306;
+static const uint16 kPointerspath = 307;
+static const uint16 kManspath = 308;
+static const uint16 kPointerfirstpath = 309;
+static const uint16 kFinaldest = 310;
+static const uint16 kDestination = 311;
+static const uint16 kLinestartx = 312;
+static const uint16 kLinestarty = 314;
+static const uint16 kLineendx = 316;
+static const uint16 kLineendy = 318;
+static const uint16 kLinepointer = 320;
+static const uint16 kLinedirection = 321;
+static const uint16 kLinelength = 322;
+static const uint16 kCh0playing = 323;
+static const uint16 kCh0repeat = 324;
+static const uint16 kCh1playing = 325;
static const uint16 kBlocktextdat = (0);
static const uint16 kPersonframes = (0);
static const uint16 kDebuglevel1 = (0);
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index 31f7408a1c..4071c56f64 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -435,26 +435,24 @@ Reel *DreamBase::getReelStart(uint16 reelPointer) {
// Locate the reel segment (reel1, reel2, reel3) this frame is stored in,
// and adjust the frame number relative to this segment.
-const Frame *DreamBase::findSource(uint16 &frame) {
- uint16 base;
+const GraphicsFile *DreamBase::findSource(uint16 &frame) {
if (frame < 160) {
- base = data.word(kReel1);
+ return &_reel1;
} else if (frame < 320) {
frame -= 160;
- base = data.word(kReel2);
+ return &_reel2;
} else {
frame -= 320;
- base = data.word(kReel3);
+ return &_reel3;
}
- return (const Frame *)getSegment(base).ptr(0, (frame+1)*sizeof(Frame));
}
void DreamBase::showReelFrame(Reel *reel) {
uint16 x = reel->x + data.word(kMapadx);
uint16 y = reel->y + data.word(kMapady);
uint16 frame = reel->frame();
- const Frame *base = findSource(frame);
- showFrame(base, x, y, frame, 8);
+ const GraphicsFile *base = findSource(frame);
+ showFrame(*base, x, y, frame, 8);
}
void DreamBase::showGameReel(ReelRoutine *routine) {
@@ -466,8 +464,8 @@ void DreamBase::showGameReel(ReelRoutine *routine) {
}
const Frame *DreamBase::getReelFrameAX(uint16 frame) {
- const Frame *base = findSource(frame);
- return base + frame;
+ const GraphicsFile *base = findSource(frame);
+ return &base->_frames[frame];
}
void DreamBase::showRain() {
@@ -1115,18 +1113,14 @@ void DreamBase::clearBeforeLoad() {
}
void DreamBase::clearReels() {
- deallocateMem(data.word(kReel1));
- deallocateMem(data.word(kReel2));
- deallocateMem(data.word(kReel3));
+ _reel1.clear();
+ _reel2.clear();
+ _reel3.clear();
}
void DreamBase::getRidOfReels() {
- if (data.byte(kRoomloaded) == 0)
- return /* (dontgetrid) */;
-
- deallocateMem(data.word(kReel1));
- deallocateMem(data.word(kReel2));
- deallocateMem(data.word(kReel3));
+ if (data.byte(kRoomloaded))
+ clearReels();
}
void DreamBase::liftNoise(uint8 index) {
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 818e1a537b..e9f1ea4f51 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -651,8 +651,13 @@ done: // The engine will need some cleaner finalization, let's put it here for n
_mainSprites.clear();
_exFrames.clear();
+ _exText.clear();
+
_setFrames.clear();
_freeFrames.clear();
+ _reel1.clear();
+ _reel2.clear();
+ _reel3.clear();
_textFile1.clear();
_textFile2.clear();
@@ -809,6 +814,23 @@ void DreamBase::loadGraphicsFile(GraphicsFile &file, const char *fileName) {
f.read(file._data, sizeInBytes - 2080);
}
+void DreamBase::loadGraphicsSegment(GraphicsFile &file, unsigned int len) {
+ assert(len >= 2080);
+ delete[] file._data;
+ file._data = new uint8[len - 2080];
+ engine->readFromFile((uint8 *)file._frames, 2080);
+ engine->readFromFile(file._data, len - 2080);
+}
+
+void DreamBase::loadTextSegment(TextFile &file, unsigned int len) {
+ unsigned int headerSize = 2 * file._size;
+ assert(len >= headerSize);
+ delete[] file._text;
+ file._text = new char[len - headerSize];
+ engine->readFromFile((uint8 *)file._offsetsLE, headerSize);
+ engine->readFromFile((uint8 *)file._text, len - headerSize);
+}
+
void DreamBase::loadIntoTemp(const char *fileName) {
loadGraphicsFile(_tempGraphics, fileName);
}
@@ -2170,9 +2192,9 @@ void DreamBase::getRidOfAll() {
_backdropBlocks = 0;
_setFrames.clear();
- deallocateMem(data.word(kReel1));
- deallocateMem(data.word(kReel2));
- deallocateMem(data.word(kReel3));
+ _reel1.clear();
+ _reel2.clear();
+ _reel3.clear();
deallocateMem(data.word(kReels));
deallocateMem(data.word(kPeople));
deallocateMem(data.word(kSetdesc));
@@ -2202,13 +2224,7 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
clearAndLoad(workspace(), 0, len[1], 132*66); // 132*66 = maplen
sortOutMap();
- // TODO: Create function for loading a GraphicsFile from a file segment
- _setFrames.clear();
- assert(len[2] >= 2080);
- engine->readFromFile((uint8 *)_setFrames._frames, 2080);
- _setFrames._data = new uint8[len[2] - 2080];
- engine->readFromFile(_setFrames._data, len[2] - 2080);
-
+ loadGraphicsSegment(_setFrames, len[2]);
if (!skipDat)
clearAndLoad(data.word(kSetdat), 255, len[3], kSetdatlen);
else
@@ -2216,24 +2232,16 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
// NB: The skipDat version of this function as called by restoreall
// had a 'call bloc' instead of 'call loadseg' for reel1,
// but 'bloc' was not defined.
- // TODO: kReel1/2/3 are also GraphicsFiles?
- data.word(kReel1) = allocateAndLoad(len[4]);
- data.word(kReel2) = allocateAndLoad(len[5]);
- data.word(kReel3) = allocateAndLoad(len[6]);
+ loadGraphicsSegment(_reel1, len[4]);
+ loadGraphicsSegment(_reel2, len[5]);
+ loadGraphicsSegment(_reel3, len[6]);
data.word(kReels) = allocateAndLoad(len[7]);
data.word(kPeople) = allocateAndLoad(len[8]);
// TODO: kSetdesc, kBlockdesc, kRoomdesc are also TextFiles?
data.word(kSetdesc) = allocateAndLoad(len[9]);
data.word(kBlockdesc) = allocateAndLoad(len[10]);
data.word(kRoomdesc) = allocateAndLoad(len[11]);
-
- // TODO: Create function for loading a GraphicsFile from a file segment
- _freeFrames.clear();
- assert(len[12] >= 2080);
- engine->readFromFile((uint8 *)_freeFrames._frames, 2080);
- _freeFrames._data = new uint8[len[12] - 2080];
- engine->readFromFile(_freeFrames._data, len[12] - 2080);
-
+ loadGraphicsSegment(_freeFrames, len[12]);
if (!skipDat)
clearAndLoad(data.word(kFreedat), 255, len[13], kFreedatlen);
else
@@ -2270,9 +2278,9 @@ void DreamBase::restoreReels() {
engine->skipBytes(len[1]);
engine->skipBytes(len[2]);
engine->skipBytes(len[3]);
- data.word(kReel1) = allocateAndLoad(len[4]);
- data.word(kReel2) = allocateAndLoad(len[5]);
- data.word(kReel3) = allocateAndLoad(len[6]);
+ loadGraphicsSegment(_reel1, len[4]);
+ loadGraphicsSegment(_reel2, len[5]);
+ loadGraphicsSegment(_reel3, len[6]);
engine->closeFile();
}
diff --git a/engines/dreamweb/talk.cpp b/engines/dreamweb/talk.cpp
index 74357f395f..172a61fad1 100644
--- a/engines/dreamweb/talk.cpp
+++ b/engines/dreamweb/talk.cpp
@@ -76,8 +76,8 @@ void DreamBase::talk() {
void DreamBase::convIcons() {
uint8 index = data.byte(kCharacter) & 127;
uint16 frame = getPersFrame(index);
- const Frame *base = findSource(frame);
- showFrame(base, 234, 2, frame, 0);
+ const GraphicsFile *base = findSource(frame);
+ showFrame(*base, 234, 2, frame, 0);
}
uint16 DreamBase::getPersFrame(uint8 index) {