home *** CD-ROM | disk | FTP | other *** search
/ PC Underground / UNDERGROUND.ISO / graphic / wobbler.asm < prev    next >
Assembly Source File  |  1995-07-28  |  2KB  |  65 lines

  1. extrn WaitRetrace:far
  2.  
  3. data segment public
  4.   extrn sine:dataptr           ;sine table
  5. data ends
  6.  
  7.  
  8. code segment public
  9. assume cs:code,ds:data
  10.  
  11. public make_wob
  12. make_wob proc pascal wob_pos,wob_height,wob_offset:word
  13.   xor cx,cx                     ;row counter to 0
  14.   call waitretrace              ;synchronization with cathode ray
  15.  
  16. next_line:
  17.   inc cx                        ;increment row counter
  18.  
  19.   mov bx,cx                     ;define position within the wobbler
  20.   sub bx,wob_pos
  21.   mov si,bx                     ;note for end
  22.  
  23.   add bx,wob_offset             ;offset for movement
  24.   and bx,63                     ;allow only values from 0..63 (array size)
  25.   shl bx,1                      ;array access to words
  26.   mov bx,sine[bx]              ;get value in bx
  27.  
  28.   cli                           ;clear interrupts, because it's VERY time critical
  29.   mov dx,3dah                   ;select input status register 1
  30.  
  31. in_display:
  32.   in al,dx                      ;wait for (horizontal) retrace
  33.   test al,1
  34.   je in_display
  35. in_retrace:
  36.   in al,dx                      ;wait for display
  37.   test al,1
  38.   jne in_retrace
  39.  
  40.   cmp cx,wob_pos                ;reached desired line ?
  41.   jb next_line                  ;no -> set default value
  42.  
  43.   mov dx,3d4h                   ;CRTC register 4 (horizontal sync start)
  44.   mov al,4                      ;select
  45.   mov ah,bl                     ;get sine value
  46.   out dx,ax                     ;and enter
  47.  
  48.   cmp si,wob_height              ;end reached ?
  49.   jb next_line
  50.  
  51.   mov dx,3dah
  52. wait1:
  53.   in al,dx                      ;wait for (horizontal) retrace
  54.   test al,1
  55.   jne wait1
  56.   mov dx,3d4h                   ;set sync start back to normal
  57.   mov ax,5504h
  58.   out dx,ax
  59.   sti                           ;allow interrupts again
  60.   ret
  61. make_wob endp
  62.  
  63. code ends
  64. end
  65.