Files
meadow/cmd/meadowcli/uxnmin.ha
T
2026-05-14 10:43:19 -04:00

55 lines
1.0 KiB
Hare

use fmt;
use os;
use fs;
use io;
use strings;
use unix;
use unix::poll;
use uxn;
def MAX_CONSOLE_INPUT = 0x1000;
export fn main() void = {
let run = true;
if(len(os::args) < 2){
fmt::printf("usage: %s file.rom [args..]\n")!;
return;
};
let path = os::args[1];
//Setting up pollfds for unix::poll
const consolefd: []unix::poll::pollfd = [unix::poll::pollfd {
fd = os::stdin_file,
events = unix::poll::event::POLLIN,
revents = 0,
} ];
let state: *uxn::uxn = uxn::uxn_init(path)!;
uxn::uxn_reset(state);
uxn::uxn_console_argument(state);
for (run) {
if(state.console_vector != 0){
const pollr: uint = match(unix::poll::poll(consolefd, unix::poll::NONBLOCK)){
case let i: uint =>
yield i;
case =>
yield 0;
};
if(pollr > 0){
// fmt::println("Input!")!;
let buf: [MAX_CONSOLE_INPUT]u8 = [0...];
io::read(os::stdin_file, buf)!;
uxn::console_poll(buf,state);
};
}else{
// nothing left to do...
run = false;
};
if(state.dev[0x0f] != 0) run = false;
};
};