Skip to content

Commit

Permalink
- Disable vertical scaling more thoroughly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Apr 2, 2024
1 parent ac61623 commit 8bea5ad
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 57 deletions.
4 changes: 4 additions & 0 deletions cube/swiss/include/patcher.h
Expand Up @@ -80,6 +80,10 @@ extern u8 GXSetDispCopyYScalePatch1[];
extern u32 GXSetDispCopyYScalePatch1_length;
extern u8 GXSetDispCopyYScalePatch2[];
extern u32 GXSetDispCopyYScalePatch2_length;
extern u8 GXSetDispCopyYScaleStub1[];
extern u32 GXSetDispCopyYScaleStub1_length;
extern u8 GXSetDispCopyYScaleStub2[];
extern u32 GXSetDispCopyYScaleStub2_length;
extern u8 GXSetProjectionHook[];
extern u32 GXSetProjectionHook_length;
extern u8 GXSetScissorHook[];
Expand Down
135 changes: 82 additions & 53 deletions cube/swiss/source/patcher.c
Expand Up @@ -7827,11 +7827,11 @@ void Patch_Video(u32 *data, u32 length, int dataType)
{ 576, 331, 34, 119, 15, 12, NULL, 0, "__GXInitGX" } // SN Systems ProDG
};
FuncPattern GXAdjustForOverscanSigs[5] = {
{ 57, 6, 4, 0, 3, 11, GXAdjustForOverscanPatch, GXAdjustForOverscanPatch_length, "GXAdjustForOverscanD" },
{ 67, 6, 4, 0, 3, 14, GXAdjustForOverscanPatch, GXAdjustForOverscanPatch_length, "GXAdjustForOverscanD" },
{ 72, 17, 15, 0, 3, 5, GXAdjustForOverscanPatch, GXAdjustForOverscanPatch_length, "GXAdjustForOverscan" },
{ 63, 11, 8, 1, 2, 10, GXAdjustForOverscanPatch, GXAdjustForOverscanPatch_length, "GXAdjustForOverscan" }, // SN Systems ProDG
{ 81, 17, 15, 0, 3, 7, GXAdjustForOverscanPatch, GXAdjustForOverscanPatch_length, "GXAdjustForOverscan" }
{ 57, 6, 4, 0, 3, 11, NULL, 0, "GXAdjustForOverscanD" },
{ 67, 6, 4, 0, 3, 14, NULL, 0, "GXAdjustForOverscanD" },
{ 72, 17, 15, 0, 3, 5, NULL, 0, "GXAdjustForOverscan" },
{ 63, 11, 8, 1, 2, 10, NULL, 0, "GXAdjustForOverscan" }, // SN Systems ProDG
{ 81, 17, 15, 0, 3, 7, NULL, 0, "GXAdjustForOverscan" }
};
FuncPattern GXSetDispCopySrcSigs[7] = {
{ 104, 44, 10, 5, 5, 6, NULL, 0, "GXSetDispCopySrcD" },
Expand All @@ -7843,15 +7843,15 @@ void Patch_Video(u32 *data, u32 length, int dataType)
{ 31, 11, 8, 0, 0, 0, NULL, 0, "GXSetDispCopySrc" } // SN Systems ProDG
};
FuncPattern GXSetDispCopyYScaleSigs[9] = {
{ 100, 33, 8, 8, 4, 7, GXSetDispCopyYScalePatch1, GXSetDispCopyYScalePatch1_length, "GXSetDispCopyYScaleD" },
{ 85, 32, 4, 6, 4, 7, GXSetDispCopyYScalePatch1, GXSetDispCopyYScalePatch1_length, "GXSetDispCopyYScaleD" },
{ 82, 33, 4, 6, 4, 5, GXSetDispCopyYScalePatch1, GXSetDispCopyYScalePatch1_length, "GXSetDispCopyYScaleD" },
{ 47, 15, 8, 2, 0, 4, GXSetDispCopyYScalePatch1, GXSetDispCopyYScalePatch1_length, "GXSetDispCopyYScale" },
{ 53, 17, 4, 1, 5, 8, GXSetDispCopyYScalePatch1, GXSetDispCopyYScalePatch1_length, "GXSetDispCopyYScale" },
{ 50, 14, 4, 1, 5, 8, GXSetDispCopyYScalePatch1, GXSetDispCopyYScalePatch1_length, "GXSetDispCopyYScale" },
{ 44, 8, 4, 1, 2, 3, GXSetDispCopyYScalePatch2, GXSetDispCopyYScalePatch2_length, "GXSetDispCopyYScale" }, // SN Systems ProDG
{ 51, 16, 4, 1, 5, 7, GXSetDispCopyYScalePatch1, GXSetDispCopyYScalePatch1_length, "GXSetDispCopyYScale" },
{ 52, 17, 4, 1, 5, 7, GXSetDispCopyYScalePatch1, GXSetDispCopyYScalePatch1_length, "GXSetDispCopyYScale" } // SN Systems ProDG
{ 100, 33, 8, 8, 4, 7, NULL, 0, "GXSetDispCopyYScaleD" },
{ 85, 32, 4, 6, 4, 7, NULL, 0, "GXSetDispCopyYScaleD" },
{ 82, 33, 4, 6, 4, 5, NULL, 0, "GXSetDispCopyYScaleD" },
{ 47, 15, 8, 2, 0, 4, NULL, 0, "GXSetDispCopyYScale" },
{ 53, 17, 4, 1, 5, 8, NULL, 0, "GXSetDispCopyYScale" },
{ 50, 14, 4, 1, 5, 8, NULL, 0, "GXSetDispCopyYScale" },
{ 44, 8, 4, 1, 2, 3, NULL, 0, "GXSetDispCopyYScale" }, // SN Systems ProDG
{ 51, 16, 4, 1, 5, 7, NULL, 0, "GXSetDispCopyYScale" },
{ 52, 17, 4, 1, 5, 7, NULL, 0, "GXSetDispCopyYScale" } // SN Systems ProDG
};
FuncPattern GXSetCopyFilterSigs[7] = {
{ 567, 183, 44, 32, 36, 38, GXSetCopyFilterPatch, GXSetCopyFilterPatch_length, "GXSetCopyFilterD" },
Expand Down Expand Up @@ -7976,6 +7976,35 @@ void Patch_Video(u32 *data, u32 length, int dataType)
break;
}

