Skip to content

Commit

Permalink
HALT implementiert
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentadamczyk committed May 31, 2024
1 parent c95a426 commit 381c213
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
2 changes: 0 additions & 2 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub struct CPU {
ime_flag: bool,
/// 0 if nothing to do, 2 if ime needs to be set after next instruction, 1 if ime needs to be set after this instruction
enable_ime: i32,
low_power_mode: bool,
last_execution_time: std::time::Instant,
cycles: u64,
}
Expand All @@ -48,7 +47,6 @@ impl CPU {
last_step_result: InstructionResult::default(),
enable_ime: 0,
ime_flag: false,
low_power_mode: false,
last_execution_time: std::time::Instant::now(),
cycles: 0,
}
Expand Down
47 changes: 32 additions & 15 deletions src/cpu/instructions/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,38 @@ impl CPU {
}

pub fn halt(&mut self) -> InstructionResult {
self.low_power_mode = true;

// Halt bug implementieren oder nicht?
if self.ime_flag {}
//bug einfügen
if self.interrupt_pentding() {}
InstructionResult {
cycles: 0,
bytes: 1,
condition_codes: ConditionCodes {
zero: FlagState::NotAffected,
subtract: FlagState::NotAffected,
half_carry: FlagState::NotAffected,
carry: FlagState::NotAffected,
},
// Halt bug ist noch nicht implementiert. Bug tritt nicht und wird auch nicht behoben.
if self.ime_flag {
if self.check_and_handle_interrupts(){
InstructionResult{
bytes: 1,
cycles: 0,
condition_codes: ConditionCodes{
carry: FlagState::NotAffected,
half_carry: FlagState::NotAffected,
subtract: FlagState::NotAffected,
zero: FlagState::NotAffected,
}
}
}
else{
InstructionResult::default()
}
}
else if self.interrupt_pentding(){
InstructionResult{
bytes: 1,
cycles: 0,
condition_codes: ConditionCodes{
carry: FlagState::NotAffected,
half_carry: FlagState::NotAffected,
subtract: FlagState::NotAffected,
zero: FlagState::NotAffected,
}
}
}
else{
InstructionResult::default()
}
}
}
Expand Down

0 comments on commit 381c213

Please sign in to comment.