Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stencil for hiding initially invisible tiles on high resolution #427

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/text_object.h"
"src/tile.cc"
"src/tile.h"
"src/tile_hires_stencil.cc"
"src/tile_hires_stencil.h"
"src/trait_defs.h"
"src/trait.cc"
"src/trait.h"
Expand Down
9 changes: 9 additions & 0 deletions src/map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "svga.h"
#include "text_object.h"
#include "tile.h"
#include "tile_hires_stencil.h"
#include "window_manager.h"
#include "window_manager_private.h"
#include "worldmap.h"
Expand Down Expand Up @@ -390,6 +391,8 @@ int mapSetElevation(int elevation)
gameMouseObjectsShow();
}

tile_hires_stencil_on_center_tile_or_elevation_change();

return 0;
}

Expand Down Expand Up @@ -1043,6 +1046,8 @@ static int mapLoad(File* stream)
// NOTE: Uninline.
mapSetEnteringLocation(-1, -1, -1);

tile_hires_stencil_init();

gameMovieFadeOut();

gMapHeader.version = 20;
Expand Down Expand Up @@ -1520,6 +1525,8 @@ static void isoWindowRefreshRectGame(Rect* rect)
_obj_render_pre_roof(&rectToUpdate, gElevation);
tileRenderRoofsInRect(&rectToUpdate, gElevation);
_obj_render_post_roof(&rectToUpdate, gElevation);

tile_hires_stencil_draw(&rectToUpdate, gIsoWindowBuffer, rectGetWidth(&gIsoWindowRect), rectGetHeight(&gIsoWindowRect));
}

// 0x483F44
Expand All @@ -1541,6 +1548,8 @@ static void isoWindowRefreshRectMapper(Rect* rect)
_obj_render_pre_roof(&rectToUpdate, gElevation);
tileRenderRoofsInRect(&rectToUpdate, gElevation);
_obj_render_post_roof(&rectToUpdate, gElevation);

tile_hires_stencil_draw(&rectToUpdate, gIsoWindowBuffer, rectGetWidth(&gIsoWindowRect), rectGetHeight(&gIsoWindowRect));
}

// NOTE: Inlined.
Expand Down
2 changes: 2 additions & 0 deletions src/sfall_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace fallout {

#define SFALL_CONFIG_FILE_NAME "ddraw.ini"

#define SFALL_CONFIG_MAIN_KEY "Main"
#define SFALL_CONFIG_MISC_KEY "Misc"
#define SFALL_CONFIG_SCRIPTS_KEY "Scripts"

Expand Down Expand Up @@ -75,6 +76,7 @@ namespace fallout {
#define SFALL_CONFIG_VERSION_STRING "VersionString"
#define SFALL_CONFIG_CONFIG_FILE "ConfigFile"
#define SFALL_CONFIG_PATCH_FILE "PatchFile"
#define SFALL_CONFIG_HIRES_MODE "HiResMode"

#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER 1
#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR 3
Expand Down
19 changes: 14 additions & 5 deletions src/tile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "platform_compat.h"
#include "settings.h"
#include "svga.h"
#include "tile_hires_stencil.h"

namespace fallout {

Expand Down Expand Up @@ -69,7 +70,7 @@ static int _tile_make_line(int currentCenterTile, int newCenterTile, int* tiles,
static double const dbl_50E7C7 = -4.0;

// 0x51D950
static bool gTileBorderInitialized = false;
bool gTileBorderInitialized = false;

// 0x51D954
static bool gTileScrollBlockingEnabled = true;
Expand Down Expand Up @@ -196,16 +197,16 @@ static unsigned char _tile_grid_occupied[512];
static unsigned char _tile_mask[512];

// 0x66BBC4
static int gTileBorderMinX = 0;
int gTileBorderMinX = 0;

// 0x66BBC8
static int gTileBorderMinY = 0;
int gTileBorderMinY = 0;

// 0x66BBCC
static int gTileBorderMaxX = 0;
int gTileBorderMaxX = 0;

// 0x66BBD0
static int gTileBorderMaxY = 0;
int gTileBorderMaxY = 0;

// 0x66BBD4
static Rect gTileWindowRect;
Expand Down Expand Up @@ -599,6 +600,8 @@ int tileSetCenter(int tile, int flags)

gCenterTile = tile;

tile_hires_stencil_on_center_tile_or_elevation_change();

if ((flags & TILE_SET_CENTER_REFRESH_WINDOW) != 0) {
// NOTE: Uninline.
tileWindowRefresh();
Expand Down Expand Up @@ -627,6 +630,9 @@ static void tileRefreshMapper(Rect* rect, int elevation)
_obj_render_pre_roof(&rectToUpdate, elevation);
tileRenderRoofsInRect(&rectToUpdate, elevation);
_obj_render_post_roof(&rectToUpdate, elevation);

tile_hires_stencil_draw(&rectToUpdate, gTileWindowBuffer, gTileWindowWidth, gTileWindowHeight);

gTileWindowRefreshProc(&rectToUpdate);
}

Expand All @@ -651,6 +657,9 @@ static void tileRefreshGame(Rect* rect, int elevation)
_obj_render_pre_roof(&rectToUpdate, elevation);
tileRenderRoofsInRect(&rectToUpdate, elevation);
_obj_render_post_roof(&rectToUpdate, elevation);

tile_hires_stencil_draw(&rectToUpdate, gTileWindowBuffer, gTileWindowWidth, gTileWindowHeight);

gTileWindowRefreshProc(&rectToUpdate);
}

Expand Down
6 changes: 6 additions & 0 deletions src/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ extern const int dword_51D984[6];
extern int gHexGridSize;
extern int gCenterTile;

extern bool gTileBorderInitialized;
extern int gTileBorderMinX;
extern int gTileBorderMinY;
extern int gTileBorderMaxX;
extern int gTileBorderMaxY;

int tileInit(TileData** a1, int squareGridWidth, int squareGridHeight, int hexGridWidth, int hexGridHeight, unsigned char* buf, int windowWidth, int windowHeight, int windowPitch, TileWindowRefreshProc* windowRefreshProc);
void _tile_reset_();
void tileReset();
Expand Down
Loading
Loading