How does a real Sony PlayStation 4 console really work?

GAMEBOYADVANCETEMPORARY

Well-Known Member
OP
Newcomer
Joined
Sep 23, 2022
Messages
51
Trophies
0
Age
29
Location
Bat Yam
XP
220
Country
Israel
I want to develop a Sony PlayStation 4 emulator from scratch by using Visual Studio 2022 Preview Enterprise Edition but I don't know how or where to start.

I already know how to program and develop Visual C++ applications with Visual Studio.

But I must know how a real Sony PlayStation 4 console really work, how does a real Sony PlayStation 4 console reads a Sony PlayStation 4 disc and how a real Sony PlayStation 4 console plays a Sony PlayStation 4 rom/game from a Sony PlayStation 4 disc.

Is Sony PlayStation 4 documented somewhere?
 
Last edited by GAMEBOYADVANCETEMPORARY,

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,321
Country
United Kingdom
C++ is useful in this, maybe even essential (not having oop options in making an emulator like this is a nightmare), but it is far from the whole story.

There are three, maybe four approaches to making an emulator.

1) Classic emulation. However many chips there are you recreate what their outputs are for a given input, and get it all timed reasonably well, possibly plus BIOS/firmware (though if you want to kick it to those ripped from a PS4 then so it goes). The PS4 is largely X64 based which is nice as it is a well documented assembly language. General rule of thumb was you need a machine 10x more powerful than the emulated system to even consider this, most PCs are not that.

2) Dynamic recompilation aka dynarec and other translation efforts. Harder with most modern code but still reasonable enough. It was realised in the leap to the 32bit/PS1/N64 generation that most code was written in C family code and then compiled for what its target was. With enough analysis of the static code to determine patterns you could take the code as found at runtime and convert it into instructions for the host system without needing all the overhead of emulation and simulation approaches to the point where today most consider this their primary approach.
Similarly there are only so many ways to sensibly do 2d graphics and 3d graphics, and indeed the consoles tend to use at least similar APIs to more conventional/open devices, and to that end you can convert calls for one API into a one on the host system if you can figure out the list of them and determine a suitable conversion.

3) Simulation. Like 1 but rather than hoping you get the timings right, or going for game specific hacks, you actually simulate the chip at transistor level. Not much good for play emulators but cheat making, hacking, homebrew, debugging and such could seriously benefit. Mind you speed wise this will be abysmal -- 6502 (as seen on the NES) is a system grinder and you are going to be orders of magnitude greater.

4) is same but offloaded to other things like FPGAs and other processing enhancement devices you might stick in the PCIE ports (back during the PS3 it was noted IBM sold Cell chips you could put in the PCIE port for instance).
 

Randqalan

The Wheel of Time Turns
Member
Joined
Jan 25, 2014
Messages
1,077
Trophies
1
Location
M00N Base quanto
XP
2,037
Country
United States
No Jit c or c+ to compassionate for floating on call to actually respond. I like the above response but there are ways and ways. Do your research for what you know and compare what is required everything is really binary. So if you can find words for on to other it will work but remember if you forget even a 0 or an 1 some code translation will be off.
 

KuntilanakMerah

Well-Known Member
Member
Joined
Dec 14, 2021
Messages
203
Trophies
0
Age
25
XP
272
Country
Australia
But I must know how a real Sony PlayStation 4 console really work, how does a real Sony PlayStation 4 console reads a Sony PlayStation 4 disc and how a real Sony PlayStation 4 console plays a Sony PlayStation 4 rom/game from a Sony PlayStation 4 disc.
Just insert ps4 disc you just buy into your ps4 console, and you will see some spinning cd images floated on your tv and it read whole disc after that select the game icons on your screen and press X button and voila the games perfectly loaded
Is Sony PlayStation 4 documented somewhere?
if you buy ps4 you'll see ps4 user manual inside the box
 

Hanafuda

Well-Known Member
Member
Joined
Nov 21, 2005
Messages
4,492
Trophies
2
XP
6,951
Country
United States
hlIHngF.jpg
 

GAMEBOYADVANCETEMPORARY

Well-Known Member
OP
Newcomer
Joined
Sep 23, 2022
Messages
51
Trophies
0
Age
29
Location
Bat Yam
XP
220
Country
Israel
on a serious note, best way is probably psdevwiki. that's a repository of what people have found out about the ps3 and the ps4.
psdevwiki is exactly what I was looking for! Thank you so much!

