snake: version 0.7

git-svn-id: svn://kolibrios.org@1677 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2010-10-24 19:11:32 +00:00
parent f165f88e77
commit 72eb0b5fb7
6 changed files with 1486 additions and 417 deletions

View File

@ -1,21 +1,23 @@
;;===First_menu_mode===========================================================================================================
First_menu:
mov byte[window_title+5], 0
mcall 71,1,window_title
mcall 40,111b ; set events: standart
mcall 66,1,1 ; set scan codes mode for keyboard
mov [is_new_record], 0
mov [lives], START_LIVES
call Show_cursor
mov [score], 0
call Set_first_level_of_play_mode
mov ebx, [time_wait_limit_const]
mov [time_wait_limit], ebx
.redraw:
call Set_geometry
mcall 12,1
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
call Draw_decorations
@ -68,16 +70,26 @@ First_menu:
.key: ; a key was pressed
mcall 2 ; get keycode
cmp ah, 0x1B ; Escape
cmp ah, 0x01 ; Escape
je Save_do_smth_else_and_exit
cmp ah, 0x0D ; Enter
cmp ah, 0x1C ; Enter
je Level_begin
cmp ah, 0x20 ; Space
cmp ah, 0x39 ; Space
jne @f
call Change_play_mode
call Delete_buttons
call Draw_buttons
jmp .still ; jump to wait for another event
@@:
cmp ah, [shortcut_increase]
jne @f
call Increase_geometry
jmp .redraw
@@:
cmp ah, [shortcut_decrease]
jne @f
call Decrease_geometry
jmp .redraw
@@:
jmp .still ; jump to wait for another event

View File

@ -2,6 +2,17 @@
Game_over:
cmp [play_mode], LEVELS_MODE
jne @f
dec [lives]
jz @f
call Draw_splash
jmp Level_begin
@@:
mov byte[window_title+5], 0
mcall 71,1,window_title
mcall 66,1,0 ; set ascii mode for keyboard
call Show_cursor
mov ebx, [score]
@ -22,13 +33,8 @@ Game_over:
mcall 40,100111b ; set events: standart + mouse
.redraw:
call Set_geometry
mcall 12,1
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
call Draw_decorations

View File

