mirror of
https://github.com/thornAvery/kep-hack.git
synced 2026-02-22 15:12:18 +13:00
Move all code out of home.asm into home/
This results in 64 home/*.asm files, comparable to pokecrystal's 57.
This commit is contained in:
parent
51ac538c25
commit
bbf2f51a02
35 changed files with 1754 additions and 1758 deletions
65
home/pathfinding.asm
Normal file
65
home/pathfinding.asm
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue