mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Do all the video modes
This commit is contained in:
parent
ce5641f5ef
commit
5ac408d414
|
@ -4,19 +4,23 @@ use super::{
|
|||
set_graphics_mode, set_graphics_settings, DisplayMode, GraphicsSettings, HEIGHT, WIDTH,
|
||||
};
|
||||
|
||||
use core::convert::TryInto;
|
||||
use core::{convert::TryInto, marker::PhantomData};
|
||||
|
||||
const BITMAP_MODE_3: MemoryMapped2DArray<u16, { WIDTH as usize }, { HEIGHT as usize }> =
|
||||
unsafe { MemoryMapped2DArray::new(0x600_0000) };
|
||||
|
||||
#[non_exhaustive]
|
||||
pub struct Bitmap3 {}
|
||||
pub struct Bitmap3<'gba> {
|
||||
phantom: PhantomData<&'gba ()>,
|
||||
}
|
||||
|
||||
impl Bitmap3 {
|
||||
impl Bitmap3<'_> {
|
||||
pub(crate) unsafe fn new() -> Self {
|
||||
set_graphics_mode(DisplayMode::Bitmap3);
|
||||
set_graphics_settings(GraphicsSettings::LAYER_BG2);
|
||||
Bitmap3 {}
|
||||
Bitmap3 {
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Draws point to screen at (x, y) coordinates with colour and panics if
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use core::marker::PhantomData;
|
||||
|
||||
use crate::memory_mapped::{MemoryMapped1DArray, MemoryMapped2DArray};
|
||||
|
||||
use super::{
|
||||
|
@ -25,13 +27,17 @@ pub enum Page {
|
|||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
pub struct Bitmap4 {}
|
||||
pub struct Bitmap4<'gba> {
|
||||
phantom: PhantomData<&'gba ()>,
|
||||
}
|
||||
|
||||
impl Bitmap4 {
|
||||
impl Bitmap4<'_> {
|
||||
pub(crate) unsafe fn new() -> Self {
|
||||
set_graphics_mode(DisplayMode::Bitmap4);
|
||||
set_graphics_settings(GraphicsSettings::LAYER_BG2);
|
||||
Bitmap4 {}
|
||||
Bitmap4 {
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Draws point on specified page at (x, y) coordinates with colour index
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use core::cell::RefCell;
|
||||
use core::{cell::RefCell, marker::PhantomData};
|
||||
|
||||
use super::{
|
||||
CreatableRegularTiledMode, MapLoan, RegularBackgroundSize, RegularMap, RegularTiledMode,
|
||||
|
@ -9,18 +9,20 @@ use crate::{
|
|||
display::{set_graphics_mode, DisplayMode, Priority},
|
||||
};
|
||||
|
||||
pub struct Tiled0 {
|
||||
pub struct Tiled0<'gba> {
|
||||
regular: RefCell<Bitarray<1>>,
|
||||
screenblocks: RefCell<Bitarray<1>>,
|
||||
phantom: PhantomData<&'gba ()>,
|
||||
}
|
||||
|
||||
impl Tiled0 {
|
||||
impl Tiled0<'_> {
|
||||
pub(crate) unsafe fn new() -> Self {
|
||||
set_graphics_mode(DisplayMode::Tiled0);
|
||||
|
||||
Self {
|
||||
regular: Default::default(),
|
||||
screenblocks: Default::default(),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,13 +35,13 @@ impl Tiled0 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TiledMode for Tiled0 {
|
||||
impl TiledMode for Tiled0<'_> {
|
||||
fn screenblocks(&self) -> &RefCell<Bitarray<1>> {
|
||||
&self.screenblocks
|
||||
}
|
||||
}
|
||||
|
||||
impl CreatableRegularTiledMode for Tiled0 {
|
||||
impl CreatableRegularTiledMode for Tiled0<'_> {
|
||||
const REGULAR_BACKGROUNDS: usize = 4;
|
||||
|
||||
fn regular(&self) -> &RefCell<Bitarray<1>> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use core::cell::RefCell;
|
||||
use core::{cell::RefCell, marker::PhantomData};
|
||||
|
||||
use super::{
|
||||
AffineBackgroundSize, AffineMap, AffineTiledMode, CreatableAffineTiledMode,
|
||||
|
@ -10,13 +10,14 @@ use crate::{
|
|||
display::{set_graphics_mode, tiled::AFFINE_BG_ID_OFFSET, DisplayMode, Priority},
|
||||
};
|
||||
|
||||
pub struct Tiled1 {
|
||||
pub struct Tiled1<'gba> {
|
||||
regular: RefCell<Bitarray<1>>,
|
||||
affine: RefCell<Bitarray<1>>,
|
||||
screenblocks: RefCell<Bitarray<1>>,
|
||||
phantom: PhantomData<&'gba ()>,
|
||||
}
|
||||
|
||||
impl Tiled1 {
|
||||
impl Tiled1<'_> {
|
||||
pub(crate) unsafe fn new() -> Self {
|
||||
set_graphics_mode(DisplayMode::Tiled1);
|
||||
|
||||
|
@ -29,6 +30,7 @@ impl Tiled1 {
|
|||
regular: Default::default(),
|
||||
affine,
|
||||
screenblocks: Default::default(),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,13 +47,13 @@ impl Tiled1 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TiledMode for Tiled1 {
|
||||
impl TiledMode for Tiled1<'_> {
|
||||
fn screenblocks(&self) -> &RefCell<Bitarray<1>> {
|
||||
&self.screenblocks
|
||||
}
|
||||
}
|
||||
|
||||
impl CreatableRegularTiledMode for Tiled1 {
|
||||
impl CreatableRegularTiledMode for Tiled1<'_> {
|
||||
const REGULAR_BACKGROUNDS: usize = 2;
|
||||
|
||||
fn regular(&self) -> &RefCell<Bitarray<1>> {
|
||||
|
@ -59,7 +61,7 @@ impl CreatableRegularTiledMode for Tiled1 {
|
|||
}
|
||||
}
|
||||
|
||||
impl CreatableAffineTiledMode for Tiled1 {
|
||||
impl CreatableAffineTiledMode for Tiled1<'_> {
|
||||
const AFFINE_BACKGROUNDS: usize = 1;
|
||||
|
||||
fn affine(&self) -> &RefCell<Bitarray<1>> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use core::cell::RefCell;
|
||||
use core::{cell::RefCell, marker::PhantomData};
|
||||
|
||||
use super::{
|
||||
AffineBackgroundSize, AffineMap, AffineTiledMode, CreatableAffineTiledMode, MapLoan, TiledMode,
|
||||
|
@ -8,12 +8,13 @@ use crate::{
|
|||
display::{set_graphics_mode, tiled::AFFINE_BG_ID_OFFSET, DisplayMode, Priority},
|
||||
};
|
||||
|
||||
pub struct Tiled2 {
|
||||
pub struct Tiled2<'gba> {
|
||||
affine: RefCell<Bitarray<1>>,
|
||||
screenblocks: RefCell<Bitarray<1>>,
|
||||
phantom: PhantomData<&'gba ()>,
|
||||
}
|
||||
|
||||
impl Tiled2 {
|
||||
impl Tiled2<'_> {
|
||||
pub(crate) unsafe fn new() -> Self {
|
||||
set_graphics_mode(DisplayMode::Tiled2);
|
||||
|
||||
|
@ -25,6 +26,7 @@ impl Tiled2 {
|
|||
Self {
|
||||
affine,
|
||||
screenblocks: Default::default(),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,13 +39,13 @@ impl Tiled2 {
|
|||
}
|
||||
}
|
||||
|
||||
impl TiledMode for Tiled2 {
|
||||
impl TiledMode for Tiled2<'_> {
|
||||
fn screenblocks(&self) -> &RefCell<Bitarray<1>> {
|
||||
&self.screenblocks
|
||||
}
|
||||
}
|
||||
|
||||
impl CreatableAffineTiledMode for Tiled2 {
|
||||
impl CreatableAffineTiledMode for Tiled2<'_> {
|
||||
const AFFINE_BACKGROUNDS: usize = 2;
|
||||
|
||||
fn affine(&self) -> &RefCell<Bitarray<1>> {
|
||||
|
|
|
@ -13,27 +13,27 @@ pub struct Video;
|
|||
|
||||
impl Video {
|
||||
/// Bitmap mode that provides a 16-bit colour framebuffer
|
||||
pub fn bitmap3(&mut self) -> Bitmap3 {
|
||||
pub fn bitmap3(&mut self) -> Bitmap3<'_> {
|
||||
unsafe { Bitmap3::new() }
|
||||
}
|
||||
|
||||
/// Bitmap 4 provides two 8-bit paletted framebuffers with page switching
|
||||
pub fn bitmap4(&mut self) -> Bitmap4 {
|
||||
pub fn bitmap4(&mut self) -> Bitmap4<'_> {
|
||||
unsafe { Bitmap4::new() }
|
||||
}
|
||||
|
||||
/// Tiled 0 mode provides 4 regular, tiled backgrounds
|
||||
pub fn tiled0(&mut self) -> (Tiled0, VRamManager) {
|
||||
pub fn tiled0(&mut self) -> (Tiled0<'_>, VRamManager) {
|
||||
(unsafe { Tiled0::new() }, VRamManager::new())
|
||||
}
|
||||
|
||||
/// Tiled 1 mode provides 2 regular tiled backgrounds and 1 affine tiled background
|
||||
pub fn tiled1(&mut self) -> (Tiled1, VRamManager) {
|
||||
pub fn tiled1(&mut self) -> (Tiled1<'_>, VRamManager) {
|
||||
(unsafe { Tiled1::new() }, VRamManager::new())
|
||||
}
|
||||
|
||||
/// Tiled 2 mode provides 2 affine tiled backgrounds
|
||||
pub fn tiled2(&mut self) -> (Tiled2, VRamManager) {
|
||||
pub fn tiled2(&mut self) -> (Tiled2<'_>, VRamManager) {
|
||||
(unsafe { Tiled2::new() }, VRamManager::new())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue