Metropoli BBS
VIEWER: trig.asm MODE: TEXT (ASCII)
include qlib.inc
include math.inc
include string.inc
include video.inc
include conio.inc
include stdlib.inc
include stdio.inc

.data
  start dw 0
  cnt dw ?
  x dw ?
  y dw ?
  v dd ?
  d REAL8 ?
  vid dd 0a0000h
  m_pi REAL8 3.141592654
  _2 dd 2
  _180 dd 180
  _80 dd 80
  result dd ?
  vidtmp dd ?

.code

show proc,a:byte
  .if start
    mov ax,start
    mov x,ax
  .else
    mov x,0
  .endif
  mov cnt,0
@@:
  fild _2
  fild x
  fmulp st(1),st
  fild _180
  fdivp st(1),st
  fld m_pi
  fmulp st(1),st
  fstp d
  wait
  .if a==0
    callp sin,d
  .elseif a==1
    callp cos,d
  .elseif a==2
    callp tan,d
  .endif
  .if _math_typ
    mov dptr[d],eax    ;Watcom
    mov dptr[d+4],edx
  .else
    fstp d             ;Borland
    fwait
  .endif
  fld d
  fild _80
  fmulp st(1),st
  fistp result
  wait
  mov eax,result
  add eax,100
  .if eax<200
    imul eax,320
    xor ebx,ebx
    mov bx,x
    sub bx,start
    add eax,ebx
    add eax,vidtmp
    mov bptr[eax],31
  .endif
  inc x
  inc cnt
  .if cnt<180
    jmp @b
  .endif
  call g_copy
  ret
show endp

clrit proc
  mov edi,vidtmp
  mov ecx,320*200/4
  mov eax,0
  rep stosd
  callp g_hline,0,100,180,1
  callp g_vline,45,90,110,1
  callp g_vline,90,80,120,1
  callp g_vline,135,90,110,1
  callp g_vline,0,50,150,1
  ret
clrit endp

main proc

  .if !_fpu
    callp printf,"No 80387 detected!\n"
    callp exit,0
  .endif

  callp g_loadfnt,"8bit.fnt"
  .if eax==ERROR
    callp printf,"Unable to load font"
    callp exit,0
  .endif
  callp malloc,320*200
  .if eax==NULL
    callp printf,"no ram"
    callp exit,0
  .endif
  mov vidtmp,eax
  callp g_setbuf,eax
  mov edi,vidtmp
  mov ecx,320*200/4
  mov eax,0
  rep stosd

  callp g_getmode,320,200,8
  .if eax==ERROR
    callp printf,"no VGA?"
    callp exit,0
  .endif
  callp g_setmode
  call clrit
  callp g_printxy,0,0,"Trig: sin()"
  callp show,0
@@:
  call getch
  cmp al,0
  jz @b
  callp clrit
  callp g_printxy,0,0,"Trig: cos()"
  callp show,1
@@:
  call getch
  cmp al,0
  jz @b
  callp clrit
  callp g_printxy,0,0,"Trig: tan()"
  callp show,2
@@:
  call getch
  cmp al,0
  jz @b

@@:
  callp clrit
  callp g_printxy,0,0,"Trig: coolness ;)"
  callp show,0
  inc start
  .if start>180
    mov start,0
  .endif
  call kbhit
  cmp al,0
  jz @b
  call getch

  callp t_setmode,80,25
  ret
main endp

end


[ RETURN TO DIRECTORY ]