-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSNAKE.ASM
1125 lines (915 loc) · 18.8 KB
/
SNAKE.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
.Model Small
PUBLIC TIMER_TICK
DRAW_ROW MACRO X
LOCAL L1
MOV AH,0CH
; MOV AL,3
MOV CX,10
MOV DX,X
L1: INT 10H
INC CX
CMP CX,301
JL L1
ENDM
DRAW_COLUMN MACRO Y
LOCAL L2
MOV AH,0CH
; MOV AL,3
MOV CX,Y
MOV DX,10
L2: INT 10H
INC DX
CMP DX,190
JL L2
ENDM
.Stack 100h
.DATA
A DB 0
v DB 0
loading db 0
pause db,0
welcomemsg db 1 dup(0ah),4 dup(" "),2 dup(" ")," WELLCOME TO SNAKE GAME ",2 dup(" "),3 dup(" "),9 dup(" "),'$'
startmsg db 9 dup(0ah),4 dup(">> "),2 dup(" ")," press 's' to start the game ",2 dup(" "),4 dup(">> "),9 dup(" "),'$'
resumemsg db 1 dup(0ah),4 dup(">> "),2 dup(" ")," press 'r' to resume the game ",2 dup(" "),4 dup(">> "),9 dup(" "),'$'
savemsg db 1 dup(0ah),4 dup(">> "),2 dup(" ")," press 'l' to save the game ",2 dup(" "),4 dup(">> "),9 dup(" "),'$'
highscoremsg db 1 dup(0ah),4 dup(">> "),2 dup(" ")," press 'h' to show High score ",2 dup(" "),4 dup(">> "),9 dup(" "),'$'
SHOW_GAME_OVER db 14 dup(0ah),27 dup(" ")," GAME OVER $" ,36 dup(" "),'$'
Exitmsg db 1 dup(0ah),6 dup(">> "),2 dup(" ")," press 'e' to exit ",2 dup(" "),4 dup(">> "),9 dup(" "),'$'
okay_msg db 16 dup(0ah),27 dup(" ")," press 'o' to continue $" ,36 dup(" "),'$'
score_5 db 14 dup(0ah),27 dup(" "),"Your Score is :$"
score_6 db 14 dup(0ah),22 dup(" "),"Your High Score is :$"
;point dw 0
point_2 db ,31 dup(" "),'$'
point_3 db ,31 dup(" "),'$'
;himel
NEW_TIMER_VEC DW ?,?
OLD_TIMER_VEC DW ?,?
TIMER_FLAG DB 0
HEAD_DX DW ?
HEAD_CX DW ?
TAIL_DX DW ?
TAIL_CX DW ?
SPEED_DX DW 0
SPEED_CX DW 0
CUR_DIR DB 4DH
SNAKE_DX DW 100 DUP(?)
SNAKE_CX DW 100 DUP(?)
SC_INT dw 0
;FOOD_DX DW ?
;FOOD_CX DW ?
FOOD_IND DW 0
FOOD_DX DW 114,138,162,78,90,102,46,34,86,94,110,134,158,74,86,98,42,30,82,90,'$'
FOOD_CX DW 168,96,156,108,204,84,180,228,164,92,164,92,152,104,200,80,176,224,160,88,'$'
SNAKE_SIZE DW 3
STOP DW ?
SCORE DB '000000$'
stop_flag db 0
FILE_SAVEGAME DB "SAVEGAME.TXT",0
HIGHSCORE_FILE DB "INPUT.TXT",0
HANDLE DW ?
Z DW ?
.Code
SET_DISP_MODE PROC
MOV AH,0
MOV AL,04H
INT 10H
MOV AH,0BH
MOV BH,0
MOV BL,8
INT 10H
MOV BH,1
MOV BL,1
INT 10H
MOV AL ,3
DRAW_ROW 10
DRAW_ROW 189
DRAW_COLUMN 10
DRAW_COLUMN 300
RET
SET_DISP_MODE ENDP
DISPLAY_BALL PROC
MOV AH, 0CH ; write pixel
INT 10H
INC CX ; pixel on next col
INT 10H
INC CX ; pixel on next col
INT 10H
INC CX ; pixel on next col
INT 10H
INC DX ; down 1 row
INT 10H
INC DX ; down 1 row
INT 10H
INC DX ; down 1 row
INT 10H
DEC CX ; prev col
INT 10H
DEC CX ; prev col
INT 10H
DEC CX ; prev col
INT 10H
DEC DX
INT 10H ; restore dx
DEC DX
INT 10H
DEC DX
RET
DISPLAY_BALL ENDP
CHECK_BOUNDARY PROC
MOV CX,HEAD_CX
MOV DX,HEAD_DX
CMP CX,15
JG LP1
MOV STOP,1
LP1:
CMP CX, 294
JL LP2
MOV STOP,1
; check row value
LP2:
CMP DX, 11
JG LP3
MOV STOP,1
LP3:
CMP DX, 183
JL LP4
MOV STOP,1
LP4:
MOV BX,2
ADD CX,SPEED_CX
ADD DX,SPEED_DX
CHECK:
CMP SNAKE_DX[BX],DX
JNE INCREASE
CMP SNAKE_CX[BX],CX
JNE INCREASE
MOV STOP,1
JMP DONE
INCREASE:
ADD BX,2
MOV DI,SNAKE_SIZE
ADD DI,DI
CMP BX,DI
JNE CHECK
DONE:
RET
CHECK_BOUNDARY EndP
TIMER_TICK PROC
PUSH DS
PUSH AX
MOV AX,SEG TIMER_FLAG
MOV DS,AX
MOV TIMER_FLAG,1
POP AX
POP DS
IRET
TIMER_TICK ENDP
DRAW_SNAKE PROC ; PARAM LENGH,40
MOV AL, 1
MOV BX, 0
DR_SN:
MOV DX,SNAKE_DX[BX]
MOV CX,SNAKE_CX[BX]
CALL DISPLAY_BALL
ADD BX,2
MOV DI,SNAKE_SIZE
ADD DI,DI
CMP BX,DI
JNE DR_SN
RET
DRAW_SNAKE ENDP
DRAW_FOOD PROC
MOV AL,2
ADD FOOD_IND,2
CMP FOOD_IND,20*2
JNE DR
MOV FOOD_IND,0
DR:
MOV BX,FOOD_IND
MOV DX,FOOD_DX[BX]
MOV CX,FOOD_CX[BX]
CALL DISPLAY_BALL
RET
DRAW_FOOD ENDP
SHOW_SCORE PROC
MOV DX,0
MOV AX,0
MOV AX,SC_INT
MOV BX,5
SET_SC:
MOV CX,10
DIV CX
MOV SCORE[BX],DL
ADD SCORE[BX],'0'
MOV DX,0
DEC BX
CMP BX,-1
JNE SET_SC
MOV AH,2
XOR BH,BH
MOV DX,0020H
INT 10H
MOV AH,09
MOV DX,OFFSET SCORE
INT 21H
RET
SHOW_SCORE ENDP
CHECK_FOOD PROC
MOV BX,FOOD_IND
MOV DI,HEAD_DX
CMP FOOD_DX[BX],DI
JNE FIN2
MOV DI,HEAD_CX
CMP FOOD_CX[BX],DI
JNE FIN2
INC SNAKE_SIZE
ADD SC_INT,5
CALL DRAW_FOOD
CALL SHOW_SCORE
FIN2:
RET
CHECK_FOOD ENDP
MOVE_ARRAY PROC
MOV DI,SNAKE_SIZE
DEC DI
ADD DI,DI
MOV BX,DI
SHIFT:
MOV DI,SNAKE_DX[BX-2]
MOV SNAKE_DX[BX],DI
MOV DI,SNAKE_CX[BX-2]
MOV SNAKE_CX[BX],DI
SUB BX,2
CMP BX,0
JNE SHIFT
MOV BX,SNAKE_SIZE
DEC BX
ADD BX,BX
MOV DI,SNAKE_DX[BX]
MOV TAIL_DX,DI
MOV DI,SNAKE_CX[BX]
MOV TAIL_CX,DI
MOV DI,HEAD_DX
MOV SNAKE_DX[0],DI
MOV DI,HEAD_CX
MOV SNAKE_CX[0],DI
RET
MOVE_ARRAY ENDP
GAME_LOOP PROC
MOV STOP,0
cmp pause,1
je FIN3
CALL CHECK_BOUNDARY
CALL CHECK_FOOD
CMP STOP,1
JE GAME_FINISH
TEST_TIMER:
CMP TIMER_FLAG, 1 ;4 TICKS
JNE TEST_TIMER
MOV TIMER_FLAG, 0
TEST_TIMER_2:
CMP TIMER_FLAG, 1
JNE TEST_TIMER_2
MOV TIMER_FLAG, 0
; TEST_TIMER_3:
; CMP TIMER_FLAG, 1
;JNE TEST_TIMER_3
;MOV TIMER_FLAG, 0
;TEST_TIMER_4:
; CMP TIMER_FLAG, 1
;JNE TEST_TIMER_4
; MOV TIMER_FLAG, 0
MOV DI,SPEED_CX
ADD HEAD_CX,DI
MOV DI,SPEED_DX
ADD HEAD_DX,DI
MOV CX,HEAD_CX
MOV DX,HEAD_DX
MOV AL, 1
CALL DISPLAY_BALL
MOV CX,TAIL_CX
MOV DX,TAIL_DX
MOV AL, 0
CALL DISPLAY_BALL
CALL MOVE_ARRAY
JMP FIN3
GAME_FINISH:
CALL GAME_OVER
CALL SHOW
CALL START
FIN3:
RET
GAME_LOOP ENDP
MOVE_RIGHT PROC
MOV SPEED_DX,0
MOV SPEED_CX,4
RET
MOVE_RIGHT ENDP
MOVE_LEFT PROC
MOV SPEED_DX,0
MOV SPEED_CX,4
NEG SPEED_CX
RET
MOVE_LEFT ENDP
MOVE_UP PROC
MOV SPEED_DX,4
MOV SPEED_CX,0
NEG SPEED_DX
RET
MOVE_UP ENDP
MOVE_DOWN PROC
MOV SPEED_DX,4
MOV SPEED_CX,0
RET
MOVE_DOWN ENDP
SET_UP_INT PROC
MOV AH, 35H
INT 21H
MOV [DI], BX
MOV [DI+2], ES
MOV DX, [SI]
PUSH DS
MOV DS, [SI+2]
MOV AH, 25H
INT 21H
POP DS
RET
SET_UP_INT ENDP
READCHAR PROC
MOV AH, 01H
INT 16H
JNZ KEYPRESSED
RET
KEYPRESSED:
CMP AL,'p'
JNE STILL
CALL PAUSE_1
STILL:
CMP AL,'l'
JE SAVE
JMP GET_DIRECTION
SAVE:
CALL SAVE_GAME
JMP START
GET_DIRECTION:
MOV AH, 00H ;get the key
INT 16H
CMP CUR_DIR,48H
JNE NEXT1
CMP AH, 50H
JE SKIP
NEXT1:
CMP CUR_DIR,50H
JNE NEXT2
CMP AH, 48H
JE SKIP
NEXT2:
CMP CUR_DIR,4BH
JNE NEXT3
CMP AH, 4DH
JE SKIP
NEXT3:
CMP CUR_DIR,4DH
JNE CHANGE
CMP AH, 4BH
JE SKIP
CHANGE:
MOV CUR_DIR,AH
SKIP:
RET
READCHAR ENDP
MOVE_SNAKE PROC
CMP CUR_DIR,48H
JE UP
CMP CUR_DIR,4BH
JE LEFT
CMP CUR_DIR,4DH
JE RIGHT
CMP CUR_DIR,50H
JE DOWN
jmp fin
UP:
CALL MOVE_UP
JMP FIN
LEFT:
CALL MOVE_LEFT
JMP FIN
RIGHT:
CALL MOVE_RIGHT
JMP FIN
DOWN:
CALL MOVE_DOWN
FIN:
RET
MOVE_SNAKE ENDP
main Proc
; set VGA 320x200 256 color mode
MOV AX,@DATA
MOV DS,AX
start:
; set CGA 640x480 16 color mode
MOV Ah, 0
mov al, 12h
INT 10h
; draw 256 color band
MOV AH, 0CH ; write pixel function
MOV AL,13 ; start pixel color 0
MOV BH, 0 ; page 0
MOV DX, 0 ; row
OL1:
MOV CX, 0 ; col
L1:
INT 10h
; next color
INC CX ; next col
CMP CX, 640
JL L1
INC DX; next row
CMP DX,480
JL OL1
lea dx, welcomemsg
mov ah, 9
int 21h
lea dx, startmsg
mov ah, 9
int 21h
lea dx, resumemsg
mov ah, 9
int 21h
lea dx, savemsg
mov ah, 9
int 21h
lea dx,highscoremsg
mov ah, 9
int 21h
lea dx,Exitmsg
mov ah, 9
int 21h
;here
check_for_key:
; === check for player commands:
;mov ah, 01h
; int 16h
; jz score_1
MOV AH, 0
INT 16h
cmp al,'h' ; esc - key?
je score_1
cmp al,'s'
je game_start
cmp al,'r'
je load_game
cmp al,'e'
je return
jmp check_for_key
score_1:
call score_read;show
jmp start
game_start:
call refresh
call go_game
jmp start
load_game:
call load
jmp go_game
jmp start
return:
;here
; getch
;MOV AH, 0 //if itcomments out then e button is needed to press twiceterminate the program
;INT 16h //this too
; return to text mode
MOV AX, 3
INT 10h
; return to DOS
MOV AH, 4CH
INT 21h
main EndP
; End main
show proc
push ax
push dx
; set CGA 640x480 16 color mode
MOV Ah, 0
mov al, 12h
INT 10h
; draw 256 color band
MOV AH, 0CH ; write pixel function
MOV AL,10 ; start pixel color 0
MOV BH, 0 ; page 0
MOV DX, 0 ; row
OL_1:
MOV CX, 0 ; col
L_1:
INT 10h
; next color
INC CX ; next col
CMP CX, 640
JL L_1
INC DX; next row
CMP DX,480
JL OL_1
mov ah,9
lea dx,score_5
int 21h
; mov ah, 2
; mov bx, SC_INT
;add bx, '0'
; mov dx, bx
;int 21h
mov ah,9
lea dx,score
int 21h
cmp v,1
je print_score
mov ah,9
lea dx,point_2
int 21h
lea dx,okay_msg
int 21h
lea dx,point_2
int 21h
jmp okay
print_score:
mov ah,9
lea dx,point_3
int 21h
mov v,0
lea dx,okay_msg
int 21h
lea dx,point_2
int 21h
okay:
MOV AH, 0
INT 16h
cmp al,'o' ; esc - key?
jne okay
pop dx
pop ax
ret
show endp
go_game PROC near
;MOV AX, @DATA
;MOV DS, AX
CALL SET_DISP_MODE
MOV NEW_TIMER_VEC, OFFSET TIMER_TICK
MOV NEW_TIMER_VEC+2, CS
MOV AL, 1CH;
LEA DI, OLD_TIMER_VEC
LEA SI, NEW_TIMER_VEC
CALL SET_UP_INT
cmp loading,1
je no_change
MOV CX,152
MOV DX,98
MOV BX,0
MAKE_ARRAY:
MOV SNAKE_CX[BX], CX
MOV SNAKE_DX[BX], DX
SUB CX,4
ADD BX,2
MOV DI,SNAKE_SIZE
ADD DI,DI
CMP BX,DI
JNE MAKE_ARRAY
NO_CHANGE:
mov di,snake_size
add di,di
mov bx,di
MOV DI,SNAKE_DX[0]
MOV HEAD_DX,DI
MOV DI,SNAKE_CX[0]
MOV HEAD_CX,DI
MOV DI,SNAKE_DX[BX-2]
MOV TAIL_DX,DI
MOV DI,SNAKE_CX[BX-2]
MOV TAIL_CX,DI
CALL DRAW_SNAKE
MOV DI,HEAD_DX
CALL DRAW_FOOD
CALL SHOW_SCORE
GM:
cmp pause,1
je stop_snake
CALL READCHAR
CALL MOVE_SNAKE
CALL GAME_LOOP
JMP GM
stop_snake:
ret
go_game ENDP
GAME_OVER PROC NEAR
push ax
push bx
push dx
; set CGA 640x480 16 color mode
MOV Ah, 0
mov al, 12h
INT 10h
; draw 256 color band
MOV AH, 0CH ; write pixel function
MOV AL,10 ; start pixel color 0
MOV BH, 0 ; page 0
MOV DX, 0 ; row
OL_5:
MOV CX, 0 ; col
L_5:
INT 10h
; next color
INC CX ; next col
CMP CX, 640
JL L_5
INC DX; next row
CMP DX,480
JL OL_5
mov ah,9
lea dx,SHOW_GAME_OVER
int 21h
mov ah,9
lea dx,point_2
int 21h
lea dx,okay_msg
int 21h
lea dx,point_2
int 21h
;SAVE HIGHSCORE TO FILE
LEA DX,HIGHSCORE_FILE
MOV AH,3DH
MOV AL,0
INT 21H
MOV HANDLE,AX
LEA DX,z
MOV BX,HANDLE
MOV AH,3FH
MOV CX,1
INT 21H
LEA DX,HIGHSCORE_FILE
MOV AH,3EH
mov bx,handle
INT 21H
mov bx,z
cmp bx,SC_INT
JG HERE
LEA DX,HIGHSCORE_FILE
MOV AH,3CH
MOV CX,0
INT 21h
; JC OPEN_ERROR
MOV HANDLE,AX
; write to file:
MOV AH,40H
MOV BX,HANDLE
MOV DX, OFFSET SC_INT
MOV CX,1
INT 21h
;END OF CODE OF SAVING SCORE
LEA DX,HIGHSCORE_FILE
MOV AH,3EH
mov bx,handle
INT 21H
HERE:
mov v,1
okay_1:
MOV AH, 0
INT 16h
cmp al,'o' ; esc - key?
jne okay_1
pop dx
pop bx
pop ax
ret
GAME_OVER ENDP
SAVE_GAME PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
mov pause,1
LEA DX,FILE_SAVEGAME
MOV AH,3CH
MOV CX,0
INT 21h
; JC OPEN_ERROR
MOV HANDLE,AX
; write to file:
MOV AH,40H
MOV BX,HANDLE
MOV DX, OFFSET CUR_DIR
MOV CX,1
INT 21h
MOV AH,40H
LEA DX,SNAKE_DX
MOV CX,100
INT 21H
MOV AH,40H
LEA DX,SNAKE_CX
MOV CX,100
INT 21H
MOV AH,40H
LEA DX,SC_INT
MOV CX,1
INT 21H
MOV AH,40H
LEA DX,FOOD_IND
MOV CX,1
INT 21H
MOV AH,40H
LEA DX,SNAKE_SIZE
MOV CX,1
INT 21H
MOV AH,40H
LEA DX,STOP
MOV CX,1
INT 21H
MOV AH,40H
LEA DX,SCORE
MOV CX,6
INT 21H
MOV AH,3EH
mov bx,handle
INT 21H
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
RET
SAVE_GAME ENDP
load proc near
cmp stop,1
je start_new
jmp same
start_new:
call refresh
call go_game
jmp start
same:
cmp stop,1
je flag
mov loading,1
flag:
mov pause,0
LEA DX,FILE_SAVEGAME
MOV AH,3DH
MOV AL,0
INT 21H
MOV HANDLE,AX
LEA DX,CUR_DIR
MOV BX,HANDLE
MOV AH,3FH
MOV CX,1
INT 21H
MOV AH,3FH
LEA DX,SNAKE_DX
MOV CX,100
INT 21H
MOV AH,3FH
LEA DX,SNAKE_CX
MOV CX,100
INT 21H
MOV AH,3FH
LEA DX,SC_INT
MOV CX,1
INT 21H
MOV AH,3FH
LEA DX,FOOD_IND
MOV CX,1
INT 21H
MOV AH,3FH
LEA DX,SNAKE_SIZE
MOV CX,1
INT 21H
MOV AH,3FH
LEA DX,STOP
MOV CX,1
INT 21H
MOV AH,3FH
LEA DX,SCORE
MOV CX,6
INT 21H
MOV AH,3EH
mov bx,handle
INT 21H
ret
load endp
refresh proc near
mov FOOD_IND,0
mov loading,0
mov A,0
mov v,0
mov pause,0
mov NEW_TIMER_VEC,0
mov NEW_TIMER_VEC+1,0
mov OLD_TIMER_VEC,0
mov OLD_TIMER_VEC+1,0
MOV TIMER_FLAG,0
MOV HEAD_DX ,0
MOV HEAD_CX,0
MOV TAIL_DX,0
MOV TAIL_CX,0
MOV CUR_DIR,4DH ;HERE
MOV CX,100
XOR DI,DI
D1:
MOV SNAKE_DX[DI],0
ADD DI,2
LOOP D1
MOV CX,100
XOR DI,DI
D2:
MOV SNAKE_CX[DI],0
ADD DI,2
LOOP D2
MOV SPEED_DX,0
MOV SPEED_CX,0
MOV SC_INT,0
MOV FOOD_DX,0
MOV FOOD_CX,0
MOV SNAKE_SIZE,3
MOV STOP,0