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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- snake dw s_size dup(0)
- tail dw ?
- left equ 4bh
- right equ 4dh
- up equ 48h
- down equ 50h
- cur_dir db right
- temps dw 0
- wait_time dw 0
- stopped db 0
- start:
- mov ah, 1
- mov ch, 2bh
- mov cl, 0bh
- int 10h
- ;mov x_coo, 10
- ;mov y_coo, 10
- ;call obstacle_hor
- ;jmp game_loop
- mov x_coo, 20
- mov y_coo, 5
- call obstacle_hor
- mov x_coo, 20
- mov y_coo, 15
- call obstacle_hor
- mov x_coo, 20
- mov y_coo, 25
- call obstacle_hor
- mov x_coo, 20
- mov y_coo, 35
- call obstacle_hor
- mov x_coo, 20
- mov y_coo, 45
- call obstacle_hor
- mov x_coo, 7
- mov y_coo, 45
- call obstacle_hor
- mov x_coo, 7
- mov y_coo, 55
- call obstacle_hor
- mov x_coo, 7
- mov y_coo, 65
- call obstacle_hor
- mov x_coo, 5
- mov y_coo, 15
- call obstacle_hor
- mov x_coo, 8
- mov y_coo, 25
- call obstacle_hor
- mov x_coo, 11
- mov y_coo, 35
- call obstacle_hor
- mov x_coo, 14
- mov y_coo, 45
- call obstacle_hor
- mov x_coo, 17
- mov y_coo, 55
- call obstacle_hor
- mov x_coo, 20
- mov y_coo, 65
- call obstacle_hor
- mov x_coo, 23
- mov y_coo, 75
- call obstacle_hor
- mov x_coo, 2
- mov y_coo, 5
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 10
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 15
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 20
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 25
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 30
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 35
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 40
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 45
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 50
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 55
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 60
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 65
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 70
- call obstacle_ver
- mov x_coo, 2
- mov y_coo, 75
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 5
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 10
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 15
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 20
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 25
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 30
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 35
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 40
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 45
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 50
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 55
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 60
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 65
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 70
- call obstacle_ver
- mov x_coo, 14
- mov y_coo, 75
- call obstacle_ver
- game_loop:
- cmp stopped, 1
- je gtfo
- mov al, 0
- mov ah, 05h
- int 10h
- mov dx, snake[0]
- mov ah, 02h
- int 10h
- mov al, '*'
- mov ah, 09h
- mov bl, 0eh
- mov cx, 1
- int 10h
- mov ax, snake[s_size * 2 - 2]
- mov tail, ax
- call move_snake
- mov dx, tail
- mov ah, 02h
- int 10h
- mov al, ' '
- mov ah, 09h
- mov bl, 0eh
- mov cx, 1
- int 10h
- check_for_key:
- mov ah, 01h
- int 16h
- jz no_key
- mov ah, 00h
- int 16h
- cmp al, 1bh
- je stop_game
- mov cur_dir, ah
- no_key:
- mov ah, 00h
- int 1ah
- cmp dx, wait_time
- jb check_for_key
- add dx, 4
- mov wait_time, dx
- jmp game_loop
- stop_game:
- mov ah, 1
- mov ch, 0bh
- mov cl, 0bh
- int 10h
- ret
- move_snake proc near
- mov ax, 40h
- mov es, ax
- mov di, s_size * 2 - 2
- mov cx, s_size-1
- move_array:
- mov ax, snake[di-2]
- mov snake[di], ax
- sub di, 2
- loop move_array
- cmp cur_dir, left
- je move_left
- cmp cur_dir, right
- je move_right
- cmp cur_dir, up
- je move_up
- cmp cur_dir, down
- je move_down
- jmp stop_move
- move_left:
- mov al, b.snake[0]
- dec al
- mov b.snake[0], al
- cmp al, -1
- jne stop_move
- mov al, es:[4ah]
- dec al
- mov b.snake[0], al
- jmp stop_move
- move_right:
- mov al, b.snake[0]
- inc al
- mov b.snake[0], al
- cmp al, es:[4ah]
- jb stop_move
- mov b.snake[0], 0
- move_up:
- mov al, b.snake[1]
- dec al
- mov b.snake[1], al
- cmp al, -1
- jne stop_move
- mov al, es:[84h]
- mov b.snake[1], al
- jmp stop_move
- move_down:
- mov al, b.snake[1]
- inc al
- mov b.snake[1], al
- cmp al, es:[84h]
- jbe stop_move
- mov b.snake[1], 0
- jmp stop_move
- stop_move:
- push ax
- push bx
- push cx
- push dx
- push si
- push di
- lea si, ar
- lea di, snake
- mov ax, [di]
- mov temps, ax
- mov ah, 0
- mov al, b.temps[1]
- mov bh, 0
- mov bl, b.temps[0]
- mov dx, 80
- mul dx
- add ax, bx
- add si, ax
- mov ch, 0
- mov cl, [si]
- cmp cl, 1
- jne nope1
- mov stopped, 1
- nope1:
- pop di
- pop si
- pop dx
- pop cx
- pop bx
- pop ax
- ret
- move_snake endp
- obstacle_hor proc
- push ax
- push bx
- push cx
- push dx
- mov cx,10
- LOOP1:
- cmp x_coo, 25
- jge skip1
- cmp y_coo, 80
- jge skip1
- mov dh,x_coo
- mov dl,y_coo
- push ax
- push bx
- push cx
- push dx
- push si
- lea si, ar
- mov ah, 0
- mov al, x_coo
- mov dx, 80
- mul dx
- mov bh, 0
- mov bl, y_coo
- add ax, bx
- add si, ax
- mov [si], 1
- pop si
- pop dx
- pop cx
- pop bx
- pop ax
- mov ah,2
- int 10h
- push cx
- mov al, '#'
- mov ah, 09h
- mov bl, 0ah
- mov cx, 1
- int 10h
- inc y_coo
- pop cx
- loop LOOP1
- skip1:
- pop dx
- pop cx
- pop bx
- pop ax
- ret
- obstacle_hor endp
- obstacle_ver proc
- push ax
- push bx
- push cx
- push dx
- mov cx,10
- LOOP2:
- cmp x_coo, 25
- jge skip1
- cmp y_coo, 80
- jge skip2
- mov dh,x_coo
- mov dl,y_coo
- push ax
- push bx
- push cx
- push dx
- push si
- lea si, ar
- mov ah, 0
- mov al, x_coo
- mov dx, 80
- mul dx
- mov bh, 0
- mov bl, y_coo
- add ax, bx
- add si, ax
- mov [si], 1
- pop si
- pop dx
- pop cx
- pop bx
- pop ax
- mov ah,2
- int 10h
- push cx
- mov al, '#'
- mov ah, 09h
- mov bl, 0ah
- mov cx, 1
- int 10h
- inc x_coo
- pop cx
- loop LOOP2
- skip2:
- pop dx
- pop cx
- pop bx
- pop ax
- ret
- obstacle_ver endp
- gtfo:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement