      .include #system
      
;;; This belongs to the OS package
;;;     .include #os
;;; for the setup macros

; --------------------------------------------------------------
; Find handler HATABS entry or first 
; free slot: 
;
; Needs:
;  device ID in A
; Returns:
;  Y contains index
;  A device ID
; Return codes:
;  C clr (BCC), Z set (BEQ) : empty slot found
;  C set (BCS), Z set (BEQ) : driver found
;  C set (BCS), Z clr (BNE) : HATABS full
;
; BUG: if there are duplicate handlers this will return
;      the outdated one
; --------------------------------------------------------------
fhatabs ldy #0
:linst cmp  hatabs,y
      beq   :done
      clc
      ldx   hatabs,y
      beq   :done
      iny 
      iny 
      iny 
      cpy   #34               ; not 36 we don't want EQ
      bcc   :linst
:done rts 

 

