Skip to content

Commit

Permalink
tcnyc ps2 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Jun 12, 2024
1 parent b9d8e8e commit 008c44e
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 8 deletions.
29 changes: 24 additions & 5 deletions .github/docs/truecrimenyc.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![truecrimenyc](https://thirteenag.github.io/screens/truecrimenyc/main2.jpg)
![truecrimenyc](http://thirteenag.github.io/screens/truecrimenyc/main2.jpg)

![](https://habrastorage.org/webt/ow/yy/mg/owyymgpibfqzfbwyf_iqoiqrede.png) Fixed Resolution

Expand All @@ -10,9 +10,28 @@

![](https://habrastorage.org/webt/ow/yy/mg/owyymgpibfqzfbwyf_iqoiqrede.png) Fixed FMVs

Installation:
Download and extract the archive to the game directory, where the exe is located.
## **PCSX2F: True Crime New York City Widescreen Fix (BETA):**

[Website](https://thirteenag.github.io/wfp#truecrimenyc) | [Source](https://github.com/ThirteenAG/WidescreenFixesPack/blob/master/source/TrueCrimeNewYorkCity.WidescreenFix/dllmain.cpp) | [Default INI File](https://github.com/ThirteenAG/WidescreenFixesPack/blob/master/data/TrueCrimeNewYorkCity.WidescreenFix/scripts/TrueCrimeNewYorkCity.WidescreenFix.ini)
One version of the game is compatible, **SLUS-21106** (crc: **42A9C4EC**).

<a href="https://github.com/sponsors/ThirteenAG"><img src="https://img.shields.io/badge/Sponsor_me_on_GitHub-5c5c5c?style=for-the-badge&logo=github&logoColor=white" width="250"></a><br><a href="https://ko-fi.com/thirteenag"><img src="https://img.shields.io/badge/Support_me_on_Ko--Fi-ff5e5b?style=for-the-badge&logo=kofi&logoColor=white" width="250"></a><br><a href="https://paypal.me/SergeyP13"><img src="https://img.shields.io/badge/Donate_with_PayPal-009cde?style=for-the-badge&logo=paypal&logoColor=white" width="250"></a><br><a href="https://www.patreon.com/ThirteenAG"><img src="https://img.shields.io/badge/Support_me_on_Patreon-ff424d?style=for-the-badge&logo=patreon&logoColor=white" width="250"></a><br><a href="https://boosty.to/thirteenag/donate"><img src="https://img.shields.io/badge/Support_me_on_Boosty-f15e2d?style=for-the-badge&logo=data:image/png;base64,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&logoColor=white" width="250"></a>
Installation:

- Download and extract [PCSX2 Fork With Plugins](https://github.com/ASI-Factory/PCSX2-Fork-With-Plugins/releases/tag/latest).
- Download and extract plugin archive to the root directory, where exe is located.
- Change the aspect ratio or window size of the emulator.
- Launch the game.
- Do **not** set native widescreen option to ON.

This plugin is a backport from pc version, and it's untested.

![](https://habrastorage.org/webt/ow/yy/mg/owyymgpibfqzfbwyf_iqoiqrede.png) Fixed Aspect Ratio

![](https://habrastorage.org/webt/ow/yy/mg/owyymgpibfqzfbwyf_iqoiqrede.png) Fixed HUD

![](https://habrastorage.org/webt/ow/yy/mg/owyymgpibfqzfbwyf_iqoiqrede.png) Fixed Field of View

![truecrimenycpcsx2f](https://github.com/ThirteenAG/WidescreenFixesPack/assets/4904157/085e488d-957e-4827-9ad4-5459861ef5db)
![truecrimenycpcsx2f](https://github.com/ThirteenAG/WidescreenFixesPack/assets/4904157/9d76f723-fca3-4d38-887f-5cf0d4f05045)


[Website](http://thirteenag.github.io/wfp#truecrimenyc) | [Source](https://github.com/ThirteenAG/WidescreenFixesPack/blob/master/source/TrueCrimeNewYorkCity.WidescreenFix/dllmain.cpp) | [Default INI File](https://github.com/ThirteenAG/WidescreenFixesPack/blob/master/data/TrueCrimeNewYorkCity.WidescreenFix/scripts/TrueCrimeNewYorkCity.WidescreenFix.ini)
2 changes: 1 addition & 1 deletion .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
tag_list: ${{ format('{0},{1}', github.event.inputs.tag_list, inputs.tag_list) }}
tag: truecrimenyc
artifacts: data/Archives/TrueCrimeNewYorkCity.WidescreenFix.zip
artifacts: data/Archives/TrueCrimeNewYorkCity.WidescreenFix.zip, data/Archives/TrueCrimeNewYorkCity.PCSX2F.WidescreenFix.zip

- name: Stubbs the Zombie Widescreen Fix
uses: ./.github/workflows/release_tag
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ env:
thug: "/t:TonyHawksUnderground_WidescreenFix"
thug2: "/t:TonyHawksUnderground2_WidescreenFix"
tod: "/t:TotalOverdose_WidescreenFix"
truecrimenyc: "/t:TrueCrimeNewYorkCity_WidescreenFix"
truecrimenyc: "/t:TrueCrimeNewYorkCity_WidescreenFix /t:TrueCrimeNewYorkCity_PCSX2F_WidescreenFix"
truecrimesola: "/t:TrueCrimeStreetsofLA_WidescreenFix"
xrd: "/t:PPSSPP_XboxRainDroplets /t:PCSX2F_XboxRainDroplets"
usm: "/t:UltimateSpiderMan_WidescreenFix"
Expand Down
Empty file.
14 changes: 13 additions & 1 deletion premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ project "Assembly64.TestApp"
targetextension ".exe"
platforms { "Win64" }
architecture "x64"
setpaths("./data/%{prj.name}", "%{prj.name}.exe", "")
setpaths("./data/%{prj.name}/", "%{prj.name}.exe", "")
project "Assembly64.TestAsi"
platforms { "Win64" }
architecture "x64"
Expand Down Expand Up @@ -648,6 +648,18 @@ project "TotalOverdose.WidescreenFix"
setpaths("Z:/WFP/Games/Total Overdose/", "TOD.exe")
project "TrueCrimeNewYorkCity.WidescreenFix"
setpaths("Z:/WFP/Games/True Crime New York City/", "True Crime New York City.exe")
project "TrueCrimeNewYorkCity.PCSX2F.WidescreenFix"
kind "Makefile"
dependson { "SplinterCellDoubleAgent.PCSX2F.WidescreenFix" }
includedirs { "external/ps2sdk/ps2sdk/ee" }
files { "source/%{prj.name}/*.h" }
files { "source/%{prj.name}/*.c", "source/%{prj.name}/makefile" }
targetextension ".elf"
setbuildpaths_ps2("Z:/GitHub/PCSX2-Fork-With-Plugins/bin/", "pcsx2x64.exe", "PLUGINS/", "%{wks.location}/../external/ps2sdk/ee/bin/vsmake.ps1", "%{wks.location}/../source/%{prj.name}/", "TrueCrimeNewYorkCity.PCSX2F.WidescreenFix")
writemakefile_ps2("TrueCrimeNewYorkCity.PCSX2F.WidescreenFix", "PLUGINS/", "0x02100000", "-l:libc.a -l:libm.a -l:libgcc.a", "../../includes/pcsx2/log.o",
"../../includes/pcsx2/memalloc.o", "../../includes/pcsx2/patterns.o", "../../includes/pcsx2/injector.o", "../../includes/pcsx2/rini.o",
"../../includes/pcsx2/inireader.o", "../../includes/pcsx2/mips.o")
writelinkfile_ps2("TrueCrimeNewYorkCity.PCSX2F.WidescreenFix")
project "TrueCrimeStreetsofLA.WidescreenFix"
setpaths("Z:/WFP/Games/True Crime Streets of LA/", "TrueCrimeMB.exe")
project "UltimateSpiderMan.WidescreenFix"
Expand Down
170 changes: 170 additions & 0 deletions source/TrueCrimeNewYorkCity.PCSX2F.WidescreenFix/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#include <stdio.h>
#include <stdint.h>
#include <math.h>

#include "../../includes/pcsx2/pcsx2f_api.h"
#include "../../includes/pcsx2/log.h"
#include "../../includes/pcsx2/injector.h"
#include "../../includes/pcsx2/inireader.h"
#include "../../includes/pcsx2/patterns.h"

int CompatibleCRCList[] = { 0x42A9C4EC };
int CompatibleElfCRCList[] = { 0x42A9C4EC, 0x1118ACD0 };
int PCSX2Data[PCSX2Data_Size] = { 1 };
char OSDText[OSDStringNum][OSDStringSize] = { {1} };
char PluginData[MaxIniSize] = { 1 };

struct ScreenX
{
int32_t nWidth;
int32_t nHeight;
float fWidth;
float fHeight;
float fAspectRatio;
float f3DScale;
float fHudScale;
float fHudOffset;
} Screen;

void __fastcall HudScaleX(int a1, int a2)
{
if (a2 == 640)
a2 = (int)(640.0f * Screen.fHudScale);

*(int*)(a1 + 0xD0) = a2;
*(float*)(a1 + 0xD8) = (float)a2 * 0.0015625f;
*(float*)(a1 + 0xE0) = 1.0 / (float)a2;
}

void init()
{
//logger.SetBuffer(OSDText, sizeof(OSDText) / sizeof(OSDText[0]), sizeof(OSDText[0]));
//logger.Write("Loading TrueCrimeNewYorkCity.PCSX2F.WidescreenFix...");

inireader.SetIniPath((char*)PluginData + sizeof(uint32_t), *(uint32_t*)PluginData);

int SkipIntro = inireader.ReadInteger("MAIN", "SkipIntro", 1);

if (SkipIntro)
{
uintptr_t ptr_100350 = pattern.get(0, "2D 20 40 02 ? ? ? ? 2D 40 20 02", -4);

if (ptr_100350 != 0)
{
//logger.Write("Skipping intro...");
injector.MakeNOP(ptr_100350);
return;
}
}

uint32_t DesktopSizeX = PCSX2Data[PCSX2Data_DesktopSizeX];
uint32_t DesktopSizeY = PCSX2Data[PCSX2Data_DesktopSizeY];
Screen.nWidth = PCSX2Data[PCSX2Data_WindowSizeX];
Screen.nHeight = PCSX2Data[PCSX2Data_WindowSizeY];
Screen.fWidth = (float)Screen.nWidth;
Screen.fHeight = (float)Screen.nHeight;
uint32_t IsFullscreen = PCSX2Data[PCSX2Data_IsFullscreen];
uint32_t AspectRatioSetting = PCSX2Data[PCSX2Data_AspectRatioSetting];

if (IsFullscreen || !Screen.nWidth || !Screen.nHeight)
{
Screen.nWidth = DesktopSizeX;
Screen.nHeight = DesktopSizeY;
}

switch (AspectRatioSetting)
{
case RAuto4_3_3_2: //not implemented
//if (GSgetDisplayMode() == GSVideoMode::SDTV_480P)
// AspectRatio = 3.0f / 2.0f;
//else
Screen.fAspectRatio = 4.0f / 3.0f;
break;
case R4_3:
Screen.fAspectRatio = 4.0f / 3.0f;
break;
case R16_9:
Screen.fAspectRatio = 16.0f / 9.0f;
break;
case Stretch:
default:
Screen.fAspectRatio = Screen.fWidth / Screen.fHeight;
break;
}

//logger.WriteF("Resolution: %dx%d", Screen.nWidth, Screen.nHeight);
//logger.WriteF("Aspect Ratio: %f", Screen.fAspectRatio);

float intResX = 640.0f;
float intResY = 480.0f;

Screen.fHudScale = (((intResX / intResY)) / (Screen.fAspectRatio));
Screen.fHudOffset = (1.0f / (448.0f * (4.0f / 3.0f))) * (((448.0f * Screen.fAspectRatio) - 448.0f * (4.0f / 3.0f)) / 2.0f);
Screen.f3DScale = (((intResX / intResY)) / (Screen.fAspectRatio));

//3D Scaling
injector.MakeInlineLUIORI(0x01D97FC, 0.0015625f * Screen.fHudScale); // 3d
injector.MakeInlineLUIORI(0x0204DD8, 0.0015625f * Screen.fHudScale); // or this

//Hud Scaling
//injector.MakeInlineLUIORI(0x020BA4C, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x02346FC, 0.0015625f * Screen.fHudScale); // ui 1
//injector.MakeInlineLUIORI(0x023830C, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x023AF68, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x023B4D8, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x023E524, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x02432EC, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x02434E8, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0243B00, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0244214, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x024422C, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x02442E0, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0244628, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x02447E8, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0244B18, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0247D58, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0247DA8, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0248210, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0248774, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x02EDDF4, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0318A78, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0325ABC, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x03F3964, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x0449CAC, 0.0015625f * Screen.fHudScale);
//injector.MakeInlineLUIORI(0x04A3AFC, 0.0015625f * Screen.fHudScale);

// Hud Pos
float f = Screen.fHudOffset;
MakeInlineWrapperWithNOP(0x233DA4,
lui(v0, HIWORD(f)),
ori(v0, v0, LOWORD(f)),
sw(v0, sp, 0x24)
);

injector.MakeJAL(0x204E74, (uintptr_t)HudScaleX);
injector.MakeJAL(0x233644, (uintptr_t)HudScaleX);
injector.MakeJAL(0x2336F4, (uintptr_t)HudScaleX);
injector.MakeJAL(0x23389C, (uintptr_t)HudScaleX);
injector.MakeJAL(0x2346AC, (uintptr_t)HudScaleX); // ui stretch
injector.MakeJAL(0x234990, (uintptr_t)HudScaleX);
injector.MakeJAL(0x2349CC, (uintptr_t)HudScaleX);
injector.MakeJAL(0x2349EC, (uintptr_t)HudScaleX);
injector.MakeJAL(0x255C58, (uintptr_t)HudScaleX);
injector.MakeJAL(0x26FBF8, (uintptr_t)HudScaleX);
injector.MakeJAL(0x270338, (uintptr_t)HudScaleX);
injector.MakeJAL(0x2752A8, (uintptr_t)HudScaleX);
injector.MakeJAL(0x275330, (uintptr_t)HudScaleX); //background ui
injector.MakeJAL(0x2C0690, (uintptr_t)HudScaleX);
injector.MakeJAL(0x2C0BA8, (uintptr_t)HudScaleX);
injector.MakeJAL(0x49FE6C, (uintptr_t)HudScaleX);
injector.MakeJAL(0x49FEB8, (uintptr_t)HudScaleX);


//logger.Write("TrueCrimeNewYorkCity.PCSX2F.WidescreenFix loaded");
//logger.ClearLog();
}

int main()
{
return 0;
}
22 changes: 22 additions & 0 deletions source/TrueCrimeNewYorkCity.PCSX2F.WidescreenFix/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
EE_BIN = ../../data/TrueCrimeNewYorkCity.PCSX2F.WidescreenFix/PLUGINS/TrueCrimeNewYorkCity.PCSX2F.WidescreenFix.elf
EE_OBJS = main.o ../../includes/pcsx2/log.o ../../includes/pcsx2/memalloc.o ../../includes/pcsx2/patterns.o ../../includes/pcsx2/injector.o ../../includes/pcsx2/rini.o ../../includes/pcsx2/inireader.o ../../includes/pcsx2/mips.o

CFLAGS = -O0 -Os -G0 -Wall -fshort-wchar -fno-pic -mno-check-zero-division -fpack-struct=16
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

BASE_ADDRESS = 0x02100000
EE_LINKFILE = linkfile
EE_LIBS += -l:libc.a -l:libm.a -l:libgcc.a
EE_LDFLAGS = -Wl,--entry=init -Wl,-Map,../../data/TrueCrimeNewYorkCity.PCSX2F.WidescreenFix/PLUGINS/TrueCrimeNewYorkCity.PCSX2F.WidescreenFix.map -Wl,-exclude-libs,ALL -Wl,'--defsym=BASE_ADDRESS=$(BASE_ADDRESS)'

all: clean main-build

main-build: $(EE_BIN)

clean:
rm -f $(EE_OBJS) $(EE_BIN)

PS2SDK = ../../external/ps2sdk/ps2sdk
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal

0 comments on commit 008c44e

Please sign in to comment.