forked from jwvhewitt/gearhead-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
congfx.pp
426 lines (366 loc) · 11.4 KB
/
congfx.pp
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
unit ConGfx;
{
GearHead: Arena, 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
}
interface
uses crt;
const
{ For the purpose of making things easy on me, the }
{ screen is divided into several zones. }
NumZones = 30;
ZONE_Map = 1;
ZONE_Clock = 2;
ZONE_Info = 3;
ZONE_Menu = 4;
ZONE_Menu1 = 5;
ZONE_Menu2 = 6;
ZONE_Dialog = 7;
ZONE_HQPilots = 8;
ZONE_HQMecha = 9;
ZONE_CharGenMenu = 10;
ZONE_CharGenDesc = 11;
ZONE_InteractStatus = 12;
ZONE_InteractMenu = 13;
ZONE_InteractMsg = 14;
ZONE_InteractTotal = 15;
ZONE_TextInput = 16;
ZONE_EqpMenu = 17;
ZONE_InvMenu = 18;
ZONE_CharGenPrompt = 19;
ZONE_Biography = 20;
ZONE_SkillGenMenu = 21;
ZONE_SkillGenDesc = 22;
ZONE_SubInfo = 23;
ZONE_Factory_Caption = 24;
ZONE_Factory_Parts = 25;
ZONE_YesNoTotal = 26;
ZONE_YesNoPrompt = 27;
ZONE_YesNoMenu = 28;
ZONE_UsagePrompt = 29;
ZONE_UsageMenu = 30;
ZONE_MemoText = 27;
ZONE_MemoMenu = 28;
ScreenZone: Array [1..NumZones , 1..4] of Integer = (
( 2 , 2 , -32 , -6 ),
( -30 , -5 , -1 , -5 ),
( -30 , 1 , -1 , 10 ),
( -30 , 11 , -1 , -6 ),
( -30 , 11 , -1 , 13 ),
( -30 , 14 , -1 , -6 ),
( 1 , -4 , -1 , 0 ),
( 3 , 3 , -62 , -6 ),
( -60 , 3 , -32 , -6 ),
( -29 , 4 , -2 , 0 ),
( 2 , -4 , -32 , 0 ),
( 2 , 2 , 46 , 5 ),
( 2 , 13 , 46 , 19 ),
( 2 , 6 , 46 , 12 ),
( 1 , 1 , 47 , 20 ),
( -71 , -15 , -40 , -12 ),
( 4 , 3 , 44 , 7 ),
( 4 , 9 , 44 , 18 ),
( -28 , 2 , -3 , 2 ),
( 4 , -10 , -34 , -6 ),
( -29 , -21 , -2 , -10 ),
( -28 , -7 , -3 , -2 ),
( -29 , 2 , -2 , 9 ),
( 2 , 2 , -32 , -20 ),
( 2 , -18 , -32 , -6 ),
( -69 , -21 , -37 , -9 ),
( -68 , -20 , -38 , -13 ),
( -68 , -11 , -38 , -10 ),
( -68 , -20 , -38 , -17 ),
( -68 , -15 , -38 , -10 )
);
{ *** STANDARD COLORS *** }
StdBlack: Byte = Black;
StdWhite: Byte = White;
MenuItem: Byte = Cyan;
MenuSelect: Byte = LightCyan;
TerrainGreen: Byte = Green;
PlayerBlue: Byte = LightBlue;
AllyPurple: Byte = LightMagenta;
EnemyRed: Byte = Red;
NeutralGrey: Byte = LightGray;
InfoGreen: Byte = Green;
InfoHiLight: Byte = LightGreen;
TextboxGrey: Byte = DarkGray;
AttackColor: Byte = LightRed;
NeutralBrown: Byte = Yellow;
BorderBlue: Byte = Blue;
Procedure ClipZone( ZoneNumber: Integer );
Procedure MaxClipZone;
Procedure ClrZone( ZoneNumber: Integer );
Procedure ClrScreen;
Procedure DrawZoneBorder( X1, Y1, X2, Y2, Color: Byte );
Procedure DrawZoneBorder( Z: Integer; C: Byte );
Procedure DrawExtBorder( Z: Integer; C: Byte );
Procedure DrawMapBorder( N,E,S,W: Boolean );
Procedure DrawBPBorder;
Procedure DrawCharGenBorder;
Procedure SetupCombatDisplay;
Procedure SetupHQDisplay;
Procedure SetupFactoryDisplay;
Procedure SetupYesNoDisplay;
Procedure SetupMemoDisplay;
Procedure SetupInteractDisplay( TeamColor: Byte );
implementation
uses ui4gh;
{$I boxdraw.inc}
Procedure ClipZone( ZoneNumber: Integer );
{ Set the clipping bounds to this defined zone. }
begin
Window( ScreenZone[ZoneNumber,1] , ScreenZone[ZoneNumber,2] , ScreenZone[ZoneNumber,3] , ScreenZone[ZoneNumber,4] );
end;
Procedure MaxClipZone;
{ Restore the clip area to the maximum possible area. }
begin
Window( 1 , 1 , ScreenColumns , ScreenRows );
end;
Procedure ClrZone( ZoneNumber: Integer );
{ Clear the specified screen zone. }
begin
ClipZone( ZoneNumber );
TextBackground( Black );
ClrScr;
MaxClipZone;
end;
Procedure ClrScreen;
{ Clear the entire screen. }
begin
TextBackground( Black );
MaxClipZone;
ClrScr;
end;
Procedure DrawZoneBorder( X1, Y1, X2, Y2, Color: Byte );
{ Do a lovely box in the specified color around the specified zone. }
var
t: integer; {a counter, of the house of CBM.}
begin
{Set the color for the box.}
TextColor(Color);
TextBackground( Black );
{$IFDEF NeedShifts}
ShiftAltCharset;
{$ENDIF}
{Print the four corners.}
GotoXY(X1,Y1);
write(BoxUpperLeft);
GotoXY(X2,Y1);
write(BoxUpperRight);
GotoXY(X1,Y2);
write(BoxLowerLeft);
GotoXY(X2,Y2);
write(BoxLowerRight);
{Print the two horizontal edges.}
for t := X1+1 to X2-1 do begin
GotoXY(t,Y1);
write(BoxHorizontal);
GotoXY(t,Y2);
write(BoxHorizontal);
end;
{Print the two vertical edges.}
for t := Y1+1 to Y2-1 do begin
GotoXY(X1,t);
write(BoxVertical);
GotoXY(X2,t);
write(BoxVertical);
end;
{$IFDEF NeedShifts}
ShiftNormalCharset;
{$ENDIF}
end;
Procedure DrawZoneBorder( Z: Integer; C: Byte );
{ Do a box around this zone. }
begin
DrawZoneBorder( ScreenZone[Z,1], ScreenZone[Z,2], ScreenZone[Z,3], ScreenZone[Z,4], C );
end;
Procedure DrawExtBorder( Z: Integer; C: Byte );
{ Do a box around this zone. }
begin
DrawZoneBorder( ScreenZone[Z,1] - 1, ScreenZone[Z,2] - 1, ScreenZone[Z,3] + 1, ScreenZone[Z,4] + 1, C );
end;
Procedure DrawMapBorder( N,E,S,W: Boolean );
{ Draw a box one character outside of the map zone. }
{ If any of the directions are set to TRUE, print a "MORE" }
{ prompt along that side. }
var
T: Integer;
begin
{ Start by drawing the border itself. }
DrawZoneBorder( ScreenZone[ ZONE_Map , 1 ] - 1 , ScreenZone[ ZONE_Map , 2 ] - 1 , ScreenZone[ ZONE_Map , 3 ] + 1 , ScreenZone[ ZONE_Map , 4 ] + 1 , Cyan );
{ Draw "MORE"s as appropriate. }
If N then begin
GotoXY( ( ScreenZone[ ZONE_Map , 1 ] + ScreenZone[ ZONE_Map , 3 ] ) div 2 - 2 , ScreenZone[ ZONE_Map , 2 ] - 1 );
Write( '+++++' );
end;
If S then begin
GotoXY( ( ScreenZone[ ZONE_Map , 1 ] + ScreenZone[ ZONE_Map , 3 ] ) div 2 - 2 , ScreenZone[ ZONE_Map , 4 ] + 1 );
Write( '+++++' );
end;
If W then begin
for t := 1 to 4 do begin
GotoXY( ScreenZone[ ZONE_Map , 1 ] - 1 , ( ScreenZone[ ZONE_Map , 2 ] + ScreenZone[ ZONE_Map , 4 ] ) div 2 - 2 + T );
Write( '+' );
end;
end;
If E then begin
for t := 1 to 4 do begin
GotoXY( ScreenZone[ ZONE_Map , 3 ] + 1 , ( ScreenZone[ ZONE_Map , 2 ] + ScreenZone[ ZONE_Map , 4 ] ) div 2 - 2 + T );
Write( '+' );
end;
end;
end;
Procedure DrawBPBorder;
{ Do the border for the BackPack routines. }
var
T: Integer;
begin
DrawZoneBorder( ScreenZone[ ZONE_EqpMenu , 1 ] - 1 , ScreenZone[ ZONE_EqpMenu , 2 ] - 1 , ScreenZone[ ZONE_InvMenu , 3 ] + 1 , ScreenZone[ ZONE_InvMenu , 4 ] + 1 , White );
GotoXY( ScreenZone[ ZONE_EqpMenu , 1 ] , ScreenZone[ ZONE_EqpMenu , 4 ] + 1 );
{$IFDEF NeedShifts}
ShiftAltCharset;
{$ENDIF}
for t := 1 to (ScreenZone[ ZONE_EqpMenu , 3 ] - ScreenZone[ ZONE_EqpMenu , 1 ] + 1 ) do
write(BoxSeperator);
{$IFDEF NeedShifts}
ShiftNormalCharset;
{$ENDIF}
end;
Procedure DrawCharGenBorder;
{ Do the border for the character generator routines. }
begin
DrawZoneBorder( ScreenZone[ ZONE_Map , 1 ] - 1 , ScreenZone[ ZONE_Map , 2 ] - 1 , ScreenZone[ ZONE_Map , 3 ] + 1 , ScreenZone[ ZONE_Map , 4 ] + 1 , PlayerBlue );
DrawZoneBorder( ScreenZone[ ZONE_CharGenPrompt , 1 ] - 1 , ScreenZone[ ZONE_CharGenPrompt , 2 ] - 1 , ScreenZone[ ZONE_CharGenPrompt , 3 ] + 1 , ScreenZone[ ZONE_CharGenPrompt , 4 ] + 1 , Blue );
end;
Procedure SetupCombatDisplay;
{ Clear the screen & draw boxes. }
begin
ClrScr;
end;
Procedure SetupHQDisplay;
{ CLear the screen & draw boxes. }
begin
ClrScr;
end;
Procedure SetupFactoryDisplay;
{ CLear the screen & draw boxes. }
begin
ClrScr;
DrawExtBorder( ZONE_Factory_Parts , LightGray );
DrawExtBorder( ZONE_Factory_Caption , White );
end;
Procedure SetupYesNoDisplay;
{ Set up the display for the YesNo box. }
var
T: Integer;
begin
ClrZone( ZONE_YesNoTotal );
DrawZoneBorder( ZONE_YesNoTotal , LightBlue );
GotoXY( ScreenZone[ ZONE_YesNoMenu , 1 ] , ScreenZone[ ZONE_YesNoMenu , 2 ] - 1 );
{$IFDEF NeedShifts}
ShiftAltCharset;
{$ENDIF}
for t := 1 to (ScreenZone[ ZONE_YesNoMenu , 3 ] - ScreenZone[ ZONE_YesNoMenu , 1 ] + 1 ) do
write(BoxSeperator);
{$IFDEF NeedShifts}
ShiftNormalCharset;
{$ENDIF}
end;
Procedure SetupMemoDisplay;
{ Draw a nice border and some instructions for the memo display. }
var
T: Integer;
begin
ClrZone( ZONE_YesNoTotal );
DrawZoneBorder( ZONE_YesNoTotal , LightMagenta );
GotoXY( ScreenZone[ ZONE_YesNoMenu , 1 ] , ScreenZone[ ZONE_YesNoMenu , 2 ] - 1 );
{$IFDEF NeedShifts}
ShiftAltCharset;
{$ENDIF}
for t := 1 to (ScreenZone[ ZONE_YesNoMenu , 3 ] - ScreenZone[ ZONE_YesNoMenu , 1 ] + 1 ) do
write(BoxSeperator);
{$IFDEF NeedShifts}
ShiftNormalCharset;
{$ENDIF}
end;
Procedure SetupInteractDisplay( TeamColor: Byte );
{ Draw the display for the interaction interface. }
begin
ClrZone( ZONE_InteractTotal );
DrawZoneBorder( ZONE_InteractTotal , TeamColor );
end;
Procedure AnchorEdge(var value: Integer; limit: Integer);
begin
if value < 1 then value := limit + value;
end;
Procedure CheckDimensions;
{ If the screen dimensions have been redefined, we'll need to alter }
{ the dimensions of the screen zones. }
var
t, uRows, uCols, iRowOff, iColOff: Integer;
begin
if ScreenRows > 57 then uRows := 57 else uRows := ScreenRows;
if ScreenColumns > 83 then uCols := 83 else uCols := ScreenColumns;
iRowOff := (uRows - 25) div 2;
iColOff := (uCols - 78) div 2;
for t := 1 to NumZones do begin
case t of
ZONE_InteractStatus, ZONE_InteractMenu,
ZONE_InteractMsg, ZONE_InteractTotal,
ZONE_InvMenu, ZONE_EqpMenu:
begin
{ Center the interaction and inventory windows within
the map window }
ScreenZone[t,1] := ScreenZone[t,1] + iColOff;
ScreenZone[t,2] := ScreenZone[t,2] + iRowOff;
ScreenZone[t,3] := ScreenZone[t,3] + iColOff;
ScreenZone[t,4] := ScreenZone[t,4] + iRowOff;
end;
ZONE_Dialog:
begin
{ The dialog window recieves any slop lines at the
bottom of the screen }
AnchorEdge(ScreenZone[t,1],uCols);
AnchorEdge(ScreenZone[t,2],uRows);
AnchorEdge(ScreenZone[t,3],uCols);
ScreenZone[t,4] := ScreenRows;
end;
else
begin
{ Normal zone anchoring. Most zone corners are
specified relative to edges of an screen area
which ranges from 80x25 to 83x57 depending on the
underlying terminal support.}
AnchorEdge(ScreenZone[t,1],uCols);
AnchorEdge(ScreenZone[t,2],uRows);
AnchorEdge(ScreenZone[t,3],uCols);
AnchorEdge(ScreenZone[t,4],uRows);
end;
end;
end;
end;
initialization
CursorOff; {LINUX ALERT... Maybe also doesn't work on Win2000}
ClrScr;
CheckDimensions;
finalization
{$IFNDEF DEBUG}
NormVideo;
ClrScr;
{$ENDIF}
CursorOn;
end.