From c4892d51abc7560fdee267e93d643d2ddc7652c9 Mon Sep 17 00:00:00 2001 From: jaby Date: Tue, 5 Dec 2023 21:04:45 -0500 Subject: [PATCH] Support %i --- examples/PoolBox/application/src/font_writer.cpp | 2 +- include/stdarg.h | 1 + support/include/FontWriter/font_writer.hpp | 2 +- support/src/FontWriter/src/font_writer.cpp | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/PoolBox/application/src/font_writer.cpp b/examples/PoolBox/application/src/font_writer.cpp index 1ed59811..71c41580 100644 --- a/examples/PoolBox/application/src/font_writer.cpp +++ b/examples/PoolBox/application/src/font_writer.cpp @@ -23,7 +23,7 @@ void font_writer_setup() { void font_writer_update() { auto state = JabyEngine::State::create(JabyEngine::Make::PositionI16(8, 8), wiggle_count); new_font_writer.write(state, "012345 ABCDEFGHIJKL\nabcedfghijkl\n", JabyEngine::GPU::Color24::Blue(), &wiggle); - new_font_writer.write(state, "Mi%iau:", JabyEngine::GPU::Color24::Yellow(), &wiggle, 12345); + new_font_writer.write(state, "Wiggle Count: %i", JabyEngine::GPU::Color24::Green(), &wiggle, wiggle_count); if(timer.is_expired_for(50_ms)) { timer.reset(); diff --git a/include/stdarg.h b/include/stdarg.h index 2b82ee31..8714b050 100644 --- a/include/stdarg.h +++ b/include/stdarg.h @@ -5,5 +5,6 @@ typedef __builtin_va_list va_list; #define va_start __builtin_va_start #define va_end __builtin_va_end #define next_arg __builtin_next_arg +#define va_arg __builtin_va_arg #endif // !__STDARG__H \ No newline at end of file diff --git a/support/include/FontWriter/font_writer.hpp b/support/include/FontWriter/font_writer.hpp index d0aff802..0e0dc22c 100644 --- a/support/include/FontWriter/font_writer.hpp +++ b/support/include/FontWriter/font_writer.hpp @@ -40,7 +40,7 @@ namespace JabyEngine { void write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, ...) { __write_impl(wiggle, color, wiggle); } - void write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, va_list b); + void write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, va_list list); void render(); #undef __write_impl diff --git a/support/src/FontWriter/src/font_writer.cpp b/support/src/FontWriter/src/font_writer.cpp index b848382e..55fe2379 100644 --- a/support/src/FontWriter/src/font_writer.cpp +++ b/support/src/FontWriter/src/font_writer.cpp @@ -43,7 +43,7 @@ namespace JabyEngine { } } - void FontWriter :: write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, va_list b) { + void FontWriter :: write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, va_list list) { const auto* primitive_end = &this->prim_buffer.double_buffer[GPU::Display::current_id][this->prim_buffer.single_buffer_length]; const auto font_size = this->prim_buffer.double_buffer[0][0]->size; const auto row_count = 256/font_size.width; @@ -91,7 +91,7 @@ namespace JabyEngine { switch(*str) { case 'i': prev_str = str + 1; - str = simple_itoa(buffer, -505, 10); + str = simple_itoa(buffer, va_arg(list, int), 10); continue; case '%':