diff --git a/math/vec4.hpp b/math/vec4.hpp index 2ec8b45..dd66865 100644 --- a/math/vec4.hpp +++ b/math/vec4.hpp @@ -15,6 +15,7 @@ struct vec<4, T> inline constexpr vec(); inline constexpr vec(T scalar); inline constexpr vec(T _x, T _y, T _z, T _w); + inline constexpr vec(vec<3, T> const& xyz, T w); constexpr inline vec<4, T> operator-() const; inline constexpr T const& operator[](int i) const; @@ -34,8 +35,13 @@ inline constexpr vec<4, T>::vec(T scalar) {} template -inline constexpr vec<4, T>::vec(T _x, T _y, T _z, T _w) - : x(_x), y(_y), z(_z), w(_w) +inline constexpr vec<4, T>::vec(T x, T y, T z, T w) + : x(x), y(y), z(z), w(w) +{} + +template +inline constexpr vec<4, T>::vec(vec<3, T> const& xyz, T w) + : x(xyz.x), y(xyz.y), z(xyz.z), w(w) {} template diff --git a/scsp/fm.cpp b/scsp/fm.cpp index ce673fb..eb45e55 100644 --- a/scsp/fm.cpp +++ b/scsp/fm.cpp @@ -666,7 +666,7 @@ void init_slots() scsp.reg.ctrl.MIXER = MIXER__MEM4MB | MIXER__MVOL(0); for (long i = 0; i < 3200; i++) { asm volatile ("nop"); } // wait for (way) more than 30µs - + /* The Saturn BIOS does not (un)initialize the DSP. Without zeroizing the DSP program, the SCSP DSP appears to have a program that continuously writes to diff --git a/tools/ttf-bitmap.cpp b/tools/ttf-bitmap.cpp index 55782e9..71a349d 100644 --- a/tools/ttf-bitmap.cpp +++ b/tools/ttf-bitmap.cpp @@ -12,7 +12,7 @@ load_bitmap_char(FT_Face face, FT_ULong char_code, uint8_t * buf) { - FT_Error error; + FT_Error error; FT_UInt glyph_index = FT_Get_Char_Index(face, char_code); error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); @@ -25,26 +25,22 @@ load_bitmap_char(FT_Face face, //printf("num_grays %d\n", face->glyph->bitmap.num_grays); //printf("pitch %d\n", face->glyph->bitmap.pitch); //printf("width %d\n", face->glyph->bitmap.width); - assert(face->glyph->bitmap.width == 8); //printf("char_code %lx rows %d\n", char_code, face->glyph->bitmap.rows); - assert((face->glyph->bitmap.rows % 8) == 0); - assert(face->glyph->bitmap.width / face->glyph->bitmap.pitch == 8); - + //assert((face->glyph->bitmap.rows % 8) == 0); + //assert(face->glyph->bitmap.width / face->glyph->bitmap.pitch == 8); + for (int y = 0; y < (int)face->glyph->bitmap.rows; y++) { uint8_t * row = &face->glyph->bitmap.buffer[y * face->glyph->bitmap.pitch]; uint8_t row_out = 0; for (unsigned int x = 0; x < face->glyph->bitmap.width; x++) { - int bit; - if (x < face->glyph->bitmap.width) { - bit = (row[x / 8] >> (7 - (x % 8))) & 1; - } else { - bit = 0; - } + if (x % 8 == 0) row_out = 0; + const uint8_t bit = (row[x / 8] >> (7 - (x % 8))) & 1; //std::cerr << (bit ? "█" : " "); row_out |= (bit << (7 - (x % 8))); + if (x % 8 == 7 || x == (face->glyph->bitmap.width - 1)) + buf[(y * face->glyph->bitmap.pitch) + (x / 8)] = row_out; } - //std::cerr << '\n'; - buf[y] = row_out; + //std::cerr << "|\n"; } // 'pitch' is bytes; 'width' is pixels @@ -78,7 +74,7 @@ int main(int argc, char *argv[]) auto end = parse_num(std::hex, argv[2]); auto font_file_path = argv[3]; auto output_file_path = argv[4]; - + error = FT_Init_FreeType(&library); if (error) { std::cerr << "FT_Init_FreeType\n"; @@ -90,7 +86,7 @@ int main(int argc, char *argv[]) std::cerr << "FT_New_Face\n"; return -1; } - + error = FT_Select_Size(face, 0); if (error) { std::cerr << "FT_Select_Size: " << FT_Error_String(error) << ' ' << error << '\n';