forked from Lea/invadeez
16 lines
521 B
Rust
16 lines
521 B
Rust
use crate::{EmulatorState, Register, get_register};
|
|
|
|
/// Sets the condition code flags according to `result`
|
|
fn set_cc(state: &mut EmulatorState, result: u16) {
|
|
state.cc.z = (result & 0xff) == 0;
|
|
state.cc.s = (result & 0x80) == 1;
|
|
state.cc.c = result > 0xff;
|
|
state.cc.p = (result & 0xff).count_ones() % 2 == 0;
|
|
}
|
|
|
|
pub fn add(register: Register, state: &mut EmulatorState) {
|
|
let result = get_register(register, state) + state.a as u16;
|
|
set_cc(state, result);
|
|
state.a = (result & 0xff) as u8;
|
|
}
|