PS1 Emulation

From PS4 Developer wiki
Revision as of 11:59, 12 September 2020 by Kozarovv (talk | contribs) (minor formatting fix)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Description[edit]

Playstation 1 emulator called internally ps1hd. Emulation on PS4 is handled differently comparing to PS3. Each PS1 game PS4 package file (.pkg) include emulator itself, so there is no included emulator in PS4 firmware. Fact that emulator is now included in game pkg, is slightly complicating providing compatibility list, as emulators include some per title patches, and different default settings. Next difference is that BIOS/ROM in external file is included in .pkg, emu need different region bios for different region titles. This time bios is not any special version, standard SCPH-550X is used. PS1 Emulator supports LUA scripting by "Lua Bridge", is powerful interface that provide many possibilities to improve compatibility. Memory card is created at first run of emulator, so you don't need to include one in pkg. Emulator have some leftovers from PSP emulator (like axinsnreplace), so core of non PS1 specific functions is the same as in PSP emu. Rest of emu seems to be "inspired" by mednafen.

Folder/File layout[edit]

Example: Medievil internal emulator, standalone pkg can differ.

├──bios
│   ├── scph5500.bin
│   ├── scph5501.bin
│   └── scph5502.bin
├──config-emu-ps4.txt
├──data
│   └── image.bin
├──eboot.bin
├──sce_module
│   ├── libc.prx
│   ├── libSceAudioLatencyEstimation.prx
│   ├── libSceFace.prx
│   ├── libSceFaceTracker.prx
│   ├── libSceFios2.prx
│   ├── libSceHand.prx
│   ├── libSceHandTracker.prx
│   ├── libSceHeadTracker.prx
│   ├── libSceJobManager.prx
│   ├── libSceNpToolkit2.prx
│   └── libSceS3DConversion.prx
├──sce_sys
│   └── param.sfo
├──scripts
│   └── patches.lua

Configuration Files[edit]

config-emu-ps4.txt[edit]

Command Values Notes Usage
--region SCEE SCEA SCEI Image/Bios region --region="SCEE"
--image path game image path, sandbox root relative "data/MyGame.bin"
--libcrypt CRC16 Libcrypt magic, unknown what is really hashed. required for many PAL games --libcrypt="0xAB34"
--scale 1 , 2 , 4, auto 1 = 1280x720, 2 = 1920x1080, 4 = 3840x2160, auto= same as ps4 video settings(?) please keep in mind that even using scale=1 can cause upscaling glitches scale=2
--antialias SSAA4x , MSAA4x same as above, using this can cause visual glitches on games that scales bad --antialias=SSAA4x
--softgpu
--state-restore
--wait
--mcd0
--mcd1
--bios path Need to match region of game, relative to sandbox root --bios="BIOS/SCPH5502.bin"
--configpath
--texdump
--texreplace
--texrecent true , false unk --texrecent=true

patches.lua[edit]

Lua patches are split between 3 categories R3K (r3000 mips), and EM (emulator), TR (trophies). Called by getXXXObject. Only exception from that is apiRequest.

Command Usage Notes
apiRequest apiRequest(<api version>) example: apiRequest(1.0)

Different emu versions support different highest api. Medievil emu support api up to 1.0 Calling api is mandatory.

getR3KObject()[edit]

For usage examples lets declare getR3KObject() as r3k [ local r3k = getR3KObject() ] to make things closer to official configs.

