From 15a1f41e8a9ff22ba4ebb83c1a56d437ec518c2e Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 27 Dec 2011 22:42:57 +0100 Subject: DREAMWEB: Remove reels segment --- engines/dreamweb/dreambase.h | 3 ++- engines/dreamweb/dreamgen.cpp | 4 ++-- engines/dreamweb/dreamgen.h | 37 ++++++++++++++++++------------------- engines/dreamweb/dreamweb.cpp | 1 + engines/dreamweb/pathfind.cpp | 13 +++++-------- engines/dreamweb/sprite.cpp | 5 +++-- engines/dreamweb/stubs.cpp | 23 +++++++++++------------ 7 files changed, 42 insertions(+), 44 deletions(-) (limited to 'engines/dreamweb') diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h index c62d202890..a9b0f57119 100644 --- a/engines/dreamweb/dreambase.h +++ b/engines/dreamweb/dreambase.h @@ -155,6 +155,8 @@ protected: TextFile _freeDesc; TextFile _personText; uint16 _personFramesLE[12]; + RoomPaths _pathData[36]; + Reel *_reelList; // Extras segment (NB: this is saved) GraphicsFile _exFrames; @@ -517,7 +519,6 @@ public: void allocateBuffers(); uint16 allocateMem(uint16 paragraphs); void deallocateMem(uint16 segment); - 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); diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp index de85b4c54e..4dc099a0b9 100644 --- a/engines/dreamweb/dreamgen.cpp +++ b/engines/dreamweb/dreamgen.cpp @@ -65,9 +65,9 @@ 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, 0xff, 0xff, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0x0120: .... .... .... .... - 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 bbedcbcbb9..1ea497281c 100644 --- a/engines/dreamweb/dreamgen.h +++ b/engines/dreamweb/dreamgen.h @@ -255,25 +255,24 @@ static const uint16 kBackdrop = 284; static const uint16 kRecordspace = 286; static const uint16 kFreedat = 288; static const uint16 kSetdat = 290; -static const uint16 kReels = 292; -static const uint16 kBlinkframe = 294; -static const uint16 kBlinkcount = 295; -static const uint16 kReasseschanges = 296; -static const uint16 kPointerspath = 297; -static const uint16 kManspath = 298; -static const uint16 kPointerfirstpath = 299; -static const uint16 kFinaldest = 300; -static const uint16 kDestination = 301; -static const uint16 kLinestartx = 302; -static const uint16 kLinestarty = 304; -static const uint16 kLineendx = 306; -static const uint16 kLineendy = 308; -static const uint16 kLinepointer = 310; -static const uint16 kLinedirection = 311; -static const uint16 kLinelength = 312; -static const uint16 kCh0playing = 313; -static const uint16 kCh0repeat = 314; -static const uint16 kCh1playing = 315; +static const uint16 kBlinkframe = 292; +static const uint16 kBlinkcount = 293; +static const uint16 kReasseschanges = 294; +static const uint16 kPointerspath = 295; +static const uint16 kManspath = 296; +static const uint16 kPointerfirstpath = 297; +static const uint16 kFinaldest = 298; +static const uint16 kDestination = 299; +static const uint16 kLinestartx = 300; +static const uint16 kLinestarty = 302; +static const uint16 kLineendx = 304; +static const uint16 kLineendy = 306; +static const uint16 kLinepointer = 308; +static const uint16 kLinedirection = 309; +static const uint16 kLinelength = 310; +static const uint16 kCh0playing = 311; +static const uint16 kCh0repeat = 312; +static const uint16 kCh1playing = 313; static const uint16 kBlocktextdat = (0); static const uint16 kPersonframes = (0); static const uint16 kDebuglevel1 = (0); diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp index 539433dbb9..468999e1ba 100644 --- a/engines/dreamweb/dreamweb.cpp +++ b/engines/dreamweb/dreamweb.cpp @@ -417,6 +417,7 @@ DreamBase::DreamBase(DreamWeb::DreamWebEngine *en) : _currentSample = 0xff; _backdropBlocks = 0; + _reelList = 0; _oldSubject._type = 0; _oldSubject._index = 0; diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp index 4f887db251..8a0596149e 100644 --- a/engines/dreamweb/pathfind.cpp +++ b/engines/dreamweb/pathfind.cpp @@ -42,19 +42,16 @@ void DreamBase::turnPathOff(uint8 param) { void DreamBase::turnAnyPathOn(uint8 param, uint8 room) { findOrMake(param, 0xff, room + 100); - PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * room, 0); - paths[param].on = 0xff; + _pathData[room].nodes[param].on = 0xff; } void DreamBase::turnAnyPathOff(uint8 param, uint8 room) { findOrMake(param, 0x00, room + 100); - PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * room, 0); - paths[param].on = 0x00; + _pathData[room].nodes[param].on = 0x00; } RoomPaths *DreamBase::getRoomsPaths() { - void *result = getSegment(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144); - return (RoomPaths *)result; + return &_pathData[data.byte(kRoomnum)]; } void DreamBase::faceRightWay() { @@ -310,7 +307,7 @@ void DreamBase::workoutFrames() { } byte DreamBase::findFirstPath(byte x, byte y) { - PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * data.byte(kRoomnum), 0); + PathNode *paths = _pathData[data.byte(kRoomnum)].nodes; for (uint8 index = 0; index < 12; index++) { if (paths[index].x1 == 0xff && paths[index].y1 == 0xff) @@ -329,7 +326,7 @@ byte DreamBase::findFirstPath(byte x, byte y) { } byte DreamBase::findPathOfPoint(byte x, byte y) { - PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * data.byte(kRoomnum), 0); + PathNode *paths = _pathData[data.byte(kRoomnum)].nodes; for (uint8 index = 0; index < 12; index++) { if (paths[index].on != 0xff) diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 424d8d52b2..cc48ca13b2 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -429,7 +429,7 @@ void DreamBase::liftSprite(Sprite *sprite, SetObject *objData) { } Reel *DreamBase::getReelStart(uint16 reelPointer) { - Reel *reel = (Reel *)getSegment(data.word(kReels)).ptr(kReellist + reelPointer * sizeof(Reel) * 8, sizeof(Reel)); + Reel *reel = &_reelList[reelPointer * 8]; return reel; } @@ -1101,7 +1101,8 @@ void DreamBase::clearBeforeLoad() { delete[] _backdropBlocks; _backdropBlocks = 0; _setFrames.clear(); - deallocateMem(data.word(kReels)); + delete[] _reelList; + _reelList = 0; _personText.clear(); _setDesc.clear(); _blockDesc.clear(); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 994111df04..0137fd2f85 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -1049,13 +1049,6 @@ void DreamBase::lockMon() { } } -uint16 DreamBase::allocateAndLoad(unsigned int size) { - // allocatemem adds 32 bytes, so it doesn't matter that size/16 rounds down - uint16 result = allocateMem(size / 16); - engine->readFromFile(getSegment(result).ptr(0, size), size); - return result; -} - void DreamBase::clearAndLoad(uint8 *buf, uint8 c, unsigned int size, unsigned int maxSize) { assert(size <= maxSize); @@ -1368,9 +1361,7 @@ void DreamBase::doChange(uint8 index, uint8 value, uint8 type) { if (freeObject->mapad[0] == 0xff) freeObject->mapad[0] = value; } else { //path -// getSegment(data.word(kReels)).byte(kPathdata + (type - 100) * 144 + index * 8 + 6) = value; - PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * (type - 100), 0); - paths[index].on = value; + _pathData[type - 100].nodes[index].on = value; } } @@ -2168,7 +2159,8 @@ void DreamBase::getRidOfAll() { _reel1.clear(); _reel2.clear(); _reel3.clear(); - deallocateMem(data.word(kReels)); + delete[] _reelList; + _reelList = 0; _personText.clear(); _setDesc.clear(); _blockDesc.clear(); @@ -2208,7 +2200,14 @@ void DreamBase::loadRoomData(const Room &room, bool skipDat) { loadGraphicsSegment(_reel1, len[4]); loadGraphicsSegment(_reel2, len[5]); loadGraphicsSegment(_reel3, len[6]); - data.word(kReels) = allocateAndLoad(len[7]); + + // segment 7 consists of 36*38 pathNodes followed by 'reelList' + engine->readFromFile((uint8 *)_pathData, 36*sizeof(RoomPaths)); + unsigned int reelLen = len[7] - 36*sizeof(RoomPaths); + unsigned int reelCount = (reelLen + sizeof(Reel) - 1) / sizeof(Reel); + delete[] _reelList; + _reelList = new Reel[reelCount]; + engine->readFromFile((uint8 *)_reelList, reelLen); // segment 8 consists of 12 personFrames followed by a TextFile engine->readFromFile((uint8 *)_personFramesLE, 24); -- cgit v1.2.3