2 Commity 7f3c218472 ... 6d1d34529e

Autor SHA1 Správa Dátum
  somewhatlurker 6d1d34529e ARB patcher: use a generic patch for instruction suffixes 4 rokov pred
  somewhatlurker c2147eccfc ARB Patcher: make status line respect terminal width 4 rokov pred

+ 2 - 5
source-code/data/amd-tools/ARB Patcher Source/gamesettings/divaaft.py

@@ -9,7 +9,7 @@ VP_SKINNING_SUB = "TEMP _adr;\n#\\1 \nTEMP mtx_tmp, mtx_tmp1, mtx_tmp2;\\2"
 
 # load the address temp with a texture coordinate instead
 # hardcoded to assume a 768*1 pixel texture
-VP_SKINNING_REGEX_2 = recompile(r"(BUFFER4[\s\S]*?)CVT.S32.F32\s*?(.*?),\s*?(.*?);")
+VP_SKINNING_REGEX_2 = recompile(r"(BUFFER4[\s\S]*?)CVT(?:.S32.F32)?\s*?(.*?),\s*?(.*?);")
 VP_SKINNING_SUB_2 = "\\1MUL \\2, \\3, 0.0013037809647979;" #1/767
 
 VP_SKINNING_REGEX_3 = recompile(r"(BUFFER4[\s\S]*?)(DP4 ([^;]*?), _mtxpal\[([^\]]*?\.x) \])")
@@ -27,7 +27,7 @@ VP_SKINNING_SUB_4 = "\\1mtx_tmp\\3"
 # make these run before VP_SKINNING_REGEX_4
 #TIGHTS_SKINNING_EFFECT_REGEX = recompile(r"(BUFFER4[\s\S]*?)SUBC .*?, vertex.attrib\[15\], .*?;\s*?SUBC1 tmp, vertex.attrib\[15\], .*?;[\s\S]*?XPD .*?, .*?, .*?;\s*?DP3_SAT (.*?), .*?, .*?;")
 #TIGHTS_SKINNING_EFFECT_SUB = "\\1MOV \\2, 0;"
-TIGHTS_SKINNING_EFFECT_REGEX = recompile(r"(BUFFER4[\s\S]*?)CVT.S32.F32\s*?(.*?),\s*?(.*?);")
+TIGHTS_SKINNING_EFFECT_REGEX = recompile(r"(BUFFER4[\s\S]*?)CVT(?:.S32.F32)?\s*?(.*?),\s*?(.*?);")
 TIGHTS_SKINNING_EFFECT_SUB = "\\1MUL \\2, \\3, 0.0013037809647979;"
 #TIGHTS_SKINNING_EFFECT_REGEX_2 = recompile(r"(BUFFER4[\s\S]*?)(IF GT1.y;[\s\S]*?|)(DP3 ([^;]*?), _mtxpal\[([^\]]*?\.x) \])(?![\s\S]*MUL  _adr)")
 #TIGHTS_SKINNING_EFFECT_REGEX_2b = recompile(r"(BUFFER4[\s\S]*?)(IF GT1.y;[\s\S]*?|)(DP3 ([^;]*?), _mtxpal\[([^\]]*?\.y) \])(?![\s\S]*MUL  _adr)")
@@ -91,9 +91,6 @@ def filename_filter(fname):
 
 # use to tweak reasults after patching
 def post_filter(fname, f_full):
-    # ideally this could do with a generic version in the main script...
-    f_full = f_full.replace('MOV.F.CC1 ', 'MOVC1 ')
-    
     f_full = f_full.replace('\nBUFFER4', '\n#BUFFER4')
     
     # fix tex sampler offsets

+ 9 - 1
source-code/data/amd-tools/ARB Patcher Source/main.py