Command Usage Notes
GetPC r3k.GetPC() Return current PC.
SetPC r3k.SetPC(address) Set current PC to address.
GetHi r3k.GetHi Return Hi register value.
SetHi r3k.SetHi(value) Set Hi register value.
GetLo r3k.GetLo Return Lo register value.
SetLo r3k.SetLo(value) Set Lo register value.
GetGpr r3k.GetGpr(reg) Return register value, require formatting like here: r3k.GetGpr(gpr.a0).
SetGpr r3k.SetGpr(reg, value) Set register value, require formatting like here: r3k.GetGpr(gpr.a0, value).
ReadMem8 r3k.ReadMem8(address) Read/return byte from address.
ReadMem16 r3k.ReadMem16(address) Read/return half from address.
ReadMem32 r3k.ReadMem32(address) Read/return word from address.
ReadMemFloat r3k.ReadMemFloat(address) Read/return float from address.
ReadMemStr r3k.ReadMemStr(address) Read/return string from address.
WriteMem8 r3k.WriteMem8(address, value) Write/set selected memory as byte to value.
WriteMem16 r3k.WriteMem16(address, value) Write/set selected memory as half to value.
WriteMem32 r3k.WriteMem32(address, value) Write/set selected memory as word to value.
WriteMemFloat r3k.WriteMemFloat(address, value) Write/set selected memory as float to value.
WriteMemStr r3k.WriteMemStr(address, value) Write/set selected memory as string to value.
WriteMemStrZ r3k.WriteMemStrZ(address, value)
AddHook r3k.AddHook(address, original opcode, function/hook) Add hook into mips code.
RemoveHook r3k.RemoveHook(?) Remove hook from mips code.
InsnReplace r3k.InsnReplace(address, original opcode, replace opcode) similar to pcsx2 pnach, but additionally use original opcode as a check.
FuncReplace r3k.FuncReplace(address, original opcode, function name) Hook/replace function in mips code with predefinied one.
BurnCycles
FlushCache r3k.FlushCache() Flush mips cache (D + I ?).

getEmuObject()[edit]

For usage examples lets declare getEmuObject() as emu [ local emu = getEmuObject() ] to make things closer to official configs.

Command Usage Notes
PadRead emu.PadRead() Return pad state (pushed buttons).
PadReadLeftStick emu.PadReadLeftStick() Return pad left stick state.
PadReadRightStick emu.PadReadRightStick() Return pad right stick state.
PadSetButtonsMode emu.PadSetButtonMode(value) Set some pad mode, in one of official configs described as "switch Select/Start -> Touchpad/Options mode" with used value 2.
AddVsyncHook
RemoveVsyncHook
ThrottleMax emu.ThrottleMax() Remove framelimiter, used frequently for loadings.
ThrottleNormal emu.ThrottleNormal() Set framelimiter to default game value.
Log emu.Log(value) Print debug messages to userland console, ex. emu.Log(string.format("Overlay: %02x", overlay)).
GetNativeLanguage emu.GetNativeLanguage() Return used PS4 language.
LoadConfig
SaveConfig
LoadState
SaveState
PostEffect
PostEffectParams
NeoMode emu.NeoMode() Return ps4 mode.
CRC32
AddFBMapping emu.AddFBMapping( , , , ) Add framebffer mapping, in Medievil used with emu.AddFBMapping(768, 256, 180, 256) values.
RemoveFBMapping emu.RemoveFBMapping( , ) Remove framebffer mapping, in Medievil used with emu.RemoveFBMapping(768, 256) values.
Launch emu.Launch("path") Emulator is able to launch selfs in own sandbox (or maybe more? ;) ), require full path (for example "/app0/folder/my_self.bin"), can be used for multidisc games.

getTrophyObject()[edit]

For usage examples lets declare getTrophyObject() as trp [ local trp = getYtophyObject() ] to make things closer to official configs.

Command Usage Notes
Unlock trp.Unlock(trophy id) Unlock trophy by id

PAL Libcrypt games[edit]

Some PAL PSX games include libcrypt protection, those are known to cause issues for emulators.
More info here: http://wiki.redump.org/index.php?title=PlayStation_1:_LibCrypt_protection_(Old)

