emulator: add 30 second countdown

This commit is contained in:
Zack Buhman 2025-07-05 18:45:05 -05:00
parent ebfc839acb
commit da897d4dce
4 changed files with 43 additions and 2 deletions

View File

@ -5,6 +5,7 @@
#include "font.hpp"
#include "math/float_types.hpp"
#include "printf/unparse.h"
namespace font {
@ -109,4 +110,19 @@ void draw_string(ta_parameter_writer& writer,
}
}
void draw_integer(ta_parameter_writer& writer,
const font& face,
int n,
int length, int fill,
float x, float y, float z,
int base_color)
{
char buf[16];
int len = unparse_base10(buf, n, length, fill);
buf[len] = 0;
draw_string(writer, face, buf, x, y, z, base_color);
}
}

View File

@ -37,4 +37,11 @@ namespace font {
const char * s,
float x, float y, float z,
int base_color);
void draw_integer(ta_parameter_writer& writer,
const font& face,
int n,
int length, int fill,
float x, float y, float z,
int base_color);
}

View File

@ -127,8 +127,9 @@ void main()
if (emulator) {
scene::emulator::current_message_id = scene::emulator::counterfeit;
//scene::scene_init(scene::id::emulator);
scene::scene_init(scene::id::tracker);
scene::scene_init(scene::id::emulator);
//scene::scene_init(scene::id::tracker);
//scene::scene_init(scene::id::logo);
} else {
scene::scene_init(scene::id::logo);
}

View File

@ -95,6 +95,8 @@ namespace scene::emulator {
int current_message_id = 0;
static int tick = 0;
void draw_title(ta_parameter_writer& writer, int color)
{
const font::font& face = font::fonts[font::font::ter_u32n];
@ -124,6 +126,11 @@ namespace scene::emulator {
draw_string(writer, face, s, x, y, 0.1, base_color);
y += face.height;
}
float tick_div = framebuffer.px_height == 480 ? (1.f / 60.f) : (1.f / 120.f);
int n = 30.000 - (tick * tick_div);
y += face.height;
draw_integer(writer, face, n, 0, 0, x, y, 0.1, base_color);
}
void transfer(ta_multiwriter& multi)
@ -150,6 +157,8 @@ namespace scene::emulator {
{0, 0, 0.1},
{0, 0, 0.1},
0x0);
tick += 1;
}
void init()
@ -165,6 +174,14 @@ namespace scene::emulator {
int done()
{
float tick_mul = framebuffer.px_height == 480 ? 60 : 120;
if (tick >= (30.000 * tick_mul)) {
int scene_id = ::scene::id::logo;
printf("scene transition to logo %d\n", scene_id);
return scene_id;
}
return -1;
}
}