@ -4,6 +4,7 @@ Level_begin:
call Load_level
call Get_eat
mcall 66,1,1 ; set scan codes mode for keyboard
Level_body:
;;===Level_body========================================================================================================
@ -15,13 +16,8 @@ mcall 26, 9
mov [time_to_wait], eax
.redraw:
call Set_geometry
mcall 12,1
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
call Draw_decorations
@ -70,26 +66,83 @@ mcall 26, 9
shr eax, 8 ; ᤢ¨£ ¥¬ ॣ¨áâà eax ­  8 ¡¨â ¢¯à ¢®, çâ®¡ë ¯®«ãç¨âì ­®¬¥à ­ ¦ â®© ª­®¯ª¨
cmp eax, 1
je Save_do_smth_else_and_exit ; ¥á«¨ íâ® ­¥ ª­®¯ª  1 (§ à¥§¥à¢¨à®¢ ­  á¨á⥬®© ª ª ª­®¯ª  § ªàëâ¨ï ¯à®£à ¬¬ë), ¯à®¯ã᪠¥¬ 2 á«¥¤ãî騥 áâà®çª¨ ª®¤ 
je Save_do_smth_else_and_exit
jmp .still
.key:
mcall 2 ; get keycode
cmp ah, 0x1B ; Escape
;pushf
;pusha
;movzx eax, ah
;dph eax
;newline
;popa
;popf
cmp ah, 0x01 ; Escape
je First_menu
cmp ah, 0x20 ; Space
cmp ah, 0x39 ; Space
je Pause_mode
cmp ah, 0xB0 ; Left
cmp ah, 0x4B ; Left
je .key.left
cmp ah, 0xB1 ; Down
cmp ah, [shortcut_move_left] ; Left
je .key.left
cmp ah, 0x50 ; Down
je .key.down
cmp ah, 0xB2 ; Up
cmp ah, [shortcut_move_down] ; Down
je .key.down
cmp ah, 0x48 ; Up
je .key.up
cmp ah, 0xB3 ; Right
cmp ah, [shortcut_move_up] ; Up
je .key.up
cmp ah, 0x4D ; Right
je .key.right
cmp ah, [shortcut_move_right] ; Right
je .key.right
cmp ah, 0x4B+0x80 ; Left released
je .key.released.left
mov al, [shortcut_move_left]
add al, 0x80
cmp ah, al ; Left released
je .key.released.left
cmp ah, 0x50+0x80 ; Down released
je .key.released.down
mov al, [shortcut_move_down]
add al, 0x80
cmp ah, al ; Down released
je .key.released.down
cmp ah, 0x48+0x80 ; Up released
je .key.released.up
mov al, [shortcut_move_up]
add al, 0x80
cmp ah, al ; Up released
je .key.released.up
cmp ah, 0x4D+0x80 ; Right released
je .key.released.right
mov al, [shortcut_move_right]
add al, 0x80
cmp ah, al ; Right released
je .key.released.right
cmp ah, [shortcut_reverse]
jne @f
call Reverse_snake
jmp .still
@@:
cmp ah, [shortcut_increase]
jne @f
call Increase_geometry
jmp .redraw
@@:
cmp ah, [shortcut_decrease]
jne @f
call Decrease_geometry
jmp .redraw
@@:
jmp .still ; jump to wait for another event
@ -98,32 +151,77 @@ mcall 26, 9
bts [action], 0
jc @f
mov [time_to_wait], 0
@@:
cmp [smart_reverse], 1
jne @f
cmp [snake_direction], RIGHT
je .still
@@:
mov [snake_direction_next], LEFT
bts [acceleration_mask], LEFT
jc Game_step
jmp .still
.key.down:
bts [action], 0
jc @f
mov [time_to_wait], 0
@@:
cmp [smart_reverse], 1
jne @f
cmp [snake_direction], UP
je .still
@@:
mov [snake_direction_next], DOWN
bts [acceleration_mask], DOWN
jc Game_step
jmp .still
.key.up:
bts [action], 0
jc @f
mov [time_to_wait], 0
@@:
cmp [smart_reverse], 1
jne @f
cmp [snake_direction], DOWN
je .still
@@:
mov [snake_direction_next], UP
bts [acceleration_mask], UP
jc Game_step
jmp .still
.key.right:
bts [action], 0
jc @f
mov [time_to_wait], 0
@@:
cmp [smart_reverse], 1
jne @f
cmp [snake_direction], LEFT
je .still
@@:
mov [snake_direction_next], RIGHT
bts [acceleration_mask], RIGHT
jc Game_step
jmp .still
.key.released.left:
btr [acceleration_mask], LEFT
jmp .still
.key.released.down:
btr [acceleration_mask], DOWN
jmp .still
.key.released.up:
btr [acceleration_mask], UP
jmp .still
.key.released.right:
btr [acceleration_mask], RIGHT
jmp .still
@ -256,6 +354,7 @@ Draw_head_prehead:
mov bx, [esi]
mov edx, [snake_color]
call Draw_square
call Draw_lives_in_head
ret
@ -349,7 +448,7 @@ Get_eat:
;; out :
;; ax = coord's of the eat square (al=x, ah=y)
;;
mcall 26,9
; xor eax, esp
shl eax, 1
@ -502,8 +601,28 @@ Snake_move:
mov cl, 1
call Draw_on_map
call Draw_head_prehead
cmp [play_mode], CLASSIC_MODE
jne .is_not_classic_mode
dec byte[speed_up_counter]
jns @f
mov al, byte[speed_up_counter+1]
mov byte[speed_up_counter], al
cmp [time_wait_limit], 4
jl @f
dec [time_wait_limit]
@@:
.is_not_classic_mode:
cmp [play_mode], LEVELS_MODE
jne .is_not_levels_mode
cmp [snake_length_x2], (EAT_TO_END_LEVEL+3)*2
je .skip
.is_not_levels_mode:
call Get_eat
call Draw_eat
.skip:
jmp Keys_done
@ -519,6 +638,7 @@ Snake_move:
pop ax
call Get_from_map
test bl, bl
jnz Game_over
@ -606,17 +726,26 @@ Draw_splash:
dec cl
cmp cl, 0
jl @f
jl .picture
push eax ebx
mcall 5,PAUSE_WHILE_DRAWING_SPLASH
mcall 2
cmp ah, 0x39 ; Space
jne @f
pop ebx eax
jmp .draw
jmp .quit
@@:
cmp ah, 0x1C ; Enter
jne @f
pop ebx eax
jmp .quit
@@:
pop ebx eax
jmp .draw
.picture:
mov ax, 2*0x100+24
mov cx, 1*0x100+5
mov edx, [splash_level_string_color]
@ -632,7 +761,7 @@ Draw_splash:
@@:
test al, al
jz @f
add esi, 20
add esi, 5
dec al
jmp @b
@@:
@ -647,7 +776,7 @@ Draw_splash:
@@:
test ah, ah
jz @f
add esi, 20
add esi, 5
dec ah
jmp @b
@@:
@ -657,11 +786,62 @@ Draw_splash:
mov edx, [splash_level_number_color]
call Draw_picture
mcall 5,PAUSE_BETWEEN_LEVELS
mcall 26,9
mov [time_before_waiting], eax
mov [time_to_wait], PAUSE_BETWEEN_LEVELS
@@:
mcall 23,[time_to_wait]
mcall 2
cmp ah, 0x39 ; Space
je .quit
cmp ah, 0x1C ; Enter
je .quit
mcall 26,9
push eax
sub eax, [time_before_waiting]
pop [time_before_waiting]
sub [time_to_wait], eax
jns @b
.quit:
ret
;;---Draw_splash-----------------------------------------------------------------------------------------------------------
Draw_lives_in_head:
;;===Draw_lives_in_head====================================================================================================
cmp [play_mode], LEVELS_MODE
jne .quit
test [show_lives_style], 2
jz .quit
mov eax, snake_dots-2
add eax, [snake_length_x2]
mov ax, word[eax]
mov bl, ah
mul byte[g_s]
mov edx, [gbxm1]
add dx, ax
shl edx, 16
mov al, bl
mul byte[g_s]
mov dx, word[gbym1]
add dx, ax
mov eax, [g_s]
shl eax, 16
add eax, [g_s]
and eax, 0xfffefffe
shr eax, 1
add edx, eax
sub edx, 0x00020003
mcall 47,0x80010001,lives,,[lives_in_head_number_color]
.quit:
ret
;;---Draw_lives_in_head----------------------------------------------------------------------------------------------------
;;---Some_functions------------------------------------------------------------------------------------------------------------

