aboutsummaryrefslogtreecommitdiff
path: root/src/entities.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/entities.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/entities.c')
-rw-r--r--src/entities.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/entities.c b/src/entities.c
index df8fb4e..e24c119 100644
--- a/src/entities.c
+++ b/src/entities.c
@@ -8,7 +8,7 @@
#include "effect.h"
-#define MAX_ENTITY 32
+#define MAX_ENTITY 16
static Entity entities[MAX_ENTITY];
static uint8_t last;
@@ -44,31 +44,36 @@ void entities_update()
for (uint8_t i = 0; i < last; i++, e++)
if (e->used)
+ {
+ e->ox = e->x;
+ e->oy = e->y;
e->update(e);
+ }
}
-void entities_erase()
+void entities_draw()
{
- Entity *e = entities + last - 1;
+ Rect dst = { 0, 0, 16, 16 };
+ Entity *e = entities;
- for (uint8_t i = 0; i < last; i++, e--)
- if (e->used)
+ for (uint8_t i = 0; i < last; i++, e++)
+ if (e->erase)
{
- Rect dst = { e->x, e->y + MAP_OFFS_Y, 16, 16 };
- blit(e->bg, &dst);
+ dst.x = e->ox;
+ dst.y = e->oy + MAP_OFFS_Y;
+ blit_copy(&dst);
+ e->erase = 0;
}
-}
-void entities_draw()
-{
- Entity *e = entities;
+ e = entities;
for (uint8_t i = 0; i < last; i++, e++)
if (e->used)
{
- Rect dst = { e->x, e->y + MAP_OFFS_Y, 16, 16 };
- read_buffer(e->bg, &dst);
+ dst.x = e->x;
+ dst.y = e->y + MAP_OFFS_Y;
blitrc(binary_sprites_start, &e->frames[e->dir * 4 + e->frame], &dst);
+ e->erase = 1;
}
}