-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.dasm
392 lines (336 loc) · 13.7 KB
/
ui.dasm
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
@window title = "Dangerfield's Dive Model";
@screen = (@widgets root children);
@screen sea = (new union (@prototypes image)
filename="images/sea.png"
x = 0
y = 0
height = 600
width = 800
children = (new)
);
@screen diver = (new union (@prototypes image)
filename="images/diver.png"
x = 100
y is {30 + (@root depth * (8))}
visible is { if(@root depth == (@root targetdepth)) { true } else { false } }
width = 47
height = 14
);
@screen diverAscend = (new union (@prototypes image)
filename="images/diverAscend.png"
x = 100
y is {30 + (@root depth * (8))}
visible is { if(@root depth > (@root targetdepth)) { true } else { false } }
width = 14
height = 47
);
@screen diverDescend = (new union (@prototypes image)
filename="images/diverDescend.png"
x = 100
y is {7 + (@root depth * (8))}
visible is { if(@root depth < (@root targetdepth)) { true } else { false } }
width = 14
height = 47
);
@screen target = (new union (@prototypes image)
filename="images/target.png"
x = 100
y is {30 + (@root targetdepth * (8))}
visible is { if(@root depth == (@root targetdepth)) { false } else { true } }
width = 11
height = 11
);
@tints = (new
normal = (new r = 0 g = 0.54 b = 0.93)
error = (new r = 1 g = 0 b = 0)
warn = (new r = 1 g = 0.78 b = 0)
);
@sprite = (new
basic = (new union (@prototypes sprite)
filename = "images/sprite.png"
columns = 2
)
);
@templates = (new);
@templates %deep label = (new union (@prototypes label)
tint is {@tints normal}
frame = 1
sprite is {@sprite basic}
);
@templates %deep valueIndicatorSmall = (new union (@prototypes widget)
width = 140
height = 20
%deep children = (new
%deep label = (new union (@templates label)
x = 10
y = 2
width = 50
)
%deep value = (new union (@templates label)
x is {..label x + (..label width)}
y = 2
)
)
tint is {@tints normal}
sprite is {@sprite basic}
);
@templates %deep indicatorGroup = (new union (@prototypes widget)
width = 250
items = 1
height is {40 + (.items * (20))}
%deep children = (new
%deep label = (new union (@templates label)
x = 10
y = 4
width := {...width - (20)}
)
)
tint is {@tints normal}
sprite is {@sprite basic}
);
@templates %deep indicatorGroupItem = (new union (@prototypes widget)
width = 200
height = 20
x = 10
y = 25
%deep children = (new
%deep label = (new union (@templates label)
x = 5
y = 2
width = 100
)
%deep value = (new union (@templates label)
x is {..label x + (..label width)}
y = 2
)
)
tint is {@tints normal}
sprite is {@sprite basic}
);
@templates %deep depthlabel = (new union (@templates label)
x = 30
depth = 0
y is {30 + (.depth * (8))}
caption is {.depth}
);
@templates %deep compartment = (new union (@templates indicatorGroupItem));
@templates compartment children value caption is {...pointer gases nitrogen pp};
@templates %deep ceiling = (new union (@templates indicatorGroupItem));
@templates ceiling tint is { if(.pointer ceiling actualDepth > (@root depth)) { @tints error } else if(..pointer ceiling depth > (@root depth)) {@tints warn} else { @tints normal } };
@templates ceiling children value caption is {...pointer ceiling depth};
# Basic Dive Gauge
@screen depthgauge = (new union (@templates valueIndicatorSmall)
x = 250
y = 100
);
@screen depthgauge children label caption = "Depth:";
@screen depthgauge children value caption is {@root depth};
@screen maxdepth = (new union (@templates valueIndicatorSmall)
x is {@screen depthgauge x}
y is {@screen depthgauge y + (@screen depthgauge height) + (10)}
);
@screen maxdepth children label caption = "Max:";
@screen maxdepth children value caption is {@root maxdepth};
@screen timer = (new union (@templates valueIndicatorSmall)
x is {@screen depthgauge x}
y is {@screen maxdepth y + (@screen maxdepth height) + (10)}
);
@screen timer children label caption = "Time:";
@screen timer children value caption is {@root modeltimeminutes};
# Game Speed
@screen speed = (new union (@templates valueIndicatorSmall)
x is {@screen depthgauge x}
y is {@screen timer y + (@screen timer height) + (10)}
);
@screen speed children label caption = "Speed: x";
@screen speed children value caption is {@root xspeed};
@screen speed children value x is {..label x + (..label width) + (12)};
# Mix Percentages
@screen mix = (new union (@templates indicatorGroup)
x is {@screen depthgauge x}
y is {@screen speed y + (@screen timer height) + (10)}
items = 1
);
@screen mix children label caption = "Gas Mix (%)";
@screen mix children oxygen = (new union (@templates indicatorGroupItem));
@screen mix children oxygen children label caption = "Oxygen";
@screen mix children oxygen children value caption := {@root gases oxygen mix * (100)};
# Nitrogen is ignored in mix specs.
# Breating Gas Pressures
@screen breathingpp = (new union (@templates indicatorGroup)
x is {@screen depthgauge x}
y is {@screen mix y + (@screen mix height) + (10)}
items = 2
);
@screen breathingpp children label caption = "Partial Pressures of Supplied Gas (BAR)";
@screen breathingpp children oxygen = (new union (@templates indicatorGroupItem));
@screen breathingpp children oxygen children label caption = "Oxygen";
@screen breathingpp children oxygen children value caption is {@root gases oxygen pp};
# Oxygen becomes increasingly dangerous ("Oxygen toxicity") over a partial pressure of 1.4+ bar. Indicate so:
@screen breathingpp children oxygen tint is { if(@root gases oxygen pp > (2.0)) {@tints error} else if(@root gases oxygen pp > (1.4)) {@tints warn} else {@tints normal}};
@screen breathingpp children nitrogen = (new union (@templates indicatorGroupItem)
y is {..oxygen y + (..oxygen height)}
);
@screen breathingpp children nitrogen children label caption = "Nitrogen";
@screen breathingpp children nitrogen children value caption is {@root gases nitrogen pp};
# Nitrogen narcosis gets increasing dangerous at pressures over 4 bar.
@screen breathingpp children nitrogen tint is { if(@root gases nitrogen pp > (5.0)) {@tints error} else if(@root gases nitrogen pp > (4.0)) {@tints warn} else {@tints normal}};
# Tissue States
@screen compartments = (new union (@templates indicatorGroup)
x = 520
y = 100
items = 9
);
@screen compartments children label caption = "Tissue Pressures for Nitrogen (BAR)";
@screen compartments children 0 = (new union (@templates compartment)
pointer := {@root compartments 0}
);
@screen compartments children 0 children label caption = "Compartment 1:";
@screen compartments children 1 = (new union (@templates compartment)
y is {..0 y + (..0 height)}
pointer is {@root compartments 1}
);
@screen compartments children 1 children label caption = "Compartment 2:";
@screen compartments children 2 = (new union (@templates compartment)
y is {..1 y + (..1 height)}
pointer is {@root compartments 2}
);
@screen compartments children 2 children label caption = "Compartment 3:";
@screen compartments children 3 = (new union (@templates compartment)
y is {..2 y + (..2 height)}
pointer is {@root compartments 3}
);
@screen compartments children 3 children label caption = "Compartment 4:";
@screen compartments children 4 = (new union (@templates compartment)
y is {..3 y + (..3 height)}
pointer is {@root compartments 4}
);
@screen compartments children 4 children label caption = "Compartment 5:";
@screen compartments children 5 = (new union (@templates compartment)
y is {..4 y + (..4 height)}
pointer is {@root compartments 5}
);
@screen compartments children 5 children label caption = "Compartment 6:";
@screen compartments children 6 = (new union (@templates compartment)
y is {..5 y + (..5 height)}
pointer is {@root compartments 6}
);
@screen compartments children 6 children label caption = "Compartment 7:";
@screen compartments children 7 = (new union (@templates compartment)
y is {..6 y + (..6 height)}
pointer is {@root compartments 7}
);
@screen compartments children 7 children label caption = "Compartment 8:";
@screen compartments children 8 = (new union (@templates compartment)
y is {..7 y + (..7 height)}
pointer is {@root compartments 8}
);
@screen compartments children 8 children label caption = "Compartment 9:";
# Depth Labels
@screen sea children metres00 = (new union (@templates depthlabel) depth = 0);
@screen sea children metres10 = (new union (@templates depthlabel) depth = 10);
@screen sea children metres20 = (new union (@templates depthlabel) depth = 20);
@screen sea children metres30 = (new union (@templates depthlabel) depth = 30);
@screen sea children metres40 = (new union (@templates depthlabel) depth = 40);
@screen sea children metres50 = (new union (@templates depthlabel) depth = 50);
@screen sea children metres60 = (new union (@templates depthlabel) depth = 60);
# Keyboard interaction
# UP & DOWN controls depth
# LEFT & RIGHT controls game speed
# NUMBERS switch between gas mixes
# The following is intended to reduce the key press rate, so the targetdepth is somewhat easier to control
# [NOTE] For some unknown-to-the-author reason, keyboard presses appear to come in 2s, thus targetdepth jumps in 2m.
@keyboardtimings = (new up = 0 down = 0 right = 0 left = 0);
@keyboardclicks = (new up = false down = false right = 0 left = 0);
@keyboardtimings up := { if(@keyboardclicks up == true) { @root time } else { @keyboardtimings up }} ;
@keyboardtimings down := { if(@keyboardclicks down == true) { @root time } else { @keyboardtimings down }} ;
@keyboardtimings right := { if(@keyboardclicks right == true) { @root time } else { @keyboardtimings right }} ;
@keyboardtimings left := { if(@keyboardclicks left == true) { @root time } else { @keyboardtimings left }} ;
@keyboardclicks up := { if(@keyboard keys up == true and (@root time - (@keyboardtimings up) > 0.2)) { true } else { false } };
@keyboardclicks down := { if(@keyboard keys down == true and (@root time - (@keyboardtimings down) > 0.2)) { true } else { false } };
@keyboardclicks right := { if(@keyboard keys right == true and (@root time - (@keyboardtimings right) > 0.2)) { true } else { false } };
@keyboardclicks left := { if(@keyboard keys left == true and (@root time - (@keyboardtimings left) > 0.2)) { true } else { false } };
@keyboard lastnumber := {
if(@keyboard keys '1' == true) {1}
else if (@keyboard keys '2' == true) {2}
else if (@keyboard keys '3' == true) {3}
else {@keyboard lastnumber}
};
@root gases oxygen mix := {
if(@keyboard lastnumber == 2) {0.32}
else if (@keyboard lastnumber == 3) {0.36}
else {0.21}
};
# [NOTE] When cadence can do Math.max & Math.min, we can add boundaries for the targetdepth nicely
@root targetdepth := {
if(@keyboardclicks down == true) {
if(@root targetdepth + 1 >= 60) { 60 }
else { @root targetdepth + 1 }
} else if(@keyboardclicks up == true) {
if(@root targetdepth - 1 <= 0) { 0 }
else { @root targetdepth - 1 }
} else {
@root targetdepth
}
};
@root xspeed := {
if(@keyboardclicks left == true) {
if(@root xspeed - 1 <= 1) { 1 }
else { @root xspeed - 1 }
} else if(@keyboardclicks right == true) {
@root xspeed + 1
} else {
@root xspeed
}
};
# Ceiling outputs
@screen ceilings = (new union (@templates indicatorGroup)
x is {@screen compartments x}
y is {@screen compartments y + (@screen compartments height) + (10)}
items = 9
);
@screen ceilings children label caption = "Tissue Ceilings (METRES DEPTH)";
@screen ceilings children 0 = (new union (@templates ceiling)
pointer is {@root compartments 0}
);
@screen ceilings children 0 children label caption = "Compartment 1:";
@screen ceilings children 1 = (new union (@templates ceiling)
y is {..0 y + (..0 height)}
pointer is {@root compartments 1}
);
@screen ceilings children 1 children label caption = "Compartment 2:";
@screen ceilings children 2 = (new union (@templates ceiling)
y is {..1 y + (..1 height)}
pointer is {@root compartments 2}
);
@screen ceilings children 2 children label caption = "Compartment 3:";
@screen ceilings children 3 = (new union (@templates ceiling)
y is {..2 y + (..2 height)}
pointer is {@root compartments 3}
);
@screen ceilings children 3 children label caption = "Compartment 4:";
@screen ceilings children 4 = (new union (@templates ceiling)
y is {..3 y + (..3 height)}
pointer is {@root compartments 4}
);
@screen ceilings children 4 children label caption = "Compartment 5:";
@screen ceilings children 5 = (new union (@templates ceiling)
y is {..4 y + (..4 height)}
pointer is {@root compartments 5}
);
@screen ceilings children 5 children label caption = "Compartment 6:";
@screen ceilings children 6 = (new union (@templates ceiling)
y is {..5 y + (..5 height)}
pointer is {@root compartments 6}
);
@screen ceilings children 6 children label caption = "Compartment 7:";
@screen ceilings children 7 = (new union (@templates ceiling)
y is {..6 y + (..6 height)}
pointer is {@root compartments 7}
);
@screen ceilings children 7 children label caption = "Compartment 8:";
@screen ceilings children 8 = (new union (@templates ceiling)
y is {..7 y + (..7 height)}
pointer is {@root compartments 8}
);
@screen ceilings children 8 children label caption = "Compartment 9:";