Death sentence, crystalization, treasurization, etc
Jump to navigation
Jump to search
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