Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Note: this is for Red Star's side of things. White Moon's uses similar enough values.
- 0C:4A26 FAD7DB ld a,[$DBD7]
- 0C:4A29 47 ld b,a - B carries Level byte
- 0C:4A2A FAD8DB ld a,[$DBD8]
- 0C:4A2D 4F ld c,a - C carries Flank byte
- 0C:4A2E FAD9DB ld a,[$DBD9] - A carries Support byte
- 0C:4A31 CDA249 call $49A2 - H is the truncation of the multiplier, L is the float point (percent being value multiplied by 64/25)
- 0C:4A34 54 ld d,h
- 0C:4A35 5D ld e,l - D is the truncation of the multiplier, E is the float point (percent being value multiplied by 64/25)
- 0C:4A36 FAD4DB ld a,[$DBD4]
- 0C:4A39 47 ld b,a - B carries ATK byte
- 0C:4A3A FAD3DB ld a,[$DBD3] - A carries HP byte
- 0C:4A3D CDFC49 call $49FC - Total ATK = ATK * HP * (100 + ATK boosts) / 100; Float error causes slightly lower values on any number not a multiple of 25
- 0C:4A40 7D ld a,l
- 0C:4A41 EADADB ld [$DBDA],a
- 0C:4A44 7C ld a,h
- 0C:4A45 EADBDB ld [$DBDB],a - $DBDA (2 bytes) carries Total ATK
- 0C:4A48 E5 push hl
- 0C:4A49 216400 ld hl,$0064
- 0C:4A4C FAECDB ld a,[$DBEC]
- 0C:4A4F 47 ld b,a - B carries opponent's Level byte
- 0C:4A50 FAEDDB ld a,[$DBED]
- 0C:4A53 4F ld c,a - C carries opponent's Flank byte
- 0C:4A54 FAEBDB ld a,[$DBEB] - A carries opponent's Cover byte
- 0C:4A57 CDCC49 call $49CC - H is the truncation of the multiplier, L is the float point (percent being value multiplied by 64/25). All 3 multiplier change bytes have half effect, if you're wondering.
- 0C:4A5A 54 ld d,h
- 0C:4A5B 5D ld e,l - D is the truncation of the multiplier, E is the float point (percent being value multiplied by 64/25)
- 0C:4A5C FAEADB ld a,[$DBEA]
- 0C:4A5F 47 ld b,a - B carries opponent's DEF byte
- 0C:4A60 FAE8DB ld a,[$DBE8] - A carries opponent's HP byte
- 0C:4A63 CD214A call $4A21 - for opponent, Total DEF = DEF * 2 * HP * (100 + DEF boosts / 2) / 100; Float error causes slightly lower values on any number not a multiple of 25
- 0C:4A66 7D ld a,l
- 0C:4A67 EAF1DB ld [$DBF1],a
- 0C:4A6A 7C ld a,h
- 0C:4A6B EAF2DB ld [$DBF2],a - $DBF2 (2 bytes) carries opponent's Total DEF
- 0C:4A6E D1 pop de - if you're confused, at this point, the Total ATK would be at the very top of the stack from the Push HL instruction, so DE would be holding the Total ATK value now
- 0C:4A6F CDC329 call $29C3 - HL = Total DEF - Total ATK
- 0C:4A72 3822 jr c,$30A96 - if HL is now negative, this basically sets A to 0 and ends the whole thing. The opponent's unit will be destroyed as a result.
- 0C:4A74 54 ld d,h
- 0C:4A75 5D ld e,l
- 0C:4A76 FAEADB ld a,[$DBEA]
- 0C:4A79 07 rlca
- 0C:4A7A 4F ld c,a - C is double the opponent's DEF byte
- 0C:4A7B 0600 ld b,$00
- 0C:4A7D CD212A call $2A21 - DE = (Total DEF - Total ATK) / (DEF*2); BC holds remainder
- 0C:4A80 78 ld a,b
- 0C:4A81 B1 or c
- 0C:4A82 2801 jr z,$30A85
- 0C:4A84 13 inc de - if remainder != 0, increase DE by 1
- 0C:4A85 7A ld a,d
- 0C:4A86 A7 and a
- 0C:4A87 2008 jr nz,$30A91 - yeah, why should DE even approach 255?
- 0C:4A89 FAE8DB ld a,[$DBE8]
- 0C:4A8C 57 ld d,a - D carries opponent's HP value
- 0C:4A8D 7B ld a,e - A carries expected new HP value
- 0C:4A8E BA cp d
- 0C:4A8F 3806 jr c,$30A97 - if the expected new HP value is lower, this procedure will be ended
- 0C:4A91 FAE8DB ld a,[$DBE8] - forces HP to remain unchanged if the new value were to exceed the old one
- 0C:4A94 1801 jr $30A97 - ends
- 0C:4A96 AF xor a
- 0C:4A97 C9 ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement