Skip to content

Commit

Permalink
implement FX33
Browse files Browse the repository at this point in the history
  • Loading branch information
gthvn1 committed Apr 29, 2024
1 parent 532b8c2 commit 6c65df7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## 2024-04-27
- Implement FX33 - BCD
- Implement 2NNN - CALL addr
- Fixes issues for printing IBM logo
- Framebuffer is now part of the chip8
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## What?
- Another *chip8* emulator in rust
- Only instructions used to display IBM logo are implemented
- Next to implement for pong is `0xfe33`
- Next to implement for pong is `fX65`
- To run it: `cargo run --bin emulator chip8-roms/IBM_logo.ch8`
- To debug prepend `RUST_LOG=debug`
- [Changelog](https://github.com/gthvn1/chip8-emulator/blob/master/Changelog.md)
Expand Down
11 changes: 10 additions & 1 deletion src/chip8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,16 @@ impl Chip8 {
self.mem[DISPLAY_OFFSET..(DISPLAY_OFFSET + DISPLAY_SIZE)].copy_from_slice(&fb_copy);
}
0xE => return Err(Chip8Error::NotImplemented(opcode)),
0xF => return Err(Chip8Error::NotImplemented(opcode)),
0xF => match opcode.nn() {
0x33 => {
let vx = self.vregs[opcode.x() as usize];
let idx = self.i as usize;
self.mem[idx] = ((vx / 100) % 10) as u8; // hundreds digit
self.mem[idx + 1] = ((vx / 10) % 10) as u8; // tens digit
self.mem[idx + 2] = (vx % 10) as u8; // ones digit
}
_ => return Err(Chip8Error::NotImplemented(opcode)),
},
_ => {
return Err(Chip8Error::UnknownOpcode(opcode));
}
Expand Down

0 comments on commit 6c65df7

Please sign in to comment.