From bec452628455a5e02b0d88c819a505a66cfb7c68 Mon Sep 17 00:00:00 2001 From: Ivan Baravy Date: Thu, 15 Jul 2010 12:37:55 +0000 Subject: [PATCH] snake: new game git-svn-id: svn://kolibrios.org@1518 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/games/snake/trunk/build_en.bat | 5 + programs/games/snake/trunk/first_menu.asm | 88 +++ programs/games/snake/trunk/game_over.asm | 137 +++++ programs/games/snake/trunk/level.asm | 529 ++++++++++++++++ programs/games/snake/trunk/makefile | 2 + programs/games/snake/trunk/pause.asm | 80 +++ programs/games/snake/trunk/snake.asm | 704 ++++++++++++++++++++++ programs/games/snake/trunk/snake.ini | 101 ++++ 8 files changed, 1646 insertions(+) create mode 100644 programs/games/snake/trunk/build_en.bat create mode 100644 programs/games/snake/trunk/first_menu.asm create mode 100644 programs/games/snake/trunk/game_over.asm create mode 100644 programs/games/snake/trunk/level.asm create mode 100644 programs/games/snake/trunk/makefile create mode 100644 programs/games/snake/trunk/pause.asm create mode 100644 programs/games/snake/trunk/snake.asm create mode 100644 programs/games/snake/trunk/snake.ini diff --git a/programs/games/snake/trunk/build_en.bat b/programs/games/snake/trunk/build_en.bat new file mode 100644 index 0000000000..d65e0cf13f --- /dev/null +++ b/programs/games/snake/trunk/build_en.bat @@ -0,0 +1,5 @@ +@erase lang.inc +@echo lang fix en >lang.inc +@fasm snake.asm snake +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/games/snake/trunk/first_menu.asm b/programs/games/snake/trunk/first_menu.asm new file mode 100644 index 0000000000..b6e391f9e5 --- /dev/null +++ b/programs/games/snake/trunk/first_menu.asm @@ -0,0 +1,88 @@ +;;===First_menu_mode=========================================================================================================== + +First_menu: + + mov [snake_length_x2], 6 + mov word[snake_dots], 0x0303 + mov dword[snake_dots+2], 0x03050304 + mov [snake_napravlenie], 3 + mov [snake_napravlenie_next], 3 + +Redraw_window: + mcall 12,1 + mcall 0,200*65536+WINDOW_WIDTH,326*65536+WINDOW_HEIGHT,[window_style], ,window_title + + call Draw_decorations + call Draw_first_menu_picture + call Draw_menu_strings + + mcall 12,2 + +Wait_for_event: + mcall 10 ; wait for event + ; ok, what an event? + dec al ; has the window been moved or resized? + jz Redraw_window ; + dec al ; was a key pressed? + jz Is_key ; + + +Is_button: ; a button was pressed + mcall 17 ; get button number + shr eax, 8 ; we should do it to get the real button code + + cmp eax, 1 ; is it close button? + je Exit ; if so, jump to quit... + + jmp Wait_for_event ; jump to wait for another event + + +Is_key: ; a key was pressed + mcall 2 ; get keycode + + cmp ah, 0x1B ; Escape + je Exit + cmp ah, 0x0D ; Enter + je Level_begin + cmp ah, 0x20 ; Space + je Level_begin + + jmp Wait_for_event ; jump to wait for another event + +;;---First_menu_mode----------------------------------------------------------------------------------------------------------- + + +;;===Some_functions============================================================================================================ + +Draw_first_menu_picture: + ;;===Draw_first_menu_picture================================================================================================ + + mov al, 5 + mov bh, 0 + mov ecx, picture_first_menu_snake + mov edx, [snake_picture_color] + call Draw_picture + + mov al, 4 + mov bh, 7 + mov ecx, picture_first_menu_version + mov edx, [version_picture_color] + call Draw_picture + + ret + + ;;---Draw_first_menu_picture------------------------------------------------------------------------------------------------ + + +Draw_menu_strings: + ;;===Make_menu_strings========================================================================================= + + mcall 4,153*65536+BOTTOM_MIDDLE_STRINGS,[navigation_strings_color],press_to_start + mcall ,213*65536+TOP_STRINGS,[navigation_strings_color],press_esc_to_exit +; mcall ,406*65536+TOP_STRINGS,[navigation_strings_color],press_F2_to_options + + ret + + ;;---Make_menu_strings----------------------------------------------------------------------------------------- + +;;---Some_functions------------------------------------------------------------------------------------------------------------ \ No newline at end of file diff --git a/programs/games/snake/trunk/game_over.asm b/programs/games/snake/trunk/game_over.asm new file mode 100644 index 0000000000..ef27bed2f5 --- /dev/null +++ b/programs/games/snake/trunk/game_over.asm @@ -0,0 +1,137 @@ +;;===Game_over_mode============================================================================================================ + +Game_over: + + mov ebx, [score] + cmp ebx, [hi_score] + jng Game_over_Redraw + + mov [is_new_record], 1 + + mcall 40,100111b ; set events: standart + mouse + +Game_over_Redraw: + mcall 12,1 + mcall 0,200*65536+WINDOW_WIDTH,326*65536+WINDOW_HEIGHT,[window_style], ,window_title + + cmp [is_new_record], 1 + jnz @f + push dword edit1 + call [edit_box.draw] + @@: + + call Draw_decorations + call Draw_game_over_picture + call Draw_game_over_strings + + mcall 12,2 + +Game_over_Wait_for_event: + mcall 10 ; wait for event + ; ok, what an event? + dec al ; has the window been moved or resized? + jz Game_over_Redraw + dec al ; was a key pressed? + jz Game_over_key + dec al ; was a button pressed? + jz Game_over_button + + +Game_over_mouse: ; mouse event received + push dword edit1 + call [edit_box.mouse] + + jmp Game_over_Wait_for_event + + +Game_over_key: ; a key was pressed + mcall 2 ; get keycode + + cmp [is_new_record], 1 + jnz .skip + + cmp ah, 0x0D ; Enter + jnz @f + call Score_and_name_store + mov [is_new_record], 0 + mcall 40,111b ; set events: standart + jmp First_menu + + @@: + push dword edit1 + call [edit_box.key] + + jmp Game_over_Wait_for_event + .skip: + + cmp ah, 0x1B ; Escape - go to menu + jne Game_over_Wait_for_event + + mcall 40,111b ; set events: standart + jmp First_menu + + +Game_over_button: ; a button was pressed + mcall 17 ; get button number + shr eax, 8 ; we should do it to get the real button code + + cmp eax, 1 + je Exit + + jmp Game_over_Wait_for_event + +;;---Game_over_mode------------------------------------------------------------------------------------------------------------ + + +;;===Some_functions============================================================================================================ + +Draw_game_over_picture: + ;;===Draw_game_over_picture================================================================================================ + + mov al, 11 + mov bh, 0 + mov ecx, picture_game_over + mov edx, [game_over_picture_color] + call Draw_picture + + ret + + ;;---Draw_game_over_picture------------------------------------------------------------------------------------------------ + + +Draw_game_over_strings: + ;;===Draw_game_over_strings================================================================================================ + + + + cmp [is_new_record], 1 + jnz @f + + mcall 4,40*65536+BOTTOM_TOP_STRINGS,[game_over_strings_color],string_congratulations + mcall ,244*65536+BOTTOM_BOTTOM_STRINGS, ,string_enter_your_name + mcall ,210*65536+TOP_STRINGS,[navigation_strings_color],string_apply_name_enter + mcall 47,0x00070000,[score],(399)*65536+BOTTOM_TOP_STRINGS,[game_over_hiscore_color] + + ret + + @@: + + call Draw_menu_esc + + ret + + ;;---Draw_game_over_strings------------------------------------------------------------------------------------------------ + + +Score_and_name_store: + ;;===Name_store============================================================================================================ + + + invoke ini.set_str, cur_dir_path, aScore, aChampion_name, hed, 15 + invoke ini.set_int, cur_dir_path, aScore, aHiscore, [score] + + ret + + ;;---Name_store------------------------------------------------------------------------------------------------------------ + +;;---Some_functions------------------------------------------------------------------------------------------------------------ \ No newline at end of file diff --git a/programs/games/snake/trunk/level.asm b/programs/games/snake/trunk/level.asm new file mode 100644 index 0000000000..8969114d43 --- /dev/null +++ b/programs/games/snake/trunk/level.asm @@ -0,0 +1,529 @@ +;;===Level_mode================================================================================================================ + +Level_begin: + + mov [score], 0 + mov [action], 0 + mov [number_of_free_dots], GRID_WIDTH*GRID_HEIGHT-3 + + 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 + mov ecx, GRID_WIDTH*GRID_HEIGHT/4 + rep movsd + +Level_body: + ;;===Level_body======================================================================================================== + +mcall 26, 9 + mov [time_before_waiting], eax + mov eax, [time_wait_limit] + mov [time_to_wait], eax + + Redraw: + mcall 12,1 + mcall 0,200*65536+WINDOW_WIDTH,326*65536+WINDOW_HEIGHT,[window_style], ,window_title + + call Draw_decorations + call Draw_snake + call Draw_eat + call Draw_level_strings + + mcall 12,2 + + Waiting: + 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 + jmp Waiting + @@: + + Message: ; ok, what an event? + dec al ; has the window been moved or resized? + jz Redraw ; + dec al ; was a key pressed? + jz Key ; + dec al ; was a button pressed? + jz Button ; + + + Key: + mcall 2 ; get keycode + + cmp ah, 0x1B ; Escape + je First_menu + cmp ah, 0x20 ; Space + je Pause_mode + cmp ah, 0xB0 ; Left + je .left + cmp ah, 0xB1 ; Down + je .down + cmp ah, 0xB2 ; Up + je .up + cmp ah, 0xB3 ; Right + je .right + + jmp Waiting ; jump to wait for another event + + + .left: + cmp [action], 0 + jne @f + mov [time_to_wait], 0 + @@: + mov [action], 1 + mov [snake_napravlenie_next], 0 + jmp Waiting + + .down: + cmp [action], 0 + jne @f + mov [time_to_wait], 0 + @@: + mov [action], 1 + mov [snake_napravlenie_next], 1 + jmp Waiting + + .up: + cmp [action], 0 + jne @f + mov [time_to_wait], 0 + @@: + mov [action], 1 + mov [snake_napravlenie_next], 2 + jmp Waiting + + .right: + cmp [action], 0 + jne @f + mov [time_to_wait], 0 + @@: + mov [action], 1 + mov [snake_napravlenie_next], 3 + jmp Waiting + + + Button: ; процедура обрабоки кнопок в программе + mcall 17 ; функция 17: получить номер нажатой кнопки + + shr eax, 8 ; сдвигаем регистр eax на 8 бит вправо, чтобы получить номер нажатой кнопки + cmp eax, 1 + je Exit ; если это не кнопка 1 (зарезервирована системой как кнопка закрытия программы), пропускаем 2 следующие строчки кода + + jmp Waiting + + + 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 + mov al, GRID_WIDTH-1 + @@: + jmp Snake_move + + .to_down: + mov [snake_napravlenie], DOWN + mov ax, [edx] + inc ah + cmp ah, GRID_HEIGHT + jne @f + mov ah, 0 + @@: + jmp Snake_move + + .to_up: + mov [snake_napravlenie], UP + mov ax, [edx] + dec ah + cmp ah, -1 + jne @f + mov ah, GRID_HEIGHT-1 + @@: + jmp Snake_move + + .to_right: + mov [snake_napravlenie], RIGHT + mov ax, [edx] + inc al + cmp al, GRID_WIDTH + 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================================================================================================ + + call Draw_menu_esc + call Draw_score_string + call Draw_score_number ; Draw score (number) + call Draw_hiscore_string + call Draw_hiscore_number + call Draw_champion_string + call Draw_champion_name + + mcall 4,225*65536+BOTTOM_MIDDLE_STRINGS,[navigation_strings_color],string_pause_space ; Draw 'PAUSE - SPACE' string + + 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 + + dec cx + add esi, 2 + sub edi, 2 + + test cx, cx + 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 + mov bl, GRID_WIDTH + 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 + mov dl, [ebx] ; The pre_last dot x_coord + + cmp cl, dl + je .X_ravny + + cmp cl, 0 + jne .skip2 + + cmp dl, 23 + jne .Normal_y_ravny + mov [snake_napravlenie_next], 3 + ret + + .skip2: + cmp cl, 23 + jne .Normal_y_ravny + cmp dl, 0 + jne .Normal_y_ravny + mov [snake_napravlenie_next], 0 + ret + + .Normal_y_ravny: + + cmp cl, dl + jg .Napravlenie_to_right + mov [snake_napravlenie_next], 0 + ret + + .Napravlenie_to_right: + mov [snake_napravlenie_next], 3 + ret + + .X_ravny: + inc eax + inc ebx + mov cl, [eax] + mov dl, [ebx] + + cmp cl, 0 + jne .skip3 + + cmp dl, 10 + jne .Normal_x_ravny + mov [snake_napravlenie_next], 1 + ret + + .skip3: + cmp cl, 10 + jne .Normal_x_ravny + cmp dl, 0 + jne .Normal_x_ravny + mov [snake_napravlenie_next], 2 + ret + + .Normal_x_ravny: + + cmp cl, dl ; !!! + jg .Napravlenie_to_down ; 0 1 2 ... + mov [snake_napravlenie_next], 2 ; 1 + ret ; 2 + ; . + .Napravlenie_to_down: ; . + mov [snake_napravlenie_next], 1 ; . + + 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: + + mov ecx, snake_dots-4 + add ecx, [snake_length_x2] + + 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 + + mov ax, word[snake_dots] + mov cl, 0 + call Draw_on_map + 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 + jmp Waiting + + ;;---Snake_move-------------------------------------------------------------------------------------------------------- + +;;---Some_functions------------------------------------------------------------------------------------------------------------ \ No newline at end of file diff --git a/programs/games/snake/trunk/makefile b/programs/games/snake/trunk/makefile new file mode 100644 index 0000000000..9556c1a32c --- /dev/null +++ b/programs/games/snake/trunk/makefile @@ -0,0 +1,2 @@ +snake : snake.asm first_menu.asm level.asm pause.asm game_over.asm + fasm snake.asm snake diff --git a/programs/games/snake/trunk/pause.asm b/programs/games/snake/trunk/pause.asm new file mode 100644 index 0000000000..0952beb17c --- /dev/null +++ b/programs/games/snake/trunk/pause.asm @@ -0,0 +1,80 @@ +;;===Pause_mode================================================================================================================ + +Pause_mode: + + mov [action], 0 + mov eax, [time_wait_limit] + mov [time_to_wait], eax + +Pause_Redraw_window: + mcall 12,1 + mcall 0,200*65536+WINDOW_WIDTH,326*65536+WINDOW_HEIGHT,[window_style], ,window_title + + call Draw_decorations + call Draw_pause_picture + call Draw_pause_strings + + mcall 12,2 + + +Pause_Wait_for_event: + mcall 10 ; wait for event + ; ok, what an event? + dec al ; has the window been moved or resized? + jz Pause_Redraw_window + dec al ; was a key pressed? + jz Pause_Is_key + + +Pause_Is_button: ; a button was pressed + mcall 17 ; get button number + shr eax, 8 ; we should do it to get the real button code + + cmp eax, 1 + je Exit + + jmp Pause_Wait_for_event + + +Pause_Is_key: ; a key was pressed + mcall 2 ; get keycode + + cmp ah, 0x1B ; Escape - go to menu + je First_menu + cmp ah, 0x20 ; Space - resume game + je Level_body + + jmp Pause_Wait_for_event + +;;---Pause_mode---------------------------------------------------------------------------------------------------------------- + + +;;===Some_functions============================================================================================================ + +Draw_pause_picture: + ;;===Draw_pause_picture======================================================================================================== + + mov al, 6 + mov bh, 2 + mov ecx, picture_pause + mov edx, [pause_picture_color] + call Draw_picture + + ret + + ;;---Draw_pause_picture-------------------------------------------------------------------------------------------------------- + + +Draw_pause_strings: + ;;===Draw_pause_strings================================================================================================ + + mcall 4,219*65536+BOTTOM_MIDDLE_STRINGS,[navigation_strings_color],string_resume_space ; Show 'RESUME - SPACE' string + + call Draw_menu_esc ; Show 'MENU - ESC' string + + + ret + + ;;---Draw_pause_strings------------------------------------------------------------------------------------------------ + +;;---Some_functions------------------------------------------------------------------------------------------------------------ \ No newline at end of file diff --git a/programs/games/snake/trunk/snake.asm b/programs/games/snake/trunk/snake.asm new file mode 100644 index 0000000000..58e28df7c2 --- /dev/null +++ b/programs/games/snake/trunk/snake.asm @@ -0,0 +1,704 @@ +;;===HEADER==================================================================================================================== + +use32 + org 0x0 + db 'MENUET01' + dd 0x1,start,i_end,d_end,stacktop,0x0,cur_dir_path + +;;---HEADER-------------------------------------------------------------------------------------------------------------------- + +include '../../../proc32.inc' +include '../../../macros.inc' +include '../../../system/launch/trunk/mem.inc' +include '../../../develop/libraries/libs-dev/.test/dll.inc' +include '../../../develop/libraries/box_lib/trunk/box_lib.mac' + +;;===Define_chapter============================================================================================================ + +WINDOW_WIDTH equ 550 +WINDOW_HEIGHT equ 320 +GRID_STEP equ 20 +GRID_BEGIN_X equ 31 +GRID_BEGIN_Y equ 31 +GRID_WIDTH equ 24 +GRID_HEIGHT equ 11 +GRID_ENDS_WIDTH equ 13 + +BOTTOM_TOP_STRINGS equ 270 +BOTTOM_MIDDLE_STRINGS equ 276 +BOTTOM_BOTTOM_STRINGS equ 282 +TOP_STRINGS equ 5 + +SCORE_EAT equ 100 + +LEFT equ 0 +DOWN equ 1 +UP equ 2 +RIGHT equ 3 + +;;---Define_chapter------------------------------------------------------------------------------------------------------------ + +start: + +stdcall dll.Load,@IMPORT + or eax, eax + jnz Exit + +align 4 + + mov eax, cur_dir_path + @@: + cmp byte[eax], 0 + jz @f + inc eax + jmp @b + @@: + mov dword[eax], '.ini' + + invoke ini.get_int, cur_dir_path, aPreferences, aSpeed, 70 + neg eax + add [time_wait_limit], eax + invoke ini.get_int, cur_dir_path, aPreferences, aDecorations, 1 + mov [decorations], al + + invoke ini.get_color, cur_dir_path, aColors, aBackground_color, 0x000000 + or [background_color], eax + or [window_style], eax + invoke ini.get_color, cur_dir_path, aColors, aDecorations_color, 0x00aaaa00 + or [decorations_color], eax + invoke ini.get_color, cur_dir_path, aColors, aSnake_color, 0x1111ff + or [snake_color], eax + invoke ini.get_color, cur_dir_path, aColors, aSnake_head_color, 0x1111ff + or [snake_head_color], eax + invoke ini.get_color, cur_dir_path, aColors, aSnake_picture_color, 0x4488ff + or [snake_picture_color], eax + invoke ini.get_color, cur_dir_path, aColors, aVersion_picture_color, 0x55ff55 + or [version_picture_color], eax + invoke ini.get_color, cur_dir_path, aColors, aPause_picture_color, 0x11ff11 + or [pause_picture_color], eax + invoke ini.get_color, cur_dir_path, aColors, aGame_over_picture_color, 0xff1111 + or [game_over_picture_color], eax + invoke ini.get_color, cur_dir_path, aColors, aEat_color, 0xffff11 + or [eat_color], eax + invoke ini.get_color, cur_dir_path, aColors, aNavigation_strings_color, 0x80ff7777 + or [navigation_strings_color], eax + invoke ini.get_color, cur_dir_path, aColors, aGame_over_strings_color, 0x80ff9900 + or [game_over_strings_color], eax + invoke ini.get_color, cur_dir_path, aColors, aScore_string_color, 0x80ffffff + or [score_string_color], eax + invoke ini.get_color, cur_dir_path, aColors, aHiscore_string_color, 0x80ffffff + or [hiscore_string_color], eax + invoke ini.get_color, cur_dir_path, aColors, aChampion_string_color, 0x80ffffff + or [champion_string_color], eax + invoke ini.get_color, cur_dir_path, aColors, aGame_over_hiscore_color, 0x80ffdd44 + or [game_over_hiscore_color], eax + invoke ini.get_color, cur_dir_path, aColors, aScore_number_color, 0xffffff + or [score_number_color], eax + invoke ini.get_color, cur_dir_path, aColors, aHiscore_number_color, 0x00ffffff + or [hiscore_number_color], eax + invoke ini.get_color, cur_dir_path, aColors, aChampion_name_color, 0x80ffffff + or [champion_name_color], eax + +include 'first_menu.asm' ; First menu body and functions +include 'level.asm' ; Level body and functions (game process) +include 'pause.asm' ; Pause body and functions +include 'game_over.asm' ; Game_over body and functions + +;;===Some_functions============================================================================================================ + +Exit: + ;;===Exit============================================================================================================== + + or eax, -1 + int 0x40 + + ;;---Exit-------------------------------------------------------------------------------------------------------------- + + +Draw_decorations: + ;;===Draw_decorations================================================================================================== + + cmp [decorations], 1 + je grid_lines + cmp [decorations], 2 + je grid_lines_with_ends + cmp [decorations], 3 + je grid_lines_with_corners + cmp [decorations], 4 + je grid_dots + cmp [decorations], 5 + je borders_lines + cmp [decorations], 6 + je borders_lines_with_ends + cmp [decorations], 7 + je borders_dots + cmp [decorations], 8 + je corners_dots + cmp [decorations], 9 + je corners_inner + cmp [decorations], 10 + je corners_outer + cmp [decorations], 11 + je corners_crosses + ret + + + grid_lines: + + mov eax, 38 + mov ebx, (GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1) + mov ecx, (GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP) + mov edx, [decorations_color] + + @@: + mcall + add ebx, GRID_STEP*65536+GRID_STEP + cmp ebx, (GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP)*65536+(GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP) + jng @b + + mov ebx, (GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP) + mov ecx, (GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1) + + @@: + mcall + add ecx, GRID_STEP*65536+GRID_STEP + cmp ecx, (GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP)*65536+(GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP) + jng @b + + ret + + + grid_lines_with_ends: + + mov eax, 38 + mov ebx, (GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1) + mov ecx, (GRID_BEGIN_Y-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP+GRID_ENDS_WIDTH) + mov edx, [decorations_color] + + @@: + mcall + add ebx, GRID_STEP*65536+GRID_STEP + cmp ebx, (GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP)*65536+(GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP) + jng @b + + mov ebx, (GRID_BEGIN_X-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP+GRID_ENDS_WIDTH) + mov ecx, (GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1) + + @@: + mcall + add ecx, GRID_STEP*65536+GRID_STEP + cmp ecx, (GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP)*65536+(GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP) + jng @b + + ret + + + grid_lines_with_corners: + + call grid_lines + call corners_outer + + ret + + + grid_dots: + + mov eax, 1 + mov ebx, GRID_BEGIN_X-1 + mov ecx, GRID_BEGIN_Y-1 + mov edx, [decorations_color] + + @@: + mcall + add ebx, GRID_STEP + cmp ebx, GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1 + jng @b + add ecx, GRID_STEP + cmp ecx, GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1 + jg @f + mov ebx, GRID_BEGIN_X-1 + jmp @b + + @@: + ret + + + borders_lines: + + mcall 38,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1),17*65536+263,[decorations_color] + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1), , + mcall ,17*65536+523,(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1) + mcall ,17*65536+523,(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1) + + ret + + + borders_lines_with_ends: + + call borders_lines + call corners_outer + + ret + + + borders_dots: + + mov eax, 1 + mov ebx, GRID_BEGIN_X-1 + mov ecx, GRID_BEGIN_Y-1 + mov edx, [decorations_color] + @@: + mcall + add ebx, GRID_STEP + cmp ebx, GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP + jng @b + + mov ebx, GRID_BEGIN_X-1 + mov ecx, GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP + @@: + mcall + add ebx, GRID_STEP + cmp ebx, GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP + jng @b + + mov ebx, GRID_BEGIN_X-1 + mov ecx, GRID_BEGIN_Y-1 + @@: + mcall + add ecx, GRID_STEP + cmp ecx, GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP + jng @b + + mov ebx, GRID_BEGIN_X-1+GRID_WIDTH*GRID_STEP + mov ecx, GRID_BEGIN_Y-1 + @@: + mcall + add ecx, GRID_STEP + cmp ecx, GRID_BEGIN_Y-1+GRID_HEIGHT*GRID_STEP + jng @b + + ret + + + corners_dots: + + mcall 13,(GRID_BEGIN_X-2)*65536+2,(GRID_BEGIN_Y-2)*65536+2,[decorations_color] + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+2,(GRID_BEGIN_Y-2)*65536+2, + mcall 13,(GRID_BEGIN_X-2)*65536+2,(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+2, + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+2,(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+2, + + ret + + + corners_inner: + + mcall 38,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1+GRID_ENDS_WIDTH),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1),[decorations_color] + mcall ,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1+GRID_ENDS_WIDTH),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1), + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-GRID_ENDS_WIDTH-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1), + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-GRID_ENDS_WIDTH-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1), + mcall ,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1+GRID_ENDS_WIDTH), + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1+GRID_ENDS_WIDTH), + mcall ,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-GRID_ENDS_WIDTH-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1), + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-GRID_ENDS_WIDTH-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1), + + ret + + + corners_outer: + + mcall 38,(GRID_BEGIN_X-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1),[decorations_color] + mcall ,(GRID_BEGIN_X-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1), + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1+GRID_ENDS_WIDTH),(GRID_BEGIN_Y-1)*65536+(GRID_BEGIN_Y-1), + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1+GRID_ENDS_WIDTH),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1), + mcall ,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_Y-1), + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y-1-GRID_ENDS_WIDTH)*65536+(GRID_BEGIN_Y-1), + mcall ,(GRID_BEGIN_X-1)*65536+(GRID_BEGIN_X-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1+GRID_ENDS_WIDTH), + mcall ,(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1)*65536+(GRID_BEGIN_X+GRID_WIDTH*GRID_STEP-1),(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1)*65536+(GRID_BEGIN_Y+GRID_HEIGHT*GRID_STEP-1+GRID_ENDS_WIDTH), + + ret + + + corners_crosses: + + call corners_inner + call corners_outer + + ret + + + ;;---Draw_decorations-------------------------------------------------------------------------------------------------- + + +Draw_square: + ;;===Draw_square======================================================================================================= + ;; bl - x_coord + ;; bh - y_coord + ;; edx - color + + mov cl, bh + + mov al, 20 + mul bl + mov bx, ax + add bx, 31 + shl ebx, 16 + add ebx, 19 + + mov al, 20 + mul cl + mov cx, ax + add cx, 31 + shl ecx, 16 + add ecx, 19 + + mcall 13 + + ret + + ;;---Draw_square------------------------------------------------------------------------------------------------------- + + +Draw_menu_esc: + ;;===Draw_menu_esc===================================================================================================== + + mcall 4,234*65536+TOP_STRINGS,[navigation_strings_color],string_menu_esc + + ret + + ;;---Draw_menu_esc----------------------------------------------------------------------------------------------------- + + +Draw_score_string: + ;;===Draw_score_string================================================================================================= + + mcall 4,56*65536+BOTTOM_TOP_STRINGS,[score_string_color],string_score + + ret + + ;;---Draw_score_string------------------------------------------------------------------------------------------------- + + +Draw_score_number: + ;;===Draw_score_number================================================================================================= + + mcall 47,0x00070000,[score],104*65536+BOTTOM_TOP_STRINGS,[score_number_color],[background_color] + + ret + + ;;---Draw_score_number------------------------------------------------------------------------------------------------- + + +Draw_hiscore_string: + ;;===Draw_hiscore_string=============================================================================================== + + mcall 4,376*65536+BOTTOM_TOP_STRINGS,[hiscore_string_color],string_hi_score + + ret + + ;;---Draw_hiscore_string----------------------------------------------------------------------------------------------- + + +Draw_hiscore_number: + ;;===Draw_hiscore_number=============================================================================================== + + mcall 47,0x00070000,[hi_score],442*65536+BOTTOM_TOP_STRINGS,[hiscore_number_color] + + ret + + ;;---Draw_hiscore_number----------------------------------------------------------------------------------------------- + + +Draw_champion_string: + ;;===Draw_champion_string============================================================================================== + + mcall 4,376*65536+BOTTOM_BOTTOM_STRINGS,[champion_string_color],string_champion + + ret + + ;;---Draw_champion_string---------------------------------------------------------------------------------------------- + + +Draw_champion_name: + ;;===Draw_champion_name================================================================================================ + + mcall 4,442*65536+BOTTOM_BOTTOM_STRINGS,[champion_name_color],champion_name + + ret + + ;;---Draw_champion_name------------------------------------------------------------------------------------------------ + + +Draw_picture: + ;;===Draw_picture====================================================================================================== + ;; in : + ;; al = picture height (in squares) + ;; bh = number of top square + ;; ecx = pointer to picture data + ;; edx = picture color + ;; + + .draw: + xor bl, bl + + .loop: + cmp byte[ecx], 0 + jz @f + push eax ebx ecx + call Draw_square + pop ecx ebx eax + + @@: + inc ecx + inc bl + cmp bl, GRID_WIDTH + jne .loop + + dec al + test al, al + jnz @f + ret + @@: + inc bh + jmp .draw + + + ;;---Draw_picture------------------------------------------------------------------------------------------------------ + + +Draw_on_map: + ;;===Draw_on_map======================================================================================================= + ;; in : + ;; al = x coord + ;; ah = y coord + ;; cl = value to draw + ;; + + and eax, 0x0000ffff + xor bx, bx + mov bl, al + shr ax, 8 + mov dx, 24 + mul dx + add ax, bx + mov edi, field_map + add edi, eax + mov [edi], cl + + ret + + ;;---Draw_on_map------------------------------------------------------------------------------------------------------- + + +Get_from_map: + ;;===Get_from_map====================================================================================================== + ;; in : + ;; al = x coord + ;; ah = y coord + ;; out : + ;; al = value on map + ;; + + push eax + + and eax, 0x0000ffff + xor bx, bx + mov bl, al + shr ax, 8 + mov dx, 24 + mul dx + add ax, bx + mov edi, field_map + add edi, eax + mov bl, [edi] + + pop eax + + ret + + ;;---Get_from_map------------------------------------------------------------------------------------------------------ + + +;;---Some_functions-------------------------------------------------------------------------------------------------------- + + +;;===Variables============================================================================================================= + +window_title db 'Snake',0 +window_style dd 0x34000000 +time_before_waiting dd 0x0 +time_to_wait dd 0x0 +time_wait_limit dd 101 +decorations db 0x0 +number_of_free_dots dw 0x0 + +field_map db 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,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,0,0,0,0,0,0,0,0,\ + 0,0,0,1,1,1,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,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,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,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,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,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 + +string_score db 'SCORE :',0 +string_hi_score db 'HI-SCORE :',0 +string_player db 'PLAYER :',0 +string_champion db 'CHAMPION :',0 +string_level db 'LEVEL :',0 +string_pause_space db 'PAUSE - ',0x27,'SPACE',0x27,0 +string_resume_space db 'RESUME - ',0x27,'SPACE',0x27,0 +string_menu_esc db 'MENU - ',0x27,'ESC',0x27,0 +string_apply_name_enter db 'APPLY NAME - ',0x27,'ENTER',0x27,0 + +champion_name db 'dunkaist',0x20,0x20,0x20,0x20,0x20,0x20,0x20,0 + +press_to_start db '...PRESS ',0x27,'SPACE',0x27,' OR ',0x27,'ENTER',0x27,' TO START...',0 +press_esc_to_exit db 'PRESS ',0x27,'ESC',0x27,' TO EXIT',0 +;press_F2_to_options db 'PRESS ',0x27,'F2',0x27,' TO OPTIONS',0 + +snake_dots db 3,3, 4,3, 5,3, 522 dup (0) ; 264 dots +snake_napravlenie db 3 +snake_napravlenie_next db 3 +snake_length_x2 dd 6 + +eat db 0,0 + +score dd 0 +hi_score dd 777 +is_new_record db 0 + +action db 0 + +string_congratulations db 'Congratulations!!! You are the champion!! New hi-score is :',0 +string_enter_your_name db 'Enter your name, please :',0 + +picture_first_menu_snake db 1,1,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,1,1,\ + 1,0,0,0,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,0,1,\ + 1,1,1,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,0,1,1,1,1,\ + 0,0,0,1,0,1,0,1,1,0,1,1,1,1,0,1,0,1,0,0,1,0,0,0,\ + 1,1,1,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,1,1,1 + +picture_first_menu_version db 0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,\ + 0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,\ + 0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,\ + 0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0 + +picture_pause db 1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,1,1,0,1,1,1,1,\ + 1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1,0,0,0,\ + 1,0,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1,0,0,0,\ + 1,1,1,0,0,1,1,1,1,0,1,0,0,1,0,1,1,1,1,0,1,1,1,0,\ + 1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,0,1,0,1,0,0,0,\ + 1,0,0,0,0,1,0,0,1,0,0,1,1,0,0,1,1,1,1,0,1,1,1,1 + +picture_game_over db 0,0,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,1,1,1,1,0,\ + 0,1,0,0,1,0,0,1,0,1,0,0,1,1,0,1,1,0,1,0,0,0,0,0,\ + 1,0,0,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,1,1,1,1,0,0,\ + 1,0,0,1,0,0,1,1,1,1,1,0,1,0,0,0,1,0,1,0,0,0,0,0,\ + 0,1,1,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,1,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,1,1,1,0,0,1,0,0,0,1,0,1,1,1,1,1,0,1,1,1,1,0,\ + 0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,\ + 0,1,0,0,0,1,0,1,0,0,0,1,0,1,1,1,1,0,0,1,0,0,0,1,\ + 0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,0,0,1,1,1,1,0,\ + 0,0,1,1,1,0,0,0,0,1,0,0,0,1,1,1,1,1,0,1,0,0,0,1 + +start_map db 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,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,0,0,0,0,0,0,0,0,\ + 0,0,0,1,1,1,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,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,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,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,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,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 + +background_color dd 0x000000 +decorations_color dd 0x00000000 +snake_color dd 0x000000 +snake_head_color dd 0x000000 +snake_picture_color dd 0x000000 +version_picture_color dd 0x000000 +pause_picture_color dd 0x000000 +game_over_picture_color dd 0x000000 +eat_color dd 0x000000 +navigation_strings_color dd 0x80000000 +game_over_strings_color dd 0x80000000 +score_string_color dd 0x80000000 +hiscore_string_color dd 0x80000000 +champion_string_color dd 0x80000000 +game_over_hiscore_color dd 0x80000000 +score_number_color dd 0x40000000 +hiscore_number_color dd 0x00000000 +champion_name_color dd 0x80000000 + +align 4 +@IMPORT: + +library \ + libini , 'libini.obj' ,\ + box_lib , 'box_lib.obj' + +import libini,\ + ini.get_str , 'ini_get_str' ,\ + ini.get_int , 'ini_get_int' ,\ + ini.set_str , 'ini_set_str' ,\ + ini.set_int , 'ini_set_int' ,\ + ini.get_color , 'ini_get_color' + +import box_lib,\ + edit_box.draw , 'edit_box' ,\ + edit_box.key , 'edit_box_key' ,\ + edit_box.mouse , 'edit_box_mouse' + +bFirstDraw db 0 + +aScore db 'Score',0 +aHiscore db 'Hiscore',0 +aChampion_name db 'Champion_name',0 + +aPreferences db 'Preferences',0 +aSpeed db 'Speed',0 +aDecorations db 'Decorations',0 + +aColors db 'Colors',0 +aBackground_color db 'Background_color',0 +aDecorations_color db 'Decorations_color',0 +aSnake_color db 'Snake_color',0 +aSnake_head_color db 'Snake_head_color',0 +aSnake_picture_color db 'Snake_picture_color',0 +aVersion_picture_color db 'Version_picture_color',0 +aPause_picture_color db 'Pause_picture_color',0 +aGame_over_picture_color db 'Game_over_picture_color',0 +aEat_color db 'Eat_color',0 +aNavigation_strings_color db 'Navigation_string_color',0 +aGame_over_strings_color db 'Game_over_string_color',0 +aScore_string_color db 'Score_string_color',0 +aHiscore_string_color db 'Hiscore_string_color',0 +aChampion_string_color db 'Champion_string_color',0 +aGame_over_hiscore_color db 'Game_over_hiscore_color',0 +aScore_number_color db 'Score_number_color',0 +aHiscore_number_color db 'Hiscore_number_color',0 +aChampion_name_color db 'Champion_name_color',0 + +edit1 edit_box 100,397,278,0x000000,0x00aa00,0x000000,0x000000,0x80ffdd44,15,hed,mouse_dd,ed_focus,hed_end-hed-1,hed_end-hed-1 + +hed db '',0 +hed_end: +rb 256 +ed_buffer rb 100 + +mouse_dd rd 1 + +i_end: +cur_dir_path rb 4096 +@PARAMS rb 4096 +;;---Variables------------------------------------------------------------------------------------------------------------- + +rb 4096 +stacktop: +d_end: \ No newline at end of file diff --git a/programs/games/snake/trunk/snake.ini b/programs/games/snake/trunk/snake.ini new file mode 100644 index 0000000000..32a3ac02d2 --- /dev/null +++ b/programs/games/snake/trunk/snake.ini @@ -0,0 +1,101 @@ +[Preferences] +Speed=80 +; SLOW == 0 <= Speed <= 100 == FAST +Decorations=2 +; 0 = nothing +; 1 = grid_lines +; 2 = grid_lines_with_ends +; 3 = grid_lines_with_corners +; 4 = grid_dots +; 5 = borders_lines +; 6 = borders_lines_with_ends +; 7 = borders_dots +; 8 = corners_dots +; 9 = corners_inner +; 10 = corners_outer +; 11 = corners_crosses + +[Colors] + +; Standard color scheme +Background_color = 0,0,0 +Decorations_color = 170,170,0 +Snake_color = 17,17,255 +Snake_head_color = 17,17,255 +Snake_picture_color = 68,136,255 +Version_picture_color = 85,255,85 +Pause_picture_color = 17,255,17 +Game_over_picture_color = 255,17,17 +Navigation_string_color = 255,119,119 +Game_over_string_color = 255,153,0 +Game_over_hiscore_color = 255,221,68 +Eat_color = 255,255,17 +Score_number_color = 255,255,255 +Score_string_color = 255,255,255 +Hiscore_number_color = 255,255,255 +Hiscore_string_color = 255,255,255 +Champion_string_color = 255,255,255 +Champion_name_color = 255,255,255 + +; Light scheme +;Background_color = 245,245,245 +;Decorations_color = 55,55,55 +;Snake_color = 215,115,215 +;Snake_head_color = 215,115,215 +;Snake_picture_color = 105,155,205 +;Version_picture_color = 155,255,0 +;Pause_picture_color = 75,255,75 +;Game_over_picture_color = 225,125,105 +;Navigation_string_color = 205,105,105 +;Game_over_string_color = 255,255,255 +;Game_over_hiscore_color = 255,255,255 +;Eat_color = 255,255,55 +;Score_number_color = 100,100,255 +;Score_string_color = 100,100,255 +;Hiscore_number_color = 100,100,255 +;Hiscore_string_color = 100,100,255 +;Champion_string_color = 100,100,255 +;Champion_name_color = 100,100,255 + +; Ultra white scheme +;Background_color = 0,0,0 +;Snake_color = 30,30,30 +;Snake_head_color = 30,30,30 +;Snake_picture_color = 30,30,30 +;Version_picture_color = 70,70,70 +;Pause_picture_color = 30,30,30 +;Game_over_picture_color = 30,30,30 +;Navigation_string_color = 255,255,255 +;Game_over_string_color = 255,255,255 +;Game_over_hiscore_color = 255,255,255 +;Eat_color = 0,255,0 +;Score_number_color = 0,0,0 +;Score_string_color = 255,255,255 +;Hiscore_number_color = 0,0,0 +;Hiscore_string_color = 255,255,255 +;Champion_string_color = 255,255,255 +;Champion_name_color = 255,255,255 + +; Ultra black scheme +;Background_color = 0,0,0 +;Decorations_color = 255,255,255 +;Snake_color = 255,255,255 +;Snake_head_color = 255,255,255 +;Snake_picture_color = 255,255,255 +;Version_picture_color = 225,225,225 +;Pause_picture_color = 225,225,225 +;Game_over_picture_color = 225,225,225 +;Navigation_string_color = 0,0,0 +;Game_over_string_color = 0,0,0 +;Game_over_hiscore_color = 0,0,0 +;Eat_color = 255,0,0 +;Score_number_color = 255,255,255 +;Score_string_color = 255,255,255 +;Hiscore_number_color = 255,255,255 +;Hiscore_string_color = 255,255,255 +;Champion_string_color = 0,0,0 +;Champion_name_color = 0,0,0 + +[Score] +Hiscore=777 +Champion_name= \ No newline at end of file