diff --git a/src/font.cpp b/src/font.cpp index 003954e..bb6dea8 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -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); +} + } diff --git a/src/font.hpp b/src/font.hpp index ecfca89..1fcbdfe 100644 --- a/src/font.hpp +++ b/src/font.hpp @@ -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); } diff --git a/src/main.cpp b/src/main.cpp index 18387d2..e7c74b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); } diff --git a/src/scene/emulator/scene.cpp b/src/scene/emulator/scene.cpp index c1f9217..36130d3 100644 --- a/src/scene/emulator/scene.cpp +++ b/src/scene/emulator/scene.cpp @@ -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; } }