And I see that there are a lot to be done! I consider to create an utility that creates a window exe file from a Sony PlayStation 4 iso file.

If Sony PlayStation 4 is really X64 as you say then good for me that the tool doesn't have to translate the opcodes from one processor to another.

I think that the main focus is to change all the system calls to call windows functions rather than Sony PlayStation 4 functions.
 
Last edited by GAMEBOYADVANCETEMPORARY,

GAMEBOYADVANCETEMPORARY

Well-Known Member
OP
Newcomer
Joined
Sep 23, 2022
Messages
51
Trophies
0
Age
29
Location
Bat Yam
XP
220
Country
Israel
Start with something a little less complex than PS4? Chip-8 is what most people suggest.
Chip-8 is not a little less complex than PS4 but in fact Chip-8 is very much less complex than PS4.

Also this is pointless to make another Chip-8 emulator when there are plenty Chip-8 emulators which can be googled for free.

I do can read the source code of these existing Chip-8 emulators to learn the basics of hardware emulation which I already know.

This is more meaningful to make an emulator for a hardware that you can't google a complete working emulator for it like the Sony PlayStation 4 hardware.

But to do this I need more information about the Sony PlayStation 4 hardware, how it works, how it reads the PS4 disc and plays it on screen.

psdevwiki provides this information and my emulator will be based on what psdevwiki has to tell about Sony PlayStation 4.

But thank you so much for your suggestion!
 

GAMEBOYADVANCETEMPORARY

Well-Known Member
OP
Newcomer
Joined
Sep 23, 2022
Messages
51
Trophies
0
Age
29
Location
Bat Yam
XP
220
Country
Israel
The PS4 disc is the least of your worries, you need to boot the PS4 OS first.
psdevwiki probably explains how does the PS4 OS work but rpcs3 has a list view that shows all installed PS3 roms and double click the installed PS3 rom to boot it.

PS3 also has an OS like PS4 but it is not playable with rpcs3 and no PS3 rom is booted from this PS3 OS in rpcs3.

For a start my PS4 emulator will work as how rpcs3 does.

Show a list view of all installed PS4 roms and double click the installed PS4 rom to boot it.

Unlike rpcs3, my PS4 emulator won't show a preview image of the installed PS4 rom. Maybe at a later version when my PS4 emulator is working very well done.

At the beginning only the name of the installed PS4 rom will be shown in the list view of all installed PS4 roms as a label.

But of course that the OS must be still booted and emulated in order to boot and emulate the rom.

EDIT:

rpcs3 has a "Boot VSH/XMB" command in the "File" menu which makes the PS3 OS playable but still no PS3 rom can be booted due the fact that rpcs3 still does not support multiprocessing (running at least two processes simultaneously).

But my PS4 emulator won't have any "Boot VSH/XMB" until it is working very well done.

At least work as good as rpcs3 does in OS & rom emulation.
 
Last edited by GAMEBOYADVANCETEMPORARY,

BanthonyHopkins

Member
Newcomer
Joined
Apr 11, 2022
Messages
5
Trophies
0
Age
45
Location
Mars
XP
181
Country
United Kingdom
Okay... so you need to take a step back. Sorry but I do not think you know what you are trying to undertake.

There are a TON of things that you would need in order to get (3D accelerated) commercial games to work, and it's probably just not possible yet with the information we have on the PlayStation 4 AMD APU and other weird chipsets.

1. There is no 3D accelerator on the market that acts exactly like the PS4 APU - it is a heavily modified Jaguar+Radeon APU+chipset, with no 'on-die' north/southbridge, or IRC timing components you'd find in a normal PC (). You will have to be translating the weird GL / transfer operations from the game code into the emulated GPU, and then into something like native OpenGL on the host, which I don't think is fully understood yet. Assuming we even have fast enough memory/bus to "emulate" this process yet.

2. You'll to create a process that virutalises the weird IOMMU bridge between PCI-Express and the APU, which even the PS4 Linux developers do not fully understand ()

3. There are the "Onion" and "Garlic" buses between the memory and the GPU which are non-standard and operate at something stupid like 180gibs. There is nothing that fast yet on x86-xx commercial PCs - you'd probably have to scrape and load most of the required graphic assets, for the specific scene, into memory, of which most people/devices won't have enough.

