-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditMaze.pas
1253 lines (1063 loc) · 38.4 KB
/
EditMaze.pas
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(*
Copyright (C) 2024 Jeffrey Getzin.
Licensed under the GNU General Public License v3.0 with additional terms.
See the LICENSE file in the repository root for details.
*)
[Inherit ('Types','SMGRTL','LibRtl')]Module Edit_Maze;
{ This module facilitates the editing of a level of a maze }
Const
Space_Char = '.';
Transparent_Char = '*';
Walk_Through_Char = ':';
Door_Char = '+';
Secret_Char = '$';
Wall_Char = '#';
ZeroOrd = Ord('0');
Up_Arrow = CHR(18); Down_Arrow = CHR(19);
Left_Arrow = CHR(20); Right_Arrow = CHR(21);
Type
Floor_Type = Array [1..20,1..20] of Room_Record;
Print_Mode = (Specials,Rooms,Normal);
Var
Monster: List_of_monsters;
ScreenDisplay: [External]Unsigned;
PrintMazeFile: [External]Text;
MazeFile: [External]LevelFile;
Print_Queue: [External,Volatile]Line;
Answer: Char;
Level_Loaded: Integer;
Need_to_Load,Need_to_Save: Boolean;
SPKind_Name: [Readonly]Array [SPKind] of Packed Array [1..15] of char;
Special_Kind_Name: [Readonly]Array [Special_Kind] of Packed Array [1..15] of char;
Floor_Number: Integer;
Floor: Level;
Need_to_load_Monsters: Boolean;
Value
Level_Loaded:=0;
Need_to_Load:=True; Need_to_Save:=False; Need_to_Load_Monsters:=True;
SPKind_Name[NothingSpecial] := 'Nothing';
SPKind_Name[Msg] := 'Message';
SPKind_Name[Msg_Item_Given] := 'Msg/Item';
SPKind_Name[Msg_Pool] := 'Msg/Pool';
SPKind_Name[Msg_Hidden_Item] := 'Msg/Hddn item';
SPKind_Name[Msg_Need_Item] := 'Msg/need_item';
SPKind_Name[Msg_Lower_AC] := 'Msg/Lower AC';
SPKind_Name[Msg_Raise_AC] := 'Msg/Raise AC';
SPKind_Name[Msg_Goto_Castle] := 'Msg/goto_castle';
SPKind_Name[Msg_Encounter] := 'Msg/encounter';
SPKind_Name[Riddle] := 'Riddle';
SPKind_Name[Fee] := 'Fee';
SPKind_Name[Msg_Trade_Item] := 'Trade items';
SPKind_Name[Msg_Picture] := 'Msg/Picture';
SPKind_Name[Unknown] := 'Unknown';
Special_Kind_Name[Nothing] := 'Nothing';
Special_Kind_Name[Stairs] := 'Stairs';
Special_Kind_Name[Pit] := 'Pit';
Special_Kind_Name[Chute] := 'Chute';
Special_Kind_Name[Rotate] := 'Rotate';
Special_Kind_Name[Darkness] := 'Darkness';
Special_Kind_Name[Teleport] := 'Teleport';
Special_Kind_Name[Damage] := 'Damage';
Special_Kind_Name[Elevator] := 'Elevator';
Special_Kind_Name[Rock] := 'Rock';
Special_Kind_Name[Antimagic] := 'AntiMagic';
Special_Kind_Name[SPFeature] := 'Special Feature';
Special_Kind_Name[An_Encounter] := 'Encounter';
Special_Kind_Name[Cliff] := 'Cliff';
(******************************************************************************)
[External]Procedure Delay (Seconds: Real);External;
[External]Function String (Num: Integer; Len: Integer:=0):Line;external;
[External]Procedure Cursor;External;
[External]Procedure No_Cursor;External;
[External]Function Get_Num (Display: Unsigned): Integer;External;
[External]Function Make_Choice (Choices: Char_Set; Time_Out: Integer:=-1;
Time_Out_Char: Char:=' '): Char;External;
[External]Function Yes_or_No (Time_Out: Integer:=-1;
Time_Out_Char: Char:=' '): [Volatile]Char;External;
(******************************************************************************)
Procedure Print_Level;
{ This procedure will print the name of the current level on the screen }
Begin { Print Level }
If Level_Loaded>0 then SMG$Put_Chars (ScreenDisplay,
'Current Level: '
+String(Level_Loaded),1,1)
End; { Print Level }
(******************************************************************************)
Procedure Print_Load_Choices;
{ This procedure will print a menu of levels to choose from }
Begin { Print Load Choices }
SMG$Put_Chars (ScreenDisplay,
'Load Level',5,22,,1);
SMG$Put_Chars (ScreenDisplay,
'---- -----',6,22,,1);
SMG$Put_Chars (ScreenDisplay,
' A) Load level 1',7,22);
SMG$Put_Chars (ScreenDisplay,
' B) Load level 2',8,22);
SMG$Put_Chars (ScreenDisplay,
' C) Load level 3',9,22);
SMG$Put_Chars (ScreenDisplay,
' D) Load level 4',10,22);
SMG$Put_Chars (ScreenDisplay,
' E) Load level 5',11,22);
SMG$Put_Chars (ScreenDisplay,
' F) Load level 6',12,22);
SMG$Put_Chars (ScreenDisplay,
' G) Load level 7',13,22);
SMG$Put_Chars (ScreenDisplay,
' H) Load level 8',14,22);
SMG$Put_Chars (ScreenDisplay,
' I) Load level 9',15,22);
SMG$Put_Chars (ScreenDisplay,
' J) Load level 10',16,22);
SMG$Put_Chars (ScreenDisplay,
' K) Load level Hell 1',17,22);
SMG$Put_Chars (ScreenDisplay,
' L) Load level Hell 2',18,22);
SMG$Put_Chars (ScreenDisplay,
' M) Load level Hell 3',7,42);
SMG$Put_Chars (ScreenDisplay,
' N) Load level Hell 4',8,42);
SMG$Put_Chars (ScreenDisplay,
' O) Load level Hell 5',9,42);
SMG$Put_Chars (ScreenDisplay,
' P) Load level Hell 6',10,42);
SMG$Put_Chars (ScreenDisplay,
' Q) Load level Hell 7',11,42);
SMG$Put_Chars (ScreenDisplay,
' R) Load level Hell 8',12,42);
SMG$Put_Chars (ScreenDisplay,
' S) Load level Hell 9',13,42);
SMG$Put_Chars (ScreenDisplay,
' T) Don''t load a level',14,42);
SMG$Put_Chars (ScreenDisplay,
' Which?',19,32);
End; { Print Load Choices }
(******************************************************************************)
[External]Function Read_Level_from_Maze_File(Var fileVar: LevelFile; levelNumber: Integer): Level;External;
[External]Procedure Save_Level_to_Maze_File(Var fileVar: LevelFile; filename: Line; Floor: Level);External;
[External]Function Get_Maze_File_Name (levelCharacter: Char): Line;External;
(******************************************************************************)
Procedure Load_Floor (Number: Integer; Typed_Char: Char);
{ This procedure will load a specified floor. If the floor file doesn't
exist, a blank one will be created. }
Begin { Load Floor }
{ Set the appropriate flags, and build the filename for the specified level }
Floor_Number:=Number; Level_Loaded:=Number; Need_to_Load:=False;
{ Attempt to open the level file }
Floor:=Read_Level_from_Maze_File(MazeFile,Number);
SMG$Put_Chars (ScreenDisplay,
'Loaded.',23,36,,1);
Delay (1);
End; { Load Floor }
(******************************************************************************)
Procedure Load_Level (Var Floor: Level);
{ This procedure will allow the user to load a level to be edited }
Var
Answer: Char;
Begin { Load Level }
{ Print a menu of choices }
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay);
Print_Level;
Print_Load_Choices;
SMG$End_Display_Update(ScreenDisplay);
{ Make and handle choice }
Answer:=Make_Choice(['A'..'T']);
If Answer<>'T' then
If (Ord(Answer)-64)<>Floor_Number then
Load_Floor (Ord(Answer)-64,Answer)
End; { Load Level }
(******************************************************************************)
Procedure Save_Level (Floor: Level);
Var
Answer: Char;
Name: Line;
Begin
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay);
Print_Level;
SMG$Put_Chars (ScreenDisplay,
'Save Level',5,32,,1);
SMG$Put_Chars (ScreenDisplay,
'---- -----',6,32,,1);
SMG$Put_Chars (ScreenDisplay,
' A) Save level '+String(Level_Loaded),7,32);
SMG$Put_Chars (ScreenDisplay,
' Q) Don''t save a level',8,32);
SMG$Put_Chars (ScreenDisplay,
' Which?',10,32);
SMG$End_Display_Update (ScreenDisplay);
Answer:=Make_Choice (['A'..'J', 'Q']);
If Answer<>'Q' then
Begin
Answer:=Chr(Level_loaded+64);
Name:=Get_Maze_File_Name(Answer);
Save_Level_to_Maze_File(MazeFile,Name, Floor);
SMG$Put_Chars (ScreenDisplay,
'Saved.',23,36,,1);
Need_to_Save:=False;
Delay(1);
End;
End;
(******************************************************************************)
Procedure Check_Monsters;
[External]Procedure Read_Monsters (Var Monster: List_of_Monsters);External;
Begin
If Need_to_Load_Monsters then
Begin
Read_Monsters (Monster); Need_to_Load_Monsters:=False;
End;
End;
(******************************************************************************)
Procedure Print_Encounter_Menu (Index: Integer; Var Enc: Encounter);
Var
T: Line;
Begin
Check_Monsters;
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay);
SMG$Set_Cursor_ABS (ScreenDisplay,3,1);
SMG$Put_Line (ScreenDisplay,
' Edit Encounter '+String(Index,1),1,1);
T:=' A) Base Monster: '
+String(Enc.Base_Monster_Number)
+'(';
If Enc.Base_Monster_Number>0 then
T:=T
+Monster[Enc.Base_Monster_Number].Real_Name
+')'
Else
T:=T+'None)';
SMG$Put_Line (ScreenDisplay, T);
T:=' B) Random addition: '
+String(Enc.addition.X)
+'D'
+String(Enc.addition.Y);
If Enc.Addition.Z>-1 then
T:=T+'+';
T:=T+String (Enc.Addition.Z);
SMG$Put_Line (ScreenDisplay,T);
SMG$Put_Line (ScreenDisplay,
' C) Probability: '
+String(Enc.Probability));
SMG$Put_Line (ScreenDisplay,
' E) Exit',2);
SMG$Put_Line (ScreenDisplay,
' Which?');
Print_Level;
SMG$End_Display_Update (ScreenDisplay);
End;
(******************************************************************************)
Procedure Edit_Encounter (Index: Integer; Var Enc: Encounter);
Var
Number: Integer;
Answer: Char;
Begin
Repeat
Begin
Print_Encounter_Menu (Index,Enc);
Answer:=Make_Choice (['A'..'C','E']);
If Answer in ['A','C'] then
Begin
SMG$Put_Chars (ScreenDisplay,
'Enter an integer: ',13,1);
Number:=Get_Num(ScreenDisplay);
Case Answer of
'A': If (Number<=450) and (Number>=0) then
Enc.Base_Monster_Number:=Number
Else
Enc.Base_Monster_Number:=450;
'C': If (Number<=200) and (Number>=0) then
Enc.Probability:=Number
Else
Enc.Probability:=200;
End
End
Else
If Answer='B' then
Begin
SMG$Put_Chars(ScreenDisplay,'Enter X: ',13,1);
Enc.Addition.X:=Get_Num(ScreenDisplay);
SMG$Put_Chars(ScreenDisplay,'Enter Y: ',14,1);
Enc.Addition.Y:=Get_Num(ScreenDisplay);
SMG$Put_Chars(ScreenDisplay,'Enter Z: ',15,1);
Enc.Addition.Z:=Get_Num(ScreenDisplay);
End;
End;
Until Answer='E'
End;
(******************************************************************************)
Procedure Print_Range (Enc: Encounter);
Var
T: Line;
First,Last: Integer;
Begin
T:='';
Check_Monsters;
First:=Enc.Base_Monster_Number; Last:=First+(Enc.Addition.X*Enc.Addition.Y)+Enc.Addition.Z;
If (First>0) and (Last<451) then
T:='['
+Monster[First].Real_Name
+'-'
+Monster[Last].Real_Name
+']';
SMG$Put_Chars (ScreenDisplay, T);
End;
(******************************************************************************)
Procedure Encounter_Edit (Var Table: Encounter_Table);
Var
Answer: Char;
Begin
Repeat
Begin
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay);
Print_Level;
SMG$Put_Chars (ScreenDisplay,
'Encounter Edit',5,29,,1);
SMG$Put_Chars (ScreenDisplay,
'--------- ----',6,29,,1);
SMG$Put_Chars (ScreenDisplay,
' 1) Edit Encounter one '
+' (wandering) ',7,1);
Print_Range (Table[1]);
SMG$Put_Chars (ScreenDisplay,
' 2) Edit Encounter two '
+' (lair) ',8,1);
Print_Range (Table[2]);
SMG$Put_Chars (ScreenDisplay,
' 3) Edit Encounter three '
+'(?special?) ',9,1);
Print_Range (Table[3]);
SMG$Put_Chars (ScreenDisplay,
' 0) Exit',10,1);
SMG$Put_Chars (ScreenDisplay,
' Which?',12,1);
SMG$End_Display_Update (ScreenDisplay);
Answer:=Make_Choice (['0'..'3']);
If Answer<>'0' then Edit_Encounter (Ord(Answer)-ZeroOrd,Table[Ord(Answer)-ZeroOrd]);
End;
Until (Answer='0');
End;
(******************************************************************************)
Procedure Print_Item (Table: Special_Table_Type; Position: Integer);
Var
T: Line;
Item: Integer;
Begin
Item:=Position;
T:=' '+CHR(Position+65);
T:=T+' '+Special_Kind_Name[Table[Item].Special];
T:=T+' ';
If Table[Item].Special=SPFeature then
T:=T+SPKind_Name[Table[Item].Feature]
Else
T:=T+Pad('Nothing',' ',15);
T:=T+' ';
T:=T+String (table[Item].Pointer1,10);
T:=T+' ';
T:=T+String (table[Item].Pointer2,10);
T:=T+' ';
T:=T+String (table[Item].Pointer3,10);
SMG$Put_Chars (ScreenDisplay,T,Position+5,1);
End;
(******************************************************************************)
Procedure Print_Special_Item (Special: SpKind; Position: Integer);
Begin
SMG$Put_Chars (ScreenDisplay,SpKind_Name[Special],Position+5,20);
ENd;
(******************************************************************************)
Procedure Print_Feature_Item (Feature: Special_Kind; Position: Integer);
Begin
SMG$Put_Chars (ScreenDisplay,Special_Kind_Name[Feature],Position+5,4);
ENd;
(******************************************************************************)
Procedure Feature_Edit (Var Feature: SPKind; Number: Integer);
Var
Answer: Char;
Begin
Repeat
Begin
SMG$Put_Chars (ScreenDisplay,
'<-- -->, space exits',22,1,1);
Answer:=Make_Choice ([Left_Arrow,Right_Arrow,CHR(32)]);
Case Answer of
Left_Arrow: If (Feature=NothingSpecial) then
Begin
Feature:=Unknown;
End
Else
Begin
Feature:=Pred(Feature);
End;
Right_Arrow: If (Feature=Unknown) then
Begin
Feature:=NothingSpecial;
End
Else
Begin
Feature:=Succ(Feature);
End;
End;
Print_Special_Item (Feature,Number);
End;
Until Answer=CHR(32);
End;
(******************************************************************************)
Procedure Kind_Edit (Var Special: Special_Kind; Number: Integer);
Var
Answer: Char;
Begin
Repeat
Begin
SMG$Put_Chars (ScreenDisplay,
'<-- -->, space exits',22,1,1);
Answer:=Make_Choice ([Left_Arrow,Right_Arrow,CHR(32)]);
Case Answer of
Left_Arrow: If (Special=Nothing) then
Begin
Special:=Cliff;
End
Else
Begin
Special:=Pred(Special);
End;
Right_Arrow: If (Special=Cliff) then
Begin
Special:=Nothing;
End
Else
Begin
Special:=Succ(Special);
End;
End;
Print_Feature_Item (Special, Number);
End;
Until (Answer=CHR(32));
End;
(******************************************************************************)
Procedure Special_Edit (Var Table: Special_Table_Type);
Var
Answer: Char;
Options: Char_Set;
T: Line;
Number: Integer;
Item: Integer;
Begin
Repeat
Begin
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay);
SMG$Put_Chars (ScreenDisplay,
'Special Editor',1,37,,1);
SMG$Put_Chars (ScreenDisplay,
'------- ------',2,37,,1);
Print_Level;
SMG$Set_Cursor_ABS (ScreenDisplay,3,1);
SMG$Put_Line (ScreenDisplay,
'# Kind Special '
+' Pointer1 Pointer'
+'2 Pointer3');
SMG$Put_Line (ScreenDisplay,
'-- --------------- ---------'
+'------ ---------- ---------'
+'- ----------');
For Item:=0 to 15 do
Begin
Print_Item (Table, Item);
End;
SMG$End_Display_Update (ScreenDisplay);
SMG$Put_Chars (ScreenDisplay,
'Edit which special? (Q exi'
+'ts) --',22,1);
Cursor;
Answer:=Make_Choice (['A'..'Q']);
No_Cursor;
Number:=Ord(Answer)-65;
If (Number<=15) then
Repeat
Begin
Options:=['K','P','E'];
T:='Edit: K)ind, ';
If (Table[Number].Special=SPFeature) then
Begin
T:=T+'F)eature, ';
Options:=Options+['F'];
End;
T:=T+'P)ointers, or E)xit edit';
SMG$Put_Chars (ScreenDisplay,T,22,1,1);
Answer:=Make_Choice (Options);
Case Answer of
'E': ;
'F': Feature_Edit (Table[Number].Feature,Number);
'K': Kind_Edit (Table[Number].Special,Number);
'P': Begin
SMG$Put_Chars (ScreenDisplay,
'Enter Pointer1: ',22,1,1);
Table[Number].Pointer1:=Get_Num(ScreenDisplay);
SMG$Put_Chars (ScreenDisplay,
'Enter Pointer2: ',22,1,1);
Table[Number].Pointer2:=Get_Num(ScreenDisplay);
SMG$Put_Chars (ScreenDisplay,
'Enter Pointer3: ',22,1,1);
Table[Number].Pointer3:=Get_Num(ScreenDisplay);
Print_Item (Table,Number);
End;
End; { Case }
End; { Repeat }
Until (Answer='E');
End;
Until (Number=16);
End;
(******************************************************************************)
Function Top_Row (Spot: Room_Record): Line;
Var
T: Line;
Begin
T:='';
If (Spot.North<>Passage) or (Spot.West<>Passage) then
T:=T+Wall_Char
Else
T:=T+' ';
Case Spot.North of
Passage: T:=T+' ';
Transparent: T:=T+Transparent_Char; { w }
Walk_Through: T:=T+Walk_Through_Char; { ~ }
Wall: T:=T+Wall_Char; { - }
Door: T:=T+Door_Char; { ^ }
Secret: T:=T+Secret_Char;
Otherwise T:=T+Space_Char;
End;
If (Spot.North<>Passage) or (Spot.East<>Passage) then
T:=T+Wall_Char
Else
T:=T+' ';
Top_Row:=T;
End;
(******************************************************************************)
Function Middle_Row (Spot: Room_Record; Mode: Print_Mode): Line;
Var
T: Line;
Begin
T:='';
Case Spot.West of
Passage: T:=' ';
Transparent: T:=Transparent_Char; { left curly bracket }
Wall: T:=Wall_Char; { | }
Walk_Through: T:=Walk_Through_Char; { S }
Door: T:=Door_Char; { < }
Secret: T:=Secret_Char; { $ }
Otherwise T:=Space_Char;
End;
Case Mode of
Normal: T:=T+Space_Char;
Rooms: If Spot.Kind=Room then T:=T
+'R'
Else T:=T
+'C';
Specials: T:=T+CHR(Ord(Spot.Contents)+65);
Otherwise T:=T+Space_Char;
End;
Case Spot.East of
Passage: T:=T+' ';
Transparent: T:=T+Transparent_Char; { left curly bracket }
Wall: T:=T+Wall_Char; { | }
Walk_Through: T:=T+Walk_Through_Char; { S }
Door: T:=T+Door_Char; { < }
Secret: T:=T+Secret_Char; { $ }
Otherwise T:=T+Space_Char;
End;
Middle_Row:=T;
End;
(******************************************************************************)
Function Bottom_Row (Spot: Room_Record): Line;
Var
T: Line;
Begin
T:='';
If (Spot.South<>Passage) or (Spot.West<>Passage) then
T:=T+Wall_Char { + }
Else
T:=T+' ';
Case Spot.South of
Passage: T:=T+' ';
Transparent: T:=T+Transparent_Char; { w }
Walk_Through: T:=T+Walk_Through_Char; { ~ }
Wall: T:=T+Wall_Char; { - }
Door: T:=T+Door_Char; { ^ }
Secret: T:=T+Secret_Char;
Otherwise T:=T+Space_Char;
End;
If (Spot.South<>Passage) or (Spot.East<>Passage) then
T:=T+Wall_Char { + }
Else
T:=T+' ';
Bottom_Row:=T;
End;
(******************************************************************************)
Procedure Print_Key;
Begin
SMG$Put_Chars (ScreenDisplay,
'Key',
16,62);
SMG$Put_Chars (ScreenDisplay,
'---',
17,62);
SMG$Put_Chars (ScreenDisplay,
'Space = "'
+Space_Char
+'"',
18,62);
SMG$Put_Chars (ScreenDisplay,
'Trans. Wall = "'
+Transparent_Char
+'"',
19,62);
SMG$Put_Chars (ScreenDisplay,
'Walkthrough = "'
+Walk_Through_Char
+'"',
20,62);
SMG$Put_Chars (ScreenDisplay,
'Door = "'
+Door_Char
+'"',
21,62);
SMG$Put_Chars (ScreenDisplay,
'Secret Door = "'
+Secret_Char
+'"',
22,62);
SMG$Put_Chars (ScreenDisplay,
'Wall = "'
+Wall_Char
+'"',
23,62);
End;
(******************************************************************************)
Procedure Print_Screen (Maze: Floor_Type; CursorX,CursorY,TopX,TopY: Integer; Mode: Print_Mode:=Normal);
Type
Row_Type = (Top,Middle,Bottom);
Var
T: Line;
Row: Row_Type;
RoomX,RoomY,SpotY,LastX,LastY: Integer;
Spot: Room_Record;
Spot_Special: Special_Kind;
SP: SPKind;
Begin
LastX:=1+20; If LastX>20 then LastX:=20; LastY:=TopY+6; { TODO: Looks like a logic error }
For RoomY:=TopY to LastY do
For Row:=Top to Bottom do
Begin
For RoomX:=1 to LastX do
Begin
Spot:=Maze[RoomX,RoomY];
Case Row of
Top: SMG$Put_Chars (ScreenDisplay,Top_Row (Spot));
Middle: SMG$Put_Chars (ScreenDisplay,Middle_Row (Spot,Mode));
Bottom: SMG$Put_Chars (ScreenDisplay,Bottom_Row (Spot));
End;
End;
SMG$Put_Line (ScreenDisplay,'');
End;
Spoty:=(CursorY-TopY)+1;
Spot:=Maze[CursorX,CursorY];
Case Mode of
Normal: T:=Space_Char;
Rooms: If Spot.Kind=Room then
T:='R'
Else
T:='C';
Specials: T:=CHR(Ord(Spot.Contents)+65);
End;
SMG$Put_Chars (ScreenDisplay,T,(SpotY*3),(CursorX*3)-1,0,2);
Print_Key;
Spot_Special:=Floor.Special_Table[Spot.Contents].Special;
If Spot_Special=SPFeature then
Begin
SP:=Floor.Special_Table[Spot.Contents].Feature;
SMG$Put_Chars (ScreenDisplay,
SpKind_Name[SP]
+'',13,62);
End
Else
SMG$Erase_Line (ScreenDisplay,13,62);
SMG$Put_Chars (ScreenDisplay,
String(Floor.Special_Table[Spot.Contents].Pointer1)
+' '+
String(Floor.Special_Table[Spot.Contents].Pointer2)
+' '+
String(Floor.Special_Table[Spot.Contents].Pointer3),14,62);
End;
(******************************************************************************)
Procedure Move_Up (Var CurrentY,TopY: Integer);
{ This procedure moves the cursor up, and wraps if off the edge }
Begin { Move Up }
If CurrentY>1 then { If still on screen... }
Begin { If on screen }
CurrentY:=CurrentY-1;
If CurrentY<TopY then
TopY:=CurrentY;
End { If on screen }
Else
Begin { Wrap }
CurrentY:=20;
TopY:=20-6;
End; { Wrap }
End; { Move Up }
(******************************************************************************)
Procedure Move_Left (Var CursorX,CursorY,TopY: Integer);
{ This procedure moves the cursor to the left, and wraps if off the edge }
Begin { Move Left }
CursorX:=CursorX-1;
If CursorX<1 then
Begin
CursorX:=20;
Move_UP (CursorY,TopY);
End;
End; { Move Left }
(******************************************************************************)
Procedure Move_Down (Var CurrentY,TopY: Integer);
{ This procedure moves the cursor down, and wraps if off the edge }
Begin { Move Down }
If CurrentY<20 then { If still on screen... }
Begin { Move down }
CurrentY:=CurrentY+1;
If CurrentY>TopY+6 then
TopY:=TopY+1;
End
Else { Otherwise, wrap to top of screen }
Begin { Move to top }
CurrentY:=1;
TopY:=1;
End; { Move to top }
End; { Move Down }
(******************************************************************************)
Procedure Move_Right (Var CursorX,CursorY,TopY: Integer);
{ This procedure moves the cursor to the right, and wraps if off the edge }
Begin { Move Right }
CursorX:=CursorX+1;
If CursorX>20 then
Begin
CursorX:=1;
Move_Down (CursorY,TopY);
End;
End; { Move Right }
(******************************************************************************)
Procedure Room_or_Corridor (Var Maze: Floor_Type; Var CursorX,CursorY,TopY: Integer);
{ This procedure enters the Room/Corridor mode, which allows the user to maneuver over any spot in the maze and assign it as a
room or as a corridor. }
Const
Room_Command_Line = 'Room/Corridor '
+'options. Use Arrows. T)oggle '
+'or E)xit';
Var
Answer: Char;
Begin { Room or Corridor }
Repeat
Begin { Repeat }
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Put_Chars (ScreenDisplay,Room_Command_Line,1,1,1,1);
SMG$Set_Cursor_ABS (ScreenDisplay,2,1);
Print_Screen (Maze,CursorX,CursorY,1,TopY,Rooms); { Print level }
SMG$Put_Chars (ScreenDisplay,
'X: '
+ String(CursorX, 2)
+ ' Y: '
+ String(CursorY, 2)
+ ' Z: '
+ String(Level_Loaded,2),
2, 66);
SMG$End_Display_Update (ScreenDisplay);
Answer:=Make_Choice ([Down_Arrow,Up_Arrow,Left_Arrow,Right_Arrow,'T','E']);
Case Answer of
'T': Begin
If Maze[CursorX,CursorY].Kind=Room then
Begin
Maze[CursorX,CursorY].Kind:=Corridor;
End
Else
Begin
Maze[CursorX,CursorY].Kind:=Room;
End;
Move_Right (CursorX,CursorY,TopY);
End;
Left_Arrow: If (CursorX>1) then
Begin
Move_Left (CursorX,CursorY,TopY);
End;
Right_Arrow: If (CursorX<20) then
Begin
Move_Right (CursorX,CursorY,TopY);
End;
Up_Arrow: If (CursorY>1) then
Begin
Move_Up (CursorY,TopY);
End;
Down_Arrow: If (CursorY<20) then
Begin
Move_Down (CursorY,TopY);
End;
End; { Case }
End; { Repeat }
Until (answer='E'); { Until user wants to E)xit this mode }
End; { Room or Corridor }
(******************************************************************************)
Procedure Change_Room_Special (Var Maze: Floor_Type; Var CursorX,CursorY,TopY: Integer);
{ This procedure lets the user place a special in the room by typing its letter code }
Var
Special: Char;
Begin { Change Room Special }
{ Get the special }
SMG$Put_Chars (ScreenDisplay,
'Enter special letter, <SPACE> exits',
23,1,,1);
Special:=Make_Choice(['A'..'P',CHR(32)]);
{ If not exiting mode, place the special }
If (Special<>CHR(32)) then
Begin
Maze[CursorX,CursorY].Contents:=ORD(Special)-65;
End;
SMG$Erase_Line (ScreenDisplay,23,1);
Move_Right (CursorX,CursorY,TopY);
End; { Change Room Special }
(******************************************************************************)
Procedure Special_Placement (Var Maze: Floor_Type; Var CursorX,CursorY,TopY: Integer);
{ This procedure runs the Special Placement mode. It allows the user to maneuver the cursor over the maze, and place specials
wherever he or she feels like }
Const
Special_Command_Line = 'Specials o'
+'ptions: Use Arrows, P)lace a spec'
+'ial or E)xit';
Var
Answer: Char;
Begin { Special Placement }
Repeat
Begin { Repeat }
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Put_Chars (ScreenDisplay,Special_Command_Line,1,1,1,1);
{ Print the floor plan, mode=2 (indicating specials) }
SMG$Set_Cursor_ABS (ScreenDisplay,2,1);
Print_Screen (Maze,CursorX,CursorY,1,TopY,Specials);
SMG$Put_Chars (ScreenDisplay,
'X: '
+String(CursorX,2)
+' Y: '
+String(CursorY,2)
+' Z: '
+String(Level_Loaded,2),2,66);
SMG$End_Display_Update (ScreenDisplay);
{ Get the choice and handle it }