game snake refactoring
Some checks failed
Build system / Check kernel codestyle (pull_request) Successful in 2m5s
Build system / Build (pull_request) Failing after 2m57s

This commit is contained in:
2026-02-01 18:49:13 +04:00
parent 1173ca7b26
commit 8e006128c8
7 changed files with 691 additions and 730 deletions

View File

@@ -9,7 +9,7 @@ First_menu:
mov [lives], START_LIVES
call Show_cursor
mov [score], 0
mov [numberScore.value], 0
call Set_first_level_of_play_mode
mov ebx, [time_wait_limit_const]
@@ -24,7 +24,8 @@ First_menu:
call Draw_decorations
call Draw_first_menu_picture
call Draw_menu_strings
stdcall draw.Navigation, labelExit, [posLabel.yTop], 0
stdcall draw.Navigation, labelStart, [posLabel.yCenter], 0
call Draw_buttons
@@:
mcall 12,2
@@ -118,29 +119,6 @@ Draw_first_menu_picture:
;;---Draw_first_menu_picture------------------------------------------------------------------------------------------------
Draw_menu_strings:
;;===Make_menu_strings======================================================================================================
mov ebx, [window_width]
shr ebx, 1
sub ebx, press_to_start.size*3+6
shl ebx, 16
add ebx, dword[bottom_middle_strings]
mcall 4, ,[navigation_strings_color],press_to_start
mov ebx, [window_width]
shr ebx, 1
sub ebx, press_esc_to_exit.size*3+6
shl ebx, 16
add ebx, [top_strings]
mcall , ,[navigation_strings_color],press_esc_to_exit
; mcall ,406*65536+TOP_STRINGS,[navigation_strings_color],press_F2_to_options
ret
;;---Make_menu_strings------------------------------------------------------------------------------------------------------
Draw_buttons:
;;===Draw_buttons===========================================================================================================
@@ -278,33 +256,31 @@ Delete_buttons:
Change_play_mode:
;;===Change_play_mode======================================================================================================
cmp [play_mode], LEVELS_MODE
jne @f
mov [play_mode], CLASSIC_MODE
mov [cur_level_number], 0
ret
@@:
inc [play_mode]
xor [play_mode], LEVELS_MODE
call Set_first_level_of_play_mode
ret
;;---Change_play_mode------------------------------------------------------------------------------------------------------
Set_first_level_of_play_mode:
;;===Set_first_level_of_play_mode==========================================================================================
cmp [play_mode], CLASSIC_MODE
jne @f
mov [cur_level_number], CLASSIC_MODE_FIRST_LEVEL
mov [numberLevel.value], CLASSIC_MODE_FIRST_LEVEL
mov eax, [numberHiscore.valueClassic]
mov esi, labelChampionName.valueClassic
@@:
cmp [play_mode], LEVELS_MODE
jne @f
mov [cur_level_number], LEVELS_MODE_FIRST_LEVEL
mov [numberLevel.value], LEVELS_MODE_FIRST_LEVEL
mov eax, [numberHiscore.valueLevels]
mov esi, labelChampionName.valueLevels
@@:
mov [numberHiscore.value], eax
mov edi, [labelChampionName.value]
mov ecx, CHAMPION_NAME_LENGTH
cld
rep movsb
ret

View File