4. Security. Running straight from an unmodified PS4 ISO is probably impossible - there's a lot going on here. There is a security co-processor on the APU die that is not fully understood yet. The game is expecting when it "asks" to execute something, that the Orbis OS is going to facilitate decrypting and verifying the binary (or section thereof), and then jumping to it. You can decrypt the whole ISO, but then you are going to need to patch on-the-fly all of these checks, such that the game believes it is running on real hardware, and running correctly. This is not easy and takes years to even get some kind of display on the screen. You will also be having to manage writeable or executable pages in the same way that the PS4 does, which is likely to also be extremely custom and emulating it will drop performance. If you want to do this 'natively', you would probably be designing your emulator to just ignore this, however most modern OS will not allow it - so to even get the emulator to run, you'd be asking users to disable OS security features which might not even be possible.

5. The OS and subsystems. The game executable is going to be constantly trying to read license info and anti-piracy, PSN connection, friends list, identity, sockets, devices, other stuff. You have to trap and emulate returns for all of this, and reversing these calls is mostly just trial and error with lots of luck mixed in.

6. Instruction set. The PS4 is a "off shelf" (in quotes) AMD Jaguar CPU, but there is bound to be a bunch of extra instructions that Sony asked for, probably for performance and security functions, that will just lob illegal_instruction exceptions and catch fire. You'd need to patch all of these out on-the-fly with equivalent routines; this may DUNK performance as well, depending on what else is going on.

If you have never written an actual "emulator" of anything before, definitely start with trying to emulate some pico gpio processor, not a massive commercial game console on which thousands of people spent years producing.
 
Last edited by BanthonyHopkins,
  • Like
Reactions: komabear

GAMEBOYADVANCETEMPORARY

Well-Known Member
OP
Newcomer
Joined
Sep 23, 2022
Messages
51
Trophies
0
Age
29
Location
Bat Yam
XP
220
Country
Israel
Okay... so you need to take a step back. Sorry but I do not think you know what you are trying to undertake.

There are a TON of things that you would need in order to get (3D accelerated) commercial games to work, and it's probably just not possible yet with the information we have on the PlayStation 4 AMD APU and other weird chipsets.

1. There is no 3D accelerator on the market that acts exactly like the PS4 APU - it is a heavily modified Jaguar+Radeon APU+chipset, with no 'on-die' north/southbridge, or IRC timing components you'd find in a normal PC (). You will have to be translating the weird GL / transfer operations from the game code into the emulated GPU, and then into something like native OpenGL on the host, which I don't think is fully understood yet. Assuming we even have fast enough memory/bus to "emulate" this process yet.

2. You'll to create a process that virutalises the weird IOMMU bridge between PCI-Express and the APU, which even the PS4 Linux developers do not fully understand ()

3. There are the "Onion" and "Garlic" buses between the memory and the GPU which are non-standard and operate at something stupid like 180gibs. There is nothing that fast yet on x86-xx commercial PCs - you'd probably have to scrape and load most of the required graphic assets, for the specific scene, into memory, of which most people/devices won't have enough.

4. Security. Running straight from an unmodified PS4 ISO is probably impossible - there's a lot going on here. There is a security co-processor on the APU die that is not fully understood yet. The game is expecting when it "asks" to execute something, that the Orbis OS is going to facilitate decrypting and verifying the binary (or section thereof), and then jumping to it. You can decrypt the whole ISO, but then you are going to need to patch on-the-fly all of these checks, such that the game believes it is running on real hardware, and running correctly. This is not easy and takes years to even get some kind of display on the screen. You will also be having to manage writeable or executable pages in the same way that the PS4 does, which is likely to also be extremely custom and emulating it will drop performance. If you want to do this 'natively', you would probably be designing your emulator to just ignore this, however most modern OS will not allow it - so to even get the emulator to run, you'd be asking users to disable OS security features which might not even be possible.

5. The OS and subsystems. The game executable is going to be constantly trying to read license info and anti-piracy, PSN connection, friends list, identity, sockets, devices, other stuff. You have to trap and emulate returns for all of this, and reversing these calls is mostly just trial and error with lots of luck mixed in.

