Difference between revisions of "Chocobo Check"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m (Notes Formattin)
Line 1: Line 1:
ROUTINE : CHOCOBO CHECK
+
ROUTINE : CHOCOBO CHECK
 
+
  PARAMETERS: r4 = Unit data pointer
  PARAMETERS:
+
  RETURNS: r2 = 0x00 if unit not mountable (because of status or not a chocobo)
      r4 = Unit
+
          r2 = 0x01 if unit is a mountable chocobo, already ridden
 
+
          r2 = 0x02 if unit is a mountable chocobo with mount info = 0x00 (unit data 0x182)
  RETURNS:
+
--------------------------------------------------------------------------------------------------------------
      r2   =   0, If proper statuses not found and/or unit is not a chocobo
+
  001743c8: 27bdffe8 addiu r29,r29,0xffe8     |
            1, If unit is a chocobo with proper status and riding check was not passed
+
  001743cc: afb00010 sw r16,0x0010(r29)       |
            2, If unit is a chocobo with proper status and riding check was passed
+
  001743d0: 00808021 addu r16,r4,r0           |{{f/std|<nowiki>r16 = unit data pointer</nowiki>}}
 
+
  001743d4: afbf0014 sw r31,0x0014(r29)       |
SECTION 1 : SET UP ROUTINE AND CALL OTHER ROUTINE
+
  001743d8: 92020003 lbu r2,0x0003(r16)       |{{f/load|<nowiki>r2 = unit JOB ID</nowiki>}}
 
+
  001743dc: 00000000 nop                     |
  001743c8: 27bdffe8 addiu r29,r29,0xffe8
+
  001743e0: 2442ffa2 addiu r2,r2,-0x005e      |{{f/std|<nowiki>r2 = r2 - 0x5E (Chocobo Job ID = 0x5e)</nowiki>}}
  001743cc: afb00010 sw r16,0x0010(r29)
+
  001743e4: 2c420003 sltiu r2,r2,0x0003       |{{f/std|<nowiki>r2 = 0x01 if Unit job ID is 0x5e, 0x5f or 0x60  (Note: r2 is unsigned so can only happen for jobs 0x5E - 0x60)</nowiki>}}
  001743d0: 00808021 addu r16,r4,r0
+
  001743e8: 10400005 beq r2,r0,0x00174400    {{f/Cond|<nowiki>If Unit has the job chocobo</nowiki>}} /Else branch then jump to {{f/loc|<nowiki>End</nowiki>}} with r2 = 0x00
  001743d4: afbf0014 sw r31,0x0014(r29)
+
  001743ec: 02002021 addu r4,r16,r0               |{{f/std|<nowiki>r4 = unit data pointer</nowiki>}}
  001743d8: 92020003 lbu r2,0x0003(r16)         #  r2 = [Current job ID of unit]
+
  001743f0: 0c01786c jal 0x0005e1b0               |{{f/jal|Status_Checks_(r5_%3D_set_to_check)|<nowiki>Status_Checks_(r5_%3D_set_to_check)</nowiki>}} Check if unit has a unmountable status - return r2 = 0x01 if so
  001743dc: 00000000 nop
+
  001743f4: 3405000a ori r5,r0,0x000a             |{{f/std|<nowiki>r5 = 0x0A (set to check in the routine above)</nowiki>}}
  001743e0: 2442ffa2 addiu r2,r2,0xffa2        #  r2 = r2 - 0x5E (94)
+
  001743f8: 10400003 beq r2,r0,0x00174408          {{f/Cond|<nowiki>If unit have one of the checked status / Else branch to mount info check</nowiki>}}
  001743e4: 2c420003 sltiu r2,r2,0x0003         #  IF (Unit is not a chocobo)  Note: Condition is (UNSIGNED r2 < 3); can only happen for jobs 0x5E - 0x60
+
  001743fc: 00000000 nop                               |{{f/std|<nowiki> </nowiki>}}
  001743e8: 10400005 beq r2,r0,0x 00174400        #      RETURN 0
+
  00174400: 0805d107 j 0x0017441c            {{f/Cond|<nowiki>Else </nowiki>}}   |{{f/jump|<nowiki> jump to </nowiki>{{f/loc|<nowiki>End</nowiki>}}<nowiki> (r2 = 0x00)</nowiki>}} {{f/std|<nowiki> Not a chocobo or chocobo not mountable</nowiki>}}
  001743ec: 02002021 addu r4,r16,r0        
+
  00174404: 00001021 addu r2,r0,r0                    
  001743f0: 0c01786c jal 0x0005e1b0           #  Routine: Check status flags (r4 = current unit, r5 = 10)
+
  00174408: 92030182 lbu r3,0x0182(r16)           {{f/Cond|<nowiki>Else  </nowiki>}} {{f/load|<nowiki>r3 = Unit mount info</nowiki>}} {{f/std|<nowiki>(unit has no unmountable status)</nowiki>}}
  001743f4: 3405000a ori r5,r0,0x000a          
+
  0017440c: 00000000 nop                           |
  001743f8: 10400003 beq r2,r0,0x 00174408        #  IF (Routine result == 0)
