File: ui4gh.pp

package info (click to toggle)
gearhead2 0.701-1
  • links: PTS
  • area: main
  • in suites: buster, sid
  • size: 14,184 kB
  • sloc: pascal: 49,692; makefile: 85; sh: 12
file content (724 lines) | stat: -rw-r--r-- 19,850 bytes parent folder | download | duplicates (2)
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
unit ui4gh;
	{ User Interface for GearHead. }
	{ This unit exists to keep me from copying changes back and forth between }
	{ the SDL mode units and the CRT mode units... }
{
	GearHead2, a roguelike mecha CRPG
	Copyright (C) 2005 Joseph Hewitt

	This library is free software; you can redistribute it and/or modify it
	under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation; either version 2.1 of the License, or (at
	your option) any later version.

	The full text of the LGPL can be found in license.txt.

	This library is distributed in the hope that it will be useful, but
	WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
	General Public License for more details. 

	You should have received a copy of the GNU Lesser General Public License
	along with this library; if not, write to the Free Software Foundation,
	Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
}
{$LONGSTRINGS ON}


interface

uses gears,texutil,dos;

type
	KeyMapDesc = Record
		CmdName,CmdDesc: String;
		isacommand: Boolean;		{ Return TRUE if this key is a command. }
		KCode: Char;
	end;

