2010-07-15 14:37:55 +02:00
|
|
|
|
;;===Level_mode================================================================================================================
|
|
|
|
|
|
|
|
|
|
Level_begin:
|
|
|
|
|
|
|
|
|
|
mov [score], 0
|
|
|
|
|
mov [action], 0
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov eax, [gw_mul_gh]
|
|
|
|
|
sub eax, 3
|
|
|
|
|
mov [number_of_free_dots], ax
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
|
|
|
|
invoke ini.get_str, cur_dir_path, aScore, aChampion_name, champion_name, 15, champion_name
|
|
|
|
|
invoke ini.get_int, cur_dir_path, aScore, aHiscore, 0
|
|
|
|
|
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz @f
|
|
|
|
|
mov dword [hi_score], eax
|
|
|
|
|
@@:
|
|
|
|
|
|
|
|
|
|
mov esi, start_map
|
|
|
|
|
mov edi, field_map
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov ecx, [gw_mul_gh]
|
|
|
|
|
shr ecx, 2
|
2010-07-15 14:37:55 +02:00
|
|
|
|
rep movsd
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
call Get_eat
|
|
|
|
|
|
2010-07-15 14:37:55 +02:00
|
|
|
|
Level_body:
|
|
|
|
|
;;===Level_body========================================================================================================
|
|
|
|
|
|
|
|
|
|
mcall 26, 9
|
|
|
|
|
mov [time_before_waiting], eax
|
|
|
|
|
mov eax, [time_wait_limit]
|
|
|
|
|
mov [time_to_wait], eax
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
.redraw:
|
2010-07-15 14:37:55 +02:00
|
|
|
|
mcall 12,1
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov ebx, [wp_x]
|
|
|
|
|
shl ebx, 16
|
|
|
|
|
add ebx, dword[window_width]
|
|
|
|
|
mov ecx, [wp_y]
|
|
|
|
|
shl ecx, 16
|
|
|
|
|
add ecx, dword[window_height]
|
|
|
|
|
mcall 0, , ,[window_style], ,window_title
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
|
|
|
|
call Draw_decorations
|
|
|
|
|
call Draw_snake
|
|
|
|
|
call Draw_eat
|
|
|
|
|
call Draw_level_strings
|
|
|
|
|
|
|
|
|
|
mcall 12,2
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
.still:
|
2010-07-15 14:37:55 +02:00
|
|
|
|
mcall 26, 9
|
|
|
|
|
push eax
|
|
|
|
|
sub eax, [time_before_waiting]
|
|
|
|
|
pop [time_before_waiting]
|
|
|
|
|
cmp [time_to_wait], eax
|
|
|
|
|
jg @f
|
|
|
|
|
cmp [action], 0
|
|
|
|
|
jne Game_step
|
|
|
|
|
@@:
|
|
|
|
|
sub [time_to_wait], eax
|
|
|
|
|
mcall 23, [time_to_wait] ;
|
|
|
|
|
|
|
|
|
|
test al, al
|
|
|
|
|
jnz @f
|
|
|
|
|
cmp [action], 0
|
|
|
|
|
jne Game_step
|
|
|
|
|
mcall 26, 9
|
|
|
|
|
mov [time_before_waiting], eax
|
|
|
|
|
mov eax, [time_wait_limit]
|
|
|
|
|
mov [time_to_wait], eax
|
2010-07-19 16:59:30 +02:00
|
|
|
|
jmp .still
|
2010-07-15 14:37:55 +02:00
|
|
|
|
@@:
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
.message: ; ok, what an event?
|
2010-07-15 14:37:55 +02:00
|
|
|
|
dec al ; has the window been moved or resized?
|
2010-07-19 16:59:30 +02:00
|
|
|
|
jz .redraw ;
|
2010-07-15 14:37:55 +02:00
|
|
|
|
dec al ; was a key pressed?
|
2010-07-19 16:59:30 +02:00
|
|
|
|
jz .key ;
|
2010-07-15 14:37:55 +02:00
|
|
|
|
dec al ; was a button pressed?
|
2010-07-19 16:59:30 +02:00
|
|
|
|
jz .button ;
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
.key:
|
2010-07-15 14:37:55 +02:00
|
|
|
|
mcall 2 ; get keycode
|
|
|
|
|
|
|
|
|
|
cmp ah, 0x1B ; Escape
|
|
|
|
|
je First_menu
|
|
|
|
|
cmp ah, 0x20 ; Space
|
|
|
|
|
je Pause_mode
|
|
|
|
|
cmp ah, 0xB0 ; Left
|
2010-07-19 16:59:30 +02:00
|
|
|
|
je .key.left
|
2010-07-15 14:37:55 +02:00
|
|
|
|
cmp ah, 0xB1 ; Down
|
2010-07-19 16:59:30 +02:00
|
|
|
|
je .key.down
|
2010-07-15 14:37:55 +02:00
|
|
|
|
cmp ah, 0xB2 ; Up
|
2010-07-19 16:59:30 +02:00
|
|
|
|
je .key.up
|
2010-07-15 14:37:55 +02:00
|
|
|
|
cmp ah, 0xB3 ; Right
|
2010-07-19 16:59:30 +02:00
|
|
|
|
je .key.right
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
jmp .still ; jump to wait for another event
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.button: ; <20><><EFBFBD>楤<EFBFBD><E6A5A4><EFBFBD> <20><>ࠡ<EFBFBD><E0A0A1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20>ணࠬ<E0AEA3><E0A0AC>
|
|
|
|
|
mcall 17 ; <20>㭪<EFBFBD><E3ADAA><EFBFBD> 17: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>⮩ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
shr eax, 8 ; ᤢ<><E1A4A2><EFBFBD><EFBFBD><EFBFBD> ॣ<><E0A5A3><EFBFBD><EFBFBD> eax <20><> 8 <20><><EFBFBD> <20><>ࠢ<EFBFBD>, <20>⮡<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>⮩ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
cmp eax, 1
|
|
|
|
|
je Exit ; <20> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 (<28><>१<EFBFBD>ࢨ<E0A2A8><E0AEA2><EFBFBD> <20><><EFBFBD>⥬<EFBFBD><E2A5AC> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ணࠬ<E0AEA3><E0A0AC>), <20>ய<EFBFBD>᪠<EFBFBD><E1AAA0> 2 <><E1ABA5><EFBFBD>騥 <20><><EFBFBD><EFBFBD>窨 <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
jmp .still
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.key.left:
|
|
|
|
|
bts dword[action], 0
|
|
|
|
|
jc @f
|
2010-07-15 14:37:55 +02:00
|
|
|
|
mov [time_to_wait], 0
|
|
|
|
|
@@:
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], LEFT
|
|
|
|
|
jmp .still
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
.key.down:
|
|
|
|
|
bts dword[action], 0
|
|
|
|
|
jc @f
|
2010-07-15 14:37:55 +02:00
|
|
|
|
mov [time_to_wait], 0
|
|
|
|
|
@@:
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], DOWN
|
|
|
|
|
jmp .still
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
.key.up:
|
|
|
|
|
bts dword[action], 0
|
|
|
|
|
jc @f
|
2010-07-15 14:37:55 +02:00
|
|
|
|
mov [time_to_wait], 0
|
|
|
|
|
@@:
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], UP
|
|
|
|
|
jmp .still
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
.key.right:
|
|
|
|
|
bts dword[action], 0
|
|
|
|
|
jc @f
|
2010-07-15 14:37:55 +02:00
|
|
|
|
mov [time_to_wait], 0
|
|
|
|
|
@@:
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], RIGHT
|
|
|
|
|
jmp .still
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Game_step:
|
|
|
|
|
|
|
|
|
|
cmp [snake_napravlenie], LEFT ; are we moving to left?
|
|
|
|
|
jz .left
|
|
|
|
|
cmp [snake_napravlenie], DOWN ; ... down?
|
|
|
|
|
jz .down
|
|
|
|
|
cmp [snake_napravlenie], UP ; ... up?
|
|
|
|
|
jz .up
|
|
|
|
|
jmp .right ; then right
|
|
|
|
|
|
|
|
|
|
.left:
|
|
|
|
|
cmp [snake_napravlenie_next], RIGHT ; next step is to right?
|
|
|
|
|
jz .with_rewerse
|
|
|
|
|
jmp .without_rewerse
|
|
|
|
|
|
|
|
|
|
.down:
|
|
|
|
|
cmp [snake_napravlenie_next], UP ; next step is to up?
|
|
|
|
|
jz .with_rewerse
|
|
|
|
|
jmp .without_rewerse
|
|
|
|
|
|
|
|
|
|
.up:
|
|
|
|
|
cmp [snake_napravlenie_next], DOWN ; next step is to bottom?
|
|
|
|
|
jz .with_rewerse
|
|
|
|
|
jmp .without_rewerse
|
|
|
|
|
|
|
|
|
|
.right:
|
|
|
|
|
cmp [snake_napravlenie_next], LEFT ; next step is to left?
|
|
|
|
|
jz .with_rewerse
|
|
|
|
|
jmp .without_rewerse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.with_rewerse:
|
|
|
|
|
call Set_reverse_napravlenie
|
|
|
|
|
call Reverse
|
|
|
|
|
|
|
|
|
|
.without_rewerse:
|
|
|
|
|
; mov [time_to_wait], 0
|
|
|
|
|
mov edx, snake_dots-2
|
|
|
|
|
add edx, [snake_length_x2]
|
|
|
|
|
|
|
|
|
|
cmp [snake_napravlenie_next], LEFT
|
|
|
|
|
je .to_left
|
|
|
|
|
cmp [snake_napravlenie_next], DOWN
|
|
|
|
|
je .to_down
|
|
|
|
|
cmp [snake_napravlenie_next], UP
|
|
|
|
|
je .to_up
|
|
|
|
|
cmp [snake_napravlenie_next], RIGHT
|
|
|
|
|
je .to_right
|
|
|
|
|
|
|
|
|
|
.to_left:
|
|
|
|
|
mov [snake_napravlenie], LEFT
|
|
|
|
|
mov ax, [edx]
|
|
|
|
|
dec al
|
|
|
|
|
cmp al, -1
|
|
|
|
|
jne @f
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov al, byte[g_w]
|
|
|
|
|
dec al
|
2010-07-15 14:37:55 +02:00
|
|
|
|
@@:
|
|
|
|
|
jmp Snake_move
|
|
|
|
|
|
|
|
|
|
.to_down:
|
|
|
|
|
mov [snake_napravlenie], DOWN
|
|
|
|
|
mov ax, [edx]
|
|
|
|
|
inc ah
|
2010-07-19 16:59:30 +02:00
|
|
|
|
cmp ah, byte[g_h]
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jne @f
|
|
|
|
|
mov ah, 0
|
|
|
|
|
@@:
|
|
|
|
|
jmp Snake_move
|
|
|
|
|
|
|
|
|
|
.to_up:
|
|
|
|
|
mov [snake_napravlenie], UP
|
|
|
|
|
mov ax, [edx]
|
|
|
|
|
dec ah
|
|
|
|
|
cmp ah, -1
|
|
|
|
|
jne @f
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov ah, byte[g_h]
|
|
|
|
|
dec ah
|
2010-07-15 14:37:55 +02:00
|
|
|
|
@@:
|
|
|
|
|
jmp Snake_move
|
|
|
|
|
|
|
|
|
|
.to_right:
|
|
|
|
|
mov [snake_napravlenie], RIGHT
|
|
|
|
|
mov ax, [edx]
|
|
|
|
|
inc al
|
2010-07-19 16:59:30 +02:00
|
|
|
|
cmp al, byte[g_w]
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jne @f
|
|
|
|
|
mov al, 0
|
|
|
|
|
@@:
|
|
|
|
|
jmp Snake_move
|
|
|
|
|
|
|
|
|
|
;;---Level_body--------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
;;---Level_mode----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;===Some_functions============================================================================================================
|
|
|
|
|
|
|
|
|
|
Draw_snake:
|
|
|
|
|
;;===Draw_snake========================================================================================================
|
|
|
|
|
|
|
|
|
|
call Draw_head_prehead
|
|
|
|
|
mov edx, [snake_color]
|
|
|
|
|
mov esi, snake_dots-6
|
|
|
|
|
add esi, [snake_length_x2]
|
|
|
|
|
|
|
|
|
|
@@:
|
|
|
|
|
mov bx, [esi]
|
|
|
|
|
sub esi, 2
|
|
|
|
|
call Draw_square
|
|
|
|
|
cmp esi, snake_dots-2
|
|
|
|
|
jne @b
|
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;;---Draw_snake--------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Draw_head_prehead:
|
|
|
|
|
;;===Draw_head_prehead=================================================================================================
|
|
|
|
|
|
|
|
|
|
mov edx, [snake_head_color]
|
|
|
|
|
mov esi, snake_dots-2
|
|
|
|
|
add esi, [snake_length_x2]
|
|
|
|
|
mov bx, [esi]
|
|
|
|
|
call Draw_square
|
|
|
|
|
sub esi, 2
|
|
|
|
|
mov bx, [esi]
|
|
|
|
|
mov edx, [snake_color]
|
|
|
|
|
call Draw_square
|
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;;---Draw_head_prehead-------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Draw_level_strings:
|
|
|
|
|
;;===Draw_level_strings================================================================================================
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov ebx, [window_width]
|
|
|
|
|
shr ebx, 1
|
|
|
|
|
sub ebx, (string_resume_space-string_pause_space-1)*3+6
|
|
|
|
|
shl ebx, 16
|
|
|
|
|
add ebx, [top_strings]
|
|
|
|
|
mcall 4, ,[navigation_strings_color],string_pause_space ; Draw 'PAUSE - SPACE' string
|
|
|
|
|
|
|
|
|
|
; call Draw_menu_esc
|
2010-07-15 14:37:55 +02:00
|
|
|
|
call Draw_score_string
|
|
|
|
|
call Draw_score_number ; Draw score (number)
|
|
|
|
|
call Draw_champion_string
|
|
|
|
|
call Draw_champion_name
|
2010-07-19 16:59:30 +02:00
|
|
|
|
call Draw_hiscore_string
|
|
|
|
|
call Draw_hiscore_number
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;;---Draw_level_strings------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Reverse:
|
|
|
|
|
;;===Reverse===========================================================================================================
|
|
|
|
|
|
|
|
|
|
mov ecx, [snake_length_x2]
|
|
|
|
|
shr ecx, 2
|
|
|
|
|
mov esi, snake_dots
|
|
|
|
|
mov edi, snake_dots-2
|
|
|
|
|
add edi, [snake_length_x2]
|
|
|
|
|
|
|
|
|
|
@@:
|
|
|
|
|
mov ax, [edi]
|
|
|
|
|
xchg ax, [esi]
|
|
|
|
|
mov [edi], ax
|
|
|
|
|
|
|
|
|
|
add esi, 2
|
|
|
|
|
sub edi, 2
|
2010-07-19 16:59:30 +02:00
|
|
|
|
dec cx
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jnz @b
|
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;;---Reverse-----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Draw_eat:
|
|
|
|
|
;;===Draw_eat==========================================================================================================
|
|
|
|
|
|
|
|
|
|
mov bx, word[eat]
|
|
|
|
|
mov edx, [eat_color]
|
|
|
|
|
|
|
|
|
|
call Draw_square
|
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;;---Draw_eat----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Get_eat:
|
|
|
|
|
;;===Get_eat===========================================================================================================
|
|
|
|
|
;; in :
|
|
|
|
|
;;
|
|
|
|
|
;; out :
|
|
|
|
|
;; ax = coord's of the eat square (al=x, ah=y)
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
mcall 26,9
|
|
|
|
|
; xor eax, esp
|
|
|
|
|
shl eax, 1
|
|
|
|
|
xor edx, edx
|
|
|
|
|
div word[number_of_free_dots]
|
|
|
|
|
mov ebx, field_map
|
|
|
|
|
|
|
|
|
|
.loop:
|
|
|
|
|
cmp byte[ebx], 0
|
|
|
|
|
jne @f
|
|
|
|
|
test dx, dx
|
|
|
|
|
jz .place_found
|
|
|
|
|
dec dx
|
|
|
|
|
@@:
|
|
|
|
|
inc ebx
|
|
|
|
|
jmp .loop
|
|
|
|
|
|
|
|
|
|
.place_found:
|
|
|
|
|
sub ebx, field_map
|
|
|
|
|
mov eax, ebx
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov bl, byte[g_w]
|
2010-07-15 14:37:55 +02:00
|
|
|
|
div bl
|
|
|
|
|
xchg al, ah
|
|
|
|
|
|
|
|
|
|
mov word[eat], ax
|
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;;---Get_eat-----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sdvig:
|
|
|
|
|
;;===Sdvig=============================================================================================================
|
|
|
|
|
|
|
|
|
|
mov esi, snake_dots+2
|
|
|
|
|
mov edi, snake_dots
|
|
|
|
|
mov ecx, [snake_length_x2]
|
|
|
|
|
shr ecx, 1
|
|
|
|
|
|
|
|
|
|
cld
|
|
|
|
|
rep movsw
|
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;;---Sdvig-------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Set_reverse_napravlenie:
|
|
|
|
|
;;===Set_reverse_napravlenie===========================================================================================
|
|
|
|
|
|
|
|
|
|
mov eax, snake_dots
|
|
|
|
|
mov ebx, snake_dots+2
|
|
|
|
|
|
|
|
|
|
mov cl, [eax] ; The last dot x_coord
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov ch, [ebx] ; The pre_last dot x_coord
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
cmp cl, ch
|
2010-07-15 14:37:55 +02:00
|
|
|
|
je .X_ravny
|
|
|
|
|
|
|
|
|
|
cmp cl, 0
|
|
|
|
|
jne .skip2
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov dl, byte[g_w]
|
|
|
|
|
dec dl
|
|
|
|
|
cmp ch, dl
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jne .Normal_y_ravny
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], RIGHT
|
2010-07-15 14:37:55 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.skip2:
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov dl, byte[g_w]
|
|
|
|
|
dec dl
|
|
|
|
|
cmp cl, dl
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jne .Normal_y_ravny
|
2010-07-19 16:59:30 +02:00
|
|
|
|
cmp ch, 0
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jne .Normal_y_ravny
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], LEFT
|
2010-07-15 14:37:55 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.Normal_y_ravny:
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
cmp cl, ch
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jg .Napravlenie_to_right
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], LEFT
|
2010-07-15 14:37:55 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.Napravlenie_to_right:
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], RIGHT
|
2010-07-15 14:37:55 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.X_ravny:
|
|
|
|
|
inc eax
|
|
|
|
|
inc ebx
|
|
|
|
|
mov cl, [eax]
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov ch, [ebx]
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
|
|
|
|
cmp cl, 0
|
|
|
|
|
jne .skip3
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov dl, byte[g_h]
|
|
|
|
|
dec dl
|
|
|
|
|
cmp ch, dl
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jne .Normal_x_ravny
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], DOWN
|
2010-07-15 14:37:55 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.skip3:
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov dl, byte[g_h]
|
|
|
|
|
dec dl
|
|
|
|
|
cmp ch, dl
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jne .Normal_x_ravny
|
2010-07-19 16:59:30 +02:00
|
|
|
|
cmp ch, 0
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jne .Normal_x_ravny
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], UP
|
2010-07-15 14:37:55 +02:00
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
.Normal_x_ravny:
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
cmp cl, ch ; !!!
|
2010-07-15 14:37:55 +02:00
|
|
|
|
jg .Napravlenie_to_down ; 0 1 2 ...
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], UP ; 1
|
2010-07-15 14:37:55 +02:00
|
|
|
|
ret ; 2
|
|
|
|
|
; .
|
|
|
|
|
.Napravlenie_to_down: ; .
|
2010-07-19 16:59:30 +02:00
|
|
|
|
mov [snake_napravlenie_next], DOWN ; .
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
;;---Set_reverse_napravlenie-------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Snake_move:
|
|
|
|
|
;;===Snake_move========================================================================================================
|
|
|
|
|
;; in :
|
|
|
|
|
;; ax = coord's of new head
|
|
|
|
|
;; edx = snake_dots+[snake_length_x2]-2 (snake head)
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
add edx, 2
|
|
|
|
|
mov [edx], ax
|
|
|
|
|
cmp ax, word[eat]
|
|
|
|
|
jne .eat_and_new_head_are_different
|
|
|
|
|
|
|
|
|
|
add [snake_length_x2], 2
|
|
|
|
|
add [score], SCORE_EAT
|
|
|
|
|
dec word[number_of_free_dots]
|
|
|
|
|
cmp word[number_of_free_dots], 0
|
|
|
|
|
je Game_over
|
|
|
|
|
mov ax, word[eat]
|
|
|
|
|
mov cl, 1
|
|
|
|
|
call Draw_on_map
|
|
|
|
|
call Draw_head_prehead
|
|
|
|
|
call Get_eat
|
|
|
|
|
call Draw_eat
|
|
|
|
|
|
|
|
|
|
jmp Keys_done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.eat_and_new_head_are_different:
|
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
push ax
|
|
|
|
|
|
|
|
|
|
mov ax, word[snake_dots]
|
|
|
|
|
mov cl, 0
|
|
|
|
|
call Draw_on_map
|
|
|
|
|
|
|
|
|
|
pop ax
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
|
|
|
|
call Get_from_map
|
|
|
|
|
test bl, bl
|
|
|
|
|
jnz Game_over
|
|
|
|
|
|
|
|
|
|
mov cl, 1
|
|
|
|
|
call Draw_on_map
|
|
|
|
|
|
|
|
|
|
mov bx, word[snake_dots]
|
|
|
|
|
mov edx, [background_color]
|
|
|
|
|
call Draw_square
|
2010-07-19 16:59:30 +02:00
|
|
|
|
|
2010-07-15 14:37:55 +02:00
|
|
|
|
call Sdvig
|
|
|
|
|
|
|
|
|
|
call Draw_head_prehead
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Keys_done:
|
|
|
|
|
|
|
|
|
|
cmp [score], 0
|
|
|
|
|
je @f
|
|
|
|
|
dec [score]
|
|
|
|
|
call Draw_score_number
|
|
|
|
|
@@:
|
|
|
|
|
mcall 26, 9
|
|
|
|
|
mov [time_before_waiting], eax
|
|
|
|
|
mov eax, [time_wait_limit]
|
|
|
|
|
mov [time_to_wait], eax
|
2010-07-19 16:59:30 +02:00
|
|
|
|
jmp Level_body.still
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
2010-07-19 16:59:30 +02:00
|
|
|
|
;;---Snake_move------------------------------------------------------------------------------------------------------------
|
2010-07-15 14:37:55 +02:00
|
|
|
|
|
|
|
|
|
;;---Some_functions------------------------------------------------------------------------------------------------------------
|