Determine Status Bubble Parameters

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: DETERMINE STATUS BUBBLE PARAMETERS
#       Parameters:
#           r4 = [Unit misc data pointer]

0007eb8c: 3c028004 lui r2,0x8004
0007eb90: 8c425980 lw r2,0x5980(r2)             #   Unit acting status? frame data?
0007eb94: 27bdffd0 addiu r29,r29,-0x0030
0007eb98: afb00018 sw r16,0x0018(r29)
0007eb9c: 00808021 addu r16,r4,r0
0007eba0: afb1001c sw r17,0x001c(r29)
0007eba4: 00008821 addu r17,r0,r0               #   index = 0
0007eba8: afbf0028 sw r31,0x0028(r29)
0007ebac: afb30024 sw r19,0x0024(r29)
0007ebb0: 184000bb blez r2,0x0007eea0           #   if ([Unit acting status] <= 0 (not targeting or acting?)), return (exit the routine)	// invalid status I imagine?
0007ebb4: afb20020 sw r18,0x0020(r29)
0007ebb8: 34120014 ori r18,r0,0x0014            #   20
0007ebbc: 3c130400 lui r19,0x0400               #   0x04000000
                                                #   do {
0007ebc0: 920402dd lbu r4,0x02dd(r16)           #       [Status bubble to show]
0007ebc4: 34020009 ori r2,r0,0x0009             
0007ebc8: 14820006 bne r4,r2,0x0007ebe4         #       if ([Status bubble to show] == 9) {
0007ebcc: 00000000 nop
0007ebd0: 960202e0 lhu r2,0x02e0(r16)           #           Timer?
0007ebd4: 00000000 nop
0007ebd8: 30420008 andi r2,r2,0x0008            #           Timer? & 0x08
0007ebdc: 0801fafd j 0x0007ebf4
0007ebe0: 000210c2 srl r2,r2,0x03               #           [Value to save] = (Timer? & 0x08) >> 3		//loops between the 1st and 2nd frames every 8 on the counter (charge...?)
                                                #       } else {
0007ebe4: 960202e0 lhu r2,0x02e0(r16)           #           Timer?
0007ebe8: 00000000 nop
0007ebec: 30420010 andi r2,r2,0x0010            #           Timer? & 0x10
0007ebf0: 00021102 srl r2,r2,0x04               #           [Value to save] = (Timer? & 0x10) >> 4		//loops between the 1st and 2nd frames every 16 on the counter (everything else)
                                                #       }
0007ebf4: a60202e2 sh r2,0x02e2(r16)            #       MiscUnitData.0x2e2 = [Value to save]			//stores current status bubble frame
0007ebf8: 960202e0 lhu r2,0x02e0(r16)           #       Timer?
0007ebfc: 00000000 nop
0007ec00: 3042000f andi r2,r2,0x000f            #       Timer? & 0x0f
0007ec04: 1440009e bne r2,r0,0x0007ee80
0007ec08: 3c021fff lui r2,0x1fff
                                                #       if ((Timer? & 0x0f) == 0) {				//on every 16th frame (otherwise, end, and increment timer by 1)
0007ec0c: 8e050140 lw r5,0x0140(r16)            #           Status Flags 1 through 4
0007ec10: 3442c2c4 ori r2,r2,0xc2c4                    
0007ec14: 00a21024 and r2,r5,r2                 #           Check for statuses: 				//check for all statuses with a bubble
                                                #               (Byte 4, mask 0x1f): Reraise, Darkness, Death Sentence, Silence, Charm
                                                #               (Byte 3, mask 0xff): Oil, Poison, Protect, Shell, Don't Act, Don't Move, Blood Suck, Innocent
                                                #               (Byte 2, mask 0xc2): Faith, Berserk, Charging
                                                #               (Byte 1, mask 0xc4): Confusion, Sleep, Dead (KO)
0007ec18: 14400009 bne r2,r0,0x0007ec40
0007ec1c: 30a80004 andi r8,r5,0x0004            #           (Check for Dead (KO) status)
                                                #           if (None of the checked statuses were present) {
