aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-29 23:12:41 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-29 23:12:41 +0100
commitb176d3779cbc3d0d02d6651b082cd5011522f7be (patch)
treef22495a8d8b1d5dfc5f5f0f87b23b947b5027ce0 /src
parent3f7b9d71c75360207dd05b8cb67131b08f2c18ca (diff)
downloadgold-mine-run-b176d3779cbc3d0d02d6651b082cd5011522f7be.tar.gz
gold-mine-run-b176d3779cbc3d0d02d6651b082cd5011522f7be.zip
Add attract screen
Diffstat (limited to 'src')
-rw-r--r--src/menu.c102
1 files changed, 96 insertions, 6 deletions
diff --git a/src/menu.c b/src/menu.c
index 24c24c7..ac5bcfc 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -7,15 +7,20 @@
#include "data.h"
#include "game.h"
-uint8_t run_menu()
+#define CAST_LEN 6
+
+static void render_hiscore()
{
char b[10];
- blit_erase(0);
-
sprintf(b, "HI %06li", get_hiscore());
put_text(124, 10, b, 5);
+ put_text(96, 180, "_2023 USEBOX.NET", 1);
+}
+
+static void render_menu()
+{
Rect dst = { 80, 45, 160, 38 };
blit(binary_title_start, &dst);
@@ -23,11 +28,54 @@ uint8_t run_menu()
put_text(64, 140, "CODE, GRAPHICS AND SOUND", 2);
put_text(96, 150, "JUAN J. MARTINEZ", 3);
+}
- put_text(96, 180, "_2023 USEBOX.NET", 1);
+/* names of the cast */
+static const char *names[CAST_LEN] = {
+ "THE MINER",
+ "SNAKEY",
+ "BATTY",
+ "OLD MINER",
+ "MR BONES",
+ "TIME MONSTER",
+};
+
+/* sprites for the cast */
+static const Rect sprites[CAST_LEN] = {
+ { 0, 0, 144, 144 },
+ { 0, 32, 144, 144 },
+ { 64, 32, 144, 144 },
+ { 0, 80, 144, 144 },
+ { 80, 48, 144, 144 },
+ { 80, 48, 144, 144 },
+};
+
+static void render_cast()
+{
+ put_text(128, 32, "THE CAST", 1);
+
+ Rect dst = { 104, 50, 16, 16 };
+
+ /* show the cast line by line */
+ for (uint8_t i = 0; i < CAST_LEN; i++)
+ {
+ blitrc(binary_sprites_start, &sprites[i], &dst);
+ put_text(dst.x + 16 + 8, dst.y + 6, names[i], i + 2);
- wait_vsync();
- blit_update();
+ wait_vsync();
+ blit_update();
+
+ wait_frames(32);
+
+ dst.y += 20;
+ }
+}
+
+uint8_t run_menu()
+{
+ uint16_t count = 0;
+ uint8_t cast = 0;
+ uint8_t wait;
while (1)
{
@@ -36,5 +84,47 @@ uint8_t run_menu()
if (keys[KEY_SPACE])
return 1;
+
+ /* change of screen, requires drawing */
+ if (count == 0)
+ {
+ blit_erase(0);
+
+ render_hiscore();
+ if (cast)
+ render_cast();
+ else
+ {
+ wait = 0;
+ render_menu();
+ }
+
+ wait_vsync();
+ blit_update();
+ }
+
+ /* if is not cast, we do the "blink" effect */
+ if (!cast)
+ {
+ wait++;
+ if (wait == 64 || wait == 80)
+ {
+ if (wait == 80)
+ wait = 0;
+
+ put_text(84, 110, "PRESS SPACE TO PLAY", wait ? 0 : 1);
+ wait_vsync();
+ blit_update();
+ }
+ }
+
+ /* frames before changing screen */
+ if (count++ == 324)
+ {
+ cast ^= 1;
+ count = 0;
+ }
+
+ wait_vsync();
}
}