@@ -0,0 +1,144 @@
macro defLabel name, color, [text]
{
common
local ..str
..str db text, 0
name#.len = $ - ..str - 1
name LABEL color, name#.len, ..str
}
macro defNumber name, color, size
{
common
name#.len = size
name LABEL color, name#.len, 0
}
; -----------------------------
; <20>¨áã¥â ⥪áâ ¯® yPosition ¨ 業âà¨àãï ⥪áâ ¯® è¨à¨­¥ íªà ­ 
; á ãç¥â®¬ ¤«¨­ë ⥪áâ  ¨ 㪠§ ­­®£® ᬥ饭¨ï ¢ ᨬ¢®« å
; input: pText - 㪠§ â¥«ì ­  áâàãªâãàã
; yPosition - ¯®§¨æ¨ï Y
; countOffset - ª®«-¢® ᨬ¢®«®¢ ¤«ï ᬥ饭¨ï
; -----------------------------
proc draw.Navigation pText, yPosition, countOffset
mov eax, [pText]
mov eax, [eax + LABEL.size]
sub eax, [countOffset]
stdcall draw.GetNavigationX, eax
stdcall draw.Label, [pText], eax, [yPosition], 0
ret
endp
; -----------------------------
; <20>¨áã¥â ç¨á«® ¯® yPosition ¨ 業âà¨àãï ç¨á«® ¯® è¨à¨­¥ íªà ­ 
; á ãç¥â®¬ ¤«¨­ë ç¨á«  ¨ 㪠§ ­­®£® ᬥ饭¨ï ¢ ᨬ¢®« å
; input: pNumber - 㪠§ â¥«ì ­  áâàãªâãàã
; yPosition - ¯®§¨æ¨ï Y
; countOffset - ª®«-¢® ᨬ¢®«®¢ ¤«ï ᬥ饭¨ï
; -----------------------------
proc draw.NavigationNumber pNumber, yPosition, countOffset
mov eax, [pNumber]
mov eax, [eax + LABEL.size]
sub eax, [countOffset]
stdcall draw.GetNavigationX, eax
stdcall draw.Number, [pNumber], eax, [yPosition], 0
ret
endp
; -----------------------------
; ‚®§¢à é ¥â ª®®à¤¨­ âã X ¤«ï à §¬¥é¥­¨ï ⥪áâ  ¯® 業âàã íªà ­ 
; á ãç¥â®¬ 㪠§ ­­®£® ᬥ饭¨ï ¢ ᨬ¢®« å
; input: countOffset - ª®«-¢® ᨬ¢®«®¢ ¤«ï ᬥ饭¨ï
; output: eax - ª®®à¤¨­ â  X
; -----------------------------
proc draw.GetNavigationX countOffset
mov eax, [countOffset]
neg eax
mul [configFont.width]
add eax, [window_width]
sub eax, 10
shr eax, 1
ret
endp
; -----------------------------
; ”®à¬¨àã¥â ¢ ®¤­®¬ ॣ¨áâॠª®®à¤¨­ âë ¢ ­ã¦­®¬ ä®à¬ â¥ ¤®¡ ¢«ïï
; è¨à¨­ã ᬥ饭¨ï ᨬ¢®«®¢ ¯® X ¥á«¨ 㪠§ ­® ª®«-¢®
; input: xPosition - ¯®§¨æ¨ï ¯® X
; yPosition - ¯®§¨æ¨ï ¯® Y
; countOffset - ª®«-¢® ᨬ¢®«®¢ ¤«ï ᬥ饭¨ï
; output: eax - ª®®à¤¨­ â  ¢ ä®à¬ â¥ X*65536+Y
; -----------------------------
proc draw._prepareCoord xPosition, yPosition, countOffset
mov eax, [countOffset]
mul [configFont.width]
add eax, [xPosition]
shl eax, 16
add eax, [yPosition]
ret
endp
; -----------------------------
; <20>¨áã¥â ⥪áâ ¯® 㪠§ ­­®© ¯®§¨æ¨¨ X ¨ Y
; ¨ ᬥ頥⠭  è¨à¨­ã ᨬ¢®«®¢ ¯® X ¥á«¨ 㪠§ ­®
; input: pText - 㪠§ â¥«ì ­  áâàãªâãàã
; xPosition - ¯®§¨æ¨ï X
; yPosition - ¯®§¨æ¨ï Y
; countOffset - ª®«-¢® ᨬ¢®«®¢ ¤«ï ᬥ饭¨ï
; -----------------------------
proc draw.Label pText, xPosition, yPosition, countOffset
stdcall draw._prepareCoord, [xPosition], [yPosition], [countOffset]
mov ebx, eax
mov eax, [pText]
mov ecx, [configFont.mask]
or ecx, [eax + LABEL.color]
mov edx, [eax + LABEL.value]
mcall 4
ret
endp
; -----------------------------
; <20>¨áã¥â ç¨á«® ¯® 㪠§ ­­®© ¯®§¨æ¨¨ X ¨ Y
; ¨ ᬥ頥⠭  è¨à¨­ã ᨬ¢®«®¢ ¯® X ¥á«¨ 㪠§ ­®
; input: pNumber - 㪠§ â¥«ì ­  áâàãªâãàã
; xPosition - ¯®§¨æ¨ï X
; yPosition - ¯®§¨æ¨ï Y
; countOffset - ª®«-¢® ᨬ¢®«®¢ ¤«ï ᬥ饭¨ï
; -----------------------------
proc draw.Number pNumber, xPosition, yPosition, countOffset
stdcall draw._prepareCoord, [xPosition], [yPosition], [countOffset]
mov edx, eax
mov eax, [pNumber]
mov ebx, [eax + LABEL.size]
shl ebx, 16
mov ecx, [eax + LABEL.value]
mov esi, [configFont.maskNumber]
or esi, [eax + LABEL.color]
mcall 47, , , , ,[background_color]
ret
endp
; -----------------------------
; “áâ ­®¢¨âì ­ áâனª¨ èà¨äâ  ¢ § ¢¨á¨¬®á⨠®â à §¬¥à  ï祩ª¨
; ãáâ ­ ¢«¨¢ ¥â ¢ëá®âã, è¨à¨­ã ᨬ¢®«  ¨ ¬ áªã ¤«ï à¨á®¢ ­¨ï ⥪áâ  ¨ ç¨á« 
; input: squareSideLength - à §¬¥à ï祩ª¨
; -----------------------------
proc draw.setConfigFont squareSideLength
cmp [squareSideLength], MIN_SQUARE_SIDE_LENGTH_FONT
jg @f
cmp [configFont.flag], FONT_SMALL
je .return
mov [configFont.flag], FONT_SMALL
jmp .set
@@:
cmp [configFont.flag], FONT_LARGE
je .return
mov [configFont.flag], FONT_LARGE
.set:
mov eax, [configFont.flag]
lea ebx, [eax + 8]
shl ebx, 28
mov [configFont.mask], ebx
lea ebx, [eax*2 + 6]
mov [configFont.width], ebx
lea ebx, [8 + eax*4]
mov [configFont.height], ebx
lea ebx, [eax + 4]
shl ebx, 28
mov [configFont.maskNumber], ebx
.return:
ret
endp

View File

