-
Notifications
You must be signed in to change notification settings - Fork 0
/
mario.asm
1313 lines (1216 loc) · 30.2 KB
/
mario.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
; clear the screen
[org 0x0100]
jmp start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
jumpDelay:
push cx
push ax
mov al, 0x00
in al, 0x60 ; read a char from keyboard port
cmp al, 0x1E
jne notDelayLeft
call clearMario
sub word [cs:marioLocation],2
call detectCoinSackOne
call detectCoinSackTwo
call detectCoinSackThree
call detectCollision
cmp word [cs:locationCheckFlag], 1
jne leftCollisionNotDetectedInDelay
mov word [cs:locationCheckFlag],0
call clearMario
add word [cs:marioLocation],2
leftCollisionNotDetectedInDelay:
notDelayLeft:
cmp al, 0x20
jne notDelayRight
call clearMario
add word [cs:marioLocation],2
call detectCoinSackOne
call detectCoinSackTwo
call detectCoinSackThree
call detectCollision
cmp word [cs:locationCheckFlag], 1
jne RightCollisionNotDetectedInDelay
mov word [cs:locationCheckFlag],0
call clearMario
sub word [cs:marioLocation],2
RightCollisionNotDetectedInDelay:
notDelayRight:
mov cx, 0xffff
delayLoop:
loop delayLoop
pop ax
pop cx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
detectCollision:
push ax
push cx
push si
push bx
push dx
push di
push bp
mov dx, [cs:enemyOneLocation]
mov di, [cs:enemyTwoLocation]
add word dx,2
mov word [cs:enemyOneLocation+2], dx
add word dx,2
mov word [cs:enemyOneLocation+4], dx
add word dx,160
mov word [cs:enemyOneLocation+6], dx
sub word dx,2
mov word [cs:enemyOneLocation+8], dx
sub word dx,2
mov word [cs:enemyOneLocation+10], dx
add word dx,160
mov word [cs:enemyOneLocation+12], dx
add word dx,2
mov word [cs:enemyOneLocation+14], dx
add word dx,2
mov word [cs:enemyOneLocation+16], dx
add word di,2
mov word [cs:enemyTwoLocation+2], di
add word di,2
mov word [cs:enemyTwoLocation+4], di
add word di,160
mov word [cs:enemyTwoLocation+6], di
sub word di,2
mov word [cs:enemyTwoLocation+8], di
sub word di,2
mov word [cs:enemyTwoLocation+10], di
add word di,160
mov word [cs:enemyTwoLocation+12], di
add word di,2
mov word [cs:enemyTwoLocation+14], di
add word di,2
mov word [cs:enemyTwoLocation+16], di
mov ax, [cs:marioLocation]
add ax, 320
mov word [cs:marioLeftLegLocation], ax
mov word [cs:marioRightLegLocation], ax
add word [cs:marioRightLegLocation], 4
mov si, 0
mov bx, hurdleLocation
mov cx, 12
detectHurdlesLoop:
mov word ax, [cs:marioRightLegLocation]
cmp word ax, [bx+si]
je collisionDetected
mov word ax, [cs:marioLeftLegLocation]
cmp word ax, [bx+si]
je collisionDetected
add si, 2
loop detectHurdlesLoop
mov si, 0
mov di, 0
mov bx, enemyOneLocation
mov bp, enemyTwoLocation
mov cx, 9
detectEnemyLoop:
mov word ax, [cs:marioRightLegLocation]
cmp word ax, [bx+di]
je enemeyCollisionDetected
cmp word ax, [bp+si]
je enemeyCollisionDetected
mov word ax, [cs:marioLeftLegLocation]
cmp word ax, [bx+di]
je enemeyCollisionDetected
cmp word ax, [bp+si]
je enemeyCollisionDetected
add si, 2
add di,2
loop detectEnemyLoop
jmp endCollisionFunction
enemeyCollisionDetected:
mov byte [cs:marioLife], 0
jmp endCollisionFunction
collisionDetected:
mov word [cs:locationCheckFlag],1
endCollisionFunction:
pop bp
pop di
pop dx
pop bx
pop si
pop cx
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
delay:
push cx
mov cx, 0xffff
loopTimeDelay
loop loopTimeDelay
pop cx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
detectCoinSackOne:
push cx
cmp word [cs:coinSackOneCheck], 5
jae endDetectCoinSackOneFunction
mov word cx, [cs:marioLocation]
cmp word cx, 3216
je coinSackOneDetected
cmp word cx, 3218
je coinSackOneDetected
add cx, 4
cmp word cx, 3216
je coinSackOneDetected
cmp word cx, 3218
je coinSackOneDetected
jmp endDetectCoinSackOneFunction
coinSackOneDetected:
add word [cs:score], 5
add word [cs:coinSackOneCheck], 1
call clearMario
add word [cs:marioLocation], 160
call drawMario
endDetectCoinSackOneFunction
pop cx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
detectCoinSackTwo:
push cx
cmp word [cs:coinSackTwoCheck], 5
jae endDetectCoinSackTwoFunction
mov word cx, [cs:marioLocation]
cmp word cx, 3330
je coinSackTwoDetected
cmp word cx, 3332
je coinSackTwoDetected
add cx, 4
cmp word cx, 3330
je coinSackTwoDetected
cmp word cx, 3332
je coinSackTwoDetected
jmp endDetectCoinSackTwoFunction
coinSackTwoDetected:
add word [cs:score], 5
add word [cs:coinSackTwoCheck], 1
call clearMario
add word [cs:marioLocation], 160
call drawMario
endDetectCoinSackTwoFunction
pop cx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
detectCoinSackThree:
push cx
cmp word [cs:coinSackThreeCheck], 5
jae endDetectCoinSackThreeFunction
mov word cx, [cs:marioLocation]
cmp word cx, 2960
je coinSackThreeDetected
cmp word cx, 2962
je coinSackThreeDetected
add cx, 4
cmp word cx, 2960
je coinSackThreeDetected
cmp word cx, 2962
je coinSackThreeDetected
jmp endDetectCoinSackThreeFunction
coinSackThreeDetected:
add word [cs:score], 5
add word [cs:coinSackThreeCheck], 1
call clearMario
add word [cs:marioLocation], 160
call drawMario
endDetectCoinSackThreeFunction
pop cx
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Blue:
push es
push ax
push cx
push di
mov ax, 0xb800
mov es, ax ; point es to video base
xor di, di ; point di to top left column
mov ax, 0x3020 ; space char in normal attribute
mov cx, 2000 ; number of screen locations
cld ; auto increment mode
rep stosw ; clear the whole screen
pop di
pop cx
pop ax
pop es
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawBlueBorder:
pusha
mov ax, 0xb800
mov es, ax
mov di,0
startBorderUp:
mov word[es:di],0x1020
add di,2
cmp di,160
jne startBorderUp
mov di,3840
startBorderDown:
mov word[es:di],0x1020
add di,2
cmp di,4000
jne startBorderDown
mov di,318
startBorderRight:
mov word[es:di],0x1020
add di,160
cmp di,3998
jne startBorderRight
mov di,160
startBorderLeft:
mov word[es:di],0x1020
add di,160
cmp di,3840
jne startBorderLeft
mov di,316
startBorderRight1:
mov word[es:di],0x1020
add di,160
cmp di,3996
jne startBorderRight1
mov di,162
startBorderLeft2:
mov word[es:di],0x1020
add di,160
cmp di,3842
jne startBorderLeft2
popa
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
startScreen:
startGameScreen:
push ax
push dx
push es
push di
push si
;push 0x1020
call Blue
mov ax,0xb800
mov es,ax
mov di,0
call drawBlueBorder
;center box top bar
mov di,660
mov si,di
add si,120
nextchar1a:
mov word [es:di],0x6020
add di,2
cmp di,si
jne nextchar1a
mov di,820
mov si,di
add si,120
;center box main
nextchar1b:
mov word [es:di],0x0020
add di,2
cmp di,si
jne nextchar1b
add di,40
mov si,di
add si,120
cmp di,2000
jle nextchar1b
;print message
mov word ax, 1174
push ax ;location of string print
mov ax, 00001110b ;attribute byte
push ax
mov ax, screenOneMessageOne
push ax
mov ax, 27 ;message length
push ax
call printstr
;print message
mov word ax, 1014
push ax ;location of string print
mov ax, 00001111b ;attribute byte
push ax
mov ax, screenOneMessageTwo
push ax
mov ax, 22 ;message length
push ax
call printstr
;print message
mov word ax, 1334
push ax ;location of string print
mov ax, 00001111b ;attribute byte
push ax
mov ax, screenOneMessageThree
push ax
mov ax, 16 ;message length
push ax
call printstr
;print message
mov word ax, 1494
push ax ;location of string print
mov ax, 00001111b ;attribute byte
push ax
mov ax, screenOneMessageFour
push ax
mov ax, 18 ;message length
push ax
call printstr
;print message
mov word ax, 1654
push ax ;location of string print
mov ax, 00001111b ;attribute byte
push ax
mov ax, screenOneMessageFive
push ax
mov ax, 19 ;message length
push ax
call printstr
;print message
mov word ax, 1784
push ax ;location of string print
mov ax, 00001110b ;attribute byte
push ax
mov ax, screenOneMessageSix
push ax
mov ax, 56 ;message length
push ax
call printstr
pop si
pop di
pop es
pop dx
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
printstr:
push bp
mov bp, sp
push es
push ax
push cx
push si
push di
mov ax, 0xb800
mov es, ax ; point es to video base
mov di,[bp+10] ; point di to required location
mov si, [bp+6] ; point si to string
mov cx, [bp+4] ; load length of string in cx
mov ah, [bp+8] ; load attribute in ah
cld ; auto increment mode
nextcharprint:
lodsb ; load next char in al
stosw ; print char/attribute pair
loop nextcharprint ; repeat for the whole string
pop di
pop si
pop cx
pop ax
pop es
pop bp
ret 8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
printNumber:
push bp
mov bp, sp
push es
push ax
push bx
push cx
push dx
push di
mov ax, 0xb800
mov es, ax ; point es to video base
mov ax, [bp+4] ; load number in ax
mov bx, 10 ; use base 10 for division
mov cx, 0 ; initialize count of digits
nextdigit:
mov dx, 0 ; zero upper half of dividend
div bx ; divide by 10
add dl, 0x30 ; convert digit into ascii value
push dx ; save ascii value on stack
inc cx ; increment count of values
cmp ax, 0 ; is the quotient zero
jnz nextdigit ; if no divide it again
mov di, 180 ; point di to top left column
nextpos:
pop dx ; remove a digit from the stack
mov dh, 0x07 ; use normal attribute
mov [es:di], dx ; print char on screen
add di, 2 ; move to next screen location
loop nextpos ; repeat for all digits on stack
pop di
pop dx
pop cx
pop bx
pop ax
pop es
pop bp
ret 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
clearScreen: ; function to clear screen
push ax
push es
push di
mov ax, 0xb800 ; load video base in ax
mov es, ax ; point es to video base
mov di, 0 ; point di to top left column
nextchar:
mov word [es:di], 0x0720 ; clear next char on screen
add di, 2 ; move to next screen location
cmp di, 4000 ; has the whole screen cleared
jne nextchar ; if no clear next position
pop di
pop es
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawHurdles: ;function to draw hurdles
push ax
push es
push si
push di
push bx
push cx
mov ax, 0xb800 ; load video base in ax
mov es, ax ; point es to video base
mov al, 0x2E
mov ah, 00101010b
mov word cx, 12
mov bx, hurdleLocation
mov si, 0
drawHurdlesLoop:
mov word di, [bx+si]
mov word [es:di], ax
add si, 2
loop drawHurdlesLoop
pop cx
pop bx
pop di
pop si
pop es
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawMario: ;function to draw superMario
push es
push di
push ax
mov di, [marioLocation]
mov ax, 0xb800
mov es, ax
mov al, 0x2A ;eyes
mov ah, 11000001b
mov word[es:di], ax
add di, 4
mov word[es:di], ax
mov al, 0x2E
mov ah, 01000000b
sub di, 2
mov word[es:di], ax ;nose
mov ah, 01000100b
add di, 160
mov word[es:di], ax
add di, 158
mov word[es:di], ax
add di, 4
mov word[es:di], ax
pop ax
pop di
pop es
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
clearMario: ;function to clear mario
push es
push di
push ax
mov di, [marioLocation]
mov ax, 0xb800
mov es, ax
mov word[es:di], 0x0720
add di, 4
mov word[es:di], 0x0720
sub di, 2
mov word[es:di], 0x0720 ;nose
add di, 160
mov word[es:di], 0x0720
add di, 158
mov word[es:di], 0x0720
add di, 4
mov word[es:di], 0x0720
pop ax
pop di
pop es
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
enemyMovement: ;function to move enemies to and fro
inc byte[cs:enemyMovementDelay]
cmp byte[cs:enemyMovementDelay],5
jne enemyMovementDone
mov byte [cs:enemyMovementDelay],1
cmp byte[cs:enemyMovementDirectionFlag],1
je enemyMoveReverse
push word [cs:enemyOneLocation]
call clearEnemy
push word [cs:enemyTwoLocation]
call clearEnemy
sub word[cs:enemyTwoLocation],2
add word[cs:enemyOneLocation],2
cmp word[enemyOneLocation], 3592
jne enemyMovementDone
mov byte [cs:enemyMovementDirectionFlag],1
jmp enemyMovementDone
enemyMoveReverse:
push word [cs:enemyOneLocation]
call clearEnemy
push word [cs:enemyTwoLocation]
call clearEnemy
add word[cs:enemyTwoLocation],2
sub word[cs:enemyOneLocation],2
cmp word[enemyOneLocation], 3566
jne enemyMovementDone
mov byte [cs:enemyMovementDirectionFlag],0
enemyMovementDone:
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawEnemy: ;function to draw enemy
push bp
mov bp, sp
push es
push di
push ax
mov ax, 0xb800
mov es, ax
mov word di, [bp+4]
mov al, 0x30
mov ah, 0000110b
mov word [es:di], ax
add word di, 4
mov word [es:di], ax
sub word di, 2
add word di, 160
mov al, 0x5E
mov word [es:di], ax
pop ax
pop di
pop es
pop bp
ret 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
clearEnemy: ;function to clear enemy
push bp
mov bp, sp
push es
push di
push ax
mov ax, 0xb800
mov es, ax
mov word di, [cs:bp+4]
mov word [es:di], 0x0720
add word di, 4
mov word [es:di], 0x0720
sub word di, 2
add word di, 160
mov word [es:di], 0x0720
pop ax
pop di
pop es
pop bp
ret 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawMonster: ;function to draw the monster
push di
push ax
push es
;(-_(-_(-_(-_-)_-)_-)_-)
mov di, [cs:monsterLocation] ;00000100 red
mov ax, 0xb800 ;00001110 yellow
mov es, ax ;0x28 (
;0x29 )
mov ah, 00000011b
mov al, 0x28
mov word [es:di], ax
add word di, 6
mov word [es:di], ax
add word di, 6
mov word [es:di], ax
add word di, 6
mov ah, 00001111b
mov word [es:di], ax
mov al, 0x29
add word di, 8
mov word [es:di], ax
mov ah, 00000011b
add word di, 6
mov word [es:di], ax
add word di, 6
mov word [es:di], ax
add word di, 6
mov word [es:di], ax
add word di, 6
mov word [es:di], ax
sub word di, 2
mov al, 0x2D
mov ah, 00000100b
mov word [es:di], ax
sub word di, 6
mov word [es:di], ax
sub word di, 6
mov word [es:di], ax
sub word di, 6
mov word [es:di], ax
mov ah, 10000100b
sub word di, 6
mov word [es:di], ax
sub word di, 4
mov word [es:di], ax
mov ah, 00000100b
sub word di, 6
mov word [es:di], ax
sub word di, 6
mov word [es:di], ax
sub word di, 6
mov word [es:di], ax
add word di, 2
mov ah, 00001110b
mov al,0x5F
mov word [es:di], ax
add word di, 6
mov word [es:di], ax
add word di, 6
mov word [es:di], ax
add word di, 6
mov ah, 00001111b
mov word [es:di], ax
mov ah, 00001110b
add di, 6
mov word [es:di], ax
add word di, 6
mov word [es:di], ax
add word di, 6
mov word [es:di], ax
add word di, 6
mov word [es:di], ax
pop es
pop ax
pop di
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
clearMonsterLine: ;function clears the monster
push ax
push es
push di
push cx
mov ax, 0xb800 ; load video base in ax
mov es, ax ; point es to video base
mov di, [cs:monsterLocation]
mov word cx, 26
nextMonsterChar:
mov word [es:di], 0x0720 ; clear next char on screen
add di, 2 ; move to next screen location
loop nextMonsterChar ; if no clear next position
pop cx
pop di
pop es
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
monsterMovement: ;function moves the monster to and fro
inc byte[cs:monsterMovementDelay]
cmp byte[cs:monsterMovementDelay],3
jne monsterMovementDone
mov byte[cs:monsterMovementDelay],1
cmp byte[cs:monsterMovementDirectionFlag],1
je monsterMoveReverse
call clearMonsterLine
add word[cs:monsterLocation],2
cmp word[cs:monsterLocation], 424
jne monsterMovementDone
mov byte [cs:monsterMovementDirectionFlag],1
jmp monsterMovementDone
monsterMoveReverse:
call clearMonsterLine
sub word[cs:monsterLocation],2
cmp word[cs:monsterLocation], 324
jne monsterMovementDone
mov byte [cs:monsterMovementDirectionFlag],0
monsterMovementDone:
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
generateFireballs: ;function to generate fireball
push ax
inc word [cs:fireball+4]
cmp word [cs:fireball+4], 3
jne cmpFireballTwo
mov word [cs:fireball+4], 1
mov word [cs:fireball], 1
mov word ax, [cs:monsterLocation]
add word ax, 22
mov word [cs:fireball+2], ax
cmpFireballTwo:
fireballDrawingCompleted:
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
printFireball: ;function to print fireball
push bp
mov bp, sp
push ax
push es
push di
mov ax, 0xb800
mov es, ax
mov al, 0x25
mov ah, 00001001b
mov di, [bp+4]
mov word [es:di], ax
pop di
pop es
pop ax
pop bp
ret 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawCoinSackOne: ;function to draw coin sack
push ax
push es
mov ax, 0xb800
mov es, ax
mov al, 0x3D
mov ah, 00001110b
mov word [es:2576], ax
mov word [es:2578], ax
mov word [es:2736], ax
mov word [es:2738], ax
pop es
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
clearCoinSackOne: ;function to clear coin sack
push ax
push es
mov ax, 0xb800
mov es, ax
mov word [es:2576], 0x0720
mov word [es:2578], 0x0720
mov word [es:2736], 0x0720
mov word [es:2738], 0x0720
pop es
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawCoinSackTwo: ;function to draw coin sack
push ax
push es
mov ax, 0xb800
mov es, ax
mov al, 0x3D
mov ah, 00001110b
mov word [es:2690], ax
mov word [es:2692], ax
mov word [es:2850], ax
mov word [es:2852], ax
pop es
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
clearCoinSackTwo: ;function to clear coin sack
push ax
push es
mov ax, 0xb800
mov es, ax
mov word [es:2690], 0x0720
mov word [es:2692], 0x0720
mov word [es:2850], 0x0720
mov word [es:2852], 0x0720
pop es
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawCoinSackThree: ;function to draw coin sack
push ax
push es
mov ax, 0xb800
mov es, ax
mov al, 0x3D
mov ah, 00001110b
mov word [es:2320], ax
mov word [es:2322], ax
mov word [es:2480], ax
mov word [es:2482], ax
pop es
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
clearCoinSackThree: ;function to clear coin sack
push ax
push es
mov ax, 0xb800
mov es, ax
mov word [es:2320], 0x0720
mov word [es:2322], 0x0720
mov word [es:2480], 0x0720
mov word [es:2482], 0x0720
pop es
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
drawKingdom: ;function to draw the kingdom
push es
push ax
mov ax, 0xb800
mov es, ax
mov al, 0x7C
mov ah, 00001011b
mov word [es:3822], ax
mov word [es:3662], ax
mov word [es:3502], ax
mov word [es:3834], ax
mov word [es:3674] ,ax
mov word [es:3514], ax
mov word [es:3506], ax
mov word [es:3510], ax
mov word [es:3348], ax
mov ah, 00001111b
mov word [es:3826], ax
mov word [es:3830], ax
mov al, 0x5f
mov word [es:3824], ax
mov word [es:3832], ax
mov word [es:3504], ax
mov word [es:3344], ax
mov word [es:3512], ax
mov word [es:3352], ax
mov al, 0x30
mov ah, 00001101b
mov word [es:3828], ax
mov al, 0x2F
mov ah, 00001111b
mov word [es:3668], ax
mov al, 0x5C
mov word [es:3670], ax
mov ah, 00001111b
mov al, 0x2D
mov word [es:3508], ax
mov ah, 10001101b
mov al, 0x7E
mov word [es:3350], ax
pop ax
pop es
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
removeFireBall: ;function to clear the fireball
push bp
mov bp, sp
push ax
push es
push di
mov ax, 0xb800
mov es, ax
mov di, [bp+4]
mov word [es:di], 0x0720
pop di
pop es
pop ax
pop bp
ret 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
fireBallCollisionDetection: ;check if character has collided with character
push ax
cmp word [cs:fireball], 0
je fireballNotCollided