6. Instruction set. The PS4 is a "off shelf" (in quotes) AMD Jaguar CPU, but there is bound to be a bunch of extra instructions that Sony asked for, probably for performance and security functions, that will just lob illegal_instruction exceptions and catch fire. You'd need to patch all of these out on-the-fly with equivalent routines; this may DUNK performance as well, depending on what else is going on.

If you have never written an actual "emulator" of anything before, definitely start with trying to emulate some pico gpio processor, not a massive commercial game console on which thousands of people spent years producing.

This is the answer that I was looking for! Thank you!
I wanted to know the true complexity and difficulty of emulating the Sony PlayStation 4 and you gave me the answer that I was seeking!

The Nintendo Switch and Xbox One are not as hard as Sony PlayStation 4 since Nintendo Switch already has two emulators, YuZu and Ryujinx and Xbox One also has at least one emulator.

And if all the Sony PlayStation 4 isos are really encrypted as you say then I can't start my Sony PlayStation 4 emulator project until I know how to decrypt these Sony PlayStation 4 isos first.

If emulating the Sony PlayStation 4 is really so hard and nightmare then why the developer of KyTy believes that he or she will emulate the Sony PlayStation 5 at all?
 

godreborn

Welcome to the Machine
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
you're basically making fake pkgs, having samu do everything for you including decryption. you'd need the emulator to use fself. passcode is irrelevant, but most fake pkgs use all 0's, but that's not needed. I think it gets that info from the license.dat. I know al azif told me that the key to all pkgs is the passcode, so everything related to the pkgs is derived from it including the keystone which is a fingerprint of the passcode. now, that I don't know how you can emulate unless the pkg is all 0's. we know what that fingerprint looks like, but I don't know if the algorithm is known or if we can reverse the process.
Post automatically merged:

plus, from what I've heard, the ps5 is almost identical to the ps4, just different keys and security, but the process is the same, so that might be why he thinks a ps5 emulator is possible. it will likely use fself again and have the system do all the work.
 

GAMEBOYADVANCETEMPORARY

Well-Known Member
OP
Newcomer
Joined
Sep 23, 2022
Messages
51
Trophies
0
Age
29
Location
Bat Yam
XP
220
Country
Israel
you're basically making fake pkgs, having samu do everything for you including decryption. you'd need the emulator to use fself. passcode is irrelevant, but most fake pkgs use all 0's, but that's not needed. I think it gets that info from the license.dat. I know al azif told me that the key to all pkgs is the passcode, so everything related to the pkgs is derived from it including the keystone which is a fingerprint of the passcode. now, that I don't know how you can emulate unless the pkg is all 0's. we know what that fingerprint looks like, but I don't know if the algorithm is known or if we can reverse the process.
Post automatically merged:

plus, from what I've heard, the ps5 is almost identical to the ps4, just different keys and security, but the process is the same, so that might be why he thinks a ps5 emulator is possible. it will likely use fself again and have the system do all the work.
The other consoles are not as secured and protected as Sony PlayStation 4 & 5 from what I read here, like Nintendo Switch and Xbox One.

This surprises me to hear that the Sony PlayStation 5 is almost identical to Sony PlayStation 4, because most Sony PlayStation 5 games are ray traced and unlike PS4 games and a PS5 emulator, unlike PS4 emulator, has to emulate the ray tracing efficiently and this is not an easy task.

Also Sony PlayStation 5, unlike Sony PlayStation 4, is SSD based and not HDD based and this means that a PS5 emulator, unlike a PS4 emulator, will also have to emulate the SSD part efficiently as well.

But if PS5 is really almost identical to PS4 then this is excellent because when there is a working PS4 emulator that can emulate most commercial PS4 games very well then nobody will have to wait many years for a PS5 emulator that can emulate most commercial PS5 games.

But of course that to play a ray traced PS5 game on PC always on 60 FPS, the PC must have a RTX GPU with at least 32 GB RAM and at least 8 cores CPU and a SSD drive storage, an expensive gaming PC, because no matter how much good a PS5 emulator will emulate all PS5 games, a strong, powerful and fast PC is still required to play ray traced PS5 games always on 60 FPS.

I changed my mind. I will view the source codes of existing PS4 emulators and I will try to improve them to make the existing PS4 emulators work better on PS4 emulation.
 
Last edited by GAMEBOYADVANCETEMPORARY,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    HiradeGirl @ HiradeGirl: Have a nice day. Life. Week. Month. year.