mirror of
https://github.com/RGBCube/DOOM-fire-zig
synced 2025-07-28 09:37:44 +00:00
Cross platform update -- merge branch 'JacobHin2-jacobhin2'
This commit is contained in:
commit
3f80a338f7
3 changed files with 16 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
# DOOMFIRE
|
||||
Test your TTY might!
|
||||
## Test your TTY's might!
|
||||
|
||||

|
||||
|
||||
|
@ -8,7 +8,11 @@ The doom-fire algo can push upwards of 180k a frame - results may vary! It is,
|
|||
As a comparable, this is the younger sibling of a node variant ( https://github.com/const-void/DOOM-fire-node ).
|
||||
|
||||
# INSTALL
|
||||
Tested on OX Monterey / M1 w/zig 0.9...unsure if it will work on Win or Linux, sadly, due to TIOCGWINSZ flag. No third party dependencies!
|
||||
Tested on OX Monterey / M1 w/zig 0.9...
|
||||
|
||||
EDIT: Now tested on Artix Linux - links against libc to get the size of the TTY.
|
||||
|
||||
This means that the program does rely on libc, this shouldn't be a problem.
|
||||
|
||||
```
|
||||
$ git clone https://github.com/const-void/DOOM-fire-zig/
|
||||
|
@ -22,6 +26,7 @@ $ zig build run
|
|||
* kitty.app - great
|
||||
* Terminal.app - poor -- seems to drop framerates
|
||||
* VS Code - great
|
||||
* Alacritty (artix linux) - great
|
||||
|
||||
# Inspiration / Credits
|
||||
* doom fire - https://github.com/filipedeschamps/doom-fire-algorithm, https://github.com/fabiensanglard/DoomFirePSX/blob/master/flames.html
|
||||
|
|
|
@ -12,6 +12,8 @@ pub fn build(b: *std.build.Builder) void {
|
|||
const mode = b.standardReleaseOptions();
|
||||
|
||||
const exe = b.addExecutable("DOOM-fire", "src/main.zig");
|
||||
|
||||
exe.linkLibC();
|
||||
exe.setTarget(target);
|
||||
exe.setBuildMode(mode);
|
||||
exe.install();
|
||||
|
|
11
src/main.zig
11
src/main.zig
|
@ -4,6 +4,9 @@
|
|||
// Copy/paste as it helps!
|
||||
//
|
||||
const std = @import("std");
|
||||
const c = @cImport({
|
||||
@cInclude("sys/ioctl.h");
|
||||
});
|
||||
|
||||
const allocator = std.heap.page_allocator;
|
||||
|
||||
|
@ -11,7 +14,7 @@ const stdout = std.io.getStdOut().writer();
|
|||
const stdin = std.io.getStdIn().reader();
|
||||
|
||||
///////////////////////////////////
|
||||
// Tested on M1 osx12.1
|
||||
// Tested on M1 osx12.1 + Artix Linux.
|
||||
// fast - vs code terminal
|
||||
// slow - Terminal.app
|
||||
///////////////////////////////////
|
||||
|
@ -79,8 +82,8 @@ pub fn emitFmt(comptime s: []const u8, args: anytype) void {
|
|||
|
||||
//// Settings
|
||||
|
||||
//OSX specific ... maybe
|
||||
const TIOCGWINSZ = 0x40087468; //ioctl flag
|
||||
// Get this value from libc.
|
||||
const TIOCGWINSZ = c.TIOCGWINSZ; // ioctl flag
|
||||
|
||||
//term size
|
||||
const TermSz = struct { height: usize, width: usize };
|
||||
|
@ -143,7 +146,7 @@ pub fn initColor() void {
|
|||
|
||||
//get terminal size given a tty
|
||||
pub fn getTermSz(tty: std.os.fd_t) !TermSz {
|
||||
var winsz = std.os.system.winsize{ .ws_col = 0, .ws_row = 0, .ws_xpixel = 0, .ws_ypixel = 0 };
|
||||
var winsz = c.winsize{ .ws_col = 0, .ws_row = 0, .ws_xpixel = 0, .ws_ypixel = 0 };
|
||||
const rv = std.os.system.ioctl(tty, TIOCGWINSZ, @ptrToInt(&winsz));
|
||||
const err = std.os.errno(rv);
|
||||
if (rv == 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue