Difference between revisions of "Death sentence, crystalization, treasurization, etc"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with " Death sentence, crystalization, treasurization, reraise, defend removal, chicken brave increment 00183078: 27bdffe0 addiu r29,r29,0xffe0 0018307c: afb00010 sw r16,0x0010(r2...")
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  Death sentence, crystalization, treasurization, reraise, defend removal, chicken brave increment
+
'''BATTLE.BIN''' :  - Death sentence, crystalization, treasurization, reraise, defend removal, chicken brave increment
  00183078: 27bdffe0 addiu r29,r29,0xffe0
+
  ------------------------------------------------------------------------------------------
0018307c: afb00010 sw r16,0x0010(r29)
+
  Parameter : r4 = Unit ID (Active Unit : CT > 100)
00183080: 00a08021 addu r16,r5,r0
+
            r5 = Unit data pointer
00183084: afb10014 sw r17,0x0014(r29)
+
  Return : r2 = 0 No additionnal action to process
00183088: 2611018c addiu r17,r16,0x018c
+
          r2 = 1 if crystal or treasure infliction
0018308c: afbf0018 sw r31,0x0018(r29)
+
          r2 = 2 Reraise (status or undead unit), cancel defend or Increment Brave
00183090: 0c062f5d jal 0x0018bd74
+
          r2 = 3 If death by death sentence
  00183094: 02202021 addu r4,r17,r0
+
  ------------------------------------------------------------------------------------------
00183098: 0c0088c3 jal 0x0002230c
+
  00183078: 27bdffe0 addiu r29,r29,-0x0020    |
0018309c: 00000000 nop
+
  0018307c: afb00010 sw r16,0x0010(r29)       |
  001830a0: 00403021 addu r6,r2,r0
+
  00183080: 00a08021 addu r16,r5,r0            |{{f/adr|Preserve Unit data pointer}}
001830a4: 92030058 lbu r3,0x0058(r16)
+
  00183084: afb10014 sw r17,0x0014(r29)        |
001830a8: 34020020 ori r2,r0,0x0020
+
  00183088: 2611018c addiu r17,r16,0x018c      |{{f/adr|Unit Current Action data pointer}}
  001830ac: 30630030 andi r3,r3,0x0030
+
  0018308c: afbf0018 sw r31,0x0018(r29)        |
001830b0: 14620013 bne r3,r2,0x 00183100 branch if dead or undead
+
  00183090: 0c062f5d jal 0x0018bd74            |{{f/jal|Current Action Data Nulling|Current Action Data Nulling}}
001830b4: 00000000 nop
+
  00183094: 02202021 addu r4,r17,r0            |{{f/std|send pointer}}
001830b8: 9202005a lbu r2,0x005a(r16)
+
00183098: 0c0088c3 jal 0x0002230c            |{{f/jal|Random Number Generator|Random Number Generator}}
001830bc: 00000000 nop
+
  0018309c: 00000000 nop                      |
001830c0: 30420020 andi r2,r2,0x0020
+
  001830a0: 00403021 addu r6,r2,r0            |{{f/std|Pass rdm number (0-7fff) on r6}}
001830c4: 1040000e beq r2,r0,0x 00183100 Branch if Status = Reraise
+
  001830a4: 92030058 lbu r3,0x0058(r16)        |{{f/load|Current status set 1}}
  001830c8: 3c03cccc lui r3,0xcccc
+
  001830a8: 34020020 ori r2,r0,0x0020          |
 
+
  001830ac: 30630030 andi r3,r3,0x0030        |{{f/std|Check Dead and Undead}}
  001830cc: 9602002a lhu r2,0x002a(r16) Load Unit's Max HP
+
  001830b0: 14620013 bne r3,r2,0x00183100      {{f/Cond|If Unit is Dead and is not undead}}
  001830d0: 3463cccd ori r3,r3,0xcccd
+
  001830b4: 00000000 nop                           |
  001830d4: 00430019 multu r2,r3 Max HP * 0.8
+
   
  001830d8: 34020002 ori r2,r0,0x0002 r2 = 2
+
                  {{f/sec|--------------- Reraise (status) section -------------------}}
  001830dc: 34030020 ori r3,r0,0x0020 r3 = 20
+
  001830b8: 9202005a lbu r2,0x005a(r16)            |{{f/load|Current status set 3}}
  001830e0: a20301ac sb r3,0x01ac(r16) Store Status Removal 1 = Dead
+
001830bc: 00000000 nop                           |
  001830e4: a20301ae sb r3,0x01ae(r16) Store Status Removal 3 = Reraise
+
  001830c0: 30420020 andi r2,r2,0x0020            |
  001830e8: 34030048 ori r3,r0,0x0048
+
  001830c4: 1040000e beq r2,r0,0x00183100          {{f/Cond|If Unit has reraise}}
  001830ec: a20301b1 sb r3,0x01b1(r16) Store Attack Type = HP Heal/Status Change?
