pro show_hxafid,date0,overplot=overp,fill=fill,color=colo,map=out, $
                xrange=xr,yrange=yr

; plot/calculation range, derive from plot parms, or keyword, or...

if keyword_set(overp) then begin
   dx = 0 > long(!x.crange) < 1024
   dy = 0 > long(!y.crange) < 1024
endif else begin
   if n_elements(xr) eq 2 then dx = 0 > long(xr) < 1024 else begin
      dx = [0L,1024]
      xr = dx
   endelse
   if n_elements(yr) eq 2 then dy = 0 > long(yr) < 1024 else begin
      dy = [0L,1024]
      yr = dy
   endelse
endelse

if n_elements(colo) eq 0 then if keyword_set(fill) $
                    then colo=!d.n_colors/2+1 else colo=!d.n_colors

; derived:
nx = dx(1)-dx(0)
ny = dy(1)-dy(0)

; default to current date
if n_elements(date0) eq 0 then date0 = !stime
date = anytim2ints(date0)

; get the fiducial marks
forzones,x_add,y_add

; get the hxa apparent solar radius in x and y
hxa_parms,hpix=hpix,h_xx=h_xx,h_yy=h_yy,version=version
sunr = get_rb0p(date,/radius) / hpix
hdb_file = concat_dir('DIR_GEN_STATUS','hxa_dbase.genx')
restgen,hdb,file=hdb_file
hdbs = int2secarr(hdb,date)
sunx = sunr * interpol(hdb.hxa_fx,hdbs,0.0)*1e-4
suny = sunr * interpol(hdb.hxa_fy,hdbs,0.0)*1e-4
sunx = sunx(0)
suny = suny(0)

; determine mission correction (slow varying and small, could be neglected)
att_struct,att_summary=att
att.status2 = version
att.time = date.time
att.day = date.day
fix_old_att,att
cor = att.pnt(0:1)/100.0

; sxt coordinate array, with cor.:
xy = transpose([[reform((findgen(nx)+dx(0)-cor(0)) # (fltarr(ny)+1),nx*ny)], $
                [reform((fltarr(nx)+1) # (findgen(ny)+dy(0)-cor(1)),nx*ny)]])

; hxa coordinate array:
;xy = sxt2hxaxy(0,xy,/noo,/nom)      ; /noo,/nom -> 1st parm. (time) ignored
xy = sxt2hxaxy(replicate(date,nx*ny),xy,/noo)   ; proper way

; calc. rx,ry
rx = (sunx^2 - (xy(1,*)-h_yy)^2) > 0.0
rx = sqrt(rx)
ry = (suny^2 - (xy(0,*)-h_xx)^2) > 0.0
ry = sqrt(ry)

zon = x_add((xy(0,*)-rx)>0) or x_add((xy(0,*)+rx)<2047) or $
      y_add((xy(1,*)-ry)>0) or y_add((xy(1,*)+ry)<2047) or $
      rx eq 0.0 or ry eq 0.0

zon = reform(zon,nx,ny)

out = intarr(1024,1024)
out(dx(0),dy(0)) = zon

if keyword_set(overp) then begin
   contour,out*2,lev=1,/overplot,fill=fill,c_col=colo
endif else begin
   contour,out*2,lev=1,xsty=1,ysty=1,xran=xr,yran=yr,fill=fill,c_col=colo
endelse

return
end