sahlberg / pop-fe

Python script to automate the process of fetching boxart and installing PS1 games (onto your PSP/VITA/PS2/PS3)
135 stars 13 forks source link

Cannot override game_id if the input is a multi disc game #27

Closed Fabax01 closed 1 year ago

Fabax01 commented 1 year ago

pop-fe# pop-fe.py --psp-dir=/psp --game_id=SLUS01163 /psp/game.cue /psp/game2.cue Processing /psp/game.cue ... Processing /psp/game2.cue ... Try URL http://www.hwc.nat.cu/psx/SLES_028.67_COV.jpg Falling back to PSXDATACENTRE for cover Id: SLES02867

sahlberg commented 1 year ago

Thanks. I have checked in a fix for this in current master. Please test.

I have also checked in a change so that it will install and build pop-e under linux on all pushes to github and verify that it can create PS3 and PSP images including multidisk. I have added a test for this so that it will not have a regression.

sahlberg commented 1 year ago

Also, I added a workflow that installs and builds pop-fe on ubuntu and then also runs some tests to create images. This is based on fake disk images (disk image with an ISO that only contains system.cnf and nothing else).

Might be useful to do something similar to docker. I.e. add a job that set up docker, builds a docker image for pop-fe and tests that it can convert a cue/bin into a PKG. Do you want to do that? I don't use docker myself but I guess I can figure it out if you don't want to. To make sure there are no future regressions in the docker build like the one you fixed the other day.

Fabax01 commented 1 year ago

Thanks! I'll test the fix ASAP.

Re:Docker workflow

As long as the tests pass under Debian/Ubuntu, there's no need for another testing workflow (there are rare exceptions as docker shares the host's kernel etc.) Pop-fe is issue-free under docker, runs as it should be. I had to fix the docker file as it did not have all of the dependencies fulfilled, (no atracdenc, no ffmpeg, no opencv). I'll clean it/update it in a bit (I saw that now there is a --install flag; It makes my original fix redundant, I'll let pop-fe handle it as the last step in the dockerfile.)

Fabax01 commented 1 year ago

pop-fe.py --psp-dir=. --game_id=SLPS01623 --snd0=/psp/testimages/vs/sine.wav --cover=/psp/testimages/vs/blank.png --pic0=/psp/testimages/vs/blank.png --pic1=/psp/testimages/vs/blank.png /psp/testimages/vs/vs.cue /psp/testimages/vs/vs.cue

Processing /psp/testimages/vs/vs.cue ... Processing /psp/testimages/vs/vs.cue ... Get cover from /psp/testimages/vs/blank.png Get PIC0/Screenshot from /psp/testimages/vs/blank.png Get PIC1/Screenshot from /psp/testimages/vs/blank.png Id: SLPS01623

Works great, but seems it changes only disc1's id. If I open eboot.pbp in a hex editor and search for PSISOIMG, just under it I see the disc id that pops uses for loading patches (As an example, try Strider 2 euro/pal. The game will freeze after the second stage's miniboss, unless you use the US/JP ID (hardcoded patch, _SLUS_01163 or _SLPS_02621)

In the test file, the first match has _SLPS_01623 under it, but disc 2 has _SLES_02754 instead.

sahlberg commented 1 year ago

Oh, the emulator inspects the disk id and applies patches based on it?

Ok, so currently --game_id only takes a single argument and it only applies to the first disk. I am happy to change this but I need to understand how/what would work. I could change it to allow --game_id to take a comma-separated list of IDs instead of just a single one, i.e. --game-id=SLUS01623,SLUS01163

Then it will override the game_id for the first n disks? Would that work?

(and it really should be --disk_id and not --game_id I think. I did not know very much about PSX disk games when I started so ...)

Fabax01 commented 1 year ago

Note that this is neither an issue nor a request; only information. With your fix POP-FE parses the correct ID for cover auto-download etc. and it is good enough for me. Anyone can easily edit the eboot.pbp if they need, and in rare cases it is necessary to not specify a custom gameid (as an example, Dino crisis PAL has libcrypt... if you tell the program to use the USA ID, it will not inject the data and will fail protection. (freeze before title screen). But if you do not, it will freeze when you aim with a shotgun...) The solution is simple: let pop-fe process the file with the original ID, then hex edit _SLES_xxxxx in _SLUS_yyyyy. .... or add a force libcrypt sub channel injection flag, which would be a mess with multidisc games. Probably not worth the effort. Anyway, enough blabbering... Thanks for the hard work.

(Nevermind, Github only now shows that you replied... sorry for the wall of text.)

Fabax01 commented 1 year ago

Ok, so currently --game_id only takes a single argument and it only applies to the first disk. I am happy to change this but I need to understand how/what would work. I could change it to allow --game_id to take a comma-separated list of IDs instead of just a single one, i.e. --game-id=SLUS01623,SLUS01163

Then it will override the game_id for the first n disks?

I think it would be a great solution. game_id=slus00000,slus000001 game.cue game2.cue first disc gets its ID changed in slus00000 and second into slus00001. But, again, please do not feel in a hurry to implement. POP-FE's eboots have the diskID clearly visible, unlike the official ones. Anyone can change the ID. (it is always after the PSISOIMG header...)

sahlberg commented 1 year ago

I will do this change to game_id next weekend.

As for editing the EBOOT.PBP. I think that would work for a PSP EBOOT but not a PS3 EBOOT. I think the PS3 only actually reads the disk sectors and the ATRAC3 audio streams from the EBOOT but it reads the PSISOIMG sections from ISO.BIN.DAT, so I think you would need to edit ISO.BIN.DAT but that file is both signed and encrypted so there would be many very annoying manual steps involved to edit it. Probably better to just let pop-fe do it.

You also brought up a good point about libcrypt. I think that should also be changed. I think the libcrypt patching should ignore what --game_id overrides the IDs to be and it should always use the ID that it reads from the bin file itself. That will require some rearrangement of in what order I do things in pop-fe but I can do that change too next weekend.

I.e. so 1, allow --game_id to override the ID for all disks, not just the first one 2, make libcrypt patching ignore --game_id and always use the ID it extracts from the bin file

sahlberg commented 1 year ago

Can you try current master? I changed it so that you can specify a comma separated list of IDs for multidics games. This also applies to if you put a file 'GAME_ID' in the same directory as the cue/bin file.

Libcrypt and generation of subchannel and magic word is still based on the id found in the corresponding cue/bin and is not affected by overriding the is using --game_id. Similarly, the resolution field (PAL or NTCS) is also based on the id from the cue/bin and is not affected by --game_id.

Is this kind of what you need for overriding the game id?

Fabax01 commented 1 year ago

Thanks, tested both on PS3, PSP & works great!