Skip to content

Commit

Permalink
pvr: rgb888 needs to be correctly aligned when xclip.min != 0
Browse files Browse the repository at this point in the history
Fixes glitchy combat opening animation in soul calibur (with full
framebuffer emulation). Use slower but correct method instead.
Issue #1591
  • Loading branch information
flyinghead committed Aug 17, 2024
1 parent cb0b667 commit af73532
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
13 changes: 8 additions & 5 deletions core/hw/pvr/pvr_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ template u32 pvr_read32p<u32>(u32 addr);
template float pvr_read32p<float>(u32 addr);

//write
template<typename T>
template<typename T, bool Internal = false>
void DYNACALL pvr_write32p(u32 addr, T data)
{
if constexpr (sizeof(T) == 1)
if constexpr (!Internal && sizeof(T) == 1)
{
INFO_LOG(MEMORY, "%08x: 8-bit VRAM writes are not possible", addr);
return;
Expand All @@ -234,9 +234,12 @@ void DYNACALL pvr_write32p(u32 addr, T data)

*(T *)&vram[pvr_map32(addr)] = data;
}
template void pvr_write32p<u8>(u32 addr, u8 data);
template void pvr_write32p<u16>(u32 addr, u16 data);
template void pvr_write32p<u32>(u32 addr, u32 data);
template void pvr_write32p<u8, false>(u32 addr, u8 data);
template void pvr_write32p<u8, true>(u32 addr, u8 data);
template void pvr_write32p<u16, false>(u32 addr, u16 data);
template void pvr_write32p<u16, true>(u32 addr, u16 data);
template void pvr_write32p<u32, false>(u32 addr, u32 data);
template void pvr_write32p<u32, true>(u32 addr, u32 data);

void DYNACALL TAWrite(u32 address, const SQBuffer *data, u32 count)
{
Expand Down
2 changes: 1 addition & 1 deletion core/hw/pvr/pvr_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void YUV_reset();

// 32-bit vram path handlers
template<typename T> T DYNACALL pvr_read32p(u32 addr);
template<typename T> void DYNACALL pvr_write32p(u32 addr, T data);
template<typename T, bool Internal = false> void DYNACALL pvr_write32p(u32 addr, T data);
// Area 4 handlers
template<typename T, bool upper> T DYNACALL pvr_read_area4(u32 addr);
template<typename T, bool upper> void DYNACALL pvr_write_area4(u32 addr, T data);
12 changes: 5 additions & 7 deletions core/rend/TexCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ class FBPixelWriter

template<typename T>
void write(T pixel) {
pvr_write32p(dstAddr, pixel);
pvr_write32p<T, true>(dstAddr, pixel);
dstAddr += sizeof(T);
}

Expand Down Expand Up @@ -1173,14 +1173,12 @@ class FBLineWriter888

void write(int xmin, int xmax, const u8 *& pixel, int y)
{
for (int c = xmin; c < xmax - 3; c += 4)
for (int c = xmin; c < xmax; c++)
{
pixWriter.write((u32)((pixel[Blue + 4] << 24) | (pixel[Red] << 16) | (pixel[Green] << 8) | pixel[Blue]));
pixel += 4;
pixWriter.write((u32)((pixel[Green + 4] << 24) | (pixel[Blue + 4] << 16) | (pixel[Red] << 8) | pixel[Green]));
pixWriter.write(pixel[Blue]);
pixWriter.write(pixel[Green]);
pixWriter.write(pixel[Red]);
pixel += 4;
pixWriter.write((u32)((pixel[Red + 4] << 24) | (pixel[Green + 4] << 16) | (pixel[Blue + 4] << 8) | pixel[Red]));
pixel += 8;
}
}

Expand Down

0 comments on commit af73532

Please sign in to comment.