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
|
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001 Ludvig Strigeus
* Copyright (C) 2001-2006 The ScummVM project
*
* 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.
*
* $Header$
*
*/
#include "common/stdafx.h"
#include "common/config-file.h"
#include "common/config-manager.h"
#include "common/str.h"
#include "scumm/actor.h"
#include "scumm/charset.h"
#include "scumm/intern_he.h"
#include "scumm/object.h"
#include "scumm/resource.h"
#include "scumm/resource_v7he.h"
#include "scumm/scumm.h"
#include "scumm/sound.h"
#include "scumm/util.h"
namespace Scumm {
#define OPCODE(x) _OPCODE(ScummEngine_v80he, x)
void ScummEngine_v80he::setupOpcodes() {
static const OpcodeEntryV80he opcodes[256] = {
/* 00 */
OPCODE(o6_pushByte),
OPCODE(o6_pushWord),
OPCODE(o72_pushDWord),
OPCODE(o6_pushWordVar),
/* 04 */
OPCODE(o72_getScriptString),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_wordArrayRead),
/* 08 */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_wordArrayIndexedRead),
/* 0C */
OPCODE(o6_dup),
OPCODE(o6_not),
OPCODE(o6_eq),
OPCODE(o6_neq),
/* 10 */
OPCODE(o6_gt),
OPCODE(o6_lt),
OPCODE(o6_le),
OPCODE(o6_ge),
/* 14 */
OPCODE(o6_add),
OPCODE(o6_sub),
OPCODE(o6_mul),
OPCODE(o6_div),
/* 18 */
OPCODE(o6_land),
OPCODE(o6_lor),
OPCODE(o6_pop),
OPCODE(o72_isAnyOf),
/* 1C */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* 20 */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* 24 */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* 28 */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* 2C */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* 30 */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* 34 */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* 38 */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* 3C */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* 40 */
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_writeWordVar),
/* 44 */
OPCODE(o6_invalid),
OPCODE(o80_createSound),
OPCODE(o80_getFileSize),
OPCODE(o6_wordArrayWrite),
/* 48 */
OPCODE(o80_stringToInt),
OPCODE(o80_getSoundVar),
OPCODE(o80_localizeArrayToRoom),
OPCODE(o6_wordArrayIndexedWrite),
/* 4C */
OPCODE(o6_invalid),
OPCODE(o80_readConfigFile),
OPCODE(o80_writeConfigFile),
OPCODE(o6_wordVarInc),
/* 50 */
OPCODE(o72_resetCutscene),
OPCODE(o6_invalid),
OPCODE(o72_findObjectWithClassOf),
OPCODE(o6_wordArrayInc),
/* 54 */
OPCODE(o72_getObjectImageX),
OPCODE(o72_getObjectImageY),
OPCODE(o72_captureWizImage),
OPCODE(o6_wordVarDec),
/* 58 */
OPCODE(o72_getTimer),
OPCODE(o72_setTimer),
OPCODE(o72_getSoundPosition),
OPCODE(o6_wordArrayDec),
/* 5C */
OPCODE(o6_if),
OPCODE(o6_ifNot),
OPCODE(o72_startScript),
OPCODE(o6_startScriptQuick),
/* 60 */
OPCODE(o72_startObject),
OPCODE(o72_drawObject),
OPCODE(o72_printWizImage),
OPCODE(o72_getArrayDimSize),
/* 64 */
OPCODE(o72_getNumFreeArrays),
OPCODE(o6_stopObjectCode),
OPCODE(o6_stopObjectCode),
OPCODE(o6_endCutscene),
/* 68 */
OPCODE(o6_cutscene),
OPCODE(o6_invalid),
OPCODE(o6_freezeUnfreeze),
OPCODE(o80_cursorCommand),
/* 6C */
OPCODE(o6_breakHere),
OPCODE(o6_ifClassOfIs),
OPCODE(o6_setClass),
OPCODE(o6_getState),
/* 70 */
OPCODE(o80_setState),
OPCODE(o6_setOwner),
OPCODE(o6_getOwner),
OPCODE(o6_jump),
/* 74 */
OPCODE(o70_startSound),
OPCODE(o6_stopSound),
OPCODE(o6_invalid),
OPCODE(o6_stopObjectScript),
/* 78 */
OPCODE(o6_panCameraTo),
OPCODE(o6_actorFollowCamera),
OPCODE(o6_setCameraAt),
OPCODE(o6_loadRoom),
/* 7C */
OPCODE(o6_stopScript),
OPCODE(o6_walkActorToObj),
OPCODE(o6_walkActorTo),
OPCODE(o6_putActorAtXY),
/* 80 */
OPCODE(o6_putActorAtObject),
OPCODE(o6_faceActor),
OPCODE(o6_animateActor),
OPCODE(o6_doSentence),
/* 84 */
OPCODE(o70_pickupObject),
OPCODE(o6_loadRoomWithEgo),
OPCODE(o6_invalid),
OPCODE(o6_getRandomNumber),
/* 88 */
OPCODE(o6_getRandomNumberRange),
OPCODE(o6_invalid),
OPCODE(o6_getActorMoving),
OPCODE(o6_isScriptRunning),
/* 8C */
OPCODE(o70_getActorRoom),
OPCODE(o6_getObjectX),
OPCODE(o6_getObjectY),
OPCODE(o6_getObjectOldDir),
/* 90 */
OPCODE(o6_getActorWalkBox),
OPCODE(o6_getActorCostume),
OPCODE(o6_findInventory),
OPCODE(o6_getInventoryCount),
/* 94 */
OPCODE(o6_invalid),
OPCODE(o6_beginOverride),
OPCODE(o6_endOverride),
OPCODE(o6_setObjectName),
/* 98 */
OPCODE(o6_isSoundRunning),
OPCODE(o6_setBoxFlags),
OPCODE(o6_invalid),
OPCODE(o70_resourceRoutines),
/* 9C */
OPCODE(o72_roomOps),
OPCODE(o72_actorOps),
OPCODE(o6_invalid),
OPCODE(o6_getActorFromXY),
/* A0 */
OPCODE(o72_findObject),
OPCODE(o6_pseudoRoom),
OPCODE(o6_getActorElevation),
OPCODE(o6_getVerbEntrypoint),
/* A4 */
OPCODE(o72_arrayOps),
OPCODE(o6_invalid),
OPCODE(o6_drawBox),
OPCODE(o6_pop),
/* A8 */
OPCODE(o6_getActorWidth),
OPCODE(o60_wait),
OPCODE(o6_getActorScaleX),
OPCODE(o6_getActorAnimCounter1),
/* AC */
OPCODE(o80_drawWizPolygon),
OPCODE(o6_isAnyOf),
OPCODE(o72_systemOps),
OPCODE(o6_isActorInBox),
/* B0 */
OPCODE(o6_delay),
OPCODE(o6_delaySeconds),
OPCODE(o6_delayMinutes),
OPCODE(o6_stopSentence),
/* B4 */
OPCODE(o6_printLine),
OPCODE(o6_printText),
OPCODE(o6_printDebug),
OPCODE(o6_printSystem),
/* B8 */
OPCODE(o6_printActor),
OPCODE(o6_printEgo),
OPCODE(o72_talkActor),
OPCODE(o72_talkEgo),
/* BC */
OPCODE(o72_dimArray),
OPCODE(o6_stopObjectCode),
OPCODE(o6_startObjectQuick),
OPCODE(o6_startScriptQuick2),
/* C0 */
OPCODE(o72_dim2dimArray),
OPCODE(o72_traceStatus),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* C4 */
OPCODE(o6_abs),
OPCODE(o6_distObjectObject),
OPCODE(o6_distObjectPt),
OPCODE(o6_distPtPt),
/* C8 */
OPCODE(o72_kernelGetFunctions),
OPCODE(o70_kernelSetFunctions),
OPCODE(o6_delayFrames),
OPCODE(o6_pickOneOf),
/* CC */
OPCODE(o6_pickOneOfDefault),
OPCODE(o6_stampObject),
OPCODE(o72_drawWizImage),
OPCODE(o72_debugInput),
/* D0 */
OPCODE(o6_getDateTime),
OPCODE(o6_stopTalking),
OPCODE(o6_getAnimateVariable),
OPCODE(o6_invalid),
/* D4 */
OPCODE(o6_shuffle),
OPCODE(o72_jumpToScript),
OPCODE(o6_band),
OPCODE(o6_bor),
/* D8 */
OPCODE(o6_isRoomScriptRunning),
OPCODE(o60_closeFile),
OPCODE(o72_openFile),
OPCODE(o72_readFile),
/* DC */
OPCODE(o72_writeFile),
OPCODE(o72_findAllObjects),
OPCODE(o72_deleteFile),
OPCODE(o72_rename),
/* E0 */
OPCODE(o80_drawLine),
OPCODE(o72_getPixel),
OPCODE(o60_localizeArrayToScript),
OPCODE(o80_pickVarRandom),
/* E4 */
OPCODE(o6_setBoxSet),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
/* E8 */
OPCODE(o6_invalid),
OPCODE(o70_seekFilePos),
OPCODE(o72_redimArray),
OPCODE(o60_readFilePos),
/* EC */
OPCODE(o70_copyString),
OPCODE(o70_getStringWidth),
OPCODE(o70_getStringLen),
OPCODE(o70_appendString),
/* F0 */
OPCODE(o70_concatString),
OPCODE(o70_compareString),
OPCODE(o70_isResourceLoaded),
OPCODE(o72_readINI),
/* F4 */
OPCODE(o72_writeINI),
OPCODE(o70_getStringLenForWidth),
OPCODE(o70_getCharIndexInString),
OPCODE(o6_invalid),
/* F8 */
OPCODE(o72_getResourceSize),
OPCODE(o72_setFilePath),
OPCODE(o72_setWindowCaption),
OPCODE(o70_polygonOps),
/* FC */
OPCODE(o70_polygonHit),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
};
_opcodesV80he = opcodes;
}
void ScummEngine_v80he::executeOpcode(byte i) {
OpcodeProcV80he op = _opcodesV80he[i].proc;
(this->*op) ();
}
const char *ScummEngine_v80he::getOpcodeDesc(byte i) {
return _opcodesV80he[i].desc;
}
void ScummEngine_v80he::o80_createSound() {
byte subOp = fetchScriptByte();
switch (subOp) {
case 27:
createSound(_heSndResId, pop());
break;
case 217:
createSound(_heSndResId, -1);
break;
case 232:
_heSndResId = pop();
break;
case 255:
// dummy case
break;
default:
error("o80_createSound: default case %d", subOp);
}
}
void ScummEngine_v80he::o80_getFileSize() {
byte filename[256];
copyScriptString(filename, sizeof(filename));
Common::File f;
if (!f.open((char *)filename)) {
push(-1);
} else {
push(f.size());
f.close();
}
}
void ScummEngine_v80he::o80_stringToInt() {
int id, len, val;
byte *addr;
char string[100];
id = pop();
addr = getStringAddress(id);
if (!addr)
error("o80_stringToInt: Reference to zeroed array pointer (%d)", id);
len = resStrLen(getStringAddress(id)) + 1;
memcpy(string, addr, len);
val = atoi(string);
push(val);
}
void ScummEngine_v80he::o80_getSoundVar() {
int var = pop();
int snd = pop();
push(_sound->getSoundVar(snd, var));
}
void ScummEngine_v80he::o80_localizeArrayToRoom() {
int slot = pop();
localizeArray(slot, 0xFF);
}
void ScummEngine_v80he::o80_readConfigFile() {
byte option[128], section[128], filename[256];
ArrayHeader *ah;
Common::String entry;
int len;
copyScriptString(option, sizeof(option));
copyScriptString(section, sizeof(section));
copyScriptString(filename, sizeof(filename));
convertFilePath(filename, true);
Common::ConfigFile ConfFile;
ConfFile.loadFromFile((const char *)filename);
byte subOp = fetchScriptByte();
switch (subOp) {
case 43: // HE 100
case 6: // number
ConfFile.getKey((const char *)option, (const char *)section, entry);
push(atoi(entry.c_str()));
break;
case 77: // HE 100
case 7: // string
ConfFile.getKey((const char *)option, (const char *)section, entry);
writeVar(0, 0);
len = resStrLen((const byte *)entry.c_str());
ah = defineArray(0, kStringArray, 0, 0, 0, len);
memcpy(ah->data, entry.c_str(), len);
push(readVar(0));
break;
default:
error("o80_readConfigFile: default type %d", subOp);
}
debug(0, "o80_readConfigFile: Filename %s Section %s Option %s Value %s", filename, section, option, entry.c_str());
}
void ScummEngine_v80he::o80_writeConfigFile() {
byte filename[256], section[256], option[256], string[1024];
int value;
byte subOp = fetchScriptByte();
switch (subOp) {
case 43: // HE 100
case 6: // number
value = pop();
sprintf((char *)string, "%d", value);
copyScriptString(option, sizeof(option));
copyScriptString(section, sizeof(section));
copyScriptString(filename, sizeof(filename));
convertFilePath(filename, true);
break;
case 77: // HE 100
case 7: // string
copyScriptString(string, sizeof(string));
copyScriptString(option, sizeof(option));
copyScriptString(section, sizeof(section));
copyScriptString(filename, sizeof(filename));
convertFilePath(filename, true);
break;
default:
error("o80_writeConfigFile: default type %d", subOp);
}
Common::ConfigFile ConfFile;
ConfFile.loadFromFile((const char *)filename);
ConfFile.setKey((char *)option, (char *)section, (char *)string);
ConfFile.saveToFile((const char *)filename);
debug(0,"o80_writeConfigFile: Filename %s Section %s Option %s String %s", filename, section, option, string);
}
void ScummEngine_v80he::o80_cursorCommand() {
int a, i;
int args[16];
byte subOp = fetchScriptByte();
switch (subOp) {
case 0x13:
case 0x14:
a = pop();
_wiz->loadWizCursor(a);
break;
case 0x3C:
pop();
a = pop();
_wiz->loadWizCursor(a);
break;
case 0x90: // SO_CURSOR_ON Turn cursor on
_cursor.state = 1;
break;
case 0x91: // SO_CURSOR_OFF Turn cursor off
_cursor.state = 0;
break;
case 0x92: // SO_USERPUT_ON
_userPut = 1;
break;
case 0x93: // SO_USERPUT_OFF
_userPut = 0;
break;
case 0x94: // SO_CURSOR_SOFT_ON Turn soft cursor on
_cursor.state++;
if (_cursor.state > 1)
error("Cursor state greater than 1 in script");
break;
case 0x95: // SO_CURSOR_SOFT_OFF Turn soft cursor off
_cursor.state--;
break;
case 0x96: // SO_USERPUT_SOFT_ON
_userPut++;
break;
case 0x97: // SO_USERPUT_SOFT_OFF
_userPut--;
break;
case 0x9C: // SO_CHARSET_SET
initCharset(pop());
break;
case 0x9D: // SO_CHARSET_COLOR
getStackList(args, ARRAYSIZE(args));
for (i = 0; i < 16; i++)
_charsetColorMap[i] = _charsetData[_string[1]._default.charset][i] = (unsigned char)args[i];
break;
default:
error("o80_cursorCommand: default case %x", subOp);
}
VAR(VAR_CURSORSTATE) = _cursor.state;
VAR(VAR_USERPUT) = _userPut;
}
void ScummEngine_v80he::o80_setState() {
int state = pop();
int obj = pop();
state &= 0x7FFF;
putState(obj, state);
removeObjectFromDrawQue(obj);
}
void ScummEngine_v80he::o80_drawWizPolygon() {
WizImage wi;
wi.x1 = wi.y1 = pop();
wi.resNum = pop();
wi.state = 0;
wi.flags = kWIFIsPolygon;
_wiz->displayWizImage(&wi);
}
/**
* Draw a 'line' between two points.
*
* @param x1 the starting x coordinate
* @param y1 the starting y coordinate
* @param x the ending x coordinate
* @param y the ending y coordinate
* @param step the step size used to render the line, only ever 'step'th point is drawn
* @param type the line type -- points are rendered by drawing actors (type == 2),
* wiz images (type == 3), or pixels (any other type)
* @param id the id of an actor, wizimage or color (low bit) & flag (high bit)
*/
void ScummEngine_v80he::drawLine(int x1, int y1, int x, int y, int step, int type, int id) {
debug(0,"drawLine: x1 %d y1 %d x %d y %d, step %d type %d id %d", x1, y1, x, y, step, type, id);
if (step < 0) {
step = -step;
}
if (step == 0) {
step = 1;
}
const int dx = x - x1;
const int dy = y - y1;
const int absDX = ABS(dx);
const int absDY = ABS(dy);
const int maxDist = MAX(absDX, absDY);
y = y1;
x = x1;
if (type == 2) {
Actor *a = derefActor(id, "drawLine");
a->drawActorToBackBuf(x, y);
} else if (type == 3) {
WizImage wi;
wi.flags = 0;
wi.y1 = y;
wi.x1 = x;
wi.resNum = id;
wi.state = 0;
_wiz->displayWizImage(&wi);
} else {
drawPixel(x, y, id);
}
int stepCount = 0;
int tmpX = 0;
int tmpY = 0;
for (int i = 0; i <= maxDist; i++) {
tmpX += absDX;
tmpY += absDY;
int drawFlag = 0;
if (tmpX > maxDist) {
drawFlag = 1;
tmpX -= maxDist;
if (dx >= 0) {
x++;
} else {
x--;
}
}
if (tmpY > maxDist) {
drawFlag = dy;
tmpY -= maxDist;
if (dy >= 0) {
y++;
} else {
y--;
}
}
if (drawFlag == 0)
continue;
if ((stepCount++ % step) != 0 && maxDist != i)
continue;
if (type == 2) {
Actor *a = derefActor(id, "drawLine");
a->drawActorToBackBuf(x, y);
} else if (type == 3) {
WizImage wi;
wi.flags = 0;
wi.y1 = y;
wi.x1 = x;
wi.resNum = id;
wi.state = 0;
_wiz->displayWizImage(&wi);
} else {
drawPixel(x, y, id);
}
}
}
void ScummEngine_v80he::drawPixel(int x, int y, int flags) {
byte *src, *dst;
VirtScreen *vs;
if (x < 0 || x > 639)
return;
if (y < 0)
return;
if ((vs = findVirtScreen(y)) == NULL)
return;
markRectAsDirty(vs->number, x, y, x, y + 1);
if ((flags & 0x4000) || (flags & 0x2000000)) {
src = vs->getPixels(x, y);
dst = vs->getBackPixels(x, y);
*dst = *src;
} else if ((flags & 0x2000) || (flags & 4000000)) {
src = vs->getBackPixels(x, y);
dst = vs->getPixels(x, y);
*dst = *src;
} else if (flags & 0x8000000) {
error("drawPixel: unsupported flag 0x%x", flags);
} else {
dst = vs->getPixels(x, y);
*dst = flags;
if ((flags & 0x8000) || (flags & 0x1000000)) {
dst = vs->getBackPixels(x, y);
*dst = flags;
}
}
}
void ScummEngine_v80he::o80_drawLine() {
int id, step, x, y, x1, y1;
step = pop();
id = pop();
y = pop();
x = pop();
y1 = pop();
x1 = pop();
byte subOp = fetchScriptByte();
switch (subOp) {
case 55:
drawLine(x1, y1, x, y, step, 2, id);
break;
case 63:
drawLine(x1, y1, x, y, step, 3, id);
break;
case 66:
drawLine(x1, y1, x, y, step, 1, id);
break;
default:
error("o80_drawLine: default case %d", subOp);
}
}
void ScummEngine_v80he::o80_pickVarRandom() {
int num;
int args[100];
int32 dim1end;
num = getStackList(args, ARRAYSIZE(args));
int value = fetchScriptWord();
if (readVar(value) == 0) {
defineArray(value, kDwordArray, 0, 0, 0, num);
if (value & 0x8000)
localizeArray(readVar(value), 0xFF);
else if (value & 0x4000)
localizeArray(readVar(value), _currentScript);
if (num > 0) {
int16 counter = 0;
do {
writeArray(value, 0, counter + 1, args[counter]);
} while (++counter < num);
}
shuffleArray(value, 1, num);
writeArray(value, 0, 0, 2);
push(readArray(value, 0, 1));
return;
}
num = readArray(value, 0, 0);
ArrayHeader *ah = (ArrayHeader *)getResourceAddress(rtString, readVar(value));
dim1end = FROM_LE_32(ah->dim1end);
if (dim1end < num) {
int32 var_2 = readArray(value, 0, num - 1);
shuffleArray(value, 1, dim1end);
num = 1;
if (readArray(value, 0, 1) == var_2 && dim1end >= 3) {
int32 tmp = readArray(value, 0, 2);
writeArray(value, 0, num, tmp);
writeArray(value, 0, 2, var_2);
}
}
writeArray(value, 0, 0, num + 1);
push(readArray(value, 0, num));
}
} // End of namespace Scumm
|