0007ec20: 92030004 lbu r3,0x0004(r16)           #               Unit misc ID
0007ec24: 3c028009 lui r2,0x8009
0007ec28: 8c426118 lw r2,0x6118(r2)             #               Casting unit ID?
0007ec2c: 00000000 nop
0007ec30: 10620004 beq r3,r2,0x0007ec44                                                         
0007ec34: 00b33824 and r7,r5,r19                #               (Check for Death Sentence status)
                                                #               if ([Unit misc ID] != [Casting unit ID?]) {
0007ec38: 0801fba8 j 0x0007eea0
0007ec3c: a20002dc sb r0,0x02dc(r16)            #                   [Activation byte for Status Bubble] = 0
                                                #                   Return (exit the routine)
                                                #               }
                                                #           }
0007ec40: 00b33824 and r7,r5,r19                #           (Check for Death Sentence status)
0007ec44: 340a0015 ori r10,r0,0x0015            #           21
0007ec48: 3c068009 lui r6,0x8009
0007ec4c: 8cc66118 lw r6,0x6118(r6)             #           Casting unit ID?
0007ec50: 3c098009 lui r9,0x8009
0007ec54: 25293cb4 addiu r9,r9,0x3cb4           #           [Base pointer for status to check?] (0x80093cb4)
0007ec58: 00041080 sll r2,r4,0x02               #           [Status bubble to show] * 4
0007ec5c: 00491821 addu r3,r2,r9                #           [Status to check pointer?] = 0x80093cb4 + ([Status bubble to show] * 4)
                                                #           [Temp status bubble to show] = [Status bubble to show]
                                                
                                                #           do {
0007ec60: 14800005 bne r4,r0,0x0007ec78         #               if ([Temp status bubble to show] == 0) {				// branch if status bubble is not 0 (dead state?)
0007ec64: 00000000 nop
0007ec68: 1500001e bne r8,r0,0x0007ece4         #                   if (Unit has Dead status), break (exit the loop)			// branch if unit dead
0007ec6c: 00000000 nop
0007ec70: 0801fb23 j 0x0007ec8c
0007ec74: 24840001 addiu r4,r4,0x0001           #                       [Temp status bubble to show] = [Status bubble to show] + 1                // if unit's status bubble is 0, but they aren't dead, ++ 1
                                                #               } else {
0007ec78: 14920003 bne r4,r18,0x0007ec88        #                   if ([Temp status bubble to show] == 20) {				// branch if status bubble is not 20 (doom?)
0007ec7c: 00000000 nop
0007ec80: 14e00018 bne r7,r0,0x0007ece4                                 if (Unit has Death Sentence status), break (exit the loop)
0007ec84: 00000000 nop
                                                #                   }
0007ec88: 24840001 addiu r4,r4,0x0001           #                   [Temp status bubble to show] = [Status bubble to show] + 1			// if unit's status bubble is 0x20, but they aren't doomed, ++ 1
                                                #               }
0007ec8c: 28820016 slti r2,r4,0x0016
0007ec90: 14400003 bne r2,r0,0x0007eca0												// branch if unit's status bubble is < 0x16
0007ec94: 24630004 addiu r3,r3,0x0004           #               [Status to check pointer?] = [Status to check pointer?] + 4
                                                #               if ([Temp status bubble to show] >= 22]) {
0007ec98: 01201821 addu r3,r9,r0                #                   [Status to check pointer?] = [Base pointer for status to check?] (0x80093cb4)	//if unit's status bubble is greater than 0x16 (except when it's 0x20?), set it to 0
0007ec9c: 00002021 addu r4,r0,r0                #                   [Temp status bubble to show] = 0
                                                #               }
0007eca0: 920202dd lbu r2,0x02dd(r16)           #               [Status bubble to show]
0007eca4: 00000000 nop
0007eca8: 1082000e beq r4,r2,0x0007ece4         #               if ([Temp status bubble to show] == [Status bubble to show]), break (exit the loop)	// if status bubble was changed, exit loop
0007ecac: 00000000 nop
0007ecb0: 108a0008 beq r4,r10,0x0007ecd4        #               if ([Temp status bubble to show] != 21 (0x15, AT)) {					// AT is special I guess.
0007ecb4: 00000000 nop
0007ecb8: 8c620000 lw r2,0x0000(r3)             #                   [Status to check] = *([Status to check pointer])
0007ecbc: 00000000 nop
0007ecc0: 00a21024 and r2,r5,r2                 #                   Check if [Status to check] is present on unit
0007ecc4: 14400007 bne r2,r0,0x0007ece4         #                   If ([Status to check] is present on unit), break (exit the loop)
0007ecc8: 00000000 nop
0007eccc: 0801fb18 j 0x0007ec60                 #                   continue (skip this rest of this loop iteration), skipping condition check
0007ecd0: 00000000 nop
                                                #               }
0007ecd4: 92020004 lbu r2,0x0004(r16)           #               [Unit misc ID]
0007ecd8: 00000000 nop
0007ecdc: 1446ffe0 bne r2,r6,0x0007ec60         								// loop while unit misc ID isn't the casting unit?
0007ece0: 00000000 nop
                                                #           } while ([Unit misc ID] != [Casting unit ID?])
0007ece4: 92020006 lbu r2,0x0006(r16)           #           Spritesheet ID
0007ece8: a20402dd sb r4,0x02dd(r16)            #           [Status bubble to show] = [Temp status bubble to show]					// update new status bubble
0007ecec: 00021080 sll r2,r2,0x02               #           [Spritesheet ID] * 4
0007ecf0: 3c018009 lui r1,0x8009
0007ecf4: 00220821 addu r1,r1,r2
0007ecf8: 90234748 lbu r3,0x4748(r1)            #           SHP ID for this Spritesheet
0007ecfc: 00000000 nop
0007ed00: 2c620008 sltiu r2,r3,0x0008           
0007ed04: 1040004f beq r2,r0,0x0007ee44         #           if ([SHP ID] < 8) {
0007ed08: 00031080 sll r2,r3,0x02               #               [SHP ID] * 4
0007ed0c: 3c018006 lui r1,0x8006
0007ed10: 00220821 addu r1,r1,r2
0007ed14: 8c227810 lw r2,0x7810(r1)             #               Load code pointer for this [SHP ID]
0007ed18: 00000000 nop
0007ed1c: 00400008 jr r2                        #               (Jump to appropriate code - see table and switch statement below)
0007ed20: 00000000 nop

#   [SHP ID]    [RAM Address]   [Code pointer]
#   0           80067810        8007ed6c		//type 1
#   1           80067814        8007ed6c		//type 2
#   2           80067818        8007ee44		//Cyoko
#   3           8006781c        8007ee44		//Other
#   4           80067820        8007ed34		//Monster
#   5           80067824        8007ee44		//ruka
#   6           80067828        8007ed24		//arute
#   7           8006782c        8007ed2c		//kanzen

                                                #               [Reset X Value] = true
                                                #               switch ([SHP ID]) {
#   ([SHP ID] == 6)                             #                   case 6:				//Arute
0007ed24: 0801fb9e j 0x0007ee78
0007ed28: 2402ffba addiu r2,r0,-0x0046          #                       [Y value] = -0x46
                                                #                       break
#   ([SHP ID] == 7)                             #                   case 7:				//Kanzen
0007ed2c: 0801fb9e j 0x0007ee78
0007ed30: 2402ff88 addiu r2,r0,-0x0078          #                       [Y value] = -0x78
                                                #                       break
#   ([SHP ID] == 4)                             #                   case 4:				// Monster
0007ed34: 960201dc lhu r2,0x01dc(r16)           #                       [Current animation ID]?
0007ed38: 00000000 nop
0007ed3c: 00021842 srl r3,r2,0x01               #                       [Current animation ID] / 2
0007ed40: 3402001a ori r2,r0,0x001a             
0007ed44: 10620004 beq r3,r2,0x0007ed58         
0007ed48: 2402fffb addiu r2,r0,-0x0005          
                                                #                       if (([Current animation ID] / 2 != 26) 
0007ed4c: 34020034 ori r2,r0,0x0034
0007ed50: 14620004 bne r3,r2,0x0007ed64         #                           && ([Current animation ID] / 2) != 52) {
0007ed54: 2402fffb addiu r2,r0,-0x0005
                                                
0007ed58: a20202de sb r2,0x02de(r16)            #                           [Status Bubble X Location] = -5
0007ed5c: 0801fb9f j 0x0007ee7c                 #                           [Reset X Value] = false
0007ed60: 2402ffe7 addiu r2,r0,-0x0019                                      [Y value] = -0x19
                                                #                       }
0007ed64: 0801fb9e j 0x0007ee78
0007ed68: 2402ffe7 addiu r2,r0,-0x0019          #                       [Y value] = -0x19
                                                #                       break

