include	clib.inc
include	fblk.inc
include	wsub.inc

PPROC	fbffirst, fcb:dword, count:word
	xor	dx,dx
	jmp	fbffirst_init
    fbffirst_loop:
	les	bx,fcb
	mov	ax,dx
	shl	ax,2
	add	bx,ax
	mov	ax,es:[bx+2]
	mov	bx,es:[bx]
	mov	es,ax
	mov	cx,es:[bx]
	test	cx,_A_SELECTED
	jz	fbffirst_next
	mov	dx,ax
	mov	ax,bx
	add	ax,fb_name
	jmp	fbffirst_end
    fbffirst_next:
	inc	dx
    fbffirst_init:
	cmp	count,dx
	jg	fbffirst_loop
	xor	ax,ax
	cwd
    fbffirst_end:
	ret
PEND	fbffirst

PPROC	wsffirst, wsub:dword
	les	bx,wsub
	invoke	fbffirst, es:[bx.ws_fcb], es:[bx.ws_count]
	ret
PEND	wsffirst

	END
