-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95c8ec8
commit 4e07010
Showing
4 changed files
with
54 additions
and
51 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
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 enum GBMode { | ||
Classic, | ||
Color, | ||
} |
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,46 @@ | ||
use bitflags::{bitflags}; | ||
use crate::mode::GBMode; | ||
|
||
pub struct Registers { | ||
a: u8, | ||
f: Flags, | ||
b: u8, | ||
c: u8, | ||
d: u8, | ||
e: u8, | ||
h: u8, | ||
l: u8, | ||
pc: u16, | ||
sp: u16, | ||
} | ||
|
||
bitflags! { | ||
pub struct Flags: u8 { | ||
const C = 0b00010000; | ||
const H = 0b00100000; | ||
const N = 0b01000000; | ||
const Z = 0b10000000; | ||
} | ||
} | ||
|
||
impl Registers { | ||
pub fn new(mode: GBMode) -> Registers { | ||
match mode { | ||
GBMode::Classic => { | ||
Registers { | ||
a: 0x01, | ||
f: Flags::C | Flags::H | Flags::Z, | ||
b: 0x00, | ||
c: 0x13, | ||
d: 0x00, | ||
e: 0xD8, | ||
h: 0x01, | ||
l: 0x4D, | ||
pc: 0x0100, | ||
sp: 0xFFFE | ||
} | ||
}, | ||
_ => panic!("Mode not yet supported!") | ||
} | ||
} | ||
} |