XGA: Fix pattern map pixel reading when (width + 1) is not divisible by 8, fixes #5779.

This commit is contained in:
OBattler
2025-07-13 06:50:32 +02:00
parent 3894be72f5
commit 51cd80e7b1

View File

@@ -993,15 +993,20 @@ xga_accel_read_pattern_map_pixel(svga_t *svga, int x, int y, uint32_t base, int
uint8_t byte;
uint8_t px;
int skip = 0;
int x_dir = (xga->accel.octant & 0x04) ? -1 : 1;
int y_dir = (xga->accel.octant & 0x02) ? -1 : 1;
int pos = ((y * width * y_dir) + (x * x_dir));
addr += (pos / 8);
bits = 7 - (abs(pos) & 7);
if ((addr < xga->linear_base) || (addr > (xga->linear_base + 0xfffff)))
skip = 1;
addr += (y * (width >> 3));
if (!skip) {
READ(addr + (x >> 3), byte);
READ(addr, byte);
} else
byte = mem_readb_phys(addr + (x >> 3));
byte = mem_readb_phys(addr);
xga_log("0. AccessMode=%02x, SRCMAP=%02x, DSTMAP=%02x, PAT=%02x.\n", xga->access_mode & 0x0f, (xga->accel.px_map_format[xga->accel.src_map] & 0x0f), (xga->accel.px_map_format[xga->accel.dst_map] & 0x0f), (xga->accel.px_map_format[xga->accel.pat_src] & 0x08));
if (!(xga->accel.px_map_format[xga->accel.src_map] & 0x08) && !(xga->accel.px_map_format[xga->accel.dst_map] & 0x08)) {
@@ -1010,8 +1015,7 @@ xga_accel_read_pattern_map_pixel(svga_t *svga, int x, int y, uint32_t base, int
}
}
bits = 7 - (x & 7);
px = (byte >> bits) & 0x01;
px = (byte >> bits) & 1;
if (xga->accel.command == 0x08013002)
xga_log("Read Pattern Skip=%d, lx=%d, ly=%d, px=%d, py=%d, dx=%d, dy=%d, xlen=%d, width=%d, byte=%02x, bits=%d, addr=%08x, addrpx=%08x, base=%08x, chain=%08x.\n", skip, xga->accel.x, xga->accel.y, x, y, xga->accel.dx, xga->accel.dy, xga->accel.x_len, width, byte, bits, addr, addr + (x >> 3), base, xga->accel.carry_chain);