View File

@ -2,19 +2,15 @@
Pause_mode:
mcall 66,1,1 ; set scan codes mode for keyboard
call Show_cursor
mov [action], 0
mov eax, [time_wait_limit]
mov [time_to_wait], eax
.redraw:
call Set_geometry
mcall 12,1
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
call Draw_decorations
@ -46,10 +42,20 @@ Pause_mode:
.key: ; a key was pressed
mcall 2 ; get keycode
cmp ah, 0x1B ; Escape - go to menu
cmp ah, 0x01 ; Escape - go to menu
je First_menu
cmp ah, 0x20 ; Space - resume game
cmp ah, 0x39 ; Space - resume game
je Level_body
cmp ah, [shortcut_increase]
jne @f
call Increase_geometry
jmp .redraw
@@:
cmp ah, [shortcut_decrease]
jne @f
call Decrease_geometry
jmp .redraw
@@:
jmp .still

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,53 @@
;;===Common_preferences=================================================
[Preferences]
Speed=80
; Delay between moves in ms (1/100 second)
; SLOW == 0 <= Speed <= 100 == FAST
Theme=Theme_standard
; Theme name to use
; See [Theme_*] sections below for available themes
; Name of any theme must be shorter than 30 chars
Smart_reverse=0
; 0 - disabled, 1 - eabled
; If this option is enabled, the snake may be reversed only by pressing Reverse key (see [Shortcuts] section)
; For example, if the snake is moving to the left and you press RIGHT key the snake will not move to the right
Show_lives_style=2
; 0 - do not show remaining lives
; 1 - show as a number in window title
; 2 - draw the number in snake head
; 3 - both 1 & 2
Draw_level_name_in_window_title=1
; 1 - yes, draw
; 0 - no
; This option includes drawing 'Classic mode' string in window title for classic mode (without levels)
Separating_symbol=/
; Symbol that separates 'Snake', '3 lives' and level name in window title
; 'Snake | 3 lives | Towers of Hanoi'
; 'Snake - 3 lives
; 'Snake / Towers of Hanoi'
; or smth like these ones
;;---Common_preferences-------------------------------------------------
;;===Shortcuts==========================================================
[Shortcuts]
; Keys of moving. These ones are in addition to the standard combination of arrows.
; VIM-like navigation is used by default.
Move_left = h
Move_down = j
Move_up = k
Move_right = l
; Snake reverse key
Reverse = Tab
; Increare/decrease field keys
Increase = u
Decrease = i
;;---Shortcuts----------------------------------------------------------
;;===Visual_themes======================================================
[Theme_standard]
; all these keys are optional
Decorations = 2
Decorations = 3
; 0 = nothing
; 1 = grid_lines
; 2 = grid_lines_with_ends
@ -29,6 +65,8 @@ Decorations_color = 170,170,0
Snake_color = 17,17,255
Snake_head_color = 107,107,255
; by default Snake_head_color is equal to Snake_color, so the snake has no head
Lives_in_head_number_color= 255,136,0
; color of the number in snake head which represents remaining lives
Snake_picture_color = 68,136,255
; color of big 'SNAKE' label at start menu
Version_picture_color = 85,255,85
@ -75,6 +113,7 @@ Background_color = 245,245,245
Decorations_color = 55,55,55
Snake_color = 225,125,225
Snake_head_color = 255,125,55
Lives_in_head_number_color= 255,255,255
Snake_picture_color = 105,155,205
Version_picture_color = 155,255,0
Pause_picture_color = 75,255,75
@ -106,6 +145,7 @@ Background_color = 255,255,255
Decorations_color = 0,0,0
Snake_color = 30,30,30
Snake_head_color = 30,30,30
Lives_in_head_number_color= 255,255,255
Snake_picture_color = 30,30,30
Version_picture_color = 70,70,70
Pause_picture_color = 30,30,30
@ -137,6 +177,7 @@ Background_color = 0,0,0
Decorations_color = 255,255,255
Snake_color = 255,255,255
Snake_head_color = 255,255,255
Lives_in_head_number_color= 30,30,30
Snake_picture_color = 255,255,255
Version_picture_color = 225,225,225
Pause_picture_color = 225,225,225
@ -172,4 +213,5 @@ Square_side_length=19
Champion_name_classic=
Hiscore_classic=777
Champion_name_levels=
Hiscore_levels=222
Hiscore_levels=222
;;---Reserved_Section---------------------------------------------------