-
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
148bb6d
commit 010f9a0
Showing
4 changed files
with
117 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
pub struct BGPI { | ||
pub address: u8, | ||
pub auto_increment: bool | ||
} | ||
|
||
impl BGPI { | ||
pub fn new() -> Self { | ||
Self { | ||
address: 0, | ||
auto_increment: false | ||
} | ||
} | ||
|
||
pub fn read(&self) -> u8 { | ||
let a = if self.auto_increment { | ||
0x80 | ||
} else { | ||
0x00 | ||
}; | ||
a | self.address | ||
} | ||
|
||
pub fn write(&mut self, v: u8) { | ||
self.auto_increment = v & 0x80 != 0x00; | ||
self.address = v & 0x3F; | ||
} | ||
} |
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 ppu; | ||
mod cc; | ||
mod cc; | ||
mod bgpi; | ||
mod structs; |
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,66 @@ | ||
use bitflags::bitflags; | ||
|
||
#[derive(PartialEq, Copy, Clone)] | ||
pub enum Priority { | ||
Color0, | ||
Priority, | ||
Normal, | ||
} | ||
|
||
#[derive(PartialEq, Copy, Clone)] | ||
pub enum PPUMode { | ||
OAMScan = 2, | ||
Draw = 3, | ||
HBlank = 0, | ||
VBlank = 1, | ||
} | ||
|
||
bitflags! { | ||
#[derive(PartialEq, Copy, Clone)] | ||
pub struct Attributes: u8 { | ||
const PRIORITY = 0b1000_0000; | ||
const Y_FLIP = 0b0100_0000; | ||
const X_FLIP = 0b0010_0000; | ||
const PALETTE_NO_0 = 0b0001_0000; | ||
const BANK = 0b0000_1000; | ||
} | ||
} | ||
|
||
bitflags! { | ||
#[derive(PartialEq, Copy, Clone)] | ||
pub struct LCDC: u8 { | ||
// LCD & PPU enable: 0 = Off; 1 = On | ||
const LCD_ENABLE = 0b1000_0000; | ||
// Window tile map area: 0 = 9800–9BFF; 1 = 9C00–9FFF | ||
const WINDOW_AREA = 0b0100_0000; | ||
// Window enable: 0 = Off; 1 = On | ||
const WINDOW_ENABLE = 0b0010_0000; | ||
// BG & Window tile data area: 0 = 8800–97FF; 1 = 8000–8FFF | ||
const TILE_DATA_AREA = 0b0001_0000; | ||
// BG tile map area: 0 = 9800–9BFF; 1 = 9C00–9FFF | ||
const BG_TILE_MAP_AREA = 0b0000_1000; | ||
// OBJ size: 0 = 8×8; 1 = 8×16 | ||
const OBJ_SIZE = 0b0000_0100; | ||
// OBJ enable: 0 = Off; 1 = On | ||
const OBJ_ENABLE = 0b0000_0010; | ||
// BG & Window enable (GB) / priority (CGB): 0 = Off; 1 = On | ||
const WINDOW_PRIORITY = 0b0000_0001; | ||
} | ||
} | ||
|
||
bitflags! { | ||
#[derive(PartialEq, Copy, Clone)] | ||
pub struct LCDS: u8 { | ||
// LYC int select (Read/Write): If set, selects the LYC == LY condition for the STAT interrupt. | ||
const LYC_SELECT = 0b0100_0000; | ||
// Mode 2 int select (Read/Write): If set, selects the Mode 2 condition for the STAT interrupt. | ||
const MODE_2_SELECT = 0b0010_0000; | ||
// Mode 1 int select (Read/Write): If set, selects the Mode 1 condition for the STAT interrupt. | ||
const MODE_1_SELECT = 0b0001_0000; | ||
// Mode 0 int select (Read/Write): If set, selects the Mode 0 condition for the STAT interrupt. | ||
const MODE_0_SELECT = 0b0000_1000; | ||
// LYC == LY (Read-only): Set when LY contains the same value as LYC; it is constantly updated. | ||
const LYC_EQUALS = 0b0000_0100; | ||
// PPU mode (Read-only): Indicates the PPU’s current status. | ||
} | ||
} |