From 52ae89df67ad56dbb6302fd9e85ad45279554a4c Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 29 Jan 2020 15:33:51 +0100 Subject: [PATCH] cleanup of EM engine cave size definition names --- src/game_em/convert.c | 16 ++++++++-------- src/game_em/emerald.h | 20 ++++++++++---------- src/game_em/export.h | 10 +++++++++- src/game_em/graphics.c | 8 ++++---- src/game_em/input.c | 24 ++++++++++++------------ src/game_em/logic.c | 18 +++++++++--------- src/game_em/main_em.h | 5 ----- 7 files changed, 52 insertions(+), 49 deletions(-) diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 04f46309..dd220900 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -911,8 +911,8 @@ void convert_em_level(unsigned char *src, int file_version) } /* first fill the complete playfield with the default border element */ - for (y = 0; y < HEIGHT; y++) - for (x = 0; x < WIDTH; x++) + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) native_em_level.cave[x][y] = Zborder; /* then copy the real level contents from level file into the playfield */ @@ -938,16 +938,16 @@ void prepare_em_level(void) /* reset all runtime variables to their initial values */ - for (y = 0; y < HEIGHT; y++) - for (x = 0; x < WIDTH; x++) + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) lev.cave[x][y] = native_em_level.cave[x][y]; - for (y = 0; y < HEIGHT; y++) - for (x = 0; x < WIDTH; x++) + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) lev.next[x][y] = lev.cave[x][y]; - for (y = 0; y < HEIGHT; y++) - for (x = 0; x < WIDTH; x++) + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) lev.draw[x][y] = lev.cave[x][y]; lev.time_initial = lev.time_seconds; diff --git a/src/game_em/emerald.h b/src/game_em/emerald.h index fe90d793..1cf3deff 100644 --- a/src/game_em/emerald.h +++ b/src/game_em/emerald.h @@ -52,8 +52,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define EM_ENGINE_USE_ADDITIONAL_ELEMENTS /* one border for Zborder elements, one border for steelwall, if needed */ -#define EM_MAX_CAVE_WIDTH (MAX_PLAYFIELD_WIDTH + 2 + 2) -#define EM_MAX_CAVE_HEIGHT (MAX_PLAYFIELD_HEIGHT + 2 + 2) +#define CAVE_WIDTH (MAX_PLAYFIELD_WIDTH + 2 + 2) +#define CAVE_HEIGHT (MAX_PLAYFIELD_HEIGHT + 2 + 2) /* ----------------------------------------------------------------------------- @@ -701,15 +701,15 @@ struct LEVEL int exit_x, exit_y; /* kludge for playing player exit sound */ - short cavebuf[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT]; - short nextbuf[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT]; - short drawbuf[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT]; - short boombuf[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT]; + short cavebuf[CAVE_WIDTH][CAVE_HEIGHT]; + short nextbuf[CAVE_WIDTH][CAVE_HEIGHT]; + short drawbuf[CAVE_WIDTH][CAVE_HEIGHT]; + short boombuf[CAVE_WIDTH][CAVE_HEIGHT]; - short *cavecol[EM_MAX_CAVE_WIDTH]; - short *nextcol[EM_MAX_CAVE_WIDTH]; - short *drawcol[EM_MAX_CAVE_WIDTH]; - short *boomcol[EM_MAX_CAVE_WIDTH]; + short *cavecol[CAVE_WIDTH]; + short *nextcol[CAVE_WIDTH]; + short *drawcol[CAVE_WIDTH]; + short *boomcol[CAVE_WIDTH]; short **cave; short **next; diff --git a/src/game_em/export.h b/src/game_em/export.h index 7601a909..9c0ff052 100644 --- a/src/game_em/export.h +++ b/src/game_em/export.h @@ -8,6 +8,14 @@ #include "emerald.h" +// ---------------------------------------------------------------------------- +// constant definitions +// ---------------------------------------------------------------------------- + +#define EM_MAX_CAVE_WIDTH CAVE_WIDTH +#define EM_MAX_CAVE_HEIGHT CAVE_HEIGHT + + // ---------------------------------------------------------------------------- // exported structures // ---------------------------------------------------------------------------- @@ -36,7 +44,7 @@ struct LevelInfo_EM { int file_version; - short cave[EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT]; + short cave[CAVE_WIDTH][CAVE_HEIGHT]; struct LEVEL *lev; struct PLAYER *ply[MAX_PLAYERS]; diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 0f763382..c6c1d542 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -300,8 +300,8 @@ static void animscreen(void) }; if (!game.use_native_emc_graphics_engine) - for (y = 2; y < EM_MAX_CAVE_HEIGHT - 2; y++) - for (x = 2; x < EM_MAX_CAVE_WIDTH - 2; x++) + for (y = 2; y < CAVE_HEIGHT - 2; y++) + for (x = 2; x < CAVE_WIDTH - 2; x++) SetGfxAnimation_EM(&graphic_info_em_object[lev.draw[x][y]][frame], lev.draw[x][y], 7 - frame, x - 2, y - 2); @@ -326,8 +326,8 @@ static void animscreen(void) int yy = y + xy[i][1]; int tile_next; - if (xx < 0 || xx >= EM_MAX_CAVE_WIDTH || - yy < 0 || yy >= EM_MAX_CAVE_HEIGHT) + if (xx < 0 || xx >= CAVE_WIDTH || + yy < 0 || yy >= CAVE_HEIGHT) continue; tile_next = lev.draw[xx][yy]; diff --git a/src/game_em/input.c b/src/game_em/input.c index 9514b1f5..3883bbda 100644 --- a/src/game_em/input.c +++ b/src/game_em/input.c @@ -22,26 +22,26 @@ void game_init_vars(void) RandomEM = 1684108901; - for (y = 0; y < HEIGHT; y++) - for (x = 0; x < WIDTH; x++) + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) lev.cavebuf[x][y] = Zborder; - for (y = 0; y < HEIGHT; y++) - for (x = 0; x < WIDTH; x++) + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) lev.nextbuf[x][y] = Zborder; - for (y = 0; y < HEIGHT; y++) - for (x = 0; x < WIDTH; x++) + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) lev.drawbuf[x][y] = Zborder; - for (y = 0; y < HEIGHT; y++) - for (x = 0; x < WIDTH; x++) + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) lev.boombuf[x][y] = Xblank; - for (x = 0; x < WIDTH; x++) + for (x = 0; x < CAVE_WIDTH; x++) lev.cavecol[x] = lev.cavebuf[x]; - for (x = 0; x < WIDTH; x++) + for (x = 0; x < CAVE_WIDTH; x++) lev.nextcol[x] = lev.nextbuf[x]; - for (x = 0; x < WIDTH; x++) + for (x = 0; x < CAVE_WIDTH; x++) lev.drawcol[x] = lev.drawbuf[x]; - for (x = 0; x < WIDTH; x++) + for (x = 0; x < CAVE_WIDTH; x++) lev.boomcol[x] = lev.boombuf[x]; lev.cave = lev.cavecol; diff --git a/src/game_em/logic.c b/src/game_em/logic.c index bcaf88c8..da397d56 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -1228,7 +1228,7 @@ static void check_player(struct PLAYER *ply) static void set_nearest_player_xy(int x, int y, int *dx, int *dy) { - int distance, distance_shortest = EM_MAX_CAVE_WIDTH + EM_MAX_CAVE_HEIGHT; + int distance, distance_shortest = CAVE_WIDTH + CAVE_HEIGHT; int i; /* default values if no players are alive anymore */ @@ -6273,8 +6273,8 @@ void logic_2(void) seed = RandomEM; score = 0; - for (y = 1; y < HEIGHT - 1; y++) - for (x = 0; x < WIDTH; x++) + for (y = 1; y < CAVE_HEIGHT - 1; y++) + for (x = 0; x < CAVE_WIDTH; x++) handle_tile(x, y); if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive) @@ -6334,8 +6334,8 @@ void logic_3(void) for (count = lev.amoeba_time; count--;) { - x = (random >> 10) % (WIDTH - 2); - y = (random >> 20) % (HEIGHT - 2); + x = (random >> 10) % (CAVE_WIDTH - 2); + y = (random >> 20) % (CAVE_HEIGHT - 2); Lamoeba(x, y); @@ -6346,13 +6346,13 @@ void logic_3(void) /* handle explosions */ - for (y = 1; y < HEIGHT - 1; y++) - for (x = 1; x < WIDTH - 1; x++) + for (y = 1; y < CAVE_HEIGHT - 1; y++) + for (x = 1; x < CAVE_WIDTH - 1; x++) Lexplode(x, y); /* triple buffering */ - for (y = 0; y < HEIGHT; y++) - for (x = 0; x < WIDTH; x++) + for (y = 0; y < CAVE_HEIGHT; y++) + for (x = 0; x < CAVE_WIDTH; x++) next[x][y] = cave[x][y]; } diff --git a/src/game_em/main_em.h b/src/game_em/main_em.h index 171b8668..ac00b423 100644 --- a/src/game_em/main_em.h +++ b/src/game_em/main_em.h @@ -37,11 +37,6 @@ #define FILE_VERSION_EM_ACTUAL FILE_VERSION_EM_V6 -/* level sizes and positions for EM engine */ - -#define WIDTH EM_MAX_CAVE_WIDTH -#define HEIGHT EM_MAX_CAVE_HEIGHT - /* screen sizes and positions for EM engine */ #define TILESIZE 32 -- 2.34.1