the vanished one Posted August 28, 2008 Share Posted August 28, 2008 Hi. I'm working on a UI mod for Planescape: Torment. It edits some offsets in the executable, but Torment.exe in the 4CD version of the game is different from the 2CD one. What can I write in my .tp2 file so that Weidu edits certain offsets if the mod is installed on Torment 4CD, and other offsets if installed on Torment 2CD? Example: For Torment 4CD, it should execute: WRITE_SHORT "0x3cad81" "1024" For Torment 2CD, it should execute: WRITE_SHORT "0x3cabc1" "1024" Perhaps it has been asked before, but I can't find anything. I remember something about checking the size of the file, and there's a IF_SIZE_IS command in WeiDU, but I don't know how to use it. Link to comment
Bearwere Posted August 28, 2008 Share Posted August 28, 2008 well, you could find an offset where 2-cd and 4-cd .exe have different values, make READ from this offset and thus determine the version Link to comment
the vanished one Posted August 28, 2008 Author Share Posted August 28, 2008 Thanks! If anyone else is interested, here's a quick version checker: BEGIN ~version checker~ COPY ~Torment.exe~ ~Torment.exe~ READ_SHORT 0x00293a96 ~offset_0x00293a96~ ACTION_IF ~%offset_0x00293a96%~ = 20992 THEN BEGIN PRINT ~4CD version~ END ELSE BEGIN PRINT ~2CD version~ END Link to comment
the vanished one Posted August 28, 2008 Author Share Posted August 28, 2008 Is it okay to COPY the same file twice? I can't find another way to READ from torment.exe. This is what I have now: COPY ~Torment.exe~ ~Torment.exe~ READ_SHORT 0x00293a96 ~offset_0x00293a96~ ACTION_IF ~%offset_0x00293a96%~ = 20992 THEN BEGIN PRINT ~4CD version~ COPY ~Torment.exe~ ~Torment.exe~ WRITE_SHORT "0x3cad81" "1024" WRITE_SHORT "0x3cad88" "768" WRITE_SHORT "0x3caeac" "1024" WRITE_SHORT "0x3caeb3" "1023" WRITE_SHORT "0x3caed7" "695" WRITE_SHORT "0x3caede" "695" ... ... ... WRITE_SHORT "0x2ca70f" "512" WRITE_SHORT "0x2ca716" "348" END ELSE BEGIN PRINT ~2CD version~ COPY ~Torment.exe~ ~Torment.exe~ WRITE_SHORT "0x3cabc1" "1024" WRITE_SHORT "0x3cabc8" "768" WRITE_SHORT "0x3cacec" "1024" WRITE_SHORT "0x3cacf3" "1023" WRITE_SHORT "0x3cad17" "695" WRITE_SHORT "0x3cad1e" "695" ... ... ... WRITE_SHORT "0x09a5cb" "512" WRITE_SHORT "0x09a5d7" "294" END Link to comment
Icendoan Posted August 28, 2008 Share Posted August 28, 2008 I'm not sure you even need to do that, just put the other fixes in another IF or ELSE instead of ENDing and COPYing again. So your code would be COPY ~Torment.exe~ ~Torment.exe~ READ_SHORT 0x00293a96 ~offset_0x00293a96~ ACTION_IF ~%offset_0x00293a96%~ = 20992 THEN BEGIN PRINT ~4CD version~ COPY ~Torment.exe~ ~Torment.exe~ WRITE_SHORT "0x3cad81" "1024" WRITE_SHORT "0x3cad88" "768" WRITE_SHORT "0x3caeac" "1024" WRITE_SHORT "0x3caeb3" "1023" WRITE_SHORT "0x3caed7" "695" WRITE_SHORT "0x3caede" "695" ... ... ... WRITE_SHORT "0x2ca70f" "512" WRITE_SHORT "0x2ca716" "348" ELSE BEGIN PRINT ~2CD version~ WRITE_SHORT "0x3cabc1" "1024" WRITE_SHORT "0x3cabc8" "768" WRITE_SHORT "0x3cacec" "1024" WRITE_SHORT "0x3cacf3" "1023" WRITE_SHORT "0x3cad17" "695" WRITE_SHORT "0x3cad1e" "695" ... ... ... WRITE_SHORT "0x09a5cb" "512" WRITE_SHORT "0x09a5d7" "294" END Icen Link to comment
the vanished one Posted August 28, 2008 Author Share Posted August 28, 2008 Sorry, I didn't explain myself well enough. The problem is with the very first COPY, the one I use to tell WeiDU that I need to READ from it. The other two are mutually exclusive, so only one is used. Link to comment
Taimon Posted August 28, 2008 Share Posted August 28, 2008 Yes you can copy a file to itself. I would use a single COPY and PATCH_IF / PATCH_PRINT in your case. Link to comment
the vanished one Posted August 28, 2008 Author Share Posted August 28, 2008 PATCH_IF is perfect. Thank you. Link to comment
Qwinn Posted August 29, 2008 Share Posted August 29, 2008 I'm actually doing some engine tweaks for the next version of my Fixpack, so I'm pretty deep in this myself. I wouldn't do a plain old "ELSE" if I were you. I'd put a condition on that "ELSE" to -verify- that it's the 2CD version (search differerent location for the same value, or same location for different value). Just to be safe. For example, I don't know yet if the german version of the game has a different .exe (something I'm trying to find out now). BG2 has a whole ton of different versions of their .exe. I just don't think it's safe to say "if this value isn't here, it MUST be the 2cd version"... leave room for other possibilities. If it fails both your checks, then you can safely PRINT "Error: Can't identify PS:T version", dump out, and we'll all be better for identifying a third version of the .exe. Qwinn Link to comment
the vanished one Posted August 29, 2008 Author Share Posted August 29, 2008 Yes, you're right. I'll do that. Also, thanks for your fix pack, UB and tweak tools, they're awesome. Link to comment
the vanished one Posted August 30, 2008 Author Share Posted August 30, 2008 In case anyone is interested, here's the latest version. It could probably still be improved. COPY ~Torment.exe~ ~Torment.exe~ SET ~failure~ = 0 READ_SHORT 0x00293a96 ~offset_0x00293a96~ PATCH_IF (~offset_0x00293a96~ = 20992) THEN BEGIN PATCH_PRINT ~4CD version~ WRITE_SHORT "0x3cad81" "1024" ... ... WRITE_SHORT "0x2ca716" "348" END ELSE BEGIN READ_SHORT 0x0056da27 ~offset_0x0056da27~ PATCH_IF (~offset_0x0056da27~ = 20992) THEN BEGIN PATCH_PRINT ~2CD version~ WRITE_SHORT "0x3cabc1" "1024" ... ... WRITE_SHORT "0x09a5d7" "294" END ELSE BEGIN PATCH_PRINT ~unsupported version~ SET ~failure~ = 1 END END ACTION_IF (~failure~ = 1) THEN BEGIN FAIL ~Error: your version of the game is not supported.~ END Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.