home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / screen / getfrq / getfreq.das next >
Text File  |  1993-11-12  |  4KB  |  163 lines

  1. `-----------------------------------------------------------------------------
  2. `                     GET VIDEO VERTICAL RETRACE FREQUENCY
  3. `
  4. `This program gives the vertical frequency of the video display. The value
  5. ` differ from the current video mode.
  6. `
  7. `Written in DASH 1.0
  8. `Sebastien Demers  November 10, 1993
  9. `
  10.  
  11.         include extfunc.dh
  12.         objinclude system.lib
  13.  
  14.         word TimeCnt
  15.         dword OldInt8
  16.         byte SOption
  17.  
  18.  
  19. `-----------------------------------------------------------------------------
  20. `              Wait for vertical retrace (at bit set 1) (normal)
  21. `
  22. void waitfor1()
  23. a1:     mov     dx,3dah
  24.         jmp     far a2                  `wait a little
  25. a2:     in      al,dx
  26.         test    al,1000b
  27.         jz      a1
  28.         .
  29.  
  30. `-----------------------------------------------------------------------------
  31. `                Wait for vertical retrace (at bit set 0 )
  32.  
  33. void waitfor0()
  34. a1:     mov     dx,3dah
  35.         jmp     far a2                  `wait a little
  36. a2:     in      al,dx
  37.         test    al,1000b
  38.         jnz     a1
  39.         .
  40.  
  41. `-----------------------------------------------------------------------------
  42. `                          New interrupt 8 routine
  43.  
  44. void NewInt8()
  45.         push    ax
  46.         push    ds
  47.         mov     ax,seg _data
  48.         mov     ds,ax
  49.         inc     TimeCnt
  50.         pushf
  51.         call    OldInt8
  52.         pop     ds
  53.         pop     ax
  54.         iret
  55.         .
  56.  
  57. `-----------------------------------------------------------------------------
  58. `            CLEAR_SCREEN
  59. `
  60. `Clear the all 128k buffer without changing the video mode
  61. `
  62. void clear_screen()
  63.         cmp     SOption,0               `Do not clear the screen option?
  64.         jnz     ne                      `yes
  65.         es= 0a000h; di= 0
  66.     mov    cx,8192
  67. a1:    push    cx
  68.     mov    cx,16/2
  69.     ax=0
  70.     rep stosw
  71.     pop    cx
  72.     es=es+1; di=0
  73.     loop    a1
  74. ne:
  75.     .
  76.  
  77. `----------------------------------------------------------------------------
  78. `                RESTORE SCREEN
  79. `
  80. void restore_screen()
  81.         cmp     SOption,0
  82.         jnz     ne
  83.     mov    ax,3
  84.     int    10h
  85. ne:
  86.     .
  87.  
  88. `-----------------------------------------------------------------------------
  89. `                              Read command line
  90.  
  91. byte ReadCL()
  92.         ds= _PspAdrs
  93.         si= 81h
  94.  
  95. a1:     lodsb
  96.         cmp     al,13
  97.         je      ne
  98.         cmp     al,'/'
  99.         jne     a1
  100.  
  101.         lodsb
  102.         cmp     al,'?'
  103.         je      a2                      `help command
  104.         and     al,223
  105.         cmp     al,'D'
  106.         je      a3
  107.         jmp     a1
  108.  
  109. a2:     Printf "GET VIDEO FREQUENCY  Copyright (c) 1993 by Sebastien Demers\e"\\
  110.                " Option: \e"\\
  111.                "         /D             Do not clear the screen while testing\e\e" \\
  112.                " Run only on COLOR displays and may not run in windows 386 enhanced mode\e"
  113.  
  114.  
  115.         ds=ss
  116.         return  1
  117.  
  118. a3:     ss:SOption=1
  119.         jmp     a1
  120.  
  121. ne:     ds=ss
  122.         return  0
  123.         .
  124.  
  125. `------------------------------------------------------------------------------
  126. `                                   MAIN
  127.  
  128. begin
  129.         word counter
  130.         byte flag
  131.         ReadCL()
  132.         or      al,al
  133.         jnz     terminate
  134.  
  135.         clear_screen()
  136.         OldInt8= GetIntVec( 8 )
  137.         mov     dwtemp[\word 0], offset #glb NewInt8
  138.         mov     dwtemp[\word 2], cs
  139.         SetIntVec( 8, dwtemp )
  140.         SetTimer( 4, 1193280/20 )               `stop the timer
  141.         Waitfor0()
  142.         Waitfor1()
  143.         SetTimer( 3, 1193280/20 )               `start it at frequency of 20Hz
  144.         TimeCnt=0
  145.         Counter=0
  146.  
  147. a1:     cmp     TimeCnt, 20
  148.         jae     aend
  149.         inc     Counter
  150.         Waitfor0()
  151.         Waitfor1()
  152.         jmp     a1
  153.  
  154. aend:   SetTimer( 3, 0 )                        `18.2 normal
  155.         SetIntVec( 8, OldInt8 )
  156.         Restore_screen()
  157.         printf "Video vertical frequency: %u Hz", Counter
  158. terminate:
  159.  
  160. end
  161.  
  162.  
  163.