[ref] Simple constant out
This commit is contained in:
@@ -61,6 +61,7 @@ impl Device {
|
||||
0xF0, 0x80, 0xF0, 0x80, 0x80 // F
|
||||
];
|
||||
const FONT_DEFAULT_MEM_LOCATION_START: usize = 0x50;
|
||||
const FONT_HEIGHT: u16 = 5;
|
||||
const FONT_DEFAULT_MEM_LOCATION_END: usize = 0x9F;
|
||||
const ROM_START: usize = 0x200;
|
||||
pub fn cycle(&mut self) -> EmulatorResult<()> {
|
||||
@@ -238,8 +239,7 @@ impl Device {
|
||||
}
|
||||
Instruction::SetIndexToFontCharacter(x) => {
|
||||
let requested_char = self.registers.v[x];
|
||||
// TODO extract 5 to constant
|
||||
let font_address = Self::FONT_DEFAULT_MEM_LOCATION_START as u16 + 5 * requested_char as u16;
|
||||
let font_address = Self::FONT_DEFAULT_MEM_LOCATION_START as u16 + Self::FONT_HEIGHT * requested_char as u16;
|
||||
self.registers.i = font_address;
|
||||
}
|
||||
Instruction::DoBCDConversion(x) => {
|
||||
@@ -250,8 +250,10 @@ impl Device {
|
||||
binary_value_to_decode_temp /= 10;
|
||||
let hundreds_digit = binary_value_to_decode_temp % 10;
|
||||
binary_value_to_decode_temp /= 10;
|
||||
|
||||
// If this fails, something has gone truly wrong
|
||||
assert_eq!(0, binary_value_to_decode_temp);
|
||||
|
||||
let val = [hundreds_digit, tens_digit, unit_digit];
|
||||
let index = self.registers.i as usize;
|
||||
self.memory[index..(index + 3)].copy_from_slice(&val);
|
||||
|
Reference in New Issue
Block a user