Fixed a scrolling bug, added C-style comments to Forge

This commit is contained in:
2024-05-12 23:48:47 -05:00
parent b7ce04d245
commit bd54ae1ef0
3 changed files with 16 additions and 2 deletions
@@ -33,4 +33,18 @@ mod test {
]
)
}
#[test]
fn parse_comments() {
// No other good place to put this test...
let prog = Program::from_str("global /* I am a comment */ foo; const blah = 3; // also a comment").unwrap();
let decls: Vec<_> = dislocate(prog.0);
assert_eq!(
decls,
vec![
Declaration::from_str("global foo;").unwrap(),
Declaration::from_str("const blah = 3;").unwrap(),
]
)
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
// C++-style whitespace and comments
WHITESPACE = _{ " " | "\t" | NEWLINE }
COMMENT = _{ "//" ~ (!"\n" ~ ANY)* }
COMMENT = _{ ("//" ~ (!"\n" ~ ANY)*) | ("/*" ~ (!"*/" ~ ANY)* ~ "*/") }
// C-style names
name_char = { ASCII_ALPHA_LOWER | ASCII_ALPHA_UPPER | "_" | "$" }
+1 -1
View File
@@ -92,7 +92,7 @@ fn init_palette<P: PeekPoke>(machine: &mut P) {
}
fn to_byte_address((x, y): (Word, Word), reg: DisplayRegisters) -> Word {
let row_start = (y + reg.row_offset % reg.height) * reg.width + reg.screen;
let row_start = ((y + reg.row_offset) % reg.height) * reg.width + reg.screen;
((x + reg.col_offset) % reg.width) + row_start
}