From 8d8ab8ed86cab6b938ce26f97b02ffe2cf948e4c Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 29 Jan 2020 00:51:33 +0100 Subject: [PATCH] moved cave arrays and pointers for EM engine to level structure --- src/game_em/convert.c | 8 +++--- src/game_em/emerald.h | 15 +++++++++++ src/game_em/export.h | 5 ---- src/game_em/graphics.c | 10 ++++---- src/game_em/input.c | 56 +++++++++++------------------------------- src/game_em/logic.c | 28 ++++++++++----------- src/game_em/main_em.h | 6 ----- 7 files changed, 52 insertions(+), 76 deletions(-) diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 70ca9f80..04f46309 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -940,15 +940,15 @@ void prepare_em_level(void) for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) - Cave[x][y] = native_em_level.cave[x][y]; + lev.cave[x][y] = native_em_level.cave[x][y]; for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) - Next[x][y] = Cave[x][y]; + lev.next[x][y] = lev.cave[x][y]; for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) - Draw[x][y] = Cave[x][y]; + lev.draw[x][y] = lev.cave[x][y]; lev.time_initial = lev.time_seconds; lev.time = lev.time_initial; @@ -1021,7 +1021,7 @@ void prepare_em_level(void) native_em_level.cave[x][y] = Xblank; - Cave[x][y] = Next[x][y] = Draw[x][y] = Xblank; + lev.cave[x][y] = lev.next[x][y] = lev.draw[x][y] = Xblank; } } } diff --git a/src/game_em/emerald.h b/src/game_em/emerald.h index 5e77b8b4..fe90d793 100644 --- a/src/game_em/emerald.h +++ b/src/game_em/emerald.h @@ -700,6 +700,21 @@ struct LEVEL int num_ball_arrays; /* number of ball data arrays used */ 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 *cavecol[EM_MAX_CAVE_WIDTH]; + short *nextcol[EM_MAX_CAVE_WIDTH]; + short *drawcol[EM_MAX_CAVE_WIDTH]; + short *boomcol[EM_MAX_CAVE_WIDTH]; + + short **cave; + short **next; + short **draw; + short **boom; }; struct PLAYER diff --git a/src/game_em/export.h b/src/game_em/export.h index 550110c0..7601a909 100644 --- a/src/game_em/export.h +++ b/src/game_em/export.h @@ -70,14 +70,9 @@ struct EngineSnapshotInfo_EM unsigned int RandomEM; struct LEVEL lev; struct PLAYER ply[MAX_PLAYERS]; - short Array[4][EM_MAX_CAVE_WIDTH][EM_MAX_CAVE_HEIGHT]; int screen_x; int screen_y; int frame; - short **Boom; - short **Cave; - short **Next; - short **Draw; }; diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 1ba8c511..0f763382 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -109,7 +109,7 @@ void BackToFront_EM(void) static struct GraphicInfo_EM *getObjectGraphic(int x, int y) { - int tile = Draw[x][y]; + int tile = lev.draw[x][y]; struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame]; if (!game.use_native_emc_graphics_engine) @@ -302,8 +302,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++) - SetGfxAnimation_EM(&graphic_info_em_object[Draw[x][y]][frame], - Draw[x][y], 7 - frame, x - 2, y - 2); + SetGfxAnimation_EM(&graphic_info_em_object[lev.draw[x][y]][frame], + lev.draw[x][y], 7 - frame, x - 2, y - 2); for (y = top; y < top + MAX_BUF_YSIZE; y++) { @@ -311,7 +311,7 @@ static void animscreen(void) { int sx = x % MAX_BUF_XSIZE; int sy = y % MAX_BUF_YSIZE; - int tile = Draw[x][y]; + int tile = lev.draw[x][y]; struct GraphicInfo_EM *g = &graphic_info_em_object[tile][frame]; int obj = g->unique_identifier; int crm = 0; @@ -330,7 +330,7 @@ static void animscreen(void) yy < 0 || yy >= EM_MAX_CAVE_HEIGHT) continue; - tile_next = Draw[xx][yy]; + tile_next = lev.draw[xx][yy]; if (!graphic_info_em_object[tile_next][frame].has_crumbled_graphics) crm |= (1 << i); diff --git a/src/game_em/input.c b/src/game_em/input.c index 3738b38b..9514b1f5 100644 --- a/src/game_em/input.c +++ b/src/game_em/input.c @@ -11,14 +11,6 @@ unsigned int RandomEM; struct LEVEL lev; struct PLAYER ply[MAX_PLAYERS]; -short **Boom; -short **Cave; -short **Next; -short **Draw; - -static short *Index[4][WIDTH]; -static short Array[4][WIDTH][HEIGHT]; - extern int screen_x; extern int screen_y; @@ -32,30 +24,30 @@ void game_init_vars(void) for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) - Array[0][x][y] = Zborder; + lev.cavebuf[x][y] = Zborder; for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) - Array[1][x][y] = Zborder; + lev.nextbuf[x][y] = Zborder; for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) - Array[2][x][y] = Zborder; + lev.drawbuf[x][y] = Zborder; for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) - Array[3][x][y] = Xblank; + lev.boombuf[x][y] = Xblank; for (x = 0; x < WIDTH; x++) - Index[0][x] = Array[0][x]; + lev.cavecol[x] = lev.cavebuf[x]; for (x = 0; x < WIDTH; x++) - Index[1][x] = Array[1][x]; + lev.nextcol[x] = lev.nextbuf[x]; for (x = 0; x < WIDTH; x++) - Index[2][x] = Array[2][x]; + lev.drawcol[x] = lev.drawbuf[x]; for (x = 0; x < WIDTH; x++) - Index[3][x] = Array[3][x]; + lev.boomcol[x] = lev.boombuf[x]; - Cave = Index[0]; - Next = Index[1]; - Draw = Index[2]; - Boom = Index[3]; + lev.cave = lev.cavecol; + lev.next = lev.nextcol; + lev.draw = lev.drawcol; + lev.boom = lev.boomcol; } void InitGameEngine_EM(void) @@ -168,7 +160,7 @@ void readjoy(byte action, struct PLAYER *ply) void SaveEngineSnapshotValues_EM(void) { - int i, j, k; + int i; engine_snapshot_em.game_em = game_em; engine_snapshot_em.lev = lev; @@ -179,23 +171,13 @@ void SaveEngineSnapshotValues_EM(void) engine_snapshot_em.screen_x = screen_x; engine_snapshot_em.screen_y = screen_y; - engine_snapshot_em.Boom = Boom; - engine_snapshot_em.Cave = Cave; - engine_snapshot_em.Next = Next; - engine_snapshot_em.Draw = Draw; - for (i = 0; i < 4; i++) engine_snapshot_em.ply[i] = ply[i]; - - for (i = 0; i < 4; i++) - for (j = 0; j < HEIGHT; j++) - for (k = 0; k < WIDTH; k++) - engine_snapshot_em.Array[i][k][j] = Array[i][k][j]; } void LoadEngineSnapshotValues_EM(void) { - int i, j, k; + int i; game_em = engine_snapshot_em.game_em; lev = engine_snapshot_em.lev; @@ -206,16 +188,6 @@ void LoadEngineSnapshotValues_EM(void) screen_x = engine_snapshot_em.screen_x; screen_y = engine_snapshot_em.screen_y; - Boom = engine_snapshot_em.Boom; - Cave = engine_snapshot_em.Cave; - Next = engine_snapshot_em.Next; - Draw = engine_snapshot_em.Draw; - for (i = 0; i < 4; i++) ply[i] = engine_snapshot_em.ply[i]; - - for (i = 0; i < 4; i++) - for (j = 0; j < HEIGHT; j++) - for (k = 0; k < WIDTH; k++) - Array[i][k][j] = engine_snapshot_em.Array[i][k][j]; } diff --git a/src/game_em/logic.c b/src/game_em/logic.c index 0fec08c9..bcaf88c8 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -6210,9 +6210,9 @@ void logic_1(void) int start_check_nr; int i; - cave = Cave; - next = Next; - boom = Boom; + cave = lev.cave; + next = lev.next; + boom = lev.boom; game_em.any_player_moving = FALSE; game_em.any_player_snapping = FALSE; @@ -6266,9 +6266,9 @@ void logic_2(void) { int x, y; - cave = Cave; - next = Next; - boom = Boom; + cave = lev.cave; + next = lev.next; + boom = lev.boom; seed = RandomEM; score = 0; @@ -6285,10 +6285,10 @@ void logic_2(void) RandomEM = seed; /* triple buffering */ - void *temp = Cave; - Cave = Next; - Next = Draw; - Draw = temp; + void *temp = lev.cave; + lev.cave = lev.next; + lev.next = lev.draw; + lev.draw = temp; } void logic_3(void) @@ -6298,9 +6298,9 @@ void logic_3(void) int count; unsigned int random; - cave = Cave; - next = Next; - boom = Boom; + cave = lev.cave; + next = lev.next; + boom = lev.boom; /* update variables */ @@ -6354,5 +6354,5 @@ void logic_3(void) for (y = 0; y < HEIGHT; y++) for (x = 0; x < WIDTH; x++) - Next[x][y] = Cave[x][y]; + next[x][y] = cave[x][y]; } diff --git a/src/game_em/main_em.h b/src/game_em/main_em.h index 1376d58b..171b8668 100644 --- a/src/game_em/main_em.h +++ b/src/game_em/main_em.h @@ -98,12 +98,6 @@ extern struct PLAYER ply[MAX_PLAYERS]; extern struct LevelInfo_EM native_em_level; extern struct GraphicInfo_EM graphic_info_em_object[TILE_MAX][8]; extern struct GraphicInfo_EM graphic_info_em_player[MAX_PLAYERS][PLY_MAX][8]; - -extern short **Boom; -extern short **Cave; -extern short **Next; -extern short **Draw; - extern struct GameInfo_EM game_em; extern unsigned char tab_blank[TILE_MAX]; -- 2.34.1