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
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This code is based on the original source code of Lord Avalot d'Argent version 1.3.
* Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
*/
/*
��� ��� ���� ��� ��� �� ��� ����� ��� �� � ���� ��� ��� ��� �
�� �� � � � � ��� �� � � � � � � ��� ���� � �� ��� �
� � � �� �� ��� � � � � � ��� � �� ��� � � � ��� ���
BASHER Handles the keyboard. */
#define __basher_implementation__
/* Note: this unit can record keystrokes, for the demo. If you want it
to do this, define the o.c.c. RECORD. Setting gyro.demo to True will
cause them to be played back. */
#include "basher.h"
#include "enhanced.h"
#include "lucerna.h"
#include "Graph.h"
#include "scrolls.h"
#include "acci.h"
#include "trip5.h"
#include "pingo.h"
#include "dropdown.h"
#include "logger.h"
#include "Sticks.h"
#include "enid.h"
namespace Avalanche {
boolean entering_filename;
byte left_margin;
void plottext() {
const array<0, 2, byte> p = {{0, 1, 3}};
byte x, y, n;
x = 0;
if (mouse_near_text()) super_off();
cursor_off();
for (n = 0; n <= 2; n ++)
for (y = 0; y <= 7; y ++) {
for (x = 1; x <= length(current); x ++)
mem[0xa000 * p[n]*pagetop + 12882 + y * 80 + x] = little[current[x]][y];
fillchar(mem[0xa000 * p[n]*pagetop + 12883 + y * 80 + x], 77 - x, '\0');
}
cursor_on();
super_on();
}
void wipetext() {
const array<0, 2, byte> n = {{0, 1, 3}};
byte y, p;
if (mouse_near_text()) super_off();
cursor_off();
for (y = 0; y <= 7; y ++)
for (p = 0; p <= 2; p ++)
fillchar(mem[0xa000 * n[p]*pagetop + 12883 + y * 80], 77, '\0');
quote = true;
curpos = 1;
cursor_on();
super_on();
}
/*procedure cursor;
begin
if curflash=0 then
begin
if mouse_near_text then Super_Off;
cursoron:=not cursoron;
mem[$A000*13442+curpos]:=not mem[$A000*13442+curpos];
mem[$A000*pagetop+13442+curpos]:=not mem[$A000*pagetop+13442+curpos];
curflash:=17;
Super_On;
end else dec(curflash);
end;*/
void do_cursor() {
bytefield bf;
byte fv;
mem[0xac00 * 13442 + curpos] = ~ mem[0xac00 * 13442 + curpos];
{
bf.x1 = curpos + 1;
bf.x2 = curpos + 2;
bf.y1 = 168;
bf.y2 = 168;
}
for (fv = 0; fv <= 1; fv ++) getset[fv].remember(bf);
}
void cursor_on() {
if (cursoron) return;
do_cursor();
cursoron = true;
}
void cursor_off() {
if (! cursoron) return;
do_cursor();
cursoron = false;
}
void get_demorec() {
demofile >> demo_rec;
inchar = demo_rec.key;
extd = demo_rec.extd;
demo_rec.delay -= 1;
}
#ifdef RECORD
void record_one() {
demo_rec.delay = count;
demo_rec.key = inchar;
demo_rec.extd = extd;
demofile << demo_rec;
count = 0;
}
#endif
/*
procedure storeline(whatwhat:string);
var
fv:byte;
what:string[77];
ok:boolean;
function upline(x:string):string;
var fv:byte; n:string[77];
begin
for fv:=1 to length(x) do n[fv]:=upcase(x[fv]);
n[0]:=x[0]; upline:=n;
end;
begin
what:=upline(whatwhat); ok:=false;
for fv:=1 to 20 do
if what=upline(previous^[fv]) then
begin { it already exists, in string "fv" }
move(previous^[fv+1],previous^[fv],(20-fv)*78);
previous^[20]:=whatwhat; ok:=true;
end;
if ok then exit;
{ it's not on the list, so add it }
move(previous^[2],previous^[1],1482); { shove up }
previous^[20]:=whatwhat;
end;
*/
void typein();
static char firstchar(string x) {
char firstchar_result;
firstchar_result = x[1];
return firstchar_result;
}
static void try_dd() { /* This asks the Parsekey proc in Dropdown if it knows it. */
parsekey(inchar, extd);
}
void typein() {
byte w;
inkey();
#ifdef RECORD record_one(); #endif
switch (inchar) {
case RANGE_15('\40', '\56'):
case '\60' ... '\337':
case '\341' ... '\377':
if (ddm_o.menunow) {
parsekey(inchar, extd);
} else {
if (length(current) < 76) {
if ((inchar == '"') || (inchar == '`')) {
if (quote) inchar = '`';
else inchar = '"';
quote = ! quote; /* Quote- Unquote... */
}
insert(inchar, current, curpos);
curpos += 1;
plottext();
} else blip();
}
break;
case '\10':
if (! ddm_o.menunow) {
if (curpos > left_margin) {
curpos -= 1;
if (set::of('"', '`', eos).has(current[curpos])) quote = ! quote;
Delete(current, curpos, 1);
plottext();
} else blip();
}
break;
case '\0':
case '\340': {
switch (extd) {
/* Function keys: */
case cf1:
callverb(vb_help);
break; /* f1 - help (obviously) */
case cf2:
fxtoggle();
break; /* f2 - sound */
case ccf2:
case cf11: {
clearwords();
callverb(vb_save);
}
break; /* ^f2 - save */
case cf3:
if (length(current) < length(/*previous^[20]*/last)) { /* f3 - rec last */
current = current + copy(/*previous^[20]*/last, length(current) + 1, 255);
curpos = length(current) + 1;
plottext();
}
break;
case ccf3:
case cf12: {
clearwords();
callverb(vb_load);
}
break; /* ^f3 - load */
case cf4:
callverb(vb_restart);
break; /* f4 - restart game */
case cf5: {
person = pardon;
thing = pardon;
callverb(firstchar(f5_does())); /* f5 - get up/ whatever */
}
break;
case cf6:
callverb(vb_pause);
break; /* f6 - pause */
case cf7:
callverb(vb_open);
break; /* f7 - open door */
case cf8:
callverb(vb_look);
break; /* f8 - look */
case cf9:
callverb(vb_score);
break; /* f9 - score */
case ccf7:
major_redraw();
break; /* ^f7 - open door */
case cf10:
case c_ax:
case caf4: {
#ifdef RECORD
display("Hi. You have just finished recording. GIED.");
close(demofile);
exit(0);
#endif
callverb(vb_quit); /* f10, alt-X, alt-f4 - quit */
}
break;
case ccf5:
back_to_bootstrap(2);
break; /* ^f5 - Dos shell. */
case csf10:
callverb(vb_info);
break; /* sf10 - version */
case c_ab:
callverb(vb_boss);
break; /* alt-B */
case c_ad:
display("Wrong game!");
break; /* alt-D */
case ccleft:
if (curpos > left_margin) {
cursor_off();
curpos -= 1;
cursor_on();
}
break; /* ^left */
case ccright:
if (curpos <= length(current)) { /* ^right */
cursor_off();
curpos += 1;
cursor_on();
}
break;
case cchome: {
cursor_off();
curpos = 1;
cursor_on();
}
break; /* ^home */
case ccend: {
cursor_off();
curpos = length(current) + 1;
cursor_on();
}
break; /* ^end */
case c_ar:
oh = 177;
break; /* alt-R = repeater (re-chime) */
case cup:
case cdown:
case cleft:
case cright:
case cpgup:
case cpgdn:
case chome:
case cend:
if (ddm_o.menunow) try_dd();
else tripkey(extd);
break; /* Up/Down/Left/Right/PgUp/PgDn */
case cnum5:
tripkey(extd);
break; /* Numeric 5 */
case cdel:
if (! ddm_o.menunow) {
if (curpos <= length(current)) {
if (set::of('"', '`', eos).has(current[curpos])) quote = ! quote;
Delete(current, curpos, 1);
plottext();
} else blip();
}
break;
default:
try_dd();
}
}
break;
case cescape:
case '/':
if (ddm_o.menunow) { /* Escape */
ddm_o.wipe();
} else if (entering_filename) {
normal_edit();
wipetext();
} else
ddm_m.getcertain(ddm_o.menunum);
break;
case creturn:
if (ddm_o.menunow) try_dd(); /* Return */
else {
log_command(current);
if (entering_filename) {
edna_save(copy(current, 24, 255));
normal_edit();
wipetext();
} else {
if (current != "") last = current;
parse();
do_that();
if (! entering_filename) {
current = "";
wipetext();
}
}
}
break;
case '\11':
callverb(vb_inv);
break; /* Ctrl-I= inventory */
case '\7':
errorled();
break;
case '\25': {
current = "";
wipetext();
}
break;
case '\27': {
tr[1].xs = walk;
newspeed();
}
break;
case '\22': {
tr[1].xs = run;
newspeed();
}
break;
case '\2':
bosskey();
break;
case '\12':
ctrl = cjoy;
break; /* Joystick */
case '\13':
ctrl = ckey;
break; /* Keyboard */
case '\3':
callverb(vb_quit);
break; /* Ctrl-C= request to quit */
}
showrw();
if (demo) get_demorec();
}
/* 'x'..'z': begin setvisualpage(ord(extd)-63); write(#7); inkey; end;
'�': begin setvisualpage(0); write(#7); inkey; end;*/
void keyboard_link() {
state(defaultled); /* if defaultled=1 then on; { For the menus }*/
joykeys(); /* Test joystick buttons- I know that's not keyboard. */
if (demo) {
if (keypressede()) exit(0);
if (demo_rec.delay > 0)
demo_rec.delay -= 1;
else typein();
return;
}
#ifdef RECORD count += 1; #endif
if (! keypressede()) return;
if (keyboardclick) click();
typein();
}
boolean demo_ready() {
boolean demo_ready_result;
if (demo_rec.delay > 0) {
slowdown();
demo_rec.delay -= 1;
}
demo_ready_result = demo_rec.delay == 0;
return demo_ready_result;
}
void filename_edit() {
entering_filename = true;
current = "Filename\? (Esc=cancel):";
left_margin = 24;
curpos = 24;
plottext();
}
void normal_edit() {
entering_filename = false;
current = "";
left_margin = 1;
curpos = 1;
}
class unit_basher_initialize {
public:
unit_basher_initialize();
};
static unit_basher_initialize basher_constructor;
unit_basher_initialize::unit_basher_initialize() {
/* new(previous);*/ last = "";
normal_edit();
if (demo) {
assign(demofile, "demo.avd");
reset(demofile);
}
#ifdef RECORD
count = 0;
assign(demofile, "demo.avd");
rewrite(demofile);
#endif
}
} // End of namespace Avalanche.
|