DEADSOFTWARE

3e9763be912be89a1be453e99a71a024973bcf91
[d2df-sdl.git] / src / shared / mapstructio.inc
1 procedure getBytesAt (var dest; const buf; ofs, len: Integer);
2 begin
3 Move((PChar(@buf)+ofs)^, dest, len);
4 end;
6 procedure getWordAt (var dest; const buf; ofs: Integer);
7 type PWord = ^Word; PByte = ^Byte;
8 var
9 p: PByte;
10 d: PWord;
11 begin
12 p := PByte(@buf); Inc(p, ofs);
13 d := PWord(@dest);
14 d^ := p^;
15 Inc(p);
16 d^ := (d^) or ((p^) shl 8);
17 end;
19 procedure getIntAt (var dest; const buf; ofs: Integer);
20 type PInt = ^LongWord; PByte = ^Byte;
21 var
22 p: PByte;
23 d: PInt;
24 begin
25 p := PByte(@buf); Inc(p, ofs);
26 d := PInt(@dest);
27 d^ := p^;
28 Inc(p);
29 d^ := (d^) or ((p^) shl 8);
30 Inc(p);
31 d^ := (d^) or ((p^) shl 16);
32 Inc(p);
33 d^ := (d^) or ((p^) shl 24);
34 end;
36 procedure putBytesAt (var buf; ofs: Integer; const src; len: Integer);
37 begin
38 Move(src, (PChar(@buf)+ofs)^, len);
39 end;
41 procedure putWordAt (var buf; ofs: Integer; const src);
42 type PWord = ^Word; PByte = ^Byte;
43 var
44 p: PByte;
45 d: PWord;
46 begin
47 p := PByte(PChar(@buf)+ofs);
48 d := PWord(@src);
49 p^ := (d^) and $ff;
50 Inc(p);
51 p^ := ((d^) shr 8) and $ff;
52 end;
54 procedure putIntAt (var buf; ofs: Integer; const src);
55 type PInt = ^LongWord; PByte = ^Byte;
56 var
57 p: PByte;
58 d: PInt;
59 begin
60 p := PByte(PChar(@buf)+ofs);
61 d := PInt(@src);
62 p^ := (d^) and $ff;
63 Inc(p);
64 p^ := ((d^) shr 8) and $ff;
65 Inc(p);
66 p^ := ((d^) shr 16) and $ff;
67 Inc(p);
68 p^ := ((d^) shr 24) and $ff;
69 end;
71 procedure mb_Read_TriggerData (var tr: TTriggerData; ttype: Integer; const buf; bufsize: Integer);
72 procedure xreadExit ();
73 begin
74 getBytesAt(tr.MapName, buf, 0, 16);
75 end;
77 procedure xreadTeleport ();
78 begin
79 getIntAt(tr.TargetPoint.x, buf, 0);
80 getIntAt(tr.TargetPoint.y, buf, 4);
81 getBytesAt(tr.d2d_teleport, buf, 8, 1);
82 getBytesAt(tr.silent_teleport, buf, 9, 1);
83 getBytesAt(tr.TlpDir, buf, 10, 1);
84 end;
86 procedure xreadOpendoor ();
87 begin
88 getIntAt(tr.PanelID, buf, 0);
89 getBytesAt(tr.NoSound, buf, 4, 1);
90 getBytesAt(tr.d2d_doors, buf, 5, 1);
91 end;
93 procedure xreadPress ();
94 begin
95 getIntAt(tr.tX, buf, 0);
96 getIntAt(tr.tY, buf, 4);
97 getWordAt(tr.tWidth, buf, 8);
98 getWordAt(tr.tHeight, buf, 10);
99 getWordAt(tr.Wait, buf, 12);
100 getWordAt(tr.Count, buf, 14);
101 getIntAt(tr.MonsterID, buf, 16);
102 getBytesAt(tr.ExtRandom, buf, 20, 1);
103 end;
105 procedure xreadSecret ();
106 begin
107 end;
109 procedure xreadTexture ();
110 begin
111 getBytesAt(tr.ActivateOnce, buf, 0, 1);
112 getBytesAt(tr.AnimOnce, buf, 1, 1);
113 end;
115 procedure xreadSound ();
116 begin
117 getBytesAt(tr.SoundName, buf, 0, 64);
118 getBytesAt(tr.Volume, buf, 64, 1);
119 getBytesAt(tr.Pan, buf, 65, 1);
120 getBytesAt(tr.Local, buf, 66, 1);
121 getBytesAt(tr.PlayCount, buf, 67, 1);
122 getBytesAt(tr.SoundSwitch, buf, 68, 1);
123 end;
125 procedure xreadSpawnmonster ();
126 begin
127 getIntAt(tr.MonPos.x, buf, 0);
128 getIntAt(tr.MonPos.y, buf, 4);
129 getBytesAt(tr.MonType, buf, 8, 1);
130 getIntAt(tr.MonHealth, buf, 12);
131 getBytesAt(tr.MonDir, buf, 16, 1);
132 getBytesAt(tr.MonActive, buf, 17, 1);
133 getIntAt(tr.MonCount, buf, 20);
134 getBytesAt(tr.MonEffect, buf, 24, 1);
135 getWordAt(tr.MonMax, buf, 26);
136 getWordAt(tr.MonDelay, buf, 28);
137 getBytesAt(tr.MonBehav, buf, 30, 1);
138 end;
140 procedure xreadSpawnitem ();
141 begin
142 getIntAt(tr.ItemPos.x, buf, 0);
143 getIntAt(tr.ItemPos.y, buf, 4);
144 getBytesAt(tr.ItemType, buf, 8, 1);
145 getBytesAt(tr.ItemFalls, buf, 9, 1);
146 getBytesAt(tr.ItemOnlyDM, buf, 10, 1);
147 getIntAt(tr.ItemCount, buf, 12);
148 getBytesAt(tr.ItemEffect, buf, 16, 1);
149 getWordAt(tr.ItemMax, buf, 18);
150 getWordAt(tr.ItemDelay, buf, 20);
151 end;
153 procedure xreadMusic ();
154 begin
155 getBytesAt(tr.MusicName, buf, 0, 64);
156 getBytesAt(tr.MusicAction, buf, 64, 1);
157 end;
159 procedure xreadPush ();
160 begin
161 getWordAt(tr.PushAngle, buf, 0);
162 getBytesAt(tr.PushForce, buf, 2, 1);
163 getBytesAt(tr.ResetVel, buf, 3, 1);
164 end;
166 procedure xreadScore ();
167 begin
168 getBytesAt(tr.ScoreAction, buf, 0, 1);
169 getBytesAt(tr.ScoreCount, buf, 1, 1);
170 getBytesAt(tr.ScoreTeam, buf, 2, 1);
171 getBytesAt(tr.ScoreCon, buf, 3, 1);
172 getBytesAt(tr.ScoreMsg, buf, 4, 1);
173 end;
175 procedure xreadMessage ();
176 begin
177 getBytesAt(tr.MessageKind, buf, 0, 1);
178 getBytesAt(tr.MessageSendTo, buf, 1, 1);
179 getBytesAt(tr.MessageText, buf, 2, 100);
180 getWordAt(tr.MessageTime, buf, 102);
181 end;
183 procedure xreadDamage ();
184 begin
185 getWordAt(tr.DamageValue, buf, 0);
186 getWordAt(tr.DamageInterval, buf, 2);
187 end;
189 procedure xreadHealth ();
190 begin
191 getWordAt(tr.HealValue, buf, 0);
192 getWordAt(tr.HealInterval, buf, 2);
193 getBytesAt(tr.HealMax, buf, 4, 1);
194 getBytesAt(tr.HealSilent, buf, 5, 1);
195 end;
197 procedure xreadShot ();
198 begin
199 getIntAt(tr.ShotPos.x, buf, 0);
200 getIntAt(tr.ShotPos.y, buf, 4);
201 getBytesAt(tr.ShotType, buf, 8, 1);
202 getBytesAt(tr.ShotTarget, buf, 9, 1);
203 getBytesAt(tr.ShotSound, buf, 10, 1);
204 getBytesAt(tr.ShotAllMap, buf, 11, 1);
205 getIntAt(tr.ShotPanelID, buf, 12);
206 getWordAt(tr.ShotIntSight, buf, 16);
207 getWordAt(tr.ShotAngle, buf, 18);
208 getWordAt(tr.ShotWait, buf, 20);
209 getWordAt(tr.ShotAccuracy, buf, 22);
210 getWordAt(tr.ShotAmmo, buf, 24);
211 getWordAt(tr.ShotIntReload, buf, 26);
212 end;
214 procedure xreadEffect ();
215 begin
216 getBytesAt(tr.FXCount, buf, 0, 1);
217 getBytesAt(tr.FXType, buf, 1, 1);
218 getBytesAt(tr.FXSubType, buf, 2, 1);
219 getBytesAt(tr.FXColorR, buf, 3, 1);
220 getBytesAt(tr.FXColorG, buf, 4, 1);
221 getBytesAt(tr.FXColorB, buf, 5, 1);
222 getBytesAt(tr.FXPos, buf, 6, 1);
223 getWordAt(tr.FXWait, buf, 8);
224 getBytesAt(tr.FXVelX, buf, 10, 1);
225 getBytesAt(tr.FXVelY, buf, 11, 1);
226 getBytesAt(tr.FXSpreadL, buf, 12, 1);
227 getBytesAt(tr.FXSpreadR, buf, 13, 1);
228 getBytesAt(tr.FXSpreadU, buf, 14, 1);
229 getBytesAt(tr.FXSpreadD, buf, 15, 1);
230 end;
232 begin
233 if (bufsize < 104) then raise Exception.Create('invalid buffer size in mb_Read_TriggerData');
234 if (ttype = TRIGGER_EXIT) then begin xreadExit(); exit; end;
235 if (ttype = TRIGGER_TELEPORT) then begin xreadTeleport(); exit; end;
236 if (ttype = TRIGGER_OPENDOOR) then begin xreadOpendoor(); exit; end;
237 if (ttype = TRIGGER_CLOSEDOOR) then begin xreadOpendoor(); exit; end;
238 if (ttype = TRIGGER_DOOR) then begin xreadOpendoor(); exit; end;
239 if (ttype = TRIGGER_DOOR5) then begin xreadOpendoor(); exit; end;
240 if (ttype = TRIGGER_CLOSETRAP) then begin xreadOpendoor(); exit; end;
241 if (ttype = TRIGGER_TRAP) then begin xreadOpendoor(); exit; end;
242 if (ttype = TRIGGER_LIFTUP) then begin xreadOpendoor(); exit; end;
243 if (ttype = TRIGGER_LIFTDOWN) then begin xreadOpendoor(); exit; end;
244 if (ttype = TRIGGER_LIFT) then begin xreadOpendoor(); exit; end;
245 if (ttype = TRIGGER_PRESS) then begin xreadPress(); exit; end;
246 if (ttype = TRIGGER_ON) then begin xreadPress(); exit; end;
247 if (ttype = TRIGGER_OFF) then begin xreadPress(); exit; end;
248 if (ttype = TRIGGER_ONOFF) then begin xreadPress(); exit; end;
249 if (ttype = TRIGGER_SECRET) then begin xreadSecret(); exit; end;
250 if (ttype = TRIGGER_TEXTURE) then begin xreadTexture(); exit; end;
251 if (ttype = TRIGGER_SOUND) then begin xreadSound(); exit; end;
252 if (ttype = TRIGGER_SPAWNMONSTER) then begin xreadSpawnmonster(); exit; end;
253 if (ttype = TRIGGER_SPAWNITEM) then begin xreadSpawnitem(); exit; end;
254 if (ttype = TRIGGER_MUSIC) then begin xreadMusic(); exit; end;
255 if (ttype = TRIGGER_PUSH) then begin xreadPush(); exit; end;
256 if (ttype = TRIGGER_SCORE) then begin xreadScore(); exit; end;
257 if (ttype = TRIGGER_MESSAGE) then begin xreadMessage(); exit; end;
258 if (ttype = TRIGGER_DAMAGE) then begin xreadDamage(); exit; end;
259 if (ttype = TRIGGER_HEALTH) then begin xreadHealth(); exit; end;
260 if (ttype = TRIGGER_SHOT) then begin xreadShot(); exit; end;
261 if (ttype = TRIGGER_EFFECT) then begin xreadEffect(); exit; end;
262 raise Exception.Create('invalid trigger type in mb_Read_TriggerData');
263 end;
266 procedure mb_Read_TMapHeaderRec_1 (var tr: TMapHeaderRec_1; const buf; bufsize: Integer);
267 procedure xreadTmapheaderrec_1 ();
268 begin
269 getBytesAt(tr.MapName, buf, 0, 32);
270 getBytesAt(tr.MapAuthor, buf, 32, 32);
271 getBytesAt(tr.MapDescription, buf, 64, 256);
272 getBytesAt(tr.MusicName, buf, 320, 64);
273 getBytesAt(tr.SkyName, buf, 384, 64);
274 getWordAt(tr.Width, buf, 448);
275 getWordAt(tr.Height, buf, 450);
276 end;
278 begin
279 if (bufsize < 452) then raise Exception.Create('invalid buffer size in readTMapHeaderRec_1');
280 xreadTmapheaderrec_1();
281 end;
283 procedure mb_Read_TTextureRec_1 (var tr: TTextureRec_1; const buf; bufsize: Integer);
284 procedure xreadTtexturerec_1 ();
285 begin
286 getBytesAt(tr.Resource, buf, 0, 64);
287 getBytesAt(tr.Anim, buf, 64, 1);
288 end;
290 begin
291 if (bufsize < 65) then raise Exception.Create('invalid buffer size in readTTextureRec_1');
292 xreadTtexturerec_1();
293 end;
295 procedure mb_Read_TPanelRec_1 (var tr: TPanelRec_1; const buf; bufsize: Integer);
296 procedure xreadTpanelrec_1 ();
297 begin
298 getIntAt(tr.X, buf, 0);
299 getIntAt(tr.Y, buf, 4);
300 getWordAt(tr.Width, buf, 8);
301 getWordAt(tr.Height, buf, 10);
302 getWordAt(tr.TextureNum, buf, 12);
303 getWordAt(tr.PanelType, buf, 14);
304 getBytesAt(tr.Alpha, buf, 16, 1);
305 getBytesAt(tr.Flags, buf, 17, 1);
306 end;
308 begin
309 if (bufsize < 18) then raise Exception.Create('invalid buffer size in readTPanelRec_1');
310 xreadTpanelrec_1();
311 end;
313 procedure mb_Read_TItemRec_1 (var tr: TItemRec_1; const buf; bufsize: Integer);
314 procedure xreadTitemrec_1 ();
315 begin
316 getIntAt(tr.X, buf, 0);
317 getIntAt(tr.Y, buf, 4);
318 getBytesAt(tr.ItemType, buf, 8, 1);
319 getBytesAt(tr.Options, buf, 9, 1);
320 end;
322 begin
323 if (bufsize < 10) then raise Exception.Create('invalid buffer size in readTItemRec_1');
324 xreadTitemrec_1();
325 end;
327 procedure mb_Read_TMonsterRec_1 (var tr: TMonsterRec_1; const buf; bufsize: Integer);
328 procedure xreadTmonsterrec_1 ();
329 begin
330 getIntAt(tr.X, buf, 0);
331 getIntAt(tr.Y, buf, 4);
332 getBytesAt(tr.MonsterType, buf, 8, 1);
333 getBytesAt(tr.Direction, buf, 9, 1);
334 end;
336 begin
337 if (bufsize < 10) then raise Exception.Create('invalid buffer size in readTMonsterRec_1');
338 xreadTmonsterrec_1();
339 end;
341 procedure mb_Read_TAreaRec_1 (var tr: TAreaRec_1; const buf; bufsize: Integer);
342 procedure xreadTarearec_1 ();
343 begin
344 getIntAt(tr.X, buf, 0);
345 getIntAt(tr.Y, buf, 4);
346 getBytesAt(tr.AreaType, buf, 8, 1);
347 getBytesAt(tr.Direction, buf, 9, 1);
348 end;
350 begin
351 if (bufsize < 10) then raise Exception.Create('invalid buffer size in readTAreaRec_1');
352 xreadTarearec_1();
353 end;
355 procedure mb_Read_TTriggerRec_1 (var tr: TTriggerRec_1; const buf; bufsize: Integer);
356 procedure xreadTtriggerrec_1 ();
357 begin
358 getIntAt(tr.X, buf, 0);
359 getIntAt(tr.Y, buf, 4);
360 getWordAt(tr.Width, buf, 8);
361 getWordAt(tr.Height, buf, 10);
362 getBytesAt(tr.Enabled, buf, 12, 1);
363 getIntAt(tr.TexturePanel, buf, 13);
364 getBytesAt(tr.TriggerType, buf, 17, 1);
365 getBytesAt(tr.ActivateType, buf, 18, 1);
366 getBytesAt(tr.Keys, buf, 19, 1);
367 getBytesAt(tr.DATA, buf, 20, 128);
368 end;
370 begin
371 if (bufsize < 148) then raise Exception.Create('invalid buffer size in readTTriggerRec_1');
372 xreadTtriggerrec_1();
373 end;
375 procedure mb_Write_TriggerData (var buf; bufsize: Integer; ttype: Integer; var tr: TTriggerData);
376 procedure xwriteExit ();
377 begin
378 putBytesAt(buf, 0, tr.MapName, 16);
379 end;
381 procedure xwriteTeleport ();
382 begin
383 putIntAt(buf, 0, tr.TargetPoint.x);
384 putIntAt(buf, 4, tr.TargetPoint.y);
385 putBytesAt(buf, 8, tr.d2d_teleport, 1);
386 putBytesAt(buf, 9, tr.silent_teleport, 1);
387 putBytesAt(buf, 10, tr.TlpDir, 1);
388 end;
390 procedure xwriteOpendoor ();
391 begin
392 putIntAt(buf, 0, tr.PanelID);
393 putBytesAt(buf, 4, tr.NoSound, 1);
394 putBytesAt(buf, 5, tr.d2d_doors, 1);
395 end;
397 procedure xwritePress ();
398 begin
399 putIntAt(buf, 0, tr.tX);
400 putIntAt(buf, 4, tr.tY);
401 putWordAt(buf, 8, tr.tWidth);
402 putWordAt(buf, 10, tr.tHeight);
403 putWordAt(buf, 12, tr.Wait);
404 putWordAt(buf, 14, tr.Count);
405 putIntAt(buf, 16, tr.MonsterID);
406 putBytesAt(buf, 20, tr.ExtRandom, 1);
407 end;
409 procedure xwriteSecret ();
410 begin
411 end;
413 procedure xwriteTexture ();
414 begin
415 putBytesAt(buf, 0, tr.ActivateOnce, 1);
416 putBytesAt(buf, 1, tr.AnimOnce, 1);
417 end;
419 procedure xwriteSound ();
420 begin
421 putBytesAt(buf, 0, tr.SoundName, 64);
422 putBytesAt(buf, 64, tr.Volume, 1);
423 putBytesAt(buf, 65, tr.Pan, 1);
424 putBytesAt(buf, 66, tr.Local, 1);
425 putBytesAt(buf, 67, tr.PlayCount, 1);
426 putBytesAt(buf, 68, tr.SoundSwitch, 1);
427 end;
429 procedure xwriteSpawnmonster ();
430 begin
431 putIntAt(buf, 0, tr.MonPos.x);
432 putIntAt(buf, 4, tr.MonPos.y);
433 putBytesAt(buf, 8, tr.MonType, 1);
434 putIntAt(buf, 12, tr.MonHealth);
435 putBytesAt(buf, 16, tr.MonDir, 1);
436 putBytesAt(buf, 17, tr.MonActive, 1);
437 putIntAt(buf, 20, tr.MonCount);
438 putBytesAt(buf, 24, tr.MonEffect, 1);
439 putWordAt(buf, 26, tr.MonMax);
440 putWordAt(buf, 28, tr.MonDelay);
441 putBytesAt(buf, 30, tr.MonBehav, 1);
442 end;
444 procedure xwriteSpawnitem ();
445 begin
446 putIntAt(buf, 0, tr.ItemPos.x);
447 putIntAt(buf, 4, tr.ItemPos.y);
448 putBytesAt(buf, 8, tr.ItemType, 1);
449 putBytesAt(buf, 9, tr.ItemFalls, 1);
450 putBytesAt(buf, 10, tr.ItemOnlyDM, 1);
451 putIntAt(buf, 12, tr.ItemCount);
452 putBytesAt(buf, 16, tr.ItemEffect, 1);
453 putWordAt(buf, 18, tr.ItemMax);
454 putWordAt(buf, 20, tr.ItemDelay);
455 end;
457 procedure xwriteMusic ();
458 begin
459 putBytesAt(buf, 0, tr.MusicName, 64);
460 putBytesAt(buf, 64, tr.MusicAction, 1);
461 end;
463 procedure xwritePush ();
464 begin
465 putWordAt(buf, 0, tr.PushAngle);
466 putBytesAt(buf, 2, tr.PushForce, 1);
467 putBytesAt(buf, 3, tr.ResetVel, 1);
468 end;
470 procedure xwriteScore ();
471 begin
472 putBytesAt(buf, 0, tr.ScoreAction, 1);
473 putBytesAt(buf, 1, tr.ScoreCount, 1);
474 putBytesAt(buf, 2, tr.ScoreTeam, 1);
475 putBytesAt(buf, 3, tr.ScoreCon, 1);
476 putBytesAt(buf, 4, tr.ScoreMsg, 1);
477 end;
479 procedure xwriteMessage ();
480 begin
481 putBytesAt(buf, 0, tr.MessageKind, 1);
482 putBytesAt(buf, 1, tr.MessageSendTo, 1);
483 putBytesAt(buf, 2, tr.MessageText, 100);
484 putWordAt(buf, 102, tr.MessageTime);
485 end;
487 procedure xwriteDamage ();
488 begin
489 putWordAt(buf, 0, tr.DamageValue);
490 putWordAt(buf, 2, tr.DamageInterval);
491 end;
493 procedure xwriteHealth ();
494 begin
495 putWordAt(buf, 0, tr.HealValue);
496 putWordAt(buf, 2, tr.HealInterval);
497 putBytesAt(buf, 4, tr.HealMax, 1);
498 putBytesAt(buf, 5, tr.HealSilent, 1);
499 end;
501 procedure xwriteShot ();
502 begin
503 putIntAt(buf, 0, tr.ShotPos.x);
504 putIntAt(buf, 4, tr.ShotPos.y);
505 putBytesAt(buf, 8, tr.ShotType, 1);
506 putBytesAt(buf, 9, tr.ShotTarget, 1);
507 putBytesAt(buf, 10, tr.ShotSound, 1);
508 putBytesAt(buf, 11, tr.ShotAllMap, 1);
509 putIntAt(buf, 12, tr.ShotPanelID);
510 putWordAt(buf, 16, tr.ShotIntSight);
511 putWordAt(buf, 18, tr.ShotAngle);
512 putWordAt(buf, 20, tr.ShotWait);
513 putWordAt(buf, 22, tr.ShotAccuracy);
514 putWordAt(buf, 24, tr.ShotAmmo);
515 putWordAt(buf, 26, tr.ShotIntReload);
516 end;
518 procedure xwriteEffect ();
519 begin
520 putBytesAt(buf, 0, tr.FXCount, 1);
521 putBytesAt(buf, 1, tr.FXType, 1);
522 putBytesAt(buf, 2, tr.FXSubType, 1);
523 putBytesAt(buf, 3, tr.FXColorR, 1);
524 putBytesAt(buf, 4, tr.FXColorG, 1);
525 putBytesAt(buf, 5, tr.FXColorB, 1);
526 putBytesAt(buf, 6, tr.FXPos, 1);
527 putWordAt(buf, 8, tr.FXWait);
528 putBytesAt(buf, 10, tr.FXVelX, 1);
529 putBytesAt(buf, 11, tr.FXVelY, 1);
530 putBytesAt(buf, 12, tr.FXSpreadL, 1);
531 putBytesAt(buf, 13, tr.FXSpreadR, 1);
532 putBytesAt(buf, 14, tr.FXSpreadU, 1);
533 putBytesAt(buf, 15, tr.FXSpreadD, 1);
534 end;
536 begin
537 if (bufsize < 104) then raise Exception.Create('invalid buffer size in mb_Write_TriggerData');
538 if (ttype = TRIGGER_EXIT) then begin xwriteExit(); exit; end;
539 if (ttype = TRIGGER_TELEPORT) then begin xwriteTeleport(); exit; end;
540 if (ttype = TRIGGER_OPENDOOR) then begin xwriteOpendoor(); exit; end;
541 if (ttype = TRIGGER_CLOSEDOOR) then begin xwriteOpendoor(); exit; end;
542 if (ttype = TRIGGER_DOOR) then begin xwriteOpendoor(); exit; end;
543 if (ttype = TRIGGER_DOOR5) then begin xwriteOpendoor(); exit; end;
544 if (ttype = TRIGGER_CLOSETRAP) then begin xwriteOpendoor(); exit; end;
545 if (ttype = TRIGGER_TRAP) then begin xwriteOpendoor(); exit; end;
546 if (ttype = TRIGGER_LIFTUP) then begin xwriteOpendoor(); exit; end;
547 if (ttype = TRIGGER_LIFTDOWN) then begin xwriteOpendoor(); exit; end;
548 if (ttype = TRIGGER_LIFT) then begin xwriteOpendoor(); exit; end;
549 if (ttype = TRIGGER_PRESS) then begin xwritePress(); exit; end;
550 if (ttype = TRIGGER_ON) then begin xwritePress(); exit; end;
551 if (ttype = TRIGGER_OFF) then begin xwritePress(); exit; end;
552 if (ttype = TRIGGER_ONOFF) then begin xwritePress(); exit; end;
553 if (ttype = TRIGGER_SECRET) then begin xwriteSecret(); exit; end;
554 if (ttype = TRIGGER_TEXTURE) then begin xwriteTexture(); exit; end;
555 if (ttype = TRIGGER_SOUND) then begin xwriteSound(); exit; end;
556 if (ttype = TRIGGER_SPAWNMONSTER) then begin xwriteSpawnmonster(); exit; end;
557 if (ttype = TRIGGER_SPAWNITEM) then begin xwriteSpawnitem(); exit; end;
558 if (ttype = TRIGGER_MUSIC) then begin xwriteMusic(); exit; end;
559 if (ttype = TRIGGER_PUSH) then begin xwritePush(); exit; end;
560 if (ttype = TRIGGER_SCORE) then begin xwriteScore(); exit; end;
561 if (ttype = TRIGGER_MESSAGE) then begin xwriteMessage(); exit; end;
562 if (ttype = TRIGGER_DAMAGE) then begin xwriteDamage(); exit; end;
563 if (ttype = TRIGGER_HEALTH) then begin xwriteHealth(); exit; end;
564 if (ttype = TRIGGER_SHOT) then begin xwriteShot(); exit; end;
565 if (ttype = TRIGGER_EFFECT) then begin xwriteEffect(); exit; end;
566 raise Exception.Create('invalid trigger type in mb_Write_TriggerData');
567 end;
570 procedure mb_Write_TMapHeaderRec_1 (var buf; bufsize: Integer; var tr: TMapHeaderRec_1);
571 procedure xwriteTmapheaderrec_1 ();
572 begin
573 putBytesAt(buf, 0, tr.MapName, 32);
574 putBytesAt(buf, 32, tr.MapAuthor, 32);
575 putBytesAt(buf, 64, tr.MapDescription, 256);
576 putBytesAt(buf, 320, tr.MusicName, 64);
577 putBytesAt(buf, 384, tr.SkyName, 64);
578 putWordAt(buf, 448, tr.Width);
579 putWordAt(buf, 450, tr.Height);
580 end;
582 begin
583 if (bufsize < 452) then raise Exception.Create('invalid buffer size in writeTMapHeaderRec_1');
584 xwriteTmapheaderrec_1();
585 end;
587 procedure mb_Write_TTextureRec_1 (var buf; bufsize: Integer; var tr: TTextureRec_1);
588 procedure xwriteTtexturerec_1 ();
589 begin
590 putBytesAt(buf, 0, tr.Resource, 64);
591 putBytesAt(buf, 64, tr.Anim, 1);
592 end;
594 begin
595 if (bufsize < 65) then raise Exception.Create('invalid buffer size in writeTTextureRec_1');
596 xwriteTtexturerec_1();
597 end;
599 procedure mb_Write_TPanelRec_1 (var buf; bufsize: Integer; var tr: TPanelRec_1);
600 procedure xwriteTpanelrec_1 ();
601 begin
602 putIntAt(buf, 0, tr.X);
603 putIntAt(buf, 4, tr.Y);
604 putWordAt(buf, 8, tr.Width);
605 putWordAt(buf, 10, tr.Height);
606 putWordAt(buf, 12, tr.TextureNum);
607 putWordAt(buf, 14, tr.PanelType);
608 putBytesAt(buf, 16, tr.Alpha, 1);
609 putBytesAt(buf, 17, tr.Flags, 1);
610 end;
612 begin
613 if (bufsize < 18) then raise Exception.Create('invalid buffer size in writeTPanelRec_1');
614 xwriteTpanelrec_1();
615 end;
617 procedure mb_Write_TItemRec_1 (var buf; bufsize: Integer; var tr: TItemRec_1);
618 procedure xwriteTitemrec_1 ();
619 begin
620 putIntAt(buf, 0, tr.X);
621 putIntAt(buf, 4, tr.Y);
622 putBytesAt(buf, 8, tr.ItemType, 1);
623 putBytesAt(buf, 9, tr.Options, 1);
624 end;
626 begin
627 if (bufsize < 10) then raise Exception.Create('invalid buffer size in writeTItemRec_1');
628 xwriteTitemrec_1();
629 end;
631 procedure mb_Write_TMonsterRec_1 (var buf; bufsize: Integer; var tr: TMonsterRec_1);
632 procedure xwriteTmonsterrec_1 ();
633 begin
634 putIntAt(buf, 0, tr.X);
635 putIntAt(buf, 4, tr.Y);
636 putBytesAt(buf, 8, tr.MonsterType, 1);
637 putBytesAt(buf, 9, tr.Direction, 1);
638 end;
640 begin
641 if (bufsize < 10) then raise Exception.Create('invalid buffer size in writeTMonsterRec_1');
642 xwriteTmonsterrec_1();
643 end;
645 procedure mb_Write_TAreaRec_1 (var buf; bufsize: Integer; var tr: TAreaRec_1);
646 procedure xwriteTarearec_1 ();
647 begin
648 putIntAt(buf, 0, tr.X);
649 putIntAt(buf, 4, tr.Y);
650 putBytesAt(buf, 8, tr.AreaType, 1);
651 putBytesAt(buf, 9, tr.Direction, 1);
652 end;
654 begin
655 if (bufsize < 10) then raise Exception.Create('invalid buffer size in writeTAreaRec_1');
656 xwriteTarearec_1();
657 end;
659 procedure mb_Write_TTriggerRec_1 (var buf; bufsize: Integer; var tr: TTriggerRec_1);
660 procedure xwriteTtriggerrec_1 ();
661 begin
662 putIntAt(buf, 0, tr.X);
663 putIntAt(buf, 4, tr.Y);
664 putWordAt(buf, 8, tr.Width);
665 putWordAt(buf, 10, tr.Height);
666 putBytesAt(buf, 12, tr.Enabled, 1);
667 putIntAt(buf, 13, tr.TexturePanel);
668 putBytesAt(buf, 17, tr.TriggerType, 1);
669 putBytesAt(buf, 18, tr.ActivateType, 1);
670 putBytesAt(buf, 19, tr.Keys, 1);
671 putBytesAt(buf, 20, tr.DATA, 128);
672 end;
674 begin
675 if (bufsize < 148) then raise Exception.Create('invalid buffer size in writeTTriggerRec_1');
676 xwriteTtriggerrec_1();
677 end;