|
From: quzar <qu...@us...> - 2024-10-08 19:24:05
|
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 d8a5b8379f4e6652ad98f81ccc6d3248c2986cb5 (commit)
via 42cd2b6cec424c4e1c651536ed893675bd76a2b6 (commit)
via 67155450e73fa430380a88aee0527d47807380ca (commit)
from 98018e6f51e2e7bf6ffe3274e6e8d94769860640 (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 d8a5b8379f4e6652ad98f81ccc6d3248c2986cb5
Merge: 42cd2b6c 67155450
Author: Donald Haase <qu...@ya...>
Date: Tue Oct 8 15:22:58 2024 -0400
Merge pull request #799 from pcercuei/fix-nehe26
examples: Fix nehe26 builds
commit 42cd2b6cec424c4e1c651536ed893675bd76a2b6
Author: Falco Girgis <gyr...@gm...>
Date: Tue Oct 8 14:20:44 2024 -0500
Made builtin font used by vmu_printf() public. (#793)
* Made built in font used by vmu_printf() public.
- Need a quick font without external dependencies to use with the
extended font-drawing methods in the vmufb API? Sweet. We already have
one used by vmu_printf()
- Now get or set the vmufb font via vmu_get_font() and vmu_set_font(), or
directly access the builtin one.
commit 67155450e73fa430380a88aee0527d47807380ca
Author: Paul Cercueil <pa...@cr...>
Date: Tue Oct 8 13:17:36 2024 +0200
examples: Fix nehe26 builds
Fix the gldc and KGL builds of nehe26.
They caused problems because of the nested data/Makefile. The romdisk
files are now generated by the example's main Makefile.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/gldc/nehe/nehe26/Makefile | 12 ++-
examples/dreamcast/gldc/nehe/nehe26/data/Makefile | 12 ---
.../dreamcast/gldc/nehe/nehe26/romdisk/.empty | 0
.../dreamcast/gldc/nehe/nehe26/romdisk/sphere.bin | Bin 5836 -> 0 bytes
.../dreamcast/gldc/nehe/nehe26/romdisk/torus.bin | Bin 5836 -> 0 bytes
.../dreamcast/gldc/nehe/nehe26/romdisk/tube.bin | Bin 5836 -> 0 bytes
examples/dreamcast/kgl/nehe/nehe26/Makefile | 12 ++-
examples/dreamcast/kgl/nehe/nehe26/data/Makefile | 12 ---
.../dreamcast/kgl/nehe/nehe26/romdisk/.empty | 0
.../dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin | Bin 5836 -> 0 bytes
.../dreamcast/kgl/nehe/nehe26/romdisk/torus.bin | Bin 5836 -> 0 bytes
.../dreamcast/kgl/nehe/nehe26/romdisk/tube.bin | Bin 5836 -> 0 bytes
kernel/arch/dreamcast/include/dc/vmu_fb.h | 108 ++++++++++++++++-----
kernel/arch/dreamcast/util/vmu_fb.c | 18 +++-
kernel/arch/dreamcast/util/vmu_printf.c | 8 +-
15 files changed, 125 insertions(+), 57 deletions(-)
delete mode 100644 examples/dreamcast/gldc/nehe/nehe26/data/Makefile
copy addons/lib/.keepme => examples/dreamcast/gldc/nehe/nehe26/romdisk/.empty (100%)
delete mode 100644 examples/dreamcast/gldc/nehe/nehe26/romdisk/sphere.bin
delete mode 100644 examples/dreamcast/gldc/nehe/nehe26/romdisk/torus.bin
delete mode 100644 examples/dreamcast/gldc/nehe/nehe26/romdisk/tube.bin
delete mode 100644 examples/dreamcast/kgl/nehe/nehe26/data/Makefile
copy addons/lib/.keepme => examples/dreamcast/kgl/nehe/nehe26/romdisk/.empty (100%)
delete mode 100644 examples/dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin
delete mode 100644 examples/dreamcast/kgl/nehe/nehe26/romdisk/torus.bin
delete mode 100644 examples/dreamcast/kgl/nehe/nehe26/romdisk/tube.bin
diff --git a/examples/dreamcast/gldc/nehe/nehe26/Makefile b/examples/dreamcast/gldc/nehe/nehe26/Makefile
index 6c4816e7..0cccc720 100644
--- a/examples/dreamcast/gldc/nehe/nehe26/Makefile
+++ b/examples/dreamcast/gldc/nehe/nehe26/Makefile
@@ -7,13 +7,14 @@
TARGET = nehe26.elf
OBJS = nehe26.o romdisk.o
KOS_ROMDISK_DIR = romdisk
+RD_DATA = romdisk/sphere.bin romdisk/torus.bin romdisk/tube.bin
all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
clean: rm-elf
- -rm -f $(OBJS)
+ -rm -f $(OBJS) $(RD_DATA) data/txt2bin
rm-elf:
-rm -f $(TARGET) romdisk.*
@@ -28,3 +29,12 @@ dist: $(TARGET)
-rm -f $(OBJS) romdisk.img
$(KOS_STRIP) $(TARGET)
+data/txt2bin: data/txt2bin.c
+ $(CC) -o $@ $<
+
+romdisk.img: $(RD_DATA)
+
+$(RD_DATA): %.bin: data/txt2bin
+
+$(RD_DATA): romdisk/%.bin: data/%.txt
+ data/txt2bin $< $@
diff --git a/examples/dreamcast/gldc/nehe/nehe26/data/Makefile b/examples/dreamcast/gldc/nehe/nehe26/data/Makefile
deleted file mode 100644
index dcaf81c2..00000000
--- a/examples/dreamcast/gldc/nehe/nehe26/data/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# Kallistios - txt2bin Makefile
-#
-# (c)2002, Paul Boese
-#
-
-CC = gcc -Wall
-
-all:
- $(CC) -o txt2bin txt2bin.c
-
-clean:
- @rm txt2bin *.bin
diff --git a/addons/lib/.keepme b/examples/dreamcast/gldc/nehe/nehe26/romdisk/.empty
similarity index 100%
copy from addons/lib/.keepme
copy to examples/dreamcast/gldc/nehe/nehe26/romdisk/.empty
diff --git a/examples/dreamcast/gldc/nehe/nehe26/romdisk/sphere.bin b/examples/dreamcast/gldc/nehe/nehe26/romdisk/sphere.bin
deleted file mode 100644
index 6b6db530..00000000
Binary files a/examples/dreamcast/gldc/nehe/nehe26/romdisk/sphere.bin and /dev/null differ
diff --git a/examples/dreamcast/gldc/nehe/nehe26/romdisk/torus.bin b/examples/dreamcast/gldc/nehe/nehe26/romdisk/torus.bin
deleted file mode 100644
index da95c893..00000000
Binary files a/examples/dreamcast/gldc/nehe/nehe26/romdisk/torus.bin and /dev/null differ
diff --git a/examples/dreamcast/gldc/nehe/nehe26/romdisk/tube.bin b/examples/dreamcast/gldc/nehe/nehe26/romdisk/tube.bin
deleted file mode 100644
index 988bc75d..00000000
Binary files a/examples/dreamcast/gldc/nehe/nehe26/romdisk/tube.bin and /dev/null differ
diff --git a/examples/dreamcast/kgl/nehe/nehe26/Makefile b/examples/dreamcast/kgl/nehe/nehe26/Makefile
index 2a0c4c84..b15db8dc 100644
--- a/examples/dreamcast/kgl/nehe/nehe26/Makefile
+++ b/examples/dreamcast/kgl/nehe/nehe26/Makefile
@@ -7,13 +7,14 @@
TARGET = nehe26.elf
OBJS = nehe26.o romdisk.o
KOS_ROMDISK_DIR = romdisk
+RD_DATA = romdisk/sphere.bin romdisk/torus.bin romdisk/tube.bin
all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
clean: rm-elf
- -rm -f $(OBJS)
+ -rm -f $(OBJS) $(RD_DATA) data/txt2bin
rm-elf:
-rm -f $(TARGET) romdisk.*
@@ -28,3 +29,12 @@ dist: $(TARGET)
-rm -f $(OBJS) romdisk.img
$(KOS_STRIP) $(TARGET)
+data/txt2bin: data/txt2bin.c
+ $(CC) -o $@ $<
+
+romdisk.img: $(RD_DATA)
+
+$(RD_DATA): %.bin: data/txt2bin
+
+$(RD_DATA): romdisk/%.bin: data/%.txt
+ data/txt2bin $< $@
diff --git a/examples/dreamcast/kgl/nehe/nehe26/data/Makefile b/examples/dreamcast/kgl/nehe/nehe26/data/Makefile
deleted file mode 100644
index dcaf81c2..00000000
--- a/examples/dreamcast/kgl/nehe/nehe26/data/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# Kallistios - txt2bin Makefile
-#
-# (c)2002, Paul Boese
-#
-
-CC = gcc -Wall
-
-all:
- $(CC) -o txt2bin txt2bin.c
-
-clean:
- @rm txt2bin *.bin
diff --git a/addons/lib/.keepme b/examples/dreamcast/kgl/nehe/nehe26/romdisk/.empty
similarity index 100%
copy from addons/lib/.keepme
copy to examples/dreamcast/kgl/nehe/nehe26/romdisk/.empty
diff --git a/examples/dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin b/examples/dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin
deleted file mode 100644
index 6b6db530..00000000
Binary files a/examples/dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin and /dev/null differ
diff --git a/examples/dreamcast/kgl/nehe/nehe26/romdisk/torus.bin b/examples/dreamcast/kgl/nehe/nehe26/romdisk/torus.bin
deleted file mode 100644
index da95c893..00000000
Binary files a/examples/dreamcast/kgl/nehe/nehe26/romdisk/torus.bin and /dev/null differ
diff --git a/examples/dreamcast/kgl/nehe/nehe26/romdisk/tube.bin b/examples/dreamcast/kgl/nehe/nehe26/romdisk/tube.bin
deleted file mode 100644
index 988bc75d..00000000
Binary files a/examples/dreamcast/kgl/nehe/nehe26/romdisk/tube.bin and /dev/null differ
diff --git a/kernel/arch/dreamcast/include/dc/vmu_fb.h b/kernel/arch/dreamcast/include/dc/vmu_fb.h
index ae38a21d..cad3a684 100644
--- a/kernel/arch/dreamcast/include/dc/vmu_fb.h
+++ b/kernel/arch/dreamcast/include/dc/vmu_fb.h
@@ -10,35 +10,50 @@
/** \file dc/vmu_fb.h
\brief VMU framebuffer.
- \ingroup vmu
+ \ingroup vmu_fb
This file provides an API that can be used to compose a 48x32 image that can
then be displayed on the VMUs connected to the system.
+
+ \author Paul Cercueil
*/
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+
#include <dc/maple.h>
+#include <dc/maple/vmu.h>
#include <stdint.h>
+#include <stdarg.h>
+
+/** \defgroup vmu_fb Framebuffer
+ * \ingroup vmu
+ *
+ * This API provides a virtual framebuffer abstraction for the VMU with a
+ * series of convenient methods for drawing complex and dynamic content.
+ *
+ * @{
+*/
-/** \brief VMU framebuffer.
+/** \brief Virtual framebuffer for the VMU
This object contains a 48x32 monochrome framebuffer. It can be painted to,
- or displayed one the VMUs connected to the system, using the API below.
-
- \headerfile dc/vmu_fb.h
+ or displayed on one the VMUs connected to the system, using the API below.
*/
-typedef struct {
- uint32_t data[48];
+typedef struct vmufb {
+ uint32_t data[VMU_SCREEN_WIDTH]; /**< Private framebuffer pixel data */
} vmufb_t;
/** \brief VMU framebuffer font meta-data.
- \headerfile dc/vmu_fb.h
+ This structure describes a font, including character sizes,
+ layout, and a pointer to the raw font data.
*/
-typedef struct {
- unsigned int w; /**< \brief Character width in pixels */
- unsigned int h; /**< \brief Character height in pixels */
- unsigned int stride; /**< \brief Size of one character in bytes */
- const char *fontdata; /**< \brief Pointer to the font data */
+typedef struct vmufb_font {
+ unsigned int w; /**< Character width in pixels */
+ unsigned int h; /**< Character height in pixels */
+ size_t stride; /**< Size of one character in bytes */
+ const char *fontdata; /**< Pointer to the font data */
} vmufb_font_t;
/** \brief Render into the VMU framebuffer
@@ -103,7 +118,7 @@ void vmufb_present(const vmufb_t *fb, maple_device_t *dev);
\param fb A pointer to the vmufb_t to paint to.
\param font A pointer to the vmufb_font_t that will be used for
- painting the text
+ painting the text (or NULL to use the default)
\param x The horizontal position of the top-left corner of
the drawing area, in pixels
\param y The vertical position of the top-left corner of the
@@ -115,11 +130,11 @@ void vmufb_present(const vmufb_t *fb, maple_device_t *dev);
\param str The text to render
*/
void vmufb_print_string_into(vmufb_t *fb,
- const vmufb_font_t *font,
- unsigned int x, unsigned int y,
- unsigned int w, unsigned int h,
- unsigned int line_spacing,
- const char *str);
+ const vmufb_font_t *font,
+ unsigned int x, unsigned int y,
+ unsigned int w, unsigned int h,
+ unsigned int line_spacing,
+ const char *str);
/** \brief Render a string into the VMU framebuffer
@@ -128,12 +143,14 @@ void vmufb_print_string_into(vmufb_t *fb,
\param fb A pointer to the vmufb_t to paint to.
\param font A pointer to the vmufb_font_t that will be used for
- painting the text
+ painting the text (or NULL to use the default)
\param str The text to render
*/
-static __inline__ void
-vmufb_print_string(vmufb_t *fb, const vmufb_font_t *font, const char *str) {
- vmufb_print_string_into(fb, font, 0, 0, 48, 32, 0, str);
+static __inline__
+void vmufb_print_string(vmufb_t *fb, const vmufb_font_t *fnt,
+ const char *str) {
+ vmufb_print_string_into(fb, fnt, 0, 0,
+ VMU_SCREEN_WIDTH, VMU_SCREEN_HEIGHT, 0, str);
}
/** \brief Render a string to attached VMUs using the built-in font
@@ -141,10 +158,51 @@ vmufb_print_string(vmufb_t *fb, const vmufb_font_t *font, const char *str) {
Uses the built-in VMU font to render a string to all VMUs connected to the
system.
+ \note
+ The font currently set as the default font will be used.
+
\param fmt The format string, optionally followed by extra
arguments.
+
+ \sa vmu_set_font()
*/
-__attribute__ ((format (printf, 1, 2)))
-void vmu_printf(const char *fmt, ...);
+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()
+ */
+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
+ */
+extern const vmufb_font_t vmufb_font4x6;
+
+/** @} */
+
+__END_DECLS
#endif /* __DC_VMU_FB_H */
diff --git a/kernel/arch/dreamcast/util/vmu_fb.c b/kernel/arch/dreamcast/util/vmu_fb.c
index 5fc94013..1be9e6d6 100644
--- a/kernel/arch/dreamcast/util/vmu_fb.c
+++ b/kernel/arch/dreamcast/util/vmu_fb.c
@@ -2,6 +2,7 @@
util/vmu_fb.c
Copyright (C) 2023 Paul Cercueil
+ Copyright (C) 2024 Falco Girgis
*/
@@ -14,6 +15,8 @@
#define GENMASK(h, l) \
(((unsigned int)-1 << (l)) & ((unsigned int)-1 >> (31 - (h))))
+static const vmufb_font_t *default_font = &vmufb_font4x6;
+
static uint64_t extract_bits(const uint8_t *data,
unsigned int offt, unsigned int w) {
uint32_t tmp, lsb, nb_bits;
@@ -81,7 +84,7 @@ void vmufb_paint_area(vmufb_t *fb,
for (i = 0; i < h; i++) {
bits = extract_bits((const uint8_t *)data, i * w, w);
- insert_bits((uint8_t *)fb->data, (y + i) * 48 + x, w, bits);
+ insert_bits((uint8_t *)fb->data, (y + i) * VMU_SCREEN_WIDTH + x, w, bits);
}
}
@@ -92,7 +95,7 @@ void vmufb_clear(vmufb_t *fb) {
void vmufb_clear_area(vmufb_t *fb,
unsigned int x, unsigned int y,
unsigned int w, unsigned int h) {
- uint32_t tmp[48] = {};
+ uint32_t tmp[VMU_SCREEN_WIDTH] = {};
vmufb_paint_area(fb, x, y, w, h, (const char *) tmp);
}
@@ -120,6 +123,7 @@ void vmufb_print_string_into(vmufb_t *fb,
unsigned int line_spacing,
const char *str) {
unsigned int xorig = x, yorig = y;
+ font = font? font : default_font;
for (; *str; str++) {
switch (*str) {
@@ -148,3 +152,13 @@ void vmufb_print_string_into(vmufb_t *fb,
x += font->w;
}
}
+
+const vmufb_font_t *vmu_set_font(const vmufb_font_t *font) {
+ const vmufb_font_t *temp = default_font;
+ default_font = font;
+ 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 6024415c..92840001 100644
--- a/kernel/arch/dreamcast/util/vmu_printf.c
+++ b/kernel/arch/dreamcast/util/vmu_printf.c
@@ -115,15 +115,14 @@ static const char fontdata_4x6[] = {
0xee, 0xe0, 0x00, 0x66, 0x00, 0xee, 0xee, 0xe0,
};
-static const vmufb_font_t vmufb_font4x6 = {
+const vmufb_font_t vmufb_font4x6 = {
.w = 4,
.h = 6,
.stride = 3,
.fontdata = fontdata_4x6,
};
-void vmu_printf(const char *fmt, ...)
-{
+void vmu_printf(const char *fmt, ...) {
maple_device_t *dev;
unsigned int vmu;
char buf[256];
@@ -135,7 +134,8 @@ void vmu_printf(const char *fmt, ...)
vsnprintf(buf, sizeof(buf), fmt, va);
va_end(va);
- vmufb_print_string(&vmufb, &vmufb_font4x6, buf);
+ vmufb_clear(&vmufb);
+ vmufb_print_string(&vmufb, vmu_get_font(), buf);
for (vmu = 0; ; vmu++) {
dev = maple_enum_type(vmu, MAPLE_FUNC_LCD);
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|