-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmove.asm
1537 lines (1321 loc) · 28.4 KB
/
move.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
INCLUDE macros.inc
EXTRN CHAR:BYTE
EXTRN printChatChar2:FAR
EXTRN items:WORD
EXTRN items_x:WORD
EXTRN items_y:WORD
EXTRN items_type:BYTE
EXTRN x1_Car1:WORD
EXTRN x2_Car1:WORD
EXTRN y1_Car1:WORD
EXTRN y2_Car1:WORD
EXTRN speed_Car1:WORD
EXTRN color_Car1:BYTE
EXTRN left_Car1:BYTE
EXTRN right_Car1:BYTE
EXTRN up_Car1:BYTE
EXTRN down_Car1:BYTE
EXTRN genObs_Car1:BYTE
EXTRN passObs_Car1:BYTE
EXTRN receivedMove:BYTE
EXTRN sentMove:BYTE
EXTRN x1_Car2:WORD
EXTRN x2_Car2:WORD
EXTRN y1_Car2:WORD
EXTRN y2_Car2:WORD
EXTRN speed_Car2:WORD
EXTRN color_Car2:BYTE
EXTRN left_Car2:BYTE
EXTRN right_Car2:BYTE
EXTRN up_Car2:BYTE
EXTRN down_Car2:BYTE
EXTRN genObs_Car2:BYTE
EXTRN passObs_Car2:BYTE
EXTRN pressedF4:BYTE
EXTRN x1_CarTemp:WORD
EXTRN x2_CarTemp:WORD
EXTRN y1_CarTemp:WORD
EXTRN y2_CarTemp:WORD
EXTRN speed_CarTemp:WORD
EXTRN color_CarTemp:BYTE
EXTRN left_CarTemp:BYTE
EXTRN right_CarTemp:BYTE
EXTRN up_CarTemp:BYTE
EXTRN down_CarTemp:BYTE
EXTRN powerTypeTemp:BYTE
EXTRN genObs_CarTemp:BYTE
EXTRN passObs_CarTemp:BYTE
EXTRN prevState_passObsTemp:BYTE
EXTRN curState_CarTemp:BYTE
EXTRN nearest_x_power:WORD
EXTRN nearest_y_power:WORD
EXTRN check_center_car:BYTE
EXTRN check_if_color:BYTE
EXTRN flag_direction_temp:BYTE
PUBLIC moveCar,check_move,item_color
PUBLIC xc_Car,yc_Car,culc_center_of_car
public receive_move
EXTRN CAR:FAR
EXTRN SEND:FAR
EXTRN sendData:BYTE
EXTRN generateGameData:BYTE
EXTRN send_powerUps:FAR
EXTRN receive_powerUps:FAR
.model HUGE
.data
item_color DB 0
;you must select number of car move 1->car_1 2->car_2
check_call_from_car_color db ?
color_car_to_check db ?
x_car DW ?
y_car DW ?
position_power_to_car db ? ;0->up 1->down 2->left 3->right
power_x DW ? ;current x-coord to power up
power_y DW ? ;current y-coord to power up
xc_Car dw ?
yc_Car dw ?
haight_car equ 3
width_car equ 2
pev_x1 dw ?
pev_x2 dw ?
pev_y1 dw ?
pev_y2 dw ?
color_pav equ 8
.code
add_obstacle proc far
mov si,offset items_x
mov di,offset items_y
mov bx,offset items_type
add si,items ; add two times to move by words
add si,items
add di,items ; add two times to move by words
add di,items
add bx,items
mov [si],cx ; save the generated data
mov [di],dx ; save the generated data
mov [bx],al ; save the generated data
inc items
ret
add_obstacle endp
check_not_white_colUD proc FAR
mov check_if_color,0
add si,1 ;y2
check_colors_loop1UD:
mov ah,0dh
int 10h ; get color of pixel in CX,DX (al = color)
cmp al,0fh
jnz return_not_white1UD
inc dx ;y1
cmp dx,si
jnz check_colors_loop1UD
ret
return_not_white1UD: mov check_if_color,1
mov item_color,al
ret
check_not_white_colUD endp
check_not_white_colDU proc FAR
mov check_if_color,0
sub si,1
check_colors_loop1DU:
mov ah,0dh
int 10h ; get color of pixel in CX,DX (al = color)
cmp al,0fh
jnz return_not_white1DU
dec dx
cmp dx,si
jnz check_colors_loop1DU
ret
return_not_white1DU: mov check_if_color,1
mov item_color,al
ret
check_not_white_colDU endp
check_not_white_rowLR proc FAR
mov check_if_color,0
add si,1
check_colors_loop2LR:
mov ah,0dh
int 10h ; get color of pixel in CX,DX (al = color)
cmp al,0fh
jnz return_not_white2LR
inc cx
cmp CX,si
jnz check_colors_loop2LR
ret
return_not_white2LR: mov check_if_color,1
mov item_color,al
ret
check_not_white_rowLR endp
check_not_white_rowRL proc FAR
mov check_if_color,0
sub si,1
check_colors_loop2RL:
mov ah,0dh
int 10h ; get color of pixel in CX,DX (al = color)
cmp al,0fh
jnz return_not_white2RL
dec cx
cmp CX,si
jnz check_colors_loop2RL
ret
return_not_white2RL: mov check_if_color,1
mov item_color,al
ret
check_not_white_rowRL endp
;save the previus coordinate becs if i not move
save_prev_coord proc far
mov ax,x1_CarTemp
mov pev_x1,ax
mov ax,x2_CarTemp
mov pev_x2,ax
mov ax,y1_CarTemp
mov pev_y1,ax
mov ax,y2_CarTemp
mov pev_y2,ax
ret
save_prev_coord endp
save_temp_coord proc far
mov ax,pev_x1
mov x1_CarTemp,ax
mov ax,pev_x2
mov x2_CarTemp,ax
mov ax,pev_y1
mov y1_CarTemp,ax
mov ax,pev_y2
mov y2_CarTemp,ax
ret
save_temp_coord endp
check_car_around_power_color proc FAR
mov cx,power_x
sub cx,2 ;start from above power up
mov dx,power_y
sub dx,2
mov si,power_x
add si,2
mov check_if_color,0
cmp color_CarTemp,1h
jnz not_car2
mov color_car_to_check,1h
jmp positions
not_car2:
mov color_car_to_check,6h
positions:
cmp position_power_to_car,1
jz to_down
cmp position_power_to_car,2
jz to_left
cmp position_power_to_car,3
jz to_Right
to_up:
check_colors_loop1:
mov ah,0dh ; X, Y
int 10h ; get color of pixel in CX,DX (al = color)
cmp al,color_car_to_check
jz found_car
inc cx
cmp cx,si
jnz check_colors_loop1
ret
found_car: mov check_if_color,1
mov item_color,al
ret
to_down:
mov cx,power_x
sub cx,2
mov dx,power_y ;start from down power up
add dx,2
check_colors_loop2:
mov ah,0dh ; X, Y
int 10h ; get color of pixel in CX,DX (al = color)
cmp al,color_car_to_check
jz found2_car
inc cx
cmp cx,si
jnz check_colors_loop2
ret
found2_car: mov check_if_color,1
mov item_color,al
ret
to_left:
mov cx,power_x
sub cx,2
mov dx,power_y ;start from down power up
sub dx,2
mov si,power_y
add si,2
check_colors_loop3:
mov ah,0dh ; X, Y
int 10h ; get color of pixel in CX,DX (al = color)
cmp al,color_car_to_check
jz found3_car
inc dx
cmp dx,si
jnz check_colors_loop3
ret
found3_car: mov check_if_color,1
mov item_color,al
ret
to_Right:
mov cx,power_x
add cx,2
mov dx,power_y ;start from down power up
mov si,power_y
add si,2
sub dx,2
check_colors_loop4:
mov ah,0dh ; X, Y
int 10h ; get color of pixel in CX,DX (al = color)
cmp al,color_car_to_check
jz found4_car
inc dx
cmp dx,si
jnz check_colors_loop4
ret
found4_car: mov check_if_color,1
mov item_color,al
ret
check_car_around_power_color endp
get_power_up proc far
;mov ax,@data
mov ax,ds
mov es,ax
mov di,offset items_type
mov cx,items
loo:
mov al,powerTypeTemp
REPNE SCASB
mov bx,2
mov ax,items
sub ax,cx
dec ax
cmp cx,0
jnz Add_past_element
;check_past_element
push bx
push cx
mov cl,powerTypeTemp
mov bx, offset items_type
add bx,ax
cmp byte ptr [bx],cl
pop cx
pop bx
jnz lastt
Add_past_element: ;not add past element only*
mov si,offset items_x
mul bl
add si,ax
mov dx,[si]
mov power_x,dx
;indix power I stop
mov ax,items
sub ax,cx
dec ax
mov si,offset items_y
mul bl
add si,ax
mov dx,[si]
mov power_y,dx
push ax
push dx
push si
push cx
jmp as
ga1:jmp loo
as:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
call check_car_around_power_color ; function
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pop cx
pop si
pop dx
pop ax
push si
cmp check_if_color,1 ;hidden power up
jnz nothidd
; inc powerTypeTemp
mov ax,items
sub ax,cx
dec ax
mov si,offset items_type
add si,ax
mov byte ptr[si],6
nothidd:
pop si
cmp cx,0
jg ga1
lastt:
ret
get_power_up endp
culc_center_of_car proc FAR
mov ax ,x2_CarTemp
sub ax,x1_CarTemp
mov bl,2
div bl
mov ah,0
add ax,x1_CarTemp
mov xc_Car,ax
mov ax ,y2_CarTemp
sub ax,y1_CarTemp
mov bl,2
div bl
mov ah,0
add ax,y1_CarTemp
mov yc_Car,ax
ret
culc_center_of_car endp
check_around_OR_in_CarTemp proc far ;check if around the car an obstacle
mov CX,x1_CarTemp
mov si,x2_CarTemp
mov DX,y1_CarTemp
dec DX
call check_not_white_rowLR ;check above car from left to right
cmp check_if_color,1
jnz not_above_CarTemp
cmp item_color,2 ;green obstacle
jnz again_above
mov curState_CarTemp,1
ret
again_above:
xchg cx,si
call check_not_white_rowRL
cmp item_color,2 ;green obstacle
jnz not_above_CarTemp
mov curState_CarTemp,1
ret
not_above_CarTemp:
mov CX,x1_CarTemp
mov si,x2_CarTemp
mov DX,y2_CarTemp
inc DX
call check_not_white_rowLR ;check below car
cmp check_if_color,1
jnz not_below_CarTemp
cmp item_color,2
jnz again_below
mov curState_CarTemp,1
ret
again_below:
xchg cx,si
call check_not_white_rowRL
cmp item_color,2 ;green obstacle
jnz not_below_CarTemp
mov curState_CarTemp,1
ret
not_below_CarTemp:
mov CX,x2_CarTemp
mov DX ,y1_CarTemp
mov si ,y2_CarTemp
inc CX
call check_not_white_colUD ;check right car
cmp check_if_color,1
jnz not_right_CarTemp
cmp item_color,2
jnz again_right
mov curState_CarTemp,1
ret
again_right:
xchg dx,si
call check_not_white_colDU
cmp item_color,2 ;green obstacle
jnz not_right_CarTemp
mov curState_CarTemp,1
ret
not_right_CarTemp:
mov CX,x1_CarTemp
mov DX ,y1_CarTemp
mov si ,y2_CarTemp
dec CX
call check_not_white_colUD ;check left car
cmp check_if_color,1
jnz not_left_CarTemp
cmp item_color,2
jnz again_left
mov curState_CarTemp,1
ret
again_left:
xchg dx,si
call check_not_white_colDU
cmp item_color,2 ;green obstacle
jnz not_left_CarTemp
mov curState_CarTemp,1
ret
not_left_CarTemp:
mov si,offset items_x
mov di,offset items_y
add si,items ; add two times to move by words
add si,items
add di,items ; add two times to move by words
add di,items
mov CX,items
check_itemsArray1:
mov DX,[si]
cmp DX,x1_CarTemp
jl next1
cmp DX,x2_CarTemp
jg next1
mov DX,[di]
cmp DX,y1_CarTemp
jl next1
cmp DX,y2_CarTemp
jg next1
mov curState_CarTemp,1
jmp return1
next1:
sub si,2
sub di,2
loop check_itemsArray1
mov curState_CarTemp,0
return1:
ret
check_around_OR_in_CarTemp endp
moveCar proc far
push ax
drawCar x1_CarTemp,y1_CarTemp,x2_CarTemp,y2_CarTemp,color_CarTemp
call culc_center_of_car
pop ax
cmp ah,0 ;al=color,ah=direction (0,1,2,3) -> (down,up,right,left)
jnz not_movedown
jmp moveDown
not_movedown: cmp ah,1
jnz not_moveUp
jmp moveUp
not_moveUp: cmp ah,2
jnz not_moveRight
jmp moveRight
not_moveRight:
jmp moveLeft
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
moveDown:
push ax
push dx
push si
push cx
mov di,speed_CarTemp
cmp di,0 ;check if speed equal = 0
jnz moveDownspeed
pop cx
pop si
pop dx
pop ax
call culc_center_of_car
call CAR
ret
moveDownspeed:
push ax
call save_prev_coord ;save the prev coordinate
pop ax
cmp flag_direction_temp,0
jz sd
cmp flag_direction_temp,1
jz sd
mov ax,xc_Car
mov x1_CarTemp,ax
sub x1_CarTemp,width_car
mov x2_CarTemp,ax
add x2_CarTemp,width_car
mov ax,yc_Car
jmp asd
sd: jmp ready3
asd:
mov y1_CarTemp,ax
sub y1_CarTemp,haight_car
mov y2_CarTemp,ax
add y2_CarTemp,haight_car
mov dX,y1_CarTemp
mov CX ,x1_CarTemp
mov si ,x2_CarTemp
call check_not_white_rowLR
cmp item_color,color_pav
jnz ready3
add y1_CarTemp,1
add y2_CarTemp,1
ready3:
mov BX,y2_CarTemp
inc BX
push di
call check_around_OR_in_CarTemp
pop di
mov DX,BX
mov CX ,x1_CarTemp
mov si ,x2_CarTemp
call check_not_white_rowLR
push DX
push si
push di
push BX
cmp item_color,9H ;(blue) check power up to get it from type speed up
jnz not1_power9
mov position_power_to_car,0
mov powerTypeTemp,2
call get_power_up
jmp not1_power12
not1_power9:
cmp item_color,0AH ;(green) check power up to get it from type speed down
jnz not1_power10
mov position_power_to_car,0
mov powerTypeTemp,3
call get_power_up
jmp not1_power12
not1_power10:
cmp item_color,0BH ;(cyan) check power up to get it from type generate obstacle
jnz not1_power11
mov position_power_to_car,0
mov powerTypeTemp,4
call get_power_up
jmp not1_power12
not1_power11:
cmp item_color,0CH ;(red) check power up to get it from type pass obstacle
jnz not1_power12
mov position_power_to_car,0
mov powerTypeTemp,5
call get_power_up
not1_power12:
pop bx
pop di
pop si
pop dx
push cx
mov cl,curState_CarTemp
and cl,prevState_passObsTemp ;if prev = 1 (passing) and current = 1,there is obstacle around or in car then
mov prevState_passObsTemp,cl
pop cx
cmp check_if_color,1
jnz can_move_down
cmp item_color,2
jz again1
push ax
call save_temp_coord ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pop ax
jmp exit1CarTemp
again1:
xchg cx,si
call check_not_white_rowRL
cmp item_color,2
jz skip1
push ax
call save_temp_coord ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pop ax
jmp exit1CarTemp
skip1:
cmp prevState_passObsTemp,0
jz no_passing_down
jmp can_move_down
no_passing_down:
cmp passObs_CarTemp,1
jz continue1
push ax
call save_temp_coord ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pop ax
jmp exit1CarTemp
continue1:
mov prevState_passObsTemp,1
mov passObs_CarTemp,0
can_move_down:
cmp genObs_CarTemp,1
jnz not_genObs_down ;genObs_CarTemp = 0 (not active) not generate obstacle due to moving down CarTemp
push di
push BX
push AX
mov CX,x1_CarTemp
add CX,6 ;width car 8 pixels, mid point of obstacle after x1+3
mov dx,y1_CarTemp
mov al,0
call add_obstacle
pop AX
pop BX
pop di
mov genObs_CarTemp,0
not_genObs_down:
drawCar pev_x1,pev_y1,pev_x2,pev_y2,0fh
mov y2_CarTemp,BX
drawCar x1_CarTemp,y1_CarTemp,x2_CarTemp,BX,color_CarTemp
drawRow x1_CarTemp,x2_CarTemp,y1_CarTemp,0fh
mov BX,y1_CarTemp
inc BX
mov y1_CarTemp,BX
dec di
cmp di,0h
mov flag_direction_temp,1
jz exit1CarTemp
jmp moveDownspeed
exit1CarTemp:
pop cx
pop si
pop dx
pop ax
call culc_center_of_car
call CAR
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
moveUp:
push ax
push dx
push si
push cx
mov di,speed_CarTemp
cmp di,0 ;check if speed equal = 0
jnz moveUpSpeed
pop cx
pop si
pop dx
pop ax
call culc_center_of_car
call CAR
ret
moveUpSpeed:
push ax
call save_prev_coord ;save the prev coordinate
pop ax
cmp flag_direction_temp,0
jz ready2
cmp flag_direction_temp,1
jz ready2
mov ax,xc_Car
mov x1_CarTemp,ax
sub x1_CarTemp,width_car
mov x2_CarTemp,ax
add x2_CarTemp,width_car
mov ax,yc_Car
mov y1_CarTemp,ax
sub y1_CarTemp,haight_car
mov y2_CarTemp,ax
add y2_CarTemp,haight_car
mov DX,y2_CarTemp
mov CX ,x1_CarTemp
mov si ,x2_CarTemp
call check_not_white_rowLR
cmp item_color,color_pav
jnz ready2
sub y1_CarTemp,1
sub y2_CarTemp,1
ready2:
mov BX,y1_CarTemp
dec BX
push di
call check_around_OR_in_CarTemp
pop di
mov DX,BX
mov CX ,x1_CarTemp
mov si ,x2_CarTemp
call check_not_white_rowLR
push DX
push si
push di
push BX
cmp item_color,9H ;(blue) check power up to get it from type speed up
jnz not2_power9
mov position_power_to_car,1
mov powerTypeTemp,2
call get_power_up
jmp not2_power12
not2_power9:
cmp item_color,0AH ;(green) check power up to get it from type speed down
jnz not2_power10
mov position_power_to_car,1
mov powerTypeTemp,3
call get_power_up
jmp not2_power12
not2_power10:
cmp item_color,0BH ;(cyan) check power up to get it from type generate obstacle
jnz not2_power11
mov position_power_to_car,1
mov powerTypeTemp,4
call get_power_up
jmp not2_power12
not2_power11:
cmp item_color,0CH ;(red) check power up to get it from type pass obstacle
jnz not2_power12
mov position_power_to_car,1
mov powerTypeTemp,5
call get_power_up
not2_power12:
pop bx
pop di
pop si
pop dx
push cx
mov cl,curState_CarTemp
and cl,prevState_passObsTemp ;if prev = 1 (passing) and current = 1,there is obstacle around or in car then
mov prevState_passObsTemp,cl
pop cx
cmp check_if_color,1
jnz can_move_up
cmp item_color,2
jz again2
push ax
call save_temp_coord ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pop ax
jmp exit2CarTemp
again2:
xchg cx,si
call check_not_white_rowRL
cmp item_color,2
jz skip2
push ax
call save_temp_coord ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pop ax
jmp exit2CarTemp
skip2:
cmp prevState_passObsTemp,0
jz no_passing_up
jmp can_move_up
no_passing_up:
cmp passObs_CarTemp,1
jz continue2
push ax
call save_temp_coord ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pop ax
jmp exit2CarTemp
continue2:
mov prevState_passObsTemp,1
mov passObs_CarTemp,0
can_move_up:
cmp genObs_CarTemp,1
jnz not_genObs_up ;genObs_CarTemp = 0 (not active) not generate obstacle due to moving down CarTemp
push di
push BX
push AX
mov CX,x1_CarTemp
add CX,6 ;width car 8 pixels, mid point of obstacle after x1+3
mov dx,y2_CarTemp
mov al,0
call add_obstacle
pop AX
pop BX
pop di
mov genObs_CarTemp,0
not_genObs_up:
drawCar pev_x1,pev_y1,pev_x2,pev_y2,0fh
mov y1_CarTemp,BX
drawCar x1_CarTemp,y1_CarTemp,x2_CarTemp,y2_CarTemp,color_CarTemp
mov BX,y2_CarTemp
drawRow x1_CarTemp,x2_CarTemp,BX,0fh
dec BX
mov y2_CarTemp,BX
dec di
cmp di,0h
mov flag_direction_temp,0
jz exit2CarTemp
jmp moveUpSpeed
exit2CarTemp:
pop cx
pop si
pop dx
pop ax
call culc_center_of_car
call CAR
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
moveRight:
push ax
push dx
push si
push cx
mov di,speed_CarTemp
cmp di,0 ;check if speed equal = 0
jnz moveRightSpeed
pop cx
pop si
pop dx
pop ax
call culc_center_of_car
call CAR
ret
moveRightSpeed:
push ax
call save_prev_coord ;save the prev coordinate
pop ax
;check if change direction
cmp flag_direction_temp,2
jz ready0
cmp flag_direction_temp,3
jz ready0
mov ax,xc_Car
mov x1_CarTemp,ax
sub x1_CarTemp,haight_car
mov x2_CarTemp,ax
add x2_CarTemp,haight_car
mov ax,yc_Car
mov y1_CarTemp,ax
sub y1_CarTemp,width_car
mov y2_CarTemp,ax
add y2_CarTemp,width_car
mov CX,x1_CarTemp
mov DX ,y1_CarTemp
mov si ,y2_CarTemp
call check_not_white_colUD
cmp item_color,color_pav
jnz ready0
add x1_CarTemp,1
add x2_CarTemp,1
ready0:
mov BX,x2_CarTemp
inc BX
push di
call check_around_OR_in_CarTemp
pop di
mov CX,BX
mov DX ,y1_CarTemp
mov si ,y2_CarTemp
call check_not_white_colUD
push DX
push si
push di
push BX
cmp item_color,9H ;(blue) check power up to get it from type speed up
jnz not3_power9
mov position_power_to_car,2
mov powerTypeTemp,2
call get_power_up
jmp not3_power12
not3_power9:
cmp item_color,0AH ;(green) check power up to get it from type speed down
jnz not3_power10