Editing Talk:PS2 Emulation
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 203: | Line 203: | ||
|}{{clear}} | |}{{clear}} | ||
=== | ===ps2_netemu command 0x4=== | ||
Patch SPE 3 program (eedma) by searching for ila r4, xxxxx, starting at 0x178A0 and replacing them with (0x42000004 | ((value << 7) & 0x1FFFF80)<br> | |||
* | 0x42000004 is ila r4 opcode. Due to opcode encoding example result of that patch with value 0x08 will be 0x42000404 (ila r4, 0x08). | ||
There is little bit more than that, but main purpose is just to patch SPE program behavior. | |||
* What are the valid values? The official config from The Suffering uses a 0x8 value, yet the flashing does still happen. Increasing it to 0x20 seems to fix the flashing.--[[User:Agrippa|Agrippa]] ([[User talk:Agrippa|talk]]) 14:42, 22 February 2022 (UTC) | |||
** 0x00 - 0x3FFFF. Well you can use higher values, but it will be truncated by mask to something below 0x40000 anyway. Default is 0x12345 if i understand correctly. --[[User:Kozarovv|Kozarovv]] ([[User talk:Kozarovv|talk]]) 16:29, 22 February 2022 (UTC) | |||
=== | ===ps2_netemu command 0x5=== | ||
The | The external config format used by ps2_netemu.self doesnt supports command ID 0x5. But this same command with a different ID (0x4) was used by this game configs embedded inside ps2_gxemu.self: Grand Theft Auto: Liberty City Stories (SLES-54135, SLES-54136, SLUS-21423), Grand Theft Auto: Vice City Stories (SLES-54622, SLES-54623, SLUS-21590), Hunter: The Reckoning Wayward (SLES-51823), Onimusha: Dawn of Dreams (SLPM-66275), Shinseiki Evangelion: Ayanami Ikusei Keikaku with Asuka Hokan Keikaku (SLPM-65340), Tekken Tag Tournament (SLUS-20001)<br> | ||
The reason why command ID 0x5 is not supported in the config files is because the related emulator code is enabled permanently in ps2_netemu.self, so in the practise is like if all config files have this command enabled<br> | |||
The command patches EEDMA SPE program (at eedma init, 0x1F77C in latest netemu) to set different handling for DIRECT/DIRECTHL VIF1 commands. Weird solution, wasn't better to just change pointers in spe program instead of patching that on init? | |||
=== | ===ps2_netemu command 0x0B=== | ||
There is a lot of misunderstanding about that command. | |||
Offset seems to be dependent on read mode, is not about what media we use. This is dependent how game read data, more precisely how game read that one sector we want to patch. | |||
PCSX2 "CDVD reads" logs can help here: | |||
'''CDRead requested block size (CD disc):''' | |||
*2048 = Offset + 0x18 (skip 12 sync bytes, 4 of header, and 8 of subheader) | |||
*2328 = Offset + 0x18 (skip 12 sync bytes, 4 of header, and 8 of subheader) | |||
*2340 = Offset + 0x0C (skip only 12 bytes of sync data) | |||
'''DVDRead requested block size (DVD Disc):''' | |||
*2064 = Offset match, but only until the 349th sector. Otherwise is offset - 0x0C because that read mode see data as ID DATA (4) + ID DATA EDC (2) + Reserved bytes (6) + 2048 data + EDC (4). Why there is some weirdness that about first sectors, no idea. Maybe it is something common for DVD discs that i'm not aware off. | |||
"Offset + XX" for CD assume that you use Isobuster RAW mode. "Offset - XX" for DVD assume that you use Isobuster NON RAW mode (ISO can't store all data, so is missing ID/Resv bytes too.<br> | |||
Keep in mind there is a bug in pcsx2 where fastboot "force" 2048 CD read on DVD disc for executable. That one will match 2064 read for us. | |||
* You are very right. I was not aware about different read modes you can specify in the sceCdRead command. That makes sense and that explains that Freekstyle issue. Regarding the whole offset misunderstanding, I know it could be confusing sometimes when you open the mounted file system through the HxD for example (only data bytes are seen). It is important to load the image file in the hex editor directly (or use the "Load image file" in HxD), or check the RAW box in the Isobuster's sector viewer.<br> When it comes to the DVD discs, I know the offset correction is somehow related to the DVD RAW 2064 bytes per sector mode. But I am not sure if it is not applied until the 349th sector precisely - it is what I noticed by looking into the Psychonauts and Street Racing Syndicate configs. The latter has got the patch data applied to the 349th sector without the 0xC correction at all. It is the farthest example I have found.--[[User:Agrippa|Agrippa]] ([[User talk:Agrippa|talk]]) 14:47, 20 February 2022 (UTC) | |||
* The next 0x0B sector DVD patch in ascending order is in the Ace Combat Zero: The Belkan War config (402nd sector). It does use the +0xC correction. So it is somewhere between 349th and 402nd sector the correction starts to be applied.--[[User:Agrippa|Agrippa]] ([[User talk:Agrippa|talk]]) 14:00, 22 February 2022 (UTC) | |||
* | |||
===ps2_netemu command 0x0C=== | ===ps2_netemu command 0x0C=== | ||
Line 262: | Line 243: | ||
*** Well that's "unfortunate" because Shadowman2 would be perfect test case here. I noticed that Shadowma2 have hardcoded bios settings "CDVD_READ_DELAY", so maybe is handled there. --[[User:Kozarovv|Kozarovv]] ([[User talk:Kozarovv|talk]]) 19:11, 4 March 2022 (UTC) | *** Well that's "unfortunate" because Shadowman2 would be perfect test case here. I noticed that Shadowma2 have hardcoded bios settings "CDVD_READ_DELAY", so maybe is handled there. --[[User:Kozarovv|Kozarovv]] ([[User talk:Kozarovv|talk]]) 19:11, 4 March 2022 (UTC) | ||
===ps2_netemu command 0x0F=== | |||
Apparently command is combined 0x26, and 0x27. Address range is added to both 0x26, and 0x27 list. | |||
This is probably because someone realized later that you not always need accuracy on both FPU, and COP2 to make things work, and that game speed suffer from it. So command was split into 2 separate commands, leaving combined 0x0F for backward compatibility. | |||
0x0F use 2 list counters. From 0x26, and from 0x27. This make usage limit variable. With overall limit 31 for 0x27, and 31 for 0x26. When we have 20 0x0F commands, and 12 0x27, or 0x26. Emulator will panic as one of counters will be above allowed (31) number. | |||
Edit: There are some additional runtimes which check 0x26/0x0F/0x10/0x27 and 0x0E. Those runtimes check that current PC match one from configs, and return true or false. Is unknown what is purpose of that check, and even if it is really used (no xrefs, but can be ppc bctr jump). I'm suspecting that check is what make slowdown when commands are used on unsupported opcodes. This is weird if is really working, but that will explain slowdowns.. Supported opcodes perform own check for current PC, and supported command anyway. So maybe that's some kind of hint for recompiler. No idea, really. | |||
* In other words, the 0x0E command is equal to the 0x0F one, but it does work on a specific offset instead of range, am I right? And neither 0x0E/0x0F/0x26/0x27 should affect the mul/div accuracy, but the add/sub only.--[[User:Agrippa|Agrippa]] ([[User talk:Agrippa|talk]]) 14:26, 6 March 2022 (UTC) | |||
===ps2_netemu command 0x12=== | |||
=== | First 8 bytes of that command are special flags. Not quite sure about bytes 5-8 yet, because at some point they are used to "andc" with first 4 bytes. | ||
Some examples for first 4 bytes: | |||
0x100000 = Different code path for VU0 opcodes that do ADD/SUB with multiply (MSUB, MADDA, etc.). | |||
0x200000 = Run some additional code in VU0 load/store opcodes (ILW, LQI, ISWR, etc.) | |||
0x400000 = Skip emu syscall 3 (3) | |||
0x800000 = Skip emu syscall 3 (4) | |||
0x4000000 = This flag ensure that type 2 config from cmd 0x12 will run. Otherwise it seems to be skipped. | |||
0x8000000 = Run some additional code for VU0 DIV opcode | |||
0x30000000 = Different code path for VU0 MUL opcodes, include opcodes like MSUB for mul part. So 0x30100000 work for mul, and sub part. | |||
====type 1==== | ====type 1==== | ||
Line 338: | Line 298: | ||
seg017:00000000001984C0 bgt cr6, next_value | seg017:00000000001984C0 bgt cr6, next_value | ||
</pre> | </pre> | ||
====type 2==== | ====type 2==== | ||
Line 404: | Line 362: | ||
stw r9, 0x1238(r31) save count>>1 | stw r9, 0x1238(r31) save count>>1 | ||
std r11, 0x1240(r31) save ptr to table values start | std r11, 0x1240(r31) save ptr to table values start | ||
---big handler, different register settings?--- | |||
===ps2_netemu command 0x29=== | |||
Something related with read time, maybe seek time. First value is meant to be lower than second value, but this is not requirement. | |||
Code that use it seems to delay some read/seek operation by multiply of first, or second value depending which sector is currently read (or maybe which part of disc actually). Here is code from one of fuctions that use values from that command, keep in mind that "mecha" is just fancy name for cdvd in that emu. | |||
if ((75 * cdvd.CrtSecond + 4500 * cdvd.CrtMinute + cdvd.CrtFrame - 150) >= *(mecha.unk_0x60)) | |||
a = *(cmd_0x29_val_2); | |||
else | |||
a = *(cmd_0x29_val_1); | |||
b = 4835703278458516699; // read https://munroesj52.github.io/vec__int64__ppc_8h.html (search on page for that number). | |||
c = (79800000 * a * b) >> 64; // 0x4C1A6C0 (79800000) is value that lv1 repo key be.clock return. | |||
===ps2_netemu command | d = c >> 18; // This and 2 above are generally used as a division by multiply. | ||
e = get_timebase_reg(); | |||
if ( e == 0 ) | |||
{ | |||
do | |||
e = get_timebase_reg(); | |||
while ( e == 0 ); | |||
} | |||
f = e - *(mecha.unk_0x24); | |||
if ( f >= d ) | |||
{ | |||
* | MECHA_update_status(mecha); | ||
* | result = unlock_sc06(0x8000LL); | ||
} | |||
* | |||
* | |||
* | |||
* | |||
== | |||
= | |||
* | |||
else | |||
{ | |||
do | |||
e = get_timebase_reg(); | |||
while ( e == 0 ); | |||
*(mecha.unk_20) = d - f + e; | |||
*mecha.unk_00 = 5; | |||
result = unlock_sc06(0x8000LL); | |||
} | |||
=== | ===ps2_netemu command 0x4D=== | ||
Ok, i don't get that config. Here is what happen in assembly: | |||
0xD820 ilhu r19, 0x7FFF | |||
0xD824 lqr r20, Q_cfg_0x4D ; 0x3F800000 in wild arms | |||
0xD82C iohl r19, 0xFFFF | |||
0xD834 and r17, r80, r19 ; r17 = Q & 0x7FFFFFFF mask | |||
0xD840 ceqi r15, r17, 0 ; r15 = r17 (shortcut to move 0 or value if exist to r15) | |||
0xD844 lqr r10, ST_Q | |||
0xD84C cwd r9, 0x30+var_30+8(sp) | |||
0xD850 rotqbyi r16, r20, 4 ; load mask from config to r16 | |||
0xD858 and r12, r15, r16 ; tempQ & 0x3F800000 (r15 and with mask from cfg 0x3F800000) | |||
0xD860 or r5, r80, r12 ; or r80(Q) with r12(Q masked with 0x3F800000) | |||
0xD868 shufb r7, r5, r10, r9 ; Prepare correct write for Q (r5 stored to r10 + 8) | |||
0xD870 stqr r7, ST_Q ; write result as Q value in STQ | |||
I removed irrelevant code that setup RGBA for readability, its not affecting Q. So my point is that all that masked Q is finally ored with r80. So with whole untouched Q value. Doen't that make all those operations irrelevant, or i made some mistake here?<br> | |||
This config can be quite important because it should help to fix issues like Galerians Ash without dirty static patches. More games affected: [[https://github.com/PCSX2/pcsx2/issues/5137 | List]] | |||
==XMB messages related with PS2 Emulation== | ==XMB messages related with PS2 Emulation== | ||
Line 689: | Line 507: | ||
* Without Factory Service Mode : gives "Incompatible Data" when inserting PS2 disc | * Without Factory Service Mode : gives "Incompatible Data" when inserting PS2 disc | ||
* When enabling [ | * When enabling [http://www.ps3devwiki.com/files/devtools/lv2-v9-pkg/ LV2Patcher] without factory service mode (patch4 set as http://pastie.org/private/jp8zhvuocjz95cfrjm0uzg) : no changes in XMB:Game (still only PS upscaler/smoothing, no PS2 mention at all) | ||
* When enabling [ | * When enabling [http://www.ps3devwiki.com/files/devtools/lv2-v9-pkg/ LV2Patcher] without factory service mode (patch4 set as http://pastie.org/4355919) : gives XMB:Game PS2 smoothing/upscaling options, it also make an inserted disk to be seen as PS2 format. Still same problem of ¨incompatible title¨ and loss of BT/settings. Also after returning to XMB, it no longer sees the disc as PS2 format but as incompatible data (which suggests the lv2 patch is undone, as lv2 is reloaded when returning from the ps2 lpar) | ||
* Using [ | * Using [http://www.ps3devwiki.com/files/OtherOSplusplus/misc/boot_ps2.pkg boot_ps2.pkg] without factory service mode : no resetting of date/time/displayoutput (still output on mainscreen), but all connection to any bound bluetooth device is lost, even when connected via USB (need PS button reactivation), and after a long while comes up with the message that the title is not compatible and that the ps3 needs to be updated (Basic nag screen that is on BC PS3s when inserting a noncompatible title). | ||
* With Factory Service Mode enabled (there are no Xmb options to combinetest with [ | * With Factory Service Mode enabled (there are no Xmb options to combinetest with [http://www.ps3devwiki.com/files/devtools/lv2-v9-pkg/ LV2Patcher] or [http://www.ps3devwiki.com/files/OtherOSplusplus/misc/boot_ps2.pkg boot_ps2.pkg]): gives ´PS2 disc´ detected at disc icon, but starting gives: resetting of date/time/displayoutput (effectively disabling my mainscreen), then all connection to any bound bluetooth device is lost, even when connected via USB (needs multiple PS button reactivation), and after a long while comes up with the message that the title is not compatible and that the ps3 needs to be updated (Basic nag screen that is on BC PS3s when inserting a noncompatible title). | ||
In short: [ | In short: [http://www.ps3devwiki.com/files/OtherOSplusplus/misc/boot_ps2.pkg boot_ps2.pkg] and Factory Service Mode seem to enable simulare (it tries to boot it) while [http://www.ps3devwiki.com/files/OtherOSplusplus/misc/boot_ps2.pkg boot_ps2.pkg] gives you more options e.g. using [http://www.ps3devwiki.com/files/devtools/lv2-v9-pkg/ LV2Patcher]. | ||
Perhaps hardswapping out all the dev_flash ps2 emu files for the same software only emulator would circumvent the 'incompatible title' message. | Perhaps hardswapping out all the dev_flash ps2 emu files for the same software only emulator would circumvent the 'incompatible title' message. | ||
==== Second test: FW 2.70/3.15 ==== | ==== Second test: FW 2.70/3.15 ==== | ||
Silent Hill : gives disk icon "unsupported data" and error message like "This model of the PS3 system is not compatible with Playstation2 format software" when run via disc icon. Using [ | Silent Hill : gives disk icon "unsupported data" and error message like "This model of the PS3 system is not compatible with Playstation2 format software" when run via disc icon. Using [http://www.ps3devwiki.com/files/OtherOSplusplus/misc/boot_ps2.pkg boot_ps2.pkg] gives title not supported error message like "This title is not currently compatible with the PS3 system". | ||
==== Third test: FW 3.55 OtherOS++22GB (with SS Patches) ==== | ==== Third test: FW 3.55 OtherOS++22GB (with SS Patches) ==== | ||
Silent Hill : gives disk icon "unsupported data" and error message like "This model of the PS3 system is not compatible with Playstation2 format software" when run via disc icon. Using [ | Silent Hill : gives disk icon "unsupported data" and error message like "This model of the PS3 system is not compatible with Playstation2 format software" when run via disc icon. Using [http://www.ps3devwiki.com/files/OtherOSplusplus/misc/boot_ps2.pkg boot_ps2.pkg] gives blackscreen lockup, not reacting on PS button, or powerbutton, requiring removing powercord. | ||
Line 904: | Line 722: | ||
ID match US release of Crazy Taxi. This id is kinda special, because Swap Magic CD version, and some other Datel products like Action Replay use Crazy Taxi TOC in their retail discs. | ID match US release of Crazy Taxi. This id is kinda special, because Swap Magic CD version, and some other Datel products like Action Replay use Crazy Taxi TOC in their retail discs. | ||
Is known that they literally ripped part of disc (with key/logo, and TOC), and frankesteined it with own products. | Is known that they literally ripped part of disc (with key/logo, and TOC), and frankesteined it with own products. | ||
So mentioned check first compare hash, and if that match, then run function that perform another check at disc sector 267559 (0x41527), so exactly where main executable is. | So mentioned check first compare hash, and if that match, then run function that perform another check at disc sector 267559 (0x41527), so exactly where main executable is. | ||
I didn't figured out what next, but this is probably anti AR/Datel/SM check. What's weird, there seems to be nothing for TimeSplitters2 which if i recall correctly was used for DVD version of Swap Magic | I didn't figured out what next, but this is probably anti AR/Datel/SM check. What's weird, there seems to be nothing for TimeSplitters2 which if i recall correctly was used for DVD version of Swap Magic. | ||
==CDVD Commands== | ==CDVD Commands== | ||
Line 1,088: | Line 905: | ||
Every "mechacon_auth" command return zeroed result with different size. Only exception here is 0x81 which return 1. | Every "mechacon_auth" command return zeroed result with different size. Only exception here is 0x81 which return 1. | ||
</pre> | </pre> | ||
==EE I/O Handlers list== | ==EE I/O Handlers list== | ||
Line 1,678: | Line 1,424: | ||
|- | |- | ||
|} | |} | ||
1000F800 to 1000F8B0 seems to be some fake regs for testing purposes. Probably not existing on real PS2. | 1000F800 to 1000F8B0 seems to be some fake regs for testing purposes. Probably not existing on real PS2. | ||
* 1000F820 return "DrJock TV Quiz P" | |||
* 1000F830 return "hD bags few lynx" | |||
* 1000F820 return "DrJock TV Quiz P" | |||
* 1000F830 return "hD bags few lynx" | |||
That make string "DrJock TV Quiz PhD bags few lynx" - This is perfect summary of Sony work. Since correct pangram should use "MrJock". So even here they made mistake. | That make string "DrJock TV Quiz PhD bags few lynx" - This is perfect summary of Sony work. Since correct pangram should use "MrJock". So even here they made mistake. | ||
* | * 1F00F880 return hardcoded value of 0x4457, which match emu revision i'm working on. Can be just coincidence. | ||
==Random notes about SPE in ps2_netemu== | ==Random notes about SPE in ps2_netemu== | ||
===IOP SPE=== | ===IOP SPE=== | ||
This is unconfirmed by any code reversing for now, but IOP emulator print messages like: | This is unconfirmed by any code reversing for now, but IOP emulator print messages like: | ||
Cache write (IOPADDR/LSADDR/SIZE) | Cache write (IOPADDR/LSADDR/SIZE) | ||
Cache read (IOPADDR/LSADDR/SIZE) | Cache read (IOPADDR/LSADDR/SIZE) | ||
ERROR: Double ICACHE fault | ERROR: Double ICACHE fault | ||
Which suggest that instruction cache is emulated for IOP. Making this (ps2/gx/net) emu only PS2 emulator that support cache emulation for IOP. For now even most ps1 emulators lack of that feature, and none of known PS2 emulators do that (including Pcsx2/Play!/Dobiestation). With this we can safely assume that also load delay slots are handled correctly here. Unrelated, but is hard to believe that someone implemented icache, but not load delay slots. Which again make it only known emu set that support this afaik. | Which suggest that instruction cache is emulated for IOP. Making this (ps2/gx/net) emu only PS2 emulator that support cache emulation for IOP. For now even most ps1 emulators lack of that feature, and none of known PS2 emulators do that (including Pcsx2/Play!/Dobiestation). With this we can safely assume that also load delay slots are handled correctly here. Unrelated, but is hard to believe that someone implemented icache, but not load delay slots. Which again make it only known emu set that support this afaik. | ||
===EEDMA on SPE3=== | ===EEDMA on SPE3=== | ||
Line 1,785: | Line 1,452: | ||
*8 - SPRfrom dma is handled on PPE only it seems | *8 - SPRfrom dma is handled on PPE only it seems | ||
*9 - SPRto dma is handled on PPE only it seems | *9 - SPRto dma is handled on PPE only it seems | ||
Additionally EEDMA handle VU1 code writes/reads | Additionally EEDMA handle VU1 code writes/reads. Only VU1 code, VU1 data is handled by SPE2 (VU1), and any VU0 r/w is handled by PPU only.<br> | ||
So is more like "Close to GS" DMA handler. | So is more like "Close to GS" DMA handler. | ||
Line 1,791: | Line 1,458: | ||
===VU1 emulation on SPE=== | ===VU1 emulation on SPE=== | ||
When I disassembled VU1 SPE program, i noticed that real code is really small part of that. Not much to run real VU recompiler/interpreter. | When I disassembled VU1 SPE program, i noticed that real code is really small part of that. Not much to run real VU recompiler/interpreter. | ||
Then i found out something impressive in my opinion. Real deal is that real code delivered to SPE is created on PPE dynamically based on real PS2 VU1 code. Due to similarity of SPE with VU requested in IBM by Sony at design level, there is no VU1 interpreter or recompiler per se. Emulator take VU1 code, dismount it to parts by OP field types, and reassemble into ready SPE code using ready hex templates. I'm not familiar with professional naming of that operation, but its like ahead of time translation of code. So when VU1 code reach SPE is already translated to SPE opcodes. In other terms, SPE responsible for running VU1 is really running VU1 code in some way. | Then i found out something impressive in my opinion. Real deal is that real code delivered to SPE is created on PPE dynamically based on real PS2 VU1 code. Due to similarity of SPE with VU requested in IBM by Sony at design level, there is no VU1 interpreter or recompiler per se. Emulator take VU1 code, dismount it to parts by OP field types, and reassemble into ready SPE code using ready hex templates. I'm not familiar with professional naming of that operation, but its like ahead of time translation of code. So when VU1 code reach SPE is already translated to SPE opcodes. In other terms, SPE responsible for running VU1 is really running VU1 code in some way. | ||
In latest ps2_netemu function responsible for translating VU1 code into SPE ready code is located at 0x13C69C | In latest ps2_netemu function responsible for translating VU1 code into SPE ready code is located at 0x13C69C | ||
===IPU skip mpeg hack=== | |||
There are some leftovers of SKIP MPEG hack in SPE 6 (IPU), i'm not sure that is still available. | There are some leftovers of SKIP MPEG hack in SPE 6 (IPU), i'm not sure that is still available. | ||
Looking at cmd 0x1A there is small chance that is mentioned hack, but i can't confirm yet. | |||
===SPE4 and SPE5=== | ===SPE4 and SPE5=== | ||
Line 1,853: | Line 1,499: | ||
== ps2_netemu supported video modes == | == ps2_netemu supported video modes == | ||
Both HDTV modes (0x51 1080i and 0x52 720p) crash the emulator | 0x53 video mode (576p) seems to work right. Both HDTV modes (0x51 1080i and 0x52 720p) crash the emulator. Tested by forcing the values in the sceGsResetGraph function. | ||
=== Widescreen support === | === Widescreen support === | ||
If the game does retrieve the widescreen flag from the GetOSDConfigParam through the scescfGetAspect function, the results are as follows: | If the game does retrieve the widescreen flag from the GetOSDConfigParam through the scescfGetAspect function, the results are as follows: | ||
Line 1,864: | Line 1,509: | ||
== Emu Patches == | == Emu Patches == | ||
===Skip demo disc check=== | ===Skip demo disc check=== | ||
Line 1,923: | Line 1,531: | ||
in 4.75+ emu: 0x8EEA0 beq cr7, demo_check ---> nop | in 4.75+ emu: 0x8EEA0 beq cr7, demo_check ---> nop | ||