mirror of https://github.com/fairyglade/ly.git
Allow modifying DOOM animation fire colors (closes #239)
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
parent
78d64ad2a7
commit
4e859e56cb
|
@ -101,6 +101,15 @@ console_dev = /dev/console
|
||||||
# Available inputs: info_line, session, login, password
|
# Available inputs: info_line, session, login, password
|
||||||
default_input = login
|
default_input = login
|
||||||
|
|
||||||
|
# DOOM animation top color (low intensity flames)
|
||||||
|
doom_top_color = 0x00FF0000
|
||||||
|
|
||||||
|
# DOOM animation middle color (medium intensity flames)
|
||||||
|
doom_middle_color = 0x00FFFF00
|
||||||
|
|
||||||
|
# DOOM animation bottom color (high intensity flames)
|
||||||
|
doom_bottom_color = 0x00FFFFFF
|
||||||
|
|
||||||
# Error background color id
|
# Error background color id
|
||||||
error_bg = 0x00000000
|
error_bg = 0x00000000
|
||||||
|
|
||||||
|
|
|
@ -5,28 +5,14 @@ const utils = @import("../tui/utils.zig");
|
||||||
|
|
||||||
const Doom = @This();
|
const Doom = @This();
|
||||||
|
|
||||||
pub const STEPS = 13;
|
pub const STEPS = 12;
|
||||||
pub const FIRE = [_]utils.Cell{
|
|
||||||
utils.initCell(' ', 9, 0),
|
|
||||||
utils.initCell(0x2591, 0x00FF0000, 0), // Red
|
|
||||||
utils.initCell(0x2592, 0x00FF0000, 0), // Red
|
|
||||||
utils.initCell(0x2593, 0x00FF0000, 0), // Red
|
|
||||||
utils.initCell(0x2588, 0x00FF0000, 0), // Red
|
|
||||||
utils.initCell(0x2591, 0x00FFFF00, 2), // Yellow
|
|
||||||
utils.initCell(0x2592, 0x00FFFF00, 2), // Yellow
|
|
||||||
utils.initCell(0x2593, 0x00FFFF00, 2), // Yellow
|
|
||||||
utils.initCell(0x2588, 0x00FFFF00, 2), // Yellow
|
|
||||||
utils.initCell(0x2591, 0x00FFFFFF, 4), // White
|
|
||||||
utils.initCell(0x2592, 0x00FFFFFF, 4), // White
|
|
||||||
utils.initCell(0x2593, 0x00FFFFFF, 4), // White
|
|
||||||
utils.initCell(0x2588, 0x00FFFFFF, 4), // White
|
|
||||||
};
|
|
||||||
|
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
terminal_buffer: *TerminalBuffer,
|
terminal_buffer: *TerminalBuffer,
|
||||||
buffer: []u8,
|
buffer: []u8,
|
||||||
|
fire: [STEPS + 1]utils.Cell,
|
||||||
|
|
||||||
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer) !Doom {
|
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer, top_color: u32, middle_color: u32, bottom_color: u32) !Doom {
|
||||||
const buffer = try allocator.alloc(u8, terminal_buffer.width * terminal_buffer.height);
|
const buffer = try allocator.alloc(u8, terminal_buffer.width * terminal_buffer.height);
|
||||||
initBuffer(buffer, terminal_buffer.width);
|
initBuffer(buffer, terminal_buffer.width);
|
||||||
|
|
||||||
|
@ -34,6 +20,21 @@ pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer) !Doom {
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.terminal_buffer = terminal_buffer,
|
.terminal_buffer = terminal_buffer,
|
||||||
.buffer = buffer,
|
.buffer = buffer,
|
||||||
|
.fire = [_]utils.Cell{
|
||||||
|
utils.initCell(' ', 0x00000000, 0),
|
||||||
|
utils.initCell(0x2591, top_color, 0),
|
||||||
|
utils.initCell(0x2592, top_color, 0),
|
||||||
|
utils.initCell(0x2593, top_color, 0),
|
||||||
|
utils.initCell(0x2588, top_color, 0),
|
||||||
|
utils.initCell(0x2591, middle_color, 2),
|
||||||
|
utils.initCell(0x2592, middle_color, 2),
|
||||||
|
utils.initCell(0x2593, middle_color, 2),
|
||||||
|
utils.initCell(0x2588, middle_color, 2),
|
||||||
|
utils.initCell(0x2591, bottom_color, 4),
|
||||||
|
utils.initCell(0x2592, bottom_color, 4),
|
||||||
|
utils.initCell(0x2593, bottom_color, 4),
|
||||||
|
utils.initCell(0x2588, bottom_color, 4),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,16 +63,16 @@ pub fn draw(self: Doom) void {
|
||||||
if (buffer_source < buffer_dest_offset) continue;
|
if (buffer_source < buffer_dest_offset) continue;
|
||||||
|
|
||||||
var buffer_dest = buffer_source - buffer_dest_offset;
|
var buffer_dest = buffer_source - buffer_dest_offset;
|
||||||
if (buffer_dest > 12) buffer_dest = 0;
|
if (buffer_dest > STEPS) buffer_dest = 0;
|
||||||
self.buffer[dest] = @intCast(buffer_dest);
|
self.buffer[dest] = @intCast(buffer_dest);
|
||||||
|
|
||||||
const dest_y = dest / self.terminal_buffer.width;
|
const dest_y = dest / self.terminal_buffer.width;
|
||||||
const dest_x = dest % self.terminal_buffer.width;
|
const dest_x = dest % self.terminal_buffer.width;
|
||||||
utils.putCell(dest_x, dest_y, FIRE[buffer_dest]);
|
utils.putCell(dest_x, dest_y, self.fire[buffer_dest]);
|
||||||
|
|
||||||
const source_y = source / self.terminal_buffer.width;
|
const source_y = source / self.terminal_buffer.width;
|
||||||
const source_x = source % self.terminal_buffer.width;
|
const source_x = source % self.terminal_buffer.width;
|
||||||
utils.putCell(source_x, source_y, FIRE[buffer_source]);
|
utils.putCell(source_x, source_y, self.fire[buffer_source]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,5 +83,5 @@ fn initBuffer(buffer: []u8, width: usize) void {
|
||||||
const slice_end = buffer[length..];
|
const slice_end = buffer[length..];
|
||||||
|
|
||||||
@memset(slice_start, 0);
|
@memset(slice_start, 0);
|
||||||
@memset(slice_end, STEPS - 1);
|
@memset(slice_end, STEPS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,9 @@ colormix_col2: u32 = 0x000000FF,
|
||||||
colormix_col3: u32 = 0x20000000,
|
colormix_col3: u32 = 0x20000000,
|
||||||
console_dev: []const u8 = "/dev/console",
|
console_dev: []const u8 = "/dev/console",
|
||||||
default_input: Input = .login,
|
default_input: Input = .login,
|
||||||
|
doom_top_color: u32 = 0x00FF0000,
|
||||||
|
doom_middle_color: u32 = 0x00FFFF00,
|
||||||
|
doom_bottom_color: u32 = 0x00FFFFFF,
|
||||||
error_bg: u32 = 0x00000000,
|
error_bg: u32 = 0x00000000,
|
||||||
error_fg: u32 = 0x01FF0000,
|
error_fg: u32 = 0x01FF0000,
|
||||||
fg: u32 = 0x00FFFFFF,
|
fg: u32 = 0x00FFFFFF,
|
||||||
|
|
|
@ -337,7 +337,7 @@ pub fn main() !void {
|
||||||
|
|
||||||
switch (config.animation) {
|
switch (config.animation) {
|
||||||
.none => {},
|
.none => {},
|
||||||
.doom => doom = try Doom.init(allocator, &buffer),
|
.doom => doom = try Doom.init(allocator, &buffer, config.doom_top_color, config.doom_middle_color, config.doom_bottom_color),
|
||||||
.matrix => matrix = try Matrix.init(allocator, &buffer, config.cmatrix_fg, config.cmatrix_min_codepoint, config.cmatrix_max_codepoint),
|
.matrix => matrix = try Matrix.init(allocator, &buffer, config.cmatrix_fg, config.cmatrix_min_codepoint, config.cmatrix_max_codepoint),
|
||||||
.colormix => color_mix = ColorMix.init(&buffer, config.colormix_col1, config.colormix_col2, config.colormix_col3),
|
.colormix => color_mix = ColorMix.init(&buffer, config.colormix_col1, config.colormix_col2, config.colormix_col3),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue