aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/access/access.cpp6
-rw-r--r--engines/access/access.h2
-rw-r--r--engines/access/room.cpp92
-rw-r--r--engines/access/room.h16
-rw-r--r--engines/access/screen.cpp6
-rw-r--r--engines/access/screen.h3
6 files changed, 103 insertions, 22 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp
index 2f505c2ffa..a21a97c0b0 100644
--- a/engines/access/access.cpp
+++ b/engines/access/access.cpp
@@ -247,10 +247,4 @@ void AccessEngine::doEstablish(int v) {
warning("TODO: doEstablish");
}
-void AccessEngine::loadPlayField(int fileNum, int subfile) {
- // TODO
-}
-
-
-
} // End of namespace Access
diff --git a/engines/access/access.h b/engines/access/access.h
index 5fa0aed1c7..26ae88e6fb 100644
--- a/engines/access/access.h
+++ b/engines/access/access.h
@@ -226,8 +226,6 @@ public:
void establish(int v);
void establishCenter(int v);
-
- void loadPlayField(int fileNum, int subfile);
};
} // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index e0acf1c32a..6f449268c6 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -35,7 +35,13 @@ Room::Room(AccessEngine *vm) : Manager(vm) {
_function = 0;
_roomFlag = 0;
_playField = nullptr;
+ _playFieldWidth = _playFieldHeight = 0;
+ _matrixSize = 0;
_tile = nullptr;
+ _vWindowWidth = _vWindowHeight = 0;
+ _vWindowBytesWide = 0;
+ _bufferBytesWide = 0;
+ _vWindowLinesTall = 0;
}
Room::~Room() {
@@ -181,7 +187,7 @@ void Room::loadRoomData(const byte *roomData) {
_vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1;
if (roomInfo._playFieldFile._fileNum != -1) {
- _vm->loadPlayField(roomInfo._playFieldFile._fileNum,
+ loadPlayField(roomInfo._playFieldFile._fileNum,
roomInfo._playFieldFile._subfile);
setupRoom();
@@ -243,23 +249,23 @@ void Room::setupRoom() {
if (_roomFlag != 2)
setIconPalette();
- if (_vm->_screen->_vWindowSize.x == _playFieldSize.x) {
+ if (_vWindowWidth == _playFieldWidth) {
_vm->_screen->_scrollX = 0;
_vm->_screen->_scrollCol = 0;
} else {
_vm->_screen->_scrollX = _vm->_player->_rawPlayer.x -
(_vm->_player->_rawPlayer.x >> 4);
int xp = MAX((_vm->_player->_rawPlayer.x >> 4) -
- (_vm->_screen->_vWindowSize.x / 2), 0);
+ (_vWindowWidth / 2), 0);
_vm->_screen->_scrollCol = xp;
- xp = xp + _vm->_screen->_vWindowSize.x - _playFieldSize.x;
+ xp = xp + _vWindowWidth - _playFieldWidth;
if (xp >= 0) {
_vm->_screen->_scrollCol = xp + 1;
}
}
- if (_vm->_screen->_vWindowSize.y == _playFieldSize.y) {
+ if (_vWindowHeight == _playFieldHeight) {
_vm->_screen->_scrollY = 0;
_vm->_screen->_scrollRow = 0;
}
@@ -267,10 +273,10 @@ void Room::setupRoom() {
_vm->_screen->_scrollY = _vm->_player->_rawPlayer.y -
(_vm->_player->_rawPlayer.y >> 4);
int yp = MAX((_vm->_player->_rawPlayer.y >> 4) -
- (_vm->_screen->_vWindowSize.y / 2), 0);
+ (_vWindowHeight / 2), 0);
_vm->_screen->_scrollRow = yp;
- yp = yp + _vm->_screen->_vWindowSize.y - _playFieldSize.y;
+ yp = yp + _vWindowHeight - _playFieldHeight;
if (yp >= 0) {
_vm->_screen->_scrollRow = yp + 1;
}
@@ -287,7 +293,7 @@ void Room::setWallCodes() {
void Room::buildScreen() {
int scrollCol = _vm->_screen->_scrollCol;
- int cnt = _vm->_screen->_vWindowSize.x + 1;
+ int cnt = _vWindowWidth + 1;
int offset = 0;
for (int idx = 0; idx < cnt, offset += TILE_WIDTH; ++idx) {
@@ -301,15 +307,15 @@ void Room::buildScreen() {
void Room::buildColumn(int playX, int screenX) {
const byte *pSrc = _playField + _vm->_screen->_scrollRow *
- _playFieldSize.x + playX;
+ _playFieldWidth + playX;
byte *pDest = (byte *)_vm->_buffer1.getPixels();
- for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) {
+ for (int y = 0; y <= _vWindowHeight; ++y) {
byte *pTile = _tile + (*pSrc << 8);
for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) {
Common::copy(pTile, pTile + TILE_WIDTH, pDest);
- pDest += _vm->_screen->_vWindowSize.x;
+ pDest += _vWindowWidth;
}
}
}
@@ -318,6 +324,70 @@ void Room::init4Quads() {
error("TODO: init4Quads");
}
+void Room::loadPlayField(int fileNum, int subfile) {
+ byte *playData = _vm->_files->loadFile(fileNum, subfile);
+ Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10);
+
+ // Copy the new palette
+ _vm->_screen->loadRawPalette(&stream);
+
+ // Copy off the tile data
+ _tileSize = playData[2] << 8;
+ _tile = new byte[_tileSize];
+ stream.read(_tile, _tileSize);
+
+ // Copy off the playfield data
+ _matrixSize = playData[0] * playData[1];
+ _playField = new byte[_matrixSize];
+ stream.read(_playField, _matrixSize);
+
+ // Load the plotter data
+ int numWalls = READ_LE_UINT16(playData + 6);
+ int numBlocks = playData[8];
+ _plotter.load(&stream, numWalls, numBlocks);
+
+ _vWindowWidth = playData[3];
+ _vWindowBytesWide = _vWindowWidth << 4;
+ _bufferBytesWide = _vWindowBytesWide + 16;
+ _vWindowHeight = playData[4];
+ _vWindowLinesTall = _vWindowHeight << 4;
+
+ _vm->_screen->setBufferScan();
+ delete[] playData;
+}
+
+/*------------------------------------------------------------------------*/
+
+Plotter::Plotter() {
+ _delta = _blockIn = 0;
+}
+
+void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockCount) {
+ // Load the wall count
+ _walls.resize(wallCount);
+
+ for (int i = 0; i < wallCount; ++i)
+ _walls[i].left = stream->readSint16LE();
+ for (int i = 0; i < wallCount; ++i)
+ _walls[i].top = stream->readSint16LE();
+ for (int i = 0; i < wallCount; ++i)
+ _walls[i].right = stream->readSint16LE();
+ for (int i = 0; i < wallCount; ++i)
+ _walls[i].bottom = stream->readSint16LE();
+
+ // Load the block list
+ _blocks.resize(blockCount);
+
+ for (int i = 0; i < blockCount; ++i)
+ _blocks[i].left = stream->readSint16LE();
+ for (int i = 0; i < blockCount; ++i)
+ _blocks[i].top = stream->readSint16LE();
+ for (int i = 0; i < blockCount; ++i)
+ _blocks[i].right = stream->readSint16LE();
+ for (int i = 0; i < blockCount; ++i)
+ _blocks[i].bottom = stream->readSint16LE();
+}
+
/*------------------------------------------------------------------------*/
RoomInfo::RoomInfo(const byte *data) {
diff --git a/engines/access/room.h b/engines/access/room.h
index 72963371d6..0c19308469 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -36,6 +36,10 @@ public:
Common::Array<Common::Rect> _blocks;
int _blockIn;
int _delta;
+public:
+ Plotter();
+
+ void load(Common::SeekableReadStream *stream, int wallCount, int blockCount);
};
class JetFrame {
@@ -54,6 +58,8 @@ public:
class Room: public Manager {
private:
void roomLoop();
+
+ void loadPlayField(int fileNum, int subfile);
protected:
void loadRoomData(const byte *roomData);
void setupRoom();
@@ -86,8 +92,16 @@ public:
int _function;
int _roomFlag;
byte *_playField;
- Common::Point _playFieldSize;
+ int _matrixSize;
+ int _playFieldWidth;
+ int _playFieldHeight;
byte *_tile;
+ int _tileSize;
+ int _vWindowWidth;
+ int _vWindowHeight;
+ int _vWindowBytesWide;
+ int _bufferBytesWide;
+ int _vWindowLinesTall;
public:
Room(AccessEngine *vm);
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 63fd98b566..b2cb7da8cc 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -73,7 +73,7 @@ void Screen::setInitialPalettte() {
}
void Screen::loadPalette(Common::SeekableReadStream *stream) {
- stream->read(&_rawPalette[0], PALETTE_SIZE);
+ loadRawPalette(stream);
setPalette();
_loadPalFlag = true;
}
@@ -88,6 +88,10 @@ void Screen::setPalette() {
g_system->getPaletteManager()->setPalette(&_rawPalette[0], 0, PALETTE_COUNT);
}
+void Screen::loadRawPalette(Common::SeekableReadStream *stream) {
+ stream->read(&_rawPalette[0], PALETTE_SIZE);
+}
+
void Screen::updatePalette() {
g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT);
updateScreen();
diff --git a/engines/access/screen.h b/engines/access/screen.h
index f32761347b..45db7d0fb1 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -66,7 +66,6 @@ public:
bool _scrollFlag;
int _scrollThreshold;
int _startColor, _numColors;
- Common::Point _vWindowSize;
Common::Point _bufferStart;
int _scrollCol, _scrollRow;
int _windowXAdd, _windowYAdd;
@@ -111,6 +110,8 @@ public:
void setPalette();
+ void loadRawPalette(Common::SeekableReadStream *stream);
+
/**
* Copy a buffer to the screen
*/