Fix wrong sprite size calculation

This solve many graphical glitches with normal sprites in:

- Kirby - Nightmare in Dreamland
- DragonBall Advanced Adventure
- DragonBall Supersonic Warriors


Former-commit-id: aa7813720ca86c0ff0a3111f245d35765112d750
This commit is contained in:
Michel Heily 2019-11-16 20:11:43 +02:00
parent 49ef59b8e9
commit 3c3e8c35b4

View file

@ -35,13 +35,21 @@ impl ObjAffineParams {
} }
impl ObjAttrs { impl ObjAttrs {
fn size(&self) -> (usize, usize) { fn size(&self) -> (i32, i32) {
let n = 8 << self.1.size(); match (self.1.size(), self.0.shape()) {
match self.0.shape() { (0, 0) /* Square */ => (8, 8),
0 /* Square */ => (n, n), (1, 0) /* Square */ => (16, 16),
1 /* Wide */ => (n, n >> 1), (2, 0) /* Square */ => (32, 32),
2 /* Tall */ => (n >> 1, n), (3, 0) /* Square */ => (64, 64),
_ => unreachable!("invalid obj shape") (0, 1) /* Wide */ => (16, 8),
(1, 1) /* Wide */ => (32, 8),
(2, 1) /* Wide */ => (32, 16),
(3, 1) /* Wide */ => (64, 32),
(0, 2) /* Tall */ => (8, 16),
(1, 2) /* Tall */ => (8, 32),
(2, 2) /* Tall */ => (16, 32),
(3, 2) /* Tall */ => (32, 64),
_ => (8, 8), // according to commit f01016a30b2e8482d06798895ebc674370e81816 in melonDS
} }
} }
fn coords(&self) -> (usize, usize) { fn coords(&self) -> (usize, usize) {