Fixed console input, Left works now to load files

This commit is contained in:
JJ Bliss
2026-05-08 15:20:57 -04:00
parent 9c60296d21
commit be55c2be5e
3 changed files with 87 additions and 39 deletions
+43
View File
@@ -952,5 +952,48 @@ export fn uxn_init(path: str) ( *uxn | error ) = {
};
export fn uxn_reset(state: *uxn) void = {
state.running = true;
const args = os::args[2..];
const argcount = len(args): u8;
if(argcount > 0){
state.dev[0x17] = 1;
}else {
state.dev[0x17] = 0;
};
uxn_eval(reset_vector,state)!;
state.dev[0x17] = 0;
};
export fn uxn_console_argument(state: *uxn) void = {
// fmt::printf("Evaluating console arguments")!;
let args = os::args[2..];
let i: u8 = 0;
let argcount = len(args): u8;
for (let arg .. args){
// fmt::println("Console input args")!;
for(let char: u8 .. strings::toutf8(arg)){
// fmt::printfln("Console input arg char: {}", char: rune)!;
match (console_input(char,2,state)) {
case done =>
yield done;
case let val: u8 =>
fmt::fatalf("Unhandled Opcode: {:x}", val);
case =>
yield done;
};
};
let ctype: u8 = if(i == (argcount - 1)){
yield 4;
} else {
yield 3;
};
match (console_input('\n',ctype,state)) {
case done =>
yield done;
case let val: u8 =>
fmt::fatalf("Unhandled Opcode: {:x}", val);
case =>
yield done;
};
i+=1; //TODO using i here seems inelegant
};
};