?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1.  ifndef included_xatan
  2.  define included_xatan
  3.  include "../common/pushpop.asm"
  4.  include "constantsx.asm"
  5.  include "xmul.asm"
  6.  include "xadd.asm"
  7.  include "xsqrt.asm"
  8.  include "xbg.asm"
  9.  
  10. ;x/BG(1,sqrt(1+x^2))
  11. var_x=xOP1+152 ;FIXME
  12. xatan:
  13.   call pushpop
  14.   push bc
  15.   ld de,var_x
  16.   call mov10
  17.  
  18.   ld de,(var_x+8)
  19.   ld a,d
  20.   and $7F
  21.   or e
  22.   jr z,xatan_special
  23.  
  24. ; ;If x>=1.0, calculate as pi/2-atan(1/x)
  25.   ld hl,var_x
  26. ;   ld a,(var_x+9)
  27. ;   and $7F
  28. ;   cp $40
  29. ;   jr c,+_
  30. ;   ld b,h
  31. ;   ld c,l
  32. ;   call xinv
  33. ;   call +_+1
  34. ;   pop bc
  35. ;   ld de,xconst_pi_div_2
  36. ;   jp xrsub
  37. ; _:
  38. ;   .db $FE
  39. ;   push bc
  40.   ld d,h
  41.   ld e,l
  42.   ld bc,xOP2
  43.   call xmul
  44.   ld h,b
  45.   ld l,c
  46.   ld de,xconst_1
  47.   call xadd
  48.   call xsqrt
  49.   ex de,hl
  50.   call xbg
  51.   ld hl,var_x
  52.   pop bc
  53.   jp xmul
  54. xatan_special:
  55.   ld hl,var_x
  56.   ld a,(var_x+7)
  57.   and $C0
  58.   jr z,xatan_return
  59.   jp p,xatan_return
  60.   ld hl,xconst_pi_div_2
  61. xatan_return:
  62.   sla d
  63.   pop de
  64.   call mov9
  65.   ld a,(hl)
  66.   rla
  67.   rrca
  68.   ld (de),a
  69.   ret
  70.  
  71.  endif
  72.