+
  00174410: 14600002 bne r3,r0,0x0017441c          {{f/Cond|<nowiki>if unit is riding or being ridden</nowiki>}} /Else  (not ridden) branch to {{f/loc|<nowiki>End</nowiki>}} With r2 = 0x02
  001743fc: 00000000 nop                     #      JUMP to [SECTION 2]
+
  00174414: 34020002 ori r2,r0,0x0002             |{{f/std|<nowiki>r2 = 0x02</nowiki>}}
  00174400: 0805d107 j 0x 0017441c              #   RETURN 0
+
  00174418: 34020001 ori r2,r0,0x0001                 |{{f/std|<nowiki>r2 = 0x01</nowiki>}}
  00174404: 00001021 addu r2,r0,r0
+
  0017441c: 8fbf0014 lw r31,0x0014(r29)       |End
 
+
  00174420: 8fb00010 lw r16,0x0010(r29)      
SECTION 2 : CHECK RIDDEN UNIT
+
  00174424: 27bd0018 addiu r29,r29,0x0018    
 
+
  00174428: 03e00008 jr r31                  
  00174408: 92030182 lbu r3,0x0182(r16)
+
  0017442c: 00000000 nop                    
  0017440c: 00000000 nop
 
  00174410: 14600002 bne r3,r0,0x 0017441c        #  IF (Something to do with riding?)
 
  00174414: 34020002 ori r2,r0,0x0002           #      RETURN 2
 
  00174418: 34020001 ori r2,r0,0x0001           #    RETURN 1
 
 
 
SECTION 3 : RETURN r2
 
 
 
  0017441c: 8fbf0014 lw r31,0x0014(r29)
 
  00174420: 8fb00010 lw r16,0x0010(r29)
 
  00174424: 27bd0018 addiu r29,r29,0x0018
 
  00174428: 03e00008 jr r31
 
  0017442c: 00000000 nop
 
 
 
  
 
== Return Locations ==
 
== Return Locations ==

Revision as of 21:14, 3 December 2021

ROUTINE : CHOCOBO CHECK
 PARAMETERS: r4 = Unit data pointer
 RETURNS:  r2 = 0x00 if unit not mountable (because of status or not a chocobo)
         r2 = 0x01 if unit is a mountable chocobo, already ridden
         r2 = 0x02 if unit is a mountable chocobo with mount info = 0x00 (unit data 0x182)
-------------------------------------------------------------------------------------------------------------- 
001743c8: 27bdffe8 addiu r29,r29,0xffe8     |
001743cc: afb00010 sw r16,0x0010(r29)       |
001743d0: 00808021 addu r16,r4,r0           |r16 = unit data pointer
001743d4: afbf0014 sw r31,0x0014(r29)       |
001743d8: 92020003 lbu r2,0x0003(r16)       |r2 = unit JOB ID
001743dc: 00000000 nop                      |
001743e0: 2442ffa2 addiu r2,r2,-0x005e      |r2 = r2 - 0x5E  (Chocobo Job ID = 0x5e)
001743e4: 2c420003 sltiu r2,r2,0x0003       |r2 = 0x01 if Unit job ID is 0x5e, 0x5f or 0x60  (Note: r2 is unsigned so can only happen for jobs 0x5E - 0x60)
001743e8: 10400005 beq r2,r0,0x00174400     #If Unit has the job chocobo /Else branch then jump to End with r2 = 0x00
001743ec: 02002021 addu r4,r16,r0                |r4 = unit data pointer
001743f0: 0c01786c jal 0x0005e1b0                |-->Status_Checks_(r5_%3D_set_to_check) Check if unit has a unmountable status - return r2 = 0x01 if so
001743f4: 3405000a ori r5,r0,0x000a              |r5 = 0x0A (set to check in the routine above)
001743f8: 10400003 beq r2,r0,0x00174408          #If unit have one of the checked status / Else branch to mount info check
001743fc: 00000000 nop                               | 
00174400: 0805d107 j 0x0017441c             #Else    |>> jump to End (r2 = 0x00)  Not a chocobo or chocobo not mountable
00174404: 00001021 addu r2,r0,r0                     
00174408: 92030182 lbu r3,0x0182(r16)            #Else   r3 = Unit mount info (unit has no unmountable status)
0017440c: 00000000 nop                           |
00174410: 14600002 bne r3,r0,0x0017441c          #if unit is riding or being ridden /Else  (not ridden) branch to End With r2 = 0x02
00174414: 34020002 ori r2,r0,0x0002              |r2 = 0x02
00174418: 34020001 ori r2,r0,0x0001                  |r2 = 0x01
0017441c: 8fbf0014 lw r31,0x0014(r29)       |End
00174420: 8fb00010 lw r16,0x0010(r29)       
00174424: 27bd0018 addiu r29,r29,0x0018     
00174428: 03e00008 jr r31                   
0017442c: 00000000 nop                      

Return Locations

00174844: Store movement stuff into scratch pad
00174994: Store movement stuff into scratch pad
0017de2c: Check if another unit is on the same Tile