Anonymous user
Zig Bare Bones: Difference between revisions
Jump to navigation
Jump to search
no edit summary
[unchecked revision] | [unchecked revision] |
No edit summary |
No edit summary |
||
Line 152:
LightMagenta = 13,
LightBrown = 14,
White = 15,
};
Line 163:
return @enumToInt(fg) | (@enumToInt(bg) << 4);
}
fn vgaEntry(uc: u8, new_color: u8) u16 {
var c: u16 = new_color;
return uc | (c << 8);
}
Line 182 ⟶ 183:
pub fn putCharAt(c: u8, new_color: u8, x: usize, y: usize) void {
const index
buffer[index] = vgaEntry(c, new_color);
}
Line 188 ⟶ 189:
pub fn putChar(c: u8) void {
putCharAt(c, color, column, row);
column += 1;
if (column == VGA_WIDTH) {
column = 0;
row += 1;
if (row == VGA_HEIGHT)
row = 0;
Line 196 ⟶ 199:
pub fn puts(data: []const u8) void {
for (data) |
putChar(
}
pub const writer = Writer(void, error{}, callback){ .context = {} };
fn callback(_: void, string: []const u8) error{}!usize {
puts(string);
return string.len;
}
pub fn printf(comptime format: []const u8, args: anytype) void {
▲ puts(fmt.bufPrint(&buf, format, args) catch unreachable);
}
</source>
|