[Scummvm-cvs-logs] scummvm master -> 08be0411b1bfba715d5c1b50b50a893a27e12f8c
wjp
wjp at usecode.org
Tue Dec 27 18:41:32 CET 2011
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
39a0153fbf DREAMWEB: Remove mapStore segment
7bae1022ed DREAMWEB: Remove mapData segment
df7bb24184 DREAMWEB: Create MapFlags struct, remove backdrops segment
08be0411b1 DREAMWEB: Streamline text file handling
Commit: 39a0153fbf503854011bc1947ef261e06868d971
https://github.com/scummvm/scummvm/commit/39a0153fbf503854011bc1947ef261e06868d971
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T08:56:50-08:00
Commit Message:
DREAMWEB: Remove mapStore segment
Changed paths:
devtools/tasmrecover/tasm-recover
engines/dreamweb/dreambase.h
engines/dreamweb/dreamgen.cpp
engines/dreamweb/dreamgen.h
engines/dreamweb/monitor.cpp
engines/dreamweb/newplace.cpp
engines/dreamweb/print.cpp
engines/dreamweb/stubs.cpp
engines/dreamweb/vgagrafx.cpp
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 1da9942..4cbb7c9 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -284,6 +284,7 @@ p = parser(skip_binary_data = [
'endtextname',
'gungraphic',
'monkface',
+ 'mapstore',
])
p.strip_path = 3
context = p.parse('dreamweb/dreamweb.asm')
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 44d62db..ed384fa 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -47,6 +47,7 @@ const unsigned int kUnderTextBufSize = kUnderTextSizeX_f * kUnderTextSizeY_f;
const unsigned int kUnderTimedTextBufSize = 256 * kUnderTimedTextSizeY_f;
const unsigned int kLengthOfVars = 68;
const unsigned int kNumChanges = 250;
+const unsigned int kLenOfMapStore = 22*8*20*8;
/**
* This class is one of the parent classes of DreamGenContext. Its sole purpose
@@ -85,6 +86,7 @@ protected:
// from vgagrafx.cpp
uint8 _workspace[(0x1000 + 2) * 16];
+ uint8 _mapStore[kLenOfMapStore + 32];
// from people.cpp
ReelRoutine _reelRoutines[kNumReelRoutines+1];
@@ -794,7 +796,6 @@ public:
inline uint8 *workspace() { return _workspace; }
void clearWork();
- uint8 *mapStore();
void panelToMap();
void mapToPanel();
void dumpMap();
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 777961f..910fd81 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -65,15 +65,15 @@ void DreamGenContext::__start() {
//0x0100: .... .... .... ....
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//0x0110: .... .... .... ....
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
//0x0120: .... .... .... ....
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
//0x0130: .... .... .... ....
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
//0x0140: .... .... .... ....
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//0x0150: .... .... .... ....
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
+ 0x00, 0x00, 0x00, 0x00, 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 b736c3c..3ad9b1d 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -251,53 +251,52 @@ static const uint16 kBufferin = 276;
static const uint16 kBufferout = 278;
static const uint16 kExtras = 280;
static const uint16 kWorkspace = 282;
-static const uint16 kMapstore = 284;
-static const uint16 kCharset1 = 286;
-static const uint16 kMainsprites = 288;
-static const uint16 kBackdrop = 290;
-static const uint16 kMapdata = 292;
-static const uint16 kRecordspace = 294;
-static const uint16 kFreedat = 296;
-static const uint16 kSetdat = 298;
-static const uint16 kReel1 = 300;
-static const uint16 kReel2 = 302;
-static const uint16 kReel3 = 304;
-static const uint16 kRoomdesc = 306;
-static const uint16 kFreedesc = 308;
-static const uint16 kSetdesc = 310;
-static const uint16 kBlockdesc = 312;
-static const uint16 kSetframes = 314;
-static const uint16 kFreeframes = 316;
-static const uint16 kPeople = 318;
-static const uint16 kReels = 320;
-static const uint16 kCommandtext = 322;
-static const uint16 kPuzzletext = 324;
-static const uint16 kTraveltext = 326;
-static const uint16 kTempgraphics = 328;
-static const uint16 kTempgraphics2 = 330;
-static const uint16 kTempgraphics3 = 332;
-static const uint16 kTempsprites = 334;
-static const uint16 kTextfile1 = 336;
-static const uint16 kTextfile2 = 338;
-static const uint16 kTextfile3 = 340;
-static const uint16 kBlinkframe = 342;
-static const uint16 kBlinkcount = 343;
-static const uint16 kReasseschanges = 344;
-static const uint16 kPointerspath = 345;
-static const uint16 kManspath = 346;
-static const uint16 kPointerfirstpath = 347;
-static const uint16 kFinaldest = 348;
-static const uint16 kDestination = 349;
-static const uint16 kLinestartx = 350;
-static const uint16 kLinestarty = 352;
-static const uint16 kLineendx = 354;
-static const uint16 kLineendy = 356;
-static const uint16 kLinepointer = 358;
-static const uint16 kLinedirection = 359;
-static const uint16 kLinelength = 360;
-static const uint16 kCh0playing = 361;
-static const uint16 kCh0repeat = 362;
-static const uint16 kCh1playing = 363;
+static const uint16 kCharset1 = 284;
+static const uint16 kMainsprites = 286;
+static const uint16 kBackdrop = 288;
+static const uint16 kMapdata = 290;
+static const uint16 kRecordspace = 292;
+static const uint16 kFreedat = 294;
+static const uint16 kSetdat = 296;
+static const uint16 kReel1 = 298;
+static const uint16 kReel2 = 300;
+static const uint16 kReel3 = 302;
+static const uint16 kRoomdesc = 304;
+static const uint16 kFreedesc = 306;
+static const uint16 kSetdesc = 308;
+static const uint16 kBlockdesc = 310;
+static const uint16 kSetframes = 312;
+static const uint16 kFreeframes = 314;
+static const uint16 kPeople = 316;
+static const uint16 kReels = 318;
+static const uint16 kCommandtext = 320;
+static const uint16 kPuzzletext = 322;
+static const uint16 kTraveltext = 324;
+static const uint16 kTempgraphics = 326;
+static const uint16 kTempgraphics2 = 328;
+static const uint16 kTempgraphics3 = 330;
+static const uint16 kTempsprites = 332;
+static const uint16 kTextfile1 = 334;
+static const uint16 kTextfile2 = 336;
+static const uint16 kTextfile3 = 338;
+static const uint16 kBlinkframe = 340;
+static const uint16 kBlinkcount = 341;
+static const uint16 kReasseschanges = 342;
+static const uint16 kPointerspath = 343;
+static const uint16 kManspath = 344;
+static const uint16 kPointerfirstpath = 345;
+static const uint16 kFinaldest = 346;
+static const uint16 kDestination = 347;
+static const uint16 kLinestartx = 348;
+static const uint16 kLinestarty = 350;
+static const uint16 kLineendx = 352;
+static const uint16 kLineendy = 354;
+static const uint16 kLinepointer = 356;
+static const uint16 kLinedirection = 357;
+static const uint16 kLinelength = 358;
+static const uint16 kCh0playing = 359;
+static const uint16 kCh0repeat = 360;
+static const uint16 kCh1playing = 361;
static const uint16 kBlocktextdat = (0);
static const uint16 kPersonframes = (0);
static const uint16 kDebuglevel1 = (0);
diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp
index 7419bcf..4f037c6 100644
--- a/engines/dreamweb/monitor.cpp
+++ b/engines/dreamweb/monitor.cpp
@@ -223,7 +223,7 @@ void DreamBase::input() {
_inputLine[data.word(kCurpos) * 2 + 0] = currentKey;
if (currentKey > 'Z')
continue;
- multiGet(mapStore() + data.word(kCurpos) * 256, data.word(kMonadx), data.word(kMonady), 8, 8);
+ multiGet(_mapStore + data.word(kCurpos) * 256, data.word(kMonadx), data.word(kMonady), 8, 8);
uint8 charWidth;
printChar(engine->tempCharset(), data.word(kMonadx), data.word(kMonady), currentKey, 0, &charWidth, NULL);
_inputLine[data.word(kCurpos) * 2 + 1] = charWidth;
@@ -248,7 +248,7 @@ void DreamBase::delChar() {
data.word(kCurslocx) -= width;
uint16 offset = data.word(kCurpos);
offset = ((offset & 0x00ff) << 8) | ((offset & 0xff00) >> 8);
- multiPut(mapStore() + offset, data.word(kMonadx), data.word(kMonady), 8, 8);
+ multiPut(_mapStore + offset, data.word(kMonadx), data.word(kMonady), 8, 8);
multiDump(data.word(kMonadx), data.word(kMonady), 8, 8);
}
diff --git a/engines/dreamweb/newplace.cpp b/engines/dreamweb/newplace.cpp
index 8c94b3f..4d82d70 100644
--- a/engines/dreamweb/newplace.cpp
+++ b/engines/dreamweb/newplace.cpp
@@ -134,11 +134,11 @@ void DreamBase::lookAtPlace() {
}
void DreamBase::getUnderCentre() {
- multiGet(mapStore(), 58, 72, 254, 110);
+ multiGet(_mapStore, 58, 72, 254, 110);
}
void DreamBase::putUnderCentre() {
- multiPut(mapStore(), 58, 72, 254, 110);
+ multiPut(_mapStore, 58, 72, 254, 110);
}
void DreamBase::locationPic() {
diff --git a/engines/dreamweb/print.cpp b/engines/dreamweb/print.cpp
index 9cd7b46..f5f0dda 100644
--- a/engines/dreamweb/print.cpp
+++ b/engines/dreamweb/print.cpp
@@ -253,7 +253,7 @@ void DreamBase::rollEndCreditsGameWon() {
data.byte(kVolumeto) = 0;
data.byte(kVolumedirection) = (byte)-1;
- multiGet(mapStore(), 75, 20, 160, 160);
+ multiGet(_mapStore, 75, 20, 160, 160);
const uint8 *string = getTextInFile1(3);
const int linespacing = data.word(kLinespacing);
@@ -264,7 +264,7 @@ void DreamBase::rollEndCreditsGameWon() {
// line of text.
for (int j = 0; j < linespacing; ++j) {
vSync();
- multiPut(mapStore(), 75, 20, 160, 160);
+ multiPut(_mapStore, 75, 20, 160, 160);
vSync();
// Output up to 18 lines of text
@@ -292,7 +292,7 @@ void DreamBase::rollEndCreditsGameWon() {
}
void DreamBase::rollEndCreditsGameLost() {
- multiGet(mapStore(), 25, 20, 160, 160);
+ multiGet(_mapStore, 25, 20, 160, 160);
const uint8 *string = getTextInFile1(49);
const int linespacing = data.word(kLinespacing);
@@ -303,7 +303,7 @@ void DreamBase::rollEndCreditsGameLost() {
// line of text.
for (int j = 0; j < linespacing; ++j) {
vSync();
- multiPut(mapStore(), 25, 20, 160, 160);
+ multiPut(_mapStore, 25, 20, 160, 160);
vSync();
// Output up to 18 lines of text
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 1392d16..772509b 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -836,7 +836,7 @@ void DreamBase::putUnderTimed() {
}
void DreamBase::triggerMessage(uint16 index) {
- multiGet(mapStore(), 174, 153, 200, 63);
+ multiGet(_mapStore, 174, 153, 200, 63);
uint16 offset = kTextstart + getSegment(data.word(kPuzzletext)).word(index * 2);
const uint8 *string = getSegment(data.word(kPuzzletext)).ptr(offset, 0);
uint16 y = 156;
@@ -844,7 +844,7 @@ void DreamBase::triggerMessage(uint16 index) {
hangOn(140);
workToScreen();
hangOn(340);
- multiPut(mapStore(), 174, 153, 200, 63);
+ multiPut(_mapStore, 174, 153, 200, 63);
workToScreen();
data.byte(kLasttrigger) = 0;
}
@@ -2464,7 +2464,6 @@ void DreamBase::allocateBuffers() {
data.word(kMapdata) = allocateMem(kLengthofmap/16);
data.word(kFreedat) = allocateMem(kFreedatlen/16);
data.word(kSetdat) = allocateMem(kSetdatlen/16);
- data.word(kMapstore) = allocateMem(kLenofmapstore/16);
}
void DreamBase::workToScreenM() {
diff --git a/engines/dreamweb/vgagrafx.cpp b/engines/dreamweb/vgagrafx.cpp
index 7e74264..f611a79 100644
--- a/engines/dreamweb/vgagrafx.cpp
+++ b/engines/dreamweb/vgagrafx.cpp
@@ -357,16 +357,12 @@ void DreamBase::zoom() {
data.byte(kDidzoom) = 1;
}
-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));
+ multiGet(_mapStore, data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize));
}
void DreamBase::mapToPanel() {
- multiPut(mapStore(), data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize));
+ multiPut(_mapStore, data.word(kMapxstart) + data.word(kMapadx), data.word(kMapystart) + data.word(kMapady), data.byte(kMapxsize), data.byte(kMapysize));
}
void DreamBase::dumpMap() {
@@ -384,11 +380,12 @@ bool DreamBase::pixelCheckSet(const ObjPos *pos, uint8 x, uint8 y) {
void DreamBase::loadPalFromIFF() {
Common::File palFile;
+ uint8* buf = new uint8[2000];
palFile.open("DREAMWEB.PAL");
- palFile.read(mapStore(), 2000);
+ palFile.read(buf, 2000);
palFile.close();
- const uint8 *src = mapStore() + 0x30;
+ const uint8 *src = buf + 0x30;
uint8 *dst = _mainPal;
for (size_t i = 0; i < 256*3; ++i) {
uint8 c = src[i] / 4;
@@ -401,6 +398,8 @@ void DreamBase::loadPalFromIFF() {
}
dst[i] = c;
}
+
+ delete[] buf;
}
void DreamBase::createPanel() {
Commit: 7bae1022eddc9805bb9163c01676f02f50459c4f
https://github.com/scummvm/scummvm/commit/7bae1022eddc9805bb9163c01676f02f50459c4f
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T08:56:50-08:00
Commit Message:
DREAMWEB: Remove mapData segment
Changed paths:
engines/dreamweb/backdrop.cpp
engines/dreamweb/dreambase.h
engines/dreamweb/sprite.cpp
engines/dreamweb/stubs.cpp
diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp
index 875e168..e85889d 100644
--- a/engines/dreamweb/backdrop.cpp
+++ b/engines/dreamweb/backdrop.cpp
@@ -27,7 +27,7 @@ namespace DreamGen {
void DreamBase::doBlocks() {
uint16 dstOffset = data.word(kMapady) * 320 + data.word(kMapadx);
uint16 mapOffset = kMap + data.byte(kMapy) * kMapwidth + data.byte(kMapx);
- const uint8 *mapData = getSegment(data.word(kMapdata)).ptr(mapOffset, 0);
+ const uint8 *mapData = _mapData + mapOffset;
const uint8 *blocks = getSegment(data.word(kBackdrop)).ptr(kBlocks, 0);
uint8 *dstBuffer = workspace() + dstOffset;
@@ -242,7 +242,8 @@ void DreamBase::showAllFree() {
void DreamBase::drawFlags() {
uint8 *mapFlags = _mapFlags;
- const uint8 *mapData = getSegment(data.word(kMapdata)).ptr(kMap + data.byte(kMapy) * kMapwidth + data.byte(kMapx), 0);
+ uint16 mapOffset = kMap + data.byte(kMapy) * kMapwidth + data.byte(kMapx);
+ const uint8 *mapData = _mapData + mapOffset;
const uint8 *backdropFlags = getSegment(data.word(kBackdrop)).ptr(kFlags, 0);
for (size_t i = 0; i < 10; ++i) {
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index ed384fa..b310bb3 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -48,6 +48,9 @@ const unsigned int kUnderTimedTextBufSize = 256 * kUnderTimedTextSizeY_f;
const unsigned int kLengthOfVars = 68;
const unsigned int kNumChanges = 250;
const unsigned int kLenOfMapStore = 22*8*20*8;
+const unsigned int kMapWidth = 66;
+const unsigned int kMapHeight = 60;
+const unsigned int kLengthOfMap = kMapWidth * kMapHeight;
/**
* This class is one of the parent classes of DreamGenContext. Its sole purpose
@@ -62,6 +65,9 @@ class DreamBase : public SegmentManager {
protected:
DreamWeb::DreamWebEngine *engine;
+ // from backdrop.cpp
+ uint8 _mapData[kLengthOfMap + 32];
+
// from keypad.cpp
uint8 _pressList[6];
diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp
index 3c1ba6b..244f6a3 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -1100,8 +1100,7 @@ void DreamBase::clearBeforeLoad() {
clearReels();
//clearRest
- uint8 *dst = (uint8 *)getSegment(data.word(kMapdata)).ptr(0, 0);
- memset(dst, 0, kMaplen);
+ memset(_mapData, 0, kMaplen);
deallocateMem(data.word(kBackdrop));
deallocateMem(data.word(kSetframes));
deallocateMem(data.word(kReels));
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 772509b..e47e792 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -1885,7 +1885,7 @@ void DreamBase::zoomOnOff() {
void DreamBase::sortOutMap() {
const uint8 *src = workspace();
- uint8 *dst = (uint8 *)getSegment(data.word(kMapdata)).ptr(0, 0);
+ uint8 *dst = _mapData;
for (uint16 y = 0; y < kMaplength; ++y) {
memcpy(dst, src, kMapwidth);
dst += kMapwidth;
@@ -2461,7 +2461,6 @@ void DreamBase::drawFloor() {
void DreamBase::allocateBuffers() {
data.word(kExtras) = allocateMem(kLengthofextra/16);
- data.word(kMapdata) = allocateMem(kLengthofmap/16);
data.word(kFreedat) = allocateMem(kFreedatlen/16);
data.word(kSetdat) = allocateMem(kSetdatlen/16);
}
Commit: df7bb24184ea599280640107c19f898c43d74ac3
https://github.com/scummvm/scummvm/commit/df7bb24184ea599280640107c19f898c43d74ac3
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T09:01:33-08:00
Commit Message:
DREAMWEB: Create MapFlags struct, remove backdrops segment
Changed paths:
devtools/tasmrecover/tasm-recover
engines/dreamweb/backdrop.cpp
engines/dreamweb/dreambase.h
engines/dreamweb/dreamgen.cpp
engines/dreamweb/dreamgen.h
engines/dreamweb/sprite.cpp
engines/dreamweb/structs.h
engines/dreamweb/stubs.cpp
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 4cbb7c9..1edd60a 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -241,6 +241,9 @@ p = parser(skip_binary_data = [
'ch1blockstocopy',
'sounddata',
'sounddata2',
+ 'mapstore',
+ 'mapdata',
+ 'backdrops',
# vgagrafx.asm
'cityname',
'extragraphics1',
@@ -284,7 +287,6 @@ p = parser(skip_binary_data = [
'endtextname',
'gungraphic',
'monkface',
- 'mapstore',
])
p.strip_path = 3
context = p.parse('dreamweb/dreamweb.asm')
diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp
index e85889d..553390f 100644
--- a/engines/dreamweb/backdrop.cpp
+++ b/engines/dreamweb/backdrop.cpp
@@ -28,7 +28,6 @@ void DreamBase::doBlocks() {
uint16 dstOffset = data.word(kMapady) * 320 + data.word(kMapadx);
uint16 mapOffset = kMap + data.byte(kMapy) * kMapwidth + data.byte(kMapx);
const uint8 *mapData = _mapData + mapOffset;
- const uint8 *blocks = getSegment(data.word(kBackdrop)).ptr(kBlocks, 0);
uint8 *dstBuffer = workspace() + dstOffset;
for (size_t i = 0; i < 10; ++i) {
@@ -36,7 +35,7 @@ void DreamBase::doBlocks() {
uint16 blockType = mapData[j];
if (blockType != 0) {
uint8 *dst = dstBuffer + i * 320 * 16 + j * 16;
- const uint8 *block = blocks + blockType * 256;
+ const uint8 *block = _backdropBlocks + blockType * 256;
for (size_t k = 0; k < 4; ++k) {
memcpy(dst, block, 16);
block += 16;
@@ -162,17 +161,17 @@ void DreamBase::showAllObs() {
}
}
-bool DreamBase::addAlong(const uint8 *mapFlags) {
+static bool addAlong(const MapFlag *mapFlags) {
for (size_t i = 0; i < 11; ++i) {
- if (mapFlags[3 * i] != 0)
+ if (mapFlags[i]._flag != 0)
return true;
}
return false;
}
-bool DreamBase::addLength(const uint8 *mapFlags) {
+static bool addLength(const MapFlag *mapFlags) {
for (size_t i = 0; i < 10; ++i) {
- if (mapFlags[3 * 11 * i] != 0)
+ if (mapFlags[11 * i]._flag != 0)
return true;
}
return false;
@@ -180,19 +179,19 @@ bool DreamBase::addLength(const uint8 *mapFlags) {
void DreamBase::getDimension(uint8 *mapXstart, uint8 *mapYstart, uint8 *mapXsize, uint8 *mapYsize) {
uint8 yStart = 0;
- while (! addAlong(_mapFlags + 3 * 11 * yStart))
+ while (! addAlong(_mapFlags + 11 * yStart))
++yStart;
uint8 xStart = 0;
- while (! addLength(_mapFlags + 3 * xStart))
+ while (! addLength(_mapFlags + xStart))
++xStart;
uint8 yEnd = 10;
- while (! addAlong(_mapFlags + 3 * 11 * (yEnd - 1)))
+ while (! addAlong(_mapFlags + 11 * (yEnd - 1)))
--yEnd;
uint8 xEnd = 11;
- while (! addLength(_mapFlags + 3 * (xEnd - 1)))
+ while (! addLength(_mapFlags + (xEnd - 1)))
--xEnd;
*mapXstart = xStart;
@@ -241,18 +240,17 @@ void DreamBase::showAllFree() {
}
void DreamBase::drawFlags() {
- uint8 *mapFlags = _mapFlags;
+ MapFlag *mapFlag = _mapFlags;
uint16 mapOffset = kMap + data.byte(kMapy) * kMapwidth + data.byte(kMapx);
const uint8 *mapData = _mapData + mapOffset;
- const uint8 *backdropFlags = getSegment(data.word(kBackdrop)).ptr(kFlags, 0);
for (size_t i = 0; i < 10; ++i) {
for (size_t j = 0; j < 11; ++j) {
uint8 tile = mapData[i * kMapwidth + j];
- mapFlags[0] = backdropFlags[2 * tile + 0];
- mapFlags[1] = backdropFlags[2 * tile + 1];
- mapFlags[2] = tile;
- mapFlags += 3;
+ mapFlag->_flag = _backdropFlags[tile]._flag;
+ mapFlag->_flagEx = _backdropFlags[tile]._flagEx;
+ mapFlag->_type = tile;
+ mapFlag++;
}
}
}
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index b310bb3..21fd415 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -66,6 +66,8 @@ protected:
DreamWeb::DreamWebEngine *engine;
// from backdrop.cpp
+ uint8 *_backdropBlocks;
+ BackdropMapFlag _backdropFlags[96];
uint8 _mapData[kLengthOfMap + 32];
// from keypad.cpp
@@ -103,7 +105,7 @@ protected:
ObjectRef _openInvList[16];
ObjectRef _ryanInvList[30];
uint8 _pointerBack[32*32];
- uint8 _mapFlags[11*10*3];
+ MapFlag _mapFlags[11*10];
uint8 _startPal[3*256];
uint8 _endPal[3*256];
uint8 _mainPal[3*256];
@@ -137,8 +139,6 @@ public:
void calcFrFrame(const Frame *frameBase, uint16 frameNum, uint8* width, uint8* height, uint16 x, uint16 y, ObjPos *objPos);
void makeBackOb(SetObject *objData, uint16 x, uint16 y);
void showAllObs();
- bool addAlong(const uint8 *mapFlags);
- bool addLength(const uint8 *mapFlags);
void getDimension(uint8 *mapXstart, uint8 *mapYstart, uint8 *mapXsize, uint8 *mapYsize);
void calcMapAd();
void showAllFree();
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 910fd81..a0a3f07 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -65,15 +65,15 @@ void DreamGenContext::__start() {
//0x0100: .... .... .... ....
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//0x0110: .... .... .... ....
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
//0x0120: .... .... .... ....
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
//0x0130: .... .... .... ....
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
//0x0140: .... .... .... ....
- 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//0x0150: .... .... .... ....
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
+ 0x00, 0x00, 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 3ad9b1d..b7f3a5e 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -254,49 +254,48 @@ static const uint16 kWorkspace = 282;
static const uint16 kCharset1 = 284;
static const uint16 kMainsprites = 286;
static const uint16 kBackdrop = 288;
-static const uint16 kMapdata = 290;
-static const uint16 kRecordspace = 292;
-static const uint16 kFreedat = 294;
-static const uint16 kSetdat = 296;
-static const uint16 kReel1 = 298;
-static const uint16 kReel2 = 300;
-static const uint16 kReel3 = 302;
-static const uint16 kRoomdesc = 304;
-static const uint16 kFreedesc = 306;
-static const uint16 kSetdesc = 308;
-static const uint16 kBlockdesc = 310;
-static const uint16 kSetframes = 312;
-static const uint16 kFreeframes = 314;
-static const uint16 kPeople = 316;
-static const uint16 kReels = 318;
-static const uint16 kCommandtext = 320;
-static const uint16 kPuzzletext = 322;
-static const uint16 kTraveltext = 324;
-static const uint16 kTempgraphics = 326;
-static const uint16 kTempgraphics2 = 328;
-static const uint16 kTempgraphics3 = 330;
-static const uint16 kTempsprites = 332;
-static const uint16 kTextfile1 = 334;
-static const uint16 kTextfile2 = 336;
-static const uint16 kTextfile3 = 338;
-static const uint16 kBlinkframe = 340;
-static const uint16 kBlinkcount = 341;
-static const uint16 kReasseschanges = 342;
-static const uint16 kPointerspath = 343;
-static const uint16 kManspath = 344;
-static const uint16 kPointerfirstpath = 345;
-static const uint16 kFinaldest = 346;
-static const uint16 kDestination = 347;
-static const uint16 kLinestartx = 348;
-static const uint16 kLinestarty = 350;
-static const uint16 kLineendx = 352;
-static const uint16 kLineendy = 354;
-static const uint16 kLinepointer = 356;
-static const uint16 kLinedirection = 357;
-static const uint16 kLinelength = 358;
-static const uint16 kCh0playing = 359;
-static const uint16 kCh0repeat = 360;
-static const uint16 kCh1playing = 361;
+static const uint16 kRecordspace = 290;
+static const uint16 kFreedat = 292;
+static const uint16 kSetdat = 294;
+static const uint16 kReel1 = 296;
+static const uint16 kReel2 = 298;
+static const uint16 kReel3 = 300;
+static const uint16 kRoomdesc = 302;
+static const uint16 kFreedesc = 304;
+static const uint16 kSetdesc = 306;
+static const uint16 kBlockdesc = 308;
+static const uint16 kSetframes = 310;
+static const uint16 kFreeframes = 312;
+static const uint16 kPeople = 314;
+static const uint16 kReels = 316;
+static const uint16 kCommandtext = 318;
+static const uint16 kPuzzletext = 320;
+static const uint16 kTraveltext = 322;
+static const uint16 kTempgraphics = 324;
+static const uint16 kTempgraphics2 = 326;
+static const uint16 kTempgraphics3 = 328;
+static const uint16 kTempsprites = 330;
+static const uint16 kTextfile1 = 332;
+static const uint16 kTextfile2 = 334;
+static const uint16 kTextfile3 = 336;
+static const uint16 kBlinkframe = 338;
+static const uint16 kBlinkcount = 339;
+static const uint16 kReasseschanges = 340;
+static const uint16 kPointerspath = 341;
+static const uint16 kManspath = 342;
+static const uint16 kPointerfirstpath = 343;
+static const uint16 kFinaldest = 344;
+static const uint16 kDestination = 345;
+static const uint16 kLinestartx = 346;
+static const uint16 kLinestarty = 348;
+static const uint16 kLineendx = 350;
+static const uint16 kLineendy = 352;
+static const uint16 kLinepointer = 354;
+static const uint16 kLinedirection = 355;
+static const uint16 kLinelength = 356;
+static const uint16 kCh0playing = 357;
+static const uint16 kCh0repeat = 358;
+static const uint16 kCh1playing = 359;
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 244f6a3..cd79d38 100644
--- a/engines/dreamweb/sprite.cpp
+++ b/engines/dreamweb/sprite.cpp
@@ -539,10 +539,10 @@ void DreamBase::moveMap(uint8 param) {
void DreamBase::checkOne(uint8 x, uint8 y, uint8 *flag, uint8 *flagEx, uint8 *type, uint8 *flagX, uint8 *flagY) {
*flagX = x / 16;
*flagY = y / 16;
- const uint8 *tileData = &_mapFlags[(*flagY * 11 + *flagX) * 3];
- *flag = tileData[0];
- *flagEx = tileData[1];
- *type = tileData[2];
+ const MapFlag &tileData = _mapFlags[*flagY * 11 + *flagX];
+ *flag = tileData._flag;
+ *flagEx = tileData._flagEx;
+ *type = tileData._type;
}
uint8 DreamBase::getBlockOfPixel(uint8 x, uint8 y) {
@@ -1101,7 +1101,7 @@ void DreamBase::clearBeforeLoad() {
//clearRest
memset(_mapData, 0, kMaplen);
- deallocateMem(data.word(kBackdrop));
+ delete[] _backdropBlocks;
deallocateMem(data.word(kSetframes));
deallocateMem(data.word(kReels));
deallocateMem(data.word(kPeople));
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index af8b3e9..4e58988 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -281,6 +281,17 @@ struct ObjectRef {
}
};
+struct BackdropMapFlag {
+ uint8 _flag;
+ uint8 _flagEx;
+};
+
+struct MapFlag {
+ uint8 _flag;
+ uint8 _flagEx;
+ uint8 _type;
+};
+
} // End of namespace DreamWeb
#endif
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index e47e792..13f2740 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -2148,7 +2148,7 @@ void DreamBase::getRidOfTempsP() {
}
void DreamBase::getRidOfAll() {
- deallocateMem(data.word(kBackdrop));
+ delete[] _backdropBlocks;
deallocateMem(data.word(kSetframes));
deallocateMem(data.word(kReel1));
deallocateMem(data.word(kReel2));
@@ -2174,7 +2174,11 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) {
for (int i = 0; i < 15; ++i)
len[i] = header.len(i);
- data.word(kBackdrop) = allocateAndLoad(len[0]);
+ assert(len[0] >= 192);
+ _backdropBlocks = new uint8[len[0] - 192];
+ engine->readFromFile((uint8 *)_backdropFlags, 192);
+ engine->readFromFile(_backdropBlocks, len[0] - 192);
+
clearAndLoad(workspace(), 0, len[1], 132*66); // 132*66 = maplen
sortOutMap();
data.word(kSetframes) = allocateAndLoad(len[2]);
Commit: 08be0411b1bfba715d5c1b50b50a893a27e12f8c
https://github.com/scummvm/scummvm/commit/08be0411b1bfba715d5c1b50b50a893a27e12f8c
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-12-27T09:40:25-08:00
Commit Message:
DREAMWEB: Streamline text file handling
Changed paths:
devtools/tasmrecover/tasm-recover
engines/dreamweb/dreambase.h
engines/dreamweb/dreamgen.cpp
engines/dreamweb/dreamgen.h
engines/dreamweb/monitor.cpp
engines/dreamweb/newplace.cpp
engines/dreamweb/people.cpp
engines/dreamweb/structs.h
engines/dreamweb/stubs.cpp
engines/dreamweb/use.cpp
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index 1edd60a..6845890 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -244,6 +244,12 @@ p = parser(skip_binary_data = [
'mapstore',
'mapdata',
'backdrops',
+ 'textfile1',
+ 'textfile2',
+ 'textfile3',
+ 'puzzletext',
+ 'commandtext',
+ 'traveltext',
# vgagrafx.asm
'cityname',
'extragraphics1',
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 21fd415..4727fc4 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -65,6 +65,8 @@ class DreamBase : public SegmentManager {
protected:
DreamWeb::DreamWebEngine *engine;
+ const char *_timedString;
+
// from backdrop.cpp
uint8 *_backdropBlocks;
BackdropMapFlag _backdropFlags[96];
@@ -121,6 +123,14 @@ protected:
Common::List<Rain> _rainList;
uint8 _initialVars[kLengthOfVars]; // TODO: This shouldn't be necessary
+ // textfiles
+ TextFile _textFile1;
+ TextFile _textFile2;
+ TextFile _textFile3;
+ TextFile _travelText;
+ TextFile _puzzleText;
+ TextFile _commandText;
+
public:
DreamBase(DreamWeb::DreamWebEngine *en);
@@ -481,6 +491,7 @@ public:
uint16 allocateMem(uint16 paragraphs);
void deallocateMem(uint16 segment);
uint16 allocateAndLoad(unsigned int size);
+ void loadTextFile(TextFile &file, const char *fileName);
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);
@@ -625,7 +636,7 @@ public:
void dumpWatch();
void watchCount();
void signOn();
- void searchForFiles(uint16 segment);
+ void searchForFiles(const char *filesString);
void triggerMessage(uint16 index);
void processTrigger();
void dreamweb();
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index a0a3f07..b0de4df 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -69,11 +69,9 @@ void DreamGenContext::__start() {
//0x0120: .... .... .... ....
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
//0x0130: .... .... .... ....
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
//0x0140: .... .... .... ....
- 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- //0x0150: .... .... .... ....
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, };
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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 b7f3a5e..132ae0f 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -268,34 +268,28 @@ static const uint16 kSetframes = 310;
static const uint16 kFreeframes = 312;
static const uint16 kPeople = 314;
static const uint16 kReels = 316;
-static const uint16 kCommandtext = 318;
-static const uint16 kPuzzletext = 320;
-static const uint16 kTraveltext = 322;
-static const uint16 kTempgraphics = 324;
-static const uint16 kTempgraphics2 = 326;
-static const uint16 kTempgraphics3 = 328;
-static const uint16 kTempsprites = 330;
-static const uint16 kTextfile1 = 332;
-static const uint16 kTextfile2 = 334;
-static const uint16 kTextfile3 = 336;
-static const uint16 kBlinkframe = 338;
-static const uint16 kBlinkcount = 339;
-static const uint16 kReasseschanges = 340;
-static const uint16 kPointerspath = 341;
-static const uint16 kManspath = 342;
-static const uint16 kPointerfirstpath = 343;
-static const uint16 kFinaldest = 344;
-static const uint16 kDestination = 345;
-static const uint16 kLinestartx = 346;
-static const uint16 kLinestarty = 348;
-static const uint16 kLineendx = 350;
-static const uint16 kLineendy = 352;
-static const uint16 kLinepointer = 354;
-static const uint16 kLinedirection = 355;
-static const uint16 kLinelength = 356;
-static const uint16 kCh0playing = 357;
-static const uint16 kCh0repeat = 358;
-static const uint16 kCh1playing = 359;
+static const uint16 kTempgraphics = 318;
+static const uint16 kTempgraphics2 = 320;
+static const uint16 kTempgraphics3 = 322;
+static const uint16 kTempsprites = 324;
+static const uint16 kBlinkframe = 326;
+static const uint16 kBlinkcount = 327;
+static const uint16 kReasseschanges = 328;
+static const uint16 kPointerspath = 329;
+static const uint16 kManspath = 330;
+static const uint16 kPointerfirstpath = 331;
+static const uint16 kFinaldest = 332;
+static const uint16 kDestination = 333;
+static const uint16 kLinestartx = 334;
+static const uint16 kLinestarty = 336;
+static const uint16 kLineendx = 338;
+static const uint16 kLineendy = 340;
+static const uint16 kLinepointer = 342;
+static const uint16 kLinedirection = 343;
+static const uint16 kLinelength = 344;
+static const uint16 kCh0playing = 345;
+static const uint16 kCh0repeat = 346;
+static const uint16 kCh1playing = 347;
static const uint16 kBlocktextdat = (0);
static const uint16 kPersonframes = (0);
static const uint16 kDebuglevel1 = (0);
diff --git a/engines/dreamweb/monitor.cpp b/engines/dreamweb/monitor.cpp
index 4f037c6..23c26f6 100644
--- a/engines/dreamweb/monitor.cpp
+++ b/engines/dreamweb/monitor.cpp
@@ -91,9 +91,11 @@ void DreamBase::useMon() {
} while (!stop);
getRidOfTemp();
getRidOfTempCharset();
- deallocateMem(data.word(kTextfile1));
- deallocateMem(data.word(kTextfile2));
- deallocateMem(data.word(kTextfile3));
+
+ _textFile1.clear();
+ _textFile2.clear();
+ _textFile3.clear();
+
data.byte(kGetback) = 1;
playChannel1(26);
data.byte(kManisoffscreen) = 0;
@@ -324,7 +326,7 @@ void DreamBase::randomAccess(uint16 count) {
void DreamBase::monMessage(uint8 index) {
assert(index > 0);
- const char *string = (const char *)getSegment(data.word(kTextfile1)).ptr(kTextstart, 0);
+ const char *string = _textFile1._text;
for (uint8 i = 0; i < index; ++i) {
while (*string++ != '+') {
}
@@ -376,21 +378,21 @@ void DreamBase::printOuterMon() {
void DreamBase::loadPersonal() {
if (data.byte(kLocation) == 0 || data.byte(kLocation) == 42)
- data.word(kTextfile1) = standardLoad("DREAMWEB.T01"); // monitor file 1
+ loadTextFile(_textFile1, "DREAMWEB.T01"); // monitor file 1
else
- data.word(kTextfile1) = standardLoad("DREAMWEB.T02"); // monitor file 2
+ loadTextFile(_textFile1, "DREAMWEB.T02"); // monitor file 2
}
void DreamBase::loadNews() {
// textfile2 holds information accessible by anyone
if (data.byte(kNewsitem) == 0)
- data.word(kTextfile2) = standardLoad("DREAMWEB.T10"); // monitor file 10
+ loadTextFile(_textFile2, "DREAMWEB.T10"); // monitor file 10
else if (data.byte(kNewsitem) == 1)
- data.word(kTextfile2) = standardLoad("DREAMWEB.T11"); // monitor file 11
+ loadTextFile(_textFile2, "DREAMWEB.T11"); // monitor file 11
else if (data.byte(kNewsitem) == 2)
- data.word(kTextfile2) = standardLoad("DREAMWEB.T12"); // monitor file 12
+ loadTextFile(_textFile2, "DREAMWEB.T12"); // monitor file 12
else
- data.word(kTextfile2) = standardLoad("DREAMWEB.T13"); // monitor file 13
+ loadTextFile(_textFile2, "DREAMWEB.T13"); // monitor file 13
}
void DreamBase::loadCart() {
@@ -401,15 +403,15 @@ void DreamBase::loadCart() {
cartridgeId = getExAd(cartridgeIndex)->id[3] + 1;
if (cartridgeId == 0)
- data.word(kTextfile3) = standardLoad("DREAMWEB.T20"); // monitor file 20
+ loadTextFile(_textFile3, "DREAMWEB.T20"); // monitor file 20
else if (cartridgeId == 1)
- data.word(kTextfile3) = standardLoad("DREAMWEB.T21"); // monitor file 21
+ loadTextFile(_textFile3, "DREAMWEB.T21"); // monitor file 21
else if (cartridgeId == 2)
- data.word(kTextfile3) = standardLoad("DREAMWEB.T22"); // monitor file 22
+ loadTextFile(_textFile3, "DREAMWEB.T22"); // monitor file 22
else if (cartridgeId == 3)
- data.word(kTextfile3) = standardLoad("DREAMWEB.T23"); // monitor file 23
+ loadTextFile(_textFile3, "DREAMWEB.T23"); // monitor file 23
else
- data.word(kTextfile3) = standardLoad("DREAMWEB.T24"); // monitor file 24
+ loadTextFile(_textFile3, "DREAMWEB.T24"); // monitor file 24
}
void DreamBase::showKeys() {
@@ -479,9 +481,9 @@ void DreamBase::dirCom() {
monitorLogo();
scrollMonitor();
monMessage(9);
- searchForFiles(data.word(kTextfile1));
- searchForFiles(data.word(kTextfile2));
- searchForFiles(data.word(kTextfile3));
+ searchForFiles(_textFile1._text);
+ searchForFiles(_textFile2._text);
+ searchForFiles(_textFile3._text);
scrollMonitor();
}
@@ -491,13 +493,13 @@ void DreamBase::dirFile(const char *dirName) {
memcpy(topic, dirName, 14);
topic[0] = 34;
- const char *text = (const char *)getSegment(data.word(kTextfile1)).ptr(kTextstart, 0);
+ const char *text = _textFile1._text;
const char *found = searchForString(topic, text);
if (!found) {
- text = (const char *)getSegment(data.word(kTextfile2)).ptr(kTextstart, 0);
+ text = _textFile2._text;
found = searchForString(topic, text);
if (!found) {
- text = (const char *)getSegment(data.word(kTextfile3)).ptr(kTextstart, 0);
+ text = _textFile3._text;
found = searchForString(topic, text);
}
}
@@ -540,13 +542,13 @@ void DreamBase::read() {
const char *topic = _currentFile;
- const char *text = (const char *)getSegment(data.word(kTextfile1)).ptr(kTextstart, 0);
+ const char *text = _textFile1._text;
const char *found = searchForString(topic, text);
if (!found) {
- text = (const char *)getSegment(data.word(kTextfile2)).ptr(kTextstart, 0);
+ text = _textFile2._text;
found = searchForString(topic, text);
if (!found) {
- text = (const char *)getSegment(data.word(kTextfile3)).ptr(kTextstart, 0);
+ text = _textFile3._text;
found = searchForString(topic, text);
}
}
@@ -644,8 +646,7 @@ void DreamBase::signOn() {
}
}
-void DreamBase::searchForFiles(uint16 segment) {
- const char *filesString = (const char *)getSegment(segment).ptr(kTextstart, 0);
+void DreamBase::searchForFiles(const char *filesString) {
byte curChar;
while (true) {
diff --git a/engines/dreamweb/newplace.cpp b/engines/dreamweb/newplace.cpp
index 4d82d70..21975ee 100644
--- a/engines/dreamweb/newplace.cpp
+++ b/engines/dreamweb/newplace.cpp
@@ -92,7 +92,8 @@ void DreamBase::selectLocation() {
getRidOfTemp();
getRidOfTemp2();
getRidOfTemp3();
- deallocateMem(data.word(kTraveltext));
+
+ _travelText.clear();
}
void DreamBase::showCity() {
@@ -120,8 +121,7 @@ void DreamBase::lookAtPlace() {
if (_foreignRelease)
showFrame(tempGraphics3(), 60, 72+55+21, 4, 0);
- uint16 offset = kTextstart + getSegment(data.word(kTraveltext)).word(data.byte(kDestpos) * 2);
- const uint8 *string = getSegment(data.word(kTraveltext)).ptr(offset, 0);
+ const uint8 *string = (const uint8 *)_travelText.getString(data.byte(kDestpos));
findNextColon(&string);
uint16 y = (_foreignRelease) ? 84 + 4 : 84;
printDirect(&string, 63, &y, 191, 191 & 1);
@@ -153,8 +153,7 @@ void DreamBase::locationPic() {
if (data.byte(kDestpos) == data.byte(kReallocation))
showFrame(tempGraphics(), 104, 140 + 14, 3, 0); // Currently in this location
- uint16 offset = kTextstart + getSegment(data.word(kTraveltext)).word(data.byte(kDestpos) * 2);
- const uint8 *string = getSegment(data.word(kTraveltext)).ptr(offset, 0);
+ const uint8 *string = (const uint8 *)_travelText.getString(data.byte(kDestpos));
DreamBase::printDirect(string, 50, 20, 241, 241 & 1);
}
diff --git a/engines/dreamweb/people.cpp b/engines/dreamweb/people.cpp
index a6ebbcc..7adc2b1 100644
--- a/engines/dreamweb/people.cpp
+++ b/engines/dreamweb/people.cpp
@@ -917,8 +917,7 @@ void DreamBase::mugger(ReelRoutine &routine) {
createPanel2();
showIcon();
- uint16 offset = kTextstart + getSegment(data.word(kPuzzletext)).word(41 * 2);
- const uint8 *string = getSegment(data.word(kPuzzletext)).ptr(offset, 0);
+ const uint8 *string = (const uint8 *)_puzzleText.getString(41);
uint16 y = 104;
printDirect(&string, 33 + 20, &y, 241, 241 & 1);
workToScreen();
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index 4e58988..ce675fc 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -292,6 +292,23 @@ struct MapFlag {
uint8 _type;
};
+struct TextFile {
+ TextFile() : _text(0) { }
+
+ uint16 _offsetsLE[66];
+ char *_text;
+
+ const char *getString(unsigned int i) const {
+ assert(i < 66);
+ return _text + READ_LE_UINT16(&_offsetsLE[i]);
+ }
+ void clear() {
+ delete[] _text;
+ _text = 0;
+ }
+};
+
+
} // End of namespace DreamWeb
#endif
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 13f2740..1868c19 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -644,6 +644,23 @@ done: // The engine will need some cleaner finalization, let's put it here for n
engine->freeIcons2();
}
+void DreamBase::loadTextFile(TextFile &file, const char *fileName)
+{
+ FileHeader header;
+
+ Common::File f;
+ f.open(fileName);
+ f.read((uint8 *)&header, sizeof(FileHeader));
+ uint16 sizeInBytes = header.len(0);
+ assert(sizeInBytes >= 2*66);
+
+ delete[] file._text;
+ file._text = new char[sizeInBytes - 2*66];
+
+ f.read(file._offsetsLE, 2*66);
+ f.read(file._text, sizeInBytes - 2*66);
+}
+
void DreamBase::screenUpdate() {
newPlace();
mainScreen();
@@ -837,8 +854,7 @@ void DreamBase::putUnderTimed() {
void DreamBase::triggerMessage(uint16 index) {
multiGet(_mapStore, 174, 153, 200, 63);
- uint16 offset = kTextstart + getSegment(data.word(kPuzzletext)).word(index * 2);
- const uint8 *string = getSegment(data.word(kPuzzletext)).ptr(offset, 0);
+ const uint8 *string = (const uint8 *)_puzzleText.getString(index);
uint16 y = 156;
printDirect(&string, 174, &y, 141, true);
hangOn(140);
@@ -877,9 +893,8 @@ void DreamBase::useTimedText() {
else if (data.word(kTimecount) > data.word(kCounttotimed))
return;
- const uint8 *string = getSegment(data.word(kTimedseg)).ptr(data.word(kTimedoffset), 0);
- uint16 y = data.byte(kTimedy);
- printDirect(&string, data.byte(kTimedx), &y, 237, true);
+ const uint8 *string = (const uint8 *)_timedString;
+ printDirect(string, data.byte(kTimedx), data.byte(kTimedy), 237, true);
data.byte(kNeedtodumptimed) = 1;
}
@@ -904,10 +919,8 @@ void DreamBase::setupTimedTemp(uint8 textIndex, uint8 voiceIndex, uint8 x, uint8
data.byte(kTimedx) = x;
data.word(kCounttotimed) = countToTimed;
data.word(kTimecount) = timeCount + countToTimed;
- data.word(kTimedseg) = data.word(kTextfile1);
- data.word(kTimedoffset) = kTextstart + getSegment(data.word(kTextfile1)).word(textIndex * 2);
- const uint8 *string = getSegment(data.word(kTextfile1)).ptr(data.word(kTimedoffset), 0);
- debug(1, "setupTimedTemp: (%d, %d) => '%s'", textIndex, voiceIndex, string);
+ _timedString = _textFile1.getString(textIndex);
+ debug(1, "setupTimedTemp: (%d, %d) => '%s'", textIndex, voiceIndex, _timedString);
}
void DreamBase::dumpTimedText() {
@@ -1130,11 +1143,8 @@ void DreamBase::delTextLine() {
void DreamBase::commandOnly(uint8 command) {
delTextLine();
- uint16 index = command * 2;
- uint16 offset = kTextstart + getSegment(data.word(kCommandtext)).word(index);
- uint16 y = data.word(kTextaddressy);
- const uint8 *string = getSegment(data.word(kCommandtext)).ptr(offset, 0);
- printDirect(&string, data.word(kTextaddressx), &y, data.byte(kTextlen), (bool)(data.byte(kTextlen) & 1));
+ const uint8 *string = (const uint8 *)_commandText.getString(command);
+ printDirect(string, data.word(kTextaddressx), data.word(kTextaddressy), data.byte(kTextlen), (bool)(data.byte(kTextlen) & 1));
data.byte(kNewtextline) = 1;
}
@@ -1228,12 +1238,11 @@ void DreamBase::copyName(uint8 type, uint8 index, uint8 *dst) {
void DreamBase::commandWithOb(uint8 command, uint8 type, uint8 index) {
uint8 commandLine[64] = "OBJECT NAME ONE ";
delTextLine();
- uint16 commandText = kTextstart + getSegment(data.word(kCommandtext)).word(command * 2);
uint8 textLen = data.byte(kTextlen);
- {
- const uint8 *string = getSegment(data.word(kCommandtext)).ptr(commandText, 0);
- printDirect(string, data.word(kTextaddressx), data.word(kTextaddressy), textLen, (bool)(textLen & 1));
- }
+
+ const uint8 *string = (const uint8 *)_commandText.getString(command);
+ printDirect(string, data.word(kTextaddressx), data.word(kTextaddressy), textLen, (bool)(textLen & 1));
+
copyName(type, index, commandLine);
uint16 x = data.word(kLastxpos);
if (command != 0)
@@ -1628,14 +1637,12 @@ void DreamBase::animPointer() {
}
void DreamBase::printMessage(uint16 x, uint16 y, uint8 index, uint8 maxWidth, bool centered) {
- uint16 offset = kTextstart + getSegment(data.word(kCommandtext)).word(index * 2);
- const uint8 *string = getSegment(data.word(kCommandtext)).ptr(offset, 0);
+ const uint8 *string = (const uint8 *)_commandText.getString(index);
printDirect(string, x, y, maxWidth, centered);
}
void DreamBase::printMessage2(uint16 x, uint16 y, uint8 index, uint8 maxWidth, bool centered, uint8 count) {
- uint16 offset = kTextstart + getSegment(data.word(kCommandtext)).word(index * 2);
- const uint8 *string = getSegment(data.word(kCommandtext)).ptr(offset, 0);
+ const uint8 *string = (const uint8 *)_commandText.getString(index);
while (count--) {
findNextColon(&string);
}
@@ -2033,8 +2040,8 @@ void DreamBase::readSetData() {
engine->setIcons2(icons2Buffer);
data.word(kMainsprites) = standardLoad("DREAMWEB.S00");
- data.word(kPuzzletext) = standardLoad("DREAMWEB.T80");
- data.word(kCommandtext) = standardLoad("DREAMWEB.T84");
+ loadTextFile(_puzzleText, "DREAMWEB.T80");
+ loadTextFile(_commandText, "DREAMWEB.T84");
useCharset1();
// FIXME: Why is this commented out?
@@ -2128,7 +2135,7 @@ void DreamBase::getRidOfTemp() {
}
void DreamBase::getRidOfTempText() {
- deallocateMem(data.word(kTextfile1));
+ _textFile1.clear();
}
void DreamBase::getRidOfTemp2() {
@@ -2359,10 +2366,7 @@ void DreamBase::examIcon() {
}
const uint8 *DreamBase::getTextInFile1(uint16 index) {
- SegmentRef text = getSegment(data.word(kTextfile1));
- uint16 offset = text.word(index * 2) + kTextstart;
- const uint8 *string = text.ptr(offset, 0);
- return string;
+ return (const uint8 *)_textFile1.getString(index);
}
void DreamBase::checkFolderCoords() {
@@ -2443,11 +2447,11 @@ void DreamBase::folderExit() {
}
void DreamBase::loadTravelText() {
- data.word(kTraveltext) = standardLoad("DREAMWEB.T81"); // location descs
+ loadTextFile(_travelText, "DREAMWEB.T81"); // location descs
}
void DreamBase::loadTempText(const char *fileName) {
- data.word(kTextfile1) = standardLoad(fileName);
+ loadTextFile(_textFile1, fileName);
}
void DreamBase::drawFloor() {
@@ -2835,13 +2839,11 @@ void DreamBase::describeOb() {
// Additional text
if (compare(data.byte(kCommand), data.byte(kObjecttype), "CUPE")) {
// Empty cup
- uint16 offset = kTextstart + getSegment(data.word(kPuzzletext)).word(40 * 2);
- const uint8 *string = getSegment(data.word(kPuzzletext)).ptr(offset, 0);
+ const uint8 *string = (const uint8 *)_puzzleText.getString(40);
printDirect(string, 36, y + 10, 241, 241 & 1);
} else if (compare(data.byte(kCommand), data.byte(kObjecttype), "CUPF")) {
// Full cup
- uint16 offset = kTextstart + getSegment(data.word(kPuzzletext)).word(39 * 2);
- const uint8 *string = getSegment(data.word(kPuzzletext)).ptr(offset, 0);
+ const uint8 *string = (const uint8 *)_puzzleText.getString(39);
printDirect(string, 36, y + 10, 241, 241 & 1);
}
}
@@ -3325,10 +3327,8 @@ void DreamBase::setupTimedUse(uint16 textIndex, uint16 countToTimed, uint16 time
data.byte(kTimedx) = x;
data.word(kCounttotimed) = countToTimed;
data.word(kTimecount) = timeCount + countToTimed;
- data.word(kTimedseg) = data.word(kPuzzletext);
- data.word(kTimedoffset) = kTextstart + getSegment(data.word(kPuzzletext)).word(textIndex * 2);
- const uint8 *string = getSegment(data.word(kPuzzletext)).ptr(data.word(kTimedoffset), 0);
- debug(1, "setupTimedUse: %d => '%s'", textIndex, string);
+ _timedString = _puzzleText.getString(textIndex);
+ debug(1, "setupTimedUse: %d => '%s'", textIndex, _timedString);
}
void DreamBase::entryTexts() {
diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp
index 280d78b..1b91cc8 100644
--- a/engines/dreamweb/use.cpp
+++ b/engines/dreamweb/use.cpp
@@ -1644,8 +1644,7 @@ void DreamBase::showPuzText(uint16 command, uint16 count) {
showMan();
showExit();
obIcons();
- uint16 offset = kTextstart + getSegment(data.word(kPuzzletext)).word(command * 2);
- const uint8 *string = getSegment(data.word(kPuzzletext)).ptr(offset, 0);
+ const uint8 *string = (const uint8 *)_puzzleText.getString(command);
printDirect(string, 36, 104, 241, 241 & 1);
workToScreenM();
hangOnP(count);
More information about the Scummvm-git-logs
mailing list