-
Notifications
You must be signed in to change notification settings - Fork 4
/
movement.asm
3411 lines (3198 loc) · 70.6 KB
/
movement.asm
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
SEGMENT CODE ; 7
; Movement code and tick function
%include "base.inc"
%include "constants.asm"
%include "structs.asm"
%include "variables.asm"
%include "func.mac"
%include "if.mac"
%include "extern.inc"
%include "windows.inc"
; 0
; DoTick advances the game one tick.
; It handles movement for Chip, including mouse movement,
; buffered moves, slipping, and boosting; it calls
; SlipLoop and MonsterLoop to update monster positions;
; and it plays the timer sound when the clock is low.
;
func DoTick
sub sp,byte +0xc
push di
push si
%arg tick:word
%local ydir:word
%local xdir:word
%local local_8:word
%local hDC:word
; get the device context
push word [hwndBoard] ; hWnd
call far USER.GetDC ; 13 KERNEL.GetDC
mov [hDC],ax
; check whether we're on an even tick or an odd tick
test byte [tick],0x1
jz .evenTick
jmp word .oddTick
.evenTick: ; 24
mov bx,[GameStatePtr]
; if chip is sliding, don't do anything
cmp word [bx+IsSliding],byte +0x0
if nz
jmp word .monsterloop
endif ; 32
; If ChipHasMoved is set, just clear it
cmp word [bx+ChipHasMoved],byte +0x0
jz .tryBufferedKeystroke
.clearAlreadyMovedFlag: ; 39
mov bx,[GameStatePtr]
mov word [bx+ChipHasMoved],0x0
jmp word .monsterloop
.tryBufferedKeystroke: ; 46
; Use a buffered keystroke if we have one (and if chip isn't dead)
cmp word [bx+IsBuffered],byte +0x0
if nz
cmp word [bx+Autopsy],byte NotDeadYet
if e
push byte +0x1
push byte +0x1
push word [bx+BufferedY]
push word [bx+BufferedX]
push ax
call far MoveChip ; 61 7:1184
add sp,byte +0xa
endif ; 69
; ...and clear the keystroke regardless
mov bx,[GameStatePtr]
mov word [bx+IsBuffered],0x0
mov bx,[GameStatePtr]
mov word [bx+HaveMouseTarget],0x0
jmp word .monsterloop
endif
.tryMouseMovement: ; 80
; we don't have a buffered keystroke
; But we might have a mouse target...
cmp word [bx+HaveMouseTarget],byte +0x0
if z
jmp word .standAroundLikeAnIdiot
endif ; 8a
; If we've reached the target, clear HaveMouseTarget and ChipHasMoved and get on with it
; di = mousex - chipx
mov ax,[bx+MouseTargetX] ; mouse target x
sub ax,[bx+ChipX]
mov di,ax
; si = mousey - chipy
mov si,[bx+MouseTargetY] ; mouse target y
sub si,[bx+ChipY]
or ax,ax
jnz .mouseTryLargestDirection
or si,si
jnz .mouseTryLargestDirection
mov [bx+HaveMouseTarget],ax ; = 0
jmp short .clearAlreadyMovedFlag
; mov [bx+ChipHasMoved], 0
; jmp .monsterloop
.mouseTryLargestDirection: ; aa
; If we /haven't/ reached the target yet, make a step towards it
; First, figure out the proper direction
; cx = abs(x distance)
cwd
xor ax,dx
sub ax,dx
mov cx,ax
; ax = abs(y distance)
mov ax,si
cwd
xor ax,dx
sub ax,dx
; if ydistance >= xdistance
cmp ax,cx
if ge
or si,si
if g
; north
mov word [xdir],0
mov word [ydir],1
jmp short .label13
endif ; cc
; south
mov word [xdir],0
mov word [ydir],-1
else ; d8
or di,di
if g
; east
mov word [xdir],1
else ; e4
; west
mov word [xdir],-1
endif ; e9
mov word [ydir],0
endif ; ee
.label13:
; If chip is dead, forget all that; go do something else
cmp word [bx+Autopsy],byte +0x0
if nz
jmp word .dead
endif
.moveChipAttempt1: ; f8
; Actually move chip
; last argument = (xdist == 0 || ydist == 0)
or si,si
jz .label18
or di,di
jz .label18
mov word [local_8],0x0
jmp short .label19
nop
.label18: ; 108
mov word [local_8],0x1
.label19: ; 10d
push word [local_8]
push byte +0x1
push word [ydir]
push word [xdir]
push word [hDC]
call far MoveChip ; 11b 7:1184
add sp,byte +0xa
or ax,ax
; If we succeeded, or chip died, go deal with it
if nz
jmp word .dead
endif ; 12a
mov bx,[GameStatePtr]
cmp [bx+HaveMouseTarget],ax ; 0
jz .dead
.mouseTryOtherDirection:
; Otherwise we must have been blocked
; Try the other direction
; abs(di)
mov ax,di
cwd
xor ax,dx
sub ax,dx
mov cx,ax
; abs(si)
mov ax,si
cwd
xor ax,dx
sub ax,dx
cmp ax,cx
if l
jmp word .chooseNorthOrSouth2
endif ; 14d
; if xdist > 0, dir = (1,0)
or di,di
if g
; east
mov word [xdir],1
.setYdirToZero2: ; 154
mov word [ydir],0
jmp short .moveChipAttempt2
nop
endif ; 15c
; if xdist < 0, dir = (-1,0)
or di,di
if l
; west
mov word [xdir],-1
jmp short .setYdirToZero2
nop
endif
.chooseNothing2: ; 168
; if xdist == 0, dir = (0,0)
xor ax,ax
mov [ydir],ax
mov [xdir],ax
.moveChipAttempt2: ; 170
; if chip died in the first attempt, go deal with that
mov bx,[GameStatePtr]
cmp word [bx+Autopsy],byte +0x0
jnz .dead
; otherwise clear the HasMoved flag and carry on
mov word [bx+ChipHasMoved],0x0
; do we have a direction?
cmp word [xdir],byte +0x0
jnz .label27
cmp word [ydir],byte +0x0
jz .label28
.label27: ; 18d
push byte +0x1
push byte +0x1
push word [ydir]
push word [xdir]
push word [hDC]
call far MoveChip ; 19a 7:1184
add sp,byte +0xa
or ax,ax
jnz .dead
.label28: ; 1a6
mov bx,[GameStatePtr]
mov word [bx+HaveMouseTarget],0x0
.dead: ; 1b0
mov bx,[GameStatePtr]
cmp word [bx+Autopsy],byte +0x0
jnz .clearMouseTarget
mov ax,[bx+MouseTargetX]
cmp [bx+ChipX],ax
if nz
jmp word .clearAlreadyMovedFlag
; mov [bx+ChipHasMoved], 0
; jmp .monsterloop
endif ; 1c8
mov ax,[bx+MouseTargetY]
cmp [bx+ChipY],ax
if nz
jmp word .clearAlreadyMovedFlag
; mov [bx+ChipHasMoved], 0
; jmp .monsterloop
endif
.clearMouseTarget: ; 1d5
mov word [bx+HaveMouseTarget],0x0
jmp word .clearAlreadyMovedFlag
; mov [bx+ChipHasMoved], 0
; jmp .monsterloop
.chooseNorthOrSouth2: ; 1de
; the x distance was greater than the y distance
; if ydist > 0, dir = (0,1)
or si,si
if g
; south
mov word [xdir],0
mov word [ydir],1
jmp short .moveChipAttempt2
endif ; 1ee
; if ydist == 0, dir = (0,0)
or si,si
if ge
jmp word .chooseNothing2
endif ; 1f5
; if ydist < 0, dir = (0,-1)
; north
mov word [xdir],0
mov word [ydir],-1
jmp word .moveChipAttempt2
; go move chip
.standAroundLikeAnIdiot: ; 202
; We don't have a mouse target
; If chip is idle for 2 or more even ticks, face south
mov ax,[bx+IdleTickCount]
inc word [bx+IdleTickCount]
cmp ax,0x2
jl .monsterloop
mov bx,[GameStatePtr]
mov ax,[bx+ChipY]
shl ax,byte 0x5
add ax,[bx+ChipX]
add bx,ax
mov al,[bx+Upper]
mov [bp-0x3],al
cmp al,ChipS
jz .monsterloop
cmp al,SwimS
jz .monsterloop
cmp byte [bx+Lower],Water
if e
mov al,SwimS
else ; 238
mov al,ChipS
endif ; 23a
mov [bx],al
mov bx,[GameStatePtr]
push word [bx+ChipY]
push word [bx+ChipX]
push word [hDC]
call far UpdateTile ; 24b 2:1ca
add sp,byte +0x6
;;; PHASE 2 ;;;
; Monsters move
.monsterloop: ; 253
mov bx,[GameStatePtr]
cmp word [bx+MonsterListLen],byte +0x0
jz .doChipSlideMovement
mov al,[tick]
and ax,0x3
cmp ax,0x1
sbb ax,ax
neg ax
push ax ; tick&3 == 0
push word [hDC]
call far MonsterLoop ; 26f 3:74e Monster loop
add sp,byte +0x4
jmp short .doChipSlideMovement
nop
.oddTick: ; 27a
; We're on an odd tick
; Not much to do
; If we have a buffered keystroke and we're not sliding and ChipHasMoved isn't set,
; then move chip if he isn't dead.
mov bx,[GameStatePtr]
cmp word [bx+IsBuffered],byte +0x0
jz .doChipSlideMovement
cmp word [bx+IsSliding],byte +0x0
jnz .doChipSlideMovement
cmp word [bx+ChipHasMoved],byte +0x0
jnz .doChipSlideMovement
cmp word [bx+Autopsy],byte NotDeadYet
if e
push byte +0x1
push byte +0x1
push word [bx+BufferedY]
push word [bx+BufferedX]
push ax
call far MoveChip ; 2a7 7:1184
add sp,byte +0xa
endif ; 2af
; and whether he moved or not, clear the keystroke and mouse target
mov bx,[GameStatePtr]
mov word [bx+IsBuffered],0x0
mov bx,[GameStatePtr]
mov word [bx+HaveMouseTarget],0x0
;;; PHASE 3 ;;;
; Perform slide movement for chip
.doChipSlideMovement: ; 2c3
; Sliding!
mov bx,[GameStatePtr]
cmp word [bx+IsSliding],byte +0x0
if z
jmp word .doMonsterSlideMovement
endif ; 2d1
; First off, clear the idle timer
mov word [bx+IdleTickCount],0x0
; and then move chip in the direction he's sliding
push byte +0x1
push byte +0x0
mov bx,[GameStatePtr]
push word [bx+SlideY]
push word [bx+SlideX]
push word [hDC]
call far MoveChip ; 2ea 7:1184
add sp,byte +0xa
or ax,ax
if nz
jmp word .moveChipAfterSliding
endif ; 2f9
mov bx,[GameStatePtr]
cmp [bx+IsSliding],ax ; == 0
if z
jmp word .moveChipAfterSliding
endif ; 306
neg word [bx+SlideX]
mov si,[GameStatePtr]
neg word [si+SlideY]
push word DummyVarForSlideMovement
push ax ; 0
mov ax,[GameStatePtr]
add ax,SlideY
push ax
mov ax,[GameStatePtr]
add ax,SlideX
push ax
mov bx,[GameStatePtr]
push word [bx+ChipY]
push word [bx+ChipX]
push word [bx+ChipY]
push word [bx+ChipX]
call far SlideMovement ; 338 7:636
add sp,byte +0x10
push byte +0x1
push byte +0x0
mov bx,[GameStatePtr]
push word [bx+SlideY]
push word [bx+SlideX]
push word [hDC]
call far MoveChip ; 353 7:1184
add sp,byte +0xa
or ax,ax
jnz .moveChipAfterSliding
mov si,[GameStatePtr]
neg word [si+SlideX]
mov si,[GameStatePtr]
neg word [si+SlideY]
push word DummyVarForSlideMovement
push ax ; 0
mov ax,[GameStatePtr]
add ax,SlideY
push ax
mov ax,[GameStatePtr]
add ax,SlideX
push ax
mov bx,[GameStatePtr]
push word [bx+ChipY]
push word [bx+ChipX]
push word [bx+ChipY]
push word [bx+ChipX]
call far SlideMovement ; 395 7:636
add sp,byte +0x10
; Allow chip to get a move in after sliding
.moveChipAfterSliding: ; 39d
mov bx,[GameStatePtr]
cmp word [bx+ChipHasMoved],byte +0x0
if nz
mov word [bx+ChipHasMoved],0x0
jmp word .doMonsterSlideMovement
nop
endif
.tryBufferedMoveAfterSliding: ; 3b2
cmp word [bx+IsBuffered],byte +0x0
jz .tryMouseMoveAfterSliding
cmp word [bx+Autopsy],byte +0x0
jnz .label44
cmp word [bx+IsSliding],byte +0x0
jz .label45
mov ax,[bx+SlideX]
cmp [bx+BufferedX],ax
jnz .label45
mov ax,[bx+SlideY]
cmp [bx+BufferedY],ax
jz .label44
.label45: ; 3db
push byte +0x1
push byte +0x1
push word [bx+BufferedY]
push word [bx+BufferedX]
push word [hDC]
call far MoveChip ; 3ea 7:1184
add sp,byte +0xa
.label44: ; 3f2
mov bx,[GameStatePtr]
mov word [bx+IsBuffered],0x0
jmp word .clearMouseTargetAndProceedToMonsterSlideMovement
nop
.tryMouseMoveAfterSliding: ; 400
cmp word [bx+HaveMouseTarget],byte +0x0
if z
jmp word .doMonsterSlideMovement
endif ; 40a
mov ax,[bx+MouseTargetX]
sub ax,[bx+ChipX]
mov di,ax
mov si,[bx+MouseTargetY]
sub si,[bx+ChipY]
or ax,ax
jnz .label48
or si,si
jnz .label48
jmp word .clearMouseTargetAndProceedToMonsterSlideMovement
.label48: ; 427
cwd
xor ax,dx
sub ax,dx
mov cx,ax
mov ax,si
cwd
xor ax,dx
sub ax,dx
cmp ax,cx
if ge
or si,si
if g
; north
mov word [xdir],0
mov word [ydir],1
jmp short .label51
nop
endif ; 44a
; south
mov word [xdir],0
mov word [ydir],-1
else ; 456
or di,di
if g
; east
mov word [xdir],1
else ; 462
; west
mov word [xdir],-1
endif ; 467
mov word [ydir],0
endif
.label51: ; 46c
cmp word [bx+Autopsy],byte +0x0
if nz
jmp word .label55
endif ; 476
cmp word [bx+IsSliding],byte +0x0
jz .label56
mov ax,[xdir]
cmp [bx+SlideX],ax
jnz .label56
mov ax,[ydir]
cmp [bx+SlideY],ax
jnz .label56
jmp word .label55
.label56: ; 492
or si,si
jz .label57
or di,di
jz .label57
mov word [local_8],0x0
jmp short .label58
nop
.label57: ; 4a2
mov word [local_8],0x1
.label58: ; 4a7
push word [local_8]
push byte +0x1
push word [ydir]
push word [xdir]
push word [hDC]
call far MoveChip ; 4b5 7:1184
add sp,byte +0xa
or ax,ax
if nz
jmp word .label55
endif ; 4c4
mov bx,[GameStatePtr]
cmp [bx+HaveMouseTarget],ax ; == 0
if z
jmp word .label55
endif ; 4d1
mov ax,di
cwd
xor ax,dx
sub ax,dx
mov cx,ax
mov ax,si
cwd
xor ax,dx
sub ax,dx
cmp ax,cx
if ge
or di,di
if g
; west
mov word [xdir],0x1
.label65: ; 4ee
mov word [ydir],0x0
jmp short .label63
nop
endif ; 4f6
or di,di
jnl .chooseNothing4
; east
mov word [xdir],-1
jmp short .label65
nop
endif ; 502
or si,si
if g
; south
mov word [xdir],0x0
mov word [ydir],0x1
jmp short .label63
endif ; 512
or si,si
if l
; north
mov word [xdir],0x0
mov word [ydir],-1
jmp short .label63
endif ; 522
.chooseNothing4:
xor ax,ax
mov [ydir],ax
mov [xdir],ax
.label63: ; 52a
mov bx,[GameStatePtr]
cmp word [bx+Autopsy],byte +0x0
jnz .label55
cmp word [bx+IsSliding],byte +0x0
jz .label67
mov ax,[xdir]
cmp [bx+SlideX],ax
jnz .label67
mov ax,[ydir]
cmp [bx+SlideY],ax
jz .label55
.label67: ; 54e
cmp word [xdir],byte +0x0
jnz .label68
cmp word [ydir],byte +0x0
jz .label69
.label68: ; 55a
push byte +0x1
push byte +0x1
push word [ydir]
push word [xdir]
push word [hDC]
call far MoveChip ; 567 7:1184
add sp,byte +0xa
or ax,ax
jnz .label55
.label69: ; 573
mov bx,[GameStatePtr]
mov word [bx+HaveMouseTarget],0x0
.label55: ; 57d
mov bx,[GameStatePtr]
cmp word [bx+Autopsy],byte +0x0
jnz .clearMouseTargetAndProceedToMonsterSlideMovement
mov ax,[bx+MouseTargetX]
cmp [bx+ChipX],ax
jnz .doMonsterSlideMovement
mov ax,[bx+MouseTargetY]
cmp [bx+ChipY],ax
jnz .doMonsterSlideMovement
.clearMouseTargetAndProceedToMonsterSlideMovement: ; 59c
mov bx,[GameStatePtr]
mov word [bx+HaveMouseTarget],0x0
;;; PHASE 4 ;;;;
; Monster slide movement
.doMonsterSlideMovement: ; 5a6
; Do slip list loop and release DC
push word [hDC]
call far SlipLoop ; 5a9 3:13de Slip loop
;;; PHASE 5 ;;;;
; clean up, timer
add sp,byte +0x2
push word [hwndBoard]
push word [hDC]
call far USER.ReleaseDC ; 5b8
; countdown timer?
cmp word [TimeRemaining],byte +0x0
jle .end
cmp word [tick],byte +0x0
jz .end
mov ax,[tick]
mov cx,0xa
sub dx,dx
div cx
or dx,dx
jnz .end
dec word [TimeRemaining]
cmp word [TimeRemaining],byte +0xf
if le
push byte +0x1
push byte TickSound
call far PlaySoundEffect ; 5e7 8:56c
add sp,byte +0x4
endif ; 5ef
push byte +0x1
call far FUN_2_0cbe ; 5f1 2:cbe
add sp,byte +0x2
cmp word [TimeRemaining],byte +0x0
jnz .end
push byte +0x1
push byte ChipDeathByTimeSound
call far PlaySoundEffect ; 604 8:56c
add sp,byte +0x4
mov bx,[GameStatePtr]
mov word [bx+Autopsy],OutOfTime
call far ShowDeathMessage ; 616 2:b9a
push byte +0x1
mov bx,[GameStatePtr]
push word [bx+LevelNumber]
call far FUN_4_0356 ; 625 4:356 load level
add sp,byte +0x4
.end: ; 62d
pop si
pop di
endfunc
; 636
; Slide movement for a creature
; Sets the tile direction and updates the slip list
func SlideMovement
sub sp,byte +0x16
push di
push si
%arg xsrc:word ; +6
%arg ysrc:word ; +8
%arg xdest:word ; +10
%arg ydest:word ; +c
%arg xdirptr:word ; +e
%arg ydirptr:word ; +10
%arg flag:word ; +12
%arg facing:word ; +14
; -4 (si) far pointer to x dir
; -6 seg
; -8 (di) far pointer to y dir
; -a seg
%define xdir (bp-0xc)
%define ydir (bp-0xe)
%define slipseg (bp-0x10) ; far pointer to slip list entry
%define slipptr (bp-0x12)
; TODO
;%define xdirptr si
;%define ydirptr di
; fetch *xdirptr and *ydirptr
mov bx,[xdirptr]
mov ax,[bx]
mov [xdir],ax
mov bx,[ydirptr]
mov ax,[bx]
mov [ydir],ax
; check the flag
mov ax,[flag]
or ax,ax
jz .label0 ; ax == 0
dec ax
jl .label1 ; ax < 1 => ax < 0
jo .label1 ; ax - 1 overflows => ax == MININT16
dec ax
jng .label2 ; (ax-1) <= 1 => ax <= 2
; otherwise
.label1: ; 664
; uninitialized
mov si,[bp-0x6]
mov di,[bp-0xa]
jmp short .label3
; set xdir and ydir pointers
; to slidex and slidey if chip
; or sliplist xdir and ydir if monster
; flag == 0
.label0: ; 66c
mov bx,[GameStatePtr]
mov word [bx+IsSliding],0x1
mov ax,[GameStatePtr]
add ax,SlideX
mov si,ax
mov [bp-0x4],ds
mov ax,[GameStatePtr]
add ax,SlideY
mov di,ax
mov [bp-0x8],ds
jmp short .label3
; flag == 2
; if the slipper is a monster
; find its entry on the slip list
; or create a new entry if one doesn't exist
.label2: ; 68e
push word [ysrc]
push word [xsrc]
mov bx,[ysrc]
shl bx,byte 0x5
add bx,[xsrc]
mov si,[GameStatePtr]
mov al,[bx+si+Upper]
push ax
call far FindSlipperAt ; 6a4 3:1396
add sp,byte +0x6
mov [slipptr],ax
mov [slipseg],dx
or dx,ax
if z
call far NewSlipper ; 6b6 3:1250
mov [slipptr],ax
mov [slipseg],dx
endif ; 6c1
mov ax,[slipseg]
or ax,[slipptr]
if z
jmp word .return
endif ; 6cc
mov ax,[slipptr]
mov dx,[slipseg]
add ax,Slipper.xdir
mov si,ax
mov [bp-0x4],dx
mov ax,[slipptr]
add ax,Slipper.ydir
mov di,ax
mov [bp-0x8],dx
; get the tile
; XXX when would x0 != x1?
.label3: ; 6e5
mov ax,[xsrc]
cmp [xdest],ax
jne .label7
mov ax,[ysrc]
cmp [ydest],ax
jne .label7
mov bx,[ydest]
shl bx,byte 0x5
add bx,[xdest]
add bx,[GameStatePtr]
mov al,[bx+Lower]
jmp short .label8
.label7: ; 708
mov bx,[ydest]
shl bx,byte 0x5
add bx,[xdest]
add bx,[GameStatePtr]
mov al,[bx+Upper]
; switch statement
.label8: ; 717
mov [bp-0x13],al
cmp al,ChipN
jb .label9
cmp al,ChipE
jna .label10
.label9: ; 722
cmp byte [bp-0x13],SwimN
jb .label11
cmp byte [bp-0x13],SwimE
ja .label11
.label10: ; 72e
mov al,[bx+Lower]
mov [bp-0x13],al
.label11: ; 735
mov al,[bp-0x13]
sub ah,ah
cmp ax,ForceRandom
jnz .notForceRandom
jmp word .forceRandom
.notForceRandom: ; 742
jna .label14
jmp word .label15
.label14: ; 747
cmp al,IceWallNW
jz .iceWallNW
jg .label17
sub al,Ice
jz .ice
dec al
if z
jmp word .forceS
endif ; 758
sub al,ForceN - ForceS
if z
jmp word .setSlideNorth
endif ; 75f
dec al
if z
jmp word .forceE
endif ; 766
dec al
if z
jmp word .forceW
endif ; 76d
jmp word .label15
.label17: ; 770
sub al,IceWallNE
jz .iceWallNE
dec al
if z
jmp word .iceWallSE
endif ; 77b
dec al
if z
jmp word .iceWallSW
endif ; 782
sub al,Teleport - IceWallSW
jz .ice
sub al,Trap - Teleport
jz .ice
jmp word .label15
; Ice
.ice: ; 78d
mov ax,[xdir]
mov es,[bp-0x4]
mov [es:si],ax
mov ax,[ydir]
.setYdirToAX: ; 799
mov es,[bp-0x8]
mov [es:di],ax
jmp word .label15
nop
nop
; Ice wall NW
.iceWallNW: ; 7a4
cmp word [xdir],byte -0x1
jnz .label32
cmp word [ydir],byte +0x0
jz .setSlideSouth
.label32: ; 7b0
cmp word [xdir],byte +0x0
jnz .turnAround
cmp word [ydir],byte -0x1
jnz .turnAround
jmp word .setSlideEast
.turnAround: ; 7bf
mov ax,[xdir]
neg ax
mov es,[bp-0x4]
mov [es:si],ax
mov ax,[ydir]
neg ax
jmp short .setYdirToAX
nop
; Ice wall NE
.iceWallNE: ; 7d2
cmp word [xdir],byte +0x0
jnz .label35
cmp word [ydir],byte -0x1
jz .setSlideWest
.label35: ; 7de
cmp word [xdir],byte +0x1
jnz .turnAround
cmp word [ydir],byte +0x0
jnz .turnAround
; Force S
.forceS: ; 7ea
.setSlideSouth:
mov es,[bp-0x4]
mov word [es:si],0x0
mov es,[bp-0x8]
mov word [es:di],0x1
jmp short .label15
; Ice wall SE
.iceWallSE: ; 7fc
; check if we're sliding south
cmp word [xdir],byte +0x0
jnz .label36
cmp word [ydir],byte +0x1
jnz .label36
.forceW:
.setSlideWest: ; 808
; set slide dir to -1,0
mov es,[bp-0x4]
mov word [es:si],-1
jmp short .setYdirToZero
.label36: ; 812
; check if we're sliding west (0,1)
cmp word [xdir],byte +0x1
jnz .turnAround
cmp word [ydir],byte +0x0
jnz .turnAround
.setSlideNorth: ; 81e
; set slide dir to 0,-1