DEADSOFTWARE

Add contours
[d2df-editor.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 procedure xreadScript ();
233 begin
234 getBytesAt(tr.SCRProc, buf, 0, 64);
235 getIntAt(tr.SCRArg, buf, 64);
236 end;
238 begin
239 if (bufsize < 104) then raise Exception.Create('invalid buffer size in mb_Read_TriggerData');
240 if (ttype = TRIGGER_EXIT) then begin xreadExit(); exit; end;
241 if (ttype = TRIGGER_TELEPORT) then begin xreadTeleport(); exit; end;
242 if (ttype = TRIGGER_OPENDOOR) then begin xreadOpendoor(); exit; end;
243 if (ttype = TRIGGER_CLOSEDOOR) then begin xreadOpendoor(); exit; end;
244 if (ttype = TRIGGER_DOOR) then begin xreadOpendoor(); exit; end;
245 if (ttype = TRIGGER_DOOR5) then begin xreadOpendoor(); exit; end;
246 if (ttype = TRIGGER_CLOSETRAP) then begin xreadOpendoor(); exit; end;
247 if (ttype = TRIGGER_TRAP) then begin xreadOpendoor(); exit; end;
248 if (ttype = TRIGGER_LIFTUP) then begin xreadOpendoor(); exit; end;
249 if (ttype = TRIGGER_LIFTDOWN) then begin xreadOpendoor(); exit; end;
250 if (ttype = TRIGGER_LIFT) then begin xreadOpendoor(); exit; end;
251 if (ttype = TRIGGER_PRESS) then begin xreadPress(); exit; end;
252 if (ttype = TRIGGER_ON) then begin xreadPress(); exit; end;
253 if (ttype = TRIGGER_OFF) then begin xreadPress(); exit; end;
254 if (ttype = TRIGGER_ONOFF) then begin xreadPress(); exit; end;
255 if (ttype = TRIGGER_SECRET) then begin xreadSecret(); exit; end;
256 if (ttype = TRIGGER_TEXTURE) then begin xreadTexture(); exit; end;
257 if (ttype = TRIGGER_SOUND) then begin xreadSound(); exit; end;
258 if (ttype = TRIGGER_SPAWNMONSTER) then begin xreadSpawnmonster(); exit; end;
259 if (ttype = TRIGGER_SPAWNITEM) then begin xreadSpawnitem(); exit; end;
260 if (ttype = TRIGGER_MUSIC) then begin xreadMusic(); exit; end;
261 if (ttype = TRIGGER_PUSH) then begin xreadPush(); exit; end;
262 if (ttype = TRIGGER_SCORE) then begin xreadScore(); exit; end;
263 if (ttype = TRIGGER_MESSAGE) then begin xreadMessage(); exit; end;
264 if (ttype = TRIGGER_DAMAGE) then begin xreadDamage(); exit; end;
265 if (ttype = TRIGGER_HEALTH) then begin xreadHealth(); exit; end;
266 if (ttype = TRIGGER_SHOT) then begin xreadShot(); exit; end;
267 if (ttype = TRIGGER_EFFECT) then begin xreadEffect(); exit; end;
268 if (ttype = TRIGGER_SCRIPT) then begin xreadScript(); exit; end;
269 raise Exception.Create('invalid trigger type in mb_Read_TriggerData');
270 end;
273 procedure mb_Read_TMapHeaderRec_1 (var tr: TMapHeaderRec_1; const buf; bufsize: Integer);
274 procedure xreadTmapheaderrec_1 ();
275 begin
276 getBytesAt(tr.MapName, buf, 0, 32);
277 getBytesAt(tr.MapAuthor, buf, 32, 32);
278 getBytesAt(tr.MapDescription, buf, 64, 256);
279 getBytesAt(tr.MusicName, buf, 320, 64);
280 getBytesAt(tr.SkyName, buf, 384, 64);
281 getWordAt(tr.Width, buf, 448);
282 getWordAt(tr.Height, buf, 450);
283 end;
285 begin
286 if (bufsize < 452) then raise Exception.Create('invalid buffer size in readTMapHeaderRec_1');
287 xreadTmapheaderrec_1();
288 end;
290 procedure mb_Read_TTextureRec_1 (var tr: TTextureRec_1; const buf; bufsize: Integer);
291 procedure xreadTtexturerec_1 ();
292 begin
293 getBytesAt(tr.Resource, buf, 0, 64);
294 getBytesAt(tr.Anim, buf, 64, 1);
295 end;
297 begin
298 if (bufsize < 65) then raise Exception.Create('invalid buffer size in readTTextureRec_1');
299 xreadTtexturerec_1();
300 end;
302 procedure mb_Read_TPanelRec_1 (var tr: TPanelRec_1; const buf; bufsize: Integer);
303 procedure xreadTpanelrec_1 ();
304 begin
305 getIntAt(tr.X, buf, 0);
306 getIntAt(tr.Y, buf, 4);
307 getWordAt(tr.Width, buf, 8);
308 getWordAt(tr.Height, buf, 10);
309 getWordAt(tr.TextureNum, buf, 12);
310 getWordAt(tr.PanelType, buf, 14);
311 getBytesAt(tr.Alpha, buf, 16, 1);
312 getBytesAt(tr.Flags, buf, 17, 1);
313 end;
315 begin
316 if (bufsize < 18) then raise Exception.Create('invalid buffer size in readTPanelRec_1');
317 xreadTpanelrec_1();
318 end;
320 procedure mb_Read_TItemRec_1 (var tr: TItemRec_1; const buf; bufsize: Integer);
321 procedure xreadTitemrec_1 ();
322 begin
323 getIntAt(tr.X, buf, 0);
324 getIntAt(tr.Y, buf, 4);
325 getBytesAt(tr.ItemType, buf, 8, 1);
326 getBytesAt(tr.Options, buf, 9, 1);
327 end;
329 begin
330 if (bufsize < 10) then raise Exception.Create('invalid buffer size in readTItemRec_1');
331 xreadTitemrec_1();
332 end;
334 procedure mb_Read_TMonsterRec_1 (var tr: TMonsterRec_1; const buf; bufsize: Integer);
335 procedure xreadTmonsterrec_1 ();
336 begin
337 getIntAt(tr.X, buf, 0);
338 getIntAt(tr.Y, buf, 4);
339 getBytesAt(tr.MonsterType, buf, 8, 1);
340 getBytesAt(tr.Direction, buf, 9, 1);
341 end;
343 begin
344 if (bufsize < 10) then raise Exception.Create('invalid buffer size in readTMonsterRec_1');
345 xreadTmonsterrec_1();
346 end;
348 procedure mb_Read_TAreaRec_1 (var tr: TAreaRec_1; const buf; bufsize: Integer);
349 procedure xreadTarearec_1 ();
350 begin
351 getIntAt(tr.X, buf, 0);
352 getIntAt(tr.Y, buf, 4);
353 getBytesAt(tr.AreaType, buf, 8, 1);
354 getBytesAt(tr.Direction, buf, 9, 1);
355 end;
357 begin
358 if (bufsize < 10) then raise Exception.Create('invalid buffer size in readTAreaRec_1');
359 xreadTarearec_1();
360 end;
362 procedure mb_Read_TTriggerRec_1 (var tr: TTriggerRec_1; const buf; bufsize: Integer);
363 procedure xreadTtriggerrec_1 ();
364 begin
365 getIntAt(tr.X, buf, 0);
366 getIntAt(tr.Y, buf, 4);
367 getWordAt(tr.Width, buf, 8);
368 getWordAt(tr.Height, buf, 10);
369 getBytesAt(tr.Enabled, buf, 12, 1);
370 getIntAt(tr.TexturePanel, buf, 13);
371 getBytesAt(tr.TriggerType, buf, 17, 1);
372 getBytesAt(tr.ActivateType, buf, 18, 1);
373 getBytesAt(tr.Keys, buf, 19, 1);
374 getBytesAt(tr.DATA, buf, 20, 128);
375 end;
377 begin
378 if (bufsize < 148) then raise Exception.Create('invalid buffer size in readTTriggerRec_1');
379 xreadTtriggerrec_1();
380 end;
382 procedure mb_Write_TriggerData (var buf; bufsize: Integer; ttype: Integer; var tr: TTriggerData);
383 procedure xwriteExit ();
384 begin
385 putBytesAt(buf, 0, tr.MapName, 16);
386 end;
388 procedure xwriteTeleport ();
389 begin
390 putIntAt(buf, 0, tr.TargetPoint.x);
391 putIntAt(buf, 4, tr.TargetPoint.y);
392 putBytesAt(buf, 8, tr.d2d_teleport, 1);
393 putBytesAt(buf, 9, tr.silent_teleport, 1);
394 putBytesAt(buf, 10, tr.TlpDir, 1);
395 end;
397 procedure xwriteOpendoor ();
398 begin
399 putIntAt(buf, 0, tr.PanelID);
400 putBytesAt(buf, 4, tr.NoSound, 1);
401 putBytesAt(buf, 5, tr.d2d_doors, 1);
402 end;
404 procedure xwritePress ();
405 begin
406 putIntAt(buf, 0, tr.tX);
407 putIntAt(buf, 4, tr.tY);
408 putWordAt(buf, 8, tr.tWidth);
409 putWordAt(buf, 10, tr.tHeight);
410 putWordAt(buf, 12, tr.Wait);
411 putWordAt(buf, 14, tr.Count);
412 putIntAt(buf, 16, tr.MonsterID);
413 putBytesAt(buf, 20, tr.ExtRandom, 1);
414 end;
416 procedure xwriteSecret ();
417 begin
418 end;
420 procedure xwriteTexture ();
421 begin
422 putBytesAt(buf, 0, tr.ActivateOnce, 1);
423 putBytesAt(buf, 1, tr.AnimOnce, 1);
424 end;
426 procedure xwriteSound ();
427 begin
428 putBytesAt(buf, 0, tr.SoundName, 64);
429 putBytesAt(buf, 64, tr.Volume, 1);
430 putBytesAt(buf, 65, tr.Pan, 1);
431 putBytesAt(buf, 66, tr.Local, 1);
432 putBytesAt(buf, 67, tr.PlayCount, 1);
433 putBytesAt(buf, 68, tr.SoundSwitch, 1);
434 end;
436 procedure xwriteSpawnmonster ();
437 begin
438 putIntAt(buf, 0, tr.MonPos.x);
439 putIntAt(buf, 4, tr.MonPos.y);
440 putBytesAt(buf, 8, tr.MonType, 1);
441 putIntAt(buf, 12, tr.MonHealth);
442 putBytesAt(buf, 16, tr.MonDir, 1);
443 putBytesAt(buf, 17, tr.MonActive, 1);
444 putIntAt(buf, 20, tr.MonCount);
445 putBytesAt(buf, 24, tr.MonEffect, 1);
446 putWordAt(buf, 26, tr.MonMax);
447 putWordAt(buf, 28, tr.MonDelay);
448 putBytesAt(buf, 30, tr.MonBehav, 1);
449 end;
451 procedure xwriteSpawnitem ();
452 begin
453 putIntAt(buf, 0, tr.ItemPos.x);
454 putIntAt(buf, 4, tr.ItemPos.y);
455 putBytesAt(buf, 8, tr.ItemType, 1);
456 putBytesAt(buf, 9, tr.ItemFalls, 1);
457 putBytesAt(buf, 10, tr.ItemOnlyDM, 1);
458 putIntAt(buf, 12, tr.ItemCount);
459 putBytesAt(buf, 16, tr.ItemEffect, 1);
460 putWordAt(buf, 18, tr.ItemMax);
461 putWordAt(buf, 20, tr.ItemDelay);
462 end;
464 procedure xwriteMusic ();
465 begin
466 putBytesAt(buf, 0, tr.MusicName, 64);
467 putBytesAt(buf, 64, tr.MusicAction, 1);
468 end;
470 procedure xwritePush ();
471 begin
472 putWordAt(buf, 0, tr.PushAngle);
473 putBytesAt(buf, 2, tr.PushForce, 1);
474 putBytesAt(buf, 3, tr.ResetVel, 1);
475 end;
477 procedure xwriteScore ();
478 begin
479 putBytesAt(buf, 0, tr.ScoreAction, 1);
480 putBytesAt(buf, 1, tr.ScoreCount, 1);
481 putBytesAt(buf, 2, tr.ScoreTeam, 1);
482 putBytesAt(buf, 3, tr.ScoreCon, 1);
483 putBytesAt(buf, 4, tr.ScoreMsg, 1);
484 end;
486 procedure xwriteMessage ();
487 begin
488 putBytesAt(buf, 0, tr.MessageKind, 1);
489 putBytesAt(buf, 1, tr.MessageSendTo, 1);
490 putBytesAt(buf, 2, tr.MessageText, 100);
491 putWordAt(buf, 102, tr.MessageTime);
492 end;
494 procedure xwriteDamage ();
495 begin
496 putWordAt(buf, 0, tr.DamageValue);
497 putWordAt(buf, 2, tr.DamageInterval);
498 end;
500 procedure xwriteHealth ();
501 begin
502 putWordAt(buf, 0, tr.HealValue);
503 putWordAt(buf, 2, tr.HealInterval);
504 putBytesAt(buf, 4, tr.HealMax, 1);
505 putBytesAt(buf, 5, tr.HealSilent, 1);
506 end;
508 procedure xwriteShot ();
509 begin
510 putIntAt(buf, 0, tr.ShotPos.x);
511 putIntAt(buf, 4, tr.ShotPos.y);
512 putBytesAt(buf, 8, tr.ShotType, 1);
513 putBytesAt(buf, 9, tr.ShotTarget, 1);
514 putBytesAt(buf, 10, tr.ShotSound, 1);
515 putBytesAt(buf, 11, tr.ShotAllMap, 1);
516 putIntAt(buf, 12, tr.ShotPanelID);
517 putWordAt(buf, 16, tr.ShotIntSight);
518 putWordAt(buf, 18, tr.ShotAngle);
519 putWordAt(buf, 20, tr.ShotWait);
520 putWordAt(buf, 22, tr.ShotAccuracy);
521 putWordAt(buf, 24, tr.ShotAmmo);
522 putWordAt(buf, 26, tr.ShotIntReload);
523 end;
525 procedure xwriteEffect ();
526 begin
527 putBytesAt(buf, 0, tr.FXCount, 1);
528 putBytesAt(buf, 1, tr.FXType, 1);
529 putBytesAt(buf, 2, tr.FXSubType, 1);
530 putBytesAt(buf, 3, tr.FXColorR, 1);
531 putBytesAt(buf, 4, tr.FXColorG, 1);
532 putBytesAt(buf, 5, tr.FXColorB, 1);
533 putBytesAt(buf, 6, tr.FXPos, 1);
534 putWordAt(buf, 8, tr.FXWait);
535 putBytesAt(buf, 10, tr.FXVelX, 1);
536 putBytesAt(buf, 11, tr.FXVelY, 1);
537 putBytesAt(buf, 12, tr.FXSpreadL, 1);
538 putBytesAt(buf, 13, tr.FXSpreadR, 1);
539 putBytesAt(buf, 14, tr.FXSpreadU, 1);
540 putBytesAt(buf, 15, tr.FXSpreadD, 1);
541 end;
543 begin
544 if (bufsize < 104) then raise Exception.Create('invalid buffer size in mb_Write_TriggerData');
545 if (ttype = TRIGGER_EXIT) then begin xwriteExit(); exit; end;
546 if (ttype = TRIGGER_TELEPORT) then begin xwriteTeleport(); exit; end;
547 if (ttype = TRIGGER_OPENDOOR) then begin xwriteOpendoor(); exit; end;
548 if (ttype = TRIGGER_CLOSEDOOR) then begin xwriteOpendoor(); exit; end;
549 if (ttype = TRIGGER_DOOR) then begin xwriteOpendoor(); exit; end;
550 if (ttype = TRIGGER_DOOR5) then begin xwriteOpendoor(); exit; end;
551 if (ttype = TRIGGER_CLOSETRAP) then begin xwriteOpendoor(); exit; end;
552 if (ttype = TRIGGER_TRAP) then begin xwriteOpendoor(); exit; end;
553 if (ttype = TRIGGER_LIFTUP) then begin xwriteOpendoor(); exit; end;
554 if (ttype = TRIGGER_LIFTDOWN) then begin xwriteOpendoor(); exit; end;
555 if (ttype = TRIGGER_LIFT) then begin xwriteOpendoor(); exit; end;
556 if (ttype = TRIGGER_PRESS) then begin xwritePress(); exit; end;
557 if (ttype = TRIGGER_ON) then begin xwritePress(); exit; end;
558 if (ttype = TRIGGER_OFF) then begin xwritePress(); exit; end;
559 if (ttype = TRIGGER_ONOFF) then begin xwritePress(); exit; end;
560 if (ttype = TRIGGER_SECRET) then begin xwriteSecret(); exit; end;
561 if (ttype = TRIGGER_TEXTURE) then begin xwriteTexture(); exit; end;
562 if (ttype = TRIGGER_SOUND) then begin xwriteSound(); exit; end;
563 if (ttype = TRIGGER_SPAWNMONSTER) then begin xwriteSpawnmonster(); exit; end;
564 if (ttype = TRIGGER_SPAWNITEM) then begin xwriteSpawnitem(); exit; end;
565 if (ttype = TRIGGER_MUSIC) then begin xwriteMusic(); exit; end;
566 if (ttype = TRIGGER_PUSH) then begin xwritePush(); exit; end;
567 if (ttype = TRIGGER_SCORE) then begin xwriteScore(); exit; end;
568 if (ttype = TRIGGER_MESSAGE) then begin xwriteMessage(); exit; end;
569 if (ttype = TRIGGER_DAMAGE) then begin xwriteDamage(); exit; end;
570 if (ttype = TRIGGER_HEALTH) then begin xwriteHealth(); exit; end;
571 if (ttype = TRIGGER_SHOT) then begin xwriteShot(); exit; end;
572 if (ttype = TRIGGER_EFFECT) then begin xwriteEffect(); exit; end;
573 raise Exception.Create('invalid trigger type in mb_Write_TriggerData');
574 end;
577 procedure mb_Write_TMapHeaderRec_1 (var buf; bufsize: Integer; var tr: TMapHeaderRec_1);
578 procedure xwriteTmapheaderrec_1 ();
579 begin
580 putBytesAt(buf, 0, tr.MapName, 32);
581 putBytesAt(buf, 32, tr.MapAuthor, 32);
582 putBytesAt(buf, 64, tr.MapDescription, 256);
583 putBytesAt(buf, 320, tr.MusicName, 64);
584 putBytesAt(buf, 384, tr.SkyName, 64);
585 putWordAt(buf, 448, tr.Width);
586 putWordAt(buf, 450, tr.Height);
587 end;
589 begin
590 if (bufsize < 452) then raise Exception.Create('invalid buffer size in writeTMapHeaderRec_1');
591 xwriteTmapheaderrec_1();
592 end;
594 procedure mb_Write_TTextureRec_1 (var buf; bufsize: Integer; var tr: TTextureRec_1);
595 procedure xwriteTtexturerec_1 ();
596 begin
597 putBytesAt(buf, 0, tr.Resource, 64);
598 putBytesAt(buf, 64, tr.Anim, 1);
599 end;
601 begin
602 if (bufsize < 65) then raise Exception.Create('invalid buffer size in writeTTextureRec_1');
603 xwriteTtexturerec_1();
604 end;
606 procedure mb_Write_TPanelRec_1 (var buf; bufsize: Integer; var tr: TPanelRec_1);
607 procedure xwriteTpanelrec_1 ();
608 begin
609 putIntAt(buf, 0, tr.X);
610 putIntAt(buf, 4, tr.Y);
611 putWordAt(buf, 8, tr.Width);
612 putWordAt(buf, 10, tr.Height);
613 putWordAt(buf, 12, tr.TextureNum);
614 putWordAt(buf, 14, tr.PanelType);
615 putBytesAt(buf, 16, tr.Alpha, 1);
616 putBytesAt(buf, 17, tr.Flags, 1);
617 end;
619 begin
620 if (bufsize < 18) then raise Exception.Create('invalid buffer size in writeTPanelRec_1');
621 xwriteTpanelrec_1();
622 end;
624 procedure mb_Write_TItemRec_1 (var buf; bufsize: Integer; var tr: TItemRec_1);
625 procedure xwriteTitemrec_1 ();
626 begin
627 putIntAt(buf, 0, tr.X);
628 putIntAt(buf, 4, tr.Y);
629 putBytesAt(buf, 8, tr.ItemType, 1);
630 putBytesAt(buf, 9, tr.Options, 1);
631 end;
633 begin
634 if (bufsize < 10) then raise Exception.Create('invalid buffer size in writeTItemRec_1');
635 xwriteTitemrec_1();
636 end;
638 procedure mb_Write_TMonsterRec_1 (var buf; bufsize: Integer; var tr: TMonsterRec_1);
639 procedure xwriteTmonsterrec_1 ();
640 begin
641 putIntAt(buf, 0, tr.X);
642 putIntAt(buf, 4, tr.Y);
643 putBytesAt(buf, 8, tr.MonsterType, 1);
644 putBytesAt(buf, 9, tr.Direction, 1);
645 end;
647 begin
648 if (bufsize < 10) then raise Exception.Create('invalid buffer size in writeTMonsterRec_1');
649 xwriteTmonsterrec_1();
650 end;
652 procedure mb_Write_TAreaRec_1 (var buf; bufsize: Integer; var tr: TAreaRec_1);
653 procedure xwriteTarearec_1 ();
654 begin
655 putIntAt(buf, 0, tr.X);
656 putIntAt(buf, 4, tr.Y);
657 putBytesAt(buf, 8, tr.AreaType, 1);
658 putBytesAt(buf, 9, tr.Direction, 1);
659 end;
661 begin
662 if (bufsize < 10) then raise Exception.Create('invalid buffer size in writeTAreaRec_1');
663 xwriteTarearec_1();
664 end;
666 procedure mb_Write_TTriggerRec_1 (var buf; bufsize: Integer; var tr: TTriggerRec_1);
667 procedure xwriteTtriggerrec_1 ();
668 begin
669 putIntAt(buf, 0, tr.X);
670 putIntAt(buf, 4, tr.Y);
671 putWordAt(buf, 8, tr.Width);
672 putWordAt(buf, 10, tr.Height);
673 putBytesAt(buf, 12, tr.Enabled, 1);
674 putIntAt(buf, 13, tr.TexturePanel);
675 putBytesAt(buf, 17, tr.TriggerType, 1);
676 putBytesAt(buf, 18, tr.ActivateType, 1);
677 putBytesAt(buf, 19, tr.Keys, 1);
678 putBytesAt(buf, 20, tr.DATA, 128);
679 end;
681 begin
682 if (bufsize < 148) then raise Exception.Create('invalid buffer size in writeTTriggerRec_1');
683 xwriteTtriggerrec_1();
684 end;