Skip to content

Commit

Permalink
Merge pull request #6 from mlund/bitwise_operations
Browse files Browse the repository at this point in the history
Add AND, OR, and XOR options for poke command
  • Loading branch information
mlund committed Jan 18, 2024
2 parents ade6a5a + 969437d commit 1d9d5a8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ultimate64 run skate_or_die.prg # load and run PRG file
ultimate64 load sprites.dat --address 0x2000 # load data to memory
ultimate65 peek 0x1000 --dasm -n 32 # disassemble 32 bytes
ultimate65 poke 0xd020 3 # write single byte
ultimate65 poke 0xd016 0b0000_1100 --xor # bitwise operations
ultimate64 sidplay yie_ar_kung_fu.sid -n 2 # play SID tune
ultimate64 modplay enigma.mod # play Amiga MOD tune
~~~
Expand All @@ -52,10 +53,12 @@ Addresses can be hexadecimal (`0x1000`) or decimal (`4096`).
- [x] World class memory safety due to Rust
- [x] Excellent error handling and error messages
- [x] Convenient decimal, hexadecimal and binary input
- [x] Bitwise logical operations for POKE
- [x] 6502 disassembly
- [x] Load address detection
- [x] Precompiled binaries for MacOS, Linux, and Windows

## Todo

- [ ] Disk image and file manipulation
- [ ] Memory bank switching for RAM access
26 changes: 25 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ enum Commands {
/// Value to write, e.g. `16`, `0x10` or `0b0001_0000`
#[arg(value_parser = parse::<u8>)]
value: u8,
/// Bitwise AND with existing value
#[clap(long = "and", action, conflicts_with = "bitwise_or")]
bitwise_and: bool,
/// Bitwise OR with existing value
#[clap(long = "or", action, conflicts_with = "bitwise_and")]
bitwise_or: bool,
/// Bitwise XOR with existing value
#[clap(long = "xor", action, conflicts_with = "bitwise_and")]
bitwise_xor: bool,
},
/// Power off machine
Poweroff,
Expand Down Expand Up @@ -184,7 +193,22 @@ fn do_main() -> Result<()> {
println!("{:x?}", data);
}
}
Commands::Poke { address, value } => {
Commands::Poke {
address,
value,
bitwise_and,
bitwise_or,
bitwise_xor,
} => {
let value = if bitwise_and {
ultimate.read_mem(address, 1)?[0] & value
} else if bitwise_or {
ultimate.read_mem(address, 1)?[0] | value
} else if bitwise_xor {
ultimate.read_mem(address, 1)?[0] ^ value
} else {
value
};
ultimate.write_mem(address, &[value])?;
}
Commands::Reboot => {
Expand Down

0 comments on commit 1d9d5a8

Please sign in to comment.