if (in_range(swissSettings.gameVMode, 1, 7)) {
for (j = 0; j < sizeof(GXAdjustForOverscanSigs) / sizeof(FuncPattern); j++) {
GXAdjustForOverscanSigs[j].Patch = GXAdjustForOverscanPatch;
GXAdjustForOverscanSigs[j].PatchLength = GXAdjustForOverscanPatch_length;
}
}

if (swissSettings.aveCompat == 1 && swissSettings.rt4kOptim) {
for (j = 0; j < sizeof(GXSetDispCopyYScaleSigs) / sizeof(FuncPattern); j++) {
if (j == 6) {
GXSetDispCopyYScaleSigs[j].Patch = GXSetDispCopyYScaleStub2;
GXSetDispCopyYScaleSigs[j].PatchLength = GXSetDispCopyYScaleStub2_length;
} else {
GXSetDispCopyYScaleSigs[j].Patch = GXSetDispCopyYScaleStub1;
GXSetDispCopyYScaleSigs[j].PatchLength = GXSetDispCopyYScaleStub1_length;
}
}
} else if (in_range(swissSettings.gameVMode, 1, 7)) {
for (j = 0; j < sizeof(GXSetDispCopyYScaleSigs) / sizeof(FuncPattern); j++) {
if (j == 6) {
GXSetDispCopyYScaleSigs[j].Patch = GXSetDispCopyYScalePatch2;
GXSetDispCopyYScaleSigs[j].PatchLength = GXSetDispCopyYScalePatch2_length;
} else {
GXSetDispCopyYScaleSigs[j].Patch = GXSetDispCopyYScalePatch1;
GXSetDispCopyYScaleSigs[j].PatchLength = GXSetDispCopyYScalePatch1_length;
}
}
}

if (swissSettings.gameVMode == 3 || swissSettings.gameVMode == 10)
memcpy(VAR_VFILTER, vertical_reduction[swissSettings.forceVFilter], 7);
else
Expand Down Expand Up @@ -10168,51 +10197,51 @@ void Patch_Video(u32 *data, u32 length, int dataType)
}
}