@@ -98,7 +98,7 @@ def patch_shader(fname, f_lines, game_settings_module=None, enable_print_warning
     return f_full
 
 if __name__ == '__main__':
-    from os import listdir, makedirs
+    from os import listdir, makedirs, get_terminal_size
     from os.path import join as joinpath, splitext, isfile, exists, dirname
     from re import compile as recompile
     import sys
@@ -207,6 +207,14 @@ if __name__ == '__main__':
         status_str += ' {:.2%}'.format(progress_val)
         status_str += '   ' + fname
         
+        try:
+            terminal_width = get_terminal_size()[0]
+        except:
+            terminal_width = 120
+        
+        if len(status_str) > terminal_width:
+            status_str = status_str[:terminal_width-3] + '...'
+        
         # fix characters left on screen from a previous longer line
         # (without cursor staying off to the side)
         this_status_len = len(status_str)

+ 12 - 1
source-code/data/amd-tools/ARB Patcher Source/rules.py

@@ -10,7 +10,7 @@ PARAM_REGEX = recompile(r"(?<!#)(?<!#\s)((SHORT\s*?|LONG\s*?)?PARAM\s*?([^\[\]\s
 UNUSED_PARAM_REGEX = recompile(r"(?<!#)(?<!#\s)((SHORT\s*?|LONG\s*?)?PARAM\s*?([^\[\]\s]*?)(\s*?\[.*?\])?\s*?=\s*?([^\s].*?);)\s*(?![\s\S]*[\s\-{]\3[\s,;\[])")
 
 # I think some of these instructions might still be left after other patches..  they will be commented out
-BAD_INSTR_REGEX = recompile(r"((?<!#)(?<!#\s)(CVT.S32.F32|BUFFER4|POW|NRM|REP)\s+?.*?;|ENDREP;|[^;\n]*\s*?(p_coef2d\[idx.x\]).*?;)\s*")
+BAD_INSTR_REGEX = recompile(r"((?<!#)(?<!#\s)(CVT|BUFFER4|POW|NRM|REP)\s+?.*?;|ENDREP;|[^;\n]*\s*?(p_coef2d\[idx.x\]).*?;)\s*")
 
 # find the header tag to replace with !!ARBxx1.0 and an NV OPTION
 NVFP_HEADER_REGEX = recompile(r"!!NVfp\d\.\d")
@@ -52,6 +52,15 @@ CONDITIONAL_CAL_REGEX = recompile(r"CAL\s+?(.*?)\s+?\((.*?)\)\s*?;")
 CONDITIONAL_CAL_SUB = "IF \\2; CAL \\1; ENDIF;"
 
 
+# seems like some suffixes (eg .F, .CC1) don't work
+# first regex: drop everything before the CC suffix, and convert CC suffix to appended C0/C1
+INSTR_SUFFIX_REGEX = recompile(r"(;\s*?)([A-Z\d]+)[A-Z\d\.]*?\.CC(\d)")
+INSTR_SUFFIX_SUB = "\\1\\2C\\3"
+# second regex: remove all remaining suffixes (or all suffixes for instructions without CC)
+INSTR_SUFFIX_REGEX_2 = recompile(r"(;\s*?)([A-Z\d]+)\.[A-Z\.\d]+")
+INSTR_SUFFIX_SUB_2 = "\\1\\2"
+
+
 MATCH_FP_FNAME = recompile(r".*fp")
 MATCH_VP_FNAME = recompile(r".*vp")
 MATCH_ALL_FNAME = recompile(r".*")
@@ -65,4 +74,6 @@ fix_repls = [
     (MATCH_ALL_FNAME, RET_IF_REGEX, RET_IF_SUB, False),
     (MATCH_ALL_FNAME, CONDITIONAL_RET_REGEX, CONDITIONAL_RET_SUB, True),
     (MATCH_ALL_FNAME, CONDITIONAL_CAL_REGEX, CONDITIONAL_CAL_SUB, False),
+    (MATCH_ALL_FNAME, INSTR_SUFFIX_REGEX, INSTR_SUFFIX_SUB, False),
+    (MATCH_ALL_FNAME, INSTR_SUFFIX_REGEX_2, INSTR_SUFFIX_SUB_2, False),
 ]