+
  001830c8: 3c03cccc lui r3,0xcccc                    |
  001830f0: 00001810 mfhi r3 r3 = Max HP * 0.8
+
  001830cc: 9602002a lhu r2,0x002a(r16)                |{{f/load|Load Unit's Max HP}}
  001830f4: 000318c2 srl r3,r3,0x03 Max HP / 10
+
  001830d0: 3463cccd ori r3,r3,0xcccd                  |
  001830f8: 08060cad j 0x 001832b4
+
  001830d4: 00430019 multu r2,r3                      |
  001830fc: a6030192 sh r3,0x0192(r16) Store HP Recovery = Max HP / 10
+
  001830d8: 34020002 ori r2,r0,0x0002                  |
 
+
  001830dc: 34030020 ori r3,r0,0x0020                  |
  00183100: 92050058 lbu r5,0x0058(r16)
+
  001830e0: a20301ac sb r3,0x01ac(r16)                |{{f/store|<nowiki>Store Status Removal 1 = Dead</nowiki>}}
00183104: 00000000 nop
+
001830e4: a20301ae sb r3,0x01ae(r16)                 |{{f/store|<nowiki>Store Status Removal 3 = Reraise</nowiki>}}
  00183108: 30a20020 andi r2,r5,0x0020
+
  001830e8: 34030048 ori r3,r0,0x0048                  |
0018310c: 1040003d beq r2,r0,0x 00183204 branch if not dead
+
  001830ec: a20301b1 sb r3,0x01b1(r16)                |{{f/store|<nowiki>Store Attack Type = HP Heal and Status Change</nowiki>}}
  00183110: 00000000 nop
+
  001830f0: 00001810 mfhi r3                          |{{f/std|<nowiki>r3 = Max HP * 0.8</nowiki>}}
  if dead
+
  001830f4: 000318c2 srl r3,r3,0x03                    |{{f/std|Max HP / 10}}
00183114: 3c028019 lui r2,0x8019
+
  001830f8: 08060cad j 0x001832b4                      {{f/jump|Jump to }} {{f/loc|END}} {{f/std|return 0x02}}
  00183118: 8c42f5fc lw r2,-0x0a04(r2) load acting unit ID
+
  001830fc: a6030192 sh r3,0x0192(r16)                |{{f/store|<nowiki>Store HP Recovery = 10% of Max HP</nowiki>}}
  0018311c: 00000000 nop
+
                                            '''Else : Unit is Not dead or dead and will not reraise'''
  00183120: 14400038 bne r2,r0,0x 00183204
+
  00183100: 92050058 lbu r5,0x0058(r16)           |{{f/load|Current status set 1}}
  00183124: 00000000 nop
+
00183104: 00000000 nop                          |
  00183128: 92020005 lbu r2,0x0005(r16)
+
  00183108: 30a20020 andi r2,r5,0x0020            |
  0018312c: 00000000 nop
+
  0018310c: 1040003d beq r2,r0,0x00183204          {{f/Cond|If unit is dead}}
00183130: 30420004 andi r2,r2,0x0004
+
  00183110: 00000000 nop                              |
  00183134: 1440005f bne r2,r0,0x 001832b4 branch if immortal return r2 = 0
+
   
  00183138: 00001021 addu r2,r0,r0
+
                  {{f/sec|--------------- Death counter Expiration section -------------------}}
 
+
  00183114: 3c028019 lui r2,0x8019                    |
0018313c: 92020006 lbu r2,0x0006(r16)
+
  00183118: 8c42f5fc lw r2,-0x0a04(r2)                 |{{f/load|Load Action state}}
  00183140: 00000000 nop
+
  0018311c: 00000000 nop                               |
00183144: 30420009 andi r2,r2,0x0009
+
  00183120: 14400038 bne r2,r0,0x00183204              {{f/Cond|If Action is not executing : avoid dead section}}
  00183148: 1440005a bne r2,r0,0x 001832b4 branch if immortal/save/load formation
+
  00183124: 00000000 nop                                  |
  0018314c: 00001021 addu r2,r0,r0
+
  00183128: 92020005 lbu r2,0x0005(r16)                |{{f/load|Unit ENTD flags}}
  00183150: 92040007 lbu r4,0x0007(r16) load death counter
+
  0018312c: 00000000 nop                              |
  00183154: 340200ff ori r2,r0,0x00ff
+
  00183130: 30420004 andi r2,r2,0x0004                |{{f/std|Check immortal}}
  00183158: 2484ffff addiu r4,r4,0xffff death counter -1
+
  00183134: 1440005f bne r2,r0,0x001832b4              {{f/Cond|If Unit is immortal : branch to }} {{f/loc|END}} {{f/std|return 0x00}}
0018315c: 308300ff andi r3,r4,0x00ff
+
  00183138: 00001021 addu r2,r0,r0                        |
00183160: 10620003 beq r3,r2,0x 00183170 branch if knocked out
+
0018313c: 92020006 lbu r2,0x0006(r16)               |{{f/load|Unit Gender}}
00183164: 00001021 addu r2,r0,r0 return r2 = 0
+
  00183140: 00000000 nop                              |
  00183168: 08060cad j 0x 001832b4
+
  00183144: 30420009 andi r2,r2,0x0009                |{{f/std|Check [Load Formation] and [Save as guest]}}
0018316c: a2040007 sb r4,0x0007(r16) store new death counter
+
  00183148: 1440005a bne r2,r0,0x001832b4              {{f/Cond|If unit has [Load formation] or [Save as a guest] flags : branch to}} {{f/loc|END}} {{f/std|return 0x00}}
 
+
  0018314c: 00001021 addu r2,r0,r0                        |
  00183170: 30a20010 andi r2,r5,0x0010
+
  00183174: 10400012 beq r2,r0,0x 001831c0 branch if not undead
+
  00183150: 92040007 lbu r4,0x0007(r16)                |{{f/load|load death counter}}
  00183178: 30c20001 andi r2,r6,0x0001
+
  00183154: 340200ff ori r2,r0,0x00ff                  |
  0018317c: 10400010 beq r2,r0,0x 001831c0 ?
+
  00183158: 2484ffff addiu r4,r4,-0x0001              |{{f/std|death counter -1}}
00183180: 34020020 ori r2,r0,0x0020
+
  0018315c: 308300ff andi r3,r4,0x00ff                |
 
+
  00183160: 10620003 beq r3,r2,0x00183170              {{f/Cond|If Death counter has not expired}}
  00183184: 0c0088c3 jal 0x0002230c     random number
+
  00183164: 00001021 addu r2,r0,r0                        |
  00183188: a2220020 sb r2,0x0020(r17) store ??
+
  00183168: 08060cad j 0x001832b4                          {{f/jump|Jump to }} {{f/loc|END}} {{f/std|return 0x00}}
  0018318c: 9603002a lhu r3,0x002a(r16) load max HP
+
  0018316c: a2040007 sb r4,0x0007(r16)                    |{{f/store|store new death counter}}
  00183190: 00000000 nop
+
                                                    '''Else : death counter has expired'''
  00183194: 00430018 mult r2,r3
+
  00183170: 30a20010 andi r2,r5,0x0010                    |{{f/std|Undead check}}
00183198: 00001812 mflo r3
+
  00183174: 10400012 beq r2,r0,0x001831c0                  {{f/Cond|If Unit is undead}}
  0018319c: 04610002 bgez r3,0x 001831a8
+
  00183178: 30c20001 andi r2,r6,0x0001                        |{{f/std|Random is uneven ? (50%)}}
  001831a0: 34020002 ori r2,r0,0x0002 return r2 = 2
+
  0018317c: 10400010 beq r2,r0,0x001831c0                      {{f/Cond|If Undead unit is reviving}}
  001831a4: 24637fff addiu r3,r3,0x7fff
+
                                            {{f/sec|Revive Undead}}
  001831a8: 00031bc3 sra r3,r3,0x0f
+
  00183180: 34020020 ori r2,r0,0x0020                              |
  001831ac: 24630001 addiu r3,r3,0x0001 Undead Revival
+
  00183184: 0c0088c3 jal 0x0002230c                                |{{f/jal|Random Number Generator|Random Number Generator}}
  001831b0: a6230006 sh r3,0x0006(r17) store HP recovery
+
  00183188: a2220020 sb r2,0x0020(r17)                             |{{f/store|<nowiki>Store status removal 1 = dead</nowiki>}}
  001831b4: 34030048 ori r3,r0,0x0048
+
  0018318c: 9603002a lhu r3,0x002a(r16)                            |{{f/load|load max HP}}
  001831b8: 08060cad j 0x 001832b4
+
00183190: 00000000 nop                                           |
  001831bc: a2230025 sb r3,0x0025(r17) store attack type HP recovery/status change
+
  00183194: 00430018 mult r2,r3                                    |
 
+
  00183198: 00001812 mflo r3                                      |{{f/std|Max HP * Rdm(1…7fff)}}
  001831c0: 920201ba lbu r2,0x01ba(r16) load modified flags
+
  0018319c: 04610002 bgez r3,0x001831a8                            {{f/Cond|If Result is less than 0}}
  001831c4: 00000000 nop
+
  001831a0: 34020002 ori r2,r0,0x0002                              |
  001831c8: 30420008 andi r2,r2,0x0008
+
  001831a4: 24637fff addiu r3,r3,0x7fff                                |{{f/std|Make positive}}
  001831cc: 10400002 beq r2,r0,0x 001831d8 branch if not control flagged
+
  001831a8: 00031bc3 sra r3,r3,0x0f                                |
  001831d0: 34030010 ori r3,r0,0x0010
+
  001831ac: 24630001 addiu r3,r3,0x0001                            |{{f/std|rdm (1…Max HP)}}
  001831d4: 34030110 ori r3,r0,0x0110
+
  001831b0: a6230006 sh r3,0x0006(r17)                            |{{f/store|store as HP recovery}}
001831d8: 00c31024 and r2,r6,r3
+
  001831b4: 34030048 ori r3,r0,0x0048                              |
  001831dc: 10400004 beq r2,r0,0x 001831f0
+
001831b8: 08060cad j 0x001832b4                                  {{f/jump|Jump to }} {{f/loc|END}} {{f/std|return 0x02}}
  001831e0: 34020001 ori r2,r0,0x0001 return r2 = 1
+
  001831bc: a2230025 sb r3,0x0025(r17)                             |{{f/store|store attack type HP recovery and status change}}
  001831e4: 34030040 ori r3,r0,0x0040
+
   
001831e8: 08060c7e j 0x 001831f8
+
                                            {{f/sec|Crystal or Treasure ?}}
  001831ec: a223001b sb r3,0x001b(r17) store attack status infliction (0x40 = crystal)
+
                                                        '''Else : Dead unit is not undead (very dead)'''
 
+
  001831c0: 920201ba lbu r2,0x01ba(r16)                       |{{f/load|load modified flags}}
  001831f0: 34030001 ori r3,r0,0x0001
+
  001831c4: 00000000 nop                                       |
  001831f4: a223001c sb r3,0x001c(r17) store attack status infliction treasure
+
  001831c8: 30420008 andi r2,r2,0x0008                        |
  001831f8: 34030008 ori r3,r0,0x0008
+
  001831cc: 10400002 beq r2,r0,0x001831d8                      {{f/Cond|If Player controls unit}}
001831fc: 08060cad j 0x 001832b4
+
  001831d0: 34030010 ori r3,r0,0x0010                          |{{f/std|50% chances of 0x00}}
  00183200: a2230025 sb r3,0x0025(r17) store status change
+
  001831d4: 34030110 ori r3,r0,0x0110                              |{{f/std|25% chances of 0x00}}
  if not dead
+
  001831d8: 00c31024 and r2,r6,r3                                  |
  00183204: 9202005c lbu r2,0x005c(r16) load current status
+
  001831dc: 10400004 beq r2,r0,0x001831f0                      {{f/Cond|If Rdm says Crystal (50% for AI, 75% for player)}}
  00183208: 00000000 nop
+
001831e0: 34020001 ori r2,r0,0x0001                              |{{f/std|<nowiki>return r2 = 1</nowiki>}}
  0018320c: 30420001 andi r2,r2,0x0001
+
  001831e4: 34030040 ori r3,r0,0x0040                              |{{f/std|Crystal bit}}
  00183210: 10400013 beq r2,r0,0x 00183260 branch if not death sentenced
+
001831e8: 08060c7e j 0x001831f8                                  {{f/jump|Jump to Attack Type (Avoid treasure)}}
  00183214: 00000000 nop
+
  001831ec: a223001b sb r3,0x001b(r17)                             |{{f/store|<nowiki>store attack status infliction (0x40 = crystal)</nowiki>}}
  00183218: 9204006c lbu r4,0x006c(r16) load death sentence CT
+
                                                            '''Else : Treasure'''
  0018321c: 00000000 nop
+
  001831f0: 34030001 ori r3,r0,0x0001                              |{{f/std|Treasure bit}}
  00183220: 2484ffff addiu r4,r4,0xffff decrement death sentence CT
+
  001831f4: a223001c sb r3,0x001c(r17)                            |{{f/store|store attack status infliction treasure}}
  00183224: 308200ff andi r2,r4,0x00ff
+
  001831f8: 34030008 ori r3,r0,0x0008                          |
  00183228: 1440000c bne r2,r0,0x 0018325c branch if CT is not 0
+
  001831fc: 08060cad j 0x001832b4                              {{f/jump|Jump to }} {{f/loc|END}} {{f/std|return 0x01}}
  0018322c: 34020001 ori r2,r0,0x0001
+
  00183200: a2230025 sb r3,0x0025(r17)                         |{{f/store|<nowiki>Attack type = status change</nowiki>}}
  00183230: a2220024 sb r2,0x0024(r17) store death sentence status removal
+
                  {{f/sec|--------------- Not Dead section : Death sentence, Defend, Chicken-------------------}}
  00183234: 34020008 ori r2,r0,0x0008
+
                                                '''Else : Unit is not Dead'''
00183238: a2220025 sb r2,0x0025(r17) store as status change
+
  00183204: 9202005c lbu r2,0x005c(r16)                |{{f/load|load current status 3}}
  0018323c: 92020058 lbu r2,0x0058(r16) laod current status
+
  00183208: 00000000 nop                              |
  00183240: 00000000 nop
+
  0018320c: 30420001 andi r2,r2,0x0001                |
  00183244: 30420010 andi r2,r2,0x0010
+
  00183210: 10400013 beq r2,r0,0x00183260              {{f/Cond|If Unit has Death Sentence}}
  00183248: 14400005 bne r2,r0,0x 00183260 Branch if undead
+
00183214: 00000000 nop                                  |
  0018324c: 34020020 ori r2,r0,0x0020
+
00183218: 9204006c lbu r4,0x006c(r16)                    |{{f/load|load death sentence CT}}
  00183250: a222001b sb r2,0x001b(r17) store attack status infliction: dead
+
0018321c: 00000000 nop                                  |
  00183254: 08060cad j 0x 001832b4
+
00183220: 2484ffff addiu r4,r4,-0x0001              |{{f/std|decrement death sentence CT}}
  00183258: 34020003 ori r2,r0,0x0003 jump to end, return r2 = 3
+
00183224: 308200ff andi r2,r4,0x00ff                |
 
+
00183228: 1440000c bne r2,r0,0x0018325c                  {{f/Cond|If CT reach 0}}
  0018325c: a204006c sb r4,0x006c(r16) store death sentence CT
+
0018322c: 34020001 ori r2,r0,0x0001                          |{{f/std|Death sentence bit}}
  00183260: 92020058 lbu r2,0x0058(r16) load current status
+
00183230: a2220024 sb r2,0x0024(r17)                        |{{f/store|store death sentence status removal}}
00183264: 00000000 nop
+
00183234: 34020008 ori r2,r0,0x0008                          |
  00183268: 30420002 andi r2,r2,0x0002
+
00183238: a2220025 sb r2,0x0025(r17)                        |{{f/store|store as status change (attack type)}}
  0018326c: 10400004 beq r2,r0,0x 00183280 branch if not defending
+
0018323c: 92020058 lbu r2,0x0058(r16)                        |{{f/load|laod current status}}
  00183270: 34020002 ori r2,r0,0x0002
+
00183240: 00000000 nop                                      |
  00183274: a2220020 sb r2,0x0020(r17) store attack status removal: defend
+
00183244: 30420010 andi r2,r2,0x0010                        |
  00183278: 34020008 ori r2,r0,0x0008
+
00183248: 14400005 bne r2,r0,0x00183260                      {{f/Cond|If Unit is undead Avoid Death infliction}}
0018327c: a2220025 sb r2,0x0025(r17) store attack type
+
0018324c: 34020020 ori r2,r0,0x0020                          |{{f/std|Death bit}}
00183280: 92020024 lbu r2,0x0024(r16) load brave
+
00183250: a222001b sb r2,0x001b(r17)                        |{{f/store|store attack status infliction: dead}}
00183284: 00000000 nop
+
00183254: 08060cad j 0x001832b4                              {{f/jump|Jump to }} {{f/loc|END}} {{f/std|return 0x03}}
00183288: 2c42000a sltiu r2,r2,0x000a
+
00183258: 34020003 ori r2,r0,0x0003                              |
  0018328c: 10400005 beq r2,r0,0x 001832a4 branch if brave > 10
+
                                                        '''Else : CT no null'''
  00183290: 34030081 ori r3,r0,0x0081
+
0018325c: a204006c sb r4,0x006c(r16)                        |{{f/store|Update death sentence CT}}
  00183294: 92220025 lbu r2,0x0025(r17) load attack type
+
00183260: 92020058 lbu r2,0x0058(r16)                |{{f/load|load current status 1}}
  00183298: a2230016 sb r3,0x0016(r17) store brave change +1
+
00183264: 00000000 nop                              |
0018329c: 34420001 ori r2,r2,0x0001
+
00183268: 30420002 andi r2,r2,0x0002                |
001832a0: a2220025 sb r2,0x0025(r17) store attack type
+
0018326c: 10400004 beq r2,r0,0x00183280              {{f/Cond|If Unit is defending}}
001832a4: 92220025 lbu r2,0x0025(r17)
+
00183270: 34020002 ori r2,r0,0x0002                      |
  001832a8: 00000000 nop
+
00183274: a2220020 sb r2,0x0020(r17)                    |{{f/store|store attack status removal: defend}}
  001832ac: 0002102b sltu r2,r0,r2 set if attack type < 2
+
00183278: 34020008 ori r2,r0,0x0008                      |
  001832b0: 00021040 sll r2,r2,0x01 return 2 if attack type < 2
+
0018327c: a2220025 sb r2,0x0025(r17)                    |{{f/store|store attack type : status change}}
 +
00183280: 92020024 lbu r2,0x0024(r16)                |{{f/load|load unit's brave}}
 +
00183284: 00000000 nop                              |
 +
00183288: 2c42000a sltiu r2,r2,0x000a                |
 +
0018328c: 10400005 beq r2,r0,0x001832a4              {{f/Cond|If Brave < 10 (chicken brave increment)}}
 +
00183290: 34030081 ori r3,r0,0x0081                      |
 +
00183294: 92220025 lbu r2,0x0025(r17)                    |{{f/load|load attack type}}
 +
00183298: a2230016 sb r3,0x0016(r17)                    |{{f/store|store brave change : bonus +1}}
 +
0018329c: 34420001 ori r2,r2,0x0001                      |
 +
001832a0: a2220025 sb r2,0x0025(r17)                    |{{f/store|store attack type : pseudo status}}
 +
001832a4: 92220025 lbu r2,0x0025(r17)               |{{f/load|Load attack type}}
 +
  001832a8: 00000000 nop                               |
 +
  001832ac: 0002102b sltu r2,r0,r2                     |{{f/std|1 If Attack type is not null}}
 +
  001832b0: 00021040 sll r2,r2,0x01                   |{{f/std|Return 2 if here and attack type is not null}} {{f/std|Most of cases forces exit at 1832b4}}
 
  001832b4: 8fbf0018 lw r31,0x0018(r29)
 
  001832b4: 8fbf0018 lw r31,0x0018(r29)
 
  001832b8: 8fb10014 lw r17,0x0014(r29)
 
  001832b8: 8fb10014 lw r17,0x0014(r29)
Line 159: Line 172:
 
  001832c4: 03e00008 jr r31
 
  001832c4: 03e00008 jr r31
 
  001832c8: 00000000 nop
 
  001832c8: 00000000 nop
 +
===Return locations===
 +
'''BATTLE.BIN'''
 +
  00182b18: [[In_between_turn_control_routine]]

Latest revision as of 16:14, 16 March 2024

BATTLE.BIN :  -  Death sentence, crystalization, treasurization, reraise, defend removal, chicken brave increment
------------------------------------------------------------------------------------------
Parameter : r4 = Unit ID (Active Unit : CT > 100)
            r5 = Unit data pointer
Return : r2 = 0 No additionnal action to process
         r2 = 1 if crystal or treasure infliction 
         r2 = 2 Reraise (status or undead unit), cancel defend or Increment Brave
         r2 = 3 If death by death sentence
------------------------------------------------------------------------------------------
00183078: 27bdffe0 addiu r29,r29,-0x0020     |
0018307c: afb00010 sw r16,0x0010(r29)        |
00183080: 00a08021 addu r16,r5,r0            |Preserve Unit data pointer
00183084: afb10014 sw r17,0x0014(r29)        |
00183088: 2611018c addiu r17,r16,0x018c      |Unit Current Action data pointer
0018308c: afbf0018 sw r31,0x0018(r29)        |
00183090: 0c062f5d jal 0x0018bd74            |-->Current Action Data Nulling
00183094: 02202021 addu r4,r17,r0            |send pointer
00183098: 0c0088c3 jal 0x0002230c            |-->Random Number Generator
0018309c: 00000000 nop                       |
001830a0: 00403021 addu r6,r2,r0             |Pass rdm number (0-7fff) on r6
001830a4: 92030058 lbu r3,0x0058(r16)        |Current status set 1
001830a8: 34020020 ori r2,r0,0x0020          |
001830ac: 30630030 andi r3,r3,0x0030         |Check Dead and Undead
001830b0: 14620013 bne r3,r2,0x00183100      #If Unit is Dead and is not undead
001830b4: 00000000 nop                           |

                  --------------- Reraise (status) section -------------------
001830b8: 9202005a lbu r2,0x005a(r16)            |Current status set 3
001830bc: 00000000 nop                           |
001830c0: 30420020 andi r2,r2,0x0020             |
001830c4: 1040000e beq r2,r0,0x00183100          #If Unit has reraise
001830c8: 3c03cccc lui r3,0xcccc                     |
001830cc: 9602002a lhu r2,0x002a(r16)                |Load Unit's Max HP
001830d0: 3463cccd ori r3,r3,0xcccd                  |
001830d4: 00430019 multu r2,r3                       |
001830d8: 34020002 ori r2,r0,0x0002                  |
001830dc: 34030020 ori r3,r0,0x0020                  |
001830e0: a20301ac sb r3,0x01ac(r16)                 |Store Status Removal 1 = Dead
001830e4: a20301ae sb r3,0x01ae(r16)                 |Store Status Removal 3 = Reraise
001830e8: 34030048 ori r3,r0,0x0048                  |
001830ec: a20301b1 sb r3,0x01b1(r16)                 |Store Attack Type = HP Heal and Status Change
001830f0: 00001810 mfhi r3                           |r3 = Max HP * 0.8
001830f4: 000318c2 srl r3,r3,0x03                    |Max HP / 10
001830f8: 08060cad j 0x001832b4                      >>Jump to  END return 0x02
001830fc: a6030192 sh r3,0x0192(r16)                 |Store HP Recovery = 10% of Max HP
                                            Else : Unit is Not dead or dead and will not reraise
00183100: 92050058 lbu r5,0x0058(r16)            |Current status set 1
00183104: 00000000 nop                           |
00183108: 30a20020 andi r2,r5,0x0020             |
0018310c: 1040003d beq r2,r0,0x00183204          #If unit is dead
00183110: 00000000 nop                               |

                  --------------- Death counter Expiration  section -------------------
00183114: 3c028019 lui r2,0x8019                     |
00183118: 8c42f5fc lw r2,-0x0a04(r2)                 |Load Action state
0018311c: 00000000 nop                               |
00183120: 14400038 bne r2,r0,0x00183204              #If Action is not executing : avoid dead section
00183124: 00000000 nop                                   |
00183128: 92020005 lbu r2,0x0005(r16)                |Unit ENTD flags
0018312c: 00000000 nop                               |
00183130: 30420004 andi r2,r2,0x0004                 |Check immortal
00183134: 1440005f bne r2,r0,0x001832b4              #If Unit is immortal : branch to  END return 0x00
00183138: 00001021 addu r2,r0,r0                         |
0018313c: 92020006 lbu r2,0x0006(r16)                |Unit Gender
00183140: 00000000 nop                               |
00183144: 30420009 andi r2,r2,0x0009                 |Check [Load Formation] and [Save as guest]
00183148: 1440005a bne r2,r0,0x001832b4              #If unit has [Load formation] or [Save as a guest] flags : branch to END return 0x00
0018314c: 00001021 addu r2,r0,r0                         |

00183150: 92040007 lbu r4,0x0007(r16)                |load death counter
00183154: 340200ff ori r2,r0,0x00ff                  |
00183158: 2484ffff addiu r4,r4,-0x0001               |death counter -1
0018315c: 308300ff andi r3,r4,0x00ff                 |
00183160: 10620003 beq r3,r2,0x00183170              #If Death counter has not expired
00183164: 00001021 addu r2,r0,r0                         |
00183168: 08060cad j 0x001832b4                          >>Jump to  END return 0x00
0018316c: a2040007 sb r4,0x0007(r16)                     |store new death counter
                                                    Else : death counter has expired
00183170: 30a20010 andi r2,r5,0x0010                     |Undead check
00183174: 10400012 beq r2,r0,0x001831c0                  #If Unit is undead
00183178: 30c20001 andi r2,r6,0x0001                         |Random is uneven ? (50%)
0018317c: 10400010 beq r2,r0,0x001831c0                      #If Undead unit is reviving
                                            Revive Undead
00183180: 34020020 ori r2,r0,0x0020                              |
00183184: 0c0088c3 jal 0x0002230c                                |-->Random Number Generator
00183188: a2220020 sb r2,0x0020(r17)                             |Store status removal 1 = dead
0018318c: 9603002a lhu r3,0x002a(r16)                            |load max HP
00183190: 00000000 nop                                           |
00183194: 00430018 mult r2,r3                                    |
00183198: 00001812 mflo r3                                       |Max HP * Rdm(1…7fff)
0018319c: 04610002 bgez r3,0x001831a8                            #If Result is less than 0
001831a0: 34020002 ori r2,r0,0x0002                              |
001831a4: 24637fff addiu r3,r3,0x7fff                                |Make positive
001831a8: 00031bc3 sra r3,r3,0x0f                                |
001831ac: 24630001 addiu r3,r3,0x0001                            |rdm (1…Max HP)
001831b0: a6230006 sh r3,0x0006(r17)                             |store as HP recovery
001831b4: 34030048 ori r3,r0,0x0048                              |
001831b8: 08060cad j 0x001832b4                                  >>Jump to  END return 0x02
001831bc: a2230025 sb r3,0x0025(r17)                             |store attack type HP recovery and status change

                                            Crystal or Treasure ?
                                                        Else : Dead unit is not undead (very dead)
001831c0: 920201ba lbu r2,0x01ba(r16)                        |load modified flags
001831c4: 00000000 nop                                       |
001831c8: 30420008 andi r2,r2,0x0008                         |
001831cc: 10400002 beq r2,r0,0x001831d8                      #If Player controls unit
001831d0: 34030010 ori r3,r0,0x0010                          |50% chances of 0x00
001831d4: 34030110 ori r3,r0,0x0110                              |25% chances of 0x00
001831d8: 00c31024 and r2,r6,r3                                  |
001831dc: 10400004 beq r2,r0,0x001831f0                      #If Rdm says Crystal (50% for AI, 75% for player)
001831e0: 34020001 ori r2,r0,0x0001                              |return r2 = 1
001831e4: 34030040 ori r3,r0,0x0040                              |Crystal bit
001831e8: 08060c7e j 0x001831f8                                  >>Jump to Attack Type (Avoid treasure)
001831ec: a223001b sb r3,0x001b(r17)                             |store attack status infliction (0x40 = crystal)
                                                            Else : Treasure
001831f0: 34030001 ori r3,r0,0x0001                              |Treasure bit
001831f4: a223001c sb r3,0x001c(r17)                             |store attack status infliction treasure
001831f8: 34030008 ori r3,r0,0x0008                          |
001831fc: 08060cad j 0x001832b4                              >>Jump to  END return 0x01
00183200: a2230025 sb r3,0x0025(r17)                         |Attack type = status change
                  --------------- Not Dead section : Death sentence, Defend, Chicken-------------------
                                                Else : Unit is not Dead
00183204: 9202005c lbu r2,0x005c(r16)                |load current status 3
00183208: 00000000 nop                               |
0018320c: 30420001 andi r2,r2,0x0001                 |
00183210: 10400013 beq r2,r0,0x00183260              #If Unit has Death Sentence
00183214: 00000000 nop                                   |
00183218: 9204006c lbu r4,0x006c(r16)                    |load death sentence CT
0018321c: 00000000 nop                                   |
00183220: 2484ffff addiu r4,r4,-0x0001               |decrement death sentence CT
00183224: 308200ff andi r2,r4,0x00ff                 |
00183228: 1440000c bne r2,r0,0x0018325c                  #If CT reach 0
0018322c: 34020001 ori r2,r0,0x0001                          |Death sentence bit
00183230: a2220024 sb r2,0x0024(r17)                         |store death sentence status removal
00183234: 34020008 ori r2,r0,0x0008                          |
00183238: a2220025 sb r2,0x0025(r17)                         |store as status change (attack type)
0018323c: 92020058 lbu r2,0x0058(r16)                        |laod current status
00183240: 00000000 nop                                       |
00183244: 30420010 andi r2,r2,0x0010                         |
00183248: 14400005 bne r2,r0,0x00183260                      #If Unit is undead Avoid Death infliction
0018324c: 34020020 ori r2,r0,0x0020                          |Death bit
00183250: a222001b sb r2,0x001b(r17)                         |store attack status infliction: dead
00183254: 08060cad j 0x001832b4                              >>Jump to  END return 0x03
00183258: 34020003 ori r2,r0,0x0003                              |
                                                        Else : CT no null
0018325c: a204006c sb r4,0x006c(r16)                         |Update death sentence CT
00183260: 92020058 lbu r2,0x0058(r16)                |load current status 1
00183264: 00000000 nop                               |
00183268: 30420002 andi r2,r2,0x0002                 |
0018326c: 10400004 beq r2,r0,0x00183280              #If Unit is defending
00183270: 34020002 ori r2,r0,0x0002                      |
00183274: a2220020 sb r2,0x0020(r17)                     |store attack status removal: defend
00183278: 34020008 ori r2,r0,0x0008                      |
0018327c: a2220025 sb r2,0x0025(r17)                     |store attack type : status change
00183280: 92020024 lbu r2,0x0024(r16)                |load unit's brave
00183284: 00000000 nop                               |
00183288: 2c42000a sltiu r2,r2,0x000a                |
0018328c: 10400005 beq r2,r0,0x001832a4              #If Brave < 10 (chicken brave increment)
00183290: 34030081 ori r3,r0,0x0081                      |
00183294: 92220025 lbu r2,0x0025(r17)                    |load attack type
00183298: a2230016 sb r3,0x0016(r17)                     |store brave change : bonus +1
0018329c: 34420001 ori r2,r2,0x0001                      |
001832a0: a2220025 sb r2,0x0025(r17)                     |store attack type : pseudo status
001832a4: 92220025 lbu r2,0x0025(r17)                |Load attack type
001832a8: 00000000 nop                               |
001832ac: 0002102b sltu r2,r0,r2                     |1 If Attack type is not null
001832b0: 00021040 sll r2,r2,0x01                    |Return 2 if here and attack type is not null Most of cases forces exit at 1832b4
001832b4: 8fbf0018 lw r31,0x0018(r29)
001832b8: 8fb10014 lw r17,0x0014(r29)
001832bc: 8fb00010 lw r16,0x0010(r29)
001832c0: 27bd0020 addiu r29,r29,0x0020
001832c4: 03e00008 jr r31
001832c8: 00000000 nop

Return locations

BATTLE.BIN
 00182b18: In_between_turn_control_routine