diff options
author | Rangi <35663410+Rangi42@users.noreply.github.com> | 2018-08-25 22:23:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-25 22:23:45 -0400 |
commit | 3eacab563d0e1ab5557c2443556a7a5e58d14cad (patch) | |
tree | 3d747166409fdc94f0fd1aa760693a7ee5bd2156 /engine/pokemon/experience.asm | |
parent | 89681d231611938a791f4256e602c88c2f9aa3e1 (diff) | |
parent | b2adcd6d6ff91efc764a6ecc65147be7b9cda9e8 (diff) |
Merge pull request #555 from Rangi42/ldh
Use real labels for HRAM instead of constants, and the ldh instruction
Diffstat (limited to 'engine/pokemon/experience.asm')
-rw-r--r-- | engine/pokemon/experience.asm | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/engine/pokemon/experience.asm b/engine/pokemon/experience.asm index 3c3b10439..1dae3bb61 100644 --- a/engine/pokemon/experience.asm +++ b/engine/pokemon/experience.asm @@ -11,15 +11,15 @@ CalcLevel: call CalcExpAtLevel push hl ld hl, wTempMonExp + 2 - ld a, [hProduct + 3] + ldh a, [hProduct + 3] ld c, a ld a, [hld] sub c - ld a, [hProduct + 2] + ldh a, [hProduct + 2] ld c, a ld a, [hld] sbc c - ld a, [hProduct + 1] + ldh a, [hProduct + 1] ld c, a ld a, [hl] sbc c @@ -42,121 +42,121 @@ CalcExpAtLevel: ; Cube the level call .LevelSquared ld a, d - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; Multiply by a ld a, [hl] and $f0 swap a - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; Divide by b ld a, [hli] and $f - ld [hDivisor], a + ldh [hDivisor], a ld b, 4 call Divide ; Push the cubic term to the stack - ld a, [hQuotient + 0] + ldh a, [hQuotient + 0] push af - ld a, [hQuotient + 1] + ldh a, [hQuotient + 1] push af - ld a, [hQuotient + 2] + ldh a, [hQuotient + 2] push af ; Square the level and multiply by the lower 7 bits of c call .LevelSquared ld a, [hl] and $7f - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; Push the absolute value of the quadratic term to the stack - ld a, [hProduct + 1] + ldh a, [hProduct + 1] push af - ld a, [hProduct + 2] + ldh a, [hProduct + 2] push af - ld a, [hProduct + 3] + ldh a, [hProduct + 3] push af ld a, [hli] push af ; Multiply the level by d xor a - ld [hMultiplicand + 0], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 0], a + ldh [hMultiplicand + 1], a ld a, d - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld a, [hli] - ld [hMultiplier], a + ldh [hMultiplier], a call Multiply ; Subtract e ld b, [hl] - ld a, [hProduct + 3] + ldh a, [hProduct + 3] sub b - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a ld b, $0 - ld a, [hProduct + 2] + ldh a, [hProduct + 2] sbc b - ld [hMultiplicand + 1], a - ld a, [hProduct + 1] + ldh [hMultiplicand + 1], a + ldh a, [hProduct + 1] sbc b - ld [hMultiplicand], a + ldh [hMultiplicand], a ; If bit 7 of c is set, c is negative; otherwise, it's positive pop af and $80 jr nz, .subtract ; Add c*n**2 to (d*n - e) pop bc - ld a, [hProduct + 3] + ldh a, [hProduct + 3] add b - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a pop bc - ld a, [hProduct + 2] + ldh a, [hProduct + 2] adc b - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a pop bc - ld a, [hProduct + 1] + ldh a, [hProduct + 1] adc b - ld [hMultiplicand], a + ldh [hMultiplicand], a jr .done_quadratic .subtract ; Subtract c*n**2 from (d*n - e) pop bc - ld a, [hProduct + 3] + ldh a, [hProduct + 3] sub b - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a pop bc - ld a, [hProduct + 2] + ldh a, [hProduct + 2] sbc b - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a pop bc - ld a, [hProduct + 1] + ldh a, [hProduct + 1] sbc b - ld [hMultiplicand], a + ldh [hMultiplicand], a .done_quadratic ; Add (a/b)*n**3 to (d*n - e +/- c*n**2) pop bc - ld a, [hProduct + 3] + ldh a, [hProduct + 3] add b - ld [hMultiplicand + 2], a + ldh [hMultiplicand + 2], a pop bc - ld a, [hProduct + 2] + ldh a, [hProduct + 2] adc b - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 1], a pop bc - ld a, [hProduct + 1] + ldh a, [hProduct + 1] adc b - ld [hMultiplicand], a + ldh [hMultiplicand], a ret .LevelSquared: xor a - ld [hMultiplicand + 0], a - ld [hMultiplicand + 1], a + ldh [hMultiplicand + 0], a + ldh [hMultiplicand + 1], a ld a, d - ld [hMultiplicand + 2], a - ld [hMultiplier], a + ldh [hMultiplicand + 2], a + ldh [hMultiplier], a jp Multiply INCLUDE "data/growth_rates.asm" |