@@ -15,16 +15,16 @@ Game_over:
mcall 66,1,0 ; set ascii mode for keyboard
call Show_cursor
mov ebx, [score]
mov ebx, [numberScore.value]
cmp [play_mode], CLASSIC_MODE
jne @f
cmp ebx, [hi_score_classic]
cmp ebx, [numberHiscore.valueClassic]
jng .redraw
mov [is_new_record], 1
jmp .done
@@:
cmp ebx, [hi_score_levels]
cmp ebx, [numberHiscore.valueLevels]
jng .redraw
mov [is_new_record], 1
jmp .done
@@ -120,51 +120,29 @@ Draw_game_over_picture:
Draw_game_over_strings:
;;===Draw_game_over_strings================================================================================================
cmp [is_new_record], 1
jnz @f
mov ebx, [window_width]
shr ebx, 1
sub ebx, string_congratulations.size*3+6*6
shl ebx, 16
add ebx, [bottom_top_strings]
mcall 4, ,[game_over_strings_color],string_congratulations
mov ebx, [window_width]
shr ebx, 1
sub ebx, string_enter_your_name.size*3+6*6
shl ebx, 16
add ebx, [bottom_bottom_strings]
mcall , , ,string_enter_your_name
mov ebx, [window_width]
shr ebx, 1
sub ebx, string_apply_name_enter.size*3
shl ebx, 16
add ebx, [top_strings]
mcall , ,[navigation_strings_color],string_apply_name_enter
mov edx, [window_width]
shr edx, 1
add edx, string_congratulations.size*3-6*6-1
shl edx, 16
add edx, dword[bottom_top_strings]
mcall 47,0x00070000,[score], ,[game_over_hiscore_color]
mov ebx, [window_width]
shr ebx, 1
add ebx, string_enter_your_name.size*3-6*6-3
mov [edit1.left], ebx
mov eax, [numberScore.value]
mov [numberGameOver.value], eax
stdcall draw.Navigation, labelCongratulations, [posLabel.yCenter], -numberGameOver.len
stdcall draw.NavigationNumber, numberGameOver, [posLabel.yCenter], labelCongratulations.len
stdcall draw.Navigation, labelEnterName, [posLabel.yBottom], -numberGameOver.len - 3
stdcall draw.GetNavigationX, -labelCongratulations.len+numberGameOver.len
mov [edit1.left], eax
mov eax, [posLabel.yBottom]
sub eax, 3
mov [edit1.top], eax
mov eax, [configFont.mask]
or [edit1.text_color], eax
invoke edit_box.draw, edit1
stdcall draw.Navigation, labelApply, [posLabel.yTop], 0
ret
@@:
call Draw_menu_esc
stdcall draw.Navigation, labelMenu, [posLabel.yTop], 0
ret
;;---Draw_game_over_strings------------------------------------------------------------------------------------------------
Score_and_name_store:
;;===Name_store============================================================================================================
@@ -172,23 +150,23 @@ Score_and_name_store:
cmp [play_mode], CLASSIC_MODE
jne @f
mov edi, champion_name_classic
mov edi, labelChampionName.valueClassic
jmp .done
@@:
mov edi, champion_name_levels
mov edi, labelChampionName.valueLevels
.done:
mov ecx, CHAMPION_NAME_LENGTH
rep movsb
mov eax, [score]
mov eax, [numberScore.value]
cmp [play_mode], CLASSIC_MODE
jne @f
mov [hi_score_classic], eax
mov [numberHiscore.valueClassic], eax
jmp .done2
@@:
mov [hi_score_levels], eax
mov [numberHiscore.valueLevels], eax
.done2:
ret

View File

@@ -364,47 +364,26 @@ Draw_head_prehead:
Draw_level_strings:
;;===Draw_level_strings================================================================================================
stdcall draw.Navigation, labelPause, [posLabel.yTop], 0
mov ebx, [window_width]
shr ebx, 1
sub ebx, string_pause_space.size*3+6
shl ebx, 16
add ebx, [top_strings]
mcall 4, ,[navigation_strings_color],string_pause_space ; Draw 'PAUSE - SPACE' string
stdcall draw.Label, labelScore, [posLabel.xLeft], [posLabel.yCenter], 3
stdcall draw.Number, numberScore, [posLabel.xLeft], [posLabel.yCenter], labelScore.len+3
; call Draw_menu_esc
call Draw_score_string
call Draw_score_number ; Draw score (number)
call Draw_champion_string
call Draw_champion_name
call Draw_hiscore_string
call Draw_hiscore_number
stdcall draw.Label, labelChampion, [posLabel.xRight], [posLabel.yBottom], -labelChampion.len-numberHiscore.len-3
stdcall draw.Label, labelChampionName, [posLabel.xRight], [posLabel.yBottom], -numberHiscore.len-3
stdcall draw.Label, labelHiscore, [posLabel.xRight], [posLabel.yCenter], -labelHiscore.len-numberHiscore.len-3
stdcall draw.Number, numberHiscore, [posLabel.xRight], [posLabel.yCenter], -numberHiscore.len-3
cmp [play_mode], LEVELS_MODE
jne @f
mov ebx, [window_width]
shr ebx, 3
sub ebx, 5
shl ebx, 16
add ebx, [bottom_bottom_strings]
mcall 4, ,[level_string_color],string_level
mov edx, [window_width]
shr edx, 3
sub edx, 5+1
add edx, string_level.size*6
shl edx, 16
add edx, [bottom_bottom_strings]
mcall 47,0x00020000,[cur_level_number], ,[level_number_color],[background_color]
stdcall draw.Label, labelLevel, [posLabel.xLeft], [posLabel.yBottom], 3
stdcall draw.Number, numberLevel, [posLabel.xLeft], [posLabel.yBottom], labelLevel.len+3
@@:
ret
;;---Draw_level_strings------------------------------------------------------------------------------------------------
Reverse:
;;===Reverse===========================================================================================================
@@ -594,7 +573,7 @@ Snake_move:
jne .eat_and_new_head_are_different
add [snake_length_x2], 2
add [score], SCORE_EAT
add [numberScore.value], SCORE_EAT
dec [number_of_free_dots]
cmp [number_of_free_dots], 0
je Game_over
@@ -657,10 +636,10 @@ Snake_move:
Keys_done:
cmp [score], 0
cmp [numberScore.value], 0
je @f
dec [score]
call Draw_score_number
dec [numberScore.value]
stdcall draw.Number, numberScore, [posLabel.xLeft], [posLabel.yCenter], labelScore.len+3
@@:
cmp [play_mode], LEVELS_MODE
@@ -681,10 +660,10 @@ Snake_move:
Do_smth_between_levels:
;;===Do_smth_between_levels================================================================================================
inc [cur_level_number]
cmp [cur_level_number], LAST_LEVEL_NUMBER+1
inc [numberLevel.value]
cmp [numberLevel.value], LAST_LEVEL_NUMBER+1
jne @f
mov [cur_level_number], LEVELS_MODE_FIRST_LEVEL
mov [numberLevel.value], LEVELS_MODE_FIRST_LEVEL
@@:
call Draw_splash
@@ -753,7 +732,7 @@ Draw_splash:
mov esi, picture_level
call Draw_picture
mov eax, [cur_level_number]
mov eax, [numberLevel.value]
mov dl, 10
div dl
push ax
@@ -844,5 +823,4 @@ Draw_lives_in_head:
;;---Draw_lives_in_head----------------------------------------------------------------------------------------------------
;;---Some_functions------------------------------------------------------------------------------------------------------------

