forked from nukebloodaxe/ironseed_fpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gmouse.pas
122 lines (95 loc) · 2.87 KB
/
gmouse.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
unit gmouse;
(********************************************************************
This file is part of Ironseed.
Ironseed is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Ironseed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Ironseed. If not, see <https://www.gnu.org/licenses/>.
********************************************************************)
{*********************************************
Mouse Utilities unit for IronSeed
Copyright:
1994 Channel 7, Destiny: Virtual
2013 y-salnikov
2020 Matija Nalis <mnalis-git@voyager.hr>
**********************************************}
{$L c_utils.o}
interface
type
mouseicontype = array[0..15,0..15] of byte;
mousetype =
object
error: boolean;
function x:Integer;
function y:integer;
procedure setmousecursor(n: integer);
function getstatus : boolean;
end;
var
mouse: mousetype;
oldmouseexitproc: pointer;
mdefault: mouseicontype;
procedure mousehide;cdecl; external;
procedure mousesetcursor(var i: mouseicontype); cdecl; external; // NB. var should be constref
procedure mouseshow; cdecl; external;
implementation
uses utils_;
function mouse_get_status: char;cdecl ; external;
function mouse_get_x: dword;cdecl ; external;
function mouse_get_y: dword;cdecl ; external;
function mousetype.getstatus:boolean;
begin
getstatus:=boolean(mouse_get_status);
end;
function mousetype.x:integer;
begin
x:=integer(mouse_get_x);
end;
function mousetype.y:integer;
begin
y:=integer(mouse_get_y);
end;
procedure errorhandler(s: string; errtype: integer);
begin
writeln;
case errtype of
1: writeln('File Error: ',s);
2: writeln('Mouse Error: ',s);
3: writeln('Sound Error: ',s);
4: writeln('EMS Error: ',s);
5: writeln('Fatal File Error: ',s);
6: writeln('Program Error: ',s);
7: writeln('Music Error: ',s);
end;
halt(4);
end;
procedure mousetype.setmousecursor(n: integer);
type
weaponicontype= array[0..19,0..19] of byte;
var i: integer;
f: file of weaponicontype;
tempicon: ^weaponicontype;
begin
new(tempicon);
assign(f,loc_data()+'weapicon.dta');
reset(f);
if ioresult<>0 then errorhandler('weapicon.dta',1);
seek(f,Int64(n)+87);
if ioresult<>0 then errorhandler('weapicon.dta',5);
read(f,tempicon^);
if ioresult<>0 then errorhandler('weapicon.dta',5);
close(f);
for i:=0 to 15 do
move(tempicon^[i],mdefault[i],16);
mousesetcursor(mdefault);
dispose(tempicon);
end;
begin
mouse.setmousecursor(0);
end.