aboutsummaryrefslogtreecommitdiff
path: root/src/map.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-08 22:35:16 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-08 22:35:16 +0100
commit8871729a65615df0eab213bbbf942abe75771704 (patch)
tree34a4ab0f412c34383799e14816d1dfe288705085 /src/map.c
parent5ae0b6490f5fd138f4cbf5c084680bb03b2fff05 (diff)
downloadgold-mine-run-8871729a65615df0eab213bbbf942abe75771704.tar.gz
gold-mine-run-8871729a65615df0eab213bbbf942abe75771704.zip
Avoid drawing the whole screen on each frame
This allows supporting 386DX "just about" (there will be flickering).
Diffstat (limited to 'src/map.c')
-rw-r--r--src/map.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/map.c b/src/map.c
index e5e67d1..5599ae9 100644
--- a/src/map.c
+++ b/src/map.c
@@ -74,8 +74,8 @@ void map_init(const uint8_t map[])
}
#endif
- e->x = ent[1] * MAP_TILE_W;
- e->y = ent[2] * MAP_TILE_H;
+ e->ox = e->x = ent[1] * MAP_TILE_W;
+ e->oy = e->y = ent[2] * MAP_TILE_H;
e->dir = ent[3] & 1;
init[*ent - 1](e);
@@ -98,15 +98,8 @@ void map_render()
src.y = (t / MAP_TILESET_COLS) * MAP_TILE_H;
blitrc(binary_tiles_start, &src, &dst);
- }
-
- for (uint8_t y = 0; y < MAP_H; y++)
- for (uint8_t x = 0; x < MAP_W; x++)
- {
- dst.x = x * MAP_TILE_W;
- dst.y = y * MAP_TILE_H + MAP_OFFS_Y;
- uint8_t t = gold[x + y * MAP_W];
+ t = gold[x + y * MAP_W];
/* not gold, skip! */
if (t == 0xff)
@@ -150,7 +143,9 @@ uint8_t map_update_gold(uint16_t x, uint16_t y)
src.x = (t % MAP_TILESET_COLS) * MAP_TILE_W;
src.y = (t / MAP_TILESET_COLS) * MAP_TILE_H;
+ blit_target(TARGET_BUFFER);
blitrc(binary_tiles_start, &src, &dst);
+ blit_target(TARGET_SCREEN);
total_gold--;
return 1;