List[edit]

  • Actua Ice Hockey 2 (Europe)
  • Anstoss - Premier Manager (Germany)
  • Ape Escape (Europe) , (France) , (Germany) , (Italy)
  • Ape Escape - La Invasion de los Monos (Spain)
  • Asterix - Mega Madness (Europe) (En,Fr,De,Es,It,Nl)
  • Barbie - Aventure Equestre (France)
  • Barbie - Race & Ride (Europe) , (Germany) , (Italy) , (Spain)
  • Barbie - Sports Extreme (France)
  • Barbie - Super Sports (Germany) , (Europe) , (Italy) , (Spain)
  • BDFL Manager 2001 (Germany)
  • BDFL Manager 2002 (Germany)
  • Canal+ Premier Manager (Europe) (Fr,Es,It)
  • Crash Bash (Europe) (En,Fr,De,Es,It)
  • CTR - Crash Team Racing (Europe) (En,Fr,De,Es,It,Nl) (EDC)
  • CTR - Crash Team Racing (Europe) (En,Fr,De,Es,It,Nl) (No EDC)
  • Dino Crisis (Europe) , (France) , (Germany) , (Italy) , (Spain)
  • Disney Fais Ton Histoire! - Mulan (France)
  • Disney Libro Animato Creativo - Mulan (Italy)
  • Disney's Tarzan (Europe) , (Netherlands) , (Sweden) , (Germany) , (Italy) , (France) , (Spain)
  • Disney's 102 Dalmatians - Puppies to the Rescue (Europe) (Fr,De,Es,It,Nl)
  • Disney's 102 Dalmatians - Puppies to the Rescue (Europe)
  • Disney's Aventura Interactiva - Mulan (Spain)
  • Disney's Story Studio - Mulan (Europe)
  • Disney's Verhalenstudio - Mulan (Netherlands)
  • Disneys Interaktive Abenteuer - Mulan (Germany)
  • EA Sports Superbike 2000 (Europe) (En,Fr,De,Es,It,Sv)
  • Eagle One - Harrier Attack (Europe) (En,Fr,De,Es,It)
  • Esto es Futbol (Spain)
  • F.A. Premier League Football Manager 2001, The (Europe)
  • F1 2000 (Europe) (En,Fr,De,Nl)
  • F1 2000 (Italy)
  • Final Fantasy IX (Europe) , (France) , (Germany) , (Italy) , (Spain) , (Disc 1)
  • Final Fantasy IX (Europe) , (France) , (Germany) , (Italy) , (Spain) , (Disc 2)
  • Final Fantasy IX (Europe) , (France) , (Germany) , (Italy) , (Spain) , (Disc 3)
  • Final Fantasy IX (Europe) , (France) , (Germany) , (Italy) , (Spain) , (Disc 4)
  • Final Fantasy VIII (Europe, Australia) , (France) , (Germany) , (Italy) , (Spain) , (Disc 1)
  • Final Fantasy VIII (Europe, Australia) , (France) , (Germany) , (Italy) , (Spain) , (Disc 2)
  • Final Fantasy VIII (Europe, Australia) , (France) , (Germany) , (Italy) , (Spain) , (Disc 3)
  • Final Fantasy VIII (Europe, Australia) , (France) , (Germany) , (Italy) , (Spain) , (Disc 4)
  • Football Manager Campionato 2001 (Italy)
  • Formula One 99 (Europe) (En,Es,Fi)
  • Formula One 99 (Europe) (En,Fr,De,It)
  • Frontschweine (Germany)
  • Fussball Live (Germany)
  • Fussball Manager 2001 (Germany)
  • Galerians (Europe) , (France) , (Germany) , (Disc 1)
  • Galerians (Europe) , (France) , (Germany) , (Disc 2)
  • Galerians (Europe) , (France) , (Germany) , (Disc 3)
  • Gekido - Urban Fighters (Europe) (En,Fr,De,Es,It)
  • Hogs of War (Europe)
  • Italian Job, The (Europe) , (Germany)
  • Jackie Chan Stuntmaster (Europe)
  • Le Mans 24 Hours (Europe) (En,Fr,De,Es,It,Pt)
  • Legacy of Kain - Soul Reaver (Europe) , (France) , (Germany) , (Italy) , (Spain)
  • Les Cochons de Guerre (France)
  • LMA Manager 2001 (Europe)
  • LMA Manager 2002 (Europe)
  • Lucky Luke - Western Fever (Europe) (En,Fr,De,Es,It,Nl)
  • MediEvil (Europe) , (France) , (Germany) , (Italy) , (Spain)
  • MediEvil 2 (Europe) (En,Fr,De)
  • MediEvil 2 (Europe) (Es,It,Pt)
  • MediEvil 2 (Russia)
  • Men in Black - The Series - Crashdown (Europe) , (France) , (Germany) , (Italy) , (Spain)
  • Michelin Rally Masters - Race of Champions (Europe) (En,De,Sv)
  • Michelin Rally Masters - Race of Champions (Europe) (Fr,Es,It)
  • Mike Tyson Boxing (Europe) (En,Fr,De,Es,It)
  • Mission - Impossible (Europe) (En,Fr,De,Es,It)
  • MoHo (Europe) (En,Fr,De,Es,It)
  • Monde des Bleus, Le - Le jeu officiel de l'equipe de France (France)
  • N-Gen Racing (Europe) (En,Fr,De,Es,It)
  • Need for Speed - Porsche 2000 (Europe) (En,De,Sv)
  • Need for Speed - Porsche 2000 (Europe) (Fr,Es,It)
  • Parasite Eve II (Europe) , (France) , (Germany) , (Italy) , (Spain) , (Disc 1)
  • Parasite Eve II (Europe) , (France) , (Germany) , (Italy) , (Spain) , (Disc 2)
  • PGA European Tour Golf (Europe) (En,De)
  • Premier Manager 2000 (Europe)
  • Prince Naseem Boxing (Europe) (En,Fr,De,Es,It)
  • Radikal Bikers (Europe) (En,Fr,De,Es,It)
  • RC Revenge (Europe) (En,Fr,De,Es)
  • Resident Evil 3 - Nemesis (Europe) , (France) , (Germany) , (Ireland) , (Italy) , (Spain)
  • Ronaldo V-Football (Europe) (De,Es,It,Pt)
  • Ronaldo V-Football (Europe) (En,Fr,Nl,Sv)
  • SaGa Frontier 2 (Europe) , (France) , (Germany)
  • SnoCross Championship Racing (Europe) (En,Fr,De,Es,It)
  • Space Debris (Europe) , (France) , (Germany) , (Italy)
  • Speed Freaks (Europe)
  • Spyro - Year of the Dragon (Europe) (En,Fr,De,Es,It) (v1.0) , (v1.1)
  • Spyro 2 - Gateway to Glimmer (Europe) (En,Fr,De,Es,It)
  • Sydney 2000 (Europe) , (France) , (Germany) , (Spain)
  • TechnoMage - De Terugkeer der Eeuwigheid (Netherlands)
  • TechnoMage - Die Rueckkehr der Ewigkeit (Germany)
  • TechnoMage - En Quete de L'Eternite (France)
  • TechnoMage - Return of Eternity (Europe)
  • Theme Park World (Europe) (En,Fr,De,Es,It,Nl,Sv)
  • This Is Football (Europe) (Fr,Nl)
  • This Is Football (Europe) , (Italy)
  • TOCA World Touring Cars (Europe) (En,Fr,De)
  • TOCA World Touring Cars (Europe) (Es,It)
  • UEFA Euro 2000 (Europe) , (France) , (Germany) , (Italy)
  • UEFA Striker (Europe) (En,Fr,De,Es,It,Nl)
  • Urban Chaos (Europe) (En,Es,It)
  • Urban Chaos (Germany)
  • V-Rally - Championship Edition 2 (Europe) (En,Fr,De)
  • Vagrant Story (Europe) , (France) , (Germany)
  • Walt Disney World Quest - Magical Racing Tour (Europe) (En,Fr,De,Es,It,Nl,Sv,No,Da)
  • Wip3out (Europe) (En,Fr,De,Es,It)

