object priority
This commit is contained in:
parent
8394b4d225
commit
76642194b1
|
@ -10,6 +10,8 @@ use crate::{
|
|||
};
|
||||
use minifb::{Window, WindowOptions};
|
||||
|
||||
use super::SplitRegister;
|
||||
|
||||
mod tile_window;
|
||||
mod types;
|
||||
|
||||
|
@ -301,12 +303,18 @@ impl CPU {
|
|||
x_flip: get_bit(flags, 5),
|
||||
palette: byte_to_palette(self.memory.get(palette_addr)),
|
||||
},
|
||||
oam_location: (i - 0xFE00) as u8,
|
||||
});
|
||||
if objs.len() >= 10 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
objs.sort_by_key(|o| {
|
||||
let mut v: u16 = 0x0;
|
||||
v.set_high(o.x);
|
||||
v.set_low(o.oam_location);
|
||||
v
|
||||
});
|
||||
objs.reverse();
|
||||
objs.truncate(10);
|
||||
objs
|
||||
}
|
||||
|
||||
|
|
|
@ -109,4 +109,5 @@ pub(super) struct Object {
|
|||
pub(super) y: u8,
|
||||
pub(super) tile_index: u8,
|
||||
pub(super) flags: ObjectFlags,
|
||||
pub(super) oam_location: u8,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue