diff options
author | Eugene Sandulenko | 2019-07-20 00:02:01 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:25 +0200 |
commit | edc68ef7b1f6ba89092b2f4c41f3594ae15bd4eb (patch) | |
tree | 27c802c9a6d4d793c5c75a69526117680ac352e7 | |
parent | f9422e43478aecb9430466a7da4651d0e3fc7a58 (diff) | |
download | scummvm-rg350-edc68ef7b1f6ba89092b2f4c41f3594ae15bd4eb.tar.gz scummvm-rg350-edc68ef7b1f6ba89092b2f4c41f3594ae15bd4eb.tar.bz2 scummvm-rg350-edc68ef7b1f6ba89092b2f4c41f3594ae15bd4eb.zip |
HDB: Added more constants instead of magic numbers
-rw-r--r-- | engines/hdb/gfx.h | 2 | ||||
-rw-r--r-- | engines/hdb/map.cpp | 26 | ||||
-rw-r--r-- | engines/hdb/map.h | 2 |
3 files changed, 17 insertions, 13 deletions
diff --git a/engines/hdb/gfx.h b/engines/hdb/gfx.h index 73fb92a8ae..26b08108c7 100644 --- a/engines/hdb/gfx.h +++ b/engines/hdb/gfx.h @@ -32,6 +32,8 @@ namespace HDB { enum { kScreenWidth = 640, kScreenHeight = 480, + kScreenDrawWidth = (kScreenWidth - 160), // visible pixels wide + kScreenDrawHeight = 480, kTileWidth = 32, kTileHeight = 32, kMaxSkies = 10, diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp index ca8e2a2205..daec9a8a78 100644 --- a/engines/hdb/map.cpp +++ b/engines/hdb/map.cpp @@ -1114,39 +1114,39 @@ void Map::centerMapXY(int x, int y) { int minx, miny, maxx, maxy; // Scan from centerX to right edge - maxx = (_width - (16/2)) * kTileWidth; - for (int i = checkx + 1; i <= checkx + (16 / 2); i++) { + maxx = (_width - (kScreenTileWidth / 2)) * kTileWidth; + for (int i = checkx + 1; i <= checkx + (kScreenTileWidth / 2); i++) { if (!getMapBGTileIndex(i, checky)) { - maxx = (i - (16 / 2)) * kTileWidth; + maxx = (i - (kScreenTileWidth / 2)) * kTileWidth; break; } } // Scan from centerX to left edge minx = 0; - for (int i = checkx - 1; i >= checkx - (16 / 2); i--) { + for (int i = checkx - 1; i >= checkx - (kScreenTileWidth / 2); i--) { if (!getMapBGTileIndex(i, checky)) { // +1 because we don't want to see one whole tile - minx = (1 + i + (16 / 2)) * kTileWidth; + minx = (1 + i + (kScreenTileWidth / 2)) * kTileWidth; break; } } // Scan from centerY to bottom edge - maxy = (_height - (16/2)) * kTileHeight; - for (int i = checky + 1; i <= checky + (16 / 2); i++) { + maxy = (_height - (kScreenTileHeight / 2)) * kTileHeight; + for (int i = checky + 1; i <= checky + (kScreenTileHeight / 2); i++) { if (!getMapBGTileIndex(checkx, i)) { - maxy = (i - (16 / 2)) * kTileHeight; + maxy = (i - (kScreenTileHeight / 2)) * kTileHeight; break; } } // Scan from centerY to top edge miny = 0; - for (int i = checky - 1; i >= checkx - (16 / 2); i--) { + for (int i = checky - 1; i >= checkx - (kScreenTileHeight / 2); i--) { if (!getMapBGTileIndex(checkx, i)) { - // +! because we don't want to see one whole tile - miny = (1 + i + (16 / 2)) * kTileHeight; + // +1 because we don't want to see one whole tile + miny = (1 + i + (kScreenTileHeight / 2)) * kTileHeight; break; } } @@ -1163,8 +1163,8 @@ void Map::centerMapXY(int x, int y) { y = maxy; } - x -= (480 / 2); - y -= (480 / 2); + x -= (kScreenDrawWidth / 2); + y -= (kScreenDrawHeight / 2); setMapXY(x, y); } diff --git a/engines/hdb/map.h b/engines/hdb/map.h index 1822c86234..91cecf17bd 100644 --- a/engines/hdb/map.h +++ b/engines/hdb/map.h @@ -30,6 +30,8 @@ namespace HDB { enum { kScreenXTiles = 17, kScreenYTiles = 16, + kScreenTileWidth = 16, + kScreenTileHeight = 16, kMaxGratings = 250, kMaxForegrounds = 250 }; |