Seek Obstacle On Trajectory
Jump to navigation
Jump to search
0x801af8b4 - 0x801afb34 Parameters : r4 = 0x1f800000 = pointer to list of targetable units ( see Data details) r5 = Pointer to trajectory coordinates (host vector*matrix) see Get_vector*matrix_from_GTE 0x00 : [Vector1 + Matrix*vector] (used versus X coordinates) 0x04 : [Vector2 + Matrix*vector] (used versus height data) 0x08 : [Vector3 + Matrix*vector] (used versus X coordinates) r6 = Target ID pointer ( 0x801b8b64 ) r7 = Current attack map coordinates pointer ( 0x801b8b68 ) Returns : r2 0x01 if there's an obstacle on trajectory (map or unit) Update Target ID at 0x801b864 (r6 input) if obstacle is a unit Update attack current X (from trajectory) at 0x801b8b68 (r7 0x00) Update attack current elevation at 0x801b86a (r7 0x02) Update attack current Y (from trajectory) at 0x801b8b68 (r7 0x04) Store Tile data 0x06 flags at 0x801b8b94 if a map obstacle is met Note : coordinates may be keept untouched if trajectory is stopped as an obstacle ----------------------------------------------------------------------------------------------- 001af8b4: 27bdffd0 addiu r29,r29,-0x0030 001af8b8: afb20020 sw r18,0x0020(r29) 001af8bc: 00809021 addu r18,r4,r0 |r18 = 0x1f800000 001af8c0: afb1001c sw r17,0x001c(r29) | 001af8c4: 00a08821 addu r17,r5,r0 |r17 = vector*matrix pointer 001af8c8: afb30024 sw r19,0x0024(r29) | 001af8cc: 00c09821 addu r19,r6,r0 |r19 = Target ID pointer 0x8018b64 001af8d0: 3c049249 lui r4,0x9249 |r4 = 0x92490000 001af8d4: 2402ffff addiu r2,r0,-0x0001 |r2 = -0x01 001af8d8: afbf0028 sw r31,0x0028(r29) | 001af8dc: afb00018 sw r16,0x0018(r29) | 001af8e0: ae620000 sw r2,0x0000(r19) | 001af8e4: 8e230000 lw r3,0x0000(r17) |r3 = [Vector1 + Matrix*vector] see Get_vector*matrix_from_GTE 001af8e8: 34842493 ori r4,r4,0x2493 |r4 = 0x92492493 (= -3/7 * 2^32) 001af8ec: 00640018 mult r3,r4 | [Vector1 + Matrix*vector] * ( -3/7 * 2^32) 001af8f0: 00e08021 addu r16,r7,r0 |r16 = Attack's current X pointer 001af8f4: 00001010 mfhi r2 |r2 = [Vector1 + Matrix*vector] * -3/7 001af8f8: 00431021 addu r2,r2,r3 |r2 = [Vector1 + Matrix*vector] *4/7 001af8fc: 00021103 sra r2,r2,0x04 |r2 = [Vector1 + Matrix*vector]/28 001af900: 00031fc3 sra r3,r3,0x1f |rounding stuff (= 0x01 if first bit is 1) 001af904: 00431023 subu r2,r2,r3 |r2 = [Vector1 + Matrix*vector]/28 (- 0x00) 001af908: a6020000 sh r2,0x0000(r16) |Store [Vector1 + Matrix*vector]/28 as attack current X 001af90c: 8e230008 lw r3,0x0008(r17) |r3 = [Vector3 + Matrix*vector] see Get_vector*matrix_from_GTE 001af910: 00000000 nop | 001af914: 00640018 mult r3,r4 | [Vector3 + Matrix*vector] * ( -3/7 * 2^32) 001af918: 00003021 addu r6,r0,r0 |r6 = 0x00 001af91c: 86040000 lh r4,0x0000(r16) |r4 = Attack's current X 001af920: 00001010 mfhi r2 |r2 = [Vector3 + Matrix*vector] * -3/7 001af924: 00431021 addu r2,r2,r3 |r2 = [Vector3 + Matrix*vector] *4/7 001af928: 00021103 sra r2,r2,0x04 |r2 = [Vector3 + Matrix*vector]/28 001af92c: 00031fc3 sra r3,r3,0x1f |rounding stuff (= 0x01 if first bit is 1) 001af930: 00431023 subu r2,r2,r3 |r2 = [Vector3 + Matrix*vector]/28 (- 0x00) 001af934: 00022c00 sll r5,r2,0x10 | 001af938: 00052c03 sra r5,r5,0x10 |r5 = [Vector3 + Matrix*vector]/28 with upper register cleared (0 or f) - used as Y coordinates for locating tile 001af93c: 0c060fed jal 0x00183fb4 |-->Get_Tile_Data_Pointer r2 = Pointer to Tile Data 001af940: a6020004 sh r2,0x0004(r16) |Store [Vector3 + Matrix*vector]/28 to 0x801b8b6c (Flagged as attack's current Y ) 001af944: 00402021 addu r4,r2,r0 |r4 = Tile data pointer 001af948: 90820005 lbu r2,0x0005(r4) |r2 = [Tile 0x05 byte] (unnamed) 001af94c: 00000000 nop | 001af950: 3042001f andi r2,r2,0x001f |r2 = [Tile 0x05 byte] without flags 0x80 0x40 and 0x20 001af954: 14400004 bne r2,r0,0x001af968 #if r2 = [Tile 0x05 byte] has none of 0x01 0x02 0x04 0x08 nor 0x10 flagged 001af958: 00000000 nop | 001af95c: 90850002 lbu r5,0x0002(r4) |r5 = Tile height 001af960: 0806be5d j 0x001af974 >>jump keeping r5 as tile height 001af964: 00000000 nop | 001af968: 90820005 lbu r2,0x0005(r4) #Else [Tile 0x05 byte] has 0x01 0x02 0x04 0x08 or 0x10 flagged r2 = [Tile 0x05 byte] 001af96c: 00000000 nop | 001af970: 3045001f andi r5,r2,0x001f |r5 = [Tile 0x05 byte] without flags 0x80 0x40 and 0x20 = [Tile 0x05 and 0x1f] 001af974: 90830002 lbu r3,0x0002(r4) |r3 = Tile height 001af978: 8e260004 lw r6,0x0004(r17) |r6 = [Vector2 + Matrix*vector] 001af97c: 00031040 sll r2,r3,0x01 |r2 = Tile height* 2 001af980: 00431021 addu r2,r2,r3 |r2 = Tile height* 3 001af984: 00021080 sll r2,r2,0x02 |r2 = Tile height * 12 001af988: 00021023 subu r2,r0,r2 |r2 = -Tile height * 12 001af98c: 00c2102a slt r2,r6,r2 |r2 = 0x01 if [Vector2 + Matrix*vector] < -(Tile height * 12) 001af990: 1440000a bne r2,r0,0x001af9bc #if [Vector2 + Matrix*vector] > -(Tile height * 12) /Else attack is above ground branch to elevation 0x01 check 001af994: 00651823 subu r3,r3,r5 |r3 = Tile height - [Tile 0x05 and 0x1f] (or -Tile height if [Tile 0x05 and 0x1f] = 0x00) 001af998: 00031040 sll r2,r3,0x01 |r2 = (Tile height - [Tile 0x05 and 0x1f])*2 001af99c: 00431021 addu r2,r2,r3 |r2 = (Tile height - [Tile 0x05 and 0x1f])*3 001af9a0: 00021080 sll r2,r2,0x02 |r2 = (Tile height - [Tile 0x05 and 0x1f])*12 001af9a4: 00021023 subu r2,r0,r2 |r2 = - (Tile height - [Tile 0x05 and 0x1f])*12 001af9a8: 00c2102a slt r2,r6,r2 |r2 = 0x01 if [Vector2 + Matrix*vector] < - (Tile height - [Tile 0x05 and 0x1f])*12 001af9ac: 10400003 beq r2,r0,0x001af9bc #if [Vector2 + Matrix*vector] < -(Tile height -[Tile 0x05 and 0x1f])*12 /Else it's ok (?) go to next elevation 001af9b0: 00000000 nop | 001af9b4: 0806be8d j 0x001afa34 >>jump to [Tile 0x06] section with Attack elevation = 0x00 - obstacle is meet 001af9b8: a6000002 sh r0,0x0002(r16) |Store 0x00 as Attacks current elevation 001af9bc: 86040000 lh r4,0x0000(r16) |r4 = Attack's current X 001af9c0: 86050004 lh r5,0x0004(r16) |r5 = Attack's current Y 001af9c4: 0c060fed jal 0x00183fb4 |-->Get_Tile_Data_Pointer r2 = Pointer to Tile Data 001af9c8: 34060001 ori r6,r0,0x0001 |r6 0x01 (tile elevation) 001af9cc: 00402021 addu r4,r2,r0 |r4 = Tile data pointer 001af9d0: 90820005 lbu r2,0x0005(r4) |r2 = [Tile 0x05 byte] 001af9d4: 00000000 nop | 001af9d8: 3042001f andi r2,r2,0x001f |r2 = [Tile 0x05 and 0x1f] 001af9dc: 10400004 beq r2,r0,0x001af9f0 #if r2 = [Tile 0x05 byte] has one of 0x01 0x02 0x04 0x08 or 0x10 flagged / Else branch with r5 = 0x01 001af9e0: 34050001 ori r5,r0,0x0001 |r5 = 0x01 001af9e4: 90820005 lbu r2,0x0005(r4) |r2 = [Tile 0x05 byte] 001af9e8: 00000000 nop | 001af9ec: 3045001f andi r5,r2,0x001f |r5 = [Tile 0x05 and 0x1f] brigde thickness ? 001af9f0: 90830002 lbu r3,0x0002(r4) |r3 = Tile height 001af9f4: 8e260004 lw r6,0x0004(r17) |r6 = [Vector2 + Matrix*vector] 001af9f8: 00031040 sll r2,r3,0x01 |r2 = Tile height* 2 001af9fc: 00431021 addu r2,r2,r3 |r2 = Tile height* 3 001afa00: 00021080 sll r2,r2,0x02 |r2 = Tile height * 12 001afa04: 00021023 subu r2,r0,r2 |r2 = -Tile height * 12 001afa08: 00c2102a slt r2,r6,r2 |r2 = 0x01 if [Vector2 + Matrix*vector] < -(Tile height * 12) 001afa0c: 14400015 bne r2,r0,0x001afa64 #if [Vector2 + Matrix*vector] > -(Tile height * 12) /Else Trajectory is above tile height - go to unit check 001afa10: 00651823 subu r3,r3,r5 |r3 = Tile height - [Tile 0x05 and 0x1f] (or 0x01) 001afa14: 00031040 sll r2,r3,0x01 |r2 = (Tile height - [Tile 0x05 and 0x1f])*2 001afa18: 00431021 addu r2,r2,r3 |r2 = (Tile height - [Tile 0x05 and 0x1f])*3 001afa1c: 00021080 sll r2,r2,0x02 |r2 = (Tile height - [Tile 0x05 and 0x1f])*12 001afa20: 00021023 subu r2,r0,r2 |r2 = - (Tile height - [Tile 0x05 and 0x1f])*12 001afa24: 00c2102a slt r2,r6,r2 |r2 = 0x01 if [Vector2 + Matrix*vector] < - (Tile height - [Tile 0x05 and 0x1f])*12 001afa28: 1040000e beq r2,r0,0x001afa64 #if [Vector2 + Matrix*vector] < - (Tile height - [Tile 0x05 and 0x1f])*12 /Else Trajectory is under elevation height ? - go to unit check 001afa2c: 34020001 ori r2,r0,0x0001 |r2 = 0x01 001afa30: a6020002 sh r2,0x0002(r16) |Store 0x01 as attack current elevation 001afa34: 90830006 lbu r3,0x0006(r4) >j | r3 = [Tile 0x06] Landing site of jump at 1af9b4 001afa38: 00000000 nop | 001afa3c: 00031902 srl r3,r3,0x04 |r3 = [Tile 0x06] / 16 001afa40: 30630007 andi r3,r3,0x0007 |r3 <> 0x00 if [Tile 0x06] has flag 0x10 0x20 or 0x40 001afa44: 3c01801c lui r1,0x801c |r1 = 0x801c0000 001afa48: ac238b94 sw r3,-0x746c(r1) |Store [Tile 0x06] flags 0x10 0x20 0x40 as 0x01 0x02 and/or 0x04 at 0x801b8b94 001afa4c: 0806bec6 j 0x001afb18 >>jump to END with r2 = 0x01 (Map obstacle) 001afa50: 34020001 ori r2,r0,0x0001 |r2 = 0x01 001afa54: 90430004 lbu r3,0x0004(r2) >j | r3 = ID of hitted unit Backward Landing site of loop if unit is found 001afa58: 34020001 ori r2,r0,0x0001 |r2 = 0x01 001afa5c: 0806bec6 j 0x001afb18 >>jump to end (r2 = 0x01) 001afa60: ae630000 sw r3,0x0000(r19) |Store Hitted unit ID at Target ID pointer ( 0x801b8b64 ) 001afa64: 8e420000 lw r2,0x0000(r18) |r2 = number of valid unit for targeting see List_targeting_data_of_all_valid_units 001afa68: 00000000 nop | 001afa6c: 18400029 blez r2,0x001afb14 #If number of valid units > 0x00 /Else jump to near end (r2 will be set to 0x00) 001afa70: 00003021 addu r6,r0,r0 |r6 = 0x00 001afa74: 8e280004 lw r8,0x0004(r17) |r8 = [Vector2 + Matrix*vector] 001afa78: 00404821 addu r9,r2,r0 |r9 = Nb of valids unit for targeting 001afa7c: 02402821 addu r5,r18,r0 |r5 = 0x1f800000 001afa80: 00a03821 addu r7,r5,r0 |r7 = 0x1f800000 001afa84: 84a3001c lh r3,0x001c(r5) @LOOP through each valid target unit r3 = Unit height data 001afa88: 00000000 nop | 001afa8c: 0103102a slt r2,r8,r3 |r2 = 0x01 if [Vector2 + Matrix*vector] < Unit height data 001afa90: 1040001b beq r2,r0,0x001afb00 #if [Vector2 + Matrix*vector] < Unit height data /Else branch to next unit 001afa94: 00000000 nop | 001afa98: 8ce400c4 lw r4,0x00c4(r7) |r4 = unit's spritesheets height 001afa9c: 00000000 nop | 001afaa0: 00641023 subu r2,r3,r4 |r2 = Unit height data - unit's spritesheets height (it's adding since those are negatives) 001afaa4: 0048102a slt r2,r2,r8 |r2 = 0x01 if (Unit height data - unit's spritesheets height) < [Vector2 + Matrix*vector] 001afaa8: 10400015 beq r2,r0,0x001afb00 #if (Unit height data - unit's spritesheets height) < [Vector2 + Matrix*vector] /Else branch to next unit 001afaac: 00000000 nop |Unit could be hitted ? (check further for X) 001afab0: 10800013 beq r4,r0,0x001afb00 #if unit's spritesheets height <> 0x00 /Else branch to next unit 001afab4: 00000000 nop | 001afab8: 84a3001a lh r3,0x001a(r5) |r3 = Unit X mod 001afabc: 8e240000 lw r4,0x0000(r17) |r4 = [Vector1 + Matrix*vector] 001afac0: 2462fff8 addiu r2,r3,-0x0008 |r2 = Unit X mod - 0x08 (so It's X coord * 28 + 6) 001afac4: 0044102a slt r2,r2,r4 |r2 = 0x01 if [Unit X mod - 0x08] < [Vector1 + Matrix*vector] 001afac8: 1040000d beq r2,r0,0x001afb00 #if [Unit X mod - 0x08] < [Vector1 + Matrix*vector] /Else branch to next unit 001afacc: 24620008 addiu r2,r3,0x0008 |r2 = Unit X mod + 0x08 (so It's X coord * 28 + 22) 001afad0: 0082102a slt r2,r4,r2 |r2 = 0x01 if [Vector1 + Matrix*vector] < [Unit X mod + 0x08] 001afad4: 1040000a beq r2,r0,0x001afb00 #if [Vector1 + Matrix*vector] < [Unit X mod + 0x08] /Else branch to next unit 001afad8: 00000000 nop |Unit could be hitted : check Y 001afadc: 84a3001e lh r3,0x001e(r5) |r3 = Unit Y mod 001afae0: 8e240008 lw r4,0x0008(r17) |r4 = [Vector3 + Matrix*vector] 001afae4: 2462fff8 addiu r2,r3,-0x0008 |r2 = [Unit Y mod - 8] 001afae8: 0044102a slt r2,r2,r4 |r2 = 0x01 if [Unit Y mod - 8] < [Vector3 + Matrix*vector] 001afaec: 10400004 beq r2,r0,0x001afb00 #if [Unit Y mod - 8] < [Vector3 + Matrix*vector] 001afaf0: 24620008 addiu r2,r3,0x0008 |r2 = [Unit Y mod + 8] 001afaf4: 0082102a slt r2,r4,r2 |r2 = 0x01 if [Vector3 + Matrix*vector] < [Unit Y mod + 8] 001afaf8: 1440ffd6 bne r2,r0,0x001afa54 #If [Vector3 + Matrix*vector] > [Unit Y mod + 8] /Else exit loop and branch backward 001afafc: 02461021 addu r2,r18,r6 |r2 = 0x1f800000 + loop counter 001afb00: 24e70004 addiu r7,r7,0x0004 |r7 = r7 + 0x04- Unit ID offset 001afb04: 24c60001 addiu r6,r6,0x0001 |r6 = loop counter +1 001afb08: 00c9102a slt r2,r6,r9 |r2 = 0x01 if counter < nb of valid unit 001afb0c: 1440ffdd bne r2,r0,0x001afa84 #LOOP while there's still valid units 001afb10: 24a50008 addiu r5,r5,0x0008 |r5 = r5 + 0x08 - Unit Coord. Offset 001afb14: 00001021 addu r2,r0,r0 |r2 = 0x00 (nothing hitted) 001afb18: 8fbf0028 lw r31,0x0028(r29) End 001afb1c: 8fb30024 lw r19,0x0024(r29) 001afb20: 8fb20020 lw r18,0x0020(r29) 001afb24: 8fb1001c lw r17,0x001c(r29) 001afb28: 8fb00018 lw r16,0x0018(r29) 001afb2c: 27bd0030 addiu r29,r29,0x0030 001afb30: 03e00008 jr r31 001afb34: 00000000 nop
Notes
Uses vectors manipulation in Get_vector*matrix_from_GTE as X, Y and height coordinates Checks for tile obstacle at attack coordinates and for both elevation. - obstacle is met is r5 0x02 is > -[Tile height]*12 and is < -([Tile height] - [Tile 0x05 and 0x1f])*12 rq for elevation 0x01 [Tile 0x05 and 0x1f] may be the "bridge" thickness, not sure for elevation 0x00 If obstacle is met, exit the routine with r2 = 0x01 and coordinates at r7 0x00 0x02 ad 0x04 updated, store Tile 0x06 data If no map obstacle, loop through all targetable units (data at 0x1f800000) checking for height first, if height matches check X and then Y - ( see Data details) If a unit matches the three coordinates, its ID is stored at 0x801b8b64 (flagged as attack target ID)
Return locations
Battle.bin 001afcc0: Set_Arcing_Trajectory 001b05d8: 001b04dc_-_001b06cc