if (in_range(swissSettings.gameVMode, 1, 7)) {
for (j = 0; j < sizeof(GXAdjustForOverscanSigs) / sizeof(FuncPattern); j++)
if (GXAdjustForOverscanSigs[j].offsetFoundAt) break;
for (j = 0; j < sizeof(GXAdjustForOverscanSigs) / sizeof(FuncPattern); j++)
if (GXAdjustForOverscanSigs[j].offsetFoundAt) break;

if (j < sizeof(GXAdjustForOverscanSigs) / sizeof(FuncPattern) && (i = GXAdjustForOverscanSigs[j].offsetFoundAt)) {
u32 *GXAdjustForOverscan = Calc_ProperAddress(data, dataType, i * sizeof(u32));

if (j < sizeof(GXAdjustForOverscanSigs) / sizeof(FuncPattern) && (i = GXAdjustForOverscanSigs[j].offsetFoundAt)) {
u32 *GXAdjustForOverscan = Calc_ProperAddress(data, dataType, i * sizeof(u32));

if (GXAdjustForOverscan) {
if (GXAdjustForOverscanSigs[j].Patch) {
memset(data + i, 0, GXAdjustForOverscanSigs[j].Length * sizeof(u32));
memcpy(data + i, GXAdjustForOverscanSigs[j].Patch, GXAdjustForOverscanSigs[j].PatchLength);
}
print_gecko("Found:[%s$%i] @ %08X\n", GXAdjustForOverscanSigs[j].Name, j, GXAdjustForOverscan);
if (GXAdjustForOverscan) {
if (GXAdjustForOverscanSigs[j].Patch) {
memset(data + i, 0, GXAdjustForOverscanSigs[j].Length * sizeof(u32));
memcpy(data + i, GXAdjustForOverscanSigs[j].Patch, GXAdjustForOverscanSigs[j].PatchLength);
}
print_gecko("Found:[%s$%i] @ %08X\n", GXAdjustForOverscanSigs[j].Name, j, GXAdjustForOverscan);
}
}

for (j = 0; j < sizeof(GXSetDispCopyYScaleSigs) / sizeof(FuncPattern); j++)
if (GXSetDispCopyYScaleSigs[j].offsetFoundAt) break;

if (j < sizeof(GXSetDispCopyYScaleSigs) / sizeof(FuncPattern) && (i = GXSetDispCopyYScaleSigs[j].offsetFoundAt)) {
u32 *GXSetDispCopyYScale = Calc_ProperAddress(data, dataType, i * sizeof(u32));
u32 __GXData;

for (j = 0; j < sizeof(GXSetDispCopyYScaleSigs) / sizeof(FuncPattern); j++)
if (GXSetDispCopyYScaleSigs[j].offsetFoundAt) break;

if (j < sizeof(GXSetDispCopyYScaleSigs) / sizeof(FuncPattern) && (i = GXSetDispCopyYScaleSigs[j].offsetFoundAt)) {
u32 *GXSetDispCopyYScale = Calc_ProperAddress(data, dataType, i * sizeof(u32));
u32 __GXData;

if (GXSetDispCopyYScale) {
if (GXSetDispCopyYScaleSigs[j].Patch) {
switch (j) {
case 0: __GXData = data[i + 65] & 0x1FFFFF; break;
case 1: __GXData = data[i + 56] & 0x1FFFFF; break;
case 2: __GXData = data[i + 55] & 0x1FFFFF; break;
case 3:
case 4:
case 5: __GXData = data[i + 7] & 0x1FFFFF; break;
case 6: __GXData = data[i + 7] >> 5 & 0x1F0000; break;
case 7: __GXData = data[i + 7] & 0x1FFFFF; break;
case 8: __GXData = data[i + 13] & 0x1FFFFF; break;
}

memset(data + i, 0, GXSetDispCopyYScaleSigs[j].Length * sizeof(u32));
memcpy(data + i, GXSetDispCopyYScaleSigs[j].Patch, GXSetDispCopyYScaleSigs[j].PatchLength);

if (GXSetDispCopyYScaleSigs[j].Patch != GXSetDispCopyYScalePatch2)
data[i + 6] |= __GXData;
if (GXSetDispCopyYScale) {
if (GXSetDispCopyYScaleSigs[j].Patch) {
switch (j) {
case 0: __GXData = data[i + 65] & 0x1FFFFF; break;
case 1: __GXData = data[i + 56] & 0x1FFFFF; break;
case 2: __GXData = data[i + 55] & 0x1FFFFF; break;
case 3:
case 4:
case 5: __GXData = data[i + 7] & 0x1FFFFF; break;
case 6: __GXData = data[i + 7] >> 5 & 0x1F0000; break;
case 7: __GXData = data[i + 7] & 0x1FFFFF; break;
case 8: __GXData = data[i + 13] & 0x1FFFFF; break;
}
print_gecko("Found:[%s$%i] @ %08X\n", GXSetDispCopyYScaleSigs[j].Name, j, GXSetDispCopyYScale);

memset(data + i, 0, GXSetDispCopyYScaleSigs[j].Length * sizeof(u32));
memcpy(data + i, GXSetDispCopyYScaleSigs[j].Patch, GXSetDispCopyYScaleSigs[j].PatchLength);

if (GXSetDispCopyYScaleSigs[j].Patch == GXSetDispCopyYScalePatch1)
data[i + 6] |= __GXData;
if (GXSetDispCopyYScaleSigs[j].Patch == GXSetDispCopyYScaleStub1)
data[i + 0] |= __GXData;
}
print_gecko("Found:[%s$%i] @ %08X\n", GXSetDispCopyYScaleSigs[j].Name, j, GXSetDispCopyYScale);
}
}

Expand Down
12 changes: 12 additions & 0 deletions cube/swiss/source/patches/gx/GXSetDispCopyYScaleStub1.s
@@ -0,0 +1,12 @@

.globl GXSetDispCopyYScaleStub1
GXSetDispCopyYScaleStub1:
lwz %r4, 0 (0)
lwz %r3, 484 (%r4)
extrwi %r3, %r3, 10, 12
addi %r3, %r3, 1
blr

.globl GXSetDispCopyYScaleStub1_length
GXSetDispCopyYScaleStub1_length:
.long (GXSetDispCopyYScaleStub1_length - GXSetDispCopyYScaleStub1)
12 changes: 12 additions & 0 deletions cube/swiss/source/patches/gx/GXSetDispCopyYScaleStub2.s
@@ -0,0 +1,12 @@

.globl GXSetDispCopyYScaleStub2
GXSetDispCopyYScaleStub2:
mr %r9, %r13
lwz %r3, 580 (%r9)
extrwi %r3, %r3, 10, 12
addi %r3, %r3, 1
blr

.globl GXSetDispCopyYScaleStub2_length
GXSetDispCopyYScaleStub2_length:
.long (GXSetDispCopyYScaleStub2_length - GXSetDispCopyYScaleStub2)
7 changes: 3 additions & 4 deletions cube/swiss/source/patches/vi/VIConfigureNoYScale.s
@@ -1,4 +1,3 @@
#include "reservedarea.h"

.globl VIConfigureNoYScale
VIConfigureNoYScale:
Expand All @@ -9,9 +8,9 @@ VIConfigureNoYScale:
lbz %r0, 25 (%r3)
cmpwi %r0, 0
beq 1f
srwi %r7, %r6, 1
addi %r7, %r7, 2
cmpw %r7, %r5
srwi %r6, %r6, 1
addi %r6, %r6, 2
cmpw %r6, %r5
beq 2f
1: clrrwi %r6, %r5, 1
sth %r6, 8 (%r3)
Expand Down
1 change: 1 addition & 0 deletions cube/swiss/source/video.c
Expand Up @@ -179,6 +179,7 @@ void updateVideoMode(GXRModeObj *m) {
}
}
if(swissSettings.aveCompat == 1 && swissSettings.rt4kOptim) {
m->xfbHeight = m->efbHeight;
m->viWidth = m->fbWidth;
m->viXOrigin = 40;
} else {
Expand Down

0 comments on commit 8bea5ad

Please sign in to comment.