@@ -1723,6 +1723,14 @@ void Game_Map::SetPositionX(int x, bool reset_panorama) {
17231723 const int map_width = GetTilesX () * SCREEN_TILE_SIZE;
17241724 if (LoopHorizontal ()) {
17251725 x = Utils::PositiveModulo (x, map_width);
1726+
1727+ // If the map is too small to fit in the screen, add an offset corresponding to the black border's size
1728+ if (Player::game_config.fake_resolution .Get ()) {
1729+ int map_width_in_pixels = Game_Map::GetTilesX () * TILE_SIZE;
1730+ if (map_width_in_pixels < Player::screen_width) {
1731+ x += ((Player::screen_width - map_width_in_pixels) / 2 / TILE_SIZE) * SCREEN_TILE_SIZE;
1732+ }
1733+ }
17261734 } else {
17271735 // Do not use std::clamp here. When the map is smaller than the screen the
17281736 // upper bound is smaller than the lower bound making the function fail.
@@ -1747,6 +1755,14 @@ void Game_Map::SetPositionY(int y, bool reset_panorama) {
17471755 const int map_height = GetTilesY () * SCREEN_TILE_SIZE;
17481756 if (LoopVertical ()) {
17491757 y = Utils::PositiveModulo (y, map_height);
1758+
1759+ // If the map is too small to fit in the screen, add an offset corresponding to the black border's size
1760+ if (Player::game_config.fake_resolution .Get ()) {
1761+ int map_height_in_pixels = Game_Map::GetTilesY () * TILE_SIZE;
1762+ if (map_height_in_pixels < Player::screen_height) {
1763+ y += ((Player::screen_height - map_height_in_pixels) / 2 / TILE_SIZE) * SCREEN_TILE_SIZE;
1764+ }
1765+ }
17501766 } else {
17511767 // Do not use std::clamp here. When the map is smaller than the screen the
17521768 // upper bound is smaller than the lower bound making the function fail.
@@ -2035,9 +2051,6 @@ void Game_Map::Caching::MapEventCache::RemoveEvent(const lcf::rpg::Event& ev) {
20352051namespace {
20362052 int parallax_width;
20372053 int parallax_height;
2038-
2039- bool parallax_fake_x;
2040- bool parallax_fake_y;
20412054}
20422055
20432056/* Helper function to get the current parallax parameters. If the default
@@ -2141,12 +2154,14 @@ void Game_Map::Parallax::ResetPositionX() {
21412154 return ;
21422155 }
21432156
2144- parallax_fake_x = false ;
2145-
21462157 if (!params.scroll_horz && !LoopHorizontal ()) {
2158+ // What is the width of the panorama to display on screen?
21472159 int pan_screen_width = Player::screen_width;
2148- if (Player::game_config.fake_resolution .Get ()) {
2149- pan_screen_width = SCREEN_TARGET_WIDTH;
2160+ if (Player::game_config.fake_resolution .Get ()) {
2161+ int map_width = Game_Map::GetTilesX () * TILE_SIZE;
2162+ if (map_width < pan_screen_width) {
2163+ pan_screen_width = map_width;
2164+ }
21502165 }
21512166
21522167 int tiles_per_screen = pan_screen_width / TILE_SIZE;
@@ -2165,10 +2180,7 @@ void Game_Map::Parallax::ResetPositionX() {
21652180 }
21662181 } else {
21672182 panorama.pan_x = 0 ;
2168- parallax_fake_x = true ;
21692183 }
2170- } else {
2171- parallax_fake_x = true ;
21722184 }
21732185}
21742186
@@ -2179,12 +2191,14 @@ void Game_Map::Parallax::ResetPositionY() {
21792191 return ;
21802192 }
21812193
2182- parallax_fake_y = false ;
2183-
21842194 if (!params.scroll_vert && !Game_Map::LoopVertical ()) {
2195+ // What is the height of the panorama to display on screen?
21852196 int pan_screen_height = Player::screen_height;
21862197 if (Player::game_config.fake_resolution .Get ()) {
2187- pan_screen_height = SCREEN_TARGET_HEIGHT;
2198+ int map_height = Game_Map::GetTilesY () * TILE_SIZE;
2199+ if (map_height < pan_screen_height) {
2200+ pan_screen_height = map_height;
2201+ }
21882202 }
21892203
21902204 int tiles_per_screen = pan_screen_height / TILE_SIZE;
@@ -2198,10 +2212,7 @@ void Game_Map::Parallax::ResetPositionY() {
21982212 SetPositionY (pv);
21992213 } else {
22002214 panorama.pan_y = 0 ;
2201- parallax_fake_y = true ;
22022215 }
2203- } else {
2204- parallax_fake_y = true ;
22052216 }
22062217}
22072218
@@ -2296,11 +2307,3 @@ void Game_Map::Parallax::ClearChangedBG() {
22962307 Params params {}; // default Param indicates no override
22972308 ChangeBG (params);
22982309}
2299-
2300- bool Game_Map::Parallax::FakeXPosition () {
2301- return parallax_fake_x;
2302- }
2303-
2304- bool Game_Map::Parallax::FakeYPosition () {
2305- return parallax_fake_y;
2306- }
0 commit comments