Difference between revisions of "Get vector*matrix from GTE"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
  '''Parameters''' : r4 = pointer
 
  '''Parameters''' : r4 = pointer
                 0x00 - word (may be two halfwords)
+
                 0x00 - word Vector 0 X and Y  (2 halfwords ?)
                 0x04 - word
+
                 0x04 - word Vector 0 Z
 
               r5 = pointer for return values
 
               r5 = pointer for return values
 
               r6 = pointer for return value
 
               r6 = pointer for return value
 
   
 
   
 
  '''Returns''' : Some vectors maths at r5 0x00, 0x04 and 0x08
 
  '''Returns''' : Some vectors maths at r5 0x00, 0x04 and 0x08
           Value at gtecr31 at r2 0x00           
+
           Value at gtecr31 at r6 0x00           
 
  -----------------------------------------------------------------------------------------------------------
 
  -----------------------------------------------------------------------------------------------------------
 
  8001d578: c8800000 lwc2 gtedr00_vxy0,0x0000(r4) {{f/load|Load word at r4 0x0000 to coprocessor 2 - vxy0 (vector 0 X and Y)}}
 
  8001d578: c8800000 lwc2 gtedr00_vxy0,0x0000(r4) {{f/load|Load word at r4 0x0000 to coprocessor 2 - vxy0 (vector 0 X and Y)}}
Line 12: Line 12:
 
  8001d580: 00000000 nop
 
  8001d580: 00000000 nop
 
  8001d584: 4a480012 mvmva 0x1,0x0,0x0,0x0,0x0 Multiply vector by matrix and vector addition  (See notes)
 
  8001d584: 4a480012 mvmva 0x1,0x0,0x0,0x0,0x0 Multiply vector by matrix and vector addition  (See notes)
  8001d588: e8b90000 swc2 gtedr25_mac1,0x0000(r5) {{f/store|Store word from mac1 to r5 0x000}}
+
  8001d588: e8b90000 swc2 gtedr25_mac1,0x0000(r5) {{f/store|Store word from mac1 to r5 0x000}} may be X coordinates*28 (see notes)
  8001d58c: e8ba0004 swc2 gtedr26_mac2,0x0004(r5) {{f/store|Store word from mac2 to r5 0x004}}
+
  8001d58c: e8ba0004 swc2 gtedr26_mac2,0x0004(r5) {{f/store|Store word from mac2 to r5 0x004}} Height related
  8001d590: e8bb0008 swc2 gtedr27_mac3,0x0008(r5) {{f/store|Store word from mac3 to r5 0x008}}
