Skip to content

Commit 1001414

Browse files
committed
cartridge: rename Orientation to MirrorMode.
1 parent 7172cfd commit 1001414

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

glvs-core/src/cartridge.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ pub const PRG_ROM_SIZE: u16 = 16 * 1024;
1212
pub struct Cartridge {
1313
data: Box<[u8]>,
1414
chr_idx: usize,
15-
nmtable_mirroring: Orientation,
15+
nmtable_mirroring: MirrorMode,
1616
}
1717

1818
#[derive(Debug, Clone, Copy)]
19-
pub enum Orientation {
19+
pub enum MirrorMode {
2020
Horizontal,
2121
Vertical,
2222
}
@@ -57,11 +57,10 @@ impl Cartridge {
5757
return Err(NesError::RomParsing);
5858
}
5959

60-
// TODO: double-check this, it might be swapped.
6160
let nmtable_mirroring = if util::bit(data[6], 0) {
62-
Orientation::Vertical
61+
MirrorMode::Vertical
6362
} else {
64-
Orientation::Horizontal
63+
MirrorMode::Horizontal
6564
};
6665

6766
Ok(Self {
@@ -81,7 +80,7 @@ impl Cartridge {
8180
&self.data[HEADER_SIZE..self.chr_idx]
8281
}
8382

84-
pub fn nmtable_mirroring(&self) -> Orientation {
83+
pub fn nmtable_mirroring(&self) -> MirrorMode {
8584
self.nmtable_mirroring
8685
}
8786

@@ -92,7 +91,7 @@ impl Cartridge {
9291
alloc::vec![0; HEADER_SIZE + usize::from(PRG_ROM_SIZE) + usize::from(CHR_ROM_SIZE)]
9392
.into_boxed_slice(),
9493
chr_idx: 0,
95-
nmtable_mirroring: Orientation::Horizontal,
94+
nmtable_mirroring: MirrorMode::Horizontal,
9695
}
9796
}
9897
}

glvs-core/src/ppu.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use core::ops::{Index, IndexMut};
99

1010
use arbitrary_int::{u3, u5};
1111

12-
use crate::cartridge::{CHR_ROM_SIZE, Cartridge, Orientation};
12+
use crate::cartridge::{CHR_ROM_SIZE, Cartridge, MirrorMode};
1313
use crate::ppu::registers::{CtrlBits, Loopy, MaskBits, StatusBits};
1414
use crate::ppu::video::{COLORS, Rgb8};
1515
use crate::util;
@@ -31,7 +31,7 @@ pub struct Ppu {
3131
regs: Registers,
3232
data_buffer: u8,
3333
second_write: bool,
34-
nmtable_mirroring: Orientation,
34+
nmtable_mirroring: MirrorMode,
3535
scanline: u32,
3636
dot: u32,
3737
odd_frame: bool,
@@ -664,7 +664,7 @@ impl Ppu {
664664
}
665665

666666
/// Returns (name table 0 or 1, address of cell inside the name table).
667-
fn nmtable_indices(mirroring: Orientation, addr: u16) -> (usize, usize) {
667+
fn nmtable_indices(mirroring: MirrorMode, addr: u16) -> (usize, usize) {
668668
const TABLE_1_START: u16 = 0x2000;
669669
const TABLE_2_START: u16 = 0x2400;
670670
const TABLE_3_START: u16 = 0x2800;
@@ -675,15 +675,15 @@ fn nmtable_indices(mirroring: Orientation, addr: u16) -> (usize, usize) {
675675
TABLE_1_START..TABLE_2_START => (0, usize::from(addr - TABLE_1_START)),
676676
TABLE_2_START..TABLE_3_START => (
677677
match mirroring {
678-
Orientation::Horizontal => 0,
679-
Orientation::Vertical => 1,
678+
MirrorMode::Horizontal => 0,
679+
MirrorMode::Vertical => 1,
680680
},
681681
usize::from(addr - TABLE_2_START),
682682
),
683683
TABLE_3_START..TABLE_4_START => (
684684
match mirroring {
685-
Orientation::Horizontal => 1,
686-
Orientation::Vertical => 0,
685+
MirrorMode::Horizontal => 1,
686+
MirrorMode::Vertical => 0,
687687
},
688688
usize::from(addr - TABLE_3_START),
689689
),

0 commit comments

Comments
 (0)