Known Issues[edit]

Some libcrypt issues are known to community. Here is list of them. All that can be patched before creating pkg, or fixed by using --libcrypt command in emu config.

Game Behavior
Ape Escape (PAL)

Main menu navigation will be completely disabled, making you unable to start the game.

Crash Team Racing (PAL)

Game will hang once at the end of the loading screen (for the level itself).

Legacy of Kain: Soul Reaver (PAL)

The game will hang when you're introduced with the combat tutorial when the camera pans to show the enemies.

Lucky Luke: Western Fever (PAL)

The game stops when you get to the Mexican guy blocking the bridge, he just won't move from there, ever. Even when you complete the quest. The game also has anti-cracking protection where the game will block a path with a fallen tree + maybe more.

MediEvil (PAL)

Will have a disc error icon upon loading The Hilltop Mausoleum. Interesting to note this was actually the FIRST game to use LibCrypt.

MediEvil 2 (PAL)

Will also have the same disc error icon as above, except upon loading Kensington.

PGA European Tour Golf (PAL)

In the third hole of the first tournament or by selecting some holes, the game will get stuck in "demo" mode (and will not you play anything).

Resident Evil 3: Nemesis (PAL)

Will hang at the "Game contains violence and gore" screen.

Spyro 3: Year of the Dragon (PAL)

