Skip to content

Commit 0b8597e

Browse files
committed
Fmt and clean up
1 parent 6e4ca13 commit 0b8597e

4 files changed

Lines changed: 10 additions & 39 deletions

File tree

src/interrupts.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,6 @@ impl InterruptEnableRegister {
138138
let interrupt_enable = InterruptEnableRegister::get_interrupt_enable_register(memory_bus);
139139
interrupt.is_set(interrupt_enable)
140140
}
141-
142-
/// Sets the value of the provided [Interrupt] in the interrupt enable register to the provided
143-
/// value.
144-
pub fn set_flag(memory_bus: &mut MemoryBus, interrupt: Interrupt, value: bool) {
145-
let mut interrupt_enable =
146-
InterruptEnableRegister::get_interrupt_enable_register(memory_bus);
147-
interrupt_enable = if value {
148-
interrupt.set(interrupt_enable)
149-
} else {
150-
interrupt.clear(interrupt_enable)
151-
};
152-
InterruptEnableRegister::set_interrupt_enable_register(memory_bus, interrupt_enable);
153-
}
154141
}
155142

156143
impl InterruptFlagRegister {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl RustBoy {
104104
pub fn new_before_boot(debugging_flags: DebugInfo) -> RustBoy {
105105
RustBoy {
106106
memory_bus: MemoryBus::new_before_boot(&debugging_flags),
107-
ppu: PPU::new_empty(&debugging_flags),
107+
ppu: PPU::new_empty(),
108108
timer_info: TimerInfo::new(),
109109
cpu: CPU::new_before_boot_rom(debugging_flags),
110110
}

src/ppu.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ pub(crate) mod object_handling;
33
pub mod registers;
44
pub(crate) mod tile_handling;
55

6+
use crate::MemoryBus;
67
use crate::cpu::is_bit_set;
7-
use crate::debugging::{DebugInfo, DebuggingFlagsWithoutFileHandles};
88
use crate::interrupts::{Interrupt, InterruptFlagRegister};
99
use crate::ppu::registers::LCDCRegister;
10-
use crate::MemoryBus;
1110
use information_for_shader::BuffersForRendering;
1211
use registers::PPURegisters;
1312

@@ -45,7 +44,6 @@ pub(crate) const PPU_MODE_WHILE_LCD_TURNED_OFF: RenderingMode = RenderingMode::H
4544
pub struct PPU {
4645
pub(crate) rendering_info: RenderingInfo,
4746
pub(crate) buffers_for_rendering: BuffersForRendering,
48-
pub ppu_registers: PPURegisters,
4947
}
5048

5149
/// Struct to collect the information about the current rendering state of the GPU.
@@ -291,13 +289,10 @@ impl PPU {
291289
/// The lcd_was_turned_off flag is set to
292290
/// true, so the GPU starts off in HBlank mode instead of OAMScan, which is the supposed
293291
/// behavior after the LCD was turned on (for the first time or after being turned off).
294-
pub fn new_empty(debugging_flags: &DebugInfo) -> Self {
295-
let debugging_flags =
296-
DebuggingFlagsWithoutFileHandles::from_debugging_flags(debugging_flags);
292+
pub fn new_empty() -> Self {
297293
Self {
298294
rendering_info: RenderingInfo::new_initial_state(),
299295
buffers_for_rendering: BuffersForRendering::new_empty(),
300-
ppu_registers: PPURegisters::new(debugging_flags),
301296
}
302297
}
303298
}

src/ppu/registers.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
use super::{
2-
PPU, PPU_MODE_WHILE_LCD_TURNED_OFF, RenderingMode,
3-
};
1+
use super::{PPU, PPU_MODE_WHILE_LCD_TURNED_OFF, RenderingMode};
42
use crate::cpu::{clear_bit, is_bit_set, set_bit};
53

6-
use crate::debugging::DebuggingFlagsWithoutFileHandles;
7-
use crate::interrupts::{Interrupt, InterruptFlagRegister};
84
use crate::MemoryBus;
5+
use crate::interrupts::{Interrupt, InterruptFlagRegister};
96

107
// Addresses of the GPU registers
118
const LCDC_REGISTER_ADDRESS: usize = 0xFF40;
@@ -37,7 +34,7 @@ const LYC_INT_SELECT_BIT_POSITION: usize = 6;
3734
/// Represents the registers that control the GPU.
3835
///
3936
/// This struct is empty and has no fields. Instead it is just used to group the GPU registers and make
40-
/// the interface nicer. The actual data of the registers is held in the [MemoryBus](crate::MemoryBus).
37+
/// the interface nicer. The actual data of the registers is held in the [MemoryBus](MemoryBus).
4138
///
4239
/// TODO: Explain static function setup
4340
///
@@ -53,12 +50,10 @@ const LYC_INT_SELECT_BIT_POSITION: usize = 6;
5350
/// - 0xFF49: OBP1 - Object Palette 1 Data Register
5451
/// - 0xFF4A: WY - Window Y Position Register
5552
/// - 0xFF4B: WX - Window X Position Register
56-
pub struct PPURegisters {
57-
pub(super) debugging_flags: DebuggingFlagsWithoutFileHandles,
58-
}
53+
pub struct PPURegisters {}
5954

6055
/// Represents the LCDC register of the GPU. This struct is empty and has no fields. Instead, it is
61-
/// just used to make the interface nicer and the actual register is held in the [MemoryBus](crate::MemoryBus).
56+
/// just used to make the interface nicer and the actual register is held in the [MemoryBus](MemoryBus).
6257
///
6358
/// TODO: Explain static function setup
6459
///
@@ -75,7 +70,7 @@ pub struct PPURegisters {
7570
pub struct LCDCRegister {}
7671

7772
/// Represents the LCD status register of the GPU. This struct is empty and has no fields. Instead, it is
78-
/// just used to make the interface nicer and the actual register is held in the [MemoryBus](crate::MemoryBus).
73+
/// just used to make the interface nicer and the actual register is held in the [MemoryBus](MemoryBus).
7974
///
8075
/// TODO: Explain static function setup
8176
///
@@ -136,12 +131,6 @@ impl PPU {
136131
}
137132

138133
impl PPURegisters {
139-
/// Creates a new instance of the GPURegisters struct with all registers set to their default
140-
/// startup values.
141-
pub fn new(debugging_flags: DebuggingFlagsWithoutFileHandles) -> Self {
142-
Self { debugging_flags }
143-
}
144-
145134
/// Set the LCD Control register to the provided value.
146135
///
147136
/// Also sets flags in the provided [super::ChangesToPropagateToShader] struct, to keep track of which parts
@@ -457,7 +446,7 @@ impl LCDCRegister {
457446
}
458447

459448
impl LCDStatusRegister {
460-
/// Returns the GPU mode as a [super::RenderingMode] enum.
449+
/// Returns the GPU mode as a [RenderingMode] enum.
461450
fn get_ppu_mode(memory_bus: &MemoryBus) -> RenderingMode {
462451
RenderingMode::from_u8(memory_bus.memory[LCD_STATUS_REGISTER_ADDRESS] & 0b0000_0011)
463452
}

0 commit comments

Comments
 (0)