kolibrios-gitea/programs/system/end/light/end.asm
IgorA 57d4f63fb8 change cursor in t_edit
git-svn-id: svn://kolibrios.org@8532 a494cfbc-eb01-0410-851d-a64ba20cac60
2021-01-10 19:33:26 +00:00

264 lines
5.7 KiB
NASM

; END
; KolibriOS Team 2005-2021
fade equ 0
use32 ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à 
org 0x0 ;  ¤à¥á æ¨ï á ­ã«ï
db 'MENUET01' ; 8-¡ ©â­ë© ¨¤¥­â¨ä¨ª â®à MenuetOS
dd 0x01 ; ¢¥àá¨ï § £®«®¢ª  (¢á¥£¤  1)
dd START ;  ¤à¥á ¯¥à¢®© ª®¬ ­¤ë
dd IM_END ; à §¬¥à ¯à®£à ¬¬ë
dd I_END ; ª®«¨ç¥á⢮ ¯ ¬ïâ¨
dd stacktop ;  ¤à¥á ¢¥à設ë á⥪ 
dd 0x0 ;  ¤à¥á ¡ãä¥à  ¤«ï ¯ à ¬¥â஢
dd cur_dir_path
include 'lang.inc'
include '../../../macros.inc'
include '../../../proc32.inc'
include '../../../dll.inc'
include '../../../KOSfuncs.inc'
include '../../../load_lib.mac'
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
include '../../../gui_patterns.inc'
include "../../../string.inc"
WIN_W equ 440
WIN_H equ 200
BOT_PANEL_H equ 70
CANCEL_BUTTON_ID equ 1+BT_HIDE
HOME_BUTTON_ID equ 2
REBOOT_BUTTON_ID equ 3
POWEROFF_BUTTON_ID equ 4
@use_library
align 4
START:
load_libraries l_libs_start,end_l_libs
inc eax
test eax,eax
jz close
stdcall [init_checkbox], check1
stdcall dll.Init,[init_lib]
invoke ini_get_int,ini_file,asettings,aautosave,0
mov [autosave],eax
dec eax
jnz @f
bts dword [check1.flags],1
@@:
mcall SF_SET_EVENTS_MASK,0x80000027
redraw:
call draw_window
still:
mov al,SF_WAIT_EVENT
mcall ;wait here for event
dec eax
jz redraw
dec eax
jz key
dec eax
jz button
stdcall [check_box_mouse], check1
bt dword [check1.flags],1
jnc @f
mov [autosave],1
jmp still
@@:
mov [autosave],0
jmp still
key:
mov al,SF_GET_KEY
mcall ;get key code
mov al,ah
cmp al,13
je restart
cmp al,19
je checkbox
cmp al,180
je restart_kernel
cmp al,181
je power_off
cmp al,27
jne still
close:
mcall SF_TERMINATE_PROCESS
button:
mcall SF_GET_BUTTON ;get pressed button id
xchg al,ah
dec eax
jz close
dec eax
jz restart_kernel
dec eax
jz restart
dec eax
jnz checkbox
power_off:
push 2
jmp mcall_and_close
restart:
push 3
jmp mcall_and_close
restart_kernel:
push 4
mcall_and_close:
if fade=1
; === FADE IN ===
mov eax, color1
@@:
mov ebx, [eax + 32]
mov [eax], ebx
add eax, 4
cmp eax, color21
jne @b
call draw_window
end if
invoke ini_set_int,ini_file,asettings,aautosave,[autosave]
cmp [autosave],1
jne no_save
if fade=0
mov al,SF_DRAW_TEXT
mcall ,<50,120> ,0x800000cc,label7
end if
mcall SF_FILE,rdsave
test eax,eax
js no_save
mov ecx,eax
mcall SF_SYSTEM,SSF_GET_THREAD_SLOT
mov ecx,eax
@@:
push ecx
mcall SF_WAIT_EVENT_TIMEOUT,100
dec eax
jnz no_red
call draw_window
no_red:
pop ecx
mcall SF_THREAD_INFO,proc_info
cmp [proc_info+50],9
je no_save
jmp @b
no_save:
pop ecx
mcall SF_SYSTEM,SSF_SHUTDOWN
mcall SF_TERMINATE_PROCESS
ret
checkbox:
btc dword [check1.flags],1
jc .1
mov [autosave],1
jmp .draw
.1:
mov [autosave],0
.draw:
stdcall [check_box_draw], check1
jmp still
draw_window:
mcall SF_REDRAW,SSF_BEGIN_DRAW
mov al,SF_GET_SCREEN_SIZE
mcall ;get screen max x & max y
movzx ecx,ax
shr eax,17
shl eax,16
lea ebx,[eax-(WIN_W/2) shl 16+WIN_W-1]
shr ecx,1
shl ecx,16
lea ecx,[ecx-(WIN_H/2) shl 16+WIN_H-1]
xor eax,eax
mov edx, 0x41000000
mcall ;define and draw window
DrawWideRectangle 0, 0, WIN_W, WIN_H, 2, 0xA3A7AA
DrawBar 2, 2, WIN_W-4, WIN_H-BOT_PANEL_H-2, 0x202020
DrawBar 2, WIN_H-BOT_PANEL_H-2, WIN_W-4, BOT_PANEL_H, 0x4B4B4B
WriteText 30, 27, 10010001b, 0xFFFfff, TEXT_TITLE
WriteText 55, 70, 10010000b, 0xFFFfff, TEXT_RDSAVE1
WriteText 55, 86, 10010000b, 0xFFFfff, TEXT_RDSAVE2
DefineButton WIN_W-33, 2, 32, 20, CANCEL_BUTTON_ID, 0
WriteText WIN_W-23, 5, 10000001b, 0xFFFfff, TEXT_CANCEL
stdcall [check_box_draw], check1
macro EndButton x, bgcol, id, but_text, hotkey_text
{
buty equ WIN_H-60
butw equ 116
buth equ 43
DrawWideRectangle x-3, buty-3, butw+6, buth+6, 3, 0x202020
DefineButton x, buty, butw-1, buth-1, id, bgcol
; WriteTextBold -strlen(but_text)*8 + butw / 2 + x, buty+8, 10010000b, 0xFFFfff, but_text
; WriteText -strlen(but_text)*6 + butw / 2 + x, buty+26, 10000000b, 0xFFFfff, hotkey_text
stdcall string.length, but_text
mov ebx,eax
imul ebx,4
neg ebx
add ebx,butw / 2 + x
shl ebx,16
add ebx,buty+8
mcall SF_DRAW_TEXT, , 10010000b shl 24 + 0xFFFfff, but_text
add ebx,1 shl 16
mcall
stdcall string.length, hotkey_text
mov ebx,eax
imul ebx,3
neg ebx
add ebx,butw / 2 + x
shl ebx,16
add ebx,buty+26
mcall SF_DRAW_TEXT, , 10000000b shl 24 + 0xFFFfff, hotkey_text
}
EndButton 20, 0x4E91C5, HOME_BUTTON_ID, TEXT_KERNEL, TEXT_HOME
EndButton 160, 0x55C891, REBOOT_BUTTON_ID, TEXT_REBOOT, TEXT_ENTER
EndButton 300, 0xC75C54, POWEROFF_BUTTON_ID, TEXT_OFF, TEXT_END
mov al,SF_REDRAW
mcall ,SSF_END_DRAW
ret
;---------------------------------------------------------------------
;data
include 'data.inc'
;---------------------------------------------------------------------
IM_END:
;---------------------------------------------------------------------
align 4
proc_info rb 1024
autosave rd 1
;---------------------------------------------------------------------
cur_dir_path rb 4096
library_path rb 4096
;---------------------------------------------------------------------
align 32
rb 4096
stacktop:
I_END: ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë