-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start implementing NES2 file type + refactor * Refactor... * Remove unused funcs
- Loading branch information
1 parent
4d78bd4
commit 78fea93
Showing
19 changed files
with
317 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#[derive(thiserror::Error, Debug)] | ||
pub enum NesRomReadError { | ||
#[error("file format not supported")] | ||
FileFormatNotSupported, | ||
|
||
#[error("missing magic bytes")] | ||
MissingMagicBytes, | ||
|
||
#[error("missing prg rom")] | ||
MissingPrgRom, | ||
} |
21 changes: 0 additions & 21 deletions
21
emulator/src/cartridge/common/enums.rs → ...r/src/cartridge/common/enums/mirroring.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub mod mirroring; | ||
|
||
pub mod errors; | ||
pub mod nes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::fmt::Debug; | ||
|
||
pub enum Nes { | ||
Ines, | ||
Nes2, | ||
} | ||
|
||
impl Debug for Nes { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Nes::Ines => write!(f, "Ines"), | ||
Nes::Nes2 => write!(f, "Nes2"), | ||
} | ||
} | ||
} | ||
|
||
impl PartialEq for Nes { | ||
fn eq(&self, other: &Self) -> bool { | ||
matches!( | ||
(self, other), | ||
(Nes::Ines, Nes::Ines) | (Nes::Nes2, Nes::Nes2) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pub mod consts; | ||
pub mod enums; | ||
pub mod traits; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use crate::cartridge::registers::chr_rom::ChrRom; | ||
use crate::cartridge::registers::prg_rom::PrgRom; | ||
|
||
pub trait CartridgeData { | ||
fn prg_rom(&self) -> &PrgRom; | ||
fn chr_rom(&self) -> &ChrRom; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use std::path::Path; | ||
|
||
pub trait FileLoadable { | ||
fn from_file<P: AsRef<Path>>(path: P) -> anyhow::Result<Self> | ||
where | ||
Self: Sized; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod cartridge_data; | ||
pub mod file_loadable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod file; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.