diff options
author | yenatch <yenatch@gmail.com> | 2014-09-20 00:57:27 -0400 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2014-09-20 00:57:27 -0400 |
commit | dff0cdeb5a2f901dc8d1a05847d09d7faf1654ad (patch) | |
tree | 3618582f76f4183b6bc22c5d4743b6d171d11128 /engine/experience.asm | |
parent | 1185d69819af3493fe8ace9f576fee4b420db55e (diff) | |
parent | 2ed65d9c3e3ba60939ebe2928ffddc06a90b1876 (diff) |
Merge remote-tracking branch 'YamaArashi/master'
Conflicts:
constants/misc_constants.asm
engine/battle/core.asm
engine/menu/pokedex.asm
engine/town_map.asm
home.asm
hram.asm
Diffstat (limited to 'engine/experience.asm')
-rwxr-xr-x | engine/experience.asm | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/engine/experience.asm b/engine/experience.asm index 07726821..91f1dd5d 100755 --- a/engine/experience.asm +++ b/engine/experience.asm @@ -1,28 +1,30 @@ -Func_58f43: ; 58f43 (16:4f43) +; calculates the level a mon should be based on its current exp +CalcLevelFromExperience: ; 58f43 (16:4f43) ld a, [wcf98] ld [wd0b5], a call GetMonHeader - ld d, $1 -.asm_58f4e - inc d + ld d, $1 ; init level to 1 +.loop + inc d ; increment level call CalcExperience push hl - ld hl, wcfa8 - ld a, [$ff98] + ld hl, wcfa8 ; current exp +; compare exp needed for level d with current exp + ld a, [H_MULTIPLICAND + 2] ld c, a ld a, [hld] sub c - ld a, [$ff97] + ld a, [H_MULTIPLICAND + 1] ld c, a ld a, [hld] sbc c - ld a, [H_NUMTOPRINT] ; $ff96 (aliases: H_MULTIPLICAND) + ld a, [H_MULTIPLICAND] ld c, a ld a, [hl] sbc c pop hl - jr nc, .asm_58f4e - dec d + jr nc, .loop ; if exp needed for level d is not greater than exp, try the next level + dec d ; since the exp was too high on the last loop iteration, go back to the previous value and return ret ; calculates the amount of experience needed for level d |