Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more optimizations on types #41

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion thermidity-avr/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ static void bufferBitmap(row_t row, col_t col,
uint8_t rotated[8];
memset(rotated, 0, 8);
uint16_t n = 0, x = 0;
uint16_t i_mod_height = 0, i_div_height = 0, x_mod_height = 0;
uint16_t i_div_height = 0;
height_t i_mod_height = 0, x_mod_height = 0;
for (uint16_t i = 0; i < size; i++) {
uint8_t next = bitmap[n];

Expand Down
6 changes: 3 additions & 3 deletions thermidity-avr/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
const __flash Glyph* getGlyphAddress(const __flash Font *font, code_t code) {

// https://en.wikipedia.org/wiki/Binary_search_algorithm
int16_t l = 0;
int16_t r = font->length - 1;
code_t l = 0;
code_t r = font->length - 1;

while (l <= r) {
uint8_t m = (l + r) / 2;
code_t m = (l + r) / 2;
const __flash Glyph *pglyph = &font->glyphs[m];
if (pglyph->code < code) {
l = m + 1;
Expand Down
2 changes: 1 addition & 1 deletion thermidity-avr/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef struct {
/** Glyphs of this font. */
const __flash Glyph *glyphs;
/** Number of glyphs of this font. */
const uint8_t length;
const length_t length;
/** Height of (the glyphs of) this font. */
const height_t height;
} Font;
Expand Down
3 changes: 3 additions & 0 deletions thermidity-avr/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ typedef uint8_t col_t;
/* Char code (like UTF-8 code point) */
typedef uint8_t code_t;

/* Number of glyphs of a font */
typedef uint8_t length_t;

#endif /* TYPES_H */