const
{$IFDEF ASCII}
	RPK_UpRight = '9';
	RPK_Up = '8';
	RPK_UpLeft = '7';
	RPK_Left = '4';
	RPK_Right = '6';
	RPK_DownRight = '3';
	RPK_Down = '2';
	RPK_DownLeft = '1';

	FrameDelay: Integer = 30;
{$ELSE}
	RPK_UpRight = #$89;
	RPK_Up = #$88;
	RPK_UpLeft = #$87;
	RPK_Left = #$84;
	RPK_Right = #$86;
	RPK_DownRight = #$81;
	RPK_Down = #$82;
	RPK_DownLeft = #$83;
	RPK_MouseButton = #$90;
	RPK_TimeEvent = #$91;
	RPK_RightButton = #$92;

	FrameDelay: Integer = 30;
{$ENDIF}

	MenuBasedInput = 0;
	RLBasedInput = 1;
	ControlMethod: Byte = RLBasedInput;
	CharacterMethod: Byte = RLBasedInput;
	WorldMapMethod: Byte = RLBasedInput;
	ControlTypeName: Array [0..1] of string = ('Menu','Roguelike');

	DoFullScreen: Boolean = True;
	Mouse_Active: Boolean = True;

	Always_Save_Character: Boolean = False;
	No_Combat_Taunts: Boolean = False;
	Pillage_On: Boolean = True;

	RPG_Use_Tactics: Boolean = False;
	Arena_Use_Tactics: Boolean = True;

	TacticsRoundLength: Integer = 60;
	Tactics_Turn_In_Progess: Boolean = False;

	XXRan_Wizard: Boolean = False;
	ArenaMode_Wizard: Boolean = False;

	PC_SHOULD_RUN: Boolean = False;

	Names_Above_Heads: Boolean = False;

	Cycle_All_Weapons: Boolean = False;

	Splash_Screen_At_Start: Boolean = True;

    Transparent_Interface: Boolean = True;

	BV_Off = 1;
	BV_Quarter = 2;
	BV_Half = 3;
	BV_Max = 4;
	DefMissileBV: Byte = BV_Quarter;
	DefBallisticBV: Byte = BV_Max;
	DefBeamgunBV: Byte = BV_Max;
	BVTypeName: Array [1..4] of string = ('Off','1/4','1/2','Max');

	DoAutoSave: Boolean = True;

	Load_Plots_At_Start: Boolean = False;

	Reload_All_Weapons: Boolean = False;

	Display_Mini_Map: Boolean = FaLSE;

	{ *** SCREEN DIMENSIONS *** }
{$IFDEF WIN32}
	ScreenRows: Byte = 25;
{$ELSE}
	ScreenRows: Byte = 24;
{$ENDIF}
	ScreenColumns: Byte = 80;

	Revert_Slower_Safer: Boolean = False;

	XXRan_Debug: Boolean = False;
	StdPlot_Debug: Boolean = False;


	NumMappedKeys = 51;
	KeyMap: Array [1..NumMappedKeys] of KeyMapDesc = (
	(	CmdName: 'NormSpeed';
		CmdDesc: 'Travel foreword at normal speed.';
		IsACommand: True;
		KCode: '=';	),
	(	CmdName: 'FullSpeed';
		CmdDesc: 'Travel foreword at maximum speed';
		IsACommand: True;
		KCode: '+';	),
	(	CmdName: 'TurnLeft';
		CmdDesc: 'Turn to the left.';
		IsACommand: True;
		KCode: '[';	),
	(	CmdName: 'TurnRight';
		CmdDesc: 'Turn to the right.';
		IsACommand: True;
		KCode: ']';	),
	(	CmdName: 'Stop';
		CmdDesc: 'Stop moving, wait in place.';
		IsACommand: True;
		KCode: '5';	),

	(	CmdName: 'Dir-SouthWest';
		CmdDesc: 'Move southwest.';
		IsACommand: True;
		KCode: RPK_DownLeft;	),
	(	CmdName: 'Dir-South';
		CmdDesc: 'Move south.';
		IsACommand: True;
		KCode: RPK_Down;	),
	(	CmdName: 'Dir-SouthEast';
		CmdDesc: 'Move southeast.';
		IsACommand: True;
		KCode: RPK_DownRight;	),
	(	CmdName: 'Dir-West';
		CmdDesc: 'Move west.';
		IsACommand: True;
		KCode: RPK_Left;	),
	(	CmdName: 'Dir-East';
		CmdDesc: 'Move east.';
		IsACommand: True;
		KCode: RPK_Right;	),

	(	CmdName: 'Dir-NorthWest';
		CmdDesc: 'Move northwest.';
		IsACommand: True;
		KCode: RPK_UpLeft;	),
	(	CmdName: 'Dir-North';
		CmdDesc: 'Move north.';
		IsACommand: True;
		KCode: RPK_Up;	),
	(	CmdName: 'Dir-NorthEast';
		CmdDesc: 'Move northeast.';
		IsACommand: True;
		KCode: RPK_UpRight;	),
	(	CmdName: 'ShiftGears';
		CmdDesc: 'Change movement mode.';
		IsACommand: True;
		KCode: '.';	),
	(	CmdName: 'Look';
		CmdDesc: 'Look around the map.';
		IsACommand: True;
		KCode: 'l';	),

	(	CmdName: 'AttackMenu';
		CmdDesc: 'Access the attack menu.';
		IsACommand: True;
		KCode: 'A';	),
	(	CmdName: 'QuitGame';
		CmdDesc: 'Exit the game.';
		IsACommand: True;
		KCode: 'Q';	),
	(	CmdName: 'Talk';
		CmdDesc: 'Initiate conversation with a NPC.';
		IsACommand: True;
		KCode: 't';	),
	(	CmdName: 'Help';
		CmdDesc: 'View these helpful messages.';
		IsACommand: True;
		KCode: 'h';	),
	(	CmdName: 'SwitchWeapon';
		CmdDesc: 'Change the active weapon while selecting a target.';
		IsACommand: True;
		KCode: '.';	),

	(	CmdName: 'CalledShot';
		CmdDesc: 'Toggle the Called Shot option while selecting a target.';
		IsACommand: False;
		KCode: '/';	),
	(	CmdName: 'Get';
		CmdDesc: 'Pick up an item lying on the ground.';
		IsACommand: True;
		KCode: ',';	),
	(	CmdName: 'Inventory';
		CmdDesc: 'Access all carried items.';
		IsACommand: True;
		KCode: 'i';	),
	(	CmdName: 'Equipment';
		CmdDesc: 'Access all equipped items.';
		IsACommand: True;
		KCode: 'e';	),
	(	CmdName: 'Enter';
		CmdDesc: 'Use a stairway or portal.';
		IsACommand: True;
		KCode: '>';	),

	{ Commands 26 - 30 }
	(	CmdName: 'PartBrowser';
		CmdDesc: 'Examine the individual components of your PC.';
		IsACommand: True;
		KCode: 'B';	),
	(	CmdName: 'LearnSkills';
		CmdDesc: 'Spend accumulated experience points.';
		IsACommand: True;
		KCode: 'L';	),
	(	CmdName: 'Attack';
		CmdDesc: 'Perform an attack.';
		IsACommand: True;
		KCode: 'a';	),
	(	CmdName: 'SelectMecha';
		CmdDesc: 'Choose the mecha that will be used by this PC in combat.';
		IsACommand: True;
		KCode: 'M';	),
	(	CmdName: 'UseScenery';
		CmdDesc: 'Activate a stationary item, such as a door or a computer.';
		IsACommand: True;
		KCode: 'u';	),

	{ Commands 31 - 35 }
	(	CmdName: 'Messages';
		CmdDesc: 'Review all current adventure memos, email, and news.';
		IsACommand: True;
		KCode: 'm';	),
	(	CmdName: 'SaveGame';
		CmdDesc: 'Write the game data to disk, so you can come back and waste time later.';
		IsACommand: True;
		KCode: 'X';	),
	(	CmdName: 'Enter2';
		CmdDesc: 'Use a stairway or portal.';
		IsACommand: True;
		KCode: '<';	),
	(	CmdName: 'CharInfo';
		CmdDesc: 'View detailed information about your character, access option menus.';
		IsACommand: True;
		KCode: 'C';	),
	(	CmdName: 'ApplySkill';
		CmdDesc: 'Select and use a skill that the PC knows.';
		IsACommand: True;
		KCode: 's';	),

	{ Commands 36 - 40 }
	(	CmdName: 'Eject';
		CmdDesc: 'Eject from your mecha and abandon it on the field.';
		IsACommand: True;
		KCode: 'E';	),
	(	CmdName: 'Rest';
		CmdDesc: 'Take a break for one hour of game time.';
		IsACommand: True;
		KCode: 'Z';	),
	(	CmdName: 'History';
		CmdDesc: 'Display past messages.';
		IsACommand: True;
		KCode: 'V';	),
	(	CmdName: 'FieldHQ';
		CmdDesc: 'Examine and edit your personal wargear.';
		IsACommand: True;
		KCode: 'H';	),
	(	CmdName: 'Search';
		CmdDesc: 'Check the area for enemies and secrets.';
		IsACommand: True;
		KCode: 'S';	),

	{ Commands 41 - 45 }
	(	CmdName: 'Telephone';
		CmdDesc: 'Place a telephone call to a local NPC.';
		IsACommand: True;
		KCode: 'T';	),
	(	CmdName: 'SwitchBV';
		CmdDesc: 'Switch the Burst Fire option while selecting a target.';
		IsACommand: False;
		KCode: '>';	),
	(	CmdName: 'Reverse';
		CmdDesc: 'Travel backward at normal speed.';
		IsACommand: True;
		KCode: '-';	),
	(	CmdName: 'SwitchTarget';
		CmdDesc: 'Switch to next visible enemy when selecting a target.';
		IsACommand: False;
		KCode: ';';	),
	(	CmdName: 'RunToggle';
		CmdDesc: 'Toggle running on or off.';
		IsACommand: True;
		KCode: 'r';	),

	{ Commands 46 - 50 }
	(	CmdName: 'WallToggle';
		CmdDesc: 'Toggle short walls in graphical mode.';
		IsACommand: True;
		KCode: 'W';	),
	(	CmdName: 'QuickFire';
		CmdDesc: 'Single-key automatic targeting attack.';
		IsACommand: True;
		KCode: 'f'; ),
	(	CmdName: 'RollHistory';
		CmdDesc: 'View the skill roll history.';
		IsACommand: True;
		KCode: 'R'; ),
	(	CmdName: 'ExamineTarget';
		CmdDesc: 'Examine a target closely.';
		IsACommand: False;
		KCode: '?'; ),
	(	CmdName: 'PartyMode';
		CmdDesc: 'Toggle between clock mode and tactics mode.';
		IsACommand: True;
		KCode: 'P'; ),

	{ Commands 51 - 55 }
	(	CmdName: 'UseSystem';
		CmdDesc: 'Use one of the special systems in a mecha.';
		IsACommand: True;
		KCode: 'U'; )

	);

	{ *** KEYMAP COMMAND NUMBERS *** }
	KMC_NormSpeed = 1;
	KMC_FullSpeed = 2;
	KMC_TurnLeft = 3;
	KMC_TurnRight = 4;
	KMC_Stop = 5;
	KMC_SouthWest = 6;
	KMC_South = 7;
	KMC_SouthEast = 8;
	KMC_West = 9;
	KMC_East = 10;
	KMC_NorthWest = 11;
	KMC_North = 12;
	KMC_NorthEast = 13;
	KMC_ShiftGears = 14;
	KMC_ExamineMap = 15;
	KMC_AttackMenu = 16;
	KMC_QuitGame = 17;
	KMC_Talk = 18;
	KMC_Help = 19;
	KMC_SwitchWeapon = 20;
	KMC_CalledShot = 21;
	KMC_Get = 22;
	KMC_Inventory = 23;
	KMC_Equipment = 24;
	KMC_Enter = 25;
	KMC_PartBrowser = 26;
	KMC_LearnSkills = 27;
	KMC_Attack = 28;
	KMC_SelectMecha = 29;
	KMC_UseProp = 30;
	KMC_ViewMemo = 31;
	KMC_SaveGame = 32;
	KMC_Enter2 = 33;
	KMC_CharInfo = 34;
	KMC_ApplySkill = 35;
	KMC_Eject = 36;
	KMC_Rest = 37;
	KMC_History = 38;
	KMC_FieldHQ = 39;
	KMC_Search = 40;
	KMC_Telephone = 41;
	KMC_SwitchBV = 42;
	KMC_Reverse = 43;
	KMC_SwitchTarget = 44;
	KMC_RunToggle = 45;
	KMC_WallToggle = 46;
	KMC_QuickFire = 47;
	KMC_RollHistory = 48;
	KMC_ExamineTarget = 49;
	KMC_PartyMode = 50;
	KMC_UseSystem = 51;

	Direct_Skill_Learning: Boolean = False;

	Thorough_Redraw: Boolean = False;
	Use_Tall_Walls: Boolean = True;

	Iso_Dir_Offset: Integer = 0;
	Ersatz_Mouse: Boolean = False;

	Minimal_Screen_Refresh: Boolean = False;
	Use_Software_Surface: Boolean = False;
	Use_Paper_Dolls: Boolean = False;
	Mesh_On: Boolean = False;


	Full_RPGWorld_Info: Boolean = False;

var
	Text_Messages: SAttPtr;


Function MsgString( const MsgLabel: String ): String;


implementation

Procedure LoadConfig;
	{ Open the configuration file and set the variables }
	{ as needed. }
var
	F: Text;
	S,CMD,C: String;
	T: Integer;
begin
	{See whether or not there's a configuration file.}
	S := FSearch(Config_File, GetEnv('HOME')+'/.gearhead2/;/etc');
	if S <> '' then begin
		{ If we've found a configuration file, }
		{ open it up and start reading. }
		Assign(F,S);
		Reset(F);

		while not Eof(F) do begin
			ReadLn(F,S);
			cmd := ExtractWord(S);
			if (cmd <> '') then begin
				{Check to see if CMD is one of the standard keys.}
				cmd := UpCase(cmd);
				for t := 1 to NumMappedKeys do begin
					if UpCase(KeyMap[t].CmdName) = cmd then begin
						C := ExtractWord(S);
						if Length(C) = 1 then begin
							KeyMap[t].KCode := C[1];
						end;
					end;
				end;

				{ Check to see if CMD is the animation speed throttle. }
				if cmd = 'ANIMSPEED' then begin
					T := ExtractValue( S );
					if T < 0 then T := 0;
					FrameDelay := T;
				end else if cmd = 'MECHACONTROL' then begin
					C := UpCase( ExtractWord( S ) );
					case C[1] of
						'M': ControlMethod := MenuBasedInput;
						'R': ControlMethod := RLBasedInput;
					end;
				end else if cmd = 'CHARACONTROL' then begin
					C := UpCase( ExtractWord( S ) );
					case C[1] of
						'M': CharacterMethod := MenuBasedInput;
						'R': CharacterMethod := RLBasedInput;
					end;
				end else if cmd = 'WORLDCONTROL' then begin
					C := UpCase( ExtractWord( S ) );
					case C[1] of
						'M': WorldMapMethod := MenuBasedInput;
						'R': WorldMapMethod := RLBasedInput;
					end;

				end else if cmd = 'MISSILEBV' then begin
					C := UpCase( ExtractWord( S ) );
					for t := 1 to 4 do begin
						if UpCase(BVTypeName[t]) = C then begin
							DefMissileBV := T;
						end;
					end;

				end else if cmd = 'BALLISTICBV' then begin
					C := UpCase( ExtractWord( S ) );
					for t := 1 to 4 do begin
						if UpCase(BVTypeName[t]) = C then begin
							DefBallisticBV := T;
						end;
					end;

				end else if cmd = 'BEAMGUNBV' then begin
					C := UpCase( ExtractWord( S ) );
					for t := 1 to 4 do begin
						if UpCase(BVTypeName[t]) = C then begin
							DefBeamGunBV := T;
						end;
					end;
				end else if cmd = 'DIRECTSKILLOK' then begin
					Direct_Skill_Learning := True;

				end else if cmd = 'NOAUTOSAVE' then begin
					DoAutoSave := False;

				end else if cmd = 'ALWAYSSAVECHARACTER' then begin
					ALWAYS_SAVE_CHARACTER := True;
				end else if cmd = 'NOCOMBATTAUNTS' then begin
					No_Combat_Taunts := True;

				end else if cmd = 'LOADPLOTSATSTART' then begin
					Load_Plots_At_Start := True;

				end else if cmd = 'MINIMAPON' then begin
					Display_Mini_Map := True;

				end else if cmd = 'SCREENHEIGHT' then begin
					T := ExtractValue( S );
					if T > 255 then T := 255
					else if T < 24 then T := 24;
					ScreenRows := T;

				end else if cmd = 'SCREENWIDTH' then begin
					T := ExtractValue( S );
					if T > 255 then T := 255
					else if T < 80 then T := 80;
					ScreenColumns := T;

				end else if cmd = 'RPGMODE' then begin
					C := UpCase( ExtractWord( S ) );
					RPG_Use_Tactics := C = 'TACTICS';
				end else if cmd = 'ARENAMODE' then begin
					C := UpCase( ExtractWord( S ) );
					Arena_Use_Tactics := C = 'TACTICS';

				end else if cmd = 'WINDOW' then begin
					DoFullScreen := False;
				end else if cmd = 'FULLSCREEN' then begin
					DoFullScreen := True;

				end else if cmd = 'NOMOUSE' then begin
					Mouse_Active := False;


				end else if cmd = 'NOPILLAGE' then begin
					Pillage_On := False;

				end else if cmd = 'SHORTWALLS' then begin
					Use_Tall_Walls := False;

				end else if cmd = 'RELOAD_UNEQUIPPED_WEAPONS_AT_SHOP' then begin
					Reload_All_Weapons := True;

				end else if cmd = 'LAPTOP_ISO_KEYS' then begin
					 Iso_Dir_Offset := 1;

				end else if cmd = 'CYCLE_ALL_WEAPONS' then begin
					Cycle_All_Weapons := True;

				end else if cmd = 'MINIMAL_SCREEN_REFRESH' then begin
					Minimal_Screen_Refresh := True;
				end else if cmd = 'USE_SOFTWARE_SURFACE' then begin
					Use_Software_Surface := True;
				end else if cmd = 'NO_SPLASH_SCREEN_AT_START' then begin
					Splash_Screen_At_Start := False;

				end else if cmd = 'REVERT_SLOWER_SAFER' then begin
					Revert_Slower_Safer := True;

				end else if cmd = 'NAMESON' then begin
					Names_Above_Heads := True;

				end else if cmd = 'PAPERDOLLS' then begin
					Use_Paper_Dolls := True;
				end else if cmd = 'USEMESH' then begin
					Mesh_On := True;
				end else if cmd = 'ERSATZ_MOUSE' then begin
					Ersatz_Mouse := True;

				end else if cmd = 'NO_TRANSPARENT_INTERFACE' then begin
					Transparent_Interface := False;


				end else if cmd = 'GIMMEGIMMECHOICE' then begin
					XXRan_Wizard := True;
				end else if cmd = 'XXRANDEBUG' then begin
					XXRan_Debug := True;
				end else if cmd = 'YOUARE#6' then begin
					StdPlot_Debug := True;
				end else if cmd = 'GARYGYGAX' then begin
					ArenaMode_Wizard := True;
				end else if cmd = 'DEMIURGE' then begin
					Full_RPGWorld_Info := True;

				end else if cmd[1] = '#' then begin
					S := '';

				end;
			end;
		end;

		{ Once the EOF has been reached, close the file. }
		Close(F);
	end;

end;

Procedure SaveConfig;
	{ Open the configuration file and record the variables }
	{ as needed. }
var
	F: Text;
	T: Integer;
	Procedure AddBoolean( const OpTag: String; IsOn: Boolean );
		{ Add one of the boolean options to the file. }
	begin
		if IsOn then begin
			writeln( F , OpTag );
		end else begin
			writeln( F , '#' + OpTag );
		end;
	end;
begin
	{ If we've found a configuration file, }
	{ open it up and start reading. }
	Assign( F , Config_File );
	Rewrite( F );

	writeln( F , '#' );
	writeln( F , '# ATTENTION:' );
	writeln( F , '#   Only edit the config file if GearHead is not running.' );
	writeln( F , '#   Configuration overwritten at game exit.' );
	writeln( F , '#' );

	for t := 1 to NumMappedKeys do begin
		WriteLn( F, KeyMap[t].CmdName + ' ' + KeyMap[t].KCode );
	end;

	writeln( F, 'ANIMSPEED ' + BStr( FrameDelay ) );

	writeln( F, 'MECHACONTROL ' + ControlTypeName[ ControlMethod ] );
	writeln( F, 'CHARACONTROL ' + ControlTypeName[ CharacterMethod ] );
	writeln( F, 'WORLDCONTROL ' + ControlTypeName[ WorldMapMethod ] );

	writeln( F, 'MISSILEBV ' + BVTypeName[ DefMissileBV ] );
	writeln( F, 'BALLISTICBV ' + BVTypeName[ DefBallisticBV ] );
	writeln( F, 'BEAMGUNBV ' + BVTypeName[ DefBeamGunBV ] );

	if RPG_Use_Tactics then writeln( F , 'RPGMode Tactics' )
	else writeln( F , 'RPGMode Clock' );

	if Arena_Use_Tactics then writeln( F , 'ArenaMode Tactics' )
	else writeln( F , 'ArenaMode Clock' );

	AddBoolean( 'DIRECTSKILLOK' , Direct_Skill_Learning );
	AddBoolean( 'NOAUTOSAVE' , not DoAutoSave );
	AddBoolean( 'ALWAYSSAVECHARACTER' , Always_Save_Character );
	AddBoolean( 'NOCOMBATTAUNTS' , No_Combat_Taunts );

	AddBoolean( 'RELOAD_UNEQUIPPED_WEAPONS_AT_SHOP' , Reload_All_Weapons );

	AddBoolean( 'LOADPLOTSATSTART' , Load_Plots_At_Start );
	AddBoolean( 'MINIMAPON' , Display_Mini_Map );

	writeln( F , 'SCREENHEIGHT ' + BStr( ScreenRows ) );
	writeln( F , 'SCREENWIDTH ' + BStr( ScreenColumns ) );

	AddBoolean( 'WINDOW' , not DoFullScreen );
	AddBoolean( 'NOMOUSE' , not Mouse_Active );
	AddBoolean( 'NOPILLAGE' , not Pillage_On );
	AddBoolean( 'SHORTWALLS' , not Use_Tall_Walls );

	AddBoolean( 'LAPTOP_ISO_KEYS' ,  Iso_Dir_Offset <> 0 );
	AddBoolean( 'CYCLE_ALL_WEAPONS' , Cycle_All_Weapons );
	AddBoolean( 'MINIMAL_SCREEN_REFRESH' , Minimal_Screen_Refresh );
	AddBoolean( 'USE_SOFTWARE_SURFACE' , Use_Software_Surface );
	AddBoolean( 'NO_SPLASH_SCREEN_AT_START' , not Splash_Screen_At_Start );
	AddBoolean( 'REVERT_SLOWER_SAFER' , Revert_Slower_Safer );
	AddBoolean( 'NAMESON' , Names_Above_Heads );
	AddBoolean( 'PAPERDOLLS' , Use_Paper_Dolls );
	AddBoolean( 'USEMESH' , Mesh_On );
	AddBoolean( 'ERSATZ_MOUSE' , Ersatz_Mouse );
    AddBoolean( 'NO_TRANSPARENT_INTERFACE' , not Transparent_Interface );

	{ The "secret options" come at the end. These tokens only get }
	{ included if they're already set. }
	if XXRAN_Wizard then writeln( F , 'GIMMEGIMMECHOICE' );
	if ArenaMode_Wizard then writeln( F , 'GARYGYGAX' );
	if XXRAN_Debug then writeln( F , 'XXRANDEBUG' );
	if StdPlot_Debug then writeln( F , 'YOUARE#6' );
	if Full_RPGWorld_Info then writeln( F , 'DEMIURGE' );

	Close(F);
end;


Function MsgString( const MsgLabel: String ): String;
	{ Return the standard message string which has the requested }
	{ label. }
begin
	MsgString := SAttValue( Text_Messages , MsgLabel );
end;

initialization
	Text_Messages := LoadStringList( Standard_Message_File );
	LoadConfig;

finalization
	SaveConfig;
	DisposeSAtt( Text_Messages );

end.