home *** CD-ROM | disk | FTP | other *** search
- ideal
- locals @@
-
- model Large
-
- codeseg
-
- OldInt08 dd 0
- RetraceCount db 0
-
- TimerSpeed equ 16572 ; 1,193,182 div 70 (I think)
-
- proc MyTimer
-
- ;Call the old timer interrupt routine here...
-
- push ax dx ds
- inc [Byte cs:RetraceCount]
-
- ;The timer is not 100% accurate, adjust with vertical retrace again
- ;Wait for vertical retrace
-
- mov dx,03DAh ;DX = CRTC Status Port
- @@1:
- in al,dx ;Read the port
- and al,8 ;Is a vertical retrace active?
- jz short @@1
-
- ;Reset the timer
- mov al,34h
- out 43h,al
- ;Write the new speed
- mov ax,TimerSpeed
- out 40h,al
- mov al,ah
- out 40h,al
-
- ;Signal EOI (end-of-interrupt)
- mov al,20h ;AL = 20h (EOI)
- out 20h,al ;Signal EOI to enable next
- ; interrupt
-
- pop ds dx ax
- iret
- endp MyTimer
-
- ; Enable the vertical retrace timer interrupt
-
- proc Enable_Timer
- cli
- xor ax,ax
- mov es,ax ;ES points to the first segment
- mov ax,[es:8*4]
- mov [Word cs:OldInt08],ax
- mov ax,[es:8*4+2]
- mov [Word cs:OldInt08+2],ax
- mov [Word es:8*4],offset MyTimer
- mov [Word es:8*4+2],cs
-
- ;Wait for the beginning of vertical retrace
- ;Wait for no vertical retrace
- @@1: mov dx,03DAh ;DX = CRTC Status Port
- in al,dx ;Read the port
- and al,8 ;Is a vertical retrace
- jnz @@1
-
- ;Wait for vertical retrace
- @@2:
- in al,dx ;Read the port
- and al,8 ;Is a vertical retrace
- jz Short @@2
-
- ;Set the new timer speed
- mov al,34h ;AL = 34h
- out 43h,al ;Write AL to port 43h
-
- ;Write the new speed
- mov ax,TimerSpeed
- out 40h,al
- mov al,ah
- out 40h,al
-
- sti ;Enable interrupts
- ret
- endp Enable_Timer
-
- proc Disable_Timer
- cli ;Disable interrupts
- xor ax,ax
- mov es,ax ;ES points to the first segment
- ; (interrupt vector table)
- mov ax,[Word cs:OldInt08]
- mov [Word es:8*4],ax
- mov ax,[Word cs:OldInt08+2]
- mov [Word es:8*4+2],ax
-
- ;Reset the timer speed
- mov al,34h
- out 43h,al ;Write AL to port 43h
-
- ;Write the original speed
- xor al,al ;Write 0 to port 40h
- out 40h,al
- out 40h,al
-
- sti
- ret
- endp Disable_Timer
-
- end
-
-