From 59f0507e4cd0693eb89f5ab3e44cb3c442666140 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Fri, 8 Aug 2014 22:39:13 -0700 Subject: Labelled many functions/variables --- engine/experience.asm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'engine/experience.asm') 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 -- cgit v1.2.3