~z88dk-team/z88dk-pkg/trunk

« back to all changes in this revision

Viewing changes to libsrc/algorithm/AStarSearch/astar_DeletePath.asm

  • Committer: Bazaar Package Importer
  • Author(s): Luca Falavigna
  • Date: 2008-02-12 08:23:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080212082349-wgijt44scmgje90o
Tags: 1.7.ds1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - build z88dk and z88dk-bin binary packages for lpia too
  - update Maintainer field as per spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; void __FASTCALL__ astar_DeletePath(struct astar_path *p)
 
2
; delete the path by freeing any memory associated with it
 
3
; 01.2007 aralbrec
 
4
 
 
5
XLIB astar_DeletePath
 
6
XREF _u_free
 
7
 
 
8
; enter: hl = struct astar_path *
 
9
; uses : af, bc, de, hl
 
10
 
 
11
.astar_DeletePath
 
12
 
 
13
   ld a,h
 
14
   or l
 
15
   ret z
 
16
   
 
17
   ld e,l
 
18
   ld d,h
 
19
   
 
20
   inc hl
 
21
   inc hl
 
22
   ld a,(hl)                 ; is ref count == 0?
 
23
   or a
 
24
   ret nz                    ; if not, no more freeing
 
25
 
 
26
.loop
 
27
 
 
28
   ; de = & struct astar_path
 
29
   ; hl = & struct astar_path.ref_count
 
30
 
 
31
   inc hl
 
32
   ld a,(hl)
 
33
   inc hl
 
34
   ld h,(hl)
 
35
   ld l,a                    ; hl = & next struct astar_path
 
36
   
 
37
   push hl
 
38
   ex de,hl
 
39
   push hl
 
40
   call _u_free
 
41
   pop hl
 
42
   pop hl
 
43
   
 
44
   ld a,h
 
45
   or l
 
46
   ret z                     ; no more paths!
 
47
   
 
48
   ld e,l
 
49
   ld d,h
 
50
   
 
51
   inc hl
 
52
   inc hl
 
53
   dec (hl)                  ; ref count--
 
54
   jp z, loop                ; if zero, delete it
 
55
   
 
56
   ret