2 Copyright (C) 1998 BJ Eirich (aka vecna)
\r
3 This program is free software; you can redistribute it and/or
\r
4 modify it under the terms of the GNU General Public License
\r
5 as published by the Free Software Foundation; either version 2
\r
6 of the License, or (at your option) any later version.
\r
7 This program is distributed in the hope that it will be useful,
\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
\r
10 See the GNU General Public Lic
\r
11 See the GNU General Public License for more details.
\r
12 You should have received a copy of the GNU General Public License
\r
13 along with this program; if not, write to the Free Software
\r
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
28 #define PITMODE 0x43
\r
29 #define PITCONST 1193180L
\r
37 // ================================= Data ====================================
\r
39 void (__interrupt __far *biosTimerHandler)();
\r
40 char timerinstalled=0;
\r
41 extern char soundokay;
\r
43 volatile unsigned int systemtime=0, timer_count=0, tick=0;
\r
44 volatile int backupct=0, idlect=0;
\r
46 // ================================= Code ====================================
\r
48 #pragma aux disable =\
\r
51 #pragma aux enable =\
\r
54 static void SendEOI (unsigned char irqno)
\r
56 static unsigned char ocr;
\r
57 static unsigned char eoi;
\r
59 ocr=(irqno>7) ? OCR2 : OCR1;
\r
62 if (irqno>7) outp(OCR1,0x20);
\r
65 void __interrupt __far newhandler(void)
\r
72 CheckTileAnimation();
\r
73 if (soundokay) MD_Update();
\r
77 void SetHZ(unsigned int hz)
\r
78 { unsigned int pit0_set, pit0_value;
\r
82 outp(PITMODE, 0x34);
\r
83 pit0_value=PITCONST / hz;
\r
84 pit0_set=(pit0_value & 0x00ff);
\r
85 outp(PIT0, pit0_set);
\r
86 pit0_set=(pit0_value >> 8);
\r
87 outp(PIT0, pit0_set);
\r
95 outp(PITMODE, 0x34);
\r
103 if (timerinstalled) return;
\r
105 biosTimerHandler=_dos_getvect(0x08);
\r
106 _dos_setvect(0x08, newhandler);
\r
111 void ShutdownTimer()
\r
113 if (!timerinstalled) return;
\r
115 _dos_setvect(0x08, biosTimerHandler);
\r