diff options
| author | hachem <im@hachem.wtf> | 2026-09-10 07:17:15 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-10 07:17:15 +0200 |
| commit | dbe50063b0f78ecbcb14ade65e16c5c74ad9abe1 (patch) | |
| tree | 2a4c08c6772b710cb30a0a586124196b5dabe954 /boot/framebuffer.zig | |
| parent | 0434097a393e790085911bad5229a6654876dae3 (diff) | |
feat: basic framebuffer
Diffstat (limited to 'boot/framebuffer.zig')
| -rw-r--r-- | boot/framebuffer.zig | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/boot/framebuffer.zig b/boot/framebuffer.zig new file mode 100644 index 0000000..6518b17 --- /dev/null +++ b/boot/framebuffer.zig @@ -0,0 +1,26 @@ +// linear framebuffer type shi you feel me? +// see: https://wiki.osdev.org/Limine_Bare_Bones + +const limine = @import("limine.zig"); + +pub const Framebuffer = limine.Framebuffer; + +// the request placed in .limine_requests so the loader finds and fills it +// idk why this sounds vaguely erotic, like yeah fill me harder lol +export var request: limine.FramebufferRequest linksection(".limine_requests") = .{}; + +// the response pointer is written by Limine before we run, so read it through a +// volatile pointer or the optimizer assumes it's still null +pub fn get() ?*Framebuffer { + const req: *volatile limine.FramebufferRequest = &request; + const resp = req.response orelse return null; + if (resp.framebuffer_count == 0) return null; + return resp.framebuffers.?[0]; +} + +// assumes the usual Limine RGB 32-bpp layout im sure i wont forget about this layout +// later and i wont fuck me over +pub fn putpixel(fb: *Framebuffer, x: usize, y: usize, color: u32) void { + const pixel: *align(1) u32 = @ptrCast(fb.address + y * fb.pitch + x * 4); + pixel.* = color; +} |
