Skip to content

Commit

Permalink
TAS Record+Replay
Browse files Browse the repository at this point in the history
  • Loading branch information
Niko committed Oct 31, 2024
1 parent ed14cf6 commit 1899d3e
Show file tree
Hide file tree
Showing 8 changed files with 347 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mods/Windows/TasRecorder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vs
x64
159 changes: 159 additions & 0 deletions mods/Windows/TasRecorder/OculusTest/OculusTest.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{9b5b3d7b-aff4-4129-a606-d96743c6387b}</ProjectGuid>
<RootNamespace>OculusTest</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)\..\libs\LibOVR_v32\Include;$(SolutionDir)\..\libs\glm_v998</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)\..\libs\LibOVR_v32\Lib\Windows\x64\Release\VS2017</AdditionalLibraryDirectories>
<AdditionalDependencies>LibOVR.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)\..\libs\LibOVR_v32\Include;$(SolutionDir)\..\libs\glm_v998</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)\..\libs\LibOVR_v32\Lib\Windows\x64\Release\VS2017</AdditionalLibraryDirectories>
<AdditionalDependencies>LibOVR.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)\..\libs\LibOVR_v32\Include;$(SolutionDir)\..\libs\glm_v998</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)\..\libs\LibOVR_v32\Lib\Windows\x64\Release\VS2017</AdditionalLibraryDirectories>
<AdditionalDependencies>LibOVR.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)\..\libs\LibOVR_v32\Include;$(SolutionDir)\..\libs\glm_v998</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)\..\libs\LibOVR_v32\Lib\Windows\x64\Release\VS2017</AdditionalLibraryDirectories>
<AdditionalDependencies>LibOVR.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
22 changes: 22 additions & 0 deletions mods/Windows/TasRecorder/OculusTest/OculusTest.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
23 changes: 23 additions & 0 deletions mods/Windows/TasRecorder/OculusTest/OculusTest.vcxproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommandArguments>$(SolutionDir)\..\VirtualReality_Release</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\..\VirtualReality_Release</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommandArguments>$(SolutionDir)\..\VirtualReality_Release</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\..\VirtualReality_Release</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>$(SolutionDir)\..\VirtualReality_Release</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\..\VirtualReality_Release</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommandArguments>$(SolutionDir)\..\VirtualReality_Release</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>$(SolutionDir)\..\VirtualReality_Release</LocalDebuggerWorkingDirectory>
</PropertyGroup>
</Project>
92 changes: 92 additions & 0 deletions mods/Windows/TasRecorder/OculusTest/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#define _CRT_SECURE_NO_WARNINGS

#include <windows.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/common.hpp>
#include <glm/gtx/quaternion.hpp>

#include <stdio.h>
#include <math.h>
#include <OVR_CAPI.h>

#include <thread>

void startVR()
{
system("vr-screen-cap-CTR.exe");
}

int main()
{
char* pBuf = 0;
int mode = 0;

HWND console = GetConsoleWindow();
RECT r;
GetWindowRect(console, &r); //stores the console's current dimensions
MoveWindow(console, r.left, r.top, 480, 240 + 35, TRUE);

int pid;
printf("Enter DuckStation PID: ");
scanf("%d\n", &pid);

char duckName[100];
sprintf_s(duckName, 100, "duckstation_%d", pid);

TCHAR duckNameT[100];
swprintf(duckNameT, 100, L"%hs", duckName);

// 8mb RAM
const unsigned int size = 0x800000;
HANDLE hFile = OpenFileMapping(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, duckNameT);
pBuf = (char*)MapViewOfFile(hFile, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, size);

system("cls");
printf("1 - Save\n");
printf("2 - Load\n");
printf("Enter: ");

scanf("%d\n", &pid);

// SAVE mode
if (pid == 1)
{
printf("Saving...\n");

int sizeInt = *(int*)&pBuf[0xfff0];
FILE* fp = fopen("NewTAS.bin", "wb+");
fwrite(&pBuf[0x200000], 1, sizeInt * 4, fp);
fclose(fp);

printf("Saved as NewTAS.bin, you may rename the file\n");
}

else
{
system("cls");

char name[100];
scanf("%s\n", &name[0]);

FILE* fp;

fp = fopen(name, "rb");
fseek(fp, 0L, SEEK_END);
int sizeByte = ftell(fp);
fclose(fp);

fp = fopen(name, "rb");
fread(&pBuf[0x200000], 1, sizeByte, fp);
fclose(fp);

*(int*)&pBuf[0xfff4] = 1;

printf("Loaded %s, Replay Activated\n");
}

system("pause");
exit(0);
return 0;
}
31 changes: 31 additions & 0 deletions mods/Windows/TasRecorder/TasPlayer.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32328.378
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OculusTest", "OculusTest\OculusTest.vcxproj", "{9B5B3D7B-AFF4-4129-A606-D96743C6387B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9B5B3D7B-AFF4-4129-A606-D96743C6387B}.Debug|x64.ActiveCfg = Debug|x64
{9B5B3D7B-AFF4-4129-A606-D96743C6387B}.Debug|x64.Build.0 = Debug|x64
{9B5B3D7B-AFF4-4129-A606-D96743C6387B}.Debug|x86.ActiveCfg = Debug|Win32
{9B5B3D7B-AFF4-4129-A606-D96743C6387B}.Debug|x86.Build.0 = Debug|Win32
{9B5B3D7B-AFF4-4129-A606-D96743C6387B}.Release|x64.ActiveCfg = Release|x64
{9B5B3D7B-AFF4-4129-A606-D96743C6387B}.Release|x64.Build.0 = Release|x64
{9B5B3D7B-AFF4-4129-A606-D96743C6387B}.Release|x86.ActiveCfg = Release|Win32
{9B5B3D7B-AFF4-4129-A606-D96743C6387B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {78A40A39-829C-4FCF-A32D-B6A41C23B018}
EndGlobalSection
EndGlobal
18 changes: 18 additions & 0 deletions mods/Windows/TasRecorder_Release/Directions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Recording a TAS:
Open the modded ROM in DuckStation
Play any 1P mode (multiplayer comes later)
Do NOT close DuckStation before saving
Open TasRecorder.exe at end of session
Press 1 to Save
The file NewTAS.bin will be saved
Wait for completion message
Rename to anything you want

Replaying a TAS:
Open the modded ROM in DuckStation
Pause the emulator when you see SCEA page
Open TasRecorder.exe
Press 2 to Load
Type NewTAS.bin or whatever name
Wait for completion message
Resume the emulator
Binary file not shown.

0 comments on commit 1899d3e

Please sign in to comment.