Reduce dependence on tb_cell and tb_cell_buffer()

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2024-08-05 11:08:51 +02:00
parent 071b7a2182
commit 2c428f5537
5 changed files with 44 additions and 29 deletions

View File

@@ -9,7 +9,7 @@ const termbox = interop.termbox;
const Doom = @This();
pub const STEPS = 13;
pub const FIRE = [_]termbox.tb_cell{
pub const FIRE = [_]utils.Cell{
utils.initCell(' ', 9, 0),
utils.initCell(0x2591, 2, 0), // Red
utils.initCell(0x2592, 2, 0), // Red
@@ -68,8 +68,8 @@ pub fn draw(self: Doom) void {
if (buffer_dest > 12) buffer_dest = 0;
self.buffer[dest] = @intCast(buffer_dest);
self.terminal_buffer.buffer[dest] = FIRE[buffer_dest];
self.terminal_buffer.buffer[source] = FIRE[buffer_source];
self.terminal_buffer.buffer[dest] = toTermboxCell(FIRE[buffer_dest]);
self.terminal_buffer.buffer[source] = toTermboxCell(FIRE[buffer_source]);
}
}
}
@@ -82,3 +82,11 @@ fn initBuffer(buffer: []u8, width: usize) void {
@memset(slice_start, 0);
@memset(slice_end, STEPS - 1);
}
fn toTermboxCell(cell: utils.Cell) termbox.tb_cell {
return .{
.ch = cell.ch,
.fg = cell.fg,
.bg = cell.bg,
};
}