[XCX] Fix squashed character in menus with resolution pack

Basically, the code previously would always replace the ratio calculation code for the 3d rendering and just load the upscaled width divided by the upscaled height. But the code gets passed other aspect ratios too, for example in the gear menu (and very likely other menus too).
So, even when users didn't use an ultrawide aspect ratio it would set the aspect ratio of anything that was 3d rendered to be 16:9, basically.

Comparison:
http://www.framecompare.com/image-compare/screenshotcomparison/D6WDWNNX
https://cdn.discordapp.com/attachments/292733452590120961/663586520531337223/unknown.png

I made some assumptions about the other game versions regarding the floating point register that I use to load the scale float into, which is free to use in the EU 1.0.1 version at least.
I assume that the code for all of this is would be very similar though, since the previous ratio patch only had some addresses change across versions so it's probably fine.

This actually properly fixes https://github.com/slashiee/cemu_graphic_packs/issues/334 which was closed without any proper solution. Someone reported the issue in the Cemu Discord which made me fix it, since I thought the issue was addressed already.
This commit is contained in:
Crementif 2020-01-06 05:54:33 +01:00
parent 5bbdf0ffc6
commit 66383aa0f5
No known key found for this signature in database
GPG Key ID: 11A98E7DE0412B33

View File

@ -1,65 +1,161 @@
[XCXAspectV100U_V101U] [XCXAspectV100E_V101E]
moduleMatches = 2878856811, 0x676EB33E moduleMatches = 0x218F6E07, 0xF882D5CF
# rodata constants # Code cave
0x1003E754 = .float $width/$height codeCaveSize = 0x0000028
_aspectAddr = 0x1003E754
_widthScaleRatio = 0x0000000
0x0000000 = .float ($width/$gameWidth)
_heightScaleRatio = 0x0000004
0x0000004 = .float ($height/$gameHeight)
_aspectChangeCave = 0x0000008
; Scale the width of the viewport that it wants to calculate the ratio for
0x0000008 = lis r7, _widthScaleRatio@ha
0x000000C = lfs f8, _widthScaleRatio@l(r7)
0x0000010 = fmuls f13, f13, f8
; Scale the height of the viewport that it wants to calculate the ratio for
0x0000014 = lis r7, _heightScaleRatio@ha
0x0000018 = lfs f8, _heightScaleRatio@l(r7)
0x000001C = fmuls f9, f9, f8
0x0000020 = fdivs f13, f13, f9 ; Original instruction that got replaced by the code cave jump, which divides the width and height to get the aspect ratio
0x0000024 = blr ; Return to the original code
# Code changes
0x03160AE8 = bla _aspectChangeCave ; Modify this instruction to go to the code cave which scales the height and width to the upscale ratios
0x1003E754 = .float ($width/$height) ; Modify constant that has a ratio in the code
# 3d Aspect
0x031608E4 = lis r7, _aspectAddr@ha
0x031608E8 = lfs f13, _aspectAddr@l(r7)
[XCXAspectV102U] [XCXAspectV102U]
moduleMatches = 0x30B6E091 moduleMatches = 0x30B6E091
#rodata constants # Code cave
0x1003E754 = .float $width/$height codeCaveSize = 0x0000028
_aspectAddr = 0x1003E754
# 3d Aspect _widthScaleRatio = 0x0000000
0x03160A64 = lis r7, _aspectAddr@ha 0x0000000 = .float ($width/$gameWidth)
0x03160A68 = lfs f13, _aspectAddr@l(r7) _heightScaleRatio = 0x0000004
0x0000004 = .float ($height/$gameHeight)
[XCXAspectV100E_V101E] _aspectChangeCave = 0x0000008
moduleMatches = 0x218F6E07, 0xF882D5CF 0x0000008 = lis r7, _widthScaleRatio@ha
0x000000C = lfs f8, _widthScaleRatio@l(r7)
0x0000010 = fmuls f13, f13, f8
0x0000014 = lis r7, _heightScaleRatio@ha
0x0000018 = lfs f8, _heightScaleRatio@l(r7)
0x000001C = fmuls f9, f9, f8
# rodata constants 0x0000020 = fdivs f13, f13, f9
0x1003E754 = .float $width/$height 0x0000024 = blr
_aspectAddr = 0x1003E754
# Code changes
0x03160A68 = bla _aspectChangeCave
0x1003E754 = .float ($width/$height)
[XCXAspectV100U_V101U]
moduleMatches = 2878856811, 0x676EB33E
# Code cave
codeCaveSize = 0x0000028
_widthScaleRatio = 0x0000000
0x0000000 = .float ($width/$gameWidth)
_heightScaleRatio = 0x0000004
0x0000004 = .float ($height/$gameHeight)
_aspectChangeCave = 0x0000008
0x0000008 = lis r7, _widthScaleRatio@ha
0x000000C = lfs f8, _widthScaleRatio@l(r7)
0x0000010 = fmuls f13, f13, f8
0x0000014 = lis r7, _heightScaleRatio@ha
0x0000018 = lfs f8, _heightScaleRatio@l(r7)
0x000001C = fmuls f9, f9, f8
0x0000020 = fdivs f13, f13, f9
0x0000024 = blr
# Code changes
0x031608E8 = bla _aspectChangeCave
0x1003E754 = .float ($width/$height)
# 3d Aspect
0x03160AE4 = lis r7, _aspectAddr@ha
0x03160AE8 = lfs f13, _aspectAddr@l(r7)
[XCXAspectV100J] [XCXAspectV100J]
moduleMatches = 0x785CA8A9 moduleMatches = 0x785CA8A9
#rodata constants # Code cave
0x1003E6C4 = .float $width/$height codeCaveSize = 0x0000028
_aspectAddr = 0x1003E6C4
# 3d Aspect _widthScaleRatio = 0x0000000
0x0315687C = lis r7, _aspectAddr@ha 0x0000000 = .float ($width/$gameWidth)
0x03156880 = lfs f13, _aspectAddr@l(r7) _heightScaleRatio = 0x0000004
0x0000004 = .float ($height/$gameHeight)
_aspectChangeCave = 0x0000008
0x0000008 = lis r7, _widthScaleRatio@ha
0x000000C = lfs f8, _widthScaleRatio@l(r7)
0x0000010 = fmuls f13, f13, f8
0x0000014 = lis r7, _heightScaleRatio@ha
0x0000018 = lfs f8, _heightScaleRatio@l(r7)
0x000001C = fmuls f9, f9, f8
0x0000020 = fdivs f13, f13, f9
0x0000024 = blr
# Code changes
0x03156880 = bla _aspectChangeCave
0x1003E6C4 = .float ($width/$height)
[XCXAspectV101J] [XCXAspectV101J]
moduleMatches = 0x8780C48F moduleMatches = 0x8780C48F
#rodata constants # Code cave
0x1003E714 = .float $width/$height codeCaveSize = 0x0000028
_aspectAddr = 0x1003E714
# 3d Aspect _widthScaleRatio = 0x0000000
0x0315BBA4 = lis r7, _aspectAddr@ha 0x0000000 = .float ($width/$gameWidth)
0x0315BBA8 = lfs f13, _aspectAddr@l(r7) _heightScaleRatio = 0x0000004
0x0000004 = .float ($height/$gameHeight)
_aspectChangeCave = 0x0000008
0x0000008 = lis r7, _widthScaleRatio@ha
0x000000C = lfs f8, _widthScaleRatio@l(r7)
0x0000010 = fmuls f13, f13, f8
0x0000014 = lis r7, _heightScaleRatio@ha
0x0000018 = lfs f8, _heightScaleRatio@l(r7)
0x000001C = fmuls f9, f9, f8
0x0000020 = fdivs f13, f13, f9
0x0000024 = blr
# Code changes
0x0315BBA8 = bla _aspectChangeCave
0x1003E714 = .float ($width/$height)
[XCXAspectV102J] [XCXAspectV102J]
moduleMatches = 0x7672271D moduleMatches = 0x7672271D
#rodata constants # Code cave
0x1003E714 = .float $width/$height codeCaveSize = 0x0000028
_aspectAddr = 0x1003E714
# 3d Aspect _widthScaleRatio = 0x0000000
0x0315BE7C = lis r7, _aspectAddr@ha 0x0000000 = .float ($width/$gameWidth)
0x0315BE80 = lfs f13, _aspectAddr@l(r7) _heightScaleRatio = 0x0000004
0x0000004 = .float ($height/$gameHeight)
_aspectChangeCave = 0x0000008
0x0000008 = lis r7, _widthScaleRatio@ha
0x000000C = lfs f8, _widthScaleRatio@l(r7)
0x0000010 = fmuls f13, f13, f8
0x0000014 = lis r7, _heightScaleRatio@ha
0x0000018 = lfs f8, _heightScaleRatio@l(r7)
0x000001C = fmuls f9, f9, f8
0x0000020 = fdivs f13, f13, f9
0x0000024 = blr
# Code changes
0x0315BE80 = bla _aspectChangeCave
0x1003E714 = .float $width/$height