Skip to content

Commit

Permalink
Replace Tile.write by making Tile arrays public
Browse files Browse the repository at this point in the history
  • Loading branch information
Hpmason committed Nov 26, 2021
1 parent 1e33ee6 commit bacd41f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
Cargo.lock
/src/assets.rs
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "gba-dvd"
description = "A Gamebody Advance ROM that's just a dvd bounce screen saver"
version = "0.1.0"
version = "0.1.1"
authors = ["Mason Ginter <[email protected]>"]
repository = "https://github.com/Hpmason/gba-dvd"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn copy_tiles() {
for i in 0..(dvd.len() / 8) {
tile = Tile4bpp::new_tile();
for j in 0..8 {
tile.write(j, dvd[i * 8 + j])
tile.0[j] = dvd[i * 8 + j];
}
// first index is used for all sprites
CHAR_DATA_4.index(i).write(tile);
Expand Down
11 changes: 2 additions & 9 deletions src/tiles/types.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
use crate::prelude::*;

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct Tile4bpp([u32; 8]);
pub struct Tile4bpp(pub [u32; 8]);

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct Tile8bpp([u32; 16]);
pub struct Tile8bpp(pub [u32; 16]);

pub trait Tile {
fn new_tile() -> Self;
fn write(&mut self, ind: usize, t: u32);
fn copy_to_block(self, ind: usize);
}

impl Tile for Tile4bpp {
fn new_tile() -> Self {
Tile4bpp::default()
}
fn write(&mut self, ind: usize, t: u32) {
self.0[ind] = t;
}
fn copy_to_block(self, ind: usize) {
CHAR_DATA_4.index(ind).write(self);
}
Expand All @@ -28,9 +24,6 @@ impl Tile for Tile8bpp {
fn new_tile() -> Self {
Tile8bpp::default()
}
fn write(&mut self, ind: usize, t: u32) {
self.0[ind] = t;
}
fn copy_to_block(self, ind: usize) {
CHAR_DATA_8.index(ind).write(self);
}
Expand Down

0 comments on commit bacd41f

Please sign in to comment.