Skip to content

Commit

Permalink
Merge branch 'main' of github.com:HAW-Rust-SoSe24/gb_emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnsAnns committed Jun 13, 2024
2 parents 87fe71d + 4c36a03 commit 7807937
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ pub struct CPU {
last_execution_time: std::time::Instant,
cycles: u64,
stop_mode: bool,
pub instruction: i32,

}

/// Note, please look at the relevant modules for the actual implementations
Expand All @@ -53,6 +55,7 @@ impl CPU {
last_execution_time: std::time::Instant::now(),
cycles: 0,
stop_mode: false,
instruction: 0,
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/cpu/instructions/jumps_subroutines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ impl CPU {
}
/// Enables interrupts and pops PC from the stack, returning to the last pushed instruction
pub fn reti(&mut self) -> InstructionResult {
self.ei();
// self.ei(); Der Ei aufruf funktioniert hier nicht, da unser superloop nicht durhclaufen wird und
// somit die Cycels nicht aktualisiert werden. D.H. EI aktualsiert das IME flag zu spät. ==>
// direkt IME Flag setzen oder enable ime flag = 1 d.h. nach dieser Instruction
self.ime_flag = true;
self.pop_r16(Register16Bit::PC);

InstructionResult {
Expand Down
1 change: 1 addition & 0 deletions src/cpu/instructions/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl CPU {
/// deactivates the IME flag, enabling Interrupts
pub fn di(&mut self) -> InstructionResult {
self.ime_flag = false;
self.enable_ime = 0;
InstructionResult {
cycles: 1,
bytes: 1,
Expand Down
7 changes: 6 additions & 1 deletion src/cpu/step.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use core::task;
use std::{thread::sleep, time::Duration};

use crate::cpu::instructions::ConditionCodes;

use super::{
instructions::{FlagState, InstParam, InstructionCondition, InstructionResult, Instructions},
registers::{self, Register16Bit, Register8Bit},
Expand Down Expand Up @@ -389,7 +391,10 @@ impl CPU {
_ => return Err(format!("Handling of {:?} not implemented", target)),
},
Instructions::RET(condition) => match condition {
InstParam::ConditionCodes(cond) => self.ret_cc(self.check_condition(cond)),
InstParam::ConditionCodes(cond) => match cond{
InstructionCondition::SkipConditionCodes => self.ret(),
_ => self.ret_cc(self.check_condition(cond)),
}
_ => self.ret(),
},
Instructions::RETI => self.reti(),
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const DOTS_PER_LINE: u32 = 456;
const TIME_PER_FRAME: f32 = 1.0 / 60.0 * 1000.0;

const DUMP_GAMEBOY_DOCTOR_LOG: bool = true;
const WINDOWS: bool = false;
const WINDOWS: bool = true;

#[macroquad::main("GB Emulator")]
async fn main() {
Expand Down

0 comments on commit 7807937

Please sign in to comment.