kolibrios/programs/system/scrsaver/scrsaver.asm
Ivan Baravy 3dc60ce167 Add scrsaver: new screen saver program.
Our default screen saver, ss, requires animations to run as its threads.
Therefore you can't set your favorite demo app as screen saver without
embedding it into ss. Vice versa, you can't run embedded animations as
standalone demos. Moreover, ss is a multi-thread app with configuration
window invoked by clicking both mouse buttons at the top right screen
corner (really?).

Scrsaver is a tiny single-thread program, configured via plain text
file, /sys/settings/system.ini. It has no window and runs a separate
executable as screen saver. This is done via primitive protocol:
 * Config file specifies program to run;
 * '@ss' parameter is passed to the program;
 * program launches '/sys/@ss' at exit if '@ss' param is passed.

See /programs/demos/spiral for working example.

git-svn-id: svn://kolibrios.org@7600 a494cfbc-eb01-0410-851d-a64ba20cac60
2019-03-11 21:34:41 +00:00

87 lines
2.0 KiB
NASM

use32
org 0
db 'MENUET01'
dd 0x01,start,i_end,e_end,e_end,0,0
include 'proc32.inc'
include 'macros.inc'
include 'dll.inc'
include 'debug-fdo.inc'
__DEBUG__ = 1
__DEBUG_LEVEL__ = 1
DEFAULT_TIMEOUT_MINS = 15
start:
mcall 68, 11
mcall 40, EVM_KEY + EVM_BACKGROUND + EVM_MOUSE
stdcall dll.Load,@IMPORT
test eax, eax
jnz exit
invoke ini.get_int, ini_file, ini_section, ini_key_timeout, DEFAULT_TIMEOUT_MINS
imul eax, 60*100 ; cs
mov [timeout], eax
; r1647 by Nasarus
mcall 66, 4, 57, 0 ; hot key for {Space}
mcall 66, 4, 28, 0 ; hot key for {Enter}
still:
mcall 23, [timeout]
test eax, eax
jz run_saver
cmp eax, 2 ; key
jnz still
mcall
; r1647 by Nasarus
cmp al, 2 ; hot key?
jnz still ; no hotkey, evenets handling go on
movzx edx, ah
mcall 72, 1, 2 ; transfer key code to active window after interception
jmp still
run_saver:
invoke ini.get_str, ini_file, ini_section, ini_key_program, ini_program_buf, ini_program_buf.size, ini_program_default
; run actual screensaver
mcall 70, f70
cmp eax, 0
jg exit
neg eax
DEBUGF 1, 'Screen saver not found: %d: %s\n', eax, ini_program_buf
exit:
mcall -1
sz ini_file, '/sys/settings/system.ini',0
sz ini_section, 'screensaver',0
sz ini_key_timeout, 'timeout',0
timeout dd ?
sz ini_key_program, 'program',0
sz ini_program_default, '/sys/demos/spiral',0
sz program_params, '@ss',0
f70: ; run
dd 7, 0, program_params, 0, 0
db 0
dd ini_program_buf
align 4
@IMPORT:
library \
libini , 'libini.obj'
import libini, \
ini.get_str, 'ini_get_str', \
ini.get_int, 'ini_get_int'
include_debug_strings
i_end:
align 4
sz ini_program_buf, 1024 dup(?)
rb 0x100
e_end: