-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.txt
153 lines (124 loc) · 3.26 KB
/
Utils.txt
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// General purpose utilities
// by Miran
// ver 1.0
{$USE CLEO}
0000: NOP
jump @UTILS_END // do not execute any code from this file yet
// linear interpolate betweet two values
// arg 0 - (float) start value
// arg 1 - (float) end value
// arg 2 - (float) progress (0.0 - 1.0)
// return - (float) interpolated value
:FLOAT_LERP
3@ = 1.0
0063: 3@ -= 2@ // inverted progress
006B: 0@ *= 3@
006B: 1@ *= 2@
005B: 0@ += 1@
cleo_return 1 0@
// Check if string starts with given prefix (case sensitive)
// arg 0@ - prefix text
// arg 1@ - reserved (occupied by prefix text too)
// arg 2@ - reserved (occupied by prefix text too)
// arg 3@ - prefix length 0-12 characters
// arg 4@ - pointer to string to search within
// return 0@ - true or false
:TEXT_STARTS_WITH
0AC7: 5@ = var 0@ offset // address of @0
repeat
read_memory 6@ = read_memory 5@ size 1 virtual_protect 0 // read char from searched prefix
read_memory 7@ = read_memory 4@ size 1 virtual_protect 0 // read char from text
if 803B: 6@ <> 7@ // (int)
then
0@ = false
return // characters not equal
end
if 6@ == 0 // null terminator character
then
0@ = true
return // end of prefix
end
if 7@ == 0 // null terminator character
then
0@ = false
return // end of text
end
5@ += 1
4@ += 1
3@ -= 1
until 3@ == 0
0@ = true // end of searched prefix
return
// return 0@ - true or false
:IS_RADAR_VISIBLE
0@ = 0
read_memory 0@ = read_memory 0x00BAA3FB size 1 virtual_protect 0
if
0@ == 0
then
0@ = true
else
0@ = false
end
return
// check is player entering/exiting interior
// return 0@ - true or false
:IS_INTERIOR_CHANGING
0@ = 0
read_memory 0@ = read_memory 0x0096A7CC size 4 virtual_protect 0 // ENEX trigger handling state
if or
0@ == 1 // entering
0@ == 2 // entered
//0@ == 3 // standing in enex, but ignore util exit
then
0@ = true
else
0@ = false
end
return
// util for writing memory region with zeros
// arg i0 - memory start address
// arg i1 - size in bytes
:UTILS_ZERO_MEMORY
/*while i1 > 0
write_memory i0 size 1 value 0 virtual_protect 0
i0 += 1
i1 -= 1
end*/
return
// util for writing array contents with zeros
// arg i0 - memory start address
// arg i1 - count of (4 byte sized) array elements
:UTILS_ZERO_ARRAY
/*while i1 > 0
write_memory i0 size 4 value 0 virtual_protect 0
i0 += 4 // element size
i1 -= 1
end*/
return
// play sound at player's position
// arg 0@ - sound id
:PlAY_SOUND_AT_PLAYER
00A0: store_actor $PLAYER_ACTOR position_to 1@ 2@ 3@
PLAY_SOUND_AT()
return
// play sound at position
// arg 0@ - sound id
// arg 1@ - position x
// arg 2@ - position y
// arg 3@ - position z
:PlAY_SOUND_AT
03D7: set_wav 2 location 1@ 2@ 3@
PLAY_SOUND()
return
// play sound
// arg 0@ - sound id
:PLAY_SOUND
040D: unload_wav 2
03CF: load_wav 0@ as 2
while 83D0: not wav 2 loaded
wait 0 ms
end
03D1: play_wav 2
return
:UTILS_END