+
  8001d590: e8bb0008 swc2 gtedr27_mac3,0x0008(r5) {{f/store|Store word from mac3 to r5 0x008}} may be Y coordinates*28
 
  8001d594: 4842f800 cfc2 r2,gtecr31_flag         r2 = gtecr31 (number of leading 0 (1 if negative) from last word moved to gtedr30_lzcs (see [[Get_Square_root_of_r4_dealing_with_4096]])
 
  8001d594: 4842f800 cfc2 r2,gtecr31_flag         r2 = gtecr31 (number of leading 0 (1 if negative) from last word moved to gtedr30_lzcs (see [[Get_Square_root_of_r4_dealing_with_4096]])
 
  8001d598: 03e00008 jr r31
 
  8001d598: 03e00008 jr r31
Line 34: Line 34:
 
  CV = vector specified by cv
 
  CV = vector specified by cv
 
   
 
   
  MAC1=A1[CV1 + MX11*V1 + MX12*V2 + MX13*V3]
+
  MAC1=A1[CV1 + MX11*V1 + MX12*V2 + MX13*V3] div by 28 and used as X coord (in 0x001af8b4)
 
  MAC2=A2[CV2 + MX21*V1 + MX22*V2 + MX23*V3]
 
  MAC2=A2[CV2 + MX21*V1 + MX22*V2 + MX23*V3]
  MAC3=A3[CV3 + MX31*V1 + MX32*V2 + MX33*V3]
+
  MAC3=A3[CV3 + MX31*V1 + MX32*V2 + MX33*V3] div by 28 and used as Y coord (in 0x001af8b4)
 
   
 
   
 
  IR1=Lm_B1[MAC1]
 
  IR1=Lm_B1[MAC1]
Line 104: Line 104:
 
  001aa6a0: [[Composite_frame_loading_for_parameter_sets]]
 
  001aa6a0: [[Composite_frame_loading_for_parameter_sets]]
 
  001af1c0:
 
  001af1c0:
  001afca4:
+
  001afca4:  
 
  001b1334:
 
  001b1334:
 
  001b13d4:
 
  001b13d4:
 
  001b1eb4:
 
  001b1eb4:

Latest revision as of 20:15, 28 January 2022

Parameters : r4 = pointer
               0x00 - word Vector 0 X and Y  (2 halfwords ?)
               0x04 - word Vector 0 Z
             r5 = pointer for return values
             r6 = pointer for return value

Returns : Some vectors maths at r5 0x00, 0x04 and 0x08
          Value at gtecr31 at r6 0x00          
-----------------------------------------------------------------------------------------------------------
8001d578: c8800000	lwc2 gtedr00_vxy0,0x0000(r4)	Load word at r4 0x0000 to coprocessor 2 - vxy0 (vector 0 X and Y)	
8001d57c: c8810004	lwc2 gtedr01_vz0,0x0004(r4)  	Load word at r4 0x0004 to coprocessor 2 - vz0 (vector 0 Z)	
8001d580: 00000000	nop		
8001d584: 4a480012	mvmva 0x1,0x0,0x0,0x0,0x0	Multiply vector by matrix and vector addition   (See notes)	
8001d588: e8b90000	swc2 gtedr25_mac1,0x0000(r5)	Store word from mac1 to r5 0x000 may be X coordinates*28 (see notes)	
8001d58c: e8ba0004	swc2 gtedr26_mac2,0x0004(r5)	Store word from mac2 to r5 0x004 Height related	
8001d590: e8bb0008	swc2 gtedr27_mac3,0x0008(r5)	Store word from mac3 to r5 0x008 may be Y coordinates*28
8001d594: 4842f800	cfc2 r2,gtecr31_flag	        r2 = gtecr31 (number of leading 0 (1 if negative) from last word moved to gtedr30_lzcs (see Get_Square_root_of_r4_dealing_with_4096)	
8001d598: 03e00008	jr r31		
8001d59c: acc20000	sw r2,0x0000(r6)	        store gtecr30_lzcs leading zeros (or one) to r6 0x00 

Notes

MVMVA 8 cop2 0x0400012 Multiply vector by matrix and vector addition.
Fields: sf, mx, v, cv, lm

in: V0/V1/V2/IR Vector v0, v1, v2 or [IR1,IR2,IR3]
    R/LLM/LCM Rotation, light or color matrix. [1,3,12]
    TR/BK Translation or background color vector.

out: [IR1,IR2,IR3] Short vector
     [MAC1,MAC2,MAC3] Long vector

Calculation:
MX = matrix specified by mx
V = vector specified by v
CV = vector specified by cv

MAC1=A1[CV1 + MX11*V1 + MX12*V2 + MX13*V3] div by 28 and used as X coord (in 0x001af8b4)
MAC2=A2[CV2 + MX21*V1 + MX22*V2 + MX23*V3]
MAC3=A3[CV3 + MX31*V1 + MX32*V2 + MX33*V3] div by 28 and used as Y coord (in 0x001af8b4)

IR1=Lm_B1[MAC1]
IR2=Lm_B2[MAC2]
IR3=Lm_B3[MAC3]

Notes:
The cv field allows selection of the far color vector, but this vector
is not added correctly by the GTE.

Return locations

Battle.bin
0007d67c: 0007d5d0_-_0007db18
0007d69c: 0007d5d0_-_0007db18
0007d6bc: 0007d5d0_-_0007db18
0007d6dc: 0007d5d0_-_0007db18
0007dad0: 0007d5d0_-_0007db18
0007dc20: 0007db1c_-_0007e300
0007dc40: 0007db1c_-_0007e300
0007dc60: 0007db1c_-_0007e300
0007dc80: 0007db1c_-_0007e300
0007de8c: 0007db1c_-_0007e300
0007deac: 0007db1c_-_0007e300
0007ded4: 0007db1c_-_0007e300
0007defc: 0007db1c_-_0007e300
0007e044: 0007db1c_-_0007e300
0007e06c: 0007db1c_-_0007e300
0007e08c: 0007db1c_-_0007e300
0007e0ac: 0007db1c_-_0007e300
0007e50c: 0007e304_-_0007e728
0007e6e0: 0007e304_-_0007e728
0007e86c: 0007e72c_-_0007e9a4
0007f0ec: Display_Status_Bubble
0007f164: Display_Status_Bubble
0007f32c: 0007f2ac_-_0007f3fc
00086ba8: 00086b44_-_00086dc0
00086d7c: 00086b44_-_00086dc0
00089214: 000890b8_-_00089248
000893e8: 00089384_-_00089458
00089414: 00089384_-_00089458
0008c5b4: 0008c550_-_0008c5e4
000e8d74: Background_Tile_Color_For_Targeting/Movement
000e9110: Background_Tile_Color_For_Targeting/Movement
000e96c8: Background_Tile_Color_For_Targeting/Movement
000e9f28: Background_Tile_Color_For_Targeting/Movement
000ea438: Background_Tile_Color_For_Targeting/Movement
000ea4a0: Background_Tile_Color_For_Targeting/Movement
000ea65c: Background_Tile_Color_For_Targeting/Movement
000eea2c: 000ee95c_-_000eeaf4
001a580c: 001a5798_-_001a5b44
001a5f4c: 001a6010_-_001a601c
001a6460: Emitter_Control_Routine
001a66cc: Emitter_Control_Routine
001a6924: Emitter_Control_Routine
001a6dfc: Emitter_Control_Routine
001a7054: Emitter_Control_Routine
001a7084: Emitter_Control_Routine
001a7318: Emitter_Control_Routine
001a7340: Emitter_Control_Routine
001a7440: Emitter_Control_Routine
001a7468: Emitter_Control_Routine
001a8160: 001a7f5c_-_001a8668
001a822c: 001a7f5c_-_001a8668
001a8294: 001a7f5c_-_001a8668
001a84a4: 001a7f5c_-_001a8668
001a84d8: 001a7f5c_-_001a8668
001aa520: Composite_frame_loading_for_parameter_sets
001aa6a0: Composite_frame_loading_for_parameter_sets
001af1c0:
001afca4: 
001b1334:
001b13d4:
001b1eb4: