ref: 570d83b73c770547e15a9c63d35588b09cc23f1f
dir: /home/pathfinding.asm/
; 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 -1 ; 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