diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lab/allocroom.cpp | 123 | ||||
-rw-r--r-- | engines/lab/parsefun.h | 2 |
2 files changed, 0 insertions, 125 deletions
diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp index e0051faf4c..a95aa8e68f 100644 --- a/engines/lab/allocroom.cpp +++ b/engines/lab/allocroom.cpp @@ -77,127 +77,4 @@ void freeRoomBuffer() { free(RoomBuffer); } -/*****************************************************************************/ -/* Frees a room's resources. */ -/*****************************************************************************/ -static void freeRoom(uint16 roomMarkerId) { - uint16 roomNum = _roomMarkers[roomMarkerId]._roomNum; - - if (roomNum != EMPTYROOM) { - _rooms[roomNum]._northView = nullptr; - _rooms[roomNum]._southView = nullptr; - _rooms[roomNum]._eastView = nullptr; - _rooms[roomNum]._westView = nullptr; - - RuleList *rules = _rooms[roomNum]._rules; - for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) - delete *rule; - _rooms[roomNum]._rules->clear(); - delete _rooms[roomNum]._rules; - _rooms[roomNum]._rules = nullptr; - _rooms[roomNum]._roomMsg = nullptr; - } - - _roomMarkers[roomMarkerId]._roomNum = EMPTYROOM; - _roomMarkers[roomMarkerId]._start0 = nullptr; - _roomMarkers[roomMarkerId]._end0 = nullptr; - _roomMarkers[roomMarkerId]._start1 = nullptr; - _roomMarkers[roomMarkerId]._end1 = nullptr; -} - -/*****************************************************************************/ -/* Gets a chunk of memory from the buffer. */ -/*****************************************************************************/ -static void *getCurMem(uint16 Size) { - if (((int32) Size) > MemLeftInBuffer) { - MemPlace = RoomBuffer; - MemLeftInBuffer = ROOMBUFFERSIZE; - NextMemPlace = NULL; - } - - void *Ptr = MemPlace; - MemPlace = (char *)MemPlace + Size; - MemLeftInBuffer -= Size; - - if (MemPlace > NextMemPlace) { - NextMemPlace = NULL; - - for (uint16 i = 0; i < MAXMARKERS; i++) { - if (_roomMarkers[i]._roomNum != EMPTYROOM) { - void *Start0 = _roomMarkers[i]._start0; - void *Start1 = _roomMarkers[i]._start1; - void *End0 = _roomMarkers[i]._end0; - void *End1 = _roomMarkers[i]._end1; - - if (((Start0 >= Ptr) && (Start0 < MemPlace)) || - ((End0 >= Ptr) && (End0 < MemPlace)) || - ((Ptr >= Start0) && (Ptr <= End0)) || - - ((Start1 >= Ptr) && (Start1 < MemPlace)) || - ((End1 >= Ptr) && (End1 < MemPlace)) || - ((Ptr >= Start1) && (Ptr <= End1))) { - freeRoom(i); - } else { - if (Start0 >= MemPlace) - if ((NextMemPlace == NULL) || (Start0 < NextMemPlace)) - NextMemPlace = Start0; - - if (Start1 >= MemPlace) - if ((NextMemPlace == NULL) || (Start1 < NextMemPlace)) - NextMemPlace = Start1; - } - } - } - - if (NextMemPlace == NULL) { - NextMemPlace = RoomBuffer; - NextMemPlace = (char *)NextMemPlace + ROOMBUFFERSIZE; - } - } - - return Ptr; -} - -/*****************************************************************************/ -/* Grabs a chunk of memory from the room buffer, and manages it for a */ -/* particular room. */ -/*****************************************************************************/ -void allocRoom(void **Ptr, uint16 size, uint16 roomNum) { - if (1 & size) /* Memory is required to be even aligned */ - size++; - - uint16 roomMarkerId = 0; - - while ((roomMarkerId < MAXMARKERS)) { - if (_roomMarkers[roomMarkerId]._roomNum == roomNum) - break; - else - roomMarkerId++; - } - - if (roomMarkerId >= MAXMARKERS) { - roomMarkerId = CurMarker; - CurMarker++; - - if (CurMarker >= MAXMARKERS) - CurMarker = 0; - - freeRoom(roomMarkerId); - _roomMarkers[roomMarkerId]._roomNum = roomNum; - } - - *Ptr = getCurMem(size); - - if (!_roomMarkers[roomMarkerId]._start0) { - _roomMarkers[roomMarkerId]._start0 = *Ptr; - _roomMarkers[roomMarkerId]._end0 = (void *)(((char *)(*Ptr)) + size - 1); - } else if (*Ptr < _roomMarkers[roomMarkerId]._start0) { - if (_roomMarkers[roomMarkerId]._start1 == nullptr) - _roomMarkers[roomMarkerId]._start1 = *Ptr; - - _roomMarkers[roomMarkerId]._end1 = (void *)(((char *)(*Ptr)) + size - 1); - } else - _roomMarkers[roomMarkerId]._end0 = (void *)(((char *)(*Ptr)) + size - 1); -} - } // End of namespace Lab diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h index 5fbc62cb3a..46c26b67d4 100644 --- a/engines/lab/parsefun.h +++ b/engines/lab/parsefun.h @@ -45,8 +45,6 @@ bool parse(const char *InputFile); bool initRoomBuffer(); void freeRoomBuffer(); -void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum); - /* From ProcessRoom.c */ |