]> code.bitgloo.com Git - clyne/osdev.git/commitdiff
zig fixes main
authorClyne Sullivan <clyne@bitgloo.com>
Thu, 3 Oct 2024 01:00:53 +0000 (21:00 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Thu, 3 Oct 2024 01:00:53 +0000 (21:00 -0400)
src/ziggie.zig

index c6747b9aa79d3873c2b175f4a4db98103c0b1aa7..a986a47b093f644e407ef56a0c8a1778540b794f 100644 (file)
@@ -1,26 +1,24 @@
 pub inline fn outb(port: u16, value: u8) void {
     asm volatile ("outb %[value], %[port]"
 pub inline fn outb(port: u16, value: u8) void {
     asm volatile ("outb %[value], %[port]"
-        :
-        : [port] "N{dx}" (port),
-          [value] "{al}" (value),
+        :: [port] "N{dx}" (port), [value] "{al}" (value),
     );
 }
 
     );
 }
 
+const VGACell = packed struct {
+    char: u8,
+    foreground: u4 = 0xf,
+    background: u4 = 0x0,
+};
+
 const VGATerminal = struct {
     const width = 80;
     const height = 25;
 const VGATerminal = struct {
     const width = 80;
     const height = 25;
-    const vram: *[width * height]u16 = @ptrFromInt(0xB8000);
+    const vram: *[width * height]VGACell = @ptrFromInt(0xB8000);
 
     offset: u16 = 0,
 
     offset: u16 = 0,
-    foreground: u8 = 0x07,
-    background: u8 = 0x00,
 
     pub fn put(self: *VGATerminal, ch: u8) void {
 
     pub fn put(self: *VGATerminal, ch: u8) void {
-        const cell = ch
-            | (@as(u16, self.foreground) << 8)
-            | (@as(u16, self.background) << 12);
-
-        vram[self.offset] = cell;
+        vram[self.offset] = VGACell{ .char = ch };
         self.offset += 1;
     }
 
         self.offset += 1;
     }
 
@@ -35,13 +33,14 @@ const VGATerminal = struct {
 
     pub fn updatecursor(self: VGATerminal) void {
         outb(0x03d4, 0x0f);
 
     pub fn updatecursor(self: VGATerminal) void {
         outb(0x03d4, 0x0f);
-        _ = self;
+        outb(0x03d5, @intCast(self.offset & 0xFF));
+        outb(0x03d4, 0x0e);
+        outb(0x03d5, @intCast(self.offset >> 8));
     }
 };
 
 export fn zigit() void {
     var vga = VGATerminal{};
     }
 };
 
 export fn zigit() void {
     var vga = VGATerminal{};
-    vga.foreground = 0x0f;
     vga.put('H');
     vga.put('i');
     vga.updatecursor();
     vga.put('H');
     vga.put('i');
     vga.updatecursor();