189 lines
7.4 KiB
NASM
189 lines
7.4 KiB
NASM
;;===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 [numberScore.value], 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
|
|
mcall 0, , ,[window_style], ,window_title
|
|
test [proc_info.wnd_state], 0x04 ; is rolled up?
|
|
jnz @f
|
|
|
|
call Draw_decorations
|
|
call Draw_first_menu_picture
|
|
stdcall draw.Navigation, labelExit, [posLabel.yTop], 0
|
|
stdcall draw.Navigation, labelStart, [posLabel.yCenter], 0
|
|
call Draw_buttons
|
|
@@:
|
|
mcall 12,2
|
|
.still:
|
|
mcall 10 ; wait for event
|
|
; ok, what an event?
|
|
dec al ; has the window been moved or resized?
|
|
jz .redraw ;
|
|
dec al ; was a key pressed?
|
|
jz .key ;
|
|
|
|
|
|
.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 Save_do_smth_else_and_exit ; if so, jump to quit...
|
|
cmp eax, 0xD0 ; 'play' button?
|
|
je Level_begin
|
|
cmp eax, 0xD1 ; 'exit' button?
|
|
je Save_do_smth_else_and_exit
|
|
cmp eax, 0xD2 ; change play mode button?
|
|
jne @f
|
|
call Change_play_mode
|
|
call Delete_buttons
|
|
call Draw_buttons
|
|
jmp .still ; jump to wait for another event
|
|
@@:
|
|
cmp eax, 0xD3 ; '+INC+' button?
|
|
jne @f
|
|
call Increase_geometry
|
|
jmp .redraw ; jump to wait for another event
|
|
@@:
|
|
cmp eax, 0xD4 ; '-dec-' button?
|
|
jne @f
|
|
call Decrease_geometry
|
|
jmp .redraw ; jump to wait for another event
|
|
@@:
|
|
|
|
jmp .still ; jump to wait for another event
|
|
|
|
|
|
.key: ; a key was pressed
|
|
mcall 2 ; get keycode
|
|
|
|
cmp ah, 0x01 ; Escape
|
|
je Save_do_smth_else_and_exit
|
|
cmp ah, 0x1C ; Enter
|
|
je Level_begin
|
|
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
|
|
|
|
;;---First_menu_mode-----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
;;===Some_functions============================================================================================================
|
|
|
|
Draw_first_menu_picture:
|
|
;;===Draw_first_menu_picture================================================================================================
|
|
|
|
mov ax, 2*0x100+24
|
|
mov cx, 1*0x100+5
|
|
mov edx, [snake_picture_color]
|
|
mov esi, picture_first_menu_snake
|
|
call Draw_picture
|
|
|
|
mov ax, 3*0x100+11
|
|
mov cx, 8*0x100+5
|
|
mov edx, [version_picture_color]
|
|
mov esi, picture_first_menu_version
|
|
call Draw_picture
|
|
|
|
ret
|
|
|
|
;;---Draw_first_menu_picture------------------------------------------------------------------------------------------------
|
|
|
|
Draw_buttons:
|
|
;;===Draw_buttons===========================================================================================================
|
|
stdcall draw.Button, labelButtonPlay, 0x000000D0, [button_x_left], [button_y_top], [button_width_short], [button_height]
|
|
stdcall draw.Button, labelButtonExit, 0x000000D1, [button_x_right], [button_y_top], [button_width_short], [button_height]
|
|
|
|
cmp [play_mode], CLASSIC_MODE
|
|
jne @f
|
|
mov eax, labelButtonClassic
|
|
jmp .drawButtonMode
|
|
@@:
|
|
mov eax, labelButtonLevels
|
|
.drawButtonMode:
|
|
stdcall draw.Button, eax, 0x000000D2, [button_x_left], [button_y_middle], [button_width_long], [button_height]
|
|
|
|
stdcall draw.Button, labelButtonInc, 0x000000D3, [button_x_left], [button_y_bottom], [button_width_short], [button_height]
|
|
stdcall draw.Button, labelButtonDec, 0x000000D4, [button_x_right], [button_y_bottom], [button_width_short], [button_height]
|
|
ret
|
|
;;---Draw_buttons----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
Delete_buttons:
|
|
;;===Delete_buttons========================================================================================================
|
|
|
|
mcall 8,,,0x800000D0
|
|
mcall ,,,0x800000D1
|
|
mcall ,,,0x800000D2
|
|
mcall ,,,0x800000D3
|
|
mcall ,,,0x800000D4
|
|
|
|
ret
|
|
|
|
;;---Delete_buttons--------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
Change_play_mode:
|
|
;;===Change_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 [numberLevel.value], CLASSIC_MODE_FIRST_LEVEL
|
|
mov eax, [numberHiscore.valueClassic]
|
|
mov esi, labelChampionName.valueClassic
|
|
@@:
|
|
cmp [play_mode], LEVELS_MODE
|
|
jne @f
|
|
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
|
|
|
|
;;---Set_first_level_of_play_mode-------------------------------------------------------------------------------------------
|
|
|
|
;;---Some_functions-------------------------------------------------------------------------------------------------------------
|