Compare commits
No commits in common. "738b1da85bf981ba985a8ed76a2aafd1fed97402" and "c3a73e3104447757942a53a440e68a3a0872f8ce" have entirely different histories.
738b1da85b
...
c3a73e3104
2 changed files with 8 additions and 40 deletions
|
@ -1,25 +0,0 @@
|
|||
(decimal printer)
|
||||
o
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
o
|
||||
(check if 0)
|
||||
v B-=-#01 <
|
||||
v * D-(div/10)
|
||||
v B * <
|
||||
o
|
||||
v> * 1 ^
|
||||
F -R0* B(next digit, %10)
|
||||
*| # <-A vo(+48 = ascii)
|
||||
| #84 <
|
||||
| *-|
|
||||
F +B * B
|
||||
#< \F----
|
||||
|
||||
*-|
|
||||
P-
|
||||
B
|
19
src/main.rs
19
src/main.rs
|
@ -1,8 +1,4 @@
|
|||
use std::{
|
||||
env, fs,
|
||||
io::{stdin, stdout, Write},
|
||||
process::exit,
|
||||
};
|
||||
use std::{env, fs, io::{stdin, stdout, Write}, process::exit};
|
||||
|
||||
use owo_colors::OwoColorize;
|
||||
|
||||
|
@ -104,6 +100,7 @@ fn main() {
|
|||
.unwrap_or_default();
|
||||
|
||||
let mut interpreter = Machine::new(&source, input_data);
|
||||
print!("\x1B[2J"); // clear screen
|
||||
interpreter.show();
|
||||
|
||||
loop {
|
||||
|
@ -142,12 +139,7 @@ q | quit | exit
|
|||
["dbg" | "debug"] => {
|
||||
dbg!(&interpreter);
|
||||
}
|
||||
["step", num] => {
|
||||
if let Ok(n) = num.parse() {
|
||||
interpreter.step(n);
|
||||
interpreter.show();
|
||||
}
|
||||
}
|
||||
["step", num] => _ = num.parse().map(|n| interpreter.step(n)),
|
||||
["q" | "exit" | "quit"] => break,
|
||||
["h" | "help" | "?"] => {
|
||||
println!("{}", HELP_TEXT.green());
|
||||
|
@ -178,8 +170,9 @@ impl Machine {
|
|||
}
|
||||
|
||||
fn show(&self) {
|
||||
// dbg!(&self);
|
||||
print!("\x1B[2J"); // clear screen
|
||||
print!("\x1B[1;1H"); // reset cursor
|
||||
print!("\x1B[u"); // reset cursor
|
||||
for y in 0..self.grid.height() {
|
||||
let mut marbles_on_row = Vec::new();
|
||||
for x in 0..self.grid.width() {
|
||||
|
@ -430,7 +423,7 @@ impl Machine {
|
|||
MathOp::Div => val_a.checked_div(val_b).unwrap_or_default(),
|
||||
MathOp::Rem => val_a.checked_rem(val_b).unwrap_or_default(),
|
||||
};
|
||||
// println!("{op:?} a:{val_a} b:{val_b}");
|
||||
println!("{op:?} a:{val_a} b:{val_b}");
|
||||
*self.grid.get_mut(front_pos) = Tile::Marble { value: result, dir };
|
||||
self.marbles.push(front_pos);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue