Process Single Unit Movement

From Final Fantasy Hacktics Wiki
Revision as of 18:53, 7 January 2017 by Glain (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#   ROUTINE: PROCESS SINGLE UNIT MOVEMENT
#       Parameters:
#           r4 = (unitMisc) Unit misc data pointer

8006d818: 27bdffe8 addiu r29,r29,-0x0018
8006d81c: afb00010 sw r16,0x0010(r29)
8006d820: 3c058009 lui r5,0x8009
8006d824: 24a56220 addiu r5,r5,0x6220           #   0x80096220
8006d828: 3c068009 lui r6,0x8009
8006d82c: 24c66224 addiu r6,r6,0x6224           #   0x80096224
8006d830: afbf0014 sw r31,0x0014(r29)
8006d834: 0c01aeb6 jal 0x8006bad8               #   ? 0x6bad8 (unitMisc, 0x80096220, 0x80096224);
8006d838: 00808021 addu r16,r4,r0               #   unitMisc
8006d83c: 9202011c lbu r2,0x011c(r16)           #   unitMisc.CurrentMovement
8006d840: 3c018009 lui r1,0x8009
8006d844: a022621c sb r2,0x621c(r1)             #   *0x8009621c = unitMisc.CurrentMovement
8006d848: 9202007f lbu r2,0x007f(r16)           #   unitMisc.0x7f
8006d84c: 00000000 nop
8006d850: 2443ffff addiu r3,r2,-0x0001          #   value = unitMisc.0x7f - 1
8006d854: 2c62003c sltiu r2,r3,0x003c
8006d858: 10400044 beq r2,r0,0x8006d96c         #   if (value < 60) {
8006d85c: 00031080 sll r2,r3,0x02               #       value * 4
8006d860: 3c018006 lui r1,0x8006
8006d864: 00220821 addu r1,r1,r2
8006d868: 8c2273d8 lw r2,0x73d8(r1)             #       *(0x800673d8 + (value * 4))
8006d86c: 00000000 nop
8006d870: 00400008 jr r2                        #       Jump to appropriate code - see table and switch statement below)           
8006d874: 00000000 nop

#   [value]    [RAM Address]   [Code pointer]

#   0           800673d8        8006d924
#   1           800673dc        8006d8f4
#   2           800673e0        8006d924
#   3           800673e4        8006d8f4
#   4           800673e8        8006d924
#   5           800673ec        8006d8f4
#   6           800673f0        8006d924
#   7           800673f4        8006d8f4
#   8           800673f8        8006d924
#   9           800673fc        8006d8f4
#   10          80067400        8006d924
#   11          80067404        8006d8f4
#   12          80067408        8006d924
#   13          8006740c        8006d8f4
#   14          80067410        8006d924
#   15          80067414        8006d8f4
#   16          80067418        8006d878
#   17          8006741c        8006d8cc
#   18          80067420        8006d8d4
#   19          80067424        8006d8bc
#   20          80067428        8006d878
#   21          8006742c        8006d8cc
#   22          80067430        8006d8d4
#   23          80067434        8006d8bc
#   24          80067438        8006d878
#   25          8006743c        8006d8cc
#   26          80067440        8006d8d4
#   27          80067444        8006d8bc
#   28          80067448        8006d878
#   29          8006744c        8006d8cc
#   30          80067450        8006d8d4
#   31          80067454        8006d8bc
#   32          80067458        8006d96c
#   33          8006745c        8006d944
#   34          80067460        8006d914
#   35          80067464        8006d944
#   36          80067468        8006d914
#   37          8006746c        8006d944
#   38          80067470        8006d914
#   39          80067474        8006d944
#   40          80067478        8006d914
#   41          8006747c        8006d96c
#   42          80067480        8006d934
#   43          80067484        8006d904
#   44          80067488        8006d8e4
#   45          8006748c        8006d96c
#   46          80067490        8006d934
#   47          80067494        8006d904
#   48          80067498        8006d8e4
#   49          8006749c        8006d96c
#   50          800674a0        8006d934
#   51          800674a4        8006d904
#   52          800674a8        8006d8e4
#   53          800674ac        8006d96c
#   54          800674b0        8006d934
#   55          800674b4        8006d904
#   56          800674b8        8006d8e4
#   57          800674bc        8006d96c
#   58          800674c0        8006d954
#   59          800674c4        8006d964

                                                #       // Note: There is no case for the values 32, 41, 45, 49, 53, and 57; they skip the switch entirely.
                                                #       switch (value) {
                                                #           case 16: case 20: case 24: case 28:
8006d878: 960201e2 lhu r2,0x01e2(r16)           #               unitMisc.0x1e2
8006d87c: 00000000 nop
8006d880: 1440003a bne r2,r0,0x8006d96c         #               if (unitMisc.0x1e2 != 0) break;
8006d884: 02003021 addu r6,r16,r0               #               unitMisc
8006d888: 3404001f ori r4,r0,0x001f             #               31
8006d88c: 9202007f lbu r2,0x007f(r16)           #               unitMisc.0x7f
8006d890: 86050070 lh r5,0x0070(r16)            #               unitMisc.FacingDirection?
8006d894: 24420001 addiu r2,r2,0x0001           #               unitMisc.0x7f + 1
8006d898: 0c02065e jal 0x80081978               #               ? 0x81978 (31, unitMisc.FacingDirection?, unitMisc);
8006d89c: a202007f sb r2,0x007f(r16)            #               unitMisc.0x7f = unitMisc.0x7f + 1
8006d8a0: 02002021 addu r4,r16,r0               #               unitMisc
8006d8a4: 0c01ae58 jal 0x8006b960               #               ? 0x6b690 (unitMisc, 39);
8006d8a8: 34050027 ori r5,r0,0x0027             #               39
8006d8ac: 0c01a495 jal 0x80069254               #               ? 0x69254 (unitMisc);
8006d8b0: 02002021 addu r4,r16,r0               #               unitMisc
8006d8b4: 0801b65b j 0x8006d96c                 #               break;
8006d8b8: 00000000 nop                          #           case 19: case 23: case 27: case 31:
8006d8bc: 0c01b0f6 jal 0x8006c3d8               #               ? 0x6c3d8 (unitMisc);
8006d8c0: 02002021 addu r4,r16,r0               #               unitMisc
8006d8c4: 0801b65b j 0x8006d96c                 #               break;
8006d8c8: 00000000 nop                          #           case 17: case 21: case 25: case 29:
8006d8cc: 0c01b1e4 jal 0x8006c790               #               ? 0x6c790 (unitMisc);
8006d8d0: 02002021 addu r4,r16,r0               #               unitMisc
                                                #           case 18: case 22: case 26: case 30:
8006d8d4: 0c01b13e jal 0x8006c4f8               #               ? 0x6caf8 (unitMisc);
8006d8d8: 02002021 addu r4,r16,r0               #               unitMisc
8006d8dc: 0801b65b j 0x8006d96c                 #               break;
8006d8e0: 00000000 nop                          #           case 44: case 48: case 52: case 56:
8006d8e4: 0c01b4a2 jal 0x8006d288               #               ? 0x6d288 (unitMisc);
8006d8e8: 02002021 addu r4,r16,r0               #               unitMisc
8006d8ec: 0801b65b j 0x8006d96c                 #               break;
8006d8f0: 00000000 nop                          #           case 1: case 3: case 5: case 7: case 9: case 11: case 13: case 15:
8006d8f4: 0c01b2b4 jal 0x8006cad0               #               ? 0x6cad0 (unitMisc);
8006d8f8: 02002021 addu r4,r16,r0               #               unitMisc
8006d8fc: 0801b65b j 0x8006d96c                 #               break;
8006d900: 00000000 nop                          #           case 43: case 47: case 51: case 55:
8006d904: 0c01b468 jal 0x8006d1a0               #               ? 0x6d1a0 (unitMisc);
8006d908: 02002021 addu r4,r16,r0               #               unitMisc
8006d90c: 0801b65b j 0x8006d96c                 #               break;
8006d910: 00000000 nop                          #           case 34: case 36: case 38: case 40:
8006d914: 0c01b50d jal 0x8006d434               #               ? 0x6d434 (unitMisc);
8006d918: 02002021 addu r4,r16,r0               #               unitMisc
8006d91c: 0801b65b j 0x8006d96c                 #               break;
8006d920: 00000000 nop                          #           case 0: case 2: case 4: case 6: case 8: case 10: case 12: case 14:
8006d924: 0c01b325 jal 0x8006cc94               #               ? 0x6cc94 (unitMisc);
8006d928: 02002021 addu r4,r16,r0               #               unitMisc
8006d92c: 0801b65b j 0x8006d96c                 #               break;
8006d930: 00000000 nop                          #           case 42: case 46: case 50: case 54:
8006d934: 0c01b418 jal 0x8006d060               #               ? 0x6d060 (unitMisc);
8006d938: 02002021 addu r4,r16,r0               #               unitMisc
8006d93c: 0801b65b j 0x8006d96c                 #               break;
8006d940: 00000000 nop                          #           case 33: case 35: case 37: case 39:
8006d944: 0c01b4d1 jal 0x8006d344               #               ? 0x6d344 (unitMisc);
8006d948: 02002021 addu r4,r16,r0               #               unitMisc
8006d94c: 0801b65b j 0x8006d96c                 #               break;
8006d950: 00000000 nop                          #           case 58:
8006d954: 0c01b5f1 jal 0x8006d7c4               #               ? 0x6d7c4 unitMisc);
8006d958: 02002021 addu r4,r16,r0               #               unitMisc
8006d95c: 0801b65b j 0x8006d96c                 #               break;
8006d960: 00000000 nop                          #           case 59:
8006d964: 0c01b5e7 jal 0x8006d79c               #               ? 0x6d79c (unitMisc);
8006d968: 02002021 addu r4,r16,r0               #               unitMisc
                                                #               break;
                                                #   }
8006d96c: 9202007f lbu r2,0x007f(r16)           #   unitMisc.0x7f
8006d970: 00000000 nop
8006d974: 14400061 bne r2,r0,0x8006dafc         #   if (unitMisc.0x7f != 0) return;
8006d978: 340200fe ori r2,r0,0x00fe             #   0xfe                 
8006d97c: 9203009c lbu r3,0x009c(r16)           #   unitMisc.NumMovementTiles
8006d980: 00000000 nop
8006d984: 14620007 bne r3,r2,0x8006d9a4         
8006d988: 340200ff ori r2,r0,0x00ff             #   0xff
                                                #   if (unitMisc.NumMovementTiles == 0xfe) {
8006d98c: 0c01a4af jal 0x800692bc               #       ? 0x692bc (unitMisc);
8006d990: 02002021 addu r4,r16,r0               #       unitMisc
8006d994: 0c01a7b8 jal 0x80069ee0               #       ? 0x69ee0 (unitMisc);
8006d998: 02002021 addu r4,r16,r0               #       unitMisc
8006d99c: 0801b6bf j 0x8006dafc                 #       return;
8006d9a0: 00000000 nop                          #   }
8006d9a4: 14620009 bne r3,r2,0x8006d9cc         #   if (unitMisc.NumMovementTiles == 0xff) {
8006d9a8: 00000000 nop
8006d9ac: 0c01a4af jal 0x800692bc               #       ? 0x692bc (unitMisc);
8006d9b0: 02002021 addu r4,r16,r0               #       unitMisc
8006d9b4: 0c01a7b8 jal 0x80069ee0               #       ? 0x69ee0 (unitMisc);
8006d9b8: 02002021 addu r4,r16,r0               #       unitMisc
8006d9bc: 0c066b8c jal 0x8019ae30               #       ? 0x19ae30 ();
8006d9c0: a200011b sb r0,0x011b(r16)            #       unitMisc.0x11b = 0;
8006d9c4: 0801b6bf j 0x8006dafc                 #       return;
8006d9c8: 00000000 nop
                                                #   }
8006d9cc: 10600049 beq r3,r0,0x8006daf4         #   if ((unitMisc.NumMovementTiles != 0)
8006d9d0: 00000000 nop                          #       
8006d9d4: 8e040098 lw r4,0x0098(r16)            #       unitMisc.NumTilesMovedSoFar
8006d9d8: 00000000 nop
8006d9dc: 0083102b sltu r2,r4,r3                   
8006d9e0: 10400044 beq r2,r0,0x8006daf4         #       and (unitMisc.NumTilesMovedSoFar < unitMisc.NumMovementTiles)) 
                                                #  {
8006d9e4: 2462ffff addiu r2,r3,-0x0001          #       unitMisc.NumMovementTiles - 1
8006d9e8: 14820003 bne r4,r2,0x8006d9f8         #       if (unitMisc.NumTilesMovedSoFar == unitMisc.NumMovementTiles - 1) {
8006d9ec: 00000000 nop
8006d9f0: 0c01b5f9 jal 0x8006d7e4               #           ? 0x6d7e4 (unitMisc);
8006d9f4: 02002021 addu r4,r16,r0               #           unitMisc
                                                #       }
8006d9f8: 8e020098 lw r2,0x0098(r16)            #       oldNumTilesMovedSoFar = unitMisc.NumTilesMovedSoFar
8006d9fc: 00000000 nop
8006da00: 24430001 addiu r3,r2,0x0001           #       oldNumTilesMovedSoFar + 1
8006da04: 02021021 addu r2,r16,r2               #       unitMisc + oldNumTilesMovedSoFar
8006da08: ae030098 sw r3,0x0098(r16)            #       unitMisc.NumTilesMovedSoFar = oldNumTilesMovedSoFar + 1
8006da0c: 9042009d lbu r2,0x009d(r2)            #       moveValue = unitMisc.TileMovementArray[oldNumTilesMovedSoFar]
8006da10: 02002021 addu r4,r16,r0               #       unitMisc
8006da14: 3c018009 lui r1,0x8009
8006da18: a022621c sb r2,0x621c(r1)             #       *0x8009621c = moveValue
8006da1c: 0c01b566 jal 0x8006d598               #       ? 0x6d598 (unitMisc);
8006da20: a202011c sb r2,0x011c(r16)            #       unitMisc.CurrentMovementValue = moveValue
8006da24: 92030119 lbu r3,0x0119(r16)           #       unitMisc.0x119
8006da28: 00000000 nop
8006da2c: 30620080 andi r2,r3,0x0080            #       unitMisc.0x119 & 0x80
8006da30: 10400009 beq r2,r0,0x8006da58         
8006da34: 30620040 andi r2,r3,0x0040            #       unitMisc.0x119 & 0x40
                                                #       if ((unitMisc.0x119 & 0x80) != 0) {
8006da38: 3c058009 lui r5,0x8009
8006da3c: 8ca56220 lw r5,0x6220(r5)             #           *0x80096220
8006da40: 3c068009 lui r6,0x8009
8006da44: 8cc66224 lw r6,0x6224(r6)             #           *0x80096224
8006da48: 0c01a820 jal 0x8006a080               #           ? 0x6a080 (unitMisc, *0x80096220, *0x80096224);
8006da4c: 02002021 addu r4,r16,r0               #           unitMisc
8006da50: 0801b6bf j 0x8006dafc                 #           return;
8006da54: 00000000 nop
                                                #       }
8006da58: 10400009 beq r2,r0,0x8006da80         #       if ((unitMisc.0x119 & 0x40) != 0) {
8006da5c: 00000000 nop
8006da60: 3c058009 lui r5,0x8009
8006da64: 8ca56220 lw r5,0x6220(r5)             #           *0x80096220
8006da68: 3c068009 lui r6,0x8009
8006da6c: 8cc66224 lw r6,0x6224(r6)             #           *0x80096224
8006da70: 0c01a7c5 jal 0x80069f14               #           ? 0x69f14 (unitMisc, *0x80096220, *0x80096224);
8006da74: 02002021 addu r4,r16,r0               #           unitMisc
8006da78: 0801b6bf j 0x8006dafc                 #           return;
8006da7c: 00000000 nop
                                                #       }
8006da80: 3c028009 lui r2,0x8009
8006da84: 9042621c lbu r2,0x621c(r2)            #       *0x8009621c
8006da88: 00000000 nop
8006da8c: 00021082 srl r2,r2,0x02               #       *0x8009621c >> 2
8006da90: 30430001 andi r3,r2,0x0001            #       testValue = ((*0x8009621c >> 2) & 1)
8006da94: 10600005 beq r3,r0,0x8006daac         #   
8006da98: 34020001 ori r2,r0,0x0001             #       1                                           
                                                #       if (testValue != 0) {
8006da9c: 1062000d beq r3,r2,0x8006dad4         #           if (testValue != 1)         // How is this even possible?
8006daa0: 00000000 nop
8006daa4: 0801b6bf j 0x8006dafc                 #               return;
8006daa8: 00000000 nop
                                                #       } else {
8006daac: 02002021 addu r4,r16,r0               #           unitMisc
8006dab0: 3c058009 lui r5,0x8009
8006dab4: 8ca56220 lw r5,0x6220(r5)             #           *0x80096220
8006dab8: 3c068009 lui r6,0x8009
8006dabc: 8cc66224 lw r6,0x6224(r6)             #           *0x80096224
8006dac0: 34022000 ori r2,r0,0x2000             #           0x2000
8006dac4: 0c01a883 jal 0x8006a20c               #           ? 0x6a20c (unitMisc, *0x80096220, *0x80096224);
8006dac8: ac82003c sw r2,0x003c(r4)             #           unitMisc.0x3c = 0x2000      // Special movement flags??
8006dacc: 0801b6bf j 0x8006dafc                 #           return;
8006dad0: 00000000 nop
                                                #       }
8006dad4: 3c058009 lui r5,0x8009
8006dad8: 8ca56220 lw r5,0x6220(r5)             #       *0x80096220
8006dadc: 3c068009 lui r6,0x8009
8006dae0: 8cc66224 lw r6,0x6224(r6)             #       *0x80096224
8006dae4: 0c01a8e0 jal 0x8006a380               #       ? 0x6a380 (unitMisc, *0x80096220, *0x80096224);
8006dae8: 02002021 addu r4,r16,r0               #       unitMisc
8006daec: 0801b6bf j 0x8006dafc                 #       return;
8006daf0: 00000000 nop
                                                #   }
8006daf4: 0c01af39 jal 0x8006bce4               #   ? 0x6bce4 (unitMisc);
8006daf8: 02002021 addu r4,r16,r0               #   unitMisc
8006dafc: 8fbf0014 lw r31,0x0014(r29)
8006db00: 8fb00010 lw r16,0x0010(r29)
8006db04: 27bd0018 addiu r29,r29,0x0018
8006db08: 03e00008 jr r31
8006db0c: 00000000 nop