@@ -107,6 +107,7 @@ class GfxMatWriteMethod(enum.Enum):
107107 "OOT" : oot_default_draw_layers ,
108108}
109109
110+
110111def normalize_hex_pointer (name : str ) -> str :
111112 stripped = name .strip ()
112113 if stripped .lower ().startswith ("0x" ):
@@ -130,6 +131,7 @@ def format_asset_path(objectPath: str | None, name: str | None) -> str:
130131 return sanitized_name
131132 return sanitized_path
132133
134+
133135CCMUXDict = {
134136 "COMBINED" : 0 ,
135137 "TEXEL0" : 1 ,
@@ -2161,7 +2163,7 @@ def to_binary(self):
21612163 )
21622164
21632165 def to_soh_xml (self ):
2164- baseStr = " <Vtx X=\ " {pX}\ " Y=\ " {pY}\ " Z=\ " {pZ}\ " S=\ " {s}\ " T=\ " {t}\ " R=\ " {r}\ " G=\ " {g}\ " B=\ " {b}\ " A=\ " {a}\ " />"
2166+ baseStr = ' <Vtx X="{pX}" Y="{pY}" Z="{pZ}" S="{s}" T="{t}" R="{r}" G="{g}" B="{b}" A="{a}"/>'
21652167 return baseStr .format (
21662168 pX = self .position [0 ],
21672169 pY = self .position [1 ],
@@ -2262,7 +2264,7 @@ def to_binary(self):
22622264 return data
22632265
22642266 def to_soh_xml (self ):
2265- data = " <Vertex Version=\" 0 \ " >\n "
2267+ data = ' <Vertex Version="0 ">\n '
22662268 for vert in self .vertices :
22672269 data += "\t " + vert .to_soh_xml () + "\n "
22682270 data += "</Vertex>\n "
@@ -2361,7 +2363,7 @@ def to_c(self, f3d, name_override: Optional[str] = None):
23612363 return data
23622364
23632365 def to_soh_xml (self , modelDirPath , objectPath ):
2364- data = " <DisplayList Version=\" 0 \ " >\n "
2366+ data = ' <DisplayList Version="0 ">\n '
23652367 for command in self .commands :
23662368 if isinstance (command , (SPDisplayList , SPBranchList , SPVertex , DPSetTextureImage )):
23672369 data += "\t " + command .to_soh_xml (objectPath ) + "\n "
@@ -2380,13 +2382,15 @@ def toO2R(self, folderPath: str, segments: dict | None = None):
23802382 data .extend (struct .pack ("<I" , 1 ))
23812383 data .extend (struct .pack (">IIQIQIQQQI" , 0x4F444C54 , 0 , 0xDEADBEEFDEADBEEF , 0 , 0 , 0 , 0 , 0 , 0 , 0 ))
23822384
2383- data .extend (struct .pack (
2384- ">bBHI" ,
2385- 4 ,
2386- 0xFF ,
2387- 0xFFFF ,
2388- 0xFFFFFFFF ,
2389- ))
2385+ data .extend (
2386+ struct .pack (
2387+ ">bBHI" ,
2388+ 4 ,
2389+ 0xFF ,
2390+ 0xFFFF ,
2391+ 0xFFFFFFFF ,
2392+ )
2393+ )
23902394
23912395 data .extend (struct .pack (">II" , 0x33 << 24 , 0xBEEFBEEF ))
23922396
@@ -2894,7 +2898,7 @@ def to_soh_xml(self, modelDirPath, objectPath, include_cull_vertices=True, combi
28942898
28952899 if combined_call_lines or combined_other_lines :
28962900 data += (
2897- " <DisplayList Version=\" 0 \ " >\n "
2901+ ' <DisplayList Version="0 ">\n '
28982902 + "" .join (combined_call_lines + combined_other_lines )
28992903 + "</DisplayList>\n \n "
29002904 )
@@ -3440,7 +3444,7 @@ def to_soh_xml(self, modelDirPath, objectPath, include_cull_vertices=True, write
34403444 return ""
34413445
34423446 call_lines , other_lines = self .get_soh_root_draw_lines (objectPath )
3443- drawData = " <DisplayList Version=\" 0 \ " >\n " + "" .join (call_lines + other_lines ) + "</DisplayList>\n \n "
3447+ drawData = ' <DisplayList Version="0 ">\n ' + "" .join (call_lines + other_lines ) + "</DisplayList>\n \n "
34443448 writeXMLData (drawData , os .path .join (modelDirPath , self .draw .name ))
34453449 return drawData
34463450
@@ -3536,8 +3540,10 @@ def has_scroll_data(self):
35363540 True if either texture has non-zero scroll values
35373541 """
35383542 return (
3539- self .tile_scroll_tex0 .s != 0 or self .tile_scroll_tex0 .t != 0 or
3540- self .tile_scroll_tex1 .s != 0 or self .tile_scroll_tex1 .t != 0
3543+ self .tile_scroll_tex0 .s != 0
3544+ or self .tile_scroll_tex0 .t != 0
3545+ or self .tile_scroll_tex1 .s != 0
3546+ or self .tile_scroll_tex1 .t != 0
35413547 )
35423548
35433549 def to_soh_xml (self ):
@@ -3964,9 +3970,7 @@ def textureTypeO2R(self) -> int:
39643970 def toO2R (self , folderPath : str ):
39653971 data = bytearray (0 )
39663972
3967- print (
3968- f"FImage.toO2R { self .name } { self .fmt } { self .bitSize } { self .width } x{ self .height } { len (self .data )} bytes"
3969- )
3973+ print (f"FImage.toO2R { self .name } { self .fmt } { self .bitSize } { self .width } x{ self .height } { len (self .data )} bytes" )
39703974
39713975 data .extend (struct .pack ("<IIIQIQIQQQI" , 0 , 0x4F544558 , 0 , 0xDEADBEEFDEADBEEF , 0 , 0 , 0 , 0 , 0 , 0 , 0 ))
39723976 data .extend (struct .pack ("<IIII" , self .textureTypeO2R (), self .width , self .height , len (self .data )))
@@ -4149,6 +4153,7 @@ def to_c(self, static=True):
41494153 header += "segmented_to_virtual(" + self .vertList .name + " + " + str (self .offset ) + ")"
41504154 else :
41514155 header += self .vertList .name + " + " + str (self .offset )
4156+
41524157 return header + ", " + str (self .count ) + ", " + str (self .index ) + ")"
41534158
41544159 def toO2R (self , folderPath : str ):
@@ -4171,7 +4176,7 @@ def toO2R(self, folderPath: str):
41714176 return data
41724177
41734178 def to_soh_xml (self , objectPath = "" ):
4174- baseStr = " <LoadVertices Path=\ " {parent}/{vertexPath}\ " VertexBufferIndex=\ " {bufferIndex}\ " VertexOffset=\ " {vertexOffset}\ " Count=\ " {count}\ " />"
4179+ baseStr = ' <LoadVertices Path="{parent}/{vertexPath}" VertexBufferIndex="{bufferIndex}" VertexOffset="{vertexOffset}" Count="{count}"/>'
41754180 return baseStr .format (
41764181 parent = objectPath ,
41774182 vertexPath = self .vertList .name ,
@@ -5104,6 +5109,7 @@ def to_soh_xml(self, objectPath=""):
51045109 flags = "," .join (sorted (self .flagList ))
51055110 return f'<GeometryFlags Mode="Load" Flags="{ flags } "/>'
51065111
5112+
51075113def gsSPSetOtherMode (cmd , sft , length , data , f3d ):
51085114 if f3d .F3DEX_GBI_2 :
51095115 words = _SHIFTL (cmd , 24 , 8 ) | _SHIFTL (32 - (sft ) - (length ), 8 , 8 ) | _SHIFTL ((length ) - 1 , 0 , 8 ), data
@@ -5452,11 +5458,13 @@ def toO2R(self, folderPath: str):
54525458 return data
54535459
54545460 def to_soh_xml (self , objectPath = "" ):
5455- prefix = self . image . internal_path if self . image . internal_path else ( objectPath if self . image . filename is not None else "" )
5456- imagePath = format_asset_path ( prefix , self . image . name if self .image .name else "" )
5457- return (
5458- f'<SetTextureImage Path=" { imagePath } " Format=" { self . fmt } " Size=" { self .siz } " Width=" { self . width } "/>'
5461+ prefix = (
5462+ self .image .internal_path
5463+ if self . image . internal_path
5464+ else ( objectPath if self .image . filename is not None else "" )
54595465 )
5466+ imagePath = format_asset_path (prefix , self .image .name if self .image .name else "" )
5467+ return f'<SetTextureImage Path="{ imagePath } " Format="{ self .fmt } " Size="{ self .siz } " Width="{ self .width } "/>'
54605468
54615469
54625470def gsDPSetCombine (muxs0 , muxs1 , f3d ):
@@ -5532,7 +5540,7 @@ def _ac(name: str) -> str:
55325540 return name if name .startswith ("G_ACMUX_" ) else f"G_ACMUX_{ name } "
55335541
55345542 return (
5535- ' <SetCombineLERP '
5543+ " <SetCombineLERP "
55365544 f'A0="{ _cc (self .a0 )} " B0="{ _cc (self .b0 )} " C0="{ _cc (self .c0 )} " D0="{ _cc (self .d0 )} " '
55375545 f'Aa0="{ _ac (self .Aa0 )} " Ab0="{ _ac (self .Ab0 )} " Ac0="{ _ac (self .Ac0 )} " Ad0="{ _ac (self .Ad0 )} " '
55385546 f'A1="{ _cc (self .a1 )} " B1="{ _cc (self .b1 )} " C1="{ _cc (self .c1 )} " D1="{ _cc (self .d1 )} " '
@@ -5582,7 +5590,7 @@ def to_binary(self, f3d, segments):
55825590 def to_soh_xml (self , objectPath = "" ):
55835591 return (
55845592 f'<SetEnvColor R="{ self .r } " G="{ self .g } " B="{ self .b } " A="{ self .a } "'
5585- f' { getDynamicCosmeticXmlAttrs (self .cosmeticEntry , self .cosmeticCategory )} />'
5593+ f" { getDynamicCosmeticXmlAttrs (self .cosmeticEntry , self .cosmeticCategory )} />"
55865594 )
55875595
55885596
@@ -5645,7 +5653,7 @@ def to_binary(self, f3d, segments):
56455653 def to_soh_xml (self , objectPath = "" ):
56465654 return (
56475655 f'<SetPrimColor M="{ self .m } " L="{ self .l } " R="{ self .r } " G="{ self .g } " B="{ self .b } " A="{ self .a } "'
5648- f' { getDynamicCosmeticXmlAttrs (self .cosmeticEntry , self .cosmeticCategory )} />'
5656+ f" { getDynamicCosmeticXmlAttrs (self .cosmeticEntry , self .cosmeticCategory )} />"
56495657 )
56505658
56515659
@@ -5725,10 +5733,7 @@ def is_LOADTILE(self, f3d):
57255733 return self .tile == f3d .G_TX_LOADTILE
57265734
57275735 def to_soh_xml (self , objectPath = "" ):
5728- return (
5729- f'<SetTileSize T="{ self .tile } " Uls="{ self .uls } " Ult="{ self .ult } " '
5730- f'Lrs="{ self .lrs } " Lrt="{ self .lrt } "/>'
5731- )
5736+ return f'<SetTileSize T="{ self .tile } " Uls="{ self .uls } " Ult="{ self .ult } " ' f'Lrs="{ self .lrs } " Lrt="{ self .lrt } "/>'
57325737
57335738
57345739@dataclass (unsafe_hash = True )
@@ -5743,10 +5748,7 @@ def to_binary(self, f3d, segments):
57435748 return gsDPLoadTileGeneric (f3d .G_LOADTILE , self .tile , self .uls , self .ult , self .lrs , self .lrt )
57445749
57455750 def to_soh_xml (self , objectPath = "" ):
5746- return (
5747- f'<LoadTile Tile="{ self .tile } " Uls="{ self .uls } " Ult="{ self .ult } " '
5748- f'Lrs="{ self .lrs } " Lrt="{ self .lrt } "/>'
5749- )
5751+ return f'<LoadTile Tile="{ self .tile } " Uls="{ self .uls } " Ult="{ self .ult } " ' f'Lrs="{ self .lrs } " Lrt="{ self .lrt } "/>'
57505752
57515753
57525754@dataclass (unsafe_hash = True )
@@ -5816,8 +5818,7 @@ def to_binary(self, f3d, segments):
58165818
58175819 def to_soh_xml (self , objectPath = "" ):
58185820 return (
5819- f'<LoadBlock Tile="{ self .tile } " Uls="{ self .uls } " Ult="{ self .ult } " '
5820- f'Lrs="{ self .lrs } " Dxt="{ self .dxt } " />'
5821+ f'<LoadBlock Tile="{ self .tile } " Uls="{ self .uls } " Ult="{ self .ult } " ' f'Lrs="{ self .lrs } " Dxt="{ self .dxt } " />'
58215822 )
58225823
58235824
@@ -6522,5 +6523,4 @@ def to_soh_xml(self):
65226523 DPLoadTLUT_pal16 ,
65236524 DPLoadTLUT_pal256 ,
65246525 DPLoadTLUT ,
6525- ]
6526-
6526+ ]
0 commit comments