From ed716d6907ca32a5ada9806c67e29483dab5f33f Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 28 Mar 2023 10:53:23 +0300 Subject: [PATCH] initial self support (self header) --- .gitignore | 1 + emulator/emulator.vcxproj | 144 ++++++++++++++++++++++++++++++ emulator/emulator.vcxproj.filters | 27 ++++++ emulator/main.cpp | 71 +++++++++++++++ emulator/types.h | 14 +++ shadps4.sln | 31 +++++++ 6 files changed, 288 insertions(+) create mode 100644 emulator/emulator.vcxproj create mode 100644 emulator/emulator.vcxproj.filters create mode 100644 emulator/main.cpp create mode 100644 emulator/types.h create mode 100644 shadps4.sln diff --git a/.gitignore b/.gitignore index 517c46c6..e5b75453 100644 --- a/.gitignore +++ b/.gitignore @@ -401,3 +401,4 @@ FodyWeavers.xsd /tools/pkg extractor/game/* /tools/pkg extractor/*.pkg /shadPS4/shadps4.ini +/emulator/eboot.bin diff --git a/emulator/emulator.vcxproj b/emulator/emulator.vcxproj new file mode 100644 index 00000000..6806016b --- /dev/null +++ b/emulator/emulator.vcxproj @@ -0,0 +1,144 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {a9f02793-712d-4602-bf3f-14473d492952} + emulator + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + shadps4 + + + shadps4 + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/emulator/emulator.vcxproj.filters b/emulator/emulator.vcxproj.filters new file mode 100644 index 00000000..bcb8ec23 --- /dev/null +++ b/emulator/emulator.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Source Files + + + \ No newline at end of file diff --git a/emulator/main.cpp b/emulator/main.cpp new file mode 100644 index 00000000..be3fa0f3 --- /dev/null +++ b/emulator/main.cpp @@ -0,0 +1,71 @@ +#include "types.h" +#include + +#pragma warning(disable:4996) + +struct self_header +{ + static const u32 signature = 0x1D3D154Fu; + + u32 magic; + u08 version; + u08 mode; + u08 endian;// 1 is little endian + u08 attributes; + u08 category; + u08 program_type; + u16 padding1; + u16 header_size; + u16 meta_size; + u32 file_size; + u32 padding2; + u16 segment_count; + u16 unknown1A; //always 0x22 + u32 padding3; +}; + + + +int main(int argc, char* argv[]) +{ + const char* const path = argv[1]; //argument 1 is the path of self file to boot + + auto handle = fopen(path, "rb"); + if (handle == nullptr) + { + printf("Failed to open file.\n"); + return 2; + } + + self_header header; + if (fread(&header, sizeof(self_header), 1, handle) != 1) + { + printf("Failed to read SELF header.\n"); + fclose(handle); + return 3; + } + + if (header.magic != self_header::signature) + { + printf("Not a SELF file.\n"); + fclose(handle); + return 4; + } + + printf("SELF header:\n"); + printf(" magic ..............: 0x%08X\n", header.magic); + printf(" version .........: %d\n", header.version); + printf(" mode .........: 0x%X\n", header.mode); + printf(" endian .........: %d\n", header.endian); + printf(" attributes .........: 0x%X\n", header.attributes); + printf(" category .........: 0x%X\n", header.category); + printf(" program_type........: 0x%X\n", header.program_type); + printf(" header size ........: 0x%X\n", header.header_size); + printf(" meta size .....: 0x%X\n", header.meta_size); + printf(" file size ..........: 0x%X\n", header.file_size); + printf(" padding2 ...........: 0x%08X\n", header.padding2); + printf(" segment count ......: %u\n", header.segment_count); + printf(" unknown 1A .........: 0x%04X\n", header.unknown1A); + printf(" padding3 ...........: 0x%04X\n", header.padding3); + printf("\n"); +} diff --git a/emulator/types.h b/emulator/types.h new file mode 100644 index 00000000..64a05f85 --- /dev/null +++ b/emulator/types.h @@ -0,0 +1,14 @@ +#pragma once + +using s08 = char; +using s16 = short; +using s32 = int; +using s64 = long long; + +using u08 = unsigned char; +using u16 = unsigned short; +using u32 = unsigned int; +using u64 = unsigned long long; + +using f32 = float; +using f64 = double; \ No newline at end of file diff --git a/shadps4.sln b/shadps4.sln new file mode 100644 index 00000000..640bb8b8 --- /dev/null +++ b/shadps4.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "emulator", "emulator\emulator.vcxproj", "{A9F02793-712D-4602-BF3F-14473D492952}" +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 + {A9F02793-712D-4602-BF3F-14473D492952}.Debug|x64.ActiveCfg = Debug|x64 + {A9F02793-712D-4602-BF3F-14473D492952}.Debug|x64.Build.0 = Debug|x64 + {A9F02793-712D-4602-BF3F-14473D492952}.Debug|x86.ActiveCfg = Debug|Win32 + {A9F02793-712D-4602-BF3F-14473D492952}.Debug|x86.Build.0 = Debug|Win32 + {A9F02793-712D-4602-BF3F-14473D492952}.Release|x64.ActiveCfg = Release|x64 + {A9F02793-712D-4602-BF3F-14473D492952}.Release|x64.Build.0 = Release|x64 + {A9F02793-712D-4602-BF3F-14473D492952}.Release|x86.ActiveCfg = Release|Win32 + {A9F02793-712D-4602-BF3F-14473D492952}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5ED4FBB3-A0BC-4244-B8FE-93A2BF2C1C9A} + EndGlobalSection +EndGlobal