forked from beefviper/hode-vs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
andy.cpp
1700 lines (1617 loc) · 48.1 KB
/
andy.cpp
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
/*
* Heart of Darkness engine rewrite
* Copyright (C) 2009-2011 Gregory Montoir (cyx@users.sourceforge.net)
*/
#include "game.h"
#include "random.h"
#include "util.h"
// probably rename this to anim.cpp as this updates most LvlObject, not only Andy
static const uint8_t andyOp1LookupTable[] = {
0, 0, 0, 0, 1, 1, 2, 2, 3, 4, 3, 4, 2, 2, 1, 1,
4, 3, 4, 3, 5, 6, 7, 8, 7, 8, 5, 6, 8, 7, 6, 5,
6, 5, 8, 7, 9, 9, 9, 9, 10, 10, 11, 11, 12, 13, 12, 13,
11, 11, 10, 10, 13, 12, 13, 12, 14, 15, 16, 17, 15, 14, 17, 16,
16, 17, 14, 15, 17, 16, 15, 14, 18, 19, 18, 19, 19, 18, 19, 18,
20, 20, 21, 21, 21, 21, 20, 20, 22, 23, 22, 23, 23, 22, 23, 22,
24, 24, 25, 25, 25, 25, 24, 24, 26, 26, 26, 26, 27, 27, 27, 27
};
int Game::moveAndyObjectOp1(int op) {
op = andyOp1LookupTable[op];
switch (op) {
case 0:
return 1;
case 1:
return _directionKeyMask & 1;
case 2:
return (_directionKeyMask >> 2) & 1;
case 3:
return (_directionKeyMask >> 1) & 1;
case 4:
return (_directionKeyMask >> 3) & 1;
case 5:
return ((_directionKeyMask & 3) == 3) ? 1 : 0;
case 6:
return ((_directionKeyMask & 9) == 9) ? 1 : 0;
case 7:
return ((_directionKeyMask & 6) == 6) ? 1 : 0;
case 8:
return ((_directionKeyMask & 12) == 12) ? 1 : 0;
case 9:
return (_directionKeyMask == 0) ? 1 : 0;
case 10:
return (~_directionKeyMask) & 1;
case 11:
return ((~_directionKeyMask) >> 2) & 1;
case 12:
return ((~_directionKeyMask) >> 1) & 1;
case 13:
return ((~_directionKeyMask) >> 3) & 1;
case 14:
return _directionKeyMask & 3;
case 15:
return _directionKeyMask & 9;
case 16:
return _directionKeyMask & 6;
case 17:
return _directionKeyMask & 12;
case 18:
return (_directionKeyMask == 2) ? 1 : 0;
case 19:
return (_directionKeyMask == 8) ? 1 : 0;
case 20:
return (_directionKeyMask == 1) ? 1 : 0;
case 21:
return (_directionKeyMask == 4) ? 1 : 0;
case 22:
return ((_directionKeyMask & 13) != 0) ? 1 : 0;
case 23:
return ((_directionKeyMask & 7) != 0) ? 1 : 0;
case 24:
return ((_directionKeyMask & 14) != 0) ? 1 : 0;
case 25:
return ((_directionKeyMask & 11) != 0) ? 1 : 0;
case 26:
return _directionKeyMask & 5;
case 27:
return _directionKeyMask & 10;
default:
error("moveAndyObjectOp1 op %d", op);
break;
}
return 0;
}
int Game::moveAndyObjectOp2(int op) {
switch (op) {
case 0:
return 1;
case 1:
return _actionKeyMask & 1;
case 2:
return (_actionKeyMask >> 1) & 1;
case 3:
return (_actionKeyMask >> 2) & 1;
case 4:
return ((_actionKeyMask & 3) == 3) ? 1 : 0;
case 5:
return ((_actionKeyMask & 6) == 6) ? 1 : 0;
case 6:
return ((_actionKeyMask & 5) == 5) ? 1 : 0;
case 7:
return ((_actionKeyMask & 7) == 7) ? 1 : 0;
case 8:
return (_actionKeyMask >> 3) & 1;
case 9:
return (_actionKeyMask == 0) ? 1 : 0;
case 10:
return (~_actionKeyMask) & 1;
case 11:
return ((~_actionKeyMask) >> 1) & 1;
case 12:
return ((~_actionKeyMask) >> 2) & 1;
case 13:
return (_actionKeyMask >> 4) & 1;
case 14:
return (_actionKeyMask >> 5) & 1;
case 15:
return ((_actionKeyMask & 48) == 48) ? 1 : 0;
case 16:
return (_actionKeyMask >> 6) & 1;
case 17:
return (_actionKeyMask == 1) ? 1 : 0;
case 18:
return (_actionKeyMask == 2) ? 1 : 0;
case 19:
return (_actionKeyMask == 4) ? 1 : 0;
case 20:
return (_actionKeyMask >> 7) & 1;
case 21:
return (_actionKeyMask == 8) ? 1 : 0;
case 22:
return (_actionKeyMask == 16) ? 1 : 0;
case 23:
return (_actionKeyMask == 32) ? 1 : 0;
case 24:
return (_actionKeyMask == 64) ? 1 : 0;
case 25:
return (_actionKeyMask == 128) ? 1 : 0;
case 26:
return ((_actionKeyMask & 24) == 24) ? 1 : 0;
case 27:
return ((_actionKeyMask & 96) == 96) ? 1 : 0;
case 28:
return ((_actionKeyMask & 192) == 192) ? 1 : 0;
case 29:
return ((_actionKeyMask & 3) == 0) ? 1 : 0;
case 30:
return ((_actionKeyMask & 6) == 0) ? 1 : 0;
case 31:
return ((_actionKeyMask & 5) == 0) ? 1 : 0;
case 32:
return ((_actionKeyMask & 7) == 0) ? 1 : 0;
case 33:
return ((~_actionKeyMask) >> 3) & 1;
case 34:
return ((~_actionKeyMask) >> 4) & 1;
case 35:
return ((~_actionKeyMask) >> 5) & 1;
case 36:
return ((~_actionKeyMask) >> 6) & 1;
case 37:
return ((~_actionKeyMask) >> 7) & 1;
case 38:
return ((_actionKeyMask & 3) != 0) ? 1 : 0;
case 39:
return ((_actionKeyMask & 6) != 0) ? 1 : 0;
case 40:
return ((_actionKeyMask & 5) != 0) ? 1 : 0;
case 41:
return ((_actionKeyMask & 7) != 0) ? 1 : 0;
case 42:
return ((_actionKeyMask & 3) == 1) ? 1 : 0;
case 43:
return ((_actionKeyMask & 5) == 1) ? 1 : 0;
case 44:
return ((_actionKeyMask & 3) == 2) ? 1 : 0;
case 45:
return ((_actionKeyMask & 6) == 2) ? 1 : 0;
case 46:
return ((_actionKeyMask & 5) == 4) ? 1 : 0;
case 47:
return ((_actionKeyMask & 6) == 4) ? 1 : 0;
default:
error("moveAndyObjectOp2 op %d", op);
break;
}
return 0;
}
static const int _andyMoveTable1[] = { 0, 1, -1, 513, 511, 512, -511, -513, -512 };
static const int _andyMoveTable2[] = { 0, 1, 512, 513, 1024, 1025, 1536, 1537 };
static const int _andyMoveTable3[] = { 0, -1, 512, 511, 1024, 1023, 1536, 1535 };
static const int _andyMoveTable4[] = { 0, 1, 512, 1, -511 };
static const int _andyMoveTable5[] = { 0, -1, 512, -1, -513 };
static const int _andyMoveTable6[] = { -1024, -1025, -1026, -512, -513, -514 };
static const int _andyMoveTable7[] = { -1024, -1023, -1022, -512, -511, -510 };
static const int _andyMoveTable8[] = { 0, 512, 1024, 1536 };
static const int _andyMoveTable9[] = { -1024, 1, -512, -1 };
static const int _andyMoveTable10[] = { -1024, -1, -512, 1 };
static const int _andyMoveTable11[] = { -509, -512 };
static const int _andyMoveTable12[] = { -515, -512 };
static const int _andyMoveTable13[] = { 1, 1, 1, 512, -1, -1 };
static const int _andyMoveTable14[] = { -1, -1, -1, 512, 1, 1 };
static const int _andyMoveTable15[] = { 1536, 512, 1, 512 };
static const int _andyMoveTable16[] = { 1536, 512, -1, 512 };
static const int _andyMoveTable17[] = { 1022, -1, 512, 1 };
static const int _andyMoveTable18[] = { 1026, 1, 512, -1 };
static const int _andyMoveTable19[] = { -2, -1, -1, 512, 1, 1 };
static const int _andyMoveTable20[] = { 2, 1, 1, 512, -1, -1 };
static const int _andyMoveTable21[] = { -1, -512, -1, -1, -511 };
static const int _andyMoveTable22[] = { 1, -512, 1, 1, -513 };
static const int _andyMoveTable23[] = { -1024, -512 };
static const int _andyMoveTable24[] = { -1024, -512 };
static const int _andyMoveTable25[] = { 1, -512, 1, 1, -511 };
static const int _andyMoveTable26[] = { -1, -512, -1, -1, -511 };
static const int _andyMoveTable27[] = { 1, 512, 512, 1, 1, 511, -1 };
static const int _andyMoveTable28[] = { -1, 512, 512, -1, -1, 513, 1 };
static const int _andyMoveTable29[] = { 1536, 512 };
static const int _andyMoveTable30[] = { 1536, 512 };
static const int _andyMoveTable31[] = { -1, 512, 512, -1, -1, 513, 1 };
static const int _andyMoveTable32[] = { 1, 512, 512, 1, 1, 511, -1 };
static const int _andyMoveTable33[] = { -1, -1, -1, 512, 1, 1 };
static const int _andyMoveTable34[] = { 1, 1, 1, 512, -1, -1 };
static const int _andyMoveTable35[] = {
0, 0, 8, 0, -8, 0, 8, 8, -8, 8, 0, 8, 8, -8, -8, -8,
0, -8, 16, 0, -16, 0, 16, 16, -16, 16, 0, 16, 16, -16, -16, -16,
24, 0, -24, 0, 24, 24, -24, 24, 0, 24, 24, -24, -24, -24, 0, 0,
};
static const int _andyMoveTable37[] = { -1021, 1027, 2048, -1027, 1021, 2048, -1021, -2048, -3069, -1027, -2048, -3075 };
static const int _andyMoveTable39[] = { 1027, 2048, 3075 };
static const int _andyMoveTable40[] = { 1021, 2048, 3069 };
static const int _andyMoveTable41[] = { -1025, 2, 1023, 2050 };
static const int _andyMoveTable42[] = { -1023, -2, 1025, 2046 };
static const int _andyMoveTable43[] = { -512, 1536, -515, -509, 1533, 1539 };
int Game::moveAndyObjectOp3(int op) {
switch (op) {
case 0:
return 1;
case 1: {
int offset = (_andyMoveMask & 1) != 0 ? 3 : 0;
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[_andyMoveTable37[offset + i] + _andyMaskBufferPos1] & 8) == 0) {
return 0;
}
}
}
return 1;
case 2: {
int i, offset = _andyMaskBufferPos1;
for (i = 0; i < 9; ++i) {
if ((_screenMaskBuffer[_andyMoveTable1[i] + offset] & 8) != 0) {
offset += _andyMoveTable1[i];
break;
}
}
if ((_screenMaskBuffer[offset + 2048] & 8) != 0) {
const int alignDy = (_andyLevelData0x288PosTablePtr[1].y + _andyMoveData.yPos) & 7;
_andyMoveData.yPos += _andyMoveTable35[i * 2 + 1] - alignDy;
const int alignDx = (_andyLevelData0x288PosTablePtr[1].x + _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[i * 2] - alignDx + 4;
if ((_andyMoveMask & 1) != 0) {
--_andyMoveData.xPos;
}
return 1;
}
}
return 0;
case 3:
for (int i = 0; i < 9; ++i) {
if ((_screenMaskBuffer[_andyMoveTable1[i] + _andyMaskBufferPos1] & 8) != 0) {
const int alignDx = (_andyLevelData0x288PosTablePtr[1].x + _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[i * 2] - alignDx + 4;
break;
}
}
return 1;
case 4: {
int offset = _andyMaskBufferPos1 - 512;
int ret = 0;
const int *p;
if (_andyMoveMask & 1) {
--offset;
p = &_andyMoveTable37[3];
} else {
++offset;
p = &_andyMoveTable37[0];
}
int _al = 0;
for (int i = 0; i < 9; ++i) {
if ((_screenMaskBuffer[_andyMoveTable1[i] + offset] & 8) == 0) {
continue;
}
ret = 1;
_al = i;
offset += _andyMoveTable1[i];
break;
}
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[p[i] + offset] & 8) != 0) {
continue;
}
return 0;
}
if (ret) {
const int alignDy = (_andyLevelData0x288PosTablePtr[1].y + _andyMoveData.yPos) & 7;
_andyMoveData.yPos += _andyMoveTable35[_al * 2 + 1] - alignDy - 8;
const int alignDx = (_andyLevelData0x288PosTablePtr[1].x + _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[_al * 2 + 0] - alignDx + 4;
if (_andyMoveMask & 1) {
_andyMoveData.xPos -= 9;
} else {
_andyMoveData.xPos += 8;
}
return ret;
}
}
return 0;
case 5:
return (_andyMoveState[8] >> 3) & 1;
case 6:
return (_andyMoveState[20] >> 3) & 1;
case 7:
return (_andyMoveState[28] >> 3) & 1;
case 8:
return (_andyMoveState[0] >> 3) & 1;
case 9: {
int offset = (_andyMoveMask & 1) != 0 ? -1 : 1;
int mask = _screenMaskBuffer[_andyMaskBufferPos1];
if ((mask & 1) != 0 && (_screenMaskBuffer[_andyMaskBufferPos1 + offset] & 1) != 0) {
return (mask & 4) != 0 ? 0 : 1;
}
mask = _screenMaskBuffer[_andyMaskBufferPos1 - 512];
if ((mask & 1) != 0 && (_screenMaskBuffer[_andyMaskBufferPos1 - 512 + offset] & 1) != 0) {
return (mask & 4) != 0 ? 0 : 1;
}
}
return 0;
case 10: {
const int offset = (_andyMoveMask & 1) != 0 ? 1 : -1;
if (_screenMaskBuffer[_andyMaskBufferPos5 + 512] & 1) {
if (_screenMaskBuffer[_andyMaskBufferPos5 + 512 + offset] & 1) {
return 1;
}
}
}
return 0;
case 11: {
const int index = (_andyMoveMask & 1) == 0 ? 5 : 3;
if ((_andyMoveState[index] & 8) != 0 && (_andyMoveState[16 + index] & 8) != 0) {
return 1;
}
}
return 0;
case 12: {
const int index = (_andyMoveMask & 1) == 0 ? 1 : 7;
if ((_andyMoveState[8 + index] & 8) != 0 && (_andyMoveState[24 + index] & 8) != 0) {
return 1;
}
}
return 0;
case 13:
return (_andyMoveState[8] & 9) == 0 ? 1 : 0;
case 14: {
const int index = (_andyMoveMask & 1) | 2;
return (_andyMoveState[4 + 8 * index] & 9) == 0 ? 1 : 0;
}
case 15: {
const int index = (_andyMoveMask & 1) == 0 ? 7 : -1;
return ((_andyMoveState[24 + index] >> 3) & (_andyMoveState[8 + index] >> 3)) & 1;
}
case 16: {
const int index = (_andyMoveMask & 1) == 0 ? 3 : 5;
return ((_andyMoveState[16 + index] >> 3) & (_andyMoveState[index] >> 3)) & 1;
}
case 17: {
const int index = (_andyMoveMask & 1) == 0 ? 7 : 1;
return ((_andyMoveState[16 + index] >> 3) & (_andyMoveState[index] >> 3)) & 1;
}
case 18: {
const int index = (_andyMoveMask & 1) == 0 ? 1 : 7;
return ((_andyMoveState[24 + index] >> 3) & (_andyMoveState[8 + index] >> 3)) & 1;
}
case 19: {
const int index = (_andyMoveMask & 1) == 0 ? 3 : 5;
return ((_andyMoveState[24 + index] >> 3) & (_andyMoveState[8 + index] >> 3)) & 1;
}
case 20: {
const int index = (_andyMoveMask & 1) == 0 ? 5 : 3;
return ((_andyMoveState[16 + index] >> 3) & (_andyMoveState[index] >> 3)) & 1;
}
case 21: {
const int index = (_andyMoveMask & 1) == 0 ? 5 : 3;
return ((_andyMoveState[24 + index] >> 3) & (_andyMoveState[8 + index] >> 3)) & 1;
}
case 22:
return (_andyMoveState[0] & 9) == 0 ? 1 : 0;
case 23: {
const int index = (~_andyMoveMask & 1) | 2;
return (_andyMoveState[4 + 8 * index] & 9) == 0 ? 1 : 0;
}
case 24: {
const int index = (_andyMoveMask & 1) == 0 ? 5 : 2;
return ((~(_andyMoveState[16 + index] & _andyMoveState[index])) >> 3) & 1;
}
case 25: {
const int index = (_andyMoveMask & 1) == 0 ? 1 : 6;
return ((~(_andyMoveState[24 + index] & _andyMoveState[8 + index])) >> 3) & 1;
}
case 26: {
const int index = (_andyMoveMask & 1) == 0 ? 3 : 5;
return ((~(_andyMoveState[16 + index] & _andyMoveState[index])) >> 3) & 1;
}
case 27: {
const int index = (_andyMoveMask & 1) == 0 ? 5 : 3;
return ((~(_andyMoveState[24 + index] & _andyMoveState[8 + index])) >> 3) & 1;
}
case 28: {
const int index = (_andyMoveMask & 1) == 0 ? 1 : 7;
return ((~_andyMoveState[index]) >> 3) & 1;
}
case 29: {
const int index = (_andyMoveMask & 1) == 0 ? 7 : 1;
return ((~_andyMoveState[8 + index]) >> 3) & 1;
}
case 30: {
int index1, index2;
if (_andyMoveMask & 1) {
index1 = 2;
index2 = 3;
} else {
index1 = 6;
index2 = 5;
}
if (((_andyMoveState[16 + index1] & _andyMoveState[index1]) & 8) == 0 || (_andyMoveState[index2] & 1) != 0) {
return 0;
}
}
return 1;
case 31: {
int index1, index2;
if (_andyMoveMask & 1) {
index1 = 6;
index2 = 5;
} else {
index1 = 2;
index2 = 3;
}
if (((_andyMoveState[24 + index1] & _andyMoveState[8 + index1]) & 8) == 0 || (_andyMoveState[8 + index2] & 1) != 0) {
return 0;
}
}
return 1;
case 32: {
int index1, index2;
if (_andyMoveMask & 1) {
index1 = 2;
index2 = 3;
} else {
index1 = 6;
index2 = 5;
}
if (((_andyMoveState[16 + index1] & _andyMoveState[index1]) & 8) != 0 && (_andyMoveState[index2] & 1) == 0) {
return 0;
}
}
return 1;
case 33: {
int index1, index2;
if (_andyMoveMask & 1) {
index1 = 6;
index2 = 5;
} else {
index1 = 2;
index2 = 3;
}
if (((_andyMoveState[24 + index1] & _andyMoveState[8 + index1]) & 8) != 0 && (_andyMoveState[index2] & 1) == 0) {
return 0;
}
}
return 1;
case 34: {
const int index = (_andyMoveMask & 1) == 0 ? 1 : 7;
return ((_andyMoveState[16 + index] >> 3) & (_andyMoveState[index] >> 3)) & 1;
}
case 35:
if ((_screenMaskBuffer[_andyMaskBufferPos3 - 514] | _screenMaskBuffer[_andyMaskBufferPos3 - 513]) & 8) {
if ((_screenMaskBuffer[_andyMaskBufferPos3 + 514] | _screenMaskBuffer[_andyMaskBufferPos3 + 513]) & 8) {
return 1;
} else {
return 0;
}
}
if ((_screenMaskBuffer[_andyMaskBufferPos3 - 511] | _screenMaskBuffer[_andyMaskBufferPos3 - 510]) & 8) {
if ((_screenMaskBuffer[_andyMaskBufferPos3 + 511] | _screenMaskBuffer[_andyMaskBufferPos3 + 510]) & 8) {
return 1;
} else {
return 0;
}
}
return 0;
case 36:
if (_andyMoveMask & 1) {
int _al = 0;
int ret = 1;
int offset = _andyMaskBufferPos2;
if (_screenMaskBuffer[_andyMaskBufferPos2 + 1] & 8) {
++offset;
_al = 2;
} else if (_screenMaskBuffer[_andyMaskBufferPos2 + 2] & 8) {
offset += 2;
_al = 0;
} else if (_screenMaskBuffer[_andyMaskBufferPos2 + 3] & 8) {
offset += 3;
_al = 1;
} else if (_screenMaskBuffer[_andyMaskBufferPos2 + 4] & 8) {
offset += 4;
_al = 9;
} else {
return 0;
}
int xPos = _andyMoveTable37[3];
int i = 0;
while (_screenMaskBuffer[xPos + offset] & 8) {
++i;
if (i >= 2) {
const int alignDx = (_andyLevelData0x288PosTablePtr[2].x + _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[_al * 2] - alignDx + 7;
return ret;
}
xPos = _andyMoveTable37[3 + i];
}
} else {
int ret = 1;
int offset = _andyMaskBufferPos1;
int _al = 0;
if (_screenMaskBuffer[_andyMaskBufferPos1 - 1] & 8) {
--offset;
_al = 2;
} else if (_screenMaskBuffer[_andyMaskBufferPos1 - 2] & 8) {
offset -= 2;
_al = 10;
} else if (_screenMaskBuffer[_andyMaskBufferPos1 - 3] & 8) {
offset -= 3;
_al = 17;
}
int xPos = _andyMoveTable37[0];
int i = 0;
while (_screenMaskBuffer[xPos + offset] & 8) {
++i;
if (i >= 2) {
const int alignDx = (_andyLevelData0x288PosTablePtr[1].x - _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[_al * 2] - alignDx + 4;
return ret;
}
xPos = _andyMoveTable37[i];
}
}
return 0;
case 37:
if ((_andyMoveMask & 1) == 0) {
int ret = 1;
int _al = 0;
int offset = _andyMaskBufferPos1;
if (_screenMaskBuffer[_andyMaskBufferPos1 + 1] & 8) {
++offset;
_al = 2;
} else if (_screenMaskBuffer[_andyMaskBufferPos1 + 2] & 8) {
offset += 2;
_al = 0;
} else if (_screenMaskBuffer[_andyMaskBufferPos1 + 3] & 8) {
offset += 3;
_al = 1;
} else if (_screenMaskBuffer[_andyMaskBufferPos1 + 4] & 8) {
offset += 4;
_al = 9;
} else {
ret = 0;
}
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[offset + _andyMoveTable37[3 + i]] & 8) == 0) {
return 0;
}
}
if (ret) {
const int alignDx = (_andyLevelData0x288PosTablePtr[1].x + _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[_al * 2] - alignDx + 7;
}
return ret;
} else {
int ret = 1;
int _al = 0;
int offset = _andyMaskBufferPos2;
if (_screenMaskBuffer[_andyMaskBufferPos2 - 1] & 8) {
--offset;
_al = 2;
} else if (_screenMaskBuffer[_andyMaskBufferPos2 - 2] & 8) {
offset -= 2;
_al = 10;
} else if (_screenMaskBuffer[_andyMaskBufferPos2 - 3] & 8) {
offset -= 3;
_al = 17;
}
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[offset + _andyMoveTable37[i]] & 8) == 0) {
return 0;
}
}
const int alignDx = (_andyLevelData0x288PosTablePtr[2].x + _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[_al * 2] - alignDx + 4;
return ret;
}
return 0;
case 38:
if (_screenMaskBuffer[_andyMaskBufferPos3 + 1536] & 8) {
if ((_screenMaskBuffer[_andyMaskBufferPos3 + 2557] | _screenMaskBuffer[_andyMaskBufferPos3 + 2563]) & 8) {
return 1;
} else {
return 0;
}
}
if ((_screenMaskBuffer[_andyMaskBufferPos3 + 1533] | _screenMaskBuffer[_andyMaskBufferPos3 + 1534] | _screenMaskBuffer[_andyMaskBufferPos3 + 1535]) & 8) {
if ((_screenMaskBuffer[_andyMaskBufferPos3 + 2562] | _screenMaskBuffer[_andyMaskBufferPos3 + 2561] | _screenMaskBuffer[_andyMaskBufferPos3 + 2560]) & 8) {
return 1;
} else {
return 0;
}
}
if ((_screenMaskBuffer[_andyMaskBufferPos3 + 1539] | _screenMaskBuffer[_andyMaskBufferPos3 + 1538] | _screenMaskBuffer[_andyMaskBufferPos3 + 1537]) & 8) {
if ((_screenMaskBuffer[_andyMaskBufferPos3 + 2558] | _screenMaskBuffer[_andyMaskBufferPos3 + 2559] | _screenMaskBuffer[_andyMaskBufferPos3 + 2560]) & 8) {
return 1;
} else {
return 0;
}
}
return 0;
case 39:
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos5] & 1) == 0) {
continue;
}
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos4] & 1) == 0) {
continue;
}
return 1;
}
return 0;
case 40:
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos5] & 1) == 0) {
continue;
}
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos4] & 1) == 0) {
continue;
}
return 0;
}
return 1;
case 41: {
const int *p = (_andyMoveMask & 1) == 0 ? _andyMoveTable2 : _andyMoveTable3;
for (int i = 0; i < 2; ++i) {
int mask = _screenMaskBuffer[_andyMaskBufferPos1 + p[i]];
mask |= _screenMaskBuffer[_andyMaskBufferPos2 + p[i]];
mask |= _screenMaskBuffer[_andyMaskBufferPos4 + p[i]];
mask |= _screenMaskBuffer[_andyMaskBufferPos5 + p[i]];
mask |= _screenMaskBuffer[_andyMaskBufferPos3 + p[i]];
mask |= _screenMaskBuffer[_andyMaskBufferPos0 + p[i]];
if ((mask & 6) != 0) {
return 1;
}
}
}
return 0;
case 42: {
int ret = 1;
int _al = 0;
int offset = _andyMaskBufferPos4;
if ((_andyMoveData.flags1 & 0x10) != 0) {
if (_screenMaskBuffer[offset + 512] & 8) {
offset += 512;
_al = 9;
} else if (_screenMaskBuffer[offset + 511] & 8) {
offset += 511;
_al = 1;
} else if (_screenMaskBuffer[offset + 510] & 8) {
offset += 510;
_al = 0;
} else if (_screenMaskBuffer[offset + 509] & 8) {
offset += 509;
_al = 2;
} else if (_screenMaskBuffer[offset + 508] & 8) {
offset += 508;
_al = 10;
} else {
ret = 0;
}
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[_andyMoveTable39[i] + offset] & 8) == 0) {
return 0;
}
}
if (ret) {
const int alignDx = (_andyLevelData0x288PosTablePtr[5].x - _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[_al * 2] - alignDx + 7;
return ret;
}
} else {
if (_screenMaskBuffer[offset + 512] & 8) {
offset += 512;
_al = 10;
} else if (_screenMaskBuffer[offset + 513] & 8) {
offset += 513;
_al = 2;
} else if (_screenMaskBuffer[offset + 514] & 8) {
offset += 514;
_al = 0;
} else if (_screenMaskBuffer[offset + 515] & 8) {
offset += 515;
_al = 1;
} else if (_screenMaskBuffer[offset + 516] & 8) {
offset += 516;
_al = 9;
} else {
ret = 0;
}
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[_andyMoveTable40[i] + offset] & 8) == 0) {
return 0;
}
}
if (ret) {
const int alignDx = (_andyLevelData0x288PosTablePtr[5].x - _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[_al * 2] - alignDx;
return ret;
}
}
}
return 0;
case 43: {
int ret = 1;
int _al = 0;
int offset = _andyMaskBufferPos5;
if ((_andyMoveData.flags1 & 0x10) == 0) {
if (_screenMaskBuffer[offset + 512] & 8) {
offset += 512;
_al = 9;
} else if (_screenMaskBuffer[offset + 511] & 8) {
offset += 511;
_al = 1;
} else if (_screenMaskBuffer[offset + 510] & 8) {
offset += 510;
_al = 0;
} else if (_screenMaskBuffer[offset + 509] & 8) {
offset += 509;
_al = 2;
} else if (_screenMaskBuffer[offset + 508] & 8) {
offset += 508;
_al = 10;
} else {
ret = 0;
}
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[_andyMoveTable39[i] + offset] & 8) == 0) {
return 0;
}
}
if (ret) {
const int alignDx = (_andyLevelData0x288PosTablePtr[4].x + _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[_al * 2] - alignDx + 6;
return ret;
}
} else {
if (_screenMaskBuffer[offset + 512] & 8) {
offset += 512;
_al = 10;
} else if (_screenMaskBuffer[offset + 513] & 8) {
offset += 513;
_al = 2;
} else if (_screenMaskBuffer[offset + 514] & 8) {
offset += 514;
_al = 0;
} else if (_screenMaskBuffer[offset + 515] & 8) {
offset += 515;
_al = 1;
} else if (_screenMaskBuffer[offset + 516] & 8) {
offset += 516;
_al = 9;
} else {
ret = 0;
}
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[_andyMoveTable40[i] + offset] & 8) == 0) {
return 0;
}
}
if (ret) {
const int alignDx = (_andyLevelData0x288PosTablePtr[4].x + _andyMoveData.xPos) & 7;
_andyMoveData.xPos += _andyMoveTable35[_al * 2] - alignDx + 1;
return ret;
}
}
}
return 0;
case 44: {
const int offset = (_andyMoveMask & 1) == 0 ? _andyMaskBufferPos5 - 1 : _andyMaskBufferPos5 + 1;
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + offset] & 1) != 0) {
return 0;
}
}
}
return 1;
case 45: {
const int *p = (_andyMoveMask & 1) != 0 ? _andyMoveTable4 : _andyMoveTable5;
for (int i = 0; i < 5; ++i) {
if ((_screenMaskBuffer[_andyMaskBufferPos1 + p[i]] & 6) != 0) {
return 1;
}
}
}
return 0;
case 46: {
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos3] & 1) != 0) {
return 1;
}
}
}
return 0;
case 47: {
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos3] & 1) != 0) {
return 0;
}
}
}
return 1;
case 48: {
const int *p = (_andyMoveMask & 1) != 0 ? _andyMoveTable4 : _andyMoveTable5;
for (int i = 0; i < 5; ++i) {
if ((_screenMaskBuffer[_andyMaskBufferPos2 + p[i]] & 6) != 0) {
return 1;
}
}
}
return 0;
case 49: {
const int d = (_andyMoveMask & 1) != 0 ? _andyMaskBufferPos4 - 1 : _andyMaskBufferPos4 + 1;
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + d] & 1) != 0) {
return 0;
}
}
}
return 1;
case 50:
for (int i = 0; i < 3; ++i) {
if (((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos4] | _screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos5]) & 1) != 0) {
return 1;
}
}
return 0;
case 51:
for (int i = 0; i < 3; ++i) {
if (((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos5] | _screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos4]) & 1) != 0) {
return 0;
}
}
return 1;
case 52:
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos5] & 1) != 0) {
return 1;
}
}
return 0;
case 53:
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos5] & 1) != 0) {
return 0;
}
}
return 1;
case 54:
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos4] & 1) != 0) {
return 1;
}
}
return 0;
case 55:
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos4] & 1) != 0) {
return 0;
}
}
return 1;
case 56:
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos1] & 6) != 0) {
return 1;
}
}
return 0;
case 57:
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos4] & 2) != 0) {
return 1;
}
}
return 0;
case 58:
case 60:
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos2] & 6) != 0) {
return 1;
}
}
return 0;
case 59:
case 61:
for (int i = 0; i < 2; ++i) {
if ((_screenMaskBuffer[_andyMoveTable8[i] + _andyMaskBufferPos5] & 2) != 0) {
return 1;
}
}
return 0;
case 62: {
const int *p = (_andyMoveMask & 1) == 0 ? _andyMoveTable4 : _andyMoveTable5;
for (int i = 0; i < 5; ++i) {
if ((_screenMaskBuffer[_andyMaskBufferPos1 + p[i]] & 6) != 0) {
return 1;
}
}
}
return 0;
case 63: {
const int *p = (_andyMoveMask & 1) == 0 ? _andyMoveTable4 : _andyMoveTable5;
for (int i = 0; i < 5; ++i) {
if ((_screenMaskBuffer[_andyMaskBufferPos2 + p[i]] & 6) != 0) {
return 1;
}
}
}
return 0;
case 64: {
const int *p = (_andyMoveMask & 1) == 0 ? _andyMoveTable39 : _andyMoveTable40;
for (int i = 0; i < 3; ++i) {
if ((_screenMaskBuffer[_andyMaskBufferPos1 + p[i]] & 8) == 0) {
return 0;
}
}
}
return 1;
case 65: {
const int *p = (_andyMoveMask & 1) == 0 ? _andyMoveTable40 : _andyMoveTable39;
for (int i = 0; i < 3; ++i) {