-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.asm
1442 lines (1076 loc) · 19.4 KB
/
main.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
;a macro to print msgs
print macro string
pusha
lea dx, string
mov ah, 09h
int 21h
endm
; a macro for mouse cursor
mouse macro x, y
pusha
mov ah, 02h
mov bx, 0
mov dh, x
mov dl, y
int 10h
popa
endm
.model small
.stack 0100h
.data
key db 0
; for line 1
xaxis1 dw 50
yaxis1 dw 20
xaxis2 dw 80
yaxis2 dw 20
xaxis3 dw 110
yaxis3 dw 20
xaxis4 dw 140
yaxis4 dw 20
xaxis5 dw 170
yaxis5 dw 20
xaxis6 dw 200
yaxis6 dw 20
xaxis7 dw 230
yaxis7 dw 20
xaxis8 dw 260
yaxis8 dw 20
; for line2
x1 dw 60 ; x for x axis
y1 dw 37 ; y for y axis
x2 dw 90
y2 dw 37
x3 dw 120
y3 dw 37
x4 dw 150
y4 dw 37
x5 dw 180
y5 dw 37
x6 dw 210
y6 dw 37
x7 dw 240
y7 dw 37
;for line 3
xcord1 dw 77 ; x coordinate
ycord1 dw 52 ; y coordinate
xcord2 dw 107 ; x coordinate
ycord2 dw 52 ; y coordinate
xcord3 dw 137 ; x coordinate
ycord3 dw 52 ; y coordinate
xcord4 dw 167 ; x coordinate
ycord4 dw 52 ; y coordinate
xcord5 dw 197 ; x coordinate
ycord5 dw 52 ; y coordinate
;for line 4
xa dw 98 ; xa for brick1
ya dw 68 ; ya for brick1
xb dw 115
yb dw 68
xc dw 130
yc dw 68
xd dw 195
yd dw 68
;line 5
xe dw 105
ye dw 84
xf dw 200
yf dw 84
;---paddle
px dw 10 ; paddle on x axis
py dw 180 ; paddle on y axis
temp dw 180
tempx dw 90
tempy dw 180
temp2 dw 185
gamename db "/BRICK BREAKER\",'$'
gamename2 db"\ /",'$'
gamename3 db " ~~~~~~~~~~~~~",'$'
entername db"Player name: ",'$'
instruction1 db " INSTRUCTIONS:",'$'
instruction2 db "1.Hit the bricks with ball to break them", '$'
instruction3 db "2.The ball will be bounced using paddle",'$'
instruction4 db "3.The ball cannot touch the floor",'$'
instruction5 db "4.Break maximum bricks to earn score",'$'
instruction6 db "5.Enter your name to continue",'$'
;screen 2
play0 db "------",'$'
play db "| PLAY |",'$'
resume0 db"--------",'$'
resume db "| RESUME |", '$'
scoreboard0 db"-------------",'$'
scoreboard db "| SCORE BOARD |",'$'
exitmsg0 db"------",'$'
exitmsg db"| EXIT |", '$'
;BORDER1 DB"/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\",'$'
;BORDER2 DB"\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/",'$'
border1 db"/\/\ /\/\ /\/\ /\/\ /\/\ /\/\ /\/\ /\/\",'$'
border2 db"\ / \ / \ / \ / \ / \ / \ / \ /",'$'
border3 db" \/ \/ \/ \/ \/ \/ \/ \/",'$'
heart1 db"/\/\",'$'
heart2 db"\ /", '$'
heart3 db" \/", '$'
score db "Score: $"
pname db "Name: $"
Level db "Level:1 $"
username db 7 dup('$') ,'$'
.code
main proc
mov ax, @data
mov ds,ax
firstScreen:
call clearscreen
mov ah, 00h
mov al, 13h
int 10h
mov ah, 02h
mov bx, 0
mov dh, 1
mov dl, 13
int 10h
lea dx, gamename
mov ah, 09h
int 21h
mov ah, 02h
mov bx, 0
mov dh, 2
mov dl, 13
int 10h
print gamename2
mov ah, 02h
mov bx, 0
mov dh, 3
mov dl, 13
int 10h
print gamename3
mov ah, 02h
mov bx, 0
mov dh, 5
mov dl, 13
int 10h
print instruction1
mov ah, 02h
mov bx, 0
mov dh, 7
mov dl, 0
int 10h
print instruction2
mov ah, 02h
mov bx, 0
mov dh, 9
mov dl, 0
int 10h
print instruction3
mov ah, 02h
mov bx, 0
mov dh, 11
mov dl, 0
int 10h
print instruction4
mov ah, 02h
mov bx, 0
mov dh, 13
mov dl, 0
int 10h
print instruction5
mov ah, 02h
mov bx, 0
mov dh, 15
mov dl, 0
int 10h
print instruction6
mov ah, 02h
mov bx, 0
mov dh, 17
mov dl, 5
int 10h
lea dx, entername
mov ah, 09h
int 21h
lea dx,username
Mov ah, 3fh
Int 21h
call clearscreen
mouse 0, 0
print border1
mouse 1, 0
print border2
mouse 2, 0
print border3
mouse 4, 0
print heart1
mouse 5, 0
print heart2
mouse 6, 0
print heart3
mouse 8, 0
print heart1
mouse 9, 0
print heart2
mouse 10, 0
print heart3
mouse 12, 0
print heart1
mouse 13, 0
print heart2
mouse 14, 0
print heart3
mouse 16, 0
print heart1
mouse 17, 0
print heart2
mouse 18, 0
print heart3
mouse 20, 0
print heart1
mouse 21, 0
print heart2
mouse 22, 0
print heart3
;;;;;;;;;;;;;;;;
mouse 4, 196
print heart1
mouse 5, 196
print heart2
mouse 6, 196
print heart3
mouse 8, 196
print heart1
mouse 9, 196
print heart2
mouse 10, 196
print heart3
mouse 12, 196
print heart1
mouse 13, 196
print heart2
mouse 14, 196
print heart3
mouse 16, 196
print heart1
mouse 17, 196
print heart2
mouse 18, 196
print heart3
mouse 20, 196
print heart1
mouse 21, 196
print heart2
mouse 22, 196
print heart3
;print play
mouse 4, 16
print play0
mouse 5, 15
print play
mouse 6, 16
print play0
;print resume
mouse 9, 15
print resume0
mouse 10, 14
print resume
mouse 11, 15
print resume0
;print scoreBoard
mouse 14, 13
print scoreboard0
mouse 15, 12
print scoreboard
mouse 16, 13
print scoreboard0
;print exit
mouse 19, 16
print exitmsg0
mouse 20, 15
print exitmsg
mouse 21, 16
print exitmsg0
;call clearscreen
options:
mov ah,1
int 16h
;jz options
mov ah,00h
int 16h
cmp ah,4Bh
je firstScreen
;cmp ah,4Dh
;je right
cmp al,101
je Exit
cmp al, 112
je nextScreen
JNE options
nextScreen:
call clearscreen
mouse 1,1
print score
mouse 1,12
mov dl,03 ; heart
mov ah,02
int 21h
mouse 1,13
mov dl,03 ; heart
mov ah,02
int 21h
mouse 1,14
mov dl,03 ; heart
mov ah,02
int 21h
mouse 1,18
print Level
mouse 1,28
print pname
mouse 1,33
mov si, offset username
mov cx, 7
hii:
mov ah, 02h
mov dl, [si]
inc si
int 21h
loop hii
;bricks-----------------------------
mov bx,0 ; counter
again:
mov xaxis1,50
mov bx,0
L1:
MOV AH, 0Ch
MOV AL, 01h ; Color Number
MOV CX, xaxis1 ; co-ordinates of X-axis
MOV DX, yaxis1 ; co-ordinates of Y-axis
INT 10H
inc xaxis1
inc bx
cmp bx,30
je fill
jne L1
fill:
inc yaxis1
cmp yaxis1,35
je box1
jne again
;-------------------------------------
box1:
again1:
mov xaxis2,80
mov bx,0
L2:
MOV AH, 0Ch
MOV AL, 04h ; Color Number
MOV CX, xaxis2 ; co-ordinates of X-axis
MOV DX, yaxis2 ; co-ordinates of Y-axis
INT 10H
inc xaxis2
inc bx
cmp bx,30
je color
jne L2
color:
inc yaxis2
cmp yaxis2,35
je box2
jne again1
;-----------------------------
box2:
again2:
mov xaxis3,110
mov bx,0
L3:
MOV AH, 0Ch
MOV AL, 0Eh ; Color Number
MOV CX, xaxis3 ; co-ordinates of X-axis
MOV DX, yaxis3 ; co-ordinates of Y-axis
INT 10H
inc xaxis3
inc bx
cmp bx,30
je color1
jne L3
color1:
inc yaxis3
cmp yaxis3,35
je box3
jne again2
;--------------------------------------------
box3:
again3:
mov xaxis4,140
mov bx,0
L4:
MOV AH, 0Ch
MOV AL, 01h ; Color Number
MOV CX, xaxis4 ; co-ordinates of X-axis
MOV DX, yaxis4 ; co-ordinates of Y-axis
INT 10H
inc xaxis4
inc bx
cmp bx,30
je color2
jne L4
color2:
inc yaxis4
cmp yaxis4,35
je box4
jne again3
;---------------------------------------
box4:
again4:
mov xaxis5,170
mov bx,0
L5:
MOV AH, 0Ch
MOV AL, 02h ; Color Number
MOV CX, xaxis5 ; co-ordinates of X-axis
MOV DX, yaxis5 ; co-ordinates of Y-axis
INT 10H
inc xaxis5
inc bx
cmp bx,30
je color3
jne L5
color3:
inc yaxis5
cmp yaxis5,35
je box5
jne again4
;--------------------------------------
box5:
again5:
mov xaxis6,200
mov bx,0
L6:
MOV AH, 0Ch
MOV AL, 05h ; Color Number
MOV CX, xaxis6 ; co-ordinates of X-axis
MOV DX, yaxis6 ; co-ordinates of Y-axis
INT 10H
inc xaxis6
inc bx
cmp bx,30
je color4
jne L6
color4:
inc yaxis6
cmp yaxis6,35
je box6
jne again5
;-----------------------------------------
box6:
again6:
mov xaxis7,230
mov bx,0
L7:
MOV AH, 0Ch
MOV AL, 02h ; Color Number
MOV CX, xaxis7 ; co-ordinates of X-axis
MOV DX, yaxis7 ; co-ordinates of Y-axis
INT 10H
inc xaxis7
inc bx
cmp bx,30
je color5
jne L7
color5:
inc yaxis7
cmp yaxis7,35
je box7
jne again6
;---------------------------------
box7:
again7:
mov xaxis8,260
mov bx,0
L8:
MOV AH, 0Ch
MOV AL, 0Eh ; Color Number
MOV CX, xaxis8 ; co-ordinates of X-axis
MOV DX, yaxis8 ; co-ordinates of Y-axis
INT 10H
inc xaxis8
inc bx
cmp bx,30
je color6
jne L8
color6:
inc yaxis8
cmp yaxis8,35
je rec1
jne again7
;--------------------
rec1:
r1: ; r = repeat process
mov x1,60
mov bx,0
do1: ; do the process
MOV AH, 0Ch
MOV AL, 0Eh ; Color Number
MOV CX, x1 ; co-ordinates of X-axis
MOV DX, y1 ; co-ordinates of Y-axis
INT 10H
inc x1
inc bx
cmp bx,30
je c1 ; c for coloring
jne do1
c1:
inc y1
cmp y1,50
je rec2
jne r1
;--------------------
rec2:
r2:
mov x2,90
mov bx,0
do2: ; do the process
MOV AH, 0Ch
MOV AL, 02h ; Color Number
MOV CX, x2 ; co-ordinates of X-axis
MOV DX, y2 ; co-ordinates of Y-axis
INT 10H
inc x2
inc bx
cmp bx,30
je c2
jne do2
c2:
inc y2
cmp y2,50
je rec3
jne r2
;--------------------
rec3:
r3:
mov x3,120
mov bx,0
do3: ; do the process
MOV AH, 0Ch
MOV AL, 01h ; Color Number
MOV CX, x3 ; co-ordinates of X-axis
MOV DX, y3 ; co-ordinates of Y-axis
INT 10H
inc x3
inc bx
cmp bx,30
je c3
jne do3
c3:
inc y3
cmp y3,50
je rec4
jne r3
;----------------
rec4:
r4:
mov x4,150
mov bx,0
do4: ; do the process
MOV AH, 0Ch
MOV AL, 05h ; Color Number
MOV CX, x4 ; co-ordinates of X-axis
MOV DX, y4 ; co-ordinates of Y-axis
INT 10H
inc x4
inc bx
cmp bx,30
je c4
jne do4
c4:
inc y4
cmp y4,50
je rec5
jne r4
;----------------
rec5:
r5:
mov x5,180
mov bx,0
do5: ; do the process
MOV AH, 0Ch
MOV AL, 0Eh ; Color Number
MOV CX, x5 ; co-ordinates of X-axis
MOV DX, y5 ; co-ordinates of Y-axis
INT 10H
inc x5
inc bx
cmp bx,30
je c5
jne do5
c5:
inc y5
cmp y5,50
je rec6
jne r5
;----------------
rec6:
r6:
mov x6,210
mov bx,0
do6: ; do the process
MOV AH, 0Ch
MOV AL, 02h ; Color Number
MOV CX, x6 ; co-ordinates of X-axis
MOV DX, y6 ; co-ordinates of Y-axis
INT 10H
inc x6
inc bx
cmp bx,30
je c6
jne do6
c6:
inc y6
cmp y6,50
je rec7
jne r6
;----------------
rec7:
r7:
mov x7,240
mov bx,0
do7: ; do the process
MOV AH, 0Ch
MOV AL, 01h ; Color Number
MOV CX, x7 ; co-ordinates of X-axis
MOV DX, y7 ; co-ordinates of Y-axis
INT 10H
inc x7
inc bx
cmp bx,30
je c7
jne do7
c7:
inc y7
cmp y7,50
je brick1
jne r7
;-----------------------
brick1:
rep1:
mov xcord1,77
mov bx,0
make1: ; make the brick
MOV AH, 0Ch
MOV AL, 02h ; Color Number
MOV CX, xcord1 ; co-ordinates of X-axis
MOV DX, ycord1 ; co-ordinates of Y-axis
INT 10H
inc xcord1
inc bx
cmp bx,30
je clr1 ; colour the brick
jne make1
clr1:
inc ycord1
cmp ycord1,65
je brick2
jne rep1
;-----------------------
brick2:
rep2:
mov xcord2,107
mov bx,0
make2: ; make the brick
MOV AH, 0Ch
MOV AL, 01h ; Color Number
MOV CX, xcord2 ; co-ordinates of X-axis
MOV DX, ycord2 ; co-ordinates of Y-axis
INT 10H
inc xcord2
inc bx
cmp bx,30
je clr2 ; colour the brick
jne make2
clr2:
inc ycord2
cmp ycord2,65
je brick3
jne rep2
;-----------------------
brick3:
rep3:
mov xcord3, 137
mov bx,0
make3: ; make the brick
MOV AH, 0Ch
MOV AL, 05h ; Color Number
MOV CX, xcord3 ; co-ordinates of X-axis
MOV DX, ycord3 ; co-ordinates of Y-axis
INT 10H
inc xcord3
inc bx
cmp bx,30
je clr3 ; colour the brick
jne make3
clr3:
inc ycord3
cmp ycord3,65
je brick4
jne rep3
;-----------------------
brick4:
rep4:
mov xcord4,167
mov bx,0
make4: ; make the brick
MOV AH, 0Ch
MOV AL, 04h ; Color Number
MOV CX, xcord4 ; co-ordinates of X-axis
MOV DX, ycord4 ; co-ordinates of Y-axis
INT 10H
inc xcord4
inc bx
cmp bx,30
je clr4 ; colour the brick
jne make4
clr4:
inc ycord4
cmp ycord4,65
je brick5
jne rep4
;-----------------------
brick5:
rep5:
mov xcord5,197
mov bx,0
make5: ; make the brick
MOV AH, 0Ch
MOV AL, 01h ; Color Number
MOV CX, xcord5 ; co-ordinates of X-axis
MOV DX, ycord5 ; co-ordinates of Y-axis
INT 10H
inc xcord5
inc bx
cmp bx,40
je clr5 ; colour the brick
jne make5
clr5:
inc ycord5
cmp ycord5,65
je br1