diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-07-07 18:50:58 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-07-07 19:43:11 -0400 |
commit | bbf2f51a02b2544f1bef32a5868503b474ae2fef (patch) | |
tree | d73507228a57e4f3cece2fb93fe7df3a9439553f /home/pathfinding.asm | |
parent | 51ac538c25f8c0a6d88101569a17f02d09855d31 (diff) |
Move all code out of home.asm into home/
This results in 64 home/*.asm files, comparable to pokecrystal's 57.
Diffstat (limited to 'home/pathfinding.asm')
-rw-r--r-- | home/pathfinding.asm | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/home/pathfinding.asm b/home/pathfinding.asm new file mode 100644 index 00000000..aca5a763 --- /dev/null +++ b/home/pathfinding.asm @@ -0,0 +1,65 @@ +; calculates the difference |a-b|, setting carry flag if a<b +CalcDifference:: + sub b + ret nc + cpl + add $1 + scf + ret + +MoveSprite:: +; move the sprite [hSpriteIndex] with the movement pointed to by de +; actually only copies the movement data to wNPCMovementDirections for later + call SetSpriteMovementBytesToFF +MoveSprite_:: + push hl + push bc + call GetSpriteMovementByte1Pointer + xor a + ld [hl], a + ld hl, wNPCMovementDirections + ld c, 0 + +.loop + ld a, [de] + ld [hli], a + inc de + inc c + cp $FF ; have we reached the end of the movement data? + jr nz, .loop + + ld a, c + ld [wNPCNumScriptedSteps], a ; number of steps taken + + pop bc + ld hl, wd730 + set 0, [hl] + pop hl + xor a + ld [wOverrideSimulatedJoypadStatesMask], a + ld [wSimulatedJoypadStatesEnd], a + dec a + ld [wJoyIgnore], a + ld [wWastedByteCD3A], a + ret + +; divides [hDividend2] by [hDivisor2] and stores the quotient in [hQuotient2] +DivideBytes:: + push hl + ld hl, hQuotient2 + xor a + ld [hld], a + ld a, [hld] + and a + jr z, .done + ld a, [hli] +.loop + sub [hl] + jr c, .done + inc hl + inc [hl] + dec hl + jr .loop +.done + pop hl + ret |