Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .zigversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.14
0.15.2
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Build Requirements:
* windows - kernel32

Merge Request (MR) Validation:
* Each MR tested on MacOS Sequia 15.3 / M1 w/zig 0.14 on MacOS Kitty, VS Code, Alacritty.
* Each MR tested on MacOS Sequia 15.3 / M1 w/zig 0.15.2 on MacOS Kitty, VS Code, Alacritty.
* Many MR tested on Windows 10 / Intel, with Microsoft Terminal, CMD.EXE, PowerShell.
* Linux tests are c/o the wonderful community who help identify...and repair...cross platform issues!

Expand All @@ -40,6 +40,7 @@ Start your favorite terminal, maximize it, then launch DOOM-fire-zig! Test your
| VS Code | great | great | poor (20fps) |
| Warp | great? | great | - |
| WezTerm | ? | ? | ok |
| Ghostty | great | great | - |

### Definitions
```
Expand Down Expand Up @@ -143,4 +144,3 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.


10 changes: 6 additions & 4 deletions build.tst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ pub fn build(b: *std.Build) void {

const exe = b.addExecutable(.{
.name = "DOOM-fire",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});

exe.linkLibC();
Expand All @@ -30,7 +32,7 @@ pub fn build(b: *std.Build) void {
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);

const exe_tests = b.addTest(.{ .name = "exe_tests", .root_source_file = b.path("src/main.zig"), .target = target });
const exe_tests = b.addTest(.{ .name = "exe_tests", .root_module = exe.root_module });

const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&exe_tests.step);
Expand Down
8 changes: 5 additions & 3 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ pub fn build(b: *std.Build) void {

const exe = b.addExecutable(.{
.name = "DOOM-fire",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});

//libc linking
Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// Tracks the earliest Zig version that the package considers to be a
// supported use case.
.minimum_zig_version = "0.14.0",
.minimum_zig_version = "0.15.2",

// This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`.
Expand Down
37 changes: 20 additions & 17 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const std = @import("std");

const allocator = std.heap.page_allocator;

var stdout: std.fs.File.Writer = undefined;
var stdin: std.fs.File.Reader = undefined;
var stdout: std.fs.File = undefined;
var stdin: std.fs.File = undefined;
var g_tty_win: win32.HANDLE = undefined;

///////////////////////////////////
Expand Down Expand Up @@ -117,10 +117,14 @@ pub fn emit(s: []const u8) !void {
}
return;
} else {
const sz = try stdout.write(s);
if (sz == 0) {
return;
} // cauze I c
var written: usize = 0;
while (written < s.len) {
const sz = try stdout.write(s[written..]);
if (sz == 0) {
return;
}
written += sz;
}
return;
}
}
Expand Down Expand Up @@ -231,7 +235,7 @@ pub fn getTermSzLinux() !TermSz {
//Linux-MacOS Case

//base case - invoked from cmd line
const tty_nix = stdout.context.handle;
const tty_nix = stdout.handle;
var winsz = std.c.winsize{ .col = 0, .row = 0, .xpixel = 0, .ypixel = 0 };
const rv = std.c.ioctl(tty_nix, TIOCGWINSZ, @intFromPtr(&winsz));
const err = std.posix.errno(rv);
Expand Down Expand Up @@ -338,10 +342,9 @@ pub fn pause() !void {

try emit(color_reset);
try emit("Press return to continue...");
var b: u8 = undefined;
b = stdin.readByte() catch undefined;

if (b == 'q') {
var b: [1]u8 = undefined;
const bytes_read = stdin.read(&b) catch 0;
if (bytes_read == 1 and b[0] == 'q') {
//exit cleanly
try complete();
std.process.exit(0);
Expand Down Expand Up @@ -576,11 +579,11 @@ pub fn scrollMarquee() !void {
try emit(line_clear_to_eol);
try emit(nl);

std.time.sleep(10 * std.time.ns_per_ms);
std.Thread.sleep(10 * std.time.ns_per_ms);
}

//let quote chill for a second
std.time.sleep(1000 * std.time.ns_per_ms);
std.Thread.sleep(1000 * std.time.ns_per_ms);

//fade out
fade_idx = fade_len - 1;
Expand All @@ -598,7 +601,7 @@ pub fn scrollMarquee() !void {
try emit(txt[txt_idx * 2 + 1]);
try emit(line_clear_to_eol);
try emit(nl);
std.time.sleep(10 * std.time.ns_per_ms);
std.Thread.sleep(10 * std.time.ns_per_ms);
}
try emit(nl);
}
Expand Down Expand Up @@ -689,7 +692,7 @@ pub fn paintBuf() !void {
fps = @as(f64, @floatFromInt(bs_frame_tic)) / t_dur;

try emit(fg[0]);
try emitFmt("mem: {s:.2} min / {s:.2} avg / {s:.2} max [ {d:.2} fps ]", .{ std.fmt.fmtIntSizeBin(bs_sz_min), std.fmt.fmtIntSizeBin(bs_sz_avg), std.fmt.fmtIntSizeBin(bs_sz_max), fps });
try emitFmt("mem: {Bi:.2} min / {Bi:.2} avg / {Bi:.2} max [ {d:.2} fps ]", .{ bs_sz_min, bs_sz_avg, bs_sz_max, fps });
}

// initBuf(); defer freeBuf();
Expand Down Expand Up @@ -835,8 +838,8 @@ pub fn showDoomFire() !void {
///////////////////////////////////

pub fn main() anyerror!void {
stdout = std.io.getStdOut().writer();
stdin = std.io.getStdIn().reader();
stdout = std.fs.File.stdout();
stdin = std.fs.File.stdin();

try initTerm();
defer complete() catch {};
Expand Down