#   ([SHP ID] == 0) or ([SHP ID] == 1)          #                   case 0: case 1:				//type 1 and type 2
0007ed6c: 9204007c lbu r4,0x007c(r16)           #                       (Parameter 1: X Coordinate)
0007ed70: 9205007d lbu r5,0x007d(r16)           #                       (Parameter 2: Y Coordinate)
0007ed74: 9206007e lbu r6,0x007e(r16)           #                       (Parameter 3: Higher Elevation bit)
0007ed78: 0c060fed jal 0x00183fb4               #                       ROUTINE: Get Tile Data Pointer (X Coordinate, Y Coordinate, Higher Elevation bit)
0007ed7c: 00000000 nop
0007ed80: 90420003 lbu r2,0x0003(r2)            #                       Height (halves) and depth
0007ed84: 00000000 nop
0007ed88: 304200e0 andi r2,r2,0x00e0            #                       Check for Depth
0007ed8c: 10400017 beq r2,r0,0x0007edec         #                       if (Depth > 0) {
0007ed90: 00000000 nop
0007ed94: 960201dc lhu r2,0x01dc(r16)           #                           [Current animation ID]
0007ed98: 00000000 nop
0007ed9c: 00021842 srl r3,r2,0x01               #                           [Current animation ID] / 2
0007eda0: 34020024 ori r2,r0,0x0024
0007eda4: 1062000d beq r3,r2,0x0007eddc         											//if animation is "Sleeping" branch (y = -0x1e)
0007eda8: 28620025 slti r2,r3,0x0025
                                                #                           if (([Current animation ID] / 2) != 36) {
0007edac: 10400005 beq r2,r0,0x0007edc4												//if animation is greater than "Confuse" branch (check for more animations)
0007edb0: 3402001a ori r2,r0,0x001a
                                                #                               if (([Current animation ID] / 2) <= 37) {
0007edb4: 10620006 beq r3,r2,0x0007edd0												//if animation is "dead" branch (x = -5, y = -0x23)
0007edb8: 2402fffb addiu r2,r0,-0x0005          #                                     
                                                #                                   if (([Current animation ID] / 2) != 31) {           

0007edbc: 0801fb9e j 0x0007ee78													//if animation does not fulfill any of those criteria, y = -0x28
0007edc0: 2402ffd8 addiu r2,r0,-0x0028                                                  [Y value] = -0x28
                                                #                                   }
                                                #                               } 
0007edc4: 34020034 ori r2,r0,0x0034
0007edc8: 14620006 bne r3,r2,0x0007ede4												//if animation is not "being killed" branch (r2 = -0x28)
0007edcc: 2402fffb addiu r2,r0,-0x0005                                         
                                                #                               else if (([Current animation ID] / 2) == 52) {
0007edd0: a20202de sb r2,0x02de(r16)            #                                   [Status Bubble X Location] = -5			//if animation is currently "being killed" X location = -5, y value = -0x23
0007edd4: 0801fb9f j 0x0007ee7c                 #                                   [Reset X Value] = false      
0007edd8: 2402ffdd addiu r2,r0,-0x0023          #                                   [Y value] = -0x23
                                                #                               }
                                                #                           } else {
0007eddc: 0801fb9e j 0x0007ee78                 
0007ede0: 2402ffe2 addiu r2,r0,-0x001e          #                               [Y value] = -0x1e
                                                #                           }
0007ede4: 0801fb9e j 0x0007ee78
0007ede8: 2402ffd8 addiu r2,r0,-0x0028          #                           [Y value] = -0x28
                                                #                       } else {
0007edec: 960201dc lhu r2,0x01dc(r16)           #                           [Current animation ID]				//if depth < 0, do the same thing again but with slightly altered y values. 
0007edf0: 00000000 nop
0007edf4: 00021842 srl r3,r2,0x01               #                           [Current animation ID] / 2
0007edf8: 34020024 ori r2,r0,0x0024
0007edfc: 1062000d beq r3,r2,0x0007ee34
0007ee00: 28620025 slti r2,r3,0x0025
                                                #                           if (([Current animation ID] / 2) != 36) {
0007ee04: 10400005 beq r2,r0,0x0007ee1c
0007ee08: 3402001a ori r2,r0,0x001a
                                                #                               if (([Current animation ID] / 2) >= 37) {
0007ee0c: 10620006 beq r3,r2,0x0007ee28
0007ee10: 2402fffb addiu r2,r0,-0x0005
                                                #                                   if (([Current animation ID] / 2) != 31) {
0007ee14: 0801fb9e j 0x0007ee78
0007ee18: 2402ffd8 addiu r2,r0,-0x0028          #                                       [Y value] = -0x28
                                                #                                   }
                                                #                               }
0007ee1c: 34020034 ori r2,r0,0x0034
0007ee20: 14620006 bne r3,r2,0x0007ee3c
0007ee24: 2402fffb addiu r2,r0,-0x0005
                                                #                               else if (([Current animation ID] / 2) == 52) {
0007ee28: a20202de sb r2,0x02de(r16)            #                                   [Status Bubble X Location] = -5    
0007ee2c: 0801fb9f j 0x0007ee7c                 #                                   [Reset X Value] = false
0007ee30: 2402ffe7 addiu r2,r0,-0x0019          #                                   [Y value] = -0x19
                                                #                               }
                                                #                           } else {
0007ee34: 0801fb9e j 0x0007ee78
0007ee38: 2402ffe2 addiu r2,r0,-0x001e          #                               [Y value] = -0x1e
                                                #                           }
0007ee3c: 0801fb9e j 0x0007ee78
0007ee40: 2402ffd8 addiu r2,r0,-0x0028          #                           [Y value] = -0x28
                                                #                   }
                                                #                   break
                                                #               }
                                                #           } else {
#   (Any other [SHP ID])
0007ee44: 960201dc lhu r2,0x01dc(r16)           #               [Current animation ID]
0007ee48: 00000000 nop
0007ee4c: 00021842 srl r3,r2,0x01               #               [Current animation ID] / 2
0007ee50: 3402001a ori r2,r0,0x001a
0007ee54: 10620004 beq r3,r2,0x0007ee68
0007ee58: 2402fffb addiu r2,r0,-0x0005
                                                #               if ((([Current animation ID] / 2) == 31) 
0007ee5c: 34020034 ori r2,r0,0x0034
0007ee60: 14620004 bne r3,r2,0x0007ee74
0007ee64: 2402fffb addiu r2,r0,-0x0005
                                                #                   or (([Current animation ID] / 2) == 52)) {
0007ee68: a20202de sb r2,0x02de(r16)            #                   [Status Bubble X Location] = -5
0007ee6c: 0801fb9f j 0x0007ee7c                 #                   [Reset X Value] = false
0007ee70: 2402ffe2 addiu r2,r0,-0x001e          #                   [Y value] = -0x1e
                                                #               } else {
0007ee74: 2402ffce addiu r2,r0,-0x0032          #                   [Y value] = -0x32
                                                #               }
                                                #           }
                                                #           if ([Reset X Value]) {
0007ee78: a20002de sb r0,0x02de(r16)            #               [Status Bubble X Location] = 0
                                                #           }
0007ee7c: a20202df sb r2,0x02df(r16)            #           [Status Bubble Y Location] = [Y value]
                                                #       }
0007ee80: 26310001 addiu r17,r17,0x0001         #       index = index + 1
0007ee84: 960202e0 lhu r2,0x02e0(r16)           #       Timer
0007ee88: 3c038004 lui r3,0x8004
0007ee8c: 8c635980 lw r3,0x5980(r3)             #       Unit Acting Status?
0007ee90: 24420001 addiu r2,r2,0x0001           #       Timer + 1
0007ee94: 0223182a slt r3,r17,r3                
0007ee98: 1460ff49 bne r3,r0,0x0007ebc0            
0007ee9c: a60202e0 sh r2,0x02e0(r16)            #       Timer = Timer + 1
                                                #   } while (index < Unit Acting Status?)
0007eea0: 8fbf0028 lw r31,0x0028(r29)
0007eea4: 8fb30024 lw r19,0x0024(r29)
0007eea8: 8fb20020 lw r18,0x0020(r29)
0007eeac: 8fb1001c lw r17,0x001c(r29)
0007eeb0: 8fb00018 lw r16,0x0018(r29)
0007eeb4: 27bd0030 addiu r29,r29,0x0030
0007eeb8: 03e00008 jr r31
0007eebc: 00000000 nop