RED-Project icon indicating copy to clipboard operation
RED-Project copied to clipboard

Valis: The Fantasm Soldier

Open NeoArcade1 opened this issue 11 months ago • 14 comments

Anyone know if we have a PC Engine Super CD-ROM² bios stowed away here?

NeoArcade1 avatar Jan 10 '25 06:01 NeoArcade1

Anyone know if we have a PC Engine Super CD-ROM² bios stowed away here?

Edit: Completely revised my comment. Apparently the game uses Mednafen. Didn’t notice this as I was only checking the depots for the DLC. The ROMs should be in ValisCollection_Data/StreamingAssets/mednafen/mcs/, but a review commented that you can’t play them outside of this fork. Perhaps they made the BIOS emulation HLE with this version?

If you still can’t find the BIOS specifically, you can always check the memory for the game with something like HxD or dump it with Task Manager on Windows while the BIOS screen is active. The BIOS should be loaded into memory at that time if it is included!

DrAzathoth avatar Jan 10 '25 23:01 DrAzathoth

The files in the ValisCollection_Data/StreamingAssets/mednafen/mcs/ folder appear to just be savestates. If you add the .gz file extension to each of them, then decompress them with gunzip (7-Zip should work as well), then open them up in a hex editor, the files start with the string MDFNSVST, which is the signature for a Mednafen savestate, according to a changelog posted at https://forum.fobby.net/index.php?t=msg&th=764 :

June 26, 2012:
	Changed save-state header magic from the 16-bytes MEDNAFENSVESTATE to the 8-bytes MDFNSVST, to make room for a 64-bit creation
	timestamp(which will be used in the future).
	The old header magic is still recognized, for backwards compatibility.

farmerbb avatar Jan 11 '25 04:01 farmerbb

I suppose save states wouldn't have the bios. Speaking of an HLE bios, who knows if they would be compatible with any RetroArch cores, but I wonder if the MagicEngine HLE bios' could be extracted. I was able to download a pce.DMP from the task manager when the bios screen was up, but I don't know how to access the contents. I purchased a license years ago, however it doesn't seem to be updated any longer. The demo version is identical to the full version, but with a time limit. Currently, I rip my TGCD games with Alcohol 120% FE into .ccd format on a virtual machine, then mount them with ImgDrive Lite and launch them with MagicEngine via a .bat file.

NeoArcade1 avatar Jan 12 '25 06:01 NeoArcade1

I bought the bundle during the Steam spring sale. I think that the actual disc images are in the StreamingAssests\Game folder. It looks like each subfolder there has an edat file for each track on the original CD. The edats seem to be 44 bytes larger than the tracks if you split the bin cue into iso and cdr files. There looks to be an encryption on the edat files though.

stuckinstyx avatar Mar 13 '25 23:03 stuckinstyx

I compared my original valis II jap cd with edat files in StreamingAssests\Game folder and when sorted by size their is the same number of files plus one of 256k the one that start with "BRXZQ..." and maybe its a file needed to decrypt the rest. And the file of 4,9k "NFWRAW..." is probably the encrypted cue file. Maybe the files are fully decrypted and loaded into memory when the game running.

OfficerRyan1 avatar Mar 15 '25 02:03 OfficerRyan1

It looks like the .edat files might be XOR encrypted.

Inside the Mednafen source code included with the Valis game launcher, the file src/FileStream.cpp contains these additions when comparing it to the original Mednafen 1.29.0 source code:

isEncrypt = false;
size_t ext_len = strlen(".edat");
if((path.size() >= ext_len) && !MDFN_memazicmp(path.c_str() + (path.size() - ext_len), ".edat", ext_len))
{
    isEncrypt = true;
}
if(isEncrypt)
{
    for (size_t i = 0; i < dr; i++)
    {
        tmp_data[i] ^= 0x01;
    }
}

farmerbb avatar Mar 16 '25 07:03 farmerbb

Seems like this Steam forum post might contain the filenames for the BIOS and .cue files: https://steamcommunity.com/app/3097550/discussions/0/4696784467779444321/

farmerbb avatar Mar 16 '25 07:03 farmerbb

Ok, I'm able to successfully decrypt the files within the ValisCollection_Data/StreamingAssets/Game directory using Luigi Auriemma's XOR program. Encryption key is 0xAA.

Example decrypted .cue file for Valis II (Valis2_jp/NFWRAM3W8MJFKSSFQMDKNFPDM9VP6H5Y.edat): NFWRAM3W8MJFKSSFQMDKNFPDM9VP6H5Y.edat.txt

farmerbb avatar Mar 16 '25 14:03 farmerbb

Example commands for decrypting everything all at once using WSL, with xor.exe placed in the Game folder:

for i in $(find . -type d); do mkdir -p decrypted/$i; done
for i in $(find . -type f -name *.edat); do ./xor.exe $i decrypted/$i 0xAA; done

farmerbb avatar Mar 16 '25 14:03 farmerbb

It seems as if the post on the steam forum is explaining how to boot the game without mentioning that a downloaded bios is actually required to run the game.

NeoArcade1 avatar Mar 16 '25 23:03 NeoArcade1

I can confirm that the Super CD-ROM² BIOS v3.00 is within the data files for all games included in the Valis collection.

farmerbb avatar Mar 18 '25 19:03 farmerbb

Thank you for the clarity. Finally managed to get WSL working and sure enough by renaming the file that is sized at 256K to syscard3.pce, PCECD games boot up perfectly in RetroArch! Great Work!

To get the games to run on RetroArch, find the smallest file within each folder and rename the extension from "edat" to "cue". Then use this tool (the zipped one) to compile a CHD file.

NeoArcade1 avatar Mar 19 '25 22:03 NeoArcade1

Awesome! I should note that the source code for the XOR program is included in the zip, so you can also compile and run it on Linux. There's no hard dependency on WSL.

farmerbb avatar Mar 20 '25 20:03 farmerbb

I got them all working with RetroArch. Strangely I could run all but Valis I directly from the cue files, but I had to create a CHD to get the first one to work. Not sure why.

stuckinstyx avatar Mar 21 '25 17:03 stuckinstyx