Cleanup tile.h

See #42
This commit is contained in:
Alexander Batalov 2022-06-19 08:02:47 +03:00
parent a9ca75a1a3
commit 7658a41f64
2 changed files with 83 additions and 129 deletions

View File

@ -18,29 +18,68 @@
#define _USE_MATH_DEFINES
#include <math.h>
typedef struct STRUCT_51D99C {
int field_0;
int field_4;
} STRUCT_51D99C;
typedef struct STRUCT_51DA04 {
int field_0;
int field_4;
} STRUCT_51DA04;
typedef struct STRUCT_51DA6C {
int field_0;
int field_4;
int field_8;
int field_C; // something with light level?
} STRUCT_51DA6C;
typedef struct STRUCT_51DB0C {
int field_0;
int field_4;
int field_8;
} STRUCT_51DB0C;
typedef struct STRUCT_51DB48 {
int field_0;
int field_4;
int field_8;
} STRUCT_51DB48;
void tileSetBorder(int windowWidth, int windowHeight, int hexGridWidth, int hexGridHeight);
void tileRefreshMapper(Rect* rect, int elevation);
void tileRefreshGame(Rect* rect, int elevation);
void _roof_fill_on(int x, int y, int elevation);
void sub_4B23DC(int x, int y, int elevation);
void tileRenderRoof(int fid, int x, int y, Rect* rect, int light);
void _draw_grid(int tile, int elevation, Rect* rect);
void tileRenderFloor(int fid, int x, int y, Rect* rect);
int _tile_make_line(int currentCenterTile, int newCenterTile, int* tiles, int tilesCapacity);
// 0x50E7C7
double const dbl_50E7C7 = -4.0;
static double const dbl_50E7C7 = -4.0;
// 0x51D950
bool gTileBorderInitialized = false;
static bool gTileBorderInitialized = false;
// 0x51D954
bool gTileScrollBlockingEnabled = true;
static bool gTileScrollBlockingEnabled = true;
// 0x51D958
bool gTileScrollLimitingEnabled = true;
static bool gTileScrollLimitingEnabled = true;
// 0x51D95C
bool gTileRoofIsVisible = true;
static bool gTileRoofIsVisible = true;
// 0x51D960
bool gTileGridIsVisible = false;
static bool gTileGridIsVisible = false;
// 0x51D964
TileWindowRefreshElevationProc* gTileWindowRefreshElevationProc = tileRefreshGame;
static TileWindowRefreshElevationProc* gTileWindowRefreshElevationProc = tileRefreshGame;
// 0x51D968
bool gTileEnabled = true;
static bool gTileEnabled = true;
// 0x51D96C
const int _off_tile[6] = {
@ -63,7 +102,7 @@ const int dword_51D984[6] = {
};
// 0x51D99C
STRUCT_51D99C _rightside_up_table[13] = {
static STRUCT_51D99C _rightside_up_table[13] = {
{ -1, 2 },
{ 78, 2 },
{ 76, 6 },
@ -80,7 +119,7 @@ STRUCT_51D99C _rightside_up_table[13] = {
};
// 0x51DA04
STRUCT_51DA04 _upside_down_table[13] = {
static STRUCT_51DA04 _upside_down_table[13] = {
{ 0, 32 },
{ 48, 32 },
{ 49, 30 },
@ -97,7 +136,7 @@ STRUCT_51DA04 _upside_down_table[13] = {
};
// 0x51DA6C
STRUCT_51DA6C _verticies[10] = {
static STRUCT_51DA6C _verticies[10] = {
{ 16, -1, -201, 0 },
{ 48, -2, -2, 0 },
{ 960, 0, 0, 0 },
@ -111,7 +150,7 @@ STRUCT_51DA6C _verticies[10] = {
};
// 0x51DB0C
STRUCT_51DB0C _rightside_up_triangles[5] = {
static STRUCT_51DB0C _rightside_up_triangles[5] = {
{ 2, 3, 0 },
{ 3, 4, 1 },
{ 5, 6, 3 },
@ -120,7 +159,7 @@ STRUCT_51DB0C _rightside_up_triangles[5] = {
};
// 0x51DB48
STRUCT_51DB48 _upside_down_triangles[5] = {
static STRUCT_51DB48 _upside_down_triangles[5] = {
{ 0, 3, 1 },
{ 2, 5, 3 },
{ 3, 6, 4 },
@ -129,95 +168,95 @@ STRUCT_51DB48 _upside_down_triangles[5] = {
};
// 0x668224
int _intensity_map[3280];
static int _intensity_map[3280];
// 0x66B564
int _dir_tile2[2][6];
static int _dir_tile2[2][6];
// Deltas to perform tile calculations in given direction.
//
// 0x66B594
int _dir_tile[2][6];
static int _dir_tile[2][6];
// 0x66B5C4
unsigned char _tile_grid_blocked[512];
static unsigned char _tile_grid_blocked[512];
// 0x66B7C4
unsigned char _tile_grid_occupied[512];
static unsigned char _tile_grid_occupied[512];
// 0x66B9C4
unsigned char _tile_mask[512];
static unsigned char _tile_mask[512];
// 0x66BBC4
int gTileBorderMinX = 0;
static int gTileBorderMinX = 0;
// 0x66BBC8
int gTileBorderMinY = 0;
static int gTileBorderMinY = 0;
// 0x66BBCC
int gTileBorderMaxX = 0;
static int gTileBorderMaxX = 0;
// 0x66BBD0
int gTileBorderMaxY = 0;
static int gTileBorderMaxY = 0;
// 0x66BBD4
Rect gTileWindowRect;
static Rect gTileWindowRect;
// 0x66BBE4
unsigned char _tile_grid[32 * 16];
static unsigned char _tile_grid[32 * 16];
// 0x66BDE4
int _square_rect;
static int _square_rect;
// 0x66BDE8
int _square_x;
static int _square_x;
// 0x66BDEC
int _square_offx;
static int _square_offx;
// 0x66BDF0
int _square_offy;
static int _square_offy;
// 0x66BDF4
TileWindowRefreshProc* gTileWindowRefreshProc;
static TileWindowRefreshProc* gTileWindowRefreshProc;
// 0x66BDF8
int _tile_offy;
static int _tile_offy;
// 0x66BDFC
int _tile_offx;
static int _tile_offx;
// 0x66BE00
int gSquareGridSize;
static int gSquareGridSize;
// Number of tiles horizontally.
//
// Currently this value is always 200.
//
// 0x66BE04
int gHexGridWidth;
static int gHexGridWidth;
// 0x66BE08
TileData** gTileSquares;
static TileData** gTileSquares;
// 0x66BE0C
unsigned char* gTileWindowBuffer;
static unsigned char* gTileWindowBuffer;
// Number of tiles vertically.
//
// Currently this value is always 200.
//
// 0x66BE10
int gHexGridHeight;
static int gHexGridHeight;
// 0x66BE14
int gTileWindowHeight;
static int gTileWindowHeight;
// 0x66BE18
int _tile_x;
static int _tile_x;
// 0x66BE1C
int _tile_y;
static int _tile_y;
// The number of tiles in the hex grid.
//
@ -225,16 +264,16 @@ int _tile_y;
int gHexGridSize;
// 0x66BE24
int gSquareGridHeight;
static int gSquareGridHeight;
// 0x66BE28
int gTileWindowPitch;
static int gTileWindowPitch;
// 0x66BE2C
int gSquareGridWidth;
static int gSquareGridWidth;
// 0x66BE30
int gTileWindowWidth;
static int gTileWindowWidth;
// 0x66BE34
int gCenterTile;

View File

@ -3,96 +3,19 @@
#include "geometry.h"
#include "map.h"
#include "obj_types.h"
#define TILE_SET_CENTER_FLAG_0x01 0x01
#define TILE_SET_CENTER_FLAG_0x02 0x02
typedef struct STRUCT_51D99C {
int field_0;
int field_4;
} STRUCT_51D99C;
typedef struct STRUCT_51DA04 {
int field_0;
int field_4;
} STRUCT_51DA04;
typedef struct STRUCT_51DA6C {
int field_0;
int field_4;
int field_8;
int field_C; // something with light level?
} STRUCT_51DA6C;
typedef struct STRUCT_51DB0C {
int field_0;
int field_4;
int field_8;
} STRUCT_51DB0C;
typedef struct STRUCT_51DB48 {
int field_0;
int field_4;
int field_8;
} STRUCT_51DB48;
typedef void(TileWindowRefreshProc)(Rect* rect);
typedef void(TileWindowRefreshElevationProc)(Rect* rect, int elevation);
extern double const dbl_50E7C7;
extern bool gTileBorderInitialized;
extern bool gTileScrollBlockingEnabled;
extern bool gTileScrollLimitingEnabled;
extern bool gTileRoofIsVisible;
extern bool gTileGridIsVisible;
extern TileWindowRefreshElevationProc* gTileWindowRefreshElevationProc;
extern bool gTileEnabled;
extern const int _off_tile[6];
extern const int dword_51D984[6];
extern STRUCT_51D99C _rightside_up_table[13];
extern STRUCT_51DA04 _upside_down_table[13];
extern STRUCT_51DA6C _verticies[10];
extern STRUCT_51DB0C _rightside_up_triangles[5];
extern STRUCT_51DB48 _upside_down_triangles[5];
extern int _intensity_map[3280];
extern int _dir_tile2[2][6];
extern int _dir_tile[2][6];
extern unsigned char _tile_grid_blocked[512];
extern unsigned char _tile_grid_occupied[512];
extern unsigned char _tile_mask[512];
extern int gTileBorderMinX;
extern int gTileBorderMinY;
extern int gTileBorderMaxX;
extern int gTileBorderMaxY;
extern Rect gTileWindowRect;
extern unsigned char _tile_grid[512];
extern int _square_rect;
extern int _square_x;
extern int _square_offx;
extern int _square_offy;
extern TileWindowRefreshProc* gTileWindowRefreshProc;
extern int _tile_offy;
extern int _tile_offx;
extern int gSquareGridSize;
extern int gHexGridWidth;
extern TileData** gTileSquares;
extern unsigned char* gTileWindowBuffer;
extern int gHexGridHeight;
extern int gTileWindowHeight;
extern int _tile_x;
extern int _tile_y;
extern int gHexGridSize;
extern int gSquareGridHeight;
extern int gTileWindowPitch;
extern int gSquareGridWidth;
extern int gTileWindowWidth;
extern int gCenterTile;
int tileInit(TileData** a1, int squareGridWidth, int squareGridHeight, int hexGridWidth, int hexGridHeight, unsigned char* buf, int windowWidth, int windowHeight, int windowPitch, TileWindowRefreshProc* windowRefreshProc);
void tileSetBorder(int windowWidth, int windowHeight, int hexGridWidth, int hexGridHeight);
void _tile_reset_();
void tileReset();
void tileExit();
@ -101,8 +24,6 @@ void tileEnable();
void tileWindowRefreshRect(Rect* rect, int elevation);
void tileWindowRefresh();
int tileSetCenter(int tile, int flags);
void tileRefreshMapper(Rect* rect, int elevation);
void tileRefreshGame(Rect* rect, int elevation);
int tileRoofIsVisible();
int tileToScreenXY(int tile, int* x, int* y, int elevation);
int tileFromScreenXY(int x, int y, int elevation);
@ -125,16 +46,10 @@ int squareTileFromScreenXY(int screenX, int screenY, int elevation);
void squareTileScreenToCoord(int screenX, int screenY, int elevation, int* coordX, int* coordY);
void squareTileScreenToCoordRoof(int screenX, int screenY, int elevation, int* coordX, int* coordY);
void tileRenderRoofsInRect(Rect* rect, int elevation);
void _roof_fill_on(int x, int y, int elevation);
void _tile_fill_roof(int x, int y, int elevation, int a4);
void sub_4B23DC(int x, int y, int elevation);
void tileRenderRoof(int fid, int x, int y, Rect* rect, int light);
void tileRenderFloorsInRect(Rect* rect, int elevation);
bool _square_roof_intersect(int x, int y, int elevation);
void _grid_render(Rect* rect, int elevation);
void _draw_grid(int tile, int elevation, Rect* rect);
void tileRenderFloor(int fid, int x, int y, Rect* rect);
int _tile_make_line(int currentCenterTile, int newCenterTile, int* tiles, int tilesCapacity);
int _tile_scroll_to(int tile, int flags);
static bool tileIsValid(int tile)