-
Notifications
You must be signed in to change notification settings - Fork 0
/
volfied_YahliAlton3.asm
1881 lines (1600 loc) · 28.9 KB
/
volfied_YahliAlton3.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
IDEAL
MODEL small
STACK 100h
DATASEG
; cords:
x dw 309 ; the cords of the character
y dw 191
xs dw 10 ; the cords of the screen
ys dw 190
xs2 dw 10
ys2 dw 190
startx dw 0
starty dw 0 ;the cords when pressing space
paintx dw 0
painty dw 0
stopx dw 0 ;the last pixel we stop to paint
stopy dw 0
xe dw 50 ; enemy x cord
ye dw 50 ; enemy y
xe2
ye2
; colors:
color db 7
color2 db 4 ; צבע השובל
colors db 0eh ;צבע המסך
colord db 2 ;for debug
colord2 db 5
colorg1 db 4 ;color
colorg2 db 0eh ;to color
enemy_color db 5
; for precents caculate:
precent_per_paint db 20
sum_pixels dw 530 ;the number of pixels is 53,044
count_paint db 0 ;count the number of paint use in paint_function
paint1_precent dw 0
paint2_precent dw 0
screen_paint_precent dw 0
; booleans:
;0 - non, 1 - up (w), 2 - down (s), 3 - right (d), 4 - left (a)
first_tav db 0
final_tav db 0
is_complete_paint db 0
is_space db 0 ; 0 - regular, 1 - first_space, 2 - space
; arrays:
my_zone db 1h, 2h, 3h, 4h, 5h, 6h, 7h, 8h, 9h ;my character
enemy1_character db 1h, 2h, 3h, 4h, 5h, 6h, 7h, 8h, 9h, 10h, 11h, 12h, 13h
; other:
index dw 0
i dw 0
i2 dw 0
number_of_runns dw 0
; max dw 65535 ; the maximum value we can put in dw
enemy_index dw 0
DELAY dw 10
speedx dw 1
speedy dw 1
message2 db 10, 13, 10, 13, 10, 13, 'You win! GG', 10, 13, '$'
message3 db "press 'e' to play again", 10, 13, '$'
message4 db "or 'q' to exit$"
message5 db 10, 13, 10, 13, 10, 13, 'You lose! better luck next time', 10, 13, '$'
CODESEG
jmp start
help12:
jmp end_func
proc paint_area2 ; alagorithm flood_fill
; save to al the color
mov bh, 0h
mov cx, [paintx]
push cx ;save cx (paintx)
mov dx, [painty]
push dx ;save dx (painty)
mov ah, 0dh
int 10h
cmp al, 4
je help12 ;jmp to end_func
cmp al, 0eh
je help12 ; jmp to end_func
cmp al, 10h
je help12 ; jmp to end_func
;32763
cmp [number_of_runns], 10600
jg help12 ; jmp to end_func
cmp [number_of_runns], 10600
je max_run
; cmp al, 7
; je end_func
; paint
mov bh,0h
mov cx,[paintx]
mov dx,[painty]
mov al,[colors]
mov ah,0ch
int 10h
add [number_of_runns], 1
; go to all 4 directions
; right
add [paintx], 1
call paint_area2
sub [paintx], 1
sub [painty], 1 ;up
call paint_area2
add [painty], 1
sub [paintx], 1
call paint_area2 ;left
add [paintx], 1
add [painty], 1
call paint_area2 ;down
jmp end_func
max_run:
add [number_of_runns], 1
mov ax, [paintx]
mov [stopx], ax
mov ax, [painty]
mov [stopy], ax
mov [is_complete_paint], 0
end_func:
pop dx ;get paintyaaaa
pop cx ;get paintx
mov [paintx], cx ;return to the back cords
mov [painty], dx
; cmp [painty], 100
; je countinu2
ret
endp paint_area2
proc my_character ; מציירת קוביה
push [x]
push [y]
mov cx, 3
mov [index], 0
loopXP: ;מעלה את x
; שמירה
push cx
mov bh, 0h
mov cx, [x]
mov dx, [y]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset my_zone
add bx, index
mov [bx], al
add [index], 1
; ציור
mov bh, 0h
mov cx, [x]
mov dx, [y]
mov al,[color]
mov ah,0ch
int 10h
pop cx
add [x],1
loop loopXP
; שינוי מיקום
sub [y], 1
sub [x], 1
mov cx, 3
loopXN: ;מוריד את x
push cx
mov bh, 0h
mov cx, [x]
mov dx, [y]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset my_zone
add bx, index
mov [bx], al
add [index], 1
; ציור
mov bh,0h
mov cx,[x]
mov dx,[y]
mov al,[color]
mov ah,0ch
int 10h
pop cx
add [x],-1
loop loopXN
sub [y], 1
add [x], 1
mov cx, 3
loopXP2: ;מעלה את x
push cx
mov bh, 0h
mov cx, [x]
mov dx, [y]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset my_zone
add bx, index
mov [bx], al
add [index], 1
; ציור
mov bh,0h
mov cx,[x]
mov dx,[y]
mov al,[color]
mov ah,0ch
int 10h
pop cx
add [x],1
loop loopXP2
pop [y]
pop [x]
ret
endp my_character
proc delete_char2
push [x]
push [y]
mov cx, 3
mov [index], 0
loopDXP: ;מעלה את x ;D - delete, X - x, P - positive, N - negative
; שמירה
push cx
; קליטה מהמערך
mov bx, offset my_zone
add bx, index
mov al, [bx] ;save to al the color
add [index], 1
; ציור
mov bh, 0h
mov cx, [x]
mov dx, [y]
; al - the color from the array
mov ah,0ch
int 10h
pop cx
add [x],1
loop loopDXP
; שינוי מיקום
sub [y], 1
sub [x], 1
mov cx, 3
loopDXN: ;מוריד את x
push cx
; קליטה מהמערך
mov bx, offset my_zone
add bx, index
mov al, [bx] ;save to al the color
add [index], 1
; ציור
mov bh,0h
mov cx,[x]
mov dx,[y]
; the color is - al
mov ah,0ch
int 10h
pop cx
add [x],-1
loop loopDXN
sub [y], 1
add [x], 1
mov cx, 3
loopDXP2: ;מעלה את x
push cx
; קליטה מהמערך
mov bx, offset my_zone
add bx, index
mov al, [bx]
add [index], 1
; ציור
mov bh,0h
mov cx,[x]
mov dx,[y]
; al - the color
mov ah,0ch
int 10h
pop cx
add [x],1
loop loopDXP2
pop [y]
pop [x]
ret
endp delete_char2
proc make_screen
mov cx, 300
loopSXP: ;מעלה את x ;s = screen x
push cx
mov bh,0h
mov cx,[xs]
mov dx,[ys]
mov al,[colors]
mov ah,0ch
int 10h
pop cx
add [xs],1
loop loopSXP
mov cx, 180
loopSYP:
push cx
mov bh,0h
mov cx,[xs]
mov dx,[ys]
mov al,[colors]
mov ah,0ch
int 10h
pop cx
sub [ys],1
loop loopSYP
mov cx, 300
loopSXN: ;מעלה את x
push cx
mov bh,0h
mov cx,[xs]
mov dx,[ys]
mov al,[colors]
mov ah,0ch
int 10h
pop cx
sub [xs],1
loop loopSXN
mov cx, 180
loopSYN:
push cx
mov bh,0h
mov cx,[xs]
mov dx,[ys]
mov al,[colors]
mov ah,0ch
int 10h
pop cx
add [ys],1
loop loopSYN
ret
endp make_screen
proc print_array ;for debug ;for my_character
push dx
push ax
push cx
push bx
mov cx, 9
mov dh, 1
mov [i], 0
loopP:
mov dl, 48
add dl, dh
mov ah, 02h
int 21h
mov bx, offset my_zone
add bx, [i]
; sub bx, 1
mov dl, 48
add dl, [bx]
mov ah, 02h
int 21h
mov dl, ' '
int 21h
add dh, 1
add [i], 1
loop loopP
mov dl, '-'
int 21h
pop bx
pop cx
pop ax
pop dx
ret
endp print_array
proc print_array2 ;for debug ;for enemey_character
push dx
push ax
push cx
push bx
mov cx, 14
mov dh, 1
mov [i2], 0
loopP2:
mov dl, 48
add dl, dh
mov ah, 02h
int 21h
mov bx, offset enemy1_character
add bx, [i2]
; sub bx, 1
mov dl, 48
add dl, [bx]
mov ah, 02h
int 21h
mov dl, ' '
int 21h
add dh, 1
add [i2], 1
loop loopP2
mov dl, '-'
int 21h
pop bx
pop cx
pop ax
pop dx
ret
endp print_array2
proc color_to_color
mov [xs2], 10
mov [ys2], 190
loopaint:
mov bh, 0h
mov cx, [xs2]
mov dx, [ys2]
mov ah, 0dh
int 10h
cmp al, [colorg1]
je paint_red
jmp loopend
paint_red:
mov bh,0h
mov cx,[xs2]
mov dx,[ys2]
mov al,[colorg2]
mov ah,0ch
int 10h
loopend:
add [xs2], 1
cmp [xs2], 311
je upy
jmp loopaint
upy:
mov [xs2], 10
sub [ys2], 1
cmp [ys2], 9
je endpaint
jmp loopaint
endpaint:
ret
endp color_to_color
proc start_paint ;where to start painting ;right now not ready
mov ax, startx
mov [paintx], ax
mov ax, starty
mov [painty], ax
mov al, [first_tav]
mov ah, [final_tav]
cmp al, 1
je up_paint
cmp al, 2
je down_paint
cmp al, 3
je right_paint
cmp al, 4
je left_paint
jmp exit
up_paint:
mov ax, [x]
cmp ax, [startx]
jge up_right
jl up_left
jmp exit
up_right:
sub [painty], 2
add [paintx], 2
ret
up_left:
sub [painty], 2
ret
down_paint:
mov ax, [x]
cmp ax, [startx]
jge down_right
jl down_left
jmp exit
down_right:
add [paintx], 2
ret
down_left:
ret
right_paint:
mov ax, [y]
cmp ax, [starty]
jge right_down
jl right_up
jmp exit
right_down:
add [paintx], 2
ret
right_up:
add [paintx], 2
sub [painty], 2
ret
left_paint:
mov ax, [y]
cmp ax, [starty]
jge left_down
jl left_up
jmp exit
left_down:
ret
left_up:
sub [painty], 2
ret
endp start_paint
proc start_paintN ;negative form of start_paint ;we change jg to jl and jl to jg
mov ax, startx
mov [paintx], ax
mov ax, starty
mov [painty], ax
mov al, [first_tav]
mov ah, [final_tav]
cmp al, 1
je up_paint2
cmp al, 2
je down_paint2
cmp al, 3
je right_paint2
cmp al, 4
je left_paint2
jmp exit
up_paint2:
mov ax, [x]
cmp ax, [startx]
jl up_right2
jge up_left2
jmp exit
up_right2:
sub [painty], 2
add [paintx], 2
ret
up_left2:
sub [painty], 2
ret
down_paint2:
mov ax, [x]
cmp ax, [startx]
jl down_right2
jge down_left2
jmp exit
down_right2:
add [paintx], 2
ret
down_left2:
ret
right_paint2:
mov ax, [y]
cmp ax, [starty]
jl right_down2
jge right_up2
jmp exit
right_down2:
add [paintx], 2
ret
right_up2:
add [paintx], 2
sub [painty], 2
ret
left_paint2:
mov ax, [y]
cmp ax, [starty]
jl left_down2
jge left_up2
jmp exit
left_down2:
ret
left_up2:
sub [painty], 2
ret
endp start_paintN
proc start_paint1
mov ax, startx
mov [paintx], ax
mov ax, starty
mov [painty], ax
mov al, [first_tav]
mov ah, [final_tav]
cmp al, 1
je up_right3
cmp al, 2
je down_right3
cmp al, 3
je right_down3
cmp al, 4
je left_down3
jmp exit
up_right3:
sub [painty], 2
add [paintx], 2
ret
down_right3:
add [paintx], 2
ret
right_down3:
add [paintx], 2
ret
left_down3:
ret
endp start_paint1
proc start_paint2
mov ax, startx
mov [paintx], ax
mov ax, starty
mov [painty], ax
mov al, [first_tav]
mov ah, [final_tav]
cmp al, 1
je up_left3
cmp al, 2
je down_left3
cmp al, 3
je right_up3
cmp al, 4
je left_up3
jmp exit
up_left3:
sub [painty], 2
ret
down_left3:
ret
right_up3:
add [paintx], 2
sub [painty], 2
ret
left_up3:
sub [painty], 2
ret
endp start_paint2
proc print_precents
mov ax, [screen_paint_precent]
mov bl, 10
div bl
; al = ax div 10 = a_ (first char)
; ah = ax mod 10 = _a (last char)
mov bl, al
mov bh, ah
; go to thee start of the line
mov dl, 13
mov ah, 2
int 21h
mov dl, 48
add dl, bl
int 21h
mov dl, 48
add dl, bh
int 21h
mov ax, [screen_paint_precent]
cmp ax, 75
jge player_win
ret
endp print_precents
player_win:
push seg message2
mov dx, offset message2
mov ah, 9h
int 21h
push seg message3
mov dx, offset message3
mov ah, 9h
int 21h
push seg message4
mov dx, offset message4
mov ah, 9h
int 21h
check_start_or_exit:
mov ah, 00h
int 16h
cmp al, 'e'
je help16
cmp al, 'q'
je help17
jmp check_start_or_exit
help16:
jmp start
help17:
jmp exit
player_lose:
push seg message5
mov dx, offset message5
mov ah, 9h
int 21h
push seg message3
mov dx, offset message3
mov ah, 9h
int 21h
push seg message4
mov dx, offset message4
mov ah, 9h
int 21h
jmp check_start_or_exit
proc enemy_character
push [xe]
push [ye]
mov [enemy_index], 0
; שמירה
mov bh, 0h
mov cx, [xe]
mov dx, [ye]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset enemy1_character
add bx, [enemy_index]
mov [bx], al
add [enemy_index], 1
; ציור
mov bh, 0h
mov cx, [xe]
mov dx, [ye]
mov al,[enemy_color]
mov ah,0ch
int 10h
sub [xe], 1
add [ye], 1
mov cx, 3
loopXP3: ;מעלה את x
; שמירה
push cx
mov bh, 0h
mov cx, [xe]
mov dx, [ye]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset enemy1_character
add bx, [enemy_index]
mov [bx], al
add [enemy_index], 1
; ציור
mov bh, 0h
mov cx, [xe]
mov dx, [ye]
mov al,[enemy_color]
mov ah,0ch
int 10h
pop cx
add [xe],1
loop loopXP3
; שינוי מיקום
add [ye], 1
mov cx, 5
loopXN2: ;מוריד את x
push cx
mov bh, 0h
mov cx, [xe]
mov dx, [ye]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset enemy1_character
add bx, [enemy_index]
mov [bx], al
add [enemy_index], 1
; ציור
mov bh,0h
mov cx,[xe]
mov dx,[ye]
mov al,[enemy_color]
mov ah,0ch
int 10h
pop cx
add [xe],-1
loop loopXN2
add [ye], 1
add [xe], 2
mov cx, 3
loopXP4: ;מעלה את x
; שמירה
push cx
mov bh, 0h
mov cx, [xe]
mov dx, [ye]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset enemy1_character
add bx, [enemy_index]
mov [bx], al
add [enemy_index], 1
; ציור
mov bh, 0h
mov cx, [xe]
mov dx, [ye]
mov al,[enemy_color]
mov ah,0ch
int 10h
pop cx
add [xe],1
loop loopXP4
; שינוי מיקום
add [ye], 1
sub [xe], 2
; שמירה
mov bh, 0h
mov cx, [xe]
mov dx, [ye]
mov ah, 0dh
int 10h
;שמירה במערך
mov bx, offset enemy1_character
add bx, [enemy_index]
mov [bx], al
; add [enemy_index], 1
; ציור
mov bh, 0h
mov cx, [xe]
mov dx, [ye]
mov al,[enemy_color]
mov ah,0ch
int 10h
pop [ye]
pop [xe]
ret
endp enemy_character
proc enemy_delete
push [xe]
push [ye]
mov [enemy_index], 0
; קליטה מהמערך
mov bx, offset enemy1_character
add bx, [enemy_index]
mov al, [bx] ;save to al the color
add [enemy_index], 1
; ציור
mov bh,0h
mov cx,[xe]
mov dx,[ye]
; the color is - al
mov ah,0ch
int 10h
sub [xe], 1
add [ye], 1
mov cx, 3
loopDXP3: ;מעלה את x
; שמירה
push cx
; קליטה מהמערך
mov bx, offset enemy1_character
add bx, [enemy_index]
mov al, [bx] ;save to al the color
add [enemy_index], 1
; ציור
mov bh,0h
mov cx,[xe]
mov dx,[ye]
; the color is - al
mov ah,0ch
int 10h
pop cx
add [xe],1
loop loopDXP3
; שינוי מיקום
add [ye], 1
mov cx, 5
loopDXN2: ;מוריד את x
push cx
; קליטה מהמערך
mov bx, offset enemy1_character
add bx, [enemy_index]
mov al, [bx] ;save to al the color
add [enemy_index], 1
; ציור
mov bh,0h
mov cx,[xe]
mov dx,[ye]
; the color is - al
mov ah,0ch
int 10h
pop cx
add [xe],-1
loop loopDXN2
add [ye], 1
add [xe], 2
mov cx, 3
loopDXP4: ;מעלה את x
; שמירה
push cx
; קליטה מהמערך
mov bx, offset enemy1_character
add bx, [enemy_index]
mov al, [bx] ;save to al the color
add [enemy_index], 1
; ציור
mov bh,0h
mov cx,[xe]
mov dx,[ye]
; the color is - al
mov ah,0ch
int 10h
pop cx
add [xe],1
loop loopDXP4