Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
3 changed files with 47 additions and 3 deletions
Showing only changes of commit 10ac77fc75 - Show all commits

View File

@ -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, "Miau: %i", JabyEngine::GPU::Color24::Red(), &wiggle, 12345);
new_font_writer.write(state, "Mi%iau:", JabyEngine::GPU::Color24::Yellow(), &wiggle, 12345);
if(timer.is_expired_for(50_ms)) {
timer.reset();

View File

@ -4,5 +4,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
#endif // !__STDARG__H

View File

@ -4,6 +4,30 @@
#include <stdio.h>
namespace JabyEngine {
static const char* simple_itoa(char (&buffer)[32], int value, int base) {
const bool is_neg = value < 0;
int i = 32 - 2;
if(is_neg) {
value *= -1;
}
for(; value && i; i--, value /= base) {
char chr = '0' + value%base;
if(chr > '9') {
chr += ('A' - '9');
}
buffer[i] = chr;
}
buffer[32 - 1] = '\0';
if(is_neg) {
buffer[i] = '-';
return &buffer[i];
}
return &buffer[i+1];
}
void FontWriter :: setup(const FontBufferInfo& buffer_info, const SimpleTIM& vram_dst, const GPU::SizeI16& font_size) {
this->prim_buffer = buffer_info;
this->tex_page = Make::TexPage(vram_dst.get_texture_position(), GPU::TexturePageColor::$4bit).linked();
@ -39,12 +63,19 @@ namespace JabyEngine {
state.pos.move(primitive->size.width, 0);
return true;
};
const auto old_x = state.pos.x;
const auto old_x = state.pos.x;
const char* prev_str = nullptr;
char buffer[32];
while(true) {
const auto cur_char = *str++;
auto cur_char = *str++;
switch(cur_char) {
case '\0':
if(prev_str) {
str = prev_str;
prev_str = nullptr;
continue;
}
return;
case '\n':
@ -56,6 +87,18 @@ namespace JabyEngine {
state.pos.x += font_size.width;
continue;
case '%':
switch(*str) {
case 'i':
prev_str = str + 1;
str = simple_itoa(buffer, -505, 10);
continue;
case '%':
str++;
break;
}
default:
auto& primitive = *this->cur_primitive++;
if(!push_char(state, primitive, cur_char)) {