-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.asm
3319 lines (2776 loc) · 80.7 KB
/
Source.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 Irvine32.inc
includelib Winmm.lib
INCLUDE macros.inc
.386
;.model flat,stdcall
.stack 4096
BUFFER_SIZE = 1000
BUFFER_SIZE2 = 5000
.data
nextline DB 0ah,0dh , 0
GameMenu BYTE " ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " _______ _ ______ ____ ____ _ ____ _____ ",0ah
BYTE " |_ __ \ / \ .' ___ ||_ \ / _| / \ |_ \|_ _| ",0ah
BYTE " | |__) | / _ \ / .' \_| | \/ | / _ \ | \ | | ",0ah
BYTE " | ___/ / ___ \ | | | |\ /| | / ___ \ | |\ \| | ",0ah
BYTE " _| |_ _/ / \ \_\ `.___.'\ _| |_\/_| |_ _/ / \ \_ _| |_\ |_ ",0ah
BYTE " |_____||____| |____|`.____ .'|_____||_____||____| |____||_____|\____| ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " 1. START GAME ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " 2. SHOW INSTRUCTIONS ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " 3. SHOW HIGH SCORE ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " 4. EXIT GAME ",0ah
BYTE " ",0
Pausemenu BYTE " ",0ah
BYTE " _______ _ ______ ____ ____ _ ____ _____ ",0ah
BYTE " |_ __ \ / \ .' ___ ||_ \ / _| / \ |_ \|_ _| ",0ah
BYTE " | |__) | / _ \ / .' \_| | \/ | / _ \ | \ | | ",0ah
BYTE " | ___/ / ___ \ | | | |\ /| | / ___ \ | |\ \| | ",0ah
BYTE " _| |_ _/ / \ \_\ `.___.'\ _| |_\/_| |_ _/ / \ \_ _| |_\ |_ ",0ah
BYTE " |_____||____| |____|`.____ .'|_____||_____||____| |____||_____|\____| ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " 1. CONTINUE ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " 2. SHOW INSTRUCTIONS ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " 3. EXIT GAME ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " ",0
INSTRUCTIONS BYTE " ",0ah
BYTE " ___ _ _ ____ _____ ____ _ _ ____ _____ ___ ___ _ _ ____ ",0ah
BYTE " |_ _| \ | / ___|_ _| _ \| | | |/ ___|_ _|_ _/ _ \| \ | / ___| ",0ah
BYTE " | || \| \___ \ | | | |_) | | | | | | | | | | | | \| \___ \ ",0ah
BYTE " | || |\ |___) || | | _ <| |_| | |___ | | | | |_| | |\ |___) | ",0ah
BYTE " |___|_| \_|____/ |_| |_| \_\\___/ \____| |_| |___\___/|_| \_|____/ ",0ah
BYTE " ",0ah
BYTE " ",0ah
BYTE " Movement : Move LEFT [A] Move RIGHT [D] ",0ah
BYTE " ",0ah
BYTE " Move UP [W] Move DOWN [S] ",0ah
BYTE " ",0ah
BYTE " Collect All Dots to Advance to next Level . With Increase in every Level Diffculty Increases ",0ah
BYTE " ",0ah
BYTE " LEVEL1 : Most Easy Level with Simple Ghost that just move around Randomly and do not Follow Player ",0ah
BYTE " ",0ah
BYTE " LEVEL2 : Ghost Become Fast and Follow Player if Player come in there Line of Sight . Fruit[o] will Spawn ",0ah
BYTE " Randomly. Collect them to get more Points ",0ah
BYTE " ",0ah
BYTE " LEVEL3 : ALmost Same as Level 2 but new type of Ghost are Introduced which will follow player even more ",0ah
BYTE " Faster and Teleport after some time to a Position near to Player ",0ah
BYTE " ",0ah
BYTE " ",0
HIGHSCORE BYTE " ",0ah
BYTE " ",0ah
BYTE " __ __ __ _______ __ __ _______. ______ ______ .______ _______ ",0ah
BYTE " | | | | | | / _____|| | | | / | / | / __ \ | _ \ | ____| ",0ah
BYTE " | |__| | | | | | __ | |__| | | (----`| ,----'| | | | | |_) | | |__ ",0ah
BYTE " | __ | | | | | |_ | | __ | \ \ | | | | | | | / | __| ",0ah
BYTE " | | | | | | | |__| | | | | | .----) | | `----.| `--' | | |\ \----.| |____ ",0ah
BYTE " |__| |__| |__| \______| |__| |__| |_______/ \______| \______/ | _| `._____||_______| ",0ah
BYTE " ",0ah
BYTE " ",0
;---------------- LEVEL 1
GameMaze1 BYTE" ---------------------------------------------------------------------------------------------------------------------",0ah
BYTE " |. . . . . . . . . . . . . . . . . . . . . . . . ||||||||||||||| . .|",0ah
BYTE " |.|||.|||||||||||||||||||||.||||||||||||||||||||||||||||||.|||||||||||||||.|||.|||||||||.|||. . . . . . . . .|||||| |",0ah
BYTE " |. . . . . . . . . . . . . . . . . . . . . . . |||.||||||||||||||||| . .|",0ah
BYTE " ||||| |||.||||.||||||||||||||||.||||||||||||.||||||||| |||||||||.|||.||||||||| ||||||||| . . . . . . .|||| |",0ah
BYTE " | .||| |||| ||| |||. .|||||||||||| |||||| |||||| ||| . . . . . |||.|||||||||||||||||. |",0ah
BYTE " ||||| |||.||||.||| ||| ||| . . |||. . ||| ||||||.|||.|||||||||||||||||||.|||. . . . . . . . . .||||||",0ah
BYTE " |. .||| |||| ||| |||.|||.|||||||||||||||.|||||||||||||||| |||.|| . . . . . . ||||||| |||||||||. .|",0ah
BYTE " | |||.|||.||||.||| ||| . ||| . . . . . . . . . .||||||||||||||||.|||. . . . . |||| |",0ah
BYTE " |.||| ||| |||| ||||||||||||||||.||||||||||||.|||||||.||||||||.|||.||||||||||||||||||||||. .||||||||||||||||| ||||.|",0ah
BYTE " |. . . . . . . . . . . . |||||||. . . . .X||| . . . . . . |||.|||||||||||||||||.|||| |",0ah
BYTE " ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| . . |||||||||||||||||||||| . . . . . . .|",0ah
BYTE " --------------------------------------------------------------------------------------------------------------------- ",0
GameMaze2 BYTE " ---------------------------------------------------------------------------------------------------------------------",0ah
BYTE " |. .|||.||||||||. . .||||||||||||||. . . . . |||||||||||||| + |||||||||||||. . .|||||||||| |||||||||||",0ah
BYTE " | ||| . . . |||. . . . |||||| |||||||||.||||||||| . .|||. . . . |||. . . || . +|||||",0ah
BYTE " |.|||.|||.|||||||||||| ||||||||||||||. . . . . . . .||||||||||||||||||.||||||||||||.||||||||||||||.|||||",0ah
BYTE " | ||| ||| ||| |||. .||||||||||||||||| ||||||||| |||||||||. . . . . . ||||||||.|| . . . ||",0ah
BYTE " |.|||.|||.||| ||| |||. . + |||. . ||||| |||||| ||||||||||||||||||||||. . . . . |||| |||||| |||||",0ah
BYTE " | ||| ||| ||| |||.||| |||||||||||||||.||||||| ||||||.||||||. . . . .||||||||.|||||||. . .||||",0ah
BYTE " |.|||.|||.||| ||| . .|||. . . . |||||||||||||||||| . . |||||||||||||||. . . . . || |||| ||||",0ah
BYTE " | ||| ||| ||||||||||||.||||||||||||||.|||||||.||||||||||||||||||||| ||||||||||||||||||| ||||||||||||||||||| ||||.||||",0ah
BYTE " |. + .|||. . . . . . . . . . .||||. . . |||||. . . . . .||||. . . |||. . . .|",0ah
BYTE " | ||| . ||||||||||||||||.||||||.|||||||||||. . ||||.|||||X . .||| |||||||||||||||. . . |||.||||||.||||||||||| |",0ah
BYTE " |.|||.|||.||||||. .||| |||||| ||||||||||| ||||||||| ||||| ||||| |||. . .|||||||||.|||||||| ||||||.||||||||. .|",0ah
BYTE " | . |||. . |||||. .||||||. . . .|||||||||. . .|||||.|||||||| . . . . . . . . . .||||",0ah
BYTE " --------------------------------------------------------------------------------------------------------------------- ",0
GameMaze3 BYTE " ---------------------------------------------------------------------------------------------------------------------",0ah
BYTE " |. . . .|||||||||||||||||||| . |||||||||||||||||. . + .||||||||||||||||||||||||||||||||||||||||||||||| . .|",0ah
BYTE " |.|||||||||||. . . .|||. . . . |||||||||| |||||. . . . . . . . . . . . . .|||||| |",0ah
BYTE " |. . + . .||| |||||||.|||.||.|| |||||||. . . . . ||||| |||||||||||||||||||| || |||||||| || ||||| . .|",0ah
BYTE " |||||||.|||||. .|||||||.||| || ||. . .|| |||||||||| ||||||||||| ||||||||||||||||||||.|| |||||||| ||.|||||.||.|||||",0ah
BYTE " |. . . .||| . .|||.||.|| |||| || ||||| ||||||. . . . . . || + || ||||| || |",0ah
BYTE " ||| |||||||||.|||.||||| |. . ||.||||.||.|||||||||||||||||||||| ||||||||||||||||||||.||||||||||||||.|||||.||.|||||",0ah
BYTE " ||| |||||||||.||| ||.||.|||||||.||| ||||. . . . . . . . . . . . . . . . . . . . . |",0ah
BYTE " |. . . . .|| || |||||||.|||.|||| ||||| ||||| ||||||||||||| ||||||||||||||||||||||||||| ||| ||||.|||||||||||.|",0ah
BYTE " | |||||||||||||||.||. . . ||| ||||.|| . . ||. . . .|. . . . ||. . . ||| |||| ||| . . |",0ah
BYTE " |. . . . || || ||||||||||||||.|||| . |||||.|| ||||||||X||||.|||||||| |||||||| |||.||||||||| ||||.|||.|||||||.|",0ah
BYTE " | ||||||||||||.||. . . . . . || . . .||| . . . . . . . .|||. . . . ||| ||||||| |",0ah
BYTE " |.|||||||||||| + ||||||||||. . ||||||||.||||||||||| |||||||||||||.|||||||||||||||||.||||||||||||||||||. . . +|",0ah
BYTE " --------------------------------------------------------------------------------------------------------------------- ",0
GameMaze BYTE 1700 DUP(?)
ground BYTE "------------------------------------------------------------------------------------------------------------------------",0
TotalPLayerLifes DWORD 3
level WORD 1
FruitSpawnTime DWORD 300
GhostEatenTimer DWORD 0 , 0, 0 ,0 ,0
GhostEaten DWORD 0
NoOfGhost DWORD 3
GhostMovementKey DWORD 0 , 0 , 0 , 0 , 0
GhostsIndexInGameMaze DWORD 650 ,650 ,650 ,650 , 769
GhostIndexPreviousData BYTE " " , " " ," " , " " , " "
GhostMovementTimer DWORD 0 , 0 , 0 , 0 , 0
DefaultGhostPosition DWORD 650
GhostChar db "G"
AdvancedGhostMovementTimer DWORD 0 , 0
AdvancedGhostPosition DWORD 121 , 235
AdvancedGhostMovementKey DWORD 0 , 0
AdvancedGhostPreviousData BYTE " ", " "
AdvancedChar BYTE "#"
AdvancedTelportTime DWORD 300 , 500
strScore BYTE "SCORE : ",0
score DWORD 0
PlayerIndexInGameMaze DWORD 1252
DefaultPlayerIndexInGameMaze DWORD 1252
MaxMazeIndexSize DWORD 1546
TotalNumberOfDotinMap DWORD 313
GameMazeLength DWORD 1546 , 1666 , 1666
TotalNumberOfDots DWORD 313 , 298 , 321
player BYTE "X" , 0
PowerUp BYTE 0
PowerUpTimer DWORD 0
EndGame BYTE 0
PromptLostLive db "You Lost A live" , 0
PromptEnterKey db "Press ENTER to Continue" , 0
PromptPoweUp db "PowerUp" , 0
PromptHeading BYTE "PAC-MAN" , 0
PromptStartGame BYTE "1 . START GAME" , 0
PromptDies BYTE "!YOU DIED!" , 0
PromptGameEnd BYTE "Game END" , 0
PromptEnterName BYTE "Enter You Name" , 0
PromptLevelFinished BYTE "!LEVEL COMPLETED!" , 0
PromptGameWon BYTE "CONGRATULATION! YOU WON" , 0
Continue DB 255 DUP(0)
continueChar BYTE ?
inputChar BYTE ?
Timer DWORD 0
SpacetohideContent db " " , 0
PlayerName BYTE 255 DUP(0)
File BYTE "score.txt" , 0
buffer BYTE BUFFER_SIZE DUP(?)
fileHandle HANDLE ?
lengthofData DWORD 0
buffer2 BYTE BUFFER_SIZE2 DUP(?)
buffer2size DWORD 0
AlreadyExistPlayer BYTE 0
AlreadyExistPlayerIndex DWORD 0
StartChecking BYTE 1
Swap BYTE 0
mainindex1 DWORD 0
mainindex2 DWORD 0
index1 DWORD 0
index2 DWORD 0
Score1 DWORD 0
Score2 DWORD 0
StartSound db 'E:\Programming\COAL\Projects\Irvine_Template\sounds\pacman_beginning.wav' , 0
deathSound db 'E:\Programming\COAL\Projects\Irvine_Template\sounds\pacman_death.wav' , 0
FruitSound db 'E:\Programming\COAL\Projects\Irvine_Template\sounds\pacman_eatfruit.wav' , 0
wakawakaSound db 'E:\Programming\COAL\Projects\Irvine_Template\sounds\pac-man-waka-waka.wav' , 0
PlaySound PROTO,
pszSound:PTR BYTE,
hmod:DWORD,
fdwSound:DWORD
SND_LOOP equ 8 ; Define the loop flag value
.code
ResetAllVariable PROC
mov TotalPLayerLifes ,3
mov level , 1
mov FruitSpawnTime , 300
mov GhostEatenTimer[0] , 0
mov GhostEatenTimer[4] , 0
mov GhostEatenTimer[8] , 0
mov GhostEatenTimer[12] , 0
mov GhostEatenTimer[16] , 0
mov GhostEaten , 0
mov NoOfGhost , 3
mov GhostMovementKey[0] , 0
mov GhostMovementKey[4] , 0
mov GhostMovementKey[8] , 0
mov GhostMovementKey[12] , 0
mov GhostMovementKey[16] , 0
mov GhostsIndexInGameMaze[0] , 650
mov GhostsIndexInGameMaze[4] , 650
mov GhostsIndexInGameMaze[8] , 650
mov GhostsIndexInGameMaze[12] , 650
mov GhostsIndexInGameMaze[16] , 650
mov GhostIndexPreviousData[0] , " "
mov GhostIndexPreviousData[1] , " "
mov GhostIndexPreviousData[2] , " "
mov GhostIndexPreviousData[3] , " "
mov GhostIndexPreviousData[4] , " "
mov GhostMovementTimer[0] , 0
mov GhostMovementTimer[4] , 0
mov GhostMovementTimer[8] , 0
mov GhostMovementTimer[12] , 0
mov GhostMovementTimer[16] , 0
mov DefaultGhostPosition , 650
mov GhostChar , "G"
mov AdvancedGhostMovementTimer[0] , 0
mov AdvancedGhostMovementTimer[4] , 0
mov AdvancedGhostPosition[0] , 121
mov AdvancedGhostPosition[4] , 235
mov AdvancedGhostMovementKey[0] , 0
mov AdvancedGhostMovementKey[4] , 0
mov AdvancedGhostPreviousData[0] ," "
mov AdvancedGhostPreviousData[1] ," "
mov AdvancedChar , "#"
mov AdvancedTelportTime[0] , 300
mov AdvancedTelportTime[4] , 500
mov score , 0
mov PlayerIndexInGameMaze , 1252
mov DefaultPlayerIndexInGameMaze ,1252
mov MaxMazeIndexSize , 1546
mov TotalNumberOfDotinMap , 313
mov PowerUp , 0
mov PowerUpTimer , 0
mov Timer , 0
mov EndGame , 0
ret
ResetAllVariable ENDP
main PROC
mov eax,White +(Black*16)
call SetTextColor
call clrscr
MainMenu:
INVOKE PlaySound, OFFSET StartSound, NULL , 11h
mov dl,0 ;Col
mov dh,1
call gotoxy
mov eax , lightMagenta + (black * 16)
call setTextColor
mov edx , offset GameMenu
call WriteString
mov eax , 0
call readchar
cmp al , 50
jne no_ins_Called
call show_instruction
mov eax , 0
no_ins_Called:
cmp al , 49
je start_Game
cmp al , 51
jne no_score_called
call ShowHighScore
no_score_called:
jmp exitGame2
start_Game:
call clrscr
mov dl , 50
mov dh , 13
call gotoxy
mov edx , offset PromptEnterName
call writeString
mov eax , white + (black * 16)
call SetTextColor
mov dl , 54
mov dh , 15
call gotoxy
mov edx , offset PlayerName
mov ecx , 255
call readString
;setting up initial Maze for level 1
mov esi ,0
mov ecx , 0
mov bl , "."
count:
mov al , GameMaze1[esi]
mov GameMaze[esi] , al
inc esi
cmp GameMaze1[esi] , 0
jne count
mov al , 0
mov GameMaze[esi] , al
gameLoop:
inc Timer
;--------------- LEVEL Management
mov ax , level
cmp ax , 1
jne Check_Level2
PUSH offset GhostIndexPreviousData
PUSH offset GhostsIndexInGameMaze
PUSH offset PlayerIndexInGameMaze
PUSH offset TotalPLayerLifes
PUSH offset GhostChar
PUSH offset TotalNumberOfDots
PUSH offset GameMazeLength
PUSH offset NoOfGhost
PUSH offset level
PUSH offset TotalNumberOfDotinMap
PUSH offset score
call Level1
Check_Level2:
cmp ax , 2
jne Check_Level3
PUSH offset GhostIndexPreviousData
PUSH offset GhostsIndexInGameMaze
PUSH offset PlayerIndexInGameMaze
PUSH offset TotalPLayerLifes
PUSH offset FruitSpawnTime
PUSH offset TotalNumberOfDots
PUSH offset GameMazeLength
PUSH offset NoOfGhost
PUSH offset level
PUSH offset TotalNumberOfDotinMap
PUSH offset score
call Level2
Check_Level3:
cmp ax , 3
jne Check_end_Game
PUSH offset AdvancedGhostMovementTimer
PUSH offset AdvancedTelportTime
PUSH offset AdvancedChar
PUSH offset GhostChar
PUSH offset PlayerIndexInGameMaze
PUSH offset AdvancedGhostPosition
PUSh offset AdvancedGhostPreviousData
PUSH offset GameMaze
call AdvancedGhostMovement
PUSH offset AdvancedGhostPreviousData
PUSH offset AdvancedGhostPosition
PUSH offset TotalPLayerLifes
PUSH offset NoOfGhost
PUSH offset GameMaze
PUSH offset GhostMovementKey
PUSH offset GhostsIndexInGameMaze
PUSH offset GhostIndexPreviousData
PUSH offset PlayerIndexInGameMaze
call AdvancedGhostPlayerCollision
PUSH offset EndGame
PUSH offset GameMaze
call Level3
Check_end_Game:
call DrawMaze
;-------------- draw score:
mov eax,lightCyan+(black * 16)
call SetTextColor
mov dl,53
mov dh,3
call Gotoxy
mov edx,OFFSET strScore
call WriteString
mov eax,score
call WriteInt
;--------------cheking if player dies
cmp EndGame , 1
jne no_game_end
jmp show_game_end
no_game_end:
cmp TotalPLayerLifes , 0
jne not_dead
mov dl , 51
mov dh , 13
call gotoXY
mov eax , white + (black * 16)
mov edx , offset PromptDies
call writeString
show_game_end:
mov dl , 52
mov dh , 14
call gotoXY
mov edx , offset PromptGameEnd
call writeString
mov dl , 44
mov dh , 15
call gotoXY
mov edx , offset PromptEnterKey
call writeString
PUSH offset level
PUSH offset PlayerName
PUSH offset score
call SavePlayerData
mov eax , 0
continue_loop:
mov eax , 0
call readchar
cmp al , 13
jne continue_loop
call ResetAllVariable
jmp exitGame
not_dead:
;--------------- Draw Lives
mov eax , white + (Black * 16)
call setTextColor
mov ecx , 2
mov ebx , TotalPLayerLifes
mov al , 3
DrawLives:
mov dl, al
mov dh, 22
call Gotoxy
mov edx , offset player
call WriteString
add al , 3
dec ebx
cmp ebx , 0
jne DrawLives
mov dl, 3
mov dh, 29
call Gotoxy
;---------------Fruit Spawn
mov eax , 1
cmp level , 1
je no_fruit_spawn
PUSH offset MaxMazeIndexSize
PUSH offset FruitSpawnTime
PUSH offset GameMaze
call FruitSpawnRandom
no_fruit_spawn:
;---------------Working with eaten Ghost Due to Power Up
cmp GhostEaten , 0
je no_eaten_ghost
PUSH offset NoOfGhost
PUSH offset GhostEatenTimer
PUSH offset GhostEaten
call SpawningEatenGhost
no_eaten_ghost:
;---------------Power Up Working
mov al , 1
cmp PowerUp , 1
jne no_Power_up
PUSH NoOfGhost
PUSH offset PowerUp
PUSH offset PowerUpTimer
call PowerUpWorking
no_Power_up:
;---------------Ghost Working And Movement / Collision
PUSH offset GhostMovementTimer
PUSH offset AdvancedChar
PUSH offset PowerUp
PUSH offset GhostChar
PUSH offset GhostsIndexInGameMaze
PUSh offset GhostIndexPreviousData
PUSH offset NoOfGhost
PUSH offset GameMaze
call GhostMovement
mov eax , 1
cmp PowerUp , al
je power_up_on
PUSH offset TotalPLayerLifes
PUSH offset NoOfGhost
PUSH offset GameMaze
PUSH offset GhostMovementKey
PUSH offset GhostsIndexInGameMaze
PUSH offset GhostIndexPreviousData
PUSH offset PlayerIndexInGameMaze
call CheckPlayerGhostCollision
jmp power_up_off
power_up_on:
PUSH offset score
PUSH offset GhostEatenTimer
PUSH offset GhostEaten
PUSH offset NoOfGhost
PUSH offset GameMaze
PUSH offset GhostMovementKey
PUSH offset GhostsIndexInGameMaze
PUSH offset GhostIndexPreviousData
PUSH offset PlayerIndexInGameMaze
call CheckPLayerEatGhost
power_up_off:
;-------------- get user key input
call ReadKey
mov inputChar,al
;-------------- exit game if user types 'x'
cmp inputChar , "p"
jne no_pause
call PauseGame
cmp al , 51
je exitGame
no_pause:
cmp inputChar,"x"
je exitGame
;--------------Check for Player Movement Key Pressed(W A S D)
cmp inputChar,"w"
je moveUp
cmp inputChar,"s"
je moveDown
cmp inputChar,"a"
je moveLeft
cmp inputChar,"d"
je moveRight
jmp afterMoveMent
moveUp:
PUSH offset PowerUpTimer
PUSH offset PowerUp
PUSH PlayerIndexInGameMaze
PUSH offset GameMaze
PUSH offset score
call MovePlayerUp
jmp afterMoveMent
moveDown:
PUSH offset PowerUpTimer
PUSH offset PowerUp
PUSH PlayerIndexInGameMaze
PUSH offset GameMaze
PUSH offset score
call MovePlayerDown
jmp afterMoveMent
moveLeft:
PUSH offset PowerUpTimer
PUSH offset PowerUp
PUSH PlayerIndexInGameMaze
PUSH offset GameMaze
PUSH offset score
call MovePlayerLeft
jmp afterMoveMent
moveRight:
PUSH offset PowerUpTimer
PUSH offset PowerUp
PUSH PlayerIndexInGameMaze
PUSH offset GameMaze
PUSH offset score
call MovePlayerRight
jmp afterMoveMent
;-------------------- Default Game Flow After checking Movement Key
afterMoveMent:
mov eax,40
call Delay
jmp gameLoop
exitGame:
call clrscr
exitGame2:
cmp al , 52
jne MainMenu
exit
main ENDP
SortBuffer PROC
;First Move to second Player start them compare
sort_untill_no_swap:
mov swap , 0
mov StartChecking , 0
mov esi , 0
mov edi , 0
move_to_scnd_player_name:
inc edi
cmp buffer2[edi] , 0ah
jne move_to_scnd_player_name
inc edi
keep_swaping:
mov mainindex1 , esi
mov mainindex2, edi
mov eax , esi
mov ebx , edi
find_score1: ;going to index where player Score end on File Buffer of index esi
inc eax
cmp buffer2[eax] , 0dh
jne find_score1
dec eax
mov index1 , eax
find_score2: ;going to index where player Score end on File Buffer index edi
inc ebx
cmp buffer2[ebx] , 0dh
jne check_null
jmp out_loop
check_null:
cmp buffer2[ebx] , 0
jne find_score2
out_loop:
dec ebx
mov index2 , ebx
mov esi , index1
mov ebx , 0
mov bx , 1
mov ecx , 0
mov eax , 0
get_score: ;getting Player Score and converting from String to intergers
mov al , Buffer2[esi]
sub al , 48
cmp al , 0
mul bx
add ecx, eax
mov eax , ebx
mov bx , 10
mul bx
mov ebx , eax
dec esi
cmp Buffer2[esi] , 32
jne get_score
mov Score1 , ecx
mov esi , index2
mov ebx , 0
mov bx , 1
mov ecx , 0
mov eax , 0
get_score1: ;getting Player Score and converting from String to intergers
mov al , Buffer2[esi]
sub al , 48
mul bx
add ecx, eax
mov eax , ebx
mov bx , 10
mul bx
mov ebx , eax
dec esi
cmp Buffer2[esi] , 32
jne get_score1
mov Score2 , ecx
cmp Score1 , ecx
ja no_swap
mov swap , 1
mov esi , mainindex1 ;Move First Player data to temp
mov edi , 0
move_buffer_to_temp:
mov al , buffer2[esi]
mov buffer[edi] , al
inc esi
inc edi
cmp buffer2[esi-1] , 0Ah
jne move_buffer_to_temp
mov buffer[edi] , 0
mov esi , mainindex1 ;Swap Second Player with First Player
mov edi , mainindex2
swapData:
mov al , buffer2[edi] ;Take Second Player Data
mov buffer2[esi] , al ;Move to First Player
inc edi
inc esi
cmp buffer2[edi] , 0
jne keep_loop
mov StartChecking , 1
jmp out_loop1
keep_loop:
cmp buffer2[edi-1] , 0ah
jne swapData
out_loop1:
cmp StartChecking , 1
jne no_end
mov al , 0dh
mov buffer2[esi] ,al
inc esi
mov al , 0ah
mov buffer2[esi] ,al
inc esi
no_end:
mov edx , esi
mov edi , 0
move_temp_to_buffer:
mov al , buffer[edi]
mov buffer2[esi] , al
inc esi
inc edi
cmp buffer[edi] , 0
jne move_temp_to_buffer
cmp StartChecking , 1
jne no_end1
dec esi
mov al , 0
mov buffer2[esi] , al
dec esi
mov buffer2[esi] , al
no_end1:
mov esi , edx
jmp out_condition3
no_swap:
mov esi , index1
add esi , 3
out_condition3:
mov edi , index2
cmp buffer2[edi+1] , 0
je out_condition
add edi , 3
cmp buffer2[edi] , 0
jne keep_swaping
out_condition:
cmp swap ,1
je sort_untill_no_swap
ret
SortBuffer ENDP
SavePlayerData PROC
PUSH ebp
mov ebp , esp
;[ebp + 16] == level
;[ebp + 12] == PlayerName
;[ebp + 8] == score
mov ecx , [ebp + 12]
mov ebx , 0
mov bh , 0
mov esi , 0
copy_untill_end:
mov bl , [ecx + esi]
mov buffer[esi] , bl
inc esi
cmp [ecx + esi] , bh
jne copy_untill_end
mov edi , esi
add edi , 4
mov bh , " "
copy_space:
mov buffer[esi] , bh
inc esi
cmp esi , edi
jne copy_space
;COMMENT @
mov ecx , [ebp + 16]
mov bx , [ecx]
add bl , 48
mov buffer[esi] , bl
inc esi
mov edi , esi
add edi , 4
mov bh , " "
copy_space1:
mov buffer[esi] , bh
inc esi
cmp esi , edi
jne copy_space1
;Convert Score into String
mov edx , offset buffer
mov ecx , [ebp + 8]
mov eax , [ecx]
cmp eax , 10
jnb not_below_10
add eax , 48
mov buffer[esi] , al
inc esi
jmp out_condition
not_below_10:
cmp eax , 100
jnb no_below_100
mov bl , 10
div bl
add al , 48
mov buffer[esi] , al
inc esi
add ah , 48
mov buffer[esi] , ah
inc esi
jmp out_condition
no_below_100:
cmp eax , 1000
jnb no_below_1000
add esi , 2
mov bl , 10
div bl
add ah , 48
mov buffer[esi] , ah
dec esi
movzx eax , al
div bl
add ah , 48
mov buffer[esi] , ah
dec esi
add al , 48
mov buffer[esi] , al
add esi , 3
jmp out_condition
no_below_1000:
add esi , 3
mov bl , 10
div bl
add ah , 48
mov buffer[esi] , ah
dec esi
movzx eax , al
div bl
add ah , 48
mov buffer[esi] , ah
dec esi
movzx eax , al
div bl
add ah , 48
mov buffer[esi] , ah
dec esi
add al , 48
mov buffer[esi] , al
add esi , 4
jmp out_condition
out_condition:
mov buffer[esi] , 0
mov lengthofData , esi
mov edx , offset File
call OpenInputFile
mov fileHandle , eax
mov edx , offset buffer2
mov ecx , BUFFER_SIZE2
call ReadFromFile
mov buffer2[eax] , 0
mov buffer2size , eax
mov eax , FileHandle
call CloseFile
;Checking if Player Aleady Exist
mov esi , 0
mov edi , 0
mov eax , esi
keep_comparing:
cmp startChecking , 1
jne dont_check
mov dl , PlayerName[edi]
cmp buffer2[esi] , dl
je char_are_equal
mov startChecking , 0
mov edi , 0
jmp dont_check
char_are_equal:
inc edi
cmp PlayerName[edi] , 0
jne no_player_name_end
mov AlreadyExistPlayer , 1