View File

@@ -17,7 +17,8 @@ Pause_mode:
call Draw_decorations
call Draw_pause_picture
call Draw_pause_strings
stdcall draw.Navigation, labelMenu, [posLabel.yTop], 0
stdcall draw.Navigation, labelResume, [posLabel.yCenter], 0
mcall 12,2
@@:
.still:
@@ -77,22 +78,4 @@ Draw_pause_picture:
;;---Draw_pause_picture--------------------------------------------------------------------------------------------------------
Draw_pause_strings:
;;===Draw_pause_strings================================================================================================
mov ebx, [window_width]
shr ebx, 1
sub ebx, string_resume_space.size*3+6
shl ebx, 16
add ebx, dword[bottom_middle_strings]
mcall 4, ,[navigation_strings_color],string_resume_space ; Show 'RESUME - SPACE' string
call Draw_menu_esc ; Show 'MENU - ESC' string
ret
;;---Draw_pause_strings------------------------------------------------------------------------------------------------
;;---Some_functions------------------------------------------------------------------------------------------------------------

View File

@@ -7,11 +7,11 @@ use32
;;---HEADER--------------------------------------------------------------------------------------------------------------------
include 'lang.inc'
include '../../proc32.inc'
include '../../macros.inc'
include '../../dll.inc'
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
;include '../../system/board/trunk/debug.inc'
;;===Define_chapter============================================================================================================
@@ -21,7 +21,15 @@ WINDOW_MODE_FULLSCREEN equ 1
GRID_WIDTH equ 28
GRID_HEIGHT equ 14
MIN_SQUARE_SIDE_LENGTH equ 9
MIN_SQUARE_SIDE_LENGTH equ 10
MIN_SQUARE_SIDE_LENGTH_FONT equ 20
FONT_SMALL equ 0
FONT_LARGE equ 1
DEFAULT_NAVIGATION_COLOR equ 0xff7777
DEFAULT_LABEL_COLOR equ 0xffffff
DEFAULT_LABEL_END_COLOR equ 0xff9900
DEFAULT_NUMBER_END_COLOR equ 0xffdd44
DEFAULT_HISCORE equ 777
SCORE_EAT equ 100
@@ -53,7 +61,11 @@ CHAMPION_NAME_LENGTH equ 15
LAST_LEVEL_NUMBER equ 36
START_LIVES equ 3
struct LABEL
color dd ?
size dd ?
value dd ?
ends
;;---Define_chapter------------------------------------------------------------------------------------------------------------
start:
@@ -129,30 +141,49 @@ align 4
or [you_win_picture_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aEat_color, 0xffff11
or [eat_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aNavigation_strings_color, 0x80ff7777
or [navigation_strings_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aGame_over_strings_color, 0x80ff9900
or [game_over_strings_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aScore_string_color, 0x80ffffff
or [score_string_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aLevel_string_color, 0xffffff
or [level_string_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aHiscore_string_color, 0x80ffffff
or [hiscore_string_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aChampion_string_color, 0x80ffffff
or [champion_string_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aGame_over_hiscore_color, 0x80ffdd44
or [game_over_hiscore_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aScore_number_color, 0xffffff
or [score_number_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aLevel_number_color, 0xffffff
or [level_number_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aHiscore_number_color, 0x00ffffff
or [hiscore_number_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aChampion_name_color, 0x80ffffff
or [champion_name_color], eax
; ini navigation color
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.labelNavigation, DEFAULT_NAVIGATION_COLOR
mov [labelMenu.color], eax
mov [labelExit.color], eax
mov [labelStart.color], eax
mov [labelPause.color], eax
mov [labelApply.color], eax
mov [labelResume.color], eax
; ini color score
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.labelScore, DEFAULT_LABEL_COLOR
mov [labelScore.color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.numberScore, DEFAULT_LABEL_COLOR
mov [numberScore.color], eax
; ini color hiscore
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.labelHiscore, DEFAULT_LABEL_COLOR
mov [labelHiscore.color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.numberHiscore, DEFAULT_LABEL_COLOR
mov [numberHiscore.color], eax
; ini color champion
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.labelChampion, DEFAULT_LABEL_COLOR
mov [labelChampion.color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.labelChampionName, DEFAULT_LABEL_COLOR
mov [labelChampionName.color], eax
; ini color level
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.labelLevel, DEFAULT_LABEL_COLOR
mov [labelLevel.color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.numberLevel, DEFAULT_LABEL_COLOR
mov [numberLevel.color], eax
; ini color game over
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.labelGameOver, DEFAULT_LABEL_END_COLOR
mov [labelCongratulations.color], eax
mov [labelEnterName.color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, configColor.numberGameOver, DEFAULT_NUMBER_END_COLOR
mov [numberGameOver.color], eax
mov [edit1.text_color], eax
; ini color edit box
invoke ini.get_color, cur_dir_path, aTheme_name, aEdit_box_selection_color, 0x00aa00
or [edit1.shift_color], eax
mov [edit1.shift_color], eax
mov eax, [background_color]
mov [edit1.color], eax
mov [edit1.focus_border_color], eax
mov [edit1.blur_border_color], eax
;
invoke ini.get_color, cur_dir_path, aTheme_name, aButton_color, 0xDDDDDD
or [button_color], eax
invoke ini.get_color, cur_dir_path, aTheme_name, aButton_text_color, 0x000000
@@ -168,19 +199,12 @@ align 4
invoke ini.get_int, cur_dir_path, aReserved, aSquare_side_length, 19
mov [square_side_length], eax
invoke ini.get_str, cur_dir_path, aReserved, aChampion_name_classic, champion_name_classic, CHAMPION_NAME_LENGTH, champion_name_classic
invoke ini.get_int, cur_dir_path, aReserved, aHiscore_classic, 777
or [hi_score_classic], eax
invoke ini.get_str, cur_dir_path, aReserved, aChampion_name_levels, champion_name_levels, CHAMPION_NAME_LENGTH, champion_name_levels
invoke ini.get_int, cur_dir_path, aReserved, aHiscore_levels, 777
or [hi_score_levels], eax
mov eax, [background_color]
mov [edit1.color], eax
mov [edit1.focus_border_color], eax
mov [edit1.blur_border_color], eax
mov eax, [game_over_hiscore_color]
mov [edit1.text_color], eax
invoke ini.get_str, cur_dir_path, aReserved, config.championNameClassic, labelChampionName.valueClassic, CHAMPION_NAME_LENGTH+1, labelChampionName.valueClassic
invoke ini.get_str, cur_dir_path, aReserved, config.championNameLevels, labelChampionName.valueLevels, CHAMPION_NAME_LENGTH+1, labelChampionName.valueLevels
invoke ini.get_int, cur_dir_path, aReserved, config.hiscoreClassic, DEFAULT_HISCORE
mov [numberHiscore.valueClassic], eax
invoke ini.get_int, cur_dir_path, aReserved, config.hiscoreLevels, DEFAULT_HISCORE
mov [numberHiscore.valueLevels], eax
mcall 37,4,cursor_data,2 ; load empty cursor (for "hiding" cursor while level_mode)
mov [cursor_handle], eax
@@ -195,7 +219,7 @@ 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
include 'functions.asm'
;;===Some_functions============================================================================================================
@@ -206,25 +230,25 @@ Save_do_smth_else_and_exit:
invoke ini.set_int, cur_dir_path, aReserved, aSquare_side_length, [square_side_length]
mov edi, champion_name_classic
mov edi, labelChampionName.valueClassic
xor al, al
mov ecx, CHAMPION_NAME_LENGTH+1
cld
repne scasb
neg ecx
add ecx, CHAMPION_NAME_LENGTH
invoke ini.set_str, cur_dir_path, aReserved, aChampion_name_classic, champion_name_classic, ecx
invoke ini.set_int, cur_dir_path, aReserved, aHiscore_classic, [hi_score_classic]
invoke ini.set_str, cur_dir_path, aReserved, config.championNameClassic, labelChampionName.valueClassic, ecx
invoke ini.set_int, cur_dir_path, aReserved, config.hiscoreClassic, [numberHiscore.valueClassic]
mov edi, champion_name_levels
mov edi, labelChampionName.valueLevels
xor al, al
mov ecx, CHAMPION_NAME_LENGTH+1
cld
repne scasb
neg ecx
add ecx, CHAMPION_NAME_LENGTH
invoke ini.set_str, cur_dir_path, aReserved, aChampion_name_levels, champion_name_levels, ecx
invoke ini.set_int, cur_dir_path, aReserved, aHiscore_levels, [hi_score_levels]
invoke ini.set_str, cur_dir_path, aReserved, config.championNameLevels, labelChampionName.valueLevels, ecx
invoke ini.set_int, cur_dir_path, aReserved, config.hiscoreLevels, [numberHiscore.valueLevels]
;;---Save_do_smth_else_and_exit--------------------------------------------------------------------------------------------
@@ -345,7 +369,9 @@ Set_geometry:
@@:
mov eax, [square_side_length]
inc eax ; space between squares
mov [g_s], eax
stdcall draw.setConfigFont, eax
mov eax, [g_s]
shr eax, 1
@@ -456,19 +482,27 @@ Set_geometry:
shr cx, 1
add cx, dx
mov word[wp_y], cx
mov [top_strings], 8
mov eax, [window_height]
sub eax, 50
mov [bottom_top_strings], eax
add eax, 6
mov [bottom_middle_strings], eax
add eax, 6
mov [bottom_bottom_strings], eax
sub eax, 4
mov [edit1.top], eax
; ?????????? ????? ??? ?????? ??
; ????? ?? Y
mov ecx, [configFont.height]
mov ebx, ecx
shr ebx, 1
mov eax, [gbym1]
sub eax, ecx
sub eax, ebx
mov [posLabel.yTop], eax
mov eax, [gbym1_plus_gh_mul_gs]
add eax, ecx
sub eax, ebx
mov [posLabel.yCenter], eax
add eax, ecx
add eax, ebx
mov [posLabel.yBottom], eax
; x
mov eax, [gbxm1]
mov [posLabel.xLeft], eax
mov eax, [gbxm1_plus_gw_mul_gs]
mov [posLabel.xRight], eax
mov eax, [g_s]
shl eax, 2
@@ -541,15 +575,12 @@ Increase_geometry:
Decrease_geometry:
;;===Decrease_geometry=================================================================================================
cmp [square_side_length], MIN_SQUARE_SIDE_LENGTH
je @f
dec [square_side_length]
mov [resized_by_hotkey], 1
@@:
ret
;;---Decrease_geometry-------------------------------------------------------------------------------------------------
@@ -930,140 +961,6 @@ Draw_square:
;;---Draw_square-------------------------------------------------------------------------------------------------------
Draw_menu_esc:
;;===Draw_menu_esc=====================================================================================================
mov ebx, [window_width]
shr ebx, 1
sub ebx, string_menu_esc.size*3+6
shl ebx, 16
add ebx, dword[top_strings]
mcall 4, ,[navigation_strings_color],string_menu_esc
ret
;;---Draw_menu_esc-----------------------------------------------------------------------------------------------------
Draw_score_string:
;;===Draw_score_string=================================================================================================
mov ebx, [window_width]
shr ebx, 3
sub ebx, 5
shl ebx, 16
add ebx, dword[bottom_top_strings]
mcall 4, ,[score_string_color],string_score
ret
;;---Draw_score_string-------------------------------------------------------------------------------------------------
Draw_score_number:
;;===Draw_score_number=================================================================================================
mov edx, [window_width]
shr edx, 3
sub edx, 5+1
add edx, string_score.size*6
shl edx, 16
add edx, dword[bottom_top_strings]
mcall 47,0x00070000,[score], ,[score_number_color],[background_color]
ret
;;---Draw_score_number-------------------------------------------------------------------------------------------------
Draw_hiscore_string:
;;===Draw_hiscore_string===============================================================================================
mov ebx, [window_width]
shr ebx, 3
neg ebx
add ebx, [window_width]
sub ebx, string_hi_score.size*6+7*6+5
shl ebx, 16
add ebx, dword[bottom_top_strings]
mcall 4, ,[hiscore_string_color],string_hi_score
ret
;;---Draw_hiscore_string-----------------------------------------------------------------------------------------------
Draw_hiscore_number:
;;===Draw_hiscore_number===================================================================================================
mov edx, [window_width]
shr edx, 3
neg edx
add edx, [window_width]
sub edx, 7*6+6
shl edx, 16
add edx, dword[bottom_top_strings]
cmp [play_mode], CLASSIC_MODE
jne @f
mov ecx, [hi_score_classic]
jmp .done
@@:
mov ecx, [hi_score_levels]
.done:
mcall 47,0x00070000, , ,[hiscore_number_color]
ret
;;---Draw_hiscore_number---------------------------------------------------------------------------------------------------
Draw_champion_string:
;;===Draw_champion_string==================================================================================================
mov ebx, [window_width]
shr ebx, 3
neg ebx
add ebx, [window_width]
sub ebx, string_champion.size*6+7*6+5
shl ebx, 16
add ebx, dword[bottom_bottom_strings]
mcall 4, ,[champion_string_color],string_champion
ret
;;---Draw_champion_string----------------------------------------------------------------------------------------------
Draw_champion_name:
;;===Draw_champion_name================================================================================================
mov ebx, [window_width]
shr ebx, 3
neg ebx
add ebx, [window_width]
sub ebx, CHAMPION_NAME_LENGTH/2*6+7*6+6 ; there is no difference between length of champion names for other play_modes
add ebx, CHAMPION_NAME_LENGTH/2*6
shl ebx, 16
add ebx, dword[bottom_bottom_strings]
cmp [play_mode], CLASSIC_MODE
jne @f
mov edx, champion_name_classic
jmp .done
@@:
mov edx, champion_name_levels
.done:
mcall 4, ,[champion_name_color],
ret
;;---Draw_champion_name------------------------------------------------------------------------------------------------
Draw_picture:
;;===Draw_picture======================================================================================================
;; in :
@@ -1170,7 +1067,7 @@ Load_level:
;; cur_level_number = level number to load
;;
mov eax, [cur_level_number]
mov eax, [numberLevel.value]
mov edx, stage_00
@@:
test al, al
@@ -1370,7 +1267,6 @@ Reverse_snake:
;;---Reverse_snake---------------------------------------------------------------------------------------------------------
;;===Variables==================================================================================================================
window_title db 'Snake',64+15 dup (0)
@@ -1388,29 +1284,6 @@ lives dd START_LIVES
acceleration_mask dd 0x0
resized_by_hotkey dd 0x0
fullscreen dd 0x0
szZ string_score ,'SCORE : '
szZ string_hi_score ,'HI-SCORE : '
szZ string_champion ,'CHAMPION : '
szZ string_level ,'LEVEL : '
szZ string_pause_space ,'PAUSE - ',0x27,'SPACE',0x27
szZ string_resume_space ,'RESUME - ',0x27,'SPACE',0x27
szZ string_menu_esc ,'MENU - ',0x27,'ESC',0x27
szZ string_apply_name_enter ,'APPLY NAME - ',0x27,'ENTER',0x27
szZ press_to_start ,'PRESS ',0x27,'ENTER',0x27,' TO START'
szZ press_esc_to_exit ,'PRESS ',0x27,'ESC',0x27,' TO EXIT'
;press_F2_to_options db 'PRESS ',0x27,'F2',0x27,' TO OPTIONS',0
szZ string_congratulations ,' Congratulations!!! New hi-score is : '
szZ string_enter_your_name ,'You are the champion! Enter your name : '
szZ string_button_play ,'PLAY'
szZ string_button_exit ,'EXIT'
szZ string_button_inc ,'+INC+'
szZ string_button_dec ,'-dec-'
szZ string_button_pm_classic,'CLASSIC mode'
szZ string_button_pm_levels ,'LEVELS mode'
is_new_record dd 0
@@ -1449,19 +1322,6 @@ picture_game_over db 00110000b,00000000b,00000000b,00000000b,\
00001000b,10010100b,10000111b,10000000b,\
00000111b,00001000b,11110100b,01000000b
;picture_you_win db 10001001b,11001000b,10000000b,\
; 10001010b,00101000b,10000000b,\
; 01010010b,00101000b,10000000b,\
; 00100010b,00101000b,10000000b,\
; 00100001b,11000111b,00000000b,\
; 00000000b,00000000b,00000000b,\
; 00000000b,00000000b,00000000b,\
; 01000100b,10010001b,00000000b,\
; 01010100b,10011001b,00000000b,\
; 01010100b,10010101b,00000000b,\
; 01010100b,10010011b,00000000b,\
; 00101000b,10010001b,00000000b
picture_you_win db 01000100b,01000011b,10001000b,10000000b,\
01000100b,01000100b,01001000b,10000000b,\
01000100b,01000100b,00001000b,10000000b,\
@@ -2357,23 +2217,12 @@ pause_picture_color dd 0x000000
game_over_picture_color dd 0x000000
you_win_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
button_color dd 0x000000
button_text_color dd 0x80000000
stone_color dd 0x000000
splash_background_color dd 0x000000
splash_level_string_color dd 0x000000
splash_level_number_color dd 0x000000
level_string_color dd 0x80000000
level_number_color dd 0x00000000
align 4
@@ -2396,8 +2245,6 @@ import box_lib,\
edit_box.key , 'edit_box_key' ,\
edit_box.mouse , 'edit_box_mouse'
bFirstDraw db 0
aPreferences db 'Preferences',0
aSpeed db 'Speed',0
aTheme db 'Theme',0
@@ -2428,15 +2275,6 @@ aPause_picture_color db 'Pause_picture_color',0
aGame_over_picture_color db 'Game_over_picture_color',0
aYou_win_picture_color db 'You_win_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
aEdit_box_selection_color db 'Edit_box_selection_color',0
aButton_color db 'Button_color',0
aButton_text_color db 'Button_text_color',0
@@ -2444,15 +2282,81 @@ aStone_color db 'Stone_color',0
aSplash_background_color db 'Splash_background_color',0
aSplash_level_string_color db 'Splash_level_string_color',0
aSplash_level_number_color db 'Splash_level_number_color',0
aLevel_string_color db 'Level_string_color',0
aLevel_number_color db 'Level_number_color',0
aReserved db 'Reserved',0
aSquare_side_length db 'Square_side_length',0
aHiscore_classic db 'Hiscore_classic',0
aChampion_name_classic db 'Champion_name_classic',0
aHiscore_levels db 'Hiscore_levels',0
aChampion_name_levels db 'Champion_name_levels',0
config:
.championNameClassic db 'Champion_name_classic',0
.championNameLevels db 'Champion_name_levels',0
.hiscoreClassic db 'Hiscore_classic',0
.hiscoreLevels db 'Hiscore_levels',0
configFont:
.flag dd 0
.width dd 6
.height dd 9
.mask dd 0x80000000
.maskNumber dd 0x40000000
configColor:
.labelNavigation db 'Navigation_string_color',0
.labelScore db 'Score_string_color',0
.numberScore db 'Score_number_color',0
.labelLevel db 'Level_string_color',0
.numberLevel db 'Level_number_color',0
.labelHiscore db 'Hiscore_string_color',0
.numberHiscore db 'Hiscore_number_color',0
.labelChampion db 'Champion_string_color',0
.labelChampionName db 'Champion_name_color',0
.labelGameOver db 'Game_over_string_color',0
.numberGameOver db 'Game_over_hiscore_color',0
if lang eq ru_RU
szZ string_button_play ,'ˆƒ<CB86>œ'
szZ string_button_exit ,'‚›•Ž„'
szZ string_button_inc ,'+INC+'
szZ string_button_dec ,'-dec-'
szZ string_button_pm_classic,'०¨¬ Š‹€‘‘ˆ—…‘Šˆ‰'
szZ string_button_pm_levels ,'०¨¬ “<>Ž<C5BD>…‰'
defLabel labelScore , DEFAULT_LABEL_COLOR, '‘—…’ : '
defLabel labelLevel , DEFAULT_LABEL_COLOR, '“<>Ž<E2809A>œ : '
defLabel labelHiscore , DEFAULT_LABEL_COLOR, '‹“—˜ˆ‰ ‘—…’ : '
defLabel labelChampion , DEFAULT_LABEL_COLOR, '—…Œ<E280A6>ˆŽ<CB86> : '
defLabel labelMenu , DEFAULT_NAVIGATION_COLOR, '<27>€†Œˆ… ',0x27,'ESC',0x27,' „‹Ÿ ‚›•Ž„€ Œ…<C592>ž'
defLabel labelExit , DEFAULT_NAVIGATION_COLOR, '<27>€†Œˆ… ',0x27,'ESC',0x27,' „‹Ÿ ‚›•Ž„€ ˆ‡ ˆƒ<CB86>'
defLabel labelStart , DEFAULT_NAVIGATION_COLOR, '<27>€†Œˆ… ',0x27,'ENTER',0x27,' —Ž<E28099> <20>€—€œ'
defLabel labelPause , DEFAULT_NAVIGATION_COLOR, '<27>€†Œˆ… ',0x27,'SPACE',0x27, ' „‹Ÿ <20>€“‡'
defLabel labelApply , DEFAULT_NAVIGATION_COLOR, '‚‚…„ˆ’… ˆŒŸ ˆ <20>€†Œˆ… ',0x27,'ENTER',0x27
defLabel labelResume , DEFAULT_NAVIGATION_COLOR, '<27>€†Œˆ… ',0x27,'SPACE',0x27, ' „‹Ÿ <20><>ބކ…<E280A0>ˆŸ'
defLabel labelCongratulations, DEFAULT_LABEL_END_COLOR, '<27>®§¤à ¢«ï¥¬!!! <20>®¢ë© «ãç訩 áç¥â : '
defLabel labelEnterName , DEFAULT_LABEL_END_COLOR, '’¥¯¥àì ¢ë 祬¯¨®­! ‚¢¥¤¨â¥ ᢮¥ ¨¬ï : '
else
szZ string_button_play ,'PLAY'
szZ string_button_exit ,'EXIT'
szZ string_button_inc ,'+INC+'
szZ string_button_dec ,'-dec-'
szZ string_button_pm_classic,'CLASSIC mode'
szZ string_button_pm_levels ,'LEVELS mode'
defLabel labelScore , DEFAULT_LABEL_COLOR, 'SCORE : '
defLabel labelLevel , DEFAULT_LABEL_COLOR, 'LEVEL : '
defLabel labelHiscore , DEFAULT_LABEL_COLOR, 'HI-SCORE : '
defLabel labelChampion , DEFAULT_LABEL_COLOR, 'CHAMPION : '
defLabel labelMenu , DEFAULT_NAVIGATION_COLOR, 'MENU - ',0x27,'ESC',0x27
defLabel labelExit , DEFAULT_NAVIGATION_COLOR, 'PRESS ',0x27,'ESC',0x27,' TO EXIT'
defLabel labelStart , DEFAULT_NAVIGATION_COLOR, 'PRESS ',0x27,'ENTER',0x27,' TO START'
defLabel labelPause , DEFAULT_NAVIGATION_COLOR, 'PAUSE - ',0x27,'SPACE',0x27
defLabel labelApply , DEFAULT_NAVIGATION_COLOR, 'APPLY NAME - ',0x27,'ENTER',0x27
defLabel labelResume , DEFAULT_NAVIGATION_COLOR, 'RESUME - ',0x27,'SPACE',0x27
defLabel labelCongratulations, DEFAULT_LABEL_END_COLOR, 'Congratulations!!! New hi-score is : '
defLabel labelEnterName , DEFAULT_LABEL_END_COLOR, 'You are the champion! Enter your name : '
end if
defNumber numberScore , DEFAULT_LABEL_COLOR, 7
defNumber numberLevel , DEFAULT_LABEL_COLOR, 2
defNumber numberHiscore , DEFAULT_LABEL_COLOR, 7
defLabel labelChampionName, DEFAULT_LABEL_COLOR, 15 dup (0x20)
defNumber numberGameOver , DEFAULT_NUMBER_END_COLOR, 7
edit1 edit_box 65,397,0x0,0x000000,0x000000,0x000000,0x000000,0x80000000,15,hed,mouse_dd,ed_focus,hed_end-hed-1,hed_end-hed-1
@@ -2461,20 +2365,23 @@ hed db '',0
i_end:
hed_end:
rb 256
posLabel:
.xLeft rd 1
.xRight rd 1
.yTop rd 1
.yCenter rd 1
.yBottom rd 1
labelChampionName.valueClassic rb CHAMPION_NAME_LENGTH
labelChampionName.valueLevels rb CHAMPION_NAME_LENGTH
numberHiscore.valueClassic rd 1
numberHiscore.valueLevels rd 1
mouse_dd rd 1
window_style rd 1
cur_level rd 1
cur_level_number rd 1
hi_level rd 1
score rd 1
hi_score_classic rd 1
hi_score_levels rd 1
champion_name_classic rb CHAMPION_NAME_LENGTH
champion_name_levels rb CHAMPION_NAME_LENGTH
snake_dots rb GRID_WIDTH*GRID_HEIGHT*2+3 ; +3 bytes for faster dword copying
snake_direction rd 1
@@ -2502,11 +2409,6 @@ gs_shl16_gs rd 1
gbxm1_shl16_gbxm1 rd 1
gbym1_shl16_gbym1 rd 1
bottom_top_strings rd 1
bottom_middle_strings rd 1
bottom_bottom_strings rd 1
top_strings rd 1
button_x_left rd 1
button_x_right rd 1
button_y_top rd 1