-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUTILS.PAS
123 lines (96 loc) · 1.99 KB
/
UTILS.PAS
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
unit Utils;
interface
type MouseState = record
X, Y: Integer;
Button1, Button2: Boolean;
end;
MouseStatePtr = ^MouseState;
procedure InitMouse;
procedure ShowMouse;
procedure HideMouse;
function GetMouseState: MouseStatePtr;
function TimeSync(CurrentTimer: Byte): Byte;
function AlignNumber(Number: Word): string;
procedure PlayerSound;
procedure EnemySound;
implementation
uses Crt, Dos;
procedure Cursor; external; {$L CURSOR.OBJ}
procedure InitMouse;
var R: Registers;
begin
R.AX := 0; { initialize mouse driver }
Intr($33, R);
R.AX := 9; { define own mouse cursor }
R.BX := 7; { horizontal hot spot }
R.CX := 7; { vertical hot spot }
R.ES := Seg(Cursor);
R.DX := Ofs(Cursor);
Intr($33, R);
end;
procedure ShowMouse;
var R: Registers;
begin
R.AX := 1;
Intr($33, R);
end;
procedure HideMouse;
var R: Registers;
begin
R.AX := 2;
Intr($33, R);
end;
function GetMouseState: MouseStatePtr;
var R: Registers;
Result: MouseState;
begin
R.AX := 3; { query mouse state }
Intr($33, R);
Result.X := R.CX div 2; { 0-639 }
Result.Y := R.DX; { 0-199 }
Result.Button1 := (R.BX and 1) <> 0;
Result.Button2 := (R.BX and 2) <> 0;
GetMouseState := @Result;
end;
function TimeSync(CurrentTimer: Byte): Byte;
var h, m, s, Counter: Word;
begin
repeat
GetTime(h, m, s, Counter);
Counter := Counter div 4; { 25 ticks per second }
until Counter <> CurrentTimer;
TimeSync := Counter;
end;
function _ToString(Number: Word): string;
var S: string;
begin
Str(Number, S);
_ToString := S;
end;
function AlignNumber(Number: Word): string;
var S: string;
begin
S := ' ' + _ToString(Number);
AlignNumber := Copy(S, Length(S) - 3, 4);
end;
procedure PlayerSound;
var i: Byte;
begin
for i := 30 downto 10 do
begin
Sound(i * 8);
Delay(2);
end;
NoSound;
end;
procedure EnemySound;
var i: Byte;
begin
for i := 34 downto 14 do
begin
Sound(i * 8);
Delay(2);
end;
NoSound;
end;
end.