diff options
author | Willem Jan Palenstijn | 2011-12-27 17:56:37 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2011-12-27 18:01:33 +0100 |
commit | df7bb24184ea599280640107c19f898c43d74ac3 (patch) | |
tree | 5cf1646564d1f3b3cac8d03f392f00198952640b /engines/dreamweb | |
parent | 7bae1022eddc9805bb9163c01676f02f50459c4f (diff) | |
download | scummvm-rg350-df7bb24184ea599280640107c19f898c43d74ac3.tar.gz scummvm-rg350-df7bb24184ea599280640107c19f898c43d74ac3.tar.bz2 scummvm-rg350-df7bb24184ea599280640107c19f898c43d74ac3.zip |
DREAMWEB: Create MapFlags struct, remove backdrops segment
Diffstat (limited to 'engines/dreamweb')
-rw-r--r-- | engines/dreamweb/backdrop.cpp | 30 | ||||
-rw-r--r-- | engines/dreamweb/dreambase.h | 6 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.cpp | 6 | ||||
-rw-r--r-- | engines/dreamweb/dreamgen.h | 85 | ||||
-rw-r--r-- | engines/dreamweb/sprite.cpp | 10 | ||||
-rw-r--r-- | engines/dreamweb/structs.h | 11 | ||||
-rw-r--r-- | engines/dreamweb/stubs.cpp | 8 |
7 files changed, 84 insertions, 72 deletions
diff --git a/engines/dreamweb/backdrop.cpp b/engines/dreamweb/backdrop.cpp index e85889dae5..553390fe70 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 b310bb3b46..21fd415052 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 910fd8147d..a0a3f0759b 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 3ad9b1d186..b7f3a5e452 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 244f6a32ae..cd79d386fc 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 af8b3e9f00..4e58988595 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 e47e79250f..13f27406d8 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]); |