Compare commits

...

2 Commits

Author SHA1 Message Date
233fae545a Fix large sprites
Some checks failed
Cargo Build & Test / Rust project - latest (stable) (push) Failing after 8s
2026-04-08 22:47:41 -05:00
00e28203fa Remove debug prints in mem 2026-04-08 22:47:18 -05:00
2 changed files with 47 additions and 28 deletions

View File

@@ -658,7 +658,7 @@ impl<'a> CpuMem<'a> {
} }
} else if (addr & 0x6000) >> 13 == 3 { } else if (addr & 0x6000) >> 13 == 3 {
*cur_prg_bank = (val & 0x0F) as usize; *cur_prg_bank = (val & 0x0F) as usize;
println!("Updating ROM: new {:X}", val); // println!("Updating ROM: new {:X}", val);
match mode { match mode {
MMC1Mode::Full => { MMC1Mode::Full => {
let bank0 = self.mem.cpu.find(SegmentId::PrgBank0).unwrap(); let bank0 = self.mem.cpu.find(SegmentId::PrgBank0).unwrap();
@@ -686,7 +686,7 @@ impl<'a> CpuMem<'a> {
} else { } else {
*shift_reg = (*shift_reg >> 1) | ((val & 0x01) << 4); *shift_reg = (*shift_reg >> 1) | ((val & 0x01) << 4);
*count += 1; *count += 1;
println!("Mapper SHR {:05b}", *shift_reg); // println!("Mapper SHR {:05b}", *shift_reg);
} }
} }
_ => (), _ => (),

View File

@@ -164,7 +164,7 @@ impl OAM {
OamState::ReadY => { OamState::ReadY => {
let l = self.oam_read_buffer as usize; let l = self.oam_read_buffer as usize;
if self.count < 8 { if self.count < 8 {
if l <= line && line < l + 8 { if l <= line && line < l + if self.large_sprites { 16 } else { 8 } {
self.secondary[self.count as usize * 4] = self.oam_read_buffer; self.secondary[self.count as usize * 4] = self.oam_read_buffer;
self.state = OamState::ReadTile; self.state = OamState::ReadTile;
} else { } else {
@@ -214,36 +214,55 @@ impl OAM {
} else if run % 8 == 3 { } else if run % 8 == 3 {
self.sprite_output_units[run / 8].x_pos = self.secondary[(run / 8) * 4 + 3]; self.sprite_output_units[run / 8].x_pos = self.secondary[(run / 8) * 4 + 3];
} else if run % 8 == 4 { } else if run % 8 == 4 {
} else if run % 8 == 5 { // } else if run % 8 == 5 {
let off = line - self.sprite_output_units[run / 8].y_pos as usize; // let off = line - self.sprite_output_units[run / 8].y_pos as usize;
let off = if self.sprite_output_units[run / 8].attrs.vflip() { // let off = if self.sprite_output_units[run / 8].attrs.vflip() {
7 - off // 7 - off
} else { // } else {
off // off
}; // };
let addr = if self.sprite_offset_0x1000 { // let addr = if self.sprite_offset_0x1000 {
0x1000 // 0x1000
} else { // } else {
0x0000 // 0x0000
} + 16 * self.sprite_output_units[run / 8].tile as u16 // } + 16 * self.sprite_output_units[run / 8].tile as u16
+ off as u16; // + off as u16;
self.sprite_output_units[run / 8].low = mem.read(addr).reg_map(|_, _| todo!()); // self.sprite_output_units[run / 8].low = mem.read(addr).reg_map(|_, _| todo!());
} else if run % 8 == 6 { } else if run % 8 == 6 {
} else if run % 8 == 7 { } else if run % 8 == 5 || run % 8 == 7 {
let off = line - self.sprite_output_units[run / 8].y_pos as usize; let off = line - self.sprite_output_units[run / 8].y_pos as usize;
let off = if self.sprite_output_units[run / 8].attrs.vflip() { let addr = if self.large_sprites {
7 - off let off = if self.sprite_output_units[run / 8].attrs.vflip() {
15 - off
} else {
off
};
(if self.sprite_output_units[run / 8].tile & 1 == 1 {
0x1000
} else {
0x0000
} + 16 * (self.sprite_output_units[run / 8].tile & !1) as u16
+ off as u16 + if off > 7 { 8 } else { 0 })
} else { } else {
off let off = if self.sprite_output_units[run / 8].attrs.vflip() {
7 - off
} else {
off
};
(if self.sprite_offset_0x1000 {
0x1000
} else {
0x0000
} + 16 * self.sprite_output_units[run / 8].tile as u16
+ off as u16)
}; };
let addr = if self.sprite_offset_0x1000 { if run % 8 == 5 {
0x1000 self.sprite_output_units[run / 8].low =
mem.read(addr).reg_map(|_, _| todo!());
} else { } else {
0x0000 self.sprite_output_units[run / 8].high =
} + 16 * self.sprite_output_units[run / 8].tile as u16 mem.read(addr + 8).reg_map(|_, _| todo!());
+ off as u16 }
+ 8;
self.sprite_output_units[run / 8].high = mem.read(addr).reg_map(|_, _| todo!());
} }
} }
} }