@@ -106,6 +106,7 @@ class GfxMatWriteMethod(enum.Enum):
106106 "OOT" : oot_default_draw_layers ,
107107}
108108
109+
109110def normalize_hex_pointer (name : str ) -> str :
110111 stripped = name .strip ()
111112 if stripped .lower ().startswith ("0x" ):
@@ -129,6 +130,7 @@ def format_asset_path(objectPath: str | None, name: str | None) -> str:
129130 return sanitized_name
130131 return sanitized_path
131132
133+
132134CCMUXDict = {
133135 "COMBINED" : 0 ,
134136 "TEXEL0" : 1 ,
@@ -1879,7 +1881,6 @@ def __init__(self):
18791881 self .interval = 1
18801882
18811883
1882-
18831884def tile_func (direction : str , speed : int , cmd_num : int ):
18841885 if speed == 0 or speed is None :
18851886 return None
@@ -2144,7 +2145,6 @@ def to_binary(self):
21442145 + bytearray (self .colorOrNormal )
21452146 )
21462147
2147-
21482148 def to_c (self ):
21492149 def spc (x ):
21502150 return "{" + ", " .join ([str (a ) for a in x ]) + "}"
@@ -2232,7 +2232,6 @@ def to_binary(self):
22322232 data .extend (vert .to_binary ())
22332233 return data
22342234
2235-
22362235 def to_c (self ):
22372236 data = CData ()
22382237 data .header = f"extern Vtx { self .name } [{ len (self .vertices )} ];\n "
@@ -2325,7 +2324,6 @@ def to_c(self, f3d, name_override: Optional[str] = None):
23252324
23262325 return data
23272326
2328-
23292327 def toO2R (self , folderPath : str , segments : dict | None = None ):
23302328 data = bytearray (0 )
23312329
@@ -2334,13 +2332,15 @@ def toO2R(self, folderPath: str, segments: dict | None = None):
23342332 data .extend (struct .pack ("<I" , 1 ))
23352333 data .extend (struct .pack (">IIQIQIQQQI" , 0x4F444C54 , 0 , 0xDEADBEEFDEADBEEF , 0 , 0 , 0 , 0 , 0 , 0 , 0 ))
23362334
2337- data .extend (struct .pack (
2338- ">bBHI" ,
2339- 4 ,
2340- 0xFF ,
2341- 0xFFFF ,
2342- 0xFFFFFFFF ,
2343- ))
2335+ data .extend (
2336+ struct .pack (
2337+ ">bBHI" ,
2338+ 4 ,
2339+ 0xFF ,
2340+ 0xFFFF ,
2341+ 0xFFFFFFFF ,
2342+ )
2343+ )
23442344
23452345 data .extend (struct .pack (">II" , 0x33 << 24 , 0xBEEFBEEF ))
23462346
@@ -2833,7 +2833,6 @@ def to_c_material_revert(self, gfxFormatter):
28332833 data .append (self .materialRevert .to_c (self .f3d ))
28342834 return data
28352835
2836-
28372836 def to_c (self , textureExportSettings : TextureExportSettings , gfxFormatter : GfxFormatter ):
28382837 texCSeparate = textureExportSettings .texCSeparate
28392838 savePNG = textureExportSettings .savePNG
@@ -2951,8 +2950,6 @@ def save_textures(self, exportPath):
29512950 image .filepath = oldpath
29522951 return texturesSaved
29532952
2954-
2955-
29562953 def freePalettes (self ):
29572954 pass
29582955
@@ -3141,8 +3138,6 @@ def save_binary(self, romfile, f3d, segments):
31413138 for cmd_list in self .draw_overrides :
31423139 cmd_list .save_binary (romfile , f3d , segments )
31433140
3144-
3145-
31463141 def to_c (self , f3d : F3D , gfxFormatter : GfxFormatter ):
31473142 staticData = CData ()
31483143
@@ -3191,7 +3186,6 @@ def save_binary(self, romfile, f3d, segments):
31913186 self .triList .save_binary (romfile , f3d , segments )
31923187 self .vertexList .save_binary (romfile )
31933188
3194-
31953189 def to_c (self , f3d , gfxFormatter ):
31963190 data = CData ()
31973191 data .append (self .vertexList .to_c ())
@@ -3228,12 +3222,13 @@ def has_scroll_data(self):
32283222 True if either texture has non-zero scroll values
32293223 """
32303224 return (
3231- self .tile_scroll_tex0 .s != 0 or self .tile_scroll_tex0 .t != 0 or
3232- self .tile_scroll_tex1 .s != 0 or self .tile_scroll_tex1 .t != 0
3225+ self .tile_scroll_tex0 .s != 0
3226+ or self .tile_scroll_tex0 .t != 0
3227+ or self .tile_scroll_tex1 .s != 0
3228+ or self .tile_scroll_tex1 .t != 0
32333229 )
32343230
32353231
3236-
32373232def get_f3d_mat_from_version (material : bpy .types .Material ):
32383233 return material .f3d_mat if material .mat_ver > 3 else material
32393234
@@ -3325,7 +3320,6 @@ def save_binary(self, romfile, f3d, segments):
33253320 if self .revert is not None and self .revert .tag .Export :
33263321 self .revert .save_binary (romfile , f3d , segments )
33273322
3328-
33293323 def to_c (self , f3d ):
33303324 data = CData ()
33313325 if self .material .tag .Export :
@@ -3622,9 +3616,7 @@ def textureTypeO2R(self) -> int:
36223616 def toO2R (self , folderPath : str ):
36233617 data = bytearray (0 )
36243618
3625- print (
3626- f"FImage.toO2R { self .name } { self .fmt } { self .bitSize } { self .width } x{ self .height } { len (self .data )} bytes"
3627- )
3619+ print (f"FImage.toO2R { self .name } { self .fmt } { self .bitSize } { self .width } x{ self .height } { len (self .data )} bytes" )
36283620
36293621 data .extend (struct .pack ("<IIIQIQIQQQI" , 0 , 0x4F544558 , 0 , 0xDEADBEEFDEADBEEF , 0 , 0 , 0 , 0 , 0 , 0 , 0 ))
36303622 data .extend (struct .pack ("<IIII" , self .textureTypeO2R (), self .width , self .height , len (self .data )))
@@ -3749,7 +3741,6 @@ def _resolve_matrix_address(self):
37493741 pass
37503742 return address
37513743
3752-
37533744 def toO2R (self , folderPath : str ):
37543745 data = bytearray (0 )
37553746
@@ -3803,6 +3794,7 @@ def to_c(self, static=True):
38033794 header += "segmented_to_virtual(" + self .vertList .name + " + " + str (self .offset ) + ")"
38043795 else :
38053796 header += self .vertList .name + " + " + str (self .offset )
3797+
38063798 return header + ", " + str (self .count ) + ", " + str (self .index ) + ")"
38073799
38083800 def toO2R (self , folderPath : str ):
@@ -3825,7 +3817,6 @@ def toO2R(self, folderPath: str):
38253817 return data
38263818
38273819
3828-
38293820@dataclass (unsafe_hash = True )
38303821class SPViewport (GbiMacro ):
38313822 # v = seg pointer, n = count, v0 = ?
@@ -3864,7 +3855,6 @@ def to_c(self, static=True):
38643855 else :
38653856 return "glistp = " + self .displayList .name + "(glistp)"
38663857
3867-
38683858 def toO2R (self , folderPath : str ):
38693859 data = bytearray (0 )
38703860
@@ -3911,7 +3901,6 @@ def to_binary(self, f3d, segments):
39113901 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
39123902
39133903
3914-
39153904# SPSprite2DBase
39163905
39173906
@@ -4032,7 +4021,6 @@ def to_binary(self, f3d, segments):
40324021 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
40334022
40344023
4035-
40364024@dataclass (unsafe_hash = True )
40374025class SPLine3D (GbiMacro ):
40384026 v0 : int
@@ -4091,7 +4079,6 @@ def to_binary(self, f3d, segments):
40914079 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
40924080
40934081
4094-
40954082# F3DEX3 TODO: Encoding of _g*SP5Triangles commands (SPTriangleStrip, SPTriangleFan)
40964083# and support for these in export including tri reordering
40974084
@@ -4109,7 +4096,6 @@ def to_binary(self, f3d, segments):
41094096 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
41104097
41114098
4112-
41134099@dataclass (unsafe_hash = True )
41144100class SPSegment (GbiMacro ):
41154101 segment : int
@@ -4494,7 +4480,6 @@ def size(self, f3d):
44944480 return GFX_SIZE * (2 + max (len (self .lights .l ), 1 ))
44954481
44964482
4497-
44984483# F3DEX3 TODO: SPCameraWorld
44994484
45004485# Reflection/Hiliting Macros
@@ -4620,7 +4605,6 @@ def to_binary(self, f3d, segments):
46204605 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
46214606
46224607
4623-
46244608# SPTextureL
46254609
46264610
@@ -4691,7 +4675,6 @@ def to_binary(self, f3d, segments):
46914675 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
46924676
46934677
4694-
46954678@dataclass (unsafe_hash = True )
46964679class SPClearGeometryMode (GbiMacro ):
46974680 flagList : set [str ] = field (default_factory = set )
@@ -4705,7 +4688,6 @@ def to_binary(self, f3d, segments):
47054688 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
47064689
47074690
4708-
47094691@dataclass (unsafe_hash = True )
47104692class SPLoadGeometryMode (GbiMacro ):
47114693 flagList : set [str ]
@@ -4784,7 +4766,6 @@ def to_binary(self, f3d, segments):
47844766 return gsSPSetOtherMode (cmd , sft , self .length , data , f3d )
47854767
47864768
4787-
47884769@dataclass (unsafe_hash = True )
47894770class SPSetOtherModeSub (GbiMacro ):
47904771 mode : str
@@ -4875,7 +4856,6 @@ def to_binary(self, f3d, segments):
48754856 return gsSPSetOtherMode (f3d .G_SETOTHERMODE_H , f3d .G_MDSFT_TEXTLUT , 2 , modeVal , f3d )
48764857
48774858
4878-
48794859@dataclass (unsafe_hash = True )
48804860class DPSetTextureFilter (SPSetOtherModeHSub ):
48814861 def to_binary (self , f3d , segments ):
@@ -5059,7 +5039,6 @@ def toO2R(self, folderPath: str):
50595039 return data
50605040
50615041
5062-
50635042def gsDPSetCombine (muxs0 , muxs1 , f3d ):
50645043 words = _SHIFTL (f3d .G_SETCOMBINE , 24 , 8 ) | _SHIFTL (muxs0 , 0 , 24 ), muxs1
50655044 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
@@ -5125,7 +5104,6 @@ def to_binary(self, f3d, segments):
51255104 )
51265105 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
51275106
5128-
51295107 def to_c (self , static = True ):
51305108 if static :
51315109 return f"gsDPSetCombineLERP({ ', ' .join ( self .getargs (static ) )} )"
@@ -5142,8 +5120,6 @@ def sDPRGBColor(cmd, r, g, b, a):
51425120 return gsDPSetColor (cmd , (_SHIFTL (r , 24 , 8 ) | _SHIFTL (g , 16 , 8 ) | _SHIFTL (b , 8 , 8 ) | _SHIFTL (a , 0 , 8 )))
51435121
51445122
5145-
5146-
51475123@dataclass (unsafe_hash = True )
51485124class DPSetEnvColor (GbiMacro ):
51495125 r : int
@@ -5157,7 +5133,6 @@ def to_binary(self, f3d, segments):
51575133 return sDPRGBColor (f3d .G_SETENVCOLOR , self .r , self .g , self .b , self .a )
51585134
51595135
5160-
51615136@dataclass (unsafe_hash = True )
51625137class DPSetBlendColor (GbiMacro ):
51635138 r : int
@@ -5215,7 +5190,6 @@ def to_binary(self, f3d, segments):
52155190 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
52165191
52175192
5218-
52195193@dataclass (unsafe_hash = True )
52205194class SPLightToRDP (GbiMacro ):
52215195 light : int
@@ -5292,7 +5266,6 @@ def is_LOADTILE(self, f3d):
52925266 return self .tile == f3d .G_TX_LOADTILE
52935267
52945268
5295-
52965269@dataclass (unsafe_hash = True )
52975270class DPLoadTile (GbiMacro ):
52985271 tile : int
@@ -5305,7 +5278,6 @@ def to_binary(self, f3d, segments):
53055278 return gsDPLoadTileGeneric (f3d .G_LOADTILE , self .tile , self .uls , self .ult , self .lrs , self .lrt )
53065279
53075280
5308-
53095281@dataclass (unsafe_hash = True )
53105282class DPSetTile (GbiMacro ):
53115283 fmt : str
@@ -5347,7 +5319,6 @@ def is_LOADTILE(self, f3d):
53475319 return self .tile == f3d .G_TX_LOADTILE
53485320
53495321
5350-
53515322@dataclass (unsafe_hash = True )
53525323class DPLoadBlock (GbiMacro ):
53535324 tile : int
@@ -5365,7 +5336,6 @@ def to_binary(self, f3d, segments):
53655336 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
53665337
53675338
5368-
53695339@dataclass (unsafe_hash = True )
53705340class DPLoadTLUTCmd (GbiMacro ):
53715341 tile : int
@@ -5376,7 +5346,6 @@ def to_binary(self, f3d, segments):
53765346 return words [0 ].to_bytes (4 , "big" ) + words [1 ].to_bytes (4 , "big" )
53775347
53785348
5379-
53805349@dataclass (unsafe_hash = True )
53815350class DPLoadTextureBlock (GbiMacro ):
53825351 timg : FImage
@@ -6017,28 +5986,24 @@ def to_binary(self, f3d, segments):
60175986 return gsDPNoParam (f3d .G_RDPFULLSYNC )
60185987
60195988
6020-
60215989@dataclass (unsafe_hash = True )
60225990class DPTileSync (GbiMacro ):
60235991 def to_binary (self , f3d , segments ):
60245992 return gsDPNoParam (f3d .G_RDPTILESYNC )
60255993
60265994
6027-
60285995@dataclass (unsafe_hash = True )
60295996class DPPipeSync (GbiMacro ):
60305997 def to_binary (self , f3d , segments ):
60315998 return gsDPNoParam (f3d .G_RDPPIPESYNC )
60325999
60336000
6034-
60356001@dataclass (unsafe_hash = True )
60366002class DPLoadSync (GbiMacro ):
60376003 def to_binary (self , f3d , segments ):
60386004 return gsDPNoParam (f3d .G_RDPLOADSYNC )
60396005
60406006
6041-
60426007F3DClassesWithPointers = [
60436008 SPVertex ,
60446009 SPDisplayList ,
@@ -6058,4 +6023,3 @@ def to_binary(self, f3d, segments):
60586023 DPLoadTLUT_pal256 ,
60596024 DPLoadTLUT ,
60606025]
6061-
0 commit comments