-
Notifications
You must be signed in to change notification settings - Fork 0
/
candy.asm
1691 lines (1564 loc) · 31.1 KB
/
candy.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
OUTP MACRO X
MOV DL,X
MOV AH,02H
INT 21H
ENDM
.MODEL SMALL
.STACK 100h
.DATA
gameName db "************ CANDY CRUSH ************$"
MENU DB " *_*_*____ MAIN MENU ____*_*_*", 10,13,"$"
player db "Enter name: $"
pname db 20 DUP(0)
fname db "record.txt"
fhandle dw ?
random db 0
welcome db "WELCOME TO THE GAME$"
COUNT DB 0
X DW 0
Y DW 0
BOARD DB 49 DUP(0)
YLINE DB 0
VAR DW 0
VAR2 DW 0
RULES DB "GAME RULES$"
RULE1 DB "1)Swap candy on board to make a match of 3 or more.$"
RULE2 DB "2)Shape and colour of candy must match$"
RULE3 DB "3)Matched candies will eliminate and new candies will replace them.$"
MOVES DB 0
LEVEL DB "LEVEL:$"
LEVELNUM DB 0
SCORESTR DB "Score:$"
SCORE DB 0
MOVESSTR DB "Moves:$"
GETX DW 0
GETY DW 0
INDEX1 DB 0
INDEX2 DB 0
GETX1 DW 0
GETY1 DW 0
NUMBER DB 0
REGBL DB 0
INVALID DB "INVALID MOVE$"
CANDYCOUNT DB 0
CANDYTYPE DB 0
PNAME_LEN DB 0
VALID DB 0
COMBO DB 0
page_border db "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^$"
newlinestr db 10, 13, '$'
crushing db "CRUSHING$"
exploded DB "EXPLOSION", '$'
colorbomb db 0
matches db 0
DOTTED db " -----------------------", 10,13,"$"
tag db " | LEVEL: $"
SUCCESS DB " LEVEL SUCCESS $"
FAILURE DB " LEVEL FAILED $"
.CODE
main proc
MOV AX,@DATA
MOV DS,AX
MOV AH,3CH ;3ch: file creation, 3eh: file closes
MOV CL,0 ;to enter read only mode
MOV DX, OFFSET FNAME
INT 21H
MOV FHANDLE,AX
MOV AH,00H ;setting video mode
MOV AL,0Dh ;320x200 pixels and 16 colours
INT 10H
MOV AH,0BH
MOV BH,00H
MOV BL,04H ;background colour
INT 10H
MOV AH,06h ;scroll-up window
MOV AL,0
MOV BH,24H ;text and background colour
MOV CH,0 ;upper row number
MOV CL,0 ;left col
MOV DH,24
MOV DL,79
INT 10H
CALL PG_BORDER
MOV AH,02H
MOV BH,0
MOV DH,8 ;displays message in line 8
MOV DL,2 ;starts display with a gap of 2 spaces
INT 10H
MOV DX, offset gameName ;displays GAME NAME
MOV AH,09H
INT 21H
MOV AH,02H
MOV BH,0
MOV DH,15 ;displays message in line 15
MOV DL,8 ;starts displaying message with 8 spaces
INT 10H
MOV DX, offset player ;display enter message
MOV AH,09H
INT 21H
MOV SI, OFFSET pname ;to store player name
.REPEAT
INC PNAME_LEN
MOV AH,01
INT 21H
MOV AH,0
MOV [SI],AL
inc SI
.UNTIL AL== 13 ;takes input for player name till user presses enter key
mov byte ptr [SI], 36 ;'$' sign to make string output better
;writing name in .txt file
MOV AH,3DH ;3dh write mode
MOV CL,2 ;to read or write
INT 21H
MOV CX, LENGTHOF PNAME
MOV BX,fhandle ;File handler moves into AX as soon as file is opened
MOV DX,OFFSET pname
MOV AH,40H
INT 21H
MOV AH,02H
MOV BH,0
MOV DH,21 ;displays message in line 21
MOV DL,8 ;starts display with a gap of 8 spaces
INT 10H
MOV DX, offset WELCOME ;displays WELCOME MESSAGE
MOV AH,09H
INT 21H
MOV AH,08H
INT 21H
CALL RULESPAGE ;displays second page with rules
MOV AH,08H
INT 21H
.REPEAT
CALL MAINMENU_PAGE
MOV AH,08H
INT 21H
SUB AL,48
MOV LEVELNUM,AL
.IF AL == 1
MOV LEVELNUM,1
MOV AH,05H ;MOVE TO NEXT PAGE WITH BOARD DISPLAY
MOV AL,03H
MOV AH,0BH
MOV BH,02H
MOV BL,0H ;background colour
INT 10H
MOV AH,06h ;scroll-up window
MOV AL,0
MOV BH,00H ;text and background colour
MOV CH,0 ;upper row number
MOV CL,0 ;left col
MOV DH,24
MOV DL,79
INT 10H
CALL LEVEL1
.ELSEIF AL == 2
MOV LEVELNUM,2
MOV AH,05H ;MOVE TO NEXT PAGE WITH BOARD DISPLAY
MOV AL,04H
MOV AH,0BH
MOV BH,02H
MOV BL,0H ;background colour
INT 10H
MOV AH,06h ;scroll-up window
MOV AL,0
MOV BH,00H ;text and background colour
MOV CH,0 ;upper row number
MOV CL,0 ;left col
MOV DH,24
MOV DL,79
INT 10H
CALL LEVEL2
.ELSEIF AL == 3
MOV LEVELNUM,3
MOV AH,05H ;MOVE TO NEXT PAGE WITH BOARD DISPLAY
MOV AL,05H
MOV AH,0BH
MOV BH,02H
MOV BL,0H ;background colour
INT 10H
MOV AH,06h ;scroll-up window
MOV AL,0
MOV BH,00H ;text and background colour
MOV CH,0 ;upper row number
MOV CL,0 ;left col
MOV DH,24
MOV DL,79
INT 10H
CALL LEVEL3
.ENDIF
CALL CLS
MOV AH,00
MOV AL,13
INT 10H
MOV AH,05H ;MOVE TO NEXT PAGE WITH BOARD DISPLAY
MOV AL,06H
MOV AH,06h ;scroll-up window
MOV AL,0
MOV BH,00H ;text and background colour
MOV CH,0 ;upper row number
MOV CL,0 ;left col
MOV DH,24
MOV DL,79
INT 10H
MOV AH,02H
MOV BH,0
MOV DH,12
MOV DL,14
INT 10H
.IF SCORE >150
LEA DX,SUCCESS ;SCREEN DISPLAYS LEVEL SUCCESS
MOV AH,09H
INT 21H
.ELSE
LEA DX,FAILURE ;SCREEN DISPLAYS LEVEL FAILED
MOV AH,09H
INT 21H
.ENDIF
mov ah,08h
int 21h
CALL CLS
MOV AH,00
MOV AL,13
INT 10H
.UNTIL LEVELNUM==0
MOV AH,0 ;EXITS VIDEO MODE
INT 16H
MOV AH,03
INT 10h
MOV AH,3EH ;closes file
MOV BX,FHANDLE
INT 21H
MOV AH,4CH
INT 21H
main endp
;******************
;DISPLAYS RULES PAGE
;*****************
RULESPAGE PROC
MOV AH,05H ;MOVE TO NEXT PAGE TO DISPLAY RULES
MOV AL, 01H
MOV AH,0BH
MOV BH,00H
MOV BL,08H ;background colour
INT 10H
MOV AH,06h ;scroll-up window
MOV AL,0
MOV BH,58H ;text and background colour
MOV CH,0 ;upper row number
MOV CL,0 ;left col
MOV DH,24
MOV DL,79
INT 10H
MOV AH,02H
MOV BH, 0
MOV DH,2 ;displays message in line 2
MOV DL,0 ;starts display with a gap of 0 spaces
INT 10H
lea DX, page_border ;displays gamename
MOV AH,09H
INT 21H
MOV AH,02H
MOV BH,0
MOV DH,24 ;displays message in line 24
MOV DL,0 ;starts display with a gap of 0 spaces
INT 10H
lea DX, page_border ;displays DESIGNED STRIPE
MOV AH,09H
INT 21H
MOV AH,02H
MOV BH,0
MOV DH,5 ;displays message in line 5
MOV DL,15 ;starts display with a gap of 15 spaces
INT 10H
MOV DX, offset RULES ;displays game rules
MOV AH,09H
INT 21H
MOV AH,02H
MOV BH,0
MOV DH,11 ;displays message in line 11
MOV DL,2 ;starts display with a gap of 2 spaces
INT 10H
MOV DX, offset RULE1 ;displays rule1
MOV AH,09H
INT 21H
MOV AH,02H
MOV BH,0
MOV DH,15 ;displays message in line 15
MOV DL,2 ;starts display with a gap of 2 spaces
INT 10H
MOV DX, offset RULE2 ;displays rule1
MOV AH,09H
INT 21H
MOV AH,02H
MOV BH,0
MOV DH,18 ;displays message in line 18
MOV DL,2 ;starts display with a gap of 2 spaces
INT 10H
MOV DX, offset RULE3 ;displays rule1
MOV AH,09H
INT 21H
RET
RULESPAGE ENDP
;************************************
;MAIN MENU PAGE
;****************************************
MAINMENU_PAGE PROC USES AX BX CX DX
MOV AH,05H ;DISPLAYS THIRD PAGE WITH MENU
MOV AL,02H
MOV AH,0BH
MOV BH,00H
MOV BL,04H ;background colour
INT 10H
MOV AH,06h ;scroll-up window
MOV AL,0
MOV BH,04H ;text and background colour
MOV CH,0 ;upper row number
MOV CL,0 ;left col
MOV DH,24
MOV DL,79
INT 10H
CALL PG_BORDER
MOV AH,02H
MOV BH,0
MOV DH,4 ;displays message in line 8
MOV DL,2 ;starts display with a gap of 2 spaces
INT 10H
LEA DX,MENU
MOV AH,09H
INT 21H
CALL NL
CALL NL
LEA DX,DOTTED
MOV AH,09H
INT 21H
LEA DX,TAG
MOV AH,09H
INT 21H
OUTP '1'
MOV CX,0
.WHILE CX<6
OUTP ' '
INC CX
.ENDW
OUTP '|'
CALL NL
LEA DX,DOTTED
MOV AH,09H
INT 21H
CALL NL
CALL NL
LEA DX,DOTTED
MOV AH,09H
INT 21H
LEA DX,TAG
MOV AH,09H
INT 21H
OUTP '2'
MOV CX,0
.WHILE CX<6
OUTP ' '
INC CX
.ENDW
OUTP '|'
CALL NL
LEA DX,DOTTED
MOV AH,09H
INT 21H
CALL NL
CALL NL
LEA DX,DOTTED
MOV AH,09H
INT 21H
LEA DX,TAG
MOV AH,09H
INT 21H
OUTP '3'
MOV CX,0
.WHILE CX<6
OUTP ' '
INC CX
.ENDW
OUTP '|'
CALL NL
LEA DX,DOTTED
MOV AH,09H
INT 21H
RET
MAINMENU_PAGE ENDP
;*********************************************
;NEXT LINE
;*********************************************
NL PROC USES AX DX
MOV DL,10
MOV AH,02H
INT 21H
MOV DL,13
MOV AH,02H
INT 21H
RET
NL ENDP
;*********************************************
;GETS RANDOM NUMBER USING SYSTEM TIME
;*********************************************
RAND PROC USES AX BX CX DX
MOV AH,0
MOV AL, 0
INT 1AH
MOV random,DL
RET
RAND ENDP
;********************************************
;PAGE BORDER WITH TWO DESIGNED STRIPES
;********************************************
PG_BORDER PROC USES AX BX CX DX
MOV AH,06h ;scroll-up window
MOV AL,0
MOV BH,24H ;text and background colour
MOV CH,0 ;upper row number
MOV CL,0 ;left col
MOV DH,24
MOV DL,79
INT 10H
MOV AH,02H
MOV BH, 0
MOV DH,2 ;displays message in line 2
MOV DL,0 ;starts display with a gap of 0 spaces
INT 10H
lea DX, page_border ;displays gamename
MOV AH,09H
INT 21H
MOV AH,02H
MOV BH,0
MOV DH,24 ;displays message in line 24
MOV DL,0 ;starts display with a gap of 0 spaces
INT 10H
lea DX, page_border ;displays DESIGNED STRIPE
MOV AH,09H
INT 21H
RET
PG_BORDER ENDP
;*******************************************
;CONSTRUCTS BLOCK BORDER FOR EACH CELL
;*******************************************
BLOCK_BORDER PROC USES AX BX CX DX
MOV AH,0CH
MOV AL,0FH
MOV BX,X
ADD BX,30
MOV CX,X
.WHILE CX<=BX ;constructs two parallel horizontal nice
MOV DX,Y
INT 10H
ADD DX,20
INT 10H
INC CX
.ENDW
MOV BX,Y
ADD BX,20
MOV DX,Y
.WHILE DX<=BX ;constructs two vertical lines
MOV CX,X
INT 10H
ADD CX,30
INT 10H
INC DX
.ENDW
RET
BLOCK_BORDER ENDP
;********************************************
;initializes board using random function
;********************************************
INITIALIZE_BOARD PROC USES SI AX
MOV COUNT,0
MOV SI,OFFSET BOARD ;address of board
MOV AX,0
.REPEAT
CALL RAND ;repeats random function
MOV AL,COUNT
XOR random,AL ;random generated number is randomized even more xor
MOV AL,random
MOV AH,0
MOV BL,5 ;taking mod of 5
DIV BL
MOV BYTE PTR [SI],AH
INC SI
INC COUNT
.UNTIL COUNT==49
RET
INITIALIZE_BOARD ENDP
;******************************************
;FUNCTION CALL FOR DARK BLUE SQUARE CANDY
;********************************************
SQR PROC USES AX BX CX DX
MOV AH,0CH ;function call for drawing pixels
MOV AL,01H ;selecting dark blue color
MOV BH,01
MOV BX,X
ADD BX,20 ;x-axis range
MOV CX,X
ADD CX,10
MOV DX,Y
ADD DX,5
MOV YLINE,DL
ADD YLINE,10 ;y-axis range
.WHILE CX<BX
MOV DX,Y
ADD DX,5
INT 10H
.WHILE DL<YLINE ;nested loop
INC DX
INT 10H
.ENDW
INC CX
.ENDW
RET
SQR ENDP
;******************************************
;FUNCTION CALL FOR PEACH RECTANGLE CANDY
;*******************************************
RECT PROC USES AX BX CX DX
MOV AH,0CH ;function call for drawing pixel
MOV AL,0CH ;peach color
MOV BH,01H
MOV BX,X
ADD BX,25 ;x-axis range
MOV CX,X
ADD CX,5
MOV DX,Y
ADD DX,7
MOV YLINE,DL
ADD YLINE,7 ;y-axis range
.WHILE CX<BX
MOV DX,Y
ADD DX,7
INT 10H
.WHILE DL<YLINE ;nested loop
INC DX
INT 10H
.ENDW
INC CX
.ENDW
RET
RECT ENDP
;**************************************
;FUNCTION CALL FOR RED HEART CANDY
;**************************************
HEART PROC USES AX BX CX DX
MOV AH,0CH ;function call for drawing pixels
MOV AL,04H ;RED colour
MOV BH,01H
MOV BX,0
MOV CX,0
MOV DX,0
MOV CX,X
MOV DX,Y
ADD CX,11
ADD DX,6
INT 10H
INC CX
INT 10H
ADD CX,4
INT 10H
INC CX
INT 10H
INC DX
MOV CX,X
ADD CX,10
MOV BX,CX ;drawing top curves of the heart
ADD BX,9 ;hard coded
.WHILE CX<BX
MOV VAR,BX
SUB VAR,CX
.IF VAR!=5
INT 10H
.ENDIF
INC CX
.ENDW
MOV CX,X
ADD CX, 10
MOV BX,CX
ADD BX,9 ;drawing 2 lined rectangle
.WHILE CX<BX
MOV DX,Y
ADD DX,8
INT 10H
INC DX
INT 10H
INC CX
.ENDW
INC DX ;drawing a downward triangle line by line
MOV CX,X
ADD CX,11
MOV BX,CX
ADD BX,7
.WHILE CX<BX
INT 10H
INC CX
.ENDW
INC DX
MOV CX,X
ADD CX,12
MOV BX,CX
ADD BX,5
.WHILE CX<BX
INT 10H
INC CX
.ENDW
INC DX
MOV CX,X
ADD CX,13
MOV BX,CX
ADD BX,3
.WHILE CX<BX
INT 10H
INC CX
.ENDW
INC DX
MOV CX,X
ADD CX,14
INT 10H
RET
HEART ENDP
;********************************************
;FUNCTION CALL FOR CYAN TRIANGLE CANDY
;*******************************************
TRIANGLE PROC USES AX BX CX DX
MOV AX,X
MOV VAR, ax
ADD VAR,15
MOV BH,0
MOV BX,0
MOV DX,Y
ADD DX,5
MOV YLINE,DL
ADD YLINE,9
MOV AX,VAR
MOV VAR2, AX
MOV AH,0CH ;drawing pixels
MOV AL,0BH ;cyan
.REPEAT
MOV CX,VAR
.WHILE CX<=WORD PTR VAR2
INT 10H
INC CX
.ENDW
DEC WORD PTR VAR ;decrementing starting point
INC WORD PTR VAR2 ;incrementing ending point
INC DX
.UNTIL DL==YLINE
RET
TRIANGLE ENDP
;***************************************
;FUNCTION CALL FOR YELLOW DIAMOND CANDY
;***************************************
DIAMOND PROC
mov AX, X
MOV VAR, AX
ADD VAR,15
MOV BH,0
MOV BX,0
MOV DX,Y
ADD DX,5
MOV YLINE,DL
ADD YLINE,5 ;y-axis range
mov ax, var
mov var2, ax
mov ah, 0ch ;function call for drawing pixels
mov al, 0Eh ;yellow colour
.REPEAT ;loop for up-right triangle
mov cx, word ptr var
.WHILE cx<=word ptr var2
int 10h
inc cx
.ENDW
dec word ptr var
inc word ptr var2
inc dx
.UNTIL dl==YLINE
ADD YLINE, 6
.REPEAT ;loop for downwards triangle
mov cx, word ptr var
.WHILE cx<=word ptr var2
int 10h
inc cx
.ENDW
INC word ptr var
DEc word ptr var2
inc dx
.UNTIL dl==YLINE
RET
DIAMOND ENDP
;*********************************
;FUNCTION CALL FOR COLOUR BOMB
;********************************
BOMB PROC USES AX BX CX DX
MOV AH,0CH ;drawing pixels
MOV AL,00H
MOV BH,01
MOV BX,X
ADD BX,20 ;x-axis range
MOV CX,X
ADD CX,10
MOV DX,Y
ADD DX,5
MOV YLINE,DL
ADD YLINE,10 ;y-axis range
.WHILE CX<BX ;draws vertical lines
MOV AH,0CH
INC AL
MOV DX,Y
ADD DX,5
INT 10H
.WHILE DL<YLINE
INC DX
INT 10H
.ENDW
INC CX
.ENDW
RET
BOMB ENDP
;***************************
;FUNCTION CALL FOR BLOCKAGE
;******************************
BLOCKAGE PROC USES AX BX CX DX
MOV AH,0CH
MOV AL,0fH
MOV BX,X
ADD BX,25
MOV CX,X
ADD CX,5
MOV DX,Y
.WHILE CX<BX ;printing diagonal left to right
INT 10H
INC CX
INC DX
.ENDW
MOV BX,X
ADD BX,5
MOV CX,X
ADD CX,25
MOV DX,Y
.WHILE CX>BX ;printing diagonal righ to left
INT 10H
DEC CX
INC DX
.ENDW
RET
BLOCKAGE ENDP
;*****************************************
;function to highlight selected BLOCK
;***********************************
HIGHLIGHT PROC USES AX BX CX DX
MOV AH,0CH
MOV AL,0fH
MOV BX,X
ADD BX,25
MOV CX,X
ADD CX,2 ;same as block border with different diensions
.WHILE CX<=BX
MOV DX,Y
ADD DX,2
INT 10H
INC DX
ADD DX,17
INT 10H
INC CX
.ENDW
MOV BX,Y
ADD BX,17
MOV DX,Y
ADD DX,2
.WHILE DX<=BX
MOV CX,X
ADD CX,2
INT 10H
ADD CX,25
INT 10H
INC DX
.ENDW
RET
HIGHLIGHT ENDP
;*************************************************
;FUNCTION CALL FOR DISPLAYING LEVEL DETAILS
;**********************************************
LEVEL_DETAILS PROC USES AX BX CX DX
MOV AH,06h ;scroll-up window
MOV AL,0
MOV BH,00H ;text and background colour
MOV CH,0 ;upper row number
MOV CL,0 ;left col
MOV DH,24
MOV DL,79
INT 10H
MOV AH,02H
MOV BH,0
MOV DH,2 ;displays message in line 8
MOV DL,2 ;starts display with a gap of 2 spaces
INT 10H
MOV DX, offset gameName ;displays gamename
MOV AH,09H
INT 21H
MOV AH,02H
MOV BH,0
MOV DH,4 ;displays message in line 4
MOV DL,29 ;starts display with a gap of 29 spaces
INT 10H
MOV DX, offset LEVEL ;displays the word 'LEVEL'
MOV AH,09H
INT 21H
MOV DL, LEVELNUM ;displays level number
ADD DL,48
MOV AH,02H
INT 21H
MOV AH,02H
MOV BH,0
MOV DH,6 ;displays message in line 6
MOV DL,29 ;starts display with a gap of 29 spaces
INT 10H
MOV SI,OFFSET pname
MOV CL,0
.WHILE CL<PNAME_LEN
MOV DL,BYTE PTR [SI]
MOV AH,02H
INT 21H
INC SI
INC CL
.ENDW
MOV AH,02H
MOV BH,0
MOV DH,8 ;displays message in line 8
MOV DL,29 ;starts display with a gap of 29 spaces
INT 10H
MOV DX, offset MOVESSTR ;displays the word 'Moves'
MOV AH,09H
INT 21H
MOV DL,MOVES ;displays moves
MOV NUMBER,DL
CALL DISPLAYNUM
OUTP '/'
OUTP '1'
OUTP '5' ;total moves for each level
MOV AH,02H
MOV BH,0
MOV DH,10 ;displays message in line 10
MOV DL,29 ;starts display with a gap of 29 spaces
INT 10H
MOV DX, offset SCORESTR ;displays the word 'Score'
MOV AH,09H
INT 21H
MOV DL,SCORE ;displays moves
MOV NUMBER,DL
CALL DISPLAYNUM
RET
LEVEL_DETAILS ENDP
;******************
;FUNCTION CALL FOR DISPLAYING BOARD AS PER ARRAY
;*******************
DISPLAYBOARD PROC USES SI AX
MOV COUNT,0
MOV SI,OFFSET BOARD
MOV X,10
MOV Y,30
.WHILE COUNT<49
MOV Al, [SI]
.IF AL!=5
CALL BLOCK_BORDER
.ENDIF
.IF aL==0
CALL SQR
.ELSEIF AL==1
CALL RECT
.ELSEIF AL==2
CALL HEART
.ELSEIF AL==3
CALL TRIANGLE
.ELSEIF AL==4
CALL DIAMOND
.ELSEIF AL==6
CALL BOMB
.ENDIF
INC SI
ADD X,30
.IF X>=220
MOV X,10
ADD Y,20
.ENDIF
INC COUNT
.ENDW
RET
DISPLAYBOARD ENDP
;***********************************************
;FUNCTION CALL FOR INITIALIZING BOARD FOR LEVEL3
;************************************************
LEVEL3_BOARD PROC USES SI
MOV SI,OFFSET BOARD
MOV COUNT,3