-
Notifications
You must be signed in to change notification settings - Fork 0
/
gametime.c
executable file
·100 lines (100 loc) · 2.11 KB
/
gametime.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <DOS.H>
#include "SOURGAME/GAMEINFO.H"
#include "SOURGAME/GAMETIME.H"
#include "SOURGAME/GAMEGRAP.H"
#define OCTET unsigned char
void Accelerer_Horloge (short);
void Retablir_Horloge (void);
void interrupt far Routine_Timer_Interruption (void);
void (interrupt far *Ancienne_Interruption_Timer)(void);
short result;
short port = 0x3c4;
short commutateur_chrono = OFF;
short compteur_timer = 0;
short vitesse;
short nbrt;
void Top_Retrace (void)
{
nbrt = 0;
}
short Out_Retrace (void)
{
return (nbrt);
}
void interrupt far Routine_Timer_Interruption (void)
{
if (commutateur_chrono == ON)
{
nbrt ++;
compteur_timer ++;
if (compteur_timer > TEMPO_TIMER)
{
result = inport(port);
Dec_Temps (1);
outport (port,result);
compteur_timer = 0;
Ancienne_Interruption_Timer ();
}
else
{
enable ();
(void)outp (0x20,0x20);
}
}
else
{
enable ();
(void)outp (0x20,0x20);
}
}
void far Installer_Timer_Interruption (void)
{
disable ();
Accelerer_Horloge (FREQUENCE);
Ancienne_Interruption_Timer = getvect (TIMER_INTERRUPTION);
setvect (TIMER_INTERRUPTION,Routine_Timer_Interruption);
enable ();
}
void far Desinstaller_Timer_Interruption (void)
{
commutateur_chrono = OFF;
disable ();
Retablir_Horloge ();
setvect (TIMER_INTERRUPTION,
Ancienne_Interruption_Timer);
enable ();
}
void far Activer_Timer (void)
{
commutateur_chrono = ON;
}
void far Desactiver_Timer (void)
{
commutateur_chrono = OFF;
}
void Accelerer_Horloge (short freq)
{
unsigned short tspeed;
tspeed = 1193180UL / (unsigned short)freq;
outportb (0x43,0x3c);
outportb (0x40,tspeed & 0xff);
outportb (0x40,tspeed >> 8);
}
void Retablir_Horloge (void)
{
outportb (0x43,0x3c);
outportb (0x40,0xff);
outportb (0x40,0xff);
}
void Pause (unsigned short duree)
{
delay (duree * (FREQUENCE/18.206759) );
}
void Init_Cadence (short vit)
{
vitesse = vit;
}
short Lire_Cadence (void)
{
return (vitesse);
}