Wiggle experiments

This commit is contained in:
2023-12-01 15:25:36 -05:00
parent cd9f90bcd4
commit 833bc560d0
5 changed files with 18 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ namespace JabyEngine {
FontWriter::setup(buffer_info, vram_dst, Make::SizeI16(font_info.FontSize.width, font_info.FontSize.height));
}
GPU::PositionI16 write(GPU::PositionI16 pos, const char* str);
GPU::PositionI16 write(GPU::PositionI16 pos, const char* str, GPU::Color24 color = GPU::Color24::Grey(), uint8_t wiggle_count = 0);
void render();
};
}

View File

@@ -4,11 +4,13 @@
#include <stdio.h>
namespace JabyEngine {
static constexpr int8_t WiggleValues[] = {0, 3, 5, 1, -2, -5, -4, 1};//{0, 2, 6, 2, 0, -2, -6, -2};
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();
this->cur_primitive = buffer_info.double_buffer[GPU::Display::current_id];
for(size_t buffer_id = 0; buffer_id < 2; buffer_id++) {
for(size_t buffer_element_id = 0; buffer_element_id < buffer_info.single_buffer_length; buffer_element_id++) {
this->prim_buffer.double_buffer[buffer_id][buffer_element_id] = Make::SPRT(
@@ -19,7 +21,7 @@ namespace JabyEngine {
}
}
GPU::PositionI16 FontWriter :: write(GPU::PositionI16 pos, const char* str) {
GPU::PositionI16 FontWriter :: write(GPU::PositionI16 pos, const char* str, GPU::Color24 color, uint8_t wiggle_count) {
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;
@@ -41,13 +43,14 @@ namespace JabyEngine {
auto& primitive = *this->cur_primitive++;
primitive->position = pos;
primitive->position.move(0, -WiggleValues[wiggle_count&0b111]);
primitive->tex_offset = GPU::PageOffset::from_tile_id(cur_char - '!', row_count, font_size);
primitive->color = GPU::Color24::Grey();
primitive->color = color;
primitive.concat(*this->cur_primitive);
pos.move(primitive->size.width, 0);
wiggle_count++;
}
return pos;
}