adt_ListCurr.asm
bitfixer_bitfixer/dg/z88dk/libsrc/adt/linkedlist/adt_ListCurr.asm
; void __FASTCALL__ *adt_ListCurr(struct adt_List *list)
; 02.2003, 06.2005 aralbrec

PUBLIC adt_ListCurr

.adt_ListCurr

; enter: hl = struct adt_List *
; exit : no carry = list empty or current points outside list, else:
;        hl = current item in list and carry set
; uses : af, hl

   ld a,(hl)
   inc hl
   or (hl)
   jr z, nothing             ; zero items in list
   
   inc hl
   ld a,(hl)
   dec a
   jr nz, nothing            ; current ptr not INLIST
   
   inc hl
   ld a,(hl)
   inc hl
   ld l,(hl)
   ld h,a                    ; hl = current adt_ListNode
   
   ld a,(hl)
   inc hl
   ld h,(hl)
   ld l,a                    ; hl = item
   
   scf
   ret

.nothing

   ld hl,0
   ret
