
015/018 01 Aug 90 11:57:00
From:   Mark Johnston
To:     Darryl Gregorash
Subj:   Re: Game ports and timers
Attr:   
------------------------------------------------
 [ ... continued from previous message ]

     Here's  some  code  I  have  used to reprogram the
timer to tick faster for my own purpose (in  this  case
to increment  a  tick flag and an elapsed second flag).
The values I used cause the timer to tick approximately
200 times per second vs. the origianl 18.2.   This  was
originally  written  for MASM and intended to integrate
with a C program.

----------- cut here ------------
off            equ         0h
on             equ         0ffffh
;
.MODEL         COMPACT
.CODE
;local data
tick           db          0
tock           db          200
secflag        dw          0
go_8_switch    dw          off
tickcount      dw          0
org_int8_addr  dd          ?
;
new_int8       proc        far
new_int8_entry:
               cmp         cs:go_8_switch, on    ;inhibit new interrupt code
               jne         bypass1               ;if not enabled or if it
               mov         cs:go_8_switch, off   ;attempts to interrupt itself
               sti
               inc         cs:tickcount
               push        ax
               xor         ah, ah
               mov         al, cs:tock
               dec         al
               jnz         not_a_sec
               inc         cs:secflag
               mov         ax, 200
not_a_sec:
               mov         cs:tock, al
               xor         ah, ah
               mov         al, cs:tick
               inc         al
               cmp         ax, 11        ;we want the old interrupt handler
               jb          no_org_int_8  ;to be activated only every 11 ticks
               sub         ax, 11
               mov         cs:tick, al
               pop         ax
               cli
               mov         cs:go_8_switch, on
bypass1:
               jmp         cs:org_int8_addr
no_org_int_8:
               mov         cs:tick, al
               mov         al, 20h
               out         20h, al ;must (!) send EOI to interrupt controller
                                   ;if not executing original timer interrupt
               pop         ax
               cli
               mov         cs:go_8_switch, on
               iret
new_int8       endp
;
----------- cut here ------------

 [ to be continued ... ]


--- Qtach2 v1.02 U4
 * Origin: =# The QNX Telegraph #=  Tacoma WA  (206)535-6109 (1:138/110)