Interesting case for this one, the game will eventually randomly delete eggs, reset progress with unlocked characters, remove sheep in boss battles, change the language and even tell you off for playing a "hacked copy" + more. Interesting to note that the game also detected early LibCrypt knockout PPF patches back when the game was first released as it had checksum checks throughout the game, which caused the same effects above. The US platinum release only has anti mod detection (not libcrypt) and will do the above effects if it realises it's been modified. The original US release appears to not have any protection.

This is Football (PAL)

Hangs on the loading screen going ingame.

V-Rally: Championship Edition 2 (PAL)

The game will endlessly load on the heartbeat loading screen (with no disc activity).

Wip3out (PAL)

The game will freeze when passing the finish line.

Multi-Disc support[edit]

This needs more testing but in theory it should work as follows.

On Real PS1 Hardware, PS2, PSP, PSV, PS3[edit]

Example Game: Final Fantasy VII containing 3 Discs:

  • Before the Game asks you to change Discs, it will ask you if you wish to save the Game.
    • If doing so, the Save File already creates a "Flag" containing Information that this Save File requires the next Disc (this is perfectly visible with Final Fantasy VIII as seen here).
      • Example: When Aerith dies and you fight JENOVA, the Game creates the Save File asking for CD 2 while you are still on CD 1.
  • After you saved the Game, it will immediately ask you to insert the next Disc.
    • The reason why this works and it's supported because in theory, you could save your Game right before you get asked to change the Disc but instead of doing so, you shut down your console and decides to play further tomorrow.
      • So when loading the same Save File on next day, it will already ask in the beginning for the next Disc.
        • If the next Disc is already inserted, then it will load the Game immediately.
        • If not then it will ask again for switching Discs (same when inserting a wrong Disc like "Disc 3" for instance but "Disc 2" is needed).

So how to do this on a PS4?[edit]

Since as mentioned above the problematic we have is that every PKG contains not only the Game as an Image-File, but also the Emulator and a Save File itself. So a workaround is needed:

  • You create a FPKG containing Disc 1 of Final Fantasy VII only (Example Content ID = CUSAFF7D1).
  • You play the Game normally until it asks you to save the Game before it will ask you to change the Disc.
  • Save the Game and close the Application.
  • On your PS4 Harddrive, there should be theoretically the Save File somewhere (within the Game Files from the Game itself ???).
  • Dump the Save File and edit the "Parameters" (PARAM.SFO ???) so CUSAFF7D1 gets into CUSAFF7D2.
  • Create your next FPKG containing Disc 2 of Final Fantasy VII only and insert your edited Save File (Content ID = CUSAFF7D2 for both the FPKG as the Save File).
  • Start the new FPKG created and it should recognize your Save File and load the Game from the beginning of Disc 2
  • Do the same process for every other additional Disc.

Links[edit]