Debian Codegraph @

gcc/testsuite/gm2/projects/pim/run/pass/tower/DrawG.mod

raw
1 IMPLEMENTATION MODULE DrawG ;
2
3
4 FROM AdvMap IMPORT Rooms, Door, DoorStatus, Line, Adjacent ;
5 FROM ASCII IMPORT lf, bs ;
6 FROM Window IMPORT Clip, ClipPoint ;
7 FROM StdIO IMPORT Write ;
8 IMPORT DrawL ;
9
10 FROM Screen IMPORT Height, Width, Flush,
11 WriteCommentLine1, WriteCommentLine2, WriteCommentLine3 ;
12
13 FROM AdvSystem IMPORT Player, PlayerNo, PlayerSet,
14 NextFreePlayer,
15 IsPlayerActive,
16 GetReadAccessToPlayer,
17 GetWriteAccessToPlayer,
18 ReleaseReadAccessToPlayer,
19 ReleaseWriteAccessToPlayer,
20 GetReadAccessToDoor,
21 ReleaseReadAccessToDoor,
22 GetReadAccessToTreasure,
23 ReleaseReadAccessToTreasure,
24 GetAccessToScreenNo,
25 ReleaseAccessToScreenNo ;
26
27
28 (* All these procedures to draw on the screens - are Global *)
29 (* Ie they will draw to all the screens that are within *)
30 (* the area of effect. *)
31
32
33 (* DrawMan draws the calling player on every screen that *)
34 (* is within the area of effect. And which has the same *)
35 (* current room number. *)
36 (* This routine only uses the AccessToScreen Locks. *)
37
38 PROCEDURE DrawMan (p: CARDINAL) ;
39 VAR
40 i,
41 x, y, Sx, Sy, r,
42 dir : CARDINAL ;
43 BEGIN
44 WITH Player[p] DO
45 r := RoomOfMan ;
46 x := Xman ;
47 y := Yman ;
48 dir := Direction
49 END ;
50
51 FOR i := 0 TO NextFreePlayer-1 DO
52 IF IsPlayerActive(i)
53 THEN
54 WITH Player[i] DO
55 IF r=RoomOfMan
56 THEN
57 Sy := ScreenY ;
58 Sx := ScreenX ;
59 IF (x>=Sx) AND (x<=Sx+Width) AND
60 (y>=Sy) AND (y<=Sy+Height)
61 THEN
62 GetAccessToScreenNo(i) ;
63 DrawL.DrawMan(p#i, x-Sx, y-Sy, dir) ;
64 ReleaseAccessToScreenNo(i)
65 END
66 END
67 END
68 END
69 END
70 END DrawMan ;
71
72
73 (* EraseMan erases the calling player on every screen that is *)
74 (* currently displaying this player. *)
75
76 PROCEDURE EraseMan (p: CARDINAL) ;
77 VAR
78 i, r, x, y, Sx, Sy: CARDINAL ;
79 BEGIN
80 WITH Player[p] DO
81 r := RoomOfMan ;
82 x := Xman ;
83 y := Yman
84 END ;
85
86 FOR i := 0 TO NextFreePlayer-1 DO
87 IF IsPlayerActive(i)
88 THEN
89 WITH Player[i] DO
90 IF r=RoomOfMan
91 THEN
92 Sy := ScreenY ;
93 Sx := ScreenX ;
94 IF (x>=Sx) AND (x<=Sx+Width) AND
95 (y>=Sy) AND (y<=Sy+Height)
96 THEN
97 GetAccessToScreenNo(i) ;
98 DrawL.Erase(x-Sx, y-Sy) ;
99 Flush(i) ;
100 ReleaseAccessToScreenNo(i)
101 END
102 END
103 END
104 END
105 END
106 END EraseMan ;
107
108
109 (* DrawDoor draws a door on every screen possible ie all that *)
110 (* are in this particular area. Hence the coordinates need *)
111 (* to be absolute NOT relative! *)
112 (* This procedure uses Locks GetAccessToScreen ONLY! *)
113
114 PROCEDURE DrawDoor (RoomOfDoor, IndexToDoor: CARDINAL) ;
115 VAR
116 p : CARDINAL ;
117 hx, hy,
118 x, y, NextRoom,
119 i, j, x1, y1, x2, y2: CARDINAL ;
120 ok : BOOLEAN ;
121 yt, xt : CARDINAL ;
122 ds : DoorStatus ;
123 BEGIN
124 WITH Rooms[RoomOfDoor].Doors[IndexToDoor].Position DO
125 x1 := X1 ;
126 x2 := X2 ;
127 y1 := Y1 ;
128 y2 := Y2
129 END ;
130
131 WITH Rooms[RoomOfDoor].Doors[IndexToDoor] DO
132 ds := StateOfDoor ;
133 NextRoom := LeadsTo
134 END ;
135
136 FOR p := 0 TO NextFreePlayer-1 DO
137 IF IsPlayerActive(p)
138 THEN
139 WITH Player[p] DO
140 IF (RoomOfDoor=RoomOfMan) OR (RoomOfMan=NextRoom)
141 THEN
142 i := x1 ;
143 j := y1 ;
144 x := x2 ;
145 y := y2 ;
146 Clip(i, j, x, y, ScreenX, ScreenY, ok) ;
147 IF ok
148 THEN
149 GetAccessToScreenNo(p) ;
150 IF i=x
151 THEN
152 hx := x2 ;
153 hy := y2 ;
154 ClipPoint(hx, hy, ScreenX, ScreenY, ok) ;
155 DrawL.DLine(i, j, x, y, ok, ds)
156 ELSE
157 hx := x1 ;
158 hy := y1 ;
159 ClipPoint(hx, hy, ScreenX, ScreenY, ok) ;
160 DrawL.DLine(i, j, x, y, ok, ds)
161 END ;
162 ReleaseAccessToScreenNo(p)
163 END
164 END
165 END
166 END
167 END
168 END DrawDoor ;
169
170
171 (* This procedure only uses LOCKS GetAccessToScreen *)
172
173 PROCEDURE DrawTreasure (room, x, y: CARDINAL) ;
174 VAR
175 p : CARDINAL ;
176 Sx, Sy: CARDINAL ;
177 BEGIN
178 p := 0 ;
179 WHILE p < NextFreePlayer DO
180 IF IsPlayerActive(p)
181 THEN
182 WITH Player[p] DO
183 IF room=RoomOfMan
184 THEN
185 Sy := ScreenY ;
186 Sx := ScreenX ;
187 IF (x>=Sx) AND (x<=Sx+Width) AND
188 (y>=Sy) AND (y<=Sy+Height)
189 THEN
190 GetAccessToScreenNo(p) ;
191 DrawL.DTreasure(x-Sx, y-Sy) ;
192 ReleaseAccessToScreenNo(p)
193 END
194 END
195 END
196 END ;
197 INC (p)
198 END
199 END DrawTreasure ;
200
201
202 PROCEDURE EraseTreasure (room, x, y: CARDINAL) ;
203 VAR
204 p : CARDINAL ;
205 Sx, Sy: CARDINAL ;
206 BEGIN
207 p := 0 ;
208 WHILE p < NextFreePlayer DO
209 IF IsPlayerActive(p)
210 THEN
211 WITH Player[p] DO
212 IF room=RoomOfMan
213 THEN
214 Sy := ScreenY ;
215 Sx := ScreenX ;
216 IF (x>=Sx) AND (x<=Sx+Width) AND
217 (y>=Sy) AND (y<=Sy+Height)
218 THEN
219 GetAccessToScreenNo(p) ;
220 DrawL.Erase(x-Sx, y-Sy) ;
221 Flush(p) ;
222 ReleaseAccessToScreenNo(p)
223 END
224 END
225 END
226 END ;
227 INC (p)
228 END
229 END EraseTreasure ;
230
231
232 (* This procedure only uses LOCKS GetAccessToScreen *)
233
234 PROCEDURE DrawArrow (room, x, y, dir: CARDINAL ; VAR playerscreen: PlayerSet) ;
235 VAR
236 p, Sx, Sy: CARDINAL ;
237 BEGIN
238 playerscreen := PlayerSet{} ;
239 p := 0 ;
240 WHILE p < NextFreePlayer DO
241 IF IsPlayerActive(p)
242 THEN
243 WITH Player[p] DO
244 IF room=RoomOfMan
245 THEN
246 Sy := ScreenY ;
247 Sx := ScreenX ;
248 IF (x>=Sx) AND (x<=Sx+Width) AND
249 (y>=Sy) AND (y<=Sy+Height)
250 THEN
251 INCL(playerscreen, p) ;
252 GetAccessToScreenNo(p) ;
253 DrawL.DArrow(x-Sx, y-Sy, dir) ;
254 ReleaseAccessToScreenNo(p)
255 END
256 END
257 END
258 END ;
259 INC (p)
260 END
261 END DrawArrow ;
262
263
264 PROCEDURE EraseArrow (x, y: CARDINAL ; playerscreen: PlayerSet; flush: BOOLEAN) ;
265 VAR
266 p, Sx, Sy: CARDINAL ;
267 BEGIN
268 p := 0 ;
269 WHILE p < NextFreePlayer DO
270 IF IsPlayerActive(p)
271 THEN
272 WITH Player[p] DO
273 IF p IN playerscreen
274 THEN
275 Sy := ScreenY ;
276 Sx := ScreenX ;
277 IF (x>=Sx) AND (x<=Sx+Width) AND
278 (y>=Sy) AND (y<=Sy+Height)
279 THEN
280 GetAccessToScreenNo(p) ;
281 DrawL.Erase(x-Sx, y-Sy) ;
282 IF flush
283 THEN
284 Flush(p)
285 END ;
286 ReleaseAccessToScreenNo(p)
287 END
288 END
289 END
290 END ;
291 INC (p)
292 END
293 END EraseArrow ;
294
295
296 PROCEDURE DisplayMessage (a1, a2, a3: ARRAY OF CHAR) ;
297 VAR
298 i, p, r: CARDINAL ;
299 BEGIN
300 p := PlayerNo() ;
301 GetReadAccessToPlayer ;
302 r := Player[p].RoomOfMan ;
303 FOR i := 0 TO NextFreePlayer-1 DO
304 IF IsPlayerActive(i)
305 THEN
306 WITH Player[i] DO
307 IF r=RoomOfMan
308 THEN
309 GetAccessToScreenNo(i) ;
310 WriteCommentLine1(i, a1) ;
311 WriteCommentLine2(i, a2) ;
312 WriteCommentLine3(i, a3) ;
313 ReleaseAccessToScreenNo(i)
314 END
315 END
316 END
317 END ;
318 ReleaseReadAccessToPlayer
319 END DisplayMessage ;
320
321
322 END DrawG.
323 (*
324 * Local variables:
325 * compile-command: "make"
326 * End:
327 *)