From: falcovorbis <fal...@us...> - 2024-10-11 05:12:33
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via b96c8042f0e7f9c51dd75216d18164dfb298fe95 (commit) via 8b78cd111a4af8c32f65afbd9baf1eb3ad02f05f (commit) via 3b708837842d9a1c907fb8113b4d616d51e3ba5b (commit) from a11364a33bbd9fd5bbd40ba76743d2a8f0eb9cc0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b96c8042f0e7f9c51dd75216d18164dfb298fe95 Author: Andy Barajas <and...@gm...> Date: Thu Oct 10 22:11:43 2024 -0700 Fix spacing and added more documentation to vmu_set_font() (#809) commit 8b78cd111a4af8c32f65afbd9baf1eb3ad02f05f Merge: a11364a3 3b708837 Author: Donald Haase <qu...@ya...> Date: Thu Oct 10 18:05:18 2024 -0400 Merge pull request #805 from Dreamcast-Projects/vmu_lcd_fix Fix vmu_lcd compile error and extend vmu font API commit 3b708837842d9a1c907fb8113b4d616d51e3ba5b Author: Andress Barajas <and...@gm...> Date: Thu Oct 10 13:24:23 2024 -0700 Fix VMU LCD compile error and update VMU font API - Remove extern vmufb_font4x6 - Handle NULL param in vmu_set_font() - Add id property to font for differentiation ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/vmu/vmu_lcd/lcd.c | 119 +------------------------- kernel/arch/dreamcast/include/dc/vmu_fb.h | 48 +++++------ kernel/arch/dreamcast/util/vmu_fb.c | 133 +++++++++++++++++++++++++++--- kernel/arch/dreamcast/util/vmu_printf.c | 113 +------------------------ 4 files changed, 149 insertions(+), 264 deletions(-) diff --git a/examples/dreamcast/vmu/vmu_lcd/lcd.c b/examples/dreamcast/vmu/vmu_lcd/lcd.c index 49f7a6be..904a7e27 100644 --- a/examples/dreamcast/vmu/vmu_lcd/lcd.c +++ b/examples/dreamcast/vmu/vmu_lcd/lcd.c @@ -30,120 +30,6 @@ #include <arch/arch.h> -/* 4x6 font from the Linux kernel: - https://github.com/torvalds/linux/blob/master/lib/fonts/font_mini_4x6.c - - Modified locally to pack the data better. - - Created by Kenneth Albanowski. - No rights reserved, released to the public domain. - */ -static const char fontdata_4x6[] = { - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0x00, 0x00, 0x00, 0x44, 0x40, 0x40, 0xaa, 0x00, - 0x00, 0xaf, 0xfa, 0x00, 0x46, 0xec, 0x40, 0xa2, - 0x48, 0xa0, 0x69, 0x6a, 0xd0, 0x24, 0x00, 0x00, - 0x24, 0x44, 0x20, 0x42, 0x22, 0x40, 0x0e, 0xee, - 0x00, 0x04, 0xe4, 0x00, 0x00, 0x04, 0x80, 0x00, - 0xe0, 0x00, 0x00, 0x00, 0x40, 0x02, 0x48, 0x00, - 0x4a, 0xaa, 0x40, 0x4c, 0x44, 0xe0, 0xc2, 0x48, - 0xe0, 0xe2, 0x62, 0xe0, 0xaa, 0xe2, 0x20, 0xe8, - 0xe2, 0xe0, 0xe8, 0xea, 0xe0, 0xe2, 0x22, 0x20, - 0xea, 0xea, 0xe0, 0xea, 0xe2, 0x20, 0x00, 0x40, - 0x40, 0x00, 0x40, 0x48, 0x24, 0x84, 0x20, 0x0e, - 0x0e, 0x00, 0x84, 0x24, 0x80, 0xe2, 0x60, 0x40, - 0x4e, 0xe8, 0x40, 0x4a, 0xea, 0xa0, 0xca, 0xca, - 0xc0, 0x68, 0x88, 0x60, 0xca, 0xaa, 0xc0, 0xe8, - 0xe8, 0xe0, 0xe8, 0xe8, 0x80, 0x68, 0xea, 0x60, - 0xaa, 0xea, 0xa0, 0xe4, 0x44, 0xe0, 0x22, 0x2a, - 0x40, 0xaa, 0xca, 0xa0, 0x88, 0x88, 0xe0, 0xae, - 0xea, 0xa0, 0xae, 0xee, 0xa0, 0x4a, 0xaa, 0x40, - 0xca, 0xc8, 0x80, 0x4a, 0xae, 0x60, 0xca, 0xec, - 0xa0, 0x68, 0x42, 0xc0, 0xe4, 0x44, 0x40, 0xaa, - 0xaa, 0x60, 0xaa, 0xa4, 0x40, 0xaa, 0xee, 0xa0, - 0xaa, 0x4a, 0xa0, 0xaa, 0x44, 0x40, 0xe2, 0x48, - 0xe0, 0x64, 0x44, 0x60, 0x08, 0x42, 0x00, 0x62, - 0x22, 0x60, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x0f, - 0x84, 0x00, 0x00, 0x00, 0x6a, 0xe0, 0x88, 0xca, - 0xc0, 0x00, 0x68, 0x60, 0x22, 0x6a, 0x60, 0x0e, - 0xe8, 0x60, 0x24, 0xe4, 0x40, 0x06, 0xa6, 0xe0, - 0x88, 0xca, 0xa0, 0x40, 0x44, 0x40, 0x40, 0x44, - 0x80, 0x08, 0xac, 0xa0, 0x0c, 0x44, 0xe0, 0x00, - 0xee, 0xa0, 0x00, 0xca, 0xa0, 0x04, 0xaa, 0x40, - 0x00, 0xca, 0xc8, 0x00, 0x6a, 0x62, 0x0c, 0xa8, - 0x80, 0x06, 0xc2, 0xc0, 0x04, 0xe4, 0x40, 0x00, - 0xaa, 0x60, 0x00, 0xae, 0x40, 0x00, 0xae, 0xe0, - 0x00, 0xa4, 0xa0, 0x00, 0xae, 0x2c, 0x0e, 0x6c, - 0xe0, 0x24, 0xc4, 0x20, 0x44, 0x44, 0x40, 0x84, - 0x64, 0x80, 0x5a, 0x00, 0x00, 0x4a, 0xae, 0x00, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0x06, 0xc6, 0x00, 0x0c, 0x6c, 0x00, - 0x82, 0x82, 0x82, 0xa5, 0xa5, 0xa5, 0xdb, 0xdb, - 0xdb, 0x44, 0x44, 0x44, 0x44, 0xc4, 0x44, 0x44, - 0xcc, 0x44, 0x66, 0xe6, 0x66, 0x00, 0xe6, 0x66, - 0x00, 0xcc, 0x44, 0x66, 0xee, 0x66, 0x66, 0x66, - 0x66, 0x00, 0xee, 0x66, 0x66, 0xee, 0x00, 0x66, - 0xe0, 0x00, 0x44, 0xcc, 0x00, 0x00, 0xc4, 0x44, - 0x44, 0x70, 0x00, 0x44, 0xf0, 0x00, 0x00, 0xf4, - 0x44, 0x44, 0x74, 0x44, 0x00, 0xf0, 0x00, 0x44, - 0xf4, 0x44, 0x44, 0x77, 0x44, 0x66, 0x76, 0x66, - 0x66, 0x77, 0x00, 0x00, 0x77, 0x66, 0x66, 0xff, - 0x00, 0x00, 0xff, 0x66, 0x66, 0x77, 0x66, 0x00, - 0xff, 0x00, 0x66, 0xff, 0x66, 0x44, 0xff, 0x00, - 0x66, 0xf0, 0x00, 0x00, 0xff, 0x44, 0x00, 0xf6, - 0x66, 0x66, 0x70, 0x00, 0x44, 0x77, 0x00, 0x00, - 0x77, 0x44, 0x00, 0x76, 0x66, 0x66, 0xf6, 0x66, - 0x44, 0xff, 0x44, 0x44, 0xc0, 0x00, 0x00, 0x74, - 0x44, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xcc, - 0xcc, 0xcc, 0x33, 0x33, 0x33, 0xff, 0xf0, 0x00, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0x00, 0x66, 0x00, 0xee, 0xee, 0xe0, -}; - -static const vmufb_font_t vmufb_font4x6 = { - .w = 4, - .h = 6, - .stride = 3, - .fontdata = fontdata_4x6, -}; - static const char smiley[] = { 0b00111100, 0b01000010, @@ -164,12 +50,15 @@ KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS); int main(int argc, char **argv) { unsigned int x, y, i, vmu; maple_device_t *dev; + const vmufb_font_t *font; float val; /* If start is pressed, exit the app. */ cont_btn_callback(0, CONT_START, (cont_btn_callback_t)arch_exit); + font = vmu_get_font(); + for(i = 0; ; i++) { vmufb_clear(&vmufb); @@ -179,7 +68,7 @@ int main(int argc, char **argv) { vmufb_paint_area(&vmufb, x, y, 8, 8, smiley); - vmufb_print_string_into(&vmufb, &vmufb_font4x6, + vmufb_print_string_into(&vmufb, font, 12, 12, 24, 6, 0, &message[(i / 16) % sizeof(message)]); diff --git a/kernel/arch/dreamcast/include/dc/vmu_fb.h b/kernel/arch/dreamcast/include/dc/vmu_fb.h index cad3a684..98cc6bef 100644 --- a/kernel/arch/dreamcast/include/dc/vmu_fb.h +++ b/kernel/arch/dreamcast/include/dc/vmu_fb.h @@ -50,6 +50,7 @@ typedef struct vmufb { layout, and a pointer to the raw font data. */ typedef struct vmufb_font { + unsigned int id; /**< Font id */ unsigned int w; /**< Character width in pixels */ unsigned int h; /**< Character height in pixels */ size_t stride; /**< Size of one character in bytes */ @@ -147,9 +148,9 @@ void vmufb_print_string_into(vmufb_t *fb, \param str The text to render */ static __inline__ -void vmufb_print_string(vmufb_t *fb, const vmufb_font_t *fnt, +void vmufb_print_string(vmufb_t *fb, const vmufb_font_t *font, const char *str) { - vmufb_print_string_into(fb, fnt, 0, 0, + vmufb_print_string_into(fb, font, 0, 0, VMU_SCREEN_WIDTH, VMU_SCREEN_HEIGHT, 0, str); } @@ -169,37 +170,30 @@ void vmufb_print_string(vmufb_t *fb, const vmufb_font_t *fnt, void vmu_printf(const char *fmt, ...) __printflike(1, 2); /** \brief Sets the default font for drawing text to the VMU. - * - * \warning - * The API does not take ownership of or copy \p font, so - * the given pointer must remain valid as long as it is set - * as the default! - * - * \param font Pointer to the font to set as default - * \returns Pointer to the previous default font - * - * \sa vmu_get_font() + + This function allows you to set a custom font for drawing text + to the VMU screen. If the \p font parameter is set to `NULL`, + the built-in VMU font will be used as the default. + + \warning + The API does not take ownership of or copy \p font, so + the given pointer must remain valid as long as it is set + as the default! + + \param font Pointer to the font to set as default + \returns Pointer to the previous default font + + \sa vmu_get_font() */ const vmufb_font_t *vmu_set_font(const vmufb_font_t *font); /** \brief Returns the default font used to draw text to the VMU. - * - * \returns Pointer to the font currently set as the default - * - * \sa vmu_set_font() - */ -const vmufb_font_t *vmu_get_font(void); -/** \brief Built-in VMU framebuffer font. - * - * \note - * This is the font that is currently used as the default. - * - * Linux 4x6 font: lib/fonts/font_mino_4x6.c - * - * \author Kenneth Albanowski + \returns Pointer to the font currently set as the default + + \sa vmu_set_font() */ -extern const vmufb_font_t vmufb_font4x6; +const vmufb_font_t *vmu_get_font(void); /** @} */ diff --git a/kernel/arch/dreamcast/util/vmu_fb.c b/kernel/arch/dreamcast/util/vmu_fb.c index 1be9e6d6..f590ce8c 100644 --- a/kernel/arch/dreamcast/util/vmu_fb.c +++ b/kernel/arch/dreamcast/util/vmu_fb.c @@ -15,6 +15,118 @@ #define GENMASK(h, l) \ (((unsigned int)-1 << (l)) & ((unsigned int)-1 >> (31 - (h)))) +/* Linux 4x6 font: lib/fonts/font_mini_4x6.c + * + * Created by Kenneth Albanowski. + * No rights reserved, released to the public domain. + */ +static const char fontdata_4x6[] = { + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0x00, 0x00, 0x00, 0x44, 0x40, 0x40, 0xaa, 0x00, + 0x00, 0xaf, 0xfa, 0x00, 0x46, 0xec, 0x40, 0xa2, + 0x48, 0xa0, 0x69, 0x6a, 0xd0, 0x24, 0x00, 0x00, + 0x24, 0x44, 0x20, 0x42, 0x22, 0x40, 0x0e, 0xee, + 0x00, 0x04, 0xe4, 0x00, 0x00, 0x04, 0x80, 0x00, + 0xe0, 0x00, 0x00, 0x00, 0x40, 0x02, 0x48, 0x00, + 0x4a, 0xaa, 0x40, 0x4c, 0x44, 0xe0, 0xc2, 0x48, + 0xe0, 0xe2, 0x62, 0xe0, 0xaa, 0xe2, 0x20, 0xe8, + 0xe2, 0xe0, 0xe8, 0xea, 0xe0, 0xe2, 0x22, 0x20, + 0xea, 0xea, 0xe0, 0xea, 0xe2, 0x20, 0x00, 0x40, + 0x40, 0x00, 0x40, 0x48, 0x24, 0x84, 0x20, 0x0e, + 0x0e, 0x00, 0x84, 0x24, 0x80, 0xe2, 0x60, 0x40, + 0x4e, 0xe8, 0x40, 0x4a, 0xea, 0xa0, 0xca, 0xca, + 0xc0, 0x68, 0x88, 0x60, 0xca, 0xaa, 0xc0, 0xe8, + 0xe8, 0xe0, 0xe8, 0xe8, 0x80, 0x68, 0xea, 0x60, + 0xaa, 0xea, 0xa0, 0xe4, 0x44, 0xe0, 0x22, 0x2a, + 0x40, 0xaa, 0xca, 0xa0, 0x88, 0x88, 0xe0, 0xae, + 0xea, 0xa0, 0xae, 0xee, 0xa0, 0x4a, 0xaa, 0x40, + 0xca, 0xc8, 0x80, 0x4a, 0xae, 0x60, 0xca, 0xec, + 0xa0, 0x68, 0x42, 0xc0, 0xe4, 0x44, 0x40, 0xaa, + 0xaa, 0x60, 0xaa, 0xa4, 0x40, 0xaa, 0xee, 0xa0, + 0xaa, 0x4a, 0xa0, 0xaa, 0x44, 0x40, 0xe2, 0x48, + 0xe0, 0x64, 0x44, 0x60, 0x08, 0x42, 0x00, 0x62, + 0x22, 0x60, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x0f, + 0x84, 0x00, 0x00, 0x00, 0x6a, 0xe0, 0x88, 0xca, + 0xc0, 0x00, 0x68, 0x60, 0x22, 0x6a, 0x60, 0x0e, + 0xe8, 0x60, 0x24, 0xe4, 0x40, 0x06, 0xa6, 0xe0, + 0x88, 0xca, 0xa0, 0x40, 0x44, 0x40, 0x40, 0x44, + 0x80, 0x08, 0xac, 0xa0, 0x0c, 0x44, 0xe0, 0x00, + 0xee, 0xa0, 0x00, 0xca, 0xa0, 0x04, 0xaa, 0x40, + 0x00, 0xca, 0xc8, 0x00, 0x6a, 0x62, 0x0c, 0xa8, + 0x80, 0x06, 0xc2, 0xc0, 0x04, 0xe4, 0x40, 0x00, + 0xaa, 0x60, 0x00, 0xae, 0x40, 0x00, 0xae, 0xe0, + 0x00, 0xa4, 0xa0, 0x00, 0xae, 0x2c, 0x0e, 0x6c, + 0xe0, 0x24, 0xc4, 0x20, 0x44, 0x44, 0x40, 0x84, + 0x64, 0x80, 0x5a, 0x00, 0x00, 0x4a, 0xae, 0x00, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0x06, 0xc6, 0x00, 0x0c, 0x6c, 0x00, + 0x82, 0x82, 0x82, 0xa5, 0xa5, 0xa5, 0xdb, 0xdb, + 0xdb, 0x44, 0x44, 0x44, 0x44, 0xc4, 0x44, 0x44, + 0xcc, 0x44, 0x66, 0xe6, 0x66, 0x00, 0xe6, 0x66, + 0x00, 0xcc, 0x44, 0x66, 0xee, 0x66, 0x66, 0x66, + 0x66, 0x00, 0xee, 0x66, 0x66, 0xee, 0x00, 0x66, + 0xe0, 0x00, 0x44, 0xcc, 0x00, 0x00, 0xc4, 0x44, + 0x44, 0x70, 0x00, 0x44, 0xf0, 0x00, 0x00, 0xf4, + 0x44, 0x44, 0x74, 0x44, 0x00, 0xf0, 0x00, 0x44, + 0xf4, 0x44, 0x44, 0x77, 0x44, 0x66, 0x76, 0x66, + 0x66, 0x77, 0x00, 0x00, 0x77, 0x66, 0x66, 0xff, + 0x00, 0x00, 0xff, 0x66, 0x66, 0x77, 0x66, 0x00, + 0xff, 0x00, 0x66, 0xff, 0x66, 0x44, 0xff, 0x00, + 0x66, 0xf0, 0x00, 0x00, 0xff, 0x44, 0x00, 0xf6, + 0x66, 0x66, 0x70, 0x00, 0x44, 0x77, 0x00, 0x00, + 0x77, 0x44, 0x00, 0x76, 0x66, 0x66, 0xf6, 0x66, + 0x44, 0xff, 0x44, 0x44, 0xc0, 0x00, 0x00, 0x74, + 0x44, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xcc, + 0xcc, 0xcc, 0x33, 0x33, 0x33, 0xff, 0xf0, 0x00, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0x00, 0x66, 0x00, 0xee, 0xee, 0xe0, +}; + +static const vmufb_font_t vmufb_font4x6 = { + .id = 0, + .w = 4, + .h = 6, + .stride = 3, + .fontdata = fontdata_4x6, +}; + static const vmufb_font_t *default_font = &vmufb_font4x6; static uint64_t extract_bits(const uint8_t *data, @@ -28,10 +140,10 @@ static uint64_t extract_bits(const uint8_t *data, Since we manipulate 8 bits at a time, and neither "w" nor "offt" are required to be byte-aligned, we need to compute a mask of valid bits for each byte that is processed. */ - while (w) { + while(w) { tmp = data[offt / 8]; - if (8 - (offt & 0x7) > w) + if(8 - (offt & 0x7) > w) lsb = 8 - (offt & 0x7) - w; else lsb = 0; @@ -54,10 +166,10 @@ static void insert_bits(uint8_t *data, unsigned int offt, unsigned int w, uint64_t bits) { uint32_t tmp, lsb, nb_bits, mask; - while (w) { + while(w) { tmp = data[offt / 8]; - if (8 - (offt & 0x7) > w) + if(8 - (offt & 0x7) > w) lsb = 8 - (offt & 0x7) - w; else lsb = 0; @@ -82,7 +194,7 @@ void vmufb_paint_area(vmufb_t *fb, unsigned int i; uint64_t bits; - for (i = 0; i < h; i++) { + for(i = 0; i < h; i++) { bits = extract_bits((const uint8_t *)data, i * w, w); insert_bits((uint8_t *)fb->data, (y + i) * VMU_SCREEN_WIDTH + x, w, bits); } @@ -125,7 +237,7 @@ void vmufb_print_string_into(vmufb_t *fb, unsigned int xorig = x, yorig = y; font = font? font : default_font; - for (; *str; str++) { + for(; *str; str++) { switch (*str) { case '\n': x = xorig; @@ -135,13 +247,13 @@ void vmufb_print_string_into(vmufb_t *fb, break; } - if (x > xorig + w - font->w) { + if(x > xorig + w - font->w) { /* We run out of horizontal space - put character on new line */ x = xorig; y += line_spacing + font->h; } - if (y > yorig + h - font->h) { + if(y > yorig + h - font->h) { /* We ran out of space */ break; } @@ -155,10 +267,11 @@ void vmufb_print_string_into(vmufb_t *fb, const vmufb_font_t *vmu_set_font(const vmufb_font_t *font) { const vmufb_font_t *temp = default_font; - default_font = font; + default_font = (font) ? font : &vmufb_font4x6; + return temp; } const vmufb_font_t *vmu_get_font(void) { return default_font; -} \ No newline at end of file +} diff --git a/kernel/arch/dreamcast/util/vmu_printf.c b/kernel/arch/dreamcast/util/vmu_printf.c index 92840001..4a725954 100644 --- a/kernel/arch/dreamcast/util/vmu_printf.c +++ b/kernel/arch/dreamcast/util/vmu_printf.c @@ -1,6 +1,6 @@ /* KallistiOS ##version## - util/vmu_fb.c + util/vmu_printf.c Copyright (C) 2024 Paul Cercueil */ @@ -11,117 +11,6 @@ static vmufb_t vmufb; -/* Linux 4x6 font: lib/fonts/font_mini_4x6.c - * - * Created by Kenneth Albanowski. - * No rights reserved, released to the public domain. - */ -static const char fontdata_4x6[] = { - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0x00, 0x00, 0x00, 0x44, 0x40, 0x40, 0xaa, 0x00, - 0x00, 0xaf, 0xfa, 0x00, 0x46, 0xec, 0x40, 0xa2, - 0x48, 0xa0, 0x69, 0x6a, 0xd0, 0x24, 0x00, 0x00, - 0x24, 0x44, 0x20, 0x42, 0x22, 0x40, 0x0e, 0xee, - 0x00, 0x04, 0xe4, 0x00, 0x00, 0x04, 0x80, 0x00, - 0xe0, 0x00, 0x00, 0x00, 0x40, 0x02, 0x48, 0x00, - 0x4a, 0xaa, 0x40, 0x4c, 0x44, 0xe0, 0xc2, 0x48, - 0xe0, 0xe2, 0x62, 0xe0, 0xaa, 0xe2, 0x20, 0xe8, - 0xe2, 0xe0, 0xe8, 0xea, 0xe0, 0xe2, 0x22, 0x20, - 0xea, 0xea, 0xe0, 0xea, 0xe2, 0x20, 0x00, 0x40, - 0x40, 0x00, 0x40, 0x48, 0x24, 0x84, 0x20, 0x0e, - 0x0e, 0x00, 0x84, 0x24, 0x80, 0xe2, 0x60, 0x40, - 0x4e, 0xe8, 0x40, 0x4a, 0xea, 0xa0, 0xca, 0xca, - 0xc0, 0x68, 0x88, 0x60, 0xca, 0xaa, 0xc0, 0xe8, - 0xe8, 0xe0, 0xe8, 0xe8, 0x80, 0x68, 0xea, 0x60, - 0xaa, 0xea, 0xa0, 0xe4, 0x44, 0xe0, 0x22, 0x2a, - 0x40, 0xaa, 0xca, 0xa0, 0x88, 0x88, 0xe0, 0xae, - 0xea, 0xa0, 0xae, 0xee, 0xa0, 0x4a, 0xaa, 0x40, - 0xca, 0xc8, 0x80, 0x4a, 0xae, 0x60, 0xca, 0xec, - 0xa0, 0x68, 0x42, 0xc0, 0xe4, 0x44, 0x40, 0xaa, - 0xaa, 0x60, 0xaa, 0xa4, 0x40, 0xaa, 0xee, 0xa0, - 0xaa, 0x4a, 0xa0, 0xaa, 0x44, 0x40, 0xe2, 0x48, - 0xe0, 0x64, 0x44, 0x60, 0x08, 0x42, 0x00, 0x62, - 0x22, 0x60, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x0f, - 0x84, 0x00, 0x00, 0x00, 0x6a, 0xe0, 0x88, 0xca, - 0xc0, 0x00, 0x68, 0x60, 0x22, 0x6a, 0x60, 0x0e, - 0xe8, 0x60, 0x24, 0xe4, 0x40, 0x06, 0xa6, 0xe0, - 0x88, 0xca, 0xa0, 0x40, 0x44, 0x40, 0x40, 0x44, - 0x80, 0x08, 0xac, 0xa0, 0x0c, 0x44, 0xe0, 0x00, - 0xee, 0xa0, 0x00, 0xca, 0xa0, 0x04, 0xaa, 0x40, - 0x00, 0xca, 0xc8, 0x00, 0x6a, 0x62, 0x0c, 0xa8, - 0x80, 0x06, 0xc2, 0xc0, 0x04, 0xe4, 0x40, 0x00, - 0xaa, 0x60, 0x00, 0xae, 0x40, 0x00, 0xae, 0xe0, - 0x00, 0xa4, 0xa0, 0x00, 0xae, 0x2c, 0x0e, 0x6c, - 0xe0, 0x24, 0xc4, 0x20, 0x44, 0x44, 0x40, 0x84, - 0x64, 0x80, 0x5a, 0x00, 0x00, 0x4a, 0xae, 0x00, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |