summaryrefslogtreecommitdiff
path: root/stage3/gfx.c
diff options
context:
space:
mode:
authorLizzy Fleckenstein <eliasfleckenstein@web.de>2022-10-06 16:45:17 +0200
committerLizzy Fleckenstein <eliasfleckenstein@web.de>2022-10-06 16:45:17 +0200
commitf8397815545adb7d0da36614e0065aa68453a2e4 (patch)
treea771f526970c6724b2511577dceece8783450a49 /stage3/gfx.c
downloadcuddles-f8397815545adb7d0da36614e0065aa68453a2e4.tar.xz
Initial commit
Diffstat (limited to 'stage3/gfx.c')
-rw-r--r--stage3/gfx.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/stage3/gfx.c b/stage3/gfx.c
new file mode 100644
index 0000000..0ecf423
--- /dev/null
+++ b/stage3/gfx.c
@@ -0,0 +1,32 @@
+#include "gfx.h"
+
+struct GfxInfo *gfxinfo = (void *) (0x1000-10);
+
+// byteswap
+u32 make_color(color col)
+{
+ return ((u32) 0)
+ & ((u32) col.r << 0)
+ & ((u32) col.g << 8)
+ & ((u32) col.b << 16)
+ & ((u32) col.a << 24);
+}
+
+void set_pixel(u16 x, u16 y, u32 col)
+{
+ *((u32 *) (u64) (gfxinfo->framebuffer + y * gfxinfo->pitch + x * sizeof col)) = col;
+}
+
+void set_region(u16 x, u16 y, u16 w, u16 h, u32 col)
+{
+ void *cbeg = (void *) (u64) (gfxinfo->framebuffer + y * gfxinfo->pitch + x * sizeof col);
+ void *cend = cbeg + h * gfxinfo->pitch;
+
+ for (; cbeg < cend; cbeg += gfxinfo->pitch) {
+ void *rbeg = cbeg;
+ void *rend = rbeg + w * sizeof col;
+
+ for (; rbeg < rend; rbeg += sizeof col)
+ *((u32 *) rbeg) = col;
+ }
+}