home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / asm_programming / LENZSCRL.ZIP / INTS.ASM < prev    next >
Assembly Source File  |  1993-10-06  |  4KB  |  171 lines

  1. ; Interrupt routines....
  2.  
  3.  
  4.                         .model small
  5.                         locals
  6.  
  7.                         extrn DemoInt:near
  8.                         extrn Sync:near
  9.  
  10.                         public SetInts,ClearInts,GetRasterLine
  11.                         public FrameNum
  12. .data
  13.                         align 2
  14.  
  15. FrameNum        dd 0
  16.  
  17. .code
  18. .386
  19.  
  20. frametimeb        dw ?
  21. frametime        dw ?
  22.  
  23. in_int            db 0
  24.  
  25. oldint8                 dd ?
  26.  
  27. INTER                   equ 8
  28.  
  29. intti8             proc far
  30.  
  31.                         push ax
  32.                         push ds
  33.  
  34.                         mov ax,seg FrameNum
  35.                         mov ds,ax
  36.  
  37.                         inc FrameNum
  38.  
  39.                         mov al,20h
  40.                         out 20h,al
  41.                         call Sync
  42.  
  43.                         mov al,36h
  44.                         out 43h,al
  45.                         mov al,byte ptr cs:frametimeb[0]
  46.                         out 40h,al
  47.                         mov al,byte ptr cs:frametimeb[1]
  48.                         out 40h,al
  49.  
  50.                         test cs:in_int,1
  51.                         jnz @@1
  52.  
  53.                         mov cs:in_int,1
  54.  
  55.                         sti
  56.                         call DemoInt
  57.                         mov cs:in_int,0
  58.                         cli
  59. @@1:
  60.                         pop ds
  61.                         pop ax
  62.                         iret
  63.  
  64. intti8             endp
  65.  
  66.  
  67.  
  68. SetInts         proc near
  69.  
  70.                         cli
  71.                         xor ax,ax
  72.                         mov es,ax
  73.                         mov ax,es:[INTER*4]
  74.                         mov word ptr cs:oldint8,ax
  75.                         mov ax,es:[INTER*4+2]
  76.                         mov word ptr cs:oldint8[2],ax
  77.                         mov ax,offset intti8
  78.                         mov es:[INTER*4],ax
  79.                         mov es:[INTER*4+2],cs
  80.                         sti
  81.  
  82.                         call Sync
  83.  
  84.                         mov al,36h
  85.                         out 43h,al
  86.                         mov al,0
  87.                         out 40h,al
  88.                         mov al,0
  89.                         out 40h,al
  90.  
  91.                         call Sync
  92.  
  93.                         xor al,al
  94.                         out 43h,al
  95.                         in al,40h
  96.                         mov ah,al
  97.                         in al,40h
  98.                         xchg al,ah
  99.                         neg ax
  100.                         shr ax,1
  101.                         mov cs:frametime,ax
  102.                         mov dx,ax
  103.                         mov al,ah
  104.                         xor ah,ah
  105.                         sub dx,ax
  106.                         shl dx,1
  107.                         mov cs:frametimeb,dx
  108.                         mov al,36h
  109.                         out 43h,al
  110.                         mov al,dl
  111.                         out 40h,al
  112.                         mov al,dh
  113.                         out 40h,al
  114.                         ret
  115.  
  116. SetInts         endp
  117.  
  118.  
  119. ClearInts         proc near
  120.  
  121.                         cli
  122.                         xor ax,ax
  123.                         mov es,ax
  124.                         mov ax,WORD PTR cs:oldint8
  125.                         mov dx,WORD PTR cs:oldint8[2]
  126.                         mov es:[INTER*4],ax
  127.                         mov es:[INTER*4+2],dx
  128.                         sti
  129.  
  130.                         mov al,36h
  131.                         out 43h,al
  132.                         mov al,0
  133.                         out 40h,al
  134.                         mov al,0
  135.                         out 40h,al
  136.                         ret
  137.  
  138. ClearInts         endp
  139.  
  140.  
  141. GetRasterLine           proc near
  142.  
  143.                         push dx
  144.                         push cx
  145.  
  146.                         cli
  147.                         xor al,al
  148.                         out 43h,al
  149.                         in al,40h
  150.                         mov dl,al
  151.                         in al,40h
  152.                         mov dh,al
  153.                         shr dx,1
  154.                         mov ax,cs:frametime
  155.                         sub ax,dx
  156.                         mov cx,400
  157.                         mul cx
  158.                         mov cx,cs:frametime
  159.                         div cx
  160.                         sti
  161.  
  162.                         pop cx
  163.                         pop dx
  164.  
  165.                         ret
  166.  
  167. GetRasterLine           endp
  168.  
  169.                         end
  170.  
  171.