From b17e075138570270406772a64ae705c91ed9f6f9 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Fri, 2 Feb 2024 09:12:51 +0800 Subject: [PATCH] add verite font There are still texture sampling issues that I don't understand. Until I properly understand this, using (bitmap) fonts that have power-of-two dimensions seem to produce "acceptable but incorrect" results. --- europc_mono.hpp | 7 ------- europc_mono.data => europc_mono_9x14.data | Bin europc_mono_9x14.hpp | 7 +++++++ example/example.mk | 4 ++-- example/font_bitmap.cpp | 4 ++-- example/suzanne_profile.cpp | 16 ++++++++-------- font/font_bitmap.cpp | 4 ++-- sperrypc.hpp | 7 ------- sperrypc.data => sperrypc_8x8.data | Bin sperrypc_8x8.hpp | 7 +++++++ verite_8x16.data | Bin 0 -> 1536 bytes verite_8x16.hpp | 7 +++++++ 12 files changed, 35 insertions(+), 28 deletions(-) delete mode 100644 europc_mono.hpp rename europc_mono.data => europc_mono_9x14.data (100%) create mode 100644 europc_mono_9x14.hpp delete mode 100644 sperrypc.hpp rename sperrypc.data => sperrypc_8x8.data (100%) create mode 100644 sperrypc_8x8.hpp create mode 100644 verite_8x16.data create mode 100644 verite_8x16.hpp diff --git a/europc_mono.hpp b/europc_mono.hpp deleted file mode 100644 index 5640718..0000000 --- a/europc_mono.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -extern uint32_t _binary_europc_mono_data_start __asm("_binary_europc_mono_data_start"); -extern uint32_t _binary_europc_mono_data_end __asm("_binary_europc_mono_data_end"); -extern uint32_t _binary_europc_mono_data_size __asm("_binary_europc_mono_data_size"); diff --git a/europc_mono.data b/europc_mono_9x14.data similarity index 100% rename from europc_mono.data rename to europc_mono_9x14.data diff --git a/europc_mono_9x14.hpp b/europc_mono_9x14.hpp new file mode 100644 index 0000000..a2be09f --- /dev/null +++ b/europc_mono_9x14.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include + +extern uint32_t _binary_europc_mono_9x14_data_start __asm("_binary_europc_mono_9x14_data_start"); +extern uint32_t _binary_europc_mono_9x14_data_end __asm("_binary_europc_mono_9x14_data_end"); +extern uint32_t _binary_europc_mono_9x14_data_size __asm("_binary_europc_mono_9x14_data_size"); diff --git a/example/example.mk b/example/example.mk index 19e512b..70e325b 100644 --- a/example/example.mk +++ b/example/example.mk @@ -40,7 +40,7 @@ FONT_BITMAP_OBJ = \ holly/region_array.o \ holly/background.o \ holly/ta_fifo_polygon_converter.o \ - sperrypc.data.o + sperrypc_8x8.data.o example/font_bitmap.elf: LDSCRIPT = $(LIB)/alt.lds example/font_bitmap.elf: $(START_OBJ) $(FONT_BITMAP_OBJ) @@ -124,7 +124,7 @@ SUZANNE_PROFILE_OBJ = \ holly/ta_fifo_polygon_converter.o \ font/font_bitmap.o \ sh7091/serial.o \ - europc_mono.data.o + verite_8x16.data.o example/suzanne_profile.elf: LDSCRIPT = $(LIB)/alt.lds example/suzanne_profile.elf: $(START_OBJ) $(SUZANNE_PROFILE_OBJ) diff --git a/example/font_bitmap.cpp b/example/font_bitmap.cpp index c0822b6..560b885 100644 --- a/example/font_bitmap.cpp +++ b/example/font_bitmap.cpp @@ -18,7 +18,7 @@ #include "holly/region_array.hpp" #include "twiddle.hpp" -#include "sperrypc.hpp" +#include "sperrypc_8x8.hpp" struct vertex { float x; @@ -229,7 +229,7 @@ void main() { vga(); - auto src = reinterpret_cast(&_binary_sperrypc_data_start); + auto src = reinterpret_cast(&_binary_sperrypc_8x8_data_start); inflate_font(src); palette_data(); diff --git a/example/suzanne_profile.cpp b/example/suzanne_profile.cpp index ccd7754..f427313 100644 --- a/example/suzanne_profile.cpp +++ b/example/suzanne_profile.cpp @@ -21,7 +21,7 @@ #include "math/vec4.hpp" #include "font/font_bitmap.hpp" -#include "europc_mono.hpp" +#include "verite_8x16.hpp" constexpr float half_degree = 0.01745329f / 2; @@ -239,11 +239,11 @@ void main() { vga(); - auto src = reinterpret_cast(&_binary_europc_mono_data_start); - font_bitmap::inflate(2, // pitch - 9, // width - 14, // height - 16, // texture_width + auto src = reinterpret_cast(&_binary_verite_8x16_data_start); + font_bitmap::inflate(1, // pitch + 8, // width + 16, // height + 8, // texture_width 16, // texture_height src); font_bitmap::palette_data(); @@ -308,8 +308,8 @@ void main() transform2(parameter, lights[2], {0.f, 0.f, 1.f, 1.f}); font_bitmap::transform_string(parameter, - 16, 16, // texture - 9, 14, // glyph + 8, 16, // texture + 8, 16, // glyph 40, 40, // position "test", 4); diff --git a/font/font_bitmap.cpp b/font/font_bitmap.cpp index 55d38e5..813ceba 100644 --- a/font/font_bitmap.cpp +++ b/font/font_bitmap.cpp @@ -156,8 +156,8 @@ void transform_string(ta_parameter_writer& parameter, y += static_cast(position_y); z = 1.f / (z + 10.f); - u *= static_cast(glyph_width - 1) / static_cast(texture_width); - v *= static_cast(glyph_height - 1) / static_cast(texture_height); + u *= static_cast(glyph_width) / static_cast(texture_width); + v *= static_cast(glyph_height) / static_cast(texture_height); parameter.append() = ta_vertex_parameter::polygon_type_3(polygon_vertex_parameter_control_word(end_of_strip), diff --git a/sperrypc.hpp b/sperrypc.hpp deleted file mode 100644 index 82f31f5..0000000 --- a/sperrypc.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -extern uint32_t _binary_sperrypc_data_start __asm("_binary_sperrypc_data_start"); -extern uint32_t _binary_sperrypc_data_end __asm("_binary_sperrypc_data_end"); -extern uint32_t _binary_sperrypc_data_size __asm("_binary_sperrypc_data_size"); diff --git a/sperrypc.data b/sperrypc_8x8.data similarity index 100% rename from sperrypc.data rename to sperrypc_8x8.data diff --git a/sperrypc_8x8.hpp b/sperrypc_8x8.hpp new file mode 100644 index 0000000..286ea61 --- /dev/null +++ b/sperrypc_8x8.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include + +extern uint32_t _binary_sperrypc_8x8_data_start __asm("_binary_sperrypc_8x8_data_start"); +extern uint32_t _binary_sperrypc_8x8_data_end __asm("_binary_sperrypc_8x8_data_end"); +extern uint32_t _binary_sperrypc_8x8_data_size __asm("_binary_sperrypc_8x8_data_size"); diff --git a/verite_8x16.data b/verite_8x16.data new file mode 100644 index 0000000000000000000000000000000000000000..369f0a9813a5b0bb81859f04f6ca35b9d34f283f GIT binary patch literal 1536 zcmZWpD{tID5MBjX0jtPx!6~Zp3l>zBfkD-uQDgQU;bfRN2_B}j_Q5Qv#_4TIq z3e{jwP_`3u1U=I}zb3KR?37*{fMb}-N zJL#A3P4m36e+2iEB1WQc60hd&8zcFg(l(6a*s=W{f`!gIw`cyjA)4b|$ETDg^vd{6 z+`pt92Aty~_%{ClK9>9topzxh1FA20pW}u2&{VpZ?fd>KXDs=mF;U=n!uhIP@l$$= z*O~XBssePKdF&WeJ;P4)z^t0ycVy)onYM==pvAL@G`e;pf3F8#t|JN&sj46-b zBb^S=Z@#bUchk`Lozw%$xY9%3=Zz-qS)cHj7W|XN?}@cCKfqh?K8``tNWs5vvFJUg z0jpV2L!~~g6@) + +extern uint32_t _binary_verite_8x16_data_start __asm("_binary_verite_8x16_data_start"); +extern uint32_t _binary_verite_8x16_data_end __asm("_binary_verite_8x16_data_end"); +extern uint32_t _binary_verite_8x16_data_size __asm("_binary_verite_8x16_data_size");