From 7c097c73f4aae22895c4583f0cdcf109f2a1035c Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 2 Apr 2024 23:56:46 +0200 Subject: [PATCH] GSU: fix PLOT obj-mode tile index calculation --- src/cpu_gsu/cpu.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpu_gsu/cpu.rs b/src/cpu_gsu/cpu.rs index a60f345..9002a8c 100644 --- a/src/cpu_gsu/cpu.rs +++ b/src/cpu_gsu/cpu.rs @@ -1105,7 +1105,7 @@ impl CpuGsu { let tilenum = if self.regs.get_scmr_height() == ScreenHeight::Obj || self.regs.test_por(PORFlag::ObjMode) { - (y / 0x80) * 0x200 + (x / 0x80) * 0x100 + ((y / 8) & 0x0F) + ((x / 8) & 0x0F) + (y / 0x80) * 0x200 + (x / 0x80) * 0x100 + ((y / 8) & 0x0F) * 0x10 + ((x / 8) & 0x0F) } else { match self.regs.get_scmr_height() { ScreenHeight::H128 => (x / 8) * 0x10 + (y / 8), @@ -1122,7 +1122,7 @@ impl CpuGsu { }; const BITPLANE_OFFSETS: [usize; 8] = [0x00, 0x01, 0x10, 0x11, 0x20, 0x21, 0x30, 0x31]; - let bit = 1 << (7 - (x % 8)); + let bit = 1 << (7 - (x & 7)); for bitp in 0..(bpp.num_bitplanes()) { let addr = row_addr + BITPLANE_OFFSETS[bitp];