some stuff in progress, moving work to desktop
parent
a7f58b3128
commit
d6fc597ffa
@ -0,0 +1 @@
|
||||
# ZING: Z-machine Implementation for ruNning Games
|
@ -0,0 +1,38 @@
|
||||
struct ZChar(u8);
|
||||
struct ZsciiChar(u8);
|
||||
|
||||
struct ZsciiString(Vec<ZsciiChar>);
|
||||
|
||||
/// Returns:
|
||||
/// - a result that wraps a ZsciiString, erroring if the slice terminates before the string ends
|
||||
/// - a usize indicating how many bytes were consumed
|
||||
|
||||
pub fn decode_zchars(zchars: &[u8]) -> Option<(ZsciiString, usize)> {
|
||||
fn cut_string(zchars: &[u8]) -> Option<Vec<u16>> {
|
||||
for (i, word) in zchars.chunks_exact(2).map(|c| u16::from_be_bytes([c[0], c[1]])).enumerate() {
|
||||
}
|
||||
}
|
||||
let zchars = slice_string(zchars);
|
||||
// let mut index: usize = 0;
|
||||
// let mut out = Vec::new();
|
||||
// loop {
|
||||
// let word = u16::from_be_bytes([zchars[index], zchars[index + 1]]);
|
||||
// let end_bit_set = word & 0x8000 != 0;
|
||||
// let chars = [
|
||||
// (word & (0b11111 << 10)) >> 10,
|
||||
// (word & (0b11111 << 5)) >> 5,
|
||||
// (word & (0b11111 << 0)) >> 0,
|
||||
// ].map(|c| ZChar(c as u8));
|
||||
// out.extend(chars);
|
||||
// index += 2;
|
||||
// if index >= zchars.len() - 1 { break (Err(out), index); }
|
||||
// if end_bit_set { break (Ok(out), index); }
|
||||
// // TODO: finish
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/// Returns:
|
||||
pub fn decode_instruction(memory: &[u8], address: usize) {
|
||||
|
||||
}
|
Loading…
Reference in New Issue