aboutsummaryrefslogtreecommitdiff
path: root/src/game.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/game.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/game.c')
-rw-r--r--src/game.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/src/game.c b/src/game.c
index ba6ee85..67f7739 100644
--- a/src/game.c
+++ b/src/game.c
@@ -91,7 +91,7 @@ static void hud_render()
sprintf(b, "%02d", time);
put_text(172, 4, b, time > 10 || stageclear ? 1 : 15);
if (!gameover && !stageclear && time <= 10)
- sound_queue_efx(EFX_TIME);
+ sound_play_efx(EFX_TIME);
}
if (hud & HUD_STAGE)
@@ -105,6 +105,8 @@ static void hud_render()
static void run_gameover()
{
+ wait_vsync();
+
blit_erase(0);
/* restore the HUD after erasing the screen */
@@ -113,19 +115,14 @@ static void run_gameover()
put_text(124, 90, "GAME OVER", 1);
- wait_vsync();
- blit_update();
-
/* wait some time */
wait_frames(255);
}
static void run_stageclear()
{
- put_text(116, 100, "STAGE CLEAR", 1);
-
wait_vsync();
- blit_update();
+ put_text(116, 100, "STAGE CLEAR", 1);
/* wait some time */
wait_frames(96);
@@ -135,23 +132,24 @@ static void run_stageclear()
add_score(25);
time--;
hud |= HUD_TIME;
- sound_queue_efx(EFX_GOLD);
- hud_render();
wait_frames(4);
- blit_update();
- sound_play_queue();
+
+ wait_vsync();
+ hud_render();
+ sound_play_efx(EFX_GOLD);
}
/* wait some time */
wait_frames(64);
+ wait_vsync();
blit_erase(0);
+
/* restore the HUD after erasing the screen */
hud = HUD_ALL;
- hud_render();
wait_vsync();
- blit_update();
+ hud_render();
wait_frames(32);
}
@@ -173,25 +171,30 @@ next_stage:
tmonster = NULL;
+ blit_target(TARGET_BUFFER);
blit_erase(0);
map_init(binary_stage_start);
- /* render the scene with the READY? text */
map_render();
- entities_draw();
- player_draw();
hud_render();
- put_text(136, 100, "READY?", 1);
wait_vsync();
- blit_update();
+ blit_copy_all();
+
+ blit_target(TARGET_SCREEN);
+ put_text(136, 100, "READY?", 1);
+
+ entities_draw();
+ player_draw();
/* wait some time */
wait_frames(96);
/* erase the READY? text */
- map_render();
+ wait_vsync();
+ blit_copy_all();
+
entities_draw();
player_draw();
@@ -226,10 +229,6 @@ next_stage:
if (pause)
continue;
- /* erase first the last we draw */
- player_erase();
- entities_erase();
-
if (map_is_complete())
{
if (!stageclear)
@@ -237,7 +236,7 @@ next_stage:
timer_stop();
tmonster = NULL;
entities_warp_out_all();
- sound_queue_efx(EFX_WARP);
+ sound_play_efx(EFX_WARP);
stageclear = STAGECLEAR_DELAY;
}
@@ -271,13 +270,12 @@ next_stage:
entities_update();
+ wait_vsync();
+
+ player_erase();
entities_draw();
player_draw();
- wait_vsync();
- blit_update();
- sound_play_queue();
-
if (gameover)
{
gameover--;